00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <iostream>
00023
00024 #include <dcopclient.h>
00025 #include <kaboutdata.h>
00026 #include <kcmdlineargs.h>
00027 #include <kdebug.h>
00028 #include <kiconloader.h>
00029 #include <klocale.h>
00030 #include <kstartupinfo.h>
00031 #include <kuniqueapplication.h>
00032 #include <kwin.h>
00033 #include <kstandarddirs.h>
00034 #include <ktrader.h>
00035 #include "plugin.h"
00036
00037 #include <qlabel.h>
00038 #include "prefs.h"
00039
00040 #include "alarmclient.h"
00041 #include "mainwindow.h"
00042
00043 using namespace std;
00044
00045 static const char description[] =
00046 I18N_NOOP( "KDE personal information manager" );
00047
00048 static const char version[] = "1.2.3";
00049
00050 class KontactApp : public KUniqueApplication {
00051 public:
00052 KontactApp() : mMainWindow( 0 ) {}
00053 ~KontactApp() {}
00054
00055 int newInstance();
00056
00057 private:
00058 void startKOrgac();
00059 Kontact::MainWindow *mMainWindow;
00060 };
00061
00062 static void listPlugins()
00063 {
00064 KInstance instance( "kontact" );
00065 KTrader::OfferList offers = KTrader::self()->query(
00066 QString::fromLatin1( "Kontact/Plugin" ),
00067 QString( "[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );
00068 for ( KService::List::Iterator it = offers.begin(); it != offers.end(); ++it ) {
00069 KService::Ptr service = (*it);
00070
00071 QVariant var = service->property( "X-KDE-KontactPluginHasPart" );
00072 if ( var.isValid() && var.toBool() == false )
00073 continue;
00074 cout << service->library().remove( "libkontact_" ).latin1() << endl;
00075 }
00076 }
00077
00078 static KCmdLineOptions options[] =
00079 {
00080 { "module <module>", I18N_NOOP( "Start with a specific Kontact module" ), 0 },
00081 { "iconify", I18N_NOOP( "Start in iconified (minimized) mode" ), 0 },
00082 { "list", I18N_NOOP( "List all possible modules and exit" ), 0 },
00083 KCmdLineLastOption
00084 };
00085
00086 int KontactApp::newInstance()
00087 {
00088 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00089 QString moduleName;
00090 if ( Kontact::Prefs::self()->forceStartupPlugin() ) {
00091 moduleName = Kontact::Prefs::self()->forcedStartupPlugin();
00092 }
00093 if ( args->isSet( "module" ) ) {
00094 moduleName = QString::fromLocal8Bit( args->getOption( "module" ) );
00095 }
00096
00097 if ( isRestored() ) {
00098
00099 if ( KMainWindow::canBeRestored( 1 ) ) {
00100 mMainWindow = new Kontact::MainWindow();
00101 setMainWidget( mMainWindow );
00102 mMainWindow->show();
00103 mMainWindow->restore( 1 );
00104 }
00105 } else {
00106 if ( !mMainWindow ) {
00107 mMainWindow = new Kontact::MainWindow();
00108 if ( !moduleName.isEmpty() )
00109 mMainWindow->setActivePluginModule( moduleName );
00110 mMainWindow->show();
00111 setMainWidget( mMainWindow );
00112
00113
00114 if ( args->isSet( "iconify" ) )
00115 KWin::iconifyWindow( mMainWindow->winId(), false );
00116 } else {
00117 if ( !moduleName.isEmpty() )
00118 mMainWindow->setActivePluginModule( moduleName );
00119 }
00120 }
00121
00122 AlarmClient alarmclient;
00123 alarmclient.startDaemon();
00124
00125
00126
00127 return KUniqueApplication::newInstance();
00128 }
00129
00130 int main( int argc, char **argv )
00131 {
00132 KAboutData about( "kontact", I18N_NOOP( "Kontact" ), version, description,
00133 KAboutData::License_GPL, I18N_NOOP("(C) 2001-2004 The Kontact developers"), 0, "http://kontact.org" );
00134 about.addAuthor( "Daniel Molkentin", 0, "molkentin@kde.org" );
00135 about.addAuthor( "Don Sanders", 0, "sanders@kde.org" );
00136 about.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" );
00137 about.addAuthor( "Tobias K\303\266nig", 0, "tokoe@kde.org" );
00138 about.addAuthor( "David Faure", 0, "faure@kde.org" );
00139 about.addAuthor( "Ingo Kl\303\266cker", 0, "kloecker@kde.org" );
00140 about.addAuthor( "Sven L\303\274ppken", 0, "sven@kde.org" );
00141 about.addAuthor( "Zack Rusin", 0, "zack@kde.org" );
00142 about.addAuthor( "Matthias Hoelzer-Kluepfel", I18N_NOOP("Original Author"), "mhk@kde.org" );
00143
00144 KCmdLineArgs::init( argc, argv, &about );
00145 KCmdLineArgs::addCmdLineOptions( options );
00146 KUniqueApplication::addCmdLineOptions();
00147 KApplication::addCmdLineOptions();
00148
00149 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00150 if ( args->isSet( "list" ) ) {
00151 listPlugins();
00152 return 0;
00153 }
00154
00155 if ( !KontactApp::start() ) {
00156
00157 return 0;
00158 }
00159
00160 KontactApp app;
00161 bool ret = app.exec();
00162 while ( KMainWindow::memberList->first() )
00163 delete KMainWindow::memberList->first();
00164
00165 return ret;
00166 }