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

bool AkList::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 41 of file aklist.cpp.

References Akonadi::Handler::failureResponse(), Akonadi::ImapParser::parseNumber(), Akonadi::ImapParser::parseParenthesizedList(), Akonadi::ImapParser::parseString(), Akonadi::Handler::responseAvailable(), Akonadi::Response::setString(), Akonadi::Response::setSuccess(), Akonadi::Response::setTag(), and Akonadi::Handler::tag().

{
  // parse out the reference name and mailbox name
  int pos = line.indexOf( ' ' ) + 1; // skip tag
  QByteArray tmp;

  // command
  pos = ImapParser::parseString( line, tmp, pos );
  if ( tmp == "X-AKLSUB" )
    mOnlySubscribed = true;

  qint64 baseCollection;
  bool ok = false;
  pos = ImapParser::parseNumber( line, baseCollection, &ok, pos );
  if ( !ok )
    return failureResponse( "Invalid base collection" );

  int depth;
  pos = ImapParser::parseString( line, tmp, pos );
  if ( tmp.isEmpty() )
    return failureResponse( "Specify listing depth" );
  if ( tmp == "INF" )
    depth = INT_MAX;
  else
    depth = tmp.toInt();

  QList<QByteArray> filter;
  pos = ImapParser::parseParenthesizedList( line, filter, pos );

  for ( int i = 0; i < filter.count() - 1; i += 2 ) {
    if ( filter.at( i ) == "RESOURCE" ) {
      mResource = Resource::retrieveByName( QString::fromLatin1( filter.at(i + 1) ) );
      if ( !mResource.isValid() )
        return failureResponse( "Unknown resource" );
    } else
      return failureResponse( "Invalid filter parameter" );
  }

  Location::List locations;
  if ( baseCollection != 0 ) { // not root
    Location loc = Location::retrieveById( baseCollection );
    if ( !loc.isValid() )
      return failureResponse( "Collection " + QByteArray::number( baseCollection ) + " does not exist" );
    if ( depth == 0 )
      locations << loc;
    else {
      locations << loc.children();
      --depth;
    }
  } else {
    if ( depth != 0 ) {
      Location::List list = Location::retrieveFiltered( Location::parentIdColumn(), 0 );
      locations << list;
    }
    --depth;
  }

  foreach ( const Location &loc, locations )
    listCollection( loc, depth );

  Response 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