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

bool List::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 list.cpp.

References Akonadi::Handler::failureResponse(), Akonadi::ImapParser::parseString(), Akonadi::HandlerHelper::pathForCollection(), Akonadi::Handler::responseAvailable(), Akonadi::Response::setString(), Akonadi::Response::setSuccess(), Akonadi::Response::setTag(), Akonadi::Response::setUntagged(), and Akonadi::Handler::tag().

{
    // parse out the reference name and mailbox name
    int pos = line.indexOf( ' ' ) + 1; // skip tag
    pos = line.indexOf( ' ', pos ) + 1; // skip command
    QString reference;
    pos = ImapParser::parseString( line, reference, pos );
    QString mailbox;
    ImapParser::parseString( line, mailbox, pos );

//     qDebug() << "reference:" << reference << "mailbox:" << mailbox << "::" << endl;

    Response response;
    response.setUntagged();

    if ( mailbox.isEmpty() ) { // special case of asking for the delimiter
        response.setString( "LIST (\\Noselect) \"/\" \"\"" );
        emit responseAvailable( response );
    } else {
        QList<Location> collections;
        if ( !listCollections( reference, mailbox, collections ) ) {
          return failureResponse( "Unable to find collection" );
        }

        foreach ( const Location &loc, collections ) {
            QByteArray list( "LIST ");
            list += '(';
            bool first = true;
            QList<MimeType> supportedMimeTypes = loc.mimeTypes();
            if ( supportedMimeTypes.isEmpty() ) {
                list += "\\Noinferiors";
                first = false;
            }
            bool canContainFolders = false;
            foreach ( const MimeType &mt, supportedMimeTypes ) {
              if ( mt.name() == QLatin1String("inode/directory") ) {
                canContainFolders = true;
                break;
              }
            }
            if ( canContainFolders ) {
                if ( !first ) list += ' ';
                list += "\\Noselect";
                first = false;
            }
            if ( !supportedMimeTypes.isEmpty() ) {
                if ( !first ) list += ' ';
                list += "\\MimeTypes[" + MimeType::joinByName( supportedMimeTypes, QLatin1String(",") ).toLatin1() + ']';
            }
            list += ") ";
            list += "\"/\" \""; // FIXME delimiter
            if ( loc.isValid() )
              list += HandlerHelper::pathForCollection( loc ).toUtf8();
            else
              list += loc.name(); // search folder
            list += "\"";
            response.setString( list );
            emit responseAvailable( response );
        }
    }

    response.setSuccess();
    response.setTag( tag() );
    response.setString( "List completed" );
    emit responseAvailable( response );
    deleteLater();
    return true;
}


Generated by  Doxygen 1.6.0   Back to index