move var that have nothing to do with GTK to gajim instead of roster or gajim.py: contacts, groups, newly_added, to_be_removed, awaiting_messages (was queues), nicks, allow_notifications, con_types, sleeper_state

This commit is contained in:
Yann Leboulanger 2005-07-18 21:08:31 +00:00
parent bee9df2142
commit a47cca07f0
11 changed files with 248 additions and 250 deletions

View file

@ -691,8 +691,8 @@ class Chat:
self.on_join_group_chat_menuitem_activate, text)
allow_add = False
if self.plugin.roster.contacts[self.account].has_key(text):
c = self.plugin.roster.contacts[self.account][text][0]
if gajim.contacts[self.account].has_key(text):
c = gajim.contacts[self.account][text][0]
if _('not in the roster') in c.groups:
allow_add = True
else: # he's not at all in the account contacts

View file

@ -44,3 +44,17 @@ else:
last_message_time = {} # list of time of the latest incomming message
# {acct1: {jid1: time1, jid2: time2}, }
encrypted_chats = {} # list of encrypted chats {acct1: [jid1, jid2], ..}
contacts = {} # list of contacts {acct: {jid1: [C1, C2]}, } one Contact per resource
groups = {} # list of groups
newly_added = {} # list of contacts that has just signed in
to_be_removed = {} # list of contacts that has just signed out
awaiting_messages = {} # list of messages reveived but not printed
nicks = {} # list of our nick names in each account
allow_notifications = {} # do we allow notifications for each account ?
con_types = {} # type of each connection (ssl, tls, tcp, ...)
sleeper_state = {} #whether we pass auto away / xa or not
#0:don't use sleeper for this account
#1:online and use sleeper
#2:autoaway and use sleeper
#3:autoxa and use sleeper

View file

@ -491,7 +491,7 @@ class PreferencesWindow:
#open new tabbed chat windows
for jid in jids:
if kind == 'chats':
user = self.plugin.roster.contacts[acct][jid][0]
user = gajim.contacts[acct][jid][0]
self.plugin.roster.new_chat(user, acct)
if kind == 'gc':
self.plugin.roster.new_room(jid, saved_var[jid]['nick'], acct)
@ -524,7 +524,7 @@ class PreferencesWindow:
#open new tabbed chat windows
for jid in jids:
if kind == 'chats':
user = self.plugin.roster.contacts[acct][jid][0]
user = gajim.contacts[acct][jid][0]
self.plugin.roster.new_chat(user, acct)
if kind == 'gc':
self.plugin.roster.new_room(jid, saved_var[jid]['nick'], acct)
@ -1165,20 +1165,16 @@ _('To change the account name, you must be disconnected.')).get_response()
if name != self.account:
#update variables
self.plugin.windows[name] = self.plugin.windows[self.account]
self.plugin.queues[name] = self.plugin.queues[self.account]
self.plugin.nicks[name] = self.plugin.nicks[self.account]
self.plugin.allow_notifications[name] = \
self.plugin.allow_notifications[self.account]
self.plugin.roster.groups[name] = \
self.plugin.roster.groups[self.account]
self.plugin.roster.contacts[name] = \
self.plugin.roster.contacts[self.account]
self.plugin.roster.newly_added[name] = \
self.plugin.roster.newly_added[self.account]
self.plugin.roster.to_be_removed[name] = \
self.plugin.roster.to_be_removed[self.account]
self.plugin.sleeper_state[name] = \
self.plugin.sleeper_state[self.account]
gajim.awaiting_messages[name] = \
gajim.awaiting_messages[self.account]
gajim.nicks[name] = gajim.nicks[self.account]
gajim.allow_notifications[name] = \
gajim.allow_notifications[self.account]
gajim.groups[name] = gajim.groups[self.account]
gajim.contacts[name] = gajim.contacts[self.account]
gajim.newly_added[name] = gajim.newly_added[self.account]
gajim.to_be_removed[name] = gajim.to_be_removed[self.account]
gajim.sleeper_state[name] = gajim.sleeper_state[self.account]
gajim.encrypted_chats[name] = gajim.encrypted_chats[self.account]
gajim.last_message_time[name] = \
gajim.last_message_time[self.account]
@ -1195,12 +1191,14 @@ _('To change the account name, you must be disconnected.')).get_response()
list[0] = name
del self.plugin.windows[self.account]
del self.plugin.queues[self.account]
del self.plugin.nicks[self.account]
del self.plugin.allow_notifications[self.account]
del self.plugin.roster.groups[self.account]
del self.plugin.roster.contacts[self.account]
del self.plugin.sleeper_state[self.account]
del gajim.awaiting_messages[self.account]
del gajim.nicks[self.account]
del gajim.allow_notifications[self.account]
del gajim.groups[self.account]
del gajim.contacts[self.account]
del gajim.newly_added[self.account]
del gajim.to_be_removed[self.account]
del gajim.sleeper_state[self.account]
del gajim.encrypted_chats[self.account]
del gajim.last_message_time[self.account]
gajim.connections[self.account].name = name
@ -1243,15 +1241,15 @@ _('To change the account name, you must be disconnected.')).get_response()
#update variables
self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, \
'gc_config': {}}
self.plugin.queues[name] = {}
gajim.awaiting_messages[name] = {}
gajim.connections[name].connected = 0
self.plugin.roster.groups[name] = {}
self.plugin.roster.contacts[name] = {}
self.plugin.roster.newly_added[name] = []
self.plugin.roster.to_be_removed[name] = []
self.plugin.nicks[name] = config['name']
self.plugin.allow_notifications[name] = False
self.plugin.sleeper_state[name] = 0
gajim.groups[name] = {}
gajim.contacts[name] = {}
gajim.newly_added[name] = []
gajim.to_be_removed[name] = []
gajim.nicks[name] = config['name']
gajim.allow_notifications[name] = False
gajim.sleeper_state[name] = 0
gajim.encrypted_chats[name] = []
gajim.last_message_time[name] = {}
#refresh accounts window
@ -1272,7 +1270,7 @@ _('To change the account name, you must be disconnected.')).get_response()
new_password = dialog.run()
if new_password != -1:
gajim.connections[self.account].change_password(new_password, \
self.plugin.nicks[self.account])
gajim.nicks[self.account])
if self.xml.get_widget('save_password_checkbutton').get_active():
self.xml.get_widget('password_entry').set_text(new_password)
@ -1669,7 +1667,7 @@ class ServiceRegistrationWindow:
user1 = Contact(jid = self.service, name = self.service,
groups = [_('Transports')], show = 'offline', status = 'offline',
sub = 'from')
self.plugin.roster.contacts[self.account][self.service] = [user1]
gajim.contacts[self.account][self.service] = [user1]
self.plugin.roster.add_contact_to_roster(self.service, self.account)
gajim.connections[self.account].register_agent(self.service, self.infos)
self.window.destroy()
@ -2135,7 +2133,7 @@ _('Without a connection, you can not browse available services')).get_response()
jid = model.get_value(iter, 1)
node = model.get_value(iter, 2)
registered_transports = []
contacts = self.plugin.roster.contacts[self.account]
contacts = gajim.contacts[self.account]
for j in contacts:
if _('Transports') in contacts[j][0].groups:
registered_transports.append(j)
@ -2334,13 +2332,16 @@ class RemoveAccountWindow:
gajim.config.del_per('accounts', self.account)
self.plugin.save_config()
del self.plugin.windows[self.account]
del self.plugin.queues[self.account]
del self.plugin.nicks[self.account]
del self.plugin.allow_notifications[self.account]
del self.plugin.roster.groups[self.account]
del self.plugin.roster.contacts[self.account]
del self.plugin.roster.to_be_removed[self.account]
del self.plugin.roster.newly_added[self.account]
del gajim.awaiting_messages[self.account]
del gajim.nicks[self.account]
del gajim.allow_notifications[self.account]
del gajim.groups[self.account]
del gajim.contacts[self.account]
del gajim.to_be_removed[self.account]
del gajim.newly_added[self.account]
del gajim.sleeper_state[self.account]
del gajim.encrypted_chats[self.account]
del gajim.last_message_time[self.account]
self.plugin.roster.draw_roster()
if self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'].init_accounts()

