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

/*
 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description: Implementation of applicationmanagement components
 *
 */


#include <hbapplication.h>
#include <hbtransparentwindow.h>
#include <hbstackedlayout.h>
#include <hbmainwindow.h>
#include <hbview.h>
#include <QTranslator>
#include <QLocale>
#include <e32property.h>
#include "FotaServer.h"
#include "FotaSrvDebug.h"
#include "fsview.h"

int main(int argc, char *argv[])
    { 
    FLOG(_L("CFotaServer::Main >>"));

    FLOG(_L("CFotaServer::HbApplication >>"));
    HbApplication a(argc, argv);
    
    HbFSView* view = new HbFSView();
    FLOG(_L("CFotaServer::HbView >>"));
    view->hideItems(Hb::AllItems);
    FLOG(_L("CFotaServer::hideItems >>"));
    view->setContentFullScreen();
    FLOG(_L("CFotaServer::setContentFullScreen >>"));

    HbMainWindow mainWindow(0, Hb::WindowFlagTransparent);
    FLOG(_L("CFotaServer::mainWindow >>"));

    HbTransparentWindow *transparentWindow = new HbTransparentWindow;
    FLOG(_L("CFotaServer::transparentWindow >>"));
    HbStackedLayout *stackedLayout = new HbStackedLayout;
    FLOG(_L("CFotaServer::stackedLayout >>"));
    stackedLayout->addItem(transparentWindow);
    FLOG(_L("CFotaServer::addItem >>"));
    view->setLayout(stackedLayout);
    FLOG(_L("CFotaServer::setLayout >>"));

    mainWindow.addView(view);
    FLOG(_L("CFotaServer::addView >>"));
    mainWindow.setCurrentView(view);
    mainWindow.lower();
    FLOG(_L("CFotaServer::setCurrentView >>"));

    // create the server (leave it on the cleanup stack)
    CFotaServer* server = CFotaServer::NewInstance(mainWindow);

    if (server == NULL)
        {
        return 0;
        }
    
    mainWindow.show();

    FLOG(_L("CFotaServer::show <<"));
    RSemaphore sem;
    TInt ret = sem.OpenGlobal(KFotaServerScem);
    FLOG(_L("CFotaServer::OpenGlobal >>"));

    FLOG(_L("CFotaServer::showMaximized <<"));

    QTranslator *translator = new QTranslator();
    QString lang = QLocale::system().name();
    QString path = "Z:/resource/qt/translations/";
    bool fine = translator->load("deviceupdates_" + lang, path);
    if (fine)
        qApp->installTranslator(translator);
    
    QTranslator *commontranslator = new QTranslator();
    fine = commontranslator->load("common_" + lang, path);/*finally required once localisation available*/
       if(fine)
            qApp->installTranslator(commontranslator);
       else
            qDebug("fotaserver common translator loading failed");

       a.setApplicationName("FotaServer");
    
    
    view->SetServer(server);
    a.installEventFilter(view);


    // Initialisation complete, now signal the client
    if (ret == KErrNone)
        {
        sem.Signal();
        FLOG(_L("CFotaServer::Signal <<"));
        sem.Close();
        FLOG(_L("CFotaServer::Close <<"));
        }
    FLOG(_L("CFotaServer::KErrNone <<"));
    //This will install and start a active scheduler for this thread.
    ret = a.exec();

    RProperty::Set(TUid::Uid(KOmaDMAppUid), KFotaServerActive, 0);  
    delete server;
    FLOG(_L("CFotaServer::Main <<"));
    return ret;
    }