fotaapplication/fotaserver/src/main.cpp
branchRCL_3
changeset 26 19bba8228ff0
parent 25 b183ec05bd8c
child 27 5cc2995847ea
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
     1 /*
       
     2  * Copyright (c) 2000 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: Implementation of applicationmanagement components
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 #include <hbapplication.h>
       
    20 #include <hbtransparentwindow.h>
       
    21 #include <hbstackedlayout.h>
       
    22 #include <hbmainwindow.h>
       
    23 #include <hbview.h>
       
    24 #include <QTranslator>
       
    25 #include <QLocale>
       
    26 #include <e32property.h>
       
    27 #include "FotaServer.h"
       
    28 #include "FotaSrvDebug.h"
       
    29 #include "fsview.h"
       
    30 
       
    31 int main(int argc, char *argv[])
       
    32     { 
       
    33     FLOG(_L("CFotaServer::Main >>"));
       
    34 
       
    35     FLOG(_L("CFotaServer::HbApplication >>"));
       
    36     HbApplication a(argc, argv);
       
    37     
       
    38     FSView* view = new FSView();
       
    39     FLOG(_L("CFotaServer::HbView >>"));
       
    40     view->hideItems(Hb::AllItems);
       
    41     FLOG(_L("CFotaServer::hideItems >>"));
       
    42     view->setContentFullScreen();
       
    43     FLOG(_L("CFotaServer::setContentFullScreen >>"));
       
    44 
       
    45     HbMainWindow mainWindow(0, Hb::WindowFlagTransparent);
       
    46     FLOG(_L("CFotaServer::mainWindow >>"));
       
    47 
       
    48     HbTransparentWindow *transparentWindow = new HbTransparentWindow;
       
    49     FLOG(_L("CFotaServer::transparentWindow >>"));
       
    50     HbStackedLayout *stackedLayout = new HbStackedLayout;
       
    51     FLOG(_L("CFotaServer::stackedLayout >>"));
       
    52     stackedLayout->addItem(transparentWindow);
       
    53     FLOG(_L("CFotaServer::addItem >>"));
       
    54     view->setLayout(stackedLayout);
       
    55     FLOG(_L("CFotaServer::setLayout >>"));
       
    56 
       
    57     mainWindow.addView(view);
       
    58     FLOG(_L("CFotaServer::addView >>"));
       
    59     mainWindow.setCurrentView(view);
       
    60     mainWindow.lower();
       
    61     FLOG(_L("CFotaServer::setCurrentView >>"));
       
    62 
       
    63     // create the server (leave it on the cleanup stack)
       
    64     CFotaServer* server = CFotaServer::NewInstance(mainWindow);
       
    65 
       
    66     if (server == NULL)
       
    67         {
       
    68         return 0;
       
    69         }
       
    70     
       
    71     mainWindow.show();
       
    72 
       
    73     FLOG(_L("CFotaServer::show <<"));
       
    74     //app.installEventFilter(view);
       
    75     RSemaphore sem;
       
    76     TInt ret = sem.OpenGlobal(KFotaServerScem);
       
    77     FLOG(_L("CFotaServer::OpenGlobal >>"));
       
    78 
       
    79     FLOG(_L("CFotaServer::showMaximized <<"));
       
    80 
       
    81     QTranslator *translator = new QTranslator();
       
    82     QString lang = QLocale::system().name();
       
    83     QString path = "Z:/resource/qt/translations/";
       
    84     bool fine = translator->load("deviceupdates_" + lang, path);
       
    85     if (fine)
       
    86         qApp->installTranslator(translator);
       
    87     
       
    88     QTranslator *commontranslator = new QTranslator();
       
    89     fine = commontranslator->load("common_" + lang, path);/*finally required once localisation available*/
       
    90        if(fine)
       
    91             qApp->installTranslator(commontranslator);
       
    92        else
       
    93             qDebug("fotaserver common translator loading failed");
       
    94 
       
    95        a.setApplicationName("FotaServer");
       
    96     
       
    97     
       
    98     view->SetServer(server);
       
    99     a.installEventFilter(view);
       
   100 
       
   101 
       
   102     // Initialisation complete, now signal the client
       
   103     if (ret == KErrNone)
       
   104         {
       
   105         sem.Signal();
       
   106         FLOG(_L("CFotaServer::Signal <<"));
       
   107         sem.Close();
       
   108         FLOG(_L("CFotaServer::Close <<"));
       
   109         }
       
   110     FLOG(_L("CFotaServer::KErrNone <<"));
       
   111     //This will install and start a active scheduler for this thread.
       
   112     ret = a.exec();
       
   113 
       
   114     RProperty::Set(TUid::Uid(KOmaDMAppUid), KFotaServerActive, 0);  
       
   115     delete server;
       
   116     FLOG(_L("CFotaServer::Main <<"));
       
   117     return ret;
       
   118     }