• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

smtp.h

Go to the documentation of this file.
00001 /*
00002    Copyright (c) 2000 Bernd Johannes Wuebben <wuebben@math.cornell.edu>
00003    Copyright (c) 2000 Stephan Kulow <coolo@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, or (at your option)
00008    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 #ifndef SMTP_H
00020 #define SMTP_H
00021 
00022 #include <QtCore/QObject>
00023 #include <QtCore/QTimer>
00024 #include <QtNetwork/QTcpSocket>
00025 #include <ksocketfactory.h>
00026 
00027 /*int SMTPServerStatus[] = {
00028     220,  // greeting from server
00029     221,  // server acknolages goodbye
00030     250,  // command successful
00031     354,  // ready to receive data
00032     501,  // error
00033     550,  // user unknown
00034     0     // null
00035 };
00036 
00037 int SMTPClientStatus[] = {
00038     50,   // not logged in yet.
00039     100,  // logged in, got 220
00040     150,  // sent helo, got 250
00041     200,  // sent mail from, got 250
00042     250,  // sent rctp to, got 250
00043     300,  // data sent, got 354
00044     350,  // sent data/., got 250
00045     400,  // send quit, got 221
00046     450,  // finished, logged out
00047     0     // null
00048 };
00049 */
00050 
00051 #define DEFAULT_SMTP_PORT 25
00052 #define DEFAULT_SMTP_SERVER localhost
00053 #define DEFAULT_SMTP_TIMEOUT 60
00054 
00055 #define SMTP_READ_BUFFER_SIZE 256
00056 
00057 class SMTP:public QObject
00058 {
00059     Q_OBJECT
00060 public:
00061     explicit SMTP(char *serverhost = 0, unsigned short int port = 0,
00062                   int timeout = DEFAULT_SMTP_TIMEOUT);
00063     ~SMTP();
00064 
00065     void setServerHost(const QString& serverhost);
00066     void setPort(unsigned short int port);
00067     void setTimeOut(int timeout);
00068 
00069     bool isConnected(){return connected;}
00070     bool isFinished(){return finished;}
00071     QString getLastLine(){return lastLine;}
00072 
00073     void setSenderAddress(const QString& sender);
00074     void setRecipientAddress(const QString& recipient);
00075     void setMessageSubject(const QString& subject);
00076     void setMessageBody(const QString& message);
00077     void setMessageHeader(const QString &header);
00078 
00079     typedef enum {
00080         None = 0,             // null
00081         Greet = 220,          // greeting from server
00082         Goodbye = 221,        // server acknolages quit
00083         Successful = 250,     // command successful
00084         ReadyData = 354,      // server ready to receive data
00085         Error = 501,          // error
00086         Unknown = 550        // user unknown
00087     }SMTPServerStatus;
00088 
00089     typedef enum {
00090         Init = 50,            // not logged in yet
00091         In = 100,             // logged in, got 220
00092         Ready = 150,          // sent HELO, got 250
00093         SentFrom = 200,       // sent MAIL FROM:, got 250
00094         SentTo = 250,         // sent RCTP TO:, got 250
00095         Data = 300,           // Data sent, got 354
00096         Finished = 350,       // finished sending data, got 250
00097         Quit = 400,           // sent Quit, got 221
00098         Out = 450,            // finished, logged out
00099         CError = 500           // didn't finish, had error or connection drop
00100     }SMTPClientStatus;
00101 
00102     typedef enum {
00103         NoError = 0,
00104         ConnectError = 10,
00105         NotConnected = 11,
00106         ConnectTimeout = 15,
00107         InteractTimeout = 16,
00108         UnknownResponse = 20,
00109         UnknownUser = 30,
00110         Command = 40
00111     }SMTPError;
00112 
00113 protected:
00114     void processLine(QString *line);
00115 
00116 public Q_SLOTS:
00117     void openConnection();
00118     void sendMessage();
00119     void closeConnection();
00120 
00121     void connectTimerTick();
00122     void connectTimedOut();
00123     void interactTimedOut();
00124 
00125     void socketReadyToRead();
00126     void socketClosed();
00127 
00128 Q_SIGNALS:
00129     void connectionClosed();
00130     void messageSent();
00131     void error(int);
00132 
00133 private:
00134     QString serverHost;
00135     unsigned short int hostPort;
00136     int timeOut;
00137 
00138     bool connected;
00139     bool finished;
00140 
00141     QString senderAddress;
00142     QString recipientAddress;
00143     QString messageSubject;
00144     QString messageBody, messageHeader;
00145 
00146     SMTPClientStatus state;
00147     SMTPClientStatus lastState;
00148     SMTPServerStatus serverState;
00149 
00150     QString domainName;
00151 
00152     QTcpSocket *sock;
00153     QTimer connectTimer;
00154     QTimer timeOutTimer;
00155     QTimer interactTimer;
00156 
00157     char readBuffer[SMTP_READ_BUFFER_SIZE];
00158     QString lineBuffer;
00159     QString lastLine;
00160     QString writeString;
00161 };
00162 #endif

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal