]>
Commit | Line | Data |
---|---|---|
53e6db90 DC |
1 | ;ELC\1c\0\0\0 |
2 | ;;; Compiled | |
3 | ;;; in Emacs version 28.2 | |
4 | ;;; with all optimizations. | |
5 | ||
6 | ||
7 | ||
8 | (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\305\306\307\310\311\304%\210\312\313\314\315\316DD\317\311\306\320\315&\a\210\312\321\314\315\322DD\323\311\306\320\315&\a\207" [require seq fsm mailcap jabber custom-declare-group jabber-httpupload nil "Jabber HTTP Upload Settings." :group custom-declare-variable jabber-httpupload-upload-function funcall function #[0 "\300\207" [jabber-httpupload-put-file-curl] 1 #1=""] "The function used to upload the file.\n Some functions calls external programs such as Curl and wget, please check their\n documentation for more information." :type jabber-httpupload-record-command #[0 "\300\207" ["sox -d -t ogg $(filename).ogg"] 1 #1#] "What is the command used to record audio?\nUse $(filename) where the temporal filename should be."] 8) | |
9 | #@281 Alist of Jabber connections and the node with HTTP Upload support. | |
10 | This is filled by the `jabber-httpupload-test-all-connections-suport'. | |
11 | Each element are of the form (jabber-connection . string/nil). If the value is | |
12 | a string, it is the upload item IRI, if nil means no support.\1f | |
13 | (defvar jabber-httpupload-support nil (#$ . 884)) | |
14 | #@169 Test all connections in `jabber-connections' for HTTP Upload support. | |
15 | Store the results at `jabber-httpupload-support'. | |
16 | If the connection is already tested, ignore it.\1f | |
17 | (defalias 'jabber-httpupload-test-all-connections-support #[0 "\302\b\303\304 \"\"\211\211\205\19\0\211@\305\ 1!\210\ 1A\266\202\202\b\0\207" [jabber-connections jabber-httpupload-support seq-difference mapcar car jabber-httpupload-test-connection-support] 5 (#$ . 1221)]) | |
18 | #@211 Test if HTTP Upload is supported on the JC connection's server. | |
19 | If it is supported, store the item IRI at `jabber-httpupload-support'. | |
20 | ||
21 | This function is asynchronous, thus it won't return any results. | |
22 | ||
23 | (fn JC)\1f | |
24 | (defalias 'jabber-httpupload-test-connection-support #[257 "\300\ 1\301\"\207" [jabber-httpupload-apply-to-items #[514 "\300\ 2\ 2\301\234\"\207" [jabber-httpupload-test-item-support 1] 6 "\n\n(fn JC RESULT)"]] 4 (#$ . 1659)]) | |
25 | #@242 Test if the IRI Disco item supports HTTP Upload. | |
26 | Get the Disco Info from the provided IRI at the current JC jabber connection, | |
27 | if the HTTP Upload namespace feature is in the answer, store the IRI | |
28 | in `jabber-httpupload-support'. | |
29 | ||
30 | (fn JC IRI)\1f | |
31 | (defalias 'jabber-httpupload-test-item-support #[514 "\300\ 2\ 2\301\302\303\ 6\ 6\"\301%\207" [jabber-disco-get-info nil make-closure #[771 "\302\ 1A@\235\205\ f\0\ 2\300B B\211\11\207" [V0 jabber-httpupload-support "urn:xmpp:http:upload"] 5 "\n\n(fn JC DATA RESULT)"]] 9 (#$ . 2097)]) | |
32 | #@224 Retrieve al Disco IRIs from the server connected in JC. | |
33 | Return a list of IRI strings. | |
34 | ||
35 | JC is a jabber connection. | |
36 | CALLBACK is a function that receives two arguments: Jabber connection and | |
37 | the item vector. | |
38 | ||
39 | (fn JC CALLBACK)\1f | |
40 | (defalias 'jabber-httpupload-apply-to-items #[514 "\300\301\ 3!\302\"\303\ 3\ 2\304\305\306\ 6\a\"\304%\207" [plist-get fsm-get-state-data :server jabber-disco-get-items nil make-closure #[771 "\211\211\205\18\0\211@\301\302\ 2\"\210\300\ 5\ 2\"\210\ 1A\266\202\202\ 1\0\207" [V0 message "item: %S"] 8 "\n\n(fn JC DATA RESULT)"]] 10 (#$ . 2615)]) | |
41 | #@478 Check if the server has HTTP Upload support. | |
42 | Return the tuple (jabber-connection . upload-url) when there is support from | |
43 | the server. Return nil when the server does not support HTTP Upload. | |
44 | ||
45 | If the server is not in `jabber-httpupload-support', then it is considered as | |
46 | it is not supported. It SHOULD be tested on-line with | |
47 | `jabber-httpupload-test-connection-support' as soon as the connection and | |
48 | authentication is established. | |
49 | ||
50 | JC is the Jabber Connection to use. | |
51 | ||
52 | (fn JC)\1f | |
53 | (defalias 'jabber-httpupload-server-has-support #[257 "\301\302\303\ 3\"\b\"\207" [jabber-httpupload-support seq-find make-closure #[257 "\300\ 1@\232\205 \0\211A\207" [V0] 3 "\n\n(fn TUPLE)"]] 5 (#$ . 3169)]) | |
54 | #@221 Retrieve the slot data from the XML-DATA information. | |
55 | The XML-DATA is the stanza receive from the Jabber Connection after requesting | |
56 | the slot for a file. | |
57 | The returned list has the PUT URL and the GET URL. | |
58 | ||
59 | (fn XML-DATA)\1f | |
60 | (defalias 'jabber-httpupload-parse-slot-answer #[257 "\300\ 1\301\"\302\ 1:\205\ e\0\303\ 2\ 2\"\266\202\300\ 2\304\"\302\ 1:\205\1e\0\303\ 2\ 2\"\266\202D\207" [jabber-xml-path (slot put) url xml-get-attribute-or-nil (slot get)] 7 (#$ . 3857)]) | |
61 | #@483 Callback function used when the slot request succeeded. | |
62 | XML-DATA is the received XML from the server. | |
63 | DATA is a triple (filedata success-callback success-args) where: | |
64 | FILEDATA is a triple (filename size content-type) | |
65 | SUCCESS-CALLBACK is a function to call after parsing and requesting the | |
66 | upload. | |
67 | It should accept following arguments: JC XML-DATA FILEDATA PUT-GET-URLS | |
68 | and SUCCESS-ARGS. | |
69 | SUCCESS-ARGS is a list to pass to the SUCCESS-CALLBACK. | |
70 | ||
71 | (fn JC XML-DATA DATA)\1f | |
72 | (defalias 'jabber-httpupload--request-slot-successful #[771 "\300\ 2!\ 1@\ 2A@\301\ 48\ 1\ 6\a\ 6\a\ 5\ 6\a\ 5%\207" [jabber-httpupload-parse-slot-answer 2] 13 (#$ . 4308)]) | |
73 | #@391 Callback function used when the slot request failed. | |
74 | ||
75 | DATA is a list (filedata error-callback error-args) where: | |
76 | FILEDATA is a triple (filename size content-type) | |
77 | ERROR-CALLBACK is a function to call. If no error-callback is provided, then | |
78 | `error' is used. Its arguments are JC XML-DATA FILEDATA ERROR-ARGS. | |
79 | ERROR-ARGS is list passed to the ERROR-CALLBACK. | |
80 | ||
81 | (fn JC XML-DATA DATA)\1f | |
82 | (defalias 'jabber-httpupload--request-slot-failed #[771 "\211@\ 1A@\300\ 38\ 1\203\15\0\ 1\ 6\ 6\ 6\ 6\ 5\ 4$\207\301\302\303\ 6\ 6@\ 6\b#!\207" [2 error format "The file %s cannot be uploaded: SLOT rejected. %S"] 11 (#$ . 4948)]) | |
83 | #@578 Request a slot for HTTP Upload to the server's connection. | |
84 | JC is an active Jabber Connection. | |
85 | FILEDATA is a list with (filename size content-type). | |
86 | SUCCESS-CALLBACK is a function name to call when the slot is received. Its | |
87 | arguments should be: jc xml-data data and put-get-URLs. | |
88 | SUCCESS-ARGS is a list of arguments used by the SUCCESS-CALLBACK | |
89 | ERROR-CALLBACK is a function to call on failure. Its arguments should be: | |
90 | jc xml-data. | |
91 | ERROR-ARGS is a list with arguments for ERROR-CALLBACK. | |
92 | ||
93 | (fn JC FILEDATA SUCCESS-CALLBACK SUCCESS-ARGS &optional ERROR-CALLBACK ERROR-ARGS)\1f | |
94 | (defalias 'jabber-httpupload-request-slot #[1540 "\300\ 5@!\ 5A@\301\ 6\a8\302\ 6 \303\ 6\v!A\304\305\306\307\ 6 B\310\ 6 B\311\ 6 BFD\312\ 6\r\ 6\r\ 6\rE\313\ 6\ f\ 6\r\ 6\rE&\b\207" [file-name-nondirectory 2 jabber-send-iq jabber-httpupload-server-has-support "get" request (xmlns . "urn:xmpp:http:upload:0") filename size content-type jabber-httpupload--request-slot-successful jabber-httpupload--request-slot-failed] 20 (#$ . 5546)]) | |
95 | #@253 Should the SSL/TLS certificates be ignore from JC connection? | |
96 | Check if JC URL is in the variable `jabber-invalid-certificate-servers', if it | |
97 | is the XMPP and HTTPs connection should be established regarding their | |
98 | certificate validation status. | |
99 | ||
100 | (fn JC)\1f | |
101 | (defalias 'jabber-httpupload-ignore-certificate #[257 "\301\302\ 2!\303\"\b\235\207" [jabber-invalid-certificate-servers plist-get fsm-get-state-data :server] 4 (#$ . 6530)]) | |
102 | #@501 Update the given file at FILEPATH to the provided PUT-URL. | |
103 | The CONTENT-TYPE (MIME type) of the file must match the one provided | |
104 | to the Jabber Connection with `jabber-httpupload-request-slot'. | |
105 | IGNORE-CERT-PROBLEMS allows to connect with HTTPS servers with invalid or | |
106 | non-trusted SSL/TLS certificates. | |
107 | When the process ends, a callback function is called using the following | |
108 | code: (funcall CALLBACK CALLBACK-ARG) | |
109 | ||
110 | (fn FILEPATH CONTENT-TYPE PUT-URL CALLBACK CALLBACK-ARG &optional IGNORE-CERT-PROBLEMS)\1f | |
111 | (defalias 'jabber-httpupload-upload-file #[1541 "\b\ 6\ 6\ 6\ 6\ 6\ 6\ 6\ 6\ 6\ 6\ 6\ 6&\ 6?\205\16\0\301\302!\207" [jabber-httpupload-upload-function error "The upload function failed to PUT the file to the server. Try other function or install the required program"] 13 (#$ . 6961)]) | |
112 | #@233 Alist of running processes uploading the file to the server. | |
113 | List of running processes uploading the file to the server | |
114 | associated with their callback and arguments. Each element has | |
115 | the following format: (process . (callback arg))\1f | |
116 | (defvar jabber-httpupload-upload-processes nil (#$ . 7724)) | |
117 | #@209 What to do when an upload process ends. | |
118 | PROCESS is the process that ended. | |
119 | First remove the process from `jabber-httpupload-upload-processes', | |
120 | then call its callback with the provided argument. | |
121 | ||
122 | (fn PROCESS)\1f | |
123 | (defalias 'jabber-httpupload-process-ended #[257 "\211\b\236\211A@\ 1AA@\301\ 4\b\"\10\ 1\ 1!\207" [jabber-httpupload-upload-processes assq-delete-all] 7 (#$ . 8023)]) | |
124 | #@260 Detect when Curl ends and act accordingly. | |
125 | PROCESS is the asynchronous Curl call. | |
126 | EVENT is a string describing the reason the sentinel were called. | |
127 | ||
128 | When EVENT is "finished | |
129 | ", then the function | |
130 | `jabber-httpupload-process-ended' is called. | |
131 | ||
132 | (fn PROCESS EVENT)\1f | |
133 | (defalias 'jabber-httpupload-curl-sentinel #[514 "r\301\ 2!q\210\302\18db\210\303\304\ 2\"c\210*\211\305\230\205\e\0\306\ 2!\207" [inhibit-read-only process-buffer t format "Sentinel: %S event received." "finished\n" jabber-httpupload-process-ended] 5 (#$ . 8394)]) | |
134 | #@621 Use the curl command to put the file at FILEPATH into the PUT-URL. | |
135 | Send the SIZE and CONTENT-TYPE MIME as headers. | |
136 | IGNORE-CERT-PROBLEMS enable the use of HTTPS connections with invalid or | |
137 | non-trusted SSL/TLS certificates. If nil, curl will validate the certificate | |
138 | provided by the HTTP/S Web server. | |
139 | When the process ends, the function CALLBACK is called like the following | |
140 | call: (funcall CALLBACK CALLBACK-ARG). | |
141 | The process is registered at `jabber-httpupload-upload-processes' AList with | |
142 | the provided CALLBACK and CALLBACK-ARG. | |
143 | ||
144 | (fn FILEPATH CONTENT-TYPE PUT-URL CALLBACK CALLBACK-ARG &optional IGNORE-CERT-PROBLEMS)\1f | |
145 | (defalias 'jabber-httpupload-put-file-curl #[1541 "\303\304!\18\305\306\b\ 3\203\ f\0\307\202\10\0\310\ 6 \ 6 \ 6 &\ 6\b\205I\0r\311\312!q\210\313\19db\210\305\314\315 \ 6\a\ 4$c\210\316\317p\ 3#\211\ 5\ 5DB\nB\12\320\ 1\321\"\266\ 2\322c\210*\313)\207" [exec-path inhibit-read-only jabber-httpupload-upload-processes executable-find "curl" format "%s %s --upload-file '%s' -H \"content-type: %s\" '%s'" "--insecure" "" get-buffer-create "*jabber-httpupload-put-file-curl*" t "%s Uploading to %s with curl:\n$ %s" current-time-string start-process-shell-command "jabber-httpupload-put-file-curl" set-process-sentinel jabber-httpupload-curl-sentinel "-- done --"] 13 (#$ . 8916)]) | |
146 | #@164 Send the GET URL address to the JID user. | |
147 | The message requiers the GET-URL of the slot file, the receiver's JID | |
148 | and the JC Jabber Connection. | |
149 | ||
150 | (fn JC JID GET-URL)\1f | |
151 | (defalias 'jabber-httpupload-send-file-url #[771 "\301\ 3!\302\ 3\b\"\203\ e\0\303\202\ f\0\304\305\ 5\306\307\ 6\aB\310\ 6\ 6B\311\ 6\ 6BE\312\313\ 6\bE\314\315\316\313\ 6\vEEF\"\207" [*jabber-active-groupchats* jabber-connection-original-jid assoc "groupchat" "chat" jabber-send-sexp message to from type body nil x ((xmlns . "jabber:x:oob")) url] 15 (#$ . 10183)]) | |
152 | #@116 Send the file at FILEPATH to the user JID. | |
153 | JC is the Jabber Connection to send the file URL. | |
154 | ||
155 | (fn JC JID FILEPATH)\1f | |
156 | (defalias 'jabber-httpupload-send-file #[771 "\300\ 3!\204\n\0\301\302!\210\303\ 1!\304\ 18\262\ 1\305\306\ 3!!\ 2\ 2\ 2E\307\ 6\ 6\ 2\310\ 6\bC$\207" [jabber-httpupload-server-has-support error "The Jabber Connection provided has no HTTP Upload support" file-attributes 7 mailcap-extension-to-mime file-name-extension jabber-httpupload-request-slot jabber-httpupload--slot-reserved] 11 (#$ . 10691) (byte-code "\300 \301\302\303\211\211\304\305&\ 6\306\307!E\207" [jabber-read-account jabber-read-jid-completing "Send file to: " nil full t read-file-name "File to send:"] 8)]) | |
157 | #@496 Callback function used when the upload is done. | |
158 | When the upload process finished, a callback function is called with an | |
159 | argument. | |
160 | This function is expected to be used as the CALLBACK argument for the function | |
161 | `jabber-httpupload-upload-file', DATA is its CALLBACK-ARG argument. | |
162 | Also, see `jabber-httpupload-process-ended' for more information. | |
163 | DATA is expected to have the following foramt: (jc jid get-url). | |
164 | After the upload is done, send the get-url to the destined Jabber user JID. | |
165 | ||
166 | (fn DATA)\1f | |
167 | (defalias 'jabber-httpupload--upload-done #[257 "\211@\ 1A@\300\ 38\3011\13\0\302\ 3\ 3\ 3#0\207\207" [2 (error) jabber-httpupload-send-file-url] 8 (#$ . 11363)]) | |
168 | #@299 Callback function used when the slot request succeeded. | |
169 | JC is the current Jabber Connection. | |
170 | XML-DATA is the received XML from the server. | |
171 | FILEDATA is a triple `(filepath size content-type). | |
172 | URLS is a tuple `(put-url get-url). | |
173 | EXTRA-DATA is a list `(jid) | |
174 | ||
175 | (fn JC XML-DATA FILEDATA URLS EXTRA-DATA)\1f | |
176 | (defalias 'jabber-httpupload--slot-reserved #[1285 "\ 2@\300\ 48\ 2@\ 4A@\ 5@\301\302\ 6\b\"\210\3031-\0\304\305\ 6\ 6!\ 5\ 3\306\ 6\ e\ 6\b\ 6\bE\307\ 6\10!&\ 60\207\207" [2 message "jabber-httpupload: slot PUT and GET URLs: %S" (error) jabber-httpupload-upload-file expand-file-name jabber-httpupload--upload-done jabber-httpupload-ignore-certificate] 18 (#$ . 12015)]) | |
177 | #@72 Create a new audio record and save the file into a temporal directory.\1f | |
178 | (defalias 'jabber-httpupload--record-audio #[0 "\301\302p\303\304\305\b##\306\ 1\307\"\207" [jabber-httpupload-record-command start-process-shell-command "jabber-httpupload-record-audio" replace-string "$(filename" "/tmp/jabber-httpupload-record" set-process-sentinel jabber-httpupload-record-sentinel] 7 (#$ . 12653)]) | |
179 | (byte-code "\300\301\302\"\210\303\304!\207" [add-hook jabber-post-connect-hooks jabber-httpupload-test-connection-support provide jabber-httpupload] 3) |