vmail 1.4.2 → 1.4.3
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.
- data/lib/vmail/imap_client.rb +32 -26
- data/lib/vmail/version.rb +1 -1
- metadata +5 -20
data/lib/vmail/imap_client.rb
CHANGED
@@ -14,15 +14,6 @@ module Vmail
|
|
14
14
|
|
15
15
|
DIVIDER_WIDTH = 46
|
16
16
|
|
17
|
-
MailboxAliases = { 'sent' => '[Gmail]/Sent Mail',
|
18
|
-
'all' => '[Gmail]/All Mail',
|
19
|
-
'starred' => '[Gmail]/Starred',
|
20
|
-
'important' => '[Gmail]/Important',
|
21
|
-
'drafts' => '[Gmail]/Drafts',
|
22
|
-
'spam' => '[Gmail]/Spam',
|
23
|
-
'trash' => '[Gmail]/Trash'
|
24
|
-
}
|
25
|
-
|
26
17
|
attr_accessor :max_seqno # of current mailbox
|
27
18
|
|
28
19
|
def initialize(config)
|
@@ -37,6 +28,7 @@ module Vmail
|
|
37
28
|
@current_mail = nil
|
38
29
|
@current_message_uid = nil
|
39
30
|
@width = 140
|
31
|
+
@prefix = "Gmail"
|
40
32
|
end
|
41
33
|
|
42
34
|
# holds mail objects keyed by [mailbox, uid]
|
@@ -74,8 +66,8 @@ module Vmail
|
|
74
66
|
end
|
75
67
|
|
76
68
|
def select_mailbox(mailbox, force=false)
|
77
|
-
if
|
78
|
-
mailbox =
|
69
|
+
if mailbox_aliases[mailbox]
|
70
|
+
mailbox = mailbox_aliases[mailbox]
|
79
71
|
end
|
80
72
|
if mailbox == @mailbox && !force
|
81
73
|
return
|
@@ -148,16 +140,30 @@ module Vmail
|
|
148
140
|
|
149
141
|
def list_mailboxes
|
150
142
|
log 'loading mailboxes...'
|
151
|
-
@mailboxes ||= ((@imap.list("[
|
143
|
+
@mailboxes ||= ((@imap.list("[#@prefix]/", "%") || []) + (@imap.list("", "*")) || []).
|
152
144
|
select {|struct| struct.attr.none? {|a| a == :Noselect} }.
|
153
145
|
map {|struct| struct.name}.
|
154
|
-
map {|name|
|
146
|
+
map {|name| mailbox_aliases.invert[name] || name}
|
155
147
|
@mailboxes.delete("INBOX")
|
156
148
|
@mailboxes.unshift("INBOX")
|
157
149
|
log "loaded mailboxes: #{@mailboxes.inspect}"
|
150
|
+
if @mailboxes.detect {|m| m =~ /^\[Google Mail\]/}
|
151
|
+
@prefix = "Google Mail"
|
152
|
+
end
|
158
153
|
@mailboxes.join("\n")
|
159
154
|
end
|
160
155
|
|
156
|
+
def mailbox_aliases
|
157
|
+
{ "sent" => "[#@prefix]/Sent Mail",
|
158
|
+
"all" => "[#@prefix]/All Mail",
|
159
|
+
"starred" => "[#@prefix]/Starred",
|
160
|
+
"important" => "[#@prefix]/Important",
|
161
|
+
"drafts" => "[#@prefix]/Drafts",
|
162
|
+
"spam" => "[#@prefix]/Spam",
|
163
|
+
"trash" => "[#@prefix]/Trash"
|
164
|
+
}
|
165
|
+
end
|
166
|
+
|
161
167
|
# called internally, not by vim client
|
162
168
|
def mailboxes
|
163
169
|
if @mailboxes.nil?
|
@@ -209,7 +215,7 @@ module Vmail
|
|
209
215
|
envelope = fetch_data.attr["ENVELOPE"]
|
210
216
|
size = fetch_data.attr["RFC822.SIZE"]
|
211
217
|
flags = fetch_data.attr["FLAGS"]
|
212
|
-
address_struct = if @mailbox ==
|
218
|
+
address_struct = if @mailbox == "[#@prefix]/Sent Mail"
|
213
219
|
structs = envelope.to || envelope.cc
|
214
220
|
structs.nil? ? nil : structs.first
|
215
221
|
else
|
@@ -222,7 +228,7 @@ module Vmail
|
|
222
228
|
else
|
223
229
|
[Mail::Encodings.unquote_and_convert_to(address_struct.mailbox, 'UTF-8'), Mail::Encodings.unquote_and_convert_to(address_struct.host, 'UTF-8')].join('@')
|
224
230
|
end
|
225
|
-
if @mailbox ==
|
231
|
+
if @mailbox == "[#@prefix]/Sent Mail" && envelope.to && envelope.cc
|
226
232
|
total_recips = (envelope.to + envelope.cc).size
|
227
233
|
address += " + #{total_recips - 1}"
|
228
234
|
end
|
@@ -500,21 +506,21 @@ EOF
|
|
500
506
|
decrement_max_seqno(uid_set.size)
|
501
507
|
# for delete, do in a separate thread because deletions are slow
|
502
508
|
spawn_thread_if_tty do
|
503
|
-
unless @mailbox ==
|
504
|
-
log "@imap.uid_copy #{uid_set.inspect} to
|
505
|
-
log @imap.uid_copy(uid_set, "[
|
509
|
+
unless @mailbox == "[#@prefix]/Trash"
|
510
|
+
log "@imap.uid_copy #{uid_set.inspect} to [#@prefix]/Trash"
|
511
|
+
log @imap.uid_copy(uid_set, "[#@prefix]/Trash")
|
506
512
|
end
|
507
513
|
log "@imap.uid_store #{uid_set.inspect} #{action} [#{flg.to_sym}]"
|
508
514
|
log @imap.uid_store(uid_set, action, [flg.to_sym])
|
509
515
|
reload_mailbox
|
510
516
|
clear_cached_message
|
511
517
|
end
|
512
|
-
elsif flg == 'spam' || flg ==
|
518
|
+
elsif flg == 'spam' || flg == "[#@prefix]/Spam"
|
513
519
|
log "Marking as spam uid_set: #{uid_set.inspect}"
|
514
520
|
decrement_max_seqno(uid_set.size)
|
515
521
|
spawn_thread_if_tty do
|
516
|
-
log "@imap.uid_copy #{uid_set.inspect} to
|
517
|
-
log @imap.uid_copy(uid_set, "[
|
522
|
+
log "@imap.uid_copy #{uid_set.inspect} to [#@prefix]/Spam"
|
523
|
+
log @imap.uid_copy(uid_set, "[#@prefix]/Spam")
|
518
524
|
log "@imap.uid_store #{uid_set.inspect} #{action} [:Deleted]"
|
519
525
|
log @imap.uid_store(uid_set, action, [:Deleted])
|
520
526
|
reload_mailbox
|
@@ -536,8 +542,8 @@ EOF
|
|
536
542
|
if mailbox == 'all'
|
537
543
|
log "archiving messages"
|
538
544
|
end
|
539
|
-
if
|
540
|
-
mailbox =
|
545
|
+
if mailbox_aliases[mailbox]
|
546
|
+
mailbox = mailbox_aliases[mailbox]
|
541
547
|
end
|
542
548
|
create_if_necessary mailbox
|
543
549
|
log "moving uid_set: #{uid_set.inspect} to #{mailbox}"
|
@@ -552,8 +558,8 @@ EOF
|
|
552
558
|
|
553
559
|
def copy_to(uid_set, mailbox)
|
554
560
|
uid_set = uid_set.split(',').map(&:to_i)
|
555
|
-
if
|
556
|
-
mailbox =
|
561
|
+
if mailbox_aliases[mailbox]
|
562
|
+
mailbox = mailbox_aliases[mailbox]
|
557
563
|
end
|
558
564
|
create_if_necessary mailbox
|
559
565
|
log "copying #{uid_set.inspect} to #{mailbox}"
|
@@ -574,7 +580,7 @@ EOF
|
|
574
580
|
end
|
575
581
|
|
576
582
|
def create_if_necessary(mailbox)
|
577
|
-
current_mailboxes = mailboxes.map {|m|
|
583
|
+
current_mailboxes = mailboxes.map {|m| mailbox_aliases[m] || m}
|
578
584
|
if !current_mailboxes.include?(mailbox)
|
579
585
|
log "current mailboxes: #{current_mailboxes.inspect}"
|
580
586
|
log "creating mailbox #{mailbox}"
|
data/lib/vmail/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 1.4.
|
8
|
+
- 3
|
9
|
+
version: 1.4.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Choi
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-18 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -162,20 +162,5 @@ rubygems_version: 1.3.7
|
|
162
162
|
signing_key:
|
163
163
|
specification_version: 3
|
164
164
|
summary: A Vim interface to Gmail
|
165
|
-
test_files:
|
166
|
-
|
167
|
-
- test/base64_test.rb
|
168
|
-
- test/fixtures/euc-kr-header.eml
|
169
|
-
- test/fixtures/euc-kr-html.eml
|
170
|
-
- test/fixtures/google-affiliate.eml
|
171
|
-
- test/fixtures/htmlbody.eml
|
172
|
-
- test/fixtures/moleskine-html.eml
|
173
|
-
- test/fixtures/reply-template-encoding-test.eml
|
174
|
-
- test/fixtures/reply_all.eml
|
175
|
-
- test/fixtures/rfc_part.eml
|
176
|
-
- test/fixtures/textbody-nocontenttype.eml
|
177
|
-
- test/fixtures/with-attachments.eml
|
178
|
-
- test/message_formatter_test.rb
|
179
|
-
- test/reply_template_test.rb
|
180
|
-
- test/test_helper.rb
|
181
|
-
- test/time_format_test.rb
|
165
|
+
test_files: []
|
166
|
+
|