37
|
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: Messaging service application startup main().
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <hbapplication.h>
|
|
19 |
#include <QTranslator>
|
|
20 |
#include <QLocale>
|
|
21 |
#include <QFile>
|
|
22 |
#include <QPointer>
|
|
23 |
#include <QDateTime>
|
51
|
24 |
#include <HbSplashScreen>
|
|
25 |
#include <xqserviceutil.h>
|
37
|
26 |
|
|
27 |
#include "msgservicewindow.h"
|
|
28 |
#include "debugtraces.h"
|
|
29 |
|
|
30 |
//Localised constants
|
|
31 |
#define LOC_TITLE hbTrId("txt_messaging_title_messaging")
|
|
32 |
|
|
33 |
const QString debugFileName("c:/msgservice_app.txt");
|
51
|
34 |
const QString TRANSLATOR_FILE_PATH("z:/resource/qt/translations/");
|
37
|
35 |
|
|
36 |
#ifdef _DEBUG_TRACES_
|
|
37 |
void debugInit(QtMsgType type, const char *msg)
|
|
38 |
{
|
|
39 |
|
|
40 |
QFile ofile(debugFileName);
|
|
41 |
if (!ofile.open(QIODevice::Append | QIODevice::Text))
|
|
42 |
{
|
|
43 |
qFatal("error opening results file");
|
|
44 |
return;
|
|
45 |
}
|
|
46 |
QDateTime dt = QDateTime::currentDateTime();
|
|
47 |
|
|
48 |
QTextStream out(&ofile);
|
|
49 |
switch (type)
|
|
50 |
{
|
|
51 |
case QtDebugMsg:
|
|
52 |
out << " DEBUG:";
|
|
53 |
out << msg;
|
|
54 |
break;
|
|
55 |
case QtWarningMsg:
|
|
56 |
out << " WARN:";
|
|
57 |
out << msg;
|
|
58 |
break;
|
|
59 |
case QtCriticalMsg:
|
|
60 |
out << "\n ";
|
|
61 |
out << dt.toString("dd/MM/yyyy hh:mm:ss.zzz:ap");
|
|
62 |
out << " CRITICAL:";
|
|
63 |
out << msg;
|
|
64 |
break;
|
|
65 |
case QtFatalMsg:
|
|
66 |
out << " FATAL:";
|
|
67 |
out << msg;
|
|
68 |
abort();
|
|
69 |
break;
|
|
70 |
default:
|
|
71 |
out << " No Log Selection Type:";
|
|
72 |
out << msg;
|
|
73 |
break;
|
|
74 |
|
|
75 |
}
|
|
76 |
}
|
|
77 |
#endif
|
|
78 |
|
|
79 |
int main(int argc, char **argv)
|
|
80 |
{
|
67
|
81 |
// Need splashScreen at construction time itself?
|
|
82 |
bool needImmdSplashScreen = true;
|
|
83 |
|
|
84 |
// Decision logic to launch the splash screen based on the service called
|
51
|
85 |
QString serviceName = XQServiceUtil::interfaceName( argc, argv);
|
|
86 |
if( !serviceName.compare( QString( "com.nokia.symbian.IMessageSend") ) )
|
|
87 |
{
|
|
88 |
HbSplashScreen::setScreenId( "sendservice" );
|
|
89 |
}
|
|
90 |
else if ( !serviceName.compare( "com.nokia.symbian.IMessageView") )
|
|
91 |
{
|
|
92 |
HbSplashScreen::setScreenId( "viewservice" );
|
67
|
93 |
needImmdSplashScreen = false;
|
51
|
94 |
}
|
67
|
95 |
|
|
96 |
// Appropriate HbApplication initialization
|
|
97 |
HbApplication app( argc, argv,
|
|
98 |
needImmdSplashScreen? Hb::DefaultApplicationFlags : Hb::NoSplash);
|
|
99 |
|
|
100 |
// Install translator.
|
37
|
101 |
QString locale = QLocale::system().name();
|
|
102 |
QTranslator translator;
|
46
|
103 |
QTranslator translator_comm;
|
51
|
104 |
translator.load(TRANSLATOR_FILE_PATH + QString("messaging_") + locale);
|
|
105 |
translator_comm.load(TRANSLATOR_FILE_PATH + QString("common_") + locale);
|
37
|
106 |
app.installTranslator(&translator);
|
46
|
107 |
app.installTranslator(&translator_comm);
|
67
|
108 |
app.setApplicationName(LOC_TITLE);
|
37
|
109 |
|
67
|
110 |
// Create mainwindow, but don't show it just yet.
|
|
111 |
// We shall show the mainwindow at appropriate places later in the code.
|
37
|
112 |
QPointer<MsgServiceWindow> window = new MsgServiceWindow();
|
67
|
113 |
|
|
114 |
// Start event-loop
|
37
|
115 |
int rv = app.exec();
|
|
116 |
delete window;
|
|
117 |
return rv;
|
|
118 |
}
|
|
119 |
|