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