From 41c2933a5ab2a2592a8d4dffb91b6db3a02f3c9b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Jul 2014 16:21:31 +0200 Subject: rename file so that name makes any sense --- facetracknoir/facetracknoir.h | 2 +- facetracknoir/global-settings.cpp | 136 -------------------------------------- facetracknoir/global-settings.h | 93 -------------------------- facetracknoir/plugin-support.cpp | 136 ++++++++++++++++++++++++++++++++++++++ facetracknoir/plugin-support.h | 93 ++++++++++++++++++++++++++ facetracknoir/tracker.h | 2 +- 6 files changed, 231 insertions(+), 231 deletions(-) delete mode 100644 facetracknoir/global-settings.cpp delete mode 100644 facetracknoir/global-settings.h create mode 100644 facetracknoir/plugin-support.cpp create mode 100644 facetracknoir/plugin-support.h (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 192b00b6..ca8084c2 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -55,7 +55,7 @@ using namespace options; #include "facetracknoir/main-settings.hpp" -#include "global-settings.h" +#include "facetracknoir/plugin-support.h" #include "tracker.h" #include "facetracknoir/shortcuts.h" diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp deleted file mode 100644 index 9c84945b..00000000 --- a/facetracknoir/global-settings.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "global-settings.h" - -#if !(defined(_WIN32)) -# include -#endif - -SelectedLibraries* Libraries = NULL; - -SelectedLibraries::~SelectedLibraries() -{ - if (pTracker) { - delete pTracker; - pTracker = NULL; - } - - if (pSecondTracker) { - delete pSecondTracker; - pSecondTracker = NULL; - } - - if (pFilter) - delete pFilter; - - if (pProtocol) - delete pProtocol; -} - -SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : - pTracker(NULL), pSecondTracker(NULL), pFilter(NULL), pProtocol(NULL) -{ - correct = false; - if (!mainApp) - return; - CTOR_FUNPTR ptr; - DynamicLibrary* lib; - - lib = mainApp->current_tracker1(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pTracker = (ITracker*) ptr(); - } - - lib = mainApp->current_tracker2(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pSecondTracker = (ITracker*) ptr(); - } - - lib = mainApp->current_protocol(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pProtocol = (IProtocol*) ptr(); - } - - lib = mainApp->current_filter(); - - if (lib && lib->Constructor) { - ptr = (CTOR_FUNPTR) lib->Constructor; - pFilter = (IFilter*) ptr(); - } - - // Check if the Protocol-server files were installed OK. - // Some servers also create a memory-mapping, for Inter Process Communication. - // The handle of the MainWindow is sent to 'The Game', so it can send a message back. - - if (pProtocol) - if(!pProtocol->checkServerInstallationOK()) - return; - - // retrieve pointers to the User Interface and the main Application - if (pTracker) { - pTracker->StartTracker( mainApp->get_video_widget() ); - } - if (pSecondTracker) { - pSecondTracker->StartTracker( mainApp->get_video_widget() ); - } - - correct = true; -} - -DynamicLibrary::DynamicLibrary(const QString& filename) -{ - this->filename = filename; -#if defined(_WIN32) - QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; - handle = new QLibrary(fullPath); - qDebug() << handle->errorString(); - Dialog = (SETTINGS_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); - Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); - Metadata = (METADATA_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); - qDebug() << handle->errorString(); -#else - QByteArray latin1 = QFile::encodeName(filename); - handle = dlopen(latin1.constData(), RTLD_NOW | -# ifdef __linux - RTLD_DEEPBIND -# elif defined(__APPLE__) - RTLD_LOCAL|RTLD_FIRST|RTLD_NOW -# else - 0 -# endif - ); - if (handle) - { - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - Dialog = (DIALOG_FUNPTR) dlsym(handle, "GetDialog"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - Constructor = (CTOR_FUNPTR) dlsym(handle, "GetConstructor"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - Metadata = (METADATA_FUNPTR) dlsym(handle, "GetMetadata"); - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - } else { - fprintf(stderr, "Error, if any: %s\n", dlerror()); - fflush(stderr); - } -#endif -} - -DynamicLibrary::~DynamicLibrary() -{ -#if defined(_WIN32) - handle->unload(); -#else - if (handle) - (void) dlclose(handle); -#endif -} diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h deleted file mode 100644 index 4394d1a0..00000000 --- a/facetracknoir/global-settings.h +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - -#if defined(_WIN32) -# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "@0" -# ifdef _MSC_VER -# define MAYBE_STDCALL_UNDERSCORE "_" -#else -# define MAYBE_STDCALL_UNDERSCORE "" -# endif -#else -# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "" -# define MAYBE_STDCALL_UNDERSCORE "" -#endif - -#ifdef _MSC_VER -# define virt_override -#else -# define virt_override override -#endif - -#include - -#include -#include -#include -#include -#include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_filter_base/ftnoir_filter_base.h" -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" - -#if defined(_WIN32) -# define CALLING_CONVENTION __stdcall -#else -# define CALLING_CONVENTION -#endif - -class IDynamicLibraryProvider; - -struct SelectedLibraries { -public: - ITracker* pTracker; - ITracker* pSecondTracker; - IFilter* pFilter; - IProtocol* pProtocol; - SelectedLibraries(IDynamicLibraryProvider* main = NULL); - ~SelectedLibraries(); - bool correct; -}; - -extern SelectedLibraries* Libraries; - -struct Metadata; - -extern "C" typedef void* (CALLING_CONVENTION * CTOR_FUNPTR)(void); -extern "C" typedef Metadata* (CALLING_CONVENTION* METADATA_FUNPTR)(void); -extern "C" typedef void* (CALLING_CONVENTION* DIALOG_FUNPTR)(void); - -class DynamicLibrary { -public: - DynamicLibrary(const QString& filename); - virtual ~DynamicLibrary(); - DIALOG_FUNPTR Dialog; - CTOR_FUNPTR Constructor; - METADATA_FUNPTR Metadata; - QString filename; -private: -#if defined(_WIN32) - QLibrary* handle; -#else - void* handle; -#endif -}; - -struct Metadata -{ - Metadata() {} - virtual ~Metadata() {} - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; - -class IDynamicLibraryProvider { -public: - virtual DynamicLibrary* current_tracker1() = 0; - virtual DynamicLibrary* current_tracker2() = 0; - virtual DynamicLibrary* current_protocol() = 0; - virtual DynamicLibrary* current_filter() = 0; - virtual QFrame* get_video_widget() = 0; -}; diff --git a/facetracknoir/plugin-support.cpp b/facetracknoir/plugin-support.cpp new file mode 100644 index 00000000..09e1c200 --- /dev/null +++ b/facetracknoir/plugin-support.cpp @@ -0,0 +1,136 @@ +#include "plugin-support.h" + +#if !(defined(_WIN32)) +# include +#endif + +SelectedLibraries* Libraries = NULL; + +SelectedLibraries::~SelectedLibraries() +{ + if (pTracker) { + delete pTracker; + pTracker = NULL; + } + + if (pSecondTracker) { + delete pSecondTracker; + pSecondTracker = NULL; + } + + if (pFilter) + delete pFilter; + + if (pProtocol) + delete pProtocol; +} + +SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : + pTracker(NULL), pSecondTracker(NULL), pFilter(NULL), pProtocol(NULL) +{ + correct = false; + if (!mainApp) + return; + CTOR_FUNPTR ptr; + DynamicLibrary* lib; + + lib = mainApp->current_tracker1(); + + if (lib && lib->Constructor) { + ptr = (CTOR_FUNPTR) lib->Constructor; + pTracker = (ITracker*) ptr(); + } + + lib = mainApp->current_tracker2(); + + if (lib && lib->Constructor) { + ptr = (CTOR_FUNPTR) lib->Constructor; + pSecondTracker = (ITracker*) ptr(); + } + + lib = mainApp->current_protocol(); + + if (lib && lib->Constructor) { + ptr = (CTOR_FUNPTR) lib->Constructor; + pProtocol = (IProtocol*) ptr(); + } + + lib = mainApp->current_filter(); + + if (lib && lib->Constructor) { + ptr = (CTOR_FUNPTR) lib->Constructor; + pFilter = (IFilter*) ptr(); + } + + // Check if the Protocol-server files were installed OK. + // Some servers also create a memory-mapping, for Inter Process Communication. + // The handle of the MainWindow is sent to 'The Game', so it can send a message back. + + if (pProtocol) + if(!pProtocol->checkServerInstallationOK()) + return; + + // retrieve pointers to the User Interface and the main Application + if (pTracker) { + pTracker->StartTracker( mainApp->get_video_widget() ); + } + if (pSecondTracker) { + pSecondTracker->StartTracker( mainApp->get_video_widget() ); + } + + correct = true; +} + +DynamicLibrary::DynamicLibrary(const QString& filename) +{ + this->filename = filename; +#if defined(_WIN32) + QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; + handle = new QLibrary(fullPath); + qDebug() << handle->errorString(); + Dialog = (SETTINGS_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); + Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); + Metadata = (METADATA_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); + qDebug() << handle->errorString(); +#else + QByteArray latin1 = QFile::encodeName(filename); + handle = dlopen(latin1.constData(), RTLD_NOW | +# ifdef __linux + RTLD_DEEPBIND +# elif defined(__APPLE__) + RTLD_LOCAL|RTLD_FIRST|RTLD_NOW +# else + 0 +# endif + ); + if (handle) + { + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + Dialog = (DIALOG_FUNPTR) dlsym(handle, "GetDialog"); + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + Constructor = (CTOR_FUNPTR) dlsym(handle, "GetConstructor"); + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + Metadata = (METADATA_FUNPTR) dlsym(handle, "GetMetadata"); + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + } else { + fprintf(stderr, "Error, if any: %s\n", dlerror()); + fflush(stderr); + } +#endif +} + +DynamicLibrary::~DynamicLibrary() +{ +#if defined(_WIN32) + handle->unload(); +#else + if (handle) + (void) dlclose(handle); +#endif +} diff --git a/facetracknoir/plugin-support.h b/facetracknoir/plugin-support.h new file mode 100644 index 00000000..4394d1a0 --- /dev/null +++ b/facetracknoir/plugin-support.h @@ -0,0 +1,93 @@ +#pragma once + +#if defined(_WIN32) +# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "@0" +# ifdef _MSC_VER +# define MAYBE_STDCALL_UNDERSCORE "_" +#else +# define MAYBE_STDCALL_UNDERSCORE "" +# endif +#else +# define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "" +# define MAYBE_STDCALL_UNDERSCORE "" +#endif + +#ifdef _MSC_VER +# define virt_override +#else +# define virt_override override +#endif + +#include + +#include +#include +#include +#include +#include +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ftnoir_filter_base/ftnoir_filter_base.h" +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" + +#if defined(_WIN32) +# define CALLING_CONVENTION __stdcall +#else +# define CALLING_CONVENTION +#endif + +class IDynamicLibraryProvider; + +struct SelectedLibraries { +public: + ITracker* pTracker; + ITracker* pSecondTracker; + IFilter* pFilter; + IProtocol* pProtocol; + SelectedLibraries(IDynamicLibraryProvider* main = NULL); + ~SelectedLibraries(); + bool correct; +}; + +extern SelectedLibraries* Libraries; + +struct Metadata; + +extern "C" typedef void* (CALLING_CONVENTION * CTOR_FUNPTR)(void); +extern "C" typedef Metadata* (CALLING_CONVENTION* METADATA_FUNPTR)(void); +extern "C" typedef void* (CALLING_CONVENTION* DIALOG_FUNPTR)(void); + +class DynamicLibrary { +public: + DynamicLibrary(const QString& filename); + virtual ~DynamicLibrary(); + DIALOG_FUNPTR Dialog; + CTOR_FUNPTR Constructor; + METADATA_FUNPTR Metadata; + QString filename; +private: +#if defined(_WIN32) + QLibrary* handle; +#else + void* handle; +#endif +}; + +struct Metadata +{ + Metadata() {} + virtual ~Metadata() {} + + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; + virtual void getIcon(QIcon *icon) = 0; +}; + +class IDynamicLibraryProvider { +public: + virtual DynamicLibrary* current_tracker1() = 0; + virtual DynamicLibrary* current_tracker2() = 0; + virtual DynamicLibrary* current_protocol() = 0; + virtual DynamicLibrary* current_filter() = 0; + virtual QFrame* get_video_widget() = 0; +}; diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 46440c32..49e7f302 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -10,7 +10,7 @@ #include #include #include -#include "global-settings.h" +#include "plugin-support.h" #include #include -- cgit v1.2.3