|
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: |
|
15 * |
|
16 */ |
|
17 #include "SCPDBDebug.h" |
|
18 #include "SCPParamDBController.h" |
|
19 #include <TerminalControl3rdPartyAPI.h> |
|
20 |
|
21 #include <centralrepository.h> |
|
22 #include "DmEventNotifierCommon.h" |
|
23 #include "DmEventNotifierCRKeys.h" |
|
24 #include <e32property.h> |
|
25 #include <apgcli.h> |
|
26 #include <apacmdln.h> |
|
27 |
|
28 void CSCPParamDBController :: ConstructL() { |
|
29 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL() >>>")); |
|
30 |
|
31 _SCPDB_LOG(_L("[CSCPParamDBController]->INFO: Creating iParamDB")); |
|
32 iParamDB = CSCPParamDB :: NewL(); |
|
33 _SCPDB_LOG(_L("[CSCPParamDBController]-> iParamDB created successfully...")); |
|
34 |
|
35 /* |
|
36 * Invocation of sw-handler. This is done only once hence cenrep key is used. |
|
37 */ |
|
38 |
|
39 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL(): Checking for KAppUidDmEventNotifier cenrep ")); |
|
40 CRepository* centrep = NULL; |
|
41 |
|
42 TRAPD(err, centrep = CRepository::NewL( TUid::Uid(KAppUidDmEventNotifier) )); |
|
43 |
|
44 if(err == KErrNone) { |
|
45 TInt lVal = KErrNone; |
|
46 TInt err_val = centrep->Get(KDmEventNotifierEnabled, lVal); |
|
47 |
|
48 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL(): cenrep KDmEventNotifierEnabled value: %d "), lVal); |
|
49 if(err_val == KErrNone && 0 == lVal) { |
|
50 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL(): RApaLsSession connection >>> ")); |
|
51 RApaLsSession apaLsSession; |
|
52 User :: LeaveIfError(apaLsSession.Connect()); |
|
53 TApaAppInfo appInfo; |
|
54 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL(): RApaLsSession connection successful ")); |
|
55 |
|
56 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL(): run dmeventnotifier.exe ")); |
|
57 //apaLsSession.GetAppInfo(appInfo, aUid); Required only if handle is registered through _reg file. |
|
58 #if defined (__WINS__) // ifdef (__WINSCW__) |
|
59 _LIT(KExampleTaskHandlerExe, "C:\\sys\\bin\\dmeventnotifier.exe"); |
|
60 #else |
|
61 _LIT(KExampleTaskHandlerExe, "Z:\\Sys\\Bin\\dmeventnotifier.exe"); |
|
62 #endif |
|
63 |
|
64 appInfo.iFullName = KExampleTaskHandlerExe; |
|
65 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
66 cmdLine->SetExecutableNameL( appInfo.iFullName ); |
|
67 TBuf<KMaxFileName> temp; |
|
68 temp.Copy (appInfo.iFullName); |
|
69 TInt err = apaLsSession.StartApp(*cmdLine); |
|
70 |
|
71 User :: LeaveIfError(err); |
|
72 CleanupStack :: PopAndDestroy(cmdLine); |
|
73 apaLsSession.Close(); |
|
74 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL(): started dmeventnotifier.exe successfully")); |
|
75 } |
|
76 } |
|
77 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL(): Checking KAppUidDmEventNotifier cenrep completed ")); |
|
78 |
|
79 delete centrep; |
|
80 _SCPDB_LOG(_L("[CSCPParamDBController]-> ConstructL() <<<")); |
|
81 } |
|
82 |
|
83 EXPORT_C CSCPParamDBController :: ~CSCPParamDBController() { |
|
84 if(iParamDB != NULL) { |
|
85 delete iParamDB; |
|
86 } |
|
87 } |
|
88 |
|
89 EXPORT_C CSCPParamDBController* CSCPParamDBController :: NewL() { |
|
90 _SCPDB_LOG(_L("[CSCPParamDBController]-> NewL() >>>")); |
|
91 CSCPParamDBController* lSelf = new(ELeave) CSCPParamDBController(); |
|
92 CleanupStack :: PushL(lSelf); |
|
93 lSelf->ConstructL(); |
|
94 CleanupStack :: Pop(); |
|
95 _SCPDB_LOG(_L("[CSCPParamDBController]-> NewL() <<<")); |
|
96 return lSelf; |
|
97 } |
|
98 |
|
99 EXPORT_C CSCPParamDBController* CSCPParamDBController :: NewLC() { |
|
100 _SCPDB_LOG(_L("[CSCPParamDBController]-> NewLC() >>>")); |
|
101 CSCPParamDBController* lSelf = NewL(); |
|
102 CleanupStack :: PushL(lSelf); |
|
103 _SCPDB_LOG(_L("[CSCPParamDBController]-> NewLC() <<<")); |
|
104 return lSelf; |
|
105 } |
|
106 |
|
107 EXPORT_C TInt CSCPParamDBController :: SetValueL(TInt aParamID, const TInt32 aValue, const TInt32 aApp) { |
|
108 switch(aParamID) { |
|
109 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
110 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
111 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
112 case RTerminalControl3rdPartySession :: EPasscodeRequireUpperAndLower: |
|
113 case RTerminalControl3rdPartySession :: EPasscodeRequireCharsAndNumbers: |
|
114 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
115 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
116 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
117 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
118 case RTerminalControl3rdPartySession :: EPasscodeCheckSpecificStrings: |
|
119 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
120 case RTerminalControl3rdPartySession :: EPasscodeConsecutiveNumbers: |
|
121 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
122 case RTerminalControl3rdPartySession :: EPasscodeMinSpecialCharacters: |
|
123 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: |
|
124 break; |
|
125 default: |
|
126 return KErrNotSupported; |
|
127 } |
|
128 |
|
129 if(aValue < 0) { |
|
130 return KErrArgument; |
|
131 } |
|
132 |
|
133 return iParamDB->SetValueForParameterL(aParamID, aValue, aApp); |
|
134 } |
|
135 |
|
136 EXPORT_C TInt CSCPParamDBController :: SetValuesL(TInt aParamID, const RPointerArray <HBufC>& aParamValues, const TInt32 aApp) { |
|
137 switch(aParamID) { |
|
138 case RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific: |
|
139 break; |
|
140 default: |
|
141 return KErrNotSupported; |
|
142 } |
|
143 |
|
144 return iParamDB->SetValuesForParameterL(aParamID, aParamValues, aApp); |
|
145 } |
|
146 |
|
147 EXPORT_C TInt CSCPParamDBController :: GetValueL(TInt aParamID, TInt32& aValue, TInt32& aApp) { |
|
148 switch(aParamID) { |
|
149 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
150 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
151 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
152 case RTerminalControl3rdPartySession :: EPasscodeRequireUpperAndLower: |
|
153 case RTerminalControl3rdPartySession :: EPasscodeRequireCharsAndNumbers: |
|
154 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
155 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
156 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
157 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
158 case RTerminalControl3rdPartySession :: EPasscodeCheckSpecificStrings: |
|
159 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
160 case RTerminalControl3rdPartySession :: EPasscodeConsecutiveNumbers: |
|
161 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
162 case RTerminalControl3rdPartySession :: EPasscodeMinSpecialCharacters: |
|
163 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: |
|
164 break; |
|
165 default: |
|
166 return KErrNotSupported; |
|
167 } |
|
168 |
|
169 return iParamDB->GetValueForParameterL(aParamID, aValue, aApp); |
|
170 } |
|
171 |
|
172 EXPORT_C TInt CSCPParamDBController :: GetValuesL(TInt aParamID, RPointerArray <HBufC>& aParamValues, const TInt32 aApp) { |
|
173 switch(aParamID) { |
|
174 case RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific: |
|
175 break; |
|
176 default: |
|
177 return KErrNotSupported; |
|
178 } |
|
179 |
|
180 return iParamDB->GetValuesForParameterL(aParamID, aParamValues, aApp); |
|
181 } |
|
182 |
|
183 EXPORT_C TInt CSCPParamDBController :: ListApplicationsL(RArray <TUid>& aIDArray) { |
|
184 return iParamDB->GetApplicationIDListL(aIDArray); |
|
185 } |
|
186 |
|
187 EXPORT_C TBool CSCPParamDBController :: IsParamValueSharedL(HBufC* aParamValue, const TInt32 aApp) { |
|
188 return iParamDB->IsParamValueSharedL(aParamValue, aApp); |
|
189 } |
|
190 |
|
191 EXPORT_C TInt CSCPParamDBController :: DropValuesL(TInt aParamID, const TInt32 aApp) { |
|
192 switch(aParamID) { |
|
193 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
194 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
195 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
196 case RTerminalControl3rdPartySession :: EPasscodeRequireUpperAndLower: |
|
197 case RTerminalControl3rdPartySession :: EPasscodeRequireCharsAndNumbers: |
|
198 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
199 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
200 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
201 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
202 case RTerminalControl3rdPartySession :: EPasscodeCheckSpecificStrings: |
|
203 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
204 case RTerminalControl3rdPartySession :: EPasscodeConsecutiveNumbers: |
|
205 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
206 case RTerminalControl3rdPartySession :: EPasscodeMinSpecialCharacters: |
|
207 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: |
|
208 case RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific: |
|
209 break; |
|
210 default: |
|
211 return KErrNotSupported; |
|
212 } |
|
213 |
|
214 return iParamDB->DropValuesL(aParamID, aApp); |
|
215 } |
|
216 |
|
217 EXPORT_C TInt CSCPParamDBController :: DropValuesL(TInt aParamID, RPointerArray <HBufC>& aParamValues, const TInt32 aApp) { |
|
218 switch(aParamID) { |
|
219 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
220 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
221 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
222 case RTerminalControl3rdPartySession :: EPasscodeRequireUpperAndLower: |
|
223 case RTerminalControl3rdPartySession :: EPasscodeRequireCharsAndNumbers: |
|
224 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
225 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
226 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
227 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
228 case RTerminalControl3rdPartySession :: EPasscodeCheckSpecificStrings: |
|
229 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
230 case RTerminalControl3rdPartySession :: EPasscodeConsecutiveNumbers: |
|
231 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
232 case RTerminalControl3rdPartySession :: EPasscodeMinSpecialCharacters: |
|
233 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: |
|
234 case RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific: |
|
235 break; |
|
236 default: |
|
237 return KErrNotSupported; |
|
238 } |
|
239 |
|
240 return iParamDB->DropValuesL(aParamID, aParamValues, aApp); |
|
241 } |
|
242 |
|
243 EXPORT_C TInt CSCPParamDBController :: ListParamsUsedByAppL(RArray <TInt>& aParamIds, const TInt32 aApp) { |
|
244 return iParamDB->ListParamsUsedByAppL(aParamIds, aApp); |
|
245 } |
|
246 |
|
247 EXPORT_C TInt CSCPParamDBController :: ListEntriesL(RArray <TInt32>& aNumCols, RPointerArray <HBufC>& aDesCols, const TInt32 aApp) { |
|
248 return iParamDB->ListEntriesL(aNumCols, aDesCols, aApp); |
|
249 } |