Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[bpt/emacs.git] / lisp / gnus / gnus-sync.el
index e2a71f0..8cf92df 100644 (file)
@@ -1,6 +1,6 @@
 ;;; gnus-sync.el --- synchronization facility for Gnus
 
-;; Copyright (C) 2010-201 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <tzz@lifelogs.com>
 ;; Keywords: news synchronization nntp nnrss
@@ -88,7 +88,6 @@
 (require 'gnus)
 (require 'gnus-start)
 (require 'gnus-util)
-(require 'gmm-utils)
 
 (defvar gnus-topic-alist) ;; gnus-group.el
 (eval-when-compile
@@ -139,6 +138,11 @@ and `gnus-topic-alist'.  Also see `gnus-variable-list'."
 (defvar gnus-sync-newsrc-loader nil
   "Carrier for newsrc data")
 
+(defcustom gnus-sync-file-encrypt-to nil
+  "If non-nil, `epa-file-encrypt-to' is set from this for encrypting the Sync
+  file."
+  :group 'gnus-sync)
+
 (defcustom gnus-sync-lesync-name (system-name)
   "The LeSync name for this machine."
   :group 'gnus-sync
@@ -177,16 +181,15 @@ and `gnus-topic-alist'.  Also see `gnus-variable-list'."
 (defun gnus-sync-lesync-call (url method headers &optional kvdata)
   "Make an access request to URL using KVDATA and METHOD.
 KVDATA must be an alist."
-  (gmm-flet ((json-alist-p (list) (gnus-sync-json-alist-p list))) ; temp patch
-    (let ((url-request-method method)
-          (url-request-extra-headers headers)
-          (url-request-data (if kvdata (json-encode kvdata) nil)))
-      (with-current-buffer (url-retrieve-synchronously url)
-        (let ((data (gnus-sync-lesync-parse)))
-          (gnus-message 12 "gnus-sync-lesync-call: %s URL %s sent %S got %S"
-                        method url `((headers . ,headers) (data ,kvdata)) data)
-          (kill-buffer (current-buffer))
-          data)))))
+  (let ((url-request-method method)
+       (url-request-extra-headers headers)
+       (url-request-data (if kvdata (json-encode kvdata) nil)))
+    (with-current-buffer (url-retrieve-synchronously url)
+      (let ((data (gnus-sync-lesync-parse)))
+       (gnus-message 12 "gnus-sync-lesync-call: %s URL %s sent %S got %S"
+                     method url `((headers . ,headers) (data ,kvdata)) data)
+       (kill-buffer (current-buffer))
+       data))))
 
 (defun gnus-sync-lesync-PUT (url headers &optional data)
   (gnus-sync-lesync-call url "PUT" headers data))
@@ -764,6 +767,9 @@ With a prefix, FORCE is set and all groups will be saved."
         (progn
           (let ((coding-system-for-write gnus-ding-file-coding-system)
                 (standard-output (current-buffer)))
+            (when gnus-sync-file-encrypt-to
+              (set (make-local-variable 'epa-file-encrypt-to)
+                   gnus-sync-file-encrypt-to))
             (princ (format ";; -*- mode:emacs-lisp; coding: %s; -*-\n"
                            gnus-ding-file-coding-system))
             (princ ";; Gnus sync data v. 0.0.1\n")