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