codhandler/roapapp/src/RequestCompleteCallback.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2004 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 the License "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: 
       
    15 *      Implementation of class CRequestCompleteCallback.   
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "RequestCompleteCallback.h"
       
    24 #include "RoapAppPanic.h"
       
    25 
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 
       
    28 // ---------------------------------------------------------
       
    29 // CRequestCompleteCallback::CRequestCompleteCallback()
       
    30 // ---------------------------------------------------------
       
    31 //
       
    32 CRequestCompleteCallback::CRequestCompleteCallback()
       
    33 : CActive( CActive::EPriorityStandard )
       
    34     {
       
    35     CActiveScheduler::Add( this );
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------
       
    39 // CRequestCompleteCallback::~CRequestCompleteCallback()
       
    40 // ---------------------------------------------------------
       
    41 //
       
    42 CRequestCompleteCallback::~CRequestCompleteCallback()
       
    43     {
       
    44     Cancel();
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CRequestCompleteCallback::CallbackOnCompletion()
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 void CRequestCompleteCallback::CallbackOnCompletion
       
    52 ( const TCallBack& aCallback )
       
    53     {
       
    54     __ASSERT_DEBUG( !IsActive(), RoapAppPanic( ERoapAppRequestPending ) );
       
    55     iCallback = aCallback;
       
    56     SetActive();
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CRequestCompleteCallback::DoCancel()
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 void CRequestCompleteCallback::DoCancel()
       
    64     {
       
    65     // The request should have been completed/Cancelled already, this object
       
    66     // cannot cancel it. If still pending, panic now (rather than hang).
       
    67     __ASSERT_ALWAYS( iStatus != KRequestPending, \
       
    68         RoapAppPanic( ERoapAppRequestPending ) );
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CRequestCompleteCallback::RunL()
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 void CRequestCompleteCallback::RunL()
       
    76     {
       
    77 #ifdef _DEBUG
       
    78     // Debug-only variable.
       
    79     TBool ret =
       
    80 #endif
       
    81     iCallback.CallBack();
       
    82     // This object cannot renew the request itself. Therefore, callbacks
       
    83     // must return EFalse.
       
    84     __ASSERT_DEBUG( !ret, RoapAppPanic( ERoapAppInvalidCallback ) );
       
    85     }