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 class KMSender: public QObject
00038 {
00039   Q_OBJECT
00040   friend class KMSendProc;
00041 
00042 public:
00043   KMSender();
00044   virtual ~KMSender();
00045 
00053   virtual bool send(KMMessage* msg, short sendNow=-1);
00054 
00056   virtual bool sendQueued();
00057 
00059   bool sending(void) const { return mSendInProgress; }
00060 
00063   bool sendImmediate(void) const { return mSendImmediate; }
00064   virtual void setSendImmediate(bool);
00065 
00068   bool sendQuotedPrintable(void) const { return mSendQuotedPrintable; }
00069   virtual void setSendQuotedPrintable(bool);
00070 
00072   KMTransportInfo * transportInfo() { return mTransportInfo; }
00073 
00075   virtual void readConfig(void);
00076 
00078   virtual void writeConfig(bool withSync=TRUE);
00079 
00081   void setStatusMsg(const QString&);
00082 
00084   void setStatusByLink(const KMMessage *aMsg);
00085 
00087   void emitProgressInfo( int currentFileProgress );
00088 
00089 signals:
00091   void statusMsg(const QString&);
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   KMMessage * mCurrentMsg;
00140   int mSentMessages, mTotalMessages;
00141   int mSentBytes, mTotalBytes;
00142   int mFailedMessages;
00143 };
00144 
00145 
00146 //-----------------------------------------------------------------------------
00147 class KMSendProc: public QObject
00148 {
00149   Q_OBJECT
00150 
00151 public:
00152   KMSendProc(KMSender*);
00153   virtual ~KMSendProc() {}
00154 
00156   virtual void start(void);
00157 
00159   virtual void preSendInit(void);
00160 
00162   virtual bool send(KMMessage* msg) = 0;
00163 
00165   virtual bool finish(bool destructive);
00166 
00168   virtual void abort() = 0;
00169 
00172   bool sendOk(void) const { return mSendOk; }
00173 
00175   bool sending(void) const { return mSending; }
00176 
00178   QString message(void) const { return mMsg; }
00179 
00180 signals:
00182   void idle();
00183 
00185   void started(bool);
00186 
00187 
00188 protected:
00192   virtual void failed(const QString &msg);
00193 
00194 #if !KDE_IS_VERSION( 3, 1, 90 ) // dotstuffing and LF->CRLF is now
00195                 // done by the SMTP kioslave
00197   virtual QCString prepareStr(const QCString &str, bool toCRLF=FALSE,
00198    bool noSingleDot=TRUE);
00199 #endif
00200 
00202   virtual void statusMsg(const QString&);
00203 
00208   virtual bool addRecipients(const KMime::Types::AddrSpecList & aRecpList);
00209 
00215   virtual bool addOneRecipient(const QString& aRecipient) = 0;
00216 
00217 protected:
00218   bool mSendOk, mSending;
00219   QString mMsg;
00220   KMSender* mSender;
00221 };
00222 
00223 
00224 //-----------------------------------------------------------------------------
00225 class KMSendSendmail: public KMSendProc
00226 {
00227   Q_OBJECT
00228 public:
00229   KMSendSendmail(KMSender*);
00230   virtual ~KMSendSendmail();
00231   virtual void start(void);
00232   virtual bool send(KMMessage* msg);
00233   virtual bool finish(bool destructive);
00234   virtual void abort();
00235 
00236 protected slots:
00237   void receivedStderr(KProcess*,char*,int);
00238   void wroteStdin(KProcess*);
00239   void sendmailExited(KProcess*);
00240 
00241 protected:
00242   virtual bool addOneRecipient(const QString& aRecipient);
00243 
00244   QCString mMsgStr;
00245   char* mMsgPos;
00246   int mMsgRest;
00247   KProcess* mMailerProc;
00248 };
00249 
00250 //-----------------------------------------------------------------------------
00251 class KMSendSMTP : public KMSendProc
00252 {
00253 Q_OBJECT
00254 public:
00255   KMSendSMTP(KMSender *sender);
00256   ~KMSendSMTP();
00257 
00258   virtual bool send(KMMessage *);
00259   virtual void abort();
00260   virtual bool finish(bool);
00261 
00262 protected:
00263   virtual bool addOneRecipient(const QString& aRecipient);
00264 
00265 private slots:
00266   void dataReq(KIO::Job *, QByteArray &);
00267   void result(KIO::Job *);
00268   void slaveError(KIO::Slave *, int, const QString &);
00269 
00270 private:
00271   QString mQuery;
00272   QString mQueryField;
00273   QCString mMessage;
00274   uint mMessageLength;
00275   uint mMessageOffset;
00276 
00277   bool mInProcess;
00278 
00279   KIO::TransferJob *mJob;
00280   KIO::Slave *mSlave;
00281 };
00282 
00283 #endif /*kmsender_h*/
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:37:34 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003