satengine/SatServer/Engine/src/csatmultimodeapi.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Encapsule the access to etelmm API in sat
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include    <mmtsy_names.h>
       
    20 #include    "csatmultimodeapi.h"
       
    21 #include    "csatsactivewrapper.h"
       
    22 #include    "SatLog.h"
       
    23 
       
    24 #ifdef SAT_USE_DUMMY_TSY
       
    25     _LIT( KSatSDummyTsyModuleName, "DSAT" );
       
    26     _LIT( KSatSDummyTsyPhoneName, "DMobile" );
       
    27 #endif
       
    28 
       
    29 const TInt KLoopMaxTryouts = 5;
       
    30 const TInt KLoopTimeout = 3000000;
       
    31 
       
    32 // ================= MEMBER FUNCTIONS ==========================================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // Class constructor.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CSatMultiModeApi::CSatMultiModeApi()
       
    39     {
       
    40     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::CSatMultiModeApi calling-exiting" )
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // Destructor
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CSatMultiModeApi::~CSatMultiModeApi()
       
    48     {
       
    49     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::~CSatMultiModeApi calling" )
       
    50 
       
    51     if ( iCallOpened )
       
    52         {
       
    53         iCall.Close();
       
    54         }
       
    55     
       
    56     if ( iLineOpened )
       
    57         {
       
    58         iLine.Close();
       
    59         }
       
    60     
       
    61     if ( iUssdOpened )
       
    62         {
       
    63         iUssd.Close();
       
    64         }
       
    65         
       
    66     iCustomPhone.Close();
       
    67     
       
    68     iPhone.Close();
       
    69 
       
    70 #ifdef SAT_USE_DUMMY_TSY
       
    71     iDummyPhone.Close();
       
    72 #endif
       
    73     iTelServer.Close();
       
    74             
       
    75     delete iWrapper;
       
    76     iWrapper = NULL;
       
    77 
       
    78     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::~CSatMultiModeApi calling" )
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CSatMultiModeApi::NewL
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CSatMultiModeApi* CSatMultiModeApi::NewL()
       
    86     {
       
    87     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::NewL calling" )
       
    88 
       
    89     CSatMultiModeApi* self = new( ELeave )CSatMultiModeApi();
       
    90     CleanupStack::PushL( self );
       
    91     self->ConstructL();
       
    92     CleanupStack::Pop( self );
       
    93     
       
    94     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::NewL calling" )
       
    95     return self;
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CSatMultiModeApi::Phone
       
   100 // (other items were commented in a header).
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 RMobilePhone* CSatMultiModeApi::Phone()
       
   104     {
       
   105     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::Phone calling-exiting" )
       
   106     return &iPhone;
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CSatMultiModeApi::Phone
       
   111 // (other items were commented in a header).
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 RMobilePhone* CSatMultiModeApi::DummyPhone()
       
   115     {
       
   116     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::Phone calling-exiting" )
       
   117 #ifdef SAT_USE_DUMMY_TSY
       
   118     return &iDummyPhone;
       
   119 #else
       
   120     return NULL;
       
   121 #endif
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CSatMultiModeApi::CustomApi
       
   126 // (other items were commented in a header).
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 RMmCustomAPI* CSatMultiModeApi::CustomApi()
       
   130     {
       
   131     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::CustomApi calling-exiting" )
       
   132     return &iCustomPhone;
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CSatMultiModeApi::LowerErrorGranularity
       
   137 // (other items were commented in a header).
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CSatMultiModeApi::LowerErrorGranularity()
       
   141     {
       
   142     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::LowerErrorGranularity \
       
   143         calling-exiting" )
       
   144     iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorBasic );
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CSatMultiModeApi::RaiseErrorGranularity
       
   149 // (other items were commented in a header).
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 void CSatMultiModeApi::RaiseErrorGranularity()
       
   153     {
       
   154     LOG( NORMAL, "SATENGINE: CSatMultiModeApi::RaiseErrorGranularity \
       
   155         calling-exiting" )
       
   156     iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended );
       
   157     }
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CSatMultiModeApi::GetNetworkRegistrationStatus
       
   161 // (other items were commented in a header).
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 void CSatMultiModeApi::GetNetworkRegistrationStatus( 
       
   165         TRequestStatus& aReqStatus, 
       
   166         RMobilePhone::TMobilePhoneRegistrationStatus& aStatus)
       
   167     {
       
   168     LOG( SIMPLE, 
       
   169     "SATENGINE: CSatMultiModeApi::GetNetworkRegistrationStatus calling" )
       
   170 
       
   171     iPhone.GetNetworkRegistrationStatus( aReqStatus, aStatus );
       
   172 
       
   173     LOG( SIMPLE,
       
   174      "SATENGINE: CSatMultiModeApi::GetNetworkRegistrationStatus exiting" )
       
   175     }
       
   176 // -----------------------------------------------------------------------------
       
   177 // CSatMultiModeApi::NotifyNetworkRegistrationStatusChange
       
   178 // (other items were commented in a header).
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 void CSatMultiModeApi::NotifyNetworkRegistrationStatusChange(
       
   182         TRequestStatus& aReqStatus, 
       
   183         RMobilePhone::TMobilePhoneRegistrationStatus& aStatus)
       
   184     {    
       
   185     LOG( SIMPLE, "SATENGINE: \
       
   186     CSatMultiModeApi::NotifyNetworkRegistrationStatusChange calling" )
       
   187     
       
   188     iPhone.NotifyNetworkRegistrationStatusChange( aReqStatus, aStatus );
       
   189     
       
   190     LOG( SIMPLE, "SATENGINE: \
       
   191     CSatMultiModeApi::NotifyNetworkRegistrationStatusChange exiting" )
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CSatMultiModeApi::GetSubscriberId
       
   196 // (other items were commented in a header).
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 void CSatMultiModeApi::GetSubscriberId(TRequestStatus& aReqStatus, 
       
   200         RMobilePhone::TMobilePhoneSubscriberId& aId)
       
   201     {
       
   202     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::GetSubscriberId calling" )
       
   203     iPhone.GetSubscriberId( aReqStatus, aId );
       
   204     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::GetSubscriberId exiting" )
       
   205     }
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // CSatMultiModeApi::SendDTMFTones
       
   209 // (other items were commented in a header).
       
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 void CSatMultiModeApi::SendDTMFTones( TRequestStatus& aReqStatus, 
       
   213         const TDesC& aTones)
       
   214     {
       
   215     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::SendDTMFTones calling" )
       
   216     iPhone.SendDTMFTones( aReqStatus, aTones );
       
   217     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::SendDTMFTones exiting" )
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CSatMultiModeApi::ContinueDTMFStringSending
       
   222 // (other items were commented in a header).
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 TInt CSatMultiModeApi::ContinueDTMFStringSending( TBool aContinue )
       
   226     {
       
   227     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::ContinueDTMFStringSending" )
       
   228     return iPhone.ContinueDTMFStringSending( aContinue );
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CSatMultiModeApi::DialNoFdnCheck
       
   233 // (other items were commented in a header).
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 void CSatMultiModeApi::DialNoFdnCheck( TRequestStatus& aStatus,
       
   237         const TDesC8& aCallParams, const TDesC& aTelNumber)
       
   238     {
       
   239     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::DialNoFdnCheck calling" )
       
   240     TInt err = LoadMobileCall();
       
   241     LOG2( SIMPLE, "SATENGINE: CSatMultiModeApi::DialNoFdnCheck err %d", err )
       
   242     
       
   243     iCall.DialNoFdnCheck( aStatus, aCallParams, aTelNumber );
       
   244     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::DialNoFdnCheck exiting" )
       
   245     }
       
   246                         
       
   247 // -----------------------------------------------------------------------------
       
   248 // CSatMultiModeApi::SendNetworkServiceRequestNoFdnCheck
       
   249 // (other items were commented in a header).
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 void CSatMultiModeApi::SendNetworkServiceRequestNoFdnCheck( 
       
   253         TRequestStatus& aReqStatus, const TDesC& aServiceString)
       
   254                        
       
   255     {
       
   256     LOG( SIMPLE, "SATENGINE: \
       
   257             CSatMultiModeApi::SendNetworkServiceRequestNoFdnCheck calling" )
       
   258     
       
   259     iPhone.SendNetworkServiceRequestNoFdnCheck( aReqStatus, aServiceString );
       
   260     
       
   261     LOG( SIMPLE, "SATENGINE: \
       
   262             CSatMultiModeApi::SendNetworkServiceRequestNoFdnCheck exiting" )
       
   263     }
       
   264                                 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CSatMultiModeApi::SendMessageNoFdnCheck
       
   267 // (other items were commented in a header).
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 void CSatMultiModeApi::SendMessageNoFdnCheck( TRequestStatus& aReqStatus,
       
   271             const TDesC8& aMsgData, const TDesC8& aMsgAttributes )
       
   272     {
       
   273     LOG( SIMPLE,
       
   274         "SATENGINE: CSatMultiModeApi::SendMessageNoFdnCheck calling" )
       
   275     
       
   276     iUssd.SendMessageNoFdnCheck( aReqStatus, aMsgData, aMsgAttributes );
       
   277     
       
   278     LOG( SIMPLE, 
       
   279         "SATENGINE: CSatMultiModeApi::SendMessageNoFdnCheck exiting" )
       
   280     }
       
   281 
       
   282 // -----------------------------------------------------------------------------
       
   283 // CSatMultiModeApi::CancelAsyncRequest
       
   284 // (other items were commented in a header).
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 void CSatMultiModeApi::CancelAsyncRequest(TInt aReqToCancel)
       
   288     {
       
   289     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::CancelAsyncRequest calling" )
       
   290     iPhone.CancelAsyncRequest( aReqToCancel );
       
   291     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::CancelAsyncRequest exiting" )
       
   292     }
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // CSatMultiModeApi::DialCancel
       
   296 // (other items were commented in a header).
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 void CSatMultiModeApi::DialCancel()
       
   300     {
       
   301     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::DialCancel calling" )
       
   302     iCall.DialCancel();
       
   303     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::DialCancel exiting" )
       
   304     }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CSatMultiModeApi::GetCurrentActiveUSimApplication
       
   308 // (other items were commented in a header).
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 void CSatMultiModeApi::GetCurrentActiveUSimApplication(
       
   312                          TRequestStatus& aReqStatus, RMobilePhone::TAID& aAID )
       
   313     {
       
   314     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::\
       
   315             GetCurrentActiveUSimApplication calling" )
       
   316     iPhone.GetCurrentActiveUSimApplication( aReqStatus,aAID );
       
   317     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::\
       
   318             GetCurrentActiveUSimApplication exiting" )
       
   319     }
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CSatMultiModeApi::IsCallIncoming
       
   323 // (other items were commented in a header).
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 TBool CSatMultiModeApi::IsCallIncoming()
       
   327     {
       
   328     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::IsCallIncoming entering" )
       
   329     TInt lines( 0 );
       
   330     TBool callIncoming( EFalse );
       
   331 
       
   332     // Enumerate all lines in the phone
       
   333     TInt err( iPhone.EnumerateLines( lines ) );
       
   334 
       
   335     if ( KErrNone == err )
       
   336         {
       
   337         RPhone::TLineInfo lineInfo;
       
   338         // Check the lines' status one by one
       
   339         for( TInt i = 0; ( i < lines ) && !callIncoming; ++i )
       
   340             {
       
   341             err = iPhone.GetLineInfo( i, lineInfo ); 
       
   342             if ( KErrNone == err )
       
   343                 {
       
   344                 LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::IsCallIncoming \
       
   345                     line status is %d", lineInfo.iStatus )
       
   346                 if ( ( RCall::EStatusDialling == lineInfo.iStatus ) ||
       
   347                      ( RCall::EStatusRinging == lineInfo.iStatus ) )
       
   348                     {
       
   349                     // There is an incoming call
       
   350                     callIncoming = ETrue;
       
   351                     }
       
   352                 }
       
   353             else
       
   354                 {
       
   355                 // Error happened when getting line info
       
   356                 // We currently do nothing but skip the error line and log it
       
   357                 LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::IsCallIncoming \
       
   358                     getting line status error %d", err )
       
   359                 }
       
   360             }
       
   361         }
       
   362     else
       
   363         {
       
   364         // Enumerate lines error
       
   365         LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::IsCallIncoming \
       
   366             enumerate lines error %d", err )
       
   367         }
       
   368 
       
   369     LOG2( SIMPLE, "SATENGINE: CSatMultiModeApi::IsCallIncoming exiting %d", 
       
   370           callIncoming )
       
   371     return callIncoming;
       
   372     }
       
   373 
       
   374 // -----------------------------------------------------------------------------
       
   375 // CSatMultiModeApi::NotifyMobileCallStatusChange
       
   376 // -----------------------------------------------------------------------------
       
   377 //
       
   378 void CSatMultiModeApi::NotifyMobileCallStatusChange ( 
       
   379         TRequestStatus& aReqStatus, RMobileCall::TMobileCallStatus& aStatus )
       
   380     {
       
   381     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::NotifyMobileCallStatusChange \
       
   382              calling" )
       
   383     iCall.NotifyMobileCallStatusChange( aReqStatus, aStatus );
       
   384     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::NotifyMobileCallStatusChange \
       
   385              exiting" )
       
   386     }
       
   387 
       
   388 // -----------------------------------------------------------------------------
       
   389 // CSatMultiModeApi::NotifyCallStatusChangeCancel
       
   390 // (other items were commented in a header).
       
   391 // -----------------------------------------------------------------------------
       
   392 //
       
   393 void CSatMultiModeApi::NotifyCallStatusChangeCancel()
       
   394     {
       
   395     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::DialCancel calling" )
       
   396     iCall.NotifyStatusChangeCancel();
       
   397     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::DialCancel exiting" )
       
   398     }
       
   399 
       
   400 // -----------------------------------------------------------------------------
       
   401 // CSatMultiModeApi::NotifyMobileCallStatusChange
       
   402 // -----------------------------------------------------------------------------
       
   403 //
       
   404 void CSatMultiModeApi::TerminateActiveCalls(TRequestStatus& aReqStatus)
       
   405     {
       
   406     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::TerminateAllCalls calling" )
       
   407 
       
   408     iPhone.TerminateActiveCalls( aReqStatus );
       
   409     
       
   410     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::TerminateAllCalls exiting" )
       
   411     } 
       
   412 
       
   413 // -----------------------------------------------------------------------------
       
   414 // CSatMultiModeApi::GetMobileCallInfo
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 TInt CSatMultiModeApi::GetMobileCallInfo(TDes8& aCallInfo)
       
   418     {
       
   419     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::GetMobileCallInfo calling" )
       
   420     TInt ret = iCall.GetMobileCallInfo( aCallInfo );
       
   421     LOG2( SIMPLE, "SATENGINE: CSatMultiModeApi::GetMobileCallInfo exiting %d",
       
   422             ret )
       
   423     return ret;
       
   424     }
       
   425        
       
   426 // -----------------------------------------------------------------------------
       
   427 // CSatMultiModeApi::GetMobileCallInfo
       
   428 // -----------------------------------------------------------------------------
       
   429 //
       
   430 void CSatMultiModeApi::DialEmergencyCall(TRequestStatus& aReqStatus, 
       
   431         const TDesC& aNumber)
       
   432     {
       
   433     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::DialEmergencyCall calling" )
       
   434     TInt err = LoadMobileCall();
       
   435     LOG2( SIMPLE, "SATENGINE: CSatMultiModeApi::DialEmergencyCall err %d", err )
       
   436     iCall.DialEmergencyCall( aReqStatus, aNumber );
       
   437     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::DialEmergencyCall exiting" )
       
   438     }
       
   439 
       
   440 // -----------------------------------------------------------------------------
       
   441 // CSatMultiModeApi::ConstructL
       
   442 // -----------------------------------------------------------------------------
       
   443 //
       
   444 void CSatMultiModeApi::ConstructL()
       
   445     {
       
   446     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::ConstructL calling" )
       
   447 
       
   448     // Connect to ETel Server    
       
   449     ConnectETelServerL();
       
   450 #if !defined ( __WINSCW__ )
       
   451     //On the emulator the load will leave. We can not use the functionaly
       
   452     //on enmulator
       
   453     LoadUssdMessagingL();
       
   454 #endif
       
   455 
       
   456     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::ConstructL exiting" )
       
   457     }
       
   458 
       
   459 // -----------------------------------------------------------------------------
       
   460 // CSatMultiModeApi::ConnectETelServerL
       
   461 // (other items were commented in a header).
       
   462 // -----------------------------------------------------------------------------
       
   463 //
       
   464 void CSatMultiModeApi::ConnectETelServerL()
       
   465     {
       
   466     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::ConnectETelServerL calling" )
       
   467 
       
   468     TInt numberOfTries( 1 );        // Indicates loop tryouts
       
   469     TBool loopSuccess( EFalse );    // Loop stopper, if this is ETrue
       
   470     TInt error = KErrNone;          // Error that is Leave'd
       
   471 
       
   472     if ( !iWrapper )
       
   473         {
       
   474         LOG( NORMAL, "SATENGINE: CSatMultiModeApi::ConnectETelServerL \
       
   475         iWrapper false" )
       
   476         iWrapper = new ( ELeave ) CSatSActiveWrapper();
       
   477         }
       
   478 
       
   479     // First loop is for connecting to RTelServer. Loop is done until
       
   480     // connection returns KErrNone or when max loop try outs has been 
       
   481     // reached
       
   482     while ( !loopSuccess && numberOfTries <= KLoopMaxTryouts )
       
   483         {
       
   484         error = iTelServer.Connect();
       
   485         if ( KErrNone == error )
       
   486             {
       
   487             LOG( NORMAL, "SATENGINE: \
       
   488             CSatMultiModeApi::ConnectETelServerL KErrNone == error" )
       
   489             loopSuccess = ETrue;
       
   490             }
       
   491         else
       
   492             {
       
   493             numberOfTries++;
       
   494             iWrapper->After( KLoopTimeout );
       
   495             }
       
   496         }
       
   497 
       
   498     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::ConnectETelServerL \
       
   499           numberOfTries: %i", numberOfTries )
       
   500 
       
   501     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::ConnectETelServerL \
       
   502           error: %i", error )
       
   503 
       
   504     // Check the error status
       
   505     User::LeaveIfError( error );
       
   506 
       
   507     // Now load phone module
       
   508     LoadPhoneModuleL( iPhone, KMmTsyModuleName, KMmTsyPhoneName );
       
   509 
       
   510 #ifdef SAT_USE_DUMMY_TSY
       
   511     // Also load dummy tsy
       
   512     LoadPhoneModuleL( iDummyPhone, KSatSDummyTsyModuleName, KSatSDummyTsyPhoneName );
       
   513 #endif // SAT_USE_DUMMY_TSY
       
   514 
       
   515     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
       
   516 
       
   517     // No need for wrapper anymore
       
   518     delete iWrapper;
       
   519     iWrapper = NULL;
       
   520 
       
   521     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::ConnectETelServerL exiting" )
       
   522     }
       
   523 
       
   524 // -----------------------------------------------------------------------------
       
   525 // CSatMultiModeApi::LoadPhoneModuleL
       
   526 // (other items were commented in a header).
       
   527 // -----------------------------------------------------------------------------
       
   528 //
       
   529 void CSatMultiModeApi::LoadPhoneModuleL( RMobilePhone& aPhone,
       
   530         const TDesC& aModuleName, const TDesC& aPhoneName )
       
   531     {
       
   532     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL calling" )
       
   533 
       
   534     TInt numberOfTries( 1 );        // Indicates loop tryouts
       
   535     TBool loopSuccess( EFalse );    // Loop stopper, if this is ETrue
       
   536     TInt error = KErrNone;          // Error that is Leave'd
       
   537 
       
   538     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL \
       
   539           ModuleName: %S", &aModuleName )
       
   540 
       
   541     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL \
       
   542           PhoneName: %S", &aPhoneName )
       
   543 
       
   544     // We wait here until the phone module gets loaded.
       
   545     // Load the correct phone module depending on the TSY being used.
       
   546     while ( !loopSuccess && numberOfTries <= KLoopMaxTryouts )
       
   547         {
       
   548         error = iTelServer.LoadPhoneModule( aModuleName );
       
   549         if ( KErrNone == error )
       
   550             {
       
   551             loopSuccess = ETrue;
       
   552             }
       
   553         else
       
   554             {
       
   555             numberOfTries++;
       
   556             iWrapper->After( KLoopTimeout );
       
   557             }
       
   558         }
       
   559 
       
   560     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL \
       
   561           numberOfTries: %i", numberOfTries )
       
   562 
       
   563     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL \
       
   564           error: %i", error )
       
   565 
       
   566     // Check the error status
       
   567     User::LeaveIfError( error );
       
   568 
       
   569     // This function retrieves the total number of phones supported by all
       
   570     // the currently loaded ETel (TSY) modules.
       
   571     TInt phoneCount( 0 );
       
   572     User::LeaveIfError( iTelServer.EnumeratePhones( phoneCount ) );
       
   573 
       
   574     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL \
       
   575           phoneCount: %i", phoneCount )
       
   576 
       
   577     // This function retrieves information associated with the specified phone
       
   578     RTelServer::TPhoneInfo phoneInfo;
       
   579     while ( phoneCount-- )
       
   580         {
       
   581         User::LeaveIfError( iTelServer.GetPhoneInfo( phoneCount,
       
   582             phoneInfo ) );
       
   583 
       
   584         // Check that do we have the right phone
       
   585         if ( phoneInfo.iName == aPhoneName )
       
   586             {
       
   587             LOG( NORMAL, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL \
       
   588             phoneInfo.iName == aPhoneName" )
       
   589             phoneCount = 0;
       
   590             }
       
   591         }
       
   592 
       
   593     if ( phoneInfo.iName != aPhoneName )
       
   594         {
       
   595         // Did not found correct phone info -> Leave
       
   596         LOG( SIMPLE, 
       
   597             "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL Not found" )
       
   598         User::Leave( KErrNotFound );
       
   599         }
       
   600 
       
   601     // Reset the counter and loop status for the next loop.
       
   602     numberOfTries = 1;
       
   603     loopSuccess = EFalse;
       
   604 
       
   605     // We wait here until the phone gets opened.
       
   606     // Open the correct phone depending on the TSY being used.
       
   607     while ( !loopSuccess && ( numberOfTries <= KLoopMaxTryouts ) )
       
   608         {
       
   609         error = aPhone.Open( iTelServer, aPhoneName );
       
   610 
       
   611         if ( KErrNone == error )
       
   612             {
       
   613             LOG( NORMAL, "SATENGINE: \
       
   614             CSatMultiModeApi::LoadPhoneModuleL KErrNone == error" )
       
   615             loopSuccess = ETrue;
       
   616             }
       
   617         else
       
   618             {
       
   619             numberOfTries++;
       
   620             iWrapper->After( KLoopTimeout );
       
   621             }
       
   622         }
       
   623     if ( !loopSuccess )
       
   624         {
       
   625         LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL\
       
   626                       phone open failed" );
       
   627         }
       
   628     
       
   629     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::LoadPhoneModuleL exiting" )
       
   630     }
       
   631 
       
   632 // -----------------------------------------------------------------------------
       
   633 // CSatMultiModeApi::LoadMobileCall
       
   634 // (other items were commented in a header).
       
   635 // -----------------------------------------------------------------------------
       
   636 //
       
   637 TInt CSatMultiModeApi::LoadMobileCall()
       
   638     {
       
   639     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::LoadMobileCallL calling" )
       
   640 
       
   641     if ( iCallOpened )
       
   642         {
       
   643         iCall.Close();
       
   644         }
       
   645     
       
   646     if ( iLineOpened )
       
   647         {
       
   648         iLine.Close();
       
   649         }
       
   650     
       
   651     TInt numberOfTries( 1 );        // Indicates loop tryouts
       
   652     TBool loopSuccess( EFalse );    // Loop stopper, if this is ETrue
       
   653     TInt error = KErrNone;          // Error that is Leave'd
       
   654 
       
   655     while ( !loopSuccess && numberOfTries <= KLoopMaxTryouts )
       
   656         {
       
   657         error = iLine.Open( iPhone, KMmTsyVoice1LineName );
       
   658         if ( KErrNone == error )
       
   659             {
       
   660             loopSuccess = ETrue;
       
   661             iLineOpened = ETrue;
       
   662             }
       
   663         else
       
   664             {
       
   665             numberOfTries++;
       
   666             iWrapper->After( KLoopTimeout );
       
   667             }
       
   668         }
       
   669 
       
   670     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadMobileCallL \
       
   671           iLine numberOfTries: %i", numberOfTries )
       
   672 
       
   673     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadMobileCallL \
       
   674           iLine error: %i", error )
       
   675     
       
   676     numberOfTries = 1;
       
   677     loopSuccess =  EFalse;
       
   678 
       
   679     while ( iLineOpened &&!loopSuccess && numberOfTries <= KLoopMaxTryouts )
       
   680         {
       
   681         error = iCall.OpenNewCall( iLine );
       
   682         if ( KErrNone == error )
       
   683             {
       
   684             loopSuccess = ETrue;
       
   685             iCallOpened = ETrue;
       
   686             }
       
   687         else
       
   688             {
       
   689             numberOfTries++;
       
   690             iWrapper->After( KLoopTimeout );
       
   691             }
       
   692         }
       
   693 
       
   694     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadMobileCallL \
       
   695           iCall numberOfTries: %i", numberOfTries )
       
   696 
       
   697     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadMobileCallL \
       
   698           iCall error: %i", error )
       
   699 
       
   700     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::LoadMobileCallL exiting" )
       
   701     return error;
       
   702     }
       
   703     
       
   704 // -----------------------------------------------------------------------------
       
   705 // CSatMultiModeApi::LoadMobileCallL
       
   706 // (other items were commented in a header).
       
   707 // -----------------------------------------------------------------------------
       
   708 //    
       
   709 void CSatMultiModeApi::LoadUssdMessagingL()
       
   710     
       
   711     {
       
   712     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::LoadUssdMessagingL calling" )
       
   713 
       
   714     TInt numberOfTries( 1 );        // Indicates loop tryouts
       
   715     TBool loopSuccess( EFalse );    // Loop stopper, if this is ETrue
       
   716     TInt error = KErrNone;          // Error that is Leave'd
       
   717 
       
   718     while ( !loopSuccess && numberOfTries <= KLoopMaxTryouts )
       
   719         {
       
   720         error = iUssd.Open( iPhone );
       
   721         if ( KErrNone == error )
       
   722             {
       
   723             loopSuccess = ETrue;
       
   724             iUssdOpened = ETrue;
       
   725             }
       
   726         else
       
   727             {
       
   728             numberOfTries++;
       
   729             iWrapper->After( KLoopTimeout );
       
   730             }
       
   731         }
       
   732 
       
   733     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadUssdMessagingL \
       
   734           iUssd numberOfTries: %i", numberOfTries )
       
   735 
       
   736     LOG2( NORMAL, "SATENGINE: CSatMultiModeApi::LoadUssdMessagingL \
       
   737           iUssd error: %i", error )
       
   738           
       
   739     User::LeaveIfError( error );
       
   740 
       
   741     LOG( SIMPLE, "SATENGINE: CSatMultiModeApi::LoadUssdMessagingL exiting" )
       
   742     }
       
   743 
       
   744 
       
   745 //End of file