show "room has been destroyed" only when it has been destroyed. Fixes #5952

This commit is contained in:
Yann Leboulanger 2010-09-29 17:51:52 +02:00
parent 0a1356e006
commit ffba6193e4

View file

@ -883,11 +883,12 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent):
jid = self.gc_contact.jid jid = self.gc_contact.jid
else: else:
jid = self.iq_obj.getJid() jid = self.iq_obj.getJid()
st = self.status
if jid: if jid:
# we know real jid, save it in db # we know real jid, save it in db
self.status += ' (%s)' % jid st += ' (%s)' % jid
try: try:
gajim.logger.write('gcstatus', self.fjid, self.status, gajim.logger.write('gcstatus', self.fjid, st,
self.show) self.show)
except exceptions.PysqliteOperationalError, e: except exceptions.PysqliteOperationalError, e:
self.conn.dispatch('DB_ERROR', (_('Disk Write Error'), self.conn.dispatch('DB_ERROR', (_('Disk Write Error'),
@ -908,23 +909,22 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent):
# We may ask it to real jid in gui part. # We may ask it to real jid in gui part.
self.status_code = [] self.status_code = []
ns_muc_user_x = self.iq_obj.getTag('x', namespace=xmpp.NS_MUC_USER) ns_muc_user_x = self.iq_obj.getTag('x', namespace=xmpp.NS_MUC_USER)
if ns_muc_user_x: destroy = ns_muc_user_x.getTag('destroy')
if ns_muc_user_x and destroy:
# Room has been destroyed. see # Room has been destroyed. see
# http://www.xmpp.org/extensions/xep-0045.html#destroyroom # http://www.xmpp.org/extensions/xep-0045.html#destroyroom
self.reason = _('Room has been destroyed') self.reason = _('Room has been destroyed')
destroy = ns_muc_user_x.getTag('destroy') r = destroy.getTagData('reason')
if destroy: if r:
r = destroy.getTagData('reason') self.reason += ' (%s)' % r
if r: if destroy.getAttr('jid'):
self.reason += ' (%s)' % r try:
if destroy.getAttr('jid'): jid = helpers.parse_jid(destroy.getAttr('jid'))
try: self.reason += '\n' + \
jid = helpers.parse_jid(destroy.getAttr('jid')) _('You can join this room instead: %s') % jid
self.reason += '\n' + \ except common.helpers.InvalidFormat:
_('You can join this room instead: %s') % jid pass
except common.helpers.InvalidFormat: self.status_code = ['destroyed']
pass
self.status_code = ['destroyed']
else: else:
self.reason = self.iq_obj.getReason() self.reason = self.iq_obj.getReason()
self.status_code = self.iq_obj.getStatusCode() self.status_code = self.iq_obj.getStatusCode()