telephonyserverplugins/common_tsy/commontsy/src/mmcustomtsy/CMmCustomTsy.cpp
changeset 0 3553901f7fa8
child 14 7ef16719d8cb
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 "CMmCustomTsy.h"
       
    20 #include "CMmCustomGsmExt.h"
       
    21 #include "cmmcalllist.h"
       
    22 #include "cmmphoneextinterface.h"
       
    23 #include "CMmWimTsy.h"
       
    24 #include "cmmcalltsy.h"
       
    25 #include "CMmCommonStaticUtility.h"
       
    26 #include "CMmSimLockTsy.h"
       
    27 #include "MmTsy_conf.h"
       
    28 #include <ctsy/tflogger.h>
       
    29 #include "cmmpblist.h"
       
    30 #include "cmmphonebookstoretsy.h"
       
    31 #include "CMmPacketTsy.h"
       
    32 #include "CMmSIMTsy.h"
       
    33 #include "CMmCustomSecurityTsy.h"
       
    34 #include <ctsy/serviceapi/gsmerror.h>
       
    35 #include <ctsy/serviceapi/cmmcustomvendorext.h>
       
    36 #include "cmmnettsy.h"  // for CMmNetTsy::CipheringIndicatorForcedOff()
       
    37 #include <ctsy/serviceapi/ctsydomaincrkeys.h>
       
    38 #include "ctsyprivatecrpkeys.h"
       
    39 #include <featureuids.h>
       
    40 
       
    41 // ======== MEMBER FUNCTIONS ========
       
    42 
       
    43 CMmCustomTsy::CMmCustomTsy()
       
    44     {
       
    45     iMmPhoneTsy = NULL;
       
    46     iMmCustomExtInterface = NULL;
       
    47     Mem::FillZ( iMmSubTsy, sizeof( iMmSubTsy ) );
       
    48 
       
    49     // initialize internal data
       
    50     iCipheringInfo.iIndStatus = EFalse;
       
    51     iCipheringInfo.iCiphStatus = EFalse;
       
    52     }
       
    53 
       
    54 void CMmCustomTsy::ConstructL(
       
    55     CMmPhoneTsy* aMmPhoneTsy )
       
    56     {
       
    57 TFLOGSTRING("TSY: CMmCustomTsy::ConstructL");
       
    58     iMmPhoneTsy = aMmPhoneTsy;
       
    59 
       
    60     iMmCustomExtInterface = CMmCustomGsmExt::NewL( aMmPhoneTsy, this );
       
    61     iMmSubTsy[ESubTsyIdxWIM] = CMmWimTsy::NewL( this );
       
    62     iMmSubTsy[ESubTsyIdxSimLock] = CMmSimLockTsy::NewL( this );
       
    63     iMmSubTsy[ESubTsyIdxPacket] = CMmPacketTsy::NewL( this, aMmPhoneTsy );
       
    64 
       
    65     iMmSubTsy[ESubTsyIdxSIM]  = CMmSIMTsy::NewL( this );
       
    66 
       
    67     iMmSecurityTsy = CMmCustomSecurityTsy::NewL( this, aMmPhoneTsy );
       
    68 
       
    69     // Create custom vendor extension
       
    70     // Send request to the Domestic OS layer.
       
    71     iMmCustomVendorExt = (CMmCustomVendorExt*) NULL;
       
    72     CMmDataPackage package;
       
    73 
       
    74     package.PackData( &iMmCustomVendorExt ); // ptr to ptr
       
    75     Phone()->MessageManager()->HandleRequestL(
       
    76             EMmTsyGetCustomVendorExtPtrIPC, &package );
       
    77 TFLOGSTRING2("TSY: CMmCustomTsy::ConstructL -- iMmCustomVendorExt=0x%x", TUint(iMmCustomVendorExt));
       
    78     // The request above is 'completed' immediatedly (there is no need for
       
    79     // actual complete)
       
    80 
       
    81     // iMmCustomVendorExt should now hold ptr to custom vendor extension.
       
    82     // But if not, no problem, we just use the base class.
       
    83     if ( NULL == iMmCustomVendorExt )
       
    84         {
       
    85 TFLOGSTRING("TSY: CMmCustomTsy::ConstructL -- no vendor IPC extensions");
       
    86         iMmCustomVendorExt = new(ELeave)CMmCustomVendorExt();
       
    87         }
       
    88     
       
    89     // initialize custom vendor extension 
       
    90     iMmCustomVendorExt->InitializeL( *this );
       
    91 
       
    92 #ifdef REQHANDLE_TIMER
       
    93     // Create req handle store
       
    94     iTsyReqHandleStore = CMmTsyReqHandleStore::NewL( this, iMmPhoneTsy,
       
    95         ECustomTsyMaxNumOfRequests, iCustomReqHandles );
       
    96 #else
       
    97     // Create req handle store
       
    98     iTsyReqHandleStore = CMmTsyReqHandleStore::NewL(
       
    99         ECustomTsyMaxNumOfRequests, iCustomReqHandles );
       
   100 #endif
       
   101 
       
   102     // register custom tsy in the message manager
       
   103     Phone()->MessageManager()->RegisterTsyObject(
       
   104         CMmMessageManagerBase::ECustomTsy, this );
       
   105 
       
   106     iAdnCacheStatus = RMmCustomAPI::ECacheNotReady;
       
   107     iFdnCacheStatus = RMmCustomAPI::ECacheNotReady;
       
   108 
       
   109     iISVDialNumberCheckObject = NULL;
       
   110     iISVDialNumberCheck = EFalse;
       
   111     iGetIccCfStatusBootUp = ETrue;
       
   112     //Get pointer to public CenRep
       
   113     iCFISCentRep = iMmPhoneTsy->GetCfisCenRep();
       
   114     iCFISPrivateCentRep = iMmPhoneTsy->GetCfisPRCenRep();
       
   115 	TInt err = iFeatureControl.Open();
       
   116 	iUsingFeatureManager = (err == KErrNone);
       
   117     
       
   118     // update/receive Icc Call forward information
       
   119     if( iMmPhoneTsy->NosBootState()->iSIMReady )
       
   120         {
       
   121 TFLOGSTRING("TSY: CMmCustomTsy::ConstructL -- GET ICC call forward indicators");       
       
   122         // Get Icc cfis values from LTSY
       
   123         Phone()->MessageManager()->HandleRequestL( 
       
   124             ECustomGetIccCallForwardingStatusIPC );
       
   125         }
       
   126         
       
   127     // check if HomeZoneParams has been already read in NotifySimStatusReady
       
   128  	// if not, query again
       
   129     if ( !iMmPhoneTsy->GetHomeZoneParamsChecked() )
       
   130     	{
       
   131 TFLOGSTRING("TSY: CMmCustomTsy::ConstructL - GetHomeZoneParamsChecked()");    	
       
   132         CMmSIMTsy* simCustomTsy = NULL;
       
   133         simCustomTsy = ( CMmSIMTsy* )GetSIMTsyPtr();
       
   134 TFLOGSTRING("TSY: CMmCustomTsy::ConstructL - pointer created");
       
   135 	
       
   136         if ( simCustomTsy )
       
   137             {
       
   138 TFLOGSTRING("TSY: CMmCustomTsy::ConstructL - CheckViagHomeZoneParamsL()");
       
   139             simCustomTsy->CheckViagHomezoneParamsL();
       
   140             iMmPhoneTsy->SetHomeZoneParamsChecked( ETrue );
       
   141             }
       
   142         else
       
   143         	{
       
   144 TFLOGSTRING("TSY: CMmCustomTsy::ConstructL - CheckViagHomeZoneParamsL() False");        		
       
   145 			iMmPhoneTsy->SetHomeZoneParamsChecked( EFalse );
       
   146         	}
       
   147     	}     
       
   148     }
       
   149 
       
   150 CMmCustomTsy* CMmCustomTsy::NewL(
       
   151     CMmPhoneTsy* aMmPhoneTsy )
       
   152     {
       
   153 TFLOGSTRING("TSY: CMmCustomTsy::NewL");
       
   154     CMmCustomTsy* mmCustomTsy = new ( ELeave ) CMmCustomTsy();
       
   155     CleanupClosePushL( *mmCustomTsy );
       
   156     mmCustomTsy->ConstructL( aMmPhoneTsy );
       
   157     CleanupStack::Pop( mmCustomTsy );
       
   158 
       
   159     return mmCustomTsy;
       
   160     }
       
   161 
       
   162 CMmCustomTsy::~CMmCustomTsy()
       
   163     {
       
   164 TFLOGSTRING("TSY: CMmCustomTsy::~CMmCustomTsy");
       
   165 
       
   166 	iFeatureControl.Close();
       
   167 	
       
   168     // Delete subsystems
       
   169     for ( TInt i = 0; ESubTsyIdxMaxNum > i; i++ )
       
   170         {
       
   171         delete iMmSubTsy[i];
       
   172         }
       
   173 
       
   174     if ( iMmCustomVendorExt )
       
   175         {
       
   176         // delete vendor extension
       
   177         delete iMmCustomVendorExt;
       
   178         }
       
   179 
       
   180     if ( iMmSecurityTsy )
       
   181         {
       
   182         // Delete SecurityTsy
       
   183         delete iMmSecurityTsy;
       
   184         }
       
   185 
       
   186     if ( iMmCustomExtInterface )
       
   187         {
       
   188         // Delete GSM extensions
       
   189         delete iMmCustomExtInterface;
       
   190         }
       
   191 
       
   192     if ( iTsyReqHandleStore )
       
   193         {
       
   194         // delete req handle store
       
   195         delete iTsyReqHandleStore;
       
   196         }
       
   197 
       
   198     iMmCustomVendorExt = NULL;
       
   199     iMmSecurityTsy = NULL;
       
   200     iMmCustomExtInterface = NULL;
       
   201     iTsyReqHandleStore = NULL;
       
   202     iISVDialNumberCheckObject = NULL;
       
   203     iCFISCentRep = NULL;
       
   204 
       
   205     if ( iMmPhoneTsy )
       
   206         {
       
   207         iMmPhoneTsy->SetCustomTsy( NULL );
       
   208 
       
   209         // unregister custom tsy in the message manager
       
   210         iMmPhoneTsy->MessageManager()->DeregisterTsyObject(this);
       
   211         }
       
   212     }
       
   213 
       
   214 // ---------------------------------------------------------------------------
       
   215 // CMmCustomTsy::Phone
       
   216 // Returns pointer to PhoneTsy object
       
   217 // (other items were commented in a header).
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 CMmPhoneTsy* CMmCustomTsy::Phone()
       
   221     {
       
   222     return iMmPhoneTsy;
       
   223     }
       
   224 
       
   225 
       
   226 // ---------------------------------------------------------------------------
       
   227 // CMmCustomTsy::ExtFunc
       
   228 // Dispatches extension function requests. All functions that are not part
       
   229 // of the core function set, are routed via the ExtFunc method.
       
   230 // At the beginning of this method, packaged pointers are unpacked. Then
       
   231 // the correct function is selected using the IPC number.
       
   232 // (other items were commented in a header).
       
   233 // ---------------------------------------------------------------------------
       
   234 //
       
   235 TInt CMmCustomTsy::ExtFunc(
       
   236     const TTsyReqHandle aTsyReqHandle,
       
   237     const TInt aIpc,
       
   238     const TDataPackage& aPackage )
       
   239     {
       
   240     TInt ret = KErrNone;
       
   241     TInt trapError = KErrNone;
       
   242     iReqHandleType = ECustomTsyReqHandleUnknown;
       
   243 
       
   244     // before processing further the request, check if offline mode status
       
   245     // is enabled and if the given request can be perfomed in that case.
       
   246     if ( ERfsStateInfoInactive == iMmPhoneTsy->GetRfStateInfo() &&
       
   247         !IsRequestPossibleInOffline( aIpc ) )
       
   248         {
       
   249 TFLOGSTRING2 ("TSY: Offline mode ON, request is not allowed: %d", aIpc );
       
   250         ret = CMmCommonStaticUtility::EpocErrorCode( KErrGeneral,
       
   251                 KErrGsmOfflineOpNotAllowed );
       
   252 
       
   253         // Complete the request with appropiate error
       
   254         ReqCompleted ( aTsyReqHandle, ret );
       
   255         }
       
   256     else
       
   257         {
       
   258         TRAP( trapError, ret = DoExtFuncL( aTsyReqHandle, aIpc, aPackage ); );
       
   259 
       
   260         if ( KErrNone != trapError )
       
   261             {
       
   262             // error handling. Object cannot be created.
       
   263             ret = trapError;
       
   264             }
       
   265         if ( KErrNone != ret )
       
   266             {
       
   267             ReqCompleted( aTsyReqHandle, ret );
       
   268             }
       
   269         }
       
   270 
       
   271     return KErrNone;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 // CMmCustomTsy::DoExtFuncL
       
   276 // This DoExtFuncL is called by Etel server when it has Custom API
       
   277 // request for the TSY. To process a request handle, request type and request
       
   278 // data are passed to the Custom TSY.
       
   279 // (other items were commented in a header).
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 TInt CMmCustomTsy::DoExtFuncL(
       
   283     const TTsyReqHandle aTsyReqHandle,
       
   284     const TInt aIpc,
       
   285     const TDataPackage& aPackage )
       
   286     {
       
   287     TInt ret( KErrNotSupported );
       
   288 
       
   289     // first check if request is supported in CMmSecurityTsy
       
   290     // (due layering that class is no longer a part of extension modules)
       
   291 
       
   292     ret = iMmSecurityTsy->DoExtFuncL( aTsyReqHandle, aIpc, aPackage );
       
   293 
       
   294     if ( KErrNotSupported == ret )
       
   295         {
       
   296         // then check if this is vendor extension IPC
       
   297         // these IPCs are handled by VendorExt class in licensee tsy.
       
   298        if ( iMmCustomVendorExt->SupportingIPC(aIpc) )
       
   299           {
       
   300           ret = iMmCustomVendorExt->DoExtFuncL( aTsyReqHandle, aIpc,
       
   301                     aPackage );
       
   302           }
       
   303        else
       
   304           {
       
   305           // then check all the Custom extension modules
       
   306           ret = CMmTsyBase::DoBaseExtFuncL( aTsyReqHandle, aIpc, aPackage );
       
   307 	      }
       
   308 
       
   309         // if extension modules did not serve this request
       
   310         if ( KErrNotSupported == ret )
       
   311             {
       
   312             // reset last tsy request type
       
   313             iReqHandleType = ECustomTsyReqHandleUnknown;
       
   314 
       
   315             switch ( aIpc )
       
   316                 {
       
   317                 // Perform IMS Authentication
       
   318                 case EMobilePhoneIMSAuthenticate:
       
   319                     ret = ImsAuthenticationL( aTsyReqHandle,
       
   320                         REINTERPRET_CAST(
       
   321                         RMobilePhone::TImsAuthenticateDataV5*,
       
   322                         aPackage.Ptr1() ) );
       
   323                     break;
       
   324                 // Get sim authentication data
       
   325                 case ECustomGetSimAuthenticationDataIPC:
       
   326                     ret = SimAuthenticationL( aTsyReqHandle, aPackage );
       
   327                     break;
       
   328                 // Notify Dtmf event
       
   329                 case ECustomNotifyDtmfEventIPC:
       
   330                     ret = NotifyDtmfEvent(
       
   331                         REINTERPRET_CAST( RMmCustomAPI::TDtmfInfo*,
       
   332                         aPackage.Ptr1() ) );
       
   333                     break;
       
   334                 // Get Diagnostic Octets - info 
       
   335                 case ECustomGetDiagnosticOctetsIPC:
       
   336                    ret = GetDiagnosticInfo ( aTsyReqHandle,
       
   337                        REINTERPRET_CAST( TName*, aPackage.Ptr1() ) );
       
   338                    break;
       
   339                 // Get Remote Alerting Tone Status
       
   340                 case ECustomGetRemoteAlertingToneStatusIPC:
       
   341                     ret = GetRemoteAlertingToneStatus ( aTsyReqHandle,
       
   342                         REINTERPRET_CAST(
       
   343                         RMmCustomAPI::TRemoteAlertingToneStatus*,
       
   344                         aPackage.Ptr1() ) );
       
   345                     break;
       
   346                 // Call Origin
       
   347                 case ECustomCallOriginIPC:
       
   348                     ret = GetCallOrigin( aTsyReqHandle,
       
   349                         REINTERPRET_CAST( TName*, aPackage.Ptr1() ),
       
   350                         REINTERPRET_CAST( RMmCustomAPI::TCallOrigin*,
       
   351                         aPackage.Ptr2() ) );
       
   352                     break;
       
   353                 // Terminate a Call/all calls
       
   354                 case ECustomTerminateCallIPC:
       
   355                     ret = TerminateCallL( aTsyReqHandle,
       
   356                         REINTERPRET_CAST( TName*, aPackage.Ptr1() ) );
       
   357                     break;
       
   358                 // Get Als Blocked
       
   359                 case ECustomGetAlsBlockedIPC:
       
   360                     ret = GetAlsBlockedL( aTsyReqHandle,
       
   361                         REINTERPRET_CAST( RMmCustomAPI::TGetAlsBlockStatus*,
       
   362                         aPackage.Ptr1() ) );
       
   363                     break;
       
   364                 // Set Alternative Line Service Blocked
       
   365                 case ECustomSetAlsBlockedIPC:
       
   366                     ret = SetAlsBlockedL( aTsyReqHandle,
       
   367                         REINTERPRET_CAST( RMmCustomAPI::TSetAlsBlock*,
       
   368                         aPackage.Ptr1() ) );
       
   369                     break;
       
   370                 // Notify Als Blocked Change
       
   371                 case ECustomNotifyAlsBlockedChangedIPC:
       
   372                     ret = NotifyAlsBlockedChanged (
       
   373                         REINTERPRET_CAST( RMmCustomAPI::TGetAlsBlockStatus*,
       
   374                         aPackage.Ptr1() ) );
       
   375                     break;
       
   376                 // Get ALS pp support
       
   377                 case ECustomCheckAlsPpSupportIPC:
       
   378                     ret = GetAlsPpSupportL( aTsyReqHandle,
       
   379                         REINTERPRET_CAST( RMmCustomAPI::TAlsSupport*,
       
   380                                           aPackage.Ptr1() ) );
       
   381                     break;
       
   382                 // Get ciphering information
       
   383                 case ECustomGetCipheringInfoIPC:
       
   384                     ret = GetCipheringInfoL( aTsyReqHandle,
       
   385                         REINTERPRET_CAST( RMmCustomAPI::TCipheringInfo*,
       
   386                         aPackage.Ptr1() ) );
       
   387                     break;
       
   388                 // Notify ciphering information change
       
   389                 case ECustomNotifyCipheringInfoChangeIPC:
       
   390                     ret = NotifyCipheringInfoChange(
       
   391                         REINTERPRET_CAST(RMmCustomAPI::TCipheringInfo*,
       
   392                         aPackage.Ptr1() ) );
       
   393                     break;
       
   394                 // Notify NSPS status
       
   395                 case ECustomNotifyNSPSStatusIPC:
       
   396                     ret = NotifyNSPSStatus (
       
   397                          REINTERPRET_CAST(RMmCustomAPI::TNspsStatus*,
       
   398                          aPackage.Ptr1() ) );
       
   399                     break;
       
   400                 // Wake up network from NSPS status
       
   401                 case ECustomNetWakeupIPC:
       
   402                     ret = NetWakeupL( aTsyReqHandle );
       
   403                     break;
       
   404                 case ECustomClearCallBlackListIPC:
       
   405                     ret = ClearCallBlackListL ( aTsyReqHandle );
       
   406                     break;
       
   407                 // SS additional info notification
       
   408                 case ECustomSsAdditionalInfoNotificationIPC:
       
   409                      ret = SsAdditionalInfoNotification(
       
   410                         REINTERPRET_CAST( RMmCustomAPI::TSsAdditionalInfo*,
       
   411                         aPackage.Ptr1() ) );
       
   412                      break;
       
   413                 // Get the air time duration
       
   414                 case ECustomGetAirTimeDurationIPC:
       
   415                     ret = GetAirTimeDuration ( aTsyReqHandle,
       
   416                         REINTERPRET_CAST( TTimeIntervalSeconds*,
       
   417                         aPackage.Ptr1() ) );
       
   418                     break;
       
   419                 // Check emergency number
       
   420                 case ECustomCheckEmergencyNumberIPC:
       
   421                     ret = CheckEmergencyNumberL( aTsyReqHandle,
       
   422                         REINTERPRET_CAST( RMmCustomAPI::TEmerNumberCheckMode*,
       
   423                             aPackage.Ptr1() ),
       
   424                         REINTERPRET_CAST( TBool*, aPackage.Ptr2() ) );
       
   425                     break;
       
   426                 // Get Network Operator Name
       
   427                 case ECustomGetNetworkProviderNameIPC:
       
   428                     ret = GetNetworkOperatorNameL( aPackage.Des1u() );
       
   429                     break;
       
   430                 // Get two digit dial support
       
   431                 case ECustomCheckTwoDigitDialSupportIPC:
       
   432                     ret = CheckTwoDigitDialSupportL( aTsyReqHandle,
       
   433                         REINTERPRET_CAST( RMmCustomAPI::TTwoDigitDialSupport*,
       
   434                         aPackage.Ptr1() ) );
       
   435                     break;
       
   436                 // Notify when phonebook cache is ready
       
   437                 case ECustomNotifyPndCacheReadyIPC:
       
   438                     ret = NotifyPhoneBookCacheReady( aTsyReqHandle,
       
   439                         REINTERPRET_CAST( TName*, aPackage.Ptr1() ) );
       
   440                     break;
       
   441                 // Get phonebook cache status
       
   442                 case ECustomGetPndCacheStatusIPC:
       
   443                     ret = GetPndCacheStatus( aTsyReqHandle,
       
   444                         REINTERPRET_CAST( RMmCustomAPI::TPndCacheStatus*,
       
   445                             aPackage.Ptr1() ),
       
   446                         REINTERPRET_CAST( const TName*, aPackage.Des2u() ) );
       
   447                     break;
       
   448                 // Get the programmable operator name
       
   449                 case ECustomGetOperatorNameIPC:
       
   450                     ret = GetOperatorNameL( aTsyReqHandle,
       
   451                         REINTERPRET_CAST( RMmCustomAPI::TOperatorNameInfo*,
       
   452                         aPackage.Ptr1() ) );
       
   453                     break;
       
   454                 // Notify SS Network event
       
   455                 case ECustomNotifySsNetworkEventIPC:
       
   456                     ret = NotifySsNetworkEvent(
       
   457                         REINTERPRET_CAST( RMmCustomAPI::TSsTypeAndMode*,
       
   458                         aPackage.Ptr1() ),
       
   459                         REINTERPRET_CAST( RMmCustomAPI::TSsInfo*,
       
   460                         aPackage.Ptr2() ) );
       
   461                     break;
       
   462                 // Get the programmable operator logo
       
   463                 case ECustomGetProgrammableOperatorLogoIPC:
       
   464                     ret = GetProgrammableOperatorLogoL( aTsyReqHandle,
       
   465                         REINTERPRET_CAST( RMmCustomAPI::TOperatorId*,
       
   466                         aPackage.Ptr1() ),
       
   467                         REINTERPRET_CAST( RMmCustomAPI::TOperatorLogo*,
       
   468                         aPackage.Ptr2() ) );
       
   469                     break;
       
   470                 // Sat refresh complete notification
       
   471                 case ECustomSatRefreshCompleteNotificationIPC:
       
   472                     ret = SatRefreshCompleteNotification();
       
   473                     break;
       
   474                 // Reset the net server
       
   475                 case ECustomResetNetServerIPC:
       
   476                     ret = ResetNetServerL( aTsyReqHandle );
       
   477                     break;
       
   478                 // Notify Network Connection Failure
       
   479                 case ECustomNotifyNetworkConnectionFailureIPC:
       
   480                     ret = NotifyNetworkConnectionFailure( );
       
   481                     break;
       
   482                 // Get supported network modes
       
   483                 case ECustomGetSystemNetworkModesIPC:
       
   484                     ret = GetSystemNetworkModesL( aTsyReqHandle,
       
   485                         REINTERPRET_CAST(TUint32*, aPackage.Ptr1()) );
       
   486                     break;
       
   487                 // Set system network mode
       
   488                 case ECustomSetSystemNetworkModeIPC:
       
   489                     ret = SetSystemNetworkModeL( aTsyReqHandle,
       
   490                         REINTERPRET_CAST(RMmCustomAPI::TNetworkModeCaps*,
       
   491                         aPackage.Ptr1()) );
       
   492                     break;
       
   493                 // Get current system network mode
       
   494                 case ECustomGetCurrentSystemNetworkModesIPC:
       
   495                     ret = GetCurrentSystemNetworkModeL( aTsyReqHandle,
       
   496                         REINTERPRET_CAST(TUint32*, aPackage.Ptr1()) );
       
   497                     break;
       
   498                 // Get supported network bands
       
   499                 case ECustomGetBandSelectionIPC:
       
   500                     ret = GetSystemNetworkBandL( aTsyReqHandle,
       
   501                         REINTERPRET_CAST(RMmCustomAPI::TBandSelection*,
       
   502                         aPackage.Ptr1()),
       
   503                         REINTERPRET_CAST(RMmCustomAPI::TNetworkModeCaps*,
       
   504                         aPackage.Ptr2()) );
       
   505                     break;
       
   506                 // Set system network band
       
   507                 case ECustomSetBandSelectionIPC:
       
   508                     ret = SetSystemNetworkBandL( aTsyReqHandle,
       
   509                         REINTERPRET_CAST(RMmCustomAPI::TBandSelection*,
       
   510                         aPackage.Ptr1() ),
       
   511                         REINTERPRET_CAST(RMmCustomAPI::TNetworkModeCaps*,
       
   512                         aPackage.Ptr2() ) );
       
   513                     break;
       
   514                 // Notify SS request complete
       
   515                 case ECustomNotifySsRequestCompleteIPC:
       
   516                     ret = SsRequestCompleteNotification(
       
   517                          REINTERPRET_CAST( TInt*, aPackage.Ptr1() ) );
       
   518                     break;
       
   519                 case ECustomGetLifeTimeIPC:
       
   520                     ret = GetLifeTimeL( aTsyReqHandle, aPackage.Des1n() );
       
   521                     break;
       
   522                 case ECustomReadSimFileIPC:
       
   523                     ret = GetSimFileInfoL(aTsyReqHandle, aPackage.Des1n(),
       
   524                         aPackage.Des2n());
       
   525                     break;
       
   526                 // Get 3G phonebook info
       
   527                 case EGet3GPBInfoIPC:
       
   528                     ret = Get3GPBInfo ( aTsyReqHandle,
       
   529                         REINTERPRET_CAST( RMmCustomAPI::T3GPBInfo*,
       
   530                         aPackage.Ptr1() ) );
       
   531                     break;
       
   532                 case ECustomSetDriveModeIPC:
       
   533                     ret = SetDriveModeL( aTsyReqHandle,
       
   534                         REINTERPRET_CAST( RMmCustomAPI::TSetDriveMode*,
       
   535                         aPackage.Ptr1() ) );
       
   536                     break;
       
   537                 case ECustomSetSimMessageStatusReadIPC:
       
   538                     ret = SetSimMessageStatusReadL( aTsyReqHandle,
       
   539                         *( REINTERPRET_CAST(TTime*, aPackage.Ptr1() ) ),
       
   540                         *( REINTERPRET_CAST(TInt*, aPackage.Ptr2() ) ) );
       
   541                     break;
       
   542                 case ECustomNotifyRauEventIPC:
       
   543                     ret = NotifyRauEvent(
       
   544                         REINTERPRET_CAST( RMmCustomAPI::TRauEventStatus*,
       
   545                         aPackage.Ptr1() ) );
       
   546                     break;
       
   547                 case ECustomReadHSxPAStatusIPC:
       
   548                     ret = ReadHSxPAStatusL( aTsyReqHandle, REINTERPRET_CAST(
       
   549                         RMmCustomAPI::THSxPAStatus*, aPackage.Ptr1() ) );
       
   550                     break;
       
   551                 case ECustomWriteHSxPAStatusIPC:
       
   552                     ret = WriteHSxPAStatusL( aTsyReqHandle, REINTERPRET_CAST(
       
   553                         RMmCustomAPI::THSxPAStatus*, aPackage.Ptr1() ) );
       
   554                     break;
       
   555                 case ECustomNotifyHSxPAStatusIPC:
       
   556                     ret = NotifyHSxPAStatus( REINTERPRET_CAST(
       
   557                         RMmCustomAPI::THSxPAStatus*, aPackage.Ptr1() ) );
       
   558                     break;
       
   559                 case ECustomGetIccCallForwardingStatusIPC:
       
   560                 	ret = GetIccCallForwardingStatusL( aTsyReqHandle,
       
   561                     	aPackage.Des1n() );
       
   562                 	break;
       
   563                 case ECustomNotifyIccCallForwardingStatusChangeIPC:
       
   564                     ret = NotifyIccCallForwardingStatusChange(
       
   565                     	aPackage.Des1n() );
       
   566                     break;
       
   567                 case ECustomNotifyCellInfoChangeIPC:
       
   568                     ret = NotifyCellInfoChange( aPackage.Des1n() );
       
   569                     break;
       
   570                 case ECustomGetCellInfoIPC:
       
   571                     ret = GetCellInfoL( aPackage.Des1n() );
       
   572                     break;
       
   573                 case ECustomGetServiceTableSupportbyApplicationIPC:
       
   574                     ret = GetUSIMServiceSupportL( aTsyReqHandle, 
       
   575                         REINTERPRET_CAST( RMmCustomAPI::TAppSupport*, 
       
   576                         aPackage.Ptr1() ) );
       
   577                     break;
       
   578                 case ECustomNotifyRemoteAlertingToneStatusChangeIPC:
       
   579                     ret = NotifyRemoteAlertingToneStatusChange(
       
   580                         REINTERPRET_CAST( 
       
   581                         RMmCustomAPI::TRemoteAlertingToneStatus*,
       
   582                         aPackage.Ptr1() ) );
       
   583                     break;
       
   584                 default:
       
   585                     // ret is already set as KErrNotSupported
       
   586 TFLOGSTRING2("TSY: CMmCustomTsy::DoExtFuncL unsupported ipc=%d", aIpc);
       
   587                     break;
       
   588                 }
       
   589 
       
   590             // save request handle
       
   591             if ( ECustomTsyReqHandleUnknown != iReqHandleType )
       
   592                 {
       
   593 #ifdef REQHANDLE_TIMER
       
   594                 // set timer for the request
       
   595                 SetTypeOfResponse ( iReqHandleType, aTsyReqHandle );
       
   596 #else
       
   597                 iTsyReqHandleStore->SetTsyReqHandle( iReqHandleType,
       
   598                     aTsyReqHandle );
       
   599 #endif // REQHANDLE_TIMER
       
   600                 }
       
   601             }
       
   602         }
       
   603 
       
   604     return ret;
       
   605     }
       
   606 
       
   607 // ---------------------------------------------------------------------------
       
   608 // CMmCustomTsy::RegisterNotification
       
   609 // Called when the server recognises that this notification is being posted
       
   610 // for the first time on this sub-session object. It enables the TSY to
       
   611 // "turn on" any regular notification messages that it may receive from DOS.
       
   612 // (other items were commented in a header).
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 TInt CMmCustomTsy::RegisterNotification(
       
   616     const TInt aIpc )
       
   617     {
       
   618     TInt ret ( KErrNotSupported );
       
   619 
       
   620     switch( aIpc )
       
   621         {
       
   622         case ECustomNotifyRauEventIPC:
       
   623         case ECustomNotifyDtmfEventIPC:
       
   624         case ECustomNotifyAlsBlockedChangedIPC:
       
   625         case ECustomNotifyCipheringInfoChangeIPC:
       
   626         case ECustomNotifyNSPSStatusIPC:
       
   627         case ECustomSsAdditionalInfoNotificationIPC:
       
   628         case ECustomNotifySsRequestCompleteIPC:
       
   629         case ECustomNotifyPndCacheReadyIPC:
       
   630         case ECustomNotifySsNetworkEventIPC:
       
   631         case ECustomSatRefreshCompleteNotificationIPC:
       
   632         case ECustomNotifyNetworkConnectionFailureIPC:
       
   633         case ECustomNotifyHSxPAStatusIPC:
       
   634         case ECustomNotifyIccCallForwardingStatusChangeIPC:
       
   635         case ECustomNotifyCellInfoChangeIPC:
       
   636         case ECustomNotifyRemoteAlertingToneStatusChangeIPC:
       
   637             ret =  KErrNone;
       
   638             break;
       
   639 
       
   640         default:
       
   641             if ( iMmCustomVendorExt->SupportingIPC( aIpc ) )
       
   642                 {
       
   643                 ret = iMmCustomVendorExt->RegisterNotification( aIpc );
       
   644                 }
       
   645             else
       
   646                 {
       
   647                 ret = CMmTsyBase::RegisterNotification( aIpc );
       
   648                 }
       
   649             break;
       
   650         }
       
   651 
       
   652     return ret;
       
   653     }
       
   654 
       
   655 // ---------------------------------------------------------------------------
       
   656 // CMmCustomTsy::DeregisterNotification
       
   657 // Called when the server recognises that this notification will not be posted
       
   658 // again because the last client to have a handle on this sub-session object
       
   659 // has just closed the handle. It enables the TSY to "turn off" any regular
       
   660 // notification messages that it may receive from DOS.
       
   661 // (other items were commented in a header).
       
   662 // ---------------------------------------------------------------------------
       
   663 //
       
   664 TInt CMmCustomTsy::DeregisterNotification(
       
   665     const TInt aIpc )
       
   666     {
       
   667     TInt ret ( KErrNotFound );
       
   668 
       
   669     switch( aIpc )
       
   670         {
       
   671         case ECustomNotifyRauEventIPC:
       
   672         case ECustomNotifyDtmfEventIPC:
       
   673         case ECustomNotifyAlsBlockedChangedIPC:
       
   674         case ECustomNotifyCipheringInfoChangeIPC:
       
   675         case ECustomNotifyNSPSStatusIPC:
       
   676         case ECustomSsAdditionalInfoNotificationIPC:
       
   677         case ECustomNotifySsRequestCompleteIPC:
       
   678         case ECustomNotifyPndCacheReadyIPC:
       
   679         case ECustomNotifySsNetworkEventIPC:
       
   680         case ECustomSatRefreshCompleteNotificationIPC:
       
   681         case ECustomNotifyNetworkConnectionFailureIPC:
       
   682         case ECustomNotifyHSxPAStatusIPC:
       
   683         case ECustomNotifyIccCallForwardingStatusChangeIPC:
       
   684         case ECustomNotifyCellInfoChangeIPC:
       
   685         case ECustomNotifyRemoteAlertingToneStatusChangeIPC:
       
   686             ret =  KErrNone;
       
   687             break;
       
   688         default:
       
   689             if ( iMmCustomVendorExt->SupportingIPC( aIpc ) )
       
   690                 {
       
   691                 ret = iMmCustomVendorExt->DeregisterNotification( aIpc );
       
   692                 }
       
   693             else
       
   694                 {
       
   695                 ret = CMmTsyBase::DeregisterNotification( aIpc );
       
   696                 }
       
   697             break;
       
   698         }
       
   699 
       
   700     return ret;
       
   701     }
       
   702 
       
   703 // ---------------------------------------------------------------------------
       
   704 // CMmCustomTsy::ReqModeL
       
   705 // Returns request mode for given IPC. If the IPC number belongs to some of
       
   706 // the Custom API functions.
       
   707 // Possible return values:
       
   708 //     tsy has own buffering            =0x00000000  
       
   709 //     KReqModeMultipleCompletionEnabled=0x00000001
       
   710 //     KReqModeFlowControlObeyed=0x00000002
       
   711 //     KReqModeRePostImmediately=0x00000004
       
   712 // (other items were commented in a header).
       
   713 // ---------------------------------------------------------------------------
       
   714 //
       
   715 CTelObject::TReqMode CMmCustomTsy::ReqModeL(
       
   716     const TInt aIpc )
       
   717     {
       
   718     CTelObject::TReqMode ret = 0;
       
   719 
       
   720     switch ( aIpc )
       
   721         {
       
   722         // methods using DOS
       
   723         case ECustomNetWakeupIPC:
       
   724         case ECustomGetNetworkProviderNameIPC:
       
   725         case ECustomCheckTwoDigitDialSupportIPC:
       
   726         case ECustomGetOperatorNameIPC:
       
   727         case ECustomResetNetServerIPC:
       
   728             ret = KReqModeFlowControlObeyed;
       
   729             break;
       
   730             
       
   731         //TSYs wishing to implement their own buffering can return 0 
       
   732         case ECustomSetAlsBlockedIPC:            
       
   733         case ECustomSetDriveModeIPC:            
       
   734             ret = 0;
       
   735             break;
       
   736 
       
   737         // Notifications
       
   738         case ECustomNotifyRauEventIPC:
       
   739         case ECustomNotifyDtmfEventIPC:
       
   740         case ECustomNotifyAlsBlockedChangedIPC:
       
   741         case ECustomNotifyCipheringInfoChangeIPC:
       
   742         case ECustomNotifyNSPSStatusIPC:
       
   743         case ECustomSsAdditionalInfoNotificationIPC:
       
   744         case ECustomNotifyPndCacheReadyIPC:
       
   745         case ECustomNotifySsNetworkEventIPC:
       
   746         case ECustomSatRefreshCompleteNotificationIPC:
       
   747         case ECustomNotifyNetworkConnectionFailureIPC:
       
   748         case ECustomNotifySsRequestCompleteIPC:
       
   749         case ECustomNotifyHSxPAStatusIPC:
       
   750         case ECustomNotifyIccCallForwardingStatusChangeIPC:
       
   751         case ECustomNotifyCellInfoChangeIPC:
       
   752         case ECustomNotifyRemoteAlertingToneStatusChangeIPC:
       
   753             ret = KReqModeRePostImmediately |
       
   754                   KReqModeMultipleCompletionEnabled;
       
   755             break;
       
   756 
       
   757         // methods that are using DOS but have own flow control system
       
   758         case ECustomGetProgrammableOperatorLogoIPC:
       
   759         case ECustomTerminateCallIPC:
       
   760         case ECustomCheckEmergencyNumberIPC:
       
   761         case ECustomCheckAlsPpSupportIPC:
       
   762         case ECustomGetAlsBlockedIPC:
       
   763         case ECustomGetCipheringInfoIPC:
       
   764         case ECustomClearCallBlackListIPC:
       
   765         case ECustomGetSystemNetworkModesIPC:
       
   766         case ECustomSetSystemNetworkModeIPC:
       
   767         case ECustomGetCurrentSystemNetworkModesIPC:
       
   768         case ECustomReadHSxPAStatusIPC:
       
   769         case ECustomWriteHSxPAStatusIPC:
       
   770         case ECustomGetIccCallForwardingStatusIPC:
       
   771         case ECustomGetCellInfoIPC:
       
   772         case ECustomGetBandSelectionIPC:
       
   773         case ECustomSetBandSelectionIPC:
       
   774 
       
   775         // methods not using DOS
       
   776         case ECustomCallOriginIPC:
       
   777         case ECustomGetDiagnosticOctetsIPC:
       
   778         case ECustomGetAirTimeDurationIPC:
       
   779         case ECustomGetRemoteAlertingToneStatusIPC:
       
   780         case ECustomGetPndCacheStatusIPC:
       
   781         case ECustomGetLifeTimeIPC:
       
   782         case ECustomReadSimFileIPC:
       
   783         case EGet3GPBInfoIPC:
       
   784         case EMobilePhoneIMSAuthenticate:
       
   785         case ECustomGetSimAuthenticationDataIPC:
       
   786        	case ECustomGetServiceTableSupportbyApplicationIPC:
       
   787 
       
   788         // from Security Tsy
       
   789         case ECustomCheckSecurityCodeIPC:
       
   790         case ECustomIsBlockedIPC:
       
   791         case ECustomDisablePhoneLockIPC:
       
   792         case ECustomGetActivePinIPC:
       
   793         case ECustomSetSimMessageStatusReadIPC:
       
   794             ret = 0;
       
   795             break;
       
   796         default:
       
   797             if ( iMmCustomVendorExt->SupportingIPC( aIpc ) )
       
   798                 {
       
   799                 ret = iMmCustomVendorExt->ReqModeL( aIpc );
       
   800                 }
       
   801             else
       
   802                 {
       
   803                 ret = CMmTsyBase::ReqModeL ( aIpc );
       
   804                 }
       
   805             break;
       
   806         }
       
   807 
       
   808     return ret;
       
   809     }
       
   810 
       
   811 // ---------------------------------------------------------------------------
       
   812 // CMmCustomTsy::NumberOfSlotsL
       
   813 // Returns number of slots to be used for given IPC.
       
   814 // (other items were commented in a header).
       
   815 // ---------------------------------------------------------------------------
       
   816 //
       
   817 TInt CMmCustomTsy::NumberOfSlotsL(
       
   818     const TInt aIpc )
       
   819     {
       
   820     TInt numberOfSlots ( KMmCustomDefaultSlots );
       
   821 
       
   822     switch ( aIpc )
       
   823         {
       
   824         case ECustomNotifyDtmfEventIPC:
       
   825             numberOfSlots = KMmCustomNotifyDtmfEventSlots;
       
   826             break;
       
   827         case ECustomNotifyRauEventIPC:
       
   828         case ECustomNotifyAlsBlockedChangedIPC:
       
   829         case ECustomNotifyCipheringInfoChangeIPC:
       
   830         case ECustomNotifyNSPSStatusIPC:
       
   831         case ECustomSsAdditionalInfoNotificationIPC:
       
   832         case ECustomNotifySsRequestCompleteIPC:
       
   833         case ECustomNotifyPndCacheReadyIPC:
       
   834         case ECustomNotifySsNetworkEventIPC:
       
   835         case ECustomSatRefreshCompleteNotificationIPC:
       
   836         case ECustomNotifyNetworkConnectionFailureIPC:
       
   837         case ECustomNotifyHSxPAStatusIPC:
       
   838         case ECustomNotifyIccCallForwardingStatusChangeIPC:
       
   839         case ECustomNotifyCellInfoChangeIPC:
       
   840         case ECustomNotifyRemoteAlertingToneStatusChangeIPC:
       
   841             break;
       
   842 
       
   843         default:
       
   844             if ( iMmCustomVendorExt->SupportingIPC( aIpc ) )
       
   845                 {
       
   846                 numberOfSlots = iMmCustomVendorExt->NumberOfSlotsL( aIpc );
       
   847                 }
       
   848             else
       
   849                 {
       
   850                 numberOfSlots = CMmTsyBase:: NumberOfSlotsL( aIpc );
       
   851                 }
       
   852             break;
       
   853         }
       
   854 
       
   855     return numberOfSlots;
       
   856     }
       
   857 
       
   858 // ---------------------------------------------------------------------------
       
   859 // CMmCustomTsy::GetRequiredPlatSecCaps
       
   860 // ETel server calls this method to find out capabilities of custom IPCs.
       
   861 // (other items were commented in a header).
       
   862 // ---------------------------------------------------------------------------
       
   863 //
       
   864 TSecurityPolicy CMmCustomTsy::GetRequiredPlatSecCaps(
       
   865     const TInt aIpc )
       
   866     {
       
   867 TFLOGSTRING2( "TSY: CMmCustomTsy::GetRequiredPlatSecCaps ipc=%d", aIpc );
       
   868     // assume fail as default return value
       
   869     TSecurityPolicy policy( TSecurityPolicy::EAlwaysFail );
       
   870 
       
   871     // deal with cancellations
       
   872     TInt ipc ( aIpc );
       
   873     if (ipc >= KIpcCustomExt + EMobileCancelOffset)
       
   874         {
       
   875         ipc  -= EMobileCancelOffset;
       
   876 TFLOGSTRING2("TSY: CMmCustomTsy::GetRequiredPlatSecCaps cancel for ipc=%d", ipc);
       
   877         }
       
   878 
       
   879     switch ( ipc )
       
   880         {
       
   881         case ECustomNotifyRauEventIPC:
       
   882         case ECustomSatRefreshCompleteNotificationIPC: // To be removed
       
   883         case ECustomNotifyPndCacheReadyIPC:
       
   884         case ECustomGetPndCacheStatusIPC:
       
   885         case EGet3GPBInfoIPC:
       
   886         case ECustomNotifyDtmfEventIPC:
       
   887         case ECustomGetRemoteAlertingToneStatusIPC:
       
   888         case ECustomCallOriginIPC:
       
   889         case ECustomGetAlsBlockedIPC:
       
   890         case ECustomNotifyAlsBlockedChangedIPC:
       
   891         case ECustomCheckAlsPpSupportIPC:
       
   892         case ECustomCheckEmergencyNumberIPC:
       
   893         case ECustomGetCipheringInfoIPC:
       
   894         case ECustomNotifyCipheringInfoChangeIPC:
       
   895         case ECustomNotifyNSPSStatusIPC:
       
   896         case ECustomNotifyProgrammableOperatorLogoChangeIPC:
       
   897         case ECustomNotifyNetworkConnectionFailureIPC:
       
   898         case ECustomNotifySsRequestCompleteIPC:
       
   899         case ECustomGetActivePinIPC:
       
   900         case ECustomGetSystemNetworkModesIPC:
       
   901         case ECustomGetCurrentSystemNetworkModesIPC:
       
   902         case ECustomGetATRIPC:
       
   903         case ECustomNotifySimCardStatusIPC:
       
   904         case ECustomGetSimCardReaderStatusIPC:
       
   905         case ECustomNotifyHSxPAStatusIPC:
       
   906         case ECustomNotifyIccCallForwardingStatusChangeIPC:
       
   907         case ECustomNotifyCellInfoChangeIPC:
       
   908         case ECustomGetBandSelectionIPC:
       
   909         case ECustomNotifyRemoteAlertingToneStatusChangeIPC:
       
   910 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=None");
       
   911             policy = TSecurityPolicy( TSecurityPolicy::EAlwaysPass );
       
   912             break;
       
   913 
       
   914         // NetworkControl
       
   915         case ECustomResetNetServerIPC:
       
   916         case ECustomSetSystemNetworkModeIPC:
       
   917         case ECustomSimWarmResetIPC:
       
   918         case ECustomSetBandSelectionIPC:
       
   919 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=NetworkControl");
       
   920             policy = TSecurityPolicy( ECapabilityNetworkControl );
       
   921             break;
       
   922 
       
   923         // NetworkControl, PowerMgmt
       
   924         case ECustomPowerSimOnIPC:
       
   925         case ECustomPowerSimOffIPC:
       
   926 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=NetworkControl, PowerMgmt");
       
   927             policy = TSecurityPolicy( ECapabilityNetworkControl,
       
   928                 ECapabilityPowerMgmt );
       
   929             break;
       
   930 
       
   931         // NetworkControl, ReadDeviceData
       
   932         case ECustomReleaseFileIPC:
       
   933         case ECustomRestartFileIPC:
       
   934 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=NetworkControl, ReadDeviceData");
       
   935             policy = TSecurityPolicy( ECapabilityNetworkControl,
       
   936                 ECapabilityReadDeviceData );
       
   937             break;
       
   938 
       
   939         // NetworkServices
       
   940         case ECustomTerminateCallIPC:
       
   941         case ECustomCancelUssdSessionIPC:
       
   942 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=NetworkServices");
       
   943             policy = TSecurityPolicy( ECapabilityNetworkServices );
       
   944             break;
       
   945 
       
   946         // NetworkServices, WriteDeviceData
       
   947         case ECustomSetDriveModeIPC:
       
   948 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=NetworkServices, WriteDeviceData");
       
   949             policy = TSecurityPolicy( ECapabilityNetworkServices,
       
   950                 ECapabilityWriteDeviceData );
       
   951             break;
       
   952 
       
   953         // ReadDeviceData
       
   954         case EReadViagHomeZoneParamsIPC:
       
   955         case ECustomGetNetworkProviderNameIPC:
       
   956         case ECustomGetDiagnosticOctetsIPC:
       
   957         case ECustomGetLifeTimeIPC:
       
   958         case ECustomGetOperatorNameIPC:
       
   959         case ECustomGetProgrammableOperatorLogoIPC:
       
   960         case ECustomSsAdditionalInfoNotificationIPC:
       
   961         case ECustomIsBlockedIPC:
       
   962         case ECustomCheckTwoDigitDialSupportIPC:
       
   963         case ECustomNotifyEGprsInfoChange:
       
   964         case ECustomGetEGprsInfo:
       
   965         case EMobilePhoneIMSAuthenticate:
       
   966         case ECustomReadHSxPAStatusIPC:
       
   967         case ECustomGetIccCallForwardingStatusIPC:
       
   968         case ECustomGetCellInfoIPC:
       
   969 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=ReadDeviceData");
       
   970             policy = TSecurityPolicy( ECapabilityReadDeviceData );
       
   971             break;
       
   972 
       
   973         // ReadDeviceData, Location
       
   974         case EReadViagHomeZoneCacheIPC:
       
   975 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=ReadDeviceData, Location");
       
   976             policy = TSecurityPolicy( ECapabilityReadDeviceData,
       
   977                 ECapabilityLocation );
       
   978             break;
       
   979 
       
   980         // ReadDeviceData, ReadUserData
       
   981         case ECustomNotifySsNetworkEventIPC:
       
   982 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy= ReadDeviceData, ReadUserData");
       
   983             policy = TSecurityPolicy( ECapabilityReadDeviceData,
       
   984                 ECapabilityReadUserData );
       
   985             break;
       
   986 
       
   987         // ReadDeviceData, ReadUserData, Location
       
   988         case ECustomReadSimFileIPC:
       
   989 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=ReadDeviceData, ReadUserData, Location");
       
   990             policy = TSecurityPolicy( ECapabilityReadDeviceData,
       
   991                 ECapabilityReadUserData,
       
   992                 ECapabilityLocation );
       
   993             break;
       
   994 
       
   995         // ReadDeviceData, ReadUserData, WriteUserData, NetworkControl
       
   996         case ECustomGetSimAuthenticationDataIPC:
       
   997 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=ReadDeviceData, ReadUserData, WriteUserData, NetworkControl");
       
   998             policy = TSecurityPolicy( ECapabilityReadDeviceData,
       
   999                 ECapabilityReadUserData,
       
  1000                 ECapabilityWriteUserData,
       
  1001                 ECapabilityNetworkControl );
       
  1002             break;
       
  1003 
       
  1004        	case ECustomGetServiceTableSupportbyApplicationIPC:
       
  1005 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=ReadDeviceData");
       
  1006             policy = TSecurityPolicy( ECapabilityReadDeviceData );
       
  1007             break;
       
  1008         // ReadDeviceData, WriteDeviceData, ReadUserData, WriteUserData,
       
  1009         // Location, NetworkServices, NetworkControl
       
  1010         case ECustomSendAPDUReqIPC:
       
  1011         case ECustomSendAPDUReqV2IPC:
       
  1012 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=ReadDeviceData, WriteDeviceData, ReadUserData, WriteUserData, Location, NetworkServices, NetworkControl");
       
  1013             policy = TSecurityPolicy( ECapabilityReadDeviceData,
       
  1014                 ECapabilityWriteDeviceData,
       
  1015                 ECapabilityReadUserData,
       
  1016                 ECapabilityWriteUserData,
       
  1017                 ECapabilityLocation,
       
  1018                 ECapabilityNetworkServices,
       
  1019                 ECapabilityNetworkControl  );
       
  1020             break;
       
  1021 
       
  1022         // ReadUserData
       
  1023         case ECustomStartSimCbTopicBrowsingIPC:
       
  1024         case ECustomGetNextSimCbTopicIPC:
       
  1025         case ECustomGetAirTimeDurationIPC:
       
  1026 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=ReadUserData");
       
  1027             policy = TSecurityPolicy( ECapabilityReadUserData );
       
  1028             break;
       
  1029 
       
  1030         // WriteDeviceData
       
  1031         case ECustomSetAlwaysOnMode:
       
  1032         case ECustomSimLockActivateIPC:
       
  1033         case ECustomSimLockDeActivateIPC:
       
  1034         case ECustomSetAlsBlockedIPC:
       
  1035         case ECustomClearCallBlackListIPC:
       
  1036         case ECustomNetWakeupIPC:
       
  1037         case ECustomCheckSecurityCodeIPC:
       
  1038         case ECustomDisablePhoneLockIPC:
       
  1039         case ECustomSetSimMessageStatusReadIPC:
       
  1040         case ECustomWriteHSxPAStatusIPC:
       
  1041 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=WriteDeviceData");
       
  1042             policy = TSecurityPolicy( ECapabilityWriteDeviceData );
       
  1043             break;
       
  1044 
       
  1045         // WriteDeviceData, Location
       
  1046         case EWriteViagHomeZoneCacheIPC:
       
  1047 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=WriteDeviceData, Location");
       
  1048             policy = TSecurityPolicy( ECapabilityWriteDeviceData,
       
  1049                 ECapabilityLocation );
       
  1050             break;
       
  1051 
       
  1052         // WriteUserData
       
  1053         case ECustomDeleteSimCbTopicIPC:
       
  1054 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=WriteUserData");
       
  1055             policy = TSecurityPolicy( ECapabilityWriteUserData );
       
  1056             break;
       
  1057 
       
  1058         // WriteDeviceData
       
  1059         case EWriteViagHomeZoneUHZIUESettingsIPC:
       
  1060 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=WriteDeviceData");
       
  1061             policy = TSecurityPolicy( ECapabilityWriteDeviceData );
       
  1062             break;
       
  1063         default:
       
  1064             if ( iMmCustomVendorExt->SupportingIPC(ipc) )
       
  1065                 {
       
  1066                 policy = iMmCustomVendorExt->GetRequiredPlatSecCaps(ipc);
       
  1067                 }
       
  1068             else
       
  1069                 {
       
  1070                 // if none of the above then we end up here,
       
  1071                 // as a default we already have caps as alwaysfail.
       
  1072 TFLOGSTRING("TSY: CMmCustomTsy::GetRequiredPlatSecCaps policy=AlwaysFail");
       
  1073                 }
       
  1074             break;
       
  1075         }
       
  1076 
       
  1077     return policy;
       
  1078     }
       
  1079 
       
  1080 // ---------------------------------------------------------------------------
       
  1081 // CMmCustomTsy::CancelService
       
  1082 // When the clients close their sub-sessions (eg. by calling RPhone::Close),
       
  1083 // they may not have cancelled all their outstanding asynchronous requests
       
  1084 // before closing. It is up to the ETel server to clean up in this situation,
       
  1085 // so the server will find the list of outstanding requests related to that
       
  1086 // sub-session object and pass these outstanding IPC request numbers, one at
       
  1087 // a time, to the CancelService function in the TSY.
       
  1088 // (other items were commented in a header).
       
  1089 // ---------------------------------------------------------------------------
       
  1090 //
       
  1091 TInt CMmCustomTsy::CancelService(
       
  1092     const TInt aIpc,
       
  1093     const TTsyReqHandle aTsyReqHandle )
       
  1094     {
       
  1095     TInt ret ( KErrGeneral );
       
  1096 
       
  1097     // When the clients close their sub-sessions (eg. by calling
       
  1098     // RPhone::Close), they may not have cancelled all their outstanding
       
  1099     // asynchronous requests before closing. It is up to the ETel server to
       
  1100     // clean up in this situation, so the server will find the list of
       
  1101     // outstanding requests related to that sub-session object and pass these
       
  1102     // outstanding IPC request numbers, one at a time, to the CancelService
       
  1103     // function in the TSY.
       
  1104 
       
  1105     switch ( aIpc )
       
  1106         {
       
  1107         case ECustomTerminateCallIPC:
       
  1108         case ECustomSetAlsBlockedIPC:
       
  1109         case ECustomNetWakeupIPC:
       
  1110         case ECustomClearCallBlackListIPC:
       
  1111         case ECustomResetNetServerIPC:
       
  1112         case ECustomGetPndCacheStatusIPC:
       
  1113         case ECustomSetDriveModeIPC:
       
  1114         case ECustomSetBandSelectionIPC:	
       
  1115         case ECustomSetSystemNetworkModeIPC:            
       
  1116             // TSY has started a request and it is not possible to then
       
  1117             // cancel it. The best thing for the TSY to do in
       
  1118             // this case is to proceed as though the Cancel never happened.
       
  1119             // The server's call to the TSY cancel function will return
       
  1120             // synchronously. The TSY then continues to wait for the methods
       
  1121             // acknowledgement and when it receives it, the TSY will complete
       
  1122             // the original request.
       
  1123             ret = KErrNone;
       
  1124             break;
       
  1125         case ECustomNotifyRauEventIPC:
       
  1126             ret = NotifyRauEventCancel();
       
  1127             break;
       
  1128         case ECustomNotifyDtmfEventIPC:
       
  1129             ret = NotifyDtmfEventCancel( aTsyReqHandle );
       
  1130             break;
       
  1131         case ECustomGetAlsBlockedIPC:
       
  1132             ret = GetAlsBlockedCancel ();
       
  1133             break;
       
  1134         case ECustomGetCipheringInfoIPC:
       
  1135             ret = GetCipheringInfoCancel();
       
  1136             break;
       
  1137         case ECustomNotifyCipheringInfoChangeIPC:
       
  1138             ret = NotifyCipheringInfoChangeCancel( aTsyReqHandle );
       
  1139             break;
       
  1140         case ECustomNotifyNSPSStatusIPC:
       
  1141             ret = NotifyNSPSStatusCancel( aTsyReqHandle );
       
  1142             break;
       
  1143         case ECustomNotifyAlsBlockedChangedIPC:
       
  1144             ret = NotifyAlsBlockedChangedCancel( aTsyReqHandle );
       
  1145             break;
       
  1146         case ECustomCheckAlsPpSupportIPC:
       
  1147             ret = GetAlsPpSupportCancel();
       
  1148             break;
       
  1149         case ECustomSsAdditionalInfoNotificationIPC:
       
  1150             ret = SsAdditionalInfoNotificationCancel( aTsyReqHandle );
       
  1151             break;
       
  1152         case ECustomNotifySsRequestCompleteIPC:
       
  1153             ret = SsRequestCompleteNotificationCancel( aTsyReqHandle );
       
  1154             break;
       
  1155         case ECustomNotifyPndCacheReadyIPC:
       
  1156             ret = NotifyPhoneBookCacheReadyCancel( aTsyReqHandle );
       
  1157             break;
       
  1158         case ECustomCheckEmergencyNumberIPC:
       
  1159             ret = CheckEmergencyNumberCancel();
       
  1160             break;
       
  1161         case ECustomGetNetworkProviderNameIPC:
       
  1162             ret = GetNetworkOperatorNameCancel();
       
  1163             break;
       
  1164         case ECustomCheckTwoDigitDialSupportIPC:
       
  1165             ret = CheckTwoDigitDialSupportCancel();
       
  1166             break;
       
  1167         case ECustomGetOperatorNameIPC:
       
  1168             ret = GetOperatorNameCancel();
       
  1169             break;
       
  1170         case ECustomNotifySsNetworkEventIPC:
       
  1171             ret = NotifySsNetworkEventCancel();
       
  1172             break;
       
  1173         case ECustomGetProgrammableOperatorLogoIPC:
       
  1174             ret = GetProgrammableOperatorLogoCancel();
       
  1175             break;
       
  1176         case ECustomSatRefreshCompleteNotificationIPC:
       
  1177             ret = SatRefreshCompleteNotificationCancel( aTsyReqHandle );
       
  1178             break;
       
  1179         case ECustomGetCurrentSystemNetworkModesIPC:
       
  1180             ret = GetCurrentSystemNetworkModeCancel( aTsyReqHandle );
       
  1181             break;
       
  1182         case ECustomNotifyNetworkConnectionFailureIPC:
       
  1183             ret = NotifyNetworkConnectionFailureCancel();
       
  1184             break;
       
  1185         case ECustomReadSimFileIPC:
       
  1186             ret = GetSimFileInfoCancel( aTsyReqHandle );
       
  1187             break;
       
  1188         case ECustomGetLifeTimeIPC:
       
  1189             ret = GetLifeTimeCancel();
       
  1190             break;
       
  1191         case EGet3GPBInfoIPC:
       
  1192             ret = Get3GPBInfoCancel ();
       
  1193             break;
       
  1194         case ECustomGetSystemNetworkModesIPC:
       
  1195             ret = GetSystemNetworkModesCancel( aTsyReqHandle );
       
  1196             break;
       
  1197         case EMobilePhoneIMSAuthenticate:
       
  1198             ret = ImsAuthenticationCancel();
       
  1199             break;
       
  1200         case ECustomGetSimAuthenticationDataIPC:
       
  1201             ret = SimAuthenticationCancel();
       
  1202             break;
       
  1203         case ECustomReadHSxPAStatusIPC:
       
  1204             ret = ReadHSxPAStatusCancel();
       
  1205             break;
       
  1206         case ECustomWriteHSxPAStatusIPC:
       
  1207             ret = WriteHSxPAStatusCancel();
       
  1208             break;
       
  1209         case ECustomNotifyHSxPAStatusIPC:
       
  1210             ret = NotifyHSxPAStatusCancel();
       
  1211             break;
       
  1212         case ECustomNotifyIccCallForwardingStatusChangeIPC:
       
  1213             ret = NotifyIccCallForwardingStatusChangeCancel( aTsyReqHandle );
       
  1214             break;
       
  1215         case ECustomGetIccCallForwardingStatusIPC:
       
  1216             ret = GetIccCallForwardingStatusCancel();
       
  1217             break;
       
  1218         case ECustomNotifyCellInfoChangeIPC:
       
  1219             ret = NotifyCellInfoChangeCancel();
       
  1220             break;
       
  1221         case ECustomGetCellInfoIPC:
       
  1222             ret = GetCellInfoCancel();
       
  1223             break;
       
  1224         case ECustomGetBandSelectionIPC:
       
  1225             ret = GetSystemNetworkBandCancel( aTsyReqHandle );
       
  1226             break;
       
  1227        	case ECustomGetServiceTableSupportbyApplicationIPC:
       
  1228        		ret = GetUSIMServiceSupportCancel();
       
  1229        		break;
       
  1230         case ECustomNotifyRemoteAlertingToneStatusChangeIPC:
       
  1231             ret = NotifyRemoteAlertingToneStatusChangeCancel();
       
  1232             break;
       
  1233         case ECustomTsyGetIccCallForwardingStatus:
       
  1234           	ret = GetIccCallForwardingStatusCancel( aTsyReqHandle );
       
  1235           	break;
       
  1236         default:
       
  1237         	if ( iMmSecurityTsy->SupportingIPC( aIpc ) ) 
       
  1238         		{ 
       
  1239         		ret = iMmSecurityTsy->CancelService ( aIpc, 
       
  1240         				aTsyReqHandle ); 
       
  1241         		}
       
  1242         	else if ( iMmCustomVendorExt->SupportingIPC( aIpc ) )
       
  1243                 {
       
  1244                 ret = iMmCustomVendorExt->CancelService ( aIpc,
       
  1245                         aTsyReqHandle );
       
  1246                 }
       
  1247             else
       
  1248                 {
       
  1249                 ret = CMmTsyBase::CancelService ( aIpc, aTsyReqHandle );
       
  1250                 }
       
  1251             break;
       
  1252         }
       
  1253 
       
  1254     return ret;
       
  1255     }
       
  1256 
       
  1257 // ---------------------------------------------------------------------------
       
  1258 // CMmCustomTsy::IMSAuthenticationL
       
  1259 // Requests authentication data generatation from input parameters
       
  1260 // (other items were commented in a header).
       
  1261 // ---------------------------------------------------------------------------
       
  1262 //
       
  1263 TInt CMmCustomTsy::ImsAuthenticationL(
       
  1264     const TTsyReqHandle aTsyReqHandle,
       
  1265     RMobilePhone::TImsAuthenticateDataV5* aAuthenticationData )
       
  1266     {
       
  1267     // Save pointer to client space
       
  1268     iIMSAuthenticationData = aAuthenticationData;
       
  1269 
       
  1270     CMmDataPackage authenticationDataPackage;
       
  1271     authenticationDataPackage.PackData( iIMSAuthenticationData );
       
  1272 
       
  1273     TInt ret = ( iMmPhoneTsy->MessageManager()->HandleRequestL(
       
  1274         EMobilePhoneIMSAuthenticate, &authenticationDataPackage ) );
       
  1275 
       
  1276     // Check response of the extension
       
  1277     if ( KErrNone != ret )
       
  1278         {
       
  1279         ReqCompleted( aTsyReqHandle, ret );
       
  1280         }
       
  1281     else
       
  1282         {
       
  1283         // Save the req handle type
       
  1284         iReqHandleType = ECustomTsyIMSAuthenticate;
       
  1285         }
       
  1286 
       
  1287     return KErrNone;
       
  1288     }
       
  1289 
       
  1290 // ---------------------------------------------------------------------------
       
  1291 // CMmCustomTsy::CompleteImsAuthentication
       
  1292 // Requests authentication data generatation from input parameters
       
  1293 // (other items were commented in a header).
       
  1294 // ---------------------------------------------------------------------------
       
  1295 //
       
  1296 void CMmCustomTsy::CompleteImsAuthentication(
       
  1297     CMmDataPackage* aDataPackage,
       
  1298     TInt aResult )
       
  1299     {
       
  1300     // reset req handle. Returns the deleted req handle
       
  1301     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  1302         ECustomTsyIMSAuthenticate );
       
  1303 
       
  1304     if ( KErrNone == aResult )
       
  1305         {
       
  1306         if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  1307             {
       
  1308             RMobilePhone::TImsAuthenticateDataV5* authenticationData;
       
  1309             aDataPackage->UnPackData( &authenticationData );
       
  1310 
       
  1311             // Copy data to client
       
  1312             iIMSAuthenticationData->iRES.Copy( authenticationData->iRES );
       
  1313             iIMSAuthenticationData->iCK.Copy( authenticationData->iCK );
       
  1314             iIMSAuthenticationData->iIK.Copy( authenticationData->iIK );
       
  1315 
       
  1316             iIMSAuthenticationData = NULL;
       
  1317 
       
  1318             ReqCompleted( reqHandle, aResult );
       
  1319             }
       
  1320         }
       
  1321     else if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  1322         {
       
  1323         if ( KErrTimedOut == aResult )
       
  1324             {
       
  1325             iIMSAuthenticationData = NULL;
       
  1326             }
       
  1327         else
       
  1328             {
       
  1329             RMobilePhone::TImsAuthenticateDataV5* authenticationData;
       
  1330             aDataPackage->UnPackData( &authenticationData );
       
  1331 
       
  1332             // It is possible that request is completed whithout any data
       
  1333             // inside datapackage
       
  1334             if ( NULL != authenticationData )
       
  1335                 {
       
  1336                 iIMSAuthenticationData->iAUTS.Copy(
       
  1337                   authenticationData->iAUTS );
       
  1338 
       
  1339                 iIMSAuthenticationData = NULL;
       
  1340                 }
       
  1341             }
       
  1342 
       
  1343         ReqCompleted( reqHandle, aResult );
       
  1344         }
       
  1345     }
       
  1346 
       
  1347 // ---------------------------------------------------------------------------
       
  1348 // CMmCustomTsy::ImsAuthenticationCancel
       
  1349 // Cancels sim authentication request
       
  1350 // (other items were commented in a header).
       
  1351 // ---------------------------------------------------------------------------
       
  1352 //
       
  1353 TInt CMmCustomTsy::ImsAuthenticationCancel()
       
  1354     {
       
  1355     // reset the reqhandle
       
  1356     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  1357         ECustomTsyIMSAuthenticate );
       
  1358 
       
  1359     // reset pointer to client data
       
  1360     iIMSAuthenticationData = NULL;
       
  1361 
       
  1362     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  1363     	{
       
  1364     	// complete
       
  1365     	ReqCompleted( reqHandle, KErrCancel );
       
  1366     	}
       
  1367 
       
  1368     return KErrNone;
       
  1369     }
       
  1370 
       
  1371 // ---------------------------------------------------------------------------
       
  1372 // CMmCustomTsy::SimAuthenticationL
       
  1373 // Gets authentication parameters from sim
       
  1374 // (other items were commented in a header).
       
  1375 // ---------------------------------------------------------------------------
       
  1376 //
       
  1377 TInt CMmCustomTsy::SimAuthenticationL(
       
  1378     const TTsyReqHandle aTsyReqHandle,
       
  1379     const TDataPackage& aAuthData )
       
  1380     {
       
  1381     TInt ret ( KErrNone );
       
  1382     TInt rfStateInfo ( ERfsStateInfoNormal );
       
  1383 
       
  1384 TFLOGSTRING( "CMmCustomTSY: CMmCustomTsy::SimAuthentication" );
       
  1385 
       
  1386     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(ECustomTsyGetSimAuthenticationData);
       
  1387     if(0 < reqHandle)
       
  1388         {
       
  1389         return KErrServerBusy;
       
  1390         }
       
  1391 
       
  1392 
       
  1393 
       
  1394     RMmCustomAPI::TSimAuthenticationBase* basePtr =
       
  1395         REINTERPRET_CAST( RMmCustomAPI::TSimAuthenticationBase*,
       
  1396         aAuthData.Ptr1() );
       
  1397 
       
  1398     CMmDataPackage authenticationDataPackage;
       
  1399 
       
  1400     rfStateInfo = iMmPhoneTsy->GetRfStatus();
       
  1401 
       
  1402     // Declare a RAND sized buffer
       
  1403     TBuf8<16> rand;
       
  1404 
       
  1405     if ( RMmCustomAPI::TSimAuthenticationBase::EEapSim ==
       
  1406         basePtr->ExtensionId() )
       
  1407         {
       
  1408         iEapSim = REINTERPRET_CAST( RMmCustomAPI::TSimAuthenticationEapSim*,
       
  1409             basePtr );
       
  1410 
       
  1411         rand.Append( iEapSim->iRandomParameters );
       
  1412 
       
  1413         authenticationDataPackage.PackData( iEapSim, &rfStateInfo );
       
  1414         }
       
  1415     else if ( RMmCustomAPI::TSimAuthenticationBase::EEapAka ==
       
  1416         basePtr->ExtensionId() )
       
  1417         {
       
  1418         iEapAka = REINTERPRET_CAST( RMmCustomAPI::TSimAuthenticationEapAka*,
       
  1419             basePtr );
       
  1420 
       
  1421         rand.Append( iEapAka->iRandomParameters );
       
  1422 
       
  1423         authenticationDataPackage.PackData( iEapAka, &rfStateInfo );
       
  1424         }
       
  1425     else if ( RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrap ==
       
  1426         basePtr->ExtensionId() )
       
  1427         {
       
  1428 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::in EGbaBootstrap" );
       
  1429         iGbaBootstrap = REINTERPRET_CAST( 
       
  1430 	        RMmCustomAPI::TSimAuthenticationGbaBootstrap*, basePtr );
       
  1431 
       
  1432         rand.Append( iGbaBootstrap->iRandomParameters );
       
  1433 
       
  1434         authenticationDataPackage.PackData( iGbaBootstrap, &rfStateInfo  ); 
       
  1435 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::out EGbaBootstrap" ); 
       
  1436         }
       
  1437     else if ( RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapUpdate ==
       
  1438         basePtr->ExtensionId() )
       
  1439         {
       
  1440 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::in EGbaBootstrapUpdate" );
       
  1441         iGbaBootstrapUpdate = REINTERPRET_CAST( 
       
  1442         	RMmCustomAPI::TSimAuthenticationGbaBootstrapUpdate*, basePtr );
       
  1443 
       
  1444         authenticationDataPackage.PackData( iGbaBootstrapUpdate, &rfStateInfo  ); 
       
  1445 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::out EGbaBootstrapUpdate" ); 
       
  1446         }
       
  1447     else if ( 
       
  1448         RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapNafDerivation ==
       
  1449         basePtr->ExtensionId() )
       
  1450         {
       
  1451 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::in EGbaBootstrapNafDerivation" );
       
  1452         iGbaNafDerivation = REINTERPRET_CAST( 
       
  1453         	RMmCustomAPI::TSimAuthenticationGbaNafDerivation*, basePtr );
       
  1454 
       
  1455         authenticationDataPackage.PackData( iGbaNafDerivation, &rfStateInfo  ); 
       
  1456 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::out EGbaBootstrapNafDerivation" );
       
  1457         }
       
  1458     else if ( RMmCustomAPI::TSimAuthenticationBase::EMgvMskUpdate ==
       
  1459         basePtr->ExtensionId() )
       
  1460         {
       
  1461 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::in EMgvMskUpdate" );  
       
  1462         iMgvMskUpdate = REINTERPRET_CAST( 
       
  1463         	RMmCustomAPI::TSimAuthenticationMgvMskUpdate*, basePtr );
       
  1464 
       
  1465         authenticationDataPackage.PackData( iMgvMskUpdate, &rfStateInfo  ); 
       
  1466 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::out EMgvMskUpdate" );
       
  1467         }
       
  1468     else if ( RMmCustomAPI::TSimAuthenticationBase::EMgvMtkGeneration ==
       
  1469         basePtr->ExtensionId() )
       
  1470         {
       
  1471 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::in EMgvMtkGeneration" );
       
  1472         iMgvMtkGeneration = REINTERPRET_CAST( 
       
  1473         	RMmCustomAPI::TSimAuthenticationMgvMtkGeneration*, basePtr );
       
  1474 
       
  1475         authenticationDataPackage.PackData( iMgvMtkGeneration, &rfStateInfo  ); 
       
  1476 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::out EMgvMtkGeneration" );
       
  1477         }
       
  1478     else if ( RMmCustomAPI::TSimAuthenticationBase::EMgvMskDeletion ==
       
  1479         basePtr->ExtensionId() )
       
  1480         {
       
  1481 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::in EMgvMskDeletion" );
       
  1482         iMgvMskDeletion = REINTERPRET_CAST( 
       
  1483         	RMmCustomAPI::TSimAuthenticationMgvMskDeletion*, basePtr );
       
  1484 
       
  1485         authenticationDataPackage.PackData( iMgvMskDeletion, &rfStateInfo  ); 
       
  1486 TFLOGSTRING( "CMmCustomTSY: SimAuthenticationL::out EMgvMskDeletion" ); 
       
  1487         }
       
  1488     else
       
  1489         {
       
  1490 TFLOGSTRING2( "CMmCustomTSY: Invalid authentication type specified: %d", basePtr->ExtensionId() );
       
  1491         ret = KErrNotSupported;
       
  1492 
       
  1493         iEapSim = NULL;
       
  1494         iEapAka = NULL;
       
  1495 		iGbaBootstrap = NULL;
       
  1496 		iGbaBootstrapUpdate = NULL;
       
  1497 		iGbaNafDerivation = NULL;
       
  1498 		iMgvMskUpdate = NULL;
       
  1499 		iMgvMtkGeneration = NULL;
       
  1500 		iMgvMskDeletion = NULL;
       
  1501 
       
  1502         //ReqCompleted( aTsyReqHandle, ret );
       
  1503         }
       
  1504 
       
  1505     // Check if Rand received from network is valid
       
  1506     // when if basePtr has ExtensionId of EEapSim or EEapAka
       
  1507     if ( RMmCustomAPI::TSimAuthenticationBase::EEapSim ==
       
  1508         basePtr->ExtensionId() || RMmCustomAPI::TSimAuthenticationBase::
       
  1509         EEapAka == basePtr->ExtensionId())/* || RMmCustomAPI::
       
  1510         TSimAuthenticationBase::EGbaBootstrap == basePtr->ExtensionId())*/
       
  1511 	    {
       
  1512 		ret =  CheckRandValidityL( rand );
       
  1513 	    }
       
  1514       
       
  1515     if ( KErrNone == ret )
       
  1516        {
       
  1517        ret = ( iMmPhoneTsy->MessageManager()->HandleRequestL(
       
  1518            ECustomGetSimAuthenticationDataIPC, &authenticationDataPackage ) );
       
  1519 
       
  1520        // check result
       
  1521        if ( KErrNone == ret )
       
  1522            {
       
  1523            // Save the req handle type
       
  1524            iReqHandleType = ECustomTsyGetSimAuthenticationData;
       
  1525            }
       
  1526        else
       
  1527            {
       
  1528            iEapSim = NULL;
       
  1529            iEapAka = NULL;
       
  1530 		   iGbaBootstrap = NULL;
       
  1531 	       iGbaBootstrapUpdate = NULL;
       
  1532 		   iGbaNafDerivation = NULL;
       
  1533 		   iMgvMskUpdate = NULL;
       
  1534 		   iMgvMtkGeneration = NULL;
       
  1535 		   iMgvMskDeletion = NULL;
       
  1536 
       
  1537            ReqCompleted( aTsyReqHandle, ret );
       
  1538            }
       
  1539        }
       
  1540     else
       
  1541         {
       
  1542         iEapSim = NULL;
       
  1543         iEapAka = NULL;
       
  1544 		iGbaBootstrap = NULL;
       
  1545 		iGbaBootstrapUpdate = NULL;
       
  1546 		iGbaNafDerivation = NULL;
       
  1547 		iMgvMskUpdate = NULL;
       
  1548 		iMgvMtkGeneration = NULL;
       
  1549 		iMgvMskDeletion = NULL;
       
  1550 
       
  1551         ReqCompleted( aTsyReqHandle, ret );
       
  1552         }
       
  1553 
       
  1554     return KErrNone;
       
  1555     }
       
  1556 
       
  1557 // ---------------------------------------------------------------------------
       
  1558 // CMmCustomTsy::CompleteSimAuthentication
       
  1559 // Completes sim authenticaiton request
       
  1560 // (other items were commented in a header).
       
  1561 // ---------------------------------------------------------------------------
       
  1562 //
       
  1563 void CMmCustomTsy::CompleteSimAuthentication(
       
  1564     CMmDataPackage* aDataPackage,
       
  1565     TInt aResult )
       
  1566     {
       
  1567 TFLOGSTRING( "TSY: CMmCustomTsy::CompleteSimAuthentication" );
       
  1568     // reset req handle. Returns the deleted req handle
       
  1569     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  1570         ECustomTsyGetSimAuthenticationData );
       
  1571 
       
  1572     if ( KErrNone == aResult )
       
  1573         {
       
  1574         if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  1575             {
       
  1576             RMmCustomAPI::TSimAuthenticationBase* basePtr;
       
  1577             aDataPackage->UnPackData( &basePtr );
       
  1578 
       
  1579             // if 2G authentication needs to be completed
       
  1580             if ( RMmCustomAPI::TSimAuthenticationBase::EEapSim ==
       
  1581                 basePtr->ExtensionId() )
       
  1582                 {
       
  1583                 RMmCustomAPI::TSimAuthenticationEapSim* eapSim;
       
  1584 
       
  1585                 aDataPackage->UnPackData( &eapSim );
       
  1586 
       
  1587                 // Copy data to client
       
  1588                 iEapSim->iSRES.Copy( eapSim->iSRES );
       
  1589                 iEapSim->iKC.Copy( eapSim->iKC );
       
  1590 
       
  1591                 iEapSim = NULL;
       
  1592 
       
  1593                 ReqCompleted( reqHandle, aResult );
       
  1594                 }
       
  1595             // if 3G authentication needs to be completed
       
  1596             else if ( RMmCustomAPI::TSimAuthenticationBase::EEapAka ==
       
  1597                 basePtr->ExtensionId() )
       
  1598                 {
       
  1599                 RMmCustomAPI::TSimAuthenticationEapAka* eapAka;
       
  1600 
       
  1601                 aDataPackage->UnPackData( &eapAka );
       
  1602 
       
  1603                 // Copy data to client
       
  1604                 iEapAka->iRES.Copy( eapAka->iRES );
       
  1605                 iEapAka->iCK.Copy( eapAka->iCK );
       
  1606                 iEapAka->iIK.Copy( eapAka->iIK );
       
  1607 
       
  1608                 iEapAka = NULL;
       
  1609 
       
  1610                 ReqCompleted( reqHandle, aResult );
       
  1611                 }
       
  1612             else if ( RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrap ==
       
  1613                 basePtr->ExtensionId() )
       
  1614                 {
       
  1615 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::in EGbaBootstrap" );
       
  1616                 RMmCustomAPI::TSimAuthenticationGbaBootstrap* gbaBootstrap;
       
  1617 
       
  1618                 aDataPackage->UnPackData( &gbaBootstrap );
       
  1619 
       
  1620                 // Copy data to client
       
  1621                 iGbaBootstrap->iRES.Copy( gbaBootstrap->iRES );
       
  1622                 iGbaBootstrap->iAUTS.Copy( gbaBootstrap->iAUTS );
       
  1623 
       
  1624                 iGbaBootstrap = NULL;
       
  1625 
       
  1626                 ReqCompleted( reqHandle, aResult );
       
  1627 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::out EGbaBootstrap" );
       
  1628                 }
       
  1629             else if ( 
       
  1630                 RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrapUpdate ==
       
  1631                 basePtr->ExtensionId() )
       
  1632                 {
       
  1633 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::in EGbaBootstrapUpdate" );                
       
  1634                 RMmCustomAPI::TSimAuthenticationGbaBootstrapUpdate* 
       
  1635                     gbaBootstrapUpdate;
       
  1636 
       
  1637                 aDataPackage->UnPackData( &gbaBootstrapUpdate );
       
  1638 
       
  1639                 // Copy data to client
       
  1640                 iGbaBootstrapUpdate->iRandomParameters.Copy( 
       
  1641                     gbaBootstrapUpdate->iRandomParameters );
       
  1642 
       
  1643                 iGbaBootstrapUpdate = NULL;
       
  1644 
       
  1645                 ReqCompleted( reqHandle, aResult );
       
  1646 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::out EGbaBootstrapUpdate" );
       
  1647                 }
       
  1648             else if ( 
       
  1649                 RMmCustomAPI::TSimAuthenticationBase::
       
  1650                     EGbaBootstrapNafDerivation == basePtr->ExtensionId() )
       
  1651                 {
       
  1652 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::in EGbaBootstrapNafDerivation" );                
       
  1653                 RMmCustomAPI::TSimAuthenticationGbaNafDerivation* 
       
  1654                     gbaNafDerivation;
       
  1655 
       
  1656                 aDataPackage->UnPackData( &gbaNafDerivation );
       
  1657 
       
  1658                 // Copy data to client
       
  1659                 iGbaNafDerivation->iKsExtNaf.Copy( 
       
  1660                     gbaNafDerivation->iKsExtNaf );
       
  1661 
       
  1662                 iGbaNafDerivation = NULL;
       
  1663 
       
  1664                 ReqCompleted( reqHandle, aResult );
       
  1665 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::out EGbaBootstrapNafDerivation" );                
       
  1666                 }
       
  1667             else if ( RMmCustomAPI::TSimAuthenticationBase::EMgvMskUpdate ==
       
  1668                     basePtr->ExtensionId() )
       
  1669                 {
       
  1670 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::in EMgvMskUpdate" );                
       
  1671                 RMmCustomAPI::TSimAuthenticationMgvMskUpdate* mgvMskUpdate;
       
  1672 
       
  1673                 aDataPackage->UnPackData( &mgvMskUpdate );
       
  1674 
       
  1675                 // Copy data to client
       
  1676                 iMgvMskUpdate->iMikey.Copy( mgvMskUpdate->iMikey );
       
  1677                 // Smartcard support for MobileTV
       
  1678                 iMgvMskUpdate->iBCASTManagement.Copy( mgvMskUpdate->iBCASTManagement );
       
  1679                 iMgvMskUpdate->iParentalRating.Copy( mgvMskUpdate->iParentalRating );
       
  1680                 iMgvMskUpdate->iSecurityPolicyExt.Copy( mgvMskUpdate->iSecurityPolicyExt );
       
  1681                                
       
  1682                 iMgvMskUpdate = NULL;
       
  1683 
       
  1684                 ReqCompleted( reqHandle, aResult );
       
  1685 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::out EMgvMskUpdate" );
       
  1686                 }
       
  1687             else if ( RMmCustomAPI::TSimAuthenticationBase::
       
  1688                     EMgvMtkGeneration == basePtr->ExtensionId() )
       
  1689                 {
       
  1690 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::in EMgvMtkGeneration" );                
       
  1691                 RMmCustomAPI::TSimAuthenticationMgvMtkGeneration* 
       
  1692                     mgvMtkGeneration;
       
  1693 
       
  1694                 aDataPackage->UnPackData( &mgvMtkGeneration );
       
  1695 
       
  1696                 // Copy data to client
       
  1697                 iMgvMtkGeneration->iMtkSalt.Copy( mgvMtkGeneration->iMtkSalt );
       
  1698                 // Smartcard support for MobileTV
       
  1699                 iMgvMtkGeneration->iBCASTManagement.Copy( mgvMtkGeneration->iBCASTManagement );
       
  1700                 iMgvMtkGeneration->iParentalControl.Copy( mgvMtkGeneration->iParentalControl );
       
  1701                 iMgvMtkGeneration->iTrafficEncryptionKey.Copy( mgvMtkGeneration->iTrafficEncryptionKey );
       
  1702                 iMgvMtkGeneration = NULL;
       
  1703 
       
  1704                 ReqCompleted( reqHandle, aResult );
       
  1705 TFLOGSTRING( "CMmCustomTSY: CompleteSimAuthentication::out EMgvMtkGeneration" ); 
       
  1706                 }
       
  1707             else if ( RMmCustomAPI::TSimAuthenticationBase::
       
  1708                     EMgvMskDeletion == basePtr->ExtensionId() )
       
  1709                 {
       
  1710                 ReqCompleted( reqHandle, aResult );
       
  1711                 }
       
  1712             else
       
  1713                 {
       
  1714 TFLOGSTRING2( "CMmCustomTSY: Invalid authentication type specified: %d", basePtr->ExtensionId() );
       
  1715                 aResult = KErrArgument;
       
  1716                 ReqCompleted( reqHandle, aResult );
       
  1717                 }
       
  1718             }
       
  1719         }
       
  1720     else if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  1721         {
       
  1722         if ( KErrTimedOut == aResult )
       
  1723             {
       
  1724             iEapSim = NULL;
       
  1725             iEapAka = NULL;
       
  1726             }
       
  1727         else
       
  1728             {
       
  1729             RMmCustomAPI::TSimAuthenticationBase* basePtr;
       
  1730             aDataPackage->UnPackData( &basePtr );
       
  1731 
       
  1732             // if no datapackage is received in error response
       
  1733             if ( NULL == basePtr )
       
  1734                 {
       
  1735                 iEapAka = NULL;
       
  1736                 iEapSim = NULL;
       
  1737                 }
       
  1738             else
       
  1739                 {
       
  1740                 // if 3G authentication needs to be completed
       
  1741                 // copy AUTS sequence to client
       
  1742                 if ( RMmCustomAPI::TSimAuthenticationBase::EEapAka ==
       
  1743                         basePtr->ExtensionId() )
       
  1744                     {
       
  1745                     RMmCustomAPI::TSimAuthenticationEapAka* eapAka;
       
  1746                     aDataPackage->UnPackData( &eapAka );
       
  1747 
       
  1748                     iEapAka->iAUTS.Copy( eapAka->iAUTS );
       
  1749 
       
  1750                     iEapAka = NULL;
       
  1751                     }
       
  1752                 
       
  1753                 else if( RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrap ==
       
  1754                         basePtr->ExtensionId() )
       
  1755                     {
       
  1756 TFLOGSTRING( "TSYMH: CompleteSimAuthentication RMmCustomAPI::TSimAuthenticationBase::EGbaBootstrap" );
       
  1757                     RMmCustomAPI::TSimAuthenticationGbaBootstrap* gbabootstrap;
       
  1758                     aDataPackage->UnPackData( &gbabootstrap );
       
  1759 
       
  1760                     iGbaBootstrap->iAUTS.Copy( gbabootstrap->iAUTS );
       
  1761                     }
       
  1762                     
       
  1763                 iEapSim = NULL;
       
  1764                 }
       
  1765             }
       
  1766 
       
  1767 	    // reset pointer to client data
       
  1768 		iGbaBootstrap = NULL;
       
  1769 		iGbaBootstrapUpdate = NULL;
       
  1770 		iMgvMskUpdate = NULL;
       
  1771 		iMgvMtkGeneration = NULL;
       
  1772 		iMgvMskDeletion = NULL;
       
  1773         ReqCompleted( reqHandle, aResult );
       
  1774         }
       
  1775     }
       
  1776 
       
  1777 // ---------------------------------------------------------------------------
       
  1778 // CMmCustomTsy::SimAuthenticationCancel
       
  1779 // Cancels sim authentication request
       
  1780 // (other items were commented in a header).
       
  1781 // ---------------------------------------------------------------------------
       
  1782 //
       
  1783 TInt CMmCustomTsy::SimAuthenticationCancel()
       
  1784     {
       
  1785     // reset the reqhandle
       
  1786     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  1787         ECustomTsyGetSimAuthenticationData );
       
  1788 
       
  1789     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  1790 	    {
       
  1791 	    // reset pointer to client data
       
  1792 	    iEapSim = NULL;
       
  1793 	    iEapAka = NULL;
       
  1794 		iGbaBootstrap = NULL;
       
  1795 		iGbaBootstrapUpdate = NULL;
       
  1796 		iMgvMskUpdate = NULL;
       
  1797 		iMgvMtkGeneration = NULL;
       
  1798 		iMgvMskDeletion = NULL;
       
  1799 		
       
  1800 	    // complete
       
  1801         ReqCompleted( reqHandle, KErrCancel );
       
  1802 
       
  1803         }
       
  1804 
       
  1805     return KErrNone;
       
  1806     }
       
  1807 
       
  1808 // ---------------------------------------------------------------------------
       
  1809 // CMmCustomTsy::CheckRandValidityL
       
  1810 // Checks if rand received from network is valid
       
  1811 // (other items were commented in a header).
       
  1812 // ---------------------------------------------------------------------------
       
  1813 //
       
  1814 TInt CMmCustomTsy::CheckRandValidityL(
       
  1815     TBuf8<16> aRand )
       
  1816     {
       
  1817     TInt ret( KErrNone );
       
  1818 
       
  1819     TDesC8& rand = aRand;
       
  1820 
       
  1821     CSHA1* sha1 = CSHA1::NewL();
       
  1822 
       
  1823     sha1->Reset();
       
  1824 
       
  1825     TPtrC8 messageDigest = sha1->Final( rand );
       
  1826 
       
  1827     ret = FindSetBitsFromBackup( messageDigest );
       
  1828 
       
  1829     // If bits were not found from rand_db.prv or
       
  1830     // if rand_db.prv itself was not found
       
  1831     if ( KErrNone == ret || KErrNotFound == ret )
       
  1832         {
       
  1833         ret = InsertBlobsToRandDb( messageDigest );
       
  1834         }
       
  1835 
       
  1836     delete sha1;
       
  1837     sha1 = NULL;
       
  1838 
       
  1839     if ( KErrArgument == ret && 0 == iFreshBitCounter )
       
  1840        {
       
  1841 TFLOGSTRING( "CMmCustomTsy: RAND rejected" );
       
  1842        }
       
  1843 
       
  1844     return ret;
       
  1845     }
       
  1846 
       
  1847 // ---------------------------------------------------------------------------
       
  1848 // CMmCustomTsy::CreateRandDb
       
  1849 // Creates rand_db.cur
       
  1850 // (other items were commented in a header).
       
  1851 // ---------------------------------------------------------------------------
       
  1852 //
       
  1853 TInt CMmCustomTsy::CreateRandDb()
       
  1854     {
       
  1855     TInt ret = ( KErrNone );
       
  1856 
       
  1857     // local variable initialized to zero
       
  1858     TInt counter = 0;
       
  1859 
       
  1860     // empty tbuf for rand_db initialization
       
  1861     TBuf8<1> empty;
       
  1862     empty.Append( 0 );
       
  1863 
       
  1864     // fileSize is initialized to 2 because of filesize calculation method
       
  1865     TInt fileSize = 2;
       
  1866 
       
  1867     RFs   fs;
       
  1868     RFile file;
       
  1869     
       
  1870     ret = fs.Connect();
       
  1871     
       
  1872     TDriveNumber driveNumber;
       
  1873     driveNumber = fs.GetSystemDrive();
       
  1874     fs.CreatePrivatePath( driveNumber );
       
  1875     fs.SetSessionToPrivate( driveNumber );
       
  1876     
       
  1877     if ( KErrNone == ret )
       
  1878         {
       
  1879         ret = file.Create( fs, KRandDb, EFileShareAny );
       
  1880 
       
  1881         if ( KErrNone != ret )
       
  1882             {
       
  1883 TFLOGSTRING( "TSY: CMmCustomTsy: 'rand_db.cur' creation failed!" );
       
  1884             }
       
  1885         else if ( KErrNone == ret )
       
  1886             {
       
  1887             ret = file.Open( fs, KRandDb, EFileShareAny | EFileWrite );
       
  1888 
       
  1889             if ( KErrNone == ret )
       
  1890                 {
       
  1891                 // calculates how many bits can be addressed with current
       
  1892                 // BLOB_SIZE
       
  1893                 for ( counter = 1; counter < BLOB_SIZE; counter++ )
       
  1894                     {
       
  1895                     fileSize = ( fileSize * 2 );
       
  1896                     }
       
  1897                 // max number of bits is divided by 8 to get the actual
       
  1898                 // filesize
       
  1899                 fileSize = ( fileSize / 8 );
       
  1900 
       
  1901                 ret = file.SetSize( fileSize + METADATA_SIZE );
       
  1902 
       
  1903                 // reset every byte of newly created rand_db to zero
       
  1904                 for ( counter = 0; counter < ( fileSize + METADATA_SIZE );
       
  1905                     counter++ )
       
  1906                     {
       
  1907                     ret = file.Write( counter, empty );
       
  1908                     }
       
  1909 
       
  1910                 if ( KErrNone != ret )
       
  1911                     {
       
  1912 TFLOGSTRING( "TSY: CMmCustomTsy: 'rand_db.cur' initialization failed!" );
       
  1913                     file.Close();
       
  1914                     }
       
  1915                 }
       
  1916             else
       
  1917                 {
       
  1918 TFLOGSTRING( "TSY: CMmCustomTsy: 'rand_db.cur' open failed!" );
       
  1919                 }
       
  1920             }
       
  1921 
       
  1922         if ( KErrNone == ret )
       
  1923             {
       
  1924             file.Close();
       
  1925             fs.Close();
       
  1926             }
       
  1927         else
       
  1928             {
       
  1929             fs.Close();
       
  1930             }
       
  1931         }
       
  1932     else
       
  1933         {
       
  1934 TFLOGSTRING( "TSY: CMmCustomTsy: Could not connect to file server!" );
       
  1935         }
       
  1936 
       
  1937     // Give some time for file.Close() and fs.Close() to complete
       
  1938     User::After( 200000 );
       
  1939 
       
  1940     return ret;
       
  1941     }
       
  1942 
       
  1943 // ---------------------------------------------------------------------------
       
  1944 // CMmCustomTsy::InsertBlobsToRandDb
       
  1945 // Inserts blobs to rand_db.cur
       
  1946 // (other items were commented in a header).
       
  1947 // ---------------------------------------------------------------------------
       
  1948 //
       
  1949 TInt CMmCustomTsy::InsertBlobsToRandDb(
       
  1950     TPtrC8 aMessageDigest )
       
  1951     {
       
  1952     RFs fs;
       
  1953     RFile file;
       
  1954 
       
  1955     TBuf8<1> byteFromRandDb;
       
  1956 
       
  1957     TInt ret = KErrNone;
       
  1958 
       
  1959     // Many local variables initialized to zero
       
  1960     TInt8 counter = 0;
       
  1961     TInt8 counter2 = 0;
       
  1962 
       
  1963     TUint16 hexDigit = 0;
       
  1964     TUint8 blob = 0;
       
  1965     TInt byteNumber = 0;
       
  1966     TInt bit = 0;
       
  1967 
       
  1968     TUint16 assignedBits = 0;
       
  1969     iFreshBitCounter = 0;
       
  1970 
       
  1971     ret = fs.Connect();
       
  1972        
       
  1973     TDriveNumber driveNumber;
       
  1974     driveNumber = fs.GetSystemDrive();
       
  1975     fs.CreatePrivatePath( driveNumber );
       
  1976     fs.SetSessionToPrivate( driveNumber );
       
  1977 
       
  1978     if ( KErrNone == ret )
       
  1979         {
       
  1980         ret = file.Open( fs, KRandDb, EFileShareExclusive | EFileWrite );
       
  1981         if ( KErrNotFound == ret )
       
  1982             {
       
  1983             ret = CreateRandDb();
       
  1984 
       
  1985             if ( KErrNone == ret )
       
  1986                 {
       
  1987                 ret = file.Open( fs, KRandDb, EFileShareExclusive |
       
  1988                     EFileWrite );
       
  1989                 if( KErrNone != ret )
       
  1990                     {
       
  1991 TFLOGSTRING( "TSY: CMmCustomTsy: rand_db open failed" );
       
  1992                     }
       
  1993                 }
       
  1994             if ( KErrNone != ret )
       
  1995                 {
       
  1996                 fs.Close();
       
  1997 
       
  1998                 return ret;
       
  1999                 }
       
  2000             }
       
  2001 
       
  2002         for ( counter = 0; counter < 20; counter++ )
       
  2003             {
       
  2004             // reset loop variables
       
  2005             hexDigit = 0;
       
  2006             assignedBits = 0;
       
  2007 
       
  2008             // read one hexDigit from message digest
       
  2009             hexDigit = static_cast< TUint16 > ( aMessageDigest[counter] );
       
  2010             hexDigit <<= 8;
       
  2011             counter++;
       
  2012             hexDigit |= static_cast< TUint16 > ( aMessageDigest[counter] );
       
  2013 
       
  2014             bit = 1;
       
  2015 
       
  2016             // read as many bits from hexDigit as blobSize indicates
       
  2017             for ( counter2 = 0; counter2 < BLOB_SIZE; counter2++ )
       
  2018                 {
       
  2019                 assignedBits |= bit & hexDigit;
       
  2020                 bit <<= 1;
       
  2021                 }
       
  2022 
       
  2023             byteNumber = ( assignedBits / 8 );
       
  2024             bit = ( assignedBits - ( byteNumber * 8 ) );
       
  2025 
       
  2026             ret = file.Read( byteNumber, byteFromRandDb  );
       
  2027             if( KErrNone != ret )
       
  2028                 {
       
  2029                 break;
       
  2030                 }
       
  2031 
       
  2032             blob = 128;
       
  2033             blob >>= bit;
       
  2034 
       
  2035             // if bit is not already set
       
  2036             if ( !blob == ( blob & byteFromRandDb[0] ) )
       
  2037                 {
       
  2038 
       
  2039                 byteFromRandDb[0] |= blob;
       
  2040 
       
  2041                 ret = file.Write( byteNumber, byteFromRandDb );
       
  2042                 if( KErrNone != ret )
       
  2043                     {
       
  2044                     break;
       
  2045                     }
       
  2046 
       
  2047                 iFreshBitCounter++;
       
  2048                 }
       
  2049             }
       
  2050 
       
  2051         file.Close();
       
  2052         fs.Close();
       
  2053         }
       
  2054     else
       
  2055         {
       
  2056 TFLOGSTRING( "TSY: CMmCustomTsy: Could not connect to file server!" );
       
  2057         return ret;
       
  2058         }
       
  2059 
       
  2060     // if no new bits were found e.g. RAND will be rejected
       
  2061     if ( 0 == iFreshBitCounter )
       
  2062         {
       
  2063         ret = KErrArgument;
       
  2064         }
       
  2065     else
       
  2066         {
       
  2067         ret = UpdateBitCounter();
       
  2068         }
       
  2069 
       
  2070     return ret;
       
  2071     }
       
  2072 
       
  2073 // ---------------------------------------------------------------------------
       
  2074 // CMmCustomTsy::UpdateBitCounter
       
  2075 // Updates bitcounter information on rand_db.cur
       
  2076 // (other items were commented in a header).
       
  2077 // ---------------------------------------------------------------------------
       
  2078 //
       
  2079 TInt CMmCustomTsy::UpdateBitCounter()
       
  2080     {
       
  2081     TInt ret( KErrNone );
       
  2082 
       
  2083     RFs fs;
       
  2084     RFile file;
       
  2085 
       
  2086     TBuf8<2> bitCounterBytes;
       
  2087 
       
  2088     // local varibales initialized to zero
       
  2089     TUint16 bitCounter = 0;
       
  2090     TUint16 temporaryBitCounter = 0;
       
  2091     TInt8 counter = 0;
       
  2092 
       
  2093     // fileSize is initialized to 2 because of filesize calculation method
       
  2094     TInt fileSize = 2;
       
  2095 
       
  2096     ret = fs.Connect();
       
  2097     
       
  2098     TDriveNumber driveNumber;
       
  2099     driveNumber = fs.GetSystemDrive();
       
  2100     fs.CreatePrivatePath( driveNumber );
       
  2101     fs.SetSessionToPrivate( driveNumber );
       
  2102     
       
  2103     if ( KErrNone == ret )
       
  2104         {
       
  2105         ret = file.Open( fs, KRandDb, EFileShareExclusive | EFileWrite );
       
  2106         if ( KErrNone == ret )
       
  2107             {
       
  2108             // calculate filesize
       
  2109             for ( counter = 1; counter < BLOB_SIZE; counter++ )
       
  2110                 {
       
  2111                 fileSize = ( fileSize * 2 );
       
  2112                 }
       
  2113             fileSize = ( fileSize / 8 );
       
  2114 
       
  2115             ret = file.Read( fileSize, bitCounterBytes, 2 );
       
  2116             if ( KErrNone == ret  )
       
  2117                 {
       
  2118                 // read bitcounter info from rand_db
       
  2119                 bitCounter = STATIC_CAST( TUint16, bitCounterBytes[0] );
       
  2120                 bitCounter <<= 8;
       
  2121                 bitCounter |= bitCounterBytes[1];
       
  2122 
       
  2123                 // add fresh bits to bit counter info
       
  2124                 bitCounter += iFreshBitCounter;
       
  2125 
       
  2126                 temporaryBitCounter = bitCounter;
       
  2127                 bitCounterBytes[1] = STATIC_CAST( TUint8,
       
  2128                   temporaryBitCounter );
       
  2129                 temporaryBitCounter >>= 8;
       
  2130                 bitCounterBytes[0] = STATIC_CAST( TUint8,
       
  2131                   temporaryBitCounter );
       
  2132 
       
  2133                 ret = file.Write( fileSize, bitCounterBytes, 2 );
       
  2134 
       
  2135                 // if more than half of the available bits are set
       
  2136                 if ( ( fileSize * 4 ) < bitCounter )
       
  2137                     {
       
  2138                     ret = fs.Delete( KRandDbPrev );
       
  2139 
       
  2140                     if ( KErrNotFound == ret  || KErrNone == ret )
       
  2141                         {
       
  2142                         ret = file.Rename( KRandDbPrev );
       
  2143                         }
       
  2144                     }
       
  2145                 }
       
  2146 
       
  2147             file.Close();
       
  2148             }
       
  2149 
       
  2150         fs.Close();
       
  2151         }
       
  2152     else
       
  2153         {
       
  2154 TFLOGSTRING( "TSY: CMmCustomTsy: Could not connect to file server!" );
       
  2155         }
       
  2156 
       
  2157     return ret;
       
  2158     }
       
  2159 
       
  2160 // ---------------------------------------------------------------------------
       
  2161 // CMmCustomTsy::FindSetBitsFromBackup
       
  2162 // Checks rand_db.prv for set bits
       
  2163 // (other items were commented in a header).
       
  2164 // ---------------------------------------------------------------------------
       
  2165 //
       
  2166 TInt CMmCustomTsy::FindSetBitsFromBackup(
       
  2167     TPtrC8 aMessageDigest )
       
  2168     {
       
  2169     RFs fs;
       
  2170     RFile file;
       
  2171     TBuf8<1> byteFromRandDb;
       
  2172 
       
  2173     TInt ret = KErrNone;
       
  2174 
       
  2175     // Many local variables initialized to zero
       
  2176     TInt8 counter = 0;
       
  2177     TInt8 counter2 = 0;
       
  2178 
       
  2179     TUint16 hexDigit = 0;
       
  2180     TUint8 blob = 0;
       
  2181     TInt byteNumber = 0;
       
  2182     TInt bit = 0;
       
  2183 
       
  2184     TUint16 assignedBits = 0;
       
  2185     iFreshBitCounter = 0;
       
  2186 
       
  2187     ret = fs.Connect();
       
  2188     
       
  2189     TDriveNumber driveNumber;
       
  2190     driveNumber = fs.GetSystemDrive();
       
  2191     fs.CreatePrivatePath( driveNumber );
       
  2192     fs.SetSessionToPrivate( driveNumber );
       
  2193     
       
  2194     if( KErrNone == ret )
       
  2195     {
       
  2196     ret = file.Open( fs, KRandDbPrev, EFileShareAny | EFileRead );
       
  2197 
       
  2198     if ( KErrNone == ret )
       
  2199         {
       
  2200         for ( counter = 0; counter < 20; counter++ )
       
  2201             {
       
  2202             // reset loop variables
       
  2203             hexDigit = 0;
       
  2204             assignedBits = 0;
       
  2205 
       
  2206             // read one hexDigit from message digest
       
  2207             hexDigit = STATIC_CAST( TUint16, aMessageDigest[counter] );
       
  2208             hexDigit <<= 8;
       
  2209             counter++;
       
  2210             hexDigit |= STATIC_CAST( TUint16, aMessageDigest[counter] );
       
  2211 
       
  2212             // Initialize bit to 1
       
  2213             bit = 1;
       
  2214 
       
  2215             // read as many bits from hexDigit as blobSize indicates
       
  2216             for ( counter2 = 0; counter2 < BLOB_SIZE; counter2++ )
       
  2217                 {
       
  2218                 assignedBits |= bit & hexDigit;
       
  2219                 bit <<= 1;
       
  2220                 }
       
  2221 
       
  2222             // calculate the byte and bit to be read from rand_db backup
       
  2223             byteNumber = ( assignedBits / 8 );
       
  2224             bit = ( assignedBits - ( byteNumber * 8 ) );
       
  2225 
       
  2226             ret = file.Read( byteNumber, byteFromRandDb );
       
  2227             if ( KErrNone != ret )
       
  2228                 {
       
  2229                 break;
       
  2230                 }
       
  2231 
       
  2232             // Initialize blob to 10000000
       
  2233             blob = 128;
       
  2234             blob >>= bit;
       
  2235 
       
  2236             // if bit is not found from old db
       
  2237             if ( !blob == ( blob & byteFromRandDb[0] ) )
       
  2238                 {
       
  2239                 iFreshBitCounter++;
       
  2240 
       
  2241                 file.Close();
       
  2242                 fs.Close();
       
  2243 
       
  2244                 return ret;
       
  2245                 }
       
  2246             }
       
  2247 
       
  2248         file.Close();
       
  2249         fs.Close();
       
  2250 
       
  2251         if ( 0 == iFreshBitCounter )
       
  2252             {
       
  2253             ret = KErrArgument;
       
  2254             }
       
  2255         else
       
  2256             {
       
  2257             ret = KErrNone;
       
  2258             }
       
  2259         }
       
  2260 
       
  2261     if ( KErrNotFound == ret )
       
  2262         {
       
  2263         fs.Close();
       
  2264         }
       
  2265     }
       
  2266 
       
  2267     return ret;
       
  2268     }
       
  2269 
       
  2270 // ---------------------------------------------------------------------------
       
  2271 // CMmCustomTsy::TerminateCallL
       
  2272 // This method is used for terminating a call or all calls.
       
  2273 // (other items were commented in a header).
       
  2274 // ---------------------------------------------------------------------------
       
  2275 //
       
  2276 TInt CMmCustomTsy::TerminateCallL(
       
  2277     const TTsyReqHandle aTsyReqHandle,
       
  2278     const TName* aCallName )
       
  2279     {
       
  2280     // set return value to KErrNotFound
       
  2281     TInt ret( KErrNotFound );
       
  2282 
       
  2283     TTsyReqHandle terminateCallHandle =
       
  2284         iTsyReqHandleStore->GetTsyReqHandle( ECustomTsyTerminateCall );
       
  2285 
       
  2286     if ( 0 < terminateCallHandle )
       
  2287         {
       
  2288         //The request is already in processing because of previous request
       
  2289         //Complete request with status value informing the client about
       
  2290         //the situation.
       
  2291         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  2292         }
       
  2293     else
       
  2294         {
       
  2295         // Cases are:
       
  2296         // if parameter is ALL_CALLS
       
  2297         //     if any active or held call exists
       
  2298         //         hangup active and held calls
       
  2299         //     else
       
  2300         //         complete with KErrNone
       
  2301         // else (parameter is single call)
       
  2302         //     if call exists
       
  2303         //         hangup call
       
  2304         //     else
       
  2305         //         complete with KErrNotFound
       
  2306         //
       
  2307 
       
  2308         // call id
       
  2309         TInt callId = -1;
       
  2310 
       
  2311         // indicates if this is called in an error situation (ETrue)
       
  2312         // or by user request (EFalse);
       
  2313         TBool isError = EFalse;
       
  2314 
       
  2315         // terminate all calls
       
  2316         // CompareF returns 0 if names are equal
       
  2317         if ( 0 == aCallName->CompareF( KTerminateAllCalls ) )
       
  2318             {
       
  2319             CMmCallTsy* activeCall =
       
  2320                 iMmPhoneTsy->CallList()->GetMmCallByStatus(
       
  2321                     RMobileCall::EStatusConnected );
       
  2322             CMmCallTsy* heldCall =
       
  2323                 iMmPhoneTsy->CallList()->GetMmCallByStatus(
       
  2324                     RMobileCall::EStatusHold );
       
  2325             CMmCallTsy* connectingCall =
       
  2326                 iMmPhoneTsy->CallList()->GetMmCallByStatus(
       
  2327                     RMobileCall::EStatusDialling );
       
  2328             if ( NULL == connectingCall )
       
  2329                 {
       
  2330                 connectingCall =
       
  2331                 iMmPhoneTsy->CallList()->GetMmCallByStatus(
       
  2332                     RMobileCall::EStatusConnecting );
       
  2333                 }
       
  2334 
       
  2335             if ( activeCall || heldCall || connectingCall )
       
  2336                 {
       
  2337                 // Let's have negative or zero mean "all active and held calls
       
  2338                 // and the call id given by taking absolute value of
       
  2339                 // parameter" as we need to somehow pass alerting call id,
       
  2340                 // which is neither active or held call..
       
  2341                 callId = ( NULL != connectingCall ) ?
       
  2342                     -TInt( connectingCall->CallId() ) : ( 0 );
       
  2343                 CMmDataPackage dataPackage;
       
  2344                 dataPackage.PackData( &callId, &isError );
       
  2345                 ret = iMmPhoneTsy->MessageManager()->HandleRequestL(
       
  2346                     ECustomTerminateCallIPC, &dataPackage );
       
  2347                 }
       
  2348             else
       
  2349                 {
       
  2350                 ReqCompleted( aTsyReqHandle, KErrNone );
       
  2351                 // return immediately, otherwise KErrNone would cause the
       
  2352                 // request handle to be saved!
       
  2353                 return KErrNone;
       
  2354                 }
       
  2355             }
       
  2356         // terminate call by name
       
  2357         else
       
  2358             {
       
  2359             // change the cause value, a specific call termination is called
       
  2360             // when error has ocurred
       
  2361             isError = ETrue;
       
  2362 
       
  2363             // get call object by name
       
  2364             CMmCallTsy* namedCall =
       
  2365                 iMmPhoneTsy->CallList()->GetMmCallByName( aCallName );
       
  2366 
       
  2367             // get call ID
       
  2368             if ( namedCall )
       
  2369                 {
       
  2370                 callId = namedCall->CallId();
       
  2371                 CMmDataPackage dataPackage;
       
  2372                 dataPackage.PackData( &callId, &isError );
       
  2373                 ret = iMmPhoneTsy->MessageManager()->HandleRequestL(
       
  2374                     ECustomTerminateCallIPC, &dataPackage );
       
  2375                 }
       
  2376             }
       
  2377 
       
  2378         if ( KErrNone != ret )
       
  2379             {
       
  2380             // request failed, complete with error value
       
  2381             ReqCompleted( aTsyReqHandle, ret );
       
  2382             }
       
  2383         else
       
  2384             {
       
  2385             // Store the request handle
       
  2386             iReqHandleType = ECustomTsyTerminateCall;
       
  2387             }
       
  2388         }
       
  2389 
       
  2390     return KErrNone;
       
  2391     }
       
  2392 
       
  2393 // ---------------------------------------------------------------------------
       
  2394 // CMmCustomTsy::CompleteTerminateCall
       
  2395 // This method completes a TerminateCall or a DialCancel request.
       
  2396 // (other items were commented in a header).
       
  2397 // ---------------------------------------------------------------------------
       
  2398 //
       
  2399 void CMmCustomTsy::CompleteTerminateCall(
       
  2400     TInt aError )
       
  2401     {
       
  2402 TFLOGSTRING2( "TSY: CMmCustomTsy::CompleteTerminateCall - aError: %d", aError );
       
  2403 
       
  2404     // reset req handle. Returns the deleted req handle
       
  2405     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  2406         ECustomTsyTerminateCall );
       
  2407 
       
  2408     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  2409         {
       
  2410         // complete the request with reqhandle and aError
       
  2411         ReqCompleted( reqHandle, aError );
       
  2412         }
       
  2413     // Set 3rd party Dial check number to EFalse  
       
  2414     iISVDialNumberCheck = EFalse;    
       
  2415     }
       
  2416 
       
  2417 // ---------------------------------------------------------------------------
       
  2418 // CMmCustomTsy::NotifyDtmfEvent
       
  2419 // This method allows a client to be notified when the DTMF phase of a call
       
  2420 // has begun and completed
       
  2421 // (other items were commented in a header).
       
  2422 // ---------------------------------------------------------------------------
       
  2423 //
       
  2424 TInt CMmCustomTsy::NotifyDtmfEvent(
       
  2425         RMmCustomAPI::TDtmfInfo* aInfo )
       
  2426     {
       
  2427 TFLOGSTRING("TSY: CMmCustomTsy::NotifyDtmfEvent");
       
  2428     // save pointer to client data
       
  2429     iNotifyInfo = aInfo;
       
  2430 
       
  2431     // save handle type
       
  2432     iReqHandleType = ECustomTsyNotifyDtmfEvent;
       
  2433 
       
  2434     return KErrNone;
       
  2435     }
       
  2436 
       
  2437 // ---------------------------------------------------------------------------
       
  2438 // CMmCustomTsy::CompleteNotifyDtmfEvent
       
  2439 // Completes a NotifyDtmfEvent request.
       
  2440 // (other items were commented in a header).
       
  2441 // ---------------------------------------------------------------------------
       
  2442 //
       
  2443 void CMmCustomTsy::CompleteNotifyDtmfEvent(
       
  2444     RMmCustomAPI::TDtmfInfo aInfo,
       
  2445     TInt aErrorCode )
       
  2446     {
       
  2447 TFLOGSTRING("TSY: CMmCustomTsy::CompleteNotifyDtmfEvent");
       
  2448     // reset request handle. Returns the deleted req handle.
       
  2449     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  2450         ECustomTsyNotifyDtmfEvent );
       
  2451 
       
  2452     // check if request was called
       
  2453     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  2454         {
       
  2455         // check if response was ok
       
  2456         if ( KErrNone == aErrorCode )
       
  2457             {
       
  2458             // set the information for the client
       
  2459             *iNotifyInfo= aInfo;
       
  2460             }
       
  2461 
       
  2462         // reset the internal variable
       
  2463         iNotifyInfo = NULL;
       
  2464         // complete
       
  2465         ReqCompleted( reqHandle, aErrorCode );
       
  2466         }
       
  2467     }
       
  2468 
       
  2469 // ---------------------------------------------------------------------------
       
  2470 // CMmCustomTsy::NotifyDtmfEventCancel
       
  2471 // This method cancels an outstanding notification of dtmf event, placed with
       
  2472 // the NotifyDtmfEvent function.
       
  2473 // (other items were commented in a header).
       
  2474 // ---------------------------------------------------------------------------
       
  2475 //
       
  2476 TInt CMmCustomTsy::NotifyDtmfEventCancel(
       
  2477     const TTsyReqHandle aTsyReqHandle )
       
  2478     {
       
  2479     // reset pointer to client data
       
  2480     iNotifyInfo = NULL;
       
  2481 
       
  2482     // reset reqhandle
       
  2483     iTsyReqHandleStore->ResetTsyReqHandle( ECustomTsyNotifyDtmfEvent );
       
  2484 
       
  2485     // complete with KErrCancel
       
  2486     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  2487 
       
  2488     return KErrNone;
       
  2489     }
       
  2490 
       
  2491 // ---------------------------------------------------------------------------
       
  2492 // CMmCustomTsy::GetDiagnosticInfo
       
  2493 // This function gets the SS diagnostic info (octets) of a call object.
       
  2494 // (other items were commented in a header).
       
  2495 // ---------------------------------------------------------------------------
       
  2496 //
       
  2497 TInt CMmCustomTsy::GetDiagnosticInfo(
       
  2498     const TTsyReqHandle aTsyReqHandle,
       
  2499     TName* aCallName )
       
  2500     {
       
  2501     TInt errorValue = KErrNone;
       
  2502     // get call object by name
       
  2503     CMmCallTsy* mmCall = iMmPhoneTsy->CallList()->GetMmCallByName(
       
  2504       aCallName );
       
  2505 
       
  2506     // if call exists
       
  2507     if ( mmCall )
       
  2508         {
       
  2509         TUint8 diags = mmCall->GetDiagnostics();
       
  2510         //gets diagnostic value - check value -  return error code
       
  2511 
       
  2512         if ( 0 != diags )
       
  2513             {
       
  2514 TFLOGSTRING3( "TSY:CMmCustomTsy::GetDiagnosticInfo: Diagnostic info=%d asked for call id=%d", diags, mmCall->CallId() );
       
  2515             switch ( diags )
       
  2516                 {                
       
  2517                 case KDiagnosticInfoBarredWithCUG:
       
  2518                     errorValue = KErrDiagnosticInfoBarredWithCUG;
       
  2519                     break;
       
  2520                 case KDiagnosticInfoBarredNoCUG:
       
  2521                     errorValue = KErrDiagnosticInfoBarredNoCUG; 
       
  2522                     break;
       
  2523                 case KDiagnosticInfoBarredUnknownCUG:
       
  2524                     errorValue = KErrDiagnosticInfoBarredUnknownCUG;
       
  2525                     break;
       
  2526                 case KDiagnosticInfoBarredIncompatibleCUG:
       
  2527                     errorValue = KErrDiagnosticInfoBarredIncompatibleCUG;
       
  2528                     break;
       
  2529                 case KDiagnosticInfoBarredFailureCUG:
       
  2530                     errorValue = KErrDiagnosticInfoBarredFailureCUG;
       
  2531                     break;
       
  2532                 case KDiagnosticInfoBarredClirNotSubscribed:
       
  2533                     errorValue = KErrDiagnosticInfoBarredClirNotSubscribed;
       
  2534                     break;   
       
  2535                 case KDiagnosticInfoBarredCCBSPossible:
       
  2536                     errorValue = KErrDiagnosticInfoBarredCCBSPossible;
       
  2537                     break; 
       
  2538                 case KDiagnosticInfoBarredCCBSNotPossible:
       
  2539                     errorValue = KErrDiagnosticInfoBarredCCBSNotPossible;
       
  2540                     break;
       
  2541                 default:
       
  2542                     errorValue = KErrNone;
       
  2543                     break;
       
  2544                 }
       
  2545             }
       
  2546 TFLOGSTRING2( "TSY: CMmCustomTsy::GetDiagnosticInfo - ReqCompleted - Error code: %d", errorValue );
       
  2547         // complete errorvalue to client  - inform change  
       
  2548         ReqCompleted( aTsyReqHandle, errorValue ); 
       
  2549         }
       
  2550     else
       
  2551         {
       
  2552          // call is not found
       
  2553 TFLOGSTRING("TSY: CMmCustomTsy::GetDiagnosticInfo - Call is not found");
       
  2554         ReqCompleted( aTsyReqHandle, KErrNotFound );
       
  2555         }
       
  2556 TFLOGSTRING2( "TSY: CMmCustomTsy::GetDiagnosticInfo - Error code: %d", errorValue );
       
  2557    
       
  2558     return KErrNone;
       
  2559     }
       
  2560 
       
  2561 // ---------------------------------------------------------------------------
       
  2562 // CMmCustomTsy::CompleteGetDiagnosticOctects
       
  2563 // This function sets the SS diagnostic octets of a call object when received
       
  2564 // from DOS.
       
  2565 // (other items were commented in a header).
       
  2566 // ---------------------------------------------------------------------------
       
  2567 //
       
  2568 void CMmCustomTsy::CompleteGetDiagnosticOctects(
       
  2569     TInt aCallId,
       
  2570     TUint8 aDiags )
       
  2571     {
       
  2572     // get call object by id
       
  2573     CMmCallTsy* mmCall = iMmPhoneTsy->CallList()->GetMmCallById( aCallId );
       
  2574 
       
  2575     // if call exists, set diagnostics
       
  2576     if ( mmCall )
       
  2577         {
       
  2578         mmCall->SetDiagnostics( aDiags );
       
  2579         }
       
  2580     }
       
  2581 
       
  2582 // ---------------------------------------------------------------------------
       
  2583 // CMmCustomTsy::GetRemoteAlertingToneStatus
       
  2584 // This function returns the remote alerting tone status.
       
  2585 // (other items were commented in a header).
       
  2586 // ---------------------------------------------------------------------------
       
  2587 //
       
  2588 TInt CMmCustomTsy::GetRemoteAlertingToneStatus(
       
  2589     const TTsyReqHandle aTsyReqHandle,
       
  2590     RMmCustomAPI::TRemoteAlertingToneStatus* aToneStatus )
       
  2591     {
       
  2592 TFLOGSTRING("TSY: CMmCustomTsy::GetRemoteAlertingToneStatus");
       
  2593     TInt ret = iMmCustomExtInterface->GetRemoteAlertingToneStatus(
       
  2594         aToneStatus );
       
  2595 
       
  2596     ReqCompleted( aTsyReqHandle, ret );
       
  2597 
       
  2598     return KErrNone;
       
  2599     }
       
  2600 
       
  2601 // ---------------------------------------------------------------------------
       
  2602 // CMmCustomTsy::GetCallOrigin
       
  2603 // This function returns the origin of the call (ETel or other), defined by
       
  2604 // aCallName parameter.
       
  2605 // (other items were commented in a header).
       
  2606 // ---------------------------------------------------------------------------
       
  2607 //
       
  2608 TInt CMmCustomTsy::GetCallOrigin(
       
  2609     const TTsyReqHandle aTsyReqHandle,
       
  2610     TName* aCallName,
       
  2611     RMmCustomAPI::TCallOrigin* aOrigin )
       
  2612     {
       
  2613     // get call object by name
       
  2614     CMmCallTsy* mmCall = iMmPhoneTsy->CallList()->GetMmCallByName(
       
  2615       aCallName );
       
  2616 
       
  2617     // if call exists
       
  2618     if ( mmCall )
       
  2619         {
       
  2620         // get the call origin from Call Object
       
  2621         // if the call is a ghost call it means that is not made by ETEL
       
  2622          if ( mmCall->ETelOriginated() )
       
  2623             {
       
  2624             *aOrigin = RMmCustomAPI::EETelCall;
       
  2625             }
       
  2626          else
       
  2627             {
       
  2628             *aOrigin = RMmCustomAPI::EOutsider;
       
  2629             }
       
  2630         }
       
  2631     else // call not found
       
  2632         {
       
  2633         *aOrigin = RMmCustomAPI::EUnknown;
       
  2634         }
       
  2635 
       
  2636     ReqCompleted( aTsyReqHandle, KErrNone );
       
  2637 
       
  2638     return KErrNone;
       
  2639     }
       
  2640 
       
  2641 // ---------------------------------------------------------------------------
       
  2642 // CMmCustomTsy::GetAlsBlockedL
       
  2643 // This method gets the alternating line service block status.
       
  2644 // (other items were commented in a header).
       
  2645 // ---------------------------------------------------------------------------
       
  2646 //
       
  2647 TInt CMmCustomTsy::GetAlsBlockedL(
       
  2648     const TTsyReqHandle aTsyReqHandle,
       
  2649     RMmCustomAPI::TGetAlsBlockStatus* aBlockStatus )
       
  2650     {
       
  2651 TFLOGSTRING3( "TSY: CMmCustomTsy::GetAlsBlockedL - Req handle: %d, Block status: %d", aTsyReqHandle, *aBlockStatus );
       
  2652     TTsyReqHandle getAlsBlockedHandle =
       
  2653         iTsyReqHandleStore->GetTsyReqHandle( ECustomTsyGetAlsBlocked );
       
  2654 
       
  2655     if ( 0 < getAlsBlockedHandle )
       
  2656         {
       
  2657         // The request is already in processing because of previous request
       
  2658         // Complete request with status value informing the client about
       
  2659         // the situation.
       
  2660         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  2661         }
       
  2662     else
       
  2663         {
       
  2664         // save pointer to client data
       
  2665         iRetAlsBlockStatus = aBlockStatus;
       
  2666 
       
  2667         // call DOS (no packed parameters)
       
  2668         TInt ret = iMmPhoneTsy->MessageManager()->HandleRequestL(
       
  2669             ECustomGetAlsBlockedIPC );
       
  2670 
       
  2671         // check the result of the call
       
  2672         if ( KErrNone != ret )
       
  2673             {
       
  2674             ReqCompleted ( aTsyReqHandle, ret );
       
  2675             }
       
  2676         else
       
  2677             {
       
  2678             // Store the request handle
       
  2679             iReqHandleType = ECustomTsyGetAlsBlocked;
       
  2680             }
       
  2681         }
       
  2682 
       
  2683     return KErrNone;
       
  2684     }
       
  2685 
       
  2686 // ---------------------------------------------------------------------------
       
  2687 // CMmCustomTsy::CompleteGetAlsBlocked
       
  2688 // Completes a GetAlsBlocked operation.
       
  2689 // (other items were commented in a header).
       
  2690 // ---------------------------------------------------------------------------
       
  2691 //
       
  2692 void CMmCustomTsy::CompleteGetAlsBlocked(
       
  2693     RMmCustomAPI::TGetAlsBlockStatus  aBlockStatus,
       
  2694     TInt aErrorCode )
       
  2695     {
       
  2696 TFLOGSTRING3( "TSY: CMmCustomTsy::CompleteGetAlsBlocked - Block status: %d, Error code: %d", aBlockStatus, aErrorCode );
       
  2697     //reset req handle. Returns the deleted req handle
       
  2698     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  2699         ECustomTsyGetAlsBlocked );
       
  2700 
       
  2701     // check if request was called
       
  2702     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  2703         {
       
  2704         //check if response was ok
       
  2705         if ( KErrNone == aErrorCode )
       
  2706             {
       
  2707             // set the information for the client
       
  2708             *iRetAlsBlockStatus = aBlockStatus;
       
  2709             }
       
  2710         // reset the internal variable
       
  2711         iRetAlsBlockStatus = NULL;
       
  2712         // complete
       
  2713         ReqCompleted( reqHandle, aErrorCode );
       
  2714         }
       
  2715     }
       
  2716 
       
  2717 // ---------------------------------------------------------------------------
       
  2718 // CMmCustomTsy::GetAlsBlockedCancel
       
  2719 // This method cancels getting of alternative line service block status.
       
  2720 // (other items were commented in a header).
       
  2721 // ---------------------------------------------------------------------------
       
  2722 //
       
  2723 TInt CMmCustomTsy::GetAlsBlockedCancel()
       
  2724     {
       
  2725     // reset the pointer to client space
       
  2726     iRetAlsBlockStatus = NULL;
       
  2727 
       
  2728     // reset the req handle
       
  2729     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  2730         ECustomTsyGetAlsBlocked );
       
  2731 
       
  2732     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  2733     	{
       
  2734     	// complete with cancel
       
  2735     	ReqCompleted( reqHandle, KErrCancel );
       
  2736     	}
       
  2737 
       
  2738     return KErrNone;
       
  2739     }
       
  2740 
       
  2741 // ---------------------------------------------------------------------------
       
  2742 // CMmCustomTsy::Get3GPBInfo
       
  2743 // This method gets 3G phonebook info.
       
  2744 // (other items were commented in a header).
       
  2745 // ---------------------------------------------------------------------------
       
  2746 //
       
  2747 TInt CMmCustomTsy::Get3GPBInfo(
       
  2748     const TTsyReqHandle aTsyReqHandle,
       
  2749     RMmCustomAPI::T3GPBInfo* aInfo )
       
  2750     {
       
  2751     // Fill info struct
       
  2752     aInfo->iMaxLenAnr = ( TInt16 )iMmPhoneTsy->PhoneBookState()->
       
  2753         iANRNumLengthMax;
       
  2754     aInfo->iMaxLenEmail = ( TInt16 )iMmPhoneTsy->PhoneBookState()->
       
  2755         iEmailTextLengthMax;
       
  2756     aInfo->iMaxLenSne = ( TInt16 )iMmPhoneTsy->PhoneBookState()->
       
  2757         iSNETextLengthMax;
       
  2758     aInfo->iMaxNumAnr = ( TInt8 )iMmPhoneTsy->PhoneBookState()->
       
  2759         iANRNumOfEntriesPerEntry;
       
  2760     aInfo->iMaxNumEmail = ( TInt8 )iMmPhoneTsy->PhoneBookState()->
       
  2761         iEmailNumOfEntriesPerEntry;
       
  2762     aInfo->iMaxNumGroupName = ( TInt8 )iMmPhoneTsy->PhoneBookState()->
       
  2763         iGRPNumOfEntriesPerEntry;
       
  2764     aInfo->iMaxNumSne = ( TInt8 )iMmPhoneTsy->PhoneBookState()->
       
  2765         iSNENumOfEntriesPerEntry;
       
  2766     aInfo->iMaxLenGroupName = -1;   // Not known
       
  2767 
       
  2768     // complete with KErrNone
       
  2769     ReqCompleted( aTsyReqHandle, KErrNone );
       
  2770 
       
  2771     return KErrNone;
       
  2772     }
       
  2773 
       
  2774 // ---------------------------------------------------------------------------
       
  2775 // CMmCustomTsy::Get3GPBInfoCancel
       
  2776 // This method cancels getting of 3G phonebook info
       
  2777 // (other items were commented in a header).
       
  2778 // ---------------------------------------------------------------------------
       
  2779 //
       
  2780 TInt CMmCustomTsy::Get3GPBInfoCancel()
       
  2781     {
       
  2782     // Get3GPBInfo is completed immediately after the request
       
  2783     // has been done. No cancelling possible.
       
  2784     return KErrNone;
       
  2785     }
       
  2786 
       
  2787 // ---------------------------------------------------------------------------
       
  2788 // CMmCustomTsy::SetAlsBlockedL
       
  2789 // This method sets the alternating line service (ALS) block status using the
       
  2790 // aBlockStatus variable.
       
  2791 // (other items were commented in a header).
       
  2792 // ---------------------------------------------------------------------------
       
  2793 //
       
  2794 TInt CMmCustomTsy::SetAlsBlockedL(
       
  2795     const TTsyReqHandle aTsyReqHandle,
       
  2796     RMmCustomAPI::TSetAlsBlock* aBlockStatus )
       
  2797     {
       
  2798 TFLOGSTRING3( "TSY: CMmCustomTsy::SetAlsBlockedL - Req handle: %d, Block status: %d", aTsyReqHandle, *aBlockStatus );
       
  2799     // get the handle
       
  2800     TTsyReqHandle setAlsBlockedHandle =
       
  2801         iTsyReqHandleStore->GetTsyReqHandle( ECustomTsySetAlsBlocked );
       
  2802 
       
  2803     if ( setAlsBlockedHandle > 0 )
       
  2804         {
       
  2805         // The request is already in processing because of previous request
       
  2806         // Complete request with status value informing the client about
       
  2807         // the situation.
       
  2808         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  2809         }
       
  2810     else
       
  2811         {
       
  2812         // save pointer to aBlockStatus (used for notification)
       
  2813         iSetBlockStatus = aBlockStatus;
       
  2814 
       
  2815         // call DOS
       
  2816         // packed parameter: TSetAlsBlock (block status)
       
  2817         CMmDataPackage dataPackage;
       
  2818         dataPackage.PackData( aBlockStatus );
       
  2819         TInt ret = iMmPhoneTsy->MessageManager()->HandleRequestL(
       
  2820             ECustomSetAlsBlockedIPC, &dataPackage );
       
  2821 
       
  2822         // check success
       
  2823         if ( KErrNone != ret )
       
  2824             {
       
  2825             ReqCompleted ( aTsyReqHandle, ret );
       
  2826             }
       
  2827         else
       
  2828             {
       
  2829             // Store the request handle
       
  2830             iReqHandleType = ECustomTsySetAlsBlocked;
       
  2831             }
       
  2832         }
       
  2833 
       
  2834     return KErrNone;
       
  2835     }
       
  2836 
       
  2837 // ---------------------------------------------------------------------------
       
  2838 // CMmCustomTsy::CompleteSetAlsBlocked
       
  2839 // Completes a SetAlsBlocked request. If value for completion is KErrNone and
       
  2840 // a NotifyAlsBlockedChanged has been requested this method calls
       
  2841 // CompleteNotifyAlsBlockedChanged.
       
  2842 // (other items were commented in a header).
       
  2843 // ---------------------------------------------------------------------------
       
  2844 //
       
  2845 void CMmCustomTsy::CompleteSetAlsBlocked(
       
  2846     TInt aErrorCode )
       
  2847     {
       
  2848 TFLOGSTRING2( "TSY: CMmCustomTsy::CompleteSetAlsBlocked - Error code: %d", aErrorCode );
       
  2849     // get reaq handle for NotifyAlsBlockedChanged
       
  2850     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  2851         ECustomTsyNotifyAlsBlockedChanged );
       
  2852 
       
  2853     // check if notification was requested and Set was ok
       
  2854     if( ECustomTsyReqHandleUnknown != reqHandle && KErrNone == aErrorCode )
       
  2855         {
       
  2856         CompleteNotifyAlsBlockedChanged ();
       
  2857         }
       
  2858 
       
  2859     // reset saved pointer
       
  2860     iSetBlockStatus = NULL;
       
  2861 
       
  2862     // reset req handle. Returns the deleted req handle
       
  2863     reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  2864         ECustomTsySetAlsBlocked );
       
  2865 
       
  2866     // check if request was called
       
  2867     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  2868         {
       
  2869         // complete
       
  2870         ReqCompleted( reqHandle, aErrorCode );
       
  2871         }
       
  2872     }
       
  2873 
       
  2874 // ---------------------------------------------------------------------------
       
  2875 // CMmCustomTsy::NotifyAlsBlockedChanged
       
  2876 // This method notifies a client of changed ALS blocked status.
       
  2877 // (other items were commented in a header).
       
  2878 // ---------------------------------------------------------------------------
       
  2879 //
       
  2880 TInt CMmCustomTsy::NotifyAlsBlockedChanged(
       
  2881     RMmCustomAPI::TGetAlsBlockStatus* aBlockStatus )
       
  2882     {
       
  2883     // save pointer to client data
       
  2884     iRetNotifyAlsBlockStatus = aBlockStatus;
       
  2885 
       
  2886     // save handle type
       
  2887     iReqHandleType = ECustomTsyNotifyAlsBlockedChanged;
       
  2888 
       
  2889     return KErrNone;
       
  2890     }
       
  2891 
       
  2892 // ---------------------------------------------------------------------------
       
  2893 // CMmCustomTsy::CompleteNotifyAlsBlockedChanged
       
  2894 // This method notifies a client of changed ALS blocked status.
       
  2895 // (other items were commented in a header).
       
  2896 // ---------------------------------------------------------------------------
       
  2897 //
       
  2898 void CMmCustomTsy::CompleteNotifyAlsBlockedChanged()
       
  2899     {
       
  2900     // reset req handle. Returns the deleted req handle
       
  2901     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  2902         ECustomTsyNotifyAlsBlockedChanged );
       
  2903 
       
  2904     // check if handle exists
       
  2905     if ( ECustomTsyReqHandleUnknown != reqHandle && iSetBlockStatus)
       
  2906         {
       
  2907         // set the information for the client
       
  2908 #ifndef USING_CTSY_DISPATCHER
       
  2909         if ( RMmCustomAPI::EActivateBlock == *iSetBlockStatus )
       
  2910 #else	//USING_CTSY_DISPATCHER
       
  2911         if ( iSetBlockStatus && RMmCustomAPI::EActivateBlock == *iSetBlockStatus )
       
  2912 #endif //USING_CTSY_DISPATCHER
       
  2913             {
       
  2914             *iRetNotifyAlsBlockStatus = RMmCustomAPI::EBlockStatusActive;
       
  2915             }
       
  2916         else // EDeactivateBlock == *iSetBlockStatus
       
  2917             {
       
  2918             *iRetNotifyAlsBlockStatus = RMmCustomAPI::EBlockStatusInactive;
       
  2919             }
       
  2920 TFLOGSTRING2( "TSY: CMmCustomTsy::CompleteNotifyAlsBlockedChanged - Block status: %d", *iSetBlockStatus );
       
  2921 
       
  2922         // reset the varible
       
  2923         iRetNotifyAlsBlockStatus = NULL;
       
  2924 
       
  2925         // complete
       
  2926         ReqCompleted( reqHandle, KErrNone );
       
  2927         }
       
  2928     }
       
  2929 
       
  2930 // ---------------------------------------------------------------------------
       
  2931 // CMmCustomTsy::NotifyAlsBlockedChangedCancel
       
  2932 // Cancels an outstanding NotifyAlsBlockedChanged notification.
       
  2933 // (other items were commented in a header).
       
  2934 // ---------------------------------------------------------------------------
       
  2935 //
       
  2936 TInt CMmCustomTsy::NotifyAlsBlockedChangedCancel(
       
  2937     const TTsyReqHandle aTsyReqHandle )
       
  2938     {
       
  2939     // reset the pointer to client data
       
  2940     iRetNotifyAlsBlockStatus = NULL;
       
  2941 
       
  2942     // reset the reqhandle
       
  2943     iTsyReqHandleStore->ResetTsyReqHandle(
       
  2944         ECustomTsyNotifyAlsBlockedChanged );
       
  2945 
       
  2946     // complete
       
  2947     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  2948 
       
  2949     return KErrNone;
       
  2950     }
       
  2951 
       
  2952 // ---------------------------------------------------------------------------
       
  2953 // CMmCustomTsy::GetAlsPpSupportL
       
  2954 // Gets ALS support information from Product Profile.
       
  2955 // (other items were commented in a header).
       
  2956 // ---------------------------------------------------------------------------
       
  2957 //
       
  2958 TInt CMmCustomTsy::GetAlsPpSupportL(
       
  2959     const TTsyReqHandle aTsyReqHandle,
       
  2960     RMmCustomAPI::TAlsSupport* aSupport )
       
  2961     {
       
  2962 TFLOGSTRING( "TSY: CMmCustomTsy::GetAlsPpSupportL");
       
  2963     // save pointer to client space
       
  2964     iAlsSupport = aSupport;
       
  2965     
       
  2966     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  2967         ECustomTsyGetAlsPpSupport );
       
  2968 
       
  2969     if ( 0 < reqHandle )
       
  2970         {
       
  2971 TFLOGSTRING( "TSY: CMmCustomTsy::GetAlsPpSupportL - Already processing, save handle");
       
  2972         //The request is already in processing because of previous request
       
  2973         //Complete request with status value informing the client about
       
  2974 		TCheckAlsPpSupportRequest* req = 
       
  2975                               new (ELeave) TCheckAlsPpSupportRequest();
       
  2976 		req->iReqHandle = aTsyReqHandle;
       
  2977 		req->iRetSupport = aSupport;
       
  2978 		iCheckAlsPpSupportRequests.AppendL( req );
       
  2979         }
       
  2980     else
       
  2981         {
       
  2982     // call DOS (no packed parameters)
       
  2983     TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  2984         ECustomCheckAlsPpSupportIPC );
       
  2985 
       
  2986     if ( KErrNone != ret )
       
  2987         {
       
  2988         ReqCompleted( aTsyReqHandle, ret );
       
  2989         }
       
  2990     else
       
  2991         {
       
  2992 TFLOGSTRING( "TSY: CMmCustomTsy::GetAlsPpSupportL - Save handle");
       
  2993         // Save the req handle type
       
  2994         iReqHandleType = ECustomTsyGetAlsPpSupport;
       
  2995 			// save request in queue for completion
       
  2996 			TCheckAlsPpSupportRequest* req = 
       
  2997                               new (ELeave) TCheckAlsPpSupportRequest();
       
  2998 			req->iReqHandle = aTsyReqHandle;
       
  2999 			req->iRetSupport = aSupport;
       
  3000 			iCheckAlsPpSupportRequests.AppendL( req );
       
  3001 	        }
       
  3002         }
       
  3003 
       
  3004     return KErrNone;
       
  3005     }
       
  3006 
       
  3007 // ---------------------------------------------------------------------------
       
  3008 // CMmCustomTsy::GetAlsPpSupportCancel
       
  3009 // Cancels an outstanding asynchronous request to get ALS support.
       
  3010 // (other items were commented in a header).
       
  3011 // ---------------------------------------------------------------------------
       
  3012 //
       
  3013 TInt CMmCustomTsy::GetAlsPpSupportCancel()
       
  3014     {
       
  3015 TFLOGSTRING( "TSY: CMmCustomTsy::GetAlsPpSupportCancel");
       
  3016     // reset the pointer to client data
       
  3017     iAlsSupport = NULL;
       
  3018 
       
  3019     // reset the reqhandle
       
  3020     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3021         ECustomTsyGetAlsPpSupport );
       
  3022 
       
  3023     // complete
       
  3024     TInt checkAlsPpSupportRequestsCount = 
       
  3025         iCheckAlsPpSupportRequests.Count();
       
  3026 TFLOGSTRING2( "TSY: CMmCustomTsy::GetAlsPpSupportCancel - Cancel %d requests", checkAlsPpSupportRequestsCount );
       
  3027 
       
  3028 	for ( TInt i=0; i < checkAlsPpSupportRequestsCount ; i++ )
       
  3029 		{
       
  3030         TCheckAlsPpSupportRequest* req = 
       
  3031             iCheckAlsPpSupportRequests[ i ];
       
  3032 		//reset the return pointer
       
  3033         ReqCompleted( req->iReqHandle, KErrCancel );
       
  3034 		}
       
  3035     // Complete the client request
       
  3036 	// Destroy Array 
       
  3037  	iCheckAlsPpSupportRequests.ResetAndDestroy();
       
  3038 
       
  3039     return KErrNone;
       
  3040     }
       
  3041 
       
  3042 // ---------------------------------------------------------------------------
       
  3043 // CMmCustomTsy::CompleteGetAlsPpSupport
       
  3044 // Completes a GetAlsPpSupport request.
       
  3045 // (other items were commented in a header).
       
  3046 // ---------------------------------------------------------------------------
       
  3047 //
       
  3048 void CMmCustomTsy::CompleteGetAlsPpSupport(
       
  3049     RMmCustomAPI::TAlsSupport aAlsSupport,
       
  3050     TInt aErrorCode )
       
  3051     {
       
  3052 TFLOGSTRING3( "TSY: CMmCustomTsy::CompleteGetAlsPpSupport - ALS support: %d, Error: %d", aAlsSupport, aErrorCode );
       
  3053     TBool status = EFalse;
       
  3054     
       
  3055     // Check if the get was called internally during boot
       
  3056     if( iMmPhoneTsy->GetAlsQueryInBoot() )
       
  3057         {
       
  3058     	if( RMmCustomAPI::EAlsSupportOn == aAlsSupport )
       
  3059             {
       
  3060 TFLOGSTRING( "TSY: CMmCustomTsy::CompleteGetAlsPpSupport - ALS supported by SIM" );
       
  3061             status = ETrue;
       
  3062             }
       
  3063         //Update ALS status from sim
       
  3064         iMmPhoneTsy->SetAlsState( status );
       
  3065     	iMmPhoneTsy->SetAlsQueryInBoot( EFalse );
       
  3066         }
       
  3067     
       
  3068     // reset req handle. Returns the deleted req handle
       
  3069     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3070         ECustomTsyGetAlsPpSupport );
       
  3071 
       
  3072     // check if request was called
       
  3073     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  3074         {
       
  3075         // check if response was ok
       
  3076         if ( KErrNone == aErrorCode )
       
  3077             {
       
  3078             // set the information for the client
       
  3079             *iAlsSupport = aAlsSupport;
       
  3080 
       
  3081             if( RMmCustomAPI::EAlsSupportOn == aAlsSupport )
       
  3082             	{
       
  3083 TFLOGSTRING( "TSY: CMmCustomTsy::CompleteGetAlsPpSupport - ALS supported by SIM" );
       
  3084             	status = ETrue;
       
  3085             	}
       
  3086             //Update ALS status from sim
       
  3087             iMmPhoneTsy->SetAlsState( status );
       
  3088             }
       
  3089 
       
  3090         // reset the internal variable
       
  3091         iAlsSupport = NULL;
       
  3092         // complete
       
  3093         TInt checkAlsPpSupportRequestsCount = 
       
  3094             iCheckAlsPpSupportRequests.Count();
       
  3095 TFLOGSTRING2( "TSY: CMmCustomTsy::CompleteGetAlsPpSupport - Complete %d requests", checkAlsPpSupportRequestsCount );
       
  3096 
       
  3097 		for ( TInt i=0; i < checkAlsPpSupportRequestsCount ; i++ )
       
  3098 			{
       
  3099             TCheckAlsPpSupportRequest* req = 
       
  3100                 iCheckAlsPpSupportRequests[ i ];
       
  3101             
       
  3102             //set value in client side
       
  3103             *(req->iRetSupport) = aAlsSupport;
       
  3104 			//reset the return pointer
       
  3105             ReqCompleted( req->iReqHandle, aErrorCode );
       
  3106 			}
       
  3107         // Complete the client request
       
  3108 		//Destroy Array 
       
  3109  		iCheckAlsPpSupportRequests.ResetAndDestroy();
       
  3110         }
       
  3111     }
       
  3112 
       
  3113 // ---------------------------------------------------------------------------
       
  3114 // CMmCustomTsy::GetCipheringInfoL
       
  3115 // Get Ciphering Info
       
  3116 // (other items were commented in a header).
       
  3117 // ---------------------------------------------------------------------------
       
  3118 //
       
  3119 TInt CMmCustomTsy::GetCipheringInfoL(
       
  3120     const TTsyReqHandle aTsyReqHandle,
       
  3121     RMmCustomAPI::TCipheringInfo* aInfo )
       
  3122     {
       
  3123     // this is special case, only called when Ciphering indicator
       
  3124     // is forced off for some operators
       
  3125     if ( iMmPhoneTsy->GetNetTsy()->CipheringIndicatorForcedOff() )
       
  3126         {
       
  3127         aInfo->iIndStatus = EFalse;
       
  3128         aInfo->iCiphStatus = EFalse;
       
  3129 
       
  3130         ReqCompleted( aTsyReqHandle, KErrNone );
       
  3131         }
       
  3132     // normal case
       
  3133     else
       
  3134         {
       
  3135         TTsyReqHandle getCipheringInfoHandle =
       
  3136             iTsyReqHandleStore->GetTsyReqHandle( ECustomTsyGetCipheringInfo );
       
  3137 
       
  3138         if ( 0 < getCipheringInfoHandle )
       
  3139             {
       
  3140             // The request is already in processing because of previous request
       
  3141             // Complete request with status value informing the client about
       
  3142             // the situation.
       
  3143             ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  3144             }
       
  3145         else
       
  3146             {
       
  3147             // save pointer to client space
       
  3148             iRetCipheringInfo = aInfo;
       
  3149 
       
  3150             // call DOS (no packed parameters)
       
  3151             TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  3152                 ECustomGetCipheringInfoIPC );
       
  3153 
       
  3154             // check the correct completion of the call to the extension
       
  3155             if ( KErrNone != ret )
       
  3156                 {
       
  3157                 ReqCompleted( aTsyReqHandle, ret );
       
  3158                 }
       
  3159             else
       
  3160                 {
       
  3161                 // Save the req handle type
       
  3162                 iReqHandleType = ECustomTsyGetCipheringInfo;
       
  3163                 }
       
  3164             }
       
  3165         }
       
  3166 
       
  3167     return KErrNone;
       
  3168     }
       
  3169 
       
  3170 // ---------------------------------------------------------------------------
       
  3171 // CMmCustomTsy::CompleteGetCipheringInfo
       
  3172 // Completes a GetCipheringInfo request.
       
  3173 // (other items were commented in a header).
       
  3174 // ---------------------------------------------------------------------------
       
  3175 //
       
  3176 void CMmCustomTsy::CompleteGetCipheringInfo(
       
  3177     TBool aCipherIndStatus,
       
  3178     TInt aErrorCode )
       
  3179     {
       
  3180     // reset req handle. Returns the deleted req handle
       
  3181     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3182         ECustomTsyGetCipheringInfo );
       
  3183 
       
  3184     // check if request was called
       
  3185     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  3186         {
       
  3187         // check if response was ok
       
  3188         if ( KErrNone == aErrorCode )
       
  3189             {
       
  3190             // set the information for the client
       
  3191             iRetCipheringInfo->iIndStatus = aCipherIndStatus;
       
  3192             iRetCipheringInfo->iCiphStatus = iCipheringInfo.iCiphStatus;
       
  3193             }
       
  3194 
       
  3195         // reset the internal variable
       
  3196         iRetCipheringInfo = NULL;
       
  3197         // complete
       
  3198         ReqCompleted( reqHandle, aErrorCode );
       
  3199         }
       
  3200     }
       
  3201 
       
  3202 // ---------------------------------------------------------------------------
       
  3203 // CMmCustomTsy::GetCipheringInfoCancel
       
  3204 // This function cancels an outstanding GetCipheringInfo request.
       
  3205 // (other items were commented in a header).
       
  3206 // ---------------------------------------------------------------------------
       
  3207 //
       
  3208 TInt CMmCustomTsy::GetCipheringInfoCancel()
       
  3209     {
       
  3210     // reset the pointer to client space
       
  3211     iRetCipheringInfo = NULL;
       
  3212 
       
  3213     // reset the req handle
       
  3214     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3215         ECustomTsyGetCipheringInfo );
       
  3216 
       
  3217     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  3218     	{
       
  3219     	// complete with cancel
       
  3220     	ReqCompleted( reqHandle, KErrCancel );
       
  3221     	}
       
  3222 
       
  3223     return KErrNone;
       
  3224     }
       
  3225 
       
  3226 // ---------------------------------------------------------------------------
       
  3227 // CMmCustomTsy::NotifyCipheringInfoChange
       
  3228 // Notifies a client of ciphering info change.
       
  3229 // (other items were commented in a header).
       
  3230 // ---------------------------------------------------------------------------
       
  3231 //
       
  3232 TInt CMmCustomTsy::NotifyCipheringInfoChange(
       
  3233     RMmCustomAPI::TCipheringInfo* aInfo )
       
  3234     {
       
  3235     // save pointer to client data
       
  3236     iRetNotifyCipheringInfoChange = aInfo;
       
  3237 
       
  3238     // set the reqhandle type
       
  3239     iReqHandleType = ECustomTsyNotifyCipheringInfoChange;
       
  3240 
       
  3241     return KErrNone;
       
  3242     }
       
  3243 
       
  3244 // ---------------------------------------------------------------------------
       
  3245 // CMmCustomTsy::NotifyCipheringInfoChangeCancel
       
  3246 // Cancels an outstanding NotifyCipheringInfoChange request.
       
  3247 // (other items were commented in a header).
       
  3248 // ---------------------------------------------------------------------------
       
  3249 //
       
  3250 TInt CMmCustomTsy::NotifyCipheringInfoChangeCancel(
       
  3251     const TTsyReqHandle aTsyReqHandle )
       
  3252     {
       
  3253     // reset the pointer to client data
       
  3254     iRetNotifyCipheringInfoChange = NULL;
       
  3255 
       
  3256     // reset the reqhandle
       
  3257     iTsyReqHandleStore->ResetTsyReqHandle(
       
  3258         ECustomTsyNotifyCipheringInfoChange );
       
  3259 
       
  3260     // complete
       
  3261     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  3262 
       
  3263     return KErrNone;
       
  3264     }
       
  3265 
       
  3266 // ---------------------------------------------------------------------------
       
  3267 // CMmCustomTsy::CompleteNotifyCipheringInfoChange
       
  3268 // Completes the NotifyCipheringInfoChange method.
       
  3269 // (other items were commented in a header).
       
  3270 // ---------------------------------------------------------------------------
       
  3271 //
       
  3272 void CMmCustomTsy::CompleteNotifyCipheringInfoChange(
       
  3273     TBool aCipherIndStatus,
       
  3274     TBool aCipherStatus,
       
  3275     TInt aErrorCode )
       
  3276     {
       
  3277 TFLOGSTRING("TSY:CMmCustomTsy::CompleteNotifyCipheringInfoChange entered");
       
  3278     // this is special case, only called when Ciphering indicator
       
  3279     // is forced off for some operators
       
  3280     if ( iMmPhoneTsy->GetNetTsy()->CipheringIndicatorForcedOff() )
       
  3281         {
       
  3282 TFLOGSTRING("TSY:CMmCustomTsy::CompleteNotifyCipheringInfoChange: Ciphering forced off");
       
  3283         TTsyReqHandle handle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3284             ECustomTsyNotifyCipheringInfoChange );
       
  3285 
       
  3286         if ( ECustomTsyReqHandleUnknown != handle )
       
  3287             {
       
  3288 TFLOGSTRING("TSY:CMmCustomTsy::CompleteNotifyCipheringInfoChange: Ciphering forced off, request completed");
       
  3289             iRetNotifyCipheringInfoChange->iIndStatus = EFalse;
       
  3290             iRetNotifyCipheringInfoChange->iCiphStatus = ETrue;
       
  3291 
       
  3292             iRetNotifyCipheringInfoChange = NULL;
       
  3293 
       
  3294             ReqCompleted( handle, KErrNone );
       
  3295             }
       
  3296         }
       
  3297 
       
  3298      // check if information has changed, continue only in case is changed
       
  3299     else
       
  3300         {
       
  3301         if ( iCipheringInfo.iIndStatus  != aCipherIndStatus ||
       
  3302             iCipheringInfo.iCiphStatus != aCipherStatus )
       
  3303             {
       
  3304             // save the information in the custom TSY
       
  3305             iCipheringInfo.iIndStatus = aCipherIndStatus;
       
  3306             iCipheringInfo.iCiphStatus = aCipherStatus;
       
  3307 
       
  3308             // reset req handle. Returns the deleted req handle
       
  3309             TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3310                 ECustomTsyNotifyCipheringInfoChange );
       
  3311 
       
  3312             // check if handle exists
       
  3313             if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  3314                 {
       
  3315                 // set the information for the client
       
  3316                 iRetNotifyCipheringInfoChange->iIndStatus =
       
  3317                     iCipheringInfo.iIndStatus;
       
  3318                 iRetNotifyCipheringInfoChange->iCiphStatus =
       
  3319                     iCipheringInfo.iCiphStatus;
       
  3320 
       
  3321                 // reset the varible
       
  3322                 iRetNotifyCipheringInfoChange = NULL;
       
  3323 
       
  3324                 // complete
       
  3325                 ReqCompleted( reqHandle, aErrorCode );
       
  3326 
       
  3327                 }
       
  3328             }
       
  3329         }
       
  3330     }
       
  3331 
       
  3332 // ---------------------------------------------------------------------------
       
  3333 // CMmCustomTsy::NotifyNSPSStatus
       
  3334 // Notifies a client of a change in NSPS (No Service Power Save) status.
       
  3335 // (other items were commented in a header).
       
  3336 // ---------------------------------------------------------------------------
       
  3337 //
       
  3338 TInt CMmCustomTsy::NotifyNSPSStatus(
       
  3339     RMmCustomAPI::TNspsStatus* aNspsStatus )
       
  3340     {
       
  3341     // save pointer to client data
       
  3342     iRetNspsStatus = aNspsStatus;
       
  3343 
       
  3344     // set the reqhandle type
       
  3345     iReqHandleType = ECustomTsyNotifyNSPSStatus;
       
  3346 
       
  3347     return KErrNone;
       
  3348     }
       
  3349 
       
  3350 // ---------------------------------------------------------------------------
       
  3351 // CMmCustomTsy::CompleteNotifyNSPSStatus
       
  3352 // Completes the notification of a change in NSPS (No Service Power Save)
       
  3353 // status.
       
  3354 // (other items were commented in a header).
       
  3355 // ---------------------------------------------------------------------------
       
  3356 //
       
  3357 void CMmCustomTsy::CompleteNotifyNSPSStatus(
       
  3358     TBool aNspsStatus )
       
  3359     {
       
  3360     // reset req handle. Returns the deleted req handle
       
  3361     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3362         ECustomTsyNotifyNSPSStatus );
       
  3363 
       
  3364     // check if handle exists
       
  3365     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  3366         {
       
  3367         // set the information for the client
       
  3368         if ( aNspsStatus ) // the NSPS mode is ON
       
  3369             {
       
  3370             *iRetNspsStatus = RMmCustomAPI::ENspsOn;
       
  3371             }
       
  3372         else
       
  3373             {
       
  3374             *iRetNspsStatus = RMmCustomAPI::ENspsOff;
       
  3375             }
       
  3376 
       
  3377         // reset the varible
       
  3378         iRetNspsStatus = NULL;
       
  3379 
       
  3380         // complete
       
  3381         ReqCompleted( reqHandle, KErrNone );
       
  3382         }
       
  3383     }
       
  3384 
       
  3385 // ---------------------------------------------------------------------------
       
  3386 // CMmCustomTsy::NotifyNSPSStatusCancel
       
  3387 // Cancels an outstanding notification of a change in NSPS (No Service Power
       
  3388 // Save) status.
       
  3389 // (other items were commented in a header).
       
  3390 // ---------------------------------------------------------------------------
       
  3391 //
       
  3392 TInt CMmCustomTsy::NotifyNSPSStatusCancel(
       
  3393     const TTsyReqHandle aTsyReqHandle )
       
  3394     {
       
  3395     // reset pointer to client data
       
  3396     iRetNspsStatus = NULL;
       
  3397 
       
  3398     // reset reqhandle
       
  3399     iTsyReqHandleStore->ResetTsyReqHandle( ECustomTsyNotifyNSPSStatus );
       
  3400 
       
  3401     // complete with KErrCancel
       
  3402     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  3403 
       
  3404     return KErrNone;
       
  3405     }
       
  3406 
       
  3407 // ---------------------------------------------------------------------------
       
  3408 // CMmCustomTsy::NetWakeupL
       
  3409 // Send  NetWakeUp request
       
  3410 // (other items were commented in a header).
       
  3411 // ---------------------------------------------------------------------------
       
  3412 //
       
  3413 TInt CMmCustomTsy::NetWakeupL(
       
  3414     const TTsyReqHandle aTsyReqHandle )
       
  3415     {
       
  3416     // intialize ret value
       
  3417     TInt ret ( KErrNone );
       
  3418 
       
  3419     // call DOS (no packed parameters)
       
  3420     ret = Phone()->MessageManager()->HandleRequestL( ECustomNetWakeupIPC );
       
  3421 
       
  3422     // check result
       
  3423     if ( KErrNone != ret )
       
  3424         {
       
  3425         ReqCompleted( aTsyReqHandle, ret );
       
  3426         }
       
  3427     else
       
  3428         {
       
  3429         // Save the req handle type
       
  3430         iReqHandleType = ECustomTsyNetWakeup;
       
  3431         }
       
  3432 
       
  3433     return KErrNone;
       
  3434     }
       
  3435 
       
  3436 // ---------------------------------------------------------------------------
       
  3437 // CMmCustomTsy::CompleteNetWakeup
       
  3438 // Completes a NetWakeup request.
       
  3439 // (other items were commented in a header).
       
  3440 // ---------------------------------------------------------------------------
       
  3441 //
       
  3442 void CMmCustomTsy::CompleteNetWakeup(
       
  3443      TInt aErrorCode )
       
  3444     {
       
  3445     // reset req handle. Returns the deleted req handle
       
  3446     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3447         ECustomTsyNetWakeup );
       
  3448 
       
  3449     // check the handle and complete
       
  3450     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  3451         {
       
  3452         ReqCompleted( reqHandle, aErrorCode );
       
  3453         }
       
  3454     }
       
  3455 
       
  3456 #ifdef REQHANDLE_TIMER
       
  3457 // ---------------------------------------------------------------------------
       
  3458 // CMmCustomTsy::SetTypeOfResponse
       
  3459 // Sets the type of response for a given handle.
       
  3460 // Automatic mode includes an automatic response in case of no response from
       
  3461 // the DOS in a specified time.
       
  3462 // (other items were commented in a header).
       
  3463 // ---------------------------------------------------------------------------
       
  3464 //
       
  3465 void CMmCustomTsy::SetTypeOfResponse(
       
  3466     const TInt aReqHandleType,
       
  3467     const TTsyReqHandle aTsyReqHandle )
       
  3468     {
       
  3469     TInt timeOut( 0 );
       
  3470     TInt ipc( 0 );
       
  3471 
       
  3472     switch ( aReqHandleType )
       
  3473         {
       
  3474         case ECustomTsyCallGsmBlackListClear:
       
  3475             timeOut = KMmCustomCallGsmBlackListClearTimeOut;
       
  3476             ipc = ECustomClearCallBlackListIPC;
       
  3477             break;
       
  3478         case ECustomTsyTerminateCall:
       
  3479             timeOut = KMmCustomTerminateCallTimeOut;
       
  3480             ipc = ECustomTerminateCallIPC;
       
  3481             break;
       
  3482         case ECustomTsyGetAlsBlocked:
       
  3483             timeOut = KMmCustomGetAlsBlockedTimeOut;
       
  3484             ipc = ECustomGetAlsBlockedIPC;
       
  3485             break;
       
  3486         case ECustomTsySetAlsBlocked:
       
  3487             timeOut = KMmCustomSetAlsBlockedTimeOut;
       
  3488             ipc = ECustomSetAlsBlockedIPC;
       
  3489             break;
       
  3490         case ECustomTsyGetCipheringInfo:
       
  3491             timeOut = KMmCustomGetCipheringInfoTimeOut;
       
  3492             ipc = ECustomGetCipheringInfoIPC;
       
  3493             break;
       
  3494         case ECustomTsyCheckEmergencyNumber:
       
  3495             timeOut = KMmCustomCheckEmergencyNumberTimeout;
       
  3496             ipc = ECustomCheckEmergencyNumberIPC;
       
  3497             break;
       
  3498         case ECustomTsyGetNetworkOperatorName:
       
  3499             timeOut = KMmCustomGetNetworkOperatorNameTimeout;
       
  3500             ipc = ECustomGetNetworkProviderNameIPC;
       
  3501             break;
       
  3502         case ECustomTsyCheckTwoDigitDialSupport:
       
  3503             timeOut = KMmCustomCheckTwoDigitDialTimeout;
       
  3504             ipc = ECustomCheckTwoDigitDialSupportIPC;
       
  3505             break;
       
  3506         case ECustomTsyGetOperatorName:
       
  3507             timeOut = KMmCustomGetOperatorNameTimeout;
       
  3508             ipc = ECustomGetOperatorNameIPC;
       
  3509             break;
       
  3510         case ECustomTsyGetProgrammableOperatorLogo:
       
  3511             timeOut = KMmCustomGetProgrammableOperatorLogoTimeout;
       
  3512             ipc = ECustomGetProgrammableOperatorLogoIPC;
       
  3513             break;
       
  3514         case ECustomTsyResetNetServer:
       
  3515             timeOut = KMmCustomResetNetServer;
       
  3516             ipc = ECustomResetNetServerIPC;
       
  3517             break;
       
  3518         case ECustomTsyGetSimFileInfo:
       
  3519             timeOut = KMmCustomReadSimFile;
       
  3520             ipc = ECustomReadSimFileIPC;
       
  3521             break;
       
  3522         case ECustomTsyGetLifeTimerInfo:
       
  3523             timeOut = KMmCustomReadSimFile;
       
  3524             ipc = ECustomGetLifeTimeIPC;
       
  3525             break;
       
  3526         case ECustomTsyIMSAuthenticate:
       
  3527             timeOut = KMmCustomIMSAuthenticate;
       
  3528             ipc = EMobilePhoneIMSAuthenticate;
       
  3529             break;
       
  3530         case ECustomTsyGetSimAuthenticationData:
       
  3531             timeOut = KMmCustomGetSimAuthenticationData;
       
  3532             ipc = ECustomGetSimAuthenticationDataIPC;
       
  3533             break;
       
  3534         case ECustomTsySetDriveMode:
       
  3535             timeOut = KMmCustomSetDriveModeTimeOut;
       
  3536             ipc = ECustomSetDriveModeIPC;
       
  3537             break;
       
  3538         case ECustomTsyReadHSxPAStatus:
       
  3539             timeOut = KMmCustomTsyReadHSxPAStatusTimeOut;
       
  3540             ipc = ECustomReadHSxPAStatusIPC;
       
  3541             break;
       
  3542         case ECustomTsyWriteHSxPAStatus:
       
  3543             timeOut = KMmCustomTsyWriteHSxPAStatusTimeOut;
       
  3544             ipc = ECustomWriteHSxPAStatusIPC;
       
  3545             break;
       
  3546         case ECustomTsyGetIccCallForwardingStatus:
       
  3547         	timeOut = KMmCustomTsyGetIccCallForwardingStatusTimeOut;
       
  3548         	ipc = ECustomGetIccCallForwardingStatusIPC;
       
  3549         	break;
       
  3550         case ECustomTsyGetCellInfo:
       
  3551             timeOut = KMmCustomTsyGetCellInfoTimeOut;
       
  3552             ipc = ECustomGetCellInfoIPC;
       
  3553             break;
       
  3554        	case ECustomTsyGetUSIMServiceSupport:
       
  3555             timeOut = KMmCustomGetUSIMServiceSupportTimeOut;
       
  3556             ipc = ECustomGetServiceTableSupportbyApplicationIPC;
       
  3557             break;
       
  3558         case ECustomTsyGetSystemNetworkBand:
       
  3559             timeOut = KMmCustomTsyGetSystemNetworkBandTimeOut;
       
  3560             ipc = ECustomGetBandSelectionIPC;
       
  3561             break;
       
  3562         default:
       
  3563             // Does not use timer
       
  3564             iTsyReqHandleStore->SetTsyReqHandle( aReqHandleType,
       
  3565                 aTsyReqHandle );
       
  3566             break;
       
  3567         }
       
  3568 
       
  3569     if ( 0 < timeOut )
       
  3570         {
       
  3571         // The timeout parameter is given in seconds.
       
  3572         iTsyReqHandleStore->SetTsyReqHandle( aReqHandleType, aTsyReqHandle,
       
  3573             timeOut, ipc );
       
  3574         }
       
  3575     }
       
  3576 
       
  3577 // ---------------------------------------------------------------------------
       
  3578 // CMmCustomTsy::Complete
       
  3579 // Completes the request due the timer expiration.
       
  3580 // (other items were commented in a header).
       
  3581 // ---------------------------------------------------------------------------
       
  3582 //
       
  3583 void CMmCustomTsy::Complete(
       
  3584     TInt aReqHandleType,
       
  3585     TInt aError,
       
  3586     TInt aIPC )
       
  3587     {
       
  3588 TFLOGSTRING3( "TSY: CMmCustomTsy::Complete - ReqHandleType: %d Error: %d", aReqHandleType, aError );
       
  3589     TBool subTsyReqFound = EFalse;
       
  3590     TInt max = GetMaxNumberOfSubsystems();
       
  3591     CMmSubTsyBase** subTsyPtr = GetSubsystemArrayPtr();
       
  3592 
       
  3593     // Check Custom TSY's subsystems' req handles first
       
  3594     for ( TInt i = 0; max > i; i++ )
       
  3595         {
       
  3596         // check which custom object handles this IPC
       
  3597         if ( ( NULL != subTsyPtr[i] ) &&
       
  3598              ( EFalse != subTsyPtr[i]->SupportingIPC( aIPC ) ) )
       
  3599             {
       
  3600             // call complete method of the right custom object
       
  3601             subTsyPtr[i]->Complete( aReqHandleType, aError );
       
  3602             i = max;
       
  3603             subTsyReqFound = ETrue;
       
  3604             }
       
  3605         }
       
  3606 
       
  3607     // If the reg handle was not found on Custom TSY's subsystems check the
       
  3608     // Custom TSY's request handles
       
  3609     if ( !subTsyReqFound )
       
  3610         {
       
  3611         TBuf<1> name(KNullDesC);
       
  3612         RMmCustomAPI::TOperatorNameInfo operatorNameInfo;
       
  3613         RMmCustomAPI::TLifeTimeData timeData;
       
  3614 
       
  3615         // All possible Custom TSY req handle types are listed in the
       
  3616         // switch case below.
       
  3617         switch ( aReqHandleType )
       
  3618             {
       
  3619             case ECustomTsyCallGsmBlackListClear:
       
  3620                 CompleteClearCallBlackList ( aError );
       
  3621                 break;
       
  3622             case ECustomTsyTerminateCall:
       
  3623                 CompleteTerminateCall( aError );
       
  3624                 break;
       
  3625             case ECustomTsyGetAlsBlocked:
       
  3626                 CompleteGetAlsBlocked( RMmCustomAPI::EBlockStatusUnknown,
       
  3627                     aError );
       
  3628                 break;
       
  3629             case ECustomTsySetAlsBlocked:
       
  3630                 CompleteSetAlsBlocked( aError );
       
  3631                 break;
       
  3632             case ECustomTsyGetCipheringInfo:
       
  3633                 CompleteGetCipheringInfo( EFalse, aError );
       
  3634                 break;
       
  3635             case ECustomTsyCheckEmergencyNumber:
       
  3636                 CompleteCheckEmergencyNumber( 0, aError );
       
  3637                 break;
       
  3638             case ECustomTsyGetNetworkOperatorName:
       
  3639                 CompleteGetNetworkOperatorName( &name, aError );
       
  3640                 break;
       
  3641             case ECustomTsyCheckTwoDigitDialSupport:
       
  3642                 CompleteCheckTwoDigitDialSupport(
       
  3643                     RMmCustomAPI::ETwoDigitDialSupportOff, aError );
       
  3644                 break;
       
  3645             case ECustomTsyGetOperatorName:
       
  3646                 // we don't initialize as this is response to error situation
       
  3647                 CompleteGetOperatorName( operatorNameInfo , aError );
       
  3648                 break;
       
  3649             case ECustomTsyResetNetServer:
       
  3650                 CompleteResetNetServer( aError );
       
  3651                 break;
       
  3652             case ECustomTsyGetSimFileInfo:
       
  3653                 CompleteGetSimFileInfo( NULL, aError );
       
  3654                 break;
       
  3655             case ECustomTsyGetLifeTimerInfo:
       
  3656                 CompleteGetLifeTime( timeData, aError );
       
  3657                 break;
       
  3658             case ECustomTsyGetProgrammableOperatorLogo:
       
  3659                 CompleteGetProgrammableOperatorLogo( NULL, NULL, aError );
       
  3660                 break;
       
  3661             case ECustomTsyGetSimAuthenticationData:
       
  3662                 CompleteSimAuthentication( NULL, aError );
       
  3663                 break;
       
  3664             case ECustomTsyIMSAuthenticate:
       
  3665                 CompleteImsAuthentication( NULL, aError );
       
  3666                 break;
       
  3667             case ECustomTsySetDriveMode:
       
  3668                 CompleteSetDriveMode( aError );
       
  3669                 break;
       
  3670             case ECustomTsyReadHSxPAStatus:
       
  3671                 CompleteReadHSxPAStatus( NULL, aError );
       
  3672                 break;
       
  3673             case ECustomTsyWriteHSxPAStatus:
       
  3674                 CompleteWriteHSxPAStatus( aError );
       
  3675                 break;
       
  3676             case ECustomTsyGetCellInfo:
       
  3677                 CompleteGetCellInfo( NULL, aError );
       
  3678                 break;
       
  3679             case ECustomTsyGetUSIMServiceSupport:
       
  3680                 CompleteGetUSIMServiceSupport( NULL, aError );
       
  3681                 break;
       
  3682             case ECustomTsyGetSystemNetworkBand:
       
  3683                 CompleteGetSystemNetworkBand(
       
  3684                     RMmCustomAPI::ENetworkBandAny,
       
  3685                     RMmCustomAPI::KCapsNetworkModeDual,
       
  3686                     aError );
       
  3687                 break;
       
  3688             case ECustomTsyGetIccCallForwardingStatus:
       
  3689                 CompleteGetIccCallForwardingStatus( NULL, aError );
       
  3690                 break;                
       
  3691             default:
       
  3692                 break;
       
  3693             }
       
  3694         }
       
  3695     }
       
  3696 #endif // REQHANDLE_TIMER
       
  3697 
       
  3698 // ---------------------------------------------------------------------------
       
  3699 // CMmCustomTsy::ClearCallBlackList
       
  3700 // Clears the Call Blacklist.
       
  3701 // (other items were commented in a header).
       
  3702 // ---------------------------------------------------------------------------
       
  3703 //
       
  3704 TInt CMmCustomTsy::ClearCallBlackListL(
       
  3705     const TTsyReqHandle aTsyReqHandle )
       
  3706     {
       
  3707     TInt retValue ( KErrNone );
       
  3708 
       
  3709     TTsyReqHandle reqhandle =
       
  3710         iTsyReqHandleStore->GetTsyReqHandle(
       
  3711             ECustomTsyCallGsmBlackListClear );
       
  3712 
       
  3713     if ( 0 < reqhandle )
       
  3714         {
       
  3715         // The request is already in processing because of previous request
       
  3716         // Complete request with status value informing the client about
       
  3717         // the situation.
       
  3718         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  3719         }
       
  3720     else
       
  3721         {
       
  3722         // call DOS and initialize ret value
       
  3723         // no parameters for DOS call
       
  3724         retValue = Phone()->MessageManager()->
       
  3725             HandleRequestL( ECustomClearCallBlackListIPC );
       
  3726 
       
  3727         // check result
       
  3728         if ( KErrNone != retValue )
       
  3729             {
       
  3730             ReqCompleted( aTsyReqHandle, retValue );
       
  3731             }
       
  3732         else
       
  3733             {
       
  3734             // Save the req handle type
       
  3735             iReqHandleType = ECustomTsyCallGsmBlackListClear;
       
  3736             }
       
  3737         }
       
  3738 
       
  3739     return KErrNone;
       
  3740     }
       
  3741 
       
  3742 // ---------------------------------------------------------------------------
       
  3743 // CMmCustomTsy::CompleteClearCallBlackList
       
  3744 // Completes a ClearCallBlackList request.
       
  3745 // (other items were commented in a header).
       
  3746 // ---------------------------------------------------------------------------
       
  3747 //
       
  3748 void CMmCustomTsy::CompleteClearCallBlackList(
       
  3749     TInt aErrorCode )
       
  3750     {
       
  3751     // reset req handle. Returns the deleted req handle
       
  3752     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3753         ECustomTsyCallGsmBlackListClear );
       
  3754 
       
  3755     // check the handle and complete
       
  3756     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  3757         {
       
  3758         ReqCompleted( reqHandle, aErrorCode );
       
  3759         }
       
  3760     }
       
  3761 
       
  3762 // ---------------------------------------------------------------------------
       
  3763 // CMmCustomTsy::ClearCallBlackListCancel
       
  3764 // Cancels an outstanding ClearCallBlackList request.
       
  3765 // (other items were commented in a header).
       
  3766 // ---------------------------------------------------------------------------
       
  3767 //
       
  3768 TInt CMmCustomTsy::ClearCallBlackListCancel()
       
  3769     {
       
  3770     // reset req handle. Returns the deleted req handle
       
  3771     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3772         ECustomTsyCallGsmBlackListClear );
       
  3773     // complete with KErrCancel
       
  3774     // check the handle and complete
       
  3775     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  3776         {
       
  3777         ReqCompleted( reqHandle, KErrCancel );
       
  3778         }
       
  3779 
       
  3780     return KErrNone;
       
  3781     }
       
  3782 
       
  3783 // ---------------------------------------------------------------------------
       
  3784 // CMmCustomTsy::GetAirTimeDuration
       
  3785 // Gets the air time duration information from CMmPhoneTsy.
       
  3786 // (other items were commented in a header).
       
  3787 // ---------------------------------------------------------------------------
       
  3788 //
       
  3789 TInt CMmCustomTsy::GetAirTimeDuration(
       
  3790     const TTsyReqHandle aTsyReqHandle,
       
  3791     TTimeIntervalSeconds* aTime )
       
  3792     {
       
  3793     // get the air time duration from phone
       
  3794     Phone()->GetAirTimeDuration( *aTime );
       
  3795 
       
  3796     // complete with KErrNone
       
  3797     ReqCompleted( aTsyReqHandle, KErrNone );
       
  3798 
       
  3799     return KErrNone;
       
  3800     }
       
  3801 
       
  3802 // ---------------------------------------------------------------------------
       
  3803 // CMmCustomTsy::CheckEmergencyNumberL
       
  3804 // Checks whether given number is emergency number or not.
       
  3805 // (other items were commented in a header).
       
  3806 // ---------------------------------------------------------------------------
       
  3807 //
       
  3808 TInt CMmCustomTsy::CheckEmergencyNumberL(
       
  3809     const TTsyReqHandle aTsyReqHandle,
       
  3810     RMmCustomAPI::TEmerNumberCheckMode* aNumberMode,
       
  3811     TBool* aResult )
       
  3812     {
       
  3813 TFLOGSTRING2("TSY: CMmCustomTsy::CheckEmergencyNumberL number=%S", &(aNumberMode->iNumber) );
       
  3814 
       
  3815     TInt ret(KErrGeneral);
       
  3816 
       
  3817     TTsyReqHandle requestHandle =
       
  3818         iTsyReqHandleStore->GetTsyReqHandle( ECustomTsyCheckEmergencyNumber );
       
  3819 
       
  3820     // 3rd Dial check number
       
  3821     if( iISVDialNumberCheck && 0 == requestHandle )
       
  3822         {
       
  3823 TFLOGSTRING2("TSY: CMmCustomTsy::CheckEmergencyNumberL - 3rd party client nbr check aResult  = %d" , aResult );
       
  3824         iEmergencyNumberCheckMode   = aNumberMode;
       
  3825         iEmergencyNumberCheckResult = aResult;
       
  3826 
       
  3827         // parameter for DOS call: a TEmerNumberCheckMode
       
  3828         CMmDataPackage dataPackage;
       
  3829         dataPackage.PackData( aNumberMode );
       
  3830         ret = Phone()->MessageManager()->HandleRequestL(
       
  3831             ECustomCheckEmergencyNumberIPC, &dataPackage );
       
  3832         }
       
  3833 
       
  3834     //Normal case
       
  3835     else
       
  3836         {
       
  3837 TFLOGSTRING2("TSY: CMmCustomTsy::CheckEmergencyNumberL - aResult  = %d" , aResult );
       
  3838 
       
  3839         if ( ( 0 < requestHandle || iISVDialNumberCheck ) && 0 != aTsyReqHandle )
       
  3840             {
       
  3841             // The request is already in processing because of previous request
       
  3842             ret = KErrServerBusy;
       
  3843             }
       
  3844         
       
  3845         else if( iISVDialNumberCheck && 0 == aTsyReqHandle )
       
  3846             {
       
  3847             ret = KErrServerBusy;
       
  3848             }
       
  3849         
       
  3850         else
       
  3851             {
       
  3852             // save pointers
       
  3853             iEmergencyNumberCheckMode   = aNumberMode;
       
  3854             iEmergencyNumberCheckResult = aResult;
       
  3855 
       
  3856             // parameter for DOS call: a TEmerNumberCheckMode
       
  3857             CMmDataPackage dataPackage;
       
  3858             dataPackage.PackData( aNumberMode );
       
  3859             ret = Phone()->MessageManager()->HandleRequestL(
       
  3860                     ECustomCheckEmergencyNumberIPC, &dataPackage );
       
  3861 
       
  3862             // check the correct completion of the call
       
  3863             if ( KErrNone == ret )
       
  3864                 {
       
  3865                 // Save the req handle type
       
  3866                 iReqHandleType = ECustomTsyCheckEmergencyNumber;
       
  3867                 }
       
  3868             }
       
  3869         }
       
  3870 
       
  3871     return ret;
       
  3872     }
       
  3873 
       
  3874 // ---------------------------------------------------------------------------
       
  3875 // CMmCustomTsy::CompleteCheckEmergencyNumber
       
  3876 // Completes checking of emergency number.
       
  3877 // (other items were commented in a header).
       
  3878 // ---------------------------------------------------------------------------
       
  3879 //
       
  3880 void CMmCustomTsy::CompleteCheckEmergencyNumber(
       
  3881     RMmCustomAPI::TMobileTelNumber* aTelNumber,
       
  3882     TInt aErrorValue )
       
  3883     {
       
  3884 
       
  3885 TFLOGSTRING("TSY: CMmCustomTsy::CompleteCheckEmergencyNumber" );
       
  3886 
       
  3887     // 3rd party number check completion0
       
  3888     if( iISVDialNumberCheck )
       
  3889         {
       
  3890         //Reset
       
  3891         TBool isEmergencyNbr = EFalse;
       
  3892 
       
  3893         if ( KErrNone == aErrorValue && NULL == aTelNumber )
       
  3894             {
       
  3895             *iEmergencyNumberCheckResult = ETrue;
       
  3896             isEmergencyNbr = EFalse;
       
  3897             }
       
  3898         else
       
  3899             {
       
  3900             *iEmergencyNumberCheckResult = ETrue;
       
  3901             isEmergencyNbr = ETrue;
       
  3902             }
       
  3903 
       
  3904     // check is the Dial cancel NULL
       
  3905     if( iISVDialNumberCheckObject )
       
  3906       {
       
  3907 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteCheckEmergencyNumber - Complete3rdPartyCallNbrCheck isEmergencyNbr = %d",isEmergencyNbr );
       
  3908       iISVDialNumberCheckObject->Complete3rdPartyCallNbrCheck(
       
  3909         isEmergencyNbr );
       
  3910       }
       
  3911 
       
  3912       //reset pointer
       
  3913       iISVDialNumberCheckObject = NULL;
       
  3914       iISVDialNumberCheck = EFalse;
       
  3915       }
       
  3916 
       
  3917     // Normal case
       
  3918     else
       
  3919       {
       
  3920     // reset req handle. Returns the deleted req handle
       
  3921     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3922         ECustomTsyCheckEmergencyNumber );
       
  3923 
       
  3924     // check if request was called
       
  3925     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  3926         {
       
  3927         // check if response was ok
       
  3928         if ( KErrNone == aErrorValue )
       
  3929             {
       
  3930             //set the information for the client
       
  3931         if ( aTelNumber )
       
  3932             {
       
  3933             *iEmergencyNumberCheckResult = ETrue;
       
  3934             iEmergencyNumberCheckMode->iNumber = *aTelNumber;
       
  3935             }
       
  3936         else
       
  3937             {
       
  3938             *iEmergencyNumberCheckResult = EFalse;
       
  3939             }
       
  3940         }
       
  3941 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteCheckEmergencyNumber number=%S", &(iEmergencyNumberCheckMode->iNumber) );
       
  3942 
       
  3943         // reset the internal variable
       
  3944         iEmergencyNumberCheckResult = NULL;
       
  3945         iEmergencyNumberCheckMode   = NULL;
       
  3946         // complete
       
  3947         ReqCompleted( reqHandle, aErrorValue );
       
  3948         }
       
  3949 
       
  3950         }
       
  3951 
       
  3952     //Reset
       
  3953     iISVDialNumberCheck = EFalse;
       
  3954     }
       
  3955 
       
  3956 // ---------------------------------------------------------------------------
       
  3957 // CMmCustomTsy::CheckEmergencyNumberCancel
       
  3958 // Cancels checking of emergency number.
       
  3959 // (other items were commented in a header).
       
  3960 // ---------------------------------------------------------------------------
       
  3961 //
       
  3962 TInt CMmCustomTsy::CheckEmergencyNumberCancel()
       
  3963     {
       
  3964     iEmergencyNumberCheckResult = NULL;
       
  3965 
       
  3966     // reset the req handle.Returns the deleted req handle.
       
  3967     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  3968         ECustomTsyCheckEmergencyNumber );
       
  3969 
       
  3970     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  3971     	{
       
  3972     	// complete with cancel
       
  3973     	ReqCompleted( reqHandle, KErrCancel );
       
  3974     	}
       
  3975 
       
  3976     return KErrNone;
       
  3977     }
       
  3978 
       
  3979 // ---------------------------------------------------------------------------
       
  3980 // CMmCustomTsy::NotifyPhoneBookCacheReady
       
  3981 // Notifies client when phonebookcache is ready.
       
  3982 // (other items were commented in a header).
       
  3983 // ---------------------------------------------------------------------------
       
  3984 //
       
  3985 TInt CMmCustomTsy::NotifyPhoneBookCacheReady(
       
  3986     const TTsyReqHandle,
       
  3987     TName*  aPndName )
       
  3988     {
       
  3989     iPndName = aPndName;
       
  3990 
       
  3991     iReqHandleType = ECustomTsyNotifyCacheReady;
       
  3992 
       
  3993     return KErrNone;
       
  3994     }
       
  3995 
       
  3996 // ---------------------------------------------------------------------------
       
  3997 // CMmCustomTsy::CompleteNotifyPhoneBookCacheReady
       
  3998 // Completes notify phonebook cache ready.
       
  3999 // (other items were commented in a header).
       
  4000 // ---------------------------------------------------------------------------
       
  4001 //
       
  4002 void CMmCustomTsy::CompleteNotifyPhoneBookCacheReady(
       
  4003     TName& aPndName,
       
  4004     TInt aResult )
       
  4005     {
       
  4006     // reset req handle. Returns the deleted req handle
       
  4007     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4008         ECustomTsyNotifyCacheReady );
       
  4009 
       
  4010     // check if request was called
       
  4011     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4012         {
       
  4013         *iPndName = aPndName;
       
  4014 
       
  4015         iPndName = NULL;
       
  4016 
       
  4017         ReqCompleted( reqHandle, aResult );
       
  4018         }
       
  4019     }
       
  4020 
       
  4021 // ---------------------------------------------------------------------------
       
  4022 // CMmCustomTsy::NotifyPhoneBookCacheReadyCancel
       
  4023 // Cancels notify phonebook cache ready notification.
       
  4024 // (other items were commented in a header).
       
  4025 // ---------------------------------------------------------------------------
       
  4026 //
       
  4027 TInt CMmCustomTsy::NotifyPhoneBookCacheReadyCancel(
       
  4028     const TTsyReqHandle )
       
  4029     {
       
  4030     // reset request handle
       
  4031     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4032         ECustomTsyNotifyCacheReady );
       
  4033 
       
  4034     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4035     	{
       
  4036     	ReqCompleted( reqHandle, KErrCancel );
       
  4037     	}
       
  4038 
       
  4039     return KErrNone;
       
  4040     }
       
  4041 
       
  4042 // ---------------------------------------------------------------------------
       
  4043 // CMmCustomTsy::GetPndCacheStatus
       
  4044 // This function gets current status of phonebook caching.
       
  4045 // (other items were commented in a header).
       
  4046 // ---------------------------------------------------------------------------
       
  4047 //
       
  4048 TInt CMmCustomTsy::GetPndCacheStatus(
       
  4049     const TTsyReqHandle aTsyReqHandle,
       
  4050     RMmCustomAPI::TPndCacheStatus* aPndStatus,
       
  4051     const TName* aPndName )
       
  4052     {
       
  4053     
       
  4054     TInt error = KErrNone;
       
  4055     // used phonebook is Adn
       
  4056     if ( 0 == aPndName->CompareF( KETelIccAdnPhoneBook ) )
       
  4057         {
       
  4058 TFLOGSTRING2("TSY: CMmCustomTsy::GetPndCacheStatus - ADN phonebook status: %d", iAdnCacheStatus);
       
  4059         *aPndStatus = iAdnCacheStatus;
       
  4060         }
       
  4061     // used phonebook is Fdn
       
  4062     else if ( 0 == aPndName->CompareF( KETelIccFdnPhoneBook ) )
       
  4063         {
       
  4064 TFLOGSTRING2("TSY: CMmCustomTsy::GetPndCacheStatus - FDN phonebook status: %d", iFdnCacheStatus);
       
  4065         *aPndStatus = iFdnCacheStatus;
       
  4066         }
       
  4067     // used phonebook doesn't have cache
       
  4068     else if ( ( 0 == aPndName->CompareF( KETelIccBdnPhoneBook ) ) ||
       
  4069               ( 0 == aPndName->CompareF( KETelIccSdnPhoneBook ) ) ||
       
  4070               ( 0 == aPndName->CompareF( KETelIccVoiceMailBox ) ) )
       
  4071         {
       
  4072 TFLOGSTRING2("TSY: CMmCustomTsy::GetPndCacheStatus - No cache for: %S ", aPndName);
       
  4073         *aPndStatus = RMmCustomAPI::ECacheNotUsed;
       
  4074         }
       
  4075     else
       
  4076         {
       
  4077 TFLOGSTRING2("TSY: CMmCustomTsy::GetPndCacheStatus - No cache found for: %S ", aPndName);        
       
  4078         error = KErrArgument;
       
  4079         }
       
  4080 
       
  4081     ReqCompleted( aTsyReqHandle, error );
       
  4082 
       
  4083     return KErrNone;
       
  4084     }
       
  4085 
       
  4086 // ---------------------------------------------------------------------------
       
  4087 // CMmCustomTsy::UpdateCacheStatus
       
  4088 // This method updates phonebook caching status.
       
  4089 // (other items were commented in a header).
       
  4090 // ---------------------------------------------------------------------------
       
  4091 //
       
  4092 void CMmCustomTsy::UpdateCacheStatus(
       
  4093     RMmCustomAPI::TPndCacheStatus aPndStatus,
       
  4094     TName& aPndName )
       
  4095     {
       
  4096 TFLOGSTRING3("TSY: CMmCustomTsy::UpdateCacheStatus - Phonebook: %S status: %d", &aPndName, aPndStatus);
       
  4097     // if used phonebook is Adn
       
  4098     if ( 0 == aPndName.CompareF( KETelIccAdnPhoneBook ) )
       
  4099         {
       
  4100         iAdnCacheStatus = aPndStatus;
       
  4101         }
       
  4102     // else if used phonebook is Fdn
       
  4103     else if ( 0 == aPndName.CompareF( KETelIccFdnPhoneBook ) )
       
  4104         {
       
  4105         iFdnCacheStatus = aPndStatus;
       
  4106         }
       
  4107     }
       
  4108 
       
  4109 // ---------------------------------------------------------------------------
       
  4110 // CMmCustomTsy::GetNetworkOperatorNameL
       
  4111 // Gets the network operator name from the SIM card.
       
  4112 // (other items were commented in a header).
       
  4113 // ---------------------------------------------------------------------------
       
  4114 //
       
  4115 TInt CMmCustomTsy::GetNetworkOperatorNameL(
       
  4116     TDes* aNetworkOperatorName )
       
  4117     {
       
  4118     // call DOS (no packed parameters)
       
  4119     TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  4120         ECustomGetNetworkProviderNameIPC );
       
  4121 
       
  4122     if ( KErrNone == ret )
       
  4123         {
       
  4124         // save pointer to client space and req handle type
       
  4125         iNetworkOperatorName = aNetworkOperatorName;        
       
  4126         iReqHandleType = ECustomTsyGetNetworkOperatorName;
       
  4127         }
       
  4128 
       
  4129     return ret;
       
  4130     }
       
  4131 
       
  4132 // ---------------------------------------------------------------------------
       
  4133 // CMmCustomTsy::GetNetworkOperatorName
       
  4134 // Completes getting network operator name from SIM card.
       
  4135 // (other items were commented in a header).
       
  4136 // ---------------------------------------------------------------------------
       
  4137 //
       
  4138 void CMmCustomTsy::CompleteGetNetworkOperatorName(
       
  4139     TDes* aName,
       
  4140     TInt aError )
       
  4141     {
       
  4142     // reset req handle. Returns the deleted req handle
       
  4143     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4144         ECustomTsyGetNetworkOperatorName );
       
  4145 
       
  4146     // check if request was called
       
  4147     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4148         {
       
  4149         // check if response was ok
       
  4150         if ( ( KErrNone == aError ) && ( NULL != aName ) )
       
  4151             {
       
  4152             if ( aName->Length() <= iNetworkOperatorName->MaxLength() )
       
  4153                 {            
       
  4154                 // set the information for the client
       
  4155                 *iNetworkOperatorName = *aName;
       
  4156                 }
       
  4157             else
       
  4158                 {
       
  4159                 // client delivered too small buffer
       
  4160                 aError = KErrArgument;               
       
  4161                 }
       
  4162             }
       
  4163 
       
  4164         // reset the internal variable
       
  4165         iNetworkOperatorName = NULL;
       
  4166         // complete
       
  4167         ReqCompleted( reqHandle, aError );
       
  4168         }
       
  4169     }
       
  4170 
       
  4171 // ---------------------------------------------------------------------------
       
  4172 // CMmCustomTsy::GetNetworkOperatorNameCancel
       
  4173 // Cancels getting network operator name from SIM card.
       
  4174 // (other items were commented in a header).
       
  4175 // ---------------------------------------------------------------------------
       
  4176 //
       
  4177 TInt CMmCustomTsy::GetNetworkOperatorNameCancel()
       
  4178     {
       
  4179     // reset the pointer to client space
       
  4180     iNetworkOperatorName = NULL;
       
  4181 
       
  4182     // reset the req handle
       
  4183     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4184         ECustomTsyGetNetworkOperatorName );
       
  4185 
       
  4186     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4187     	{
       
  4188     	// complete with cancel
       
  4189     	ReqCompleted( reqHandle, KErrCancel );
       
  4190     	}
       
  4191 
       
  4192     return KErrNone;
       
  4193     }
       
  4194 
       
  4195 // ---------------------------------------------------------------------------
       
  4196 // CMmCustomTsy::SsAdditionalInfoNotification
       
  4197 // Notification request for additional info message.
       
  4198 // (other items were commented in a header).
       
  4199 // ---------------------------------------------------------------------------
       
  4200 //
       
  4201 TInt CMmCustomTsy::SsAdditionalInfoNotification(
       
  4202     RMmCustomAPI::TSsAdditionalInfo* aSsAdditionalInfo )
       
  4203     {
       
  4204 TFLOGSTRING("TSY: CMmCustomTsy::SsAdditionalInfoNotification");
       
  4205     iRetSsAdditionalInfo = aSsAdditionalInfo;
       
  4206     iReqHandleType = ECustomTsyNotifySsAdditionalInfo;
       
  4207 
       
  4208     return KErrNone;
       
  4209     }
       
  4210 
       
  4211 // ---------------------------------------------------------------------------
       
  4212 // CMmCustomTsy::SsAdditionalInfoNotificationCancel
       
  4213 // Cancels notification request for additional info message.
       
  4214 // (other items were commented in a header).
       
  4215 // ---------------------------------------------------------------------------
       
  4216 //
       
  4217 TInt CMmCustomTsy::SsAdditionalInfoNotificationCancel(
       
  4218     const TTsyReqHandle )
       
  4219     {
       
  4220 TFLOGSTRING("TSY: CMmCustomTsy::SsAdditionalInfoNotificationCancel");
       
  4221     iRetSsAdditionalInfo = NULL;
       
  4222 
       
  4223     // reset reqhandle
       
  4224     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4225         ECustomTsyNotifySsAdditionalInfo );
       
  4226 
       
  4227     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4228     	{
       
  4229     	ReqCompleted( reqHandle, KErrCancel );
       
  4230     	}
       
  4231 
       
  4232     return KErrNone;
       
  4233     }
       
  4234 
       
  4235 // ---------------------------------------------------------------------------
       
  4236 // CMmCustomTsy::CompleteSsAdditionalInfoNotification
       
  4237 // Completes SsAdditionalInfo notification.
       
  4238 // (other items were commented in a header).
       
  4239 // ---------------------------------------------------------------------------
       
  4240 //
       
  4241 void CMmCustomTsy::CompleteSsAdditionalInfoNotification(
       
  4242     RMmCustomAPI::TSsAdditionalInfo* aSsAdditionalInfo,
       
  4243     TInt aError )
       
  4244     {
       
  4245 TFLOGSTRING("TSY: CMmCustomTsy::CompleteSsAdditionalInfoNotification");
       
  4246     // reset req handle. Returns the deleted req handle
       
  4247     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4248         ECustomTsyNotifySsAdditionalInfo );
       
  4249 
       
  4250     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4251         {
       
  4252         // copy data to client
       
  4253         iRetSsAdditionalInfo->iOperationCode =
       
  4254             aSsAdditionalInfo->iOperationCode;
       
  4255         iRetSsAdditionalInfo->iAdditionalInfo.Copy(
       
  4256             aSsAdditionalInfo->iAdditionalInfo );
       
  4257 
       
  4258         // reset pointer to client
       
  4259         iRetSsAdditionalInfo = NULL;
       
  4260 
       
  4261         // Complete the client request
       
  4262         ReqCompleted( reqHandle, aError );
       
  4263         }
       
  4264     }
       
  4265 
       
  4266 // ---------------------------------------------------------------------------
       
  4267 // CMmCustomTsy::CheckTwoDigitDialSupportL
       
  4268 // Checks two digit dialing support from Product Profile.
       
  4269 // (other items were commented in a header).
       
  4270 // ---------------------------------------------------------------------------
       
  4271 //
       
  4272 TInt CMmCustomTsy::CheckTwoDigitDialSupportL(
       
  4273     const TTsyReqHandle aTsyReqHandle,
       
  4274     RMmCustomAPI::TTwoDigitDialSupport* aSupport )
       
  4275     {
       
  4276 TFLOGSTRING("TSY: CMmCustomTsy::CheckTwoDigitDialSupportL");
       
  4277     // save pointer to client space
       
  4278     iTwoDigitDialSupport = aSupport;
       
  4279 
       
  4280     // call DOS
       
  4281     TInt error = Phone()->MessageManager()->HandleRequestL(
       
  4282         ECustomCheckTwoDigitDialSupportIPC );
       
  4283 
       
  4284     if ( KErrNone != error )
       
  4285         {
       
  4286         ReqCompleted( aTsyReqHandle, error );
       
  4287         }
       
  4288     else
       
  4289         {
       
  4290         // Save the req handle type
       
  4291         iReqHandleType = ECustomTsyCheckTwoDigitDialSupport;
       
  4292         }
       
  4293 
       
  4294     return KErrNone;
       
  4295     }
       
  4296 
       
  4297 // ---------------------------------------------------------------------------
       
  4298 // CMmCustomTsy::CheckTwoDigitDialSupport
       
  4299 // Completes a CheckTwoDigitDialSupport request.
       
  4300 // (other items were commented in a header).
       
  4301 // ---------------------------------------------------------------------------
       
  4302 //
       
  4303 void CMmCustomTsy::CompleteCheckTwoDigitDialSupport(
       
  4304      RMmCustomAPI::TTwoDigitDialSupport aTwoDigitDialSupport,
       
  4305      TInt aErrorCode )
       
  4306     {
       
  4307     // reset req handle. Returns the deleted req handle
       
  4308     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4309         ECustomTsyCheckTwoDigitDialSupport );
       
  4310 
       
  4311     // check if request was called
       
  4312     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4313         {
       
  4314         // check if response was ok
       
  4315         if ( KErrNone == aErrorCode )
       
  4316             {
       
  4317             // set the information for the client
       
  4318             *iTwoDigitDialSupport = aTwoDigitDialSupport;
       
  4319             }
       
  4320 
       
  4321         // reset the internal variable
       
  4322         iTwoDigitDialSupport = NULL;
       
  4323         // complete
       
  4324         ReqCompleted( reqHandle, aErrorCode );
       
  4325         }
       
  4326     }
       
  4327 
       
  4328 // ---------------------------------------------------------------------------
       
  4329 // CMmCustomTsy::CheckTwoDigitDialSupportCancel
       
  4330 // Cancels an outstanding CheckTwoDigitDialSupport request.
       
  4331 // (other items were commented in a header).
       
  4332 // ---------------------------------------------------------------------------
       
  4333 //
       
  4334 TInt CMmCustomTsy::CheckTwoDigitDialSupportCancel()
       
  4335     {
       
  4336     // reset the pointer to client data
       
  4337     iTwoDigitDialSupport = NULL;
       
  4338 
       
  4339     // reset the reqhandle
       
  4340     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4341         ECustomTsyCheckTwoDigitDialSupport );
       
  4342 
       
  4343     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4344     	{
       
  4345     	// complete
       
  4346     	ReqCompleted( reqHandle, KErrCancel );
       
  4347     	}
       
  4348 
       
  4349     return KErrNone;
       
  4350     }
       
  4351 
       
  4352 // ---------------------------------------------------------------------------
       
  4353 // CMmCustomTsy::GetOperatorNameL
       
  4354 // Get the programmable operator name of the current network.
       
  4355 // (other items were commented in a header).
       
  4356 // ---------------------------------------------------------------------------
       
  4357 //
       
  4358 TInt CMmCustomTsy::GetOperatorNameL(
       
  4359     const TTsyReqHandle aTsyReqHandle,
       
  4360     RMmCustomAPI::TOperatorNameInfo* aOperatorNameInfo )
       
  4361     {
       
  4362     // save a pointer to client space
       
  4363     iRetOperatorNameInfo = aOperatorNameInfo;
       
  4364 
       
  4365     // call DOS (no packed parameters)
       
  4366     TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  4367         ECustomGetOperatorNameIPC );
       
  4368 
       
  4369     // check result
       
  4370     if ( KErrNone != ret )
       
  4371         {
       
  4372         ReqCompleted( aTsyReqHandle, ret );
       
  4373         }
       
  4374     else
       
  4375         {
       
  4376         // Save the req handle type
       
  4377         iReqHandleType = ECustomTsyGetOperatorName;
       
  4378         }
       
  4379 
       
  4380     return KErrNone;
       
  4381     }
       
  4382 
       
  4383 // ---------------------------------------------------------------------------
       
  4384 // CMmCustomTsy::GetOperatorNameCancel
       
  4385 // Cancels an outstanding GetOperatorName request.
       
  4386 // (other items were commented in a header).
       
  4387 // ---------------------------------------------------------------------------
       
  4388 //
       
  4389 TInt CMmCustomTsy::GetOperatorNameCancel()
       
  4390     {
       
  4391     // reset the pointer to client space
       
  4392     iRetOperatorNameInfo = NULL;
       
  4393 
       
  4394     // reset the req handle
       
  4395     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4396         ECustomTsyGetOperatorName );
       
  4397 
       
  4398     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4399     	{
       
  4400     	// complete with cancel
       
  4401     	ReqCompleted( reqHandle, KErrCancel );
       
  4402     	}
       
  4403 
       
  4404     return KErrNone;
       
  4405     }
       
  4406 
       
  4407 // ---------------------------------------------------------------------------
       
  4408 // CMmCustomTsy::CompleteGetOperatorName
       
  4409 // Completes an outstanding GetOperatorName request.
       
  4410 // (other items were commented in a header).
       
  4411 // ---------------------------------------------------------------------------
       
  4412 //
       
  4413 void CMmCustomTsy::CompleteGetOperatorName(
       
  4414     RMmCustomAPI::TOperatorNameInfo& aOperatorNameInfo,
       
  4415     TInt aErrorValue )
       
  4416     {
       
  4417     // reset the req handle
       
  4418     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4419         ECustomTsyGetOperatorName );
       
  4420 
       
  4421     // check the validity of the handler
       
  4422     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4423         {
       
  4424         if ( KErrNone == aErrorValue )
       
  4425             {
       
  4426             // Copy the programmable operator name info in the client space
       
  4427             *iRetOperatorNameInfo = aOperatorNameInfo;
       
  4428             }
       
  4429         // reset the pointer to client space
       
  4430         iRetOperatorNameInfo = NULL;
       
  4431 
       
  4432         // complete operation
       
  4433         ReqCompleted ( reqHandle, aErrorValue );
       
  4434         }
       
  4435     }
       
  4436 
       
  4437 // ---------------------------------------------------------------------------
       
  4438 // CMmCustomTsy::NotifySsNetworkEvent
       
  4439 // Notifies the client about a network generated SS event.
       
  4440 // (other items were commented in a header).
       
  4441 // ---------------------------------------------------------------------------
       
  4442 //
       
  4443 TInt CMmCustomTsy::NotifySsNetworkEvent(
       
  4444     RMmCustomAPI::TSsTypeAndMode* aSsTypeAndMode,
       
  4445     RMmCustomAPI::TSsInfo* aSsInfo )
       
  4446     {
       
  4447     // save pointer to client data
       
  4448     iSsTypeAndMode = aSsTypeAndMode;
       
  4449     iSsInfo = aSsInfo;
       
  4450 
       
  4451     // set the reqhandle type
       
  4452     iReqHandleType = ECustomTsySsNotification;
       
  4453 
       
  4454     return KErrNone;
       
  4455     }
       
  4456 
       
  4457 // ---------------------------------------------------------------------------
       
  4458 // CMmCustomTsy::NotifySsNetworkEventCancel
       
  4459 // Cancels an outstanding NotifySsNetworkEvent.
       
  4460 // (other items were commented in a header).
       
  4461 // ---------------------------------------------------------------------------
       
  4462 //
       
  4463 TInt CMmCustomTsy::NotifySsNetworkEventCancel()
       
  4464     {
       
  4465     // erase pointers to client data
       
  4466     iSsTypeAndMode = NULL;
       
  4467     iSsInfo = NULL;
       
  4468 
       
  4469     // reset the reqhandle
       
  4470     TTsyReqHandle tsyReqHandle =
       
  4471         iTsyReqHandleStore->ResetTsyReqHandle( ECustomTsySsNotification );
       
  4472 
       
  4473     if ( ECustomTsyReqHandleUnknown != tsyReqHandle )
       
  4474     	{
       
  4475     	// complete with cancel
       
  4476     	ReqCompleted( tsyReqHandle, KErrCancel );
       
  4477     	}
       
  4478 
       
  4479     return KErrNone;
       
  4480     }
       
  4481 
       
  4482 // ---------------------------------------------------------------------------
       
  4483 // CMmCustomTsy::CompleteNotifySsNetworkEvent
       
  4484 // Completes NotifySsNetworkEvent.
       
  4485 // (other items were commented in a header).
       
  4486 // ---------------------------------------------------------------------------
       
  4487 //
       
  4488 void CMmCustomTsy::CompleteNotifySsNetworkEvent(
       
  4489    RMmCustomAPI::TSsTypeAndMode& aSsTypeAndMode,
       
  4490    RMmCustomAPI::TSsInfo& aSsInfo,
       
  4491    TInt aErrorCode )
       
  4492     {
       
  4493     // reset the reqhandle
       
  4494     TTsyReqHandle tsyReqHandle =
       
  4495         iTsyReqHandleStore->ResetTsyReqHandle( ECustomTsySsNotification );
       
  4496 
       
  4497     if ( ECustomTsyReqHandleUnknown != tsyReqHandle )
       
  4498         {
       
  4499         if ( KErrNone == aErrorCode )
       
  4500             {
       
  4501             // save data in client space
       
  4502             *iSsTypeAndMode = aSsTypeAndMode;
       
  4503             *iSsInfo = aSsInfo;
       
  4504             }
       
  4505         // reset the pointers to client space
       
  4506         iSsTypeAndMode = NULL;
       
  4507         iSsInfo = NULL;
       
  4508         // complete
       
  4509         ReqCompleted( tsyReqHandle, aErrorCode );
       
  4510         }
       
  4511     }
       
  4512 
       
  4513 // ---------------------------------------------------------------------------
       
  4514 // CMmCustomTsy::GetProgrammableOperatorLogoL
       
  4515 // Gets the programmable operator logo.
       
  4516 // (other items were commented in a header).
       
  4517 // ---------------------------------------------------------------------------
       
  4518 //
       
  4519 TInt CMmCustomTsy::GetProgrammableOperatorLogoL(
       
  4520     const TTsyReqHandle aTsyReqHandle,
       
  4521     RMmCustomAPI::TOperatorId* aOperatorId,
       
  4522     RMmCustomAPI::TOperatorLogo* aLogo )
       
  4523     {
       
  4524     TTsyReqHandle reqhandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  4525         ECustomTsyGetProgrammableOperatorLogo );
       
  4526 
       
  4527     if ( 0 < reqhandle )
       
  4528         {
       
  4529         // The request is already in processing because of previous request
       
  4530         // Complete request with status value informing the client about
       
  4531         // the situation.
       
  4532         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  4533         }
       
  4534     else
       
  4535         {
       
  4536         // save a pointer to client space
       
  4537         iRetOperatorLogoInfo = aLogo;
       
  4538         iRetOperatorIdInfo = aOperatorId;
       
  4539 
       
  4540         // call DOS
       
  4541         // packed parameter: RMmCustomAPI::TOperatorId
       
  4542         CMmDataPackage dataPackage;
       
  4543         dataPackage.PackData( aOperatorId );
       
  4544         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  4545             ECustomGetProgrammableOperatorLogoIPC, &dataPackage );
       
  4546 
       
  4547         if ( KErrNone != ret )
       
  4548             {
       
  4549             ReqCompleted( aTsyReqHandle, ret );
       
  4550             }
       
  4551         else
       
  4552             {
       
  4553             // Save the req handle type
       
  4554             iReqHandleType = ECustomTsyGetProgrammableOperatorLogo;
       
  4555             }
       
  4556         }
       
  4557 
       
  4558     return KErrNone;
       
  4559     }
       
  4560 
       
  4561 // ---------------------------------------------------------------------------
       
  4562 // CMmCustomTsy::GetProgrammableOperatorLogoCancel
       
  4563 // Cancels an outstanding GetProgrammableOperatorLogo request.
       
  4564 // (other items were commented in a header).
       
  4565 // ---------------------------------------------------------------------------
       
  4566 //
       
  4567 TInt CMmCustomTsy::GetProgrammableOperatorLogoCancel()
       
  4568     {
       
  4569     // reset the pointers
       
  4570     iRetOperatorLogoInfo = NULL;
       
  4571     iRetOperatorIdInfo = NULL;
       
  4572 
       
  4573     // reset the req handle
       
  4574     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4575         ECustomTsyGetProgrammableOperatorLogo );
       
  4576 
       
  4577     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4578     	{
       
  4579     	// complete with cancel
       
  4580     	ReqCompleted( reqHandle, KErrCancel );
       
  4581     	}
       
  4582 
       
  4583     return KErrNone;
       
  4584     }
       
  4585 
       
  4586 // ---------------------------------------------------------------------------
       
  4587 // CMmCustomTsy::CompleteGetProgrammableOperatorLogo
       
  4588 // Completes GetProgrammableOperatorLogo.
       
  4589 // (other items were commented in a header).
       
  4590 // ---------------------------------------------------------------------------
       
  4591 //
       
  4592 void CMmCustomTsy::CompleteGetProgrammableOperatorLogo(
       
  4593     RMmCustomAPI::TOperatorId* aOperatorIdInfo,
       
  4594     RMmCustomAPI::TOperatorLogo* aLogoData,
       
  4595     TInt aErrorValue )
       
  4596     {
       
  4597    
       
  4598     // reset the req handle
       
  4599     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4600         ECustomTsyGetProgrammableOperatorLogo );
       
  4601     
       
  4602     // check the validity of the handler
       
  4603     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4604         {
       
  4605         if ( KErrNone == aErrorValue)
       
  4606             {
       
  4607             // if client has allocated big enough space for logo data, logo data
       
  4608             // is appended into client space pointer
       
  4609             if ( ( aLogoData->iOperatorLogo ) &&
       
  4610                 ( aLogoData->iOperatorLogo->Size() <=
       
  4611                 iRetOperatorLogoInfo->iOperatorLogo->MaxSize() ) )
       
  4612                 {
       
  4613                 // Copy the logo info in the client space
       
  4614                 iRetOperatorLogoInfo->iLogoInfo = aLogoData->iLogoInfo;
       
  4615                 // Copy the logo in the client space
       
  4616                 iRetOperatorLogoInfo->iOperatorLogo->Copy( *(
       
  4617                     aLogoData->iOperatorLogo ) );
       
  4618                 // Copy the operator info in the client space
       
  4619                 *iRetOperatorIdInfo = *aOperatorIdInfo;
       
  4620                 }
       
  4621             else
       
  4622                 {
       
  4623                 // logo will not fit into client space
       
  4624                 aErrorValue = KErrTooBig;
       
  4625                 }
       
  4626             }
       
  4627 
       
  4628         // reset the pointers
       
  4629         iRetOperatorLogoInfo = NULL;
       
  4630         iRetOperatorIdInfo = NULL;
       
  4631 
       
  4632         // complete operation
       
  4633         ReqCompleted ( reqHandle, aErrorValue );
       
  4634         }
       
  4635     }
       
  4636 
       
  4637 // ---------------------------------------------------------------------------
       
  4638 // CMmCustomTsy::SatRefreshCompleteNotification
       
  4639 // Notifies the client of SAT refresh.
       
  4640 // (other items were commented in a header).
       
  4641 // ---------------------------------------------------------------------------
       
  4642 //
       
  4643 TInt CMmCustomTsy::SatRefreshCompleteNotification()
       
  4644     {
       
  4645     iReqHandleType = ECustomTsySatRefreshCompleteNotification;
       
  4646 
       
  4647     return KErrNone;
       
  4648     }
       
  4649 
       
  4650 // ---------------------------------------------------------------------------
       
  4651 // CMmCustomTsy::SatRefreshCompleteNotificationCancel
       
  4652 // Cancels an outstanding asynchronous SatRefreshCompleteNotification request.
       
  4653 // (other items were commented in a header).
       
  4654 // ---------------------------------------------------------------------------
       
  4655 //
       
  4656 TInt CMmCustomTsy::SatRefreshCompleteNotificationCancel(
       
  4657     const TTsyReqHandle aTsyReqHandle )
       
  4658     {
       
  4659     // reset reqhandle
       
  4660     iTsyReqHandleStore->ResetTsyReqHandle(
       
  4661         ECustomTsySatRefreshCompleteNotification );
       
  4662 
       
  4663     // complete with KErrCancel
       
  4664     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  4665 
       
  4666     return KErrNone;
       
  4667     }
       
  4668 
       
  4669 // ---------------------------------------------------------------------------
       
  4670 // CMmCustomTsy::CompleteSatRefreshCompleteNotification
       
  4671 // Completes the notification of SAT refresh to the client.
       
  4672 // (other items were commented in a header).
       
  4673 // ---------------------------------------------------------------------------
       
  4674 //
       
  4675 void CMmCustomTsy::CompleteSatRefreshCompleteNotification()
       
  4676     {
       
  4677     //Note iRefresh is never set to ETrue
       
  4678     
       
  4679     // reset req handle. Returns the deleted req handle
       
  4680     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4681         ECustomTsySatRefreshCompleteNotification );
       
  4682 
       
  4683     // check if handle exists
       
  4684     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4685         {
       
  4686         // complete
       
  4687         ReqCompleted( reqHandle, KErrNone );
       
  4688         // set sat refresh flag off
       
  4689         SetSatRefreshStatus ( EFalse );
       
  4690         //Reset ME ALS info
       
  4691         Phone()->ResetMEAlsInfo();
       
  4692         }
       
  4693     }
       
  4694 
       
  4695 // ---------------------------------------------------------------------------
       
  4696 // CMmCustomTsy::SetSatRefreshStatus
       
  4697 // Sets aSatRefreshStatus into internal variable iIsRefresh.
       
  4698 // (other items were commented in a header).
       
  4699 // ---------------------------------------------------------------------------
       
  4700 //
       
  4701 EXPORT_C void CMmCustomTsy::SetSatRefreshStatus(
       
  4702     TBool aSatRefreshStatus )
       
  4703     {
       
  4704     iIsRefresh = aSatRefreshStatus;
       
  4705     }
       
  4706 
       
  4707 // ---------------------------------------------------------------------------
       
  4708 // CMmCustomTsy::ResetNetServerL
       
  4709 // Resets the net server to previous network selection when user doesn't select
       
  4710 // a network from the network list got in a search.
       
  4711 // (other items were commented in a header).
       
  4712 // ---------------------------------------------------------------------------
       
  4713 //
       
  4714 TInt CMmCustomTsy::ResetNetServerL(
       
  4715     const TTsyReqHandle aTsyReqHandle )
       
  4716     {
       
  4717 TFLOGSTRING("TSY: CMmCustomTsy::ResetNetServerL");
       
  4718     // call DOS (no packed parameters)
       
  4719     TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  4720         ECustomResetNetServerIPC );
       
  4721 
       
  4722     if ( KErrNone != ret )
       
  4723         {
       
  4724         ReqCompleted( aTsyReqHandle, ret );
       
  4725         }
       
  4726     else
       
  4727         {
       
  4728         // Save the req handle type
       
  4729         iReqHandleType = ECustomTsyResetNetServer;
       
  4730         }
       
  4731 
       
  4732     return KErrNone;
       
  4733     }
       
  4734 
       
  4735 // ---------------------------------------------------------------------------
       
  4736 // CMmCustomTsy::CompleteResetNetServer
       
  4737 // Completes a ResetNetServer request.
       
  4738 // (other items were commented in a header).
       
  4739 // ---------------------------------------------------------------------------
       
  4740 //
       
  4741 void CMmCustomTsy::CompleteResetNetServer(
       
  4742     TInt aErrorValue )
       
  4743     {
       
  4744 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteResetNetServer - Error: %d", aErrorValue );
       
  4745     // reset the reqhandle
       
  4746     TTsyReqHandle tsyReqHandle =
       
  4747         iTsyReqHandleStore->ResetTsyReqHandle( ECustomTsyResetNetServer );
       
  4748 
       
  4749     // Check the reqHandle
       
  4750     if ( ECustomTsyReqHandleUnknown != tsyReqHandle )
       
  4751         {
       
  4752         // Check that the error value is not KErrCancel, because this will
       
  4753         // cause panic on the ETEL side - error: EZGO-6WVD5N  
       
  4754         if ( KErrCancel == aErrorValue )
       
  4755             {
       
  4756             // Convert the error value from KErrCancel to KErrNotReady
       
  4757             aErrorValue = KErrNotReady; 
       
  4758             }
       
  4759             
       
  4760 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteResetNetServer - complete with error value: %d", aErrorValue );
       
  4761         ReqCompleted( tsyReqHandle, aErrorValue );
       
  4762         }
       
  4763     }
       
  4764 
       
  4765 // ---------------------------------------------------------------------------
       
  4766 // CMmCustomTsy::NotifyNetworkConnectionFailure
       
  4767 // Notifies of a network connection failure. This failure is so severe that
       
  4768 // the only way to recover is to restart the phone.
       
  4769 // (other items were commented in a header).
       
  4770 // ---------------------------------------------------------------------------
       
  4771 //
       
  4772 TInt CMmCustomTsy::NotifyNetworkConnectionFailure()
       
  4773     {
       
  4774     iReqHandleType = ECustomTsyNotifyNetworkConnectionFailure;
       
  4775 
       
  4776     return KErrNone;
       
  4777     }
       
  4778 
       
  4779 // ---------------------------------------------------------------------------
       
  4780 // CMmCustomTsy::NotifyNetworkConnectionFailureCancel
       
  4781 // Cancels a NotifyNetworkConnectionFailure.
       
  4782 // (other items were commented in a header).
       
  4783 // ---------------------------------------------------------------------------
       
  4784 //
       
  4785 TInt CMmCustomTsy::NotifyNetworkConnectionFailureCancel()
       
  4786     {
       
  4787     // reset the reqhandle
       
  4788     TTsyReqHandle tsyReqHandle =
       
  4789         iTsyReqHandleStore->ResetTsyReqHandle(
       
  4790         ECustomTsyNotifyNetworkConnectionFailure );
       
  4791 
       
  4792     if ( ECustomTsyReqHandleUnknown != tsyReqHandle )
       
  4793     	{
       
  4794     	// complete with cancel
       
  4795     	ReqCompleted( tsyReqHandle, KErrCancel );
       
  4796     	}
       
  4797 
       
  4798     return KErrNone;
       
  4799     }
       
  4800 
       
  4801 // ---------------------------------------------------------------------------
       
  4802 // CMmCustomTsy::CompleteNotifyNetworkConnectionFailure
       
  4803 // Completes NotifyNetworkConnectionFailure.
       
  4804 // (other items were commented in a header).
       
  4805 // ---------------------------------------------------------------------------
       
  4806 //
       
  4807 void CMmCustomTsy::CompleteNotifyNetworkConnectionFailure()
       
  4808     {
       
  4809     // If SIM is inserted complete network connection failure
       
  4810     if ( iMmPhoneTsy->NosBootState()->iSIMReady )
       
  4811         {
       
  4812 TFLOGSTRING("TSY: CMmCustomTsy::CompleteNotifyNetworkConnectionFailure");
       
  4813         // reset the reqhandle
       
  4814         TTsyReqHandle tsyReqHandle =
       
  4815             iTsyReqHandleStore->ResetTsyReqHandle(
       
  4816             ECustomTsyNotifyNetworkConnectionFailure );
       
  4817 
       
  4818         // Check the reqHandle
       
  4819         if( ECustomTsyReqHandleUnknown != tsyReqHandle )
       
  4820             {
       
  4821             ReqCompleted ( tsyReqHandle, KErrNone );
       
  4822             }
       
  4823         }
       
  4824     }
       
  4825 
       
  4826 // ---------------------------------------------------------------------------
       
  4827 // CMmCustomTsy::SsRequestCompleteNotification
       
  4828 // Notification request for "SS request complete".
       
  4829 // (other items were commented in a header).
       
  4830 // ---------------------------------------------------------------------------
       
  4831 //
       
  4832 TInt CMmCustomTsy::SsRequestCompleteNotification(
       
  4833     TInt* aStatus )
       
  4834     {
       
  4835     iRetSsRequestComplete = aStatus;
       
  4836     iReqHandleType = ECustomTsyNotifySsRequestComplete;
       
  4837 
       
  4838     return KErrNone;
       
  4839     }
       
  4840 
       
  4841 // ---------------------------------------------------------------------------
       
  4842 // CMmCustomTsy::CompleteSsRequestCompleteNotification
       
  4843 // Completes notification request for "SS request complete".
       
  4844 // (other items were commented in a header).
       
  4845 // ---------------------------------------------------------------------------
       
  4846 //
       
  4847 void CMmCustomTsy::CompleteSsRequestCompleteNotification(
       
  4848     TInt aSsStatus,
       
  4849     TInt aError )
       
  4850     {
       
  4851     // Reset the req handle. Returns the deleted req handle
       
  4852     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4853         ECustomTsyNotifySsRequestComplete );
       
  4854 
       
  4855     // check if request was called
       
  4856     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4857         {
       
  4858         if ( NULL == iRetSsRequestComplete )
       
  4859             {
       
  4860             ReqCompleted( reqHandle, KErrCorrupt );
       
  4861             }
       
  4862         else
       
  4863             {
       
  4864             *iRetSsRequestComplete = aSsStatus;
       
  4865             iRetSsRequestComplete = NULL;
       
  4866             ReqCompleted( reqHandle, aError );
       
  4867             }
       
  4868         }
       
  4869     }
       
  4870 
       
  4871 // ---------------------------------------------------------------------------
       
  4872 // CMmCustomTsy::SsRequestCompleteNotificationCancel
       
  4873 // Cancels notification request for "SS request complete".
       
  4874 // (other items were commented in a header).
       
  4875 // ---------------------------------------------------------------------------
       
  4876 //
       
  4877 TInt CMmCustomTsy::SsRequestCompleteNotificationCancel(
       
  4878     const TTsyReqHandle )
       
  4879     {
       
  4880     iRetSsRequestComplete = NULL;
       
  4881 
       
  4882     // reset reqhandler
       
  4883     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4884         ECustomTsyNotifySsRequestComplete );
       
  4885 
       
  4886     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4887     	{
       
  4888     	// complete with cancel    	
       
  4889     	ReqCompleted( reqHandle, KErrCancel );
       
  4890     	}
       
  4891 
       
  4892     return KErrNone;
       
  4893     }
       
  4894 
       
  4895 // ---------------------------------------------------------------------------
       
  4896 // CMmCustomTsy::GetSystemNetworkModesL
       
  4897 // This method gets the supported network modes.
       
  4898 // (other items were commented in a header).
       
  4899 // ---------------------------------------------------------------------------
       
  4900 //
       
  4901 TInt CMmCustomTsy::GetSystemNetworkModesL(
       
  4902     const TTsyReqHandle aTsyReqHandle,
       
  4903     TUint32* aSystemNetworkModes )
       
  4904     {
       
  4905     TTsyReqHandle reqhandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  4906         ECustomTsyGetSystemNetworkModes );
       
  4907 
       
  4908     if ( 0 < reqhandle )
       
  4909         {
       
  4910         // The request is already in processing because of previous request
       
  4911         // Complete request with status value informing the client about
       
  4912         // the situation.
       
  4913         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  4914         }
       
  4915     else
       
  4916         {
       
  4917         // save pointer to the packaged life timer info
       
  4918         iSystemNetworkModes = aSystemNetworkModes;
       
  4919         TBool useCurrentRats = EFalse;
       
  4920         // call DOS
       
  4921         CMmDataPackage dataPackage;
       
  4922         dataPackage.PackData( &useCurrentRats );
       
  4923         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  4924             ECustomGetSystemNetworkModesIPC, &dataPackage );
       
  4925 
       
  4926         // Check response of the extension
       
  4927         if ( KErrNone != ret )
       
  4928             {
       
  4929             ReqCompleted( aTsyReqHandle, ret );
       
  4930             }
       
  4931         else
       
  4932             {
       
  4933             // Save the req handle type
       
  4934             iReqHandleType = ECustomTsyGetSystemNetworkModes;
       
  4935             }
       
  4936         }
       
  4937 
       
  4938     return KErrNone;
       
  4939     }
       
  4940 
       
  4941 // ---------------------------------------------------------------------------
       
  4942 // CMmCustomTsy::CompleteGetSystemOrCurrentNetworkModes
       
  4943 // Completes a GetSystemNetworkModes.
       
  4944 // (other items were commented in a header).
       
  4945 // ---------------------------------------------------------------------------
       
  4946 //
       
  4947 void CMmCustomTsy::CompleteGetSystemOrCurrentNetworkModes(
       
  4948     TUint32 aSystemNetworkModes,
       
  4949     TInt aResult )
       
  4950     {
       
  4951     // reset req handle. Returns the deleted req handle
       
  4952     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4953         ECustomTsyGetSystemNetworkModes );
       
  4954 
       
  4955     // check if handle exists
       
  4956     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4957         {
       
  4958         // set the information for the client
       
  4959         *iSystemNetworkModes = aSystemNetworkModes;
       
  4960 
       
  4961         // complete
       
  4962         ReqCompleted( reqHandle, aResult );
       
  4963         }
       
  4964 
       
  4965     // reset req handle. Returns the deleted req handle
       
  4966     reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  4967         ECustomTsyGetCurrentSystemNetworkMode );
       
  4968 
       
  4969     // check if handle exists
       
  4970     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  4971         {
       
  4972         // set the information for the client
       
  4973         *iCurrentNetworkMode = aSystemNetworkModes;
       
  4974 
       
  4975         // complete
       
  4976         ReqCompleted( reqHandle, aResult );
       
  4977         }
       
  4978     }
       
  4979 
       
  4980 // ---------------------------------------------------------------------------
       
  4981 // CMmCustomTsy::GetSystemNetworkModesCancel
       
  4982 // Cancels a GetSystemNetworkModes.
       
  4983 // (other items were commented in a header).
       
  4984 // ---------------------------------------------------------------------------
       
  4985 //
       
  4986 TInt CMmCustomTsy::GetSystemNetworkModesCancel(
       
  4987     const TTsyReqHandle aTsyReqHandle )
       
  4988     {
       
  4989     // reset the pointer to client data
       
  4990     iSystemNetworkModes = NULL;
       
  4991 
       
  4992     // reset the reqhandle
       
  4993     iTsyReqHandleStore->ResetTsyReqHandle(
       
  4994         ECustomTsyGetSystemNetworkModes );
       
  4995 
       
  4996     // complete
       
  4997     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  4998 
       
  4999     return KErrNone;
       
  5000     }
       
  5001 
       
  5002 // ---------------------------------------------------------------------------
       
  5003 // CMmCustomTsy::SetSystemNetworkModeL
       
  5004 // This method sets the system network mode.
       
  5005 // (other items were commented in a header).
       
  5006 // ---------------------------------------------------------------------------
       
  5007 //
       
  5008 TInt CMmCustomTsy::SetSystemNetworkModeL(
       
  5009     const TTsyReqHandle aTsyReqHandle,
       
  5010     RMmCustomAPI::TNetworkModeCaps* aSystemNetworkModeCaps )
       
  5011     {
       
  5012     TTsyReqHandle reqhandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  5013         ECustomTsySetSystemNetworkMode );
       
  5014 
       
  5015     if ( 0 < reqhandle )
       
  5016         {
       
  5017         // The request is already in processing because of previous request
       
  5018         // Complete request with status value informing the client about
       
  5019         // the situation.
       
  5020         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  5021         }
       
  5022     else
       
  5023         {
       
  5024         // call DOS
       
  5025         RMmCustomAPI::TNetworkModeCaps networkModeCaps =
       
  5026             *aSystemNetworkModeCaps;
       
  5027         CMmDataPackage dataPackage;
       
  5028         dataPackage.PackData( &networkModeCaps );
       
  5029         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  5030             ECustomSetSystemNetworkModeIPC, &dataPackage );
       
  5031 
       
  5032         // Check response of the extension
       
  5033         if ( KErrNone != ret )
       
  5034             {
       
  5035             ReqCompleted( aTsyReqHandle, ret );
       
  5036             }
       
  5037         else
       
  5038             {
       
  5039             // Save the req handle type
       
  5040             iReqHandleType = ECustomTsySetSystemNetworkMode;
       
  5041             }
       
  5042         }
       
  5043 
       
  5044     return KErrNone;
       
  5045     }
       
  5046 
       
  5047 // ---------------------------------------------------------------------------
       
  5048 // CMmCustomTsy::CompleteSetSystemNetworkMode
       
  5049 // Completes a SetSystemNetworkMode.
       
  5050 // (other items were commented in a header).
       
  5051 // ---------------------------------------------------------------------------
       
  5052 //
       
  5053 void CMmCustomTsy::CompleteSetSystemNetworkMode(
       
  5054     TInt aResult )
       
  5055     {
       
  5056     // reset req handle. Returns the deleted req handle
       
  5057     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5058         ECustomTsySetSystemNetworkMode );
       
  5059 
       
  5060     // check if handle exists
       
  5061     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  5062         {
       
  5063         // complete
       
  5064         ReqCompleted( reqHandle, aResult );
       
  5065         }
       
  5066     }
       
  5067 
       
  5068 // ---------------------------------------------------------------------------
       
  5069 // CMmCustomTsy::GetCurrentSystemNetworkModeL
       
  5070 // This function gets the current network mode GSM/UMTS/Dual.
       
  5071 // (other items were commented in a header).
       
  5072 // ---------------------------------------------------------------------------
       
  5073 //
       
  5074 TInt CMmCustomTsy::GetCurrentSystemNetworkModeL(
       
  5075     const TTsyReqHandle aTsyReqHandle,
       
  5076     TUint32* aNetworkMode )
       
  5077     {
       
  5078 TFLOGSTRING("CMmCustomTsy::GetCurrentSystemNetworkModeL");
       
  5079     TTsyReqHandle reqhandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  5080         ECustomTsyGetCurrentSystemNetworkMode );
       
  5081 
       
  5082     if ( 0 < reqhandle )
       
  5083         {
       
  5084         // The request is already in processing because of previous request
       
  5085         // Complete request with status value informing the client about
       
  5086         // the situation.
       
  5087         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  5088         }
       
  5089     else
       
  5090         {
       
  5091         iCurrentNetworkMode = aNetworkMode;
       
  5092         // call DOS
       
  5093         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  5094             ECustomGetCurrentSystemNetworkModesIPC );
       
  5095 
       
  5096         if ( KErrNone != ret )
       
  5097             {
       
  5098             ReqCompleted( aTsyReqHandle, ret );
       
  5099             }
       
  5100         else
       
  5101             {
       
  5102             iReqHandleType = ECustomTsyGetCurrentSystemNetworkMode;
       
  5103             }
       
  5104         }
       
  5105 
       
  5106     return KErrNone;
       
  5107     }
       
  5108 
       
  5109 // ---------------------------------------------------------------------------
       
  5110 //  CMmCustomTsy::GetCurrentSystemNetworkModeCancel
       
  5111 //  Cancel outstanding request
       
  5112 // (other items were commented in a header).
       
  5113 // ---------------------------------------------------------------------------
       
  5114 //
       
  5115 TInt CMmCustomTsy::GetCurrentSystemNetworkModeCancel(
       
  5116     const TTsyReqHandle aTsyReqHandle )
       
  5117     {
       
  5118 TFLOGSTRING("CMmCustomTsy::GetCurrentSystemNetworkModeCancel");
       
  5119 
       
  5120     // reset pointer to client data
       
  5121     iCurrentNetworkMode = NULL;
       
  5122 
       
  5123     // reset reqhandle
       
  5124     iTsyReqHandleStore->ResetTsyReqHandle(
       
  5125         ECustomTsyGetCurrentSystemNetworkMode );
       
  5126 
       
  5127     // complete with KErrCancel
       
  5128     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  5129 
       
  5130     return KErrNone;
       
  5131     }
       
  5132 
       
  5133 // ---------------------------------------------------------------------------
       
  5134 // CMmCustomTsy::GetSimFileInfoL
       
  5135 // Gets data from a given location of a given sim file determined by the
       
  5136 // aSimFileInfoPckg parameter. Saves the pointer to the client side store
       
  5137 // buffer for further completion.
       
  5138 // (other items were commented in a header).
       
  5139 // ---------------------------------------------------------------------------
       
  5140 //
       
  5141 TInt CMmCustomTsy::GetSimFileInfoL(
       
  5142     const TTsyReqHandle aTsyReqHandle,
       
  5143     TDes8* aSimFileInfoPckg,
       
  5144     TDes8* aSimResponseBuffer )
       
  5145     {
       
  5146 TFLOGSTRING( "TSY: CMmCustomTsy::GetSimFileInfoL" );
       
  5147     TTsyReqHandle reqHandle =
       
  5148         iTsyReqHandleStore->GetTsyReqHandle( ECustomTsyGetSimFileInfo );
       
  5149 
       
  5150     // Unpack the TSimFileInfo data
       
  5151     RMmCustomAPI::TSimFileInfoPckg* simFileInfoPckg =
       
  5152         ( RMmCustomAPI::TSimFileInfoPckg* ) aSimFileInfoPckg;
       
  5153 
       
  5154     RMmCustomAPI::TSimFileInfo simFileInfo = ( *simFileInfoPckg )();
       
  5155 
       
  5156     if ( 0 < reqHandle )
       
  5157         {
       
  5158         //The request is already in processing because of previous request
       
  5159         //Check if the request is the same than before
       
  5160         
       
  5161         //Check the file path in SIM where file is read, the offset from 
       
  5162         //beginning of the file and amount of data to read
       
  5163         if ( ( KErrNotFound != simFileInfo.iPath.Match( iGetSimFileInfoReq.iPath ) ) 
       
  5164         	&& ( iGetSimFileInfoReq.iOffSet == simFileInfo.iOffSet )
       
  5165         	&& ( iGetSimFileInfoReq.iSize == simFileInfo.iSize ) )
       
  5166         	{
       
  5167 TFLOGSTRING( "TSY: CMmCustomTsy::GetSimFileInfoL - Same info already requested" );
       
  5168 
       
  5169 			TGetSimFileInfoRequest* req = new ( ELeave ) TGetSimFileInfoRequest();
       
  5170 			req->iReqHandle = aTsyReqHandle;
       
  5171 			req->iSimFileInfo = aSimResponseBuffer;
       
  5172 			iGetSimFileInfoRequests.AppendL( req );
       
  5173         	}
       
  5174         else
       
  5175         	{
       
  5176             //Complete request with status value informing the client about
       
  5177             //the situation.
       
  5178             ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  5179         	}
       
  5180         }
       
  5181     else
       
  5182         {
       
  5183         iGetSimFileInfoReq = simFileInfo;
       
  5184         // call DOS
       
  5185         CMmDataPackage dataPackage;
       
  5186         dataPackage.PackData( &simFileInfo );
       
  5187         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  5188             ECustomReadSimFileIPC, &dataPackage );
       
  5189 
       
  5190         // check the return value of the call to DOS
       
  5191         if ( KErrNone != ret )
       
  5192             {
       
  5193             ReqCompleted( aTsyReqHandle, ret );
       
  5194             }
       
  5195         else
       
  5196             {
       
  5197 TFLOGSTRING( "TSY: CMmCustomTsy::GetSimFileInfoL - Save handle" );
       
  5198 	        // Save the req handle type
       
  5199 	        iReqHandleType = ECustomTsyGetSimFileInfo;
       
  5200 			// Save request in queue for completion
       
  5201 	        TGetSimFileInfoRequest* req = new ( ELeave ) TGetSimFileInfoRequest();
       
  5202 			req->iReqHandle = aTsyReqHandle;
       
  5203 			req->iSimFileInfo = aSimResponseBuffer;
       
  5204 			iGetSimFileInfoRequests.AppendL( req );
       
  5205             }
       
  5206         }
       
  5207 
       
  5208     return KErrNone;
       
  5209     }
       
  5210 
       
  5211 // ---------------------------------------------------------------------------
       
  5212 // CMmCustomTsy::GetSimFileInfoCancel
       
  5213 // Cancels an outstanding GetSimFileInfo request.
       
  5214 // (other items were commented in a header).
       
  5215 // ---------------------------------------------------------------------------
       
  5216 //
       
  5217 TInt CMmCustomTsy::GetSimFileInfoCancel( TTsyReqHandle aTsyReqHandle )
       
  5218     {
       
  5219 TFLOGSTRING( "TSY: CMmCustomTsy::GetSimFileInfoCancel" );
       
  5220     
       
  5221 	for ( TInt i = 0; i < iGetSimFileInfoRequests.Count(); i++ )
       
  5222 		{
       
  5223 		TGetSimFileInfoRequest* req = iGetSimFileInfoRequests[ i ];
       
  5224 		if ( aTsyReqHandle == req->iReqHandle )
       
  5225 			{
       
  5226 			//reset the return pointer
       
  5227 	        ReqCompleted( req->iReqHandle, KErrCancel );
       
  5228 			
       
  5229 	        iGetSimFileInfoRequests.Remove( i );
       
  5230 	        iGetSimFileInfoRequests.Compress();
       
  5231 	        
       
  5232 	        //Delete TGetSimFileInfoRequest object
       
  5233 	        delete req;
       
  5234 			}
       
  5235 		}
       
  5236 
       
  5237 	if ( 0 == iGetSimFileInfoRequests.Count() )
       
  5238 		{
       
  5239 	    // reset the reqhandle
       
  5240 	    TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5241 	        ECustomTsyGetSimFileInfo );
       
  5242 	    
       
  5243 		//Destroy Array
       
  5244 		iGetSimFileInfoRequests.ResetAndDestroy();
       
  5245 		}
       
  5246 
       
  5247     return KErrNone;
       
  5248     }
       
  5249 
       
  5250 // ---------------------------------------------------------------------------
       
  5251 // CMmCustomTsy::CompleteGetSimFileInfo
       
  5252 // Completes an outstanding GetSimFileInfo request.
       
  5253 // (other items were commented in a header).
       
  5254 // ---------------------------------------------------------------------------
       
  5255 //
       
  5256 void CMmCustomTsy::CompleteGetSimFileInfo(
       
  5257     TDesC8* aData,
       
  5258     TInt aError )
       
  5259     {
       
  5260 TFLOGSTRING( "TSY: CMmCustomTsy::CompleteGetSimFileInfo" );
       
  5261     
       
  5262     // reset the reqhandle
       
  5263     TTsyReqHandle tsyReqHandle =
       
  5264         iTsyReqHandleStore->ResetTsyReqHandle( ECustomTsyGetSimFileInfo );
       
  5265     
       
  5266     // Check the reqHandle
       
  5267     if ( ECustomTsyReqHandleUnknown != tsyReqHandle )
       
  5268         {
       
  5269         // complete
       
  5270         TInt getSimFileInfoRequestsCount = iGetSimFileInfoRequests.Count();
       
  5271 TFLOGSTRING2( "TSY: CMmCustomTsy::CompleteGetSimFileInfo - Complete %d requests", getSimFileInfoRequestsCount );
       
  5272         
       
  5273 		for ( TInt i = 0; i < getSimFileInfoRequestsCount; i++ )
       
  5274 		    {
       
  5275 		    TGetSimFileInfoRequest* req = iGetSimFileInfoRequests[ i ];
       
  5276 		
       
  5277 		    if ( ( KErrNone == aError ) && aData )
       
  5278 		        {
       
  5279 		        // check the size....
       
  5280 		        if ( req->iSimFileInfo->MaxLength() >= aData->Length() )
       
  5281 		            {
       
  5282 		            req->iSimFileInfo->Copy( *aData );
       
  5283 		            ReqCompleted( req->iReqHandle, aError );
       
  5284 		            }
       
  5285 		        else // data is too big for client's buffer
       
  5286 		            {
       
  5287 		            req->iSimFileInfo->Zero();
       
  5288 		            ReqCompleted( req->iReqHandle, KErrOverflow );
       
  5289 		            }
       
  5290 		        }
       
  5291 		    else
       
  5292 	            {
       
  5293 	            req->iSimFileInfo->Zero();
       
  5294 	            ReqCompleted( req->iReqHandle, aError );
       
  5295 	            }
       
  5296 		    }
       
  5297         }
       
  5298 	
       
  5299     //Destroy Array 
       
  5300     iGetSimFileInfoRequests.ResetAndDestroy();
       
  5301     }
       
  5302 
       
  5303 // ---------------------------------------------------------------------------
       
  5304 // CMmCustomTsy::GetLifeTimeL
       
  5305 // Gets the life timer's information and the manufacturing date of the phone.
       
  5306 // (other items were commented in a header).
       
  5307 // ---------------------------------------------------------------------------
       
  5308 //
       
  5309 TInt CMmCustomTsy::GetLifeTimeL(
       
  5310     const TTsyReqHandle aTsyReqHandle,
       
  5311     TDes8* aLifeTimerInfoPckg )
       
  5312     {
       
  5313     
       
  5314     TInt ret( KErrNone );
       
  5315     TFLOGSTRING ("TSY: CMmCustomTsy::GetLifeTimeL");
       
  5316     if ( sizeof(RMmCustomAPI::TLifeTimeData) != aLifeTimerInfoPckg->MaxLength() )
       
  5317         {
       
  5318         TFLOGSTRING ("TSY: CMmCustomTsy::GetLifeTimeL bad size argument");
       
  5319         // Complete the request with appropiate error        
       
  5320         return KErrArgument;
       
  5321         }
       
  5322     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  5323             ECustomTsyGetLifeTimerInfo  );
       
  5324     if ( ECustomTsyReqHandleUnknown != reqHandle ) 
       
  5325         {
       
  5326 TFLOGSTRING( "TSY: CMmCustomTsy::GetLifeTimeL - ECustomTsyReqHandleUnknown" );
       
  5327         // The request is already in processing because of previous request.
       
  5328         // Complete request with status value informing the client about 
       
  5329         // the situation.
       
  5330         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  5331         }
       
  5332     else
       
  5333         {
       
  5334         // save pointer to the packaged life timer info
       
  5335         iLifeTimerInfoPckg = aLifeTimerInfoPckg;
       
  5336         TFLOGSTRING( "TSY: CMmCustomTsy::GetLifeTimeL - send request" );
       
  5337         iTsyReqHandleStore->SetTsyReqHandle( 
       
  5338                         ECustomTsyGetLifeTimerInfo, aTsyReqHandle );
       
  5339         ret = Phone()->MessageManager()->HandleRequestL(
       
  5340                 ECustomGetLifeTimeIPC);
       
  5341         // Check response of the extension
       
  5342         if ( KErrNone != ret )
       
  5343             {
       
  5344             TFLOGSTRING( "TSY: CMmCustomTsy::GetLifeTimeL - DOS layer returned error " );
       
  5345             TTsyReqHandle tsyReqHandle =
       
  5346                 iTsyReqHandleStore->ResetTsyReqHandle( 
       
  5347                                     ECustomTsyGetLifeTimerInfo );
       
  5348             if ( ECustomTsyReqHandleUnknown != tsyReqHandle )
       
  5349                 {
       
  5350                 TFLOGSTRING( "TSY: CMmCustomTsy::GetLifeTimeL - DOS error - unknown handle" );
       
  5351                 }
       
  5352             ReqCompleted( aTsyReqHandle, ret );
       
  5353             }
       
  5354         }
       
  5355     return KErrNone;
       
  5356     }
       
  5357 
       
  5358 // ---------------------------------------------------------------------------
       
  5359 // CMmCustomTsy::GetLifeTimeCancel
       
  5360 // Cancels an ongoing GetLifeTime request.
       
  5361 // (other items were commented in a header).
       
  5362 // ---------------------------------------------------------------------------
       
  5363 //
       
  5364 TInt CMmCustomTsy::GetLifeTimeCancel()
       
  5365     {
       
  5366     // reset the reqhandle
       
  5367     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5368         ECustomTsyGetLifeTimerInfo );
       
  5369 
       
  5370     // reset pointer to client data
       
  5371     iLifeTimerInfoPckg = NULL;
       
  5372 
       
  5373     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  5374     	{
       
  5375     	// complete with cancel
       
  5376     	ReqCompleted( reqHandle, KErrCancel );
       
  5377     	}
       
  5378 
       
  5379     return KErrNone;
       
  5380     }
       
  5381 
       
  5382 // ---------------------------------------------------------------------------
       
  5383 // CMmCustomTsy::CompleteGetLifeTime
       
  5384 // Completes a GetLifeTime request.
       
  5385 // (other items were commented in a header).
       
  5386 // ---------------------------------------------------------------------------
       
  5387 //
       
  5388 void CMmCustomTsy::CompleteGetLifeTime(
       
  5389     RMmCustomAPI::TLifeTimeData& aLifeTimerData,
       
  5390     TInt aErrorValue )
       
  5391     {
       
  5392     // reset the reqhandle
       
  5393     TTsyReqHandle tsyReqHandle =
       
  5394         iTsyReqHandleStore->ResetTsyReqHandle( ECustomTsyGetLifeTimerInfo );
       
  5395 
       
  5396     // Check the reqHandle
       
  5397     if ( ECustomTsyReqHandleUnknown != tsyReqHandle )
       
  5398         {
       
  5399         // Check if there is error
       
  5400         if ( KErrNone == aErrorValue )
       
  5401             {
       
  5402             // pack the return information
       
  5403             RMmCustomAPI::TLifeTimeDataPckg aPackg ( aLifeTimerData);
       
  5404             // Copy the return info into the client side
       
  5405             (*iLifeTimerInfoPckg) = aPackg;
       
  5406             }
       
  5407         // reset the pointer to client space
       
  5408         iLifeTimerInfoPckg = NULL;
       
  5409         // complete
       
  5410         ReqCompleted( tsyReqHandle, aErrorValue );
       
  5411         }
       
  5412     }
       
  5413 
       
  5414 // ---------------------------------------------------------------------------
       
  5415 // CMmCustomTsy::DeliverCode
       
  5416 // Deliveres code and unblock code.
       
  5417 // (other items were commented in a header).
       
  5418 // ---------------------------------------------------------------------------
       
  5419 //
       
  5420 void CMmCustomTsy::DeliverCodeL(
       
  5421     RMobilePhone::TCodeAndUnblockCode aCodes )
       
  5422     {
       
  5423     iMmSecurityTsy->DeliverCodeL( aCodes );
       
  5424     }
       
  5425 
       
  5426 // ---------------------------------------------------------------------------
       
  5427 // CMmCustomTsy::SetDriveModeL
       
  5428 // This method sets Drive Mode status using the aModeStatus variable.
       
  5429 // (other items were commented in a header).
       
  5430 // ---------------------------------------------------------------------------
       
  5431 //
       
  5432 TInt CMmCustomTsy::SetDriveModeL(
       
  5433     const TTsyReqHandle aTsyReqHandle,
       
  5434     RMmCustomAPI::TSetDriveMode* aModeStatus )
       
  5435     {
       
  5436 TFLOGSTRING3("TSY: CMmCustomTsy::SetDriveModeL - Req handle: %d, Mode status: %d", aTsyReqHandle, *aModeStatus );
       
  5437 	if ( (iUsingFeatureManager) && (iFeatureControl.FeatureSupported(NFeature::KDriveModeCanRestrictMtCalls) == KFeatureSupported) )
       
  5438         {
       
  5439         // get the handle
       
  5440         TTsyReqHandle setDriveModeHandle =
       
  5441             iTsyReqHandleStore->GetTsyReqHandle( ECustomTsySetDriveMode );
       
  5442 
       
  5443         if ( setDriveModeHandle > 0 )
       
  5444             {
       
  5445             // The request is already in processing because of previous
       
  5446             // request. Complete request with status value informing the
       
  5447             // client about the situation.
       
  5448             ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  5449             }
       
  5450         else
       
  5451             {
       
  5452             // call DOS
       
  5453             // packed parameter: TSetDriveMode (mode status)
       
  5454             CMmDataPackage dataPackage;
       
  5455             dataPackage.PackData( aModeStatus );
       
  5456             TInt ret = iMmPhoneTsy->MessageManager()->HandleRequestL(
       
  5457                 ECustomSetDriveModeIPC, &dataPackage );
       
  5458 
       
  5459             // check success
       
  5460             if ( KErrNone != ret )
       
  5461                 {
       
  5462                 ReqCompleted ( aTsyReqHandle, ret );
       
  5463                 }
       
  5464             else
       
  5465                 {
       
  5466                 // Store the request handle
       
  5467                 iReqHandleType = ECustomTsySetDriveMode;
       
  5468                 }
       
  5469             }
       
  5470         }
       
  5471     else
       
  5472         {
       
  5473         ReqCompleted ( aTsyReqHandle, KErrNotSupported );
       
  5474         }
       
  5475 	
       
  5476     return KErrNone;
       
  5477     }
       
  5478 
       
  5479 // ---------------------------------------------------------------------------
       
  5480 // CMmCustomTsy::CompleteSetDriveMode
       
  5481 // Completes a Set Drive Mode request.
       
  5482 // (other items were commented in a header).
       
  5483 // ---------------------------------------------------------------------------
       
  5484 //
       
  5485 void CMmCustomTsy::CompleteSetDriveMode(
       
  5486     TInt aErrorCode )
       
  5487     {
       
  5488 TFLOGSTRING2( "TSY: CMmCustomTsy::CompleteSetDriveMode - Error code: %d", aErrorCode );
       
  5489 	if ( (iUsingFeatureManager) && (iFeatureControl.FeatureSupported(NFeature::KDriveModeCanRestrictMtCalls) == KFeatureSupported) )
       
  5490         {
       
  5491         //Reset req handle, returns the deleted req handle
       
  5492         TTsyReqHandle reqHandle =
       
  5493             iTsyReqHandleStore->ResetTsyReqHandle( ECustomTsySetDriveMode );
       
  5494 
       
  5495         //check if request was called
       
  5496         if( ECustomTsyReqHandleUnknown != reqHandle )
       
  5497             {
       
  5498             //complete
       
  5499             ReqCompleted( reqHandle, aErrorCode );
       
  5500             }
       
  5501         }
       
  5502     }
       
  5503 
       
  5504 // ---------------------------------------------------------------------------
       
  5505 // CMmCustomTsy::IsRequestPossibleInOffLine
       
  5506 // Checks wether a ETel request can be performed or not while offline mode is
       
  5507 // enabled
       
  5508 // (other items were commented in a header).
       
  5509 // ---------------------------------------------------------------------------
       
  5510 //
       
  5511 TBool CMmCustomTsy::IsRequestPossibleInOffline(
       
  5512     TInt aIpc )
       
  5513     {
       
  5514     // we assume here that most of the requests are possible, thefore
       
  5515     // we switch for the not possible ones, optimizing a bit the checking.
       
  5516     TBool isRequestPossible ( ETrue );
       
  5517     // yet another switching function, yeah!
       
  5518     switch ( aIpc )
       
  5519         {
       
  5520         //case ECustomSsAdditionalInfoNotificationIPC: //ok (but shouldn't be
       
  5521                                                        //triggered anyways)
       
  5522         //case ECustomNotifySsRequestCompleteIPC: //ok (but shouldn't be
       
  5523                                                   //triggered anyways)
       
  5524         //case ECustomStartSimCbTopicBrowsingIPC: //ok
       
  5525         //case ECustomGetNextSimCbTopicIPC: //ok
       
  5526         //case ECustomDeleteSimCbTopicIPC: //ok
       
  5527         //case ECustomReadSimFileIPC: //ok
       
  5528         //case ECustomNotifyDtmfEventIPC: //ok (policy is to leave
       
  5529                                           //the notifications as ok)
       
  5530         //case ECustomGetDiagnosticOctetsIPC: //ok (NO?, this only applies to
       
  5531                                               //call so...should be no)
       
  5532         //case ECustomSetAlsBlockedIPC: //ok
       
  5533         //case ECustomGetAlsBlockedIPC: //ok
       
  5534         //case ECustomCheckAlsPpSupportIPC: //ok
       
  5535         //case ECustomGetRemoteAlertingToneStatusIPC:
       
  5536         //case ECustomCallOriginIPC: //ok (only for emergency)
       
  5537         //case ECustomNotifyAlsBlockedChangedIPC: //ok //Notify Als
       
  5538                                                        //Blocked Change
       
  5539         //case ECustomTerminateCallIPC: //ok (or no?) //Terminate a Call
       
  5540         //case ECustomClearCallBlackListIPC: //ok //Clear call blacklist
       
  5541         //case ECustomSimLockActivateIPC: //ok
       
  5542         //case ECustomSimLockDeActivateIPC: //ok
       
  5543         //case EReadViagHomeZoneParamsIPC: //ok
       
  5544         //case EReadViagHomeZoneCacheIPC: //ok
       
  5545         //case EWriteViagHomeZoneCacheIPC: //ok
       
  5546         //case ECustomGetCipheringInfoIPC: //ok
       
  5547         //case ECustomNotifyCipheringInfoChangeIPC: //ok
       
  5548         //case ECustomNotifyNSPSStatusIPC: //ok
       
  5549         case ECustomNetWakeupIPC: //NO
       
  5550         //case ECustomGetNetworkProviderNameIPC: //ok //(info is got from sim)
       
  5551         case ECustomGetOperatorNameIPC: //NO //(there is no operator
       
  5552                                              //available in offline)
       
  5553         //case ECustomGetProgrammableOperatorLogoIPC: //ok
       
  5554         case ECustomResetNetServerIPC: //NO (or yes, but this one is sensible)
       
  5555         //case ECustomNotifyProgrammableOperatorLogoChangeIPC: //ok
       
  5556         //case ECustomNotifyNetworkConnectionFailureIPC: //ok
       
  5557         //case ECustomGetAirTimeDurationIPC: //ok (at least for emergency call)
       
  5558         //case ECustomNotifyPndCacheReadyIPC: //ok
       
  5559         //case ECustomGetPndCacheStatusIPC: //ok
       
  5560         //case ECustomNotifySsNetworkEventIPC: //ok //(shouldn't be possible
       
  5561                                                     //to get any )
       
  5562         //case ECustomCheckTwoDigitDialSupportIPC: //ok
       
  5563         //case ECustomSendAPDUReqIPC: //ok
       
  5564         //case ECustomGetLifeTimeIPC: //ok
       
  5565         //case ECustomIsBlockedIPC: //ok
       
  5566         //case ECustomCheckSecurityCodeIPC: //ok
       
  5567         //case ECustomCheckEmergencyNumberIPC: //ok
       
  5568         //case ECustomSatRefreshCompleteNotificationIPC: //ok
       
  5569         //case ECustomDisablePhoneLockIPC: //ok
       
  5570         //case ECustomGetActivePinIPC: //ok
       
  5571         //case ECustomReleaseFileIPC: //ok
       
  5572         //case ECustomRestartFileIPC: //ok
       
  5573         //case ECustomNotifyEGprsInfoChange: //ok
       
  5574         //case ECustomGetEGprsInfo: //ok
       
  5575         //case EGet3GPBInfoIPC: //ok
       
  5576         //case ECustomSetDriveModeIPC: //ok
       
  5577         //case ECustomReadHSxPAStatusIPC: //ok
       
  5578         //case ECustomWriteHSxPAStatusIPC: //ok
       
  5579         //case ECustomNotifyHSxPAStatusIPC: //ok
       
  5580         //case ECustomNotifyCellInfoChangeIPC: //ok
       
  5581         //case ECustomGetCellInfoIPC: //ok
       
  5582 
       
  5583         //case ECustomGetBandSelectionIPC: //ok
       
  5584         //case ECustomNotifyRemoteAlertingToneStatusChangeIPC: //ok
       
  5585 
       
  5586         case ECustomSetSystemNetworkModeIPC:
       
  5587         case ECustomSetBandSelectionIPC:
       
  5588             isRequestPossible = EFalse;
       
  5589             break;
       
  5590         default:
       
  5591             break;
       
  5592         }
       
  5593 
       
  5594     return isRequestPossible;
       
  5595     }
       
  5596 
       
  5597 // ---------------------------------------------------------------------------
       
  5598 // CMmCustomTsy::CompleteGetCurrentSystemNetworkMode
       
  5599 // Completes Get Current System Network Mode
       
  5600 // (other items were commented in a header).
       
  5601 // ---------------------------------------------------------------------------
       
  5602 //
       
  5603 void CMmCustomTsy::CompleteGetCurrentSystemNetworkMode(
       
  5604     TUint32 aCurrentNetwork,
       
  5605     TInt aResult )
       
  5606     {
       
  5607     // reset req handle. Returns the deleted req handle
       
  5608     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5609         ECustomTsyGetCurrentSystemNetworkMode );
       
  5610 
       
  5611     // check if handle exists
       
  5612     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  5613         {
       
  5614         // set the information for the client
       
  5615         *iCurrentNetworkMode = aCurrentNetwork;
       
  5616 
       
  5617         // reset the varible
       
  5618         iCurrentNetworkMode = NULL;
       
  5619 
       
  5620         // complete
       
  5621         ReqCompleted( reqHandle, aResult );
       
  5622         }
       
  5623     }
       
  5624 
       
  5625 // ---------------------------------------------------------------------------
       
  5626 // CMmCustomTsy::SetSimMessageStatusReadL
       
  5627 // Sets SIM SMS storage status to "read". Implements
       
  5628 // CustomAPI method SetSimMessageStatusRead.
       
  5629 // (other items were commented in a header).
       
  5630 // ---------------------------------------------------------------------------
       
  5631 //
       
  5632 TInt CMmCustomTsy::SetSimMessageStatusReadL(
       
  5633     const TTsyReqHandle aTsyReqHandle,
       
  5634     TTime& aTime,
       
  5635     TInt& aTimezoneDiff )
       
  5636     {
       
  5637     // NOTE: This method asynchronously calls DOS, and then immediately
       
  5638     // completes with KErrNone. Any problems or errors are silently ignored.
       
  5639 
       
  5640     //call DOS
       
  5641     CMmDataPackage dataPackage;
       
  5642     dataPackage.PackData( &aTime, &aTimezoneDiff );
       
  5643     iMmPhoneTsy->MessageManager()->HandleRequestL(
       
  5644         ECustomSetSimMessageStatusReadIPC, &dataPackage );
       
  5645 
       
  5646     // immediately complete, ignore the result.
       
  5647     ReqCompleted( aTsyReqHandle, KErrNone );
       
  5648 
       
  5649     return KErrNone;
       
  5650     }
       
  5651 
       
  5652 // ---------------------------------------------------------------------------
       
  5653 // CMmCustomTsy::ISVDialNumberCheck
       
  5654 // Saves call object for completion
       
  5655 // (other items were commented in a header).
       
  5656 // ---------------------------------------------------------------------------
       
  5657 //
       
  5658 void CMmCustomTsy::SetObjectForISVDialNumberCheck(
       
  5659     CMmVoiceCallTsy* aCallObject )
       
  5660     {
       
  5661 TFLOGSTRING2("TSY: CMmCustomTsy::SetObjectForISVDialNumberCheck aCallObject=%x", aCallObject );
       
  5662     //Save pointer for completion of check emergency number
       
  5663     iISVDialNumberCheckObject = aCallObject;
       
  5664     //ISV dial has been requested
       
  5665     iISVDialNumberCheck = ETrue;
       
  5666     }
       
  5667 
       
  5668 // ---------------------------------------------------------------------------
       
  5669 // CMmCustomTsy::NotifyRauEvent
       
  5670 // Sets RAU event notification
       
  5671 // (other items were commented in a header).
       
  5672 // ---------------------------------------------------------------------------
       
  5673 //
       
  5674 TInt CMmCustomTsy::NotifyRauEvent(
       
  5675     RMmCustomAPI::TRauEventStatus* aEventStatus )
       
  5676     {
       
  5677 TFLOGSTRING("TSY: CMmCustomTsy::NotifyRauEvent");
       
  5678 
       
  5679     // save pointer to client data
       
  5680     iRauEventStatus = aEventStatus;
       
  5681 
       
  5682     // save handle type
       
  5683     iReqHandleType = ECustomTsyNotifyRauEvent;
       
  5684 
       
  5685     return KErrNone;
       
  5686     }
       
  5687 
       
  5688 // ---------------------------------------------------------------------------
       
  5689 // CMmCustomTsy::CompleteNotifyRauEvent
       
  5690 // Completes a NotifyRauEvent request.
       
  5691 // (other items were commented in a header).
       
  5692 // ---------------------------------------------------------------------------
       
  5693 //
       
  5694 void CMmCustomTsy::CompleteNotifyRauEvent(
       
  5695     RMmCustomAPI::TRauEventStatus aEventStatus,
       
  5696     TInt aErrorCode )
       
  5697     {
       
  5698 TFLOGSTRING("TSY: CMmCustomTsy::CompleteNotifyRauEvent");
       
  5699 
       
  5700     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5701         ECustomTsyNotifyRauEvent );
       
  5702 
       
  5703     // check if request was called
       
  5704     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  5705         {
       
  5706         // check if response was ok
       
  5707         if ( KErrNone == aErrorCode )
       
  5708             {
       
  5709             // set the information for the client
       
  5710             *iRauEventStatus = aEventStatus;
       
  5711             }
       
  5712 
       
  5713         // reset the internal variable
       
  5714         iRauEventStatus = NULL;
       
  5715         // complete
       
  5716         ReqCompleted( reqHandle, aErrorCode );
       
  5717         }
       
  5718     }
       
  5719 
       
  5720 // ---------------------------------------------------------------------------
       
  5721 // CMmCustomTsy::NotifyRauEventCancel
       
  5722 // This method cancels an outstanding notification of RAU event, placed with
       
  5723 // the NotifyRauEvent function.
       
  5724 // (other items were commented in a header).
       
  5725 // ---------------------------------------------------------------------------
       
  5726 //
       
  5727 TInt CMmCustomTsy::NotifyRauEventCancel()
       
  5728     {
       
  5729     // reset reqhandle
       
  5730     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( 
       
  5731         ECustomTsyNotifyRauEvent );
       
  5732 
       
  5733     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  5734         {
       
  5735         // reset pointer to client data
       
  5736         iRauEventStatus = NULL;
       
  5737 
       
  5738         ReqCompleted( reqHandle, KErrCancel );
       
  5739         }
       
  5740 
       
  5741     return KErrNone;
       
  5742     }
       
  5743 
       
  5744 // ---------------------------------------------------------------------------
       
  5745 // CMmCustomTsy::ReadHSxPAStatusL
       
  5746 // Read high speed channel status
       
  5747 // (other items were commented in a header).
       
  5748 // ---------------------------------------------------------------------------
       
  5749 //
       
  5750 TInt CMmCustomTsy::ReadHSxPAStatusL(
       
  5751     const TTsyReqHandle aTsyReqHandle,
       
  5752     RMmCustomAPI::THSxPAStatus* aHSxPAStatus )
       
  5753     {
       
  5754 TFLOGSTRING("TSY: CMmCustomTsy::ReadHSxPAStatusL");
       
  5755 
       
  5756     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  5757         ECustomTsyReadHSxPAStatus );
       
  5758 
       
  5759     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  5760         {
       
  5761         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  5762         }
       
  5763     else
       
  5764         {
       
  5765         // save pointer to client data
       
  5766         iRetHSxPAStatus = aHSxPAStatus;
       
  5767 
       
  5768         // call DOS (no packed parameters)
       
  5769         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  5770             ECustomReadHSxPAStatusIPC );
       
  5771 
       
  5772         // check the result of the call
       
  5773         if ( KErrNone != ret )
       
  5774             {
       
  5775             ReqCompleted( aTsyReqHandle, ret );
       
  5776             }
       
  5777         else
       
  5778             {
       
  5779             // Store the request handle
       
  5780             iReqHandleType = ECustomTsyReadHSxPAStatus;
       
  5781             }
       
  5782         }
       
  5783 
       
  5784     return KErrNone;
       
  5785     }
       
  5786 
       
  5787 // ---------------------------------------------------------------------------
       
  5788 // CMmCustomTsy::CompleteReadHSxPAStatus
       
  5789 // Completes a ReadHSxPAStatus request
       
  5790 // (other items were commented in a header).
       
  5791 // ---------------------------------------------------------------------------
       
  5792 //
       
  5793 void CMmCustomTsy::CompleteReadHSxPAStatus(
       
  5794     CMmDataPackage* aDataPackage,
       
  5795     TInt aErrorCode )
       
  5796     {
       
  5797 TFLOGSTRING("TSY: CMmCustomTsy::CompleteReadHSxPAStatus");
       
  5798 
       
  5799     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5800         ECustomTsyReadHSxPAStatus );
       
  5801 
       
  5802     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  5803         {
       
  5804         if ( KErrNone == aErrorCode )
       
  5805             {
       
  5806             RMmCustomAPI::THSxPAStatus status;
       
  5807             aDataPackage->UnPackData( status );
       
  5808 
       
  5809 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteReadHSxPAStatus, status = %d", status);
       
  5810 
       
  5811             // Save the status.
       
  5812             iHSxPAStatus = status;
       
  5813 
       
  5814             // set the information for the client
       
  5815             *iRetHSxPAStatus = status;
       
  5816 
       
  5817             // reset the internal variable
       
  5818             iRetHSxPAStatus = NULL;
       
  5819             //Complete request to success
       
  5820             ReqCompleted( reqHandle, KErrNone );
       
  5821             }
       
  5822         else
       
  5823             {
       
  5824             // Complete with error
       
  5825             ReqCompleted( reqHandle, aErrorCode );
       
  5826             }
       
  5827         }
       
  5828     }
       
  5829 
       
  5830 // ---------------------------------------------------------------------------
       
  5831 // CMmCustomTsy::ReadHSxPAStatusCancel
       
  5832 // Cancels a ReadHSxPAStatus request
       
  5833 // (other items were commented in a header).
       
  5834 // ---------------------------------------------------------------------------
       
  5835 //
       
  5836 TInt CMmCustomTsy::ReadHSxPAStatusCancel()
       
  5837     {
       
  5838 TFLOGSTRING("TSY: CMmCustomTsy::ReadHSxPAStatusCancel");
       
  5839 
       
  5840     // reset the reqhandle
       
  5841     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5842         ECustomTsyReadHSxPAStatus );
       
  5843 
       
  5844     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  5845         {
       
  5846         // reset the pointer to client data
       
  5847         iRetHSxPAStatus = NULL;
       
  5848 
       
  5849         ReqCompleted( reqHandle, KErrCancel );
       
  5850         }
       
  5851 
       
  5852     return KErrNone;
       
  5853     }
       
  5854 
       
  5855 // ---------------------------------------------------------------------------
       
  5856 // CMmCustomTsy::WriteHSxPAStatusL
       
  5857 // Write HSxPAStatus
       
  5858 // (other items were commented in a header).
       
  5859 // ---------------------------------------------------------------------------
       
  5860 //
       
  5861 TInt CMmCustomTsy::WriteHSxPAStatusL(
       
  5862     const TTsyReqHandle aTsyReqHandle,
       
  5863     RMmCustomAPI::THSxPAStatus* aHSxPAStatus )
       
  5864     {
       
  5865 TFLOGSTRING2("TSY: CMmCustomTsy::WriteHSxPAStatusL. New status: %d", *aHSxPAStatus);
       
  5866 
       
  5867     iSetHSxPAStatus = aHSxPAStatus;
       
  5868 
       
  5869     // get the handle
       
  5870     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  5871         ECustomTsyWriteHSxPAStatus );
       
  5872 
       
  5873     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  5874         {
       
  5875         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  5876         }
       
  5877     else
       
  5878         {
       
  5879         CMmDataPackage dataPackage;
       
  5880         dataPackage.PackData( iSetHSxPAStatus );
       
  5881 
       
  5882         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  5883             ECustomWriteHSxPAStatusIPC, &dataPackage );
       
  5884 
       
  5885         if ( KErrNone != ret )
       
  5886             {
       
  5887             ReqCompleted( aTsyReqHandle, ret );
       
  5888             }
       
  5889         else
       
  5890             {
       
  5891             // Save the req handle type
       
  5892             iReqHandleType = ECustomTsyWriteHSxPAStatus;
       
  5893             }
       
  5894         }
       
  5895 
       
  5896     return KErrNone;
       
  5897     }
       
  5898 
       
  5899 // ---------------------------------------------------------------------------
       
  5900 // CMmCustomTsy::CompleteWriteHSxPAStatus
       
  5901 // Complete WriteHSxPAStatus request
       
  5902 // (other items were commented in a header).
       
  5903 // ---------------------------------------------------------------------------
       
  5904 //
       
  5905 void CMmCustomTsy::CompleteWriteHSxPAStatus(
       
  5906     TInt aErrorCode )
       
  5907     {
       
  5908 TFLOGSTRING("TSY: CMmCustomTsy::CompleteWriteHSxPAStatus");
       
  5909 
       
  5910     //reset req handle.
       
  5911     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5912         ECustomTsyWriteHSxPAStatus );
       
  5913 
       
  5914     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  5915         {
       
  5916         if ( KErrNone == aErrorCode )
       
  5917             {
       
  5918             // Save the current status
       
  5919             iHSxPAStatus = *iSetHSxPAStatus;
       
  5920             }
       
  5921 
       
  5922         // erase pointer to client data
       
  5923         iSetHSxPAStatus = NULL;
       
  5924 
       
  5925         ReqCompleted( reqHandle, aErrorCode );
       
  5926         }
       
  5927     }
       
  5928 
       
  5929 // ---------------------------------------------------------------------------
       
  5930 // CMmCustomTsy::WriteHSxPAStatusCancel
       
  5931 // Cancel WriteHSxPAStatus request
       
  5932 // (other items were commented in a header).
       
  5933 // ---------------------------------------------------------------------------
       
  5934 //
       
  5935 TInt CMmCustomTsy::WriteHSxPAStatusCancel()
       
  5936     {
       
  5937 TFLOGSTRING("TSY: CMmCustomTsy::WriteHSxPAStatusCancel");
       
  5938 
       
  5939     // reset the reqhandle
       
  5940     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5941         ECustomTsyWriteHSxPAStatus );
       
  5942 
       
  5943     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  5944         {
       
  5945         // erase pointer to client data
       
  5946         iSetHSxPAStatus = NULL;
       
  5947 
       
  5948         ReqCompleted( reqHandle, KErrCancel );
       
  5949         }
       
  5950 
       
  5951     return KErrNone;
       
  5952     }
       
  5953 
       
  5954 // ---------------------------------------------------------------------------
       
  5955 // CMmCustomTsy::NotifyHSxPAStatus
       
  5956 // Set HSxPA notification
       
  5957 // (other items were commented in a header).
       
  5958 // ---------------------------------------------------------------------------
       
  5959 //
       
  5960 TInt CMmCustomTsy::NotifyHSxPAStatus(
       
  5961     RMmCustomAPI::THSxPAStatus* aHSxPAStatus )
       
  5962     {
       
  5963 TFLOGSTRING("TSY: CMmCustomTsy::NotifyHSxPAStatus");
       
  5964 
       
  5965     // save pointer to client data
       
  5966     iRetNotifyHSxPAStatus = aHSxPAStatus;
       
  5967 
       
  5968     // set the reqhandle type
       
  5969     iReqHandleType = ECustomTsyNotifyHSxPAStatus;
       
  5970 
       
  5971     return KErrNone;
       
  5972     }
       
  5973 
       
  5974 // ---------------------------------------------------------------------------
       
  5975 // CMmCustomTsy::CompleteNotifyHSxPAStatus
       
  5976 // Complete HSxPA notification
       
  5977 // (other items were commented in a header).
       
  5978 // ---------------------------------------------------------------------------
       
  5979 //
       
  5980 void CMmCustomTsy::CompleteNotifyHSxPAStatus(
       
  5981     CMmDataPackage* aDataPackage,
       
  5982     TInt aErrorCode )
       
  5983     {
       
  5984 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteNotifyHSxPAStatus, Error: %d", aErrorCode);
       
  5985 
       
  5986     RMmCustomAPI::THSxPAStatus status;
       
  5987     aDataPackage->UnPackData( status );
       
  5988 
       
  5989 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteNotifyHSxPAStatus, old status: %d", iHSxPAStatus);
       
  5990 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteNotifyHSxPAStatus, new status: %d", status);
       
  5991 
       
  5992     // check if status was changed
       
  5993     if ( iHSxPAStatus != status )
       
  5994         {
       
  5995         // Check if notification was requested
       
  5996         TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  5997             ECustomTsyNotifyHSxPAStatus );
       
  5998 
       
  5999         if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6000             {
       
  6001             // check if response was ok
       
  6002             if ( KErrNone == aErrorCode )
       
  6003                 {
       
  6004                 // Save the status
       
  6005                 iHSxPAStatus = status;
       
  6006 
       
  6007                 // set the information for the client
       
  6008                 *iRetNotifyHSxPAStatus = status;
       
  6009 
       
  6010                 //Complete request to success
       
  6011                 ReqCompleted( reqHandle, KErrNone );
       
  6012                 }
       
  6013             else
       
  6014                 {
       
  6015                 // Complete error value
       
  6016                 ReqCompleted( reqHandle, aErrorCode );
       
  6017                 }
       
  6018 
       
  6019             // reset the internal variable
       
  6020             iRetNotifyHSxPAStatus = NULL;
       
  6021             }
       
  6022         }
       
  6023     }
       
  6024 
       
  6025 // ---------------------------------------------------------------------------
       
  6026 // CMmCustomTsy::NotifyHSxPAStatusCancel
       
  6027 // Cancel HSxPA notification
       
  6028 // (other items were commented in a header).
       
  6029 // ---------------------------------------------------------------------------
       
  6030 //
       
  6031 TInt CMmCustomTsy::NotifyHSxPAStatusCancel()
       
  6032     {
       
  6033 TFLOGSTRING("TSY: CMmCustomTsy::NotifyHSxPAStatusCancel");
       
  6034 
       
  6035     // reset the reqhandle
       
  6036     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6037         ECustomTsyNotifyHSxPAStatus );
       
  6038 
       
  6039     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  6040         {
       
  6041         // reset the pointer to client data
       
  6042         iRetNotifyHSxPAStatus = NULL;
       
  6043 
       
  6044         ReqCompleted( reqHandle, KErrCancel );
       
  6045         }
       
  6046 
       
  6047     return KErrNone;
       
  6048     }
       
  6049 
       
  6050 // ---------------------------------------------------------------------------
       
  6051 // CMmCustomTsy::GetCallForwardingStatusL
       
  6052 // Gets  call forwarding status
       
  6053 // (other items were commented in a header).
       
  6054 // ---------------------------------------------------------------------------
       
  6055 //
       
  6056 TInt CMmCustomTsy::GetIccCallForwardingStatusL(
       
  6057     TTsyReqHandle /*aTsyReqHandle*/,
       
  6058     TDes8* aCFIndicators )
       
  6059     {
       
  6060 TFLOGSTRING("TSY: CMmCustomTsy::GetIccCallForwardingStatusL");
       
  6061 
       
  6062     TInt ret( KErrGeneral );
       
  6063 
       
  6064     //Get reqhandle
       
  6065     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  6066         ECustomTsyGetIccCallForwardingStatus );
       
  6067     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  6068         {
       
  6069         ret = KErrServerBusy;
       
  6070         }
       
  6071     else
       
  6072         {
       
  6073         if(  sizeof(RMmCustomAPI::TCFIndicators) > aCFIndicators->Size())
       
  6074             {
       
  6075             ret = KErrArgument;    
       
  6076             }
       
  6077         else
       
  6078             {
       
  6079             //Store client side pointer
       
  6080             iRetCFIndicators =  aCFIndicators;
       
  6081             
       
  6082             ret = Phone()->MessageManager()->HandleRequestL(
       
  6083                 ECustomGetIccCallForwardingStatusIPC );
       
  6084             
       
  6085             if ( KErrNone == ret )
       
  6086                 {
       
  6087                 // Save the req handle type
       
  6088                 iReqHandleType = ECustomTsyGetIccCallForwardingStatus;
       
  6089                 }
       
  6090             }
       
  6091         }
       
  6092 
       
  6093     return ret;
       
  6094     }
       
  6095 
       
  6096 // ---------------------------------------------------------------------------
       
  6097 // CMmCustomTsy::CompleteGetCallForwardingStatus
       
  6098 // completes gets  call forwarding status request
       
  6099 // (other items were commented in a header).
       
  6100 // ---------------------------------------------------------------------------
       
  6101 //
       
  6102 void CMmCustomTsy::CompleteGetIccCallForwardingStatus(
       
  6103     CMmDataPackage* aDataPackage,
       
  6104     TInt aErrorCode )
       
  6105     {
       
  6106 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteGetIccCallForwardingStatus, aErrorCode=%d", aErrorCode );
       
  6107 
       
  6108     //reset req handle.
       
  6109     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6110         ECustomTsyGetIccCallForwardingStatus );
       
  6111 
       
  6112     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  6113         {
       
  6114         if( KErrNone == aErrorCode )
       
  6115             {
       
  6116             RMmCustomAPI::TCFIndicatorsPckg* tcfIndicatorPckg = REINTERPRET_CAST(
       
  6117                     	RMmCustomAPI::TCFIndicatorsPckg*, iRetCFIndicators );
       
  6118             RMmCustomAPI::TCFIndicators& tcfIndicator = ( *tcfIndicatorPckg )();
       
  6119 
       
  6120             aDataPackage->UnPackData( iCurrentTCFIndicator );
       
  6121 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteGetIccCallForwardingStatus, indicator=%u", iCurrentTCFIndicator.iIndicator );
       
  6122 
       
  6123             tcfIndicator.iIndicator = iCurrentTCFIndicator.iIndicator;
       
  6124                 tcfIndicator.iCFNumber.iTypeOfNumber =
       
  6125             iCurrentTCFIndicator.iCFNumber.iTypeOfNumber;
       
  6126             tcfIndicator.iCFNumber.iNumberPlan =
       
  6127                 iCurrentTCFIndicator.iCFNumber.iNumberPlan;
       
  6128             tcfIndicator.iCFNumber.iTelNumber.Copy(
       
  6129                iCurrentTCFIndicator.iCFNumber.iTelNumber );
       
  6130 
       
  6131 	        // Update CenRep with latest valid data
       
  6132 	        if( &iCurrentTCFIndicator )
       
  6133 	            {
       
  6134 TFLOGSTRING("TSY: CMmCustomTsy::CompleteGetIccCallForwardingStatus : Update Central Repository");
       
  6135 	            TPckg<TUint32> tempPckg( iCurrentTCFIndicator.iIndicator );
       
  6136 	            iCFISCentRep->Set( KCtsyCallForwardingIndicator, tempPckg );
       
  6137 	
       
  6138 	            iCFISPrivateCentRep->Set( KCtsyCallForwardingNumberPlan,
       
  6139 	                iCurrentTCFIndicator.iCFNumber.iNumberPlan );
       
  6140 	            iCFISCentRep->Set( KCtsyCallForwardingNumber,
       
  6141 	                iCurrentTCFIndicator.iCFNumber.iTelNumber );
       
  6142 	            iCFISPrivateCentRep->Set( KCtsyCallForwardingMspId,
       
  6143 	                iCurrentTCFIndicator.iMultipleSubscriberProfileID );
       
  6144 	            }
       
  6145             }
       
  6146         //Erase client side pointer
       
  6147         iRetCFIndicators = NULL;
       
  6148         //Complete
       
  6149         ReqCompleted( reqHandle, aErrorCode );
       
  6150         }
       
  6151 
       
  6152     //Request is made during boot-up done only once
       
  6153     else if( iGetIccCfStatusBootUp )
       
  6154         {
       
  6155         if( KErrNone == aErrorCode )
       
  6156             {
       
  6157             iGetIccCfStatusBootUp = EFalse;
       
  6158             aDataPackage->UnPackData( iCurrentTCFIndicator );
       
  6159 TFLOGSTRING("TSY: CMmCustomTsy::CompleteGetIccCallForwardingStatus CenRep key UnconditionalCFStatus not RESETED.");     
       
  6160 
       
  6161 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteGetIccCallForwardingStatus : Bootup case, KCtsyCallForwardingIndicator indicator=%u", iCurrentTCFIndicator.iIndicator );
       
  6162 
       
  6163             TPckg<TUint32> tempPckg( iCurrentTCFIndicator.iIndicator );
       
  6164             iCFISCentRep->Set( KCtsyCallForwardingIndicator, tempPckg );
       
  6165             iCFISPrivateCentRep->Set( KCtsyCallForwardingNumberPlan,
       
  6166             iCurrentTCFIndicator.iCFNumber.iNumberPlan );
       
  6167             iCFISCentRep->Set( KCtsyCallForwardingNumber,
       
  6168             iCurrentTCFIndicator.iCFNumber.iTelNumber );
       
  6169             iCFISPrivateCentRep->Set( KCtsyCallForwardingMspId,
       
  6170             iCurrentTCFIndicator.iMultipleSubscriberProfileID );
       
  6171 TFLOGSTRING("TSY: CMmCustomTsy::CompleteGetIccCallForwardingStatus CenRep updated."); 			
       
  6172             }
       
  6173         }
       
  6174     }
       
  6175 
       
  6176 // ---------------------------------------------------------------------------
       
  6177 // CMmCustomTsy::GetIccCallForwardingStatusCancel
       
  6178 // Cancels Get icc call forwarding status
       
  6179 // (other items were commented in a header).
       
  6180 // ---------------------------------------------------------------------------
       
  6181 //
       
  6182 TInt CMmCustomTsy::GetIccCallForwardingStatusCancel(
       
  6183 	const TTsyReqHandle aTsyReqHandle )
       
  6184     {
       
  6185 TFLOGSTRING("CMmCustomTsy::GetIccCallForwardingStatusCancel");
       
  6186 	// reset reqhandle
       
  6187 	iTsyReqHandleStore->ResetTsyReqHandle(
       
  6188 			ECustomTsyGetIccCallForwardingStatus );
       
  6189 
       
  6190 	// complete with KErrCancel
       
  6191 	ReqCompleted( aTsyReqHandle, KErrCancel );
       
  6192 
       
  6193 	return KErrNone;
       
  6194     }
       
  6195 	 
       
  6196 // ---------------------------------------------------------------------------
       
  6197 // CMmCustomTsy::GetIccCallForwardingStatusCancel
       
  6198 // Cancels an ongoing GetIccCallForwardingStatus request.
       
  6199 // (other items were commented in a header).
       
  6200 // ---------------------------------------------------------------------------
       
  6201 //
       
  6202 TInt CMmCustomTsy::GetIccCallForwardingStatusCancel()
       
  6203     {
       
  6204     //Reset req handle
       
  6205     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( 
       
  6206         ECustomTsyGetIccCallForwardingStatus );
       
  6207         
       
  6208     //Erase client side pointer
       
  6209     iRetCFIndicators = NULL;
       
  6210     
       
  6211     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6212     	{
       
  6213     	//Complete request with cancel
       
  6214     	ReqCompleted( reqHandle, KErrCancel );
       
  6215     	}
       
  6216     
       
  6217     return KErrNone;
       
  6218     }
       
  6219     
       
  6220 // ---------------------------------------------------------------------------
       
  6221 // CMmCustomTsy::NotifyCallForwardingStatusChange
       
  6222 // Set notification on
       
  6223 // (other items were commented in a header).
       
  6224 // ---------------------------------------------------------------------------
       
  6225 //
       
  6226 TInt CMmCustomTsy::NotifyIccCallForwardingStatusChange(
       
  6227     TDes8* aCFIndicators )
       
  6228     {
       
  6229 
       
  6230     iNotifyCFIndicator = aCFIndicators;
       
  6231     // save handle type
       
  6232     iReqHandleType = ECustomTsyNotifyIccCallForwardingStatusChange;
       
  6233 
       
  6234     return KErrNone;
       
  6235     }
       
  6236 
       
  6237 // ---------------------------------------------------------------------------
       
  6238 // CMmCustomTsy::CompleteNotifyCallForwardingStatusChange
       
  6239 // Notifies client
       
  6240 // (other items were commented in a header).
       
  6241 // ---------------------------------------------------------------------------
       
  6242 //
       
  6243 void CMmCustomTsy::CompleteNotifyIccCallForwardingStatusChange(
       
  6244     CMmDataPackage* aDataPackage,
       
  6245     TInt aErrorCode )
       
  6246     {
       
  6247 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteNotifyIccCallForwardingStatusChange, Error: %d", aErrorCode);
       
  6248 
       
  6249     RMmCustomAPI::TCFIndicators tempNotifyCFIndicator;
       
  6250     aDataPackage->UnPackData( tempNotifyCFIndicator );
       
  6251 
       
  6252     TBool isChanged = IsIccCallForwardingStatusChanged(
       
  6253         tempNotifyCFIndicator );
       
  6254 
       
  6255     // check if information was changed
       
  6256     if ( isChanged )
       
  6257         {
       
  6258         //Update CTSY internal buffer
       
  6259         iCurrentTCFIndicator = tempNotifyCFIndicator;
       
  6260 
       
  6261         if ( KErrNone == aErrorCode )
       
  6262             {  
       
  6263 			//Update CenRep
       
  6264 
       
  6265             TPckg<TUint32> tempPckg( iCurrentTCFIndicator.iIndicator );
       
  6266 			iCFISCentRep->Set( KCtsyCallForwardingIndicator, tempPckg );	
       
  6267 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteNotifyIccCallForwardingStatusChange : Update CenRep, KCtsyCallForwardingIndicator indicator=%u", iCurrentTCFIndicator.iIndicator );
       
  6268 				
       
  6269         	iCFISPrivateCentRep->Set( KCtsyCallForwardingNumberPlan, 
       
  6270         	    iCurrentTCFIndicator.iCFNumber.iNumberPlan );
       
  6271 			
       
  6272         	iCFISCentRep->Set( KCtsyCallForwardingNumber,
       
  6273         	    iCurrentTCFIndicator.iCFNumber.iTelNumber );        
       
  6274 				        		    
       
  6275         	iCFISPrivateCentRep->Set( KCtsyCallForwardingMspId, 
       
  6276         	    iCurrentTCFIndicator.iMultipleSubscriberProfileID );
       
  6277             //CenRep updated
       
  6278 TFLOGSTRING("TSY: CMmCustomTsy::CompleteNotifyIccCallForwardingStatusChange CenRep updated."); 	            
       
  6279             }
       
  6280 
       
  6281         // Check if notification was requested
       
  6282         TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6283             ECustomTsyNotifyIccCallForwardingStatusChange );
       
  6284 
       
  6285         if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6286             {
       
  6287             // check if response was ok
       
  6288             if ( KErrNone == aErrorCode )
       
  6289                 {
       
  6290                 RMmCustomAPI::TCFIndicatorsPckg* tcfIndicatorPckg =
       
  6291                 REINTERPRET_CAST(
       
  6292                 RMmCustomAPI::TCFIndicatorsPckg*, iNotifyCFIndicator );
       
  6293                 RMmCustomAPI::TCFIndicators& tcfIndicator =
       
  6294                 ( *tcfIndicatorPckg )();
       
  6295 
       
  6296                 if( sizeof(RMmCustomAPI::TCFIndicators) > tcfIndicatorPckg->Size())
       
  6297                     {
       
  6298                     ReqCompleted( reqHandle, KErrArgument);
       
  6299                     }
       
  6300                 else
       
  6301                     {
       
  6302                     // Save the new info
       
  6303                     tcfIndicator = tempNotifyCFIndicator;
       
  6304                     //Complete request 
       
  6305                     ReqCompleted( reqHandle, KErrNone );
       
  6306                     }
       
  6307                 }
       
  6308             else
       
  6309                 {
       
  6310                 // Complete with error value
       
  6311                 ReqCompleted( reqHandle, aErrorCode );
       
  6312                 }
       
  6313 
       
  6314             // reset the internal variable
       
  6315             //iNotifyCFIndicator = NULL;
       
  6316             }
       
  6317         }
       
  6318     }
       
  6319 
       
  6320 // ---------------------------------------------------------------------------
       
  6321 // CMmCustomTsy::NotifyCallForwardingStatusChangeCancel
       
  6322 // Cancels notification
       
  6323 // (other items were commented in a header).
       
  6324 // ---------------------------------------------------------------------------
       
  6325 //
       
  6326 TInt CMmCustomTsy::NotifyIccCallForwardingStatusChangeCancel(
       
  6327     const TTsyReqHandle aTsyReqHandle )
       
  6328     {
       
  6329     // reset pointer to client data
       
  6330     iNotifyCFIndicator = NULL;
       
  6331 
       
  6332     // reset reqhandle
       
  6333     iTsyReqHandleStore->ResetTsyReqHandle(
       
  6334         ECustomTsyNotifyIccCallForwardingStatusChange );
       
  6335 
       
  6336     // complete with KErrCancel
       
  6337     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  6338 
       
  6339     return KErrNone;
       
  6340     }
       
  6341 
       
  6342 // ---------------------------------------------------------------------------
       
  6343 // CMmCustomTsy::IsCallForwardingStatusChanged
       
  6344 // Decides if CTSY internal indicator buffer differs from received buffer
       
  6345 // (other items were commented in a header).
       
  6346 // ---------------------------------------------------------------------------
       
  6347 //
       
  6348 TBool CMmCustomTsy::IsIccCallForwardingStatusChanged(
       
  6349     RMmCustomAPI::TCFIndicators& aNotifyCFIndicator )
       
  6350     {
       
  6351     TBool changed( EFalse );
       
  6352 
       
  6353     if( ( aNotifyCFIndicator.iIndicator !=
       
  6354         iCurrentTCFIndicator.iIndicator ) ||
       
  6355         ( aNotifyCFIndicator.iCFNumber.iTypeOfNumber !=
       
  6356         iCurrentTCFIndicator.iCFNumber.iTypeOfNumber ) ||
       
  6357         ( aNotifyCFIndicator.iCFNumber.iNumberPlan !=
       
  6358         iCurrentTCFIndicator.iCFNumber.iNumberPlan ) ||
       
  6359         KErrNotFound == ( aNotifyCFIndicator.iCFNumber.iTelNumber.Match(
       
  6360         iCurrentTCFIndicator.iCFNumber.iTelNumber ) ) )
       
  6361         {
       
  6362         changed = ETrue;
       
  6363         }
       
  6364 
       
  6365     return changed;
       
  6366     }
       
  6367 
       
  6368 // ---------------------------------------------------------------------------
       
  6369 // CMmCustomTsy::GetCellInfoL
       
  6370 // Gets GSM/WCDMA cell(s) info.
       
  6371 // (other items were commented in a header).
       
  6372 // ---------------------------------------------------------------------------
       
  6373 //
       
  6374 TInt CMmCustomTsy::GetCellInfoL(
       
  6375     TDes8* aCellInfoPckg )
       
  6376     {
       
  6377 TFLOGSTRING("TSY: CMmCustomTsy::GetCellInfo");
       
  6378 
       
  6379     TInt ret = KErrServerBusy;
       
  6380 
       
  6381     // Try to get request handle
       
  6382     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  6383         ECustomTsyGetCellInfo );
       
  6384 
       
  6385     if ( ECustomTsyReqHandleUnknown == reqHandle )
       
  6386         {
       
  6387         ret = KErrArgument;
       
  6388         
       
  6389         if ( sizeof( RMmCustomAPI::TMmCellInfo ) <= 
       
  6390              aCellInfoPckg->MaxLength() )
       
  6391             {
       
  6392             iCellInfoPckg = REINTERPRET_CAST(
       
  6393                 RMmCustomAPI::TMmCellInfoPckg*, aCellInfoPckg );
       
  6394 
       
  6395             ret = Phone()->MessageManager()->HandleRequestL(
       
  6396                 ECustomGetCellInfoIPC  );	
       
  6397         
       
  6398     	    if ( KErrNone == ret )
       
  6399     	        {
       
  6400     	        // Save request handle in DoExtFuncL()
       
  6401     	        iReqHandleType = ECustomTsyGetCellInfo;
       
  6402     	        }
       
  6403     	    }
       
  6404 		}
       
  6405 
       
  6406     return ret;
       
  6407     }
       
  6408 
       
  6409 // ---------------------------------------------------------------------------
       
  6410 // CMmCustomTsy::GetCellInfoCancel
       
  6411 // Cancels an outstanding GetCellInfo request.
       
  6412 // (other items were commented in a header).
       
  6413 // ---------------------------------------------------------------------------
       
  6414 //
       
  6415 TInt CMmCustomTsy::GetCellInfoCancel()
       
  6416     {
       
  6417 TFLOGSTRING("TSY: CMmCustomTsy::GetCellInfoCancel");
       
  6418 
       
  6419     // reset the req handle
       
  6420     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6421         ECustomTsyGetCellInfo );
       
  6422 
       
  6423     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  6424         {
       
  6425     	// reset pointer to client data
       
  6426         iCellInfoPckg = NULL;
       
  6427 
       
  6428         // complete with cancel
       
  6429         ReqCompleted( reqHandle, KErrCancel );
       
  6430         }
       
  6431 
       
  6432     return KErrNone;
       
  6433     }
       
  6434 
       
  6435 // ---------------------------------------------------------------------------
       
  6436 // CMmCustomTsy::CompleteGetCellInfo
       
  6437 // Completes an outstanding GetCellInfo request.
       
  6438 // (other items were commented in a header).
       
  6439 // ---------------------------------------------------------------------------
       
  6440 //
       
  6441 void CMmCustomTsy::CompleteGetCellInfo(
       
  6442     RMmCustomAPI::TMmCellInfo* aCellInfo,
       
  6443     TInt aErrorValue )
       
  6444     {
       
  6445 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteGetCellInfo - aErrorValue %d", aErrorValue);
       
  6446 
       
  6447     // reset the req handle
       
  6448     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6449         ECustomTsyGetCellInfo );
       
  6450 
       
  6451     // check the validity of the handler
       
  6452     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6453         {
       
  6454         if ( KErrNone == aErrorValue )
       
  6455             {
       
  6456             RMmCustomAPI::TMmCellInfo& tempCellInfo = ( *iCellInfoPckg )();
       
  6457             tempCellInfo = *aCellInfo;
       
  6458             }
       
  6459         // reset the pointer to client space
       
  6460         iCellInfoPckg = NULL;
       
  6461 
       
  6462         // complete operation
       
  6463         ReqCompleted ( reqHandle, aErrorValue );
       
  6464         }
       
  6465     }
       
  6466 
       
  6467 // ---------------------------------------------------------------------------
       
  6468 // CMmCustomTsy::NotifyCellInfoChange
       
  6469 // Notification cell(s) info changes
       
  6470 // (other items were commented in a header).
       
  6471 // ---------------------------------------------------------------------------
       
  6472 //
       
  6473 TInt CMmCustomTsy::NotifyCellInfoChange(
       
  6474     TDes8* aCellInfoPckg )
       
  6475     {
       
  6476 TFLOGSTRING("TSY: CMmCustomTsy::NotifyCellInfoChange");
       
  6477    
       
  6478     RMmCustomAPI::TMmCellInfo temp;
       
  6479 	RMmCustomAPI::TMmCellInfoPckg tempPckg(temp);
       
  6480 	
       
  6481 	TInt paramLength = aCellInfoPckg->MaxLength();
       
  6482 	TInt expectedLength = tempPckg.MaxLength();
       
  6483 
       
  6484     TInt ret = KErrArgument;
       
  6485 	if (paramLength == expectedLength)
       
  6486 		{
       
  6487 	    iRetNotifyCellInfoPckg = REINTERPRET_CAST( RMmCustomAPI::TMmCellInfoPckg*, aCellInfoPckg );
       
  6488 	    // set the reqhandle type
       
  6489 	    iReqHandleType = ECustomTsyNotifyCellInfoChange;
       
  6490 	    
       
  6491 	    ret = KErrNone;
       
  6492 		}
       
  6493     return ret;
       
  6494     }
       
  6495 
       
  6496 // ---------------------------------------------------------------------------
       
  6497 // CMmCustomTsy::CompleteNotifyCellInfoChange
       
  6498 // Complete cell info change notification
       
  6499 // (other items were commented in a header).
       
  6500 // ---------------------------------------------------------------------------
       
  6501 //
       
  6502 void CMmCustomTsy::CompleteNotifyCellInfoChange(
       
  6503     RMmCustomAPI::TMmCellInfo* aCellInfo,
       
  6504     TInt aErrorCode )
       
  6505     {
       
  6506 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteNotifyCellInfoChange Error: %d", aErrorCode);
       
  6507 
       
  6508     // Check if notification was requested
       
  6509 	TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6510         ECustomTsyNotifyCellInfoChange );
       
  6511 
       
  6512     // check if request was called
       
  6513     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6514         {
       
  6515         // check if response was ok
       
  6516         if ( KErrNone == aErrorCode )
       
  6517             {
       
  6518             // set the information for the client
       
  6519             RMmCustomAPI::TMmCellInfo& tempCellInfo = ( *iRetNotifyCellInfoPckg )();
       
  6520             tempCellInfo = *aCellInfo;
       
  6521             }
       
  6522         // reset the internal variable
       
  6523         iRetNotifyCellInfoPckg = NULL;
       
  6524 
       
  6525         // complete
       
  6526         ReqCompleted( reqHandle, aErrorCode );
       
  6527         }
       
  6528     }
       
  6529 
       
  6530 // ---------------------------------------------------------------------------
       
  6531 // CMmCustomTsy::NotifyCellInfoChangeCancel
       
  6532 // Cancel cell info change notification
       
  6533 // (other items were commented in a header).
       
  6534 // ---------------------------------------------------------------------------
       
  6535 //
       
  6536 TInt CMmCustomTsy::NotifyCellInfoChangeCancel()
       
  6537     {
       
  6538 TFLOGSTRING("TSY: CMmCustomTsy::NotifyCellInfoChangeCancel");
       
  6539 
       
  6540     // reset the reqhandle
       
  6541     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6542         ECustomTsyNotifyCellInfoChange );
       
  6543 
       
  6544     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  6545         {
       
  6546         // reset the pointer to client data
       
  6547         iRetNotifyCellInfoPckg = NULL;
       
  6548 
       
  6549         ReqCompleted( reqHandle, KErrCancel );
       
  6550         }
       
  6551 
       
  6552     return KErrNone;
       
  6553     }
       
  6554 
       
  6555 // ---------------------------------------------------------------------------
       
  6556 // CMmCustomTsy::GetPhonebookCacheStatus
       
  6557 // Get Phonebook cache status
       
  6558 // (other items were commented in a header).
       
  6559 // ---------------------------------------------------------------------------
       
  6560 //
       
  6561 RMmCustomAPI::TPndCacheStatus CMmCustomTsy::GetPhonebookCacheStatus( 
       
  6562     TUint8 aPhoneBookType )
       
  6563     {
       
  6564 TFLOGSTRING("TSY: CMmCustomTsy::GetPhonebookCacheStatus");
       
  6565     RMmCustomAPI::TPndCacheStatus ret( RMmCustomAPI::ECacheNotUsed );
       
  6566 
       
  6567     switch ( aPhoneBookType )
       
  6568         {
       
  6569         case KADNPhoneBook:
       
  6570             ret = iAdnCacheStatus;
       
  6571             break;
       
  6572         case KFDNPhoneBook:
       
  6573             ret = iFdnCacheStatus;
       
  6574             break;
       
  6575         case KSDNPhoneBook:
       
  6576         case KVMBXPhoneBook:
       
  6577         case KMBDNPhoneBook:
       
  6578             ret = RMmCustomAPI::ECacheNotUsed;
       
  6579             break;
       
  6580         }
       
  6581     
       
  6582     return ret;
       
  6583     }
       
  6584 
       
  6585 // ---------------------------------------------------------------------------
       
  6586 // CMmCustomTsy::ReqCompleted
       
  6587 // Completes a request back to the client.
       
  6588 // (other items were commented in a header).
       
  6589 // ---------------------------------------------------------------------------
       
  6590 //
       
  6591 void CMmCustomTsy::ReqCompleted( const TTsyReqHandle aTsyReqHandle,
       
  6592     const TInt aError )
       
  6593     {
       
  6594 TFLOGSTRING3("TSY: CMmCustomTsy::ReqCompleted, aTsyReqHandle=%d, aError=%d", aTsyReqHandle, aError );
       
  6595 
       
  6596 	CTelObject::ReqCompleted ( aTsyReqHandle, aError );
       
  6597 	}
       
  6598 
       
  6599 // ---------------------------------------------------------------------------
       
  6600 // CMmCustomTsy::GetSystemNetworkBandL
       
  6601 // This method gets the supported network band.
       
  6602 // (other items were commented in a header).
       
  6603 // ---------------------------------------------------------------------------
       
  6604 //
       
  6605 TInt CMmCustomTsy::GetSystemNetworkBandL(
       
  6606     const TTsyReqHandle aTsyReqHandle,
       
  6607     RMmCustomAPI::TBandSelection* aSystemNetworkBand,
       
  6608     RMmCustomAPI::TNetworkModeCaps* aSystemNetworkMode )
       
  6609     {
       
  6610 TFLOGSTRING("TSY: CMmCustomTsy::GetSystemNetworkBandL");
       
  6611     TTsyReqHandle reqhandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  6612         ECustomTsyGetSystemNetworkBand );
       
  6613 
       
  6614     if ( ECustomTsyReqHandleUnknown < reqhandle )
       
  6615         {
       
  6616         // The request is already in processing because of previous request
       
  6617         // Complete request with status value informing the client about
       
  6618         // the situation.
       
  6619         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  6620         }
       
  6621     else
       
  6622         {
       
  6623         // save pointer to the packaged life timer info
       
  6624         iAvailableSystemNetworkBand = aSystemNetworkBand;
       
  6625         iSystemNetworkModeCaps = aSystemNetworkMode;
       
  6626         // call DOS
       
  6627         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  6628             ECustomGetBandSelectionIPC );
       
  6629 
       
  6630         // Check response of the extension
       
  6631         if ( KErrNone != ret )
       
  6632             {
       
  6633             ReqCompleted( aTsyReqHandle, ret );
       
  6634             }
       
  6635         else
       
  6636             {
       
  6637             // Save the req handle type
       
  6638             iReqHandleType = ECustomTsyGetSystemNetworkBand;
       
  6639             }
       
  6640         }
       
  6641 
       
  6642     return KErrNone;
       
  6643     }
       
  6644 
       
  6645 // ---------------------------------------------------------------------------
       
  6646 // CMmCustomTsy::CompleteGetSystemNetworkBand
       
  6647 // Completes a GetSystemNetworkBand.
       
  6648 // (other items were commented in a header).
       
  6649 // ---------------------------------------------------------------------------
       
  6650 //
       
  6651 void CMmCustomTsy::CompleteGetSystemNetworkBand(
       
  6652     RMmCustomAPI::TBandSelection aSystemNetworkBand,
       
  6653     RMmCustomAPI::TNetworkModeCaps aSystemNetworkMode,
       
  6654     TInt aResult )
       
  6655     {
       
  6656 TFLOGSTRING2("TSY: CMmCustomTsy::CompleteGetSystemNetworkBand. Result: %d", aResult);
       
  6657     // reset req handle. Returns the deleted req handle
       
  6658     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6659         ECustomTsyGetSystemNetworkBand );
       
  6660 
       
  6661     // check if handle exists
       
  6662     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6663         {
       
  6664         
       
  6665         if ( KErrNone == aResult )
       
  6666             {
       
  6667             // set the information for the client
       
  6668             *iAvailableSystemNetworkBand = aSystemNetworkBand;
       
  6669             if ( *iSystemNetworkModeCaps != aSystemNetworkMode )
       
  6670                 {
       
  6671                 *iSystemNetworkModeCaps = aSystemNetworkMode;
       
  6672                 }
       
  6673             }
       
  6674         
       
  6675         // complete
       
  6676         ReqCompleted( reqHandle, aResult );
       
  6677         }
       
  6678     }
       
  6679     
       
  6680 // ---------------------------------------------------------------------------
       
  6681 // CMmCustomTsy::GetSystemNetworkBandCancel
       
  6682 // Cancels a GetSystemNetworkBand.
       
  6683 // (other items were commented in a header).
       
  6684 // ---------------------------------------------------------------------------
       
  6685 //
       
  6686 TInt CMmCustomTsy::GetSystemNetworkBandCancel(
       
  6687     const TTsyReqHandle aTsyReqHandle )
       
  6688     {
       
  6689 TFLOGSTRING("TSY: CMmCustomTsy::GetSystemNetworkBandCancel");
       
  6690     // reset the pointer to client data
       
  6691     iAvailableSystemNetworkBand = NULL;
       
  6692     iSystemNetworkModeCaps = NULL;
       
  6693 
       
  6694     // reset the reqhandle
       
  6695     iTsyReqHandleStore->ResetTsyReqHandle(
       
  6696         ECustomTsyGetSystemNetworkBand );
       
  6697 
       
  6698     // complete
       
  6699     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  6700 
       
  6701     return KErrNone;
       
  6702     }
       
  6703 
       
  6704 // ---------------------------------------------------------------------------
       
  6705 // CMmCustomTsy::SetSystemNetworkBandL
       
  6706 // This method sets the system network band.
       
  6707 // (other items were commented in a header).
       
  6708 // ---------------------------------------------------------------------------
       
  6709 //
       
  6710 TInt CMmCustomTsy::SetSystemNetworkBandL(
       
  6711     const TTsyReqHandle aTsyReqHandle,
       
  6712     RMmCustomAPI::TBandSelection* aSystemNetworkBand,
       
  6713     RMmCustomAPI::TNetworkModeCaps* aSystemNetworkModeCaps )
       
  6714     {
       
  6715 TFLOGSTRING("TSY: CMmCustomTsy::SetSystemNetworkBandL");
       
  6716     TTsyReqHandle reqhandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  6717         ECustomTsySetSystemNetworkBand );
       
  6718 
       
  6719     if ( ECustomTsyReqHandleUnknown < reqhandle )
       
  6720         {
       
  6721         // The request is already in processing because of previous request
       
  6722         // Complete request with status value informing the client about
       
  6723         // the situation.
       
  6724         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  6725         }
       
  6726     else
       
  6727         {
       
  6728         // call DOS
       
  6729         // The networkband to be set
       
  6730         RMmCustomAPI::TBandSelection networkBand =
       
  6731             *aSystemNetworkBand;
       
  6732         // Used network mode
       
  6733         RMmCustomAPI::TNetworkModeCaps networkMode =
       
  6734             *aSystemNetworkModeCaps;
       
  6735         CMmDataPackage dataPackage;
       
  6736         // Pack network mode and band
       
  6737         dataPackage.PackData( &networkBand, &networkMode );
       
  6738         TInt ret = Phone()->MessageManager()->HandleRequestL(
       
  6739             ECustomSetBandSelectionIPC, &dataPackage );
       
  6740 
       
  6741         // Check response of the extension
       
  6742         if ( KErrNone != ret )
       
  6743             {
       
  6744             ReqCompleted( aTsyReqHandle, ret );
       
  6745             }
       
  6746         else
       
  6747             {
       
  6748             // Save the req handle type
       
  6749             iReqHandleType = ECustomTsySetSystemNetworkBand;
       
  6750             }
       
  6751         }
       
  6752 
       
  6753     return KErrNone;
       
  6754     }
       
  6755 
       
  6756 // ---------------------------------------------------------------------------
       
  6757 // CMmCustomTsy::CompleteSetSystemNetworkBand
       
  6758 // Completes a SetSystemNetworkBand.
       
  6759 // (other items were commented in a header).
       
  6760 // ---------------------------------------------------------------------------
       
  6761 //
       
  6762 void CMmCustomTsy::CompleteSetSystemNetworkBand(
       
  6763     TInt aResult )
       
  6764     {
       
  6765 TFLOGSTRING("TSY: CMmCustomTsy::CompleteSetSystemNetworkBand");
       
  6766     // reset req handle. Returns the deleted req handle
       
  6767     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6768         ECustomTsySetSystemNetworkBand );
       
  6769 
       
  6770     // check if handle exists
       
  6771     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6772         {
       
  6773         // complete
       
  6774         ReqCompleted( reqHandle, aResult );
       
  6775         }
       
  6776     }
       
  6777 
       
  6778 // ---------------------------------------------------------------------------
       
  6779 // CMmCustomTsy::SetIccCfBootUpFlag
       
  6780 // Set new value for ICC CF bootup.
       
  6781 // (other items were commented in a header).
       
  6782 // ---------------------------------------------------------------------------
       
  6783 //
       
  6784 void CMmCustomTsy::SetIccCfBootUpFlag( TBool aBootUp )
       
  6785     {
       
  6786 TFLOGSTRING2("TSY: CMmCustomTsy::SetIccCfBootUpFlag, aBootUp=%d", aBootUp );
       
  6787 
       
  6788     iGetIccCfStatusBootUp = aBootUp;
       
  6789     }
       
  6790     
       
  6791 // ---------------------------------------------------------------------------
       
  6792 // CMmCustomTsy::GetUSIMServiceSupportL
       
  6793 // (other items were commented in a header).
       
  6794 // ---------------------------------------------------------------------------
       
  6795 //
       
  6796 TInt CMmCustomTsy::GetUSIMServiceSupportL(
       
  6797     const TTsyReqHandle aTsyReqHandle,
       
  6798     RMmCustomAPI::TAppSupport* aAppSupport )
       
  6799     {
       
  6800 TFLOGSTRING("TSY: CMmCustomTsy::GetUSIMServiceSupportL");
       
  6801 
       
  6802     TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle(
       
  6803         ECustomTsyGetUSIMServiceSupport );
       
  6804 
       
  6805     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6806         {
       
  6807         ReqCompleted( aTsyReqHandle, KErrServerBusy );
       
  6808         }
       
  6809     else
       
  6810         {
       
  6811         // save pointer to client data
       
  6812         iAppSupport = aAppSupport;
       
  6813 
       
  6814 	    CMmDataPackage appSupportPackage;
       
  6815 	    appSupportPackage.PackData( iAppSupport );
       
  6816 
       
  6817         // call DOS (no packed parameters)
       
  6818         TInt ret = KErrNone;
       
  6819         ret = Phone()->MessageManager()->HandleRequestL(
       
  6820             ECustomGetServiceTableSupportbyApplicationIPC, &appSupportPackage);
       
  6821 
       
  6822         // check the result of the call
       
  6823         if ( KErrNone != ret )
       
  6824             {
       
  6825             ReqCompleted( aTsyReqHandle, ret );
       
  6826             }
       
  6827         else
       
  6828             {
       
  6829             // Store the request handle
       
  6830             iReqHandleType = ECustomTsyGetUSIMServiceSupport;
       
  6831             }
       
  6832         }
       
  6833 
       
  6834     return KErrNone;
       
  6835     }
       
  6836 
       
  6837 // ---------------------------------------------------------------------------
       
  6838 // CMmCustomTsy::CompleteGetUSIMServiceSupport
       
  6839 // Completes a GetUSIMServiceSupport request
       
  6840 // (other items were commented in a header).
       
  6841 // ---------------------------------------------------------------------------
       
  6842 //
       
  6843 void CMmCustomTsy::CompleteGetUSIMServiceSupport(
       
  6844     CMmDataPackage* aDataPackage,
       
  6845     TInt aErrorCode )
       
  6846     {
       
  6847 TFLOGSTRING("TSY: CMmCustomTsy::CompleteGetUSIMServiceSupport");
       
  6848 
       
  6849     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6850         ECustomTsyGetUSIMServiceSupport );
       
  6851 
       
  6852     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  6853         {
       
  6854         if ( KErrNone == aErrorCode )
       
  6855             {
       
  6856             RMmCustomAPI::TAppSupport *appSupport;
       
  6857             aDataPackage->UnPackData( &appSupport );
       
  6858 
       
  6859             // set the information for the client
       
  6860             *iAppSupport = *appSupport;
       
  6861 
       
  6862             // reset the internal variable
       
  6863 			iAppSupport = NULL;
       
  6864 			
       
  6865             //Complete request to success
       
  6866             ReqCompleted( reqHandle, KErrNone );
       
  6867             }
       
  6868         else
       
  6869             {
       
  6870             // Complete with error
       
  6871             ReqCompleted( reqHandle, aErrorCode );
       
  6872             }
       
  6873         }
       
  6874     }
       
  6875 
       
  6876 // ---------------------------------------------------------------------------
       
  6877 // CMmCustomTsy::GetUSIMServiceSupportCancel
       
  6878 // Cancels a GetUSIMServiceSupport request
       
  6879 // (other items were commented in a header).
       
  6880 // ---------------------------------------------------------------------------
       
  6881 //
       
  6882 TInt CMmCustomTsy::GetUSIMServiceSupportCancel()
       
  6883     {
       
  6884 TFLOGSTRING("TSY: CMmCustomTsy::GetUSIMServiceSupportCancel");
       
  6885 
       
  6886     // reset the reqhandle
       
  6887     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6888         ECustomTsyGetUSIMServiceSupport );
       
  6889 
       
  6890     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  6891         {
       
  6892         // reset the pointer to client data
       
  6893 		iAppSupport = NULL;
       
  6894 
       
  6895         ReqCompleted( reqHandle, KErrCancel );
       
  6896         }
       
  6897 
       
  6898     return KErrNone;
       
  6899     }
       
  6900 
       
  6901 // ---------------------------------------------------------------------------
       
  6902 // CMmCustomTsy::NotifyRemoteAlertingToneStatusChange
       
  6903 // Sets Remote Alerting Tone Status Change notification
       
  6904 // (other items were commented in a header).
       
  6905 // ---------------------------------------------------------------------------
       
  6906 //
       
  6907 TInt CMmCustomTsy::NotifyRemoteAlertingToneStatusChange(
       
  6908     RMmCustomAPI::TRemoteAlertingToneStatus* aToneStatus )
       
  6909     {
       
  6910 TFLOGSTRING("TSY: CMmCustomTsy::NotifyRemoteAlertingToneStatusChange");
       
  6911 
       
  6912     // save pointer to client data
       
  6913     iToneStatus = aToneStatus;
       
  6914 
       
  6915     // save handle type
       
  6916     iReqHandleType = ECustomTsyNotifyRemoteAlertingToneStatusChange;
       
  6917 
       
  6918     return KErrNone;
       
  6919     }
       
  6920 
       
  6921 // ---------------------------------------------------------------------------
       
  6922 // CMmCustomTsy::CompleteNotifyRemoteAlertingToneStatusChange
       
  6923 // Completes a NotifyRemoteToneAlertingStatusChange request.
       
  6924 // (other items were commented in a header).
       
  6925 // ---------------------------------------------------------------------------
       
  6926 //
       
  6927 void CMmCustomTsy::CompleteNotifyRemoteAlertingToneStatusChange(
       
  6928     RMmCustomAPI::TRemoteAlertingToneStatus aToneStatus,
       
  6929     TInt aErrorCode )
       
  6930     {
       
  6931 TFLOGSTRING("TSY: CMmCustomTsy::CompleteNotifyRemoteAlertingToneStatusChange");
       
  6932 
       
  6933     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  6934         ECustomTsyNotifyRemoteAlertingToneStatusChange );
       
  6935 
       
  6936     // check if request was called
       
  6937     if ( ECustomTsyReqHandleUnknown != reqHandle )
       
  6938         {
       
  6939         // check if response was ok
       
  6940         if ( KErrNone == aErrorCode )
       
  6941             {
       
  6942             // set the information for the client
       
  6943             *iToneStatus = aToneStatus;
       
  6944             }
       
  6945 
       
  6946         // reset the internal variable
       
  6947         iToneStatus = NULL;
       
  6948         // complete
       
  6949         ReqCompleted( reqHandle, aErrorCode );
       
  6950         }
       
  6951     }
       
  6952 
       
  6953 // ---------------------------------------------------------------------------
       
  6954 // CMmCustomTsy::NotifyRemoteAlertingToneStatusChangeCancel
       
  6955 // This method cancels an outstanding notification of 
       
  6956 // RemoteAlertingToneStatusChange.
       
  6957 // (other items were commented in a header).
       
  6958 // ---------------------------------------------------------------------------
       
  6959 //
       
  6960 TInt CMmCustomTsy::NotifyRemoteAlertingToneStatusChangeCancel()
       
  6961     {
       
  6962     // reset reqhandle
       
  6963     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( 
       
  6964         ECustomTsyNotifyRemoteAlertingToneStatusChange );
       
  6965 
       
  6966     if( ECustomTsyReqHandleUnknown != reqHandle )
       
  6967         {
       
  6968         // reset pointer to client data
       
  6969         iToneStatus = NULL;
       
  6970 
       
  6971         ReqCompleted( reqHandle, KErrCancel );
       
  6972         }
       
  6973 
       
  6974     return KErrNone;
       
  6975     }
       
  6976 
       
  6977 //  End of File