Home » Developing U++ » U++ Developers corner » Pop3 class and reference examples for U++
Re: Pop3 class and reference examples for U++ [message #42611 is a reply to message #41753] |
Wed, 26 March 2014 18:31 |
Oblivion
Messages: 1093 Registered: August 2007
|
Senior Contributor |
|
|
Also I propose a change:
I was looking into the possibility of using TcpSocket::GetLine() instead of Pop3::GetDataLine() method and come up with the below modification.
You are the expert, so please comment if this is valid. (It seems so and works, but again, I am suspicious).
bool Pop3::PutGet(const String& s, bool multiline, bool nolog)
{
// Put() request.
if(!s.IsEmpty()) {
if(!nolog)
LLOG(">> " << TrimRight(s));
if(!PutAll(s)) {
LLOG("-- " << GetLastError());
return false;
}
}
// Get() response.
data.Clear();
String line = GetLine();
if(!line.IsVoid()) {
LLOG("<< " << line);
if(line.StartsWith("+OK")) {
if(!multiline) {
data.Cat(line);
return true;
}
else
for(;;) {
line = GetLine();
if(line.IsVoid()) // IsEmpty() cannot be used here.
break;
if(line == ".") {
LLOG("<< ...");
return true;
}
data.Cat(*line == '.' ? line.Mid(1) : line);
data.Cat("\r\n");
}
}
else
if(line.StartsWith("-ERR"))
error = line;
}
LLOG("-- " << GetLastError());
return false;
}
Basically, it appends the CRLF after downloading. This way, we can discard GetDataLine() method in favor of native TcpSocket method.
Regards.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Wed, 26 March 2014 18:35] Report message to a moderator
|
|
|
|
|
Pop3 class and reference examples for U++
By: Oblivion on Fri, 17 January 2014 01:49
|
|
|
Re: Pop3 class and reference examples for U++
By: koldo on Fri, 17 January 2014 08:12
|
|
|
Re: Pop3 class and reference examples for U++
By: mirek on Fri, 17 January 2014 08:27
|
|
|
Re: Pop3 class and reference examples for U++
By: Oblivion on Fri, 17 January 2014 12:00
|
|
|
Re: Pop3 class and reference examples for U++
By: mirek on Tue, 25 March 2014 10:07
|
|
|
Re: Pop3 class and reference examples for U++
By: mirek on Wed, 26 March 2014 10:34
|
|
|
Re: Pop3 class and reference examples for U++
By: Oblivion on Wed, 26 March 2014 12:37
|
|
|
Re: Pop3 class and reference examples for U++
By: Oblivion on Wed, 26 March 2014 18:31
|
|
|
Re: Pop3 class and reference examples for U++
By: mirek on Thu, 27 March 2014 08:45
|
|
|
Re: Pop3 class and reference examples for U++
By: Oblivion on Thu, 27 March 2014 15:24
|
|
|
Re: Pop3 class and reference examples for U++
By: mirek on Thu, 27 March 2014 15:38
|
|
|
Re: Pop3 class and reference examples for U++
By: Oblivion on Sun, 30 March 2014 01:48
|
|
|
Re: Pop3 class and reference examples for U++
By: mirek on Sun, 30 March 2014 09:29
|
|
|
Re: Pop3 class and reference examples for U++
By: Oblivion on Thu, 10 April 2014 01:24
|
|
|
Re: Pop3 class and reference examples for U++
By: Oblivion on Thu, 10 April 2014 16:14
|
|
|
Re: Pop3 class and reference examples for U++
By: mirek on Mon, 28 April 2014 17:48
|
|
|
Re: Pop3 class and reference examples for U++
By: Oblivion on Wed, 16 April 2014 03:00
|
Goto Forum:
Current Time: Mon Apr 29 04:20:01 CEST 2024
Total time taken to generate the page: 0.06516 seconds
|