|
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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __SSMSYSTEMWIDEPROPERTY_H__ |
|
17 #define __SSMSYSTEMWIDEPROPERTY_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <e32property.h> |
|
21 |
|
22 #include <ssm/ssmswp.h> |
|
23 |
|
24 class CSsmPropertyMonitor; |
|
25 |
|
26 /** |
|
27 Read-only client interface to receive notifications when a |
|
28 System Wide Property's value is changed. |
|
29 |
|
30 The implementation is similar to RProperty so the general pitfalls |
|
31 of RProperties applies. I.e. if the value changes several times before |
|
32 being read, only the last set value will be available. And to |
|
33 avoid missing a second notification, subscribtion must be reissued |
|
34 the first thing when you get a change notification, not after the |
|
35 change have been handled. |
|
36 |
|
37 CSsmSystemWideProperty wraps this class in an active object. |
|
38 |
|
39 @see CSsmSystemWideProperty |
|
40 @publishedPartner |
|
41 @released |
|
42 */ |
|
43 NONSHARABLE_CLASS(RSsmSystemWideProperty) |
|
44 { |
|
45 public: |
|
46 IMPORT_C TInt Connect(TUint aSwpKey); |
|
47 TInt Connect(TUint aSwpKey, TUid aProcessSid); |
|
48 IMPORT_C void Close(); |
|
49 IMPORT_C TInt GetValue(TInt& aValue) const; |
|
50 IMPORT_C void Subscribe(TRequestStatus& aStatus); |
|
51 IMPORT_C void SubscribeCancel(); |
|
52 |
|
53 private: |
|
54 TUint iKey; |
|
55 RProperty iProperty; |
|
56 TInt iSpare[4]; |
|
57 }; |
|
58 |
|
59 /** |
|
60 Interface to implement for clients that want to use the @c CSsmSystemWideProperty |
|
61 utility class. |
|
62 |
|
63 @publishedPartner |
|
64 @released |
|
65 */ |
|
66 class MSwpChangeNotificationSubscriber |
|
67 { |
|
68 public: |
|
69 /** |
|
70 @c SwpChanged is called when the value of the subscribed Swp have changed |
|
71 @param aSwp contains the new value for the monitored Swp |
|
72 */ |
|
73 virtual void SwpChanged(TSsmSwp aSwp) = 0; |
|
74 }; |
|
75 |
|
76 /** |
|
77 Utility class for monitoring a system Wide Property. Maintains a list of |
|
78 subscribers that share a single active object. When the monitored |
|
79 Sytem Wide Property changes the subscribers will be notified in the order |
|
80 they were added to the list of subscribers. |
|
81 |
|
82 @see RSsmSystemWideProperty |
|
83 @publishedPartner |
|
84 @released |
|
85 */ |
|
86 NONSHARABLE_CLASS(CSsmSystemWideProperty) : public CBase |
|
87 { |
|
88 public: |
|
89 IMPORT_C static CSsmSystemWideProperty* NewL(TUint aSwpKey); |
|
90 IMPORT_C static CSsmSystemWideProperty* NewLC(TUint aSwpKey); |
|
91 static CSsmSystemWideProperty* NewLC(TUint aSwpKey, TUid aProcessSid); |
|
92 IMPORT_C ~CSsmSystemWideProperty(); |
|
93 IMPORT_C TInt GetValue(TSsmSwp& aSwp) const; |
|
94 IMPORT_C void AddSubscriberL(MSwpChangeNotificationSubscriber& aSubscriber); |
|
95 IMPORT_C void RemoveSubscriber(const MSwpChangeNotificationSubscriber& aSubscriber); |
|
96 //for CSsmPropertyMonitor |
|
97 void NotifySubscribers(TSsmSwp aSwp); |
|
98 |
|
99 private: |
|
100 CSsmSystemWideProperty(); |
|
101 void ConstructL(TUint aSwpKey, TUid aProcessSid); |
|
102 |
|
103 private: |
|
104 RPointerArray<MSwpChangeNotificationSubscriber> iSubscribers; // Elements of the array are not owned. |
|
105 CSsmPropertyMonitor* iMonitor; |
|
106 TInt iSpare[4]; |
|
107 }; |
|
108 |
|
109 |
|
110 #endif |