terminalsecurity/SCP/SCPClient/src/SCPLockObserver.cpp
branchRCL_3
changeset 15 007508d6e57b
parent 2 5594fba90824
child 23 4af31167ea77
equal deleted inserted replaced
14:504e41245867 15:007508d6e57b
    22 #include "secui.hrh"
    22 #include "secui.hrh"
    23 #include "SCPLockObserver.h"
    23 #include "SCPLockObserver.h"
    24 #include "SCPQueryDialog.h"
    24 #include "SCPQueryDialog.h"
    25 #include "SCPDebug.h"
    25 #include "SCPDebug.h"
    26 
    26 
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
    27 // ================= MEMBER FUNCTIONS =======================
    29 //
    28 //
    30 // ----------------------------------------------------------
    29 // ----------------------------------------------------------
    31 // CSCPLockObserver::NewL()
    30 // CSCPLockObserver::NewL()
    32 // Constructs a new entry with given values.
    31 // Constructs a new entry with given values.
    53 // ----------------------------------------------------------
    52 // ----------------------------------------------------------
    54 //
    53 //
    55 CSCPLockObserver::~CSCPLockObserver()
    54 CSCPLockObserver::~CSCPLockObserver()
    56     {
    55     {
    57     
    56     
    58     Dprint(_L("CSCPLockObserver::~CSCPLockObserver"));
    57     Dprint(_L("CSCPLockObserver::~CSCPLockObserver >>>"));
    59     
       
    60     Cancel();
    58     Cancel();
       
    59     Dprint(_L("CSCPLockObserver::~CSCPLockObserver <<<"));
    61     }
    60     }
    62 //
    61 //
    63 // ----------------------------------------------------------
    62 // ----------------------------------------------------------
    64 // CSCPLockObserver::Start()
    63 // CSCPLockObserver::Start()
    65 // Starts listening an event 
    64 // Starts listening an event 
    78     return KErrInUse;
    77     return KErrInUse;
    79     }
    78     }
    80         
    79         
    81     iStatus = KRequestPending;
    80     iStatus = KRequestPending;
    82     
    81     
    83     switch(iType)
    82     switch(iType) {
    84         {
    83         case ESecUiDeviceLockObserver:
    85             case ESecUiDeviceLockObserver:
    84             
    86                 
    85             Dprint(_L("CSCPLockObserver::Start() Device Lock Observer"));
    87                 Dprint(_L("CSCPLockObserver::Start() Device Lock Observer"));
    86             
    88                 
    87             iProperty.Attach(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus); 
    89                 iProperty.Attach(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus); 
    88             break;
    90                 break;
    89         case ESecUiCallStateObserver: {
    91 #if 0          
    90             Dprint(_L("CSCPLockObserver::Start() Call State Observer"));                
    92             case ESecUiRequestStateObserver:
    91             iProperty.Attach(KPSUidCtsyCallInformation, KCTsyCallState);
    93                     
    92         }
    94                     Dprint(_L("CSCPLockObserver::Start() Request State Observer"));
    93         break;
    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 
    94 
   106             default:
    95         default:
   107                 break;
    96             break;
   108         }
    97     }
   109     
    98     
   110     iProperty.Subscribe(iStatus);
    99     iProperty.Subscribe(iStatus);
       
   100     iSubscribedToEvent = ETrue;
   111     SetActive();
   101     SetActive();
   112     iSubscribedToEvent = ETrue;
   102     Dprint(_L("CSCPLockObserver::Start() END"));    
   113     
       
   114     Dprint(_L("CSCPLockObserver::Start() END"));
       
   115     
       
   116     return KErrNone;
   103     return KErrNone;
   117     }
   104     }
   118 //
   105 //
   119 // ----------------------------------------------------------
   106 // ----------------------------------------------------------
   120 // CLockObserver::CLockObserver()
   107 // CLockObserver::CLockObserver()
   121 // C++ constructor
   108 // C++ constructor
   122 // ----------------------------------------------------------
   109 // ----------------------------------------------------------
   123 // 
   110 // 
   124 CSCPLockObserver::CSCPLockObserver(CSCPQueryDialog* aDialog, TInt aType) : CActive(0), iDialog(aDialog), iSubscribedToEvent(EFalse), iType(aType)
   111 CSCPLockObserver :: CSCPLockObserver(CSCPQueryDialog* aDialog, TInt aType) : CActive(0),
   125 	{                            
   112         iDialog(aDialog), iType(aType), 
   126     }
   113         iInformCallEnding(EFalse), iSubscribedToEvent(EFalse) {
       
   114     
       
   115     TInt lStatus;
       
   116     RProperty :: Get(KPSUidCtsyCallInformation, KCTsyCallState, lStatus);
       
   117     
       
   118     switch(lStatus) {
       
   119         default:
       
   120         case EPSCTsyCallStateUninitialized:
       
   121         case EPSCTsyCallStateNone:
       
   122             iInformCallEnding = EFalse;
       
   123             break;
       
   124         case EPSCTsyCallStateDisconnecting:
       
   125         case EPSCTsyCallStateAlerting:
       
   126         case EPSCTsyCallStateHold:
       
   127         case EPSCTsyCallStateRinging:
       
   128         case EPSCTsyCallStateDialling:
       
   129         case EPSCTsyCallStateAnswering:
       
   130         case EPSCTsyCallStateConnected:
       
   131             iInformCallEnding = ETrue;
       
   132             break;
       
   133     };
       
   134 }
   127 //
   135 //
   128 // ----------------------------------------------------------
   136 // ----------------------------------------------------------
   129 // CSCPLockObserver::ConstructL()
   137 // CSCPLockObserver::ConstructL()
   130 // Symbian OS default constructor
   138 // Symbian OS default constructor
   131 // ----------------------------------------------------------
   139 // ----------------------------------------------------------
   147 // ----------------------------------------------------------
   155 // ----------------------------------------------------------
   148 // CSCPLockObserver::RunL()
   156 // CSCPLockObserver::RunL()
   149 // Called by Active Scheduler
   157 // Called by Active Scheduler
   150 // ----------------------------------------------------------
   158 // ----------------------------------------------------------
   151 // 
   159 // 
   152 void CSCPLockObserver::RunL()
   160 void CSCPLockObserver :: RunL() {
   153 	{
   161     Dprint(_L("[CSCPLockObserver]-> RunL() >>>"));
   154 	
   162     
   155     Dprint(_L("CSCPLockObserver::RunL() BEGIN"));
   163     switch(iType) {
   156     
   164         case ESecUiDeviceLockObserver:
   157     
   165         TInt autolockState;
   158     switch(iType)
   166         iProperty.Get(autolockState);
   159         {
   167         
   160             case ESecUiDeviceLockObserver:
   168         if(autolockState > EAutolockOff) {            
   161                  TInt autolockState;
   169             Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Device Lock"));
   162                  iProperty.Get( autolockState );
   170             iDialog->TryCancelQueryL(ESecUiDeviceLocked);
   163                  if (autolockState > EAutolockOff)
   171             iSubscribedToEvent = EFalse;
   164                     {
   172         }
   165                     
   173         break;
   166                     Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Device Lock"));
   174         case ESecUiCallStateObserver: {
   167                     
   175             TInt callState;
   168                 	iDialog->TryCancelQueryL(ESecUiDeviceLocked);
   176             iProperty.Get(callState);
   169                 	iSubscribedToEvent = EFalse;
   177             Dprint( (_L("CSCPLockObserver::RunL() callState before Start() : %d"), callState ));
       
   178             Start();
       
   179             
       
   180             switch(callState) {
       
   181                 default:
       
   182                     break;
       
   183                 case EPSCTsyCallStateNone:
       
   184                     if(iInformCallEnding) {
       
   185                         Dprint( (_L("CSCPLockObserver::RunL() Branched to EPSCTsyCallStateNone")));
       
   186                         iDialog->TryCancelQueryL(EEnded);                    
       
   187                         iInformCallEnding = EFalse;
   170                     }
   188                     }
       
   189                     break;
       
   190                 case EPSCTsyCallStateAlerting:
       
   191                 case EPSCTsyCallStateHold:
       
   192                 case EPSCTsyCallStateRinging:
       
   193                 case EPSCTsyCallStateDialling:
       
   194                 case EPSCTsyCallStateAnswering:
       
   195                 case EPSCTsyCallStateConnected: {
       
   196                         Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Active Call"));                
       
   197                         TRAPD(lErr, iDialog->TryCancelQueryL(EInProgress));
       
   198                         Dprint( (_L("CSCPLockObserver::RunL() lErr : %d"), lErr ));                        
       
   199                         iInformCallEnding = ETrue;
       
   200                 }
   171                 break;
   201                 break;
   172 #if 0         
   202             };
   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         }
   203         }
   204 
   204         break;
   205    
   205         default:
   206 	
   206             break;
   207     Dprint(_L("CSCPLockObserver::RunL() END"));
   207     }
   208     
   208     
   209 	}
   209     Dprint(_L("[CSCPLockObserver]-> RunL() <<<"));    
       
   210 }
   210 //
   211 //
   211 // ----------------------------------------------------------
   212 // ----------------------------------------------------------
   212 // CSCPLockObserver::DoCancel()
   213 // CSCPLockObserver::DoCancel()
   213 // Cancels event listening
   214 // Cancels event listening
   214 // ----------------------------------------------------------
   215 // ----------------------------------------------------------
   217     {
   218     {
   218     
   219     
   219     Dprint(_L("CSCPLockObserver::DoCancel() BEGIN"));
   220     Dprint(_L("CSCPLockObserver::DoCancel() BEGIN"));
   220     
   221     
   221     if(iSubscribedToEvent)
   222     if(iSubscribedToEvent)
   222     	iProperty.Cancel();
   223         iProperty.Cancel();
       
   224     
   223     iStatus = KErrNone;
   225     iStatus = KErrNone;
   224     
   226     
   225     Dprint(_L("CSCPLockObserver::DoCancel() END"));
   227     Dprint(_L("CSCPLockObserver::DoCancel() END"));
   226     
   228     
   227     }
   229     }