<!-- Method definitions -->
+ <method name="ttsd_worker_submit_report_async">
+ <arg type="s" name="report" direction="in"/>
+ <arg type="i" name="ret" direction="out"/>
+ </method>
+
<method name="ttsd_worker_submit_report">
<arg type="s" name="report" direction="in"/>
<arg type="i" name="ret" direction="out"/>
#ifndef __TTSD_WORKER_LIB_H__
#define __TTSD_WORKER_LIB_H__
+typedef void(*ttsd_worker_submit_report_completed_cb)(char *result, void *user_data);
+
+int ttsd_worker_submit_report_async(char *report, ttsd_worker_submit_report_completed_cb completed_cb);
int ttsd_worker_submit_report(char *report);
#endif /* __TTSD_WORKER_LIB_H__ */
GCancellable *cancellable;
GDBusConnection *client_bus;
GDBusProxy *client_bus_proxy;
+ ttsd_worker_submit_report_completed_cb completed_cb;
} dbus_h;
static dbus_h *__make_dbus_connection(void);
static void __destroy_dbus_connection(dbus_h *h);
+static void __submit_completed_cb(GObject *source_object, GAsyncResult *res, gpointer user_data);
static void __destroy_dbus_connection(dbus_h *h)
{
return NULL;
}
+static void __submit_completed_cb(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ GError *g_error = NULL;
+ GVariant *g_var;
+ dbus_h *h = user_data;
+ char *result = NULL;
+
+ _D("Send completed");
+
+ if (h == NULL) {
+ _E("There's no user_data for dbus_h");
+ return;
+ }
+
+ g_var = g_dbus_proxy_call_finish(h->client_bus_proxy, res, &g_error);
+ if (g_error) {
+ _E("DBus proxy call is failed[%s]", g_error->message);
+ result = strdup("Failed to submit report");
+ g_error_free(g_error);
+ } else {
+ result = strdup("Success to submit report");
+ g_variant_unref(g_var);
+ }
+
+ h->completed_cb(result, NULL);
+
+ __destroy_dbus_connection(h);
+}
+
+int ttsd_worker_submit_report_async(char *report, ttsd_worker_submit_report_completed_cb completed_cb)
+{
+ dbus_h *h = NULL;
+
+ h = __make_dbus_connection();
+ if (!h) {
+ _E("Failed to make dbus connection");
+ return -1;
+ }
+
+ h->completed_cb = completed_cb;
+
+ g_dbus_proxy_call(h->client_bus_proxy, "ttsd_worker_submit_report_async", g_variant_new("(s)", report), G_DBUS_CALL_FLAGS_NONE, -1, h->cancellable, (GAsyncReadyCallback) __submit_completed_cb, h);
+
+ return 0;
+}
+
int ttsd_worker_submit_report(char *report)
{
dbus_h *h = NULL;