diff options
Diffstat (limited to 'fbreader/src/network/tree')
| -rw-r--r-- | fbreader/src/network/tree/NetworkAuthorTree.cpp | 53 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkBookTree.cpp | 262 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkCatalogRootTree.cpp | 265 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkCatalogTree.cpp | 292 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkCatalogUtil.cpp | 92 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkCatalogUtil.h | 45 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkLibrary.cpp | 101 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkLibrary.h | 57 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkSearcher.cpp | 179 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkSearcher.h | 59 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkSeriesTree.cpp | 72 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkTree.cpp | 31 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkTreeFactory.cpp | 123 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkTreeFactory.h | 42 | ||||
| -rw-r--r-- | fbreader/src/network/tree/NetworkTreeNodes.h | 275 | ||||
| -rw-r--r-- | fbreader/src/network/tree/RootTree.cpp | 42 | ||||
| -rw-r--r-- | fbreader/src/network/tree/SearchCatalogTree.cpp | 41 |
17 files changed, 0 insertions, 2031 deletions
diff --git a/fbreader/src/network/tree/NetworkAuthorTree.cpp b/fbreader/src/network/tree/NetworkAuthorTree.cpp deleted file mode 100644 index 8106838..0000000 --- a/fbreader/src/network/tree/NetworkAuthorTree.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include <ZLResource.h> -#include <ZLImage.h> - -#include "NetworkTreeNodes.h" - -const ZLTypeId NetworkAuthorTree::TYPE_ID(NetworkTree::TYPE_ID); - -const ZLTypeId &NetworkAuthorTree::typeId() const { - return TYPE_ID; -} - -const ZLResource &NetworkAuthorTree::resource() const { - return ZLResource::resource("networkView")["authorNode"]; -} - -NetworkAuthorTree::NetworkAuthorTree(NetworkTree *parent, const NetworkBookItem::AuthorData &author) : NetworkTree(parent), myAuthor(author) { - init(); -} - -void NetworkAuthorTree::init() { - //registerExpandTreeAction(); -} - -std::string NetworkAuthorTree::title() const { - return myAuthor.DisplayName; -} - -shared_ptr<const ZLImage> NetworkAuthorTree::image() const { - return defaultCoverImage("booktree-author.png"); -} - -const NetworkBookItem::AuthorData &NetworkAuthorTree::author() { - return myAuthor; -} diff --git a/fbreader/src/network/tree/NetworkBookTree.cpp b/fbreader/src/network/tree/NetworkBookTree.cpp deleted file mode 100644 index c59d247..0000000 --- a/fbreader/src/network/tree/NetworkBookTree.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include <ZLResource.h> -#include <ZLImage.h> -#include <ZLExecutionUtil.h> -#include <ZLNetworkManager.h> - -#include "NetworkTreeNodes.h" -#include "NetworkTreeFactory.h" -#include "NetworkLibrary.h" -#include "NetworkCatalogUtil.h" - -#include "../../networkActions/NetworkActions.h" - -const ZLTypeId NetworkBookTree::TYPE_ID(ZLTreePageNode::TYPE_ID); - -const ZLTypeId &NetworkBookTree::typeId() const { - return TYPE_ID; -} - -const ZLResource &NetworkBookTree::resource() const { - return ZLResource::resource("networkView")["bookNode"]; -} - -NetworkBookTree::NetworkBookTree(NetworkTree *parent, shared_ptr<NetworkItem> book, SummaryType summaryType) : ZLTreePageNode(parent), myBook(book), mySummaryType(summaryType) { - init(); -} - -//TODO we don't need a actions wrappers since we don't use old network library -class NetworkTreeBookReadAction : public NetworkBookReadAction { -public: - NetworkTreeBookReadAction(const NetworkBookTree &tree, const NetworkBookItem &book, bool demo) : NetworkBookReadAction(book, demo), myTree(tree) {} - void run() { - NetworkBookReadAction::run(); - myTree.close(); - } - -private: - const NetworkBookTree &myTree; -}; - -static std::vector<shared_ptr<ZLTreeAction> > getBookActions(NetworkBookTree &tree) { - std::vector<shared_ptr<ZLTreeAction> > actions; - const NetworkBookItem &book = tree.book(); - if (!book.reference(BookReference::DOWNLOAD_FULL).isNull() || - !book.reference(BookReference::DOWNLOAD_FULL_CONDITIONAL).isNull()) { - actions.push_back(new NetworkTreeBookReadAction(tree, book, false)); - actions.push_back(new NetworkBookDownloadAction(tree, book, false)); - actions.push_back(new NetworkBookDeleteAction(book)); - } - if (!book.reference(BookReference::DOWNLOAD_DEMO).isNull()) { - actions.push_back(new NetworkTreeBookReadAction(tree, book, true)); - actions.push_back(new NetworkBookDownloadAction(tree, book, true, tree.resource()["demo"].value())); - } - if (!book.reference(BookReference::BUY).isNull()) { - actions.push_back(new NetworkBookBuyDirectlyAction(tree, book)); - } else if (!book.reference(BookReference::BUY_IN_BROWSER).isNull()) { - actions.push_back(new NetworkBookBuyInBrowserAction(book)); - } - return actions; -} - -void NetworkBookTree::init() { - std::vector<shared_ptr<ZLTreeAction> > actions = getBookActions(*this); - for (std::size_t i = 0; i < actions.size(); ++i) { - registerAction(actions.at(i)); - } -} - -std::string NetworkBookTree::title() const { - return myBook->Title; -} - -std::string NetworkBookTree::subtitle() const { - int count = 0; - std::string authorsString; - const std::vector<NetworkBookItem::AuthorData> authors = book().Authors; - for (std::vector<NetworkBookItem::AuthorData>::const_iterator it = authors.begin(); it != authors.end(); ++it) { - if (!authorsString.empty()) { - authorsString += ", "; - } - authorsString += it->DisplayName; - ++count; - } - if (mySummaryType == NONE && count == 1) { - return std::string(); - } - return authorsString; -} - -shared_ptr<ZLTreePageInfo> NetworkBookTree::getPageInfo() /*const*/ { - if (myPageInfo.isNull()) { - myPageInfo = new BookItemWrapper(*this, myBook); - } - return myPageInfo; -} - - -shared_ptr<const ZLImage> NetworkBookTree::image() const { - if (myImage.isNull()) { - myImage = NetworkCatalogUtil::getAndDownloadImageByUrl(myBook->URLByType[NetworkItem::URL_COVER], this); - } - return (!myImage.isNull() && myImage->good()) ? myImage : FBTree::defaultCoverImage("booktree-book.png"); -} - -shared_ptr<const ZLImage> NetworkBookTree::fullImage() const { - if (myBook->URLByType.find(NetworkItem::URL_FULL_COVER) == myBook->URLByType.end()) { - return 0; - } - shared_ptr<const ZLImage> fullImage = NetworkCatalogUtil::getImageByUrl(myBook->URLByType[NetworkItem::URL_FULL_COVER]); - return !fullImage.isNull() ? fullImage : 0; -} - -const NetworkBookItem &NetworkBookTree::book() const { - return (const NetworkBookItem&)*myBook; -} - - -NetworkBookTree::BookItemWrapper::BookItemWrapper(NetworkBookTree &tree, shared_ptr<NetworkItem> bookItem) : - myTree(tree), myBookItem(bookItem), myIsInitialized(false) { -} - -bool NetworkBookTree::BookItemWrapper::isPageInfoLoaded() { - return myIsInitialized; -} - -class BookItemWrapperScope : public ZLUserData { -public: - shared_ptr<ZLNetworkRequest::Listener> listener; -}; - -void NetworkBookTree::BookItemWrapper::loadAll(shared_ptr<ZLNetworkRequest::Listener> listener) { - if (myIsInitialized) { - listener->finished(); - return; - } - - NetworkBookItem &bookItem = book(); - - BookItemWrapperScope *scope = new BookItemWrapperScope; - scope->listener = listener; - shared_ptr<ZLUserDataHolder> scopeData = new ZLUserDataHolder; - scopeData->addUserData("scope", scope); - - if (bookItem.isFullyLoaded()) { - onInformationLoaded(*scopeData, std::string()); - return; - } - bookItem.loadFullInformation(ZLExecutionUtil::createListener(scopeData, this, &NetworkBookTree::BookItemWrapper::onInformationLoaded)); -} - -void NetworkBookTree::BookItemWrapper::onInformationLoaded(ZLUserDataHolder &data, const std::string &error){ - shared_ptr<const ZLImage> cover = image(); - if (!cover.isNull()) { - shared_ptr<ZLNetworkRequest> request = cover->synchronizationData(); - if (!request.isNull()) { - request->setListener(ZLExecutionUtil::createListener(new ZLUserDataHolder(data), this, &NetworkBookTree::BookItemWrapper::onCoverLoaded)); - ZLNetworkManager::Instance().performAsync(request); - return; - } - } - onCoverLoaded(data, error); //if image is loaded already -} - -void NetworkBookTree::BookItemWrapper::onCoverLoaded(ZLUserDataHolder &data, const std::string &error) { - BookItemWrapperScope &scope = static_cast<BookItemWrapperScope&>(*data.getUserData("scope")); - if (error.empty()) { - myIsInitialized = true; - } - scope.listener->finished(error); -} - -std::string NetworkBookTree::BookItemWrapper::title() const { - return book().Title; -} - -std::vector<std::string> NetworkBookTree::BookItemWrapper::authors() const { - const NetworkBookItem &bookItem = book(); - std::vector<std::string> authors; - for (std::size_t i = 0; i < bookItem.Authors.size(); ++i) { - authors.push_back(bookItem.Authors.at(i).DisplayName); - } - return authors; -} - -std::vector<std::string> NetworkBookTree::BookItemWrapper::tags() const { - return book().Tags; -} - -std::string NetworkBookTree::BookItemWrapper::summary() const { - return book().Summary; -} - -shared_ptr<const ZLImage> NetworkBookTree::BookItemWrapper::image() const { - shared_ptr<const ZLImage> fullImage = myTree.fullImage(); - if (!fullImage.isNull()) { - return fullImage; - } - return myTree.image(); -} - -const std::vector<shared_ptr<ZLTreeAction> > &NetworkBookTree::BookItemWrapper::actions() const { - return myTree.actions(); -} - -std::string NetworkBookTree::BookItemWrapper::actionText(const shared_ptr<ZLTreeAction> &action) const { - return myTree.actionText(action); -} - -class RelatedAction : public ZLTreeAction { -public: - RelatedAction(shared_ptr<NetworkItem> item) : myTitle(item->Title) { - myNode = new NetworkCatalogTree(&NetworkLibrary::Instance().getFakeCatalogTree(), item); - //myNode = NetworkTreeFactory::createNetworkTree(0, item); - } - ZLResourceKey key() const { return ZLResourceKey(""); } - std::string text(const ZLResource &/*resource*/) const { - return myTitle; - } - void run() { - if (NetworkCatalogTree *tree = zlobject_cast<NetworkCatalogTree*>(&*myNode)){ - tree->expand(); - } - } - -private: - shared_ptr<ZLTreeTitledNode> myNode; - std::string myTitle; -}; - -const std::vector<shared_ptr<ZLTreeAction> > NetworkBookTree::BookItemWrapper::relatedActions() const { - if (!myRelatedActions.empty()) { - return myRelatedActions; - } - std::vector<shared_ptr<NetworkItem> > catalogItems = static_cast<NetworkBookItem&>(*myBookItem).getRelatedCatalogsItems(); - for (std::size_t i = 0; i < catalogItems.size(); ++i) { - shared_ptr<NetworkItem> item = catalogItems.at(i); - myRelatedActions.push_back(new RelatedAction(item)); - } - return myRelatedActions; -} - -NetworkBookItem &NetworkBookTree::BookItemWrapper::book() const { - return (NetworkBookItem&)*myBookItem; -} diff --git a/fbreader/src/network/tree/NetworkCatalogRootTree.cpp b/fbreader/src/network/tree/NetworkCatalogRootTree.cpp deleted file mode 100644 index 50a78f5..0000000 --- a/fbreader/src/network/tree/NetworkCatalogRootTree.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include <ZLStringUtil.h> -#include <ZLExecutionUtil.h> - -#include "../../fbreader/FBReader.h" - -#include "../authentication/NetworkAuthenticationManager.h" -#include "../../networkActions/NetworkOperationRunnable.h" -#include "../../networkActions/AuthenticationDialogManager.h" -#include "../../networkActions/PasswordRecoveryDialog.h" -#include "../../networkActions/RegisterUserDialog.h" - -#include "NetworkLibrary.h" - -#include "NetworkTreeNodes.h" - -class NetworkTreeCatalogAuthAction : public ZLTreeAction { - -protected: - NetworkTreeCatalogAuthAction(NetworkAuthenticationManager &mgr, bool forLoggedUsers); - -protected: - bool makesSense() const; - -protected: - NetworkAuthenticationManager &myManager; - -private: - const bool myForLoggedUsers; -}; - -class NetworkCatalogRootTree::LoginAction : public NetworkTreeCatalogAuthAction { - -public: - LoginAction(NetworkAuthenticationManager &mgr, ZLTreeNode *node); - void run(); - ZLResourceKey key() const; - -private: - void onAuthorised(const std::string &error); - -private: - ZLTreeNode *myNode; - -friend class LoginActionListener; -}; - -class NetworkCatalogRootTree::LogoutAction : public NetworkTreeCatalogAuthAction { - -public: - LogoutAction(NetworkAuthenticationManager &mgr); - void run(); - ZLResourceKey key() const; - std::string text(const ZLResource &resource) const; -}; - -class NetworkCatalogRootTree::TopupAccountAction : public NetworkTreeCatalogAuthAction { - -public: - TopupAccountAction(NetworkAuthenticationManager &mgr); - -private: - void run(); - ZLResourceKey key() const; - std::string text(const ZLResource &resource) const; - bool makesSense() const; -}; - -class NetworkCatalogRootTree::PasswordRecoveryAction : public NetworkTreeCatalogAuthAction { - -public: - PasswordRecoveryAction(NetworkAuthenticationManager &mgr); - void run(); - ZLResourceKey key() const; -}; - -class NetworkCatalogRootTree::RegisterUserAction : public NetworkTreeCatalogAuthAction { - -public: - RegisterUserAction(NetworkAuthenticationManager &mgr); - void run(); - ZLResourceKey key() const; -}; - -const ZLTypeId NetworkCatalogRootTree::TYPE_ID(NetworkCatalogTree::TYPE_ID); - -const ZLTypeId &NetworkCatalogRootTree::typeId() const { - return TYPE_ID; -} - -NetworkCatalogRootTree::NetworkCatalogRootTree(RootTree *parent, NetworkLink &link, std::size_t position) : - NetworkCatalogTree(parent, link.libraryItem(), position), myLink(link) { - init(); //at old version, init is called when node should be painted (and if initialized yet) -} - -void NetworkCatalogRootTree::init() { - shared_ptr<NetworkAuthenticationManager> mgr = myLink.authenticationManager(); - //registerAction(new ExpandCatalogAction(*this)); - //registerAction(new ReloadAction(*this)); - if (!mgr.isNull()) { - registerAction(new LoginAction(*mgr, this)); - registerAction(new LogoutAction(*mgr)); - registerAction(new TopupAccountAction(*mgr)); - - if (mgr->registrationSupported()) { - registerAction(new RegisterUserAction(*mgr)); - } - if (mgr->passwordRecoverySupported()) { - registerAction(new PasswordRecoveryAction(*mgr)); - } - } -} - -const ZLResource &NetworkCatalogRootTree::resource() const { - return ZLResource::resource("networkView")["libraryItemRootNode"]; -} - -NetworkTreeCatalogAuthAction::NetworkTreeCatalogAuthAction(NetworkAuthenticationManager &mgr, bool forLoggedUsers) : myManager(mgr), myForLoggedUsers(forLoggedUsers) { -} - -bool NetworkTreeCatalogAuthAction::makesSense() const { - return (myManager.isAuthorised().Status == B3_FALSE) != myForLoggedUsers; -} - -NetworkCatalogRootTree::LoginAction::LoginAction(NetworkAuthenticationManager &mgr, ZLTreeNode *node) : - NetworkTreeCatalogAuthAction(mgr, false), myNode(node) { -} - -ZLResourceKey NetworkCatalogRootTree::LoginAction::key() const { - return ZLResourceKey("login"); -} - -class LoginActionListener : public ZLNetworkRequest::Listener { -public: - LoginActionListener(NetworkCatalogRootTree::LoginAction &action) : myAction(action) {} - - virtual void finished(const std::string &error) { - myAction.onAuthorised(error); - } - - virtual void setUIStatus(bool enabled) { - if (enabled) { - myAction.myNode->notifyDownloadStarted(); - } else { - myAction.myNode->notifyDownloadStopped(); - } - } - -private: - NetworkCatalogRootTree::LoginAction &myAction; -}; - -void NetworkCatalogRootTree::LoginAction::run() { - if (!NetworkOperationRunnable::tryConnect()) { - return; - } - AuthenticationDialogManager::authAndInitAsync( - myManager, - new LoginActionListener(*this) - ); -} - -void NetworkCatalogRootTree::LoginAction::onAuthorised(const std::string &/*error*/) { - myNode->notifyDownloadStopped(); - NetworkLibrary::Instance().invalidateVisibility(); - NetworkLibrary::Instance().synchronize(); - NetworkLibrary::Instance().refresh(); -} - -NetworkCatalogRootTree::LogoutAction::LogoutAction(NetworkAuthenticationManager &mgr) : NetworkTreeCatalogAuthAction(mgr, true) { -} - -ZLResourceKey NetworkCatalogRootTree::LogoutAction::key() const { - return ZLResourceKey("logout"); -} - -std::string NetworkCatalogRootTree::LogoutAction::text(const ZLResource &resource) const { - const std::string text = ZLTreeAction::text(resource); - return ZLStringUtil::printf(text, myManager.currentUserName()); -} - -void NetworkCatalogRootTree::LogoutAction::run() { - myManager.logOut(); - NetworkLibrary::Instance().invalidateVisibility(); - NetworkLibrary::Instance().synchronize(); - NetworkLibrary::Instance().refresh(); -} - - -NetworkCatalogRootTree::TopupAccountAction::TopupAccountAction(NetworkAuthenticationManager &mgr) : NetworkTreeCatalogAuthAction(mgr, true) { -} - -ZLResourceKey NetworkCatalogRootTree::TopupAccountAction::key() const { - return !myManager.currentAccount().empty() ? ZLResourceKey("topupAccount") : ZLResourceKey("topupAccountUndefined"); -} - -std::string NetworkCatalogRootTree::TopupAccountAction::text(const ZLResource &resource) const { - const std::string text = ZLTreeAction::text(resource); - std::string account = myManager.currentAccount(); - if (!account.empty() && !myManager.topupAccountLink().empty()) { - return ZLStringUtil::printf(text, account); - } - return text; -} - -void NetworkCatalogRootTree::TopupAccountAction::run() { - FBReader::Instance().openLinkInBrowser(myManager.topupAccountLink()); - NetworkLibrary::Instance().refresh(); -} - -bool NetworkCatalogRootTree::TopupAccountAction::makesSense() const { - return NetworkTreeCatalogAuthAction::makesSense(); -} - -NetworkCatalogRootTree::PasswordRecoveryAction::PasswordRecoveryAction(NetworkAuthenticationManager &mgr) : NetworkTreeCatalogAuthAction(mgr, false) { -} - -ZLResourceKey NetworkCatalogRootTree::PasswordRecoveryAction::key() const { - return ZLResourceKey("passwordRecovery"); -} - -void NetworkCatalogRootTree::PasswordRecoveryAction::run() { - if (!NetworkOperationRunnable::tryConnect()) { - return; - } - - PasswordRecoveryDialog::run(myManager); - FBReader::Instance().refreshWindow(); - NetworkLibrary::Instance().refresh(); -} - -NetworkCatalogRootTree::RegisterUserAction::RegisterUserAction(NetworkAuthenticationManager &mgr) : NetworkTreeCatalogAuthAction(mgr, false) { -} - -ZLResourceKey NetworkCatalogRootTree::RegisterUserAction::key() const { - return ZLResourceKey("register"); -} - -void NetworkCatalogRootTree::RegisterUserAction::run() { - if (!NetworkOperationRunnable::tryConnect()) { - return; - } - - RegisterUserDialog::run(myManager); - FBReader::Instance().refreshWindow(); - NetworkLibrary::Instance().refresh(); -} diff --git a/fbreader/src/network/tree/NetworkCatalogTree.cpp b/fbreader/src/network/tree/NetworkCatalogTree.cpp deleted file mode 100644 index 6b6bf6e..0000000 --- a/fbreader/src/network/tree/NetworkCatalogTree.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include <algorithm> - -#include <ZLDialogManager.h> - -#include "../authentication/NetworkAuthenticationManager.h" -#include "NetworkCatalogUtil.h" -#include "../../networkActions/NetworkOperationRunnable.h" -#include "../NetworkErrors.h" -#include "NetworkTreeFactory.h" -#include "../../networkActions/AuthenticationDialogManager.h" -#include "NetworkTreeNodes.h" - -const ZLTypeId NetworkCatalogTree::TYPE_ID(NetworkTree::TYPE_ID); - -const ZLTypeId &NetworkCatalogTree::typeId() const { - return TYPE_ID; -} - -NetworkCatalogTree::NetworkCatalogTree(RootTree *parent, shared_ptr<NetworkItem> item, std::size_t position) : - NetworkTree(parent, position), myItem(item) { -} - -NetworkCatalogTree::NetworkCatalogTree(NetworkCatalogTree *parent, shared_ptr<NetworkItem> item, std::size_t position) : - NetworkTree(parent, position), myItem(item) { - init(); -} - -void NetworkCatalogTree::init() { -// if (!item().URLByType[NetworkItem::URL_CATALOG].empty()) { -// registerAction(new ExpandCatalogAction(*this)); -// } -// const std::string htmlUrl = -// item().URLByType[NetworkItem::URL_HTML_PAGE]; -// if (!htmlUrl.empty()) { -// registerAction(new OpenInBrowserAction(htmlUrl)); -// } - //registerAction(new ReloadAction(*this)); -} - -std::string NetworkCatalogTree::title() const { - return myItem->Title; -} - -std::string NetworkCatalogTree::subtitle() const { - return ((const NetworkCatalogItem&)*myItem).Summary; -} - - -shared_ptr<const ZLImage> NetworkCatalogTree::image() const { - const std::string &url = myItem->URLByType[NetworkItem::URL_COVER]; - if (url.empty()) { - if (ZLTreeTitledNode* node = zlobject_cast<ZLTreeTitledNode*>(parent())) { - return node->image(); - } - } - if (myImage.isNull()) { - myImage = NetworkCatalogUtil::getAndDownloadImageByUrl(url, this); - } - return (!myImage.isNull() && myImage->good()) ? myImage : FBTree::defaultCoverImage("booktree-catalog.png"); -} - -class AsyncLoadSubCatalogRunnable : public ZLNetworkRequest::Listener { - -public: - AsyncLoadSubCatalogRunnable(NetworkCatalogTree *tree, bool resumeMode) : - myTree(tree), myResumeMode(resumeMode) { - myTree->notifyDownloadStarted(); - if (myResumeMode) { - myTree->item().resumeLoading(myChildrens, this); - } else { - myTree->item().loadChildren(myChildrens, this); - } - } - - void finished(const std::string &error) { - myTree->notifyDownloadStopped(); - myTree->onChildrenReceived(myChildrens, error); - } - - void setUIStatus(bool enabled) { - if (enabled) { - myTree->notifyDownloadStarted(); - } else { - myTree->notifyDownloadStopped(); - } - } - -private: - NetworkCatalogTree *myTree; - NetworkItem::List myChildrens; - bool myResumeMode; -}; - -//class NetworkCatalogTreeAuthScope : public ZLUserData { -//public: -// shared_ptr<ZLNetworkRequest::Listener> listener; -//}; - -class NetworkCatalogTreeAuthListener : public ZLNetworkRequest::Listener { -public: - NetworkCatalogTreeAuthListener(NetworkCatalogTree *tree) : myTree(tree) { - } - - void finished(const std::string &error) { - myTree->onAuthCheck(error); - } - - void setUIStatus(bool enabled) { - if (enabled) { - myTree->notifyDownloadStarted(); - } else { - myTree->notifyDownloadStopped(); - } - } - -private: - NetworkCatalogTree *myTree; -}; - -void NetworkCatalogTree::requestChildren(shared_ptr<ZLNetworkRequest::Listener> listener) { - myListeners.push_back(listener); - if (myListeners.size() > 1) { - return; - } - - const NetworkLink &link = item().Link; - shared_ptr<NetworkAuthenticationManager> manager = link.authenticationManager(); - - if (item().getVisibility() == B3_UNDEFINED && !manager.isNull()) { - AuthenticationDialogManager::authAndInitAsync(*manager, new NetworkCatalogTreeAuthListener(this)); - return; - } - - if (!manager.isNull() && manager->isAuthorised(0).Status == B3_TRUE) { - AuthenticationDialogManager::athoriseIfCan(*manager, new NetworkCatalogTreeAuthListener(this)); - return; - } - onAuthCheck(std::string()); -} - -void NetworkCatalogTree::onAuthCheck(const std::string &error) { - if (!error.empty()) { - notifyListeners(error); - return; - } - - if (!myChildrenItems.empty()) { - notifyDownloadStopped(); - notifyListeners(std::string()); //TODO maybe not be silent about auth error here - return; - } - new AsyncLoadSubCatalogRunnable(this, false); - -} - -void NetworkCatalogTree::requestMoreChildren(shared_ptr<ZLNetworkRequest::Listener> listener) { - //TODO does double requesting is processed correct? - if (!item().supportsResumeLoading()) { - listener->finished(); - return; - } - myListeners.push_back(listener); - if (myListeners.size() == 1) { - new AsyncLoadSubCatalogRunnable(this, true); - } -} - -void NetworkCatalogTree::onChildrenReceived(NetworkItem::List &childrens, const std::string &error) { - if (!error.empty()) { - //special case for authenticationFailed after 'cancel' button pressed in AuthDialog? - //TODO maybe it'll be work wrong at some cases? maybe we should have another error this case? - if (error != NetworkErrors::errorMessage(NetworkErrors::ERROR_AUTHENTICATION_FAILED)) { - NetworkErrors::showErrorMessage(error); - } - notifyListeners(error); - return; - } - - myChildrenItems.insert(myChildrenItems.end(), childrens.begin(), childrens.end()); - - if (myChildrenItems.empty()) { - ZLDialogManager::Instance().informationBox(ZLResourceKey("emptyCatalogBox")); - notifyListeners(error); - return; - } - - bool hasSubcatalogs = false; - for (NetworkItem::List::iterator it = myChildrenItems.begin(); it != myChildrenItems.end(); ++it) { - if ((*it)->typeId() == NetworkCatalogItem::TYPE_ID) { - hasSubcatalogs = true; - break; - } - } - - //TODO rewrite this method - if (hasSubcatalogs) { - for (NetworkItem::List::iterator it = childrens.begin(); it != childrens.end(); ++it) { - NetworkTreeFactory::createNetworkTree(this, *it); - } - } else { - NetworkTreeFactory::fillAuthorTree(this, childrens); - } - notifyListeners(error); - - this->updated(); -} - -void NetworkCatalogTree::notifyListeners(const std::string &error) { - for (std::size_t i = 0; i < myListeners.size(); ++i) { - if (!myListeners.at(i).isNull()) - myListeners.at(i)->finished(error); - } - myListeners.clear(); -} - -NetworkCatalogItem &NetworkCatalogTree::item() { - return (NetworkCatalogItem&)*myItem; -} - -void NetworkCatalogTree::updateVisibility() { - //adding to remove list and clearing all existed nodes - List toRemove; - NetworkItem::List itemsWithNodes; //used in loop for creating new nodes (for these items new nodes won't be created) - for (size_t i = 0; i < children().size(); ++i) { - ZLTreeNode* tree = children().at(i); - if (!tree->isInstanceOf(NetworkCatalogTree::TYPE_ID)) { - continue; - } - NetworkCatalogTree *child = (NetworkCatalogTree*)tree; - itemsWithNodes.push_back(child->myItem); - switch (child->item().getVisibility()) { - case B3_TRUE: - child->updateVisibility(); - break; - case B3_FALSE: - toRemove.push_back(child); - break; - case B3_UNDEFINED: - child->clearCatalog(); - break; - } - } - - //creating new nodes (if necessary) - for (size_t i = 0; i < myChildrenItems.size(); ++i) { - shared_ptr<NetworkItem> item = myChildrenItems.at(i); - if (!item->isInstanceOf(NetworkCatalogItem::TYPE_ID)) { - continue; - } - if (std::find(itemsWithNodes.begin(), itemsWithNodes.end(), item) != itemsWithNodes.end()) { - continue; - } - NetworkCatalogItem *catalogItem = (NetworkCatalogItem*)(&*item); - if (catalogItem->getVisibility() != B3_FALSE) { - NetworkTreeFactory::createNetworkTree(this, item, i); - } - } - - for (size_t i = 0; i < toRemove.size(); ++i) { - ZLTreeNode* tree = toRemove.at(i); - remove(tree); - } - -} - -void NetworkCatalogTree::clearCatalog() { - myChildrenItems.clear(); - clear(); -} - -const ZLResource &NetworkCatalogTree::resource() const { - return ZLResource::resource("networkView")["libraryItemNode"]; -} diff --git a/fbreader/src/network/tree/NetworkCatalogUtil.cpp b/fbreader/src/network/tree/NetworkCatalogUtil.cpp deleted file mode 100644 index 953bf67..0000000 --- a/fbreader/src/network/tree/NetworkCatalogUtil.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include <ZLStringUtil.h> -#include <ZLNetworkManager.h> - -#include <ZLBase64EncodedImage.h> -#include <ZLNetworkImage.h> - -#include "NetworkCatalogUtil.h" - -#include "../NetworkLinkCollection.h" - -shared_ptr<const ZLImage> NetworkCatalogUtil::getImageByNetworkUrl(const std::string &url, const std::string &prefix) { - if (!ZLStringUtil::stringStartsWith(url, prefix)) { - return 0; - } - - return new ZLNetworkImage(ZLMimeType::IMAGE_AUTO, url); -} - -shared_ptr<const ZLImage> NetworkCatalogUtil::getImageByDataUrl(const std::string &url) { - if (!ZLStringUtil::stringStartsWith(url, "data:")) { - return 0; - } - - std::size_t index = url.find(','); - if (index == std::string::npos) { - return 0; - } - - ZLBase64EncodedImage *image = new ZLBase64EncodedImage(ZLMimeType::IMAGE_AUTO); - image->addData(url, index + 1, std::string::npos); - return image; -} - -shared_ptr<const ZLImage> NetworkCatalogUtil::getImageByUrl(const std::string &url) { - shared_ptr<const ZLImage> image; - - image = getImageByNetworkUrl(url, "http://"); - if (!image.isNull()) { - return image; - } - - image = getImageByNetworkUrl(url, "https://"); - if (!image.isNull()) { - return image; - } - - return getImageByDataUrl(url); -} - -class NetworkImageDownloadListener : public ZLNetworkRequest::Listener { -public: - NetworkImageDownloadListener(ZLTreeNode *node) : myNode(node) {} - void finished(const std::string &error) { - if (error.empty()) { - myNode->updated(); - } - } -private: - ZLTreeNode *myNode; -}; - -shared_ptr<const ZLImage> NetworkCatalogUtil::getAndDownloadImageByUrl(const std::string &url, const ZLTreeNode *node) { - shared_ptr<const ZLImage> image = getImageByUrl(url); - - if (!image.isNull()) { - shared_ptr<ZLNetworkRequest> downloadRequest = image->synchronizationData(); - if (!downloadRequest.isNull()) { - downloadRequest->setListener(new NetworkImageDownloadListener(const_cast<ZLTreeNode*>(node))); - ZLNetworkManager::Instance().performAsync(downloadRequest); - } - } - return image; -} diff --git a/fbreader/src/network/tree/NetworkCatalogUtil.h b/fbreader/src/network/tree/NetworkCatalogUtil.h deleted file mode 100644 index 0196896..0000000 --- a/fbreader/src/network/tree/NetworkCatalogUtil.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __NETWORKCATALOGUTIL_H__ -#define __NETWORKCATALOGUTIL_H__ - -#include <string> - -#include <shared_ptr.h> - -#include <ZLTreeNode.h> - -class ZLImage; - -class NetworkCatalogUtil { - -public: - static shared_ptr<const ZLImage> getImageByUrl(const std::string &url); - static shared_ptr<const ZLImage> getAndDownloadImageByUrl(const std::string &url, const ZLTreeNode *node); - -private: - static shared_ptr<const ZLImage> getImageByNetworkUrl(const std::string &url, const std::string &prefix); - static shared_ptr<const ZLImage> getImageByDataUrl(const std::string &url); - -private: - NetworkCatalogUtil(); -}; - -#endif /* __NETWORKCATALOGUTIL_H__ */ diff --git a/fbreader/src/network/tree/NetworkLibrary.cpp b/fbreader/src/network/tree/NetworkLibrary.cpp deleted file mode 100644 index 118abd0..0000000 --- a/fbreader/src/network/tree/NetworkLibrary.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include <ZLDialogManager.h> - -#include "../NetworkLinkCollection.h" - -//#include "NetworkNodesFactory.h" - -#include "../NetworkItems.h" -#include "../NetworkLinkCollection.h" -#include "../NetworkLink.h" -#include "../SearchResult.h" -#include "../authentication/NetworkAuthenticationManager.h" -#include "../../networkActions/NetworkOperationRunnable.h" -#include "NetworkSearcher.h" -#include "NetworkTreeNodes.h" - -#include "NetworkLibrary.h" - -NetworkLibrary *NetworkLibrary::ourInstance = 0; - -NetworkLibrary &NetworkLibrary::Instance() { - if (ourInstance == 0) { - ourInstance = new NetworkLibrary(); - } - return *ourInstance; -} - -NetworkLibrary::NetworkLibrary() { - //TODO maybe it should be created in showDialog method? - myDialog = ZLDialogManager::Instance().createTreeDialog(ZLResource::resource("networkView")); - myRootTree.setDialog(myDialog); - myFakeRootTree.setDialog(myDialog); - myUpdateVisibility = false; - myChildrenAreInvalid = true; -} - -void NetworkLibrary::showDialog() { - synchronize(); - myDialog->run(&myRootTree); - myDialog->setSearcher(new NetworkSearcher); -} - -void NetworkLibrary::refresh() { - myDialog->onRefresh(); -} - -void NetworkLibrary::makeUpToDate() { - //TODO rewrite this method - NetworkLinkCollection::Instance().initialize(); - NetworkLinkCollection &collection = NetworkLinkCollection::Instance(); - for (std::size_t i = 0; i < collection.size(); ++i) { - NetworkLink &link = collection.link(i); - new NetworkCatalogRootTree(&myRootTree, link, i); - } -} - -void NetworkLibrary::updateVisibility() { - for (size_t i = 0; i < myRootTree.children().size(); ++i) { - ZLTreeNode* tree = myRootTree.children().at(i); - if (NetworkCatalogTree* catalogTree = zlobject_cast<NetworkCatalogTree*>(tree)) { - catalogTree->updateVisibility(); - } - } -} - -RootTree &NetworkLibrary::getFakeCatalogTree() { - return myFakeRootTree; -} - -void NetworkLibrary::synchronize() { - if (myChildrenAreInvalid) { - myChildrenAreInvalid = false; - makeUpToDate(); - } - if (myUpdateVisibility) { - myUpdateVisibility = false; - updateVisibility(); - } -} - -void NetworkLibrary::invalidateVisibility() { - myUpdateVisibility = true; -} diff --git a/fbreader/src/network/tree/NetworkLibrary.h b/fbreader/src/network/tree/NetworkLibrary.h deleted file mode 100644 index 026cbbd..0000000 --- a/fbreader/src/network/tree/NetworkLibrary.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __NETWORKLIBRARY_H__ -#define __NETWORKLIBRARY_H__ - -#include <ZLTreeDialog.h> - -#include "NetworkTreeNodes.h" - -class NetworkLibrary { - -public: - static NetworkLibrary &Instance(); - -private: - static NetworkLibrary *ourInstance; - -public: - void showDialog(); - void refresh(); - RootTree &getFakeCatalogTree(); - - void synchronize(); - void invalidateVisibility(); - -private: - NetworkLibrary(); - void makeUpToDate(); - - void updateVisibility(); - -private: - shared_ptr<ZLTreeDialog> myDialog; - RootTree myRootTree; - RootTree myFakeRootTree; - bool myUpdateVisibility; - bool myChildrenAreInvalid; -}; - -#endif /* __NETWORKLIBRARY_H__ */ diff --git a/fbreader/src/network/tree/NetworkSearcher.cpp b/fbreader/src/network/tree/NetworkSearcher.cpp deleted file mode 100644 index 10d318e..0000000 --- a/fbreader/src/network/tree/NetworkSearcher.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include <ZLNetworkManager.h> -#include <ZLDialogManager.h> -#include <ZLTimeManager.h> - -#include "../authentication/NetworkAuthenticationManager.h" -#include "../../networkActions/NetworkOperationRunnable.h" -#include "../NetworkLinkCollection.h" -#include "../NetworkLink.h" -#include "../NetworkOperationData.h" -#include "../NetworkErrors.h" -#include "NetworkTreeNodes.h" -#include "NetworkLibrary.h" -#include "NetworkSearcher.h" - -//TODO rewrite code to not to use fake network link - -NetworkSearcher::NetworkSearcher() { } - -void NetworkSearcher::simpleSearch(const std::string &pattern) { - //TODO maybe move code for simple search from NetworkLinkCollection to here - NetworkCatalogTree *tree = new SearchCatalogTree(&NetworkLibrary::Instance().getFakeCatalogTree(), new AllCatalogsSearchItem(myFakeLink, pattern)); - tree->expand(); -} - -AllCatalogsSearchItem::AllCatalogsSearchItem(const NetworkLink &link, const std::string &pattern) : - NetworkCatalogItem(link, std::string(), std::string(), UrlInfoCollection()), - myPattern(pattern) { -} - -class AllCatalogsSearchItemListener : public ZLNetworkRequest::Listener { -public: - AllCatalogsSearchItemListener(AllCatalogsSearchItem &item, - NetworkItem::List &children, - shared_ptr<ZLNetworkRequest::Listener> listener, - ZLNetworkRequest::Vector requestList, - std::vector<shared_ptr<NetworkOperationData> > dataList) : - myItem(item), - myChildren(children), - myListener(listener), - myDataList(dataList), - myHolder(this) { - myItemFound = false; - myCollection = new NetworkBookCollection; - myCounter = 0; - performRequests(requestList); - } - - void performRequests(ZLNetworkRequest::Vector requestList) { - for (std::size_t i = 0; i < requestList.size(); ++i) { - shared_ptr<ZLNetworkRequest> request = requestList.at(i); - request->setListener(myHolder); - ++myCounter; - ZLNetworkManager::Instance().performAsync(request); - } - } - - void finished(const std::string &error) { - --myCounter; - - ZLNetworkRequest::Vector requestList; - - for (std::size_t i = 0; i < myDataList.size(); ++i) { - shared_ptr<NetworkOperationData> data = myDataList.at(i); - for (std::size_t j = 0; j < data->Items.size(); ++j) { - myCollection->addBook(data->Items.at(j)); - } - - if (!data->Items.empty()) { - shared_ptr<ZLNetworkRequest> request = data->resume(); - if (!request.isNull()) { - request->setListener(myHolder); - requestList.push_back(request); - } - } - } - - - if (!myCollection->books().empty()) { - myItem.onChildrenLoaded(myChildren, myCollection, myListener); - myChildren.clear(); - myCollection->clear(); - } - - if (!requestList.empty()) { - performRequests(requestList); - } - - if (myCounter == 0) { - ZLTimeManager::deleteLater(myHolder); - myHolder.reset(); //destroy itself - } - } - -private: - AllCatalogsSearchItem &myItem; - NetworkItem::List &myChildren; - shared_ptr<ZLNetworkRequest::Listener> myListener; - shared_ptr<NetworkBookCollection> myCollection; //TODO maybe remove this class using - - bool myItemFound; - - std::vector<shared_ptr<NetworkOperationData> > myDataList; - int myCounter; -// std::string myErrorMessage; - shared_ptr<ZLNetworkRequest::Listener> myHolder; //for keeping this instance alive -}; - -std::string AllCatalogsSearchItem::loadChildren(NetworkItem::List &children, shared_ptr<ZLNetworkRequest::Listener> listener) { - ZLNetworkRequest::Vector requestList; - std::vector<shared_ptr<NetworkOperationData> > dataList; - - const NetworkLinkCollection::LinkVector &links = NetworkLinkCollection::Instance().activeLinks(); - for (std::size_t i = 0; i < links.size(); ++i) { - const NetworkLink &link = *links.at(i); - shared_ptr<NetworkOperationData> data = new NetworkOperationData(link); - - shared_ptr<ZLNetworkRequest> request = link.simpleSearchData(*data, myPattern); - if (!request.isNull()) { - dataList.push_back(data); - requestList.push_back(request); - } - } - - new AllCatalogsSearchItemListener(*this, children, listener, requestList, dataList); - - return std::string(); -} - -void AllCatalogsSearchItem::onChildrenLoaded(NetworkItem::List &children, shared_ptr<NetworkBookCollection> collection, shared_ptr<ZLNetworkRequest::Listener> listener) { - if (!collection.isNull()) { - const NetworkItem::List &books = collection->books(); - children.assign(books.begin(), books.end()); - } - listener->finished(); -} - -FakeNetworkLink::FakeNetworkLink() : NetworkLink("") { } - -shared_ptr<ZLNetworkRequest> FakeNetworkLink::simpleSearchData(NetworkOperationData &/*data*/, const std::string &/*pattern*/) const { - return 0; -} - -shared_ptr<ZLNetworkRequest> FakeNetworkLink::advancedSearchData(NetworkOperationData &/*data*/, const std::string &/*titleAndSeries*/, const std::string &/*author*/, const std::string &/*tag*/, const std::string &/*annotation*/) const { - return 0; -} - -shared_ptr<ZLNetworkRequest> FakeNetworkLink::resume(NetworkOperationData &/*data*/) const { - return 0; -} - -shared_ptr<NetworkAuthenticationManager> FakeNetworkLink::authenticationManager() const { - return 0; -} - -shared_ptr<NetworkItem> FakeNetworkLink::libraryItem() const { - return 0; -} - -void FakeNetworkLink::rewriteUrl(std::string &/*url*/, bool /*isUrlExternal*/) const { -} diff --git a/fbreader/src/network/tree/NetworkSearcher.h b/fbreader/src/network/tree/NetworkSearcher.h deleted file mode 100644 index 08ebc35..0000000 --- a/fbreader/src/network/tree/NetworkSearcher.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __NETWORKSEARCHER_H__ -#define __NETWORKSEARCHER_H__ - -#include <ZLTreeSearcher.h> - -#include "../NetworkBookCollection.h" -#include "../NetworkItems.h" - -//TODO rewrite code to not to use fake network link -class FakeNetworkLink : public NetworkLink { -public: - FakeNetworkLink(); - shared_ptr<ZLNetworkRequest> simpleSearchData(NetworkOperationData &data, const std::string &pattern) const; - shared_ptr<ZLNetworkRequest> advancedSearchData(NetworkOperationData &data, const std::string &titleAndSeries, const std::string &author, const std::string &tag, const std::string &annotation) const; - shared_ptr<ZLNetworkRequest> resume(NetworkOperationData &data) const; - shared_ptr<NetworkAuthenticationManager> authenticationManager() const; - shared_ptr<NetworkItem> libraryItem() const; - void rewriteUrl(std::string &url, bool isUrlExternal = false) const; -}; - -class NetworkSearcher : public ZLTreeSearcher { -public: - NetworkSearcher(); - void simpleSearch(const std::string &pattern); -private: - const FakeNetworkLink myFakeLink; -}; - -class AllCatalogsSearchItem : public NetworkCatalogItem { - -public: - AllCatalogsSearchItem(const NetworkLink &link, const std::string &pattern); - std::string loadChildren(List &children, shared_ptr<ZLNetworkRequest::Listener> listener); - void onChildrenLoaded(List &children, shared_ptr<NetworkBookCollection> collection, shared_ptr<ZLNetworkRequest::Listener> listener); - -private: - std::string myPattern; -}; - -#endif /* __NETWORKSEARCHER_H__ */ diff --git a/fbreader/src/network/tree/NetworkSeriesTree.cpp b/fbreader/src/network/tree/NetworkSeriesTree.cpp deleted file mode 100644 index 4456ade..0000000 --- a/fbreader/src/network/tree/NetworkSeriesTree.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include <set> -#include <algorithm> - -#include <ZLResource.h> -#include <ZLImage.h> -#include <ZLStringUtil.h> - -#include "NetworkCatalogUtil.h" -#include "NetworkTreeNodes.h" - -const ZLTypeId NetworkSeriesTree::TYPE_ID(NetworkTree::TYPE_ID); - -const ZLTypeId &NetworkSeriesTree::typeId() const { - return TYPE_ID; -} - -const ZLResource &NetworkSeriesTree::resource() const { - return ZLResource::resource("networkView")["seriesNode"]; -} - -NetworkSeriesTree::NetworkSeriesTree(NetworkTree *parent, const std::string &seriesTitle) : - NetworkTree(parent), mySeriesTitle(seriesTitle) { - init(); -} - -void NetworkSeriesTree::init() { - //registerExpandTreeAction(); -} - -std::string NetworkSeriesTree::title() const { - return mySeriesTitle; -} - -std::string NetworkSeriesTree::subtitle() const { - return ZLStringUtil::printf(resource()["booksCount"].value((int)children().size()), (unsigned int)children().size()); -} - -static const size_t MAX_BATCH_SIZE = 6; - -shared_ptr<const ZLImage> NetworkSeriesTree::image() const { - if (myImages.empty()) { - for (size_t i = 0; i < std::min(children().size(), MAX_BATCH_SIZE); ++i) { - NetworkBookTree *bookTree = zlobject_cast<NetworkBookTree*>(children().at(i)); - if (!bookTree) { - continue; - } - NetworkItem::UrlInfoCollection urlByType = bookTree->book().URLByType; - std::string url = urlByType[NetworkItem::URL_COVER]; - myImages.push_back(NetworkCatalogUtil::getAndDownloadImageByUrl(url, this)); - } - } - return ZLImageManager::Instance().makeBatchImage(myImages, FBTree::defaultCoverImage("booktree-book.png")); -} diff --git a/fbreader/src/network/tree/NetworkTree.cpp b/fbreader/src/network/tree/NetworkTree.cpp deleted file mode 100644 index ac7b39a..0000000 --- a/fbreader/src/network/tree/NetworkTree.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include "NetworkTreeNodes.h" - -const ZLTypeId NetworkTree::TYPE_ID(FBTree::TYPE_ID); - -const ZLTypeId &NetworkTree::typeId() const { - return TYPE_ID; -} - - -NetworkTree::NetworkTree(RootTree *parent, std::size_t position) : FBTree(parent, position) { } - -NetworkTree::NetworkTree(NetworkTree *parent, std::size_t position) : FBTree(parent, position) { } diff --git a/fbreader/src/network/tree/NetworkTreeFactory.cpp b/fbreader/src/network/tree/NetworkTreeFactory.cpp deleted file mode 100644 index 0868034..0000000 --- a/fbreader/src/network/tree/NetworkTreeFactory.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include "NetworkTreeFactory.h" - -#include "NetworkTreeNodes.h" - -#include "../NetworkBookCollection.h" - -NetworkTreeFactory::NetworkTreeFactory() { -} - -ZLTreeTitledNode *NetworkTreeFactory::createNetworkTree(NetworkCatalogTree *parent, shared_ptr<NetworkItem> item, std::size_t position) { - if (item->isInstanceOf(NetworkCatalogItem::TYPE_ID)) { - NetworkCatalogItem *catalogItem = (NetworkCatalogItem*)(&*item); - if (catalogItem->getVisibility() == B3_FALSE) { - return 0; - } - NetworkCatalogTree *ptr = new NetworkCatalogTree(parent, item, position); - ptr->item().onDisplayItem(); - return ptr; - } else if (item->isInstanceOf(NetworkBookItem::TYPE_ID)) { - return new NetworkBookTree(parent, item, NetworkBookTree::AUTHORS); - } - return 0; -} - -void NetworkTreeFactory::fillAuthorTree(NetworkTree *parent, const NetworkItem::List &books) { - NetworkSeriesTree *seriesTree = 0; - NetworkAuthorTree *authorTree = 0; - - int flags = NetworkCatalogItem::FLAGS_DEFAULT; - if (NetworkCatalogTree* catalogTree = zlobject_cast<NetworkCatalogTree*>(parent)) { - flags = catalogTree->item().getFlags(); - } - NetworkBookTree::SummaryType booksSummaryType = NetworkBookTree::AUTHORS; - if ((parent->isInstanceOf(NetworkCatalogTree::TYPE_ID) && - (flags & NetworkCatalogItem::FLAG_SHOW_AUTHOR) == 0) || - parent->isInstanceOf(NetworkAuthorTree::TYPE_ID)) { - booksSummaryType = NetworkBookTree::NONE; - } - - for (NetworkItem::List::const_iterator it = books.begin(); it != books.end(); ++it) { - if (!(*it)->isInstanceOf(NetworkBookItem::TYPE_ID)) { - continue; - } - const NetworkBookItem &book = (const NetworkBookItem &) **it; - - //TODO split this method on smaller parts - switch (flags & NetworkCatalogItem::FLAGS_GROUP) { - case NetworkCatalogItem::FLAG_GROUP_BY_SERIES: - if (book.SeriesTitle.empty()) { - new NetworkBookTree(parent, *it, booksSummaryType); - } else { - if (seriesTree == 0 || seriesTree->title() != book.SeriesTitle) { - seriesTree = new NetworkSeriesTree(parent, book.SeriesTitle); - } - new NetworkBookTree(seriesTree, *it, booksSummaryType); - } - break; - case NetworkCatalogItem::FLAG_GROUP_MORE_THAN_1_BOOK_BY_SERIES: - { - std::string seriesTitle = book.SeriesTitle; - if (!seriesTitle.empty() && (seriesTree == 0 || seriesTree->title() != seriesTitle)) { - NetworkItem::List::const_iterator jt = it + 1; - while (jt != books.end() && !(*jt)->isInstanceOf(NetworkBookItem::TYPE_ID)) { - ++jt; - } - if (jt == books.end()) { - seriesTitle.clear(); - } else { - const NetworkBookItem &next = (const NetworkBookItem&)**jt; - if (next.SeriesTitle != seriesTitle) { - seriesTitle.clear(); - } - } - } - if (seriesTitle.empty()) { - seriesTree = 0; - new NetworkBookTree(parent, *it, booksSummaryType); - } else { - if (seriesTree == 0 || seriesTree->title() != seriesTitle) { - seriesTree = new NetworkSeriesTree(parent, seriesTitle); - } - new NetworkBookTree(seriesTree, *it, booksSummaryType); - } - } - break; - case NetworkCatalogItem::FLAG_GROUP_BY_AUTHOR: - if (book.Authors.empty()) { - new NetworkBookTree(parent, *it, booksSummaryType); - } else { - const NetworkBookItem::AuthorData &author = book.Authors.front(); - if (authorTree == 0 || authorTree->author() != author) { - authorTree = new NetworkAuthorTree(parent, author); - } - new NetworkBookTree(authorTree, *it, booksSummaryType); - } - break; - default: - new NetworkBookTree(parent, *it, booksSummaryType); - break; - } - - - } -} diff --git a/fbreader/src/network/tree/NetworkTreeFactory.h b/fbreader/src/network/tree/NetworkTreeFactory.h deleted file mode 100644 index b53213e..0000000 --- a/fbreader/src/network/tree/NetworkTreeFactory.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __NETWORKTREEFACTORY_H__ -#define __NETWORKTREEFACTORY_H__ - -#include "../NetworkItems.h" - -class NetworkBookCollection; -class FBTree; -class NetworkCatalogTree; -class NetworkTree; -class ZLTreeTitledNode; - - -class NetworkTreeFactory { - -private: - NetworkTreeFactory(); - -public: - static ZLTreeTitledNode *createNetworkTree(NetworkCatalogTree *parent, shared_ptr<NetworkItem> item, std::size_t position = (std::size_t)-1); - static void fillAuthorTree(NetworkTree *parent, const NetworkItem::List &books); -}; - -#endif /* __NETWORKTREEFACTORY_H__ */ diff --git a/fbreader/src/network/tree/NetworkTreeNodes.h b/fbreader/src/network/tree/NetworkTreeNodes.h deleted file mode 100644 index fcc76f6..0000000 --- a/fbreader/src/network/tree/NetworkTreeNodes.h +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __NETWORKTREENODES_H__ -#define __NETWORKTREENODES_H__ - -#include <ZLResource.h> -#include <ZLExecutionUtil.h> - -#include <ZLTreeNode.h> -#include <ZLTreeDialog.h> -#include <ZLTreePageNode.h> - -#include "../NetworkLink.h" -#include "../../tree/FBTree.h" - -//maybe RootTree should be nested class for NetworkLibrary? -class RootTree : public ZLTreeNode { - -public: - static const ZLTypeId TYPE_ID; - -private: - const ZLTypeId &typeId() const; - -public: - RootTree(); - void setDialog(shared_ptr<ZLTreeDialog> dialog); - - -protected: - ZLTreeListener *listener() const; - -private: - shared_ptr<ZLTreeDialog> myListener; -}; - -class NetworkTree : public FBTree { - -public: - static const ZLTypeId TYPE_ID; - -private: - const ZLTypeId &typeId() const; - -public: - NetworkTree(RootTree *parent, std::size_t position); - NetworkTree(NetworkTree *parent, std::size_t position = (std::size_t)-1); -}; - -class NetworkCatalogTree : public NetworkTree { - -public: - static const ZLTypeId TYPE_ID; - -private: - const ZLTypeId &typeId() const; - -public: - NetworkCatalogTree(RootTree *parent, shared_ptr<NetworkItem> item, std::size_t position = (std::size_t)-1); - NetworkCatalogTree(NetworkCatalogTree *parent, shared_ptr<NetworkItem> item, std::size_t position = (std::size_t)-1); - - std::string title() const; - std::string subtitle() const; - shared_ptr<const ZLImage> image() const; - - void requestChildren(shared_ptr<ZLNetworkRequest::Listener> listener); - void requestMoreChildren(shared_ptr<ZLNetworkRequest::Listener> listener); - virtual void onChildrenReceived(NetworkItem::List &childrens, const std::string &error); - - NetworkCatalogItem &item(); - - void updateVisibility(); - void clearCatalog(); - -private: - void init(); - void notifyListeners(const std::string &error); - -private: - void onAuthCheck(const std::string &error); - -private: - const ZLResource &resource() const; - -private: - shared_ptr<NetworkItem> myItem; - NetworkItem::List myChildrenItems; - - std::vector<shared_ptr<ZLNetworkRequest::Listener> > myListeners; - mutable shared_ptr<const ZLImage> myImage; - -friend class NetworkTreeFactory; -friend class NetworkCatalogTreeAuthListener; -}; - -class NetworkCatalogRootTree : public NetworkCatalogTree { - -public: - static const ZLTypeId TYPE_ID; - -private: - const ZLTypeId &typeId() const; - -public: - class LoginAction; - class LogoutAction; - class TopupAccountAction; - class PasswordRecoveryAction; - class RegisterUserAction; - -public: - NetworkCatalogRootTree(RootTree *parent, NetworkLink &link, std::size_t position); - void init(); - -private: - const ZLResource &resource() const; - -private: - NetworkLink &myLink; -}; - -class SearchCatalogTree : public NetworkCatalogTree { - -public: - static const ZLTypeId TYPE_ID; - -private: - const ZLTypeId &typeId() const; - -public: - SearchCatalogTree(RootTree *parent, shared_ptr<NetworkItem> item, std::size_t position = (std::size_t)-1); - - void requestChildren(shared_ptr<ZLNetworkRequest::Listener> listener); - void onChildrenReceived(NetworkItem::List &childrens, const std::string &error); -}; - -class NetworkAuthorTree : public NetworkTree { - -public: - static const ZLTypeId TYPE_ID; - -private: - const ZLTypeId &typeId() const; - -protected: - NetworkAuthorTree(NetworkTree *parent, const NetworkBookItem::AuthorData &author); - -friend class NetworkTreeFactory; - -public: - const NetworkBookItem::AuthorData &author(); - -private: - void init(); - const ZLResource &resource() const; - shared_ptr<const ZLImage> image() const; - std::string title() const; - -private: - NetworkBookItem::AuthorData myAuthor; -}; - -class NetworkSeriesTree : public NetworkTree { - -public: - static const ZLTypeId TYPE_ID; - -private: - const ZLTypeId &typeId() const; - -protected: - NetworkSeriesTree(NetworkTree *parent, const std::string &seriesTitle); - -friend class NetworkTreeFactory; - -private: - void init(); - const ZLResource &resource() const; - shared_ptr<const ZLImage> image() const; - std::string title() const; - std::string subtitle() const; - -private: - std::string mySeriesTitle; - mutable std::vector<shared_ptr<const ZLImage> > myImages; -}; - -class NetworkBookTree : public ZLTreePageNode { - -public: - static const ZLTypeId TYPE_ID; - -private: - const ZLTypeId &typeId() const; - -public: - enum SummaryType { AUTHORS, NONE }; - -private: - NetworkBookTree(NetworkTree *parent, shared_ptr<NetworkItem> book, SummaryType summaryType); - void init(); - -friend class NetworkTreeFactory; - -public: - const NetworkBookItem &book() const; - -public: - const ZLResource &resource() const; - shared_ptr<const ZLImage> image() const; - shared_ptr<const ZLImage> fullImage() const; - std::string title() const; - std::string subtitle() const; - - shared_ptr<ZLTreePageInfo> getPageInfo(); - -private: - class BookItemWrapper : public ZLTreePageInfo { - - public: - BookItemWrapper(NetworkBookTree &tree, shared_ptr<NetworkItem> bookItem); - - bool isPageInfoLoaded(); - void loadAll(shared_ptr<ZLNetworkRequest::Listener> listener); - void onInformationLoaded(ZLUserDataHolder &data, const std::string &error); - void onCoverLoaded(ZLUserDataHolder &data, const std::string &error); - - public: - std::string title() const; - std::vector<std::string> authors() const; - std::vector<std::string> tags() const; - std::string summary() const; - shared_ptr<const ZLImage> image() const; - - //TODO maybe store actions in other place? - const std::vector<shared_ptr<ZLTreeAction> > &actions() const; - std::string actionText(const shared_ptr<ZLTreeAction> &action) const; - const std::vector<shared_ptr<ZLTreeAction> > relatedActions() const; - - private: - NetworkBookItem &book() const; - - private: - NetworkBookTree &myTree; - shared_ptr<NetworkItem> myBookItem; - mutable bool myIsInitialized; - - mutable std::vector<shared_ptr<ZLTreeAction> > myRelatedActions; - }; - -private: - shared_ptr<NetworkItem> myBook; - SummaryType mySummaryType; - mutable shared_ptr<const ZLImage> myImage; - shared_ptr<ZLTreePageInfo> myPageInfo; -}; - -#endif /* __NETWORKTREENODES_H__ */ diff --git a/fbreader/src/network/tree/RootTree.cpp b/fbreader/src/network/tree/RootTree.cpp deleted file mode 100644 index 8aad8a5..0000000 --- a/fbreader/src/network/tree/RootTree.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include "NetworkTreeNodes.h" - -const ZLTypeId RootTree::TYPE_ID(ZLTreeNode::TYPE_ID); - -const ZLTypeId &RootTree::typeId() const { - return TYPE_ID; -} - - -RootTree::RootTree() { - -} - -void RootTree::setDialog(shared_ptr<ZLTreeDialog> dialog) { - myListener = dialog; -} - -ZLTreeListener *RootTree::listener() const { - if (myListener.isNull()) { - return 0; - } - return &(*myListener); -} diff --git a/fbreader/src/network/tree/SearchCatalogTree.cpp b/fbreader/src/network/tree/SearchCatalogTree.cpp deleted file mode 100644 index 62ee967..0000000 --- a/fbreader/src/network/tree/SearchCatalogTree.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include "NetworkTreeNodes.h" - -const ZLTypeId SearchCatalogTree::TYPE_ID(NetworkCatalogTree::TYPE_ID); - -const ZLTypeId &SearchCatalogTree::typeId() const { - return TYPE_ID; -} - -SearchCatalogTree::SearchCatalogTree(RootTree *parent, shared_ptr<NetworkItem> item, std::size_t position) : - NetworkCatalogTree(parent, item, position) { - //TODO maybe remove this class -} - -void SearchCatalogTree::requestChildren(shared_ptr<ZLNetworkRequest::Listener> listener) { - notifySearchStarted(); - NetworkCatalogTree::requestChildren(listener); -} - -void SearchCatalogTree::onChildrenReceived(NetworkItem::List &childrens, const std::string &error) { - notifySearchStopped(); - NetworkCatalogTree::onChildrenReceived(childrens, error); -} |
