Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Oblivion is currently offline  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.


[Updated on: Wed, 26 March 2014 18:35]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Value size ?
Next Topic: Skylark: Should escape character '$' be replaced to avoid name clash with Jquery?
Goto Forum:
  


Current Time: Mon Apr 29 04:20:01 CEST 2024

Total time taken to generate the page: 0.06516 seconds