aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/main.py b/main.py
index ec3d0b6..ef51809 100755
--- a/main.py
+++ b/main.py
@@ -1,24 +1,36 @@
#!/usr/bin/env python3
from dial import DialManager, DialThread
-from phone import PhoneManager
+from hangup import HangUpThread
from time import sleep
from queue import Queue
+from threading import Event
if __name__ == "__main__":
queue = Queue()
- dial_thread = DialThread(queue)
- print("starting thread")
- dial_thread.start()
+ phone_held = Event()
+
+ # start phone as on hook
+ phone_held.clear()
+ dial_thread = DialThread(queue, phone_held)
+ print("starting dial thread")
+ dial_thread.start()
dial_manager = DialManager()
- phone_manager = PhoneManager()
+
+ hang_up_thread = HangUpThread(phone_held, dial_manager)
+ print("starting hang up thread")
+ hang_up_thread.start()
print("main loop")
while True:
- dialed = queue.get(block=True)
+ phone_held.wait()
+ try:
+ dialed = queue.get(block=True, timeout=0.1)
+ except:
+ continue
response = dial_manager.dial(dialed)
if response is not None:
- phone_manager.handle_event(response)
+ response.speak()