plugin.accounts[name] -> gajim.config.get_per()

This commit is contained in:
Yann Leboulanger 2005-04-14 07:05:10 +00:00
parent c5553d27a3
commit b40bcc9105
9 changed files with 226 additions and 192 deletions

View file

@ -94,7 +94,7 @@ class Chat:
chat = 'Chat' chat = 'Chat'
elif self.widget_name == 'groupchat_window': elif self.widget_name == 'groupchat_window':
chat = 'Groupchat' 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 + ')' title = start + chat + ' (account: ' + self.account + ')'
else: else:
title = start + chat title = start + chat

View file

@ -17,7 +17,7 @@
## ##
APP='gajim' APP='gajim'
DIR='po' DIR='../po'
import locale, gettext import locale, gettext

View file

@ -170,10 +170,10 @@ class Preferences_window:
def on_reset_colors_and_fonts_button_clicked(self, widget): def on_reset_colors_and_fonts_button_clicked(self, widget):
gajim.config.set('accounttextcolor', \ gajim.config.set('accounttextcolor', \
gajim.config.get_default('accounttextcolor')) gajim.config.get_default('accounttextcolor'))
gajim.config.set('grouptextcolor' \ gajim.config.set('grouptextcolor', \
gajim.config.get_default('grouptextcolor')) gajim.config.get_default('grouptextcolor'))
gajim.config.set('usertextcolor', \ gajim.config.set('usertextcolor', \
gajim.config.get_default('usertextcolor'] gajim.config.get_default('usertextcolor'))
gajim.config.set('accountbgcolor', \ gajim.config.set('accountbgcolor', \
gajim.config.get_default('accountbgcolor')) gajim.config.get_default('accountbgcolor'))
gajim.config.set('groupbgcolor', gajim.config.get_default('groupbgcolor')) gajim.config.set('groupbgcolor', gajim.config.get_default('groupbgcolor'))
@ -259,7 +259,7 @@ class Preferences_window:
def update_print_time(self): def update_print_time(self):
"""Update time in Opened Chat Windows""" """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'): if self.plugin.windows[a]['chats'].has_key('tabbed'):
self.plugin.windows[a]['chats']['tabbed'].update_print_time() self.plugin.windows[a]['chats']['tabbed'].update_print_time()
else: else:
@ -302,7 +302,7 @@ class Preferences_window:
def update_text_tags(self): def update_text_tags(self):
"""Update color tags in Opened Chat Windows""" """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'): if self.plugin.windows[a]['chats'].has_key('tabbed'):
self.plugin.windows[a]['chats']['tabbed'].update_tags() self.plugin.windows[a]['chats']['tabbed'].update_tags()
else: else:
@ -397,7 +397,7 @@ class Preferences_window:
else: else:
gajim.config.set('sound_' + sound_event, False) gajim.config.set('sound_' + sound_event, False)
gajim.config.set('sound_' + sound_event + '_file', \ gajim.config.set('sound_' + sound_event + '_file', \
model.get_value(iter, 2) model.get_value(iter, 2))
iter = model.iter_next(iter) iter = model.iter_next(iter)
self.plugin.save_config() self.plugin.save_config()
@ -435,9 +435,9 @@ class Preferences_window:
iter = model.iter_next(iter) iter = model.iter_next(iter)
i += 1 i += 1
#FIXME: we need to remove options #FIXME: we need to remove options
while self.plugin.config.has_key('msg%s_name' % 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_name' % i)
del gajim.config.set('msg%i' % i] # del gajim.config.set('msg%i' % i)
i += 1 i += 1
self.plugin.save_config() self.plugin.save_config()
@ -451,9 +451,9 @@ class Preferences_window:
iter = model.iter_next(iter) iter = model.iter_next(iter)
i += 1 i += 1
#FIXME: we need to remove options #FIXME: we need to remove options
while self.plugin.config.has_key('msg%s_name' % 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_name' % i)
del gajim.config.set('msg%i' % i] # del gajim.config.set('msg%i' % i)
i += 1 i += 1
self.plugin.save_config() self.plugin.save_config()
@ -558,13 +558,13 @@ class Preferences_window:
events = {} events = {}
#events = {name : [use_it, file], name2 : [., .], ...} #events = {name : [use_it, file], name2 : [., .], ...}
#FIXME: #FIXME:
for key in self.plugin.config.keys(): # for key in self.plugin.config.keys():
if key.find('sound_') == 0: # if key.find('sound_') == 0:
if not self.plugin.config.has_key(key + '_file'): # if not self.plugin.config.has_key(key + '_file'):
continue # continue
ev = key.replace('sound_', '') # ev = key.replace('sound_', '')
events[ev] = [gajim.config.get(key), \ # events[ev] = [gajim.config.get(key), \
gajim.config.get(key + '_file')] # gajim.config.get(key + '_file')]
model = self.sound_tree.get_model() model = self.sound_tree.get_model()
model.clear() model.clear()
for ev in events: for ev in events:
@ -648,11 +648,12 @@ class Preferences_window:
self.xml.get_widget('save_position_checkbutton').set_active(st) self.xml.get_widget('save_position_checkbutton').set_active(st)
#Merge accounts #Merge accounts
st = gajim.config.set('mergeaccounts') st = gajim.config.get('mergeaccounts')
self.xml.get_widget('merge_checkbutton').set_active(st) self.xml.get_widget('merge_checkbutton').set_active(st)
#iconset #iconset
list_style = os.listdir('plugins/gtkgui/iconsets/') #FIXME: path
list_style = os.listdir('../data/iconsets/')
model = gtk.ListStore(gobject.TYPE_STRING) model = gtk.ListStore(gobject.TYPE_STRING)
self.iconset_combobox.set_model(model) self.iconset_combobox.set_model(model)
l = [] l = []
@ -763,7 +764,8 @@ class Preferences_window:
#autopopupaway #autopopupaway
st = gajim.config.get('autopopupaway') st = gajim.config.get('autopopupaway')
self.auto_popup_away_checkbutton.set_active(st) 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 #Ignore messages from unknown contacts
self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\ self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\
@ -1055,7 +1057,6 @@ class Account_modification_window:
#update variables #update variables
self.plugin.windows[name] = self.plugin.windows[self.account] self.plugin.windows[name] = self.plugin.windows[self.account]
self.plugin.queues[name] = self.plugin.queues[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.nicks[name] = self.plugin.nicks[self.account]
self.plugin.roster.groups[name] = \ self.plugin.roster.groups[name] = \
self.plugin.roster.groups[self.account] self.plugin.roster.groups[self.account]
@ -1081,19 +1082,32 @@ class Account_modification_window:
del self.plugin.nicks[self.account] del self.plugin.nicks[self.account]
del self.plugin.roster.groups[self.account] del self.plugin.roster.groups[self.account]
del self.plugin.roster.contacts[self.account] del self.plugin.roster.contacts[self.account]
del self.plugin.accounts[self.account]
del self.plugin.sleeper_state[self.account] del self.plugin.sleeper_state[self.account]
self.plugin.send('ACC_CHG', self.account, name) gajim.connections[self.account].name = name
self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\ gajim.connections[name] = gajim.connections[self.account]
'savepass': save_password, 'password': password, \ del gajim.connections[self.account]
'resource': resource, 'priority' : priority, \ gajim.config.del_per('accounts', self.account)
'autoconnect': autoconnect, 'use_proxy': use_proxy, 'proxyhost': \ gajim.config.add_per('accounts', name)
proxyhost, 'proxyport': proxyport, 'keyid': keyID, \
'keyname': key_name, 'savegpgpass': save_gpg_password, \ gajim.config.set_per('accounts', name, 'name', login)
'gpgpassword': gpg_password, 'sync_with_global_status': \ gajim.config.set_per('accounts', name, 'hostname', hostname)
sync_with_global_status, 'no_log_for': self.infos['no_log_for']} gajim.config.set_per('accounts', name, 'savepass', save_password)
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ gajim.config.set_per('accounts', name, 'password', password)
'GtkGui')) 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: if save_password:
self.plugin.send('PASSPHRASE', name, password) self.plugin.send('PASSPHRASE', name, password)
#refresh accounts window #refresh accounts window
@ -1104,7 +1118,7 @@ class Account_modification_window:
self.window.destroy() self.window.destroy()
return return
#if it's a new account #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')) Error_dialog(_('An account already has this name'))
return return
#if we neeed to register a new account #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, \ self.plugin.send('NEW_ACC', None, (hostname, login, password, name, \
resource, priority, use_proxy, proxyhost, proxyport)) resource, priority, use_proxy, proxyhost, proxyport))
return return
self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\ gajim.config.set_per('accounts', name, 'name', login)
'savepass': save_password, 'password': password, 'resource': \ gajim.config.set_per('accounts', name, 'hostname', hostname)
resource, 'priority' : priority, 'autoconnect': autoconnect, \ gajim.config.set_per('accounts', name, 'savepass', save_password)
'use_proxy': use_proxy, 'proxyhost': proxyhost, \ gajim.config.set_per('accounts', name, 'password', password)
'proxyport': proxyport, 'keyid': keyID, 'keyname': key_name, \ gajim.config.set_per('accounts', name, 'resource', resource)
'savegpgpass': save_gpg_password, 'gpgpassword': gpg_password,\ gajim.config.set_per('accounts', name, 'priority', priority)
'sync_with_global_status': 1, 'no_log_for': self.infos['no_log_for']} gajim.config.set_per('accounts', name, 'autoconnect', autoconnect)
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ gajim.config.set_per('accounts', name, 'use_proxy', use_proxy)
'GtkGui')) 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: if save_password:
self.plugin.send('PASSPHRASE', name, password) self.plugin.send('PASSPHRASE', name, password)
#update variables #update variables
self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}} self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}}
self.plugin.queues[name] = {} self.plugin.queues[name] = {}
self.plugin.connected[name] = 0 gajim.config.connections[name].connected = 0
self.plugin.roster.groups[name] = {} self.plugin.roster.groups[name] = {}
self.plugin.roster.contacts[name] = {} self.plugin.roster.contacts[name] = {}
self.plugin.roster.newly_added[name] = [] self.plugin.roster.newly_added[name] = []
@ -1184,15 +1207,23 @@ class Account_modification_window:
no_log_for = '' no_log_for = ''
if self.xml.get_widget('log_history_checkbutton').get_active(): if self.xml.get_widget('log_history_checkbutton').get_active():
no_log_for = acct no_log_for = acct
self.plugin.accounts[acct] = {'name': login, 'hostname': hostname,\ gajim.config.set_per('accounts', name, 'name', login)
'savepass': save_password, 'password': password, 'resource': \ gajim.config.set_per('accounts', name, 'hostname', hostname)
resource, 'priority' : priority, 'autoconnect': autoconnect, \ gajim.config.set_per('accounts', name, 'savepass', save_password)
'use_proxy': use_proxy, 'proxyhost': proxyhost, \ gajim.config.set_per('accounts', name, 'password', password)
'proxyport': proxyport, 'keyid': keyID, 'keyname': key_name, \ gajim.config.set_per('accounts', name, 'resource', resource)
'savegpgpass': save_gpg_password, 'gpgpassword': gpg_password,\ gajim.config.set_per('accounts', name, 'priority', priority)
'sync_with_global_status': 1, 'no_log_for': no_log_for} gajim.config.set_per('accounts', name, 'autoconnect', autoconnect)
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ gajim.config.set_per('accounts', name, 'use_proxy', use_proxy)
'GtkGui')) 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): def on_edit_details_button_clicked(self, widget):
if not self.plugin.windows.has_key(self.account): 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) self.plugin.send('ASK_VCARD', self.account, jid)
def on_gpg_choose_button_clicked(self, widget, data=None): def on_gpg_choose_button_clicked(self, widget, data=None):
#FIXME: secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys()
secret_keys = connection.ask_gpg_secrete_keys()
if not secret_keys: if not secret_keys:
Error_dialog(_('error contacting %s') % service) Error_dialog(_('error contacting %s') % service)
return return
@ -1299,10 +1329,10 @@ class Accounts_window:
self.delete_button.set_sensitive(False) self.delete_button.set_sensitive(False)
model = self.accounts_treeview.get_model() model = self.accounts_treeview.get_model()
model.clear() model.clear()
for account in self.plugin.accounts: for account in gajim.connections:
iter = model.append() iter = model.append()
model.set(iter, 0, account, 1,\ model.set(iter, 0, account, 1, gajim.config.get_per('accounts', \
self.plugin.accounts[account]['hostname']) account, 'hostname'))
def on_accounts_treeview_cursor_changed(self, widget): def on_accounts_treeview_cursor_changed(self, widget):
"""Activate delete and modify buttons when a row is selected""" """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 dialog.get_response() == gtk.RESPONSE_YES:
if self.plugin.connected[account]: if self.plugin.connected[account]:
self.plugin.send('STATUS', account, ('offline', 'offline')) self.plugin.send('STATUS', account, ('offline', 'offline'))
del self.plugin.accounts[account] del gajim.connections[account]
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
'GtkGui'))
del self.plugin.windows[account] del self.plugin.windows[account]
del self.plugin.queues[account] del self.plugin.queues[account]
del self.plugin.connected[account]
del self.plugin.roster.groups[account] del self.plugin.roster.groups[account]
del self.plugin.roster.contacts[account] del self.plugin.roster.contacts[account]
#FIXME: missing things: to_be_deleted for ex
self.plugin.roster.draw_roster() self.plugin.roster.draw_roster()
self.init_accounts() self.init_accounts()
@ -1345,6 +1373,7 @@ class Accounts_window:
sel = self.accounts_treeview.get_selection() sel = self.accounts_treeview.get_selection()
(model, iter) = sel.get_selected() (model, iter) = sel.get_selected()
account = model.get_value(iter, 0) account = model.get_value(iter, 0)
#FIXME:
infos = self.plugin.accounts[account] infos = self.plugin.accounts[account]
infos['accname'] = account infos['accname'] = account
infos['jid'] = self.plugin.accounts[account]['name'] + \ infos['jid'] = self.plugin.accounts[account]['name'] + \
@ -1356,9 +1385,11 @@ class Accounts_window:
def on_sync_with_global_status_checkbutton_toggled(self, widget): def on_sync_with_global_status_checkbutton_toggled(self, widget):
if widget.get_active(): 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: 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): def __init__(self, plugin):
self.plugin = plugin self.plugin = plugin
@ -1795,8 +1826,7 @@ class Service_discovery_window:
if not iter : if not iter :
return return
service = model.get_value(iter, 1) service = model.get_value(iter, 1)
#FIXME: infos = gajim.connections[self.account].ask_register_agent_info(service)
infos = connection.ask_register_agent_info(service)
if not infos.has_key('instructions'): if not infos.has_key('instructions'):
Error_dialog(_('error contacting %s') % service) Error_dialog(_('error contacting %s') % service)
else: else:
@ -1867,7 +1897,8 @@ class Service_discovery_window:
self.address_comboboxentry.set_model(liststore) self.address_comboboxentry.set_model(liststore)
self.address_comboboxentry.set_text_column(0) self.address_comboboxentry.set_text_column(0)
self.latest_addresses = gajim.config.get('latest_disco_addresses').split() 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: if server_address in self.latest_addresses:
self.latest_addresses.remove(server_address) self.latest_addresses.remove(server_address)
self.latest_addresses.insert(0, server_address) self.latest_addresses.insert(0, server_address)

View file

@ -20,6 +20,7 @@
import gtk import gtk
import gtk.glade import gtk.glade
import gobject import gobject
from common import gajim
from common import i18n from common import i18n
_ = i18n._ _ = i18n._
APP = i18n.APP APP = i18n.APP
@ -55,11 +56,9 @@ class Vcard_information_window:
self.plugin.send('UPDUSER', self.account, (self.user.jid, \ self.plugin.send('UPDUSER', self.account, (self.user.jid, \
self.user.name, self.user.groups)) self.user.name, self.user.groups))
#log history ? #log history ?
account_info = self.plugin.accounts[self.account]
oldlog = 1 oldlog = 1
no_log_for = [] no_log_for = gajim.config.get_per('accounts', self.account, 'no_log_for')\
if account_info.has_key('no_log_for'): .split()
no_log_for = account_info['no_log_for'].split()
if self.user.jid in no_log_for: if self.user.jid in no_log_for:
oldlog = 0 oldlog = 0
log = self.xml.get_widget('log_checkbutton').get_active() log = self.xml.get_widget('log_checkbutton').get_active()
@ -68,10 +67,8 @@ class Vcard_information_window:
if log and self.user.jid in no_log_for: if log and self.user.jid in no_log_for:
no_log_for.remove(self.user.jid) no_log_for.remove(self.user.jid)
if oldlog != log: if oldlog != log:
account_info['no_log_for'] = ' '.join(no_log_for) gajim.config.set_per('accounts', self.account, 'no_log_for', \
self.plugin.accounts[self.account] = account_info ' '.join(no_log_for))
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
'Gtkgui'))
self.window.destroy() self.window.destroy()
def set_value(self, entry_name, value): def set_value(self, entry_name, value):
@ -105,10 +102,9 @@ class Vcard_information_window:
else: else:
self.xml.get_widget('ask_label').set_text('None') self.xml.get_widget('ask_label').set_text('None')
self.xml.get_widget('nickname_entry').set_text(self.user.name) self.xml.get_widget('nickname_entry').set_text(self.user.name)
account_info = self.plugin.accounts[self.account]
log = 1 log = 1
if account_info.has_key('no_log_for'): if self.user.jid in gajim.config.get_per('accounts', account, \
if self.user.jid in account_info['no_log_for'].split(' '): 'no_log_for').split(' '):
log = 0 log = 0
self.xml.get_widget('log_checkbutton').set_active(log) self.xml.get_widget('log_checkbutton').set_active(log)
resources = self.user.resource + ' (' + str(self.user.priority) + ')' resources = self.user.resource + ' (' + str(self.user.priority) + ')'
@ -165,7 +161,7 @@ class Vcard_information_window:
if vcard.has_key('NICKNAME'): if vcard.has_key('NICKNAME'):
nick = vcard['NICKNAME'] nick = vcard['NICKNAME']
if nick == '': 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.nicks[self.account] = nick
self.plugin.send('VCARD', self.account, vcard) 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.window = self.xml.get_widget('new_message_dialog')
self.jid_entry = self.xml.get_widget('jid_entry') self.jid_entry = self.xml.get_widget('jid_entry')
our_jid = self.plugin.accounts[account]['name'] + '@' +\ our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
self.plugin.accounts[account]['hostname'] gajim.config.get_per('accounts', self.account, 'hostname')
if len(self.plugin.accounts) > 1: if len(gajim.config.connections) > 1:
title = 'New Message as ' + our_jid title = 'New Message as ' + our_jid
else: else:
title = 'New Message' title = 'New Message'

View file

@ -22,7 +22,7 @@ import gtk.glade
import pango import pango
import gobject import gobject
import time import time
from common import gajim
from dialogs import * from dialogs import *
from chat import * from chat import *
from gtkgui import CellRendererImage from gtkgui import CellRendererImage

View file

@ -25,10 +25,17 @@ import pango
import gobject import gobject
import os import os
import sre import sre
global gajim from common import gajim
import common.gajim as gajim
import common.sleepy import common.sleepy
from common import i18n
i18n.init()
_ = i18n._
APP = i18n.APP
gtk.glade.bindtextdomain(APP, i18n.DIR)
gtk.glade.textdomain(APP)
try: try:
import winsound # windows-only built-in module for playing wav import winsound # windows-only built-in module for playing wav
except ImportError: except ImportError:
@ -163,13 +170,6 @@ from systray import *
from dialogs import * from dialogs import *
from config 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' GTKGUI_GLADE='gtkgui.glade'
@ -313,12 +313,12 @@ class interface:
#It isn't an agent #It isn't an agent
self.roster.chg_user_status(user1, array[1], array[2], account) self.roster.chg_user_status(user1, array[1], array[2], account)
#play sound #play sound
if old_show < 2 and new_show > 1 and \ if old_show < 2 and new_show > 1 and gajim.config.get( \
self.config['sound_contact_connected']: 'sound_contact_connected'):
self.play_sound('sound_contact_connected') self.play_sound('sound_contact_connected')
if not self.windows[account]['chats'].has_key(jid) and \ if not self.windows[account]['chats'].has_key(jid) and \
not self.queues[account].has_key(jid) and \ not self.queues[account].has_key(jid) and not gajim.config.get( \
not self.config['autopopup']: 'autopopup'):
#FIXME: #FIXME:
#DOES NOT ALWAYS WORK WHY? #DOES NOT ALWAYS WORK WHY?
#I control nkour@lagaule in jabber #I control nkour@lagaule in jabber
@ -329,12 +329,12 @@ class interface:
# new message works # new message works
instance = Popup_window(self, 'Contact Online', jid, account) instance = Popup_window(self, 'Contact Online', jid, account)
self.roster.popup_windows.append(instance) self.roster.popup_windows.append(instance)
elif old_show > 1 and new_show < 2 and \ elif old_show > 1 and new_show < 2 and gajim.config.get( \
self.config['sound_contact_disconnected']: 'sound_contact_disconnected'):
self.play_sound('sound_contact_disconnected') self.play_sound('sound_contact_disconnected')
if not self.windows[account]['chats'].has_key(jid) and \ if not self.windows[account]['chats'].has_key(jid) and \
not self.queues[account].has_key(jid) and \ not self.queues[account].has_key(jid) and not gajim.config.get( \
not self.config['autopopup']: 'autopopup'):
instance = Popup_window(self, 'Contact Offline', jid, account) instance = Popup_window(self, 'Contact Offline', jid, account)
self.roster.popup_windows.append(instance) self.roster.popup_windows.append(instance)
@ -349,7 +349,7 @@ class interface:
jid = array[0].split('/')[0] jid = array[0].split('/')[0]
if jid.find("@") <= 0: if jid.find("@") <= 0:
jid = jid.replace('@', '') 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): not self.roster.contacts[account].has_key(jid):
return return
@ -357,13 +357,13 @@ class interface:
if not self.windows[account]['chats'].has_key(jid) and \ if not self.windows[account]['chats'].has_key(jid) and \
not self.queues[account].has_key(jid): not self.queues[account].has_key(jid):
first = True first = True
if not self.config['autopopup']: if not gajim.config.get('autopopup'):
instance = Popup_window(self, 'New Message', jid, account) instance = Popup_window(self, 'New Message', jid, account)
self.roster.popup_windows.append(instance) self.roster.popup_windows.append(instance)
self.roster.on_message(jid, array[1], array[2], account) 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') 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') self.play_sound('sound_next_message_received')
def handle_event_msgerror(self, account, array): def handle_event_msgerror(self, account, array):
@ -376,7 +376,7 @@ class interface:
def handle_event_msgsent(self, account, array): def handle_event_msgsent(self, account, array):
#('MSG', account, (jid, msg, keyID)) #('MSG', account, (jid, msg, keyID))
if self.config['sound_message_sent']: if gajim.config.get('sound_message_sent'):
self.play_sound('sound_message_sent') self.play_sound('sound_message_sent')
def handle_event_subscribe(self, account, array): def handle_event_subscribe(self, account, array):
@ -430,22 +430,22 @@ class interface:
if self.windows['account_modification']: if self.windows['account_modification']:
self.windows['account_modification'].account_is_ok(array[1]) self.windows['account_modification'].account_is_ok(array[1])
else: else:
self.accounts[name] = {'name': array[1], \ gajim.config.set_per('accounts', name, 'name', array[1])
'hostname': array[0],\ gajim.config.set_per('accounts', name, 'hostname', array[0])
'password': array[2],\ gajim.config.set_per('accounts', name, 'password', array[2])
'resource': array[4],\ gajim.config.set_per('accounts', name, 'resource', array[4])
'priority': array[5],\ gajim.config.set_per('accounts', name, 'priority', array[5])
'use_proxy': array[6],\ gajim.config.set_per('accounts', name, 'use_proxy', array[6])
'proxyhost': array[7], \ gajim.config.set_per('accounts', name, 'proxyhost', array[7])
'proxyport': array[8]} gajim.config.set_per('accounts', name, 'proxyport', array[8])
self.send('CONFIG', None, ('accounts', self.accounts, 'GtkGui'))
self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}} self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}}
self.queues[name] = {} self.queues[name] = {}
self.connected[name] = 0 gajim.connections[name].connected = 0
self.nicks[name] = array[1] self.nicks[name] = array[1]
self.roster.groups[name] = {} self.roster.groups[name] = {}
self.roster.contacts[name] = {} self.roster.contacts[name] = {}
self.sleeper_state[name] = 0 self.sleeper_state[name] = 0
#FIXME: add missing to_be_deleted for ex
if self.windows.has_key('accounts'): if self.windows.has_key('accounts'):
self.windows['accounts'].init_accounts() self.windows['accounts'].init_accounts()
self.roster.draw_roster() self.roster.draw_roster()
@ -458,7 +458,7 @@ class interface:
if array.has_key('NICKNAME'): if array.has_key('NICKNAME'):
nick = array['NICKNAME'] nick = array['NICKNAME']
if nick == '': if nick == '':
nick = self.accounts[account]['name'] nick = gajim.config.get_per('accounts', account, 'name')
self.nicks[account] = nick self.nicks[account] = nick
def handle_event_vcard(self, account, array): def handle_event_vcard(self, account, array):
@ -525,7 +525,7 @@ class interface:
if not self.sleeper.poll(): if not self.sleeper.poll():
return 1 return 1
state = self.sleeper.getState() state = self.sleeper.getState()
for account in self.accounts.keys(): for account in gajim.connections:
if not self.sleeper_state[account]: if not self.sleeper_state[account]:
continue continue
if state == common.sleepy.STATE_AWAKE and \ if state == common.sleepy.STATE_AWAKE and \
@ -535,14 +535,14 @@ class interface:
self.sleeper_state[account] = 1 self.sleeper_state[account] = 1
elif state == common.sleepy.STATE_AWAY and \ elif state == common.sleepy.STATE_AWAY and \
self.sleeper_state[account] == 1 and \ self.sleeper_state[account] == 1 and \
self.config['autoaway']: gajim.config.get('autoaway'):
#we go away #we go away
self.send('STATUS', account, ('away', 'auto away (idle)')) self.send('STATUS', account, ('away', 'auto away (idle)'))
self.sleeper_state[account] = 2 self.sleeper_state[account] = 2
elif state == common.sleepy.STATE_XAWAY and (\ elif state == common.sleepy.STATE_XAWAY and (\
self.sleeper_state[account] == 2 or \ self.sleeper_state[account] == 2 or \
self.sleeper_state[account] == 1) and \ self.sleeper_state[account] == 1) and \
self.config['autoxa']: gajim.config.get('autoxa'):
#we go extended away #we go extended away
self.send('STATUS', account, ('xa', 'auto away (idle)')) self.send('STATUS', account, ('xa', 'auto away (idle)'))
self.sleeper_state[account] = 3 self.sleeper_state[account] = 3
@ -551,18 +551,16 @@ class interface:
def autoconnect(self): def autoconnect(self):
"""auto connect at startup""" """auto connect at startup"""
ask_message = 0 ask_message = 0
for a in self.accounts.keys(): for a in gajim.connections:
if self.accounts[a].has_key('autoconnect'): if gajim.config.get_per('accounts', a, 'autoconnect'):
if self.accounts[a]['autoconnect']:
ask_message = 1 ask_message = 1
break break
if ask_message: if ask_message:
message = self.roster.get_status_message('online', 1) message = self.roster.get_status_message('online', 1)
if message == -1: if message == -1:
return return
for a in self.accounts.keys(): for a in gajim.connections:
if self.accounts[a].has_key('autoconnect'): if gajim.config.get_per('accounts', a, 'autoconnect'):
if self.accounts[a]['autoconnect']:
self.roster.send_status(a, 'online', message, 1) self.roster.send_status(a, 'online', message, 1)
return 0 return 0
@ -642,7 +640,7 @@ class interface:
def init_regexp(self): def init_regexp(self):
#initialize emoticons dictionary #initialize emoticons dictionary
self.emoticons = dict() 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): for i in range(0, len(split_line)/2):
emot_file = split_line[2*i+1] emot_file = split_line[2*i+1]
if not self.image_is_ok(emot_file): if not self.image_is_ok(emot_file):

View file

@ -21,6 +21,7 @@ import gtk
import gtk.glade import gtk.glade
import time import time
from common import gajim
from common import i18n from common import i18n
_ = i18n._ _ = i18n._

View file

@ -25,6 +25,7 @@ import os
import Queue import Queue
import common.sleepy import common.sleepy
from common import gajim
from tabbed_chat_window import * from tabbed_chat_window import *
from groupchat_window import * from groupchat_window import *
from history_window import * from history_window import *
@ -250,7 +251,7 @@ class Roster_window:
join_gc_menuitem.remove_submenu() join_gc_menuitem.remove_submenu()
if new_message_menuitem.get_submenu(): if new_message_menuitem.get_submenu():
new_message_menuitem.remove_submenu() new_message_menuitem.remove_submenu()
if len(self.plugin.accounts.keys()) > 0: if len(gajim.connections) > 0:
new_message_menuitem.set_sensitive(True) new_message_menuitem.set_sensitive(True)
join_gc_menuitem.set_sensitive(True) join_gc_menuitem.set_sensitive(True)
add_new_contact_menuitem.set_sensitive(True) add_new_contact_menuitem.set_sensitive(True)
@ -260,21 +261,21 @@ class Roster_window:
join_gc_menuitem.set_sensitive(False) join_gc_menuitem.set_sensitive(False)
add_new_contact_menuitem.set_sensitive(False) add_new_contact_menuitem.set_sensitive(False)
service_disco_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 #add
sub_menu = gtk.Menu() sub_menu = gtk.Menu()
add_new_contact_menuitem.set_submenu(sub_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')) item = gtk.MenuItem(_('to ') + account + _(' account'))
sub_menu.append(item) 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() sub_menu.show_all()
#disco #disco
sub_menu = gtk.Menu() sub_menu = gtk.Menu()
service_disco_menuitem.set_submenu(sub_menu) service_disco_menuitem.set_submenu(sub_menu)
for account in self.plugin.accounts.keys(): for account in gajim.connections:
our_jid = self.plugin.accounts[account]['name'] + '@' +\ our_jid = gajim.config.get_per('accounts', account, 'name') + '@' +\
self.plugin.accounts[account]['hostname'] gajim.config.get_per('accounts', account, 'hostname')
item = gtk.MenuItem(_('using ') + account + _(' account')) item = gtk.MenuItem(_('using ') + account + _(' account'))
sub_menu.append(item) sub_menu.append(item)
item.connect('activate', self.on_service_disco_menuitem_activate, account) item.connect('activate', self.on_service_disco_menuitem_activate, account)
@ -282,39 +283,43 @@ class Roster_window:
#join gc #join gc
sub_menu = gtk.Menu() sub_menu = gtk.Menu()
join_gc_menuitem.set_submenu(sub_menu) join_gc_menuitem.set_submenu(sub_menu)
for account in self.plugin.accounts.keys(): for account in gajim.connections:
our_jid = self.plugin.accounts[account]['name'] + '@' +\ our_jid = gajim.config.get_per('accounts', account, 'name') + '@' +\
self.plugin.accounts[account]['hostname'] gajim.config.get_per('accounts', account, 'hostname')
item = gtk.MenuItem(_('as ') + our_jid) item = gtk.MenuItem(_('as ') + our_jid)
sub_menu.append(item) 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() sub_menu.show_all()
#new message #new message
sub_menu = gtk.Menu() sub_menu = gtk.Menu()
new_message_menuitem.set_submenu(sub_menu) new_message_menuitem.set_submenu(sub_menu)
for account in self.plugin.accounts.keys(): for account in gajim.connections:
our_jid = self.plugin.accounts[account]['name'] + '@' +\ our_jid = gajim.config.get_per('accounts', account, 'name') + '@' +\
self.plugin.accounts[account]['hostname'] gajim.config.get_per('accounts', account, 'hostname')
item = gtk.MenuItem(_('as ') + our_jid) item = gtk.MenuItem(_('as ') + our_jid)
sub_menu.append(item) 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() sub_menu.show_all()
elif len(self.plugin.accounts.keys()) == 1: # one account elif len(gajim.connections) == 1: # one account
#add #add
if not self.add_new_contact_handler_id: if not self.add_new_contact_handler_id:
self.add_new_contact_handler_id = add_new_contact_menuitem.connect(\ 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 #disco
if not self.service_disco_handler_id: if not self.service_disco_handler_id:
self.service_disco_handler_id = service_disco_menuitem.connect(\ self.service_disco_handler_id = service_disco_menuitem.connect( \
'activate', self.on_service_disco_menuitem_activate, self.plugin.accounts.keys()[0]) 'activate', self.on_service_disco_menuitem_activate, \
gajim.connections.keys()[0])
#join_gc #join_gc
if not self.join_gc_handler_id: if not self.join_gc_handler_id:
self.join_gc_handler_id = join_gc_menuitem.connect(\ self.join_gc_handler_id = join_gc_menuitem.connect( \
'activate', self.on_join_gc_activate, self.plugin.accounts.keys()[0]) 'activate', self.on_join_gc_activate, gajim.connections.keys()\
[0])
if not self.new_message_menuitem_handler_id: if not self.new_message_menuitem_handler_id:
self.new_message_menuitem_handler_id = new_message_menuitem.connect(\ self.new_message_menuitem_handler_id = new_message_menuitem. \
'activate', self.on_new_message_menuitem_activate, self.plugin.accounts.keys()[0]) connect('activate', self.on_new_message_menuitem_activate, \
gajim.connections.keys()[0])
def draw_roster(self): def draw_roster(self):
"""Clear and draw roster""" """Clear and draw roster"""
@ -526,6 +531,7 @@ class Roster_window:
def on_edit_account(self, widget, account): def on_edit_account(self, widget, account):
if not self.plugin.windows.has_key('account_modification_window'): if not self.plugin.windows.has_key('account_modification_window'):
#FIXME:
infos = self.plugin.accounts[account] infos = self.plugin.accounts[account]
infos['accname'] = account infos['accname'] = account
infos['jid'] = self.plugin.accounts[account]["name"] + \ infos['jid'] = self.plugin.accounts[account]["name"] + \
@ -696,8 +702,7 @@ class Roster_window:
self.plugin.systray.set_status('connecting') self.plugin.systray.set_status('connecting')
save_pass = 0 save_pass = 0
if self.plugin.accounts[account].has_key('savepass'): save_pass = gajim.config.get_per('accounts', account, 'savepass')
save_pass = self.plugin.accounts[account]['savepass']
if not save_pass and self.plugin.connected[account] < 2: if not save_pass and self.plugin.connected[account] < 2:
passphrase = '' passphrase = ''
w = Passphrase_dialog(_('Enter your password for account %s') \ w = Passphrase_dialog(_('Enter your password for account %s') \
@ -712,19 +717,19 @@ class Roster_window:
return return
self.plugin.send('PASSPHRASE', account, passphrase) self.plugin.send('PASSPHRASE', account, passphrase)
if save: if save:
self.plugin.accounts[account]['savepass'] = 1 gajim.config.set_per('accounts', account, 'savepass', True)
self.plugin.accounts[account]['password'] = passphrase gajim.config.set_per('accounts', account, 'password', passphrase)
keyid = None keyid = None
save_gpg_pass = 0 save_gpg_pass = 0
if self.plugin.accounts[account].has_key('savegpgpass'): save_gpg_pass = gajim.config.get_per('accounts', account, \
save_gpg_pass = self.plugin.accounts[account]['savegpgpass'] 'savegpgpass')
if self.plugin.accounts[account].has_key('keyid'): keyid = gajim.config.get_per('accounts', account, 'keyid')
keyid = self.plugin.accounts[account]['keyid']
if keyid and self.plugin.connected[account] < 2 and \ if keyid and self.plugin.connected[account] < 2 and \
gajim.config.get('usegpg'): gajim.config.get('usegpg'):
if save_gpg_pass: if save_gpg_pass:
passphrase = self.plugin.accounts[account]['gpgpassword'] passphrase = gajim.config.get_per('accounts', account, \
'gpgpassword')
else: else:
passphrase = '' passphrase = ''
w = Passphrase_dialog(\ w = Passphrase_dialog(\
@ -734,8 +739,10 @@ class Roster_window:
if passphrase == -1: if passphrase == -1:
passphrase = '' passphrase = ''
if save: if save:
self.plugin.accounts[account]['savegpgpass'] = 1 gajim.config.set_per('accounts', account, 'savegpgpass', True)
self.plugin.accounts[account]['gpgpassword'] = passphrase gajim.config.set_per('accounts', account, 'gpgpassword', \
passphrase)
#FIXME:
self.plugin.send('GPGPASSPHRASE', account, passphrase) self.plugin.send('GPGPASSPHRASE', account, passphrase)
self.plugin.send('STATUS', account, (status, txt)) self.plugin.send('STATUS', account, (status, txt))
for room_jid in self.plugin.windows[account]['gc']: for room_jid in self.plugin.windows[account]['gc']:
@ -769,7 +776,7 @@ class Roster_window:
active = self.status_combobox.get_active() active = self.status_combobox.get_active()
if active < 0: if active < 0:
return return
accounts = self.plugin.accounts.keys() accounts = gajim.connections.keys()
if len(accounts) == 0: if len(accounts) == 0:
Error_dialog(_('You must create an account before connecting to jabber network.')) Error_dialog(_('You must create an account before connecting to jabber network.'))
self.update_status_comboxbox() self.update_status_comboxbox()
@ -780,8 +787,8 @@ class Roster_window:
self.update_status_comboxbox() self.update_status_comboxbox()
return return
for acct in accounts: for acct in accounts:
if self.plugin.accounts[acct].has_key('sync_with_global_status'): if not gajim.config.get_per('accounts', acct, \
if not self.plugin.accounts[acct]['sync_with_global_status']: 'sync_with_global_status'):
continue continue
self.send_status(acct, status, message) self.send_status(acct, status, message)
@ -945,7 +952,7 @@ class Roster_window:
if self.plugin.systray_enabled: if self.plugin.systray_enabled:
self.window.hide() self.window.hide()
else: else:
accounts = self.plugin.accounts.keys() accounts = gajim.connections.keys()
get_msg = False get_msg = False
for acct in accounts: for acct in accounts:
if self.plugin.connected[acct]: if self.plugin.connected[acct]:
@ -981,7 +988,7 @@ class Roster_window:
gtk.main_quit() gtk.main_quit()
def on_quit_menuitem_activate(self, widget): def on_quit_menuitem_activate(self, widget):
accounts = self.plugin.accounts.keys() accounts = gajim.connections.keys()
get_msg = False get_msg = False
for acct in accounts: for acct in accounts:
if self.plugin.connected[acct]: if self.plugin.connected[acct]:
@ -1139,7 +1146,7 @@ class Roster_window:
# Update the systray # Update the systray
if self.plugin.systray_enabled: if self.plugin.systray_enabled:
self.plugin.systray.set_img() self.plugin.systray.set_img()
for account in self.plugin.accounts.keys(): for account in gajim.connected:
# Update opened chat windows # Update opened chat windows
for jid in self.plugin.windows[account]['chats']: for jid in self.plugin.windows[account]['chats']:
if jid != 'tabbed': if jid != 'tabbed':
@ -1338,7 +1345,7 @@ class Roster_window:
self.to_be_removed = {} self.to_be_removed = {}
self.popups_height = 0 self.popups_height = 0
self.popup_windows = [] self.popup_windows = []
for a in self.plugin.accounts.keys(): for a in gajim.connections:
self.contacts[a] = {} self.contacts[a] = {}
self.groups[a] = {} self.groups[a] = {}
self.newly_added[a] = [] self.newly_added[a] = []
@ -1416,6 +1423,6 @@ class Roster_window:
self.hidden_lines = gajim.config.get('hiddenlines').split('\t') self.hidden_lines = gajim.config.get('hiddenlines').split('\t')
self.draw_roster() 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'] = \ self.plugin.windows['account_modification'] = \
Account_modification_window(self.plugin, {}) Account_modification_window(self.plugin, {})

View file

@ -23,6 +23,7 @@ import pango
import gobject import gobject
import time import time
from common import gajim
from dialogs import * from dialogs import *
from history_window import * from history_window import *
from chat import * from chat import *