Commit 36a2a7bd authored by Philippe Proulx's avatar Philippe Proulx Committed by Tristan Matthews

Librarize daemon and create daemon app

Refs:# 48032
parent ae4131cb
......@@ -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
......
/*
* 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);