<status> is not a must (except when using GPG)

This commit is contained in:
Yann Leboulanger 2005-05-20 15:32:05 +00:00
parent 4b6e527fdf
commit 58ab395501

View file

@ -602,17 +602,17 @@ class Connection:
def change_status(self, show, msg): def change_status(self, show, msg):
if not show in STATUS_LIST: if not show in STATUS_LIST:
return -1 return -1
if not msg:
msg = show
self.status = msg
signed = '' signed = ''
keyID = gajim.config.get_per('accounts', self.name, 'keyid') keyID = gajim.config.get_per('accounts', self.name, 'keyid')
if keyID and USE_GPG: if keyID and USE_GPG:
if not msg:
msg = show
signed = self.gpg.sign(msg, keyID) signed = self.gpg.sign(msg, keyID)
if signed == 'BAD_PASSPHRASE': if signed == 'BAD_PASSPHRASE':
signed = '' signed = ''
if self.connected < 2: if self.connected < 2:
self.dispatch('BAD_PASSPHRASE', ()) self.dispatch('BAD_PASSPHRASE', ())
self.status = msg
if show != 'offline' and not self.connected: if show != 'offline' and not self.connected:
self.connection = self.connect() self.connection = self.connect()
if self.connected == 2: if self.connected == 2:
@ -622,8 +622,9 @@ class Connection:
if show == 'invisible': if show == 'invisible':
ptype = 'invisible' ptype = 'invisible'
prio = str(gajim.config.get_per('accounts', self.name, 'priority')) prio = str(gajim.config.get_per('accounts', self.name, 'priority'))
p = common.xmpp.Presence(typ = ptype, priority = prio, show =\ p = common.xmpp.Presence(typ = ptype, priority = prio, show = show)
show, status=msg) if msg:
p.setStatus(msg)
if signed: if signed:
p.setTag(common.xmpp.NS_SIGNED + ' x').setData(signed) p.setTag(common.xmpp.NS_SIGNED + ' x').setData(signed)
@ -637,8 +638,10 @@ class Connection:
elif show == 'offline' and self.connected: elif show == 'offline' and self.connected:
self.connected = 0 self.connected = 0
if self.connection: if self.connection:
self.connection.send(common.xmpp.Presence(typ = 'unavailable', p = common.xmpp.Presence(typ = 'unavailable')
status = msg)) if msg:
p.setStatus(msg)
self.connection.send(p)
self.connection.disconnect() self.connection.disconnect()
self.dispatch('STATUS', 'offline') self.dispatch('STATUS', 'offline')
self.connection = None self.connection = None
@ -648,9 +651,11 @@ class Connection:
if show == 'invisible': if show == 'invisible':
ptype = 'invisible' ptype = 'invisible'
prio = str(gajim.config.get_per('accounts', self.name, 'priority')) prio = str(gajim.config.get_per('accounts', self.name, 'priority'))
p = common.xmpp.Presence(typ = ptype, priority = prio, show = show, p = common.xmpp.Presence(typ = ptype, priority = prio, show = show)
status = msg) if msg:
if signed: p.setTag(common.xmpp.NS_SIGNED + ' x').setData(signed) p.setStatus(msg)
if signed:
p.setTag(common.xmpp.NS_SIGNED + ' x').setData(signed)
self.connection.send(p) self.connection.send(p)
self.dispatch('STATUS', show) self.dispatch('STATUS', show)