1
/****************************************************************************
2
* Copyright (C) 2014 by Savoir-Faire Linux *
3
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
5
* This library is free software; you can redistribute it and/or *
6
* modify it under the terms of the GNU Lesser General Public *
7
* License as published by the Free Software Foundation; either *
8
* version 2.1 of the License, or (at your option) any later version. *
10
* This library 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 GNU *
13
* Lesser General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17
***************************************************************************/
18
#include "hookmanager.h"
20
#include <QtCore/QCoreApplication>
21
#include "dbus/configurationmanager.h"
23
HookManager* HookManager::m_spInstance = nullptr;
25
HookManager::HookManager() : QObject(QCoreApplication::instance())
27
ConfigurationManagerInterface & configurationManager = DBus::ConfigurationManager::instance();
28
QMap<QString,QString> hooks = configurationManager.getHookSettings();
29
m_AddPrefix = hooks[HookManager::Names::PHONE_NUMBER_HOOK_ADD_PREFIX];
30
m_SipFeild = hooks[HookManager::Names::URLHOOK_SIP_FIELD ];
31
m_Command = hooks[HookManager::Names::URLHOOK_COMMAND ];
32
m_Iax2Enabled = hooks[HookManager::Names::URLHOOK_IAX2_ENABLED ]=="true"?true:false;
33
m_SipEnabled = hooks[HookManager::Names::URLHOOK_SIP_ENABLED ]=="true"?true:false;
34
m_PhoneNumberEnabled = hooks[HookManager::Names::PHONE_NUMBER_HOOK_ENABLED ]=="true"?true:false;
38
HookManager::~HookManager()
42
void HookManager::save()
44
ConfigurationManagerInterface & configurationManager = DBus::ConfigurationManager::instance();
45
QMap<QString,QString> hooks;
47
hooks[HookManager::Names::PHONE_NUMBER_HOOK_ADD_PREFIX] = m_AddPrefix;
48
hooks[HookManager::Names::URLHOOK_SIP_FIELD ] = m_SipFeild;
49
hooks[HookManager::Names::URLHOOK_COMMAND ] = m_Command;
50
hooks[HookManager::Names::URLHOOK_IAX2_ENABLED ] = m_Iax2Enabled?"true":"false";
51
hooks[HookManager::Names::URLHOOK_SIP_ENABLED ] = m_SipEnabled?"true":"false";
52
hooks[HookManager::Names::PHONE_NUMBER_HOOK_ENABLED ] = m_PhoneNumberEnabled?"true":"false";
53
configurationManager.setHookSettings(hooks);
56
HookManager* HookManager::instance()
59
m_spInstance = new HookManager();
63
QString HookManager::prefix() const
68
QString HookManager::sipFeild() const
73
QString HookManager::command() const
78
bool HookManager::isIax2Enabled() const
83
bool HookManager::isSipEnabled() const
88
bool HookManager::isPhoneNumberEnabled() const
90
return m_PhoneNumberEnabled;
93
void HookManager::setPrefix(const QString& prefix)
99
void HookManager::setSipFeild(const QString& field)
105
void HookManager::setCommand(const QString& command)
111
void HookManager::setIax2Enabled(bool enabled)
113
m_Iax2Enabled = enabled;
117
void HookManager::setSipEnabled(bool enabled)
119
m_SipEnabled = enabled;
123
void HookManager::setPhoneNumberEnabled(bool enabled)
125
m_PhoneNumberEnabled = enabled;