|
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:main() for messaging application. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <hbapplication.h> |
|
19 #include <QTranslator> |
|
20 #include <QLocale> |
|
21 #include <QFile> |
|
22 #include "debugtraces.h" |
|
23 #include <QDateTime> |
|
24 #include <QPointer> |
|
25 |
|
26 #include "msgmainwindow.h" |
|
27 |
|
28 //Localised constants |
|
29 #define LOC_TITLE hbTrId("txt_messaging_title_messaging") |
|
30 |
|
31 const QString debugFileName("c:/art2_app_log.txt"); |
|
32 #ifdef _DEBUG_TRACES_ |
|
33 void debugInit(QtMsgType type, const char *msg) |
|
34 { |
|
35 |
|
36 QFile ofile(debugFileName); |
|
37 if (!ofile.open(QIODevice::Append | QIODevice::Text)) |
|
38 { |
|
39 qFatal("error opening results file"); |
|
40 return; |
|
41 } |
|
42 QDateTime dt = QDateTime::currentDateTime(); |
|
43 |
|
44 QTextStream out(&ofile); |
|
45 switch (type) |
|
46 { |
|
47 case QtDebugMsg: |
|
48 out << " DEBUG:"; |
|
49 out << msg; |
|
50 break; |
|
51 case QtWarningMsg: |
|
52 out << " WARN:"; |
|
53 out << msg; |
|
54 break; |
|
55 case QtCriticalMsg: |
|
56 out << "\n "; |
|
57 out << dt.toString("dd/MM/yyyy hh:mm:ss.zzz:ap"); |
|
58 out << " CRITICAL:"; |
|
59 out << msg; |
|
60 break; |
|
61 case QtFatalMsg: |
|
62 out << " FATAL:"; |
|
63 out << msg; |
|
64 abort(); |
|
65 break; |
|
66 default: |
|
67 out << " No Log Selection Type:"; |
|
68 out << msg; |
|
69 break; |
|
70 |
|
71 } |
|
72 } |
|
73 |
|
74 #endif |
|
75 int main(int argc, char *argv[]) |
|
76 { |
|
77 // Application |
|
78 HbApplication app(argc, argv); |
|
79 |
|
80 //TODO: Uncomment the lines when actual translation files are available in sdk and remove loading locally. |
|
81 QString locale = QLocale::system().name(); |
|
82 QString path = "z:/resource/qt/translations/"; |
|
83 QTranslator translator; |
|
84 //QTranslator translator_comm; |
|
85 //translator.load(path + QString("messaging_") + locale); |
|
86 //translator_comm.load(path + QString("common_") + locale); |
|
87 translator.load( "messaging_en_GB", ":/translations" ); |
|
88 app.installTranslator(&translator); |
|
89 //app.installTranslator(&translator_comm); |
|
90 |
|
91 app.setApplicationName(LOC_TITLE); |
|
92 |
|
93 #ifdef _DEBUG_TRACES_ |
|
94 //Debug Logs |
|
95 QFile ofile; |
|
96 if (ofile.exists(debugFileName)) |
|
97 { |
|
98 ofile.remove(debugFileName); |
|
99 } |
|
100 qInstallMsgHandler(debugInit); |
|
101 #endif |
|
102 bool serviceRequest = false; |
|
103 if(argc >1) |
|
104 { |
|
105 serviceRequest = true; |
|
106 } |
|
107 // Main window |
|
108 QPointer<MsgMainWindow> mainWindow = new MsgMainWindow(serviceRequest); |
|
109 mainWindow->show(); |
|
110 |
|
111 // Event loop |
|
112 int error = app.exec(); |
|
113 |
|
114 // delete main window and return error |
|
115 delete mainWindow; |
|
116 return error; |
|
117 } |
|
118 |
|
119 // End of file |