aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-08-23 09:21:47 +0200
committerGravatar Tom Willemsen2012-08-23 09:21:47 +0200
commite8a8a700a45c87c91c1a42d66386b0eee03a536c (patch)
tree2c17e4bc2e7dcfb735deb637b43506bbfc8b2331
parentbc17d8749771922b4557ebcfedbf59b71fd44bf3 (diff)
downloadavandu-e8a8a700a45c87c91c1a42d66386b0eee03a536c.tar.gz
avandu-e8a8a700a45c87c91c1a42d66386b0eee03a536c.zip
Add raw option to avandu--send-command-sync
This is useful for functions that need to check something outside of the "content" list of the result. Probably all of them should though. * avandu.el (avandu--send-command-sync): New parameter: raw. Return the content part of the results if RAW is nil, otherwise return the results onmodified. (avandu-login): Pass a RAW argument to `avandu--send-command-sync'.
-rw-r--r--avandu.el13
1 files changed, 8 insertions, 5 deletions
diff --git a/avandu.el b/avandu.el
index 78a7b6a..ec10823 100644
--- a/avandu.el
+++ b/avandu.el
@@ -368,7 +368,7 @@ FUNC should be a callback function as defined by
(unless (url-retrieve avandu-tt-rss-api-url func)
(message "Complete."))))
-(defun avandu--send-command-sync (data)
+(defun avandu--send-command-sync (data &optional raw)
"Send a command with parameters DATA to tt-rss. The current
session-id is added to the request and then DATA is passed on to
`json-encode'.
@@ -378,8 +378,9 @@ For example:
(avandu--send-command-sync '((op . \"isLoggedIn\")))
-This function returns the result of `json-read' passed over the
-returned json."
+This function returns the content part of the result of
+`json-read' passed over the returned json, unless RAW is non-nil,
+in which case the result is returned as-is."
(let* ((url-request-data (avandu--prep-params data))
(url-request-method "POST")
(buffer (url-retrieve-synchronously avandu-tt-rss-api-url))
@@ -389,7 +390,9 @@ returned json."
(search-forward "\n\n")
(setq result (json-read)))
(kill-buffer buffer)
- (avu-prop result content)))
+ (if (not raw)
+ (avu-prop result content)
+ result)))
(defun avandu-categories (&optional unread)
"Get the created categories. If UNREAD is non-nil only get
@@ -554,7 +557,7 @@ otherwise."
(let ((result (avandu--send-command-sync
`((op . "login")
(user . ,avandu-user)
- (password . ,(avandu--password))))))
+ (password . ,(avandu--password))) t)))
(if (eq (avandu--get-status-id result) 0)
(progn
(setq avandu--session-id (avandu--get-session-id result))