mtpdataproviders/mtpplaybackcontroldp/src/cmtppbcgetdevicepropvalue.cpp
changeset 49 c20dd21d1eb4
parent 29 3ae5cb0b4c02
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    26 #include "mtpplaybackcontroldpconst.h"
    26 #include "mtpplaybackcontroldpconst.h"
    27 #include "cmtpplaybackcontroldp.h"
    27 #include "cmtpplaybackcontroldp.h"
    28 #include "cmtpplaybackproperty.h"
    28 #include "cmtpplaybackproperty.h"
    29 #include "cmtpplaybackcommand.h"
    29 #include "cmtpplaybackcommand.h"
    30 #include "mtpplaybackcontrolpanic.h"
    30 #include "mtpplaybackcontrolpanic.h"
    31 
    31 #include "OstTraceDefinitions.h"
    32 
    32 #ifdef OST_TRACE_COMPILER_IN_USE
    33 // Class constants.
    33 #include "cmtppbcgetdevicepropvalueTraces.h"
    34 __FLOG_STMT(_LIT8(KComponent,"GetPlaybackDevicePropValue");)
    34 #endif
       
    35 
    35 
    36 
    36 /**
    37 /**
    37 Two-phase constructor.
    38 Two-phase constructor.
    38 @param aPlugin  The data provider plugin
    39 @param aPlugin  The data provider plugin
    39 @param aFramework The data provider framework
    40 @param aFramework The data provider framework
    42 */  
    43 */  
    43 MMTPRequestProcessor* CMTPPbcGetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework, 
    44 MMTPRequestProcessor* CMTPPbcGetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework, 
    44                                                    MMTPConnection& aConnection, 
    45                                                    MMTPConnection& aConnection, 
    45                                                    CMTPPlaybackControlDataProvider& aDataProvider)
    46                                                    CMTPPlaybackControlDataProvider& aDataProvider)
    46     {
    47     {
       
    48     OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_NEWL_ENTRY );
    47     CMTPPbcGetDevicePropValue* self = new (ELeave) CMTPPbcGetDevicePropValue(aFramework, aConnection, aDataProvider);
    49     CMTPPbcGetDevicePropValue* self = new (ELeave) CMTPPbcGetDevicePropValue(aFramework, aConnection, aDataProvider);
       
    50     OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_NEWL_EXIT );
    48     return self;
    51     return self;
    49     }
    52     }
    50 
    53 
    51 /**
    54 /**
    52 Destructor.
    55 Destructor.
    53 */    
    56 */    
    54 CMTPPbcGetDevicePropValue::~CMTPPbcGetDevicePropValue()
    57 CMTPPbcGetDevicePropValue::~CMTPPbcGetDevicePropValue()
    55     {
    58     {
    56     __FLOG(_L8("~CMTPPbcGetDevicePropValue - Entry"));
    59     OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_CMTPPBCGETDEVICEPROPVALUE_ENTRY );
    57     delete iPbCmd;
    60     delete iPbCmd;
    58     __FLOG(_L8("~CMTPPbcGetDevicePropValue - Exit"));
    61     OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_CMTPPBCGETDEVICEPROPVALUE_EXIT );
    59     __FLOG_CLOSE;
       
    60     }
    62     }
    61 
    63 
    62 /**
    64 /**
    63 Constructor.
    65 Constructor.
    64 */    
    66 */    
    66                                                 MMTPConnection& aConnection,
    68                                                 MMTPConnection& aConnection,
    67                                                 CMTPPlaybackControlDataProvider& aDataProvider):
    69                                                 CMTPPlaybackControlDataProvider& aDataProvider):
    68     CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
    70     CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
    69     iPlaybackControlDp(aDataProvider)
    71     iPlaybackControlDp(aDataProvider)
    70     {
    72     {
    71     //Open the log system
    73     OstTraceFunctionEntry0( DUP1_CMTPPBCGETDEVICEPROPVALUE_CMTPPBCGETDEVICEPROPVALUE_ENTRY );
    72     __FLOG_OPEN(KMTPSubsystem, KComponent);
    74     OstTraceFunctionExit0( DUP1_CMTPPBCGETDEVICEPROPVALUE_CMTPPBCGETDEVICEPROPVALUE_EXIT );
    73     }
    75     }
    74 
    76 
    75 /**
    77 /**
    76 CMTPPbcGetDevicePropValue request validator.
    78 CMTPPbcGetDevicePropValue request validator.
    77 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
    79 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
    78 */
    80 */
    79 TMTPResponseCode CMTPPbcGetDevicePropValue::CheckRequestL()
    81 TMTPResponseCode CMTPPbcGetDevicePropValue::CheckRequestL()
    80     {
    82     {
    81     __FLOG(_L8("CheckRequestL - Entry"));
    83     OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_CHECKREQUESTL_ENTRY );
    82     TMTPResponseCode respCode = CMTPRequestProcessor::CheckRequestL();
    84     TMTPResponseCode respCode = CMTPRequestProcessor::CheckRequestL();
    83     if(respCode == EMTPRespCodeOK)
    85     if(respCode == EMTPRespCodeOK)
    84         {
    86         {
    85         respCode = EMTPRespCodeDevicePropNotSupported;
    87         respCode = EMTPRespCodeDevicePropNotSupported;
    86         TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    88         TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    93                 respCode = EMTPRespCodeOK;
    95                 respCode = EMTPRespCodeOK;
    94                 break;
    96                 break;
    95                 }
    97                 }
    96             }
    98             }
    97         }
    99         }
    98     __FLOG(_L8("CheckRequestL - Exit"));
   100     OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_CHECKREQUESTL_EXIT );
    99     return respCode;
   101     return respCode;
   100     }
   102     }
   101 
   103 
   102 /**
   104 /**
   103 CMTPPbcGetDevicePropValue request handler.
   105 CMTPPbcGetDevicePropValue request handler.
   104 */   
   106 */   
   105 void CMTPPbcGetDevicePropValue::ServiceL()
   107 void CMTPPbcGetDevicePropValue::ServiceL()
   106     {
   108     {
   107     __FLOG(_L8("ServiceL - Entry"));
   109     OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_SERVICEL_ENTRY );
   108     //Destroy the previous playback command.
   110     //Destroy the previous playback command.
   109     delete iPbCmd;
   111     delete iPbCmd;
   110     iPbCmd = NULL;
   112     iPbCmd = NULL;
   111     
   113     
   112     //Get the device property code
   114     //Get the device property code
   133         }
   135         }
   134     else
   136     else
   135         {
   137         {
   136         SendResponseL(EMTPRespCodeParameterNotSupported);
   138         SendResponseL(EMTPRespCodeParameterNotSupported);
   137         }
   139         }
   138     __FLOG(_L8("ServiceL - Exit"));
   140     OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_SERVICEL_EXIT );
   139     }
   141     }
   140 
   142 
   141 void CMTPPbcGetDevicePropValue::HandlePlaybackCommandCompleteL(CMTPPlaybackCommand* aCmd, TInt aErr)
   143 void CMTPPbcGetDevicePropValue::HandlePlaybackCommandCompleteL(CMTPPlaybackCommand* aCmd, TInt aErr)
   142     {
   144     {
   143     __FLOG(_L8("HandlePlaybackCommandCompleteL - Entry"));
   145     OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_ENTRY );
   144     __FLOG_1(_L8("aErr %d"), aErr);
   146     OstTrace1( TRACE_NORMAL, CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aErr %d", aErr );
       
   147     
   145 
   148 
   146     //Handle the error
   149     //Handle the error
   147     TBool useDefault = EFalse;
   150     TBool useDefault = EFalse;
   148     switch(aErr)
   151     switch(aErr)
   149         {
   152         {
   150         case KPlaybackErrNone:
   153         case KPlaybackErrNone:
   151             {
   154             {
   152             __ASSERT_DEBUG((aCmd != NULL), Panic(EMTPPBDataNullErr));
   155             __ASSERT_DEBUG((aCmd != NULL), Panic(EMTPPBDataNullErr));
   153             __ASSERT_DEBUG((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), Panic(EMTPPBArgumentErr));
   156             __ASSERT_DEBUG((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), Panic(EMTPPBArgumentErr));
   154             __ASSERT_ALWAYS((aCmd != NULL), User::Leave(KErrArgument));
   157             __ASSERT_ALWAYS_OST((aCmd != NULL), OstTrace0( TRACE_ERROR, DUP2_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "Error argument" ), User::Leave(KErrArgument));
   155             __ASSERT_ALWAYS((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), User::Leave(KErrArgument));
   158             __ASSERT_ALWAYS_OST((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), OstTrace0( TRACE_ERROR, DUP3_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "Error argument" ), User::Leave(KErrArgument));
   156             __FLOG_1(_L8("aCmd %d"), aCmd->PlaybackCommand());
   159             OstTrace1( TRACE_NORMAL, DUP1_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aCmd %d", aCmd->PlaybackCommand() );
   157             }
   160             }
   158             break;
   161             break;
   159         case KPlaybackErrContextInvalid:
   162         case KPlaybackErrContextInvalid:
   160             {
   163             {
   161             useDefault = ETrue;
   164             useDefault = ETrue;
   164         case KPlaybackErrDeviceUnavailable:
   167         case KPlaybackErrDeviceUnavailable:
   165             {
   168             {
   166             iPlaybackControlDp.RequestToResetPbCtrl();
   169             iPlaybackControlDp.RequestToResetPbCtrl();
   167             SendResponseL(EMTPRespCodeDeviceBusy);
   170             SendResponseL(EMTPRespCodeDeviceBusy);
   168             }
   171             }
       
   172             OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
   169             return;
   173             return;
   170         default:
   174         default:
   171             {
   175             {
   172             SendResponseL(EMTPRespCodeDeviceBusy);
   176             SendResponseL(EMTPRespCodeDeviceBusy);
   173             }
   177             }
       
   178             OstTraceFunctionExit0( DUP1_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
   174             return;
   179             return;
   175         }
   180         }
   176 
   181 
   177     CMTPPlaybackProperty& property(iPlaybackControlDp.GetPlaybackProperty());
   182     CMTPPlaybackProperty& property(iPlaybackControlDp.GetPlaybackProperty());
   178     TMTPDevicePropertyCode propCode(static_cast<TMTPDevicePropertyCode>
   183     TMTPDevicePropertyCode propCode(static_cast<TMTPDevicePropertyCode>
   235 
   240 
   236     default:
   241     default:
   237         SendResponseL(EMTPRespCodeDevicePropNotSupported);
   242         SendResponseL(EMTPRespCodeDevicePropNotSupported);
   238         break;             
   243         break;             
   239         }
   244         }
   240     __FLOG(_L8("HandlePlaybackCommandCompleteL - Exit"));
   245     OstTraceFunctionExit0( DUP2_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
   241     }
   246     }
   242 
   247