phoneclientserver/phoneserver/src/ussd/cphsrvussdsendhandler.cpp
author hgs
Fri, 23 Jul 2010 12:32:49 +0300 (2010-07-23)
changeset 35 6aefa3341fcc
parent 33 8d5d7fcf9b59
permissions -rw-r--r--
201029
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2002-2005 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 Handler Send.
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
hgs
parents:
diff changeset
    19
// INCLUDE FILES
hgs
parents:
diff changeset
    20
#include "cphsrvussdsendhandler.h" 
hgs
parents:
diff changeset
    21
#include "mphsrvussdnetworkobserver.h" 
hgs
parents:
diff changeset
    22
#include "mphsrvphoneinterface.h" 
hgs
parents:
diff changeset
    23
#include "cphsrvussdsessioncancelwaiter.h" 
hgs
parents:
diff changeset
    24
#include "phsrvdebuginfo.h" //debug prints 
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
#include <gsmuelem.h>
hgs
parents:
diff changeset
    27
#include <f32file.h>
hgs
parents:
diff changeset
    28
#include <rmmcustomapi.h>
hgs
parents:
diff changeset
    29
hgs
parents:
diff changeset
    30
//CONSTANTS
hgs
parents:
diff changeset
    31
const TInt KPhSrvUssdSenderPriority = CActive::EPriorityLow + 1;
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
// ============================ MEMBER FUNCTIONS ===============================
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    36
// CPhSrvUssdSendHandler::CPhSrvUssdSendHandler
hgs
parents:
diff changeset
    37
//
hgs
parents:
diff changeset
    38
// Constructor
hgs
parents:
diff changeset
    39
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    40
//
hgs
parents:
diff changeset
    41
/*****************************************************
hgs
parents:
diff changeset
    42
*   Series 60 Customer / ETel
hgs
parents:
diff changeset
    43
*   Series 60  ETel API
hgs
parents:
diff changeset
    44
*****************************************************/
hgs
parents:
diff changeset
    45
CPhSrvUssdSendHandler::CPhSrvUssdSendHandler(
hgs
parents:
diff changeset
    46
    MPhSrvUssdNetworkObserver& aObserver,
hgs
parents:
diff changeset
    47
    RMobileUssdMessaging& aUssdMessaging,
hgs
parents:
diff changeset
    48
    MPhSrvPhoneInterface& aPhoneInterface )
hgs
parents:
diff changeset
    49
    :    CActive( KPhSrvUssdSenderPriority ),
hgs
parents:
diff changeset
    50
         iObserver( aObserver ),
hgs
parents:
diff changeset
    51
         iUssdMessaging( aUssdMessaging ),
hgs
parents:
diff changeset
    52
         iPhoneInterface( aPhoneInterface )
hgs
parents:
diff changeset
    53
    {
hgs
parents:
diff changeset
    54
    CActiveScheduler::Add( this );
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
    // R&D SOLUTION ->
hgs
parents:
diff changeset
    57
    iSessionCancelWaiter = new CPhSrvUssdSessionCancelWaiter;
hgs
parents:
diff changeset
    58
    __ASSERT_ALWAYS( iSessionCancelWaiter, User::Invariant() );
hgs
parents:
diff changeset
    59
    // <-
hgs
parents:
diff changeset
    60
    }
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
hgs
parents:
diff changeset
    63
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    64
// CPhSrvUssdSendHandler::~CPhSrvUssdSendHandler
hgs
parents:
diff changeset
    65
//
hgs
parents:
diff changeset
    66
// Destructor
hgs
parents:
diff changeset
    67
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    68
//
hgs
parents:
diff changeset
    69
CPhSrvUssdSendHandler::~CPhSrvUssdSendHandler()
hgs
parents:
diff changeset
    70
    {
hgs
parents:
diff changeset
    71
    _DPRINT( 4, "PhSrv.Sendhandler.Destructor.Start" );           // debug print
hgs
parents:
diff changeset
    72
    Cancel();
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
    // R&D solution ->
hgs
parents:
diff changeset
    75
    if ( iSessionCancelWaiter )
hgs
parents:
diff changeset
    76
        {
hgs
parents:
diff changeset
    77
        if ( iSessionCancelWaiter->IsActive() )
hgs
parents:
diff changeset
    78
            {
hgs
parents:
diff changeset
    79
            _DPRINT( 4, "PhSrv.Sendhandler.Destructor.IsActive.SendRelease" );
hgs
parents:
diff changeset
    80
            iUssdMessaging.CancelAsyncRequest( EMobileUssdMessagingSendRelease );
hgs
parents:
diff changeset
    81
            }
hgs
parents:
diff changeset
    82
        delete iSessionCancelWaiter;
hgs
parents:
diff changeset
    83
        iSessionCancelWaiter = NULL;
hgs
parents:
diff changeset
    84
        }
hgs
parents:
diff changeset
    85
    // <-
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
    delete iMsgData;
hgs
parents:
diff changeset
    88
    iMsgData = NULL;
hgs
parents:
diff changeset
    89
hgs
parents:
diff changeset
    90
    delete iMsgAttribute;
hgs
parents:
diff changeset
    91
    iMsgAttribute = NULL;
hgs
parents:
diff changeset
    92
     _DPRINT( 4, "PhSrv.Sendhandler.Destructor.End" );           // debug print
hgs
parents:
diff changeset
    93
    }
