Changeset 323


Ignore:
Timestamp:
06/20/08 15:16:25 (16 years ago)
Author:
niltonneto
Message:
 
Location:
trunk/instant_messenger
Files:
6 edited

Legend:

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

    r311 r323  
    171171        } 
    172172 
    173         final function get_last_access_user($pUser) 
     173        final function get_last_access_user($pUser = array("jid" => "this")) 
    174174        { 
    175175                $id = "last_time_user"; 
  • trunk/instant_messenger/inc/class.Ujabber.inc.php

    r318 r323  
    5959                        return "disconnected"; 
    6060 
    61                 $this->get_last_access_user(array("jid" => "this")); 
    62  
    6361                if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) 
    6462                { 
     
    7674                        $buffer = ''; 
    7775 
    78                         while ( ( connection_aborted() === 0 ) && time() - $init < 30 ) 
     76                        while ( ( connection_aborted() === 0 ) && time() - $init < 50 ) 
    7977                        { 
    8078                                # read from server and write in the client 
     
    106104        } 
    107105 
     106        public final function checkConnection() 
     107        { 
     108                $this->get_last_access_user(); 
     109                return $this->isConnected(); 
     110        } 
     111 
    108112        public final function Composing($pJid) 
    109113        { 
  • trunk/instant_messenger/inc/controller.xml

    r318 r323  
    5858                        <item ref="composing" class="Ujabber" method="composing" prefix="class." suffix=".inc.php" /> 
    5959                        <item ref="paused" class="Ujabber" method="paused" prefix="class." suffix=".inc.php" /> 
     60                        <item ref="checkConnection" class="Ujabber" method="checkConnection" prefix="class." suffix=".inc.php" /> 
    6061                </php> 
    6162                <xml></xml> 
  • trunk/instant_messenger/js/client.js

    r321 r323  
    149149                        if ( !_disconnected ) 
    150150                        { 
    151                                 _conn.go('$this.Ujabber.getContacts', 
    152                                         function(data) 
    153                                         { 
    154                                                 if ( data == 'disconnected' ) 
    155                                                         setTimeout(_contacts, 3000); 
    156                                         } 
    157                                 ); 
     151                                _conn.go('$this.Ujabber.getContacts'); 
    158152                                setTimeout(function() 
    159153                                { 
     
    294288                } 
    295289 
     290                function _check_connection() 
     291                { 
     292                        if ( !_disconnected ) 
     293                                _conn.go('t.checkConnection'); 
     294                } 
     295 
    296296                function Client() 
    297297                { 
    298298                        _request(); 
    299299                        setTimeout(_contacts, 3000); 
     300                        window.setInterval(_check_connection, 20000); 
    300301                } 
    301302 
  • trunk/instant_messenger/js/jabber.js

    r321 r323  
    381381                        _pPresence = arguments[0]; 
    382382 
    383                 _cookies.set('IM_presence', _pPresence); 
     383                if ( _pPresence == 'auto' ) 
     384                { 
     385                        if ( _cookies.get('IM_presence') == 'available' ) 
     386                                _pPresence = 'xa'; 
     387                } 
     388                else 
     389                        _cookies.set('IM_presence', _pPresence); 
    384390 
    385391                switch ( _pPresence ) 
     
    812818        Jabber.prototype.setPresence = _setPresence; 
    813819        window.Jabber = Jabber; 
     820        window.InstantMessengerPresence = _setPresence; 
    814821} 
    815822)(); 
  • trunk/instant_messenger/js/preferences.js

    r318 r323  
    77        var     _window         = new Windows(_xtools, _im_content); 
    88        var _cookies    = new IMCookies; 
    9         var idTimeout   = ""; 
    109        var Timeout             = ""; 
    1110 
     
    3736                _win_preferences.bx.style.display = 'none'; 
    3837                _win_preferences.wc.style.padding = '5px'; 
    39                  
     38 
    4039                var _params = { 
    4140                        'lang1':imGetLang('Options'), 
     
    7675                var preferences = arguments[0].split(';'); 
    7776                        preferences.pop(); 
    78                  
     77 
    7978                for(var i in preferences) 
    8079                { 
     
    9493                        else 
    9594                        { 
    96                                 Timeout = ( parseInt(value) > 0 ) ? value : "1";  
     95                                Timeout = ( parseInt(value) > 0 ) ? value : "1"; 
    9796                                if( top.document.getElementById(field) ) 
    9897                                        top.document.getElementById(field).value = Timeout; 
     
    104103        { 
    105104                var preferences = ""; 
    106                  
     105 
    107106                if((preferences = _cookies.get('preferences_im'))) 
    108107                        _preferences(preferences); 
     
    114113        { 
    115114                _win_preferences = _window.get('preferences_window'); 
    116          
     115 
    117116                var preferences = ""; 
    118117                var numbers = /^\d+$/; 
    119                  
     118 
    120119                // Offline 
    121120        if (top.document.getElementById('ch_offline').checked) 
     
    129128                        _cookies.set('IM_unavailable', 'hidden'); 
    130129                } 
    131          
     130 
    132131                // TimeOut 
    133132                if(numbers.test(top.document.getElementById('time_xa_im').value) && top.document.getElementById('time_xa_im').value != "0") 
     
    141140                        Timeout = 1; 
    142141                } 
    143         
     142 
    144143                // New Message 
    145144                if(top.document.getElementById('rd_nm').checked) 
     
    150149                else 
    151150                        preferences += 'rd_nm:false;'; 
    152          
     151 
    153152                if(top.document.getElementById('rd_ch').checked) 
    154153                { 
     
    175174        } 
    176175 
    177         function _setPresence() 
    178         { 
    179                 var _presence = false; 
    180                 var _pPresence; 
    181                 if ( arguments.length == 0 ) 
    182                 { 
    183                         if ( !(_pPresence = _cookies.get('IM_presence')) ) 
    184                                 _pPresence = 'available'; 
    185                 } 
    186                 else 
    187                         _pPresence = arguments[0]; 
    188  
    189                 _cookies.set('IM_presence', _pPresence); 
    190  
    191                 switch ( _pPresence ) 
    192                 { 
    193                         case 'away': 
    194                         case 'dnd': 
    195                         case 'xa': 
    196                                 _presence = 'show=' + _pPresence; 
    197                         break; 
    198                         case 'available': 
    199                         case 'unavailable': 
    200                                 _presence = 'type=' + _pPresence; 
    201                         break; 
    202                 } 
    203  
    204                 if ( _presence ) 
    205                 { 
    206                         var _img_status = eval('im_' + _pPresence + '.src'); 
    207  
    208                         var _status = top.document.getElementById('im_status'); 
    209                         if ( _status ) 
    210                                 _status.style.backgroundImage = 'url(' + _img_status + ')'; 
    211  
    212                         var _win_contacts = _window.get('contact_list'); 
    213                         if ( _win_contacts ) 
    214                                 _win_contacts.icon(_img_status); 
    215  
    216                         _conn.go('$this.Ujabber.setPresence', _presence); 
    217                 } 
    218         } 
    219  
     176        var _changed = false; 
     177        var _id_timeout = ""; 
    220178        function _setTimeOut() 
    221179        { 
    222                 _setPresence('xa'); 
    223                 idTimeout = setTimeout('top.window.im_preferences.timeOut();', parseInt(Timeout) * 60000); 
     180                _changed = true; 
     181                InstantMessengerPresence('auto'); 
    224182        } 
    225183 
    226184        function _timeOut() 
    227185        { 
    228                 if(idTimeout) 
    229                 { 
    230                         clearTimeout(idTimeout); 
    231                         var _status = ''; 
    232                  
    233                         if((_status = _cookies.get('IM_presence')) === 'xa') 
    234                                 _setPresence('available'); 
    235                 } 
    236                  
    237                 idTimeout = setTimeout('top.window.im_preferences._setTimeOut("xa");', parseInt(Timeout) * 60000); 
     186                if ( _id_timeout ) 
     187                        clearTimeout(_id_timeout); 
     188 
     189                if ( _changed ) 
     190                { 
     191                        _changed = false; 
     192                        InstantMessengerPresence(); 
     193                } 
     194 
     195                _id_timeout = setTimeout(_setTimeOut, parseInt(Timeout) * 60000); 
    238196        } 
    239197 
     
    243201                _timeOut(); 
    244202        } 
    245          
     203 
    246204        Preferences.prototype._setTimeOut        = _setTimeOut; 
    247205        Preferences.prototype.timeOut            = _timeOut; 
     
    249207        Preferences.prototype.getfocus           = focus_select; 
    250208        top.window.im_preferences                        = new Preferences; 
    251         top.window.document.onmousemove          = _timeOut; 
     209        _config(top.window.document, 'onmousemove', _timeOut); 
    252210 
    253211})(); 
Note: See TracChangeset for help on using the changeset viewer.