From: Fulup Ar Foll Date: Tue, 22 Dec 2015 16:55:35 +0000 (+0100) Subject: Merge origin/master X-Git-Tag: blowfish_2.0.1~322 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=6d575b22b86ebfac5e2b4c9d672f45805a5b63ce;hp=0d37437a44e872db93631270cee0472fe9716673;p=src%2Fapp-framework-binder.git Merge origin/master --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fba65e3..7e9502bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(json-c REQUIRED json-c) PKG_CHECK_MODULES(libmicrohttpd REQUIRED libmicrohttpd) PKG_CHECK_MODULES(uuid REQUIRED uuid) +PKG_CHECK_MODULES(dbus REQUIRED dbus-1) # Optional plugin dependencies PKG_CHECK_MODULES(alsa alsa) PKG_CHECK_MODULES(librtlsdr librtlsdr>=0.5.0) @@ -51,8 +52,8 @@ ENDIF(librtlsdr_FOUND) INCLUDE(FindThreads) FIND_PACKAGE(Threads) -SET(include_dirs ${INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include ${json-c_INCLUDE_DIRS} ${libmicrohttpd_INCLUDE_DIRS} ${uuid_INCLUDE_DIRS} ${alsa_INCLUDE_DIRS} ${librtlsdr_INCLUDE_DIRS}) -SET(link_libraries ${json-c_LIBRARIES} ${libmicrohttpd_LIBRARIES} ${uuid_LIBRARIES} ${alsa_LIBRARIES} ${librtlsdr_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${libefence_LIBRARIES} -lmagic -lm -ldl) +SET(include_dirs ${INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include ${json-c_INCLUDE_DIRS} ${libmicrohttpd_INCLUDE_DIRS} ${uuid_INCLUDE_DIRS} ${dbus_INCLUDE_DIRS} ${alsa_INCLUDE_DIRS} ${librtlsdr_INCLUDE_DIRS}) +SET(link_libraries ${json-c_LIBRARIES} ${libmicrohttpd_LIBRARIES} ${uuid_LIBRARIES} ${dbus_LIBRARIES} ${alsa_LIBRARIES} ${librtlsdr_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${libefence_LIBRARIES} -lmagic -lm -ldl) SET(plugin_install_dir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/afb) ADD_DEFINITIONS(-DPLUGIN_INSTALL_DIR="${plugin_install_dir}") diff --git a/README.md b/README.md index 5846f001..c54c0f1e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ industry requirementsas the primary target for this code is AGL. * libmicrohttpd ("libmicrohttpd-dev/devel"); * json-c ("libjson-c-dev/devel"); * uuid ("uuid-dev/libuuid-devel"); + * dbus ("libdbus-1-dev/dbus-1-devel"); optionally, for plugins : diff --git a/include/local-def.h b/include/local-def.h index 68c42867..22a3608b 100644 --- a/include/local-def.h +++ b/include/local-def.h @@ -261,6 +261,7 @@ typedef struct { int fakemod; // respond to GET/POST request without interacting with sndboard int forceexit; // when autoconfig from script force exit before starting server AFB_plugin **plugins; // pointer to REST/API plugins + int pluginCount; // loaded plugins count magic_t magic; // Mime type file magic lib sigjmp_buf restartCkpt; // context save for restart set/longjmp } AFB_session; diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 769cc1e1..d8566161 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,5 +1,5 @@ +ADD_SUBDIRECTORY(afm-main-plugin) ADD_SUBDIRECTORY(session) ADD_SUBDIRECTORY(samples) ADD_SUBDIRECTORY(audio) ADD_SUBDIRECTORY(radio) -ADD_SUBDIRECTORY(afm-main-plugin) diff --git a/plugins/afm-main-plugin/CMakeLists.txt b/plugins/afm-main-plugin/CMakeLists.txt index 673bc951..5ed1d4b2 100644 --- a/plugins/afm-main-plugin/CMakeLists.txt +++ b/plugins/afm-main-plugin/CMakeLists.txt @@ -1,14 +1,7 @@ - -pkg_check_modules(EXTRAS REQUIRED dbus-1) -add_compile_options(${EXTRAS_CFLAGS}) -include_directories(${EXTRAS_INCLUDE_DIRS}) -link_libraries(${EXTRAS_LIBRARIES}) - ADD_LIBRARY(afm-main-api MODULE afm-main-plugin.c utils-jbus.c) SET_TARGET_PROPERTIES(afm-main-api PROPERTIES PREFIX "") TARGET_LINK_LIBRARIES(afm-main-api ${link_libraries}) INCLUDE_DIRECTORIES(${include_dirs}) INSTALL(TARGETS afm-main-api LIBRARY DESTINATION ${plugin_install_dir}) - diff --git a/src/rest-api.c b/src/rest-api.c index 5565f356..8146e144 100644 --- a/src/rest-api.c +++ b/src/rest-api.c @@ -575,9 +575,10 @@ void initPlugins(AFB_session *session) { struct dirent *pluginDir; DIR *dir; afbJsonType = json_object_new_string (AFB_MSG_JTYPE); - int i = 0; + int num = 0; - plugins = (AFB_plugin **) malloc (sizeof(AFB_plugin)); + /* pre-allocate for 20 plugins, we will downsize if necessary */ + plugins = (AFB_plugin **) malloc (20*sizeof(AFB_plugin)); if ((dir = opendir(session->config->plugins)) == NULL) { fprintf(stderr, "Could not open plugin directory [%s], exiting...\n", session->config->plugins); @@ -594,7 +595,7 @@ void initPlugins(AFB_session *session) { pluginRegisterFct = dlsym (plugin, "pluginRegister"); free (pluginPath); if (!plugin) { - if (verbose) fprintf(stderr, "[%s] is not a binary plugin, continuing...\n", pluginDir->d_name); + if (verbose) fprintf(stderr, "[%s] is not loadable, continuing...\n", pluginDir->d_name); continue; } else if (!pluginRegisterFct) { if (verbose) fprintf(stderr, "[%s] is not an AFB plugin, continuing...\n", pluginDir->d_name); @@ -602,12 +603,14 @@ void initPlugins(AFB_session *session) { } if (verbose) fprintf(stderr, "[%s] is a valid AFB plugin, loading it\n", pluginDir->d_name); - plugins = (AFB_plugin **) realloc (plugins, (i+1)*sizeof(AFB_plugin)); - plugins[i] = (AFB_plugin *) malloc (sizeof(AFB_plugin)); - plugins[i] = (**pluginRegisterFct)(); - i++; + plugins[num] = (AFB_plugin *) malloc (sizeof(AFB_plugin)); + plugins[num] = (**pluginRegisterFct)(); + num++; + /* only 20 plugins are supported at that time */ + if (num == 20) break; } - plugins[i] = NULL; + plugins = (AFB_plugin **) realloc (plugins, (num+1)*sizeof(AFB_plugin)); + plugins[num] = NULL; closedir (dir); @@ -618,4 +621,5 @@ void initPlugins(AFB_session *session) { // complete plugins and save them within current sessions session->plugins = RegisterJsonPlugins(plugins); + session->pluginCount = num; }