mtpdataproviders/mtppictbridgedp/pictbridgeengine/src/dpsptpnotifier.cpp
changeset 47 63cf70d3ecd8
parent 28 85e0c0339cc3
child 60 841f70763fbe
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  This class implements functions of setting personality to 
    14 * Description:  This class implements functions of setting personality to 
    15 *                MTP. 
    15 *                MTP. 
    16 *  Version     : %version: 1 % 
    16 *  Version     : %version: 2 % 
    17 *
    17 *
    18 */
    18 */
    19 
    19 
    20 
    20 
    21 #include <e32debug.h>
       
    22 #include "dpsptpnotifier.h"
    21 #include "dpsptpnotifier.h"
    23 #include "dpsusbnotifier.h"
    22 #include "dpsusbnotifier.h"
    24 #include "dpsconst.h"
    23 #include "dpsconst.h"
    25 
    24 #include "OstTraceDefinitions.h"
    26 #ifdef _DEBUG
    25 #ifdef OST_TRACE_COMPILER_IN_USE
    27 #	define IF_DEBUG(t) {RDebug::t;}
    26 #include "dpsptpnotifierTraces.h"
    28 #else
       
    29 #	define IF_DEBUG(t)
       
    30 #endif
    27 #endif
    31 
    28 
    32 // ---------------------------------------------------------------------------
    29 // ---------------------------------------------------------------------------
    33 // 
    30 // 
    34 // ---------------------------------------------------------------------------
    31 // ---------------------------------------------------------------------------
    35 //
    32 //
    36 CDpsPtpNotifier* CDpsPtpNotifier::NewL(CDpsUsbNotifier* aParent)
    33 CDpsPtpNotifier* CDpsPtpNotifier::NewL(CDpsUsbNotifier* aParent)
    37     {
    34     {
    38     IF_DEBUG(Print(_L("CDpsPtpNotifier::NewL")));
       
    39     CDpsPtpNotifier* self = new(ELeave) CDpsPtpNotifier(aParent);
    35     CDpsPtpNotifier* self = new(ELeave) CDpsPtpNotifier(aParent);
    40     return self;	    
    36     return self;	    
    41     }
    37     }
    42     
    38     
    43 // ---------------------------------------------------------------------------
    39 // ---------------------------------------------------------------------------
    45 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
    46 //
    42 //
    47 CDpsPtpNotifier::CDpsPtpNotifier(CDpsUsbNotifier* aParent) :
    43 CDpsPtpNotifier::CDpsPtpNotifier(CDpsUsbNotifier* aParent) :
    48     CActive(EPriorityNormal), iNotifier(aParent)
    44     CActive(EPriorityNormal), iNotifier(aParent)
    49     {
    45     {
    50     IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::Ctor")));    
    46     OstTraceFunctionEntry0( CDPSPTPNOTIFIER_CDPSPTPNOTIFIER_CONS_ENTRY );
    51     CActiveScheduler::Add(this);
    47     CActiveScheduler::Add(this);
    52     IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::Ctor")));    
    48     OstTraceFunctionExit0( CDPSPTPNOTIFIER_CDPSPTPNOTIFIER_CONS_EXIT );
    53     }    
    49     }    
    54     
    50     
    55 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    56 // 
    52 // 
    57 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    58 //
    54 //
    59 CDpsPtpNotifier::~CDpsPtpNotifier()
    55 CDpsPtpNotifier::~CDpsPtpNotifier()
    60     {
    56     {
    61     IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::")));        
    57     OstTraceFunctionEntry0( CDPSPTPNOTIFIER_CDPSPTPNOTIFIER_DES_ENTRY );       
    62     Cancel();
    58     Cancel();   
    63     IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::~")));        
    59     OstTraceFunctionExit0( DUP1_CDPSPTPNOTIFIER_CDPSPTPNOTIFIER_DES_EXIT );
    64     }
    60     }
    65     
    61     
    66 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    67 // 
    63 // 
    68 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
    69 //    
    65 //    
    70 void CDpsPtpNotifier::ChangePtpPersonality()    
    66 void CDpsPtpNotifier::ChangePtpPersonality()    
    71     {
    67     {
    72     IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::ChangePtpPersonality")));            
    68     OstTraceFunctionEntry0( CDPSPTPNOTIFIER_CHANGEPTPPERSONALITY_ENTRY );         
    73     if (!IsActive())
    69     if (!IsActive())
    74         {
    70         {
    75         TInt personalityId = KUsbPersonalityIdMTP;
    71         TInt personalityId = KUsbPersonalityIdMTP;
    76         iNotifier->iUsbM.GetCurrentPersonalityId(personalityId);
    72         iNotifier->iUsbM.GetCurrentPersonalityId(personalityId);
    77         IF_DEBUG(Print(_L("CDpsPtpNotifier::ChangePtpPersonality, current personality= %d"), personalityId));
    73         OstTrace1(TRACE_NORMAL, CDPSPTPNOTIFIER_CHANGEPTPPERSONALITY, "current personality= %d", personalityId );
    78         if(KUsbPersonalityIdPCSuiteMTP == personalityId)
    74         if(KUsbPersonalityIdPCSuiteMTP == personalityId)
    79             {
    75             {
    80             TRequestStatus* statusPtr = &iStatus;
    76             TRequestStatus* statusPtr = &iStatus;
    81             User::RequestComplete(statusPtr, KErrNone);
    77             User::RequestComplete(statusPtr, KErrNone);
    82             SetActive();            
    78             SetActive();            
    84         else                
    80         else                
    85             {
    81             {
    86             iNotifier->iUsbW.SetPersonality(iStatus, KUsbPersonalityIdMTP, ETrue);
    82             iNotifier->iUsbW.SetPersonality(iStatus, KUsbPersonalityIdMTP, ETrue);
    87             SetActive();
    83             SetActive();
    88             }
    84             }
    89         }
    85         }     
    90     IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::ChangePtpPersonality")));        
    86     OstTraceFunctionExit0( CDPSPTPNOTIFIER_CHANGEPTPPERSONALITY_EXIT );
    91     }
    87     }
    92 
    88 
    93 // ---------------------------------------------------------------------------
    89 // ---------------------------------------------------------------------------
    94 // 
    90 // 
    95 // ---------------------------------------------------------------------------
    91 // ---------------------------------------------------------------------------
    96 //
    92 //
    97 void CDpsPtpNotifier::RunL()
    93 void CDpsPtpNotifier::RunL()
    98     {
    94     {
    99     IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::RunL %d"), iStatus.Int()));            
    95     OstTraceFunctionEntry0( CDPSPTPNOTIFIER_RUNL_ENTRY );
       
    96     OstTrace1( TRACE_NORMAL, CDPSPTPNOTIFIER_RUNL, "iStatus %d", iStatus.Int());         
   100     if (KErrNone == iStatus.Int())
    97     if (KErrNone == iStatus.Int())
   101         {
    98         {
   102         iNotifier->iPersonality = KUsbPersonalityIdMTP;
    99         iNotifier->iPersonality = KUsbPersonalityIdMTP;
   103         TInt ret = iNotifier->ConnectState();
   100         TInt ret = iNotifier->ConnectState();
   104         if (ret != KErrNone)
   101         if (ret != KErrNone)
   105             {
   102             {
   106             IF_DEBUG(Print(_L("error happened %d"), ret));
   103             OstTrace1( TRACE_WARNING, DUP1_CDPSPTPNOTIFIER_RUNL, "error happened %d", ret );
   107             }
   104             }
   108         }
   105         }
   109     iNotifier->PtpNotify(iStatus.Int());        
   106     iNotifier->PtpNotify(iStatus.Int());        
   110     IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::RunL")));
   107     OstTraceFunctionExit0( CDPSPTPNOTIFIER_RUNL_EXIT );
   111     }
   108     }
   112     
   109     
   113 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
   114 // 
   111 // 
   115 // ---------------------------------------------------------------------------
   112 // ---------------------------------------------------------------------------
   116 //
   113 //
   117 void CDpsPtpNotifier::DoCancel()
   114 void CDpsPtpNotifier::DoCancel()
   118     {
   115     {
   119     IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::DoCancel")));                
   116     OstTraceFunctionEntry0( CDPSPTPNOTIFIER_DOCANCEL_ENTRY );               
   120     iNotifier->iUsbW.CancelSetPersonality();
   117     iNotifier->iUsbW.CancelSetPersonality();          
   121     IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::DoCancel")));                
   118     OstTraceFunctionExit0( CDPSPTPNOTIFIER_DOCANCEL_EXIT );
   122     }
   119     }
   123     
   120     
   124 // ---------------------------------------------------------------------------
   121 // ---------------------------------------------------------------------------
   125 // 
   122 // 
   126 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
   127 //
   124 //
   128 TInt CDpsPtpNotifier::RunError(TInt aErr)
   125 TInt CDpsPtpNotifier::RunError(TInt aErr)
   129     {
   126     {
   130     IF_DEBUG(Print(_L("CDpsPtpNotifier::RunError")));                    
   127     OstTraceDef1( OST_TRACE_CATEGORY_PRODUCTION, TRACE_IMPORTANT, CDPSPTPNOTIFIER_RUNERROR, 
       
   128             "error code %d", aErr);
   131     return aErr;
   129     return aErr;
   132     }
   130     }