Qore Pop3Client Module Reference 1.9
Loading...
Searching...
No Matches
Pop3Client.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* Pop3Client.qm Copyright 2013 - 2023 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// minimum qore version
26
27// need mime definitions
28
29// need MailMessage classes
30
31// requires the ConnectionProvider module
32
33// assume local var scope, do not use "$" for vars, members, and method calls
34
35
122
128namespace Pop3Client {
131
134
136
150
151public:
153protected:
154 Socket sock();
155
156 // connect string
157 string connect;
158
159 // ensures exclusive access to the object
160 Mutex mutex();
161
162 // optional info log closure
163 *code log_info;
164
165 // optional debug log closure
166 *code log_debug;
167
168 // "tls" flag
169 bool tls = False;
170
171 // "starttls" flag
172 bool starttls = False;
173
174 // "noquit" flag
175 bool noquit = False;
176
177 // authentication credentials
178 string user;
179 string pass;
180
181 // logged in flag
182 bool logged_in = False;
183
184 // read timeout in milliseconds
185 timeout readTimeout = DefaultReadTimeout;
186
187 // connect timeout in milliseconds
188 timeout connectTimeout = DefaultConnectTimeout;
189
190 // log password
191 bool log_pass = False;
192
193 const MaxDebugLine = 2048;
194
195public:
197
199 const POP3Port = 110;
200
202 const POP3SPort = 995;
203
205 const Protocols = {
206 "pop3": {"tls": False, "port": POP3Port},
207 "pop3s": {"tls": True, "port": POP3SPort},
208 };
209
211
228 constructor(string url, *code log, *code dbglog);
229
230
232
235
236
238
240 string getTarget();
241
242
244
251 logPassword(bool pwd);
252
253
255
262
263
265
272 tls(bool n_tls);
273
274
276
282 bool tls();
283
284
286
293 starttls(bool n_starttls);
294
295
297
303 bool starttls();
304
305
307
314 noquit(bool n_noquit);
315
316
318
327 bool noquit();
328
329
331
344
345
347
358 *hash getMail();
359
360
362
377 hash stat();
378
379
381
396 *hash list();
397
398
400
411 del(softstring msg);
412
413
415
424 del(list l);
425
426
428
438
439
441
451
452
454
461
462
464
470
471
473
478 setReadTimeout(timeout to);
479
480
482
488
489
491
497
498
500
505 setConnectTimeout(timeout to);
506
507
509
515
516
518
524
525
527
535
536
538
548
549
551
581 nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
582
583
585
603 hash<auto> getUsageInfo();
604
605
607
617
618
620
636 setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data);
637
638
640
650
651
653 // don't reimplement this method; fix/enhance it in the module
654protected:
655 final disconnectIntern();
656public:
657
658
659 // don't reimplement this method; fix/enhance it in the module
660protected:
661 final MailMessage::Message retrIntern(softstring id);
662public:
663
664
665 // don't reimplement this method; fix/enhance it in the module
666protected:
667 final hash statIntern();
668public:
669
670
671 // don't reimplement this method; fix/enhance it in the module
672protected:
673 final *hash listIntern();
674public:
675
676
677 // read a line from the socket (terminated with \n)
678protected:
679 string readLine(timeout to);
680public:
681
682
683 // gets a trimmed one-line response from the server, throws an exception if an error response is received
684 // don't reimplement this method; fix/enhance it in the module
685protected:
686 final string getResponse();
687public:
688
689
690 // gets a trimmed multi-line response from the server, throws an exception if an error response is received
691 // don't reimplement this method; fix/enhance it in the module
692protected:
693 final list getResponseMulti();
694public:
695
696
697 // gets a multi-line response from the server, throws an exception if an error response is received
698 // does not include the first line in the response
699 // don't reimplement this method; fix/enhance it in the module
700protected:
701 final string getResponseMultiStr();
702public:
703
704
705protected:
706 log(string msg);
707public:
708
709
710protected:
711 logDbg(string msg);
712public:
713
714
715 // don't reimplement this method; fix/enhance it in the module
716protected:
717 final sendCommandIntern(string str, bool masked = False);
718public:
719
720
721 // don't reimplement this method; fix/enhance it in the module
722protected:
723 final list sendCommandMulti(string str);
724public:
725
726
727 // don't reimplement this method; fix/enhance it in the module
728protected:
729 final string sendCommandMultiStr(string str);
730public:
731
732
733 // don't reimplement this method; fix/enhance it in the module
734protected:
735 final string sendCommand(string str);
736public:
737
738
739 // don't reimplement this method; fix/enhance it in the module
740protected:
741 final string sendCommandMasked(string str);
742public:
743
744
745protected:
746 loginIntern(string r);
747public:
748
749
750protected:
751 doSSLIntern();
752public:
753
754
755 // when this method returns without an exception, the object is in the TRANSACTION state
756protected:
757 connectIntern();
758public:
759
760
761protected:
762 forceDisconnectIntern();
763public:
764
766};
767
769
776
777public:
779 const ConnectionScheme = <ConnectionSchemeInfo>{
780 "cls": Class::forName("Pop3Connection"),
781 };
782
784
794 constructor(string name, string description, string url, hash attributes = {}, hash options = {})
795 ;
796
797
799 string getType();
800
801
803
807 *hash<auto> getRuntimeOptions();
808
809
811
818protected:
819 Pop3Client getImpl(bool connect = True, *hash rtopts);
820public:
821
822
824protected:
825 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
826public:
827
828};
829};
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
del(list l)
sends a "DELE" command (http://tools.ietf.org/html/rfc1939#page-8) to the POP3 server to mark the giv...
setConnectTimeout(timeout to)
sets the connect timeout
connect()
Connect to the server with the connection parameters set in the constructor()
reset()
send a "RSET" command (http://tools.ietf.org/html/rfc1939#page-9) to the POP3 server which will unmar...
noquit(bool n_noquit)
sets the "noquit" flag
starttls(bool n_starttls)
sets the flag for using the "STLS" command after connecting (RFC 2595); this is only used if the TLS/...
destructor()
disconnects if connected and destroys the object
setReadTimeout(timeout to)
sets the read timeout
setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data)
Sets a Queue object to receive socket events.
bool tls()
returns the TLS/SSL flag
bool starttls()
returns the "starttls" flag (RFC 2595)
logPassword(bool pwd)
log password
int getConnectTimeoutMs()
returns the connect timeout as an integer giving milliseconds
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
setEventQueue()
Removes any Queue object so that socket events are no longer added to the Queue.
hash< auto > getUsageInfo()
Returns performance statistics for the socket.
*hash list()
returns a hash with message information from the "LIST" command (http://tools.ietf....
constructor(string url, *code log, *code dbglog)
creates the Pop3Client object
hash stat()
returns a hash with status information from the "STAT" command (http://tools.ietf....
bool isConnected()
return connection status
disconnect()
disconnect from the server
tls(bool n_tls)
sets the TLS/SSL flag
del(softstring msg)
sends a "DELE" command (http://tools.ietf.org/html/rfc1939#page-8) to the POP3 server to mark the giv...
noop()
send a "NOOP" command (http://tools.ietf.org/html/rfc1939#page-9) to the POP3 server
date getConnectTimeoutDate()
returns the connect timeout as a relative time value
bool logPassword()
returns the log password flag
bool noquit()
return the "noquit" flag; if this flag is True, then no "QUIT" command is sent to the POP3 server whe...
date getReadTimeoutDate()
returns the read timeout as a relative time value
clearStats()
Clears performance statistics.
*hash getMail()
returns a hash of mail messages keyed by message ID or NOTHING if no messages are available on the se...
string getTarget()
Returns the connection target string.
forceDisconnect()
force disconnect of socket without error
int getReadTimeoutMs()
returns the read timeout as an integer giving milliseconds
class for POP3 connections; returns an object of class Pop3Client for receiving or polling for emails
Definition: Pop3Client.qm.dox.h:775
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
const ConnectionScheme
Connection entry info.
Definition: Pop3Client.qm.dox.h:779
string getType()
returns "pop3"
*hash< auto > getRuntimeOptions()
returns runtime options
Pop3Client getImpl(bool connect=True, *hash rtopts)
returns a Pop3Client object
constructor(string name, string description, string url, hash attributes={}, hash options={})
creates the RestConnection connection object
the main namespace for the Pop3Client module
Definition: Pop3Client.qm.dox.h:128
const DefaultConnectTimeout
30 second connect timeout
Definition: Pop3Client.qm.dox.h:133
const DefaultReadTimeout
15 second read timeout
Definition: Pop3Client.qm.dox.h:130