phoneclientserver/phoneclient/Src/UssdWrapper/CPhCltUssdRequestHandler.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002 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 Notify Handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cphcltussdrequesthandler.h" 
       
    22 #include "mphcltussdrequesthandler.h" 
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CPhCltUssdRequestHandler::CPhCltUssdRequestHandler
       
    29 // C++ constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CPhCltUssdRequestHandler::CPhCltUssdRequestHandler(
       
    34     MPhCltUssdRequestHandler& aHandler,
       
    35     TInt aPriority )
       
    36     : CActive( aPriority ), iHandler( aHandler )
       
    37     {
       
    38     CActiveScheduler::Add( this );
       
    39     }
       
    40 
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CPhCltUssdRequestHandler::NewL
       
    44 // Two-phased constructor.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CPhCltUssdRequestHandler* CPhCltUssdRequestHandler::NewL( 
       
    48     MPhCltUssdRequestHandler& aHandler,
       
    49     TInt aPriority )
       
    50     {
       
    51     CPhCltUssdRequestHandler* self = 
       
    52         new( ELeave ) CPhCltUssdRequestHandler( aHandler , aPriority );
       
    53     CleanupStack::PushL( self );
       
    54     self->ConstructL();
       
    55     CleanupStack::Pop(); // self
       
    56     return self;
       
    57     }
       
    58 
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CPhCltUssdRequestHandler::ConstructL
       
    62 // Symbian 2nd phase constructor can leave.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CPhCltUssdRequestHandler::ConstructL()
       
    66     {
       
    67     User::LeaveIfError( iPhClient.Connect() );
       
    68     User::LeaveIfError( iUssdClient.Open( iPhClient ) );
       
    69     }
       
    70 
       
    71 
       
    72 // Destructor
       
    73 CPhCltUssdRequestHandler::~CPhCltUssdRequestHandler()
       
    74     {
       
    75     Cancel();
       
    76 
       
    77     //iUssdClient.CancelSend(); Fix to ou1cimx1#265402
       
    78     iUssdClient.Close();
       
    79 
       
    80     iPhClient.Close();
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CPhCltUssdRequestHandler::SendUssd
       
    86 //
       
    87 // Called when Sending
       
    88 // -----------------------------------------------------------------------------
       
    89 void CPhCltUssdRequestHandler::SendUssd( 
       
    90     const TDesC8& aMsgData, 
       
    91     const TDesC8& aMsgAttribute )
       
    92     {
       
    93     iUssdClient.SendUssd( iStatus , aMsgData , aMsgAttribute );
       
    94     SetActive();
       
    95     }
       
    96 
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CPhCltUssdRequestHandler::SendUssdCancel
       
   100 // 
       
   101 // -----------------------------------------------------------------------------
       
   102 void CPhCltUssdRequestHandler::SendUssdCancel()
       
   103     {
       
   104     if ( IsActive() )
       
   105         {
       
   106         Cancel();
       
   107         TRAP_IGNORE( iHandler.HandleSendEventL( KErrCancel ) );
       
   108         }
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CPhCltUssdRequestHandler::UssdClient
       
   113 // 
       
   114 // Returns USSD Client instance
       
   115 // -----------------------------------------------------------------------------
       
   116 RPhCltUssd& CPhCltUssdRequestHandler::UssdClient()
       
   117     {
       
   118     return iUssdClient;
       
   119     }
       
   120 
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CPhCltUssdRequestHandler::RunL
       
   124 //
       
   125 // Called when Send completes
       
   126 // -----------------------------------------------------------------------------
       
   127 void CPhCltUssdRequestHandler::RunL()
       
   128     {
       
   129     iHandler.HandleSendEventL( iStatus.Int() );
       
   130     }
       
   131 
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CPhCltUssdRequestHandler::DoCancel
       
   135 //
       
   136 // Called when Send is cancelled
       
   137 // -----------------------------------------------------------------------------
       
   138 
       
   139 void CPhCltUssdRequestHandler::DoCancel()
       
   140     {
       
   141     iUssdClient.CancelSend();
       
   142     }
       
   143 
       
   144 
       
   145 //  End of File