# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# smtp.h

    00001 /* $Id: smtp.h,v 1.3 2001/01/16 02:33:21 garbanzo Exp $ */
    00002
    00003 #ifndef SMTP_H
    00004 #define SMTP_H
    00005
    00006 #include <qobject.h>
    00007 #include <qtimer.h>
    00008 #include <ksock.h>
    00009
    00010 /*int SMTPServerStatus[] = {
    00011     220,  // greeting from server
    00012     221,  // server acknolages goodbye
    00013     250,  // command successful
    00014     354,  // ready to recieve data
    00015     501,  // error
    00016     550,  // user unkown
    00017     0     // null
    00018 };
    00019
    00020 int SMTPClientStatus[] = {
    00021     50,   // not logged in yet.
    00022     100,  // logged in, got 220
    00023     150,  // sent helo, got 250
    00024     200,  // sent mail from, got 250
    00025     250,  // sent rctp to, got 250
    00026     300,  // data sent, got 354
    00027     350,  // sent data/., got 250
    00028     400,  // send quit, got 221
    00029     450,  // finished, logged out
    00030     0     // null
    00031 };
    00032 */
    00033
    00034 #define DEFAULT_SMTP_PORT 25
    00035 #define DEFAULT_SMTP_SERVER localhost
    00036 #define DEFAULT_SMTP_TIMEOUT 60
    00037
    00038 #define SMTP_READ_BUFFER_SIZE 256
    00039
    00040 class SMTP:public QObject
    00041 {
    00042     Q_OBJECT
    00043 public:
    00044     SMTP(char *serverhost = 0, unsigned short int port = 0, int timeout = DEFAULT_SMTP_TIMEOUT);
    00045     ~SMTP();
    00046
    00047     void setServerHost(const QString& serverhost);
    00048     void setPort(unsigned short int port);
    00049     void setTimeOut(int timeout);
    00050
    00051     bool isConnected(){return connected;};
    00052     bool isFinished(){return finished;};
    00053     QString getLastLine(){return lastLine;};
    00054
    00055     void setSenderAddress(const QString& sender);
    00056     void setRecipientAddress(const QString& recipient);
    00057     void setMessageSubject(const QString& subject);
    00058     void setMessageBody(const QString& message);
    00059     void setMessageHeader(const QString &header);
    00060
    00061     typedef enum {
    00062         NONE = 0,             // null
    00063         GREET = 220,          // greeting from server
    00064         GOODBYE = 221,        // server acknolages quit
    00065         SUCCESSFUL = 250,     // command successful
    00066         READYDATA = 354,      // server ready to recieve data
    00067         ERROR = 501,          // error
    00068         UNKNOWN = 550        // user unknown
    00069     }SMTPServerStatus;
    00070
    00071     typedef enum {
    00072         INIT = 50,            // not logged in yet
    00073         IN = 100,             // logged in, got 220
    00074         READY = 150,          // sent HELO, got 250
    00075         SENTFROM = 200,       // sent MAIL FROM:, got 250
    00076         SENTTO = 250,         // sent RCTP TO:, got 250
    00077         DATA = 300,           // DATA sent, got 354
    00078         FINISHED = 350,       // finished sending data, got 250
    00079         QUIT = 400,           // sent QUIT, got 221
    00080         OUT = 450,            // finished, logged out
    00081         CERROR = 500           // didn't finish, had error or connection drop
    00082     }SMTPClientStatus;
    00083
    00084     typedef enum {
    00085         NOERROR = 0,
    00086         CONNECTERROR = 10,
    00087         NOTCONNECTED = 11,
    00088         CONNECTTIMEOUT = 15,
    00089         INTERACTTIMEOUT = 16,
    00090         UNKNOWNRESPONSE = 20,
    00091         UNKNOWNUSER = 30,
    00092         COMMAND = 40
    00093     }SMTPError;
    00094
    00095 protected:
    00096     void processLine(QString *line);
    00097
    00098 public slots:
    00099     void openConnection();
    00100     void sendMessage();
    00101     void closeConnection();
    00102
    00103     void connectTimerTick();
    00104     void connectTimedOut();
    00105     void interactTimedOut();
    00106
    00107     void socketRead(KSocket *);
    00108     void socketClose(KSocket *);
    00109
    00110 signals:
    00111     void connectionClosed();
    00112     void messageSent();
    00113     void error(int);
    00114
    00115 private:
    00116     QString serverHost;
    00117     unsigned short int hostPort;
    00118     int timeOut;
    00119
    00120     bool connected;
    00121     bool finished;
    00122
    00123     QString senderAddress;
    00124     QString recipientAddress;
    00125     QString messageSubject;
    00126     QString messageBody, messageHeader;
    00127
    00128     SMTPClientStatus state;
    00129     SMTPClientStatus lastState;
    00130     SMTPServerStatus serverState;
    00131
    00132     QString domainName;
    00133
    00134     KSocket *sock;
    00135     QTimer connectTimer;
    00136     QTimer timeOutTimer;
    00137     QTimer interactTimer;
    00138
    00139     char readBuffer[SMTP_READ_BUFFER_SIZE];
    00140     QString lineBuffer;
    00141     QString lastLine;
    00142     QString writeString;
    00143 };
    00144 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:14:40 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001