Changeset 305 for trunk/instant_messenger/inc/Jabberd2.abstract.php
- Timestamp:
- 06/06/08 13:54:09 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/inc/Jabberd2.abstract.php
r287 r305 7 7 class Jabberd2 extends Jabber 8 8 { 9 final function connect($pUser = false, $pPassword = false, $pConnectionType = false )9 final function connect($pUser = false, $pPassword = false, $pConnectionType = false, $pWebjabber = false ) 10 10 { 11 11 try 12 12 { 13 13 if ( $pUser && $pPassword && $pConnectionType ) 14 if ( $_connect = parent::connect($pUser, $pPassword, $pConnectionType ) )14 if ( $_connect = parent::connect($pUser, $pPassword, $pConnectionType, $pWebjabber) ) 15 15 return $_connect; 16 16 … … 48 48 */ 49 49 50 final function addContacts($pContact) 51 { 52 $jid = explode("@",$pContact['email']); 53 $jid = $jid[0]."@".$this->_server; 54 $name = $pContact['name']; 55 $group = $pContact['group']; 56 57 if(trim($jid[0]) != trim($this->_user)) 58 { 59 if ( $jid ) 50 final function addRoster($pRoster) 51 { 52 if ( !$this->connected ) 53 return "disconnected"; 54 55 if ( trim($pRoster['uid']) ) 56 { 57 $jid = $pRoster['uid'] . "@" . $this->_server; 58 59 $newroster = "<item jid='" . $jid . "'"; 60 $newroster .= " name='" . $pRoster['name'] . "'"; 61 $newroster .= "><group>" . $pRoster['group'] . "</group></item>"; 62 63 if ( $this->iq('set', "addroster_" . time(), NULL, NULL, "jabber:iq:roster", $newroster) ) 60 64 { 61 $newcontact = "<item jid='".$jid."'"; 62 $newcontact .= " name='" . $name . "'"; 63 $newcontact .= "><group>" . $group . "</group></item>"; 65 $this->getContacts(); 66 return true; 64 67 } 65 68 } 66 $addid = "adduser_" . time(); 67 if ( !$this->connected ) 68 echo "disconnected"; 69 else 70 { 71 if ( $this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact) ) 72 $this->getContacts(); 73 echo "OK"; 74 } 69 return false; 70 } 71 72 final function addContact($pContact) 73 { 74 $this->addRoster($pContact); 75 $this->subscription($pContact['uid'] . "@" . $this->_server, 'subscribe'); 75 76 } 76 77 … … 89 90 $jid = ( trim($pJid['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pJid['jid']; 90 91 $vcard = (trim($pJid['jid']) == "this") ? 'vCard_user' : 'vCard'; 91 92 92 93 if ( !$this->connected ) 93 94 { … … 120 121 final function removeContact($pContact) 121 122 { 122 $delid = 'deluser_' . time();123 123 if ( !$this->isConnected() ) 124 124 return "disconnected"; 125 126 if ( $this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact['jid']."' subscription='remove'/>") ) 127 if ( $this->subscription($pContact['jid'],"unsubscribed") ) 128 echo "OK"; 125 126 if ( $this->iq('set', 'delroster_' . time(), NULL, NULL, 'jabber:iq:roster',"<item jid='".$pContact['jid']."' subscription='remove'/>") ) 127 { 128 $this->getContacts(); 129 return true; 130 } 131 return false; 132 } 133 134 function allowContact($pRoster) 135 { 136 $this->addRoster($pRoster); 137 $jid = $pRoster['uid'] . "@" . $this->_server; 138 $this->subscription($jid, 'subscribed'); 139 $this->subscription($jid, 'subscribe'); 129 140 } 130 141 … … 141 152 return true; 142 153 } 143 }144 145 final function compression()146 {147 $compress = "<compress xmlns='http://jabber.org/protocol/compress'><method>zlib</method></compress>";148 $this->writeSocket($compress);149 154 } 150 155 … … 166 171 } 167 172 168 final function get_last_access_user($pUser)169 {170 $id = "last_time_user";171 $jid = ( trim($pUser['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pUser['jid'];172 $this->iq('get', $id, $jid, NULL, "jabber:iq:last");173 }174 175 173 final function setStatus() 176 174 { 177 175 $this->setPresence(array("type" => "unavailable")); 178 $this->setPresence(array("type" => "available")); 176 $this->setPresence(array("type" => "available")); 179 177 } 180 178
Note: See TracChangeset
for help on using the changeset viewer.