TreeFrogFramework  1.18
tpopmailer.h
Go to the documentation of this file.
1 #ifndef TPOPMAILER_H
2 #define TPOPMAILER_H
3 
4 #include <QObject>
5 #include <QString>
6 #include <QByteArray>
7 #include <TGlobal>
8 
9 class QTcpSocket;
10 
11 
12 class T_CORE_EXPORT TPopMailer : public QObject
13 {
14  Q_OBJECT
15 public:
16  TPopMailer(QObject *parent = 0);
17  TPopMailer(const QString &hostName, quint16 port, QObject *parent = 0);
18  ~TPopMailer();
19 
20  QString key() const { return "pop"; }
21  QString hostName() const { return popHostName; }
22  void setHostName(const QString &hostName);
23  quint16 port() const { return popPort; }
24  void setPort(quint16 port);
25  void setUserName(const QByteArray &username);
26  void setPassword(const QByteArray &password);
27  void setApopEnabled(bool enable);
28 
29  bool connectToHost();
30  QByteArray readMail(int index);
31  void quit();
32 
33 protected:
34  bool cmdUser();
35  bool cmdPass();
36  bool cmdApop(const QByteArray &token);
37  bool cmdStat();
38  bool cmdRetr(int index, QByteArray &message);
39  bool cmdQuit();
40 
41  bool cmd(const QByteArray &command, QByteArray *reply = 0);
42  bool readResponse(QByteArray *reply = 0);
43  bool write(const QByteArray &command);
44 
45 private:
48 
49  QTcpSocket *socket;
50  QString popHostName;
51  quint16 popPort;
52  QByteArray userName;
53  QByteArray password;
54  bool apopEnabled;
55 };
56 
57 
58 inline void TPopMailer::setUserName(const QByteArray &username)
59 {
60  userName = username;
61 }
62 
63 
64 inline void TPopMailer::setPassword(const QByteArray &pass)
65 {
66  password = pass;
67 }
68 
69 #endif // TPOPMAILER_H
#define T_CORE_EXPORT
Definition: tglobal.h:81
void setPassword(const QByteArray &password)
Definition: tpopmailer.h:64
QString hostName() const
Definition: tpopmailer.h:21
#define T_DISABLE_COPY(Class)
Definition: tglobal.h:137
#define T_DISABLE_MOVE(Class)
Definition: tglobal.h:141
QString key() const
Definition: tpopmailer.h:20
void setUserName(const QByteArray &username)
Definition: tpopmailer.h:58
quint16 port() const
Definition: tpopmailer.h:23
The TPopMailer class provides a simple functionality to receive emails by POP.
Definition: tpopmailer.h:12