kmail
kmfilteraction.hGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef kmfilteraction_h
00021 #define kmfilteraction_h
00022
00023 #include <kmime_mdn.h>
00024
00025 #include <qstring.h>
00026 #include <qstringlist.h>
00027 #include <qdict.h>
00028 #include <qptrlist.h>
00029 #include <qvaluelist.h>
00030 #include <qguardedptr.h>
00031 #include <qwidget.h>
00032
00033 class KMMsgBase;
00034 class KMMessage;
00035 class QWidget;
00036 class KMFolder;
00037 class KTempFile;
00038
00039
00040
00041
00042
00043
00044
00045
00055 class KMFilterAction
00056 {
00057 public:
00073 enum ReturnCode { ErrorNeedComplete = 0x1, GoOn = 0x2, ErrorButGoOn = 0x4,
00074 CriticalError = 0x8 };
00077 KMFilterAction(const char* aName, const QString aLabel);
00078 virtual ~KMFilterAction();
00079
00082 const QString label() const { return mLabel; }
00083
00086 const QString name() const { return mName; }
00087
00095 virtual ReturnCode process(KMMessage* msg) const = 0;
00096
00100 virtual void processAsync(KMMessage* msg) const;
00101
00104 virtual bool requiresBody(KMMsgBase* msgBase) const;
00105
00110 virtual bool isEmpty() const { return FALSE; }
00111
00114 virtual QWidget* createParamWidget(QWidget* parent) const;
00115
00119 virtual void applyParamWidgetValue(QWidget* paramWidget);
00120
00123 virtual void setParamWidgetValue(QWidget* paramWidget) const;
00124
00127 virtual void clearParamWidget(QWidget* paramWidget) const;
00128
00130 virtual void argsFromString(const QString argsStr) = 0;
00131
00133 virtual const QString argsAsString() const = 0;
00134
00137 virtual const QString displayString() const = 0;
00138
00142 virtual bool folderRemoved(KMFolder* aFolder, KMFolder* aNewFolder);
00143
00145 static KMFilterAction* newAction();
00146
00149 static int tempOpenFolder(KMFolder* aFolder);
00150
00152 static void sendMDN( KMMessage * msg, KMime::MDN::DispositionType d,
00153 const QValueList<KMime::MDN::DispositionModifier> & m
00154 =QValueList<KMime::MDN::DispositionModifier>() );
00155
00156 private:
00157 QString mName;
00158 QString mLabel;
00159 };
00160
00161
00162
00163
00164
00165
00166
00167
00181 class KMFilterActionWithNone : public KMFilterAction
00182 {
00183 public:
00186 KMFilterActionWithNone(const char* aName, const QString aLabel);
00187
00190 virtual void argsFromString(const QString) {};
00191
00194 virtual const QString argsAsString() const { return QString::null; }
00195
00198 virtual const QString displayString() const;
00199 };
00200
00201
00202
00203
00204
00205
00206
00207
00208
00222 class KMFilterActionWithString : public KMFilterAction
00223 {
00224 public:
00227 KMFilterActionWithString(const char* aName, const QString aLabel);
00228
00233 virtual bool isEmpty() const { return mParameter.stripWhiteSpace().isEmpty(); }
00234
00237 virtual QWidget* createParamWidget(QWidget* parent) const;
00238
00242 virtual void applyParamWidgetValue(QWidget* paramWidget);
00243
00246 virtual void setParamWidgetValue(QWidget* paramWidget) const;
00247
00250 virtual void clearParamWidget(QWidget* paramWidget) const;
00251
00253 virtual void argsFromString(const QString argsStr);
00254
00256 virtual const QString argsAsString() const;
00257
00260 virtual const QString displayString() const;
00261
00262 protected:
00263 QString mParameter;
00264 };
00265
00266
00267
00268
00269
00270
00271
00272
00286 class KMFilterActionWithUOID : public KMFilterAction
00287 {
00288 public:
00291 KMFilterActionWithUOID(const char* aName, const QString aLabel);
00292
00297 virtual bool isEmpty() const { return mParameter == 0; }
00298
00300 virtual void argsFromString(const QString argsStr);
00301
00303 virtual const QString argsAsString() const;
00304
00307 virtual const QString displayString() const;
00308
00309 protected:
00310 uint mParameter;
00311 };
00312
00313
00314
00315
00316
00317
00318
00319
00339 class KMFilterActionWithStringList : public KMFilterActionWithString
00340 {
00341 public:
00344 KMFilterActionWithStringList(const char* aName, const QString aLabel);
00345
00348 virtual QWidget* createParamWidget(QWidget* parent) const;
00349
00353 virtual void applyParamWidgetValue(QWidget* paramWidget);
00354
00357 virtual void setParamWidgetValue(QWidget* paramWidget) const;
00358
00361 virtual void clearParamWidget(QWidget* paramWidget) const;
00362
00364 virtual void argsFromString(const QString argsStr);
00365
00366 protected:
00367 QStringList mParameterList;
00368 };
00369
00370
00371
00372
00373
00374
00375
00376
00377
00392 class KMFilterActionWithFolder : public KMFilterAction
00393 {
00394 public:
00397 KMFilterActionWithFolder(const char* aName, const QString aLabel);
00398
00403 virtual bool isEmpty() const { return (!mFolder && mFolderName.isEmpty()); }
00404
00407 virtual QWidget* createParamWidget(QWidget* parent) const;
00408
00412 virtual void applyParamWidgetValue(QWidget* paramWidget);
00413
00416 virtual void setParamWidgetValue(QWidget* paramWidget) const;
00417
00420 virtual void clearParamWidget(QWidget* paramWidget) const;
00421
00423 virtual void argsFromString(const QString argsStr);
00424
00426 virtual const QString argsAsString() const;
00427
00430 virtual const QString displayString() const;
00431
00435 virtual bool folderRemoved(KMFolder* aFolder, KMFolder* aNewFolder);
00436
00437 protected:
00438 QGuardedPtr<KMFolder> mFolder;
00439 QString mFolderName;
00440 };
00441
00442
00443
00444
00445
00446
00447
00448
00463 class KMFilterActionWithAddress : public KMFilterActionWithString
00464 {
00465 public:
00468 KMFilterActionWithAddress(const char* aName, const QString aLabel);
00469
00472 virtual QWidget* createParamWidget(QWidget* parent) const;
00473
00477 virtual void applyParamWidgetValue(QWidget* paramWidget);
00478
00481 virtual void setParamWidgetValue(QWidget* paramWidget) const;
00482
00485 virtual void clearParamWidget(QWidget* paramWidget) const;
00486 };
00487
00488
00489
00490
00491
00492
00493
00494
00514 class KMFilterActionWithUrl : public KMFilterAction
00515 {
00516 public:
00519 KMFilterActionWithUrl(const char* aName, const QString aLabel);
00520 ~KMFilterActionWithUrl();
00525 virtual bool isEmpty() const { return mParameter.stripWhiteSpace().isEmpty(); }
00526
00529 virtual QWidget* createParamWidget(QWidget* parent) const;
00530
00534 virtual void applyParamWidgetValue(QWidget* paramWidget);
00535
00538 virtual void setParamWidgetValue(QWidget* paramWidget) const;
00539
00542 virtual void clearParamWidget(QWidget* paramWidget) const;
00543
00545 virtual void argsFromString(const QString argsStr);
00546
00548 virtual const QString argsAsString() const;
00549
00552 virtual const QString displayString() const;
00553
00554 protected:
00555 QString mParameter;
00556 };
00557
00558
00559 class KMFilterActionWithCommand : public KMFilterActionWithUrl
00560 {
00561 public:
00564 KMFilterActionWithCommand(const char* aName, const QString aLabel);
00565
00568 virtual QWidget* createParamWidget(QWidget* parent) const;
00569
00573 virtual void applyParamWidgetValue(QWidget* paramWidget);
00574
00577 virtual void setParamWidgetValue(QWidget* paramWidget) const;
00578
00581 virtual void clearParamWidget(QWidget* paramWidget) const;
00582
00588 virtual QString substituteCommandLineArgsFor( KMMessage *aMsg, QPtrList<KTempFile> & aTempFileList ) const;
00589
00590 virtual ReturnCode genericProcess( KMMessage * aMsg, bool filtering ) const;
00591 };
00592
00593
00594
00595 class KMFilterActionWithTest : public KMFilterAction
00596 {
00597 public:
00600 KMFilterActionWithTest(const char* aName, const QString aLabel);
00601 ~KMFilterActionWithTest();
00606 virtual bool isEmpty() const { return mParameter.stripWhiteSpace().isEmpty(); }
00607
00610 virtual QWidget* createParamWidget(QWidget* parent) const;
00611
00615 virtual void applyParamWidgetValue(QWidget* paramWidget);
00616
00619 virtual void setParamWidgetValue(QWidget* paramWidget) const;
00620
00623 virtual void clearParamWidget(QWidget* paramWidget) const;
00624
00626 virtual void argsFromString(const QString argsStr);
00627
00629 virtual const QString argsAsString() const;
00630
00633 virtual const QString displayString() const;
00634
00635 protected:
00636 QString mParameter;
00637 };
00638
00639
00640 typedef KMFilterAction* (*KMFilterActionNewFunc)(void);
00641
00642
00643
00645 struct KMFilterActionDesc
00646 {
00647 QString label, name;
00648 KMFilterActionNewFunc create;
00649 };
00650
00673 class KMFilterActionDict: public QDict<KMFilterActionDesc>
00674 {
00675 public:
00676 KMFilterActionDict();
00677
00685 void insert(KMFilterActionNewFunc aNewFunc);
00686
00689 const QPtrList<KMFilterActionDesc>& list() const { return mList; }
00690
00691 protected:
00694 virtual void init(void);
00695
00696 private:
00697 QPtrList<KMFilterActionDesc> mList;
00698 };
00699
00700 #endif
|