author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2009 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 the License "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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#include <e32base.h> |
|
21 |
////#include <senduiconsts.h> |
|
22 |
#include "messaginginterface.h" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
23 |
#include <badesca.h> |
19 | 24 |
#include "getheader.h" |
25 |
#include <f32file.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include<liwservicehandler.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#include<msvstd.h> |
19 | 28 |
#include "messageheader.h" |
29 |
#ifdef MAIN |
|
30 |
#define getheader_test4 main |
|
31 |
#endif |
|
32 |
||
33 |
_LIT8(KService, "Service.Messaging"); |
|
34 |
_LIT8(KIDataSource,"IMessaging"); |
|
35 |
||
36 |
||
37 |
int getheader_test4(int, char**) |
|
38 |
{ |
|
39 |
__UHEAP_MARK; |
|
40 |
// Iter-3 test work |
|
41 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
42 |
||
43 |
CLiwGenericParamList* inParamList = &(iServiceHandler->InParamListL()); |
|
44 |
CLiwGenericParamList* outParamList = &(iServiceHandler->OutParamListL()); |
|
45 |
||
46 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
47 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
48 |
||
49 |
RCriteriaArray a; |
|
50 |
||
51 |
a.AppendL(crit); |
|
52 |
||
53 |
iServiceHandler->AttachL(a); |
|
54 |
||
55 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inParamList, *outParamList); |
|
56 |
||
57 |
delete crit; |
|
58 |
crit = NULL; |
|
59 |
a.Reset(); |
|
60 |
||
61 |
TInt pos = 0; |
|
62 |
MLiwInterface* interface = NULL; |
|
63 |
_LIT8(KDataSource, "IMessaging"); |
|
64 |
outParamList->FindFirst(pos,KDataSource ); |
|
65 |
if(pos != KErrNotFound) |
|
66 |
{ |
|
67 |
interface = (*outParamList)[pos].Value().AsInterface(); |
|
68 |
} |
|
69 |
||
70 |
outParamList->Reset(); |
|
71 |
// Iter-2 same |
|
72 |
||
73 |
||
74 |
||
75 |
_LIT8(KCmd,"GetList"); |
|
76 |
TLiwVariant content(_L("Inbox")); |
|
77 |
TLiwGenericParam elem ; |
|
78 |
elem.SetNameAndValueL(_L8("Type"),content); |
|
79 |
inParamList->AppendL(elem); |
|
80 |
content.Reset(); |
|
81 |
elem.Reset(); |
|
82 |
||
83 |
||
84 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
85 |
CleanupStack::PushL(map); |
|
86 |
||
87 |
CLiwDefaultList* mtmtypelist = CLiwDefaultList::NewL(); |
|
88 |
CleanupStack::PushL(mtmtypelist); |
|
89 |
||
90 |
||
91 |
TLiwVariant mmsmtm(KMessageTypeMMS);// how the user wud gv this param |
|
92 |
mtmtypelist->AppendL(mmsmtm); |
|
93 |
mmsmtm.Reset(); |
|
94 |
||
95 |
TLiwVariant add1(mtmtypelist); |
|
96 |
||
97 |
map->InsertL(_L8("MessageTypeList"), add1); // Mtmtype is added |
|
98 |
mtmtypelist->DecRef(); |
|
99 |
CleanupStack::Pop(mtmtypelist); |
|
100 |
add1.Reset(); |
|
101 |
||
102 |
||
103 |
CLiwDefaultList* senderlist = CLiwDefaultList::NewL(); |
|
104 |
CleanupStack::PushL(senderlist); |
|
105 |
||
106 |
HBufC* address1 = HBufC::NewL(20) ; |
|
107 |
CleanupStack::PushL(address1); |
|
108 |
address1->Des().Copy(_L("9008032761")); |
|
109 |
TLiwVariant addres1(address1); |
|
110 |
senderlist->AppendL(addres1); |
|
111 |
addres1.Reset(); |
|
112 |
CleanupStack::PopAndDestroy(address1); |
|
113 |
||
114 |
TLiwVariant from(senderlist); |
|
115 |
map->InsertL(_L8("SenderList"),from); // Sender list |
|
116 |
from.Reset(); |
|
117 |
||
118 |
CleanupStack::Pop(senderlist); |
|
119 |
senderlist->DecRef(); |
|
120 |
||
121 |
||
122 |
HBufC* subject = HBufC::NewL(20); |
|
123 |
subject->Des().Copy(_L8("MMS")); |
|
124 |
||
125 |
TLiwVariant sub(subject); |
|
126 |
map->InsertL(_L8("Subject"),sub); // subject is null |
|
127 |
sub.Reset(); |
|
128 |
delete subject; |
|
129 |
||
130 |
||
131 |
TDateTime start(2006,EJanuary,22,0,0,0,0); |
|
132 |
TTime startdate(start); |
|
133 |
TLiwVariant date1(startdate); |
|
134 |
map->InsertL(_L8("StartDate"),date1); |
|
135 |
date1.Reset(); |
|
136 |
||
137 |
TDateTime end(2007,EDecember,23,0,0,0,0); |
|
138 |
TTime enddate(end) ; |
|
139 |
TLiwVariant date2(enddate); |
|
140 |
map->InsertL(_L8("EndDate"),date2); |
|
141 |
date2.Reset(); |
|
142 |
||
143 |
TLiwVariant filterparam(map); |
|
144 |
TLiwGenericParam element ; |
|
145 |
element.SetNameAndValueL(_L8("Filter"),filterparam); |
|
146 |
filterparam.Reset(); |
|
147 |
||
148 |
||
149 |
inParamList->AppendL(element); |
|
150 |
element.Reset(); |
|
151 |
||
152 |
map->DecRef(); |
|
153 |
CleanupStack::Pop(map); |
|
154 |
||
155 |
CLiwDefaultMap* sortmap = CLiwDefaultMap::NewL(); |
|
156 |
CleanupStack::PushL(sortmap); |
|
157 |
||
158 |
HBufC* sort1 = HBufC::NewL(20) ; |
|
159 |
CleanupStack::PushL(sort1); |
|
160 |
sort1->Des().Copy(_L("Date")); |
|
161 |
TLiwVariant sort(sort1); |
|
162 |
sortmap->InsertL(_L8("Key"), sort); |
|
163 |
sort.Reset(); |
|
164 |
CleanupStack::PopAndDestroy(sort1); |
|
165 |
||
166 |
||
167 |
HBufC* order1 = HBufC::NewL(20) ; |
|
168 |
CleanupStack::PushL(order1); |
|
169 |
order1->Des().Copy(_L("Ascending")); |
|
170 |
TLiwVariant order(order1); |
|
171 |
sortmap->InsertL(_L8("Order"), order); |
|
172 |
order.Reset(); |
|
173 |
CleanupStack::PopAndDestroy(order1); |
|
174 |
||
175 |
||
176 |
TLiwVariant sortordermap(sortmap); |
|
177 |
TLiwGenericParam element1 ; |
|
178 |
element1.SetNameAndValueL(_L8("SortOrder"),sortordermap); |
|
179 |
sortordermap.Reset(); |
|
180 |
||
181 |
||
182 |
inParamList->AppendL(element1); |
|
183 |
element1.Reset(); |
|
184 |
||
185 |
||
186 |
sortmap->DecRef(); |
|
187 |
CleanupStack::Pop(sortmap); |
|
188 |
||
189 |
||
190 |
||
191 |
||
192 |
TInt err = 0; |
|
193 |
TRAP(err,interface->ExecuteCmdL( KCmd ,*inParamList ,*outParamList)); |
|
194 |
pos = 0 ; |
|
195 |
||
196 |
const TLiwGenericParam* output = outParamList->FindFirst( pos,_L8("ReturnValue")); |
|
197 |
||
198 |
TInt val=0; |
|
199 |
if(output) |
|
200 |
{ |
|
201 |
//RFile //fs; |
|
202 |
//R//fs r//fs; |
|
203 |
//r//fs.Connect(); |
|
204 |
//r//fs.Delete(_L("c:\\getheaderiter3_4.txt")); |
|
205 |
//fs.Create(r//fs, _L("c:\\getheaderiter3_4.txt"), EFileShareExclusive|EFileWrite) ; |
|
206 |
||
207 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
208 |
||
209 |
TLiwVariant data; |
|
210 |
||
211 |
while( iterlist->NextL(data)) |
|
212 |
{ |
|
213 |
||
214 |
const CLiwMap* Map = data.AsMap(); |
|
215 |
||
216 |
TLiwVariant mtmtype; |
|
217 |
Map->FindL(_L8("MessageType"),mtmtype); |
|
218 |
TPtrC mtm = mtmtype.AsDes(); |
|
219 |
||
220 |
if(mtm.FindF(_L("MMS")) == KErrNotFound) |
|
221 |
val++; |
|
222 |
||
223 |
||
224 |
TBuf8<50> buf; |
|
225 |
buf.Copy(mtm) ; |
|
226 |
//fs.Write(_L8("Mtm Id :")); |
|
227 |
//fs.Write(buf); |
|
228 |
//fs.Write(_L8("\n")); /// writing mtm type |
|
229 |
mtmtype.Reset(); |
|
230 |
||
231 |
TLiwVariant sender; |
|
232 |
Map->FindL(_L8("Sender"),sender); |
|
233 |
TPtrC send = sender.AsDes(); |
|
234 |
||
235 |
if(send.FindF(_L("9008032761")) == KErrNotFound) |
|
236 |
val++; |
|
237 |
||
238 |
||
239 |
buf.Copy(send) ; |
|
240 |
//fs.Write(_L8("Sender :")); |
|
241 |
//fs.Write(buf); |
|
242 |
//fs.Write(_L8("\n")); /// writing sender |
|
243 |
sender.Reset(); |
|
244 |
||
245 |
TLiwVariant subject1; |
|
246 |
Map->FindL(_L8("Subject"),subject1); |
|
247 |
TPtrC subjectdes = subject1.AsDes(); |
|
248 |
||
249 |
if(subjectdes.FindF(_L("MMS")) == KErrNotFound) |
|
250 |
val++; |
|
251 |
||
252 |
||
253 |
buf.Copy(subjectdes) ; |
|
254 |
//fs.Write(_L8("Subject :")); /// writing subject |
|
255 |
||
256 |
//fs.Write(buf); |
|
257 |
//fs.Write(_L8("\n")); |
|
258 |
subject1.Reset(); |
|
259 |
||
260 |
TLiwVariant messageid; |
|
261 |
Map->FindL(_L8("MessageId"),messageid); |
|
262 |
TInt id = (TInt)messageid.AsTInt32(); |
|
263 |
||
264 |
||
265 |
||
266 |
buf.Num(id) ; |
|
267 |
//fs.Write(_L8("Message id :")); |
|
268 |
//fs.Write(buf); |
|
269 |
//fs.Write(_L8("\n")); /// writing messageid |
|
270 |
messageid.Reset(); |
|
271 |
||
272 |
TLiwVariant date; |
|
273 |
Map->FindL(_L8("Time"),date); |
|
274 |
||
275 |
||
276 |
TTime date1 =(TTime) date.AsTTime(); |
|
277 |
||
278 |
||
279 |
TDateTime date2 = date1.DateTime(); |
|
280 |
||
281 |
buf.Num(date2.Day()); |
|
282 |
//fs.Write(_L8("Day:")); |
|
283 |
//fs.Write(buf); |
|
284 |
//fs.Write(_L8("\t")); /// writing day |
|
285 |
||
286 |
buf.Num(date2.Month()); |
|
287 |
//fs.Write(_L8("Month:")); |
|
288 |
//fs.Write(buf); |
|
289 |
//fs.Write(_L8("\t")); /// writing month |
|
290 |
||
291 |
buf.Num(date2.Year()); |
|
292 |
//fs.Write(_L8("Year:")); |
|
293 |
//fs.Write(buf); |
|
294 |
//fs.Write(_L8("\n")); /// writing year |
|
295 |
date.Reset(); |
|
296 |
||
297 |
TLiwVariant unreadflag; |
|
298 |
Map->FindL(_L8("Unread"),unreadflag); |
|
299 |
TBool unread = (TBool)unreadflag.AsTBool(); |
|
300 |
||
301 |
||
302 |
||
303 |
buf.Num(unread) ; |
|
304 |
//fs.Write(_L8("Unread flag :")); |
|
305 |
//fs.Write(buf); |
|
306 |
//fs.Write(_L8("\n")); /// writing unread |
|
307 |
unreadflag.Reset(); |
|
308 |
||
309 |
TLiwVariant attachmentflag; |
|
310 |
Map->FindL(_L8("Attachment"),attachmentflag); |
|
311 |
TBool attachment = (TBool)attachmentflag.AsTBool(); |
|
312 |
||
313 |
||
314 |
||
315 |
buf.Num(attachment) ; |
|
316 |
//fs.Write(_L8("Attachment Flag :")); |
|
317 |
//fs.Write(buf); |
|
318 |
//fs.Write(_L8("\n")); /// writing attachment |
|
319 |
attachmentflag.Reset(); |
|
320 |
||
321 |
TLiwVariant priorityflag; |
|
322 |
Map->FindL(_L8("Priority"),priorityflag); |
|
323 |
TPtrC priority = priorityflag.AsDes(); |
|
324 |
||
325 |
||
326 |
TLiwVariant bodytext; |
|
327 |
Map->FindL(_L8("BodyText"),bodytext); |
|
328 |
TPtrC bodytxt = bodytext.AsDes(); |
|
329 |
bodytext.Reset(); |
|
330 |
||
331 |
buf.Copy(priority) ; |
|
332 |
//fs.Write(_L8("Priority Flag :")); |
|
333 |
//fs.Write(buf); |
|
334 |
//fs.Write(_L8("\n")); /// writing priority |
|
335 |
priorityflag.Reset(); |
|
336 |
data.Reset(); /// upto here we get map by iterable list |
|
337 |
||
338 |
} |
|
339 |
//fs.Close(); |
|
340 |
//r//fs.Close(); |
|
341 |
||
342 |
} |
|
343 |
||
344 |
TInt index=0; |
|
345 |
||
346 |
interface->Close(); |
|
347 |
iServiceHandler->Reset(); |
|
348 |
delete iServiceHandler; |
|
349 |
||
350 |
__UHEAP_MARKEND; |
|
351 |
||
352 |
if(0 == val) |
|
353 |
return KErrNone; |
|
354 |
else |
|
355 |
return KErrGeneral; |
|
356 |
||
357 |
} |