harvesterplugins/messaging/email/qtemailfetcher/qtemailfetcher.cpp
changeset 19 08315a312857
parent 18 1edf350003c5
child 22 2ef216e92ef2
equal deleted inserted replaced
18:1edf350003c5 19:08315a312857
   298         return;
   298         return;
   299     }
   299     }
   300     //More mailboxes available.
   300     //More mailboxes available.
   301     delete iMailFolderList; iMailFolderList = NULL;
   301     delete iMailFolderList; iMailFolderList = NULL;
   302     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";
   303     connect( iMailFolderList, SIGNAL(foldersListed( qint32 )), this, SLOT(handleMailFoldersListed( qint32)) );
   304     connect( iMailFolderList, SIGNAL(foldersListed( qint32 )), this, SLOT(handleMailFoldersListed( qint32)) );
   304     iMailFolderList->start();
   305     iMailFolderList->start();
   305    
   306    
   306 //    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
   307 //    QTimer::singleShot( waitForSeconds, iMailFolderList, SLOT( start()) );
   308 //    QTimer::singleShot( waitForSeconds, iMailFolderList, SLOT( start()) );
   341     delete iEnvelopeListing; iEnvelopeListing = NULL; 
   342     delete iEnvelopeListing; iEnvelopeListing = NULL; 
   342     iEnvelopeListing= new NmApiEnvelopeListing( 
   343     iEnvelopeListing= new NmApiEnvelopeListing( 
   343             this, 
   344             this, 
   344             iFolders.at( iCurrentFolderIndex++ ).id(),
   345             iFolders.at( iCurrentFolderIndex++ ).id(),
   345             iMailBoxes.at( iCurrentMailboxIndex-1 ).id() ); //we have already incremented iMailboxIndex.
   346             iMailBoxes.at( iCurrentMailboxIndex-1 ).id() ); //we have already incremented iMailboxIndex.
   346 
   347     qDebug() << "\n QEmailFetcher::collecting mails from the "<< iFolders.at( iCurrentFolderIndex++ ).name() << "Folder \n";
   347     connect(iEnvelopeListing, SIGNAL(envelopesListed(qint32)),this,SLOT(processMessages(qint32)));
   348     connect(iEnvelopeListing, SIGNAL(envelopesListed(qint32)),this,SLOT(processMessages(qint32)));
   348     iEnvelopeListing->start();
   349     iEnvelopeListing->start();
   349     qDebug() << "QEmailFetcher::processNextFolder :processNextFolder";
   350     qDebug() << "QEmailFetcher::processNextFolder :processNextFolder";
   350 }
   351 }
   351 
   352 
   371 
   372 
   372 //------------------------------------------------------------------------------
   373 //------------------------------------------------------------------------------
   373 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){
   374     NmApiMessageEnvelope envelope;
   375     NmApiMessageEnvelope envelope;
   375     qDebug() << "QEmailFetcher::handleMessageEvent :START";
   376     qDebug() << "QEmailFetcher::handleMessageEvent :START";
       
   377     qDebug() << "\n QEmailFetcher::aEvent="<< aEvent<<" MailboxId =" << aMailboxId << " FolderId = "<< aFolderId;
   376     const int messageCount = aMessageList.count();
   378     const int messageCount = aMessageList.count();
       
   379     qDebug() << "\n QEmailFetcher::message count="<< messageCount;
   377     if( messageCount>0 ){
   380     if( messageCount>0 ){
   378     if( aEvent == MessageCreated || aEvent == MessageChanged ){
   381     if( aEvent == MessageCreated || aEvent == MessageChanged ){
   379         qDebug() << "QEmailFetcher::handleMessageEvent :MessageCreated || MessageChanged";
   382         qDebug() << "QEmailFetcher::handleMessageEvent :MessageCreated || MessageChanged";
   380         for( int i=0; i<messageCount; i++ ){
   383         for( int i=0; i<messageCount; i++ ){
       
   384             qDebug() << "\n MessageId"<< aMessageList.at( i );
   381             if( iEmailService->getEnvelope( aMailboxId, aFolderId, aMessageList.at( i ), envelope ) ){
   385             if( iEmailService->getEnvelope( aMailboxId, aFolderId, aMessageList.at( i ), envelope ) ){
   382                qDebug() << "QEmailFetcher::handleMessageEvent :HandleDocumentL";
   386                qDebug() << "QEmailFetcher::handleMessageEvent :HandleDocumentL";
   383                 QT_TRAP_THROWING( 
   387                 QT_TRAP_THROWING( 
   384                    iEmailObserver.HandleDocumentL( getSearchDocumentL( envelope, aMailboxId, aFolderId ), 
   388                    iEmailObserver.HandleDocumentL( getSearchDocumentL( envelope, aMailboxId, aFolderId ), 
   385                            //Doing this simply avoids *duplicate* code for update action.
   389                            //Doing this simply avoids *duplicate* code for update action.
   388         }
   392         }
   389     }
   393     }
   390     else if( aEvent == MessageDeleted ) {
   394     else if( aEvent == MessageDeleted ) {
   391         qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted";
   395         qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted";
   392         for( int i=0; i<messageCount; i++ ){
   396         for( int i=0; i<messageCount; i++ ){
       
   397                 qDebug() << "\n MessageId"<< aMessageList.at( i );
   393                 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted : HandleDocumentL";
   398                 qDebug() << "QEmailFetcher::handleMessageEvent :MessageDeleted : HandleDocumentL";
   394                 QT_TRAP_THROWING( 
   399                 QT_TRAP_THROWING( 
   395                 iEmailObserver.HandleDocumentL( getPartialSearchDocument( aMessageList.at( i ) ), ECPixRemoveAction ) );
   400                 iEmailObserver.HandleDocumentL( getPartialSearchDocument( aMessageList.at( i ) ), ECPixRemoveAction ) );
   396             }
   401             }
   397         }
   402         }