|
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 __SSMSTATEAWARESESSION_H__ |
|
17 #define __SSMSTATEAWARESESSION_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <domaindefs.h> |
|
21 |
|
22 #include <ssm/ssmstate.h> |
|
23 |
|
24 class CSsmStateMonitor; |
|
25 |
|
26 /** |
|
27 Read-only client interface to receive notifications when the |
|
28 System State changes. |
|
29 |
|
30 CSsmStateAwareSession wraps this class in an active object. |
|
31 |
|
32 @see CSsmStateAwareSession |
|
33 @publishedPartner |
|
34 @released |
|
35 */ |
|
36 NONSHARABLE_CLASS(RSsmStateAwareSession) |
|
37 { |
|
38 public: |
|
39 IMPORT_C RSsmStateAwareSession(); |
|
40 IMPORT_C TInt Connect(TDmDomainId aId); |
|
41 IMPORT_C void Close(); |
|
42 IMPORT_C TSsmState State() const; |
|
43 IMPORT_C void RequestStateNotification(TRequestStatus& aStatus); |
|
44 IMPORT_C void RequestStateNotificationCancel(); |
|
45 IMPORT_C void AcknowledgeStateNotification(TInt aError); |
|
46 IMPORT_C void AcknowledgeAndRequestStateNotification(TInt aError, TRequestStatus& aStatus); |
|
47 private: |
|
48 RSsmStateAwareSession(const RSsmStateAwareSession& aState); |
|
49 |
|
50 private: |
|
51 //The main reason for this class is to hide implementation details that might change |
|
52 class RPrivateImpl; |
|
53 RPrivateImpl* iPimpl; |
|
54 }; |
|
55 |
|
56 /** |
|
57 Interface to implement for clients that want to use the @c CSsmStateAwareSession |
|
58 utility class. |
|
59 |
|
60 @publishedPartner |
|
61 @released |
|
62 */ |
|
63 class MStateChangeNotificationSubscriber |
|
64 { |
|
65 public: |
|
66 /** |
|
67 @c StateChanged is called when the System State have changed |
|
68 @param aSsmState contains the new System State |
|
69 @see TSsmMainSystemStates |
|
70 */ |
|
71 virtual void StateChanged(TSsmState aSsmState) = 0; |
|
72 }; |
|
73 |
|
74 /** |
|
75 Utility class for monitoring the System State. Maintains a list of |
|
76 subscribers that share a single active object. When the System State |
|
77 changes the subscribers will be notified in the order |
|
78 they were added to the list of subscribers. |
|
79 |
|
80 @see TSsmMainSystemStates |
|
81 @see RSsmStateAwareSession |
|
82 @publishedPartner |
|
83 @released |
|
84 */ |
|
85 NONSHARABLE_CLASS(CSsmStateAwareSession) : public CBase |
|
86 { |
|
87 public: |
|
88 IMPORT_C static CSsmStateAwareSession* NewL(TDmDomainId aId); |
|
89 IMPORT_C static CSsmStateAwareSession* NewLC(TDmDomainId aId); |
|
90 IMPORT_C ~CSsmStateAwareSession(); |
|
91 IMPORT_C TSsmState State() const; |
|
92 IMPORT_C void AddSubscriberL(MStateChangeNotificationSubscriber& aSubscriber); |
|
93 IMPORT_C void RemoveSubscriber(const MStateChangeNotificationSubscriber& aSubscriber); |
|
94 // for CSsmStateMonitor |
|
95 void NotifySubscribers(TSsmState aNewState); |
|
96 |
|
97 private: |
|
98 CSsmStateAwareSession(); |
|
99 void ConstructL(TDmDomainId aId); |
|
100 |
|
101 private: |
|
102 RPointerArray<MStateChangeNotificationSubscriber> iSubscribers; // Elements of the array are not owned. |
|
103 CSsmStateMonitor* iMonitor; |
|
104 TInt iSpare[4]; |
|
105 }; |
|
106 |
|
107 #endif |