sup 1.3 → 1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/checks.yml +10 -9
- data/.rubocop.yml +1 -1
- data/CONTRIBUTORS +2 -2
- data/History.txt +38 -0
- data/Manifest.txt +19 -1
- data/README.md +5 -3
- data/Rakefile +1 -1
- data/bin/sup +5 -3
- data/bin/sup-sync +1 -2
- data/contrib/nix/.gitignore +1 -0
- data/contrib/nix/Gemfile.lock +41 -34
- data/contrib/nix/gem-install-shell.nix +1 -1
- data/contrib/nix/gemset.nix +80 -58
- data/contrib/nix/ruby2.4-Gemfile.lock +1 -1
- data/contrib/nix/ruby2.4-gemset.nix +2 -2
- data/contrib/nix/ruby2.5-Gemfile.lock +1 -1
- data/contrib/nix/ruby2.5-gemset.nix +2 -2
- data/contrib/nix/ruby2.6-Gemfile.lock +1 -1
- data/contrib/nix/ruby2.6-gemset.nix +2 -2
- data/contrib/nix/ruby2.7-Gemfile.lock +1 -1
- data/contrib/nix/ruby2.7-gemset.nix +2 -2
- data/contrib/nix/ruby3.0-Gemfile.lock +1 -1
- data/contrib/nix/ruby3.0-gemset.nix +2 -2
- data/contrib/nix/ruby3.1-Gemfile.lock +101 -0
- data/contrib/nix/ruby3.1-gemset.nix +391 -0
- data/contrib/nix/ruby3.1-shell.nix +2 -13
- data/contrib/nix/ruby3.2-Gemfile.lock +101 -0
- data/contrib/nix/ruby3.2-gemset.nix +391 -0
- data/contrib/nix/ruby3.2-shell.nix +2 -13
- data/contrib/nix/ruby3.3-shell.nix +1 -12
- data/contrib/nix/ruby3.4-shell.nix +1 -10
- data/contrib/nix/ruby4.0-shell.nix +41 -0
- data/contrib/nix/test-all-rubies.sh +2 -1
- data/contrib/screenshot-generator/.gitignore +1 -0
- data/contrib/screenshot-generator/default.nix +253 -0
- data/contrib/screenshot-generator/scenes.yaml +51 -0
- data/contrib/screenshot-generator/shoot.rb +127 -0
- data/contrib/screenshot-generator/sup-is-plain-text-applied.msg +83 -0
- data/contrib/screenshot-generator/sup-is-plain-text.msg +78 -0
- data/lib/sup/account.rb +2 -0
- data/lib/sup/buffer.rb +14 -3
- data/lib/sup/contact.rb +3 -4
- data/lib/sup/draft.rb +15 -15
- data/lib/sup/index.rb +15 -5
- data/lib/sup/maildir.rb +21 -16
- data/lib/sup/mbox.rb +0 -10
- data/lib/sup/message.rb +5 -19
- data/lib/sup/message_chunks.rb +1 -25
- data/lib/sup/mode.rb +1 -0
- data/lib/sup/modes/contact_list_mode.rb +0 -1
- data/lib/sup/modes/edit_message_mode.rb +53 -5
- data/lib/sup/modes/label_search_results_mode.rb +1 -2
- data/lib/sup/modes/line_cursor_mode.rb +22 -20
- data/lib/sup/modes/search_results_mode.rb +0 -1
- data/lib/sup/modes/thread_index_mode.rb +28 -27
- data/lib/sup/modes/thread_view_mode.rb +1 -2
- data/lib/sup/person.rb +0 -6
- data/lib/sup/poll.rb +1 -4
- data/lib/sup/rfc2047.rb +5 -2
- data/lib/sup/sent.rb +5 -4
- data/lib/sup/source.rb +2 -47
- data/lib/sup/util.rb +2 -2
- data/lib/sup/version.rb +1 -1
- data/lib/sup.rb +1 -1
- data/man/sup-add.1 +6 -6
- data/man/sup-config.1 +6 -6
- data/man/sup-dump.1 +5 -5
- data/man/sup-import-dump.1 +7 -7
- data/man/sup-recover-sources.1 +5 -5
- data/man/sup-sync-back-maildir.1 +9 -9
- data/man/sup-sync.1 +11 -11
- data/man/sup-tweak-labels.1 +10 -10
- data/man/sup.1 +11 -11
- data/sup.gemspec +1 -1
- data/test/dummy_buffer.rb +34 -0
- data/test/dummy_source.rb +0 -4
- data/test/fixtures/contacts.txt +2 -1
- data/test/fixtures/folded-from-header.eml +8 -0
- data/test/fixtures/rfc2047-header-encoding.eml +2 -1
- data/test/fixtures/text-attachments-with-charset.eml +7 -0
- data/test/integration/test_draft.rb +128 -0
- data/test/integration/test_index.rb +62 -0
- data/test/integration/test_maildir.rb +2 -0
- data/test/integration/test_mbox.rb +2 -0
- data/test/integration/test_sup-add.rb +4 -0
- data/test/test_crypto.rb +7 -2
- data/test/test_header_parsing.rb +9 -9
- data/test/test_message.rb +22 -3
- data/test/unit/test_contact.rb +15 -3
- data/test/unit/test_edit_message_mode.rb +6 -1
- data/test/unit/test_index.rb +89 -0
- data/test/unit/test_line_cursor_mode.rb +214 -0
- data/test/unit/test_maildir.rb +21 -0
- metadata +30 -9
- data/man/sup-psych-ify-config-files.1 +0 -76
- data/shell.nix +0 -1
data/lib/sup/draft.rb
CHANGED
|
@@ -11,19 +11,19 @@ class DraftManager
|
|
|
11
11
|
|
|
12
12
|
def self.source_name; "sup://drafts"; end
|
|
13
13
|
def self.source_id; 9999; end
|
|
14
|
-
def new_source; @source = DraftLoader.new; end
|
|
14
|
+
def new_source; @source = DraftLoader.new @dir; end
|
|
15
15
|
|
|
16
16
|
def write_draft
|
|
17
17
|
offset = @source.gen_offset
|
|
18
18
|
fn = @source.fn_for_offset offset
|
|
19
|
-
File.open(fn, "w:
|
|
19
|
+
File.open(fn, "w", :encoding => $encoding) { |f| yield f }
|
|
20
20
|
PollManager.poll_from @source
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def discard m
|
|
24
24
|
raise ArgumentError, "not a draft: source id #{m.source.id.inspect}, should be #{DraftManager.source_id.inspect} for #{m.id.inspect}" unless m.source.id.to_i == DraftManager.source_id
|
|
25
25
|
Index.delete m.id
|
|
26
|
-
File.delete @source.fn_for_offset(m.source_info) rescue
|
|
26
|
+
File.delete @source.fn_for_offset(m.source_info) rescue Errno::ENOENT
|
|
27
27
|
UpdateManager.relay self, :single_message_deleted, m
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -32,7 +32,7 @@ class DraftLoader < Source
|
|
|
32
32
|
attr_accessor :dir
|
|
33
33
|
yaml_properties
|
|
34
34
|
|
|
35
|
-
def initialize dir
|
|
35
|
+
def initialize dir
|
|
36
36
|
Dir.mkdir dir unless File.exist? dir
|
|
37
37
|
super DraftManager.source_name, true, false
|
|
38
38
|
@dir = dir
|
|
@@ -70,22 +70,22 @@ class DraftLoader < Source
|
|
|
70
70
|
|
|
71
71
|
def fn_for_offset o; File.join(@dir, o.to_s); end
|
|
72
72
|
|
|
73
|
-
def load_header offset
|
|
74
|
-
File.open(fn_for_offset(offset)) { |f| parse_raw_email_header f }
|
|
75
|
-
end
|
|
76
|
-
|
|
77
73
|
def load_message offset
|
|
78
74
|
raise SourceError, "Draft not found" unless File.exist? fn_for_offset(offset)
|
|
79
|
-
File.open
|
|
80
|
-
RMail::
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
File.open(fn_for_offset(offset)) do |f|
|
|
76
|
+
message = RMail::Parser.read f
|
|
77
|
+
message.header.set "Content-Type", "text/plain; charset=#{$encoding}"
|
|
78
|
+
message
|
|
83
79
|
end
|
|
84
80
|
end
|
|
85
81
|
|
|
82
|
+
def fallback_date_for_message offset
|
|
83
|
+
File.mtime fn_for_offset(offset)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
86
|
def raw_header offset
|
|
87
87
|
ret = ""
|
|
88
|
-
File.open(fn_for_offset(offset), "r
|
|
88
|
+
File.open(fn_for_offset(offset), "r") do |f|
|
|
89
89
|
until f.eof? || (l = f.gets) =~ /^$/
|
|
90
90
|
ret += l
|
|
91
91
|
end
|
|
@@ -94,13 +94,13 @@ class DraftLoader < Source
|
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
def each_raw_message_line offset
|
|
97
|
-
File.open(fn_for_offset(offset), "r
|
|
97
|
+
File.open(fn_for_offset(offset), "r") do |f|
|
|
98
98
|
yield f.gets until f.eof?
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
def raw_message offset
|
|
103
|
-
IO.read
|
|
103
|
+
IO.read fn_for_offset(offset)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def start_offset; 0; end
|
data/lib/sup/index.rb
CHANGED
|
@@ -142,7 +142,7 @@ EOS
|
|
|
142
142
|
|
|
143
143
|
def save_index
|
|
144
144
|
info "Flushing Xapian updates to disk. This may take a while..."
|
|
145
|
-
@xapian.
|
|
145
|
+
@xapian.commit
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
def contains_id? id
|
|
@@ -406,11 +406,15 @@ EOS
|
|
|
406
406
|
query = {}
|
|
407
407
|
|
|
408
408
|
subs = HookManager.run("custom-search", :subs => s) || s
|
|
409
|
+
|
|
410
|
+
subs = "type:mail #{subs}"
|
|
411
|
+
|
|
409
412
|
begin
|
|
410
413
|
subs = SearchManager.expand subs
|
|
411
414
|
rescue SearchManager::ExpansionError => e
|
|
412
415
|
raise ParseError, e.message
|
|
413
416
|
end
|
|
417
|
+
|
|
414
418
|
subs = subs.gsub(/\b(to|from):(\S+)\b/) do
|
|
415
419
|
field, value = $1, $2
|
|
416
420
|
email_field, name_field = %w(email name).map { |x| "#{field}_#{x}" }
|
|
@@ -516,9 +520,13 @@ EOS
|
|
|
516
520
|
qp.stemmer = Xapian::Stem.new($config[:stem_language])
|
|
517
521
|
qp.stemming_strategy = Xapian::QueryParser::STEM_SOME
|
|
518
522
|
qp.default_op = Xapian::Query::OP_AND
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
523
|
+
begin
|
|
524
|
+
rangeprocessor = Xapian::NumberRangeProcessor.new DATE_VALUENO, 'date:'
|
|
525
|
+
qp.add_rangeprocessor rangeprocessor
|
|
526
|
+
rescue NameError # xapian < 1.3
|
|
527
|
+
valuerangeprocessor = Xapian::NumberValueRangeProcessor.new DATE_VALUENO, 'date:', true
|
|
528
|
+
qp.add_valuerangeprocessor valuerangeprocessor
|
|
529
|
+
end
|
|
522
530
|
NORMAL_PREFIX.each { |k,info| info[:prefix].each {
|
|
523
531
|
|v| qp.add_prefix k, v }
|
|
524
532
|
}
|
|
@@ -670,7 +678,9 @@ EOS
|
|
|
670
678
|
neglabels = [:spam, :deleted, :killed].reject { |l| (labels.include? l) || opts.member?("load_#{l}".intern) }
|
|
671
679
|
pos_terms, neg_terms = [], []
|
|
672
680
|
|
|
673
|
-
|
|
681
|
+
## workaround for https://trac.xapian.org/ticket/855
|
|
682
|
+
#pos_terms << mkterm(:type, 'mail')
|
|
683
|
+
pos_terms << Q::MatchAll
|
|
674
684
|
pos_terms.concat(labels.map { |l| mkterm(:label,l) })
|
|
675
685
|
pos_terms << opts[:qobj] if opts[:qobj]
|
|
676
686
|
pos_terms << mkterm(:source_id, opts[:source_id]) if opts[:source_id]
|
data/lib/sup/maildir.rb
CHANGED
|
@@ -84,10 +84,6 @@ class Maildir < Source
|
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
def load_header id
|
|
88
|
-
with_file_for(id) { |f| parse_raw_email_header f }
|
|
89
|
-
end
|
|
90
|
-
|
|
91
87
|
def load_message id
|
|
92
88
|
with_file_for(id) { |f| RMail::Parser.read f }
|
|
93
89
|
end
|
|
@@ -189,20 +185,29 @@ class Maildir < Source
|
|
|
189
185
|
end
|
|
190
186
|
|
|
191
187
|
def maildir_labels id
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
188
|
+
flags = maildir_flags id
|
|
189
|
+
labels = []
|
|
190
|
+
labels << :unread unless flags.member? :seen
|
|
191
|
+
labels << :deleted if flags.member? :trashed
|
|
192
|
+
labels << :starred if flags.member? :flagged
|
|
193
|
+
labels << :forwarded if flags.member? :passed
|
|
194
|
+
labels << :replied if flags.member? :replied
|
|
195
|
+
labels << :draft if flags.member? :draft
|
|
196
|
+
labels
|
|
198
197
|
end
|
|
199
198
|
|
|
200
|
-
def
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
199
|
+
def maildir_flags id
|
|
200
|
+
maildir_data(id)[2].each_char.map do |c|
|
|
201
|
+
case c
|
|
202
|
+
when 'D' then :draft
|
|
203
|
+
when 'F' then :flagged
|
|
204
|
+
when 'P' then :passed
|
|
205
|
+
when 'R' then :replied
|
|
206
|
+
when 'S' then :seen
|
|
207
|
+
when 'T' then :trashed
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
206
211
|
|
|
207
212
|
def valid? id
|
|
208
213
|
File.exist? File.join(@dir, id)
|
data/lib/sup/mbox.rb
CHANGED
|
@@ -69,16 +69,6 @@ class MBox < Source
|
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
def load_header offset
|
|
73
|
-
header = nil
|
|
74
|
-
@mutex.synchronize do
|
|
75
|
-
ensure_open
|
|
76
|
-
@f.seek offset
|
|
77
|
-
header = parse_raw_email_header @f
|
|
78
|
-
end
|
|
79
|
-
header
|
|
80
|
-
end
|
|
81
|
-
|
|
82
72
|
def load_message offset
|
|
83
73
|
@mutex.synchronize do
|
|
84
74
|
ensure_open
|
data/lib/sup/message.rb
CHANGED
|
@@ -48,8 +48,6 @@ class Message
|
|
|
48
48
|
|
|
49
49
|
attr_accessor :locations
|
|
50
50
|
|
|
51
|
-
## if you specify a :header, will use values from that. otherwise,
|
|
52
|
-
## will try and load the header from the source.
|
|
53
51
|
def initialize opts
|
|
54
52
|
@locations = opts[:locations] or raise ArgumentError, "locations can't be nil"
|
|
55
53
|
@snippet = opts[:snippet]
|
|
@@ -64,17 +62,18 @@ class Message
|
|
|
64
62
|
## we need to initialize this. see comments in parse_header as to
|
|
65
63
|
## why.
|
|
66
64
|
@refs = []
|
|
67
|
-
|
|
68
|
-
#parse_header(opts[:header] || @source.load_header(@source_info))
|
|
69
65
|
end
|
|
70
66
|
|
|
71
67
|
def decode_header_field v
|
|
72
68
|
return unless v
|
|
73
69
|
return v unless v.is_a? String
|
|
74
70
|
return unless v.size < MAX_HEADER_VALUE_SIZE # avoid regex blowup on spam
|
|
71
|
+
## Unfold per RFC 5322 2.2.3: remove each CRLF immediately followed
|
|
72
|
+
## by WSP, leaving the WSP in place.
|
|
73
|
+
v = v.gsub(/\r?\n(?=[ \t])/, "")
|
|
75
74
|
## Header values should be either 7-bit with RFC2047-encoded words
|
|
76
75
|
## or UTF-8 as per RFC6532. Replace any invalid high bytes with U+FFFD.
|
|
77
|
-
Rfc2047.decode_to $encoding, v.
|
|
76
|
+
Rfc2047.decode_to $encoding, v.force_encoding(Encoding::UTF_8).scrub
|
|
78
77
|
end
|
|
79
78
|
|
|
80
79
|
def parse_header encoded_header
|
|
@@ -333,21 +332,8 @@ EOS
|
|
|
333
332
|
end
|
|
334
333
|
end
|
|
335
334
|
|
|
336
|
-
## returns all the content from a message that will be indexed
|
|
337
|
-
def indexable_content
|
|
338
|
-
load_from_source!
|
|
339
|
-
[
|
|
340
|
-
from && from.indexable_content,
|
|
341
|
-
to.map { |p| p.indexable_content },
|
|
342
|
-
cc.map { |p| p.indexable_content },
|
|
343
|
-
bcc.map { |p| p.indexable_content },
|
|
344
|
-
indexable_chunks.map { |c| c.lines.map { |l| l.fix_encoding! } },
|
|
345
|
-
indexable_subject,
|
|
346
|
-
].flatten.compact.join " "
|
|
347
|
-
end
|
|
348
|
-
|
|
349
335
|
def indexable_body
|
|
350
|
-
indexable_chunks.map { |c| c.lines }.flatten.compact.
|
|
336
|
+
indexable_chunks.map { |c| c.lines }.flatten.compact.join " "
|
|
351
337
|
end
|
|
352
338
|
|
|
353
339
|
def indexable_chunks
|
data/lib/sup/message_chunks.rb
CHANGED
|
@@ -35,30 +35,6 @@ require 'shellwords'
|
|
|
35
35
|
## included as quoted text during a reply. Text, Quotes, and mime-parsed
|
|
36
36
|
## attachments are quotable; Signatures are not.
|
|
37
37
|
|
|
38
|
-
## monkey-patch time: make temp files have the right extension
|
|
39
|
-
## Backport from Ruby 1.9.2 for versions lower than 1.8.7
|
|
40
|
-
if RUBY_VERSION < '1.8.7'
|
|
41
|
-
class Tempfile
|
|
42
|
-
def make_tmpname(prefix_suffix, n)
|
|
43
|
-
case prefix_suffix
|
|
44
|
-
when String
|
|
45
|
-
prefix = prefix_suffix
|
|
46
|
-
suffix = ""
|
|
47
|
-
when Array
|
|
48
|
-
prefix = prefix_suffix[0]
|
|
49
|
-
suffix = prefix_suffix[1]
|
|
50
|
-
else
|
|
51
|
-
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
|
52
|
-
end
|
|
53
|
-
t = Time.now.strftime("%Y%m%d")
|
|
54
|
-
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
|
55
|
-
path << "-#{n}" if n
|
|
56
|
-
path << suffix
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
|
|
62
38
|
module Redwood
|
|
63
39
|
module Chunk
|
|
64
40
|
class Attachment
|
|
@@ -129,7 +105,7 @@ EOS
|
|
|
129
105
|
text = case @content_type
|
|
130
106
|
when /^text\/plain\b/
|
|
131
107
|
if /^UTF-7$/i =~ encoded_content.charset
|
|
132
|
-
@raw_content.decode_utf7
|
|
108
|
+
@raw_content.decode_utf7 :invalid => :replace, :undef => :replace
|
|
133
109
|
else
|
|
134
110
|
begin
|
|
135
111
|
charset = Encoding.find(encoded_content.charset || 'US-ASCII')
|
data/lib/sup/mode.rb
CHANGED
|
@@ -83,7 +83,6 @@ class ContactListMode < LineCursorMode
|
|
|
83
83
|
def multi_search people
|
|
84
84
|
mode = PersonSearchResultsMode.new people
|
|
85
85
|
BufferManager.spawn "search for #{people.map { |p| p.name }.join(', ')}", mode
|
|
86
|
-
mode.load_threads :num => mode.buffer.content_height
|
|
87
86
|
end
|
|
88
87
|
|
|
89
88
|
def search
|
|
@@ -80,6 +80,16 @@ Return value:
|
|
|
80
80
|
True if mail has been sent successfully, false otherwise.
|
|
81
81
|
EOS
|
|
82
82
|
|
|
83
|
+
HookManager.register "sent-save-to", <<EOS
|
|
84
|
+
Selects where to save sent mail to. If this hook doesn't exist, the
|
|
85
|
+
"sent_source" config will be used (possibly defaulting to sup://sent).
|
|
86
|
+
Variables:
|
|
87
|
+
message: RMail::Message instance of the mail which has been sent.
|
|
88
|
+
account: Account instance matching the From address.
|
|
89
|
+
Return value:
|
|
90
|
+
Source to save the sent mail to, or nil to use the default.
|
|
91
|
+
EOS
|
|
92
|
+
|
|
83
93
|
attr_reader :status
|
|
84
94
|
attr_accessor :body, :header
|
|
85
95
|
bool_reader :edited
|
|
@@ -451,9 +461,46 @@ protected
|
|
|
451
461
|
end
|
|
452
462
|
end
|
|
453
463
|
|
|
464
|
+
## utility method to read a raw email header from an IO stream and turn it
|
|
465
|
+
## into a hash of key-value pairs. minor special semantics for certain headers.
|
|
466
|
+
def self.parse_raw_email_header f
|
|
467
|
+
header = {}
|
|
468
|
+
last = nil
|
|
469
|
+
|
|
470
|
+
while(line = f.gets)
|
|
471
|
+
case line
|
|
472
|
+
## these three can occur multiple times, and we want the first one
|
|
473
|
+
when /^(Delivered-To|X-Original-To|Envelope-To):\s*(.*?)\s*$/i; header[last = $1.downcase] ||= $2
|
|
474
|
+
## regular header: overwrite (not that we should see more than one)
|
|
475
|
+
## TODO: figure out whether just using the first occurrence changes
|
|
476
|
+
## anything (which would simplify the logic slightly)
|
|
477
|
+
when /^([^:\s]+):\s*(.*?)\s*$/i; header[last = $1.downcase] = $2
|
|
478
|
+
when /^\r*$/; break # blank line signifies end of header
|
|
479
|
+
else
|
|
480
|
+
if last
|
|
481
|
+
header[last] << " " unless header[last].empty?
|
|
482
|
+
header[last] << line.strip
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
|
|
487
|
+
%w(subject from to cc bcc).each do |k|
|
|
488
|
+
v = header[k] or next
|
|
489
|
+
next unless Rfc2047.is_encoded? v
|
|
490
|
+
header[k] = begin
|
|
491
|
+
Rfc2047.decode_to $encoding, v
|
|
492
|
+
rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::IllegalSequence
|
|
493
|
+
v
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
header
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
def parse_raw_email_header f; self.class.parse_raw_email_header f end
|
|
500
|
+
|
|
454
501
|
def parse_file fn
|
|
455
502
|
File.open(fn) do |f|
|
|
456
|
-
header =
|
|
503
|
+
header = parse_raw_email_header(f).inject({}) { |h, (k, v)| h[k.capitalize] = v; h } # lousy HACK
|
|
457
504
|
body = f.readlines.map { |l| l.chomp }
|
|
458
505
|
|
|
459
506
|
header.delete_if { |k, v| NON_EDITABLE_HEADERS.member? k }
|
|
@@ -534,11 +581,12 @@ protected
|
|
|
534
581
|
raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $? == 0
|
|
535
582
|
end
|
|
536
583
|
|
|
537
|
-
SentManager.write_sent_message(
|
|
584
|
+
SentManager.write_sent_message(HookManager.run("sent-save-to", :message => m, :account => acct),
|
|
585
|
+
date, from_email) { |f| f.puts sanitize_body(m.to_s) }
|
|
538
586
|
BufferManager.kill_buffer buffer
|
|
539
587
|
BufferManager.flash "Message sent!"
|
|
540
588
|
true
|
|
541
|
-
rescue SystemCallError, SendmailCommandFailed, CryptoManager::Error => e
|
|
589
|
+
rescue SystemCallError, SendmailCommandFailed, CryptoManager::Error, TypeError => e
|
|
542
590
|
warn "Problem sending mail: #{e.message}"
|
|
543
591
|
BufferManager.flash "Problem sending mail: #{e.message}"
|
|
544
592
|
false
|
|
@@ -553,7 +601,6 @@ protected
|
|
|
553
601
|
|
|
554
602
|
def build_message date
|
|
555
603
|
m = RMail::Message.new
|
|
556
|
-
m.header["Content-Type"] = "text/plain; charset=#{$encoding}"
|
|
557
604
|
m.body = @body.join("\n")
|
|
558
605
|
m.body += "\n" + sig_lines.join("\n") unless @sig_edited
|
|
559
606
|
## body must end in a newline or GPG signatures will be WRONG!
|
|
@@ -601,8 +648,9 @@ protected
|
|
|
601
648
|
m.header["Date"] = date.rfc2822
|
|
602
649
|
m.header["Message-Id"] = @message_id
|
|
603
650
|
m.header["User-Agent"] = "Sup/#{Redwood::VERSION}"
|
|
651
|
+
m.header["Content-Type"] = "text/plain; charset=#{$encoding}"
|
|
604
652
|
m.header["Content-Transfer-Encoding"] ||= +"8bit"
|
|
605
|
-
m.header["MIME-Version"] = +"1.0"
|
|
653
|
+
m.header["MIME-Version"] = +"1.0"
|
|
606
654
|
m
|
|
607
655
|
end
|
|
608
656
|
|
|
@@ -29,8 +29,7 @@ class LabelSearchResultsMode < ThreadIndexMode
|
|
|
29
29
|
when :inbox
|
|
30
30
|
BufferManager.raise_to_front InboxMode.instance.buffer
|
|
31
31
|
else
|
|
32
|
-
|
|
33
|
-
b.mode.load_threads :num => b.content_height if new
|
|
32
|
+
BufferManager.spawn_unless_exists("All threads with label '#{label}'") { LabelSearchResultsMode.new [label] }
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
35
|
end
|
|
@@ -20,14 +20,19 @@ class LineCursorMode < ScrollMode
|
|
|
20
20
|
while true
|
|
21
21
|
e = @load_more_q.pop
|
|
22
22
|
@load_more_callbacks.each { |c| c.call e }
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
hysteresis = $config[:load_more_threads_hysteresis] || 0.5
|
|
24
|
+
if hysteresis > 0 then
|
|
25
|
+
sleep hysteresis
|
|
26
|
+
@load_more_q.pop until @load_more_q.empty?
|
|
27
|
+
end
|
|
25
28
|
end
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
super opts
|
|
29
32
|
end
|
|
30
33
|
|
|
34
|
+
def spawned; call_load_more_callbacks buffer.content_height + 1; end
|
|
35
|
+
|
|
31
36
|
def cleanup
|
|
32
37
|
@load_more_thread.kill
|
|
33
38
|
super
|
|
@@ -157,26 +162,22 @@ protected
|
|
|
157
162
|
end
|
|
158
163
|
end
|
|
159
164
|
|
|
160
|
-
|
|
165
|
+
def half_page_up
|
|
166
|
+
super
|
|
167
|
+
set_cursor_pos [botline, @curpos].min
|
|
168
|
+
end
|
|
169
|
+
|
|
161
170
|
def page_down
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
## if we're on the last page, and it's a full page, try and load
|
|
169
|
-
## more lines via the callbacks and then shift the page down
|
|
170
|
-
elsif topline == lines - buffer.content_height
|
|
171
|
-
call_load_more_callbacks buffer.content_height
|
|
172
|
-
super
|
|
171
|
+
relpos = @curpos - topline
|
|
172
|
+
super
|
|
173
|
+
set_cursor_pos [topline + relpos, lines - 1].min
|
|
174
|
+
call_load_more_callbacks buffer.content_height if lines < topline + buffer.content_height
|
|
175
|
+
end
|
|
173
176
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
set_cursor_pos [topline + relpos, lines - 1].min
|
|
179
|
-
end
|
|
177
|
+
def half_page_down
|
|
178
|
+
super
|
|
179
|
+
set_cursor_pos [topline, @curpos].max
|
|
180
|
+
call_load_more_callbacks buffer.content_height if lines < topline + buffer.content_height
|
|
180
181
|
end
|
|
181
182
|
|
|
182
183
|
def jump_to_start
|
|
@@ -187,6 +188,7 @@ protected
|
|
|
187
188
|
def jump_to_end
|
|
188
189
|
super if topline < (lines - buffer.content_height)
|
|
189
190
|
set_cursor_pos(lines - 1)
|
|
191
|
+
call_load_more_callbacks buffer.content_height
|
|
190
192
|
end
|
|
191
193
|
|
|
192
194
|
private
|
|
@@ -49,7 +49,6 @@ class SearchResultsMode < ThreadIndexMode
|
|
|
49
49
|
short_text = text.length < 20 ? text : text[0 ... 20] + "..."
|
|
50
50
|
mode = SearchResultsMode.new query
|
|
51
51
|
BufferManager.spawn "search: \"#{short_text}\"", mode
|
|
52
|
-
mode.load_threads :num => mode.buffer.content_height
|
|
53
52
|
rescue Index::ParseError => e
|
|
54
53
|
BufferManager.flash "Problem: #{e.message}!"
|
|
55
54
|
end
|
|
@@ -494,6 +494,29 @@ EOS
|
|
|
494
494
|
threads.each { |t| Index.save_thread t }
|
|
495
495
|
end
|
|
496
496
|
|
|
497
|
+
## returns an undo lambda
|
|
498
|
+
def actually_toggle_killed t
|
|
499
|
+
if t.has_label? :killed
|
|
500
|
+
t.remove_label :killed
|
|
501
|
+
add_or_unhide t.first
|
|
502
|
+
UpdateManager.relay self, :labeled, t.first
|
|
503
|
+
lambda do
|
|
504
|
+
t.apply_label :killed
|
|
505
|
+
hide_thread t
|
|
506
|
+
UpdateManager.relay self, :labeled, t.first
|
|
507
|
+
end
|
|
508
|
+
else
|
|
509
|
+
t.apply_label :killed
|
|
510
|
+
hide_thread t
|
|
511
|
+
UpdateManager.relay self, :labeled, t.first
|
|
512
|
+
lambda do
|
|
513
|
+
t.remove_label :killed
|
|
514
|
+
add_or_unhide t.first
|
|
515
|
+
UpdateManager.relay self, :labeled, t.first
|
|
516
|
+
end
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
|
|
497
520
|
def kill
|
|
498
521
|
t = cursor_thread or return
|
|
499
522
|
multi_kill [t]
|
|
@@ -507,35 +530,13 @@ EOS
|
|
|
507
530
|
|
|
508
531
|
## m-m-m-m-MULTI-KILL
|
|
509
532
|
def multi_kill threads
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
hide_thread t
|
|
516
|
-
end
|
|
517
|
-
end.each do |t|
|
|
518
|
-
UpdateManager.relay self, :labeled, t.first
|
|
519
|
-
Index.save_thread t
|
|
520
|
-
end
|
|
521
|
-
regen_text
|
|
522
|
-
end
|
|
523
|
-
|
|
524
|
-
threads.each do |t|
|
|
525
|
-
if t.toggle_label :killed
|
|
526
|
-
hide_thread t
|
|
527
|
-
else
|
|
528
|
-
add_or_unhide t.first
|
|
529
|
-
end
|
|
530
|
-
end.each do |t|
|
|
531
|
-
# send 'labeled'... this might be more specific
|
|
532
|
-
UpdateManager.relay self, :labeled, t.first
|
|
533
|
-
Index.save_thread t
|
|
534
|
-
end
|
|
535
|
-
|
|
533
|
+
undos = threads.map { |t| actually_toggle_killed t }
|
|
534
|
+
UndoManager.register "killing/unkilling #{threads.size.pluralize 'threads'}", undos,
|
|
535
|
+
lambda { regen_text }, lambda { threads.each { |t| Index.save_thread t } }
|
|
536
|
+
regen_text
|
|
537
|
+
threads.each { |t| Index.save_thread t }
|
|
536
538
|
killed, unkilled = threads.partition { |t| t.has_label? :killed }.map(&:size)
|
|
537
539
|
BufferManager.flash "#{killed.pluralize 'thread'} killed, #{unkilled} unkilled"
|
|
538
|
-
regen_text
|
|
539
540
|
end
|
|
540
541
|
|
|
541
542
|
def cleanup
|
|
@@ -205,7 +205,7 @@ EOS
|
|
|
205
205
|
@layout[m].state = (@layout[m].state == :detailed ? :open : :detailed)
|
|
206
206
|
update
|
|
207
207
|
end
|
|
208
|
-
|
|
208
|
+
|
|
209
209
|
def reload
|
|
210
210
|
update
|
|
211
211
|
end
|
|
@@ -298,7 +298,6 @@ EOS
|
|
|
298
298
|
p = @person_lines[curpos] or return
|
|
299
299
|
mode = PersonSearchResultsMode.new [p]
|
|
300
300
|
BufferManager.spawn "Search for #{p.name}", mode
|
|
301
|
-
mode.load_threads :num => mode.buffer.content_height
|
|
302
301
|
end
|
|
303
302
|
|
|
304
303
|
def compose
|
data/lib/sup/person.rb
CHANGED
|
@@ -71,12 +71,6 @@ class Person
|
|
|
71
71
|
def eql? o; email.eql? o.email end
|
|
72
72
|
def hash; email.hash end
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
## see comments in self.from_address
|
|
76
|
-
def indexable_content
|
|
77
|
-
[name, email, email.split(/@/).first].join(" ")
|
|
78
|
-
end
|
|
79
|
-
|
|
80
74
|
class << self
|
|
81
75
|
|
|
82
76
|
def full_address name, email
|
data/lib/sup/poll.rb
CHANGED
|
@@ -219,12 +219,9 @@ EOS
|
|
|
219
219
|
Index.sync_message m, true
|
|
220
220
|
end
|
|
221
221
|
|
|
222
|
-
## We need to add or unhide the message when it either did not exist
|
|
223
|
-
## before at all or when it was updated. We do *not* add/unhide when
|
|
224
|
-
## the same message was found at a different location
|
|
225
222
|
if old_m
|
|
226
223
|
UpdateManager.relay self, :updated, m
|
|
227
|
-
|
|
224
|
+
else
|
|
228
225
|
UpdateManager.relay self, :added, m
|
|
229
226
|
end
|
|
230
227
|
when :delete
|
data/lib/sup/rfc2047.rb
CHANGED
|
@@ -62,10 +62,13 @@ module Rfc2047
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
begin
|
|
65
|
-
text.force_encoding
|
|
65
|
+
text.force_encoding charset
|
|
66
|
+
text.encode! target
|
|
66
67
|
rescue ArgumentError, EncodingError
|
|
67
|
-
word
|
|
68
|
+
next word
|
|
68
69
|
end
|
|
70
|
+
next word unless text.valid_encoding?
|
|
71
|
+
text
|
|
69
72
|
end
|
|
70
73
|
end
|
|
71
74
|
end
|
data/lib/sup/sent.rb
CHANGED
|
@@ -24,13 +24,14 @@ class SentManager
|
|
|
24
24
|
@source
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def write_sent_message date, from_email, &block
|
|
27
|
+
def write_sent_message src, date, from_email, &block
|
|
28
28
|
::Thread.new do
|
|
29
29
|
debug "store the sent message (locking sent source..)"
|
|
30
|
-
@source
|
|
31
|
-
|
|
30
|
+
use_src = src || @source
|
|
31
|
+
use_src.synchronize do
|
|
32
|
+
use_src.store_message date, from_email, &block
|
|
32
33
|
end
|
|
33
|
-
PollManager.poll_from
|
|
34
|
+
PollManager.poll_from use_src
|
|
34
35
|
end
|
|
35
36
|
end
|
|
36
37
|
end
|