kmail

annotationjobs.h
1 /*
2  * annotationjobs.h
3  *
4  * Copyright (c) 2004 David Faure <faure@kde.org>
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give
21  * permission to link the code of this program with any edition of
22  * the TQt library by Trolltech AS, Norway (or with modified versions
23  * of TQt that use the same license as TQt), and distribute linked
24  * combinations including the two. You must obey the GNU General
25  * Public License in all respects for all of the code used other than
26  * TQt. If you modify this file, you may extend this exception to
27  * your version of the file, but you are not obligated to do so. If
28  * you do not wish to do so, delete this exception statement from
29  * your version.
30  */
31 
32 #ifndef ANNOTATIONJOBS_H
33 #define ANNOTATIONJOBS_H
34 
35 #include <tdeio/job.h>
36 #include <tqvaluevector.h>
37 
38 namespace KMail {
39 
42  AnnotationAttribute() {} // for TQValueVector
43  AnnotationAttribute( const TQString& e, const TQString& n, const TQString& v )
44  : entry( e ), name( n ), value( v ) {}
45  TQString entry; // e.g. /comment
46  TQString name; // e.g. value.shared
47  TQString value;
48 };
49 
50 typedef TQValueVector<AnnotationAttribute> AnnotationList;
51 
59 namespace AnnotationJobs {
60 
68 TDEIO::SimpleJob* setAnnotation( TDEIO::Slave* slave, const KURL& url, const TQString& entry,
69  const TQMap<TQString,TQString>& attributes );
70 
75 MultiSetAnnotationJob* multiSetAnnotation( TDEIO::Slave* slave, const KURL& url, const AnnotationList& annotations );
76 
77 class GetAnnotationJob;
85 GetAnnotationJob* getAnnotation( TDEIO::Slave* slave, const KURL& url, const TQString& entry,
86  const TQStringList& attributes );
87 
93 MultiGetAnnotationJob* multiGetAnnotation( TDEIO::Slave* slave, const KURL& url, const TQStringList& entries );
94 
101 MultiUrlGetAnnotationJob* multiUrlGetAnnotation( TDEIO::Slave* slave,
102  const KURL& baseUrl,
103  const TQStringList& paths,
104  const TQString& annotation );
105 
106 
108 class GetAnnotationJob : public TDEIO::SimpleJob
109 {
110  TQ_OBJECT
111 
112 public:
113  GetAnnotationJob( const KURL& url, const TQString& entry, const TQByteArray &packedArgs,
114  bool showProgressInfo );
115 
116  const AnnotationList& annotations() const { return mAnnotations; }
117 
118 protected slots:
119  void slotInfoMessage( TDEIO::Job*, const TQString& );
120 private:
121  AnnotationList mAnnotations;
122  TQString mEntry;
123 };
124 
126 class MultiGetAnnotationJob : public TDEIO::Job
127 {
128  TQ_OBJECT
129 
130 
131 public:
132  MultiGetAnnotationJob( TDEIO::Slave* slave, const KURL& url, const TQStringList& entries, bool showProgressInfo );
133 
134 signals:
135  // Emitted when a given annotation was found - or not found
136  void annotationResult( const TQString& entry, const TQString& value, bool found );
137 
138 protected slots:
139  virtual void slotStart();
140  virtual void slotResult( TDEIO::Job *job );
141 
142 private:
143  TDEIO::Slave* mSlave;
144  const KURL mUrl;
145  const TQStringList mEntryList;
146  TQStringList::const_iterator mEntryListIterator;
147 };
148 
150 class MultiUrlGetAnnotationJob : public TDEIO::Job
151 {
152  TQ_OBJECT
153 
154 
155 public:
156  MultiUrlGetAnnotationJob( TDEIO::Slave* slave, const KURL& baseUrl,
157  const TQStringList& paths, const TQString& annotation );
158 
159  TQMap<TQString, TQString> annotations() const;
160 
161 protected slots:
162  virtual void slotStart();
163  virtual void slotResult( TDEIO::Job *job );
164 
165 private:
166  TDEIO::Slave* mSlave;
167  const KURL mUrl;
168  const TQStringList mPathList;
169  TQStringList::const_iterator mPathListIterator;
170  TQString mAnnotation;
171  TQMap<TQString, TQString> mAnnotations;
172 };
173 
175 class MultiSetAnnotationJob : public TDEIO::Job
176 {
177  TQ_OBJECT
178 
179 
180 public:
181  MultiSetAnnotationJob( TDEIO::Slave* slave, const KURL& url, const AnnotationList& annotations, bool showProgressInfo );
182 
183 signals:
184  // Emitted when a given annotation was successfully changed
185  void annotationChanged( const TQString& entry, const TQString& attribute, const TQString& value );
186 
187 protected slots:
188  virtual void slotStart();
189  virtual void slotResult( TDEIO::Job *job );
190 
191 private:
192  TDEIO::Slave* mSlave;
193  const KURL mUrl;
194  const AnnotationList mAnnotationList;
195  AnnotationList::const_iterator mAnnotationListIterator;
196 };
197 
198 } // AnnotationJobs namespace
199 
200 } // KMail namespace
201 
202 #endif /* ANNOTATIONJOBS_H */
203 
TDEIO::SimpleJob * setAnnotation(TDEIO::Slave *slave, const KURL &url, const TQString &entry, const TQMap< TQString, TQString > &attributes)
Set an annotation entry (note that it can have multiple attributes)
MultiGetAnnotationJob * multiGetAnnotation(TDEIO::Slave *slave, const KURL &url, const TQStringList &entries)
Get multiple annotation entries Currently we assume we want to get the "value" for each,...
GetAnnotationJob * getAnnotation(TDEIO::Slave *slave, const KURL &url, const TQString &entry, const TQStringList &attributes)
Get an annotation entry.
MultiUrlGetAnnotationJob * multiUrlGetAnnotation(TDEIO::Slave *slave, const KURL &baseUrl, const TQStringList &paths, const TQString &annotation)
Get annotation entries for multiple folders.
MultiSetAnnotationJob * multiSetAnnotation(TDEIO::Slave *slave, const KURL &url, const AnnotationList &annotations)
Set multiple annotation entries.
folderdiaquotatab.h
Definition: aboutdata.cpp:40
One entry in the annotation list: attribute name and attribute value.