#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#if HAVE_UNIQUE
+#if HAVE_HILDON
+ #include <libosso.h>
+ typedef osso_context_t* MidoriAppInstance;
+ #define MidoriAppInstanceNull NULL
+#elif HAVE_UNIQUE
typedef gpointer MidoriAppInstance;
#define MidoriAppInstanceNull NULL
#include <unique/unique.h>
#include "socket.h"
#endif
+#if !HAVE_HILDON
typedef struct _NotifyNotification NotifyNotification;
typedef struct
gboolean (*notification_show) (NotifyNotification* notification,
GError** error);
} LibNotifyFuncs;
+#endif
struct _MidoriApp
{
MidoriAppInstance instance;
+ #if !HAVE_HILDON
/* libnotify handling */
gchar* program_notify_send;
GModule* libnotify_module;
LibNotifyFuncs libnotify_funcs;
+ #endif
};
struct _MidoriAppClass
if (g_str_equal (command, "activate"))
{
+ if (!app->browser)
+ return FALSE;
+
gtk_window_set_screen (GTK_WINDOW (app->browser), screen);
gtk_window_present (GTK_WINDOW (app->browser));
return TRUE;
}
else if (g_str_equal (command, "open"))
{
+ if (!app->browser)
+ return FALSE;
+
gtk_window_set_screen (GTK_WINDOW (app->browser), screen);
gtk_window_present (GTK_WINDOW (app->browser));
if (!uris)
return FALSE;
}
-#if HAVE_UNIQUE
+#if HAVE_HILDON
+static osso_return_t
+midori_app_osso_rpc_handler_cb (const gchar* interface,
+ const gchar* method,
+ GArray* arguments,
+ gpointer data,
+ osso_rpc_t * retval)
+{
+ MidoriApp* app = MIDORI_APP (data);
+ GdkScreen* screen = NULL;
+ gboolean success;
+
+ if (!g_strcmp0 (method, "top_application"))
+ success = midori_app_command_received (app, "activate", NULL, screen);
+ else if (!g_strcmp0 (method, "new"))
+ success = midori_app_command_received (app, "new", NULL, screen);
+ else if (!g_strcmp0 (method, "open"))
+ {
+ /* FIXME: Handle arguments */
+ success = midori_app_command_received (app, "open", NULL, screen);
+ }
+ else if (!g_strcmp0 (method, "command"))
+ {
+ /* FIXME: Handle arguments */
+ success = midori_app_command_received (app, "command", NULL, screen);
+ }
+
+ return success ? OSSO_OK : OSSO_INVALID;
+}
+#elif HAVE_UNIQUE
static UniqueResponse
midori_browser_message_received_cb (UniqueApp* instance,
UniqueCommand command,
const gchar* name)
{
MidoriAppInstance instance;
+
+ #if HAVE_HILDON
+ instance = osso_initialize (PACKAGE_NAME, PACKAGE_VERSION, FALSE, NULL);
+
+ if (!instance)
+ {
+ g_critical ("Error initializing OSSO D-Bus context - Midori");
+ return NULL;
+ }
+
+ if (osso_rpc_set_default_cb_f (instance, midori_app_osso_rpc_handler_cb,
+ app) != OSSO_OK)
+ {
+ g_critical ("Error initializing remote procedure call handler - Midori");
+ osso_deinitialize (instance);
+ return NULL;
+ }
+ #else
GdkDisplay* display;
gchar* display_name;
gchar* instance_name;
g_free (instance_name);
g_free (display_name);
+ #endif
return instance;
}
katze_object_assign (app->extensions, NULL);
katze_object_assign (app->browsers, NULL);
- #if HAVE_UNIQUE
+ #if HAVE_HILDON
+ osso_deinitialize (app->instance);
+ app->instance = NULL;
+ #elif HAVE_UNIQUE
katze_object_assign (app->instance, NULL);
#else
sock_cleanup ();
#endif
+ #if !HAVE_HILDON
if (app->libnotify_module)
{
app->libnotify_funcs.uninit ();
g_module_close (app->libnotify_module);
}
katze_assign (app->program_notify_send, NULL);
+ #endif
G_OBJECT_CLASS (midori_app_parent_class)->finalize (object);
}
if (app->instance == MidoriAppInstanceNull)
app->instance = midori_app_create_instance (app, app->name);
- #if HAVE_UNIQUE
+
+ #if HAVE_HILDON
+ /* FIXME: Determine if application is running already */
+ if (app->instance)
+ return FALSE;
+ #elif HAVE_UNIQUE
if (app->instance)
return unique_app_is_running (app->instance);
#else
/* g_return_val_if_fail (MIDORI_IS_APP (app), FALSE); */
g_return_val_if_fail (midori_app_instance_is_running (app), FALSE);
- #if HAVE_UNIQUE
+ #if HAVE_HILDON
+ osso_application_top (app->instance, PACKAGE_NAME, NULL);
+ #elif HAVE_UNIQUE
if (app->instance)
{
response = unique_app_send_message (app->instance, UNIQUE_ACTIVATE, NULL);
/* g_return_val_if_fail (MIDORI_IS_APP (app), FALSE); */
g_return_val_if_fail (midori_app_instance_is_running (app), FALSE);
- #if HAVE_UNIQUE
+ #if HAVE_HILDON
+ osso_application_top (app->instance, PACKAGE_NAME, "new");
+ #elif HAVE_UNIQUE
if (app->instance)
{
response = unique_app_send_message (app->instance, UNIQUE_NEW, NULL);
g_return_val_if_fail (midori_app_instance_is_running (app), FALSE);
g_return_val_if_fail (uris != NULL, FALSE);
- #if HAVE_UNIQUE
+ #if HAVE_HILDON
+ /* FIXME: Implement */
+ #elif HAVE_UNIQUE
if (app->instance)
{
message = unique_message_data_new ();
if (!midori_app_instance_is_running (app))
return midori_app_command_received (app, "command", command, NULL);
- #if HAVE_UNIQUE
+ #if HAVE_HILDON
+ /* FIXME: Implement */
+ #elif HAVE_UNIQUE
if (app->instance)
{
message = unique_message_data_new ();
static void
midori_app_init_libnotify (MidoriApp* app)
{
+ #if !HAVE_HILDON
gint i;
const gchar* sonames[] = { "libnotify.so", "libnotify.so.1", NULL };
}
app->program_notify_send = g_find_program_in_path ("notify-send");
+ #endif
}
/**