aboutsummaryrefslogtreecommitdiff
path: root/gmail.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-10 21:59:15 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-10 21:59:15 +0100
commit77d1a0ba2ff7e75d6feb4ec1c9c4efd2a95bd133 (patch)
treedd52efd7eac8bb0e1257608cb2f522982f3369d6 /gmail.lua
parent1c0cefff8bd4ff7a2aa7e683e1be4fdd1de905f8 (diff)
downloadvicious-legacy-77d1a0ba2ff7e75d6feb4ec1c9c4efd2a95bd133.tar.xz
gmail: switch to ~/.netrc for login storage
Login information is now kept in the ~/.netrc file, which should be readable only by the owner. This should solve futher problems with unquoted characters addressed in the last commit. The format of the ~/.netrc file is as follows (also documented in the README): machine mail.google.com login user password pass
Diffstat (limited to 'gmail.lua')
-rw-r--r--gmail.lua24
1 files changed, 11 insertions, 13 deletions
diff --git a/gmail.lua b/gmail.lua
index da086c7..b4bd081 100644
--- a/gmail.lua
+++ b/gmail.lua
@@ -8,8 +8,11 @@ local type = type
local tonumber = tonumber
local io = { popen = io.popen }
local setmetatable = setmetatable
-local string = { match = string.match }
local helpers = require("vicious.helpers")
+local string = {
+ find = string.find,
+ match = string.match
+}
-- }}}
@@ -21,37 +24,32 @@ module("vicious.gmail")
local rss = {
inbox = {
"https://mail.google.com/mail/feed/atom",
- "Gmail - Inbox for "
+ "Gmail %- Inbox"
},
unread = {
"https://mail.google.com/mail/feed/atom/unread",
- "Gmail - Label &#39;unread&#39; for "
+ "Gmail %- Label"
},
--labelname = {
-- "https://mail.google.com/mail/feed/atom/labelname",
- -- "Gmail - Label &#39;labelname&#39; for "
+ -- "Gmail %- Label"
--},
}
--- Todo: safer storage, maybe hook into Kwallet
-local cfg = {
- user = "", -- user@gmail.com
- pass = "", -- users password
- feed = rss.unread -- default is all unread
-}
+-- Default is all unread
+local feed = rss.unread
-- }}}
-- {{{ Gmail widget type
local function worker(format, warg)
- local auth = cfg.user ..":".. cfg.pass
local mail = {
["{count}"] = 0,
["{subject}"] = "N/A"
}
-- Get info from the Gmail atom feed
- local f = io.popen("curl --connect-timeout 1 -m 3 -fsu '"..auth.."' "..cfg.feed[1])
+ local f = io.popen("curl --connect-timeout 1 -m 3 -fsn " .. feed[1])
-- Could be huge don't read it all at once, info we are after is at the top
for line in f:lines() do
@@ -61,7 +59,7 @@ local function worker(format, warg)
-- Find subject tags
local title = string.match(line, "<title>(.*)</title>")
-- If the subject changed then break out of the loop
- if title ~= nil and title ~= cfg.feed[2] .. cfg.user then
+ if title ~= nil and not string.find(title, feed[2]) then
-- Check if we should scroll, or maybe truncate
if warg then
if type(warg) == "table" then