Pop3Client.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file Pop3Client.qm POP3 client module definition
/* Pop3Client.qm Copyright 2013 - 2017 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// minimum qore version
// need mime definitions
// need MailMessage classes
// requires the ConnectionProvider module
// assume local var scope, do not use "$" for vars, members, and method calls
namespace Pop3Client {
const DefaultReadTimeout = 15s;
const DefaultConnectTimeout = 30s;
class Pop3Client {
public:
private :
Socket sock();
// connect string
string connect;
// ensures exclusive access to the object
Mutex mutex();
// optional info log closure
*code log_info;
// optional debug log closure
*code log_debug;
// "tls" flag
bool tls = False;
// "starttls" flag
bool starttls = False;
// "noquit" flag
bool noquit = False;
// authentication credentials
string user;
string pass;
// logged in flag
bool logged_in = False;
// read timeout in milliseconds
timeout readTimeout = DefaultReadTimeout;
// connect timeout in milliseconds
timeout connectTimeout = DefaultConnectTimeout;
// log password
bool log_pass = False;
const MaxDebugLine = 2048;
public:
public :
const POP3Port = 110;
const POP3SPort = 995;
const Protocols = (
"pop3": ("tls": False, "port": POP3Port),
"pop3s": ("tls": True, "port": POP3SPort),
);
public:
constructor(string url, *code log, *code dbglog);
destructor();
logPassword(bool pwd);
bool logPassword();
tls(bool n_tls);
bool tls();
starttls(bool n_starttls);
bool starttls();
noquit(bool n_noquit);
bool noquit();
connect();
*hash getMail();
hash stat();
*hash list();
del(softstring msg);
del(list l);
noop();
reset();
bool isConnected();
disconnect();
setReadTimeout(timeout to);
int getReadTimeoutMs();
date getReadTimeoutDate();
setConnectTimeout(timeout to);
int getConnectTimeoutMs();
date getConnectTimeoutDate();
forceDisconnect();
nothing clearWarningQueue();
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
hash getUsageInfo();
clearStats();
// don't reimplement this method; fix/enhance it in the module
private:
final disconnectIntern();
public:
// don't reimplement this method; fix/enhance it in the module
private:
final MailMessage::Message retrIntern(softstring id);
public:
// don't reimplement this method; fix/enhance it in the module
private:
final hash statIntern();
public:
// don't reimplement this method; fix/enhance it in the module
private:
final *hash listIntern();
public:
// read a line from the socket (terminated with \n)
private:
string readLine(timeout to);
public:
// gets a trimmed one-line response from the server, throws an exception if an error response is received
// don't reimplement this method; fix/enhance it in the module
private:
final string getResponse();
public:
// gets a trimmed multi-line response from the server, throws an exception if an error response is received
// don't reimplement this method; fix/enhance it in the module
private:
final list getResponseMulti();
public:
// gets a multi-line response from the server, throws an exception if an error response is received
// does not include the first line in the response
// don't reimplement this method; fix/enhance it in the module
private:
final string getResponseMultiStr();
public:
private:
log(string msg);
public:
private:
logDbg(string msg);
public:
// don't reimplement this method; fix/enhance it in the module
private:
final sendCommandIntern(string str, bool masked = False);
public:
// don't reimplement this method; fix/enhance it in the module
private:
final list sendCommandMulti(string str);
public:
// don't reimplement this method; fix/enhance it in the module
private:
final string sendCommandMultiStr(string str);
public:
// don't reimplement this method; fix/enhance it in the module
private:
final string sendCommand(string str);
public:
// don't reimplement this method; fix/enhance it in the module
private:
final string sendCommandMasked(string str);
public:
private:
loginIntern(string r);
public:
private:
doSSLIntern();
public:
// when this method returns without an exception, the object is in the TRANSACTION state
private:
connectIntern();
public:
private:
forceDisconnectIntern();
public:
};
class Pop3Connection : public ConnectionProvider::AbstractConnection {
public:
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
string getType();
*hash getRuntimeOptions();
private:
Pop3Client getImpl(bool connect = True, *hash rtopts);
public:
static Pop3Connection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
};
};
ConnectionProvider::AbstractConnection::monitor
bool monitor
date
date date(date dt)
stat
*list stat(string path)
Pop3Client::Pop3Connection
class for POP3 connections; returns an object of class Pop3Client for receiving or polling for emails...
Definition: Pop3Client.qm.dox.h:739
MailMessage::Message
Pop3Client::DefaultConnectTimeout
const DefaultConnectTimeout
30 second connect timeout
Definition: Pop3Client.qm.dox.h:114
ConnectionProvider::AbstractConnection::opts
*hash opts
Pop3Client::Pop3Connection::constructor
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
creates the Pop3Connection object
True
const True
ConnectionProvider::AbstractConnection::name
string name
ConnectionProvider::AbstractConnection::urlh
hash urlh
False
const False
Pop3Client
the main namespace for the Pop3Client module
Definition: Pop3Client.qm.dox.h:109
list
list list(...)
Pop3Client::Pop3Connection::getImpl
Pop3Client getImpl(bool connect=True, *hash rtopts)
returns a Pop3Client object
ConnectionProvider::AbstractConnection
Pop3Client::Pop3Connection::make
static Pop3Connection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
static constructor
Pop3Client::Pop3Connection::getRuntimeOptions
*hash getRuntimeOptions()
returns runtime options
Pop3Client::Pop3Connection::getType
string getType()
returns "pop3"
ConnectionProvider::AbstractConnection::desc
string desc
ConnectionProvider::AbstractConnection::url
string url
hash
hash hash(object obj)
Pop3Client::DefaultReadTimeout
const DefaultReadTimeout
15 second read timeout
Definition: Pop3Client.qm.dox.h:111