messagingapp/msgnotifications/msgnotifier/src/main.cpp
branchRCL_3
changeset 57 ebe688cedc25
equal deleted inserted replaced
54:fa1df4b99609 57:ebe688cedc25
       
     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 <QTranslator>
       
    21 #include <QLocale>
       
    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);
       
    75     QString locale = QLocale::system().name();
       
    76     QString path = "z:/resource/qt/translations/";
       
    77     QTranslator translator;
       
    78     QTranslator translator_comm;
       
    79     translator.load(path + QString("messaging_") + locale);
       
    80     translator_comm.load(path + QString("common_") + locale);
       
    81     app.installTranslator(&translator);
       
    82     app.installTranslator(&translator_comm);
       
    83     
       
    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