|
1 // Copyright (c) 2007-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32std.h> |
|
17 #include "mmsgtestpropertywatcher.h" |
|
18 #include "cmsgtestpropertywatcher.h" |
|
19 |
|
20 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); |
|
21 |
|
22 EXPORT_C CMsgTestPropertyWatcher* CMsgTestPropertyWatcher::NewL(TUid aCategory, TUint aKey, MMsgTestPropertyWatcher& aCallback) |
|
23 { |
|
24 CMsgTestPropertyWatcher* self=new(ELeave) CMsgTestPropertyWatcher(); |
|
25 CleanupStack::PushL(self); |
|
26 self->ConstructL(aCategory, aKey, aCallback); |
|
27 CleanupStack::Pop(self); |
|
28 return self; |
|
29 } |
|
30 |
|
31 CMsgTestPropertyWatcher::CMsgTestPropertyWatcher() |
|
32 :CActive(EPriorityHigh) |
|
33 {} |
|
34 |
|
35 void CMsgTestPropertyWatcher::ConstructL(TUid aCategory, TUint aKey, MMsgTestPropertyWatcher& aCallback) |
|
36 { |
|
37 iCategory = aCategory; |
|
38 iKey = aKey; |
|
39 iCallback = &aCallback; |
|
40 |
|
41 User::LeaveIfError(iProperty.Attach(aCategory,aKey)); |
|
42 CActiveScheduler::Add(this); |
|
43 |
|
44 // initial subscription |
|
45 iProperty.Subscribe(iStatus); |
|
46 SetActive(); |
|
47 } |
|
48 |
|
49 EXPORT_C CMsgTestPropertyWatcher::~CMsgTestPropertyWatcher() |
|
50 { |
|
51 Cancel(); |
|
52 iProperty.Close(); |
|
53 } |
|
54 |
|
55 void CMsgTestPropertyWatcher::DoCancel() |
|
56 { |
|
57 iProperty.Cancel(); |
|
58 } |
|
59 |
|
60 void CMsgTestPropertyWatcher::RunL() |
|
61 { |
|
62 // re-subscribe before processing new value to prevent missing updates |
|
63 iProperty.Subscribe(iStatus); |
|
64 SetActive(); |
|
65 |
|
66 iCallback->HandleEventL(iProperty, iKey); |
|
67 } |
|
68 |
|
69 EXPORT_C RProperty& CMsgTestPropertyWatcher::Property() |
|
70 { |
|
71 return iProperty; |
|
72 } |