kontact
main.cpp00001
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 #include <uniqueapphandler.h>
00043
00044 using namespace std;
00045
00046 static const char description[] =
00047 I18N_NOOP( "KDE personal information manager" );
00048
00049 static const char version[] = "1.2.4";
00050
00051 class KontactApp : public KUniqueApplication {
00052 public:
00053 KontactApp() : mMainWindow( 0 ), mSessionRestored( false ) {}
00054 ~KontactApp() {}
00055
00056 int newInstance();
00057 void setMainWindow( Kontact::MainWindow *window ) {
00058 mMainWindow = window;
00059 setMainWidget( window );
00060 }
00061 void setSessionRestored( bool restored ) {
00062 mSessionRestored = restored;
00063 }
00064
00065 private:
00066 void startKOrgac();
00067 Kontact::MainWindow *mMainWindow;
00068 bool mSessionRestored;
00069 };
00070
00071 static void listPlugins()
00072 {
00073 KInstance instance( "kontact" );
00074 KTrader::OfferList offers = KTrader::self()->query(
00075 QString::fromLatin1( "Kontact/Plugin" ),
00076 QString( "[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );
00077 for ( KService::List::Iterator it = offers.begin(); it != offers.end(); ++it ) {
00078 KService::Ptr service = (*it);
00079
00080 QVariant var = service->property( "X-KDE-KontactPluginHasPart" );
00081 if ( var.isValid() && var.toBool() == false )
00082 continue;
00083 cout << service->library().remove( "libkontact_" ).latin1() << endl;
00084 }
00085 }
00086
00087 int KontactApp::newInstance()
00088 {
00089 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00090 QString moduleName;
00091 if ( Kontact::Prefs::self()->forceStartupPlugin() ) {
00092 moduleName = Kontact::Prefs::self()->forcedStartupPlugin();
00093 }
00094 if ( args->isSet( "module" ) ) {
00095 moduleName = QString::fromLocal8Bit( args->getOption( "module" ) );
00096 }
00097
00098 if ( !mSessionRestored ) {
00099 if ( !mMainWindow ) {
00100 mMainWindow = new Kontact::MainWindow();
00101 if ( !moduleName.isEmpty() )
00102 mMainWindow->setActivePluginModule( moduleName );
00103 mMainWindow->show();
00104 setMainWidget( mMainWindow );
00105
00106
00107 if ( args->isSet( "iconify" ) )
00108 KWin::iconifyWindow( mMainWindow->winId(), false );
00109 } else {
00110 if ( !moduleName.isEmpty() )
00111 mMainWindow->setActivePluginModule( moduleName );
00112 }
00113 }
00114
00115 AlarmClient alarmclient;
00116 alarmclient.startDaemon();
00117
00118
00119
00120 return KUniqueApplication::newInstance();
00121 }
00122
00123 int main( int argc, char **argv )
00124 {
00125 KAboutData about( "kontact", I18N_NOOP( "Kontact" ), version, description,
00126 KAboutData::License_GPL, I18N_NOOP("(C) 2001-2004 The Kontact developers"), 0, "http://kontact.org" );
00127 about.addAuthor( "Daniel Molkentin", 0, "molkentin@kde.org" );
00128 about.addAuthor( "Don Sanders", 0, "sanders@kde.org" );
00129 about.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" );
00130 about.addAuthor( "Tobias K\303\266nig", 0, "tokoe@kde.org" );
00131 about.addAuthor( "David Faure", 0, "faure@kde.org" );
00132 about.addAuthor( "Ingo Kl\303\266cker", 0, "kloecker@kde.org" );
00133 about.addAuthor( "Sven L\303\274ppken", 0, "sven@kde.org" );
00134 about.addAuthor( "Zack Rusin", 0, "zack@kde.org" );
00135 about.addAuthor( "Matthias Hoelzer-Kluepfel", I18N_NOOP("Original Author"), "mhk@kde.org" );
00136
00137 KCmdLineArgs::init( argc, argv, &about );
00138 Kontact::UniqueAppHandler::loadKontactCommandLineOptions();
00139
00140 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00141 if ( args->isSet( "list" ) ) {
00142 listPlugins();
00143 return 0;
00144 }
00145
00146 if ( !KontactApp::start() ) {
00147
00148 return 0;
00149 }
00150
00151 KontactApp app;
00152 if ( app.restoringSession() ) {
00153
00154 if ( KMainWindow::canBeRestored( 1 ) ) {
00155 Kontact::MainWindow *mainWindow = new Kontact::MainWindow();
00156 app.setMainWindow( mainWindow );
00157 app.setSessionRestored( true );
00158 mainWindow->show();
00159 mainWindow->restore( 1 );
00160 }
00161 }
00162
00163 bool ret = app.exec();
00164 while ( KMainWindow::memberList->first() )
00165 delete KMainWindow::memberList->first();
00166
00167 return ret;
00168 }
|