Commit 5f527632 authored by Bruno Coudoin's avatar Bruno Coudoin

Initial support for dbus. Untested. To use it, you need to compile

with dbus support using --with-dbus and run GCompris with:
gcompris --sugarActivityId ANYTHING_HERE
I implemented what's documented here:
http://wiki.laptop.org/go/Activity_DBus_API



svn path=/branches/gcomprixo/; revision=2868
parent 9a51e88e
......@@ -372,6 +372,20 @@ if test x$with_gnet = xyes; then
AC_DEFINE([USE_GNET], 1,[Networking is enabled])
fi
dnl DBUS support
AC_MSG_CHECKING([wether we build with DBUS (needed only for OLPC SUGAR XO)])
AC_ARG_ENABLE(dbus,
AC_HELP_STRING(
[--enable-dbus],
[Turn on dbus (will let GCompris integrate well on OLPC SUGAR XO)]),
with_dbus="$enableval", with_dbus="no")
AC_MSG_RESULT($with_dbus)
if test x$with_dbus = xyes; then
PKG_CHECK_MODULES(DBUS, [dbus-1 dbus-glib-1],, AC_MSG_ERROR([*** DBUS not found!]))
AC_DEFINE([USE_DBUS], 1,[DBUS support is enabled])
fi
dnl check for python
AC_ARG_WITH(python,AC_HELP_STRING(
[--with-python=path],
......@@ -938,6 +952,7 @@ echo "Python plugin = $build_python_plugin"
echo "SQLITE database (--enable-sqlite) = $with_sqlite (profiles depend on this)"
echo "GNET Networking (--enable-gnet) = $with_gnet (networking depends on this)"
echo "DBUS Support (OLPC XO Sugar) = $with_dbus"
echo "BINRELOC (--enable-binreloc) = $br_cv_binreloc"
echo "NSBundle (--enable-nsbundle) = $nsbundle"
......
......@@ -55,6 +55,7 @@ INCLUDES = \
-DGNOME_DISABLE_DEPRECATED \
$(sqlite_cflags) \
$(GNET_CFLAGS) \
$(DBUS_CFLAGS) \
$(cairo_cflags) \
$(NSBUNDLE_CPPFLAGS)
......@@ -77,6 +78,7 @@ gcompris_SOURCES = \
bonus.h \
cache.c \
config.c \
dbus.c \
dialog.c \
drag.c \
drag.h \
......@@ -127,6 +129,7 @@ gcompris_LDFLAGS = \
gcompris_LDADD = \
$(GCOMPRIS_LIBS) $(sqlite_ldadd) $(XML_LIBS) $(GNET_LIBS) \
$(DBUS_LIBS) \
$(INTLLIBS) $(NSBUNDLE_LDFLAGS)
# $(LIBICONV)
......
/* gcompris - timer.c
*
* Copyright (C) 2007 Bruno coudoin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "gcompris.h"
#include <gc_core.h>
#if USE_DBUS
#include <dbus/dbus-glib.h>
#include <glib-object.h>
#include <dbus/dbus.h>
#define SUPPORT_OR_RETURN(rv) {}
#else
#define SUPPORT_OR_RETURN(rv) { return rv; }
#endif
#define _ACTIVITY_SERVICE_NAME "org.laptop.Activity"
#define _ACTIVITY_SERVICE_PATH "/org/laptop/Activity"
#define _ACTIVITY_INTERFACE "org.laptop.Activity"
void _set_active(DBusGProxy *proxy, gint active, void *dummy)
{
printf("_set_active %d\n", active);
if(active)
gc_sound_close();
else
gc_sound_reopen();
}
void
gc_dbus_init(gchar *sugarActivityId)
{
SUPPORT_OR_RETURN();
#ifdef USE_DBUS
DBusGConnection *connection;
GError *error;
DBusGProxy *proxy;
g_type_init ();
error = NULL;
connection = dbus_g_bus_get (DBUS_BUS_SESSION,
&error);
if (connection == NULL)
{
g_printerr ("Failed to open connection to bus: %s\n",
error->message);
g_error_free (error);
exit (1);
}
gchar *service_name = g_strdup_printf("%s%s",
_ACTIVITY_SERVICE_NAME,
sugarActivityId);
gchar *object_path = g_strdup_printf("%s/%s",
_ACTIVITY_SERVICE_PATH,
sugarActivityId);
proxy = dbus_g_proxy_new_for_name (connection,
service_name,
object_path,
_ACTIVITY_INTERFACE);
dbus_g_proxy_connect_signal(proxy, "set_active",
G_CALLBACK(_set_active), NULL, NULL);
#endif
}
......@@ -58,4 +58,7 @@ void gc_cache_clear();
gchar *gc_cache_get(gchar *url);
gchar *gc_cache_insert(const gchar *url, const char *buffer, gssize length);
/** dbus */
void gc_dbus_init(gchar *sugarActivityId);
#endif
......@@ -1699,6 +1699,9 @@ main (int argc, char *argv[])
gc_sound_play_ogg("sounds/$LOCALE/misc/welcome.ogg", NULL);
}
if (sugarActivityId)
gc_dbus_init(sugarActivityId);
gtk_main ();
/* FIXME: HACK Needed or we have unresolved symbols at python plugin dlopen
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment