/
Connection.php
117 lines (104 loc) · 2.72 KB
/
Connection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* Copyright 2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2013 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
/**
* Abstract interface for the object used to connect to remote mail server.
*
* NOTE: This class is NOT intended to be accessed outside of the package.
* There is NO guarantees that the API of this class will not change across
* versions.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2013 Horde LLC
* @internal
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*
* @property-read boolean $connected Is there a connection to the server?
* @property-read boolean $secure Is the connection secure?
*/
abstract class Horde_Imap_Client_Base_Connection
{
/**
* Is there a connection to the server?
*
* @var boolean
*/
protected $_connected = false;
/**
* Debug object.
*
* @var object
*/
protected $_debug;
/**
* Is the connection secure?
*
* @var boolean
*/
protected $_secure = false;
/**
* Constructor.
*
* @param Horde_Imap_Client_Base $base The base client object.
* @param object $debug The debug handler.
*
* @throws Horde_Imap_Client_Exception
*/
public function __construct(Horde_Imap_Client_Base $base, $debug)
{
if (($secure = $base->getParam('secure')) &&
!extension_loaded('openssl')) {
if ($secure !== true) {
throw new InvalidArgumentException('Secure connections require the PHP openssl extension.');
}
$base->setParam('secure', false);
}
$this->_debug = $debug;
}
/**
*/
public function __get($name)
{
switch ($name) {
case 'connected':
return $this->_connected;
case 'secure':
return $this->_secure;
}
}
/**
* This object can not be cloned.
*/
public function __clone()
{
throw new LogicException('Object cannot be cloned.');
}
/**
* This object can not be serialized.
*/
public function __sleep()
{
throw new LogicException('Object can not be serialized.');
}
/**
* Start a TLS connection to the server.
*
* @return boolean Whether TLS was successfully started.
*/
abstract public function startTls();
/**
* Close the connection to the server.
*/
abstract public function close();
}