diff --git a/libfreerdp/core/CMakeLists.txt b/libfreerdp/core/CMakeLists.txt index 4337f095a..14a3e3e62 100644 --- a/libfreerdp/core/CMakeLists.txt +++ b/libfreerdp/core/CMakeLists.txt @@ -52,8 +52,6 @@ set(${MODULE_PREFIX}_SRCS bulk.h activation.c activation.h - extension.c - extension.h gcc.c gcc.h mcs.c diff --git a/libfreerdp/core/extension.c b/libfreerdp/core/extension.c deleted file mode 100644 index ce062fe57..000000000 --- a/libfreerdp/core/extension.c +++ /dev/null @@ -1,233 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * FreeRDP Extension Plugin Interface - * - * Copyright 2010-2011 Vic Lee - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include - -#include - -#include "extension.h" - -#ifdef _WIN32 -#define DLOPEN(f) LoadLibraryA(f) -#define DLSYM(f, n) GetProcAddress(f, n) -#define DLCLOSE(f) FreeLibrary(f) -#define PATH_SEPARATOR '\\' -#define PLUGIN_EXT "dll" -#else -#include -#define DLOPEN(f) dlopen(f, RTLD_LOCAL | RTLD_LAZY) -#define DLSYM(f, n) dlsym(f, n) -#define DLCLOSE(f) dlclose(f) -#define PATH_SEPARATOR '/' - -#ifdef __APPLE__ -#define PLUGIN_EXT "dylib" -#else -#define PLUGIN_EXT "so" -#endif - -#endif - -static UINT32 FREERDP_CC extension_register_plugin(rdpExtPlugin* plugin) -{ - rdpExtension* ext = (rdpExtension*) plugin->ext; - - if (ext->num_plugins >= FREERDP_EXT_MAX_COUNT) - { - fprintf(stderr, "extension_register_extension: maximum number of plugins reached.\n"); - return 1; - } - - ext->plugins[ext->num_plugins++] = plugin; - return 0; -} - -static UINT32 FREERDP_CC extension_register_pre_connect_hook(rdpExtPlugin* plugin, PFREERDP_EXTENSION_HOOK hook) -{ - rdpExtension* ext = (rdpExtension*) plugin->ext; - - if (ext->num_pre_connect_hooks >= FREERDP_EXT_MAX_COUNT) - { - fprintf(stderr, "extension_register_pre_connect_hook: maximum plugin reached.\n"); - return 1; - } - - ext->pre_connect_hooks[ext->num_pre_connect_hooks] = hook; - ext->pre_connect_hooks_instances[ext->num_pre_connect_hooks] = plugin; - ext->num_pre_connect_hooks++; - return 0; -} - -static UINT32 FREERDP_CC extension_register_post_connect_hook(rdpExtPlugin* plugin, PFREERDP_EXTENSION_HOOK hook) -{ - rdpExtension* ext = (rdpExtension*) plugin->ext; - - if (ext->num_post_connect_hooks >= FREERDP_EXT_MAX_COUNT) - { - fprintf(stderr, "extension_register_post_connect_hook: maximum plugin reached.\n"); - return 1; - } - - ext->post_connect_hooks[ext->num_post_connect_hooks] = hook; - ext->post_connect_hooks_instances[ext->num_post_connect_hooks] = plugin; - ext->num_post_connect_hooks++; - - return 0; -} - -static int extension_load_plugins(rdpExtension* extension) -{ - int i; - void* han; - char path[256]; - rdpSettings* settings; - PFREERDP_EXTENSION_ENTRY entry; - FREERDP_EXTENSION_ENTRY_POINTS entryPoints; - - settings = extension->instance->settings; - - entryPoints.ext = extension; - entryPoints.pRegisterExtension = extension_register_plugin; - entryPoints.pRegisterPreConnectHook = extension_register_pre_connect_hook; - entryPoints.pRegisterPostConnectHook = extension_register_post_connect_hook; - - for (i = 0; settings->extensions[i].name[0]; i++) - { - if (strchr(settings->extensions[i].name, PATH_SEPARATOR) == NULL) - sprintf_s(path, sizeof(path), EXT_PATH "/%s." PLUGIN_EXT, settings->extensions[i].name); - else - sprintf_s(path, sizeof(path), "%s", settings->extensions[i].name); - - han = DLOPEN(path); - fprintf(stderr, "extension_load_plugins: %s\n", path); - - if (han == NULL) - { - fprintf(stderr, "extension_load_plugins: failed to load %s\n", path); - continue; - } - - entry = (PFREERDP_EXTENSION_ENTRY) DLSYM(han, FREERDP_EXT_EXPORT_FUNC_NAME); - if (entry == NULL) - { - DLCLOSE(han); - fprintf(stderr, "extension_load_plugins: failed to find export function in %s\n", path); - continue; - } - - entryPoints.data = extension->instance->settings->extensions[i].data; - if (entry(&entryPoints) != 0) - { - DLCLOSE(han); - fprintf(stderr, "extension_load_plugins: %s entry returns error.\n", path); - continue; - } - - DLCLOSE(han); - } - - return 0; -} - -static int extension_init_plugins(rdpExtension* extension) -{ - int i; - - for (i = 0; i < extension->num_plugins; i++) - extension->plugins[i]->init(extension->plugins[i], extension->instance); - - return 0; -} - -static int extension_uninit_plugins(rdpExtension* extension) -{ - int i; - - for (i = 0; i < extension->num_plugins; i++) - extension->plugins[i]->uninit(extension->plugins[i], extension->instance); - - return 0; -} - -/** Gets through all registered pre-connect hooks and executes them. - * @param extension - pointer to a rdpExtension structure - * @return 0 always - */ -int extension_pre_connect(rdpExtension* extension) -{ - int i; - - for (i = 0; i < extension->num_pre_connect_hooks; i++) - extension->pre_connect_hooks[i](extension->pre_connect_hooks_instances[i], extension->instance); - - return 0; -} - -/** Gets through all registered post-connect hooks and executes them. - * @param extension - pointer to a rdpExtension structure - * @return 0 always - */ -int extension_post_connect(rdpExtension* ext) -{ - int i; - - for (i = 0; i < ext->num_post_connect_hooks; i++) - ext->post_connect_hooks[i](ext->post_connect_hooks_instances[i], ext->instance); - - return 0; -} - -void extension_load_and_init_plugins(rdpExtension* extension) -{ - extension_load_plugins(extension); - extension_init_plugins(extension); -} - -rdpExtension* extension_new(freerdp* instance) -{ - rdpExtension* extension = NULL; - - if (instance != NULL) - { - extension = (rdpExtension*) malloc(sizeof(rdpExtension)); - ZeroMemory(extension, sizeof(rdpExtension)); - - extension->instance = instance; - } - - return extension; -} - -void extension_free(rdpExtension* extension) -{ - if (extension != NULL) - { - extension_uninit_plugins(extension); - free(extension); - } -} diff --git a/libfreerdp/core/extension.h b/libfreerdp/core/extension.h deleted file mode 100644 index 1ee35ea3d..000000000 --- a/libfreerdp/core/extension.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * FreeRDP Extension Plugin Interface - * - * Copyright 2010-2011 Vic Lee - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __EXTENSION_H -#define __EXTENSION_H - -#include - -#include -#include -#include - -#define FREERDP_EXT_MAX_COUNT 16 - -struct rdp_extension -{ - freerdp* instance; - rdpExtPlugin* plugins[FREERDP_EXT_MAX_COUNT]; - int num_plugins; - PFREERDP_EXTENSION_HOOK pre_connect_hooks[FREERDP_EXT_MAX_COUNT]; - rdpExtPlugin* pre_connect_hooks_instances[FREERDP_EXT_MAX_COUNT]; - int num_pre_connect_hooks; - PFREERDP_EXTENSION_HOOK post_connect_hooks[FREERDP_EXT_MAX_COUNT]; - rdpExtPlugin* post_connect_hooks_instances[FREERDP_EXT_MAX_COUNT]; - int num_post_connect_hooks; -}; -typedef struct rdp_extension rdpExtension; - -FREERDP_API int extension_pre_connect(rdpExtension* extension); -FREERDP_API int extension_post_connect(rdpExtension* extension); - -FREERDP_API rdpExtension* extension_new(freerdp* instance); -FREERDP_API void extension_free(rdpExtension* extension); -FREERDP_API void extension_load_and_init_plugins(rdpExtension* extension); - -#endif /* __EXTENSION_H */ - diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index e94882577..d2aca2f58 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -27,7 +27,6 @@ #include "surface.h" #include "transport.h" #include "connection.h" -#include "extension.h" #include "message.h" #include @@ -79,9 +78,6 @@ BOOL freerdp_connect(freerdp* instance) settings->KeyboardFunctionKey = 12; } - extension_load_and_init_plugins(rdp->extension); - extension_pre_connect(rdp->extension); - if (!status) { if (!connectErrorCode) @@ -117,8 +113,6 @@ BOOL freerdp_connect(freerdp* instance) instance->update->dump_rfx = TRUE; } - extension_post_connect(rdp->extension); - IFCALLRET(instance->PostConnect, status, instance); update_post_connect(instance->update); diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 05f0b8e12..1fcd13f90 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -1223,16 +1223,14 @@ rdpRdp* rdp_new(rdpContext* context) rdp->settings = context->settings; rdp->settings->instance = context->instance; + if (context->instance) context->instance->settings = rdp->settings; - rdp->extension = extension_new(context->instance); - if (!rdp->extension) - goto out_free_settings; - rdp->transport = transport_new(rdp->settings); if (!rdp->transport) - goto out_free_extension; + goto out_free_settings; + rdp->transport->rdp = rdp; rdp->license = license_new(rdp); @@ -1303,8 +1301,6 @@ out_free_license: license_free(rdp->license); out_free_transport: transport_free(rdp->transport); -out_free_extension: - extension_free(rdp->extension); out_free_settings: if (newSettings) freerdp_settings_free(rdp->settings); @@ -1368,7 +1364,6 @@ void rdp_free(rdpRdp* rdp) crypto_hmac_free(rdp->fips_hmac); freerdp_settings_free(rdp->settings); freerdp_settings_free(rdp->settingsCopy); - extension_free(rdp->extension); transport_free(rdp->transport); license_free(rdp->license); input_free(rdp->input); diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index 3514e8101..f830e737b 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -34,7 +34,6 @@ #include "update.h" #include "license.h" #include "errinfo.h" -#include "extension.h" #include "autodetect.h" #include "heartbeat.h" #include "multitransport.h" @@ -138,7 +137,6 @@ struct rdp_rdp rdpRedirection* redirection; rdpSettings* settings; rdpTransport* transport; - rdpExtension* extension; rdpAutoDetect* autodetect; rdpHeartbeat* heartbeat; rdpMultitransport* multitransport;