kmail

kmsender.h

00001 /*
00002  * kmail: KDE mail client
00003  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  */
00020 #ifndef kmsender_h
00021 #define kmsender_h
00022 #include "messagesender.h"
00023 
00024 #ifndef KDE_USE_FINAL
00025 # ifndef REALLY_WANT_KMSENDER
00026 #  error Do not include kmsender.h, but messagesender.h.
00027 # endif
00028 #endif
00029 
00030 #include <tqcstring.h>
00031 #include <tqstring.h>
00032 #include <tqstringlist.h>
00033 #include <tqmap.h>
00034 #include <tqobject.h>
00035 #include <tdeversion.h>
00036 
00037 class KMMessage;
00038 class KMFolder;
00039 class KMFolderMgr;
00040 class TDEConfig;
00041 class TDEProcess;
00042 class KMSendProc;
00043 class KMSendSendmail;
00044 class KMSendSMTP;
00045 class TQStrList;
00046 class KMTransportInfo;
00047 class KMPrecommand;
00048 
00049 namespace KPIM {
00050   class ProgressItem;
00051 }
00052 
00053 class KMSender: public TQObject, public KMail::MessageSender
00054 {
00055   Q_OBJECT
00056   
00057   friend class ::KMSendProc;
00058   friend class ::KMSendSendmail;
00059   friend class ::KMSendSMTP;
00060 
00061 public:
00062   KMSender();
00063   ~KMSender();
00064 
00065 protected:
00073   bool doSend(KMMessage* msg, short sendNow);
00074 
00078   bool doSendQueued( const TQString& transport );
00079 
00080 private:
00082   bool sending() const { return mSendInProgress; }
00083 
00084 public:
00087   bool sendImmediate() const { return mSendImmediate; }
00088   void setSendImmediate(bool);
00089 
00092   bool sendQuotedPrintable() const { return mSendQuotedPrintable; }
00093   void setSendQuotedPrintable(bool);
00094 
00095 private:
00097   KMTransportInfo * transportInfo() { return mTransportInfo; }
00098 
00099 public:
00101   void readConfig();
00102 
00104   void writeConfig(bool withSync=true);
00105 
00106 private:
00108   void setStatusMsg(const TQString&);
00109 
00111   void setStatusByLink(const KMMessage *aMsg);
00112 
00114   void emitProgressInfo( int currentFileProgress );
00115 
00116 private slots:
00118   void slotPrecommandFinished(bool);
00119 
00120   void slotIdle();
00121 
00123   void slotAbortSend();
00124 
00126   void sendProcStarted(bool success);
00127 
00129   void outboxMsgAdded(int idx);
00130 
00131 private:
00133   void doSendMsg();
00134 
00136   void doSendMsgAux();
00137 
00139   void cleanup();
00140 
00144   bool settingsOk() const;
00145 
00148   KMSendProc* createSendProcFromString( const TQString & transport );
00149 
00150   bool runPrecommand( const TQString & cmd );
00151 
00152 private:
00153   bool mSendImmediate;
00154   bool mSendQuotedPrintable;
00155   KMTransportInfo *mTransportInfo;
00156   KMPrecommand *mPrecommand;
00157 
00158   TQString mCustomTransport;
00159   bool mSentOk, mSendAborted;
00160   TQString mErrorMsg;
00161   KMSendProc *mSendProc;
00162   TQString mMethodStr;
00163   bool mSendProcStarted;
00164   bool mSendInProgress;
00165   KMFolder *mOutboxFolder;
00166   KMFolder *mSentFolder;
00167   KMMessage * mCurrentMsg;
00168   KPIM::ProgressItem* mProgressItem;
00169   int mSentMessages, mTotalMessages;
00170   int mSentBytes, mTotalBytes;
00171   int mFailedMessages;
00172   TQMap<TQString,TQString> mPasswdCache;
00173 };
00174 
00175 #endif /*kmsender_h*/