Merge the new command system in

This commit is contained in:
red-agent 2009-09-17 23:22:48 +03:00
commit 030738db2d
12 changed files with 111 additions and 15 deletions

View File

@ -1,5 +1,5 @@
AC_INIT([Gajim - A Jabber Instant Messager], AC_INIT([Gajim - A Jabber Instant Messager],
[0.12.5.1-dev],[http://trac.gajim.org/],[gajim]) [0.12.5.2-dev],[http://trac.gajim.org/],[gajim])
AC_PREREQ([2.59]) AC_PREREQ([2.59])
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)

View File

@ -76,6 +76,9 @@ if gajim.config.get('use_speller') and HAS_GTK_SPELL:
spell.set_language(langs[lang]) spell.set_language(langs[lang])
except OSError: except OSError:
del langs[lang] del langs[lang]
if spell:
spell.detach()
del tv
################################################################################ ################################################################################
class ChatControlBase(MessageControl, CommonCommands): class ChatControlBase(MessageControl, CommonCommands):
@ -1469,6 +1472,19 @@ class ChatControl(ChatControlBase, ChatCommands):
else: else:
self._tune_image.hide() self._tune_image.hide()
def change_resource(self, resource):
old_full_jid = self.get_full_jid()
self.resource = resource
new_full_jid = self.get_full_jid()
# update gajim.last_message_time
if old_full_jid in gajim.last_message_time[self.account]:
gajim.last_message_time[self.account][new_full_jid] = \
gajim.last_message_time[self.account][old_full_jid]
# update events
gajim.events.change_jid(self.account, old_full_jid, new_full_jid)
# update MessageWindow._controls
self.parent_win.change_jid(self.account, old_full_jid, new_full_jid)
def on_avatar_eventbox_enter_notify_event(self, widget, event): def on_avatar_eventbox_enter_notify_event(self, widget, event):
''' '''
we enter the eventbox area so we under conditions add a timeout we enter the eventbox area so we under conditions add a timeout
@ -2299,6 +2315,10 @@ class ChatControl(ChatControlBase, ChatCommands):
self.handlers[i].disconnect(i) self.handlers[i].disconnect(i)
del self.handlers[i] del self.handlers[i]
self.conv_textview.del_handlers() self.conv_textview.del_handlers()
if gajim.config.get('use_speller') and HAS_GTK_SPELL:
spell_obj = gtkspell.get_from_text_view(self.msg_textview)
if spell_obj:
spell_obj.detach()
self.msg_textview.destroy() self.msg_textview.destroy()
def minimizable(self): def minimizable(self):

View File

@ -67,7 +67,6 @@ class Config:
__options = { __options = {
# name: [ type, default_value, help_string ] # name: [ type, default_value, help_string ]
'verbose': [ opt_bool, False, '', True ], 'verbose': [ opt_bool, False, '', True ],
'alwaysauth': [ opt_bool, False ],
'autopopup': [ opt_bool, False ], 'autopopup': [ opt_bool, False ],
'notify_on_signin': [ opt_bool, True ], 'notify_on_signin': [ opt_bool, True ],
'notify_on_signout': [ opt_bool, False ], 'notify_on_signout': [ opt_bool, False ],
@ -287,6 +286,7 @@ class Config:
'autoconnect_as': [ opt_str, 'online', _('Status used to autoconnect as. Can be online, chat, away, xa, dnd, invisible. NOTE: this option is used only if restore_last_status is disabled'), True ], 'autoconnect_as': [ opt_str, 'online', _('Status used to autoconnect as. Can be online, chat, away, xa, dnd, invisible. NOTE: this option is used only if restore_last_status is disabled'), True ],
'restore_last_status': [ opt_bool, False, _('If enabled, restore the last status that was used.') ], 'restore_last_status': [ opt_bool, False, _('If enabled, restore the last status that was used.') ],
'autoreconnect': [ opt_bool, True ], 'autoreconnect': [ opt_bool, True ],
'autoauth': [ opt_bool, False, _('If True, Contacts requesting authorization will be automatically accepted.')],
'active': [ opt_bool, True], 'active': [ opt_bool, True],
'proxy': [ opt_str, '', '', True ], 'proxy': [ opt_str, '', '', True ],
'keyid': [ opt_str, '', '', True ], 'keyid': [ opt_str, '', '', True ],

View File

@ -2353,13 +2353,14 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
if ptype == 'subscribe': if ptype == 'subscribe':
log.debug('subscribe request from %s' % who) log.debug('subscribe request from %s' % who)
if gajim.config.get('alwaysauth') or who.find("@") <= 0 or \ if gajim.config.get_per('accounts', self.name, 'autoauth') or \
jid_stripped in self.jids_for_auto_auth or transport_auto_auth: who.find('@') <= 0 or jid_stripped in self.jids_for_auto_auth or \
transport_auto_auth:
if self.connection: if self.connection:
p = common.xmpp.Presence(who, 'subscribed') p = common.xmpp.Presence(who, 'subscribed')
p = self.add_sha(p) p = self.add_sha(p)
self.connection.send(p) self.connection.send(p)
if who.find("@") <= 0 or transport_auto_auth: if who.find('@') <= 0 or transport_auto_auth:
self.dispatch('NOTIFY', (jid_stripped, 'offline', 'offline', self.dispatch('NOTIFY', (jid_stripped, 'offline', 'offline',
resource, prio, keyID, timestamp, None)) resource, prio, keyID, timestamp, None))
if transport_auto_auth: if transport_auto_auth:

View File

@ -27,7 +27,7 @@ docdir = '../'
datadir = '../' datadir = '../'
localedir = '../po' localedir = '../po'
version = '0.12.5.1-dev' version = '0.12.5.2-dev'
import sys, os.path import sys, os.path
for base in ('.', 'common'): for base in ('.', 'common'):

View File

@ -114,6 +114,12 @@ def latex_to_image(str_):
result = None result = None
exitcode = 0 exitcode = 0
try:
bg_str, fg_str = gajim.interface.get_bg_fg_colors()
except:
# interface may not be available when we test latext at startup
bg_str, fg_str = 'rgb 1.0 1.0 1.0', 'rgb 0.0 0.0 0.0'
# filter latex code with bad commands # filter latex code with bad commands
if check_blacklist(str_): if check_blacklist(str_):
# we triggered the blacklist, immediately return None # we triggered the blacklist, immediately return None
@ -131,7 +137,7 @@ def latex_to_image(str_):
if exitcode == 0: if exitcode == 0:
# convert dvi to png # convert dvi to png
latex_png_dpi = gajim.config.get('latex_png_dpi') latex_png_dpi = gajim.config.get('latex_png_dpi')
exitcode = try_run(['dvipng', '-bg', 'rgb 1.0 1.0 1.0', '-T', exitcode = try_run(['dvipng', '-bg', bg_str, '-fg', fg_str, '-T',
'tight', '-D', latex_png_dpi, tmpfile + '.dvi', '-o', 'tight', '-D', latex_png_dpi, tmpfile + '.dvi', '-o',
tmpfile + '.png']) tmpfile + '.png'])

View File

@ -202,6 +202,8 @@ class OptionsParser:
self.update_config_to_01231() self.update_config_to_01231()
if old < [0, 12, 5, 1] and new >= [0, 12, 5, 1]: if old < [0, 12, 5, 1] and new >= [0, 12, 5, 1]:
self.update_config_to_01251() self.update_config_to_01251()
if old < [0, 12, 5, 2] and new >= [0, 12, 5, 2]:
self.update_config_to_01252()
gajim.logger.init_vars() gajim.logger.init_vars()
gajim.config.set('version', new_version) gajim.config.set('version', new_version)
@ -727,4 +729,11 @@ class OptionsParser:
con.close() con.close()
gajim.config.set('version', '0.12.5.1') gajim.config.set('version', '0.12.5.1')
def update_config_to_01252(self):
if 'alwaysauth' in self.old_values:
val = self.old_values['alwaysauth']
for account in gajim.config.get_per('accounts'):
gajim.config.set_per('accounts', account, 'autoauth', val)
gajim.config.set('version', '0.12.5.2')
# vim: se ts=3: # vim: se ts=3:

View File

@ -1077,6 +1077,7 @@ class ManageProxiesWindow:
self.proxytype_combobox = self.xml.get_widget('proxytype_combobox') self.proxytype_combobox = self.xml.get_widget('proxytype_combobox')
self.init_list() self.init_list()
self.block_signal = False
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)
self.window.show_all() self.window.show_all()
# hide the BOSH fields by default # hide the BOSH fields by default
@ -1134,6 +1135,7 @@ class ManageProxiesWindow:
iter_ = model.append() iter_ = model.append()
model.set(iter_, 0, 'proxy' + unicode(i)) model.set(iter_, 0, 'proxy' + unicode(i))
gajim.config.add_per('proxies', 'proxy' + unicode(i)) gajim.config.add_per('proxies', 'proxy' + unicode(i))
self.proxies_treeview.set_cursor(model.get_path(iter_))
def on_remove_proxy_button_clicked(self, widget): def on_remove_proxy_button_clicked(self, widget):
(model, iter_) = self.proxies_treeview.get_selection().get_selected() (model, iter_) = self.proxies_treeview.get_selection().get_selected()
@ -1143,11 +1145,16 @@ class ManageProxiesWindow:
model.remove(iter_) model.remove(iter_)
gajim.config.del_per('proxies', proxy) gajim.config.del_per('proxies', proxy)
self.xml.get_widget('remove_proxy_button').set_sensitive(False) self.xml.get_widget('remove_proxy_button').set_sensitive(False)
self.block_signal = True
self.on_proxies_treeview_cursor_changed(self.proxies_treeview)
self.block_signal = False
def on_close_button_clicked(self, widget): def on_close_button_clicked(self, widget):
self.window.destroy() self.window.destroy()
def on_useauth_checkbutton_toggled(self, widget): def on_useauth_checkbutton_toggled(self, widget):
if self.block_signal:
return
act = widget.get_active() act = widget.get_active()
proxy = self.proxyname_entry.get_text().decode('utf-8') proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'useauth', act) gajim.config.set_per('proxies', proxy, 'useauth', act)
@ -1155,6 +1162,8 @@ class ManageProxiesWindow:
self.xml.get_widget('proxypass_entry').set_sensitive(act) self.xml.get_widget('proxypass_entry').set_sensitive(act)
def on_boshuseproxy_checkbutton_toggled(self, widget): def on_boshuseproxy_checkbutton_toggled(self, widget):
if self.block_signal:
return
act = widget.get_active() act = widget.get_active()
proxy = self.proxyname_entry.get_text().decode('utf-8') proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'bosh_useproxy', act) gajim.config.set_per('proxies', proxy, 'bosh_useproxy', act)
@ -1164,11 +1173,6 @@ class ManageProxiesWindow:
def on_proxies_treeview_cursor_changed(self, widget): def on_proxies_treeview_cursor_changed(self, widget):
#FIXME: check if off proxy settings are correct (see #FIXME: check if off proxy settings are correct (see
# http://trac.gajim.org/changeset/1921#file2 line 1221 # http://trac.gajim.org/changeset/1921#file2 line 1221
(model, iter_) = widget.get_selection().get_selected()
if not iter_:
return
proxy = model[iter_][0]
self.xml.get_widget('proxyname_entry').set_text(proxy)
proxyhost_entry = self.xml.get_widget('proxyhost_entry') proxyhost_entry = self.xml.get_widget('proxyhost_entry')
proxyport_entry = self.xml.get_widget('proxyport_entry') proxyport_entry = self.xml.get_widget('proxyport_entry')
proxyuser_entry = self.xml.get_widget('proxyuser_entry') proxyuser_entry = self.xml.get_widget('proxyuser_entry')
@ -1176,6 +1180,7 @@ class ManageProxiesWindow:
boshuri_entry = self.xml.get_widget('boshuri_entry') boshuri_entry = self.xml.get_widget('boshuri_entry')
useauth_checkbutton = self.xml.get_widget('useauth_checkbutton') useauth_checkbutton = self.xml.get_widget('useauth_checkbutton')
boshuseproxy_checkbutton = self.xml.get_widget('boshuseproxy_checkbutton') boshuseproxy_checkbutton = self.xml.get_widget('boshuseproxy_checkbutton')
self.block_signal = True
proxyhost_entry.set_text('') proxyhost_entry.set_text('')
proxyport_entry.set_text('') proxyport_entry.set_text('')
proxyuser_entry.set_text('') proxyuser_entry.set_text('')
@ -1188,6 +1193,17 @@ class ManageProxiesWindow:
#useauth_checkbutton.set_active(False) #useauth_checkbutton.set_active(False)
#self.on_useauth_checkbutton_toggled(useauth_checkbutton) #self.on_useauth_checkbutton_toggled(useauth_checkbutton)
(model, iter_) = widget.get_selection().get_selected()
if not iter_:
self.xml.get_widget('proxyname_entry').set_text('')
self.xml.get_widget('proxytype_combobox').set_sensitive(False)
self.xml.get_widget('proxy_table').set_sensitive(False)
self.block_signal = False
return
proxy = model[iter_][0]
self.xml.get_widget('proxyname_entry').set_text(proxy)
if proxy == _('None'): # special proxy None if proxy == _('None'): # special proxy None
self.show_bosh_fields(False) self.show_bosh_fields(False)
self.proxyname_entry.set_editable(False) self.proxyname_entry.set_editable(False)
@ -1219,12 +1235,15 @@ class ManageProxiesWindow:
gajim.config.get_per('proxies', proxy, 'bosh_useproxy')) gajim.config.get_per('proxies', proxy, 'bosh_useproxy'))
useauth_checkbutton.set_active( useauth_checkbutton.set_active(
gajim.config.get_per('proxies', proxy, 'useauth')) gajim.config.get_per('proxies', proxy, 'useauth'))
self.block_signal = False
def on_proxies_treeview_key_press_event(self, widget, event): def on_proxies_treeview_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Delete: if event.keyval == gtk.keysyms.Delete:
self.on_remove_proxy_button_clicked(widget) self.on_remove_proxy_button_clicked(widget)
def on_proxyname_entry_changed(self, widget): def on_proxyname_entry_changed(self, widget):
if self.block_signal:
return
(model, iter_) = self.proxies_treeview.get_selection().get_selected() (model, iter_) = self.proxies_treeview.get_selection().get_selected()
if not iter_: if not iter_:
return return
@ -1243,6 +1262,8 @@ class ManageProxiesWindow:
model.set_value(iter_, 0, new_name) model.set_value(iter_, 0, new_name)
def on_proxytype_combobox_changed(self, widget): def on_proxytype_combobox_changed(self, widget):
if self.block_signal:
return
types = ['http', 'socks5', 'bosh'] types = ['http', 'socks5', 'bosh']
type_ = self.proxytype_combobox.get_active() type_ = self.proxytype_combobox.get_active()
self.show_bosh_fields(types[type_]=='bosh') self.show_bosh_fields(types[type_]=='bosh')
@ -1250,26 +1271,36 @@ class ManageProxiesWindow:
gajim.config.set_per('proxies', proxy, 'type', types[type_]) gajim.config.set_per('proxies', proxy, 'type', types[type_])
def on_proxyhost_entry_changed(self, widget): def on_proxyhost_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8') value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8') proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'host', value) gajim.config.set_per('proxies', proxy, 'host', value)
def on_proxyport_entry_changed(self, widget): def on_proxyport_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8') value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8') proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'port', value) gajim.config.set_per('proxies', proxy, 'port', value)
def on_proxyuser_entry_changed(self, widget): def on_proxyuser_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8') value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8') proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'user', value) gajim.config.set_per('proxies', proxy, 'user', value)
def on_boshuri_entry_changed(self, widget): def on_boshuri_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8') value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8') proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'bosh_uri', value) gajim.config.set_per('proxies', proxy, 'bosh_uri', value)
def on_proxypass_entry_changed(self, widget): def on_proxypass_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8') value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8') proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'pass', value) gajim.config.set_per('proxies', proxy, 'pass', value)

