aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Silva <psilva+git@pedrosilva.pt>2013-04-02 11:57:43 +0100
committerPedro Silva <psilva+git@pedrosilva.pt>2013-04-02 11:57:43 +0100
commit5cde1d497d47664226a01a2068dc11d758d02b6f (patch)
tree54ad0bf28a23cf1a648d539f0221de529eba91f5
parentea0ae945fa4168e01669973e1cb31c2834db9377 (diff)
Implement nnttrss-{login,logout,logged-in-p}
-rw-r--r--nnttrss.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/nnttrss.el b/nnttrss.el
index 41a217d..52856ad 100644
--- a/nnttrss.el
+++ b/nnttrss.el
@@ -39,6 +39,29 @@ JSON object. Returns the JSON response as a plist or nil."
(if (= status 0) content
(nnheader-report 'nnttrss (plist-get content :error)))))))
+(defun nnttrss-login (address user password)
+ "Login to the server at ADDRESS using USER and PASSWORD
+credentials. Returns a session id string or nil."
+ (let ((response (nnttrss-post-request `(:op "login"
+ :user ,user
+ :password ,password)
+ address)))
+ (plist-get response :session_id)))
+
+(defun nnttrss-logout (address session-id)
+ "Logout of the server at ADDRESS using SESSION-ID credentials."
+ (nnttrss-post-request `(:op "logout"
+ :sid ,session-id)
+ address))
+
+(defun nnttrss-logged-in-p (address session-id)
+ "Return t if there is a valid session at ADDRESS with
+ SESSION-ID, false otherwise."
+ (let ((response (nnttrss-post-request `(:op "isLoggedIn"
+ :sid ,session-id)
+ address)))
+ (plist-get response :status)))
+
(gnus-declare-backend "nnttrss" 'address 'prompt-address)