24 #include <dcopclient.h>
25 #include <tdeaboutdata.h>
26 #include <tdecmdlineargs.h>
28 #include <kiconloader.h>
29 #include <tdelocale.h>
30 #include <tdestartupinfo.h>
31 #include <tdeuniqueapplication.h>
33 #include <kstandarddirs.h>
40 #include "alarmclient.h"
41 #include "mainwindow.h"
42 #include <uniqueapphandler.h>
43 #include "profilemanager.h"
47 static const char description[] =
48 I18N_NOOP(
"TDE personal information manager" );
50 static const char version[] =
"1.2.9";
52 class KontactApp :
public TDEUniqueApplication {
54 KontactApp() : mMainWindow( 0 ), mSessionRestored( false )
56 TDEGlobal::iconLoader()->addAppDir(
"tdepim" );
61 void setMainWindow( Kontact::MainWindow *window ) {
63 setMainWidget( window );
65 void setSessionRestored(
bool restored ) {
66 mSessionRestored = restored;
71 Kontact::MainWindow *mMainWindow;
72 bool mSessionRestored;
75 static void listPlugins()
77 TDEInstance instance(
"kontact" );
78 TDETrader::OfferList offers = TDETrader::self()->query(
79 TQString::fromLatin1(
"Kontact/Plugin" ),
80 TQString(
"[X-TDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );
81 for ( KService::List::Iterator it = offers.begin(); it != offers.end(); ++it ) {
82 KService::Ptr service = (*it);
84 TQVariant var = service->property(
"X-TDE-KontactPluginHasPart" );
85 if ( var.isValid() && var.toBool() ==
false )
87 cout << service->library().remove(
"libkontact_" ).latin1() << endl;
91 static void listProfiles()
93 TQValueList<Kontact::Profile> profiles = Kontact::ProfileManager::self()->profiles();
94 for( TQValueListIterator<Kontact::Profile> it = profiles.begin() ; it != profiles.end(); ++it ) {
95 cout << (*it).name().latin1() << endl;
99 int KontactApp::newInstance()
101 TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
103 if ( Kontact::Prefs::self()->forceStartupPlugin() ) {
104 moduleName = Kontact::Prefs::self()->forcedStartupPlugin();
106 if ( args->isSet(
"module" ) ) {
107 moduleName = TQString::fromLocal8Bit( args->getOption(
"module" ) );
110 if ( !mSessionRestored ) {
111 if ( !mMainWindow ) {
112 mMainWindow =
new Kontact::MainWindow();
113 if ( !moduleName.isEmpty() )
114 mMainWindow->setActivePluginModule( moduleName );
116 setMainWidget( mMainWindow );
119 if ( args->isSet(
"iconify" ) )
120 KWin::iconifyWindow( mMainWindow->winId(),
false );
122 if ( !moduleName.isEmpty() )
123 mMainWindow->setActivePluginModule( moduleName );
127 if ( args->isSet(
"profile" ) ) {
128 TQValueList<Kontact::Profile> profiles = Kontact::ProfileManager::self()->profiles();
129 for( TQValueListIterator<Kontact::Profile> it = profiles.begin(); it != profiles.end(); ++it ){
130 if( args->getOption(
"profile") == (*it).name().latin1() ) {
131 Kontact::ProfileManager::self()->loadProfile( (*it).id() );
137 AlarmClient alarmclient;
138 alarmclient.startDaemon();
142 return TDEUniqueApplication::newInstance();
145 int main(
int argc,
char **argv )
147 TDEAboutData about(
"kontact", I18N_NOOP(
"Kontact" ), version, description,
148 TDEAboutData::License_GPL,
149 I18N_NOOP(
"(C) 2008-2018 The Trinity Desktop Project\n(C) 2001-2008 The Kontact developers"),
150 0,
"http://www.trinitydesktop.org" );
151 about.addAuthor(
"Daniel Molkentin", 0,
"molkentin@kde.org" );
152 about.addAuthor(
"Don Sanders", 0,
"sanders@kde.org" );
153 about.addAuthor(
"Cornelius Schumacher", 0,
"schumacher@kde.org" );
154 about.addAuthor(
"Tobias K\303\266nig", 0,
"tokoe@kde.org" );
155 about.addAuthor(
"David Faure", 0,
"faure@kde.org" );
156 about.addAuthor(
"Ingo Kl\303\266cker", 0,
"kloecker@kde.org" );
157 about.addAuthor(
"Sven L\303\274ppken", 0,
"sven@kde.org" );
158 about.addAuthor(
"Zack Rusin", 0,
"zack@kde.org" );
159 about.addAuthor(
"Matthias Hoelzer-Kluepfel", I18N_NOOP(
"Original Author"),
"mhk@kde.org" );
161 TDECmdLineArgs::init( argc, argv, &about );
164 TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
165 if ( args->isSet(
"list" ) ) {
170 if ( args->isSet(
"listprofiles" ) ) {
175 if ( !KontactApp::start() ) {
181 if ( app.restoringSession() ) {
183 if ( TDEMainWindow::canBeRestored( 1 ) ) {
184 Kontact::MainWindow *mainWindow =
new Kontact::MainWindow();
185 app.setMainWindow( mainWindow );
186 app.setSessionRestored(
true );
188 mainWindow->restore( 1 );
192 bool ret = app.exec();
193 while ( TDEMainWindow::memberList->first() )
194 delete TDEMainWindow::memberList->first();
static void loadKontactCommandLineOptions()
Load the kontact command line options.