00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 static const char *kpilot_id =
00031 "$Id: kpilot.cc,v 1.80.4.12 2003/03/22 20:47:12 adridg Exp $";
00032
00033
00034 #include "options.h"
00035
00036 #include <qfile.h>
00037 #include <qptrlist.h>
00038 #include <qstring.h>
00039 #include <qvbox.h>
00040 #include <qtimer.h>
00041
00042 #include <kjanuswidget.h>
00043
00044 #ifndef _KURL_H_
00045 #include <kurl.h>
00046 #endif
00047 #ifndef _KMESSAGEBOX_H_
00048 #include <kmessagebox.h>
00049 #endif
00050 #ifndef _KSTATUSBAR_H_
00051 #include <kstatusbar.h>
00052 #endif
00053 #ifndef _KCONFIG_H_
00054 #include <kconfig.h>
00055 #endif
00056 #ifndef _KWIN_H_
00057 #include <kwin.h>
00058 #endif
00059 #ifndef _KCOMBOBOX_H_
00060 #include <kcombobox.h>
00061 #endif
00062 #ifndef _KMENUBAR_H_
00063 #include <kmenubar.h>
00064 #endif
00065 #ifndef _KSTDDIRS_H_
00066 #include <kstddirs.h>
00067 #endif
00068 #ifndef _KABOUTDATA_H_
00069 #include <kaboutdata.h>
00070 #endif
00071 #ifndef _KCMDLINEARGS_H_
00072 #include <kcmdlineargs.h>
00073 #endif
00074 #ifndef _KICONLOADER_H_
00075 #include <kiconloader.h>
00076 #endif
00077 #ifndef _KDEBUG_H_
00078 #include <kdebug.h>
00079 #endif
00080 #ifndef _KACTION_H_
00081 #include <kaction.h>
00082 #endif
00083 #ifndef _KSTDACTION_H_
00084 #include <kstdaction.h>
00085 #endif
00086 #ifndef _KUNIQUEAPP_H_
00087 #include <kuniqueapp.h>
00088 #endif
00089 #include <kkeydialog.h>
00090 #include <kedittoolbar.h>
00091
00092 #include <kprogress.h>
00093
00094
00095 #include "kpilotConfigDialog.h"
00096 #include "kpilotConfig.h"
00097
00098 #include "pilotComponent.h"
00099
00100 #include "addressWidget.h"
00101 #include "memoWidget.h"
00102 #include "fileInstallWidget.h"
00103 #include "logWidget.h"
00104
00105 #include "conduitConfigDialog.h"
00106
00107 #ifndef _KPILOT_PILOTDAEMON_H
00108 #include "pilotDaemonDCOP.h"
00109 #endif
00110
00111 #ifndef __PILOTDAEMONDCOP_STUB__
00112 #include "pilotDaemonDCOP_stub.h"
00113 #endif
00114
00115 #include "kpilot.moc"
00116
00117 class KPilotInstaller::KPilotPrivate
00118 {
00119 public:
00120 typedef QList<PilotComponent> ComponentList;
00121
00122 private:
00123 ComponentList fPilotComponentList;
00124
00125 public:
00126 ComponentList &list() { return fPilotComponentList; } ;
00127 } ;
00128
00129 KPilotInstaller::KPilotInstaller() :
00130 KMainWindow(0),
00131 DCOPObject("KPilotIface"),
00132 fDaemonStub(new PilotDaemonDCOP_stub("kpilotDaemon",
00133 "KPilotDaemonIface")),
00134 fP(new KPilotPrivate),
00135 fMenuBar(0L),
00136 fToolBar(0L),
00137 fQuitAfterCopyComplete(false),
00138 fManagingWidget(0L),
00139 fKillDaemonOnExit(false),
00140 fDaemonWasRunning(true),
00141 fStatus(Startup),
00142 fFileInstallWidget(0L),
00143 fLogWidget(0L)
00144 {
00145 FUNCTIONSETUP;
00146
00147 readConfig();
00148 setupWidget();
00149
00150 #ifdef DEBUG
00151 PilotRecord::allocationInfo();
00152 #endif
00153
00154
00155 (void) kpilot_id;
00156 }
00157
00158 KPilotInstaller::~KPilotInstaller()
00159 {
00160 FUNCTIONSETUP;
00161 killDaemonIfNeeded();
00162 delete fDaemonStub;
00163 #ifdef DEBUG
00164 PilotRecord::allocationInfo();
00165 #endif
00166 }
00167
00168 void KPilotInstaller::killDaemonIfNeeded()
00169 {
00170 FUNCTIONSETUP;
00171 if (fKillDaemonOnExit)
00172 {
00173 if (!fDaemonWasRunning)
00174 {
00175 #ifdef DEBUG
00176 DEBUGKPILOT << fname << ": Killing daemon." << endl;
00177 #endif
00178
00179 getDaemon().quitNow();
00180 }
00181 }
00182 }
00183
00184 void KPilotInstaller::startDaemonIfNeeded()
00185 {
00186 FUNCTIONSETUP;
00187
00188 QString daemonError;
00189 QCString daemonDCOP;
00190 int daemonPID;
00191
00192 QString s = getDaemon().statusString();
00193
00194 #ifdef DEBUG
00195 DEBUGKPILOT << fname << ": Daemon status is " << s << endl;
00196 #endif
00197
00198 if ((s.isNull()) || (!getDaemon().ok()))
00199 {
00200 #ifdef DEBUG
00201 DEBUGKPILOT << fname
00202 << ": Daemon not responding, trying to start it."
00203 << endl;
00204 #endif
00205 fDaemonWasRunning = false;
00206 }
00207 else
00208 {
00209 fDaemonWasRunning = true;
00210 }
00211
00212 if (!fDaemonWasRunning && KApplication::startServiceByDesktopName(
00213 CSL1("kpilotdaemon"),
00214 QString::null, &daemonError, &daemonDCOP, &daemonPID
00215 #if (KDE_VERSION >= 220)
00216
00217 , "0"
00218 #endif
00219 ))
00220 {
00221 kdError() << k_funcinfo << ": Can't start daemon : " << daemonError << endl;
00222 }
00223 else
00224 {
00225 #ifdef DEBUG
00226 s = getDaemon().statusString();
00227 DEBUGKPILOT << fname << ": Daemon status is " << s << endl;
00228 #endif
00229 }
00230 }
00231
00232 void KPilotInstaller::readConfig()
00233 {
00234 FUNCTIONSETUP;
00235
00236 KPilotConfigSettings & c = KPilotConfig::getConfig();
00237 fKillDaemonOnExit = c.getKillDaemonOnExit();
00238
00239 (void) PilotAppCategory::setupPilotCodec(c.getEncoding());
00240 }
00241
00242
00243 void KPilotInstaller::setupWidget()
00244 {
00245 FUNCTIONSETUP;
00246
00247 #ifdef DEBUG
00248 DEBUGKPILOT << fname << ": Creating central widget." << endl;
00249 #endif
00250
00251 setCaption(CSL1("KPilot"));
00252 setMinimumSize(500, 405);
00253
00254
00255 fManagingWidget = new KJanusWidget(this,"mainWidget",
00256 KJanusWidget::IconList);
00257 fManagingWidget->setMinimumSize(500, 330);
00258 fManagingWidget->show();
00259 setCentralWidget(fManagingWidget);
00260
00261 initIcons();
00262 initMenu();
00263 initComponents();
00264
00265 createGUI(CSL1("kpilotui.rc"), false);
00266 #ifdef DEBUG
00267 DEBUGKPILOT << fname
00268 << ": Got XML from "
00269 << xmlFile() << " and " << localXMLFile() << endl;
00270 #endif
00271 setAutoSaveSettings();
00272 }
00273
00274
00275 void KPilotInstaller::initComponents()
00276 {
00277 FUNCTIONSETUP;
00278
00279 QString defaultDBPath = KPilotConfig::getDefaultDBPath();
00280
00281 #ifdef DEBUG
00282 DEBUGKPILOT << fname << ": Creating component pages." << endl;
00283 #endif
00284
00285 QString pixfile;
00286 QWidget *w;
00287
00288 #define VIEWICON(a) KGlobal::dirs()->findResource("data",(a))
00289
00290 #define ADDICONPAGE(a,b) pixfile = VIEWICON(b); \
00291 w = getManagingWidget()->addVBoxPage(a,QString::null, \
00292 (pixfile.isEmpty() ? QPixmap() : QPixmap(pixfile))) ;
00293
00294 ADDICONPAGE(i18n("HotSync"),CSL1("kpilot/kpilot-hotsync.png"));
00295 fLogWidget = new LogWidget(w);
00296 addComponentPage(fLogWidget, i18n("HotSync"));
00297 fLogWidget->setShowTime(true);
00298
00299
00300 ADDICONPAGE(i18n("Memo Viewer"),CSL1("kpilot/kpilot-knotes.png"));
00301 addComponentPage(new MemoWidget(w, defaultDBPath),
00302 i18n("Memo Viewer"));
00303
00304 ADDICONPAGE(i18n("Address Viewer"),CSL1("kpilot/kpilot-address.png"));
00305 addComponentPage(new AddressWidget(w,defaultDBPath),
00306 i18n("Address Viewer"));
00307
00308 ADDICONPAGE(i18n("File Installer"),CSL1("kpilot/kpilot-fileinstaller.png"));
00309 fFileInstallWidget = new FileInstallWidget(
00310 w,defaultDBPath);
00311 addComponentPage(fFileInstallWidget, i18n("File Installer"));
00312
00313 #undef ADDICONPAGE
00314 #undef VIEWICON
00315
00316 QTimer::singleShot(500,this,SLOT(initializeComponents()));
00317 }
00318
00319
00320
00321 void KPilotInstaller::initIcons()
00322 {
00323 FUNCTIONSETUP;
00324
00325 }
00326
00327
00328
00329 void KPilotInstaller::slotSelectComponent(PilotComponent * c)
00330 {
00331 FUNCTIONSETUP;
00332
00333 QWidget *p = static_cast <QWidget *>(c);
00334 if (!p) { kdWarning() << k_funcinfo << ": Not a widget." << endl; return;}
00335
00336 QObject *o = p->parent();
00337 if (!o) { kdWarning() << k_funcinfo << ": No parent." << endl; return; }
00338
00339 QWidget *parent = dynamic_cast<QWidget *>(o);
00340 if (!parent) { kdWarning() << k_funcinfo << ": No widget parent." << endl; return; }
00341
00342 int index = fManagingWidget->pageIndex(parent);
00343
00344 if (index < 0)
00345 {
00346 kdWarning() << k_funcinfo << ": Index " << index << endl;
00347 return;
00348 }
00349
00350 fManagingWidget->showPage(index);
00351 }
00352
00353
00354
00355
00356 void KPilotInstaller::slotBackupRequested()
00357 {
00358 FUNCTIONSETUP;
00359 setupSync(PilotDaemonDCOP::Backup,
00360 i18n("Backing up Pilot. ") +
00361 i18n("Please press the HotSync button."));
00362 }
00363
00364 void KPilotInstaller::slotRestoreRequested()
00365 {
00366 FUNCTIONSETUP;
00367 setupSync(PilotDaemonDCOP::Restore,
00368 i18n("Restoring Pilot. ") +
00369 i18n("Please press the HotSync button."));
00370 }
00371
00372 void KPilotInstaller::slotHotSyncRequested()
00373 {
00374 FUNCTIONSETUP;
00375 setupSync(PilotDaemonDCOP::HotSync,
00376 i18n("HotSyncing. ") +
00377 i18n("Please press the HotSync button."));
00378 }
00379
00380 #if 0
00381 void KPilotInstaller::slotFastSyncRequested()
00382 {
00383 FUNCTIONSETUP;
00384 setupSync(PilotDaemonDCOP::FastSync,
00385 i18n("FastSyncing. ") +
00386 i18n("Please press the HotSync button."));
00387 }
00388 #endif
00389
00390 void KPilotInstaller::slotListSyncRequested()
00391 {
00392 FUNCTIONSETUP;
00393 setupSync(PilotDaemonDCOP::Test,
00394 QString::fromLatin1("Listing Pilot databases."));
00395 }
00396
00397 ASYNC KPilotInstaller::daemonStatus(int i)
00398 {
00399 FUNCTIONSETUP;
00400 #ifdef DEBUG
00401 DEBUGKPILOT << fname << ": Received daemon message " << i << endl;
00402 #endif
00403
00404 switch(i)
00405 {
00406 case KPilotDCOP::EndOfHotSync :
00407 componentPostSync();
00408 break;
00409 default :
00410 kdWarning() << k_funcinfo << ": Unhandled status message " << i << endl;
00411 break;
00412 }
00413 }
00414
00415 bool KPilotInstaller::componentPreSync()
00416 {
00417 FUNCTIONSETUP;
00418
00419 QString reason;
00420 QString rprefix(i18n("Can't start a Sync now. %1"));
00421
00422 for (fP->list().first();
00423 fP->list().current(); fP->list().next())
00424 {
00425 #ifdef DEBUG
00426 DEBUGKPILOT << fname
00427 << ": Pre-sync for builtin "
00428 << fP->list().current()->name() << endl;
00429 #endif
00430 if (!fP->list().current()->preHotSync(reason))
00431 break;
00432 }
00433
00434 if (!reason.isNull())
00435 {
00436 KMessageBox::sorry(this,
00437 rprefix.arg(reason),
00438 i18n("Can't start Sync"));
00439 return false;
00440 }
00441 return true;
00442 }
00443
00444 void KPilotInstaller::componentPostSync()
00445 {
00446 FUNCTIONSETUP;
00447
00448 for (fP->list().first();
00449 fP->list().current(); fP->list().next())
00450 {
00451 #ifdef DEBUG
00452 DEBUGKPILOT << fname
00453 << ": Post-sync for builtin "
00454 << fP->list().current()->name() << endl;
00455 #endif
00456 fP->list().current()->postHotSync();
00457 }
00458 }
00459
00460 void KPilotInstaller::setupSync(int kind, const QString & message)
00461 {
00462 FUNCTIONSETUP;
00463
00464 if (!componentPreSync())
00465 {
00466 return;
00467 }
00468 if (!message.isEmpty())
00469 {
00470 QString m(message);
00471 if (fLogWidget)
00472 {
00473 fLogWidget->logMessage(m);
00474 }
00475 }
00476 getDaemon().requestSync(kind);
00477 }
00478
00479
00480 void KPilotInstaller::closeEvent(QCloseEvent * e)
00481 {
00482 FUNCTIONSETUP;
00483
00484 quit();
00485 e->accept();
00486 }
00487
00488 void KPilotInstaller::initMenu()
00489 {
00490 FUNCTIONSETUP;
00491
00492 KAction *p;
00493
00494
00495 p = new KAction(i18n("&HotSync"), CSL1("hotsync"), 0,
00496 this, SLOT(slotHotSyncRequested()),
00497 actionCollection(), "file_hotsync");
00498 #if 0
00499 p = new KAction(i18n("&FastSync"), CSL1("fastsync"), 0,
00500 this, SLOT(slotHotSyncRequested()),
00501 actionCollection(), "file_fastsync");
00502 #endif
00503 #ifdef DEBUG
00504 p = new KAction(TODO_I18N("List only"),CSL1("list"),0,
00505 this,SLOT(slotListSyncRequested()),
00506 actionCollection(), "file_list");
00507 #endif
00508 p = new KAction(i18n("&Backup"), CSL1("backup"), 0,
00509 this, SLOT(slotBackupRequested()),
00510 actionCollection(), "file_backup");
00511 p = new KAction(i18n("&Restore"), CSL1("restore"), 0,
00512 this, SLOT(slotRestoreRequested()),
00513 actionCollection(), "file_restore");
00514 p = KStdAction::quit(this, SLOT(quit()), actionCollection());
00515
00516
00517
00518
00519 #if KDE_VERSION >= 0x30180
00520 createStandardStatusBarAction();
00521 #endif
00522
00523 #if KDE_VERSION >= 0x30080
00524 setStandardToolBarMenuEnabled(true);
00525 #else
00526 m_toolbarAction =
00527 KStdAction::showToolbar(this, SLOT(optionsShowToolbar()),
00528 actionCollection());
00529 #endif
00530
00531 p = KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()),
00532 actionCollection());
00533 p = KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()),
00534 actionCollection());
00535 p = KStdAction::preferences(this, SLOT(slotConfigureKPilot()),
00536 actionCollection());
00537 p = new KAction(i18n("C&onfigure Conduits..."), CSL1("configure"), 0, this,
00538 SLOT(slotConfigureConduits()), actionCollection(),
00539 "options_configure_conduits");
00540 }
00541
00542 void KPilotInstaller::fileInstalled(int)
00543 {
00544 FUNCTIONSETUP;
00545 }
00546
00547 void KPilotInstaller::quit()
00548 {
00549 FUNCTIONSETUP;
00550
00551 for (fP->list().first();
00552 fP->list().current(); fP->list().next())
00553 {
00554 QString reason;
00555 if (!fP->list().current()->preHotSync(reason))
00556 {
00557 kdWarning() << k_funcinfo
00558 << ": Couldn't save "
00559 << fP->list().current()->name()
00560 << endl;
00561 }
00562 }
00563
00564 killDaemonIfNeeded();
00565 kapp->quit();
00566 }
00567
00568 void KPilotInstaller::addComponentPage(PilotComponent * p,
00569 const QString & name)
00570 {
00571 FUNCTIONSETUP;
00572
00573 if (!p)
00574 {
00575 kdWarning() << k_funcinfo
00576 << ": Adding NULL component?" << endl;
00577 return;
00578 }
00579
00580 #ifdef DEBUG
00581 DEBUGKPILOT << fname
00582 << ": Adding component @"
00583 << (int) p << " called " << p->name("(none)") << endl;
00584 #endif
00585
00586 fP->list().append(p);
00587
00588
00589
00590
00591
00592
00593
00594 const char *componentname = p->name("(none)");
00595 char *actionname = 0L;
00596
00597 if (strncmp(componentname, "component_", 10) == 0)
00598 {
00599 actionname = new char[strlen(componentname) - 10 + 8];
00600
00601 strcpy(actionname, "view_");
00602 strcat(actionname, componentname + 10);
00603 }
00604 else
00605 {
00606 actionname = new char[8 + strlen(componentname)];
00607
00608 strcpy(actionname, "view_");
00609 strcat(actionname, componentname);
00610 }
00611
00612 #ifdef DEBUG
00613 DEBUGKPILOT << fname
00614 << ": Using component action name "
00615 << name << " for " << actionname << endl;
00616 #endif
00617
00618 KToggleAction *pt =
00619 new KToggleAction(name, 0,
00620 p, SLOT(slotShowComponent()),
00621 actionCollection(), actionname);
00622
00623 pt->setExclusiveGroup(CSL1("view_menu"));
00624
00625 connect(p, SIGNAL(showComponent(PilotComponent *)),
00626 this, SLOT(slotSelectComponent(PilotComponent *)));
00627 }
00628
00629 void KPilotInstaller::initializeComponents()
00630 {
00631 FUNCTIONSETUP;
00632
00633 for (PilotComponent *p = fP->list().first();
00634 p ; p = fP->list().next())
00635 {
00636 p->initialize();
00637 }
00638 }
00639
00640
00641 #if KDE_VERSION >= 0x30080
00642
00643
00644 void KPilotInstaller::optionsShowToolbar()
00645 {
00646 }
00647 #else
00648 void KPilotInstaller::optionsShowToolbar()
00649 {
00650 FUNCTIONSETUP;
00651 if (m_toolbarAction->isChecked())
00652 {
00653 toolBar()->show();
00654 }
00655 else
00656 {
00657 toolBar()->hide();
00658 }
00659
00660 kapp->processEvents();
00661 resizeEvent(0);
00662 }
00663 #endif
00664
00665
00666 void KPilotInstaller::optionsConfigureKeys()
00667 {
00668 FUNCTIONSETUP;
00669 KKeyDialog::configureKeys(actionCollection(), xmlFile());
00670 }
00671
00672 void KPilotInstaller::optionsConfigureToolbars()
00673 {
00674 FUNCTIONSETUP;
00675
00676 #if KDE_VERSION >= 0x030100
00677
00678 saveMainWindowSettings( KGlobal::config(), autoSaveGroup() );
00679 #endif
00680 KEditToolbar dlg(actionCollection());
00681 connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(newToolbarConfig()));
00682 dlg.exec();
00683 }
00684
00685 void KPilotInstaller::slotNewToolbarConfig()
00686 {
00687
00688 createGUI();
00689 #if KDE_VERSION >= 0x030180
00690 applyMainWindowSettings( KGlobal::config(), autoSaveGroup() );
00691 #endif
00692 }
00693
00694 void KPilotInstaller::slotConfigureKPilot()
00695 {
00696 FUNCTIONSETUP;
00697
00698
00699
00700
00701 int rememberedSync = getDaemon().nextSyncType();
00702 getDaemon().requestSync(0);
00703
00704 KPilotConfig::getConfig().reparseConfiguration();
00705 KPilotConfigDialog *options = new KPilotConfigDialog(this,
00706 "configDialog", true);
00707
00708 if (!options)
00709 {
00710 kdError() << k_funcinfo
00711 << ": Can't allocate KPilotOptions object" << endl;
00712 getDaemon().requestSync(rememberedSync);
00713 return;
00714 }
00715
00716 options->exec();
00717
00718 if (options->result())
00719 {
00720 #ifdef DEBUG
00721 DEBUGKPILOT << fname << ": Updating link." << endl;
00722 #endif
00723
00724 KPilotConfig::getConfig().sync();
00725 readConfig();
00726
00727
00728
00729
00730 getDaemon().reloadSettings();
00731
00732
00733
00734
00735 for (fP->list().first();
00736 fP->list().current();
00737 fP->list().next())
00738 {
00739 fP->list().current()->initialize();
00740 }
00741 }
00742
00743 KPILOT_DELETE(options);
00744 getDaemon().requestSync(rememberedSync);
00745
00746 #ifdef DEBUG
00747 DEBUGKPILOT << fname << ": Done with options." << endl;
00748 #endif
00749 }
00750
00751 void KPilotInstaller::slotConfigureConduits()
00752 {
00753 FUNCTIONSETUP;
00754
00755 ConduitConfigDialog *conSetup = 0L;
00756
00757 conSetup = new ConduitConfigDialog(this,0L,true);
00758 int r = conSetup->exec();
00759 if (r)
00760 {
00761 KPilotConfig::getConfig().sync();
00762 getDaemon().reloadSettings();
00763 }
00764 delete conSetup;
00765 }
00766
00767
00768 const char *KPilotInstaller::version(int kind)
00769 {
00770 FUNCTIONSETUP;
00771
00772
00773
00774 if (kind)
00775 {
00776 return ::kpilot_id;
00777 }
00778 else
00779 {
00780 return "KPilot v" KPILOT_VERSION;
00781 }
00782 }
00783
00784
00785
00786
00787
00788
00789 static KCmdLineOptions kpilotoptions[] = {
00790 {"s", 0, 0},
00791 {"setup",
00792 I18N_NOOP("Setup the Pilot device and other parameters"),
00793 0L},
00794 {"c", 0, 0},
00795 {"conduit-setup", I18N_NOOP("Run conduit setup"), 0L},
00796 {0, 0, 0}
00797 };
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811 int run_mode = 0;
00812
00813
00814 int main(int argc, char **argv)
00815 {
00816 FUNCTIONSETUP;
00817
00818 KAboutData about("kpilot", I18N_NOOP("KPilot"),
00819 KPILOT_VERSION,
00820 "KPilot - HotSync software for KDE\n\n",
00821 KAboutData::License_GPL, "(c) 1998-2000,2001, Dan Pilone");
00822 about.addAuthor("Dan Pilone",
00823 I18N_NOOP("Project Leader"),
00824 "pilone@slac.com", "http://www.slac.com/pilone/kpilot_home/");
00825 about.addAuthor("Adriaan de Groot",
00826 I18N_NOOP("Maintainer"),
00827 "groot@kde.org", "http://www.cs.kun.nl/~adridg/kpilot/");
00828 about.addCredit("Preston Brown", I18N_NOOP("VCal conduit"));
00829 about.addCredit("Greg Stern", I18N_NOOP("Abbrowser conduit"));
00830 about.addCredit("Chris Molnar", I18N_NOOP("Expenses conduit"));
00831 about.addCredit("Heiko Purnhagen", I18N_NOOP("Bugfixer"));
00832 about.addCredit("Joerg Habenicht", I18N_NOOP("Bugfixer"));
00833 about.addCredit("Martin Junius",
00834 I18N_NOOP("XML GUI"),
00835 "mj@m-j-s.net", "http://www.m-j-s.net/kde/");
00836 about.addCredit("David Bishop",
00837 I18N_NOOP(".ui files"));
00838 about.addCredit("Aaron J. Seigo",
00839 I18N_NOOP("Bugfixer, coolness"));
00840 about.addCredit("Reinhold Kainhofer",
00841 I18N_NOOP("vCal and Addressbook conduit ports, time conduit, AvantGo conduit"), "reinhold@kainhofer.com", "http://reinhold.kainhofer.com/");
00842
00843
00844 KCmdLineArgs::init(argc, argv, &about);
00845 #ifdef DEBUG
00846 KCmdLineArgs::addCmdLineOptions(debug_options, "debug", "debug");
00847 #endif
00848 KCmdLineArgs::addCmdLineOptions(kpilotoptions, "kpilot", 0L, "debug");
00849 KUniqueApplication::addCmdLineOptions();
00850 KCmdLineArgs *p = KCmdLineArgs::parsedArgs();
00851
00852 if (p->isSet("setup"))
00853 {
00854 run_mode = 's';
00855 }
00856 if (p->isSet("conduit-setup"))
00857 {
00858 run_mode = 'c';
00859 }
00860
00861 if (!KUniqueApplication::start())
00862 {
00863 return 0;
00864 }
00865 KUniqueApplication a(true, true);
00866
00867 KPilotConfig::getDebugLevel();
00868
00869 KPilotConfigSettings & c = KPilotConfig::getConfig();
00870 if (c.getVersion() < KPilotConfig::ConfigurationVersion)
00871 {
00872 run_mode = 'S';
00873 }
00874
00875 if (run_mode == 'c')
00876 {
00877 ConduitConfigDialog *cs = new ConduitConfigDialog(0L,0L,true);
00878 int r = cs->exec();
00879
00880 if (r)
00881 {
00882 return 1;
00883 }
00884 else
00885 {
00886 return 0;
00887 }
00888 }
00889
00890 if ((run_mode == 's') || (run_mode == 'S'))
00891 {
00892 #ifdef DEBUG
00893 DEBUGKPILOT << fname
00894 << ": Running setup first."
00895 << " (mode " << run_mode << ")" << endl;
00896 #endif
00897
00898 KPilotConfigDialog *options = new KPilotConfigDialog(0L,
00899 "configDialog", true);
00900 int r = options->exec();
00901
00902 if (run_mode == 's')
00903 {
00904 if (!r)
00905 {
00906 return 1;
00907 }
00908 else
00909 {
00910 return 0;
00911 }
00912 }
00913
00914 if (!r)
00915 return 1;
00916
00917
00918
00919
00920
00921
00922 c.resetGroup();
00923 }
00924
00925 if (c.getVersion() < KPilotConfig::ConfigurationVersion)
00926 {
00927 kdWarning() << k_funcinfo <<
00928 ": Is still not configured for use." << endl;
00929 return 1;
00930 }
00931
00932
00933 KPilotInstaller *tp = new KPilotInstaller();
00934
00935 if (tp->status() == KPilotInstaller::Error)
00936 {
00937 delete tp;
00938
00939 tp = 0;
00940 return 1;
00941 }
00942
00943 tp->startDaemonIfNeeded();
00944
00945 KGlobal::dirs()->addResourceType("pilotdbs",
00946 CSL1("share/apps/kpilot/DBBackup"));
00947 tp->show();
00948 a.setMainWidget(tp);
00949 return a.exec();
00950 }
00951
00952