From 2367dda7c37dda4d1cceeba263c8d5fc47b2136e Mon Sep 17 00:00:00 2001 From: red-agent Date: Tue, 13 Oct 2009 00:46:06 +0300 Subject: [PATCH 01/11] Fix for the autorejoin, to handle absent conferences --- src/common/connection_handlers.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index e6bb1deb7..0378c3ae4 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -2273,6 +2273,21 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, errmsg = prs.getErrorMsg() errcode = prs.getErrorCode() room_jid, nick = gajim.get_room_and_nick_from_fjid(who) + + gc_control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, + self.name) + + # gc_control might be in the other place if it's minimized. Note: + # this solution might have an impact on the performance. + if gc_control is None: + for control in gajim.interface.minimized_controls[self.name]: + # Using here this hack instead of isinstance() to avoid risk + # of cycle import when trying to import GroupchatControl from + # groupchat_control.py + if control.__class__.__name__ == 'GroupchatControl' and \ + control.room_jid == room_jid: + gc_control = control + if errcode == '502': # Internal Timeout: self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource, @@ -2290,9 +2305,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, self.dispatch('ERROR', (_('Unable to join group chat'), _('You are banned from group chat %s.') % room_jid)) elif (errcode == '404') or (errcon == 'item-not-found'): - # group chat does not exist - self.dispatch('ERROR', (_('Unable to join group chat'), - _('Group chat %s does not exist.') % room_jid)) + if gc_control is None or gc_control.autorejoin is None: + # group chat does not exist + self.dispatch('ERROR', (_('Unable to join group chat'), + _('Group chat %s does not exist.') % room_jid)) elif (errcode == '405') or (errcon == 'not-allowed'): self.dispatch('ERROR', (_('Unable to join group chat'), _('Group chat creation is restricted.'))) From 970aa8c848ef8bc2fa17f1b2435444230b08f465 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 13 Oct 2009 07:53:05 +0200 Subject: [PATCH 02/11] fix look in minimized_controls --- src/common/connection_handlers.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 0378c3ae4..0ae68e6c8 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -2279,14 +2279,9 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, # gc_control might be in the other place if it's minimized. Note: # this solution might have an impact on the performance. - if gc_control is None: - for control in gajim.interface.minimized_controls[self.name]: - # Using here this hack instead of isinstance() to avoid risk - # of cycle import when trying to import GroupchatControl from - # groupchat_control.py - if control.__class__.__name__ == 'GroupchatControl' and \ - control.room_jid == room_jid: - gc_control = control + if gc_control is None and \ + room_jid in gajim.interface.minimized_controls[self.name]: + gc_control = control if errcode == '502': # Internal Timeout: From 997a8f842915b536589c8fa1c696acb966043649 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 13 Oct 2009 12:56:14 +0200 Subject: [PATCH 03/11] correctly get minimized room --- src/common/connection_handlers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 0ae68e6c8..5c7e2da29 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -2281,7 +2281,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, # this solution might have an impact on the performance. if gc_control is None and \ room_jid in gajim.interface.minimized_controls[self.name]: - gc_control = control + gc_control = gajim.interface.minimized_controls[self.name][ + room_jid] if errcode == '502': # Internal Timeout: From 2f1412050ced5a4cc328aacf444c904b0bc6afd0 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 13 Oct 2009 13:42:44 +0200 Subject: [PATCH 04/11] [Xytovl] ability to configure font and colors of incoming / outgoing messages. Fixes #5311 --- src/common/config.py | 13 ++++++++++--- src/conversation_textview.py | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/common/config.py b/src/common/config.py index 903c313e8..781b18b56 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -90,11 +90,18 @@ class Config: 'mood_iconset': [ opt_str, DEFAULT_MOOD_ICONSET, '', True ], 'activity_iconset': [ opt_str, DEFAULT_ACTIVITY_ICONSET, '', True ], 'use_transports_iconsets': [ opt_bool, True, '', True ], - 'inmsgcolor': [ opt_color, '#a40000', '', True ], - 'outmsgcolor': [ opt_color, '#3465a4', '', True ], - 'statusmsgcolor': [ opt_color, '#73d216', '', True ], + 'inmsgcolor': [ opt_color, '#a40000', _('Incoming nickname color.'), True ], + 'outmsgcolor': [ opt_color, '#3465a4', _('Outgoing nickname color.'), True ], + 'inmsgtxtcolor': [ opt_color, '', _('Incoming text color.'), True ], + 'outmsgtxtcolor': [ opt_color, '#a2a2a2', _('Outgoing text color.'), True ], + 'statusmsgcolor': [ opt_color, '#73d216', _('Status message text color.'), True ], 'markedmsgcolor': [ opt_color, '#ff8080', '', True ], 'urlmsgcolor': [ opt_color, '#204a87', '', True ], + 'inmsgfont': [ opt_str, '', _('Incoming nickname font.'), True ], + 'outmsgfont': [ opt_str, '', _('Outgoing nickname font.'), True ], + 'inmsgtxtfont': [ opt_str, '', _('Incoming text font.'), True ], + 'outmsgtxtfont': [ opt_str, '', _('Outgoing text font.'), True ], + 'statusmsgfont': [ opt_str, '', _('Status message text font.'), True ], 'collapsed_rows': [ opt_str, '', _('List (space separated) of rows (accounts and groups) that are collapsed.'), True ], 'roster_theme': [ opt_str, _('default'), '', True ], 'mergeaccounts': [ opt_bool, False, '', True ], diff --git a/src/conversation_textview.py b/src/conversation_textview.py index 6e44f1ddc..3af295cbb 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -230,13 +230,35 @@ class ConversationTextview(gobject.GObject): self.tagIn = buffer_.create_tag('incoming') color = gajim.config.get('inmsgcolor') + font = pango.FontDescription(gajim.config.get('inmsgfont')) self.tagIn.set_property('foreground', color) + self.tagIn.set_property('font-desc', font) + self.tagOut = buffer_.create_tag('outgoing') color = gajim.config.get('outmsgcolor') + font = pango.FontDescription(gajim.config.get('outmsgfont')) self.tagOut.set_property('foreground', color) + self.tagOut.set_property('font-desc', font) + self.tagStatus = buffer_.create_tag('status') color = gajim.config.get('statusmsgcolor') + font = pango.FontDescription(gajim.config.get('satusmsgfont')) self.tagStatus.set_property('foreground', color) + self.tagStatus.set_property('font-desc', font) + + self.tagInText = buffer_.create_tag('incomingtxt') + color = gajim.config.get('inmsgtxtcolor') + font = pango.FontDescription(gajim.config.get('inmsgtxtfont')) + if color: + self.tagInText.set_property('foreground', color) + self.tagInText.set_property('font-desc', font) + + self.tagOutText = buffer_.create_tag('outgoingtxt') + color = gajim.config.get('outmsgtxtcolor') + if color: + font = pango.FontDescription(gajim.config.get('outmsgtxtfont')) + self.tagOutText.set_property('foreground', color) + self.tagOutText.set_property('font-desc', font) colors = gajim.config.get('gc_nicknames_colors') colors = colors.split(':') @@ -1219,6 +1241,10 @@ class ConversationTextview(gobject.GObject): 'chat_merge_consecutive_nickname_indent')) else: self.print_name(name, kind, other_tags_for_name) + if kind == 'incoming': + text_tags.append('incomingtxt') + elif kind == 'outgoing': + text_tags.append('outgoingtxt') self.print_subject(subject) self.print_real_text(text, text_tags, name, xhtml, graphics=graphics) From 6c2b658a9aa39660b221146158ff0605413b9639 Mon Sep 17 00:00:00 2001 From: red-agent Date: Tue, 13 Oct 2009 17:38:42 +0300 Subject: [PATCH 05/11] Improved the lookup of the minimized control --- src/common/connection_handlers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 5c7e2da29..dcd61a946 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -2277,12 +2277,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, gc_control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, self.name) - # gc_control might be in the other place if it's minimized. Note: - # this solution might have an impact on the performance. - if gc_control is None and \ - room_jid in gajim.interface.minimized_controls[self.name]: - gc_control = gajim.interface.minimized_controls[self.name][ - room_jid] + # If gc_control is missing - it may be minimized. Try to get it from + # there. If it's not there - then it's missing anyway and will + # remain set to None. + if gc_control is None: + minimized = gajim.interface.minimized_controls[self.name] + gc_control = minimized.get(room_jid) if errcode == '502': # Internal Timeout: From f18ede1c887805a2e9e11aaa9aec39eb30fefe0e Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 13 Oct 2009 19:26:56 +0200 Subject: [PATCH 06/11] detect incoming MUC error presences from the ID. Fixes #5309 --- src/common/connection.py | 14 ++++++++++++-- src/common/connection_handlers.py | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 4ff4a7270..39a0cc5ca 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -39,6 +39,7 @@ import operator import time import locale +import hmac try: randomsource = random.SystemRandom() @@ -190,6 +191,7 @@ class Connection(ConnectionHandlers): self.vcard_supported = False self.private_storage_supported = True self.streamError = '' + self.secret_hmac = str(random.random())[2:] # END __init__ def put_event(self, ev): @@ -1775,8 +1777,12 @@ class Connection(ConnectionHandlers): last_log = 0 self.last_history_time[room_jid] = last_log - p = common.xmpp.Presence(to = '%s/%s' % (room_jid, nick), - show = show, status = self.status) + p = common.xmpp.Presence(to='%s/%s' % (room_jid, nick), + show=show, status=self.status) + h = hmac.new(self.secret_hmac, room_jid).hexdigest()[:6] + id_ = self.connection.getAnID() + id_ = 'gajim_muc_' + id_ + '_' + h + p.setID(id_) if gajim.config.get('send_sha_in_gc_presence'): p = self.add_sha(p) self.add_lang(p) @@ -1843,6 +1849,10 @@ class Connection(ConnectionHandlers): xmpp_show = helpers.get_xmpp_show(show) p = common.xmpp.Presence(to = '%s/%s' % (jid, nick), typ = ptype, show = xmpp_show, status = status) + h = hmac.new(self.secret_hmac, jid).hexdigest()[:6] + id_ = self.connection.getAnID() + id_ = 'gajim_muc_' + id_ + '_' + h + p.setID(id_) if gajim.config.get('send_sha_in_gc_presence') and show != 'offline': p = self.add_sha(p, ptype != 'unavailable') self.add_lang(p) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index dcd61a946..c221cfb8b 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -34,6 +34,7 @@ import socket import sys import operator import hashlib +import hmac from time import (altzone, daylight, gmtime, localtime, mktime, strftime, time as time_time, timezone, tzname) @@ -2207,6 +2208,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, return jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who) timestamp = None + id_ = prs.getID() is_gc = False # is it a GC presence ? sigTag = None ns_muc_user_x = None @@ -2246,6 +2248,13 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, if self.connection.getRoster().getItem(agent): # to be sure it's a transport contact transport_auto_auth = True + if not is_gc and id_ and id_.startswith('gajim_muc_') and \ + ptype == 'error': + # Error presences may not include sent stanza, so we don't detect it's + # a muc preence. So detect it by ID + h = hmac.new(self.secret_hmac, jid_stripped).hexdigest()[:6] + if id_.split('_')[-1] = h: + is_gc = True status = prs.getStatus() or '' show = prs.getShow() if not show in gajim.SHOW_LIST: From d7a780e60a92b9bdb9d74aaf001ae56ba58b11fd Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 13 Oct 2009 19:31:07 +0200 Subject: [PATCH 07/11] fix typo --- src/common/connection_handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index c221cfb8b..95dec13a6 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -2253,7 +2253,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, # Error presences may not include sent stanza, so we don't detect it's # a muc preence. So detect it by ID h = hmac.new(self.secret_hmac, jid_stripped).hexdigest()[:6] - if id_.split('_')[-1] = h: + if id_.split('_')[-1] == h: is_gc = True status = prs.getStatus() or '' show = prs.getShow() From 166a70b48e4a81502a65f416b721f5a943017e08 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 13 Oct 2009 20:05:45 +0200 Subject: [PATCH 08/11] update some colors. Fixes #5321 --- configure.ac | 2 +- src/common/config.py | 4 ++-- src/common/defs.py | 2 +- src/common/optparser.py | 12 ++++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 24d8ad2c4..a8d896008 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([Gajim - A Jabber Instant Messager], - [0.12.5.4-dev],[http://trac.gajim.org/],[gajim]) + [0.12.5.5-dev],[http://trac.gajim.org/],[gajim]) AC_PREREQ([2.59]) AC_CONFIG_HEADER(config.h) diff --git a/src/common/config.py b/src/common/config.py index 781b18b56..3153e870e 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -93,8 +93,8 @@ class Config: 'inmsgcolor': [ opt_color, '#a40000', _('Incoming nickname color.'), True ], 'outmsgcolor': [ opt_color, '#3465a4', _('Outgoing nickname color.'), True ], 'inmsgtxtcolor': [ opt_color, '', _('Incoming text color.'), True ], - 'outmsgtxtcolor': [ opt_color, '#a2a2a2', _('Outgoing text color.'), True ], - 'statusmsgcolor': [ opt_color, '#73d216', _('Status message text color.'), True ], + 'outmsgtxtcolor': [ opt_color, '#555753', _('Outgoing text color.'), True ], + 'statusmsgcolor': [ opt_color, '#4e9a06', _('Status message text color.'), True ], 'markedmsgcolor': [ opt_color, '#ff8080', '', True ], 'urlmsgcolor': [ opt_color, '#204a87', '', True ], 'inmsgfont': [ opt_str, '', _('Incoming nickname font.'), True ], diff --git a/src/common/defs.py b/src/common/defs.py index 8bbc982c4..1b4ba22d5 100644 --- a/src/common/defs.py +++ b/src/common/defs.py @@ -27,7 +27,7 @@ docdir = '../' datadir = '../' localedir = '../po' -version = '0.12.5.4-dev' +version = '0.12.5.5-dev' import sys, os.path for base in ('.', 'common'): diff --git a/src/common/optparser.py b/src/common/optparser.py index 96020f11b..75f9c4975 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -208,6 +208,8 @@ class OptionsParser: self.update_config_to_01253() if old < [0, 12, 5, 4] and new >= [0, 12, 5, 4]: self.update_config_to_01254() + if old < [0, 12, 5, 5] and new >= [0, 12, 5, 5]: + self.update_config_to_01255() gajim.logger.init_vars() gajim.config.set('version', new_version) @@ -764,4 +766,14 @@ class OptionsParser: gajim.config.set(c, vals[c][1]) gajim.config.set('version', '0.12.5.4') + def update_config_to_01254(self): + vals = {'statusmsgcolor': ['#73d216', '#4e9a06'], + 'outmsgtxtcolor': ['#a2a2a2', '#555753']} + for c in vals: + val = self.old_values[c] + if val == vals[c][0]: + # We didn't change default value, so update it with new default + gajim.config.set(c, vals[c][1]) + gajim.config.set('version', '0.12.5.5') + # vim: se ts=3: From 1ae8339222e75bd84b47c051bf420349e83e33e5 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 13 Oct 2009 20:27:12 +0200 Subject: [PATCH 09/11] typo --- src/common/optparser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/optparser.py b/src/common/optparser.py index 75f9c4975..fcd182712 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -766,7 +766,7 @@ class OptionsParser: gajim.config.set(c, vals[c][1]) gajim.config.set('version', '0.12.5.4') - def update_config_to_01254(self): + def update_config_to_01255(self): vals = {'statusmsgcolor': ['#73d216', '#4e9a06'], 'outmsgtxtcolor': ['#a2a2a2', '#555753']} for c in vals: From bf298d456845c898cd4253a652536ab1a3f4ab6a Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 13 Oct 2009 21:44:14 +0200 Subject: [PATCH 10/11] prevent traceback in upgrade function --- src/common/optparser.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/optparser.py b/src/common/optparser.py index fcd182712..62d69d377 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -760,6 +760,8 @@ class OptionsParser: 'urlmsgcolor': ['#0000ff', '#204a87'], 'gc_nicknames_colors': ['#a34526:#c000ff:#0012ff:#388a99:#045723:#7c7c7c:#ff8a00:#94452d:#244b5a:#32645a', '#4e9a06:#f57900:#ce5c00:#3465a4:#204a87:#75507b:#5c3566:#c17d11:#8f5902:#ef2929:#cc0000:#a40000']} for c in vals: + if c not in self.old_values: + continue val = self.old_values[c] if val == vals[c][0]: # We didn't change default value, so update it with new default @@ -770,6 +772,8 @@ class OptionsParser: vals = {'statusmsgcolor': ['#73d216', '#4e9a06'], 'outmsgtxtcolor': ['#a2a2a2', '#555753']} for c in vals: + if c not in self.old_values: + continue val = self.old_values[c] if val == vals[c][0]: # We didn't change default value, so update it with new default From c59f4f7d73062a06857867332287bb922621e43e Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 14 Oct 2009 08:40:28 +0200 Subject: [PATCH 11/11] show incoming and outgoing style in history window too. Fixes #5321 --- src/history_window.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/history_window.py b/src/history_window.py index f3bcfad08..2ad639fb7 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -409,6 +409,7 @@ class HistoryWindow: constants.KIND_CHAT_MSG_RECV): contact_name = self.completion_dict[self.jid][C_INFO_NAME] tag_name = 'incoming' + tag_msg = 'incomingtxt' elif kind in (constants.KIND_SINGLE_MSG_SENT, constants.KIND_CHAT_MSG_SENT): if self.account: @@ -419,6 +420,7 @@ class HistoryWindow: account = gajim.contacts.get_accounts()[0] contact_name = gajim.nicks[account] tag_name = 'outgoing' + tag_msg = 'outgoingtxt' elif kind == constants.KIND_GCSTATUS: # message here (if not None) is status message if message: