writeLog('ERROR', $e->getMessage()); return false; } } function closeSocket() { $this->close($this->_socket); } function disconnect() { $this->_disconnect(); } final function readSocket() { return $this->read(); } final function writeSocket($pData) { return $this->write($pData); } /* * Jabber - Functions */ final function addContacts($pContact) { $jid = explode("@",$pContact['email']); $jid = $jid[0]."@".$this->_server; $name = $pContact['name']; $group = $pContact['group']; if(trim($jid[0]) != trim($this->_user)) { if ( $jid ) { $newcontact = ""; } } $addid = "adduser_" . time(); if ( !$this->connected ) echo "disconnected"; else { if($this->writeSocket($this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact))) { $this->getContacts(); if($this->subscription($pContact['jid'],"subscribe")) echo "OK"; } } } final function getContacts() { $this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster'); } final function getVcard($pJid) { if(is_array($pJid)) { $jid = (trim($pJid['jid']) == "this") ? $this->_user . '@' . $this->_server : $pJid['jid']; if ( !$this->connected ) echo "disconnected"; else { $this->writeSocket($this->iq('get', 'vCard', $jid, NULL, "vcard-temp", "")); echo "OK"; } } else { $this->iq('get', 'vCard', $pJid, NULL, "vcard-temp", ""); } } final function newVcard($NewVcard) { $id = $this->_user; if ( !$this->connected ) echo "disconnected"; else { $this->writeSocket($this->iq('set', $id, NULL, NULL, "vcard-temp", "".$NewVcard['vcard']."")); echo "OK"; } } final function removeContact($pContact) { $delid = 'deluser_' . time(); if( !$this->connected ) echo "disconnected"; else { if($this->writeSocket($this->iq('set',$delid,NULL,NULL,"jabber:iq:roster",""))) { $this->getContacts(); if($this->subscription($pContact['jid'],"unsubscribed")) echo "OK"; } } } final function subscription($pTo, $pType = false) { $jid = (is_array($pTo)) ? $pTo['jid'] : $pTo ; $type = (is_array($pTo)) ? $pTo['type'] : $pType ; if ( !$this->connected ) return false; else { $this->writeSocket(""); return true; } } final function setPresence($pPresence = false) { if ( !$pPresence ) $this->presence(); $type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL; $to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL; $show = ( isset($pPresence['show']) ) ? $pPresence['show'] : NULL; $status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL; $priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL; $this->presence($type, $to, $show, $status, $priority); } final function updateContact($pContact) { $jid = $pContact['jid']; $name = $pContact['name']; $group = $pContact['group']; if ( $jid ) { $updatecontact = ""; } $upid = 'updateuser_' . time(); if ( !$this->connected ) echo "disconnected"; else { $this->writeSocket($this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact)); $this->getContacts(); echo "OK"; } } } ?>