mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsconnectnotifier.cpp
changeset 49 c20dd21d1eb4
parent 29 3ae5cb0b4c02
child 60 841f70763fbe
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    15 *                PTP printer connction and disconnection. 
    15 *                PTP printer connction and disconnection. 
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 #include <e32debug.h>
       
    21 #include "dpsconnectnotifier.h"
    20 #include "dpsconnectnotifier.h"
    22 #include "dpsusbnotifier.h"
    21 #include "dpsusbnotifier.h"
    23 
    22 #include "OstTraceDefinitions.h"
    24 #ifdef _DEBUG
    23 #ifdef OST_TRACE_COMPILER_IN_USE
    25 #	define IF_DEBUG(t) {RDebug::t;}
    24 #include "dpsconnectnotifierTraces.h"
    26 #else
       
    27 #	define IF_DEBUG(t)
       
    28 #endif
    25 #endif
    29 
    26 
    30 const TUint KUsbAllStates = 0xFFFFFFFF;
    27 const TUint KUsbAllStates = 0xFFFFFFFF;
    31 
    28 
    32 // ---------------------------------------------------------------------------
    29 // ---------------------------------------------------------------------------
    33 // 
    30 // 
    34 // ---------------------------------------------------------------------------
    31 // ---------------------------------------------------------------------------
    35 // 
    32 // 
    36 CDpsConnectNotifier* CDpsConnectNotifier::NewL(CDpsUsbNotifier* aParent)
    33 CDpsConnectNotifier* CDpsConnectNotifier::NewL(CDpsUsbNotifier* aParent)
    37     {
    34     {
    38     IF_DEBUG(Print(_L("CDpsConnectNotifier::NewL")));
       
    39     CDpsConnectNotifier* self = new(ELeave) CDpsConnectNotifier(aParent);
    35     CDpsConnectNotifier* self = new(ELeave) CDpsConnectNotifier(aParent);
    40     return self;	    
    36     return self;	    
    41     }
    37     }
    42     
    38     
    43 // ---------------------------------------------------------------------------
    39 // ---------------------------------------------------------------------------
    45 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
    46 //     
    42 //     
    47 CDpsConnectNotifier::CDpsConnectNotifier(CDpsUsbNotifier* aParent) :
    43 CDpsConnectNotifier::CDpsConnectNotifier(CDpsUsbNotifier* aParent) :
    48     CActive(EPriorityNormal), iNotifier(aParent) 
    44     CActive(EPriorityNormal), iNotifier(aParent) 
    49     {
    45     {
    50     IF_DEBUG(Print(_L(">>>CDpsConnectNotifier::Ctor")));    
    46     OstTraceFunctionEntry0( DUP1_CDPSCONNECTNOTIFIER_CDPSCONNECTNOTIFIER_CONS_ENTRY ); 
    51     CActiveScheduler::Add(this);
    47     CActiveScheduler::Add(this);
    52     IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::Ctor")));    
    48     OstTraceFunctionExit0( DUP1_CDPSCONNECTNOTIFIER_CDPSCONNECTNOTIFIER_CONS_EXIT );
    53     }
    49     }
    54    
    50    
    55 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    56 // 
    52 // 
    57 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    58 //     
    54 //     
    59 CDpsConnectNotifier::~CDpsConnectNotifier()
    55 CDpsConnectNotifier::~CDpsConnectNotifier()
    60     {
    56     {
    61     IF_DEBUG(Print(_L(">>>CDpsConnectNotifier::~")));   
    57     OstTraceFunctionEntry0( CDPSCONNECTNOTIFIER_CDPSCONNECTNOTIFIER_DES_ENTRY );  
    62     Cancel();
    58     Cancel();
    63     IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::~")));   
    59     OstTraceFunctionExit0( CDPSCONNECTNOTIFIER_CDPSCONNECTNOTIFIER_DES_EXIT );
    64     }
    60     }
    65    
    61    
    66 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    67 // 
    63 // 
    68 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
    69 //     
    65 //     
    70 void CDpsConnectNotifier::ConnectNotify()
    66 void CDpsConnectNotifier::ConnectNotify()
    71     {
    67     {
    72     IF_DEBUG(Print(_L(">>>CDpsConnectNotifier::ConnectNotify")));    
    68     OstTraceFunctionEntry0( CDPSCONNECTNOTIFIER_CONNECTNOTIFY_ENTRY );  
    73     if (!IsActive())
    69     if (!IsActive())
    74         {
    70         {
    75 	    iNotifier->iUsbM.DeviceStateNotification(KUsbAllStates, 
    71 	    iNotifier->iUsbM.DeviceStateNotification(KUsbAllStates, 
    76 	                                             iNotifier->iConnectState, 
    72 	                                             iNotifier->iConnectState, 
    77 	                                             iStatus);
    73 	                                             iStatus);
    78         SetActive();			
    74         SetActive();			
    79         }
    75         } 	
    80     IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::ConnectNotify")));    	
    76     OstTraceFunctionExit0( CDPSCONNECTNOTIFIER_CONNECTNOTIFY_EXIT );
    81     }
    77     }
    82     
    78     
    83 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    84 // 
    80 // 
    85 // ---------------------------------------------------------------------------
    81 // ---------------------------------------------------------------------------
    86 // 
    82 // 
    87 void CDpsConnectNotifier::RunL()
    83 void CDpsConnectNotifier::RunL()
    88     {
    84     {
    89     IF_DEBUG(Print(_L
    85     OstTraceFunctionEntry0( CDPSCONNECTNOTIFIER_RUNL_ENTRY );
    90         (">>>CDpsConnectNotifier::RunL %x"), iNotifier->iConnectState));
    86     OstTrace1( TRACE_NORMAL, CDPSCONNECTNOTIFIER_RUNL, "status %d", iNotifier->iConnectState );
       
    87 
    91     if (KErrNone == iStatus.Int())
    88     if (KErrNone == iStatus.Int())
    92         {
    89         {
    93         
    90         
    94         // notify connect (by set personality)
    91         // notify connect (by set personality)
    95         if (iNotifier->iConnectState == EUsbDeviceStateConfigured && 
    92         if (iNotifier->iConnectState == EUsbDeviceStateConfigured && 
   115             }
   112             }
   116         
   113         
   117         }
   114         }
   118     else
   115     else
   119         {
   116         {
   120         IF_DEBUG(Print(_L("\tthe iStatus is wrong!!!")));
   117         OstTrace0( TRACE_WARNING, DUP1_CDPSCONNECTNOTIFIER_RUNL, "the iStatus is wrong!!!" );
   121         }    
   118         }      
   122     IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::RunL")));    
   119     OstTraceFunctionExit0( CDPSCONNECTNOTIFIER_RUNL_EXIT );
   123     }
   120     }
   124     
   121     
   125 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   126 // 
   123 // 
   127 // ---------------------------------------------------------------------------
   124 // ---------------------------------------------------------------------------
   128 // 
   125 // 
   129 void CDpsConnectNotifier::DoCancel()
   126 void CDpsConnectNotifier::DoCancel()
   130     {
   127     {
   131     IF_DEBUG(Print(_L(">>>CDpsConnectNotifier::DoCancel")));    
   128     OstTraceFunctionEntry0( CDPSCONNECTNOTIFIER_DOCANCEL_ENTRY );  
   132     iNotifier->iUsbM.DeviceStateNotificationCancel();
   129     iNotifier->iUsbM.DeviceStateNotificationCancel();
   133     IF_DEBUG(Print(_L("<<<CDpsConnectNotifier::DoCancel")));
   130     OstTraceFunctionExit0( CDPSCONNECTNOTIFIER_DOCANCEL_EXIT );
   134     }
   131     }
   135     
   132     
   136 // ---------------------------------------------------------------------------
   133 // ---------------------------------------------------------------------------
   137 // 
   134 // 
   138 // ---------------------------------------------------------------------------
   135 // ---------------------------------------------------------------------------
   139 // 
   136 // 
   140 TInt CDpsConnectNotifier::RunError(TInt aErr)
   137 TInt CDpsConnectNotifier::RunError(TInt aErr)
   141     {
   138     {
   142     IF_DEBUG(Print(_L("CDpsConnectNotifier::RunError is %d"), aErr));    
   139     OstTraceDef1(OST_TRACE_CATEGORY_PRODUCTION, TRACE_IMPORTANT, CDPSCONNECTNOTIFIER_RUNERROR, 
       
   140             "CDpsConnectNotifier::RunError is %d", aErr );
   143     return aErr;
   141     return aErr;
   144     }
   142     }