210 { |
210 { |
211 __ALFFXLOGSTRING("CPolicyHandler::GetListBoxKml - return KErrNotFound <<"); |
211 __ALFFXLOGSTRING("CPolicyHandler::GetListBoxKml - return KErrNotFound <<"); |
212 return KErrNotFound; |
212 return KErrNotFound; |
213 } |
213 } |
214 |
214 |
215 aResourceDir.Set( iListBoxPolicies[i]->ResourceDir() ); |
215 aResourceDir.Set( iListBoxPolicies[i]->ResourceDir() ); |
216 aBackgroundFilename.Set( iListBoxPolicies[i]->BackgroundFilename() ); |
216 aBackgroundFilename.Set( iListBoxPolicies[i]->BackgroundFilename() ); |
217 aItemFilename.Set( iListBoxPolicies[i]->ItemFilename() ); |
217 aItemFilename.Set( iListBoxPolicies[i]->ItemFilename() ); |
218 aCachePriority = iListBoxPolicies[i]->CachePriority(); |
218 aCachePriority = iListBoxPolicies[i]->CachePriority(); |
219 aWantedTime = iListBoxPolicies[i]->WantedTime(); |
219 aWantedTime = iListBoxPolicies[i]->WantedTime(); |
220 aMinTime = iListBoxPolicies[i]->MinTime(); |
220 aMinTime = iListBoxPolicies[i]->MinTime(); |
221 |
221 |
222 // For now, this entry should have no priority over others |
222 // For now, this entry should have no priority over others |
223 iListBoxPolicies[i]->SetCachePriority( 0 ); |
223 iListBoxPolicies[i]->SetCachePriority( 0 ); |
224 __ALFFXLOGSTRING("CPolicyHandler::GetListBoxKml - return KErrNone <<"); |
224 __ALFFXLOGSTRING("CPolicyHandler::GetListBoxKml - return KErrNone <<"); |
225 return KErrNone; |
225 return KErrNone; |
226 } |
226 } |
227 |
227 |
228 // --------------------------------------------------------------------------- |
228 // --------------------------------------------------------------------------- |
229 // --------------------------------------------------------------------------- |
229 // --------------------------------------------------------------------------- |
230 // |
230 // |
231 void CPolicyHandler::RegisterFullscreenKmlL(TUint aAction, const TUid& aUid, const TThreadId& aThreadId, |
231 void CPolicyHandler::RegisterFullscreenKmlL(TUint aAction, const TUid& aUid, const TThreadId& aThreadId, |
232 const TDesC& aResourceDir, const TDesC& aFilename, |
232 const TDesC& aResourceDir, const TDesC& aFilename, |
233 TInt /*aCachePriority*/, TInt aWantedTime, TInt aMinTime) |
233 TInt /*aCachePriority*/, TInt aWantedTime, TInt aMinTime) |
234 { |
234 { |
235 __ALFFXLOGSTRING3("CPolicyHandler::RegisterFullscreenKmlL - aAction: %d aUid: 0x%x aThread.Id : %d", aAction, aUid, aThreadId.Id() ); |
235 __ALFFXLOGSTRING3("CPolicyHandler::RegisterFullscreenKmlL - aAction: %d aUid: 0x%x aThread.Id : %d", aAction, aUid, aThreadId.Id() ); |
236 __ALFFXLOGSTRING2("CPolicyHandler::RegisterFullscreenKmlL - aResourceDir: %S, aFilename: %S", &aResourceDir, &aFilename ); |
236 __ALFFXLOGSTRING2("CPolicyHandler::RegisterFullscreenKmlL - aResourceDir: %S, aFilename: %S", &aResourceDir, &aFilename ); |
237 TInt cachePriority = 1; //aCachePriority; |
237 TInt cachePriority = 1; //aCachePriority; |
238 // For now, the cache priority is always 1 at registration time, and after |
238 // For now, the cache priority is always 1 at registration time, and after |
239 // fetching the KML information from the policy, it gets set to 0. This is |
239 // fetching the KML information from the policy, it gets set to 0. This is |
240 // used to trigger eviction from the KML cache. Newly registered KML:s have |
240 // used to trigger eviction from the KML cache. Newly registered KML:s have |
241 // priority over existing... |
241 // priority over existing... |
242 |
242 |
243 CFullscreenPolicy* policy = NULL; |
243 CFullscreenPolicy* policy = NULL; |
244 |
244 |
245 // Check if the action was already is registered and if so, delete it. |
245 // Check if the action was already is registered and if so, delete it. |
246 TInt count = iFullscreenPolicies.Count()-1; |
246 TInt count = iFullscreenPolicies.Count()-1; |
247 for(; count >= 0; count--) |
247 for(; count >= 0; count--) |
248 { |
248 { |
249 if( iFullscreenPolicies[count]->Action() == aAction && |
249 if( iFullscreenPolicies[count]->Action() == aAction && |
250 iFullscreenPolicies[count]->Uid() == aUid) |
250 iFullscreenPolicies[count]->Uid() == aUid) |
251 { |
251 { |
252 policy = iFullscreenPolicies[count]; |
252 policy = iFullscreenPolicies[count]; |
253 iFullscreenPolicies.Remove(count); |
253 iFullscreenPolicies.Remove(count); |
254 delete policy; |
254 delete policy; |
255 policy = NULL; |
255 policy = NULL; |
256 } |
256 } |
257 } |
257 } |
258 |
258 |
259 // create and add the new action. |
259 // create and add the new action. |
260 policy = CFullscreenPolicy::NewL(aAction, aUid, aThreadId, aResourceDir, aFilename, |
260 policy = CFullscreenPolicy::NewL(aAction, aUid, aThreadId, aResourceDir, aFilename, |
261 cachePriority, aWantedTime, aMinTime); |
261 cachePriority, aWantedTime, aMinTime); |
262 CleanupStack::PushL(policy); |
262 CleanupStack::PushL(policy); |
263 iFullscreenPolicies.AppendL(policy); |
263 iFullscreenPolicies.AppendL(policy); |
264 CleanupStack::Pop(policy); |
264 CleanupStack::Pop(policy); |
265 __ALFFXLOGSTRING("CPolicyHandler::RegisterFullscreenKmlL <<"); |
265 __ALFFXLOGSTRING("CPolicyHandler::RegisterFullscreenKmlL <<"); |
266 } |
266 } |
267 |
267 |
268 // --------------------------------------------------------------------------- |
268 // --------------------------------------------------------------------------- |
269 // --------------------------------------------------------------------------- |
269 // --------------------------------------------------------------------------- |
270 // |
270 // |
271 TInt CPolicyHandler::UnregisterFullscreenKml(TUint aAction, const TUid& aUid) |
271 TInt CPolicyHandler::UnregisterFullscreenKml(TUint aAction, const TUid& aUid) |
272 { |
272 { |
273 __ALFFXLOGSTRING2("CPolicyHandler::UnregisterFullscreenKml - aAction: %d, aUid: 0x%x <<", aAction, aUid ); |
273 __ALFFXLOGSTRING2("CPolicyHandler::UnregisterFullscreenKml - aAction: %d, aUid: 0x%x <<", aAction, aUid ); |
274 TInt count = iFullscreenPolicies.Count() -1; |
274 TInt count = iFullscreenPolicies.Count() -1; |
275 for(; count >= 0; count--) |
275 for(; count >= 0; count--) |
276 { |
276 { |
277 if(iFullscreenPolicies[count]->Action() == aAction && |
277 if(iFullscreenPolicies[count]->Action() == aAction && |
278 iFullscreenPolicies[count]->Uid() == aUid) |
278 iFullscreenPolicies[count]->Uid() == aUid) |
279 { |
279 { |
280 CFullscreenPolicy* policy = iFullscreenPolicies[count]; |
280 CFullscreenPolicy* policy = iFullscreenPolicies[count]; |
281 iFullscreenPolicies.Remove(count); |
281 iFullscreenPolicies.Remove(count); |
282 delete policy; |
282 delete policy; |
283 policy = NULL; |
283 policy = NULL; |
284 __ALFFXLOGSTRING("CPolicyHandler::UnregisterFullscreenKml - return KErrNone <<"); |
284 __ALFFXLOGSTRING("CPolicyHandler::UnregisterFullscreenKml - return KErrNone <<"); |
285 return KErrNone; |
285 return KErrNone; |
286 } |
286 } |
287 } |
287 } |
288 __ALFFXLOGSTRING("CPolicyHandler::UnregisterFullscreenKml - return KErrNotFound <<"); |
288 __ALFFXLOGSTRING("CPolicyHandler::UnregisterFullscreenKml - return KErrNotFound <<"); |
289 return KErrNotFound; |
289 return KErrNotFound; |
290 } |
290 } |
291 |
291 |
292 // --------------------------------------------------------------------------- |
292 // --------------------------------------------------------------------------- |
293 // --------------------------------------------------------------------------- |
293 // --------------------------------------------------------------------------- |
294 // |
294 // |
295 TInt CPolicyHandler::UnregisterFullscreenKml(const TThreadId& aThreadId) |
295 TInt CPolicyHandler::UnregisterFullscreenKml(const TThreadId& aThreadId) |
296 { |
296 { |
297 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterFullscreenKml - aThreadId: %d >>", aThreadId.Id()); |
297 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterFullscreenKml - aThreadId: %d >>", aThreadId.Id()); |
298 TInt count = iFullscreenPolicies.Count() -1; |
298 TInt count = iFullscreenPolicies.Count() -1; |
299 TInt err = KErrNotFound; |
299 TInt err = KErrNotFound; |
300 TThreadId tid; |
300 TThreadId tid; |
301 |
301 |
302 for(; count >= 0; count--) |
302 for(; count >= 0; count--) |
303 { |
303 { |
304 tid = iFullscreenPolicies[count]->ThreadId(); |
304 tid = iFullscreenPolicies[count]->ThreadId(); |
305 if( tid.Id() == aThreadId.Id()) |
305 if( tid.Id() == aThreadId.Id()) |
306 { |
306 { |
307 CFullscreenPolicy* policy = iFullscreenPolicies[count]; |
307 CFullscreenPolicy* policy = iFullscreenPolicies[count]; |
308 iFullscreenPolicies.Remove(count); |
308 iFullscreenPolicies.Remove(count); |
309 delete policy; |
309 delete policy; |
310 policy = NULL; |
310 policy = NULL; |
311 err = KErrNone; |
311 err = KErrNone; |
312 } |
312 } |
313 } |
313 } |
314 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterFullscreenKml - return: %d <<", err); |
314 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterFullscreenKml - return: %d <<", err); |
315 return err; |
315 return err; |
316 } |
316 } |
317 |
317 |
318 // --------------------------------------------------------------------------- |
318 // --------------------------------------------------------------------------- |
319 // --------------------------------------------------------------------------- |
319 // --------------------------------------------------------------------------- |
320 // |
320 // |
321 TInt CPolicyHandler::UnregisterAllKml(const TThreadId& aThreadId) |
321 TInt CPolicyHandler::UnregisterAllKml(const TThreadId& aThreadId) |
322 { |
322 { |
323 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterAllKml - aThreadId: <<", aThreadId.Id()); |
323 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterAllKml - aThreadId: <<", aThreadId.Id()); |
324 TInt err = KErrNotFound; |
324 TInt err = KErrNotFound; |
325 TInt err1 = UnregisterFullscreenKml(aThreadId); |
325 TInt err1 = UnregisterFullscreenKml(aThreadId); |
326 TInt err2 = UnregisterControlKml(aThreadId); |
326 TInt err2 = UnregisterControlKml(aThreadId); |
327 |
327 |
328 if(err1 == KErrNone || err2 == KErrNone) |
328 if(err1 == KErrNone || err2 == KErrNone) |
329 err = KErrNone; |
329 err = KErrNone; |
330 |
330 |
331 |
331 |
332 TInt err3 = UnregisterListBoxKml(aThreadId); |
332 TInt err3 = UnregisterListBoxKml(aThreadId); |
333 if(err3 == KErrNone) |
333 if(err3 == KErrNone) |
334 err = KErrNone; |
334 err = KErrNone; |
335 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterAllKml - return: %d <<", err); |
335 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterAllKml - return: %d <<", err); |
336 return err; |
336 return err; |
337 } |
337 } |
338 |
338 |
339 |
339 |
340 // --------------------------------------------------------------------------- |
340 // --------------------------------------------------------------------------- |
341 // --------------------------------------------------------------------------- |
341 // --------------------------------------------------------------------------- |
342 // |
342 // |
343 TInt CPolicyHandler::GetFullscreenKml( TUint aAction, const TUid& aToUid, const TUid& aFromUid, |
343 TInt CPolicyHandler::GetFullscreenKml( TUint aAction, const TUid& aToUid, const TUid& aFromUid, |
344 TPtrC& aResourceDir, TPtrC& aFilename, |
344 TPtrC& aResourceDir, TPtrC& aFilename, |
345 TInt& aCachePriority, TInt& aWantedTime, TInt& aMinTime) |
345 TInt& aCachePriority, TInt& aWantedTime, TInt& aMinTime) |
346 { |
346 { |
347 __ALFFXLOGSTRING3("CPolicyHandler::GetFullscreenKml - aAction: %d, aToUid: %d, aFromUid :%d", aAction, aToUid, aFromUid ); |
347 __ALFFXLOGSTRING3("CPolicyHandler::GetFullscreenKml - aAction: %d, aToUid: %d, aFromUid :%d", aAction, aToUid, aFromUid ); |
348 __ALFFXLOGSTRING2("CPolicyHandler::GetFullscreenKml - aResourceDir: %S, aFilename :%S", &aResourceDir, &aFilename ); |
348 __ALFFXLOGSTRING2("CPolicyHandler::GetFullscreenKml - aResourceDir: %S, aFilename :%S", &aResourceDir, &aFilename ); |
349 |
349 |
350 // Checking if the UID is blocked. |
350 // Checking if the UID is blocked. |
351 TInt blockedUids = iFullScreenBlocks.Count(); |
351 TInt blockedUids = iFullScreenBlocks.Count(); |
352 aResourceDir.Set( TPtrC() ); |
352 aResourceDir.Set( TPtrC() ); |
353 aFilename.Set( TPtrC() ); |
353 aFilename.Set( TPtrC() ); |
354 |
354 |
355 for( TInt i = 0 ; i < blockedUids ; i++ ) |
355 for( TInt i = 0 ; i < blockedUids ; i++ ) |
356 { |
356 { |
357 if( iFullScreenBlocks[i]->iToUid == aToUid || |
357 if( iFullScreenBlocks[i]->iToUid == aToUid || |
358 iFullScreenBlocks[i]->iFromUid == aFromUid) |
358 iFullScreenBlocks[i]->iFromUid == aFromUid) |
359 { |
359 { |
360 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotSupported <<"); |
360 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotSupported <<"); |
361 return KErrNotSupported; |
361 return KErrNotSupported; |
362 } |
362 } |
363 } |
363 } |
364 |
364 |
365 TInt count = iFullscreenPolicies.Count(); |
365 TInt count = iFullscreenPolicies.Count(); |
366 // try to find it using both action and uid |
366 // try to find it using both action and uid |
367 for(TInt i = 0; i < count; i++) |
367 for(TInt i = 0; i < count; i++) |
368 { |
368 { |
369 if(iFullscreenPolicies[i]->Action() == aAction && |
369 if(iFullscreenPolicies[i]->Action() == aAction && |
370 iFullscreenPolicies[i]->Uid() == aToUid) |
370 iFullscreenPolicies[i]->Uid() == aToUid) |
371 { |
371 { |
372 aResourceDir.Set( iFullscreenPolicies[i]->ResourceDir() ); |
372 aResourceDir.Set( iFullscreenPolicies[i]->ResourceDir() ); |
373 aFilename.Set( iFullscreenPolicies[i]->Filename() ); |
373 aFilename.Set( iFullscreenPolicies[i]->Filename() ); |
374 aCachePriority = iFullscreenPolicies[i]->CachePriority(); |
374 aCachePriority = iFullscreenPolicies[i]->CachePriority(); |
375 aWantedTime = iFullscreenPolicies[i]->WantedTime(); |
375 aWantedTime = iFullscreenPolicies[i]->WantedTime(); |
376 aMinTime = iFullscreenPolicies[i]->MinTime(); |
376 aMinTime = iFullscreenPolicies[i]->MinTime(); |
377 // Check if theres a block on this UID/Action pair. |
377 // Check if theres a block on this UID/Action pair. |
378 if( aFilename.Length() == 0 ) |
378 if( aFilename.Length() == 0 ) |
379 { |
379 { |
380 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotSupported <<"); |
380 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotSupported <<"); |
381 return KErrNotSupported; |
381 return KErrNotSupported; |
382 } |
382 } |
383 |
383 |
384 // For now, this entry should have no priority over others |
384 // For now, this entry should have no priority over others |
385 iFullscreenPolicies[i]->SetCachePriority(0); |
385 iFullscreenPolicies[i]->SetCachePriority(0); |
386 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNone <<"); |
386 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNone <<"); |
387 return KErrNone; |
387 return KErrNone; |
388 } |
388 } |
389 } |
389 } |
390 // try to find the default (Uid == KNullUid) |
390 // try to find the default (Uid == KNullUid) |
391 for(TInt i = 0; i < count; i++) |
391 for(TInt i = 0; i < count; i++) |
392 { |
392 { |
393 if(iFullscreenPolicies[i]->Action() == aAction && |
393 if(iFullscreenPolicies[i]->Action() == aAction && |
394 iFullscreenPolicies[i]->Uid() == KNullUid) |
394 iFullscreenPolicies[i]->Uid() == KNullUid) |
395 { |
395 { |
396 aResourceDir.Set( iFullscreenPolicies[i]->ResourceDir() ); |
396 aResourceDir.Set( iFullscreenPolicies[i]->ResourceDir() ); |
397 aFilename.Set( iFullscreenPolicies[i]->Filename() ); |
397 aFilename.Set( iFullscreenPolicies[i]->Filename() ); |
398 aCachePriority = iFullscreenPolicies[i]->CachePriority(); |
398 aCachePriority = iFullscreenPolicies[i]->CachePriority(); |
399 aWantedTime = iFullscreenPolicies[i]->WantedTime(); |
399 aWantedTime = iFullscreenPolicies[i]->WantedTime(); |
400 aMinTime = iFullscreenPolicies[i]->MinTime(); |
400 aMinTime = iFullscreenPolicies[i]->MinTime(); |
401 |
401 |
402 // For now, this entry should have no priority over others |
402 // For now, this entry should have no priority over others |
403 iFullscreenPolicies[i]->SetCachePriority(0); |
403 iFullscreenPolicies[i]->SetCachePriority(0); |
404 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNone <<"); |
404 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNone <<"); |
405 return KErrNone; |
405 return KErrNone; |
406 } |
406 } |
407 } |
407 } |
408 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotFound <<"); |
408 __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotFound <<"); |
409 return KErrNotFound; |
409 return KErrNotFound; |
410 } |
410 } |
411 |
411 |
412 |
412 |
413 // --------------------------------------------------------------------------- |
413 // --------------------------------------------------------------------------- |
414 // --------------------------------------------------------------------------- |
414 // --------------------------------------------------------------------------- |
415 // |
415 // |
416 TInt CPolicyHandler::BlockFullScreenUid(const TUid& aUid, TBool aBlockFrom, TBool aBlockTo) |
416 TInt CPolicyHandler::BlockFullScreenUid(const TUid& aUid, TBool aBlockFrom, TBool aBlockTo) |
417 { |
417 { |
418 __ALFFXLOGSTRING3("CPolicyHandler::BlockFullScreenUid - aUid: 0x%x, aBlockFrom: %d, aBlockTo: %d >>", aUid, aBlockFrom, aBlockTo ); |
418 __ALFFXLOGSTRING3("CPolicyHandler::BlockFullScreenUid - aUid: 0x%x, aBlockFrom: %d, aBlockTo: %d >>", aUid, aBlockFrom, aBlockTo ); |
419 TFullScreenBlock* block = NULL; |
419 TFullScreenBlock* block = NULL; |
420 |
420 |
421 TInt blockedUids = iFullScreenBlocks.Count(); |
421 TInt blockedUids = iFullScreenBlocks.Count(); |
422 if( blockedUids > 0) |
422 if( blockedUids > 0) |
423 { |
423 { |
424 // Looking for an existing To block. |
424 // Looking for an existing To block. |
425 if(!aBlockTo && aBlockFrom ) |
425 if(!aBlockTo && aBlockFrom ) |
426 { |
426 { |
427 for(TInt i = 0; i < blockedUids; i++) |
427 for(TInt i = 0; i < blockedUids; i++) |
428 { |
428 { |
429 if(iFullScreenBlocks[i]->iFromUid == aUid) |
429 if(iFullScreenBlocks[i]->iFromUid == aUid) |
430 { |
430 { |
431 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<"); |
431 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<"); |
432 return KErrNone; |
432 return KErrNone; |
433 } |
433 } |
434 } |
434 } |
435 } |
435 } |
436 // Looking for an existing From block. |
436 // Looking for an existing From block. |
437 else if(aBlockTo && !aBlockFrom) |
437 else if(aBlockTo && !aBlockFrom) |
438 { |
438 { |
439 for(TInt i = 0; i < blockedUids; i++) |
439 for(TInt i = 0; i < blockedUids; i++) |
440 { |
440 { |
441 if(iFullScreenBlocks[i]->iToUid == aUid) |
441 if(iFullScreenBlocks[i]->iToUid == aUid) |
442 { |
442 { |
443 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<"); |
443 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<"); |
444 return KErrNone; |
444 return KErrNone; |
445 } |
445 } |
446 } |
446 } |
447 } |
447 } |
448 // Trying to unblock stuff. |
448 // Trying to unblock stuff. |
449 else if(!aBlockTo && !aBlockFrom) |
449 else if(!aBlockTo && !aBlockFrom) |
450 { |
450 { |
451 for(TInt i = blockedUids -1; i >= 0; i--) |
451 for(TInt i = blockedUids -1; i >= 0; i--) |
452 { |
452 { |
453 if( iFullScreenBlocks[i]->iToUid == aUid || |
453 if( iFullScreenBlocks[i]->iToUid == aUid || |
454 iFullScreenBlocks[i]->iFromUid == aUid ) |
454 iFullScreenBlocks[i]->iFromUid == aUid ) |
455 { |
455 { |
456 block = iFullScreenBlocks[i]; |
456 block = iFullScreenBlocks[i]; |
457 iFullScreenBlocks.Remove(i); |
457 iFullScreenBlocks.Remove(i); |
458 delete block; |
458 delete block; |
459 block = NULL; |
459 block = NULL; |
460 } |
460 } |
461 } |
461 } |
462 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<"); |
462 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<"); |
463 return KErrNone; |
463 return KErrNone; |
464 } |
464 } |
465 // Looking for an existing To and From block with the same UID's. |
465 // Looking for an existing To and From block with the same UID's. |
466 else |
466 else |
467 { |
467 { |
468 for(TInt i = 0; i < blockedUids; i++) |
468 for(TInt i = 0; i < blockedUids; i++) |
469 { |
469 { |
470 if( iFullScreenBlocks[i]->iToUid == aUid && |
470 if( iFullScreenBlocks[i]->iToUid == aUid && |
471 iFullScreenBlocks[i]->iFromUid == aUid ) |
471 iFullScreenBlocks[i]->iFromUid == aUid ) |
472 { |
472 { |
473 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<"); |
473 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<"); |
474 return KErrNone; |
474 return KErrNone; |
475 } |
475 } |
476 } |
476 } |
477 } |
477 } |
478 } |
478 } |
479 |
479 |
480 // None found. Create! |
480 // None found. Create! |
481 block = new TFullScreenBlock(); |
481 block = new TFullScreenBlock(); |
482 if(NULL == block) |
482 if(NULL == block) |
483 { |
483 { |
484 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNoMemory <<"); |
484 __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNoMemory <<"); |
485 return KErrNoMemory; |
485 return KErrNoMemory; |
486 } |
486 } |
487 |
487 |
488 if(aBlockTo) |
488 if(aBlockTo) |
489 { |
489 { |
490 block->iToUid = aUid; |
490 block->iToUid = aUid; |
491 } |
491 } |
492 if(aBlockFrom) |
492 if(aBlockFrom) |
493 { |
493 { |
494 block->iFromUid = aUid; |
494 block->iFromUid = aUid; |
495 } |
495 } |
496 |
496 |
497 TInt err = iFullScreenBlocks.Append(block); |
497 TInt err = iFullScreenBlocks.Append(block); |
498 if(KErrNone != err) |
498 if(KErrNone != err) |
499 { |
499 { |
500 delete block; |
500 delete block; |
501 block = NULL; |
501 block = NULL; |
502 } |
502 } |
503 __ALFFXLOGSTRING1("CPolicyHandler::BlockFullScreenUid - return: %d <<", err); |
503 __ALFFXLOGSTRING1("CPolicyHandler::BlockFullScreenUid - return: %d <<", err); |
504 return err; |
504 return err; |
505 } |
505 } |
506 |
506 |
507 // --------------------------------------------------------------------------- |
507 // --------------------------------------------------------------------------- |
508 // --------------------------------------------------------------------------- |
508 // --------------------------------------------------------------------------- |
509 // |
509 // |
510 TInt CPolicyHandler::RegisterControlAction(const TUid aUid, TUint aAction, const TDesC& aActionString) |
510 TInt CPolicyHandler::RegisterControlAction(const TUid aUid, TUint aAction, const TDesC& aActionString) |
511 { |
511 { |
512 __ALFFXLOGSTRING3("CPolicyHandler::RegisterControlAction - aUid: 0x%x, aAction: %d, aActionString: %S", aUid, aAction, &aActionString ); |
512 __ALFFXLOGSTRING3("CPolicyHandler::RegisterControlAction - aUid: 0x%x, aAction: %d, aActionString: %S", aUid, aAction, &aActionString ); |
513 TInt index = 0; |
513 TInt index = 0; |
514 CControlPolicy* pData = NULL; |
514 CControlPolicy* pData = NULL; |
515 CActionPolicy* pPolicy = NULL; |
515 CActionPolicy* pPolicy = NULL; |
516 |
516 |
517 // TEST!!!!!!!!!! |
517 // TEST!!!!!!!!!! |
518 // First see if we have an empty entry that means a new KML has been registered |
518 // First see if we have an empty entry that means a new KML has been registered |
519 // Adding just a KML does not remove the old one, the old one gets removed only |
519 // Adding just a KML does not remove the old one, the old one gets removed only |
520 // after we add an action to the new KML |
520 // after we add an action to the new KML |
521 |
521 |
522 // The double action of first registering a KML file and then registering the action |
522 // The double action of first registering a KML file and then registering the action |
523 // should be replaced with single call where the control file and action are defined |
523 // should be replaced with single call where the control file and action are defined |
524 // in one call |
524 // in one call |
525 |
525 |
526 TInt count = iControlPolicies.Count(); |
526 TInt count = iControlPolicies.Count(); |
527 index = -1; // Setting index to negative value to use as check if match found. |
527 index = -1; // Setting index to negative value to use as check if match found. |
528 TInt i = 0; |
528 TInt i = 0; |
529 TInt j = 0; |
529 TInt j = 0; |
530 TInt k = 0; |
530 TInt k = 0; |
531 |
531 |
532 // We stop when we find a matching empty entry |
532 // We stop when we find a matching empty entry |
533 // But first old non-empty entries are deleted |
533 // But first old non-empty entries are deleted |
534 for( i = count - 1; i >= 0 && index == -1; i-- ) |
534 for( i = count - 1; i >= 0 && index == -1; i-- ) |
535 { |
535 { |
536 pData = iControlPolicies[i]; |
536 pData = iControlPolicies[i]; |
537 if( pData->Uid() == aUid ) |
537 if( pData->Uid() == aUid ) |
538 { |
538 { |
539 if ( pData->iControlPolicies.Count() == 0 ) |
539 if ( pData->iControlPolicies.Count() == 0 ) |
540 { |
540 { |
541 index = i; |
541 index = i; |
542 // We have found an empty definition. |
542 // We have found an empty definition. |
543 // This means a new effect definition file has been added, and the new action |
543 // This means a new effect definition file has been added, and the new action |
544 // should be attached to it. |
544 // should be attached to it. |
545 // But first we have to remove the possible old effect file |
545 // But first we have to remove the possible old effect file |
546 for ( j = count - 1; j >= 0; j-- ) |
546 for ( j = count - 1; j >= 0; j-- ) |
547 { |
547 { |
548 pData = iControlPolicies[j]; |
548 pData = iControlPolicies[j]; |
549 if ( pData->Uid() == aUid ) |
549 if ( pData->Uid() == aUid ) |
550 { |
550 { |
551 for ( k = 0; pData && k < pData->iControlPolicies.Count(); k++ ) |
551 for ( k = 0; pData && k < pData->iControlPolicies.Count(); k++ ) |
552 { |
552 { |
553 pPolicy = pData->iControlPolicies[k]; |
553 pPolicy = pData->iControlPolicies[k]; |
554 if ( pPolicy->iAction == aAction ) |
554 if ( pPolicy->iAction == aAction ) |
555 { |
555 { |
556 // Old definition found, remove the whole policy entry |
556 // Old definition found, remove the whole policy entry |
557 iControlPolicies.Remove( j ); |
557 iControlPolicies.Remove( j ); |
558 count--; // this value is referred later. It must be kept up to date. |
558 count--; // this value is referred later. It must be kept up to date. |
559 delete pData; |
559 delete pData; |
560 pData = NULL; |
560 pData = NULL; |
561 } |
561 } |
562 } |
562 } |
563 } |
563 } |
564 } |
564 } |
565 } |
565 } |
566 } |
566 } |
567 } |
567 } |
568 |
568 |
569 if( index >= 0 ) |
569 if( index >= 0 ) |
570 { |
570 { |
571 index = -1; // paranoid... |
571 index = -1; // paranoid... |
572 // find the empty entry again - if it exists |
572 // find the empty entry again - if it exists |
573 // our indexes may have got messed up if we removed something |
573 // our indexes may have got messed up if we removed something |
574 // so we must recheck the index |
574 // so we must recheck the index |
575 // We only accept entries with no policies, as we just checked |
575 // We only accept entries with no policies, as we just checked |
576 // the existence of an entry with matching policy |
576 // the existence of an entry with matching policy |
577 for( i = count - 1; i >= 0 && index == -1; i-- ) |
577 for( i = count - 1; i >= 0 && index == -1; i-- ) |
578 { |
578 { |
579 pData = iControlPolicies[i]; |
579 pData = iControlPolicies[i]; |
580 if( pData->Uid() == aUid ) |
580 if( pData->Uid() == aUid ) |
581 { |
581 { |
582 if ( pData->iControlPolicies.Count() == 0 ) |
582 if ( pData->iControlPolicies.Count() == 0 ) |
583 { |
583 { |
584 index = i; |
584 index = i; |
585 } |
585 } |
586 } |
586 } |
587 } |
587 } |
588 } |
588 } |
589 // Now we have checked if we have an effect file definition that has no entries yet, |
589 // Now we have checked if we have an effect file definition that has no entries yet, |
590 // and if we found one, we deleted old effect file definitions for this UID. |
590 // and if we found one, we deleted old effect file definitions for this UID. |
591 // Now we check if we just update an old action or add a new one to the existing entry |
591 // Now we check if we just update an old action or add a new one to the existing entry |
592 |
592 |
593 // First checking if we need to update a policy. |
593 // First checking if we need to update a policy. |
594 // If we have an empty entry, we must use it, not add our action to a different entry |
594 // If we have an empty entry, we must use it, not add our action to a different entry |
595 // even if if has the same UID. |
595 // even if if has the same UID. |
596 // So we must not try to find an existing entry if we have already decided to use an |
596 // So we must not try to find an existing entry if we have already decided to use an |
597 // empty entry |
597 // empty entry |
598 |
598 |
599 if ( index < 0 ) |
599 if ( index < 0 ) |
600 { |
600 { |
601 if(FindControlPolicy(aAction, aUid, pPolicy, index) == KErrNone) |
601 if(FindControlPolicy(aAction, aUid, pPolicy, index) == KErrNone) |
602 { |
602 { |
603 // If we get here and pPolicy == NULL, something is really wrong outside of |
603 // If we get here and pPolicy == NULL, something is really wrong outside of |
604 // our control. |
604 // our control. |
605 pPolicy->iAction = aAction; |
605 pPolicy->iAction = aAction; |
606 // Setting the action string is a leaving method. |
606 // Setting the action string is a leaving method. |
607 // Trap it here to avoid the rest of the system to become |
607 // Trap it here to avoid the rest of the system to become |
608 // leaving to. |
608 // leaving to. |
609 TRAPD(err, pPolicy->SetActionStringL(aActionString)); |
609 TRAPD(err, pPolicy->SetActionStringL(aActionString)); |
610 if(KErrNone != err) |
610 if(KErrNone != err) |
611 { |
611 { |
612 __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err); |
612 __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err); |
613 return err; |
613 return err; |
614 } |
614 } |
615 pPolicy->iPolicy = ESupported; |
615 pPolicy->iPolicy = ESupported; |
616 iClientRequestHandler->RegisterControlAction( aUid, aAction); |
616 iClientRequestHandler->RegisterControlAction( aUid, aAction); |
617 __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNone <<"); |
617 __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNone <<"); |
618 return KErrNone; |
618 return KErrNone; |
619 } |
619 } |
620 } |
620 } |
621 |
621 |
622 if( index < 0 ) |
622 if( index < 0 ) |
623 { |
623 { |
624 __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNotFound <<"); |
624 __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNotFound <<"); |
625 return KErrNotFound; |
625 return KErrNotFound; |
626 } |
626 } |
627 |
627 |
628 pData = iControlPolicies[index]; |
628 pData = iControlPolicies[index]; |
629 pPolicy = new CActionPolicy(); |
629 pPolicy = new CActionPolicy(); |
630 if(!pPolicy) |
630 if(!pPolicy) |
631 { |
631 { |
632 __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNoMemory <<"); |
632 __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNoMemory <<"); |
633 return KErrNoMemory; |
633 return KErrNoMemory; |
634 } |
634 } |
635 |
635 |
636 // Assign some values |
636 // Assign some values |
637 pPolicy->iAction = aAction; |
637 pPolicy->iAction = aAction; |
638 pPolicy->iPolicy = ESupported; |
638 pPolicy->iPolicy = ESupported; |
639 TRAPD(err, pPolicy->SetActionStringL(aActionString)); |
639 TRAPD(err, pPolicy->SetActionStringL(aActionString)); |
640 if(KErrNone != err) |
640 if(KErrNone != err) |
641 { |
641 { |
642 delete pPolicy; |
642 delete pPolicy; |
643 __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err); |
643 __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err); |
644 return err; |
644 return err; |
645 } |
645 } |
646 |
646 |
647 // Then add it to the list. |
647 // Then add it to the list. |
648 err = pData->iControlPolicies.Append(pPolicy); |
648 err = pData->iControlPolicies.Append(pPolicy); |
649 if(err != KErrNone) |
649 if(err != KErrNone) |
650 { |
650 { |
651 delete pPolicy; |
651 delete pPolicy; |
652 pPolicy = NULL; |
652 pPolicy = NULL; |
653 __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err); |
653 __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err); |
654 return err; |
654 return err; |
655 } |
655 } |
656 iClientRequestHandler->RegisterControlAction(aUid, aAction); |
656 iClientRequestHandler->RegisterControlAction(aUid, aAction); |
657 __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err); |
657 __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err); |
658 return err; |
658 return err; |
659 } |
659 } |
660 |
660 |
661 |
661 |
662 // --------------------------------------------------------------------------- |
662 // --------------------------------------------------------------------------- |
663 // --------------------------------------------------------------------------- |
663 // --------------------------------------------------------------------------- |
664 // |
664 // |
665 TInt CPolicyHandler::UnregisterControlAction(const TUid aUid, TUint aAction) |
665 TInt CPolicyHandler::UnregisterControlAction(const TUid aUid, TUint aAction) |
666 { |
666 { |
667 __ALFFXLOGSTRING2("CPolicyHandler::UnregisterControlAction - aUid %d, aAction: %d >>", aUid, aAction); |
667 __ALFFXLOGSTRING2("CPolicyHandler::UnregisterControlAction - aUid %d, aAction: %d >>", aUid, aAction); |
668 CControlPolicy* pData = NULL; |
668 CControlPolicy* pData = NULL; |
669 CActionPolicy* pPolicy = NULL; |
669 CActionPolicy* pPolicy = NULL; |
670 |
670 |
671 TInt count = iControlPolicies.Count(); |
671 TInt count = iControlPolicies.Count(); |
672 |
672 |
673 // Removing policy for action. |
673 // Removing policy for action. |
674 for(TInt counter = 0; counter < count; counter++) |
674 for(TInt counter = 0; counter < count; counter++) |
675 { |
675 { |
676 pData = iControlPolicies[counter]; |
676 pData = iControlPolicies[counter]; |
677 if(pData->Uid() == aUid) |
677 if(pData->Uid() == aUid) |
678 { |
678 { |
679 TInt polActionCount = pData->iControlPolicies.Count(); |
679 TInt polActionCount = pData->iControlPolicies.Count(); |
680 // Iterating the list from first. No problem since we only delete one item! |
680 // Iterating the list from first. No problem since we only delete one item! |
681 for(TInt j = 0; j < polActionCount; j++) |
681 for(TInt j = 0; j < polActionCount; j++) |
682 { |
682 { |
683 pPolicy = pData->iControlPolicies[j]; |
683 pPolicy = pData->iControlPolicies[j]; |
684 if(pPolicy->iAction == aAction) |
684 if(pPolicy->iAction == aAction) |
685 { |
685 { |
686 // Call this before removing data permanently! |
686 // Call this before removing data permanently! |
687 iClientRequestHandler->RemoveControlPolicy( aUid, aAction); |
687 iClientRequestHandler->RemoveControlPolicy( aUid, aAction); |
688 delete pPolicy; |
688 delete pPolicy; |
689 pPolicy = NULL; |
689 pPolicy = NULL; |
690 pData->iControlPolicies.Remove(j); |
690 pData->iControlPolicies.Remove(j); |
691 __ALFFXLOGSTRING("CPolicyHandler::UnregisterControlAction - return KErrNone<<"); |
691 __ALFFXLOGSTRING("CPolicyHandler::UnregisterControlAction - return KErrNone<<"); |
692 return KErrNone; |
692 return KErrNone; |
693 } |
693 } |
694 } |
694 } |
695 } |
695 } |
696 } |
696 } |
697 __ALFFXLOGSTRING("CPolicyHandler::UnregisterControlAction - return KErrNotFound<<"); |
697 __ALFFXLOGSTRING("CPolicyHandler::UnregisterControlAction - return KErrNotFound<<"); |
698 return KErrNotFound; |
698 return KErrNotFound; |
699 } |
699 } |
700 |
700 |
701 |
701 |
702 // --------------------------------------------------------------------------- |
702 // --------------------------------------------------------------------------- |
703 // --------------------------------------------------------------------------- |
703 // --------------------------------------------------------------------------- |
704 // |
704 // |
705 void CPolicyHandler::RegisterControlKmlL(const TUid &aUid, const TThreadId &aThreadId, |
705 void CPolicyHandler::RegisterControlKmlL(const TUid &aUid, const TThreadId &aThreadId, |
706 const TDesC& aResourceDir, const TDesC& aFilename, |
706 const TDesC& aResourceDir, const TDesC& aFilename, |
707 const TInt aWantedTime, const TInt aMinTime) |
707 const TInt aWantedTime, const TInt aMinTime) |
708 { |
708 { |
709 |
709 |
710 __ALFFXLOGSTRING2("CPolicyHandler::RegisterControlKmlL - aUid :%d aThread.Id :%d", aUid, aThreadId.Id() ); |
710 __ALFFXLOGSTRING2("CPolicyHandler::RegisterControlKmlL - aUid :%d aThread.Id :%d", aUid, aThreadId.Id() ); |
711 __ALFFXLOGSTRING2("CPolicyHandler::RegisterControlKmlL - aResourceDir: %S, aFilename :%S", &aResourceDir, &aFilename ); |
711 __ALFFXLOGSTRING2("CPolicyHandler::RegisterControlKmlL - aResourceDir: %S, aFilename :%S", &aResourceDir, &aFilename ); |
712 |
712 |
713 CControlPolicy* policy = NULL; |
713 CControlPolicy* policy = NULL; |
714 TInt cachePriority = 1; //aCachePriority; |
714 TInt cachePriority = 1; //aCachePriority; |
715 // For now, the cache priority is always 1 at registration time, and after |
715 // For now, the cache priority is always 1 at registration time, and after |
716 // fetching the KML information from the policy, it gets set to 0. This is |
716 // fetching the KML information from the policy, it gets set to 0. This is |
717 // used to trigger eviction from the KML cache. Newly registered KML:s have |
717 // used to trigger eviction from the KML cache. Newly registered KML:s have |
718 // priority over existing... |
718 // priority over existing... |
719 |
719 |
720 // Check if the action was already is registered and if so, delete it. |
720 // Check if the action was already is registered and if so, delete it. |
721 |
721 |
722 // TEST!!!!!!!!!!!! Don't delete before action is added |
722 // TEST!!!!!!!!!!!! Don't delete before action is added |
723 // Only delete if the entry has no policies, then we are replacing the xml file |
723 // Only delete if the entry has no policies, then we are replacing the xml file |
724 // though we have added no actions yet |
724 // though we have added no actions yet |
725 TInt count = iControlPolicies.Count()-1; |
725 TInt count = iControlPolicies.Count()-1; |
726 for(; count >= 0; count--) |
726 for(; count >= 0; count--) |
727 { |
727 { |
728 if( iControlPolicies[count]->Uid() == aUid) |
728 if( iControlPolicies[count]->Uid() == aUid) |
729 { |
729 { |
730 policy = iControlPolicies[count]; |
730 policy = iControlPolicies[count]; |
731 if ( policy->iControlPolicies.Count() == 0 ) |
731 if ( policy->iControlPolicies.Count() == 0 ) |
732 { |
732 { |
733 iControlPolicies.Remove(count); |
733 iControlPolicies.Remove(count); |
734 delete policy; |
734 delete policy; |
735 policy = NULL; |
735 policy = NULL; |
736 } |
736 } |
737 } |
737 } |
738 } |
738 } |
739 |
739 |
740 // Create the new action and add it. |
740 // Create the new action and add it. |
741 policy = CControlPolicy::NewL(aUid, aThreadId, aResourceDir, aFilename, cachePriority, aWantedTime, aMinTime); |
741 policy = CControlPolicy::NewL(aUid, aThreadId, aResourceDir, aFilename, cachePriority, aWantedTime, aMinTime); |
742 CleanupStack::PushL(policy); |
742 CleanupStack::PushL(policy); |
743 iControlPolicies.AppendL(policy); |
743 iControlPolicies.AppendL(policy); |
744 CleanupStack::Pop(policy); |
744 CleanupStack::Pop(policy); |
745 __ALFFXLOGSTRING("CPolicyHandler::RegisterControlKmlL <<"); |
745 __ALFFXLOGSTRING("CPolicyHandler::RegisterControlKmlL <<"); |
746 } |
746 } |
747 |
747 |
748 // --------------------------------------------------------------------------- |
748 // --------------------------------------------------------------------------- |
749 // --------------------------------------------------------------------------- |
749 // --------------------------------------------------------------------------- |
750 // |
750 // |
751 TInt CPolicyHandler::RemoveControlKml(const TUid &aUid) |
751 TInt CPolicyHandler::RemoveControlKml(const TUid &aUid) |
752 { |
752 { |
753 __ALFFXLOGSTRING1("CPolicyHandler::RemoveControlKml - aUid: %d ", aUid); |
753 __ALFFXLOGSTRING1("CPolicyHandler::RemoveControlKml - aUid: %d ", aUid); |
754 |
754 |
755 TInt err = KErrNotFound; |
755 TInt err = KErrNotFound; |
756 CControlPolicy* ptr = NULL; |
756 CControlPolicy* ptr = NULL; |
757 CActionPolicy* action = NULL; |
757 CActionPolicy* action = NULL; |
758 TInt policyCount = iControlPolicies.Count(); |
758 TInt policyCount = iControlPolicies.Count(); |
759 // We may remove several KMLs if different actions have different effect files |
759 // We may remove several KMLs if different actions have different effect files |
760 for( TInt i = policyCount - 1; i >= 0; i--) |
760 for( TInt i = policyCount - 1; i >= 0; i--) |
761 { |
761 { |
762 ptr = iControlPolicies[i]; |
762 ptr = iControlPolicies[i]; |
763 if(ptr->Uid() == aUid) |
763 if(ptr->Uid() == aUid) |
764 { |
764 { |
765 // making sure that policies get removed from the running clients as well! |
765 // making sure that policies get removed from the running clients as well! |
766 TInt count = ptr->iControlPolicies.Count(); |
766 TInt count = ptr->iControlPolicies.Count(); |
767 if( count > 0) |
767 if( count > 0) |
768 { |
768 { |
769 for(TInt j = 0; j < count; j++) |
769 for(TInt j = 0; j < count; j++) |
770 { |
770 { |
771 action = ptr->iControlPolicies[j]; |
771 action = ptr->iControlPolicies[j]; |
772 iClientRequestHandler->RemoveControlPolicy(aUid, action->iAction); |
772 iClientRequestHandler->RemoveControlPolicy(aUid, action->iAction); |
773 } |
773 } |
774 } |
774 } |
775 iControlPolicies.Remove(i); |
775 iControlPolicies.Remove(i); |
776 delete ptr; |
776 delete ptr; |
777 ptr = NULL; |
777 ptr = NULL; |
778 err = KErrNone; |
778 err = KErrNone; |
779 } |
779 } |
780 } |
780 } |
781 __ALFFXLOGSTRING1("CPolicyHandler::RemoveControlKml - return: %d <<", err); |
781 __ALFFXLOGSTRING1("CPolicyHandler::RemoveControlKml - return: %d <<", err); |
782 return err; |
782 return err; |
783 } |
783 } |
784 |
784 |
785 // --------------------------------------------------------------------------- |
785 // --------------------------------------------------------------------------- |
786 // --------------------------------------------------------------------------- |
786 // --------------------------------------------------------------------------- |
787 // |
787 // |
788 TInt CPolicyHandler::UnregisterControlKml(const TThreadId &aThreadId) |
788 TInt CPolicyHandler::UnregisterControlKml(const TThreadId &aThreadId) |
789 { |
789 { |
790 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterControlKml - aThreadId: %d ", aThreadId.Id() ); |
790 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterControlKml - aThreadId: %d ", aThreadId.Id() ); |
791 CControlPolicy* ptr = NULL; |
791 CControlPolicy* ptr = NULL; |
792 CActionPolicy* action = NULL; |
792 CActionPolicy* action = NULL; |
793 TInt err = KErrNotFound; |
793 TInt err = KErrNotFound; |
794 TThreadId tid; |
794 TThreadId tid; |
795 TInt policyCount = iControlPolicies.Count(); |
795 TInt policyCount = iControlPolicies.Count(); |
796 |
796 |
797 for( TInt i = policyCount - 1; i >= 0; i--) |
797 for( TInt i = policyCount - 1; i >= 0; i--) |
798 { |
798 { |
799 ptr = iControlPolicies[i]; |
799 ptr = iControlPolicies[i]; |
800 tid = ptr->ThreadId(); |
800 tid = ptr->ThreadId(); |
801 |
801 |
802 if(tid.Id() == aThreadId.Id()) |
802 if(tid.Id() == aThreadId.Id()) |
803 { |
803 { |
804 // making sure that policies get removed from the running clients as well! |
804 // making sure that policies get removed from the running clients as well! |
805 TInt count = ptr->iControlPolicies.Count(); |
805 TInt count = ptr->iControlPolicies.Count(); |
806 if(count > 0) |
806 if(count > 0) |
807 { |
807 { |
808 for(TInt j = 0; j < count; j++) |
808 for(TInt j = 0; j < count; j++) |
809 { |
809 { |
810 action = ptr->iControlPolicies[j]; |
810 action = ptr->iControlPolicies[j]; |
811 iClientRequestHandler->RemoveControlPolicy(ptr->Uid(), action->iAction); |
811 iClientRequestHandler->RemoveControlPolicy(ptr->Uid(), action->iAction); |
812 } |
812 } |
813 } |
813 } |
814 iControlPolicies.Remove(i); |
814 iControlPolicies.Remove(i); |
815 delete ptr; |
815 delete ptr; |
816 ptr = NULL; |
816 ptr = NULL; |
817 err = KErrNone; |
817 err = KErrNone; |
818 } |
818 } |
819 } |
819 } |
820 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterControlKml - return: %d <<", err); |
820 __ALFFXLOGSTRING1("CPolicyHandler::UnregisterControlKml - return: %d <<", err); |
821 return err; |
821 return err; |
822 } |
822 } |
823 |
823 |
824 // --------------------------------------------------------------------------- |
824 // --------------------------------------------------------------------------- |
825 // --------------------------------------------------------------------------- |
825 // --------------------------------------------------------------------------- |
826 // |
826 // |
827 TInt CPolicyHandler::GetControlKml( TUid aUid, TUint aAction, TPtrC& aResourceDir, |
827 TInt CPolicyHandler::GetControlKml( TUid aUid, TUint aAction, TPtrC& aResourceDir, |
828 TPtrC& aFileName, TPtrC& aActionString, TInt& aCachePriority, |
828 TPtrC& aFileName, TPtrC& aActionString, TInt& aCachePriority, |
829 TInt& aWantedTime, TInt& aMinTime) |
829 TInt& aWantedTime, TInt& aMinTime) |
830 { |
830 { |
831 __ALFFXLOGSTRING2("CPolicyHandler::GetControlKml - aAction: %d aUid :0x%x", aAction, aUid ); |
831 __ALFFXLOGSTRING2("CPolicyHandler::GetControlKml - aAction: %d aUid :0x%x", aAction, aUid ); |
832 __ALFFXLOGSTRING3("CPolicyHandler::GetControlKml - aResourceDir: %S, aFilename :%S, aActionString: %S", &aResourceDir, &aFileName, &aActionString ); |
832 __ALFFXLOGSTRING3("CPolicyHandler::GetControlKml - aResourceDir: %S, aFilename :%S, aActionString: %S", &aResourceDir, &aFileName, &aActionString ); |
833 |
833 |
834 CControlPolicy* ptr = NULL; |
834 CControlPolicy* ptr = NULL; |
835 CActionPolicy* pPolicy = NULL; |
835 CActionPolicy* pPolicy = NULL; |
836 aResourceDir.Set( TPtrC() ); |
836 aResourceDir.Set( TPtrC() ); |
837 aFileName.Set( TPtrC() ); |
837 aFileName.Set( TPtrC() ); |
838 aActionString.Set( TPtrC() ); |
838 aActionString.Set( TPtrC() ); |
839 |
839 |
840 TInt itemCount = iControlPolicies.Count(); |
840 TInt itemCount = iControlPolicies.Count(); |
841 for(TInt i = 0; i < itemCount; i++) |
841 for(TInt i = 0; i < itemCount; i++) |
842 { |
842 { |
843 ptr = iControlPolicies[i]; |
843 ptr = iControlPolicies[i]; |
844 if( ptr->Uid() == aUid) |
844 if( ptr->Uid() == aUid) |
845 { |
845 { |
846 aResourceDir.Set( ptr->ResourceDir() ); |
846 aResourceDir.Set( ptr->ResourceDir() ); |
847 aFileName.Set( ptr->Filename() ); |
847 aFileName.Set( ptr->Filename() ); |
848 aCachePriority = ptr->CachePriority(); |
848 aCachePriority = ptr->CachePriority(); |
849 aWantedTime = ptr->WantedTime(); |
849 aWantedTime = ptr->WantedTime(); |
850 aMinTime = ptr->MinTime(); |
850 aMinTime = ptr->MinTime(); |
851 TInt actionCount = ptr->iControlPolicies.Count(); |
851 TInt actionCount = ptr->iControlPolicies.Count(); |
852 for(TInt j = 0; j < actionCount; j++) |
852 for(TInt j = 0; j < actionCount; j++) |
853 { |
853 { |
854 pPolicy = ptr->iControlPolicies[j]; |
854 pPolicy = ptr->iControlPolicies[j]; |
855 if(pPolicy->iAction == aAction) |
855 if(pPolicy->iAction == aAction) |
856 { |
856 { |
857 aActionString.Set( pPolicy->ActionString() ); |
857 aActionString.Set( pPolicy->ActionString() ); |
858 // For now, this entry should have no priority over others |
858 // For now, this entry should have no priority over others |
859 ptr->SetCachePriority(0); |
859 ptr->SetCachePriority(0); |
860 __ALFFXLOGSTRING("CPolicyHandler::GetControlKml - return KErrNone <<"); |
860 __ALFFXLOGSTRING("CPolicyHandler::GetControlKml - return KErrNone <<"); |
861 return KErrNone; |
861 return KErrNone; |
862 } |
862 } |
863 } |
863 } |
864 } |
864 } |
865 } |
865 } |
866 __ALFFXLOGSTRING("CPolicyHandler::GetControlKml - return KErrNotFound <<"); |
866 __ALFFXLOGSTRING("CPolicyHandler::GetControlKml - return KErrNotFound <<"); |
867 return KErrNotFound; |
867 return KErrNotFound; |
868 } |
868 } |
869 |
869 |
870 // --------------------------------------------------------------------------- |
870 // --------------------------------------------------------------------------- |
871 // --------------------------------------------------------------------------- |
871 // --------------------------------------------------------------------------- |
872 // |
872 // |
873 TInt CPolicyHandler::GetAllControlPolicies(RPointerArray<CClientControlPolicy>& aControlPolicies) |
873 TInt CPolicyHandler::GetAllControlPolicies(RPointerArray<CClientControlPolicy>& aControlPolicies) |
874 { |
874 { |
875 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies >>"); |
875 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies >>"); |
876 TInt err = KErrNone; |
876 TInt err = KErrNone; |
877 |
877 |
878 TInt itemCount = iControlPolicies.Count(); |
878 TInt itemCount = iControlPolicies.Count(); |
879 if( 0 >= itemCount) |
879 if( 0 >= itemCount) |
880 { |
880 { |
881 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNotFound <<"); |
881 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNotFound <<"); |
882 return KErrNotFound; |
882 return KErrNotFound; |
883 } |
883 } |
884 |
884 |
885 for(TInt i = 0; i < itemCount; i++) |
885 for(TInt i = 0; i < itemCount; i++) |
886 { |
886 { |
887 CClientControlPolicy* ptr = new CClientControlPolicy(); |
887 CClientControlPolicy* ptr = new CClientControlPolicy(); |
888 if ( ptr == NULL ) |
888 if ( ptr == NULL ) |
889 { |
889 { |
890 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<"); |
890 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<"); |
891 return KErrNoMemory; |
891 return KErrNoMemory; |
892 } |
892 } |
893 ptr->iUid = iControlPolicies[i]->Uid(); |
893 ptr->iUid = iControlPolicies[i]->Uid(); |
894 HBufC* fname = HBufC::New(iControlPolicies[i]->Filename().Length()); |
894 HBufC* fname = HBufC::New(iControlPolicies[i]->Filename().Length()); |
895 if ( fname == NULL ) |
895 if ( fname == NULL ) |
896 { |
|
897 delete ptr; |
|
898 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<"); |
|
899 return KErrNoMemory; |
|
900 } |
|
901 fname->Des().Copy(iControlPolicies[i]->Filename()); |
|
902 ptr->iFilename.Assign(fname); |
|
903 HBufC* resdir = HBufC::New(255); |
|
904 if ( resdir == NULL ) |
|
905 { |
896 { |
906 delete ptr; |
897 delete ptr; |
907 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<"); |
898 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<"); |
908 return KErrNoMemory; |
899 return KErrNoMemory; |
909 } |
900 } |
910 ptr->iResourceDir.Assign(resdir); |
901 fname->Des().Copy(iControlPolicies[i]->Filename()); |
911 // In order to actually copy the pointers to the policy data, we |
902 ptr->iFilename.Assign(fname); |
912 // need to iterate through the entire list. |
903 HBufC* resdir = HBufC::New(255); |
913 TInt count = iControlPolicies[i]->iControlPolicies.Count(); |
904 if ( resdir == NULL ) |
914 if(count > 0) |
905 { |
915 { |
906 delete ptr; |
916 for( TInt j = 0; j < count; j++) |
907 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<"); |
917 { |
908 return KErrNoMemory; |
918 err = ptr->iControlPolicies.Append(iControlPolicies[i]->iControlPolicies[j]); |
909 } |
919 if(KErrNone != err) |
910 ptr->iResourceDir.Assign(resdir); |
920 { |
911 // In order to actually copy the pointers to the policy data, we |
921 delete ptr; |
912 // need to iterate through the entire list. |
922 __ALFFXLOGSTRING1("CPolicyHandler::GetAllControlPolicies - return: %d <<", err); |
913 TInt count = iControlPolicies[i]->iControlPolicies.Count(); |
923 return err; |
914 if(count > 0) |
924 } |
915 { |
925 } |
916 for( TInt j = 0; j < count; j++) |
926 err = aControlPolicies.Append(ptr); |
917 { |
927 if(KErrNone != err) |
918 err = ptr->iControlPolicies.Append(iControlPolicies[i]->iControlPolicies[j]); |
928 { |
919 if(KErrNone != err) |
929 delete ptr; |
920 { |
930 __ALFFXLOGSTRING1("CPolicyHandler::GetAllControlPolicies - return: %d <<", err); |
921 delete ptr; |
931 return err; |
922 __ALFFXLOGSTRING1("CPolicyHandler::GetAllControlPolicies - return: %d <<", err); |
932 } |
923 return err; |
933 } |
924 } |
934 else |
925 } |
935 { |
926 err = aControlPolicies.Append(ptr); |
936 delete ptr; |
927 if(KErrNone != err) |
937 ptr = NULL; |
928 { |
938 } |
929 delete ptr; |
939 } |
930 __ALFFXLOGSTRING1("CPolicyHandler::GetAllControlPolicies - return: %d <<", err); |
940 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNotFound<<"); |
931 return err; |
941 return KErrNone; |
932 } |
942 } |
933 } |
|
934 else |
|
935 { |
|
936 delete ptr; |
|
937 ptr = NULL; |
|
938 } |
|
939 } |
|
940 __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNotFound<<"); |
|
941 return KErrNone; |
|
942 } |
943 |
943 |
944 // --------------------------------------------------------------------------- |
944 // --------------------------------------------------------------------------- |
945 // --------------------------------------------------------------------------- |
945 // --------------------------------------------------------------------------- |
946 // |
946 // |
947 TInt CPolicyHandler::RequestPolicy(const RMessage2& aMessage) |
947 TInt CPolicyHandler::RequestPolicy(const RMessage2& aMessage) |
948 { |
948 { |
949 return iClientRequestHandler->RequestPolicy(aMessage); |
949 return iClientRequestHandler->RequestPolicy(aMessage); |
950 } |
950 } |
951 |
951 |
952 // --------------------------------------------------------------------------- |
952 // --------------------------------------------------------------------------- |
953 // --------------------------------------------------------------------------- |
953 // --------------------------------------------------------------------------- |
954 // |
954 // |
955 TInt CPolicyHandler::GetPolicyL( TThreadId aClientId, TInt aPolicyCount, TPtr8& aOutBuf ) |
955 TInt CPolicyHandler::GetPolicyL( TThreadId aClientId, TInt aPolicyCount, TPtr8& aOutBuf ) |
956 { |
956 { |
957 return iClientRequestHandler->GetPolicyL( aClientId, aPolicyCount, aOutBuf ); |
957 return iClientRequestHandler->GetPolicyL( aClientId, aPolicyCount, aOutBuf ); |
958 } |
958 } |
959 |
959 |
960 // --------------------------------------------------------------------------- |
960 // --------------------------------------------------------------------------- |
961 // --------------------------------------------------------------------------- |
961 // --------------------------------------------------------------------------- |
962 // |
962 // |
963 void CPolicyHandler::RemoveClient( TThreadId aClientId ) |
963 void CPolicyHandler::RemoveClient( TThreadId aClientId ) |
964 { |
964 { |
965 iClientRequestHandler->RemoveClient( aClientId ); |
965 iClientRequestHandler->RemoveClient( aClientId ); |
966 } |
966 } |
967 |
967 |
968 // --------------------------------------------------------------------------- |
968 // --------------------------------------------------------------------------- |
969 // --------------------------------------------------------------------------- |
969 // --------------------------------------------------------------------------- |
970 // |
970 // |
971 /* |
971 /* |
972 void CPolicyHandler::RemoveDeadClients() |
972 void CPolicyHandler::RemoveDeadClients() |
973 { |
973 { |
974 iClientRequestHandler->RemoveDeadClients(); |
974 iClientRequestHandler->RemoveDeadClients(); |
975 } |
975 } |
976 */ |
976 */ |
977 |
977 |
978 // --------------------------------------------------------------------------- |
978 // --------------------------------------------------------------------------- |
979 // --------------------------------------------------------------------------- |
979 // --------------------------------------------------------------------------- |
980 // |
980 // |
981 /* |
981 /* |
982 void CPolicyHandler::DumpClientsL(RFileWriteStream& aFile) |
982 void CPolicyHandler::DumpClientsL(RFileWriteStream& aFile) |
983 { |
983 { |
984 iClientRequestHandler->DumpClientsL(aFile); |
984 iClientRequestHandler->DumpClientsL(aFile); |
985 } |
985 } |
986 */ |
986 */ |
987 |
987 |
988 |
988 |
989 //============== PRIVATE METHODS =================/ |
989 //============== PRIVATE METHODS =================/ |
990 |
990 |
991 // --------------------------------------------------------------------------- |
991 // --------------------------------------------------------------------------- |
992 // --------------------------------------------------------------------------- |
992 // --------------------------------------------------------------------------- |
993 // |
993 // |
994 TInt CPolicyHandler::FindControlPolicy(TUint aAction, TUid aUid, CActionPolicy*& aPolicy, TInt& aIndex) |
994 TInt CPolicyHandler::FindControlPolicy(TUint aAction, TUid aUid, CActionPolicy*& aPolicy, TInt& aIndex) |
995 { |
995 { |
996 __ALFFXLOGSTRING3("CPolicyHandler::FindControlPolicy - aAction: %d, aUid: 0x%x, aIndex: %d", aAction, aUid, aIndex ); |
996 __ALFFXLOGSTRING3("CPolicyHandler::FindControlPolicy - aAction: %d, aUid: 0x%x, aIndex: %d", aAction, aUid, aIndex ); |
997 |
997 |
998 TInt count = iControlPolicies.Count(); |
998 TInt count = iControlPolicies.Count(); |
999 aIndex = -1; // Setting index to low value to avoid accidental insertion. |
999 aIndex = -1; // Setting index to low value to avoid accidental insertion. |
1000 |
1000 |
1001 CControlPolicy* pData = NULL; |
1001 CControlPolicy* pData = NULL; |
1002 for(TInt i = 0; i < count; i++) |
1002 for(TInt i = 0; i < count; i++) |
1003 { |
1003 { |
1004 pData = iControlPolicies[i]; |
1004 pData = iControlPolicies[i]; |
1005 if(pData->Uid() == aUid) |
1005 if(pData->Uid() == aUid) |
1006 { |
1006 { |
1007 aIndex = i; |
1007 aIndex = i; |
1008 TInt j = pData->iControlPolicies.Count(); |
1008 TInt j = pData->iControlPolicies.Count(); |
1009 CActionPolicy* pPolicy = NULL; |
1009 CActionPolicy* pPolicy = NULL; |
1010 for(TInt q = 0; q < j; q++) |
1010 for(TInt q = 0; q < j; q++) |
1011 { |
1011 { |
1012 pPolicy = pData->iControlPolicies[q]; |
1012 pPolicy = pData->iControlPolicies[q]; |
1013 if(pPolicy->iAction == aAction) |
1013 if(pPolicy->iAction == aAction) |
1014 { |
1014 { |
1015 aPolicy = pPolicy; |
1015 aPolicy = pPolicy; |
1016 __ALFFXLOGSTRING("CPolicyHandler::FindControlPolicy - return KErrNone <<"); |
1016 __ALFFXLOGSTRING("CPolicyHandler::FindControlPolicy - return KErrNone <<"); |
1017 return KErrNone; |
1017 return KErrNone; |
1018 } |
1018 } |
1019 } |
1019 } |
1020 } |
1020 } |
1021 } |
1021 } |
1022 __ALFFXLOGSTRING("CPolicyHandler::FindControlPolicy - return KErrNotFound <<"); |
1022 __ALFFXLOGSTRING("CPolicyHandler::FindControlPolicy - return KErrNotFound <<"); |
1023 return KErrNotFound; |
1023 return KErrNotFound; |
1024 } |
1024 } |
1025 |
1025 |
1026 |
1026 |
1027 // --- EOF --- |
1027 // --- EOF --- |
1028 |
1028 |
1029 |
1029 |