phoneclientserver/phoneserver/Src/Ussd/CPhSrvUssdManager.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
parent 18 594d59766373
child 20 987c9837762f
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
     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".
    14 * Description:  USSD Manager.
    14 * Description:  USSD Manager.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 #include "CPhSrvUssdManager.h"
    19 #include "cphsrvussdmanager.h" 
    20 #include "PhSrvUtils.h"
    20 #include "phsrvutils.h" 
    21 #include "CPhSrvUssdSendHandler.h"
    21 #include "cphsrvussdsendhandler.h" 
    22 #include "CPhSrvUssdReceiveHandler.h"
    22 #include "cphsrvussdreceivehandler.h" 
    23 #include "CPhSrvUssdNotifyNWRelease.h"
    23 #include "cphsrvussdnotifynwrelease.h" 
    24 #include "CPhSrvResourceManager.h"
    24 #include "cphsrvresourcemanager.h" 
    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 <telservicesvariant.hrh>
    44 #include "phsrvdebuginfo.h" 
    51 #include "PhSrvDebugInfo.h"
       
    52 #include <e32property.h>
    45 #include <e32property.h>
    53 
       
    54 #include <NcnListInternalPSKeys.h>
       
    55 #include <centralrepository.h>
    46 #include <centralrepository.h>
    56 #include <telservicesinternalcrkeys.h>
       
    57 #include <coreapplicationuisdomainpskeys.h>
    47 #include <coreapplicationuisdomainpskeys.h>
    58 
    48 
    59 //RM-RIM 417-66528
       
    60 #include <CUssdExtensionInterface.h>
       
    61 
    49 
    62 // CONSTANTS
    50 // CONSTANTS
    63 const TInt KPhSrvDefaultValue = 0x00000000;
    51 const TInt KPhSrvDefaultValue = 0x00000000;
    64 // const TInt KPhSrvUssdNoTone = 0; // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
    52 // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
    65 const TInt KPhSrvUssdTone   = 2; // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
    53 // const TInt KPhSrvUssdNoTone = 0; 
    66 
       
    67 // const TInt KPhSrvUssdTimeOutObserverGranularity = 2;
    54 // const TInt KPhSrvUssdTimeOutObserverGranularity = 2;
    68 // const TInt KPhSrvUssdSentMessageObserverGranularity = 2;
    55 // const TInt KPhSrvUssdSentMessageObserverGranularity = 2;
    69 const TInt KPhSrvUssdAppUID = 0x10005955;
    56 // See KUssdSecureId in phcltclientserver.h
       
    57 //const TInt KPhSrvUssdAppUID = 0x10005955; 
    70 
    58 
    71 const TInt KPhSrvUssdMessageQueryInterval = 500000; // 0.5 sec
    59 const TInt KPhSrvUssdMessageQueryInterval = 500000; // 0.5 sec
    72 const TInt KPhSrvUssdNoteExitPeriod = 500000; // 0.5 sec
    60 //const TInt KPhSrvUssdNoteExitPeriod = 500000; // 0.5 sec
    73 //
    61 //
    74 const TUint KPhSrvUssdDefaultDCS = 0x0f;                        // 00001111
    62 const TUint KPhSrvUssdDefaultDCS = 0x0f;                        // 00001111
    75 
    63 
    76 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguage = 0x10;// 00010000
    64 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguage = 0x10;// 00010000
    77 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguageSkipChars3 = 3;
    65 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguageSkipChars3 = 3;
    91 const TUint KPhSrvUssdDcsGeneralInformationAlphabetUCS2 = 0x08; // xxxx10xx
    79 const TUint KPhSrvUssdDcsGeneralInformationAlphabetUCS2 = 0x08; // xxxx10xx
    92 
    80 
    93 const TUint KPhSrvUssdDcsMessageHandlingAlphabetMask = 0xf4;    // 11110100
    81 const TUint KPhSrvUssdDcsMessageHandlingAlphabetMask = 0xf4;    // 11110100
    94 const TUint KPhSrvUssdDcsMessageHandlingAlphabet8Bit = 0xf4;    // 1111x1xx
    82 const TUint KPhSrvUssdDcsMessageHandlingAlphabet8Bit = 0xf4;    // 1111x1xx
    95 const TInt KPhrUssdNotifyArraySize = 1;
    83 const TInt KPhrUssdNotifyArraySize = 1;
       
    84 
       
    85 // Refers to HbPopup::NoDismiss = 0
       
    86 const TInt KPhSrvUssdPopupDismissPolicy = 0; 
       
    87 // The time out only for testing, from CPhSrvUssdReplyTimer.cpp
       
    88 const TUint KPhSrvUssdTimeout = 300000000;
       
    89 
       
    90 // Use QT style localization
       
    91 _LIT(KUssdLocFilename, "ussd_");
       
    92 _LIT(KCommonLocFilename, "common_");
       
    93 _LIT(KLocPath, "z:\\resource\\qt\\translations");
       
    94 _LIT(KUssdReply, "txt_ussd_button_reply"); // Reply
       
    95 _LIT(KUssdExit, "txt_ussd_button_exit"); // Exit
       
    96 _LIT(KUssdNext, "txt_ussd_button_next"); //Next
       
    97 _LIT(KUssdYes, "txt_common_button_yes"); // Yes
       
    98 _LIT(KUssdNo, "txt_common_button_no"); // No
       
    99 _LIT(KUssdTitle, "txt_ussd_title_message"); // Message
       
   100 _LIT(KUssdDone, "txt_ussd_dpopinfo_done"); // Done
       
   101 _LIT(KUssdConfirm, "txt_ussd_info_there_are_still_unread_notifications");
    96 
   102 
    97 // MACROS
   103 // MACROS
    98 
   104 
    99 #define _DPRINT_FLAGS() \
   105 #define _DPRINT_FLAGS() \
   100     _DDPRINT( 4, "PhSrv.FLAGS.MsgTypeReply ", iMsgTypeReply ); \
   106     _DDPRINT( 4, "PhSrv.FLAGS.MsgTypeReply ", iMsgTypeReply ); \
   379     CPhSrvResourceManager& aResourceManager
   385     CPhSrvResourceManager& aResourceManager
   380     )
   386     )
   381     :CActive( EPriorityLow ),
   387     :CActive( EPriorityLow ),
   382      iFsSession( aFsSession ),
   388      iFsSession( aFsSession ),
   383      iResourceManager( aResourceManager ),
   389      iResourceManager( aResourceManager ),
       
   390      iDeviceDialog( NULL ),
   384      iDCS ( KPhCltDcsUnknown ),
   391      iDCS ( KPhCltDcsUnknown ),
   385      iReturnResultPckg ( iReturnResult )
   392      iReturnResultPckg ( iReturnResult ),
   386 
   393      iTextBuffer ( NULL )
   387     {
   394     {
   388     CActiveScheduler::Add( this );
   395     CActiveScheduler::Add( this );
   389     }
   396     }
   390 
   397 
   391 
   398 
   396 //
   403 //
   397 // -----------------------------------------------------------------------------
   404 // -----------------------------------------------------------------------------
   398 //
   405 //
   399 CPhSrvUssdManager::~CPhSrvUssdManager()
   406 CPhSrvUssdManager::~CPhSrvUssdManager()
   400     {
   407     {
   401     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.start" );       // debug print
   408     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.start" );
   402 
   409 
   403 
   410 
   404     delete iUssdSendHandler;
   411     delete iUssdSendHandler;
   405     iUssdSendHandler = NULL;
   412     iUssdSendHandler = NULL;
   406 
   413 
   411     iUssdNotifyNWRelease = NULL;
   418     iUssdNotifyNWRelease = NULL;
   412 
   419 
   413     Cancel();
   420     Cancel();
   414 
   421 
   415     iTimer.Close();
   422     iTimer.Close();
   416 
   423     
   417     delete iGlobalMsgQuery;
   424     delete iTextBuffer;
   418     iGlobalMsgQuery = NULL;
   425     iTextBuffer = NULL;
       
   426     
       
   427     delete iDeviceDialog;
       
   428     iDeviceDialog = NULL;
   419 
   429 
   420     if ( iNotifyArray )
   430     if ( iNotifyArray )
   421         {
   431         {
   422         iNotifyArray->Reset();
   432         iNotifyArray->Reset();
   423         }
   433         }
   430     iUssdReplyTimer = NULL;
   440     iUssdReplyTimer = NULL;
   431 
   441 
   432     iFsSession.Close();
   442     iFsSession.Close();
   433 
   443 
   434     iMobileUssdMessaging.Close();
   444     iMobileUssdMessaging.Close();
   435 
       
   436     delete iMeQuHeaderText;
       
   437     iMeQuHeaderText = NULL;
       
   438     
   445     
   439     delete iMoAckCallback;
   446     delete iMoAckCallback;
   440 
   447 
   441     // RM-RIM 417-66528
   448     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.end" );
   442     delete iUssdExtnInterface;
       
   443     iUssdExtnInterface = NULL;
       
   444         
       
   445     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.end" );       // debug print
       
   446     }
   449     }
   447 
   450 
   448 
   451 
   449 // -----------------------------------------------------------------------------
   452 // -----------------------------------------------------------------------------
   450 // CPhSrvUssdManager::ConstructL
   453 // CPhSrvUssdManager::ConstructL
   453 //
   456 //
   454 // -----------------------------------------------------------------------------
   457 // -----------------------------------------------------------------------------
   455 //
   458 //
   456 void CPhSrvUssdManager::ConstructL( MPhSrvPhoneInterface& aPhoneInterface )
   459 void CPhSrvUssdManager::ConstructL( MPhSrvPhoneInterface& aPhoneInterface )
   457     {
   460     {
   458     _DPRINT( 4, "PhSrv.ConstructL.Start" );       // debug print
   461     _DPRINT( 4, "PhSrv.ConstructL.Start" );
       
   462     const TBool textResolver = HbTextResolverSymbian::Init( 
       
   463         KUssdLocFilename, KLocPath );
       
   464     _DDPRINT( 4, "PhSrv.ConstructL.ussd loc:", textResolver );
   459     User::LeaveIfError( iTimer.CreateLocal() );
   465     User::LeaveIfError( iTimer.CreateLocal() );
   460 
   466 
   461     User::LeaveIfError( iMobileUssdMessaging.Open( aPhoneInterface.PhSrvMobilePhone() ) );
   467     User::LeaveIfError( iMobileUssdMessaging.Open( aPhoneInterface.PhSrvMobilePhone() ) );
   462 
   468 
   463     // Check support
   469     // Check support
   489 
   495 
   490     iVariantReadOnlyValues = KPhSrvDefaultValue;
   496     iVariantReadOnlyValues = KPhSrvDefaultValue;
   491 
   497 
   492     User::LeaveIfError( GetTelephonyVariantData() );
   498     User::LeaveIfError( GetTelephonyVariantData() );
   493 
   499 
   494     iMeQuHeaderText = iResourceManager.ReadResourceLC(
   500     _DDPRINT( 4, "PhSrv.ConstructL.iSatCanceled ", iSatCanceled );
   495         R_PHSRV_USSD_MESQUERY_MESSAGE);
       
   496     CleanupStack::Pop( iMeQuHeaderText );
       
   497 
       
   498 	_DDPRINT( 4, "PhSrv.ConstructL.iSatCanceled ", iSatCanceled );
       
   499     _DDPRINT( 4, "PhSrv.ConstructL.iShowDone ", iShowDone );
   501     _DDPRINT( 4, "PhSrv.ConstructL.iShowDone ", iShowDone );
   500     iNotifyArray = new( ELeave ) CDesCArrayFlat( KPhrUssdNotifyArraySize );
   502     iNotifyArray = new( ELeave ) CDesCArrayFlat( KPhrUssdNotifyArraySize );
   501     
   503     _DPRINT( 4, "PhSrv.ConstructL.End" );
   502     // RM-RIM 417-66528
       
   503     TRAP_IGNORE(iUssdExtnInterface = CUssdExtensionInterface::NewL());
       
   504     _DPRINT( 4, "PhSrv.ConstructL.iUssdExtnInterface Created");
       
   505     _DPRINT( 4, "PhSrv.ConstructL.End" );       // debug print
       
   506     }
   504     }
   507 
   505 
   508 
   506 
   509 // -----------------------------------------------------------------------------
   507 // -----------------------------------------------------------------------------
   510 // CPhSrvUssdManager::SendHandlerL
   508 // CPhSrvUssdManager::SendHandlerL
   515 //
   513 //
   516 CPhSrvUssdSendHandler& CPhSrvUssdManager::SendHandlerL()
   514 CPhSrvUssdSendHandler& CPhSrvUssdManager::SendHandlerL()
   517     {
   515     {
   518     // If SendHandler is not created, first check that MO Ussd
   516     // If SendHandler is not created, first check that MO Ussd
   519     // is supported by the TSY.
   517     // is supported by the TSY.
   520     _DPRINT( 4, "PhSrv.SendHandlerL.Start" );       // debug print
   518     _DPRINT( 4, "PhSrv.SendHandlerL.Start" );
   521     if ( iUssdSendHandler == NULL )
   519     if ( iUssdSendHandler == NULL )
   522         {
   520         {
   523         _DPRINT( 4, "PhSrv.SendHandlerL.iUssdSendHandler.NULL" );       // debug print
   521         _DPRINT( 4, "PhSrv.SendHandlerL.iUssdSendHandler.NULL" );
   524         RMobileUssdMessaging::TMobileUssdCapsV1 caps;
   522         RMobileUssdMessaging::TMobileUssdCapsV1 caps;
   525         RMobileUssdMessaging::TMobileUssdCapsV1Pckg pckgCaps( caps );
   523         RMobileUssdMessaging::TMobileUssdCapsV1Pckg pckgCaps( caps );
   526         User::LeaveIfError( iMobileUssdMessaging.GetCaps( pckgCaps ) );
   524         User::LeaveIfError( iMobileUssdMessaging.GetCaps( pckgCaps ) );
   527         _DPRINT( 4, "PhSrv.SendHandlerL.iMobileUssdMessaging.GetCaps" );       // debug print
   525         _DPRINT( 4, "PhSrv.SendHandlerL.iMobileUssdMessaging.GetCaps" );
   528 
   526 
   529         if ( ( caps.iUssdTypes & RMobileUssdMessaging::KCapsMOUssd ) == 0 ||
   527         if ( ( caps.iUssdTypes & RMobileUssdMessaging::KCapsMOUssd ) == 0 ||
   530             ( caps.iUssdFormat & RMobileUssdMessaging::KCapsPackedString )
   528             ( caps.iUssdFormat & RMobileUssdMessaging::KCapsPackedString )
   531             == 0 )
   529             == 0 )
   532             {
   530             {
   533             _DPRINT( 4, "PhSrv.SendHandlerL.KErrNotSupported" );       // debug print
   531             _DPRINT( 4, "PhSrv.SendHandlerL.KErrNotSupported" );
   534             User::Leave( KErrNotSupported );
   532             User::Leave( KErrNotSupported );
   535             }
   533             }
   536 
   534 
   537         iUssdSendHandler =
   535         iUssdSendHandler =
   538             new( ELeave ) CPhSrvUssdSendHandler(
   536             new( ELeave ) CPhSrvUssdSendHandler(
   539                 *this,
   537                 *this,
   540                 iMobileUssdMessaging,
   538                 iMobileUssdMessaging,
   541                 *iPhoneInterface );
   539                 *iPhoneInterface );
   542         }
   540         }
   543     _DPRINT( 4, "PhSrv.SendHandlerL.End" );       // debug print
   541     _DPRINT( 4, "PhSrv.SendHandlerL.End" );
   544     return *iUssdSendHandler;
   542     return *iUssdSendHandler;
   545     }
   543     }
   546 
   544 
   547 
   545 
   548 // -----------------------------------------------------------------------------
   546 // -----------------------------------------------------------------------------
   555 void CPhSrvUssdManager::SendUssdL(
   553 void CPhSrvUssdManager::SendUssdL(
   556     const TDesC8& aMsgData,
   554     const TDesC8& aMsgData,
   557     RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttribute,
   555     RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttribute,
   558     MPhSrvUssdMessageSentObserver& aObserver )
   556     MPhSrvUssdMessageSentObserver& aObserver )
   559     {
   557     {
   560     _DPRINT( 4, "PhSrv.SendUssdL.Start ######" );           // debug print
   558     _DPRINT( 4, "PhSrv.SendUssdL.Start ######" );
   561     _DPRINT_FLAGS();
   559     _DPRINT_FLAGS();
   562     
       
   563     //417-66528
       
   564     if (iUssdExtnInterface)
       
   565         {
       
   566         if(!iUssdExtnInterface->ValidateUssdMsgSending(aMsgData,aMsgAttribute))
       
   567             {
       
   568             // invalid attempt to send USSD message. Show the note 
       
   569             User::Leave( KErrAccessDenied );
       
   570             }
       
   571         }
       
   572     
   560     
   573     if ( iObserver && iNetworkReleased ) 
   561     if ( iObserver && iNetworkReleased ) 
   574         {
   562         {
   575         // Network has been released but the previous send request is still alive.
   563         // Network has been released but the previous send request is still alive.
   576         // Cancel the pervious send operation, complete the old request with error
   564         // Cancel the pervious send operation, complete the old request with error
   577         // and clean up the pointer.
   565         // and clean up the pointer.
   578         _DPRINT( 4, "PhSrv.SendUssdL.Error.Complete.Existing" );           // debug print
   566         _DPRINT( 4, "PhSrv.SendUssdL.Error.Complete.Existing" );
   579         if ( iUssdSendHandler ) 
   567         if ( iUssdSendHandler ) 
   580             {
   568             {
   581             iUssdSendHandler->Cancel();
   569             iUssdSendHandler->Cancel();
   582             }
   570             }
   583         iObserver->UssdMessageSentObserverHandleResult( KErrSessionClosed );
   571         iObserver->UssdMessageSentObserverHandleResult( KErrSessionClosed );
   584         iObserver = NULL;
   572         iObserver = NULL;
   585         }
   573         }
   586     
   574     
   587     if ( iObserver || iSendingAck )
   575     if ( iObserver || iSendingAck )
   588         {
   576         {
   589         _DPRINT( 4, "PhSrv.SendUssdL.KErrInUse" );           // debug print
   577         _DPRINT( 4, "PhSrv.SendUssdL.KErrInUse" );
   590         // Other client is using the service.
   578         // Other client is using the service.
   591         User::Leave( KErrInUse );
   579         User::Leave( KErrInUse );
   592         }
   580         }
   593 
   581 
   594     // Check that message type is set
   582     // Check that message type is set
   595     if( ( aMsgAttribute.iFlags & RMobileUssdMessaging::KUssdMessageType )
   583     if( ( aMsgAttribute.iFlags & RMobileUssdMessaging::KUssdMessageType )
   596         == 0 )
   584         == 0 )
   597         _DPRINT( 4, "PhSrv.SendUssdL.KUssdMessageType.0" );       // debug print
   585         _DPRINT( 4, "PhSrv.SendUssdL.KUssdMessageType.0" );
   598         {
   586         {
   599         // Mesasge type not set -> Set it.
   587         // Mesasge type not set -> Set it.
   600         aMsgAttribute.iFlags |= RMobileUssdMessaging::KUssdMessageType;
   588         aMsgAttribute.iFlags |= RMobileUssdMessaging::KUssdMessageType;
   601         if ( NetworkWaitingForAnAnswer() )
   589         if ( NetworkWaitingForAnAnswer() )
   602             {
   590             {
   603             // Network is waiting for an answer
   591             // Network is waiting for an answer
   604             _DPRINT( 4, "PhSrv.SendUssdL.EUssdMOReply" );	// debug print
   592             _DPRINT( 4, "PhSrv.SendUssdL.EUssdMOReply" );   // debug print
   605             aMsgAttribute.iType = RMobileUssdMessaging::EUssdMOReply;
   593             aMsgAttribute.iType = RMobileUssdMessaging::EUssdMOReply;
   606             }
   594             }
   607         else
   595         else
   608             {
   596             {
   609             _DPRINT( 4, "PhSrv.SendUssdL.EUssdMORequest" );  // debug print
   597             _DPRINT( 4, "PhSrv.SendUssdL.EUssdMORequest" );  // debug print
   612         }
   600         }
   613         
   601         
   614     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs( aMsgAttribute );
   602     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs( aMsgAttribute );
   615     iShowDone = ETrue;
   603     iShowDone = ETrue;
   616     _DPRINT( 4, "PhSrv.SendUssdL.iShowDone.ETrue" );
   604     _DPRINT( 4, "PhSrv.SendUssdL.iShowDone.ETrue" );
   617     _DPRINT( 4, "PhSrv.SendUssdL.Send" );           // debug print
   605     _DPRINT( 4, "PhSrv.SendUssdL.Send" );
   618     SendHandlerL().SendUssdL( aMsgData , attribs );
   606     SendHandlerL().SendUssdL( aMsgData , attribs );
   619     iObserver = &aObserver;
   607     iObserver = &aObserver;
   620     // Not closing nor closed anymore
   608     // Not closing nor closed anymore
   621     iNetworkReleased = EFalse;
   609     iNetworkReleased = EFalse;
   622     iSendRelease = EFalse;
   610     iSendRelease = EFalse;
   627     if ( NetworkWaitingForAnAnswer() )
   615     if ( NetworkWaitingForAnAnswer() )
   628         {
   616         {
   629         _DPRINT( 4, "PhSrv.SendUssdCancel.TimerStop" );   // debug print
   617         _DPRINT( 4, "PhSrv.SendUssdCancel.TimerStop" );   // debug print
   630         iUssdReplyTimer->Stop();
   618         iUssdReplyTimer->Stop();
   631         }
   619         }
   632     _DPRINT( 4, "PhSrv.SendUssdL.End" );           // debug print
   620     _DPRINT( 4, "PhSrv.SendUssdL.End" );
   633     }
   621     }
   634 
   622 
   635 // -----------------------------------------------------------------------------
   623 // -----------------------------------------------------------------------------
   636 // CPhSrvUssdManager::NetworkWaitingForAnAnswer
   624 // CPhSrvUssdManager::NetworkWaitingForAnAnswer
   637 // -----------------------------------------------------------------------------
   625 // -----------------------------------------------------------------------------
   647 //
   635 //
   648 // -----------------------------------------------------------------------------
   636 // -----------------------------------------------------------------------------
   649 //
   637 //
   650 void CPhSrvUssdManager::SendUssdCancel()
   638 void CPhSrvUssdManager::SendUssdCancel()
   651     {
   639     {
   652     _DPRINT( 4, "PhSrv.SendUssdCancel.Start #######" );           // debug print
   640     _DPRINT( 4, "PhSrv.SendUssdCancel.Start #######" );
   653 
   641 
   654     // Ack sending should not be canceled unless it's about terminating
   642     // Ack sending should not be canceled unless it's about terminating
   655     // the whole session
   643     // the whole session
   656     _DPRINT_FLAGS();
   644     _DPRINT_FLAGS();
   657     if ( !iSendingAck || iSendRelease ) 
   645     if ( !iSendingAck || iSendRelease ) 
   666         iSatCanceled = ETrue;
   654         iSatCanceled = ETrue;
   667         }
   655         }
   668     iObserver = NULL;
   656     iObserver = NULL;
   669     
   657     
   670     SetActiveIfPendingNotificationsExist();
   658     SetActiveIfPendingNotificationsExist();
   671     _DPRINT( 4, "PhSrv.SendUssdCancel.End" );           // debug print
   659     _DPRINT( 4, "PhSrv.SendUssdCancel.End" );
   672     }
   660     }
   673 
   661 
   674 // -----------------------------------------------------------------------------
   662 // -----------------------------------------------------------------------------
   675 // CPhSrvUssdManager::SetActiveIfPendingNotificationsExist
   663 // CPhSrvUssdManager::SetActiveIfPendingNotificationsExist
   676 // -----------------------------------------------------------------------------
   664 // -----------------------------------------------------------------------------
   705         aError );
   693         aError );
   706 
   694 
   707     // complete SAT if needed
   695     // complete SAT if needed
   708     if ( aError < KErrNone )
   696     if ( aError < KErrNone )
   709         {
   697         {
   710         // debug print
   698  
   711         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.CompleteSat" );
   699         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.CompleteSat" );
   712         CompleteSatL( NULL, aError );
   700         CompleteSatL( NULL, aError );
   713         }
   701         }
   714 
   702 
   715     if ( iObserver )
   703     if ( iObserver )
   716         {
   704         {
   717         // debug print
   705  
   718         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.Observer" );
   706         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.Observer" );
   719 
   707 
   720         iObserver->UssdMessageSentObserverHandleResult( aError );
   708         iObserver->UssdMessageSentObserverHandleResult( aError );
   721         iObserver = NULL;
   709         iObserver = NULL;
   722         }
   710         }
   726     AsyncProcessMoAcks();
   714     AsyncProcessMoAcks();
   727     
   715     
   728     // debug print
   716     // debug print
   729     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.End" );
   717     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.End" );
   730     }
   718     }
       
   719 
   731 
   720 
   732 // -----------------------------------------------------------------------------
   721 // -----------------------------------------------------------------------------
   733 // CPhSrvUssdManager::UssdAppTaskExists
   722 // CPhSrvUssdManager::UssdAppTaskExists
   734 //
   723 //
   735 //
   724 //
   742     RWsSession wsSession;
   731     RWsSession wsSession;
   743     User::LeaveIfError(wsSession.Connect());
   732     User::LeaveIfError(wsSession.Connect());
   744     _DPRINT( 4, "PhSrv.UssdAppTaskExists.wsSession.Connect" );
   733     _DPRINT( 4, "PhSrv.UssdAppTaskExists.wsSession.Connect" );
   745     CleanupClosePushL(wsSession);
   734     CleanupClosePushL(wsSession);
   746     TApaTaskList tasklist(wsSession);
   735     TApaTaskList tasklist(wsSession);
   747     TApaTask task = tasklist.FindApp(TUid::Uid(KPhSrvUssdAppUID));
   736     TApaTask task = tasklist.FindApp( KUssdSecureId );
   748     ret = task.Exists();
   737     ret = task.Exists();
   749 
   738 
   750     CleanupStack::PopAndDestroy();
   739     CleanupStack::PopAndDestroy();
   751     return ret;
   740     return ret;
   752 }
   741 }
   769         aError );
   758         aError );
   770     _DPRINT_FLAGS();
   759     _DPRINT_FLAGS();
   771     if ( aError != KErrNone )
   760     if ( aError != KErrNone )
   772         {
   761         {
   773         TurnLightsOn(); //Ensure lights on
   762         TurnLightsOn(); //Ensure lights on
   774         // debug print
   763  
   775         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleReceivedEventL.ShErNote" );
   764         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleReceivedEventL.ShErNote" );
   776         ShowErrorNoteL( aError );
   765         ShowErrorNoteL( aError );
   777         }
   766         }
   778     else if ( iSendRelease )
   767     else if ( iSendRelease )
   779         {
   768         {
   786         }
   775         }
   787     }
   776     }
   788 
   777 
   789 // -----------------------------------------------------------------------------
   778 // -----------------------------------------------------------------------------
   790 // CPhSrvUssdManager::UssdHandleReceivedEventL
   779 // CPhSrvUssdManager::UssdHandleReceivedEventL
   791 //
       
   792 //
       
   793 //
       
   794 // -----------------------------------------------------------------------------
   780 // -----------------------------------------------------------------------------
   795 //
   781 //
   796 void CPhSrvUssdManager::UssdHandleReceivedEventL(
   782 void CPhSrvUssdManager::UssdHandleReceivedEventL(
   797     const TDes8& aMsgData,
   783     const TDes8& aMsgData,
   798     const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes )
   784     const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes )
   799     {
   785     {
   800     // This always is either ongoing transaction or starting a new based
   786     // This always is either ongoing transaction or starting a new based
   801     // on incoming message, mark transaction to be open.
   787     // on incoming message, mark transaction to be open.
   802     iNetworkReleased = EFalse;
   788     iNetworkReleased = EFalse;
   803 		
   789         
   804     // 2. Complete Send with some positive value.
   790     // 2. Complete Send with some positive value.
   805 	if ( iObserver )
   791     if ( iObserver )
   806         {
   792         {
   807         // debug print
   793  
   808         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Observer" );
   794         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Observer" );
   809         UssdNetworkObserverHandleSendEventL( 1 ); // some positive value
   795         UssdNetworkObserverHandleSendEventL( 1 ); // some positive value
   810         }
   796         }
   811 	
   797     
   812     if ( aMsgAttributes.iFlags&RMobileUssdMessaging::KUssdMessageType &&
   798     if ( aMsgAttributes.iFlags&RMobileUssdMessaging::KUssdMessageType &&
   813          aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest )
   799          aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest )
   814         {
   800         {
   815         // 3. Stop old reply timer and start new one if needed.
   801         // 3. Stop old reply timer and start new one if needed.
   816         RestartReplyTimerL();
   802         RestartReplyTimerL();
   827     iReceivedMessage.Zero();
   813     iReceivedMessage.Zero();
   828     DecodeL(aMsgData, iDecodedMessage, dcs);
   814     DecodeL(aMsgData, iDecodedMessage, dcs);
   829     if(iDecodedMessage.Length() > 0)
   815     if(iDecodedMessage.Length() > 0)
   830         {
   816         {
   831         iReceivedMessage = iDecodedMessage;
   817         iReceivedMessage = iDecodedMessage;
   832         }
       
   833     // 4. Invoke UssdExtensionPlugin
       
   834     // 417-66528
       
   835     TBool isResponseValidated = EFalse;
       
   836     if (iUssdExtnInterface)
       
   837         {
       
   838         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.InvokeExtension" );
       
   839         isResponseValidated = iUssdExtnInterface->ValidateUssdResponse(aMsgData);
       
   840         }
   818         }
   841     // 5. Show note.
   819     // 5. Show note.
   842     // debug print
   820     // debug print
   843     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Note" );
   821     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Note" );
   844     if ( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType ) ||
   822     if ( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType ) ||
   845             aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   823             aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   846         {
   824         {
   847         if ( !ShowNotesL() )
   825         if ( !ShowNotesL() )
   848             {
   826             {
   849             // debug print
   827      
   850             _DPRINT( 4,
   828             _DPRINT( 4,
   851                 "PhSrv.UssdHandleReceivedEventL.SAtReturn" );
   829                 "PhSrv.UssdHandleReceivedEventL.SAtReturn" );
   852             return;
   830             return;
   853             }
   831             }
   854         }
   832         }
   855     //6. Check if the response is valid for the extension
   833 
   856     //RM-RIM 417-66528
   834     // empty string is handled as ok message
   857     if (iUssdExtnInterface && isResponseValidated)
   835     if ( !iDecodedMessage.Length() )
   858         PorcessReceivedMessageInExtesnionL(aMsgData, aMsgAttributes);
   836         {
       
   837         TurnLightsOn(); //Ensure lights on
       
   838  
       
   839         _DPRINT( 4,
       
   840             "PhSrv.UssdHandleReceivedEventL.EmptyString" );
       
   841         
       
   842         ShowDoneNoteL();
       
   843 
       
   844  
       
   845         _DPRINT( 4,
       
   846             "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
       
   847         }
   859     else
   848     else
   860         ProcessReceivedMessageL(aMsgData, aMsgAttributes);
   849         {
       
   850         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
       
   851         iNotifyMessage = ( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTNotify );
       
   852         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
       
   853         _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
       
   854         iMsgTypeReply = ( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTReply );
       
   855         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
   861         
   856         
   862     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Editor" );
   857         if ( iNotifyMessage ) 
   863     if (aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest
       
   864             && UssdAppTaskExistsL())
       
   865         {
       
   866         iEmptyEditor = ETrue;
       
   867         } _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.End" );
       
   868     }
       
   869 // -----------------------------------------------------------------------------
       
   870 // CPhSrvUssdManager::ProcessReceivedMessageL
       
   871 //
       
   872 //
       
   873 //
       
   874 // -----------------------------------------------------------------------------
       
   875 //
       
   876 void CPhSrvUssdManager::ProcessReceivedMessageL(const TDes8& /*aMsgData*/,
       
   877         const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
       
   878     {
       
   879     // empty string is handled as ok message
       
   880     if (!iDecodedMessage.Length())
       
   881         {
       
   882         TurnLightsOn(); //Ensure lights on
       
   883 
       
   884         // debug print
       
   885         _DPRINT( 4,
       
   886                 "PhSrv.UssdHandleReceivedEventL.EmptyString" );
       
   887         ShowDoneNoteL();
       
   888         // debug print
       
   889         _DPRINT( 4,
       
   890                 "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
       
   891         }
       
   892     else
       
   893         {
       
   894         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
       
   895         iNotifyMessage = (aMsgAttributes.iType
       
   896                 == RMobileUssdMessaging::EUssdMTNotify);
       
   897         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage ); 
       
   898         _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
       
   899         iMsgTypeReply = (aMsgAttributes.iType
       
   900                 == RMobileUssdMessaging::EUssdMTReply);
       
   901         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
       
   902 
       
   903         if (iNotifyMessage)
       
   904             {
   858             {
   905             // need to send an MO ack
   859             // need to send an MO ack
   906             iAcksToBeSent++;
   860             iAcksToBeSent ++;
   907             }
   861             }
   908 
   862         
   909         if (iNotifyMessage || iMsgTypeReply)
   863         if ( !iDeviceDialog  ){
       
   864             iDeviceDialog = CHbDeviceMessageBoxSymbian::NewL(
       
   865                 CHbDeviceMessageBoxSymbian::EInformation );
       
   866             iDeviceDialog->SetObserver( this );
       
   867             iDeviceDialog->SetTimeout( KPhSrvUssdTimeout );
       
   868             iDeviceDialog->SetDismissPolicy ( KPhSrvUssdPopupDismissPolicy );
       
   869             iDeviceDialog->SetIconVisible(EFalse);
       
   870             
       
   871             // Show left key with empty string accoring to ui concept
       
   872             iDeviceDialog->SetButton( 
       
   873                 CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse );
       
   874             // Show Exit Key always
       
   875             iDeviceDialog->SetButton( 
       
   876                 CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );
       
   877             iDeviceDialog->SetButtonTextL(
       
   878                 CHbDeviceMessageBoxSymbian::ERejectButton, 
       
   879                 LoadDefaultString( KUssdExit ) );
       
   880             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Exit" );             
       
   881         }
       
   882       
       
   883         if ( iNotifyMessage || iMsgTypeReply )
   910             {
   884             {
   911             //This is for reply message in notifyarray
   885             //This is for reply message in notifyarray
   912             iNotifyMessage = ETrue;
   886             iNotifyMessage = ETrue;
   913             _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
   887             _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
   914 
   888 
   915             //Notify added to array
   889             //Notify added to array
   916             iNotifyArray->AppendL(iReceivedMessage);
   890             iNotifyArray->AppendL( iReceivedMessage );
   917 
   891 
   918             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" ); // debug print
   892             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" );
   919             UpdateNotifyMessage();
   893             UpdateNotifyMessageL();
   920 
   894 
   921             if (!iSendRelease && NotifyCount() <= 1)
   895             if ( !iSendRelease && NotifyCount() <= 1 )
   922                 {
   896                 {
   923                 _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" ); // debug print
   897                 _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" );
   924                 Cancel();
   898                 Cancel();
   925                 }
   899                 }
   926             }
   900             }
   927         else
   901         else
   928             {
   902             {
   929             // New message deletes old message, i.e. Cancel existing query.
   903             // New message deletes old message, i.e. Cancel existing query.
   930             Cancel();
   904             Cancel();
   931             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" ); // debug print
   905             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" );
   932             }
   906             }
   933         CreateGlobalMessageQueryL(aMsgAttributes);
   907 
       
   908         // Remove Reply key
       
   909         if( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType )
       
   910              || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
       
   911             {
       
   912             // Remove Answer key
       
   913             iDeviceDialog->SetButton( 
       
   914                 CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse );
       
   915             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NoAnswer" ); 
       
   916             }
       
   917         // Show Reply key
       
   918         else
       
   919             {
       
   920             iDeviceDialog->SetButton( 
       
   921                 CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue );              
       
   922             iDeviceDialog->SetButtonTextL(
       
   923                 CHbDeviceMessageBoxSymbian::EAcceptButton, 
       
   924                 LoadDefaultString( KUssdReply ) ); 
       
   925             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.WithAnswer" ); 
       
   926             }
       
   927 
       
   928  
       
   929         _DPRINT( 4,
       
   930             "PhSrv.UssdHandleReceivedEventL.String.Middle" );
       
   931 
       
   932         // Play the USSD tone if needed. Logically should be in RunL, but here
       
   933         // to give better balancing with voice and visible message.
       
   934         // <-- QT PHONE START-->
       
   935         /*
       
   936         if ( IsTelephonyFeatureSupported( KTelephonyLVFlagUssdTone ) )
       
   937             {
       
   938             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.PlayTone" );
       
   939             PlayUssdTone();
       
   940             }
       
   941         */
       
   942             // <-- QT PHONE END-->
       
   943         // Launch the new message query
       
   944         if ( !IsActive() )
       
   945             {
       
   946             iLaunchGMQ = ETrue;
       
   947             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
       
   948             SetActive();
       
   949             }
   934         AsyncProcessMoAcks();
   950         AsyncProcessMoAcks();
   935         } 
   951         }
   936     _DPRINT( 4, "PhSrv.ProcesdReceivedMessageL.End" );
   952     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Editor" );
   937     }
   953     if( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest && UssdAppTaskExistsL() )
   938 
   954         {
   939 // -----------------------------------------------------------------------------
   955         iEmptyEditor = ETrue;
   940 // CPhSrvUssdManager::PorcessReceivedMessageInExtesnionL
   956         }
   941 //
   957     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.End" );
   942 //
   958     }
   943 //
   959 
   944 // -----------------------------------------------------------------------------
       
   945 //
       
   946 void CPhSrvUssdManager::PorcessReceivedMessageInExtesnionL(
       
   947         const TDes8& /*aMsgData*/,
       
   948         const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
       
   949     {
       
   950     TInt errfromextension = KErrNone;
       
   951     // empty string is handled as ok message
       
   952     if (!iDecodedMessage.Length())
       
   953         {
       
   954         // debug print
       
   955         _DPRINT( 4,
       
   956                 "PhSrv.UssdHandleReceivedEventL.EmptyString" );
       
   957         //RM-RIM 417-66528
       
   958         TRAP_IGNORE(iUssdExtnInterface->ProcessReceivedUssdL(iDecodedMessage, errfromextension));
       
   959         // debug print
       
   960         _DPRINT( 4,
       
   961                 "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
       
   962         }
       
   963     else
       
   964         {
       
   965         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
       
   966         iNotifyMessage = (aMsgAttributes.iType
       
   967                 == RMobileUssdMessaging::EUssdMTNotify);
       
   968         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage ); 
       
   969         _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
       
   970         iMsgTypeReply = (aMsgAttributes.iType
       
   971                 == RMobileUssdMessaging::EUssdMTReply);
       
   972         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
       
   973 
       
   974         if (iNotifyMessage)
       
   975             {
       
   976             // need to send an MO ack
       
   977             iAcksToBeSent++;
       
   978             }
       
   979 
       
   980         if (iNotifyMessage || iMsgTypeReply)
       
   981             {
       
   982             //This is for reply message in notifyarray
       
   983             iNotifyMessage = ETrue;
       
   984             _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
       
   985             if (!iSendRelease && NotifyCount() <= 1)
       
   986                 {
       
   987                 _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" ); // debug print
       
   988                 Cancel();
       
   989                 }
       
   990             }
       
   991         else
       
   992             {
       
   993             // New message deletes old message, i.e. Cancel existing query.
       
   994             Cancel();
       
   995             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" ); // debug print
       
   996             }
       
   997         TInt errfromextension = KErrNone;
       
   998         ProcessMoAcksL();
       
   999         iLaunchGMQ = EFalse;
       
  1000         TRAP_IGNORE(iUssdExtnInterface->ProcessReceivedUssdL(iDecodedMessage, errfromextension)); 
       
  1001         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Extn.ProcessReceivedUssdL.ErrCode", errfromextension);
       
  1002         }
       
  1003     }
       
  1004 // -----------------------------------------------------------------------------
   960 // -----------------------------------------------------------------------------
  1005 // CPhSrvUssdManager::RestartReplyTimerL
   961 // CPhSrvUssdManager::RestartReplyTimerL
  1006 //
   962 //
  1007 //
   963 //
  1008 //
   964 //
  1034 // -----------------------------------------------------------------------------
   990 // -----------------------------------------------------------------------------
  1035 //
   991 //
  1036 void CPhSrvUssdManager::UssdNetworkObserverHandleNotifyNWReleaseL(
   992 void CPhSrvUssdManager::UssdNetworkObserverHandleNotifyNWReleaseL(
  1037 const RMobilePhone::TMobilePhoneSendSSRequestV3 & aReturnResult,
   993 const RMobilePhone::TMobilePhoneSendSSRequestV3 & aReturnResult,
  1038 TInt aError )
   994 TInt aError )
  1039 	{
   995     {
  1040  	_DDPRINT( 4, "PhSrv.UssdNotifyNWRelease ##### ", aError ); // debug print
   996     _DDPRINT( 4, "PhSrv.UssdNotifyNWRelease ##### ", aError ); // debug print
  1041     _DPRINT_FLAGS();
   997     _DPRINT_FLAGS();
  1042  	TBool showNotes = ShowNotesL();
   998     TBool showNotes = ShowNotesL();
  1043  	iNetworkReleased = ETrue;
   999     iNetworkReleased = ETrue;
  1044  	iSendingAck = EFalse;
  1000     iSendingAck = EFalse;
  1045     iSendRelease = EFalse;
  1001     iSendRelease = EFalse;
  1046  	iAcksToBeSent = 0;
  1002     iAcksToBeSent = 0;
  1047  	
  1003     
  1048  	if ( iHavePendingSatMessagePointer )
  1004     if ( iHavePendingSatMessagePointer )
  1049  		{
  1005         {
  1050  		iReturnResult = aReturnResult;
  1006         iReturnResult = aReturnResult;
  1051  		if ( !iSatCanceled )
  1007         if ( !iSatCanceled )
  1052  			{
  1008             {
  1053  			CompleteSatL(&iReceivedMessage, aError );
  1009             CompleteSatL(&iReceivedMessage, aError );
  1054 			_DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.CompleteSat" );       // debug print
  1010             _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.CompleteSat" );
  1055  			}
  1011             }
  1056  		}
  1012         }
  1057  	if ( iUssdReplyTimer && iUssdReplyTimer->IsTimerActive() )
  1013     if ( iUssdReplyTimer && iUssdReplyTimer->IsTimerActive() )
  1058     	{
  1014         {
  1059     	_DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Timer.Stop" );
  1015         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Timer.Stop" );
  1060     	iUssdReplyTimer->Stop();
  1016         iUssdReplyTimer->Stop();
  1061     	Cancel();
  1017         Cancel();
  1062     	CheckArray();
  1018         CheckArray();
  1063     	}
  1019         }
  1064     if ( showNotes && iShowDone )
  1020     if ( showNotes && iShowDone )
  1065         {
  1021         {
  1066         ShowDoneNoteL();
  1022         ShowDoneNoteL();
  1067         }
  1023         }
  1068     if ( iUssdSendHandler && iSendingAck ) 
  1024     if ( iUssdSendHandler && iSendingAck ) 
  1069         {
  1025         {
  1070         // if we are sending ack, it can be canceled.
  1026         // if we are sending ack, it can be canceled.
  1071         iUssdSendHandler->Cancel();
  1027         iUssdSendHandler->Cancel();
  1072         }
  1028         }
  1073     //417-66528
  1029     
  1074     //Notify Extension on NWRelease
       
  1075     if(iUssdExtnInterface)
       
  1076         {
       
  1077         iUssdExtnInterface->NotifyNWError(aError);
       
  1078         }
       
  1079     iSatCanceled = EFalse;
  1030     iSatCanceled = EFalse;
  1080     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.iSatCanceled.EFalse" );
  1031     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.iSatCanceled.EFalse" );
  1081     iShowDone = EFalse;
  1032     iShowDone = EFalse;
  1082     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Ending" );
  1033     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Ending" );
  1083     _DPRINT_FLAGS();
  1034     _DPRINT_FLAGS();
  1084     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.End" );
  1035     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.End" );
  1085 	}
  1036     }
  1086 
  1037 
  1087 // -----------------------------------------------------------------------------
  1038 // -----------------------------------------------------------------------------
  1088 // CPhSrvUssdManager::ShowDoneNoteL
  1039 // CPhSrvUssdManager::ShowDoneNoteL
  1089 //
  1040 //
  1090 // -----------------------------------------------------------------------------
  1041 // -----------------------------------------------------------------------------
  1091 //
  1042 //
  1092 void CPhSrvUssdManager::ShowDoneNoteL()
  1043 void CPhSrvUssdManager::ShowDoneNoteL()
  1093     {
  1044     {
  1094     _DDPRINT( 4, "PhSrv.ShowDoneNoteL.iShowDone", iShowDone );
  1045     _DDPRINT( 4, "PhSrv.ShowDoneNoteL.iShowDone", iShowDone );
  1095     // Show global confirmation note "Done"
  1046     // Show global confirmation note "Done"
  1096     HBufC* noteText = iResourceManager.ReadResourceLC( R_PHSRV_TEXT_DONE );
  1047     CHbDeviceMessageBoxSymbian::InformationL(
  1097     CAknGlobalNote* note = CAknGlobalNote::NewLC();
  1048         LoadDefaultString( KUssdDone ) );
  1098     note->ShowNoteL( EAknGlobalConfirmationNote, *noteText );
       
  1099     CleanupStack::PopAndDestroy( note );
       
  1100     CleanupStack::PopAndDestroy( noteText );
       
  1101     iShowDone = EFalse;
  1049     iShowDone = EFalse;
  1102     }
  1050     }
  1103 
  1051 
  1104 // -----------------------------------------------------------------------------
  1052 // -----------------------------------------------------------------------------
  1105 // CPhSrvUssdManager::ShowErrorNoteL
  1053 // CPhSrvUssdManager::ShowErrorNoteL
  1113         {
  1061         {
  1114         _DPRINT( 4, "PhSrv.ShowErrorNoteL.Return" );
  1062         _DPRINT( 4, "PhSrv.ShowErrorNoteL.Return" );
  1115         return;
  1063         return;
  1116         }
  1064         }
  1117 
  1065 
       
  1066     // Show specific error message
  1118     CTextResolver* textResolver = CTextResolver::NewLC();
  1067     CTextResolver* textResolver = CTextResolver::NewLC();
  1119 
       
  1120     HBufC* buffer = textResolver->ResolveErrorString( aError ).AllocLC();
  1068     HBufC* buffer = textResolver->ResolveErrorString( aError ).AllocLC();
  1121 
  1069 
  1122     CAknGlobalNote* note = CAknGlobalNote::NewLC();
  1070     CHbDeviceMessageBoxSymbian::InformationL( buffer ->Des() );
  1123     note->ShowNoteL( EAknGlobalErrorNote, *buffer );
  1071 
  1124 
  1072     CleanupStack::PopAndDestroy( buffer ); 
  1125     CleanupStack::PopAndDestroy( 3 ); // note, buffer, textResolver
  1073     CleanupStack::PopAndDestroy( textResolver ); 
       
  1074     
       
  1075     
  1126     _DPRINT( 4, "PhSrv.ShowErrorNoteL.End" );
  1076     _DPRINT( 4, "PhSrv.ShowErrorNoteL.End" );
  1127     return;
  1077     return;
  1128     }
  1078     }
  1129 
  1079 
  1130 
  1080 
  1313     delete iUssdReplyTimer;
  1263     delete iUssdReplyTimer;
  1314     iUssdReplyTimer = NULL;
  1264     iUssdReplyTimer = NULL;
  1315 
  1265 
  1316     if ( aError == KErrNone &&
  1266     if ( aError == KErrNone &&
  1317          IsActive() &&
  1267          IsActive() &&
  1318          iGlobalMsgQuery )
  1268          iDeviceDialog ) 
  1319         {
  1269         {
  1320         Cancel();
  1270         Cancel();
  1321         // Terminates USSD session.
  1271         // Terminates USSD session.
  1322         _DPRINT( 4, "PhSrv.ReplyTimer.SendRelease" );     // debug print
  1272         _DPRINT( 4, "PhSrv.ReplyTimer.SendRelease" );     // debug print
  1323         if ( iNotifyArray ) 
  1273         if ( iNotifyArray ) 
  1329     _DPRINT( 4, "PhSrv.ReplyTimer.End" );     // debug print
  1279     _DPRINT( 4, "PhSrv.ReplyTimer.End" );     // debug print
  1330     }
  1280     }
  1331 
  1281 
  1332 
  1282 
  1333 // -----------------------------------------------------------------------------
  1283 // -----------------------------------------------------------------------------
       
  1284 // CPhSrvUssdManager::MessageBoxClosed
       
  1285 // -----------------------------------------------------------------------------
       
  1286 //       
       
  1287 void CPhSrvUssdManager::MessageBoxClosed(
       
  1288     const CHbDeviceMessageBoxSymbian* aMessageBox,
       
  1289     CHbDeviceMessageBoxSymbian::TButtonId aButton)
       
  1290     {
       
  1291     _DPRINT( 4, "PhSrv.MsgClose.Start" );
       
  1292     // ussd device dialog observer callback function
       
  1293     TPtrC leftBtn = aMessageBox->ButtonText( 
       
  1294         CHbDeviceMessageBoxSymbian::EAcceptButton );
       
  1295     TPtrC rightBtn = aMessageBox->ButtonText( 
       
  1296         CHbDeviceMessageBoxSymbian::ERejectButton );    
       
  1297 
       
  1298     TInt err = KErrNone;
       
  1299     // Click Yes on Confirmation note (Yes, No) 
       
  1300     if ( !leftBtn.Compare( 
       
  1301           LoadDefaultString( KUssdYes ) ) && 
       
  1302           ( CHbDeviceMessageBoxSymbian::EAcceptButton == aButton ) )
       
  1303         {
       
  1304         _DPRINT( 4, "PhSrv.MsgClose.SK.Yes" );
       
  1305         iClearArray = EFalse;
       
  1306         iNotifyArray->Reset();
       
  1307         TryCloseSession();
       
  1308         }
       
  1309     // Click "No" on Confirmation note (Yes, No) 
       
  1310     else if ( !rightBtn.Compare( 
       
  1311                LoadDefaultString( KUssdNo ) ) && 
       
  1312               ( CHbDeviceMessageBoxSymbian::ERejectButton == aButton ) )
       
  1313         {
       
  1314         _DPRINT( 4, "PhSrv.MsgClose.SK.No" );
       
  1315         iClearArray = EFalse;
       
  1316         iNotifyMessage = ETrue; // for removing the yes/no query
       
  1317         CheckArray();
       
  1318         TryCloseSession();
       
  1319         }
       
  1320     // Click "Next" on Notification note (Next, Exit) 
       
  1321     else if ( !leftBtn.Compare( 
       
  1322                LoadDefaultString( KUssdNext ) ) && 
       
  1323                ( CHbDeviceMessageBoxSymbian::EAcceptButton == aButton ) )
       
  1324         {
       
  1325         _DPRINT( 4, "PhSrv.MsgClose.SK.Next" ); 
       
  1326         CheckArray();
       
  1327         TryCloseSession();
       
  1328         }
       
  1329     // Click "Exit" on Notification note (Next, Exit or only Exit) 
       
  1330     else if ( !rightBtn.Compare( 
       
  1331                LoadDefaultString( KUssdExit ) ) && 
       
  1332                ( CHbDeviceMessageBoxSymbian::ERejectButton == aButton ) )
       
  1333         {
       
  1334         TRAP( err, ClearArrayL() );
       
  1335         _DDPRINT( 4, "PhSrv.MsgClose.SK.Clear.%d", err );
       
  1336         TryCloseSession();
       
  1337         _DPRINT( 4, "PhSrv.MsgClose.SK.Exit" ); 
       
  1338         }
       
  1339     // Click "Reply" on Message note (Reply, Exit) 
       
  1340     else if ( !leftBtn.Compare( 
       
  1341                LoadDefaultString( KUssdReply ) ) && 
       
  1342                ( CHbDeviceMessageBoxSymbian::EAcceptButton == aButton ) )
       
  1343         {
       
  1344         // Answer
       
  1345         iStartEditor = ETrue;
       
  1346         iShowDone = EFalse;
       
  1347         // Start the USSD editor now.
       
  1348         TRAP( err, RequestStartEditingL() );
       
  1349         _DDPRINT( 4, "PhSrv.MsgClose.RequestStartEditingL.%d", err );
       
  1350         }    
       
  1351     else 
       
  1352         {
       
  1353         _DPRINT( 4, "PhSrv.MsgClose.SK.Default" ); 
       
  1354         }
       
  1355   
       
  1356     _DPRINT( 4, "PhSrv.MsgClose.End" ); 
       
  1357     }
       
  1358 
       
  1359 // -----------------------------------------------------------------------------
  1334 // CPhSrvUssdManager::RunL
  1360 // CPhSrvUssdManager::RunL
  1335 // -----------------------------------------------------------------------------
  1361 // -----------------------------------------------------------------------------
  1336 //
  1362 //
  1337 void CPhSrvUssdManager::RunL()
  1363 void CPhSrvUssdManager::RunL()
  1338     {
  1364     {
  1339     _DPRINT( 4, "PhSrv.RunL.Start" );           // debug print
  1365     _DPRINT( 4, "PhSrv.RunL.Start" );    
  1340 
  1366 
  1341     ProcessMoAcksL();
  1367     ProcessMoAcksL();
  1342     
  1368     
  1343     if ( iLaunchGMQ )
  1369     if ( iLaunchGMQ )
  1344         {
  1370         {
  1348         _DPRINT( 4, "PhSrv.iLaunchGMQ.EFalse" );
  1374         _DPRINT( 4, "PhSrv.iLaunchGMQ.EFalse" );
  1349         }
  1375         }
  1350     else
  1376     else
  1351         {
  1377         {
  1352         iStartEditor = EFalse;
  1378         iStartEditor = EFalse;
  1353         
  1379         // update device dialog
  1354         TInt key = iStatus.Int();
       
  1355         if ( key == EEikBidOk ) // OK key
       
  1356             {
       
  1357             if ( NetworkWaitingForAnAnswer() )
       
  1358                 {
       
  1359                 key = EAknSoftkeyShow;
       
  1360                 }
       
  1361             else
       
  1362                 {
       
  1363                 key = EAknSoftkeyExit;
       
  1364                 }
       
  1365             }
       
  1366 
       
  1367         switch( key )
       
  1368             {
       
  1369             case EAknSoftkeyShow:
       
  1370                 {
       
  1371                 // Answer
       
  1372                 iStartEditor = ETrue;
       
  1373                 iShowDone = EFalse;
       
  1374                 // Start the USSD editor now.
       
  1375                 _DPRINT( 4, "PhSrv.RunL.RequestStartEditingL" ); // debug print
       
  1376                 RequestStartEditingL();
       
  1377                 break;
       
  1378                 }
       
  1379             case EAknSoftkeyYes:
       
  1380                 {
       
  1381                 _DPRINT( 4, "PhSrv.RunL.SK.Yes" );
       
  1382                 iClearArray = EFalse;
       
  1383                 iNotifyArray->Reset();
       
  1384                 TryCloseSession();
       
  1385                 break;
       
  1386                 }
       
  1387             case EAknSoftkeyCancel:
       
  1388                 _DPRINT( 4, "PhSrv.RunL.SK.Cancel" ); 
       
  1389                 if ( iHavePendingSatMessagePointer )
       
  1390                     {
       
  1391                     iSatCanceled = ETrue;
       
  1392                     CompleteSatL( &iReceivedMessage, KErrCancel );
       
  1393                     _DPRINT( 4, "PhSrv.RunL.CompleteSatL" );
       
  1394                     }
       
  1395                 // fall through.
       
  1396             case EAknSoftkeyExit:
       
  1397                 _DPRINT( 4, "PhSrv.RunL.SK.Exit" ); 
       
  1398                 ClearArrayL();
       
  1399                 TryCloseSession();
       
  1400                 break;
       
  1401             case EAknSoftkeyBack:
       
  1402                 _DPRINT( 4, "PhSrv.RunL.SK.Back" ); 
       
  1403                 ClearArrayL();
       
  1404                 TryCloseSession();
       
  1405                 break;
       
  1406             case EAknSoftkeyNo:
       
  1407                 _DPRINT( 4, "PhSrv.RunL.SK.No" );
       
  1408                 iClearArray = EFalse;
       
  1409                 iNotifyMessage = ETrue; // for removing the yes/no query
       
  1410                 // fall through.
       
  1411             case EAknSoftkeyNext:
       
  1412                 _DPRINT( 4, "PhSrv.RunL.SK.Next" ); 
       
  1413                 CheckArray();
       
  1414                 TryCloseSession();
       
  1415                 break;
       
  1416             default:
       
  1417                 _DPRINT( 4, "PhSrv.RunL.SK.Default" ); 
       
  1418                 break;
       
  1419             }
       
  1420         _DPRINT( 4, "PhSrv.RunL.End" );     // debug print
  1380         _DPRINT( 4, "PhSrv.RunL.End" );     // debug print
  1421         }
  1381         }
  1422     }
  1382     }
  1423 // RM-RIM 417-66528
  1383 
  1424 // -----------------------------------------------------------------------------
       
  1425 // CPhSrvUssdManager::CreateGlobalMessageQueryL
       
  1426 // -----------------------------------------------------------------------------
       
  1427 //
       
  1428 void CPhSrvUssdManager::CreateGlobalMessageQueryL(
       
  1429         const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
       
  1430     {
       
  1431     if (!iGlobalMsgQuery)
       
  1432         {
       
  1433         iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
       
  1434         }
       
  1435 
       
  1436     // Delay after message query so that application execution order will
       
  1437     // be correct.
       
  1438     iGlobalMsgQuery->SetExitDelay(KPhSrvUssdNoteExitPeriod);
       
  1439 
       
  1440     TInt softkeys = R_AVKON_SOFTKEYS_USSD_ANSWER_EXIT__ANSWER;
       
  1441     if (!(aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType)
       
  1442             || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest)
       
  1443         {
       
  1444         softkeys = R_AVKON_SOFTKEYS_EXIT;
       
  1445         }
       
  1446 
       
  1447     // Set timer that lauches Global MessageQuery after time interval.
       
  1448     iSoftkeys = softkeys;
       
  1449 
       
  1450     // debug print
       
  1451     _DPRINT( 4,
       
  1452             "PhSrv.UssdHandleReceivedEventL.String.Middle" );
       
  1453 
       
  1454     // Play the USSD tone if needed. Logically should be in RunL, but here
       
  1455     // to give better balancing with voice and visible message.
       
  1456     if (IsTelephonyFeatureSupported(KTelSrvLVFlagUssdTone))
       
  1457         {
       
  1458         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.PlayTone" );
       
  1459         PlayUssdTone();
       
  1460         }
       
  1461     // Launch the new message query
       
  1462     if (!IsActive())
       
  1463         {
       
  1464         iLaunchGMQ = ETrue;
       
  1465         iTimer.After(iStatus, KPhSrvUssdMessageQueryInterval);
       
  1466         SetActive();
       
  1467         }
       
  1468     }
       
  1469 // -----------------------------------------------------------------------------
  1384 // -----------------------------------------------------------------------------
  1470 // CPhSrvUssdManager::LaunchGlobalMessageQueryL
  1385 // CPhSrvUssdManager::LaunchGlobalMessageQueryL
  1471 // -----------------------------------------------------------------------------
  1386 // -----------------------------------------------------------------------------
  1472 //
  1387 //
  1473 void CPhSrvUssdManager::LaunchGlobalMessageQueryL()
  1388 void CPhSrvUssdManager::LaunchGlobalMessageQueryL()
  1474     {
  1389     {
  1475     _DPRINT( 4, "PhSrv.LGMQ.start" );
  1390     _DPRINT( 4, "PhSrv.LGMQ.start" );
  1476     _DPRINT_FLAGS();
  1391     _DPRINT_FLAGS();
       
  1392 
  1477     if ( iNotifyMessage )
  1393     if ( iNotifyMessage )
  1478         {
  1394         {
  1479         _DDPRINT( 4, "PhSrv.LGMQ.NotifyMessage", iNotifyMessage );
  1395         _DDPRINT( 4, "PhSrv.LGMQ.NotifyMessage", iNotifyMessage );
  1480         iNotifyMessage = ETrue;
  1396         iNotifyMessage = ETrue;
  1481         TInt count = NotifyCount();
  1397         TInt count = NotifyCount();
       
  1398         //check softkey in avkon.rss 
  1482         if ( count > 1 )
  1399         if ( count > 1 )
  1483             {
  1400             {
  1484             iSoftkeys = R_AVKON_SOFTKEYS_NEXT_EXIT__NEXT;
  1401             // Next, Exit
       
  1402             iDeviceDialog->SetButton(
       
  1403                 CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue );            
       
  1404             iDeviceDialog->SetButtonTextL(
       
  1405                 CHbDeviceMessageBoxSymbian::EAcceptButton, 
       
  1406                 LoadDefaultString( KUssdNext ) );
       
  1407             iDeviceDialog->SetButton(
       
  1408                 CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );    
       
  1409             iDeviceDialog->SetButtonTextL(
       
  1410                 CHbDeviceMessageBoxSymbian::ERejectButton, 
       
  1411                 LoadDefaultString( KUssdExit ) );  
       
  1412             _DPRINT( 4, "PhSrv.LGMQ.Next&Exit" );
  1485             }
  1413             }
  1486         else
  1414         else
  1487             {
  1415             {
  1488             iSoftkeys = R_AVKON_SOFTKEYS_EXIT;
  1416             // Only Exit
       
  1417             iDeviceDialog->SetButton(
       
  1418                 CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse ); 
       
  1419             iDeviceDialog->SetButton(
       
  1420                 CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );               
       
  1421             iDeviceDialog->SetButtonTextL(
       
  1422                 CHbDeviceMessageBoxSymbian::ERejectButton, 
       
  1423                 LoadDefaultString( KUssdExit ) );   
       
  1424             _DPRINT( 4, "PhSrv.LGMQ.onlyExit" );
  1489             }
  1425             }
  1490         if ( iClearArray )
  1426         if ( iClearArray )
  1491             {
  1427             {
  1492             iSoftkeys = R_AVKON_SOFTKEYS_YES_NO;
  1428             HbTextResolverSymbian::Init( KCommonLocFilename, KLocPath );
       
  1429             _DPRINT( 4, "PhSrv.LGMQ.use common loc file" );
       
  1430             // Yes, No
       
  1431             iDeviceDialog->SetButton(
       
  1432                 CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue );               
       
  1433             iDeviceDialog->SetButtonTextL(
       
  1434                 CHbDeviceMessageBoxSymbian::EAcceptButton, 
       
  1435                 LoadDefaultString( KUssdYes ) );
       
  1436             iDeviceDialog->SetButton(
       
  1437                 CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );              
       
  1438             iDeviceDialog->SetButtonTextL(
       
  1439                 CHbDeviceMessageBoxSymbian::ERejectButton, 
       
  1440                 LoadDefaultString( KUssdNo ) );  
       
  1441             _DPRINT( 4, "PhSrv.LGMQ.Yes&No" );
       
  1442             HbTextResolverSymbian::Init( KUssdLocFilename, KLocPath );
       
  1443             _DPRINT( 4, "PhSrv.LGMQ.back up to use ussd loc file" );
  1493             }
  1444             }
  1494         iReceivedMessage.Zero();
  1445         iReceivedMessage.Zero();
  1495         iReceivedMessage = (*iNotifyArray)[0];
  1446         iReceivedMessage = (*iNotifyArray)[0];
  1496         }
  1447         }
  1497     TurnLightsOn(); //Ensure lights on
  1448     TurnLightsOn(); //Ensure lights on
  1498 
  1449 
  1499     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery" ); // debug print
  1450     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery" ); // debug print
  1500     // Launch Global MessageQuery as requested.
  1451     // Launch Global MessageQuery as requested.
  1501     iGlobalMsgQuery->ShowMsgQueryL(iStatus, iReceivedMessage, iSoftkeys,
  1452     // Dialog not support header text, this code is only 
  1502             *iMeQuHeaderText, KNullDesC);
  1453     // for testing, not final solution.
  1503     _DPRINT( 4, "PhSrv.LGMQ.SetActive" );
  1454     TInt receiveLength = iReceivedMessage.Length();
  1504     SetActive();
  1455     _DDPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.MsgLength", receiveLength ); 
       
  1456     
       
  1457     TInt titleLength = LoadDefaultString( KUssdTitle ).Length();
       
  1458     _DDPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.TilteLength", titleLength );
       
  1459     
       
  1460     TInt length = receiveLength + titleLength;
       
  1461     _DDPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.TotalLength", length );    
       
  1462         
       
  1463     HBufC* titleAndText = HBufC::NewLC( length );
       
  1464     titleAndText->Des().Append( LoadDefaultString( KUssdTitle ) );
       
  1465     titleAndText->Des().Append( iReceivedMessage );
       
  1466     iDeviceDialog->SetTextL( titleAndText->Des() );
       
  1467     CleanupStack::Pop( titleAndText );
       
  1468     
       
  1469     iDeviceDialog->Close();
       
  1470     iDeviceDialog->ShowL();
  1505     iShowDone = EFalse;
  1471     iShowDone = EFalse;
       
  1472    
  1506     // Do nothing else in RunL this time.
  1473     // Do nothing else in RunL this time.
  1507     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.ret" ); // debug print
  1474     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.ret" ); // debug print
  1508     }
  1475     }
  1509 
  1476 
  1510 // -----------------------------------------------------------------------------
  1477 // -----------------------------------------------------------------------------
  1604 // -----------------------------------------------------------------------------
  1571 // -----------------------------------------------------------------------------
  1605 // CPhSrvUssdManager::CheckArray()
  1572 // CPhSrvUssdManager::CheckArray()
  1606 // -----------------------------------------------------------------------------
  1573 // -----------------------------------------------------------------------------
  1607 //
  1574 //
  1608 void CPhSrvUssdManager::CheckArray()
  1575 void CPhSrvUssdManager::CheckArray()
  1609 	{
  1576     {
  1610 	_DPRINT( 4, "PhSrv.CheckArray.Start" );     // debug print
  1577     _DPRINT( 4, "PhSrv.CheckArray.Start" );     // debug print
  1611  	if (iNotifyArray  && NotifyCount() > 0)
  1578     if (iNotifyArray  && NotifyCount() > 0)
  1612 		{
  1579         {
  1613 		if 	( !iNotifyMessage && !iClearArray )
  1580         if  ( !iNotifyMessage && !iClearArray )
  1614 			{
  1581             {
  1615 			iLaunchGMQ = ETrue;
  1582             iLaunchGMQ = ETrue;
  1616 			iNotifyMessage = ETrue;
  1583             iNotifyMessage = ETrue;
  1617 			_DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.ETrue" );
  1584             _DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.ETrue" );
  1618 			iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
  1585             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
  1619 			_DDPRINT( 4, "PhSrv.CheckArray.SetActive.NoNotifyMessage ", iStatus.Int() );
  1586             _DDPRINT( 4, "PhSrv.CheckArray.SetActive.NoNotifyMessage ", iStatus.Int() );
  1620 			SetActive();
  1587             SetActive();
  1621 			}
  1588             }
  1622 		else if( NotifyCount() > 1 )
  1589         else if( NotifyCount() > 1 )
  1623 			{
  1590             {
  1624 			( iNotifyArray )->Delete( 0 );
  1591             ( iNotifyArray )->Delete( 0 );
  1625 			( iNotifyArray )->Compress();
  1592             ( iNotifyArray )->Compress();
  1626 			iLaunchGMQ = ETrue;
  1593             iLaunchGMQ = ETrue;
  1627 			iNotifyMessage = ETrue;
  1594             iNotifyMessage = ETrue;
  1628 			_DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.ETrue" );
  1595             _DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.ETrue" );
  1629 			iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
  1596             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
  1630 			_DDPRINT( 4, "PhSrv.CheckArray.SetActive.NotifyCount>1 ", iStatus.Int() );
  1597             _DDPRINT( 4, "PhSrv.CheckArray.SetActive.NotifyCount>1 ", iStatus.Int() );
  1631 			SetActive();
  1598             SetActive();
  1632 			}
  1599             }
  1633  		else
  1600         else
  1634      		{
  1601             {
  1635 			iNotifyArray->Reset();
  1602             iNotifyArray->Reset();
  1636      		iNotifyMessage = EFalse;
  1603             iNotifyMessage = EFalse;
  1637      		_DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.EFalse" );
  1604             _DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.EFalse" );
  1638      		}
  1605             }
  1639   		}
  1606         }
  1640     _DPRINT_FLAGS();
  1607     _DPRINT_FLAGS();
  1641   	_DPRINT( 4, "PhSrv.CheckArray.End" );     // debug print
  1608     _DPRINT( 4, "PhSrv.CheckArray.End" );     // debug print
  1642  	}
  1609     }
  1643 
  1610 
  1644 // -----------------------------------------------------------------------------
  1611 // -----------------------------------------------------------------------------
  1645 // CPhSrvUssdManager::ClearArray()
  1612 // CPhSrvUssdManager::ClearArray()
  1646 // -----------------------------------------------------------------------------
  1613 // -----------------------------------------------------------------------------
  1647 //
  1614 //
  1648   void CPhSrvUssdManager::ClearArrayL()
  1615   void CPhSrvUssdManager::ClearArrayL()
  1649   	{
  1616     {
  1650   	_DPRINT( 4, "PhSrv.ClearArrayL.Start" );     // debug print
  1617     _DPRINT( 4, "PhSrv.ClearArrayL.Start" );     // debug print
  1651   	if (iNotifyArray && NotifyCount() > 0)
  1618     if (iNotifyArray && NotifyCount() > 0)
  1652 	  	{
  1619         {
  1653 	  	if (iNotifyMessage && NotifyCount()== 1 )
  1620         if (iNotifyMessage && NotifyCount()== 1 )
  1654 	  		{
  1621             {
  1655 	  		iNotifyArray->Reset();
  1622             iNotifyArray->Reset();
  1656 	  		}
  1623             }
  1657 	  	else
  1624         else
  1658 	  		{
  1625             {
  1659 	  		iReceivedMessage.Zero();
  1626             iReceivedMessage.Zero();
  1660 	  		HBufC* unreadText = iResourceManager.ReadResourceLC( R_PHSRV_TEXT_UNREAD );
  1627             iReceivedMessage.Append( 
  1661 	  		TPtr pMessage( unreadText->Des() );
  1628                 LoadDefaultString( KUssdConfirm ) );
  1662 	  		iReceivedMessage.Append( pMessage );
  1629             iNotifyArray->InsertL( 0, iReceivedMessage );
  1663 	  		iNotifyArray->InsertL( 0, iReceivedMessage );
  1630             iLaunchGMQ = ETrue;
  1664 	        CleanupStack::PopAndDestroy( unreadText );
  1631             iNotifyMessage = ETrue;
  1665 	  		iLaunchGMQ = ETrue;
  1632             _DPRINT( 4, "PhSrv.ClearArrayL.iNotifyMessage.ETrue" );
  1666 	  		iNotifyMessage = ETrue;
  1633             iClearArray = ETrue;
  1667 	  		_DPRINT( 4, "PhSrv.ClearArrayL.iNotifyMessage.ETrue" );
  1634             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
  1668 	  		iClearArray = ETrue;
  1635             _DDPRINT( 4, "PhSrv.ClearArrayL.iTimer ", iStatus.Int() );
  1669 	  		iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
  1636             SetActive();
  1670 	  		_DDPRINT( 4, "PhSrv.ClearArrayL.iTimer ", iStatus.Int() );
  1637             }
  1671 			SetActive();
  1638         }
  1672 	  		}
       
  1673 	  	}
       
  1674     _DPRINT_FLAGS();
  1639     _DPRINT_FLAGS();
  1675 	_DPRINT( 4, "PhSrv.ClearArrayL.End" );     // debug print
  1640     _DPRINT( 4, "PhSrv.ClearArrayL.End" );     // debug print
  1676   	}
  1641     }
  1677 
  1642 
  1678 // -----------------------------------------------------------------------------
  1643 // -----------------------------------------------------------------------------
  1679 // CPhSrvUssdManager::NotifyCount()
  1644 // CPhSrvUssdManager::NotifyCount()
  1680 // -----------------------------------------------------------------------------
  1645 // -----------------------------------------------------------------------------
  1681 //
  1646 //
  1682   TInt CPhSrvUssdManager::NotifyCount()
  1647 TInt CPhSrvUssdManager:: NotifyCount()
  1683   {
  1648 {
  1684   if( iNotifyArray )
  1649     TInt count = iNotifyArray->Count();
  1685       {
  1650     _DDPRINT( 4, "PhSrv.NotifyCount:", count );     // debug print
  1686       return iNotifyArray->Count();
  1651     return count;
  1687       }
  1652 }
  1688   else
  1653 
  1689       {
  1654 // -----------------------------------------------------------------------------
  1690       return 0;
  1655 // CPhSrvUssdManager::UpdateNotifyMessageL()
  1691       }
  1656 // -----------------------------------------------------------------------------
  1692   }
  1657 //
  1693 
  1658   void CPhSrvUssdManager:: UpdateNotifyMessageL()
  1694   // -----------------------------------------------------------------------------
  1659     {
  1695 // CPhSrvUssdManager::UpdateNotifyMessage()
  1660     _DDPRINT( 4, "PhSrv.UpdateNotifyMessageL.Start, clear: ", iClearArray );     // debug print
  1696 // -----------------------------------------------------------------------------
  1661 
  1697 //
  1662     // Show left softkey - "Next"
  1698   void CPhSrvUssdManager::UpdateNotifyMessage()
  1663     if (NotifyCount() > 1 && !iClearArray )
  1699   	{
  1664         {
  1700   	_DDPRINT( 4, "PhSrv.UpdateNotifyMessage.Start, clear: ", iClearArray );     // debug print
  1665         _DPRINT( 4, "PhSrv.UpdateNotifyMessageL" );     // debug print
  1701   	if (NotifyCount() > 1 && !iClearArray )
  1666         iDeviceDialog->SetButton( 
  1702   		{
  1667             CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue ); 
  1703   		_DPRINT( 4, "PhSrv.UpdateNotifyMessage" );     // debug print
  1668         iDeviceDialog->SetButtonTextL(
  1704   		iGlobalMsgQuery->UpdateMsgQuery( R_AVKON_SOFTKEYS_NEXT_EXIT__NEXT );
  1669             CHbDeviceMessageBoxSymbian::EAcceptButton, 
  1705   		}
  1670             LoadDefaultString( KUssdNext ) );
  1706   	_DPRINT( 4, "PhSrv.UpdateNotifyMessage.End" );     // debug print
  1671         }
  1707   	}
  1672     // Remove left softkey
       
  1673     else
       
  1674         {
       
  1675         iDeviceDialog->SetButton( 
       
  1676                     CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse );         
       
  1677         }
       
  1678     iDeviceDialog->UpdateL();        
       
  1679     
       
  1680     _DPRINT( 4, "PhSrv.UpdateNotifyMessageL.End" );     // debug print
       
  1681     }
  1708 
  1682 
  1709 // -----------------------------------------------------------------------------
  1683 // -----------------------------------------------------------------------------
  1710 // CPhSrvUssdManager::DoCancel
  1684 // CPhSrvUssdManager::DoCancel
  1711 // -----------------------------------------------------------------------------
  1685 // -----------------------------------------------------------------------------
  1712 //
  1686 //
  1713 void CPhSrvUssdManager::DoCancel()
  1687 void CPhSrvUssdManager::DoCancel()
  1714     {
  1688     {
  1715     _DPRINT( 4, "PhSrv.DoCancel.Start" ); // debug print
  1689     _DPRINT( 4, "PhSrv.DoCancel.Start" ); // debug print
  1716     iTimer.Cancel();
  1690     iTimer.Cancel();
  1717     iLaunchGMQ = EFalse;
  1691     iLaunchGMQ = EFalse;
  1718 
  1692     if ( iDeviceDialog )
  1719     if ( iGlobalMsgQuery )
       
  1720         {
  1693         {
  1721         _DPRINT( 4, "PhSrv.DoCancel" ); // debug print
  1694         _DPRINT( 4, "PhSrv.DoCancel" ); // debug print
  1722         iGlobalMsgQuery->CancelMsgQuery();
  1695         iDeviceDialog->Close();
       
  1696         delete iDeviceDialog;
       
  1697         iDeviceDialog = NULL;
  1723         }
  1698         }
  1724     _DPRINT( 4, "PhSrv.DoCancel.End" ); // debug print
  1699     _DPRINT( 4, "PhSrv.DoCancel.End" ); // debug print
  1725     }
  1700     }
  1726 
  1701 
  1727 // -----------------------------------------------------------------------------
  1702 // -----------------------------------------------------------------------------
  1750     _DPRINT( 4, "PhSrv.RequestStartEditingL.wsSession.connect" );     // debug print
  1725     _DPRINT( 4, "PhSrv.RequestStartEditingL.wsSession.connect" );     // debug print
  1751     CleanupClosePushL( wsSession );
  1726     CleanupClosePushL( wsSession );
  1752 
  1727 
  1753     // Find the task with name
  1728     // Find the task with name
  1754     TApaTaskList tasklist( wsSession );
  1729     TApaTaskList tasklist( wsSession );
  1755     TApaTask task = tasklist.FindApp( TUid::Uid( KPhSrvUssdAppUID ) );
  1730     TApaTask task = tasklist.FindApp( KUssdSecureId );
  1756 
  1731 
  1757     // If task exists, bring it to foreground
  1732     // If task exists, bring it to foreground
  1758     if ( task.Exists() )
  1733     if ( task.Exists() )
  1759         {
  1734         {
  1760         _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.task.BringToForeground" );
  1735         _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.task.BringToForeground" );
  1767         User::LeaveIfError( apaLsSession.Connect() );
  1742         User::LeaveIfError( apaLsSession.Connect() );
  1768         _DPRINT( 4, "PhSrv.RequestStartEditingL.apaLsSession.connect" );     // debug print
  1743         _DPRINT( 4, "PhSrv.RequestStartEditingL.apaLsSession.connect" );     // debug print
  1769         CleanupClosePushL( apaLsSession );
  1744         CleanupClosePushL( apaLsSession );
  1770 
  1745 
  1771         TApaAppInfo appInfo;
  1746         TApaAppInfo appInfo;
  1772         TInt err = apaLsSession.GetAppInfo(
  1747         
  1773             appInfo,
  1748         TInt err = apaLsSession.GetAppInfo( appInfo, KUssdSecureId );
  1774             TUid::Uid( KPhSrvUssdAppUID )  );
  1749         _DDPRINT( 4, "PhSrv.RequestStartEditingL.GetAppInfo ", err );     // debug print
       
  1750         
  1775         if ( err == KErrNone )
  1751         if ( err == KErrNone )
  1776             {
  1752             {
  1777             _DDPRINT( 4, "PhSrv.RequestStartEditingL.GetAppInfo ", err );     // debug print
       
  1778 
       
  1779         #ifndef SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
  1753         #ifndef SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
  1780             CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
  1754             CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
  1781             apaCommandLine->SetExecutableNameL( appInfo.iFullName );
  1755             apaCommandLine->SetExecutableNameL( appInfo.iFullName );
  1782         #else // SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
  1756         #else // SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
  1783             CApaCommandLine* apaCommandLine =
  1757             CApaCommandLine* apaCommandLine =
  1784                 CApaCommandLine::NewLC( appInfo.iFullName );
  1758                 CApaCommandLine::NewLC( appInfo.iFullName );
  1785         #endif // SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
  1759         #endif // SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
  1786 
  1760 
  1787             err = apaLsSession.StartApp( *apaCommandLine );
  1761             TThreadId id( static_cast<TInt64>( 0 ) );
       
  1762             err = apaLsSession.StartApp( *apaCommandLine, id );
       
  1763             _DDPRINT( 4, "PhSrv.RequestStartEditingL.ThreadId ", id ); 
  1788             CleanupStack::PopAndDestroy( apaCommandLine );
  1764             CleanupStack::PopAndDestroy( apaCommandLine );
  1789             }
  1765             }
  1790         CleanupStack::PopAndDestroy(); // apaLsSession
  1766         CleanupStack::PopAndDestroy( &apaLsSession ); // apaLsSession
       
  1767         
       
  1768         // bring the ussd editor to foreground, only for testing
       
  1769         TApaTaskList tasklist( wsSession );
       
  1770         TApaTask task = tasklist.FindApp( KUssdSecureId );
       
  1771         if ( task.Exists() )
       
  1772             {
       
  1773             _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.task.BringToForeground" );
       
  1774             task.BringToForeground();
       
  1775             }
       
  1776         // bring the ussd editor to foreground, only for testing
  1791         }
  1777         }
  1792     CleanupStack::PopAndDestroy(); // wsSession
  1778     CleanupStack::PopAndDestroy(); // wsSession
  1793 
  1779 
  1794     _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.end" ); // debug print
  1780     _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.end" ); // debug print
  1795     }
  1781     }
  1824     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.start" ); // debug print
  1810     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.start" ); // debug print
  1825     if ( iUssdReplyTimer )
  1811     if ( iUssdReplyTimer )
  1826         {
  1812         {
  1827         if ( iUssdReplyTimer->IsTimerActive() )
  1813         if ( iUssdReplyTimer->IsTimerActive() )
  1828             {
  1814             {
  1829             // debug print
  1815      
  1830             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer" );
  1816             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer" );
  1831 
  1817 
  1832             // Read the information what is the reason
  1818             // Read the information what is the reason
  1833             // for application termination.
  1819             // for application termination.
  1834             TPhCltUssdAppExitReason exitReason = EPhCltExitReasonUnknown;
  1820             TPhCltUssdAppExitReason exitReason = EPhCltExitReasonUnknown;
  1835             TPckg< TPhCltUssdAppExitReason > exitReasonPckg( exitReason );
  1821             TPckg< TPhCltUssdAppExitReason > exitReasonPckg( exitReason );
  1836             aMessage.ReadL(
  1822             aMessage.ReadL(
  1837                 0,
  1823                 0,
  1838                 exitReasonPckg );
  1824                 exitReasonPckg );
  1839 
  1825 
  1840             // debug print
  1826      
  1841             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer2" );
  1827             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer2" );
  1842 
  1828 
  1843             // If reason was the completion of send operation, the USSD
  1829             // If reason was the completion of send operation, the USSD
  1844             // session is not canceled, otherwise it is canceled.
  1830             // session is not canceled, otherwise it is canceled.
  1845             if ( exitReason != EPhCltSendCompleted )
  1831             if ( exitReason != EPhCltSendCompleted )
  1846                 {
  1832                 {
  1847                 // debug print
  1833          
  1848                 _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.SendRelease" );
  1834                 _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.SendRelease" );
  1849                 CloseSession();
  1835                 CloseSession();
  1850                 }
  1836                 }
  1851             }
  1837             }
  1852         }
  1838         }
  1910         _DPRINT( 4, "PhSrv.InformStartSAT.Complete.InUse" ); // debug print
  1896         _DPRINT( 4, "PhSrv.InformStartSAT.Complete.InUse" ); // debug print
  1911         aSatMessage.Complete( KErrInUse );
  1897         aSatMessage.Complete( KErrInUse );
  1912         }
  1898         }
  1913     else
  1899     else
  1914         {
  1900         {
  1915         _DPRINT( 4, "PhSrv.InformStartSAT.Set" );           // debug print
  1901         _DPRINT( 4, "PhSrv.InformStartSAT.Set" );    
  1916 
  1902 
  1917         // There was not pending SAT message
  1903         // There was not pending SAT message
  1918         iHavePendingSatMessagePointer = ETrue;
  1904         iHavePendingSatMessagePointer = ETrue;
  1919         _DDPRINT( 4, "PhSrv.UssdM.InformStartSAT.PendingSatPointer ", iHavePendingSatMessagePointer );
  1905         _DDPRINT( 4, "PhSrv.UssdM.InformStartSAT.PendingSatPointer ", iHavePendingSatMessagePointer );
  1920         iPendingSatMessagePointer = aSatMessage;
  1906         iPendingSatMessagePointer = aSatMessage;
  1928 // CPhSrvUssdManager::InformStopSAT
  1914 // CPhSrvUssdManager::InformStopSAT
  1929 // -----------------------------------------------------------------------------
  1915 // -----------------------------------------------------------------------------
  1930 //
  1916 //
  1931 void CPhSrvUssdManager::InformStopSAT()
  1917 void CPhSrvUssdManager::InformStopSAT()
  1932     {
  1918     {
  1933     _DPRINT( 4, "PhSrv.InformStopSAT.Start" );               // debug print
  1919     _DPRINT( 4, "PhSrv.InformStopSAT.Start" );        
  1934 
  1920 
  1935     // Do the actions only if there is pending SAT message.
  1921     // Do the actions only if there is pending SAT message.
  1936     if ( iHavePendingSatMessagePointer )
  1922     if ( iHavePendingSatMessagePointer )
  1937         {
  1923         {
  1938         _DPRINT( 4, "PhSrv.InformStopSAT.Complete.Cancel" ); // debug print
  1924         _DPRINT( 4, "PhSrv.InformStopSAT.Complete.Cancel" ); // debug print
  1941             iPendingSatMessagePointer.Complete( KErrCancel );
  1927             iPendingSatMessagePointer.Complete( KErrCancel );
  1942             _DPRINT( 4, "PhSrv.InformStopSAT.Complete.KErrCancel" );
  1928             _DPRINT( 4, "PhSrv.InformStopSAT.Complete.KErrCancel" );
  1943             }
  1929             }
  1944         iHavePendingSatMessagePointer = EFalse;
  1930         iHavePendingSatMessagePointer = EFalse;
  1945         }
  1931         }
  1946     _DPRINT( 4, "PhSrv.InformStopSAT.End" );                 // debug print
  1932     _DPRINT( 4, "PhSrv.InformStopSAT.End" );          
  1947     }
  1933     }
  1948 
  1934 
  1949 // -----------------------------------------------------------------------------
  1935 // -----------------------------------------------------------------------------
  1950 // CPhSrvUssdManager::ShowNotes
  1936 // CPhSrvUssdManager::ShowNotes
  1951 // -----------------------------------------------------------------------------
  1937 // -----------------------------------------------------------------------------
  1993 //
  1979 //
  1994 void CPhSrvUssdManager::CompleteSatL(
  1980 void CPhSrvUssdManager::CompleteSatL(
  1995     TDesC* aReceiveString,
  1981     TDesC* aReceiveString,
  1996     TInt aError )
  1982     TInt aError )
  1997     {
  1983     {
  1998     _DPRINT( 4, "PhSrv.CompleteSatL.Start" );                // debug print
  1984     _DPRINT( 4, "PhSrv.CompleteSatL.Start" );         
  1999     if ( aReceiveString )
  1985     if ( aReceiveString )
  2000         {
  1986         {
  2001         if ( aReceiveString->Length() )
  1987         if ( aReceiveString->Length() )
  2002             {
  1988             {
  2003             _DPRINT( 4, "PhSrv.CompleteSatL.recString.>0" ); // debug print
  1989             _DPRINT( 4, "PhSrv.CompleteSatL.recString.>0" ); // debug print
  2004             // copy the received string to client side.
  1990             // copy the received string to client side.
  2005             if ( iPendingSatMessagePointer.Int1() < aReceiveString->Length() )
  1991             if ( iPendingSatMessagePointer.Int1() < aReceiveString->Length() )
  2006                 {
  1992                 {
  2007                 // debug print
  1993          
  2008                 _DPRINT( 4, "PhSrv.CompleteSatL.recString.LengthError" );
  1994                 _DPRINT( 4, "PhSrv.CompleteSatL.recString.LengthError" );
  2009                 if ( !iPendingSatMessagePointer.IsNull() )
  1995                 if ( !iPendingSatMessagePointer.IsNull() )
  2010                     {
  1996                     {
  2011                     iPendingSatMessagePointer.Complete( KErrOverflow );
  1997                     iPendingSatMessagePointer.Complete( KErrOverflow );
  2012                     _DPRINT( 4, "PhSrv.CompleteSatLComplete.KErrOverFlow" );
  1998                     _DPRINT( 4, "PhSrv.CompleteSatLComplete.KErrOverFlow" );
  2013                     }
  1999                     }
  2014                 iHavePendingSatMessagePointer = EFalse;
  2000                 iHavePendingSatMessagePointer = EFalse;
  2015                 }
  2001                 }
  2016 			else
  2002             else
  2017 				{
  2003                 {
  2018             _DPRINT( 4, "PhSrv.CompleteSatL.recString.Write" );  // debug print
  2004             _DPRINT( 4, "PhSrv.CompleteSatL.recString.Write" );  // debug print
  2019             iPendingSatMessagePointer.WriteL(
  2005             iPendingSatMessagePointer.WriteL(
  2020                 2,
  2006                 2,
  2021                 *aReceiveString );
  2007                 *aReceiveString );
  2022 
  2008 
  2026                 0,
  2012                 0,
  2027                 dcsPackage );
  2013                 dcsPackage );
  2028             }
  2014             }
  2029         }
  2015         }
  2030         }
  2016         }
  2031     _DPRINT( 4, "PhSrv.CompleteSatL.Middle" );           // debug print
  2017     _DPRINT( 4, "PhSrv.CompleteSatL.Middle" );    
  2032     if ( !iPendingSatMessagePointer.IsNull() )
  2018     if ( !iPendingSatMessagePointer.IsNull() )
  2033         {
  2019         {
  2034         if ( aReceiveString && !iSatCanceled )
  2020         if ( aReceiveString && !iSatCanceled )
  2035             {
  2021             {
  2036             _DDPRINT( 4, "PhSrv.CompleteSatL.Complete.", iReturnResult.iOpCode  );   // debug print
  2022             _DDPRINT( 4, "PhSrv.CompleteSatL.Complete.", iReturnResult.iOpCode  );   // debug print
  2043             }
  2029             }
  2044         }
  2030         }
  2045 
  2031 
  2046     iHavePendingSatMessagePointer = EFalse;
  2032     iHavePendingSatMessagePointer = EFalse;
  2047 
  2033 
  2048     _DPRINT( 4, "PhSrv.CompleteSatL.End" );           // debug print
  2034     _DPRINT( 4, "PhSrv.CompleteSatL.End" );    
  2049     }
  2035     }
  2050 
  2036 
  2051 
  2037 
  2052 // -----------------------------------------------------------------------------
  2038 // -----------------------------------------------------------------------------
  2053 // CPhSrvUssdManager::IsTelephonyFeatureSupported
  2039 // CPhSrvUssdManager::IsTelephonyFeatureSupported
  2055 // -----------------------------------------------------------------------------
  2041 // -----------------------------------------------------------------------------
  2056 //
  2042 //
  2057 TBool CPhSrvUssdManager::IsTelephonyFeatureSupported(
  2043 TBool CPhSrvUssdManager::IsTelephonyFeatureSupported(
  2058     const TInt aFeatureId )
  2044     const TInt aFeatureId )
  2059     {
  2045     {
  2060 	return ( aFeatureId & iVariantReadOnlyValues );
  2046     return ( aFeatureId & iVariantReadOnlyValues );
  2061     }
  2047     }
  2062 
  2048 
  2063 
  2049 
  2064 // -----------------------------------------------------------------------------
  2050 // -----------------------------------------------------------------------------
  2065 // CPhSrvUssdManager::PlayUssdTone
  2051 // CPhSrvUssdManager::PlayUssdTone
  2066 //
  2052 //
  2067 // -----------------------------------------------------------------------------
  2053 // -----------------------------------------------------------------------------
  2068 //
  2054 //
  2069 TInt CPhSrvUssdManager::PlayUssdTone()
  2055 TInt CPhSrvUssdManager::PlayUssdTone()
  2070     {
  2056     {
  2071     _DPRINT( 4, "PhSrv.UssdM.PlayTone.start" );           // debug print
  2057     _DPRINT( 4, "PhSrv.UssdM.PlayTone.start" );    
  2072 
  2058 
  2073     TInt err = KErrNone;
  2059     TInt err = KErrNone;
  2074 
  2060 // <-- QT PHONE  START-->
  2075     RProperty::Define( KPSUidNcnList, KNcnPlayAlertTone, RProperty::EInt, ECapability_None , ECapabilityWriteDeviceData );
  2061 //    RProperty::Define( KPSUidNcnList, KNcnPlayAlertTone, RProperty::EInt, ECapability_None , ECapabilityWriteDeviceData );
  2076     RProperty::Set( KPSUidNcnList, KNcnPlayAlertTone, KPhSrvUssdTone );
  2062 //    RProperty::Set( KPSUidNcnList, KNcnPlayAlertTone, KPhSrvUssdTone );
       
  2063 // <-- QT PHONE END-->
  2077 
  2064 
  2078     // debug print
  2065     // debug print
  2079     _DDPRINT(
  2066     _DDPRINT(
  2080         4,
  2067         4,
  2081         "PhSrv.UssdM.PlayTone.end",
  2068         "PhSrv.UssdM.PlayTone.end",
  2090 //
  2077 //
  2091 TInt CPhSrvUssdManager::GetTelephonyVariantData()
  2078 TInt CPhSrvUssdManager::GetTelephonyVariantData()
  2092     {
  2079     {
  2093     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.Start" );
  2080     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.Start" );
  2094     TInt err = KErrNone;
  2081     TInt err = KErrNone;
  2095 
  2082 // <-- QT PHONE START-->
       
  2083 /*
  2096     // Variation data should be unchangable during run-time,
  2084     // Variation data should be unchangable during run-time,
  2097     // therefore, if once succesfully read, later reads are
  2085     // therefore, if once succesfully read, later reads are
  2098     // not allowed.
  2086     // not allowed.
  2099     if ( iVariantReadOnlyValues == KPhSrvDefaultValue )
  2087     if ( iVariantReadOnlyValues == KPhSrvDefaultValue )
  2100         {
  2088         {
  2101         CRepository* cenRepSession = NULL;
  2089         CRepository* cenRepSession = NULL;
  2102         TRAP ( err ,
  2090         TRAP ( err ,
  2103                cenRepSession = CRepository::NewL( KCRUidTelSrvVariation ) );
  2091                cenRepSession = CRepository::NewL( KCRUidTelVariation ) );
  2104         if ( err == KErrNone )
  2092         if ( err == KErrNone )
  2105             {
  2093             {
  2106             err = cenRepSession->Get( KTelSrvVariationFlags,
  2094             err = cenRepSession->Get( KTelVariationFlags,
  2107                                    iVariantReadOnlyValues );
  2095                                    iVariantReadOnlyValues );
  2108             }
  2096             }
  2109         delete cenRepSession;
  2097         delete cenRepSession;
  2110         }
  2098         }
  2111 
  2099 
  2112     _DDPRINT( 4, "PhSrv.UssdM.variant", iVariantReadOnlyValues ); // debug print
  2100     _DDPRINT( 4, "PhSrv.UssdM.variant", iVariantReadOnlyValues ); // debug print
  2113     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.End" );
  2101     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.End" );
       
  2102     */
       
  2103 // <-- QT PHONE END-->
  2114     return err;
  2104     return err;
  2115     }
  2105     }
  2116 
  2106 
  2117 
  2107 
  2118 // -----------------------------------------------------------------------------
  2108 // -----------------------------------------------------------------------------
  2120 //
  2110 //
  2121 // -----------------------------------------------------------------------------
  2111 // -----------------------------------------------------------------------------
  2122 //
  2112 //
  2123 void CPhSrvUssdManager::SendMoAcknowledgementL()
  2113 void CPhSrvUssdManager::SendMoAcknowledgementL()
  2124     {
  2114     {
  2125     _DPRINT( 4, "PhSrv.SendMoAckL.Start" );           // debug print
  2115     _DPRINT( 4, "PhSrv.SendMoAckL.Start" );    
  2126 
  2116 
  2127     // Acknowledge MT USSD message.
  2117     // Acknowledge MT USSD message.
  2128     RMobileUssdMessaging::TMobileUssdAttributesV1 msgAttribs;
  2118     RMobileUssdMessaging::TMobileUssdAttributesV1 msgAttribs;
  2129     msgAttribs.iFlags =
  2119     msgAttribs.iFlags =
  2130         RMobileUssdMessaging::KUssdMessageType +
  2120         RMobileUssdMessaging::KUssdMessageType +
  2138     msgAttribs.iDcs    = KPhSrvUssdDefaultDCS;
  2128     msgAttribs.iDcs    = KPhSrvUssdDefaultDCS;
  2139 
  2129 
  2140     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs = msgAttribs;
  2130     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs = msgAttribs;
  2141     SendHandlerL().SendUssdL( KNullDesC8() , attribs );
  2131     SendHandlerL().SendUssdL( KNullDesC8() , attribs );
  2142 
  2132 
  2143     _DPRINT( 4, "PhSrv.SendMoAckL.End" );           // debug print
  2133     _DPRINT( 4, "PhSrv.SendMoAckL.End" );    
  2144     }
  2134     }
  2145 
  2135 
  2146 // -----------------------------------------------------------------------------
  2136 // -----------------------------------------------------------------------------
  2147 // CPhSrvUssdManager::TurnLightsOn
  2137 // CPhSrvUssdManager::TurnLightsOn
  2148 //
  2138 //
  2149 // -----------------------------------------------------------------------------
  2139 // -----------------------------------------------------------------------------
  2150 //
  2140 //
  2151 void CPhSrvUssdManager::TurnLightsOn()
  2141 void CPhSrvUssdManager::TurnLightsOn()
  2152     {
  2142     {
  2153      _DPRINT( 4, "PhSrv.TurnLightsOn Start" );           // debug print
  2143     _DPRINT( 4, "PhSrv.TurnLightsOn.Start" );    
  2154 
  2144 
  2155 
  2145 
  2156          // Change the bit on and off. SysAp will detect that
  2146      // Change the bit on and off. SysAp will detect that
  2157      // the lights should be switched on for the specified time.
  2147      // the lights should be switched on for the specified time.
  2158      //
  2148      //
  2159          RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn);
  2149      RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn);
  2160          TInt err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOff);
  2150      TInt err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOff);
  2161 
  2151 
  2162          if ( err != KErrNone )
  2152      if ( err != KErrNone )
  2163                  {
  2153          {
  2164                  _DDPRINT( 4,"PhSrv.TurnLightsOn.Error: ",err );// debug print
  2154          _DDPRINT( 4,"PhSrv.TurnLightsOn.Error: ",err );// debug print
  2165                  }
  2155          }
  2166 
  2156 
  2167      _DPRINT( 4, "PhSrv.TurnLightsOn.End" );           // debug print
  2157     _DPRINT( 4, "PhSrv.TurnLightsOn.End" );    
  2168     }
  2158     }
       
  2159 
       
  2160 // -----------------------------------------------------------------------------
       
  2161 // CPhSrvUssdManager::LoadDefaultString
       
  2162 // -----------------------------------------------------------------------------
       
  2163 //
       
  2164 const TPtrC CPhSrvUssdManager::LoadDefaultString( const TDesC& aText )
       
  2165     {
       
  2166     _DPRINT( 4, "PhSrv.LoadDefaultString.Start" );
       
  2167     
       
  2168     if ( iTextBuffer )
       
  2169         {
       
  2170         delete iTextBuffer;
       
  2171         iTextBuffer = NULL;
       
  2172         _DPRINT( 4, "PhSrv.LoadDefaultString.Clear" );
       
  2173         }
       
  2174     TInt err = KErrNone;
       
  2175     TPtrC ptr( aText );
       
  2176     if ( ptr.Length() )
       
  2177         {
       
  2178         TRAP( err, iTextBuffer = HbTextResolverSymbian::LoadL( ptr ) );
       
  2179         _DDPRINT( 4, "PhSrv.LoadDefaultString.LoadL.%d", err );
       
  2180         if ( iTextBuffer )
       
  2181             {
       
  2182             ptr.Set( iTextBuffer->Des() );   
       
  2183             _DPRINT( 4, "PhSrv.LoadDefaultString.Set" );
       
  2184             }
       
  2185         }    
       
  2186     _DPRINT( 4, "PhSrv.LoadDefaultString.End" );
       
  2187     return ptr;
       
  2188     }
       
  2189 
  2169 // End of File
  2190 // End of File