emailservices/nmailagent/src/nmmailagent.cpp
changeset 40 2c62ef3caffd
parent 23 2dc6caa42ec3
child 30 759dc5235cdb
equal deleted inserted replaced
39:b0b89ca206b5 40:2c62ef3caffd
    93 
    93 
    94 			connect(plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
    94 			connect(plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
    95 				this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
    95 				this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
    96 				Qt::UniqueConnection);
    96 				Qt::UniqueConnection);
    97 
    97 
    98 			connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId)),
    98 			connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId, int)),
    99 				this, SLOT(handleConnectionEvent(NmConnectState, const NmId)),
    99 				this, SLOT(handleConnectionEvent(NmConnectState, const NmId, int)),
   100 				Qt::UniqueConnection);
   100 				Qt::UniqueConnection);
   101     	}
   101     	}
   102     }
   102     }
   103 
   103 
   104     // load all current mailboxes
   104     // load all current mailboxes
   436 
   436 
   437             // When created a new mail in the outbox, we are in sending state
   437             // When created a new mail in the outbox, we are in sending state
   438             if (mailboxInfo->mOutboxFolderId == folderId) {
   438             if (mailboxInfo->mOutboxFolderId == folderId) {
   439                 // The first mail created in the outbox
   439                 // The first mail created in the outbox
   440                 if (mailboxInfo->mOutboxMails <= 0) {
   440                 if (mailboxInfo->mOutboxMails <= 0) {
       
   441 					NMLOG("NmMailAgent: first mail in outbox");
       
   442 					activate = true;
   441                     updateNeeded = true;
   443                     updateNeeded = true;
   442                 }
   444                 }
   443                 mailboxInfo->mOutboxMails += messageIds.count();
   445                 mailboxInfo->mOutboxMails += messageIds.count();
   444             }
   446             }
   445             break;
   447             break;
   481                     mailboxInfo->mOutboxMails = 0;
   483                     mailboxInfo->mOutboxMails = 0;
   482                 }
   484                 }
   483 
   485 
   484                 // The last mail was now deleted
   486                 // The last mail was now deleted
   485                 if (mailboxInfo->mOutboxMails == 0) {
   487                 if (mailboxInfo->mOutboxMails == 0) {
       
   488 					NMLOG("NmMailAgent: last mail deleted from outbox");
       
   489 
   486                     // Keep it active if there is unread mails
   490                     // Keep it active if there is unread mails
   487                     activate = mailboxInfo->mUnreadMailIdList.count() > 0;
   491                     activate = mailboxInfo->mUnreadMailIdList.count() > 0;
   488                     updateNeeded = true;
   492                     updateNeeded = true;
   489                 }
   493                 }
   490             }
   494             }
   548 
   552 
   549 /*!
   553 /*!
   550     Received from NmFrameworkAdapter connectionState signal
   554     Received from NmFrameworkAdapter connectionState signal
   551     \sa NmFrameworkAdapter
   555     \sa NmFrameworkAdapter
   552 */
   556 */
   553 void NmMailAgent::handleConnectionEvent(NmConnectState state, const NmId mailboxId)
   557 void NmMailAgent::handleConnectionEvent(NmConnectState state, const NmId mailboxId, int errorcode)
   554 {
   558 {
   555     NMLOG(QString("NmMailAgent::handleConnectionEvent %1 %2").arg(state).arg(mailboxId.id()));
   559 	Q_UNUSED(errorcode);
       
   560     NMLOG(QString("NmMailAgent::handleConnectionEvent %1 %2 %3").arg(state).arg(mailboxId.id()).arg(errorcode));
   556     NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
   561     NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
   557     if (mailboxInfo) {
   562     if (mailboxInfo) {
   558         // Connecting, Connected, Disconnecting, Disconnected
   563         // Connecting, Connected, Disconnecting, Disconnected
   559         mailboxInfo->mConnectState = state;
   564         mailboxInfo->mConnectState = state;
   560     }
   565     }
   625         mailbox.id(), NmFolderOutbox );
   630         mailbox.id(), NmFolderOutbox );
   626 
   631 
   627     // Get branded mailbox icon
   632     // Get branded mailbox icon
   628     NmMailbox mailbox2( mailbox );
   633     NmMailbox mailbox2( mailbox );
   629     QString domainName = mailbox2.address().address();
   634     QString domainName = mailbox2.address().address();
   630     int delimIndex = domainName.indexOf('@');
       
   631     if( delimIndex >= 0 ) {
       
   632         domainName = domainName.mid(delimIndex+1);
       
   633         NMLOG(QString("Mailbox domain name: %1").arg(domainName));
       
   634     }
       
   635     EmailMailboxInfo emailMailboxInfo;
   635     EmailMailboxInfo emailMailboxInfo;
   636     mailboxInfo->mIconName =
   636     mailboxInfo->mIconName =
   637         emailMailboxInfo.mailboxIcon(domainName);
   637         emailMailboxInfo.mailboxIcon(domainName);
   638     
   638 
   639     return mailboxInfo;
   639     return mailboxInfo;
   640 }
   640 }
   641 
   641 
   642 /*!
   642 /*!
   643     Return mailbox info class with mailbox id. If no class is found, create a new instance with given id.
   643     Return mailbox info class with mailbox id. If no class is found, create a new instance with given id.