Skip to content
Snippets Groups Projects
Commit d0c086c2 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

[ #50194 ] Fix the 'hooks' config page

parent c894730d
Branches
Tags
No related merge requests found
...@@ -106,6 +106,7 @@ set( qtsflphone_LIB_SRCS ...@@ -106,6 +106,7 @@ set( qtsflphone_LIB_SRCS
#Other #Other
sflphone_const.h sflphone_const.h
categorizedcompositenode.cpp categorizedcompositenode.cpp
hookmanager.cpp
) )
set( qtsflphone_LIB_HDRS set( qtsflphone_LIB_HDRS
...@@ -141,6 +142,7 @@ set( qtsflphone_LIB_HDRS ...@@ -141,6 +142,7 @@ set( qtsflphone_LIB_HDRS
transitionalcontactbackend.h transitionalcontactbackend.h
abstractitembackend.h abstractitembackend.h
itembackendmodel.h itembackendmodel.h
hookmanager.h
video/videodevice.h video/videodevice.h
video/videodevicemodel.h video/videodevicemodel.h
video/videocodec.h video/videocodec.h
......
/****************************************************************************
* Copyright (C) 2014 by Savoir-Faire Linux *
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "hookmanager.h"
#include <QtCore/QCoreApplication>
#include "dbus/configurationmanager.h"
HookManager* HookManager::m_spInstance = nullptr;
HookManager::HookManager() : QObject(QCoreApplication::instance())
{
ConfigurationManagerInterface & configurationManager = DBus::ConfigurationManager::instance();
QMap<QString,QString> hooks = configurationManager.getHookSettings();
m_AddPrefix = hooks[HookManager::Names::PHONE_NUMBER_HOOK_ADD_PREFIX];
m_SipFeild = hooks[HookManager::Names::URLHOOK_SIP_FIELD ];
m_Command = hooks[HookManager::Names::URLHOOK_COMMAND ];
m_Iax2Enabled = hooks[HookManager::Names::URLHOOK_IAX2_ENABLED ]=="true"?true:false;
m_SipEnabled = hooks[HookManager::Names::URLHOOK_SIP_ENABLED ]=="true"?true:false;
m_PhoneNumberEnabled = hooks[HookManager::Names::PHONE_NUMBER_HOOK_ENABLED ]=="true"?true:false;
}
HookManager::~HookManager()
{
}
void HookManager::save()
{
ConfigurationManagerInterface & configurationManager = DBus::ConfigurationManager::instance();
QMap<QString,QString> hooks;
hooks[HookManager::Names::PHONE_NUMBER_HOOK_ADD_PREFIX] = m_AddPrefix;
hooks[HookManager::Names::URLHOOK_SIP_FIELD ] = m_SipFeild;
hooks[HookManager::Names::URLHOOK_COMMAND ] = m_Command;
hooks[HookManager::Names::URLHOOK_IAX2_ENABLED ] = m_Iax2Enabled?"true":"false";
hooks[HookManager::Names::URLHOOK_SIP_ENABLED ] = m_SipEnabled?"true":"false";
hooks[HookManager::Names::PHONE_NUMBER_HOOK_ENABLED ] = m_PhoneNumberEnabled?"true":"false";
configurationManager.setHookSettings(hooks);
}
HookManager* HookManager::instance()
{
if (!m_spInstance)
m_spInstance = new HookManager();
return m_spInstance;
}
QString HookManager::prefix() const
{
return m_AddPrefix;
}
QString HookManager::sipFeild() const
{
return m_SipFeild;
}
QString HookManager::command() const
{
return m_Command;
}
bool HookManager::isIax2Enabled() const
{
return m_Iax2Enabled;
}
bool HookManager::isSipEnabled() const
{
return m_SipEnabled;
}
bool HookManager::isPhoneNumberEnabled() const
{
return m_PhoneNumberEnabled;
}
void HookManager::setPrefix(const QString& prefix)
{
m_AddPrefix = prefix;
save();
}
void HookManager::setSipFeild(const QString& field)
{
m_SipFeild = field;
save();
}
void HookManager::setCommand(const QString& command)
{
m_Command = command;
save();
}
void HookManager::setIax2Enabled(bool enabled)
{
m_Iax2Enabled = enabled;
save();
}
void HookManager::setSipEnabled(bool enabled)
{
m_SipEnabled = enabled;
save();
}
void HookManager::setPhoneNumberEnabled(bool enabled)
{
m_PhoneNumberEnabled = enabled;
save();
}
/****************************************************************************
* Copyright (C) 2014 by Savoir-Faire Linux *
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef HOOKMANAGER_H
#define HOOKMANAGER_H
#include "typedefs.h"
/**
* This class allow to get and set the different hooks
*/
class LIB_EXPORT HookManager : public QObject
{
Q_OBJECT
public:
static HookManager* instance();
//Properties
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix )
Q_PROPERTY(QString sipFeild READ sipFeild WRITE setSipFeild )
Q_PROPERTY(QString command READ command WRITE setCommand )
Q_PROPERTY(bool iax2Enabled READ isIax2Enabled WRITE setIax2Enabled )
Q_PROPERTY(bool sipEnabled READ isSipEnabled WRITE setSipEnabled )
Q_PROPERTY(bool phoneNumberEnabled READ isPhoneNumberEnabled WRITE setPhoneNumberEnabled )
//Getters
QString prefix () const;
QString sipFeild () const;
QString command () const;
bool isIax2Enabled () const;
bool isSipEnabled () const;
bool isPhoneNumberEnabled() const;
//Setters
void setPrefix (const QString& prefix );
void setSipFeild (const QString& field );
void setCommand (const QString& command);
void setIax2Enabled (bool enabled );
void setSipEnabled (bool enabled );
void setPhoneNumberEnabled (bool enabled );
private:
explicit HookManager();
virtual ~HookManager();
void save();
class Names {
public:
constexpr static const char* PHONE_NUMBER_HOOK_ADD_PREFIX = "PHONE_NUMBER_HOOK_ADD_PREFIX";
constexpr static const char* URLHOOK_SIP_FIELD = "URLHOOK_SIP_FIELD" ;
constexpr static const char* URLHOOK_COMMAND = "URLHOOK_COMMAND" ;
constexpr static const char* URLHOOK_IAX2_ENABLED = "URLHOOK_IAX2_ENABLED" ;
constexpr static const char* URLHOOK_SIP_ENABLED = "URLHOOK_SIP_ENABLED" ;
constexpr static const char* PHONE_NUMBER_HOOK_ENABLED = "PHONE_NUMBER_HOOK_ENABLED" ;
};
//Attributes
QString m_AddPrefix ;
QString m_SipFeild ;
QString m_Command ;
bool m_Iax2Enabled ;
bool m_SipEnabled ;
bool m_PhoneNumberEnabled;
static HookManager* m_spInstance;
};
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment