Skip to content

Commit

Permalink
Print some details on append and fetch actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
lefcha committed Feb 19, 2012
1 parent 644d698 commit 81b09d1
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mailbox.lua
Expand Up @@ -797,6 +797,11 @@ function Mailbox.append_message(self, message, flags, date)
r = ifcore.append(self._account._session, self._mailbox, message, flags,
date)
if r == nil then error("append request failed", 0) end
if options.info == true and r == true then
print(string.format("Appended message of %d octets to %s@%s/%s.",
#message, self._account._username,
self._account._server, self._mailbox))
end

return r
end
Expand Down
60 changes: 60 additions & 0 deletions src/message.lua
Expand Up @@ -35,52 +35,112 @@ end

function Message.fetch_structure(self)
local r = self._mailbox._fetch_structure(self._mailbox, { self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched the structure of %s@%s/%s[%d].",
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

function Message.fetch_header(self)
local r = self._mailbox._fetch_header(self._mailbox, { self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched the header of %s@%s/%s[%d].",
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

function Message.fetch_body(self)
local r = self._mailbox._fetch_body(self._mailbox, { self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched the body of %s@%s/%s[%d].",
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

function Message.fetch_message(self)
local r = self._mailbox._fetch_message(self._mailbox, { self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched message %s@%s/%s[%d].",
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

function Message.fetch_field(self, field)
local r = self._mailbox._fetch_fields(self._mailbox, { field },
{ self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched field \"%s\" of %s@%s/%s[%d].", field,
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

function Message.fetch_fields(self, fields)
local r = self._mailbox._fetch_fields(self._mailbox, fields, { self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched some of the fields of %s@%s/%s[%d].",
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

function Message.fetch_part(self, part)
local r = self._mailbox._fetch_parts(self._mailbox, { part }, self._uid)
if not r or not r[part] then return end
if options.info == true then
print(string.format("Fetched part \"%s\" of %s@%s/%s[%d].", part,
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[part]
end

function Message.fetch_size(self)
local r = self._mailbox._fetch_size(self._mailbox, { self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched the size of %s@%s/%s[%d].",
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

function Message.fetch_date(self)
local r = self._mailbox._fetch_date(self._mailbox, { self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched the date of %s@%s/%s[%d].",
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

function Message.fetch_flags(self)
local r = self._mailbox._fetch_flags(self._mailbox, { self._uid })
if not r or not r[self._uid] then return end
if options.info == true then
print(string.format("Fetched the flags of %s@%s/%s[%d].",
self._account._username, self._account._server,
self._mailbox._mailbox, self._uid))
end
return r[self._uid]
end

Expand Down

0 comments on commit 81b09d1

Please sign in to comment.