Fix radio plugin runtime
authorManuel Bachmann <manuel.bachmann@iot.bzh>
Wed, 16 Dec 2015 16:47:59 +0000 (17:47 +0100)
committerManuel Bachmann <manuel.bachmann@iot.bzh>
Wed, 16 Dec 2015 16:47:59 +0000 (17:47 +0100)
Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
nbproject/configurations.xml
nbproject/private/Default.properties
nbproject/private/configurations.xml
plugins/radio/radio-api.c

index 0a5d9b3..c9b7be5 100644 (file)
@@ -2,6 +2,21 @@
 <configurationDescriptor version="97">
   <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
     <df root="." name="0">
+      <df name="plugins">
+        <df name="audio">
+          <in>audio-api.c</in>
+        </df>
+        <df name="radio">
+          <in>radio-api.c</in>
+          <in>radio-rtlsdr.c</in>
+        </df>
+        <df name="samples">
+          <in>HelloWorld.c</in>
+        </df>
+        <df name="session">
+          <in>token-api.c</in>
+        </df>
+      </df>
       <df name="src">
         <in>afbs-api.c</in>
         <in>alsa-api.c</in>
@@ -49,7 +64,6 @@
       <flagsDictionary>
         <element flagsID="0" commonFlags="-fPIE"/>
         <element flagsID="1" commonFlags="-mtune=generic -march=x86-64 -fPIC"/>
-        <element flagsID="2" commonFlags="-mtune=generic -march=x86-64 -fPIE"/>
       </flagsDictionary>
       <codeAssistance>
       </codeAssistance>
           <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
           <executablePath>build/afb-daemon</executablePath>
           <cTool flags="1">
-            <incDir>
-              <pElem>plugins/audio</pElem>
-              <pElem>/usr/include/json-c</pElem>
-              <pElem>include</pElem>
-              <pElem>/usr/include/uuid</pElem>
-              <pElem>build/plugins</pElem>
-              <pElem>plugins/samples</pElem>
-              <pElem>/usr/include/json-c</pElem>
-              <pElem>include</pElem>
-              <pElem>/usr/include/uuid</pElem>
-              <pElem>build/plugins</pElem>
-              <pElem>plugins/session</pElem>
-              <pElem>/usr/include/json-c</pElem>
-              <pElem>include</pElem>
-              <pElem>/usr/include/uuid</pElem>
-              <pElem>build/plugins</pElem>
-            </incDir>
           </cTool>
         </makeTool>
         <preBuild>
           <preBuildFirst>true</preBuildFirst>
         </preBuild>
       </makefileType>
+      <folder path="0/plugins">
+        <cTool>
+          <incDir>
+            <pElem>include</pElem>
+            <pElem>/usr/include/json-c</pElem>
+            <pElem>/usr/include/libusb-1.0</pElem>
+            <pElem>build/plugins</pElem>
+          </incDir>
+        </cTool>
+      </folder>
+      <folder path="0/plugins/audio">
+        <cTool>
+          <incDir>
+            <pElem>plugins/audio</pElem>
+            <pElem>/usr/include/uuid</pElem>
+          </incDir>
+        </cTool>
+      </folder>
+      <folder path="0/plugins/radio">
+        <cTool>
+          <incDir>
+            <pElem>plugins/radio</pElem>
+          </incDir>
+        </cTool>
+      </folder>
+      <folder path="0/plugins/samples">
+        <cTool>
+          <incDir>
+            <pElem>plugins/samples</pElem>
+            <pElem>/usr/include/uuid</pElem>
+          </incDir>
+        </cTool>
+      </folder>
+      <folder path="0/plugins/session">
+        <cTool>
+          <incDir>
+            <pElem>plugins/session</pElem>
+            <pElem>/usr/include/uuid</pElem>
+          </incDir>
+        </cTool>
+      </folder>
+      <item path="plugins/audio/audio-api.c" ex="false" tool="0" flavor2="2">
+        <cTool flags="1">
+        </cTool>
+      </item>
+      <item path="plugins/radio/radio-api.c" ex="false" tool="0" flavor2="2">
+        <cTool flags="1">
+          <incDir>
+            <pElem>/usr/include/json-c</pElem>
+            <pElem>include</pElem>
+            <pElem>/usr/include/uuid</pElem>
+            <pElem>build/plugins</pElem>
+          </incDir>
+        </cTool>
+      </item>
+      <item path="plugins/radio/radio-rtlsdr.c" ex="false" tool="0" flavor2="2">
+        <cTool flags="1">
+          <incDir>
+            <pElem>include</pElem>
+            <pElem>/usr/include/json-c</pElem>
+            <pElem>/usr/include/uuid</pElem>
+            <pElem>build/plugins</pElem>
+          </incDir>
+        </cTool>
+      </item>
+      <item path="plugins/samples/HelloWorld.c" ex="false" tool="0" flavor2="2">
+        <cTool flags="1">
+        </cTool>
+      </item>
+      <item path="plugins/session/token-api.c" ex="false" tool="0" flavor2="2">
+        <cTool flags="1">
+        </cTool>
+      </item>
       <item path="src/afbs-api.c" ex="false" tool="0" flavor2="2">
         <cTool flags="0">
           <incDir>
-            <pElem>include</pElem>
+            <pElem>plugins/audio</pElem>
             <pElem>/usr/include/json-c</pElem>
+            <pElem>include</pElem>
+            <pElem>/usr/include/uuid</pElem>
+            <pElem>build/plugins</pElem>
+            <pElem>plugins/samples</pElem>
+            <pElem>plugins/session</pElem>
             <pElem>build/src</pElem>
           </incDir>
         </cTool>
       <item path="src/alsa-api.c" ex="false" tool="0" flavor2="2">
         <cTool flags="0">
           <incDir>
-            <pElem>include</pElem>
+            <pElem>plugins/audio</pElem>
             <pElem>/usr/include/json-c</pElem>
+            <pElem>include</pElem>
+            <pElem>/usr/include/uuid</pElem>
+            <pElem>build/plugins</pElem>
+            <pElem>plugins/samples</pElem>
+            <pElem>plugins/session</pElem>
             <pElem>build/src</pElem>
           </incDir>
         </cTool>
       </item>
       <item path="src/config.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="2">
+        <cTool flags="1">
           <incDir>
             <pElem>src</pElem>
             <pElem>/usr/include/json-c</pElem>
             <pElem>build/src</pElem>
           </incDir>
           <preprocessorList>
+            <Elem>HAVE_RADIO_PLUGIN=1</Elem>
             <Elem>__PIC__=2</Elem>
-            <Elem>__PIE__=2</Elem>
             <Elem>__REGISTER_PREFIX__=</Elem>
             <Elem>__USER_LABEL_PREFIX__=</Elem>
             <Elem>__pic__=2</Elem>
-            <Elem>__pie__=2</Elem>
           </preprocessorList>
         </cTool>
       </item>
       <item path="src/dbus-api.c" ex="false" tool="0" flavor2="2">
         <cTool flags="0">
           <incDir>
-            <pElem>include</pElem>
+            <pElem>plugins/audio</pElem>
             <pElem>/usr/include/json-c</pElem>
+            <pElem>include</pElem>
+            <pElem>/usr/include/uuid</pElem>
+            <pElem>build/plugins</pElem>
+            <pElem>plugins/samples</pElem>
+            <pElem>plugins/session</pElem>
             <pElem>build/src</pElem>
           </incDir>
         </cTool>
             <pElem>/usr/include/uuid</pElem>
             <pElem>build/src</pElem>
           </incDir>
+          <preprocessorList>
+            <Elem>HAVE_RADIO_PLUGIN=1</Elem>
+            <Elem>__PIC__=2</Elem>
+            <Elem>__REGISTER_PREFIX__=</Elem>
+            <Elem>__USER_LABEL_PREFIX__=</Elem>
+            <Elem>__pic__=2</Elem>
+          </preprocessorList>
         </cTool>
       </item>
       <item path="src/main.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="2">
+        <cTool flags="1">
           <incDir>
             <pElem>src</pElem>
             <pElem>/usr/include/json-c</pElem>
             <pElem>build/src</pElem>
           </incDir>
           <preprocessorList>
+            <Elem>HAVE_RADIO_PLUGIN=1</Elem>
             <Elem>__PIC__=2</Elem>
-            <Elem>__PIE__=2</Elem>
             <Elem>__REGISTER_PREFIX__=</Elem>
             <Elem>__USER_LABEL_PREFIX__=</Elem>
             <Elem>__pic__=2</Elem>
-            <Elem>__pie__=2</Elem>
           </preprocessorList>
         </cTool>
       </item>
       <item path="src/radio-api.c" ex="false" tool="0" flavor2="2">
         <cTool flags="0">
           <incDir>
-            <pElem>include</pElem>
+            <pElem>plugins/audio</pElem>
             <pElem>/usr/include/json-c</pElem>
+            <pElem>include</pElem>
+            <pElem>/usr/include/uuid</pElem>
+            <pElem>build/plugins</pElem>
+            <pElem>plugins/samples</pElem>
+            <pElem>plugins/session</pElem>
             <pElem>/usr/include/libusb-1.0</pElem>
             <pElem>build/src</pElem>
           </incDir>
         </cTool>
       </item>
       <item path="src/rest-api.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="2">
+        <cTool flags="1">
           <incDir>
             <pElem>src</pElem>
             <pElem>/usr/include/json-c</pElem>
             <pElem>/usr/include/uuid</pElem>
             <pElem>build/src</pElem>
           </incDir>
+          <preprocessorList>
+            <Elem>HAVE_RADIO_PLUGIN=1</Elem>
+            <Elem>__PIC__=2</Elem>
+            <Elem>__REGISTER_PREFIX__=</Elem>
+            <Elem>__USER_LABEL_PREFIX__=</Elem>
+            <Elem>__pic__=2</Elem>
+          </preprocessorList>
         </cTool>
       </item>
       <item path="src/session.c" ex="false" tool="0" flavor2="2">
-        <cTool flags="2">
+        <cTool flags="1">
           <incDir>
             <pElem>src</pElem>
             <pElem>/usr/include/json-c</pElem>
             <pElem>build/src</pElem>
           </incDir>
           <preprocessorList>
+            <Elem>HAVE_RADIO_PLUGIN=1</Elem>
             <Elem>__PIC__=2</Elem>
-            <Elem>__PIE__=2</Elem>
             <Elem>__REGISTER_PREFIX__=</Elem>
             <Elem>__USER_LABEL_PREFIX__=</Elem>
             <Elem>__pic__=2</Elem>
-            <Elem>__pie__=2</Elem>
           </preprocessorList>
         </cTool>
       </item>
index e63c237..e69de29 100644 (file)
@@ -1 +0,0 @@
-/home/fulup/Workspace/afb-daemon/src/session.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/session.c.o -c /home/fulup/Workspace/afb-daemon/src/session.c
index 713e87f..e198cc1 100644 (file)
@@ -2,6 +2,40 @@
 <configurationDescriptor version="97">
   <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
     <df root="." name="0">
+      <df name="build">
+        <df name="CMakeFiles">
+          <df name="3.3.2">
+            <df name="CompilerIdC">
+              <in>CMakeCCompilerId.c</in>
+            </df>
+          </df>
+          <df name="afb-daemon.dir">
+          </df>
+          <df name="CMakeTmp">
+          </df>
+          <in>feature_tests.c</in>
+        </df>
+        <df name="plugins">
+          <df name="CMakeFiles">
+            <df name="plugins.dir">
+              <df name="audio">
+              </df>
+              <df name="radio">
+              </df>
+              <df name="samples">
+              </df>
+              <df name="session">
+              </df>
+            </df>
+          </df>
+        </df>
+        <df name="src">
+          <df name="CMakeFiles">
+            <df name="src.dir">
+            </df>
+          </df>
+        </df>
+      </df>
       <df name="doc">
         <df name="nbproject.template">
           <df name="private">
@@ -18,6 +52,9 @@
         </df>
         <df name="radio">
           <in>radio-api.c</in>
+          <in>radio-api.h</in>
+          <in>radio-rtlsdr.c</in>
+          <in>radio-rtlsdr.h</in>
         </df>
         <df name="samples">
           <in>HelloWorld.c</in>
       </df>
     </df>
     <df root="." name="1">
+      <df name="build">
+        <df name="CMakeFiles">
+          <df name="3.3.2">
+            <df name="CompilerIdC">
+            </df>
+          </df>
+          <df name="afb-daemon.dir">
+          </df>
+          <df name="CMakeTmp">
+          </df>
+        </df>
+        <df name="plugins">
+          <df name="CMakeFiles">
+            <df name="plugins.dir">
+              <df name="audio">
+              </df>
+              <df name="radio">
+              </df>
+              <df name="samples">
+              </df>
+              <df name="session">
+              </df>
+            </df>
+          </df>
+        </df>
+        <df name="src">
+          <df name="CMakeFiles">
+            <df name="src.dir">
+            </df>
+          </df>
+        </df>
+      </df>
       <df name="doc">
         <df name="nbproject.template">
           <df name="private">
         <gdb_interceptlist>
           <gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
         </gdb_interceptlist>
+        <gdb_signals>
+        </gdb_signals>
         <gdb_options>
           <DebugOptions>
           </DebugOptions>
 --token=123456789</runcommandpicklistitem>
           <runcommandpicklistitem>"${OUTPUT_PATH}" --verbose --alias=icons:/usr/share/icons --token=123456789</runcommandpicklistitem>
           <runcommandpicklistitem>"${OUTPUT_PATH}" --verbose --alias=icons:/usr/share/icons --token=123456789 --rootdir=/home/fulup/Workspace/afb-client/dist.dev</runcommandpicklistitem>
+          <runcommandpicklistitem>"${OUTPUT_PATH}" --verbose --alias=icons:/usr/share/icons --token=123456789 --rootdir=/home/fulup/Workspace/afb-client/dist.dev --sessiondir=/tmp --port=1235</runcommandpicklistitem>
         </runcommandpicklist>
-        <runcommand>"${OUTPUT_PATH}" --verbose --alias=icons:/usr/share/icons --token=123456789 --rootdir=/home/fulup/Workspace/afb-client/dist.dev</runcommand>
+        <runcommand>"${OUTPUT_PATH}" --verbose --alias=icons:/usr/share/icons --token=123456789 --rootdir=/home/fulup/Workspace/afb-client/dist.dev --sessiondir=/tmp --port=1235</runcommand>
         <rundir>build</rundir>
         <buildfirst>true</buildfirst>
         <terminal-type>0</terminal-type>
index 02f6330..efd309c 100644 (file)
@@ -121,16 +121,26 @@ STATIC json_object* freeRadio (AFB_clientCtx *client) {
 
 /* ------ PUBLIC PLUGIN FUNCTIONS --------- */
 
-STATIC json_object* power (AFB_request *request) {      /* AFB_SESSION_CREATE */
+STATIC json_object* init (AFB_request *request) {       /* AFB_SESSION_CREATE */
+
+    radioCtxHandleT *ctx;
+    json_object *jresp;
+
+    /* create a private client context */
+    ctx = initRadioCtx();
+    request->client->ctx = (radioCtxHandleT*)ctx;
+
+    jresp = json_object_new_object();
+    json_object_object_add(jresp, "token", json_object_new_string (request->client->token));
+}
+
+STATIC json_object* power (AFB_request *request) {       /* AFB_SESSION_CHECK */
     
     pluginHandleT *handle = request->client->plugin->handle; 
     radioCtxHandleT *ctx = (radioCtxHandleT*)request->client->ctx;
     const char *value = getQueryValue (request, "value");
     json_object *jresp;
 
-    /* create a private client context if needed */
-    if (!ctx) ctx = initRadioCtx();
-
     /* no "?value=" parameter : return current state */
     if (!value) {
         jresp = json_object_new_object();
@@ -265,7 +275,7 @@ STATIC json_object* play (AFB_request *request) {        /* AFB_SESSION_CHECK */
 
     radioCtxHandleT *ctx = (radioCtxHandleT*)request->client->ctx;
     const char *value = getQueryValue (request, "value");
-    json_object *jresp;
+    json_object *jresp = json_object_new_object();
     
     /* no "?value=" parameter : return current state */
     if (!value) {
@@ -279,8 +289,6 @@ STATIC json_object* play (AFB_request *request) {        /* AFB_SESSION_CHECK */
         /* radio playback */
         ctx->is_playing = 1;
         _radio_play (ctx->idx);
-
-        jresp = json_object_new_object();
         json_object_object_add (jresp, "play", json_object_new_string ("on"));
     }
 
@@ -289,8 +297,6 @@ STATIC json_object* play (AFB_request *request) {        /* AFB_SESSION_CHECK */
         /* radio stop */
         ctx->is_playing = 0;
         _radio_stop (ctx->idx);
-
-        jresp = json_object_new_object();
         json_object_object_add (jresp, "play-on", json_object_new_string ("off"));
     }
 
@@ -303,7 +309,8 @@ STATIC json_object* status (AFB_request *request) {
 
 
 STATIC AFB_restapi pluginApis[]= {
-  {"power"  , AFB_SESSION_CREATE, (AFB_apiCB)power      , "Radio API - power"},
+  {"init"   , AFB_SESSION_CREATE, (AFB_apiCB)init       , "Radio API - init"},
+  {"power"  , AFB_SESSION_CHECK,  (AFB_apiCB)power      , "Radio API - power"},
   {"mode"   , AFB_SESSION_CHECK,  (AFB_apiCB)mode       , "Radio API - mode"},
   {"freq"   , AFB_SESSION_CHECK,  (AFB_apiCB)freq       , "Radio API - freq"},
   {"mute"   , AFB_SESSION_CHECK,  (AFB_apiCB)mute       , "Radio API - mute"},