we can now send status (and connect) asynchronously thanks to threads
This commit is contained in:
parent
93bf5477b4
commit
3c10f30f1f
|
@ -22,6 +22,7 @@ import os
|
|||
import time
|
||||
import sre
|
||||
import traceback
|
||||
import threading
|
||||
from calendar import timegm
|
||||
|
||||
import common.xmpp
|
||||
|
@ -732,7 +733,14 @@ class Connection:
|
|||
roster = self.connection.getRoster().getRaw()
|
||||
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:
|
||||
return -1
|
||||
sshow = show # show to be send
|
||||
|
|
|
@ -37,6 +37,7 @@ import os
|
|||
import sre
|
||||
import signal
|
||||
import getopt
|
||||
import time
|
||||
|
||||
from common import i18n
|
||||
i18n.init()
|
||||
|
@ -763,6 +764,7 @@ class Interface:
|
|||
for account in gajim.connections:
|
||||
if gajim.connections[account].connected:
|
||||
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)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit()
|
||||
|
|
|
@ -1075,7 +1075,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
|
|||
del self.gpg_passphrase[keyid]
|
||||
return False
|
||||
|
||||
def send_status(self, account, status, txt):
|
||||
def send_status(self, account, status, txt, sync = False):
|
||||
if status != 'offline':
|
||||
if gajim.connections[account].connected < 2:
|
||||
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',
|
||||
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']:
|
||||
if room_jid != 'tabbed':
|
||||
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
|
||||
for acct in accounts:
|
||||
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()
|
||||
|
||||
def on_roster_treeview_row_activated(self, widget, path, col = 0):
|
||||
|
|
Loading…
Reference in New Issue