/* * Copyright (C) 2009-2012 Geometer Plus * * 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 __LITRESAUTHENTICATIONMANAGER_H__ #define __LITRESAUTHENTICATIONMANAGER_H__ #include #include #include #include "../NetworkAuthenticationManager.h" #include "../../NetworkItems.h" class LitResAuthenticationManager : public NetworkAuthenticationManager { public: LitResAuthenticationManager(const NetworkLink &link); public: AuthenticationStatus isAuthorised(shared_ptr listener = 0); std::string authorise(const std::string &pwd, shared_ptr listener); void logOut(); bool skipIPSupported(); const std::string ¤tUserName(); bool needsInitialization(); std::string initialize(shared_ptr listener); bool needPurchase(const NetworkBookItem &book); std::string purchaseBook(const NetworkBookItem &, shared_ptr listener); shared_ptr downloadReference(const NetworkBookItem &book); std::string topupAccountLink(); std::string currentAccount(); std::string reloadPurchasedBooks(shared_ptr listener); void collectPurchasedBooks(NetworkItem::List &list); const std::set &getPurchasedIds() const; const NetworkItem::List &purchasedBooks() const; private: void onAuthorised(ZLUserDataHolder &data, const std::string &error); void onBookPurchased(ZLUserDataHolder &data, const std::string &error); void onBooksLoaded(ZLUserDataHolder &data, const std::string &error); void onAccountReceived(ZLUserDataHolder &data, const std::string &error); void onBooksReloaded(ZLUserDataHolder &data, const std::string &error); private: shared_ptr loadPurchasedBooks(std::set &purchasedBooksIds, NetworkItem::List &purchasedBooksList); void loadPurchasedBooksOnError(std::set &purchasedBooksIds, NetworkItem::List &purchasedBooksList); void loadPurchasedBooksOnSuccess(std::set &purchasedBooksIds, NetworkItem::List &purchasedBooksList); shared_ptr loadAccount(std::string &dummy1); void loadAccountOnError(); void loadAccountOnSuccess(); public: // new User Registration bool registrationSupported(); std::string registerUser(const std::string &login, const std::string &password, const std::string &email); public: // Password Recovery bool passwordRecoverySupported(); std::string recoverPassword(const std::string &email); private: bool mySidChecked; ZLStringOption mySidUserNameOption; ZLStringOption mySidOption; std::string myInitializedDataSid; std::set myPurchasedBooksIds; NetworkItem::List myPurchasedBooksList; std::string myAccount; }; #endif /* __LITRESAUTHENTICATIONMANAGER_H__ */