21 #include <kontactinterface/pimuniqueapplication.h>
28 #include <kmessagebox.h>
29 #undef Status // stupid X headers
44 class KMailApplication :
public KontactInterface::PimUniqueApplication
47 KMailApplication() : KontactInterface::PimUniqueApplication(),
48 mDelayedInstanceCreation( false ),
49 mEventLoopReached( false ) { }
50 virtual int newInstance();
51 void commitData(QSessionManager& sm);
52 void setEventLoopReached();
53 void delayedInstanceCreation();
55 bool mDelayedInstanceCreation;
56 bool mEventLoopReached;
60 void KMailApplication::commitData(QSessionManager& sm) {
63 KApplication::commitData( sm );
66 void KMailApplication::setEventLoopReached() {
67 mEventLoopReached =
true;
70 int KMailApplication::newInstance()
77 if ( !mEventLoopReached ) {
78 kDebug() <<
"Delaying instance creation.";
79 mDelayedInstanceCreation =
true;
86 if (!
kmkernel->firstInstance() || !kapp->isSessionRestored())
92 void KMailApplication::delayedInstanceCreation() {
93 if ( mDelayedInstanceCreation )
97 int main(
int argc,
char *argv[])
103 #if 0 // for testing KUniqueAppliaction on Windows
105 QString(
"main() %1 pid=%2").arg(argv[0]).arg(getpid()).toLatin1(),
106 QString(
"main() \"%1\"").arg(argv[0]).toLatin1(), MB_OK|MB_ICONINFORMATION|MB_TASKMODAL);
110 KCmdLineArgs::setCwd(QDir::currentPath().toLocal8Bit());
111 KCmdLineArgs::init(argc, argv, &about);
113 if (!KMailApplication::start())
116 KMailApplication app;
123 QApplication::setQuitOnLastWindowClosed(
false );
126 KMail::insertLibraryCataloguesAndIcons();
142 app.setEventLoopReached();
143 app.delayedInstanceCreation();
146 int ret = qApp->exec();
Central point of coordination in KMail.
static KCmdLineOptions kmail_options()
void recoverDeadLetters()
bool doSessionManagement()
int main(int argc, char *argv[])