fix send_custom_status function. see #342

This commit is contained in:
Yann Leboulanger 2007-04-22 19:45:19 +00:00
parent ca7ff635d9
commit 55a4e6c977
3 changed files with 34 additions and 7 deletions

View File

@ -731,7 +731,33 @@ class Connection(ConnectionHandlers):
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)
@ -780,8 +806,7 @@ class Connection(ConnectionHandlers):
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 @@ class Connection(ConnectionHandlers):
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'''

View File

@ -283,7 +283,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
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

View File

@ -2848,7 +2848,10 @@ class RosterWindow:
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):