terminalsecurity/SCP/SCPServer/src/SCPLockNotificationEventHandler.cpp
branchRCL_3
changeset 14 9e9792ae22e3
parent 0 b497e44ab2fc
child 61 b183ec05bd8c
equal deleted inserted replaced
13:06f47423ecee 14:9e9792ae22e3
    31  
    31  
    32 #include <mmtsy_names.h>
    32 #include <mmtsy_names.h>
    33 
    33 
    34 #include "SCPLockNotificationEventHandler.h"
    34 #include "SCPLockNotificationEventHandler.h"
    35 #include "SCPServer.h"
    35 #include "SCPServer.h"
       
    36 #include "SCPSession.h"
    36 
    37 
    37 // ================= MEMBER FUNCTIONS =======================
    38 // ================= MEMBER FUNCTIONS =======================
    38 
    39 
    39 // C++ default constructor can NOT contain any code, that
    40 // C++ default constructor can NOT contain any code, that
    40 // might leave.
    41 // might leave.
    41 //
    42 //
    42 CSCPLockNotificationEventHandler::CSCPLockNotificationEventHandler(                        
    43 CSCPLockNotificationEventHandler::CSCPLockNotificationEventHandler(                        
    43             CSCPServer* aServer
    44             CSCPServer* aServer,
       
    45             CSCPSession* aSession
    44             )
    46             )
    45 	        : CSCPLockEventHandler( aServer ),
    47 	        : CSCPLockEventHandler( aServer ),
    46 	        iQueryState(ESCPLNQueryStateNotification) 	
    48 	        iQueryState(ESCPLNQueryStateNotification),
       
    49 	        iSession (aSession),
       
    50 	        iAckReceived (EFalse)
    47     {
    51     {
    48     Dprint( (_L("--> CSCPLockNotificationEventHandler::\
    52     Dprint( (_L("--> CSCPLockNotificationEventHandler::\
    49 	      CSCPLockNotificationEventHandler()") ));
    53 	      CSCPLockNotificationEventHandler()") ));
    50 	
    54 	
    51     Dprint( (_L("<-- CSCPLockNotificationEventHandler::\
    55     Dprint( (_L("<-- CSCPLockNotificationEventHandler::\
    66     }
    70     }
    67 
    71 
    68 
    72 
    69 // Static constructor.
    73 // Static constructor.
    70 CSCPLockNotificationEventHandler* CSCPLockNotificationEventHandler::NewL(
    74 CSCPLockNotificationEventHandler* CSCPLockNotificationEventHandler::NewL(
    71         CSCPServer* aServer
    75         CSCPServer* aServer,
       
    76         CSCPSession* aSession
    72         )
    77         )
    73     {
    78     {
    74 	  Dprint( (_L("--> CSCPLockNotificationEventHandler::NewL()") ));
    79 	  Dprint( (_L("--> CSCPLockNotificationEventHandler::NewL()") ));
    75 
    80 
    76 	  CSCPLockNotificationEventHandler* self = 
    81 	  CSCPLockNotificationEventHandler* self = 
    77 	      CSCPLockNotificationEventHandler::NewLC( aServer );
    82 	      CSCPLockNotificationEventHandler::NewLC( aServer, aSession );
    78 	        
    83 	        
    79     CleanupStack::Pop( self );
    84     CleanupStack::Pop( self );
    80 	
    85 	
    81     Dprint( (_L("<-- CSCPLockNotificationEventHandler::NewL()") ));
    86     Dprint( (_L("<-- CSCPLockNotificationEventHandler::NewL()") ));
    82     return self;	
    87     return self;	
    83     }
    88     }
    84 	
    89 	
    85 
    90 
    86 // Static constructor, leaves object pointer to the cleanup stack.
    91 // Static constructor, leaves object pointer to the cleanup stack.
    87 CSCPLockNotificationEventHandler* CSCPLockNotificationEventHandler::NewLC(
    92 CSCPLockNotificationEventHandler* CSCPLockNotificationEventHandler::NewLC(
    88         CSCPServer* aServer 
    93         CSCPServer* aServer,
       
    94         CSCPSession* aSession
    89         )
    95         )
    90     {
    96     {
    91     Dprint( (_L("--> CSCPLockNotificationEventHandler::NewLC()") ));
    97     Dprint( (_L("--> CSCPLockNotificationEventHandler::NewLC()") ));
    92 
    98 
    93     CSCPLockNotificationEventHandler* self = 
    99     CSCPLockNotificationEventHandler* self = 
    94         new (ELeave) CSCPLockNotificationEventHandler( aServer );
   100         new (ELeave) CSCPLockNotificationEventHandler( aServer, aSession );
    95 
   101 
    96     CleanupStack::PushL( self );
   102     CleanupStack::PushL( self );
    97     self->ConstructL();	
   103     self->ConstructL();	
    98 	
   104 	
    99     Dprint( (_L("<-- CSCPLockNotificationEventHandler::NewLC()") ));
   105     Dprint( (_L("<-- CSCPLockNotificationEventHandler::NewLC()") ));
   147        
   153        
   148     return ret;
   154     return ret;
   149     }
   155     }
   150 
   156 
   151 // ---------------------------------------------------------
   157 // ---------------------------------------------------------
       
   158 // void CSCPLockNotificationEventHandler::AckReceived()
       
   159 // Sets the ackReceived member to indicate that the call has
       
   160 // already been acknowledged.
       
   161 // 
       
   162 // Status : Approved
       
   163 // ---------------------------------------------------------
       
   164 
       
   165 void CSCPLockNotificationEventHandler::AckReceived()
       
   166     {
       
   167     Dprint( (_L("--> CSCPLockNotificationEventHandler::AckReceived()") ));
       
   168     iAckReceived = ETrue;    
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------
       
   172 // void CSCPLockNotificationEventHandler::VerifyPass()
       
   173 // Verify password to the ISA
       
   174 // 
       
   175 // Status : Approved
       
   176 // ---------------------------------------------------------
       
   177 void CSCPLockNotificationEventHandler::VerifyPass()
       
   178     {
       
   179     Dprint( (_L("CSCPLockNotificationEventHandler::VerifyPass():\
       
   180         EPhonePasswordRequired event received") ));
       
   181 
       
   182     RMobilePhone::TMobilePhoneSecurityCode secCodeType = 
       
   183         RMobilePhone::ESecurityCodePhonePassword;
       
   184         
       
   185     RMobilePhone::TMobilePassword password;
       
   186     RMobilePhone::TMobilePassword required_fourth;
       
   187     required_fourth.Zero();
       
   188     iServer->GetCode( password );                
       
   189 
       
   190     iPhone->VerifySecurityCode(iStatus, secCodeType, 
       
   191         password, required_fourth);
       
   192 
       
   193     // Start waiting for verification response
       
   194     iQueryState = ESCPLNQueryStateVerification;
       
   195     SetActive(); 
       
   196     Dprint( (_L("<-- CSCPLockNotificationEventHandler::VerifyPass()") ));    
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------
   152 // void CSCPLockNotificationEventHandler::RunL()
   200 // void CSCPLockNotificationEventHandler::RunL()
   153 // When the correct security event is received, the code query is
   201 // When the correct security event is received, the code query is
   154 // verified via VerifySecurityCode. This method also handles the
   202 // verified via VerifySecurityCode. This method also handles the
   155 // response for this call.
   203 // response for this call.
   156 // 
   204 // 
   163    
   211    
   164     switch ( iQueryState )
   212     switch ( iQueryState )
   165         {
   213         {
   166         case ( ESCPLNQueryStateNotification ):
   214         case ( ESCPLNQueryStateNotification ):
   167             {                        
   215             {                        
   168             // Event received
   216             // Event received from Session, queryAdminCmd
   169             if ( iEvent == RMobilePhone::EPhonePasswordRequired )
   217              if (iAckReceived)
   170                 {
   218                  {
   171                 Dprint( (_L("CSCPLockNotificationEventHandler::RunL():\
   219                  VerifyPass();
   172                     EPhonePasswordRequired event received") ));
   220                  }
   173       
   221              else if ( iEvent == RMobilePhone::EPhonePasswordRequired )
   174                 RMobilePhone::TMobilePhoneSecurityCode secCodeType = 
   222                  {
   175                     RMobilePhone::ESecurityCodePhonePassword;
   223                  Dprint( (_L("--> CSCPLockNotificationEventHandler::EPhonePasswordRequired") ));
   176                     
   224                  iQueryState = ESCPLNQueryStateQueryAdmin;
   177                 RMobilePhone::TMobilePassword password;
   225                  iSession->LockOperationPending( ESCPCommandLockPhone, &iStatus );
   178                 RMobilePhone::TMobilePassword required_fourth;
   226                  SetActive();
   179                 required_fourth.Zero();
   227                  }
   180                 iServer->GetCode( password );                
   228              else
   181       
   229                  {
   182                 iPhone->VerifySecurityCode(iStatus, secCodeType, 
   230                  Dprint( (_L("CSCPLockNotificationEventHandler::RunL():\
   183                     password, required_fourth);
   231                      Invalid event received") ));
   184       
   232                  // Re-run registration, this event is not the one we're waiting for
   185                 // Start waiting for verification response
   233                  RegisterListener();
   186                 iQueryState = ESCPLNQueryStateVerification;
   234                  }
   187                 SetActive();                  
   235              break;
   188                 }
   236             }
   189             else
   237         // Event received from Session for LockOpPending, queryAdminCmd
   190                 {
   238         case (ESCPLNQueryStateQueryAdmin):
   191                 Dprint( (_L("CSCPLockNotificationEventHandler::RunL():\
   239             {             
   192                     Invalid event received") ));
   240             Dprint( (_L("--> CSCPLockNotificationEventHandler::ESCPLNQueryStateQueryAdmin") ));
   193                 // Re-run registration, this event is not the one we're waiting for
   241             VerifyPass();
   194                 RegisterListener();
       
   195                 }
       
   196         
       
   197             break;
   242             break;
   198             }
   243             }
   199 
   244 
   200         case ( ESCPLNQueryStateVerification ):
   245         case ( ESCPLNQueryStateVerification ):
   201             {                        
   246             {