12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
|
18 |
|
19 #include "nmmailagentheaders.h" |
17 #include "nmmailagentheaders.h" |
20 #include "nmmailagent.h" |
18 #include "nmmailagent.h" |
|
19 #include "ssastartupwatcher.h" |
21 |
20 |
22 #ifdef __WINSCW__ |
21 #ifdef __WINSCW__ |
23 const int NmStartupDelay = 14000; // 14s |
22 const int NmStartupDelay = 14000; // 14s |
24 #else |
23 #else |
25 const int NmStartupDelay = 4000; // 4s |
24 const int NmStartupDelay = 4000; // 4s |
26 #endif |
25 #endif |
27 |
26 |
|
27 NmMailAgent *agent = NULL; |
28 |
28 |
29 /*! |
29 /*! |
30 int main |
30 Callback for reporting startup state |
|
31 */ |
|
32 static void startupCallback(int status) |
|
33 { |
|
34 NMLOG(QString("nmailagent: startupCallback %1").arg(status)); |
|
35 Q_UNUSED(status); |
|
36 |
|
37 // either it is an error or 'non critical startup' state has been reached |
|
38 // Start the agent in both cases |
|
39 QTimer::singleShot(NmStartupDelay, agent, SLOT(delayedStart())); |
|
40 } |
|
41 |
|
42 /*! |
|
43 main |
31 */ |
44 */ |
32 int main(int argc, char *argv[]) |
45 int main(int argc, char *argv[]) |
33 { |
46 { |
34 QCoreApplication app(argc, argv); |
47 QCoreApplication app(argc, argv); |
35 NmMailAgent agent; |
|
36 |
48 |
37 // Agent will be initialised with a delay to avoid startup problems |
49 agent = new NmMailAgent; |
38 QTimer::singleShot(NmStartupDelay, &agent, SLOT(delayedStart())); |
|
39 |
50 |
40 return app.exec(); |
51 CSSAStartupWatcher *startupWatcher = CSSAStartupWatcher::New(startupCallback); |
|
52 if (!startupWatcher) { |
|
53 NMLOG("nmmailagent - watcher start failed"); |
|
54 QTimer::singleShot(NmStartupDelay, agent, SLOT(delayedStart())); |
|
55 } |
|
56 |
|
57 int retValue = app.exec(); |
|
58 delete startupWatcher; |
|
59 delete agent; |
|
60 return retValue; |
41 } |
61 } |