hgs
parents:
diff changeset
    94
hgs
parents:
diff changeset
    95
hgs
parents:
diff changeset
    96
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    97
// CPhSrvUssdSendHandler::SendUssdL
hgs
parents:
diff changeset
    98
//
hgs
parents:
diff changeset
    99
// Send the USSD data.
hgs
parents:
diff changeset
   100
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   101
//
hgs
parents:
diff changeset
   102
void CPhSrvUssdSendHandler::SendUssdL(
hgs
parents:
diff changeset
   103
            const TDesC8& aMsgData,
hgs
parents:
diff changeset
   104
            const TDesC8& aMsgAttribute )
hgs
parents:
diff changeset
   105
    {
hgs
parents:
diff changeset
   106
    _DPRINT( 4, "PhSrv.Sendhandler.SendUssd.Start" );           // debug print
hgs
parents:
diff changeset
   107
    // R&D SOLUTION ->
hgs
parents:
diff changeset
   108
    
hgs
parents:
diff changeset
   109
    // If cancel is going on, don't try to send anything.
hgs
parents:
diff changeset
   110
    if ( IsActive() || iSessionCancelWaiter->IsActive() )
hgs
parents:
diff changeset
   111
        {
hgs
parents:
diff changeset
   112
        _DPRINT( 4, "PhSrv.Sendhandler.SendUssd.KErrInUse" );    // debug print
hgs
parents:
diff changeset
   113
        User::Leave( KErrInUse );
hgs
parents:
diff changeset
   114
        }
hgs
parents:
diff changeset
   115
    // <-
hgs
parents:
diff changeset
   116
hgs
parents:
diff changeset
   117
    delete iMsgData;
hgs
parents:
diff changeset
   118
    iMsgData = NULL;
hgs
parents:
diff changeset
   119
    iMsgData = aMsgData.AllocL();
hgs
parents:
diff changeset
   120
hgs
parents:
diff changeset
   121
    delete iMsgAttribute;
hgs
parents:
diff changeset
   122
    iMsgAttribute = NULL;
hgs
parents:
diff changeset
   123
    iMsgAttribute = aMsgAttribute.AllocL();
hgs
parents:
diff changeset
   124
    iUssdMessaging.SendMessage( iStatus , *iMsgData , *iMsgAttribute );
hgs
parents:
diff changeset
   125
    SetActive();
hgs
parents:
diff changeset
   126
    _DPRINT( 4, "PhSrv.Sendhandler.SendUssd.End" );           // debug print
hgs
parents:
diff changeset
   127
    }
hgs
parents:
diff changeset
   128
hgs
parents:
diff changeset
   129
hgs
parents:
diff changeset
   130
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   131
// CPhSrvUssdSendHandler::SendUssdCancel
hgs
parents:
diff changeset
   132
//
hgs
parents:
diff changeset
   133
// Cancel USSD sending.
hgs
parents:
diff changeset
   134
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   135
//
hgs
parents:
diff changeset
   136
/*****************************************************
hgs
parents:
diff changeset
   137
*   Series 60 Customer / ETel
hgs
parents:
diff changeset
   138
*   Series 60  ETel API
hgs
parents:
diff changeset
   139
*****************************************************/
hgs
parents:
diff changeset
   140
void CPhSrvUssdSendHandler::SendUssdCancel()
hgs
parents:
diff changeset
   141
    {
hgs
parents:
diff changeset
   142
    _DPRINT( 4, "PhSrv.Sendhandler.SendUssdCancel.Start" );         // debug print
hgs
parents:
diff changeset
   143
    Cancel();
hgs
parents:
diff changeset
   144
     _DPRINT( 4, "PhSrv.Sendhandler.SendUssdCancel.End" );           // debug print
hgs
parents:
diff changeset
   145
    }
