Fix Post JSON bug
authorFulup Ar Foll <fulup@iot.bzh>
Tue, 22 Dec 2015 14:51:22 +0000 (15:51 +0100)
committerFulup Ar Foll <fulup@iot.bzh>
Tue, 22 Dec 2015 14:51:22 +0000 (15:51 +0100)
nbproject/configurations.xml
src/rest-api.c

index 449cdaf..a04af66 100644 (file)
@@ -3,6 +3,10 @@
   <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
     <df root="." name="0">
       <df name="plugins">
+        <df name="afm-main-plugin">
+          <in>afm-main-plugin.c</in>
+          <in>utils-jbus.c</in>
+        </df>
         <df name="audio">
           <in>audio-alsa.c</in>
           <in>audio-api.c</in>
@@ -24,6 +28,7 @@
         <in>alsa-api.c</in>
         <in>config.c</in>
         <in>dbus-api.c</in>
+        <in>helper-api.c</in>
         <in>http-svc.c</in>
         <in>main.c</in>
         <in>radio-api.c</in>
           </incDir>
         </cTool>
       </folder>
+      <folder path="0/plugins/afm-main-plugin">
+        <cTool>
+          <incDir>
+            <pElem>plugins/afm-main-plugin</pElem>
+          </incDir>
+        </cTool>
+      </folder>
       <folder path="0/plugins/audio">
         <cTool>
           <incDir>
+            <pElem>plugins/audio</pElem>
             <pElem>build/plugins/audio</pElem>
           </incDir>
           <preprocessorList>
             <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem>
-            <Elem>audio_api_EXPORTS</Elem>
+            <Elem>__PIC__=2</Elem>
+            <Elem>__REGISTER_PREFIX__=</Elem>
+            <Elem>__USER_LABEL_PREFIX__=</Elem>
+            <Elem>__pic__=2</Elem>
+            <Elem>audio_api_EXPORTS=1</Elem>
           </preprocessorList>
         </cTool>
       </folder>
       <folder path="0/plugins/samples">
         <cTool>
           <incDir>
+            <pElem>plugins/samples</pElem>
             <pElem>build/plugins/samples</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>
       </folder>
       <folder path="0/plugins/session">
         <cTool>
           <incDir>
+            <pElem>plugins/session</pElem>
             <pElem>build/plugins/session</pElem>
           </incDir>
           <preprocessorList>
             <Elem>PLUGIN_INSTALL_DIR="/usr/local/lib64/afb"</Elem>
-            <Elem>token_api_EXPORTS</Elem>
+            <Elem>__PIC__=2</Elem>
+            <Elem>__REGISTER_PREFIX__=</Elem>
+            <Elem>__USER_LABEL_PREFIX__=</Elem>
+            <Elem>__pic__=2</Elem>
+            <Elem>token_api_EXPORTS=1</Elem>
           </preprocessorList>
         </cTool>
       </folder>
+      <item path="plugins/afm-main-plugin/afm-main-plugin.c"
+            ex="false"
+            tool="0"
+            flavor2="2">
+        <cTool flags="2">
+          <incDir>
+            <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>
+          </preprocessorList>
+        </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>
+      </item>
       <item path="plugins/audio/audio-alsa.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="0">
+        <cTool flags="2">
         </cTool>
       </item>
       <item path="plugins/audio/audio-api.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="0">
+        <cTool flags="2">
         </cTool>
       </item>
       <item path="plugins/radio/radio-api.c" ex="false" tool="0" flavor2="2">
         </cTool>
       </item>
       <item path="plugins/samples/HelloWorld.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="0">
+        <cTool flags="2">
           <preprocessorList>
-            <Elem>helloWorld_api_EXPORTS</Elem>
+            <Elem>helloWorld_api_EXPORTS=1</Elem>
           </preprocessorList>
         </cTool>
       </item>
       <item path="plugins/samples/SamplePost.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="0">
+        <cTool flags="2">
           <preprocessorList>
-            <Elem>samplePost_api_EXPORTS</Elem>
+            <Elem>samplePost_api_EXPORTS=1</Elem>
           </preprocessorList>
         </cTool>
       </item>
       <item path="plugins/session/token-api.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="0">
+        <cTool flags="2">
         </cTool>
       </item>
       <item path="src/afbs-api.c" ex="false" tool="0" flavor2="2">
         </cTool>
       </item>
       <item path="src/config.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="0">
+        <cTool flags="2">
           <incDir>
-            <pElem>include</pElem>
+            <pElem>src</pElem>
             <pElem>/usr/include/json-c</pElem>
+            <pElem>include</pElem>
             <pElem>/usr/include/uuid</pElem>
-            <pElem>/usr/include/alsa</pElem>
             <pElem>build/src</pElem>
           </incDir>
           <preprocessorList>
             <Elem>HAVE_AUDIO_PLUGIN=1</Elem>
             <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>
           </incDir>
         </cTool>
       </item>
-      <item path="src/http-svc.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="0">
+      <item path="src/helper-api.c" ex="false" tool="0" flavor2="2">
+        <cTool flags="2">
           <incDir>
+            <pElem>src</pElem>
+            <pElem>/usr/include/json-c</pElem>
             <pElem>include</pElem>
+            <pElem>/usr/include/uuid</pElem>
+            <pElem>build/src</pElem>
+          </incDir>
+        </cTool>
+      </item>
+      <item path="src/http-svc.c" ex="false" tool="0" flavor2="2">
+        <cTool flags="2">
+          <incDir>
+            <pElem>src</pElem>
             <pElem>/usr/include/json-c</pElem>
+            <pElem>include</pElem>
             <pElem>/usr/include/uuid</pElem>
-            <pElem>/usr/include/alsa</pElem>
             <pElem>build/src</pElem>
           </incDir>
-          <preprocessorList>
-            <Elem>HAVE_AUDIO_PLUGIN=1</Elem>
-            <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="0">
+        <cTool flags="2">
           <incDir>
-            <pElem>include</pElem>
+            <pElem>src</pElem>
             <pElem>/usr/include/json-c</pElem>
+            <pElem>include</pElem>
             <pElem>/usr/include/uuid</pElem>
-            <pElem>/usr/include/alsa</pElem>
             <pElem>build/src</pElem>
           </incDir>
           <preprocessorList>
             <Elem>HAVE_AUDIO_PLUGIN=1</Elem>
             <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>
         </cTool>
       </item>
       <item path="src/session.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="0">
+        <cTool flags="2">
           <incDir>
-            <pElem>include</pElem>
+            <pElem>src</pElem>
             <pElem>/usr/include/json-c</pElem>
             <pElem>/usr/include/uuid</pElem>
-            <pElem>/usr/include/alsa</pElem>
+            <pElem>include</pElem>
             <pElem>build/src</pElem>
           </incDir>
           <preprocessorList>
             <Elem>HAVE_AUDIO_PLUGIN=1</Elem>
             <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>
index c1a20f1..3d9ffeb 100644 (file)
@@ -367,6 +367,7 @@ PUBLIC int doRestApi(struct MHD_Connection *connection, AFB_session *session, co
             // allocate application POST processor handle to zero
             postHandle = calloc(1, sizeof (AFB_PostHandle));
             postHandle->uid = postcount++; // build a UID for DEBUG
+            *con_cls = postHandle;  // update context with posthandle
             
             // Let make sure we have the right encoding and a valid length
             encoding = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE);
@@ -390,7 +391,6 @@ PUBLIC int doRestApi(struct MHD_Connection *connection, AFB_session *session, co
                 postHandle->type   = AFB_POST_FORM;
                 postHandle->pp     = MHD_create_post_processor (connection, MAX_POST_SIZE, doPostIterate, postHandle);
                 postHandle->private= (void*)request;
-                *con_cls = postHandle;  // update context with posthandle
                 
                 if (NULL == postHandle->pp) {
                     fprintf(stderr,"OOPS: Internal error fail to allocate MHD_create_post_processor\n");