Updated to support actual D-BUS interface
This commit is contained in:
parent
660133c812
commit
9c4c356a3d
9 changed files with 103 additions and 34 deletions
|
@ -6,34 +6,59 @@
|
|||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define ECHOLINK_DEFAULT_USER_CALL "N0CALL Unknown call"
|
||||
#define ECHOLINK_DEFAULT_USER_NUMBER 1
|
||||
#define ECHOLINK_DEFAULT_CORD_NUMBER 10
|
||||
#define REGISTRY_CONFIGURATION_FILE "/opt/BrandMeister/Registry.cnf"
|
||||
|
||||
BrandMeisterBridge::BrandMeisterBridge() :
|
||||
proxy(ECHOLINK_DEFAULT_CORD_NUMBER),
|
||||
store(REGISTRY_CONFIGURATION_FILE),
|
||||
talker(NULL)
|
||||
#define DELETE(object) \
|
||||
if (object) \
|
||||
delete object;
|
||||
|
||||
BrandMeisterBridge::BrandMeisterBridge()
|
||||
{
|
||||
|
||||
proxy = NULL;
|
||||
store = NULL;
|
||||
talker = NULL;
|
||||
}
|
||||
|
||||
BrandMeisterBridge::~BrandMeisterBridge()
|
||||
{
|
||||
DELETE(proxy);
|
||||
DELETE(store);
|
||||
free(talker);
|
||||
}
|
||||
|
||||
// Interface methods for ModuleEchoLink
|
||||
|
||||
void BrandMeisterBridge::setProxyConfiguration(const char* configuration)
|
||||
{
|
||||
char* pointer = const_cast<char*>(configuration);
|
||||
|
||||
uint32_t network = strtol(pointer + 0, &pointer, 10);
|
||||
uint32_t link = strtol(pointer + 1, &pointer, 10);
|
||||
proxy = new PatchCordProxy(network, link);
|
||||
}
|
||||
|
||||
void BrandMeisterBridge::setStoreConfiguration(const char* configuration)
|
||||
{
|
||||
store = new UserDataStore(configuration);
|
||||
}
|
||||
|
||||
const char* BrandMeisterBridge::getTalker()
|
||||
{
|
||||
if ((proxy == NULL) ||
|
||||
(store == NULL))
|
||||
{
|
||||
syslog(LOG_ERR, "BrandMeister bridge is not configured");
|
||||
return ECHOLINK_DEFAULT_USER_CALL;
|
||||
}
|
||||
|
||||
free(talker);
|
||||
uint32_t number = proxy.getTalkerID();
|
||||
uint32_t number = proxy->getTalkerID();
|
||||
|
||||
char call[LONG_CALLSIGN_LENGTH];
|
||||
char text[SLOW_DATA_TEXT_LENGTH];
|
||||
if ((number != 0) &&
|
||||
(store.getCredentialsForID(number, call, text)))
|
||||
(store->getCredentialsForID(number, call, text)))
|
||||
{
|
||||
asprintf(&talker, "%s %s", call, text);
|
||||
return talker;
|
||||
|
@ -45,6 +70,13 @@ const char* BrandMeisterBridge::getTalker()
|
|||
|
||||
void BrandMeisterBridge::setTalker(const char* call, const char* name)
|
||||
{
|
||||
if ((proxy == NULL) ||
|
||||
(store == NULL))
|
||||
{
|
||||
syslog(LOG_ERR, "BrandMeister bridge is not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
if (*call == '*')
|
||||
{
|
||||
// Do not process conference call-sign
|
||||
|
@ -61,12 +93,12 @@ void BrandMeisterBridge::setTalker(const char* call, const char* name)
|
|||
call = buffer;
|
||||
}
|
||||
|
||||
uint32_t number = store.getPrivateIDForCall(call);
|
||||
uint32_t number = store->getPrivateIDForCall(call);
|
||||
if (number == 0)
|
||||
number = ECHOLINK_DEFAULT_USER_NUMBER;
|
||||
|
||||
syslog(LOG_INFO, "Set talker ID to %d for call-sign %s", number, call);
|
||||
proxy.setTalkerID(number);
|
||||
proxy->setTalkerID(number);
|
||||
}
|
||||
|
||||
void BrandMeisterBridge::handleChatMessage(const char* text)
|
||||
|
@ -76,6 +108,13 @@ void BrandMeisterBridge::handleChatMessage(const char* text)
|
|||
// UB3AMO Moscow T I N A O
|
||||
// ->UA0LQE-L USSURIISK
|
||||
|
||||
if ((proxy == NULL) ||
|
||||
(store == NULL))
|
||||
{
|
||||
syslog(LOG_ERR, "BrandMeister bridge is not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp(text, "CONF ", 5) == 0)
|
||||
{
|
||||
const char* delimiter = strstr(text, "\n->");
|
||||
|
@ -88,7 +127,7 @@ void BrandMeisterBridge::handleChatMessage(const char* text)
|
|||
{
|
||||
uint32_t number = ECHOLINK_DEFAULT_USER_NUMBER;
|
||||
syslog(LOG_INFO, "Set talker ID to %d (call-sign was not fit into chat message)", number);
|
||||
proxy.setTalkerID(number);
|
||||
proxy->setTalkerID(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,14 +13,17 @@ class BrandMeisterBridge
|
|||
BrandMeisterBridge();
|
||||
~BrandMeisterBridge();
|
||||
|
||||
void setProxyConfiguration(const char* configuration);
|
||||
void setStoreConfiguration(const char* configuration);
|
||||
|
||||
const char* getTalker();
|
||||
void setTalker(const char* call, const char* name);
|
||||
void handleChatMessage(const char* text);
|
||||
|
||||
private:
|
||||
|
||||
PatchCordProxy proxy;
|
||||
UserDataStore store;
|
||||
PatchCordProxy* proxy;
|
||||
UserDataStore* store;
|
||||
char* talker;
|
||||
|
||||
};
|
||||
|
|
|
@ -412,6 +412,15 @@ bool ModuleEchoLink::initialize(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (cfg().getValue(cfgName(), "BRIDGE_PROXY", value))
|
||||
{
|
||||
bridge.setProxyConfiguration(value.c_str());
|
||||
}
|
||||
if (cfg().getValue(cfgName(), "BRIDGE_STORE", value))
|
||||
{
|
||||
bridge.setStoreConfiguration(value.c_str());
|
||||
}
|
||||
|
||||
// Initialize directory server communication
|
||||
dir = new Directory(servers, mycall, password, location, bind_addr);
|
||||
dir->statusChanged.connect(mem_fun(*this, &ModuleEchoLink::onStatusChanged));
|
||||
|
|
|
@ -18,17 +18,19 @@
|
|||
#define VALUE_CORD_OUTGOING_SOURCE_ID 1
|
||||
#define VALUE_CORD_INCOMING_SOURCE_ID 4
|
||||
|
||||
PatchCordProxy::PatchCordProxy(uint32_t number) :
|
||||
number(number),
|
||||
banner(NULL)
|
||||
PatchCordProxy::PatchCordProxy(uint32_t network, uint32_t link)
|
||||
{
|
||||
banner = NULL;
|
||||
number = link;
|
||||
asprintf(&path, OBJECT_PATH "/%d", network);
|
||||
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
|
||||
}
|
||||
|
||||
PatchCordProxy::~PatchCordProxy()
|
||||
{
|
||||
free(banner);
|
||||
dbus_connection_unref(connection);
|
||||
free(banner);
|
||||
free(path);
|
||||
}
|
||||
|
||||
void PatchCordProxy::setTalkerID(uint32_t value)
|
||||
|
@ -46,7 +48,7 @@ uint32_t PatchCordProxy::getTalkerID()
|
|||
void PatchCordProxy::getContextBanner()
|
||||
{
|
||||
DBusMessage* message = dbus_message_new_method_call(
|
||||
SERVICE_NAME, OBJECT_PATH,
|
||||
SERVICE_NAME, path,
|
||||
INTERFACE_NAME, "getContextList");
|
||||
|
||||
const char* name = AUTOPATCH_LINK_NAME;
|
||||
|
@ -82,7 +84,7 @@ void PatchCordProxy::getContextBanner()
|
|||
void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value)
|
||||
{
|
||||
DBusMessage* message = dbus_message_new_method_call(
|
||||
SERVICE_NAME, OBJECT_PATH,
|
||||
SERVICE_NAME, path,
|
||||
INTERFACE_NAME, "setVendorSpecificValue");
|
||||
|
||||
dbus_message_append_args(message,
|
||||
|
@ -109,7 +111,7 @@ void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value)
|
|||
uint32_t PatchCordProxy::getVendorSpecificValue(uint32_t key)
|
||||
{
|
||||
DBusMessage* message = dbus_message_new_method_call(
|
||||
SERVICE_NAME, OBJECT_PATH,
|
||||
SERVICE_NAME, path,
|
||||
INTERFACE_NAME, "getContextData");
|
||||
|
||||
dbus_message_append_args(message,
|
||||
|
|
|
@ -10,7 +10,7 @@ class PatchCordProxy
|
|||
{
|
||||
public:
|
||||
|
||||
PatchCordProxy(uint32_t number);
|
||||
PatchCordProxy(uint32_t network, uint32_t link);
|
||||
~PatchCordProxy();
|
||||
|
||||
void setTalkerID(uint32_t value);
|
||||
|
@ -19,6 +19,8 @@ class PatchCordProxy
|
|||
private:
|
||||
|
||||
DBusConnection* connection;
|
||||
char* path;
|
||||
|
||||
uint32_t number;
|
||||
char* banner;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue