31
|
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 |
#ifdef _DEBUG_TRACES_
|
|
30 |
void debugInit(QtMsgType type, const char *msg)
|
|
31 |
{
|
|
32 |
|
|
33 |
QFile ofile(debugFileName);
|
|
34 |
if (!ofile.open(QIODevice::Append | QIODevice::Text)) {
|
|
35 |
qFatal("error opening results file");
|
|
36 |
return;
|
|
37 |
}
|
|
38 |
QDateTime dt = QDateTime::currentDateTime();
|
|
39 |
|
|
40 |
QTextStream out(&ofile);
|
|
41 |
switch (type) {
|
|
42 |
case QtDebugMsg:
|
|
43 |
out << "\n DEBUG:";
|
|
44 |
out << msg;
|
|
45 |
break;
|
|
46 |
case QtWarningMsg:
|
|
47 |
out << "\n WARN:";
|
|
48 |
out << msg;
|
|
49 |
break;
|
|
50 |
case QtCriticalMsg:
|
|
51 |
out << "\n ";
|
|
52 |
out << dt.toString("dd/MM/yyyy hh:mm:ss.zzz:ap");
|
|
53 |
out << " CRITICAL:";
|
|
54 |
out << msg;
|
|
55 |
break;
|
|
56 |
case QtFatalMsg:
|
|
57 |
out << "\n FATAL:";
|
|
58 |
out << msg;
|
|
59 |
abort();
|
|
60 |
break;
|
|
61 |
default:
|
|
62 |
out << " No Log Selection Type:";
|
|
63 |
out << msg;
|
|
64 |
break;
|
|
65 |
|
|
66 |
}
|
|
67 |
}
|
|
68 |
#endif
|
|
69 |
|
|
70 |
int main(int argc, char *argv[])
|
|
71 |
{
|
|
72 |
QCoreApplication app(argc, argv);
|
|
73 |
|
|
74 |
#ifdef _DEBUG_TRACES_
|
|
75 |
//Debug Logs
|
|
76 |
QFile ofile;
|
|
77 |
if (ofile.exists(debugFileName)) {
|
|
78 |
ofile.remove(debugFileName);
|
|
79 |
}
|
|
80 |
qInstallMsgHandler(debugInit);
|
|
81 |
#endif
|
|
82 |
// TODO: Get notifications at startup time.handled later
|
|
83 |
QPointer<MsgNotifier> msgNotifier = new MsgNotifier();
|
|
84 |
int r = app.exec();
|
|
85 |
delete msgNotifier;
|
|
86 |
return r;
|
|
87 |
}
|
|
88 |
|