vmail 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *swp
2
+ login.yml
3
+ gmail.yml
4
+ *.log
data/NOTES ADDED
@@ -0,0 +1,541 @@
1
+
2
+ interesting. the UID don't seem to be globally unique. two different
3
+ messages in 2 different mailboxes can have same UID
4
+
5
+
6
+ Mon Nov 22 23:12:49 EST 2010
7
+
8
+ - next, do window sensing and recreation. let user expand the message
9
+ detail window and shrink it with some key like <cr>
10
+
11
+ I need status windows that show how many messagesin a box, when it was
12
+ last updated, etc
13
+
14
+ This app is coming along well.
15
+
16
+
17
+ Another reason to not allow a divergent offline store is that when the
18
+ schema changes on an update, it's easier to have the user rebuild the
19
+ locate version of the GMAIL
20
+
21
+
22
+ Another anomaly. Threading seems to reverse the UIDs.
23
+
24
+
25
+ Imap tasks should be batched so that we don't have the overhead of an
26
+ imap login each time.
27
+
28
+ The vertial 3 pan view should have a different set of columns in the
29
+ message list window.
30
+
31
+ Need command to reprocess text translation, also to display way eml.
32
+
33
+ NEXT. Learn how to do a popup window. Try out other Vim plugins! Do some
34
+ research online.
35
+
36
+ OR, do replies.
37
+
38
+ - work on email formatting
39
+
40
+ Flag new messages. And position cursor correctly on a refresh.
41
+
42
+
43
+
44
+
45
+
46
+ inputlist()
47
+
48
+
49
+ winrestcmd() potentially useful
50
+
51
+ 1resize 20|vert 1resize 84|2resize 18|vert 2resize 84|3resize 39|vert 3resize 84|
52
+
53
+
54
+ ------------------------------------------------------------------------
55
+ Thu Nov 25 16:55:07 EST 2010 {{{1
56
+
57
+ Trying new schema and more unix-inspired approach. First, the schema is
58
+ changed to allow unique messages to be shared across mailboxes via
59
+ message_refs. The Mailbox model has been removed.
60
+
61
+ Second, the tools should be smaller and less interdependent. There
62
+ should be a tool just for getting a text list of UID for a mailbox, and
63
+ then another that takes a UID and pulls down the raw eml, which I can
64
+ then use for testing.
65
+
66
+ The tool to insert into data should take two arguments, the mailbox name
67
+ and the UID, and the raw eml into STDIN.
68
+
69
+ Set up a test harness for all this email caching and data extraction
70
+ with rspec or test unit
71
+
72
+ ------------------------------------------------------------------------
73
+ Fri Nov 26 12:08:26 EST 2010 {{{1
74
+
75
+ I need a text extract tool that works like iconv command line tool.
76
+
77
+ Lots of little tools for my workbench.
78
+
79
+
80
+ Now, I'm thinking of ditching the database. Use one document of
81
+ concatenated EML with message and mailbox info incorporated.
82
+
83
+
84
+ I tried using folds to present the email headers but I'm not sure it
85
+ works. Too many key strokes to unfold, fold, move to next message, and
86
+ unfold. Also, search doesn't work as expected since it searches through
87
+ all the text.
88
+
89
+ This suggests that using the database might be the best solution.
90
+
91
+
92
+ OK I've experimented and found a reasonably fast way to do imap searchs
93
+
94
+ e.g.
95
+
96
+ ruby lib/gmail.rb FROM monit BEFORE 8-Aug-2010 SINCE 1-Jun-2010
97
+
98
+ Now the question is how to get from output to load a specific message
99
+ and then possibly reply to it.
100
+
101
+ And later, we need to keep a contact list somehow.
102
+
103
+ I also forgot how an email is sent with sendmail. Maybe with
104
+ authentication.
105
+
106
+ ------------------------------------------------------------------------
107
+ Sun Nov 28 10:42:50 EST 2010
108
+
109
+ Got threaded message list fetch working
110
+
111
+ Marking messages for deletion or starring could be done very simply:
112
+ Just add a mark '*' or 'D' to the beginning of lines that should be
113
+ starred or deleted, then press a command key.
114
+
115
+ Just put one commented line at top of generated list. This is so the
116
+ viewer can refresh the list on demand when the user wants to. But the
117
+ focus should be on generating these imap search result lists from the
118
+ command line and saving the output to a file. Then the use can view the
119
+ file in the viewer. Should the file serve as a virtual mailbox?
120
+
121
+ User can alway do "search command | tee inbox" periodically and then
122
+ view the inbox in the viewer when a new message arrives.
123
+
124
+ There are even ways of setting up watches from the command to see if a
125
+ new message arrives in a certain mailbox. These recipes should be
126
+ written up in a tutorial on the website.
127
+
128
+
129
+ Wrote a wrapper startup script that you invoke like so
130
+
131
+ ./wrapper inbox 20 all
132
+ ./wrapper inbox 20 subject instantwatcher
133
+
134
+ This will generate the list file and open the viewer on it.
135
+
136
+ I think this is the workflow I want. It keeps the viewer lightweight and
137
+ prevents it from becoming a captive user interface.
138
+
139
+
140
+
141
+ Remember to convert uid to_i before calling IMAP methods.
142
+
143
+ Need to figure out a way to flag a line and show the change. Do we have
144
+ to use Vim data structures?
145
+
146
+ Also, be careful. The f command throws an error when there is no mailbox
147
+ and search term information at the top of the message list.
148
+
149
+
150
+ Make a view mode that lets one simple page through the messages and keep
151
+ track of which message is visible.
152
+
153
+ TODO Try d for trash and D for permanent Delete.
154
+
155
+
156
+ http://stackoverflow.com/questions/1430866/gmail-threading-imap-and-ruby
157
+
158
+ ------------------------------------------------------------------------
159
+ Tue Nov 30 07:30:19 EST 2010
160
+
161
+ Start from command line, and then quit. Not meant to be an application
162
+ that you keep open. At least not for my uses.
163
+
164
+ But it would be better to start up the app in the Ruby wrapper
165
+
166
+ If it's contained in vim, I can use append(lnum, list) to insert
167
+ previous messages to the top of the buffer as the user scrolls back.
168
+
169
+ So two things to accomplish this morning:
170
+ 1. start the application in a Ruby wrapper
171
+ 2. select mailbox from viewer
172
+ 3. infinite paging back
173
+
174
+ Done:
175
+ 1. Ruby wrapper
176
+ 2. Update the current mailbox
177
+ 3. Fast deletes, range flagging
178
+ 4. slightly better multipart displaying
179
+
180
+ Won't do:
181
+ - infinite paging
182
+ - starting mailbox from viewer
183
+
184
+ TODO
185
+ - send messages
186
+
187
+
188
+ Unicode korean characters are wider than ascii characters, so this will
189
+ mess up alignment, but I don't know what I can do about this.
190
+
191
+ ------------------------------------------------------------------------
192
+ Wed Dec 1 15:39:39 EST 2010
193
+
194
+ - got composing messages working, switching between full screen message
195
+ view and list view
196
+
197
+ TODO
198
+ - reply to messages
199
+
200
+ contacts
201
+ - import contacts by looking at sent mailbox. save contacts into a file
202
+ and use that for autocompletion
203
+
204
+ split reply window veritcally: that's the way I wanted this interface
205
+
206
+ Quoting emails:
207
+
208
+ http://en.wikipedia.org/wiki/Posting_style
209
+
210
+ stackoverflow:
211
+
212
+ If you get the raw source of the messages you can relate messages to one
213
+ another by looking at the following headers:
214
+
215
+ Message-ID:
216
+ <097819EBC7F79F4A850C8F088D35927302442A82AA@xxxxxxxxxxxxxxxxxxx>
217
+ References: <4A8BE8F3.2060007@xxxxxxxxxxxxxx>
218
+ In-Reply-To: <4A8BE8F3.2060007@xxxxxxxxxxxxxxx>
219
+ link|flag
220
+ answered Aug 28 '09 at 7:23
221
+ Kees de Kooter
222
+ 1,7341512
223
+
224
+
225
+ TODO
226
+ - get full email addresses including names
227
+ - fix reply to quote header
228
+ - address book
229
+ - later:
230
+ - append to text file
231
+ - display and save attachments
232
+ Thurs
233
+ - start packaging
234
+ - need a better way to refresh a stale IMAP connection
235
+ - try wrapping client calls with Timeout. Then call daemon to refresh
236
+ connection if things take too long.
237
+
238
+ * Need to save mail list buffer or else it forgets what user has flagged
239
+ or deleted.
240
+
241
+
242
+ - will have to write out message list buffer
243
+
244
+ - IMAP fails from parsing email from
245
+
246
+ D, [2010-12-02T04:14:47.034816 #26464] DEBUG -- : error fetching uid
247
+ 83682
248
+ D, [2010-12-02T04:14:47.034884 #26464] DEBUG -- : unknown token -
249
+ "\"[Christian" (Net::IMAP::ResponseParseError)
250
+
251
+
252
+ It is vital to rewrite the message list buffer to file. This is a
253
+ significant bug. Since new messages gotten via update disappear when
254
+ coming back from full screen message view.
255
+
256
+ Also, let use go forward and back while reading full messages.
257
+ Or even in split view. Don't bind n since we need it for search. Use
258
+ CTRL-n, CTRL-p? or leader n leader
259
+
260
+ Need better recovery from expired IMAP session. At least some kind of
261
+ warning so that use retries the previous action that failed.
262
+
263
+ TODO
264
+ - gmail charset correction
265
+
266
+
267
+ ------------------------------------------------------------------------
268
+ Tue Dec 7 09:36:01 EST 2010
269
+
270
+ Instead of autocomplete mailbox chooser, have a generic search command
271
+ line buffer that might autocomplete the mailbox for you.
272
+
273
+ This simplifies the user interface and makes it more coherent.
274
+
275
+ You will always specify a mailbox and a command. Get the user used to
276
+ doing searches like this.
277
+
278
+ I'm also thinking of keep the viewer thin and not that featureful.
279
+ I'll emphasize the command line features, like using search criteria to
280
+ pipe emails into a text file.
281
+
282
+ Change the architecture so that the daemon is fired up in a separate
283
+ process.
284
+
285
+ I don't think I need to download the RFC822 header, the envelope has
286
+ this data.
287
+
288
+ Done.
289
+
290
+ Next, in the search window, I can keep a history of previous searches.
291
+ And just execute the command that the user hits carriage return on.
292
+
293
+ ENVELOPE: !ruby/struct:Net::IMAP::Envelope
294
+ date: Tue, 7 Dec 2010 11:25:47 -0500
295
+ subject: "Error message: /titles.new"
296
+ from:
297
+ - !ruby/struct:Net::IMAP::Address
298
+ name:
299
+ route:
300
+ mailbox: error
301
+ host: instantwatcher.com
302
+ sender:
303
+ - !ruby/struct:Net::IMAP::Address
304
+ name:
305
+ route:
306
+ mailbox: error
307
+ host: instantwatcher.com
308
+ reply_to:
309
+ - !ruby/struct:Net::IMAP::Address
310
+ name:
311
+ route:
312
+ mailbox: error
313
+ host: instantwatcher.com
314
+ to:
315
+ - !ruby/struct:Net::IMAP::Address
316
+ name:
317
+ route:
318
+ mailbox: dhchoi
319
+ host: gmail.com
320
+ cc:
321
+ bcc:
322
+ in_reply_to:
323
+ message_id: <4cfe600b1cd1f_202540e109c8ee@ubuntu.tmail>
324
+
325
+
326
+
327
+
328
+ (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:3235:in `parse_error': unknown token - "\"[Christian" (Net::IMAP::ResponseParseError)
329
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:3180:in `next_token'
330
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:3097:in `lookahead'
331
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:2995:in `nstring'
332
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:2183:in `envelope'
333
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:2170:in `envelope_data'
334
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:2145:in `msg_att'
335
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:2125:in `numeric_response'
336
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:2067:in `response_untagged'
337
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:2047:in `response'
338
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:1973:in `parse'
339
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:1124:in `get_response'
340
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:1036:in `receive_responses'
341
+ from (druby://127.0.0.1:61676) /Users/choi/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/imap.rb:1023:in `block in initialize'
342
+ from run.rb:8:in `block in <main>'
343
+ from run.rb:7:in `open'
344
+ from run.rb:7:in `<main>'
345
+
346
+
347
+
348
+ # Sends a APPEND command to append the +message+ to the end of
349
+ # the +mailbox+. The optional +flags+ argument is an array of
350
+ # flags to initially passing to the new message. The optional
351
+ # +date_time+ argument specifies the creation time to assign to the
352
+ # new message; it defaults to the current time.
353
+ # For example:
354
+ #
355
+ # imap.append("inbox", <<EOF.gsub(/\n/, "\r\n"), [:Seen], Time.now)
356
+ # Subject: hello
357
+ # From: shugo@ruby-lang.org
358
+ # To: shugo@ruby-lang.org
359
+ #
360
+ # hello world
361
+ # EOF
362
+ #
363
+ # A Net::IMAP::NoResponseError is raised if the mailbox does
364
+ # not exist (it is not created automatically), or if the flags,
365
+ # date_time, or message arguments contain errors.
366
+
367
+
368
+
369
+
370
+ Next, I think I need to restore the vertical mailbox selection mode, and
371
+ then have the search window execute in the current mailbox.
372
+
373
+ Finally, I need to eliminate the limit number (on search) and just to dynamic
374
+ back-paging when a user gets to the top line, which will say "Get 40
375
+ more messages" or something.
376
+
377
+ Also, forget 2 pane, just toggle full screen message and list view
378
+
379
+ Finally, I need to do autocompletion for contacts.
380
+
381
+
382
+
383
+ done today:
384
+ - backpaging
385
+ - single window at a time
386
+ - vertical mailbox selection
387
+ - no more yaml
388
+
389
+ OK next
390
+ - autocompletion for contacts
391
+ - extract and show attachments, bytesize
392
+ - can't show this without downloading RFC822.header
393
+ - autocomplete better for mailbox
394
+ - STTY adjustment `stty size` from the vim client and sent to back end?
395
+
396
+ This url doesn't open
397
+
398
+ http://twitter.com/#!/kanter/status/12398658028834816
399
+
400
+ Because of the # or !. Wrapping it in quotes double or singles
401
+ doesn't fix the prob. Need to use system and shellescape
402
+
403
+ TODO
404
+ - display current mailbox somewhere, and also search query
405
+ - allow splitting the window to keep multiple messages open. Don't call only.
406
+ - move to - done
407
+ - contacts!
408
+ - character encodings
409
+
410
+ echo winwidth(1)
411
+ use this instead of system('stty size') to get window width
412
+ - then adjust the column sizes
413
+
414
+ :set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
415
+
416
+ - in .vmail/ dir?
417
+
418
+ ------------------------------------------------------------------------
419
+ Thu Dec 9 10:13:53 EST 2010
420
+
421
+ - got status line to show current mailbox. Next I just need to show the
422
+ current search query!
423
+ - got bells to go away in most cases
424
+ - need to work on autocomplete for addressbook
425
+ - getting there!
426
+
427
+ - ok i got statusline working in principle
428
+
429
+ - next, do contacts
430
+ - fix encoding issues
431
+ - get ready to release. Monday seems doable.
432
+
433
+ for contacts, use dictionary file option in vim
434
+
435
+
436
+ DONE
437
+ - contacts, proof of concept
438
+ - encoding issues (some at least)
439
+ - get reply template recipients right
440
+ - forwarding (not with attachments)
441
+ - auto-adjusting column widths depending on window width
442
+ - for older message, replace time with year
443
+ - signature
444
+ - open hyperlink in browser (OS X only?)
445
+ - open html in browser
446
+ - when show_next_message, get message without flashing the list
447
+ - solved by restoring two pane view
448
+ - when loading update, position cursor on first new message
449
+ - spacebar in message window to fullscreen the message and toggle back
450
+ - spam range
451
+ - in list, show message sizes
452
+ - prevent the "8 more lines" and wait for enter. 2 is the threshhold
453
+ - fix compose message, reply windowing
454
+ - mapping improvements:
455
+ - straight to reply from list window
456
+ - fixed addresses in recipients to a reply all
457
+ - position cursor conveniently on opening compose windows
458
+ - show num additional when in sent msg list
459
+ - save drafts on server to [Gmail]/Drafts
460
+ - use unquote_and_convert for subject lines?
461
+ - attachments extraction
462
+ - encoding issues (korean)
463
+ - plus use iconv for 1.8
464
+ - search for from kr
465
+ - can't rely on mail.encoding to be non-nil
466
+ - if html version, command to open
467
+
468
+
469
+ next:
470
+ - create another bin wrapper to start both daemon and client from same
471
+ window. redirect streams from daemon to a log file
472
+ - can alter dep on command line opts
473
+ - package gem
474
+ - vmail-server
475
+ - vmail (client)
476
+ - try running as one wrapper process
477
+ - sending an attachment
478
+ - can specify a directory, then all the items in the directory get
479
+ attached and sent
480
+ - forwarding attachments
481
+ - could be "attach: [uid] attachments to signal"
482
+ - use :wq to send compose message, not ,d (easy to confuse with delete!)
483
+ - close! to cancel
484
+ - fewer mappings to remember this way
485
+ - put instructions in message window; put in a top section
486
+ - map u update from message window
487
+ - follow mysql and use -u and -p flags on startup of server?
488
+ - omitting -p flag forces prompt
489
+ - get rid of config file
490
+ - use temp files
491
+ - tempname()
492
+ - system() allows a parameters that is written to tmp file and passed
493
+ to stdin
494
+ - help document should just be readme? or part of it.
495
+ - print all selected messages into file (append)
496
+ - can pipe through a command line tool, so we don't need to clutter
497
+ viewer.vim with more mappings and functions
498
+ - put "move to >" and "select mailbox >" in command window
499
+ - make compat with ruby 1.8
500
+ - help
501
+ - readme
502
+ - ,s s confusion? Star vs search
503
+ - sort contacts by frequency, then take first 10 or so of any match
504
+ group
505
+ - enhance contacts auto fix with more advance vim script
506
+ - mvim = allow using through VMAIL_EDITOR env variable
507
+
508
+ later:
509
+ - allow one daemon, multiple clients (select mailbox?)
510
+ - remember searches?
511
+ - archive function (shortcut for move to all mail)
512
+ - crate to package app as a OS X app?
513
+ http://rubyconf2008.confreaks.com/crate-packaging-your-ruby-application.html
514
+ - need to bundle macvim
515
+ - if move to unknown mailbox, create the mailbox, then do the move
516
+ - some lingering encoding issues
517
+ - something is wrong with cursorline sometimes
518
+ - try flashing progress in echo line
519
+ - straight to switch mailbox, etc from message window
520
+ - allow deliver command from any buffer or window, as long as headers are at top
521
+ - range selection from : prompt
522
+ - starring
523
+ - do fast action like deletes
524
+ - reload after window resize
525
+ - sometimes update doesn't work - bug
526
+ - message threads
527
+
528
+
529
+
530
+ ------------------------------------------------------------------------
531
+
532
+ Threading
533
+ how to find the message that a message is in reply-to
534
+
535
+ imap.search ["HEADER", "MESSAGE-ID", "<757FC46C-9394-494E-91B4-B051F48419DA@prx.org>"]
536
+
537
+ :! ls %
538
+
539
+ % is filename
540
+
541
+