phoneclientserver/phoneserver/Src/Ussd/CPhSrvUssdManager.cpp
changeset 15 d7fc66ccd6fb
parent 13 e32024264ebb
child 31 a2467631ae02
equal deleted inserted replaced
13:e32024264ebb 15:d7fc66ccd6fb
     1 /*
     1 /*
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    25 #include "cphsrvussdreplytimer.h" 
    25 #include "cphsrvussdreplytimer.h" 
    26 #include "mphsrvussdmessagesentobserver.h" 
    26 #include "mphsrvussdmessagesentobserver.h" 
    27 #include "mphsrvphoneinterface.h" 
    27 #include "mphsrvphoneinterface.h" 
    28 #include "cphsrvussdsessioncancelwaiter.h" 
    28 #include "cphsrvussdsessioncancelwaiter.h" 
    29 
    29 
    30 #include <AknGlobalNote.h> 
       
    31 #include <aknnotedialog.h>
       
    32 #include <aknstaticnotedialog.h>
       
    33 #include <AknProgressDialog.h> 
       
    34 #include <apacmdln.h>
    30 #include <apacmdln.h>
    35 #include <apgtask.h>
    31 #include <apgtask.h>
    36 #include <bautils.h>
    32 #include <bautils.h>
    37 #include <StringLoader.h> 
       
    38 #include <AknGlobalMsgQuery.h> 
       
    39 #include <textresolver.h>
    33 #include <textresolver.h>
    40 #include <charconv.h>
    34 #include <charconv.h>
    41 #include <gsmuelem.h>
    35 #include <gsmuelem.h>
    42 #include <exterror.h>
    36 #include <exterror.h>
    43 #include <rmmcustomapi.h>
    37 #include <rmmcustomapi.h>
    44 
    38 
    45 #include <w32std.h>
    39 #include <w32std.h>
    46 #include <apgcli.h>
    40 #include <apgcli.h>
    47 #include <cphcltussd.h> 
    41 #include <cphcltussd.h> 
    48 #include <avkon.rsg>
    42 #include <hbtextresolversymbian.h>
    49 #include <phoneserver.rsg> 
    43 #include <phoneserver.rsg> 
    50 #include "phsrvdebuginfo.h" 
    44 #include "phsrvdebuginfo.h" 
    51 #include <e32property.h>
    45 #include <e32property.h>
    52 #include <centralrepository.h>
    46 #include <centralrepository.h>
    53 #include <coreapplicationuisdomainpskeys.h>
    47 #include <coreapplicationuisdomainpskeys.h>
    59 // const TInt KPhSrvUssdTimeOutObserverGranularity = 2;
    53 // const TInt KPhSrvUssdTimeOutObserverGranularity = 2;
    60 // const TInt KPhSrvUssdSentMessageObserverGranularity = 2;
    54 // const TInt KPhSrvUssdSentMessageObserverGranularity = 2;
    61 const TInt KPhSrvUssdAppUID = 0x10005955;
    55 const TInt KPhSrvUssdAppUID = 0x10005955;
    62 
    56 
    63 const TInt KPhSrvUssdMessageQueryInterval = 500000; // 0.5 sec
    57 const TInt KPhSrvUssdMessageQueryInterval = 500000; // 0.5 sec
    64 const TInt KPhSrvUssdNoteExitPeriod = 500000; // 0.5 sec
    58 //const TInt KPhSrvUssdNoteExitPeriod = 500000; // 0.5 sec
    65 //
    59 //
    66 const TUint KPhSrvUssdDefaultDCS = 0x0f;                        // 00001111
    60 const TUint KPhSrvUssdDefaultDCS = 0x0f;                        // 00001111
    67 
    61 
    68 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguage = 0x10;// 00010000
    62 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguage = 0x10;// 00010000
    69 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguageSkipChars3 = 3;
    63 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguageSkipChars3 = 3;
    83 const TUint KPhSrvUssdDcsGeneralInformationAlphabetUCS2 = 0x08; // xxxx10xx
    77 const TUint KPhSrvUssdDcsGeneralInformationAlphabetUCS2 = 0x08; // xxxx10xx
    84 
    78 
    85 const TUint KPhSrvUssdDcsMessageHandlingAlphabetMask = 0xf4;    // 11110100
    79 const TUint KPhSrvUssdDcsMessageHandlingAlphabetMask = 0xf4;    // 11110100
    86 const TUint KPhSrvUssdDcsMessageHandlingAlphabet8Bit = 0xf4;    // 1111x1xx
    80 const TUint KPhSrvUssdDcsMessageHandlingAlphabet8Bit = 0xf4;    // 1111x1xx
    87 const TInt KPhrUssdNotifyArraySize = 1;
    81 const TInt KPhrUssdNotifyArraySize = 1;
       
    82 
       
    83 // Refers to HbPopup::NoDismiss = 0
       
    84 const TInt KPhSrvUssdPopupDismissPolicy = 0; 
       
    85 // The time out only for testing, from CPhSrvUssdReplyTimer.cpp
       
    86 const TUint KPhSrvUssdTimeout = 300000000;
       
    87 
       
    88 // Use QT style localization
       
    89 _LIT(KUssdLocFilename, "phcltsrvussd.ts");
       
    90 _LIT(KUssdLocPath, "z://data");
       
    91 _LIT(KUssdReply, "txt_ussd_button_reply"); // Reply
       
    92 _LIT(KUssdExit, "txt_ussd_button_exit"); // Exit
       
    93 _LIT(KUssdNext, "txt_ussd_button_next"); //Next
       
    94 _LIT(KUssdYes, "txt_common_button_yes"); // Yes
       
    95 _LIT(KUssdNo, "txt_common_button_no"); // No
       
    96 _LIT(KUssdTitle, "txt_ussd_title_message"); // Message
       
    97 _LIT(KUssdDone, "txt_ussd_dpopinfo_done"); // Done
       
    98 _LIT(KUssdConfirm, "txt_ussd_info_there_are_still_unread_notifications");
    88 
    99 
    89 // MACROS
   100 // MACROS
    90 
   101 
    91 #define _DPRINT_FLAGS() \
   102 #define _DPRINT_FLAGS() \
    92     _DDPRINT( 4, "PhSrv.FLAGS.MsgTypeReply ", iMsgTypeReply ); \
   103     _DDPRINT( 4, "PhSrv.FLAGS.MsgTypeReply ", iMsgTypeReply ); \
   371     CPhSrvResourceManager& aResourceManager
   382     CPhSrvResourceManager& aResourceManager
   372     )
   383     )
   373     :CActive( EPriorityLow ),
   384     :CActive( EPriorityLow ),
   374      iFsSession( aFsSession ),
   385      iFsSession( aFsSession ),
   375      iResourceManager( aResourceManager ),
   386      iResourceManager( aResourceManager ),
       
   387      iDeviceDialog( NULL ),
   376      iDCS ( KPhCltDcsUnknown ),
   388      iDCS ( KPhCltDcsUnknown ),
   377      iReturnResultPckg ( iReturnResult )
   389      iReturnResultPckg ( iReturnResult ),
   378 
   390      iTextResolver ( EFalse ),
       
   391      iTextBuffer ( NULL )
   379     {
   392     {
   380     CActiveScheduler::Add( this );
   393     CActiveScheduler::Add( this );
   381     }
   394     }
   382 
   395 
   383 
   396 
   388 //
   401 //
   389 // -----------------------------------------------------------------------------
   402 // -----------------------------------------------------------------------------
   390 //
   403 //
   391 CPhSrvUssdManager::~CPhSrvUssdManager()
   404 CPhSrvUssdManager::~CPhSrvUssdManager()
   392     {
   405     {
   393     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.start" );       // debug print
   406     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.start" );
   394 
   407 
   395 
   408 
   396     delete iUssdSendHandler;
   409     delete iUssdSendHandler;
   397     iUssdSendHandler = NULL;
   410     iUssdSendHandler = NULL;
   398 
   411 
   403     iUssdNotifyNWRelease = NULL;
   416     iUssdNotifyNWRelease = NULL;
   404 
   417 
   405     Cancel();
   418     Cancel();
   406 
   419 
   407     iTimer.Close();
   420     iTimer.Close();
   408 
   421     
   409     delete iGlobalMsgQuery;
   422     delete iTextBuffer;
   410     iGlobalMsgQuery = NULL;
   423     iTextBuffer = NULL;
       
   424     
       
   425     delete iDeviceDialog;
       
   426     iDeviceDialog = NULL;
   411 
   427 
   412     if ( iNotifyArray )
   428     if ( iNotifyArray )
   413         {
   429         {
   414         iNotifyArray->Reset();
   430         iNotifyArray->Reset();
   415         }
   431         }
   422     iUssdReplyTimer = NULL;
   438     iUssdReplyTimer = NULL;
   423 
   439 
   424     iFsSession.Close();
   440     iFsSession.Close();
   425 
   441 
   426     iMobileUssdMessaging.Close();
   442     iMobileUssdMessaging.Close();
   427 
       
   428     delete iMeQuHeaderText;
       
   429     iMeQuHeaderText = NULL;
       
   430     
   443     
   431     delete iMoAckCallback;
   444     delete iMoAckCallback;
   432 
   445 
   433     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.end" );       // debug print
   446     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.end" );
   434     }
   447     }
   435 
   448 
   436 
   449 
   437 // -----------------------------------------------------------------------------
   450 // -----------------------------------------------------------------------------
   438 // CPhSrvUssdManager::ConstructL
   451 // CPhSrvUssdManager::ConstructL
   441 //
   454 //
   442 // -----------------------------------------------------------------------------
   455 // -----------------------------------------------------------------------------
   443 //
   456 //
   444 void CPhSrvUssdManager::ConstructL( MPhSrvPhoneInterface& aPhoneInterface )
   457 void CPhSrvUssdManager::ConstructL( MPhSrvPhoneInterface& aPhoneInterface )
   445     {
   458     {
   446     _DPRINT( 4, "PhSrv.ConstructL.Start" );       // debug print
   459     _DPRINT( 4, "PhSrv.ConstructL.Start" );
       
   460     iTextResolver = HbTextResolverSymbian::Init( 
       
   461         KUssdLocFilename, KUssdLocPath );
       
   462     _DDPRINT( 4, "PhSrv.ConstructL.loc:", iTextResolver );
   447     User::LeaveIfError( iTimer.CreateLocal() );
   463     User::LeaveIfError( iTimer.CreateLocal() );
   448 
   464 
   449     User::LeaveIfError( iMobileUssdMessaging.Open( aPhoneInterface.PhSrvMobilePhone() ) );
   465     User::LeaveIfError( iMobileUssdMessaging.Open( aPhoneInterface.PhSrvMobilePhone() ) );
   450 
   466 
   451     // Check support
   467     // Check support
   477 
   493 
   478     iVariantReadOnlyValues = KPhSrvDefaultValue;
   494     iVariantReadOnlyValues = KPhSrvDefaultValue;
   479 
   495 
   480     User::LeaveIfError( GetTelephonyVariantData() );
   496     User::LeaveIfError( GetTelephonyVariantData() );
   481 
   497 
   482     iMeQuHeaderText = iResourceManager.ReadResourceLC(
       
   483         R_PHSRV_USSD_MESQUERY_MESSAGE);
       
   484     CleanupStack::Pop( iMeQuHeaderText );
       
   485 
       
   486     _DDPRINT( 4, "PhSrv.ConstructL.iSatCanceled ", iSatCanceled );
   498     _DDPRINT( 4, "PhSrv.ConstructL.iSatCanceled ", iSatCanceled );
   487     _DDPRINT( 4, "PhSrv.ConstructL.iShowDone ", iShowDone );
   499     _DDPRINT( 4, "PhSrv.ConstructL.iShowDone ", iShowDone );
   488     iNotifyArray = new( ELeave ) CDesCArrayFlat( KPhrUssdNotifyArraySize );
   500     iNotifyArray = new( ELeave ) CDesCArrayFlat( KPhrUssdNotifyArraySize );
   489     _DPRINT( 4, "PhSrv.ConstructL.End" );       // debug print
   501     _DPRINT( 4, "PhSrv.ConstructL.End" );
   490     }
   502     }
   491 
   503 
   492 
   504 
   493 // -----------------------------------------------------------------------------
   505 // -----------------------------------------------------------------------------
   494 // CPhSrvUssdManager::SendHandlerL
   506 // CPhSrvUssdManager::SendHandlerL
   499 //
   511 //
   500 CPhSrvUssdSendHandler& CPhSrvUssdManager::SendHandlerL()
   512 CPhSrvUssdSendHandler& CPhSrvUssdManager::SendHandlerL()
   501     {
   513     {
   502     // If SendHandler is not created, first check that MO Ussd
   514     // If SendHandler is not created, first check that MO Ussd
   503     // is supported by the TSY.
   515     // is supported by the TSY.
   504     _DPRINT( 4, "PhSrv.SendHandlerL.Start" );       // debug print
   516     _DPRINT( 4, "PhSrv.SendHandlerL.Start" );
   505     if ( iUssdSendHandler == NULL )
   517     if ( iUssdSendHandler == NULL )
   506         {
   518         {
   507         _DPRINT( 4, "PhSrv.SendHandlerL.iUssdSendHandler.NULL" );       // debug print
   519         _DPRINT( 4, "PhSrv.SendHandlerL.iUssdSendHandler.NULL" );
   508         RMobileUssdMessaging::TMobileUssdCapsV1 caps;
   520         RMobileUssdMessaging::TMobileUssdCapsV1 caps;
   509         RMobileUssdMessaging::TMobileUssdCapsV1Pckg pckgCaps( caps );
   521         RMobileUssdMessaging::TMobileUssdCapsV1Pckg pckgCaps( caps );
   510         User::LeaveIfError( iMobileUssdMessaging.GetCaps( pckgCaps ) );
   522         User::LeaveIfError( iMobileUssdMessaging.GetCaps( pckgCaps ) );
   511         _DPRINT( 4, "PhSrv.SendHandlerL.iMobileUssdMessaging.GetCaps" );       // debug print
   523         _DPRINT( 4, "PhSrv.SendHandlerL.iMobileUssdMessaging.GetCaps" );
   512 
   524 
   513         if ( ( caps.iUssdTypes & RMobileUssdMessaging::KCapsMOUssd ) == 0 ||
   525         if ( ( caps.iUssdTypes & RMobileUssdMessaging::KCapsMOUssd ) == 0 ||
   514             ( caps.iUssdFormat & RMobileUssdMessaging::KCapsPackedString )
   526             ( caps.iUssdFormat & RMobileUssdMessaging::KCapsPackedString )
   515             == 0 )
   527             == 0 )
   516             {
   528             {
   517             _DPRINT( 4, "PhSrv.SendHandlerL.KErrNotSupported" );       // debug print
   529             _DPRINT( 4, "PhSrv.SendHandlerL.KErrNotSupported" );
   518             User::Leave( KErrNotSupported );
   530             User::Leave( KErrNotSupported );
   519             }
   531             }
   520 
   532 
   521         iUssdSendHandler =
   533         iUssdSendHandler =
   522             new( ELeave ) CPhSrvUssdSendHandler(
   534             new( ELeave ) CPhSrvUssdSendHandler(
   523                 *this,
   535                 *this,
   524                 iMobileUssdMessaging,
   536                 iMobileUssdMessaging,
   525                 *iPhoneInterface );
   537                 *iPhoneInterface );
   526         }
   538         }
   527     _DPRINT( 4, "PhSrv.SendHandlerL.End" );       // debug print
   539     _DPRINT( 4, "PhSrv.SendHandlerL.End" );
   528     return *iUssdSendHandler;
   540     return *iUssdSendHandler;
   529     }
   541     }
   530 
   542 
   531 
   543 
   532 // -----------------------------------------------------------------------------
   544 // -----------------------------------------------------------------------------
   539 void CPhSrvUssdManager::SendUssdL(
   551 void CPhSrvUssdManager::SendUssdL(
   540     const TDesC8& aMsgData,
   552     const TDesC8& aMsgData,
   541     RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttribute,
   553     RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttribute,
   542     MPhSrvUssdMessageSentObserver& aObserver )
   554     MPhSrvUssdMessageSentObserver& aObserver )
   543     {
   555     {
   544     _DPRINT( 4, "PhSrv.SendUssdL.Start ######" );           // debug print
   556     _DPRINT( 4, "PhSrv.SendUssdL.Start ######" );
   545     _DPRINT_FLAGS();
   557     _DPRINT_FLAGS();
   546     
   558     
   547     if ( iObserver && iNetworkReleased ) 
   559     if ( iObserver && iNetworkReleased ) 
   548         {
   560         {
   549         // Network has been released but the previous send request is still alive.
   561         // Network has been released but the previous send request is still alive.
   550         // Cancel the pervious send operation, complete the old request with error
   562         // Cancel the pervious send operation, complete the old request with error
   551         // and clean up the pointer.
   563         // and clean up the pointer.
   552         _DPRINT( 4, "PhSrv.SendUssdL.Error.Complete.Existing" );           // debug print
   564         _DPRINT( 4, "PhSrv.SendUssdL.Error.Complete.Existing" );
   553         if ( iUssdSendHandler ) 
   565         if ( iUssdSendHandler ) 
   554             {
   566             {
   555             iUssdSendHandler->Cancel();
   567             iUssdSendHandler->Cancel();
   556             }
   568             }
   557         iObserver->UssdMessageSentObserverHandleResult( KErrSessionClosed );
   569         iObserver->UssdMessageSentObserverHandleResult( KErrSessionClosed );
   558         iObserver = NULL;
   570         iObserver = NULL;
   559         }
   571         }
   560     
   572     
   561     if ( iObserver || iSendingAck )
   573     if ( iObserver || iSendingAck )
   562         {
   574         {
   563         _DPRINT( 4, "PhSrv.SendUssdL.KErrInUse" );           // debug print
   575         _DPRINT( 4, "PhSrv.SendUssdL.KErrInUse" );
   564         // Other client is using the service.
   576         // Other client is using the service.
   565         User::Leave( KErrInUse );
   577         User::Leave( KErrInUse );
   566         }
   578         }
   567 
   579 
   568     // Check that message type is set
   580     // Check that message type is set
   569     if( ( aMsgAttribute.iFlags & RMobileUssdMessaging::KUssdMessageType )
   581     if( ( aMsgAttribute.iFlags & RMobileUssdMessaging::KUssdMessageType )
   570         == 0 )
   582         == 0 )
   571         _DPRINT( 4, "PhSrv.SendUssdL.KUssdMessageType.0" );       // debug print
   583         _DPRINT( 4, "PhSrv.SendUssdL.KUssdMessageType.0" );
   572         {
   584         {
   573         // Mesasge type not set -> Set it.
   585         // Mesasge type not set -> Set it.
   574         aMsgAttribute.iFlags |= RMobileUssdMessaging::KUssdMessageType;
   586         aMsgAttribute.iFlags |= RMobileUssdMessaging::KUssdMessageType;
   575         if ( NetworkWaitingForAnAnswer() )
   587         if ( NetworkWaitingForAnAnswer() )
   576             {
   588             {
   586         }
   598         }
   587         
   599         
   588     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs( aMsgAttribute );
   600     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs( aMsgAttribute );
   589     iShowDone = ETrue;
   601     iShowDone = ETrue;
   590     _DPRINT( 4, "PhSrv.SendUssdL.iShowDone.ETrue" );
   602     _DPRINT( 4, "PhSrv.SendUssdL.iShowDone.ETrue" );
   591     _DPRINT( 4, "PhSrv.SendUssdL.Send" );           // debug print
   603     _DPRINT( 4, "PhSrv.SendUssdL.Send" );
   592     SendHandlerL().SendUssdL( aMsgData , attribs );
   604     SendHandlerL().SendUssdL( aMsgData , attribs );
   593     iObserver = &aObserver;
   605     iObserver = &aObserver;
   594     // Not closing nor closed anymore
   606     // Not closing nor closed anymore
   595     iNetworkReleased = EFalse;
   607     iNetworkReleased = EFalse;
   596     iSendRelease = EFalse;
   608     iSendRelease = EFalse;
   601     if ( NetworkWaitingForAnAnswer() )
   613     if ( NetworkWaitingForAnAnswer() )
   602         {
   614         {
   603         _DPRINT( 4, "PhSrv.SendUssdCancel.TimerStop" );   // debug print
   615         _DPRINT( 4, "PhSrv.SendUssdCancel.TimerStop" );   // debug print
   604         iUssdReplyTimer->Stop();
   616         iUssdReplyTimer->Stop();
   605         }
   617         }
   606     _DPRINT( 4, "PhSrv.SendUssdL.End" );           // debug print
   618     _DPRINT( 4, "PhSrv.SendUssdL.End" );
   607     }
   619     }
   608 
   620 
   609 // -----------------------------------------------------------------------------
   621 // -----------------------------------------------------------------------------
   610 // CPhSrvUssdManager::NetworkWaitingForAnAnswer
   622 // CPhSrvUssdManager::NetworkWaitingForAnAnswer
   611 // -----------------------------------------------------------------------------
   623 // -----------------------------------------------------------------------------
   621 //
   633 //
   622 // -----------------------------------------------------------------------------
   634 // -----------------------------------------------------------------------------
   623 //
   635 //
   624 void CPhSrvUssdManager::SendUssdCancel()
   636 void CPhSrvUssdManager::SendUssdCancel()
   625     {
   637     {
   626     _DPRINT( 4, "PhSrv.SendUssdCancel.Start #######" );           // debug print
   638     _DPRINT( 4, "PhSrv.SendUssdCancel.Start #######" );
   627 
   639 
   628     // Ack sending should not be canceled unless it's about terminating
   640     // Ack sending should not be canceled unless it's about terminating
   629     // the whole session
   641     // the whole session
   630     _DPRINT_FLAGS();
   642     _DPRINT_FLAGS();
   631     if ( !iSendingAck || iSendRelease ) 
   643     if ( !iSendingAck || iSendRelease ) 
   640         iSatCanceled = ETrue;
   652         iSatCanceled = ETrue;
   641         }
   653         }
   642     iObserver = NULL;
   654     iObserver = NULL;
   643     
   655     
   644     SetActiveIfPendingNotificationsExist();
   656     SetActiveIfPendingNotificationsExist();
   645     _DPRINT( 4, "PhSrv.SendUssdCancel.End" );           // debug print
   657     _DPRINT( 4, "PhSrv.SendUssdCancel.End" );
   646     }
   658     }
   647 
   659 
   648 // -----------------------------------------------------------------------------
   660 // -----------------------------------------------------------------------------
   649 // CPhSrvUssdManager::SetActiveIfPendingNotificationsExist
   661 // CPhSrvUssdManager::SetActiveIfPendingNotificationsExist
   650 // -----------------------------------------------------------------------------
   662 // -----------------------------------------------------------------------------
   679         aError );
   691         aError );
   680 
   692 
   681     // complete SAT if needed
   693     // complete SAT if needed
   682     if ( aError < KErrNone )
   694     if ( aError < KErrNone )
   683         {
   695         {
   684         // debug print
   696  
   685         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.CompleteSat" );
   697         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.CompleteSat" );
   686         CompleteSatL( NULL, aError );
   698         CompleteSatL( NULL, aError );
   687         }
   699         }
   688 
   700 
   689     if ( iObserver )
   701     if ( iObserver )
   690         {
   702         {
   691         // debug print
   703  
   692         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.Observer" );
   704         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.Observer" );
   693 
   705 
   694         iObserver->UssdMessageSentObserverHandleResult( aError );
   706         iObserver->UssdMessageSentObserverHandleResult( aError );
   695         iObserver = NULL;
   707         iObserver = NULL;
   696         }
   708         }
   744         aError );
   756         aError );
   745     _DPRINT_FLAGS();
   757     _DPRINT_FLAGS();
   746     if ( aError != KErrNone )
   758     if ( aError != KErrNone )
   747         {
   759         {
   748         TurnLightsOn(); //Ensure lights on
   760         TurnLightsOn(); //Ensure lights on
   749         // debug print
   761  
   750         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleReceivedEventL.ShErNote" );
   762         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleReceivedEventL.ShErNote" );
   751         ShowErrorNoteL( aError );
   763         ShowErrorNoteL( aError );
   752         }
   764         }
   753     else if ( iSendRelease )
   765     else if ( iSendRelease )
   754         {
   766         {
   761         }
   773         }
   762     }
   774     }
   763 
   775 
   764 // -----------------------------------------------------------------------------
   776 // -----------------------------------------------------------------------------
   765 // CPhSrvUssdManager::UssdHandleReceivedEventL
   777 // CPhSrvUssdManager::UssdHandleReceivedEventL
   766 //
       
   767 //
       
   768 //
       
   769 // -----------------------------------------------------------------------------
   778 // -----------------------------------------------------------------------------
   770 //
   779 //
   771 void CPhSrvUssdManager::UssdHandleReceivedEventL(
   780 void CPhSrvUssdManager::UssdHandleReceivedEventL(
   772     const TDes8& aMsgData,
   781     const TDes8& aMsgData,
   773     const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes )
   782     const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes )
   777     iNetworkReleased = EFalse;
   786     iNetworkReleased = EFalse;
   778         
   787         
   779     // 2. Complete Send with some positive value.
   788     // 2. Complete Send with some positive value.
   780     if ( iObserver )
   789     if ( iObserver )
   781         {
   790         {
   782         // debug print
   791  
   783         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Observer" );
   792         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Observer" );
   784         UssdNetworkObserverHandleSendEventL( 1 ); // some positive value
   793         UssdNetworkObserverHandleSendEventL( 1 ); // some positive value
   785         }
   794         }
   786     
   795     
   787     if ( aMsgAttributes.iFlags&RMobileUssdMessaging::KUssdMessageType &&
   796     if ( aMsgAttributes.iFlags&RMobileUssdMessaging::KUssdMessageType &&
   811     if ( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType ) ||
   820     if ( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType ) ||
   812             aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   821             aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   813         {
   822         {
   814         if ( !ShowNotesL() )
   823         if ( !ShowNotesL() )
   815             {
   824             {
   816             // debug print
   825      
   817             _DPRINT( 4,
   826             _DPRINT( 4,
   818                 "PhSrv.UssdHandleReceivedEventL.SAtReturn" );
   827                 "PhSrv.UssdHandleReceivedEventL.SAtReturn" );
   819             return;
   828             return;
   820             }
   829             }
   821         }
   830         }
   822 
   831 
   823     // empty string is handled as ok message
   832     // empty string is handled as ok message
   824     if ( !iDecodedMessage.Length() )
   833     if ( !iDecodedMessage.Length() )
   825         {
   834         {
   826         TurnLightsOn(); //Ensure lights on
   835         TurnLightsOn(); //Ensure lights on
   827         // debug print
   836  
   828         _DPRINT( 4,
   837         _DPRINT( 4,
   829             "PhSrv.UssdHandleReceivedEventL.EmptyString" );
   838             "PhSrv.UssdHandleReceivedEventL.EmptyString" );
   830         
   839         
   831         ShowDoneNoteL();
   840         ShowDoneNoteL();
   832 
   841 
   833         // debug print
   842  
   834         _DPRINT( 4,
   843         _DPRINT( 4,
   835             "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
   844             "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
   836         }
   845         }
   837     else
   846     else
   838         {
   847         {
   847             {
   856             {
   848             // need to send an MO ack
   857             // need to send an MO ack
   849             iAcksToBeSent ++;
   858             iAcksToBeSent ++;
   850             }
   859             }
   851         
   860         
       
   861         if ( !iDeviceDialog  ){
       
   862             iDeviceDialog = CHbDeviceMessageBoxSymbian::NewL(
       
   863                 CHbDeviceMessageBoxSymbian::EInformation );
       
   864             iDeviceDialog->SetObserver( this );
       
   865             iDeviceDialog->SetTimeout( KPhSrvUssdTimeout );
       
   866             iDeviceDialog->SetDismissPolicy ( KPhSrvUssdPopupDismissPolicy );
       
   867             
       
   868             // Show left key with empty string accoring to ui concept
       
   869             iDeviceDialog->SetButton( 
       
   870                 CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse );
       
   871             // Show Exit Key always
       
   872             iDeviceDialog->SetButton( 
       
   873                 CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );
       
   874             iDeviceDialog->SetButtonTextL(
       
   875                 CHbDeviceMessageBoxSymbian::ERejectButton, 
       
   876                 LoadDefaultString( KUssdExit ) );
       
   877             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Exit" );             
       
   878         }
       
   879       
   852         if ( iNotifyMessage || iMsgTypeReply )
   880         if ( iNotifyMessage || iMsgTypeReply )
   853             {
   881             {
   854             //This is for reply message in notifyarray
   882             //This is for reply message in notifyarray
   855             iNotifyMessage = ETrue;
   883             iNotifyMessage = ETrue;
   856             _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
   884             _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
   857 
   885 
   858             //Notify added to array
   886             //Notify added to array
   859             iNotifyArray->AppendL( iReceivedMessage );
   887             iNotifyArray->AppendL( iReceivedMessage );
   860 
   888 
   861             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" );       // debug print
   889             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" );
   862             UpdateNotifyMessage();
   890             UpdateNotifyMessageL();
   863 
   891 
   864             if ( !iSendRelease && NotifyCount() <= 1 )
   892             if ( !iSendRelease && NotifyCount() <= 1 )
   865                 {
   893                 {
   866                 _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" );       // debug print
   894                 _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" );
   867                 Cancel();
   895                 Cancel();
   868                 }
   896                 }
   869             }
   897             }
   870         else
   898         else
   871             {
   899             {
   872             // New message deletes old message, i.e. Cancel existing query.
   900             // New message deletes old message, i.e. Cancel existing query.
   873             Cancel();
   901             Cancel();
   874             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" );       // debug print
   902             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" );
   875             }
   903             }
   876 
   904 
   877         if ( !iGlobalMsgQuery )
   905         // Remove Reply key
   878             {
       
   879             iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
       
   880             }
       
   881 
       
   882         // Delay after message query so that application execution order will
       
   883         // be correct.
       
   884         iGlobalMsgQuery->SetExitDelay( KPhSrvUssdNoteExitPeriod );
       
   885 
       
   886         TInt softkeys = R_AVKON_SOFTKEYS_USSD_ANSWER_EXIT__ANSWER;
       
   887         if( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType )
   906         if( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType )
   888              || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   907              || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   889             {
   908             {
   890             softkeys = R_AVKON_SOFTKEYS_EXIT;
   909             // Remove Answer key
   891             }
   910             iDeviceDialog->SetButton( 
   892 
   911                 CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse );
   893         // Set timer that lauches Global MessageQuery after time interval.
   912             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NoAnswer" ); 
   894         iSoftkeys = softkeys;
   913             }
   895 
   914         // Show Reply key
   896         // debug print
   915         else
       
   916             {
       
   917             iDeviceDialog->SetButton( 
       
   918                 CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue );              
       
   919             iDeviceDialog->SetButtonTextL(
       
   920                 CHbDeviceMessageBoxSymbian::EAcceptButton, 
       
   921                 LoadDefaultString( KUssdReply ) ); 
       
   922             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.WithAnswer" ); 
       
   923             }
       
   924 
       
   925  
   897         _DPRINT( 4,
   926         _DPRINT( 4,
   898             "PhSrv.UssdHandleReceivedEventL.String.Middle" );
   927             "PhSrv.UssdHandleReceivedEventL.String.Middle" );
   899 
   928 
   900         // Play the USSD tone if needed. Logically should be in RunL, but here
   929         // Play the USSD tone if needed. Logically should be in RunL, but here
   901         // to give better balancing with voice and visible message.
   930         // to give better balancing with voice and visible message.
   902 
   931         // <-- QT PHONE START-->
       
   932         /*
       
   933         if ( IsTelephonyFeatureSupported( KTelephonyLVFlagUssdTone ) )
       
   934             {
       
   935             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.PlayTone" );
       
   936             PlayUssdTone();
       
   937             }
       
   938         */
       
   939             // <-- QT PHONE END-->
   903         // Launch the new message query
   940         // Launch the new message query
   904         if ( !IsActive() )
   941         if ( !IsActive() )
   905             {
   942             {
   906             iLaunchGMQ = ETrue;
   943             iLaunchGMQ = ETrue;
   907             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
   944             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
   965         {
  1002         {
   966         iReturnResult = aReturnResult;
  1003         iReturnResult = aReturnResult;
   967         if ( !iSatCanceled )
  1004         if ( !iSatCanceled )
   968             {
  1005             {
   969             CompleteSatL(&iReceivedMessage, aError );
  1006             CompleteSatL(&iReceivedMessage, aError );
   970             _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.CompleteSat" );       // debug print
  1007             _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.CompleteSat" );
   971             }
  1008             }
   972         }
  1009         }
   973     if ( iUssdReplyTimer && iUssdReplyTimer->IsTimerActive() )
  1010     if ( iUssdReplyTimer && iUssdReplyTimer->IsTimerActive() )
   974         {
  1011         {
   975         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Timer.Stop" );
  1012         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Timer.Stop" );
  1002 //
  1039 //
  1003 void CPhSrvUssdManager::ShowDoneNoteL()
  1040 void CPhSrvUssdManager::ShowDoneNoteL()
  1004     {
  1041     {
  1005     _DDPRINT( 4, "PhSrv.ShowDoneNoteL.iShowDone", iShowDone );
  1042     _DDPRINT( 4, "PhSrv.ShowDoneNoteL.iShowDone", iShowDone );
  1006     // Show global confirmation note "Done"
  1043     // Show global confirmation note "Done"
  1007     HBufC* noteText = iResourceManager.ReadResourceLC( R_PHSRV_TEXT_DONE );
  1044     CHbDeviceMessageBoxSymbian::InformationL(
  1008     CAknGlobalNote* note = CAknGlobalNote::NewLC();
  1045         LoadDefaultString( KUssdDone ) );
  1009     note->ShowNoteL( EAknGlobalConfirmationNote, *noteText );
       
  1010     CleanupStack::PopAndDestroy( note );
       
  1011     CleanupStack::PopAndDestroy( noteText );
       
  1012     iShowDone = EFalse;
  1046     iShowDone = EFalse;
  1013     }
  1047     }
  1014 
  1048 
  1015 // -----------------------------------------------------------------------------
  1049 // -----------------------------------------------------------------------------
  1016 // CPhSrvUssdManager::ShowErrorNoteL
  1050 // CPhSrvUssdManager::ShowErrorNoteL
  1024         {
  1058         {
  1025         _DPRINT( 4, "PhSrv.ShowErrorNoteL.Return" );
  1059         _DPRINT( 4, "PhSrv.ShowErrorNoteL.Return" );
  1026         return;
  1060         return;
  1027         }
  1061         }
  1028 
  1062 
       
  1063     // Show specific error message
  1029     CTextResolver* textResolver = CTextResolver::NewLC();
  1064     CTextResolver* textResolver = CTextResolver::NewLC();
  1030 
       
  1031     HBufC* buffer = textResolver->ResolveErrorString( aError ).AllocLC();
  1065     HBufC* buffer = textResolver->ResolveErrorString( aError ).AllocLC();
  1032 
  1066 
  1033     CAknGlobalNote* note = CAknGlobalNote::NewLC();
  1067     CHbDeviceMessageBoxSymbian::InformationL( buffer ->Des() );
  1034     note->ShowNoteL( EAknGlobalErrorNote, *buffer );
  1068 
  1035 
  1069     CleanupStack::PopAndDestroy( buffer ); 
  1036     CleanupStack::PopAndDestroy( 3 ); // note, buffer, textResolver
  1070     CleanupStack::PopAndDestroy( textResolver ); 
       
  1071     
       
  1072     
  1037     _DPRINT( 4, "PhSrv.ShowErrorNoteL.End" );
  1073     _DPRINT( 4, "PhSrv.ShowErrorNoteL.End" );
  1038     return;
  1074     return;
  1039     }
  1075     }
  1040 
  1076 
  1041 
  1077 
  1224     delete iUssdReplyTimer;
  1260     delete iUssdReplyTimer;
  1225     iUssdReplyTimer = NULL;
  1261     iUssdReplyTimer = NULL;
  1226 
  1262 
  1227     if ( aError == KErrNone &&
  1263     if ( aError == KErrNone &&
  1228          IsActive() &&
  1264          IsActive() &&
  1229          iGlobalMsgQuery )
  1265          iDeviceDialog ) 
  1230         {
  1266         {
  1231         Cancel();
  1267         Cancel();
  1232         // Terminates USSD session.
  1268         // Terminates USSD session.
  1233         _DPRINT( 4, "PhSrv.ReplyTimer.SendRelease" );     // debug print
  1269         _DPRINT( 4, "PhSrv.ReplyTimer.SendRelease" );     // debug print
  1234         if ( iNotifyArray ) 
  1270         if ( iNotifyArray ) 
  1240     _DPRINT( 4, "PhSrv.ReplyTimer.End" );     // debug print
  1276     _DPRINT( 4, "PhSrv.ReplyTimer.End" );     // debug print
  1241     }
  1277     }
  1242 
  1278 
  1243 
  1279 
  1244 // -----------------------------------------------------------------------------
  1280 // -----------------------------------------------------------------------------
       
  1281 // CPhSrvUssdManager::MessageBoxClosed
       
  1282 // -----------------------------------------------------------------------------
       
  1283 //       
       
  1284 void CPhSrvUssdManager::MessageBoxClosed(
       
  1285     const CHbDeviceMessageBoxSymbian* aMessageBox,
       
  1286     CHbDeviceMessageBoxSymbian::TButtonId aButton)
       
  1287     {
       
  1288     _DPRINT( 4, "PhSrv.MsgClose.Start" );
       
  1289     // ussd device dialog observer callback function
       
  1290     TPtrC leftBtn = aMessageBox->ButtonText( 
       
  1291         CHbDeviceMessageBoxSymbian::EAcceptButton );
       
  1292     TPtrC rightBtn = aMessageBox->ButtonText( 
       
  1293         CHbDeviceMessageBoxSymbian::ERejectButton );    
       
  1294 
       
  1295     TInt err = KErrNone;
       
  1296     // Click Yes on Confirmation note (Yes, No) 
       
  1297     if ( !leftBtn.Compare( 
       
  1298           LoadDefaultString( KUssdYes ) ) && 
       
  1299           ( CHbDeviceMessageBoxSymbian::EAcceptButton == aButton ) )
       
  1300         {
       
  1301         _DPRINT( 4, "PhSrv.MsgClose.SK.Yes" );
       
  1302         iClearArray = EFalse;
       
  1303         iNotifyArray->Reset();
       
  1304         TryCloseSession();
       
  1305         }
       
  1306     // Click "No" on Confirmation note (Yes, No) 
       
  1307     else if ( !rightBtn.Compare( 
       
  1308                LoadDefaultString( KUssdNo ) ) && 
       
  1309               ( CHbDeviceMessageBoxSymbian::ERejectButton == aButton ) )
       
  1310         {
       
  1311         _DPRINT( 4, "PhSrv.MsgClose.SK.No" );
       
  1312         iClearArray = EFalse;
       
  1313         iNotifyMessage = ETrue; // for removing the yes/no query
       
  1314         CheckArray();
       
  1315         TryCloseSession();
       
  1316         }
       
  1317     // Click "Next" on Notification note (Next, Exit) 
       
  1318     else if ( !leftBtn.Compare( 
       
  1319                LoadDefaultString( KUssdNext ) ) && 
       
  1320                ( CHbDeviceMessageBoxSymbian::EAcceptButton == aButton ) )
       
  1321         {
       
  1322         _DPRINT( 4, "PhSrv.MsgClose.SK.Next" ); 
       
  1323         CheckArray();
       
  1324         TryCloseSession();
       
  1325         }
       
  1326     // Click "Exit" on Notification note (Next, Exit or only Exit) 
       
  1327     else if ( !rightBtn.Compare( 
       
  1328                LoadDefaultString( KUssdExit ) ) && 
       
  1329                ( CHbDeviceMessageBoxSymbian::ERejectButton == aButton ) )
       
  1330         {
       
  1331         TRAP( err, ClearArrayL() );
       
  1332         _DDPRINT( 4, "PhSrv.MsgClose.SK.Clear.%d", err );
       
  1333         TryCloseSession();
       
  1334         _DPRINT( 4, "PhSrv.MsgClose.SK.Exit" ); 
       
  1335         }
       
  1336     // Click "Reply" on Message note (Reply, Exit) 
       
  1337     else if ( !leftBtn.Compare( 
       
  1338                LoadDefaultString( KUssdReply ) ) && 
       
  1339                ( CHbDeviceMessageBoxSymbian::EAcceptButton == aButton ) )
       
  1340         {
       
  1341         // Answer
       
  1342         iStartEditor = ETrue;
       
  1343         iShowDone = EFalse;
       
  1344         // Start the USSD editor now.
       
  1345         TRAP( err, RequestStartEditingL() );
       
  1346         _DDPRINT( 4, "PhSrv.MsgClose.RequestStartEditingL.%d", err );
       
  1347         }    
       
  1348     else 
       
  1349         {
       
  1350         _DPRINT( 4, "PhSrv.MsgClose.SK.Default" ); 
       
  1351         }
       
  1352   
       
  1353     _DPRINT( 4, "PhSrv.MsgClose.End" ); 
       
  1354     }
       
  1355 
       
  1356 // -----------------------------------------------------------------------------
  1245 // CPhSrvUssdManager::RunL
  1357 // CPhSrvUssdManager::RunL
  1246 // -----------------------------------------------------------------------------
  1358 // -----------------------------------------------------------------------------
  1247 //
  1359 //
  1248 void CPhSrvUssdManager::RunL()
  1360 void CPhSrvUssdManager::RunL()
  1249     {
  1361     {
  1250     _DPRINT( 4, "PhSrv.RunL.Start" );           // debug print
  1362     _DPRINT( 4, "PhSrv.RunL.Start" );    
  1251 
  1363 
  1252     ProcessMoAcksL();
  1364     ProcessMoAcksL();
  1253     
  1365     
  1254     if ( iLaunchGMQ )
  1366     if ( iLaunchGMQ )
  1255         {
  1367         {
  1259         _DPRINT( 4, "PhSrv.iLaunchGMQ.EFalse" );
  1371         _DPRINT( 4, "PhSrv.iLaunchGMQ.EFalse" );
  1260         }
  1372         }
  1261     else
  1373     else
  1262         {
  1374         {
  1263         iStartEditor = EFalse;
  1375         iStartEditor = EFalse;
  1264         
  1376         // update device dialog
  1265         TInt key = iStatus.Int();
       
  1266         if ( key == EEikBidOk ) // OK key
       
  1267             {
       
  1268             if ( NetworkWaitingForAnAnswer() )
       
  1269                 {
       
  1270                 key = EAknSoftkeyShow;
       
  1271                 }
       
  1272             else
       
  1273                 {
       
  1274                 key = EAknSoftkeyExit;
       
  1275                 }
       
  1276             }
       
  1277 
       
  1278         switch( key )
       
  1279             {
       
  1280             case EAknSoftkeyShow:
       
  1281                 {
       
  1282                 // Answer
       
  1283                 iStartEditor = ETrue;
       
  1284                 iShowDone = EFalse;
       
  1285                 // Start the USSD editor now.
       
  1286                 _DPRINT( 4, "PhSrv.RunL.RequestStartEditingL" ); // debug print
       
  1287                 RequestStartEditingL();
       
  1288                 break;
       
  1289                 }
       
  1290             case EAknSoftkeyYes:
       
  1291                 {
       
  1292                 _DPRINT( 4, "PhSrv.RunL.SK.Yes" );
       
  1293                 iClearArray = EFalse;
       
  1294                 iNotifyArray->Reset();
       
  1295                 TryCloseSession();
       
  1296                 break;
       
  1297                 }
       
  1298             case EAknSoftkeyCancel:
       
  1299                 _DPRINT( 4, "PhSrv.RunL.SK.Cancel" ); 
       
  1300                 if ( iHavePendingSatMessagePointer )
       
  1301                     {
       
  1302                     iSatCanceled = ETrue;
       
  1303                     CompleteSatL( &iReceivedMessage, KErrCancel );
       
  1304                     _DPRINT( 4, "PhSrv.RunL.CompleteSatL" );
       
  1305                     }
       
  1306                 // fall through.
       
  1307             case EAknSoftkeyExit:
       
  1308                 _DPRINT( 4, "PhSrv.RunL.SK.Exit" ); 
       
  1309                 ClearArrayL();
       
  1310                 TryCloseSession();
       
  1311                 break;
       
  1312             case EAknSoftkeyBack:
       
  1313                 _DPRINT( 4, "PhSrv.RunL.SK.Back" ); 
       
  1314                 ClearArrayL();
       
  1315                 TryCloseSession();
       
  1316                 break;
       
  1317             case EAknSoftkeyNo:
       
  1318                 _DPRINT( 4, "PhSrv.RunL.SK.No" );
       
  1319                 iClearArray = EFalse;
       
  1320                 iNotifyMessage = ETrue; // for removing the yes/no query
       
  1321                 // fall through.
       
  1322             case EAknSoftkeyNext:
       
  1323                 _DPRINT( 4, "PhSrv.RunL.SK.Next" ); 
       
  1324                 CheckArray();
       
  1325                 TryCloseSession();
       
  1326                 break;
       
  1327             default:
       
  1328                 _DPRINT( 4, "PhSrv.RunL.SK.Default" ); 
       
  1329                 break;
       
  1330             }
       
  1331         _DPRINT( 4, "PhSrv.RunL.End" );     // debug print
  1377         _DPRINT( 4, "PhSrv.RunL.End" );     // debug print
  1332         }
  1378         }
  1333     }
  1379     }
  1334 
  1380 
  1335 // -----------------------------------------------------------------------------
  1381 // -----------------------------------------------------------------------------
  1338 //
  1384 //
  1339 void CPhSrvUssdManager::LaunchGlobalMessageQueryL()
  1385 void CPhSrvUssdManager::LaunchGlobalMessageQueryL()
  1340     {
  1386     {
  1341     _DPRINT( 4, "PhSrv.LGMQ.start" );
  1387     _DPRINT( 4, "PhSrv.LGMQ.start" );
  1342     _DPRINT_FLAGS();
  1388     _DPRINT_FLAGS();
       
  1389 
  1343     if ( iNotifyMessage )
  1390     if ( iNotifyMessage )
  1344         {
  1391         {
  1345         _DDPRINT( 4, "PhSrv.LGMQ.NotifyMessage", iNotifyMessage );
  1392         _DDPRINT( 4, "PhSrv.LGMQ.NotifyMessage", iNotifyMessage );
  1346         iNotifyMessage = ETrue;
  1393         iNotifyMessage = ETrue;
  1347         TInt count = NotifyCount();
  1394         TInt count = NotifyCount();
       
  1395         //check softkey in avkon.rss 
  1348         if ( count > 1 )
  1396         if ( count > 1 )
  1349             {
  1397             {
  1350             iSoftkeys = R_AVKON_SOFTKEYS_NEXT_EXIT__NEXT;
  1398             // Next, Exit
       
  1399             iDeviceDialog->SetButton(
       
  1400                 CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue );            
       
  1401             iDeviceDialog->SetButtonTextL(
       
  1402                 CHbDeviceMessageBoxSymbian::EAcceptButton, 
       
  1403                 LoadDefaultString( KUssdNext ) );
       
  1404             iDeviceDialog->SetButton(
       
  1405                 CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );    
       
  1406             iDeviceDialog->SetButtonTextL(
       
  1407                 CHbDeviceMessageBoxSymbian::ERejectButton, 
       
  1408                 LoadDefaultString( KUssdExit ) );  
       
  1409             _DPRINT( 4, "PhSrv.LGMQ.Next&Exit" );
  1351             }
  1410             }
  1352         else
  1411         else
  1353             {
  1412             {
  1354             iSoftkeys = R_AVKON_SOFTKEYS_EXIT;
  1413             // Only Exit
       
  1414             iDeviceDialog->SetButton(
       
  1415                 CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse ); 
       
  1416             iDeviceDialog->SetButton(
       
  1417                 CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );               
       
  1418             iDeviceDialog->SetButtonTextL(
       
  1419                 CHbDeviceMessageBoxSymbian::ERejectButton, 
       
  1420                 LoadDefaultString( KUssdExit ) );   
       
  1421             _DPRINT( 4, "PhSrv.LGMQ.onlyExit" );
  1355             }
  1422             }
  1356         if ( iClearArray )
  1423         if ( iClearArray )
  1357             {
  1424             {
  1358             iSoftkeys = R_AVKON_SOFTKEYS_YES_NO;
  1425             // Yes, No
       
  1426             iDeviceDialog->SetButton(
       
  1427                 CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue );               
       
  1428             iDeviceDialog->SetButtonTextL(
       
  1429                 CHbDeviceMessageBoxSymbian::EAcceptButton, 
       
  1430                 LoadDefaultString( KUssdYes ) );
       
  1431             iDeviceDialog->SetButton(
       
  1432                 CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );              
       
  1433             iDeviceDialog->SetButtonTextL(
       
  1434                 CHbDeviceMessageBoxSymbian::ERejectButton, 
       
  1435                 LoadDefaultString( KUssdNo ) );  
       
  1436             _DPRINT( 4, "PhSrv.LGMQ.Yes&No" );
  1359             }
  1437             }
  1360         iReceivedMessage.Zero();
  1438         iReceivedMessage.Zero();
  1361         iReceivedMessage = (*iNotifyArray)[0];
  1439         iReceivedMessage = (*iNotifyArray)[0];
  1362         }
  1440         }
  1363     TurnLightsOn(); //Ensure lights on
  1441     TurnLightsOn(); //Ensure lights on
  1364 
  1442 
  1365     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery" ); // debug print
  1443     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery" ); // debug print
  1366     // Launch Global MessageQuery as requested.
  1444     // Launch Global MessageQuery as requested.
  1367     iGlobalMsgQuery->ShowMsgQueryL(iStatus, iReceivedMessage, iSoftkeys,
  1445     // Dialog not support header text, this code is only 
  1368             *iMeQuHeaderText, KNullDesC);
  1446     // for testing, not final solution.
  1369     _DPRINT( 4, "PhSrv.LGMQ.SetActive" );
  1447     TInt receiveLength = iReceivedMessage.Length();
  1370     SetActive();
  1448     _DDPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.MsgLength", receiveLength ); 
       
  1449     
       
  1450     TInt titleLength = LoadDefaultString( KUssdTitle ).Length();
       
  1451     _DDPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.TilteLength", titleLength );
       
  1452     
       
  1453     TInt length = receiveLength + titleLength;
       
  1454     _DDPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.TotalLength", length );    
       
  1455         
       
  1456     HBufC* titleAndText = HBufC::NewLC( length );
       
  1457     titleAndText->Des().Append( LoadDefaultString( KUssdTitle ) );
       
  1458     titleAndText->Des().Append( iReceivedMessage );
       
  1459     iDeviceDialog->SetTextL( titleAndText->Des() );
       
  1460     CleanupStack::Pop( titleAndText );
       
  1461     
       
  1462     iDeviceDialog->Close();
       
  1463     iDeviceDialog->ShowL();
  1371     iShowDone = EFalse;
  1464     iShowDone = EFalse;
       
  1465    
  1372     // Do nothing else in RunL this time.
  1466     // Do nothing else in RunL this time.
  1373     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.ret" ); // debug print
  1467     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.ret" ); // debug print
  1374     }
  1468     }
  1375 
  1469 
  1376 // -----------------------------------------------------------------------------
  1470 // -----------------------------------------------------------------------------
  1521             iNotifyArray->Reset();
  1615             iNotifyArray->Reset();
  1522             }
  1616             }
  1523         else
  1617         else
  1524             {
  1618             {
  1525             iReceivedMessage.Zero();
  1619             iReceivedMessage.Zero();
  1526             HBufC* unreadText = iResourceManager.ReadResourceLC( R_PHSRV_TEXT_UNREAD );
  1620             iReceivedMessage.Append( 
  1527             TPtr pMessage( unreadText->Des() );
  1621                 LoadDefaultString( KUssdConfirm ) );
  1528             iReceivedMessage.Append( pMessage );
       
  1529             iNotifyArray->InsertL( 0, iReceivedMessage );
  1622             iNotifyArray->InsertL( 0, iReceivedMessage );
  1530             CleanupStack::PopAndDestroy( unreadText );
       
  1531             iLaunchGMQ = ETrue;
  1623             iLaunchGMQ = ETrue;
  1532             iNotifyMessage = ETrue;
  1624             iNotifyMessage = ETrue;
  1533             _DPRINT( 4, "PhSrv.ClearArrayL.iNotifyMessage.ETrue" );
  1625             _DPRINT( 4, "PhSrv.ClearArrayL.iNotifyMessage.ETrue" );
  1534             iClearArray = ETrue;
  1626             iClearArray = ETrue;
  1535             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
  1627             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
  1543 
  1635 
  1544 // -----------------------------------------------------------------------------
  1636 // -----------------------------------------------------------------------------
  1545 // CPhSrvUssdManager::NotifyCount()
  1637 // CPhSrvUssdManager::NotifyCount()
  1546 // -----------------------------------------------------------------------------
  1638 // -----------------------------------------------------------------------------
  1547 //
  1639 //
  1548   TInt CPhSrvUssdManager:: NotifyCount()
  1640 TInt CPhSrvUssdManager:: NotifyCount()
  1549   {
  1641 {
  1550   return iNotifyArray->Count();
  1642     TInt count = iNotifyArray->Count();
  1551   }
  1643     _DDPRINT( 4, "PhSrv.NotifyCount:", count );     // debug print
  1552 
  1644     return count;
  1553   // -----------------------------------------------------------------------------
  1645 }
  1554 // CPhSrvUssdManager::UpdateNotifyMessage()
  1646 
  1555 // -----------------------------------------------------------------------------
  1647 // -----------------------------------------------------------------------------
  1556 //
  1648 // CPhSrvUssdManager::UpdateNotifyMessageL()
  1557   void CPhSrvUssdManager:: UpdateNotifyMessage()
  1649 // -----------------------------------------------------------------------------
  1558     {
  1650 //
  1559     _DDPRINT( 4, "PhSrv.UpdateNotifyMessage.Start, clear: ", iClearArray );     // debug print
  1651   void CPhSrvUssdManager:: UpdateNotifyMessageL()
       
  1652     {
       
  1653     _DDPRINT( 4, "PhSrv.UpdateNotifyMessageL.Start, clear: ", iClearArray );     // debug print
       
  1654 
       
  1655     // Show left softkey - "Next"
  1560     if (NotifyCount() > 1 && !iClearArray )
  1656     if (NotifyCount() > 1 && !iClearArray )
  1561         {
  1657         {
  1562         _DPRINT( 4, "PhSrv.UpdateNotifyMessage" );     // debug print
  1658         _DPRINT( 4, "PhSrv.UpdateNotifyMessageL" );     // debug print
  1563         iGlobalMsgQuery->UpdateMsgQuery( R_AVKON_SOFTKEYS_NEXT_EXIT__NEXT );
  1659         iDeviceDialog->SetButton( 
  1564         }
  1660             CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue ); 
  1565     _DPRINT( 4, "PhSrv.UpdateNotifyMessage.End" );     // debug print
  1661         iDeviceDialog->SetButtonTextL(
       
  1662             CHbDeviceMessageBoxSymbian::EAcceptButton, 
       
  1663             LoadDefaultString( KUssdNext ) );
       
  1664         }
       
  1665     // Remove left softkey
       
  1666     else
       
  1667         {
       
  1668         iDeviceDialog->SetButton( 
       
  1669                     CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse );         
       
  1670         }
       
  1671     iDeviceDialog->UpdateL();        
       
  1672     
       
  1673     _DPRINT( 4, "PhSrv.UpdateNotifyMessageL.End" );     // debug print
  1566     }
  1674     }
  1567 
  1675 
  1568 // -----------------------------------------------------------------------------
  1676 // -----------------------------------------------------------------------------
  1569 // CPhSrvUssdManager::DoCancel
  1677 // CPhSrvUssdManager::DoCancel
  1570 // -----------------------------------------------------------------------------
  1678 // -----------------------------------------------------------------------------
  1572 void CPhSrvUssdManager::DoCancel()
  1680 void CPhSrvUssdManager::DoCancel()
  1573     {
  1681     {
  1574     _DPRINT( 4, "PhSrv.DoCancel.Start" ); // debug print
  1682     _DPRINT( 4, "PhSrv.DoCancel.Start" ); // debug print
  1575     iTimer.Cancel();
  1683     iTimer.Cancel();
  1576     iLaunchGMQ = EFalse;
  1684     iLaunchGMQ = EFalse;
  1577 
  1685     if ( iDeviceDialog )
  1578     if ( iGlobalMsgQuery )
       
  1579         {
  1686         {
  1580         _DPRINT( 4, "PhSrv.DoCancel" ); // debug print
  1687         _DPRINT( 4, "PhSrv.DoCancel" ); // debug print
  1581         iGlobalMsgQuery->CancelMsgQuery();
  1688         iDeviceDialog->Close();
       
  1689         delete iDeviceDialog;
       
  1690         iDeviceDialog = NULL;
  1582         }
  1691         }
  1583     _DPRINT( 4, "PhSrv.DoCancel.End" ); // debug print
  1692     _DPRINT( 4, "PhSrv.DoCancel.End" ); // debug print
  1584     }
  1693     }
  1585 
  1694 
  1586 // -----------------------------------------------------------------------------
  1695 // -----------------------------------------------------------------------------
  1645 
  1754 
  1646             err = apaLsSession.StartApp( *apaCommandLine );
  1755             err = apaLsSession.StartApp( *apaCommandLine );
  1647             CleanupStack::PopAndDestroy( apaCommandLine );
  1756             CleanupStack::PopAndDestroy( apaCommandLine );
  1648             }
  1757             }
  1649         CleanupStack::PopAndDestroy(); // apaLsSession
  1758         CleanupStack::PopAndDestroy(); // apaLsSession
       
  1759         
       
  1760         // bring the ussd editor to foreground, only for testing
       
  1761         TApaTaskList tasklist( wsSession );
       
  1762         TApaTask task = tasklist.FindApp( TUid::Uid( KPhSrvUssdAppUID ) );
       
  1763         if ( task.Exists() )
       
  1764             {
       
  1765             _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.task.BringToForeground" );
       
  1766             task.BringToForeground();
       
  1767             }
       
  1768         // bring the ussd editor to foreground, only for testing
  1650         }
  1769         }
  1651     CleanupStack::PopAndDestroy(); // wsSession
  1770     CleanupStack::PopAndDestroy(); // wsSession
  1652 
  1771 
  1653     _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.end" ); // debug print
  1772     _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.end" ); // debug print
  1654     }
  1773     }
  1683     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.start" ); // debug print
  1802     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.start" ); // debug print
  1684     if ( iUssdReplyTimer )
  1803     if ( iUssdReplyTimer )
  1685         {
  1804         {
  1686         if ( iUssdReplyTimer->IsTimerActive() )
  1805         if ( iUssdReplyTimer->IsTimerActive() )
  1687             {
  1806             {
  1688             // debug print
  1807      
  1689             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer" );
  1808             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer" );
  1690 
  1809 
  1691             // Read the information what is the reason
  1810             // Read the information what is the reason
  1692             // for application termination.
  1811             // for application termination.
  1693             TPhCltUssdAppExitReason exitReason = EPhCltExitReasonUnknown;
  1812             TPhCltUssdAppExitReason exitReason = EPhCltExitReasonUnknown;
  1694             TPckg< TPhCltUssdAppExitReason > exitReasonPckg( exitReason );
  1813             TPckg< TPhCltUssdAppExitReason > exitReasonPckg( exitReason );
  1695             aMessage.ReadL(
  1814             aMessage.ReadL(
  1696                 0,
  1815                 0,
  1697                 exitReasonPckg );
  1816                 exitReasonPckg );
  1698 
  1817 
  1699             // debug print
  1818      
  1700             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer2" );
  1819             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer2" );
  1701 
  1820 
  1702             // If reason was the completion of send operation, the USSD
  1821             // If reason was the completion of send operation, the USSD
  1703             // session is not canceled, otherwise it is canceled.
  1822             // session is not canceled, otherwise it is canceled.
  1704             if ( exitReason != EPhCltSendCompleted )
  1823             if ( exitReason != EPhCltSendCompleted )
  1705                 {
  1824                 {
  1706                 // debug print
  1825          
  1707                 _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.SendRelease" );
  1826                 _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.SendRelease" );
  1708                 CloseSession();
  1827                 CloseSession();
  1709                 }
  1828                 }
  1710             }
  1829             }
  1711         }
  1830         }
  1769         _DPRINT( 4, "PhSrv.InformStartSAT.Complete.InUse" ); // debug print
  1888         _DPRINT( 4, "PhSrv.InformStartSAT.Complete.InUse" ); // debug print
  1770         aSatMessage.Complete( KErrInUse );
  1889         aSatMessage.Complete( KErrInUse );
  1771         }
  1890         }
  1772     else
  1891     else
  1773         {
  1892         {
  1774         _DPRINT( 4, "PhSrv.InformStartSAT.Set" );           // debug print
  1893         _DPRINT( 4, "PhSrv.InformStartSAT.Set" );    
  1775 
  1894 
  1776         // There was not pending SAT message
  1895         // There was not pending SAT message
  1777         iHavePendingSatMessagePointer = ETrue;
  1896         iHavePendingSatMessagePointer = ETrue;
  1778         _DDPRINT( 4, "PhSrv.UssdM.InformStartSAT.PendingSatPointer ", iHavePendingSatMessagePointer );
  1897         _DDPRINT( 4, "PhSrv.UssdM.InformStartSAT.PendingSatPointer ", iHavePendingSatMessagePointer );
  1779         iPendingSatMessagePointer = aSatMessage;
  1898         iPendingSatMessagePointer = aSatMessage;
  1787 // CPhSrvUssdManager::InformStopSAT
  1906 // CPhSrvUssdManager::InformStopSAT
  1788 // -----------------------------------------------------------------------------
  1907 // -----------------------------------------------------------------------------
  1789 //
  1908 //
  1790 void CPhSrvUssdManager::InformStopSAT()
  1909 void CPhSrvUssdManager::InformStopSAT()
  1791     {
  1910     {
  1792     _DPRINT( 4, "PhSrv.InformStopSAT.Start" );               // debug print
  1911     _DPRINT( 4, "PhSrv.InformStopSAT.Start" );        
  1793 
  1912 
  1794     // Do the actions only if there is pending SAT message.
  1913     // Do the actions only if there is pending SAT message.
  1795     if ( iHavePendingSatMessagePointer )
  1914     if ( iHavePendingSatMessagePointer )
  1796         {
  1915         {
  1797         _DPRINT( 4, "PhSrv.InformStopSAT.Complete.Cancel" ); // debug print
  1916         _DPRINT( 4, "PhSrv.InformStopSAT.Complete.Cancel" ); // debug print
  1800             iPendingSatMessagePointer.Complete( KErrCancel );
  1919             iPendingSatMessagePointer.Complete( KErrCancel );
  1801             _DPRINT( 4, "PhSrv.InformStopSAT.Complete.KErrCancel" );
  1920             _DPRINT( 4, "PhSrv.InformStopSAT.Complete.KErrCancel" );
  1802             }
  1921             }
  1803         iHavePendingSatMessagePointer = EFalse;
  1922         iHavePendingSatMessagePointer = EFalse;
  1804         }
  1923         }
  1805     _DPRINT( 4, "PhSrv.InformStopSAT.End" );                 // debug print
  1924     _DPRINT( 4, "PhSrv.InformStopSAT.End" );          
  1806     }
  1925     }
  1807 
  1926 
  1808 // -----------------------------------------------------------------------------
  1927 // -----------------------------------------------------------------------------
  1809 // CPhSrvUssdManager::ShowNotes
  1928 // CPhSrvUssdManager::ShowNotes
  1810 // -----------------------------------------------------------------------------
  1929 // -----------------------------------------------------------------------------
  1852 //
  1971 //
  1853 void CPhSrvUssdManager::CompleteSatL(
  1972 void CPhSrvUssdManager::CompleteSatL(
  1854     TDesC* aReceiveString,
  1973     TDesC* aReceiveString,
  1855     TInt aError )
  1974     TInt aError )
  1856     {
  1975     {
  1857     _DPRINT( 4, "PhSrv.CompleteSatL.Start" );                // debug print
  1976     _DPRINT( 4, "PhSrv.CompleteSatL.Start" );         
  1858     if ( aReceiveString )
  1977     if ( aReceiveString )
  1859         {
  1978         {
  1860         if ( aReceiveString->Length() )
  1979         if ( aReceiveString->Length() )
  1861             {
  1980             {
  1862             _DPRINT( 4, "PhSrv.CompleteSatL.recString.>0" ); // debug print
  1981             _DPRINT( 4, "PhSrv.CompleteSatL.recString.>0" ); // debug print
  1863             // copy the received string to client side.
  1982             // copy the received string to client side.
  1864             if ( iPendingSatMessagePointer.Int1() < aReceiveString->Length() )
  1983             if ( iPendingSatMessagePointer.Int1() < aReceiveString->Length() )
  1865                 {
  1984                 {
  1866                 // debug print
  1985          
  1867                 _DPRINT( 4, "PhSrv.CompleteSatL.recString.LengthError" );
  1986                 _DPRINT( 4, "PhSrv.CompleteSatL.recString.LengthError" );
  1868                 if ( !iPendingSatMessagePointer.IsNull() )
  1987                 if ( !iPendingSatMessagePointer.IsNull() )
  1869                     {
  1988                     {
  1870                     iPendingSatMessagePointer.Complete( KErrOverflow );
  1989                     iPendingSatMessagePointer.Complete( KErrOverflow );
  1871                     _DPRINT( 4, "PhSrv.CompleteSatLComplete.KErrOverFlow" );
  1990                     _DPRINT( 4, "PhSrv.CompleteSatLComplete.KErrOverFlow" );
  1885                 0,
  2004                 0,
  1886                 dcsPackage );
  2005                 dcsPackage );
  1887             }
  2006             }
  1888         }
  2007         }
  1889         }
  2008         }
  1890     _DPRINT( 4, "PhSrv.CompleteSatL.Middle" );           // debug print
  2009     _DPRINT( 4, "PhSrv.CompleteSatL.Middle" );    
  1891     if ( !iPendingSatMessagePointer.IsNull() )
  2010     if ( !iPendingSatMessagePointer.IsNull() )
  1892         {
  2011         {
  1893         if ( aReceiveString && !iSatCanceled )
  2012         if ( aReceiveString && !iSatCanceled )
  1894             {
  2013             {
  1895             _DDPRINT( 4, "PhSrv.CompleteSatL.Complete.", iReturnResult.iOpCode  );   // debug print
  2014             _DDPRINT( 4, "PhSrv.CompleteSatL.Complete.", iReturnResult.iOpCode  );   // debug print
  1902             }
  2021             }
  1903         }
  2022         }
  1904 
  2023 
  1905     iHavePendingSatMessagePointer = EFalse;
  2024     iHavePendingSatMessagePointer = EFalse;
  1906 
  2025 
  1907     _DPRINT( 4, "PhSrv.CompleteSatL.End" );           // debug print
  2026     _DPRINT( 4, "PhSrv.CompleteSatL.End" );    
  1908     }
  2027     }
  1909 
  2028 
  1910 
  2029 
  1911 // -----------------------------------------------------------------------------
  2030 // -----------------------------------------------------------------------------
  1912 // CPhSrvUssdManager::IsTelephonyFeatureSupported
  2031 // CPhSrvUssdManager::IsTelephonyFeatureSupported
  1925 //
  2044 //
  1926 // -----------------------------------------------------------------------------
  2045 // -----------------------------------------------------------------------------
  1927 //
  2046 //
  1928 TInt CPhSrvUssdManager::PlayUssdTone()
  2047 TInt CPhSrvUssdManager::PlayUssdTone()
  1929     {
  2048     {
  1930     _DPRINT( 4, "PhSrv.UssdM.PlayTone.start" );           // debug print
  2049     _DPRINT( 4, "PhSrv.UssdM.PlayTone.start" );    
  1931 
  2050 
  1932     TInt err = KErrNone;
  2051     TInt err = KErrNone;
  1933 // <-- QT PHONE  START-->
  2052 // <-- QT PHONE  START-->
  1934 //    RProperty::Define( KPSUidNcnList, KNcnPlayAlertTone, RProperty::EInt, ECapability_None , ECapabilityWriteDeviceData );
  2053 //    RProperty::Define( KPSUidNcnList, KNcnPlayAlertTone, RProperty::EInt, ECapability_None , ECapabilityWriteDeviceData );
  1935 //    RProperty::Set( KPSUidNcnList, KNcnPlayAlertTone, KPhSrvUssdTone );
  2054 //    RProperty::Set( KPSUidNcnList, KNcnPlayAlertTone, KPhSrvUssdTone );
  1950 //
  2069 //
  1951 TInt CPhSrvUssdManager::GetTelephonyVariantData()
  2070 TInt CPhSrvUssdManager::GetTelephonyVariantData()
  1952     {
  2071     {
  1953     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.Start" );
  2072     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.Start" );
  1954     TInt err = KErrNone;
  2073     TInt err = KErrNone;
       
  2074 // <-- QT PHONE START-->
       
  2075 /*
       
  2076     // Variation data should be unchangable during run-time,
       
  2077     // therefore, if once succesfully read, later reads are
       
  2078     // not allowed.
       
  2079     if ( iVariantReadOnlyValues == KPhSrvDefaultValue )
       
  2080         {
       
  2081         CRepository* cenRepSession = NULL;
       
  2082         TRAP ( err ,
       
  2083                cenRepSession = CRepository::NewL( KCRUidTelVariation ) );
       
  2084         if ( err == KErrNone )
       
  2085             {
       
  2086             err = cenRepSession->Get( KTelVariationFlags,
       
  2087                                    iVariantReadOnlyValues );
       
  2088             }
       
  2089         delete cenRepSession;
       
  2090         }
       
  2091 
       
  2092     _DDPRINT( 4, "PhSrv.UssdM.variant", iVariantReadOnlyValues ); // debug print
       
  2093     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.End" );
       
  2094     */
       
  2095 // <-- QT PHONE END-->
  1955     return err;
  2096     return err;
  1956     }
  2097     }
  1957 
  2098 
  1958 
  2099 
  1959 // -----------------------------------------------------------------------------
  2100 // -----------------------------------------------------------------------------
  1961 //
  2102 //
  1962 // -----------------------------------------------------------------------------
  2103 // -----------------------------------------------------------------------------
  1963 //
  2104 //
  1964 void CPhSrvUssdManager::SendMoAcknowledgementL()
  2105 void CPhSrvUssdManager::SendMoAcknowledgementL()
  1965     {
  2106     {
  1966     _DPRINT( 4, "PhSrv.SendMoAckL.Start" );           // debug print
  2107     _DPRINT( 4, "PhSrv.SendMoAckL.Start" );    
  1967 
  2108 
  1968     // Acknowledge MT USSD message.
  2109     // Acknowledge MT USSD message.
  1969     RMobileUssdMessaging::TMobileUssdAttributesV1 msgAttribs;
  2110     RMobileUssdMessaging::TMobileUssdAttributesV1 msgAttribs;
  1970     msgAttribs.iFlags =
  2111     msgAttribs.iFlags =
  1971         RMobileUssdMessaging::KUssdMessageType +
  2112         RMobileUssdMessaging::KUssdMessageType +
  1979     msgAttribs.iDcs    = KPhSrvUssdDefaultDCS;
  2120     msgAttribs.iDcs    = KPhSrvUssdDefaultDCS;
  1980 
  2121 
  1981     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs = msgAttribs;
  2122     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs = msgAttribs;
  1982     SendHandlerL().SendUssdL( KNullDesC8() , attribs );
  2123     SendHandlerL().SendUssdL( KNullDesC8() , attribs );
  1983 
  2124 
  1984     _DPRINT( 4, "PhSrv.SendMoAckL.End" );           // debug print
  2125     _DPRINT( 4, "PhSrv.SendMoAckL.End" );    
  1985     }
  2126     }
  1986 
  2127 
  1987 // -----------------------------------------------------------------------------
  2128 // -----------------------------------------------------------------------------
  1988 // CPhSrvUssdManager::TurnLightsOn
  2129 // CPhSrvUssdManager::TurnLightsOn
  1989 //
  2130 //
  1990 // -----------------------------------------------------------------------------
  2131 // -----------------------------------------------------------------------------
  1991 //
  2132 //
  1992 void CPhSrvUssdManager::TurnLightsOn()
  2133 void CPhSrvUssdManager::TurnLightsOn()
  1993     {
  2134     {
  1994      _DPRINT( 4, "PhSrv.TurnLightsOn Start" );           // debug print
  2135     _DPRINT( 4, "PhSrv.TurnLightsOn.Start" );    
  1995 
  2136 
  1996 
  2137 
  1997          // Change the bit on and off. SysAp will detect that
  2138      // Change the bit on and off. SysAp will detect that
  1998      // the lights should be switched on for the specified time.
  2139      // the lights should be switched on for the specified time.
  1999      //
  2140      //
  2000          RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn);
  2141      RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn);
  2001          TInt err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOff);
  2142      TInt err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOff);
  2002 
  2143 
  2003          if ( err != KErrNone )
  2144      if ( err != KErrNone )
  2004                  {
  2145          {
  2005                  _DDPRINT( 4,"PhSrv.TurnLightsOn.Error: ",err );// debug print
  2146          _DDPRINT( 4,"PhSrv.TurnLightsOn.Error: ",err );// debug print
  2006                  }
  2147          }
  2007 
  2148 
  2008      _DPRINT( 4, "PhSrv.TurnLightsOn.End" );           // debug print
  2149     _DPRINT( 4, "PhSrv.TurnLightsOn.End" );    
  2009     }
  2150     }
       
  2151 
       
  2152 // -----------------------------------------------------------------------------
       
  2153 // CPhSrvUssdManager::LoadDefaultString
       
  2154 // -----------------------------------------------------------------------------
       
  2155 //
       
  2156 const TPtrC CPhSrvUssdManager::LoadDefaultString( const TDesC& aText )
       
  2157     {
       
  2158     _DPRINT( 4, "PhSrv.LoadDefaultString.Start" );
       
  2159     
       
  2160     if ( iTextBuffer )
       
  2161         {
       
  2162         delete iTextBuffer;
       
  2163         iTextBuffer = NULL;
       
  2164         _DPRINT( 4, "PhSrv.LoadDefaultString.Clear" );
       
  2165         }
       
  2166     TInt err = KErrNone;
       
  2167     TPtrC ptr( aText );
       
  2168     if ( iTextResolver && ptr.Length() )
       
  2169         {
       
  2170         TRAP( err, iTextBuffer = HbTextResolverSymbian::LoadL( ptr ) );
       
  2171         _DDPRINT( 4, "PhSrv.LoadDefaultString.LoadL.%d", err );
       
  2172         if ( iTextBuffer )
       
  2173             {
       
  2174             ptr.Set( iTextBuffer->Des() );   
       
  2175             _DPRINT( 4, "PhSrv.LoadDefaultString.Set" );
       
  2176             }
       
  2177         }    
       
  2178     _DPRINT( 4, "PhSrv.LoadDefaultString.End" );
       
  2179     return ptr;
       
  2180     }
       
  2181 
  2010 // End of File
  2182 // End of File