Function: gnus-open-server
gnus-open-server is an autoloaded and byte-compiled function defined
in gnus-int.el.gz.
Signature
(gnus-open-server COMMAND-METHOD)
Documentation
Open a connection to COMMAND-METHOD.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-int.el.gz
(defun gnus-open-server (command-method)
"Open a connection to COMMAND-METHOD."
(gnus-backend-trace :opening gnus-command-method)
(let* ((gnus-command-method (if (stringp command-method)
(gnus-server-to-method command-method)
command-method))
(elem (assoc gnus-command-method gnus-opened-servers))
(server (gnus-method-to-server-name gnus-command-method)))
;; If this method was previously denied, we just return nil.
(if (eq (nth 1 elem) 'denied)
(progn
(gnus-message
1 "Server %s previously determined to be down; not retrying" server)
nil)
;; Open the server.
(let* ((open-server-function
(gnus-get-function gnus-command-method 'open-server))
(result
(condition-case err
(funcall open-server-function
(nth 1 gnus-command-method)
(nthcdr 2 gnus-command-method))
(error
(gnus-message 1 "Unable to open server %s due to: %s"
server (error-message-string err))
nil)
(quit
(if debug-on-quit
(debug "Quit")
(gnus-message 1 "Quit trying to open server %s" server))
nil)))
open-offline)
;; If this hasn't been opened before, we add it to the list.
(unless elem
(setq elem (list gnus-command-method nil)
gnus-opened-servers (cons elem gnus-opened-servers)))
;; Set the status of this server.
(setcar
(cdr elem)
(cond (result
(if (eq open-server-function 'nnagent-open-server)
;; The agent's backend has a "special" status
'offline
'ok))
((and gnus-agent
(gnus-agent-method-p gnus-command-method))
(cond
(gnus-server-unopen-status
;; Set the server's status to the unopen
;; status. If that status is offline,
;; recurse to open the agent's backend.
(setq open-offline (eq gnus-server-unopen-status 'offline))
gnus-server-unopen-status)
((not gnus-batch-mode)
(setq open-offline t)
'offline)
(t
;; This agentized server was still denied
'denied)))
(t
;; This unagentized server must be denied
'denied)))
;; NOTE: I MUST set the server's status to offline before this
;; recursive call as this status will drive the
;; gnus-get-function (called above) to return the agent's
;; backend.
(if open-offline
;; Recursively open this offline server to perform the
;; open-server function of the agent's backend.
(let ((gnus-server-unopen-status 'denied))
;; Bind gnus-server-unopen-status to avoid recursively
;; prompting with "go offline?". This is only a concern
;; when the agent's backend fails to open the server.
(gnus-open-server gnus-command-method))
(when (and (eq (cadr elem) 'ok) gnus-agent
(gnus-agent-method-p gnus-command-method))
(save-excursion
(gnus-agent-possibly-synchronize-flags-server
gnus-command-method)))
(gnus-backend-trace :opened gnus-command-method)
result)))))