messagingapp/msgservices/msgserviceapp/src/main.cpp
author hgs
Tue, 07 Sep 2010 13:28:39 +0530
changeset 62 fdbe8253b596
parent 51 3507212d340e
child 67 fc91263aee62
permissions -rw-r--r--
201035_03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description: Messaging service application startup main().
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include <hbapplication.h>
hgs
parents:
diff changeset
    19
#include <QTranslator>
hgs
parents:
diff changeset
    20
#include <QLocale>
hgs
parents:
diff changeset
    21
#include <QFile>
hgs
parents:
diff changeset
    22
#include <QPointer>
hgs
parents:
diff changeset
    23
#include <QDateTime>
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    24
#include <HbSplashScreen>
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    25
#include <xqserviceutil.h>
37
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
#include "msgservicewindow.h"
hgs
parents:
diff changeset
    28
#include "debugtraces.h"
hgs
parents:
diff changeset
    29
hgs
parents:
diff changeset
    30
//Localised constants
hgs
parents:
diff changeset
    31
#define LOC_TITLE hbTrId("txt_messaging_title_messaging")
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
const QString debugFileName("c:/msgservice_app.txt");
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    34
const QString TRANSLATOR_FILE_PATH("z:/resource/qt/translations/");
37
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
#ifdef _DEBUG_TRACES_
hgs
parents:
diff changeset
    37
void debugInit(QtMsgType type, const char *msg)
hgs
parents:
diff changeset
    38
{
hgs
parents:
diff changeset
    39
hgs
parents:
diff changeset
    40
    QFile ofile(debugFileName);
hgs
parents:
diff changeset
    41
    if (!ofile.open(QIODevice::Append | QIODevice::Text))
hgs
parents:
diff changeset
    42
    {
hgs
parents:
diff changeset
    43
        qFatal("error opening results file");
hgs
parents:
diff changeset
    44
        return;
hgs
parents:
diff changeset
    45
    }
hgs
parents:
diff changeset
    46
    QDateTime dt = QDateTime::currentDateTime();
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
    QTextStream out(&ofile);
hgs
parents:
diff changeset
    49
    switch (type)
hgs
parents:
diff changeset
    50
    {
hgs
parents:
diff changeset
    51
        case QtDebugMsg:
hgs
parents:
diff changeset
    52
            out << " DEBUG:";
hgs
parents:
diff changeset
    53
            out << msg;
hgs
parents:
diff changeset
    54
            break;
hgs
parents:
diff changeset
    55
        case QtWarningMsg:
hgs
parents:
diff changeset
    56
            out << " WARN:";
hgs
parents:
diff changeset
    57
            out << msg;
hgs
parents:
diff changeset
    58
            break;
hgs
parents:
diff changeset
    59
        case QtCriticalMsg:
hgs
parents:
diff changeset
    60
            out << "\n ";
hgs
parents:
diff changeset
    61
            out << dt.toString("dd/MM/yyyy hh:mm:ss.zzz:ap");
hgs
parents:
diff changeset
    62
            out << " CRITICAL:";
hgs
parents:
diff changeset
    63
            out << msg;
hgs
parents:
diff changeset
    64
            break;
hgs
parents:
diff changeset
    65
        case QtFatalMsg:
hgs
parents:
diff changeset
    66
            out << " FATAL:";
hgs
parents:
diff changeset
    67
            out << msg;
hgs
parents:
diff changeset
    68
            abort();
hgs
parents:
diff changeset
    69
            break;
hgs
parents:
diff changeset
    70
        default:
hgs
parents:
diff changeset
    71
            out << " No Log Selection Type:";
hgs
parents:
diff changeset
    72
            out << msg;
hgs
parents:
diff changeset
    73
            break;
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
    }
hgs
parents:
diff changeset
    76
}
hgs
parents:
diff changeset
    77
#endif
hgs
parents:
diff changeset
    78
hgs
parents:
diff changeset
    79
int main(int argc, char **argv)
hgs
parents:
diff changeset
    80
{
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    81
    // if else loop to launch the splash screen based on the service called.
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    82
    
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    83
    QString serviceName = XQServiceUtil::interfaceName( argc, argv);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    84
    
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    85
    if( !serviceName.compare( QString( "com.nokia.symbian.IMessageSend") ) )
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    86
        {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    87
        HbSplashScreen::setScreenId( "sendservice" );
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    88
        }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    89
    else if ( !serviceName.compare( "com.nokia.symbian.IMessageView") )
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    90
        {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    91
        HbSplashScreen::setScreenId( "viewservice" );
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    92
        }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    93
    
37
hgs
parents:
diff changeset
    94
    HbApplication app( argc, argv );
hgs
parents:
diff changeset
    95
    
46
b1f0785c289d 201027_03
hgs
parents: 37
diff changeset
    96
   //installing translator.
37
hgs
parents:
diff changeset
    97
    QString locale = QLocale::system().name();
hgs
parents:
diff changeset
    98
    QTranslator translator;
46
b1f0785c289d 201027_03
hgs
parents: 37
diff changeset
    99
    QTranslator translator_comm;
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   100
    translator.load(TRANSLATOR_FILE_PATH + QString("messaging_") + locale);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   101
    translator_comm.load(TRANSLATOR_FILE_PATH + QString("common_") + locale);
37
hgs
parents:
diff changeset
   102
    app.installTranslator(&translator);
46
b1f0785c289d 201027_03
hgs
parents: 37
diff changeset
   103
    app.installTranslator(&translator_comm);
37
hgs
parents:
diff changeset
   104
hgs
parents:
diff changeset
   105
    app.setApplicationName(LOC_TITLE);
hgs
parents:
diff changeset
   106
    
hgs
parents:
diff changeset
   107
    QPointer<MsgServiceWindow> window = new MsgServiceWindow();
hgs
parents:
diff changeset
   108
    window->show();
hgs
parents:
diff changeset
   109
    
hgs
parents:
diff changeset
   110
    int rv = app.exec();
hgs
parents:
diff changeset
   111
    delete window;
hgs
parents:
diff changeset
   112
    return rv;
hgs
parents:
diff changeset
   113
}
hgs
parents:
diff changeset
   114