mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepwatcher.cpp
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #include "cmtpusbconnection.h"
       
    22 #include "cmtpusbepwatcher.h"
       
    23 
       
    24 __FLOG_STMT(_LIT8(KComponent,"UsbEpWatcher");)
       
    25 
       
    26 /**
       
    27 USB MTP device class endpoint stall status observer factory method.
       
    28 @return A pointer to an USB MTP device class endpoint stall status 
       
    29 observer object. Ownership IS transfered.
       
    30 @leave One of the system wide error codes, if a processing failure occurs.
       
    31 */
       
    32 CMTPUsbEpWatcher* CMTPUsbEpWatcher::NewL(CMTPUsbConnection& aConnection)
       
    33     {
       
    34     CMTPUsbEpWatcher* self = new (ELeave) CMTPUsbEpWatcher(aConnection);
       
    35     CleanupStack::PushL(self);
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop(self);
       
    38     return self;
       
    39     }
       
    40     
       
    41 /**
       
    42 Destructor.
       
    43 */
       
    44 CMTPUsbEpWatcher::~CMTPUsbEpWatcher()
       
    45     {
       
    46     __FLOG(_L8("~CMTPUsbEpWatcher - Entry"));
       
    47     Cancel();
       
    48     __FLOG(_L8("~CMTPUsbEpWatcher - Exit"));
       
    49     __FLOG_CLOSE;
       
    50     }
       
    51 
       
    52 void CMTPUsbEpWatcher::Start()
       
    53     {
       
    54     __FLOG(_L8("Start - Entry"));
       
    55     if (!IsActive())
       
    56         {
       
    57         RequestIssue();
       
    58         }
       
    59     __FLOG(_L8("Start - Exit"));
       
    60     }
       
    61     
       
    62 void CMTPUsbEpWatcher::Stop()
       
    63     {
       
    64     __FLOG(_L8("Stop - Entry"));
       
    65     Cancel();
       
    66     __FLOG(_L8("Stop - Exit"));
       
    67     }
       
    68     
       
    69 void CMTPUsbEpWatcher::DoCancel()
       
    70     {
       
    71     __FLOG(_L8("DoCancel - Entry"));    
       
    72     RequestCancel();
       
    73     __FLOG(_L8("DoCancel - Exit"));  
       
    74     }
       
    75     
       
    76 #ifdef __FLOG_ACTIVE
       
    77 TInt CMTPUsbEpWatcher::RunError(TInt aError)
       
    78 #else
       
    79 TInt CMTPUsbEpWatcher::RunError(TInt /*aError*/)
       
    80 #endif
       
    81     {
       
    82     __FLOG(_L8("RunError - Entry"));
       
    83     __FLOG_VA((_L8("Error = %d"), aError));
       
    84     __FLOG(_L8("RunError - Exit"));
       
    85     RequestIssue();
       
    86     return KErrNone;  
       
    87     }
       
    88     
       
    89 void CMTPUsbEpWatcher::RunL()
       
    90     {
       
    91     __FLOG(_L8("RunL - Entry"));
       
    92     iConnection.EndpointStallStatusChangedL(iEndpointStatus);
       
    93     RequestIssue();
       
    94     __FLOG(_L8("RunL - Exit"));  
       
    95     }
       
    96 
       
    97 CMTPUsbEpWatcher::CMTPUsbEpWatcher(CMTPUsbConnection& aConnection) :
       
    98     CActive(EPriorityStandard),
       
    99     iConnection(aConnection)
       
   100     {
       
   101     CActiveScheduler::Add(this);
       
   102     }
       
   103     
       
   104 void CMTPUsbEpWatcher::ConstructL()
       
   105     {
       
   106     __FLOG_OPEN(KMTPSubsystem, KComponent);
       
   107     __FLOG(_L8("ConstructL - Entry"));    
       
   108     __FLOG(_L8("ConstructL - Exit")); 
       
   109     }
       
   110 
       
   111 void CMTPUsbEpWatcher::RequestCancel()
       
   112     {
       
   113     __FLOG(_L8("RequestCancel - Entry"));    
       
   114     iConnection.Ldd().EndpointStatusNotifyCancel();
       
   115     __FLOG(_L8("RequestCancel - Exit")); 
       
   116     }
       
   117     
       
   118 void CMTPUsbEpWatcher::RequestIssue()
       
   119     {
       
   120     __FLOG(_L8("RequestIssue - Entry"));    
       
   121     iConnection.Ldd().EndpointStatusNotify(iStatus, iEndpointStatus);
       
   122     SetActive();
       
   123     __FLOG(_L8("RequestIssue - Exit")); 
       
   124     }