fix send_custom_status function. see #342
This commit is contained in:
parent
ca7ff635d9
commit
55a4e6c977
|
@ -731,7 +731,33 @@ class Connection(ConnectionHandlers):
|
||||||
self.awaiting_answers[id] = (PRIVACY_ARRIVED, )
|
self.awaiting_answers[id] = (PRIVACY_ARRIVED, )
|
||||||
self.connection.send(iq)
|
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:
|
if not show in STATUS_LIST:
|
||||||
return -1
|
return -1
|
||||||
sshow = helpers.get_xmpp_show(show)
|
sshow = helpers.get_xmpp_show(show)
|
||||||
|
@ -780,8 +806,7 @@ class Connection(ConnectionHandlers):
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
self.activate_privacy_rule('visible')
|
self.activate_privacy_rule('visible')
|
||||||
priority = unicode(gajim.get_priority(self.name, sshow))
|
priority = unicode(gajim.get_priority(self.name, sshow))
|
||||||
p = common.xmpp.Presence(typ = None, priority = priority, show = sshow,
|
p = common.xmpp.Presence(typ = None, priority = priority, show = sshow)
|
||||||
to = to)
|
|
||||||
p = self.add_sha(p)
|
p = self.add_sha(p)
|
||||||
if msg:
|
if msg:
|
||||||
p.setStatus(msg)
|
p.setStatus(msg)
|
||||||
|
@ -790,8 +815,7 @@ class Connection(ConnectionHandlers):
|
||||||
if self.connection:
|
if self.connection:
|
||||||
self.connection.send(p)
|
self.connection.send(p)
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
if not to:
|
self.dispatch('STATUS', show)
|
||||||
self.dispatch('STATUS', show)
|
|
||||||
|
|
||||||
def _on_disconnected(self):
|
def _on_disconnected(self):
|
||||||
''' called when a disconnect request has completed successfully'''
|
''' called when a disconnect request has completed successfully'''
|
||||||
|
|
|
@ -283,7 +283,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
||||||
else:
|
else:
|
||||||
self.reannounce()
|
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:
|
if not show in STATUS_LIST:
|
||||||
return -1
|
return -1
|
||||||
self.status = show
|
self.status = show
|
||||||
|
|
|
@ -2848,7 +2848,10 @@ class RosterWindow:
|
||||||
gajim.sleeper_state[account] = 'online'
|
gajim.sleeper_state[account] = 'online'
|
||||||
elif gajim.sleeper_state[account] not in ('autoaway', 'autoxa'):
|
elif gajim.sleeper_state[account] not in ('autoaway', 'autoxa'):
|
||||||
gajim.sleeper_state[account] = 'off'
|
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(
|
for gc_control in gajim.interface.msg_win_mgr.get_controls(
|
||||||
message_control.TYPE_GC):
|
message_control.TYPE_GC):
|
||||||
|
|
Loading…
Reference in New Issue