Browse Source

Bumped OpenGL require from 3.2 to 2.0, fixed plugin loading on win and mac, added licenses for new libraries

tags/v0.3.0
Andrew Belt 7 years ago
parent
commit
2fd04a764e
8 changed files with 240 additions and 79 deletions
  1. +151
    -0
      LICENSE-dist.txt
  2. +5
    -4
      Makefile
  3. +1
    -1
      src/app.cpp
  4. +1
    -1
      src/app/ModuleWidget.cpp
  5. +7
    -7
      src/app/Toolbar.cpp
  6. +18
    -12
      src/gui.cpp
  7. +55
    -53
      src/plugin.cpp
  8. +2
    -1
      src/widgets/FramebufferWidget.cpp

+ 151
- 0
LICENSE-dist.txt View File

@@ -235,3 +235,154 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# curl

Copyright (c) 1996 - 2017, Daniel Stenberg, daniel@haxx.se, and many contributors, see the THANKS file.

All rights reserved.

Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.


# libzip

Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner

The authors can be contacted at <libzip@nih.at>

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# OpenSSL

OpenSSL License
---------------

/* ====================================================================
* Copyright (c) 1998-2017 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* openssl-core@openssl.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/

Original SSLeay License
-----------------------

/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/


+ 5
- 4
Makefile View File

@@ -19,7 +19,7 @@ endif
ifeq ($(ARCH), mac) ifeq ($(ARCH), mac)
SOURCES += ext/noc/noc_file_dialog.m SOURCES += ext/noc/noc_file_dialog.m
CFLAGS += -DNOC_FILE_DIALOG_OSX CFLAGS += -DNOC_FILE_DIALOG_OSX
CXXFLAGS += -DAPPLE -stdlib=libc++ -I$(HOME)/local/include
CXXFLAGS += -DAPPLE -stdlib=libc++ -I$(HOME)/local/include -I/usr/local/lib/libzip/include
LDFLAGS += -stdlib=libc++ -L$(HOME)/local/lib -lpthread -lglew -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -ldl -ljansson -lportaudio -lportmidi -lsamplerate -lcurl -lzip LDFLAGS += -stdlib=libc++ -L$(HOME)/local/lib -lpthread -lglew -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -ldl -ljansson -lportaudio -lportmidi -lsamplerate -lcurl -lzip
TARGET = Rack TARGET = Rack
endif endif
@@ -28,12 +28,13 @@ ifeq ($(ARCH), win)
SOURCES += ext/noc/noc_file_dialog.c SOURCES += ext/noc/noc_file_dialog.c
CFLAGS += -DNOC_FILE_DIALOG_WIN32 CFLAGS += -DNOC_FILE_DIALOG_WIN32
CXXFLAGS += -DGLEW_STATIC \ CXXFLAGS += -DGLEW_STATIC \
-I$(HOME)/pkg/portaudio-r1891-build/include
-I$(HOME)/pkg/portaudio-r1891-build/include -I/mingw64/lib/libzip/include -I$(HOME)/local/include
LDFLAGS += \ LDFLAGS += \
-Wl,-Bstatic,--whole-archive \ -Wl,-Bstatic,--whole-archive \
-lglfw3 -lgdi32 -lglew32 -ljansson -lsamplerate -lcurl -lzip \
-ljansson -lsamplerate \
-Wl,-Bdynamic,--no-whole-archive \ -Wl,-Bdynamic,--no-whole-archive \
-lpthread -lopengl32 -lcomdlg32 -lole32 \
-lpthread -lglfw3 -lgdi32 -lglew32 -lopengl32 -lcomdlg32 -lole32 -lzip \
-L $(HOME)/local/lib -lcurl \
-lportmidi \ -lportmidi \
-L$(HOME)/pkg/portaudio-r1891-build/lib/x64/ReleaseMinDependency -lportaudio_x64 \ -L$(HOME)/pkg/portaudio-r1891-build/lib/x64/ReleaseMinDependency -lportaudio_x64 \
-Wl,--export-all-symbols,--out-implib,libRack.a -mwindows -Wl,--export-all-symbols,--out-implib,libRack.a -mwindows


+ 1
- 1
src/app.cpp View File

@@ -4,7 +4,7 @@
namespace rack { namespace rack {


std::string gApplicationName = "VCV Rack"; std::string gApplicationName = "VCV Rack";
std::string gApplicationVersion = "v0.2.0 alpha";
std::string gApplicationVersion = "v0.2.1 alpha";


RackWidget *gRackWidget = NULL; RackWidget *gRackWidget = NULL;




+ 1
- 1
src/app/ModuleWidget.cpp View File

@@ -183,7 +183,7 @@ void ModuleWidget::onMouseDown(int button) {
menu->pushChild(menuLabel); menu->pushChild(menuLabel);


ResetParamsMenuItem *resetItem = new ResetParamsMenuItem(); ResetParamsMenuItem *resetItem = new ResetParamsMenuItem();
resetItem->text = "Initialize parameters";
resetItem->text = "Initialize";
resetItem->moduleWidget = this; resetItem->moduleWidget = this;
menu->pushChild(resetItem); menu->pushChild(resetItem);




+ 7
- 7
src/app/Toolbar.cpp View File

@@ -156,13 +156,13 @@ Toolbar::Toolbar() {
xPos += cpuUsageButton->box.size.x; xPos += cpuUsageButton->box.size.x;
} }


xPos += margin;
{
Widget *pluginManager = new PluginManagerWidget();
pluginManager->box.pos = Vec(xPos, margin);
addChild(pluginManager);
xPos += pluginManager->box.size.x;
}
// xPos += margin;
// {
// Widget *pluginManager = new PluginManagerWidget();
// pluginManager->box.pos = Vec(xPos, margin);
// addChild(pluginManager);
// xPos += pluginManager->box.size.x;
// }
} }


void Toolbar::draw(NVGcontext *vg) { void Toolbar::draw(NVGcontext *vg) {


+ 18
- 12
src/gui.cpp View File

@@ -6,9 +6,11 @@
#include "gui.hpp" #include "gui.hpp"
#include "app.hpp" #include "app.hpp"


// #define NANOVG_GL2_IMPLEMENTATION
#define NANOVG_GL3_IMPLEMENTATION
#define NANOVG_GL2_IMPLEMENTATION
// #define NANOVG_GL3_IMPLEMENTATION
#include "../ext/nanovg/src/nanovg_gl.h" #include "../ext/nanovg/src/nanovg_gl.h"
// Hack to get framebuffer objects working on OpenGL 2 (we blindly assume the extension is supported)
#define NANOVG_FBO_VALID 1
#include "../ext/nanovg/src/nanovg_gl_utils.h" #include "../ext/nanovg/src/nanovg_gl_utils.h"
#define BLENDISH_IMPLEMENTATION #define BLENDISH_IMPLEMENTATION
#include "../ext/oui/blendish.h" #include "../ext/oui/blendish.h"
@@ -189,12 +191,12 @@ void guiInit() {
err = glfwInit(); err = glfwInit();
assert(err); assert(err);


// glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
// glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
// glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
// glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
// glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
// glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
std::string title = gApplicationName + " " + gApplicationVersion; std::string title = gApplicationName + " " + gApplicationVersion;
window = glfwCreateWindow(1000, 750, title.c_str(), NULL, NULL); window = glfwCreateWindow(1000, 750, title.c_str(), NULL, NULL);
assert(window); assert(window);
@@ -214,14 +216,18 @@ void guiInit() {
glewExperimental = GL_TRUE; glewExperimental = GL_TRUE;
err = glewInit(); err = glewInit();
assert(err == GLEW_OK); assert(err == GLEW_OK);

// Check framebuffer support
assert(GLEW_EXT_framebuffer_object);

// GLEW generates GL error because it calls glGetString(GL_EXTENSIONS), we'll consume it here. // GLEW generates GL error because it calls glGetString(GL_EXTENSIONS), we'll consume it here.
glGetError(); glGetError();


glfwSetWindowSizeLimits(window, 240, 160, GLFW_DONT_CARE, GLFW_DONT_CARE); glfwSetWindowSizeLimits(window, 240, 160, GLFW_DONT_CARE, GLFW_DONT_CARE);


// Set up NanoVG // Set up NanoVG
// gVg = nvgCreateGL2(NVG_ANTIALIAS);
gVg = nvgCreateGL3(NVG_ANTIALIAS);
gVg = nvgCreateGL2(NVG_ANTIALIAS);
// gVg = nvgCreateGL3(NVG_ANTIALIAS);
assert(gVg); assert(gVg);


// Set up Blendish // Set up Blendish
@@ -232,8 +238,8 @@ void guiInit() {


void guiDestroy() { void guiDestroy() {
defaultFont.reset(); defaultFont.reset();
// nvgDeleteGL2(gVg);
nvgDeleteGL3(gVg);
nvgDeleteGL2(gVg);
// nvgDeleteGL3(gVg);
glfwDestroyWindow(window); glfwDestroyWindow(window);
glfwTerminate(); glfwTerminate();
} }


+ 55
- 53
src/plugin.cpp View File

@@ -5,19 +5,22 @@
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/param.h> // for MAXPATHLEN
#include <fcntl.h> #include <fcntl.h>


#if defined(WINDOWS)
#include <windows.h>
#elif defined(LINUX) || defined(APPLE)
#include <dlfcn.h>
#include <glob.h>
#endif

#include <curl/curl.h> #include <curl/curl.h>
#include <zip.h> #include <zip.h>
#include <jansson.h> #include <jansson.h>


#if defined(WINDOWS)
#include <windows.h>
#include <shellapi.h>
#include <direct.h>
#define mkdir(_dir, _perms) _mkdir(_dir)
#endif
#include <dlfcn.h>
#include <dirent.h>

#include "plugin.hpp" #include "plugin.hpp"




@@ -39,20 +42,26 @@ Plugin::~Plugin() {
} }




static int loadPlugin(const char *path) {
static int loadPlugin(std::string slug) {
#if defined(LINUX)
std::string path = "./plugins/" + slug + "/plugin.so";
#elif defined(WINDOWS)
std::string path = "./plugins/" + slug + "/plugin.dll";
#elif defined(APPLE)
std::string path = "./plugins/" + slug + "/plugin.dylib";
#endif

// Load dynamic/shared library // Load dynamic/shared library
#if defined(WINDOWS) #if defined(WINDOWS)
HINSTANCE handle = LoadLibrary(path);
HINSTANCE handle = LoadLibrary(path.c_str());
if (!handle) { if (!handle) {
fprintf(stderr, "Failed to load library %s\n", path);
fprintf(stderr, "Failed to load library %s\n", path.c_str());
return -1; return -1;
} }
#elif defined(LINUX) || defined(APPLE) #elif defined(LINUX) || defined(APPLE)
char ppath[1024];
snprintf(ppath, sizeof(ppath), "./%s", path);
void *handle = dlopen(ppath, RTLD_NOW | RTLD_GLOBAL);
void *handle = dlopen(path.c_str(), RTLD_NOW | RTLD_GLOBAL);
if (!handle) { if (!handle) {
fprintf(stderr, "Failed to load library %s: %s\n", path, dlerror());
fprintf(stderr, "Failed to load library %s: %s\n", path.c_str(), dlerror());
return -1; return -1;
} }
#endif #endif
@@ -66,23 +75,23 @@ static int loadPlugin(const char *path) {
initCallback = (InitCallback) dlsym(handle, "init"); initCallback = (InitCallback) dlsym(handle, "init");
#endif #endif
if (!initCallback) { if (!initCallback) {
fprintf(stderr, "Failed to read init() symbol in %s\n", path);
fprintf(stderr, "Failed to read init() symbol in %s\n", path.c_str());
return -2; return -2;
} }


// Add plugin to map // Add plugin to map
Plugin *plugin = initCallback(); Plugin *plugin = initCallback();
if (!plugin) { if (!plugin) {
fprintf(stderr, "Library %s did not return a plugin\n", path);
fprintf(stderr, "Library %s did not return a plugin\n", path.c_str());
return -3; return -3;
} }
gPlugins.push_back(plugin); gPlugins.push_back(plugin);
fprintf(stderr, "Loaded plugin %s\n", path);
fprintf(stderr, "Loaded plugin %s\n", path.c_str());
return 0; return 0;
} }


void pluginInit() { void pluginInit() {
curl_global_init(CURL_GLOBAL_ALL);
curl_global_init(CURL_GLOBAL_NOTHING);


// Load core // Load core
// This function is defined in core.cpp // This function is defined in core.cpp
@@ -90,33 +99,16 @@ void pluginInit() {
gPlugins.push_back(corePlugin); gPlugins.push_back(corePlugin);


// Search for plugin libraries // Search for plugin libraries
#if defined(WINDOWS)
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile("plugins/*", &ffd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
char pluginFilename[MAX_PATH];
snprintf(pluginFilename, sizeof(pluginFilename), "plugins/%s/plugin.dll", ffd.cFileName);
loadPlugin(pluginFilename);
} while (FindNextFile(hFind, &ffd));
}
FindClose(hFind);

#elif defined(LINUX) || defined(APPLE)
#if defined(LINUX)
const char *globPath = "plugins/*/plugin.so";
#elif defined(WINDOWS)
const char *globPath = "plugins/*/plugin.dll";
#elif defined(APPLE)
const char *globPath = "plugins/*/plugin.dylib";
#endif
glob_t result;
glob(globPath, GLOB_TILDE, NULL, &result);
for (int i = 0; i < (int) result.gl_pathc; i++) {
loadPlugin(result.gl_pathv[i]);
DIR *dir = opendir("plugins");
if (dir) {
struct dirent *d;
while ((d = readdir(dir))) {
if (d->d_name[0] == '.')
continue;
loadPlugin(d->d_name);
} }
globfree(&result);
#endif
closedir(dir);
}
} }


