source: qutecom-coip/libs/coipmanager/tests/commandline-test/AccountCommand.cpp @ 126:e699782dd54b

Last change on this file since 126:e699782dd54b was 126:e699782dd54b, checked in by laurent, 3 years ago

update copyright

File size: 3.0 KB
Line 
1/*
2 * QuteCom, a voice over Internet phone
3 * Copyright (C) 2010 Mbdsys
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20#include "AccountCommand.h"
21
22#include <coipmanager/CoIpManager.h>
23#include <coipmanager_base/account/AIMAccount.h>
24#include <coipmanager_base/account/AccountList.h>
25#include <coipmanager_base/account/GTalkAccount.h>
26#include <coipmanager_base/account/IAXAccount.h>
27#include <coipmanager_base/account/ICQAccount.h>
28#include <coipmanager_base/account/JabberAccount.h>
29#include <coipmanager_base/account/MSNAccount.h>
30#include <coipmanager_base/account/YahooAccount.h>
31#include <coipmanager/datamanager/UserProfileManager.h>
32#include <coipmanager_base/userprofile/UserProfile.h>
33
34#include <util/Logger.h>
35#include <util/SafeDelete.h>
36#include <event/Event2.h>
37
38#include <iostream>
39
40AccountCommand::AccountCommand(CoIpManager & coIpManager)
41        : Command("Account management", "Add, Remove and list accounts", coIpManager) {
42
43        _menuContent.push_back(std::pair<std::string, boost::function< void () > >("Add an account", boost::bind(&AccountCommand::addAccount, this)));
44        _menuContent.push_back(std::pair<std::string, boost::function< void () > >("Remove an account", boost::bind(&AccountCommand::removeAccount, this)));
45        _menuContent.push_back(std::pair<std::string, boost::function< void () > >("List account", boost::bind(&AccountCommand::listAccount, this)));
46}
47
48AccountCommand::~AccountCommand() {
49}
50
51void AccountCommand::addAccount() {
52        std::string login;
53        std::string password;
54        std::string server;
55
56        EnumAccountType::AccountType accountType = EnumAccountType::AccountTypeUnknown;
57
58        accountType = chooseAProtocol();
59
60        std::cout << "login: ";
61        std::cin >> login;
62
63        std::cout << "password: ";
64        std::cin >> password;
65
66        Account * account = new Account(login, password, accountType);
67        account->setSavePassword(true);
68        if (accountType == EnumAccountType::AccountTypeIAX) {
69                std::cout << "server: ";
70                std::cin >> server;
71                ((IAXAccount *) account->getPrivateAccount())->setSIPProxyServerHostname(server);
72        }
73
74        _coIpManager.getUserProfileManager().getAccountManager().add(*account);
75        OWSAFE_DELETE(account);
76}
77
78void AccountCommand::removeAccount() {
79        Account * account = Menu::listAccountMenu(_coIpManager);
80        _coIpManager.getUserProfileManager().getAccountManager().remove(account->getUUID());
81        OWSAFE_DELETE(account);
82}
83
84void AccountCommand::listAccount() {
85        Menu::listAccount(_coIpManager);
86}
Note: See TracBrowser for help on using the repository browser.