kmail

annotationjobs.h

Go to the documentation of this file.
00001 /*
00002  * annotationjobs.h
00003  *
00004  * Copyright (c) 2004 David Faure <faure@kde.org>
00005  *
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; version 2 of the License
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, USA.
00019  *
00020  *  In addition, as a special exception, the copyright holders give
00021  *  permission to link the code of this program with any edition of
00022  *  the Qt library by Trolltech AS, Norway (or with modified versions
00023  *  of Qt that use the same license as Qt), and distribute linked
00024  *  combinations including the two.  You must obey the GNU General
00025  *  Public License in all respects for all of the code used other than
00026  *  Qt.  If you modify this file, you may extend this exception to
00027  *  your version of the file, but you are not obligated to do so.  If
00028  *  you do not wish to do so, delete this exception statement from
00029  *  your version.
00030  */
00031 
00032 #ifndef ANNOTATIONJOBS_H
00033 #define ANNOTATIONJOBS_H
00034 
00035 #include <kio/job.h>
00036 #include <qvaluevector.h>
00037 
00038 namespace KMail {
00039 
00041 struct AnnotationAttribute {
00042   AnnotationAttribute() {} // for QValueVector
00043   AnnotationAttribute( const QString& e, const QString& n, const QString& v )
00044     : entry( e ), name( n ), value( v ) {}
00045   QString entry; // e.g. /comment
00046   QString name;  // e.g. value.shared
00047   QString value;
00048 };
00049 
00050 typedef QValueVector<AnnotationAttribute> AnnotationList;
00051 
00059 namespace AnnotationJobs {
00060 
00068 KIO::SimpleJob* setAnnotation( KIO::Slave* slave, const KURL& url, const QString& entry,
00069                                const QMap<QString,QString>& attributes );
00070 
00071 class MultiSetAnnotationJob;
00075 MultiSetAnnotationJob* multiSetAnnotation( KIO::Slave* slave, const KURL& url, const AnnotationList& annotations );
00076 
00077 class GetAnnotationJob;
00085 GetAnnotationJob* getAnnotation( KIO::Slave* slave, const KURL& url, const QString& entry,
00086                                  const QStringList& attributes );
00087 
00088 class MultiGetAnnotationJob;
00093 MultiGetAnnotationJob* multiGetAnnotation( KIO::Slave* slave, const KURL& url, const QStringList& entries );
00094 
00095 class MultiUrlGetAnnotationJob;
00101 MultiUrlGetAnnotationJob* multiUrlGetAnnotation( KIO::Slave* slave,
00102                                               const KURL& baseUrl,
00103                                               const QStringList& paths,
00104                                               const QString& annotation );
00105 
00106 
00108 class GetAnnotationJob : public KIO::SimpleJob
00109 {
00110   Q_OBJECT
00111 public:
00112   GetAnnotationJob( const KURL& url, const QString& entry, const QByteArray &packedArgs,
00113                     bool showProgressInfo );
00114 
00115   const AnnotationList& annotations() const { return mAnnotations; }
00116 
00117 protected slots:
00118   void slotInfoMessage( KIO::Job*, const QString& );
00119 private:
00120   AnnotationList mAnnotations;
00121   QString mEntry;
00122 };
00123 
00125 class MultiGetAnnotationJob : public KIO::Job
00126 {
00127   Q_OBJECT
00128 
00129 public:
00130   MultiGetAnnotationJob( KIO::Slave* slave, const KURL& url, const QStringList& entries, bool showProgressInfo );
00131 
00132 signals:
00133   // Emitted when a given annotation was found - or not found
00134   void annotationResult( const QString& entry, const QString& value, bool found );
00135 
00136 protected slots:
00137   virtual void slotStart();
00138   virtual void slotResult( KIO::Job *job );
00139 
00140 private:
00141   KIO::Slave* mSlave;
00142   const KURL mUrl;
00143   const QStringList mEntryList;
00144   QStringList::const_iterator mEntryListIterator;
00145 };
00146 
00148 class MultiUrlGetAnnotationJob : public KIO::Job
00149 {
00150   Q_OBJECT
00151 
00152 public:
00153   MultiUrlGetAnnotationJob( KIO::Slave* slave, const KURL& baseUrl,
00154                             const QStringList& paths, const QString& annotation );
00155 
00156   QMap<QString, QString> annotations() const;
00157 
00158 protected slots:
00159   virtual void slotStart();
00160   virtual void slotResult( KIO::Job *job );
00161 
00162 private:
00163   KIO::Slave* mSlave;
00164   const KURL mUrl;
00165   const QStringList mPathList;
00166   QStringList::const_iterator mPathListIterator;
00167   QString mAnnotation;
00168   QMap<QString, QString> mAnnotations;
00169 };
00170 
00172 class MultiSetAnnotationJob : public KIO::Job
00173 {
00174   Q_OBJECT
00175 
00176 public:
00177   MultiSetAnnotationJob( KIO::Slave* slave, const KURL& url, const AnnotationList& annotations, bool showProgressInfo );
00178 
00179 signals:
00180   // Emitted when a given annotation was successfully changed
00181   void annotationChanged( const QString& entry, const QString& attribute, const QString& value );
00182 
00183 protected slots:
00184   virtual void slotStart();
00185   virtual void slotResult( KIO::Job *job );
00186 
00187 private:
00188   KIO::Slave* mSlave;
00189   const KURL mUrl;
00190   const AnnotationList mAnnotationList;
00191   AnnotationList::const_iterator mAnnotationListIterator;
00192 };
00193 
00194 } // AnnotationJobs namespace
00195 
00196 } // KMail namespace
00197 
00198 #endif /* ANNOTATIONJOBS_H */
00199