taskswitcher/server/src/main.cpp
author Jaakko Haukipuro (Nokia-MS/Oulu) <Jaakko.Haukipuro@nokia.com>
Thu, 16 Sep 2010 12:11:40 +0100
changeset 117 c63ee96dbe5f
permissions -rw-r--r--
Missing activityfw and taskswitcher components - fix for Bug 3670

/*
* Copyright (c) 2009 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:
*
*/

#include <QApplication>

#include "hsrunningappserver.h"
#include "tstaskmonitorglobals.h"
#include <apgwgnam.h>
#include <eikenv.h>

#include <caservice.h>

int main(int argc, char *argv[]) 
{
    QApplication app(argc, argv);
    
    // hide server from TaskSwitcher
    CEikonEnv * env = CEikonEnv::Static();
    if(env) {
        env->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);

        CApaWindowGroupName *wgName = CApaWindowGroupName::NewLC(env->WsSession());    
        wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc.
        wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down    
        wgName->SetCaptionL(KRunningAppServerName);    
        wgName->SetWindowGroupName(env->RootWin());
        CleanupStack::PopAndDestroy(wgName);
    }
    
    // maintain instance of caservice (needed for getting application icons)
    QSharedPointer<CaService> service = CaService::instance();    
    
    CServer2* serverObject = CRunningAppServer::NewLC();    
    CleanupStack::Pop(serverObject);
    
    RSemaphore semaphore;
    if (KErrNone == semaphore.OpenGlobal(KTsServerReadySemaphore)) {
        semaphore.Signal();
    }
    semaphore.Close();
    
    int result = app.exec();
    
    delete serverObject;
    return result;
}