fotaapplication/fotaserver/src/main.cpp
author hgs
Fri, 15 Oct 2010 11:46:45 +0530
changeset 73 ae69c2e8bc34
parent 51 2e64dc50f295
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     1
/*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     2
 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     3
 * All rights reserved.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     8
 *
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     9
 * Initial Contributors:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    11
 *
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    12
 * Contributors:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    13
 *
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    14
 * Description: Implementation of applicationmanagement components
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    15
 *
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    16
 */
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    17
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    18
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    19
#include <hbapplication.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    20
#include <hbtransparentwindow.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    21
#include <hbstackedlayout.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    22
#include <hbmainwindow.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    23
#include <hbview.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    24
#include <QTranslator>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    25
#include <QLocale>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    26
#include <e32property.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    27
#include "FotaServer.h"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    28
#include "FotaSrvDebug.h"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    29
#include "fsview.h"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    30
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    31
int main(int argc, char *argv[])
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    32
    { 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    33
    FLOG(_L("CFotaServer::Main >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    34
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    35
    FLOG(_L("CFotaServer::HbApplication >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    36
    HbApplication a(argc, argv);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    37
    
73
hgs
parents: 51
diff changeset
    38
    HbFSView* view = new HbFSView();
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    39
    FLOG(_L("CFotaServer::HbView >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    40
    view->hideItems(Hb::AllItems);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    41
    FLOG(_L("CFotaServer::hideItems >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    42
    view->setContentFullScreen();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    43
    FLOG(_L("CFotaServer::setContentFullScreen >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    44
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    45
    HbMainWindow mainWindow(0, Hb::WindowFlagTransparent);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    46
    FLOG(_L("CFotaServer::mainWindow >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    47
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    48
    HbTransparentWindow *transparentWindow = new HbTransparentWindow;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    49
    FLOG(_L("CFotaServer::transparentWindow >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    50
    HbStackedLayout *stackedLayout = new HbStackedLayout;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    51
    FLOG(_L("CFotaServer::stackedLayout >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    52
    stackedLayout->addItem(transparentWindow);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    53
    FLOG(_L("CFotaServer::addItem >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    54
    view->setLayout(stackedLayout);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    55
    FLOG(_L("CFotaServer::setLayout >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    56
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    57
    mainWindow.addView(view);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    58
    FLOG(_L("CFotaServer::addView >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    59
    mainWindow.setCurrentView(view);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    60
    mainWindow.lower();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    61
    FLOG(_L("CFotaServer::setCurrentView >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    62
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    63
    // create the server (leave it on the cleanup stack)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    64
    CFotaServer* server = CFotaServer::NewInstance(mainWindow);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    65
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    66
    if (server == NULL)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    67
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    68
        return 0;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    69
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    70
    
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    71
    mainWindow.show();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    72
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    73
    FLOG(_L("CFotaServer::show <<"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    74
    RSemaphore sem;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    75
    TInt ret = sem.OpenGlobal(KFotaServerScem);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    76
    FLOG(_L("CFotaServer::OpenGlobal >>"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    77
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    78
    FLOG(_L("CFotaServer::showMaximized <<"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    79
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    80
    QTranslator *translator = new QTranslator();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    81
    QString lang = QLocale::system().name();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    82
    QString path = "Z:/resource/qt/translations/";
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    83
    bool fine = translator->load("deviceupdates_" + lang, path);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    84
    if (fine)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    85
        qApp->installTranslator(translator);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    86
    
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    87
    QTranslator *commontranslator = new QTranslator();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    88
    fine = commontranslator->load("common_" + lang, path);/*finally required once localisation available*/
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    89
       if(fine)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    90
            qApp->installTranslator(commontranslator);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    91
       else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    92
            qDebug("fotaserver common translator loading failed");
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    93
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    94
       a.setApplicationName("FotaServer");
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    95
    
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    96
    
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    97
    view->SetServer(server);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    98
    a.installEventFilter(view);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    99
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   100
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   101
    // Initialisation complete, now signal the client
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   102
    if (ret == KErrNone)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   103
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   104
        sem.Signal();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   105
        FLOG(_L("CFotaServer::Signal <<"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   106
        sem.Close();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   107
        FLOG(_L("CFotaServer::Close <<"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   108
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   109
    FLOG(_L("CFotaServer::KErrNone <<"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   110
    //This will install and start a active scheduler for this thread.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   111
    ret = a.exec();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   112
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   113
    RProperty::Set(TUid::Uid(KOmaDMAppUid), KFotaServerActive, 0);  
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   114
    delete server;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   115
    FLOG(_L("CFotaServer::Main <<"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   116
    return ret;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   117
    }