[151] | 1 | <?php |
---|
| 2 | |
---|
| 3 | ini_set('include_path', $_SERVER['DOCUMENT_ROOT'] . '/instant_messenger/inc/'); |
---|
| 4 | |
---|
| 5 | require_once 'Jabber.abstract.php'; |
---|
| 6 | |
---|
| 7 | class Jabberd2 extends Jabber |
---|
| 8 | { |
---|
| 9 | final function connect($pUser = false, $pPassword = false) |
---|
| 10 | { |
---|
| 11 | try |
---|
| 12 | { |
---|
| 13 | if ( parent::connect($pUser, $pPassword) ) |
---|
| 14 | if ( $this->presence() ) |
---|
| 15 | return true; |
---|
| 16 | |
---|
| 17 | return false; |
---|
| 18 | } |
---|
| 19 | catch(Exception $e) |
---|
| 20 | { |
---|
| 21 | $this->writeLog('ERROR', $e->getMessage()); |
---|
| 22 | return false; |
---|
| 23 | } |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | function disconnect() |
---|
| 27 | { |
---|
| 28 | $this->_disconnect(); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | final function readSocket() |
---|
| 32 | { |
---|
| 33 | return $this->read(); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | final function writeSocket($pData) |
---|
| 37 | { |
---|
| 38 | return $this->write($pData); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | final function setPresence($pPresence) |
---|
| 42 | { |
---|
| 43 | $type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL; |
---|
| 44 | $to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL; |
---|
| 45 | $show = ( isset($pPresence['show']) ) ? $pPresence['show'] : NULL; |
---|
| 46 | $status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL; |
---|
| 47 | $priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL; |
---|
| 48 | |
---|
| 49 | $this->presence($type, $to, $show, $status, $priority); |
---|
| 50 | } |
---|
| 51 | /* |
---|
| 52 | * Vcard |
---|
| 53 | */ |
---|
| 54 | |
---|
| 55 | final function getVcard($pVcard) |
---|
| 56 | { |
---|
| 57 | $this->iq('get', $pVcard, $pVcard, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>"); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | final function newVcard($NewVcard) |
---|
| 61 | { |
---|
| 62 | $id = $_SESSION['phpgw_info']['instant_messenger']['user']; |
---|
| 63 | $this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard."</vCard>"); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /* |
---|
| 67 | * Contacts |
---|
| 68 | */ |
---|
| 69 | |
---|
| 70 | final function getContacts() |
---|
| 71 | { |
---|
| 72 | $this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster'); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | final function addContacts($pContact) |
---|
| 76 | { |
---|
| 77 | $addid = "adduser_" . time(); |
---|
| 78 | $this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $pContact); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | final function removeContact($pContact) |
---|
| 82 | { |
---|
| 83 | $delid = 'deluser_' . time(); |
---|
| 84 | $this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact."' subscription='remove'/>"); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | final function updateContact($pContact) |
---|
| 88 | { |
---|
| 89 | $upid = 'updateuser_' . time(); |
---|
| 90 | $this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $pContact); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | /* |
---|
| 94 | * Presence |
---|
| 95 | */ |
---|
| 96 | |
---|
| 97 | final function SubscriptionAcceptRequest($to = NULL) |
---|
| 98 | { |
---|
| 99 | $this->presence("subscribed", $to); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | final function SubscriptionDenyRequest($to = NULL) |
---|
| 103 | { |
---|
| 104 | $this->presence("unsubscribed", $to); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | final function Subscribe($to = NULL) |
---|
| 108 | { |
---|
| 109 | $this->presence("subscribe", $to); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | final function Unsubscribe($to = NULL) |
---|
| 113 | { |
---|
| 114 | $this->presence("unsubscribe", $to); |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | ?> |
---|