View file

@ -100,7 +100,7 @@ class EditGroupsDialog:
def init_list(self):
store = gtk.ListStore(str, bool)
self.list.set_model(store)
for g in self.plugin.roster.groups[self.account].keys():
for g in gajim.groups[self.account].keys():
if g in [_('Transports'), _('not in the roster')]:
continue
iter = store.append()
@ -268,8 +268,8 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
liststore.append(['Jabber', ''])
self.agents = ['Jabber']
jid_agents = []
for j in self.plugin.roster.contacts[account]:
user = self.plugin.roster.contacts[account][j][0]
for j in gajim.contacts[account]:
user = gajim.contacts[account][j][0]
if _('Transports') in user.groups and user.show != 'offline' and \
user.show != 'error':
jid_agents.append(j)
@ -305,7 +305,7 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
self.group_comboboxentry = self.xml.get_widget('group_comboboxentry')
liststore = gtk.ListStore(str)
self.group_comboboxentry.set_model(liststore)
for g in self.plugin.roster.groups[account].keys():
for g in gajim.groups[account].keys():
if g != _('not in the roster') and g != _('Transports'):
self.group_comboboxentry.append_text(g)
@ -698,7 +698,7 @@ class SubscriptionRequestWindow:
'''accept the request'''
gajim.connections[self.account].send_authorization(self.jid)
self.window.destroy()
if not self.plugin.roster.contacts[self.account].has_key(self.jid):
if not gajim.contacts[self.account].has_key(self.jid):
AddNewContactWindow(self.plugin, self.account, self.jid)
def on_contact_info_button_clicked(self, widget):
@ -735,8 +735,7 @@ _('You can not join a group chat unless you are connected.')).get_response()
self.window = self.xml.get_widget('join_groupchat_window')
self.xml.get_widget('server_entry').set_text(server)
self.xml.get_widget('room_entry').set_text(room)
self.xml.get_widget('nickname_entry').set_text(
self.plugin.nicks[self.account])
self.xml.get_widget('nickname_entry').set_text(gajim.nicks[self.account])
self.xml.signal_autoconnect(self)
self.plugin.windows[account]['join_gc'] = self #now add us to open windows
our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
@ -880,8 +879,8 @@ class PopupNotificationWindow:
event_type_label.set_markup('<b>' + event_type + '</b>')
if self.jid in self.plugin.roster.contacts[account]:
txt = self.plugin.roster.contacts[account][self.jid][0].name
if self.jid in gajim.contacts[account]:
txt = gajim.contacts[account][self.jid][0].name
else:
txt = self.jid
@ -940,8 +939,8 @@ class PopupNotificationWindow:
def on_popup_notification_window_button_press_event(self, widget, event):
# use Contact class, new_chat expects it that way
# is it in the roster?
if self.plugin.roster.contacts[self.account].has_key(self.jid):
contact = self.plugin.roster.contacts[self.account][self.jid][0]
if gajim.contacts[self.account].has_key(self.jid):
contact = gajim.contacts[self.account][self.jid][0]
else:
keyID = ''
attached_keys = gajim.config.get_per('accounts', self.account,
@ -951,7 +950,7 @@ class PopupNotificationWindow:
contact = Contact(jid = self.jid, name = self.jid.split('@')[0],
groups = [_('not in the roster')], show = 'not in the roster',
status = _('not in the roster'), sub = 'none', keyID = keyID)
self.plugin.roster.contacts[self.account][self.jid] = [contact]
gajim.contacts[self.account][self.jid] = [contact]
self.plugin.roster.add_contact_to_roster(contact.self.jid,
self.account) # FIXME: contact.self.jid ???

View file

@ -198,17 +198,17 @@ class Interface:
def handle_event_con_type(self, account, con_type):
# ('CON_TYPE', account, con_type) which can be 'ssl', 'tls', 'tcp'
self.con_types[account] = con_type
gajim.con_types[account] = con_type
def allow_notif(self, account):
self.allow_notifications[account] = True
gajim.allow_notifications[account] = True
def handle_event_status(self, account, status): # OUR status
#('STATUS', account, status)
if status != 'offline':
gobject.timeout_add(30000, self.allow_notif, account)
else:
self.allow_notifications[account] = False
gajim.allow_notifications[account] = False
self.roster.on_status_changed(account, status)
if self.remote:
self.remote.raise_signal('AccountPresence', (status, account))
@ -235,8 +235,8 @@ class Interface:
else:
ji = jid
#Update user
if self.roster.contacts[account].has_key(ji):
luser = self.roster.contacts[account][ji]
if gajim.contacts[account].has_key(ji):
luser = gajim.contacts[account][ji]
user1 = None
resources = []
for u in luser:
@ -248,7 +248,7 @@ class Interface:
if user1.show in statuss:
old_show = statuss.index(user1.show)
else:
user1 = self.roster.contacts[account][ji][0]
user1 = gajim.contacts[account][ji][0]
if user1.show in statuss:
old_show = statuss.index(user1.show)
if (resources != [''] and (len(luser) != 1 or
@ -263,20 +263,20 @@ class Interface:
user1.resource = resource
if user1.jid.find('@') > 0 and len(luser) == 1: # It's not an agent
if old_show == 0 and new_show > 1:
if not user1.jid in self.roster.newly_added[account]:
self.roster.newly_added[account].append(user1.jid)
if user1.jid in self.roster.to_be_removed[account]:
self.roster.to_be_removed[account].remove(user1.jid)
if not user1.jid in gajim.newly_added[account]:
gajim.newly_added[account].append(user1.jid)
if user1.jid in gajim.to_be_removed[account]:
gajim.to_be_removed[account].remove(user1.jid)
gobject.timeout_add(5000, self.roster.remove_newly_added, \
user1.jid, account)
if old_show > 1 and new_show == 0 and gajim.connections[account].\
connected > 1:
if not user1.jid in self.roster.to_be_removed[account]:
self.roster.to_be_removed[account].append(user1.jid)
if user1.jid in self.roster.newly_added[account]:
self.roster.newly_added[account].remove(user1.jid)
if not user1.jid in gajim.to_be_removed[account]:
gajim.to_be_removed[account].append(user1.jid)
if user1.jid in gajim.newly_added[account]:
gajim.newly_added[account].remove(user1.jid)
self.roster.draw_contact(user1.jid, account)
if not self.queues[account].has_key(jid):
if not gajim.awaiting_messages[account].has_key(jid):
gobject.timeout_add(5000, self.roster.really_remove_user, \
user1, account)
user1.show = array[1]
@ -285,10 +285,10 @@ class Interface:
user1.keyID = keyID
if jid.find('@') <= 0:
#It must be an agent
if self.roster.contacts[account].has_key(ji):
if gajim.contacts[account].has_key(ji):
#Update existing iter
self.roster.draw_contact(ji, account)
elif self.roster.contacts[account].has_key(ji):
elif gajim.contacts[account].has_key(ji):
#It isn't an agent
self.roster.chg_contact_status(user1, array[1], array[2], account)
#play sound
@ -297,9 +297,9 @@ class Interface:
'enabled'):
self.play_sound('contact_connected')
if not self.windows[account]['chats'].has_key(jid) and \
not self.queues[account].has_key(jid) and \
not gajim.awaiting_messages[account].has_key(jid) and \
gajim.config.get('notify_on_signin') and \
self.allow_notifications[account]:
gajim.allow_notifications[account]:
show_notification = False
# check OUR status and if we allow notifications for that status
if gajim.config.get('autopopupaway'): # always notify
@ -318,7 +318,7 @@ class Interface:
'enabled'):
self.play_sound('contact_disconnected')
if not self.windows[account]['chats'].has_key(jid) and \
not self.queues[account].has_key(jid) and \
not gajim.awaiting_messages[account].has_key(jid) and \
gajim.config.get('notify_on_signout'):
show_notification = False
# check OUR status and if we allow notifications for that status
@ -357,7 +357,7 @@ class Interface:
chat_win = self.windows[account]['chats'][fjid]
chat_win.print_conversation(array[1], fjid, tim = array[2])
return
qs = self.queues[account]
qs = gajim.awaiting_messages[account]
if not qs.has_key(fjid):
qs[fjid] = []
qs[fjid].append((array[1], array[2], array[3]))
@ -371,12 +371,12 @@ class Interface:
if gajim.config.get('ignore_unknown_contacts') and \
not self.roster.contacts[account].has_key(jid):
not gajim.contacts[account].has_key(jid):
return
first = False
if not self.windows[account]['chats'].has_key(jid) and \
not self.queues[account].has_key(jid):
not gajim.awaiting_messages[account].has_key(jid):
first = True
if gajim.config.get('notify_on_new_message'):
show_notification = False
@ -456,8 +456,8 @@ class Interface:
def handle_event_subscribed(self, account, array):
#('SUBSCRIBED', account, (jid, resource))
jid = array[0]
if self.roster.contacts[account].has_key(jid):
u = self.roster.contacts[account][jid][0]
if gajim.contacts[account].has_key(jid):
u = gajim.contacts[account][jid][0]
u.resource = array[1]
self.roster.remove_user(u, account)
if _('not in the roster') in u.groups:
@ -475,7 +475,7 @@ class Interface:
user1 = Contact(jid = jid, name = jid.split('@')[0],
groups = [_('General')], show = 'online', status = 'online',
ask = 'to', resource = array[1], keyID = keyID)
self.roster.contacts[account][jid] = [user1]
gajim.contacts[account][jid] = [user1]
self.roster.add_contact_to_roster(jid, account)
dialogs.InformationDialog(_('Authorization accepted'),
_('The contact "%s" has authorized you to see his status.')
@ -526,15 +526,15 @@ class Interface:
if self.windows.has_key('account_modification'):
self.windows['account_modification'].account_is_ok(array[0])
self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, 'gc_config': {}}
self.queues[name] = {}
gajim.awaiting_messages[name] = {}
gajim.connections[name].connected = 0
self.nicks[name] = array[1]['name']
self.allow_notifications[name] = False
self.roster.groups[name] = {}
self.roster.contacts[name] = {}
self.roster.newly_added[name] = []
self.roster.to_be_removed[name] = []
self.sleeper_state[name] = 0
gajim.nicks[name] = array[1]['name']
gajim.allow_notifications[name] = False
gajim.groups[name] = {}
gajim.contacts[name] = {}
gajim.newly_added[name] = []
gajim.to_be_removed[name] = []
gajim.sleeper_state[name] = 0
gajim.encrypted_chats[name] = []
gajim.last_message_time[name] = {}
if self.windows.has_key('accounts'):
@ -551,7 +551,7 @@ class Interface:
if array.has_key('NICKNAME'):
nick = array['NICKNAME']
if nick:
self.nicks[account] = nick
gajim.nicks[account] = nick
def handle_event_vcard(self, account, array):
win = None
@ -617,12 +617,12 @@ class Interface:
def handle_event_roster_info(self, account, array):
#('ROSTER_INFO', account, (jid, name, sub, ask, groups))
jid = array[0]
if not self.roster.contacts[account].has_key(jid):
if not gajim.contacts[account].has_key(jid):
return
users = self.roster.contacts[account][jid]
users = gajim.contacts[account][jid]
if not (array[2] or array[3]):
self.roster.remove_user(users[0], account)
del self.roster.contacts[account][jid]
del gajim.contacts[account][jid]
#TODO if it was the only one in its group, remove the group
return
for user in users:
@ -655,26 +655,26 @@ class Interface:
return True # renew timeout (loop for ever)
state = self.sleeper.getState()
for account in gajim.connections:
if not self.sleeper_state[account]:
if not gajim.sleeper_state[account]:
continue
if state == common.sleepy.STATE_AWAKE and \
self.sleeper_state[account] > 1:
gajim.sleeper_state[account] > 1:
#we go online
self.roster.send_status(account, 'online', 'Online')
self.sleeper_state[account] = 1
gajim.sleeper_state[account] = 1
elif state == common.sleepy.STATE_AWAY and \
self.sleeper_state[account] == 1 and \
gajim.sleeper_state[account] == 1 and \
gajim.config.get('autoaway'):
#we go away
self.roster.send_status(account, 'away', 'auto away (idle)')
self.sleeper_state[account] = 2
gajim.sleeper_state[account] = 2
elif state == common.sleepy.STATE_XAWAY and (\
self.sleeper_state[account] == 2 or \
self.sleeper_state[account] == 1) and \
gajim.sleeper_state[account] == 2 or \
gajim.sleeper_state[account] == 1) and \
gajim.config.get('autoxa'):
#we go extended away
self.roster.send_status(account, 'xa', 'auto away (idle)')
self.sleeper_state[account] = 3
gajim.sleeper_state[account] = 3
return True # renew timeout (loop for ever)
def autoconnect(self):
@ -879,20 +879,16 @@ class Interface:
gtk.about_dialog_set_email_hook(self.on_launch_browser_mailer, 'mail')
gtk.about_dialog_set_url_hook(self.on_launch_browser_mailer, 'url')
self.windows = {'logs':{}}
self.queues = {}
self.nicks = {}
self.allow_notifications = {}
self.con_types = {}
self.sleeper_state = {} #whether we pass auto away / xa or not
for a in gajim.connections:
self.windows[a] = {'infos': {}, 'chats': {}, 'gc': {}, 'gc_config': {}}
self.queues[a] = {}
self.nicks[a] = gajim.config.get_per('accounts', a, 'name')
self.allow_notifications[a] = False
self.sleeper_state[a] = 0 #0:don't use sleeper for this account
#1:online and use sleeper
#2:autoaway and use sleeper
#3:autoxa and use sleeper
gajim.contacts[a] = {}
gajim.groups[a] = {}
gajim.newly_added[a] = []
gajim.to_be_removed[a] = []
gajim.awaiting_messages[a] = {}
gajim.nicks[a] = gajim.config.get_per('accounts', a, 'name')
gajim.allow_notifications[a] = False
gajim.sleeper_state[a] = 0
gajim.encrypted_chats[a] = []
gajim.last_message_time[a] = {}

