changeset 5 | 453da2cfceef |
parent 4 | 90517678cc4f |
child 11 | 06b8e2af4411 |
4:90517678cc4f | 5:453da2cfceef |
---|---|
58 #include <mmsconst.h> |
58 #include <mmsconst.h> |
59 #include <MIUTMSG.H> |
59 #include <MIUTMSG.H> |
60 #include <MSVFIND.H> |
60 #include <MSVFIND.H> |
61 #include <IMPCMTM.H> |
61 #include <IMPCMTM.H> |
62 #include <mmsclient.h> |
62 #include <mmsclient.h> |
63 #include <etelmm.h> |
|
64 #include <msvapi.h> |
|
65 #include <IAPPrefs.h> |
|
66 #include <SMTCMTM.H> |
|
67 #include <SMUTHDR.H> |
|
63 #endif |
68 #endif |
64 |
69 |
65 #include <qdebug.h> |
70 #include <qdebug.h> |
66 |
71 |
67 QTM_USE_NAMESPACE |
72 QTM_USE_NAMESPACE |
77 |
82 |
78 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3) { }; |
83 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3) { }; |
79 |
84 |
80 void getFolders(RArray<TMsvId> &folders); |
85 void getFolders(RArray<TMsvId> &folders); |
81 |
86 |
87 int countMessages(); |
|
88 void deleteAllMessages(); |
|
89 void createMailAccountL(); |
|
90 void printAccounts(); |
|
91 void deleteAccounts(); |
|
92 void deleteAllFolders(); |
|
93 TInt createFolder(TPtrC name); |
|
94 |
|
82 TMsvId makeSMS(TMsvId folder); |
95 TMsvId makeSMS(TMsvId folder); |
83 TMsvId makeIMAP4(TMsvId folder); |
96 TMsvId makeIMAP4(TMsvId folder); |
84 |
97 |
85 CMsvSession *iSession; |
98 CMsvSession *iSession; |
86 CClientMtmRegistry *iMtmRegistry; |
99 CClientMtmRegistry *iMtmRegistry; |
87 CSmsClientMtm *iSmsMtm; |
100 CSmsClientMtm *iSmsMtm; |
88 CImap4ClientMtm *iImap4Mtm; |
101 CImap4ClientMtm *iImap4Mtm; |
102 CSmtpClientMtm *iSmtpMtm; |
|
89 CMmsClientMtm *iMmsMtm; |
103 CMmsClientMtm *iMmsMtm; |
90 |
104 |
91 RArray<TMsvId> iFolders; |
105 RArray<TMsvId> iFolders; |
92 RArray<TMsvId> iNewMsgs; |
106 RArray<TMsvId> iNewMsgs; |
107 TMsvId iMsvImapService; |
|
108 TMsvId iMsvSmtpService; |
|
93 |
109 |
94 }; |
110 }; |
95 |
111 |
96 TMsvId OsNative::makeSMS(TMsvId folder){ |
112 TMsvId OsNative::makeSMS(TMsvId folder){ |
97 TBuf<10> aAddress(_L("Nokia")); |
113 TBuf<10> aAddress(_L("Nokia")); |
98 TBuf<20> aDescription(_L("Important Message")); |
114 TBuf<20> aDescription(_L("Important Message")); |
99 |
115 |
100 _LIT(KTxt1,"Hi phone owner, how r u?"); |
116 _LIT(KTxt1,"Hi phone owner, how r u?"); |
101 |
117 |
102 TBuf<150> iMessage; |
118 TBuf<150> iMessage; |
103 iMessage.Copy(KTxt1); |
119 iMessage.Copy(KTxt1); |
104 |
120 |
105 // m_native->iSmsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId); //inbox KMsvDraftEntryId |
121 iSmsMtm->SwitchCurrentEntryL(folder); //inbox |
106 iSmsMtm->SwitchCurrentEntryL(folder); |
122 // Clean phones without a SIM doesn't have a default service |
107 |
123 // TMsvId serviceId; |
108 iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid); |
124 // TRAPD(err, serviceId = iSmsMtm->DefaultServiceL()); |
109 |
125 // if(err) { |
110 CSmsHeader& iHeader = iSmsMtm->SmsHeader(); |
126 // qDebug() << "No default service"; |
111 iHeader.SetFromAddressL(aAddress); |
127 // return 0; |
112 |
128 // } |
113 |
129 |
114 CRichText& body = iSmsMtm->Body(); |
130 |
115 body.Reset(); |
131 TRAPD(err1, iSmsMtm->SwitchCurrentEntryL( folder )); |
116 body.InsertL(0, iMessage); |
132 if(err1){ |
117 |
133 qDebug() << "Failed to create SMS1: " << err1; |
118 TMsvEntry entry = iSmsMtm->Entry().Entry(); |
134 return 0; |
119 entry.SetInPreparation(EFalse); |
135 } |
120 entry.SetVisible(ETrue); |
136 |
121 entry.iDate.HomeTime(); |
137 TRAPD(err, iSmsMtm->CreateMessageL( iSmsMtm->ServiceId() )); |
122 entry.iDescription.Set(aDescription); |
138 |
123 entry.iDetails.Set(aAddress); |
139 //TRAPD(err, iSmsMtm->CreateMessageL(KMsvLocalServiceIndexEntryId)); |
124 entry.SetUnread(EFalse); |
140 if(err){ |
125 |
141 qDebug() << "Failed to create SMS: " << err; |
126 |
142 return 0; |
127 iSmsMtm->Entry().ChangeL(entry); |
143 } |
128 iSmsMtm->SaveMessageL(); |
144 |
129 |
145 CSmsHeader& iHeader = iSmsMtm->SmsHeader(); |
130 return entry.Id(); |
146 TRAP(err, iHeader.SetFromAddressL(aAddress)); |
147 if(err) |
|
148 qDebug() << "Failed to set from address: " << err; |
|
149 |
|
150 CRichText& body = iSmsMtm->Body(); |
|
151 body.Reset(); |
|
152 TRAP(err, body.InsertL(0, iMessage)); |
|
153 if(err) |
|
154 qDebug() << "Failed to add body: " << err; |
|
155 |
|
156 TMsvEntry entry = iSmsMtm->Entry().Entry(); |
|
157 entry.SetInPreparation(EFalse); |
|
158 entry.SetVisible(ETrue); |
|
159 entry.iDate.HomeTime(); |
|
160 entry.iDescription.Set(aDescription); |
|
161 entry.iDetails.Set(aAddress); |
|
162 entry.SetUnread(ETrue); |
|
163 |
|
164 TRAP(err, |
|
165 iSmsMtm->Entry().ChangeL(entry); |
|
166 iSmsMtm->SaveMessageL(); |
|
167 ); |
|
168 if(err) |
|
169 qDebug() << "Failed to save changes: " << err; |
|
170 |
|
171 return entry.Id(); |
|
172 } |
|
173 |
|
174 void OsNative::printAccounts(){ |
|
175 RArray<TPopAccount> aPop; |
|
176 RArray<TImapAccount> aImap; |
|
177 RArray<TSmtpAccount> aSmtp; |
|
178 CEmailAccounts* account = CEmailAccounts::NewLC(); |
|
179 TRAPD(err, |
|
180 account->GetPopAccountsL(aPop); |
|
181 account->GetImapAccountsL(aImap); |
|
182 account->GetSmtpAccountsL(aSmtp); |
|
183 ); |
|
184 if(err){ |
|
185 qDebug()<< "Can't get all accounts"; |
|
186 } |
|
187 |
|
188 for(int i = 0; i < aPop.Count(); i++){ |
|
189 QString name = QString::fromUtf16(aPop[i].iPopAccountName.Ptr(), aPop[i].iPopAccountName.Length()); |
|
190 qDebug() << "Pop account: " << name << hex << " SMTP: " << aPop[i].iSmtpService; |
|
191 // account->DeletePopAccountL(aPop[i]); |
|
192 } |
|
193 for(int i = 0; i < aImap.Count(); i++){ |
|
194 QString name = QString::fromUtf16(aImap[i].iImapAccountName.Ptr(), aImap[i].iImapAccountName.Length()); |
|
195 qDebug() << "Imap account: " << name << hex << " SMTP: " << aImap[i].iSmtpService; |
|
196 // account->DeleteImapAccountL(aImap[i]); |
|
197 } |
|
198 for(int i = 0; i < aSmtp.Count(); i++){ |
|
199 QString name = QString::fromUtf16(aSmtp[i].iSmtpAccountName.Ptr(), aSmtp[i].iSmtpAccountName.Length()); |
|
200 qDebug() << "SMTP account: " << name << hex << " Related: " << aSmtp[i].iRelatedService; |
|
201 // account->DeleteSmtpAccountL(aSmtp[i]); |
|
202 } |
|
203 aPop.Close(); |
|
204 aSmtp.Close(); |
|
205 aImap.Close(); |
|
206 CleanupStack::PopAndDestroy(account); |
|
207 } |
|
208 |
|
209 void OsNative::deleteAccounts(){ |
|
210 RArray<TPopAccount> aPop; |
|
211 RArray<TImapAccount> aImap; |
|
212 RArray<TSmtpAccount> aSmtp; |
|
213 CEmailAccounts* account = CEmailAccounts::NewLC(); |
|
214 TRAPD(err, |
|
215 account->GetPopAccountsL(aPop); |
|
216 account->GetImapAccountsL(aImap); |
|
217 account->GetSmtpAccountsL(aSmtp); |
|
218 ); |
|
219 if(err){ |
|
220 qDebug()<< "Can't get all accounts"; |
|
221 } |
|
222 |
|
223 for(int i = 0; i < aPop.Count(); i++){ |
|
224 QString name = QString::fromUtf16(aPop[i].iPopAccountName.Ptr(), aPop[i].iPopAccountName.Size()); |
|
225 if(name.startsWith("BMTestAccount")) |
|
226 account->DeletePopAccountL(aPop[i]); |
|
227 } |
|
228 for(int i = 0; i < aImap.Count(); i++){ |
|
229 QString name = QString::fromUtf16(aImap[i].iImapAccountName.Ptr(), aImap[i].iImapAccountName.Size()); |
|
230 if(name.startsWith("BMTestAccount")) |
|
231 account->DeleteImapAccountL(aImap[i]); |
|
232 |
|
233 } |
|
234 for(int i = 0; i < aSmtp.Count(); i++){ |
|
235 QString name = QString::fromUtf16(aSmtp[i].iSmtpAccountName.Ptr(), aSmtp[i].iSmtpAccountName.Size()); |
|
236 if(name.startsWith("BMTestAccount")) |
|
237 account->DeleteSmtpAccountL(aSmtp[i]); |
|
238 } |
|
239 aPop.Close(); |
|
240 aSmtp.Close(); |
|
241 aImap.Close(); |
|
242 CleanupStack::PopAndDestroy(account); |
|
131 } |
243 } |
132 |
244 |
133 TMsvId OsNative::makeIMAP4(TMsvId folder){ |
245 TMsvId OsNative::makeIMAP4(TMsvId folder){ |
134 TBuf<20> aSubject(_L("Test Subject")); |
246 |
135 TBuf<20> aFrom(_L("Nokia@foo.com")); |
247 // create a new object to access an existing entry |
136 TBuf<20> aTo(_L("Boo@bar.com")); |
248 CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
137 TBuf<20> aDescription(_L("Test Message")); |
249 CleanupStack::PushL(msvEntry); // 1 |
138 |
250 |
139 _LIT(KTo, "Boo@bar.com"); |
251 msvEntry->SetEntryL(folder); |
140 _LIT(KTxt1,"Test autogenerated message by benchmark/tst_messaging for performance testing"); |
252 |
141 |
253 // mtm takes ownership of entry context |
142 TBuf<150> iMessage; |
254 CleanupStack::Pop(msvEntry); // 0 |
143 iMessage.Copy(KTxt1); |
255 iSmtpMtm->SetCurrentEntryL(msvEntry); |
144 |
256 |
145 // m_native->iSmsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId); //inbox KMsvDraftEntryId |
257 // create a new message |
146 iImap4Mtm->SwitchCurrentEntryL(folder); |
258 TMsvId defaultServiceId(0); |
147 |
259 defaultServiceId = iSmtpMtm->DefaultServiceL(); |
148 // Set the context to the folder in which message has to be created |
260 CMsvEntry *pE = iSession->GetEntryL(defaultServiceId); |
149 CMsvEntry* entry = CMsvEntry::NewL(*iSession,folder,TMsvSelectionOrdering()); |
261 CleanupStack::PushL(pE); |
150 CleanupStack::PushL(entry); |
262 QString name = QString::fromUtf16(pE->Entry().iDetails.Ptr(), pE->Entry().iDetails.Length()); |
151 entry->SetEntryL(folder); |
263 CleanupStack::PopAndDestroy(pE); |
152 |
264 iSmtpMtm->CreateMessageL(defaultServiceId); |
153 CMsvOperationActiveSchedulerWait* waiter=CMsvOperationActiveSchedulerWait::NewLC(); |
265 |
154 //CleanupStack::PushL(waiter); |
266 // set subject |
155 |
267 iSmtpMtm->SetSubjectL( _L("Test Message") ); |
156 TMsvEmailTypeList msvEmailTypeList = 0; |
268 // set body |
157 TMsvPartList partList = (KMsvMessagePartBody | KMsvMessagePartAttachments); |
269 iSmtpMtm->Body().Reset(); |
158 |
270 iSmtpMtm->Body().InsertL(0, _L("This is the text body")); |
159 CImEmailOperation* emailOperation = CImEmailOperation::CreateNewL(waiter->iStatus, *iSession,KMsvGlobalOutBoxIndexEntryId, partList, msvEmailTypeList, KUidMsgTypeSMTP); |
271 |
160 CleanupStack::PushL(emailOperation); |
272 // get the entry of the message |
161 waiter->Start(); |
273 TMsvEntry messageEntry = iSmtpMtm->Entry().Entry(); |
162 |
274 // AddSenderToMtmAddresseeL(*iSmtpMtm, parameters, ETrue ); |
163 TMsvId temp; |
275 // SetSenderToEntryDetails(messageEntry, parameters, ETrue); |
164 TPckgC<TMsvId> paramPack(temp); |
276 messageEntry.iMtm = KUidMsgTypeIMAP4; // or any other than KUidMsgTypeSMTP to display 'from' field instead of 'to' field |
165 const TDesC8& progBuf = emailOperation->ProgressL(); |
277 |
166 paramPack.Set(progBuf); |
278 // set the description field same as the message subject |
167 TMsvId newMessageId; |
279 messageEntry.iDescription.Set( _L("test") ); |
168 newMessageId = paramPack(); |
280 messageEntry.iDetails.Set( _L("test subject") ); |
169 |
281 |
170 entry->SetEntryL(newMessageId); |
282 // save the changes done above |
171 |
283 iSmtpMtm->Entry().ChangeL(messageEntry); |
172 CMsvStore* store = entry->EditStoreL(); |
284 // get an access to the message store |
173 CleanupStack::PushL(store); |
285 CMsvStore* store = msvEntry->EditStoreL(); |
174 CImHeader* emailEntry = CImHeader::NewLC(); |
286 CleanupStack::PushL(store); // 1 |
175 emailEntry->RestoreL(*store); |
287 |
176 emailEntry->SetFromL((TDesC8&)aFrom); |
288 // save the attachments |
177 emailEntry->SetSubjectL((TDesC&)aDescription); |
289 |
178 emailEntry->ToRecipients().AppendL(KTo); |
290 // save the changes made to the message store |
179 |
|
180 // Paragraph format layer for the rich text object |
|
181 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); |
|
182 CleanupStack::PushL(paraFormatLayer); |
|
183 // Character format layer for the rich text object |
|
184 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); |
|
185 CleanupStack::PushL(charFormatLayer); |
|
186 |
|
187 CRichText* bodyText = CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256); |
|
188 CleanupStack::PushL(bodyText); |
|
189 |
|
190 // Insert the contents of a buffer into the document at specified position |
|
191 bodyText->InsertL(0, KTxt1); |
|
192 store->StoreBodyTextL(*bodyText); |
|
193 emailEntry->StoreL(*store); |
|
194 // Store the changes permanently |
|
195 store->CommitL(); |
291 store->CommitL(); |
196 |
292 CleanupStack::PopAndDestroy(store); // 0 |
197 CleanupStack::PopAndDestroy(8,entry); // bodyText,charFormatLayer,paraFormatLayer,emailEntry,store, emailOperationg,waiter,entry |
293 // save the message |
294 iSmtpMtm->SaveMessageL(); |
|
295 // final fine tuning |
|
296 TMsvEmailEntry temailEntry = static_cast<TMsvEmailEntry>(messageEntry); |
|
297 temailEntry.SetMessageFolderType(EFolderTypeUnknown); |
|
298 temailEntry.SetDisconnectedOperation(ENoDisconnectedOperations); |
|
299 temailEntry.SetEncrypted(EFalse); |
|
300 temailEntry.SetSigned(EFalse); |
|
301 temailEntry.SetVCard(EFalse); |
|
302 temailEntry.SetVCalendar(EFalse); |
|
303 temailEntry.SetReceipt(EFalse); |
|
304 temailEntry.SetMHTMLEmail(EFalse); |
|
305 temailEntry.SetBodyTextComplete(ETrue); |
|
306 |
|
307 temailEntry.SetAttachment(EFalse); |
|
308 |
|
309 temailEntry.iDate.HomeTime(); |
|
310 temailEntry.SetVisible(ETrue); |
|
311 temailEntry.SetInPreparation(EFalse); |
|
312 temailEntry.SetUnread(ETrue); |
|
313 temailEntry.SetNew(ETrue); |
|
314 |
|
315 temailEntry.SetComplete(ETrue); |
|
316 temailEntry.iServiceId = iMsvSmtpService; |
|
317 temailEntry.iRelatedId = 0; |
|
318 |
|
319 iSmtpMtm->Entry().ChangeL(temailEntry); |
|
320 |
|
321 // reset email headers |
|
322 CImHeader* header = CImHeader::NewLC(); // 1 |
|
323 CMsvStore* msvStore = msvEntry->EditStoreL(); |
|
324 CleanupStack::PushL(msvStore); // 2 |
|
325 header->RestoreL(*msvStore); |
|
326 header->SetSubjectL( _L("test email") ); |
|
327 header->SetFromL( _L("blah@blah.com") ); |
|
328 header->SetReceiptAddressL( _L("Foo@bar.com") ); |
|
329 header->StoreL( *msvStore ); |
|
330 msvStore->CommitL(); |
|
331 CleanupStack::PopAndDestroy(2); // msvStore, header // 0 |
|
332 |
|
333 // id has been generated, store it for being able to delete |
|
334 // only entries created with Creator |
|
335 TMsvId id = messageEntry.Id(); |
|
336 return id; |
|
337 } |
|
338 |
|
339 |
|
340 void OsNative::deleteAllFolders() { |
|
341 |
|
342 RArray<TMsvId> aFolders; |
|
343 |
|
344 TRAP_IGNORE(getFolders(aFolders)); |
|
345 |
|
346 TMsvSelectionOrdering sort; |
|
347 sort.SetSorting(EMsvSortByNone); |
|
348 sort.SetShowInvisibleEntries(ETrue); |
|
349 |
|
350 for(int i = 0; i < aFolders.Count(); i++) { |
|
351 CMsvEntry* inboxContext = CMsvEntry::NewL(*iSession, aFolders[i], sort); |
|
352 CleanupStack::PushL(inboxContext); |
|
353 |
|
354 // Get all entries in the folder |
|
355 CMsvEntrySelection* entries = inboxContext->ChildrenL(); |
|
356 CleanupStack::PushL(entries); |
|
357 QString desc = QString::fromUtf16(inboxContext->Entry().iDetails.Ptr(), inboxContext->Entry().iDetails.Length()); |
|
358 |
|
359 for (TInt j = 0; j < entries->Count(); j++) { |
|
360 CMsvEntry* pEntry = CMsvEntry::NewL(*iSession, entries->At(j), sort); |
|
361 CleanupStack::PushL(pEntry); |
|
362 QString desc2 = QString::fromUtf16(pEntry->Entry().iDetails.Ptr(), pEntry->Entry().iDetails.Length()); |
|
363 |
|
364 const TMsvEntry &entry = pEntry->Entry(); |
|
365 if((desc != "My folders" || desc2 == "Templates")) { |
|
366 CleanupStack::PopAndDestroy(pEntry); |
|
367 continue; |
|
368 } |
|
369 |
|
370 CleanupStack::PopAndDestroy(pEntry); |
|
371 |
|
372 TMsvId id = entries->At(j); |
|
373 qDebug() << "Deleting: " << desc << "/" << desc2; |
|
374 TRAPD(ierr, iSession->RemoveEntry(id)); // works |
|
375 if(ierr){ |
|
376 qDebug() << "Failed to delete: " << ierr << " " << hex << entries->At(j); |
|
377 } |
|
378 } |
|
379 CleanupStack::PopAndDestroy(2, inboxContext); |
|
380 } |
|
381 } |
|
382 |
|
383 void OsNative::createMailAccountL() { |
|
384 CImIAPPreferences* outgoingIAPSet = CImIAPPreferences::NewLC(); // 1 |
|
385 CImIAPPreferences* incomingIAPSet = CImIAPPreferences::NewLC(); // 2 |
|
386 CEmailAccounts* account = CEmailAccounts::NewLC(); // 3 |
|
387 |
|
388 CImImap4Settings* imap4Set = new(ELeave) CImImap4Settings; |
|
389 CleanupStack::PushL(imap4Set); // 4 |
|
390 CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings; |
|
391 CleanupStack::PushL(smtpSet); // 5 |
|
392 |
|
393 account->PopulateDefaultSmtpSettingsL(*smtpSet, *outgoingIAPSet); |
|
394 account->PopulateDefaultImapSettingsL(*imap4Set, *outgoingIAPSet); |
|
395 |
|
396 imap4Set->SetDisconnectedUserMode(ETrue); |
|
397 imap4Set->SetSynchronise(EUseLocal); |
|
398 imap4Set->SetSubscribe(EUpdateNeither); |
|
399 imap4Set->SetAutoSendOnConnect(EFalse); |
|
400 imap4Set->SetGetMailOptions(EGetImap4EmailBodyText); |
|
401 imap4Set->SetUpdatingSeenFlags(ETrue); |
|
402 imap4Set->SetServerAddressL(_L("test.sdfsdf.wer.sadazsdsddf.com")); |
|
403 |
|
404 TImapAccount imapAccountId = account->CreateImapAccountL(_L("BMTestAccount"), *imap4Set, *incomingIAPSet, EFalse); |
|
405 TSmtpAccount smtpAccountId = account->CreateSmtpAccountL(imapAccountId, *smtpSet, *outgoingIAPSet, EFalse); |
|
406 account->SetDefaultSmtpAccountL(smtpAccountId); |
|
407 |
|
408 iMsvImapService = imapAccountId.iImapService; |
|
409 iMsvSmtpService = smtpAccountId.iSmtpAccountId; |
|
198 |
410 |
199 return entry->EntryId(); |
411 // Fails with NotSupported |
200 } |
412 //iImap4Mtm->ChangeDefaultServiceL(iMsvImapService); |
413 // Failed with invalid arg |
|
414 // iSmtpMtm->ChangeDefaultServiceL(iMsvSmtpService); |
|
415 CleanupStack::PopAndDestroy(5); |
|
416 |
|
417 } |
|
418 |
|
419 int OsNative::countMessages() { |
|
420 |
|
421 RArray<TMsvId> aFolders; |
|
422 int total = 0; |
|
423 |
|
424 TRAPD(err, getFolders(aFolders)); |
|
425 if(err){ |
|
426 qDebug() << "getFodlers faield: " << err; |
|
427 return 0; |
|
428 } |
|
429 |
|
430 for(int i = 0; i < aFolders.Count(); i++){ |
|
431 TMsvSelectionOrdering sort; |
|
432 sort.SetSorting(EMsvSortByNone); |
|
433 sort.SetShowInvisibleEntries(ETrue); |
|
434 CMsvEntry* inboxContext = CMsvEntry::NewL(*iSession, |
|
435 aFolders[i], sort); |
|
436 CleanupStack::PushL(inboxContext); // 1 |
|
437 |
|
438 // Get all entries in the Inbox |
|
439 CMsvEntrySelection* entries = inboxContext->ChildrenL(); |
|
440 CleanupStack::PushL(entries); // 2 |
|
441 for (TInt i = 0; i < entries->Count(); i++) { |
|
442 |
|
443 TMsvId entryID = entries->At(i); |
|
444 |
|
445 const TUid mtm = inboxContext->ChildDataL(entryID).iMtm; |
|
446 if (mtm == KUidMsgTypeSMS) { |
|
447 total++; |
|
448 } |
|
449 else if ((mtm == KUidMsgTypeIMAP4) || (mtm == KUidMsgTypeSMTP)) { |
|
450 total++; |
|
451 } |
|
452 else { |
|
453 } |
|
454 } |
|
455 CleanupStack::PopAndDestroy(2, inboxContext); |
|
456 } |
|
457 return total; |
|
458 } |
|
459 |
|
460 void OsNative::deleteAllMessages() { |
|
461 |
|
462 RArray<TMsvId> aFolders; |
|
463 |
|
464 TRAPD(err, getFolders(aFolders)); |
|
465 if(err){ |
|
466 qDebug() << "getFodlers faield: " << err; |
|
467 return; |
|
468 } |
|
469 |
|
470 for(int i = 0; i < aFolders.Count(); i++){ |
|
471 TMsvSelectionOrdering sort; |
|
472 CMsvEntry* inboxContext = CMsvEntry::NewL(*iSession, aFolders[i], sort); |
|
473 CleanupStack::PushL(inboxContext); // 1 |
|
474 |
|
475 // Get all entries in the Inbox |
|
476 CMsvEntrySelection* entries = inboxContext->ChildrenL(); |
|
477 CleanupStack::PushL(entries); // 2 |
|
478 for (TInt i = 0; i < entries->Count(); i++) { |
|
479 |
|
480 TMsvId entryID = entries->At(i); |
|
481 const TUid mtm = inboxContext->ChildDataL(entryID).iMtm; |
|
482 |
|
483 if ((mtm == KUidMsgTypeSMS) || (mtm == KUidMsgTypeIMAP4) || (mtm == KUidMsgTypeSMTP)) { |
|
484 iSession->RemoveEntry(entryID); |
|
485 } |
|
486 } |
|
487 CleanupStack::PopAndDestroy(2, inboxContext); |
|
488 } |
|
489 } |
|
490 |
|
491 |
|
492 #define KMsvMyFoldersEntryIdValue 0x1008 |
|
493 const TMsvId KMsvMyFoldersEntryId=KMsvMyFoldersEntryIdValue; |
|
494 |
|
495 TInt OsNative::createFolder(TPtrC name){ |
|
496 TMsvId msvServId; |
|
497 CMsvEntry *entry1 = NULL; |
|
498 CMsvEntry * rootEntry = NULL; |
|
499 CMsvEntry *entryRootService = NULL; |
|
500 |
|
501 TInt newFldrID = 0; |
|
502 |
|
503 //Get the entry (whatever is passed in) |
|
504 entry1 = iSession->GetEntryL(KMsvMyFoldersEntryIdValue); |
|
505 CleanupStack::PushL(entry1); |
|
506 |
|
507 if (entry1) |
|
508 { |
|
509 msvServId = entry1->OwningService(); |
|
510 |
|
511 entryRootService = iSession->GetEntryL(msvServId); |
|
512 CleanupStack::PushL(entryRootService); |
|
513 |
|
514 rootEntry = iSession->GetEntryL(msvServId); |
|
515 CleanupStack::PushL(rootEntry); |
|
516 |
|
517 rootEntry->SetEntryL(KMsvMyFoldersEntryIdValue); // set to parent |
|
518 |
|
519 TMsvEntry newServiceEntry; |
|
520 |
|
521 newServiceEntry.iDate.HomeTime(); |
|
522 newServiceEntry.iSize = 0; |
|
523 newServiceEntry.iType = KUidMsvFolderEntry; |
|
524 newServiceEntry.iMtm = KUidMsvLocalServiceMtm; |
|
525 // newServiceEntry.iServiceId = iSmsMtm->ServiceId(); |
|
526 // newServiceEntry.iServiceId = KMsvLocalServiceIndexEntryId; |
|
527 newServiceEntry.iServiceId = iMsvImapService; |
|
528 newServiceEntry.iDetails.Set(name); |
|
529 newServiceEntry.iDescription.Set(KNullDesC); |
|
530 newServiceEntry.SetVisible(ETrue); |
|
531 |
|
532 TRAPD(err, rootEntry->CreateL(newServiceEntry)); |
|
533 if(err){ |
|
534 QString n = QString::fromUtf16(name.Ptr(), name.Size()); |
|
535 qDebug() << "Failed to create folder "<< n << ": " << err; |
|
536 User::Panic(_L("Fail"), err); |
|
537 } |
|
538 // qDebug() << "iError: " << newServiceEntry.iError << " complete: " << newServiceEntry.Complete() << " prot: " << newServiceEntry.DeleteProtected(); |
|
539 // newFldrID = newServiceEntry.Id(); |
|
540 CleanupStack::PopAndDestroy(); |
|
541 CleanupStack::PopAndDestroy(); |
|
542 } |
|
543 CleanupStack::PopAndDestroy(entry1); |
|
544 |
|
545 return newFldrID; |
|
546 } |
|
547 |
|
201 |
548 |
202 #else |
549 #else |
203 class OsNative { |
550 class OsNative { |
204 |
551 |
205 }; |
552 }; |
256 |
603 |
257 |
604 |
258 private slots: |
605 private slots: |
259 void initTestCase(); |
606 void initTestCase(); |
260 void cleanupTestCase(); |
607 void cleanupTestCase(); |
261 |
608 |
262 void tst_createTime_data(); |
609 void tst_createTime_data(); |
263 void tst_createTime(); |
610 void tst_createTime(); |
264 |
611 |
265 void tst_counts_data(); |
612 void tst_counts_data(); |
266 void tst_counts(); |
613 void tst_counts(); |
277 void tst_fetchFilter_data(); |
624 void tst_fetchFilter_data(); |
278 void tst_fetchFilter(); |
625 void tst_fetchFilter(); |
279 |
626 |
280 void tst_addMessage_data(); |
627 void tst_addMessage_data(); |
281 void tst_addMessage(); |
628 void tst_addMessage(); |
282 |
629 |
283 void tst_removeMessage_data(); |
630 void tst_removeMessage_data(); |
284 void tst_removeMessage(); |
631 void tst_removeMessage(); |
285 |
632 |
286 void tst_removeAllMessage_data(); |
633 void tst_removeAllMessage_data(); |
287 void tst_removeAllMessage(); |
634 void tst_removeAllMessage(); |
321 |
668 |
322 #else |
669 #else |
323 QFAIL("Platform not supported"); |
670 QFAIL("Platform not supported"); |
324 #endif |
671 #endif |
325 |
672 |
326 m_mgr = new QMessageManager(); |
|
327 |
|
328 QMessageAccountIdList list; |
|
329 list = m_mgr->queryAccounts(); |
|
330 while(!list.empty()) { |
|
331 QMessageAccount act = m_mgr->account(list.takeFirst()); |
|
332 qDebug() << "Account: " << act.name(); |
|
333 #if defined(Q_OS_SYMBIAN) |
|
334 if(act.name() == "Personal"){ |
|
335 m_act = act; |
|
336 break; |
|
337 } |
|
338 #endif |
|
339 } |
|
340 |
673 |
341 // QMessageFolderIdList flist = m_mgr->queryFolders(); |
674 // QMessageFolderIdList flist = m_mgr->queryFolders(); |
342 // while(!flist.empty()) { |
675 // while(!flist.empty()) { |
343 // QMessageFolder fol = m_mgr->folder(flist.takeFirst()); |
676 // QMessageFolder fol = m_mgr->folder(flist.takeFirst()); |
344 // qDebug() << "Folder: " << fol.name(); |
677 // qDebug() << "Folder: " << fol.name(); |
356 m_native->iSession = CMsvSession::OpenSyncL(*m_native); |
689 m_native->iSession = CMsvSession::OpenSyncL(*m_native); |
357 m_native->iMtmRegistry = CClientMtmRegistry::NewL(*m_native->iSession); |
690 m_native->iMtmRegistry = CClientMtmRegistry::NewL(*m_native->iSession); |
358 m_native->iSmsMtm = STATIC_CAST(CSmsClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeSMS)); |
691 m_native->iSmsMtm = STATIC_CAST(CSmsClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeSMS)); |
359 m_native->iImap4Mtm = STATIC_CAST(CImap4ClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeIMAP4)); |
692 m_native->iImap4Mtm = STATIC_CAST(CImap4ClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeIMAP4)); |
360 m_native->iMmsMtm = STATIC_CAST(CMmsClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeMultimedia)); |
693 m_native->iMmsMtm = STATIC_CAST(CMmsClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeMultimedia)); |
361 |
694 m_native->iSmtpMtm = STATIC_CAST(CSmtpClientMtm*,(m_native->iMtmRegistry->NewMtmL(KUidMsgTypeSMTP))); |
695 |
|
696 qDebug() << "Print accounts"; |
|
697 m_native->printAccounts(); |
|
698 qDebug() << "Delete accounts"; |
|
699 m_native->deleteAccounts(); |
|
700 qDebug() << "Delete all folders and messages"; |
|
701 m_native->deleteAllFolders(); |
|
702 m_native->deleteAllMessages(); |
|
703 qDebug() << "Create accounts"; |
|
704 TRAPD(err, m_native->createMailAccountL()); |
|
705 if(err) |
|
706 qDebug() << "Account create failed: " << err; |
|
707 qDebug() << "Oustanding ops: " << m_native->iSession->OutstandingOperationsL(); |
|
708 m_native->printAccounts(); |
|
709 qDebug() << "Create 3 folders"; |
|
710 m_native->createFolder(_L("Test1")); |
|
711 m_native->createFolder(_L("Test2")); |
|
712 m_native->createFolder(_L("Test3")); |
|
713 |
|
714 // Created messages with QMF, our symbian messages aren't very good |
|
715 // qDebug() << "Create 15 emails"; |
|
716 // for(int count = 0; count < 15; count++){ |
|
717 // TRAP(err, TMsvId id = m_native->makeIMAP4(KMsvGlobalInBoxIndexEntryId); |
|
718 // m_native->iNewMsgs.Append(id)); |
|
719 // if(err){ |
|
720 // qDebug() << "Error: " << err; |
|
721 // } |
|
722 // } |
|
723 |
|
724 |
|
725 // Can't create SMS messages on a phone with no msg center |
|
726 // qDebug() << "Create 15 SMS: " << m_native->iNewMsgs.Count(); |
|
727 // TRAPD(err, |
|
728 // for(int count = 0; count < 15; count++){ |
|
729 // TMsvId id = m_native->makeSMS(KMsvDraftEntryId); |
|
730 // m_native->iNewMsgs.Append(id); |
|
731 // } |
|
732 // ); |
|
733 qDebug() << "Initial state is set: " << m_native->iNewMsgs.Count(); |
|
734 RArray<TMsvId> folders; |
|
735 m_native->getFolders(folders); |
|
736 qDebug() << "Number of folders: " << folders.Count(); |
|
737 folders.Close(); |
|
738 qDebug() << "Number of messages: " << m_native->countMessages(); |
|
739 #else |
|
740 // this doesn't really create testable messages on symbian |
|
741 for(int i = 0; i < 30; i++) |
|
742 createMessage(); |
|
362 #endif |
743 #endif |
363 |
744 |
364 for(int i = 0; i < 20; i++) |
745 m_mgr = new QMessageManager(); |
746 |
|
747 QMessageAccountIdList list; |
|
748 list = m_mgr->queryAccounts(); |
|
749 while(!list.empty()) { |
|
750 QMessageAccount act = m_mgr->account(list.takeFirst()); |
|
751 qDebug() << "Account: " << act.name(); |
|
752 #if defined(Q_OS_SYMBIAN) |
|
753 if(act.name() == "BMTestAccount"){ |
|
754 qDebug() << "Using this account"; |
|
755 m_act = act; |
|
756 break; |
|
757 } |
|
758 #endif |
|
759 } |
|
760 |
|
761 |
|
762 for(int i = 0; i < 30; i++) |
|
365 createMessage(); |
763 createMessage(); |
366 |
|
367 } |
764 } |
368 |
765 |
369 void tst_messaging::cleanupTestCase() |
766 void tst_messaging::cleanupTestCase() |
370 { |
767 { |
371 |
768 |
769 clearMessages(); |
|
770 |
|
372 #if defined(Q_OS_SYMBIAN) |
771 #if defined(Q_OS_SYMBIAN) |
772 qDebug() << "Delete: Oustanding ops: " << m_native->iSession->OutstandingOperationsL() << " outstanding messages: " << m_native->countMessages(); |
|
773 m_native->deleteAccounts(); |
|
774 m_native->deleteAllFolders(); |
|
775 m_native->deleteAllMessages(); |
|
776 m_native->iSession->RemoveEntry(m_native->iMsvImapService); |
|
777 m_native->iSession->RemoveEntry(m_native->iMsvSmtpService); |
|
373 delete m_native->iMmsMtm; |
778 delete m_native->iMmsMtm; |
374 delete m_native->iImap4Mtm; |
779 delete m_native->iImap4Mtm; |
375 delete m_native->iSmsMtm; |
780 delete m_native->iSmsMtm; |
376 delete m_native->iMtmRegistry; |
781 delete m_native->iMtmRegistry; |
377 delete m_native->iSession; |
782 delete m_native->iSession; |
378 delete m_native; |
783 delete m_native; |
379 #endif |
784 #endif |
380 |
785 |
381 clearMessages(); |
|
382 delete m_mgr; |
786 delete m_mgr; |
383 |
787 |
384 |
788 |
385 } |
789 } |
386 |
790 |
414 #ifdef Q_OS_SYMBIAN |
818 #ifdef Q_OS_SYMBIAN |
415 |
819 |
416 __UHEAP_MARK; |
820 __UHEAP_MARK; |
417 |
821 |
418 if(m_native){ |
822 if(m_native){ |
823 delete m_native->iSmtpMtm; |
|
419 delete m_native->iMmsMtm; |
824 delete m_native->iMmsMtm; |
420 delete m_native->iImap4Mtm; |
825 delete m_native->iImap4Mtm; |
421 delete m_native->iSmsMtm; |
826 delete m_native->iSmsMtm; |
422 delete m_native->iMtmRegistry; |
827 delete m_native->iMtmRegistry; |
423 delete m_native->iSession; |
828 delete m_native->iSession; |
430 m_native->iSession = CMsvSession::OpenSyncL(*m_native); |
835 m_native->iSession = CMsvSession::OpenSyncL(*m_native); |
431 m_native->iMtmRegistry = CClientMtmRegistry::NewL(*m_native->iSession); |
836 m_native->iMtmRegistry = CClientMtmRegistry::NewL(*m_native->iSession); |
432 m_native->iSmsMtm = STATIC_CAST(CSmsClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeSMS)); |
837 m_native->iSmsMtm = STATIC_CAST(CSmsClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeSMS)); |
433 m_native->iImap4Mtm = STATIC_CAST(CImap4ClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeIMAP4)); |
838 m_native->iImap4Mtm = STATIC_CAST(CImap4ClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeIMAP4)); |
434 m_native->iMmsMtm = STATIC_CAST(CMmsClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeMultimedia)); |
839 m_native->iMmsMtm = STATIC_CAST(CMmsClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeMultimedia)); |
840 m_native->iSmtpMtm = STATIC_CAST(CSmtpClientMtm*, m_native->iMtmRegistry->NewMtmL(KUidMsgTypeSMTP)); |
|
435 } |
841 } |
436 |
842 |
437 __UHEAP_MARKEND; |
843 __UHEAP_MARKEND; |
438 #endif |
844 #endif |
439 } |
845 } |
607 } |
1013 } |
608 CleanupStack::PopAndDestroy(email); |
1014 CleanupStack::PopAndDestroy(email); |
609 |
1015 |
610 } |
1016 } |
611 else if(base == tst_messaging::Folders){ |
1017 else if(base == tst_messaging::Folders){ |
612 |
1018 RArray<TMsvId> aFolders; |
613 __UHEAP_MARK; |
1019 QBENCHMARK { |
614 |
1020 m_native->getFolders(aFolders); |
615 CEmailAccounts *email = CEmailAccounts::NewLC(); |
1021 aFolders.Close(); |
616 RArray<TPopAccount> aPop; |
|
617 RArray<TImapAccount> aImap; |
|
618 RArray<TSmtpAccount> aSmtp; |
|
619 |
|
620 email->GetPopAccountsL(aPop); |
|
621 email->GetImapAccountsL(aImap); |
|
622 email->GetSmtpAccountsL(aSmtp); |
|
623 |
|
624 |
|
625 RArray<TMsvId> aService; |
|
626 |
|
627 // qDebug() << "Pop Service: " << aPop.Count(); |
|
628 // qDebug() << "Imap Service: " << aImap.Count(); |
|
629 // qDebug() << "Smtp Service: " << aSmtp.Count(); |
|
630 |
|
631 for(int i = 0; i < aPop.Count(); i++){ |
|
632 aService.Append(aPop[i].iPopService); |
|
633 } |
|
634 for(int i = 0; i < aImap.Count(); i++){ |
|
635 aService.Append(aImap[i].iImapService); |
|
636 } |
|
637 for(int i = 0; i < aSmtp.Count(); i++){ |
|
638 aService.Append(aSmtp[i].iSmtpService); |
|
639 } |
|
640 |
|
641 |
|
642 if(aService.Count() == 0) |
|
643 QFAIL("No folders avaailable to query"); |
|
644 |
|
645 // qDebug() << "Total services: " << aService.Count(); |
|
646 |
|
647 int total; |
|
648 |
|
649 |
|
650 CMsvEntry* pEntry = NULL; |
|
651 TRAPD(err, pEntry = m_native->iSession->GetEntryL(aService[0])); |
|
652 if(err) |
|
653 QFAIL("Can't create entry object"); |
|
654 CleanupStack::PushL(pEntry); |
|
655 |
|
656 |
|
657 QBENCHMARK { |
|
658 total = 0; |
|
659 for(int i = 0; i < aService.Count(); i++){ |
|
660 |
|
661 TMsvId msvid = aService[i]; |
|
662 |
|
663 TRAP(err, pEntry->SetEntryL(msvid)); // faster to call set, saves .2ms out of 2.7ms. |
|
664 if(err){ |
|
665 qDebug() << "Failed: " << err; |
|
666 continue; |
|
667 } |
|
668 |
|
669 |
|
670 const TMsvEntry& entry = pEntry->Entry(); |
|
671 |
|
672 if (entry.iMtm == KUidMsgTypeSMS || entry.iMtm == KUidMsgTypeMultimedia || entry.iMtm == KUidMsgTypeSMTP) { |
|
673 total += 4; |
|
674 #define KDocumentsEntryIdValue 0x1008 |
|
675 pEntry->SetEntryL(KDocumentsEntryIdValue); |
|
676 } |
|
677 |
|
678 if (entry.iMtm == KUidMsgTypePOP3) { |
|
679 total+=1; |
|
680 continue; |
|
681 } |
|
682 |
|
683 CMsvEntryFilter* pFilter = CMsvEntryFilter::NewLC(); |
|
684 pFilter->SetService(msvid); |
|
685 pFilter->SetType(KUidMsvFolderEntry); |
|
686 |
|
687 CMsvEntrySelection* pSelection = new(ELeave) CMsvEntrySelection; |
|
688 CleanupStack::PushL(pSelection); |
|
689 |
|
690 m_native->iSession->GetChildIdsL(pEntry->Entry().Id(), *pFilter, *pSelection); |
|
691 if (pSelection->Count() > 0) { |
|
692 for(TInt i = 0; i < pSelection->Count(); i++) { |
|
693 // ids.append(createQMessageFolderId(folderServiceEntryId, pSelection->At(i))); |
|
694 // qDebug() << "serviceId: " << msvid << " Got one: " << "selected: " << pSelection->At(i); |
|
695 total++; |
|
696 m_native->iFolders.Append(pSelection->At(i)); |
|
697 } |
|
698 } |
|
699 else { |
|
700 // QString details = QString::fromUtf16(entry.iDetails.Ptr(),entry.iDetails.Length()); |
|
701 // QString desc = QString::fromUtf16(entry.iDescription.Ptr(),entry.iDescription.Length()); |
|
702 // qDebug() << "Nothing returned for: " << msvid << "entry: " << details << " - " << desc; |
|
703 } |
|
704 CleanupStack::PopAndDestroy(pSelection); |
|
705 CleanupStack::PopAndDestroy(pFilter); |
|
706 |
|
707 } |
1022 } |
708 } |
|
709 |
|
710 // qDebug() << "Number of Folders: " << total; |
|
711 |
|
712 aPop.Close(); |
|
713 aImap.Close(); |
|
714 aSmtp.Close(); |
|
715 aService.Close(); |
|
716 |
|
717 CleanupStack::PopAndDestroy(pEntry); |
|
718 CleanupStack::PopAndDestroy(email); |
|
719 |
|
720 __UHEAP_MARKEND; |
|
721 |
|
722 } |
1023 } |
723 else if(base == tst_messaging::Messages) { |
1024 else if(base == tst_messaging::Messages) { |
724 |
1025 |
725 RArray<TMsvId> aFolders; |
1026 RArray<TMsvId> aFolders; |
726 |
1027 |
727 aFolders.Append(KMsvGlobalInBoxIndexEntryId); |
1028 // aFolders.Append(KMsvGlobalInBoxIndexEntryId); |
728 aFolders.Append(KMsvGlobalOutBoxIndexEntryId); |
1029 // aFolders.Append(KMsvGlobalOutBoxIndexEntryId); |
729 aFolders.Append(KMsvDraftEntryId); |
1030 // aFolders.Append(KMsvDraftEntryId); |
730 aFolders.Append(KMsvSentEntryId); |
1031 // aFolders.Append(KMsvSentEntryId); |
731 for(int i = 0; i < m_native->iFolders.Count(); i++) |
1032 // for(int i = 0; i < m_native->iFolders.Count(); i++) |
732 aFolders.Append(m_native->iFolders[i]); |
1033 // aFolders.Append(m_native->iFolders[i]); |
1034 m_native->getFolders(aFolders); |
|
733 |
1035 |
734 // Access the Inbox |
1036 // Access the Inbox |
735 QBENCHMARK { |
1037 QBENCHMARK { |
736 |
1038 |
737 for(int i = 0; i < aFolders.Count(); i++){ |
1039 for(int i = 0; i < aFolders.Count(); i++){ |
775 QTest::newRow("Native-Accounts") << tst_messaging::Native << tst_messaging::Accounts; |
1077 QTest::newRow("Native-Accounts") << tst_messaging::Native << tst_messaging::Accounts; |
776 QTest::newRow("Qt-Folders") << tst_messaging::QMessaging << tst_messaging::Folders; |
1078 QTest::newRow("Qt-Folders") << tst_messaging::QMessaging << tst_messaging::Folders; |
777 QTest::newRow("Native-Folders") << tst_messaging::Native << tst_messaging::Folders; |
1079 QTest::newRow("Native-Folders") << tst_messaging::Native << tst_messaging::Folders; |
778 QTest::newRow("Qt-Messages") << tst_messaging::QMessaging << tst_messaging::Messages; |
1080 QTest::newRow("Qt-Messages") << tst_messaging::QMessaging << tst_messaging::Messages; |
779 QTest::newRow("Native-Messages") << tst_messaging::Native << tst_messaging::Messages; |
1081 QTest::newRow("Native-Messages") << tst_messaging::Native << tst_messaging::Messages; |
780 //qDebug() << "End fetch_data"; |
|
781 } |
1082 } |
782 |
1083 |
783 void tst_messaging::tst_fetch() |
1084 void tst_messaging::tst_fetch() |
784 { |
1085 { |
785 |
1086 |
832 #ifdef Q_OS_SYMBIAN |
1133 #ifdef Q_OS_SYMBIAN |
833 if(base == tst_messaging::Messages){ |
1134 if(base == tst_messaging::Messages){ |
834 __UHEAP_MARK; |
1135 __UHEAP_MARK; |
835 // Access the Inbox |
1136 // Access the Inbox |
836 QBENCHMARK { |
1137 QBENCHMARK { |
837 |
|
838 TMsvSelectionOrdering sort; |
1138 TMsvSelectionOrdering sort; |
839 sort.SetSorting(EMsvSortByDateReverse); |
1139 sort.SetSorting(EMsvSortByDateReverse); |
840 sort.SetShowInvisibleEntries(ETrue); |
1140 sort.SetShowInvisibleEntries(ETrue); |
841 |
1141 |
842 CMsvEntry* inboxContext = CMsvEntry::NewL(*m_native->iSession, |
1142 CMsvEntry* inboxContext = CMsvEntry::NewL(*m_native->iSession, |
843 KMsvGlobalInBoxIndexEntryId, sort); |
1143 KMsvDraftEntryIdValue /*KMsvGlobalInBoxIndexEntryId*/, sort); |
844 CleanupStack::PushL(inboxContext); |
1144 CleanupStack::PushL(inboxContext); |
845 |
1145 |
846 // Get all entries in the Inbox |
1146 // Get all entries in the Inbox |
847 CMsvEntrySelection* entries = inboxContext->ChildrenL(); |
1147 CMsvEntrySelection* entries = inboxContext->ChildrenL(); |
848 CleanupStack::PushL(entries); |
1148 CleanupStack::PushL(entries); |
849 |
1149 |
1150 if(entries->Count() == 0){ |
|
1151 CleanupStack::PopAndDestroy(2, inboxContext); |
|
1152 QSKIP("No messages on device to list", SkipAll); |
|
1153 } |
|
850 TMsvId entryID = entries->At(0); |
1154 TMsvId entryID = entries->At(0); |
851 const TUid mtm = inboxContext->ChildDataL(entryID).iMtm; |
1155 const TUid mtm = inboxContext->ChildDataL(entryID).iMtm; |
852 |
1156 |
853 if (mtm == KUidMsgTypeSMS) { |
1157 if (mtm == KUidMsgTypeSMS) { |
854 |
|
855 m_native->iSmsMtm->SwitchCurrentEntryL(entryID); |
1158 m_native->iSmsMtm->SwitchCurrentEntryL(entryID); |
856 TRAPD(err, m_native->iSmsMtm->LoadMessageL()); |
1159 TRAPD(err, m_native->iSmsMtm->LoadMessageL()); |
857 if(err){ |
1160 if(err){ |
858 qDebug() << "LoadMessageL failed: " << err; |
1161 qDebug() << "LoadMessageL failed: " << err; |
859 continue; |
1162 continue; |
860 } |
1163 } |
861 CSmsHeader& header = m_native->iSmsMtm->SmsHeader(); |
1164 CSmsHeader& header = m_native->iSmsMtm->SmsHeader(); |
862 } |
1165 } |
863 else if (mtm == KUidMsgTypeMultimedia) { |
1166 else if (mtm == KUidMsgTypeMultimedia) { |
864 |
|
865 // TODO None of these have a data store...skip until it can be fixed |
1167 // TODO None of these have a data store...skip until it can be fixed |
866 QFAIL("MMS message handeling is broken, change setup to use non-MMS type"); |
1168 QFAIL("MMS message handeling is broken, change setup to use non-MMS type"); |
867 } |
1169 } |
868 else if (mtm == KUidMsgTypeIMAP4) { |
1170 else if (mtm == KUidMsgTypeIMAP4) { |
869 m_native->iImap4Mtm->SwitchCurrentEntryL(entryID); |
1171 m_native->iImap4Mtm->SwitchCurrentEntryL(entryID); |
870 m_native->iImap4Mtm->LoadMessageL(); |
1172 m_native->iImap4Mtm->LoadMessageL(); |
871 } |
1173 } |
1174 else if (mtm == KUidMsgTypeSMTP){ |
|
1175 m_native->iSmtpMtm->SwitchCurrentEntryL(entryID); |
|
1176 m_native->iSmtpMtm->LoadMessageL(); |
|
1177 } |
|
872 else { |
1178 else { |
873 qDebug() << "Got Type: " << mtm.iUid; |
1179 qDebug() << "Got Type: " << hex << mtm.iUid; |
874 } |
1180 } |
875 CleanupStack::PopAndDestroy(2, inboxContext); |
1181 CleanupStack::PopAndDestroy(2, inboxContext); |
876 } |
1182 } |
877 __UHEAP_MARKEND; |
1183 __UHEAP_MARKEND; |
878 } |
1184 } |
879 |
1185 |
880 #endif |
1186 #endif |
881 } |
1187 } |
882 //qDebug() <<"End fetch"; |
1188 //qDebug() <<"End fetch"; |
925 } |
1231 } |
926 else if(base == tst_messaging::Messages){ |
1232 else if(base == tst_messaging::Messages){ |
927 QMessageIdList list; |
1233 QMessageIdList list; |
928 QMessage msg; |
1234 QMessage msg; |
929 list = m_mgr->queryMessages(); |
1235 list = m_mgr->queryMessages(); |
1236 if(list.count() == 0) |
|
1237 QFAIL("No messages to fetch"); |
|
1238 |
|
930 qDebug() << "Total fetched messages: " << list.count(); |
1239 qDebug() << "Total fetched messages: " << list.count(); |
931 QBENCHMARK { |
1240 QBENCHMARK { |
932 while(!list.empty()) |
1241 while(!list.empty()) |
933 msg = m_mgr->message(list.takeFirst()); |
1242 msg = m_mgr->message(list.takeFirst()); |
934 } |
1243 } |
935 // TODO this selects messages in built "My Folders" which the test for symbian native doesn't. Fix me. |
|
936 // list = m_mgr->queryMessages(); |
|
937 // while(!list.empty()) { |
|
938 // msg = m_mgr->message(list.takeFirst()); |
|
939 // qDebug() << "From: " << msg.from().recipient() << " subject: " << msg.subject(); |
|
940 // } |
|
941 |
|
942 } |
1244 } |
943 //qDebug() << "Got cnt: " << cnt; |
1245 //qDebug() << "Got cnt: " << cnt; |
944 } |
1246 } |
945 else if(platform == tst_messaging::Native){ |
1247 else if(platform == tst_messaging::Native){ |
946 #ifdef Q_OS_SYMBIAN |
1248 #ifdef Q_OS_SYMBIAN |
1010 // qDebug() << "LoadMessageL failed: " << err << "entryId/mtm" << entryID << "/" << mtm.iUid; |
1312 // qDebug() << "LoadMessageL failed: " << err << "entryId/mtm" << entryID << "/" << mtm.iUid; |
1011 // continue; |
1313 // continue; |
1012 // } |
1314 // } |
1013 skipped++; |
1315 skipped++; |
1014 } |
1316 } |
1015 else if (mtm == KUidMsgTypeIMAP4) { |
1317 else if (mtm == KUidMsgTypeIMAP4 || mtm == KUidMsgTypeSMTP) { |
1016 CMsvEntry* pEntry = NULL; |
1318 CMsvEntry* pEntry = NULL; |
1017 pEntry = m_native->iSession->GetEntryL(entryID); |
1319 pEntry = m_native->iSession->GetEntryL(entryID); |
1018 |
1320 |
1019 CImEmailMessage *pMsg = CImEmailMessage::NewLC(*pEntry); |
1321 CImEmailMessage *pMsg = CImEmailMessage::NewLC(*pEntry); |
1020 |
1322 |
1021 CMsvStore *store; |
1323 CMsvStore *store = 0x0; |
1022 TRAPD(err, store = pEntry->ReadStoreL()); |
1324 TRAPD(err, store = pEntry->ReadStoreL()); |
1023 if(err){ |
1325 if(err){ |
1024 // TPtrC sub; |
1326 // TPtrC sub; |
1025 // m_native->iImap4Mtm->SwitchCurrentEntryL(entryID); |
1327 // m_native->iImap4Mtm->SwitchCurrentEntryL(entryID); |
1026 // m_native->iImap4Mtm->LoadMessageL(); |
1328 // m_native->iImap4Mtm->LoadMessageL(); |
1042 TBuf<50> subject = header->Subject(); |
1344 TBuf<50> subject = header->Subject(); |
1043 |
1345 |
1044 //header buffer contains the "header" of the mail. |
1346 //header buffer contains the "header" of the mail. |
1045 TBuf<50> from = header->From(); |
1347 TBuf<50> from = header->From(); |
1046 |
1348 |
1047 // TODO: Find out why we don't select messages from the system My Folder store. |
|
1048 // QString qsubject = QString::fromUtf16(subject.Ptr(),subject.Length()); |
|
1049 // QString qfrom = QString::fromUtf16(from.Ptr(),from.Length()); |
|
1050 // qDebug() << "From: " << qfrom << " subject: " << qsubject; |
|
1051 |
|
1052 CleanupStack::PopAndDestroy(header); |
1349 CleanupStack::PopAndDestroy(header); |
1053 CleanupStack::PopAndDestroy(store); |
1350 CleanupStack::PopAndDestroy(store); |
1054 CleanupStack::PopAndDestroy(pMsg); |
1351 CleanupStack::PopAndDestroy(pMsg); |
1055 |
1352 |
1056 total++; |
1353 total++; |
1057 } |
1354 } |
1058 else { |
1355 else { |
1059 // qDebug() << "Got Type: " << mtm.iUid; |
1356 // qDebug() << "Got Type: " << mtm.iUid; |
1060 } |
1357 } |
1061 } |
1358 } |
1062 CleanupStack::PopAndDestroy(2, inboxContext); |
1359 CleanupStack::PopAndDestroy(2, inboxContext); |
1063 } |
1360 } |
1064 } |
1361 } |
1065 qDebug() << "Total messages fetched: " << total << " skipped: " << skipped; |
1362 // qDebug() << "Total messages fetched: " << total << " skipped: " << skipped; |
1066 __UHEAP_MARKEND; |
1363 __UHEAP_MARKEND; |
1067 } |
1364 } |
1068 #endif |
1365 #endif |
1069 } |
1366 } |
1070 |
1367 |
1083 QTest::newRow("Qt-Subject") << tst_messaging::QMessaging << tst_messaging::Subject; |
1380 QTest::newRow("Qt-Subject") << tst_messaging::QMessaging << tst_messaging::Subject; |
1084 QTest::newRow("Qt-TimeStamp") << tst_messaging::QMessaging << tst_messaging::TimeStamp; |
1381 QTest::newRow("Qt-TimeStamp") << tst_messaging::QMessaging << tst_messaging::TimeStamp; |
1085 QTest::newRow("Qt-Status") << tst_messaging::QMessaging << tst_messaging::Status; |
1382 QTest::newRow("Qt-Status") << tst_messaging::QMessaging << tst_messaging::Status; |
1086 QTest::newRow("Qt-Priority") << tst_messaging::QMessaging << tst_messaging::Priority; |
1383 QTest::newRow("Qt-Priority") << tst_messaging::QMessaging << tst_messaging::Priority; |
1087 QTest::newRow("Qt-Size") << tst_messaging::QMessaging << tst_messaging::Size; |
1384 QTest::newRow("Qt-Size") << tst_messaging::QMessaging << tst_messaging::Size; |
1088 QTest::newRow("Qt-AllId") << tst_messaging::QMessaging << tst_messaging::AllId; |
1385 // XXX Test is broken, User::Panic(47) on symbian |
1386 // QTest::newRow("Qt-AllId") << tst_messaging::QMessaging << tst_messaging::AllId; |
|
1089 QTest::newRow("Qt-AllSender") << tst_messaging::QMessaging << tst_messaging::AllSender; |
1387 QTest::newRow("Qt-AllSender") << tst_messaging::QMessaging << tst_messaging::AllSender; |
1090 |
1388 |
1091 QTest::newRow("Native-Id") << tst_messaging::Native << tst_messaging::Id; |
1389 QTest::newRow("Native-Id") << tst_messaging::Native << tst_messaging::Id; |
1092 QTest::newRow("Native-Type") << tst_messaging::Native << tst_messaging::Type; |
1390 QTest::newRow("Native-Type") << tst_messaging::Native << tst_messaging::Type; |
1093 QTest::newRow("Native-Sender") << tst_messaging::Native << tst_messaging::Sender; |
1391 QTest::newRow("Native-Sender") << tst_messaging::Native << tst_messaging::Sender; |
1094 QTest::newRow("Native-Subject") << tst_messaging::Native << tst_messaging::Subject; |
1392 QTest::newRow("Native-Subject") << tst_messaging::Native << tst_messaging::Subject; |
1095 QTest::newRow("Native-TimeStamp") << tst_messaging::Native << tst_messaging::TimeStamp; |
1393 QTest::newRow("Native-TimeStamp") << tst_messaging::Native << tst_messaging::TimeStamp; |
1096 QTest::newRow("Native-Status") << tst_messaging::Native << tst_messaging::Status; |
1394 QTest::newRow("Native-Status") << tst_messaging::Native << tst_messaging::Status; |
1097 QTest::newRow("Native-Priority") << tst_messaging::Native << tst_messaging::Priority; |
1395 QTest::newRow("Native-Priority") << tst_messaging::Native << tst_messaging::Priority; |
1098 QTest::newRow("Native-Size") << tst_messaging::Native << tst_messaging::Size; |
1396 QTest::newRow("Native-Size") << tst_messaging::Native << tst_messaging::Size; |
1099 QTest::newRow("Native-AllId") << tst_messaging::Native << tst_messaging::AllId; |
1397 QTest::newRow("Native-AllId") << tst_messaging::Native << tst_messaging::AllId; |
1100 QTest::newRow("Native-AllSender") << tst_messaging::Native << tst_messaging::AllSender; |
1398 QTest::newRow("Native-AllSender") << tst_messaging::Native << tst_messaging::AllSender; |
1101 |
1399 |
1102 // QTest::newRow("Native-Size") << tst_messaging::Native << tst_messaging::Size; |
1400 // QTest::newRow("Native-Size") << tst_messaging::Native << tst_messaging::Size; |
1103 } |
1401 } |
1113 QMessageFilter mf; |
1411 QMessageFilter mf; |
1114 QMessageId id; |
1412 QMessageId id; |
1115 // let's assume we want equal tests for all the filters. |
1413 // let's assume we want equal tests for all the filters. |
1116 // So let's try and filter out 1 message from each filter request. |
1414 // So let's try and filter out 1 message from each filter request. |
1117 if(filter == tst_messaging::Id){ |
1415 if(filter == tst_messaging::Id){ |
1416 id = msg_list.takeFirst(); |
|
1118 mf = QMessageFilter::byId(id); |
1417 mf = QMessageFilter::byId(id); |
1119 msg_list.push_back(id); |
1418 msg_list.push_back(id); |
1120 } |
1419 } |
1121 else if(filter == tst_messaging::Type){ |
1420 else if(filter == tst_messaging::Type){ |
1122 QMessage *msg = messageTemplate(); |
1421 QMessage *msg = messageTemplate(); |
1123 // XXX this segfault |
|
1124 //msg->setType(QMessage::Sms); |
|
1125 |
1422 |
1126 msgId = addMessage(msg); |
1423 msgId = addMessage(msg); |
1127 mf = QMessageFilter::byType(QMessage::Sms); |
1424 mf = QMessageFilter::byType(QMessage::Sms); |
1128 |
1425 |
1129 } |
1426 } |
1177 msg->setBody(body); |
1474 msg->setBody(body); |
1178 msgId = addMessage(msg); |
1475 msgId = addMessage(msg); |
1179 |
1476 |
1180 mf = QMessageFilter::bySize(5000, QMessageDataComparator::GreaterThan); |
1477 mf = QMessageFilter::bySize(5000, QMessageDataComparator::GreaterThan); |
1181 } |
1478 } |
1182 else if(filter == tst_messaging::AllId){ |
1479 else if(filter == tst_messaging::AllId){ |
1183 mf = QMessageFilter::byId(msg_list); |
1480 // mf = QMessageFilter::byId(msg_list.mid(0, 2)); works, mid(0,15) fails... |
1481 mf = QMessageFilter::byId(msg_list); |
|
1184 } |
1482 } |
1185 else if(filter == tst_messaging::AllSender){ |
1483 else if(filter == tst_messaging::AllSender){ |
1186 id = msg_list.takeFirst(); |
1484 id = msg_list.takeFirst(); |
1187 msg_list.push_back(id); |
1485 msg_list.push_back(id); |
1188 QMessage msg = m_mgr->message(id); |
1486 QMessage msg = m_mgr->message(id); |
1196 QFAIL("Empty filter provided"); |
1494 QFAIL("Empty filter provided"); |
1197 } |
1495 } |
1198 else { |
1496 else { |
1199 QMessageIdList list; |
1497 QMessageIdList list; |
1200 QMessageSortOrder sortOrder(QMessageSortOrder::byReceptionTimeStamp(Qt::DescendingOrder)); |
1498 QMessageSortOrder sortOrder(QMessageSortOrder::byReceptionTimeStamp(Qt::DescendingOrder)); |
1201 |
|
1202 QBENCHMARK { |
1499 QBENCHMARK { |
1203 list = m_mgr->queryMessages(mf, sortOrder, 100); |
1500 list = m_mgr->queryMessages(mf, sortOrder, 100); |
1204 } |
1501 } |
1205 |
|
1206 if(list.count() != 1 && filter != tst_messaging::AllId && filter != tst_messaging::AllSender) |
1502 if(list.count() != 1 && filter != tst_messaging::AllId && filter != tst_messaging::AllSender) |
1207 qDebug() << "Wanted 1 message got: " << list.count(); |
1503 qDebug() << "Wanted 1 message got: " << list.count(); |
1208 } |
1504 } |
1209 |
1505 |
1210 if(msgId.isValid()){ |
1506 if(msgId.isValid()){ |
1220 //sort.SetSorting(EMsvSortByDateReverse); |
1516 //sort.SetSorting(EMsvSortByDateReverse); |
1221 sort.SetSorting(EMsvSortById); |
1517 sort.SetSorting(EMsvSortById); |
1222 sort.SetShowInvisibleEntries(ETrue); |
1518 sort.SetShowInvisibleEntries(ETrue); |
1223 |
1519 |
1224 CMsvEntry* inboxContext = CMsvEntry::NewL(*m_native->iSession, |
1520 CMsvEntry* inboxContext = CMsvEntry::NewL(*m_native->iSession, |
1225 KMsvGlobalInBoxIndexEntryId, sort); |
1521 KMsvDraftEntryIdValue /*KMsvGlobalInBoxIndexEntryId*/, sort); |
1226 CleanupStack::PushL(inboxContext); |
1522 CleanupStack::PushL(inboxContext); // 1 |
1227 |
1523 |
1228 // Get all entries in the Inbox |
1524 // Get all entries in the Inbox |
1229 CMsvEntrySelection* entries = inboxContext->ChildrenL(); |
1525 CMsvEntrySelection* entries = inboxContext->ChildrenL(); |
1230 CleanupStack::PushL(entries); |
1526 CleanupStack::PushL(entries); // 2 |
1527 if(entries->Count() == 0){ |
|
1528 CleanupStack::PopAndDestroy(2, inboxContext); |
|
1529 QSKIP("No messages on device to list", SkipAll); |
|
1530 } |
|
1231 |
1531 |
1232 TMsvId entryID = entries->At(0); |
1532 TMsvId entryID = entries->At(0); |
1233 |
1533 |
1234 const TUid mtm = inboxContext->ChildDataL(entryID).iMtm; |
1534 const TUid mtm = inboxContext->ChildDataL(entryID).iMtm; |
1235 |
1535 |
1339 waiter->Start(); |
1639 waiter->Start(); |
1340 |
1640 |
1341 const CMsvFindResultSelection &res = finder->GetFindResult(); |
1641 const CMsvFindResultSelection &res = finder->GetFindResult(); |
1342 |
1642 |
1343 for(int i = 0; i < res.Count(); i++){ |
1643 for(int i = 0; i < res.Count(); i++){ |
1344 CMsvEntry *pEntry; |
1644 CMsvEntry *pEntry = 0x0; |
1345 TRAPD(err, pEntry = m_native->iSession->GetEntryL(res.At(i).iId)); |
1645 TRAPD(err, pEntry = m_native->iSession->GetEntryL(res.At(i).iId)); |
1346 if(err){ |
1646 if(err){ |
1347 qDebug() << "Failed to fetch: " << i << " - " << res.At(i).iId; |
1647 qDebug() << "Failed to fetch: " << i << " - " << res.At(i).iId; |
1348 continue; |
1648 continue; |
1349 } |
1649 } |
1372 waiter->Start(); |
1672 waiter->Start(); |
1373 |
1673 |
1374 const CMsvFindResultSelection &res = finder->GetFindResult(); |
1674 const CMsvFindResultSelection &res = finder->GetFindResult(); |
1375 |
1675 |
1376 for(int i = 0; i < res.Count(); i++){ |
1676 for(int i = 0; i < res.Count(); i++){ |
1377 CMsvEntry *pEntry; |
1677 CMsvEntry *pEntry = 0x0; |
1378 TRAPD(err, pEntry = m_native->iSession->GetEntryL(res.At(i).iId)); |
1678 TRAPD(err, pEntry = m_native->iSession->GetEntryL(res.At(i).iId)); |
1379 if(err){ |
1679 if(err){ |
1380 qDebug() << "Failed to fetch: " << i << " - " << res.At(i).iId; |
1680 qDebug() << "Failed to fetch: " << i << " - " << res.At(i).iId; |
1381 continue; |
1681 continue; |
1382 } |
1682 } |
1459 } |
1759 } |
1460 |
1760 |
1461 void tst_messaging::clearMessages() |
1761 void tst_messaging::clearMessages() |
1462 { |
1762 { |
1463 QMessageId id; |
1763 QMessageId id; |
1764 int num = 0; |
|
1765 qDebug() << "Start QtMessaging removal"; |
|
1464 while(!msg_list.empty()) |
1766 while(!msg_list.empty()) |
1465 m_mgr->removeMessage(msg_list.takeFirst()); |
1767 m_mgr->removeMessage(msg_list.takeFirst()), num++; |
1768 qDebug() << "Start Native removal"; |
|
1769 #ifdef Q_OS_SYMBIAN |
|
1770 while(m_native->iNewMsgs.Count()) |
|
1771 m_native->iSession->RemoveEntry(m_native->iNewMsgs[0]), m_native->iNewMsgs.Remove(0), num++; |
|
1772 #endif |
|
1773 |
|
1774 qDebug() << "Cleanup Removed: " << num; |
|
1466 } |
1775 } |
1467 |
1776 |
1468 QMessage *tst_messaging::messageTemplate() |
1777 QMessage *tst_messaging::messageTemplate() |
1469 { |
1778 { |
1470 QMessage *msg = new QMessage; |
1779 QMessage *msg = new QMessage; |
1471 |
1780 |
1781 msg->setType(QMessage::Email); |
|
1472 msg->setDate(QDateTime::currentDateTime()); |
1782 msg->setDate(QDateTime::currentDateTime()); |
1473 msg->setSubject("test"); |
1783 msg->setSubject("test"); |
1474 QMessageAddress addr; |
1784 QMessageAddress addr; |
1475 addr.setAddressee("abr@foo.com"); |
1785 addr.setAddressee("abr@foo.com"); |
1476 addr.setType(QMessageAddress::Email); |
1786 addr.setType(QMessageAddress::Email); |
1477 msg->setTo(addr); |
1787 msg->setTo(addr); |
1478 addr.setAddressee("from@bar.com"); |
1788 addr.setAddressee("from@bar.com"); |
1479 addr.setType(QMessageAddress::Email); |
1789 addr.setType(QMessageAddress::Email); |
1480 msg->setFrom(addr); |
1790 msg->setFrom(addr); |
1481 |
|
1482 // XXX one or more of these cause problems |
|
1483 // msg->setType(QMessage::Email); |
|
1484 // msg->setStatus(QMessage::Read); |
|
1485 |
|
1486 // msg->setBody("I have a body!"); |
|
1487 // msg->setParentAccountId(m_fol.parentAccountId()); |
|
1488 |
1791 |
1489 return msg; |
1792 return msg; |
1490 } |
1793 } |
1491 |
1794 |
1492 QMessageId tst_messaging::addMessage(QMessage *msg) |
1795 QMessageId tst_messaging::addMessage(QMessage *msg) |
1493 { |
1796 { |
1494 m_mgr->addMessage(msg); |
1797 if(!m_mgr->addMessage(msg)) |
1798 qDebug() << "Failed to add message: " << m_mgr->error(); |
|
1799 |
|
1495 msg_list.append(msg->id()); |
1800 msg_list.append(msg->id()); |
1496 |
1801 |
1497 //qDebug() << "id: " << msg->id().toString(); |
1802 //qDebug() << "id: " << msg->id().toString(); |
1498 |
1803 |
1499 return msg->id(); |
1804 return msg->id(); |
1517 { |
1822 { |
1518 QTest::addColumn<tst_messaging::platform>("platform"); |
1823 QTest::addColumn<tst_messaging::platform>("platform"); |
1519 QTest::addColumn<tst_messaging::types>("type"); |
1824 QTest::addColumn<tst_messaging::types>("type"); |
1520 |
1825 |
1521 QTest::newRow("Qt-Email") << tst_messaging::QMessaging << tst_messaging::Email; |
1826 QTest::newRow("Qt-Email") << tst_messaging::QMessaging << tst_messaging::Email; |
1522 QTest::newRow("Native-SMS") << tst_messaging::Native << tst_messaging::Sms; |
1827 // XXX SMS broken. On clean devices there is no SMSMC to create messages for. |
1828 // QTest::newRow("Native-SMS") << tst_messaging::Native << tst_messaging::Sms; |
|
1523 QTest::newRow("Native-Email") << tst_messaging::Native << tst_messaging::Email; |
1829 QTest::newRow("Native-Email") << tst_messaging::Native << tst_messaging::Email; |
1524 |
1830 |
1525 } |
1831 } |
1526 |
1832 |
1527 void tst_messaging::tst_addMessage() |
1833 void tst_messaging::tst_addMessage() |
1538 else if(platform == tst_messaging::Native){ |
1844 else if(platform == tst_messaging::Native){ |
1539 #ifdef Q_OS_SYMBIAN |
1845 #ifdef Q_OS_SYMBIAN |
1540 if(type == tst_messaging::Sms){ |
1846 if(type == tst_messaging::Sms){ |
1541 TMsvId id; |
1847 TMsvId id; |
1542 QBENCHMARK { |
1848 QBENCHMARK { |
1543 id = m_native->makeSMS(KMsvDraftEntryIdValue); |
1849 TRAPD(err, id = m_native->makeSMS(KMsvGlobalInBoxIndexEntryId)); |
1850 if(err){ |
|
1851 qDebug() << "Failed to create sms: " << err; |
|
1852 } |
|
1544 } |
1853 } |
1545 m_native->iNewMsgs.Append(id); |
1854 m_native->iNewMsgs.Append(id); |
1546 } |
1855 } |
1547 else if(type == tst_messaging::Email){ |
1856 else if(type == tst_messaging::Email){ |
1548 TMsvId id; |
1857 TMsvId id; |
1549 QBENCHMARK { |
1858 QBENCHMARK { |
1550 m_native->makeIMAP4(KMsvDraftEntryIdValue); |
1859 TRAPD(err, id = m_native->makeIMAP4(KMsvGlobalInBoxIndexEntryId)); |
1860 if(err){ |
|
1861 qDebug() << "Failed to create sms: " << err; |
|
1862 } |
|
1863 |
|
1551 } |
1864 } |
1552 m_native->iNewMsgs.Append(id); |
1865 m_native->iNewMsgs.Append(id); |
1553 } |
1866 } |
1554 #else |
1867 #else |
1555 Q_UNUSED(type); |
1868 Q_UNUSED(type); |
1569 void tst_messaging::tst_removeMessage() |
1882 void tst_messaging::tst_removeMessage() |
1570 { |
1883 { |
1571 QFETCH(tst_messaging::platform, platform); |
1884 QFETCH(tst_messaging::platform, platform); |
1572 |
1885 |
1573 if(platform == tst_messaging::QMessaging){ |
1886 if(platform == tst_messaging::QMessaging){ |
1574 #ifdef Q_OS_SYMBIAN |
1887 //#ifdef Q_OS_SYMBIAN |
1575 TMsvId id; |
1888 // TMsvId id; |
1576 id = m_native->makeIMAP4(KMsvDraftEntryIdValue); |
1889 // id = m_native->makeIMAP4(KMsvDraftEntryIdValue); |
1577 QString str; |
1890 // QString str; |
1578 str.setNum(id); |
1891 // str.setNum(id); |
1579 QMessageId qmid = str; |
1892 // QMessageId qmid = str; |
1580 #else |
1893 //#else |
1581 QMessageId qmid = msg_list.takeFirst(); |
1894 QMessageId qmid = msg_list.takeFirst(); |
1582 #endif |
1895 //#endif |
1583 |
1896 |
1584 QBENCHMARK_ONCE { |
1897 QBENCHMARK_ONCE { |
1585 m_mgr->removeMessage(qmid); |
1898 m_mgr->removeMessage(qmid); |
1586 } |
1899 } |
1587 } |
1900 } |
1624 else if(platform == tst_messaging::Native){ |
1937 else if(platform == tst_messaging::Native){ |
1625 #ifdef Q_OS_SYMBIAN |
1938 #ifdef Q_OS_SYMBIAN |
1626 // make sure there's enough messages to delete |
1939 // make sure there's enough messages to delete |
1627 while(m_native->iNewMsgs.Count() < 30) { |
1940 while(m_native->iNewMsgs.Count() < 30) { |
1628 TMsvId id; |
1941 TMsvId id; |
1629 id = m_native->makeSMS(KMsvDraftEntryIdValue); |
1942 id = m_native->makeIMAP4(KMsvDraftEntryIdValue); |
1630 m_native->iNewMsgs.Append(id); |
1943 m_native->iNewMsgs.Append(id); |
1631 } |
1944 } |
1632 |
1945 |
1633 QBENCHMARK { |
1946 QBENCHMARK { |
1634 CMsvEntry *pEntry; |
1947 CMsvEntry *pEntry = 0x0; |
1635 TRAPD(err, pEntry = CMsvEntry::NewL(*m_native->iSession, KMsvRootIndexEntryId, TMsvSelectionOrdering())); |
1948 TRAPD(err, pEntry = CMsvEntry::NewL(*m_native->iSession, KMsvRootIndexEntryId, TMsvSelectionOrdering())); |
1636 if(err){ |
1949 if(err){ |
1637 qDebug() << "Failed to init CMsvEntryL " << err; |
1950 qDebug() << "Failed to init CMsvEntryL " << err; |
1638 return; |
1951 return; |
1639 } |
1952 } |
1671 folders.Append(KMsvGlobalOutBoxIndexEntryId); |
1984 folders.Append(KMsvGlobalOutBoxIndexEntryId); |
1672 folders.Append(KMsvDraftEntryId); |
1985 folders.Append(KMsvDraftEntryId); |
1673 folders.Append(KMsvSentEntryId); |
1986 folders.Append(KMsvSentEntryId); |
1674 folders.Append(KMsvDeletedEntryFolderEntryId); |
1987 folders.Append(KMsvDeletedEntryFolderEntryId); |
1675 folders.Append(KDocumentsEntryIdValue); |
1988 folders.Append(KDocumentsEntryIdValue); |
1989 folders.Append(KMsvMyFoldersEntryId); |
|
1676 |
1990 |
1677 email->GetPopAccountsL(aPop); |
1991 email->GetPopAccountsL(aPop); |
1678 email->GetImapAccountsL(aImap); |
1992 email->GetImapAccountsL(aImap); |
1679 email->GetSmtpAccountsL(aSmtp); |
1993 email->GetSmtpAccountsL(aSmtp); |
1680 |
1994 |
1681 RArray<TMsvId> aService; |
1995 RArray<TMsvId> aService; |
1996 |
|
1997 // aService.Append(KMsvLocalServiceIndexEntryId); |
|
1998 // aService.Append(KMsvRootIndexEntryId); |
|
1682 |
1999 |
1683 for(int i = 0; i < aPop.Count(); i++){ |
2000 for(int i = 0; i < aPop.Count(); i++){ |
1684 aService.Append(aPop[i].iPopService); |
2001 aService.Append(aPop[i].iPopService); |
1685 } |
2002 } |
1686 for(int i = 0; i < aImap.Count(); i++){ |
2003 for(int i = 0; i < aImap.Count(); i++){ |
1692 |
2009 |
1693 TSmtpAccount sacc; |
2010 TSmtpAccount sacc; |
1694 if(email->DefaultSmtpAccountL(sacc)) |
2011 if(email->DefaultSmtpAccountL(sacc)) |
1695 aService.Append(sacc.iSmtpService); |
2012 aService.Append(sacc.iSmtpService); |
1696 |
2013 |
1697 if(aService.Count() == 0) |
2014 if(aService.Count() > 0) { |
1698 QFAIL("No folders avaailable to query"); |
2015 CMsvEntry* pEntry = NULL; |
1699 |
|
1700 CMsvEntry* pEntry = NULL; |
|
1701 pEntry = iSession->GetEntryL(aService[0]); |
|
1702 CleanupStack::PushL(pEntry); |
|
1703 |
|
1704 for(int i = 0; i < aService.Count(); i++){ |
|
1705 TMsvId msvid = aService[i]; |
|
1706 |
|
1707 pEntry->SetEntryL(msvid); // faster to call set, saves .2ms out of 2.7ms. |
|
1708 |
|
1709 const TMsvEntry& entry = pEntry->Entry(); |
|
1710 |
|
1711 CMsvEntryFilter* pFilter = CMsvEntryFilter::NewLC(); |
|
1712 pFilter->SetService(msvid); |
|
1713 pFilter->SetType(KUidMsvFolderEntry); |
|
1714 |
|
1715 CMsvEntrySelection* pSelection = new(ELeave) CMsvEntrySelection; |
|
1716 CleanupStack::PushL(pSelection); |
|
1717 |
2016 |
1718 if (entry.iMtm == KUidMsgTypeSMS || entry.iMtm == KUidMsgTypeMultimedia || entry.iMtm == KUidMsgTypeSMTP) |
2017 TRAPD(err, pEntry = iSession->GetEntryL(aService[0])); |
1719 pEntry->SetEntryL(KDocumentsEntryIdValue); |
2018 if(!err) { |
1720 |
2019 CleanupStack::PushL(pEntry); |
1721 //iSession->GetChildIdsL(pEntry->Entry().Id(), *pFilter, *pSelection); |
2020 for(int i = 0; i < aService.Count(); i++){ |
1722 iSession->GetChildIdsL(pEntry->Entry().Id(), *pFilter, *pSelection); |
2021 TMsvId msvid = aService[i]; |
1723 |
2022 |
1724 for(TInt i = 0; i < pSelection->Count(); i++) { |
2023 TRAP(err, pEntry->SetEntryL(msvid)); // faster to call set, saves .2ms out of 2.7ms. |
1725 folders.Append(pSelection->At(i)); |
2024 if(err) |
1726 } |
2025 continue; |
1727 |
2026 |
1728 CleanupStack::PopAndDestroy(pSelection); |
2027 const TMsvEntry& entry = pEntry->Entry(); |
1729 CleanupStack::PopAndDestroy(pFilter); |
2028 CMsvEntryFilter* pFilter = CMsvEntryFilter::NewLC(); |
1730 |
2029 pFilter->SetService(msvid); |
1731 } |
2030 pFilter->SetType(KUidMsvFolderEntry); |
1732 |
2031 CMsvEntrySelection* pSelection = new(ELeave) CMsvEntrySelection; |
2032 CleanupStack::PushL(pSelection); |
|
2033 |
|
2034 if (entry.iMtm == KUidMsgTypeSMS || entry.iMtm == KUidMsgTypeMultimedia || entry.iMtm == KUidMsgTypeSMTP) |
|
2035 pEntry->SetEntryL(KDocumentsEntryIdValue); |
|
2036 |
|
2037 iSession->GetChildIdsL(msvid, *pFilter, *pSelection); |
|
2038 for(TInt i = 0; i < pSelection->Count(); i++) { |
|
2039 folders.Append(pSelection->At(i)); |
|
2040 pEntry->SetEntryL(pSelection->At(i)); |
|
2041 if(pEntry->Entry().iMtm == KUidMsvFolderEntry){ |
|
2042 aService.Append(pSelection->At(i)); |
|
2043 } |
|
2044 } |
|
2045 CleanupStack::PopAndDestroy(pSelection); |
|
2046 CleanupStack::PopAndDestroy(pFilter); |
|
2047 |
|
2048 } |
|
2049 CleanupStack::PopAndDestroy(pEntry); |
|
2050 } |
|
2051 } |
|
1733 aPop.Close(); |
2052 aPop.Close(); |
1734 aImap.Close(); |
2053 aImap.Close(); |
1735 aSmtp.Close(); |
2054 aSmtp.Close(); |
1736 aService.Close(); |
2055 aService.Close(); |
1737 |
2056 |
1738 CleanupStack::PopAndDestroy(pEntry); |
|
1739 CleanupStack::PopAndDestroy(email); |
2057 CleanupStack::PopAndDestroy(email); |
1740 __UHEAP_MARKEND; |
2058 __UHEAP_MARKEND; |
1741 } |
2059 } |
1742 #endif |
2060 #endif |
1743 |
2061 |