-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wrapper.php
114 lines (98 loc) · 2.12 KB
/
Wrapper.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
<?php
/**
* Skype API Wrapper
*
* PHP versions 5.4
*
* @author П$ix <[email protected]>
*/
namespace SkypeWrapper;
require_once 'SkypeWrapper.php';
require_once 'drivers/Driver.php';
class Wrapper {
/**
*
* @var \SkypeWrapper\SkypeWrapper
*/
protected static $objWrapper = null;
/**
*
* @param string $strIdenty
* @param int $nProtocol
* @param bool $bDebugMode
* @return \SkypeWrapper\SkypeWrapper
* @throws \Exception
*/
public static function initWrapper($strIdenty, $nProtocol = self::DEFAULT_PROTOCOL, $bDebugMode = false)
{
return self::$objWrapper = new SkypeWrapper($strIdenty, $nProtocol, $bDebugMode);
}
/**
*
* @return \SkypeWrapper\SkypeWrapper
*/
public static function getWrapper() {
return self::$objWrapper;
}
// ---
// Driver factory
// ---
/**
*
* @var \SkypeWrapper\drivers\Driver
*/
protected static $objDriver = null;
protected static $arrDrivers = array(
'DbusDriver',
'ComDriver'
);
/**
*
* @param string $strIdenty
* @param int $nProtocol
* @param bool $bDebugMode
* @throws \Exception
*/
public static function initDriver($strIdenty, $nProtocol = self::DEFAULT_PROTOCOL, $bDebugMode = false)
{
foreach (self::$arrDrivers as $strDrivrClassName) {
$strDrivrClassName = "SkypeWrapper\\drivers\\".$strDrivrClassName;
if($strDrivrClassName::test())
{
self::$objDriver = new $strDrivrClassName($strIdenty, $nProtocol, $bDebugMode);
return;
}
}
throw new \Exception('not one of the drivers can\'t use');
}
/**
*
* @return \SkypeWrapper\drivers\Driver
*/
public static function getDriver()
{
if(self::$objDriver)
return self::$objDriver;
throw new \Exception('driver not inited');
}
// ---
// Debug mode
// ---
protected static $bDebugMode;
public static function setDebugMode($bDebugMode = false)
{
self::$bDebugMode = $bDebugMode;
}
public static function isDebug() {
return self::$bDebugMode;
}
public static function _debug($format) {
if (self::$bDebugMode == false) {
return;
}
$args = func_get_args();
array_shift($args);
vprintf($format, $args);
}
}
?>