another status is possible: connecting

remove some ugly hack for autoconnection
This commit is contained in:
Yann Leboulanger 2005-03-15 10:20:10 +00:00
parent ca71df0bf9
commit 02e112dab1
5 changed files with 32 additions and 61 deletions

View File

@ -1214,7 +1214,7 @@ class Account_modification_window:
Warning_dialog(_('You must first create your account before editing your information'))
return
jid = self.xml.get_widget('jid_entry').get_text()
if not self.plugin.connected[self.account]:
if self.plugin.connected[self.account] < 2:
Warning_dialog(_('You must be connected to edit your information'))
return
if not self.plugin.windows[self.account]['infos'].has_key('vcard'):
@ -1555,7 +1555,7 @@ class agent_browser_window:
self.join_button.set_sensitive(True)
def __init__(self, plugin, account):
if not plugin.connected[account]:
if plugin.connected[account] < 2:
Warning_dialog(_("You must be connected to view Agents"))
return
xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_browser_window', APP)

View File

@ -150,7 +150,7 @@ class vcard_information_window:
return vcard
def on_publish_button_clicked(self, widget):
if not self.plugin.connected[self.account]:
if self.plugin.connected[self.account] < 2:
Warning_dialog(_("You must be connected to publish your informations"))
return
vcard = self.make_vcard()
@ -163,7 +163,7 @@ class vcard_information_window:
self.plugin.send('VCARD', self.account, vcard)
def on_retrieve_button_clicked(self, widget):
if self.plugin.connected[self.account]:
if self.plugin.connected[self.account] > 1:
self.plugin.send('ASK_VCARD', self.account, self.jid)
else:
Warning_dialog(_('You must be connected to get your informations'))
@ -212,6 +212,8 @@ class Passphrase_dialog:
"""Class for Passphrase dialog"""
def run(self):
"""Wait for OK button to be pressed and return passphrase/password"""
if self.autoconnect:
gtk.gdk.threads_enter()
rep = self.window.run()
if rep == gtk.RESPONSE_OK:
passphrase = self.passphrase_entry.get_text()
@ -220,36 +222,10 @@ class Passphrase_dialog:
save_passphrase_checkbutton = self.xml.\
get_widget('save_passphrase_checkbutton')
self.window.destroy()
if self.autoconnect:
gtk.gdk.threads_leave()
return passphrase, save_passphrase_checkbutton.get_active()
def on_passphrase_dialog_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Return:
if self.autoconnect:
self.on_ok_button_clicked(widget)
else:
self.window.response(gtk.RESPONSE_OK)
def on_ok_button_clicked(self, widget):
if self.autoconnect:
self.passphrase = self.passphrase_entry.get_text()
gtk.main_quit()
def on_cancel_button_clicked(self, widget):
if self.autoconnect:
gtk.main_quit()
def get_pass(self):
self.autoconnect = 0
save_passphrase_checkbutton = self.xml.\
get_widget('save_passphrase_checkbutton')
self.window.destroy()
return self.passphrase, save_passphrase_checkbutton.get_active()
def on_passphrase_dialog_destroy(self, widget=None):
"""close window"""
if self.autoconnect:
gtk.main_quit()
def __init__(self, labeltext, checkbuttontext, autoconnect=0):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'passphrase_dialog', APP)
self.window = self.xml.get_widget('passphrase_dialog')
@ -411,7 +387,7 @@ class add_contact_window:
self.old_uid_value = uid.split('@')[0]
def __init__(self, plugin, account, jid=None):
if not plugin.connected[account]:
if plugin.connected[account] < 2:
Warning_dialog(_('You must be connected to add a contact'))
return
self.plugin = plugin
@ -587,7 +563,7 @@ class join_groupchat_window:
widget.get_toplevel().destroy()
def __init__(self, plugin, account, server='', room = ''):
if not plugin.connected[account]:
if plugin.connected[account] < 2:
Warning_dialog(_('You must be connected to join a group chat'))
return
self.plugin = plugin
@ -631,7 +607,7 @@ class New_message_dialog:
widget.get_toplevel().destroy()
def __init__(self, plugin, account):
if not plugin.connected[account]:
if plugin.connected[account] < 2:
Warning_dialog(_('You must be connected to send a message to a contact'))
return
self.plugin = plugin
@ -665,7 +641,7 @@ class Change_password_dialog:
return message
def __init__(self, plugin, account):
if not plugin.connected[account]:
if plugin.connected[account] < 2:
Warning_dialog(_('You must be connected to change your password'))
return
self.plugin = plugin

View File

@ -7567,8 +7567,6 @@ Custom</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">True</property>
<signal name="key_press_event" handler="on_passphrase_dialog_key_press_event" last_modification_time="Wed, 02 Mar 2005 10:37:49 GMT"/>
<signal name="destroy" handler="on_passphrase_dialog_destroy" last_modification_time="Wed, 02 Mar 2005 10:36:32 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox4">
@ -7591,7 +7589,6 @@ Custom</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Wed, 02 Mar 2005 10:33:28 GMT"/>
</widget>
</child>
@ -7606,7 +7603,6 @@ Custom</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<signal name="clicked" handler="on_ok_button_clicked" last_modification_time="Wed, 02 Mar 2005 10:33:19 GMT"/>
</widget>
</child>
</widget>

View File

