295 return; |
298 return; |
296 } |
299 } |
297 //More mailboxes available. |
300 //More mailboxes available. |
298 delete iMailFolderList; iMailFolderList = NULL; |
301 delete iMailFolderList; iMailFolderList = NULL; |
299 iMailFolderList = new NmApiFolderListing( this, iMailBoxes.at( iCurrentMailboxIndex++ ).id() ); |
302 iMailFolderList = new NmApiFolderListing( this, iMailBoxes.at( iCurrentMailboxIndex++ ).id() ); |
|
303 qDebug() << "\n QEmailFetcher::processing "<< iMailBoxes.at( iCurrentMailboxIndex-1 ).name()<< "Mailbox"; |
300 connect( iMailFolderList, SIGNAL(foldersListed( qint32 )), this, SLOT(handleMailFoldersListed( qint32)) ); |
304 connect( iMailFolderList, SIGNAL(foldersListed( qint32 )), this, SLOT(handleMailFoldersListed( qint32)) ); |
301 iMailFolderList->start(); |
305 iMailFolderList->start(); |
302 |
306 |
303 // const int waitForSeconds = 30; //TODO Move this constant out of here if needed elsewhere |
307 // const int waitForSeconds = 30; //TODO Move this constant out of here if needed elsewhere |
304 // QTimer::singleShot( waitForSeconds, iMailFolderList, SLOT( start()) ); |
308 // QTimer::singleShot( waitForSeconds, iMailFolderList, SLOT( start()) ); |
338 delete iEnvelopeListing; iEnvelopeListing = NULL; |
342 delete iEnvelopeListing; iEnvelopeListing = NULL; |
339 iEnvelopeListing= new NmApiEnvelopeListing( |
343 iEnvelopeListing= new NmApiEnvelopeListing( |
340 this, |
344 this, |
341 iFolders.at( iCurrentFolderIndex++ ).id(), |
345 iFolders.at( iCurrentFolderIndex++ ).id(), |
342 iMailBoxes.at( iCurrentMailboxIndex-1 ).id() ); //we have already incremented iMailboxIndex. |
346 iMailBoxes.at( iCurrentMailboxIndex-1 ).id() ); //we have already incremented iMailboxIndex. |
343 |
347 qDebug() << "\n QEmailFetcher::collecting mails from the "<< iFolders.at( iCurrentFolderIndex++ ).name() << "Folder \n"; |
344 connect(iEnvelopeListing, SIGNAL(envelopesListed(qint32)),this,SLOT(processMessages(qint32))); |
348 connect(iEnvelopeListing, SIGNAL(envelopesListed(qint32)),this,SLOT(processMessages(qint32))); |
345 iEnvelopeListing->start(); |
349 iEnvelopeListing->start(); |
346 qDebug() << "QEmailFetcher::processNextFolder :processNextFolder"; |
350 qDebug() << "QEmailFetcher::processNextFolder :processNextFolder"; |
347 } |
351 } |
348 |
352 |
368 |
372 |
369 //------------------------------------------------------------------------------ |
373 //------------------------------------------------------------------------------ |
370 void QEmailFetcher::handleMessageEvent( EmailClientApi::NmApiMessageEvent aEvent, quint64 aMailboxId, quint64 aFolderId, QList<quint64> aMessageList){ |
374 void QEmailFetcher::handleMessageEvent( EmailClientApi::NmApiMessageEvent aEvent, quint64 aMailboxId, quint64 aFolderId, QList<quint64> aMessageList){ |
371 NmApiMessageEnvelope envelope; |
375 NmApiMessageEnvelope envelope; |
372 qDebug() << "QEmailFetcher::handleMessageEvent :START"; |
376 qDebug() << "QEmailFetcher::handleMessageEvent :START"; |
|
377 qDebug() << "\n QEmailFetcher::aEvent="<< aEvent<<" MailboxId =" << aMailboxId << " FolderId = "<< aFolderId; |
373 const int messageCount = aMessageList.count(); |
378 const int messageCount = aMessageList.count(); |
|
379 qDebug() << "\n QEmailFetcher::message count="<< messageCount; |
374 if( messageCount>0 ){ |
380 if( messageCount>0 ){ |
375 if( aEvent == MessageCreated || aEvent == MessageChanged ){ |
381 if( aEvent == MessageCreated || aEvent == MessageChanged ){ |
376 qDebug() << "QEmailFetcher::handleMessageEvent :MessageCreated || MessageChanged"; |
382 qDebug() << "QEmailFetcher::handleMessageEvent :MessageCreated || MessageChanged"; |
377 for( int i=0; i<messageCount; i++ ){ |
383 for( int i=0; i<messageCount; i++ ){ |
|
384 qDebug() << "\n MessageId"<< aMessageList.at( i ); |
378 if( iEmailService->getEnvelope( aMailboxId, aFolderId, aMessageList.at( i ), envelope ) ){ |
385 if( iEmailService->getEnvelope( aMailboxId, aFolderId, aMessageList.at( i ), envelope ) ){ |
379 qDebug() << "QEmailFetcher::handleMessageEvent :HandleDocumentL"; |
386 qDebug() << "QEmailFetcher::handleMessageEvent :HandleDocumentL"; |
380 QT_TRAP_THROWING( |
387 QT_TRAP_THROWING( |
381 iEmailObserver.HandleDocumentL( getSearchDocumentL( envelope, aMailboxId, aFolderId ), |
388 iEmailObserver.HandleDocumentL( getSearchDocumentL( envelope, aMailboxId, aFolderId ), |
382 //Doing this simply avoids *duplicate* code for update action. |
389 //Doing this simply avoids *duplicate* code for update action. |
385 } |
392 } |
386 } |
393 } |
387 else if( aEvent == MessageDeleted ) { |
394 else if( aEvent == MessageDeleted ) { |
388 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted"; |
395 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted"; |
389 for( int i=0; i<messageCount; i++ ){ |
396 for( int i=0; i<messageCount; i++ ){ |
|
397 qDebug() << "\n MessageId"<< aMessageList.at( i ); |
390 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted : HandleDocumentL"; |
398 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted : HandleDocumentL"; |
391 QT_TRAP_THROWING( |
399 QT_TRAP_THROWING( |
392 iEmailObserver.HandleDocumentL( getPartialSearchDocument( aMessageList.at( i ) ), ECPixRemoveAction ) ); |
400 iEmailObserver.HandleDocumentL( getPartialSearchDocument( aMessageList.at( i ) ), ECPixRemoveAction ) ); |
393 } |
401 } |
394 } |
402 } |