Author: asterix
Date: 2007-04-22 21:45:19 +0200 (Sun, 22 Apr 2007)
New Revision: 8096
Modified:
trunk/src/common/connection.py
trunk/src/common/zeroconf/connection_zeroconf.py
trunk/src/roster_window.py
Log:
fix send_custom_status function. see #342
Modified: trunk/src/common/connection.py
===================================================================
--- trunk/src/common/connection.py 2007-04-22 18:21:30 UTC (rev 8095)
+++ trunk/src/common/connection.py 2007-04-22 19:45:19 UTC (rev 8096)
@@ -731,13 +731,39 @@
self.awaiting_answers[id] = (PRIVACY_ARRIVED, )
self.connection.send(iq)
- def change_status(self, show, msg, auto = False, to = None):
+ def send_custom_status(self, show, msg, jid):
if not show in STATUS_LIST:
return -1
+ if not self.connection:
+ return
sshow = helpers.get_xmpp_show(show)
if not msg:
msg = ''
keyID = gajim.config.get_per('accounts', self.name, 'keyid')
+ if show == 'offline':
+ p = common.xmpp.Presence(typ = 'unavailable')
+ p = self.add_sha(p, False)
+ if msg:
+ p.setStatus(msg)
+ else:
+ signed = self.get_signed_msg(msg)
+ priority = unicode(gajim.get_priority(self.name, sshow))
+ p = common.xmpp.Presence(typ = None, priority = priority, show = sshow,
+ to = jid)
+ p = self.add_sha(p)
+ if msg:
+ p.setStatus(msg)
+ if signed:
+ p.setTag(common.xmpp.NS_SIGNED + ' x').setData(signed)
+ self.connection.send(p)
+
+ def change_status(self, show, msg, auto = False):
+ if not show in STATUS_LIST:
+ return -1
+ sshow = helpers.get_xmpp_show(show)
+ if not msg:
+ msg = ''
+ keyID = gajim.config.get_per('accounts', self.name, 'keyid')
signed = ''
if not auto and not show == 'offline':
signed = self.get_signed_msg(msg)
@@ -780,8 +806,7 @@
self.connection.send(iq)
self.activate_privacy_rule('visible')
priority = unicode(gajim.get_priority(self.name, sshow))
- p = common.xmpp.Presence(typ = None, priority = priority, show = sshow,
- to = to)
+ p = common.xmpp.Presence(typ = None, priority = priority, show = sshow)
p = self.add_sha(p)
if msg:
p.setStatus(msg)
@@ -790,8 +815,7 @@
if self.connection:
self.connection.send(p)
self.priority = priority
- if not to:
- self.dispatch('STATUS', show)
+ self.dispatch('STATUS', show)
def _on_disconnected(self):
''' called when a disconnect request has completed successfully'''
Modified: trunk/src/common/zeroconf/connection_zeroconf.py
===================================================================
--- trunk/src/common/zeroconf/connection_zeroconf.py 2007-04-22 18:21:30 UTC (rev 8095)
+++ trunk/src/common/zeroconf/connection_zeroconf.py 2007-04-22 19:45:19 UTC (rev 8096)
@@ -283,7 +283,7 @@
else:
self.reannounce()
- def change_status(self, show, msg, sync = False, auto = False, to = None):
+ def change_status(self, show, msg, sync = False, auto = False):
if not show in STATUS_LIST:
return -1
self.status = show
Modified: trunk/src/roster_window.py
===================================================================
--- trunk/src/roster_window.py 2007-04-22 18:21:30 UTC (rev 8095)
+++ trunk/src/roster_window.py 2007-04-22 19:45:19 UTC (rev 8096)
@@ -2848,7 +2848,10 @@
gajim.sleeper_state[account] = 'online'
elif gajim.sleeper_state[account] not in ('autoaway', 'autoxa'):
gajim.sleeper_state[account] = 'off'
- gajim.connections[account].change_status(status, txt, auto, to = to)
+ if to:
+ gajim.connections[account].send_custom_status(status, txt, to)
+ else:
+ gajim.connections[account].change_status(status, txt, auto)
for gc_control in gajim.interface.msg_win_mgr.get_controls(
message_control.TYPE_GC):