From: Daniele Ricci <[email protected]>
---
src/odeviced/dbus/vibrator.h | 137 ++++++++
src/odeviced/dbus/vibrator.xml | 17 +
src/odeviced/frameworkd-glib-odeviced-vibrator.c | 386 ++++++++++++++++++++++
src/odeviced/frameworkd-glib-odeviced-vibrator.h | 36 ++
4 files changed, 576 insertions(+), 0 deletions(-)
create mode 100644 src/odeviced/dbus/vibrator.h
create mode 100644 src/odeviced/dbus/vibrator.xml
create mode 100644 src/odeviced/frameworkd-glib-odeviced-vibrator.c
create mode 100644 src/odeviced/frameworkd-glib-odeviced-vibrator.h
diff --git a/src/odeviced/dbus/vibrator.h b/src/odeviced/dbus/vibrator.h
new file mode 100644
index 0000000..9548292
--- /dev/null
+++ b/src/odeviced/dbus/vibrator.h
@@ -0,0 +1,137 @@
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef _DBUS_GLIB_ASYNC_DATA_FREE
+#define _DBUS_GLIB_ASYNC_DATA_FREE
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+void
+_dbus_glib_async_data_free (gpointer stuff)
+{
+ g_slice_free (DBusGAsyncData, stuff);
+}
+#endif
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freesmartphone_Device_Vibrator
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freesmartphone_Device_Vibrator
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+org_freesmartphone_Device_Vibrator_vibrate_pattern (DBusGProxy
*proxy, const gint IN_pulses, const gint IN_on_duration, const gint
IN_off_duration, const gint IN_strength, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "VibratePattern", error,
G_TYPE_INT, IN_pulses, G_TYPE_INT, IN_on_duration, G_TYPE_INT,
IN_off_duration, G_TYPE_INT, IN_strength, G_TYPE_INVALID,
G_TYPE_INVALID);
+}
+
+typedef void (*org_freesmartphone_Device_Vibrator_vibrate_pattern_reply)
(DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+org_freesmartphone_Device_Vibrator_vibrate_pattern_async_callback
(DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(org_freesmartphone_Device_Vibrator_vibrate_pattern_reply)data->cb)
(proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+org_freesmartphone_Device_Vibrator_vibrate_pattern_async (DBusGProxy
*proxy, const gint IN_pulses, const gint IN_on_duration, const gint
IN_off_duration, const gint IN_strength,
org_freesmartphone_Device_Vibrator_vibrate_pattern_reply callback,
gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_slice_new (DBusGAsyncData);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "VibratePattern",
org_freesmartphone_Device_Vibrator_vibrate_pattern_async_callback,
stuff, _dbus_glib_async_data_free, G_TYPE_INT, IN_pulses, G_TYPE_INT,
IN_on_duration, G_TYPE_INT, IN_off_duration, G_TYPE_INT, IN_strength,
G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+org_freesmartphone_Device_Vibrator_vibrate (DBusGProxy *proxy, const
gint IN_duration, const gint IN_strength, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Vibrate", error, G_TYPE_INT,
IN_duration, G_TYPE_INT, IN_strength, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*org_freesmartphone_Device_Vibrator_vibrate_reply)
(DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+org_freesmartphone_Device_Vibrator_vibrate_async_callback (DBusGProxy
*proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(org_freesmartphone_Device_Vibrator_vibrate_reply)data->cb)
(proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+org_freesmartphone_Device_Vibrator_vibrate_async (DBusGProxy *proxy,
const gint IN_duration, const gint IN_strength,
org_freesmartphone_Device_Vibrator_vibrate_reply callback, gpointer
userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_slice_new (DBusGAsyncData);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Vibrate",
org_freesmartphone_Device_Vibrator_vibrate_async_callback, stuff,
_dbus_glib_async_data_free, G_TYPE_INT, IN_duration, G_TYPE_INT,
IN_strength, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+org_freesmartphone_Device_Vibrator_stop (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Stop", error, G_TYPE_INVALID,
G_TYPE_INVALID);
+}
+
+typedef void (*org_freesmartphone_Device_Vibrator_stop_reply)
(DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+org_freesmartphone_Device_Vibrator_stop_async_callback (DBusGProxy
*proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(org_freesmartphone_Device_Vibrator_stop_reply)data->cb) (proxy,
error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+org_freesmartphone_Device_Vibrator_stop_async (DBusGProxy *proxy,
org_freesmartphone_Device_Vibrator_stop_reply callback, gpointer
userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_slice_new (DBusGAsyncData);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Stop",
org_freesmartphone_Device_Vibrator_stop_async_callback, stuff,
_dbus_glib_async_data_free, G_TYPE_INVALID);
+}
+#endif /* defined
DBUS_GLIB_CLIENT_WRAPPERS_org_freesmartphone_Device_Vibrator */
+
+G_END_DECLS
diff --git a/src/odeviced/dbus/vibrator.xml b/src/odeviced/dbus/vibrator.xml
new file mode 100644
index 0000000..acf2e02
--- /dev/null
+++ b/src/odeviced/dbus/vibrator.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection
1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node name="/">
+ <interface name="org.freesmartphone.Device.Vibrator">
+ <method name="VibratePattern">
+ <arg direction="in" type="i" name="pulses"/>
+ <arg direction="in" type="i" name="on_duration"/>
+ <arg direction="in" type="i" name="off_duration"/>
+ <arg direction="in" type="i" name="strength"/>
+ </method>
+ <method name="Vibrate">
+ <arg direction="in" type="i" name="duration"/>
+ <arg direction="in" type="i" name="strength"/>
+ </method>
+ <method name="Stop"/>
+ </interface>
+</node>
diff --git a/src/odeviced/frameworkd-glib-odeviced-vibrator.c
b/src/odeviced/frameworkd-glib-odeviced-vibrator.c
new file mode 100644
index 0000000..a4b422f
--- /dev/null
+++ b/src/odeviced/frameworkd-glib-odeviced-vibrator.c
@@ -0,0 +1,386 @@
+/*
+ * Copyright (C) 2008
+ * Authors (alphabetical) :
+ * Marc-Olivier Barre <[email protected]>
+ * Julien Cassignol <[email protected]>
+ * quickdev
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser Public License for more details.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+#include "frameworkd-glib-odeviced-dbus.h"
+#include "dbus/vibrator.h"
+
+DBusGProxy *odevicedVibratorBus = NULL;
+
+typedef struct {
+ void (*callback) (GError *, gpointer);
+ gpointer userdata;
+} odeviced_vibrator_vibrate_pattern_data_t;
+
+static void
+odeviced_vibrator_vibrate_pattern_callback(DBusGProxy * bus, GError *
dbus_error,
+ gpointer userdata)
+{
+ (void)bus;
+ odeviced_vibrator_vibrate_pattern_data_t *data = userdata;
+ GError *error = NULL;
+
+ if (data->callback != NULL) {
+ if (dbus_error != NULL)
+ error = dbus_handle_errors(dbus_error);
+
+ data->callback(error, data->userdata);
+ if (error != NULL)
+ g_error_free(error);
+ }
+
+ if (dbus_error != NULL)
+ g_error_free(dbus_error);
+ g_free(data);
+}
+
+void odeviced_vibrator_vibrate_pattern(int pulses, int on_duration,
int off_duration, int strength,
+ void (*callback) (GError *, gpointer), gpointer userdata)
+{
+ odeviced_vibrator_vibrate_pattern_data_t *data =
+ g_malloc(sizeof(odeviced_vibrator_vibrate_pattern_data_t));
+ data->callback = callback;
+ data->userdata = userdata;
+
+
org_freesmartphone_Device_Vibrator_vibrate_pattern_async(odevicedVibratorBus,
+ pulses, on_duration, off_duration, strength,
+ odeviced_vibrator_vibrate_pattern_callback,
+ data);
+}
+
+typedef struct {
+ void (*callback) (GError *, gpointer);
+ gpointer userdata;
+} odeviced_vibrator_vibrate_data_t;
+
+static void
+odeviced_vibrator_vibrate_callback(DBusGProxy * bus, GError * dbus_error,
+ gpointer userdata)
+{
+ (void)bus;
+ odeviced_vibrator_vibrate_data_t *data = userdata;
+ GError *error = NULL;
+
+ if (data->callback != NULL) {
+ if (dbus_error != NULL)
+ error = dbus_handle_errors(dbus_error);
+
+ data->callback(error, data->userdata);
+ if (error != NULL)
+ g_error_free(error);
+ }
+
+ if (dbus_error != NULL)
+ g_error_free(dbus_error);
+ g_free(data);
+}
+
+void odeviced_vibrator_vibrate(int duration, int strength,
+ void (*callback) (GError *, gpointer), gpointer userdata)
+{
+ odeviced_vibrator_vibrate_data_t *data =
+ g_malloc(sizeof(odeviced_vibrator_vibrate_data_t));
+ data->callback = callback;
+ data->userdata = userdata;
+
+ org_freesmartphone_Device_Vibrator_vibrate_async(odevicedVibratorBus,
+ duration, strength,
+ odeviced_vibrator_vibrate_callback,
+ data);
+}
+
+typedef struct {
+ void (*callback) (GError *, gpointer);
+ gpointer userdata;
+} odeviced_vibrator_stop_data_t;
+
+static void
+odeviced_vibrator_stop_callback(DBusGProxy * bus, GError * dbus_error,
+ gpointer userdata)
+{
+ (void)bus;
+ odeviced_vibrator_stop_data_t *data = userdata;
+ GError *error = NULL;
+
+ if (data->callback != NULL) {
+ if (dbus_error != NULL)
+ error = dbus_handle_errors(dbus_error);
+
+ data->callback(error, data->userdata);
+ if (error != NULL)
+ g_error_free(error);
+ }
+
+ if (dbus_error != NULL)
+ g_error_free(dbus_error);
+ g_free(data);
+}
+
+void odeviced_vibrator_stop(void (*callback) (GError *, gpointer),
gpointer userdata)
+{
+ odeviced_vibrator_stop_data_t *data =
+ g_malloc(sizeof(odeviced_vibrator_stop_data_t));
+ data->callback = callback;
+ data->userdata = userdata;
+
+ org_freesmartphone_Device_Vibrator_stop_async(odevicedVibratorBus,
+ odeviced_vibrator_stop_callback,
+ data);
+}
+
+#if 0
+void
+odeviced_audio_get_info_callback(DBusGProxy * bus, GHashTable * info,
+ GError * dbus_error, gpointer userdata)
+{
+ (void)bus;
+ odeviced_audio_get_info_data_t *data = userdata;
+ GError *error = NULL;
+
+ if (data->callback != NULL) {
+ if (dbus_error != NULL)
+ error = dbus_handle_errors(dbus_error);
+
+ data->callback(error, info, data->userdata);
+ if (error != NULL) {
+ g_error_free(error);
+ }
+ else {
+ g_free(info);
+ }
+ }
+
+ if (dbus_error != NULL)
+ g_error_free(dbus_error);
+ g_free(data);
+}
+
+void
+odeviced_audio_get_info(void (*callback) (GError *, GHashTable *, gpointer),
+ gpointer userdata)
+{
+ dbus_connect_to_odeviced_audio();
+
+ odeviced_audio_get_info_data_t *data =
+ g_malloc(sizeof(odeviced_audio_get_info_data_t));
+ data->callback = callback;
+ data->userdata = userdata;
+
+ org_freesmartphone_Device_Audio_get_info_async(odevicedAudioBus,
+
odeviced_audio_get_info_callback,
+ data);
+}
+
+typedef struct {
+ void (*callback) (GError *, gpointer);
+ gpointer userdata;
+} odeviced_audio_push_scenario_data_t;
+
+
+void
+odeviced_audio_push_scenario_callback(DBusGProxy * bus, GError * dbus_error,
+ gpointer userdata)
+{
+ (void)bus;
+ odeviced_audio_push_scenario_data_t *data = userdata;
+ GError *error = NULL;
+
+ if (data->callback != NULL) {
+ if (dbus_error != NULL)
+ error = dbus_handle_errors(dbus_error);
+
+ data->callback(error, data->userdata);
+ if (error != NULL)
+ g_error_free(error);
+ }
+
+ if (dbus_error != NULL)
+ g_error_free(dbus_error);
+ g_free(data);
+}
+
+void
+odeviced_audio_push_scenario(char *scenario,
+ void (*callback) (GError *, gpointer),
+ gpointer userdata)
+{
+ dbus_connect_to_odeviced_audio();
+
+ odeviced_audio_push_scenario_data_t *data =
+ g_malloc(sizeof(odeviced_audio_push_scenario_data_t));
+ data->callback = callback;
+ data->userdata = userdata;
+
+ org_freesmartphone_Device_Audio_push_scenario_async(odevicedAudioBus,
+ scenario,
+
odeviced_audio_push_scenario_callback,
+ data);
+}
+
+typedef struct {
+ void (*callback) (GError *, char *, gpointer);
+ gpointer userdata;
+} odeviced_audio_pull_scenario_data_t;
+
+
+void
+odeviced_audio_pull_scenario_callback(DBusGProxy * bus, char *scenario,
+ GError * dbus_error, gpointer userdata)
+{
+ (void)bus;
+ odeviced_audio_pull_scenario_data_t *data = userdata;
+ GError *error = NULL;
+
+ if (data->callback != NULL) {
+ if (dbus_error != NULL)
+ error = dbus_handle_errors(dbus_error);
+
+ data->callback(error, scenario, data->userdata);
+ if (error != NULL)
+ g_error_free(error);
+ else
+ free(scenario);
+ }
+
+ if (dbus_error != NULL)
+ g_error_free(dbus_error);
+ g_free(data);
+}
+
+void
+odeviced_audio_pull_scenario(void (*callback) (GError *, char *, gpointer),
+ gpointer userdata)
+{
+ dbus_connect_to_odeviced_audio();
+
+ odeviced_audio_pull_scenario_data_t *data =
+ g_malloc(sizeof(odeviced_audio_pull_scenario_data_t));
+ data->callback = callback;
+ data->userdata = userdata;
+
+ org_freesmartphone_Device_Audio_pull_scenario_async(odevicedAudioBus,
+
odeviced_audio_pull_scenario_callback,
+ data);
+}
+
+typedef struct {
+ void (*callback) (GError *, gpointer);
+ gpointer userdata;
+} odeviced_audio_set_scenario_data_t;
+
+
+void
+odeviced_audio_set_scenario_callback(DBusGProxy * bus, GError * dbus_error,
+ gpointer userdata)
+{
+ (void)bus;
+ odeviced_audio_set_scenario_data_t *data = userdata;
+ GError *error = NULL;
+
+ if (data->callback != NULL) {
+ if (dbus_error != NULL)
+ error = dbus_handle_errors(dbus_error);
+
+ data->callback(error, data->userdata);
+ if (error != NULL)
+ g_error_free(error);
+ }
+
+ if (dbus_error != NULL)
+ g_error_free(dbus_error);
+ g_free(data);
+}
+
+void
+odeviced_audio_set_scenario(char *scenario,
+ void (*callback) (GError *, gpointer),
+ gpointer userdata)
+{
+ dbus_connect_to_odeviced_audio();
+
+ odeviced_audio_set_scenario_data_t *data =
+ g_malloc(sizeof(odeviced_audio_set_scenario_data_t));
+ data->callback = callback;
+ data->userdata = userdata;
+
+ org_freesmartphone_Device_Audio_set_scenario_async(odevicedAudioBus,
+ scenario, odeviced_audio_set_scenario_callback, data);
+}
+
+typedef struct {
+ void (*callback) (GError *, gpointer);
+ gpointer userdata;
+} odeviced_audio_save_scenario_data_t;
+
+void
+odeviced_audio_save_scenario_callback(DBusGProxy * bus, GError * dbus_error,
+ gpointer userdata)
+{
+ (void)bus;
+ odeviced_audio_save_scenario_data_t *data = userdata;
+ GError *error = NULL;
+
+ if (data->callback != NULL) {
+ if (dbus_error != NULL)
+ error = dbus_handle_errors(dbus_error);
+
+ data->callback(error, data->userdata);
+ if (error != NULL)
+ g_error_free(error);
+ }
+
+ if (dbus_error != NULL)
+ g_error_free(dbus_error);
+ g_free(data);
+}
+
+void
+odeviced_audio_save_scenario(const char* scenario,
+ void (*callback)(GError *, gpointer),
+ gpointer userdata)
+{
+ dbus_connect_to_odeviced_audio();
+
+ odeviced_audio_save_scenario_data_t *data =
+ g_malloc(sizeof(odeviced_audio_save_scenario_data_t));
+ data->callback = callback;
+ data->userdata = userdata;
+
+ org_freesmartphone_Device_Audio_save_scenario_async(odevicedAudioBus,
+ scenario, odeviced_audio_save_scenario_callback, data);
+}
+
+void
+odeviced_audio_sound_status_handler(DBusGProxy * proxy, char *id,
+ char *status, GHashTable * properties,
+ gpointer user_data)
+{
+ (void)proxy;
+ void (*callback) (char *, char *, GHashTable *) = NULL;
+
+ callback = user_data;
+
+ if (callback != NULL)
+ (*callback) (id, status, properties);
+}
+#endif
\ No newline at end of file
diff --git a/src/odeviced/frameworkd-glib-odeviced-vibrator.h
b/src/odeviced/frameworkd-glib-odeviced-vibrator.h
new file mode 100644
index 0000000..c700db9
--- /dev/null
+++ b/src/odeviced/frameworkd-glib-odeviced-vibrator.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2008
+ * Authors (alphabetical) :
+ * quickdev
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser Public License for more details.
+ */
+
+#ifndef FRAMEWORKD_GLIB_ODEVICED_VIBRATOR_H
+#define FRAMEWORKD_GLIB_ODEVICED_VIBRATOR_H
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+void odeviced_vibrator_vibrate_pattern(int pulses, int on_duration,
int off_duration, int strength,
+ void (*callback) (GError *, gpointer), gpointer userdata);
+
+void odeviced_vibrator_vibrate(int duration, int strength,
+ void (*callback) (GError *, gpointer), gpointer userdata);
+
+void odeviced_vibrator_stop(void (*callback) (GError *, gpointer),
gpointer userdata);
+
+
+extern DBusGProxy *odevicedVibratorBus;
+
+G_END_DECLS
+#endif
--
1.6.3.3
_______________________________________________
Shr-devel mailing list
[email protected]
http://lists.shr-project.org/mailman/listinfo/shr-devel