appinstaller/AppinstUi/Server/Src/SWInstAppUi.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 2002-2008 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:   This file contains the implementation of CSWInstAppUi 
       
    15 *                class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include <aknenv.h>
       
    23 #include <SWInstDefs.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 #include "SWInstAppUi.h"
       
    27 #include "SWInstInstallRequest.h"
       
    28 #include "SWInstServer.h"
       
    29 #include "SWInstDefs.h"
       
    30 
       
    31 using namespace SwiUI;
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CSWInstAppUi::CSWInstAppUi
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CSWInstAppUi::CSWInstAppUi()
       
    40     {
       
    41     SetFullScreenApp( EFalse );
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSWInstAppUi::ConstructL
       
    46 // Symbian 2nd phase constructor can leave.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CSWInstAppUi::ConstructL()
       
    50     {
       
    51     BaseConstructL( EStandardApp | ENoScreenFurniture | ENonStandardResourceFile
       
    52             | EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
       
    53 
       
    54     // Create private path for the process
       
    55     iEikonEnv->FsSession().CreatePrivatePath( EDriveC );
       
    56     iOkToExit = ETrue;    
       
    57     }
       
    58 
       
    59 // Destructor
       
    60 CSWInstAppUi::~CSWInstAppUi()
       
    61     {    
       
    62     if ( iReqObj )
       
    63         {
       
    64         iReqObj->Cancel();
       
    65         delete iReqObj;        
       
    66         }    
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CSWInstAppUi::RunFileL
       
    71 // Process file.
       
    72 // (other items were commented in a header).
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CSWInstAppUi::InstallL( const TDesC& aFileName )
       
    76     {
       
    77     // Currently only installation supported from here
       
    78     __ASSERT_ALWAYS( !iReqObj, User::Leave( KSWInstErrBusy ) );
       
    79 
       
    80     TInstallReq params;        
       
    81     iReqObj = CSWInstInstallRequest::NewL( ERequestInstall );
       
    82     iReqObj->SetCallback( this );
       
    83     static_cast<CSWInstInstallRequest*>(iReqObj)->Install( aFileName, params );
       
    84     }
       
    85 
       
    86 void CSWInstAppUi::InstallL( RFile& aFile )
       
    87     {
       
    88     // Currently only installation supported from here
       
    89     __ASSERT_ALWAYS( !iReqObj, User::Leave( KSWInstErrBusy ) );
       
    90 
       
    91     TInstallReq params;        
       
    92     iReqObj = CSWInstInstallRequest::NewL( ERequestInstall );
       
    93     iReqObj->SetCallback( this );
       
    94 
       
    95     RFile file;
       
    96     file.Duplicate( aFile );    
       
    97     
       
    98     static_cast<CSWInstInstallRequest*>(iReqObj)->Install( file, params ); // Ownership of file transfers
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CSWInstAppUi::RequestCompleted
       
   103 // Called when request is completed.
       
   104 // (other items were commented in a header).
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CSWInstAppUi::RequestCompleted( TInt /*aResult*/ )
       
   108     {
       
   109     iOkToExit = ETrue;    
       
   110    
       
   111     RunAppShutter();
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CSWInstAppUi::HandleCommandL
       
   116 // Handles user commands.
       
   117 // (other items were commented in a header).
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CSWInstAppUi::HandleCommandL( TInt aCommand )
       
   121     {
       
   122     if ( aCommand == EEikCmdExit )
       
   123         {
       
   124         CSWInstServer* server = reinterpret_cast<CSWInstServer*>(iEikonEnv->AppServer());        
       
   125                
       
   126         if ( iReqObj && iReqObj->IsActive() && !iCancelInProgress )
       
   127             {
       
   128             // In this case we have no server running.
       
   129             iCancelInProgress = ETrue;                            
       
   130             iOkToExit = EFalse;
       
   131 
       
   132             // We must cancel the request before we can exit
       
   133             iReqObj->Cancel();   
       
   134             }
       
   135         else if ( server && !iCancelInProgress )
       
   136             {            
       
   137             // In this case we might have an pending request in the server side.
       
   138 //            iCancelInProgress = ETrue;
       
   139             iOkToExit = EFalse;
       
   140             
       
   141             // Prepare the server for exit. This will eventually call RequestCompletedL
       
   142             // when all requests have been cancelled.
       
   143             server->PrepareForExit( this );
       
   144             }
       
   145 
       
   146         if ( iOkToExit )
       
   147             {
       
   148             Exit();
       
   149             }        
       
   150         }
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CSWInstAppUi::ProcessCommandParametersL
       
   155 // Processes shell commands.
       
   156 // (other items were commented in a header).
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 TBool CSWInstAppUi::ProcessCommandParametersL( TApaCommand /*aCommand*/,
       
   160                                                TFileName& /*aDocumentName*/,
       
   161                                                const TDesC8& /*aTail*/)
       
   162     {
       
   163     return ETrue;
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CSWInstAppUi::HandleSystemEventL
       
   168 // Handles system events.
       
   169 // (other items were commented in a header).
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 void CSWInstAppUi::HandleSystemEventL( const TWsEvent &aEvent )
       
   173     {
       
   174     switch (*(TApaSystemEvent*)(aEvent.EventData()))
       
   175         {
       
   176 	case EApaSystemEventShutdown:
       
   177             // We need to exit
       
   178             HandleCommandL( EEikCmdExit );            
       
   179             break;
       
   180 	default:
       
   181             CAknAppUi::HandleSystemEventL(aEvent);
       
   182             break;
       
   183         }
       
   184     }
       
   185 
       
   186 
       
   187 //  End of File