telephonyserverplugins/common_tsy/commontsy/src/mmcustomtsy/CMmCustomSecurityTsy.cpp
changeset 0 3553901f7fa8
child 19 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 //  INCLUDE FILES
       
    19 #include "CMmCustomSecurityTsy.h"
       
    20 #include <ctsy/tflogger.h>
       
    21 #include "cmmphonegsmwcdmaext.h"
       
    22 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    23 #include <ctsy/pluginapi/cmmdatapackage.h>
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 CMmCustomSecurityTsy::CMmCustomSecurityTsy()
       
    28     {
       
    29     }
       
    30 
       
    31 void CMmCustomSecurityTsy::ConstructL(
       
    32     CMmCustomTsy* aMmCustomTsy, 
       
    33     CMmPhoneTsy* aMmPhoneTsy )
       
    34     {
       
    35 TFLOGSTRING("TSY: CMmCustomSecurityTsy::ConstructL");
       
    36     iMmCustomTsy = aMmCustomTsy;
       
    37     iMmPhoneTsy = aMmPhoneTsy;
       
    38 
       
    39     // register securitytsy in the message manager
       
    40     iMmPhoneTsy->MessageManager()->RegisterTsyObject( 
       
    41         CMmMessageManagerBase::ESecurityTsy, this );
       
    42     
       
    43     // Create req handle store
       
    44 #ifdef REQHANDLE_TIMER   
       
    45     // Create req handle store
       
    46     iTsyReqHandleStore = CMmTsyReqHandleStore::NewL( iMmCustomTsy,
       
    47         iMmCustomTsy->iMmPhoneTsy, ESecurityRequestTypeMaxNumOfRequests, 
       
    48         iSecReqHandles );
       
    49 #else
       
    50    iTsyReqHandleStore = CMmTsyReqHandleStore::NewL( 
       
    51         ESecurityRequestTypeMaxNumOfRequests, iSecReqHandles );
       
    52 #endif //REQHANDLE_TIMER
       
    53     
       
    54     return;
       
    55     }
       
    56 
       
    57 CMmCustomSecurityTsy* CMmCustomSecurityTsy::NewL(
       
    58     CMmCustomTsy* aMmCustomTsy, 
       
    59     CMmPhoneTsy* aPhoneTsy )
       
    60     {
       
    61 TFLOGSTRING("TSY: CMmCustomSecurityTsy::NewL");
       
    62     CMmCustomSecurityTsy* self = new (ELeave) CMmCustomSecurityTsy();
       
    63 
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL( aMmCustomTsy, aPhoneTsy );
       
    66     CleanupStack::Pop();
       
    67 
       
    68     return self;
       
    69     }
       
    70 
       
    71 CMmCustomSecurityTsy::~CMmCustomSecurityTsy()
       
    72     {
       
    73     if (iMmPhoneTsy )
       
    74         {
       
    75         // deregister tsy object from message manager
       
    76         iMmPhoneTsy->MessageManager()->DeregisterTsyObject(this);        
       
    77         }
       
    78     delete iTsyReqHandleStore;
       
    79 
       
    80     return;
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CMmCustomSecurityTsy::Init
       
    85 // Initialisation method that is called from ETel Server.
       
    86 // (other items were commented in a header).
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CMmCustomSecurityTsy::Init()
       
    90     {
       
    91     return;
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CMmCustomSecurityTsy::SupportingIPC
       
    96 // Tells whether the object supports given IPC.
       
    97 // (other items were commented in a header).
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 TBool CMmCustomSecurityTsy::SupportingIPC(
       
   101     TInt aIpc )
       
   102     {
       
   103     TInt ret( EFalse );
       
   104 
       
   105     switch (aIpc)
       
   106         {
       
   107         case ECustomIsBlockedIPC:
       
   108         case ECustomCheckSecurityCodeIPC:
       
   109         case ECustomDisablePhoneLockIPC:
       
   110         case ECustomGetActivePinIPC:
       
   111             ret = ETrue;
       
   112             break;
       
   113         default:
       
   114             ret = EFalse;
       
   115             break;
       
   116         }
       
   117 
       
   118     return ret;
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // CMmCustomSecurityTsy::DoExtFuncL
       
   123 // Dispatches extension function requests.
       
   124 // (other items were commented in a header).
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 TInt CMmCustomSecurityTsy::DoExtFuncL(
       
   128     const TTsyReqHandle aTsyReqHandle, 
       
   129     const TInt aIpc, 
       
   130     const TDataPackage& aPackage )
       
   131     {
       
   132     TInt ret( KErrGeneral );
       
   133 
       
   134     // reset last tsy request type
       
   135     iReqHandleType = ESecurityTsyReqHandleUnknown;
       
   136 
       
   137     switch (aIpc)
       
   138         {
       
   139         case ECustomIsBlockedIPC:
       
   140             ret = IsBlocked( aTsyReqHandle,
       
   141                 REINTERPRET_CAST( RMmCustomAPI::TSecurityCodeType*,
       
   142                 aPackage.Ptr1() ),
       
   143                 REINTERPRET_CAST( TBool*, aPackage.Ptr2() ) );
       
   144             break;
       
   145         case ECustomCheckSecurityCodeIPC:
       
   146             ret = CheckSecurityCodeL( aTsyReqHandle,
       
   147                 REINTERPRET_CAST( RMmCustomAPI::TSecurityCodeType*,
       
   148                 aPackage.Ptr1() ) );
       
   149             break;
       
   150         case ECustomDisablePhoneLockIPC:
       
   151             ret = DisablePhoneLockL( aTsyReqHandle,
       
   152                 REINTERPRET_CAST( RMobilePhone::TMobilePassword*,
       
   153                 aPackage.Ptr1() ) );
       
   154             break;
       
   155          case ECustomGetActivePinIPC:
       
   156             ret = GetActivePin( aTsyReqHandle,
       
   157                 REINTERPRET_CAST( RMobilePhone::TMobilePhoneSecurityCode*, 
       
   158                 aPackage.Ptr1() ) );
       
   159             break;
       
   160         default:
       
   161             ret = KErrNotSupported;
       
   162             break;
       
   163         }
       
   164 
       
   165     // save request handle
       
   166     if( ESecurityTsyReqHandleUnknown != iReqHandleType )
       
   167         {
       
   168 #ifdef REQHANDLE_TIMER
       
   169         SetTypeOfResponse( iReqHandleType, aTsyReqHandle );
       
   170 #else
       
   171         iTsyReqHandleStore->SetTsyReqHandle( iReqHandleType, aTsyReqHandle );
       
   172 #endif // REQHANDLE_TIMER
       
   173         }
       
   174 
       
   175     return ret;
       
   176     }
       
   177     
       
   178 // ---------------------------------------------------------------------------
       
   179 // CMmCustomSecurityTsy::ReqModeL
       
   180 // Returns request mode for given IPC. If the IPC number belongs to some of
       
   181 // the Security API functions.
       
   182 // (other items were commented in a header).
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 CTelObject::TReqMode CMmCustomSecurityTsy::ReqModeL( 
       
   186     const TInt aIpc )
       
   187     {
       
   188     CTelObject::TReqMode ret = 0;
       
   189 
       
   190     switch (aIpc)
       
   191         {
       
   192         case ECustomCheckSecurityCodeIPC:
       
   193         case ECustomIsBlockedIPC:
       
   194         case ECustomDisablePhoneLockIPC:
       
   195         case ECustomGetActivePinIPC:
       
   196             break;
       
   197         default:
       
   198             User::Leave( KErrNotSupported );
       
   199             break;
       
   200         }
       
   201 
       
   202     return ret;
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------------------------
       
   206 // CMmCustomSecurityTsy::NumberOfSlotsL
       
   207 // Returns number of slots to be used for given IPC.
       
   208 // (other items were commented in a header).
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 TInt CMmCustomSecurityTsy::NumberOfSlotsL(
       
   212     const TInt aIpc )
       
   213     {
       
   214     TInt numberOfSlots( KMmCustomDefaultSlots );
       
   215 
       
   216     switch ( aIpc )
       
   217         {
       
   218         case ECustomIsBlockedIPC:
       
   219            numberOfSlots = KMmCustomIsBlockedSlots;
       
   220            break;
       
   221         case ECustomCheckSecurityCodeIPC:
       
   222         case ECustomDisablePhoneLockIPC:
       
   223            numberOfSlots = KMmCustomCheckSecurityCodeSlots;
       
   224            break;
       
   225         case ECustomGetActivePinIPC:
       
   226            numberOfSlots = KMmCustomDefaultSlots;
       
   227            break;
       
   228         default:
       
   229             // Unknown or invalid IPC
       
   230             User::Leave( KErrNotSupported );
       
   231             break;
       
   232         }
       
   233         
       
   234     return numberOfSlots;
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // CMmCustomSecurityTsy::CancelService
       
   239 // When the clients close their sub-sessions (eg. by calling RPhone::Close),
       
   240 // they may not have cancelled all their outstanding asynchronous requests
       
   241 // before closing. It is up to the ETel server to clean up in this situation,
       
   242 // so the server will find the list of outstanding requests related to that
       
   243 // sub-session object and pass these outstanding IPC request numbers, one at
       
   244 // a time, to the CancelService function in the TSY.
       
   245 // (other items were commented in a header).
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 TInt CMmCustomSecurityTsy::CancelService(
       
   249     const TInt aIpc, 
       
   250     const TTsyReqHandle )
       
   251     {
       
   252     TInt ret( KErrNone );
       
   253     TInt trapError( KErrNone );
       
   254 
       
   255     TRAP( trapError, // START TRAP
       
   256         switch ( aIpc )
       
   257             {
       
   258             case ECustomCheckSecurityCodeIPC:
       
   259                 ret = CheckSecurityCodeCancelL();
       
   260                 break;
       
   261             case ECustomDisablePhoneLockIPC: //This IPC cannot be cancelled 
       
   262                 ret = KErrNone;
       
   263                 break;
       
   264             default:
       
   265                 ret = KErrGeneral;
       
   266                 break;
       
   267             } 
       
   268         ); // END TRAP
       
   269     if ( KErrNone != trapError )
       
   270         {
       
   271         ret = trapError;
       
   272         }
       
   273         
       
   274     return ret;
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CMmCustomSecurityTsy::RegisterNotification
       
   279 // RegisterNotification is called when the server recognises
       
   280 // that this notification is being posted for the first time on this sub-
       
   281 // session object. It enables the TSY to "turn on" any regular notification
       
   282 // messages that it may receive from DOS.
       
   283 // (other items were commented in a header).
       
   284 // ---------------------------------------------------------------------------
       
   285 //
       
   286 TInt CMmCustomSecurityTsy::RegisterNotification(    
       
   287     const TInt )
       
   288     {
       
   289     // No supported notifications in CMmCustomSecurityTsy
       
   290     return KErrNotSupported;
       
   291     }
       
   292 
       
   293 // ---------------------------------------------------------------------------
       
   294 // CMmCustomSecurityTsy::DeregisterNotification
       
   295 // DeregisterNotification is called when the server recognises that this
       
   296 // notification will not be posted again because the last client to have
       
   297 // a handle on this sub-session object has just closed the handle. It
       
   298 // enables the TSY to "turn off" any regular notification messages that
       
   299 // it may receive from DOS.
       
   300 // (other items were commented in a header).
       
   301 // ---------------------------------------------------------------------------
       
   302 //
       
   303 TInt CMmCustomSecurityTsy::DeregisterNotification(    
       
   304     const TInt )
       
   305     {
       
   306     // No supported notifications in CMmCustomSecurityTsy
       
   307     return KErrNotSupported;
       
   308     }
       
   309 
       
   310 #ifdef REQHANDLE_TIMER
       
   311 // ---------------------------------------------------------------------------
       
   312 // CMmCustomSecurityTsy::SetTypeOfResponse
       
   313 // Sets the type of response for a given handle.
       
   314 // (other items were commented in a header).
       
   315 // ---------------------------------------------------------------------------
       
   316 //
       
   317 void CMmCustomSecurityTsy::SetTypeOfResponse(
       
   318     const TInt aReqHandleType, 
       
   319     const TTsyReqHandle aTsyReqHandle )
       
   320     {
       
   321     // Does not use timer
       
   322     iTsyReqHandleStore->SetTsyReqHandle( aReqHandleType, aTsyReqHandle );
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // CMmCustomSecurityTsy::Complete
       
   327 // Completes the request due the timer expiration
       
   328 // (other items were commented in a header).
       
   329 // ---------------------------------------------------------------------------
       
   330 //
       
   331 void CMmCustomSecurityTsy::Complete(
       
   332     TInt aReqHandleType, 
       
   333     TInt aError )
       
   334     {
       
   335 TFLOGSTRING3( "CustomTSY: CMmCustomSecurityTsy::Complete.\n\t ReqHandleType:%d \n\t Error:%d\n", aReqHandleType, aError );
       
   336     // All possible TSY req handle types are listed in the
       
   337     // switch case below.
       
   338     switch ( aReqHandleType )
       
   339         {
       
   340         case ESecurityRequestTypeCheckSecurityCode:
       
   341             CompleteCheckSecurityCode( aError );
       
   342             break;
       
   343         case ESecurityRequestTypeIsBlocked:
       
   344             CompleteIsBlocked( aError, *iIsBlocked );
       
   345             break;
       
   346         case ESecurityRequestTypeDisablePhoneLock:
       
   347             CompleteDisablePhoneLock( aError );
       
   348             break;
       
   349         default:
       
   350             iMmCustomTsy->ReqCompleted( iTsyReqHandleStore->ResetTsyReqHandle( 
       
   351                 aReqHandleType ), aError );
       
   352             break;
       
   353         }
       
   354     }
       
   355 #endif // REQHANDLE_TIMER
       
   356 
       
   357 // ---------------------------------------------------------------------------
       
   358 // CMmCustomSecurityTsy::IsBlocked
       
   359 // This method gets the is blocked status
       
   360 // (other items were commented in a header).
       
   361 // ---------------------------------------------------------------------------
       
   362 //
       
   363 TInt CMmCustomSecurityTsy::IsBlocked( 
       
   364     const TTsyReqHandle aTsyReqHandle, 
       
   365     RMmCustomAPI::TSecurityCodeType* aCode,
       
   366     TBool* aIsBlocked )
       
   367     {
       
   368     if ( NULL != iTsyReqHandleStore->GetTsyReqHandle(
       
   369         ESecurityRequestTypeIsBlocked ) )
       
   370         {
       
   371         return KErrServerBusy;
       
   372         }
       
   373 TFLOGSTRING2( "TSY: CMmPhoneTsy::IsBlocked - Code to check: %d", *aCode );
       
   374 
       
   375     switch ( *aCode )
       
   376         {
       
   377         case RMmCustomAPI::ESecurityCodePin1:
       
   378             iCodeID = KSecCodePin;
       
   379             break;
       
   380         case RMmCustomAPI::ESecurityCodePin2:
       
   381             iCodeID = KSecCodePin2;
       
   382             break;
       
   383         case RMmCustomAPI::ESecurityUniversalPin:
       
   384             if ( CMmPhoneGsmWcdmaExt::EICCTypeSim3G == 
       
   385 				iMmPhoneTsy->GetActivePhoneExtension()->CurrentICCType() )
       
   386                 {
       
   387                 iCodeID = KSecCodeUpin;
       
   388                 }
       
   389             else
       
   390                 {
       
   391                 return KErrArgument;
       
   392                 }
       
   393             break;
       
   394         case RMmCustomAPI::ESecurityCodePassPhrase:
       
   395             iCodeID = KSecCodeSecurity;
       
   396             break;
       
   397         default:
       
   398             return KErrArgument;
       
   399         }
       
   400 
       
   401     // save pointer to client data
       
   402     iIsBlocked = aIsBlocked;
       
   403 
       
   404     // Send ISI message to SIM Server to check security code  and
       
   405     // intialize ret value
       
   406 
       
   407     CMmDataPackage aPackage;
       
   408     aPackage.PackData( &iCodeID );
       
   409 
       
   410     TInt retValue = KErrNone;
       
   411 	TRAPD(err, retValue = iMmPhoneTsy->MessageManager()->HandleRequestL
       
   412         ( ECustomIsBlockedIPC, &aPackage ) );
       
   413 	if(err != KErrNone)
       
   414 		{
       
   415 		retValue = err;
       
   416 		}
       
   417 
       
   418     // check result
       
   419     if ( KErrNone != retValue )
       
   420         {
       
   421         iMmCustomTsy->ReqCompleted( aTsyReqHandle, retValue );
       
   422         }
       
   423     else
       
   424         {
       
   425         // Save the req handle type 
       
   426         iReqHandleType = ESecurityRequestTypeIsBlocked;
       
   427         }
       
   428 
       
   429     return KErrNone;
       
   430     }
       
   431 
       
   432 // ---------------------------------------------------------------------------
       
   433 // CMmCustomSecurityTsy::CompleteIsBlocked
       
   434 // Completes a isblocked request
       
   435 // (other items were commented in a header).
       
   436 // ---------------------------------------------------------------------------
       
   437 //
       
   438 void CMmCustomSecurityTsy::CompleteIsBlocked(
       
   439      TInt aErrorCode, 
       
   440      TBool aIsBlocked )
       
   441     {
       
   442     // reset req handle. Returns the deleted req handle
       
   443     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( 
       
   444         ESecurityRequestTypeIsBlocked );
       
   445 
       
   446     // check the handle and complete
       
   447     if( ESecurityTsyReqHandleUnknown != reqHandle )
       
   448         {
       
   449         //set the information for the client
       
   450         *iIsBlocked = aIsBlocked;
       
   451         
       
   452         //reset pointer to client data
       
   453         iIsBlocked = NULL;
       
   454         
       
   455         iMmCustomTsy->ReqCompleted( reqHandle, aErrorCode );
       
   456         }
       
   457     }
       
   458 
       
   459 // ---------------------------------------------------------------------------
       
   460 // CMmCustomSecurityTsy::CheckSecurityCodeL
       
   461 // This method sends the check security code request
       
   462 // (other items were commented in a header).
       
   463 // ---------------------------------------------------------------------------
       
   464 //
       
   465 TInt CMmCustomSecurityTsy::CheckSecurityCodeL(
       
   466     const TTsyReqHandle aTsyReqHandle, 
       
   467     RMmCustomAPI::TSecurityCodeType* aCode )
       
   468     {
       
   469     if ( NULL != iTsyReqHandleStore->GetTsyReqHandle(
       
   470         ESecurityRequestTypeCheckSecurityCode ) )
       
   471         {
       
   472         return KErrServerBusy;
       
   473         }
       
   474 
       
   475     switch ( *aCode )
       
   476         {
       
   477         case RMmCustomAPI::ESecurityCodePin1:
       
   478             iCodeID = KSecCodePin;
       
   479             break;
       
   480         case RMmCustomAPI::ESecurityCodePin2:
       
   481             iCodeID = KSecCodePin2;
       
   482             break;
       
   483         case RMmCustomAPI::ESecurityCodePuk1:
       
   484             iCodeID = KSecCodePuk;
       
   485             break;
       
   486         case RMmCustomAPI::ESecurityCodePuk2:
       
   487             iCodeID = KSecCodePuk2;
       
   488             break;
       
   489         case RMmCustomAPI::ESecurityCodePassPhrase:
       
   490             iCodeID = KSecCodeSecurity;
       
   491             break;
       
   492         default:
       
   493             return KErrArgument;
       
   494         }
       
   495 
       
   496     CMmDataPackage aPackage;
       
   497     aPackage.PackData( &iCodeID, &iSecCode );
       
   498 
       
   499 TFLOGSTRING2( "TSY: CMmCustomSecurityTsy::CheckSecurityCodeL iSecCode: %S", &iSecCode );
       
   500     TInt retValue ( iMmPhoneTsy->MessageManager()->HandleRequestL( 
       
   501         ECustomCheckSecurityCodeIPC, &aPackage ) );
       
   502 
       
   503     // check result
       
   504     if ( KErrNone != retValue )
       
   505         {
       
   506         iMmCustomTsy->ReqCompleted( aTsyReqHandle, retValue );
       
   507         }
       
   508     else
       
   509         {
       
   510         // Save the req handle type 
       
   511         iReqHandleType = ESecurityRequestTypeCheckSecurityCode;
       
   512         }
       
   513 
       
   514     return KErrNone;
       
   515     }
       
   516 
       
   517 // ---------------------------------------------------------------------------
       
   518 // CMmCustomSecurityTsy::CompleteCheckSecurityCode
       
   519 // Completes a CheckSecurityCode request
       
   520 // (other items were commented in a header).
       
   521 // ---------------------------------------------------------------------------
       
   522 //
       
   523 void CMmCustomSecurityTsy::CompleteCheckSecurityCode(
       
   524     TInt aErrorCode )
       
   525     {
       
   526 TFLOGSTRING2("TSY: CMmCustomSecurityTsy::CompleteCheckSecurityCode - Error code: %d", aErrorCode );
       
   527     // reset req handle. Returns the deleted req handle
       
   528     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( 
       
   529         ESecurityRequestTypeCheckSecurityCode );
       
   530 
       
   531     if ( ESecurityTsyReqHandleUnknown != reqHandle )
       
   532         {
       
   533         iMmCustomTsy->ReqCompleted( reqHandle, aErrorCode );
       
   534         }
       
   535 
       
   536     // If error is not KErrNone, then security code verify has failed and
       
   537     // we need to cancel ECustomCheckSecurityCodeCancelIPC.
       
   538     // If error is KErrCancel, we have already cancelled 
       
   539     // ECustomCheckSecurityCodeCancelIPC.
       
   540     if ( ( KErrNone != aErrorCode ) && ( KErrCancel != aErrorCode ) )
       
   541         {
       
   542         TBool cancelFalse (EFalse);
       
   543         CMmDataPackage aPackage;
       
   544         aPackage.PackData( &iCodeID, &cancelFalse );
       
   545 
       
   546         TRAP_IGNORE( void( iMmPhoneTsy->MessageManager()->HandleRequestL(
       
   547               ECustomCheckSecurityCodeCancelIPC, &aPackage ) ); );
       
   548         }
       
   549     }
       
   550 
       
   551 // ---------------------------------------------------------------------------
       
   552 // CMmCustomSecurityTsy::CheckSecurityCodeCancelL
       
   553 // This function cancels an check security code request
       
   554 // (other items were commented in a header).
       
   555 // ---------------------------------------------------------------------------
       
   556 //
       
   557 TInt CMmCustomSecurityTsy::CheckSecurityCodeCancelL()
       
   558     {
       
   559     // Send message to Security Server to check security code  and
       
   560     // intialize ret value. This is cancel request, so 3rd parameter
       
   561     // is true to indicate that.
       
   562     CMmDataPackage aPackage;
       
   563     TBool trueCancel (ETrue);
       
   564     aPackage.PackData( &iCodeID, &trueCancel );
       
   565 
       
   566     TInt retValue ( iMmPhoneTsy->MessageManager()->HandleRequestL( 
       
   567         ECustomCheckSecurityCodeCancelIPC, &aPackage ) );
       
   568 
       
   569     return retValue;
       
   570     }
       
   571 
       
   572 // ---------------------------------------------------------------------------
       
   573 // CMmCustomSecurityTsy::CompleteCheckSecurityCodeCancel
       
   574 // Completes a CheckSecurityCodeCancel request
       
   575 // (other items were commented in a header).
       
   576 // ---------------------------------------------------------------------------
       
   577 //
       
   578 void CMmCustomSecurityTsy::CompleteCheckSecurityCodeCancel()
       
   579     {
       
   580 TFLOGSTRING("TSY: CMmCustomSecurityTsy::CompleteCheckSecurityCodeCancel");
       
   581     }
       
   582 
       
   583 // ---------------------------------------------------------------------------
       
   584 // CMmCustomSecurityTsy::DeliverCodeL
       
   585 // Brings required code to the Custom TSY.
       
   586 // (other items were commented in a header).
       
   587 // ---------------------------------------------------------------------------
       
   588 //
       
   589 TInt CMmCustomSecurityTsy::DeliverCodeL( 
       
   590     RMobilePhone::TCodeAndUnblockCode aCodes )
       
   591     {
       
   592     iSecCode.Copy( aCodes.iCode );
       
   593 
       
   594     CMmDataPackage aPackage;
       
   595     aPackage.PackData( &iSecCode );
       
   596     iMmPhoneTsy->MessageManager()->HandleRequestL( 
       
   597         ECustomSecurityDeliverCodeIPC, &aPackage );
       
   598 
       
   599 TFLOGSTRING2( "TSY: CMmCustomSecurityTsy::DeliverCodeL iSecCode: %S", &iSecCode );
       
   600 
       
   601     return KErrNone;
       
   602     }
       
   603 
       
   604 // ---------------------------------------------------------------------------
       
   605 // CMmCustomSecurityTsy::DisablePhoneLockL
       
   606 // This method disables phone lock
       
   607 // (other items were commented in a header).
       
   608 // ---------------------------------------------------------------------------
       
   609 //
       
   610 TInt CMmCustomSecurityTsy::DisablePhoneLockL(
       
   611     const TTsyReqHandle aTsyReqHandle, 
       
   612     RMobilePhone::TMobilePassword* aVerifyCode )
       
   613     {
       
   614     if ( NULL != iTsyReqHandleStore->GetTsyReqHandle(
       
   615         ESecurityRequestTypeDisablePhoneLock ) )
       
   616         {
       
   617         return KErrServerBusy;
       
   618         }
       
   619 
       
   620     // Send message to Security Server to disable security code
       
   621     // and intialize ret value
       
   622     CMmDataPackage aPackage;
       
   623     aPackage.PackData( aVerifyCode );
       
   624     TInt retValue ( iMmPhoneTsy->MessageManager()->HandleRequestL( 
       
   625         ECustomDisablePhoneLockIPC, &aPackage ) );
       
   626 
       
   627     // check result
       
   628     if ( KErrNone != retValue )
       
   629         {
       
   630         iMmCustomTsy->ReqCompleted( aTsyReqHandle, retValue );
       
   631         }
       
   632     else
       
   633         {
       
   634         // Save the req handle type 
       
   635         iReqHandleType = ESecurityRequestTypeDisablePhoneLock;
       
   636         }
       
   637 
       
   638     return KErrNone;
       
   639     }
       
   640 
       
   641 // ---------------------------------------------------------------------------
       
   642 // CMmCustomSecurityTsy::CompleteDisablePhoneLock
       
   643 // Completes a DisablePhoneLock request
       
   644 // (other items were commented in a header).
       
   645 // ---------------------------------------------------------------------------
       
   646 //
       
   647 void CMmCustomSecurityTsy::CompleteDisablePhoneLock(
       
   648     TInt aErrorCode )
       
   649     {
       
   650 TFLOGSTRING2("TSY: CMmCustomSecurityTsy::CompleteDisablePhoneLock - Error code: %d", aErrorCode );
       
   651     // reset req handle. Returns the deleted req handle
       
   652     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( 
       
   653         ESecurityRequestTypeDisablePhoneLock );
       
   654 
       
   655     if ( ESecurityTsyReqHandleUnknown != reqHandle )
       
   656         {
       
   657         iMmCustomTsy->ReqCompleted( reqHandle, aErrorCode );
       
   658         }
       
   659     }
       
   660 
       
   661 // ---------------------------------------------------------------------------
       
   662 // CMmCustomSecurityTsy::GetActivePin
       
   663 // Returns the currently active PIN. The value is updated by
       
   664 // events coming from security server.
       
   665 // (other items were commented in a header).
       
   666 // ---------------------------------------------------------------------------
       
   667 //
       
   668 TInt CMmCustomSecurityTsy::GetActivePin(
       
   669     const TTsyReqHandle aTsyReqHandle, 
       
   670     RMobilePhone::TMobilePhoneSecurityCode* aActivePin )
       
   671     {
       
   672     *aActivePin = iActivePin;
       
   673     iMmCustomTsy->ReqCompleted ( aTsyReqHandle, KErrNone );
       
   674 
       
   675     return KErrNone;
       
   676     }
       
   677 
       
   678 // ---------------------------------------------------------------------------
       
   679 // CMmCustomSecurityTsy::SetActivePin
       
   680 // Updates the information of the currently active PIN.
       
   681 // (other items were commented in a header).
       
   682 // ---------------------------------------------------------------------------
       
   683 //
       
   684 void CMmCustomSecurityTsy::SetActivePin(
       
   685     CMmDataPackage* aDataPackage )
       
   686     {
       
   687     RMobilePhone::TMobilePhoneSecurityCode* activePin = NULL;
       
   688     // Get the new data
       
   689     aDataPackage->UnPackData( &activePin );
       
   690         
       
   691     // Update the current information
       
   692     iActivePin = *activePin;
       
   693     }
       
   694 
       
   695 //  End of File