45 const TUint KHistoryGranularity = 0x8; |
47 const TUint KHistoryGranularity = 0x8; |
46 const TUint KPermittedDrvRangeBufLen = 0x3; |
48 const TUint KPermittedDrvRangeBufLen = 0x3; |
47 |
49 |
48 CReferencePolicyPlugin::~CReferencePolicyPlugin() |
50 CReferencePolicyPlugin::~CReferencePolicyPlugin() |
49 { |
51 { |
50 LOG_FUNC |
52 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_CREFERENCEPOLICYPLUGIN_DES_ENTRY ); |
|
53 |
51 Cancel(); |
54 Cancel(); |
52 ClearHistory(); // Remove all buffered history record. |
55 ClearHistory(); // Remove all buffered history record. |
53 delete iRepository; |
56 delete iRepository; |
54 delete iNotificationMan; |
57 delete iNotificationMan; |
55 iFs.Close(); |
58 iFs.Close(); |
|
59 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_CREFERENCEPOLICYPLUGIN_DES_EXIT ); |
56 } |
60 } |
57 |
61 |
58 CReferencePolicyPlugin* CReferencePolicyPlugin::NewL() |
62 CReferencePolicyPlugin* CReferencePolicyPlugin::NewL() |
59 { |
63 { |
60 LOG_STATIC_FUNC_ENTRY |
64 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_NEWL_ENTRY ); |
|
65 |
61 CReferencePolicyPlugin* self = new (ELeave) CReferencePolicyPlugin; |
66 CReferencePolicyPlugin* self = new (ELeave) CReferencePolicyPlugin; |
62 CleanupStack::PushL(self); |
67 CleanupStack::PushL(self); |
63 self->ConstructL(); |
68 self->ConstructL(); |
64 CleanupStack::Pop(self); |
69 CleanupStack::Pop(self); |
65 |
70 |
|
71 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_NEWL_EXIT ); |
66 return self; |
72 return self; |
67 } |
73 } |
68 |
74 |
69 void CReferencePolicyPlugin::RetrieveDriveLetterL(TText& aDriveName, |
75 void CReferencePolicyPlugin::RetrieveDriveLetterL(TText& aDriveName, |
70 const TPolicyRequestData& aData, TRequestStatus& aStatus) |
76 const TPolicyRequestData& aData, TRequestStatus& aStatus) |
71 { |
77 { |
72 LOG_FUNC |
78 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_RETRIEVEDRIVELETTERL_TTEXT_TPOLICYREQUESTDATA_TREQUESTSTATUS_ENTRY ); |
|
79 |
73 Cancel(); |
80 Cancel(); |
74 aStatus = KRequestPending; |
81 aStatus = KRequestPending; |
75 iClientStatus = &aStatus; |
82 iClientStatus = &aStatus; |
76 |
83 |
77 RetrieveDriveLetterL(aDriveName, aData); |
84 RetrieveDriveLetterL(aDriveName, aData); |
78 // In a licensee owned policy plugin, it shall complete client |
85 // In a licensee owned policy plugin, it shall complete client |
79 // request in RunL() in general |
86 // request in RunL() in general |
80 Complete(KErrNone); |
87 Complete(KErrNone); |
|
88 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_RETRIEVEDRIVELETTERL_TTEXT_TPOLICYREQUESTDATA_TREQUESTSTATUS_EXIT ); |
81 } |
89 } |
82 |
90 |
83 void CReferencePolicyPlugin::CancelRetrieveDriveLetter() |
91 void CReferencePolicyPlugin::CancelRetrieveDriveLetter() |
84 { |
92 { |
85 LOG_FUNC |
93 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_CANCELRETRIEVEDRIVELETTER_ENTRY ); |
|
94 |
86 Cancel(); |
95 Cancel(); |
|
96 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_CANCELRETRIEVEDRIVELETTER_EXIT ); |
87 } |
97 } |
88 |
98 |
89 void CReferencePolicyPlugin::SaveLatestMountInfoL( |
99 void CReferencePolicyPlugin::SaveLatestMountInfoL( |
90 const TPolicyMountRecord& aData, TRequestStatus& aStatus) |
100 const TPolicyMountRecord& aData, TRequestStatus& aStatus) |
91 { |
101 { |
92 LOG_FUNC |
102 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_SAVELATESTMOUNTINFOL_TPOLICYMOUNTRECORD_TREQUESTSTATUS_ENTRY ); |
|
103 |
93 Cancel(); |
104 Cancel(); |
94 aStatus = KRequestPending; |
105 aStatus = KRequestPending; |
95 iClientStatus = &aStatus; |
106 iClientStatus = &aStatus; |
96 |
107 |
97 SaveLatestMountInfoL(aData); |
108 SaveLatestMountInfoL(aData); |
98 // In a licensee owned policy plugin, it shall complete client |
109 // In a licensee owned policy plugin, it shall complete client |
99 // request in RunL() in general |
110 // request in RunL() in general |
100 Complete(KErrNone); |
111 Complete(KErrNone); |
|
112 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_SAVELATESTMOUNTINFOL_TPOLICYMOUNTRECORD_TREQUESTSTATUS_EXIT ); |
101 } |
113 } |
102 |
114 |
103 void CReferencePolicyPlugin::CancelSaveLatestMountInfo() |
115 void CReferencePolicyPlugin::CancelSaveLatestMountInfo() |
104 { |
116 { |
105 LOG_FUNC |
117 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_CANCELSAVELATESTMOUNTINFO_ENTRY ); |
|
118 |
106 Cancel(); |
119 Cancel(); |
|
120 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_CANCELSAVELATESTMOUNTINFO_EXIT ); |
107 } |
121 } |
108 |
122 |
109 void CReferencePolicyPlugin::SendErrorNotificationL( |
123 void CReferencePolicyPlugin::SendErrorNotificationL( |
110 const THostMsErrData& aErrData) |
124 const THostMsErrData& aErrData) |
111 { |
125 { |
112 LOG_FUNC |
126 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_SENDERRORNOTIFICATIONL_ENTRY ); |
|
127 |
113 iNotificationMan->SendErrorNotificationL(aErrData); |
128 iNotificationMan->SendErrorNotificationL(aErrData); |
|
129 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_SENDERRORNOTIFICATIONL_EXIT ); |
114 } |
130 } |
115 |
131 |
116 void CReferencePolicyPlugin::GetSuspensionPolicy(TSuspensionPolicy& aPolicy) |
132 void CReferencePolicyPlugin::GetSuspensionPolicy(TSuspensionPolicy& aPolicy) |
117 { |
133 { |
118 LOG_FUNC |
134 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_GETSUSPENSIONPOLICY_ENTRY ); |
|
135 |
119 aPolicy = iSuspensionPolicy; |
136 aPolicy = iSuspensionPolicy; |
|
137 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_GETSUSPENSIONPOLICY_EXIT ); |
120 } |
138 } |
121 |
139 |
122 void CReferencePolicyPlugin::DoCancel() |
140 void CReferencePolicyPlugin::DoCancel() |
123 { |
141 { |
124 LOG_FUNC |
142 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_DOCANCEL_ENTRY ); |
|
143 |
125 // No more work need to do in current implementation of reference |
144 // No more work need to do in current implementation of reference |
126 // policy plugin. |
145 // policy plugin. |
127 // In a licensee owned policy plugin, it shall complete client |
146 // In a licensee owned policy plugin, it shall complete client |
128 // request here with KErrCancel. |
147 // request here with KErrCancel. |
|
148 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_DOCANCEL_EXIT ); |
129 } |
149 } |
130 |
150 |
131 void CReferencePolicyPlugin::RunL() |
151 void CReferencePolicyPlugin::RunL() |
132 { |
152 { |
133 LOG_FUNC |
153 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_RUNL_ENTRY ); |
|
154 |
134 // No more work need to do in current implementation of reference |
155 // No more work need to do in current implementation of reference |
135 // policy plugin. |
156 // policy plugin. |
136 // In a licensee owned policy plugin, it shall complete client |
157 // In a licensee owned policy plugin, it shall complete client |
137 // request here with a proper error code. |
158 // request here with a proper error code. |
|
159 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_RUNL_EXIT ); |
138 } |
160 } |
139 |
161 |
140 CReferencePolicyPlugin::CReferencePolicyPlugin() : |
162 CReferencePolicyPlugin::CReferencePolicyPlugin() : |
141 CMsmmPolicyPluginBase(), |
163 CMsmmPolicyPluginBase(), |
142 iHistory(KHistoryGranularity) |
164 iHistory(KHistoryGranularity) |
143 { |
165 { |
144 LOG_FUNC |
166 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_CREFERENCEPOLICYPLUGIN_CONS_ENTRY ); |
|
167 |
145 CActiveScheduler::Add(this); |
168 CActiveScheduler::Add(this); |
|
169 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_CREFERENCEPOLICYPLUGIN_CONS_EXIT ); |
146 } |
170 } |
147 |
171 |
148 void CReferencePolicyPlugin::ConstructL() |
172 void CReferencePolicyPlugin::ConstructL() |
149 { |
173 { |
150 LOG_FUNC |
174 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_CONSTRUCTL_ENTRY ); |
|
175 |
151 iRepository = CRepository::NewL(KHostMsRepositoryUid); |
176 iRepository = CRepository::NewL(KHostMsRepositoryUid); |
152 User::LeaveIfError(iFs.Connect()); |
177 User::LeaveIfError(iFs.Connect()); |
153 iNotificationMan = CMsmmPolicyNotificationManager::NewL(); |
178 iNotificationMan = CMsmmPolicyNotificationManager::NewL(); |
154 RetrieveHistoryL(); |
179 RetrieveHistoryL(); |
155 AvailableDriveListL(); |
180 AvailableDriveListL(); |
241 for (TInt index = 0; index < iHistory.Count(); index++) |
269 for (TInt index = 0; index < iHistory.Count(); index++) |
242 { |
270 { |
243 TPckg<TPolicyMountRecord> historyPckg(*iHistory[index]); |
271 TPckg<TPolicyMountRecord> historyPckg(*iHistory[index]); |
244 User::LeaveIfError(iRepository->Set(historyRecordUid++, historyPckg)); |
272 User::LeaveIfError(iRepository->Set(historyRecordUid++, historyPckg)); |
245 } |
273 } |
|
274 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_SAVELATESTMOUNTINFOL_TPOLICYMOUNTRECORD_EXIT_DUP1 ); |
246 } |
275 } |
247 |
276 |
248 void CReferencePolicyPlugin::Complete(TInt aError) |
277 void CReferencePolicyPlugin::Complete(TInt aError) |
249 { |
278 { |
250 LOG_FUNC |
279 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_COMPLETE_ENTRY ); |
|
280 |
251 User::RequestComplete(iClientStatus, aError); |
281 User::RequestComplete(iClientStatus, aError); |
|
282 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_COMPLETE_EXIT ); |
252 } |
283 } |
253 |
284 |
254 void CReferencePolicyPlugin::PrepareAvailableDriveList() |
285 void CReferencePolicyPlugin::PrepareAvailableDriveList() |
255 { |
286 { |
256 LOG_FUNC |
287 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_PREPAREAVAILABLEDRIVELIST_ENTRY ); |
|
288 |
257 iAvailableDrvList.SetLength(KMaxDrives); |
289 iAvailableDrvList.SetLength(KMaxDrives); |
258 iAvailableDrvList.Fill(0, KMaxDrives); |
290 iAvailableDrvList.Fill(0, KMaxDrives); |
|
291 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_PREPAREAVAILABLEDRIVELIST_EXIT ); |
259 } |
292 } |
260 |
293 |
261 void CReferencePolicyPlugin::AvailableDriveListL() |
294 void CReferencePolicyPlugin::AvailableDriveListL() |
262 { |
295 { |
263 LOG_FUNC |
296 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_AVAILABLEDRIVELISTL_ENTRY ); |
|
297 |
264 TBuf8<KPermittedDrvRangeBufLen> permittedRange; |
298 TBuf8<KPermittedDrvRangeBufLen> permittedRange; |
265 TDriveList forbiddenList; |
299 TDriveList forbiddenList; |
266 |
300 |
267 PrepareAvailableDriveList(); |
301 PrepareAvailableDriveList(); |
268 |
302 |
350 CleanupStack::PushL(record); |
391 CleanupStack::PushL(record); |
351 iHistory.AppendL(record); |
392 iHistory.AppendL(record); |
352 CleanupStack::Pop(record); |
393 CleanupStack::Pop(record); |
353 } |
394 } |
354 } |
395 } |
|
396 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_RETRIEVEHISTORYL_EXIT ); |
355 } |
397 } |
356 |
398 |
357 // Remove all buffered history |
399 // Remove all buffered history |
358 void CReferencePolicyPlugin::ClearHistory() |
400 void CReferencePolicyPlugin::ClearHistory() |
359 { |
401 { |
360 LOG_FUNC |
402 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_CLEARHISTORY_ENTRY ); |
|
403 |
361 iHistory.ResetAndDestroy(); |
404 iHistory.ResetAndDestroy(); |
362 iHistory.Close(); |
405 iHistory.Close(); |
|
406 OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_CLEARHISTORY_EXIT ); |
363 } |
407 } |
364 |
408 |
365 // Search in history for a logic unit |
409 // Search in history for a logic unit |
366 TInt CReferencePolicyPlugin::SearchHistoryByLogicUnit( |
410 TInt CReferencePolicyPlugin::SearchHistoryByLogicUnit( |
367 const TPolicyRequestData& aLogicUnit) const |
411 const TPolicyRequestData& aLogicUnit) const |
368 { |
412 { |
369 LOG_FUNC |
413 OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_SEARCHHISTORYBYLOGICUNIT_ENTRY ); |
|
414 |
370 TInt ret(KErrNotFound); |
415 TInt ret(KErrNotFound); |
371 TUint count = iHistory.Count(); |
416 TUint count = iHistory.Count(); |
372 for (TUint index = 0; index < count; index ++) |
417 for (TUint index = 0; index < count; index ++) |
373 { |
418 { |
374 const TPolicyMountRecord& record = *iHistory[index]; |
419 const TPolicyMountRecord& record = *iHistory[index]; |