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 |
#include <e32base.h> |
|
20 |
////#include <senduiconsts.h> |
|
21 |
#include "messaginginterface.h" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
22 |
#include <badesca.h> |
19 | 23 |
#include "getheader.h" |
24 |
#include <f32file.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
25 |
#include<liwservicehandler.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include<msvstd.h> |
19 | 27 |
#include "messageheader.h" |
28 |
#ifdef MAIN |
|
29 |
#define getheader_test1 main |
|
30 |
#endif |
|
31 |
||
32 |
_LIT8(KService, "Service.Messaging"); |
|
33 |
_LIT8(KIDataSource,"IMessaging"); |
|
34 |
||
35 |
||
36 |
int getheader_test1(int, char**) |
|
37 |
{ |
|
38 |
__UHEAP_MARK; |
|
39 |
// Iter-3 test work |
|
40 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
41 |
||
42 |
CLiwGenericParamList* inParamList = &(iServiceHandler->InParamListL()); |
|
43 |
CLiwGenericParamList* outParamList = &(iServiceHandler->OutParamListL()); |
|
44 |
||
45 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
46 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
47 |
||
48 |
RCriteriaArray a; |
|
49 |
||
50 |
a.AppendL(crit); |
|
51 |
||
52 |
iServiceHandler->AttachL(a); |
|
53 |
||
54 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inParamList, *outParamList); |
|
55 |
||
56 |
delete crit; |
|
57 |
crit = NULL; |
|
58 |
a.Reset(); |
|
59 |
||
60 |
TInt pos = 0; |
|
61 |
MLiwInterface* interface = NULL; |
|
62 |
_LIT8(KDataSource, "IMessaging"); |
|
63 |
outParamList->FindFirst(pos,KDataSource ); |
|
64 |
if(pos != KErrNotFound) |
|
65 |
{ |
|
66 |
interface = (*outParamList)[pos].Value().AsInterface(); |
|
67 |
} |
|
68 |
||
69 |
outParamList->Reset(); |
|
70 |
// Iter-2 same |
|
71 |
||
72 |
||
73 |
||
74 |
_LIT8(KCmd,"GetList"); |
|
75 |
||
76 |
// Newly added code |
|
77 |
TLiwVariant content(_L("Inbox")); |
|
78 |
TLiwGenericParam element1 ; |
|
79 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
80 |
inParamList->AppendL(element1); |
|
81 |
content.Reset(); |
|
82 |
element1.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 |
TLiwVariant mmsmtm(KMessageTypeMMS);// how the user wud gv this param |
|
95 |
//mtmtypelist->AppendL(mmsmtm); |
|
96 |
mmsmtm.Reset(); |
|
97 |
||
98 |
TLiwVariant add1(mtmtypelist); |
|
99 |
||
100 |
map->InsertL(_L8("MessageTypeList"), add1); // Mtmtype is added |
|
101 |
mtmtypelist->DecRef(); |
|
102 |
CleanupStack::Pop(mtmtypelist); |
|
103 |
add1.Reset(); |
|
104 |
||
105 |
||
106 |
CLiwDefaultList* senderlist = CLiwDefaultList::NewL(); |
|
107 |
CleanupStack::PushL(senderlist); |
|
108 |
||
109 |
HBufC* address1 = HBufC::NewL(20) ; |
|
110 |
CleanupStack::PushL(address1); |
|
111 |
address1->Des().Copy(_L("9008032761")); |
|
112 |
TLiwVariant addres1(address1); |
|
113 |
//senderlist->AppendL(addres1); |
|
114 |
addres1.Reset(); |
|
115 |
CleanupStack::PopAndDestroy(address1); |
|
116 |
||
117 |
TLiwVariant from(senderlist); |
|
118 |
map->InsertL(_L8("SenderList"),from); // Sender list |
|
119 |
from.Reset(); |
|
120 |
||
121 |
CleanupStack::Pop(senderlist); |
|
122 |
senderlist->DecRef(); |
|
123 |
||
124 |
||
125 |
||
126 |
||
127 |
TDateTime start(2006,EJanuary,22,0,0,0,0); |
|
128 |
TTime startdate(start); |
|
129 |
TLiwVariant date1(startdate); |
|
130 |
// map->InsertL(_L8("StartDate"),date1); |
|
131 |
date1.Reset(); |
|
132 |
||
133 |
TDateTime end(2007,EDecember,23,0,0,0,0); |
|
134 |
TTime enddate(end) ; |
|
135 |
TLiwVariant date2(enddate); |
|
136 |
// map->InsertL(_L8("EndDate"),date2); |
|
137 |
date2.Reset(); |
|
138 |
||
139 |
TLiwVariant filterparam(map); |
|
140 |
TLiwGenericParam element ; |
|
141 |
element.SetNameAndValueL(_L8("Filter"),filterparam); |
|
142 |
filterparam.Reset(); |
|
143 |
||
144 |
||
145 |
inParamList->AppendL(element); |
|
146 |
element.Reset(); |
|
147 |
||
148 |
map->DecRef(); |
|
149 |
CleanupStack::Pop(map); |
|
150 |
||
151 |
TInt err = 0; |
|
152 |
TRAP(err,interface->ExecuteCmdL( KCmd ,*inParamList ,*outParamList)); |
|
153 |
pos = 0 ; |
|
154 |
||
155 |
const TLiwGenericParam* output = outParamList->FindFirst( pos,_L8("ReturnValue")); |
|
156 |
||
157 |
TInt val=0; |
|
158 |
if(output) |
|
159 |
{ |
|
160 |
//RFile fs; |
|
161 |
//RFs rFs; |
|
162 |
//rFs.Connect(); |
|
163 |
//rFs.Delete(_L("c:\\getheaderiter3_1.txt")); |
|
164 |
//fs.Create(r//fs, _L("c:\\getheaderiter3_1.txt"), EFileShareExclusive|EFileWrite) ; |
|
165 |
||
166 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
167 |
||
168 |
TLiwVariant data; |
|
169 |
||
170 |
while( iterlist->NextL(data)) |
|
171 |
{ |
|
172 |
||
173 |
const CLiwMap* Map = data.AsMap(); |
|
174 |
||
175 |
TLiwVariant mtmtype; |
|
176 |
Map->FindL(_L8("MessageType"),mtmtype); |
|
177 |
TPtrC mtm = mtmtype.AsDes(); |
|
178 |
||
179 |
if(mtm.FindF(_L("SMS")) == KErrNotFound ) |
|
180 |
val++; |
|
181 |
||
182 |
||
183 |
TBuf8<50> buf; |
|
184 |
buf.Copy(mtm) ; |
|
185 |
//fs.Write(_L8("Mtm Id :")); |
|
186 |
//fs.Write(buf); |
|
187 |
//fs.Write(_L8("\n")); /// writing mtm type |
|
188 |
mtmtype.Reset(); |
|
189 |
||
190 |
TLiwVariant sender; |
|
191 |
Map->FindL(_L8("Sender"),sender); |
|
192 |
TPtrC send = sender.AsDes(); |
|
193 |
||
194 |
//if(send.FindF(_L("9008032761")) == KErrNotFound) |
|
195 |
// val++; |
|
196 |
||
197 |
||
198 |
buf.Copy(send) ; |
|
199 |
//fs.Write(_L8("Sender :")); |
|
200 |
//fs.Write(buf); |
|
201 |
//fs.Write(_L8("\n")); /// writing sender |
|
202 |
sender.Reset(); |
|
203 |
TLiwVariant messageid; |
|
204 |
Map->FindL(_L8("MessageId"),messageid); |
|
205 |
TInt id = (TInt)messageid.AsTInt32(); |
|
206 |
||
207 |
||
208 |
||
209 |
buf.Num(id) ; |
|
210 |
//fs.Write(_L8("Message id :")); |
|
211 |
//fs.Write(buf); |
|
212 |
//fs.Write(_L8("\n")); /// writing messageid |
|
213 |
messageid.Reset(); |
|
214 |
||
215 |
TLiwVariant date; |
|
216 |
Map->FindL(_L8("Time"),date); |
|
217 |
||
218 |
||
219 |
TTime date1 =(TTime) date.AsTTime(); |
|
220 |
||
221 |
||
222 |
TDateTime date2 = date1.DateTime(); |
|
223 |
||
224 |
buf.Num(date2.Day()); |
|
225 |
//fs.Write(_L8("Day:")); |
|
226 |
//fs.Write(buf); |
|
227 |
//fs.Write(_L8("\t")); /// writing day |
|
228 |
||
229 |
buf.Num(date2.Month()); |
|
230 |
//fs.Write(_L8("Month:")); |
|
231 |
//fs.Write(buf); |
|
232 |
//fs.Write(_L8("\t")); /// writing month |
|
233 |
||
234 |
buf.Num(date2.Year()); |
|
235 |
//fs.Write(_L8("Year:")); |
|
236 |
//fs.Write(buf); |
|
237 |
//fs.Write(_L8("\n")); /// writing year |
|
238 |
date.Reset(); |
|
239 |
||
240 |
TLiwVariant unreadflag; |
|
241 |
Map->FindL(_L8("Unread"),unreadflag); |
|
242 |
TBool unread = (TBool)unreadflag.AsTBool(); |
|
243 |
||
244 |
||
245 |
||
246 |
buf.Num(unread) ; |
|
247 |
//fs.Write(_L8("Unread flag :")); |
|
248 |
//fs.Write(buf); |
|
249 |
//fs.Write(_L8("\n")); /// writing unread |
|
250 |
unreadflag.Reset(); |
|
251 |
TLiwVariant priorityflag; |
|
252 |
Map->FindL(_L8("Priority"),priorityflag); |
|
253 |
TPtrC priority = priorityflag.AsDes(); |
|
254 |
||
255 |
||
256 |
TLiwVariant bodytext; |
|
257 |
Map->FindL(_L8("BodyText"),bodytext); |
|
258 |
TPtrC bodytxt = bodytext.AsDes(); |
|
259 |
bodytext.Reset(); |
|
260 |
||
261 |
buf.Copy(priority) ; |
|
262 |
//fs.Write(_L8("Priority Flag :")); |
|
263 |
//fs.Write(buf); |
|
264 |
//fs.Write(_L8("\n")); /// writing priority |
|
265 |
priorityflag.Reset(); |
|
266 |
data.Reset(); /// upto here we get map by iterable list |
|
267 |
||
268 |
} |
|
269 |
//fs.Close(); |
|
270 |
//rfs.Close(); |
|
271 |
||
272 |
} |
|
273 |
||
274 |
TInt index=0; |
|
275 |
||
276 |
interface->Close(); |
|
277 |
iServiceHandler->Reset(); |
|
278 |
delete iServiceHandler; |
|
279 |
||
280 |
__UHEAP_MARKEND; |
|
281 |
||
282 |
if(0 == val) |
|
283 |
return KErrNone; |
|
284 |
else |
|
285 |
return KErrGeneral; |
|
286 |
||
287 |
} |