void KMSearch::stop()
{
  if ( !running() ) {
    return;
  }

  mIncompleteFolders.clear();
  QList<QPointer<KMFolder> >::ConstIterator jt;
  for ( jt = mOpenedFolders.constBegin(); jt != mOpenedFolders.constEnd(); ++jt ) {
    KMFolder *folder = *jt;
    if ( !folder ) {
      continue;
    }
    // explicitly stop jobs for this folder as it will not be closed below
    // when the folder is currently selected
    if ( folder->folderType() == KMFolderTypeImap ) {
      KMAcctImap *account =
        static_cast<KMFolderImap*>( folder->storage() )->account();
      account->ignoreJobsForFolder( folder );
    }
    folder->storage()->search( 0 );
    mSearchCount += folder->count();
    folder->close( "kmsearch" );
  }
  mRemainingFolders = -1;
  mOpenedFolders.clear();
  mFolders.clear();
  mLastFolder.clear();
  mRunning = false;
  emit finished(false);
}
Exemple #2
0
/**
 * Refreshes the list of folders we are monitoring.  This is called on
 * startup and is also connected to the 'changed' signal on the KMFolderMgr.
 */
void KMSystemTray::foldersChanged()
{
  /**
   * Hide and remove all unread mappings to cover the case where the only
   * unread message was in a folder that was just removed.
   */
  mFoldersWithUnread.clear();
  mCount = 0;

  if ( mMode == GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread ) {
    hide();
  }

  /** Disconnect all previous connections */
  disconnect(this, SLOT(updateNewMessageNotification(KMFolder *)));

  QStringList folderNames;
  QValueList<QGuardedPtr<KMFolder> > folderList;
  kmkernel->folderMgr()->createFolderList(&folderNames, &folderList);
  kmkernel->imapFolderMgr()->createFolderList(&folderNames, &folderList);
  kmkernel->dimapFolderMgr()->createFolderList(&folderNames, &folderList);
  kmkernel->searchFolderMgr()->createFolderList(&folderNames, &folderList);

  QStringList::iterator strIt = folderNames.begin();

  for(QValueList<QGuardedPtr<KMFolder> >::iterator it = folderList.begin();
     it != folderList.end() && strIt != folderNames.end(); ++it, ++strIt)
  {
    KMFolder * currentFolder = *it;
    QString currentName = *strIt;

    if ( ((!currentFolder->isSystemFolder() || (currentFolder->name().lower() == "inbox")) ||
         (currentFolder->folderType() == KMFolderTypeImap)) &&
         !currentFolder->ignoreNewMail() )
    {
      /** If this is a new folder, start listening for messages */
      connect(currentFolder, SIGNAL(numUnreadMsgsChanged(KMFolder *)),
              this, SLOT(updateNewMessageNotification(KMFolder *)));

      /** Check all new folders to see if we started with any new messages */
      updateNewMessageNotification(currentFolder);
    }
  }