terminalsecurity/SCP/SCPClient/src/SCPLockObserver.cpp
changeset 0 b497e44ab2fc
child 2 5594fba90824
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2000 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: Observer for Set System Locked event
       
    15 */
       
    16 #include    <bldvariant.hrh>
       
    17 #include    <e32property.h>
       
    18 #include	<PSVariables.h>
       
    19 #include	<coreapplicationuisdomainpskeys.h>
       
    20 #include <ctsydomainpskeys.h>
       
    21 //#include    <SecurityUIsPrivatePSKeys.h>
       
    22 #include "SecUi.hrh"
       
    23 #include "SCPLockObserver.h"
       
    24 #include "SCPQueryDialog.h"
       
    25 #include "SCPDebug.h"
       
    26 
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 //
       
    30 // ----------------------------------------------------------
       
    31 // CSCPLockObserver::NewL()
       
    32 // Constructs a new entry with given values.
       
    33 // ----------------------------------------------------------
       
    34 //
       
    35 CSCPLockObserver* CSCPLockObserver::NewL(CSCPQueryDialog* aDialog, TInt aType)
       
    36     {
       
    37     
       
    38     Dprint(_L("CSCPLockObserver::NewL() BEGIN"));
       
    39     
       
    40     CSCPLockObserver* self = new (ELeave) CSCPLockObserver(aDialog, aType);
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop();
       
    44     
       
    45     Dprint(_L("CSCPLockObserver::NewL() END"));
       
    46     
       
    47     return self;
       
    48     }
       
    49 //
       
    50 // ----------------------------------------------------------
       
    51 // CSCPLockObserver::CSCPLockObserver()
       
    52 // Destructor
       
    53 // ----------------------------------------------------------
       
    54 //
       
    55 CSCPLockObserver::~CSCPLockObserver()
       
    56     {
       
    57     
       
    58     Dprint(_L("CSCPLockObserver::~CSCPLockObserver"));
       
    59     
       
    60     Cancel();
       
    61     }
       
    62 //
       
    63 // ----------------------------------------------------------
       
    64 // CSCPLockObserver::Start()
       
    65 // Starts listening an event 
       
    66 // ----------------------------------------------------------
       
    67 //
       
    68 TInt CSCPLockObserver::Start()
       
    69     {
       
    70     
       
    71     Dprint(_L("CSCPLockObserver::Start() BEGIN"));
       
    72     
       
    73     if (IsActive())
       
    74     {
       
    75     
       
    76     Dprint(_L("CSCPLockObserver::Start() In use!!!"));
       
    77     
       
    78     return KErrInUse;
       
    79     }
       
    80         
       
    81     iStatus = KRequestPending;
       
    82     
       
    83     switch(iType)
       
    84         {
       
    85             case ESecUiDeviceLockObserver:
       
    86                 
       
    87                 Dprint(_L("CSCPLockObserver::Start() Device Lock Observer"));
       
    88                 
       
    89                 iProperty.Attach(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus); 
       
    90                 break;
       
    91 #if 0          
       
    92             case ESecUiRequestStateObserver:
       
    93                     
       
    94                     Dprint(_L("CSCPLockObserver::Start() Request State Observer"));
       
    95                     
       
    96                     iProperty.Attach(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel); 
       
    97                 break;
       
    98 #endif
       
    99             case ESecUiCallStateObserver:
       
   100                 
       
   101                 Dprint(_L("CSCPLockObserver::Start() Call State Observer"));
       
   102                 
       
   103                 iProperty.Attach(KPSUidCtsyCallInformation, KCTsyCallState); 
       
   104                 break;
       
   105 
       
   106             default:
       
   107                 break;
       
   108         }
       
   109     
       
   110     iProperty.Subscribe(iStatus);
       
   111     SetActive();
       
   112     iSubscribedToEvent = ETrue;
       
   113     
       
   114     Dprint(_L("CSCPLockObserver::Start() END"));
       
   115     
       
   116     return KErrNone;
       
   117     }
       
   118 //
       
   119 // ----------------------------------------------------------
       
   120 // CLockObserver::CLockObserver()
       
   121 // C++ constructor
       
   122 // ----------------------------------------------------------
       
   123 // 
       
   124 CSCPLockObserver::CSCPLockObserver(CSCPQueryDialog* aDialog, TInt aType) : CActive(0), iDialog(aDialog), iSubscribedToEvent(EFalse), iType(aType)
       
   125 	{                            
       
   126     }
       
   127 //
       
   128 // ----------------------------------------------------------
       
   129 // CSCPLockObserver::ConstructL()
       
   130 // Symbian OS default constructor
       
   131 // ----------------------------------------------------------
       
   132 // 
       
   133 void CSCPLockObserver::ConstructL()
       
   134     {
       
   135     
       
   136     Dprint(_L("CSCPLockObserver::ConstructL() BEGIN"));
       
   137     
       
   138     // Add this active object to the scheduler.
       
   139 	CActiveScheduler::Add(this);
       
   140 	// Begin obsering PubSub event  
       
   141 	Start();
       
   142 	
       
   143     Dprint(_L("CSCPLockObserver::ConstructL() END"));
       
   144     	
       
   145     }
       
   146 //
       
   147 // ----------------------------------------------------------
       
   148 // CSCPLockObserver::RunL()
       
   149 // Called by Active Scheduler
       
   150 // ----------------------------------------------------------
       
   151 // 
       
   152 void CSCPLockObserver::RunL()
       
   153 	{
       
   154 	
       
   155     Dprint(_L("CSCPLockObserver::RunL() BEGIN"));
       
   156     
       
   157     
       
   158     switch(iType)
       
   159         {
       
   160             case ESecUiDeviceLockObserver:
       
   161                  TInt autolockState;
       
   162                  iProperty.Get( autolockState );
       
   163                  if (autolockState > EAutolockOff)
       
   164                     {
       
   165                     
       
   166                     Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Device Lock"));
       
   167                     
       
   168                 	iDialog->TryCancelQueryL(ESecUiDeviceLocked);
       
   169                 	iSubscribedToEvent = EFalse;
       
   170                     }
       
   171                 break;
       
   172 #if 0         
       
   173             case ESecUiRequestStateObserver:
       
   174                  TInt requestState;
       
   175                  iProperty.Get( requestState );
       
   176                  if(requestState == ESecurityUIsQueryRequestCanceled)
       
   177                     {
       
   178                      
       
   179                     Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Req Canceled"));
       
   180                     
       
   181                 	iDialog->TryCancelQueryL(EEikBidCancel);
       
   182                 	iSubscribedToEvent = EFalse;   
       
   183                     }
       
   184                 break;
       
   185 #endif
       
   186             case ESecUiCallStateObserver:
       
   187                 TInt callState;
       
   188                 iProperty.Get( callState );
       
   189 				 
       
   190 				 Dprint( (_L("CSCPLockObserver::RunL() callState : %d"),callState ));
       
   191                 if(callState == EPSCTsyCallStateDisconnecting)
       
   192                     {
       
   193                      
       
   194                     Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Active Call"));
       
   195                     
       
   196                 	iDialog->TryCancelQueryL(EPSCTsyCallStateDisconnecting);
       
   197                 	iSubscribedToEvent = EFalse;   
       
   198                     }
       
   199                 break;
       
   200 
       
   201             default:
       
   202                 break;
       
   203         }
       
   204 
       
   205    
       
   206 	
       
   207     Dprint(_L("CSCPLockObserver::RunL() END"));
       
   208     
       
   209 	}
       
   210 //
       
   211 // ----------------------------------------------------------
       
   212 // CSCPLockObserver::DoCancel()
       
   213 // Cancels event listening
       
   214 // ----------------------------------------------------------
       
   215 // 
       
   216 void CSCPLockObserver::DoCancel()
       
   217     {
       
   218     
       
   219     Dprint(_L("CSCPLockObserver::DoCancel() BEGIN"));
       
   220     
       
   221     if(iSubscribedToEvent)
       
   222     	iProperty.Cancel();
       
   223     iStatus = KErrNone;
       
   224     
       
   225     Dprint(_L("CSCPLockObserver::DoCancel() END"));
       
   226     
       
   227     }
       
   228 //
       
   229 // ----------------------------------------------------------
       
   230 // CSCPLockObserver::StopObserver()
       
   231 // Cancels event listening
       
   232 // ----------------------------------------------------------
       
   233 //     
       
   234 void CSCPLockObserver::StopObserver()
       
   235 	{
       
   236 	
       
   237     Dprint(_L("CSCPLockObserver::StopObserver() BEGIN"));
       
   238     
       
   239     Cancel();
       
   240     
       
   241     Dprint(_L("CSCPLockObserver::StopObserver() END"));
       
   242     
       
   243     }
       
   244 //
       
   245 // ----------------------------------------------------------
       
   246 // CSCPLockObserver::StartObserver()
       
   247 // Start event listening
       
   248 // ----------------------------------------------------------
       
   249 //     
       
   250 void CSCPLockObserver::StartObserver()
       
   251 	{
       
   252 	
       
   253     Dprint(_L("CSCPLockObserver::StartObserver() BEGIN"));
       
   254     
       
   255     Start();
       
   256     
       
   257     Dprint(_L("CSCPLockObserver::StartObserver() END"));
       
   258     
       
   259     }
       
   260 //
       
   261 // ----------------------------------------------------------
       
   262 // CSCPLockObserver::SetAddress()
       
   263 // Start event listening
       
   264 // ----------------------------------------------------------
       
   265 //  
       
   266 void CSCPLockObserver::SetAddress(CSCPQueryDialog* aDialog)
       
   267 {
       
   268 	
       
   269     Dprint(_L("CSCPLockObserver::SetAddress() BEGIN"));
       
   270     
       
   271 	iDialog = aDialog;
       
   272 	
       
   273     Dprint(_L("CSCPLockObserver::SetAddress() END"));
       
   274     
       
   275 }
       
   276 // End of file