|
1 /* |
|
2 * Copyright (c) 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: CVIMPSTUiDoubleListboxArray-array decorator |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cvimpstuidoublelistboxarray.h" |
|
21 #include "tvimpstconsts.h" |
|
22 #include "vimpstutils.h" |
|
23 #include "mvimpstprocessarray.h" |
|
24 #include "cvimpstuidoublelistboxtabviewcontrol.h" // tab control |
|
25 #include <vimpstuires.rsg> |
|
26 #include "tvimpstenums.h" |
|
27 #include "vimpstdebugprint.h" |
|
28 // platform includes |
|
29 |
|
30 #include <AknUtils.h> |
|
31 #include <StringLoader.h> |
|
32 #include <AknIconUtils.h> |
|
33 #include <AknIconArray.h> |
|
34 #include <eikclbd.h> |
|
35 #include <AknsConstants.h> |
|
36 |
|
37 #include <vimpstui.mbg> |
|
38 |
|
39 const TInt KAvtarLength = 3; |
|
40 _LIT( KAvatarString , "%d\t" ); |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 |
|
43 // Two-phased constructor. |
|
44 CVIMPSTUiDoubleListboxArray* CVIMPSTUiDoubleListboxArray::NewL(MVIMPSTProcessArray& aItemModel, |
|
45 CFormattedCellListBoxData* aListboxData, |
|
46 CVIMPSTUiDoubleStyleListBox& aListBox, |
|
47 CVIMPSTUiDoubleListBoxTabViewControl& aTabbedviewControl |
|
48 ) |
|
49 { |
|
50 CVIMPSTUiDoubleListboxArray* self = new (ELeave) CVIMPSTUiDoubleListboxArray( aItemModel, |
|
51 aListboxData, aListBox,aTabbedviewControl); |
|
52 |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // Destructor |
|
60 CVIMPSTUiDoubleListboxArray::~CVIMPSTUiDoubleListboxArray() |
|
61 { |
|
62 delete iData; |
|
63 } |
|
64 |
|
65 // C++ default constructor can NOT contain any code, that |
|
66 // might leave. |
|
67 // |
|
68 CVIMPSTUiDoubleListboxArray::CVIMPSTUiDoubleListboxArray( MVIMPSTProcessArray& aItemModel, |
|
69 CFormattedCellListBoxData* aListboxData, CVIMPSTUiDoubleStyleListBox& aListBox /*= NULL*/, |
|
70 CVIMPSTUiDoubleListBoxTabViewControl& aTabbedviewControl) |
|
71 : |
|
72 iItemArray(aItemModel), |
|
73 iListboxData( aListboxData ), |
|
74 iListBox(aListBox), |
|
75 iTabbedviewControl(aTabbedviewControl) |
|
76 { |
|
77 } |
|
78 |
|
79 // Symbian OS default constructor can leave. |
|
80 void CVIMPSTUiDoubleListboxArray::ConstructL() |
|
81 { |
|
82 |
|
83 // maximum length of icons appended to identification |
|
84 // There can be four icons (A+B and two on D-column) |
|
85 iMaxLengthOfIcons = |
|
86 KDefaultAvatar().Length()+ // longest A-Column icon |
|
87 (KTab().Length() * 2)+ // length of tabs between items |
|
88 KContactOnlineIconA().Length(); // longest D-Column icon |
|
89 |
|
90 // Reserve enough memory to handle maximum size item |
|
91 iData = HBufC::NewL( KFriendsListMaxIdentificationLength + |
|
92 KStatusMsgMaxLength + |
|
93 iMaxLengthOfIcons ); |
|
94 |
|
95 iPresenceSupported = iItemArray.IsSubServiceSupportedL(TVIMPSTEnums::EPresence); |
|
96 iIMSupported = iItemArray.IsSubServiceSupportedL(TVIMPSTEnums::EIM ); |
|
97 } |
|
98 |
|
99 |
|
100 // --------------------------------------------------------- |
|
101 // CVIMPSTUiDoubleListboxArray::MdcaCount |
|
102 // Returns the number of descriptor elements in a descriptor array. |
|
103 // (other items were commented in a header). |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 TInt CVIMPSTUiDoubleListboxArray::MdcaCount() const |
|
107 { |
|
108 return iItemArray.Count(); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CVIMPSTUiDoubleListboxArray::MdcaCount |
|
113 // Return pointer to descriptor data in given index of an array |
|
114 // (other items were commented in a header). |
|
115 // --------------------------------------------------------- |
|
116 // |
|
117 TPtrC16 CVIMPSTUiDoubleListboxArray::MdcaPoint( TInt aIndex ) const |
|
118 { |
|
119 CHAT_DP( D_CHAT_LIT("CVIMPSTUiArray::MdcaPoint: aIndex: %d"), aIndex ); |
|
120 // Although this is a const method, we do change the member data. |
|
121 // This is done because of performance |
|
122 // -> no need to create new buffer every time. |
|
123 TPtr dataPtr( iData->Des() ); |
|
124 dataPtr.Zero(); |
|
125 |
|
126 |
|
127 // fetch the item and process correct type |
|
128 TVIMPSTEnums::TItem type = iItemArray.GetType(aIndex); |
|
129 CHAT_DP( D_CHAT_LIT(" -> item type: %d"), type ); |
|
130 |
|
131 switch( type ) |
|
132 { |
|
133 case TVIMPSTEnums::EOwnStatusItem: |
|
134 { |
|
135 CHAT_DP( D_CHAT_LIT(" -> own data") ); |
|
136 TRAP_IGNORE( AppendOwnDataL(dataPtr,aIndex ) ); |
|
137 break; |
|
138 } |
|
139 case TVIMPSTEnums::EContactItem: |
|
140 case TVIMPSTEnums::EUnknonContactItem: |
|
141 case TVIMPSTEnums::EFriendRequestItem: |
|
142 { |
|
143 return iItemArray.GetFormattedString(aIndex); |
|
144 } |
|
145 default: |
|
146 { |
|
147 // shouldn't be here |
|
148 CHAT_DP( D_CHAT_LIT(" -> default") ); |
|
149 break; |
|
150 } |
|
151 } //end outer switch |
|
152 |
|
153 CHAT_DP( D_CHAT_LIT("CVIMPSTUiArray::MdcaPoint out") ); |
|
154 return dataPtr; |
|
155 } |
|
156 |
|
157 |
|
158 |
|
159 // --------------------------------------------------------- |
|
160 // CVIMPSTUiDoubleListboxArray::AppendContact |
|
161 // Append formatted contact identification to buffer |
|
162 // (other items were commented in a header). |
|
163 // --------------------------------------------------------- |
|
164 // |
|
165 void CVIMPSTUiDoubleListboxArray::AppendOwnDataL( TPtr& aBuffer, |
|
166 TInt aIndex |
|
167 ) const |
|
168 { |
|
169 CHAT_DP( D_CHAT_LIT("CVIMPSTUiArray::AppendOwnDataL" ) ); |
|
170 TVIMPSTEnums::TVIMPSTRegistrationState loginstate = iItemArray.GetLoginState(); |
|
171 CHAT_DP( D_CHAT_LIT("CVIMPSTUiArray::AppendOwnDataL, login state: %d" ), loginstate ); |
|
172 TInt avtarIndex = iItemArray.OwnAvatarIndexL(); |
|
173 |
|
174 if( avtarIndex ) |
|
175 { |
|
176 TBuf<KAvtarLength> buf; |
|
177 buf.Format( KAvatarString, avtarIndex); |
|
178 aBuffer.Append( buf); |
|
179 } |
|
180 else |
|
181 { |
|
182 // append default avatar for column A |
|
183 aBuffer.Append( KDefaultAvatar ); |
|
184 } |
|
185 // B-column append dispplay id |
|
186 |
|
187 |
|
188 // append only max length of the user id allowed : extra check |
|
189 |
|
190 TPtrC identification(VIMPSTUtils::DisplayId(iItemArray.GetItemUserId(aIndex))); |
|
191 aBuffer.Append( identification.Left( KFriendsListMaxIdentificationLength ) ); |
|
192 |
|
193 |
|
194 |
|
195 // append \t before second line text |
|
196 aBuffer.Append( KTab ); |
|
197 |
|
198 // append status text for second line and Icon for column D based on conditions |
|
199 if ( TVIMPSTEnums::ESVCERegistered == loginstate ) |
|
200 { |
|
201 TVIMPSTEnums::TOnlineStatus status = iItemArray.GetOnlineStatusL(aIndex); |
|
202 CHAT_DP( D_CHAT_LIT("CVIMPSTUiArray::AppendOwnDataL, status: %d" ), status ); |
|
203 TPtrC statusText = iItemArray.StatusTextL( aIndex ); |
|
204 if( statusText.Length() > 0) // if status text show it |
|
205 { |
|
206 // append only KStatusMsgMaxLenght of status masg |
|
207 aBuffer.Append( statusText.Left( KStatusMsgMaxLength ) ); |
|
208 } |
|
209 else |
|
210 { // show default if no status text based on status |
|
211 switch(status) // no need to handle the serviceout case as its not applicable here in case of own data |
|
212 { |
|
213 case TVIMPSTEnums::EOnline: |
|
214 { |
|
215 HBufC* onlineText = StringLoader::LoadLC( R_QTN_SERVTAB_DEFAULT_STATUSTEXT_ONLINE ); |
|
216 aBuffer.Append( onlineText->Des()); |
|
217 CleanupStack::PopAndDestroy(); //onlineText |
|
218 break; |
|
219 } |
|
220 case TVIMPSTEnums::EBusy: |
|
221 { |
|
222 HBufC* busyText = StringLoader::LoadLC( R_SERVDETAIL_STATUSTEXT_BUSY ) ; |
|
223 aBuffer.Append( busyText->Des()); |
|
224 CleanupStack::PopAndDestroy(); //busyText |
|
225 break; |
|
226 } |
|
227 case TVIMPSTEnums::EAway: |
|
228 { |
|
229 HBufC* awayText = StringLoader::LoadLC( R_QTN_SERVTAB_DEFAULT_STATUSTEXT_AWAY ); |
|
230 aBuffer.Append( awayText->Des()); |
|
231 CleanupStack::PopAndDestroy(); //awayText |
|
232 break; |
|
233 } |
|
234 case TVIMPSTEnums::EOnPhone: |
|
235 { |
|
236 HBufC* onphoneText = StringLoader::LoadLC( R_SERVDETAIL_STATUSTEXT_ONTHEPHONE ); |
|
237 aBuffer.Append( onphoneText->Des()); |
|
238 CleanupStack::PopAndDestroy(); //onphone text |
|
239 break; |
|
240 } |
|
241 case TVIMPSTEnums::EDoNotDisturb: |
|
242 { |
|
243 HBufC* dndText = StringLoader::LoadLC( R_SERVDETAIL_STATUSTEXT_DND ); |
|
244 aBuffer.Append( dndText->Des()); |
|
245 CleanupStack::PopAndDestroy(); //dnd Text |
|
246 break; |
|
247 } |
|
248 case TVIMPSTEnums::EInvisible: |
|
249 { |
|
250 HBufC* invisibleText = StringLoader::LoadLC( R_QTN_SERVTAB_DEFAULT_STATUSTEXT_INVISIBLE ); |
|
251 aBuffer.Append( invisibleText->Des()); |
|
252 CleanupStack::PopAndDestroy(); //invisible text |
|
253 break; |
|
254 } |
|
255 case TVIMPSTEnums::EOffline: |
|
256 default: |
|
257 { |
|
258 HBufC* offlineText = StringLoader::LoadLC( R_QTN_SERVTAB_DEFAULT_STATUSTEXT_OFFLINE ); |
|
259 aBuffer.Append( offlineText->Des()); |
|
260 CleanupStack::PopAndDestroy(); //offlineText |
|
261 break; |
|
262 } |
|
263 }// end case for status text |
|
264 } |
|
265 // append tab before appending icon |
|
266 aBuffer.Append( KTab ); |
|
267 |
|
268 CHAT_DP( D_CHAT_LIT("CVIMPSTUiArray::AppendOwnDataL, handle status enum: %d" ), status ); |
|
269 switch(status) |
|
270 { |
|
271 case TVIMPSTEnums::EOnline: |
|
272 { |
|
273 aBuffer.Append( KContactOnlineIconA ); |
|
274 break; |
|
275 } |
|
276 case TVIMPSTEnums::EInvisible: |
|
277 { |
|
278 aBuffer.Append( KListInvisibleIcon ); |
|
279 break; |
|
280 } |
|
281 case TVIMPSTEnums::EBusy: |
|
282 case TVIMPSTEnums::EDoNotDisturb: |
|
283 { |
|
284 aBuffer.Append( KListBusyIcon ); |
|
285 break; |
|
286 } |
|
287 case TVIMPSTEnums::EAway: |
|
288 { |
|
289 aBuffer.Append( KListAwayIcon ); |
|
290 break; |
|
291 } |
|
292 case TVIMPSTEnums::EOnPhone: |
|
293 { |
|
294 aBuffer.Append( KFrndOnMobileIcon ); |
|
295 break; |
|
296 } |
|
297 case TVIMPSTEnums::EOffline: //Flowthrough |
|
298 { |
|
299 aBuffer.Append( KContactOfflineIconA ); |
|
300 break; |
|
301 } |
|
302 case TVIMPSTEnums::EBlocked: |
|
303 case TVIMPSTEnums::EPending: |
|
304 default: |
|
305 { |
|
306 aBuffer.Append( KEmptyIconA ); |
|
307 break; |
|
308 } |
|
309 }//end switch |
|
310 |
|
311 } |
|
312 else |
|
313 { |
|
314 // except in disconnecting state show username |
|
315 if(TVIMPSTEnums::ESVCENetworkDisConnecting != loginstate ) |
|
316 { |
|
317 CHAT_DP( D_CHAT_LIT("CVIMPSTUiArray::AppendOwnDataL, offline state" ) ); |
|
318 TPtrC userId = iItemArray.LoginUserIdFromStoreL(); |
|
319 aBuffer.Append( VIMPSTUtils::DisplayId( userId )); |
|
320 } |
|
321 aBuffer.Append( KTab ); // append tab |
|
322 aBuffer.Append( KEmptyIconC ); // no icon |
|
323 } |
|
324 |
|
325 } |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 // End of File |