| 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 |
(eval-when-compile (require 'cl)) |
|---|
| 31 |
|
|---|
| 32 |
(require 'gnus) |
|---|
| 33 |
(require 'message) |
|---|
| 34 |
(require 'gnus-range) |
|---|
| 35 |
|
|---|
| 36 |
(autoload 'gnus-agent-expire "gnus-agent") |
|---|
| 37 |
(autoload 'gnus-agent-regenerate-group "gnus-agent") |
|---|
| 38 |
(autoload 'gnus-agent-read-servers-validate-native "gnus-agent") |
|---|
| 39 |
|
|---|
| 40 |
(defcustom gnus-open-server-hook nil |
|---|
| 41 |
"Hook called just before opening connection to the news server." |
|---|
| 42 |
:group 'gnus-start |
|---|
| 43 |
:type 'hook) |
|---|
| 44 |
|
|---|
| 45 |
(defcustom gnus-server-unopen-status nil |
|---|
| 46 |
"The default status if the server is not able to open. |
|---|
| 47 |
If the server is covered by Gnus agent, the possible values are |
|---|
| 48 |
`denied', set the server denied; `offline', set the server offline; |
|---|
| 49 |
nil, ask user. If the server is not covered by Gnus agent, set the |
|---|
| 50 |
server denied." |
|---|
| 51 |
:version "22.1" |
|---|
| 52 |
:group 'gnus-start |
|---|
| 53 |
:type '(choice (const :tag "Ask" nil) |
|---|
| 54 |
(const :tag "Deny server" denied) |
|---|
| 55 |
(const :tag "Unplug Agent" offline))) |
|---|
| 56 |
|
|---|
| 57 |
(defvar gnus-internal-registry-spool-current-method nil |
|---|
| 58 |
"The current method, for the registry.") |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
(defun gnus-start-news-server (&optional confirm) |
|---|
| 65 |
"Open a method for getting news. |
|---|
| 66 |
If CONFIRM is non-nil, the user will be asked for an NNTP server." |
|---|
| 67 |
(let (how) |
|---|
| 68 |
(if gnus-current-select-method |
|---|
| 69 |
|
|---|
| 70 |
nil |
|---|
| 71 |
|
|---|
| 72 |
(unless gnus-nntp-service |
|---|
| 73 |
(setq gnus-nntp-server nil)) |
|---|
| 74 |
(when confirm |
|---|
| 75 |
|
|---|
| 76 |
(setq gnus-nntp-server |
|---|
| 77 |
(completing-read "NNTP server: " |
|---|
| 78 |
(mapcar (lambda (server) (list server)) |
|---|
| 79 |
(cons (list gnus-nntp-server) |
|---|
| 80 |
gnus-secondary-servers)) |
|---|
| 81 |
nil nil gnus-nntp-server))) |
|---|
| 82 |
|
|---|
| 83 |
(when (and gnus-nntp-server |
|---|
| 84 |
(stringp gnus-nntp-server) |
|---|
| 85 |
(not (string= gnus-nntp-server ""))) |
|---|
| 86 |
(setq gnus-select-method |
|---|
| 87 |
(cond ((or (string= gnus-nntp-server "") |
|---|
| 88 |
(string= gnus-nntp-server "::")) |
|---|
| 89 |
(list 'nnspool (system-name))) |
|---|
| 90 |
((string-match "^:" gnus-nntp-server) |
|---|
| 91 |
(list 'nnmh gnus-nntp-server |
|---|
| 92 |
(list 'nnmh-directory |
|---|
| 93 |
(file-name-as-directory |
|---|
| 94 |
(expand-file-name |
|---|
| 95 |
(substring gnus-nntp-server 1) "~/"))) |
|---|
| 96 |
(list 'nnmh-get-new-mail nil))) |
|---|
| 97 |
(t |
|---|
| 98 |
(list 'nntp gnus-nntp-server))))) |
|---|
| 99 |
|
|---|
| 100 |
(setq how (car gnus-select-method)) |
|---|
| 101 |
(cond |
|---|
| 102 |
((eq how 'nnspool) |
|---|
| 103 |
(require 'nnspool) |
|---|
| 104 |
(gnus-message 5 "Looking up local news spool...")) |
|---|
| 105 |
((eq how 'nnmh) |
|---|
| 106 |
(require 'nnmh) |
|---|
| 107 |
(gnus-message 5 "Looking up mh spool...")) |
|---|
| 108 |
(t |
|---|
| 109 |
(require 'nntp))) |
|---|
| 110 |
(setq gnus-current-select-method gnus-select-method) |
|---|
| 111 |
(gnus-run-hooks 'gnus-open-server-hook) |
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
(if gnus-agent |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
(gnus-agent-read-servers-validate-native gnus-select-method)) |
|---|
| 123 |
|
|---|
| 124 |
(or |
|---|
| 125 |
|
|---|
| 126 |
(gnus-server-opened gnus-select-method) |
|---|
| 127 |
(gnus-open-server gnus-select-method) |
|---|
| 128 |
gnus-batch-mode |
|---|
| 129 |
(gnus-y-or-n-p |
|---|
| 130 |
(format |
|---|
| 131 |
"%s (%s) open error: '%s'. Continue? " |
|---|
| 132 |
(car gnus-select-method) (cadr gnus-select-method) |
|---|
| 133 |
(gnus-status-message gnus-select-method))) |
|---|
| 134 |
(gnus-error 1 "Couldn't open server on %s" |
|---|
| 135 |
(nth 1 gnus-select-method)))))) |
|---|
| 136 |
|
|---|
| 137 |
(defun gnus-check-group (group) |
|---|
| 138 |
"Try to make sure that the server where GROUP exists is alive." |
|---|
| 139 |
(let ((method (gnus-find-method-for-group group))) |
|---|
| 140 |
(or (gnus-server-opened method) |
|---|
| 141 |
(gnus-open-server method)))) |
|---|
| 142 |
|
|---|
| 143 |
(defun gnus-check-server (&optional method silent) |
|---|
| 144 |
"Check whether the connection to METHOD is down. |
|---|
| 145 |
If METHOD is nil, use `gnus-select-method'. |
|---|
| 146 |
If it is down, start it up (again)." |
|---|
| 147 |
(let ((method (or method gnus-select-method)) |
|---|
| 148 |
result) |
|---|
| 149 |
|
|---|
| 150 |
(when (stringp method) |
|---|
| 151 |
(setq method (gnus-server-to-method method))) |
|---|
| 152 |
(if (gnus-server-opened method) |
|---|
| 153 |
|
|---|
| 154 |
t |
|---|
| 155 |
|
|---|
| 156 |
(unless silent |
|---|
| 157 |
(gnus-message 5 "Opening %s server%s..." (car method) |
|---|
| 158 |
(if (equal (nth 1 method) "") "" |
|---|
| 159 |
(format " on %s" (nth 1 method))))) |
|---|
| 160 |
(gnus-run-hooks 'gnus-open-server-hook) |
|---|
| 161 |
(prog1 |
|---|
| 162 |
(condition-case () |
|---|
| 163 |
(setq result (gnus-open-server method)) |
|---|
| 164 |
(quit (message "Quit gnus-check-server") |
|---|
| 165 |
nil)) |
|---|
| 166 |
(unless silent |
|---|
| 167 |
(gnus-message 5 "Opening %s server%s...%s" (car method) |
|---|
| 168 |
(if (equal (nth 1 method) "") "" |
|---|
| 169 |
(format " on %s" (nth 1 method))) |
|---|
| 170 |
(if result "done" "failed"))))))) |
|---|
| 171 |
|
|---|
| 172 |
(defun gnus-get-function (method function &optional noerror) |
|---|
| 173 |
"Return a function symbol based on METHOD and FUNCTION." |
|---|
| 174 |
|
|---|
| 175 |
(unless method |
|---|
| 176 |
(error "Attempted use of a nil select method")) |
|---|
| 177 |
(when (stringp method) |
|---|
| 178 |
(setq method (gnus-server-to-method method))) |
|---|
| 179 |
|
|---|
| 180 |
(let* ((method-sym (if gnus-agent |
|---|
| 181 |
(inline (gnus-agent-get-function method)) |
|---|
| 182 |
(car method))) |
|---|
| 183 |
(method-fns (get method-sym 'gnus-method-functions)) |
|---|
| 184 |
(func (let ((method-fnlist-elt (assq function method-fns))) |
|---|
| 185 |
(unless method-fnlist-elt |
|---|
| 186 |
(setq method-fnlist-elt |
|---|
| 187 |
(cons function |
|---|
| 188 |
(intern (format "%s-%s" method-sym function)))) |
|---|
| 189 |
(put method-sym 'gnus-method-functions |
|---|
| 190 |
(cons method-fnlist-elt method-fns))) |
|---|
| 191 |
(cdr method-fnlist-elt)))) |
|---|
| 192 |
|
|---|
| 193 |
(unless (fboundp func) |
|---|
| 194 |
(unless (car method) |
|---|
| 195 |
(error "Trying to require a method that doesn't exist")) |
|---|
| 196 |
(require (car method)) |
|---|
| 197 |
(when (not (fboundp func)) |
|---|
| 198 |
(if noerror |
|---|
| 199 |
(setq func nil) |
|---|
| 200 |
(error "No such function: %s" func)))) |
|---|
| 201 |
func)) |
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
(defun gnus-open-server (gnus-command-method) |
|---|
| 209 |
"Open a connection to GNUS-COMMAND-METHOD." |
|---|
| 210 |
(when (stringp gnus-command-method) |
|---|
| 211 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 212 |
(let ((elem (assoc gnus-command-method gnus-opened-servers))) |
|---|
| 213 |
|
|---|
| 214 |
(if (eq (nth 1 elem) 'denied) |
|---|
| 215 |
(progn |
|---|
| 216 |
(gnus-message 1 "Denied server") |
|---|
| 217 |
nil) |
|---|
| 218 |
|
|---|
| 219 |
(let* ((open-server-function (gnus-get-function gnus-command-method 'open-server)) |
|---|
| 220 |
(result |
|---|
| 221 |
(condition-case err |
|---|
| 222 |
(funcall open-server-function |
|---|
| 223 |
(nth 1 gnus-command-method) |
|---|
| 224 |
(nthcdr 2 gnus-command-method)) |
|---|
| 225 |
(error |
|---|
| 226 |
(gnus-message 1 (format |
|---|
| 227 |
"Unable to open server due to: %s" |
|---|
| 228 |
(error-message-string err))) |
|---|
| 229 |
nil) |
|---|
| 230 |
(quit |
|---|
| 231 |
(gnus-message 1 "Quit trying to open server") |
|---|
| 232 |
nil))) |
|---|
| 233 |
open-offline) |
|---|
| 234 |
|
|---|
| 235 |
(unless elem |
|---|
| 236 |
(setq elem (list gnus-command-method nil) |
|---|
| 237 |
gnus-opened-servers (cons elem gnus-opened-servers))) |
|---|
| 238 |
|
|---|
| 239 |
(setcar (cdr elem) |
|---|
| 240 |
(cond (result |
|---|
| 241 |
(if (eq open-server-function #'nnagent-open-server) |
|---|
| 242 |
|
|---|
| 243 |
'offline |
|---|
| 244 |
'ok)) |
|---|
| 245 |
((and gnus-agent |
|---|
| 246 |
(gnus-agent-method-p gnus-command-method)) |
|---|
| 247 |
(cond (gnus-server-unopen-status |
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
(setq open-offline (eq gnus-server-unopen-status 'offline)) |
|---|
| 252 |
gnus-server-unopen-status) |
|---|
| 253 |
((and |
|---|
| 254 |
(not gnus-batch-mode) |
|---|
| 255 |
(gnus-y-or-n-p |
|---|
| 256 |
(format "Unable to open %s:%s, go offline? " |
|---|
| 257 |
(car gnus-command-method) |
|---|
| 258 |
(cadr gnus-command-method)))) |
|---|
| 259 |
(setq open-offline t) |
|---|
| 260 |
'offline) |
|---|
| 261 |
(t |
|---|
| 262 |
|
|---|
| 263 |
'denied))) |
|---|
| 264 |
(t |
|---|
| 265 |
|
|---|
| 266 |
'denied))) |
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
(if open-offline |
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
(let ((gnus-server-unopen-status 'denied)) |
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
(gnus-open-server gnus-command-method)) |
|---|
| 280 |
result))))) |
|---|
| 281 |
|
|---|
| 282 |
(defun gnus-close-server (gnus-command-method) |
|---|
| 283 |
"Close the connection to GNUS-COMMAND-METHOD." |
|---|
| 284 |
(when (stringp gnus-command-method) |
|---|
| 285 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 286 |
(funcall (gnus-get-function gnus-command-method 'close-server) |
|---|
| 287 |
(nth 1 gnus-command-method))) |
|---|
| 288 |
|
|---|
| 289 |
(defun gnus-request-list (gnus-command-method) |
|---|
| 290 |
"Request the active file from GNUS-COMMAND-METHOD." |
|---|
| 291 |
(when (stringp gnus-command-method) |
|---|
| 292 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 293 |
(funcall (gnus-get-function gnus-command-method 'request-list) |
|---|
| 294 |
(nth 1 gnus-command-method))) |
|---|
| 295 |
|
|---|
| 296 |
(defun gnus-request-list-newsgroups (gnus-command-method) |
|---|
| 297 |
"Request the newsgroups file from GNUS-COMMAND-METHOD." |
|---|
| 298 |
(when (stringp gnus-command-method) |
|---|
| 299 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 300 |
(funcall (gnus-get-function gnus-command-method 'request-list-newsgroups) |
|---|
| 301 |
(nth 1 gnus-command-method))) |
|---|
| 302 |
|
|---|
| 303 |
(defun gnus-request-newgroups (date gnus-command-method) |
|---|
| 304 |
"Request all new groups since DATE from GNUS-COMMAND-METHOD." |
|---|
| 305 |
(when (stringp gnus-command-method) |
|---|
| 306 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 307 |
(let ((func (gnus-get-function gnus-command-method 'request-newgroups t))) |
|---|
| 308 |
(when func |
|---|
| 309 |
(funcall func date (nth 1 gnus-command-method))))) |
|---|
| 310 |
|
|---|
| 311 |
(defun gnus-server-opened (gnus-command-method) |
|---|
| 312 |
"Check whether a connection to GNUS-COMMAND-METHOD has been opened." |
|---|
| 313 |
(unless (eq (gnus-server-status gnus-command-method) |
|---|
| 314 |
'denied) |
|---|
| 315 |
(when (stringp gnus-command-method) |
|---|
| 316 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 317 |
(funcall (inline (gnus-get-function gnus-command-method 'server-opened)) |
|---|
| 318 |
(nth 1 gnus-command-method)))) |
|---|
| 319 |
|
|---|
| 320 |
(defun gnus-status-message (gnus-command-method) |
|---|
| 321 |
"Return the status message from GNUS-COMMAND-METHOD. |
|---|
| 322 |
If GNUS-COMMAND-METHOD is a string, it is interpreted as a group |
|---|
| 323 |
name. The method this group uses will be queried." |
|---|
| 324 |
(let ((gnus-command-method |
|---|
| 325 |
(if (stringp gnus-command-method) |
|---|
| 326 |
(gnus-find-method-for-group gnus-command-method) |
|---|
| 327 |
gnus-command-method))) |
|---|
| 328 |
(funcall (gnus-get-function gnus-command-method 'status-message) |
|---|
| 329 |
(nth 1 gnus-command-method)))) |
|---|
| 330 |
|
|---|
| 331 |
(defun gnus-request-regenerate (gnus-command-method) |
|---|
| 332 |
"Request a data generation from GNUS-COMMAND-METHOD." |
|---|
| 333 |
(when (stringp gnus-command-method) |
|---|
| 334 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 335 |
(funcall (gnus-get-function gnus-command-method 'request-regenerate) |
|---|
| 336 |
(nth 1 gnus-command-method))) |
|---|
| 337 |
|
|---|
| 338 |
(defun gnus-request-group (group &optional dont-check gnus-command-method) |
|---|
| 339 |
"Request GROUP. If DONT-CHECK, no information is required." |
|---|
| 340 |
(let ((gnus-command-method |
|---|
| 341 |
(or gnus-command-method (inline (gnus-find-method-for-group group))))) |
|---|
| 342 |
(when (stringp gnus-command-method) |
|---|
| 343 |
(setq gnus-command-method |
|---|
| 344 |
(inline (gnus-server-to-method gnus-command-method)))) |
|---|
| 345 |
(funcall (inline (gnus-get-function gnus-command-method 'request-group)) |
|---|
| 346 |
(gnus-group-real-name group) (nth 1 gnus-command-method) |
|---|
| 347 |
dont-check))) |
|---|
| 348 |
|
|---|
| 349 |
(defun gnus-list-active-group (group) |
|---|
| 350 |
"Request active information on GROUP." |
|---|
| 351 |
(let ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 352 |
(func 'list-active-group)) |
|---|
| 353 |
(when (gnus-check-backend-function func group) |
|---|
| 354 |
(funcall (gnus-get-function gnus-command-method func) |
|---|
| 355 |
(gnus-group-real-name group) (nth 1 gnus-command-method))))) |
|---|
| 356 |
|
|---|
| 357 |
(defun gnus-request-group-description (group) |
|---|
| 358 |
"Request a description of GROUP." |
|---|
| 359 |
(let ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 360 |
(func 'request-group-description)) |
|---|
| 361 |
(when (gnus-check-backend-function func group) |
|---|
| 362 |
(funcall (gnus-get-function gnus-command-method func) |
|---|
| 363 |
(gnus-group-real-name group) (nth 1 gnus-command-method))))) |
|---|
| 364 |
|
|---|
| 365 |
(defun gnus-request-group-articles (group) |
|---|
| 366 |
"Request a list of existing articles in GROUP." |
|---|
| 367 |
(let ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 368 |
(func 'request-group-articles)) |
|---|
| 369 |
(when (gnus-check-backend-function func group) |
|---|
| 370 |
(funcall (gnus-get-function gnus-command-method func) |
|---|
| 371 |
(gnus-group-real-name group) (nth 1 gnus-command-method))))) |
|---|
| 372 |
|
|---|
| 373 |
(defun gnus-close-group (group) |
|---|
| 374 |
"Request the GROUP be closed." |
|---|
| 375 |
(let ((gnus-command-method (inline (gnus-find-method-for-group group)))) |
|---|
| 376 |
(funcall (gnus-get-function gnus-command-method 'close-group) |
|---|
| 377 |
(gnus-group-real-name group) (nth 1 gnus-command-method)))) |
|---|
| 378 |
|
|---|
| 379 |
(defun gnus-retrieve-headers (articles group &optional fetch-old) |
|---|
| 380 |
"Request headers for ARTICLES in GROUP. |
|---|
| 381 |
If FETCH-OLD, retrieve all headers (or some subset thereof) in the group." |
|---|
| 382 |
(let ((gnus-command-method (gnus-find-method-for-group group))) |
|---|
| 383 |
(cond |
|---|
| 384 |
((and gnus-use-cache (numberp (car articles))) |
|---|
| 385 |
(gnus-cache-retrieve-headers articles group fetch-old)) |
|---|
| 386 |
((and gnus-agent (gnus-online gnus-command-method) |
|---|
| 387 |
(gnus-agent-method-p gnus-command-method)) |
|---|
| 388 |
(gnus-agent-retrieve-headers articles group fetch-old)) |
|---|
| 389 |
(t |
|---|
| 390 |
(funcall (gnus-get-function gnus-command-method 'retrieve-headers) |
|---|
| 391 |
articles (gnus-group-real-name group) |
|---|
| 392 |
(nth 1 gnus-command-method) fetch-old))))) |
|---|
| 393 |
|
|---|
| 394 |
(defun gnus-retrieve-articles (articles group) |
|---|
| 395 |
"Request ARTICLES in GROUP." |
|---|
| 396 |
(let ((gnus-command-method (gnus-find-method-for-group group))) |
|---|
| 397 |
(funcall (gnus-get-function gnus-command-method 'retrieve-articles) |
|---|
| 398 |
articles (gnus-group-real-name group) |
|---|
| 399 |
(nth 1 gnus-command-method)))) |
|---|
| 400 |
|
|---|
| 401 |
(defun gnus-retrieve-groups (groups gnus-command-method) |
|---|
| 402 |
"Request active information on GROUPS from GNUS-COMMAND-METHOD." |
|---|
| 403 |
(when (stringp gnus-command-method) |
|---|
| 404 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 405 |
(funcall (gnus-get-function gnus-command-method 'retrieve-groups) |
|---|
| 406 |
groups (nth 1 gnus-command-method))) |
|---|
| 407 |
|
|---|
| 408 |
(defun gnus-request-type (group &optional article) |
|---|
| 409 |
"Return the type (`post' or `mail') of GROUP (and ARTICLE)." |
|---|
| 410 |
(let ((gnus-command-method (gnus-find-method-for-group group))) |
|---|
| 411 |
(if (not (gnus-check-backend-function |
|---|
| 412 |
'request-type (car gnus-command-method))) |
|---|
| 413 |
'unknown |
|---|
| 414 |
(funcall (gnus-get-function gnus-command-method 'request-type) |
|---|
| 415 |
(gnus-group-real-name group) article)))) |
|---|
| 416 |
|
|---|
| 417 |
(defun gnus-request-set-mark (group action) |
|---|
| 418 |
"Set marks on articles in the back end." |
|---|
| 419 |
(let ((gnus-command-method (gnus-find-method-for-group group))) |
|---|
| 420 |
(if (not (gnus-check-backend-function |
|---|
| 421 |
'request-set-mark (car gnus-command-method))) |
|---|
| 422 |
action |
|---|
| 423 |
(funcall (gnus-get-function gnus-command-method 'request-set-mark) |
|---|
| 424 |
(gnus-group-real-name group) action |
|---|
| 425 |
(nth 1 gnus-command-method))))) |
|---|
| 426 |
|
|---|
| 427 |
(defun gnus-request-update-mark (group article mark) |
|---|
| 428 |
"Allow the back end to change the mark the user tries to put on an article." |
|---|
| 429 |
(let ((gnus-command-method (gnus-find-method-for-group group))) |
|---|
| 430 |
(if (not (gnus-check-backend-function |
|---|
| 431 |
'request-update-mark (car gnus-command-method))) |
|---|
| 432 |
mark |
|---|
| 433 |
(funcall (gnus-get-function gnus-command-method 'request-update-mark) |
|---|
| 434 |
(gnus-group-real-name group) article mark)))) |
|---|
| 435 |
|
|---|
| 436 |
(defun gnus-request-article (article group &optional buffer) |
|---|
| 437 |
"Request the ARTICLE in GROUP. |
|---|
| 438 |
ARTICLE can either be an article number or an article Message-ID. |
|---|
| 439 |
If BUFFER, insert the article in that group." |
|---|
| 440 |
(let ((gnus-command-method (gnus-find-method-for-group group))) |
|---|
| 441 |
(funcall (gnus-get-function gnus-command-method 'request-article) |
|---|
| 442 |
article (gnus-group-real-name group) |
|---|
| 443 |
(nth 1 gnus-command-method) buffer))) |
|---|
| 444 |
|
|---|
| 445 |
(defun gnus-request-head (article group) |
|---|
| 446 |
"Request the head of ARTICLE in GROUP." |
|---|
| 447 |
(let* ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 448 |
(head (gnus-get-function gnus-command-method 'request-head t)) |
|---|
| 449 |
res clean-up) |
|---|
| 450 |
(cond |
|---|
| 451 |
|
|---|
| 452 |
((and gnus-use-cache |
|---|
| 453 |
(numberp article) |
|---|
| 454 |
(gnus-cache-request-article article group)) |
|---|
| 455 |
(setq res (cons group article) |
|---|
| 456 |
clean-up t)) |
|---|
| 457 |
|
|---|
| 458 |
((gnus-agent-request-article article group) |
|---|
| 459 |
(setq res (cons group article) |
|---|
| 460 |
clean-up t)) |
|---|
| 461 |
|
|---|
| 462 |
((fboundp head) |
|---|
| 463 |
(setq res (funcall head article (gnus-group-real-name group) |
|---|
| 464 |
(nth 1 gnus-command-method)))) |
|---|
| 465 |
|
|---|
| 466 |
(t |
|---|
| 467 |
(setq res (gnus-request-article article group) |
|---|
| 468 |
clean-up t))) |
|---|
| 469 |
(when clean-up |
|---|
| 470 |
(save-excursion |
|---|
| 471 |
(set-buffer nntp-server-buffer) |
|---|
| 472 |
(goto-char (point-min)) |
|---|
| 473 |
(when (search-forward "\n\n" nil t) |
|---|
| 474 |
(delete-region (1- (point)) (point-max))) |
|---|
| 475 |
(nnheader-fold-continuation-lines))) |
|---|
| 476 |
res)) |
|---|
| 477 |
|
|---|
| 478 |
(defun gnus-request-body (article group) |
|---|
| 479 |
"Request the body of ARTICLE in GROUP." |
|---|
| 480 |
(let* ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 481 |
(head (gnus-get-function gnus-command-method 'request-body t)) |
|---|
| 482 |
res clean-up) |
|---|
| 483 |
(cond |
|---|
| 484 |
|
|---|
| 485 |
((and gnus-use-cache |
|---|
| 486 |
(numberp article) |
|---|
| 487 |
(gnus-cache-request-article article group)) |
|---|
| 488 |
(setq res (cons group article) |
|---|
| 489 |
clean-up t)) |
|---|
| 490 |
|
|---|
| 491 |
((gnus-agent-request-article article group) |
|---|
| 492 |
(setq res (cons group article) |
|---|
| 493 |
clean-up t)) |
|---|
| 494 |
|
|---|
| 495 |
((fboundp head) |
|---|
| 496 |
(setq res (funcall head article (gnus-group-real-name group) |
|---|
| 497 |
(nth 1 gnus-command-method)))) |
|---|
| 498 |
|
|---|
| 499 |
(t |
|---|
| 500 |
(setq res (gnus-request-article article group) |
|---|
| 501 |
clean-up t))) |
|---|
| 502 |
(when clean-up |
|---|
| 503 |
(save-excursion |
|---|
| 504 |
(set-buffer nntp-server-buffer) |
|---|
| 505 |
(goto-char (point-min)) |
|---|
| 506 |
(when (search-forward "\n\n" nil t) |
|---|
| 507 |
(delete-region (point-min) (1- (point)))))) |
|---|
| 508 |
res)) |
|---|
| 509 |
|
|---|
| 510 |
(defun gnus-request-post (gnus-command-method) |
|---|
| 511 |
"Post the current buffer using GNUS-COMMAND-METHOD." |
|---|
| 512 |
(when (stringp gnus-command-method) |
|---|
| 513 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 514 |
(funcall (gnus-get-function gnus-command-method 'request-post) |
|---|
| 515 |
(nth 1 gnus-command-method))) |
|---|
| 516 |
|
|---|
| 517 |
(defun gnus-request-scan (group gnus-command-method) |
|---|
| 518 |
"Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD. |
|---|
| 519 |
If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned." |
|---|
| 520 |
(let ((gnus-command-method |
|---|
| 521 |
(if group (gnus-find-method-for-group group) gnus-command-method)) |
|---|
| 522 |
(gnus-inhibit-demon t) |
|---|
| 523 |
(mail-source-plugged gnus-plugged)) |
|---|
| 524 |
(if (or gnus-plugged (not (gnus-agent-method-p gnus-command-method))) |
|---|
| 525 |
(progn |
|---|
| 526 |
(setq gnus-internal-registry-spool-current-method gnus-command-method) |
|---|
| 527 |
(funcall (gnus-get-function gnus-command-method 'request-scan) |
|---|
| 528 |
(and group (gnus-group-real-name group)) |
|---|
| 529 |
(nth 1 gnus-command-method)))))) |
|---|
| 530 |
|
|---|
| 531 |
(defsubst gnus-request-update-info (info gnus-command-method) |
|---|
| 532 |
"Request that GNUS-COMMAND-METHOD update INFO." |
|---|
| 533 |
(when (stringp gnus-command-method) |
|---|
| 534 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 535 |
(when (gnus-check-backend-function |
|---|
| 536 |
'request-update-info (car gnus-command-method)) |
|---|
| 537 |
(let ((group (gnus-info-group info))) |
|---|
| 538 |
(and (funcall (gnus-get-function gnus-command-method |
|---|
| 539 |
'request-update-info) |
|---|
| 540 |
(gnus-group-real-name group) |
|---|
| 541 |
info (nth 1 gnus-command-method)) |
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 |
|
|---|
| 545 |
(let* ((active (gnus-active group)) |
|---|
| 546 |
(min (car active))) |
|---|
| 547 |
(when (> min 1) |
|---|
| 548 |
(let* ((range (if (= min 2) 1 (cons 1 (1- min)))) |
|---|
| 549 |
(read (gnus-info-read info)) |
|---|
| 550 |
(new-read (gnus-range-add read (list range)))) |
|---|
| 551 |
(gnus-info-set-read info new-read))) |
|---|
| 552 |
info))))) |
|---|
| 553 |
|
|---|
| 554 |
(defun gnus-request-expire-articles (articles group &optional force) |
|---|
| 555 |
(let* ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 556 |
(not-deleted |
|---|
| 557 |
(funcall |
|---|
| 558 |
(gnus-get-function gnus-command-method 'request-expire-articles) |
|---|
| 559 |
articles (gnus-group-real-name group) (nth 1 gnus-command-method) |
|---|
| 560 |
force))) |
|---|
| 561 |
(when (and gnus-agent |
|---|
| 562 |
(gnus-agent-method-p gnus-command-method)) |
|---|
| 563 |
(let ((expired-articles (gnus-sorted-difference articles not-deleted))) |
|---|
| 564 |
(when expired-articles |
|---|
| 565 |
(gnus-agent-expire expired-articles group 'force)))) |
|---|
| 566 |
not-deleted)) |
|---|
| 567 |
|
|---|
| 568 |
(defun gnus-request-move-article (article group server accept-function |
|---|
| 569 |
&optional last) |
|---|
| 570 |
(let* ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 571 |
(result (funcall (gnus-get-function gnus-command-method |
|---|
| 572 |
'request-move-article) |
|---|
| 573 |
article (gnus-group-real-name group) |
|---|
| 574 |
(nth 1 gnus-command-method) accept-function last))) |
|---|
| 575 |
(when (and result gnus-agent |
|---|
| 576 |
(gnus-agent-method-p gnus-command-method)) |
|---|
| 577 |
(gnus-agent-unfetch-articles group (list article))) |
|---|
| 578 |
result)) |
|---|
| 579 |
|
|---|
| 580 |
(defun gnus-request-accept-article (group &optional gnus-command-method last |
|---|
| 581 |
no-encode) |
|---|
| 582 |
|
|---|
| 583 |
(when (stringp gnus-command-method) |
|---|
| 584 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 585 |
(when (and (not gnus-command-method) |
|---|
| 586 |
(stringp group)) |
|---|
| 587 |
(setq gnus-command-method (or (gnus-find-method-for-group group) |
|---|
| 588 |
(gnus-group-name-to-method group)))) |
|---|
| 589 |
(goto-char (point-max)) |
|---|
| 590 |
(unless (bolp) |
|---|
| 591 |
(insert "\n")) |
|---|
| 592 |
(unless no-encode |
|---|
| 593 |
(let ((message-options message-options)) |
|---|
| 594 |
(message-options-set-recipient) |
|---|
| 595 |
(save-restriction |
|---|
| 596 |
(message-narrow-to-head) |
|---|
| 597 |
(let ((mail-parse-charset message-default-charset)) |
|---|
| 598 |
(mail-encode-encoded-word-buffer))) |
|---|
| 599 |
(message-encode-message-body))) |
|---|
| 600 |
(let ((gnus-command-method (or gnus-command-method |
|---|
| 601 |
(gnus-find-method-for-group group))) |
|---|
| 602 |
(result |
|---|
| 603 |
(funcall |
|---|
| 604 |
(gnus-get-function gnus-command-method 'request-accept-article) |
|---|
| 605 |
(if (stringp group) (gnus-group-real-name group) group) |
|---|
| 606 |
(cadr gnus-command-method) |
|---|
| 607 |
last))) |
|---|
| 608 |
(when (and gnus-agent (gnus-agent-method-p gnus-command-method)) |
|---|
| 609 |
(gnus-agent-regenerate-group group (list (cdr result)))) |
|---|
| 610 |
result)) |
|---|
| 611 |
|
|---|
| 612 |
(defun gnus-request-replace-article (article group buffer &optional no-encode) |
|---|
| 613 |
(unless no-encode |
|---|
| 614 |
(let ((message-options message-options)) |
|---|
| 615 |
(message-options-set-recipient) |
|---|
| 616 |
(save-restriction |
|---|
| 617 |
(message-narrow-to-head) |
|---|
| 618 |
(let ((mail-parse-charset message-default-charset)) |
|---|
| 619 |
(mail-encode-encoded-word-buffer))) |
|---|
| 620 |
(message-encode-message-body))) |
|---|
| 621 |
(let* ((func (car (gnus-group-name-to-method group))) |
|---|
| 622 |
(result (funcall (intern (format "%s-request-replace-article" func)) |
|---|
| 623 |
article (gnus-group-real-name group) buffer))) |
|---|
| 624 |
(when (and gnus-agent (gnus-agent-method-p gnus-command-method)) |
|---|
| 625 |
(gnus-agent-regenerate-group group (list article))) |
|---|
| 626 |
result)) |
|---|
| 627 |
|
|---|
| 628 |
(defun gnus-request-associate-buffer (group) |
|---|
| 629 |
(let ((gnus-command-method (gnus-find-method-for-group group))) |
|---|
| 630 |
(funcall (gnus-get-function gnus-command-method 'request-associate-buffer) |
|---|
| 631 |
(gnus-group-real-name group)))) |
|---|
| 632 |
|
|---|
| 633 |
(defun gnus-request-restore-buffer (article group) |
|---|
| 634 |
"Request a new buffer restored to the state of ARTICLE." |
|---|
| 635 |
(let ((gnus-command-method (gnus-find-method-for-group group))) |
|---|
| 636 |
(funcall (gnus-get-function gnus-command-method 'request-restore-buffer) |
|---|
| 637 |
article (gnus-group-real-name group) |
|---|
| 638 |
(nth 1 gnus-command-method)))) |
|---|
| 639 |
|
|---|
| 640 |
(defun gnus-request-create-group (group &optional gnus-command-method args) |
|---|
| 641 |
(when (stringp gnus-command-method) |
|---|
| 642 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 643 |
(let ((gnus-command-method |
|---|
| 644 |
(or gnus-command-method (gnus-find-method-for-group group)))) |
|---|
| 645 |
(funcall (gnus-get-function gnus-command-method 'request-create-group) |
|---|
| 646 |
(gnus-group-real-name group) (nth 1 gnus-command-method) args))) |
|---|
| 647 |
|
|---|
| 648 |
(defun gnus-request-delete-group (group &optional force) |
|---|
| 649 |
(let* ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 650 |
(result |
|---|
| 651 |
(funcall (gnus-get-function gnus-command-method 'request-delete-group) |
|---|
| 652 |
(gnus-group-real-name group) force (nth 1 gnus-command-method)))) |
|---|
| 653 |
(when result |
|---|
| 654 |
(gnus-cache-delete-group group) |
|---|
| 655 |
(gnus-agent-delete-group group)) |
|---|
| 656 |
result)) |
|---|
| 657 |
|
|---|
| 658 |
(defun gnus-request-rename-group (group new-name) |
|---|
| 659 |
(let* ((gnus-command-method (gnus-find-method-for-group group)) |
|---|
| 660 |
(result |
|---|
| 661 |
(funcall (gnus-get-function gnus-command-method 'request-rename-group) |
|---|
| 662 |
(gnus-group-real-name group) |
|---|
| 663 |
(gnus-group-real-name new-name) (nth 1 gnus-command-method)))) |
|---|
| 664 |
(when result |
|---|
| 665 |
(gnus-cache-rename-group group new-name) |
|---|
| 666 |
(gnus-agent-rename-group group new-name)) |
|---|
| 667 |
result)) |
|---|
| 668 |
|
|---|
| 669 |
(defun gnus-close-backends () |
|---|
| 670 |
|
|---|
| 671 |
(let ((methods gnus-valid-select-methods) |
|---|
| 672 |
(gnus-inhibit-demon t) |
|---|
| 673 |
func gnus-command-method) |
|---|
| 674 |
(while (setq gnus-command-method (pop methods)) |
|---|
| 675 |
(when (fboundp (setq func (intern |
|---|
| 676 |
(concat (car gnus-command-method) |
|---|
| 677 |
"-request-close")))) |
|---|
| 678 |
(funcall func))))) |
|---|
| 679 |
|
|---|
| 680 |
(defun gnus-asynchronous-p (gnus-command-method) |
|---|
| 681 |
(let ((func (gnus-get-function gnus-command-method 'asynchronous-p t))) |
|---|
| 682 |
(when (fboundp func) |
|---|
| 683 |
(funcall func)))) |
|---|
| 684 |
|
|---|
| 685 |
(defun gnus-remove-denial (gnus-command-method) |
|---|
| 686 |
(when (stringp gnus-command-method) |
|---|
| 687 |
(setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
|---|
| 688 |
(let* ((elem (assoc gnus-command-method gnus-opened-servers)) |
|---|
| 689 |
(status (cadr elem))) |
|---|
| 690 |
|
|---|
| 691 |
(when (eq status 'denied) |
|---|
| 692 |
|
|---|
| 693 |
(setcar (cdr elem) 'closed)))) |
|---|
| 694 |
|
|---|
| 695 |
(provide 'gnus-int) |
|---|
| 696 |
|
|---|
| 697 |
|
|---|
| 698 |
|
|---|
| 699 |
|
|---|