View file

@ -140,7 +140,7 @@ class HistoryWindow:
tag_msg = 'status'
elif type == 'recv':
try:
name = self.plugin.roster.contacts[self.account][self.jid][0].name
name = gajim.contacts[self.account][self.jid][0].name
except:
name = None
if not name:
@ -148,7 +148,7 @@ class HistoryWindow:
msg = ':'.join(data[0:])
tag_name = 'incoming'
elif type == 'sent':
name = self.plugin.nicks[self.account]
name = gajim.nicks[self.account]
msg = ':'.join(data[0:])
tag_name = 'outgoing'
else:
@ -173,8 +173,8 @@ class HistoryWindow:
self.nb_line = gajim.logger.get_nb_line(jid)
xml = gtk.glade.XML(GTKGUI_GLADE, 'history_window', APP)
self.window = xml.get_widget('history_window')
if account and self.plugin.roster.contacts[account].has_key(jid):
list_users = self.plugin.roster.contacts[account][self.jid]
if account and gajim.contacts[account].has_key(jid):
list_users = gajim.contacts[account][self.jid]
user = list_users[0]
title = 'Conversation History with ' + user.name
else:

View file

@ -73,7 +73,6 @@ class SignalObject(DbusPrototype):
def __init__(self, service, plugin):
self.plugin = plugin
self.first_show = True
self.contacts = self.plugin.roster.contacts
self.vcard_account = None
# register our dbus API
@ -121,8 +120,8 @@ class SignalObject(DbusPrototype):
if account:
self.plugin.connections[account].send_message(jid, message, keyID)
else:
for account in self.contacts.keys():
if self.contacts[account].has_key(jid):
for account in gajim.contacts.keys():
if gajim.contacts[account].has_key(jid):
gajim.connections[account].send_message(jid,
message, keyID)
return True
@ -138,14 +137,14 @@ class SignalObject(DbusPrototype):
if account:
accounts = [account]
else:
accounts = self.contacts.keys()
accounts = gajim.connections.keys()
for account in accounts:
if self.plugin.windows[account]['chats'].has_key(jid):
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
break
elif self.contacts[account].has_key(jid):
self.plugin.roster.new_chat(self.contacts[account][jid][0],
elif gajim.contacts[account].has_key(jid):
self.plugin.roster.new_chat(gajim.contacts[account][jid][0],
account)
jid_data = self.plugin.windows[account]['chats'][jid]
jid_data.set_active_tab(jid)
@ -170,7 +169,7 @@ class SignalObject(DbusPrototype):
status, message)
else:
# account not specified, so change the status of all accounts
for acc in self.contacts.keys():
for acc in gajim.contacts.keys():
gobject.idle_add(self.plugin.roster.send_status, acc,
status, message)
return None
@ -190,7 +189,7 @@ class SignalObject(DbusPrototype):
jid_tab = acc['chats'][jid]
else:
self.plugin.roster.new_chat(
self.contacts[account][jid][0], account)
gajim.contacts[account][jid][0], account)
jid_tab = acc['chats'][jid]
if jid_tab:
jid_tab.set_active_tab(jid)
@ -210,11 +209,11 @@ class SignalObject(DbusPrototype):
# FIXME: raise exception for missing argument (0.3+)
return None
accounts = self.contacts.keys()
accounts = gajim.contacts.keys()
iq = None
for account in accounts:
if self.contacts[account].has_key(jid):
if gajim.contacts[account].has_key(jid):
self.vcard_account = account
gajim.connections[account].register_handler('VCARD',
self._receive_vcard)
@ -224,8 +223,8 @@ class SignalObject(DbusPrototype):
def list_accounts(self, *args):
''' list register accounts '''
if self.contacts:
result = self.contacts.keys()
if gajim.contacts:
result = gajim.contacts.keys()
if result and len(result) > 0:
return result
return None
@ -236,13 +235,13 @@ class SignalObject(DbusPrototype):
then return the contacts for the specified account '''
[for_account] = self._get_real_arguments(args, 1)
result = []
if not self.contacts or len(self.contacts) == 0:
if not gajim.contacts or len(gajim.contacts) == 0:
return None
if for_account:
if self.contacts.has_key(for_account):
for jid in self.contacts[for_account]:
if gajim.contacts.has_key(for_account):
for jid in gajim.contacts[for_account]:
item = self._serialized_contacts(
self.contacts[for_account][jid])
gajim.contacts[for_account][jid])
if item:
result.append(item)
else:
@ -250,9 +249,9 @@ class SignalObject(DbusPrototype):
# FIXME: there can be a return status for this [0.3+]
return None
else:
for account in self.contacts:
for jid in self.contacts[account]:
item = self._serialized_contacts(self.contacts[account][jid])
for account in gajim.contacts:
for jid in gajim.contacts[account]:
item = self._serialized_contacts(gajim.contacts[account][jid])
if item:
result.append(item)
# dbus 0.40 does not support return result as empty list

View file

@ -96,9 +96,9 @@ class RosterWindow:
status = statuss[gajim.connections[account].connected]
tls_pixbuf = None
if self.plugin.con_types.has_key(account) and\
(self.plugin.con_types[account] == 'tls' or\
self.plugin.con_types[account] == 'ssl'):
if gajim.con_types.has_key(account) and \
(gajim.con_types[account] == 'tls' or \
gajim.con_types[account] == 'ssl'):
tls_pixbuf = self.window.render_icon(gtk.STOCK_DIALOG_AUTHENTICATION,
gtk.ICON_SIZE_MENU) # the only way to create a pixbuf from stock
@ -106,16 +106,16 @@ class RosterWindow:
'account', account, account, False, tls_pixbuf])
def remove_newly_added(self, jid, account):
if jid in self.newly_added[account]:
self.newly_added[account].remove(jid)
if jid in gajim.newly_added[account]:
gajim.newly_added[account].remove(jid)
self.draw_contact(jid, account)
def add_contact_to_roster(self, jid, account):
'''Add a contact to the roster and add groups if they aren't in roster'''
showOffline = gajim.config.get('showoffline')
if not self.contacts[account].has_key(jid):
if not gajim.contacts[account].has_key(jid):
return
users = self.contacts[account][jid]
users = gajim.contacts[account][jid]
user = users[0]
if user.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
user.groups = [_('Transports')]
@ -125,7 +125,7 @@ class RosterWindow:
if (user.show == 'offline' or user.show == 'error') and \
not showOffline and (not _('Transports') in user.groups or \
gajim.connections[account].connected < 2) and \
not self.plugin.queues[account].has_key(user.jid):
not gajim.awaiting_messages[account].has_key(user.jid):
return
model = self.tree.get_model()
@ -135,12 +135,12 @@ class RosterWindow:
IterAcct = self.get_account_iter(account)
iterG = model.append(IterAcct,
[self.jabber_state_images['closed'], g, 'group', g, account, False, None])
if not self.groups[account].has_key(g): #It can probably never append
if not gajim.groups[account].has_key(g): #It can probably never append
if account + g in self.collapsed_rows:
ishidden = False
else:
ishidden = True
self.groups[account][g] = { 'expand': ishidden }
gajim.groups[account][g] = { 'expand': ishidden }
if not account in self.collapsed_rows and \
not gajim.config.get('mergeaccounts'):
self.tree.expand_row((model.get_path(iterG)[0]), False)
@ -152,18 +152,18 @@ class RosterWindow:
model.append(iterG, [self.jabber_state_images[user.show], user.name,
typestr, user.jid, account, False, None]) # FIXME None --> avatar
if self.groups[account][g]['expand']:
if gajim.groups[account][g]['expand']:
self.tree.expand_row(model.get_path(iterG),
False)
self.draw_contact(jid, account)
def really_remove_user(self, user, account):
if user.jid in self.newly_added[account]:
if user.jid in gajim.newly_added[account]:
return
if user.jid.find('@') < 1 and gajim.connections[account].connected > 1: # It's an agent
return
if user.jid in self.to_be_removed[account]:
self.to_be_removed[account].remove(user.jid)
if user.jid in gajim.to_be_removed[account]:
gajim.to_be_removed[account].remove(user.jid)
if gajim.config.get('showoffline'):
self.draw_contact(user.jid, account)
return
@ -171,7 +171,7 @@ class RosterWindow:
def remove_user(self, user, account):
'''Remove a user from the roster'''
if user.jid in self.to_be_removed[account]:
if user.jid in gajim.to_be_removed[account]:
return
model = self.tree.get_model()
for i in self.get_contact_iter(user.jid, account):
@ -182,12 +182,13 @@ class RosterWindow:
model.remove(parent_i)
# We need to check all contacts, even offline contacts
group_empty = True
for jid in self.contacts[account]:
if group in self.contacts[account][jid][0].groups:
for jid in gajim.contacts[account]:
if group in gajim.contacts[account][jid][0].groups:
group_empty = False
break
if group_empty:
del self.groups[account][group]
del gajim.groups[account][group]
def get_transport_name_by_jid(self,jid):
if not jid or not gajim.config.get('use_transports_iconsets'):
return None
@ -224,7 +225,7 @@ class RosterWindow:
iters = self.get_contact_iter(jid, account)
if len(iters) == 0:
return
users = self.contacts[account][jid]
users = gajim.contacts[account][jid]
name = users[0].name
if len(users) > 1:
name += ' (' + str(len(users)) + ')'
@ -236,7 +237,7 @@ class RosterWindow:
user = u
state_images = self.get_appropriate_state_images(jid)
if self.plugin.queues[account].has_key(jid):
if gajim.awaiting_messages[account].has_key(jid):
img = state_images['message']
elif jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
img = state_images[user.show]
@ -517,15 +518,15 @@ class RosterWindow:
self.tree.get_model().clear()
for acct in gajim.connections:
self.add_account_to_roster(acct)
for jid in self.contacts[acct].keys():
for jid in gajim.contacts[acct].keys():
self.add_contact_to_roster(jid, acct)
def mklists(self, array, account):
'''fill self.contacts and self.groups'''
if not self.contacts.has_key(account):
self.contacts[account] = {}
if not self.groups.has_key(account):
self.groups[account] = {}
'''fill gajim.contacts and gajim.groups'''
if not gajim.contacts.has_key(account):
gajim.contacts[account] = {}
if not gajim.groups.has_key(account):
gajim.groups[account] = {}
for jid in array.keys():
jids = jid.split('/')
#get jid
@ -555,26 +556,26 @@ class RosterWindow:
# when we draw the roster, we avoid having the same contact
# more than once (eg. we avoid showing it twice with 2 resources)
self.contacts[account][ji] = [user1]
gajim.contacts[account][ji] = [user1]
for g in array[jid]['groups'] :
if g in self.groups[account].keys():
if g in gajim.groups[account].keys():
continue
if account + g in self.collapsed_rows:
ishidden = False
else:
ishidden = True
self.groups[account][g] = { 'expand': ishidden }
gajim.groups[account][g] = { 'expand': ishidden }
def chg_contact_status(self, user, show, status, account):
'''When a contact changes his status'''
showOffline = gajim.config.get('showoffline')
model = self.tree.get_model()
luser = self.contacts[account][user.jid]
luser = gajim.contacts[account][user.jid]
user.show = show
user.status = status
if (show == 'offline' or show == 'error') and \
not self.plugin.queues[account].has_key(user.jid):
not gajim.awaiting_messages[account].has_key(user.jid):
if len(luser) > 1:
luser.remove(user)
self.draw_contact(user.jid, account)
@ -640,7 +641,7 @@ class RosterWindow:
if self.tooltip.timeout == 0 or self.tooltip.path != props[0]:
self.tooltip.path = row
self.tooltip.timeout = gobject.timeout_add(500,
self.show_tooltip, self.contacts[account][jid])
self.show_tooltip, gajim.contacts[account][jid])
def on_agent_logging(self, widget, jid, state, account):
'''When an agent is requested to log in or off'''
@ -659,14 +660,14 @@ class RosterWindow:
# remove transport from treeview
self.remove_user(contact, account)
# remove transport's contacts from treeview
for jid, contacts in self.contacts[account].items():
for jid, contacts in gajim.contacts[account].items():
contact = contacts[0]
if jid.endswith('@' + contact.jid):
gajim.log.debug(
'Removing contact %s due to unregistered transport %s'\
% (contact.jid, contact.name))
self.remove_user(contact, account)
del self.contacts[account][contact.jid]
del gajim.contacts[account][contact.jid]
def on_rename(self, widget, iter, path):
model = self.tree.get_model()
@ -694,7 +695,7 @@ class RosterWindow:
del keys[user.jid]
else:
keys[user.jid] = keyID[0]
for u in self.contacts[account][user.jid]:
for u in gajim.contacts[account][user.jid]:
u.keyID = keyID[0]
if self.plugin.windows[account]['chats'].has_key(user.jid):
self.plugin.windows[account]['chats'][user.jid].draw_widgets(user)
@ -724,7 +725,7 @@ class RosterWindow:
jid = model.get_value(iter, 3)
path = model.get_path(iter)
account = model.get_value(iter, 4)
contact = self.contacts[account][jid][0]
contact = gajim.contacts[account][jid][0]
xml = gtk.glade.XML(GTKGUI_GLADE, 'roster_contact_context_menu',
APP)
@ -818,14 +819,14 @@ class RosterWindow:
jid = model.get_value(iter, 3)
path = model.get_path(iter)
account = model.get_value(iter, 4)
user = self.contacts[account][jid][0]
user = gajim.contacts[account][jid][0]
menu = gtk.Menu()
item = gtk.ImageMenuItem(_('_Log on'))
icon = gtk.image_new_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_MENU)
item.set_image(icon)
menu.append(item)
show = self.contacts[account][jid][0].show
show = gajim.contacts[account][jid][0].show
if show != 'offline' and show != 'error':
item.set_sensitive(False)
item.connect('activate', self.on_agent_logging, jid, None, account)
@ -961,7 +962,7 @@ class RosterWindow:
gajim.connections[account].request_subscription(jid, txt)
if not group:
group = _('General')
if not self.contacts[account].has_key(jid):
if not gajim.contacts[account].has_key(jid):
keyID = ''
attached_keys = gajim.config.get_per('accounts', account,
'attached_gpg_keys').split()
@ -970,9 +971,9 @@ class RosterWindow:
user1 = Contact(jid = jid, name = pseudo, groups = [group],
show = 'requested', status = 'requested', ask = 'none',
sub = 'subscribe', keyID = keyID)
self.contacts[account][jid] = [user1]
gajim.contacts[account][jid] = [user1]
else:
user1 = self.contacts[account][jid][0]
user1 = gajim.contacts[account][jid][0]
if not _('not in the roster') in user1.groups:
dialogs.InformationDialog(_('Subscription request has been sent'),
_('If "%s" accepts this request you will know his status.') %jid).get_response()
@ -1010,7 +1011,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
jid = model.get_value(iter, 3)
account = model.get_value(iter, 4)
type = model.get_value(iter, 2)
user = self.contacts[account][jid][0]
user = gajim.contacts[account][jid][0]
if type == 'contact':
self.on_req_usub(widget, user, account)
elif type == 'agent':
@ -1074,8 +1075,8 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
jid = model.get_value(iter, 3)
if self.plugin.windows[account]['chats'].has_key(jid):
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
elif self.contacts[account].has_key(jid):
self.new_chat(self.contacts[account][jid][0], account)
elif gajim.contacts[account].has_key(jid):
self.new_chat(gajim.contacts[account][jid][0], account)
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
self.plugin.windows[account]['chats'][jid].window.present()
return True
@ -1103,14 +1104,14 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
_('By removing this contact you also remove authorization. Contact "%s" will always see you as offline.') % user.name)
if window.get_response() == gtk.RESPONSE_OK:
gajim.connections[account].unsubscribe(user.jid)
for u in self.contacts[account][user.jid]:
for u in gajim.contacts[account][user.jid]:
self.remove_user(u, account)
del self.contacts[account][u.jid]
del gajim.contacts[account][u.jid]
if user.jid in self.plugin.windows[account]['chats']:
user1 = Contact(jid = user.jid, name = user.name,
groups = [_('not in the roster')], show = _('not in the roster'),
status = _('not in the roster'), ask = 'none', keyID = user.keyID)
self.contacts[account][user.jid] = [user1]
gajim.contacts[account][user.jid] = [user1]
self.add_contact_to_roster(user.jid, account)
def forget_gpg_passphrase(self, keyid):
@ -1187,9 +1188,9 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
txt)
if status == 'online' and self.plugin.sleeper.getState() != \
common.sleepy.STATE_UNKNOWN:
self.plugin.sleeper_state[account] = 1
gajim.sleeper_state[account] = 1
else:
self.plugin.sleeper_state[account] = 0
gajim.sleeper_state[account] = 0
def get_status_message(self, show):
if (show == 'online' and not gajim.config.get('ask_online_status')) or \
@ -1254,15 +1255,15 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
def on_status_changed(self, account, status):
'''the core tells us that our status has changed'''
if not self.contacts.has_key(account):
if not gajim.contacts.has_key(account):
return
model = self.tree.get_model()
accountIter = self.get_account_iter(account)
if accountIter:
model.set_value(accountIter, 0, self.jabber_state_images[status])
if status == 'offline':
for jid in self.contacts[account]:
luser = self.contacts[account][jid]
for jid in gajim.contacts[account]:
luser = gajim.contacts[account][jid]
luser_copy = []
for user in luser:
luser_copy.append(user)
@ -1286,8 +1287,8 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
tabbed_chat_window.TabbedChatWindow(user, self.plugin, account)
def new_chat_from_jid(self, account, jid):
if self.contacts[account].has_key(jid):
user = self.contacts[account][jid][0]
if gajim.contacts[account].has_key(jid):
user = gajim.contacts[account][jid][0]
else:
keyID = ''
attached_keys = gajim.config.get_per('accounts', account,
@ -1297,7 +1298,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
user = Contact(jid = jid, name = jid.split('@')[0],
groups = [_('not in the roster')], show = _('not in the roster'),
status = _('not in the roster'), sub = 'none', keyID = keyID)
self.contacts[account][jid] = [user]
gajim.contacts[account][jid] = [user]
self.add_contact_to_roster(user.jid, account)
if not self.plugin.windows[account]['chats'].has_key(jid):
@ -1322,7 +1323,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
def on_message(self, jid, msg, tim, account, encrypted = False,\
msg_type = '', subject = None):
'''when we receive a message'''
if not self.contacts[account].has_key(jid):
if not gajim.contacts[account].has_key(jid):
keyID = ''
attached_keys = gajim.config.get_per('accounts', account,
'attached_gpg_keys').split()
@ -1331,7 +1332,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
user1 = Contact(jid = jid, name = jid.split('@')[0],
groups = [_('not in the roster')], show = _('not in the roster'),
status = _('not in the roster'), ask = 'none', keyID = keyID)
self.contacts[account][jid] = [user1]
gajim.contacts[account][jid] = [user1]
self.add_contact_to_roster(jid, account)
iters = self.get_contact_iter(jid, account)
@ -1346,13 +1347,13 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
if msg_type == 'normal': # it's single message
#FIXME: take into account autopopup and autopopupaway
# if user doesn't want to be bugged do it as we do the 'chat'
contact = self.contacts[account][jid][0]
contact = gajim.contacts[account][jid][0]
dialogs.SingleMessageWindow(self.plugin, account, contact,
action = 'receive', from_whom = jid, subject = subject, message = msg)
return
# Do we have a queue?
qs = self.plugin.queues[account]
qs = gajim.awaiting_messages[account]
no_queue = True
if qs.has_key(jid):
no_queue = False
@ -1385,7 +1386,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
self.tree.set_cursor(path)
else:
if not self.plugin.windows[account]['chats'].has_key(jid):
self.new_chat(self.contacts[account][jid][0], account)
self.new_chat(gajim.contacts[account][jid][0], account)
if path:
self.tree.expand_row(path[0:1], False)
self.tree.expand_row(path[0:2], False)
@ -1540,8 +1541,8 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
else:
if self.plugin.windows[account]['chats'].has_key(jid):
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
elif self.contacts[account].has_key(jid):
self.new_chat(self.contacts[account][jid][0], account)
elif gajim.contacts[account].has_key(jid):
self.new_chat(gajim.contacts[account][jid][0], account)
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
self.plugin.windows[account]['chats'][jid].window.present()
@ -1557,21 +1558,20 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
model.set_value(iter, 0, self.jabber_state_images['opened'])
jid = model.get_value(iter, 3)
for account in accounts:
if self.groups[account].has_key(jid): # This account has this group
self.groups[account][jid]['expand'] = True
if gajim.groups[account].has_key(jid): # This account has this group
gajim.groups[account][jid]['expand'] = True
if account + jid in self.collapsed_rows:
self.collapsed_rows.remove(account + jid)
elif type == 'account':
account = accounts[0] # There is only one cause we don't use merge
if account in self.collapsed_rows:
self.collapsed_rows.remove(account)
for g in self.groups[account]:
for g in gajim.groups[account]:
groupIter = self.get_group_iter(g, account)
if groupIter and self.groups[account][g]['expand']:
if groupIter and gajim.groups[account][g]['expand']:
pathG = model.get_path(groupIter)
self.tree.expand_row(pathG, False)
def on_roster_treeview_row_collapsed(self, widget, iter, path):
'''When a row is collapsed :
change the icon of the arrow'''
@ -1585,8 +1585,8 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
model.set_value(iter, 0, self.jabber_state_images['closed'])
jid = model.get_value(iter, 3)
for account in accounts:
if self.groups[account].has_key(jid): # This account has this group
self.groups[account][jid]['expand'] = False
if gajim.groups[account].has_key(jid): # This account has this group
gajim.groups[account][jid]['expand'] = False
if not account + jid in self.collapsed_rows:
self.collapsed_rows.append(account + jid)
elif type == 'account':
@ -1610,17 +1610,17 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
jid = model.get_value(iter, 3)
type = model.get_value(iter, 2)
if type == 'contact':
old_text = self.contacts[account][jid][0].name
old_text = gajim.contacts[account][jid][0].name
if old_text != new_text:
for u in self.contacts[account][jid]:
for u in gajim.contacts[account][jid]:
u.name = new_text
gajim.connections[account].update_contact(jid, new_text, u.groups)
self.draw_contact(jid, account)
elif type == 'group':
old_name = model.get_value(iter, 1)
#get all users in that group
for jid in self.contacts[account]:
user = self.contacts[account][jid][0]
for jid in gajim.contacts[account]:
user = gajim.contacts[account][jid][0]
if old_name in user.groups:
#set them in the new one and remove it from the old
self.remove_user(user, account)
@ -1723,9 +1723,9 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
else:
jid = model.get_value(iter, 3)
account = model.get_value(iter, 4)
if jid in self.newly_added[account]:
if jid in gajim.newly_added[account]:
renderer.set_property('cell-background', '#adc3c6')
elif jid in self.to_be_removed[account]:
elif jid in gajim.to_be_removed[account]:
renderer.set_property('cell-background', '#ab6161')
else:
renderer.set_property('cell-background',
@ -1758,9 +1758,9 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
account = model.get_value(iter, 4)
renderer.set_property('foreground',
gajim.config.get_per('themes', theme, 'contacttextcolor'))
if jid in self.newly_added[account]:
if jid in gajim.newly_added[account]:
renderer.set_property('cell-background', '#adc3c6')
elif jid in self.to_be_removed[account]:
elif jid in gajim.to_be_removed[account]:
renderer.set_property('cell-background', '#ab6161')
else:
renderer.set_property('cell-background',
@ -1781,9 +1781,9 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
else:
jid = model.get_value(iter, 3)
account = model.get_value(iter, 4)
if jid in self.newly_added[account]:
if jid in gajim.newly_added[account]:
renderer.set_property('cell-background', '#adc3c6')
elif jid in self.to_be_removed[account]:
elif jid in gajim.to_be_removed[account]:
renderer.set_property('cell-background', '#ab6161')
else:
renderer.set_property('cell-background',
@ -1823,8 +1823,8 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
if account and model.get_value(iter2, 4) == account:
jid1 = model.get_value(iter1, 3)
jid2 = model.get_value(iter2, 3)
luser1 = self.contacts[account][jid1]
luser2 = self.contacts[account][jid2]
luser1 = gajim.contacts[account][jid1]
luser2 = gajim.contacts[account][jid2]
cshow = {'online':0, 'chat': 1, 'away': 2, 'xa': 3, 'dnd': 4,
'invisible': 5, 'offline': 6, _('not in the roster'): 7, 'error': 8}
s = self.get_show(luser1)
@ -1897,18 +1897,18 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
return
# We upgrade only the first user because user2.groups is a pointer to
# user1.groups
u = self.contacts[account][data][0]
u = gajim.contacts[account][data][0]
u.groups.remove(grp_source)
if model.iter_n_children(iter_group_source) == 1: #this was the only child
model.remove(iter_group_source)
#delete the group if it is empty (need to look for offline users too)
group_empty = True
for jid in self.contacts[account]:
if grp_source in self.contacts[account][jid][0].groups:
for jid in gajim.contacts[account]:
if grp_source in gajim.contacts[account][jid][0].groups:
group_empty = False
break
if group_empty:
del self.groups[account][grp_source]
del gajim.groups[account][grp_source]
if not grp_dest in u.groups:
u.groups.append(grp_dest)
self.add_contact_to_roster(data, account)
@ -1947,20 +1947,9 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
self.window.resize(gajim.config.get('width'),
gajim.config.get('height'))
self.groups = {}
# contacts[account][jid] is a list of all Contact instances:
# one per resource
self.contacts = {}
self.newly_added = {}
self.to_be_removed = {}
self.popups_notification_height = 0
self.popup_notification_windows = []
self.gpg_passphrase = {}
for a in gajim.connections:
self.contacts[a] = {}
self.groups[a] = {}
self.newly_added[a] = []
self.to_be_removed[a] = []
#(icon, name, type, jid, account, editable, secondary_pixbuf)
model = gtk.TreeStore(gtk.Image, str, str, str, str, bool, gtk.gdk.Pixbuf)
model.set_sort_func(1, self.compareIters)

View file

@ -108,9 +108,9 @@ class Systray:
if self.plugin.windows[account]['chats'].has_key(jid):
self.plugin.windows[account]['chats'][jid].window.present()
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
elif self.plugin.roster.contacts[account].has_key(jid):
elif gajim.contacts[account].has_key(jid):
self.plugin.roster.new_chat(
self.plugin.roster.contacts[account][jid][0], account)
gajim.contacts[account][jid][0], account)
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
def on_new_message_menuitem_activate(self, widget, account):
@ -204,7 +204,7 @@ class Systray:
def make_groups_submenus_for_chat_with(self, account):
groups_menu = gtk.Menu()
for group in self.plugin.roster.groups[account].keys():
for group in gajim.groups[account].keys():
if group == _('Transports'):
continue
# at least one 'not offline' or 'without errors' in this group
@ -213,7 +213,7 @@ class Systray:
groups_menu.append(item)
contacts_menu = gtk.Menu()
item.set_submenu(contacts_menu)
for users in self.plugin.roster.contacts[account].values():
for users in gajim.contacts[account].values():
user = users[0]
if group in user.groups and user.show != 'offline' and \
user.show != 'error':
@ -252,7 +252,7 @@ class Systray:
w = acc['chats'][jid]
else:
self.plugin.roster.new_chat(
self.plugin.roster.contacts[account][jid][0], account)
gajim.contacts[account][jid][0], account)
acc['chats'][jid].set_active_tab(jid)
acc['chats'][jid].window.present()
if w:

View file

@ -154,8 +154,8 @@ class TabbedChatWindow(chat.Chat):
def set_state_image(self, jid):
prio = 0
if self.plugin.roster.contacts[self.account].has_key(jid):
list_users = self.plugin.roster.contacts[self.account][jid]
if gajim.contacts[self.account].has_key(jid):
list_users = gajim.contacts[self.account][jid]
else:
list_users = [self.users[jid]]
user = list_users[0]
@ -270,7 +270,7 @@ class TabbedChatWindow(chat.Chat):
self.restore_conversation(user.jid)
#print queued messages
if self.plugin.queues[self.account].has_key(user.jid):
if gajim.awaiting_messages[self.account].has_key(user.jid):
self.read_queue(user.jid)
gajim.connections[self.account].request_vcard(user.jid)
@ -362,21 +362,21 @@ class TabbedChatWindow(chat.Chat):
def read_queue(self, jid):
"""read queue and print messages containted in it"""
l = self.plugin.queues[self.account][jid]
l = gajim.awaiting_messages[self.account][jid]
user = self.users[jid]
for event in l:
self.print_conversation(event[0], jid, tim = event[1],
encrypted = event[2])
self.plugin.roster.nb_unread -= 1
self.plugin.roster.show_title()
del self.plugin.queues[self.account][jid]
del gajim.awaiting_messages[self.account][jid]
self.plugin.roster.draw_contact(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
showOffline = gajim.config.get('showoffline')
if (user.show == 'offline' or user.show == 'error') and \
not showOffline:
if len(self.plugin.roster.contacts[self.account][jid]) == 1:
if len(gajim.contacts[self.account][jid]) == 1:
self.plugin.roster.really_remove_user(user, self.account)
def print_conversation(self, text, jid, contact = '', tim = None,
@ -404,7 +404,7 @@ class TabbedChatWindow(chat.Chat):
self.xmls[jid].get_widget('gpg_togglebutton').set_active(encrypted)
if contact:
kind = 'outgoing'
name = self.plugin.nicks[self.account]
name = gajim.nicks[self.account]
else:
kind = 'incoming'
name = user.name
@ -431,8 +431,8 @@ class TabbedChatWindow(chat.Chat):
count = gajim.logger.get_nb_line(jid)
if self.plugin.queues[self.account].has_key(jid):
pos = len(self.plugin.queues[self.account][jid])
if gajim.awaiting_messages[self.account].has_key(jid):
pos = len(gajim.awaiting_messages[self.account][jid])
else:
pos = 0
@ -461,7 +461,7 @@ class TabbedChatWindow(chat.Chat):
for msg in lines:
if msg[1] == 'sent':
kind = 'outgoing'
name = self.plugin.nicks[self.account]
name = gajim.nicks[self.account]
elif msg[1] == 'recv':
kind = 'incoming'
name = self.users[jid].name

View file

@ -275,8 +275,8 @@ class VcardWindow:
self.os_info = {0: {'resource': self.user.resource, 'client': '',
'os': ''}}
i = 1
if self.plugin.roster.contacts[self.account].has_key(self.user.jid):
for u in self.plugin.roster.contacts[self.account][self.user.jid]:
if gajim.contacts[self.account].has_key(self.user.jid):
for u in gajim.contacts[self.account][self.user.jid]:
if u.resource != self.user.resource:
resources += '\n' + u.resource + ' (' + str(u.priority) + ')'
if not u.status:
@ -365,7 +365,7 @@ class VcardWindow:
nick = vcard['NICKNAME']
if nick == '':
nick = gajim.config.get_per('accounts', self.account, 'name')
self.plugin.nicks[self.account] = nick
gajim.nicks[self.account] = nick
gajim.connections[self.account].send_vcard(vcard)
def on_retrieve_button_clicked(self, widget):