|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "support.h" |
|
43 #include <qmessageaccountid.h> |
|
44 #include <qmessagefolderid.h> |
|
45 #include <qmessageid.h> |
|
46 #include <qmessagemanager.h> |
|
47 #include <qmessage_symbian_p.h> |
|
48 #include <messagingutil_p.h> |
|
49 |
|
50 #include <QDebug> |
|
51 |
|
52 #include <pop3set.h> |
|
53 #include <imapset.h> |
|
54 #include <smtpset.h> |
|
55 #include <iapprefs.h> |
|
56 #include <cemailaccounts.h> |
|
57 #include <metadatabase.h> |
|
58 #include <commsdat.h> |
|
59 |
|
60 _LIT(KPopServer, "ban-sindhub01.intra"); |
|
61 _LIT8(KPopLoginName, "ban-sindhub01"); |
|
62 _LIT8(KPopPassword, "ban-sindhub01"); |
|
63 |
|
64 _LIT(KImapServer, "ban-sindhub01.intra"); |
|
65 _LIT8(KImapPassword,"ban-sindhub01"); |
|
66 _LIT8(KImapLoginName,"ban-sindhub01"); |
|
67 |
|
68 _LIT(KSmtpServerAddress, "ban-sindhub01.intra"); |
|
69 _LIT(KEmailAlias, "Messaging example"); |
|
70 |
|
71 #define KDocumentsEntryIdValue 0x1008 |
|
72 |
|
73 class CSymbianMessagingSession : public CBase, MMsvSessionObserver |
|
74 { |
|
75 public: |
|
76 CSymbianMessagingSession(); |
|
77 ~CSymbianMessagingSession(); |
|
78 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); |
|
79 CMsvSession* ipMsvSession; |
|
80 }; |
|
81 |
|
82 CSymbianMessagingSession::CSymbianMessagingSession() |
|
83 { |
|
84 TRAPD(err, ipMsvSession = CMsvSession::OpenSyncL(*this)); |
|
85 Q_UNUSED(err) |
|
86 } |
|
87 |
|
88 CSymbianMessagingSession::~CSymbianMessagingSession() |
|
89 { |
|
90 delete ipMsvSession; |
|
91 } |
|
92 |
|
93 void CSymbianMessagingSession::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
94 { |
|
95 } |
|
96 |
|
97 QTM_BEGIN_NAMESPACE |
|
98 |
|
99 using namespace MessagingUtil; |
|
100 |
|
101 class MapiSession |
|
102 { |
|
103 public: |
|
104 static QMessageId addMessage(const Support::Parameters ¶ms); |
|
105 }; |
|
106 |
|
107 // The class 'MapiSession' is a friend of QMessageContentContainer - hijack it here |
|
108 // => This is needed to make it possible to set parentFolderId |
|
109 QMessageId MapiSession::addMessage(const Support::Parameters ¶ms) |
|
110 { |
|
111 QString parentAccountName(params["parentAccountName"]); |
|
112 QString parentFolderPath(params["parentFolderPath"]); |
|
113 QString to(params["to"]); |
|
114 QString cc(params["cc"]); |
|
115 QString from(params["from"]); |
|
116 QString date(params["date"]); |
|
117 QString receivedDate(params["receivedDate"]); |
|
118 QString subject(params["subject"]); |
|
119 QString text(params["text"]); |
|
120 QString mimeType(params["mimeType"]); |
|
121 QString attachments(params["attachments"]); |
|
122 QString priority(params["priority"]); |
|
123 QString size(params["size"]); |
|
124 QString type(params["type"]); |
|
125 QString read(params["status-read"]); |
|
126 QString hasAttachments(params["status-hasAttachments"]); |
|
127 |
|
128 QMessageManager manager; |
|
129 |
|
130 if (!to.isEmpty() && !from.isEmpty() && !date.isEmpty() && !subject.isEmpty() && |
|
131 !parentAccountName.isEmpty() && !parentFolderPath.isEmpty()) { |
|
132 // Find the named account |
|
133 QMessageAccountIdList accountIds(manager.queryAccounts(QMessageAccountFilter::byName(parentAccountName))); |
|
134 if (accountIds.count() == 1) { |
|
135 // Find the specified folder |
|
136 QMessageFolderFilter filter(QMessageFolderFilter::byName(parentFolderPath) & QMessageFolderFilter::byParentAccountId(accountIds.first())); |
|
137 QMessageFolderIdList folderIds(manager.queryFolders(filter)); |
|
138 if (folderIds.count() == 1) { |
|
139 QMessage message; |
|
140 |
|
141 message.setParentAccountId(accountIds.first()); |
|
142 message.d_ptr->_parentFolderId = folderIds.first(); |
|
143 |
|
144 QList<QMessageAddress> toList; |
|
145 foreach (const QString &addr, to.split(",")) { |
|
146 toList.append(QMessageAddress(QMessageAddress::Email, addr.trimmed())); |
|
147 } |
|
148 message.setTo(toList); |
|
149 |
|
150 QList<QMessageAddress> ccList; |
|
151 foreach (const QString &addr, cc.split(",")) { |
|
152 if (!addr.isEmpty()) { |
|
153 ccList.append(QMessageAddress(QMessageAddress::Email, addr.trimmed())); |
|
154 } |
|
155 } |
|
156 message.setCc(ccList); |
|
157 |
|
158 message.setFrom(QMessageAddress(QMessageAddress::Email, from)); |
|
159 message.setSubject(subject); |
|
160 |
|
161 QDateTime dt(QDateTime::fromString(date, Qt::ISODate)); |
|
162 dt.setTimeSpec(Qt::UTC); |
|
163 message.setDate(dt); |
|
164 |
|
165 if (type.isEmpty()) { |
|
166 message.setType(QMessage::Email); |
|
167 } else { |
|
168 if (type.toLower() == "mms") { |
|
169 message.setType(QMessage::Mms); |
|
170 } else if (type.toLower() == "sms") { |
|
171 message.setType(QMessage::Sms); |
|
172 } else if (type.toLower() == "instantmessage") { |
|
173 message.setType(QMessage::InstantMessage); |
|
174 } else { |
|
175 message.setType(QMessage::Email); |
|
176 } |
|
177 } |
|
178 |
|
179 if (!receivedDate.isEmpty()) { |
|
180 QDateTime dt(QDateTime::fromString(receivedDate, Qt::ISODate)); |
|
181 dt.setTimeSpec(Qt::UTC); |
|
182 message.setReceivedDate(dt); |
|
183 } |
|
184 |
|
185 if (!priority.isEmpty()) { |
|
186 if (priority.toLower() == "high") { |
|
187 message.setPriority(QMessage::HighPriority); |
|
188 } else if (priority.toLower() == "low") { |
|
189 message.setPriority(QMessage::LowPriority); |
|
190 } |
|
191 } |
|
192 |
|
193 /*if (!size.isEmpty()) { |
|
194 message.d_ptr->_size = size.toUInt(); |
|
195 }*/ |
|
196 |
|
197 if (!text.isEmpty()) { |
|
198 message.setBody(text, mimeType.toAscii()); |
|
199 } |
|
200 |
|
201 if (!attachments.isEmpty()) { |
|
202 message.appendAttachments(attachments.split("\n")); |
|
203 } |
|
204 |
|
205 QMessage::StatusFlags flags(0); |
|
206 if (read.toLower() == "true") { |
|
207 flags |= QMessage::Read; |
|
208 } |
|
209 if (hasAttachments.toLower() == "true") { |
|
210 flags |= QMessage::HasAttachments; |
|
211 } |
|
212 message.setStatus(flags); |
|
213 |
|
214 if (!manager.addMessage(&message)) { |
|
215 qWarning() << "Unable to addMessage:" << to << from << date << subject; |
|
216 } else { |
|
217 return message.id(); |
|
218 } |
|
219 } else { |
|
220 qWarning() << "Unable to locate parent folder:" << parentFolderPath; |
|
221 } |
|
222 } else { |
|
223 qWarning() << "Unable to locate parent account:" << parentAccountName; |
|
224 } |
|
225 } else { |
|
226 qWarning() << "Necessary information missing"; |
|
227 } |
|
228 |
|
229 return QMessageId(); |
|
230 } |
|
231 QTM_END_NAMESPACE |
|
232 |
|
233 namespace Support { |
|
234 |
|
235 using namespace CommsDat; |
|
236 |
|
237 void deleteServiceRelatedEntriesFromFolder(TMsvId serviceId, TMsvId folderId) |
|
238 { |
|
239 CSymbianMessagingSession* pSession = new(ELeave) CSymbianMessagingSession(); |
|
240 CleanupStack::PushL(pSession); |
|
241 CMsvEntry* pEntry = CMsvEntry::NewL(*(pSession->ipMsvSession), folderId, TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue)); |
|
242 CleanupStack::PushL(pEntry); |
|
243 CMsvEntrySelection* pEntries = pEntry->ChildrenWithServiceL(serviceId); |
|
244 CleanupStack::PushL(pEntries); |
|
245 for (int i = 0; i < pEntries->Count(); i++) { |
|
246 CMsvOperationWait* pMsvOperationWait = CMsvOperationWait::NewLC(); |
|
247 CMsvOperation* pMsvOperation = pEntry->DeleteL(pEntries->At(i), pMsvOperationWait->iStatus); |
|
248 CleanupStack::PushL(pMsvOperation); |
|
249 pMsvOperationWait->Start(); |
|
250 CActiveScheduler::Start(); |
|
251 CleanupStack::PopAndDestroy(pMsvOperation); |
|
252 CleanupStack::PopAndDestroy(pMsvOperationWait); |
|
253 } |
|
254 CleanupStack::PopAndDestroy(pEntries); |
|
255 CleanupStack::PopAndDestroy(pEntry); |
|
256 CleanupStack::PopAndDestroy(pSession); |
|
257 } |
|
258 |
|
259 void clearMessageStoreL() |
|
260 { |
|
261 CEmailAccounts* pEmailAccounts = CEmailAccounts::NewLC(); |
|
262 |
|
263 RArray<TImapAccount> imapAccounts(10); |
|
264 pEmailAccounts->GetImapAccountsL(imapAccounts); |
|
265 for (int i=0; i < imapAccounts.Count(); i++) { |
|
266 CImImap4Settings* settings = new(ELeave) CImImap4Settings(); |
|
267 CleanupStack::PushL(settings); |
|
268 pEmailAccounts->LoadImapSettingsL(imapAccounts[i], *settings); |
|
269 if (settings->ServerAddress().Compare(KImapServer) == 0) { |
|
270 pEmailAccounts->DeleteImapAccountL(imapAccounts[i]); |
|
271 deleteServiceRelatedEntriesFromFolder(imapAccounts[i].iImapService, KDocumentsEntryIdValue); |
|
272 } |
|
273 CleanupStack::PopAndDestroy(settings); |
|
274 } |
|
275 |
|
276 RArray<TPopAccount> popAccounts(10); |
|
277 pEmailAccounts->GetPopAccountsL(popAccounts); |
|
278 for (int i=0; i < popAccounts.Count(); i++) { |
|
279 CImPop3Settings* settings = new(ELeave) CImPop3Settings(); |
|
280 CleanupStack::PushL(settings); |
|
281 pEmailAccounts->LoadPopSettingsL(popAccounts[i], *settings); |
|
282 if (settings->ServerAddress().Compare(KPopServer) == 0) { |
|
283 pEmailAccounts->DeletePopAccountL(popAccounts[i]); |
|
284 deleteServiceRelatedEntriesFromFolder(popAccounts[i].iPopService, KDocumentsEntryIdValue); |
|
285 } |
|
286 CleanupStack::PopAndDestroy(settings); |
|
287 } |
|
288 |
|
289 RArray<TSmtpAccount> smtpAccounts(10); |
|
290 pEmailAccounts->GetSmtpAccountsL(smtpAccounts); |
|
291 for (int i=0; i < smtpAccounts.Count(); i++) { |
|
292 CImSmtpSettings* settings = new(ELeave) CImSmtpSettings(); |
|
293 CleanupStack::PushL(settings); |
|
294 pEmailAccounts->LoadSmtpSettingsL(smtpAccounts[i], *settings); |
|
295 if (settings->ServerAddress().Compare(KSmtpServerAddress) == 0) { |
|
296 pEmailAccounts->DeleteSmtpAccountL(smtpAccounts[i]); |
|
297 deleteServiceRelatedEntriesFromFolder(smtpAccounts[i].iSmtpService, KDocumentsEntryIdValue); |
|
298 } |
|
299 CleanupStack::PopAndDestroy(settings); |
|
300 } |
|
301 |
|
302 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
303 } |
|
304 |
|
305 void clearMessageStore() |
|
306 { |
|
307 TRAPD(err, clearMessageStoreL()); |
|
308 Q_UNUSED(err) |
|
309 } |
|
310 |
|
311 QMessageAccountId createPopAndSmtpAccountL(const TDesC& accountName, const TDesC& fromAddress) |
|
312 { |
|
313 CEmailAccounts* pEmailAccounts = CEmailAccounts::NewLC(); |
|
314 |
|
315 // Create IAP Preferences for IMAP & POP3 |
|
316 CImIAPPreferences* pImIAPPreferences = CImIAPPreferences::NewLC(); |
|
317 |
|
318 // Create POP3 Account |
|
319 CImPop3Settings* pImPop3Settings = new(ELeave) CImPop3Settings(); |
|
320 CleanupStack::PushL(pImPop3Settings); |
|
321 pEmailAccounts->PopulateDefaultPopSettingsL(*pImPop3Settings, *pImIAPPreferences); |
|
322 pImPop3Settings->SetServerAddressL(KPopServer); |
|
323 pImPop3Settings->SetLoginNameL(KPopLoginName); |
|
324 pImPop3Settings->SetPasswordL(KPopPassword); |
|
325 pImPop3Settings->SetPort(110); |
|
326 TPopAccount popAccount = pEmailAccounts->CreatePopAccountL(accountName, *pImPop3Settings, *pImIAPPreferences, EFalse); |
|
327 |
|
328 // Create SMTP Account |
|
329 CImSmtpSettings *pImSmtpSettings = new (ELeave) CImSmtpSettings(); |
|
330 CleanupStack::PushL(pImSmtpSettings); |
|
331 pEmailAccounts->PopulateDefaultSmtpSettingsL(*pImSmtpSettings, *pImIAPPreferences); |
|
332 pImSmtpSettings->SetServerAddressL(KSmtpServerAddress); |
|
333 pImSmtpSettings->SetEmailAliasL(KEmailAlias); |
|
334 pImSmtpSettings->SetEmailAddressL(fromAddress); |
|
335 pImSmtpSettings->SetReplyToAddressL(fromAddress); |
|
336 pImSmtpSettings->SetReceiptAddressL(fromAddress); |
|
337 pImSmtpSettings->SetPort(25); |
|
338 pEmailAccounts->CreateSmtpAccountL(popAccount, *pImSmtpSettings, *pImIAPPreferences, EFalse); |
|
339 |
|
340 CleanupStack::PopAndDestroy(pImSmtpSettings); |
|
341 CleanupStack::PopAndDestroy(pImPop3Settings); |
|
342 CleanupStack::PopAndDestroy(pImIAPPreferences); |
|
343 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
344 |
|
345 return QMessageAccountId(addIdPrefix(QString::number(popAccount.iPopService), SymbianHelpers::EngineTypeMTM)); |
|
346 } |
|
347 |
|
348 QMessageAccountId createPopAndSmtpAccount(const TDesC& accountName, const TDesC& fromAddress) |
|
349 { |
|
350 QMessageAccountId retVal; |
|
351 TRAPD(err, retVal = createPopAndSmtpAccountL(accountName, fromAddress)); |
|
352 Q_UNUSED(err) |
|
353 return retVal; |
|
354 } |
|
355 |
|
356 bool imapAccountByNameL(const TDesC& accountName, TImapAccount& account) |
|
357 { |
|
358 CEmailAccounts* pEmailAccounts = CEmailAccounts::NewLC(); |
|
359 |
|
360 RArray<TImapAccount> imapAccounts(10); |
|
361 pEmailAccounts->GetImapAccountsL(imapAccounts); |
|
362 for (int i=0; i < imapAccounts.Count(); i++) { |
|
363 if (imapAccounts[i].iImapAccountName.Compare(accountName) == 0) { |
|
364 account = imapAccounts[i]; |
|
365 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
366 return true; |
|
367 } |
|
368 } |
|
369 |
|
370 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
371 return false; |
|
372 } |
|
373 |
|
374 bool imapAccountByName(const TDesC& accountName, TImapAccount& account) |
|
375 { |
|
376 bool retVal = false; |
|
377 TRAPD(err, retVal = imapAccountByNameL(accountName, account)); |
|
378 Q_UNUSED(err) |
|
379 return retVal; |
|
380 } |
|
381 |
|
382 bool pop3AccountByNameL(const TDesC& accountName, TPopAccount& account) |
|
383 { |
|
384 CEmailAccounts* pEmailAccounts = CEmailAccounts::NewLC(); |
|
385 |
|
386 RArray<TPopAccount> popAccounts(10); |
|
387 pEmailAccounts->GetPopAccountsL(popAccounts); |
|
388 for (int i=0; i < popAccounts.Count(); i++) { |
|
389 if (popAccounts[i].iPopAccountName.Compare(accountName) == 0) { |
|
390 account = popAccounts[i]; |
|
391 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
392 return true; |
|
393 } |
|
394 } |
|
395 |
|
396 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
397 return false; |
|
398 } |
|
399 |
|
400 bool pop3AccountByName(const TDesC& accountName, TPopAccount& account) |
|
401 { |
|
402 bool retVal = false; |
|
403 TRAPD(err, retVal = pop3AccountByNameL(accountName, account)); |
|
404 Q_UNUSED(err) |
|
405 return retVal; |
|
406 } |
|
407 |
|
408 bool smtpAccountByNameL(const TDesC& accountName, TSmtpAccount& account) |
|
409 { |
|
410 CEmailAccounts* pEmailAccounts = CEmailAccounts::NewLC(); |
|
411 |
|
412 RArray<TSmtpAccount> smtpAccounts(10); |
|
413 pEmailAccounts->GetSmtpAccountsL(smtpAccounts); |
|
414 for (int i=0; i < smtpAccounts.Count(); i++) { |
|
415 if (smtpAccounts[i].iSmtpAccountName.Compare(accountName) == 0) { |
|
416 account = smtpAccounts[i]; |
|
417 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
418 return true; |
|
419 } |
|
420 } |
|
421 |
|
422 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
423 return false; |
|
424 } |
|
425 |
|
426 bool smtpAccountByName(const TDesC& accountName, TSmtpAccount& account) |
|
427 { |
|
428 bool retVal = false; |
|
429 TRAPD(err, retVal = smtpAccountByNameL(accountName, account)); |
|
430 Q_UNUSED(err) |
|
431 return retVal; |
|
432 } |
|
433 |
|
434 QMessageAccountId createImapAndSmtpAccountL(const TDesC& accountName, const TDesC& fromAddress) |
|
435 { |
|
436 CEmailAccounts* pEmailAccounts = CEmailAccounts::NewLC(); |
|
437 |
|
438 // Create IAP Preferences for IMAP & SMTP |
|
439 CImIAPPreferences* pImIAPPreferences = CImIAPPreferences::NewLC(); |
|
440 |
|
441 // Create IMAP Account |
|
442 CImImap4Settings* pImap4Settings = new(ELeave)CImImap4Settings; |
|
443 CleanupStack::PushL(pImap4Settings); |
|
444 pEmailAccounts->PopulateDefaultImapSettingsL(*pImap4Settings, *pImIAPPreferences); |
|
445 pImap4Settings->SetServerAddressL(KImapServer); |
|
446 pImap4Settings->SetLoginNameL(KImapLoginName); |
|
447 pImap4Settings->SetPasswordL(KImapPassword); |
|
448 pImap4Settings->SetPort(143); |
|
449 TImapAccount imapAccount = pEmailAccounts->CreateImapAccountL(accountName, *pImap4Settings, *pImIAPPreferences, EFalse); |
|
450 |
|
451 // Create SMTP Account |
|
452 CImSmtpSettings* pImSmtpSettings = new (ELeave) CImSmtpSettings(); |
|
453 CleanupStack::PushL(pImSmtpSettings); |
|
454 pEmailAccounts->PopulateDefaultSmtpSettingsL(*pImSmtpSettings, *pImIAPPreferences); |
|
455 pImSmtpSettings->SetServerAddressL(KSmtpServerAddress); |
|
456 pImSmtpSettings->SetEmailAliasL(KEmailAlias); |
|
457 pImSmtpSettings->SetEmailAddressL(fromAddress); |
|
458 pImSmtpSettings->SetReplyToAddressL(fromAddress); |
|
459 pImSmtpSettings->SetReceiptAddressL(fromAddress); |
|
460 pImSmtpSettings->SetPort(25); |
|
461 TSmtpAccount smtpAccount = pEmailAccounts->CreateSmtpAccountL(imapAccount, *pImSmtpSettings, *pImIAPPreferences, EFalse); |
|
462 |
|
463 TSmtpAccount defaultAccount; |
|
464 if (pEmailAccounts->DefaultSmtpAccountL(defaultAccount) == KErrNotFound) |
|
465 { |
|
466 pEmailAccounts->SetDefaultSmtpAccountL(smtpAccount); |
|
467 } |
|
468 |
|
469 CleanupStack::PopAndDestroy(pImSmtpSettings); |
|
470 CleanupStack::PopAndDestroy(pImap4Settings); |
|
471 CleanupStack::PopAndDestroy(pImIAPPreferences); |
|
472 CleanupStack::PopAndDestroy(pEmailAccounts); |
|
473 |
|
474 return QMessageAccountId(addIdPrefix(QString::number(imapAccount.iImapService), SymbianHelpers::EngineTypeMTM)); |
|
475 } |
|
476 |
|
477 QMessageAccountId createImapAndSmtpAccount(const TDesC& accountName, const TDesC& fromAddress) |
|
478 { |
|
479 QMessageAccountId retVal; |
|
480 TRAPD(err, retVal = createImapAndSmtpAccountL(accountName, fromAddress)); |
|
481 Q_UNUSED(err) |
|
482 return retVal; |
|
483 } |
|
484 |
|
485 QMessageAccountId addAccount(const Parameters ¶ms) |
|
486 { |
|
487 QString accountName(params["name"]); |
|
488 TPtrC16 symbianAccountName(KNullDesC); |
|
489 symbianAccountName.Set(reinterpret_cast<const TUint16*>(accountName.utf16())); |
|
490 |
|
491 QString fromAddress(params["fromAddress"]); |
|
492 TPtrC16 symbianFromAddress(KNullDesC); |
|
493 symbianFromAddress.Set(reinterpret_cast<const TUint16*>(fromAddress.utf16())); |
|
494 |
|
495 return createImapAndSmtpAccount(symbianAccountName, symbianFromAddress); |
|
496 } |
|
497 |
|
498 QMessageFolderId addFolderL(const TDesC& symbianAccountName, const TDesC& symbianFolderName) |
|
499 { |
|
500 TSmtpAccount account; |
|
501 bool retVal = smtpAccountByName(symbianAccountName, account); |
|
502 Q_UNUSED(retVal) |
|
503 |
|
504 CSymbianMessagingSession* pSession = new CSymbianMessagingSession(); |
|
505 CleanupStack::PushL(pSession); |
|
506 CMsvEntry* pEntry = CMsvEntry::NewL(*(pSession->ipMsvSession), KDocumentsEntryIdValue, TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue)); |
|
507 CleanupStack::PushL(pEntry); |
|
508 |
|
509 TMsvEntry newFolder; |
|
510 newFolder.iType = KUidMsvFolderEntry; |
|
511 newFolder.iMtm = KUidMsvLocalServiceMtm; |
|
512 newFolder.iServiceId = account.iSmtpService; |
|
513 newFolder.SetReadOnly(EFalse); |
|
514 newFolder.SetVisible(ETrue); |
|
515 newFolder.iDescription.Set(symbianFolderName); |
|
516 newFolder.iDetails.Set(symbianFolderName); |
|
517 newFolder.iDate.HomeTime(); |
|
518 pEntry->CreateL(newFolder); |
|
519 TMsvId folderId = newFolder.Id(); |
|
520 |
|
521 CleanupStack::PopAndDestroy(pEntry); |
|
522 CleanupStack::PopAndDestroy(pSession); |
|
523 |
|
524 QString nullString = "00000000"; |
|
525 QString serviceEntryIdString = QString::number(account.iRelatedService); |
|
526 serviceEntryIdString = nullString.left(8-serviceEntryIdString.length()) + serviceEntryIdString; |
|
527 QString folderIdString = QString::number(folderId); |
|
528 folderIdString = nullString.left(8-folderIdString.length()) + folderIdString; |
|
529 return addIdPrefix(serviceEntryIdString+folderIdString, SymbianHelpers::EngineTypeMTM); |
|
530 } |
|
531 |
|
532 QMessageFolderId addFolder(const Parameters ¶ms) |
|
533 { |
|
534 QString accountName(params["parentAccountName"]); |
|
535 TPtrC16 symbianAccountName(KNullDesC); |
|
536 symbianAccountName.Set(reinterpret_cast<const TUint16*>(accountName.utf16())); |
|
537 |
|
538 QString folderName(params["name"]); |
|
539 TPtrC16 symbianFolderName(KNullDesC); |
|
540 symbianFolderName.Set(reinterpret_cast<const TUint16*>(folderName.utf16())); |
|
541 |
|
542 QMessageFolderId id; |
|
543 TRAPD(err, id = addFolderL(symbianAccountName, symbianFolderName)); |
|
544 Q_UNUSED(err) |
|
545 return id; |
|
546 } |
|
547 |
|
548 QMessageId addMessage(const Parameters ¶ms) |
|
549 { |
|
550 return MapiSession::addMessage(params); |
|
551 } |
|
552 |
|
553 } |
|
554 |