From b613529b6c67beb516556b2b7b40e143c1928c94 Mon Sep 17 00:00:00 2001 From: NADAL Jean-Baptiste Date: Mon, 9 May 2016 23:09:31 +0200 Subject: [PATCH] Fix build of FW part. Add Options response to the Rest Daemon. (mandatory by Ajax request). --- 3P/json/.gitignore | 54 --------------------- 3P/json/json_config.h | 4 ++ 3P/ubus/.gitignore | 12 ----- 3P/ubus/ubus/builders/cmake/CMakeLists.txt | 15 ++++++ 3P/ubus/ubusd/builders/cmake/CMakeLists.txt | 27 +++++++++++ build/.gitkeep | 0 src/restd/src/routes/UbusHandler.cpp | 20 ++++++++ src/restd/src/routes/UbusHandler.h | 1 + 8 files changed, 67 insertions(+), 66 deletions(-) delete mode 100644 3P/json/.gitignore create mode 100644 3P/json/json_config.h delete mode 100644 3P/ubus/.gitignore create mode 100644 3P/ubus/ubus/builders/cmake/CMakeLists.txt create mode 100644 3P/ubus/ubusd/builders/cmake/CMakeLists.txt create mode 100644 build/.gitkeep diff --git a/3P/json/.gitignore b/3P/json/.gitignore deleted file mode 100644 index dd5c2e28..00000000 --- a/3P/json/.gitignore +++ /dev/null @@ -1,54 +0,0 @@ -*~ -*.swp -/INSTALL -.deps/ -.libs/ -/aclocal.m4 -/autom4te.cache -/config.guess -/json_config.h -/compile -/config.log -/config.status -/config.sub -/configure -/depcomp -/doc -/install-sh -/json.pc -/json-c.pc -/json-c-uninstalled.pc -/libtool -/ltmain.sh -/Makefile -/Makefile.in -/missing -/stamp-h1 -/stamp-h2 -/test-driver -/tests/Makefile -/tests/Makefile.in -/tests/test1 -/tests/test1Formatted -/tests/test2 -/tests/test2Formatted -/tests/test4 -/tests/testReplaceExisting -/tests/testSubDir -/tests/test_parse_int64 -/tests/test_parse -/tests/test_cast -/tests/test_charcase -/tests/test_locale -/tests/test_null -/tests/test_printbuf -/tests/test_set_serializer -/tests/*.vg.out -/tests/*.log -/tests/*.trs -/Debug -/Release -*.lo -*.o -/libjson-c.la -/libjson.la diff --git a/3P/json/json_config.h b/3P/json/json_config.h new file mode 100644 index 00000000..965ff1c3 --- /dev/null +++ b/3P/json/json_config.h @@ -0,0 +1,4 @@ +/* json_config.h. Generated from json_config.h.in by configure. */ + +/* Define to 1 if you have the header file. */ +#define JSON_C_HAVE_INTTYPES_H 1 diff --git a/3P/ubus/.gitignore b/3P/ubus/.gitignore deleted file mode 100644 index 551b024f..00000000 --- a/3P/ubus/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -Makefile -CMakeCache.txt -CMakeFiles -*.cmake -*.a -*.so -*.dylib -examples/server -examples/client -ubusd -ubus -install_manifest.txt diff --git a/3P/ubus/ubus/builders/cmake/CMakeLists.txt b/3P/ubus/ubus/builders/cmake/CMakeLists.txt new file mode 100644 index 00000000..0ae6ab50 --- /dev/null +++ b/3P/ubus/ubus/builders/cmake/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8.11) + +project (ubuscli) + +include (libubus) +include (libubox) + +add_executable (ucli ../../../cli.c) + +add_dependencies (ucli ubus) + +target_link_libraries (ucli + LINK_PUBLIC + ubus + ) diff --git a/3P/ubus/ubusd/builders/cmake/CMakeLists.txt b/3P/ubus/ubusd/builders/cmake/CMakeLists.txt new file mode 100644 index 00000000..58bb482c --- /dev/null +++ b/3P/ubus/ubusd/builders/cmake/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 2.8.11) + +project (ubusd) + +include (libubus) +include (libubox) + +file( + GLOB + source_files + ../../../ubusd.c + ../../../ubusd_id.c + ../../../ubusd_obj.c + ../../../ubusd_proto.c + ../../../ubusd_event.c + ../../../ubusd_acl.c + ../../../ubusd_monitor.c +) + +add_executable (ubusd ${source_files}) + +add_dependencies (ubusd ubus) + +target_link_libraries (ubusd + LINK_PUBLIC + ubus + ) \ No newline at end of file diff --git a/build/.gitkeep b/build/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/restd/src/routes/UbusHandler.cpp b/src/restd/src/routes/UbusHandler.cpp index c6ba1f5d..a2031e3d 100644 --- a/src/restd/src/routes/UbusHandler.cpp +++ b/src/restd/src/routes/UbusHandler.cpp @@ -111,6 +111,26 @@ bool UBusHandler::handleDelete (CivetServer *aServer, struct mg_connection *conn return true; } + +/*! ---------------------------------------------------------------------------- + * @fn handleOptions + * + * @brief Options Method for the Exit route. + */ +bool UBusHandler::handleOptions (CivetServer *aServer, struct mg_connection *aConn) +{ + UNUSED_PARAMETER (aServer); + + /* Add HTTP Headers. for the Responde. */ + mg_printf (aConn, "HTTP/1.1 200 OK\r\n"); + mg_printf (aConn, "Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept\r\n"); + mg_printf (aConn, "Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS\r\n"); + mg_printf (aConn, "Access-Control-Allow-Origin: *\r\n"); + + return true; +} + + /*! ---------------------------------------------------------------------------- * @fn Exec * diff --git a/src/restd/src/routes/UbusHandler.h b/src/restd/src/routes/UbusHandler.h index a2a769f2..2f9d46e1 100644 --- a/src/restd/src/routes/UbusHandler.h +++ b/src/restd/src/routes/UbusHandler.h @@ -43,6 +43,7 @@ public: bool handlePost (CivetServer *server, struct mg_connection *conn); bool handlePut (CivetServer *server, struct mg_connection *conn); bool handleDelete (CivetServer *server, struct mg_connection *conn); + bool handleOptions (CivetServer *aServer, struct mg_connection *aConn); private: bool Exec (const std::string &aCommand, const std::string &aParam,