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