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 #include <qtimer.h>
00014 
00015 #undef Status // stupid X headers
00016 
00017 #include "aboutdata.h"
00018 
00019 #include "kmstartup.h"
00020 
00021 // OLD about text.  This is horrbly outdated.
00022 /*const char* aboutText =
00023     "KMail [" KMAIL_VERSION "] by\n\n"
00024     "Stefan Taferner <taferner@kde.org>,\n"
00025     "Markus Wübben <markus.wuebben@kde.org>\n\n"
00026     "based on the work of:\n"
00027     "Lynx <lynx@topaz.hknet.com>,\n"
00028     "Stephan Meyer <Stephan.Meyer@pobox.com>,\n"
00029     "and the above authors.\n\n"
00030     "This program is covered by the GPL.\n\n"
00031     "Please send bugreports to taferner@kde.org";
00032 */
00033 
00034 //-----------------------------------------------------------------------------
00035 
00036 class KMailApplication : public KUniqueApplication
00037 {
00038 public:
00039   KMailApplication() : KUniqueApplication() { };
00040   virtual int newInstance();
00041   void commitData(QSessionManager& sm);
00042 
00043 };
00044 
00045 void KMailApplication::commitData(QSessionManager& sm) {
00046   kmkernel->dumpDeadLetters();
00047   kmkernel->setShuttingDown( true ); // Prevent further dumpDeadLetters calls
00048   KApplication::commitData( sm );
00049 }
00050 
00051 
00052 int KMailApplication::newInstance()
00053 {
00054   if (dcopClient()->isSuspended())
00055   {
00056     // Try again later.
00057     QTimer::singleShot( 100, this, SLOT(newInstance()) );
00058     return 0;
00059   }
00060 
00061   if (!kmkernel->firstInstance() || !kapp->isRestored())
00062     kmkernel->handleCommandLine( true );
00063   kmkernel->setFirstInstance(FALSE);
00064   return 0;
00065 }
00066 
00067 int main(int argc, char *argv[])
00068 {
00069   // WABA: KMail is a KUniqueApplication. Unfortunately this makes debugging
00070   // a bit harder: You should pass --nofork as commandline argument when using
00071   // a debugger. In gdb you can do this by typing "set args --nofork" before
00072   // typing "run".
00073 
00074   KMail::AboutData about;
00075 
00076   KCmdLineArgs::init(argc, argv, &about);
00077   KCmdLineArgs::addCmdLineOptions( kmail_options ); // Add kmail options
00078   if (!KMailApplication::start())
00079      return 0;
00080 
00081   KMailApplication app;
00082 
00083   // import i18n data from libraries:
00084   KMail::insertLibraryCatalogues();
00085 
00086 #if !KDE_IS_VERSION( 3, 1, 92 ) // replacement is now in KMKernel::config()
00087   // Check that all updates have been run on the config file:
00088   KMail::checkConfigUpdates();
00089 #endif
00090 
00091   // Make sure that the KNotify Daemon is running (this is necessary for people
00092   // using KMail without KDE)
00093   KNotifyClient::startDaemon();
00094 
00095   KMail::lockOrDie();
00096 
00097   kapp->dcopClient()->suspend(); // Don't handle DCOP requests yet
00098 
00099   //local, do the init
00100   KMKernel kmailKernel;
00101   kmailKernel.init();
00102   kapp->dcopClient()->setDefaultObject( kmailKernel.objId() );
00103 
00104   // and session management
00105   kmailKernel.doSessionManagement();
00106 
00107   // any dead letters?
00108   kmailKernel.recoverDeadLetters();
00109 
00110   kmsetSignalHandler(kmsignalHandler);
00111 
00112   kapp->dcopClient()->resume(); // Ok. We are ready for DCOP requests.
00113   kmkernel->setStartingUp( false ); // Starting up is finished
00114   // Go!
00115   int ret = kapp->exec();
00116   // clean up
00117   if (kmkernel->shuttingDown())
00118       kmailKernel.notClosedByUser();
00119   else
00120       kmailKernel.cleanup();
00121 
00122   KMail::cleanup();
00123   return ret;
00124 }
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:37:34 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003