phoneclientserver/phoneserver/Src/Ussd/CPhSrvUssdManager.cpp
changeset 0 ff3b6d0fd310
child 3 a4a774cb6ea7
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  USSD Manager.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "CPhSrvUssdManager.h"
       
    20 #include "PhSrvUtils.h"
       
    21 #include "CPhSrvUssdSendHandler.h"
       
    22 #include "CPhSrvUssdReceiveHandler.h"
       
    23 #include "CPhSrvUssdNotifyNWRelease.h"
       
    24 #include "CPhSrvResourceManager.h"
       
    25 #include "CPhSrvUssdReplyTimer.h"
       
    26 #include "MPhSrvUssdMessageSentObserver.h"
       
    27 #include "MPhSrvPhoneInterface.h"
       
    28 #include "CPhSrvUssdSessionCancelWaiter.h"
       
    29 
       
    30 #include <AknGlobalNote.h>
       
    31 #include <aknnotedialog.h>
       
    32 #include <aknstaticnotedialog.h>
       
    33 #include <AknProgressDialog.h>
       
    34 #include <apacmdln.h>
       
    35 #include <apgtask.h>
       
    36 #include <bautils.h>
       
    37 #include <StringLoader.h>
       
    38 #include <AknGlobalMsgQuery.h>
       
    39 #include <textresolver.h>
       
    40 #include <charconv.h>
       
    41 #include <gsmuelem.h>
       
    42 #include <exterror.h>
       
    43 #include <rmmcustomapi.h>
       
    44 
       
    45 #include <w32std.h>
       
    46 #include <apgcli.h>
       
    47 #include <CPhCltUssd.h>
       
    48 #include <avkon.rsg>
       
    49 #include <PhoneServer.rsg>
       
    50 #include <telephonyvariant.hrh>
       
    51 #include "PhSrvDebugInfo.h"
       
    52 #include <e32property.h>
       
    53 
       
    54 #include <NcnListInternalPSKeys.h>
       
    55 #include <centralrepository.h>
       
    56 #include <telinternalcrkeys.h>
       
    57 #include <coreapplicationuisdomainpskeys.h>
       
    58 
       
    59 
       
    60 // CONSTANTS
       
    61 const TInt KPhSrvDefaultValue = 0x00000000;
       
    62 // const TInt KPhSrvUssdNoTone = 0; // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
       
    63 const TInt KPhSrvUssdTone   = 2; // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
       
    64 
       
    65 // const TInt KPhSrvUssdTimeOutObserverGranularity = 2;
       
    66 // const TInt KPhSrvUssdSentMessageObserverGranularity = 2;
       
    67 const TInt KPhSrvUssdAppUID = 0x10005955;
       
    68 
       
    69 const TInt KPhSrvUssdMessageQueryInterval = 500000; // 0.5 sec
       
    70 const TInt KPhSrvUssdNoteExitPeriod = 500000; // 0.5 sec
       
    71 //
       
    72 const TUint KPhSrvUssdDefaultDCS = 0x0f;                        // 00001111
       
    73 
       
    74 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguage = 0x10;// 00010000
       
    75 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguageSkipChars3 = 3;
       
    76 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguageSkipChars2 = 2;
       
    77 const TUint KPhSrvUssdDcsAlphabetDefaultPrecededLanguageStartBit = 5;
       
    78 
       
    79 const TUint KPhSrvUssdDcsAlphabetUCS2PrecededLanguage = 0x11;   // 00010001
       
    80 const TUint KPhSrvUssdDcsAlphabetUCS2PrecededLanguageSkipChars = 2;
       
    81 
       
    82 const TUint KPhSrvUssdDcsGeneralInformationMask = 0xc0;         // 11000000
       
    83 const TUint KPhSrvUssdDcsGeneralInformation = 0x40;             // 01xxxxxx
       
    84 const TUint KPhSrvUssdDcsGeneralInformationCompressed = 0x20;   // xx1xxxxx
       
    85 const TUint KPhSrvUssdDcsGeneralInformationSimMask = 0x13;      // 00010011
       
    86 const TUint KPhSrvUssdDcsGeneralInformationSim = 0x12;          // xxx1xx10
       
    87 const TUint KPhSrvUssdDcsGeneralInformationAlphabetMask = 0x0c; // 00001100
       
    88 const TUint KPhSrvUssdDcsGeneralInformationAlphabet8Bit = 0x04; // xxxx01xx
       
    89 const TUint KPhSrvUssdDcsGeneralInformationAlphabetUCS2 = 0x08; // xxxx10xx
       
    90 
       
    91 const TUint KPhSrvUssdDcsMessageHandlingAlphabetMask = 0xf4;    // 11110100
       
    92 const TUint KPhSrvUssdDcsMessageHandlingAlphabet8Bit = 0xf4;    // 1111x1xx
       
    93 const TInt KPhrUssdNotifyArraySize = 1;
       
    94 
       
    95 // MACROS
       
    96 
       
    97 #define _DPRINT_FLAGS() \
       
    98     _DDPRINT( 4, "PhSrv.FLAGS.MsgTypeReply ", iMsgTypeReply ); \
       
    99     _DDPRINT( 4, "PhSrv.FLAGS.NwReleased   ", iNetworkReleased ); \
       
   100     _DDPRINT( 4, "PhSrv.FLAGS.SendingAck   ", iSendingAck ); \
       
   101     _DDPRINT( 4, "PhSrv.FLAGS.AcksToBeSent ", iAcksToBeSent ); \
       
   102     _DDPRINT( 4, "PhSrv.FLAGS.iSendRelease ", iSendRelease ); \
       
   103     _DDPRINT( 4, "PhSrv.FLAGS.iClearArray  ", iClearArray ); \
       
   104     _DDPRINT( 4, "PhSrv.FLAGS.iLaunchGMQ   ", iLaunchGMQ ); \
       
   105     _DDPRINT( 4, "PhSrv.FLAGS.NotifyCount  ", NotifyCount() ); \
       
   106     _DDPRINT( 4, "PhSrv.FLAGS.iShowDone    ", iShowDone ); 
       
   107 
       
   108 // ============================= LOCAL FUNCTIONS ===============================
       
   109 
       
   110 // CLASS DECLARATION
       
   111 
       
   112 #ifndef TPHSRVUSSDALPHABETPACKER_H
       
   113 #define TPHSRVUSSDALPHABETPACKER_H
       
   114 
       
   115 // CONSTANTS
       
   116 const TUint8 KPhSrvUssdCarriageReturn = 0x0d;
       
   117 
       
   118 /**
       
   119 *  Packs and unpacks data encoded in an Ussd alphabet.
       
   120 *
       
   121 *  @since 1.0
       
   122 */
       
   123 class TPhSrvUssdAlphabetPacker
       
   124     {
       
   125     public:  // Constructors and destructor
       
   126 
       
   127         /**
       
   128         * Constructor.
       
   129         *
       
   130         * @param aAlphabet The alphabet that is used.
       
   131         * @param aIsBinary Is the data binary, that will be converted.
       
   132         * @param aStartBit The start bit for conversion.
       
   133         */
       
   134         TPhSrvUssdAlphabetPacker(
       
   135             TSmsDataCodingScheme::TSmsAlphabet aAlphabet,
       
   136             TBool aIsBinary,
       
   137             TInt aStartBit );
       
   138 
       
   139 
       
   140     public: // New functions
       
   141 
       
   142         /**
       
   143         * Unpacks 7-bit buffer to 8-bit buffer.
       
   144         *
       
   145         * @param aIn Descriptor where the 7-bit buffer is.
       
   146         * @param aOut 8-bit buffer to set the result.
       
   147         * @param aNumUDUnits Buffer length.
       
   148         * @return Length of the result buffer.
       
   149         */
       
   150         TInt UnpackL(
       
   151             const TDesC8& aIn,
       
   152             TDes8& aOut,
       
   153             TInt aNumUDUnits );
       
   154 
       
   155         /**
       
   156         * Unpacks 7-bit buffer to 8-bit and converts to unicode.
       
   157         *
       
   158         * @param aCharacterSetConverter Does the converting.
       
   159         * @param aFs File server session.
       
   160         * @param aIn Packed 7-bit buffer.
       
   161         * @param aOut Unicode buffer.
       
   162         * @param aNumUDUnits Number of charahters.
       
   163         * @return Number of used octets in 8-bit buffer.
       
   164         */
       
   165         TInt UnpackAndConvertL(
       
   166             CCnvCharacterSetConverter& aCharacterSetConverter,
       
   167             RFs& aFs,
       
   168             const TDesC8& aIn,
       
   169             TDes& aOut,
       
   170             TInt aNumUDUnits );
       
   171 
       
   172         /**
       
   173         * Counts the needed octet amout.
       
   174         *
       
   175         * @param aNumUDUnits Number of source characters.
       
   176         * @return Octets needed.
       
   177         */
       
   178         TInt PackedOctetsRequiredL( TInt aNumUDUnits ) const;
       
   179 
       
   180 
       
   181     private:
       
   182 
       
   183         // Private helper methods
       
   184         TInt ElementSizeInBitsL() const;
       
   185 
       
   186 
       
   187     private:    // Data
       
   188 
       
   189         // The used coding alphabet.
       
   190         TSmsDataCodingScheme::TSmsAlphabet iAlphabet;
       
   191 
       
   192         // Is the packed data binary.
       
   193         TBool iIsBinary;
       
   194 
       
   195         // The start bit for packing.
       
   196         TInt iStartBit;
       
   197     };
       
   198 
       
   199 #endif // TPHSRVUSSDALPHABETPACKER_H
       
   200 
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // TPhSrvUssdAlphabetPacker::TPhSrvUssdAlphabetPacker
       
   204 // Constructor.
       
   205 //
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 TPhSrvUssdAlphabetPacker::TPhSrvUssdAlphabetPacker(
       
   209     TSmsDataCodingScheme::TSmsAlphabet aAlphabet,
       
   210     TBool aIsBinary,
       
   211     TInt aStartBit)
       
   212     : iAlphabet( aAlphabet ),iIsBinary( aIsBinary ),iStartBit( aStartBit )
       
   213     {
       
   214     }
       
   215 
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // TPhSrvUssdAlphabetPacker::UnpackL
       
   219 // Unpacks user data units from aIn and appends to aOut.
       
   220 //
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 TInt TPhSrvUssdAlphabetPacker::UnpackL(
       
   224     const TDesC8& aIn,
       
   225     TDes8& aOut,
       
   226     TInt aNumUDUnits )
       
   227     {
       
   228     TInt length = aNumUDUnits;
       
   229     // Ensure we've got enough  output buffer
       
   230     if ( aOut.Length() + length > aOut.MaxLength() )
       
   231         {
       
   232         User::Leave(KErrCorrupt);
       
   233         }
       
   234 
       
   235     TInt elementSizeInBits = ElementSizeInBitsL();
       
   236     if ( elementSizeInBits == 8 ) // 8-bit data?
       
   237         {
       
   238         aOut.Append( aIn );
       
   239         }
       
   240     else if ( elementSizeInBits == 7 ) // need unpacking from 7-bit data
       
   241         {
       
   242         // Get raw pointers and do unpacking
       
   243         TUint8* outPtr = ( TUint8* )aOut.Ptr() + aOut.Length();
       
   244         const TUint8* inPtr = aIn.Ptr();
       
   245 
       
   246         for ( TInt i = 0; i < length; i++ )
       
   247             {
       
   248             TInt from = ( *inPtr >> iStartBit ) & 0x7F; // Take seven bits
       
   249             if ( iStartBit )
       
   250                 {
       
   251                 inPtr++;
       
   252                 // Take more from next byte
       
   253                 from |= ( *inPtr << ( 8 - iStartBit ) ) & 0x7F;
       
   254                 }
       
   255             outPtr[i] = ( TUint8 ) from;
       
   256             iStartBit = ( iStartBit + 7 ) % 8; // roll: 0,1,2,...,6,7,0,1,2...
       
   257             }
       
   258 
       
   259         // The last character will be ignored if message ends
       
   260         // on an octet bounday with CR.
       
   261         if ( outPtr[ length-1 ] == KPhSrvUssdCarriageReturn && iStartBit == 0 )
       
   262             {
       
   263             length--;
       
   264             }
       
   265         aOut.SetLength( aOut.Length() + length );
       
   266         }
       
   267     else
       
   268         {
       
   269         __ASSERT_DEBUG(EFalse,
       
   270             PhoneServerUtils::Panic( EPhoneServerPanicModeLogicFault ) );
       
   271         }
       
   272     return length;
       
   273     }
       
   274 
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // TPhSrvUssdAlphabetPacker::UnpackAndConvertL
       
   278 // Unpacks the converts the input data, aIn, and appends to aOut
       
   279 //
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 TInt TPhSrvUssdAlphabetPacker::UnpackAndConvertL(
       
   283     CCnvCharacterSetConverter& aCharacterSetConverter,
       
   284     RFs& aFs,
       
   285     const TDesC8& aIn,
       
   286     TDes& aOut,
       
   287     TInt aNumUDUnits )
       
   288     {
       
   289 
       
   290     // Unpack first
       
   291     HBufC8* unpackedBuffer = HBufC8::NewLC( aNumUDUnits );
       
   292     TPtr8 unpackedBufferPtr( unpackedBuffer->Des() );
       
   293     UnpackL( aIn, unpackedBufferPtr,aNumUDUnits );
       
   294 
       
   295     // Convert
       
   296     CSmsAlphabetConverter* converter =
       
   297         CSmsAlphabetConverter::NewLC(
       
   298             aCharacterSetConverter, aFs, iAlphabet, iIsBinary );
       
   299 
       
   300     TPtrC convertedPtr = converter->ConvertToNativeL( *unpackedBuffer );
       
   301     if ( convertedPtr.Length() > ( aOut.MaxLength() - aOut.Length() ) )
       
   302         {
       
   303         User::Leave( KErrCorrupt );
       
   304         }
       
   305     // Cleanup and return
       
   306     aOut.Append( convertedPtr );
       
   307     CleanupStack::PopAndDestroy( 2 );    // unpackedBuffer, converter
       
   308     return aNumUDUnits;
       
   309     }
       
   310 
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // TPhSrvUssdAlphabetPacker::PackedOctetsRequiredL
       
   314 // Returns the number of octets needed to pack the specified number of
       
   315 //
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 TInt TPhSrvUssdAlphabetPacker::PackedOctetsRequiredL( TInt aNumUDUnits ) const
       
   319 
       
   320     {
       
   321     TInt octetsRequired = 0;
       
   322     TInt elementSizeInBits = ElementSizeInBitsL();
       
   323     if ( elementSizeInBits == 8 )
       
   324         {
       
   325         octetsRequired=aNumUDUnits;
       
   326         }
       
   327     else
       
   328         {
       
   329         octetsRequired =
       
   330             ( iStartBit+aNumUDUnits * elementSizeInBits + 7 ) / 8;  // Rounds up
       
   331         }
       
   332     return octetsRequired;
       
   333     }
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 // TPhSrvUssdAlphabetPacker::ElementSizeInBitsL
       
   337 // Returns the size in bits of a UDL element for the alphabet.  Leaves if
       
   338 // invalid data coding scheme.
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 TInt TPhSrvUssdAlphabetPacker::ElementSizeInBitsL() const
       
   342     {
       
   343     if (iIsBinary)
       
   344         return 8;
       
   345     switch ( iAlphabet )
       
   346         {
       
   347         case TSmsDataCodingScheme::ESmsAlphabet7Bit:
       
   348             {
       
   349             return 7;
       
   350             }
       
   351         case TSmsDataCodingScheme::ESmsAlphabet8Bit:
       
   352         case TSmsDataCodingScheme::ESmsAlphabetUCS2:
       
   353             {
       
   354             return 8;
       
   355             }
       
   356         default:
       
   357             {
       
   358             User::Leave(KErrGsmSMSDataCodingSchemeNotSupported);
       
   359             return 8;
       
   360             }
       
   361         }
       
   362     }
       
   363 
       
   364 
       
   365 
       
   366 // ============================ MEMBER FUNCTIONS ===============================
       
   367 
       
   368 // -----------------------------------------------------------------------------
       
   369 // CPhSrvUssdManager::CPhSrvUssdManager
       
   370 //
       
   371 // Constructor
       
   372 //
       
   373 // -----------------------------------------------------------------------------
       
   374 //
       
   375 CPhSrvUssdManager::CPhSrvUssdManager(
       
   376     RFs& aFsSession,
       
   377     CPhSrvResourceManager& aResourceManager
       
   378     )
       
   379     :CActive( EPriorityLow ),
       
   380      iFsSession( aFsSession ),
       
   381      iResourceManager( aResourceManager ),
       
   382      iDCS ( KPhCltDcsUnknown ),
       
   383      iReturnResultPckg ( iReturnResult )
       
   384 
       
   385     {
       
   386     CActiveScheduler::Add( this );
       
   387     }
       
   388 
       
   389 
       
   390 // -----------------------------------------------------------------------------
       
   391 // CPhSrvUssdManager::~CPhSrvUssdManager
       
   392 //
       
   393 // Destructor
       
   394 //
       
   395 // -----------------------------------------------------------------------------
       
   396 //
       
   397 CPhSrvUssdManager::~CPhSrvUssdManager()
       
   398     {
       
   399     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.start" );       // debug print
       
   400 
       
   401 
       
   402     delete iUssdSendHandler;
       
   403     iUssdSendHandler = NULL;
       
   404 
       
   405     delete iUssdReceiveHandler;
       
   406     iUssdReceiveHandler = NULL;
       
   407 
       
   408     delete iUssdNotifyNWRelease;
       
   409     iUssdNotifyNWRelease = NULL;
       
   410 
       
   411     Cancel();
       
   412 
       
   413     iTimer.Close();
       
   414 
       
   415     delete iGlobalMsgQuery;
       
   416     iGlobalMsgQuery = NULL;
       
   417 
       
   418     if ( iNotifyArray )
       
   419         {
       
   420         iNotifyArray->Reset();
       
   421         }
       
   422     delete iNotifyArray;
       
   423     if ( iUssdReplyTimer )
       
   424         {
       
   425         iUssdReplyTimer->Stop();
       
   426         }
       
   427     delete iUssdReplyTimer;
       
   428     iUssdReplyTimer = NULL;
       
   429 
       
   430     iFsSession.Close();
       
   431 
       
   432     iMobileUssdMessaging.Close();
       
   433 
       
   434     delete iMeQuHeaderText;
       
   435     iMeQuHeaderText = NULL;
       
   436     
       
   437     delete iMoAckCallback;
       
   438 
       
   439     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.end" );       // debug print
       
   440     }
       
   441 
       
   442 
       
   443 // -----------------------------------------------------------------------------
       
   444 // CPhSrvUssdManager::ConstructL
       
   445 //
       
   446 // Symbian OS 2nd phase constructor
       
   447 //
       
   448 // -----------------------------------------------------------------------------
       
   449 //
       
   450 void CPhSrvUssdManager::ConstructL( MPhSrvPhoneInterface& aPhoneInterface )
       
   451     {
       
   452     _DPRINT( 4, "PhSrv.ConstructL.Start" );       // debug print
       
   453     User::LeaveIfError( iTimer.CreateLocal() );
       
   454 
       
   455     User::LeaveIfError( iMobileUssdMessaging.Open( aPhoneInterface.PhSrvMobilePhone() ) );
       
   456 
       
   457     // Check support
       
   458     RMobileUssdMessaging::TMobileUssdCapsV1 caps;
       
   459     RMobileUssdMessaging::TMobileUssdCapsV1Pckg pckgCaps( caps );
       
   460     User::LeaveIfError( iMobileUssdMessaging.GetCaps( pckgCaps ) );
       
   461 
       
   462     if ( !( ( caps.iUssdTypes & RMobileUssdMessaging::KCapsMTUssd ) == 0 &&
       
   463         ( caps.iUssdFormat & RMobileUssdMessaging::KCapsPackedString ) == 0 ) )
       
   464         {
       
   465         _DPRINT( 4, "PhSrv.CPhSrvUssdManager::ConstructL" );
       
   466         iUssdReceiveHandler = new( ELeave ) CPhSrvUssdReceiveHandler(
       
   467             *this,
       
   468             iMobileUssdMessaging );
       
   469         iUssdReceiveHandler->ConstructL();
       
   470 
       
   471         iUssdNotifyNWRelease = new( ELeave )  CPhSrvUssdNotifyNWRelease(
       
   472             *this,
       
   473             iMobileUssdMessaging );
       
   474 
       
   475         iUssdNotifyNWRelease->ConstructL();
       
   476         }
       
   477 
       
   478     iPhoneInterface = &aPhoneInterface;
       
   479 
       
   480     SendHandlerL();
       
   481     
       
   482     iMoAckCallback = new (ELeave) CAsyncCallBack( TCallBack( MoAckCallback, this ), CActive::EPriorityIdle );
       
   483 
       
   484     iVariantReadOnlyValues = KPhSrvDefaultValue;
       
   485 
       
   486     User::LeaveIfError( GetTelephonyVariantData() );
       
   487 
       
   488     iMeQuHeaderText = iResourceManager.ReadResourceLC(
       
   489         R_PHSRV_USSD_MESQUERY_MESSAGE);
       
   490     CleanupStack::Pop( iMeQuHeaderText );
       
   491 
       
   492 	_DDPRINT( 4, "PhSrv.ConstructL.iSatCanceled ", iSatCanceled );
       
   493     _DDPRINT( 4, "PhSrv.ConstructL.iShowDone ", iShowDone );
       
   494     iNotifyArray = new( ELeave ) CDesCArrayFlat( KPhrUssdNotifyArraySize );
       
   495     _DPRINT( 4, "PhSrv.ConstructL.End" );       // debug print
       
   496     }
       
   497 
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CPhSrvUssdManager::SendHandlerL
       
   501 //
       
   502 // The send handler.
       
   503 //
       
   504 // -----------------------------------------------------------------------------
       
   505 //
       
   506 CPhSrvUssdSendHandler& CPhSrvUssdManager::SendHandlerL()
       
   507     {
       
   508     // If SendHandler is not created, first check that MO Ussd
       
   509     // is supported by the TSY.
       
   510     _DPRINT( 4, "PhSrv.SendHandlerL.Start" );       // debug print
       
   511     if ( iUssdSendHandler == NULL )
       
   512         {
       
   513         _DPRINT( 4, "PhSrv.SendHandlerL.iUssdSendHandler.NULL" );       // debug print
       
   514         RMobileUssdMessaging::TMobileUssdCapsV1 caps;
       
   515         RMobileUssdMessaging::TMobileUssdCapsV1Pckg pckgCaps( caps );
       
   516         User::LeaveIfError( iMobileUssdMessaging.GetCaps( pckgCaps ) );
       
   517         _DPRINT( 4, "PhSrv.SendHandlerL.iMobileUssdMessaging.GetCaps" );       // debug print
       
   518 
       
   519         if ( ( caps.iUssdTypes & RMobileUssdMessaging::KCapsMOUssd ) == 0 ||
       
   520             ( caps.iUssdFormat & RMobileUssdMessaging::KCapsPackedString )
       
   521             == 0 )
       
   522             {
       
   523             _DPRINT( 4, "PhSrv.SendHandlerL.KErrNotSupported" );       // debug print
       
   524             User::Leave( KErrNotSupported );
       
   525             }
       
   526 
       
   527         iUssdSendHandler =
       
   528             new( ELeave ) CPhSrvUssdSendHandler(
       
   529                 *this,
       
   530                 iMobileUssdMessaging,
       
   531                 *iPhoneInterface );
       
   532         }
       
   533     _DPRINT( 4, "PhSrv.SendHandlerL.End" );       // debug print
       
   534     return *iUssdSendHandler;
       
   535     }
       
   536 
       
   537 
       
   538 // -----------------------------------------------------------------------------
       
   539 // CPhSrvUssdManager::SendUssdL
       
   540 //
       
   541 // Send the USSD message.
       
   542 //
       
   543 // -----------------------------------------------------------------------------
       
   544 //
       
   545 void CPhSrvUssdManager::SendUssdL(
       
   546     const TDesC8& aMsgData,
       
   547     RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttribute,
       
   548     MPhSrvUssdMessageSentObserver& aObserver )
       
   549     {
       
   550     _DPRINT( 4, "PhSrv.SendUssdL.Start ######" );           // debug print
       
   551     _DPRINT_FLAGS();
       
   552     
       
   553     if ( iObserver && iNetworkReleased ) 
       
   554         {
       
   555         // Network has been released but the previous send request is still alive.
       
   556         // Cancel the pervious send operation, complete the old request with error
       
   557         // and clean up the pointer.
       
   558         _DPRINT( 4, "PhSrv.SendUssdL.Error.Complete.Existing" );           // debug print
       
   559         if ( iUssdSendHandler ) 
       
   560             {
       
   561             iUssdSendHandler->Cancel();
       
   562             }
       
   563         iObserver->UssdMessageSentObserverHandleResult( KErrSessionClosed );
       
   564         iObserver = NULL;
       
   565         }
       
   566     
       
   567     if ( iObserver || iSendingAck )
       
   568         {
       
   569         _DPRINT( 4, "PhSrv.SendUssdL.KErrInUse" );           // debug print
       
   570         // Other client is using the service.
       
   571         User::Leave( KErrInUse );
       
   572         }
       
   573 
       
   574     // Check that message type is set
       
   575     if( ( aMsgAttribute.iFlags & RMobileUssdMessaging::KUssdMessageType )
       
   576         == 0 )
       
   577         _DPRINT( 4, "PhSrv.SendUssdL.KUssdMessageType.0" );       // debug print
       
   578         {
       
   579         // Mesasge type not set -> Set it.
       
   580         aMsgAttribute.iFlags |= RMobileUssdMessaging::KUssdMessageType;
       
   581         if ( NetworkWaitingForAnAnswer() )
       
   582             {
       
   583             // Network is waiting for an answer
       
   584             _DPRINT( 4, "PhSrv.SendUssdL.EUssdMOReply" );	// debug print
       
   585             aMsgAttribute.iType = RMobileUssdMessaging::EUssdMOReply;
       
   586             }
       
   587         else
       
   588             {
       
   589             _DPRINT( 4, "PhSrv.SendUssdL.EUssdMORequest" );  // debug print
       
   590             aMsgAttribute.iType = RMobileUssdMessaging::EUssdMORequest;
       
   591             }
       
   592         }
       
   593         
       
   594     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs( aMsgAttribute );
       
   595     iShowDone = ETrue;
       
   596     _DPRINT( 4, "PhSrv.SendUssdL.iShowDone.ETrue" );
       
   597     _DPRINT( 4, "PhSrv.SendUssdL.Send" );           // debug print
       
   598     SendHandlerL().SendUssdL( aMsgData , attribs );
       
   599     iObserver = &aObserver;
       
   600     // Not closing nor closed anymore
       
   601     iNetworkReleased = EFalse;
       
   602     iSendRelease = EFalse;
       
   603     iClearArray = EFalse;
       
   604     
       
   605     // Reply timer can be killed here... Receive event might come right after this
       
   606     // which will setup the timer again if needed.
       
   607     if ( NetworkWaitingForAnAnswer() )
       
   608         {
       
   609         _DPRINT( 4, "PhSrv.SendUssdCancel.TimerStop" );   // debug print
       
   610         iUssdReplyTimer->Stop();
       
   611         }
       
   612     _DPRINT( 4, "PhSrv.SendUssdL.End" );           // debug print
       
   613     }
       
   614 
       
   615 // -----------------------------------------------------------------------------
       
   616 // CPhSrvUssdManager::NetworkWaitingForAnAnswer
       
   617 // -----------------------------------------------------------------------------
       
   618 //
       
   619 TBool CPhSrvUssdManager::NetworkWaitingForAnAnswer() 
       
   620     {
       
   621     return iUssdReplyTimer && iUssdReplyTimer->IsTimerActive();
       
   622     }
       
   623 // -----------------------------------------------------------------------------
       
   624 // CPhSrvUssdManager::SendUssdCancel
       
   625 //
       
   626 // Cancel the USSD sending.
       
   627 //
       
   628 // -----------------------------------------------------------------------------
       
   629 //
       
   630 void CPhSrvUssdManager::SendUssdCancel()
       
   631     {
       
   632     _DPRINT( 4, "PhSrv.SendUssdCancel.Start #######" );           // debug print
       
   633 
       
   634     // Ack sending should not be canceled unless it's about terminating
       
   635     // the whole session
       
   636     _DPRINT_FLAGS();
       
   637     if ( !iSendingAck || iSendRelease ) 
       
   638         {
       
   639         _DPRINT( 4, "PhSrv.SendUssdCancel.DoingCancel" );
       
   640         iUssdSendHandler->SendUssdCancel();
       
   641         }
       
   642 
       
   643     if ( iHavePendingSatMessagePointer )
       
   644         {
       
   645         _DPRINT( 4, "PhSrv.SendUssdCancel.SatCancel" );
       
   646         iSatCanceled = ETrue;
       
   647         }
       
   648     iObserver = NULL;
       
   649     
       
   650     SetActiveIfPendingNotificationsExist();
       
   651     _DPRINT( 4, "PhSrv.SendUssdCancel.End" );           // debug print
       
   652     }
       
   653 
       
   654 // -----------------------------------------------------------------------------
       
   655 // CPhSrvUssdManager::SetActiveIfPendingNotificationsExist
       
   656 // -----------------------------------------------------------------------------
       
   657 //
       
   658 void CPhSrvUssdManager::SetActiveIfPendingNotificationsExist()
       
   659     {
       
   660     if ( !IsActive() && NotifyCount() > 0 )
       
   661         {
       
   662         _DPRINT( 4, "PhSrv.AcrtivateIf.NotActiveSelf" );
       
   663         iLaunchGMQ = ETrue;
       
   664         iNotifyMessage = ETrue;
       
   665         _DPRINT( 4, "PhSrv.SendUssdCancel.iNotifyMessage.ETrue" );
       
   666         iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
       
   667         SetActive();
       
   668         _DPRINT_FLAGS();
       
   669         _DDPRINT( 4, "PhSrv.AcrtivateIf.SetActive ", iStatus.Int() );
       
   670         }
       
   671     }
       
   672 // -----------------------------------------------------------------------------
       
   673 // CPhSrvUssdManager::UssdNetworkObserverHandleSendEventL
       
   674 //
       
   675 //
       
   676 //
       
   677 // -----------------------------------------------------------------------------
       
   678 //
       
   679 void CPhSrvUssdManager::UssdNetworkObserverHandleSendEventL( TInt aError )
       
   680     {
       
   681     // debug print
       
   682     _DDPRINT(
       
   683         4,
       
   684         "PhSrv.UssdNetworkObserverHandleSendEventL.Start: ##### ",
       
   685         aError );
       
   686 
       
   687     // complete SAT if needed
       
   688     if ( aError < KErrNone )
       
   689         {
       
   690         // debug print
       
   691         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.CompleteSat" );
       
   692         CompleteSatL( NULL, aError );
       
   693         }
       
   694 
       
   695     if ( iObserver )
       
   696         {
       
   697         // debug print
       
   698         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.Observer" );
       
   699 
       
   700         iObserver->UssdMessageSentObserverHandleResult( aError );
       
   701         iObserver = NULL;
       
   702         }
       
   703     
       
   704     iSendingAck = EFalse;
       
   705     
       
   706     AsyncProcessMoAcks();
       
   707     
       
   708     // debug print
       
   709     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleSendEventL.End" );
       
   710     }
       
   711 
       
   712 
       
   713 // -----------------------------------------------------------------------------
       
   714 // CPhSrvUssdManager::UssdAppTaskExists
       
   715 //
       
   716 //
       
   717 //
       
   718 // -----------------------------------------------------------------------------
       
   719 //
       
   720 TBool CPhSrvUssdManager::UssdAppTaskExistsL()
       
   721 {   
       
   722     TBool ret = EFalse;
       
   723     RWsSession wsSession;
       
   724     User::LeaveIfError(wsSession.Connect());
       
   725     _DPRINT( 4, "PhSrv.UssdAppTaskExists.wsSession.Connect" );
       
   726     CleanupClosePushL(wsSession);
       
   727     TApaTaskList tasklist(wsSession);
       
   728     TApaTask task = tasklist.FindApp(TUid::Uid(KPhSrvUssdAppUID));
       
   729     ret = task.Exists();
       
   730 
       
   731     CleanupStack::PopAndDestroy();
       
   732     return ret;
       
   733 }
       
   734 
       
   735 // -----------------------------------------------------------------------------
       
   736 // CPhSrvUssdManager::UssdNetworkObserverHandleReceivedEventL
       
   737 //
       
   738 //
       
   739 //
       
   740 // -----------------------------------------------------------------------------
       
   741 //
       
   742 void CPhSrvUssdManager::UssdNetworkObserverHandleReceivedEventL(
       
   743     const TDes8& aMsgData,
       
   744     const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes,
       
   745     TInt aError )
       
   746     {
       
   747     _DDPRINT(
       
   748         4,
       
   749         "PhSrv.UssdNetworkObserverHandleReceivedEventL.Start: ### ",
       
   750         aError );
       
   751     _DPRINT_FLAGS();
       
   752     if ( aError != KErrNone )
       
   753         {
       
   754         TurnLightsOn(); //Ensure lights on
       
   755         // debug print
       
   756         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleReceivedEventL.ShErNote" );
       
   757         ShowErrorNoteL( aError );
       
   758         }
       
   759     else if ( iSendRelease )
       
   760         {
       
   761         // Ignore if sendrelease is to be done. If the message was
       
   762         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleReceivedEventL.SendRelease.Ignore" );
       
   763         }
       
   764     else
       
   765         {
       
   766         UssdHandleReceivedEventL( aMsgData, aMsgAttributes );
       
   767         }
       
   768     }
       
   769 
       
   770 // -----------------------------------------------------------------------------
       
   771 // CPhSrvUssdManager::UssdHandleReceivedEventL
       
   772 //
       
   773 //
       
   774 //
       
   775 // -----------------------------------------------------------------------------
       
   776 //
       
   777 void CPhSrvUssdManager::UssdHandleReceivedEventL(
       
   778     const TDes8& aMsgData,
       
   779     const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes )
       
   780     {
       
   781     // This always is either ongoing transaction or starting a new based
       
   782     // on incoming message, mark transaction to be open.
       
   783     iNetworkReleased = EFalse;
       
   784 		
       
   785     // 2. Complete Send with some positive value.
       
   786 	if ( iObserver )
       
   787         {
       
   788         // debug print
       
   789         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Observer" );
       
   790         UssdNetworkObserverHandleSendEventL( 1 ); // some positive value
       
   791         }
       
   792 	
       
   793     if ( aMsgAttributes.iFlags&RMobileUssdMessaging::KUssdMessageType &&
       
   794          aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest )
       
   795         {
       
   796         // 3. Stop old reply timer and start new one if needed.
       
   797         RestartReplyTimerL();
       
   798         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleReceivedEventL.Timer.Stop" );
       
   799         _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleReceivedEventL.Timer.New" );
       
   800         }
       
   801     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Decode" );
       
   802     TUint8 dcs = KPhSrvUssdDefaultDCS;
       
   803     if(aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageDcs)
       
   804         {
       
   805         dcs = aMsgAttributes.iDcs;
       
   806         }
       
   807     iDecodedMessage.Zero();
       
   808     iReceivedMessage.Zero();
       
   809     DecodeL(aMsgData, iDecodedMessage, dcs);
       
   810     if(iDecodedMessage.Length() > 0)
       
   811         {
       
   812         iReceivedMessage = iDecodedMessage;
       
   813         }
       
   814     // 5. Show note.
       
   815     // debug print
       
   816     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Note" );
       
   817     if ( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType ) ||
       
   818             aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
       
   819         {
       
   820         if ( !ShowNotesL() )
       
   821             {
       
   822             // debug print
       
   823             _DPRINT( 4,
       
   824                 "PhSrv.UssdHandleReceivedEventL.SAtReturn" );
       
   825             return;
       
   826             }
       
   827         }
       
   828 
       
   829     // empty string is handled as ok message
       
   830     if ( !iDecodedMessage.Length() )
       
   831         {
       
   832         TurnLightsOn(); //Ensure lights on
       
   833         // debug print
       
   834         _DPRINT( 4,
       
   835             "PhSrv.UssdHandleReceivedEventL.EmptyString" );
       
   836         
       
   837         ShowDoneNoteL();
       
   838 
       
   839         // debug print
       
   840         _DPRINT( 4,
       
   841             "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
       
   842         }
       
   843     else
       
   844         {
       
   845        	_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
       
   846         iNotifyMessage = ( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTNotify );
       
   847         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
       
   848         _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
       
   849         iMsgTypeReply = ( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTReply );
       
   850         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
       
   851         
       
   852         if ( iNotifyMessage ) 
       
   853             {
       
   854             // need to send an MO ack
       
   855             iAcksToBeSent ++;
       
   856             }
       
   857         
       
   858         if ( iNotifyMessage || iMsgTypeReply )
       
   859         	{
       
   860         	//This is for reply message in notifyarray
       
   861         	iNotifyMessage = ETrue;
       
   862         	_DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
       
   863 
       
   864 	        //Notify added to array
       
   865         	iNotifyArray->AppendL( iReceivedMessage );
       
   866 
       
   867         	_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" );       // debug print
       
   868         	UpdateNotifyMessage();
       
   869 
       
   870         	if ( !iSendRelease && NotifyCount() <= 1 )
       
   871 				{
       
   872 				_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" );       // debug print
       
   873 				Cancel();
       
   874 				}
       
   875         	}
       
   876         else
       
   877        		{
       
   878        		// New message deletes old message, i.e. Cancel existing query.
       
   879        		Cancel();
       
   880 			_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" );       // debug print
       
   881        		}
       
   882 
       
   883         if ( !iGlobalMsgQuery )
       
   884             {
       
   885             iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
       
   886             }
       
   887 
       
   888         // Delay after message query so that application execution order will
       
   889         // be correct.
       
   890         iGlobalMsgQuery->SetExitDelay( KPhSrvUssdNoteExitPeriod );
       
   891 
       
   892         TInt softkeys = R_AVKON_SOFTKEYS_USSD_ANSWER_EXIT__ANSWER;
       
   893         if( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType )
       
   894              || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
       
   895             {
       
   896             softkeys = R_AVKON_SOFTKEYS_EXIT;
       
   897             }
       
   898 
       
   899         // Set timer that lauches Global MessageQuery after time interval.
       
   900         iSoftkeys = softkeys;
       
   901 
       
   902         // debug print
       
   903         _DPRINT( 4,
       
   904             "PhSrv.UssdHandleReceivedEventL.String.Middle" );
       
   905 
       
   906         // Play the USSD tone if needed. Logically should be in RunL, but here
       
   907         // to give better balancing with voice and visible message.
       
   908         if ( IsTelephonyFeatureSupported( KTelephonyLVFlagUssdTone ) )
       
   909             {
       
   910             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.PlayTone" );
       
   911             PlayUssdTone();
       
   912             }
       
   913 
       
   914         // Launch the new message query
       
   915         if ( !IsActive() )
       
   916             {
       
   917             iLaunchGMQ = ETrue;
       
   918             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
       
   919             SetActive();
       
   920             }
       
   921         AsyncProcessMoAcks();
       
   922         }
       
   923     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Editor" );
       
   924     if( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest && UssdAppTaskExistsL() )
       
   925         {
       
   926         iEmptyEditor = ETrue;
       
   927         }
       
   928     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.End" );
       
   929     }
       
   930 
       
   931 // -----------------------------------------------------------------------------
       
   932 // CPhSrvUssdManager::RestartReplyTimerL
       
   933 //
       
   934 //
       
   935 //
       
   936 // -----------------------------------------------------------------------------
       
   937 //
       
   938 void CPhSrvUssdManager::RestartReplyTimerL()
       
   939     {
       
   940     if ( iUssdReplyTimer )
       
   941         {
       
   942         _DPRINT( 4, "PhSrv.RestartReplyTimerL.Stop" );
       
   943         iUssdReplyTimer->Stop();
       
   944         }
       
   945 
       
   946     if ( !iUssdReplyTimer )
       
   947         {
       
   948         _DPRINT( 4, "PhSrv.RestartReplyTimerL.New" );
       
   949         iUssdReplyTimer = CPhSrvUssdReplyTimer::NewL( *this );
       
   950         }
       
   951     
       
   952     _DPRINT( 4, "PhSrv.RestartReplyTimerL.Start" );
       
   953     iUssdReplyTimer->Start();
       
   954     }
       
   955 
       
   956 // -----------------------------------------------------------------------------
       
   957 // CPhSrvUssdManager::UssdNetworkObserverHandleNotifyNWReleaseL
       
   958 //
       
   959 //
       
   960 //
       
   961 // -----------------------------------------------------------------------------
       
   962 //
       
   963 void CPhSrvUssdManager::UssdNetworkObserverHandleNotifyNWReleaseL(
       
   964 const RMobilePhone::TMobilePhoneSendSSRequestV3 & aReturnResult,
       
   965 TInt aError )
       
   966 	{
       
   967  	_DDPRINT( 4, "PhSrv.UssdNotifyNWRelease ##### ", aError ); // debug print
       
   968     _DPRINT_FLAGS();
       
   969  	TBool showNotes = ShowNotesL();
       
   970  	iNetworkReleased = ETrue;
       
   971  	iSendingAck = EFalse;
       
   972     iSendRelease = EFalse;
       
   973  	iAcksToBeSent = 0;
       
   974  	
       
   975  	if ( iHavePendingSatMessagePointer )
       
   976  		{
       
   977  		iReturnResult = aReturnResult;
       
   978  		if ( !iSatCanceled )
       
   979  			{
       
   980  			CompleteSatL(&iReceivedMessage, aError );
       
   981 			_DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.CompleteSat" );       // debug print
       
   982  			}
       
   983  		}
       
   984  	if ( iUssdReplyTimer && iUssdReplyTimer->IsTimerActive() )
       
   985     	{
       
   986     	_DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Timer.Stop" );
       
   987     	iUssdReplyTimer->Stop();
       
   988     	Cancel();
       
   989     	CheckArray();
       
   990     	}
       
   991     if ( showNotes && iShowDone )
       
   992         {
       
   993         ShowDoneNoteL();
       
   994         }
       
   995     if ( iUssdSendHandler && iSendingAck ) 
       
   996         {
       
   997         // if we are sending ack, it can be canceled.
       
   998         iUssdSendHandler->Cancel();
       
   999         }
       
  1000     
       
  1001     iSatCanceled = EFalse;
       
  1002     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.iSatCanceled.EFalse" );
       
  1003     iShowDone = EFalse;
       
  1004     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Ending" );
       
  1005     _DPRINT_FLAGS();
       
  1006     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.End" );
       
  1007 	}
       
  1008 
       
  1009 // -----------------------------------------------------------------------------
       
  1010 // CPhSrvUssdManager::ShowDoneNoteL
       
  1011 //
       
  1012 // -----------------------------------------------------------------------------
       
  1013 //
       
  1014 void CPhSrvUssdManager::ShowDoneNoteL()
       
  1015     {
       
  1016     _DDPRINT( 4, "PhSrv.ShowDoneNoteL.iShowDone", iShowDone );
       
  1017     // Show global confirmation note "Done"
       
  1018     HBufC* noteText = iResourceManager.ReadResourceLC( R_PHSRV_TEXT_DONE );
       
  1019     CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
  1020     note->ShowNoteL( EAknGlobalConfirmationNote, *noteText );
       
  1021     CleanupStack::PopAndDestroy( note );
       
  1022     CleanupStack::PopAndDestroy( noteText );
       
  1023     iShowDone = EFalse;
       
  1024     }
       
  1025 
       
  1026 // -----------------------------------------------------------------------------
       
  1027 // CPhSrvUssdManager::ShowErrorNoteL
       
  1028 //
       
  1029 // -----------------------------------------------------------------------------
       
  1030 //
       
  1031 void CPhSrvUssdManager::ShowErrorNoteL( TInt aError )
       
  1032     {
       
  1033     _DDPRINT( 4, "PhSrv.ShowErrorNoteL.Start ", aError );
       
  1034     if ( aError == KErrCancel )
       
  1035         {
       
  1036         _DPRINT( 4, "PhSrv.ShowErrorNoteL.Return" );
       
  1037         return;
       
  1038         }
       
  1039 
       
  1040     CTextResolver* textResolver = CTextResolver::NewLC();
       
  1041 
       
  1042     HBufC* buffer = textResolver->ResolveErrorString( aError ).AllocLC();
       
  1043 
       
  1044     CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
  1045     note->ShowNoteL( EAknGlobalErrorNote, *buffer );
       
  1046 
       
  1047     CleanupStack::PopAndDestroy( 3 ); // note, buffer, textResolver
       
  1048     _DPRINT( 4, "PhSrv.ShowErrorNoteL.End" );
       
  1049     return;
       
  1050     }
       
  1051 
       
  1052 
       
  1053 // -----------------------------------------------------------------------------
       
  1054 // CPhSrvUssdManager::DecodeL
       
  1055 //
       
  1056 // -----------------------------------------------------------------------------
       
  1057 //
       
  1058 void CPhSrvUssdManager::DecodeL(
       
  1059     const TDesC8& aSrc,
       
  1060     TDes& aDes ,
       
  1061     TUint8 aDcs )
       
  1062     {
       
  1063     _DPRINT( 4, "PhSrv.DecodeL.Start" );
       
  1064     aDes.Zero();
       
  1065     CCnvCharacterSetConverter* charConv = CCnvCharacterSetConverter::NewLC();
       
  1066 
       
  1067     iDCS = KPhCltDcsUnknown; // default
       
  1068 
       
  1069     // Check DCS
       
  1070     TSmsDataCodingScheme::TSmsAlphabet alphabet =
       
  1071         TSmsDataCodingScheme::ESmsAlphabet7Bit; // default
       
  1072     TUint cutChars = 0;
       
  1073     TUint startBit = 0;
       
  1074 
       
  1075     // Codes from GSM 03.38
       
  1076     if ( aDcs == KPhSrvUssdDcsAlphabetDefaultPrecededLanguage )
       
  1077         {
       
  1078         FindFirstCarriageReturnL( aSrc , cutChars , startBit );
       
  1079         }
       
  1080     else if ( aDcs == KPhSrvUssdDcsAlphabetUCS2PrecededLanguage )
       
  1081         {
       
  1082         alphabet = TSmsDataCodingScheme::ESmsAlphabetUCS2;
       
  1083         cutChars = KPhSrvUssdDcsAlphabetUCS2PrecededLanguageSkipChars;
       
  1084         }
       
  1085     else if ( (aDcs&KPhSrvUssdDcsGeneralInformationMask)  ==
       
  1086             KPhSrvUssdDcsGeneralInformation ) // General data coding information
       
  1087         {
       
  1088         //Is text compressed?
       
  1089         if ( aDcs & KPhSrvUssdDcsGeneralInformationCompressed )
       
  1090             {
       
  1091             _DPRINT( 4, "PhSrv.DecodeL.KErrNotSupported" );
       
  1092             User::Leave( KErrNotSupported );
       
  1093             }
       
  1094         // Is SIM specific message
       
  1095         else if ( ( aDcs & KPhSrvUssdDcsGeneralInformationSimMask )
       
  1096                    == KPhSrvUssdDcsGeneralInformationSim )
       
  1097             {
       
  1098             _DPRINT( 4, "PhSrv.DecodeL.KErrAbort" );
       
  1099             User::Leave( KErrAbort ); // Do not show any messages
       
  1100             }
       
  1101         // 8 bit data?
       
  1102         else if ( ( aDcs&KPhSrvUssdDcsGeneralInformationAlphabetMask ) ==
       
  1103                    KPhSrvUssdDcsGeneralInformationAlphabet8Bit )
       
  1104             {
       
  1105             alphabet = TSmsDataCodingScheme::ESmsAlphabet8Bit;
       
  1106             }
       
  1107         // UCS2 bit data?
       
  1108         else if ( ( aDcs&KPhSrvUssdDcsGeneralInformationAlphabetMask ) ==
       
  1109                    KPhSrvUssdDcsGeneralInformationAlphabetUCS2 )
       
  1110             {
       
  1111             alphabet = TSmsDataCodingScheme::ESmsAlphabetUCS2;
       
  1112             }
       
  1113         }
       
  1114     // Data coding/message handling
       
  1115     else if ( ( aDcs & KPhSrvUssdDcsMessageHandlingAlphabetMask )
       
  1116                == KPhSrvUssdDcsMessageHandlingAlphabet8Bit )
       
  1117         {
       
  1118         alphabet = TSmsDataCodingScheme::ESmsAlphabet8Bit;
       
  1119         }
       
  1120 
       
  1121     TPhSrvUssdAlphabetPacker* packer =
       
  1122         new ( ELeave ) TPhSrvUssdAlphabetPacker( alphabet , EFalse, startBit );
       
  1123     CleanupStack::PushL( packer );
       
  1124 
       
  1125     if ( alphabet == TSmsDataCodingScheme::ESmsAlphabet7Bit )
       
  1126         {
       
  1127         TInt numberOfElem = ( ( aSrc.Length() - cutChars ) * 8 - startBit ) / 7;
       
  1128         packer->UnpackAndConvertL(
       
  1129             *charConv ,
       
  1130             iFsSession ,
       
  1131             aSrc.Right( aSrc.Length() - cutChars ),
       
  1132             aDes ,
       
  1133             numberOfElem );
       
  1134 
       
  1135         // DCS was 7-bit data.
       
  1136         iDCS = KPhCltDcs7Bit;
       
  1137         }
       
  1138     else // ESmsAlphabet8Bit || ESmsAlphabetUCS2
       
  1139         {
       
  1140         CSmsAlphabetConverter* converter =
       
  1141             CSmsAlphabetConverter::NewLC(
       
  1142                 *charConv , iFsSession,alphabet,EFalse );
       
  1143 
       
  1144         aDes = converter->ConvertToNativeL(
       
  1145             aSrc.Right( aSrc.Length() - cutChars ) );
       
  1146         CleanupStack::PopAndDestroy( converter );
       
  1147 
       
  1148         if( alphabet == TSmsDataCodingScheme::ESmsAlphabet8Bit )
       
  1149             {
       
  1150             // DCS was 8-bit data.
       
  1151             iDCS = KPhCltDcs8Bit;
       
  1152             }
       
  1153         else if( alphabet == TSmsDataCodingScheme::ESmsAlphabetUCS2 )
       
  1154             {
       
  1155             // DCS was UCS2 data.
       
  1156             iDCS = KPhCltDcsUcs2;
       
  1157             }
       
  1158         // If DCS not 8-bit or UCS2, then EPhCltDcsUnknown is returned.
       
  1159         }
       
  1160 
       
  1161     //
       
  1162     CleanupStack::PopAndDestroy(2); // packer, charConv
       
  1163     _DPRINT( 4, "PhSrv.DecodeL.End" );
       
  1164     }
       
  1165 
       
  1166 
       
  1167 // -----------------------------------------------------------------------------
       
  1168 // CPhSrvUssdManager::FindFirstCarriageReturnL
       
  1169 // -----------------------------------------------------------------------------
       
  1170 //
       
  1171 void CPhSrvUssdManager::FindFirstCarriageReturnL(
       
  1172     const TDesC8& aBuffer ,
       
  1173     TUint& aSkipChars ,
       
  1174     TUint& aStartBit )
       
  1175     {
       
  1176     _DPRINT( 4, "PhSrv.FindFirstCarriageReturnL.Start" );
       
  1177     if ( aBuffer.Length() < 3 )
       
  1178         {
       
  1179         _DPRINT( 4, "PhSrv.FindFirstCarriageReturnL.KErrUnderflow" );
       
  1180         User::Leave( KErrUnderflow );
       
  1181         }
       
  1182 
       
  1183     aSkipChars = 0;
       
  1184     aStartBit = 0;
       
  1185 
       
  1186     // Try out two different cases:
       
  1187     // 1. Find CR from thrid byte
       
  1188     // 2. Find CR from second byte, starting from bit 6
       
  1189 
       
  1190     // 1.:
       
  1191     if ( aBuffer[2] == KPhSrvUssdCarriageReturn )
       
  1192         {
       
  1193         aSkipChars = KPhSrvUssdDcsAlphabetDefaultPrecededLanguageSkipChars3;
       
  1194         aStartBit = 0;
       
  1195         _DPRINT( 4, "PhSrv.FindFirstCarriageReturnL.ThirdByte.Return" );
       
  1196         return;
       
  1197         }
       
  1198 
       
  1199     // 2.:
       
  1200     // First put the pieces together and then compare
       
  1201     // Take last 2 bits from the second byte:
       
  1202     TUint result1 = aBuffer[1];
       
  1203     result1 = result1 >> 6;
       
  1204 
       
  1205     // Take first 5 bits from the third byte:
       
  1206     TUint result2 = aBuffer[2];
       
  1207     result2 = result2 & 0x1f; // bits 0-4.
       
  1208     result2 = result2 << 2; // move to bits 2-6.
       
  1209 
       
  1210     TUint result = result1 + result2; // 0000 00xx + 0xxx xx00
       
  1211     if ( result == KPhSrvUssdCarriageReturn )
       
  1212         {
       
  1213         aSkipChars = KPhSrvUssdDcsAlphabetDefaultPrecededLanguageSkipChars2;
       
  1214         aStartBit = KPhSrvUssdDcsAlphabetDefaultPrecededLanguageStartBit;
       
  1215         _DPRINT( 4, "PhSrv.FindFirstCarriageReturnL.SecondByte.Return" );
       
  1216         return;
       
  1217         }
       
  1218 
       
  1219     // Is was not case 1. or 2. so we are not supporting sort of string.
       
  1220     User::Leave( KErrNotSupported );
       
  1221     _DPRINT( 4, "PhSrv.FindFirstCarriageReturnL.KErrNotSupported" );
       
  1222     }
       
  1223 
       
  1224 
       
  1225 // -----------------------------------------------------------------------------
       
  1226 // CPhSrvUssdManager::UssdReplyTimerObserverHandleExpired
       
  1227 //
       
  1228 //
       
  1229 //
       
  1230 // -----------------------------------------------------------------------------
       
  1231 //
       
  1232 void CPhSrvUssdManager::UssdReplyTimerObserverHandleExpiredL( TInt aError )
       
  1233     {
       
  1234     _DDPRINT( 4, "PhSrv.ReplyTimer.Start.aError ", aError );     // debug print
       
  1235     delete iUssdReplyTimer;
       
  1236     iUssdReplyTimer = NULL;
       
  1237 
       
  1238     if ( aError == KErrNone &&
       
  1239          IsActive() &&
       
  1240          iGlobalMsgQuery )
       
  1241         {
       
  1242         Cancel();
       
  1243         // Terminates USSD session.
       
  1244         _DPRINT( 4, "PhSrv.ReplyTimer.SendRelease" );     // debug print
       
  1245         if ( iNotifyArray ) 
       
  1246             {
       
  1247             iNotifyArray->Reset();
       
  1248             }
       
  1249         TryCloseSession();
       
  1250         }
       
  1251     _DPRINT( 4, "PhSrv.ReplyTimer.End" );     // debug print
       
  1252     }
       
  1253 
       
  1254 
       
  1255 // -----------------------------------------------------------------------------
       
  1256 // CPhSrvUssdManager::RunL
       
  1257 // -----------------------------------------------------------------------------
       
  1258 //
       
  1259 void CPhSrvUssdManager::RunL()
       
  1260     {
       
  1261     _DPRINT( 4, "PhSrv.RunL.Start" );           // debug print
       
  1262 
       
  1263     ProcessMoAcksL();
       
  1264     
       
  1265     if ( iLaunchGMQ )
       
  1266         {
       
  1267         LaunchGlobalMessageQueryL();
       
  1268         // Do not launch Global Message Query next time.
       
  1269         iLaunchGMQ = EFalse;
       
  1270         _DPRINT( 4, "PhSrv.iLaunchGMQ.EFalse" );
       
  1271         }
       
  1272     else
       
  1273         {
       
  1274         iStartEditor = EFalse;
       
  1275         
       
  1276         TInt key = iStatus.Int();
       
  1277         if ( key == EEikBidOk ) // OK key
       
  1278             {
       
  1279             if ( NetworkWaitingForAnAnswer() )
       
  1280                 {
       
  1281                 key = EAknSoftkeyShow;
       
  1282                 }
       
  1283             else
       
  1284                 {
       
  1285                 key = EAknSoftkeyExit;
       
  1286                 }
       
  1287             }
       
  1288 
       
  1289         switch( key )
       
  1290             {
       
  1291             case EAknSoftkeyShow:
       
  1292                 {
       
  1293                 // Answer
       
  1294                 iStartEditor = ETrue;
       
  1295                 iShowDone = EFalse;
       
  1296                 // Start the USSD editor now.
       
  1297                 _DPRINT( 4, "PhSrv.RunL.RequestStartEditingL" ); // debug print
       
  1298                 RequestStartEditingL();
       
  1299                 break;
       
  1300                 }
       
  1301             case EAknSoftkeyYes:
       
  1302                 {
       
  1303                 _DPRINT( 4, "PhSrv.RunL.SK.Yes" );
       
  1304                 iClearArray = EFalse;
       
  1305                 iNotifyArray->Reset();
       
  1306                 TryCloseSession();
       
  1307                 break;
       
  1308                 }
       
  1309             case EAknSoftkeyCancel:
       
  1310                 _DPRINT( 4, "PhSrv.RunL.SK.Cancel" ); 
       
  1311                 if ( iHavePendingSatMessagePointer )
       
  1312                     {
       
  1313                     iSatCanceled = ETrue;
       
  1314                     CompleteSatL( &iReceivedMessage, KErrCancel );
       
  1315                     _DPRINT( 4, "PhSrv.RunL.CompleteSatL" );
       
  1316                     }
       
  1317                 // fall through.
       
  1318             case EAknSoftkeyExit:
       
  1319                 _DPRINT( 4, "PhSrv.RunL.SK.Exit" ); 
       
  1320                 ClearArrayL();
       
  1321                 TryCloseSession();
       
  1322                 break;
       
  1323             case EAknSoftkeyBack:
       
  1324                 _DPRINT( 4, "PhSrv.RunL.SK.Back" ); 
       
  1325                 ClearArrayL();
       
  1326                 TryCloseSession();
       
  1327                 break;
       
  1328             case EAknSoftkeyNo:
       
  1329                 _DPRINT( 4, "PhSrv.RunL.SK.No" );
       
  1330                 iClearArray = EFalse;
       
  1331                 iNotifyMessage = ETrue; // for removing the yes/no query
       
  1332                 // fall through.
       
  1333             case EAknSoftkeyNext:
       
  1334                 _DPRINT( 4, "PhSrv.RunL.SK.Next" ); 
       
  1335                 CheckArray();
       
  1336                 TryCloseSession();
       
  1337                 break;
       
  1338             default:
       
  1339                 _DPRINT( 4, "PhSrv.RunL.SK.Default" ); 
       
  1340                 break;
       
  1341             }
       
  1342         _DPRINT( 4, "PhSrv.RunL.End" );     // debug print
       
  1343         }
       
  1344     }
       
  1345 
       
  1346 // -----------------------------------------------------------------------------
       
  1347 // CPhSrvUssdManager::LaunchGlobalMessageQueryL
       
  1348 // -----------------------------------------------------------------------------
       
  1349 //
       
  1350 void CPhSrvUssdManager::LaunchGlobalMessageQueryL()
       
  1351     {
       
  1352     _DPRINT( 4, "PhSrv.LGMQ.start" );
       
  1353     _DPRINT_FLAGS();
       
  1354     if ( iNotifyMessage )
       
  1355         {
       
  1356         _DDPRINT( 4, "PhSrv.LGMQ.NotifyMessage", iNotifyMessage );
       
  1357         iNotifyMessage = ETrue;
       
  1358         TInt count = NotifyCount();
       
  1359         if ( count > 1 )
       
  1360             {
       
  1361             iSoftkeys = R_AVKON_SOFTKEYS_NEXT_EXIT__NEXT;
       
  1362             }
       
  1363         else
       
  1364             {
       
  1365             iSoftkeys = R_AVKON_SOFTKEYS_EXIT;
       
  1366             }
       
  1367         if ( iClearArray )
       
  1368             {
       
  1369             iSoftkeys = R_AVKON_SOFTKEYS_YES_NO;
       
  1370             }
       
  1371         iReceivedMessage.Zero();
       
  1372         iReceivedMessage = (*iNotifyArray)[0];
       
  1373         }
       
  1374     TurnLightsOn(); //Ensure lights on
       
  1375 
       
  1376     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery" ); // debug print
       
  1377     // Launch Global MessageQuery as requested.
       
  1378     iGlobalMsgQuery->ShowMsgQueryL(iStatus, iReceivedMessage, iSoftkeys,
       
  1379             *iMeQuHeaderText, KNullDesC);
       
  1380     _DPRINT( 4, "PhSrv.LGMQ.SetActive" );
       
  1381     SetActive();
       
  1382     iShowDone = EFalse;
       
  1383     // Do nothing else in RunL this time.
       
  1384     _DPRINT( 4, "PhSrv.LGMQ.ShMsgQuery.ret" ); // debug print
       
  1385     }
       
  1386 
       
  1387 // -----------------------------------------------------------------------------
       
  1388 // CPhSrvUssdManager::ProcessMoAcksL()
       
  1389 // -----------------------------------------------------------------------------
       
  1390 //
       
  1391 void CPhSrvUssdManager::ProcessMoAcksL()
       
  1392     {
       
  1393     //Acknowledgment is sent if notify message
       
  1394     if ( iNotifyMessage && iAcksToBeSent )
       
  1395         {
       
  1396         _DPRINT( 4, "PhSrv.LGMQ.SendMoAcknowledgementL, start" );
       
  1397         _DPRINT_FLAGS();
       
  1398         if ( iUssdSendHandler && !iUssdSendHandler->IsActive() &&
       
  1399              !iNetworkReleased && !iSendRelease && !iSendingAck )
       
  1400             {
       
  1401             _DPRINT( 4, "PhSrv.LGMQ.MoAckNeededToBeSent" );
       
  1402             SendMoAcknowledgementL();
       
  1403             iAcksToBeSent--;
       
  1404             iSendingAck = ETrue;
       
  1405             }
       
  1406         _DPRINT( 4, "PhSrv.LGMQ.SendMoAcknowledgementL, end" );
       
  1407         }
       
  1408     }
       
  1409  
       
  1410 // -----------------------------------------------------------------------------
       
  1411 // CPhSrvUssdManager::AsyncProcessMoAcks()
       
  1412 // -----------------------------------------------------------------------------
       
  1413 //
       
  1414 void CPhSrvUssdManager::AsyncProcessMoAcks()
       
  1415     {
       
  1416     if ( iMoAckCallback ) 
       
  1417         {
       
  1418         iMoAckCallback->CallBack();
       
  1419         _DPRINT( 4, "PhSrv.LGMQ.AsyncProcessMoAcksL, queued" );
       
  1420         }
       
  1421     }
       
  1422 // -----------------------------------------------------------------------------
       
  1423 // CPhSrvUssdManager::MoAckCallback()
       
  1424 // -----------------------------------------------------------------------------
       
  1425 //
       
  1426 TInt CPhSrvUssdManager::MoAckCallback( TAny *aUssdManager )
       
  1427     {
       
  1428     _DPRINT( 4, "PhSrv.MoAckCallback.start" );
       
  1429     if ( aUssdManager )
       
  1430         {
       
  1431         CPhSrvUssdManager* manager = static_cast<CPhSrvUssdManager*>( aUssdManager );
       
  1432         TRAP_IGNORE( manager->ProcessMoAcksL() );
       
  1433         }
       
  1434     _DPRINT( 4, "PhSrv.MoAckCallback.end" );
       
  1435     return ETrue;
       
  1436     }
       
  1437 
       
  1438 // -----------------------------------------------------------------------------
       
  1439 // CPhSrvUssdManager::TryCloseSession()
       
  1440 // -----------------------------------------------------------------------------
       
  1441 //
       
  1442 void CPhSrvUssdManager::TryCloseSession() 
       
  1443     {
       
  1444     // Dismiss, cancel the session.
       
  1445     _DPRINT( 4, "PhSrv.CheckAndCloseSession.close" );  // debug print
       
  1446        
       
  1447     iShowDone = EFalse;
       
  1448     iEmptyEditor = EFalse;
       
  1449     
       
  1450     // If the notification array is empty, close the session.
       
  1451     if ( NotifyCount() == 0 && !iNetworkReleased )
       
  1452         {
       
  1453         CloseSession();
       
  1454         }
       
  1455     }
       
  1456 // -----------------------------------------------------------------------------
       
  1457 // CPhSrvUssdManager::CloseSession()
       
  1458 // -----------------------------------------------------------------------------
       
  1459 //
       
  1460 void CPhSrvUssdManager::CloseSession()
       
  1461     {
       
  1462     iSendRelease = ETrue;
       
  1463     iClearArray = EFalse;
       
  1464     iAcksToBeSent = 0;
       
  1465     _DPRINT( 4, "PhSrv.CheckAndCloseSession.canceling" ); 
       
  1466     SendUssdCancel();
       
  1467     Cancel();
       
  1468         
       
  1469     // Terminates USSD session.
       
  1470     if ( !iNetworkReleased ) 
       
  1471         {
       
  1472         iUssdSendHandler->SendReleaseSession();
       
  1473         }
       
  1474     if ( iUssdReplyTimer )
       
  1475         {
       
  1476         _DPRINT( 4, "PhSrv.CheckAndCloseSession.Timer.Stop" );
       
  1477         iUssdReplyTimer->Stop();
       
  1478         }
       
  1479     }
       
  1480  
       
  1481 // -----------------------------------------------------------------------------
       
  1482 // CPhSrvUssdManager::CheckArray()
       
  1483 // -----------------------------------------------------------------------------
       
  1484 //
       
  1485 void CPhSrvUssdManager::CheckArray()
       
  1486 	{
       
  1487 	_DPRINT( 4, "PhSrv.CheckArray.Start" );     // debug print
       
  1488  	if (iNotifyArray  && NotifyCount() > 0)
       
  1489 		{
       
  1490 		if 	( !iNotifyMessage && !iClearArray )
       
  1491 			{
       
  1492 			iLaunchGMQ = ETrue;
       
  1493 			iNotifyMessage = ETrue;
       
  1494 			_DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.ETrue" );
       
  1495 			iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
       
  1496 			_DDPRINT( 4, "PhSrv.CheckArray.SetActive.NoNotifyMessage ", iStatus.Int() );
       
  1497 			SetActive();
       
  1498 			}
       
  1499 		else if( NotifyCount() > 1 )
       
  1500 			{
       
  1501 			( iNotifyArray )->Delete( 0 );
       
  1502 			( iNotifyArray )->Compress();
       
  1503 			iLaunchGMQ = ETrue;
       
  1504 			iNotifyMessage = ETrue;
       
  1505 			_DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.ETrue" );
       
  1506 			iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
       
  1507 			_DDPRINT( 4, "PhSrv.CheckArray.SetActive.NotifyCount>1 ", iStatus.Int() );
       
  1508 			SetActive();
       
  1509 			}
       
  1510  		else
       
  1511      		{
       
  1512 			iNotifyArray->Reset();
       
  1513      		iNotifyMessage = EFalse;
       
  1514      		_DPRINT( 4, "PhSrv.CheckArray.iNotifyMessage.EFalse" );
       
  1515      		}
       
  1516   		}
       
  1517     _DPRINT_FLAGS();
       
  1518   	_DPRINT( 4, "PhSrv.CheckArray.End" );     // debug print
       
  1519  	}
       
  1520 
       
  1521 // -----------------------------------------------------------------------------
       
  1522 // CPhSrvUssdManager::ClearArray()
       
  1523 // -----------------------------------------------------------------------------
       
  1524 //
       
  1525   void CPhSrvUssdManager::ClearArrayL()
       
  1526   	{
       
  1527   	_DPRINT( 4, "PhSrv.ClearArrayL.Start" );     // debug print
       
  1528   	if (iNotifyArray && NotifyCount() > 0)
       
  1529 	  	{
       
  1530 	  	if (iNotifyMessage && NotifyCount()== 1 )
       
  1531 	  		{
       
  1532 	  		iNotifyArray->Reset();
       
  1533 	  		}
       
  1534 	  	else
       
  1535 	  		{
       
  1536 	  		iReceivedMessage.Zero();
       
  1537 	  		HBufC* unreadText = iResourceManager.ReadResourceLC( R_PHSRV_TEXT_UNREAD );
       
  1538 	  		TPtr pMessage( unreadText->Des() );
       
  1539 	  		iReceivedMessage.Append( pMessage );
       
  1540 	  		iNotifyArray->InsertL( 0, iReceivedMessage );
       
  1541 	        CleanupStack::PopAndDestroy( unreadText );
       
  1542 	  		iLaunchGMQ = ETrue;
       
  1543 	  		iNotifyMessage = ETrue;
       
  1544 	  		_DPRINT( 4, "PhSrv.ClearArrayL.iNotifyMessage.ETrue" );
       
  1545 	  		iClearArray = ETrue;
       
  1546 	  		iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
       
  1547 	  		_DDPRINT( 4, "PhSrv.ClearArrayL.iTimer ", iStatus.Int() );
       
  1548 			SetActive();
       
  1549 	  		}
       
  1550 	  	}
       
  1551     _DPRINT_FLAGS();
       
  1552 	_DPRINT( 4, "PhSrv.ClearArrayL.End" );     // debug print
       
  1553   	}
       
  1554 
       
  1555 // -----------------------------------------------------------------------------
       
  1556 // CPhSrvUssdManager::NotifyCount()
       
  1557 // -----------------------------------------------------------------------------
       
  1558 //
       
  1559   TInt CPhSrvUssdManager:: NotifyCount()
       
  1560   {
       
  1561   return iNotifyArray->Count();
       
  1562   }
       
  1563 
       
  1564   // -----------------------------------------------------------------------------
       
  1565 // CPhSrvUssdManager::UpdateNotifyMessage()
       
  1566 // -----------------------------------------------------------------------------
       
  1567 //
       
  1568   void CPhSrvUssdManager:: UpdateNotifyMessage()
       
  1569   	{
       
  1570   	_DDPRINT( 4, "PhSrv.UpdateNotifyMessage.Start, clear: ", iClearArray );     // debug print
       
  1571   	if (NotifyCount() > 1 && !iClearArray )
       
  1572   		{
       
  1573   		_DPRINT( 4, "PhSrv.UpdateNotifyMessage" );     // debug print
       
  1574   		iGlobalMsgQuery->UpdateMsgQuery( R_AVKON_SOFTKEYS_NEXT_EXIT__NEXT );
       
  1575   		}
       
  1576   	_DPRINT( 4, "PhSrv.UpdateNotifyMessage.End" );     // debug print
       
  1577   	}
       
  1578 
       
  1579 // -----------------------------------------------------------------------------
       
  1580 // CPhSrvUssdManager::DoCancel
       
  1581 // -----------------------------------------------------------------------------
       
  1582 //
       
  1583 void CPhSrvUssdManager::DoCancel()
       
  1584     {
       
  1585     _DPRINT( 4, "PhSrv.DoCancel.Start" ); // debug print
       
  1586     iTimer.Cancel();
       
  1587     iLaunchGMQ = EFalse;
       
  1588 
       
  1589     if ( iGlobalMsgQuery )
       
  1590         {
       
  1591         _DPRINT( 4, "PhSrv.DoCancel" ); // debug print
       
  1592         iGlobalMsgQuery->CancelMsgQuery();
       
  1593         }
       
  1594     _DPRINT( 4, "PhSrv.DoCancel.End" ); // debug print
       
  1595     }
       
  1596 
       
  1597 // -----------------------------------------------------------------------------
       
  1598 // CPhSrvUssdManager::RunError
       
  1599 //
       
  1600 // Because the RunL can leave, this function exists.
       
  1601 // In case of error, just returning KErrNone is OK.
       
  1602 // -----------------------------------------------------------------------------
       
  1603 //
       
  1604 TInt CPhSrvUssdManager::RunError( TInt /*aError*/ )
       
  1605     {
       
  1606     _DPRINT( 4, "PhSrv.RunError.Start" );     // debug print
       
  1607     return KErrNone;
       
  1608     }
       
  1609 
       
  1610 // -----------------------------------------------------------------------------
       
  1611 // CPhSrvUssdManager::RequestStartEditingL
       
  1612 // -----------------------------------------------------------------------------
       
  1613 //
       
  1614 void CPhSrvUssdManager::RequestStartEditingL()
       
  1615     {
       
  1616     _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.start" ); // debug print
       
  1617 
       
  1618     RWsSession wsSession;
       
  1619     User::LeaveIfError( wsSession.Connect() );
       
  1620     _DPRINT( 4, "PhSrv.RequestStartEditingL.wsSession.connect" );     // debug print
       
  1621     CleanupClosePushL( wsSession );
       
  1622 
       
  1623     // Find the task with name
       
  1624     TApaTaskList tasklist( wsSession );
       
  1625     TApaTask task = tasklist.FindApp( TUid::Uid( KPhSrvUssdAppUID ) );
       
  1626 
       
  1627     // If task exists, bring it to foreground
       
  1628     if ( task.Exists() )
       
  1629         {
       
  1630         _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.task.BringToForeground" );
       
  1631         task.BringToForeground();
       
  1632         }
       
  1633     else
       
  1634         {
       
  1635         // Start new app
       
  1636         RApaLsSession apaLsSession;
       
  1637         User::LeaveIfError( apaLsSession.Connect() );
       
  1638         _DPRINT( 4, "PhSrv.RequestStartEditingL.apaLsSession.connect" );     // debug print
       
  1639         CleanupClosePushL( apaLsSession );
       
  1640 
       
  1641         TApaAppInfo appInfo;
       
  1642         TInt err = apaLsSession.GetAppInfo(
       
  1643             appInfo,
       
  1644             TUid::Uid( KPhSrvUssdAppUID )  );
       
  1645         if ( err == KErrNone )
       
  1646             {
       
  1647             _DDPRINT( 4, "PhSrv.RequestStartEditingL.GetAppInfo ", err );     // debug print
       
  1648 
       
  1649         #ifndef SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
       
  1650             CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
       
  1651             apaCommandLine->SetExecutableNameL( appInfo.iFullName );
       
  1652         #else // SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
       
  1653             CApaCommandLine* apaCommandLine =
       
  1654                 CApaCommandLine::NewLC( appInfo.iFullName );
       
  1655         #endif // SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1
       
  1656 
       
  1657             err = apaLsSession.StartApp( *apaCommandLine );
       
  1658             CleanupStack::PopAndDestroy( apaCommandLine );
       
  1659             }
       
  1660         CleanupStack::PopAndDestroy(); // apaLsSession
       
  1661         }
       
  1662     CleanupStack::PopAndDestroy(); // wsSession
       
  1663 
       
  1664     _DPRINT( 4, "PhSrv.UssdM.RequestStartEditingL.end" ); // debug print
       
  1665     }
       
  1666 
       
  1667 
       
  1668 // -----------------------------------------------------------------------------
       
  1669 // CPhSrvUssdManager::InformUssdApplicationStarting
       
  1670 // -----------------------------------------------------------------------------
       
  1671 //
       
  1672 void CPhSrvUssdManager::InformUssdApplicationStarting()
       
  1673     {
       
  1674     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppStarting.start" ); // debug print
       
  1675     if ( iUssdReplyTimer )
       
  1676         {
       
  1677         _DPRINT( 4, "PhSrv.InformUssdApplicationStarting.iUssdReplyTimer" );
       
  1678         if ( iUssdReplyTimer->IsTimerActive() )
       
  1679             {
       
  1680             _DPRINT( 4, "PhSrv.InformUssdApplicationStarting.iUssdReplyTimer.active" );
       
  1681             iUssdReplyTimer->Pause();
       
  1682             }
       
  1683         }
       
  1684     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppStarting.end" ); // debug print
       
  1685     }
       
  1686 
       
  1687 // -----------------------------------------------------------------------------
       
  1688 // CPhSrvUssdManager::InformUssdApplicationTerminatingL
       
  1689 // -----------------------------------------------------------------------------
       
  1690 //
       
  1691 void CPhSrvUssdManager::InformUssdApplicationTerminatingL(
       
  1692     const RMessage2& aMessage )
       
  1693     {
       
  1694     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.start" ); // debug print
       
  1695     if ( iUssdReplyTimer )
       
  1696         {
       
  1697         if ( iUssdReplyTimer->IsTimerActive() )
       
  1698             {
       
  1699             // debug print
       
  1700             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer" );
       
  1701 
       
  1702             // Read the information what is the reason
       
  1703             // for application termination.
       
  1704             TPhCltUssdAppExitReason exitReason = EPhCltExitReasonUnknown;
       
  1705             TPckg< TPhCltUssdAppExitReason > exitReasonPckg( exitReason );
       
  1706             aMessage.ReadL(
       
  1707                 0,
       
  1708                 exitReasonPckg );
       
  1709 
       
  1710             // debug print
       
  1711             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.timer2" );
       
  1712 
       
  1713             // If reason was the completion of send operation, the USSD
       
  1714             // session is not canceled, otherwise it is canceled.
       
  1715             if ( exitReason != EPhCltSendCompleted )
       
  1716                 {
       
  1717                 // debug print
       
  1718                 _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.SendRelease" );
       
  1719                 CloseSession();
       
  1720                 }
       
  1721             }
       
  1722         }
       
  1723     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppTerminatingL.end" ); // debug print
       
  1724     }
       
  1725 
       
  1726 
       
  1727 // -----------------------------------------------------------------------------
       
  1728 // CPhSrvUssdManager::InformUssdApplicationToForeground
       
  1729 // -----------------------------------------------------------------------------
       
  1730 //
       
  1731 TInt CPhSrvUssdManager::InformUssdApplicationToForeground()
       
  1732     {
       
  1733     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppToForeground.start" ); // debug print
       
  1734 
       
  1735     // Do the same actions as in InformUssdApplicationStarting,
       
  1736     // that is why it is called.
       
  1737     InformUssdApplicationStarting();
       
  1738 
       
  1739     if ( iEmptyEditor )
       
  1740         {
       
  1741         _DPRINT( 4, "PhSrv.UssdM.InfUssdAppToForeground.empty" ); // debug print
       
  1742         iEmptyEditor = EFalse;
       
  1743         return 1; // some positive number
       
  1744         }
       
  1745     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppToForeground.end" ); // debug print
       
  1746     return KErrNone;
       
  1747     }
       
  1748 
       
  1749 
       
  1750 // -----------------------------------------------------------------------------
       
  1751 // CPhSrvUssdManager::InformUssdApplicationToBackground
       
  1752 // -----------------------------------------------------------------------------
       
  1753 //
       
  1754 void CPhSrvUssdManager::InformUssdApplicationToBackground()
       
  1755     {
       
  1756     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppToBackground.start" ); // debug print
       
  1757     if ( iUssdReplyTimer )
       
  1758         {
       
  1759         _DPRINT( 4, "PhSrv.UssdM.InfUssdAppToBackground.timer" ); // debug print
       
  1760         if ( iUssdReplyTimer->IsTimerActive() )
       
  1761             {
       
  1762             _DPRINT( 4, "PhSrv.UssdM.InfUssdAppToBackground.timer.Active" ); // debug print
       
  1763             iUssdReplyTimer->Continue();
       
  1764             }
       
  1765         }
       
  1766     _DPRINT( 4, "PhSrv.UssdM.InfUssdAppToBackground.end" ); // debug print
       
  1767     }
       
  1768 
       
  1769 
       
  1770 // -----------------------------------------------------------------------------
       
  1771 // CPhSrvUssdManager::InformStartSAT
       
  1772 // -----------------------------------------------------------------------------
       
  1773 //
       
  1774 void CPhSrvUssdManager::InformStartSAT( const RMessage2& aSatMessage )
       
  1775     {
       
  1776     _DPRINT( 4, "PhSrv.InformStartSAT.Start" );    // debug print
       
  1777 
       
  1778     if ( iHavePendingSatMessagePointer )
       
  1779         {
       
  1780         _DPRINT( 4, "PhSrv.InformStartSAT.Complete.InUse" ); // debug print
       
  1781         aSatMessage.Complete( KErrInUse );
       
  1782         }
       
  1783     else
       
  1784         {
       
  1785         _DPRINT( 4, "PhSrv.InformStartSAT.Set" );           // debug print
       
  1786 
       
  1787         // There was not pending SAT message
       
  1788         iHavePendingSatMessagePointer = ETrue;
       
  1789         _DDPRINT( 4, "PhSrv.UssdM.InformStartSAT.PendingSatPointer ", iHavePendingSatMessagePointer );
       
  1790         iPendingSatMessagePointer = aSatMessage;
       
  1791         }
       
  1792 
       
  1793     _DPRINT( 4, "PhSrv.InformStartSAT.End" );   // debug print
       
  1794     }
       
  1795 
       
  1796 
       
  1797 // -----------------------------------------------------------------------------
       
  1798 // CPhSrvUssdManager::InformStopSAT
       
  1799 // -----------------------------------------------------------------------------
       
  1800 //
       
  1801 void CPhSrvUssdManager::InformStopSAT()
       
  1802     {
       
  1803     _DPRINT( 4, "PhSrv.InformStopSAT.Start" );               // debug print
       
  1804 
       
  1805     // Do the actions only if there is pending SAT message.
       
  1806     if ( iHavePendingSatMessagePointer )
       
  1807         {
       
  1808         _DPRINT( 4, "PhSrv.InformStopSAT.Complete.Cancel" ); // debug print
       
  1809         if ( !iPendingSatMessagePointer.IsNull() )
       
  1810             {
       
  1811             iPendingSatMessagePointer.Complete( KErrCancel );
       
  1812             _DPRINT( 4, "PhSrv.InformStopSAT.Complete.KErrCancel" );
       
  1813             }
       
  1814         iHavePendingSatMessagePointer = EFalse;
       
  1815         }
       
  1816     _DPRINT( 4, "PhSrv.InformStopSAT.End" );                 // debug print
       
  1817     }
       
  1818 
       
  1819 // -----------------------------------------------------------------------------
       
  1820 // CPhSrvUssdManager::ShowNotes
       
  1821 // -----------------------------------------------------------------------------
       
  1822 //
       
  1823 
       
  1824 
       
  1825 TBool CPhSrvUssdManager::ShowNotesL()
       
  1826 {
       
  1827 _DPRINT( 4, "PhSrv.ShowNotesL.Start" );
       
  1828 
       
  1829 if ( !iHavePendingSatMessagePointer )
       
  1830     {
       
  1831     if ( iSatCanceled )
       
  1832         {
       
  1833         _DPRINT( 4, "PhSrv.ShowNotesL, EFalse" );  // debug print
       
  1834         return EFalse;
       
  1835         }
       
  1836     else
       
  1837         {
       
  1838         _DPRINT( 4, "PhSrv.ShowNotesL, ETrue" );  // debug print
       
  1839         return ETrue;
       
  1840         }
       
  1841     }
       
  1842 // Read the information whether the notes are shown or not.
       
  1843     TUint notesShown = 0;
       
  1844     TPckg< TUint > noShPckg( notesShown );
       
  1845     iPendingSatMessagePointer.ReadL(
       
  1846         0,
       
  1847         noShPckg );
       
  1848 
       
  1849     TBool showNotes = EFalse;
       
  1850     _DPRINT( 4, "PhSrv.ShowNotes Sat= EFalse" );    // debug print
       
  1851     if ( notesShown == KPhCltShowNotes )
       
  1852         {
       
  1853         _DPRINT( 4, "PhSrv.ShowNotes Sat= ETrue" ); // debug print
       
  1854         showNotes = ETrue;
       
  1855         }
       
  1856     _DPRINT( 4, "PhSrv.ShowNotesL.End" );
       
  1857     return showNotes;
       
  1858 }
       
  1859 
       
  1860 // -----------------------------------------------------------------------------
       
  1861 // CPhSrvUssdManager::CompleteSatL
       
  1862 // -----------------------------------------------------------------------------
       
  1863 //
       
  1864 void CPhSrvUssdManager::CompleteSatL(
       
  1865     TDesC* aReceiveString,
       
  1866     TInt aError )
       
  1867     {
       
  1868     _DPRINT( 4, "PhSrv.CompleteSatL.Start" );                // debug print
       
  1869     if ( aReceiveString )
       
  1870         {
       
  1871         if ( aReceiveString->Length() )
       
  1872             {
       
  1873             _DPRINT( 4, "PhSrv.CompleteSatL.recString.>0" ); // debug print
       
  1874             // copy the received string to client side.
       
  1875             if ( iPendingSatMessagePointer.Int1() < aReceiveString->Length() )
       
  1876                 {
       
  1877                 // debug print
       
  1878                 _DPRINT( 4, "PhSrv.CompleteSatL.recString.LengthError" );
       
  1879                 if ( !iPendingSatMessagePointer.IsNull() )
       
  1880                     {
       
  1881                     iPendingSatMessagePointer.Complete( KErrOverflow );
       
  1882                     _DPRINT( 4, "PhSrv.CompleteSatLComplete.KErrOverFlow" );
       
  1883                     }
       
  1884                 iHavePendingSatMessagePointer = EFalse;
       
  1885                 }
       
  1886 			else
       
  1887 				{
       
  1888             _DPRINT( 4, "PhSrv.CompleteSatL.recString.Write" );  // debug print
       
  1889             iPendingSatMessagePointer.WriteL(
       
  1890                 2,
       
  1891                 *aReceiveString );
       
  1892 
       
  1893             _DPRINT( 4, "PhSrv.CompleteSatL.recString.Write2" ); // debug print
       
  1894             TPckg< TUint > dcsPackage( iDCS );
       
  1895             iPendingSatMessagePointer.WriteL(
       
  1896                 0,
       
  1897                 dcsPackage );
       
  1898             }
       
  1899         }
       
  1900         }
       
  1901     _DPRINT( 4, "PhSrv.CompleteSatL.Middle" );           // debug print
       
  1902     if ( !iPendingSatMessagePointer.IsNull() )
       
  1903         {
       
  1904         if ( aReceiveString && !iSatCanceled )
       
  1905             {
       
  1906             _DDPRINT( 4, "PhSrv.CompleteSatL.Complete.", iReturnResult.iOpCode  );   // debug print
       
  1907             iPendingSatMessagePointer.Complete( iReturnResult.iOpCode ); // Some positive value
       
  1908             }
       
  1909         else
       
  1910             {
       
  1911             _DPRINT( 4, "PhSrv.CompleteSatL.Complete.aError" ); // debug print
       
  1912             iPendingSatMessagePointer.Complete( aError );
       
  1913             }
       
  1914         }
       
  1915 
       
  1916     iHavePendingSatMessagePointer = EFalse;
       
  1917 
       
  1918     _DPRINT( 4, "PhSrv.CompleteSatL.End" );           // debug print
       
  1919     }
       
  1920 
       
  1921 
       
  1922 // -----------------------------------------------------------------------------
       
  1923 // CPhSrvUssdManager::IsTelephonyFeatureSupported
       
  1924 //
       
  1925 // -----------------------------------------------------------------------------
       
  1926 //
       
  1927 TBool CPhSrvUssdManager::IsTelephonyFeatureSupported(
       
  1928     const TInt aFeatureId )
       
  1929     {
       
  1930 	return ( aFeatureId & iVariantReadOnlyValues );
       
  1931     }
       
  1932 
       
  1933 
       
  1934 // -----------------------------------------------------------------------------
       
  1935 // CPhSrvUssdManager::PlayUssdTone
       
  1936 //
       
  1937 // -----------------------------------------------------------------------------
       
  1938 //
       
  1939 TInt CPhSrvUssdManager::PlayUssdTone()
       
  1940     {
       
  1941     _DPRINT( 4, "PhSrv.UssdM.PlayTone.start" );           // debug print
       
  1942 
       
  1943     TInt err = KErrNone;
       
  1944 
       
  1945     RProperty::Define( KPSUidNcnList, KNcnPlayAlertTone, RProperty::EInt, ECapability_None , ECapabilityWriteDeviceData );
       
  1946     RProperty::Set( KPSUidNcnList, KNcnPlayAlertTone, KPhSrvUssdTone );
       
  1947 
       
  1948     // debug print
       
  1949     _DDPRINT(
       
  1950         4,
       
  1951         "PhSrv.UssdM.PlayTone.end",
       
  1952         err );
       
  1953     return err;
       
  1954     }
       
  1955 
       
  1956 // -----------------------------------------------------------------------------
       
  1957 // CPhSrvUssdManager::GetTelephonyVariantData
       
  1958 //
       
  1959 // -----------------------------------------------------------------------------
       
  1960 //
       
  1961 TInt CPhSrvUssdManager::GetTelephonyVariantData()
       
  1962     {
       
  1963     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.Start" );
       
  1964     TInt err = KErrNone;
       
  1965 
       
  1966     // Variation data should be unchangable during run-time,
       
  1967     // therefore, if once succesfully read, later reads are
       
  1968     // not allowed.
       
  1969     if ( iVariantReadOnlyValues == KPhSrvDefaultValue )
       
  1970         {
       
  1971         CRepository* cenRepSession = NULL;
       
  1972         TRAP ( err ,
       
  1973                cenRepSession = CRepository::NewL( KCRUidTelVariation ) );
       
  1974         if ( err == KErrNone )
       
  1975             {
       
  1976             err = cenRepSession->Get( KTelVariationFlags,
       
  1977                                    iVariantReadOnlyValues );
       
  1978             }
       
  1979         delete cenRepSession;
       
  1980         }
       
  1981 
       
  1982     _DDPRINT( 4, "PhSrv.UssdM.variant", iVariantReadOnlyValues ); // debug print
       
  1983     _DPRINT( 4, "PhSrv.UssdM.GetTelephonyVariantData.End" );
       
  1984     return err;
       
  1985     }
       
  1986 
       
  1987 
       
  1988 // -----------------------------------------------------------------------------
       
  1989 // CPhSrvUssdManager::SendMoAcknowledgementL
       
  1990 //
       
  1991 // -----------------------------------------------------------------------------
       
  1992 //
       
  1993 void CPhSrvUssdManager::SendMoAcknowledgementL()
       
  1994     {
       
  1995     _DPRINT( 4, "PhSrv.SendMoAckL.Start" );           // debug print
       
  1996 
       
  1997     // Acknowledge MT USSD message.
       
  1998     RMobileUssdMessaging::TMobileUssdAttributesV1 msgAttribs;
       
  1999     msgAttribs.iFlags =
       
  2000         RMobileUssdMessaging::KUssdMessageType +
       
  2001         RMobileUssdMessaging::KUssdDataFormat  +
       
  2002         RMobileUssdMessaging::KUssdMessageDcs;
       
  2003 
       
  2004     msgAttribs.iType   = RMobileUssdMessaging::EUssdMOAcknowledgement;
       
  2005     _DDPRINT( 4, "PhSrv.SendMoAckL.msgAttribs.iType ", msgAttribs.iType );
       
  2006     msgAttribs.iFormat = RMobileUssdMessaging::EFormatUnspecified;
       
  2007     _DDPRINT( 4, "PhSrv.SendMoAckL.msgAttribs.iFormat ", msgAttribs.iFormat );
       
  2008     msgAttribs.iDcs    = KPhSrvUssdDefaultDCS;
       
  2009 
       
  2010     RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attribs = msgAttribs;
       
  2011     SendHandlerL().SendUssdL( KNullDesC8() , attribs );
       
  2012 
       
  2013     _DPRINT( 4, "PhSrv.SendMoAckL.End" );           // debug print
       
  2014     }
       
  2015 
       
  2016 // -----------------------------------------------------------------------------
       
  2017 // CPhSrvUssdManager::TurnLightsOn
       
  2018 //
       
  2019 // -----------------------------------------------------------------------------
       
  2020 //
       
  2021 void CPhSrvUssdManager::TurnLightsOn()
       
  2022     {
       
  2023      _DPRINT( 4, "PhSrv.TurnLightsOn Start" );           // debug print
       
  2024 
       
  2025 
       
  2026          // Change the bit on and off. SysAp will detect that
       
  2027      // the lights should be switched on for the specified time.
       
  2028      //
       
  2029          RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn);
       
  2030          TInt err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOff);
       
  2031 
       
  2032          if ( err != KErrNone )
       
  2033                  {
       
  2034                  _DDPRINT( 4,"PhSrv.TurnLightsOn.Error: ",err );// debug print
       
  2035                  }
       
  2036 
       
  2037      _DPRINT( 4, "PhSrv.TurnLightsOn.End" );           // debug print
       
  2038     }
       
  2039 // End of File