Improving support for a worker thread and moving more code over to it
[theonering] / src / channel / call.py
index 2d3af62..0fd08ea 100644 (file)
@@ -104,7 +104,7 @@ class CallChannel(
                self.remove_from_connection()
 
                if self.__calledNumber is not None:
-                       le = gobject_utils.LinearExecution(self._cancel)
+                       le = gobject_utils.AsyncLinearExecution(self._conn.session.pool, self._cancel)
                        le.start()
 
        @misc_utils.log_exception(_moduleLogger)
@@ -163,7 +163,7 @@ class CallChannel(
                contact = self._conn.get_handle_by_id(telepathy.constants.HANDLE_TYPE_CONTACT, contactId)
                assert self.__contactHandle == contact, "%r != %r" % (self.__contactHandle, contact)
 
-               le = gobject_utils.LinearExecution(self._call)
+               le = gobject_utils.AsyncLinearExecution(self._conn.session.pool, self._call)
                le.start(contact)
 
                streamId = 0
@@ -172,20 +172,19 @@ class CallChannel(
                pendingSendFlags = telepathy.constants.MEDIA_STREAM_PENDING_REMOTE_SEND
                return [(streamId, contact, streamTypes[0], streamState, streamDirection, pendingSendFlags)]
 
-       def _call(self, contact, on_success, on_error):
+       @misc_utils.log_exception(_moduleLogger)
+       def _call(self, contact):
                contactNumber = contact.phoneNumber
 
                self.__calledNumber = contactNumber
                self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING)
 
                try:
-                       result = yield self._conn.session.pool.add_task, (
+                       result = yield (
                                self._conn.session.backend.call,
                                (contactNumber, ),
                                {},
-                               on_success,
-                               on_error,
-                       ), {}
+                       )
                except Exception:
                        _moduleLogger.exception(result)
                        return
@@ -193,16 +192,15 @@ class CallChannel(
                self._delayedClose.start(seconds=0)
                self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED)
 
-       def _cancel(self, on_success, on_error):
+       @misc_utils.log_exception(_moduleLogger)
+       def _cancel(self):
                _moduleLogger.debug("Cancelling call")
                try:
-                       result = yield self._conn.session.pool.add_task, (
+                       result = yield (
                                self._conn.session.backend.cancel,
                                (self.__calledNumber, ),
                                {},
-                               on_success,
-                               on_error,
-                       ), {}
+                       )
                except Exception:
                        _moduleLogger.exception(result)
                        return