Refactored plugin names #4866
This commit is contained in:
parent
b105bc8f42
commit
945ccfdb75
|
@ -39,6 +39,7 @@
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/TMethodEventJob.h"
|
#include "base/TMethodEventJob.h"
|
||||||
#include "base/TMethodJob.h"
|
#include "base/TMethodJob.h"
|
||||||
|
#include "common/PluginVersion.h"
|
||||||
#include "common/stdexcept.h"
|
#include "common/stdexcept.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -46,8 +47,6 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
static const char s_networkSecurity[] = { "ns" };
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Client
|
// Client
|
||||||
//
|
//
|
||||||
|
@ -103,7 +102,7 @@ Client::Client(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_args.m_enableCrypto) {
|
if (m_args.m_enableCrypto) {
|
||||||
m_useSecureNetwork = ARCH->plugin().exists(s_networkSecurity);
|
m_useSecureNetwork = ARCH->plugin().exists(s_pluginNames[kSecureSocket]);
|
||||||
if (m_useSecureNetwork == false) {
|
if (m_useSecureNetwork == false) {
|
||||||
LOG((CLOG_NOTE "crypto disabled because of ns plugin not available"));
|
LOG((CLOG_NOTE "crypto disabled because of ns plugin not available"));
|
||||||
}
|
}
|
||||||
|
@ -585,7 +584,7 @@ Client::cleanupStream()
|
||||||
// we need to tell the dynamic lib that allocated this object
|
// we need to tell the dynamic lib that allocated this object
|
||||||
// to do the deletion.
|
// to do the deletion.
|
||||||
if (m_useSecureNetwork) {
|
if (m_useSecureNetwork) {
|
||||||
ARCH->plugin().invoke(s_networkSecurity, "deleteSocket", NULL);
|
ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "deleteSocket", NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,11 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static const int kpluginCount = 1;
|
|
||||||
static const char kUnknownVersion[] = "unknown";
|
static const char kUnknownVersion[] = "unknown";
|
||||||
static const char* s_pluginNames[] = { "ns" };
|
|
||||||
static const char* s_pluginVersions[] = { "1.2" };
|
|
||||||
|
|
||||||
const char* getExpectedPluginVersion(const char* name)
|
const char* getExpectedPluginVersion(const char* name)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < kpluginCount; i++) {
|
for (int i = 0; i < kPluginCount; i++) {
|
||||||
if (strcmp(name, s_pluginNames[i]) == 0) {
|
if (strcmp(name, s_pluginNames[i]) == 0) {
|
||||||
return s_pluginVersions[i];
|
return s_pluginVersions[i];
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,6 +17,15 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
enum EPluginType {
|
||||||
|
kSecureSocket,
|
||||||
|
kPluginCount
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* s_pluginNames[] = { "ns" };
|
||||||
|
static const char* s_pluginVersions[] = { "1.2" };
|
||||||
|
|
||||||
|
|
||||||
//! Get expected plugin version
|
//! Get expected plugin version
|
||||||
/*!
|
/*!
|
||||||
Returns the plugin version expected by the plugin loader.
|
Returns the plugin version expected by the plugin loader.
|
||||||
|
|
|
@ -21,14 +21,13 @@
|
||||||
#include "net/TCPSocket.h"
|
#include "net/TCPSocket.h"
|
||||||
#include "net/TCPListenSocket.h"
|
#include "net/TCPListenSocket.h"
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
|
#include "common/PluginVersion.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// TCPSocketFactory
|
// TCPSocketFactory
|
||||||
//
|
//
|
||||||
|
|
||||||
static const char s_networkSecurity[] = { "ns" };
|
|
||||||
|
|
||||||
TCPSocketFactory::TCPSocketFactory(IEventQueue* events, SocketMultiplexer* socketMultiplexer) :
|
TCPSocketFactory::TCPSocketFactory(IEventQueue* events, SocketMultiplexer* socketMultiplexer) :
|
||||||
m_events(events),
|
m_events(events),
|
||||||
m_socketMultiplexer(socketMultiplexer)
|
m_socketMultiplexer(socketMultiplexer)
|
||||||
|
@ -51,7 +50,7 @@ TCPSocketFactory::create(bool secure) const
|
||||||
m_socketMultiplexer
|
m_socketMultiplexer
|
||||||
};
|
};
|
||||||
socket = static_cast<IDataSocket*>(
|
socket = static_cast<IDataSocket*>(
|
||||||
ARCH->plugin().invoke(s_networkSecurity, "getSocket", args));
|
ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "getSocket", args));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
socket = new TCPSocket(m_events, m_socketMultiplexer);
|
socket = new TCPSocket(m_events, m_socketMultiplexer);
|
||||||
|
@ -70,7 +69,7 @@ TCPSocketFactory::createListen(bool secure) const
|
||||||
m_socketMultiplexer
|
m_socketMultiplexer
|
||||||
};
|
};
|
||||||
socket = static_cast<IListenSocket*>(
|
socket = static_cast<IListenSocket*>(
|
||||||
ARCH->plugin().invoke(s_networkSecurity, "getListenSocket", args));
|
ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "getListenSocket", args));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
socket = new TCPListenSocket(m_events, m_socketMultiplexer);
|
socket = new TCPListenSocket(m_events, m_socketMultiplexer);
|
||||||
|
|
|
@ -32,7 +32,6 @@ SecureSocket* g_secureSocket = NULL;
|
||||||
SecureListenSocket* g_secureListenSocket = NULL;
|
SecureListenSocket* g_secureListenSocket = NULL;
|
||||||
Arch* g_arch = NULL;
|
Arch* g_arch = NULL;
|
||||||
Log* g_log = NULL;
|
Log* g_log = NULL;
|
||||||
static const char kPluginName[] = "ns";
|
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
helperGetLibsUsed(void)
|
helperGetLibsUsed(void)
|
||||||
|
@ -107,7 +106,7 @@ invoke(const char* command, void** args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(command, "version") == 0) {
|
else if (strcmp(command, "version") == 0) {
|
||||||
return (void*)getExpectedPluginVersion(kPluginName);
|
return (void*)getExpectedPluginVersion(s_pluginNames[kSecureSocket]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "net/IListenSocket.h"
|
#include "net/IListenSocket.h"
|
||||||
#include "net/ISocketFactory.h"
|
#include "net/ISocketFactory.h"
|
||||||
#include "net/XSocket.h"
|
#include "net/XSocket.h"
|
||||||
|
#include "common/PluginVersion.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/TMethodEventJob.h"
|
#include "base/TMethodEventJob.h"
|
||||||
|
@ -33,8 +34,6 @@
|
||||||
// ClientListener
|
// ClientListener
|
||||||
//
|
//
|
||||||
|
|
||||||
static const char s_networkSecurity[] = { "ns" };
|
|
||||||
|
|
||||||
ClientListener::ClientListener(const NetworkAddress& address,
|
ClientListener::ClientListener(const NetworkAddress& address,
|
||||||
ISocketFactory* socketFactory,
|
ISocketFactory* socketFactory,
|
||||||
IEventQueue* events,
|
IEventQueue* events,
|
||||||
|
@ -49,7 +48,7 @@ ClientListener::ClientListener(const NetworkAddress& address,
|
||||||
try {
|
try {
|
||||||
// create listen socket
|
// create listen socket
|
||||||
if (enableCrypto) {
|
if (enableCrypto) {
|
||||||
m_useSecureNetwork = ARCH->plugin().exists(s_networkSecurity);
|
m_useSecureNetwork = ARCH->plugin().exists(s_pluginNames[kSecureSocket]);
|
||||||
if (m_useSecureNetwork == false) {
|
if (m_useSecureNetwork == false) {
|
||||||
LOG((CLOG_NOTE "crypto disabled because of ns plugin not available"));
|
LOG((CLOG_NOTE "crypto disabled because of ns plugin not available"));
|
||||||
}
|
}
|
||||||
|
@ -249,7 +248,7 @@ ClientListener::cleanupListenSocket()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ARCH->plugin().invoke(
|
ARCH->plugin().invoke(
|
||||||
s_networkSecurity,
|
s_pluginNames[kSecureSocket],
|
||||||
"deleteListenSocket",
|
"deleteListenSocket",
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue