usbmgmt/usbmgr/host/fdf/production/server/src/activewaitforecomevent.cpp
changeset 0 c9bc50fca66e
child 15 f92a4f87e424
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "activewaitforecomevent.h"
       
    20 #include <usb/usblogger.h>
       
    21 #include "utils.h"
       
    22 
       
    23 
       
    24 #ifdef __FLOG_ACTIVE
       
    25 _LIT8(KLogComponent, "fdf      ");
       
    26 #endif
       
    27 
       
    28 #ifdef _DEBUG
       
    29 _LIT( KFdfEcomEventAOPanicCategory, "FdfEcomEventAO" );
       
    30 #endif
       
    31 
       
    32 CActiveWaitForEComEvent::CActiveWaitForEComEvent(MEComEventObserver& aObserver)
       
    33 :	CActive(CActive::EPriorityStandard),
       
    34 	iObserver(aObserver)
       
    35 	{
       
    36 	LOG_FUNC
       
    37 
       
    38 	CActiveScheduler::Add(this);
       
    39 	}
       
    40 
       
    41 CActiveWaitForEComEvent::~CActiveWaitForEComEvent()
       
    42 	{
       
    43 	LOG_FUNC
       
    44 	Cancel();
       
    45 	iEComSession.Close();
       
    46 	REComSession::FinalClose();
       
    47 	}
       
    48 
       
    49 CActiveWaitForEComEvent* CActiveWaitForEComEvent::NewL(MEComEventObserver& aObserver)
       
    50 	{
       
    51 	CActiveWaitForEComEvent* self = new(ELeave) CActiveWaitForEComEvent(aObserver);
       
    52 	CleanupStack::PushL(self);
       
    53 	self->ConstructL();
       
    54 	CleanupStack::Pop(self);
       
    55 	return self;
       
    56 	}
       
    57 
       
    58 
       
    59 void CActiveWaitForEComEvent::ConstructL()
       
    60 	{
       
    61 	iEComSession = REComSession::OpenL();
       
    62 	}
       
    63 
       
    64 void CActiveWaitForEComEvent::Wait()
       
    65 	{
       
    66 	LOG_FUNC
       
    67 	iEComSession.NotifyOnChange(iStatus);
       
    68 	SetActive();
       
    69 	}
       
    70 
       
    71 void CActiveWaitForEComEvent::RunL()
       
    72 	{
       
    73 	LOG_LINE
       
    74 	LOG_FUNC
       
    75 	iObserver.EComEventReceived();
       
    76 	Wait();
       
    77 	}
       
    78 
       
    79 void CActiveWaitForEComEvent::DoCancel()
       
    80 	{
       
    81 	LOG_FUNC
       
    82 	iEComSession.CancelNotifyOnChange(iStatus);
       
    83 	}
       
    84 
       
    85 TInt CActiveWaitForEComEvent::RunError(TInt aError)
       
    86 	{
       
    87 	LOG_LINE
       
    88 	LOG_FUNC
       
    89 	LOGTEXT2(_L8("ECOM change notification error = %d "), aError);
       
    90 	__ASSERT_DEBUG(EFalse, _USB_PANIC(KFdfEcomEventAOPanicCategory, aError));
       
    91 	return KErrNone;
       
    92 	}