//-------------------------------------------------- //open an NCC or OPF file //-------------------------------------------------- bool amis::dtb::Dtb::open(const ambulant::net::url* fileUrl, const ambulant::net::url* bookmarksDirectory, amis::BookList* history) { cleanUpObjects(); mpHistory = history; string log_msg = "Opening book: " + fileUrl->get_url(); amis::util::Log::Instance()->writeMessage(log_msg, "Dtb::open"); mpFiles = NULL; mpFiles = new amis::dtb::DtbFileSet(); mpFiles->initWithNccOrOpf(fileUrl, mpFileSearcher); mpFiles->setBookmarksDirectory(bookmarksDirectory); mpCurrentNavNode = NULL; if (DtbFileSet::isNccFile(fileUrl)) { amis::util::Log::Instance()->writeMessage("This is a DAISY 2.02 book", "Dtb::open"); mDaisyVersion = DAISY_202; if (mThreadYielder != 0) mThreadYielder->peekAndPump(); if (!processNcc(mpFiles->getNavFilepath(), fileUrl->is_local_file())) { return false; } } else if (DtbFileSet::isOpfFile(fileUrl)) { if (mThreadYielder != 0) mThreadYielder->peekAndPump(); if (!processOpf(mpFiles->getOpfFilepath())) { return false; } mDaisyVersion = DAISY_2005; amis::util::Log::Instance()->writeMessage("This is a Daisy 2005 book", "Dtb::open"); if (!processNcx(mpFiles->getNavFilepath(), fileUrl->is_local_file())) return false; //if (!processDaisyResourceFile(mpFiles->getResourceFilepath())) return false; } else { mDaisyVersion = UNSUPPORTED; amis::util::Log::Instance()->writeWarning("The type of book could not be determined", "Dtb::open"); return false; } loadBookmarks(mpFiles->getBookmarksFilepath()); amis::util::Log::Instance()->writeMessage("Opened book successfully", "Dtb::open"); return true; }
void endGame() { cleanUpInstances(); cleanUpObjects(); exit(0); }
//destructor amis::dtb::Dtb::~Dtb() { cleanUpObjects(); }