summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/core/handlers.py16
-rw-r--r--poezio/tabs/confirmtab.py2
2 files changed, 8 insertions, 10 deletions
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index 3ce71af6..d56f451c 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -8,6 +8,7 @@ log = logging.getLogger(__name__)
import asyncio
import curses
import functools
+import select
import ssl
import sys
import time
@@ -1235,8 +1236,6 @@ class HandlerCore:
self.core.information('You refused to validate the certificate.'
' You are now disconnected.', 'Info')
self.core.disconnect()
- new_loop.stop()
- asyncio.set_event_loop(old_loop)
confirm_tab = tabs.ConfirmTab(self.core,
'Certificate check required',
@@ -1248,14 +1247,11 @@ class HandlerCore:
self.core.add_tab(confirm_tab, True)
self.core.doupdate()
- # some magic to avoid running the event loop in which slixmpp
- # does stuff. FIXME: not perfect.
- old_loop = asyncio.get_event_loop()
- new_loop = asyncio.new_event_loop()
- asyncio.set_event_loop(new_loop)
- new_loop.add_reader(sys.stdin, self.core.on_input_readable)
- curses.beep()
- new_loop.run_forever()
+ while not confirm_tab.done:
+ sel = select.select([sys.stdin], [], [], 5)[0]
+
+ if sel:
+ self.core.on_input_readable()
def validate_ssl(self, pem):
"""
diff --git a/poezio/tabs/confirmtab.py b/poezio/tabs/confirmtab.py
index 49339fce..39f630cb 100644
--- a/poezio/tabs/confirmtab.py
+++ b/poezio/tabs/confirmtab.py
@@ -40,6 +40,7 @@ class ConfirmTab(Tab):
self.update_keys()
self.update_commands()
self.completion_callback = callback
+ self.done = False
def toggle_choice(self):
self.dialog.toggle_choice()
@@ -81,6 +82,7 @@ class ConfirmTab(Tab):
self.input.resize(1, self.width, self.height-1, 0)
def close(self, arg=None):
+ self.done = True
self.core.close_tab(self)
def on_input(self, key, raw):