summaryrefslogtreecommitdiffstats
path: root/krusader/main.cpp
blob: cecfe8915977eca5c8b999aba3f25ba9cd4b381c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/***************************************************************************
                                main.cpp
                             -------------------
    copyright            : (C) 2000 by Shie Erlich & Rafi Yanai
    e-mail               : krusader@users.sourceforge.net
    web site             : http://krusader.sourceforge.net
 ---------------------------------------------------------------------------
  Description 
 ***************************************************************************

  A

     db   dD d8888b. db    db .d8888.  .d8b.  d8888b. d88888b d8888b.
     88 ,8P' 88  `8D 88    88 88'  YP d8' `8b 88  `8D 88'     88  `8D
     88,8P   88oobY' 88    88 `8bo.   88ooo88 88   88 88ooooo 88oobY'
     88`8b   88`8b   88    88   `Y8b. 88~~~88 88   88 88~~~~~ 88`8b
     88 `88. 88 `88. 88b  d88 db   8D 88   88 88  .8D 88.     88 `88.
     YP   YD 88   YD ~Y8888P' `8888Y' YP   YP Y8888D' Y88888P 88   YD

                                                     S o u r c e    F i l e

 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

// KDE includes
#include <tdecmdlineargs.h>
#include <tdeaboutdata.h>
#include <tdelocale.h>
#include <kstandarddirs.h>
#include <ksplashscreen.h>
#include <unistd.h>
#include <signal.h>
#include <tqeventloop.h>

// Krusader includes
#include "krusader.h"
#include "krslots.h"
#include "krusaderapp.h"
#include "defaults.h"
#include <dcopclient.h>
#include <tdestartupinfo.h>
#include <stdlib.h>

static const char *description =
	I18N_NOOP("Krusader\nTwin-Panel File Manager for TDE");
// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE

static TDECmdLineOptions options[] =
{
  { "left <path>", I18N_NOOP("Start left panel at <path>"), 0},
  { "right <path>", I18N_NOOP("Start right panel at <path>"), 0},
  { "profile <panel-profile>", I18N_NOOP("Load this profile on startup"), 0},
  { 0, 0, 0 }
  // INSERT YOUR COMMANDLINE OPTIONS HERE
};

static void sigterm_handler(int i)
{
  fprintf(stderr,"Signal: %d\n",i);

  TQApplication::eventLoop()->wakeUp();
  TDEApplication::exit( - 15 );
}

int main(int argc, char *argv[]) {

// ============ begin icon-stuff ===========
// If the user has no icon specified over the commandline we set up uor own.
// this is acording to the users privileges. The icons are in Krusader::privIcon()

  bool hasIcon = false;
  int i = 0;
  char * myArgv[argc+2];

 // if no --miniicon is given, --icon is used. So we don't need to check for --miniicon separately
  for ( i = 0; i < argc; ++i ) {
    if ( strstr(argv[ i ], "-icon") != 0 ) // important: just one dash because both can appear!
     hasIcon = true;
  }

  static const char* const icon_text="--icon";
  const char* icon_name=Krusader::privIcon();
  char addedParams[strlen(icon_text)+strlen(icon_name)+2];

  if ( ! hasIcon ) {
    for ( i = 0; i < argc; ++i )
      myArgv[ i ] = argv[ i ];

    strcpy(addedParams,icon_text);
    strcpy(addedParams+strlen(icon_text)+1,icon_name);

    myArgv[ argc ] = addedParams;
    myArgv[ ++argc ] = addedParams+strlen(icon_text)+1;
    myArgv[ ++argc ] = 0;

    argv = myArgv;
  }
// ============ end icon-stuff ===========

  // ABOUT data information
#ifdef RELEASE_NAME
  TQString versionName = TQString("%1 \"%2\"").arg(VERSION).arg(RELEASE_NAME);
#else
  TQString versionName = VERSION;
#endif
  TDEAboutData aboutData( "krusader", ( geteuid() ? I18N_NOOP("Krusader") :
                        I18N_NOOP("Krusader - ROOT PRIVILEGES")),
    versionName.latin1(), description, TDEAboutData::License_GPL,
    "(c) 2000-2003, Shie Erlich, Rafi Yanai\n(c) 2004-2007, Krusader Krew",
    I18N_NOOP("Feedback\nhttp://www.krusader.org/phpBB/\n\n"
              "IRC\nserver: irc.freenode.net, channel: #krusader"),
    "http://www.krusader.org",
    "krusader@users.sourceforge.net");

  aboutData.addAuthor("Rafi Yanai","Author", "yanai@users.sourceforge.net");
  aboutData.addAuthor("Shie Erlich","Author", "erlich@users.sourceforge.net");
  aboutData.addAuthor("Karai Csaba", "Developer", "ckarai@users.sourceforge.net", 0);
  aboutData.addAuthor("Heiner Eichmann","Developer", "h.eichmann@gmx.de", 0);  
  aboutData.addAuthor("Jonas Baehr", "Developer", "jonas.baehr@web.de", 0);
  aboutData.addAuthor("Dirk Eschler", "Webmaster and i18n coordinator", "deschler@users.sourceforge.net", 0);
  aboutData.addAuthor("Frank Schoolmeesters", "Documentation and marketing coordinator", "frank_schoolmeesters@yahoo.com", 0);
  aboutData.addAuthor("Richard Holt", "Documentation & Proofing", "richard.holt@gmail.com", 0);
  aboutData.addAuthor("Matej Urbancic", " Marketing & Product Research", "matej.urban@gmail.com", 0);
  aboutData.addCredit("Václav Juza", "QA, bug-hunting, patches and general help", "vaclavjuza@gmail.com", 0);
  aboutData.addCredit("Jiri Palecek", "QA, bug-hunting, patches and general help", "jpalecek@web.de", 0);
  aboutData.addCredit("Andrew Neupokoev", "Killer Logo and Icons for Krusader (contest winner)", "doom-blue@yandex.ru", 0);
  aboutData.addCredit("The UsefulArts Organization", "Icon for krusader", "mail@usefularts.rg", 0);
  aboutData.addCredit("Gábor Lehel", "Viewer module for 3rd Hand", "illissius@gmail.com", 0);
  aboutData.addCredit("Mark Eatough", "Handbook Proof-Reader", "markeatough@yahoo.com", 0);
  aboutData.addCredit("Jan Halasa", "The old Bookmark Module", "xhalasa@fi.muni.cz", 0);
  aboutData.addCredit("Hans Loeffler", "Dir history button", 0, 0);
  aboutData.addCredit("Szombathelyi György", "ISO TDEIO slave", 0, 0);
  aboutData.addCredit("Jan Willem van de Meent (Adios)", "Icons for Krusader", "janwillem@lorentz.leidenuniv.nl", 0);
  aboutData.addCredit("Mikolaj Machowski", "Usability and QA", "<mikmach@wp.pl>", 0);
  aboutData.addCredit("Cristi Dumitrescu","QA, bug-hunting, patches and general help","cristid@chip.ro",0);
  aboutData.addCredit("Aurelien Gateau","patch for KViewer","aurelien.gateau@free.fr",0);
  aboutData.addCredit("Milan Brabec","the first patch ever !","mbrabec@volny.cz",0);
  aboutData.addCredit("Asim Husanovic","Bosnian translation","asim@megatel.ba",0);
  aboutData.addCredit("Doutor Zero","Brazilian Portuguese","doutor.zero@gmail.com",0);
  aboutData.addCredit("Milen Ivanov","Bulgarian translation","milen.ivanov@abv.bg",0);
  aboutData.addCredit("Quim Perez","Catalan translation","noguer@osona.com",0);
  aboutData.addCredit("Jinghua Luo","Chinese Simplified translation","luojinghua@msn.com",0);
  aboutData.addCredit("Mitek","Old Czech translation","mitek@email.cz",0);
  aboutData.addCredit("Martin Sixta","Old Czech translation","lukumo84@seznam.cz",0);
  aboutData.addCredit("Vaclav Juza","Czech translation","VaclavJuza@gmail.com",0);
  aboutData.addCredit("Anders Bruun Olsen", "Old Danish translation", "anders@bruun-olsen.net", 0);
  aboutData.addCredit("Peter H. Sorensen", "Danish translation", "peters@skydebanen.net", 0);
  aboutData.addCredit("Frank Schoolmeesters","Dutch translation","frank_schoolmeesters@yahoo.com",0);
  aboutData.addCredit("Rene-Pierre Lehmann","Old French translation","ripi@lepi.org",0);
  aboutData.addCredit("David Guillerm","French translation","dguillerm@gmail.com",0);
  aboutData.addCredit("Christoph Thielecke","Old German translation","crissi99@gmx.de",0);
  aboutData.addCredit("Dirk Eschler", "German translation", "deschler@users.sourceforge.net", 0);
  aboutData.addCredit("Spiros Georgaras", "Greek translation", "sngeorgaras@gmail.com", 0);
  aboutData.addCredit("Kukk Zoltan","Old Hungarian translation","kukkzoli@freemail.hu",0);
  aboutData.addCredit("Arpad Biro","Hungarian translation","biro_arpad@yahoo.com",0);
  aboutData.addCredit("Giuseppe Bordoni", "Italian translation", "geppo@geppozone.com", 0);
  aboutData.addCredit("Hideki Kimura", "Japanese translation", "hangyo1973@gmail.com", 0);
  aboutData.addCredit("UTUMI Hirosi", "Old Japanese translation", "utuhiro@mx12.freecom.ne.jp", 0);
  aboutData.addCredit("Dovydas Sankauskas", "Lithuanian translation", "laisve@gmail.com", 0);
  aboutData.addCredit("Bruno Queiros", "Portuguese translation", "brunoqueiros@portugalmail.com", 0);
  aboutData.addCredit("Lukasz Janyst","Old Polish translation","ljan@wp.pl",0);
  aboutData.addCredit("Pawel Salawa","Polish translation","boogie@myslenice.one.pl",0);
  aboutData.addCredit("Tomek Grzejszczyk","Polish translation","tgrzej@onet.eu",0);
  aboutData.addCredit("Dmitry A. Bugay","Russian translation","sam@vhnet.ru",0);
  aboutData.addCredit("Dmitry Chernyak","Old Russian translation","chernyak@mail.ru",0);
  aboutData.addCredit("Sasa Tomic","Serbian translation","stomic@gmx.net",0);
  aboutData.addCredit("Zdenko Podobna","Slovak translation","zdpo@mailbox.sk",0);
  aboutData.addCredit("Matej Urbancic","Slovenian translation","matej.urban@gmail.com",0);
  aboutData.addCredit("Rafael Munoz","Old Spanish translation","muror@hotpop.com",0);
  aboutData.addCredit("Alejandro Araiza Alvarado","Spanish translation","mebrelith@gmail.com",0);
  aboutData.addCredit("Erik Johanssen","Old Swedish translation","erre@telia.com",0);
  aboutData.addCredit("Anders Linden","Old Swedish translation","connyosis@gmx.net",0);
  aboutData.addCredit("Peter Landgren","Swedish translation","peter.talken@telia.com",0);
  aboutData.addCredit("Bekir Sonat","Turkish translation","bekirsonat@kde.org.tr",0);
  aboutData.addCredit("Ivan Petrouchtchak","Ukrainian translation","connyosis@gmx.net",0);

  // Command line arguments ...
  TDECmdLineArgs::init( argc, argv, &aboutData );
  TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  // check for command line arguments

  // create the application
  KrusaderApp app;

  {
    TDEConfigGroupSaver saver(app.config(), "Look&Feel");
    bool singleInstanceMode = app.config()->readBoolEntry( "Single Instance Mode", _SingleInstanceMode );

    // register with the dcop server
    DCOPClient* client = TDEApplication::kApplication() ->dcopClient();
    if ( !client->attach() )
       exit( 0 );
    TQCString regName = client->registerAs( TDEApplication::kApplication() ->name(), !singleInstanceMode );
    if( singleInstanceMode && regName != TDEApplication::kApplication()->name() ) {
      fprintf( stderr, "%s", i18n( "Application already running!\n" ).ascii() );

      DCOPClient::mainClient()->send( TDEApplication::kApplication() ->name(), "Krusader-Interface",
                                    "moveToTop()", TQByteArray() );
      TDEStartupInfo::appStarted();

      return 1;
    }
  }
    
  // splash screen - if the user wants one
  KSplashScreen *splash = 0;
  { // don't remove bracket
  TDEConfigGroupSaver saver(app.config(), "Look&Feel");
  if (app.config()->readBoolEntry( "Show splashscreen", _ShowSplashScreen )) {
  	TQString splashFilename = locate( "data", "krusader/splash.png" );
  	TQPixmap pixmap( splashFilename );
  	if (!pixmap.isNull()) {
    		splash = new KSplashScreen( pixmap );
    		splash->show();
  	}
  }
  } // don't remove bracket

  Krusader krusader;
  
  // catching SIGTERM, SIGHUP, SIGQUIT
  signal(SIGTERM,sigterm_handler);
  signal(SIGPIPE,sigterm_handler);
  signal(SIGHUP,sigterm_handler);

  // make sure we receive X's focus in/out events
  TQObject::connect(&app, TQT_SIGNAL(windowActive()), krusader.slot, TQT_SLOT(windowActive()));
  TQObject::connect(&app, TQT_SIGNAL(windowInactive()), krusader.slot, TQT_SLOT(windowInactive()));

  // and set krusader to be the main widget in it
  app.setMainWidget(&krusader);
  
  // hide splashscreen
  if (splash) {
    splash->finish( &krusader );
    delete splash;
  }

  // let's go.
  return app.exec();
}