|
1 /* |
|
2 * Copyright (c) 2004 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: Notifier implementation to listen presence changes. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPENGPRESENCENOTIFIER2IMP_H |
|
19 #define CPENGPRESENCENOTIFIER2IMP_H |
|
20 |
|
21 // INCLUDES |
|
22 #include "RGenericObserverArray.h" |
|
23 #include "MPEngSIDChangeObserver.h" |
|
24 #include <E32Base.h> |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 //FORWARD DECLARATIONS |
|
31 class CPEngPresenceNotifier2; |
|
32 class CPEngNWSessionSlotStorageProxy; |
|
33 class CPEngTrackedPresenceIDs2; |
|
34 class CPEngTrackedPresenceIDCollection; |
|
35 class CPEngNWSessionSlotID2; |
|
36 class MPEngPresenceObserver2; |
|
37 class MPEngContactList2; |
|
38 class MPEngPresenceAttrManager; |
|
39 class MPEngStorageManagerWatcher; |
|
40 |
|
41 |
|
42 /** |
|
43 * Notifier API implementation for presence attributes. |
|
44 * |
|
45 * @since 3.0 |
|
46 */ |
|
47 NONSHARABLE_CLASS( CPEngPresenceNotifier2Imp ): public CBase, |
|
48 public MPEngSIDChangeObserver |
|
49 { |
|
50 public: /* Construction */ |
|
51 |
|
52 |
|
53 /** |
|
54 * Instantiates CPEngPresenceNotifier2Imp object. |
|
55 * |
|
56 * @return New CPEngPresenceNotifier2Imp instance. |
|
57 */ |
|
58 static CPEngPresenceNotifier2Imp* NewL( |
|
59 CPEngPresenceNotifier2& aInterface, |
|
60 TInt aPriority, |
|
61 const CPEngNWSessionSlotID2& aNWSessionSlotID ); |
|
62 |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 ~CPEngPresenceNotifier2Imp(); |
|
68 |
|
69 |
|
70 |
|
71 protected: |
|
72 |
|
73 /** |
|
74 * C++ constructor. |
|
75 */ |
|
76 CPEngPresenceNotifier2Imp( CPEngPresenceNotifier2& aInterface, |
|
77 TInt aPriority ); |
|
78 |
|
79 |
|
80 /** |
|
81 * Symbian OS constructor. |
|
82 */ |
|
83 void ConstructL( const CPEngNWSessionSlotID2& aNWSessionSlotID ); |
|
84 |
|
85 |
|
86 |
|
87 public: /* Attribute notifier implementation */ |
|
88 |
|
89 /** |
|
90 * Implementation. |
|
91 * @since 3.0 |
|
92 */ |
|
93 TBool IsActive() const; |
|
94 |
|
95 TInt Start( const MDesCArray& aPresenceIDs, |
|
96 const TArray<TUint32>& aTypes ); |
|
97 |
|
98 void Stop(); |
|
99 |
|
100 |
|
101 |
|
102 /** |
|
103 * Implementation. |
|
104 * @since 3.0 |
|
105 */ |
|
106 TInt Update( const MDesCArray& aPresenceIDs, |
|
107 const TArray<TUint32>* aTypes, |
|
108 TBool aKeepOldTrackeds ); |
|
109 TInt Remove( const TDesC& aPresenceID ); |
|
110 TInt Remove( TUint32 aType ); |
|
111 |
|
112 CPEngTrackedPresenceIDs2& TrackedPresenceIDs(); |
|
113 |
|
114 TInt AddObserver( MPEngPresenceObserver2& aObserver ); |
|
115 TInt RemoveObserver( MPEngPresenceObserver2& aObserver ); |
|
116 |
|
117 |
|
118 private: //from MPEngSIDChangeObserver |
|
119 |
|
120 |
|
121 /** |
|
122 * Handles change of the Storage IDs. |
|
123 * |
|
124 * @param aChangedSIDs The changed SIDs. |
|
125 */ |
|
126 void HandleSIDsChangeL( CPtrCArray& aChangedSIDs ); |
|
127 |
|
128 |
|
129 /** |
|
130 * Called when SIDs notifier fails. |
|
131 * |
|
132 * @param aError is the error code. |
|
133 */ |
|
134 void HandleSIDNotifyError( TInt aError ); |
|
135 |
|
136 |
|
137 |
|
138 private: //Implementation |
|
139 |
|
140 |
|
141 void GenerateSidsL( CDesCArray*& aGeneratedSids, |
|
142 const MDesCArray& aPresenceIDs ); |
|
143 void AddTrackedAttributesL( const TArray<TUint32>& aTypes ); |
|
144 TBool RemoveTrackedAttributes( const TArray<TUint32>& aTypes ); |
|
145 void MediateNotify( TInt aError ); |
|
146 void UpdateWatcherL( CDesCArray*& aSidsList, |
|
147 const MDesCArray& aPresenceIDs, |
|
148 const TArray<TUint32>& aTypes, |
|
149 TBool aKeepOldTrackeds ); |
|
150 |
|
151 |
|
152 /** |
|
153 * Notify mediator. |
|
154 * @since 3.0 |
|
155 */ |
|
156 NONSHARABLE_CLASS( TPresenceNotifyMediator ) : |
|
157 public MGenObserverNotifyMediator< MPEngPresenceObserver2 > |
|
158 { |
|
159 public: //Constructor |
|
160 TPresenceNotifyMediator( CPEngPresenceNotifier2& aNotifier, |
|
161 CPEngTrackedPresenceIDCollection& aPresenceIds ); |
|
162 |
|
163 private: //From MGenObserverNotifyMediator |
|
164 |
|
165 void MediateNotifyL( MPEngPresenceObserver2& aObserverToNotify ); |
|
166 void MediateNotifyError( MPEngPresenceObserver2& aObserverToNotify, |
|
167 TInt aLeaveError ); |
|
168 |
|
169 private: //Data |
|
170 |
|
171 //REF: The notifier argument |
|
172 CPEngPresenceNotifier2& iNotifier; |
|
173 |
|
174 //REF: Tracked presence Ids argument |
|
175 CPEngTrackedPresenceIDCollection& iPresenceIds; |
|
176 }; |
|
177 |
|
178 |
|
179 private: //Data |
|
180 |
|
181 //REF: Implemented interface |
|
182 CPEngPresenceNotifier2& iInterface; |
|
183 |
|
184 //OWN: The notifier priority |
|
185 TInt iCActivePriority; |
|
186 |
|
187 //OWN: |
|
188 CPEngNWSessionSlotStorageProxy* iUsedSlot; |
|
189 |
|
190 //OWN: Attribute manager |
|
191 MPEngPresenceAttrManager* iAttrManager; |
|
192 |
|
193 //OWN: Storage watcher |
|
194 MPEngStorageManagerWatcher* iWatcher; |
|
195 |
|
196 //OWN: Collection of tracked presence IDs |
|
197 CPEngTrackedPresenceIDCollection* iTrackedPresenceIDs; |
|
198 |
|
199 //OWN: Tracked attribute types |
|
200 RArray< TUint32 > iTrackedAttributes; |
|
201 |
|
202 //OWN: Observer array |
|
203 RGenericObserverArray< MPEngPresenceObserver2 > iObsArray; |
|
204 |
|
205 //OWN: Flags describing the notifier state |
|
206 // Flag contents are either EFalse or ETrue |
|
207 TInt8 iStarted; |
|
208 TInt8 iDying; |
|
209 TInt8 iReserved1; |
|
210 TInt8 iReserved2; |
|
211 |
|
212 }; |
|
213 |
|
214 #endif //CPENGPRESENCENOTIFIER2IMP_H |
|
215 |
|
216 // End of File |