diff options
author | Michele Calgaro <[email protected]> | 2024-06-07 23:30:05 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2024-06-07 23:30:05 +0900 |
commit | 17b259df9cb6b28779d4881b2b6c805ee2e48eea (patch) | |
tree | 5ed61937459cb7081089111b0242c01ec178f1f3 /fbreader/src/networkActions/AuthenticationDialog.cpp | |
parent | 1cba8bce178eb2d6719c6f7f21e2c9352c5513a6 (diff) | |
download | tde-ebook-reader-17b259df9cb6b28779d4881b2b6c805ee2e48eea.tar.gz tde-ebook-reader-17b259df9cb6b28779d4881b2b6c805ee2e48eea.zip |
Rename to tde-ebook-reader
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'fbreader/src/networkActions/AuthenticationDialog.cpp')
-rw-r--r-- | fbreader/src/networkActions/AuthenticationDialog.cpp | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/fbreader/src/networkActions/AuthenticationDialog.cpp b/fbreader/src/networkActions/AuthenticationDialog.cpp deleted file mode 100644 index 4f4ed1a..0000000 --- a/fbreader/src/networkActions/AuthenticationDialog.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 <ZLDialog.h> -#include <ZLDialogManager.h> -#include <ZLOptionsDialog.h> -#include <ZLOptionEntry.h> - -#include <ZLSimpleOptionEntry.h> - -#include "../network/NetworkLink.h" -#include "AuthenticationDialog.h" -#include "NetworkOperationRunnable.h" -#include "../network/UserList.h" -#include "../network/authentication/NetworkAuthenticationManager.h" - -class UserNamesEntry : public ZLComboOptionEntry { - -public: - UserNamesEntry(UserList &userList, ZLStringOption &userNameOption); - - const std::string &initialValue() const; - const std::vector<std::string> &values() const; - void onAccept(const std::string &value); - -private: - UserList &myUserList; - ZLStringOption &myUserNameOption; -}; - -UserNamesEntry::UserNamesEntry(UserList &userList, ZLStringOption &userNameOption) : - ZLComboOptionEntry(true), myUserList(userList), myUserNameOption(userNameOption) { -} - -const std::string &UserNamesEntry::initialValue() const { - return myUserNameOption.value(); -} - -const std::vector<std::string> &UserNamesEntry::values() const { - return myUserList.users(); -} - -void UserNamesEntry::onAccept(const std::string &value) { - myUserList.addUser(value); - myUserNameOption.setValue(value); -} - - -class PasswordOptionEntry : public ZLPasswordOptionEntry { - -public: - PasswordOptionEntry(std::string &password); - - virtual const std::string &initialValue() const; - virtual void onAccept(const std::string &value); - -private: - std::string &myPassword; -}; - -PasswordOptionEntry::PasswordOptionEntry(std::string &password) : myPassword(password) { -} - -const std::string &PasswordOptionEntry::initialValue() const { - static const std::string _empty; - return _empty; -} - -void PasswordOptionEntry::onAccept(const std::string &value) { - myPassword = value; -} - -AuthenticationDialog::AuthenticationDialog(ZLStringOption &userNameOption, UserList &userList, const std::string &errorMessage, std::string &password) : - myUserList(userList) { - myDialog = ZLDialogManager::Instance().createDialog(ZLResourceKey("AuthenticationDialog")); - - if (!errorMessage.empty()) { - myDialog->addOption("", "", new ZLSimpleStaticTextOptionEntry(errorMessage)); - } - - myDialog->addOption(ZLResourceKey("login"), new UserNamesEntry(myUserList, userNameOption)); - myDialog->addOption(ZLResourceKey("password"), new PasswordOptionEntry(password)); - - myDialog->addButton(ZLDialogManager::OK_BUTTON, true); - myDialog->addButton(ZLDialogManager::CANCEL_BUTTON, false); -} - -bool AuthenticationDialog::run(ZLStringOption &userNameOption, UserList &userList, const std::string &errorMessage, std::string &password) { - AuthenticationDialog dlg(userNameOption, userList, errorMessage, password); - if (dlg.dialog().run()) { - dlg.dialog().acceptValues(); - return true; - } - return false; -} - -bool AuthenticationDialog::run(const std::string &siteName, std::string &userName, std::string &password, const std::string &message) { - UserList userList(siteName); - //TODO fix it: using unexisted string option, just for dialog showing - ZLStringOption userNameOption(ZLCategoryKey::NETWORK, "", "userName", userName); - userNameOption.setValue(std::string()); - bool result = run(userNameOption, userList, message, password); - userName = userNameOption.value(); - userNameOption.clearGroup(""); - return result; -} |