/usr/share/emacs/site-lisp/elpa-src/jabber-0.8.92/jabber-si-server.el is in elpa-jabber 0.8.92+git98dc8e-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | ;; jabber-si-server.el - handle incoming stream requests, by JEP-0095
;; Copyright (C) 2002, 2003, 2004 - tom berger - object@intelectronica.net
;; Copyright (C) 2003, 2004 - Magnus Henoch - mange@freemail.hu
;; This file is a part of jabber.el.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(require 'jabber-iq)
(require 'jabber-disco)
(require 'jabber-feature-neg)
(require 'jabber-si-common)
(jabber-disco-advertise-feature "http://jabber.org/protocol/si")
;; Now, stream methods push data to profiles. It could be the other
;; way around; not sure which is better.
(defvar jabber-si-profiles nil
"Supported SI profiles.
Each entry is a list, containing:
* The namespace URI of the profile
* Accept function, taking entire IQ stanza, and signalling a 'forbidden'
error if request is declined; returning an XML node to return in
response, or nil of none needed
* \"Connection established\" function. See `jabber-si-stream-methods'.")
(add-to-list 'jabber-iq-set-xmlns-alist
(cons "http://jabber.org/protocol/si" 'jabber-si-process))
(defun jabber-si-process (jc xml-data)
(let* ((to (jabber-xml-get-attribute xml-data 'from))
(id (jabber-xml-get-attribute xml-data 'id))
(query (jabber-iq-query xml-data))
(profile (jabber-xml-get-attribute query 'profile))
(si-id (jabber-xml-get-attribute query 'id))
(feature (car (jabber-xml-get-children query 'feature))))
(message "Receiving SI with profile '%s'" profile)
(let (stream-method
;; Find profile
(profile-data (assoc profile jabber-si-profiles)))
;; Now, feature negotiation for stream type (errors
;; don't match JEP-0095, so convert)
(condition-case err
(setq stream-method (jabber-fn-intersection
(jabber-fn-parse feature 'request)
(list (cons "stream-method" (mapcar 'car jabber-si-stream-methods)))))
(jabber-error
(jabber-signal-error "cancel" 'bad-request nil
'((no-valid-streams ((xmlns . "http://jabber.org/protocol/si")))))))
(unless profile-data
;; profile not understood
(jabber-signal-error "cancel" 'bad-request nil
'((bad-profile ((xmlns . "http://jabber.org/protocol/si"))))))
(let* ((profile-accept-function (nth 1 profile-data))
;; accept-function might throw a "forbidden" error
;; on user cancel
(profile-response (funcall profile-accept-function jc xml-data))
(profile-connected-function (nth 2 profile-data))
(stream-method-id (nth 1 (assoc "stream-method" stream-method)))
(stream-data (assoc stream-method-id jabber-si-stream-methods))
(stream-accept-function (nth 2 stream-data)))
;; prepare stream for the transfer
(funcall stream-accept-function jc to si-id profile-connected-function)
;; return result of feature negotiation of stream type
(jabber-send-iq jc to "result"
`(si ((xmlns . "http://jabber.org/protocol/si"))
,@profile-response
(feature ((xmlns . "http://jabber.org/protocol/feature-neg"))
,(jabber-fn-encode stream-method 'response)))
nil nil nil nil
id)
))))
(provide 'jabber-si-server)
;;; arch-tag: d3c75c66-4052-4cf5-8f04-8765adfc8b96
|