29
|
1 |
// Copyright (c) 2010 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 "mtpplaybackcontroldpprocessor.h"
|
|
22 |
#include "cmtprequestprocessor.h"
|
|
23 |
#include "cmtppbcgetdevicepropdesc.h"
|
|
24 |
#include "cmtppbcgetdevicepropvalue.h"
|
|
25 |
#include "cmtppbcsetdevicepropvalue.h"
|
|
26 |
#include "cmtppbcresetdevicepropvalue.h"
|
|
27 |
#include "cmtppbcskip.h"
|
|
28 |
#include "cmtprequestunknown.h"
|
|
29 |
|
|
30 |
typedef MMTPRequestProcessor*(*TMTPPlaybackRequestProcessorCreateFunc)(
|
|
31 |
MMTPDataProviderFramework& aFramework,
|
|
32 |
MMTPConnection& aConnection,
|
|
33 |
CMTPPlaybackControlDataProvider& aDataProvider);
|
|
34 |
|
|
35 |
/**
|
|
36 |
Defines an entry which maps from operation code to the request processor
|
|
37 |
|
|
38 |
@internalComponent
|
|
39 |
*/
|
|
40 |
typedef struct
|
|
41 |
{
|
|
42 |
TUint16 iOperationCode;
|
|
43 |
TMTPPlaybackRequestProcessorCreateFunc iCreateFunc;
|
|
44 |
} TMTPPlaybackRequestProcessorEntry;
|
|
45 |
|
|
46 |
/**
|
|
47 |
Playback control data provider mapping table from request ID to factory method of the request processor
|
|
48 |
*/
|
|
49 |
static const TMTPPlaybackRequestProcessorEntry KMTPRequestProcessorTable[] =
|
|
50 |
{
|
|
51 |
{EMTPOpCodeGetDevicePropDesc, CMTPPbcGetDevicePropDesc::NewL},
|
|
52 |
{EMTPOpCodeGetDevicePropValue, CMTPPbcGetDevicePropValue::NewL},
|
|
53 |
{EMTPOpCodeSetDevicePropValue, CMTPPbcSetDevicePropValue::NewL},
|
|
54 |
{EMTPOpCodeResetDevicePropValue, CMTPPbcResetDevicePropValue::NewL},
|
|
55 |
{EMTPOpCodeSkip, CMTPPbcSkip::NewL},
|
|
56 |
};
|
|
57 |
|
|
58 |
/**
|
|
59 |
Create a request processor that matches the request
|
|
60 |
@param aPlugin The reference to the data provider plugin
|
|
61 |
@param aFramework The reference to the data provider framework
|
|
62 |
@param aRequest The request to be processed
|
|
63 |
@param aConnection The connection from which the request comes from
|
|
64 |
@return a pointer to the request processor
|
|
65 |
*/
|
|
66 |
MMTPRequestProcessor* MTPPlaybackControlDpProcessor::CreateL(
|
|
67 |
MMTPDataProviderFramework& aFramework,
|
|
68 |
const TMTPTypeRequest& aRequest,
|
|
69 |
MMTPConnection& aConnection,
|
|
70 |
CMTPPlaybackControlDataProvider& aDataProvider)
|
|
71 |
{
|
|
72 |
TMTPPlaybackRequestProcessorCreateFunc createFunc = NULL;
|
|
73 |
TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
|
|
74 |
TInt count = sizeof(KMTPRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry);
|
|
75 |
for(TInt i = 0; i < count; i++)
|
|
76 |
{
|
|
77 |
if(KMTPRequestProcessorTable[i].iOperationCode == operationCode)
|
|
78 |
{
|
|
79 |
createFunc = KMTPRequestProcessorTable[i].iCreateFunc;
|
|
80 |
break;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
if(!createFunc)
|
|
85 |
{
|
|
86 |
return CMTPRequestUnknown::NewL(aFramework, aConnection);
|
|
87 |
}
|
|
88 |
else
|
|
89 |
{
|
|
90 |
return (*createFunc)(aFramework, aConnection, aDataProvider);
|
|
91 |
}
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
|