Commit 030902d7 authored by R3ABM Artem's avatar R3ABM Artem

Revert "Added support of iconv"

This reverts commit 0c0990a9
parent 0c0990a9
...@@ -9,8 +9,8 @@ TIMEOUT=0 ...@@ -9,8 +9,8 @@ TIMEOUT=0
#REJECT_OUTGOING=^()$ #REJECT_OUTGOING=^()$
#ACCEPT_OUTGOING=^(.*)$ #ACCEPT_OUTGOING=^(.*)$
SERVERS=servers.echolink.org SERVERS=servers.echolink.org
CALLSIGN=R3ABM-L CALLSIGN=callsign
PASSWORD=rqY69MWd PASSWORD=password
SYSOPNAME=*DSTAR.SU DMR Bridge* SYSOPNAME=*DSTAR.SU DMR Bridge*
LOCATION=Moscow, Russia LOCATION=Moscow, Russia
MAX_QSOS=10 MAX_QSOS=10
...@@ -22,4 +22,3 @@ AUTOCON_TIME=30 ...@@ -22,4 +22,3 @@ AUTOCON_TIME=30
BRIDGE_DEFAULT=9504 BRIDGE_DEFAULT=9504
BRIDGE_PROXY=2501:10 BRIDGE_PROXY=2501:10
BRIDGE_ENCODING=cp1251
...@@ -16,25 +16,18 @@ ...@@ -16,25 +16,18 @@
BrandMeisterBridge::BrandMeisterBridge() BrandMeisterBridge::BrandMeisterBridge()
{ {
proxy = NULL; proxy = NULL;
handle = NULL;
talker = NULL; talker = NULL;
unknown = ECHOLINK_DEFAULT_USER_NUMBER; unknown = ECHOLINK_DEFAULT_USER_NUMBER;
} }
BrandMeisterBridge::~BrandMeisterBridge() BrandMeisterBridge::~BrandMeisterBridge()
{ {
iconv_close(handle);
DELETE(proxy); DELETE(proxy);
free(talker); free(talker);
} }
// Interface methods for ModuleEchoLink // Interface methods for ModuleEchoLink
void BrandMeisterBridge::setEncodingConfiguration(const char* configuration)
{
handle = iconv_open("UTF-8", configuration);
}
void BrandMeisterBridge::setDefaultConfiguration(const char* configuration) void BrandMeisterBridge::setDefaultConfiguration(const char* configuration)
{ {
unknown = strtol(configuration, NULL, 10); unknown = strtol(configuration, NULL, 10);
...@@ -83,16 +76,39 @@ void BrandMeisterBridge::setTalker(const char* call, const char* name) ...@@ -83,16 +76,39 @@ void BrandMeisterBridge::setTalker(const char* call, const char* name)
if (*call == '*') if (*call == '*')
{ {
// Do not handle conference call-sign // Do not process conference call-sign
return; return;
} }
size_t length = strlen(call) + strlen(name); const char* delimiter1 = strpbrk(call, " -\n");
char* buffer = (char*)alloca(length + sizeof(uint32_t)); const char* delimiter2 = strpbrk(name, "\n");
if (delimiter1 != NULL)
{
// Remove characters after call-sign
size_t length = delimiter1 - call;
char* buffer = (char*)alloca(length + sizeof(uint32_t));
strncpy(buffer, call, length);
buffer[length] = '\0';
call = buffer;
}
if (delimiter2 != NULL)
{
// Remove characters after talker name
size_t length = delimiter2 - name;
char* buffer = (char*)alloca(length + sizeof(uint32_t));
strncpy(buffer, name, length);
buffer[length] = '\0';
name = buffer;
}
sprintf(buffer, "%s %s", call, name); uint32_t number = proxy->getPrivateIDForCall(call);
if (number == 0)
number = unknown;
setTalkerData(call, buffer); syslog(LOG_INFO, "Set talker ID to %d for call-sign %s (%s)", number, call, name);
proxy->setTalkerID(number);
proxy->setTalkerAlias(name);
} }
void BrandMeisterBridge::handleChatMessage(const char* text) void BrandMeisterBridge::handleChatMessage(const char* text)
...@@ -114,65 +130,14 @@ void BrandMeisterBridge::handleChatMessage(const char* text) ...@@ -114,65 +130,14 @@ void BrandMeisterBridge::handleChatMessage(const char* text)
if (delimiter != NULL) if (delimiter != NULL)
{ {
const char* call = delimiter + 3; const char* call = delimiter + 3;
setTalkerData(call, call); setTalker(call, call);
} }
else else
{ {
syslog(LOG_INFO, "Set talker ID to %d (call-sign is not present in chat message)", unknown); syslog(LOG_INFO, "Set talker ID to %d (call-sign was not fit into chat message)", unknown);
proxy->setTalkerID(unknown); proxy->setTalkerID(unknown);
proxy->setTalkerAlias(""); proxy->setTalkerAlias("");
} }
} }
} }
void BrandMeisterBridge::setTalkerData(const char* call, const char* name)
{
const char* delimiter1 = strpbrk(call, " -\n");
const char* delimiter2 = strchr(name, '\n');
if (delimiter1 != NULL)
{
// Remove characters after call-sign
size_t length = delimiter1 - call;
char* buffer = (char*)alloca(length + sizeof(uint32_t));
strncpy(buffer, call, length);
buffer[length] = '\0';
call = buffer;
}
if (delimiter2 != NULL)
{
// Remove characters after talker name
size_t length = delimiter2 - name;
char* buffer = (char*)alloca(length + sizeof(uint32_t));
strncpy(buffer, name, length);
buffer[length] = '\0';
name = buffer;
}
if (handle != NULL)
{
// Convert name to UTF8
size_t length1 = strlen(name);
size_t length2 = length1 * 3;
char* buffer = (char*)alloca(length2);
char* pointer1 = const_cast<char*>(name);
char* pointer2 = buffer;
iconv(handle, &pointer1, &length1, &pointer2, &length2);
*pointer2 = '\0';
name = buffer;
}
uint32_t number = proxy->getPrivateIDForCall(call);
if (number == 0)
{
// Use default value instead if ID not found
number = unknown;
}
proxy->setTalkerID(number);
proxy->setTalkerAlias(name);
syslog(LOG_INFO, "Set talker ID to %d for call-sign %s (%s)", number, call, name);
}
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#ifndef BRANDMEISTERBRIDGE_H #ifndef BRANDMEISTERBRIDGE_H
#define BRANDMEISTERBRIDGE_H #define BRANDMEISTERBRIDGE_H
#include <iconv.h>
#include "PatchCord.h" #include "PatchCord.h"
class BrandMeisterBridge class BrandMeisterBridge
...@@ -14,7 +12,6 @@ class BrandMeisterBridge ...@@ -14,7 +12,6 @@ class BrandMeisterBridge
BrandMeisterBridge(); BrandMeisterBridge();
~BrandMeisterBridge(); ~BrandMeisterBridge();
void setEncodingConfiguration(const char* configuration);
void setDefaultConfiguration(const char* configuration); void setDefaultConfiguration(const char* configuration);
void setProxyConfiguration(const char* configuration); void setProxyConfiguration(const char* configuration);
...@@ -25,12 +22,9 @@ class BrandMeisterBridge ...@@ -25,12 +22,9 @@ class BrandMeisterBridge
private: private:
PatchCord* proxy; PatchCord* proxy;
iconv_t handle;
char* talker; char* talker;
int unknown; int unknown;
void setTalkerData(const char* call, const char* name);
}; };
#endif #endif
\ No newline at end of file
...@@ -420,10 +420,6 @@ bool ModuleEchoLink::initialize(void) ...@@ -420,10 +420,6 @@ bool ModuleEchoLink::initialize(void)
{ {
bridge.setDefaultConfiguration(value.c_str()); bridge.setDefaultConfiguration(value.c_str());
} }
if (cfg().getValue(cfgName(), "BRIDGE_ENCODING", value))
{
bridge.setEncodingConfiguration(value.c_str());
}
if (cfg().getValue(cfgName(), "BRIDGE_PROXY", value)) if (cfg().getValue(cfgName(), "BRIDGE_PROXY", value))
{ {
bridge.setProxyConfiguration(value.c_str()); bridge.setProxyConfiguration(value.c_str());
......
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