phoneclientserver/phoneserver/Src/Ussd/CPhSrvUssdSendHandler.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Ussd Handler Send.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CPhSrvUssdSendHandler.h"
       
    21 #include "MPhSrvUssdNetworkObserver.h"
       
    22 #include "MPhSrvPhoneInterface.h"
       
    23 #include "CPhSrvUssdSessionCancelWaiter.h"
       
    24 #include "PhSrvDebugInfo.h" //debug prints
       
    25 
       
    26 #include <gsmuelem.h>
       
    27 #include <f32file.h>
       
    28 #include <rmmcustomapi.h>
       
    29 
       
    30 //CONSTANTS
       
    31 const TInt KPhSrvUssdSenderPriority = CActive::EPriorityLow + 1;
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CPhSrvUssdSendHandler::CPhSrvUssdSendHandler
       
    37 //
       
    38 // Constructor
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 /*****************************************************
       
    42 *   Series 60 Customer / ETel
       
    43 *   Series 60  ETel API
       
    44 *****************************************************/
       
    45 CPhSrvUssdSendHandler::CPhSrvUssdSendHandler(
       
    46     MPhSrvUssdNetworkObserver& aObserver,
       
    47     RMobileUssdMessaging& aUssdMessaging,
       
    48     MPhSrvPhoneInterface& aPhoneInterface )
       
    49     :    CActive( KPhSrvUssdSenderPriority ),
       
    50          iObserver( aObserver ),
       
    51          iUssdMessaging( aUssdMessaging ),
       
    52          iPhoneInterface( aPhoneInterface )
       
    53     {
       
    54     CActiveScheduler::Add( this );
       
    55 
       
    56     // R&D SOLUTION ->
       
    57     iSessionCancelWaiter = new CPhSrvUssdSessionCancelWaiter;
       
    58     __ASSERT_ALWAYS( iSessionCancelWaiter, User::Invariant() );
       
    59     // <-
       
    60     }
       
    61 
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CPhSrvUssdSendHandler::~CPhSrvUssdSendHandler
       
    65 //
       
    66 // Destructor
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CPhSrvUssdSendHandler::~CPhSrvUssdSendHandler()
       
    70     {
       
    71     _DPRINT( 4, "PhSrv.Sendhandler.Destructor.Start" );           // debug print
       
    72     Cancel();
       
    73 
       
    74     // R&D solution ->
       
    75     if ( iSessionCancelWaiter )
       
    76         {
       
    77         if ( iSessionCancelWaiter->IsActive() )
       
    78             {
       
    79             _DPRINT( 4, "PhSrv.Sendhandler.Destructor.IsActive.SendRelease" );
       
    80             iUssdMessaging.CancelAsyncRequest( EMobileUssdMessagingSendRelease );
       
    81             }
       
    82         delete iSessionCancelWaiter;
       
    83         iSessionCancelWaiter = NULL;
       
    84         }
       
    85     // <-
       
    86 
       
    87     delete iMsgData;
       
    88     iMsgData = NULL;
       
    89 
       
    90     delete iMsgAttribute;
       
    91     iMsgAttribute = NULL;
       
    92      _DPRINT( 4, "PhSrv.Sendhandler.Destructor.End" );           // debug print
       
    93     }
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CPhSrvUssdSendHandler::SendUssdL
       
    98 //
       
    99 // Send the USSD data.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CPhSrvUssdSendHandler::SendUssdL(
       
   103             const TDesC8& aMsgData,
       
   104             const TDesC8& aMsgAttribute )
       
   105     {
       
   106     _DPRINT( 4, "PhSrv.Sendhandler.SendUssd.Start" );           // debug print
       
   107     // R&D SOLUTION ->
       
   108     
       
   109     // If cancel is going on, don't try to send anything.
       
   110     if ( IsActive() || iSessionCancelWaiter->IsActive() )
       
   111         {
       
   112         _DPRINT( 4, "PhSrv.Sendhandler.SendUssd.KErrInUse" );    // debug print
       
   113         User::Leave( KErrInUse );
       
   114         }
       
   115     // <-
       
   116 
       
   117     delete iMsgData;
       
   118     iMsgData = NULL;
       
   119     iMsgData = aMsgData.AllocL();
       
   120 
       
   121     delete iMsgAttribute;
       
   122     iMsgAttribute = NULL;
       
   123     iMsgAttribute = aMsgAttribute.AllocL();
       
   124     iUssdMessaging.SendMessage( iStatus , *iMsgData , *iMsgAttribute );
       
   125     SetActive();
       
   126     _DPRINT( 4, "PhSrv.Sendhandler.SendUssd.End" );           // debug print
       
   127     }
       
   128 
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CPhSrvUssdSendHandler::SendUssdCancel
       
   132 //
       
   133 // Cancel USSD sending.
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 /*****************************************************
       
   137 *   Series 60 Customer / ETel
       
   138 *   Series 60  ETel API
       
   139 *****************************************************/
       
   140 void CPhSrvUssdSendHandler::SendUssdCancel()
       
   141     {
       
   142     _DPRINT( 4, "PhSrv.Sendhandler.SendUssdCancel.Start" );         // debug print
       
   143     Cancel();
       
   144      _DPRINT( 4, "PhSrv.Sendhandler.SendUssdCancel.End" );           // debug print
       
   145     }
       
   146 
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CPhSrvUssdSendHandler::DoCancel
       
   150 //
       
   151 // Cancel request.
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 /*****************************************************
       
   155 *   Series 60 Customer / ETel
       
   156 *   Series 60  ETel API
       
   157 *****************************************************/
       
   158 void CPhSrvUssdSendHandler::DoCancel()
       
   159     {
       
   160     _DDPRINT( 4, "PhSrv.Sendhandler.DoCancel.Start", iStatus.Int() );           // debug print
       
   161 
       
   162     iUssdMessaging.CancelAsyncRequest( EMobileUssdMessagingSendMessage );
       
   163     delete iMsgData;
       
   164     iMsgData = NULL;
       
   165     delete iMsgAttribute;
       
   166     iMsgAttribute = NULL;
       
   167     _DDPRINT( 4, "PhSrv.Sendhandler.DoCancel.End", iStatus.Int() );           // debug print
       
   168     }
       
   169 
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CPhSrvUssdSendHandler::RunL
       
   173 //
       
   174 // When iStatusRequest is changed.
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 void CPhSrvUssdSendHandler::RunL()
       
   178     {
       
   179     _DDPRINT( 4, "PhSrv.SendHandler.RunL.Start", iStatus.Int() );
       
   180     iObserver.UssdNetworkObserverHandleSendEventL( iStatus.Int() );
       
   181     _DPRINT( 4, "PhSrv.Sendhandler.RunL.End" );
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CPhSrvUssdSendHandler::SendReleaseSession
       
   186 //
       
   187 // Terminates Ussd session.
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 void CPhSrvUssdSendHandler::SendReleaseSession()
       
   191 	{
       
   192 	_DPRINT( 4, "PhSrv.Sendhandler.SendReleaseSession.Start" );         // debug print
       
   193 	if ( !iSessionCancelWaiter->IsActive() )
       
   194 		{
       
   195 		_DPRINT( 4, "PhSrv.Sendhandler.SendReleaseSession" );           // debug print
       
   196 		iUssdMessaging.SendRelease(
       
   197             iSessionCancelWaiter->iStatus,
       
   198             iSessionCancelWaiter->iSSRequestPckg );
       
   199 		_DPRINT( 4, "PhSrv.Sendhandler.SendReleaseSession2" ); 
       
   200         iSessionCancelWaiter->SetActive();
       
   201         _DDPRINT( 4, "PhSrv.Sendhandler.SRS.iUssdMessaging", iStatus.Int() );
       
   202 		}
       
   203 	_DPRINT( 4, "PhSrv.Sendhandler.SendReleaseSession.End" );           // debug print
       
   204 	}
       
   205 
       
   206 //  End of File