Print some details on append and fetch actions.

This commit is contained in:
Lefteris Chatzimparmpas 2012-02-19 23:56:54 +01:00
parent 644d6988ed
commit 81b09d1f01
2 changed files with 65 additions and 0 deletions

View File

@ -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

View File

@ -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