|
1 // Copyright (c) 2006-2009 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 #include <e32cmn.h> |
|
21 |
|
22 #include "mtpservicecommon.h" |
|
23 #include "cmtpserviceconfig.h" |
|
24 #include "cmtpservicemgr.h" |
|
25 #include <mtp/mtpprotocolconstants.h> |
|
26 |
|
27 __FLOG_STMT(_LIT8(KComponent,"ServiceMgr");) |
|
28 |
|
29 |
|
30 /** |
|
31 |
|
32 */ |
|
33 CMTPServiceMgr* CMTPServiceMgr::NewL() |
|
34 { |
|
35 CMTPServiceMgr* self = new (ELeave) CMTPServiceMgr(); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CMTPServiceMgr::CMTPServiceMgr() |
|
43 { |
|
44 |
|
45 } |
|
46 |
|
47 void CMTPServiceMgr::ConstructL() |
|
48 { |
|
49 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
50 __FLOG(_L8("ConstructL - Entry")); |
|
51 |
|
52 iSingletons.OpenL(); |
|
53 iServiceCfg = CMTPServiceConfig::NewL( iSingletons.Fs() ); |
|
54 |
|
55 __FLOG(_L8("ConstructL - Exit")); |
|
56 } |
|
57 /** |
|
58 Destructor |
|
59 */ |
|
60 CMTPServiceMgr::~CMTPServiceMgr() |
|
61 { |
|
62 __FLOG(_L8("~CMTPServiceMgr - Entry")); |
|
63 |
|
64 delete iServiceCfg; |
|
65 |
|
66 iSingletons.Close(); |
|
67 |
|
68 iServiceIDs.Close(); |
|
69 |
|
70 __FLOG(_L8("~CMTPServiceMgr - Exit")); |
|
71 __FLOG_CLOSE; |
|
72 } |
|
73 |
|
74 EXPORT_C TBool CMTPServiceMgr::IsSupportedService( const TUint aServiceID ) const |
|
75 { |
|
76 return ( ServiceInfo( aServiceID ) != NULL ); |
|
77 } |
|
78 |
|
79 EXPORT_C TBool CMTPServiceMgr::IsSupportedService( const TMTPTypeGuid& aPGUID ) const |
|
80 { |
|
81 return iServiceCfg->IsSupportedService( aPGUID ); |
|
82 } |
|
83 |
|
84 TInt CMTPServiceMgr::EnableService(const TMTPTypeGuid& aPGUID, const TUint aServiceID ) |
|
85 { |
|
86 __FLOG(_L8("CMTPServiceMgr::EnableService : ")); |
|
87 |
|
88 if( NULL == iServiceCfg->ServiceInfo(aPGUID) ) |
|
89 { |
|
90 TRAPD(err,LoadServiceL( aPGUID )); |
|
91 if( KErrNone == err) |
|
92 { |
|
93 iServiceCfg->ServiceInfo(aPGUID)->SetServiceID( aServiceID ); |
|
94 } |
|
95 |
|
96 __FLOG_1(_L8("CMTPServiceMgr::EnableService - Fail to Load service! error = %d "), err ); |
|
97 return err; |
|
98 } |
|
99 |
|
100 __FLOG(_L8("CMTPServiceMgr::EnableService - Has been loaded!")); |
|
101 |
|
102 return KErrNone; |
|
103 } |
|
104 |
|
105 TInt CMTPServiceMgr::ServiceTypeOfSupportedService( const TMTPTypeGuid& aPGUID ) const |
|
106 { |
|
107 return iServiceCfg->ServiceTypeOfSupportedService( aPGUID ); |
|
108 } |
|
109 |
|
110 EXPORT_C CMTPServiceInfo* CMTPServiceMgr::ServiceInfo(const TMTPTypeGuid& aServiceGUID )const |
|
111 { |
|
112 return iServiceCfg->ServiceInfo( aServiceGUID ); |
|
113 } |
|
114 |
|
115 EXPORT_C CMTPServiceInfo* CMTPServiceMgr::ServiceInfo(const TUint aServiceID) const |
|
116 { |
|
117 return iServiceCfg->ServiceInfo( aServiceID ); |
|
118 } |
|
119 |
|
120 EXPORT_C TBool CMTPServiceMgr::IsServiceFormatCode(const TUint32 aDatacode ) const |
|
121 { |
|
122 return ( (EMTPFormatCodeVendorExtDynamicStart <= aDatacode) && ( aDatacode <= EMTPFormatCodeVendorExtDynamicEnd ) ); |
|
123 } |
|
124 |
|
125 EXPORT_C const RArray<TUint>& CMTPServiceMgr::GetServiceIDs() const |
|
126 { |
|
127 return iServiceIDs; |
|
128 } |
|
129 |
|
130 TInt CMTPServiceMgr::InsertServiceId(const TUint aServiceId) |
|
131 { |
|
132 return iServiceIDs.InsertInOrder( aServiceId ); |
|
133 } |
|
134 |
|
135 void CMTPServiceMgr::LoadServiceL( const TMTPTypeGuid& aPGUID ) |
|
136 { |
|
137 __FLOG(_L8("CMTPServiceMgr::LoadServiceL - Entry")); |
|
138 |
|
139 iServiceCfg->LoadServiceDataL(aPGUID); |
|
140 |
|
141 __FLOG(_L8("CMTPServiceMgr::LoadServiceL - Exit")); |
|
142 } |
|
143 |
|
144 TInt CMTPServiceMgr::GetServiceProperty( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, CServiceProperty** aServicePropertye) const |
|
145 { |
|
146 __FLOG(_L8("CMTPServiceMgr::GetServiceProperty :")); |
|
147 |
|
148 CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID ); |
|
149 if( NULL == svcinfo ) |
|
150 return KErrNotSupported; |
|
151 |
|
152 CServiceProperty* prop = svcinfo->ServiceProperty( aPKNamespace, aPKID ); |
|
153 if( NULL == prop) |
|
154 return KErrNotSupported; |
|
155 |
|
156 *aServicePropertye = prop; |
|
157 |
|
158 __FLOG(_L8("CMTPServiceMgr::GetServiceProperty Exit")); |
|
159 return KErrNone; |
|
160 } |
|
161 |
|
162 TInt CMTPServiceMgr::GetServiceFormat( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceFormat** aServiceFormat ) const |
|
163 { |
|
164 __FLOG(_L8("CMTPServiceMgr::GetServiceFormat :")); |
|
165 |
|
166 CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID ); |
|
167 if( NULL == svcinfo ) |
|
168 return KErrNotSupported; |
|
169 |
|
170 CServiceFormat* format = svcinfo->ServiceFormat( aGUID ); |
|
171 if( NULL == format) |
|
172 return KErrNotSupported; |
|
173 |
|
174 *aServiceFormat = format; |
|
175 |
|
176 __FLOG(_L8("CMTPServiceMgr::GetServiceFormat Exit")); |
|
177 return KErrNone; |
|
178 } |
|
179 |
|
180 TInt CMTPServiceMgr::GetServiceMethod( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, CServiceMethod** aServiceMethod ) const |
|
181 { |
|
182 __FLOG(_L8("CMTPServiceMgr::GetServiceMethod :")); |
|
183 |
|
184 CMTPServiceInfo* svcinfo = iServiceCfg->ServiceInfo( aServicePGUID ); |
|
185 if( NULL == svcinfo ) |
|
186 return KErrNotSupported; |
|
187 |
|
188 CServiceMethod* method = svcinfo->ServiceMethod( aGUID ); |
|
189 if( NULL == method) |
|
190 return KErrNotSupported; |
|
191 |
|
192 *aServiceMethod = method ; |
|
193 |
|
194 __FLOG(_L8("CMTPServiceMgr::GetServiceMethod - Exit")); |
|
195 return KErrNone; |
|
196 } |
|
197 |
|
198 TInt CMTPServiceMgr::GetServiceId( const TMTPTypeGuid& aServiceGUID, TUint& aServiceID) const |
|
199 { |
|
200 __FLOG(_L8("CMTPServiceMgr::FindServiceId :")); |
|
201 |
|
202 CMTPServiceInfo* svcinfo = ServiceInfo( aServiceGUID ); |
|
203 |
|
204 if( NULL == svcinfo ) |
|
205 { |
|
206 __FLOG(_L8("CMTPServiceMgr::GetServiceId - Invalid serviceID")); |
|
207 |
|
208 return KErrNotFound; |
|
209 } |
|
210 else |
|
211 { |
|
212 aServiceID = svcinfo->ServiceID(); |
|
213 |
|
214 __FLOG_1(_L8("CMTPServiceMgr::GetServiceId = %d"),aServiceID ); |
|
215 |
|
216 return KErrNone; |
|
217 } |
|
218 } |
|
219 |
|
220 TInt CMTPServiceMgr::GetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, TUint& aServicePropertyCode ) const |
|
221 { |
|
222 __FLOG(_L8("CMTPServiceMgr::GetServicePropertyCode :")); |
|
223 |
|
224 CServiceProperty* prop = NULL; |
|
225 TInt err = GetServiceProperty( aServicePGUID, aPKNamespace, aPKID, &prop ); |
|
226 if( KErrNone != err) |
|
227 return err; |
|
228 |
|
229 aServicePropertyCode = prop->Code(); |
|
230 |
|
231 __FLOG(_L8("CMTPServiceMgr::GetServicePropertyCode - Exit")); |
|
232 return KErrNone; |
|
233 } |
|
234 |
|
235 TInt CMTPServiceMgr::SetServicePropertyCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aPKNamespace, const TUint aPKID, const TUint aCurrPropertyCode ) |
|
236 { |
|
237 __FLOG(_L8("CMTPServiceMgr::SetServicePropertyCode :")); |
|
238 |
|
239 CServiceProperty* prop = NULL; |
|
240 TInt err = GetServiceProperty( aServicePGUID, aPKNamespace, aPKID, &prop ); |
|
241 if( KErrNone != err) |
|
242 return err; |
|
243 |
|
244 prop->SetCode( aCurrPropertyCode ); |
|
245 |
|
246 __FLOG(_L8("CMTPServiceMgr::SetServicePropertyCode - Exit")); |
|
247 return KErrNone; |
|
248 } |
|
249 |
|
250 TInt CMTPServiceMgr::GetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceFormatCode ) const |
|
251 { |
|
252 __FLOG(_L8("CMTPServiceMgr::GetServiceFormatCode :")); |
|
253 |
|
254 CServiceFormat* format = NULL; |
|
255 TInt err = GetServiceFormat( aServicePGUID, aGUID, &format ); |
|
256 if( KErrNone != err ) |
|
257 return err; |
|
258 |
|
259 aServiceFormatCode = format->Code(); |
|
260 |
|
261 __FLOG(_L8("CMTPServiceMgr::GetServiceFormatCode - Exit")); |
|
262 return KErrNone; |
|
263 } |
|
264 |
|
265 TInt CMTPServiceMgr::SetServiceFormatCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrFormatCode ) |
|
266 { |
|
267 __FLOG(_L8("CMTPServiceMgr::SetServiceFormatCode :")); |
|
268 |
|
269 CServiceFormat* format = NULL; |
|
270 TInt err = GetServiceFormat( aServicePGUID, aGUID, &format ); |
|
271 if( KErrNone != err ) |
|
272 return err; |
|
273 |
|
274 format->SetCode( aCurrFormatCode ); |
|
275 |
|
276 __FLOG(_L8("CMTPServiceMgr::SetServiceFormatCode - Exit")); |
|
277 return KErrNone; |
|
278 } |
|
279 |
|
280 TInt CMTPServiceMgr::GetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, TUint& aServiceMethodCode ) const |
|
281 { |
|
282 __FLOG(_L8("CMTPServiceMgr::GetServiceMethodCode :")); |
|
283 |
|
284 CServiceMethod* method = NULL; |
|
285 TInt err = GetServiceMethod( aServicePGUID, aGUID, &method ); |
|
286 if ( KErrNone != err ) |
|
287 return err; |
|
288 |
|
289 aServiceMethodCode = method->Code(); |
|
290 |
|
291 __FLOG(_L8("CMTPServiceMgr::GetServiceMethodCode - Exit")); |
|
292 return KErrNone; |
|
293 } |
|
294 |
|
295 TInt CMTPServiceMgr::SetServiceMethodCode( const TMTPTypeGuid& aServicePGUID, const TMTPTypeGuid& aGUID, const TUint aCurrMethodCode ) |
|
296 { |
|
297 __FLOG(_L8("CMTPServiceMgr::SetServiceMethodCode :")); |
|
298 |
|
299 CServiceMethod* method = NULL; |
|
300 TInt err = GetServiceMethod( aServicePGUID, aGUID, &method ); |
|
301 if ( KErrNone != err ) |
|
302 return err; |
|
303 |
|
304 method->SetCode( aCurrMethodCode ); |
|
305 |
|
306 __FLOG(_L8("CMTPServiceMgr::SetServiceMethodCode - Exit")); |
|
307 return KErrNone; |
|
308 } |
|
309 |
|
310 |