author | llornkcor <llornkcor> | 2003-06-09 01:37:23 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-06-09 01:37:23 (UTC) |
commit | 364e6e65b4c3b4ceec2b1b6688f2ca2b3dce4560 (patch) (unidiff) | |
tree | 1be5d3150c2bda4b3a55f9e7d2529d73fe6d72db /noncore/unsupported/mailit/smtpclient.cpp | |
parent | 5ee1c7dff5679454d46e3c5bd5747c60ea63c959 (diff) | |
download | opie-364e6e65b4c3b4ceec2b1b6688f2ca2b3dce4560.zip opie-364e6e65b4c3b4ceec2b1b6688f2ca2b3dce4560.tar.gz opie-364e6e65b4c3b4ceec2b1b6688f2ca2b3dce4560.tar.bz2 |
patch from wim delvaux. fix from me
Diffstat (limited to 'noncore/unsupported/mailit/smtpclient.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/smtpclient.cpp | 33 |
1 files changed, 20 insertions, 13 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 | |||
@@ -64,100 +64,107 @@ void SmtpClient::addMail(const QString &from, const QString &subject, const QStr | |||
64 | 64 | ||
65 | mailList.append(mail); | 65 | mailList.append(mail); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SmtpClient::connectionEstablished() | 68 | void SmtpClient::connectionEstablished() |
69 | { | 69 | { |
70 | emit updateStatus(tr("Connection established")); | 70 | emit updateStatus(tr("Connection established")); |
71 | 71 | ||
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 | } |
81 | 86 | ||
82 | void SmtpClient::incomingData() | 87 | void SmtpClient::incomingData() |
83 | { | 88 | { |
84 | QString response; | 89 | QString response; |
85 | 90 | ||
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') { |
119 | it++; | 125 | it++; |
120 | if ( it != mailPtr->to.end() ) { | 126 | if ( it != mailPtr->to.end() ) { |
121 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 127 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
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') { |
138 | *stream << mailPtr->body << "\r\n.\r\n"; | 145 | *stream << mailPtr->body << "\r\n.\r\n"; |
139 | mailPtr = mailList.next(); | 146 | mailPtr = mailList.next(); |
140 | if (mailPtr != NULL) { | 147 | if (mailPtr != NULL) { |
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') { |
150 | *stream << "QUIT\r\n"; | 157 | *stream << "QUIT\r\n"; |
151 | status = Done; | 158 | status = Done; |
152 | QString temp; | 159 | QString temp; |
153 | temp.setNum(mailList.count()); | 160 | temp.setNum(mailList.count()); |
154 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); | 161 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); |
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 | } |