Logo Search packages:      
Sourcecode: akonadi version File versions  Download package

bool Select::handleLine ( const QByteArray &  line  )  [virtual]

Process one line of input.

Parameters:
line The input.
Returns:
false if the handler expects to read more data from the client, true otherwise.

Reimplemented from Akonadi::Handler.

Definition at line 44 of file select.cpp.

References Akonadi::HandlerHelper::collectionFromIdOrName(), Akonadi::Handler::failureResponse(), Akonadi::HandlerHelper::itemCount(), Akonadi::HandlerHelper::itemWithFlagCount(), Akonadi::HandlerHelper::itemWithoutFlagCount(), Akonadi::ImapParser::parseString(), Akonadi::Handler::responseAvailable(), Akonadi::AkonadiConnection::setSelectedCollection(), Akonadi::Response::setString(), Akonadi::Response::setSuccess(), Akonadi::Response::setTag(), Akonadi::Response::setUntagged(), and Akonadi::Handler::tag().

{
    // as per rfc, even if the following select fails, we need to reset
    connection()->setSelectedCollection( 0 );

    int pos = line.indexOf( ' ' ) + 1; // skip tag
    QByteArray buffer;

    // command
    pos = ImapParser::parseString( line, buffer, pos );
    pos = ImapParser::parseString( line, buffer, pos );
    bool silent = false;
    if ( buffer == "SILENT" ) {
      silent = true;
      pos = ImapParser::parseString( line, buffer, pos );
    }

    // collection
    Location l = HandlerHelper::collectionFromIdOrName( buffer );
    if ( !l.isValid() ) {
      bool ok = false;
      if ( buffer.toLongLong( &ok ) == 0 && ok )
        silent = true;
      else
        return failureResponse( "Cannot select this collection" );
    }

    // Responses:  REQUIRED untagged responses: FLAGS, EXISTS, RECENT
    // OPTIONAL OK untagged responses: UNSEEN, PERMANENTFLAGS
    Response response;
    if ( !silent ) {
      response.setUntagged();
      response.setString( Flag::joinByName<Flag>( Flag::retrieveAll(), QLatin1String(" ") ) );
      emit responseAvailable( response );

      int count = HandlerHelper::itemCount( l );
      if ( count < 0 )
        return failureResponse( "Unable to determine item count" );
      response.setString( QByteArray::number( count ) + " EXISTS" );
      emit responseAvailable( response );

      count = HandlerHelper::itemWithFlagCount( l, QLatin1String( "\\Recent" ) );
      if ( count < 0 )
        return failureResponse( "Unable to determine recent count" );
      response.setString( QByteArray::number( count ) + " RECENT" );
      emit responseAvailable( response );

      count = HandlerHelper::itemWithoutFlagCount( l, QLatin1String( "\\Seen" ) );
      if ( count < 0 )
        return failureResponse( "Unable to retrieve unseen count" );
      response.setString( "OK [UNSEEN " + QByteArray::number( count ) + "] Message 0 is first unseen" );
      emit responseAvailable( response );

      response.setString( "OK [UIDVALIDITY 1] UIDs valid" );
      emit responseAvailable( response );
    }

    response.setSuccess();
    response.setTag( tag() );
    response.setString( "Completed" );
    emit responseAvailable( response );

    connection()->setSelectedCollection( l.id() );
    deleteLater();
    return true;
}


Generated by  Doxygen 1.6.0   Back to index