kmail Library API Documentation

kmsender.h

00001 /* KMail Mail Sender
00002  *
00003  * Author: Stefan Taferner <taferner@alpin.or.at>
00004  */
00005 #ifndef kmsender_h
00006 #define kmsender_h
00007 #include <qcstring.h>
00008 #include <qstring.h>
00009 #include <qstringlist.h>
00010 #include <qobject.h>
00011 #include <kio/global.h>
00012 #include <kdeversion.h>
00013 
00014 class KMMessage;
00015 class KMFolder;
00016 class KMFolderMgr;
00017 class KConfig;
00018 class KProcess;
00019 class KMSendProc;
00020 class QStrList;
00021 class KMTransportInfo;
00022 class KMPrecommand;
00023 
00024 namespace KIO {
00025   class Job;
00026   class TransferJob;
00027   class Slave;
00028 }
00029 
00030 namespace KMime {
00031   namespace Types {
00032     class AddrSpec;
00033     typedef QValueList<AddrSpec> AddrSpecList;
00034   }
00035 }
00036 
00037 namespace KPIM {
00038   class ProgressItem;
00039 }
00040 
00041 class KMSender: public QObject
00042 {
00043   Q_OBJECT
00044   friend class KMSendProc;
00045 
00046 public:
00047   KMSender();
00048   virtual ~KMSender();
00049 
00057   virtual bool send(KMMessage* msg, short sendNow=-1);
00058 
00060   virtual bool sendQueued();
00061 
00063   bool sending(void) const { return mSendInProgress; }
00064 
00067   bool sendImmediate(void) const { return mSendImmediate; }
00068   virtual void setSendImmediate(bool);
00069 
00072   bool sendQuotedPrintable(void) const { return mSendQuotedPrintable; }
00073   virtual void setSendQuotedPrintable(bool);
00074 
00076   KMTransportInfo * transportInfo() { return mTransportInfo; }
00077 
00079   virtual void readConfig(void);
00080 
00082   virtual void writeConfig(bool withSync=TRUE);
00083 
00085   void setStatusMsg(const QString&);
00086 
00088   void setStatusByLink(const KMMessage *aMsg);
00089 
00091   void emitProgressInfo( int currentFileProgress );
00092 
00093 protected slots:
00095   virtual void slotPrecommandFinished(bool);
00096 
00097   virtual void slotIdle();
00098 
00100   virtual void slotAbortSend();
00101 
00103   virtual void sendProcStarted(bool success);
00104 
00106   void outboxMsgAdded(int idx);
00107 
00108 protected:
00110   virtual void doSendMsg();
00111 
00113   virtual void doSendMsgAux();
00114 
00116   virtual void cleanup(void);
00117 
00121   virtual bool settingsOk(void) const;
00122 
00125   virtual KMSendProc* createSendProcFromString(QString transport);
00126 
00127 private:
00128   bool mSendImmediate;
00129   bool mSendQuotedPrintable;
00130   KMTransportInfo *mTransportInfo;
00131   KMPrecommand *mPrecommand;
00132 
00133   bool mSentOk, mSendAborted;
00134   QString mErrorMsg;
00135   KMSendProc *mSendProc;
00136   QString mMethodStr;
00137   bool mSendProcStarted;
00138   bool mSendInProgress;
00139   KMFolder *mOutboxFolder;
00140   KMFolder *mSentFolder;
00141   KMMessage * mCurrentMsg;
00142   KPIM::ProgressItem* mProgressItem;
00143   int mSentMessages, mTotalMessages;
00144   int mSentBytes, mTotalBytes;
00145   int mFailedMessages;
00146 };
00147 
00148 
00149 //-----------------------------------------------------------------------------
00150 class KMSendProc: public QObject
00151 {
00152   Q_OBJECT
00153 
00154 public:
00155   KMSendProc(KMSender*);
00156   virtual ~KMSendProc() {}
00157 
00159   virtual void start(void);
00160 
00162   virtual void preSendInit(void);
00163 
00165   virtual bool send(KMMessage* msg) = 0;
00166 
00168   virtual bool finish(bool destructive);
00169 
00171   virtual void abort() = 0;
00172 
00175   bool sendOk(void) const { return mSendOk; }
00176 
00178   bool sending(void) const { return mSending; }
00179 
00181   QString message(void) const { return mMsg; }
00182 
00183 signals:
00185   void idle();
00186 
00188   void started(bool);
00189 
00190 
00191 protected:
00195   virtual void failed(const QString &msg);
00196 
00198   virtual void statusMsg(const QString&);
00199 
00204   virtual bool addRecipients(const KMime::Types::AddrSpecList & aRecpList);
00205 
00211   virtual bool addOneRecipient(const QString& aRecipient) = 0;
00212 
00213 protected:
00214   bool mSendOk, mSending;
00215   QString mMsg;
00216   KMSender* mSender;
00217 };
00218 
00219 
00220 //-----------------------------------------------------------------------------
00221 class KMSendSendmail: public KMSendProc
00222 {
00223   Q_OBJECT
00224 public:
00225   KMSendSendmail(KMSender*);
00226   virtual ~KMSendSendmail();
00227   virtual void start(void);
00228   virtual bool send(KMMessage* msg);
00229   virtual bool finish(bool destructive);
00230   virtual void abort();
00231 
00232 protected slots:
00233   void receivedStderr(KProcess*,char*,int);
00234   void wroteStdin(KProcess*);
00235   void sendmailExited(KProcess*);
00236 
00237 protected:
00238   virtual bool addOneRecipient(const QString& aRecipient);
00239 
00240   QCString mMsgStr;
00241   char* mMsgPos;
00242   int mMsgRest;
00243   KProcess* mMailerProc;
00244 };
00245 
00246 //-----------------------------------------------------------------------------
00247 class KMSendSMTP : public KMSendProc
00248 {
00249 Q_OBJECT
00250 public:
00251   KMSendSMTP(KMSender *sender);
00252   ~KMSendSMTP();
00253 
00254   virtual bool send(KMMessage *);
00255   virtual void abort();
00256   virtual bool finish(bool);
00257 
00258 protected:
00259   virtual bool addOneRecipient(const QString& aRecipient);
00260 
00261 private slots:
00262   void dataReq(KIO::Job *, QByteArray &);
00263   void result(KIO::Job *);
00264   void slaveError(KIO::Slave *, int, const QString &);
00265 
00266 private:
00267   QString mQuery;
00268   QString mQueryField;
00269   QCString mMessage;
00270   uint mMessageLength;
00271   uint mMessageOffset;
00272 
00273   bool mInProcess;
00274 
00275   KIO::TransferJob *mJob;
00276   KIO::Slave *mSlave;
00277 };
00278 
00279 #endif /*kmsender_h*/
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 22:43:53 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003