gmailer 0.0.9 → 0.1.0
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/CHANGES +5 -0
- data/README +34 -22
- data/gmailer.rb +260 -151
- metadata +2 -2
data/CHANGES
CHANGED
data/README
CHANGED
@@ -39,7 +39,7 @@
|
|
39
39
|
GMailer.connect(name, pwd) do |g|
|
40
40
|
puts "Your frequently used addresses:"
|
41
41
|
g.fetch(:contact=>"freq").each do |item|
|
42
|
-
puts "Name: #{item
|
42
|
+
puts "Name: #{item.name} Email: #{item.email}"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -48,7 +48,7 @@
|
|
48
48
|
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
49
49
|
labels = g.labels
|
50
50
|
g.messages(:label=>labels[0]).each {|m|
|
51
|
-
puts "Subject: #{m
|
51
|
+
puts "Subject: #{m.subject} / Snippet: #{m.snippet}" if m.new?
|
52
52
|
}
|
53
53
|
end
|
54
54
|
|
@@ -70,6 +70,14 @@ GMailer.connect(:username=>name,:password=>pwd) do |g|
|
|
70
70
|
#removing a label from a message
|
71
71
|
g.remove_label(msgid,'label_name')
|
72
72
|
|
73
|
+
g.msg(msgid) {|m|
|
74
|
+
#applying a label to a message
|
75
|
+
m.apply_label('label_name')
|
76
|
+
|
77
|
+
#removing a label from a message
|
78
|
+
m.remove_label('label_name')
|
79
|
+
}
|
80
|
+
|
73
81
|
end
|
74
82
|
|
75
83
|
=== Update preferece
|
@@ -84,79 +92,80 @@ GMailer.connect(:username=>name,:password=>pwd) do |g|
|
|
84
92
|
:snippets=>true,
|
85
93
|
:display_name=>'Display Name')
|
86
94
|
pref = g.preference
|
87
|
-
puts "Display language:#{pref
|
95
|
+
puts "Display language:#{pref.display_language}, Max Page Size:#{pref.max_page_size}"
|
88
96
|
end
|
89
97
|
|
90
98
|
=== Apply star and remove star
|
91
99
|
|
92
100
|
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
101
|
+
|
93
102
|
#apply star to a message
|
94
|
-
g.apply_star(msgid)
|
103
|
+
g.apply_star(msgid) # or g.msg(msgid).apply_star
|
95
104
|
|
96
105
|
#remove star from a message
|
97
|
-
g.remove_star(msgid)
|
106
|
+
g.remove_star(msgid) # or g.msg(msgid).remove_star
|
98
107
|
end
|
99
108
|
|
100
109
|
=== Archive and unarchive a message
|
101
110
|
|
102
111
|
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
103
112
|
#archive a message
|
104
|
-
g.archive(msgid)
|
113
|
+
g.archive(msgid) # or g.msg(msgid).archive
|
105
114
|
|
106
115
|
#unarchive a message
|
107
|
-
g.unarchive(msgid)
|
116
|
+
g.unarchive(msgid) # or g.msg(msgid).unarchive
|
108
117
|
end
|
109
118
|
|
110
119
|
=== Mark read and unread a message
|
111
120
|
|
112
121
|
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
113
122
|
#mark a message as read
|
114
|
-
g.mark_read(msgid)
|
123
|
+
g.mark_read(msgid) # or g.msg(msgid).mark_read
|
115
124
|
|
116
125
|
#mark a message as unread
|
117
|
-
g.mark_unread(msgid)
|
126
|
+
g.mark_unread(msgid) # or g.msg(msgid).mark_unread
|
118
127
|
end
|
119
128
|
|
120
129
|
=== Report spam and reverse
|
121
130
|
|
122
131
|
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
123
132
|
#report a message as not spam
|
124
|
-
g.report_spam(msgid)
|
133
|
+
g.report_spam(msgid) # or g.msg(msgid).report_spam
|
125
134
|
|
126
135
|
#report a message as not spam
|
127
|
-
g.report_not_spam(msgid)
|
136
|
+
g.report_not_spam(msgid) # or g.msg(msgid).report_not_spam
|
128
137
|
end
|
129
138
|
|
130
139
|
=== Trash In & Out and delete a message
|
131
140
|
|
132
141
|
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
133
142
|
#move a message to trash
|
134
|
-
g.trash(msgid)
|
143
|
+
g.trash(msgid) # or g.msg(msgid).trash
|
135
144
|
|
136
145
|
#move a message from trash to inbox
|
137
|
-
g.untrash(msgid)
|
146
|
+
g.untrash(msgid) # or g.msg(msgid).untrash
|
138
147
|
|
139
148
|
#delete a trash message forever
|
140
|
-
g.delete_trash(msgid)
|
149
|
+
g.delete_trash(msgid) # or g.msg(msgid).delete_trash
|
141
150
|
|
142
151
|
#delete a spam message forever
|
143
|
-
g.delete_spam(msgid)
|
152
|
+
g.delete_spam(msgid) # or g.msg(msgid).delete_spam
|
144
153
|
|
145
154
|
#delete a message forever
|
146
|
-
g.delete_message(msgid)
|
155
|
+
g.delete_message(msgid) # or g.msg(msgid).delete_message
|
147
156
|
end
|
148
157
|
|
149
158
|
=== Show Original Message
|
150
159
|
|
151
160
|
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
152
161
|
#show original
|
153
|
-
g.show_original(msgid)
|
162
|
+
g.show_original(msgid) # of g.msg(msgid).original
|
154
163
|
}
|
155
164
|
|
156
165
|
=== Fetch messages with filter
|
157
166
|
|
158
167
|
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
159
|
-
g.messages(:standard=>'all',:read=>false).
|
168
|
+
g.messages(:standard=>'all',:read=>false).each_msg {|msg|
|
160
169
|
msg.apply_star
|
161
170
|
msg.apply_label(label)
|
162
171
|
puts "subject: " + msg.subject
|
@@ -263,6 +272,9 @@ archive(msgid)
|
|
263
272
|
unarchive(msgid)
|
264
273
|
To unarchive a message
|
265
274
|
|
275
|
+
msg(msgid)
|
276
|
+
To fetch a message with msgid
|
277
|
+
|
266
278
|
update_preference(preference hash)
|
267
279
|
To update preference setting
|
268
280
|
hash is one of :max_page_size(25,50,100),:keyboard_shortcuts(true,false),:indicators(true,false),
|
@@ -395,7 +407,7 @@ box_pos
|
|
395
407
|
box
|
396
408
|
An array of conversations in current mailbox.
|
397
409
|
|
398
|
-
===
|
410
|
+
=== methods of each conversation
|
399
411
|
id
|
400
412
|
Conversation ID
|
401
413
|
|
@@ -456,7 +468,7 @@ conv_starred
|
|
456
468
|
conv
|
457
469
|
An array of messages of current conversation.
|
458
470
|
|
459
|
-
===
|
471
|
+
=== conversation method
|
460
472
|
index
|
461
473
|
Index.
|
462
474
|
|
@@ -511,7 +523,7 @@ body
|
|
511
523
|
attachment
|
512
524
|
An array of attachment-information.
|
513
525
|
|
514
|
-
===
|
526
|
+
=== methods of each attachment
|
515
527
|
id
|
516
528
|
Attachment ID.
|
517
529
|
|
@@ -530,7 +542,7 @@ size
|
|
530
542
|
contacts
|
531
543
|
An array of entries of your address book.
|
532
544
|
|
533
|
-
===
|
545
|
+
=== methods of each contact
|
534
546
|
name
|
535
547
|
Name (nickname).
|
536
548
|
|
data/gmailer.rb
CHANGED
@@ -26,6 +26,8 @@ GM_QUERY = 0x008
|
|
26
26
|
GM_CONTACT = 0x010
|
27
27
|
GM_PREFERENCE = 0x020
|
28
28
|
GM_SHOWORIGINAL = 0x040
|
29
|
+
GM_CONV_SPAM = 0x080
|
30
|
+
GM_CONV_TRASH = 0x100
|
29
31
|
|
30
32
|
GM_ACT_CREATELABEL = 1
|
31
33
|
GM_ACT_DELETELABEL = 2
|
@@ -50,7 +52,7 @@ GM_ACT_DELSPAM = 20 # delete spam, forever
|
|
50
52
|
GM_ACT_DELTRASH = 21 # delete trash message, forever
|
51
53
|
|
52
54
|
module GMailer
|
53
|
-
VERSION = "0.0
|
55
|
+
VERSION = "0.1.0"
|
54
56
|
attr_accessor :connection
|
55
57
|
|
56
58
|
# the main class.
|
@@ -210,7 +212,6 @@ module GMailer
|
|
210
212
|
end
|
211
213
|
|
212
214
|
|
213
|
-
|
214
215
|
#
|
215
216
|
# return bool
|
216
217
|
# desc See if it is connected to GMail.
|
@@ -307,7 +308,29 @@ module GMailer
|
|
307
308
|
q = "search=cat&cat=" + box.to_s + "&view=tl&start=" + pos.to_s
|
308
309
|
|
309
310
|
when GM_CONVERSATION
|
310
|
-
q = "search=
|
311
|
+
q = "search=all&ser=1&view=cv"
|
312
|
+
if (box.class==Array)
|
313
|
+
q += "&th=" + box[0].to_s
|
314
|
+
for i in 1 .. box.length
|
315
|
+
q += "&msgs=" + box[i].to_s
|
316
|
+
end
|
317
|
+
else
|
318
|
+
q += "&th=" + box.to_s
|
319
|
+
end
|
320
|
+
|
321
|
+
when GM_CONV_SPAM
|
322
|
+
q = "search=spam&ser=1&view=cv"
|
323
|
+
if (box.class==Array)
|
324
|
+
q += "&th=" + box[0].to_s
|
325
|
+
for i in 1 .. box.length
|
326
|
+
q += "&msgs=" + box[i].to_s
|
327
|
+
end
|
328
|
+
else
|
329
|
+
q += "&th=" + box.to_s
|
330
|
+
end
|
331
|
+
|
332
|
+
when GM_CONV_TRASH
|
333
|
+
q = "search=trash&ser=1&view=cv"
|
311
334
|
if (box.class==Array)
|
312
335
|
q += "&th=" + box[0].to_s
|
313
336
|
for i in 1 .. box.length
|
@@ -390,20 +413,44 @@ module GMailer
|
|
390
413
|
end
|
391
414
|
box = "inbox" unless box
|
392
415
|
fetch_box(type,box,pos)
|
416
|
+
if type == GM_CONVERSATION
|
417
|
+
fetch_box(GM_CONV_SPAM,box,pos) if @raw['mg'].nil?
|
418
|
+
fetch_box(GM_CONV_TRASH,box,pos) if @raw['mg'].nil?
|
419
|
+
end
|
420
|
+
|
393
421
|
if type == GM_SHOWORIGINAL
|
394
|
-
|
422
|
+
ss = @raw
|
395
423
|
else
|
396
|
-
|
424
|
+
ss = snapshot(type)
|
397
425
|
end
|
398
426
|
if block_given?
|
399
|
-
yield(
|
427
|
+
yield(ss)
|
400
428
|
elsif type == GM_CONTACT
|
401
|
-
|
429
|
+
ss.contacts
|
402
430
|
else
|
403
|
-
|
431
|
+
ss
|
404
432
|
end
|
405
433
|
end
|
406
434
|
|
435
|
+
#
|
436
|
+
# return message
|
437
|
+
# param message id
|
438
|
+
# desc Fetch a message with message id
|
439
|
+
#
|
440
|
+
def msg(msgid)
|
441
|
+
m = fetch(:conversation=>msgid).message
|
442
|
+
if m.nil? then
|
443
|
+
raise ArgumentError, 'Message Not Exist'
|
444
|
+
end
|
445
|
+
m.connection = self
|
446
|
+
if block_given?
|
447
|
+
yield(m)
|
448
|
+
else
|
449
|
+
m
|
450
|
+
end
|
451
|
+
|
452
|
+
end
|
453
|
+
|
407
454
|
#
|
408
455
|
# return string[]
|
409
456
|
# param string[] convs
|
@@ -418,11 +465,11 @@ module GMailer
|
|
418
465
|
end
|
419
466
|
final = []
|
420
467
|
convs.each { |v|
|
421
|
-
if v
|
422
|
-
v
|
423
|
-
f = path+"/"+vv
|
424
|
-
f = path+"/"+vv
|
425
|
-
if attachment(vv
|
468
|
+
if v.attachment
|
469
|
+
v.attachment.each { |vv|
|
470
|
+
f = path+"/"+vv.filename
|
471
|
+
f = path+"/"+vv.filename+"."+rand(2000).to_s while (FileTest.exist?(f))
|
472
|
+
if attachment(vv.id,v.id,f,false)
|
426
473
|
final.push(f)
|
427
474
|
end
|
428
475
|
}
|
@@ -448,7 +495,7 @@ module GMailer
|
|
448
495
|
end
|
449
496
|
final = []
|
450
497
|
convs.each {|v|
|
451
|
-
if v
|
498
|
+
if v.attachment
|
452
499
|
f = path+"/attachment.zip"
|
453
500
|
f = path+"/attachment."+rand(2000).to_s+".zip" while (FileTest.exist?(f))
|
454
501
|
if attachment(v["attachment"][0]["id"],v["id"],f,true)
|
@@ -832,9 +879,9 @@ module GMailer
|
|
832
879
|
@filter.keys.each do |k|
|
833
880
|
case k
|
834
881
|
when :read
|
835
|
-
ml.box = ml.box.find_all { |x| x
|
882
|
+
ml.box = ml.box.find_all { |x| x.read? == @filter[k] }
|
836
883
|
when :star
|
837
|
-
ml.box = ml.box.find_all { |x| x
|
884
|
+
ml.box = ml.box.find_all { |x| x.star? == @filter[k] }
|
838
885
|
end
|
839
886
|
end
|
840
887
|
ml.connection = self
|
@@ -1253,27 +1300,23 @@ module GMailer
|
|
1253
1300
|
end
|
1254
1301
|
@box = []
|
1255
1302
|
if raw["t"]
|
1256
|
-
raw["t"].each
|
1303
|
+
raw["t"].each do |t|
|
1257
1304
|
if (t != "t")
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
}
|
1274
|
-
@box.push(b)
|
1275
|
-
end
|
1276
|
-
}
|
1305
|
+
b = Box.new
|
1306
|
+
b.id = t[0]
|
1307
|
+
b.is_read = (t[1] != 1 ? 1 : 0)
|
1308
|
+
b.is_starred = (t[2] == 1 ? 1 : 0)
|
1309
|
+
b.date = decode(strip_tags(t[3]))
|
1310
|
+
b.sender = decode(strip_tags(t[4]))
|
1311
|
+
b.flag = t[5]
|
1312
|
+
b.subject = decode(strip_tags(t[6]))
|
1313
|
+
b.snippet = decode(t[7].gsub('"','"').gsub('…','...'))
|
1314
|
+
b.labels = t[8].empty? ? [] : t[8].map{|tt|decode(tt)}
|
1315
|
+
b.attachment = t[9].empty? ? []: decode(t[9]).split(",")
|
1316
|
+
b.msgid = t[10]
|
1317
|
+
@box.push(b)
|
1318
|
+
end
|
1319
|
+
end
|
1277
1320
|
end
|
1278
1321
|
|
1279
1322
|
if (!raw["cs"].nil?)
|
@@ -1308,74 +1351,82 @@ module GMailer
|
|
1308
1351
|
@conv_starred = false
|
1309
1352
|
|
1310
1353
|
@conv = []
|
1311
|
-
b =
|
1312
|
-
raw["mg"].each
|
1354
|
+
b = Conversation.new
|
1355
|
+
raw["mg"].each do |r|
|
1313
1356
|
if (r[0] == "mb")
|
1314
|
-
b
|
1315
|
-
b
|
1357
|
+
b.body = '' if b.body.nil?
|
1358
|
+
b.body += r[1]
|
1316
1359
|
if (r[2] == 0)
|
1317
|
-
b
|
1360
|
+
b.body = decode(b.body)
|
1318
1361
|
@conv.push(b)
|
1319
|
-
b =
|
1362
|
+
b = Conversation.new
|
1320
1363
|
end
|
1321
1364
|
elsif (r[0] == "mi")
|
1322
|
-
if !b.
|
1365
|
+
if !b.id.nil?
|
1323
1366
|
@conv.push(b)
|
1324
|
-
b =
|
1367
|
+
b = Conversation.new
|
1325
1368
|
end
|
1326
|
-
b =
|
1327
|
-
b
|
1328
|
-
b
|
1329
|
-
b
|
1330
|
-
|
1331
|
-
|
1369
|
+
b = Conversation.new
|
1370
|
+
b.index = r[2]
|
1371
|
+
b.id = r[3]
|
1372
|
+
b.is_star = r[4]
|
1373
|
+
@conv_starred = (b.is_star == 1)
|
1374
|
+
b.sender = decode(r[6])
|
1375
|
+
b.sender_email = r[8].gsub("\"",'') # remove annoying d-quotes in address
|
1376
|
+
b.recv = r[9]
|
1377
|
+
b.recv_email = r[11].to_s.gsub("\"",'')
|
1378
|
+
b.reply_email = r[14].to_s.gsub("\"",'')
|
1379
|
+
b.dt_easy = r[10]
|
1380
|
+
b.dt = r[15]
|
1381
|
+
b.subject = decode(r[16])
|
1382
|
+
b.snippet = decode(r[17])
|
1383
|
+
b.attachment = []
|
1384
|
+
r[18].each do |bb|
|
1385
|
+
at = Attachment.new
|
1386
|
+
at.id = bb[0]
|
1387
|
+
at.filename = bb[1]
|
1388
|
+
at.type = bb[2]
|
1389
|
+
at.size = bb[3]
|
1390
|
+
b.attachment.push(at)
|
1332
1391
|
end
|
1333
|
-
b
|
1334
|
-
b
|
1335
|
-
b["recv"] = r[9]
|
1336
|
-
b["recv_email"] = r[11].to_s.gsub("\"",'')
|
1337
|
-
b["reply_email"] = r[14].to_s.gsub("\"",'')
|
1338
|
-
b["dt_easy"] = r[10]
|
1339
|
-
b["dt"] = r[15]
|
1340
|
-
b["subject"] = decode(r[16])
|
1341
|
-
b["snippet"] = decode(r[17])
|
1342
|
-
b["attachment"] = []
|
1343
|
-
r[18].each {|bb|
|
1344
|
-
b["attachment"].push({"id"=>bb[0],"filename"=>bb[1],"type"=>bb[2],"size"=>bb[3]})
|
1345
|
-
}
|
1346
|
-
b["is_draft"] = false
|
1347
|
-
b["body"] = ''
|
1392
|
+
b.is_draft = false
|
1393
|
+
b.body = ''
|
1348
1394
|
elsif (r[0] == "di")
|
1349
|
-
if !b.
|
1395
|
+
if !b.id.nil?
|
1350
1396
|
@conv.push(b)
|
1351
|
-
b =
|
1397
|
+
b = Converation.new
|
1352
1398
|
end
|
1353
|
-
b =
|
1354
|
-
b
|
1355
|
-
b
|
1356
|
-
b
|
1357
|
-
@conv_starred = (b
|
1358
|
-
b
|
1359
|
-
b
|
1360
|
-
b
|
1361
|
-
b
|
1362
|
-
b
|
1363
|
-
b
|
1364
|
-
b
|
1365
|
-
b
|
1366
|
-
b
|
1367
|
-
b
|
1368
|
-
b
|
1369
|
-
b
|
1370
|
-
r[18].each
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1399
|
+
b = Converation.new
|
1400
|
+
b.index = r[2]
|
1401
|
+
b.id = r[3]
|
1402
|
+
b.is_star = r[4]
|
1403
|
+
@conv_starred = (b.is_star == 1)
|
1404
|
+
b.sender = decode(r[6])
|
1405
|
+
b.sender_email = r[8].gsub("\"",'') # remove annoying d-quotes in address
|
1406
|
+
b.recv = r[9]
|
1407
|
+
b.recv_email = r[11].gsub("\"",'')
|
1408
|
+
b.reply_email = r[14].gsub("\"",'')
|
1409
|
+
b.cc_email = r[12].gsub("\"",'')
|
1410
|
+
b.bcc_email = r[13].gsub("\"",'')
|
1411
|
+
b.dt_easy = r[10]
|
1412
|
+
b.dt = r[15]
|
1413
|
+
b.subject = decode(r[16])
|
1414
|
+
b.snippet = decode(r[17])
|
1415
|
+
b.attachment = []
|
1416
|
+
r[18].each do |bb|
|
1417
|
+
at = Attachment.new
|
1418
|
+
at.id = bb[0]
|
1419
|
+
at.filename = bb[1]
|
1420
|
+
at.type = bb[2]
|
1421
|
+
at.size = bb[3]
|
1422
|
+
b.attachment.push(at)
|
1423
|
+
end
|
1424
|
+
b.is_draft = true
|
1425
|
+
b.draft_parent = r[5]
|
1426
|
+
b.body = decode(r[20])
|
1376
1427
|
end
|
1377
|
-
|
1378
|
-
@conv.push(b) unless b.
|
1428
|
+
end
|
1429
|
+
@conv.push(b) unless !b.id.nil?
|
1379
1430
|
@message = Message.new(@conv_tile,@conv_total,@conv_id,@conv_labels,@conv_starred)
|
1380
1431
|
@message.conv = @conv
|
1381
1432
|
end
|
@@ -1383,14 +1434,11 @@ module GMailer
|
|
1383
1434
|
@contacts = []
|
1384
1435
|
if raw["ce"]
|
1385
1436
|
raw["ce"].each {|a|
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
b["notes"] = a[5]
|
1392
|
-
end
|
1393
|
-
@contacts.push(b)
|
1437
|
+
c = Contact.new
|
1438
|
+
c.name = a[2]
|
1439
|
+
c.email = a[4].gsub("\"",'')
|
1440
|
+
c.notes = a[5] if !a[5].empty?
|
1441
|
+
@contacts.push(c)
|
1394
1442
|
}
|
1395
1443
|
end
|
1396
1444
|
@view = GM_CONTACT
|
@@ -1399,33 +1447,25 @@ module GMailer
|
|
1399
1447
|
raw["p"].each_with_index { |v,i|
|
1400
1448
|
prefs[v[0]] = v[1] if i>0
|
1401
1449
|
}
|
1402
|
-
@preference =
|
1403
|
-
'keyboard_shortcuts'=>false,
|
1404
|
-
'indicators'=>false,
|
1405
|
-
'display_language'=>'en',
|
1406
|
-
'signature'=>'',
|
1407
|
-
'reply_to'=>'',
|
1408
|
-
'snippets'=>false,
|
1409
|
-
'display_name'=>'',
|
1410
|
-
}
|
1450
|
+
@preference = Preference.new
|
1411
1451
|
prefs.each do |k,v|
|
1412
1452
|
case k
|
1413
1453
|
when 'ix_nt'
|
1414
|
-
@preference
|
1454
|
+
@preference.max_page_size = v
|
1415
1455
|
when 'bx_hs'
|
1416
|
-
@preference
|
1456
|
+
@preference.keyboard_shortcuts = (v == '1')
|
1417
1457
|
when 'bx_sc'
|
1418
|
-
@preference
|
1458
|
+
@preference.indicators = (v == '1')
|
1419
1459
|
when 'sx_dl'
|
1420
|
-
@preference
|
1460
|
+
@preference.display_language = v
|
1421
1461
|
when 'sx_sg'
|
1422
|
-
@preference
|
1462
|
+
@preference.signature = (v == '0') ? '' : v
|
1423
1463
|
when 'sx_rt'
|
1424
|
-
@preference
|
1464
|
+
@preference.reply_to = v
|
1425
1465
|
when 'bx_ns'
|
1426
|
-
@preference
|
1466
|
+
@preference.snippets = (v == '0')
|
1427
1467
|
when 'sx_dn'
|
1428
|
-
@preference
|
1468
|
+
@preference.display_name = v
|
1429
1469
|
end
|
1430
1470
|
end
|
1431
1471
|
|
@@ -1442,28 +1482,23 @@ module GMailer
|
|
1442
1482
|
}
|
1443
1483
|
end
|
1444
1484
|
@filter = []
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
}
|
1463
|
-
|
1464
|
-
@filter.push(b)
|
1465
|
-
@filter_rules.push(bb)
|
1466
|
-
}
|
1485
|
+
raw["fi"][1].each do |fi|
|
1486
|
+
f = Filter.new
|
1487
|
+
f.id = fi[0]
|
1488
|
+
f.query = fi[1]
|
1489
|
+
f.star = fi[3]
|
1490
|
+
f.label = fi[4]
|
1491
|
+
f.archive = fi[5]
|
1492
|
+
f.trash = fi[6]
|
1493
|
+
f.from = fi[2][0]
|
1494
|
+
f.to = fi[2][1]
|
1495
|
+
f.subject = fi[2][2]
|
1496
|
+
f.has = fi[2][3]
|
1497
|
+
f.hasnot = fi[2][4]
|
1498
|
+
f.attach = fi[2][5]
|
1499
|
+
|
1500
|
+
@filter.push(b)
|
1501
|
+
end
|
1467
1502
|
@view = GM_PREFERENCE
|
1468
1503
|
else
|
1469
1504
|
@created = 0
|
@@ -1476,6 +1511,31 @@ module GMailer
|
|
1476
1511
|
|
1477
1512
|
end
|
1478
1513
|
|
1514
|
+
# a single filter
|
1515
|
+
class Filter
|
1516
|
+
attr_accessor :id,:query,:star,:label,:archive,:trash
|
1517
|
+
attr_accessor :from,:to,:subject,:has,:hasnot,:attach
|
1518
|
+
end
|
1519
|
+
|
1520
|
+
# a single box
|
1521
|
+
class Box
|
1522
|
+
attr_accessor :id, :is_read, :is_starred, :date, :msgid
|
1523
|
+
attr_accessor :sender, :flag, :subject, :snippet, :labels, :attachment
|
1524
|
+
|
1525
|
+
def read?
|
1526
|
+
is_read == 1
|
1527
|
+
end
|
1528
|
+
|
1529
|
+
def new?
|
1530
|
+
is_read != 1
|
1531
|
+
end
|
1532
|
+
|
1533
|
+
def star?
|
1534
|
+
is_starred == 1
|
1535
|
+
end
|
1536
|
+
|
1537
|
+
end
|
1538
|
+
|
1479
1539
|
# a list of messages.
|
1480
1540
|
class MessageList
|
1481
1541
|
attr_reader :name, :total, :pos
|
@@ -1488,15 +1548,13 @@ module GMailer
|
|
1488
1548
|
|
1489
1549
|
def each(&block)
|
1490
1550
|
@box.each do |b|
|
1491
|
-
|
1492
|
-
m.connection = @connection
|
1493
|
-
block.call(m)
|
1551
|
+
block.call(b)
|
1494
1552
|
end
|
1495
1553
|
end
|
1496
|
-
|
1497
|
-
def
|
1498
|
-
@box.
|
1499
|
-
m = connection.fetch(:conversation=>b
|
1554
|
+
|
1555
|
+
def each_msg(&block)
|
1556
|
+
@box.each do |b|
|
1557
|
+
m = connection.fetch(:conversation=>b.id).message
|
1500
1558
|
m.connection = @connection
|
1501
1559
|
block.call(m)
|
1502
1560
|
end
|
@@ -1504,6 +1562,56 @@ module GMailer
|
|
1504
1562
|
|
1505
1563
|
end
|
1506
1564
|
|
1565
|
+
# a Preference
|
1566
|
+
class Preference
|
1567
|
+
attr_accessor :max_page_size, :keyboard_shortcuts, :indicators, :display_language
|
1568
|
+
attr_accessor :signature, :reply_to, :snippets, :display_name
|
1569
|
+
def initialize
|
1570
|
+
@max_page_size = '10'
|
1571
|
+
@keyboard_shortcuts = false
|
1572
|
+
@indicators = false
|
1573
|
+
@display_language = 'en'
|
1574
|
+
@signature = ''
|
1575
|
+
@reply_to = ''
|
1576
|
+
@snippets = false
|
1577
|
+
@display_name = ''
|
1578
|
+
end
|
1579
|
+
end
|
1580
|
+
|
1581
|
+
# a Preference
|
1582
|
+
class Contact
|
1583
|
+
attr_accessor :name,:email,:notes
|
1584
|
+
def initialize
|
1585
|
+
@name = ''
|
1586
|
+
@email = ''
|
1587
|
+
@notes = ''
|
1588
|
+
end
|
1589
|
+
end
|
1590
|
+
|
1591
|
+
# a single attachment
|
1592
|
+
class Attachment
|
1593
|
+
attr_accessor :id, :filename, :type, :size
|
1594
|
+
end
|
1595
|
+
|
1596
|
+
# a single converation
|
1597
|
+
class Conversation
|
1598
|
+
attr_accessor :id, :index, :body, :draft_parent, :is_draft, :attachment
|
1599
|
+
attr_accessor :snippet, :subject, :dt, :dt_easy, :bcc_email, :cc_email
|
1600
|
+
attr_accessor :reply_email, :recv_email, :recv, :sender_email, :sender, :is_star
|
1601
|
+
def read?
|
1602
|
+
is_read == 1
|
1603
|
+
end
|
1604
|
+
|
1605
|
+
def new?
|
1606
|
+
is_read != 1
|
1607
|
+
end
|
1608
|
+
|
1609
|
+
def star?
|
1610
|
+
is_starred == 1
|
1611
|
+
end
|
1612
|
+
|
1613
|
+
end
|
1614
|
+
|
1507
1615
|
# a single message
|
1508
1616
|
class Message
|
1509
1617
|
attr_reader :title, :total, :id, :labels, :starred
|
@@ -1518,7 +1626,7 @@ module GMailer
|
|
1518
1626
|
|
1519
1627
|
def method_missing(methId)
|
1520
1628
|
str = methId.id2name
|
1521
|
-
@conv[0]
|
1629
|
+
@conv[0].method(str).call
|
1522
1630
|
end
|
1523
1631
|
|
1524
1632
|
#
|
@@ -1573,9 +1681,6 @@ module GMailer
|
|
1573
1681
|
@connection.perform_action(GM_ACT_INBOX,@id, '')
|
1574
1682
|
end
|
1575
1683
|
|
1576
|
-
def archived?()
|
1577
|
-
end
|
1578
|
-
|
1579
1684
|
#
|
1580
1685
|
# return boolean
|
1581
1686
|
# param string msgid
|
@@ -1595,7 +1700,11 @@ module GMailer
|
|
1595
1700
|
end
|
1596
1701
|
|
1597
1702
|
def read?()
|
1598
|
-
@conv[0]
|
1703
|
+
@conv[0].read?
|
1704
|
+
end
|
1705
|
+
|
1706
|
+
def new?()
|
1707
|
+
@conv[0].new?
|
1599
1708
|
end
|
1600
1709
|
|
1601
1710
|
#
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: gmailer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0
|
7
|
-
date: 2005-09-
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2005-09-12
|
8
8
|
summary: "An class interface of the Google's webmail service"
|
9
9
|
require_paths:
|
10
10
|
- ''
|