diff --git a/configure.ac b/configure.ac index 24d8ad2c44d1888b509b1d04012fd6cae9c4977b..a8d896008ecb38e99b93b0fa6504a14cad1480b3 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 903c313e817342a9b16b03f7c307073f5a047ff2..3153e870e7131a84935327c7e664f2e4f0bf643e 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, '#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 ], + '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/common/connection.py b/src/common/connection.py index 4ff4a7270a67e2fb66a608f996507b12fe006d7e..39a0cc5ca3a195f9fa12352564bad7f7f39f31d6 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 e6bb1deb771e684d1024d19eac6d77c7dd7a57a3..95dec13a6f4f7d628d3835ecc81f27e3cbff03cf 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: @@ -2273,6 +2282,17 @@ 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) + + # 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: self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource, @@ -2290,9 +2310,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.'))) diff --git a/src/common/defs.py b/src/common/defs.py index 8bbc982c4eb22a394295ae9ac6c8f5417c712de5..1b4ba22d589bb6502fcee9e30660b8355157cff2 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 96020f11b7b4db634ef035b3b3baca36ad78978e..62d69d377c43ff0f850eb9316c8e8bde05fb941f 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) @@ -758,10 +760,24 @@ 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 gajim.config.set(c, vals[c][1]) gajim.config.set('version', '0.12.5.4') + def update_config_to_01255(self): + 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 + gajim.config.set(c, vals[c][1]) + gajim.config.set('version', '0.12.5.5') + # vim: se ts=3: diff --git a/src/conversation_textview.py b/src/conversation_textview.py index 6e44f1ddcf3657d775b703e9d42023afd36351f1..3af295cbb56057998f4722680acc5b4f4af7e55f 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) diff --git a/src/history_window.py b/src/history_window.py index f3bcfad087234d2b3b6425d5c81ebbb9a13858cd..2ad639fb7510f1469ce067b91c639992eb091610 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: