kmail

annotationjobs.h

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 
00096 class GetAnnotationJob : public KIO::SimpleJob
00097 {
00098   Q_OBJECT
00099 public:
00100   GetAnnotationJob( const KURL& url, const QString& entry, const QByteArray &packedArgs,
00101                     bool showProgressInfo );
00102 
00103   const AnnotationList& annotations() const { return mAnnotations; }
00104 
00105 protected slots:
00106   void slotInfoMessage( KIO::Job*, const QString& );
00107 private:
00108   AnnotationList mAnnotations;
00109   QString mEntry;
00110 };
00111 
00113 class MultiGetAnnotationJob : public KIO::Job
00114 {
00115   Q_OBJECT
00116 
00117 public:
00118   MultiGetAnnotationJob( KIO::Slave* slave, const KURL& url, const QStringList& entries, bool showProgressInfo );
00119 
00120 signals:
00121   // Emitted when a given annotation was found - or not found
00122   void annotationResult( const QString& entry, const QString& value, bool found );
00123 
00124 protected slots:
00125   virtual void slotStart();
00126   virtual void slotResult( KIO::Job *job );
00127 
00128 private:
00129   KIO::Slave* mSlave;
00130   const KURL mUrl;
00131   const QStringList mEntryList;
00132   QStringList::const_iterator mEntryListIterator;
00133 };
00134 
00136 class MultiSetAnnotationJob : public KIO::Job
00137 {
00138   Q_OBJECT
00139 
00140 public:
00141   MultiSetAnnotationJob( KIO::Slave* slave, const KURL& url, const AnnotationList& annotations, bool showProgressInfo );
00142 
00143 signals:
00144   // Emitted when a given annotation was successfully changed
00145   void annotationChanged( const QString& entry, const QString& attribute, const QString& value );
00146 
00147 protected slots:
00148   virtual void slotStart();
00149   virtual void slotResult( KIO::Job *job );
00150 
00151 private:
00152   KIO::Slave* mSlave;
00153   const KURL mUrl;
00154   const AnnotationList mAnnotationList;
00155   AnnotationList::const_iterator mAnnotationListIterator;
00156 };
00157 
00158 } // AnnotationJobs namespace
00159 
00160 } // KMail namespace
00161 
00162 #endif /* ANNOTATIONJOBS_H */
00163 
KDE Home | KDE Accessibility Home | Description of Access Keys