Commit 0bed27ff authored by Adrien Béraud's avatar Adrien Béraud

Rename DHTAccount to RingAccount

Refs #59537

Change-Id: Id43bd63dc93c08bcab202437957e66cae9e36554
parent 800e545a
......@@ -600,8 +600,8 @@ AC_CONFIG_FILES([Makefile \
src/sip/Makefile \
src/im/Makefile \
src/iax/Makefile \
src/dht/Makefile \
src/dht/dhtcpp/Makefile \
src/ringdht/Makefile \
src/ringdht/dhtcpp/Makefile \
src/audio/Makefile \
src/audio/audiortp/Makefile \
src/audio/pulseaudio/Makefile \
......
......@@ -21,9 +21,9 @@ IAX_LIB=-liax
endif
if USE_DHT
DHT_SUBDIR=dht
DHT_CXXFLAG=-DUSE_DHT
DHT_LIBA=./dht/libdht.la
RINGACC_SUBDIR=ringdht
RINGACC_CXXFLAG=-DUSE_DHT
RINGACC_LIBA=./ringdht/libringacc.la
endif
if USE_NETWORKMANAGER
......@@ -35,7 +35,7 @@ TLS_LIB = @GNUTLS_LIBS@
TLS_CFLAGS = @GNUTLS_CFLAGS@
endif
SUBDIRS = client audio config hooks history sip $(IAX_SUBDIR) $(DHT_SUBDIR) $(INSTANT_MESSAGING_SUBDIR) $(SFL_VIDEO_SUBDIR)
SUBDIRS = client audio config hooks history sip $(IAX_SUBDIR) $(RINGACC_SUBDIR) $(INSTANT_MESSAGING_SUBDIR) $(SFL_VIDEO_SUBDIR)
# libsflphone
......@@ -48,7 +48,7 @@ libsflphone_la_LIBADD = \
./config/libconfig.la \
./hooks/libhooks.la \
./history/libhistory.la \
$(DHT_LIBA) \
$(RINGACC_LIBA) \
$(IAX_LIBA) \
$(IM_LIBA) \
$(SFL_VIDEO_LIBS)
......
......@@ -39,7 +39,7 @@
#include "iax/iaxaccount.h"
#endif
#if HAVE_DHT
#include "dht/dhtaccount.h"
#include "ringdht/ringaccount.h"
#endif
#include "sip/sipvoiplink.h" // for SIPVoIPLink::loadIP2IPSettings
......@@ -59,9 +59,9 @@ AccountFactory::AccountFactory()
SFL_DBG("registered %s account", IAXAccount::ACCOUNT_TYPE);
#endif
#if HAVE_DHT
auto dhtfunc = [](const std::string& id){ return std::make_shared<DHTAccount>(id, false); };
generators_.insert(std::make_pair(DHTAccount::ACCOUNT_TYPE, dhtfunc));
SFL_DBG("registered %s account", DHTAccount::ACCOUNT_TYPE);
auto dhtfunc = [](const std::string& id){ return std::make_shared<RingAccount>(id, false); };
generators_.insert(std::make_pair(RingAccount::ACCOUNT_TYPE, dhtfunc));
SFL_DBG("registered %s account", RingAccount::ACCOUNT_TYPE);
#endif
}
......
......@@ -47,7 +47,7 @@
#include "map_utils.h"
#include "account.h"
#if HAVE_DHT
#include "dht/dhtaccount.h"
#include "ringdht/ringaccount.h"
#endif
#include "call_factory.h"
......@@ -2766,9 +2766,9 @@ ManagerImpl::newOutgoingCall(const std::string& id,
std::string finalToUrl = toUrl;
#if HAVE_DHT
if (toUrl.find("dht:") != std::string::npos) {
SFL_WARN("DHT call detected");
auto dhtAcc = getAllAccounts<DHTAccount>();
if (toUrl.find("ring:") != std::string::npos) {
SFL_WARN("Ring DHT call detected");
auto dhtAcc = getAllAccounts<RingAccount>();
if (not dhtAcc.empty())
return dhtAcc.front()->newOutgoingCall(id, finalToUrl);
}
......
......@@ -2,16 +2,16 @@ include $(top_srcdir)/globals.mak
if USE_DHT
noinst_LTLIBRARIES = libdht.la
libdht_la_CXXFLAGS = @CXXFLAGS@
noinst_LTLIBRARIES = libringacc.la
libringacc_la_CXXFLAGS = @CXXFLAGS@
SUBDIRS = dhtcpp
libdht_la_LIBADD = \
libringacc_la_LIBADD = \
dhtcpp/libdhtcpp.la
libdht_la_SOURCES = \
dhtaccount.cpp \
dhtaccount.h
libringacc_la_SOURCES = \
ringaccount.cpp \
ringaccount.h
endif
......@@ -29,7 +29,7 @@
* as that of the covered work.
*/
#include "dhtaccount.h"
#include "ringaccount.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
......@@ -72,9 +72,9 @@
#include <sstream>
#include <cstdlib>
constexpr const char * const DHTAccount::ACCOUNT_TYPE;
constexpr const char * const RingAccount::ACCOUNT_TYPE;
DHTAccount::DHTAccount(const std::string& accountID, bool /* presenceEnabled */)
RingAccount::RingAccount(const std::string& accountID, bool /* presenceEnabled */)
: SIPAccountBase(accountID)
{
fileutils::check_dir(fileutils::get_cache_dir().c_str());
......@@ -96,7 +96,7 @@ DHTAccount::DHTAccount(const std::string& accountID, bool /* presenceEnabled */)
}
}
DHTAccount::~DHTAccount()
RingAccount::~RingAccount()
{
Manager::instance().unregisterEventHandler((uintptr_t)this);
setTransport();
......@@ -105,18 +105,18 @@ DHTAccount::~DHTAccount()
}
std::shared_ptr<SIPCall>
DHTAccount::newIncomingCall(const std::string& id)
RingAccount::newIncomingCall(const std::string& id)
{
return Manager::instance().callFactory.newCall<SIPCall, DHTAccount>(*this, id, Call::INCOMING);
return Manager::instance().callFactory.newCall<SIPCall, RingAccount>(*this, id, Call::INCOMING);
}
template <>
std::shared_ptr<SIPCall>
DHTAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
RingAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
{
auto call = Manager::instance().callFactory.newCall<SIPCall, DHTAccount>(*this, id, Call::OUTGOING);
auto dhtf = toUrl.find("dht:");
dhtf = (dhtf == std::string::npos) ? 0 : dhtf+4;
auto call = Manager::instance().callFactory.newCall<SIPCall, RingAccount>(*this, id, Call::OUTGOING);
auto dhtf = toUrl.find("ring:");
dhtf = (dhtf == std::string::npos) ? 0 : dhtf+5;
const std::string toUri = toUrl.substr(dhtf, 40);
SFL_DBG("Calling DHT peer %s", toUri.c_str());
call->setIPToIP(true);
......@@ -154,9 +154,9 @@ DHTAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
}
void
DHTAccount::createOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::string& to, const std::string& toUri, const IpAddr& peer)
RingAccount::createOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::string& to, const std::string& toUri, const IpAddr& peer)
{
SFL_WARN("DHTAccount::createOutgoingCall to: %s toUri: %s tlsListener: %d", to.c_str(), toUri.c_str(), tlsListener_?1:0);
SFL_WARN("RingAccount::createOutgoingCall to: %s toUri: %s tlsListener: %d", to.c_str(), toUri.c_str(), tlsListener_?1:0);
std::shared_ptr<SipTransport> t = link_->sipTransport->getTlsTransport(tlsListener_, getToUri(peer.toString(true, true)));
setTransport(t);
call->setTransport(t);
......@@ -209,13 +209,13 @@ DHTAccount::createOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
}
std::shared_ptr<Call>
DHTAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
RingAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
{
return newOutgoingCall<SIPCall>(id, toUrl);
}
bool
DHTAccount::SIPStartCall(const std::shared_ptr<SIPCall>& call)
RingAccount::SIPStartCall(const std::shared_ptr<SIPCall>& call)
{
std::string toUri(call->getPeerNumber()); // expecting a fully well formed sip uri
......@@ -293,7 +293,7 @@ DHTAccount::SIPStartCall(const std::shared_ptr<SIPCall>& call)
return true;
}
void DHTAccount::serialize(YAML::Emitter &out)
void RingAccount::serialize(YAML::Emitter &out)
{
using namespace Conf;
......@@ -312,7 +312,7 @@ void DHTAccount::serialize(YAML::Emitter &out)
out << YAML::EndMap;
}
void DHTAccount::unserialize(const YAML::Node &node)
void RingAccount::unserialize(const YAML::Node &node)
{
using namespace yaml_utils;
SIPAccountBase::unserialize(node);
......@@ -326,7 +326,7 @@ void DHTAccount::unserialize(const YAML::Node &node)
}
void
DHTAccount::checkIdentityPath()
RingAccount::checkIdentityPath()
{
if (not privkeyPath_.empty() and not dataPath_.empty())
return;
......@@ -367,7 +367,7 @@ saveFile(const std::string& path, const std::vector<uint8_t>& data)
}
dht::crypto::Identity
DHTAccount::loadIdentity()
RingAccount::loadIdentity()
{
dht::crypto::Certificate ca_cert;
......@@ -406,7 +406,7 @@ DHTAccount::loadIdentity()
}
void
DHTAccount::saveIdentity(const dht::crypto::Identity id, const std::string& path) const
RingAccount::saveIdentity(const dht::crypto::Identity id, const std::string& path) const
{
if (id.first)
fileutils::saveFile(path + ".pem", id.first->serialize());
......@@ -426,7 +426,7 @@ parseInt(const std::map<std::string, std::string> &details, const char *key, T &
i = atoi(iter->second.c_str());
}
void DHTAccount::setAccountDetails(const std::map<std::string, std::string> &details)
void RingAccount::setAccountDetails(const std::map<std::string, std::string> &details)
{
SIPAccountBase::setAccountDetails(details);
parseInt(details, CONFIG_DHT_PORT, dhtPort_);
......@@ -437,7 +437,7 @@ void DHTAccount::setAccountDetails(const std::map<std::string, std::string> &det
checkIdentityPath();
}
std::map<std::string, std::string> DHTAccount::getAccountDetails() const
std::map<std::string, std::string> RingAccount::getAccountDetails() const
{
std::map<std::string, std::string> a = SIPAccountBase::getAccountDetails();
......@@ -449,7 +449,7 @@ std::map<std::string, std::string> DHTAccount::getAccountDetails() const
return a;
}
void DHTAccount::doRegister()
void RingAccount::doRegister()
{
if (not isEnabled()) {
SFL_WARN("Account must be enabled to register, ignoring");
......@@ -520,7 +520,7 @@ void DHTAccount::doRegister()
}
void DHTAccount::doUnregister(std::function<void(bool)> released_cb)
void RingAccount::doUnregister(std::function<void(bool)> released_cb)
{
Manager::instance().unregisterEventHandler((uintptr_t)this);
saveNodes(dht_.exportNodes());
......@@ -532,7 +532,7 @@ void DHTAccount::doUnregister(std::function<void(bool)> released_cb)
released_cb(false);
}
void DHTAccount::saveNodes(const std::vector<dht::Dht::NodeExport>& nodes) const
void RingAccount::saveNodes(const std::vector<dht::Dht::NodeExport>& nodes) const
{
if (nodes.empty())
return;
......@@ -549,7 +549,7 @@ void DHTAccount::saveNodes(const std::vector<dht::Dht::NodeExport>& nodes) const
}
}
void DHTAccount::saveValues(const std::vector<dht::Dht::ValuesExport>& values) const
void RingAccount::saveValues(const std::vector<dht::Dht::ValuesExport>& values) const
{
fileutils::check_dir(dataPath_.c_str());
for (const auto& v : values) {
......@@ -560,7 +560,7 @@ void DHTAccount::saveValues(const std::vector<dht::Dht::ValuesExport>& values) c
}
std::vector<dht::Dht::NodeExport>
DHTAccount::loadNodes() const
RingAccount::loadNodes() const
{
std::vector<dht::Dht::NodeExport> nodes;
std::string nodesPath = nodePath_+DIR_SEPARATOR_STR "nodes";
......@@ -585,7 +585,7 @@ DHTAccount::loadNodes() const
}
std::vector<dht::Dht::ValuesExport>
DHTAccount::loadValues() const
RingAccount::loadValues() const
{
std::vector<dht::Dht::ValuesExport> values;
const auto dircontent(fileutils::readDirectory(dataPath_));
......@@ -602,7 +602,7 @@ DHTAccount::loadValues() const
return values;
}
void DHTAccount::initTlsConfiguration()
void RingAccount::initTlsConfiguration()
{
// TLS listener is unique and should be only modified through IP2IP_PROFILE
pjsip_tls_setting_default(&tlsSetting_);
......@@ -622,20 +622,20 @@ void DHTAccount::initTlsConfiguration()
tlsSetting_.qos_ignore_error = PJ_TRUE;
}
void DHTAccount::loadConfig()
void RingAccount::loadConfig()
{
SFL_WARN("DHTAccount::loadConfig()");
SFL_WARN("RingAccount::loadConfig()");
initTlsConfiguration();
transportType_ = PJSIP_TRANSPORT_TLS;
}
bool DHTAccount::userMatch(const std::string& username) const
bool RingAccount::userMatch(const std::string& username) const
{
return !username.empty() and username == dht_.getId().toString();
}
MatchRank
DHTAccount::matches(const std::string &userName, const std::string &server) const
RingAccount::matches(const std::string &userName, const std::string &server) const
{
if (userMatch(userName)) {
SFL_DBG("Matching account id in request with username %s", userName.c_str());
......@@ -645,19 +645,19 @@ DHTAccount::matches(const std::string &userName, const std::string &server) cons
}
}
std::string DHTAccount::getFromUri() const
std::string RingAccount::getFromUri() const
{
return "dht:" + dht_.getId().toString() + "@dht.invalid";
return "ring:" + dht_.getId().toString() + "@ring.dht";
}
std::string DHTAccount::getToUri(const std::string& to) const
std::string RingAccount::getToUri(const std::string& to) const
{
const std::string transport {pjsip_transport_get_type_name(transportType_)};
return "<sips:" + to + ";transport=" + transport + ">";
}
pj_str_t
DHTAccount::getContactHeader(pjsip_transport* t)
RingAccount::getContactHeader(pjsip_transport* t)
{
if (!t && transport_)
t = transport_->get();
......@@ -671,7 +671,7 @@ DHTAccount::getContactHeader(pjsip_transport* t)
transportType = PJSIP_TRANSPORT_UDP;
// Else we determine this infor based on transport information
std::string address = "dht.invalid";
std::string address = "ring.dht";
pj_uint16_t port = getTlsListenerPort();
link_->sipTransport->findLocalAddressFromTransport(t, transportType, hostname_, address, port);
......@@ -699,7 +699,7 @@ DHTAccount::getContactHeader(pjsip_transport* t)
* Enable the presence module
*/
void
DHTAccount::enablePresence(const bool& /* enabled */)
RingAccount::enablePresence(const bool& /* enabled */)
{
}
......@@ -708,13 +708,13 @@ DHTAccount::enablePresence(const bool& /* enabled */)
* and process the change.
*/
void
DHTAccount::supportPresence(int /* function */, bool /* enabled*/)
RingAccount::supportPresence(int /* function */, bool /* enabled*/)
{
}
#endif
/*
void DHTAccount::updateDialogViaSentBy(pjsip_dialog *dlg)
void RingAccount::updateDialogViaSentBy(pjsip_dialog *dlg)
{
if (allowViaRewrite_ && via_addr_.host.slen > 0)
pjsip_dlg_set_via_sent_by(dlg, &via_addr_, via_tp_);
......
......@@ -29,8 +29,8 @@
* as that of the covered work.
*/
#ifndef DHTACCOUNT_H
#define DHTACCOUNT_H
#ifndef RINGACCOUNT_H
#define RINGACCOUNT_H
#ifdef HAVE_CONFIG_H
#include "config.h"
......@@ -68,9 +68,9 @@ namespace YAML {
* @file sipaccount.h
* @brief A SIP Account specify SIP specific functions and object = SIPCall/SIPVoIPLink)
*/
class DHTAccount : public SIPAccountBase {
class RingAccount : public SIPAccountBase {
public:
constexpr static const char * const ACCOUNT_TYPE = "DHT";
constexpr static const char * const ACCOUNT_TYPE = "RING";
constexpr static const in_port_t DHT_DEFAULT_PORT = 4222;
const char* getAccountType() const {
......@@ -81,9 +81,9 @@ class DHTAccount : public SIPAccountBase {
* Constructor
* @param accountID The account identifier
*/
DHTAccount(const std::string& accountID, bool presenceEnabled);
RingAccount(const std::string& accountID, bool presenceEnabled);
~DHTAccount();
~RingAccount();
/**
* Serialize internal state of this account for configuration
......@@ -261,7 +261,7 @@ class DHTAccount : public SIPAccountBase {
*/
virtual void setAccountDetails(const std::map<std::string, std::string> &details);
NON_COPYABLE(DHTAccount);
NON_COPYABLE(RingAccount);
/**
* Start a SIP Call
......
......@@ -45,7 +45,7 @@
#include "string_utils.h"
#if HAVE_DHT
#include "dht/dhtaccount.h"
#include "ringdht/ringaccount.h"
#endif
#include "call_factory.h"
......@@ -654,7 +654,7 @@ SIPVoIPLink::guessAccount(const std::string& userName,
#if HAVE_DHT
// DHT accounts
for (const auto& account : Manager::instance().getAllAccounts<DHTAccount>()) {
for (const auto& account : Manager::instance().getAllAccounts<RingAccount>()) {
if (!account)
continue;
const MatchRank match(account->matches(userName, server));
......
include ../globals.mak
libexecdir=$(libdir)/sflphone
libexecdir=$(libdir)/dht
libexec_PROGRAMS = dhtnode
dhtnode_SOURCES = \
......@@ -8,8 +8,8 @@ dhtnode_SOURCES = \
$(top_srcdir)/src/logger.c \
dhtnode.cpp
dhtnode_CXXFLAGS=-I$(top_srcdir)/src/dht -DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\"
dhtnode_CXXFLAGS=-I$(top_srcdir)/src/ringdht -DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\"
dhtnode_LDFLAGS = @GNUTLS_LIBS@ -lpthread
dhtnode_LDADD = $(top_builddir)/src/dht/dhtcpp/libdhtcpp.la
dhtnode_LDADD = $(top_builddir)/src/ringdht/dhtcpp/libdhtcpp.la
......@@ -366,7 +366,7 @@ gboolean account_is_IAX(const account_t *account)
gboolean account_is_DHT(const account_t *account)
{
return is_type(account, "DHT");
return is_type(account, "RING");
}
account_t *create_default_account()
......
......@@ -172,7 +172,7 @@ static void show_password_cb(G_GNUC_UNUSED GtkWidget *widget, gpointer data)
static void hide_widget_for_dht(GtkComboBox *combo_box, gpointer widget)
{
gchar *type = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo_box));
if (utf8_case_equal(type, "DHT")) {
if (utf8_case_equal(type, "RING")) {
gtk_widget_hide(GTK_WIDGET(widget));
} else {
gtk_widget_show(GTK_WIDGET(widget));
......@@ -184,7 +184,7 @@ static void hide_widget_for_dht(GtkComboBox *combo_box, gpointer widget)
static void show_widget_for_dht(GtkComboBox *combo_box, gpointer widget)
{
gchar *type = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo_box));
if (utf8_case_equal(type, "DHT")) {
if (utf8_case_equal(type, "RING")) {
gtk_widget_show(GTK_WIDGET(widget));
} else {
gtk_widget_hide(GTK_WIDGET(widget));
......@@ -218,7 +218,7 @@ static void change_type_cb(GtkComboBox *combo_box, gpointer data)
if (utf8_case_equal(type, "IAX")) {
gtk_widget_hide(security_tab);
gtk_widget_hide(advanced_tab);
} else if (utf8_case_equal(type, "DHT")) {
} else if (utf8_case_equal(type, "RING")) {
gtk_widget_hide(security_tab);
gtk_widget_show(advanced_tab);
} else if (utf8_case_equal(type, "SIP")) {
......@@ -329,7 +329,7 @@ create_accout_type_combo_box(const account_t *account, gboolean is_new)
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(account_combo), "SIP");
if (dbus_is_iax2_enabled())
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(account_combo), "IAX");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(account_combo), "DHT");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(account_combo), "RING");
if (account_is_SIP(account))
gtk_combo_box_set_active(GTK_COMBO_BOX(account_combo), 0);
......@@ -1528,9 +1528,9 @@ static void update_account_from_basic_tab(account_t *account)
else
proto = g_strdup("SIP");
if (g_strcmp0(proto, "SIP") == 0 || g_strcmp0(proto, "DHT") == 0) {
if (g_strcmp0(proto, "SIP") == 0 || g_strcmp0(proto, "RING") == 0) {
if (!IS_IP2IP && g_strcmp0(proto, "DHT") != 0) {
if (!IS_IP2IP && g_strcmp0(proto, "RING") != 0) {
account_replace(account, CONFIG_ACCOUNT_REGISTRATION_EXPIRE,
gtk_entry_get_text(GTK_ENTRY(expire_spin_box)));
......@@ -1560,7 +1560,7 @@ static void update_account_from_basic_tab(account_t *account)
#endif
#ifdef SFL_PRESENCE
if (!IS_IP2IP && g_strcmp0(proto, "DHT") != 0) {
if (!IS_IP2IP && g_strcmp0(proto, "RING") != 0) {
v = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(presence_check_box));
account_replace(account, CONFIG_PRESENCE_ENABLED, bool_to_string(v));
// TODO enable/disable the presence window view
......@@ -1607,7 +1607,7 @@ static void update_account_from_basic_tab(account_t *account)
account_replace(account, CONFIG_ACCOUNT_ALIAS, gtk_entry_get_text(GTK_ENTRY(entry_alias)));
account_replace(account, CONFIG_ACCOUNT_TYPE, proto);
account_replace(account, CONFIG_ACCOUNT_HOSTNAME, gtk_entry_get_text(GTK_ENTRY(entry_hostname)));
if (g_strcmp0(proto, "DHT") != 0) {
if (g_strcmp0(proto, "RING") != 0) {
account_replace(account, CONFIG_ACCOUNT_USERNAME, gtk_entry_get_text(GTK_ENTRY(entry_username)));
account_replace(account, CONFIG_ACCOUNT_PASSWORD, gtk_entry_get_text(GTK_ENTRY(entry_password)));
account_replace(account, CONFIG_ACCOUNT_MAILBOX, gtk_entry_get_text(GTK_ENTRY(entry_mailbox)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment