diff options
-rw-r--r-- | nbproject/configurations.xml | 133 | ||||
-rw-r--r-- | plugins/afm-main-plugin/afm-main-plugin.c | 29 | ||||
-rw-r--r-- | plugins/samples/SamplePost.c | 17 | ||||
-rw-r--r-- | src/helper-api.c | 4 |
4 files changed, 78 insertions, 105 deletions
diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index 93b861c7..40d93459 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -103,31 +103,28 @@ <folder path="0/plugins/afm-main-plugin"> <cTool> <incDir> - <pElem>plugins/afm-main-plugin</pElem> + <pElem>/usr/include/dbus-1.0</pElem> + <pElem>/usr/lib64/dbus-1.0/include</pElem> + <pElem>/usr/include/alsa</pElem> + <pElem>build/plugins/afm-main-plugin</pElem> </incDir> <preprocessorList> <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem> - <Elem>__PIC__=2</Elem> - <Elem>__REGISTER_PREFIX__=</Elem> - <Elem>__USER_LABEL_PREFIX__=</Elem> - <Elem>__pic__=2</Elem> - <Elem>afm_main_api_EXPORTS=1</Elem> + <Elem>afm_main_api_EXPORTS</Elem> </preprocessorList> </cTool> </folder> <folder path="0/plugins/audio"> <cTool> <incDir> - <pElem>plugins/audio</pElem> + <pElem>/usr/include/dbus-1.0</pElem> + <pElem>/usr/lib64/dbus-1.0/include</pElem> + <pElem>/usr/include/alsa</pElem> <pElem>build/plugins/audio</pElem> </incDir> <preprocessorList> <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem> - <Elem>__PIC__=2</Elem> - <Elem>__REGISTER_PREFIX__=</Elem> - <Elem>__USER_LABEL_PREFIX__=</Elem> - <Elem>__pic__=2</Elem> - <Elem>audio_api_EXPORTS=1</Elem> + <Elem>audio_api_EXPORTS</Elem> </preprocessorList> </cTool> </folder> @@ -144,6 +141,12 @@ </folder> <folder path="0/plugins/samples"> <cTool> + <incDir> + <pElem>/usr/include/dbus-1.0</pElem> + <pElem>/usr/lib64/dbus-1.0/include</pElem> + <pElem>/usr/include/alsa</pElem> + <pElem>build/plugins/samples</pElem> + </incDir> <preprocessorList> <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem> </preprocessorList> @@ -152,16 +155,14 @@ <folder path="0/plugins/session"> <cTool> <incDir> - <pElem>plugins/session</pElem> + <pElem>/usr/include/dbus-1.0</pElem> + <pElem>/usr/lib64/dbus-1.0/include</pElem> + <pElem>/usr/include/alsa</pElem> <pElem>build/plugins/session</pElem> </incDir> <preprocessorList> <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem> - <Elem>__PIC__=2</Elem> - <Elem>__REGISTER_PREFIX__=</Elem> - <Elem>__USER_LABEL_PREFIX__=</Elem> - <Elem>__pic__=2</Elem> - <Elem>token_api_EXPORTS=1</Elem> + <Elem>token_api_EXPORTS</Elem> </preprocessorList> </cTool> </folder> @@ -169,32 +170,22 @@ ex="false" tool="0" flavor2="2"> - <cTool flags="2"> - <incDir> - <pElem>build/plugins/afm-main-plugin</pElem> - </incDir> + <cTool flags="0"> </cTool> </item> <item path="plugins/afm-main-plugin/utils-jbus.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> - <incDir> - <pElem>/usr/lib64/dbus-1.0/include/dbus</pElem> - <pElem>/usr/include/dbus-1.0/dbus</pElem> - <pElem>/usr/include/dbus-1.0</pElem> - <pElem>/usr/lib64/dbus-1.0/include</pElem> - <pElem>build/plugins/afm-main-plugin</pElem> - </incDir> + <cTool flags="0"> </cTool> </item> <item path="plugins/audio/audio-alsa.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> + <cTool flags="0"> </cTool> </item> <item path="plugins/audio/audio-api.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> + <cTool flags="0"> </cTool> </item> <item path="plugins/radio/radio-api.c" ex="false" tool="0" flavor2="2"> @@ -206,50 +197,28 @@ </cTool> </item> <item path="plugins/samples/ClientCtx.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> - <incDir> - <pElem>plugins/samples</pElem> - <pElem>build/plugins/samples</pElem> - </incDir> + <cTool flags="0"> <preprocessorList> - <Elem>__PIC__=2</Elem> - <Elem>__REGISTER_PREFIX__=</Elem> - <Elem>__USER_LABEL_PREFIX__=</Elem> - <Elem>__pic__=2</Elem> - <Elem>clientCtx_api_EXPORTS=1</Elem> + <Elem>clientCtx_api_EXPORTS</Elem> </preprocessorList> </cTool> </item> <item path="plugins/samples/HelloWorld.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> - <incDir> - <pElem>plugins/samples</pElem> - <pElem>build/plugins/samples</pElem> - </incDir> + <cTool flags="0"> <preprocessorList> - <Elem>__PIC__=2</Elem> - <Elem>__REGISTER_PREFIX__=</Elem> - <Elem>__USER_LABEL_PREFIX__=</Elem> - <Elem>__pic__=2</Elem> - <Elem>helloWorld_api_EXPORTS=1</Elem> + <Elem>helloWorld_api_EXPORTS</Elem> </preprocessorList> </cTool> </item> <item path="plugins/samples/SamplePost.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> - <incDir> - <pElem>/usr/include/dbus-1.0</pElem> - <pElem>/usr/lib64/dbus-1.0/include</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>build/plugins/samples</pElem> - </incDir> <preprocessorList> <Elem>samplePost_api_EXPORTS</Elem> </preprocessorList> </cTool> </item> <item path="plugins/session/token-api.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> + <cTool flags="0"> </cTool> </item> <item path="src/afbs-api.c" ex="false" tool="0" flavor2="2"> @@ -281,20 +250,18 @@ </cTool> </item> <item path="src/config.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> + <cTool flags="0"> <incDir> - <pElem>src</pElem> - <pElem>/usr/include/json-c</pElem> <pElem>include</pElem> + <pElem>/usr/include/json-c</pElem> <pElem>/usr/include/uuid</pElem> + <pElem>/usr/include/dbus-1.0</pElem> + <pElem>/usr/lib64/dbus-1.0/include</pElem> + <pElem>/usr/include/alsa</pElem> <pElem>build/src</pElem> </incDir> <preprocessorList> <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem> - <Elem>__PIC__=2</Elem> - <Elem>__REGISTER_PREFIX__=</Elem> - <Elem>__USER_LABEL_PREFIX__=</Elem> - <Elem>__pic__=2</Elem> </preprocessorList> </cTool> </item> @@ -329,31 +296,34 @@ </cTool> </item> <item path="src/http-svc.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> + <cTool flags="0"> <incDir> - <pElem>src</pElem> - <pElem>/usr/include/json-c</pElem> <pElem>include</pElem> + <pElem>/usr/include/json-c</pElem> <pElem>/usr/include/uuid</pElem> + <pElem>/usr/include/dbus-1.0</pElem> + <pElem>/usr/lib64/dbus-1.0/include</pElem> + <pElem>/usr/include/alsa</pElem> <pElem>build/src</pElem> </incDir> + <preprocessorList> + <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem> + </preprocessorList> </cTool> </item> <item path="src/main.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> + <cTool flags="0"> <incDir> - <pElem>src</pElem> - <pElem>/usr/include/json-c</pElem> <pElem>include</pElem> + <pElem>/usr/include/json-c</pElem> <pElem>/usr/include/uuid</pElem> + <pElem>/usr/include/dbus-1.0</pElem> + <pElem>/usr/lib64/dbus-1.0/include</pElem> + <pElem>/usr/include/alsa</pElem> <pElem>build/src</pElem> </incDir> <preprocessorList> <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem> - <Elem>__PIC__=2</Elem> - <Elem>__REGISTER_PREFIX__=</Elem> - <Elem>__USER_LABEL_PREFIX__=</Elem> - <Elem>__pic__=2</Elem> </preprocessorList> </cTool> </item> @@ -392,14 +362,19 @@ </cTool> </item> <item path="src/session.c" ex="false" tool="0" flavor2="2"> - <cTool flags="2"> + <cTool flags="0"> <incDir> - <pElem>src</pElem> + <pElem>include</pElem> <pElem>/usr/include/json-c</pElem> <pElem>/usr/include/uuid</pElem> - <pElem>include</pElem> + <pElem>/usr/include/dbus-1.0</pElem> + <pElem>/usr/lib64/dbus-1.0/include</pElem> + <pElem>/usr/include/alsa</pElem> <pElem>build/src</pElem> </incDir> + <preprocessorList> + <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem> + </preprocessorList> </cTool> </item> </conf> diff --git a/plugins/afm-main-plugin/afm-main-plugin.c b/plugins/afm-main-plugin/afm-main-plugin.c index 12bd9f33..5315da9d 100644 --- a/plugins/afm-main-plugin/afm-main-plugin.c +++ b/plugins/afm-main-plugin/afm-main-plugin.c @@ -127,20 +127,23 @@ static struct json_object *call_file__appid(AFB_request *request, AFB_PostItem * struct json_object *obj; char *query; const char *filename = getPostPath(request); - request->jresp = NULL; - if (0 >= asprintf(&query, "\"%s\"", filename)) - request->errcode = MHD_HTTP_INTERNAL_SERVER_ERROR; - else { - obj = jbus_call_sj_sync(jbus, request->api, query); - free(query); - if (obj) - request->jresp = embed(request, _id_, obj); - else - request->errcode = MHD_HTTP_FAILED_DEPENDENCY; - } - unlink(filename); + + if (filename != NULL) { + request->jresp = NULL; + if (0 >= asprintf(&query, "\"%s\"", filename)) + request->errcode = MHD_HTTP_INTERNAL_SERVER_ERROR; + else { + obj = jbus_call_sj_sync(jbus, request->api, query); + free(query); + if (obj) + request->jresp = embed(request, _id_, obj); + else + request->errcode = MHD_HTTP_FAILED_DEPENDENCY; + } + unlink(filename); + } } - return getPostFile (request, item, "/tmp"); + return getPostFile (request, item, "/tmp/upload"); } static AFB_restapi plug_apis[] = diff --git a/plugins/samples/SamplePost.c b/plugins/samples/SamplePost.c index e419be45..88949736 100644 --- a/plugins/samples/SamplePost.c +++ b/plugins/samples/SamplePost.c @@ -72,17 +72,12 @@ STATIC json_object* UploadImage (AFB_request *request, AFB_PostItem *item) { char *destination = "images"; // This is called after PostForm and then after DonePostForm - if (item == NULL) { - AFB_PostCtx *postFileCtx = getPostContext(request); - - // if postFileCtx == NULL then an error happen [getPostedFile automatically reports errors] - if (postFileCtx != NULL) { - // Do something with your newly upload filepath=postFileCtx->path - request->errcode = MHD_HTTP_OK; - request->jresp = jsonNewMessage(AFB_FAIL,"UploadFile Post Image done"); - - // Note: should not return here in order getPostedFile to clear Post resources. - } + if (item == NULL && getPostPath (request) != NULL) { + // Do something with your newly upload filepath=postFileCtx->path + request->errcode = MHD_HTTP_OK; + request->jresp = jsonNewMessage(AFB_SUCCESS,"UploadFile Post Image done"); + + // Note: should not return here in order getPostedFile to clear Post resources. } // upload multi iteration logic is handle by getPostedFile diff --git a/src/helper-api.c b/src/helper-api.c index ad0daf69..4c07c779 100644 --- a/src/helper-api.c +++ b/src/helper-api.c @@ -126,7 +126,7 @@ PUBLIC json_object* getPostFile (AFB_request *request, AFB_PostItem *item, char* // We have a context but last Xform iteration fail or application set a message if (request->jresp != NULL) { jresp = request->jresp; // retrieve previous error from postCtx - } else jresp = jsonNewMessage(AFB_FAIL,"getPostFile Post Request done"); + } else jresp = jsonNewMessage(AFB_SUCCESS,"getPostFile Post Request done"); // Error or not let's free all resources close(postFileCtx->fd); @@ -188,7 +188,7 @@ PUBLIC json_object* getPostFile (AFB_request *request, AFB_PostItem *item, char* postFileCtx->path = strdup (filepath); if (verbose) fprintf(stderr, "getPostFile path=%s\n", filepath); - + if((postFileCtx->fd = open(filepath, O_RDWR |O_CREAT, S_IRWXU|S_IRGRP)) <= 0) { postFileCtx->jresp= jsonNewMessage(AFB_FAIL,"Fail to Create destination File=[%s] error=%s\n", filepath, strerror(errno)); goto ExitOnError; |