From: Magnus H. <leg...@us...> - 2009-01-10 00:41:12
|
Update of /cvsroot/emacs-jabber/tox In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv23135 Modified Files: jabber-tox.el tox-session.xml Log Message: Communicate candidates both ways Index: jabber-tox.el =================================================================== RCS file: /cvsroot/emacs-jabber/tox/jabber-tox.el,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- jabber-tox.el 1 Jan 2009 16:21:40 -0000 1.29 +++ jabber-tox.el 10 Jan 2009 00:40:56 -0000 1.30 @@ -349,7 +349,34 @@ (:new-native-candidate (let ((components (cdr event))) (jingle-send-native-candidate state-data components) - (list :pending state-data))))) + (list :pending state-data))) + + (:iq-set + (let* ((jc (plist-get state-data :jc)) + (iq (cdr event))) + (jabber-xml-let-attributes (action) iq + (cond + ((string= action "transport-info") + (let ((tox-session (plist-get state-data :tox-session)) + (candidates + (jabber-xml-get-children + (jabber-xml-path + iq + `(jingle (transport . ,jingle-ice-udp-ns))) + 'candidate))) + ;; XXX: send iq error for no candidates + (when candidates + (dbus-call-method :session tox-name tox-session tox-session-interface + "AddRemoteCandidate" + (mapcar + 'jingle-parse-candidate + candidates)) + ;; XXX: iq result + (list :pending state-data) + ))) + (t + ;; XXX: send "bad-request" or something + ))))))) (defun jingle-send-iq (state-data action payload) "Send a Jingle IQ stanza from within a Jingle FSM. @@ -383,6 +410,7 @@ "Send a native candidate for ICE-UDP. The CANDIDATE is a list of components, as provided by the NewNativeCandidate signal of Tox." + ;; XXX: check against XEP-0176 (jingle-send-iq state-data "transport-info" `((content ((creator . "initiator") @@ -392,7 +420,8 @@ ,@(mapcar (lambda (c) `(candidate - ((component . ,(number-to-string (nth 1 c))) + ((id . ,(nth 0 c)) + (component . ,(number-to-string (nth 1 c))) ;; foundation? ;; generation? (ip . ,(nth 2 c)) @@ -401,9 +430,30 @@ (protocol . ,(nth 4 c)) (priority . ,(nth 7 c)) ;; how to translate type? + (username . ,(nth 8 c)) + (password . ,(nth 9 c)) ))) candidate)))))) +(defun jingle-parse-candidate (candidate) + "Parse an XEP-0176 <candidate/> element into DBus format. +Specifically, the signature is \"(susqsssyyss)\"." + ;; XXX: check against XEP-0176 again + (jabber-xml-let-attributes + (id component foundation generation + ip port protocol priority type + username password) + candidate + (list :string id + :uint32 (string-to-number component) + :string ip + :uint16 (string-to-number port) + "udp" "RTP" "AVP" + :byte (string-to-number priority) ;XXX: priority is preference? + :byte 0 ;XXX: fix type + :string (or username "") + :string (or password "")))) + (add-to-list 'jabber-iq-set-xmlns-alist (cons jingle-ns 'jabber-jingle-incoming-iq)) (defun jabber-jingle-incoming-iq (jc iq) Index: tox-session.xml =================================================================== RCS file: /cvsroot/emacs-jabber/tox/tox-session.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tox-session.xml 3 Nov 2008 23:53:52 -0000 1.4 +++ tox-session.xml 10 Jan 2009 00:40:56 -0000 1.5 @@ -74,6 +74,7 @@ --> <arg name='newstate' type='y'/> <!-- direction is one of: + 0: nothing 1: send only. 2: receive only. 3: send and receive. |