Skip to content
Snippets Groups Projects
Commit 36a2a7bd authored by Philippe Proulx's avatar Philippe Proulx Committed by Tristan Matthews
Browse files

Librarize daemon and create daemon app

Refs:# 48032
parent ae4131cb
Branches
Tags
No related merge requests found
Showing
with 1856 additions and 90 deletions
......@@ -19,7 +19,7 @@ unittest:
endif
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src ringtones man $(TESTS_DIR) doc
SUBDIRS = src ringtones man $(TESTS_DIR) doc bin
EXTRA_DIST = m4/libtool.m4 \
m4/lt~obsolete.m4 \
......
SUBDIRS=dbus
libexecdir=$(libdir)/sflphone
libexec_PROGRAMS = sflphoned
sflphoned_SOURCES = main.cpp
sflphoned_CXXFLAGS=-I$(top_srcdir)/src ${DBUSCPP_CFLAGS} \
-DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\"
sflphoned_LDADD = ${DBUSCPP_LIBS} dbus/libclient_dbus.la $(top_builddir)/src/libsflphone.la
......@@ -3,66 +3,57 @@ include $(top_srcdir)/globals.mak
noinst_LTLIBRARIES = libclient_dbus.la
BUILT_SOURCES= \
callmanager-glue.h \
configurationmanager-glue.h \
instance-glue.h
dbuscallmanager.adaptor.h \
dbusconfigurationmanager.adaptor.h \
dbusinstance.adaptor.h
if SFL_PRESENCE
BUILT_SOURCES+=presencemanager-glue.h
presencemanager-glue.h: presencemanager-introspec.xml Makefile.am
BUILT_SOURCES+=dbuspresencemanager.adaptor.h
dbuspresencemanager.adaptor.h: presencemanager-introspec.xml Makefile.am
dbusxx-xml2cpp $< --adaptor=$@
endif
if SFL_VIDEO
BUILT_SOURCES+=videomanager-glue.h
videomanager-glue.h: videomanager-introspec.xml Makefile.am
BUILT_SOURCES+=dbusvideomanager.adaptor.h
dbusvideomanager.adaptor.h: videomanager-introspec.xml Makefile.am
dbusxx-xml2cpp $< --adaptor=$@
endif
# Rule to generate the binding headers
callmanager-glue.h: callmanager-introspec.xml Makefile.am
dbuscallmanager.adaptor.h: callmanager-introspec.xml Makefile.am
dbusxx-xml2cpp $< --adaptor=$@
# Rule to generate the binding headers
configurationmanager-glue.h: configurationmanager-introspec.xml Makefile.am
dbusconfigurationmanager.adaptor.h: configurationmanager-introspec.xml Makefile.am
dbusxx-xml2cpp $< --adaptor=$@
# Rule to generate the binding headers
instance-glue.h: instance-introspec.xml Makefile.am
dbusinstance.adaptor.h: instance-introspec.xml Makefile.am
dbusxx-xml2cpp $< --adaptor=$@
libclient_dbus_la_SOURCES = \
callmanager_dbus.cpp \
configurationmanager_dbus.cpp \
instance.cpp \
client.cpp
dbuscallmanager.cpp \
dbusconfigurationmanager.cpp \
dbusinstance.cpp \
dbusclient.cpp \
dbusinstance.h \
dbus_cpp.h \
$(BUILT_SOURCES)
if SFL_PRESENCE
libclient_dbus_la_SOURCES += presencemanager_dbus.cpp
libclient_dbus_la_SOURCES += dbuspresencemanager.cpp
endif
if SFL_VIDEO
libclient_dbus_la_SOURCES += videomanager_dbus.cpp
endif
if USE_NETWORKMANAGER
libclient_dbus_la_SOURCES += networkmanager.cpp
NETWORKMANAGER=-DUSE_NETWORKMANAGER
libclient_dbus_la_SOURCES += dbusvideomanager.cpp
endif
libclient_dbus_la_CXXFLAGS = -I../ \
-I$(top_srcdir)/src \
-DPREFIX=\"$(prefix)\" \
-DPROGSHAREDIR=\"${datadir}/sflphone\" \
$(NETWORKMANAGER) \
$(DBUSCPP_CFLAGS)
noinst_HEADERS = \
instance.h \
networkmanager_proxy.h \
networkmanager.h \
dbus_cpp.h \
$(BUILT_SOURCES)
# Dbus service file
servicedir = $(datadir)/dbus-1/services
service_in_files = org.sflphone.SFLphone.service.in
......
File moved
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
* Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include <iostream>
#include <sflphone.h>
#include "dbuscallmanager.h"
DBusCallManager::DBusCallManager(DBus::Connection& connection)
: DBus::ObjectAdaptor(connection, "/org/sflphone/SFLphone/CallManager")
{
}
bool DBusCallManager::placeCall(const std::string& accountID, const std::string& callID, const std::string& to)
{
return sflph_call_place(accountID, callID, to);
}
bool DBusCallManager::refuse(const std::string& callID)
{
return sflph_call_refuse(callID);
}
bool DBusCallManager::accept(const std::string& callID)
{
return sflph_call_accept(callID);
}
bool DBusCallManager::hangUp(const std::string& callID)
{
return sflph_call_hang_up(callID);
}
bool DBusCallManager::hold(const std::string& callID)
{
return sflph_call_hold(callID);
}
bool DBusCallManager::unhold(const std::string& callID)
{
return sflph_call_unhold(callID);
}
bool DBusCallManager::transfer(const std::string& callID, const std::string& to)
{
return sflph_call_transfer(callID, to);
}
bool DBusCallManager::attendedTransfer(const std::string& transferID, const std::string& targetID)
{
return sflph_call_attended_transfer(transferID, targetID);
}
std::map< std::string, std::string > DBusCallManager::getCallDetails(const std::string& callID)
{
return sflph_call_get_call_details(callID);
}
std::vector< std::string > DBusCallManager::getCallList()
{
return sflph_call_get_call_list();
}
void DBusCallManager::removeConference(const std::string& conference_id)
{
sflph_call_remove_conference(conference_id);
}
bool DBusCallManager::joinParticipant(const std::string& sel_callID, const std::string& drag_callID)
{
return sflph_call_join_participant(sel_callID, drag_callID);
}
void DBusCallManager::createConfFromParticipantList(const std::vector< std::string >& participants)
{
sflph_call_create_conf_from_participant_list(participants);
}
bool DBusCallManager::isConferenceParticipant(const std::string& call_id)
{
return sflph_call_is_conference_participant(call_id);
}
bool DBusCallManager::addParticipant(const std::string& callID, const std::string& confID)
{
return sflph_call_add_participant(callID, confID);
}
bool DBusCallManager::addMainParticipant(const std::string& confID)
{
return sflph_call_add_main_participant(confID);
}
bool DBusCallManager::detachParticipant(const std::string& callID)
{
return sflph_call_detach_participant(callID);
}
bool DBusCallManager::joinConference(const std::string& sel_confID, const std::string& drag_confID)
{
return sflph_call_join_conference(sel_confID, drag_confID);
}
bool DBusCallManager::hangUpConference(const std::string& confID)
{
return sflph_call_hang_up_conference(confID);
}
bool DBusCallManager::holdConference(const std::string& confID)
{
return sflph_call_hold_conference(confID);
}
bool DBusCallManager::unholdConference(const std::string& confID)
{
return sflph_call_unhold_conference(confID);
}
std::vector<std::string> DBusCallManager::getConferenceList()
{
return sflph_call_get_conference_list();
}
std::vector<std::string> DBusCallManager::getParticipantList(const std::string& confID)
{
return sflph_call_get_participant_list(confID);
}
std::vector<std::string> DBusCallManager::getDisplayNames(const std::string& confID)
{
return sflph_call_get_display_names(confID);
}
std::string DBusCallManager::getConferenceId(const std::string& callID)
{
return sflph_call_get_conference_id(callID);
}
std::map<std::string, std::string> DBusCallManager::getConferenceDetails(const std::string& callID)
{
return sflph_call_get_conference_details(callID);
}
bool DBusCallManager::startRecordedFilePlayback(const std::string& filepath)
{
return sflph_call_play_recorded_file(filepath);
}
void DBusCallManager::stopRecordedFilePlayback(const std::string& filepath)
{
sflph_call_stop_recorded_file(filepath);
}
bool DBusCallManager::toggleRecording(const std::string& callID)
{
return sflph_call_toggle_recording(callID);
}
void DBusCallManager::setRecording(const std::string& callID)
{
sflph_call_set_recording(callID);
}
void DBusCallManager::recordPlaybackSeek(const double& value)
{
sflph_call_record_playback_seek(value);
}
bool DBusCallManager::getIsRecording(const std::string& callID)
{
return sflph_call_is_recording(callID);
}
std::string DBusCallManager::getCurrentAudioCodecName(const std::string& callID)
{
return sflph_call_get_current_audio_codec_name(callID);
}
void DBusCallManager::playDTMF(const std::string& key)
{
sflph_call_play_dtmf(key);
}
void DBusCallManager::startTone(const int32_t& start, const int32_t& type)
{
sflph_call_start_tone(start, type);
}
void DBusCallManager::setSASVerified(const std::string& callID)
{
sflph_call_set_sas_verified(callID);
}
void DBusCallManager::resetSASVerified(const std::string& callID)
{
sflph_call_reset_sas_verified(callID);
}
void DBusCallManager::setConfirmGoClear(const std::string& callID)
{
sflph_call_set_confirm_go_clear(callID);
}
void DBusCallManager::requestGoClear(const std::string& callID)
{
sflph_call_request_go_clear(callID);
}
void DBusCallManager::acceptEnrollment(const std::string& callID, const bool& accepted)
{
sflph_call_accept_enrollment(callID, accepted);
}
void DBusCallManager::sendTextMessage(const std::string& callID, const std::string& message)
{
sflph_call_send_text_message(callID, message);
}
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef __SFL_CALLMANAGER_H__
#define __SFL_CALLMANAGER_H__
#include <vector>
#include <map>
#include <string>
#include "dbus_cpp.h"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include "dbuscallmanager.adaptor.h"
#pragma GCC diagnostic warning "-Wignored-qualifiers"
#pragma GCC diagnostic warning "-Wunused-parameter"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif
#include <stdexcept>
class DBusCallManager :
public org::sflphone::SFLphone::CallManager_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor
{
public:
DBusCallManager(DBus::Connection& connection);
// Methods
bool placeCall(const std::string& accountID, const std::string& callID, const std::string& to);
bool refuse(const std::string& callID);
bool accept(const std::string& callID);
bool hangUp(const std::string& callID);
bool hold(const std::string& callID);
bool unhold(const std::string& callID);
bool transfer(const std::string& callID, const std::string& to);
bool attendedTransfer(const std::string& transferID, const std::string& targetID);
std::map< std::string, std::string > getCallDetails(const std::string& callID);
std::vector< std::string > getCallList();
void removeConference(const std::string& conference_id);
bool joinParticipant(const std::string& sel_callID, const std::string& drag_callID);
void createConfFromParticipantList(const std::vector< std::string >& participants);
bool isConferenceParticipant(const std::string& call_id);
bool addParticipant(const std::string& callID, const std::string& confID);
bool addMainParticipant(const std::string& confID);
bool detachParticipant(const std::string& callID);
bool joinConference(const std::string& sel_confID, const std::string& drag_confID);
bool hangUpConference(const std::string& confID);
bool holdConference(const std::string& confID);
bool unholdConference(const std::string& confID);
std::vector<std::string> getConferenceList();
std::vector<std::string> getParticipantList(const std::string& confID);
std::vector<std::string> getDisplayNames(const std::string& confID);
std::string getConferenceId(const std::string& callID);
std::map<std::string, std::string> getConferenceDetails(const std::string& callID);
bool startRecordedFilePlayback(const std::string& filepath);
void stopRecordedFilePlayback(const std::string& filepath);
bool toggleRecording(const std::string& callID);
void setRecording(const std::string& callID);
void recordPlaybackSeek(const double& value);
bool getIsRecording(const std::string& callID);
std::string getCurrentAudioCodecName(const std::string& callID);
void playDTMF(const std::string& key);
void startTone(const int32_t& start, const int32_t& type);
void setSASVerified(const std::string& callID);
void resetSASVerified(const std::string& callID);
void setConfirmGoClear(const std::string& callID);
void requestGoClear(const std::string& callID);
void acceptEnrollment(const std::string& callID, const bool& accepted);
void sendTextMessage(const std::string& callID, const std::string& message);
};
#endif // __SFL_CALLMANAGER_H__
/*
* Copyright (C) 2014 Savoir-Faire Linux Inc.
* Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <stdexcept>
#include <sflphone.h>
#include "dbusclient.h"
#include "dbus_cpp.h"
#include "dbusinstance.h"
#include "dbuscallmanager.h"
#include "dbusconfigurationmanager.h"
#ifdef SFL_PRESENCE
#include "dbuspresencemanager.h"
#endif
#ifdef SFL_VIDEO
#include "dbusvideomanager.h"
#endif
struct EventCallback : DBus::Callback_Base<void, DBus::DefaultTimeout&>
{
EventCallback(const std::function<void()> &func) :
callback_(func)
{}
void call(DBus::DefaultTimeout &) const
{
callback_();
}
private:
std::function<void()> callback_;
};
DBusClient* DBusClient::_lastDbusClient = nullptr;
DBusClient::DBusClient(int sflphFlags, bool persistent) :
callManager_(nullptr)
, configurationManager_(nullptr)
#ifdef SFL_PRESENCE
, presenceManager_(nullptr)
#endif
, instanceManager_(nullptr)
, dispatcher_(new DBus::BusDispatcher)
#ifdef SFL_VIDEO
, videoManager_(nullptr)
#endif
{
try {
DBus::_init_threading();
DBus::default_dispatcher = dispatcher_;
// timeout and expired are deleted internally by dispatcher_'s
// destructor, so we must NOT delete them ourselves.
DBus::DefaultTimeout *timeout = new DBus::DefaultTimeout(10 /* ms */,
true,
dispatcher_);
// Poll for SIP/IAX events
timeout->expired = new EventCallback(sflph_poll_events);
DBus::Connection sessionConnection(DBus::Connection::SessionBus());
sessionConnection.request_name("org.sflphone.SFLphone");
callManager_ = new DBusCallManager(sessionConnection);
configurationManager_ = new DBusConfigurationManager(sessionConnection);
#ifdef SFL_PRESENCE
presenceManager_ = new DBusPresenceManager(sessionConnection);
#endif
DBusInstance::OnNoMoreClientFunc onNoMoreClientFunc;
if (!persistent) {
onNoMoreClientFunc = [this] () {
this->exit();
};
}
instanceManager_ = new DBusInstance(sessionConnection, onNoMoreClientFunc);
#ifdef SFL_VIDEO
videoManager_ = new DBusVideoManager(sessionConnection);
#endif
} catch (const DBus::Error &err) {
throw std::runtime_error("cannot initialize DBus stuff");
}
auto ret = initLibrary(sflphFlags);
if (ret < 0) {
throw std::runtime_error("cannot initialize libsflphone");
}
instanceManager_->started();
}
DBusClient::~DBusClient()
{
#ifdef SFL_VIDEO
delete videoManager_;
#endif
delete instanceManager_;
#ifdef SFL_PRESENCE
delete presenceManager_;
#endif
delete configurationManager_;
delete callManager_;
delete dispatcher_;
finiLibrary();
}
int DBusClient::initLibrary(int sflphFlags)
{
if (!DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient = this;
}
// Call event handlers
sflph_call_ev_handlers callEvHandlers = {
DBusClient::callOnStateChange,
DBusClient::callOnTransferFail,
DBusClient::callOnTransferSuccess,
DBusClient::callOnRecordPlaybackStopped,
DBusClient::callOnVoiceMailNotify,
DBusClient::callOnIncomingMessage,
DBusClient::callOnIncomingCall,
DBusClient::callOnRecordPlaybackFilepath,
DBusClient::callOnConferenceCreated,
DBusClient::callOnConferenceChanged,
DBusClient::callOnUpdatePlaybackScale,
DBusClient::callOnConferenceRemove,
DBusClient::callOnNewCall,
DBusClient::callOnSipCallStateChange,
DBusClient::callOnRecordStateChange,
DBusClient::callOnSecureSdesOn,
DBusClient::callOnSecureSdesOff,
DBusClient::callOnSecureZrtpOn,
DBusClient::callOnSecureZrtpOff,
DBusClient::callOnShowSas,
DBusClient::callOnZrtpNotSuppOther,
DBusClient::callOnZrtpNegotiationFail,
DBusClient::callOnRtcpReceiveReport,
};
// Configuration event handlers
sflph_config_ev_handlers configEvHandlers = {
DBusClient::configOnVolumeChange,
DBusClient::configOnAccountsChange,
DBusClient::configOnHistoryChange,
DBusClient::configOnStunStatusFail,
DBusClient::configOnRegistrationStateChange,
DBusClient::configOnSipRegistrationStateChange,
DBusClient::configOnError,
};
#ifdef SFL_PRESENCE
// Presence event handlers
sflph_pres_ev_handlers presEvHandlers = {
DBusClient::presOnNewServerSubscriptionRequest,
DBusClient::presOnServerError,
DBusClient::presOnNewBuddyNotification,
DBusClient::presOnSubscriptionStateChange,
};
#endif // SFL_PRESENCE
#ifdef SFL_VIDEO
// Video event handlers
sflph_video_ev_handlers videoEvHandlers = {
DBusClient::videoOnDeviceEvent,
DBusClient::videoOnStartDecoding,
DBusClient::videoOnStopDecoding,
};
#endif // SFL_VIDEO
// All event handlers
sflph_ev_handlers evHandlers;
std::memset(std::addressof(evHandlers), 0, sizeof(evHandlers));
evHandlers.call_ev_handlers = callEvHandlers;
evHandlers.config_ev_handlers = configEvHandlers;
#ifdef SFL_PRESENCE
evHandlers.pres_ev_handlers = presEvHandlers;
#endif // SFL_PRESENCE
#ifdef SFL_VIDEO
evHandlers.video_ev_handlers = videoEvHandlers;
#endif // SFL_VIDEO
// Initialize now
return sflph_init(&evHandlers, static_cast<sflph_init_flag>(sflphFlags));
}
void DBusClient::finiLibrary()
{
sflph_fini();
}
int DBusClient::event_loop()
{
try {
dispatcher_->enter();
} catch (const DBus::Error &err) {
std::cerr << "quitting: " << err.name() << ": " << err.what() << std::endl;
return 1;
} catch (const std::exception &err) {
std::cerr << "quitting: " << err.what() << std::endl;
return 1;
}
return 0;
}
int DBusClient::exit()
{
// Avoid libsflphone events from now on
DBusClient::_lastDbusClient = nullptr;
try {
dispatcher_->leave();
} catch (const DBus::Error &err) {
std::cerr << "quitting: " << err.name() << ": " << err.what() << std::endl;
return 1;
} catch (const std::exception &err) {
std::cerr << "quitting: " << err.what() << std::endl;
return 1;
}
return 0;
}
DBusCallManager* DBusClient::getCallManager()
{
return callManager_;
}
DBusConfigurationManager* DBusClient::getConfigurationManager()
{
return configurationManager_;
}
#ifdef SFL_PRESENCE
DBusPresenceManager* DBusClient::getPresenceManager()
{
return presenceManager_;
}
#endif
#ifdef SFL_VIDEO
DBusVideoManager* DBusClient::getVideoManager()
{
return videoManager_;
}
#endif
void DBusClient::callOnStateChange(const std::string& call_id, const std::string& state)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->callStateChanged(call_id, state);
}
}
void DBusClient::callOnTransferFail(void)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->transferFailed();
}
}
void DBusClient::callOnTransferSuccess(void)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->transferSucceeded();
}
}
void DBusClient::callOnRecordPlaybackStopped(const std::string& path)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->recordPlaybackStopped(path);
}
}
void DBusClient::callOnVoiceMailNotify(const std::string& call_id, int nd_msg)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->voiceMailNotify(call_id, nd_msg);
}
}
void DBusClient::callOnIncomingMessage(const std::string& id, const std::string& from, const std::string& msg)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->incomingMessage(id, from, msg);
}
}
void DBusClient::callOnIncomingCall(const std::string& account_id, const std::string& call_id, const std::string& from)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->incomingCall(account_id, call_id, from);
}
}
void DBusClient::callOnRecordPlaybackFilepath(const std::string& id, const std::string& filename)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->recordPlaybackFilepath(id, filename);
}
}
void DBusClient::callOnConferenceCreated(const std::string& conf_id)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->conferenceCreated(conf_id);
}
}
void DBusClient::callOnConferenceChanged(const std::string& conf_id, const std::string& state)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->conferenceChanged(conf_id, state);
}
}
void DBusClient::callOnUpdatePlaybackScale(const std::string& filepath, int position, int scale)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->updatePlaybackScale(filepath, position, scale);
}
}
void DBusClient::callOnConferenceRemove(const std::string& conf_id)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->conferenceRemoved(conf_id);
}
}
void DBusClient::callOnNewCall(const std::string& account_id, const std::string& call_id, const std::string& to)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->newCallCreated(account_id, call_id, to);
}
}
void DBusClient::callOnSipCallStateChange(const std::string& call_id, const std::string& state, int code)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->sipCallStateChanged(call_id, state, code);
}
}
void DBusClient::callOnRecordStateChange(const std::string& call_id, int state)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->recordingStateChanged(call_id, state);
}
}
void DBusClient::callOnSecureSdesOn(const std::string& call_id)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->secureSdesOn(call_id);
}
}
void DBusClient::callOnSecureSdesOff(const std::string& call_id)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->secureSdesOff(call_id);
}
}
void DBusClient::callOnSecureZrtpOn(const std::string& call_id, const std::string& cipher)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->secureZrtpOn(call_id, cipher);
}
}
void DBusClient::callOnSecureZrtpOff(const std::string& call_id)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->secureZrtpOff(call_id);
}
}
void DBusClient::callOnShowSas(const std::string& call_id, const std::string& sas, int verified)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->showSAS(call_id, sas, verified);
}
}
void DBusClient::callOnZrtpNotSuppOther(const std::string& call_id)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->zrtpNotSuppOther(call_id);
}
}
void DBusClient::callOnZrtpNegotiationFail(const std::string& call_id, const std::string& reason, const std::string& severity)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->zrtpNegotiationFailed(call_id, reason, severity);
}
}
void DBusClient::callOnRtcpReceiveReport(const std::string& call_id, const std::map<std::string, int>& stats)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getCallManager()->onRtcpReportReceived(call_id, stats);
}
}
void DBusClient::configOnVolumeChange(const std::string& device, int value)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getConfigurationManager()->volumeChanged(device, value);
}
}
void DBusClient::configOnAccountsChange(void)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getConfigurationManager()->accountsChanged();
}
}
void DBusClient::configOnHistoryChange(void)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getConfigurationManager()->historyChanged();
}
}
void DBusClient::configOnStunStatusFail(const std::string& account_id)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getConfigurationManager()->stunStatusFailure(account_id);
}
}
void DBusClient::configOnRegistrationStateChange(const std::string& account_id, int state)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getConfigurationManager()->registrationStateChanged(account_id, state);
}
}
void DBusClient::configOnSipRegistrationStateChange(const std::string& account_id, const std::string& state, int code)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getConfigurationManager()->sipRegistrationStateChanged(account_id, state, code);
}
}
void DBusClient::configOnError(int alert)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getConfigurationManager()->errorAlert(alert);
}
}
#ifdef SFL_PRESENCE
void DBusClient::presOnNewServerSubscriptionRequest(const std::string& remote)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getPresenceManager()->newServerSubscriptionRequest(remote);
}
}
void DBusClient::presOnServerError(const std::string& account_id, const std::string& error, const std::string& msg)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getPresenceManager()->serverError(account_id, error, msg);
}
}
void DBusClient::presOnNewBuddyNotification(const std::string& account_id, const std::string& buddy_uri, int status, const std::string& line_status)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getPresenceManager()->newBuddyNotification(account_id, buddy_uri, status, line_status);
}
}
void DBusClient::presOnSubscriptionStateChange(const std::string& account_id, const std::string& buddy_uri, int state)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getPresenceManager()->subscriptionStateChanged(account_id, buddy_uri, state);
}
}
#endif // SFL_PRESENCE
#ifdef SFL_VIDEO
void DBusClient::videoOnDeviceEvent(void)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getVideoManager()->deviceEvent();
}
}
void DBusClient::videoOnStartDecoding(const std::string& id, const std::string& shm_path, int w, int h, bool is_mixer)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getVideoManager()->startedDecoding(id, shm_path, w, h, is_mixer);
}
}
void DBusClient::videoOnStopDecoding(const std::string& id, const std::string& shm_path, bool is_mixer)
{
if (DBusClient::_lastDbusClient) {
DBusClient::_lastDbusClient->getVideoManager()->stoppedDecoding(id, shm_path, is_mixer);
}
}
#endif // SFL_VIDEO
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef __DBUSCLIENT_H__
#define __DBUSCLIENT_H__
#include <sflphone.h>
class DBusConfigurationManager;
class DBusCallManager;
class DBusNetworkManager;
class DBusInstance;
#ifdef SFL_PRESENCE
class DBusPresenceManager;
#endif
#ifdef SFL_VIDEO
class DBusVideoManager;
#endif
namespace DBus {
class BusDispatcher;
}
class DBusClient {
public:
DBusClient(int sflphFlags, bool persistent);
~DBusClient();
DBusCallManager* getCallManager();
DBusConfigurationManager* getConfigurationManager();
#ifdef SFL_PRESENCE
DBusPresenceManager* getPresenceManager();
#endif
#ifdef SFL_VIDEO
DBusVideoManager* getVideoManager();
#endif
int event_loop();
int exit();
private:
int initLibrary(int sflphFlags);
void finiLibrary();
private:
static DBusClient* _lastDbusClient;
static void callOnStateChange(const std::string& call_id, const std::string& state);
static void callOnTransferFail(void);
static void callOnTransferSuccess(void);
static void callOnRecordPlaybackStopped(const std::string& path);
static void callOnVoiceMailNotify(const std::string& call_id, int nd_msg);
static void callOnIncomingMessage(const std::string& id, const std::string& from, const std::string& msg);
static void callOnIncomingCall(const std::string& account_id, const std::string& call_id, const std::string& from);
static void callOnRecordPlaybackFilepath(const std::string& id, const std::string& filename);
static void callOnConferenceCreated(const std::string& conf_id);
static void callOnConferenceChanged(const std::string& conf_id, const std::string& state);
static void callOnUpdatePlaybackScale(const std::string& filepath, int position, int scale);
static void callOnConferenceRemove(const std::string& conf_id);
static void callOnNewCall(const std::string& account_id, const std::string& call_id, const std::string& to);
static void callOnSipCallStateChange(const std::string& call_id, const std::string& state, int code);
static void callOnRecordStateChange(const std::string& call_id, int state);
static void callOnSecureSdesOn(const std::string& call_id);
static void callOnSecureSdesOff(const std::string& call_id);
static void callOnSecureZrtpOn(const std::string& call_id, const std::string& cipher);
static void callOnSecureZrtpOff(const std::string& call_id);
static void callOnShowSas(const std::string& call_id, const std::string& sas, int verified);
static void callOnZrtpNotSuppOther(const std::string& call_id);
static void callOnZrtpNegotiationFail(const std::string& call_id, const std::string& reason, const std::string& severity);
static void callOnRtcpReceiveReport(const std::string& call_id, const std::map<std::string, int>& stats);
static void configOnVolumeChange(const std::string& device, int value);
static void configOnAccountsChange(void);
static void configOnHistoryChange(void);
static void configOnStunStatusFail(const std::string& account_id);
static void configOnRegistrationStateChange(const std::string& account_id, int state);
static void configOnSipRegistrationStateChange(const std::string& account_id, const std::string& state, int code);
static void configOnError(int alert);
#ifdef SFL_PRESENCE
static void presOnNewServerSubscriptionRequest(const std::string& remote);
static void presOnServerError(const std::string& account_id, const std::string& error, const std::string& msg);
static void presOnNewBuddyNotification(const std::string& account_id, const std::string& buddy_uri, int status, const std::string& line_status);
static void presOnSubscriptionStateChange(const std::string& account_id, const std::string& buddy_uri, int state);
#endif // SFL_PRESENCE
#ifdef SFL_VIDEO
static void videoOnDeviceEvent(void);
static void videoOnStartDecoding(const std::string& id, const std::string& shm_path, int w, int h, bool is_mixer);
static void videoOnStopDecoding(const std::string& id, const std::string& shm_path, bool is_mixer);
#endif // SFL_VIDEO
private:
DBusCallManager* callManager_;
DBusConfigurationManager* configurationManager_;
#ifdef SFL_PRESENCE
DBusPresenceManager* presenceManager_;
#endif
DBusInstance* instanceManager_;
DBus::BusDispatcher* dispatcher_;
#ifdef SFL_VIDEO
DBusVideoManager *videoManager_;
#endif
};
#endif
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
* Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include <iostream>
#include <sflphone.h>
#include "dbusconfigurationmanager.h"
DBusConfigurationManager::DBusConfigurationManager(DBus::Connection& connection)
: DBus::ObjectAdaptor(connection, "/org/sflphone/SFLphone/ConfigurationManager")
{
}
std::map<std::string, std::string> DBusConfigurationManager::getAccountDetails(const std::string& accountID)
{
return sflph_config_get_account_details(accountID);
}
void DBusConfigurationManager::setAccountDetails(const std::string& accountID, const std::map< std::string, std::string >& details)
{
sflph_config_set_account_details(accountID, details);
}
std::map<std::string, std::string> DBusConfigurationManager::getAccountTemplate()
{
return sflph_config_get_account_template();
}
std::string DBusConfigurationManager::addAccount(const std::map< std::string, std::string >& details)
{
return sflph_config_add_account(details);
}
void DBusConfigurationManager::removeAccount(const std::string& accountID)
{
sflph_config_remove_account(accountID);
}
std::vector< std::string > DBusConfigurationManager::getAccountList()
{
return sflph_config_get_account_list();
}
void DBusConfigurationManager::sendRegister(const std::string& accountID, const bool& enable)
{
sflph_config_send_register(accountID, enable);
}
void DBusConfigurationManager::registerAllAccounts(void)
{
sflph_config_register_all_accounts();
}
std::map< std::string, std::string > DBusConfigurationManager::getTlsSettingsDefault()
{
return sflph_config_get_tls_default_settings();
}
std::vector< int32_t > DBusConfigurationManager::getAudioCodecList()
{
return sflph_config_get_audio_codec_list();
}
std::vector< std::string > DBusConfigurationManager::getSupportedTlsMethod()
{
return sflph_config_get_supported_tls_method();
}
std::vector< std::string > DBusConfigurationManager::getAudioCodecDetails(const int32_t& payload)
{
return sflph_config_get_audio_codec_details(payload);
}
std::vector< int32_t > DBusConfigurationManager::getActiveAudioCodecList(const std::string& accountID)
{
return sflph_config_get_active_audio_codec_list(accountID);
}
void DBusConfigurationManager::setActiveAudioCodecList(const std::vector< std::string >& list, const std::string& accountID)
{
sflph_config_set_active_audio_codec_list(list, accountID);
}
std::vector< std::string > DBusConfigurationManager::getAudioPluginList()
{
return sflph_config_get_audio_plugin_list();
}
void DBusConfigurationManager::setAudioPlugin(const std::string& audioPlugin)
{
sflph_config_set_audio_plugin(audioPlugin);
}
std::vector< std::string > DBusConfigurationManager::getAudioOutputDeviceList()
{
return sflph_config_get_audio_output_device_list();
}
void DBusConfigurationManager::setAudioOutputDevice(const int32_t& index)
{
sflph_config_set_audio_output_device(index);
}
void DBusConfigurationManager::setAudioInputDevice(const int32_t& index)
{
sflph_config_set_audio_input_device(index);
}
void DBusConfigurationManager::setAudioRingtoneDevice(const int32_t& index)
{
sflph_config_set_audio_ringtone_device(index);
}
std::vector< std::string > DBusConfigurationManager::getAudioInputDeviceList()
{
return sflph_config_get_audio_input_device_list();
}
std::vector< std::string > DBusConfigurationManager::getCurrentAudioDevicesIndex()
{
return sflph_config_get_current_audio_devices_index();
}
int32_t DBusConfigurationManager::getAudioInputDeviceIndex(const std::string& name)
{
return sflph_config_get_audio_input_device_index(name);
}
int32_t DBusConfigurationManager::getAudioOutputDeviceIndex(const std::string& name)
{
return sflph_config_get_audio_output_device_index(name);
}
std::string DBusConfigurationManager::getCurrentAudioOutputPlugin()
{
return sflph_config_get_current_audio_output_plugin();
}
bool DBusConfigurationManager::getNoiseSuppressState()
{
return sflph_config_get_noise_suppress_state();
}
void DBusConfigurationManager::setNoiseSuppressState(const bool& state)
{
sflph_config_set_noise_suppress_state(state);
}
bool DBusConfigurationManager::isAgcEnabled()
{
return sflph_config_is_agc_enabled();
}
void DBusConfigurationManager::setAgcState(const bool& enabled)
{
sflph_config_enable_agc(enabled);
}
void DBusConfigurationManager::muteDtmf(const bool& mute)
{
sflph_config_mute_dtmf(mute);
}
bool DBusConfigurationManager::isDtmfMuted()
{
return sflph_config_is_dtmf_muted();
}
bool DBusConfigurationManager::isCaptureMuted()
{
return sflph_config_is_capture_muted();
}
void DBusConfigurationManager::muteCapture(const bool& mute)
{
sflph_config_mute_capture(mute);
}
bool DBusConfigurationManager::isPlaybackMuted()
{
return sflph_config_is_playback_muted();
}
void DBusConfigurationManager::mutePlayback(const bool& mute)
{
sflph_config_mute_playback(mute);
}
std::map<std::string, std::string> DBusConfigurationManager::getRingtoneList()
{
return sflph_config_get_ringtone_list();
}
std::string DBusConfigurationManager::getAudioManager()
{
return sflph_config_get_audio_manager();
}
bool DBusConfigurationManager::setAudioManager(const std::string& api)
{
return sflph_config_set_audio_manager(api);
}
std::vector<std::string> DBusConfigurationManager::getSupportedAudioManagers()
{
return sflph_config_get_supported_audio_managers();
}
int32_t DBusConfigurationManager::isIax2Enabled()
{
return sflph_config_is_iax2_enabled();
}
std::string DBusConfigurationManager::getRecordPath()
{
return sflph_config_get_record_path();
}
void DBusConfigurationManager::setRecordPath(const std::string& recPath)
{
sflph_config_set_record_path(recPath);
}
bool DBusConfigurationManager::getIsAlwaysRecording()
{
return sflph_config_is_always_recording();
}
void DBusConfigurationManager::setIsAlwaysRecording(const bool& rec)
{
sflph_config_set_always_recording(rec);
}
void DBusConfigurationManager::setHistoryLimit(const int32_t& days)
{
sflph_config_set_history_limit(days);
}
int32_t DBusConfigurationManager::getHistoryLimit()
{
return sflph_config_get_history_limit();
}
void DBusConfigurationManager::clearHistory()
{
sflph_config_clear_history();
}
void DBusConfigurationManager::setAccountsOrder(const std::string& order)
{
sflph_config_set_accounts_order(order);
}
std::map<std::string, std::string> DBusConfigurationManager::getHookSettings()
{
return sflph_config_get_hook_settings();
}
void DBusConfigurationManager::setHookSettings(const std::map<std::string, std::string>& settings)
{
sflph_config_set_hook_settings(settings);
}
std::vector<std::map<std::string, std::string> > DBusConfigurationManager::getHistory()
{
return sflph_config_get_history();
}
std::map<std::string, std::string> DBusConfigurationManager::getTlsSettings()
{
return sflph_config_get_tls_settings();
}
void DBusConfigurationManager::setTlsSettings(const std::map< std::string, std::string >& details)
{
sflph_config_set_tls_settings(details);
}
std::map< std::string, std::string > DBusConfigurationManager::getIp2IpDetails()
{
return sflph_config_get_ip2ip_details();
}
std::vector< std::map< std::string, std::string > > DBusConfigurationManager::getCredentials(const std::string& accountID)
{
return sflph_config_get_credentials(accountID);
}
void DBusConfigurationManager::setCredentials(const std::string& accountID, const std::vector< std::map< std::string, std::string > >& details)
{
sflph_config_set_credentials(accountID, details);
}
std::string DBusConfigurationManager::getAddrFromInterfaceName(const std::string& interface)
{
return sflph_config_get_addr_from_interface_name(interface);
}
std::vector<std::string> DBusConfigurationManager::getAllIpInterface()
{
return sflph_config_get_all_ip_interface();
}
std::vector<std::string> DBusConfigurationManager::getAllIpInterfaceByName()
{
return sflph_config_get_all_ip_interface_by_name();
}
std::map<std::string, std::string> DBusConfigurationManager::getShortcuts()
{
return sflph_config_get_shortcuts();
}
void DBusConfigurationManager::setShortcuts(const std::map<std::string, std::string> &shortcutsMap)
{
sflph_config_set_shortcuts(shortcutsMap);
}
void DBusConfigurationManager::setVolume(const std::string& device, const double& value)
{
sflph_config_set_volume(device, value);
}
double DBusConfigurationManager::getVolume(const std::string& device)
{
return sflph_config_get_volume(device);
}
bool DBusConfigurationManager::checkForPrivateKey(const std::string& pemPath)
{
return sflph_config_check_for_private_key(pemPath);
}
bool DBusConfigurationManager::checkCertificateValidity(const std::string& caPath, const std::string& pemPath)
{
return sflph_config_check_certificate_validity(caPath, pemPath);
}
bool DBusConfigurationManager::checkHostnameCertificate(const std::string& host, const std::string& port)
{
return sflph_config_check_hostname_certificate(host, port);
}
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
* Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef __SFL_DBUSCONFIGURATIONMANAGER_H__
#define __SFL_DBUSCONFIGURATIONMANAGER_H__
#include <vector>
#include <map>
#include <string>
#include "dbus_cpp.h"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include "dbusconfigurationmanager.adaptor.h"
#pragma GCC diagnostic warning "-Wignored-qualifiers"
#pragma GCC diagnostic warning "-Wunused-parameter"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif
#include <stdexcept>
class DBusConfigurationManager :
public org::sflphone::SFLphone::ConfigurationManager_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor
{
public:
DBusConfigurationManager(DBus::Connection& connection);
// Methods
std::map< std::string, std::string > getAccountDetails(const std::string& accountID);
void setAccountDetails(const std::string& accountID, const std::map< std::string, std::string >& details);
std::map<std::string, std::string> getAccountTemplate();
std::string addAccount(const std::map< std::string, std::string >& details);
void removeAccount(const std::string& accoundID);
std::vector< std::string > getAccountList();
void sendRegister(const std::string& accoundID, const bool& enable);
void registerAllAccounts(void);
std::map< std::string, std::string > getTlsSettingsDefault();
std::vector< int32_t > getAudioCodecList();
std::vector< std::string > getSupportedTlsMethod();
std::vector< std::string > getAudioCodecDetails(const int32_t& payload);
std::vector< int32_t > getActiveAudioCodecList(const std::string& accountID);
void setActiveAudioCodecList(const std::vector< std::string >& list, const std::string& accountID);
std::vector< std::string > getAudioPluginList();
void setAudioPlugin(const std::string& audioPlugin);
std::vector< std::string > getAudioOutputDeviceList();
void setAudioOutputDevice(const int32_t& index);
void setAudioInputDevice(const int32_t& index);
void setAudioRingtoneDevice(const int32_t& index);
std::vector< std::string > getAudioInputDeviceList();
std::vector< std::string > getCurrentAudioDevicesIndex();
int32_t getAudioInputDeviceIndex(const std::string& name);
int32_t getAudioOutputDeviceIndex(const std::string& name);
std::string getCurrentAudioOutputPlugin();
bool getNoiseSuppressState();
void setNoiseSuppressState(const bool& state);
bool isAgcEnabled();
void setAgcState(const bool& enabled);
void muteDtmf(const bool& mute);
bool isDtmfMuted();
bool isCaptureMuted();
void muteCapture(const bool& mute);
bool isPlaybackMuted();
void mutePlayback(const bool& mute);
std::map<std::string, std::string> getRingtoneList();
std::string getAudioManager();
bool setAudioManager(const std::string& api);
std::vector<std::string> getSupportedAudioManagers();
int32_t isIax2Enabled();
std::string getRecordPath();
void setRecordPath(const std::string& recPath);
bool getIsAlwaysRecording();
void setIsAlwaysRecording(const bool& rec);
void setHistoryLimit(const int32_t& days);
int32_t getHistoryLimit();
void clearHistory();
void setAccountsOrder(const std::string& order);
std::map<std::string, std::string> getHookSettings();
void setHookSettings(const std::map<std::string, std::string>& settings);
std::vector<std::map<std::string, std::string> > getHistory();
std::map<std::string, std::string> getTlsSettings();
void setTlsSettings(const std::map< std::string, std::string >& details);
std::map< std::string, std::string > getIp2IpDetails();
std::vector< std::map< std::string, std::string > > getCredentials(const std::string& accountID);
void setCredentials(const std::string& accountID, const std::vector< std::map< std::string, std::string > >& details);
std::string getAddrFromInterfaceName(const std::string& interface);
std::vector<std::string> getAllIpInterface();
std::vector<std::string> getAllIpInterfaceByName();
std::map<std::string, std::string> getShortcuts();
void setShortcuts(const std::map<std::string, std::string> &shortcutsMap);
void setVolume(const std::string& device, const double& value);
double getVolume(const std::string& device);
bool checkForPrivateKey(const std::string& pemPath);
bool checkCertificateValidity(const std::string& caPath, const std::string& pemPath);
bool checkHostnameCertificate(const std::string& host, const std::string& port);
};
#endif // __SFL_DBUSCONFIGURATIONMANAGER_H__
......@@ -28,27 +28,29 @@
* as that of the covered work.
*/
#include "global.h"
#include "instance.h"
#include "../manager.h"
#include "dbusinstance.h"
Instance::Instance(DBus::Connection& connection) :
DBusInstance::DBusInstance(DBus::Connection& connection,
const OnNoMoreClientFunc& onNoMoreClientFunc) :
DBus::ObjectAdaptor(connection, "/org/sflphone/SFLphone/Instance"),
count(0)
onNoMoreClientFunc_(onNoMoreClientFunc),
count_(0)
{}
void
Instance::Register(const int32_t& pid UNUSED,
const std::string& name UNUSED)
DBusInstance::Register(const int32_t& pid UNUSED,
const std::string& name UNUSED)
{
++count;
++count_;
}
void
Instance::Unregister(const int32_t& pid UNUSED)
DBusInstance::Unregister(const int32_t& pid UNUSED)
{
--count;
--count_;
if (count <= 0)
Manager::instance().getClient()->onLastUnregister();
if (count_ <= 0 && onNoMoreClientFunc_) {
onNoMoreClientFunc_();
}
}
......@@ -28,8 +28,10 @@
* as that of the covered work.
*/
#ifndef INSTANCE_H
#define INSTANCE_H
#ifndef __SFL_DBUSINSTANCE_H__
#define __SFL_DBUSINSTANCE_H__
#include <functional>
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
......@@ -38,28 +40,31 @@
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include "instance-glue.h"
#include "dbusinstance.adaptor.h"
#pragma GCC diagnostic warning "-Wignored-qualifiers"
#pragma GCC diagnostic warning "-Wunused-parameter"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
#pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif
class Instance
: public org::sflphone::SFLphone::Instance_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor {
private:
int count;
class DBusInstance :
public org::sflphone::SFLphone::Instance_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor
{
public:
typedef std::function<void ()> OnNoMoreClientFunc;
public:
Instance(DBus::Connection& connection);
static const char* SERVER_PATH;
DBusInstance(DBus::Connection& connection,
const OnNoMoreClientFunc& onNoMoreClientFunc);
void Register(const int32_t& pid, const std::string& name);
void Unregister(const int32_t& pid);
int32_t getRegistrationCount();
private:
OnNoMoreClientFunc onNoMoreClientFunc_;
int count_;
};
#endif // INSTANCE_H
#endif // __SFL_DBUSINSTANCE_H__
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
* Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com>
* Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -27,37 +27,36 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include <sflphone.h>
#include "networkmanager.h"
#include "../manager.h"
#include "array_size.h"
#include "logger.h"
#include "dbuspresencemanager.h"
static const
char *stateAsString(uint32_t state)
DBusPresenceManager::DBusPresenceManager(DBus::Connection& connection)
: DBus::ObjectAdaptor(connection, "/org/sflphone/SFLphone/PresenceManager")
{
static const char * STATES[] = {"unknown", "asleep", "connecting",
"connected", "disconnected"};
}
const size_t idx = state < ARRAYSIZE(STATES) ? state : 0;
return STATES[idx];
void DBusPresenceManager::publish(const std::string& accountID, const bool& status, const std::string& note)
{
sflph_pres_publish(accountID, status, note);
}
void NetworkManager::StateChanged(const uint32_t &state)
void DBusPresenceManager::answerServerRequest(const std::string& uri, const bool& flag)
{
WARN("Network state changed: %s", stateAsString(state));
sflph_pres_answer_server_request(uri, flag);
}
void NetworkManager::PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0)
void DBusPresenceManager::subscribeBuddy(const std::string& accountID, const std::string& uri, const bool& flag)
{
WARN("Properties changed: ");
for (const auto &item : argin0)
WARN("%s", item.first.c_str());
Manager::instance().registerAccounts();
sflph_pres_subscribe_buddy(accountID, uri, flag);
}
NetworkManager::NetworkManager(DBus::Connection &connection,
const DBus::Path &dbus_path,
const char *destination) :
DBus::ObjectProxy(connection, dbus_path, destination)
{}
std::vector<std::map<std::string, std::string> > DBusPresenceManager::getSubscriptions(const std::string& accountID)
{
return sflph_pres_get_subscriptions(accountID);
}
void DBusPresenceManager::setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris)
{
sflph_pres_set_subscriptions(accountID, uris);
}
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
* Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com>
* Copyright (C) 2013 Savoir-Faire Linux Inc.
* Author: Patrick Keroulas <patrick.keroulas@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -28,22 +28,47 @@
* as that of the covered work.
*/
#ifndef NETWORKMANAGER_H_
#define NETWORKMANAGER_H_
#ifndef __SFL_DBUSPRESENCEMANAGER_H__
#define __SFL_DBUSPRESENCEMANAGER_H__
#include <vector>
#include <map>
#include <string>
#include "dbus_cpp.h"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include "networkmanager_proxy.h"
#include "dbuspresencemanager.adaptor.h"
#pragma GCC diagnostic warning "-Wignored-qualifiers"
#pragma GCC diagnostic warning "-Wunused-parameter"
class NetworkManager : public org::freedesktop::NetworkManager_proxy,
public DBus::IntrospectableProxy,
// cppcheck-suppress unusedFunction
public DBus::ObjectProxy {
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif
#include <stdexcept>
class DBusPresenceManager :
public org::sflphone::SFLphone::PresenceManager_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor
{
public:
NetworkManager(DBus::Connection &, const DBus::Path &, const char*);
void StateChanged(const uint32_t &state);
void PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0);
DBusPresenceManager(DBus::Connection& connection);
// Methods
void publish(const std::string& accountID, const bool& status, const std::string& note);
void answerServerRequest(const std::string& uri, const bool& flag);
void subscribeBuddy(const std::string& accountID, const std::string& uri, const bool& flag);
std::vector<std::map<std::string, std::string> > getSubscriptions(const std::string& accountID);
void setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris);
};
#endif
#endif // __SFL_DBUSPRESENCEMANAGER_H__
/*
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com>
* Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -29,28 +27,76 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include <sflphone.h>
#include "configurationmanager.h"
#include "global.h"
static const char* SERVER_PATH = "/org/sflphone/SFLphone/ConfigurationManager";
ConfigurationManager::ConfigurationManager(DBus::Connection& connection) :
DBus::ObjectAdaptor(connection, SERVER_PATH)
{}
std::vector<std::string>
ConfigurationManager::getSupportedAudioManagers()
{
return {
#if HAVE_ALSA
ALSA_API_STR,
#endif
#if HAVE_PULSE
PULSEAUDIO_API_STR,
#endif
#if HAVE_JACK
JACK_API_STR,
#endif
};
#include "dbusvideomanager.h"
DBusVideoManager::DBusVideoManager(DBus::Connection& connection)
: DBus::ObjectAdaptor(connection, "/org/sflphone/SFLphone/VideoManager")
{
}
std::vector<std::map<std::string, std::string>> DBusVideoManager::getCodecs(const std::string& accountID)
{
return sflph_video_get_codecs(accountID);
}
void DBusVideoManager::setCodecs(const std::string& accountID, const std::vector<std::map<std::string, std::string> > &details)
{
sflph_video_set_codecs(accountID, details);
}
std::vector<std::string> DBusVideoManager::getDeviceList()
{
return sflph_video_get_device_list();
}
std::map<std::string, std::map<std::string, std::vector<std::string>>> DBusVideoManager::getCapabilities(const std::string& name)
{
return sflph_video_get_capabilities(name);
}
std::map<std::string, std::string> DBusVideoManager::getSettings(const std::string& name)
{
return sflph_video_get_settings(name);
}
void DBusVideoManager::applySettings(const std::string& name, const std::map<std::string, std::string>& settings)
{
sflph_video_apply_settings(name, settings);
}
void DBusVideoManager::setDefaultDevice(const std::string &dev)
{
sflph_video_set_default_device(dev);
}
std::string DBusVideoManager::getDefaultDevice()
{
return sflph_video_get_default_device();
}
std::string DBusVideoManager::getCurrentCodecName(const std::string &callID)
{
return sflph_video_get_current_codec_name(callID);
}
void DBusVideoManager::startCamera()
{
sflph_video_start_camera();
}
void DBusVideoManager::stopCamera()
{
sflph_video_stop_camera();
}
bool DBusVideoManager::switchInput(const std::string& resource)
{
return sflph_video_switch_input(resource);
}
bool DBusVideoManager::hasCameraStarted()
{
return sflph_video_is_camera_started();
}
/*
* Copyright (C) 2013 Savoir-Faire Linux Inc.
* Author: Patrick Keroulas <patrick.keroulas@savoirfairelinux.com>
* Copyright (C) 2012-2013 Savoir-Faire Linux Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -28,61 +27,55 @@
* as that of the covered work.
*/
#warning Using a stub file will produce a non working application
#ifndef __SFL_DBUSVIDEOMANAGER_H__
#define __SFL_DBUSVIDEOMANAGER_H__
#include "client/videomanager.h"
#include <vector>
#include <map>
#include <string>
VideoManager::VideoManager()
{}
#include "dbus_cpp.h"
VideoDeviceMonitor& VideoManager::getVideoDeviceMonitor()
{
}
void VideoManager::deviceEvent()
{
}
void VideoManager::startedDecoding(const std::string &id, const std::string,
int w, int h)
{
}
void VideoManager::stoppedDecoding(const std::string &id, const std::string)
{
}
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
VideoCapabilities
VideoManager::getCapabilities(const std::string& name);
{
return VideoCapabilities();
}
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include "dbusvideomanager.adaptor.h"
#pragma GCC diagnostic warning "-Wignored-qualifiers"
#pragma GCC diagnostic warning "-Wunused-parameter"
std::map<std::string, std::string> VideoManager::getSettings(const std::string& name)
{
return std::map<std::string, std::string>();
}
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif
void
VideoManager::applySettings(const std::string& name,
std::map<std::string, std::string> settings)
{
}
#include <stdexcept>
bool VideoManager::hasCameraStarted()
class DBusVideoManager :
public org::sflphone::SFLphone::VideoManager_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor
{
return false;
}
public:
DBusVideoManager(DBus::Connection& connection);
void VideoManager::startCamera()
{
}
// Methods
std::vector<std::map<std::string, std::string>> getCodecs(const std::string& accountID);
void setCodecs(const std::string& accountID, const std::vector<std::map<std::string, std::string> > &details);
std::vector<std::string> getDeviceList();
std::map<std::string, std::map<std::string, std::vector<std::string>>> getCapabilities(const std::string& name);
std::map<std::string, std::string> getSettings(const std::string& name);
void applySettings(const std::string& name, const std::map<std::string, std::string>& settings);
void setDefaultDevice(const std::string &dev);
std::string getDefaultDevice();
std::string getCurrentCodecName(const std::string &callID);
void startCamera();
void stopCamera();
bool switchInput(const std::string& resource);
bool hasCameraStarted();
};
void VideoManager::stopCamera()
{
}
std::weak_ptr<sfl_video::VideoFrameActiveWriter> VideoManager::getVideoCamera()
{
return std::weak_ptr<sfl_video::VideoFrameActiveWriter>();
}
#endif // __SFL_DBUSVIDEOMANAGER_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment