kmail Library API Documentation

main.cpp

00001 // -*- mode: C++; c-file-style: "gnu" -*- 00002 // KMail startup and initialize code 00003 // Author: Stefan Taferner <taferner@alpin.or.at> 00004 00005 #include <config.h> 00006 00007 #include <kuniqueapplication.h> 00008 #include <kglobal.h> 00009 #include <knotifyclient.h> 00010 #include <dcopclient.h> 00011 #include "kmkernel.h" //control center 00012 #include "kmail_options.h" 00013 00014 #include <kdebug.h> 00015 00016 #undef Status // stupid X headers 00017 00018 #include "aboutdata.h" 00019 00020 #include "kmstartup.h" 00021 00022 // OLD about text. This is horrbly outdated. 00023 /*const char* aboutText = 00024 "KMail [" KMAIL_VERSION "] by\n\n" 00025 "Stefan Taferner <taferner@kde.org>,\n" 00026 "Markus Wübben <markus.wuebben@kde.org>\n\n" 00027 "based on the work of:\n" 00028 "Lynx <lynx@topaz.hknet.com>,\n" 00029 "Stephan Meyer <Stephan.Meyer@pobox.com>,\n" 00030 "and the above authors.\n\n" 00031 "This program is covered by the GPL.\n\n" 00032 "Please send bugreports to taferner@kde.org"; 00033 */ 00034 00035 //----------------------------------------------------------------------------- 00036 00037 class KMailApplication : public KUniqueApplication 00038 { 00039 public: 00040 KMailApplication() : KUniqueApplication() { }; 00041 virtual int newInstance(); 00042 void commitData(QSessionManager& sm); 00043 00044 }; 00045 00046 void KMailApplication::commitData(QSessionManager& sm) { 00047 kmkernel->dumpDeadLetters(); 00048 kmkernel->setShuttingDown( true ); // Prevent further dumpDeadLetters calls 00049 KApplication::commitData( sm ); 00050 } 00051 00052 00053 int KMailApplication::newInstance() 00054 { 00055 kdDebug(5006) << "KMailApplication::newInstance()" << endl; 00056 if (!kmkernel) 00057 return 0; 00058 00059 if (!kmkernel->firstInstance() || !kapp->isRestored()) 00060 kmkernel->handleCommandLine( true ); 00061 kmkernel->setFirstInstance(FALSE); 00062 return 0; 00063 } 00064 00065 int main(int argc, char *argv[]) 00066 { 00067 // WABA: KMail is a KUniqueApplication. Unfortunately this makes debugging 00068 // a bit harder: You should pass --nofork as commandline argument when using 00069 // a debugger. In gdb you can do this by typing "set args --nofork" before 00070 // typing "run". 00071 00072 KMail::AboutData about; 00073 00074 KCmdLineArgs::init(argc, argv, &about); 00075 KCmdLineArgs::addCmdLineOptions( kmail_options ); // Add kmail options 00076 if (!KMailApplication::start()) 00077 return 0; 00078 00079 KMailApplication app; 00080 00081 // import i18n data and icons from libraries: 00082 KMail::insertLibraryCataloguesAndIcons(); 00083 00084 // Make sure that the KNotify Daemon is running (this is necessary for people 00085 // using KMail without KDE) 00086 KNotifyClient::startDaemon(); 00087 00088 kapp->dcopClient()->suspend(); // Don't handle DCOP requests yet 00089 00090 KMail::lockOrDie(); 00091 00092 //local, do the init 00093 KMKernel kmailKernel; 00094 kmailKernel.init(); 00095 kapp->dcopClient()->setDefaultObject( kmailKernel.objId() ); 00096 00097 // and session management 00098 kmailKernel.doSessionManagement(); 00099 00100 // any dead letters? 00101 kmailKernel.recoverDeadLetters(); 00102 00103 kmsetSignalHandler(kmsignalHandler); 00104 00105 kapp->dcopClient()->resume(); // Ok. We are ready for DCOP requests. 00106 kmkernel->setStartingUp( false ); // Starting up is finished 00107 // Go! 00108 int ret = kapp->exec(); 00109 // clean up 00110 kmailKernel.cleanup(); 00111 00112 KMail::cleanup(); // pid file (see kmstartup.cpp) 00113 return ret; 00114 }
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:19:24 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003