Beispiel #1
0
//-----------------------------------------------------------------------------
KMFolder* KMFolderDir::createFolder(const QString& aFolderName, bool aSysFldr, KMFolderType aFolderType)
{
  KMFolder* fld;

  assert(!aFolderName.isEmpty());
  // FIXME urgs, is this still needed
  if (mDirType == KMImapDir)
    fld = new KMFolder( this, aFolderName, KMFolderTypeImap );
  else
    fld = new KMFolder( this, aFolderName, aFolderType );

  assert(fld != 0);
  fld->setSystemFolder(aSysFldr);

  KMFolderNode* fNode;
  int index = 0;
  for (fNode=first(); fNode; fNode=next()) {
    if (fNode->name().lower() > fld->name().lower()) {
      insert( index, fld );
      break;
    }
    ++index;
  }

  if (!fNode)
    append(fld);

  fld->correctUnreadMsgsCount();
  return fld;
}
void KMSearch::start()
{
  //close all referenced folders
  QList<QPointer<KMFolder> >::Iterator fit;
  for ( fit = mOpenedFolders.begin(); fit != mOpenedFolders.end(); ++fit ) {
    if ( !(*fit) ) {
      continue;
    }
    (*fit)->close( "kmsearch" );
  }
  mOpenedFolders.clear();
  mFolders.clear();

  if ( running() ) {
    return;
  }

  if ( !mSearchPattern ) {
    emit finished( true );
    return;
  }

  mFoundCount = 0;
  mSearchCount = 0;
  mRunning = true;

  mFolders.append( mRoot );
  if ( recursive() ) {
    //Append all descendants to folders
    KMFolder *folder;
    for ( int i = 0; i < mFolders.size(); i++ ) {
      folder = mFolders[i];
      KMFolderDir *dir = 0;
      if ( folder ) {
        dir = folder->child();
      } else {
        dir = &kmkernel->folderMgr()->dir();
      }
      if ( !dir ) {
        continue;
      }

      QListIterator<KMFolderNode*> it( *dir );
      while ( it.hasNext() ) {
        KMFolderNode *node = it.next();
        if ( !node->isDir() ) {
          KMFolder* kmf = dynamic_cast<KMFolder*>( node );
          if ( kmf ) {
            mFolders.append( kmf );
          }
        }
      }
    }
  }

  mRemainingFolders = mFolders.count();
  mLastFolder.clear();
  mProcessNextBatchTimer->start( 0 );
}
Beispiel #3
0
//-----------------------------------------------------------------------------
KMFolderNode* KMFolderDir::hasNamedFolder(const QString& aName)
{
  KMFolderNode* fNode;
  for (fNode=first(); fNode; fNode=next()) {
    if (fNode->name() == aName)
      return fNode;
  }
  return 0;
}
void CopyFolderJob::slotCopyNextChild( bool success )
{
  if ( mNextChildFolder )
    mNextChildFolder->close( "copyfolder" ); // refcount
  // previous sibling failed
  if ( !success ) {
    kDebug() << "Failed to copy one subfolder, let's not continue:" << mNewFolder->prettyUrl();
    rollback();
    emit folderCopyComplete( false );
    deleteLater();
  }

  //Attempt to find the next child folder which is not a directory
  KMFolderNode* node = 0;
  bool folderFound = false;
  if ( mHasChildFolders )
    for ( ; mChildFolderNodeIterator != mStorage->folder()->child()->end();
          ++mChildFolderNodeIterator ) {
      node = *mChildFolderNodeIterator;
      if ( !node->isDir() ) {
        folderFound = true;
        break;
      }
    }

  if ( folderFound ) {
    mNextChildFolder = static_cast<KMFolder*>(node);
    ++mChildFolderNodeIterator;
  } else {
    // no more children, we are done
    emit folderCopyComplete( true );
    deleteLater();
    return;
  }

  KMFolderDir * const dir = mNewFolder->createChildFolder();
  if ( !dir ) {
    kDebug() << "Failed to create subfolders of:" << mNewFolder->prettyUrl();
    emit folderCopyComplete( false );
    deleteLater();
    return;
  }
  // let it do its thing and report back when we are ready to do the next sibling
  mNextChildFolder->open( "copyfolder" ); // refcount
  FolderJob* job = new CopyFolderJob( mNextChildFolder->storage(), dir);
  connect( job, SIGNAL( folderCopyComplete( bool ) ),
           this, SLOT( slotCopyNextChild( bool ) ) );
  job->start();
}
QString KMFolder::idString() const
{
  KMFolderNode* folderNode = parent();
  if (!folderNode)
    return "";
  while ( folderNode->parent() )
    folderNode = folderNode->parent();
  QString myPath = path();
  int pathLen = myPath.length() - folderNode->path().length();
  QString relativePath = myPath.right( pathLen );
  if (!relativePath.isEmpty())
    relativePath = relativePath.right( relativePath.length() - 1 ) + '/';
  QString escapedName = name();
  /* Escape [ and ] as they are disallowed for kconfig sections and that is
     what the idString is primarily used for. */
  escapedName.replace( '[', "%(" );
  escapedName.replace( ']', "%)" );
  return relativePath + escapedName;
}
Beispiel #6
0
KMFolder* Utils::findStandardResourceFolder( KMFolderDir* folderParentDir,
                                             KMail::FolderContentsType contentsType,
                                             const QStringList &attributes )
{
  QMap<int, QString> typeMap;
  typeMap.insert( KMail::ContentsTypeCalendar, "IPF.Appointment" );
  typeMap.insert( KMail::ContentsTypeContact, "IPF.Contact" );
  typeMap.insert( KMail::ContentsTypeNote, "IPF.StickyNote" );
  typeMap.insert( KMail::ContentsTypeTask, "IPF.Task" );

  if ( !typeMap.contains( contentsType ) )
    return 0;

  for ( uint i = 0; i < attributes.count(); ++i ) {
    FolderAttributeParser parser( attributes[ i ] );
    if ( parser.folderClass() == typeMap[ contentsType ] ) {
      KMFolderNode* node = folderParentDir->hasNamedFolder( parser.folderName() );
      if ( node && !node->isDir() )
        return static_cast<KMFolder*>( node );
    }
  }

  return 0;
}