correctly show the result of an account creation (success / fail)
This commit is contained in:
parent
ca05945f63
commit
febe8d4a1a
|
@ -1402,8 +1402,9 @@ class Connection:
|
|||
else:
|
||||
gajim.config.set('usegpg', False)
|
||||
gajim.connections[self.name] = self
|
||||
self.dispatch('ACC_OK', (self.name, self.new_account_info))
|
||||
self.dispatch('ACC_OK', (self.new_account_info))
|
||||
self.new_account_info = None
|
||||
self.connection = None
|
||||
return
|
||||
is_form = data[2]
|
||||
if is_form:
|
||||
|
|
137
src/config.py
137
src/config.py
|
@ -2434,10 +2434,13 @@ class AccountCreationWizardWindow:
|
|||
|
||||
# Generic widgets
|
||||
self.notebook = self.xml.get_widget('notebook')
|
||||
self.cancel_button = self.xml.get_widget('cancel_button')
|
||||
self.back_button = self.xml.get_widget('back_button')
|
||||
self.forward_button = self.xml.get_widget('forward_button')
|
||||
self.finish_button = self.xml.get_widget('finish_button')
|
||||
self.advanced_button = self.xml.get_widget('advanced_button')
|
||||
self.finish_label = self.xml.get_widget('finish_label')
|
||||
self.go_online_checkbutton = self.xml.get_widget('go_online_checkbutton')
|
||||
|
||||
# Some vars
|
||||
self.sync = False
|
||||
|
@ -2453,6 +2456,7 @@ class AccountCreationWizardWindow:
|
|||
self.account = _('Main') + str(i)
|
||||
i += 1
|
||||
|
||||
self.notebook.set_current_page(0)
|
||||
self.advanced_button.set_no_show_all(True)
|
||||
self.xml.signal_autoconnect(self)
|
||||
self.window.show_all()
|
||||
|
@ -2472,7 +2476,10 @@ class AccountCreationWizardWindow:
|
|||
def on_back_button_clicked(self, widget):
|
||||
if self.notebook.get_current_page() == 1:
|
||||
self.notebook.set_current_page(0)
|
||||
self.back_button.set_sensitive(False)
|
||||
self.back_button.set_sensitive(False)
|
||||
elif self.notebook.get_current_page() == 3: # finish page
|
||||
self.forward_button.show()
|
||||
self.notebook.set_current_page(1) # Goto parameters page
|
||||
|
||||
def get_widgets(self):
|
||||
widgets = {}
|
||||
|
@ -2505,15 +2512,6 @@ class AccountCreationWizardWindow:
|
|||
return
|
||||
|
||||
else:
|
||||
if self.modify:
|
||||
#FIXME: pango me
|
||||
finish_text = _('Account has been added successfully.\n'
|
||||
'You can set advanced account options by pressing Advanced button,\nor later by clicking in Accounts menuitem under Edit menu from the main window.')
|
||||
else:
|
||||
#FIXME: pango me
|
||||
finish_text = _('Your new account has been created successfully.\n'
|
||||
'You can set advanced account options by pressing Advanced button,\nor later by clicking in Accounts menuitem under Edit menu from the main window.')
|
||||
|
||||
widgets = self.get_widgets()
|
||||
username = widgets['nick_entry'].get_text().decode('utf-8')
|
||||
if not username:
|
||||
|
@ -2540,15 +2538,53 @@ class AccountCreationWizardWindow:
|
|||
return
|
||||
|
||||
username, server = gajim.get_room_name_and_server_from_room_jid(jid)
|
||||
self.save_account(self.account, username, server, savepass, password)
|
||||
self.finish_label.set_text(finish_text)
|
||||
self.xml.get_widget('cancel_button').hide()
|
||||
self.save_account(username, server, savepass, password)
|
||||
self.cancel_button.hide()
|
||||
self.back_button.hide()
|
||||
self.xml.get_widget('forward_button').hide()
|
||||
self.finish_button.set_sensitive(True)
|
||||
self.finish_button.set_property('has-default', True)
|
||||
self.advanced_button.show()
|
||||
self.notebook.set_current_page(2) # show finish page
|
||||
self.forward_button.hide()
|
||||
if self.modify:
|
||||
#FIXME: pango me
|
||||
finish_text = _('Account has been added successfully.\n'
|
||||
'You can set advanced account options by pressing Advanced button,\nor later by clicking in Accounts menuitem under Edit menu from the main window.')
|
||||
self.finish_label.set_text(finish_text)
|
||||
self.finish_button.set_sensitive(True)
|
||||
self.finish_button.set_property('has-default', True)
|
||||
self.advanced_button.show()
|
||||
self.go_online_checkbutton.show()
|
||||
img = self.xml.get_widget('finish_image')
|
||||
img.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_DIALOG)
|
||||
self.notebook.set_current_page(3) # show finish page
|
||||
else:
|
||||
self.notebook.set_current_page(2) # show creqting page
|
||||
|
||||
def acc_is_ok(self, config):
|
||||
'''Account creation succeeded'''
|
||||
con = gajim.connections[self.account]
|
||||
gajim.interface.register_handlers(con)
|
||||
self.create_vars(config)
|
||||
self.finish_button.set_sensitive(True)
|
||||
self.finish_button.set_property('has-default', True)
|
||||
self.advanced_button.show()
|
||||
self.go_online_checkbutton.show()
|
||||
img = self.xml.get_widget('finish_image')
|
||||
img.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_DIALOG)
|
||||
#FIXME: pango me
|
||||
finish_text = _('Your new account has been created successfully.\n'
|
||||
'You can set advanced account options by pressing Advanced button,\nor later by clicking in Accounts menuitem under Edit menu from the main window.')
|
||||
self.finish_label.set_text(finish_text)
|
||||
self.notebook.set_current_page(3) # show finish page
|
||||
|
||||
def acc_is_not_ok(self, reason):
|
||||
'''Account creation failed'''
|
||||
self.back_button.show()
|
||||
self.cancel_button.show()
|
||||
self.go_online_checkbutton.hide()
|
||||
img = self.xml.get_widget('finish_image')
|
||||
img.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG)
|
||||
#FIXME: pango me
|
||||
finish_text = _('An error occured during account creation:\n') + reason
|
||||
self.finish_label.set_text(finish_text)
|
||||
self.notebook.set_current_page(3) # show finish page
|
||||
|
||||
def on_advanced_button_clicked(self, widget):
|
||||
gajim.interface.windows[self.account]['account_modification'] = \
|
||||
|
@ -2556,7 +2592,7 @@ class AccountCreationWizardWindow:
|
|||
self.window.destroy()
|
||||
|
||||
def on_finish_button_clicked(self, widget):
|
||||
go_online = self.xml.get_widget('go_online_checkbutton')
|
||||
go_online = self.xml.get_widget('go_online_checkbutton').get_active()
|
||||
self.window.destroy()
|
||||
if go_online:
|
||||
gajim.interface.roster.send_status(self.account, 'online', '')
|
||||
|
@ -2598,7 +2634,7 @@ class AccountCreationWizardWindow:
|
|||
string = '<span background="lightyellow">%s@%s</span>' % (name, server)
|
||||
jid_label.set_label(string)
|
||||
|
||||
def save_account(self, name, login, server, savepass, password):
|
||||
def save_account(self, login, server, savepass, password):
|
||||
config = {}
|
||||
config['name'] = login
|
||||
config['hostname'] = server
|
||||
|
@ -2619,43 +2655,44 @@ class AccountCreationWizardWindow:
|
|||
config['savegpgpass'] = False
|
||||
config['gpgpassword'] = ''
|
||||
|
||||
if name in gajim.connections:
|
||||
if self.account in gajim.connections:
|
||||
dialogs.ErrorDialog(_('Account name is in use'),
|
||||
_('You already have an account using this name.')).get_response()
|
||||
return
|
||||
con = connection.Connection(name)
|
||||
gajim.interface.register_handlers(con)
|
||||
con = connection.Connection(self.account)
|
||||
gajim.events_for_ui[self.account] = []
|
||||
if not self.modify:
|
||||
gajim.events_for_ui[name] = []
|
||||
con.new_account(name, config)
|
||||
con.new_account(self.account, config)
|
||||
return
|
||||
# The account we add already exists on the server
|
||||
gajim.connections[name] = con
|
||||
gajim.config.add_per('accounts', name)
|
||||
gajim.connections[self.account] = con
|
||||
gajim.interface.register_handlers(con)
|
||||
self.create_vars(config)
|
||||
|
||||
def create_vars(self, config):
|
||||
gajim.config.add_per('accounts', self.account)
|
||||
for opt in config:
|
||||
gajim.config.set_per('accounts', name, opt, config[opt])
|
||||
if config['savepass']:
|
||||
gajim.connections[name].password = config['password']
|
||||
gajim.config.set_per('accounts', self.account, opt, config[opt])
|
||||
|
||||
# update variables
|
||||
gajim.interface.windows[name] = {'infos': {}, 'disco': {}, 'chats': {},
|
||||
'gc': {}, 'gc_config': {}}
|
||||
gajim.interface.windows[name]['xml_console'] = \
|
||||
dialogs.XMLConsoleWindow(name)
|
||||
gajim.awaiting_events[name] = {}
|
||||
gajim.connections[name].connected = 0
|
||||
gajim.groups[name] = {}
|
||||
gajim.contacts[name] = {}
|
||||
gajim.gc_contacts[name] = {}
|
||||
gajim.gc_connected[name] = {}
|
||||
gajim.newly_added[name] = []
|
||||
gajim.to_be_removed[name] = []
|
||||
gajim.nicks[name] = config['name']
|
||||
gajim.allow_notifications[name] = False
|
||||
gajim.sleeper_state[name] = 'off'
|
||||
gajim.encrypted_chats[name] = []
|
||||
gajim.last_message_time[name] = {}
|
||||
gajim.status_before_autoaway[name] = ''
|
||||
gajim.events_for_ui[name] = []
|
||||
gajim.interface.windows[self.account] = {'infos': {}, 'disco': {},
|
||||
'chats': {}, 'gc': {}, 'gc_config': {}}
|
||||
gajim.interface.windows[self.account]['xml_console'] = \
|
||||
dialogs.XMLConsoleWindow(self.account)
|
||||
gajim.awaiting_events[self.account] = {}
|
||||
gajim.connections[self.account].connected = 0
|
||||
gajim.groups[self.account] = {}
|
||||
gajim.contacts[self.account] = {}
|
||||
gajim.gc_contacts[self.account] = {}
|
||||
gajim.gc_connected[self.account] = {}
|
||||
gajim.newly_added[self.account] = []
|
||||
gajim.to_be_removed[self.account] = []
|
||||
gajim.nicks[self.account] = config['name']
|
||||
gajim.allow_notifications[self.account] = False
|
||||
gajim.sleeper_state[self.account] = 'off'
|
||||
gajim.encrypted_chats[self.account] = []
|
||||
gajim.last_message_time[self.account] = {}
|
||||
gajim.status_before_autoaway[self.account] = ''
|
||||
gajim.events_for_ui[self.account] = []
|
||||
# refresh accounts window
|
||||
if gajim.interface.windows.has_key('accounts'):
|
||||
gajim.interface.windows['accounts'].init_accounts()
|
||||
|
|
42
src/gajim.py
42
src/gajim.py
|
@ -607,41 +607,18 @@ class Interface:
|
|||
return
|
||||
|
||||
def handle_event_acc_ok(self, account, array):
|
||||
#('ACC_OK', account, (name, config))
|
||||
name = array[0]
|
||||
dialogs.InformationDialog(_('Account registration successful'),
|
||||
_('The account "%s" has been registered with the Jabber server.') % name)
|
||||
gajim.config.add_per('accounts', name)
|
||||
for opt in array[1]:
|
||||
gajim.config.set_per('accounts', name, opt, array[1][opt])
|
||||
self.windows[name] = {'infos': {}, 'disco': {}, 'chats': {},
|
||||
'gc': {}, 'gc_config': {}}
|
||||
self.windows[name]['xml_console'] = dialogs.XMLConsoleWindow(name)
|
||||
gajim.awaiting_events[name] = {}
|
||||
# disconnect from server - our status in roster is offline
|
||||
gajim.connections[name].connected = 1
|
||||
gajim.gc_contacts[name] = {}
|
||||
gajim.gc_connected[name] = {}
|
||||
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] = 'off'
|
||||
gajim.encrypted_chats[name] = []
|
||||
gajim.last_message_time[name] = {}
|
||||
gajim.status_before_autoaway[name] = ''
|
||||
gajim.events_for_ui[name] = []
|
||||
gajim.connections[name].change_status('offline', None, True)
|
||||
gajim.connections[name].connected = 0
|
||||
if self.windows.has_key('accounts'):
|
||||
self.windows['accounts'].init_accounts()
|
||||
self.roster.draw_roster()
|
||||
|
||||
#('ACC_OK', account, (config))
|
||||
if self.windows.has_key('account_creation_wizard'):
|
||||
self.windows['account_creation_wizard'].acc_is_ok(array)
|
||||
|
||||
if self.remote and self.remote.is_enabled():
|
||||
self.remote.raise_signal('NewAccount', (account, array))
|
||||
|
||||
def handle_event_acc_not_ok(self, account, array):
|
||||
#('ACC_NOT_OK', account, (reason))
|
||||
if self.windows.has_key('account_creation_wizard'):
|
||||
self.windows['account_creation_wizard'].acc_is_not_ok(array)
|
||||
|
||||
def handle_event_quit(self, p1, p2):
|
||||
self.roster.quit_gtkgui_interface()
|
||||
|
||||
|
@ -1144,6 +1121,7 @@ class Interface:
|
|||
'AGENT_INFO_INFO': self.handle_event_agent_info_info,
|
||||
'QUIT': self.handle_event_quit,
|
||||
'ACC_OK': self.handle_event_acc_ok,
|
||||
'ACC_NOT_OK': self.handle_event_acc_not_ok,
|
||||
'MYVCARD': self.handle_event_myvcard,
|
||||
'VCARD': self.handle_event_vcard,
|
||||
'OS_INFO': self.handle_event_os_info,
|
||||
|
|
|
@ -14257,6 +14257,82 @@ to the Jabber network.</property>
|
|||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox104">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label366">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Account is being created
|
||||
Please wait.</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkProgressBar" id="progressbar1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
|
||||
<property name="fraction">0</property>
|
||||
<property name="pulse_step">0.10000000149</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label365">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox103">
|
||||
<property name="visible">True</property>
|
||||
|
@ -14270,10 +14346,8 @@ to the Jabber network.</property>
|
|||
<property name="spacing">12</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image942">
|
||||
<widget class="GtkImage" id="finish_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-apply</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
|
|
Loading…
Reference in New Issue