|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Message Notifier server startup |
|
15 * |
|
16 */ |
|
17 |
|
18 //SYSTEM INCLUDES |
|
19 #include <QCoreApplication> |
|
20 #include <QFile> |
|
21 #include <QDateTime> |
|
22 #include <QPointer> |
|
23 |
|
24 #include "msgnotifier.h" |
|
25 #include "debugtraces.h" |
|
26 |
|
27 const QString debugFileName("c:/msgnotifier.txt"); |
|
28 |
|
29 |
|
30 #ifdef _DEBUG_TRACES_ |
|
31 void debugInit(QtMsgType type, const char *msg) |
|
32 { |
|
33 |
|
34 QFile ofile(debugFileName); |
|
35 if (!ofile.open(QIODevice::Append | QIODevice::Text)) |
|
36 { |
|
37 qFatal("error opening results file"); |
|
38 return; |
|
39 } |
|
40 QDateTime dt = QDateTime::currentDateTime(); |
|
41 |
|
42 QTextStream out(&ofile); |
|
43 switch (type) |
|
44 { |
|
45 case QtDebugMsg: |
|
46 out << "\n DEBUG:"; |
|
47 out << msg; |
|
48 break; |
|
49 case QtWarningMsg: |
|
50 out << "\n WARN:"; |
|
51 out << msg; |
|
52 break; |
|
53 case QtCriticalMsg: |
|
54 out << "\n "; |
|
55 out << dt.toString("dd/MM/yyyy hh:mm:ss.zzz:ap"); |
|
56 out << " CRITICAL:"; |
|
57 out << msg; |
|
58 break; |
|
59 case QtFatalMsg: |
|
60 out << "\n FATAL:"; |
|
61 out << msg; |
|
62 abort(); |
|
63 break; |
|
64 default: |
|
65 out << " No Log Selection Type:"; |
|
66 out << msg; |
|
67 break; |
|
68 |
|
69 } |
|
70 } |
|
71 #endif |
|
72 |
|
73 int main(int argc,char *argv[]) |
|
74 { |
|
75 QCoreApplication app(argc,argv); |
|
76 |
|
77 #ifdef _DEBUG_TRACES_ |
|
78 //Debug Logs |
|
79 QFile ofile; |
|
80 if (ofile.exists(debugFileName)) { |
|
81 ofile.remove(debugFileName); |
|
82 } |
|
83 qInstallMsgHandler(debugInit); |
|
84 #endif |
|
85 |
|
86 // create harvester |
|
87 QPointer<MsgNotifier> msgNotifier = new MsgNotifier(); |
|
88 int r = app.exec(); |
|
89 delete msgNotifier; |
|
90 return r; |
|
91 } |
|
92 |