|
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: Implementation of DSCtrl plug-in adapter for DCMO |
|
15 * |
|
16 */ |
|
17 |
|
18 //SYSTEM INCLUDES |
|
19 #include <centralrepository.h> |
|
20 #include <dcmo.rsg> |
|
21 #include <e32base.h> |
|
22 #include <stringresourcereader.h> |
|
23 #include <f32file.h> |
|
24 #include <data_caging_path_literals.hrh> |
|
25 |
|
26 //USER INCLUDES |
|
27 #include "nsmldsctrldcmoadapter.h" |
|
28 |
|
29 // CONSTANTS |
|
30 const TUid KCRUidDSDCMOConfig = { 0x20022FC0 }; |
|
31 const TInt KNsmlDesktopSync = 0; // 0x0000000 defined in DS cenrep |
|
32 |
|
33 // Name of the Plug-in adapter |
|
34 _LIT(KNsmlDesktopSyncTitle, "Desktop Sync"); |
|
35 // Description for Desktop Sync adapter |
|
36 _LIT(KNsmlDSDCMODescription, "Used to enable/disable the Desktop Sync." ); //use Nsml????? |
|
37 // Path used for fetching the string to be displayed |
|
38 _LIT( KRuntimeResourceFileName, "z:dcmo.rsc" ); |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CNsmlDsCtrlDCMOAdapter::NewL |
|
44 // Two-phased constructor. |
|
45 // ----------------------------------------------------------------------------- |
|
46 CNsmlDsCtrlDCMOAdapter* CNsmlDsCtrlDCMOAdapter::NewL(TAny* aParams) |
|
47 { |
|
48 CNsmlDsCtrlDCMOAdapter* self=new(ELeave) CNsmlDsCtrlDCMOAdapter(aParams); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop(); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CNsmlDsCtrlDCMOAdapter::~CNsmlDsCtrlDCMOAdapter() |
|
57 // Destructor. |
|
58 // ----------------------------------------------------------------------------- |
|
59 CNsmlDsCtrlDCMOAdapter::~CNsmlDsCtrlDCMOAdapter() |
|
60 { |
|
61 delete iProperty; |
|
62 delete iDescription; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CNsmlDsCtrlDCMOAdapter::CNsmlDsCtrlDCMOAdapter |
|
67 // Constructor. |
|
68 // ----------------------------------------------------------------------------- |
|
69 CNsmlDsCtrlDCMOAdapter::CNsmlDsCtrlDCMOAdapter(TAny* aInitParams) |
|
70 : iInitParams((CDCMOInterface::TDCMOInterfaceInitParams*)aInitParams) |
|
71 { |
|
72 // See ConstructL() for initialisation completion. |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CNsmlDsCtrlDCMOAdapter::ConstructL() |
|
77 // Two-phased constructor. |
|
78 // ----------------------------------------------------------------------------- |
|
79 void CNsmlDsCtrlDCMOAdapter::ConstructL() |
|
80 // Safely complete the initialization of the constructed object |
|
81 { |
|
82 // Set up the data to pass back |
|
83 if(iInitParams->descriptor) |
|
84 { |
|
85 iProperty = (iInitParams->descriptor)->AllocL(); |
|
86 } |
|
87 else |
|
88 { |
|
89 iProperty = KNsmlDesktopSyncTitle().AllocL(); |
|
90 } |
|
91 iDescription = KNsmlDSDCMODescription().AllocL(); |
|
92 } |
|
93 |
|
94 |
|
95 // Implementation of CDCMOInterface |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CNsmlDsCtrlDCMOAdapter::GetDCMOPluginIntAttributeValueL |
|
98 // - Get the Value of any attribute which is an integer |
|
99 // - If its existing attribute, then success is returned. Else Failure. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 TDCMOStatus CNsmlDsCtrlDCMOAdapter::GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue) |
|
103 { |
|
104 TDCMOStatus status(EDcmoSuccess); |
|
105 TInt err(KErrNone); |
|
106 |
|
107 switch(aId) |
|
108 { |
|
109 case EGroup: { |
|
110 aValue = ESoftware; |
|
111 } |
|
112 break; |
|
113 case ENotifyUser: { |
|
114 aValue = 0; |
|
115 } |
|
116 break; |
|
117 case EAttached: { |
|
118 status = EDcmoNotSupported; |
|
119 } |
|
120 break; |
|
121 case EEnabled: { |
|
122 CRepository * rep = CRepository::NewLC( KCRUidDSDCMOConfig ); |
|
123 err = rep->Get( KNsmlDesktopSync, aValue ); |
|
124 if(err != KErrNone) |
|
125 { |
|
126 status = EDcmoFail; |
|
127 } |
|
128 CleanupStack::PopAndDestroy( rep ); |
|
129 } |
|
130 break; |
|
131 case EDenyUserEnable: { |
|
132 aValue = 1; // DenyUserEnable |
|
133 } |
|
134 break; |
|
135 default: { |
|
136 status = EDcmoNotFound; |
|
137 } |
|
138 } |
|
139 |
|
140 return status; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CNsmlDsCtrlDCMOAdapter::GetDCMOPluginStrAttributeValueL |
|
145 // - Get the Value of any attribute which is a string |
|
146 // - If its existing attribute, then success is returned. Else Failure. |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 TDCMOStatus CNsmlDsCtrlDCMOAdapter::GetDCMOPluginStrAttributeValueL(TDCMONode aId, TDes& aStrValue) |
|
150 { |
|
151 TDCMOStatus status(EDcmoSuccess); |
|
152 switch(aId) |
|
153 { |
|
154 case EProperty: { |
|
155 aStrValue = *iProperty; |
|
156 } |
|
157 break; |
|
158 |
|
159 case EDescription: { |
|
160 aStrValue = *iDescription; |
|
161 } |
|
162 break; |
|
163 default: { |
|
164 status = EDcmoNotFound; |
|
165 } |
|
166 } |
|
167 return status; |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CNsmlDsCtrlDCMOAdapter::SetDCMOPluginIntAttributeValueL |
|
172 // - Set the Value of any attribute which is an integer |
|
173 // - If its existing attribute, then success is returned. Else Failure. |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TDCMOStatus CNsmlDsCtrlDCMOAdapter::SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue) |
|
177 { |
|
178 TDCMOStatus status(EDcmoFail); |
|
179 TInt err(KErrNone); |
|
180 switch(aId) |
|
181 { |
|
182 case EDenyUserEnable: |
|
183 case ENotifyUser: |
|
184 break; |
|
185 case EEnable: { |
|
186 CRepository * rep = CRepository::NewLC( KCRUidDSDCMOConfig ); |
|
187 rep->Set( KNsmlDesktopSync, aValue ); |
|
188 CleanupStack::PopAndDestroy( rep ); |
|
189 } |
|
190 break; |
|
191 } |
|
192 if(err == KErrNone) |
|
193 { |
|
194 status = EDcmoSuccess; |
|
195 } |
|
196 return status; |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CNsmlDsCtrlDCMOAdapter::SetDCMOPluginStrAttributeValueL |
|
201 // - Set the Value of any attribute which is a string |
|
202 // - Here no Attribute comes as we dont have any String value to be set |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 TDCMOStatus CNsmlDsCtrlDCMOAdapter::SetDCMOPluginStrAttributeValueL(TDCMONode /*aId */, const TDes& /*aStrValue */) |
|
206 { |
|
207 // Nothing to do |
|
208 return EDcmoNotSupported; |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CNsmlDsCtrlDCMOAdapter::GetLocalizedNameL |
|
213 // - Get localised name of the Plug-in |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CNsmlDsCtrlDCMOAdapter::GetLocalizedNameL (HBufC*& aLocName) |
|
217 { |
|
218 TFileName myFileName; |
|
219 TParse parseObj; |
|
220 parseObj.Set( KRuntimeResourceFileName(), &KDC_RESOURCE_FILES_DIR,NULL ); |
|
221 myFileName = parseObj.FullName(); |
|
222 CStringResourceReader* readPluginName = CStringResourceReader::NewL( myFileName ); |
|
223 CleanupStack::PushL(readPluginName); |
|
224 TPtrC buf; |
|
225 buf.Set(readPluginName->ReadResourceString(R_DM_RUN_TIME_VAR_DESKTOP_SYNC)); |
|
226 aLocName = buf.AllocL() ; |
|
227 CleanupStack::PopAndDestroy(readPluginName); |
|
228 } |