hgs
parents:
diff changeset
   146
hgs
parents:
diff changeset
   147
hgs
parents:
diff changeset
   148
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   149
// CPhSrvUssdSendHandler::DoCancel
hgs
parents:
diff changeset
   150
//
hgs
parents:
diff changeset
   151
// Cancel request.
hgs
parents:
diff changeset
   152
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   153
//
hgs
parents:
diff changeset
   154
/*****************************************************
hgs
parents:
diff changeset
   155
*   Series 60 Customer / ETel
hgs
parents:
diff changeset
   156
*   Series 60  ETel API
hgs
parents:
diff changeset
   157
*****************************************************/
hgs
parents:
diff changeset
   158
void CPhSrvUssdSendHandler::DoCancel()
hgs
parents:
diff changeset
   159
    {
hgs
parents:
diff changeset
   160
    _DDPRINT( 4, "PhSrv.Sendhandler.DoCancel.Start", iStatus.Int() );           // debug print
hgs
parents:
diff changeset
   161
hgs
parents:
diff changeset
   162
    iUssdMessaging.CancelAsyncRequest( EMobileUssdMessagingSendMessage );
hgs
parents:
diff changeset
   163
    delete iMsgData;
hgs
parents:
diff changeset
   164
    iMsgData = NULL;
hgs
parents:
diff changeset
   165
    delete iMsgAttribute;
hgs
parents:
diff changeset
   166
    iMsgAttribute = NULL;
hgs
parents:
diff changeset
   167
    _DDPRINT( 4, "PhSrv.Sendhandler.DoCancel.End", iStatus.Int() );           // debug print
hgs
parents:
diff changeset
   168
    }
hgs
parents:
diff changeset
   169
hgs
parents:
diff changeset
   170
hgs
parents:
diff changeset
   171
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   172
// CPhSrvUssdSendHandler::RunL
hgs
parents:
diff changeset
   173
//
hgs
parents:
diff changeset
   174
// When iStatusRequest is changed.
hgs
parents:
diff changeset
   175
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   176
//
hgs
parents:
diff changeset
   177
void CPhSrvUssdSendHandler::RunL()
hgs
parents:
diff changeset
   178
    {
hgs
parents:
diff changeset
   179
    _DDPRINT( 4, "PhSrv.SendHandler.RunL.Start", iStatus.Int() );
hgs
parents:
diff changeset
   180
    iObserver.UssdNetworkObserverHandleSendEventL( iStatus.Int() );
hgs
parents:
diff changeset
   181
    _DPRINT( 4, "PhSrv.Sendhandler.RunL.End" );
hgs
parents:
diff changeset
   182
    }
hgs
parents:
diff changeset
   183
hgs
parents:
diff changeset
   184
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   185
// CPhSrvUssdSendHandler::SendReleaseSession
hgs
parents:
diff changeset
   186
//
hgs
parents:
diff changeset
   187
// Terminates Ussd session.
hgs
parents:
diff changeset
   188
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   189
//
hgs
parents:
diff changeset
   190
void CPhSrvUssdSendHandler::SendReleaseSession()
hgs
parents:
diff changeset
   191
    {
hgs
parents:
diff changeset
   192
    _DPRINT( 4, "PhSrv.Sendhandler.SendReleaseSession.Start" );         // debug print
hgs
parents:
diff changeset
   193
    if ( !iSessionCancelWaiter->IsActive() )
hgs
parents:
diff changeset
   194
        {
hgs
parents:
diff changeset
   195
        _DPRINT( 4, "PhSrv.Sendhandler.SendReleaseSession" );           // debug print
hgs
parents:
diff changeset
   196
        iUssdMessaging.SendRelease(
hgs
parents:
diff changeset
   197
            iSessionCancelWaiter->iStatus,
hgs
parents:
diff changeset
   198
            iSessionCancelWaiter->iSSRequestPckg );
hgs
parents:
diff changeset
   199
        _DPRINT( 4, "PhSrv.Sendhandler.SendReleaseSession2" ); 
hgs
parents:
diff changeset
   200
        iSessionCancelWaiter->SetActive();
hgs
parents:
diff changeset
   201
        _DDPRINT( 4, "PhSrv.Sendhandler.SRS.iUssdMessaging", iStatus.Int() );
hgs
parents:
diff changeset
   202
        }
hgs
parents:
diff changeset
   203
    _DPRINT( 4, "PhSrv.Sendhandler.SendReleaseSession.End" );           // debug print
hgs
parents:
diff changeset
   204
    }
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206
//  End of File