taskswitcher/server/src/main.cpp
changeset 121 0b3699f6c654
child 119 50e220be30d1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/main.cpp	Fri Sep 17 08:32:18 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* 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 "tsrunningappserver.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 = CTsRunningAppServer::NewLC();    
+    CleanupStack::Pop(serverObject);
+    
+    RSemaphore semaphore;
+    if (KErrNone == semaphore.OpenGlobal(KTsServerReadySemaphore)) {
+        semaphore.Signal();
+    }
+    semaphore.Close();
+    
+    int result = app.exec();
+    
+    delete serverObject;
+    return result;
+}