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_test2 main |
|
31 |
#endif |
|
32 |
||
33 |
_LIT8(KService, "Service.Messaging"); |
|
34 |
_LIT8(KIDataSource,"IMessaging"); |
|
35 |
||
36 |
||
37 |
int getheader_test2(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 element1 ; |
|
78 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
79 |
inParamList->AppendL(element1); |
|
80 |
content.Reset(); |
|
81 |
element1.Reset(); |
|
82 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
83 |
CleanupStack::PushL(map); |
|
84 |
||
85 |
CLiwDefaultList* mtmtypelist = CLiwDefaultList::NewL(); |
|
86 |
CleanupStack::PushL(mtmtypelist); |
|
87 |
||
88 |
||
89 |
TLiwVariant mmsmtm(KMessageTypeMMS);// how the user wud gv this param |
|
90 |
mtmtypelist->AppendL(mmsmtm); |
|
91 |
mmsmtm.Reset(); |
|
92 |
||
93 |
TLiwVariant add1(mtmtypelist); |
|
94 |
||
95 |
map->InsertL(_L8("MessageTypeList"), add1); // Mtmtype is added |
|
96 |
mtmtypelist->DecRef(); |
|
97 |
CleanupStack::Pop(mtmtypelist); |
|
98 |
add1.Reset(); |
|
99 |
||
100 |
||
101 |
CLiwDefaultList* senderlist = CLiwDefaultList::NewL(); |
|
102 |
CleanupStack::PushL(senderlist); |
|
103 |
||
104 |
HBufC* address1 = HBufC::NewL(20) ; |
|
105 |
CleanupStack::PushL(address1); |
|
106 |
address1->Des().Copy(_L("9008032761")); |
|
107 |
TLiwVariant addres1(address1); |
|
108 |
senderlist->AppendL(addres1); |
|
109 |
addres1.Reset(); |
|
110 |
CleanupStack::PopAndDestroy(address1); |
|
111 |
||
112 |
TLiwVariant from(senderlist); |
|
113 |
map->InsertL(_L8("SenderList"),from); // Sender list |
|
114 |
from.Reset(); |
|
115 |
||
116 |
CleanupStack::Pop(senderlist); |
|
117 |
senderlist->DecRef(); |
|
118 |
||
119 |
||
120 |
HBufC* subject = HBufC::NewL(20); |
|
121 |
subject->Des().Copy(_L8("MMS")); |
|
122 |
||
123 |
TLiwVariant sub(subject); |
|
124 |
map->InsertL(_L8("Subject"),sub); // subject is null |
|
125 |
sub.Reset(); |
|
126 |
delete subject; |
|
127 |
||
128 |
||
129 |
TDateTime start(2006,EJanuary,22,0,0,0,0); |
|
130 |
TTime startdate(start); |
|
131 |
TLiwVariant date1(startdate); |
|
132 |
map->InsertL(_L8("StartDate"),date1); |
|
133 |
date1.Reset(); |
|
134 |
||
135 |
TDateTime end(2007,EDecember,23,0,0,0,0); |
|
136 |
TTime enddate(end) ; |
|
137 |
TLiwVariant date2(enddate); |
|
138 |
map->InsertL(_L8("EndDate"),date2); |
|
139 |
date2.Reset(); |
|
140 |
||
141 |
TLiwVariant filterparam(map); |
|
142 |
TLiwGenericParam element ; |
|
143 |
element.SetNameAndValueL(_L8("Filter"),filterparam); |
|
144 |
filterparam.Reset(); |
|
145 |
||
146 |
||
147 |
inParamList->AppendL(element); |
|
148 |
element.Reset(); |
|
149 |
||
150 |
map->DecRef(); |
|
151 |
CleanupStack::Pop(map); |
|
152 |
||
153 |
TInt err = 0; |
|
154 |
TRAP(err,interface->ExecuteCmdL( KCmd ,*inParamList ,*outParamList)); |
|
155 |
pos = 0 ; |
|
156 |
||
157 |
const TLiwGenericParam* output = outParamList->FindFirst( pos,_L8("ReturnValue")); |
|
158 |
||
159 |
TInt val=0; |
|
160 |
if(output) |
|
161 |
{ |
|
162 |
//RFile fs; |
|
163 |
//RFs rFs; |
|
164 |
//rFs.Connect(); |
|
165 |
//rFs.Delete(_L("c:\\getheaderiter3_2.txt")); |
|
166 |
//fs.Create(r//fs, _L("c:\\getheaderiter3_2.txt"), EFileShareExclusive|EFileWrite) ; |
|
167 |
||
168 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
169 |
||
170 |
TLiwVariant data; |
|
171 |
||
172 |
while( iterlist->NextL(data)) |
|
173 |
{ |
|
174 |
||
175 |
const CLiwMap* Map = data.AsMap(); |
|
176 |
||
177 |
TLiwVariant mtmtype; |
|
178 |
Map->FindL(_L8("MessageType"),mtmtype); |
|
179 |
TPtrC mtm = mtmtype.AsDes(); |
|
180 |
||
181 |
if(mtm.FindF(_L("MMS")) == KErrNotFound) |
|
182 |
val++; |
|
183 |
||
184 |
||
185 |
TBuf8<50> buf; |
|
186 |
buf.Copy(mtm) ; |
|
187 |
//fs.Write(_L8("Mtm Id :")); |
|
188 |
//fs.Write(buf); |
|
189 |
//fs.Write(_L8("\n")); /// writing mtm type |
|
190 |
mtmtype.Reset(); |
|
191 |
||
192 |
TLiwVariant sender; |
|
193 |
Map->FindL(_L8("Sender"),sender); |
|
194 |
TPtrC send = sender.AsDes(); |
|
195 |
||
196 |
if(send.FindF(_L("9008032761")) == KErrNotFound) |
|
197 |
val++; |
|
198 |
||
199 |
||
200 |
buf.Copy(send) ; |
|
201 |
//fs.Write(_L8("Sender :")); |
|
202 |
//fs.Write(buf); |
|
203 |
//fs.Write(_L8("\n")); /// writing sender |
|
204 |
sender.Reset(); |
|
205 |
||
206 |
TLiwVariant subject1; |
|
207 |
Map->FindL(_L8("Subject"),subject1); |
|
208 |
TPtrC subjectdes = subject1.AsDes(); |
|
209 |
||
210 |
if(subjectdes.FindF(_L("MMS")) == KErrNotFound) |
|
211 |
val++; |
|
212 |
||
213 |
||
214 |
buf.Copy(subjectdes) ; |
|
215 |
//fs.Write(_L8("Subject :")); /// writing subject |
|
216 |
||
217 |
//fs.Write(buf); |
|
218 |
//fs.Write(_L8("\n")); |
|
219 |
subject1.Reset(); |
|
220 |
||
221 |
TLiwVariant messageid; |
|
222 |
Map->FindL(_L8("MessageId"),messageid); |
|
223 |
TInt id = (TInt)messageid.AsTInt32(); |
|
224 |
||
225 |
||
226 |
||
227 |
buf.Num(id) ; |
|
228 |
//fs.Write(_L8("Message id :")); |
|
229 |
//fs.Write(buf); |
|
230 |
//fs.Write(_L8("\n")); /// writing messageid |
|
231 |
messageid.Reset(); |
|
232 |
||
233 |
TLiwVariant date; |
|
234 |
Map->FindL(_L8("Time"),date); |
|
235 |
||
236 |
||
237 |
TTime date1 =(TTime) date.AsTTime(); |
|
238 |
||
239 |
||
240 |
TDateTime date2 = date1.DateTime(); |
|
241 |
||
242 |
buf.Num(date2.Day()); |
|
243 |
//fs.Write(_L8("Day:")); |
|
244 |
//fs.Write(buf); |
|
245 |
//fs.Write(_L8("\t")); /// writing day |
|
246 |
||
247 |
buf.Num(date2.Month()); |
|
248 |
//fs.Write(_L8("Month:")); |
|
249 |
////fs.Write(buf); |
|
250 |
//fs.Write(_L8("\t")); /// writing month |
|
251 |
||
252 |
buf.Num(date2.Year()); |
|
253 |
//fs.Write(_L8("Year:")); |
|
254 |
//fs.Write(buf); |
|
255 |
//fs.Write(_L8("\n")); /// writing year |
|
256 |
date.Reset(); |
|
257 |
||
258 |
TLiwVariant unreadflag; |
|
259 |
Map->FindL(_L8("Unread"),unreadflag); |
|
260 |
TBool unread = (TBool)unreadflag.AsTBool(); |
|
261 |
||
262 |
||
263 |
||
264 |
buf.Num(unread) ; |
|
265 |
//fs.Write(_L8("Unread flag :")); |
|
266 |
////fs.Write(buf); |
|
267 |
//fs.Write(_L8("\n")); /// writing unread |
|
268 |
unreadflag.Reset(); |
|
269 |
||
270 |
TLiwVariant attachmentflag; |
|
271 |
Map->FindL(_L8("Attachment"),attachmentflag); |
|
272 |
TBool attachment = (TBool)attachmentflag.AsTBool(); |
|
273 |
||
274 |
||
275 |
||
276 |
buf.Num(attachment) ; |
|
277 |
//fs.Write(_L8("Attachment Flag :")); |
|
278 |
//fs.Write(buf); |
|
279 |
//fs.Write(_L8("\n")); /// writing attachment |
|
280 |
attachmentflag.Reset(); |
|
281 |
||
282 |
TLiwVariant priorityflag; |
|
283 |
Map->FindL(_L8("Priority"),priorityflag); |
|
284 |
TPtrC priority = priorityflag.AsDes(); |
|
285 |
||
286 |
||
287 |
TLiwVariant bodytext; |
|
288 |
Map->FindL(_L8("BodyText"),bodytext); |
|
289 |
TPtrC bodytxt = bodytext.AsDes(); |
|
290 |
bodytext.Reset(); |
|
291 |
||
292 |
buf.Copy(priority) ; |
|
293 |
//fs.Write(_L8("Priority Flag :")); |
|
294 |
//fs.Write(buf); |
|
295 |
//fs.Write(_L8("\n")); /// writing priority |
|
296 |
priorityflag.Reset(); |
|
297 |
data.Reset(); /// upto here we get map by iterable list |
|
298 |
||
299 |
} |
|
300 |
//fs.Close(); |
|
301 |
//r.Close(); |
|
302 |
||
303 |
} |
|
304 |
||
305 |
TInt index=0; |
|
306 |
||
307 |
interface->Close(); |
|
308 |
iServiceHandler->Reset(); |
|
309 |
delete iServiceHandler; |
|
310 |
||
311 |
__UHEAP_MARKEND; |
|
312 |
||
313 |
if(0 == val) |
|
314 |
return KErrNone; |
|
315 |
else |
|
316 |
return KErrGeneral; |
|
317 |
||
318 |
} |