sup 0.14.1.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,9 @@ Rich Lane <rlane at the club.cc.cmu dot edus>
3
3
  Gaute Hope <eg at the gaute.vetsj dot coms>
4
4
  Whyme Lyu <callme5long at the gmail dot coms>
5
5
  Hamish Downer <dmishd at the gmail dot coms>
6
+ Damien Leone <damien.leone at the fensalir dot frs>
6
7
  Sascha Silbe <sascha-pgp at the silbe dot orgs>
8
+ Eric Weikl <eric.weikl at the gmx dot nets>
7
9
  Ismo Puustinen <ismo at the iki dot fis>
8
10
  Nicolas Pouillard <nicolas.pouillard at the gmail dot coms>
9
11
  Michael Stapelberg <michael at the stapelberg dot des>
@@ -15,28 +17,27 @@ Clint Byrum <clint at the ubuntu dot coms>
15
17
  Marcus Williams <marcus-sup at the bar-coded dot nets>
16
18
  Lionel Ott <white.magic at the gmx dot des>
17
19
  Gaudenz Steinlin <gaudenz at the soziologie dot chs>
18
- Damien Leone <damien.leone at the fensalir dot frs>
19
20
  Ingmar Vanhassel <ingmar at the exherbo dot orgs>
20
21
  Mark Alexander <marka at the pobox dot coms>
21
- Eric Weikl <eric.weikl at the gmx dot nets>
22
+ Edward Z. Yang <ezyang at the mit dot edus>
23
+ Matthieu Rakotojaona <matthieu.rakotojaona at the gmail dot coms>
22
24
  Christopher Warrington <chrisw at the rice dot edus>
23
25
  W. Trevor King <wking at the drexel dot edus>
24
26
  Richard Brown <rbrown at the exherbo dot orgs>
25
27
  Anthony Martinez <pi+sup at the pihost dot uss>
26
28
  Marc Hartstein <marc.hartstein at the alum.vassar dot edus>
27
29
  Israel Herraiz <israel.herraiz at the gmail dot coms>
28
- Matthieu Rakotojaona <matthieu.rakotojaona at the gmail dot coms>
29
30
  Bo Borgerson <gigabo at the gmail dot coms>
30
31
  Michael Hamann <michael at the content-space dot des>
31
- Jonathan Lassoff <jof at the thejof dot coms>
32
32
  William Erik Baxter <web at the superscript dot coms>
33
+ Jonathan Lassoff <jof at the thejof dot coms>
33
34
  Grant Hollingworth <grant at the antiflux dot orgs>
35
+ Adeodato Simó <dato at the net.com.org dot ess>
34
36
  Ico Doornekamp <ico at the pruts dot nls>
35
37
  Markus Klinik <markus.klinik at the gmx dot des>
36
- Adeodato Simó <dato at the net.com.org dot ess>
37
38
  Daniel Schoepe <daniel.schoepe at the googlemail dot coms>
39
+ James Taylor <james at the jamestaylor dot orgs>
38
40
  Jason Petsod <jason at the petsod dot orgs>
39
- Edward Z. Yang <edwardzyang at the thewritingpot dot coms>
40
41
  Steve Goldman <sgoldman at the tower-research dot coms>
41
42
  Robin Burchell <viroteck at the viroteck dot nets>
42
43
  Peter Harkins <ph at the malaprop dot orgs>
@@ -44,25 +45,27 @@ Decklin Foster <decklin at the red-bean dot coms>
44
45
  Cameron Matheson <cam+sup at the cammunism dot orgs>
45
46
  Carl Worth <cworth at the cworth dot orgs>
46
47
  Alex Vandiver <alex at the chmrr dot nets>
47
- Jeff Balogh <its.jeff.balogh at the gmail dot coms>
48
48
  Andrew Pimlott <andrew at the pimlott dot nets>
49
+ Jeff Balogh <its.jeff.balogh at the gmail dot coms>
49
50
  Matías Aguirre <matiasaguirre at the gmail dot coms>
50
51
  Kornilios Kourtis <kkourt at the cslab.ece.ntua dot grs>
