summaryrefslogtreecommitdiffstats
path: root/kbugbuster/backend/smtp.h
blob: b97e3b896f92288819e8de7a42e920d98ac30cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/****************************************************************************
**
** This file is a modified version of part of an example program for Qt.
** This file may be used, distributed and modified without limitation.
**
** Don Sanders <sanders@kde.org>
**
*****************************************************************************/

#ifndef SMTP_H
#define SMTP_H

#include <tqobject.h>
#include <tqstring.h>
#include <tqstringlist.h>

class QSocket;
class QTextStream;

class Smtp : public QObject
{
    Q_OBJECT

public:
    Smtp( const TQString &from, const TQStringList &to, const TQString &message, 
          const TQString &server, unsigned short int port = 25 );
    ~Smtp();
    void send( const TQString &, const TQStringList &, const TQString & );
    void quit();


signals:
    void success();
    void status( const TQString & );
    void error( const TQString &command, const TQString &response );

private slots:
    void readyRead();
    void connected();
    void deleteMe();
    void socketError(int err);
    void emitError();

private:
    enum State {
	smtpInit,
	smtpMail,
	smtpRcpt,
	smtpData,
	smtpBody,
	smtpSuccess,
	smtpQuit,
	smtpClose
    };

    TQString message;
    TQString from;
    TQStringList rcpt;
    TQSocket *mSocket;
    TQTextStream * t;
    int state;
    TQString response, responseLine;
    bool skipReadResponse;
    TQString command;
};

#endif