summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-01-28 20:09:45 +0100
committerJavier S. Pedro <maemo@javispedro.com>2011-01-28 20:09:45 +0100
commit7535fc47a7e2ae2b0055de65efcbdc2af44c3fa0 (patch)
tree470fd5477a97995f4f9531856982c3c25ee52404
parentbf65330d3ef0e57d0bf2d4c6171c77038695b771 (diff)
downloadcfmradio-7535fc47a7e2ae2b0055de65efcbdc2af44c3fa0.tar.gz
cfmradio-7535fc47a7e2ae2b0055de65efcbdc2af44c3fa0.zip
adding bugtracker link
-rw-r--r--debian/changelog6
-rw-r--r--debian/control1
-rw-r--r--radio_routing.c147
3 files changed, 154 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index fdd0fdb..7391e7e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+cfmradio (0.3.3) unstable; urgency=low
+
+ * Adding bugtracker link.
+
+ -- Javier S. Pedro <maemo@javispedro.com> Fri, 28 Jan 2011 20:09:32 +0100
+
cfmradio (0.3.2) unstable; urgency=low
* Playing with making presets a GtkTreeModel.
diff --git a/debian/control b/debian/control
index 144234d..26613da 100644
--- a/debian/control
+++ b/debian/control
@@ -15,6 +15,7 @@ XB-Description-es_ES: Reproductor de radio FM
Un reproductor de radio FM escrito en C usando Hildon con una interfaz
minimalista.
XSBC-Maemo-Display-Name: C FM Radio
+XSBC-Bugtracker: https://github.com/javispedro/cfmradio/issues
XB-Maemo-Icon-26:
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAA
AAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oK
diff --git a/radio_routing.c b/radio_routing.c
new file mode 100644
index 0000000..342f7cc
--- /dev/null
+++ b/radio_routing.c
@@ -0,0 +1,147 @@
+
+#include <dbus/dbus.h>
+
+#include "radio_routing.h"
+
+#define SIGNAL_PATH "/com/nokia/policy/decision"
+#define SIGNAL_IFACE "com.nokia.policy"
+#define SIGNAL_NAME "audio_actions"
+
+#define POLICY_AUDIO_ROUTE "com.nokia.policy.audio_route"
+
+typedef struct {
+ const char * type;
+ const char * device;
+ const char * mode;
+ const char * hwid;
+} audio_route;
+
+static void add_entry(DBusMessageIter *array, const char *key, const char *value)
+{
+ DBusMessageIter str, var;
+
+ dbus_message_iter_open_container(array, DBUS_TYPE_STRUCT, NULL, &str);
+ dbus_message_iter_append_basic(&str, DBUS_TYPE_STRING, &key);
+ dbus_message_iter_open_container(&str, DBUS_TYPE_VARIANT,
+ DBUS_TYPE_STRING_AS_STRING, &var);
+ dbus_message_iter_append_basic(&var, DBUS_TYPE_STRING, &value);
+ dbus_message_iter_close_container(&str, &var);
+ dbus_message_iter_close_container(array, &str);
+}
+
+static void fill_array2(DBusMessageIter *array, const audio_route *route)
+{
+ add_entry(array, "type", route->type);
+ add_entry(array, "device", route->device);
+ add_entry(array, "mode", route->mode);
+ add_entry(array, "hwid", route->hwid);
+}
+
+static void fill_dict(DBusMessageIter *dict, const audio_route *route)
+{
+ DBusMessageIter entry, array1, array2;
+ const char * str = POLICY_AUDIO_ROUTE;
+
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str);
+ dbus_message_iter_open_container(&entry, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING, &array1);
+ dbus_message_iter_open_container(&array1, DBUS_TYPE_ARRAY,
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING, &array2);
+ fill_array2(&array2, route);
+ dbus_message_iter_close_container(&array1, &array2);
+ dbus_message_iter_close_container(&entry, &array1);
+ dbus_message_iter_close_container(dict, &entry);
+}
+
+static void route_audio(const audio_route *route)
+{
+ DBusError error;
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter it, dict;
+ const dbus_uint32_t zero = 0;
+
+ dbus_error_init(&error);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ msg = dbus_message_new_signal(SIGNAL_PATH, SIGNAL_IFACE, SIGNAL_NAME);
+ dbus_message_iter_init_append(msg, &it);
+ dbus_message_iter_append_basic(&it, DBUS_TYPE_UINT32, &zero);
+
+ dbus_message_iter_open_container(&it, DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+ &dict);
+ fill_dict(&dict, route);
+ dbus_message_iter_close_container(&it, &dict);
+
+ dbus_connection_send(conn, msg, NULL);
+ dbus_message_unref(msg);
+}
+
+void cfm_radio_route_audio_to_headphones()
+{
+ audio_route route = {
+ .type = "sink",
+ .device = "headphone",
+ .mode = "lineout",
+ .hwid = "na"
+ };
+ route_audio(&route);
+}
+
+void cfm_radio_route_audio_to_speakers()
+{
+ audio_route route = {
+ .type = "sink",
+ .device = "ihf",
+ .mode = "ihf",
+ .hwid = "na"
+ };
+ route_audio(&route);
+}
+
+void cfm_radio_route_audio_bypass()
+{
+ audio_route route = {
+ .type = "source",
+ .device = "fmrx",
+ .mode = "na",
+ .hwid = "na"
+ };
+ route_audio(&route);
+}
+
+void cfm_radio_route_audio_reset()
+{
+ audio_route route = {
+ .type = "sink",
+ .device = "headphone",
+ .mode = "lineout",
+ .hwid = "na"
+ };
+ route_audio(&route);
+ audio_route route2 = {
+ .type = "source",
+ .device = "microphone",
+ .mode = "na",
+ .hwid = "na"
+ };
+ route_audio(&route2);
+}
+