51
- Kevin Riggle <kevinr at the free-dissociation dot coms>
52
52
  Giorgio Lando <patroclo7 at the gmail dot coms>
53
+ Kevin Riggle <kevinr at the free-dissociation dot coms>
53
54
  Benoît PIERRE <benoit.pierre at the gmail dot coms>
54
55
  Alvaro Herrera <alvherre at the alvh.no-ip dot orgs>
55
56
  Steven Lawrance <stl at the koffein dot nets>
56
57
  Jonah <Jonah at the GoodCoffee dot cas>
57
58
  ian <itaylor at the uark dot edus>
58
59
  Adam Lloyd <adam at the alloy-d dot nets>
59
- Todd Eisenberger <teisenbe at the andrew.cmu dot edus>
60
60
  Gregor Hoffleit <gregor at the sam.mediasupervision dot des>
61
- MichaelRevell <mikearevell at the gmail dot coms>
61
+ 0xACE <0xACE at the users.noreply.github dot coms>
62
62
  Per Andersson <avtobiff at the gmail dot coms>
63
+ MichaelRevell <mikearevell at the gmail dot coms>
64
+ Todd Eisenberger <teisenbe at the andrew.cmu dot edus>
63
65
  Steven Walter <swalter at the monarch.(none)>
64
66
  Matthias Vallentin <vallentin at the icir dot orgs>
67
+ akojo <atte.kojo at the gmail dot coms>
65
68
  Jon M. Dugan <jdugan at the es dot nets>
66
- Stefan Lundström <lundst at the snabb.(none)>
67
69
  Horacio Sanson <horacio at the skillupjapan.co dot jps>
70
+ Stefan Lundström <lundst at the snabb.(none)>
68
71
  Kirill Smelkov <kirr at the landau.phys.spbu dot rus>
@@ -1,3 +1,47 @@
1
+ == 0.15.0 / 2013-11-07
2
+
3
+ * Maildir Syncback has now been merged into main sup! This is a
4
+ long-time waiting feature initially developed by Damien Leone,
5
+ then picked up by Edward Z. Yang who continued development. Additionally
6
+ several others have been contributing.
7
+
8
+ Eventually, recently, Eric Weikl has picked up this branch, modernized
9
+ it to current sup, maintained it and gotten it ready for release.
10
+
11
+ Main authors:
12
+
13
+ Damien Leone
14
+ Edward Z. Yang
15
+ Eric Weikl
16
+
17
+ Not all of the features initially proposed have been included. This is
18
+ to maintain compatibility with more operating systems and wait with
19
+ the more daring features to make sure sup is stable-ish.
20
+
21
+ This is a big change since sup now can modify your mail (!), please
22
+ back up your mail and your configuration before using the maildir
23
+ syncback feature. For instructions on how to migrate an existing
24
+ maildir source or how to set up a new one, refer to the wiki:
25
+
26
+ https://github.com/sup-heliotrope/sup/wiki/Using-sup-with-other-clients
27
+
28
+ It is possible to both disable maildir syncback globally (default:
29
+ disabled) and per-source (default: enabled).
30
+
31
+ * Sup on Ruby 2.0.0 now works - but beware, this has not been very throughly
32
+ tested. Patches are welcome.
33
+
34
+ * We are now using our own rmail-sup gem with fixes for Ruby 2.0.0 and
35
+ various warnings fixed.
36
+
37
+ * sup-sync-back has been renamed to sup-sync-back-mbox to conform with
38
+ the other sync-back scripts.
39
+
40
+ * You can now save attachments to directories without specifying the full
41
+ filename (default filename is used).
42
+
43
+ * Various encoding fixes and minor bug fixes
44
+
1
45
  == 0.14.1.1 / 2013-10-29
2
46
 
3
47
  * SBU1: security release
data/README.md CHANGED
@@ -18,12 +18,16 @@ Features:
18
18
  * [Ruby-programmable hooks][hooks]
19
19
  * Automatically tracking recent contacts
20
20
 
21
- Current limitations which will be fixed:
21
+ Current limitations:
22
22
 
