fotaapplication/fotaserver/FotaServer/src/FotaSrvApp.cpp
changeset 50 a36219ae6585
parent 49 689a71addb96
child 51 2e64dc50f295
equal deleted inserted replaced
49:689a71addb96 50:a36219ae6585
     1 /*
       
     2 * Copyright (c) 2005 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:   Methods for CFotaSrvApp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <apgwgnam.h>
       
    22 #include <apgcli.h>
       
    23 #include "FotaSrvApp.h"
       
    24 #include "FotaSrvDocument.h"
       
    25 #include "FotaSrvDebug.h"
       
    26 #include "FotaServer.h"
       
    27 #include "fotaserverPrivatePSKeys.h"
       
    28 #include <apgtask.h>
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CFotaSrvApp::CFotaSrvApp
       
    32 // ---------------------------------------------------------------------------
       
    33 CFotaSrvApp::CFotaSrvApp() : iFotaServer(0), iDocument(0)
       
    34     {
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CFotaSrvApp::AppDllUid()
       
    39 // Returns application UID
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 TUid CFotaSrvApp::AppDllUid() const
       
    43     {
       
    44     TUid fotauid;
       
    45     fotauid.iUid =  KFotaServerUid;
       
    46     return fotauid;
       
    47     }
       
    48 
       
    49 // --------------------------------------------------------------------------
       
    50 // CFotaSrvApp::SetUIVisibleL
       
    51 // Turns UI visible or hidden
       
    52 // --------------------------------------------------------------------------
       
    53 //
       
    54 void CFotaSrvApp::SetUIVisibleL( const TBool aVisible, const TBool aAlsoFSW )
       
    55     {
       
    56     CFotaSrvUi*  ui = (CFotaSrvUi*)iDocument->AppUi(); //CFotaSrvUi
       
    57 
       
    58     FLOG(_L("[CFotaSrvApp]  CFotaSrvApp::SetUIVisibleL %d alsoFSW:%d")
       
    59     	,aVisible?1:0,aAlsoFSW?1:0);
       
    60     CCoeEnv*    coe = CCoeEnv::Static();
       
    61 
       
    62     TApaTask                task = TApaTask(coe->WsSession());
       
    63 
       
    64     task.SetWgId(coe->RootWin().Identifier());
       
    65     
       
    66     if ( aVisible )
       
    67         {
       
    68         //Launch DM UI Application
       
    69         TApaTaskList taskList(coe->WsSession());
       
    70         TApaTask task1(taskList.FindApp( TUid::Uid(KOmaDMAppUid)));
       
    71         FLOG(_L("Checking whether DM UI is running..."));
       
    72         TInt value (EFotaUpdateDM);
       
    73         if (task1.Exists())
       
    74 	        {
       
    75    		    FLOG(_L("Bring DM UI into FG")); 
       
    76 	        task1.BringToForeground(); //DM UI
       
    77 	        }
       
    78         else
       
    79         	{
       
    80 TInt err = RProperty::Get( KPSUidNSmlDMSyncApp, KNSmlCurrentFotaUpdateAppName, value );
       
    81 
       
    82     			if (value != EFotaUpdateNSC && value != EFotaUpdateNSCBg )
       
    83 					{
       
    84 						FLOG(_L("Launching DM UI into FG"));
       
    85         		RApaLsSession apaLsSession;
       
    86       			User::LeaveIfError(apaLsSession.Connect());
       
    87       			TThreadId thread;
       
    88            	User::LeaveIfError( apaLsSession.StartDocument(KNullDesC, TUid::Uid( KOmaDMAppUid), thread) );
       
    89            	apaLsSession.Close();
       
    90 					}				     
       
    91         	}
       
    92         if(value == EFotaUpdateDM)
       
    93         {
       
    94         	if ( aAlsoFSW ) ui->HideApplicationFromFSW( EFalse );
       
    95 				}
       
    96         else if (value == EFotaUpdateNSC || value == EFotaUpdateNSCBg )
       
    97         {
       
    98         	if ( aAlsoFSW ) ui->HideApplicationFromFSW( ETrue );
       
    99         }
       
   100 				FLOG(_L("Bring FOTA into FG")); 
       
   101       	task.BringToForeground();
       
   102       }  
       
   103     else
       
   104         {
       
   105         if ( aAlsoFSW ) ui->HideApplicationFromFSW( ETrue );
       
   106 
       
   107         task.SendToBackground();      // the task whose wingroup is at next 
       
   108                                       // ordinal position is brought to 
       
   109                                       // foreground
       
   110 
       
   111         }
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CFotaSrvApp::~CFotaSrvApp()
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 CFotaSrvApp::~CFotaSrvApp()
       
   119     {
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // CFotaSrvApp::CreateDocumentL()
       
   124 // Creates FotaSrvDocument object
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 CApaDocument* CFotaSrvApp::CreateDocumentL()
       
   128     {
       
   129     #ifdef _FOTA_DEBUG
       
   130     RDebug::Print( _L( "[FotaServer] CFotaSrvApp::CreateDocumentL:" ) );
       
   131     #endif 
       
   132     iDocument = CFotaSrvDocument::NewL( *this );
       
   133     return iDocument;
       
   134     }
       
   135 
       
   136 #include <eikstart.h>
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // NewApplication() 
       
   140 // Constructs CFotaSrvApp
       
   141 // Returns: CApaDocument*: created application object
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 LOCAL_C CApaApplication* NewApplication()
       
   145     {
       
   146     #ifdef _FOTA_DEBUG
       
   147     RDebug::Print( _L( "[FotaServer] CApaApplication* NewApplication:" ) );
       
   148     #endif 
       
   149     return new CFotaSrvApp;
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // ServerL() 
       
   154 // Getter for server
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 CFotaServer* CFotaSrvApp::Server()
       
   158     {
       
   159     return iFotaServer;
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // NewAppServerL() 
       
   164 // Called by framwork
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 void CFotaSrvApp::NewAppServerL( CApaAppServer*& aAppServer )
       
   168 	{
       
   169     #ifdef _FOTA_DEBUG
       
   170 	RDebug::Print( _L( "[FotaServer] CFotaSrvApp::NewAppServerL:" ) );
       
   171     #endif 
       
   172     iFotaServer =  new (ELeave) CFotaServer();
       
   173     iFotaServer->iParentApp = this;
       
   174     aAppServer  = iFotaServer;
       
   175 	}
       
   176 
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // E32Main
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 GLDEF_C TInt E32Main()
       
   183     {
       
   184     TInt err;
       
   185     RProcess pr; TFullName fn = pr.FullName(); 
       
   186     #ifdef _FOTA_DEBUG
       
   187     RDebug::Print(_L("[FotaServer] E32Main:    >> called by %S"), &fn);
       
   188     #endif
       
   189     err = EikStart::RunApplication( NewApplication );
       
   190     #ifdef _FOTA_DEBUG
       
   191     RDebug::Print(_L("[FotaServer] E32Main:    <<"));
       
   192     #endif
       
   193     return err;
       
   194     }
       
   195 
       
   196 // End of File