diff --git a/reference/Layout/Layout.upp b/reference/Layout/Layout.upp index 7928d592d..ba70a2e66 100644 --- a/reference/Layout/Layout.upp +++ b/reference/Layout/Layout.upp @@ -1,4 +1,4 @@ -description "Using layouts for dialogs"; +description "Using layouts for dialogs\377"; uses CtrlLib; @@ -9,3 +9,4 @@ file mainconfig "" = "GUI"; + diff --git a/reference/Layout/init b/reference/Layout/init new file mode 100644 index 000000000..baac97a71 --- /dev/null +++ b/reference/Layout/init @@ -0,0 +1,4 @@ +#ifndef _Layout_icpp_init_stub +#define _Layout_icpp_init_stub +#include "CtrlLib/init" +#endif diff --git a/reference/Pop3/Pop3.cpp b/reference/Pop3/Pop3.cpp new file mode 100644 index 000000000..43d694326 --- /dev/null +++ b/reference/Pop3/Pop3.cpp @@ -0,0 +1,59 @@ +#include + +using namespace Upp; + +// WIN32: This example requires OpenSSL .dlls to be available + +CONSOLE_APP_MAIN +{ + Cout() << "Your GMail username: "; + String user = ReadStdIn(); + Cout() << "Your GMail password: "; + String pass = ReadStdIn(); + Pop3 pop3; + pop3.Host("pop.gmail.com") + .Port(995) + .User(user, pass) + .SSL() + .Trace(); // Activate logging of Pop3. + Cout() << "Connecting to GMail POP3 server... "; + if(!pop3.Login()) { + Cout() << "Failed: " << pop3.GetLastError() << "\n"; + return; + } + int msgcount = pop3.GetMessageCount(); + if(msgcount < 0) { + Cout() << "\nFailed: " << pop3.GetLastError() << "\n"; + pop3.Logout(); + return; + } + Cout() << "There are " << msgcount << " messages in your inbox.\n"; + for(;;) { + Cout() << "Message number to retrieve (1.." << msgcount << ") or anything else to QUIT:"; + int i = StrInt(ReadStdIn()); + if(i >= 1 && i <= msgcount) { + String message = pop3.GetMessage(i); + if(IsNull(message)) + Cout() << "An error encountered: " << pop3.GetLastError() << "\n"; + else { + InetMessage m; + if(m.Read(message)) { + Cout() << "Subject: " << m["subject"] << "\n" + << "From: " << m["from"] << "\n" + << "Date: " << m["date"] << "\n"; + for(int i = 0; i < m.GetPartCount(); i++) + Cout() << "========= Part " << i << ", type " + << Nvl(m.GetPartHeader(i, "content-type"), m["content-type"]) << "\n" + << m.GetPartBody(i); + Cout() << "-------------------------------------\n"; + } + else + Cout() << "Error parsing the message\n"; + } + } + else + break; + } + Cout() << "Logging out!..\n"; + pop3.Logout(); +} diff --git a/reference/Pop3/Pop3.upp b/reference/Pop3/Pop3.upp new file mode 100644 index 000000000..056c98194 --- /dev/null +++ b/reference/Pop3/Pop3.upp @@ -0,0 +1,12 @@ +description "Examples of using Core/POP3 package to download gmail emails\377"; + +uses + Core, + Core/POP3; + +file + Pop3.cpp; + +mainconfig + "" = "SSE2"; + diff --git a/reference/Pop3/init b/reference/Pop3/init new file mode 100644 index 000000000..1fb55a9bf --- /dev/null +++ b/reference/Pop3/init @@ -0,0 +1,5 @@ +#ifndef _Pop3_icpp_init_stub +#define _Pop3_icpp_init_stub +#include "Core/init" +#include "Core/POP3/init" +#endif