diff --git a/src/chat.py b/src/chat.py index 9632810f8..b61029ab3 100644 --- a/src/chat.py +++ b/src/chat.py @@ -94,7 +94,7 @@ class Chat: chat = 'Chat' elif self.widget_name == 'groupchat_window': chat = 'Groupchat' - if len(self.plugin.accounts.keys()) >= 2: # if we have 2 or more accounts + if len(gajim.connections) >= 2: # if we have 2 or more accounts title = start + chat + ' (account: ' + self.account + ')' else: title = start + chat diff --git a/src/common/i18n.py b/src/common/i18n.py index 79cdc8910..a1367b83d 100644 --- a/src/common/i18n.py +++ b/src/common/i18n.py @@ -17,7 +17,7 @@ ## APP='gajim' -DIR='po' +DIR='../po' import locale, gettext diff --git a/src/config.py b/src/config.py index fc3c2c11c..b5108f477 100644 --- a/src/config.py +++ b/src/config.py @@ -170,10 +170,10 @@ class Preferences_window: def on_reset_colors_and_fonts_button_clicked(self, widget): gajim.config.set('accounttextcolor', \ gajim.config.get_default('accounttextcolor')) - gajim.config.set('grouptextcolor' \ + gajim.config.set('grouptextcolor', \ gajim.config.get_default('grouptextcolor')) gajim.config.set('usertextcolor', \ - gajim.config.get_default('usertextcolor'] + gajim.config.get_default('usertextcolor')) gajim.config.set('accountbgcolor', \ gajim.config.get_default('accountbgcolor')) gajim.config.set('groupbgcolor', gajim.config.get_default('groupbgcolor')) @@ -259,7 +259,7 @@ class Preferences_window: def update_print_time(self): """Update time in Opened Chat Windows""" - for a in self.plugin.accounts.keys(): + for a in gajim.connections: if self.plugin.windows[a]['chats'].has_key('tabbed'): self.plugin.windows[a]['chats']['tabbed'].update_print_time() else: @@ -302,7 +302,7 @@ class Preferences_window: def update_text_tags(self): """Update color tags in Opened Chat Windows""" - for a in self.plugin.accounts.keys(): + for a in gajim.connections: if self.plugin.windows[a]['chats'].has_key('tabbed'): self.plugin.windows[a]['chats']['tabbed'].update_tags() else: @@ -397,7 +397,7 @@ class Preferences_window: else: gajim.config.set('sound_' + sound_event, False) gajim.config.set('sound_' + sound_event + '_file', \ - model.get_value(iter, 2) + model.get_value(iter, 2)) iter = model.iter_next(iter) self.plugin.save_config() @@ -435,9 +435,9 @@ class Preferences_window: iter = model.iter_next(iter) i += 1 #FIXME: we need to remove options - while self.plugin.config.has_key('msg%s_name' % i): - del gajim.config.set('msg%i_name' % i] - del gajim.config.set('msg%i' % i] +# while self.plugin.config.has_key('msg%s_name' % i): +# del gajim.config.set('msg%i_name' % i) +# del gajim.config.set('msg%i' % i) i += 1 self.plugin.save_config() @@ -451,9 +451,9 @@ class Preferences_window: iter = model.iter_next(iter) i += 1 #FIXME: we need to remove options - while self.plugin.config.has_key('msg%s_name' % i): - del gajim.config.set('msg%i_name' % i] - del gajim.config.set('msg%i' % i] +# while self.plugin.config.has_key('msg%s_name' % i): +# del gajim.config.set('msg%i_name' % i) +# del gajim.config.set('msg%i' % i) i += 1 self.plugin.save_config() @@ -558,13 +558,13 @@ class Preferences_window: events = {} #events = {name : [use_it, file], name2 : [., .], ...} #FIXME: - for key in self.plugin.config.keys(): - if key.find('sound_') == 0: - if not self.plugin.config.has_key(key + '_file'): - continue - ev = key.replace('sound_', '') - events[ev] = [gajim.config.get(key), \ - gajim.config.get(key + '_file')] +# for key in self.plugin.config.keys(): +# if key.find('sound_') == 0: +# if not self.plugin.config.has_key(key + '_file'): +# continue +# ev = key.replace('sound_', '') +# events[ev] = [gajim.config.get(key), \ +# gajim.config.get(key + '_file')] model = self.sound_tree.get_model() model.clear() for ev in events: @@ -648,11 +648,12 @@ class Preferences_window: self.xml.get_widget('save_position_checkbutton').set_active(st) #Merge accounts - st = gajim.config.set('mergeaccounts') + st = gajim.config.get('mergeaccounts') self.xml.get_widget('merge_checkbutton').set_active(st) #iconset - list_style = os.listdir('plugins/gtkgui/iconsets/') + #FIXME: path + list_style = os.listdir('../data/iconsets/') model = gtk.ListStore(gobject.TYPE_STRING) self.iconset_combobox.set_model(model) l = [] @@ -763,7 +764,8 @@ class Preferences_window: #autopopupaway st = gajim.config.get('autopopupaway') self.auto_popup_away_checkbutton.set_active(st) - self.auto_popup_away_checkbutton.set_sensitive(gajim.config.set('autopopup']) + self.auto_popup_away_checkbutton.set_sensitive(gajim.config.get(\ + 'autopopup')) #Ignore messages from unknown contacts self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\ @@ -947,20 +949,20 @@ class Account_modification_window: self.xml.get_widget('gpg_choose_button').set_sensitive(False) else: if infos.has_key('keyid'): - if infos['keyid'] and gajim.config.get('usegpg'): - gpg_key_label.set_text(infos['keyid']) - if infos.has_key('keyname'): - self.xml.get_widget('gpg_name_label').set_text(infos['keyname']) - gpg_save_password_checkbutton = \ - self.xml.get_widget('gpg_save_password_checkbutton') - gpg_save_password_checkbutton.set_sensitive(True) - if infos.has_key('savegpgpass'): - gpg_save_password_checkbutton.set_active(infos['savegpgpass']) - if infos['savegpgpass']: - gpg_password_entry = self.xml.get_widget('gpg_password_entry') - gpg_password_entry.set_sensitive(True) - if infos.has_key('gpgpassword'): - gpg_password_entry.set_text(infos['gpgpassword']) + if infos['keyid'] and gajim.config.get('usegpg'): + gpg_key_label.set_text(infos['keyid']) + if infos.has_key('keyname'): + self.xml.get_widget('gpg_name_label').set_text(infos['keyname']) + gpg_save_password_checkbutton = \ + self.xml.get_widget('gpg_save_password_checkbutton') + gpg_save_password_checkbutton.set_sensitive(True) + if infos.has_key('savegpgpass'): + gpg_save_password_checkbutton.set_active(infos['savegpgpass']) + if infos['savegpgpass']: + gpg_password_entry = self.xml.get_widget('gpg_password_entry') + gpg_password_entry.set_sensitive(True) + if infos.has_key('gpgpassword'): + gpg_password_entry.set_text(infos['gpgpassword']) if infos.has_key('autoconnect'): self.xml.get_widget('autoconnect_checkbutton').set_active(\ infos['autoconnect']) @@ -1055,7 +1057,6 @@ class Account_modification_window: #update variables self.plugin.windows[name] = self.plugin.windows[self.account] self.plugin.queues[name] = self.plugin.queues[self.account] - self.plugin.connected[name] = self.plugin.connected[self.account] self.plugin.nicks[name] = self.plugin.nicks[self.account] self.plugin.roster.groups[name] = \ self.plugin.roster.groups[self.account] @@ -1081,19 +1082,32 @@ class Account_modification_window: del self.plugin.nicks[self.account] del self.plugin.roster.groups[self.account] del self.plugin.roster.contacts[self.account] - del self.plugin.accounts[self.account] del self.plugin.sleeper_state[self.account] - self.plugin.send('ACC_CHG', self.account, name) - self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\ - 'savepass': save_password, 'password': password, \ - 'resource': resource, 'priority' : priority, \ - 'autoconnect': autoconnect, 'use_proxy': use_proxy, 'proxyhost': \ - proxyhost, 'proxyport': proxyport, 'keyid': keyID, \ - 'keyname': key_name, 'savegpgpass': save_gpg_password, \ - 'gpgpassword': gpg_password, 'sync_with_global_status': \ - sync_with_global_status, 'no_log_for': self.infos['no_log_for']} - self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ - 'GtkGui')) + gajim.connections[self.account].name = name + gajim.connections[name] = gajim.connections[self.account] + del gajim.connections[self.account] + gajim.config.del_per('accounts', self.account) + gajim.config.add_per('accounts', name) + + gajim.config.set_per('accounts', name, 'name', login) + gajim.config.set_per('accounts', name, 'hostname', hostname) + gajim.config.set_per('accounts', name, 'savepass', save_password) + gajim.config.set_per('accounts', name, 'password', password) + gajim.config.set_per('accounts', name, 'resource', resource) + gajim.config.set_per('accounts', name, 'priority', priority) + gajim.config.set_per('accounts', name, 'autoconnect', autoconnect) + gajim.config.set_per('accounts', name, 'use_proxy', use_proxy) + gajim.config.set_per('accounts', name, 'proxyhost', proxyhost) + gajim.config.set_per('accounts', name, 'proxyport', proxyport) + gajim.config.set_per('accounts', name, 'keyid', keyID) + gajim.config.set_per('accounts', name, 'keyname', key_name) + gajim.config.set_per('accounts', name, 'savegpgpass', \ + save_gpg_password) + gajim.config.set_per('accounts', name, 'gpgpassword', gpg_password) + gajim.config.set_per('accounts', name, 'sync_with_global_status', \ + sync_with_global_status) + gajim.config.set_per('accounts', name, 'no_log_for', \ + self.infos['no_log_for']) if save_password: self.plugin.send('PASSPHRASE', name, password) #refresh accounts window @@ -1104,7 +1118,7 @@ class Account_modification_window: self.window.destroy() return #if it's a new account - if name in self.plugin.accounts.keys(): + if name in gajim.connections: Error_dialog(_('An account already has this name')) return #if we neeed to register a new account @@ -1112,21 +1126,30 @@ class Account_modification_window: self.plugin.send('NEW_ACC', None, (hostname, login, password, name, \ resource, priority, use_proxy, proxyhost, proxyport)) return - self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\ - 'savepass': save_password, 'password': password, 'resource': \ - resource, 'priority' : priority, 'autoconnect': autoconnect, \ - 'use_proxy': use_proxy, 'proxyhost': proxyhost, \ - 'proxyport': proxyport, 'keyid': keyID, 'keyname': key_name, \ - 'savegpgpass': save_gpg_password, 'gpgpassword': gpg_password,\ - 'sync_with_global_status': 1, 'no_log_for': self.infos['no_log_for']} - self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ - 'GtkGui')) + gajim.config.set_per('accounts', name, 'name', login) + gajim.config.set_per('accounts', name, 'hostname', hostname) + gajim.config.set_per('accounts', name, 'savepass', save_password) + gajim.config.set_per('accounts', name, 'password', password) + gajim.config.set_per('accounts', name, 'resource', resource) + gajim.config.set_per('accounts', name, 'priority', priority) + gajim.config.set_per('accounts', name, 'autoconnect', autoconnect) + gajim.config.set_per('accounts', name, 'use_proxy', use_proxy) + gajim.config.set_per('accounts', name, 'proxyhost', proxyhost) + gajim.config.set_per('accounts', name, 'proxyport', proxyport) + gajim.config.set_per('accounts', name, 'keyid', keyID) + gajim.config.set_per('accounts', name, 'keyname', key_name) + gajim.config.set_per('accounts', name, 'savegpgpass', \ + save_gpg_password) + gajim.config.set_per('accounts', name, 'gpgpassword', gpg_password) + gajim.config.set_per('accounts', name, 'sync_with_global_status', True) + gajim.config.set_per('accounts', name, 'no_log_for', \ + self.infos['no_log_for']) if save_password: self.plugin.send('PASSPHRASE', name, password) #update variables self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}} self.plugin.queues[name] = {} - self.plugin.connected[name] = 0 + gajim.config.connections[name].connected = 0 self.plugin.roster.groups[name] = {} self.plugin.roster.contacts[name] = {} self.plugin.roster.newly_added[name] = [] @@ -1184,15 +1207,23 @@ class Account_modification_window: no_log_for = '' if self.xml.get_widget('log_history_checkbutton').get_active(): no_log_for = acct - self.plugin.accounts[acct] = {'name': login, 'hostname': hostname,\ - 'savepass': save_password, 'password': password, 'resource': \ - resource, 'priority' : priority, 'autoconnect': autoconnect, \ - 'use_proxy': use_proxy, 'proxyhost': proxyhost, \ - 'proxyport': proxyport, 'keyid': keyID, 'keyname': key_name, \ - 'savegpgpass': save_gpg_password, 'gpgpassword': gpg_password,\ - 'sync_with_global_status': 1, 'no_log_for': no_log_for} - self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ - 'GtkGui')) + gajim.config.set_per('accounts', name, 'name', login) + gajim.config.set_per('accounts', name, 'hostname', hostname) + gajim.config.set_per('accounts', name, 'savepass', save_password) + gajim.config.set_per('accounts', name, 'password', password) + gajim.config.set_per('accounts', name, 'resource', resource) + gajim.config.set_per('accounts', name, 'priority', priority) + gajim.config.set_per('accounts', name, 'autoconnect', autoconnect) + gajim.config.set_per('accounts', name, 'use_proxy', use_proxy) + gajim.config.set_per('accounts', name, 'proxyhost', proxyhost) + gajim.config.set_per('accounts', name, 'proxyport', proxyport) + gajim.config.set_per('accounts', name, 'keyid', keyID) + gajim.config.set_per('accounts', name, 'keyname', key_name) + gajim.config.set_per('accounts', name, 'savegpgpass', \ + save_gpg_password) + gajim.config.set_per('accounts', name, 'gpgpassword', gpg_password) + gajim.config.set_per('accounts', name, 'sync_with_global_status', True) + gajim.config.set_per('accounts', name, 'no_log_for', no_log_for) def on_edit_details_button_clicked(self, widget): if not self.plugin.windows.has_key(self.account): @@ -1208,8 +1239,7 @@ class Account_modification_window: self.plugin.send('ASK_VCARD', self.account, jid) def on_gpg_choose_button_clicked(self, widget, data=None): - #FIXME: - secret_keys = connection.ask_gpg_secrete_keys() + secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys() if not secret_keys: Error_dialog(_('error contacting %s') % service) return @@ -1299,10 +1329,10 @@ class Accounts_window: self.delete_button.set_sensitive(False) model = self.accounts_treeview.get_model() model.clear() - for account in self.plugin.accounts: + for account in gajim.connections: iter = model.append() - model.set(iter, 0, account, 1,\ - self.plugin.accounts[account]['hostname']) + model.set(iter, 0, account, 1, gajim.config.get_per('accounts', \ + account, 'hostname')) def on_accounts_treeview_cursor_changed(self, widget): """Activate delete and modify buttons when a row is selected""" @@ -1327,14 +1357,12 @@ class Accounts_window: if dialog.get_response() == gtk.RESPONSE_YES: if self.plugin.connected[account]: self.plugin.send('STATUS', account, ('offline', 'offline')) - del self.plugin.accounts[account] - self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ - 'GtkGui')) + del gajim.connections[account] del self.plugin.windows[account] del self.plugin.queues[account] - del self.plugin.connected[account] del self.plugin.roster.groups[account] del self.plugin.roster.contacts[account] + #FIXME: missing things: to_be_deleted for ex self.plugin.roster.draw_roster() self.init_accounts() @@ -1345,6 +1373,7 @@ class Accounts_window: sel = self.accounts_treeview.get_selection() (model, iter) = sel.get_selected() account = model.get_value(iter, 0) + #FIXME: infos = self.plugin.accounts[account] infos['accname'] = account infos['jid'] = self.plugin.accounts[account]['name'] + \ @@ -1356,9 +1385,11 @@ class Accounts_window: def on_sync_with_global_status_checkbutton_toggled(self, widget): if widget.get_active(): - self.plugin.accounts[account]['sync_with_global_status'] = 0 + gajim.config.set_per('accounts', account, 'sync_with_global_status', \ + False) else: - self.plugin.accounts[account]['sync_with_global_status'] = 1 + gajim.config.set_per('accounts', account, 'sync_with_global_status', \ + True) def __init__(self, plugin): self.plugin = plugin @@ -1795,8 +1826,7 @@ class Service_discovery_window: if not iter : return service = model.get_value(iter, 1) - #FIXME: - infos = connection.ask_register_agent_info(service) + infos = gajim.connections[self.account].ask_register_agent_info(service) if not infos.has_key('instructions'): Error_dialog(_('error contacting %s') % service) else: @@ -1867,7 +1897,8 @@ class Service_discovery_window: self.address_comboboxentry.set_model(liststore) self.address_comboboxentry.set_text_column(0) self.latest_addresses = gajim.config.get('latest_disco_addresses').split() - server_address = self.plugin.accounts[self.account]['hostname'] + server_address = gajim.config.get_per('accounts', self.account, \ + 'hostname') if server_address in self.latest_addresses: self.latest_addresses.remove(server_address) self.latest_addresses.insert(0, server_address) diff --git a/src/dialogs.py b/src/dialogs.py index 1bebaec24..499b02e38 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -20,6 +20,7 @@ import gtk import gtk.glade import gobject +from common import gajim from common import i18n _ = i18n._ APP = i18n.APP @@ -55,23 +56,19 @@ class Vcard_information_window: self.plugin.send('UPDUSER', self.account, (self.user.jid, \ self.user.name, self.user.groups)) #log history ? - account_info = self.plugin.accounts[self.account] oldlog = 1 - no_log_for = [] - if account_info.has_key('no_log_for'): - no_log_for = account_info['no_log_for'].split() - if self.user.jid in no_log_for: - oldlog = 0 + no_log_for = gajim.config.get_per('accounts', self.account, 'no_log_for')\ + .split() + if self.user.jid in no_log_for: + oldlog = 0 log = self.xml.get_widget('log_checkbutton').get_active() if not log and not self.user.jid in no_log_for: no_log_for.append(self.user.jid) if log and self.user.jid in no_log_for: no_log_for.remove(self.user.jid) if oldlog != log: - account_info['no_log_for'] = ' '.join(no_log_for) - self.plugin.accounts[self.account] = account_info - self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ - 'Gtkgui')) + gajim.config.set_per('accounts', self.account, 'no_log_for', \ + ' '.join(no_log_for)) self.window.destroy() def set_value(self, entry_name, value): @@ -105,11 +102,10 @@ class Vcard_information_window: else: self.xml.get_widget('ask_label').set_text('None') self.xml.get_widget('nickname_entry').set_text(self.user.name) - account_info = self.plugin.accounts[self.account] log = 1 - if account_info.has_key('no_log_for'): - if self.user.jid in account_info['no_log_for'].split(' '): - log = 0 + if self.user.jid in gajim.config.get_per('accounts', account, \ + 'no_log_for').split(' '): + log = 0 self.xml.get_widget('log_checkbutton').set_active(log) resources = self.user.resource + ' (' + str(self.user.priority) + ')' if not self.user.status: @@ -165,7 +161,7 @@ class Vcard_information_window: if vcard.has_key('NICKNAME'): nick = vcard['NICKNAME'] if nick == '': - nick = self.plugin.accounts[self.account]['name'] + nick = gajim.config.get_per('accounts', self.account, 'name') self.plugin.nicks[self.account] = nick self.plugin.send('VCARD', self.account, vcard) @@ -738,9 +734,9 @@ class New_message_dialog: self.window = self.xml.get_widget('new_message_dialog') self.jid_entry = self.xml.get_widget('jid_entry') - our_jid = self.plugin.accounts[account]['name'] + '@' +\ - self.plugin.accounts[account]['hostname'] - if len(self.plugin.accounts) > 1: + our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \ + gajim.config.get_per('accounts', self.account, 'hostname') + if len(gajim.config.connections) > 1: title = 'New Message as ' + our_jid else: title = 'New Message' diff --git a/src/groupchat_window.py b/src/groupchat_window.py index f971155de..b5ad07a7c 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -22,7 +22,7 @@ import gtk.glade import pango import gobject import time - +from common import gajim from dialogs import * from chat import * from gtkgui import CellRendererImage diff --git a/src/gtkgui.py b/src/gtkgui.py index 0be4a186f..190ff2dd4 100644 --- a/src/gtkgui.py +++ b/src/gtkgui.py @@ -25,10 +25,17 @@ import pango import gobject import os import sre -global gajim -import common.gajim as gajim +from common import gajim import common.sleepy +from common import i18n +i18n.init() +_ = i18n._ +APP = i18n.APP +gtk.glade.bindtextdomain(APP, i18n.DIR) +gtk.glade.textdomain(APP) + + try: import winsound # windows-only built-in module for playing wav except ImportError: @@ -163,13 +170,6 @@ from systray import * from dialogs import * from config import * -from common import i18n - -_ = i18n._ -APP = i18n.APP -gtk.glade.bindtextdomain(APP, i18n.DIR) -gtk.glade.textdomain(APP) - GTKGUI_GLADE='gtkgui.glade' @@ -313,12 +313,12 @@ class interface: #It isn't an agent self.roster.chg_user_status(user1, array[1], array[2], account) #play sound - if old_show < 2 and new_show > 1 and \ - self.config['sound_contact_connected']: + if old_show < 2 and new_show > 1 and gajim.config.get( \ + 'sound_contact_connected'): self.play_sound('sound_contact_connected') if not self.windows[account]['chats'].has_key(jid) and \ - not self.queues[account].has_key(jid) and \ - not self.config['autopopup']: + not self.queues[account].has_key(jid) and not gajim.config.get( \ + 'autopopup'): #FIXME: #DOES NOT ALWAYS WORK WHY? #I control nkour@lagaule in jabber @@ -329,12 +329,12 @@ class interface: # new message works instance = Popup_window(self, 'Contact Online', jid, account) self.roster.popup_windows.append(instance) - elif old_show > 1 and new_show < 2 and \ - self.config['sound_contact_disconnected']: + elif old_show > 1 and new_show < 2 and gajim.config.get( \ + 'sound_contact_disconnected'): self.play_sound('sound_contact_disconnected') if not self.windows[account]['chats'].has_key(jid) and \ - not self.queues[account].has_key(jid) and \ - not self.config['autopopup']: + not self.queues[account].has_key(jid) and not gajim.config.get( \ + 'autopopup'): instance = Popup_window(self, 'Contact Offline', jid, account) self.roster.popup_windows.append(instance) @@ -349,7 +349,7 @@ class interface: jid = array[0].split('/')[0] if jid.find("@") <= 0: jid = jid.replace('@', '') - if self.config['ignore_unknown_contacts'] and \ + if gajim.config.get('ignore_unknown_contacts') and \ not self.roster.contacts[account].has_key(jid): return @@ -357,13 +357,13 @@ class interface: if not self.windows[account]['chats'].has_key(jid) and \ not self.queues[account].has_key(jid): first = True - if not self.config['autopopup']: + if not gajim.config.get('autopopup'): instance = Popup_window(self, 'New Message', jid, account) self.roster.popup_windows.append(instance) self.roster.on_message(jid, array[1], array[2], account) - if self.config['sound_first_message_received'] and first: + if gajim.config.get('sound_first_message_received') and first: self.play_sound('sound_first_message_received') - if self.config['sound_next_message_received'] and not first: + if gajim.config.get('sound_next_message_received') and not first: self.play_sound('sound_next_message_received') def handle_event_msgerror(self, account, array): @@ -376,7 +376,7 @@ class interface: def handle_event_msgsent(self, account, array): #('MSG', account, (jid, msg, keyID)) - if self.config['sound_message_sent']: + if gajim.config.get('sound_message_sent'): self.play_sound('sound_message_sent') def handle_event_subscribe(self, account, array): @@ -430,22 +430,22 @@ class interface: if self.windows['account_modification']: self.windows['account_modification'].account_is_ok(array[1]) else: - self.accounts[name] = {'name': array[1], \ - 'hostname': array[0],\ - 'password': array[2],\ - 'resource': array[4],\ - 'priority': array[5],\ - 'use_proxy': array[6],\ - 'proxyhost': array[7], \ - 'proxyport': array[8]} - self.send('CONFIG', None, ('accounts', self.accounts, 'GtkGui')) + gajim.config.set_per('accounts', name, 'name', array[1]) + gajim.config.set_per('accounts', name, 'hostname', array[0]) + gajim.config.set_per('accounts', name, 'password', array[2]) + gajim.config.set_per('accounts', name, 'resource', array[4]) + gajim.config.set_per('accounts', name, 'priority', array[5]) + gajim.config.set_per('accounts', name, 'use_proxy', array[6]) + gajim.config.set_per('accounts', name, 'proxyhost', array[7]) + gajim.config.set_per('accounts', name, 'proxyport', array[8]) self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}} self.queues[name] = {} - self.connected[name] = 0 + gajim.connections[name].connected = 0 self.nicks[name] = array[1] self.roster.groups[name] = {} self.roster.contacts[name] = {} self.sleeper_state[name] = 0 + #FIXME: add missing to_be_deleted for ex if self.windows.has_key('accounts'): self.windows['accounts'].init_accounts() self.roster.draw_roster() @@ -458,7 +458,7 @@ class interface: if array.has_key('NICKNAME'): nick = array['NICKNAME'] if nick == '': - nick = self.accounts[account]['name'] + nick = gajim.config.get_per('accounts', account, 'name') self.nicks[account] = nick def handle_event_vcard(self, account, array): @@ -525,7 +525,7 @@ class interface: if not self.sleeper.poll(): return 1 state = self.sleeper.getState() - for account in self.accounts.keys(): + for account in gajim.connections: if not self.sleeper_state[account]: continue if state == common.sleepy.STATE_AWAKE and \ @@ -535,14 +535,14 @@ class interface: self.sleeper_state[account] = 1 elif state == common.sleepy.STATE_AWAY and \ self.sleeper_state[account] == 1 and \ - self.config['autoaway']: + gajim.config.get('autoaway'): #we go away self.send('STATUS', account, ('away', 'auto away (idle)')) self.sleeper_state[account] = 2 elif state == common.sleepy.STATE_XAWAY and (\ self.sleeper_state[account] == 2 or \ self.sleeper_state[account] == 1) and \ - self.config['autoxa']: + gajim.config.get('autoxa'): #we go extended away self.send('STATUS', account, ('xa', 'auto away (idle)')) self.sleeper_state[account] = 3 @@ -551,19 +551,17 @@ class interface: def autoconnect(self): """auto connect at startup""" ask_message = 0 - for a in self.accounts.keys(): - if self.accounts[a].has_key('autoconnect'): - if self.accounts[a]['autoconnect']: - ask_message = 1 - break + for a in gajim.connections: + if gajim.config.get_per('accounts', a, 'autoconnect'): + ask_message = 1 + break if ask_message: message = self.roster.get_status_message('online', 1) if message == -1: return - for a in self.accounts.keys(): - if self.accounts[a].has_key('autoconnect'): - if self.accounts[a]['autoconnect']: - self.roster.send_status(a, 'online', message, 1) + for a in gajim.connections: + if gajim.config.get_per('accounts', a, 'autoconnect'): + self.roster.send_status(a, 'online', message, 1) return 0 def show_systray(self): @@ -642,7 +640,7 @@ class interface: def init_regexp(self): #initialize emoticons dictionary self.emoticons = dict() - split_line = self.config['emoticons'].split('\t') + split_line = gajim.config.get('emoticons').split('\t') for i in range(0, len(split_line)/2): emot_file = split_line[2*i+1] if not self.image_is_ok(emot_file): diff --git a/src/history_window.py b/src/history_window.py index 839be845d..d2dc359cc 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -21,6 +21,7 @@ import gtk import gtk.glade import time +from common import gajim from common import i18n _ = i18n._ diff --git a/src/roster_window.py b/src/roster_window.py index 64904cd97..2f7c642ee 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -25,6 +25,7 @@ import os import Queue import common.sleepy +from common import gajim from tabbed_chat_window import * from groupchat_window import * from history_window import * @@ -250,7 +251,7 @@ class Roster_window: join_gc_menuitem.remove_submenu() if new_message_menuitem.get_submenu(): new_message_menuitem.remove_submenu() - if len(self.plugin.accounts.keys()) > 0: + if len(gajim.connections) > 0: new_message_menuitem.set_sensitive(True) join_gc_menuitem.set_sensitive(True) add_new_contact_menuitem.set_sensitive(True) @@ -260,21 +261,21 @@ class Roster_window: join_gc_menuitem.set_sensitive(False) add_new_contact_menuitem.set_sensitive(False) service_disco_menuitem.set_sensitive(False) - if len(self.plugin.accounts.keys()) >= 2: # 2 or more accounts? make submenus + if len(gajim.connections) >= 2: # 2 or more accounts? make submenus #add sub_menu = gtk.Menu() add_new_contact_menuitem.set_submenu(sub_menu) - for account in self.plugin.accounts.keys(): + for account in gajim.connections: item = gtk.MenuItem(_('to ') + account + _(' account')) sub_menu.append(item) - item.connect("activate", self.on_add_new_contact, account) + item.connect('activate', self.on_add_new_contact, account) sub_menu.show_all() #disco sub_menu = gtk.Menu() service_disco_menuitem.set_submenu(sub_menu) - for account in self.plugin.accounts.keys(): - our_jid = self.plugin.accounts[account]['name'] + '@' +\ - self.plugin.accounts[account]['hostname'] + for account in gajim.connections: + our_jid = gajim.config.get_per('accounts', account, 'name') + '@' +\ + gajim.config.get_per('accounts', account, 'hostname') item = gtk.MenuItem(_('using ') + account + _(' account')) sub_menu.append(item) item.connect('activate', self.on_service_disco_menuitem_activate, account) @@ -282,39 +283,43 @@ class Roster_window: #join gc sub_menu = gtk.Menu() join_gc_menuitem.set_submenu(sub_menu) - for account in self.plugin.accounts.keys(): - our_jid = self.plugin.accounts[account]['name'] + '@' +\ - self.plugin.accounts[account]['hostname'] + for account in gajim.connections: + our_jid = gajim.config.get_per('accounts', account, 'name') + '@' +\ + gajim.config.get_per('accounts', account, 'hostname') item = gtk.MenuItem(_('as ') + our_jid) sub_menu.append(item) - item.connect("activate", self.on_join_gc_activate, account) + item.connect('activate', self.on_join_gc_activate, account) sub_menu.show_all() #new message sub_menu = gtk.Menu() new_message_menuitem.set_submenu(sub_menu) - for account in self.plugin.accounts.keys(): - our_jid = self.plugin.accounts[account]['name'] + '@' +\ - self.plugin.accounts[account]['hostname'] + for account in gajim.connections: + our_jid = gajim.config.get_per('accounts', account, 'name') + '@' +\ + gajim.config.get_per('accounts', account, 'hostname') item = gtk.MenuItem(_('as ') + our_jid) sub_menu.append(item) - item.connect('activate', self.on_new_message_menuitem_activate, account) + item.connect('activate', self.on_new_message_menuitem_activate, \ + account) sub_menu.show_all() - elif len(self.plugin.accounts.keys()) == 1: # one account + elif len(gajim.connections) == 1: # one account #add if not self.add_new_contact_handler_id: self.add_new_contact_handler_id = add_new_contact_menuitem.connect(\ - 'activate', self.on_add_new_contact, self.plugin.accounts.keys()[0]) + 'activate', self.on_add_new_contact, gajim.connections.keys()[0]) #disco if not self.service_disco_handler_id: - self.service_disco_handler_id = service_disco_menuitem.connect(\ -'activate', self.on_service_disco_menuitem_activate, self.plugin.accounts.keys()[0]) + self.service_disco_handler_id = service_disco_menuitem.connect( \ + 'activate', self.on_service_disco_menuitem_activate, \ + gajim.connections.keys()[0]) #join_gc if not self.join_gc_handler_id: - self.join_gc_handler_id = join_gc_menuitem.connect(\ - 'activate', self.on_join_gc_activate, self.plugin.accounts.keys()[0]) + self.join_gc_handler_id = join_gc_menuitem.connect( \ + 'activate', self.on_join_gc_activate, gajim.connections.keys()\ + [0]) if not self.new_message_menuitem_handler_id: - self.new_message_menuitem_handler_id = new_message_menuitem.connect(\ -'activate', self.on_new_message_menuitem_activate, self.plugin.accounts.keys()[0]) + self.new_message_menuitem_handler_id = new_message_menuitem. \ + connect('activate', self.on_new_message_menuitem_activate, \ + gajim.connections.keys()[0]) def draw_roster(self): """Clear and draw roster""" @@ -526,6 +531,7 @@ class Roster_window: def on_edit_account(self, widget, account): if not self.plugin.windows.has_key('account_modification_window'): + #FIXME: infos = self.plugin.accounts[account] infos['accname'] = account infos['jid'] = self.plugin.accounts[account]["name"] + \ @@ -696,8 +702,7 @@ class Roster_window: self.plugin.systray.set_status('connecting') save_pass = 0 - if self.plugin.accounts[account].has_key('savepass'): - save_pass = self.plugin.accounts[account]['savepass'] + save_pass = gajim.config.get_per('accounts', account, 'savepass') if not save_pass and self.plugin.connected[account] < 2: passphrase = '' w = Passphrase_dialog(_('Enter your password for account %s') \ @@ -712,19 +717,19 @@ class Roster_window: return self.plugin.send('PASSPHRASE', account, passphrase) if save: - self.plugin.accounts[account]['savepass'] = 1 - self.plugin.accounts[account]['password'] = passphrase + gajim.config.set_per('accounts', account, 'savepass', True) + gajim.config.set_per('accounts', account, 'password', passphrase) keyid = None save_gpg_pass = 0 - if self.plugin.accounts[account].has_key('savegpgpass'): - save_gpg_pass = self.plugin.accounts[account]['savegpgpass'] - if self.plugin.accounts[account].has_key('keyid'): - keyid = self.plugin.accounts[account]['keyid'] + save_gpg_pass = gajim.config.get_per('accounts', account, \ + 'savegpgpass') + keyid = gajim.config.get_per('accounts', account, 'keyid') if keyid and self.plugin.connected[account] < 2 and \ gajim.config.get('usegpg'): if save_gpg_pass: - passphrase = self.plugin.accounts[account]['gpgpassword'] + passphrase = gajim.config.get_per('accounts', account, \ + 'gpgpassword') else: passphrase = '' w = Passphrase_dialog(\ @@ -734,8 +739,10 @@ class Roster_window: if passphrase == -1: passphrase = '' if save: - self.plugin.accounts[account]['savegpgpass'] = 1 - self.plugin.accounts[account]['gpgpassword'] = passphrase + gajim.config.set_per('accounts', account, 'savegpgpass', True) + gajim.config.set_per('accounts', account, 'gpgpassword', \ + passphrase) + #FIXME: self.plugin.send('GPGPASSPHRASE', account, passphrase) self.plugin.send('STATUS', account, (status, txt)) for room_jid in self.plugin.windows[account]['gc']: @@ -769,7 +776,7 @@ class Roster_window: active = self.status_combobox.get_active() if active < 0: return - accounts = self.plugin.accounts.keys() + accounts = gajim.connections.keys() if len(accounts) == 0: Error_dialog(_('You must create an account before connecting to jabber network.')) self.update_status_comboxbox() @@ -780,9 +787,9 @@ class Roster_window: self.update_status_comboxbox() return for acct in accounts: - if self.plugin.accounts[acct].has_key('sync_with_global_status'): - if not self.plugin.accounts[acct]['sync_with_global_status']: - continue + if not gajim.config.get_per('accounts', acct, \ + 'sync_with_global_status'): + continue self.send_status(acct, status, message) def update_status_comboxbox(self): @@ -945,7 +952,7 @@ class Roster_window: if self.plugin.systray_enabled: self.window.hide() else: - accounts = self.plugin.accounts.keys() + accounts = gajim.connections.keys() get_msg = False for acct in accounts: if self.plugin.connected[acct]: @@ -981,7 +988,7 @@ class Roster_window: gtk.main_quit() def on_quit_menuitem_activate(self, widget): - accounts = self.plugin.accounts.keys() + accounts = gajim.connections.keys() get_msg = False for acct in accounts: if self.plugin.connected[acct]: @@ -1139,7 +1146,7 @@ class Roster_window: # Update the systray if self.plugin.systray_enabled: self.plugin.systray.set_img() - for account in self.plugin.accounts.keys(): + for account in gajim.connected: # Update opened chat windows for jid in self.plugin.windows[account]['chats']: if jid != 'tabbed': @@ -1338,7 +1345,7 @@ class Roster_window: self.to_be_removed = {} self.popups_height = 0 self.popup_windows = [] - for a in self.plugin.accounts.keys(): + for a in gajim.connections: self.contacts[a] = {} self.groups[a] = {} self.newly_added[a] = [] @@ -1416,6 +1423,6 @@ class Roster_window: self.hidden_lines = gajim.config.get('hiddenlines').split('\t') self.draw_roster() - if len(self.plugin.accounts) == 0: # if no account + if len(gajim.connections) == 0: # if no account self.plugin.windows['account_modification'] = \ Account_modification_window(self.plugin, {}) diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index 2e0753d82..98a73d851 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -23,6 +23,7 @@ import pango import gobject import time +from common import gajim from dialogs import * from history_window import * from chat import *