23
- * [Doesn't run on Ruby 2.0][ruby20]
23
+ * [Ruby 2.0 support][ruby20] is very fresh, consider it experimental. Patches
24
+ are welcome
24
25
 
25
- * Sup doesn't play nicely with other mail clients. Changes in Sup won't be
26
- synced back to mail source.
26
+ * Sup does in general not play nicely with other mail clients, not all
27
+ changes can be synced back to the mail source. Refer to [Maildir Syncback][maildir-syncback]
28
+ in the wiki for this recently included feature. Maildir Syncback
29
+ allows you to sync back flag changes in messages and to write messages
30
+ to maildir sources.
27
31
 
28
32
  * Unix-centrism in MIME attachment handling and in sendmail invocation.
29
33
 
@@ -68,3 +72,4 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
68
72
  [ruby20]: https://github.com/sup-heliotrope/sup/wiki/Development#sup-014
69
73
  [sup-talk]: http://rubyforge.org/mailman/listinfo/sup-talk
70
74
  [sup-devel]: http://rubyforge.org/mailman/listinfo/sup-devel
75
+ [maildir-syncback]: https://github.com/sup-heliotrope/sup/wiki/Using-sup-with-other-clients
@@ -1,3 +1,11 @@
1
+ Release 0.15.0:
2
+
3
+ Maildir Syncback has been included. Refer to the wiki for more information on
4
+ how to set it up.
5
+
6
+ sup-sync-back has been moved to sup-sync-back-mbox, please make sure
7
+ you make any needed changes.
8
+
1
9
  Release 0.14.1.1:
2
10
 
3
11
  See 0.13.2.1.
data/bin/sup CHANGED
@@ -153,6 +153,7 @@ Index.lock_interactively or exit
153
153
  begin
154
154
  Redwood::start
155
155
  Index.load
156
+ Redwood::check_syncback_settings
156
157
  Index.start_sync_worker unless $opts[:no_threads]
157
158
 
158
159
  $die = false
@@ -30,6 +30,7 @@ Options are:
30
30
  EOS
31
31
  opt :archive, "Automatically archive all new messages from these sources."
32
32
  opt :unusual, "Do not automatically poll these sources for new messages."
33
+ opt :sync_back, "Synchronize status flags back into messages, defaults to true (Maildir sources only).", :default => true
33
34
  opt :labels, "A comma-separated set of labels to apply to all messages from this source", :type => String
34
35
  opt :force_new, "Create a new account for this source, even if one already exists."
35
36
  opt :force_account, "Reuse previously defined account user@hostname.", :type => String
@@ -99,7 +100,7 @@ begin
99
100
  source =
100
101
  case parsed_uri.scheme
101
102
  when "maildir"
102
- Redwood::Maildir.new uri, !$opts[:unusual], $opts[:archive], nil, labels
103
+ Redwood::Maildir.new uri, !$opts[:unusual], $opts[:archive], $opts[:sync_back], nil, labels
103
104
  when "mbox"
104
105
  Redwood::MBox.new uri, !$opts[:unusual], $opts[:archive], nil, labels
105
106
  when nil
@@ -88,6 +88,8 @@ def add_source
88
88
  usual = axe_yes "Does this source ever receive new messages?", "y"
89
89
  archive = usual ? axe_yes("Should new messages be automatically archived? (I.e. not appear in your inbox, though still be accessible via search.)") : false
90
90
 
91
+ sync_back = (type == :maildir) ? axe_yes("Should the original Maildir messages be modified to reflect changes like read status, starred messages, etc.?", "y") : false
92
+
91
93
  labels_str = axe("Enter any labels to be automatically added to all messages from this source, separated by spaces (or 'none')", default_labels.join(","))
92
94
 
93
95
  labels = if labels_str =~ /^\s*none\s*$/i
@@ -99,6 +101,7 @@ def add_source
99
101
  cmd = build_cmd "sup-add"
100
102
  cmd += " --unusual" unless usual
101
103
  cmd += " --archive" if archive
104
+ cmd += " --no-sync-back" unless sync_back
102
105
  cmd += " --labels=#{labels.join(',')}" if labels && !labels.empty?
103
106
  cmd += " #{uri}"
104
107
 
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
5
+
6
+ require 'rubygems'
7
+ require 'trollop'
8
+ require "sup"
9
+
10
+ opts = Trollop::options do
11
+ version "sup-sync-back-maildir (sup #{Redwood::VERSION})"
12
+ banner <<EOS
13
+ Export Xapian entries to Maildir sources on disk.
14
+
15
+ This script parses the Xapian entries for a given Maildir source and renames
16
+ (changes maildir flags) e-mail files on disk according to the labels stored in
17
+ the index. It will export all the changes you made in Sup to your
18
+ Maildirs so that they can be propagated to your IMAP server with e.g. offlineimap.
19
+
20
+ The script also merges some Maildir flags into Sup such
21
+ as R (replied) and P (passed, forwarded), for instance suppose you
22
+ have an e-mail file like this: foo_bar:2,FRS (flags are favorite,
23
+ replied, seen) and its Xapian entry has labels 'starred', the merge
24
+ operation will add the 'replied' label to the Xapian entry.
25
+
26
+ If you choose not to merge (-m) you will lose information ('replied'), and in
27
+ the previous example the file will be renamed to foo_bar:2,FS.
28
+
29
+ Running this script is *strongly* recommended when setting the
30
+ "sync_back_to_maildir" option from false to true in config.yaml or changing the
31
+ "sync_back" flag to true for a source in sources.yaml.
32
+
33
+ Usage:
34
+ sup-sync-back-maildir [options] <source>*
35
+
36
+ where <source>* is source URIs. If no source is given, the default behavior is
37
+ to sync back all Maildir sources marked as usual and that have not disabled
38
+ sync back using the configuration parameter sync_back = false in sources.yaml.
39
+
40
+ Options include:
41
+ EOS
42
+ opt :no_confirm, "Don't ask for confirmation before synchronizing", :default => false, :short => "n"
43
+ opt :no_merge, "Don't merge new supported Maildir flags (R and P)", :default => false, :short => "m"
44
+ opt :list_sources, "List your Maildir sources and exit", :default => false, :short => "l"
45
+ opt :unusual_sources_too, "Sync unusual sources too if no specific source information is given", :default => false, :short => "u"
46
+ end
47
+
48
+ def die msg
49
+ $stderr.puts "Error: #{msg}"
50
+ exit(-1)
51
+ end
52
+
53
+ Redwood::start true
54
+ index = Redwood::Index.init
55
+ index.lock_interactively or exit
56
+ index.load
57
+
58
+ ## Force sync_back_to_maildir option otherwise nothing will happen
59
+ $config[:sync_back_to_maildir] = true
60
+
61
+ begin
62
+ sync_performed = []
63
+ sync_performed = File.readlines(Redwood::SYNC_OK_FN).collect { |e| e.strip }.find_all { |e| not e.empty? } if File.exists? Redwood::SYNC_OK_FN
64
+ sources = []
65
+
66
+ ## Try to find out sources given in parameters
67
+ sources = ARGV.map do |uri|
68
+ s = Redwood::SourceManager.source_for(uri) or die "unknown source: #{uri}. Did you add it with sup-add first?"
69
+ s.is_a?(Redwood::Maildir) or die "#{uri} is not a Maildir source."
70
+ s.sync_back_enabled? or die "#{uri} has disabled sync back - check your configuration."
71
+ s
72
+ end unless opts[:list_sources]
73
+
74
+ ## Otherwise, check all sources in sources.yaml
75
+ if sources.empty? or opts[:list_sources] == true
76
+ if opts[:unusual_sources_too]
77
+ sources = Redwood::SourceManager.sources.select do |s|
78
+ s.is_a? Redwood::Maildir and s.sync_back_enabled?
79
+ end
80
+ else
81
+ sources = Redwood::SourceManager.usual_sources.select do |s|
82
+ s.is_a? Redwood::Maildir and s.sync_back_enabled?
83
+ end
84
+ end
85
+ end
86
+
87
+ if opts[:list_sources] == true
88
+ sources.each do |s|
89
+ puts "id: #{s.id}, uri: #{s.uri}"
90
+ end
91
+ else
92
+ sources.each do |s|
93
+ if opts[:no_confirm] == false
94
+ print "Are you sure you want to synchronize '#{s.uri}'? (Y/n) "
95
+ next if STDIN.gets.chomp.downcase == 'n'
96
+ end
97
+
98
+ infos = Enumerator.new(index, :each_source_info, s.id).to_a
99
+ counter = 0
100
+ infos.each do |info|
101
+ print "\rSynchronizing '#{s.uri}'... #{((counter += 1)/infos.size.to_f*100).to_i}%"
102
+ index.each_message({:location => [s.id, info]}, false) do |m|
103
+ if opts[:no_merge] == false
104
+ m.merge_labels_from_locations [:replied, :forwarded]
105
+ end
106
+
107
+ if Redwood::Index.message_joining_killed? m
108
+ m.labels += [:killed]
109
+ end
110
+
111
+ index.save_message m
112
+ end
113
+ end
114
+ print "\n"
115
+ sync_performed << s.uri
116
+ end
117
+ ## Write a flag file to tell sup that the synchronization has been performed
118
+ File.open(Redwood::SYNC_OK_FN, 'w') {|f| f.write(sync_performed.join("\n")) }
119
+ end
120
+ rescue Exception => e
121
+ File.open("sup-exception-log.txt", "w") { |f| f.puts e.backtrace }
122
+ raise
123
+ ensure
124
+ index.save_index
125
+ Redwood::finish
126
+ index.unlock
127
+ end
@@ -24,7 +24,7 @@ def has_any_from_source_with_label? index, source, label
24
24
  end
25
25
 
26
26
  opts = Trollop::options do
27
- version "sup-sync-back (sup #{Redwood::VERSION})"
27
+ version "sup-sync-back-mbox (sup #{Redwood::VERSION})"
28
28
  banner <<EOS
29
29
  Drop or move messages from Sup sources that are marked as deleted or
30
30
  spam in the Sup index.
@@ -32,7 +32,7 @@ spam in the Sup index.
32
32
  Currently only works with mbox sources.
33
33
 
34
34
  Usage:
35
- sup-sync-back [options] <source>*
35
+ sup-sync-back-mbox [options] <source>*
36
36
 
37
37
  where <source>* is zero or more source URIs. If no sources are given,
38
38
  sync back all usual sources.
@@ -112,7 +112,7 @@ EOS
112
112
  source.reset!
113
113
  num_dropped = num_moved = num_scanned = 0
114
114
 
115
- out_fp = Tempfile.new "sup-sync-back-#{source.id}"
115
+ out_fp = Tempfile.new "sup-sync-back-mbox-#{source.id}"
116
116
  Redwood::PollManager.each_message_from source do |m|
117
117
  num_scanned += 1
118
118
 
data/lib/sup.rb CHANGED
@@ -59,10 +59,12 @@ module Redwood
59
59
  HOOK_DIR = File.join(BASE_DIR, "hooks")
60
60
  SEARCH_FN = File.join(BASE_DIR, "searches.txt")
61
61
  LOG_FN = File.join(BASE_DIR, "log")
62
+ SYNC_OK_FN = File.join(BASE_DIR, "sync-back-ok")
62
63
 
63
64
  YAML_DOMAIN = "supmua.org"
64
65
  LEGACY_YAML_DOMAIN = "masanjin.net"
65
66
  YAML_DATE = "2006-10-01"
67
+ MAILDIR_SYNC_CHECK_SKIPPED = 'SKIPPED'
66
68
 
67
69
  ## record exceptions thrown in threads nicely
68
70
  @exceptions = []
@@ -157,7 +159,7 @@ module Redwood
157
159
  SourceManager SearchManager IdleManager).map { |x| Redwood.const_get x.to_sym }
