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
|
@ -24,19 +24,21 @@ int main(int argc, const char* argv[])
|
||||||
{ "expression", required_argument, NULL, 'e' },
|
{ "expression", required_argument, NULL, 'e' },
|
||||||
{ "connection", required_argument, NULL, 'c' },
|
{ "connection", required_argument, NULL, 'c' },
|
||||||
{ "identity", required_argument, NULL, 'i' },
|
{ "identity", required_argument, NULL, 'i' },
|
||||||
|
{ "network", required_argument, NULL, 'n' },
|
||||||
{ "link", required_argument, NULL, 'l' },
|
{ "link", required_argument, NULL, 'l' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
pcre* expression = NULL;
|
pcre* expression = NULL;
|
||||||
const char* file = NULL;
|
const char* file = NULL;
|
||||||
uint32_t number = 10;
|
uint32_t network = 0;
|
||||||
|
uint32_t link = 10;
|
||||||
|
|
||||||
int position = 0;
|
int position = 0;
|
||||||
const char* error = NULL;
|
const char* error = NULL;
|
||||||
|
|
||||||
int selection = 0;
|
int selection = 0;
|
||||||
while ((selection = getopt_long(argc, const_cast<char* const*>(argv), "e:c:l:", options, NULL)) != EOF)
|
while ((selection = getopt_long(argc, const_cast<char* const*>(argv), "e:c:n:l:", options, NULL)) != EOF)
|
||||||
switch (selection)
|
switch (selection)
|
||||||
{
|
{
|
||||||
case 'e':
|
case 'e':
|
||||||
|
@ -51,8 +53,12 @@ int main(int argc, const char* argv[])
|
||||||
openlog(optarg, 0, LOG_USER);
|
openlog(optarg, 0, LOG_USER);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
network = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
number = atoi(optarg);
|
link = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +70,14 @@ int main(int argc, const char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((expression == NULL) ||
|
if ((expression == NULL) ||
|
||||||
|
(network == 0) ||
|
||||||
(file == NULL))
|
(file == NULL))
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"Usage: %s"
|
"Usage: %s"
|
||||||
" --expression <regular expression>"
|
" --expression <regular expression>"
|
||||||
" --connection <path to configuration file>"
|
" --connection <path to configuration file>"
|
||||||
|
" --network <network number>"
|
||||||
" --link <link number>"
|
" --link <link number>"
|
||||||
" [--identity <identity>]"
|
" [--identity <identity>]"
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -80,7 +88,7 @@ int main(int argc, const char* argv[])
|
||||||
// Main
|
// Main
|
||||||
|
|
||||||
UserDataStore store(file);
|
UserDataStore store(file);
|
||||||
PatchCordProxy proxy(number);
|
PatchCordProxy proxy(network, link);
|
||||||
|
|
||||||
char* line = NULL;
|
char* line = NULL;
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
|
|
|
@ -18,17 +18,19 @@
|
||||||
#define VALUE_CORD_OUTGOING_SOURCE_ID 1
|
#define VALUE_CORD_OUTGOING_SOURCE_ID 1
|
||||||
#define VALUE_CORD_INCOMING_SOURCE_ID 4
|
#define VALUE_CORD_INCOMING_SOURCE_ID 4
|
||||||
|
|
||||||
PatchCordProxy::PatchCordProxy(uint32_t number) :
|
PatchCordProxy::PatchCordProxy(uint32_t network, uint32_t link)
|
||||||
number(number),
|
|
||||||
banner(NULL)
|
|
||||||
{
|
{
|
||||||
|
banner = NULL;
|
||||||
|
number = link;
|
||||||
|
asprintf(&path, OBJECT_PATH "/%d", network);
|
||||||
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
|
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
PatchCordProxy::~PatchCordProxy()
|
PatchCordProxy::~PatchCordProxy()
|
||||||
{
|
{
|
||||||
free(banner);
|
|
||||||
dbus_connection_unref(connection);
|
dbus_connection_unref(connection);
|
||||||
|
free(banner);
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchCordProxy::setTalkerID(uint32_t value)
|
void PatchCordProxy::setTalkerID(uint32_t value)
|
||||||
|
@ -46,7 +48,7 @@ uint32_t PatchCordProxy::getTalkerID()
|
||||||
void PatchCordProxy::getContextBanner()
|
void PatchCordProxy::getContextBanner()
|
||||||
{
|
{
|
||||||
DBusMessage* message = dbus_message_new_method_call(
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
SERVICE_NAME, OBJECT_PATH,
|
SERVICE_NAME, path,
|
||||||
INTERFACE_NAME, "getContextList");
|
INTERFACE_NAME, "getContextList");
|
||||||
|
|
||||||
const char* name = AUTOPATCH_LINK_NAME;
|
const char* name = AUTOPATCH_LINK_NAME;
|
||||||
|
@ -82,7 +84,7 @@ void PatchCordProxy::getContextBanner()
|
||||||
void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value)
|
void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value)
|
||||||
{
|
{
|
||||||
DBusMessage* message = dbus_message_new_method_call(
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
SERVICE_NAME, OBJECT_PATH,
|
SERVICE_NAME, path,
|
||||||
INTERFACE_NAME, "setVendorSpecificValue");
|
INTERFACE_NAME, "setVendorSpecificValue");
|
||||||
|
|
||||||
dbus_message_append_args(message,
|
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)
|
uint32_t PatchCordProxy::getVendorSpecificValue(uint32_t key)
|
||||||
{
|
{
|
||||||
DBusMessage* message = dbus_message_new_method_call(
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
SERVICE_NAME, OBJECT_PATH,
|
SERVICE_NAME, path,
|
||||||
INTERFACE_NAME, "getContextData");
|
INTERFACE_NAME, "getContextData");
|
||||||
|
|
||||||
dbus_message_append_args(message,
|
dbus_message_append_args(message,
|
||||||
|
|
|
@ -10,7 +10,7 @@ class PatchCordProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PatchCordProxy(uint32_t number);
|
PatchCordProxy(uint32_t network, uint32_t link);
|
||||||
~PatchCordProxy();
|
~PatchCordProxy();
|
||||||
|
|
||||||
void setTalkerID(uint32_t value);
|
void setTalkerID(uint32_t value);
|
||||||
|
@ -19,6 +19,8 @@ class PatchCordProxy
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DBusConnection* connection;
|
DBusConnection* connection;
|
||||||
|
char* path;
|
||||||
|
|
||||||
uint32_t number;
|
uint32_t number;
|
||||||
char* banner;
|
char* banner;
|
||||||
|
|
||||||
|
|
|
@ -19,3 +19,5 @@ LINK_IDLE_TIMEOUT=0
|
||||||
DESCRIPTION="You have connected to a DSTAR.SU DMR Bridge\n"
|
DESCRIPTION="You have connected to a DSTAR.SU DMR Bridge\n"
|
||||||
AUTOCON_ECHOLINK_ID=196189
|
AUTOCON_ECHOLINK_ID=196189
|
||||||
AUTOCON_TIME=30
|
AUTOCON_TIME=30
|
||||||
|
BRIDGE_PROXY=2501:10
|
||||||
|
BRIDGE_STORE=/opt/BrandMeister/Registry.cnf
|
||||||
|
|
|
@ -6,34 +6,59 @@
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define ECHOLINK_DEFAULT_USER_CALL "N0CALL Unknown call"
|
||||||
#define ECHOLINK_DEFAULT_USER_NUMBER 1
|
#define ECHOLINK_DEFAULT_USER_NUMBER 1
|
||||||
#define ECHOLINK_DEFAULT_CORD_NUMBER 10
|
|
||||||
#define REGISTRY_CONFIGURATION_FILE "/opt/BrandMeister/Registry.cnf"
|
|
||||||
|
|
||||||
BrandMeisterBridge::BrandMeisterBridge() :
|
#define DELETE(object) \
|
||||||
proxy(ECHOLINK_DEFAULT_CORD_NUMBER),
|
if (object) \
|
||||||
store(REGISTRY_CONFIGURATION_FILE),
|
delete object;
|
||||||
talker(NULL)
|
|
||||||
|
BrandMeisterBridge::BrandMeisterBridge()
|
||||||
{
|
{
|
||||||
|
proxy = NULL;
|
||||||
|
store = NULL;
|
||||||
|
talker = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrandMeisterBridge::~BrandMeisterBridge()
|
BrandMeisterBridge::~BrandMeisterBridge()
|
||||||
{
|
{
|
||||||
|
DELETE(proxy);
|
||||||
|
DELETE(store);
|
||||||
free(talker);
|
free(talker);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interface methods for ModuleEchoLink
|
// 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()
|
const char* BrandMeisterBridge::getTalker()
|
||||||
{
|
{
|
||||||
|
if ((proxy == NULL) ||
|
||||||
|
(store == NULL))
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "BrandMeister bridge is not configured");
|
||||||
|
return ECHOLINK_DEFAULT_USER_CALL;
|
||||||
|
}
|
||||||
|
|
||||||
free(talker);
|
free(talker);
|
||||||
uint32_t number = proxy.getTalkerID();
|
uint32_t number = proxy->getTalkerID();
|
||||||
|
|
||||||
char call[LONG_CALLSIGN_LENGTH];
|
char call[LONG_CALLSIGN_LENGTH];
|
||||||
char text[SLOW_DATA_TEXT_LENGTH];
|
char text[SLOW_DATA_TEXT_LENGTH];
|
||||||
if ((number != 0) &&
|
if ((number != 0) &&
|
||||||
(store.getCredentialsForID(number, call, text)))
|
(store->getCredentialsForID(number, call, text)))
|
||||||
{
|
{
|
||||||
asprintf(&talker, "%s %s", call, text);
|
asprintf(&talker, "%s %s", call, text);
|
||||||
return talker;
|
return talker;
|
||||||
|
@ -45,6 +70,13 @@ const char* BrandMeisterBridge::getTalker()
|
||||||
|
|
||||||
void BrandMeisterBridge::setTalker(const char* call, const char* name)
|
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 == '*')
|
if (*call == '*')
|
||||||
{
|
{
|
||||||
// Do not process conference call-sign
|
// Do not process conference call-sign
|
||||||
|
@ -61,12 +93,12 @@ void BrandMeisterBridge::setTalker(const char* call, const char* name)
|
||||||
call = buffer;
|
call = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t number = store.getPrivateIDForCall(call);
|
uint32_t number = store->getPrivateIDForCall(call);
|
||||||
if (number == 0)
|
if (number == 0)
|
||||||
number = ECHOLINK_DEFAULT_USER_NUMBER;
|
number = ECHOLINK_DEFAULT_USER_NUMBER;
|
||||||
|
|
||||||
syslog(LOG_INFO, "Set talker ID to %d for call-sign %s", number, call);
|
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)
|
void BrandMeisterBridge::handleChatMessage(const char* text)
|
||||||
|
@ -76,6 +108,13 @@ void BrandMeisterBridge::handleChatMessage(const char* text)
|
||||||
// UB3AMO Moscow T I N A O
|
// UB3AMO Moscow T I N A O
|
||||||
// ->UA0LQE-L USSURIISK
|
// ->UA0LQE-L USSURIISK
|
||||||
|
|
||||||
|
if ((proxy == NULL) ||
|
||||||
|
(store == NULL))
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "BrandMeister bridge is not configured");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (strncmp(text, "CONF ", 5) == 0)
|
if (strncmp(text, "CONF ", 5) == 0)
|
||||||
{
|
{
|
||||||
const char* delimiter = strstr(text, "\n->");
|
const char* delimiter = strstr(text, "\n->");
|
||||||
|
@ -88,7 +127,7 @@ void BrandMeisterBridge::handleChatMessage(const char* text)
|
||||||
{
|
{
|
||||||
uint32_t number = ECHOLINK_DEFAULT_USER_NUMBER;
|
uint32_t number = ECHOLINK_DEFAULT_USER_NUMBER;
|
||||||
syslog(LOG_INFO, "Set talker ID to %d (call-sign was not fit into chat message)", 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();
|
||||||
~BrandMeisterBridge();
|
~BrandMeisterBridge();
|
||||||
|
|
||||||
|
void setProxyConfiguration(const char* configuration);
|
||||||
|
void setStoreConfiguration(const char* configuration);
|
||||||
|
|
||||||
const char* getTalker();
|
const char* getTalker();
|
||||||
void setTalker(const char* call, const char* name);
|
void setTalker(const char* call, const char* name);
|
||||||
void handleChatMessage(const char* text);
|
void handleChatMessage(const char* text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
PatchCordProxy proxy;
|
PatchCordProxy* proxy;
|
||||||
UserDataStore store;
|
UserDataStore* store;
|
||||||
char* talker;
|
char* talker;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -412,6 +412,15 @@ bool ModuleEchoLink::initialize(void)
|
||||||
return false;
|
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
|
// Initialize directory server communication
|
||||||
dir = new Directory(servers, mycall, password, location, bind_addr);
|
dir = new Directory(servers, mycall, password, location, bind_addr);
|
||||||
dir->statusChanged.connect(mem_fun(*this, &ModuleEchoLink::onStatusChanged));
|
dir->statusChanged.connect(mem_fun(*this, &ModuleEchoLink::onStatusChanged));
|
||||||
|
|
|
@ -18,17 +18,19 @@
|
||||||
#define VALUE_CORD_OUTGOING_SOURCE_ID 1
|
#define VALUE_CORD_OUTGOING_SOURCE_ID 1
|
||||||
#define VALUE_CORD_INCOMING_SOURCE_ID 4
|
#define VALUE_CORD_INCOMING_SOURCE_ID 4
|
||||||
|
|
||||||
PatchCordProxy::PatchCordProxy(uint32_t number) :
|
PatchCordProxy::PatchCordProxy(uint32_t network, uint32_t link)
|
||||||
number(number),
|
|
||||||
banner(NULL)
|
|
||||||
{
|
{
|
||||||
|
banner = NULL;
|
||||||
|
number = link;
|
||||||
|
asprintf(&path, OBJECT_PATH "/%d", network);
|
||||||
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
|
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
PatchCordProxy::~PatchCordProxy()
|
PatchCordProxy::~PatchCordProxy()
|
||||||
{
|
{
|
||||||
free(banner);
|
|
||||||
dbus_connection_unref(connection);
|
dbus_connection_unref(connection);
|
||||||
|
free(banner);
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchCordProxy::setTalkerID(uint32_t value)
|
void PatchCordProxy::setTalkerID(uint32_t value)
|
||||||
|
@ -46,7 +48,7 @@ uint32_t PatchCordProxy::getTalkerID()
|
||||||
void PatchCordProxy::getContextBanner()
|
void PatchCordProxy::getContextBanner()
|
||||||
{
|
{
|
||||||
DBusMessage* message = dbus_message_new_method_call(
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
SERVICE_NAME, OBJECT_PATH,
|
SERVICE_NAME, path,
|
||||||
INTERFACE_NAME, "getContextList");
|
INTERFACE_NAME, "getContextList");
|
||||||
|
|
||||||
const char* name = AUTOPATCH_LINK_NAME;
|
const char* name = AUTOPATCH_LINK_NAME;
|
||||||
|
@ -82,7 +84,7 @@ void PatchCordProxy::getContextBanner()
|
||||||
void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value)
|
void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value)
|
||||||
{
|
{
|
||||||
DBusMessage* message = dbus_message_new_method_call(
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
SERVICE_NAME, OBJECT_PATH,
|
SERVICE_NAME, path,
|
||||||
INTERFACE_NAME, "setVendorSpecificValue");
|
INTERFACE_NAME, "setVendorSpecificValue");
|
||||||
|
|
||||||
dbus_message_append_args(message,
|
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)
|
uint32_t PatchCordProxy::getVendorSpecificValue(uint32_t key)
|
||||||
{
|
{
|
||||||
DBusMessage* message = dbus_message_new_method_call(
|
DBusMessage* message = dbus_message_new_method_call(
|
||||||
SERVICE_NAME, OBJECT_PATH,
|
SERVICE_NAME, path,
|
||||||
INTERFACE_NAME, "getContextData");
|
INTERFACE_NAME, "getContextData");
|
||||||
|
|
||||||
dbus_message_append_args(message,
|
dbus_message_append_args(message,
|
||||||
|
|
|
@ -10,7 +10,7 @@ class PatchCordProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PatchCordProxy(uint32_t number);
|
PatchCordProxy(uint32_t network, uint32_t link);
|
||||||
~PatchCordProxy();
|
~PatchCordProxy();
|
||||||
|
|
||||||
void setTalkerID(uint32_t value);
|
void setTalkerID(uint32_t value);
|
||||||
|
@ -19,6 +19,8 @@ class PatchCordProxy
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DBusConnection* connection;
|
DBusConnection* connection;
|
||||||
|
char* path;
|
||||||
|
|
||||||
uint32_t number;
|
uint32_t number;
|
||||||
char* banner;
|
char* banner;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue