usbengines/usbotgwatcher/tsrc/UsbOtgWatcherTest/src/mockcusbmessagenotificationobserver.cpp
branchRCL_3
changeset 92 dde4619868dc
parent 86 703a2b94c06c
child 95 55a3258355ea
equal deleted inserted replaced
86:703a2b94c06c 92:dde4619868dc
     1 /*
       
     2 * Copyright (c) 2010 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 #include <e32base.h>
       
    19 #include <NormalHardcodedAssert.h>
       
    20 
       
    21 #include "stifassertmacros.h"
       
    22 
       
    23 #include "mockcusbmessagenotificationobserver.h"
       
    24 
       
    25 #include "debug.h"
       
    26 #include "panic.h"
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // ?description_if_needed
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CUsbMessageNotificationObserver::CUsbMessageNotificationObserver(RUsb* aUsb) :
       
    33     iUsb(aUsb)
       
    34     {
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // ?description_if_needed
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 void CUsbMessageNotificationObserver::ConstructL()
       
    42     {
       
    43     }
       
    44 
       
    45 CUsbMessageNotificationObserver* CUsbMessageNotificationObserver::NewL(
       
    46         RUsb* aUsb)
       
    47     {
       
    48     LOG(  ( "[USBOTGWATCHER]\tMockCUsbMessageNotificationObserver::NewL" ) );
       
    49 
       
    50     CUsbMessageNotificationObserver* self = new( ELeave ) CUsbMessageNotificationObserver(aUsb);
       
    51     CleanupStack::PushL(self);
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop(self);
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // ?description_if_needed
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CUsbMessageNotificationObserver::~CUsbMessageNotificationObserver()
       
    62     {
       
    63     LOG(  ( "[USBOTGWATCHER]\tMockCUsbMessageNotificationObserver::~CUsbMessageNotificationObserver" ) );
       
    64     }
       
    65 
       
    66 void CUsbMessageNotificationObserver::SubscribeL(
       
    67         MUsbMessageNotificationObserver& aObserver)
       
    68     {
       
    69     LOG( ("[USBOTGWATCHER]\tMockCUsbMessageNotificationObserver::SubscribeL"));
       
    70     STIF_ASSERT_NOT_NULL(&aObserver);
       
    71 
       
    72     iObserver = &aObserver;
       
    73     }
       
    74 
       
    75 void CUsbMessageNotificationObserver::UnsubscribeL(
       
    76         MUsbMessageNotificationObserver& aObserver)
       
    77     {
       
    78     LOG( ("[USBOTGWATCHER]\tMockCUsbMessageNotificationObserver::UnsubscribeL"));
       
    79     STIF_ASSERT_NOT_NULL(&aObserver);
       
    80 
       
    81     iObserver = NULL;
       
    82     }
       
    83 
       
    84 void CUsbMessageNotificationObserver::TriggerMessageNotificationReceivedL(
       
    85         TInt aMessage)
       
    86     {
       
    87     STIF_ASSERT_NOT_NULL(iObserver);
       
    88 
       
    89     // default, others
       
    90     iObserver->MessageNotificationReceivedL(aMessage);
       
    91     }
       
    92 
       
    93 void CUsbMessageNotificationObserver::TriggerBadHubPositionL()
       
    94     {
       
    95     STIF_ASSERT_NOT_NULL(iObserver);
       
    96 
       
    97     //KErrUsbBadHubPosition
       
    98     iObserver->BadHubPositionL();
       
    99     }
       
   100 
       
   101 void CUsbMessageNotificationObserver::TriggerVBusErrorL()
       
   102     {
       
   103     STIF_ASSERT_NOT_NULL(iObserver);
       
   104 
       
   105     //KErrUsbOtgVbusError
       
   106     iObserver->VBusErrorL();
       
   107     }
       
   108 
       
   109 void CUsbMessageNotificationObserver::TriggerSrpReceivedL()
       
   110     {
       
   111     STIF_ASSERT_NOT_NULL(iObserver);
       
   112 
       
   113     //KUsbMessageSrpReceived
       
   114     iObserver->SrpReceivedL();
       
   115     }
       
   116 
       
   117 void CUsbMessageNotificationObserver::TriggerSessionRequestedL()
       
   118     {
       
   119     STIF_ASSERT_NOT_NULL(iObserver);
       
   120 
       
   121     //KUsbMessageRequestSession
       
   122     iObserver->SessionRequestedL();
       
   123     }