158
160
  end
159
161
 
160
- def start
162
+ def start bypass_sync_check = false
161
163
  managers.each { |x| fail "#{x} already instantiated" if x.instantiated? }
162
164
 
163
165
  FileUtils.mkdir_p Redwood::BASE_DIR
@@ -173,6 +175,74 @@ module Redwood
173
175
  Redwood::SearchManager.init Redwood::SEARCH_FN
174
176
 
175
177
  managers.each { |x| x.init unless x.instantiated? }
178
+
179
+ return if bypass_sync_check
180
+
181
+ if $config[:sync_back_to_maildir]
182
+ if not File.exists? Redwood::SYNC_OK_FN
183
+ Redwood.warn_syncback <<EOS
184
+ It appears that the "sync_back_to_maildir" option has been changed
185
+ from false to true since the last execution of sup.
186
+ EOS
187
+ $stderr.puts <<EOS
188
+
189
+ Should I complain about this again? (Y/n)
190
+ EOS
191
+ File.open(Redwood::SYNC_OK_FN, 'w') {|f| f.write(Redwood::MAILDIR_SYNC_CHECK_SKIPPED) } if STDIN.gets.chomp.downcase == 'n'
192
+ end
193
+ elsif not $config[:sync_back_to_maildir] and File.exists? Redwood::SYNC_OK_FN
194
+ File.delete(Redwood::SYNC_OK_FN)
195
+ end
196
+ end
197
+
198
+ def check_syncback_settings
199
+ # don't check if syncback was never performed
200
+ return unless File.exists? Redwood::SYNC_OK_FN
201
+ active_sync_sources = File.readlines(Redwood::SYNC_OK_FN).collect { |e| e.strip }.find_all { |e| not e.empty? }
202
+ return if active_sync_sources.length == 1 and active_sync_sources[0] == Redwood::MAILDIR_SYNC_CHECK_SKIPPED
203
+ sources = SourceManager.sources
204
+ newly_synced = sources.select { |s| s.is_a? Maildir and s.sync_back_enabled? and not active_sync_sources.include? s.uri }
205
+ unless newly_synced.empty?
206
+
207
+ details =<<EOS
208
+ It appears that the option "sync_back" of the following source(s)
209
+ has been changed from false to true since the last execution of
210
+ sup:
211
+
212
+ EOS
213
+ newly_synced.each do |s|
214
+ details += "#{s} (usual: #{s.usual})\n"
215
+ end
216
+
217
+ Redwood.warn_syncback details
218
+ end
219
+ end
220
+
221
+ def self.warn_syncback details
222
+ $stderr.puts <<EOS
223
+ WARNING
224
+ -------
225
+
226
+ #{details}
227
+
228
+ It is *strongly* recommended that you run "sup-sync-back-maildir"
229
+ before continuing, otherwise you might lose changes you have made in sup
230
+ to your Xapian index.
231
+
232
+ This script should be run each time you change the
233
+ "sync_back_to_maildir" flag in config.yaml from false to true or
234
+ the "sync_back" flag is changed to true for a source in sources.yaml.
235
+
236
+ Please run "sup-sync-back-maildir -h" for more information and why this
237
+ is needed.
238
+
239
+ Note that if you have any sources that are not marked as 'ususal' in
240
+ sources.yaml you need to manually specify them when running the
241
+ sup-sync-back-maildir script.
242
+
243
+ Are you really sure you want to continue? (y/N)
244
+ EOS
245
+ abort "Aborted" unless STDIN.gets.chomp.downcase == 'y'
176
246
  end
177
247
 
178
248
  def finish
@@ -262,7 +332,8 @@ EOM
262
332
  :wrap_width => 0,
263
333
  :slip_rows => 0,
264
334
  :col_jump => 2,
265
- :stem_language => "english"
335
+ :stem_language => "english",
336
+ :sync_back_to_maildir => false
266
337
  }
267
338
  if File.exists? filename
268
339
  config = Redwood::load_yaml_obj filename
@@ -303,7 +374,8 @@ EOM
303
374
  end
304
375
 
305
376
  module_function :save_yaml_obj, :load_yaml_obj, :start, :finish,
306
- :report_broken_sources, :load_config, :managers
377
+ :report_broken_sources, :load_config, :managers,
378
+ :check_syncback_settings
307
379
  end
308
380
 
309
381
  require 'sup/version'