securitydialogs/secuidialognotifiersrv/src/secuidialognotifiersession.cpp
changeset 63 989397f9511c
parent 59 881d92421467
child 66 67b3e3c1fc87
equal deleted inserted replaced
62:3255e7d5bd67 63:989397f9511c
    16 */
    16 */
    17 
    17 
    18 #include "secuidialognotifiersession.h"  // CSecuiDialogNotifierSession
    18 #include "secuidialognotifiersession.h"  // CSecuiDialogNotifierSession
    19 #include "secuidialognotifierserver.h"   // CSecuiDialogNotifierServer
    19 #include "secuidialognotifierserver.h"   // CSecuiDialogNotifierServer
    20 #include "secuidialognotifierservername.h" // KSecuiDialogsCancelOperation
    20 #include "secuidialognotifierservername.h" // KSecuiDialogsCancelOperation
    21 // #include "secuidialogoperserverauthfail.h" // CServerAuthFailOperation
       
    22 #include "secuidialogoperbasicpinquery.h" // CBasicPinQueryOperation
    21 #include "secuidialogoperbasicpinquery.h" // CBasicPinQueryOperation
    23 #include "secuidialogstrace.h"           // TRACE macro
    22 #include "secuidialogstrace.h"           // TRACE macro
    24 #include <secdlgimpldefs.h>                 // TSecurityDialogOperation
       
    25 #include <keyguardaccessapi.h>
    23 #include <keyguardaccessapi.h>
    26 
    24 
    27 const TInt KInputParam = 0;
    25 const TInt KInputParam = 0;
    28 const TInt KOutputParam = 1;
    26 const TInt KOutputParam = 1;
    29 
    27 
    34 // CSecuiDialogNotifierSession::NewL()
    32 // CSecuiDialogNotifierSession::NewL()
    35 // ---------------------------------------------------------------------------
    33 // ---------------------------------------------------------------------------
    36 //
    34 //
    37 CSecuiDialogNotifierSession* CSecuiDialogNotifierSession::NewL()
    35 CSecuiDialogNotifierSession* CSecuiDialogNotifierSession::NewL()
    38     {
    36     {
    39 		TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 );
    37 		RDEBUG("0", 0);
    40     CSecuiDialogNotifierSession* self = new( ELeave ) CSecuiDialogNotifierSession;
    38     CSecuiDialogNotifierSession* self = new( ELeave ) CSecuiDialogNotifierSession;
    41     CleanupStack::PushL( self );
    39     CleanupStack::PushL( self );
    42     self->ConstructL();
    40     self->ConstructL();
    43     CleanupStack::Pop( self );
    41     CleanupStack::Pop( self );
    44     return self;
    42     return self;
    48 // CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession()
    46 // CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession()
    49 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    50 //
    48 //
    51 CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession()
    49 CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession()
    52     {
    50     {
    53     TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession, begin" );
    51     RDEBUG("0", 0);
    54     Server().RemoveSession();
    52     Server().RemoveSession();
    55     delete iOperationHandler;
    53     delete iOperationHandler;
    56     iOperationHandler = NULL;
    54     iOperationHandler = NULL;
    57     delete iInputBuffer;
    55     delete iInputBuffer;
    58     iInputBuffer = NULL;
    56     iInputBuffer = NULL;
    59     TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession, end" );
    57     RDEBUG("0x99", 0x99);
    60     }
    58     }
    61 
    59 
    62 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    63 // CSecuiDialogNotifierSession::CreateL()
    61 // CSecuiDialogNotifierSession::CreateL()
    64 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    65 //
    63 //
    66 void CSecuiDialogNotifierSession::CreateL()
    64 void CSecuiDialogNotifierSession::CreateL()
    67     {
    65     {
    68     TRACE( "CSecuiDialogNotifierSession::~CSecuiDialogNotifierSession" );
    66     RDEBUG("0", 0);
    69     Server().AddSession();
    67     Server().AddSession();
    70     }
    68     }
    71 
    69 
    72 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    73 // CSecuiDialogNotifierSession::ServiceL()
    71 // CSecuiDialogNotifierSession::ServiceL()
    74 // ---------------------------------------------------------------------------
    72 // ---------------------------------------------------------------------------
    75 //
    73 //
    76 void CSecuiDialogNotifierSession::ServiceL( const RMessage2& aMessage )
    74 void CSecuiDialogNotifierSession::ServiceL( const RMessage2& aMessage )
    77     {
    75     {
    78     TRACE( "CSecuiDialogNotifierSession::ServiceL, message 0x%08x", aMessage.Handle() );
    76     RDEBUG("aMessage.Handle()", aMessage.Handle());
    79     TRAPD( error, DispatchMessageL( aMessage ) );
    77     TRAPD( error, DispatchMessageL( aMessage ) );
    80     TRACE( "CSecuiDialogNotifierSession::ServiceL, dispatched, error %d", error );
    78     RDEBUG("error", error);
    81     if( error && !aMessage.IsNull() )
    79     if( error && !aMessage.IsNull() )
    82         {
    80         {
    83         TRACE( "CSecuiDialogNotifierSession::ServiceL, completing msg 0x%08x",
    81         RDEBUG("Complete aMessage.Handle()", aMessage.Handle());
    84                 aMessage.Handle() );
       
    85         aMessage.Complete( error );
    82         aMessage.Complete( error );
    86         }
    83         }
    87     }
    84     }
    88 
    85 
    89 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    90 // CSecuiDialogNotifierSession::OperationComplete()
    87 // CSecuiDialogNotifierSession::OperationComplete()
    91 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    92 //
    89 //
    93 void CSecuiDialogNotifierSession::OperationComplete()
    90 void CSecuiDialogNotifierSession::OperationComplete()
    94     {
    91     {
    95     TRACE( "CSecuiDialogNotifierSession::OperationComplete, begin" );
    92     RDEBUG("0", 0);
    96     delete iOperationHandler;
    93     delete iOperationHandler;
    97     iOperationHandler = NULL;
    94     iOperationHandler = NULL;
    98     TRACE( "CSecuiDialogNotifierSession::OperationComplete, end" );
    95     RDEBUG("0x99", 0x99);
    99     }
    96     }
   100 
    97 
   101 // ---------------------------------------------------------------------------
    98 // ---------------------------------------------------------------------------
   102 // CSecuiDialogNotifierSession::CSecuiDialogNotifierSession()
    99 // CSecuiDialogNotifierSession::CSecuiDialogNotifierSession()
   103 // ---------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
   104 //
   101 //
   105 CSecuiDialogNotifierSession::CSecuiDialogNotifierSession()
   102 CSecuiDialogNotifierSession::CSecuiDialogNotifierSession()
   106     {
   103     {
   107     TRACE( "CSecuiDialogNotifierSession::CSecuiDialogNotifierSession" );
   104     RDEBUG("0", 0);
   108     }
   105     }
   109 
   106 
   110 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
   111 // CSecuiDialogNotifierSession::ConstructL()
   108 // CSecuiDialogNotifierSession::ConstructL()
   112 // ---------------------------------------------------------------------------
   109 // ---------------------------------------------------------------------------
   113 //
   110 //
   114 void CSecuiDialogNotifierSession::ConstructL()
   111 void CSecuiDialogNotifierSession::ConstructL()
   115     {
   112     {
   116     TRACE( "CSecuiDialogNotifierSession::ConstructL" );
   113     RDEBUG("0", 0);
   117     }
   114     }
   118 
   115 
   119 // ---------------------------------------------------------------------------
   116 // ---------------------------------------------------------------------------
   120 // CSecuiDialogNotifierSession::Server()
   117 // CSecuiDialogNotifierSession::Server()
   121 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
   130 // CSecuiDialogNotifierSession::DispatchMessageL()
   127 // CSecuiDialogNotifierSession::DispatchMessageL()
   131 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   132 //
   129 //
   133 void CSecuiDialogNotifierSession::DispatchMessageL( const RMessage2& aMessage )
   130 void CSecuiDialogNotifierSession::DispatchMessageL( const RMessage2& aMessage )
   134     {
   131     {
   135     TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, begin" );
   132     RDEBUG("0", 0);
   136     if( !IsOperationCancelled( aMessage ) )
   133     if( !IsOperationCancelled( aMessage ) )
   137         {
   134         {
   138         TInt lOperation = aMessage.Function();
   135         TInt lOperation = aMessage.Function();
   139         TSecurityDialogOperation operation =
       
   140                 static_cast< TSecurityDialogOperation >( lOperation );
       
   141         TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, operation=%d", operation );
       
   142 
   136 
   143 		// from AskSecCodeInAutoLockL
   137 		// from AskSecCodeInAutoLockL
   144 		if(lOperation==0x100+6 /*RMobilePhone::EPhonePasswordRequired*/)
   138 		if(lOperation==0x100+6 /*RMobilePhone::EPhonePasswordRequired*/)
   145 			{
   139 			{
   146 		  TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, query from AskSecCodeInAutoLockL . No need to start Autolock.exe =%d", 0 );
   140 			RDEBUG("query from AskSecCodeInAutoLockL . No need to start Autolock.exe", 0);
   147 			}
   141 			}
   148 		else
   142 		else
   149 			{
   143 			{
   150 	    CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL( );
   144 	    CKeyguardAccessApi* iKeyguardAccess = CKeyguardAccessApi::NewL( );
   151 	   	TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 );
   145 	   	RDEBUG("0", 0);
   152 			TInt err = iKeyguardAccess->ShowKeysLockedNote( );
   146 			TInt err = iKeyguardAccess->ShowKeysLockedNote( );
   153 			TRACE( "CBasicPinQueryOperation::RunL, err =%d", err );
   147 			RDEBUG("err", err);
   154 			delete iKeyguardAccess;
   148 			delete iKeyguardAccess;
   155 			}
   149 			}
   156 			TRACE( "CBasicPinQueryOperation::RunL, lOperation =%d", lOperation );
   150 			RDEBUG("lOperation", lOperation);
   157 				if( lOperation >= 0x1000 )	// flag for iStartup
   151 				if( lOperation >= 0x1000 )	// flag for iStartup
   158 					lOperation -= 0x1000;
   152 					lOperation -= 0x1000;
   159 			TRACE( "CBasicPinQueryOperation::RunL, new lOperation =%d", lOperation );
   153 			RDEBUG("new lOperation", lOperation);
   160         if( lOperation < 0x200 )
   154         if( lOperation < 0x200 )
   161             {
   155             {
   162             BasicPinOperationL( aMessage );
   156             BasicPinOperationL( aMessage );
   163             }
   157             }
   164         else
   158         else
   165 	        	{
   159 	        	{
   166 	  				TRACE( "CBasicPinQueryOperation::RunL, lOperation =%d", lOperation );
   160 						RDEBUG("KErrNotSupported", KErrNotSupported);
   167 	          User::Leave( KErrNotSupported );
   161 	          User::Leave( KErrNotSupported );
   168 	          }
   162 	          }
   169         }
   163         }
   170     TRACE( "CSecuiDialogNotifierSession::DispatchMessageL, end" );
   164     RDEBUG("0x99", 0x99);
   171     }
   165     }
   172 
   166 
   173 // ---------------------------------------------------------------------------
   167 // ---------------------------------------------------------------------------
   174 // CSecuiDialogNotifierSession::IsOperationCancelled()
   168 // CSecuiDialogNotifierSession::IsOperationCancelled()
   175 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   179     TBool isCancelled = EFalse;
   173     TBool isCancelled = EFalse;
   180     if( aMessage.Function() == KSecuiDialogCancelOperation )
   174     if( aMessage.Function() == KSecuiDialogCancelOperation )
   181         {
   175         {
   182         if( iOperationHandler )
   176         if( iOperationHandler )
   183             {
   177             {
   184             TRACE( "CSecuiDialogNotifierSession::CheckIfOperationCancelledL, cancelling" );
   178             RDEBUG("0", 0);
   185             iOperationHandler->CancelOperation();
   179             iOperationHandler->CancelOperation();
   186             }
   180             }
   187         TRACE( "CSecuiDialogNotifierSession::CheckIfOperationCancelledL, completing msg 0x%08x",
   181         RDEBUG("completing aMessage.Handle()", aMessage.Handle());
   188                 aMessage.Handle() );
       
   189         aMessage.Complete( KErrNone );
   182         aMessage.Complete( KErrNone );
   190         isCancelled = ETrue;
   183         isCancelled = ETrue;
   191         }
   184         }
   192     return isCancelled;
   185     return isCancelled;
   193     }
   186     }
   197 // ---------------------------------------------------------------------------
   190 // ---------------------------------------------------------------------------
   198 //
   191 //
   199 void CSecuiDialogNotifierSession::GetInputBufferL( const RMessage2& aMessage )
   192 void CSecuiDialogNotifierSession::GetInputBufferL( const RMessage2& aMessage )
   200     {
   193     {
   201     TInt inputLength = aMessage.GetDesLength( KInputParam );
   194     TInt inputLength = aMessage.GetDesLength( KInputParam );
   202     TRACE( "CSecuiDialogNotifierSession::GetInputBufferL, inputLength=%d", inputLength );
   195     RDEBUG("inputLength", inputLength);
   203     __ASSERT_ALWAYS( inputLength > 0, User::Leave( KErrCorrupt ) );
   196     __ASSERT_ALWAYS( inputLength > 0, User::Leave( KErrCorrupt ) );
   204     if( iInputBuffer )
   197     if( iInputBuffer )
   205         {
   198         {
   206         delete iInputBuffer;
   199         delete iInputBuffer;
   207         iInputBuffer = NULL;
   200         iInputBuffer = NULL;
   208         }
   201         }
   209     iInputBuffer = HBufC8::NewL( inputLength );
   202     iInputBuffer = HBufC8::NewL( inputLength );
   210     TPtr8 inputBufferPtr( iInputBuffer->Des() );
   203     TPtr8 inputBufferPtr( iInputBuffer->Des() );
   211     aMessage.ReadL( KInputParam, inputBufferPtr );
   204     aMessage.ReadL( KInputParam, inputBufferPtr );
   212     TRACE( "CSecuiDialogNotifierSession::GetInputBufferL, read complete" );
   205     RDEBUG("0x99", 0x99);
   213     }
   206     }
   214 
   207 
   215 // ---------------------------------------------------------------------------
   208 // ---------------------------------------------------------------------------
   216 // CSecuiDialogNotifierSession::ServerAuthenticationFailureL()
   209 // CSecuiDialogNotifierSession::ServerAuthenticationFailureL()
   217 // ---------------------------------------------------------------------------
   210 // ---------------------------------------------------------------------------
   218 //
   211 //
   219 void CSecuiDialogNotifierSession::ServerAuthenticationFailureL( const RMessage2& aMessage )
   212 void CSecuiDialogNotifierSession::ServerAuthenticationFailureL( const RMessage2& /* aMessage */ )
   220     {
   213     {
   221     TRACE( "CSecuiDialogNotifierSession::ServerAuthenticationFailureL, begin" );
   214     RDEBUG("not used 0x99", 0x99);
   222     GetInputBufferL( aMessage );
       
   223 
       
   224     ASSERT( iOperationHandler == NULL );
       
   225     // iOperationHandler = CServerAuthFailOperation::NewL( *this, aMessage, KOutputParam );
       
   226     // iOperationHandler->StartL( *iInputBuffer );
       
   227 
       
   228     TRACE( "CSecuiDialogNotifierSession::ServerAuthenticationFailureL, end" );
       
   229     }
   215     }
   230 
   216 
   231 // ---------------------------------------------------------------------------
   217 // ---------------------------------------------------------------------------
   232 // CSecuiDialogNotifierSession::BasicPinOperationL()
   218 // CSecuiDialogNotifierSession::BasicPinOperationL()
   233 // ---------------------------------------------------------------------------
   219 // ---------------------------------------------------------------------------
   234 //
   220 //
   235 void CSecuiDialogNotifierSession::BasicPinOperationL( const RMessage2& aMessage )
   221 void CSecuiDialogNotifierSession::BasicPinOperationL( const RMessage2& aMessage )
   236     {
   222     {
   237     TRACE( "CSecuiDialogNotifierSession::BasicPinOperationL, begin" );
   223     RDEBUG("0", 0);
   238     GetInputBufferL( aMessage );
   224     GetInputBufferL( aMessage );
   239 
   225 
   240     ASSERT( iOperationHandler == NULL );
   226     ASSERT( iOperationHandler == NULL );
   241     iOperationHandler = CBasicPinQueryOperation::NewL( *this, aMessage, KOutputParam );
   227     iOperationHandler = CBasicPinQueryOperation::NewL( *this, aMessage, KOutputParam );
   242     iOperationHandler->StartL( *iInputBuffer );
   228     iOperationHandler->StartL( *iInputBuffer );
   243 
   229 
   244     TRACE( "CSecuiDialogNotifierSession::BasicPinOperationL, end" );
   230     RDEBUG("0x99", 0x99);
   245     }
   231     }
   246 
   232