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