|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description : |
|
15 * |
|
16 */ |
|
17 #ifndef TSWINDOWGROUPSOBSERVER_H |
|
18 #define TSWINDOWGROUPSOBSERVER_H |
|
19 |
|
20 #include "tsresourcemanager.h" |
|
21 |
|
22 /** |
|
23 * Interface declare mathods to notify about window server events |
|
24 */ |
|
25 class MTsWindowGroupsObserver |
|
26 { |
|
27 public: |
|
28 /** |
|
29 * Method notidy about window group changes. |
|
30 * @param rsc - resource manager |
|
31 * @param wgs - list of window groups associated with running applications |
|
32 */ |
|
33 virtual void HandleWindowGroupChanged(MTsResourceManager &rsc, |
|
34 const TArray<RWsSession::TWindowGroupChainInfo> & wgs) =0; |
|
35 }; |
|
36 |
|
37 /** |
|
38 * Interface declare methods to subscribe windo server events |
|
39 */ |
|
40 class MTsWindowGroupsMonitor |
|
41 { |
|
42 public: |
|
43 /** |
|
44 * Method make subscription for window server events |
|
45 * @param observer - events observer |
|
46 */ |
|
47 virtual void SubscribeL(MTsWindowGroupsObserver & observer) =0; |
|
48 |
|
49 /** |
|
50 * Method cancel subscription for window server events |
|
51 * @param observer - events observer |
|
52 */ |
|
53 virtual void Cancel(MTsWindowGroupsObserver &) =0; |
|
54 }; |
|
55 |
|
56 /** |
|
57 * Window server observer implementation. Class automaticly subscribe / cancel subscription |
|
58 * at construction / destruction level. |
|
59 * |
|
60 */ |
|
61 class CTsWindowGroupsObserver: public CBase, |
|
62 public MTsWindowGroupsObserver |
|
63 { |
|
64 public: |
|
65 /** |
|
66 * Destructor |
|
67 * Function automaticly cancel subscrption to window server events |
|
68 */ |
|
69 ~CTsWindowGroupsObserver(); |
|
70 |
|
71 protected: |
|
72 /** |
|
73 * First phase constructor |
|
74 */ |
|
75 CTsWindowGroupsObserver(MTsWindowGroupsMonitor &); |
|
76 |
|
77 /** |
|
78 * Second phase constructor. |
|
79 * Function automaticly subscribe window server events |
|
80 */ |
|
81 void BaseConstructL(); |
|
82 |
|
83 private: |
|
84 MTsWindowGroupsMonitor & mMonitor; |
|
85 }; |
|
86 |
|
87 /** |
|
88 * Window server monitor implementation. |
|
89 */ |
|
90 class CTsWindowGroupsMonitor: public CActive, |
|
91 public MTsWindowGroupsMonitor |
|
92 |
|
93 { |
|
94 public: |
|
95 /** |
|
96 * Two phase constructor |
|
97 */ |
|
98 static CTsWindowGroupsMonitor* NewL(MTsResourceManager &); |
|
99 |
|
100 /** |
|
101 * Destructor |
|
102 */ |
|
103 ~CTsWindowGroupsMonitor(); |
|
104 |
|
105 /** |
|
106 * @see MTsWindowGroupsMonitor::SubscribeL |
|
107 */ |
|
108 void SubscribeL(MTsWindowGroupsObserver &); |
|
109 |
|
110 /** |
|
111 * @see MTsWindowGroupsMonitor::Cancel |
|
112 */ |
|
113 void Cancel(MTsWindowGroupsObserver &); |
|
114 |
|
115 protected: |
|
116 /** |
|
117 * @see CActive::RunL |
|
118 */ |
|
119 void RunL(); |
|
120 |
|
121 /** |
|
122 * @see CActive::DoCancel |
|
123 */ |
|
124 void DoCancel(); |
|
125 |
|
126 /** |
|
127 * @see CActive::RunError |
|
128 */ |
|
129 TInt RunError(TInt error); |
|
130 |
|
131 private: |
|
132 /** |
|
133 * First phase constructor |
|
134 */ |
|
135 CTsWindowGroupsMonitor(MTsResourceManager &); |
|
136 |
|
137 /** |
|
138 * Second phase constructor |
|
139 */ |
|
140 void ConstructL(); |
|
141 |
|
142 /** |
|
143 * Function subscribe for event to window server and activate object |
|
144 */ |
|
145 void Subscribe(); |
|
146 |
|
147 /** |
|
148 * Function provide window server event to observers |
|
149 */ |
|
150 void ProvideEventL(); |
|
151 |
|
152 /** |
|
153 * Function provide window server event to observer |
|
154 */ |
|
155 void ProvideEventL(TWsEvent, MTsWindowGroupsObserver &); |
|
156 |
|
157 private: |
|
158 /** |
|
159 * Registry of subscribed observers |
|
160 */ |
|
161 RPointerArray<MTsWindowGroupsObserver> mObservers; |
|
162 |
|
163 /** |
|
164 * Resources manager |
|
165 */ |
|
166 MTsResourceManager &mResources; |
|
167 |
|
168 /** |
|
169 * Monitor window group |
|
170 */ |
|
171 RWindowGroup mWg; |
|
172 }; |
|
173 #endif //TSWINDOWGROUPSOBSERVER_H |