From 83efcf40d762268a5d871e5b72479a9ff1ca3ac3 Mon Sep 17 00:00:00 2001 From: Artem Prilutskiy Date: Tue, 5 Apr 2016 10:10:54 +0300 Subject: [PATCH] Changes for fixed API --- CallCapture/BrandMeisterBridge.cpp | 90 ----------------------------- CallCapture/BrandMeisterBridge.h | 28 --------- CallCapture/PatchCordProxy.cpp | 19 +++--- CallCapture/PatchCordProxy.h | 2 +- SVXLink/echolink/PatchCordProxy.cpp | 19 +++--- SVXLink/echolink/PatchCordProxy.h | 2 +- 6 files changed, 18 insertions(+), 142 deletions(-) delete mode 100644 CallCapture/BrandMeisterBridge.cpp delete mode 100644 CallCapture/BrandMeisterBridge.h diff --git a/CallCapture/BrandMeisterBridge.cpp b/CallCapture/BrandMeisterBridge.cpp deleted file mode 100644 index 1f13fd6..0000000 --- a/CallCapture/BrandMeisterBridge.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2015 by Artem Prilutskiy - -#include "BrandMeisterBridge.h" -#include -#include -#include -#include - -#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) -{ - -} - -BrandMeisterBridge::~BrandMeisterBridge() -{ - free(talker); -} - -// Interface methods for ModuleEchoLink - -const char* BrandMeisterBridge::getTalker() -{ - free(talker); - uint32_t number = proxy.getTalkerID(); - - char call[LONG_CALLSIGN_LENGTH]; - char text[SLOW_DATA_TEXT_LENGTH]; - if ((number != 0) && - (store.getCredentialsForID(number, call, text))) - { - asprintf(&talker, "%s %s", call, text); - return talker; - } - - asprintf(&talker, "DMR ID: %d", number); - return talker; -} - -void BrandMeisterBridge::setTalker(const char* call, const char* name) -{ - if (*call == '*') - { - // Do not process conference call-sign - return; - } - - const char* delimiter = strpbrk(call, " -\n"); - if (delimiter != NULL) - { - // Remove characters after call-sign - size_t length = delimiter - call; - char* buffer = (char*)alloca(length + 1); - strncpy(buffer, call, length); - call = buffer; - } - - uint32_t number = store.getPrivateIDForCall(call); - if (number == 0) - { - syslog(LOG_INFO, "DMR ID for call-sign %s not found", call); - number = ECHOLINK_DEFAULT_USER_NUMBER; - } - - syslog(LOG_DEBUG, "Set talker DMR ID to %d", number); - proxy.setTalkerID(number); -} - -void BrandMeisterBridge::handleChatMessage(const char* text) -{ - // CONF Russian Reflector, Open 24/7, Contacts: rv3dhc.link@qip.ru * Call CQ / Use pauses 2sec * [28/500] - // R3ABM-L *DSTAR.SU DMR Bridge* - // UB3AMO Moscow T I N A O - // ->UA0LQE-L USSURIISK - - const char* delimiter; - if ((strncmp(text, "CONF ", 5) == 0) && - ((delimiter = strstr(text, "\n->")) != NULL)) - { - const char* call = delimiter + 3; - setTalker(call, NULL); - } -} - diff --git a/CallCapture/BrandMeisterBridge.h b/CallCapture/BrandMeisterBridge.h deleted file mode 100644 index 554bbe8..0000000 --- a/CallCapture/BrandMeisterBridge.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 by Artem Prilutskiy - -#ifndef BRANDMEISTERBRIDGE_H -#define BRANDMEISTERBRIDGE_H - -#include "PatchCordProxy.h" -#include "UserDataStore.h" - -class BrandMeisterBridge -{ - public: - - BrandMeisterBridge(); - ~BrandMeisterBridge(); - - const char* getTalker(); - void setTalker(const char* call, const char* name); - void handleChatMessage(const char* text); - - private: - - PatchCordProxy proxy; - UserDataStore store; - char* talker; - -}; - -#endif \ No newline at end of file diff --git a/CallCapture/PatchCordProxy.cpp b/CallCapture/PatchCordProxy.cpp index a3f7876..4fab5cf 100644 --- a/CallCapture/PatchCordProxy.cpp +++ b/CallCapture/PatchCordProxy.cpp @@ -1,4 +1,4 @@ -// Copyright 2015 by Artem Prilutskiy +// Copyright 2015-2016 by Artem Prilutskiy #include "PatchCordProxy.h" #include @@ -7,9 +7,9 @@ #include #include -#define INTERFACE_NAME "me.burnaway.BrandMeister" -#define SERVICE_NAME INTERFACE_NAME +#define SERVICE_NAME "me.burnaway.BrandMeister" #define OBJECT_PATH "/me/burnaway/BrandMeister" +#define INTERFACE_NAME "me.burnaway.BrandMeister" // From AutoPatch.cpp #define AUTOPATCH_LINK_NAME "AutoPatch" @@ -22,7 +22,7 @@ PatchCordProxy::PatchCordProxy(uint32_t network, uint32_t link) { banner = NULL; number = link; - asprintf(&path, OBJECT_PATH "/%d", network); + asprintf(&name, SERVICE_NAME ".network-%d", network); connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); } @@ -30,7 +30,7 @@ PatchCordProxy::~PatchCordProxy() { dbus_connection_unref(connection); free(banner); - free(path); + free(name); } void PatchCordProxy::setTalkerID(uint32_t value) @@ -48,8 +48,7 @@ uint32_t PatchCordProxy::getTalkerID() void PatchCordProxy::getContextBanner() { DBusMessage* message = dbus_message_new_method_call( - SERVICE_NAME, path, - INTERFACE_NAME, "getContextList"); + name, OBJECT_PATH, INTERFACE_NAME, "getContextList"); const char* name = AUTOPATCH_LINK_NAME; @@ -84,8 +83,7 @@ void PatchCordProxy::getContextBanner() void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value) { DBusMessage* message = dbus_message_new_method_call( - SERVICE_NAME, path, - INTERFACE_NAME, "setVendorSpecificValue"); + name, OBJECT_PATH, INTERFACE_NAME, "setVendorSpecificValue"); dbus_message_append_args(message, DBUS_TYPE_STRING, &banner, @@ -111,8 +109,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, path, - INTERFACE_NAME, "getContextData"); + name, OBJECT_PATH, INTERFACE_NAME, "getContextData"); dbus_message_append_args(message, DBUS_TYPE_STRING, &banner, diff --git a/CallCapture/PatchCordProxy.h b/CallCapture/PatchCordProxy.h index 83bb510..836326c 100644 --- a/CallCapture/PatchCordProxy.h +++ b/CallCapture/PatchCordProxy.h @@ -19,7 +19,7 @@ class PatchCordProxy private: DBusConnection* connection; - char* path; + char* name; uint32_t number; char* banner; diff --git a/SVXLink/echolink/PatchCordProxy.cpp b/SVXLink/echolink/PatchCordProxy.cpp index a3f7876..4fab5cf 100644 --- a/SVXLink/echolink/PatchCordProxy.cpp +++ b/SVXLink/echolink/PatchCordProxy.cpp @@ -1,4 +1,4 @@ -// Copyright 2015 by Artem Prilutskiy +// Copyright 2015-2016 by Artem Prilutskiy #include "PatchCordProxy.h" #include @@ -7,9 +7,9 @@ #include #include -#define INTERFACE_NAME "me.burnaway.BrandMeister" -#define SERVICE_NAME INTERFACE_NAME +#define SERVICE_NAME "me.burnaway.BrandMeister" #define OBJECT_PATH "/me/burnaway/BrandMeister" +#define INTERFACE_NAME "me.burnaway.BrandMeister" // From AutoPatch.cpp #define AUTOPATCH_LINK_NAME "AutoPatch" @@ -22,7 +22,7 @@ PatchCordProxy::PatchCordProxy(uint32_t network, uint32_t link) { banner = NULL; number = link; - asprintf(&path, OBJECT_PATH "/%d", network); + asprintf(&name, SERVICE_NAME ".network-%d", network); connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); } @@ -30,7 +30,7 @@ PatchCordProxy::~PatchCordProxy() { dbus_connection_unref(connection); free(banner); - free(path); + free(name); } void PatchCordProxy::setTalkerID(uint32_t value) @@ -48,8 +48,7 @@ uint32_t PatchCordProxy::getTalkerID() void PatchCordProxy::getContextBanner() { DBusMessage* message = dbus_message_new_method_call( - SERVICE_NAME, path, - INTERFACE_NAME, "getContextList"); + name, OBJECT_PATH, INTERFACE_NAME, "getContextList"); const char* name = AUTOPATCH_LINK_NAME; @@ -84,8 +83,7 @@ void PatchCordProxy::getContextBanner() void PatchCordProxy::setVendorSpecificValue(uint32_t key, uint32_t value) { DBusMessage* message = dbus_message_new_method_call( - SERVICE_NAME, path, - INTERFACE_NAME, "setVendorSpecificValue"); + name, OBJECT_PATH, INTERFACE_NAME, "setVendorSpecificValue"); dbus_message_append_args(message, DBUS_TYPE_STRING, &banner, @@ -111,8 +109,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, path, - INTERFACE_NAME, "getContextData"); + name, OBJECT_PATH, INTERFACE_NAME, "getContextData"); dbus_message_append_args(message, DBUS_TYPE_STRING, &banner, diff --git a/SVXLink/echolink/PatchCordProxy.h b/SVXLink/echolink/PatchCordProxy.h index 83bb510..836326c 100644 --- a/SVXLink/echolink/PatchCordProxy.h +++ b/SVXLink/echolink/PatchCordProxy.h @@ -19,7 +19,7 @@ class PatchCordProxy private: DBusConnection* connection; - char* path; + char* name; uint32_t number; char* banner;