~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/lib/hookmanager.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 *   Copyright (C) 2014 by Savoir-Faire Linux                               *
 
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
4
 *                                                                          *
 
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.     *
 
9
 *                                                                          *
 
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.                        *
 
14
 *                                                                          *
 
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"
 
19
 
 
20
#include <QtCore/QCoreApplication>
 
21
#include "dbus/configurationmanager.h"
 
22
 
 
23
HookManager* HookManager::m_spInstance = nullptr;
 
24
 
 
25
HookManager::HookManager() : QObject(QCoreApplication::instance())
 
26
{
 
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;
 
35
 
 
36
}
 
37
 
 
38
HookManager::~HookManager()
 
39
{
 
40
}
 
41
 
 
42
void HookManager::save()
 
43
{
 
44
   ConfigurationManagerInterface & configurationManager = DBus::ConfigurationManager::instance();
 
45
   QMap<QString,QString> hooks;
 
46
 
 
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);
 
54
}
 
55
 
 
56
HookManager* HookManager::instance()
 
57
{
 
58
   if (!m_spInstance)
 
59
      m_spInstance = new HookManager();
 
60
   return m_spInstance;
 
61
}
 
62
 
 
63
QString HookManager::prefix() const
 
64
{
 
65
   return m_AddPrefix;
 
66
}
 
67
 
 
68
QString HookManager::sipFeild() const
 
69
{
 
70
   return m_SipFeild;
 
71
}
 
72
 
 
73
QString HookManager::command() const
 
74
{
 
75
   return m_Command;
 
76
}
 
77
 
 
78
bool HookManager::isIax2Enabled() const
 
79
{
 
80
   return m_Iax2Enabled;
 
81
}
 
82
 
 
83
bool HookManager::isSipEnabled() const
 
84
{
 
85
   return m_SipEnabled;
 
86
}
 
87
 
 
88
bool HookManager::isPhoneNumberEnabled() const
 
89
{
 
90
   return m_PhoneNumberEnabled;
 
91
}
 
92
 
 
93
void HookManager::setPrefix(const QString& prefix)
 
94
{
 
95
   m_AddPrefix = prefix;
 
96
   save();
 
97
}
 
98
 
 
99
void HookManager::setSipFeild(const QString& field)
 
100
{
 
101
   m_SipFeild = field;
 
102
   save();
 
103
}
 
104
 
 
105
void HookManager::setCommand(const QString& command)
 
106
{
 
107
   m_Command = command;
 
108
   save();
 
109
}
 
110
 
 
111
void HookManager::setIax2Enabled(bool enabled)
 
112
{
 
113
   m_Iax2Enabled = enabled;
 
114
   save();
 
115
}
 
116
 
 
117
void HookManager::setSipEnabled(bool enabled)
 
118
{
 
119
   m_SipEnabled = enabled;
 
120
   save();
 
121
}
 
122
 
 
123
void HookManager::setPhoneNumberEnabled(bool enabled)
 
124
{
 
125
   m_PhoneNumberEnabled = enabled;
 
126
   save();
 
127
}