23 #include "kdepim-version.h"
27 using namespace Kontact;
29 #include <libkdepimdbusinterfaces/reminderclient.h>
31 #include <KontactInterface/Plugin>
32 #include <KontactInterface/UniqueAppHandler>
34 #include <KontactInterface/PimUniqueApplication>
38 #include <KCmdLineArgs>
41 #include <KServiceTypeTrader>
42 #include <KUniqueApplication>
43 #include <KWindowSystem>
48 static const char description[] = I18N_NOOP(
"KDE personal information manager" );
50 static const char version[] = KDEPIM_VERSION;
52 class KontactApp :
public
54 KontactInterface::PimUniqueApplication
61 KontactApp() : mMainWindow( 0 ), mSessionRestored(
false )
63 KIconLoader::global()->addAppDir( QLatin1String(
"kdepim") );
73 KontactInterface::UniqueAppHandler::setMainWidget( window );
75 void setSessionRestored(
bool restored )
77 mSessionRestored = restored;
81 void loadCommandLineOptionsForNewInstance();
85 bool mSessionRestored;
90 KComponentData instance(
"kontact" );
92 const KService::List offers = KServiceTypeTrader::self()->query(
93 QString::fromLatin1(
"Kontact/Plugin" ),
94 QString::fromLatin1(
"[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );
95 KService::List::ConstIterator end( offers.end() );
96 for ( KService::List::ConstIterator it = offers.begin(); it != end; ++it ) {
97 KService::Ptr service = (*it);
99 QVariant var = service->property( QLatin1String(
"X-KDE-KontactPluginHasPart") );
100 if ( var.isValid() && var.toBool() == false ) {
103 cout << service->library().remove( QLatin1String(
"kontact_") ).toLatin1().data() << endl;
109 KCmdLineOptions options;
110 options.add(
"module <module>", ki18n(
"Start with a specific Kontact module" ) );
111 options.add(
"iconify", ki18n(
"Start in iconified (minimized) mode" ) );
112 options.add(
"list", ki18n(
"List all possible modules and exit" ) );
113 KCmdLineArgs::addCmdLineOptions( options );
117 void KontactApp::loadCommandLineOptionsForNewInstance()
119 KCmdLineArgs::reset();
123 int KontactApp::newInstance()
125 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
130 if ( args->isSet(
"module" ) ) {
131 moduleName = args->getOption(
"module" );
133 if ( !mSessionRestored ) {
134 if ( !mMainWindow ) {
136 if ( !moduleName.isEmpty() ) {
137 mMainWindow->setInitialActivePluginModule( moduleName );
140 KontactInterface::UniqueAppHandler::setMainWidget( mMainWindow );
143 if ( args->isSet(
"iconify" ) ) {
144 KWindowSystem::minimizeWindow( mMainWindow->winId(),
false );
147 if ( !moduleName.isEmpty() ) {
148 mMainWindow->setInitialActivePluginModule( moduleName );
153 KPIM::ReminderClient::startDaemon();
157 return KUniqueApplication::newInstance();
160 int main(
int argc,
char **argv )
163 KAboutData::License_GPL,
164 ki18n(
"Copyright © 2001–2013 Kontact authors" ),
165 KLocalizedString(),
"http://kontact.org" );
167 about.addAuthor( ki18n(
"Allen Winter" ), KLocalizedString(),
"winter@kde.org" );
168 about.addAuthor( ki18n(
"Rafael Fernández López" ), KLocalizedString(),
"ereslibre@kde.org" );
169 about.addAuthor( ki18n(
"Daniel Molkentin" ), KLocalizedString(),
"molkentin@kde.org" );
170 about.addAuthor( ki18n(
"Don Sanders" ), KLocalizedString(),
"sanders@kde.org" );
171 about.addAuthor( ki18n(
"Cornelius Schumacher" ), KLocalizedString(),
"schumacher@kde.org" );
172 about.addAuthor( ki18n(
"Tobias K\303\266nig" ), KLocalizedString(),
"tokoe@kde.org" );
173 about.addAuthor( ki18n(
"David Faure" ), KLocalizedString(),
"faure@kde.org" );
174 about.addAuthor( ki18n(
"Ingo Kl\303\266cker" ), KLocalizedString(),
"kloecker@kde.org" );
175 about.addAuthor( ki18n(
"Sven L\303\274ppken" ), KLocalizedString(),
"sven@kde.org" );
176 about.addAuthor( ki18n(
"Zack Rusin" ), KLocalizedString(),
"zack@kde.org" );
177 about.addAuthor( ki18n(
"Matthias Hoelzer-Kluepfel" ),
178 ki18n(
"Original Author" ),
"mhk@kde.org" );
179 about.addCredit( ki18n(
"Torgny Nyblom" ), ki18n(
"Git Migration"),
"nyblom@kde.org" );
180 about.setOrganizationDomain(
"kde.org" );
182 KCmdLineArgs::init( argc, argv, &about );
185 KUniqueApplication::addCmdLineOptions();
186 KCmdLineArgs::addStdCmdLineOptions();
188 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
189 if ( args->isSet(
"list" ) ) {
194 if ( !KontactApp::start() ) {
206 QApplication::setQuitOnLastWindowClosed(
false );
208 if ( app.restoringSession() ) {
210 if ( KMainWindow::canBeRestored( 1 ) ) {
212 app.setMainWindow( mainWindow );
213 app.setSessionRestored(
true );
215 mainWindow->restore( 1 );
219 bool ret = app.exec();
220 qDeleteAll( KMainWindow::memberList() );
int main(int argc, char **argv)
static void listPlugins()
static QString forcedStartupPlugin()
Get ForcedStartupPlugin.
static const char description[]
static void loadCommandLineOptions()
static const char version[]