[pkg-fso-commits] [SCM] libframeworkd-phonegui branch, upstream, updated. 640da47bfcff755388d0fb8f443eb34e0dea3c72
Julien 'Ainulindale' Cassignol
ainulindale at gmail.com
Sat Dec 27 20:50:01 UTC 2008
The following commit has been merged in the upstream branch:
commit 953a35b8ee95183783d7896f80faa5f78d51d90a
Author: Julien 'Ainulindale' Cassignol <ainulindale at gmail.com>
Date: Thu Nov 27 15:39:51 2008 +0100
ophonekitd: Introduced a dbus provider to manage resources and such using ophonekitd point of view.
diff --git a/ophonekitd/configure.ac b/ophonekitd/configure.ac
index f63e6ec..0c5ef10 100644
--- a/ophonekitd/configure.ac
+++ b/ophonekitd/configure.ac
@@ -13,15 +13,24 @@ AC_HEADER_STDC
PKG_CHECK_MODULES(FRAMEWORKD_GLIB, libframeworkd-glib)
PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1)
+PKG_CHECK_MODULES(DBUS, dbus-1 glib-2.0 gthread-2.0)
PKG_CHECK_MODULES(FRAMEWORKD_PHONEGUI, libframeworkd-phonegui)
AC_SUBST(DBUS_GLIB_CFLAGS)
AC_SUBST(DBUS_GLIB_LIBS)
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
AC_SUBST(FRAMEWORKD_GLIB_CFLAGS)
AC_SUBST(FRAMEWORKD_GLIB_LIBS)
AC_SUBST(FRAMEWORKD_PHONEGUI_CFLAGS)
AC_SUBST(FRAMEWORKD_PHONEGUI_LIBS)
+AC_PATH_PROG(DBUSBINDINGTOOL, dbus-binding-tool)
+AC_SUBST(DBUSBINDINGTOOL)
+
+GLIB_GENMARSHAL=`$PKG_CONFIG glib-2.0 --variable=glib_genmarshal`
+AC_SUBST(GLIB_GENMARSHAL)
+
AC_OUTPUT([
Makefile
src/Makefile
diff --git a/ophonekitd/data/ophonekitd.conf b/ophonekitd/data/ophonekitd.conf
new file mode 100644
index 0000000..380ab17
--- /dev/null
+++ b/ophonekitd/data/ophonekitd.conf
@@ -0,0 +1,8 @@
+<busconfig>
+ <policy user="root">
+ <allow own="org.shr.ophonekitd.Usage"/>
+ <allow send_path="/org/shr/ophonekitd/Usage"/>
+ <allow send_destination="org.shr.ophonekitd.Usage"/>
+ <allow receive_sender="org.shr.ophonekitd.Usage"/>
+ </policy>
+</busconfig>
diff --git a/ophonekitd/src/Makefile.am b/ophonekitd/src/Makefile.am
index 164c0a7..4c02fb8 100644
--- a/ophonekitd/src/Makefile.am
+++ b/ophonekitd/src/Makefile.am
@@ -1,22 +1,35 @@
MAINTAINERCLEANFILES = Makefile.in
+ophonekitd-usage-service-glue.h: ${top_builddir}/src/dbus/ophonekitd-usage.xml
+ $(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=ophonekitd_usage_service $^
+
bin_PROGRAMS = ophonekitd
+dbus_sources = ophonekitd-usage-service-glue.h
+
-ophonekitd_SOURCES = \
+BUILT_SOURCES = $(dbus_sources)
+
+ophonekitd_SOURCES = $(dbus_sources) \
ophonekitd-main.c \
ophonekitd-main.h \
ophonekitd-phonegui.c \
- ophonekitd-phonegui.h
+ ophonekitd-phonegui.h \
+ ophonekitd-dbus-usage.c \
+ ophonekitd-dbus-usage.h \
+ ophonekitd-dbus.c \
+ ophonekitd-dbus.h
ophonekitd_CFLAGS = \
-DDATADIR=\"$(datadir)\" \
-DPKGDATADIR=\"$(pkgdatadir)\" \
@DBUS_GLIB_CFLAGS@ \
+ @DBUS_CFLAGS@ \
@FRAMEWORKD_GLIB_CFLAGS@ \
- @FRAMEWORKD_PHONEGUI_LIBS@
+ @FRAMEWORKD_PHONEGUI_LIBS@ -ggdb
ophonekitd_LDFLAGS = \
-ldl \
@DBUS_GLIB_LIBS@ \
+ @DBUS_LIBS@ \
@FRAMEWORKD_GLIB_LIBS@ \
@FRAMEWORKD_PHONEGUI_LIBS@
diff --git a/ophonekitd/src/dbus/ophonekitd-usage.xml b/ophonekitd/src/dbus/ophonekitd-usage.xml
new file mode 100644
index 0000000..88401ca
--- /dev/null
+++ b/ophonekitd/src/dbus/ophonekitd-usage.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<node name="/org/shr/ophonekitd/Usage">
+ <interface name="org.shr.ophonekitd.Usage">
+ <method name="RequestResource">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="resource" direction="in" />
+ </method>
+ <method name="ReleaseResource">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="resource" direction="in" />
+ </method>
+ <method name="GetResourceState">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="resource" direction="in" />
+ <arg type="b" name="state" direction="out" />
+ </method>
+ </interface>
+</node>
diff --git a/ophonekitd/src/ophonekitd-dbus-common.h b/ophonekitd/src/ophonekitd-dbus-common.h
new file mode 100644
index 0000000..73fddcd
--- /dev/null
+++ b/ophonekitd/src/ophonekitd-dbus-common.h
@@ -0,0 +1,4 @@
+
+#define OPHONEKITD_USAGE_SERVICE_PATH "/org/shr/ophonekitd/Usage"
+#define OPHONEKITD_USAGE_SERVICE_NAME "org.shr.ophonekitd.Usage"
+
diff --git a/ophonekitd/src/ophonekitd-dbus-usage.c b/ophonekitd/src/ophonekitd-dbus-usage.c
new file mode 100644
index 0000000..5364238
--- /dev/null
+++ b/ophonekitd/src/ophonekitd-dbus-usage.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2008
+ * Authors (alphabetical) :
+ * Marc-Olivier Barre <marco at marcochapeau.org>
+ * Julien Cassignol <ainulindale at gmail.com>
+ * Andreas Engelbredt Dalsgaard <andreas.dalsgaard at gmail.com>
+ * 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 <glib.h>
+#include <glib/gthread.h>
+#include <frameworkd-glib/frameworkd-glib-dbus.h>
+#include <frameworkd-glib/ousaged/frameworkd-glib-ousaged.h>
+#include "ophonekitd-dbus-usage.h"
+#include "ophonekitd-main.h"
+//#include "ophonekitd-usage-service-glue.h"
+
+G_DEFINE_TYPE(OphonekitdUsageService, ophonekitd_usage_service, G_TYPE_OBJECT)
+
+static void
+ophonekitd_usage_service_class_init (OphonekitdUsageServiceClass *klass)
+{
+// dbus_g_object_type_install_info (G_OBJECT_TYPE (klass), &dbus_glib_ophonekitd_usage_service_object_info);
+}
+
+static void
+ophonekitd_usage_service_init (OphonekitdUsageService *object)
+{
+}
+
+
+OphonekitdUsageService *
+ophonekitd_usage_service_new (void)
+{
+ return g_object_new (OPHONEKITD_TYPE_USAGE_SERVICE, NULL);
+}
+
+void ophonekitd_usage_get_resource_state_callback (GError* error, gboolean state, gpointer userdata)
+{
+ DBusGMethodInvocation *context = (DBusGMethodInvocation *)userdata;
+ if(error != NULL)
+ dbus_g_method_return_error(context, error);
+ else
+ dbus_g_method_return(context, state);
+}
+
+void ophonekitd_usage_service_get_resource_state (OphonekitdUsageService *object, const char* resource, DBusGMethodInvocation *context)
+{
+ if(resource != NULL)
+ ousaged_get_resource_state(resource, ophonekitd_usage_get_resource_state_callback, context);
+}
+
+typedef struct {
+ DBusGMethodInvocation *context;
+ char *resource;
+} ophonekitd_usage_request_resource_data_t;
+
+void ophonekitd_usage_request_resource_callback (GError* error, gpointer userdata)
+{
+ ophonekitd_usage_request_resource_data_t *data = userdata;
+
+ if(error != NULL)
+ dbus_g_method_return_error(data->context, error);
+ else {
+ g_timeout_add(5000, power_up_antenna, NULL);
+ dbus_g_method_return(data->context);
+ }
+}
+
+void ophonekitd_usage_service_request_resource (OphonekitdUsageService *object, const char* resource, DBusGMethodInvocation *context)
+{
+
+ if(resource != NULL) {
+ ophonekitd_usage_request_resource_data_t *data = g_malloc (sizeof (ophonekitd_usage_request_resource_data_t));
+ data->context = context;
+ data->resource = g_strdup(resource);
+ ousaged_request_resource(resource, ophonekitd_usage_request_resource_callback, data);
+ }
+}
+
+void ophonekitd_usage_release_resource_callback (GError* error, gpointer userdata)
+{
+ DBusGMethodInvocation *context = (DBusGMethodInvocation *)userdata;
+ if(error != NULL)
+ dbus_g_method_return_error(context, error);
+ else
+ dbus_g_method_return(context);
+}
+
+void ophonekitd_usage_service_release_resource (OphonekitdUsageService *object, const char* resource, DBusGMethodInvocation *context)
+{
+ if(resource != NULL)
+ ousaged_release_resource(resource, ophonekitd_usage_release_resource_callback, context);
+}
diff --git a/ophonekitd/src/ophonekitd-dbus-usage.h b/ophonekitd/src/ophonekitd-dbus-usage.h
new file mode 100644
index 0000000..52a776c
--- /dev/null
+++ b/ophonekitd/src/ophonekitd-dbus-usage.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2008
+ * Authors (alphabetical) :
+ * Marc-Olivier Barre <marco at marcochapeau.org>
+ * Julien Cassignol <ainulindale at gmail.com>
+ * 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 _OPHONEKITD_DBUS_USAGE_H
+#define _OPHONEKITD_DBUS_USAGE_H
+
+#include <glib-object.h>
+
+#define OPHONEKITD_TYPE_USAGE_SERVICE (ophonekitd_usage_service_get_type ())
+#define OPHONEKITD_USAGE_SERVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), OPHONEKITD_TYPE_USAGE_SERVICE, OphonekitdUsageService))
+#define OPHONEKITD_USAGE_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OPHONEKITD_TYPE_USAGE_SERVICE, OphonekitdUsageServiceClass))
+#define OPHONEKITD_IS_USAGE_SERVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), OPHONEKITD_TYPE_USAGE_SERVICE))
+#define OPHONEKITD_IS_USAGE_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OPHONEKITD_TYPE_USAGE_SERVICE))
+#define OPHONEKITD_USAGE_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OPHONEKITD_TYPE_USAGE_SERVICE, OphonekitdUsageServiceClass))
+
+
+typedef struct _OphonekitdUsageService OphonekitdUsageService;
+typedef struct _OphonekitdUsageServiceClass OphonekitdUsageServiceClass;
+
+GType ophonekitd_usage_service_get_type (void);
+
+struct _OphonekitdUsageService {
+ GObject parent;
+};
+
+struct _OphonekitdUsageServiceClass {
+ GObjectClass parent;
+};
+
+void ophonekitd_usage_service_get_resource_state (OphonekitdUsageService *object, const char* resource, DBusGMethodInvocation *context);
+void ophonekitd_usage_service_release_resource (OphonekitdUsageService *object, const char* resource, DBusGMethodInvocation *context);
+void ophonekitd_usage_service_request_resource (OphonekitdUsageService *object, const char* resource, DBusGMethodInvocation *context);
+
+OphonekitdUsageService *ophonekitd_usage_service_new (void);
+
+#endif
diff --git a/ophonekitd/src/ophonekitd-dbus.c b/ophonekitd/src/ophonekitd-dbus.c
new file mode 100644
index 0000000..097af0e
--- /dev/null
+++ b/ophonekitd/src/ophonekitd-dbus.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2008
+ * Authors (alphabetical) :
+ * Marc-Olivier Barre <marco at marcochapeau.org>
+ * Julien Cassignol <ainulindale at gmail.com>
+ * Andreas Engelbredt Dalsgaard <andreas.dalsgaard at gmail.com>
+ * 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 <string.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+#include "ophonekitd-dbus.h"
+#include "ophonekitd-dbus-common.h"
+#include "ophonekitd-dbus-usage.h"
+#include "ophonekitd-usage-service-glue.h"
+
+ static gpointer
+dbus_register_object (DBusGConnection *connection,
+ DBusGProxy *proxy,
+ GType object_type,
+ const DBusGObjectInfo *info,
+ const gchar *path)
+{
+ g_debug(path);
+ GObject *object = g_object_new (object_type, NULL);
+ dbus_g_object_type_install_info (object_type, info);
+ dbus_g_connection_register_g_object (connection, path, object);
+ return object;
+}
+
+void ophonekitd_dbus_start() {
+ GError *error = NULL;
+ guint result;
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ g_type_init();
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ proxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+
+ if(!org_freedesktop_DBus_request_name (proxy,
+ OPHONEKITD_USAGE_SERVICE_NAME,
+ DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error)) {
+ g_debug("Error requesting name! %s", error->message);
+ }
+
+
+ if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ g_debug ("Got result code %u from requesting name", result);
+ }
+
+ dbus_register_object (connection,
+ proxy,
+ OPHONEKITD_TYPE_USAGE_SERVICE,
+ &dbus_glib_ophonekitd_usage_service_object_info,
+ OPHONEKITD_USAGE_SERVICE_PATH);
+}
diff --git a/libframeworkd-phonegui-gtk/src/init.c b/ophonekitd/src/ophonekitd-dbus.h
similarity index 78%
copy from libframeworkd-phonegui-gtk/src/init.c
copy to ophonekitd/src/ophonekitd-dbus.h
index 57a5ab6..842fa1b 100644
--- a/libframeworkd-phonegui-gtk/src/init.c
+++ b/ophonekitd/src/ophonekitd-dbus.h
@@ -3,6 +3,7 @@
* Authors (alphabetical) :
* Marc-Olivier Barre <marco at marcochapeau.org>
* Julien Cassignol <ainulindale at gmail.com>
+ * 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
@@ -14,12 +15,9 @@
* GNU Lesser Public License for more details.
*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <gtk/gtk.h>
+#ifndef _OPHONEKITD_DBUS_H
+#define _OPHONEKITD_DBUS_H
-void phonegui_init(int argc, char** argv) {
- gtk_init(&argc,&argv);
-}
+void ophonekitd_dbus_start();
+
+#endif
diff --git a/ophonekitd/src/ophonekitd-main.c b/ophonekitd/src/ophonekitd-main.c
index 0b19fb1..fabaf93 100644
--- a/ophonekitd/src/ophonekitd-main.c
+++ b/ophonekitd/src/ophonekitd-main.c
@@ -21,6 +21,8 @@
#include <string.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
+#include <glib.h>
+#include <glib/gthread.h>
#include <frameworkd-glib/frameworkd-glib-dbus.h>
#include <frameworkd-glib/ogsmd/frameworkd-glib-ogsmd-dbus.h>
#include <frameworkd-glib/ogsmd/frameworkd-glib-ogsmd-call.h>
@@ -31,8 +33,8 @@
#include <frameworkd-glib/odeviced/frameworkd-glib-odeviced-idlenotifier.h>
#include <frameworkd-glib/odeviced/frameworkd-glib-odeviced-powersupply.h>
#include <frameworkd-glib/odeviced/frameworkd-glib-odeviced-audio.h>
-
#include "ophonekitd-phonegui.h"
+#include "ophonekitd-dbus.h"
gboolean sim_auth_active = FALSE;
int *incoming_calls = NULL;
@@ -43,6 +45,8 @@ int outgoing_calls_size = 0;
int main(int argc, char ** argv) {
GMainLoop *mainloop = NULL;
FrameworkdHandlers fwHandler;
+ DBusGConnection *bus = NULL;
+ DBusGProxy *bus_proxy = NULL;
/* Load, connect and initiate phonegui library */
phonegui_load("ophonekitd");
@@ -57,14 +61,21 @@ int main(int argc, char ** argv) {
fwHandler.simIncomingStoredMessage = ophonekitd_sim_incoming_stored_message_handler;
fwHandler.callCallStatus = ophonekitd_call_status_handler;
fwHandler.deviceIdleNotifierState = ophonekitd_device_idle_notifier_state_handler;
- dbus_connect_to_bus(&fwHandler);
- g_debug("Connected to the buses");
- /* Initiate glib main loop */
- g_type_init();
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+
+ dbus_g_thread_init ();
+
+
mainloop = g_main_loop_new (NULL, FALSE);
g_debug("Entering glib main loop");
-
+
+ ophonekitd_dbus_start();
+
+ dbus_connect_to_bus(&fwHandler);
+ g_debug("Connected to the buses");
+
/* Start glib main loop and run list_resources() */
g_timeout_add(0, list_resources, NULL);
g_main_loop_run(mainloop);
diff --git a/ophonekitd/src/ophonekitd-main.h b/ophonekitd/src/ophonekitd-main.h
index 9c384b8..7b60e27 100644
--- a/ophonekitd/src/ophonekitd-main.h
+++ b/ophonekitd/src/ophonekitd-main.h
@@ -35,5 +35,5 @@ void sim_auth_status_callback(GError *error, int status, gpointer userdata);
void register_to_network_callback(GError *error, gpointer userdata);
void get_messagebook_info_callback(GError *error, GHashTable *info, gpointer userdata);
int exit_callback(void *data, int type, void *event);
-
+gboolean power_up_antenna();
#endif
--
libframeworkd-phonegui
More information about the pkg-fso-commits
mailing list