[gnome-games] libgames-support: [hildon] Add osso initialisation to games runtime



commit e44de6c69fdc4ea8767425ebaa897f34270e4a7a
Author: Christian Persch <chpe gnome org>
Date:   Fri Jul 3 19:16:17 2009 +0200

    libgames-support: [hildon] Add osso initialisation to games runtime
    
    Add games_runtime_init_with_osso() to initialise the osso context, and
    games_runtime_get_osso_context() to get the global context.
    Implement games_help_display() for hildon.

 libgames-support/Makefile.am     |    5 +++
 libgames-support/games-help.c    |    4 +-
 libgames-support/games-runtime.c |   55 ++++++++++++++++++++++++++++++++++++++
 libgames-support/games-runtime.h |   13 +++++++++
 4 files changed, 75 insertions(+), 2 deletions(-)
---
diff --git a/libgames-support/Makefile.am b/libgames-support/Makefile.am
index 13e9ec6..a270f09 100644
--- a/libgames-support/Makefile.am
+++ b/libgames-support/Makefile.am
@@ -219,6 +219,11 @@ libgames_support_la_CFLAGS += $(DBUS_GLIB_CFLAGS)
 libgames_support_la_LIBADD += $(DBUS_GLIB_LIBS)
 endif
 
+if HAVE_HILDON
+libgames_support_la_CFLAGS += $(HILDON_CFLAGS)
+libgames_support_la_LIBADD += $(HILDON_LIBS)
+endif
+
 # Auxiliary programme to prerender card images
 
 if HAVE_RSVG
diff --git a/libgames-support/games-help.c b/libgames-support/games-help.c
index ae273db..1b5ddb6 100644
--- a/libgames-support/games-help.c
+++ b/libgames-support/games-help.c
@@ -49,8 +49,8 @@ show_uri (GdkScreen *screen,
           guint32 timestamp,
           GError **error)
 {
-#if 0 // def HAVE_HILDON
-  osso_rpc_run_with_defaults (data->osso_context,
+#ifdef HAVE_HILDON
+  osso_rpc_run_with_defaults (games_runtime_get_osso_context (),
                               "osso_browser",
                               OSSO_BROWSER_OPEN_NEW_WINDOW_REQ,
                               NULL,
diff --git a/libgames-support/games-runtime.c b/libgames-support/games-runtime.c
index f8beda7..0c29641 100644
--- a/libgames-support/games-runtime.c
+++ b/libgames-support/games-runtime.c
@@ -36,6 +36,10 @@
 #include "games-profile.h"
 #include "games-runtime.h"
 
+#ifdef HAVE_HILDON
+static osso_context_t *osso_context;
+#endif
+
 #if defined(G_OS_WIN32) && !defined(ENABLE_BINRELOC)
 #error binreloc must be enabled on win32
 #endif
@@ -337,6 +341,50 @@ games_runtime_init (const char *name)
   return retval;
 }
 
+#ifdef HAVE_HILDON
+
+/**
+ * games_runtime_init_with_osso:
+ *
+ * Like games_runtime_init(), but also initialises the osso context.
+ *
+ * NOTE: This must be called before using ANY other glib/gtk/etc function!
+ * 
+ * Returns: %TRUE iff initialisation succeeded
+ */
+gboolean
+games_runtime_init_with_osso (const char *name,
+                              const char *service_name)
+{
+  if (!games_runtime_init (name))
+    return FALSE;
+
+  osso_context = osso_initialize (service_name, VERSION, FALSE, NULL);
+  if (osso_context == NULL) {
+    g_printerr ("Failed to initialise osso\n");
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+/**
+ * games_runtime_get_osso_context:
+ *
+ * Returns the osso context. May only be called after
+ * games_runtime_init_with_osso().
+ *
+ * Returns: a #osso_context_t
+ */
+osso_context_t*
+games_runtime_get_osso_context (void)
+{
+  g_assert (osso_context != NULL);
+  return osso_context;
+}
+
+#endif /* HAVE_HILDON */
+
 /**
  * games_runtime_shutdown:
  *
@@ -354,6 +402,13 @@ games_runtime_shutdown (void)
 
   g_free (app_name);
   app_name = NULL;
+
+#ifdef HAVE_HILDON
+  if (osso_context != NULL) {
+    osso_deinitialize (osso_context);
+    osso_context = NULL;
+  }
+#endif /* HAVE_HILDON */
 }
 
 /**
diff --git a/libgames-support/games-runtime.h b/libgames-support/games-runtime.h
index bd9a15a..23fd30e 100644
--- a/libgames-support/games-runtime.h
+++ b/libgames-support/games-runtime.h
@@ -21,6 +21,10 @@
 
 #include <glib.h>
 
+#ifdef HAVE_HILDON
+#include <libosso.h>
+#endif
+
 G_BEGIN_DECLS
 
 typedef enum {
@@ -62,6 +66,15 @@ typedef enum {
 
 gboolean games_runtime_init (const char *name);
 
+#ifdef HAVE_HILDON
+
+gboolean games_runtime_init_with_osso (const char *name,
+                                       const char *service_name);
+
+osso_context_t* games_runtime_get_osso_context (void);
+
+#endif /* HAVE_HILDON */
+
 void games_runtime_shutdown (void);
 
 const char * games_runtime_get_directory (GamesRuntimeDirectory directory);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]