we can now register to a transport in add contact window is server has such a transport. Fixes #1944

This commit is contained in:
Yann Leboulanger 2006-07-31 17:08:21 +00:00
parent 1c9b21d9d8
commit 57aeb0d0ef
5 changed files with 54 additions and 1 deletions

View File

@ -19,6 +19,7 @@
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<signal name="key_press_event" handler="on_add_new_contact_window_key_press_event" last_modification_time="Thu, 28 Apr 2005 12:59:51 GMT"/>
<signal name="destroy" handler="on_add_new_contact_window_destroy" last_modification_time="Mon, 31 Jul 2006 16:45:22 GMT"/>
<child>
<widget class="GtkVBox" id="vbox8">

View File

@ -85,6 +85,8 @@ class Connection(ConnectionHandlers):
self.retrycount = 0
self.jids_for_auto_auth = [] # list of jid to auto-authorize
self.muc_jid = None
self.available_transports = {} # list of available transports on this
# server {'icq': 'icq.server.com', }
self.vcard_supported = True
# END __init__

View File

@ -755,6 +755,8 @@ class ConnectionDisco:
gajim.proxy65_manager.resolve(jid, self.connection, self.name)
if features.__contains__(common.xmpp.NS_MUC) and is_muc:
self.muc_jid = jid
if transport_type:
self.available_transports[transport_type] = jid
self.dispatch('AGENT_INFO_INFO', (jid, node, identities,
features, data))

View File

@ -413,6 +413,15 @@ class AddNewContactWindow:
self.account = account
else:
accounts = [self.account]
if self.account:
location = gajim.interface.instances[self.account]
else:
location = gajim.interface.instances
if location.has_key('add_contact'):
location['add_contact'].window.present()
# An instance is already opened
return
location['add_contact'] = self
self.xml = gtkgui_helpers.get_glade('add_new_contact_window.glade')
self.account_combobox = self.xml.get_widget('account_combobox')
self.account_hbox = self.xml.get_widget('account_hbox')
@ -450,7 +459,11 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
widget = self.xml.get_widget(type_ + '_register_form')
widget.set_no_show_all(True)
widget.hide()
#TODO: make button sensitive if we can register and add callback
if type_ in gajim.connections[self.account].available_transports:
widget = self.xml.get_widget(type_ + '_register_button')
widget.set_sensitive(True)
widget.connect('clicked', self.on_register_button_clicked,
gajim.connections[self.account].available_transports[type_])
if jid:
type_ = gajim.get_transport_name_from_jid(jid)
@ -489,6 +502,16 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
self.xml.signal_autoconnect(self)
self.window.show_all()
def on_add_new_contact_window_destroy(self, widget):
if self.account:
location = gajim.interface.instances[self.account]
else:
location = gajim.interface.instances
del location['add_contact']
def on_register_button_clicked(self, widget, jid):
gajim.connections[self.account].request_register_agent_info(jid)
def on_add_new_contact_window_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape: # ESCAPE
self.window.destroy()
@ -558,6 +581,22 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
group = group, pseudo = nickname, auto_auth = auto_auth)
self.window.destroy()
def transport_signed_in(self, jid):
type_ = gajim.get_transport_name_from_jid(jid)
self.xml.get_widget(type_ + '_register_button').hide()
self.agents[type_] = jid
widget = self.xml.get_widget(type_ + '_register_form')
widget.set_no_show_all(False)
widget.show_all()
def transport_signed_out(self, jid):
type_ = gajim.get_transport_name_from_jid(jid)
widget = self.xml.get_widget(type_ + '_register_button')
widget.set_no_show_all(False)
widget.show_all()
del self.agents[type_]
self.xml.get_widget(type_ + '_register_form').hide()
class AboutDialog:
'''Class for about dialog'''
def __init__(self):

View File

@ -439,6 +439,15 @@ class Interface:
gajim.block_signed_in_notifications[account_ji] = True
gobject.timeout_add(30000, self.unblock_signed_in_notifications,
account_ji)
locations = (self.instances, self.instances[account])
for location in locations:
if location.has_key('add_contact'):
if old_show == 0 and new_show > 1:
location['add_contact'].transport_signed_in(jid)
break
elif old_show > 1 and new_show == 0:
location['add_contact'].transport_signed_out(jid)
break
elif ji in jid_list:
# It isn't an agent
# reset chatstate if needed: