|
1 /* |
|
2 * Copyright (c) 2008-2008 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: Implementation of the presence handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CVIMPSTDETAILSPRESENCEHANDLER_H |
|
20 #define CVIMPSTDETAILSPRESENCEHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 #include <presencecachereadhandler2.h> // handling the presence cache events |
|
26 #include <mpresencebuddyinfo2.h> // buddy info class |
|
27 #include "tvimpstenums.h" |
|
28 #include "mvimpstdetailspresencehandler.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class MVIMPSTDetailsPresenceObserver; |
|
32 class MPresenceBuddyInfo2; |
|
33 class MPresenceCacheReader2; |
|
34 class MXIMPClient; |
|
35 class MXIMPContext; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 /** |
|
39 * Class implementing the header part control of vimpstdetailsviewplugin |
|
40 * |
|
41 * @lib vimpstdetailsviewplugin.dll |
|
42 * @since S60 v5.0 |
|
43 */ |
|
44 |
|
45 class CVIMPSTDetailsPresenceHandler :public CBase, |
|
46 public MVIMPSTDetailsPresenceHandler, |
|
47 public MPresenceCacheReadHandler2 |
|
48 { |
|
49 public: |
|
50 // Construction & destruction |
|
51 /** |
|
52 * Two-phased constructor |
|
53 * @param aServiceName, service data. |
|
54 * @param aObserver, presence observer |
|
55 * @param aPresenceSupported, presence supported or not |
|
56 * @return instance of this class |
|
57 * @since S60 v5.0 |
|
58 */ |
|
59 static CVIMPSTDetailsPresenceHandler* NewL( const TDesC& aServiceName, |
|
60 MVIMPSTDetailsPresenceObserver& aObserver, |
|
61 TBool aPresenceSupported ); |
|
62 |
|
63 /** |
|
64 * Destructor. |
|
65 * @since S60 v5.0 |
|
66 */ |
|
67 ~CVIMPSTDetailsPresenceHandler(); |
|
68 |
|
69 |
|
70 public: // from MVIMPSTDetailsPresenceHandler |
|
71 |
|
72 /** |
|
73 * from MVIMPSTDetailsPresenceHandler |
|
74 * fetch presence from cache |
|
75 * @since S60 v5.0 |
|
76 */ |
|
77 void SubscribePresenceL(const TDesC& aUserId ); |
|
78 |
|
79 /** |
|
80 * from MVIMPSTDetailsPresenceHandler |
|
81 * return the presence status |
|
82 * @since S60 v5.0 |
|
83 */ |
|
84 TVIMPSTEnums::TOnlineStatus GetPresenceStatus(); |
|
85 |
|
86 |
|
87 /** |
|
88 * from MVIMPSTDetailsPresenceHandler |
|
89 * @param aIndex , index of the control |
|
90 * @return Label for control |
|
91 * @since S60 v5.0 |
|
92 */ |
|
93 const TDesC& GetHeaderLabelDataL( TInt aIndex ); |
|
94 |
|
95 /** |
|
96 * from MVIMPSTDetailsPresenceHandler |
|
97 * @return the presence status message |
|
98 * @since S60 v5.0 |
|
99 */ |
|
100 const TDesC& GetStatusMessageL(); |
|
101 |
|
102 /** |
|
103 * function to get supported or not |
|
104 * @since S60 v5.0 |
|
105 * @return ETrue if supported |
|
106 */ |
|
107 TBool IsSupported() const ; |
|
108 |
|
109 |
|
110 public: // prescachereadhandler |
|
111 |
|
112 /** |
|
113 * Handler for AllBuddiesPresenceInService method of MPresenceCacheReader. |
|
114 * |
|
115 * @param aErrorCode |
|
116 * @param aPresenceBuddyInfoList presence infos for all buddies requested. |
|
117 * Ownership of elements to callee. Can be empty if not found. |
|
118 */ |
|
119 void HandlePresenceReadL(TInt aErrorCode, |
|
120 RPointerArray<MPresenceBuddyInfo2>& aPresenceBuddyInfoList) ; |
|
121 |
|
122 /** |
|
123 * Handler for Buddy presence change notifications. |
|
124 * |
|
125 * @param aErrorCode |
|
126 * @param aPresenceBuddyInfo presence info for buddy. |
|
127 * Ownership to callee. Can be NULL if aErrorCode exist. |
|
128 */ |
|
129 void HandlePresenceNotificationL(TInt aErrorCode, |
|
130 MPresenceBuddyInfo2* aPresenceBuddyInfo); |
|
131 |
|
132 |
|
133 private: |
|
134 |
|
135 /** |
|
136 * Constructor for performing 1st stage construction |
|
137 * @param aObserver, presence observer |
|
138 * @param aPresenceSupported, check for PresenceSupported or not |
|
139 * @since S60 v5.0 |
|
140 */ |
|
141 CVIMPSTDetailsPresenceHandler(MVIMPSTDetailsPresenceObserver& aObserver, |
|
142 TBool aPresenceSupported ); |
|
143 |
|
144 /** |
|
145 * Constructor for performing 2nd stage construction |
|
146 * @param aServiceName, service data. |
|
147 * @since S60 v5.0 |
|
148 */ |
|
149 void ConstructL( const TDesC& aServiceName ); |
|
150 |
|
151 /** |
|
152 |
|
153 /** |
|
154 * Converts the presence cache status to client supported presence status. |
|
155 * |
|
156 * @since 5.0 |
|
157 * @param aAvailabilityEnum presence cache status value. |
|
158 * @param aAvabilityText avability text,to support multiple presence states. |
|
159 * @return TVIMPSTEnums::TOnlineStatus client presence status. |
|
160 */ |
|
161 void ConvertPresenceCacheEnums(MPresenceBuddyInfo2::TAvailabilityValues aAvailabilityEnum, TPtrC aAvabilityText); |
|
162 |
|
163 /** |
|
164 * Helper function for the setting the status text and status |
|
165 * @param aStatusMessage, status message . |
|
166 * @since S60 v5.0 |
|
167 */ |
|
168 void ProcessStatusMesssageL(const TDesC& aStatusMessage ); |
|
169 |
|
170 |
|
171 /** |
|
172 * function to get the label text |
|
173 * @since S60 v5.0 |
|
174 * @return status text |
|
175 */ |
|
176 const TDesC& GetStatusTextL(); |
|
177 |
|
178 /** |
|
179 * Converts the presence cache extension keys |
|
180 * user for block and pending states to client supported presence status. |
|
181 * |
|
182 * @since 5.0 |
|
183 * @param aPresenceBuddyInfo presence buddy info class. |
|
184 */ |
|
185 void GetKeyFieldsAndValuesL(MPresenceBuddyInfo2& aPresenceBuddyInfo); |
|
186 |
|
187 |
|
188 |
|
189 private: // data member |
|
190 |
|
191 // not owns: reference to presence observer |
|
192 MVIMPSTDetailsPresenceObserver& iPresenceObserver; |
|
193 // Owns : ximp client |
|
194 MXIMPClient* iXIMClient ; |
|
195 //Own : ximp context |
|
196 MXIMPContext* iPresenceContext; |
|
197 //owns : pointer to presence read interface |
|
198 MPresenceCacheReader2* iPresenceCacheReader; |
|
199 // owns, service name |
|
200 HBufC* iServiceName; |
|
201 // owns, user id |
|
202 HBufC* iUserId; |
|
203 |
|
204 // owns, status message from server if any |
|
205 HBufC* iStatusMessage; |
|
206 |
|
207 // owns, status text , online/offline etc |
|
208 HBufC* iStatusText; |
|
209 |
|
210 // owns, status |
|
211 TVIMPSTEnums::TOnlineStatus iStatus; |
|
212 // owns, presence supported or not |
|
213 TBool iPresenceSupported; |
|
214 |
|
215 }; |
|
216 |
|
217 #endif // CVIMPSTDETAILSPRESENCEHANDLER_H |