we can now send status (and connect) asynchronously thanks to threads
This commit is contained in:
parent
93bf5477b4
commit
3c10f30f1f
3 changed files with 15 additions and 4 deletions
|
@ -22,6 +22,7 @@ import os
|
||||||
import time
|
import time
|
||||||
import sre
|
import sre
|
||||||
import traceback
|
import traceback
|
||||||
|
import threading
|
||||||
from calendar import timegm
|
from calendar import timegm
|
||||||
|
|
||||||
import common.xmpp
|
import common.xmpp
|
||||||
|
@ -732,7 +733,14 @@ class Connection:
|
||||||
roster = self.connection.getRoster().getRaw()
|
roster = self.connection.getRoster().getRaw()
|
||||||
return roster
|
return roster
|
||||||
|
|
||||||
def change_status(self, show, msg):
|
def change_status(self, show, msg, sync = False):
|
||||||
|
if sync:
|
||||||
|
self.change_status2(show, msg)
|
||||||
|
else:
|
||||||
|
t = threading.Thread(target=self.change_status2, args = (show, msg))
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
def change_status2(self, show, msg):
|
||||||
if not show in STATUS_LIST:
|
if not show in STATUS_LIST:
|
||||||
return -1
|
return -1
|
||||||
sshow = show # show to be send
|
sshow = show # show to be send
|
||||||
|
|
|
@ -37,6 +37,7 @@ import os
|
||||||
import sre
|
import sre
|
||||||
import signal
|
import signal
|
||||||
import getopt
|
import getopt
|
||||||
|
import time
|
||||||
|
|
||||||
from common import i18n
|
from common import i18n
|
||||||
i18n.init()
|
i18n.init()
|
||||||
|
@ -763,6 +764,7 @@ class Interface:
|
||||||
for account in gajim.connections:
|
for account in gajim.connections:
|
||||||
if gajim.connections[account].connected:
|
if gajim.connections[account].connected:
|
||||||
gajim.connections[account].process(0.01)
|
gajim.connections[account].process(0.01)
|
||||||
|
time.sleep(0.01) # threads in connection.py have time to run
|
||||||
return True # renew timeout (loop for ever)
|
return True # renew timeout (loop for ever)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
|
@ -1075,7 +1075,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
|
||||||
del self.gpg_passphrase[keyid]
|
del self.gpg_passphrase[keyid]
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def send_status(self, account, status, txt):
|
def send_status(self, account, status, txt, sync = False):
|
||||||
if status != 'offline':
|
if status != 'offline':
|
||||||
if gajim.connections[account].connected < 2:
|
if gajim.connections[account].connected < 2:
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
|
@ -1136,7 +1136,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
|
||||||
gajim.config.set_per('accounts', account, 'gpgpassword',
|
gajim.config.set_per('accounts', account, 'gpgpassword',
|
||||||
passphrase)
|
passphrase)
|
||||||
gajim.connections[account].gpg_passphrase(passphrase)
|
gajim.connections[account].gpg_passphrase(passphrase)
|
||||||
gajim.connections[account].change_status(status, txt)
|
gajim.connections[account].change_status(status, txt, sync)
|
||||||
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]
|
||||||
|
@ -1443,7 +1443,8 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
|
||||||
return
|
return
|
||||||
for acct in accounts:
|
for acct in accounts:
|
||||||
if gajim.connections[acct].connected:
|
if gajim.connections[acct].connected:
|
||||||
self.send_status(acct, 'offline', message)
|
# send status asynchronously
|
||||||
|
self.send_status(acct, 'offline', message, True)
|
||||||
self.quit_gtkgui_plugin()
|
self.quit_gtkgui_plugin()
|
||||||
|
|
||||||
def on_roster_treeview_row_activated(self, widget, path, col = 0):
|
def on_roster_treeview_row_activated(self, widget, path, col = 0):
|
||||||
|
|
Loading…
Add table
Reference in a new issue