2014-09-05 13:02:13 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
|
|
|
local OPDSBrowser = require("ui/widget/opdsbrowser")
|
|
|
|
local UIManager = require("ui/uimanager")
|
2014-10-30 18:42:18 +00:00
|
|
|
local Screen = require("device").screen
|
2014-09-05 13:02:13 +00:00
|
|
|
local DEBUG = require("dbg")
|
|
|
|
local _ = require("gettext")
|
2014-10-22 13:34:11 +00:00
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
2014-09-05 13:02:13 +00:00
|
|
|
|
|
|
|
local OPDSCatalog = InputContainer:extend{
|
|
|
|
title = _("OPDS Catalog"),
|
|
|
|
opds_servers = {
|
|
|
|
{
|
|
|
|
title = "Project Gutenberg",
|
|
|
|
subtitle = "Free ebooks since 1971.",
|
|
|
|
url = "http://m.gutenberg.org/ebooks.opds/?format=opds",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title = "Feedbooks",
|
|
|
|
subtitle = "",
|
|
|
|
url = "http://www.feedbooks.com/publicdomain/catalog.atom",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title = "ManyBooks",
|
|
|
|
subtitle = "Online Catalog for Manybooks.net",
|
|
|
|
url = "http://manybooks.net/opds/index.php",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title = "Internet Archive",
|
|
|
|
subtitle = "Internet Archive Catalog",
|
2015-09-13 14:07:14 +00:00
|
|
|
url = "http://bookserver.archive.org/catalog/",
|
2014-09-05 13:02:13 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
onExit = function() end,
|
|
|
|
}
|
|
|
|
|
|
|
|
function OPDSCatalog:init()
|
|
|
|
local opds_browser = OPDSBrowser:new{
|
|
|
|
opds_servers = self.opds_servers,
|
|
|
|
title = self.title,
|
|
|
|
show_parent = self,
|
|
|
|
is_popout = false,
|
|
|
|
is_borderless = true,
|
|
|
|
has_close_button = true,
|
|
|
|
close_callback = function() return self:onClose() end,
|
|
|
|
}
|
|
|
|
|
|
|
|
self[1] = FrameContainer:new{
|
|
|
|
padding = 0,
|
|
|
|
bordersize = 0,
|
2014-10-22 13:34:11 +00:00
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
2014-09-05 13:02:13 +00:00
|
|
|
opds_browser,
|
|
|
|
}
|
2014-12-01 14:39:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function OPDSCatalog:onShow()
|
|
|
|
UIManager:setDirty(self, function()
|
2015-04-26 18:07:17 +00:00
|
|
|
return "ui", self[1].dimen
|
2014-12-01 14:39:41 +00:00
|
|
|
end)
|
|
|
|
end
|
2014-09-05 13:02:13 +00:00
|
|
|
|
2014-12-01 14:39:41 +00:00
|
|
|
function OPDSCatalog:onCloseWidget()
|
|
|
|
UIManager:setDirty(nil, function()
|
|
|
|
return "partial", self[1].dimen
|
|
|
|
end)
|
2014-09-05 13:02:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function OPDSCatalog:showCatalog()
|
|
|
|
DEBUG("show OPDS catalog")
|
|
|
|
UIManager:show(OPDSCatalog:new{
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
onExit = function()
|
|
|
|
--UIManager:quit()
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
function OPDSCatalog:onClose()
|
|
|
|
DEBUG("close OPDS catalog")
|
|
|
|
UIManager:close(self)
|
|
|
|
if self.onExit then
|
|
|
|
self:onExit()
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return OPDSCatalog
|