imageeditorengine/ImageEditorUtils/src/Callback.cpp
changeset 1 edfc90759b9f
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "callback.h"
       
    21 
       
    22 //=============================================================================
       
    23 EXPORT_C CObCallback::~CObCallback()
       
    24 {
       
    25 	Cancel();
       
    26     iMethod = NULL;
       
    27 }
       
    28 
       
    29 //=============================================================================
       
    30 EXPORT_C CObCallback * CObCallback::NewL (MObCallbackMethod * aMethod)
       
    31 {
       
    32 	CObCallback * self = new (ELeave) CObCallback (aMethod);
       
    33 	CleanupStack::PushL (self);
       
    34 	self->ConstructL();
       
    35 	CleanupStack::Pop();
       
    36 	return self;
       
    37 }
       
    38 
       
    39 //=============================================================================
       
    40 EXPORT_C void CObCallback::DoCallback (TInt aParam)		
       
    41 {
       
    42 	iParam = aParam;
       
    43     CompleteRequest();
       
    44 }
       
    45 
       
    46 //=============================================================================
       
    47 void CObCallback::ConstructL()
       
    48 {
       
    49 	CActiveScheduler::Add (this);
       
    50 }
       
    51 
       
    52 //=============================================================================
       
    53 CObCallback::CObCallback (MObCallbackMethod * aMethod) : 
       
    54 CActive (EPriorityStandard), 
       
    55 iMethod (aMethod)
       
    56 {
       
    57 
       
    58 }
       
    59 
       
    60 //=============================================================================
       
    61 void CObCallback::RunL()
       
    62 {
       
    63     if ( iMethod->CallbackMethodL (iParam) )
       
    64     {
       
    65         CompleteRequest();
       
    66     }
       
    67 }
       
    68 
       
    69 //=============================================================================
       
    70 void CObCallback::DoCancel()
       
    71 {
       
    72 
       
    73 }
       
    74 
       
    75 //=============================================================================
       
    76 void CObCallback::CompleteRequest()
       
    77 {
       
    78 	if ( IsActive() )
       
    79 	{
       
    80 		Cancel();
       
    81 	}
       
    82 	TRequestStatus * p = &iStatus;
       
    83 	SetActive();
       
    84 	User::RequestComplete (p, KErrNone);
       
    85 }