terminalsecurity/SCP/SCPClient/src/SCPLockObserver.cpp
branchRCL_3
changeset 26 19bba8228ff0
parent 25 b183ec05bd8c
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
    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             case ESecUiCallStateObserver:
    90             Dprint(_L("CSCPLockObserver::Start() Call State Observer"));                
    92                 
    91             iProperty.Attach(KPSUidCtsyCallInformation, KCTsyCallState);
    93                 Dprint(_L("CSCPLockObserver::Start() Call State Observer"));
    92         }
    94                 
    93         break;
    95                 iProperty.Attach(KPSUidCtsyCallInformation, KCTsyCallState); 
       
    96                 break;
       
    97 
    94 
    98             default:
    95         default:
    99                 break;
    96             break;
   100         }
    97     }
   101     
    98     
   102     iProperty.Subscribe(iStatus);
    99     iProperty.Subscribe(iStatus);
       
   100     iSubscribedToEvent = ETrue;
   103     SetActive();
   101     SetActive();
   104     iSubscribedToEvent = ETrue;
   102     Dprint(_L("CSCPLockObserver::Start() END"));    
   105     
       
   106     Dprint(_L("CSCPLockObserver::Start() END"));
       
   107     
       
   108     return KErrNone;
   103     return KErrNone;
   109     }
   104     }
   110 //
   105 //
   111 // ----------------------------------------------------------
   106 // ----------------------------------------------------------
   112 // CLockObserver::CLockObserver()
   107 // CLockObserver::CLockObserver()
   113 // C++ constructor
   108 // C++ constructor
   114 // ----------------------------------------------------------
   109 // ----------------------------------------------------------
   115 // 
   110 // 
   116 CSCPLockObserver::CSCPLockObserver(CSCPQueryDialog* aDialog, TInt aType) : CActive(0), iDialog(aDialog), iSubscribedToEvent(EFalse), iType(aType)
   111 CSCPLockObserver :: CSCPLockObserver(CSCPQueryDialog* aDialog, TInt aType) : CActive(0),
   117 	{                            
   112         iDialog(aDialog), iType(aType), 
   118     }
   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 }
   119 //
   135 //
   120 // ----------------------------------------------------------
   136 // ----------------------------------------------------------
   121 // CSCPLockObserver::ConstructL()
   137 // CSCPLockObserver::ConstructL()
   122 // Symbian OS default constructor
   138 // Symbian OS default constructor
   123 // ----------------------------------------------------------
   139 // ----------------------------------------------------------
   139 // ----------------------------------------------------------
   155 // ----------------------------------------------------------
   140 // CSCPLockObserver::RunL()
   156 // CSCPLockObserver::RunL()
   141 // Called by Active Scheduler
   157 // Called by Active Scheduler
   142 // ----------------------------------------------------------
   158 // ----------------------------------------------------------
   143 // 
   159 // 
   144 void CSCPLockObserver::RunL()
   160 void CSCPLockObserver :: RunL() {
   145 	{
   161     Dprint(_L("[CSCPLockObserver]-> RunL() >>>"));
   146 	
   162     
   147     Dprint(_L("CSCPLockObserver::RunL() BEGIN"));
   163     switch(iType) {
   148     
   164         case ESecUiDeviceLockObserver:
   149     
   165         TInt autolockState;
   150     switch(iType)
   166         iProperty.Get(autolockState);
   151         {
   167         
   152             case ESecUiDeviceLockObserver:
   168         if(autolockState > EAutolockOff) {            
   153                  TInt autolockState;
   169             Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Device Lock"));
   154                  iProperty.Get( autolockState );
   170             iDialog->TryCancelQueryL(ESecUiDeviceLocked);
   155                  if (autolockState > EAutolockOff)
   171             iSubscribedToEvent = EFalse;
   156                     {
   172         }
   157                     
   173         else if((autolockState == EAutolockOff)||(autolockState == EAutolockStatusUninitialized))
   158                     Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Device Lock"));
   174             {
   159                     
   175             Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Device UnLocked"));
   160                 	iDialog->TryCancelQueryL(ESecUiDeviceLocked);
   176             iDialog->TryCancelQueryL(ESecUiNone);
   161                 	iSubscribedToEvent = EFalse;
   177             iSubscribedToEvent = EFalse;
       
   178             }
       
   179         break;
       
   180         case ESecUiCallStateObserver: {
       
   181             TInt callState;
       
   182             iProperty.Get(callState);
       
   183             Dprint( (_L("CSCPLockObserver::RunL() callState before Start() : %d"), callState ));
       
   184             Start();
       
   185             
       
   186             switch(callState) {
       
   187                 default:
       
   188                     break;
       
   189                 case EPSCTsyCallStateNone:
       
   190                     if(iInformCallEnding) {
       
   191                         Dprint( (_L("CSCPLockObserver::RunL() Branched to EPSCTsyCallStateNone")));
       
   192                         iDialog->TryCancelQueryL(EEnded);                    
       
   193                         iInformCallEnding = EFalse;
   162                     }
   194                     }
       
   195                     break;
       
   196                 case EPSCTsyCallStateAlerting:
       
   197                 case EPSCTsyCallStateHold:
       
   198                 case EPSCTsyCallStateRinging:
       
   199                 case EPSCTsyCallStateDialling:
       
   200                 case EPSCTsyCallStateAnswering:
       
   201                 case EPSCTsyCallStateConnected: {
       
   202                         Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Active Call"));                
       
   203                         TRAPD(lErr, iDialog->TryCancelQueryL(EInProgress));
       
   204                         Dprint( (_L("CSCPLockObserver::RunL() lErr : %d"), lErr ));                        
       
   205                         iInformCallEnding = ETrue;
       
   206                 }
   163                 break;
   207                 break;
   164             case ESecUiCallStateObserver:
   208             };
   165                 TInt callState;
   209         }
   166                 iProperty.Get( callState );
   210         break;
   167 				 
   211         default:
   168 				 Dprint( (_L("CSCPLockObserver::RunL() callState : %d"),callState ));
   212             break;
   169                 if(callState == EPSCTsyCallStateDisconnecting)
   213     }
   170                     {
   214     
   171                      
   215     Dprint(_L("[CSCPLockObserver]-> RunL() <<<"));    
   172                     Dprint(_L("CSCPLockObserver::RunL() TryCancelQueryL Active Call"));
   216 }
   173                     
       
   174                 	iDialog->TryCancelQueryL(EPSCTsyCallStateDisconnecting);
       
   175                 	iSubscribedToEvent = EFalse;   
       
   176                     }
       
   177                 break;
       
   178 
   217 
   179             default:
       
   180                 break;
       
   181         }
       
   182 
       
   183    
       
   184 	
       
   185     Dprint(_L("CSCPLockObserver::RunL() END"));
       
   186     
       
   187 	}
       
   188 // ----------------------------------------------------------------------------
   218 // ----------------------------------------------------------------------------
   189 // CSCPLockObserver::RunError
   219 // CSCPLockObserver::RunError
   190 // ----------------------------------------------------------------------------
   220 // ----------------------------------------------------------------------------
   191 TInt CSCPLockObserver::RunError ( TInt /*aError*/ )
   221 TInt CSCPLockObserver::RunError ( TInt /*aError*/ )
   192     {
   222     {
   193         return KErrNone;
   223         return KErrNone;
   194     }	
   224     }	
       
   225     
       
   226    
   195 //
   227 //
   196 // ----------------------------------------------------------
   228 // ----------------------------------------------------------
   197 // CSCPLockObserver::DoCancel()
   229 // CSCPLockObserver::DoCancel()
   198 // Cancels event listening
   230 // Cancels event listening
   199 // ----------------------------------------------------------
   231 // ----------------------------------------------------------
   202     {
   234     {
   203     
   235     
   204     Dprint(_L("CSCPLockObserver::DoCancel() BEGIN"));
   236     Dprint(_L("CSCPLockObserver::DoCancel() BEGIN"));
   205     
   237     
   206     if(iSubscribedToEvent)
   238     if(iSubscribedToEvent)
   207     	iProperty.Cancel();
   239         iProperty.Cancel();
       
   240     
   208     iStatus = KErrNone;
   241     iStatus = KErrNone;
   209     
   242     
   210     Dprint(_L("CSCPLockObserver::DoCancel() END"));
   243     Dprint(_L("CSCPLockObserver::DoCancel() END"));
   211     
   244     
   212     }
   245     }