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