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