Ignore:
Timestamp:
06/06/08 13:54:09 (16 years ago)
Author:
niltonneto
Message:

Correçoes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/instant_messenger/inc/Jabberd2.abstract.php

    r287 r305  
    77class Jabberd2 extends Jabber 
    88{ 
    9         final function connect($pUser = false, $pPassword = false, $pConnectionType = false) 
     9        final function connect($pUser = false, $pPassword = false, $pConnectionType = false, $pWebjabber = false ) 
    1010        { 
    1111                try 
    1212                { 
    1313                        if ( $pUser && $pPassword && $pConnectionType ) 
    14                                 if ( $_connect = parent::connect($pUser, $pPassword, $pConnectionType) ) 
     14                                if ( $_connect = parent::connect($pUser, $pPassword, $pConnectionType, $pWebjabber) ) 
    1515                                        return $_connect; 
    1616 
     
    4848         */ 
    4949 
    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) ) 
    6064                        { 
    61                                 $newcontact  = "<item jid='".$jid."'"; 
    62                                 $newcontact .= " name='" . $name . "'"; 
    63                                 $newcontact .= "><group>" . $group . "</group></item>"; 
     65                                $this->getContacts(); 
     66                                return true; 
    6467                        } 
    6568                } 
    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'); 
    7576        } 
    7677 
     
    8990                        $jid = ( trim($pJid['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pJid['jid']; 
    9091                        $vcard = (trim($pJid['jid']) == "this") ? 'vCard_user' : 'vCard'; 
    91                          
     92 
    9293                        if ( !$this->connected ) 
    9394                        { 
     
    120121        final function removeContact($pContact) 
    121122        { 
    122                 $delid  = 'deluser_' . time(); 
    123123                if ( !$this->isConnected() ) 
    124124                        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'); 
    129140        } 
    130141 
     
    141152                        return true; 
    142153                } 
    143         } 
    144  
    145         final function compression() 
    146         { 
    147                 $compress = "<compress xmlns='http://jabber.org/protocol/compress'><method>zlib</method></compress>";    
    148                 $this->writeSocket($compress); 
    149154        } 
    150155 
     
    166171        } 
    167172 
    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  
    175173        final function setStatus() 
    176174        { 
    177175                $this->setPresence(array("type" => "unavailable")); 
    178                 $this->setPresence(array("type" => "available"));        
     176                $this->setPresence(array("type" => "available")); 
    179177        } 
    180178 
Note: See TracChangeset for help on using the changeset viewer.