|
1 /* |
|
2 * Copyright (c) 2006 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 for PC Group Interface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "CCAOpenChatsPC.h" |
|
23 #include "CCAArrayItemPC.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CCAOpenChatsPC : Ctor |
|
30 // |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CCAOpenChatsPC::CCAOpenChatsPC( const RPointerArray<MCAArrayItemPC>& |
|
34 aOpenChatsArray ) |
|
35 : iOpenChatsArray( aOpenChatsArray ), |
|
36 iActiveItem( -1 ) |
|
37 { |
|
38 } |
|
39 |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CCAOpenChatsPC : NewL |
|
43 // |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CCAOpenChatsPC* CCAOpenChatsPC::NewL( const RPointerArray<MCAArrayItemPC>& |
|
47 aOpenChatsArray ) |
|
48 { |
|
49 CCAOpenChatsPC* self = new ( ELeave ) CCAOpenChatsPC( aOpenChatsArray ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CCAOpenChatsPC : Destructor |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CCAOpenChatsPC::~CCAOpenChatsPC() |
|
59 { |
|
60 delete iActiveItemId; |
|
61 } |
|
62 |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CCAOpenChatsPC: GetIdentification |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 const TPtrC CCAOpenChatsPC::GetIdentification( TInt aIndex ) |
|
69 { |
|
70 if ( aIndex >= ( iOpenChatsArray.Count() ) || aIndex < 0 ) |
|
71 { |
|
72 return TPtrC ( KNullDesC ); |
|
73 } |
|
74 else |
|
75 { |
|
76 |
|
77 MCAArrayItemPC *arrayItem = ( MCAArrayItemPC * )iOpenChatsArray[aIndex]; |
|
78 switch ( arrayItem->Type() ) |
|
79 { |
|
80 |
|
81 case TEnumsPC::EConversationItem: |
|
82 case TEnumsPC::EGroupItem: |
|
83 { |
|
84 return arrayItem->GetItemNameText(); |
|
85 } |
|
86 |
|
87 case TEnumsPC::EInviteItem: |
|
88 { |
|
89 return *iInvitationIdentification; |
|
90 } |
|
91 default: |
|
92 break; |
|
93 |
|
94 } |
|
95 } |
|
96 |
|
97 return TPtrC ( KNullDesC ); |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CCAOpenChatsPC: GetId |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 const TPtrC CCAOpenChatsPC::GetId( TInt aIndex ) |
|
106 { |
|
107 if ( aIndex >= ( iOpenChatsArray.Count() ) || aIndex < 0 ) |
|
108 { |
|
109 return TPtrC ( KNullDesC ); |
|
110 } |
|
111 else |
|
112 { |
|
113 |
|
114 MCAArrayItemPC *arrayItem = ( MCAArrayItemPC * )iOpenChatsArray[aIndex]; |
|
115 switch ( arrayItem->Type() ) |
|
116 { |
|
117 |
|
118 case TEnumsPC::EConversationItem: |
|
119 { |
|
120 CCAConversationItemPC* conversationItem = |
|
121 dynamic_cast< CCAConversationItemPC* > ( iOpenChatsArray[aIndex] ); |
|
122 |
|
123 if ( conversationItem ) |
|
124 { |
|
125 return conversationItem->UserId(); |
|
126 } |
|
127 break; |
|
128 |
|
129 } |
|
130 case TEnumsPC::EGroupItem: |
|
131 { |
|
132 CCAGroupItemPC* groupItem = |
|
133 dynamic_cast< CCAGroupItemPC* > ( iOpenChatsArray[aIndex] ); |
|
134 |
|
135 if ( groupItem ) |
|
136 { |
|
137 return groupItem->GroupId(); |
|
138 } |
|
139 break; |
|
140 } |
|
141 |
|
142 case TEnumsPC::EInviteItem: |
|
143 { |
|
144 CCAInviteItemPC* inviteItem = |
|
145 dynamic_cast< CCAInviteItemPC* > ( iOpenChatsArray[aIndex] ); |
|
146 |
|
147 if ( inviteItem ) |
|
148 { |
|
149 return inviteItem->GetInviteID(); |
|
150 } |
|
151 break; |
|
152 } |
|
153 default: |
|
154 break; |
|
155 |
|
156 } |
|
157 |
|
158 return TPtrC ( KNullDesC ); |
|
159 } |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CCAOpenChatsPC: GetType |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 TEnumsPC::TItem CCAOpenChatsPC::GetType( TInt aIndex ) |
|
167 { |
|
168 |
|
169 if ( aIndex >= ( iOpenChatsArray.Count() ) || aIndex < 0 ) |
|
170 { |
|
171 return TEnumsPC::EInvalid; |
|
172 } |
|
173 else |
|
174 { |
|
175 MCAArrayItemPC *arrayItem = ( MCAArrayItemPC * )iOpenChatsArray[aIndex]; |
|
176 return arrayItem->Type(); |
|
177 } |
|
178 |
|
179 } |
|
180 |
|
181 |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CCAOpenChatsPC: Count |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 TInt CCAOpenChatsPC::Count() const |
|
188 { |
|
189 return iOpenChatsArray.Count(); |
|
190 } |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CCAOpenChatsPC: SetActiveItem |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CCAOpenChatsPC::SetActiveItem( const TInt aIndex ) |
|
198 { |
|
199 delete iActiveItemId; |
|
200 iActiveItem = aIndex; |
|
201 |
|
202 iActiveItemId = GetId( aIndex ).Alloc(); |
|
203 |
|
204 iActiveItemType = GetType( aIndex ); |
|
205 } |
|
206 |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CCAOpenChatsPC: GetActiveItem |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CCAOpenChatsPC::GetActiveItem( TDesC*& aId, TEnumsPC::TItem& aType ) |
|
213 { |
|
214 |
|
215 aId = NULL; |
|
216 |
|
217 if ( iActiveItemId ) |
|
218 { |
|
219 aId = iActiveItemId; |
|
220 } |
|
221 |
|
222 |
|
223 aType = iActiveItemType; |
|
224 |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // CCAOpenChatsPC: SetInvitationIdentification |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 void CCAOpenChatsPC::SetInvitationIdentification( TDesC* aIdentification ) |
|
232 { |
|
233 iInvitationIdentification = aIdentification; |
|
234 } |
|
235 |
|
236 // End of File |
|
237 |