From e6aea43665a9000622c285c388a5752f14a52164 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 1 May 2009 09:33:50 +0000 Subject: [PATCH] When saving last_status_msg_*, save also pep info --- configure.ac | 2 +- src/common/config.py | 14 +++++++------- src/common/defs.py | 2 +- src/common/optparser.py | 10 ++++++++++ src/dialogs.py | 36 +++++++++++++++++++++++++++++++----- src/roster_window.py | 34 ++++++++++++++++------------------ 6 files changed, 66 insertions(+), 32 deletions(-) diff --git a/configure.ac b/configure.ac index f4178e2c8..9d4a608bd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([Gajim - A Jabber Instant Messager], - [0.12.1.3-svn],[http://trac.gajim.org/],[gajim]) + [0.12.1.4-svn],[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 67f254739..55da5b69a 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -92,13 +92,6 @@ class Config: 'autoxa_message': [ opt_str, _('$S (Not available as a result of being idle more than $T min)'), _('$S will be replaced by current status message, $T by autoxa time.') ], 'ask_online_status': [ opt_bool, False ], 'ask_offline_status': [ opt_bool, False ], - 'last_status_msg_online': [ opt_str, '' ], - 'last_status_msg_chat': [ opt_str, '' ], - 'last_status_msg_away': [ opt_str, '' ], - 'last_status_msg_xa': [ opt_str, '' ], - 'last_status_msg_dnd': [ opt_str, '' ], - 'last_status_msg_invisible': [ opt_str, '' ], - 'last_status_msg_offline': [ opt_str, '' ], 'trayicon': [opt_str, 'always', _("When to show systray icon. Can be 'never', 'on_event', 'always'."), True], 'iconset': [ opt_str, DEFAULT_ICONSET, '', True ], 'mood_iconset': [ opt_str, DEFAULT_MOOD_ICONSET, '', True ], @@ -444,6 +437,13 @@ class Config: _('Working'): [ _("I'm working."), 'working', 'other', '', '', '' ], _('Phone'): [ _("I'm on the phone."), 'talking', 'on_the_phone', '', '', '' ], _('Out'): [ _("I'm out enjoying life."), 'relaxing', 'going_out', '', '', '' ], + '_last_online': ['', '', '', '', '', ''], + '_last_chat': ['', '', '', '', '', ''], + '_last_away': ['', '', '', '', '', ''], + '_last_xa': ['', '', '', '', '', ''], + '_last_dnd': ['', '', '', '', '', ''], + '_last_invisible': ['', '', '', '', '', ''], + '_last_offline': ['', '', '', '', '', ''], } defaultstatusmsg_default = { diff --git a/src/common/defs.py b/src/common/defs.py index 8e641b4e4..ec4bf784a 100644 --- a/src/common/defs.py +++ b/src/common/defs.py @@ -27,7 +27,7 @@ docdir = '../' datadir = '../' localedir = '../po' -version = '0.12.1.3-svn' +version = '0.12.1.4-svn' import sys, os.path for base in ('.', 'common'): diff --git a/src/common/optparser.py b/src/common/optparser.py index 2ab7cc97c..13e6a03f4 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -193,6 +193,8 @@ class OptionsParser: self.update_config_to_01212() if old < [0, 12, 1, 3] and new >= [0, 12, 1, 3]: self.update_config_to_01213() + if old < [0, 12, 1, 4] and new >= [0, 12, 1, 4]: + self.update_config_to_01214() gajim.logger.init_vars() gajim.config.set('version', new_version) @@ -647,4 +649,12 @@ class OptionsParser: msgs[msg_name][5]) gajim.config.set('version', '0.12.1.3') + def update_config_to_01214(self): + for status in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible', + 'offline']: + gajim.config.add_per('statusmsg', '_last_' + status) + gajim.config.set_per('statusmsg', '_last_' + status, 'message', + self.old_values['last_status_msg_' + status]) + gajim.config.set('version', '0.12.1.4') + # vim: se ts=3: diff --git a/src/dialogs.py b/src/dialogs.py index 50b31021a..400057c04 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -523,9 +523,10 @@ class ChangeMoodDialog: self.window.destroy() class ChangeStatusMessageDialog: - def __init__(self, on_response, show=None, pep_dict=None): + def __init__(self, on_response, show=None, show_pep=True): self.show = show - self.pep_dict = pep_dict + self.pep_dict = {} + self.show_pep = show_pep self.on_response = on_response self.xml = gtkgui_helpers.get_glade('change_status_message_dialog.glade') self.window = self.xml.get_widget('change_status_message_dialog') @@ -534,7 +535,18 @@ class ChangeStatusMessageDialog: if show: uf_show = helpers.get_uf_show(show) self.title_text = _('%s Status Message') % uf_show - msg = gajim.config.get('last_status_msg_' + show) + msg = gajim.config.get_per('statusmsg', '_last_' + self.show, + 'message') + self.pep_dict['activity'] = gajim.config.get_per('statusmsg', + '_last_' + self.show, 'activity') + self.pep_dict['subactivity'] = gajim.config.get_per('statusmsg', + '_last_' + self.show, 'subactivity') + self.pep_dict['activity_text'] = gajim.config.get_per('statusmsg', + '_last_' + self.show, 'activity_text') + self.pep_dict['mood'] = gajim.config.get_per('statusmsg', + '_last_' + self.show, 'mood') + self.pep_dict['mood_text'] = gajim.config.get_per('statusmsg', + '_last_' + self.show, 'mood_text') else: self.title_text = _('Status Message') self.window.set_title(self.title_text) @@ -551,6 +563,8 @@ class ChangeStatusMessageDialog: # have an empty string selectable, so user can clear msg self.preset_messages_dict = {'': ['', '', '', '', '', '']} for msg_name in gajim.config.get_per('statusmsg'): + if msg_name.startswith('_last_'): + continue opts = [] for opt in ['message', 'activity', 'subactivity', 'activity_text', 'mood', 'mood_text']: @@ -572,7 +586,7 @@ class ChangeStatusMessageDialog: for msg_name in sorted_keys_list: self.message_liststore.append((msg_name,)) - if pep_dict: + if show_pep: self.draw_activity() self.draw_mood() else: @@ -651,7 +665,19 @@ class ChangeStatusMessageDialog: message = helpers.remove_invalid_xml_chars(message) msg = helpers.to_one_line(message) if self.show: - gajim.config.set('last_status_msg_' + self.show, msg) + gajim.config.set_per('statusmsg', '_last_' + self.show, 'message', + msg) + if self.show_pep: + gajim.config.set_per('statusmsg', '_last_' + self.show, + 'activity', self.pep_dict['activity']) + gajim.config.set_per('statusmsg', '_last_' + self.show, + 'subactivity', self.pep_dict['subactivity']) + gajim.config.set_per('statusmsg', '_last_' + self.show, + 'activity_text', self.pep_dict['activity_text']) + gajim.config.set_per('statusmsg', '_last_' + self.show, 'mood', + self.pep_dict['mood']) + gajim.config.set_per('statusmsg', '_last_' + self.show, + 'mood_text', self.pep_dict['mood_text']) else: message = None # user pressed Cancel button or X wm button self.window.destroy() diff --git a/src/roster_window.py b/src/roster_window.py index 460f6c484..8bbc645d8 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2091,12 +2091,13 @@ class RosterWindow: if sys.platform == 'darwin': self.make_menu(force=True) - def get_status_message(self, show, pep_dict, on_response, always_ask=False): + def get_status_message(self, show, on_response, show_pep=True, + always_ask=False): ''' get the status message by: 1/ looking in default status message 2/ asking to user if needed depending on ask_on(ff)line_status and always_ask - pep_dict can be None to hide pep things from status message or a dict + show_pep can be False to hide pep things from status message or True ''' if show in gajim.config.get_per('defaultstatusmsg'): if gajim.config.get_per('defaultstatusmsg', show, 'enabled'): @@ -2106,10 +2107,11 @@ class RosterWindow: if not always_ask and ((show == 'online' and not gajim.config.get( 'ask_online_status')) or (show in ('offline', 'invisible') and not \ gajim.config.get('ask_offline_status'))): - on_response('', pep_dict) + on_response('', {'activity': '', 'subactivity': '', + 'activity_text': '', 'mood': '', 'mood_text': ''}) return - dlg = dialogs.ChangeStatusMessageDialog(on_response, show, pep_dict) + dlg = dialogs.ChangeStatusMessageDialog(on_response, show, show_pep) dlg.window.present() # show it on current workspace def change_status(self, widget, account, status): @@ -2120,8 +2122,7 @@ class RosterWindow: return self.send_status(account, status, message) self.send_pep(account, pep_dict) - pep_dict = helpers.get_pep_dict(account) - self.get_status_message(status, pep_dict, on_response) + self.get_status_message(status, on_response) if status == 'invisible' and self.connected_rooms(account): dialogs.ConfirmationDialog( @@ -2299,7 +2300,7 @@ class RosterWindow: on_continue2(message, pep_dict) if get_msg: - self.get_status_message('offline', None, on_continue) + self.get_status_message('offline', on_continue, show_pep=False) else: on_continue('', None) @@ -2591,7 +2592,7 @@ class RosterWindow: connection.set_default_list('block') connection.get_privacy_list('block') - self.get_status_message('offline', None, on_continue) + self.get_status_message('offline', on_continue, show_pep=False) def on_unblock(self, widget, list_, group=None): ''' When clicked on the 'unblock' button in context menu. ''' @@ -2944,13 +2945,12 @@ class RosterWindow: def on_change_status_message_activate(self, widget, account): show = gajim.SHOW_LIST[gajim.connections[account].connected] - pep_dict = helpers.get_pep_dict(account) def on_response(message, pep_dict): if message is None: # None is if user pressed Cancel return self.send_status(account, show, message) self.send_pep(account, pep_dict) - dialogs.ChangeStatusMessageDialog(on_response, show, pep_dict) + dialogs.ChangeStatusMessageDialog(on_response, show) def on_add_to_roster(self, widget, contact, account): dialogs.AddNewContactWindow(account, contact.jid, contact.name) @@ -3055,7 +3055,6 @@ class RosterWindow: show = helpers.get_global_show() if show == 'offline': return True - pep_dict = helpers.get_global_pep() def on_response(message, pep_dict): if message is None: return True @@ -3067,7 +3066,7 @@ class RosterWindow: connected] self.send_status(acct, current_show, message) self.send_pep(acct, pep_dict) - dialogs.ChangeStatusMessageDialog(on_response, show, pep_dict) + dialogs.ChangeStatusMessageDialog(on_response, show) return True elif event.button == 1: # Left click @@ -3202,7 +3201,8 @@ class RosterWindow: jid += '/' + contact.resource self.send_status(account, show, message, to=jid) - self.get_status_message(show, None, on_response, always_ask=True) + self.get_status_message(show, on_response, show_pep=False, + always_ask=True) def on_status_combobox_changed(self, widget): '''When we change our status via the combobox''' @@ -3226,7 +3226,6 @@ class RosterWindow: # 'Change status message' selected: # do not change show, just show change status dialog status = model[self.previous_status_combobox_active][2].decode('utf-8') - pep_dict = helpers.get_global_pep() def on_response(message, pep_dict): if message is not None: # None if user pressed Cancel for account in accounts: @@ -3241,7 +3240,7 @@ class RosterWindow: self.status_combobox.set_active( self.previous_status_combobox_active) self.combobox_callback_active = True - dialogs.ChangeStatusMessageDialog(on_response, status, pep_dict) + dialogs.ChangeStatusMessageDialog(on_response, status) return # we are about to change show, so save this new show so in case # after user chooses "Change status message" menuitem @@ -3288,7 +3287,7 @@ class RosterWindow: break if bug_user: def on_ok(): - self.get_status_message(status, None, on_continue) + self.get_status_message(status, on_continue, show_pep=False) def on_cancel(): self.update_status_combobox() @@ -3301,8 +3300,7 @@ class RosterWindow: on_response_cancel=on_cancel) return - pep_dict = helpers.get_global_pep() - self.get_status_message(status, pep_dict, on_continue) + self.get_status_message(status, on_continue) def on_preferences_menuitem_activate(self, widget): if 'preferences' in gajim.interface.instances: