terminalsecurity/SCP/DmEventNotifier/src/MMCService.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 MMC insertion, removal service
       
    15  *
       
    16  */
       
    17 
       
    18 //System includes
       
    19 #include <centralrepository.h>
       
    20 //User includes
       
    21 #include "MMCService.h"
       
    22 #include "DmEventNotifierDebug.h"
       
    23 
       
    24 // ====================== MEMBER FUNCTIONS ===================================
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CMmcService::NewL
       
    28 // ---------------------------------------------------------------------------
       
    29 CMmcService* CMmcService::NewL()
       
    30     {
       
    31     FLOG(_L("CMmcService::NewL >>"));
       
    32 
       
    33     TInt value (KErrNotFound);
       
    34 
       
    35     RProperty::Get(KMMCPSKey.iConditionCategory, KMMCPSKey.iConditionKey, value);
       
    36     CMmcService* self (NULL);
       
    37     if(value == 0)
       
    38         {
       
    39         FLOG(_L("MMC is removed, hence setting for insertion..."));
       
    40         self = new (ELeave) CMmcService(KMMCPSKeyConditionInsert);
       
    41         }
       
    42     else //(value == 1)
       
    43         {
       
    44         FLOG(_L("MMC is inserted, hence setting for removal..."))
       
    45         self = new (ELeave) CMmcService(KMMCPSKeyConditionRemove);
       
    46         }
       
    47 
       
    48     CleanupStack::PushL(self);
       
    49 
       
    50     self->ConstructL();
       
    51     self->iLookingFor = value;
       
    52     CleanupStack::Pop(self);
       
    53     FLOG(_L("CMmcService::NewL <<"));
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CMmcService::NewLC
       
    59 // ---------------------------------------------------------------------------
       
    60 CMmcService* CMmcService::NewLC()
       
    61     {
       
    62     FLOG(_L("CMmcService::NewLC >>"));
       
    63 
       
    64     CMmcService* self = CMmcService::NewL();
       
    65     CleanupStack::PushL(self);
       
    66 
       
    67     FLOG(_L("CMmcService::NewLC <<"));
       
    68     return self;
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // CMmcService::ConstructL
       
    73 // ---------------------------------------------------------------------------
       
    74 void CMmcService::ConstructL()
       
    75     {
       
    76     FLOG(_L("CMmcService::ConstructL >>"));
       
    77 
       
    78     FLOG(_L("CMmcService::ConstructL <<"));
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CMmcService::CMmcService
       
    83 // ---------------------------------------------------------------------------
       
    84 CMmcService::CMmcService(const TPSKeyCondition& aPSKeyCondition):CDmEventServiceBase(aPSKeyCondition, EMmcService)
       
    85             {
       
    86             FLOG(_L("CMmcService::CMmcService >>"));
       
    87 
       
    88             FLOG(_L("CMmcService::CMmcService <<"));
       
    89             }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // CMmcService::~CMmcService
       
    93 // ---------------------------------------------------------------------------
       
    94 CMmcService::~CMmcService()
       
    95     {
       
    96 
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CMmcService::IsKeyValid
       
   101 // ---------------------------------------------------------------------------
       
   102 TBool CMmcService::IsKeyValid()
       
   103     {
       
   104     FLOG(_L("CMmcService::IsKeyValid >>"));
       
   105     TBool ret (EFalse);
       
   106     TInt value (KErrNone);
       
   107 
       
   108     //Just read the key to find if it exists
       
   109     if (RProperty::Get(KMMCPSKey.iConditionCategory, KMMCPSKey.iConditionKey, value) == KErrNone)
       
   110         ret = ETrue;
       
   111 
       
   112     FLOG(_L("CMmcService::IsKeyValid, return = %d >>"), ret);
       
   113     return ret;
       
   114     }
       
   115 
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CMmcService::WaitForRequestCompleteL
       
   119 // ---------------------------------------------------------------------------
       
   120 void CMmcService::WaitForRequestCompleteL()
       
   121     {
       
   122     FLOG(_L("CMmcService::WaitForRequestCompleteL >>"));
       
   123     TInt value (KErrNone);
       
   124 
       
   125     iOperation = ENoOpn;
       
   126     TInt err = RProperty::Get(KMMCPSKey.iConditionCategory, KMMCPSKey.iConditionKey, value);
       
   127     FLOG(_L("err = %d"), err);
       
   128 
       
   129     switch (value)
       
   130         {
       
   131         case 0:
       
   132             {
       
   133             iOperation = EOpnRemoved;
       
   134             }
       
   135             break;
       
   136         case 1: 
       
   137             {
       
   138             iOperation = EOpnInserted;
       
   139             }
       
   140             break;
       
   141         default:
       
   142             {
       
   143             iOperation = EOpnUnknown;
       
   144             }
       
   145             break;
       
   146         }
       
   147     FLOG(_L("CMmcService::WaitForRequestCompleteL <<"));
       
   148     }
       
   149 
       
   150 // ---------------------------------------------------------------------------
       
   151 // CMmcService::TaskName
       
   152 // ---------------------------------------------------------------------------
       
   153 const TDesC& CMmcService::TaskName()
       
   154     {
       
   155     return  KMmcTaskName();
       
   156     }
       
   157 
       
   158 void CMmcService::UpdateMmcStatus()
       
   159     {
       
   160     FLOG(_L("Looking for %d"), iLookingFor);
       
   161 
       
   162     if (iLookingFor != KErrNotFound)
       
   163         {
       
   164         CRepository * rep = CRepository::NewL(TUid::Uid(KAppUidDmEventNotifier));
       
   165         rep->Set(KMMCStatus, iLookingFor);
       
   166         delete rep; rep = NULL;
       
   167         }
       
   168     else 
       
   169         {
       
   170         FLOG(_L("Can't set value %d to cenrep"), iLookingFor);
       
   171         }
       
   172     }