All Classes Namespaces Functions Variables Groups Pages
Pop3Client.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file Pop3Client.qm POP3 client module definition
/* Pop3Client.qm Copyright 2013 - 2015 David Nichols
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
// assume local var scope, do not use "$" for vars, members, and method calls
/* Version History
* 2015-11-11 v1.4: David Nichols <david@qore.org>
+ converted to new-style
* 2014-02-04 v1.3: David Nichols <david@qore.org>
+ added socket instrumention support from Qore 0.8.9
* 2013-05-22 v1.2: David Nichols <david@qore.org>
+ uncommented the "connected" debug message
* 2012-11-03 v1.1: David Nichols <david@qore.org>
+ added the logPassword() methods and masked password by default in the debug log
* 2012-09-04 v1.0: David Nichols <david@qore.org>
+ doc updates only
* 2012-06-12 v1.0: David Nichols <david@qore.org>
+ initial release
based on:
- http://tools.ietf.org/html/rfc1939 (POP3)
*/
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, any arg, timeout min_ms = 1s);
hash getUsageInfo();
clearStats();
// don't reimplement this method; fix/enhance it in the module
final private disconnectIntern();
// don't reimplement this method; fix/enhance it in the module
final private MailMessage::Message retrIntern(softstring id);
// don't reimplement this method; fix/enhance it in the module
final private hash statIntern();
// don't reimplement this method; fix/enhance it in the module
final private *hash listIntern();
// read a line from the socket (terminated with \n)
private string readLine(timeout to);
// 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
final private string getResponse();
// 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
final private list getResponseMulti();
// 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
final private string getResponseMultiStr();
private log(string msg);
private logDbg(string msg);
// don't reimplement this method; fix/enhance it in the module
final private sendCommandIntern(string str, bool masked = False);
// don't reimplement this method; fix/enhance it in the module
final private list sendCommandMulti(string str);
// don't reimplement this method; fix/enhance it in the module
final private string sendCommandMultiStr(string str);
// don't reimplement this method; fix/enhance it in the module
final private string sendCommand(string str);
// don't reimplement this method; fix/enhance it in the module
final private string sendCommandMasked(string str);
private loginIntern(string r);
private doSSLIntern();
// when this method returns without an exception, the object is in the TRANSACTION state
private connectIntern();
private forceDisconnectIntern();
};
};
date
date date(date dt)
Pop3Client::Pop3Client::disconnect
disconnect()
disconnect from the server
Pop3Client::Pop3Client::isConnected
bool isConnected()
return connection status
Pop3Client::Pop3Client::setReadTimeout
setReadTimeout(timeout to)
sets the read timeout
Pop3Client::Pop3Client::starttls
bool starttls()
returns the &quot;starttls&quot; flag (RFC 2595)
Pop3Client::Pop3Client::getConnectTimeoutMs
int getConnectTimeoutMs()
returns the connect timeout as an integer giving milliseconds
Pop3Client::Pop3Client::setWarningQueue
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
MailMessage::Message
Pop3Client::DefaultConnectTimeout
const DefaultConnectTimeout
30 second connect timeout
Definition: Pop3Client.qm.dox.h:102
Pop3Client::Pop3Client
This class provides the interface to POP3 servers and supports optional TLS/SSL encryption.
Definition: Pop3Client.qm.dox.h:118
True
const True
False
const False
Pop3Client::Pop3Client::list
*hash list()
returns a hash with message information from the &quot;LIST&quot; command (http://tools.ietf.org/html/rfc1939#page-6)
Pop3Client::Pop3Client::forceDisconnect
forceDisconnect()
force disconnect of socket without error
Pop3Client::Pop3Client::del
del(softstring msg)
sends a &quot;DELE&quot; command (http://tools.ietf.org/html/rfc1939#page-8) to the POP3 server to mark the giv...
Pop3Client::Pop3Client::logPassword
bool logPassword()
returns the log password flag
Pop3Client::Pop3Client::clearWarningQueue
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
Pop3Client::Pop3Client::getUsageInfo
hash getUsageInfo()
Returns performance statistics for the socket.
Pop3Client::Pop3Client::connect
connect()
Connect to the server with the connection parameters set in the constructor()
Pop3Client::Pop3Client::getReadTimeoutMs
int getReadTimeoutMs()
returns the read timeout as an integer giving milliseconds
Pop3Client::Pop3Client::getMail
*hash getMail()
returns a hash of mail messages keyed by message ID or NOTHING if no messages are available on the se...
Pop3Client::Pop3Client::noquit
bool noquit()
return the &quot;noquit&quot; flag; if this flag is True, then no &quot;QUIT&quot; command is sent to the POP3 server whe...
Pop3Client::Pop3Client::setConnectTimeout
setConnectTimeout(timeout to)
sets the connect timeout
Pop3Client::Pop3Client::noop
noop()
send a &quot;NOOP&quot; command (http://tools.ietf.org/html/rfc1939#page-9) to the POP3 server ...
Pop3Client::Pop3Client::Protocols
const Protocols
accepted protocols
Definition: Pop3Client.qm.dox.h:175
Pop3Client::Pop3Client::stat
hash stat()
returns a hash with status information from the &quot;STAT&quot; command (http://tools.ietf.org/html/rfc1939#page-6)
Pop3Client::Pop3Client::POP3Port
const POP3Port
default POP3 port
Definition: Pop3Client.qm.dox.h:169
Pop3Client::Pop3Client::clearStats
clearStats()
Clears performance statistics.
Pop3Client::Pop3Client::getReadTimeoutDate
date getReadTimeoutDate()
returns the read timeout as a relative time value
Pop3Client::Pop3Client::getConnectTimeoutDate
date getConnectTimeoutDate()
returns the connect timeout as a relative time value
Pop3Client::Pop3Client::constructor
constructor(string url, *code log, *code dbglog)
creates the Pop3Client object
hash
hash hash(object obj)
Pop3Client::DefaultReadTimeout
const DefaultReadTimeout
15 second read timeout
Definition: Pop3Client.qm.dox.h:99
Pop3Client::Pop3Client::reset
reset()
send a &quot;RSET&quot; command (http://tools.ietf.org/html/rfc1939#page-9) to the POP3 server which will unmar...
Pop3Client::Pop3Client::tls
bool tls()
returns the TLS/SSL flag
Pop3Client::Pop3Client::destructor
destructor()
disconnects if connected and destroys the object
Pop3Client::Pop3Client::POP3SPort
const POP3SPort
default POP3S port
Definition: Pop3Client.qm.dox.h:172