another status is possible: connecting
remove some ugly hack for autoconnection
This commit is contained in:
parent
ca71df0bf9
commit
02e112dab1
5 changed files with 32 additions and 61 deletions
|
@ -1214,7 +1214,7 @@ class Account_modification_window:
|
||||||
Warning_dialog(_('You must first create your account before editing your information'))
|
Warning_dialog(_('You must first create your account before editing your information'))
|
||||||
return
|
return
|
||||||
jid = self.xml.get_widget('jid_entry').get_text()
|
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'))
|
Warning_dialog(_('You must be connected to edit your information'))
|
||||||
return
|
return
|
||||||
if not self.plugin.windows[self.account]['infos'].has_key('vcard'):
|
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)
|
self.join_button.set_sensitive(True)
|
||||||
|
|
||||||
def __init__(self, plugin, account):
|
def __init__(self, plugin, account):
|
||||||
if not plugin.connected[account]:
|
if plugin.connected[account] < 2:
|
||||||
Warning_dialog(_("You must be connected to view Agents"))
|
Warning_dialog(_("You must be connected to view Agents"))
|
||||||
return
|
return
|
||||||
xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_browser_window', APP)
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_browser_window', APP)
|
||||||
|
|
|
@ -150,7 +150,7 @@ class vcard_information_window:
|
||||||
return vcard
|
return vcard
|
||||||
|
|
||||||
def on_publish_button_clicked(self, widget):
|
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"))
|
Warning_dialog(_("You must be connected to publish your informations"))
|
||||||
return
|
return
|
||||||
vcard = self.make_vcard()
|
vcard = self.make_vcard()
|
||||||
|
@ -163,7 +163,7 @@ class vcard_information_window:
|
||||||
self.plugin.send('VCARD', self.account, vcard)
|
self.plugin.send('VCARD', self.account, vcard)
|
||||||
|
|
||||||
def on_retrieve_button_clicked(self, widget):
|
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)
|
self.plugin.send('ASK_VCARD', self.account, self.jid)
|
||||||
else:
|
else:
|
||||||
Warning_dialog(_('You must be connected to get your informations'))
|
Warning_dialog(_('You must be connected to get your informations'))
|
||||||
|
@ -212,6 +212,8 @@ class Passphrase_dialog:
|
||||||
"""Class for Passphrase dialog"""
|
"""Class for Passphrase dialog"""
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Wait for OK button to be pressed and return passphrase/password"""
|
"""Wait for OK button to be pressed and return passphrase/password"""
|
||||||
|
if self.autoconnect:
|
||||||
|
gtk.gdk.threads_enter()
|
||||||
rep = self.window.run()
|
rep = self.window.run()
|
||||||
if rep == gtk.RESPONSE_OK:
|
if rep == gtk.RESPONSE_OK:
|
||||||
passphrase = self.passphrase_entry.get_text()
|
passphrase = self.passphrase_entry.get_text()
|
||||||
|
@ -220,36 +222,10 @@ class Passphrase_dialog:
|
||||||
save_passphrase_checkbutton = self.xml.\
|
save_passphrase_checkbutton = self.xml.\
|
||||||
get_widget('save_passphrase_checkbutton')
|
get_widget('save_passphrase_checkbutton')
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
if self.autoconnect:
|
||||||
|
gtk.gdk.threads_leave()
|
||||||
return passphrase, save_passphrase_checkbutton.get_active()
|
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):
|
def __init__(self, labeltext, checkbuttontext, autoconnect=0):
|
||||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'passphrase_dialog', APP)
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'passphrase_dialog', APP)
|
||||||
self.window = self.xml.get_widget('passphrase_dialog')
|
self.window = self.xml.get_widget('passphrase_dialog')
|
||||||
|
@ -411,7 +387,7 @@ class add_contact_window:
|
||||||
self.old_uid_value = uid.split('@')[0]
|
self.old_uid_value = uid.split('@')[0]
|
||||||
|
|
||||||
def __init__(self, plugin, account, jid=None):
|
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'))
|
Warning_dialog(_('You must be connected to add a contact'))
|
||||||
return
|
return
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
@ -587,7 +563,7 @@ class join_groupchat_window:
|
||||||
widget.get_toplevel().destroy()
|
widget.get_toplevel().destroy()
|
||||||
|
|
||||||
def __init__(self, plugin, account, server='', room = ''):
|
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'))
|
Warning_dialog(_('You must be connected to join a group chat'))
|
||||||
return
|
return
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
@ -631,7 +607,7 @@ class New_message_dialog:
|
||||||
widget.get_toplevel().destroy()
|
widget.get_toplevel().destroy()
|
||||||
|
|
||||||
def __init__(self, plugin, account):
|
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'))
|
Warning_dialog(_('You must be connected to send a message to a contact'))
|
||||||
return
|
return
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
@ -665,7 +641,7 @@ class Change_password_dialog:
|
||||||
return message
|
return message
|
||||||
|
|
||||||
def __init__(self, plugin, account):
|
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'))
|
Warning_dialog(_('You must be connected to change your password'))
|
||||||
return
|
return
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
|
|
@ -7567,8 +7567,6 @@ Custom</property>
|
||||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||||
<property name="has_separator">True</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">
|
<child internal-child="vbox">
|
||||||
<widget class="GtkVBox" id="dialog-vbox4">
|
<widget class="GtkVBox" id="dialog-vbox4">
|
||||||
|
@ -7591,7 +7589,6 @@ Custom</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<property name="focus_on_click">True</property>
|
<property name="focus_on_click">True</property>
|
||||||
<property name="response_id">-6</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>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
@ -7606,7 +7603,6 @@ Custom</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<property name="focus_on_click">True</property>
|
<property name="focus_on_click">True</property>
|
||||||
<property name="response_id">-5</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>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -831,7 +831,8 @@ class plugin:
|
||||||
for a in self.accounts.keys():
|
for a in self.accounts.keys():
|
||||||
self.windows[a] = {'infos': {}, 'chats': {}, 'gc': {}}
|
self.windows[a] = {'infos': {}, 'chats': {}, 'gc': {}}
|
||||||
self.queues[a] = {}
|
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.nicks[a] = self.accounts[a]['name']
|
||||||
self.sleeper_state[a] = 0 #0:don't use sleeper for this account
|
self.sleeper_state[a] = 0 #0:don't use sleeper for this account
|
||||||
#1:online and use sleeper
|
#1:online and use sleeper
|
||||||
|
@ -877,7 +878,7 @@ class plugin:
|
||||||
self.init_regex()
|
self.init_regex()
|
||||||
|
|
||||||
gtk.gdk.threads_enter()
|
gtk.gdk.threads_enter()
|
||||||
self.autoconnect()
|
gobject.timeout_add(100, self.autoconnect)
|
||||||
gtk.main()
|
gtk.main()
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,8 @@ class roster_window:
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
if self.get_account_iter(account):
|
if self.get_account_iter(account):
|
||||||
return
|
return
|
||||||
statuss = ['offline', 'online', 'away', 'xa', 'dnd', 'invisible']
|
statuss = ['offline', 'connecting', 'online', 'away', 'xa', 'dnd',\
|
||||||
|
'invisible']
|
||||||
status = statuss[self.plugin.connected[account]]
|
status = statuss[self.plugin.connected[account]]
|
||||||
model.append(None, (self.pixbufs[status], account, 'account', account,\
|
model.append(None, (self.pixbufs[status], account, 'account', account,\
|
||||||
account, False))
|
account, False))
|
||||||
|
@ -558,7 +559,7 @@ class roster_window:
|
||||||
item = gtk.MenuItem(_('_New message'))
|
item = gtk.MenuItem(_('_New message'))
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
item.connect("activate", self.on_new_message_menuitem_activate, account)
|
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)
|
item.set_sensitive(False)
|
||||||
|
|
||||||
menu.popup(None, None, None, event.button, event.time)
|
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):
|
def send_status(self, account, status, txt, autoconnect=0):
|
||||||
if status != 'offline':
|
if status != 'offline':
|
||||||
if not self.plugin.connected[account]:
|
if self.plugin.connected[account] < 2:
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
accountIter = self.get_account_iter(account)
|
accountIter = self.get_account_iter(account)
|
||||||
if accountIter:
|
if accountIter:
|
||||||
model.set_value(accountIter, 0, self.pixbufs['connecting'])
|
model.set_value(accountIter, 0, self.pixbufs['connecting'])
|
||||||
|
self.plugin.connected[account] = 1
|
||||||
self.plugin.systray.set_status('connecting')
|
self.plugin.systray.set_status('connecting')
|
||||||
|
|
||||||
save_pass = 0
|
save_pass = 0
|
||||||
if self.plugin.accounts[account].has_key('savepass'):
|
if self.plugin.accounts[account].has_key('savepass'):
|
||||||
save_pass = self.plugin.accounts[account]['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 = ''
|
passphrase = ''
|
||||||
w = Passphrase_dialog(_('Enter your password for account %s') \
|
w = Passphrase_dialog(_('Enter your password for account %s') \
|
||||||
% account, 'Save password', autoconnect)
|
% account, 'Save password', autoconnect)
|
||||||
if autoconnect:
|
passphrase, save = w.run()
|
||||||
gtk.main()
|
|
||||||
passphrase, save = w.get_pass()
|
|
||||||
else:
|
|
||||||
passphrase, save = w.run()
|
|
||||||
if passphrase == -1:
|
if passphrase == -1:
|
||||||
if accountIter:
|
if accountIter:
|
||||||
model.set_value(accountIter, 0, self.pixbufs['offline'])
|
model.set_value(accountIter, 0, self.pixbufs['offline'])
|
||||||
|
self.plugin.connected[account] = 0
|
||||||
|
self.plugin.systray.set_status('offline')
|
||||||
self.set_cb()
|
self.set_cb()
|
||||||
return
|
return
|
||||||
self.plugin.send('PASSPHRASE', account, passphrase)
|
self.plugin.send('PASSPHRASE', account, passphrase)
|
||||||
|
@ -697,7 +697,7 @@ class roster_window:
|
||||||
save_gpg_pass = self.plugin.accounts[account]['savegpgpass']
|
save_gpg_pass = self.plugin.accounts[account]['savegpgpass']
|
||||||
if self.plugin.accounts[account].has_key('keyid'):
|
if self.plugin.accounts[account].has_key('keyid'):
|
||||||
keyid = self.plugin.accounts[account]['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']:
|
self.plugin.config['usegpg']:
|
||||||
if save_gpg_pass:
|
if save_gpg_pass:
|
||||||
passphrase = self.plugin.accounts[account]['gpgpassword']
|
passphrase = self.plugin.accounts[account]['gpgpassword']
|
||||||
|
@ -706,11 +706,7 @@ class roster_window:
|
||||||
w = Passphrase_dialog(\
|
w = Passphrase_dialog(\
|
||||||
_('Enter GPG key passphrase for account %s') % account, \
|
_('Enter GPG key passphrase for account %s') % account, \
|
||||||
'Save passphrase', autoconnect)
|
'Save passphrase', autoconnect)
|
||||||
if autoconnect:
|
passphrase, save = w.run()
|
||||||
gtk.main()
|
|
||||||
passphrase, save = w.get_pass()
|
|
||||||
else:
|
|
||||||
passphrase, save = w.run()
|
|
||||||
if passphrase == -1:
|
if passphrase == -1:
|
||||||
passphrase = ''
|
passphrase = ''
|
||||||
if save:
|
if save:
|
||||||
|
@ -768,7 +764,7 @@ class roster_window:
|
||||||
|
|
||||||
def set_cb(self):
|
def set_cb(self):
|
||||||
#table to change index in plugin.connected to index in combobox
|
#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
|
maxi = 0
|
||||||
if len(self.plugin.connected.values()):
|
if len(self.plugin.connected.values()):
|
||||||
maxi = max(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.handler_block(self.id_signal_cb)
|
||||||
self.cb.set_active(table[maxi])
|
self.cb.set_active(table[maxi])
|
||||||
self.cb.handler_unblock(self.id_signal_cb)
|
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])
|
self.plugin.systray.set_status(statuss[maxi])
|
||||||
image = self.pixbufs[statuss[maxi]]
|
image = self.pixbufs[statuss[maxi]]
|
||||||
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
||||||
|
@ -794,7 +791,8 @@ class roster_window:
|
||||||
accountIter = self.get_account_iter(account)
|
accountIter = self.get_account_iter(account)
|
||||||
if accountIter:
|
if accountIter:
|
||||||
model.set_value(accountIter, 0, self.pixbufs[status])
|
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':
|
if status == 'offline':
|
||||||
for jid in self.contacts[account]:
|
for jid in self.contacts[account]:
|
||||||
luser = self.contacts[account][jid]
|
luser = self.contacts[account][jid]
|
||||||
|
@ -848,7 +846,7 @@ class roster_window:
|
||||||
autopopup = self.plugin.config['autopopup']
|
autopopup = self.plugin.config['autopopup']
|
||||||
autopopupaway = self.plugin.config['autopopupaway']
|
autopopupaway = self.plugin.config['autopopupaway']
|
||||||
if (autopopup == 0 or ( not autopopupaway and \
|
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):
|
self.plugin.windows[account]['chats'].has_key(jid):
|
||||||
#We save it in a queue
|
#We save it in a queue
|
||||||
if not self.plugin.queues[account].has_key(jid):
|
if not self.plugin.queues[account].has_key(jid):
|
||||||
|
|
Loading…
Add table
Reference in a new issue