gtkgui don't send messages to the connection but call the correct functions

This commit is contained in:
Yann Leboulanger 2005-04-14 09:38:08 +00:00
parent d6a76e58c4
commit eb7cf5ba4d
9 changed files with 89 additions and 92 deletions

View file

@ -33,7 +33,7 @@ class Config:
__options = { __options = {
# name: [ type, value ] # name: [ type, value ]
'log': [ opt_bool, 'False' ], 'log': [ opt_bool, 'True' ],
'delauth': [ opt_bool, 'True' ], 'delauth': [ opt_bool, 'True' ],
'delroster': [ opt_bool, 'True' ], 'delroster': [ opt_bool, 'True' ],
'alwaysauth': [ opt_bool, 'False' ], 'alwaysauth': [ opt_bool, 'False' ],

View file

@ -85,7 +85,7 @@ def get_os_info():
class connection: class connection:
"""connection""" """connection"""
def __init__(self, name = None): def __init__(self, name):
# dict of function to be calledfor each event # dict of function to be calledfor each event
self.handlers = {'ROSTER': [], 'WARNING': [], 'ERROR': [], 'STATUS': [], \ self.handlers = {'ROSTER': [], 'WARNING': [], 'ERROR': [], 'STATUS': [], \
'NOTIFY': [], 'MSG': [], 'MSGERROR': [], 'MSGSENT': [] , \ 'NOTIFY': [], 'MSG': [], 'MSGERROR': [], 'MSGSENT': [] , \
@ -99,13 +99,12 @@ class connection:
self.connection = None # Jabber.py instance self.connection = None # Jabber.py instance
self.gpg = None self.gpg = None
self.myVCardID = [] self.myVCardID = []
if name: self.password = gajim.config.get_per('accounts', name, 'hostname')
self.password = gajim.config.get_per('accounts', name, 'hostname') if USE_GPG:
if USE_GPG: self.gpg = GnuPG.GnuPG()
self.gpg = GnuPG.GnuPG() gajim.config.set('usegpg', True)
gajim.config.set('usegpg', True) else:
else: gajim.config.set('usegpg', False)
gajim.config.set('usegpg', False)
# END __init__ # END __init__
def dispatch(self, event, data): def dispatch(self, event, data):

View file

@ -1110,7 +1110,7 @@ class Account_modification_window:
gajim.config.set_per('accounts', name, 'no_log_for', \ gajim.config.set_per('accounts', name, 'no_log_for', \
self.infos['no_log_for']) self.infos['no_log_for'])
if save_password: if save_password:
self.plugin.send('PASSPHRASE', name, password) gajim.connections[name].password = password
#refresh accounts window #refresh accounts window
if self.plugin.windows.has_key('accounts'): if self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'].init_accounts() self.plugin.windows['accounts'].init_accounts()
@ -1126,8 +1126,8 @@ class Account_modification_window:
self.plugin.register_handlers(gajim.connections[name]) self.plugin.register_handlers(gajim.connections[name])
#if we neeed to register a new account #if we neeed to register a new account
if new_account_checkbutton.get_active(): if new_account_checkbutton.get_active():
self.plugin.send('NEW_ACC', None, (hostname, login, password, name, \ gajim.connections[name].new_account(hostname, login, password, name, \
resource, priority, use_proxy, proxyhost, proxyport)) resource, priority, use_proxy, proxyhost, proxyport)
return return
gajim.config.set_per('accounts', name, 'name', login) gajim.config.set_per('accounts', name, 'name', login)
gajim.config.set_per('accounts', name, 'hostname', hostname) gajim.config.set_per('accounts', name, 'hostname', hostname)
@ -1148,7 +1148,7 @@ class Account_modification_window:
gajim.config.set_per('accounts', name, 'no_log_for', \ gajim.config.set_per('accounts', name, 'no_log_for', \
self.infos['no_log_for']) self.infos['no_log_for'])
if save_password: if save_password:
self.plugin.send('PASSPHRASE', name, password) gajim.connections[name].password = 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] = {}
@ -1170,8 +1170,8 @@ class Account_modification_window:
dialog = Change_password_dialog(self.plugin, self.account) dialog = Change_password_dialog(self.plugin, self.account)
new_password = dialog.run() new_password = dialog.run()
if new_password != -1: if new_password != -1:
self.plugin.send('CHANGE_PASSWORD', self.account,\ gajim.connections[self.account].change_password(new_password, \
(new_password, self.plugin.nicks[self.account])) self.plugin.nicks[self.account])
if self.xml.get_widget('save_password_checkbutton').get_active(): if self.xml.get_widget('save_password_checkbutton').get_active():
self.xml.get_widget('password_entry').set_text(new_password) self.xml.get_widget('password_entry').set_text(new_password)
@ -1239,7 +1239,7 @@ class Account_modification_window:
if not self.plugin.windows[self.account]['infos'].has_key('vcard'): if not self.plugin.windows[self.account]['infos'].has_key('vcard'):
self.plugin.windows[self.account]['infos'][jid] = \ self.plugin.windows[self.account]['infos'][jid] = \
vcard_information_window(jid, self.plugin, self.account, True) vcard_information_window(jid, self.plugin, self.account, True)
self.plugin.send('ASK_VCARD', self.account, jid) gajim.connections[self.account].request_vcard(jid)
def on_gpg_choose_button_clicked(self, widget, data=None): def on_gpg_choose_button_clicked(self, widget, data=None):
secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys() secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys()
@ -1359,7 +1359,7 @@ class Accounts_window:
dialog = Confirmation_dialog(_('Are you sure you want to remove account (%s) ?') % account) dialog = Confirmation_dialog(_('Are you sure you want to remove account (%s) ?') % account)
if dialog.get_response() == gtk.RESPONSE_YES: if dialog.get_response() == gtk.RESPONSE_YES:
if gajim.connections[account].connected: if gajim.connections[account].connected:
self.plugin.send('STATUS', account, ('offline', 'offline')) gajim.connections[account].change_status('offline', 'offline')
del gajim.connections[account] del gajim.connections[account]
del self.plugin.windows[account] del self.plugin.windows[account]
del self.plugin.queues[account] del self.plugin.queues[account]
@ -1449,7 +1449,7 @@ class Service_registration_window:
'offline', 'from', '', '', 0, '') 'offline', 'from', '', '', 0, '')
self.plugin.roster.contacts[self.account][self.service] = [user1] self.plugin.roster.contacts[self.account][self.service] = [user1]
self.plugin.roster.add_user_to_roster(self.service, self.account) self.plugin.roster.add_user_to_roster(self.service, self.account)
self.plugin.send('REG_AGENT', self.account, self.service) gajim.connections[self.account].register_agent(self.service)
self.window.destroy() self.window.destroy()
def __init__(self, service, infos, plugin, account): def __init__(self, service, infos, plugin, account):
@ -1669,7 +1669,7 @@ class Service_discovery_window:
# we begin to fill the treevier with the first line # we begin to fill the treevier with the first line
iter = model.append(None, (jid, jid)) iter = model.append(None, (jid, jid))
self.agent_infos[jid] = {'features' : []} self.agent_infos[jid] = {'features' : []}
self.plugin.send('REQ_AGENTS', self.account, jid) gajim.connections[self.account].request_agents(jid)
def agents(self, agents): def agents(self, agents):
"""When list of available agent arrive : """When list of available agent arrive :

View file

@ -53,8 +53,8 @@ class Vcard_information_window:
self.user.name = new_name self.user.name = new_name
for i in self.plugin.roster.get_user_iter(self.user.jid, self.account): for i in self.plugin.roster.get_user_iter(self.user.jid, self.account):
self.plugin.roster.tree.get_model().set_value(i, 1, new_name) self.plugin.roster.tree.get_model().set_value(i, 1, new_name)
self.plugin.send('UPDUSER', self.account, (self.user.jid, \ gajim.connections[self.account].update_user(self.user.jid, \
self.user.name, self.user.groups)) self.user.name, self.user.groups)
#log history ? #log history ?
oldlog = 1 oldlog = 1
no_log_for = gajim.config.get_per('accounts', self.account, 'no_log_for')\ no_log_for = gajim.config.get_per('accounts', self.account, 'no_log_for')\
@ -119,8 +119,9 @@ class Vcard_information_window:
stats += '\n' + u.show + ': ' + u.status stats += '\n' + u.show + ': ' + u.status
self.xml.get_widget('resource_label').set_text(resources) self.xml.get_widget('resource_label').set_text(resources)
self.xml.get_widget('status_label').set_text(stats) self.xml.get_widget('status_label').set_text(stats)
self.plugin.send('ASK_VCARD', self.account, self.user.jid) gajim.connections[self.account].request_vcard(self.user.jid)
self.plugin.send('ASK_OS_INFO', self.account, (self.user.jid, self.user.resource)) gajim.connections[self.account].request_os_info(self.user.jid, \
self.user.resource)
def add_to_vcard(self, vcard, entry, txt): def add_to_vcard(self, vcard, entry, txt):
"""Add an information to the vCard dictionary""" """Add an information to the vCard dictionary"""
@ -163,7 +164,7 @@ class Vcard_information_window:
if nick == '': if nick == '':
nick = gajim.config.get_per('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) gajim.connections[self.account].send_vcard(vcard)
def on_retrieve_button_clicked(self, widget): def on_retrieve_button_clicked(self, widget):
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',\ entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',\
@ -174,7 +175,7 @@ class Vcard_information_window:
for e in entries: for e in entries:
self.xml.get_widget(e + '_entry').set_text('') self.xml.get_widget(e + '_entry').set_text('')
self.xml.get_widget('DESC_textview').get_buffer().set_text('') self.xml.get_widget('DESC_textview').get_buffer().set_text('')
self.plugin.send('ASK_VCARD', self.account, self.jid) gajim.connections[self.account].request_vcard(self.jid)
else: else:
Error_dialog(_('You must be connected to get your informations')) Error_dialog(_('You must be connected to get your informations'))
@ -251,8 +252,8 @@ class Edit_groups_dialog:
self.dialog.run() self.dialog.run()
self.dialog.destroy() self.dialog.destroy()
#TODO: do not send if unnecesary #TODO: do not send if unnecesary
self.plugin.send('UPDUSER', self.account, (self.user.jid, \ gajim.connections[self.account].update_user(self.user.jid, \
self.user.name, self.user.groups)) self.user.name, self.user.groups)
def update_user(self): def update_user(self):
self.plugin.roster.remove_user(self.user, self.account) self.plugin.roster.remove_user(self.user, self.account)
@ -505,7 +506,7 @@ class Add_new_contact_window:
self.plugin.roster.req_sub(self, jid, message, self.account, group,\ self.plugin.roster.req_sub(self, jid, message, self.account, group,\
nickname) nickname)
if self.xml.get_widget('auto_authorize_checkbutton').get_active(): if self.xml.get_widget('auto_authorize_checkbutton').get_active():
self.plugin.send('AUTH', self.account, jid) gajim.connections[self.account].send_authorization(jid)
self.window.destroy() self.window.destroy()
def fill_jid(self): def fill_jid(self):
@ -647,14 +648,14 @@ class subscription_request_window:
def on_authorize_button_clicked(self, widget): def on_authorize_button_clicked(self, widget):
"""Accept the request""" """Accept the request"""
self.plugin.send('AUTH', self.account, self.jid) gajim.connections[self.account].send_authorization(self.jid)
self.window.destroy() self.window.destroy()
if not self.plugin.roster.contacts[self.account].has_key(self.jid): if not self.plugin.roster.contacts[self.account].has_key(self.jid):
Add_new_contact_window(self.plugin, self.account, self.jid) Add_new_contact_window(self.plugin, self.account, self.jid)
def on_deny_button_clicked(self, widget): def on_deny_button_clicked(self, widget):
"""refuse the request""" """refuse the request"""
self.plugin.send('DENY', self.account, self.jid) gajim.connections[self.account].refuse_authorization(self.jid)
self.window.destroy() self.window.destroy()
class Join_groupchat_window: class Join_groupchat_window:
@ -718,8 +719,7 @@ class Join_groupchat_window:
self.recently_groupchat = self.recently_groupchat[0:10] self.recently_groupchat = self.recently_groupchat[0:10]
gajim.config.set('recently_groupchat', ' '.join(self.recently_groupchat)) gajim.config.set('recently_groupchat', ' '.join(self.recently_groupchat))
self.plugin.roster.new_group(jid, nickname, self.account) self.plugin.roster.new_group(jid, nickname, self.account)
self.plugin.send('GC_JOIN', self.account, (nickname, room, server, \ gajim.connections[self.account].join_gc(nickname, room, server, password)
password))
self.window.destroy() self.window.destroy()

View file

@ -72,8 +72,8 @@ class Groupchat_window(Chat):
def on_groupchat_window_destroy(self, widget): def on_groupchat_window_destroy(self, widget):
for room_jid in self.xmls: for room_jid in self.xmls:
self.plugin.send('GC_STATUS', self.account, (self.nicks[room_jid], \ gajim.connections[self.account].send_gc_status(self.nicks[room_jid], \
room_jid, 'offline', 'offline')) room_jid, 'offline', 'offline')
Chat.on_window_destroy(self, widget, 'gc') Chat.on_window_destroy(self, widget, 'gc')
def on_groupchat_window_focus_in_event(self, widget, event): def on_groupchat_window_focus_in_event(self, widget, event):
@ -233,7 +233,7 @@ class Groupchat_window(Chat):
def on_set_button_clicked(self, widget): def on_set_button_clicked(self, widget):
room_jid = self.get_active_jid() room_jid = self.get_active_jid()
subject = self.xml.get_widget('subject_entry').get_text() subject = self.xml.get_widget('subject_entry').get_text()
self.plugin.send('GC_SUBJECT', self.account, (room_jid, subject)) gajim.connections[self.account].send_gc_subject(room_jid, subject)
def on_message_textview_key_press_event(self, widget, event): def on_message_textview_key_press_event(self, widget, event):
"""When a key is pressed: """When a key is pressed:
@ -267,7 +267,7 @@ class Groupchat_window(Chat):
txt = message_buffer.get_text(start_iter, end_iter, 0) txt = message_buffer.get_text(start_iter, end_iter, 0)
if txt != '': if txt != '':
room_jid = self.get_active_jid() room_jid = self.get_active_jid()
self.plugin.send('GC_MSG', self.account, (room_jid, txt)) gajim.connections[self.account].send_gc_message(room_jid, txt)
message_buffer.set_text('', -1) message_buffer.set_text('', -1)
widget.grab_focus() widget.grab_focus()
return True return True
@ -315,68 +315,62 @@ class Groupchat_window(Chat):
def kick(self, widget, room_jid, nick): def kick(self, widget, room_jid, nick):
"""kick a user""" """kick a user"""
self.plugin.send('GC_SET_ROLE', self.account, (room_jid, nick, 'none')) gajim.connections[self.account].gc_set_role(room_jid, nick, 'none')
def grant_voice(self, widget, room_jid, nick): def grant_voice(self, widget, room_jid, nick):
"""grant voice privilege to a user""" """grant voice privilege to a user"""
self.plugin.send('GC_SET_ROLE', self.account, (room_jid, nick, \ gajim.connections[self.account].gc_set_role(room_jid, nick, 'participant')
'participant'))
def revoke_voice(self, widget, room_jid, nick): def revoke_voice(self, widget, room_jid, nick):
"""revoke voice privilege to a user""" """revoke voice privilege to a user"""
self.plugin.send('GC_SET_ROLE', self.account, (room_jid, nick, 'visitor')) gajim.connections[self.account].gc_set_role(room_jid, nick, 'visitor')
def grant_moderator(self, widget, room_jid, nick): def grant_moderator(self, widget, room_jid, nick):
"""grant moderator privilege to a user""" """grant moderator privilege to a user"""
self.plugin.send('GC_SET_ROLE', self.account, (room_jid, nick,\ gajim.connections[self.account].gc_set_role(room_jid, nick, 'moderator')
'moderator'))
def revoke_moderator(self, widget, room_jid, nick): def revoke_moderator(self, widget, room_jid, nick):
"""revoke moderator privilege to a user""" """revoke moderator privilege to a user"""
self.plugin.send('GC_SET_ROLE', self.account, (room_jid, nick, \ gajim.connections[self.account].gc_set_role(room_jid, nick, 'participant')
'participant'))
def ban(self, widget, room_jid, jid): def ban(self, widget, room_jid, jid):
"""ban a user""" """ban a user"""
self.plugin.send('GC_SET_AFFILIATION', self.account, (room_jid, jid, \ gajim.connections[self.account].gc_set_affiliation(room_jid, jid, \
'outcast')) 'outcast')
def grant_membership(self, widget, room_jid, jid): def grant_membership(self, widget, room_jid, jid):
"""grant membership privilege to a user""" """grant membership privilege to a user"""
self.plugin.send('GC_SET_AFFILIATION', self.account, (room_jid, jid, \ gajim.connections[self.account].gc_set_affiliation(room_jid, jid, \
'member')) 'member')
def revoke_membership(self, widget, room_jid, jid): def revoke_membership(self, widget, room_jid, jid):
"""revoke membership privilege to a user""" """revoke membership privilege to a user"""
self.plugin.send('GC_SET_AFFILIATION', self.account, (room_jid, jid, \ gajim.connections[self.account].gc_set_affiliation(room_jid, jid, \
'none')) 'none')
def grant_admin(self, widget, room_jid, jid): def grant_admin(self, widget, room_jid, jid):
"""grant administrative privilege to a user""" """grant administrative privilege to a user"""
self.plugin.send('GC_SET_AFFILIATION', self.account, (room_jid, jid, \ gajim.connections[self.account].gc_set_affiliation(room_jid, jid, 'admin')
'admin'))
def revoke_admin(self, widget, room_jid, jid): def revoke_admin(self, widget, room_jid, jid):
"""revoke administrative privilege to a user""" """revoke administrative privilege to a user"""
self.plugin.send('GC_SET_AFFILIATION', self.account, (room_jid, jid, \ gajim.connections[self.account].gc_set_affiliation(room_jid, jid, \
'member')) 'member')
def grant_owner(self, widget, room_jid, jid): def grant_owner(self, widget, room_jid, jid):
"""grant owner privilege to a user""" """grant owner privilege to a user"""
self.plugin.send('GC_SET_AFFILIATION', self.account, (room_jid, jid, \ gajim.connections[self.account].gc_set_affiliation(room_jid, jid, 'owner')
'owner'))
def revoke_owner(self, widget, room_jid, jid): def revoke_owner(self, widget, room_jid, jid):
"""revoke owner privilege to a user""" """revoke owner privilege to a user"""
self.plugin.send('GC_SET_AFFILIATION', self.account, (room_jid, jid, \ gajim.connections[self.account].gc_set_affiliation(room_jid, jid, 'admin')
'admin'))
def on_info(self, widget, jid): def on_info(self, widget, jid):
"""Call vcard_information_window class to display user's information""" """Call vcard_information_window class to display user's information"""
if not self.plugin.windows[self.account]['infos'].has_key(jid): if not self.plugin.windows[self.account]['infos'].has_key(jid):
self.plugin.windows[self.account]['infos'][jid] = \ self.plugin.windows[self.account]['infos'][jid] = \
Vcard_information_window(jid, self.plugin, self.account, True) Vcard_information_window(jid, self.plugin, self.account, True)
self.plugin.send('ASK_VCARD', self.account, jid) gajim.connections[self.account].request_vcard(jid)
#FIXME: maybe use roster.on_info above? #FIXME: maybe use roster.on_info above?
#FIXME: we need the resource but it's not saved #FIXME: we need the resource but it's not saved
@ -455,8 +449,8 @@ class Groupchat_window(Chat):
Chat.remove_tab(self, room_jid, 'gc') Chat.remove_tab(self, room_jid, 'gc')
if len(self.xmls) > 0: if len(self.xmls) > 0:
self.plugin.send('GC_STATUS', self.account, (self.nicks[room_jid], \ gajim.connections[self.account].send_gc_status(self.nicks[room_jid], \
room_jid, 'offline', 'offline')) room_jid, 'offline', 'offline')
del self.nicks[room_jid] del self.nicks[room_jid]
del self.list_treeview[room_jid] del self.list_treeview[room_jid]
del self.subjects[room_jid] del self.subjects[room_jid]

View file

@ -372,7 +372,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('@', '')
self.roster.on_message(jid, _("error while sending") + \ self.roster.on_message(jid, _('error while sending') + \
' \"%s\" ( %s )' % (array[3], array[2]), array[4], account) ' \"%s\" ( %s )' % (array[3], array[2]), array[4], account)
def handle_event_msgsent(self, account, array): def handle_event_msgsent(self, account, array):
@ -396,7 +396,7 @@ class interface:
if len(u.groups) == 0: if len(u.groups) == 0:
u.groups = ['General'] u.groups = ['General']
self.roster.add_user_to_roster(u.jid, account) self.roster.add_user_to_roster(u.jid, account)
self.send('UPDUSER', account, (u.jid, u.name, u.groups)) gajim.connections[account].update_user(u.jid, u.name, u.groups)
else: else:
user1 = User(jid, jid, ['General'], 'online', \ user1 = User(jid, jid, ['General'], 'online', \
'online', 'to', '', array[1], 0, '') 'online', 'to', '', array[1], 0, '')
@ -532,20 +532,20 @@ class interface:
if state == common.sleepy.STATE_AWAKE and \ if state == common.sleepy.STATE_AWAKE and \
self.sleeper_state[account] > 1: self.sleeper_state[account] > 1:
#we go online #we go online
self.send('STATUS', account, ('online', 'Online')) gajim.connections[account].change_status('online', 'Online')
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 \
gajim.config.get('autoaway'): gajim.config.get('autoaway'):
#we go away #we go away
self.send('STATUS', account, ('away', 'auto away (idle)')) gajim.connections[account].change_status('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 \
gajim.config.get('autoxa'): gajim.config.get('autoxa'):
#we go extended away #we go extended away
self.send('STATUS', account, ('xa', 'auto away (idle)')) gajim.connections[account].change_status('xa', 'auto away (idle)')
self.sleeper_state[account] = 3 self.sleeper_state[account] = 3
return 1 return 1

View file

@ -52,7 +52,8 @@ class history_window:
end = 50 end = 50
if end > self.nb_line: if end > self.nb_line:
end = self.nb_line end = self.nb_line
self.plugin.send('LOG_GET_RANGE', None, (self.jid, 0, end)) #FIXME:
# self.plugin.send('LOG_GET_RANGE', None, (self.jid, 0, end))
self.num_begin = self.nb_line self.num_begin = self.nb_line
def on_previous_button_clicked(self, widget): def on_previous_button_clicked(self, widget):
@ -68,7 +69,8 @@ class history_window:
end = begin + 50 end = begin + 50
if end > self.nb_line: if end > self.nb_line:
end = self.nb_line end = self.nb_line
self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, end)) #FIXME:
# self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, end))
self.num_begin = self.nb_line self.num_begin = self.nb_line
def on_forward_button_clicked(self, widget): def on_forward_button_clicked(self, widget):
@ -84,7 +86,8 @@ class history_window:
end = begin + 50 end = begin + 50
if end > self.nb_line: if end > self.nb_line:
end = self.nb_line end = self.nb_line
self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, end)) #FIXME:
# self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, end))
self.num_begin = self.nb_line self.num_begin = self.nb_line
def on_latest_button_clicked(self, widget): def on_latest_button_clicked(self, widget):
@ -97,7 +100,8 @@ class history_window:
begin = self.nb_line - 50 begin = self.nb_line - 50
if begin < 0: if begin < 0:
begin = 0 begin = 0
self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, self.nb_line)) #FIXME:
# self.plugin.send('LOG_GET_RANGE', None, (self.jid, begin, self.nb_line))
self.num_begin = self.nb_line self.num_begin = self.nb_line
def new_line(self, infos): def new_line(self, infos):
@ -158,4 +162,5 @@ class history_window:
color = gajim.config.get('statusmsgcolor') color = gajim.config.get('statusmsgcolor')
tagStatus.set_property('foreground', color) tagStatus.set_property('foreground', color)
self.window.show_all() self.window.show_all()
self.plugin.send('LOG_NB_LINE', None, jid) #FIXME:
# self.plugin.send('LOG_NB_LINE', None, jid)

