• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

akonadi/clients

listcommand.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Akonadi.
00003 
00004     Copyright (c) 2006 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019     USA.
00020 */
00021 
00022 #include "listcommand.h"
00023 
00024 #include "out.h"
00025 
00026 #include <akonadi/collectionfetchjob.h>
00027 #include <akonadi/private/collectionpathresolver_p.h>
00028 #include <akonadi/itemfetchjob.h>
00029 
00030 using namespace Akonadi;
00031 
00032 ListCommand::ListCommand( const QString &path )
00033   : mPath( path )
00034 {
00035   if ( mPath.isEmpty() ) mPath = "/";
00036 }
00037 
00038 void ListCommand::exec()
00039 {
00040   CollectionPathResolver *resolver = new CollectionPathResolver( mPath );
00041   if ( !resolver->exec() ) {
00042     err() << "Error resolving path '" << mPath << "': " << resolver->errorString() << endl;
00043     return;
00044   }
00045   Collection::Id currentColId = resolver->collection();
00046 
00047   CollectionFetchJob* collectionJob = new CollectionFetchJob( Collection( currentColId ) );
00048   if ( !collectionJob->exec() ) {
00049     err() << "Error listing collection '" << mPath << "': "
00050       << collectionJob->errorString()
00051       << endl;
00052     return;
00053   } else {
00054     foreach( const Akonadi::Collection &collection, collectionJob->collections() ) {
00055       out() << collection.name() << endl;
00056     }
00057   }
00058 
00059   ItemFetchJob* itemFetchJob = new ItemFetchJob( Collection( currentColId ) );
00060   if ( !itemFetchJob->exec() ) {
00061     err() << "Error listing items at '" << mPath << "': "
00062       << itemFetchJob->errorString()
00063       << endl;
00064   } else {
00065     foreach( const Akonadi::Item &item, itemFetchJob->items() ) {
00066       QString str;
00067       str = QLatin1String("Item: ") + QString::number( item.id() );
00068       if ( !item.remoteId().isEmpty() ) {
00069         str += QLatin1String(" [") + item.remoteId() + QLatin1Char(']');
00070       }
00071       if ( !item.flags().isEmpty() ) {
00072         str += QLatin1String(" ( ");
00073         foreach( const QByteArray &flag, item.flags() ) {
00074           str += flag + QLatin1Char(' ');
00075         }
00076         str += QLatin1Char(')');
00077       }
00078       str += QLatin1String(" [") + item.mimeType() + QLatin1Char(']');
00079       out() << str << endl;
00080     }
00081   }
00082 }

akonadi/clients

Skip menu "akonadi/clients"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal