commit 7749ea37e2204edae4e168b41629c50b4da15677
parent 1c2cef7a1c3ec811ee92b59b8e9f0b59c9b6d308
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Mon, 13 Oct 2008 18:14:29 -0700
add #mark_as_deleted and #expunge to Redwood::IMAP. completely untested!
Ditz-issue: 2673f091c15dd90222a59621a1842d4ef0a743f7
Diffstat:
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/bugs/issue-2673f091c15dd90222a59621a1842d4ef0a743f7.yaml b/bugs/issue-2673f091c15dd90222a59621a1842d4ef0a743f7.yaml
@@ -0,0 +1,19 @@
+--- !ditz.rubyforge.org,2008-03-06/issue
+title: make sup-sync-back work on IMAP folders
+desc: ""
+type: :feature
+component: sup-sync-back
+release:
+reporter: William Morgan <wmorgan-sup@masanjin.net>
+status: :unstarted
+disposition:
+creation_time: 2008-10-14 01:14:08.690909 Z
+references: []
+
+id: 2673f091c15dd90222a59621a1842d4ef0a743f7
+log_events:
+- - 2008-10-14 01:14:09.898338 Z
+ - William Morgan <wmorgan-sup@masanjin.net>
+ - created
+ - ""
+git_branch:
diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb
@@ -114,6 +114,19 @@ class IMAP < Source
end
synchronized :raw_message
+ def mark_as_deleted ids
+ ids = [ids].flatten # accept single arguments
+ unsynchronized_scan_mailbox
+ imap_ids = ids.map { |i| @imap_state[i] && @imap_state[i][:id] }.compact
+ @imap.store imap_ids, "+FLAGS", [:Deleted]
+ end
+ synchronized :mark_as_deleted
+
+ def expunge
+ @imap.expunge
+ end
+ synchronized :expunge
+
def connect
return if @imap
safely { } # do nothing!
@@ -259,7 +272,7 @@ private
%w(RFC822.SIZE INTERNALDATE).each do |w|
raise FatalSourceError, "requested data not in IMAP response: #{w}" unless imap_stuff.attr[w]
end
-
+
msize, mdate = imap_stuff.attr['RFC822.SIZE'] % 10000000, Time.parse(imap_stuff.attr["INTERNALDATE"])
sprintf("%d%07d", mdate.to_i, msize).to_i
end