View File

@ -1698,7 +1698,8 @@ class ChangeNickDialog(InputDialogCheck):
if len(self.room_queue) == 0: if len(self.room_queue) == 0:
self.cancel_handler = None self.cancel_handler = None
self.dialog.destroy() self.dialog.destroy()
del gajim.interface.instances['change_nick_dialog'] if 'change_nick_dialog' in gajim.interface.instances:
del gajim.interface.instances['change_nick_dialog']
return return
self.account, self.room_jid, self.prompt = self.room_queue.pop(0) self.account, self.room_jid, self.prompt = self.room_queue.pop(0)
self.setup_dialog() self.setup_dialog()

View File

@ -3045,6 +3045,25 @@ class Interface:
pep.user_send_tune(acct, artist, title, source) pep.user_send_tune(acct, artist, title, source)
gajim.connections[acct].music_track_info = music_track_info gajim.connections[acct].music_track_info = music_track_info
def get_bg_fg_colors(self):
def gdkcolor_to_rgb (gdkcolor):
return [c / 65535. for c in (gdkcolor.red, gdkcolor.green,
gdkcolor.blue)]
def format_rgb (r, g, b):
return ' '.join([str(c) for c in ('rgb', r, g, b)])
def format_gdkcolor (gdkcolor):
return format_rgb (*gdkcolor_to_rgb (gdkcolor))
# get style colors and create string for dvipng
dummy = gtk.Invisible()
dummy.ensure_style()
style = dummy.get_style()
bg_str = format_gdkcolor(style.base[gtk.STATE_NORMAL])
fg_str = format_gdkcolor(style.text[gtk.STATE_NORMAL])
return (bg_str, fg_str)
def read_sleepy(self): def read_sleepy(self):
'''Check idle status and change that status if needed''' '''Check idle status and change that status if needed'''
if not self.sleeper.poll(): if not self.sleeper.poll():

View File

@ -158,6 +158,15 @@ class MessageWindow(object):
if self.account == old_name: if self.account == old_name:
self.account = new_name self.account = new_name
def change_jid(self, account, old_jid, new_jid):
''' call then when the full jid of a contral change'''
if account not in self._controls:
return
if old_jid not in self._controls[account]:
return
self._controls[account][new_jid] = self._controls[account][old_jid]
del self._controls[account][old_jid]
def get_num_controls(self): def get_num_controls(self):
return sum(len(d) for d in self._controls.values()) return sum(len(d) for d in self._controls.values())

View File

@ -88,8 +88,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
subject = msg.getSubject() subject = msg.getSubject()
if self.jid != full_jid_with_resource: if self.jid != full_jid_with_resource:
self.resource = gajim.get_nick_from_fjid(full_jid_with_resource) self.resource = gajim.get_nick_from_fjid(full_jid_with_resource)
if self.control: if self.control and self.control.resource:
self.control.resource = self.resource self.control.change_resource(self.resource)
if not msg_type or msg_type not in ('chat', 'groupchat', 'error'): if not msg_type or msg_type not in ('chat', 'groupchat', 'error'):
msg_type = 'normal' msg_type = 'normal'