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 TQt library by Trolltech AS, Norway (or with modified versions
00023  *  of TQt that use the same license as TQt), 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  *  TQt.  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 <tdeio/job.h>
00036 #include <tqvaluevector.h>
00037 
00038 namespace KMail {
00039 
00041 struct AnnotationAttribute {
00042   AnnotationAttribute() {} // for TQValueVector
00043   AnnotationAttribute( const TQString& e, const TQString& n, const TQString& v )
00044     : entry( e ), name( n ), value( v ) {}
00045   TQString entry; // e.g. /comment
00046   TQString name;  // e.g. value.shared
00047   TQString value;
00048 };
00049 
00050 typedef TQValueVector<AnnotationAttribute> AnnotationList;
00051 
00059 namespace AnnotationJobs {
00060 
00068 TDEIO::SimpleJob* setAnnotation( TDEIO::Slave* slave, const KURL& url, const TQString& entry,
00069                                const TQMap<TQString,TQString>& attributes );
00070 
00071 class MultiSetAnnotationJob;
00075 MultiSetAnnotationJob* multiSetAnnotation( TDEIO::Slave* slave, const KURL& url, const AnnotationList& annotations );
00076 
00077 class GetAnnotationJob;
00085 GetAnnotationJob* getAnnotation( TDEIO::Slave* slave, const KURL& url, const TQString& entry,
00086                                  const TQStringList& attributes );
00087 
00088 class MultiGetAnnotationJob;
00093 MultiGetAnnotationJob* multiGetAnnotation( TDEIO::Slave* slave, const KURL& url, const TQStringList& entries );
00094 
00095 class MultiUrlGetAnnotationJob;
00101 MultiUrlGetAnnotationJob* multiUrlGetAnnotation( TDEIO::Slave* slave,
00102                                               const KURL& baseUrl,
00103                                               const TQStringList& paths,
00104                                               const TQString& annotation );
00105 
00106 
00108 class GetAnnotationJob : public TDEIO::SimpleJob
00109 {
00110   Q_OBJECT
00111   
00112 public:
00113   GetAnnotationJob( const KURL& url, const TQString& entry, const TQByteArray &packedArgs,
00114                     bool showProgressInfo );
00115 
00116   const AnnotationList& annotations() const { return mAnnotations; }
00117 
00118 protected slots:
00119   void slotInfoMessage( TDEIO::Job*, const TQString& );
00120 private:
00121   AnnotationList mAnnotations;
00122   TQString mEntry;
00123 };
00124 
00126 class MultiGetAnnotationJob : public TDEIO::Job
00127 {
00128   Q_OBJECT
00129   
00130 
00131 public:
00132   MultiGetAnnotationJob( TDEIO::Slave* slave, const KURL& url, const TQStringList& entries, bool showProgressInfo );
00133 
00134 signals:
00135   // Emitted when a given annotation was found - or not found
00136   void annotationResult( const TQString& entry, const TQString& value, bool found );
00137 
00138 protected slots:
00139   virtual void slotStart();
00140   virtual void slotResult( TDEIO::Job *job );
00141 
00142 private:
00143   TDEIO::Slave* mSlave;
00144   const KURL mUrl;
00145   const TQStringList mEntryList;
00146   TQStringList::const_iterator mEntryListIterator;
00147 };
00148 
00150 class MultiUrlGetAnnotationJob : public TDEIO::Job
00151 {
00152   Q_OBJECT
00153   
00154 
00155 public:
00156   MultiUrlGetAnnotationJob( TDEIO::Slave* slave, const KURL& baseUrl,
00157                             const TQStringList& paths, const TQString& annotation );
00158 
00159   TQMap<TQString, TQString> annotations() const;
00160 
00161 protected slots:
00162   virtual void slotStart();
00163   virtual void slotResult( TDEIO::Job *job );
00164 
00165 private:
00166   TDEIO::Slave* mSlave;
00167   const KURL mUrl;
00168   const TQStringList mPathList;
00169   TQStringList::const_iterator mPathListIterator;
00170   TQString mAnnotation;
00171   TQMap<TQString, TQString> mAnnotations;
00172 };
00173 
00175 class MultiSetAnnotationJob : public TDEIO::Job
00176 {
00177   Q_OBJECT
00178   
00179 
00180 public:
00181   MultiSetAnnotationJob( TDEIO::Slave* slave, const KURL& url, const AnnotationList& annotations, bool showProgressInfo );
00182 
00183 signals:
00184   // Emitted when a given annotation was successfully changed
00185   void annotationChanged( const TQString& entry, const TQString& attribute, const TQString& value );
00186 
00187 protected slots:
00188   virtual void slotStart();
00189   virtual void slotResult( TDEIO::Job *job );
00190 
00191 private:
00192   TDEIO::Slave* mSlave;
00193   const KURL mUrl;
00194   const AnnotationList mAnnotationList;
00195   AnnotationList::const_iterator mAnnotationListIterator;
00196 };
00197 
00198 } // AnnotationJobs namespace
00199 
00200 } // KMail namespace
00201 
00202 #endif /* ANNOTATIONJOBS_H */
00203