| author | William Roberts <williamr@symbian.org> | 
| Thu, 22 Jul 2010 16:32:06 +0100 | |
| branch | GCC_SURGE | 
| changeset 47 | 5b14749788d7 | 
| parent 25 | 84d9eb65b26f | 
| parent 34 | 84197e66a4bd | 
| permissions | -rw-r--r-- | 
| 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> | |
| 34 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 20 | #include <QTranslator> | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 21 | #include <QLocale> | 
| 31 | 22 | #include <QFile> | 
| 23 | #include <QDateTime> | |
| 24 | #include <QPointer> | |
| 25 | ||
| 26 | #include "msgnotifier.h" | |
| 27 | #include "debugtraces.h" | |
| 28 | ||
| 29 | const QString debugFileName("c:/msgnotifier.txt");
 | |
| 30 | ||
| 31 | #ifdef _DEBUG_TRACES_ | |
| 32 | void debugInit(QtMsgType type, const char *msg) | |
| 33 | {
 | |
| 34 | ||
| 35 | QFile ofile(debugFileName); | |
| 36 |     if (!ofile.open(QIODevice::Append | QIODevice::Text)) {
 | |
| 37 |         qFatal("error opening results file");
 | |
| 38 | return; | |
| 39 | } | |
| 40 | QDateTime dt = QDateTime::currentDateTime(); | |
| 41 | ||
| 42 | QTextStream out(&ofile); | |
| 43 |     switch (type) {
 | |
| 44 | case QtDebugMsg: | |
| 45 | out << "\n DEBUG:"; | |
| 46 | out << msg; | |
| 47 | break; | |
| 48 | case QtWarningMsg: | |
| 49 | out << "\n WARN:"; | |
| 50 | out << msg; | |
| 51 | break; | |
| 52 | case QtCriticalMsg: | |
| 53 | out << "\n "; | |
| 54 |         out << dt.toString("dd/MM/yyyy hh:mm:ss.zzz:ap");
 | |
| 55 | out << " CRITICAL:"; | |
| 56 | out << msg; | |
| 57 | break; | |
| 58 | case QtFatalMsg: | |
| 59 | out << "\n FATAL:"; | |
| 60 | out << msg; | |
| 61 | abort(); | |
| 62 | break; | |
| 63 | default: | |
| 64 | out << " No Log Selection Type:"; | |
| 65 | out << msg; | |
| 66 | break; | |
| 67 | ||
| 68 | } | |
| 69 | } | |
| 70 | #endif | |
| 71 | ||
| 72 | int main(int argc, char *argv[]) | |
| 73 | {
 | |
| 74 | QCoreApplication app(argc, argv); | |
| 34 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 75 | QString locale = QLocale::system().name(); | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 76 | QString path = "z:/resource/qt/translations/"; | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 77 | QTranslator translator; | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 78 | QTranslator translator_comm; | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 79 |     translator.load(path + QString("messaging_") + locale);
 | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 80 |     translator_comm.load(path + QString("common_") + locale);
 | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 81 | app.installTranslator(&translator); | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 82 | app.installTranslator(&translator_comm); | 
| 
84197e66a4bd
Revision: 201021
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 83 | |
| 31 | 84 | #ifdef _DEBUG_TRACES_ | 
| 85 | //Debug Logs | |
| 86 | QFile ofile; | |
| 87 |     if (ofile.exists(debugFileName)) {
 | |
| 88 | ofile.remove(debugFileName); | |
| 89 | } | |
| 90 | qInstallMsgHandler(debugInit); | |
| 91 | #endif | |
| 92 | // TODO: Get notifications at startup time.handled later | |
| 93 | QPointer<MsgNotifier> msgNotifier = new MsgNotifier(); | |
| 94 | int r = app.exec(); | |
| 95 | delete msgNotifier; | |
| 96 | return r; | |
| 97 | } | |
| 98 |