View file

@ -30,7 +30,7 @@ from tabbed_chat_window import *
from groupchat_window import * from groupchat_window import *
from history_window import * from history_window import *
from gtkgui import CellRendererImage, User from gtkgui import CellRendererImage, User
from dialogs import * import dialogs
from config import * from config import *
from common import i18n from common import i18n
@ -408,13 +408,13 @@ class Roster_window:
def on_agent_logging(self, widget, jid, state, account): def on_agent_logging(self, widget, jid, state, account):
"""When an agent is requested to log in or off""" """When an agent is requested to log in or off"""
self.plugin.send('AGENT_LOGGING', account, (jid, state)) gajim.connections[account].send_agent_status(jid, state)
def on_remove_agent(self, widget, jid, account): def on_remove_agent(self, widget, jid, account):
"""When an agent is requested to log in or off""" """When an agent is requested to log in or off"""
window = Confirmation_dialog(_('Are you sure you want to remove the agent %s from your roster?') % jid) window = Confirmation_dialog(_('Are you sure you want to remove the agent %s from your roster?') % jid)
if window.get_response() == gtk.RESPONSE_YES: if window.get_response() == gtk.RESPONSE_YES:
self.plugin.send('UNSUB_AGENT', account, jid) gajim.connections[account].unsubscribe_agent(jid)
for u in self.contacts[account][jid]: for u in self.contacts[account][jid]:
self.remove_user(u, account) self.remove_user(u, account)
del self.contacts[account][u.jid] del self.contacts[account][u.jid]
@ -596,13 +596,13 @@ class Roster_window:
def authorize(self, widget, jid, account): def authorize(self, widget, jid, account):
"""Authorize a user""" """Authorize a user"""
self.plugin.send('AUTH', account, jid) gajim.connections[account].send_authorization(jid)
def req_sub(self, widget, jid, txt, account, group=None, pseudo=None): def req_sub(self, widget, jid, txt, account, group=None, pseudo=None):
"""Request subscription to a user""" """Request subscription to a user"""
if not pseudo: if not pseudo:
pseudo = jid pseudo = jid
self.plugin.send('SUB', account, (jid, txt)) gajim.connections[account].request_subscription(jid, txt)
if not self.contacts[account].has_key(jid): if not self.contacts[account].has_key(jid):
if not group: if not group:
group = 'General' group = 'General'
@ -685,7 +685,7 @@ class Roster_window:
"""Remove a user""" """Remove a user"""
window = Confirmation_dialog(_("Are you sure you want to remove %s (%s) from your roster?") % (user.name, user.jid)) window = Confirmation_dialog(_("Are you sure you want to remove %s (%s) from your roster?") % (user.name, user.jid))
if window.get_response() == gtk.RESPONSE_YES: if window.get_response() == gtk.RESPONSE_YES:
self.plugin.send('UNSUB', account, user.jid) gajim.connections[account].unsubscribe(user.jid)
for u in self.contacts[account][user.jid]: for u in self.contacts[account][user.jid]:
self.remove_user(u, account) self.remove_user(u, account)
del self.contacts[account][u.jid] del self.contacts[account][u.jid]
@ -705,7 +705,7 @@ class Roster_window:
save_pass = gajim.config.get_per('accounts', account, 'savepass') save_pass = gajim.config.get_per('accounts', account, 'savepass')
if not save_pass and gajim.connections[account].connected < 2: if not save_pass and gajim.connections[account].connected < 2:
passphrase = '' passphrase = ''
w = Passphrase_dialog(_('Enter your password for account %s') \ w = dialogs.Passphrase_dialog(_('Enter your password for account %s') \
% account, 'Save password', autoconnect) % account, 'Save password', autoconnect)
passphrase, save = w.run() passphrase, save = w.run()
if passphrase == -1: if passphrase == -1:
@ -715,7 +715,7 @@ class Roster_window:
self.plugin.systray.set_status('offline') self.plugin.systray.set_status('offline')
self.update_status_comboxbox() self.update_status_comboxbox()
return return
self.plugin.send('PASSPHRASE', account, passphrase) gajim.connections[account].password = passphrase
if save: if save:
gajim.config.set_per('accounts', account, 'savepass', True) gajim.config.set_per('accounts', account, 'savepass', True)
gajim.config.set_per('accounts', account, 'password', passphrase) gajim.config.set_per('accounts', account, 'password', passphrase)
@ -732,7 +732,7 @@ class Roster_window:
'gpgpassword') 'gpgpassword')
else: else:
passphrase = '' passphrase = ''
w = Passphrase_dialog(\ w = dialogs.Passphrase_dialog(\
_('Enter GPG key passphrase for account %s') % account, \ _('Enter GPG key passphrase for account %s') % account, \
'Save passphrase', autoconnect) 'Save passphrase', autoconnect)
passphrase, save = w.run() passphrase, save = w.run()
@ -742,14 +742,13 @@ class Roster_window:
gajim.config.set_per('accounts', account, 'savegpgpass', True) gajim.config.set_per('accounts', account, 'savegpgpass', True)
gajim.config.set_per('accounts', account, 'gpgpassword', \ gajim.config.set_per('accounts', account, 'gpgpassword', \
passphrase) passphrase)
#FIXME: gajim.connections[account].gpg_passphrase(passphrase)
self.plugin.send('GPGPASSPHRASE', account, passphrase) gajim.connections[account].change_status(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']:
if room_jid != 'tabbed': if room_jid != 'tabbed':
nick = self.plugin.windows[account]['gc'][room_jid].nicks[room_jid] nick = self.plugin.windows[account]['gc'][room_jid].nicks[room_jid]
self.plugin.send('GC_STATUS', account, (nick, room_jid, status, \ gajim.connections[account].send_gc_status(nick, room_jid, status, \
txt)) txt)
if status == 'online' and self.plugin.sleeper.getState() != \ if status == 'online' and self.plugin.sleeper.getState() != \
common.sleepy.STATE_UNKNOWN: common.sleepy.STATE_UNKNOWN:
self.plugin.sleeper_state[account] = 1 self.plugin.sleeper_state[account] = 1
@ -982,7 +981,8 @@ class Roster_window:
gajim.config.set('height', height) gajim.config.set('height', height)
self.plugin.save_config() self.plugin.save_config()
self.plugin.send('QUIT', None, ('gtkgui', 1)) for account in gajim.connections:
gajim.connections[account].quit(True)
self.close_all(self.plugin.windows) self.close_all(self.plugin.windows)
if self.plugin.systray_enabled: if self.plugin.systray_enabled:
self.plugin.hide_systray() self.plugin.hide_systray()
@ -1083,8 +1083,7 @@ class Roster_window:
if old_text != new_text: if old_text != new_text:
for u in self.contacts[account][jid]: for u in self.contacts[account][jid]:
u.name = new_text u.name = new_text
self.plugin.send('UPDUSER', account, (jid, new_text, \ gajim.connections[account].update_user(jid, new_text, u.groups)
self.contacts[account][jid][0].groups))
self.redraw_jid(jid, account) self.redraw_jid(jid, account)
elif type == 'group': elif type == 'group':
old_name = model.get_value(iter, 1) old_name = model.get_value(iter, 1)
@ -1097,8 +1096,8 @@ class Roster_window:
user.groups.remove(old_name) user.groups.remove(old_name)
user.groups.append(new_text) user.groups.append(new_text)
self.add_user_to_roster(user.jid, account) self.add_user_to_roster(user.jid, account)
self.plugin.send('UPDUSER', account, (user.jid, user.name, \ gajim.connections[account].update_user(user.jid, user.name, \
user.groups)) user.groups)
model.set_value(iter, 5, False) model.set_value(iter, 5, False)
def on_service_disco_menuitem_activate(self, widget, account): def on_service_disco_menuitem_activate(self, widget, account):
@ -1298,7 +1297,7 @@ class Roster_window:
u = self.contacts[account][data][0] u = self.contacts[account][data][0]
u.groups.remove(grp_source) u.groups.remove(grp_source)
u.groups.append(grp_dest) u.groups.append(grp_dest)
self.plugin.send('UPDUSER', account, (u.jid, u.name, u.groups)) gajim.connections[account].update_user(u.jid, u.name, u.groups)
if model.iter_n_children(iter_group_source) == 1: #this was the only child if model.iter_n_children(iter_group_source) == 1: #this was the only child
model.remove(iter_group_source) model.remove(iter_group_source)
#delete the group if it is empty (need to look for offline users too) #delete the group if it is empty (need to look for offline users too)

View file

@ -187,7 +187,7 @@ class Tabbed_chat_window(Chat):
keyID = '' keyID = ''
if self.xmls[jid].get_widget('gpg_togglebutton').get_active(): if self.xmls[jid].get_widget('gpg_togglebutton').get_active():
keyID = self.users[jid].keyID keyID = self.users[jid].keyID
self.plugin.send('MSG', self.account, (jid, message, keyID)) gajim.connections[self.account].send_message(jid, message, keyID)
message_buffer.set_text('', -1) message_buffer.set_text('', -1)
self.print_conversation(message, jid, jid) self.print_conversation(message, jid, jid)
return True return True