|
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 #include <mtp/cmtptypearray.h> |
|
17 #include <mtp/mmtpdataproviderframework.h> |
|
18 #include <mtp/mtpdatatypeconstants.h> |
|
19 #include <mtp/mmtpobjectmgr.h> |
|
20 #include <mtp/tmtptyperequest.h> |
|
21 |
|
22 #include "cmtpgetserviceids.h" |
|
23 #include "mtpdevdppanic.h" |
|
24 #include "mtpdevicedpconst.h" |
|
25 #include "cmtpservicemgr.h" |
|
26 |
|
27 |
|
28 /** |
|
29 GetServiceIds request processor factory method. |
|
30 @param aPlugin The data provider plugin. |
|
31 @param aFramework The data provider framework |
|
32 @param aConnection The connection on which the request is being processed. |
|
33 @return A pointer to an GetStorageIds request processor. Ownership IS |
|
34 transfered. |
|
35 @leave One of the system wide error codes, if a processing failure occurs. |
|
36 */ |
|
37 MMTPRequestProcessor* CMTPGetServiceIds::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) |
|
38 { |
|
39 CMTPGetServiceIds* self = new (ELeave) CMTPGetServiceIds(aFramework, aConnection); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 /** |
|
47 Destructor. |
|
48 */ |
|
49 CMTPGetServiceIds::~CMTPGetServiceIds() |
|
50 { |
|
51 delete iServiceIds; |
|
52 iFrameworkSingletons.Close(); |
|
53 } |
|
54 |
|
55 /** |
|
56 Constructor. |
|
57 */ |
|
58 CMTPGetServiceIds::CMTPGetServiceIds(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : |
|
59 CMTPRequestProcessor(aFramework, aConnection, 0, NULL) |
|
60 { |
|
61 |
|
62 } |
|
63 |
|
64 void CMTPGetServiceIds::ServiceL() |
|
65 { |
|
66 BuildServiceIdsL(); |
|
67 SendDataL(*iServiceIds); |
|
68 } |
|
69 |
|
70 /** |
|
71 Second-phase constructor. |
|
72 */ |
|
73 void CMTPGetServiceIds::ConstructL() |
|
74 { |
|
75 iFrameworkSingletons.OpenL(); |
|
76 } |
|
77 |
|
78 /** |
|
79 Constructs an MTP ServiceID array dataset. |
|
80 @leave One of the system wide error codes, if a processing failure occurs. |
|
81 */ |
|
82 void CMTPGetServiceIds::BuildServiceIdsL() |
|
83 { |
|
84 // Retrieve the available ServiceIDs |
|
85 |
|
86 // Construct the dataset. |
|
87 iServiceIds = CMTPTypeArray::NewL(EMTPTypeAUINT32); |
|
88 TInt count = iFrameworkSingletons.ServiceMgr().GetServiceIDs().Count(); |
|
89 RArray<TUint> ServiceIDs = iFrameworkSingletons.ServiceMgr().GetServiceIDs(); |
|
90 for (TUint i(0); (i < count); i++) |
|
91 { |
|
92 iServiceIds->AppendUintL(ServiceIDs[i]); |
|
93 } |
|
94 |
|
95 } |
|
96 |