15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "qtemailfetcher.h" |
18 #include "qtemailfetcher.h" |
19 #include <csearchdocument.h> |
19 #include <csearchdocument.h> |
20 #include <cpixmaindefs.h> |
|
21 #include <nmapiemailaddress.h> |
20 #include <nmapiemailaddress.h> |
22 #include <nmapimessagebody.h> |
21 #include <nmapimessagebody.h> |
23 #include <nmapimailbox.h> |
22 #include <nmapimailbox.h> |
24 #include <QTimer> |
23 #include <QTimer> |
25 #include <QDebug> |
24 #include <QDebug> |
26 //#include <QThread> //If we happen to use QThread::yieldCurrentThread() |
25 #include <qdatetime.h> |
27 |
26 |
28 //Symbian specific details; picked up from cemailplugin.cpp. |
27 //Symbian specific details; picked up from cemailplugin.cpp. |
29 //Refactor it to cpixmaindefs.h |
28 //Refactor it to cpixmaindefs.h |
30 _LIT(KMsgBaseAppClassGeneric, "root msg email"); |
29 _LIT(KMsgBaseAppClassGeneric, "root msg email"); |
31 |
30 |
32 _LIT(KMsgSubject, "Subject"); |
31 _LIT(KMsgSubject, "Subject"); |
|
32 _LIT(KMsgSender, "Sender"); |
33 _LIT(KMsgRecipients, "Recipients"); |
33 _LIT(KMsgRecipients, "Recipients"); |
34 _LIT(KMsgBody, "Body"); |
34 _LIT(KMsgBody, "Body"); |
35 _LIT(KMailBoxId, "MailBoxId"); |
35 _LIT(KMailBoxId, "MailBoxId"); |
36 _LIT(KFolderId, "FolderId"); |
36 _LIT(KFolderId, "FolderId"); |
|
37 _LIT(KHasAttachment, "HasAttachment"); |
37 _LIT(KMailBoxName, "MailBoxName"); |
38 _LIT(KMailBoxName, "MailBoxName"); |
38 _LIT(KFolderName, "FolderName"); |
39 //_LIT(KFolderName, "FolderName"); |
39 _LIT(KMimeTypeField, CPIX_MIMETYPE_FIELD); |
40 _LIT(KMimeTypeField, CPIX_MIMETYPE_FIELD); |
40 _LIT(KMimeTypeMsg, "Messages"); |
41 _LIT(KMimeTypeMsg, "Messages"); |
41 |
42 _LIT(KAttachment, "Attachment"); |
42 |
43 _LIT(KSentTime, "SentTime"); |
43 |
44 |
44 //------------------------------------------------------------------------------ |
45 //------------------------------------------------------------------------------ |
45 QEmailFetcher::QEmailFetcher( MEmailItemObserver& aObserver ) |
46 QEmailFetcher::QEmailFetcher( MEmailItemObserver& aObserver ) |
46 :iEmailObserver( aObserver ), |
47 :iEmailObserver( aObserver ), |
47 iEmailEventNotifier( NULL ), |
48 iEmailEventNotifier( NULL ), |
90 qDebug() << "QEmailFetcher::newInstance :END"; |
95 qDebug() << "QEmailFetcher::newInstance :END"; |
91 return emailFetcher; //returns only if not null. |
96 return emailFetcher; //returns only if not null. |
92 } |
97 } |
93 |
98 |
94 //------------------------------------------------------------------------------ |
99 //------------------------------------------------------------------------------ |
95 void QEmailFetcher::initialize( QEmailFetcher* aThis ){ |
100 void QEmailFetcher::initialize( ){ |
96 //The use of 'aThis' is because the current function is static. |
|
97 qDebug() << "QEmailFetcher::initialize :START"; |
101 qDebug() << "QEmailFetcher::initialize :START"; |
98 connect( aThis->iEmailService, SIGNAL(initialized(bool)), |
102 connect( iEmailService, SIGNAL(initialized(bool)), |
99 aThis, SLOT(emailServiceIntialized(bool)) ); |
103 this, SLOT(emailServiceIntialized(bool)) ); |
100 aThis->iEmailService->initialise(); |
104 iEmailService->initialise(); |
101 //Monitor for Message changes |
105 //Monitor for Message changes |
102 aThis->connect( aThis->iEmailEventNotifier, |
106 connect( iEmailEventNotifier, |
103 SIGNAL(messageEvent(MessageEvent, quint64, quint64, QList<quint64>)), |
107 SIGNAL(messageEvent(EmailClientApi::NmApiMessageEvent, quint64, quint64, QList<quint64>)), |
104 aThis, |
108 this, |
105 SLOT(handleMessageEvent(MessageEvent, quint64, quint64, QList<quint64>)) ); |
109 SLOT(handleMessageEvent(EmailClientApi::NmApiMessageEvent, quint64, quint64, QList<quint64>)) ); |
106 //Monitor for Mailbox changes |
|
107 aThis->connect( aThis->iEmailEventNotifier, |
|
108 SIGNAL(mailboxEvent(MailboxEvent, QList<quint64>)), |
|
109 aThis, |
|
110 SLOT(handlemailboxEvent(MailboxEvent, QList<quint64>))); |
|
111 //Start the monitoring |
110 //Start the monitoring |
112 aThis->iEmailEventNotifier->start(); |
111 iEmailEventNotifier->start(); |
|
112 qDebug() << "QEmailFetcher::Started monitoring for Email message event"; |
113 qDebug() << "QEmailFetcher::initialize :END"; |
113 qDebug() << "QEmailFetcher::initialize :END"; |
114 } |
114 } |
115 |
115 |
116 //------------------------------------------------------------------------------ |
116 //------------------------------------------------------------------------------ |
117 void QEmailFetcher::emailServiceIntialized(bool aAllOk){ |
117 void QEmailFetcher::emailServiceIntialized(bool aAllOk){ |
141 { |
141 { |
142 return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length()); |
142 return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length()); |
143 } |
143 } |
144 |
144 |
145 //------------------------------------------------------------------------------ |
145 //------------------------------------------------------------------------------ |
146 // TODO Remove this code if qt_QString2TPtrC works. |
146 CSearchDocument* getPartialSearchDocument( quint64 aEnvelopeId ) { |
147 // TODO If this function is used, remember to release memory. |
|
148 // Ownership with caller. |
|
149 //HBufC* qt_QString2HBufC(const QString& aString) |
|
150 //{ |
|
151 // HBufC *buffer; |
|
152 //#ifdef QT_NO_UNICODE |
|
153 // TPtrC8 ptr(reinterpret_cast<const TUint8*>(aString.toLocal8Bit().constData())); |
|
154 //#else |
|
155 // TPtrC16 ptr(qt_QString2TPtrC(aString)); |
|
156 //#endif |
|
157 // buffer = q_check_ptr(HBufC::New(ptr.Length())); |
|
158 // buffer->Des().Copy(ptr); |
|
159 // return buffer; |
|
160 //} |
|
161 |
|
162 CSearchDocument* getPartialSearchDocument( const NmApiMessageEnvelope& aEnvelope ) { |
|
163 qDebug() << "getPartialSearchDocument :START"; |
147 qDebug() << "getPartialSearchDocument :START"; |
164 CSearchDocument* doc = 0; |
148 CSearchDocument* doc = 0; |
165 QT_TRAP_THROWING( |
149 QT_TRAP_THROWING( |
166 //Use qt_Qstring2TPtrC since we are working with <b>const</b> EmailMessageEnvelope. |
150 //Use qt_Qstring2TPtrC since we are working with <b>const</b> EmailMessageEnvelope. |
167 doc = CSearchDocument::NewL( qt_QString2TPtrC( QString().setNum( aEnvelope.id() ) ), |
151 doc = CSearchDocument::NewL( qt_QString2TPtrC( QString().setNum( aEnvelopeId ) ), |
168 KMsgBaseAppClassGeneric ); |
152 KMsgBaseAppClassGeneric ); |
169 ); |
153 ); |
170 qDebug() << "getPartialSearchDocument :END"; |
154 qDebug() << "getPartialSearchDocument :END"; |
171 return doc; |
155 return doc; |
172 } |
156 } |
173 } //anonymous namespace |
157 } //anonymous namespace |
174 //------------------------------------------------------------------------------ |
158 //------------------------------------------------------------------------------ |
175 |
159 |
176 CSearchDocument* QEmailFetcher::getSearchDocument( const NmApiMessageEnvelope& aEnvelope ,quint64 aMailboxId, quint64 aFolderId ){ |
160 CSearchDocument* QEmailFetcher::getSearchDocumentL( const NmApiMessageEnvelope& aEnvelope ,quint64 aMailboxId, quint64 aFolderId ){ |
177 QList<NmApiEmailAddress> toList; |
161 QList<NmApiEmailAddress> toList; |
178 qDebug() << "QEmailFetcher::getSearchDocument :START"; |
162 qDebug() << "QEmailFetcher::getSearchDocumentL :START"; |
|
163 //We need ALL the recipients in a SINGLE field. |
|
164 |
179 //Need to cast away const-ness since the get method is unfortunately not const. |
165 //Need to cast away const-ness since the get method is unfortunately not const. |
180 const_cast<NmApiMessageEnvelope&>(aEnvelope).getToRecipients( toList ); |
166 const_cast<NmApiMessageEnvelope&>(aEnvelope).getToRecipients( toList ); |
181 |
|
182 //We need ALL the recipients in a SINGLE field. |
|
183 QString recipients = ""; |
167 QString recipients = ""; |
184 for( int i=0; i<toList.length(); i++ ) |
168 for( int i=0; i<toList.length(); i++ ) |
185 recipients += toList.at( i ).displayName() + " "; //or should we get address? |
169 { |
186 |
170 qDebug() << "QEmailFetcher::To receipient displayname :"<< toList.at( i ).displayName() << "Address : "<<toList.at( i ).address(); |
|
171 recipients += toList.at( i ).displayName() + " "; |
|
172 recipients += toList.at( i ).address() + " "; |
|
173 } |
|
174 // Get CC receipents |
|
175 const_cast<NmApiMessageEnvelope&>(aEnvelope).getCcRecipients( toList ); |
|
176 for( int i=0; i<toList.length(); i++ ) |
|
177 { |
|
178 qDebug() << "QEmailFetcher::CC receipient displayname :"<< toList.at( i ).displayName() << "Address : "<<toList.at( i ).address(); |
|
179 recipients += toList.at( i ).displayName() + " "; |
|
180 recipients += toList.at( i ).address() + " "; |
|
181 } |
|
182 |
187 NmApiMessageBody body; |
183 NmApiMessageBody body; |
188 //Cast away const-ness since the get method is unfortunately not const. |
184 //Cast away const-ness since the get method is unfortunately not const. |
189 //Returns void. Cannot check for success/failure. |
185 //Returns void. Cannot check for success/failure. |
190 const_cast<NmApiMessageEnvelope&>(aEnvelope).getPlainTextBody( body ); |
186 const_cast<NmApiMessageEnvelope&>(aEnvelope).getPlainTextBody( body ); |
191 QString msgBody = body.content(); |
187 QString msgBody = body.content(); |
192 |
188 qDebug() << "QEmailFetcher::Body of mail using paintextAPI:"<< aEnvelope.plainText() ; |
193 CSearchDocument* doc = 0; |
189 CSearchDocument* doc = 0; |
194 QT_TRAP_THROWING( |
190 QT_TRAP_THROWING( |
195 //Use qt_Qstring2TPtrC since we are working with <b>const</b> EmailMessageEnvelope. |
191 //Use qt_Qstring2TPtrC since we are working with <b>const</b> EmailMessageEnvelope. |
196 doc = CSearchDocument::NewL( qt_QString2TPtrC( QString().setNum( aEnvelope.id() ) ), |
192 doc = CSearchDocument::NewL( qt_QString2TPtrC( QString().setNum( aEnvelope.id() ) ), |
197 KMsgBaseAppClassGeneric ); |
193 KMsgBaseAppClassGeneric ); |
198 doc->AddFieldL( KMimeTypeField, KMimeTypeMsg, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized); |
194 //Add the sender details |
199 doc->AddFieldL( KMsgSubject, qt_QString2TPtrC( aEnvelope.subject() ), CDocumentField::EStoreYes | CDocumentField::EIndexTokenized ); |
195 doc->AddFieldL( KMsgSender, qt_QString2TPtrC( const_cast<NmApiMessageEnvelope&>(aEnvelope).sender() ), |
200 doc->AddFieldL( KMsgRecipients, qt_QString2TPtrC( recipients ), CDocumentField::EStoreYes | CDocumentField::EIndexTokenized ); |
196 CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText); |
201 doc->AddFieldL( KMsgBody, qt_QString2TPtrC( msgBody ), CDocumentField::EStoreYes | CDocumentField::EIndexTokenized ); |
197 //Add the Mimetype |
202 doc->AddFieldL( KMailBoxId, qt_QString2TPtrC( QString().setNum( aMailboxId ) ), CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized ); |
198 doc->AddFieldL( KMimeTypeField, KMimeTypeMsg, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized ); |
203 doc->AddFieldL( KFolderId, qt_QString2TPtrC( QString().setNum( aFolderId ) ), CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized ); |
199 //Add the Subject field |
|
200 doc->AddFieldL( KMsgSubject, qt_QString2TPtrC( aEnvelope.subject() ), |
|
201 CDocumentField::EStoreYes | CDocumentField::EIndexTokenized ); |
|
202 //Add the recipients list (Includes To and CC fields) |
|
203 doc->AddFieldL( KMsgRecipients, qt_QString2TPtrC( recipients ), |
|
204 CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
|
205 //Add the email body |
|
206 doc->AddFieldL( KMsgBody, qt_QString2TPtrC( msgBody ), |
|
207 CDocumentField::EStoreYes | CDocumentField::EIndexTokenized ); |
|
208 //Add the mailboxid |
|
209 doc->AddFieldL( KMailBoxId, qt_QString2TPtrC( QString().setNum( aMailboxId ) ), |
|
210 CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized | CDocumentField::EAggregateNo ); |
|
211 //Add the folder Id |
|
212 doc->AddFieldL( KFolderId, qt_QString2TPtrC( QString().setNum( aFolderId ) ), |
|
213 CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized | CDocumentField::EAggregateNo ); |
|
214 //Add the attachment field. This field will be added only if there is any attachment.Details of the attachment |
|
215 //are not added due to lack of email application support. |
|
216 if ( aEnvelope.hasAttachments() ) |
|
217 doc->AddFieldL( KHasAttachment, KAttachment, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized); |
|
218 //Add mailbox name |
|
219 NmApiMailbox aMailBox; |
|
220 iEmailService->getMailbox( aMailboxId, aMailBox ); |
|
221 doc->AddFieldL( KMailBoxName, qt_QString2TPtrC(aMailBox.name()) , |
|
222 CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
204 |
223 |
205 // NmApiMailbox aMailBox; |
224 // Sent date time KSentTime |
206 // iEmailService->getMailbox( aMailboxId, aMailBox ); |
225 QDateTime time = aEnvelope.sentTime(); |
207 // doc->AddFieldL( KMailBoxName, qt_QString2TPtrC(aMailBox.name()) , CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized ); |
226 doc->AddFieldL( KSentTime, qt_QString2TPtrC(time.toString ()) , |
208 //TODO : Add folder name field |
227 CDocumentField::EStoreYes | CDocumentField::EIndexTokenized ); |
209 //_LIT(KFolderName, "FolderName"); |
228 //TODO : Foldername is not harvested as there is no API exposed from email application to get the foldername based on folderID. |
|
229 //This feature will be implemented as soon as we get supporting API's from Email team |
|
230 |
210 //Adding subject and body to the excerpt. |
231 //Adding subject and body to the excerpt. |
211 QString excerpt ; |
232 QString excerpt ; |
212 excerpt = aEnvelope.subject(); |
233 excerpt = aEnvelope.subject(); |
213 excerpt += msgBody ; |
234 excerpt += msgBody ; |
214 doc->AddExcerptL( qt_QString2TPtrC(excerpt) ); |
235 doc->AddExcerptL( qt_QString2TPtrC(excerpt) ); |
215 ); |
236 ); |
216 qDebug() << "QEmailFetcher::getSearchDocument :END"; |
237 qDebug() << "QEmailFetcher::getSearchDocumentL :END"; |
217 return doc; |
238 return doc; |
218 } |
239 } |
219 |
240 |
220 |
241 |
221 //------------------------------------------------------------------------------ |
242 //------------------------------------------------------------------------------ |
222 //Just to avoid duplication of the following two lines. |
|
223 void QEmailFetcher::NotifyHarvestingComplete(){ |
243 void QEmailFetcher::NotifyHarvestingComplete(){ |
224 qDebug() << "QEmailFetcher::NotifyHarvestingComplete :START"; |
244 qDebug() << "QEmailFetcher::NotifyHarvestingComplete :START"; |
225 iCurrentMailboxIndex = iCurrentFolderIndex = 0; |
245 iCurrentMailboxIndex = iCurrentFolderIndex = 0; |
|
246 //Free the iMailBoxes and iFolders |
|
247 iMailBoxes.clear(); |
|
248 iFolders.clear(); |
226 QT_TRAP_THROWING( iEmailObserver.HarvestingCompleted() ); |
249 QT_TRAP_THROWING( iEmailObserver.HarvestingCompleted() ); |
227 qDebug() << "QEmailFetcher::NotifyHarvestingComplete :END"; |
250 qDebug() << "QEmailFetcher::NotifyHarvestingComplete :END"; |
228 return; |
251 return; |
229 } |
252 } |
230 |
253 |
334 QList<NmApiMessageEnvelope> envelopes; |
357 QList<NmApiMessageEnvelope> envelopes; |
335 if ( aCount > 0 && iEnvelopeListing->getEnvelopes(envelopes) ) { |
358 if ( aCount > 0 && iEnvelopeListing->getEnvelopes(envelopes) ) { |
336 for( int i=0; i<envelopes.count(); i++ ) { |
359 for( int i=0; i<envelopes.count(); i++ ) { |
337 const NmApiMessageEnvelope &envelope = envelopes.at( i ); |
360 const NmApiMessageEnvelope &envelope = envelopes.at( i ); |
338 //Create document and call back observer. |
361 //Create document and call back observer. |
339 QT_TRAP_THROWING( iEmailObserver.HandleDocumentL( getSearchDocument( envelope, iFolders.at( iCurrentFolderIndex -1 ).id(), iMailBoxes.at( iCurrentMailboxIndex-1 ).id() ), |
362 QT_TRAP_THROWING( iEmailObserver.HandleDocumentL( getSearchDocumentL( envelope, iFolders.at( iCurrentFolderIndex -1 ).id(), |
340 ECPixAddAction ) ); |
363 iMailBoxes.at( iCurrentMailboxIndex-1 ).id() ), ECPixAddAction ) ); |
341 } |
364 } |
342 } |
365 } |
343 qDebug() << "QEmailFetcher::processMessages :END"; |
366 qDebug() << "QEmailFetcher::processMessages :END"; |
344 } |
367 } |
345 |
368 |
346 //------------------------------------------------------------------------------ |
369 //------------------------------------------------------------------------------ |
347 void QEmailFetcher::handleMessageEvent( NmApiMessageEvent aEvent, quint64 aMailboxId, quint64 aFolderId, QList<quint64> aMessageList){ |
370 void QEmailFetcher::handleMessageEvent( EmailClientApi::NmApiMessageEvent aEvent, quint64 aMailboxId, quint64 aFolderId, QList<quint64> aMessageList){ |
348 NmApiMessageEnvelope envelope; |
371 NmApiMessageEnvelope envelope; |
349 qDebug() << "QEmailFetcher::handleMessageEvent :START"; |
372 qDebug() << "QEmailFetcher::handleMessageEvent :START"; |
350 const int messageCount = aMessageList.count(); |
373 const int messageCount = aMessageList.count(); |
351 if( messageCount>0 ){ |
374 if( messageCount>0 ){ |
352 if( aEvent == MessageCreated || aEvent == MessageChanged ){ |
375 if( aEvent == MessageCreated || aEvent == MessageChanged ){ |
353 qDebug() << "QEmailFetcher::handleMessageEvent :MessageCreated || MessageChanged"; |
376 qDebug() << "QEmailFetcher::handleMessageEvent :MessageCreated || MessageChanged"; |
354 for( int i=0; i<messageCount; i++ ){ |
377 for( int i=0; i<messageCount; i++ ){ |
355 if( iEmailService->getEnvelope( aMailboxId, aFolderId, aMessageList.at( i ), envelope ) ){ |
378 if( iEmailService->getEnvelope( aMailboxId, aFolderId, aMessageList.at( i ), envelope ) ){ |
356 qDebug() << "QEmailFetcher::handleMessageEvent :HandleDocumentL"; |
379 qDebug() << "QEmailFetcher::handleMessageEvent :HandleDocumentL"; |
357 QT_TRAP_THROWING( |
380 QT_TRAP_THROWING( |
358 iEmailObserver.HandleDocumentL( getSearchDocument( envelope, aMailboxId, aFolderId ), |
381 iEmailObserver.HandleDocumentL( getSearchDocumentL( envelope, aMailboxId, aFolderId ), |
359 //Doing this simply avoids *duplicate* code for update action. |
382 //Doing this simply avoids *duplicate* code for update action. |
360 aEvent == MessageCreated ? ECPixAddAction : ECPixUpdateAction ) ); |
383 aEvent == MessageCreated ? ECPixAddAction : ECPixUpdateAction ) ); |
361 } |
384 } |
362 } |
385 } |
363 } |
386 } |
364 else if( aEvent == MessageDeleted ) { |
387 else if( aEvent == MessageDeleted ) { |
365 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted"; |
388 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted"; |
366 //TODO We can do better. For delete, we dont have to create full document. Just the ID should be enough. |
|
367 //We can have another function called getPartialSearchDocument so deletes will be faster. |
|
368 for( int i=0; i<messageCount; i++ ){ |
389 for( int i=0; i<messageCount; i++ ){ |
369 if( iEmailService->getEnvelope( aMailboxId, aFolderId, aMessageList.at( i ), envelope ) ){ |
|
370 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted : HandleDocumentL"; |
390 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted : HandleDocumentL"; |
371 QT_TRAP_THROWING( |
391 QT_TRAP_THROWING( |
372 iEmailObserver.HandleDocumentL( getPartialSearchDocument( envelope ), ECPixRemoveAction ) ); |
392 iEmailObserver.HandleDocumentL( getPartialSearchDocument( aMessageList.at( i ) ), ECPixRemoveAction ) ); |
373 } |
393 } |
374 } |
394 } |
375 } |
395 } |
376 } |
396 } |
377 } |
|
378 |
|
379 //-------------------------------------------------------------------------------------- |
|
380 void QEmailFetcher::handlemailboxEvent( EmailClientApi::NmApiMailboxEvent event, QList<quint64> idlist ){ |
|
381 const int mailboxCount = idlist.count(); |
|
382 if( event == MailboxCreated ) |
|
383 { |
|
384 //New mailbox is created.Harvest the Mailbox name and all the folder names |
|
385 } |
|
386 else |
|
387 { |
|
388 //MailBox is deleted so delete the document related to all the mailbox and folders in the mailbox |
|
389 } |
|
390 } |
|
391 |
|
392 CSearchDocument* QEmailFetcher::getMailboxorfolderSearchDocument( quint64 aMailboxId, quint64 aFolderId, TEmailDocType aDocType, QString aFoldername ){ |
|
393 |
|
394 CSearchDocument* doc = 0; |
|
395 QT_TRAP_THROWING( |
|
396 //Use qt_Qstring2TPtrC since we are working with <b>const</b> EmailMessageEnvelope. |
|
397 if ( aDocType == EEmailTypeFolder) |
|
398 { |
|
399 doc = CSearchDocument::NewL( qt_QString2TPtrC( QString().setNum( aFolderId ) ), |
|
400 KMsgBaseAppClassGeneric ); |
|
401 doc->AddFieldL( KFolderName, qt_QString2TPtrC(aFoldername) , CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized ); |
|
402 doc->AddFieldL( KFolderId, qt_QString2TPtrC( QString().setNum( aFolderId ) ), CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized ); |
|
403 } |
|
404 else if ( aDocType == EEmailTypeMailBox ) |
|
405 { |
|
406 doc = CSearchDocument::NewL( qt_QString2TPtrC( QString().setNum( aMailboxId ) ), |
|
407 KMsgBaseAppClassGeneric ); |
|
408 NmApiMailbox aMailBox; |
|
409 iEmailService->getMailbox( aMailboxId, aMailBox ); |
|
410 doc->AddFieldL( KMailBoxName, qt_QString2TPtrC(aMailBox.name()) , CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized ); |
|
411 } |
|
412 doc->AddFieldL( KMimeTypeField, KMimeTypeMsg, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized); |
|
413 doc->AddFieldL( KMailBoxId, qt_QString2TPtrC( QString().setNum( aMailboxId ) ), CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized ); |
|
414 |
|
415 ); |
|
416 qDebug() << "QEmailFetcher::getSearchDocument :END"; |
|
417 return doc; |
|
418 } |
|