@ -831,7 +831,8 @@ class plugin:
for a in self.accounts.keys():
self.windows[a] = {'infos': {}, 'chats': {}, 'gc': {}}
self.queues[a] = {}
self.connected[a] = 0
self.connected[a] = 0 #0->offline 1->connecting 2->online 3->away
#4->xa 5->dnd 6->invisible
self.nicks[a] = self.accounts[a]['name']
self.sleeper_state[a] = 0 #0:don't use sleeper for this account
#1:online and use sleeper
@ -877,7 +878,7 @@ class plugin:
self.init_regex()
gtk.gdk.threads_enter()
self.autoconnect()
gobject.timeout_add(100, self.autoconnect)
gtk.main()
gtk.gdk.threads_leave()

View File

@ -108,7 +108,8 @@ class roster_window:
model = self.tree.get_model()
if self.get_account_iter(account):
return
statuss = ['offline', 'online', 'away', 'xa', 'dnd', 'invisible']
statuss = ['offline', 'connecting', 'online', 'away', 'xa', 'dnd',\
'invisible']
status = statuss[self.plugin.connected[account]]
model.append(None, (self.pixbufs[status], account, 'account', account,\
account, False))
@ -558,7 +559,7 @@ class roster_window:
item = gtk.MenuItem(_('_New message'))
menu.append(item)
item.connect("activate", self.on_new_message_menuitem_activate, account)
if not self.plugin.connected[account]:
if self.plugin.connected[account] < 2:
item.set_sensitive(False)
menu.popup(None, None, None, event.button, event.time)
@ -662,28 +663,27 @@ class roster_window:
def send_status(self, account, status, txt, autoconnect=0):
if status != 'offline':
if not self.plugin.connected[account]:
if self.plugin.connected[account] < 2:
model = self.tree.get_model()
accountIter = self.get_account_iter(account)
if accountIter:
model.set_value(accountIter, 0, self.pixbufs['connecting'])
self.plugin.connected[account] = 1
self.plugin.systray.set_status('connecting')
save_pass = 0
if self.plugin.accounts[account].has_key('savepass'):
save_pass = self.plugin.accounts[account]['savepass']
if not save_pass and not self.plugin.connected[account]:
if not save_pass and self.plugin.connected[account] < 2:
passphrase = ''
w = Passphrase_dialog(_('Enter your password for account %s') \
% account, 'Save password', autoconnect)
if autoconnect:
gtk.main()
passphrase, save = w.get_pass()
else:
passphrase, save = w.run()
passphrase, save = w.run()
if passphrase == -1:
if accountIter:
model.set_value(accountIter, 0, self.pixbufs['offline'])
self.plugin.connected[account] = 0
self.plugin.systray.set_status('offline')
self.set_cb()
return
self.plugin.send('PASSPHRASE', account, passphrase)
@ -697,7 +697,7 @@ class roster_window:
save_gpg_pass = self.plugin.accounts[account]['savegpgpass']
if self.plugin.accounts[account].has_key('keyid'):
keyid = self.plugin.accounts[account]['keyid']
if keyid and not self.plugin.connected[account] and \
if keyid and self.plugin.connected[account] < 2 and \
self.plugin.config['usegpg']:
if save_gpg_pass:
passphrase = self.plugin.accounts[account]['gpgpassword']
@ -706,11 +706,7 @@ class roster_window:
w = Passphrase_dialog(\
_('Enter GPG key passphrase for account %s') % account, \
'Save passphrase', autoconnect)
if autoconnect:
gtk.main()
passphrase, save = w.get_pass()
else:
passphrase, save = w.run()
passphrase, save = w.run()
if passphrase == -1:
passphrase = ''
if save:
@ -768,7 +764,7 @@ class roster_window:
def set_cb(self):
#table to change index in plugin.connected to index in combobox
table = {0:5, 1:0, 2:1, 3:2, 4:3, 5:4}
table = {0:5, 1:5, 2:0, 3:1, 4:2, 5:3, 6:4}
maxi = 0
if len(self.plugin.connected.values()):
maxi = max(self.plugin.connected.values())
@ -777,7 +773,8 @@ class roster_window:
self.cb.handler_block(self.id_signal_cb)
self.cb.set_active(table[maxi])
self.cb.handler_unblock(self.id_signal_cb)
statuss = ['offline', 'online', 'away', 'xa', 'dnd', 'invisible']
statuss = ['offline', 'connecting', 'online', 'away', 'xa', 'dnd',\
'invisible']
self.plugin.systray.set_status(statuss[maxi])
image = self.pixbufs[statuss[maxi]]
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
@ -794,7 +791,8 @@ class roster_window:
accountIter = self.get_account_iter(account)
if accountIter:
model.set_value(accountIter, 0, self.pixbufs[status])
statuss = ['offline', 'online', 'away', 'xa', 'dnd', 'invisible']
statuss = ['offline', 'connecting', 'online', 'away', 'xa', 'dnd',\
'invisible']
if status == 'offline':
for jid in self.contacts[account]:
luser = self.contacts[account][jid]
@ -848,7 +846,7 @@ class roster_window:
autopopup = self.plugin.config['autopopup']
autopopupaway = self.plugin.config['autopopupaway']
if (autopopup == 0 or ( not autopopupaway and \
self.plugin.connected[account] > 1)) and not \
self.plugin.connected[account] > 2)) and not \
self.plugin.windows[account]['chats'].has_key(jid):
#We save it in a queue
if not self.plugin.queues[account].has_key(jid):