void pluginDestroy() { void pluginDestroy() {
@@ -169,7 +161,7 @@ static size_t write_string_callback(void *data, size_t size, size_t nmemb, void
return len; return len;
} }


static void extract_zip(int zipfd, int dirfd) {
static void extract_zip(const char *dir, int zipfd) {
int err = 0; int err = 0;
zip_t *za = zip_fdopen(zipfd, 0, &err); zip_t *za = zip_fdopen(zipfd, 0, &err);
if (!za) return; if (!za) return;
@@ -181,15 +173,20 @@ static void extract_zip(int zipfd, int dirfd) {
if (err) goto cleanup; if (err) goto cleanup;
int nameLen = strlen(zs.name); int nameLen = strlen(zs.name);


char path[MAXPATHLEN] = "\0";
strncat(path, dir, MAXPATHLEN);
strncat(path, "/", MAXPATHLEN);
strncat(path, zs.name, MAXPATHLEN);

if (zs.name[nameLen - 1] == '/') { if (zs.name[nameLen - 1] == '/') {
err = mkdirat(dirfd, zs.name, 0755);
err = mkdir(path, 0755);
if (err) goto cleanup; if (err) goto cleanup;
} }
else { else {
zip_file_t *zf = zip_fopen_index(za, i, 0); zip_file_t *zf = zip_fopen_index(za, i, 0);
if (!zf) goto cleanup; if (!zf) goto cleanup;


int out = openat(dirfd, zs.name, O_RDWR | O_TRUNC | O_CREAT, 0644);
int out = open(path, O_RDWR | O_TRUNC | O_CREAT, 0644);
assert(out != -1); assert(out != -1);


while (1) { while (1) {
@@ -289,18 +286,23 @@ static void pluginRefreshPlugin(json_t *pluginJ) {
downloadName = name; downloadName = name;
downloadProgress = 0.0; downloadProgress = 0.0;


std::string filename = slug + ".zip";
int dir = open("plugins", O_RDONLY | O_DIRECTORY);
int zip = openat(dir, filename.c_str(), O_RDWR | O_TRUNC | O_CREAT, 0644);
const char *dir = "plugins";
char path[MAXPATHLEN] = "\0";
strncat(path, dir, MAXPATHLEN);
strncat(path, "/", MAXPATHLEN);
strncat(path, slug.c_str(), MAXPATHLEN);
strncat(path, ".zip", MAXPATHLEN);
int zip = open(path, O_RDWR | O_TRUNC | O_CREAT, 0644);
// Download zip // Download zip
download_file(zip, url.c_str()); download_file(zip, url.c_str());
// Unzip file // Unzip file
lseek(zip, 0, SEEK_SET); lseek(zip, 0, SEEK_SET);
extract_zip(zip, dir);
// Close files
extract_zip(dir, zip);
// Close file
close(zip); close(zip);
close(dir);
downloadName = ""; downloadName = "";

// Load plugin
} }


void pluginRefresh() { void pluginRefresh() {


+ 2
- 1
src/widgets/FramebufferWidget.cpp View File

@@ -47,7 +47,8 @@ void FramebufferWidget::step() {


internal->setFramebuffer(NULL); internal->setFramebuffer(NULL);
NVGLUframebuffer *fb = nvgluCreateFramebuffer(gVg, width, height, NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); NVGLUframebuffer *fb = nvgluCreateFramebuffer(gVg, width, height, NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY);
assert(fb);
if (!fb)
return;
internal->setFramebuffer(fb); internal->setFramebuffer(fb);


// TODO Support screens with pixelRatio != 1.0 (e.g. Retina) by using the actual size of the framebuffer, etc. // TODO Support screens with pixelRatio != 1.0 (e.g. Retina) by using the actual size of the framebuffer, etc.


Loading…
Cancel
Save