diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-08-31 13:53:45 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-08-31 13:57:37 +0200 |
commit | 95a88d4ae96f319a50d8f14a3b8728b89ed1eb8a (patch) | |
tree | b1a62f0b0adc313c60e33bbf429029ab821bbedc /opentrack-api/context.cpp | |
parent | 369d744a705501c7445b7a530afde2d87b5bbff3 (diff) |
remove opentrack-api, no consumers
Diffstat (limited to 'opentrack-api/context.cpp')
-rw-r--r-- | opentrack-api/context.cpp | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp deleted file mode 100644 index b706ad3a..00000000 --- a/opentrack-api/context.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "opentrack-guts.h" -#include "opentrack.h" - -#if defined(__APPLE__) -# define SONAME "dylib" -#elif defined(_WIN32) -# define SONAME "dll" -#else -# define SONAME "so" -#endif - -#include <iostream> - -#ifdef _MSC_VER -# error "MSVC support removed" -#else -# define LIB_PREFIX "lib" -#endif - -static Metadata* get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) -{ - Metadata* meta; - if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) - return NULL; - meta->getFullName(&longName); - meta->getIcon(&icon); - return meta; -} - -static QList<opentrack_meta> list_files(QString filter) -{ - QList<opentrack_meta> ret; - QStringList filenames = QDir((qApp->applicationDirPath())).entryList( - QStringList() << (LIB_PREFIX + filter + ("*." SONAME)), - QDir::Files, QDir::Name ); - for ( int i = 0; i < filenames.size(); i++) { - QIcon icon; - QString long_name; - QString str = filenames.at(i); - DynamicLibrary* lib = new DynamicLibrary(str); - qDebug() << "Loading" << str; - std::cout.flush(); - Metadata* meta; - if (!(meta = get_metadata(lib, long_name, icon))) - { - delete lib; - continue; - } - /* TODO perhaps return full name and somesuch */ - delete meta; - QString prefix(LIB_PREFIX + filter); - QString suffix("." SONAME); - if (str.size() > prefix.size() + suffix.size() && str.startsWith(prefix) && str.endsWith(suffix)) - { - auto str2 = str.mid(prefix.size(), str.size() - prefix.size() - suffix.size()); - opentrack_meta item(str2, lib); - ret.push_back(item); - } - } - - return ret; -} - -opentrack_ctx::opentrack_ctx(int argc, char** argv, void* window_parent) : - app(argc, argv), - meta_list(list_files("opentrack-tracker-")), - fake_frame(window_parent) -{ - const int count = meta_list.size(); - list = new char*[count + 1]; - for (int i = 0; i < count; i++) - { - QByteArray tmp = meta_list.at(i).path.toUtf8(); - int len = tmp.size(); - auto foo = new char[len+1]; - for (int j = 0; j < len; j++) - foo[j] = tmp.at(j); - foo[len] = '\0'; - list[i] = foo; - } - list[count] = NULL; -} - -opentrack_ctx::~opentrack_ctx() -{ - for (int i = 0; list[i]; i++) - { - delete[] list[i]; - } - delete[] list; -} - -extern "C" -{ - -OPENTRACK_EXPORT const char** opentrack_enum_trackers(opentrack ctx) -{ - return const_cast<const char**>(ctx->list); -} - -OPENTRACK_EXPORT opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent) -{ - return new opentrack_ctx(argc, argv, window_parent); -} - -OPENTRACK_EXPORT void opentrack_finalize_ctx(opentrack foo) -{ - delete foo; -} - -} - |