1 ;;; gnus-cloud.el --- storing and retrieving data via IMAP
3 ;; Copyright (C) 2014 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 (eval-when-compile (require 'cl))
29 (defgroup gnus-cloud nil
30 "Syncing Gnus data via IMAP."
33 (defcustom gnus-cloud-synced-files '("~/\\.authinfo"
37 "List of file regexps that should be kept up-to-date via the cloud."
39 :type '(repeat regexp))
41 (defvar gnus-cloud-version "0.1")
43 (defun gnus-cloud-make-chunk (elems)
45 (insert (format "Version %s\n" gnus-cloud-version))
46 (insert (gnus-cloud-insert-data elems))))
48 (defun gnus-cloud-insert-data (elems)
49 (mm-with-unibyte-buffer
52 ((eq (car elem) :file)
54 (mm-with-unibyte-buffer
55 (insert-file-contents-literally (cadr elem))
56 (setq length (buffer-size)
57 data (buffer-string)))
58 (insert (format "file %S %s %d\n"
61 "%FT%T%z" (nth 5 (file-attributes (cadr elem))))
65 ((eq (car elem) :buffer)
66 (insert (format "data %S %d\n" (cadr elem)
67 (with-current-buffer (caddr elem)
69 (insert-buffer-substring (caddr elem))
71 (gnus-cloud-encode-data)
74 (defun gnus-cloud-encode-data ()
75 (call-process-region (point-min) (point-max) "gzip"
76 t (current-buffer) nil
78 (base64-encode-region (point-min) (point-max)))
80 (defun gnus-cloud-decode-data ()
81 (base64-decode-region (point-min) (point-max))
82 (call-process-region (point-min) (point-max) "gunzip"
83 t (current-buffer) nil
86 (defun gnus-cloud-parse-chunk ()
91 ;;; gnus-cloud.el ends here