• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.2 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • misc
  • ksendbugmail
smtp.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2000 Bernd Johannes Wuebben <wuebben@math.cornell.edu>
3  Copyright (c) 2000 Stephan Kulow <coolo@kde.org>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2, or (at your option)
8  any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 #ifndef SMTP_H
20 #define SMTP_H
21 
22 #include <QtCore/QObject>
23 #include <QtCore/QTimer>
24 #include <QtNetwork/QTcpSocket>
25 #include <ksocketfactory.h>
26 
27 /*int SMTPServerStatus[] = {
28  220, // greeting from server
29  221, // server acknolages goodbye
30  250, // command successful
31  354, // ready to receive data
32  501, // error
33  550, // user unknown
34  0 // null
35 };
36 
37 int SMTPClientStatus[] = {
38  50, // not logged in yet.
39  100, // logged in, got 220
40  150, // sent helo, got 250
41  200, // sent mail from, got 250
42  250, // sent rctp to, got 250
43  300, // data sent, got 354
44  350, // sent data/., got 250
45  400, // send quit, got 221
46  450, // finished, logged out
47  0 // null
48 };
49 */
50 
51 #define DEFAULT_SMTP_PORT 25
52 #define DEFAULT_SMTP_SERVER localhost
53 #define DEFAULT_SMTP_TIMEOUT 60
54 
55 #define SMTP_READ_BUFFER_SIZE 256
56 
57 class SMTP:public QObject
58 {
59  Q_OBJECT
60 public:
61  explicit SMTP(char *serverhost = 0, unsigned short int port = 0,
62  int timeout = DEFAULT_SMTP_TIMEOUT);
63  ~SMTP();
64 
65  void setServerHost(const QString& serverhost);
66  void setPort(unsigned short int port);
67  void setTimeOut(int timeout);
68 
69  bool isConnected(){return connected;}
70  bool isFinished(){return finished;}
71  QString getLastLine(){return lastLine;}
72 
73  void setSenderAddress(const QString& sender);
74  void setRecipientAddress(const QString& recipient);
75  void setMessageSubject(const QString& subject);
76  void setMessageBody(const QString& message);
77  void setMessageHeader(const QString &header);
78 
79  typedef enum {
80  None = 0, // null
81  Greet = 220, // greeting from server
82  Goodbye = 221, // server acknolages quit
83  Successful = 250, // command successful
84  ReadyData = 354, // server ready to receive data
85  Error = 501, // error
86  Unknown = 550 // user unknown
87  }SMTPServerStatus;
88 
89  typedef enum {
90  Init = 50, // not logged in yet
91  In = 100, // logged in, got 220
92  Ready = 150, // sent HELO, got 250
93  SentFrom = 200, // sent MAIL FROM:, got 250
94  SentTo = 250, // sent RCTP TO:, got 250
95  Data = 300, // Data sent, got 354
96  Finished = 350, // finished sending data, got 250
97  Quit = 400, // sent Quit, got 221
98  Out = 450, // finished, logged out
99  CError = 500 // didn't finish, had error or connection drop
100  }SMTPClientStatus;
101 
102  typedef enum {
103  NoError = 0,
104  ConnectError = 10,
105  NotConnected = 11,
106  ConnectTimeout = 15,
107  InteractTimeout = 16,
108  UnknownResponse = 20,
109  UnknownUser = 30,
110  Command = 40
111  }SMTPError;
112 
113 protected:
114  void processLine(QString *line);
115 
116 public Q_SLOTS:
117  void openConnection();
118  void sendMessage();
119  void closeConnection();
120 
121  void connectTimerTick();
122  void connectTimedOut();
123  void interactTimedOut();
124 
125  void socketReadyToRead();
126  void socketClosed();
127  void socketError(QAbstractSocket::SocketError);
128 
129 Q_SIGNALS:
130  void connectionClosed();
131  void messageSent();
132  void error(int);
133 
134 private:
135  QString serverHost;
136  unsigned short int hostPort;
137  int timeOut;
138 
139  bool connected;
140  bool finished;
141 
142  QString senderAddress;
143  QString recipientAddress;
144  QString messageSubject;
145  QString messageBody, messageHeader;
146 
147  SMTPClientStatus state;
148  SMTPClientStatus lastState;
149  SMTPServerStatus serverState;
150 
151  QString domainName;
152 
153  QTcpSocket *sock;
154  QTimer connectTimer;
155  QTimer timeOutTimer;
156  QTimer interactTimer;
157 
158  char readBuffer[SMTP_READ_BUFFER_SIZE];
159  QString lineBuffer;
160  QString lastLine;
161  QString writeString;
162 };
163 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Apr 16 2013 21:05:00 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

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

kdelibs-4.10.2 API Reference

Skip menu "kdelibs-4.10.2 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal