summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nbproject/configurations.xml165
-rw-r--r--nbproject/private/Default.properties1
-rw-r--r--nbproject/private/configurations.xml74
-rw-r--r--plugins/radio/radio-api.c27
4 files changed, 223 insertions, 44 deletions
diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml
index 0a5d9b3f..c9b7be53 100644
--- a/nbproject/configurations.xml
+++ b/nbproject/configurations.xml
@@ -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>
@@ -60,23 +74,6 @@
<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>
@@ -85,11 +82,89 @@
<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>
@@ -97,14 +172,19 @@
<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>
@@ -113,20 +193,24 @@
<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>
@@ -140,10 +224,17 @@
<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>
@@ -152,20 +243,24 @@
<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>
@@ -175,7 +270,7 @@
</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>
@@ -183,10 +278,17 @@
<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>
@@ -195,12 +297,11 @@
<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>
diff --git a/nbproject/private/Default.properties b/nbproject/private/Default.properties
index e63c2370..e69de29b 100644
--- a/nbproject/private/Default.properties
+++ b/nbproject/private/Default.properties
@@ -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
diff --git a/nbproject/private/configurations.xml b/nbproject/private/configurations.xml
index 713e87f4..e198cc10 100644
--- a/nbproject/private/configurations.xml
+++ b/nbproject/private/configurations.xml
@@ -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>
@@ -40,6 +77,38 @@
</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">
@@ -87,6 +156,8 @@
<gdb_interceptlist>
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
</gdb_interceptlist>
+ <gdb_signals>
+ </gdb_signals>
<gdb_options>
<DebugOptions>
</DebugOptions>
@@ -104,8 +175,9 @@
--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>
diff --git a/plugins/radio/radio-api.c b/plugins/radio/radio-api.c
index 02f6330c..efd309c3 100644
--- a/plugins/radio/radio-api.c
+++ b/plugins/radio/radio-api.c
@@ -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"},