|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Holds error message information |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CCAErrorData.h" |
|
20 #include "ChatDebugPrint.h" |
|
21 |
|
22 #include <impsdetailed.h> |
|
23 #include <impserrors.h> |
|
24 #include <badesca.h> |
|
25 |
|
26 const TInt KErrorDataArrayGranularity = 3; |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // Two-phased constructor. |
|
31 CCAErrorData* CCAErrorData::NewL( const CImpsDetailedResult& aDetailedResult ) |
|
32 { |
|
33 CCAErrorData* self = new ( ELeave ) CCAErrorData(); |
|
34 |
|
35 CleanupStack::PushL( self ); |
|
36 self->ConstructL( aDetailedResult ); |
|
37 CleanupStack::Pop( self ); |
|
38 |
|
39 return self; |
|
40 } |
|
41 |
|
42 // Two-phased constructor. |
|
43 CCAErrorData* CCAErrorData::NewL( |
|
44 TInt aCode, |
|
45 const TDesC& aDescription, |
|
46 const CPtrC16Array* aUserIDs, |
|
47 const CPtrC16Array* aGroupIDs, |
|
48 const CPtrC16Array* aMessageIDs, |
|
49 const CPtrC16Array* aScreenNames, |
|
50 const CPtrC16Array* aScreenNameGroup ) |
|
51 { |
|
52 CCAErrorData* self = new ( ELeave ) CCAErrorData(); |
|
53 |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL( |
|
56 aCode, |
|
57 aDescription, |
|
58 aUserIDs, |
|
59 aGroupIDs, |
|
60 aMessageIDs, |
|
61 aScreenNames, |
|
62 aScreenNameGroup ); |
|
63 |
|
64 CleanupStack::Pop( self ); |
|
65 |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 // Destructor |
|
71 CCAErrorData::~CCAErrorData() |
|
72 { |
|
73 delete iDescription; |
|
74 |
|
75 if ( iUserIDs ) |
|
76 { |
|
77 iUserIDs->Reset(); |
|
78 } |
|
79 delete iUserIDs; |
|
80 |
|
81 if ( iGroupIDs ) |
|
82 { |
|
83 iGroupIDs->Reset(); |
|
84 } |
|
85 delete iGroupIDs; |
|
86 |
|
87 if ( iMsgIDs ) |
|
88 { |
|
89 iMsgIDs->Reset(); |
|
90 } |
|
91 delete iMsgIDs; |
|
92 |
|
93 if ( iScreenNames ) |
|
94 { |
|
95 iScreenNames->Reset(); |
|
96 } |
|
97 delete iScreenNames; |
|
98 |
|
99 if ( iScreenNameGroup ) |
|
100 { |
|
101 iScreenNameGroup->Reset(); |
|
102 } |
|
103 delete iScreenNameGroup; |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // CCAErrorData::Code |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C TInt CCAErrorData::Code() const |
|
111 { |
|
112 // In case we get error code in specification format => 531 e.g. |
|
113 if ( iCode > 0 ) |
|
114 { |
|
115 // Imps_ERROR_BASE is negative so "+" |
|
116 return ( - iCode + Imps_ERROR_BASE ); |
|
117 } |
|
118 |
|
119 return iCode; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CCAErrorData::Description |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 EXPORT_C const TDesC& CCAErrorData::Description() const |
|
127 { |
|
128 return *iDescription; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------- |
|
132 // CCAErrorData::UserIDs |
|
133 // --------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C const CDesCArray& CCAErrorData::UserIDs() const |
|
136 { |
|
137 return *iUserIDs; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------- |
|
141 // CCAErrorData::GroupIDs |
|
142 // --------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C const CDesCArray& CCAErrorData::GroupIDs() const |
|
145 { |
|
146 return *iGroupIDs; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------- |
|
150 // CCAErrorData::MessageIDs |
|
151 // --------------------------------------------------------- |
|
152 // |
|
153 EXPORT_C const CDesCArray& CCAErrorData::MessageIDs() const |
|
154 { |
|
155 return *iMsgIDs; |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------- |
|
159 // CCAErrorData::ScreenNames |
|
160 // --------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C const CDesCArray& CCAErrorData::ScreenNames() const |
|
163 { |
|
164 return *iScreenNames; |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // CCAErrorData::ScreenNameGroup |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C const CDesCArray& CCAErrorData::ScreenNameGroup() const |
|
172 { |
|
173 return *iScreenNameGroup; |
|
174 } |
|
175 |
|
176 |
|
177 // Symbian OS default constructor can leave. |
|
178 void CCAErrorData::ConstructL( const CImpsDetailedResult& aDetailedResult ) |
|
179 { |
|
180 // Set all the data available |
|
181 SetCode( aDetailedResult.Code() ); |
|
182 |
|
183 iDescription = aDetailedResult.Descriptor().AllocL(); |
|
184 |
|
185 SetUserIDsL( aDetailedResult.UserIds() ); |
|
186 |
|
187 SetGroupIDsL( aDetailedResult.GroupIds() ); |
|
188 |
|
189 SetMessageIDsL( aDetailedResult.MessageIds() ); |
|
190 |
|
191 SetScreenNamesL( aDetailedResult.SNames() ); |
|
192 |
|
193 SetScreenNamesGroupsL( aDetailedResult.SNameGroups() ); |
|
194 |
|
195 } |
|
196 |
|
197 // Symbian OS default constructor can leave. |
|
198 void CCAErrorData::ConstructL( |
|
199 TInt aCode, |
|
200 const TDesC& aDescription, |
|
201 const CPtrC16Array* aUserIDs, |
|
202 const CPtrC16Array* aGroupIDs, |
|
203 const CPtrC16Array* aMessageIDs, |
|
204 const CPtrC16Array* aScreenNames, |
|
205 const CPtrC16Array* aScreenNameGroup ) |
|
206 { |
|
207 // Set all the data available |
|
208 SetCode( aCode ); |
|
209 |
|
210 iDescription = aDescription.AllocL(); |
|
211 |
|
212 SetUserIDsL( aUserIDs ); |
|
213 |
|
214 SetGroupIDsL( aGroupIDs ); |
|
215 |
|
216 SetMessageIDsL( aMessageIDs ); |
|
217 |
|
218 SetScreenNamesL( aScreenNames ); |
|
219 |
|
220 SetScreenNamesGroupsL( aScreenNameGroup ); |
|
221 } |
|
222 |
|
223 // C++ default constructor can NOT contain any code, that |
|
224 // might leave. |
|
225 // |
|
226 CCAErrorData::CCAErrorData() |
|
227 { |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------- |
|
231 // CCAErrorData::SetCode |
|
232 // --------------------------------------------------------- |
|
233 // |
|
234 void CCAErrorData::SetCode( TInt aCode ) |
|
235 { |
|
236 iCode = aCode; |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------- |
|
240 // CCAErrorData::SetUserIDsL |
|
241 // --------------------------------------------------------- |
|
242 // |
|
243 void CCAErrorData::SetUserIDsL( const CPtrC16Array* aUserIDs ) |
|
244 { |
|
245 iUserIDs = new ( ELeave ) CDesCArrayFlat( KErrorDataArrayGranularity ); |
|
246 // Get User WV IDs |
|
247 if ( aUserIDs ) |
|
248 { |
|
249 TInt count( aUserIDs->MdcaCount() ); |
|
250 for ( TInt arrayIndex( 0 ); arrayIndex < count; ++arrayIndex ) |
|
251 { |
|
252 iUserIDs->AppendL( aUserIDs->MdcaPoint( arrayIndex ) ); |
|
253 } |
|
254 } |
|
255 } |
|
256 |
|
257 |
|
258 // --------------------------------------------------------- |
|
259 // CCAErrorData::SetGroupIDsL |
|
260 // --------------------------------------------------------- |
|
261 // |
|
262 void CCAErrorData::SetGroupIDsL( const CPtrC16Array* aGroupIDs ) |
|
263 { |
|
264 iGroupIDs = new ( ELeave ) CDesCArrayFlat( KErrorDataArrayGranularity ); |
|
265 // Get group WV IDs |
|
266 if ( aGroupIDs ) |
|
267 { |
|
268 TInt count( aGroupIDs->MdcaCount() ); |
|
269 for ( TInt arrayIndex( 0 ); arrayIndex < count; ++arrayIndex ) |
|
270 { |
|
271 iGroupIDs->AppendL( aGroupIDs->MdcaPoint( arrayIndex ) ); |
|
272 } |
|
273 } |
|
274 } |
|
275 |
|
276 |
|
277 // --------------------------------------------------------- |
|
278 // CCAErrorData::SetMessageIDsL |
|
279 // --------------------------------------------------------- |
|
280 // |
|
281 void CCAErrorData::SetMessageIDsL( const CPtrC16Array* aMessageIDs ) |
|
282 { |
|
283 iMsgIDs = new ( ELeave ) CDesCArrayFlat( KErrorDataArrayGranularity ); |
|
284 // Get message ids |
|
285 if ( aMessageIDs ) |
|
286 { |
|
287 TInt count( aMessageIDs->MdcaCount() ); |
|
288 for ( TInt arrayIndex( 0 ); arrayIndex < count; ++arrayIndex ) |
|
289 { |
|
290 iMsgIDs->AppendL( aMessageIDs->MdcaPoint( arrayIndex ) ); |
|
291 } |
|
292 } |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------- |
|
296 // CCAErrorData::SetScreenNamesL |
|
297 // --------------------------------------------------------- |
|
298 // |
|
299 void CCAErrorData::SetScreenNamesL( const CPtrC16Array* aScreenNames ) |
|
300 { |
|
301 iScreenNames = new ( ELeave ) CDesCArrayFlat( KErrorDataArrayGranularity ); |
|
302 // Get screen names |
|
303 if ( aScreenNames ) |
|
304 { |
|
305 TInt count( aScreenNames->MdcaCount() ); |
|
306 for ( TInt arrayIndex( 0 ); arrayIndex < count; ++arrayIndex ) |
|
307 { |
|
308 iScreenNames->AppendL( aScreenNames->MdcaPoint( arrayIndex ) ); |
|
309 } |
|
310 } |
|
311 } |
|
312 |
|
313 |
|
314 // --------------------------------------------------------- |
|
315 // CCAErrorData::SetScreenNamesGroupsL |
|
316 // --------------------------------------------------------- |
|
317 // |
|
318 void CCAErrorData::SetScreenNamesGroupsL( |
|
319 const CPtrC16Array* aScreenNameGroups ) |
|
320 { |
|
321 iScreenNameGroup = |
|
322 new ( ELeave ) CDesCArrayFlat( KErrorDataArrayGranularity ); |
|
323 // Get groups of screen names |
|
324 if ( aScreenNameGroups ) |
|
325 { |
|
326 TInt count( aScreenNameGroups->MdcaCount() ); |
|
327 for ( TInt arrayIndex( 0 ); arrayIndex < count; ++arrayIndex ) |
|
328 { |
|
329 iScreenNameGroup->AppendL( |
|
330 aScreenNameGroups->MdcaPoint( arrayIndex ) ); |
|
331 } |
|
332 } |
|
333 } |
|
334 // End of File |