| 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 "ContactListCommand.h" |
|---|
| 21 | |
|---|
| 22 | #include "ContactCommand.h" |
|---|
| 23 | |
|---|
| 24 | #include <coipmanager/CoIpManager.h> |
|---|
| 25 | #include <coipmanager_base/contact/ContactList.h> |
|---|
| 26 | #include <coipmanager/datamanager/UserProfileManager.h> |
|---|
| 27 | #include <coipmanager_base/userprofile/UserProfile.h> |
|---|
| 28 | |
|---|
| 29 | #include <iostream> |
|---|
| 30 | |
|---|
| 31 | ContactListCommand::ContactListCommand(CoIpManager & coIpManager) |
|---|
| 32 | : Command("Contact list management", "Add, remove and list contacts", coIpManager) { |
|---|
| 33 | |
|---|
| 34 | _menuContent.push_back(std::pair<std::string, boost::function< void () > >("Add a contact", boost::bind(&ContactListCommand::addContact, this))); |
|---|
| 35 | _menuContent.push_back(std::pair<std::string, boost::function< void () > >("Remove a contact", boost::bind(&ContactListCommand::removeContact, this))); |
|---|
| 36 | _menuContent.push_back(std::pair<std::string, boost::function< void () > >("Modify a contact", boost::bind(&ContactListCommand::modifyContact, this))); |
|---|
| 37 | _menuContent.push_back(std::pair<std::string, boost::function< void () > >("List contacts", boost::bind(&ContactListCommand::listContact, this))); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | ContactListCommand::~ContactListCommand() { |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | void ContactListCommand::addContact() { |
|---|
| 44 | Contact contact; |
|---|
| 45 | |
|---|
| 46 | ContactCommand contactCommand(contact, _coIpManager); |
|---|
| 47 | contactCommand.exec(); |
|---|
| 48 | |
|---|
| 49 | _coIpManager.getUserProfileManager().getContactManager().add(contact); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | void ContactListCommand::modifyContact() { |
|---|
| 53 | Contact * contact = Menu::listContactMenu(_coIpManager); |
|---|
| 54 | |
|---|
| 55 | ContactCommand contactCommand(*contact, _coIpManager); |
|---|
| 56 | contactCommand.exec(); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | void ContactListCommand::removeContact() { |
|---|
| 60 | Contact * contact = Menu::listContactMenu(_coIpManager); |
|---|
| 61 | _coIpManager.getUserProfileManager().getContactManager().remove(contact->getUUID()); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | void ContactListCommand::listContact() { |
|---|
| 65 | Menu::listContact(_coIpManager); |
|---|
| 66 | } |
|---|