|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implement operation GetObjectPropsSupported |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mtp/cmtptypearray.h> |
|
20 |
|
21 #include "cgetobjectpropssupported.h" |
|
22 #include "mmmtpdplogger.h" |
|
23 #include "mmmtpdpconfig.h" |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // Verification data for the GetObjectPropSupported request |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 const TMTPRequestElementInfo KMTPGetObjectPropSupportedPolicy[] = |
|
30 { |
|
31 { |
|
32 TMTPTypeRequest::ERequestParameter1, |
|
33 EMTPElementTypeFormatCode, |
|
34 EMTPElementAttrNone, |
|
35 1, |
|
36 EMTPFormatCodeUndefined, |
|
37 0 |
|
38 }, |
|
39 }; |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CGetObjectPropsSupported::NewL |
|
43 // Two-phase construction method |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C MMmRequestProcessor* CGetObjectPropsSupported::NewL( MMTPDataProviderFramework& aFramework, |
|
47 MMTPConnection& aConnection, |
|
48 MMmMtpDpConfig& aDpConfig ) |
|
49 { |
|
50 CGetObjectPropsSupported* self = new ( ELeave ) CGetObjectPropsSupported( aFramework, aConnection, aDpConfig ); |
|
51 // CleanupStack::PushL( self ); |
|
52 // self->ConstructL(); |
|
53 // CleanupStack::Pop( self ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CGetObjectPropsSupported::~CGetObjectPropsSupported( |
|
59 // Destructor |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 EXPORT_C CGetObjectPropsSupported::~CGetObjectPropsSupported() |
|
63 { |
|
64 delete iObjectPropsSupported; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CGetObjectPropsSupported::~CGetObjectPropsSupported( |
|
69 // Standard c++ constructor |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CGetObjectPropsSupported::CGetObjectPropsSupported( MMTPDataProviderFramework& aFramework, |
|
73 MMTPConnection& aConnection, |
|
74 MMmMtpDpConfig& aDpConfig ) : |
|
75 CRequestProcessor( aFramework, |
|
76 aConnection, |
|
77 sizeof( KMTPGetObjectPropSupportedPolicy ) / sizeof( TMTPRequestElementInfo ), |
|
78 KMTPGetObjectPropSupportedPolicy ), |
|
79 iDpConfig( aDpConfig ) |
|
80 { |
|
81 PRINT( _L( "Operation: GetObjectPropsSupported(0x9801)" ) ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CGetObjectPropsSupported::ServiceL |
|
86 // GetObjectPropSupported request handler |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 EXPORT_C void CGetObjectPropsSupported::ServiceL() |
|
90 { |
|
91 delete iObjectPropsSupported; |
|
92 iObjectPropsSupported = NULL; |
|
93 iObjectPropsSupported = CMTPTypeArray::NewL( EMTPTypeAUINT16 ); |
|
94 |
|
95 TUint32 formatCode = Request().Uint32( TMTPTypeRequest::ERequestParameter1 ); |
|
96 PRINT1( _L( "MM MTP <> CGetObjectPropsSupported::ServiceL formatCode = 0x%x" ), formatCode ); |
|
97 |
|
98 const RArray<TUint>* format = iDpConfig.GetSupportedFormat(); |
|
99 TInt count = format->Count(); |
|
100 |
|
101 TInt i = 0; |
|
102 for ( ; i < count; i++ ) |
|
103 { |
|
104 if ( formatCode == (*format)[i] ) // only process the support format |
|
105 { |
|
106 const RArray<TUint>* properties; |
|
107 properties = iDpConfig.GetSupportedPropertiesL( formatCode ) ; |
|
108 |
|
109 TInt count = properties->Count(); |
|
110 |
|
111 PRINT1( _L( "MM MTP <> CGetObjectPropsSupported::ServiceL properties count = %d"), count ); |
|
112 for ( TInt j = 0; j < count; j++ ) |
|
113 { |
|
114 iObjectPropsSupported->AppendUintL( (*properties)[j] ); |
|
115 } |
|
116 |
|
117 break; |
|
118 } |
|
119 } |
|
120 |
|
121 if( i == count ) |
|
122 SendResponseL( EMTPRespCodeInvalidObjectFormatCode ); |
|
123 else |
|
124 SendDataL( *iObjectPropsSupported ); |
|
125 } |
|
126 |
|
127 // end of file |