messagingapp/msgservices/msgserviceapp/src/main.cpp
author hgs
Fri, 17 Sep 2010 20:01:45 +0530
changeset 67 fc91263aee62
parent 51 3507212d340e
permissions -rw-r--r--
201037_04
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
{
67
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    81
    // Need splashScreen at construction time itself?
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    82
    bool needImmdSplashScreen = true;
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    83
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    84
    // Decision logic to launch the splash screen based on the service called
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    85
    QString serviceName = XQServiceUtil::interfaceName( argc, argv);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    86
    if( !serviceName.compare( QString( "com.nokia.symbian.IMessageSend") ) )
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    87
        {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    88
        HbSplashScreen::setScreenId( "sendservice" );
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    89
        }
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    90
    else if ( !serviceName.compare( "com.nokia.symbian.IMessageView") )
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    91
        {
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    92
        HbSplashScreen::setScreenId( "viewservice" );
67
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    93
        needImmdSplashScreen = false;
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
    94
        }
67
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    95
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    96
    // Appropriate HbApplication initialization
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    97
    HbApplication app( argc, argv,
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    98
            needImmdSplashScreen? Hb::DefaultApplicationFlags : Hb::NoSplash);
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
    99
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
   100
    // Install translator.
37
hgs
parents:
diff changeset
   101
    QString locale = QLocale::system().name();
hgs
parents:
diff changeset
   102
    QTranslator translator;
46
b1f0785c289d 201027_03
hgs
parents: 37
diff changeset
   103
    QTranslator translator_comm;
51
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   104
    translator.load(TRANSLATOR_FILE_PATH + QString("messaging_") + locale);
3507212d340e 201031_02
hgs
parents: 46
diff changeset
   105
    translator_comm.load(TRANSLATOR_FILE_PATH + QString("common_") + locale);
37
hgs
parents:
diff changeset
   106
    app.installTranslator(&translator);
46
b1f0785c289d 201027_03
hgs
parents: 37
diff changeset
   107
    app.installTranslator(&translator_comm);
67
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
   108
    app.setApplicationName(LOC_TITLE);
37
hgs
parents:
diff changeset
   109
67
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
   110
    // Create mainwindow, but don't show it just yet.
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
   111
    // We shall show the mainwindow at appropriate places later in the code.
37
hgs
parents:
diff changeset
   112
    QPointer<MsgServiceWindow> window = new MsgServiceWindow();
67
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
   113
fc91263aee62 201037_04
hgs
parents: 51
diff changeset
   114
    // Start event-loop
37
hgs
parents:
diff changeset
   115
    int rv = app.exec();
hgs
parents:
diff changeset
   116
    delete window;
hgs
parents:
diff changeset
   117
    return rv;
hgs
parents:
diff changeset
   118
}
hgs
parents:
diff changeset
   119