Diffstat (limited to 'noncore/unsupported/mailit/smtpclient.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/smtpclient.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp index 2916f45..5b5ef52 100644 --- a/noncore/unsupported/mailit/smtpclient.cpp +++ b/noncore/unsupported/mailit/smtpclient.cpp | |||
@@ -72,9 +72,14 @@ void SmtpClient::connectionEstablished() | |||
72 | } | 72 | } |
73 | 73 | ||
74 | void SmtpClient::errorHandling(int status) | 74 | void SmtpClient::errorHandling(int status) |
75 | { | 75 | { |
76 | emit errorOccurred(status); | 76 | errorHandlingWithMsg( status, QString::null ); |
77 | } | ||
78 | |||
79 | void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg ) | ||
80 | { | ||
81 | emit errorOccurred(status, EMsg ); | ||
77 | socket->close(); | 82 | socket->close(); |
78 | mailList.clear(); | 83 | mailList.clear(); |
79 | sending = FALSE; | 84 | sending = FALSE; |
80 | } | 85 | } |
@@ -86,33 +91,34 @@ void SmtpClient::incomingData() | |||
86 | if (!socket->canReadLine()) | 91 | if (!socket->canReadLine()) |
87 | return; | 92 | return; |
88 | 93 | ||
89 | response = socket->readLine(); | 94 | response = socket->readLine(); |
90 | |||
91 | switch(status) { | 95 | switch(status) { |
92 | case Init: { | 96 | case Init: { |
93 | if (response[0] == '2') { | 97 | if (response[0] == '2') { |
94 | status = From; | 98 | status = From; |
95 | mailPtr = mailList.first(); | 99 | mailPtr = mailList.first(); |
96 | *stream << "HELO there\r\n"; | 100 | *stream << "HELO there\r\n"; |
97 | } else errorHandling(ErrUnknownResponse); | 101 | } else errorHandlingWithMsg(ErrUnknownResponse,response); |
98 | break; | 102 | break; |
99 | } | 103 | } |
100 | case From: { | 104 | case From: { |
101 | if (response[0] == '2') { | 105 | if (response[0] == '2') { |
102 | *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; | 106 | qDebug(mailPtr->from); |
107 | *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n"; | ||
103 | status = Recv; | 108 | status = Recv; |
104 | } else errorHandling(ErrUnknownResponse); | 109 | } else errorHandlingWithMsg(ErrUnknownResponse, response ); |
105 | break; | 110 | break; |
106 | } | 111 | } |
107 | case Recv: { | 112 | case Recv: { |
108 | if (response[0] == '2') { | 113 | if (response[0] == '2') { |
109 | it = mailPtr->to.begin(); | 114 | it = mailPtr->to.begin(); |
110 | if (it == NULL) | 115 | if (it == NULL) { |
111 | errorHandling(ErrUnknownResponse); | 116 | errorHandlingWithMsg(ErrUnknownResponse,response); |
112 | *stream << "RCPT TO: " << *it << ">\r\n"; | 117 | } |
118 | *stream << "RCPT TO: <" << *it << ">\r\n"; | ||
113 | status = MRcv; | 119 | status = MRcv; |
114 | } else errorHandling(ErrUnknownResponse); | 120 | } else errorHandlingWithMsg(ErrUnknownResponse,response); |
115 | break; | 121 | break; |
116 | } | 122 | } |
117 | case MRcv: { | 123 | case MRcv: { |
118 | if (response[0] == '2') { | 124 | if (response[0] == '2') { |
@@ -122,16 +128,17 @@ void SmtpClient::incomingData() | |||
122 | break; | 128 | break; |
123 | } else { | 129 | } else { |
124 | status = Data; | 130 | status = Data; |
125 | } | 131 | } |
126 | } else errorHandling(ErrUnknownResponse); | 132 | } else errorHandlingWithMsg(ErrUnknownResponse,response); |
127 | } | 133 | } |
128 | case Data: { | 134 | case Data: { |
129 | if (response[0] == '2') { | 135 | if (response[0] == '2') { |
130 | *stream << "DATA\r\n"; | 136 | *stream << "DATA\r\n"; |
131 | status = Body; | 137 | status = Body; |
132 | emit updateStatus(tr("Sending: ") + mailPtr->subject); | 138 | emit updateStatus(tr("Sending: ") + mailPtr->subject); |
133 | } else errorHandling(ErrUnknownResponse); | 139 | |
140 | } else errorHandlingWithMsg(ErrUnknownResponse,response); | ||
134 | break; | 141 | break; |
135 | } | 142 | } |
136 | case Body: { | 143 | case Body: { |
137 | if (response[0] == '3') { | 144 | if (response[0] == '3') { |
@@ -141,9 +148,9 @@ void SmtpClient::incomingData() | |||
141 | status = From; | 148 | status = From; |
142 | } else { | 149 | } else { |
143 | status = Quit; | 150 | status = Quit; |
144 | } | 151 | } |
145 | } else errorHandling(ErrUnknownResponse); | 152 | } else errorHandlingWithMsg(ErrUnknownResponse,response); |
146 | break; | 153 | break; |
147 | } | 154 | } |
148 | case Quit: { | 155 | case Quit: { |
149 | if (response[0] == '2') { | 156 | if (response[0] == '2') { |
@@ -155,9 +162,9 @@ void SmtpClient::incomingData() | |||
155 | emit mailSent(); | 162 | emit mailSent(); |
156 | mailList.clear(); | 163 | mailList.clear(); |
157 | sending = FALSE; | 164 | sending = FALSE; |
158 | socket->close(); | 165 | socket->close(); |
159 | } else errorHandling(ErrUnknownResponse); | 166 | } else errorHandlingWithMsg(ErrUnknownResponse,response); |
160 | break; | 167 | break; |
161 | } | 168 | } |
162 | } | 169 | } |
163 | } | 170 | } |