From: Magnus H. <leg...@us...> - 2008-10-16 18:35:53
|
Update of /cvsroot/emacs-jabber/tox In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12485 Modified Files: jabber-tox.el Log Message: Don't try to start if we get bad errors during startup Index: jabber-tox.el =================================================================== RCS file: /cvsroot/emacs-jabber/tox/jabber-tox.el,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- jabber-tox.el 16 Oct 2008 18:15:31 -0000 1.15 +++ jabber-tox.el 16 Oct 2008 18:35:31 -0000 1.16 @@ -62,6 +62,7 @@ (define-enter-state jingle :allocate (fsm state-data) + (condition-case e ;; Allocate a ToxSession object. (let* ((tox-session (dbus-call-method :session tox-name tox-path tox-interface @@ -104,7 +105,24 @@ fsm (cons :new-native-candidate components))))) (fsm-debug-output "Waiting") - (list state-data nil))) + (list state-data nil)) + (error + ;; So, we couldn't initiate our Jingle tool. + (setq state-data (plist-put state-data :we-deserve-to-die (error-message-string e))) + ;; Make sure we exit gracefully. + (ecase (plist-get state-data :role) + (:initiator + ;; If we're the initiator, make sure that the user gets to know + ;; what happened. + (message "Couldn't initiate Jingle session: %s" + (error-message-string e)) + ;; This seems to be the smoothest way to get rid of the FSM... + (list state-data 0.1)) + (:target + ;; If we're the target, make sure that our contact gets to know + ;; what happened. We don't know yet how, but we will soon get + ;; an :iq-set that we need to answer. + (list state-data)))))) (define-enter-state jingle nil (fsm state-data) @@ -121,7 +139,7 @@ (define-state jingle :allocate (fsm state-data event callback) - (case (car-safe event) + (case (or (car-safe event) event) (:new-native-candidate (setq state-data (plist-put state-data :native-candidates (list (cdr event)))) (list (ecase (plist-get state-data :role) @@ -138,14 +156,28 @@ (fsm-debug-output "The native candidates are %S" components) (setq state-data (plist-put state-data :native-candidates components)) (list (ecase (plist-get state-data :role) - (:initiator - :initiate) - (:target - :wait-for-initiate)) + (:initiator + :initiate) + (:target + :wait-for-initiate)) state-data))) (:iq-set - :defer))) + (if (plist-get state-data :we-deserve-to-die) + (let ((iq (cdr event))) + (jabber-xml-let-attributes (from id) iq + (jabber-send-iq-error + (plist-get state-data :jc) + from id (jabber-iq-query iq) + "wait" 'internal-server-error + (plist-get state-data :we-deserve-to-die))) + (list nil state-data)) + :defer)) + + (:timeout + ;; fatal error during initialization, but we couldn't garbage + ;; collect ourselves until now. + (list nil state-data)))) (define-enter-state jingle :initiate (fsm state-data) @@ -371,7 +403,12 @@ (fsm (fsm-send-sync fsm (cons :iq-set iq))) ((string= action "session-initiate") - (setq fsm (start-jingle jc sid :target (jabber-xml-get-attribute iq 'from))) + (condition-case e + (setq fsm (start-jingle jc sid :target (jabber-xml-get-attribute iq 'from))) + (error + (jabber-signal-error "wait" 'internal-server-error + (concat "Couldn't accept Jingle session: " + (error-message-string e))))) (puthash (cons (jabber-connection-jid jc) sid) fsm jingle-acct-sid-map) (fsm-send-sync fsm (cons :iq-set iq))) (t |