terminalsecurity/SCP/DmEventNotifier/src/SwApplicationService.cpp
changeset 0 b497e44ab2fc
child 5 3f7d9dbe57c8
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2009 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 class implements the Software (un)install service
       
    15 *
       
    16 */
       
    17 //User include
       
    18 #include "SwApplicationService.h"
       
    19 #include "DmEventNotifierDebug.h"
       
    20 
       
    21 // ====================== MEMBER FUNCTIONS ===================================
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // CSwApplicationService::NewL
       
    25 // ---------------------------------------------------------------------------
       
    26 CSwApplicationService* CSwApplicationService::NewL()
       
    27     {
       
    28     FLOG(_L("CSwApplicationService::NewL >>"));
       
    29 
       
    30     CSwApplicationService* self = new (ELeave) CSwApplicationService(KSwPSKeyCondition);
       
    31     CleanupStack::PushL(self);
       
    32 
       
    33     self->ConstructL();
       
    34 
       
    35     CleanupStack::Pop(self);
       
    36     FLOG(_L("CSwApplicationService::NewL <<"));
       
    37     return self;
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CSwApplicationService::NewLC
       
    42 // ---------------------------------------------------------------------------
       
    43 CSwApplicationService* CSwApplicationService::NewLC()
       
    44     {
       
    45     FLOG(_L("CSwApplicationService::NewLC >>"));
       
    46 
       
    47     CSwApplicationService* self = CSwApplicationService::NewL();
       
    48     CleanupStack::PushL(self);
       
    49 
       
    50     FLOG(_L("CSwApplicationService::NewLC <<"));
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CSwApplicationService::ConstructL
       
    56 // ---------------------------------------------------------------------------
       
    57 void CSwApplicationService::ConstructL()
       
    58     {
       
    59     FLOG(_L("CSwApplicationService::ConstructL >>"));
       
    60 
       
    61     FLOG(_L("CSwApplicationService::ConstructL <<"));
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CSwApplicationService::CSwApplicationService
       
    66 // ---------------------------------------------------------------------------
       
    67 CSwApplicationService::CSwApplicationService(const TPSKeyCondition& aPSKeyCondition):CDmEventServiceBase(aPSKeyCondition, ESoftwareService)
       
    68         {
       
    69         FLOG(_L("CSwApplicationService::CSwApplicationService >>"));
       
    70 
       
    71         FLOG(_L("CSwApplicationService::CSwApplicationService <<"));
       
    72         }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CSwApplicationService::~CSwApplicationService
       
    76 // ---------------------------------------------------------------------------
       
    77 CSwApplicationService::~CSwApplicationService()
       
    78     {
       
    79 
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CSwApplicationService::IsKeyValid
       
    84 // ---------------------------------------------------------------------------
       
    85 TBool CSwApplicationService::IsKeyValid()
       
    86     {
       
    87     FLOG(_L("CSwApplicationService::IsKeyValid >>"));
       
    88     TBool ret (EFalse);
       
    89     TInt value (KErrNone);
       
    90 
       
    91     //Just read the key to find if it exists
       
    92     if (RProperty::Get(KSwPSKeyCondition.iPskey.iConditionCategory, KSwPSKeyCondition.iPskey.iConditionKey, value) == KErrNone)
       
    93         ret = ETrue;
       
    94 
       
    95     FLOG(_L("CSwApplicationService::IsKeyValid, return = %d >>"), ret);
       
    96     return ret;
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CSwApplicationService::WaitForRequestCompleteL
       
   101 // ---------------------------------------------------------------------------
       
   102 void CSwApplicationService::WaitForRequestCompleteL()
       
   103     {
       
   104     FLOG(_L("CSwApplicationService::WaitForRequestCompleteL >>"));
       
   105 
       
   106     TRequestStatus status (KErrNone);
       
   107     RProperty prop;
       
   108     TInt value (KErrNone);
       
   109 
       
   110     iOperation = ENoOpn;
       
   111     TPSKey pskey = GetPSKeyCondition().iPskey;
       
   112     do {
       
   113         FLOG(_L("Waiting for IDLE state..."))
       
   114         __LEAVE_IF_ERROR( prop.Attach(pskey.iConditionCategory, pskey.iConditionKey));
       
   115     
       
   116         prop.Subscribe(status);
       
   117         User::WaitForRequest(status);
       
   118     
       
   119         __LEAVE_IF_ERROR( prop.Get(pskey.iConditionCategory, pskey.iConditionKey, value));
       
   120     }while (IsSwInIdle(value));
       
   121 
       
   122     FLOG(_L("CSwApplicationService::WaitForRequestCompleteL >>"));
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // CSwApplicationService::IsSwInIdle
       
   127 // ---------------------------------------------------------------------------
       
   128 TBool CSwApplicationService::IsSwInIdle(TInt aValue)
       
   129     {
       
   130     FLOG(_L("CSwApplicationService::IsSwInIdle, value = %d >> "), aValue);
       
   131 
       
   132     TInt operation(aValue & Swi::KSwisOperationMask);
       
   133     TInt operationStatus(aValue & Swi::KSwisOperationStatusMask);
       
   134     TBool ret (EFalse);
       
   135 
       
   136     FLOG(_L("operation %d, status %d"), operation, operationStatus);
       
   137 
       
   138     if (Swi::ESwisStatusSuccess == operationStatus) 
       
   139         {
       
   140         switch (operation)
       
   141             {
       
   142             case Swi::ESwisInstall: 
       
   143                 {
       
   144                 FLOG(_L("Installation in progress"));
       
   145                 iOperation = EOpnInstall;
       
   146                 }
       
   147                 break;
       
   148             case Swi::ESwisUninstall:
       
   149                 {
       
   150                 FLOG(_L("Uninstallation in progress"));
       
   151                 iOperation = EOpnUninstall;
       
   152                 }
       
   153                 break;
       
   154             case Swi::ESwisRestore:
       
   155                 {
       
   156                 FLOG(_L("Restore in progress"));
       
   157                 iOperation = EOpnRestore;
       
   158                 }
       
   159                 break;
       
   160             default:
       
   161                 {
       
   162                 FLOG(_L("Unknown operation"));
       
   163                 iOperation = EOpnUnknown;
       
   164                 }
       
   165             }
       
   166         }
       
   167     ret = (operation != Swi::ESwisNone)? ETrue:EFalse;
       
   168     FLOG(_L("CSwApplicationService::IsSwInIdle, ret = %d << "),ret);
       
   169     return ret;
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // CSwApplicationService::TaskName
       
   174 // ---------------------------------------------------------------------------
       
   175 const TDesC& CSwApplicationService::TaskName()
       
   176     {
       
   177     return  KSisTaskName();
       
   178     }