libunity-webapps-2.5.0~+14.04.20140409/0000755000015301777760000000000012321250157017611 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tools/0000755000015301777760000000000012321250157020751 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tools/webapps-spreader.c0000644000015301777760000001562612321247333024375 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * webapps-spreader.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" static UnityWebappsService *service = NULL; static GMainLoop *mainloop = NULL; static gchar *context_name = NULL; static GOptionEntry option_entries[] = { { "context-name", 'n',0,G_OPTION_ARG_STRING, &context_name, "Context DBus Name", NULL }, }; static gboolean parse_data_uri (const gchar *data_uri, gchar **mimetype, gchar **data) { gchar **split; int result; g_assert (g_str_has_prefix (data_uri, "data:") == TRUE); split = g_strsplit (data_uri+5, ";base64,", 2); result = g_strv_length (split); if (result != 2) { g_warning ("Failed to parse data uri: \n %s \n", data_uri); *mimetype = NULL; *data = NULL; g_strfreev (split); return FALSE; } *mimetype = split[0]; *data = split[1]; g_free (split); if (g_str_has_prefix (*mimetype, "image/") == FALSE) { g_warning ("Data URI does not have an image mimetype"); g_free (mimetype); g_free (data); *mimetype = NULL; *data = NULL; return FALSE; } return TRUE; } static GdkPixbuf * preview_image_from_data_uri (const gchar *data_uri) { GdkPixbufLoader *loader; GdkPixbuf *pixbuf; gchar *mimetype, *data; guchar *decoded; gsize decoded_length; gboolean parsed, wrote; GError *error; mimetype = NULL; data = NULL; pixbuf = NULL; loader = NULL; parsed = parse_data_uri (data_uri, &mimetype, &data); if (parsed == FALSE) { g_warning ("Failed to parse data uri"); return NULL; } decoded = g_base64_decode (data, &decoded_length); g_assert (decoded != NULL); loader = gdk_pixbuf_loader_new (); error = NULL; wrote = gdk_pixbuf_loader_write (loader, decoded, decoded_length, &error); if (wrote == FALSE) { if (error == NULL) { goto out; } g_warning ("Failed to write data to GdkPixbuf: %s", error->message); g_error_free (error); goto out; } error = NULL; if (error != NULL) { g_warning("Failed to close pixbuf loader: %s", error->message); g_error_free (error); goto out; } pixbuf = GDK_PIXBUF (g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader))); gdk_pixbuf_loader_close (loader, NULL); out: if (loader != NULL) { g_object_unref (G_OBJECT (loader)); } g_free (mimetype); g_free (data); g_free (decoded); return pixbuf; } static gchar * get_preview_title (UnityWebappsContext *context, gint interest_id) { const gchar *app_name; gchar *view_location, *title; app_name = unity_webapps_context_get_name (context); view_location = unity_webapps_context_get_view_location (context, interest_id); title = g_strdup_printf("%s - (%s)", app_name, view_location); g_free (view_location); return title; } static void create_preview_window (UnityWebappsContext *context, gint interest_id, GdkPixbuf *preview_pixbuf, gint width, gint height) { GtkWidget *window, *image; GdkWindow *gdkwin; gchar *title; guint32 xid; window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_default_size (GTK_WINDOW (window), width, height); gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE); gtk_window_set_skip_pager_hint (GTK_WINDOW (window), TRUE); gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_UTILITY); gtk_window_move (GTK_WINDOW (window), -10000, -10000); image = gtk_image_new_from_pixbuf (preview_pixbuf); gtk_container_add (GTK_CONTAINER (window), image); title = get_preview_title (context, interest_id); gtk_window_set_title (GTK_WINDOW (window), title); gtk_widget_show_all (GTK_WIDGET (window)); gdkwin = gtk_widget_get_window (GTK_WIDGET (window)); xid = gdk_x11_window_get_xid (gdkwin); printf("%d - %u\n", interest_id, xid); g_free (title); } static void preview_ready (UnityWebappsContext *context, gint interest_id, const gchar *preview_data, gpointer user_data) { GdkPixbuf *preview_pixbuf; gint width, height; preview_pixbuf = preview_image_from_data_uri (preview_data); if (preview_pixbuf == NULL) { return; } width = gdk_pixbuf_get_width (preview_pixbuf); height = gdk_pixbuf_get_height (preview_pixbuf); create_preview_window (context, interest_id, preview_pixbuf, width, height); g_object_unref (G_OBJECT (preview_pixbuf)); } static gboolean spreader_request_previews (UnityWebappsContext *context) { GVariant *interests, *interest_variant; GVariantIter *variant_iter; interests = unity_webapps_context_list_interests (context); if (interests == NULL) { return FALSE; } variant_iter = g_variant_iter_new (interests); while ((interest_variant = g_variant_iter_next_value (variant_iter))) { gint interest_id; interest_id = g_variant_get_int32 (interest_variant); unity_webapps_context_request_preview (context, interest_id, preview_ready, GINT_TO_POINTER (interest_id)); } g_variant_iter_free (variant_iter); g_variant_unref (interests); return TRUE; } gint main (gint argc, gchar **argv) { GOptionContext *option_context; UnityWebappsContext *context; GError *error; gboolean req; gtk_init (&argc, &argv); service = unity_webapps_service_new (); option_context = g_option_context_new ("- Create Preview Windows for Unity Webapps"); // TODO: GETTEXT g_option_context_add_main_entries (option_context, option_entries, NULL); error = NULL; if (!g_option_context_parse (option_context, &argc, &argv, &error)) { g_error("Failed to parse arguments: %s", error->message); exit(1); } context = unity_webapps_context_new_for_context_name (service, context_name); req = spreader_request_previews (context); if (req == FALSE) { exit(1); } mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); exit (0); } libunity-webapps-2.5.0~+14.04.20140409/tools/Makefile.am0000644000015301777760000000705712321247333023020 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_WM_PID_TRACKER_CFLAGS) \ $(UNITY_WEBAPPS_SERVICE_TRACKER_CFLAGS) \ $(UNITY_WEBAPPS_DEBUG_CFLAGS) \ $(UNITY_WEBAPPS_TOOLS_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/src/context-daemon \ -I$(top_srcdir)/src/context-daemon/util \ -I$(top_srcdir)/src/context-daemon/resource-cache \ -I$(top_srcdir)/src/libunity-webapps-repository/ tooldir = \ $(bindir) tool_PROGRAMS = \ unity-webapps-desktop-file noinst_PROGRAMS = \ context-tracker \ service-tracker \ action-invoker \ unity-webapps-tool \ unity-webapps-installer \ webapps-spreader service_tracker_SOURCES = \ service-tracker.c unity_webapps_desktop_file_SOURCES = \ unity-webapps-desktop-file.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-dirs.c \ $(top_srcdir)/src/unity-webapps-app-db.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-db.c \ $(top_srcdir)/src/context-daemon/unity-webapps-application-info.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-icon-theme.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-cache.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-factory.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-gio-utils.c \ $(top_srcdir)/src/libunity-webapps/unity-webapps-permissions.c \ $(top_srcdir)/src/unity-webapps-string-utils.c \ $(top_srcdir)/src/unity-webapps-desktop-infos.c \ $(top_srcdir)/src/context-daemon/unity-webapps-debug.c unity_webapps_desktop_file_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(top_builddir)/src/libunity-webapps-repository/libunity-webapps-repository.la service_tracker_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_SERVICE_TRACKER_LIBS) \ $(UNITY_WEBAPPS_TOOLS_LIBS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la webapps_spreader_SOURCES = \ webapps-spreader.c webapps_spreader_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_SERVICE_TRACKER_LIBS) \ $(UNITY_WEBAPPS_TOOLS_LIBS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la unity_webapps_installer_SOURCES = \ unity-webapps-installer.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-dirs.c \ $(top_srcdir)/src/unity-webapps-app-db.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-db.c \ $(top_srcdir)/src/context-daemon/unity-webapps-application-info.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-icon-theme.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-cache.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-factory.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-gio-utils.c \ $(top_srcdir)/src/libunity-webapps/unity-webapps-permissions.c \ $(top_srcdir)/src/unity-webapps-string-utils.c \ $(top_srcdir)/src/unity-webapps-desktop-infos.c \ $(top_srcdir)/src/context-daemon/unity-webapps-debug.c unity_webapps_installer_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) unity_webapps_tool_SOURCES = \ unity-webapps-tool.c unity_webapps_tool_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_SERVICE_TRACKER_LIBS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la context_tracker_SOURCES = \ context-tracker.c context_tracker_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la action_invoker_SOURCES = \ action-invoker.c action_invoker_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tools/service-tracker.c0000644000015301777760000006335412321247333024223 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * service-tracker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" static UnityWebappsService *service = NULL; static GMainLoop *mainloop = NULL; static GtkWidget *main_window = NULL; static GtkWidget *main_box = NULL; static GtkWidget *pane_alignment = NULL; static GtkWidget *tree_view = NULL; static GtkTreeStore *tree_store = NULL; static GtkWidget *current_pane = NULL; static GHashTable *contexts_by_name = NULL; typedef struct _ContextHashData { UnityWebappsContext *context; GtkTreeRowReference *row_reference; GHashTable *interests_by_id; GtkWidget *pane; GtkWidget *interests_label; } ContextHashData; typedef struct _InterestHashData { ContextHashData *context_data; GtkTreeRowReference *row_reference; gint id; GtkWidget *pane; GtkLabel *active_label; GtkLabel *location_label; GtkImage *preview_image; } InterestHashData; static gboolean parse_data_uri (const gchar *data_uri, gchar **mimetype, gchar **data) { gchar **split; int result; g_assert (g_str_has_prefix (data_uri, "data:") == TRUE); split = g_strsplit (data_uri+5, ";base64,", 2); result = g_strv_length (split); if (result != 2) { g_warning ("Failed to parse data uri: \n %s \n", data_uri); *mimetype = NULL; *data = NULL; g_strfreev (split); return FALSE; } *mimetype = split[0]; *data = split[1]; g_free (split); if (g_str_has_prefix (*mimetype, "image/") == FALSE) { g_warning ("Data URI does not have an image mimetype"); g_free (mimetype); g_free (data); *mimetype = NULL; *data = NULL; return FALSE; } return TRUE; } static GdkPixbuf * scale_preview_pixbuf (GdkPixbuf *pixbuf) { GdkPixbuf *scaled_pixbuf; gint width, height; gdouble ratio; width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); ratio = 160.0/height; scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, width*ratio, 160, GDK_INTERP_HYPER); return scaled_pixbuf; } static GdkPixbuf * preview_image_from_data_uri (const gchar *data_uri) { GdkPixbufLoader *loader; GdkPixbuf *pixbuf, *unscaled_pixbuf; gchar *mimetype, *data; guchar *decoded; gsize decoded_length; gboolean parsed, wrote; GError *error; mimetype = NULL; data = NULL; pixbuf = NULL; loader = NULL; parsed = parse_data_uri (data_uri, &mimetype, &data); if (parsed == FALSE) { g_warning ("Failed to parse data uri"); return NULL; } decoded = g_base64_decode (data, &decoded_length); g_assert (decoded != NULL); loader = gdk_pixbuf_loader_new (); error = NULL; wrote = gdk_pixbuf_loader_write (loader, decoded, decoded_length, &error); if (wrote == FALSE) { if (error == NULL) { goto out; } g_warning ("Failed to write data to GdkPixbuf: %s", error->message); g_error_free (error); goto out; } printf("Wrote %zu bytes\n", decoded_length); error = NULL; if (error != NULL) { g_warning("Failed to close pixbuf loader: %s", error->message); g_error_free (error); goto out; } unscaled_pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); pixbuf = scale_preview_pixbuf (unscaled_pixbuf); g_object_unref (G_OBJECT (unscaled_pixbuf)); gdk_pixbuf_loader_close (loader, NULL); out: if (loader != NULL) { g_object_unref (G_OBJECT (loader)); } g_free (mimetype); g_free (data); g_free (decoded); return pixbuf; } static InterestHashData * interest_hash_data_new (ContextHashData *context_data, GtkTreeIter *iter, gint id) { InterestHashData *data; GtkTreePath *path; data = g_malloc0 (sizeof (InterestHashData)); path = gtk_tree_model_get_path (GTK_TREE_MODEL (tree_store), iter); data->row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (tree_store), path); data->context_data = context_data; data->id = id; gtk_tree_path_free (path); return data; } void interest_hash_data_free (InterestHashData *data) { if (data->row_reference) { gtk_tree_row_reference_free (data->row_reference); } g_object_unref (G_OBJECT (data->pane)); g_free (data); } static ContextHashData * context_hash_data_new (UnityWebappsContext *context, GtkTreeIter *iter) { GtkTreePath *path; ContextHashData *data; data = g_malloc0 (sizeof (ContextHashData)); path = gtk_tree_model_get_path (GTK_TREE_MODEL (tree_store), iter); data->context = context; data->row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (tree_store), path); data->interests_by_id = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)interest_hash_data_free); gtk_tree_path_free (path); return data; } static void context_hash_data_free (ContextHashData *data) { if (data->row_reference) { gtk_tree_row_reference_free (data->row_reference); } g_object_unref (G_OBJECT (data->context)); g_object_unref (G_OBJECT (data->pane)); g_hash_table_destroy (data->interests_by_id); g_free (data); } static UnityWebappsContext * get_context_proxy_for_name (const gchar *name, GtkTreeIter *iter) { UnityWebappsContext *context; ContextHashData *data; data = g_hash_table_lookup (contexts_by_name, name); if (data != NULL) { return data->context; } context = unity_webapps_context_new_for_context_name (service, name); data = context_hash_data_new (context, iter); g_hash_table_insert (contexts_by_name, g_strdup (name), data); return context; } static void builder_set_label_text (GtkBuilder *builder, const gchar *label_name, const gchar *label_text) { GtkLabel *label; label = GTK_LABEL (gtk_builder_get_object (builder, label_name)); gtk_label_set_text (label, label_text); } static GdkPixbuf * render_webapp_icon_for_name (const gchar *icon_name) { GtkIconTheme *theme; GtkIconInfo *info; GdkPixbuf *pb; if (icon_name == NULL) { return NULL; } theme = gtk_icon_theme_new (); gtk_icon_theme_set_custom_theme (theme, "unity-webapps"); info = gtk_icon_theme_lookup_icon (theme, icon_name, 64, 0); if (info == NULL) { g_object_unref (G_OBJECT (theme)); return NULL; } pb = gtk_icon_info_load_icon (info, NULL); /* TODO: FIXME: ERROR */ gtk_icon_info_free (info); g_object_unref (G_OBJECT (theme)); return pb; } static void set_context_pane_labels (UnityWebappsContext *context, GtkBuilder *builder, ContextHashData *data) { gchar *name_label, *domain_label, *interests_label, *desktop_name_label; const gchar *context_name; const gchar *context_domain; const gchar *context_desktop_name; gint num_interests; context_name = unity_webapps_context_get_name (context); context_domain = unity_webapps_context_get_domain (context); context_desktop_name = unity_webapps_context_get_desktop_name (context); num_interests = 1; // TODO: FIX ME name_label = g_strdup_printf ("Name: %s", context_name); domain_label = g_strdup_printf("Domain: %s", context_domain); desktop_name_label = g_strdup_printf("Desktop Name: %s", context_desktop_name); interests_label = g_strdup_printf("Number of Interests: %d", num_interests); builder_set_label_text (builder, "domain-label", domain_label); builder_set_label_text (builder, "name-label", name_label); builder_set_label_text (builder, "desktop-name-label", desktop_name_label); builder_set_label_text (builder, "num-interests-label", interests_label); data->interests_label = GTK_WIDGET (gtk_builder_get_object (builder, "num-interests-label")); g_free (name_label); g_free (domain_label); g_free (desktop_name_label); g_free (interests_label); } static void set_context_pane_icon (UnityWebappsContext *context, GtkBuilder *builder) { GtkImage *image; GdkPixbuf *icon_pb; gchar *icon_name; icon_name = unity_webapps_context_get_icon_name (context); icon_pb = render_webapp_icon_for_name (icon_name); if (icon_pb != NULL) { image = GTK_IMAGE (gtk_builder_get_object (builder, "icon-image")); gtk_image_set_from_pixbuf (image, icon_pb); g_object_unref (G_OBJECT (icon_pb)); } g_free (icon_name); } static void on_raise_button_clicked (GtkWidget *button, gpointer user_data) { UnityWebappsContext *context; context = (UnityWebappsContext *)user_data; unity_webapps_context_raise (context); } static void on_close_button_clicked (GtkWidget *button, gpointer user_data) { UnityWebappsContext *context; context = (UnityWebappsContext *)user_data; unity_webapps_context_close (context); } static GtkWidget * make_pane_for_context (UnityWebappsContext *context, ContextHashData *data) { GtkWidget *main_widget; GtkBuilder *builder; GError *error; builder = gtk_builder_new (); error = NULL; gtk_builder_add_from_file (builder, "context-pane.xml", &error); if (error != NULL) { g_error ("Error loading context-pane.xml: %s", error->message); g_error_free (error); return NULL; } set_context_pane_labels (context, builder, data); set_context_pane_icon (context, builder); g_signal_connect (gtk_builder_get_object (builder, "raise-button"), "clicked", G_CALLBACK (on_raise_button_clicked), context); g_signal_connect (gtk_builder_get_object (builder, "close-button"), "clicked", G_CALLBACK (on_close_button_clicked), context); main_widget = GTK_WIDGET (g_object_ref (gtk_builder_get_object (builder, "box1"))); return main_widget; } static void on_preview_ready (UnityWebappsContext *context, gint interest_id, const gchar *preview_data, gpointer user_data) { GdkPixbuf *pixbuf; InterestHashData *data; data = (InterestHashData *)user_data; pixbuf = preview_image_from_data_uri (preview_data); if (pixbuf == NULL) { return; } gtk_image_set_from_pixbuf (data->preview_image, pixbuf); g_object_unref (G_OBJECT (pixbuf)); } static void on_preview_clicked (GtkWidget *button, gpointer user_data) { InterestHashData *data; data = (InterestHashData *)user_data; unity_webapps_context_request_preview (data->context_data->context, data->id, on_preview_ready, data); } static void on_interest_raise_clicked (GtkWidget *button, gpointer user_data) { UnityWebappsContext *context; InterestHashData *data; data = (InterestHashData *)user_data; context = data->context_data->context; unity_webapps_context_raise_interest (context, data->id); } static GtkWidget * make_pane_for_interest_id (UnityWebappsContext *context, gint interest_id, InterestHashData *data) { GtkWidget *main_widget; GtkBuilder *builder; gchar *message, *owner, *location; gboolean is_active; GError *error; builder = gtk_builder_new (); error = NULL; gtk_builder_add_from_file (builder, "interest-pane.xml", &error); if (error != NULL) { g_error ("Error loading interest-pane.xml: %s", error->message); g_error_free (error); return NULL; } set_context_pane_icon (context, builder); owner = unity_webapps_context_get_interest_owner (context, interest_id); message = g_strdup_printf ("Owner: %s", owner); gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "owner-label")), message); is_active = unity_webapps_context_get_view_is_active (context, interest_id); data->active_label = GTK_LABEL (gtk_builder_get_object (builder, "view-active-label")); data->location_label = GTK_LABEL (gtk_builder_get_object (builder, "location-label")); data->preview_image = GTK_IMAGE (gtk_builder_get_object (builder, "preview-image")); location = unity_webapps_context_get_view_location (context, interest_id); if (location && (strlen(location) > 0)) { gchar *lm; lm = g_strdup_printf("Location: %s", location); gtk_label_set_text (data->location_label, lm); g_free (lm); } if (is_active) { gtk_label_set_text (data->active_label, "View is Active: Yes"); } g_signal_connect (gtk_builder_get_object (builder, "preview-button"), "clicked", G_CALLBACK (on_preview_clicked), data); g_signal_connect (gtk_builder_get_object (builder, "raise-button"), "clicked", G_CALLBACK (on_interest_raise_clicked), data); main_widget = GTK_WIDGET (g_object_ref (gtk_builder_get_object (builder, "box1"))); g_free (owner); g_free (message); return main_widget; } static gint get_interest_by_tree_path (UnityWebappsContext *context, GtkTreePath *path) { ContextHashData *data; const gchar *context_name; GHashTableIter iter; gpointer key, value; context_name = unity_webapps_context_get_context_name (context); data = g_hash_table_lookup (contexts_by_name, context_name); if (data == NULL) { return -1; } g_hash_table_iter_init (&iter, data->interests_by_id); while (g_hash_table_iter_next (&iter, &key, &value)) { InterestHashData *interest_data; GtkTreePath *s_path; interest_data = (InterestHashData *)value; s_path = gtk_tree_row_reference_get_path (interest_data->row_reference); if (gtk_tree_path_compare (path, s_path) == 0) { gtk_tree_path_free (s_path); return GPOINTER_TO_INT(key); } gtk_tree_path_free (s_path); } return -1; } static UnityWebappsContext * get_context_by_tree_path (GtkTreePath *path) { GHashTableIter iter; gpointer key, value; if (path == NULL) { return NULL; } g_hash_table_iter_init (&iter, contexts_by_name); while (g_hash_table_iter_next (&iter, &key, &value)) { ContextHashData *data; GtkTreePath *s_path; data = (ContextHashData *)value; s_path = gtk_tree_row_reference_get_path (data->row_reference); if (gtk_tree_path_compare (path, s_path) == 0) { gtk_tree_path_free (s_path); return data->context; } gtk_tree_path_free (s_path); } return NULL; } static void append_interests (UnityWebappsContext *context, ContextHashData *hash_data, GtkTreeIter *iter) { GVariant *interests; GVariant *interest_variant; GVariantIter *variant_iter; interests = unity_webapps_context_list_interests (context); if (interests == NULL) { return; } variant_iter = g_variant_iter_new (interests); while ((interest_variant = g_variant_iter_next_value (variant_iter))) { GtkWidget *interest_pane; InterestHashData *data; gchar *message; GtkTreeIter new_iter; gint interest_id; interest_id = g_variant_get_int32 (interest_variant); gtk_tree_store_insert (tree_store, &new_iter, iter, 0); message = g_strdup_printf ("Interest %d", interest_id); gtk_tree_store_set (tree_store, &new_iter, 0, message, -1); data = interest_hash_data_new (hash_data, &new_iter, interest_id); interest_pane = make_pane_for_interest_id (context, interest_id, data); data->pane = interest_pane; g_hash_table_insert (hash_data->interests_by_id, GINT_TO_POINTER (interest_id), data); g_free (message); } g_variant_iter_free (variant_iter); g_variant_unref (interests); } static void on_interests_changed (UnityWebappsContext *context, gint interest_id, gpointer user_data) { ContextHashData *hash_data = (ContextHashData *)user_data; GtkTreePath *path; gchar *label_text; GtkTreeIter context_tree_iter; GHashTableIter hash_iter; gpointer key, value; g_hash_table_iter_init (&hash_iter, hash_data->interests_by_id); while (g_hash_table_iter_next (&hash_iter, &key, &value)) { InterestHashData *interest_hash_data; GtkTreePath *path; GtkTreeIter iter; interest_hash_data = (InterestHashData *)value; path = gtk_tree_row_reference_get_path (interest_hash_data->row_reference); gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &iter, path); gtk_tree_store_remove (tree_store, &iter); gtk_tree_path_free (path); } g_hash_table_remove_all (hash_data->interests_by_id); path = gtk_tree_row_reference_get_path (hash_data->row_reference); gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &context_tree_iter, path); append_interests (context, hash_data, &context_tree_iter); label_text = g_strdup_printf ("Number of Interests: %d", g_hash_table_size (hash_data->interests_by_id)); gtk_label_set_text (GTK_LABEL (hash_data->interests_label), label_text); g_free (label_text); gtk_tree_path_free (path); } static void on_view_is_active_changed (UnityWebappsContext *context, gint interest_id, gboolean is_active, gpointer user_data) { ContextHashData *data; InterestHashData *interest_data; data = (ContextHashData *)user_data; interest_data = (InterestHashData *)g_hash_table_lookup (data->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest_data == NULL) { return; } if (is_active) { gtk_label_set_text (interest_data->active_label, "View is Active: Yes"); } else { gtk_label_set_text (interest_data->active_label, "View is Active: No"); } } static void on_view_location_changed (UnityWebappsContext *context, gint interest_id, const gchar *location, gpointer user_data) { ContextHashData *data; InterestHashData *interest_data; gchar *message; data = (ContextHashData *)user_data; interest_data = (InterestHashData *)g_hash_table_lookup (data->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest_data == NULL) { return; } message = g_strdup_printf ("Location: %s", location); gtk_label_set_text (interest_data->location_label, message); g_free (message); } static void append_context_by_name (const gchar *context_name) { UnityWebappsContext *context; const gchar *name; const gchar *domain; gchar *message; ContextHashData *data; GtkTreeIter iter; gtk_tree_store_append (tree_store, &iter, NULL); context = get_context_proxy_for_name (context_name, &iter); name = unity_webapps_context_get_name (context); domain = unity_webapps_context_get_domain (context); message = g_strdup_printf("Context (%s): %s at %s", context_name, name, domain); gtk_tree_store_set(tree_store, &iter, 0, message, -1); data = g_hash_table_lookup (contexts_by_name, context_name); append_interests (context, data, &iter); unity_webapps_context_on_interest_appeared (context, on_interests_changed, data); unity_webapps_context_on_interest_vanished (context, on_interests_changed, data); unity_webapps_context_on_view_is_active_changed (context, on_view_is_active_changed, data); unity_webapps_context_on_view_location_changed (context, on_view_location_changed, data); data->pane = make_pane_for_context (context, data); g_free (message); } static void remove_context_by_name (const gchar *context_name) { GtkTreePath *path; ContextHashData *data; GtkTreeIter iter; data = (gpointer)g_hash_table_lookup (contexts_by_name, context_name); if (data == NULL) { return; } path = gtk_tree_row_reference_get_path (data->row_reference); gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &iter, path); gtk_tree_store_remove (tree_store, &iter); if (data->pane == current_pane) { gtk_container_remove (GTK_CONTAINER (pane_alignment), data->pane); current_pane = NULL; } g_hash_table_remove (contexts_by_name, context_name); gtk_tree_path_free (path); } static void populate_model_initially () { gchar **contexts; gchar *context; gint i; contexts = unity_webapps_service_list_contexts (service); i = 0; if (contexts == NULL) { return; } for (context = contexts[i]; context != NULL; context = contexts[++i]) { if (strlen (context) == 0) { continue; } append_context_by_name (context); } } static void on_context_appeared (UnityWebappsService *service, const gchar *name, gpointer user_data) { append_context_by_name (name); } static void on_context_vanished (UnityWebappsService *service, const gchar *name, gpointer user_data) { remove_context_by_name (name); } static void create_model () { tree_store = gtk_tree_store_new (1, G_TYPE_STRING); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (tree_store)); populate_model_initially (); } static void setup_column () { GtkTreeViewColumn *column; GtkCellRenderer *renderer; renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Object Name", renderer, "text", 0, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); } static void set_pane_by_context (UnityWebappsContext *context) { ContextHashData *data; const gchar *context_name; context_name = unity_webapps_context_get_context_name (context); data = g_hash_table_lookup (contexts_by_name, context_name); g_assert (data != NULL); if ((data == NULL) && (current_pane != NULL)) { gtk_container_remove (GTK_CONTAINER (pane_alignment), current_pane); current_pane = NULL; return; } if (current_pane != NULL) { if (current_pane == data->pane) { return; } gtk_container_remove (GTK_CONTAINER (pane_alignment), current_pane); current_pane = NULL; } if (gtk_widget_get_parent (data->pane) != NULL) { gtk_widget_reparent (data->pane, pane_alignment); } else { gtk_container_add (GTK_CONTAINER (pane_alignment), data->pane); } gtk_widget_show_all (data->pane); current_pane = data->pane; } static void set_pane_by_interest (UnityWebappsContext *context, gint interest_id) { ContextHashData *data; InterestHashData *interest_data; const gchar *context_name; context_name = unity_webapps_context_get_context_name (context); data = g_hash_table_lookup (contexts_by_name, context_name); interest_data = g_hash_table_lookup (data->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest_data == NULL) { return; } if ((data == NULL || interest_data == NULL) && (current_pane != NULL)) { gtk_container_remove (GTK_CONTAINER (pane_alignment), current_pane); current_pane = NULL; return; } if (current_pane != NULL) { if (current_pane == interest_data->pane) { return; } gtk_container_remove (GTK_CONTAINER (pane_alignment), current_pane); current_pane = NULL; } if (gtk_widget_get_parent (interest_data->pane) != NULL) { gtk_widget_reparent (interest_data->pane, pane_alignment); } else { gtk_container_add (GTK_CONTAINER (pane_alignment), interest_data->pane); } gtk_widget_show_all (interest_data->pane); current_pane = interest_data->pane; } static void on_tree_view_cursor_changed (GtkTreeView *tree_view, gpointer user_data) { GtkTreePath *path; UnityWebappsContext *context; gint depth; gtk_tree_view_get_cursor (tree_view, &path, NULL); if (path == NULL) { return; } depth = gtk_tree_path_get_depth (path); if (depth == 1) { context = get_context_by_tree_path (path); if (context == NULL) { goto out; } set_pane_by_context (context); } else if (depth == 2) { GtkTreePath *parent; gint interest; parent = gtk_tree_path_copy (path); gtk_tree_path_up (parent); context = get_context_by_tree_path (parent); interest = get_interest_by_tree_path (context, path); set_pane_by_interest (context, interest); gtk_tree_path_free (parent); } out: gtk_tree_path_free (path); } static void setup_treeview () { tree_view = gtk_tree_view_new (); g_signal_connect (tree_view, "cursor-changed", G_CALLBACK (on_tree_view_cursor_changed), NULL); setup_column(); gtk_container_add (GTK_CONTAINER (main_box), tree_view); create_model (); } static void setup_main_box () { main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); setup_treeview(); pane_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); gtk_container_add (GTK_CONTAINER (main_box), pane_alignment); gtk_container_add (GTK_CONTAINER (main_window), main_box); } static void setup_main_window () { gtk_window_set_title (GTK_WINDOW (main_window), "Unity Webapps Tracker"); setup_main_box (); } gint main (gint argc, gchar **argv) { gtk_init (&argc, &argv); contexts_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) context_hash_data_free); service = unity_webapps_service_new (); unity_webapps_service_on_context_appeared (service, on_context_appeared, NULL); unity_webapps_service_on_context_vanished (service, on_context_vanished, NULL); main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); setup_main_window (); gtk_window_set_default_size (GTK_WINDOW (main_window), 450, 250); gtk_widget_show_all (main_window); // gtk_window_set_resizable (GTK_WINDOW (main_window), FALSE); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); exit (0); } libunity-webapps-2.5.0~+14.04.20140409/tools/context-pane.xml0000644000015301777760000003230712321247333024107 0ustar pbusernogroup00000000000000 False False True False vertical True False True False 96 Context False True 0 True False 75 gtk-close 5 False True 1 True True 0 True True True False center vertical 13 True False 50 True False True False 0 Name: GMail True True 0 True False 0 Domain: mail.google.com True True 1 False True 0 True False 50 True False 0 Desktop name: GMail-mail.google.com False True 1 True False 50 True False 0 Number of Interests: center True True 2 True False 0.80000001192092896 0.15999999642372131 3 5 True False vertical Request Raise False True True True False False True 0 Request Close False True True True False False True 1 False True 3 True False Information False True False vertical True False Application Actions True True 0 True False True False True True 1 1 True False Actions 1 False False True 1 libunity-webapps-2.5.0~+14.04.20140409/tools/interest-pane.xml0000644000015301777760000002341212321247333024255 0ustar pbusernogroup00000000000000 False False True False vertical True False True False 96 Interest False True 0 True False 75 gtk-close 5 False True 1 True True 0 True False True False True False Owner: 0:0213 True True 0 True False True False 0 View is Active: No True True 1 False True 1 True False 7 True False Location http://www.facebook.com center end 50 False True 2 True False True False 5 100 100 True False 100 start-here True True 0 True False vertical True False 0.50999999046325684 1 0.69999998807907104 0.10999999940395355 4 Request Preview False True True True False True True 0 True False 0.75999999046325684 0.10999999940395355 Request Raise False True True True False True True 1 True True 1 False True 3 libunity-webapps-2.5.0~+14.04.20140409/tools/unity-webapps-tool.c0000644000015301777760000000651012321247333024703 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-tool.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" static UnityWebappsService *service = NULL; static void print_help () { g_printf("Usage: unity-webapps-tool \n"); g_printf("Possible commands include:\n"); g_printf(" help - display this message\n"); g_printf(" list - list running web-application contexts"); g_printf(" shutdown - shutdown the Unity Webapps System"); } static UnityWebappsContext * make_context_proxy (const gchar *name) { return unity_webapps_context_new_for_context_name (service, name); } static void list_contexts () { gchar **contexts; guint i, len; contexts = unity_webapps_service_list_contexts (service); if (contexts == NULL) { return; } len = g_strv_length ((gchar **)contexts); g_printf("Running contexts:\n"); for (i = 0; i < len; i++) { UnityWebappsContext *context; const gchar *context_name; context_name = contexts[i]; if (context_name[0] == '\0') continue; context = make_context_proxy (context_name); g_printf(" * %s (%s)\n", unity_webapps_context_get_name (context), context_name); } g_strfreev (contexts); } static void shutdown_all () { gchar **contexts; guint i, len; contexts = unity_webapps_service_list_contexts (service); if (contexts == NULL) { return; } len = g_strv_length ((gchar **)contexts); printf("Shutting down contexts\n"); for (i = 0; i < len; i++) { UnityWebappsContext *context; const gchar *context_name; gboolean shutdown; context_name = contexts[i]; context = make_context_proxy (context_name); g_printf(" * Shutting down %s (%s)..", unity_webapps_context_get_name (context), context_name); shutdown = unity_webapps_context_shutdown (context); if (shutdown == FALSE) { g_printf("Failed to shutdown\n"); } else { g_printf("Done\n"); } g_printf("Shutting down service..."); unity_webapps_service_shutdown (service); g_printf("Done\n"); } g_strfreev (contexts); } gint main (gint argc, gchar **argv) { g_type_init (); service = unity_webapps_service_new (); if (argc == 1) { print_help(); exit(0); } if (g_strcmp0(argv[1], "help") == 0) { print_help(); exit(0); } if (g_strcmp0(argv[1], "list") == 0) { list_contexts(); exit(0); } if (g_strcmp0(argv[1], "shutdown") == 0) { shutdown_all(); exit(0); } print_help(); exit (0); } libunity-webapps-2.5.0~+14.04.20140409/tools/unity-webapps-desktop-file.c0000644000015301777760000000312412321247333026312 0ustar pbusernogroup00000000000000#include #include #include #include #include "unity-webapps-application-info.h" #include "unity-webapps-application-manifest.h" static gboolean write_desktop_file (UnityWebappsApplicationManifest *manifest) { UnityWebappsApplicationInfo *info; const gchar *name, *domain; gchar *desktop_name; GError *error; name = unity_webapps_application_manifest_get_name (manifest); domain = unity_webapps_application_manifest_get_domain (manifest); if (!domain) return FALSE; info = unity_webapps_application_info_new (name, domain, "", NULL); // It's a waste of time to free this. desktop_name = unity_webapps_application_info_get_desktop_file_name (info); error = NULL; unity_webapps_application_info_write_desktop_file_to_path (info, desktop_name, &error); if (error != NULL) { // No reason to free g_warning ("Error writing desktop file: %s \n", error->message); return FALSE; } return TRUE; } gint main (gint argc, gchar **argv) { UnityWebappsApplicationManifest *manifest; gboolean wrote; g_type_init (); if (argc != 2) { g_printf("Usage: unity-webapps-desktop-file <>\n"); return 1; } manifest = unity_webapps_application_manifest_new_from_file (argv[1]); if (manifest == FALSE) { g_printf("Failed to load and parse manifest file \n"); return 1; } wrote = write_desktop_file (manifest); if (wrote == FALSE) { g_printf("Failed to write desktop file \n"); return 1; } return 0; } libunity-webapps-2.5.0~+14.04.20140409/tools/unity-webapps-installer.c0000644000015301777760000000757312321247333025735 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-tool.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ." */ #include #include #include #include #include "unity-webapps-application-info.h" #include "unity-webapps-permissions.h" static gchar *name = NULL; static gchar *domain = NULL; static gchar *icon_uri = NULL; static gchar *homepage = NULL; static gboolean force = FALSE; static GOptionEntry option_entries[] = { { "name", 'n', 0, G_OPTION_ARG_STRING, &name, "Application name", NULL}, { "domain", 'd', 0, G_OPTION_ARG_STRING, &domain, "Application domain", NULL}, { "icon-uri", 'i', 0, G_OPTION_ARG_STRING, &icon_uri, "Application main icon URI", NULL}, { "homepage", 'h', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING, &homepage, "Application homepage", NULL}, { "force", 'f', 0, G_OPTION_ARG_NONE, &force, "Force install even if Domain has been blacklisted", NULL}, { NULL, } }; static void unity_webapps_installer_parse_args (gint *argc, gchar ***argv) { GOptionContext *context; GError *error; context = g_option_context_new (" - Install Unity Webapps"); // TODO: Localization g_option_context_add_main_entries (context, option_entries, NULL); error = NULL; if (!g_option_context_parse (context, argc, argv, &error)) { g_printf("Failed to parse arguments: %s \n", error->message); g_error_free (error); exit(1); } return; } static void unity_webapps_installer_install_application () { UnityWebappsApplicationInfo *info; gchar *saved_icon, *desktop_file_path; GError *error; info = unity_webapps_application_info_new (name, domain, icon_uri, NULL); printf("Installing application: %s at %s\n", name, domain); saved_icon = unity_webapps_application_info_save_icon_file (info); if (saved_icon == NULL) { g_error ("Failed to save icon file!"); exit(1); } printf(" * Wrote icon file: %s", saved_icon); error = NULL; unity_webapps_application_info_ensure_desktop_file (info, &error); if (error != NULL) { g_error ("Failed to write desktop file: %s \n", error->message); g_error_free (error); exit (1); } desktop_file_path = unity_webapps_application_info_get_desktop_file_path (info); printf(" * Wrote desktop file: %s\n", desktop_file_path); if (homepage != NULL) { homepage = domain; } unity_webapps_application_info_set_homepage (info, homepage); return; } static void unity_webapps_installer_authorize_application () { gboolean dontask; dontask = unity_webapps_permissions_get_domain_dontask (domain); if (dontask == TRUE) { printf("Trying to install application at domain %s, which has been blacklisted due to user action.\n", domain); if (force == TRUE) { printf("Forcing install anyway\n"); } else { exit(1); } } unity_webapps_permissions_allow_domain (domain); return; } gint main (gint argc, gchar **argv) { g_type_init (); unity_webapps_installer_parse_args (&argc, &argv); unity_webapps_installer_authorize_application (); unity_webapps_installer_install_application (); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tools/action-invoker.c0000644000015301777760000001042312321247333024047 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-action-invoker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include #include #include #include static UnityWebappsService *service = NULL; static gchar *name = NULL; static gchar *domain = NULL; const gchar *action = NULL; static GOptionEntry option_entries[] = { { "name", 'n',0,G_OPTION_ARG_STRING, &name, "Application name", NULL }, { "domain", 'd',0, G_OPTION_ARG_STRING, &domain, "Application domain", NULL}, { "action", 'a', 0, G_OPTION_ARG_STRING, &action, "Action path", NULL} }; static gchar ** split_action_path (const gchar *action_path) { gchar **components; if (action_path[0] != '/') { return NULL; } components = g_strsplit (action_path+1, "/", -1); if (g_strv_length (components) > 3) { g_strfreev (components); return NULL; } return components; } static DbusmenuMenuitem * menuitem_find_child_by_label (DbusmenuMenuitem *item, const gchar *label) { const GList *children; const GList *walk; children = dbusmenu_menuitem_get_children (item); for (walk = children; walk != NULL; walk = walk->next) { DbusmenuMenuitem *child; const gchar *child_label; child = (DbusmenuMenuitem *)walk->data; child_label = dbusmenu_menuitem_property_get (child, "label"); if (g_strcmp0 (child_label, label) == 0) { return child; } } return NULL; } static void invoke_action_by_path (DbusmenuMenuitem *root, const gchar *action_path) { gchar **components; DbusmenuMenuitem *item; gint i, length; components = split_action_path (action_path); length = g_strv_length (components); if (length < 0) { return; } item = root; for (i = 0; i < length; i++) { DbusmenuMenuitem *child; gchar *component; component = components[i]; child = menuitem_find_child_by_label (item, component); if (child == NULL) { g_error ("Action not found"); exit (1); } item = child; } g_message("Invoking item: %s", components[i-1]); dbusmenu_menuitem_handle_event (item, "clicked", NULL, time(NULL)); g_strfreev (components); } static void on_root_changed (DbusmenuClient *client, DbusmenuMenuitem *newitem, gpointer user_data) { invoke_action_by_path (newitem, action); } static void context_ready (UnityWebappsContext *context, gpointer user_data) { DbusmenuClient *client; const gchar *context_name; context_name = unity_webapps_context_get_context_name (context); client = dbusmenu_client_new (context_name, "/com/canonical/Unity/Webapps/Context/ApplicationActions"); g_signal_connect (client, "root-changed", G_CALLBACK (on_root_changed), NULL); } gint main (gint argc, gchar **argv) { GOptionContext *context; GError *error; g_type_init (); service = unity_webapps_service_new (); error = NULL; context = g_option_context_new ("- Activate Unity WebApps"); // TODO: GETTEXT g_option_context_add_main_entries (context, option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printf("Failed to parse arguments: %s\n", error->message); exit(1); } unity_webapps_context_new (service, name, domain, "", NULL, context_ready, NULL); g_main_loop_run (g_main_loop_new (NULL, FALSE)); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tools/context-tracker.c0000644000015301777760000000637212321247333024244 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * view-activity-tracker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" static UnityWebappsService *service = NULL; static GMainLoop *mainloop = NULL; void print_context_for_name (const gchar *name) { UnityWebappsContext *context; const gchar *cname; const gchar *domain; context = unity_webapps_context_new_for_context_name (service, name); if (context == NULL) { return; } cname = unity_webapps_context_get_name (context); domain = unity_webapps_context_get_domain (context); gint interests = g_variant_n_children (unity_webapps_context_list_interests (context)); printf("Context (%s), %s (%s) interest #%d\n", name, cname, domain, interests); g_object_unref (G_OBJECT (context)); } void print_context_list () { gchar **context; gchar **context_list = unity_webapps_service_list_contexts (service); printf("===== Listing Contexts ===== \n"); for (context = context_list; context && *context; context++) { if (strlen (*context) == 0) continue; print_context_for_name (*context); } printf("================================\n"); g_strfreev (context_list); } static void on_interest_appeared (UnityWebappsContext *context, gint id, gpointer data) { printf("interest appeared\n"); print_context_list (); } static void on_interest_vanished (UnityWebappsContext *context, gint id, gpointer data) { printf("interest vanished\n"); print_context_list (); } static void on_context_appeared (UnityWebappsService *service, const gchar *name, gpointer user_data) { UnityWebappsContext *context; context = unity_webapps_context_new_for_context_name (service, name); unity_webapps_context_on_interest_appeared (context, on_interest_appeared, NULL); unity_webapps_context_on_interest_vanished (context, on_interest_vanished, NULL); printf("Context appeared \n"); print_context_list (); } static void on_context_vanished (UnityWebappsService *service, const gchar *name, gpointer user_data) { printf("Context vanished \n"); print_context_list (); } gint main (gint argc, gchar **argv) { g_type_init (); service = unity_webapps_service_new (); print_context_list (); unity_webapps_service_on_context_appeared (service, on_context_appeared, NULL); unity_webapps_service_on_context_vanished (service, on_context_vanished, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); exit (0); } libunity-webapps-2.5.0~+14.04.20140409/gtk-doc.make0000644000015301777760000001726712321247333022017 0ustar pbusernogroup00000000000000# -*- mode: makefile -*- #################################### # Everything below here is generic # #################################### if GTK_DOC_USE_LIBTOOL GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) GTKDOC_RUN = $(LIBTOOL) --mode=execute else GTKDOC_CC = $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) GTKDOC_LD = $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) GTKDOC_RUN = endif # We set GPATH here; this gives us semantics for GNU make # which are more like other make's VPATH, when it comes to # whether a source that is a target of one rule is then # searched for in VPATH/GPATH. # GPATH = $(srcdir) TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE) SETUP_FILES = \ $(content_files) \ $(DOC_MAIN_SGML_FILE) \ $(DOC_MODULE)-sections.txt \ $(DOC_MODULE)-overrides.txt EXTRA_DIST = \ $(HTML_IMAGES) \ $(SETUP_FILES) DOC_STAMPS=setup-build.stamp scan-build.stamp sgml-build.stamp \ html-build.stamp pdf-build.stamp \ sgml.stamp html.stamp pdf.stamp SCANOBJ_FILES = \ $(DOC_MODULE).args \ $(DOC_MODULE).hierarchy \ $(DOC_MODULE).interfaces \ $(DOC_MODULE).prerequisites \ $(DOC_MODULE).signals REPORT_FILES = \ $(DOC_MODULE)-undocumented.txt \ $(DOC_MODULE)-undeclared.txt \ $(DOC_MODULE)-unused.txt CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) if ENABLE_GTK_DOC if GTK_DOC_BUILD_HTML HTML_BUILD_STAMP=html-build.stamp else HTML_BUILD_STAMP= endif if GTK_DOC_BUILD_PDF PDF_BUILD_STAMP=pdf-build.stamp else PDF_BUILD_STAMP= endif all-local: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP) else all-local: endif docs: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP) $(REPORT_FILES): sgml-build.stamp #### setup #### setup-build.stamp: -@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ echo ' DOC Preparing build'; \ files=`echo $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types`; \ if test "x$$files" != "x" ; then \ for file in $$files ; do \ test -f $(abs_srcdir)/$$file && \ cp -pu $(abs_srcdir)/$$file $(abs_builddir)/ || true; \ done; \ fi; \ fi @touch setup-build.stamp #### scan #### scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB) @echo ' DOC Scanning header files' @_source_dir='' ; \ for i in $(DOC_SOURCE_DIR) ; do \ _source_dir="$${_source_dir} --source-dir=$$i" ; \ done ; \ gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES) @if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \ echo " DOC Introspecting gobjects"; \ scanobj_options=""; \ gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \ if test "$(?)" = "0"; then \ if test "x$(V)" = "x1"; then \ scanobj_options="--verbose"; \ fi; \ fi; \ CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" \ gtkdoc-scangobj $(SCANGOBJ_OPTIONS) $$scanobj_options --module=$(DOC_MODULE); \ else \ for i in $(SCANOBJ_FILES) ; do \ test -f $$i || touch $$i ; \ done \ fi @touch scan-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp @true #### xml #### sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files) @echo ' DOC Building XML' @_source_dir='' ; \ for i in $(DOC_SOURCE_DIR) ; do \ _source_dir="$${_source_dir} --source-dir=$$i" ; \ done ; \ gtkdoc-mkdb --module=$(DOC_MODULE) --output-format=xml --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $${_source_dir} $(MKDB_OPTIONS) @touch sgml-build.stamp sgml.stamp: sgml-build.stamp @true #### html #### html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) @echo ' DOC Building HTML' @rm -rf html @mkdir html @mkhtml_options=""; \ gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \ if test "$(?)" = "0"; then \ if test "x$(V)" = "x1"; then \ mkhtml_options="$$mkhtml_options --verbose"; \ fi; \ fi; \ gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \ if test "$(?)" = "0"; then \ mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \ fi; \ cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE) -@test "x$(HTML_IMAGES)" = "x" || \ for file in $(HTML_IMAGES) ; do \ if test -f $(abs_srcdir)/$$file ; then \ cp $(abs_srcdir)/$$file $(abs_builddir)/html; \ fi; \ if test -f $(abs_builddir)/$$file ; then \ cp $(abs_builddir)/$$file $(abs_builddir)/html; \ fi; \ done; @echo ' DOC Fixing cross-references' @gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS) @touch html-build.stamp #### pdf #### pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) @echo ' DOC Building PDF' @rm -f $(DOC_MODULE).pdf @mkpdf_options=""; \ gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \ if test "$(?)" = "0"; then \ if test "x$(V)" = "x1"; then \ mkpdf_options="$$mkpdf_options --verbose"; \ fi; \ fi; \ if test "x$(HTML_IMAGES)" != "x"; then \ for img in $(HTML_IMAGES); do \ part=`dirname $$img`; \ echo $$mkpdf_options | grep >/dev/null "\-\-imgdir=$$part "; \ if test $$? != 0; then \ mkpdf_options="$$mkpdf_options --imgdir=$$part"; \ fi; \ done; \ fi; \ gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_options $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS) @touch pdf-build.stamp ############## clean-local: @rm -f *~ *.bak @rm -rf .libs distclean-local: @rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \ $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ rm -f $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types; \ fi maintainer-clean-local: clean @rm -rf xml html install-data-local: @installfiles=`echo $(builddir)/html/*`; \ if test "$$installfiles" = '$(builddir)/html/*'; \ then echo 1>&2 'Nothing to install' ; \ else \ if test -n "$(DOC_MODULE_VERSION)"; then \ installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \ else \ installdir="$(DESTDIR)$(TARGET_DIR)"; \ fi; \ $(mkinstalldirs) $${installdir} ; \ for i in $$installfiles; do \ echo ' $(INSTALL_DATA) '$$i ; \ $(INSTALL_DATA) $$i $${installdir}; \ done; \ if test -n "$(DOC_MODULE_VERSION)"; then \ mv -f $${installdir}/$(DOC_MODULE).devhelp2 \ $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \ fi; \ $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \ fi uninstall-local: @if test -n "$(DOC_MODULE_VERSION)"; then \ installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \ else \ installdir="$(DESTDIR)$(TARGET_DIR)"; \ fi; \ rm -rf $${installdir} # # Require gtk-doc when making dist # if ENABLE_GTK_DOC dist-check-gtkdoc: else dist-check-gtkdoc: @echo "*** gtk-doc must be installed and enabled in order to make dist" @false endif dist-hook: dist-check-gtkdoc dist-hook-local @mkdir $(distdir)/html @cp ./html/* $(distdir)/html @-cp ./$(DOC_MODULE).pdf $(distdir)/ @-cp ./$(DOC_MODULE).types $(distdir)/ @-cp ./$(DOC_MODULE)-sections.txt $(distdir)/ @cd $(distdir) && rm -f $(DISTCLEANFILES) @$(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html .PHONY : dist-hook-local docs libunity-webapps-2.5.0~+14.04.20140409/Makefile.am0000644000015301777760000000062712321247333021654 0ustar pbusernogroup00000000000000ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src po tests data docs tools INTLTOOL_FILES = intltool-extract.in \ intltool-merge.in \ intltool-update.in EXTRA_DIST = $(unity_webappsdoc_DATA) \ $(INTLTOOL_FILES) \ autogen.sh DISTCLEANFILES = intltool-extract \ intltool-merge \ intltool-update \ po/.intltool-merge-cache DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc include $(top_srcdir)/Makefile.am.coverage libunity-webapps-2.5.0~+14.04.20140409/tests/0000755000015301777760000000000012321250157020753 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/Makefile.am0000644000015301777760000000016212321247333023010 0ustar pbusernogroup00000000000000SUBDIRS = context-daemon repository index-updater misc libunity-webapps if ENABLE_TESTS SUBDIRS += traced endif libunity-webapps-2.5.0~+14.04.20140409/tests/traced/0000755000015301777760000000000012321250157022215 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/multicontext/0000755000015301777760000000000012321250157024754 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/multicontext/Makefile.am0000644000015301777760000000070312321247333027012 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/tests/traced/common noinst_PROGRAMS = \ raise-most-recent raise_most_recent_SOURCES = \ raise-most-recent.c \ ../common/uwa-test-client.c raise_most_recent_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/multicontext/raise-most-recent.c0000644000015301777760000000435112321247333030466 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static UnityWebappsService *service = NULL; guint count = 2; static void raise_one (UnityWebappsContext *context, const gchar *file, gpointer user_data) { uwa_emit_test_finished (); } static void raise_two (UnityWebappsContext *context, const gchar *file, gpointer user_data) { g_warning ("Got wrong raise signal"); exit (1); } static gboolean change_activity (gpointer user_data) { UnityWebappsContext *context; context = (UnityWebappsContext *)user_data; printf("Fooo \n"); unity_webapps_context_set_view_is_active (context, FALSE); return FALSE; } static void context_two_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_context_on_raise_callback (context, raise_two, NULL); unity_webapps_context_set_view_is_active (context, TRUE); g_timeout_add_seconds (1, change_activity, context); } static void context_one_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_context_on_raise_callback (context, raise_one, NULL); unity_webapps_context_set_view_is_active (context, TRUE); unity_webapps_indicator_show_indicator (context, "Multicontext raise test"); unity_webapps_context_new (service, "TestMulticontextRaiseMostRecent", "test.ts", ICON_URL, NULL, context_two_ready, NULL); } gint main (gint argc, gchar **argv) { g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestMulticontextRaiseMostRecent", "test.ts", ICON_URL, NULL, context_one_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/multicontext/raise-most-recent.trace0000644000015301777760000000045712321247333031345 0ustar pbusernogroup00000000000000<[Service]> Handling GetContext Spawning context Handling GetContext <[Context]> Emitting ViewIsActive Emitting ViewIsActive Emitting ViewIsActive<|indicator-action-invoker TestMulticontextRaiseMostRecent|> <[Client]> Created context proxy Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/observer-api/0000755000015301777760000000000012321250157024613 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/observer-api/Makefile.am0000644000015301777760000000066712321247333026662 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/tests/traced/common noinst_PROGRAMS = \ track-location track_location_SOURCES = \ track-location.c \ ../common/uwa-test-client.c track_location_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/observer-api/track-location.c0000644000015301777760000000360212321247333027674 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static UnityWebappsService *service = NULL; static UnityWebappsContext *observer_context = NULL; static const gchar * const locations[] = {"Foo", "Bar", "Baz", NULL}; static gint location_index = 0; static void observer_context_location_changed (UnityWebappsContext *context, gint interest_id, const gchar *location, gpointer user_data) { if (g_strcmp0 (locations[location_index], location) != 0) { printf("Got incorrect location: %s\n", location); exit(1); } location_index++; if (locations[location_index] == NULL) { uwa_emit_test_finished (); } } static gboolean change_location (gpointer user_data) { UnityWebappsContext *context; context = (UnityWebappsContext *)user_data; unity_webapps_context_set_view_location (context, locations[location_index]); return TRUE; } static void create_observer_context (UnityWebappsContext *context) { observer_context = unity_webapps_context_new_for_context_name (service, unity_webapps_context_get_context_name (context)); unity_webapps_context_on_view_location_changed (observer_context, observer_context_location_changed, NULL); } static void context_one_ready (UnityWebappsContext *context, gpointer user_data) { create_observer_context (context); g_timeout_add (100, change_location, context); } gint main (gint argc, gchar **argv) { g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_one_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/observer-api/track-location.trace0000644000015301777760000000047212321247333030552 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Handling SetInterestLocation Emitting ViewLocationChanged.*Foo Handling SetInterestLocation Emitting ViewLocationChanged.*Bar Handling SetInterestLocation Emitting ViewLocationChanged.*Baz <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/Makefile.am0000644000015301777760000000030412321247333024250 0ustar pbusernogroup00000000000000SUBDIRS = misc notification indicator music-player fuzz launcher multicontext actions observer-api test-runner common if ENABLE_TESTS TESTS_ENVIRONMENT=$(SHELL) -x TESTS = run-all-tests.sh endif libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/0000755000015301777760000000000012321250157024703 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/Makefile.am0000644000015301777760000000304512321247333026743 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/tests/traced/common noinst_PROGRAMS = \ simple-show \ theme-icon \ invalid-image \ url-image \ data-uri \ invalid-data-uri invalid_data_uri_SOURCES = \ invalid-data-uri.c \ ../common/uwa-test-client.c invalid_data_uri_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la simple_show_SOURCES = \ simple-show.c \ ../common/uwa-test-client.c simple_show_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la theme_icon_SOURCES = \ theme-icon.c \ ../common/uwa-test-client.c theme_icon_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la invalid_image_SOURCES = \ invalid-image.c \ ../common/uwa-test-client.c invalid_image_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la data_uri_SOURCES = \ data-uri.c \ ../common/uwa-test-client.c data_uri_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la url_image_SOURCES = \ url-image.c \ ../common/uwa-test-client.c url_image_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/simple-show.c0000644000015301777760000000160312321247333027320 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_notification_show_notification (context, "Notification", "Sent a simple test notification", NULL); printf ("Sent a test notification \n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/invalid-image.trace0000644000015301777760000000057112321247333030436 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowNotification call Looking up URI.*thisIsNotAnImage Cache miss Resource Cache failed.*thisIsNotAnImage Handling ShowNotification call Handling ShowNotification call Resource Cache failed.*foo bar baz using application icon <[Client]> Showed notification libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/theme-icon.c0000644000015301777760000000170112321247333027100 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_notification_show_notification (context, "Test notification", "Test notification with a themed icon", "icon://user-trash"); printf("Sent a test notification with the icon://user-trash themed icon \n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/theme-icon.trace0000644000015301777760000000040012321247333027747 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowNotification call Looking up URI themed resource, skipping the cache looking up icon name: user-trash <[Client]> Showed notification libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/data-uri.c0000644000015301777760000000635712321247333026572 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sKBw0vIqzujI4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAGhklEQVRo3t2bT0gbeRTHv/MnMRl3XAoNC81hipeOs0cTTyUFpbsbwZquWHpJKHRprYUKXiK4Pe2G6qXQlka3bEFiD7KSVldoKksKHXpK4nHH9FIa2AjdLJQ1NZpkMtmDras1ycykxiS+o87vl/nMe/N+3/fm9yOKxSJqZG0ATiupZKeSWhMKq5F2ACcAHAPQCkABsAngHcXxa2DaXtOCXQKwAuAlgPVa3BRxwMCckkoOyrFwn7zy3FF4E0cxk9Y1AcXxoIQu0B02kbb1LAGYB5BoKOBiJt2bf/HkSl5c7C8k4gfnDYYFbeuB0elepDj+AYCndQUuZtK9uVDAmwvNOvR6Uq/Rgh3G76+LtGCf/BzwaoG5XCgwkQ36L9YatBS46apvjrRYx6oJdd3AhUT88tb0+J1CIt6KOhnBsDA63RstA9dHADysGXBeXPBvTo9fQ4MYLdhhHr03RTDs8EEDt21Oj/+WFxe+RYMZabHCPHp3meL4C1qWMlXgYib91VZg4ve8uNCFBjWCYcHcnIlQHH8OwNvPAW7L/HzpD1mKNixsCeizlTxdEXhzevyZnjA2OFww2LpBCV0gGBYAoKSSkGNh5J49gpJKVhxH23p2J0cUpEjFcWWglymO/043cDZ4358N+jUlKIrjYRrygeL4itdlg/eRDfp1jStm0sgG/ciFAprf6dZbwbKJrCSwHAtfzty+8atWWObmzI5HNWR6bE6PVz1Oa/Zmfpz5odSStQ+4mElz72+c/bOYSbdqCaHWW0GQFquu9y0XCsBw5rxm2I+2NTup2dMmt3fD6PR8/ak4IUu8txNaYAHA6HTrht0e59ENCwAtA8Oax2WD/lYllZzYF/J7QlmK9sqx8EU9N37Ymdhw5rxWnY+t2cmLAHrLAuce3/fqUTnVeOmz1VVnt+Zr5VgYshT1lgSWpWivLEUdmhUO11EnZXVCX754fN+x28vkrn9c0RdeX9RNSuoxWYpCSSWv7AFWUklOlqL9uqqm1WhdgGVJ/+9mg/5+ANwOsBwLD+qdpPAmXhdgJbGq/yHFwgAwuAOcFxf7quh2fJzoUC337BGqvNc+ACAKf//V9n7km3/1ZGeDwwWqw17VGnxQYS2vPEf+xRPNTUKj0wOT2/slXViNnta6BppH74EW7A1R+NOCHS0Dw9gKTCAvLqi/glIEAE7ThcSrTo2CvC7rrqoThnw7WlulNQUAnaSSWBXUJjaP3m042D33N+TbU1pWgBZIJbXWrqZf1cq+RoFWc0pxI91OKqnkCbWivhnsY9O+snaInCCx/a2nbK1br0xcjRlsqjr7GAnAXPapNREsAIBpU4188iB1azMYie1Plgcm4xrcNkkA7xpNL9dQZ78jAaxV0qBaVEyjmJrOJi3WNZIW7K9VSqvmgA0FVPvXxHHra5I4bpUqhkkqqbk9Wi8rJOKaHEOd5CWS4k6tqF2opydcD9jMT5dUqyaCYUEw7ApNCV0vtUycFxdQWI3C5PZq0q01T1CpJLJBv+YcQwldAPCSpjh+nWBYsZhJO7T8SOb2DRAMC+okD6rDXgfQNSiJOPTuJTHYukUA6zQA0Laepby4oLljWcykt4twKYpmMarDvrTT4jHYuudxhI0W7CAt1vkdYNrWkyAt1sWjCmxwuBbx4RsT+f8f+x8cRViCYWFwuB7s1tIAAKPT85RgWPGoARudbhG79nWRu5+E0emePGreNTo9k59WS9jtZdJinTsqwCbP2BzBsE/LAhMMC5PbOwZg4whk5g2DwzVWqh7ee6GtJ2FwuEaaPZRNV30jKLE1kSwTCg8pjp9qVmDzkG+KtFgflut4lH5CQ75hgmGXmy8re5ZpW89wpRZPaSm2vcvmAsGwkSYSGBGT23uhYhOgov7k+HXm5sy5ZoA2OFwR85DvHFT2W5Kqopvj3zI3Z842cngbHK5l85DvLFT2WQI6tg8XEnFsTY/7C4n4tUaCNbm9U0an58C3D++Uhdmg/3IuFLiD7ZMpdTPSYt0wj94doTi+dhvEP5osRbmtX8YnlFTyYj1gjU7PXMvA8BjBsLU/ArDb27lQoDcXmvVq6ZYckHoSW9xjkxTHH/ohj33geXHxipJK9tcoKS0aHK4HtGCv7zGefaEeC3P52PNBORbu+1yv04JdpDu7lwxnzs9XE7qHAvxJVm8rSJHThcSrzuI/SUFJrbV/+Ba97ygeLdjXwLS9prhTEsXxK5TQ9ZJg2JocxfsPlPjVREHRwK4AAAAASUVORK5CYII=" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_notification_show_notification (context, "Data URI", "A test notification with a data URI", ICON_URL); printf("Set indicator property icon (to a data URI)\n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestDataURI", "test.ts", "", NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/data-uri.trace0000644000015301777760000000052412321247333027434 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowNotification call (Making file from data URI)|(Cache hit) Obtained resource file Resource DB total size computed stored resource <[Client]> Showed notification libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/simple-show.trace0000644000015301777760000000032312321247333030172 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowNotification call using application icon for notification <[Client]> Showed notification libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/invalid-data-uri.trace0000644000015301777760000000047312321247333031063 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Handling ShowNotification call Looking up URI Cache miss Making file from data URI Failed to parse data uri Failed to save data uri failed to get resource path for URI using application icon <[Client]> Showed notification libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/url-image.trace0000644000015301777760000000027312321247333027611 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowNotification call Looking up URI <[Client]> Showed notification libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/invalid-image.c0000644000015301777760000000244212321247333027561 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; #include "uwa-test-client.h" static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_notification_show_notification (context, "Test notification", "Test notification with an invalid URL", "http://www.ubuntu.com/thisIsNotAnImage.jpg"); unity_webapps_notification_show_notification (context, "Test notification", "Test notification with a URL pointing to an invalid picture", "http://www.google.com/index.html"); unity_webapps_notification_show_notification (context, "Test notification", "Test notification with an invalid URI spec", "foo bar baz"); printf("Sent an assortment of notification with invalid URIs"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/url-image.c0000644000015301777760000000204012321247333026727 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" #define NOTIFICATION_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_notification_show_notification (context, "Test notification", "Test notification with a URL icon", NOTIFICATION_URL); printf ("Send a test notification with a URL icon \n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/notification/invalid-data-uri.c0000644000015301777760000000161512321247333030206 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "data:THIS IS NOT A VLIA DATA URIASJFAKSFLASF" #include "uwa-test-client.h" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_notification_show_notification (context, "Data URI", "A test notification with an invalid data URI", ICON_URL); printf("Set indicator property icon (to an invalid Data URI)\n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestDataURI", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/0000755000015301777760000000000012321250157024627 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/init0000755000015301777760000001666212321247333025535 0ustar pbusernogroup00000000000000#! /bin/bash # init - temporary wrapper script for .libs/init # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 # # The init program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command="(cd /home/racarr/src/webapps/libunity-webapps/trunk/tests/music-player; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games; export PATH; gcc -g -O2 -O0 -Wall -o \$progdir/\$file init.o -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 ../../src/.libs/libunity_webapps.so -lgthread-2.0 -Wl,-rpath -Wl,/home/racarr/src/webapps/libunity-webapps/trunk/src/.libs)" # This environment variable determines our operation mode. if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then # install mode needs the following variables: generated_by_libtool_version='2.4.2' notinst_deplibs=' ../../src/libunity-webapps.la' else # When we are sourced in execute mode, $file and $ECHO are already set. if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then file="$0" # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO="printf %s\\n" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string --lt- # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's ../../libtool value, followed by no. lt_option_debug= func_parse_lt_options () { lt_script_arg0=$0 shift for lt_opt do case "$lt_opt" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` cat "$lt_dump_D/$lt_dump_F" exit 0 ;; --lt-*) $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n "$lt_option_debug"; then echo "init:init:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do $ECHO "init:init:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" lt_dump_args_N=`expr $lt_dump_args_N + 1` done } # Core function for launching the target application func_exec_program_core () { if test -n "$lt_option_debug"; then $ECHO "init:init:${LINENO}: newargv[0]: $progdir/$program" 1>&2 func_lt_dump_args ${1+"$@"} 1>&2 fi exec "$progdir/$program" ${1+"$@"} $ECHO "$0: cannot exec $program $*" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from $@ and # launches target application with the remaining arguments. func_exec_program () { case " $* " in *\ --lt-*) for lt_wr_arg do case $lt_wr_arg in --lt-*) ;; *) set x "$@" "$lt_wr_arg"; shift;; esac shift done ;; esac func_exec_program_core ${1+"$@"} } # Parse options func_parse_lt_options "$0" ${1+"$@"} # Find the directory that this script lives in. thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` test "x$thisdir" = "x$file" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` while test -n "$file"; do destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` # If there was a directory component, then change thisdir. if test "x$destdir" != "x$file"; then case "$destdir" in [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; *) thisdir="$thisdir/$destdir" ;; esac fi file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then # special case for '.' if test "$thisdir" = "."; then thisdir=`pwd` fi # remove .libs from thisdir case "$thisdir" in *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; .libs ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=`cd "$thisdir" && pwd` test -n "$absdir" && thisdir="$absdir" program=lt-'init' progdir="$thisdir/.libs" if test ! -f "$progdir/$program" || { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ test "X$file" != "X$progdir/$program"; }; then file="$$-$program" if test ! -d "$progdir"; then mkdir "$progdir" else rm -f "$progdir/$file" fi # relink executable if necessary if test -n "$relink_command"; then if relink_command_output=`eval $relink_command 2>&1`; then : else printf %s\n "$relink_command_output" >&2 rm -f "$progdir/$file" exit 1 fi fi mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || { rm -f "$progdir/$program"; mv -f "$progdir/$file" "$progdir/$program"; } rm -f "$progdir/$file" fi if test -f "$progdir/$program"; then if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then # Run the actual program with our arguments. func_exec_program ${1+"$@"} fi else # The program doesn't exist. $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 $ECHO "This script is just a wrapper for $program." 1>&2 $ECHO "See the libtool documentation for more information." 1>&2 exit 1 fi fi libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/set-playlists.trace0000644000015301777760000000024212321247333030464 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling SetPlaylists <[Client]> Setting playlists libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/Makefile.am0000644000015301777760000000312312321247333026664 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/tests/traced/common noinst_PROGRAMS = \ set-track \ properties \ callbacks \ data-uri \ set-playlists \ interactive-playlist-callbacks set_track_SOURCES = \ set-track.c \ ../common/uwa-test-client.c set_track_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la set_playlists_SOURCES = \ set-playlists.c \ ../common/uwa-test-client.c set_playlists_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la data_uri_SOURCES = \ data-uri.c \ ../common/uwa-test-client.c data_uri_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la properties_SOURCES = \ properties.c \ ../common/uwa-test-client.c properties_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la callbacks_SOURCES = \ callbacks.c \ ../common/uwa-test-client.c callbacks_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la interactive_playlist_callbacks_SOURCES = \ interactive-playlist-callbacks.c \ ../common/uwa-test-client.c interactive_playlist_callbacks_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/callbacks.c0000644000015301777760000000447512321247333026726 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static guint callbacks = 0; static void on_play_pause (UnityWebappsContext *context, gpointer user_data) { callbacks ++; printf("Playpause \n"); } static void on_previous (UnityWebappsContext *context, gpointer user_data) { callbacks ++; printf("Previous \n"); } static void on_next (UnityWebappsContext *context, gpointer user_data) { callbacks ++; printf("Next \n"); } static void on_raise (UnityWebappsContext *context, const gchar *file, gpointer user_data) { printf("Raise \n"); if (callbacks >= 3) { uwa_emit_test_finished (); } } static void setup_window_active_environment(UnityWebappsContext *context) { // make sure that we have a proper window id unity_webapps_context_set_view_window(context, 1); unity_webapps_context_set_view_is_active(context, TRUE); uwa_emit_window_changed (1); } static void context_ready (UnityWebappsContext *context, gpointer user_data) { setup_window_active_environment(context); unity_webapps_music_player_init (context, "Test player"); unity_webapps_context_on_raise_callback (context, on_raise, NULL); unity_webapps_music_player_set_track (context, "Test", "Test", "Test", ICON_URL); unity_webapps_music_player_on_play_pause_callback (context, on_play_pause, NULL); unity_webapps_music_player_on_previous_callback (context, on_previous, NULL); unity_webapps_music_player_on_next_callback (context, on_next, NULL); printf ("Raise the test player, then activate all the sound controls for Test Player from the sound menu\n"); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestMusicPlayerCallback", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/interactive-playlist-callbacks.c0000644000015301777760000000257512321247333033077 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static gint count = 0; static void playlist_activated (UnityWebappsContext *context, const gchar *playlist_name, gpointer user_data) { count ++; printf("Playlist activated: %s \n", playlist_name); if (count == 3) { g_main_loop_quit (mainloop); } } static void context_ready (UnityWebappsContext *context, gpointer user_data) { const gchar *playlists[] = {"Playlist1", "Playlist2", "Playlist3", NULL}; unity_webapps_music_player_set_track (context, "Test artist", "Test album", "Playlist Test", ICON_URL); unity_webapps_music_player_set_playlists (context, playlists); unity_webapps_music_player_on_playlist_activated_callback (context, playlist_activated, NULL); printf("Activate on test music player \n"); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/data-uri.c0000644000015301777760000000641112321247333026505 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sKBw0vIqzujI4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAGhklEQVRo3t2bT0gbeRTHv/MnMRl3XAoNC81hipeOs0cTTyUFpbsbwZquWHpJKHRprYUKXiK4Pe2G6qXQlka3bEFiD7KSVldoKksKHXpK4nHH9FIa2AjdLJQ1NZpkMtmDras1ycykxiS+o87vl/nMe/N+3/fm9yOKxSJqZG0ATiupZKeSWhMKq5F2ACcAHAPQCkABsAngHcXxa2DaXtOCXQKwAuAlgPVa3BRxwMCckkoOyrFwn7zy3FF4E0cxk9Y1AcXxoIQu0B02kbb1LAGYB5BoKOBiJt2bf/HkSl5c7C8k4gfnDYYFbeuB0elepDj+AYCndQUuZtK9uVDAmwvNOvR6Uq/Rgh3G76+LtGCf/BzwaoG5XCgwkQ36L9YatBS46apvjrRYx6oJdd3AhUT88tb0+J1CIt6KOhnBsDA63RstA9dHADysGXBeXPBvTo9fQ4MYLdhhHr03RTDs8EEDt21Oj/+WFxe+RYMZabHCPHp3meL4C1qWMlXgYib91VZg4ve8uNCFBjWCYcHcnIlQHH8OwNvPAW7L/HzpD1mKNixsCeizlTxdEXhzevyZnjA2OFww2LpBCV0gGBYAoKSSkGNh5J49gpJKVhxH23p2J0cUpEjFcWWglymO/043cDZ4358N+jUlKIrjYRrygeL4itdlg/eRDfp1jStm0sgG/ciFAprf6dZbwbKJrCSwHAtfzty+8atWWObmzI5HNWR6bE6PVz1Oa/Zmfpz5odSStQ+4mElz72+c/bOYSbdqCaHWW0GQFquu9y0XCsBw5rxm2I+2NTup2dMmt3fD6PR8/ak4IUu8txNaYAHA6HTrht0e59ENCwAtA8Oax2WD/lYllZzYF/J7QlmK9sqx8EU9N37Ymdhw5rxWnY+t2cmLAHrLAuce3/fqUTnVeOmz1VVnt+Zr5VgYshT1lgSWpWivLEUdmhUO11EnZXVCX754fN+x28vkrn9c0RdeX9RNSuoxWYpCSSWv7AFWUklOlqL9uqqm1WhdgGVJ/+9mg/5+ANwOsBwLD+qdpPAmXhdgJbGq/yHFwgAwuAOcFxf7quh2fJzoUC337BGqvNc+ACAKf//V9n7km3/1ZGeDwwWqw17VGnxQYS2vPEf+xRPNTUKj0wOT2/slXViNnta6BppH74EW7A1R+NOCHS0Dw9gKTCAvLqi/glIEAE7ThcSrTo2CvC7rrqoThnw7WlulNQUAnaSSWBXUJjaP3m042D33N+TbU1pWgBZIJbXWrqZf1cq+RoFWc0pxI91OKqnkCbWivhnsY9O+snaInCCx/a2nbK1br0xcjRlsqjr7GAnAXPapNREsAIBpU4188iB1azMYie1Plgcm4xrcNkkA7xpNL9dQZ78jAaxV0qBaVEyjmJrOJi3WNZIW7K9VSqvmgA0FVPvXxHHra5I4bpUqhkkqqbk9Wi8rJOKaHEOd5CWS4k6tqF2opydcD9jMT5dUqyaCYUEw7ApNCV0vtUycFxdQWI3C5PZq0q01T1CpJLJBv+YcQwldAPCSpjh+nWBYsZhJO7T8SOb2DRAMC+okD6rDXgfQNSiJOPTuJTHYukUA6zQA0Laepby4oLljWcykt4twKYpmMarDvrTT4jHYuudxhI0W7CAt1vkdYNrWkyAt1sWjCmxwuBbx4RsT+f8f+x8cRViCYWFwuB7s1tIAAKPT85RgWPGoARudbhG79nWRu5+E0emePGreNTo9k59WS9jtZdJinTsqwCbP2BzBsE/LAhMMC5PbOwZg4whk5g2DwzVWqh7ee6GtJ2FwuEaaPZRNV30jKLE1kSwTCg8pjp9qVmDzkG+KtFgflut4lH5CQ75hgmGXmy8re5ZpW89wpRZPaSm2vcvmAsGwkSYSGBGT23uhYhOgov7k+HXm5sy5ZoA2OFwR85DvHFT2W5Kqopvj3zI3Z842cngbHK5l85DvLFT2WQI6tg8XEnFsTY/7C4n4tUaCNbm9U0an58C3D++Uhdmg/3IuFLiD7ZMpdTPSYt0wj94doTi+dhvEP5osRbmtX8YnlFTyYj1gjU7PXMvA8BjBsLU/ArDb27lQoDcXmvVq6ZYckHoSW9xjkxTHH/ohj33geXHxipJK9tcoKS0aHK4HtGCv7zGefaEeC3P52PNBORbu+1yv04JdpDu7lwxnzs9XE7qHAvxJVm8rSJHThcSrzuI/SUFJrbV/+Ba97ygeLdjXwLS9prhTEsXxK5TQ9ZJg2JocxfsPlPjVREHRwK4AAAAASUVORK5CYII=" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_music_player_init (context, "Test data URI player"); unity_webapps_music_player_set_track (context, "Test artist", "test album", "test track", ICON_URL); printf("Set Data URI Track \n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestDataURI", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/data-uri.trace0000644000015301777760000000030012321247333027350 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling set track Looking up URI Cache hit <[Client]> Setting track: test track libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/set-track.c0000644000015301777760000000171612321247333026677 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_music_player_init (context, "Test player"); unity_webapps_music_player_set_track (context, "Test artist", "Test album", "Test title", ICON_URL); printf("Set track metadata on test music player \n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/set-playlists.c0000644000015301777760000000175412321247333027621 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { const gchar *playlists[] = {"Playlist1", "Playlist2", "Playlist3", NULL}; unity_webapps_music_player_set_track (context, "Test artist", "Test album", "Playlist Test", ICON_URL); unity_webapps_music_player_set_playlists (context, playlists); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/properties.c0000644000015301777760000000375212321247333027200 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_music_player_init (context, "Test player"); unity_webapps_music_player_set_can_go_next (context, TRUE); g_assert (unity_webapps_music_player_get_can_go_next (context) == TRUE); unity_webapps_music_player_set_can_go_next (context, FALSE); g_assert (unity_webapps_music_player_get_can_go_next (context) == FALSE); unity_webapps_music_player_set_can_go_previous (context, TRUE); g_assert (unity_webapps_music_player_get_can_go_previous (context) == TRUE); unity_webapps_music_player_set_can_go_previous (context, FALSE); g_assert (unity_webapps_music_player_get_can_go_previous (context) == FALSE); unity_webapps_music_player_set_can_play (context, TRUE); g_assert (unity_webapps_music_player_get_can_play (context) == TRUE); unity_webapps_music_player_set_can_play (context, FALSE); g_assert (unity_webapps_music_player_get_can_play (context) == FALSE); unity_webapps_music_player_set_can_pause (context, TRUE); g_assert (unity_webapps_music_player_get_can_pause (context) == TRUE); unity_webapps_music_player_set_can_pause (context, FALSE); g_assert (unity_webapps_music_player_get_can_pause (context) == FALSE); unity_webapps_music_player_set_playback_state (context, 0); printf("Verified music player properties \n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/set-track.trace0000644000015301777760000000023312321247333027544 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling set track <[Client]> Setting track libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/properties.trace0000644000015301777760000000022012321247333030037 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/music-player/callbacks.trace0000644000015301777760000000074412321247333027575 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling set track Cache hit <|music-action-invoker TestMusicPlayerCallback previous|> Emitting signal Previous<|music-action-invoker TestMusicPlayerCallback playpause|> Emitting signal PlayPause<|music-action-invoker TestMusicPlayerCallback next|> Emitting signal Next<|music-action-invoker TestMusicPlayerCallback|> Emitting Raise signal <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-template.c0000644000015301777760000000131112321247333025147 0ustar pbusernogroup00000000000000#include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context) { g_main_loop_quit (mainloop); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; UnityWebappsContext *context; g_thread_init (NULL); g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, context_ready); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/run-test.sh0000755000015301777760000000115112321247333024335 0ustar pbusernogroup00000000000000#!/bin/bash set -e if [ -z $UNITY_WEBAPPS_DAEMON_EXEC_DIR ]; then export UNITY_WEBAPPS_DAEMON_EXEC_DIR="`pwd`/../../src/context-daemon/" fi if [ -d test-output-files ]; then rm -fR test-output-files fi mkdir test-output-files export UNITY_WEBAPPS_CONTEXT_USER_DIR="test-output-files" export UNITY_WEBAPPS_CONTEXT_ICON_DIR="test-output-files" export UNITY_WEBAPPS_CONTEXT_ICON_THEME_DIR="test-output-files" export UNITY_WEBAPPS_CONTEXT_ICON_APPLICATION_DIR="test-output-files" export UNITY_WEBAPPS_CONTEXT_ICON_RESOURCE_DIR="test-output-files" test-runner/test-runner -n $1 $2 $3 rm -fR test-output-files libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/0000755000015301777760000000000012321250157024016 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/interactive-action-callbacks.c0000644000015301777760000000222112321247333031666 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; int count = 0; static void action_callback (UnityWebappsContext *context, gpointer user_data) { printf("Action callback \n"); count++; if (count == 2) { uwa_emit_test_finished (); } } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_launcher_add_action (context, "Test Action 1", action_callback, NULL); unity_webapps_launcher_add_action (context, "Test Action 2", action_callback, NULL); printf("Activate Test Action 1 and 2 from the test launcher entry\n"); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/remove-actions.trace0000644000015301777760000000045112321247333027773 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddAction.*Test Action 1 Handling AddAction.*Test Action 2 Handling RemoveAction Handling RemoveActions <[Client]> Adding action Adding action Removing action Removing all actions libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/quit-application-interactive.c0000644000015301777760000000175512321247333031772 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; int count = 0; static void close_callback (UnityWebappsContext *context, gpointer user_data) { printf("Close callback \n"); uwa_emit_test_finished (); } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_context_on_close_callback (context, close_callback, NULL); printf("Quit the application from the test launcher icon\n"); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/remove-actions.c0000644000015301777760000000213512321247333027120 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void fake_callback (UnityWebappsContext *context, gpointer user_data) { return; } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_launcher_add_action (context, "Test Action 1", fake_callback, NULL); unity_webapps_launcher_add_action (context, "Test Action 2", fake_callback, NULL); unity_webapps_launcher_remove_action (context, "Test Action 1"); unity_webapps_launcher_remove_actions (context); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/add-actions.trace0000644000015301777760000000032712321247333027230 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddAction.*Test Action 1 Handling AddAction.*Test Action 2 <[Client]> Adding action Adding action libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/set-urgent.trace0000644000015301777760000000023712321247333027137 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling SetUrgent call <[Client]> Setting urgent libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/Makefile.am0000644000015301777760000000511012321247333026051 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/tests/traced/common noinst_PROGRAMS = \ set-count clear-count set-progress clear-progress set-urgent\ add-actions interactive-action-callbacks remove-actions\ quit-application-interactive add-static-action add_static_action_SOURCES = \ add-static-action.c \ ../common/uwa-test-client.c add_static_action_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la set_count_SOURCES = \ set-count.c \ ../common/uwa-test-client.c set_count_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la set_urgent_SOURCES = \ set-urgent.c \ ../common/uwa-test-client.c set_urgent_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la clear_count_SOURCES = \ clear-count.c \ ../common/uwa-test-client.c clear_count_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la set_progress_SOURCES = \ set-progress.c \ ../common/uwa-test-client.c set_progress_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la clear_progress_SOURCES = \ clear-progress.c \ ../common/uwa-test-client.c clear_progress_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la add_actions_SOURCES = \ add-actions.c \ ../common/uwa-test-client.c add_actions_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la interactive_action_callbacks_SOURCES = \ interactive-action-callbacks.c \ ../common/uwa-test-client.c interactive_action_callbacks_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la quit_application_interactive_SOURCES = \ quit-application-interactive.c \ ../common/uwa-test-client.c quit_application_interactive_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la remove_actions_SOURCES = \ remove-actions.c \ ../common/uwa-test-client.c remove_actions_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/interactive-action-callbacks.trace0000644000015301777760000000063212321247333032546 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddAction.*Test Action 1 Handling AddAction.*Test Action 2 Got item-activated Emitting ActionInvoked.*Action 1 Got item-activated Emitting ActionInvoked.*Action 2 <[Client]> Adding action Adding action action succesfully action succesfully Quicklist action invoked Quicklist action invoked libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/add-static-action.trace0000644000015301777760000000030212321247333030323 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling RemoveStaticActions Handling AddStaticAction <[Client]> Adding static action libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/set-count.trace0000644000015301777760000000022712321247333026762 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling SetCount <[Client]> Setting count libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/set-progress.trace0000644000015301777760000000023612321247333027476 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling SetProgress <[Client]> Setting progress libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/add-actions.c0000644000015301777760000000201612321247333026351 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void fake_callback (UnityWebappsContext *context, gpointer user_data) { return; } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_launcher_add_action (context, "Test Action 1", fake_callback, NULL); unity_webapps_launcher_add_action (context, "Test Action 2", fake_callback, NULL); printf("Added launcher actions \n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/clear-count.trace0000644000015301777760000000027312321247333027256 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling SetCount Handling ClearCount <[Client]> Setting count Clearing count libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/set-progress.c0000644000015301777760000000142712321247333026625 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_launcher_set_progress (context, 0.3); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/quit-application-interactive.trace0000644000015301777760000000026412321247333032640 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Emitting Raise signal to interest: 1 <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/set-count.c0000644000015301777760000000142512321247333026107 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_launcher_set_count (context, 10); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/set-urgent.c0000644000015301777760000000142012321247333026256 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_launcher_set_urgent (context); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/add-static-action.c0000644000015301777760000000160012321247333027451 0ustar pbusernogroup00000000000000#include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "unity-webapps-launcher-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer data) { unity_webapps_launcher_remove_static_actions (context); unity_webapps_launcher_add_static_action (context, "label1", "page"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_thread_init (NULL); g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/clear-progress.trace0000644000015301777760000000030612321247333027767 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling SetProgress Handling ClearProgress <[Client]> Setting progress Clearing progress libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/clear-progress.c0000644000015301777760000000151412321247333027115 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_launcher_set_progress (context, 0.3); unity_webapps_launcher_clear_progress (context); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/launcher/clear-count.c0000644000015301777760000000150612321247333026402 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_launcher_set_count (context, 10); unity_webapps_launcher_clear_count (context); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/0000755000015301777760000000000012321250157024171 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/unicode.c0000644000015301777760000000147412321247333025773 0ustar pbusernogroup00000000000000#include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "圍棋"); g_printf("Showed simple indicator"); g_main_loop_quit (mainloop); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; UnityWebappsContext *context; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/set-property-icon.trace0000644000015301777760000000034612321247333030621 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator call Handling SetProperty call Looking up URI <[Client]> Created context proxy Showed indicator libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/add-actions.trace0000644000015301777760000000046612321247333027407 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddAction call Interest id 1 is interested in action Action 1 Handling AddAction call Interest id 1 is interested in action Action 2 <[Client]> Added action: Action 1 Added action: Action 2 libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/Makefile.am0000644000015301777760000001002512321247333026225 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/tests/traced/common noinst_PROGRAMS = \ simple-show \ indicator-clear \ indicator-clears \ set-property \ set-property-icon \ set-property-icon-invalid \ multiple-servers \ set-property-time \ add-actions \ actions-callback \ indicator-callback \ raise-callback \ themed-icon \ data-uri \ presence \ interactive-presence-changed simple_show_SOURCES = \ simple-show.c \ ../common/uwa-test-client.c simple_show_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la data_uri_SOURCES = \ data-uri.c \ ../common/uwa-test-client.c data_uri_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la presence_SOURCES = \ presence.c \ ../common/uwa-test-client.c presence_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la interactive_presence_changed_SOURCES = \ interactive-presence-changed.c \ ../common/uwa-test-client.c interactive_presence_changed_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la indicator_clear_SOURCES = \ indicator-clear.c \ ../common/uwa-test-client.c indicator_clear_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la indicator_clears_SOURCES = \ indicator-clears.c \ ../common/uwa-test-client.c indicator_clears_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la set_property_SOURCES = \ set-property.c \ ../common/uwa-test-client.c set_property_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la set_property_icon_SOURCES = \ set-property-icon.c \ ../common/uwa-test-client.c set_property_icon_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la set_property_icon_invalid_SOURCES = \ set-property-icon-invalid.c \ ../common/uwa-test-client.c set_property_icon_invalid_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la multiple_servers_SOURCES = \ multiple-servers.c \ ../common/uwa-test-client.c multiple_servers_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la set_property_time_SOURCES = \ set-property-time.c \ ../common/uwa-test-client.c set_property_time_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la add_actions_SOURCES = \ add-actions.c \ ../common/uwa-test-client.c add_actions_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la actions_callback_SOURCES = \ actions-callback.c \ ../common/uwa-test-client.c actions_callback_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la indicator_callback_SOURCES = \ indicator-callback.c \ ../common/uwa-test-client.c indicator_callback_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la raise_callback_SOURCES = \ raise-callback.c \ ../common/uwa-test-client.c raise_callback_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la themed_icon_SOURCES = \ themed-icon.c \ ../common/uwa-test-client.c themed_icon_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/simple-show.c0000644000015301777760000000146012321247333026607 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Simple Indicator Test"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/actions-callback.c0000644000015301777760000000227212321247333027534 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; guint count = 0; static void on_action_callback (UnityWebappsContext *context, gpointer user_data) { printf("Callback! \n"); count ++; if (count == 2) { uwa_emit_test_finished (); } } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_add_action (context, "Callback Action 1", on_action_callback, NULL); unity_webapps_indicator_add_action (context, "Callback Action 2", on_action_callback, NULL); printf("Activate Callback Action 1 and 2 from your messaging indicator\n"); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/set-property.c0000644000015301777760000000162412321247333027017 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Indicator Property Test"); unity_webapps_indicator_set_property (context, "Indicator Property Test", "count", "3"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/indicator-callback.c0000644000015301777760000000241312321247333030045 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void on_indicator_callback (UnityWebappsContext *context, gpointer user_data) { printf("Callback! \n"); uwa_emit_test_finished (); } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Callback test"); unity_webapps_indicator_set_callback (context, "Callback test", on_indicator_callback, NULL); printf("Activate the Callback test indicator from your messaging menu \n"); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestIndicatorCallback", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/indicator-clear.c0000644000015301777760000000163612321247333027405 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" #include "uwa-test-client.h" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Indicator Clear Test"); unity_webapps_indicator_clear_indicator (context, "Indicator Clear Test"); printf("Cleared indicator\n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/set-property-icon-invalid.trace0000644000015301777760000000064112321247333032243 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator call Handling SetProperty call Resource cache returned NULL Handling ShowIndicator Handling SetProperty Resource cache returned NULL <[Client]> Created context proxy Showed indicator Setting icon property Showed indicator Setting icon property Showed indicator Setting icon property libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/set-property-icon-invalid.c0000644000015301777760000000247512321247333031376 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" #include "uwa-test-client.h" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Invalid file"); unity_webapps_indicator_set_property_icon(context, "Invalid file", "icon", "http://www.ubuntu.com/not-an-image.not-a-file-format"); unity_webapps_indicator_show_indicator (context, "Invalid image"); unity_webapps_indicator_set_property_icon (context, "Invalid image", "icon", "http://www.google.com/index.html"); unity_webapps_indicator_show_indicator (context, "Invalid URL"); unity_webapps_indicator_set_property_icon (context, "Invalid URL", "icon", "0jasf oaisfhaosi bacon"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/raise-callback.c0000644000015301777760000000245212321247333027177 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void on_raise_callback (UnityWebappsContext *context, const gchar *file, gpointer user_data) { printf("Callback! \n"); uwa_emit_test_finished (); } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Raise callback test"); unity_webapps_context_on_raise_callback (context, on_raise_callback, NULL); printf("Activate the Callback test application (not the indicator) from your messaging menu \n"); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestIndicatorRaiseCallback", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/presence.c0000644000015301777760000000146112321247333026145 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" #include "uwa-test-client.h" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { printf("Got presence: %s\n", unity_webapps_indicator_get_presence (context)); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/multiple-servers.c0000644000015301777760000000200612321247333027657 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; guint count = 2; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Multiple servers test"); count--; if (count == 0) { printf("Showed on multiple servers"); uwa_emit_test_finished (); } } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); unity_webapps_context_new (service, "Test2", "test2.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/set-property-time.c0000644000015301777760000000176012321247333027754 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { GTimeVal current_time; g_get_current_time (¤t_time); unity_webapps_indicator_show_indicator (context, "Indicator Time Test"); unity_webapps_indicator_set_property (context, "Indicator Time Test", "time", g_time_val_to_iso8601 (¤t_time)); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/data-uri.c0000644000015301777760000000671412321247333026055 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sKBw0vIqzujI4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAGhklEQVRo3t2bT0gbeRTHv/MnMRl3XAoNC81hipeOs0cTTyUFpbsbwZquWHpJKHRprYUKXiK4Pe2G6qXQlka3bEFiD7KSVldoKksKHXpK4nHH9FIa2AjdLJQ1NZpkMtmDras1ycykxiS+o87vl/nMe/N+3/fm9yOKxSJqZG0ATiupZKeSWhMKq5F2ACcAHAPQCkABsAngHcXxa2DaXtOCXQKwAuAlgPVa3BRxwMCckkoOyrFwn7zy3FF4E0cxk9Y1AcXxoIQu0B02kbb1LAGYB5BoKOBiJt2bf/HkSl5c7C8k4gfnDYYFbeuB0elepDj+AYCndQUuZtK9uVDAmwvNOvR6Uq/Rgh3G76+LtGCf/BzwaoG5XCgwkQ36L9YatBS46apvjrRYx6oJdd3AhUT88tb0+J1CIt6KOhnBsDA63RstA9dHADysGXBeXPBvTo9fQ4MYLdhhHr03RTDs8EEDt21Oj/+WFxe+RYMZabHCPHp3meL4C1qWMlXgYib91VZg4ve8uNCFBjWCYcHcnIlQHH8OwNvPAW7L/HzpD1mKNixsCeizlTxdEXhzevyZnjA2OFww2LpBCV0gGBYAoKSSkGNh5J49gpJKVhxH23p2J0cUpEjFcWWglymO/043cDZ4358N+jUlKIrjYRrygeL4itdlg/eRDfp1jStm0sgG/ciFAprf6dZbwbKJrCSwHAtfzty+8atWWObmzI5HNWR6bE6PVz1Oa/Zmfpz5odSStQ+4mElz72+c/bOYSbdqCaHWW0GQFquu9y0XCsBw5rxm2I+2NTup2dMmt3fD6PR8/ak4IUu8txNaYAHA6HTrht0e59ENCwAtA8Oax2WD/lYllZzYF/J7QlmK9sqx8EU9N37Ymdhw5rxWnY+t2cmLAHrLAuce3/fqUTnVeOmz1VVnt+Zr5VgYshT1lgSWpWivLEUdmhUO11EnZXVCX754fN+x28vkrn9c0RdeX9RNSuoxWYpCSSWv7AFWUklOlqL9uqqm1WhdgGVJ/+9mg/5+ANwOsBwLD+qdpPAmXhdgJbGq/yHFwgAwuAOcFxf7quh2fJzoUC337BGqvNc+ACAKf//V9n7km3/1ZGeDwwWqw17VGnxQYS2vPEf+xRPNTUKj0wOT2/slXViNnta6BppH74EW7A1R+NOCHS0Dw9gKTCAvLqi/glIEAE7ThcSrTo2CvC7rrqoThnw7WlulNQUAnaSSWBXUJjaP3m042D33N+TbU1pWgBZIJbXWrqZf1cq+RoFWc0pxI91OKqnkCbWivhnsY9O+snaInCCx/a2nbK1br0xcjRlsqjr7GAnAXPapNREsAIBpU4188iB1azMYie1Plgcm4xrcNkkA7xpNL9dQZ78jAaxV0qBaVEyjmJrOJi3WNZIW7K9VSqvmgA0FVPvXxHHra5I4bpUqhkkqqbk9Wi8rJOKaHEOd5CWS4k6tqF2opydcD9jMT5dUqyaCYUEw7ApNCV0vtUycFxdQWI3C5PZq0q01T1CpJLJBv+YcQwldAPCSpjh+nWBYsZhJO7T8SOb2DRAMC+okD6rDXgfQNSiJOPTuJTHYukUA6zQA0Laepby4oLljWcykt4twKYpmMarDvrTT4jHYuudxhI0W7CAt1vkdYNrWkyAt1sWjCmxwuBbx4RsT+f8f+x8cRViCYWFwuB7s1tIAAKPT85RgWPGoARudbhG79nWRu5+E0emePGreNTo9k59WS9jtZdJinTsqwCbP2BzBsE/LAhMMC5PbOwZg4whk5g2DwzVWqh7ee6GtJ2FwuEaaPZRNV30jKLE1kSwTCg8pjp9qVmDzkG+KtFgflut4lH5CQ75hgmGXmy8re5ZpW89wpRZPaSm2vcvmAsGwkSYSGBGT23uhYhOgov7k+HXm5sy5ZoA2OFwR85DvHFT2W5Kqopvj3zI3Z842cngbHK5l85DvLFT2WQI6tg8XEnFsTY/7C4n4tUaCNbm9U0an58C3D++Uhdmg/3IuFLiD7ZMpdTPSYt0wj94doTi+dhvEP5osRbmtX8YnlFTyYj1gjU7PXMvA8BjBsLU/ArDb27lQoDcXmvVq6ZYckHoSW9xjkxTHH/ohj33geXHxipJK9tcoKS0aHK4HtGCv7zGefaEeC3P52PNBORbu+1yv04JdpDu7lwxnzs9XE7qHAvxJVm8rSJHThcSrzuI/SUFJrbV/+Ba97ygeLdjXwLS9prhTEsXxK5TQ9ZJg2JocxfsPlPjVREHRwK4AAAAASUVORK5CYII=" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Indicator Data URI Test"); unity_webapps_indicator_set_property_icon(context, "Indicator Data URI Test", "icon", ICON_URL); unity_webapps_indicator_show_indicator(context, "Indicator Invalid Data URI Test"); unity_webapps_indicator_set_property_icon(context, "Indicator Invalid Data URI Test", "icon", "data:NOt a data url really? Is it?"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestDataURI", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/data-uri.trace0000644000015301777760000000051512321247333026722 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator Handling SetProperty Handling ShowIndicator Cache miss Making file from data URI Resource cache returned NULL <[Client]> Showed indicator Setting icon property Showed indicator Setting icon property libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/presence.trace0000644000015301777760000000022012321247333027011 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/add-actions.c0000644000015301777760000000200712321247333026524 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void fake_callback (UnityWebappsContext *context, gpointer user_data) { return; } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_add_action (context, "Action 1", fake_callback, NULL); unity_webapps_indicator_add_action (context, "Action 2", fake_callback, NULL); printf("Added indicator actions\n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/multiple-servers.trace0000644000015301777760000000034612321247333030540 0ustar pbusernogroup00000000000000<[Service]> Handling GetContext Spawning context Handling GetContext Spawning context <[Context]> Added interest 1 Handling ShowIndicator Handling ShowIndicator <[Client]> Showed indicator libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/simple-show.trace0000644000015301777760000000024212321247333027460 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator <[Client]> Showed indicator libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/indicator-clear.trace0000644000015301777760000000031412321247333030251 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator Handling ClearIndicator <[Client]> Showed indicator Cleared indicator libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/themed-icon.trace0000644000015301777760000000035312321247333027410 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator Handling SetProperty Looking up URI themed resource <[Client]> Showed indicator Setting icon property libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/themed-icon.c0000644000015301777760000000226612321247333026541 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Indicator Themed Icon Test"); unity_webapps_indicator_set_property_icon(context, "Indicator Themed Icon Test", "icon", "icon://user-trash"); unity_webapps_indicator_show_indicator (context, "Indicator Invalid Themed Icon Test"); unity_webapps_indicator_set_property_icon (context, "Indicator Invalid Themed Icon Test", "icon", "icon://Whatwhat"); printf("Set indicator property"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/actions-callback.trace-disabled0000644000015301777760000000106612321247333032155 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddAction Handling AddAction Handling Menuitem activated Emitting Raise signal Emitting ActionInvoked Handling Menuitem activated Emitting Raise signal Emitting ActionInvoked <[Client]> Created context proxy Added action Added action Received response.*Action succes<|indicator-action-invoker Test 'Callback Action 1'|> Received response.*Action succes<|indicator-action-invoker Test 'Callback Action 2'|> Menu action invoked Menu action invoked libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/set-property-time.trace0000644000015301777760000000037312321247333030627 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator call Handling SetProperty call <[Client]> Created context proxy Showed indicator Setting property of indicator.*time libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/interactive-presence-changed.c0000644000015301777760000000222612321247333032047 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static UnityWebappsContext *global_context = NULL; static void presence_changed (UnityWebappsContext *context, gpointer user_data) { printf("Presence changed: %s \n", unity_webapps_indicator_get_presence (global_context)); uwa_emit_test_finished (); } static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_on_presence_changed_callback (context, presence_changed, NULL); global_context = context; printf("Read presence: %s \n", unity_webapps_indicator_get_presence (global_context)); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/indicator-callback.trace0000644000015301777760000000045012321247333030720 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest Handling ShowIndicator Emitting Raise signal Emitting ActionInvoked <[Client]> Showed indicator<|indicator-action-invoker TestIndicatorCallback 'Callback test'|> Indicator action invoked libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/set-property-icon.c0000644000015301777760000000164012321247333027743 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Indicator Property Test"); unity_webapps_indicator_set_property_icon(context, "Indicator Property Test", "icon", ICON_URL); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/interactive-presence-changed.trace0000644000015301777760000000047712321247333032731 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Most available presence changed to (?[a-zA-Z]+) Added interest 1<|change-presence Away|> Most available presence changed<|change-presence ${PRESENCE}|> <[Client]> Created context proxy Presence changed notification libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/raise-callback.trace0000644000015301777760000000035512321247333030053 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest Handling ShowIndicator<|indicator-action-invoker TestIndicatorRaiseCallback|> Emitting Raise signal <[Client]> Showed indicator libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/set-property.trace0000644000015301777760000000037612321247333027676 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator call Handling SetProperty call <[Client]> Created context proxy Showed indicator Setting property of indicator.*(count) libunity-webapps-2.5.0~+14.04.20140409/tests/traced/indicator/indicator-clears.c0000644000015301777760000000170412321247333027564 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" #include "uwa-test-client.h" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Indicator Clear Test"); unity_webapps_indicator_show_indicator (context, "Indicator Clear Test2"); unity_webapps_indicator_clear_indicators (context); printf("Cleared indicator\n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/fuzz/0000755000015301777760000000000012321250157023213 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/fuzz/Makefile.am0000644000015301777760000000071512321247333025254 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/tests/traced/common noinst_PROGRAMS = \ thousand-indicators thousand_indicators_SOURCES = \ thousand-indicators.c \ ../common/uwa-test-client.c thousand_indicators_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/fuzz/thousand-indicators.trace0000644000015301777760000000055712321247333030226 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling ShowIndicator Handling ClearIndicator Handling AddAction Handling AddAction Handling AddAction Handling AddAction Handling AddAction <[Client]> Showed indicator Cleared indicator Added action Showed indicator.*10 Indicator rate limit check failed libunity-webapps-2.5.0~+14.04.20140409/tests/traced/fuzz/thousand-indicators.c0000644000015301777760000000222512321247333027344 0ustar pbusernogroup00000000000000#include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; #include "uwa-test-client.h" static void fake_callback (UnityWebappsContext *context, gpointer user_data) { return; } static void context_ready (UnityWebappsContext *context, gpointer user_data) { int i; for (i = 0; i < 1000; i++) { gchar *name; name = g_strdup_printf("Thousand indicators %d", i); unity_webapps_indicator_show_indicator (context, name); unity_webapps_indicator_clear_indicator (context, name); unity_webapps_indicator_add_action (context, name, fake_callback, NULL); g_free (name); } uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/run-all-tests.sh0000755000015301777760000000045112321247333025270 0ustar pbusernogroup00000000000000#!/bin/bash set -e if [ -z $UNITY_WEBAPPS_DAEMON_EXEC_DIR ]; then export UNITY_WEBAPPS_DAEMON_EXEC_DIR="`pwd`/../../src/context-daemon/" fi for test in $(ls */*.trace | grep -v interactive) do echo `echo $test | sed 's/\.trace//'` ./run-test.sh `echo $test | sed 's/\.trace//'` done libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/0000755000015301777760000000000012321250157023655 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/remove-actions.trace0000644000015301777760000000050512321247333027632 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddApplicationActions Handling RemoveApplicationAction Handling RemoveApplicationAction <[Client]> Adding application action Adding application action Removing application action Removing application action libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/multiple-interest.trace0000644000015301777760000000077012321247333030371 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddApplicationActions call Interest id 1 is interested.*Action 2 Referenced action.*Action 1.*count is 2 Interest id 2 is interested in action.*Action 1 Unreferenced action.*Action 1.*count is 1 Emitting InterestVanished Interest id 1 is no longer interested in action /Action 2 Unreferenced action.*Action 2.*count is 0 <[Client]> Adding application action Adding application action libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/remove-actions.c0000644000015301777760000000225312321247333026760 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void fake_callback (UnityWebappsContext *context, gpointer user_data) { } static void context_ready (UnityWebappsContext *context, gpointer user_data) { UnityWebappsApplicationActionDesc arg[] = {{"/Action 1", fake_callback, NULL}, {"/Action 2", fake_callback, NULL}}; unity_webapps_context_add_application_actions (context, arg, 2); unity_webapps_context_remove_application_action (context, "/Action 1"); unity_webapps_context_remove_application_action (context, "/Action 2"); uwa_emit_test_finished(); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/Makefile.am0000644000015301777760000000216612321247333025720 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/tests/traced/common \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) noinst_PROGRAMS = \ simple-actions hierarchy remove-actions multiple-interest simple_actions_SOURCES = \ simple-actions.c \ ../common/uwa-test-client.c simple_actions_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la hierarchy_SOURCES = \ hierarchy.c \ ../common/uwa-test-client.c hierarchy_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la remove_actions_SOURCES = \ remove-actions.c \ ../common/uwa-test-client.c remove_actions_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la multiple_interest_SOURCES = \ multiple-interest.c \ ../common/uwa-test-client.c multiple_interest_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/hierarchy.c0000644000015301777760000000334212321247333026003 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static guint callbacks = 0; static void on_action_one(UnityWebappsContext *context, gpointer user_data) { callbacks ++; printf("Action one invoked\n"); } static void on_action_two (UnityWebappsContext *context, gpointer user_data) { callbacks ++; printf("Action two invoked\n"); } static void on_action_three(UnityWebappsContext *context, gpointer user_data) { callbacks ++; printf("Action three invoked\n"); } static void on_action_four (UnityWebappsContext *context, gpointer user_data) { callbacks ++; printf("Action four invoked\n"); if (callbacks == 4) { uwa_emit_test_finished (); } } static void context_ready (UnityWebappsContext *context, gpointer user_data) { UnityWebappsApplicationActionDesc arg[] = {{"/foo/bar/baz", on_action_one, NULL}, {"/foo/bar/doublebar", on_action_two, NULL}, {"/foo/baz/bar", on_action_three, NULL}, {"/foot/boo/yaz", on_action_four, NULL}}; unity_webapps_context_add_application_actions (context, arg, 4); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/interactive-hierarchy.trace0000644000015301777760000000126412321247333031173 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddApplicationActions call.*<|action-invoker Test test.ts '/foo/bar/baz'|> Emitting ApplicationActionInvoked<|action-invoker Test test.ts '/foo/bar/doublebar'|> Emitting ApplicationActionInvoked<|action-invoker Test test.ts '/foo/baz/bar'|> Emitting ApplicationActionInvoked<|action-invoker Test test.ts '/foot/boo/yaz'|> <[Client]> Adding application action Adding application action Adding application action Adding application action Action invoked: \/foo\/bar\/baz Action invoked: \/foo\/bar\/doublebar Action invoked: \/foo\/baz\/bar Action invoked: \/foot\/boo\/yaz libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/multiple-interest.c0000644000015301777760000000277712321247333027526 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static UnityWebappsContext *context_one = NULL; static UnityWebappsService *service = NULL; static void callback () { } static void context_two_ready (UnityWebappsContext *context, gpointer user_data) { UnityWebappsApplicationActionDesc arg[] = {{"/Action 1", callback, NULL}}; unity_webapps_context_add_application_actions (context, arg, 1); unity_webapps_context_remove_application_action (context_one, "/Action 1"); unity_webapps_context_destroy (context_one, FALSE); uwa_emit_test_finished (); } static void context_ready (UnityWebappsContext *context, gpointer user_data) { UnityWebappsApplicationActionDesc arg[] = {{"/Action 1", callback, NULL}, {"/Action 2", callback, NULL}}; context_one = context; unity_webapps_context_add_application_actions (context, arg, 2); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_two_ready, NULL); } gint main (gint argc, gchar **argv) { g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/simple-actions.c0000644000015301777760000000247212321247333026757 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static guint callbacks = 0; static void on_action_one(UnityWebappsContext *context, gpointer user_data) { printf("Got action 1 with: %s\n", (gchar*) user_data); callbacks ++; } static void on_action_two (UnityWebappsContext *context, gpointer user_data) { callbacks ++; printf("Got action 2 with: %s\n", (gchar*) user_data); if (callbacks == 2) { uwa_emit_test_finished (); } } static void context_ready (UnityWebappsContext *context, gpointer user_data) { UnityWebappsApplicationActionDesc desc[] = { {"/Action 1", on_action_one, "user data one"}, {"/Action 2", on_action_two, "user data two"} }; unity_webapps_context_add_application_actions (context, desc, 2); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/actions/interactive-simple-actions.trace0000644000015301777760000000063512321247333032145 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddApplicationAction call.*Action 1 Handling AddApplicationAction call.*Action 2 Emitting ApplicationActionInvoked <[Client]> Adding application action Adding application action action succes<|action-invoker Test test.ts '/Action 1'|> Action invoked<|action-invoker Test test.ts '/Action 2'|> libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/0000755000015301777760000000000012321250157023150 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/user-abandoned.trace0000644000015301777760000000026312321247333027062 0ustar pbusernogroup00000000000000<[Service]> User abandoned the lonely daemon <[Context]> Emitting ContextReady <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/context-properties.c0000644000015301777760000000202512321247333027173 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { g_assert (g_strcmp0("test.ts", unity_webapps_context_get_domain(context)) == 0); g_assert (g_strcmp0("Test", unity_webapps_context_get_name(context)) == 0); g_assert (g_strcmp0("Testtestts.desktop", unity_webapps_context_get_desktop_name(context)) == 0); printf("Verified context properties \n"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/Makefile.am0000644000015301777760000000556112321247333025215 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/tests/traced/common noinst_PROGRAMS = \ context-properties \ create-2 \ create-2-same \ simple-create \ invalid-icon-url \ invalid-data-url \ oversized-icon \ add-icon \ user-abandoned \ destroy-interest-for-context \ abandon-before-context-ready add_icon_SOURCES = \ add-icon.c \ ../common/uwa-test-client.c add_icon_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la abandon_before_context_ready_SOURCES = \ abandon-before-context-ready.c \ ../common/uwa-test-client.c abandon_before_context_ready_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la oversized_icon_SOURCES = \ oversized-icon.c \ ../common/uwa-test-client.c oversized_icon_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la invalid_data_url_SOURCES = \ invalid-data-url.c \ ../common/uwa-test-client.c invalid_data_url_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la invalid_icon_url_SOURCES = \ invalid-icon-url.c \ ../common/uwa-test-client.c invalid_icon_url_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la context_properties_SOURCES = \ context-properties.c \ ../common/uwa-test-client.c context_properties_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la create_2_same_SOURCES = \ create-2-same.c \ ../common/uwa-test-client.c create_2_same_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la create_2_SOURCES = \ create-2.c \ ../common/uwa-test-client.c create_2_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la simple_create_SOURCES = \ simple-create.c \ ../common/uwa-test-client.c simple_create_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la user_abandoned_SOURCES = \ user-abandoned.c \ ../common/uwa-test-client.c user_abandoned_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la destroy_interest_for_context_SOURCES = \ destroy-interest-for-context.c \ ../common/uwa-test-client.c destroy_interest_for_context_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/user-abandoned.c0000644000015301777760000000143212321247333026205 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static UnityWebappsService *service = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_context_destroy (context, TRUE); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/oversized-icon.c0000644000015301777760000000176112321247333026263 0ustar pbusernogroup00000000000000#include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" #define OVERSIZED_ICON_URL "http://earthobservatory.nasa.gov/Features/BlueMarble/Images/BlueMarble_2005_SAm_09_4096.jpg" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_notification_show_notification (context, "Oversized Image Test", "A test notification with an image too big to download", OVERSIZED_ICON_URL); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/create-2.trace0000644000015301777760000000050612321247333025575 0ustar pbusernogroup00000000000000<[Service]> Handling GetContext Spawning context Handling GetContext Spawning context Handling ContextReady Emitting ContextAppeared Handling ContextReady Emitting ContextAppeared <[Context]> Added interest 1 Added interest 1 <[Client]> Created context proxy Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/create-2.c0000644000015301777760000000167212321247333024726 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; guint count = 2; static void context_ready (UnityWebappsContext *context, gpointer user_data) { count--; if (count == 0) { printf("Got two ContextReady callbacks \n"); uwa_emit_test_finished (); } } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); unity_webapps_context_new (service, "Testbarbaz", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/abandon-before-context-ready.c0000644000015301777760000000317012321247333030745 0ustar pbusernogroup00000000000000#include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static UnityWebappsService *service = NULL; static void context_prepared (UnityWebappsContext *context, gpointer user_data) { g_assert(0 && "should not get there"); } static gboolean done_with_test (gpointer user_data) { uwa_emit_test_finished (); return FALSE; } /** * * Validates that the context ready callback is NOT called if in the meantime * a context destroyed has been called. * The test is a bit timing dependant (in the prepare -> destroy sequence) but * tries to simulate someone navigating to an integrated website and very quickly * (before the loop -> context-daemon -> libunity-webapps context read -> js completes) * navigates away (changes the url). The js callback should not be called in this case. * */ gint main (gint argc, gchar **argv) { g_type_init (); service = unity_webapps_service_new (); UnityWebappsContext * context = unity_webapps_context_new_lazy (service, "Test", "test.ts", ICON_URL, NULL); unity_webapps_context_prepare(context, context_prepared, NULL); unity_webapps_context_destroy(context, TRUE); // 5 seconds is kind of arbitrary, trying to make sure that the context-daemon has the time // to come back to libunity-webapps & trigger the callback (or not) g_timeout_add_seconds (5, done_with_test, context); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/abandon-before-context-ready.trace0000644000015301777760000000027712321247333031626 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling LostInterest call Removing interest 1 <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/simple-create.c0000644000015301777760000000134012321247333026046 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/invalid-data-url.trace0000644000015301777760000000034212321247333027326 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Looking up URI Cache miss failed to get resource path Handling ShowIndicator call <[Client]> Created context proxy Showed indicator libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/oversized-icon.trace0000644000015301777760000000031312321247333027127 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Looking up URI Cache miss Making file from HTTP URI checking size too large <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/activate-application0000755000015301777760000001713212321247333027205 0ustar pbusernogroup00000000000000#! /bin/bash # activate-application - temporary wrapper script for .libs/activate-application # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 # # The activate-application program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command="(cd /home/racarr/src/webapps/libunity-webapps/trunk/tests/misc; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games; export PATH; gcc -g -O2 -O0 -Wall -o \$progdir/\$file activate-application.o -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 ../../src/.libs/libunity_webapps.so -lgthread-2.0 -Wl,-rpath -Wl,/home/racarr/src/webapps/libunity-webapps/trunk/src/.libs)" # This environment variable determines our operation mode. if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then # install mode needs the following variables: generated_by_libtool_version='2.4.2' notinst_deplibs=' ../../src/libunity-webapps.la' else # When we are sourced in execute mode, $file and $ECHO are already set. if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then file="$0" # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO="printf %s\\n" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string --lt- # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's ../../libtool value, followed by no. lt_option_debug= func_parse_lt_options () { lt_script_arg0=$0 shift for lt_opt do case "$lt_opt" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` cat "$lt_dump_D/$lt_dump_F" exit 0 ;; --lt-*) $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n "$lt_option_debug"; then echo "activate-application:activate-application:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do $ECHO "activate-application:activate-application:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" lt_dump_args_N=`expr $lt_dump_args_N + 1` done } # Core function for launching the target application func_exec_program_core () { if test -n "$lt_option_debug"; then $ECHO "activate-application:activate-application:${LINENO}: newargv[0]: $progdir/$program" 1>&2 func_lt_dump_args ${1+"$@"} 1>&2 fi exec "$progdir/$program" ${1+"$@"} $ECHO "$0: cannot exec $program $*" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from $@ and # launches target application with the remaining arguments. func_exec_program () { case " $* " in *\ --lt-*) for lt_wr_arg do case $lt_wr_arg in --lt-*) ;; *) set x "$@" "$lt_wr_arg"; shift;; esac shift done ;; esac func_exec_program_core ${1+"$@"} } # Parse options func_parse_lt_options "$0" ${1+"$@"} # Find the directory that this script lives in. thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` test "x$thisdir" = "x$file" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` while test -n "$file"; do destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` # If there was a directory component, then change thisdir. if test "x$destdir" != "x$file"; then case "$destdir" in [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; *) thisdir="$thisdir/$destdir" ;; esac fi file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then # special case for '.' if test "$thisdir" = "."; then thisdir=`pwd` fi # remove .libs from thisdir case "$thisdir" in *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; .libs ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=`cd "$thisdir" && pwd` test -n "$absdir" && thisdir="$absdir" program=lt-'activate-application' progdir="$thisdir/.libs" if test ! -f "$progdir/$program" || { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ test "X$file" != "X$progdir/$program"; }; then file="$$-$program" if test ! -d "$progdir"; then mkdir "$progdir" else rm -f "$progdir/$file" fi # relink executable if necessary if test -n "$relink_command"; then if relink_command_output=`eval $relink_command 2>&1`; then : else printf %s\n "$relink_command_output" >&2 rm -f "$progdir/$file" exit 1 fi fi mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || { rm -f "$progdir/$program"; mv -f "$progdir/$file" "$progdir/$program"; } rm -f "$progdir/$file" fi if test -f "$progdir/$program"; then if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then # Run the actual program with our arguments. func_exec_program ${1+"$@"} fi else # The program doesn't exist. $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 $ECHO "This script is just a wrapper for $program." 1>&2 $ECHO "See the libtool documentation for more information." 1>&2 exit 1 fi fi libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/create-2-same.c0000644000015301777760000000172612321247333025651 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; guint count = 2; static void context_ready (UnityWebappsContext *context, gpointer user_data) { count--; if (count == 0) { printf("Got two ContextReady callbacks \n"); g_main_loop_quit (mainloop); } uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/add-icon.trace0000644000015301777760000000042412321247333025650 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 Handling AddIcon Looking up URI (Making file from HTTP URI)|(Cache hit) Resource DB total size computed <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/invalid-icon-url.trace0000644000015301777760000000034212321247333027345 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Looking up URI Cache miss failed to get resource path Handling ShowIndicator call <[Client]> Created context proxy Showed indicator libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/invalid-icon-url.c0000644000015301777760000000151612321247333026475 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Invalid Application Icon URL Test"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestInvalid", "test.ts", "Foo bar not a url", NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/add-icon.c0000644000015301777760000000153512321247333025000 0ustar pbusernogroup00000000000000#include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" #define FAVICON_URL "http://www.ubuntu.com/sites/all/themes/ubuntu10/favicon.ico" #include "uwa-test-client.h" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_context_add_icon (context, FAVICON_URL, 16); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/simple-create.trace0000644000015301777760000000022512321247333026723 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Emitting ContextReady <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/destroy-interest-for-context.c0000644000015301777760000000260212321247333031110 0ustar pbusernogroup00000000000000#include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "http://www.ubuntu.com/sites/www.ubuntu.com/files/active/02_ubuntu/U_homepage/picto-desktop.png" static GMainLoop *mainloop = NULL; static UnityWebappsService *service = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { GVariant * interests = unity_webapps_context_list_interests(context); const gchar * name = unity_webapps_context_get_name (context); const gchar * domain = unity_webapps_context_get_domain (context); int num = g_variant_n_children(interests); int i = 0; for (i = 0; i < num; ++i) { GVariant * s = g_variant_get_child_value(interests, i); unity_webapps_service_destroy_interest_for_context(service , name, domain , g_variant_get_int32(s) , TRUE); } g_variant_unref(interests); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "Test", "test.ts", ICON_URL, NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/create-2-same.trace0000644000015301777760000000041112321247333026513 0ustar pbusernogroup00000000000000<[Service]> Handling GetContext Spawning context Handling GetContext No existing context Found existing pending invocation <[Context]> Added interest 1 Added interest 2 <[Client]> Created context proxy Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/destroy-interest-for-context.trace0000644000015301777760000000032612321247333031765 0ustar pbusernogroup00000000000000<[Service]> User abandoned the lonely daemon <[Context]> Handling AddInterest call Emitting NoInterest signal <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/invalid-data-url.c0000644000015301777760000000133512321247333026455 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "uwa-test-client.h" #define ICON_URL "data:lol" static GMainLoop *mainloop = NULL; static void context_ready (UnityWebappsContext *context, gpointer user_data) { unity_webapps_indicator_show_indicator (context, "Test"); uwa_emit_test_finished (); } gint main (gint argc, gchar **argv) { UnityWebappsService *service; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, "TestInvalidData", "test.ts", "Foo bar not a url", NULL, context_ready, NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/misc/context-properties.trace0000644000015301777760000000022112321247333030043 0ustar pbusernogroup00000000000000<[Service]> <[Context]> Added interest 1 <[Client]> Created context proxy libunity-webapps-2.5.0~+14.04.20140409/tests/traced/make-test.py0000755000015301777760000000045512321247333024472 0ustar pbusernogroup00000000000000#!/usr/bin/env python import sys, os if len(sys.argv) != 3: print("Usage: ./make-test.py module name") exit() module = sys.argv[1] name = sys.argv[2] os.system ("cp test-template.c %s/%s.c" % (module, name)) editor = os.getenv("EDITOR") os.system("%s %s/%s.c" % (editor, module, name)) libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/0000755000015301777760000000000012321250157024503 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/uwa-test.c0000644000015301777760000001505012321247333026423 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * test.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "uwa-test.h" #include "uwa-trace.h" #include #include #include #include #include struct _UwaTest { gchar *name; UwaTrace *context_trace; UwaTrace *service_trace; UwaTrace *client_trace; gboolean echo; }; UwaTest * uwa_test_new (const gchar *test_name, gboolean do_not_trace, gboolean echo) { UwaTest *test; test = g_malloc0 (sizeof (UwaTest)); test->name = g_strdup (test_name); if (do_not_trace == FALSE) { test->context_trace = uwa_trace_new_for_test_name (test_name, "Context"); if (test->context_trace == NULL) { g_error ("Failed to load trace file (Context Channel)"); return NULL; } test->service_trace = uwa_trace_new_for_test_name (test_name, "Service"); if (test->service_trace == NULL) { g_error ("Failed to load trace file (Service Channel)"); return NULL; } test->client_trace = uwa_trace_new_for_test_name (test_name, "Client"); if (test->client_trace == NULL) { g_error ("Failed to load trace file (Client Channel)"); return NULL; } } else { test->context_trace = NULL; test->service_trace = NULL; test->client_trace = NULL; } test->echo = echo; return test; } void uwa_test_free (UwaTest *test) { uwa_trace_free (test->context_trace); uwa_trace_free (test->service_trace); uwa_trace_free (test->client_trace); g_free (test->name); g_free (test); } static gboolean kill_existing_service () { gchar *argv[] = {"../../tools/unity-webapps-tool", "shutdown", NULL}; GError *error; error = NULL; g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, NULL, &error); if (error != NULL) { g_error ("Error running unity-webapps-tool to shutdown: %s", error->message); g_error_free (error); return FALSE; } return TRUE; } #define SERVICE_MESSAGE_PREFIX "** Message: [SERVICE]" static gboolean service_out_watch (GIOChannel *channel, GIOCondition condition, gpointer user_data) { UwaTest *test; gchar *out_line; gsize size; test = (UwaTest *) user_data; if (condition == G_IO_HUP) { g_io_channel_unref (channel); return FALSE; } g_io_channel_read_line (channel, &out_line, &size, NULL, NULL); if (test->echo) { g_printf("%s", out_line); } if (test->service_trace && g_str_has_prefix (out_line, SERVICE_MESSAGE_PREFIX)) { if (uwa_trace_process_line (test->service_trace, out_line) == FALSE) { g_error ("Failed to process line against trace (service channel)"); } } else if (test->context_trace) { if (uwa_trace_process_line (test->context_trace, out_line) == FALSE) { g_error ("Failed to process line against trace (context channel)"); } } g_free (out_line); return TRUE; } static gboolean spawn_new_service (UwaTest *test) { GIOChannel *out_ch; gchar *argv[] = {"../../src/webapps-service/unity-webapps-service", NULL}; gint child_stderr; GError *error; error = NULL; g_spawn_async_with_pipes (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, &child_stderr, &error); if (error != NULL) { g_error ("Error spawning service: %s", error->message); g_error_free (error); return FALSE; } out_ch = g_io_channel_unix_new (child_stderr); g_io_add_watch (out_ch, G_IO_IN | G_IO_HUP, (GIOFunc)service_out_watch, test); return TRUE; } gboolean uwa_test_prepare_environment (UwaTest *test) { g_setenv("UNITY_WEBAPPS_DEBUG_FLAGS", "all", TRUE); g_setenv("UNITY_WEBAPPS_TESTS_DISABLE_INDEX_UPDATER", "yes", TRUE); g_setenv("UNITY_WEBAPPS_RUNNING_TRACED_TESTS", "yes", TRUE); g_setenv("UNITY_WEBAPPS_USE_DBUS_CONTROLLABLE_WINDOW_TRACKING", "yes", TRUE); if (kill_existing_service() == FALSE) { printf("Couldnt kill \n"); return FALSE; } if (spawn_new_service(test) == FALSE) { return FALSE; } return TRUE; } static gboolean client_out_watch (GIOChannel *channel, GIOCondition condition, gpointer user_data) { UwaTest *test; gchar *out_line; gsize size; test = (UwaTest *)user_data; if (condition == G_IO_HUP) { g_io_channel_unref (channel); return FALSE; } g_io_channel_read_line (channel, &out_line, &size, NULL, NULL); if (test->echo) { g_printf("(Client) %s", out_line); } if (test->client_trace) { if (uwa_trace_process_line (test->client_trace, out_line) == FALSE) { g_error ("Failed to process line against trace (client channel)"); } } g_free (out_line); return TRUE; } static gboolean spawn_new_test (UwaTest *test) { GIOChannel *out_ch; gchar *argv[] = {NULL, NULL}; gint child_stderr; GError *error; error = NULL; argv[0] = test->name; g_spawn_async_with_pipes (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, &child_stderr, &error); if (error != NULL) { g_error ("Error spawning test: %s", error->message); g_error_free (error); return FALSE; } out_ch = g_io_channel_unix_new (child_stderr); g_io_add_watch (out_ch, G_IO_IN | G_IO_HUP, (GIOFunc)client_out_watch, test); return TRUE; } gboolean uwa_test_run (UwaTest *test) { spawn_new_test (test); return TRUE; } gboolean uwa_test_passed (UwaTest *test, gboolean print_next) { if (test->context_trace && (uwa_trace_passed (test->context_trace, print_next) == FALSE)) { return FALSE; } else if (test->service_trace && (uwa_trace_passed (test->service_trace, print_next) == FALSE)) { return FALSE; } else if (test->client_trace && (uwa_trace_passed (test->client_trace, print_next) == FALSE)) { return FALSE; } return TRUE; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/test-runner.c0000644000015301777760000000655312321247333027150 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * test-runner.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include #include #include "uwa-test.h" static GMainLoop *mainloop = NULL; static gchar *name = NULL; static gboolean do_not_trace = FALSE; static gboolean echo = FALSE; static gint check_count = 0; static GOptionEntry option_entries[] = { { "name", 'n',0,G_OPTION_ARG_STRING, &name, "Test name", NULL }, { "do-not-trace", 'd', 0, G_OPTION_ARG_NONE, &do_not_trace, "Do not trace (just run the test)", NULL}, { "echo", 'e', 0, G_OPTION_ARG_NONE, &echo, "Echo service output", NULL}, { NULL, } }; static gboolean timeout_cb (gpointer user_data) { UwaTest *test = (UwaTest *)user_data; if (uwa_test_passed (test, check_count == 50 ? TRUE : FALSE)) { g_printf ("Test passed\n"); exit (0); } if (check_count < 20) { check_count++; return TRUE; } printf("Test failed\n"); exit(1); return FALSE; } static void bus_filter_test_finished (GDBusConnection *connection, const gchar *sender, const gchar *object, const gchar *interface, const gchar *signal, GVariant *params, gpointer user_data) { g_timeout_add (300, timeout_cb, user_data); } gint main (gint argc, gchar **argv) { GOptionContext *context; UwaTest *test; GDBusConnection *connection; GError *error; g_type_init (); error = NULL; context = g_option_context_new ("- Run libunity-webppps unit tests"); // TODO: GETTEXT g_option_context_add_main_entries (context, option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { printf("Failed to parse arguments: %s\n", error->message); exit(1); } test = uwa_test_new (name, do_not_trace, echo); if (uwa_test_prepare_environment (test) == FALSE) { printf("Failed to prepare test environment\n"); exit(1); } error = NULL; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (error != NULL) { printf("Failed to get session bus\n"); exit(1); } g_dbus_connection_signal_subscribe (connection, NULL, "com.canonical.Unity.Webapps.TraceTester", "TestFinished", NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE, bus_filter_test_finished, test, NULL); uwa_test_run (test); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); g_object_unref (G_OBJECT (connection)); exit (0); } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/Makefile.am0000644000015301777760000000040612321247333026541 0ustar pbusernogroup00000000000000SUBDIRS = post-actions AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) noinst_PROGRAMS = \ test-runner test_runner_SOURCES = \ test-runner.c \ uwa-test.c \ uwa-test.h \ uwa-trace.c \ uwa-trace.h \ uwa-macros.h test_runner_LDADD = \ $(UNITY_WEBAPPS_LIBS) libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/post-actions/0000755000015301777760000000000012321250157027126 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/post-actions/Makefile.am0000644000015301777760000000174112321247333031167 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps noinst_PROGRAMS = \ change-presence \ action-invoker \ indicator-action-invoker \ music-action-invoker change_presence_SOURCES = \ change-presence.c change_presence_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) action_invoker_SOURCES = \ action-invoker.c action_invoker_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la indicator_action_invoker_SOURCES = \ indicator-action-invoker.c indicator_action_invoker_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la music_action_invoker_SOURCES = \ music-action-invoker.c music_action_invoker_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/post-actions/music-action-invoker.c0000644000015301777760000001031312321247333033340 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-action-invoker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include #include #include #include static gchar *application = NULL; const gchar *action = NULL; typedef enum { TRANSPORT_ACTION_PREVIOUS, TRANSPORT_ACTION_PLAY_PAUSE, TRANSPORT_ACTION_NEXT, TRANSPORT_ACTION_REWIND, TRANSPORT_ACTION_FORWIND, TRANSPORT_ACTION_NO_ACTION }TransportAction; static gboolean quit_and_flush (gpointer user_data) { while (g_main_context_pending (NULL)) { g_main_context_iteration (NULL, TRUE); } g_dbus_connection_flush_sync (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL), NULL, NULL); exit (0); return FALSE; } static void on_property_changed (DbusmenuMenuitem *metadata_item, const gchar *property, GVariant *value, gpointer user_data) { DbusmenuMenuitem *transport_item; const gchar *player_name; gint i; transport_item = user_data ? (DbusmenuMenuitem *)(((GList *)user_data)->data) : NULL; if (g_strcmp0 (property, "x-canonical-sound-menu-player-metadata-player-name") != 0) { return; } g_variant_get (value, "s", &player_name); if (g_strcmp0 (player_name, application) != 0) { return; } if (action == NULL) { i = 0; transport_item = metadata_item; } else if (g_strcmp0 (action, "playpause") == 0) { i = TRANSPORT_ACTION_PLAY_PAUSE; } else if (g_strcmp0 (action, "previous") == 0) { i = TRANSPORT_ACTION_PREVIOUS; } else if (g_strcmp0 (action, "next") == 0) { i = TRANSPORT_ACTION_NEXT; } else { i= 0; transport_item = metadata_item; } dbusmenu_menuitem_handle_event (transport_item, "clicked", g_variant_new ("i", i), time (NULL)); g_timeout_add (500, quit_and_flush, NULL); } static gboolean invoke_item (gpointer user_data) { DbusmenuMenuitem *root; const GList *children; const GList *walk; root = (DbusmenuMenuitem *)user_data; children = dbusmenu_menuitem_get_children (root); for (walk = children; walk != NULL; walk = walk->next) { DbusmenuMenuitem *child; const gchar *child_type; child = (DbusmenuMenuitem *)walk->data; child_type = dbusmenu_menuitem_property_get (child, "type"); if (g_strcmp0 (child_type, "x-canonical-sound-menu-player-metadata-type") != 0) { continue; } g_signal_connect (child, "property-changed", G_CALLBACK (on_property_changed), walk->next); } return FALSE; } static void on_root_changed (DbusmenuClient *client, DbusmenuMenuitem *newitem, gpointer user_data) { invoke_item(newitem); } static void make_client () { DbusmenuClient *client; client = dbusmenu_client_new ("com.canonical.indicator.sound", "/com/canonical/indicator/sound/menu"); g_signal_connect (client, "root-changed", G_CALLBACK (on_root_changed), NULL); } gint main (gint argc, gchar **argv) { if (argc == 2) { application = argv[1]; action = NULL; } else if (argc == 3) { application = argv[1]; action = argv[2]; } else { g_printf ("Usage: indicator-action-invoker application (action?)"); exit (1); } g_type_init (); make_client (); g_main_loop_run (g_main_loop_new (NULL, FALSE)); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/post-actions/action-invoker.c0000644000015301777760000000763712321247333032241 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-action-invoker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include #include #include #include static UnityWebappsService *service = NULL; static gchar *name = NULL; static gchar *domain = NULL; const gchar *action = NULL; static gchar ** split_action_path (const gchar *action_path) { gchar **components; if (action_path[0] != '/') { return NULL; } components = g_strsplit (action_path+1, "/", -1); if (g_strv_length (components) > 3) { g_strfreev (components); return NULL; } return components; } static DbusmenuMenuitem * menuitem_find_child_by_label (DbusmenuMenuitem *item, const gchar *label) { const GList *children; const GList *walk; children = dbusmenu_menuitem_get_children (item); for (walk = children; walk != NULL; walk = walk->next) { DbusmenuMenuitem *child; const gchar *child_label; child = (DbusmenuMenuitem *)walk->data; child_label = dbusmenu_menuitem_property_get (child, "label"); if (g_strcmp0 (child_label, label) == 0) { return child; } } return NULL; } static void invoke_action_by_path (DbusmenuMenuitem *root, const gchar *action_path) { gchar **components; DbusmenuMenuitem *item; gint i, length; components = split_action_path (action_path); length = g_strv_length (components); if (length < 0) { return; } item = root; for (i = 0; i < length; i++) { DbusmenuMenuitem *child; gchar *component; component = components[i]; child = menuitem_find_child_by_label (item, component); if (child == NULL) { g_error ("Action not found"); exit (1); } item = child; } g_message("Invoking item: %s", components[i-1]); dbusmenu_menuitem_handle_event (item, "clicked", g_variant_new("i", 0), time(NULL)); g_strfreev (components); g_dbus_connection_flush_sync (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL), NULL, NULL); exit(0); } static void on_root_changed (DbusmenuClient *client, DbusmenuMenuitem *newitem, gpointer user_data) { invoke_action_by_path (newitem, action); } static void context_ready (UnityWebappsContext *context, gpointer user_data) { DbusmenuClient *client; const gchar *context_name; context_name = unity_webapps_context_get_context_name (context); client = dbusmenu_client_new (context_name, "/com/canonical/Unity/Webapps/Context/ApplicationActions"); g_signal_connect (client, "root-changed", G_CALLBACK (on_root_changed), NULL); } gint main (gint argc, gchar **argv) { if (argc != 4) { g_printf ("Usage: action-invoker name domain action"); } name = argv[1]; domain = argv[2]; action = argv[3]; g_type_init (); service = unity_webapps_service_new (); unity_webapps_context_new (service, name, domain, "", NULL, context_ready, NULL); g_main_loop_run (g_main_loop_new (NULL, FALSE)); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/post-actions/change-presence.c0000644000015301777760000000461012321247333032324 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * change-presence.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include static GMainLoop *mainloop = NULL; static DbusmenuClient *client = NULL; static gchar *presence = NULL; static void on_root_changed (DbusmenuClient *menu_client, DbusmenuMenuitem *root_item, gpointer user_data) { const GList *children; const GList *walk; children = dbusmenu_menuitem_get_children (root_item); for (walk = children; walk != NULL; walk = walk->next) { DbusmenuMenuitem *child; const gchar *child_label; child = (DbusmenuMenuitem *)walk->data; child_label = dbusmenu_menuitem_property_get (child, "label"); if (g_strcmp0 (g_utf8_casefold (child_label, strlen (child_label)), g_utf8_casefold (presence, strlen (presence))) == 0) { dbusmenu_menuitem_handle_event (child, "clicked", NULL, time(NULL)); g_dbus_connection_flush_sync (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL), NULL, NULL); exit (0); } } exit(0); } gint main (gint argc, gchar **argv) { if (argc != 2) { printf("Usage: change-presence presence"); exit(1); } presence = argv[1]; g_type_init (); client = dbusmenu_client_new ("com.canonical.indicator.messages", "/com/canonical/indicator/messages/menu"); g_signal_connect (client, "root-changed", G_CALLBACK (on_root_changed), NULL); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); exit (0); } ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/post-actions/indicator-action-invoker.clibunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/post-actions/indicator-action-invoke0000644000015301777760000000560212321247333033576 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-action-invoker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include #include #include #include static gchar *application = NULL; const gchar *action = NULL; GDBusMenuModel *root = NULL; GActionGroup *group; static gboolean quit_and_flush (gpointer user_data) { while (g_main_context_pending (NULL)) { g_main_context_iteration (NULL, TRUE); } g_dbus_connection_flush_sync (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL), NULL, NULL); exit (0); return FALSE; } static gboolean invoke_action (gpointer data) { gchar **it; for (it = g_action_group_list_actions (group); *it; it++) { if (!g_str_has_prefix (*it, application)) continue; if (action) { if (g_strrstr (*it, ".source.")) { gchar *name = g_strrstr (*it, ".source.") + strlen (".source."); if (g_strcmp0 (name, action) == 0) g_action_group_activate_action (group, *it, NULL); } } else { if (g_str_has_suffix (*it, ".launch")) g_action_group_activate_action (group, *it, NULL); } } g_timeout_add_seconds(1, quit_and_flush, NULL); return FALSE; } static void make_client () { GDBusConnection *connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); root = g_dbus_menu_model_get (connection, "com.canonical.indicator.messages", "/com/canonical/indicator/messages/menu"); group = G_ACTION_GROUP (g_dbus_action_group_get (connection,"com.canonical.indicator.messages", "/com/canonical/indicator/messages/menu")); g_action_group_list_actions (group); g_timeout_add_seconds (1, invoke_action, NULL); } gint main (gint argc, gchar **argv) { if (argc == 2) { application = argv[1]; action = NULL; } else if (argc == 3) { application = argv[1]; action = argv[2]; } else { g_printf ("Usage: indicator-action-invoker application (action?)"); exit (1); } g_type_init (); make_client (); g_main_loop_run (g_main_loop_new (NULL, FALSE)); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/uwa-trace.h0000644000015301777760000000230712321247333026550 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * uwa-trace.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UWA_TRACE_H #define __UWA_TRACE_H #include typedef struct _UwaTrace UwaTrace; UwaTrace *uwa_trace_new_for_test_name(const gchar *name, const gchar *channel); void uwa_trace_free (UwaTrace *trace); gboolean uwa_trace_process_line (UwaTrace *trace, const gchar *line); gboolean uwa_trace_passed (UwaTrace *trace, gboolean print_next); #endif libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/uwa-macros.h0000644000015301777760000000235512321247333026741 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * uwa-macros.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UWA_MACROS_H #define __UWA_MACROS_H #include #define MACRO_STANDARD_SERVICE_CHECK "Exported Service interface\n"\ "Handling GetContext\n"\ "Spawning context\n"\ "Handling ContextReady\n" struct _UwaTraceMacro { gchar *identifier; gchar *substitution; }; struct _UwaTraceMacro trace_macros[] = { { "STANDARD_SERVICE_CHECK", MACRO_STANDARD_SERVICE_CHECK} }; #endif libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/uwa-test.h0000644000015301777760000000232012321247333026424 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * uwa-test.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UWA_TEST_H #define __UWA_TEST_H #include typedef struct _UwaTest UwaTest; UwaTest *uwa_test_new(const gchar *name, gboolean do_not_trace, gboolean echo); void test_free (UwaTest *test); gboolean uwa_test_prepare_environment (UwaTest *test); gboolean uwa_test_run (UwaTest *test); gboolean uwa_test_passed (UwaTest *test, gboolean print_next); #endif libunity-webapps-2.5.0~+14.04.20140409/tests/traced/test-runner/uwa-trace.c0000644000015301777760000004061012321247333026542 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * trace.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include "uwa-trace.h" static gchar *uwa_trace_substitute_variables (UwaTrace *trace, const gchar *input_line); struct _UwaTrace { gchar *name; gint index; GList *traces; GList *matches; GHashTable *variables; }; typedef struct _UwaTracePoint { gchar *line_match; gchar *conditional; gchar *post_action; } UwaTracePoint; #include "uwa-macros.h" static gchar * extract_conditional_from_line (const gchar *trace_line) { GRegex *conditional_regex; GMatchInfo *conditional_match_info; gchar *matched_conditional, *extracted_conditional; gint matched_conditional_len; gboolean has_conditional; conditional_regex = g_regex_new("^<\\?(.*)\\?>", 0, 0, NULL); has_conditional = g_regex_match (conditional_regex, trace_line, 0, &conditional_match_info); if (has_conditional == FALSE) { g_regex_unref (conditional_regex); return NULL; } matched_conditional = g_match_info_fetch (conditional_match_info, 0); matched_conditional_len = strlen (matched_conditional); extracted_conditional = g_strndup (matched_conditional +2, matched_conditional_len - 4); g_free (matched_conditional); g_match_info_free (conditional_match_info); g_regex_unref (conditional_regex); return extracted_conditional; } static gchar * extract_post_action_from_line (const gchar *trace_line) { GRegex *post_action_regex; GMatchInfo *post_action_match_info; gchar *matched_action, *extracted_action; gint matched_action_len; gboolean has_action; post_action_regex = g_regex_new("<\\|(.*)\\|>$", 0, 0, NULL); has_action = g_regex_match (post_action_regex, trace_line, 0, &post_action_match_info); if (has_action == FALSE) { g_regex_unref (post_action_regex); return NULL; } matched_action = g_match_info_fetch (post_action_match_info, 0); matched_action_len = strlen (matched_action); extracted_action = g_strndup (matched_action + 2, matched_action_len - 4); g_free (matched_action); g_match_info_free (post_action_match_info); g_regex_unref (post_action_regex); return extracted_action; } static gboolean parse_trace_line (const gchar *trace_line, gchar **line_match, gchar **conditional, gchar **action) { gchar *extracted_conditional, *extracted_action; *conditional = *action = *line_match = NULL; extracted_conditional = extract_conditional_from_line (trace_line); if (extracted_conditional != NULL) { *conditional = extracted_conditional; trace_line += strlen (extracted_conditional) + 4; } extracted_action = extract_post_action_from_line (trace_line); if (extracted_action != NULL) { *action = extracted_action; *line_match = g_strndup (trace_line, strlen (trace_line) - strlen(extracted_action) - 4); } else { *line_match = g_strdup (trace_line); } return TRUE; } static gboolean uwa_trace_point_has_conditional (UwaTracePoint *trace_point) { return (trace_point->conditional != NULL); } static gboolean uwa_trace_point_conditionals_satisfied (UwaTracePoint *trace_point, UwaTrace *trace) { if (uwa_trace_point_has_conditional (trace_point) == FALSE) { return TRUE; } if (g_list_find_custom (trace->matches, trace_point->conditional, (GCompareFunc)g_strcmp0) != NULL) { return TRUE; } return FALSE; } static gboolean uwa_trace_point_do_post_action (UwaTrace *trace, UwaTracePoint *trace_point) { gchar *command_line, *substituted_post_action; gint exit_status; GError *error; if (trace_point->post_action == NULL) { return TRUE; } substituted_post_action = uwa_trace_substitute_variables (trace, trace_point->post_action); command_line = g_strdup_printf("test-runner/post-actions/%s", substituted_post_action); printf("Doing post action: %s \n", command_line); error = NULL; g_spawn_command_line_sync (command_line, NULL, NULL, &exit_status, &error); if (error != NULL) { g_error ("Error spawning trace point post action: %s", error->message); g_error_free (error); g_free (command_line); g_free (substituted_post_action); return FALSE; } if (exit_status != 0) { g_error ("Trace point post action returned non zero exit status (%d)", exit_status); g_free (command_line); g_free (substituted_post_action); return FALSE; } g_free (command_line); g_free (substituted_post_action); return TRUE; } static gboolean uwa_trace_point_extract_named_variables (UwaTrace *trace, UwaTracePoint *trace_point, GMatchInfo *match_info) { GRegex *named_match_regex; GMatchInfo *named_match_info; gchar *identifier, *original_match; gboolean matched; GError *error; error = NULL; // TODO: FIXME: Support multiple matches named_match_regex = g_regex_new ("\\?<(?P[a-zA-Z]+)>", 0, 0, &error); if (error != NULL) { g_error ("Error compiling named match regex: %s", error->message); g_error_free (error); return FALSE; } matched = g_regex_match (named_match_regex, trace_point->line_match, 0, &named_match_info); if (matched == FALSE) { g_regex_unref (named_match_regex); return TRUE; } identifier = g_match_info_fetch_named (named_match_info, "identifier"); original_match = g_match_info_fetch_named (match_info, identifier); g_hash_table_insert (trace->variables, identifier, original_match); g_match_info_free (named_match_info); g_regex_unref (named_match_regex); return TRUE; } static UwaTracePoint * uwa_trace_point_new (const gchar *trace_line) { UwaTracePoint *trace_point; trace_point = g_malloc0 (sizeof (UwaTracePoint)); if (parse_trace_line (trace_line, &(trace_point->line_match), &(trace_point->conditional), &(trace_point->post_action)) == FALSE) { g_error ("Error parsing trace line: %s", trace_line); return NULL; } return trace_point; } static void uwa_trace_point_free (UwaTracePoint *trace_point) { g_free (trace_point->line_match); g_free (trace_point); } static gchar * macro_get_identifier (const gchar *trace_line) { return g_strndup (trace_line + 2, strlen (trace_line) - 4); } static gchar * substitute_macro_line (const gchar *trace_line) { gchar *substitution; gchar *identifier; gint i; identifier = macro_get_identifier (trace_line); substitution = NULL; for (i = 0; i < G_N_ELEMENTS (trace_macros); i++) { if (g_strcmp0 (identifier, trace_macros[i].identifier) == 0) { substitution = g_strdup (trace_macros[i].substitution); } } g_free (identifier); return substitution; } static gchar * preprocess_trace (const gchar *trace) { GString *preprocessed_trace; gchar **components, *retval; gint i, len; components = g_strsplit (trace, "\n", -1); len = g_strv_length (components); g_assert (len); preprocessed_trace = g_string_new (NULL); for (i = 0; i < len; i++) { const gchar *trace_line; trace_line = components[i]; if (strlen (trace_line) == 0) { continue; } if (g_str_has_prefix (trace_line, "str; g_string_free (preprocessed_trace, FALSE); g_strfreev (components); return retval; } static gchar * strip_trace (const gchar *trace, const gchar *channel) { gchar *header, *footer, *stripped; const gchar *header_loc, *footer_loc, *channel_loc; header = g_strdup_printf("<[%s]>", channel); stripped = NULL; footer = NULL; header_loc = strstr (trace, header); if (header_loc == NULL) { goto out; } g_assert ( ((header_loc-trace)+strlen(header)) < strlen(trace) ); footer = g_strdup_printf("", channel); footer_loc = strstr (trace, footer); if (footer_loc == NULL) { goto out; } channel_loc = header_loc + strlen (header) + 1; size_t stripped_size = footer_loc > channel_loc ? (footer_loc-channel_loc)-1 : 0; stripped = g_strndup (channel_loc, stripped_size); out: g_free (header); g_free (footer); return stripped; } static gchar * get_trace_file_contents (UwaTrace *trace, const gchar *channel) { gchar *trace_file_name, *contents, *stripped_trace, *processed_trace; GError *error; trace_file_name = g_strdup_printf("%s.trace", trace->name); contents = NULL; error = NULL; g_file_get_contents (trace_file_name, &contents, NULL, &error); if (error != NULL) { g_warning ("Failed to load trace file: %s", error->message); g_error_free (error); return NULL; } stripped_trace = strip_trace (contents, channel); processed_trace = preprocess_trace (stripped_trace); g_free (contents); g_free (trace_file_name); g_free (stripped_trace); return processed_trace; } static gboolean load_test_metadata (UwaTrace *trace, const gchar *channel) { gchar *trace_contents, **components; gint i, length; trace_contents = get_trace_file_contents (trace, channel); components = g_strsplit (trace_contents, "\n", -1); g_assert (components); length = g_strv_length (components); if (length == 0) { g_warning ("No trace data"); return FALSE; } for (i = 0; i < length; i++) { UwaTracePoint *trace_point; if (strlen(components[i]) == 0) { continue; } trace_point = uwa_trace_point_new (components[i]); if (trace_point == NULL) { g_error ("Error parsing trace point: %s", components[i]); return FALSE; } trace->traces = g_list_append (trace->traces, trace_point); } g_free (components); g_free (trace_contents); return TRUE; } static gchar * uwa_trace_substitute_variables (UwaTrace *trace, const gchar *input_line) { GRegex *substitution_regex; GMatchInfo *match_info; gchar *identifier, *substitution, *substituted; gboolean matched; GError *error; error = NULL; // TODO: FIXME: Support multiple variables per line. substitution_regex = g_regex_new("\\$\\{(?P[a-zA-Z]+)\\}", 0, 0, &error); if (error != NULL) { g_error ("Error compiling substitution regex: %s", error->message); g_error_free (error); return NULL; } matched = g_regex_match (substitution_regex, input_line, 0, &match_info); if (matched == FALSE) { g_regex_unref (substitution_regex); return g_strdup (input_line); } substituted = NULL; identifier = g_match_info_fetch_named (match_info, "identifier"); substitution = g_hash_table_lookup (trace->variables, identifier); if (substitution == NULL) { printf("No substitution for: %s \n", identifier); goto out; } error = NULL; substituted = g_regex_replace (substitution_regex, input_line, -1, 0, substitution, 0, &error); if (error != NULL) { g_error ("Error applying substitution regex: %s", error->message); g_error_free (error); substituted = NULL; } out: g_free (identifier); g_match_info_free (match_info); g_regex_unref (substitution_regex); return substituted; } UwaTrace * uwa_trace_new_for_test_name (const gchar *test_name, const gchar *channel) { UwaTrace *trace; trace = g_malloc0 (sizeof (UwaTrace)); trace->name = g_strdup (test_name); trace->index = 0; trace->traces = NULL; trace->matches = NULL; trace->variables = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); if (load_test_metadata (trace, channel) == FALSE) { return NULL; } return trace; } static void trace_list_foreach_free (gpointer data, gpointer user_data) { uwa_trace_point_free (data); } static void match_list_foreach_free (gpointer data, gpointer user_data) { g_free (data); } void uwa_trace_free (UwaTrace *trace) { g_list_foreach (trace->traces, trace_list_foreach_free, NULL); g_list_foreach (trace->matches, match_list_foreach_free, NULL); g_list_free (trace->traces); g_list_free (trace->matches); g_hash_table_destroy (trace->variables); g_free (trace->name); g_free (trace); } gboolean trace_line_satisfies_conditionals (UwaTrace *trace, const gchar *trace_line) { GRegex *conditional_regex; GMatchInfo *conditional_match_info; gchar *conditional; gint conditional_len; gboolean has_conditional, satisfied; conditional_regex = g_regex_new ("^<\?(.*)\?>", 0, 0, NULL); g_assert (conditional_regex); has_conditional = g_regex_match (conditional_regex, trace_line, 0, &conditional_match_info); if (has_conditional == FALSE) { g_regex_unref (conditional_regex); return TRUE; } conditional = g_match_info_fetch (conditional_match_info, 0); conditional_len = strlen (conditional); conditional = conditional + 2; // Skip the matches, conditional, (GCompareFunc)g_strcmp0) != NULL) { satisfied = TRUE; } conditional = conditional - 2; g_free (conditional); g_match_info_free (conditional_match_info); g_regex_unref (conditional_regex); return satisfied; } gboolean trace_line_has_conditional (const gchar *trace_line) { return g_str_has_prefix (trace_line, "index >= g_list_length (trace->traces)) { return TRUE; } trace_point = (UwaTracePoint *) g_list_nth_data (trace->traces, trace->index); if (uwa_trace_point_has_conditional (trace_point)) { if (uwa_trace_point_conditionals_satisfied (trace_point, trace) == FALSE) { trace->index++; if (trace->index >= g_list_length (trace->traces)) { return TRUE; } trace_point = (UwaTracePoint *) g_list_nth_data (trace->traces, trace->index); } } current_trace_match = trace_point->line_match; error = NULL; trace_regex = g_regex_new (current_trace_match, 0, 0, &error); if (error != NULL) { g_error ("Error compiling trace regex: %s", error->message); g_error_free (error); return FALSE; } matched = g_regex_match (trace_regex, line, 0, &match_info); if (matched) { gchar *match; match = g_match_info_fetch (match_info, 0); trace->matches = g_list_append (trace->matches, match); uwa_trace_point_extract_named_variables (trace, trace_point, match_info); trace->index++; if (uwa_trace_point_do_post_action (trace, trace_point) == FALSE) { g_error ("Error executing post trace action for trace point"); g_match_info_free (match_info); g_regex_unref (trace_regex); return FALSE; } } g_match_info_free (match_info); g_regex_unref (trace_regex); return TRUE; } gboolean uwa_trace_passed (UwaTrace *trace, gboolean print_next) { UwaTracePoint *trace_point; if (trace->index >= g_list_length (trace->traces)) { return TRUE; } trace_point = (UwaTracePoint *)g_list_nth_data (trace->traces, trace->index); if (print_next) { printf ("Trace failed, next pending match: %s (conditional: %s)\n", trace_point->line_match, trace_point->conditional); } return FALSE; } libunity-webapps-2.5.0~+14.04.20140409/tests/traced/common/0000755000015301777760000000000012321250157023505 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/traced/common/Makefile.am0000644000015301777760000000006112321247333025540 0ustar pbusernogroup00000000000000EXTRA_DIST = uwa-test-client.c uwa-test-client.h libunity-webapps-2.5.0~+14.04.20140409/tests/traced/common/uwa-test-client.h0000644000015301777760000000165012321247333026707 0ustar pbusernogroup00000000000000/* * uwa-test-client.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UWA_TEST_CLIENT_H #define __UWA_TEST_CLIENT_H void uwa_emit_test_finished (); void uwa_emit_window_changed (guint64 window_id); #endif libunity-webapps-2.5.0~+14.04.20140409/tests/traced/common/uwa-test-client.c0000644000015301777760000000377212321247333026711 0ustar pbusernogroup00000000000000/* * uwa-test-client.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include // in sync with what is in src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.c #define WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_PATH \ "com.canonical.Unity.Webapps.Tests.WindowTracker.DbusControllable" #define WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_SIGNAL \ "UpdateLatestWindowId" void uwa_emit_test_finished () { GDBusConnection *connection; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); // TODO: Error g_dbus_connection_emit_signal (connection, NULL, "/", "com.canonical.Unity.Webapps.TraceTester", "TestFinished", NULL, NULL); // TODO: Error g_dbus_connection_flush_sync (connection, NULL, NULL); exit(0); } void uwa_emit_window_changed (guint64 window_id) { GDBusConnection *connection; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); // TODO: Error g_dbus_connection_emit_signal (connection, NULL, "/", WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_PATH, WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_SIGNAL, g_variant_new ("(t)", window_id, NULL), NULL); g_dbus_connection_flush_sync (connection, NULL, NULL); } libunity-webapps-2.5.0~+14.04.20140409/tests/libunity-webapps/0000755000015301777760000000000012321250157024251 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/libunity-webapps/Makefile.am0000644000015301777760000000107112321247333026306 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ -DUNITY_WEBAPPS_ENABLE_DEBUG \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -DSCHEMADATADIR=\"$(top_srcdir)/data/\" noinst_PROGRAMS = \ test-unity-webapps-permissions test_unity_webapps_permissions_SOURCES = \ test-unity-webapps-permissions.c test_unity_webapps_permissions_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps/libunity-webapps.la TESTS = $(noinst_PROGRAMS) libunity-webapps-2.5.0~+14.04.20140409/tests/libunity-webapps/test-unity-webapps-permissions.c0000644000015301777760000001214712321247333032561 0ustar pbusernogroup00000000000000/* * test-unity-webapps-permissions.c * Copyright (C) Canonical LTD 2013 * * Author: Alexandre Abreu * * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #define G_SETTINGS_ENABLE_BACKEND #include #include "unity-webapps-permissions.h" #include "unity-webapps-debug.h" static void test_permissions_integration_allowed (void) { g_assert (unity_webapps_permissions_is_integration_allowed()); } static void test_permissions_integration_allowed_set_get (void) { unity_webapps_permissions_set_integration_allowed(TRUE); g_assert (unity_webapps_permissions_is_integration_allowed()); unity_webapps_permissions_set_integration_allowed(FALSE); g_assert (!unity_webapps_permissions_is_integration_allowed()); } static void test_permissions_integration_allow_disallow_domain (void) { const char *DOMAIN_NAME = "mydomain.com"; g_assert (!unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); unity_webapps_permissions_allow_domain(DOMAIN_NAME); g_assert (unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); g_assert (!unity_webapps_permissions_get_domain_dontask(DOMAIN_NAME)); unity_webapps_permissions_remove_domain_from_permissions(DOMAIN_NAME); g_assert (!unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); g_assert (!unity_webapps_permissions_get_domain_dontask(DOMAIN_NAME)); } static void test_permissions_integration_allow_domain_multiple_times (void) { // make sure not added multiple times unity_webapps_permissions_allow_domain("mydomain.com"); unity_webapps_permissions_allow_domain("mydomain.com"); unity_webapps_permissions_allow_domain("mydomain.com"); unity_webapps_permissions_allow_domain("mydomain.com"); g_assert(0 == g_strcmp0(unity_webapps_permissions_get_all_domains(), "{\"allowed\":[\"mydomain.com\"],\"dontask\":[]}") ); } static void test_permissions_integration_dontask_domain (void) { const char *DOMAIN_NAME = "mydomain.com"; g_assert (!unity_webapps_permissions_get_domain_dontask(DOMAIN_NAME)); unity_webapps_permissions_dontask_domain(DOMAIN_NAME); g_assert (!unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); g_assert (unity_webapps_permissions_get_domain_dontask(DOMAIN_NAME)); unity_webapps_permissions_remove_domain_from_permissions(DOMAIN_NAME); g_assert (!unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); } static void test_permissions_integration_allowed_domain_added_to_dontask (void) { const char *DOMAIN_NAME = "mydomain.com"; g_assert (!unity_webapps_permissions_get_domain_dontask(DOMAIN_NAME)); g_assert (!unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); unity_webapps_permissions_allow_domain("mydomain.com"); g_assert (!unity_webapps_permissions_get_domain_dontask(DOMAIN_NAME)); g_assert (unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); unity_webapps_permissions_dontask_domain(DOMAIN_NAME); g_assert (!unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); g_assert (unity_webapps_permissions_get_domain_dontask(DOMAIN_NAME)); unity_webapps_permissions_remove_domain_from_permissions(DOMAIN_NAME); g_assert (!unity_webapps_permissions_get_domain_allowed(DOMAIN_NAME)); g_assert (!unity_webapps_permissions_get_domain_dontask(DOMAIN_NAME)); } int main (int argc, char **argv) { g_type_init (); // remove giomodule warning g_io_extension_point_register(G_SETTINGS_BACKEND_EXTENSION_POINT_NAME); g_test_init (&argc, &argv, NULL); unity_webapps_permissions_tests_use_memory_backend( g_build_path("/", g_get_current_dir(), SCHEMADATADIR, NULL)); g_test_add_func("/Permissions/IntegrationAllowed/Basic", test_permissions_integration_allowed); g_test_add_func("/Permissions/IntegrationAllowed/SetGet", test_permissions_integration_allowed_set_get); g_test_add_func("/Permissions/AllowDomain/GetSet", test_permissions_integration_allow_disallow_domain); g_test_add_func("/Permissions/AllowDomain/MultipleTimes", test_permissions_integration_allow_domain_multiple_times); g_test_add_func("/Permissions/AllowDomain/DontAskDomain", test_permissions_integration_dontask_domain); g_test_add_func("/Permissions/AllowDomain/AllowedDomainAddedToDontask", test_permissions_integration_allowed_domain_added_to_dontask); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/repository/0000755000015301777760000000000012321250157023172 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/Makefile.am0000644000015301777760000000012512321247333025226 0ustar pbusernogroup00000000000000SUBDIRS=application-manifest available-application local-index application-repositorylibunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-manifest/0000755000015301777760000000000012321250157027301 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-manifest/Makefile.am0000644000015301777760000000160312321247333031337 0ustar pbusernogroup00000000000000EXTRA_DIST=test-manifest-1.json DBUS_RUNNER=dbus-test-runner --max-wait=0 AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ -DUNITY_WEBAPPS_ENABLE_DEBUG \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/context-daemon/util \ -I$(top_srcdir)/src/libunity-webapps-repository/ \ -DUNITY_WEBAPPS_TEST_BUILD \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -DTESTDATADIR=\"$(top_srcdir)/tests/repository/application-manifest/\" REAL_TESTS = \ test-application-manifest RUNNER_TESTS = noinst_PROGRAMS = \ $(REAL_TESTS) test_application_manifest_SOURCES = \ test-application-manifest.c test_application_manifest_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps-repository/libunity-webapps-repository.la TESTS = $(RUNNER_TESTS) $(REAL_TESTS) CLEANFILES = $(RUNNER_TESTS) $(REAL_TESTS) libunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-manifest/test-manifest-1.json0000644000015301777760000000027612321247333033124 0ustar pbusernogroup00000000000000{ "integration-version": "666", "name": "TestApplication", "domain" : "test.ts", "package-name": "test-application", "includes": ["http://webapps.ubuntu.com/*"], "scripts": [""] } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-manifest/test-application-manifest.clibunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-manifest/test-application-manife0000644000015301777760000000341112321247333033742 0ustar pbusernogroup00000000000000#include #include "unity-webapps-application-manifest.h" #include "unity-webapps-debug.h" typedef struct _ManifestTestFixture { UnityWebappsApplicationManifest *manifest; } ManifestTestFixture; static void setup_fixture_simple (ManifestTestFixture *fixture, gconstpointer user_data) { gboolean loaded; fixture->manifest = unity_webapps_application_manifest_new (); loaded = unity_webapps_application_manifest_load_from_file (fixture->manifest, TESTDATADIR "test-manifest-1.json"); g_assert (loaded); } static void teardown_fixture_simple (ManifestTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->manifest)); } static void test_load_simple_manifest_names_1 (ManifestTestFixture *fixture, gconstpointer user_data) { g_assert_cmpstr ("TestApplication", ==, unity_webapps_application_manifest_get_name (fixture->manifest)); g_assert_cmpstr ("unity-webapps-test-application", ==, unity_webapps_application_manifest_get_package_name (fixture->manifest)); } static void test_load_simple_manifest_domain_1 (ManifestTestFixture *fixture, gconstpointer user_data) { g_assert_cmpstr ("test.ts", ==, unity_webapps_application_manifest_get_domain (fixture->manifest)); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); unity_webapps_debug_initialize_flags (); g_test_add("/Applications/Manifest/Simple/Names", ManifestTestFixture, NULL, setup_fixture_simple, test_load_simple_manifest_names_1, teardown_fixture_simple); g_test_add("/Applications/Manifest/Simple/Domain", ManifestTestFixture, NULL, setup_fixture_simple, test_load_simple_manifest_domain_1, teardown_fixture_simple); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/0000755000015301777760000000000012321250157025371 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/Makefile.am0000644000015301777760000000267412321247333027440 0ustar pbusernogroup00000000000000EXTRA_DIST=\ test-collection-1/webapps-cut-the-rope/manifest.json\ test-collection-1/webapps-facebook/manifest.json\ test-collection-1/webapps-google-docs/manifest.json\ test-collection-1/webapps-lastfm/manifest.json\ test-collection-1/webapps-launchpad/manifest.json\ test-collection-1/webapps-reddit/manifest.json DBUS_RUNNER=dbus-test-runner --max-wait=0 AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ -DUNITY_WEBAPPS_ENABLE_DEBUG \ -DTEST_DATA=\"`readlink -f $(srcdir)`/test-collection-1\" \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/context-daemon/util \ -I$(top_srcdir)/src/libunity-webapps-repository/ \ -DUNITY_WEBAPPS_TEST_BUILD \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) REAL_TESTS = \ test-application-collector \ test-local-url-index RUNNER_TESTS = noinst_PROGRAMS = \ $(REAL_TESTS) test_local_url_index_SOURCES = \ test-local-url-index.c test_local_url_index_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps-repository/libunity-webapps-repository.la test_application_collector_SOURCES = \ test-application-collector.c test_application_collector_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps-repository/libunity-webapps-repository.la TESTS = $(RUNNER_TESTS) $(REAL_TESTS) CLEANFILES = $(RUNNER_TESTS) $(REAL_TESTS) libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-local-url-index.c0000644000015301777760000000322012321247333031510 0ustar pbusernogroup00000000000000#include #include "unity-webapps-application-collector.h" #include "unity-webapps-local-url-index.h" #include "unity-webapps-debug.h" typedef struct _ManifestTestFixture { UnityWebappsApplicationCollector *collector; UnityWebappsLocalUrlIndex *index; } ManifestTestFixture; static void setup_fixture_simple (ManifestTestFixture *fixture, gconstpointer user_data) { const gchar *path[] = {TEST_DATA, NULL}; fixture->collector = unity_webapps_application_collector_new (path); fixture->index = (UnityWebappsLocalUrlIndex *) unity_webapps_local_url_index_new (fixture->collector); g_assert (unity_webapps_local_url_index_load_applications (fixture->index)); } static void teardown_fixture_simple (ManifestTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->index)); } static void test_query_simple_collection_1 (ManifestTestFixture *fixture, gconstpointer user_data) { GList *applications; UnityWebappsAvailableApplication *app; applications = unity_webapps_url_index_lookup_url (UNITY_WEBAPPS_URL_INDEX (fixture->index), "https://docs.google.com/"); g_assert (g_list_length (applications) == 1); app = (UnityWebappsAvailableApplication *)applications->data; g_assert_cmpstr ("unity-webapps-google-docs", ==, unity_webapps_available_application_get_name (app)); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); unity_webapps_debug_initialize_flags (); g_test_add("/Applications/Index/Local/Query", ManifestTestFixture, NULL, setup_fixture_simple, test_query_simple_collection_1, teardown_fixture_simple); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-application-collector.c0000644000015301777760000000234212321247333033004 0ustar pbusernogroup00000000000000#include #include "unity-webapps-application-manifest.h" #include "unity-webapps-application-collector.h" #include "unity-webapps-debug.h" typedef struct _ManifestTestFixture { UnityWebappsApplicationCollector *collector; } ManifestTestFixture; static void setup_fixture_simple (ManifestTestFixture *fixture, gconstpointer user_data) { const gchar *path[] = {TEST_DATA, NULL}; fixture->collector = unity_webapps_application_collector_new (path); } static void teardown_fixture_simple (ManifestTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->collector)); } static void test_load_simple_collection_1 (ManifestTestFixture *fixture, gconstpointer user_data) { g_assert (unity_webapps_application_collector_search_path (fixture->collector)); g_assert (g_hash_table_size (unity_webapps_application_collector_get_applications (fixture->collector)) == 6); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); unity_webapps_debug_initialize_flags (); g_test_add("/Applications/Collector/Simple/Load", ManifestTestFixture, NULL, setup_fixture_simple, test_load_simple_collection_1, teardown_fixture_simple); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/0000755000015301777760000000000012321250157030637 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-facebook/libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-facebo0000755000015301777760000000000012321250157033436 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016500000000000011217 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-facebook/manifest.jsonlibunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-facebo0000644000015301777760000000102712321247333033442 0ustar pbusernogroup00000000000000{ "version" : "2.1", "name" : "Facebook", "package-name": "facebook", "domain": "facebook.com", "description": "Facebook Unity Integration", "homepage" : "www.facebook.com", "includes" : ["http://www.facebook.com/*", "https://www.facebook.com/*"], "integration-author" : "Webapps Team", "integration-version" : "2.1", "scripts": ["FacebookMessenger.user.js"], "requires": ["utils.js"], "icons": {"128": "facebook-128.png", "64": "facebook-64.png", "52": "facebook-52.png", "48": "facebook-48.png"} }././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-cut-the-rope/libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-cut-th0000755000015301777760000000000012321250157033423 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000017100000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-cut-the-rope/manifest.jsonlibunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-cut-th0000644000015301777760000000102712321247333033427 0ustar pbusernogroup00000000000000{ "version" : "2.1", "name" : "Cut the Rope", "domain" : "cuttherope.ie", "package-name": "cut-the-rope", "description": "Cut the Rope Unity Integration", "homepage" : "http//www.cuttherope.ie", "includes" : ["http://*.cuttherope.ie/*"], "integration-author" : "Webapps Team", "integration-version" : "2.1", "scripts": ["CutTheRope.user.js"], "requires": ["utils.js"], "icons": {"128": "cut-the-rope-128.png", "64": "cut-the-rope-64.png", "52": "cut-the-rope-52.png", "48": "cut-the-rope-48.png"} }././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-lastfm/libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-lastfm0000755000015301777760000000000012321250157033505 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016300000000000011215 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-lastfm/manifest.jsonlibunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-lastfm0000644000015301777760000000104112321247333033505 0ustar pbusernogroup00000000000000{ "version" : "2.1", "name" : "Last.fm", "package-name": "lastfm", "domain": "last.fm", "description": "last.fm Unity Integration", "homepage" : "http//www.last.fm", "includes" : ["http://last.fm/*", "https://last.fm/*", "http://*.last.fm/*", "https://*.last.fm/*"], "integration-author" : "Webapps Team", "integration-version" : "2.1", "scripts": ["lastfm-radio.user.js"], "requires": ["utils.js"], "icons": {"128": "last-fm-128.png", "64": "last-fm-64.png", "52": "last-fm-52.png", "48": "last-fm-48.png"} }././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-google-docs/libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-google0000755000015301777760000000000012321250157033473 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000017000000000000011213 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-google-docs/manifest.jsonlibunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-google0000644000015301777760000000065612321247333033506 0ustar pbusernogroup00000000000000{ "version" : "2.1", "name" : "Google Docs", "package-name": "google-docs", "domain": "docs.google.com", "description": "Google Docs Store Unity Integration", "homepage" : "http//www.docs.google.com", "includes" : ["https://docs.google.com/*"], "integration-author" : "Webapps Team", "integration-version" : "2.1", "scripts": ["GoogleDocs.user.js"], "requires": ["utils.js", "google-common.js"] }././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-launchpad/libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-launch0000755000015301777760000000000012321250157033471 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016600000000000011220 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-launchpad/manifest.jsonlibunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-launch0000644000015301777760000000102712321247333033475 0ustar pbusernogroup00000000000000{ "version" : "2.1", "name" : "Launchpad", "package-name": "launchpad", "domain": "launchpad.net", "description": "Launchpad Unity Integration", "homepage" : "http//launchpad.net", "includes" : ["https://*.launchpad.net/*", "https://launchpad.net/*"], "integration-author" : "Webapps Team", "integration-version" : "2.1", "scripts": ["Launchpad.user.js"], "requires": ["utils.js"], "icons": {"128": "launchpad-128.png", "64": "launchpad-64.png", "52": "launchpad-52.png", "48": "launchpad-48.png"} }././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-reddit/libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-reddit0000755000015301777760000000000012321250157033472 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016300000000000011215 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-reddit/manifest.jsonlibunity-webapps-2.5.0~+14.04.20140409/tests/repository/local-index/test-collection-1/webapps-reddit0000644000015301777760000000076612321247333033507 0ustar pbusernogroup00000000000000{ "version" : "2.1", "name" : "reddit", "domain" : "reddit.com", "package-name": "reddit", "description": "reddit Unity Integration", "homepage" : "http//www.reddit.com", "includes" : ["http://*.reddit.com/*", "http://reddit.com/*"], "integration-author" : "Webapps Team", "integration-version" : "2.1", "scripts": ["Reddit.user.js"], "requires": ["utils.js"], "icons": {"128": "reddit-128.png", "64": "reddit-64.png", "52": "reddit-52.png", "48": "reddit-48.png"} }libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/0000755000015301777760000000000012321250157027413 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/unity-webapps/0000755000015301777760000000000012321250157032222 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/unity-webapps/userscripts/libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/unity-webapps/userscri0000755000015301777760000000000012321250157034002 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/unity-webapps/userscripts/common/libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/unity-webapps/userscri0000755000015301777760000000000012321250157034002 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000017100000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/unity-webapps/userscripts/common/common.jslibunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/unity-webapps/userscri0000644000015301777760000000011112321247333033777 0ustar pbusernogroup00000000000000var f = function (a) { console.log('common function'); return a; }; libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/Makefile.am0000644000015301777760000000253012321247333031451 0ustar pbusernogroup00000000000000EXTRA_DIST=test-manifest-1.json test-manifest-with-scripts.json userscript-content.js unity-webapps/userscripts/common/common.js DBUS_RUNNER=dbus-test-runner --max-wait=0 AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ -DUNITY_WEBAPPS_ENABLE_DEBUG \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/context-daemon/util \ -I$(top_srcdir)/src/libunity-webapps-repository/ \ -DUNITY_WEBAPPS_TEST_BUILD \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -DTESTDATADIR=\"$(top_srcdir)/tests/repository/available-application/\" REAL_TESTS = \ test-local-available-application \ test-local-available-script-loader RUNNER_TESTS = noinst_PROGRAMS = \ $(REAL_TESTS) test_local_available_application_SOURCES = \ test-local-available-application.c test_local_available_application_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps-repository/libunity-webapps-repository.la test_local_available_script_loader_SOURCES = \ test-local-available-script-loader.c test_local_available_script_loader_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps-repository/libunity-webapps-repository.la TESTS = $(RUNNER_TESTS) $(REAL_TESTS) CLEANFILES = $(RUNNER_TESTS) $(REAL_TESTS) libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/test-manifest-1.json0000644000015301777760000000026312321247333033232 0ustar pbusernogroup00000000000000{ "integration-version": "666", "name": "TestApplication", "domain": "test.ts", "package-name": "test-application", "includes": ["http://www.test.ts/*"], "scripts": [""] } ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/test-manifest-with-scripts.jsonlibunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/test-manifest-with-scr0000644000015301777760000000035312321247333033662 0ustar pbusernogroup00000000000000{ "integration-version": "666", "name": "TestApplication", "domain": "test.ts", "package-name": "test-application", "includes": ["http://www.test.ts/*"], "scripts": ["userscript-content.js"], "requires": ["common.js"] } ././@LongLink0000000000000000000000000000016100000000000011213 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/test-local-available-application.clibunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/test-local-available-a0000644000015301777760000000270112321247333033543 0ustar pbusernogroup00000000000000#include #include "unity-webapps-application-manifest.h" #include "unity-webapps-local-available-application.h" #include "unity-webapps-debug.h" typedef struct _AvailableApplicationTestFixture { UnityWebappsLocalAvailableApplication *app; } AvailableApplicationTestFixture; static void setup_fixture_simple (AvailableApplicationTestFixture *fixture, gconstpointer user_data) { fixture->app = (UnityWebappsLocalAvailableApplication *) unity_webapps_local_available_application_new ( unity_webapps_application_manifest_new_from_file (TESTDATADIR "test-manifest-1.json")); } static void teardown_fixture_simple (AvailableApplicationTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->app)); } static void test_load_simple_application_patternspecs_1 (AvailableApplicationTestFixture *fixture, gconstpointer user_data) { g_assert (unity_webapps_local_available_application_provides_url (fixture->app, "http://www.test.ts/*")); g_assert (unity_webapps_local_available_application_provides_url (fixture->app, "https://bar.bz") == FALSE); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); unity_webapps_debug_initialize_flags (); g_test_add("/Applications/Available/Local/PatternSpecs", AvailableApplicationTestFixture, NULL, setup_fixture_simple, test_load_simple_application_patternspecs_1, teardown_fixture_simple); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/userscript-content.js0000644000015301777760000000003412321247333033623 0ustar pbusernogroup00000000000000var test = function () { }; ././@LongLink0000000000000000000000000000016300000000000011215 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/test-local-available-script-loader.clibunity-webapps-2.5.0~+14.04.20140409/tests/repository/available-application/test-local-available-s0000644000015301777760000000424712321247333033574 0ustar pbusernogroup00000000000000#include #include "unity-webapps-application-manifest.h" #include "unity-webapps-local-available-application.h" #include "unity-webapps-script-loader.h" #include "unity-webapps-debug.h" typedef struct _AvailableApplicationTestFixture { UnityWebappsLocalAvailableApplication *app; UnityWebappsScriptLoader *script_loader; } AvailableApplicationTestFixture; static void setup_fixture_simple (AvailableApplicationTestFixture *fixture, gconstpointer user_data) { fixture->app = (UnityWebappsLocalAvailableApplication *) unity_webapps_local_available_application_new ( unity_webapps_application_manifest_new_from_file ( TESTDATADIR "test-manifest-with-scripts.json")); fixture->script_loader = unity_webapps_script_loader_new (); } static void teardown_fixture_simple (AvailableApplicationTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->app)); g_object_unref (G_OBJECT (fixture->script_loader)); } static void test_load_script_with_requires (AvailableApplicationTestFixture *fixture, gconstpointer user_data) { gchar *content = unity_webapps_script_loader_get_userscript_contents ( fixture->script_loader, fixture->app); g_assert (0 == g_strcmp0(content, "\n// imported script: common.js" "\nvar f = function (a) {" "\n console.log('common function');" "\n return a;" "\n};" "\n" "\nvar test = function () {\n" "};\n")); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); g_setenv("UNITY_WEBAPPS_CONTEXT_USER_DIR", g_get_current_dir(), TRUE); unity_webapps_debug_initialize_flags (); g_test_add("/Applications/Available/Local/LoadScriptContentWithRequires", AvailableApplicationTestFixture, NULL, setup_fixture_simple, test_load_script_with_requires, teardown_fixture_simple); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-repository/0000755000015301777760000000000012321250157027712 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-repository/Makefile.am0000644000015301777760000000144512321247333031754 0ustar pbusernogroup00000000000000DBUS_RUNNER=dbus-test-runner --max-wait=0 AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ -DUNITY_WEBAPPS_ENABLE_DEBUG \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/context-daemon/util \ -I$(top_srcdir)/src/libunity-webapps-repository/ \ -DUNITY_WEBAPPS_TEST_BUILD \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) REAL_TESTS = \ test-application-repository RUNNER_TESTS = noinst_PROGRAMS = \ $(REAL_TESTS) test_application_repository_SOURCES = \ test-application-repository.c test_application_repository_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ $(top_builddir)/src/libunity-webapps-repository/libunity-webapps-repository.la TESTS = $(REAL_TESTS) $(RUNNER_TESTS) CLEANFILES = $(RUNNER_TESTS) $(REAL_TESTS) ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-repository/test-application-repository.clibunity-webapps-2.5.0~+14.04.20140409/tests/repository/application-repository/test-application-repo0000644000015301777760000000222012321247333034056 0ustar pbusernogroup00000000000000#include #include "unity-webapps-application-collector.h" #include "unity-webapps-local-url-index.h" #include "unity-webapps-application-repository.h" #include "unity-webapps-debug.h" typedef struct _RepositoryTestFixture { UnityWebappsApplicationRepository *repository; } RepositoryTestFixture; static void setup_fixture_simple (RepositoryTestFixture *fixture, gconstpointer user_data) { fixture->repository = unity_webapps_application_repository_new_default(); // unity_webapps_application_repository_prepare (fixture->repository); } static void teardown_fixture_simple (RepositoryTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->repository)); } static void test_resolve_simple_collection_1 (RepositoryTestFixture *fixture, gconstpointer user_data) { } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); unity_webapps_debug_initialize_flags (); g_test_add("/Applications/Repository/Resolvve", RepositoryTestFixture, NULL, setup_fixture_simple, test_resolve_simple_collection_1, teardown_fixture_simple); // return g_test_run (); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/misc/0000755000015301777760000000000012321250157021706 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/misc/Makefile.am0000644000015301777760000000103312321247333023741 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ -DUNITY_WEBAPPS_ENABLE_DEBUG \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) noinst_PROGRAMS = \ test-desktop-infos-util test_desktop_infos_util_SOURCES = \ $(top_srcdir)/src/unity-webapps-desktop-infos.c \ $(top_srcdir)/src/unity-webapps-string-utils.c \ test-desktop-infos-util.c test_desktop_infos_util_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) TESTS = $(noinst_PROGRAMS) libunity-webapps-2.5.0~+14.04.20140409/tests/misc/test-desktop-infos-util.c0000644000015301777760000000355512321247333026601 0ustar pbusernogroup00000000000000/* * test-desktop-infos.c * Copyright (C) Canonical LTD 2011 * * Author: Alexandre Abreu * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include "unity-webapps-desktop-infos.h" #include "unity-webapps-debug.h" static void test_desktop_basename_onename_nospaces (void) { const gchar * name = "simplename"; const gchar * domain = "my.simple.domain"; g_assert_cmpstr ("simplenamemysimpledomain", ==, unity_webapps_desktop_infos_build_desktop_basename (name, domain)); } static void test_desktop_basename_onename_spaces (void) { const gchar * name = "simpl\t\ten ame"; const gchar * domain = "my.simple.domain"; g_assert_cmpstr ("simplenamemysimpledomain", ==, unity_webapps_desktop_infos_build_desktop_basename (name, domain)); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); g_test_add_func("/DesktopInfos/Basic/OneName/NoSpaces", test_desktop_basename_onename_nospaces); g_test_add_func("/DesktopInfos/Basic/OneName/Spaces", test_desktop_basename_onename_spaces); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/0000755000015301777760000000000012321250157023700 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-window-tracker-mock.c0000644000015301777760000000553012321247333032545 0ustar pbusernogroup00000000000000/* * unity-webapps-action-tracker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-window-tracker-mock.h" #include "../unity-webapps-debug.h" struct _UnityWebappsWindowTrackerMockPrivate { guint64 active_window_id; }; G_DEFINE_TYPE(UnityWebappsWindowTrackerMock, unity_webapps_window_tracker_mock, UNITY_WEBAPPS_TYPE_WINDOW_TRACKER) #define UNITY_WEBAPPS_WINDOW_TRACKER_MOCK_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK, UnityWebappsWindowTrackerMockPrivate)) static void unity_webapps_window_tracker_mock_finalize (GObject *object) { } static guint64 unity_webapps_window_tracker_mock_get_active_window_id (UnityWebappsWindowTracker *tracker) { UnityWebappsWindowTrackerMock *self; self = UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (tracker); return self->priv->active_window_id; } static void unity_webapps_window_tracker_mock_class_init (UnityWebappsWindowTrackerMockClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsWindowTrackerClass *window_tracker_class = UNITY_WEBAPPS_WINDOW_TRACKER_CLASS (klass); object_class->finalize = unity_webapps_window_tracker_mock_finalize; window_tracker_class->get_active_window_id = unity_webapps_window_tracker_mock_get_active_window_id; g_type_class_add_private (object_class, sizeof(UnityWebappsWindowTrackerMockPrivate)); } static void unity_webapps_window_tracker_mock_init (UnityWebappsWindowTrackerMock *tracker) { tracker->priv = UNITY_WEBAPPS_WINDOW_TRACKER_MOCK_GET_PRIVATE (tracker); tracker->priv->active_window_id = 0; } UnityWebappsWindowTrackerMock * unity_webapps_window_tracker_mock_new () { return g_object_new (UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK, NULL); } void unity_webapps_window_tracker_mock_set_active_window (UnityWebappsWindowTrackerMock *tracker, guint64 window_id) { g_return_if_fail (UNITY_WEBAPPS_IS_WINDOW_TRACKER_MOCK (tracker)); tracker->priv->active_window_id = window_id; g_object_notify (G_OBJECT (tracker), "active-window-id"); } libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/test-action-manager.c0000644000015301777760000005266412321247333027725 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-action-manager.h" #include "unity-webapps-interest-manager.h" #include "unity-webapps-interest-tracker.h" #include "unity-webapps-window-tracker.h" #include "unity-webapps-window-tracker-mock.h" #include "unity-webapps-debug.h" typedef struct _ActionTestFixture { UnityWebappsActionManager *action_manager; UnityWebappsInterestManager *interest_manager; UnityWebappsInterestTracker *interest_tracker; UnityWebappsWindowTrackerMock *window_tracker; gint interest_one; gint interest_two; gint interest_three; } ActionTestFixture; static void setup_fixture_no_server_flat_single_interest (ActionTestFixture *fixture, gconstpointer user_data) { UnityWebappsInterestTracker *tracker; gchar *menu_path; gboolean use_hierarchy, track_activity; fixture->interest_manager = unity_webapps_interest_manager_new (); fixture->interest_tracker = unity_webapps_interest_tracker_new (unity_webapps_window_tracker_get_default (), fixture->interest_manager); fixture->action_manager = unity_webapps_action_manager_new_flat (fixture->interest_tracker, NULL); fixture->window_tracker = UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (unity_webapps_window_tracker_get_default ()); unity_webapps_window_tracker_mock_set_active_window (fixture->window_tracker, 1); fixture->interest_one = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":1"); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->interest_one, 1); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->interest_one, TRUE); g_object_get (fixture->action_manager, "menu-path", &menu_path, "use-hierarchy", &use_hierarchy, "track-activity", &track_activity, "interest-tracker", &tracker, NULL); g_assert (menu_path == NULL); g_assert (use_hierarchy == FALSE); g_assert (track_activity == TRUE); g_assert (tracker == fixture->interest_tracker); } static void setup_fixture_no_server_flat_multi_interest (ActionTestFixture *fixture, gconstpointer user_data) { UnityWebappsInterestTracker *tracker; gchar *menu_path; gboolean use_hierarchy, track_activity; fixture->interest_manager = unity_webapps_interest_manager_new (); fixture->interest_tracker = unity_webapps_interest_tracker_new (unity_webapps_window_tracker_get_default (), fixture->interest_manager); fixture->action_manager = unity_webapps_action_manager_new_flat (fixture->interest_tracker, NULL); fixture->window_tracker = UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (unity_webapps_window_tracker_get_default ()); unity_webapps_window_tracker_mock_set_active_window (fixture->window_tracker, 1); fixture->interest_one = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":1"); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->interest_one, 1); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->interest_one, TRUE); fixture->interest_two = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":2"); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->interest_two, 2); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->interest_two, TRUE); fixture->interest_three = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":3"); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->interest_three, 3); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->interest_three, TRUE); g_object_get (fixture->action_manager, "menu-path", &menu_path, "use-hierarchy", &use_hierarchy, "track-activity", &track_activity, "interest-tracker", &tracker, NULL); g_assert (menu_path == NULL); g_assert (use_hierarchy == FALSE); g_assert (track_activity == TRUE); g_assert (tracker == fixture->interest_tracker); } static void setup_fixture_no_server_hierarchal_single_interest (ActionTestFixture *fixture, gconstpointer user_data) { UnityWebappsInterestTracker *tracker; gchar *menu_path; gboolean use_hierarchy, track_activity; fixture->interest_manager = unity_webapps_interest_manager_new (); fixture->interest_tracker = unity_webapps_interest_tracker_new (unity_webapps_window_tracker_get_default (), fixture->interest_manager); fixture->action_manager = unity_webapps_action_manager_new (fixture->interest_tracker, NULL); fixture->window_tracker = UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (unity_webapps_window_tracker_get_default ()); unity_webapps_window_tracker_mock_set_active_window (fixture->window_tracker, 1); fixture->interest_one = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":1"); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->interest_one, 1); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->interest_one, TRUE); g_object_get (fixture->action_manager, "menu-path", &menu_path, "use-hierarchy", &use_hierarchy, "track-activity", &track_activity, "interest-tracker", &tracker, NULL); g_assert (menu_path == NULL); g_assert (use_hierarchy == TRUE); g_assert (track_activity == TRUE); g_assert (tracker == fixture->interest_tracker); } static gchar * print_action_manager (UnityWebappsActionManager *manager) { GVariant *serialized_variant; gchar *ret; serialized_variant = unity_webapps_action_manager_serialize (manager); ret = g_variant_print (serialized_variant, FALSE); g_variant_unref (serialized_variant); return ret; } static void assert_action_manager_equal (ActionTestFixture *fixture, const gchar *compare_to) { gchar *serialized; serialized = print_action_manager (fixture->action_manager); g_assert_cmpstr(serialized, ==, compare_to); g_free (serialized); } #define SINGLE_INTEREST_FLAT_SERIALIZED "([('Foo', 1, true)],)" static void test_single_interest_flat (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_FLAT_SERIALIZED); } #define SINGLE_INTEREST_FLAT_WHITESPACE_SERIALIZED "([('Foo', 1, true)],)" static void test_single_interest_flat_whitespace (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "\n \n Foo\n", fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_FLAT_SERIALIZED); } #define SINGLE_INTEREST_FLAT1_SERIALIZED "([('Bar', 1, true), ('Foo', 1, true)],)" static void test_single_interest_flat1 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_FLAT1_SERIALIZED); } #define SINGLE_INTEREST_FLAT2_SERIALIZED "([('Bar', 1, true)],)" static void test_single_interest_flat2 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_one); unity_webapps_action_manager_remove_action (fixture->action_manager, "Foo", fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_FLAT2_SERIALIZED); } #define SINGLE_INTEREST_FLAT3_SERIALIZED "([],)" static void test_single_interest_flat3 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_one); unity_webapps_interest_manager_remove_interest (fixture->interest_manager, fixture->interest_one, FALSE); assert_action_manager_equal (fixture, SINGLE_INTEREST_FLAT3_SERIALIZED); } #define SINGLE_INTEREST_FLAT4_SERIALIZED "([],)" static void test_single_interest_flat4 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_one); unity_webapps_action_manager_remove_all_actions (fixture->action_manager, fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_FLAT3_SERIALIZED); } #define MULTI_INTEREST_FLAT0_SERIALIZED "([('Foo', 2, true)],)" static void test_multi_interest_flat0 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_two); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT0_SERIALIZED); } #define MULTI_INTEREST_FLAT1_SERIALIZED "([('Foo', 1, true)],)" static void test_multi_interest_flat1 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_action_manager_remove_action (fixture->action_manager, "Foo", fixture->interest_two); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT1_SERIALIZED); } #define MULTI_INTEREST_FLAT2_SERIALIZED "([],)" static void test_multi_interest_flat2 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_action_manager_remove_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_action_manager_remove_action (fixture->action_manager, "Foo", fixture->interest_one); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT2_SERIALIZED); } #define MULTI_INTEREST_FLAT3_SERIALIZED "([('Foo', 1, true)],)" static void test_multi_interest_flat3 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_action_manager_remove_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_action_manager_remove_action (fixture->action_manager, "Foo", fixture->interest_two); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT3_SERIALIZED); } #define MULTI_INTEREST_FLAT4_SERIALIZED_0 "([('Foo', 1, false)],)" #define MULTI_INTEREST_FLAT4_SERIALIZED_1 "([('Foo', 1, true)],)" static void test_multi_interest_flat4 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_interest_manager_remove_interest (fixture->interest_manager, fixture->interest_one, FALSE); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT4_SERIALIZED_0); unity_webapps_window_tracker_mock_set_active_window (fixture->window_tracker, 2); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT4_SERIALIZED_1); } #define MULTI_INTEREST_FLAT5_SERIALIZED "([],)" static void test_multi_interest_flat5 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_interest_manager_remove_interest (fixture->interest_manager, fixture->interest_one, FALSE); unity_webapps_interest_manager_remove_interest (fixture->interest_manager, fixture->interest_two, FALSE); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT5_SERIALIZED); } #define MULTI_INTEREST_FLAT6_SERIALIZED "([('Bar', 1, true), ('Foo', 1, true)],)" static void test_multi_interest_flat6 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_action_manager_remove_all_actions (fixture->action_manager, fixture->interest_two); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT6_SERIALIZED); } #define MULTI_INTEREST_FLAT7_SERIALIZED "([('Bar', 1, false), ('Foo', 1, true)],)" static void test_multi_interest_flat7 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "Bar", fixture->interest_two); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT7_SERIALIZED); } #define MULTI_INTEREST_FLAT8_SERIALIZED "([('Foo', 2, true)],)" static void test_multi_interest_flat8 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "\nFoo", fixture->interest_two); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT8_SERIALIZED); } #define MULTI_INTEREST_FLAT9_SERIALIZED "([('Foo', 2, false)],)" static void test_multi_interest_flat9 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_two); unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_three); assert_action_manager_equal (fixture, MULTI_INTEREST_FLAT9_SERIALIZED); } #define SINGLE_INTEREST_HIERARCHAL_SERIALIZED "([('/Foo', 1, true), ('/Foo/Bar', 1, true)],)" static void test_single_interest_hierarchal (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "/Foo/Bar", fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_HIERARCHAL_SERIALIZED); } #define SINGLE_INTEREST_HIERARCHAL1_SERIALIZED "([('/Foo', 2, true), ('/Foo/Bar', 1, true)],)" static void test_single_interest_hierarchal1 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "/Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "/Foo/Bar", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "/Foo/Bar", fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_HIERARCHAL1_SERIALIZED); } #define SINGLE_INTEREST_HIERARCHAL2_SERIALIZED "([],)" static void test_single_interest_hierarchal2 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "%Foo/Bar", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "/Foo/Bar/Baz/This/Is/So/Long", fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_HIERARCHAL2_SERIALIZED); } #define SINGLE_INTEREST_HIERARCHAL3_SERIALIZED "([('/Foo', 3, true), ('/Foo/Bar', 2, true), ('/Foo/Bar/Baz', 1, true), ('/Foo/Bar/Boy', 1, true)],)" static void test_single_interest_hierarchal3 (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_action_manager_add_action (fixture->action_manager, "/Foo", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "/Foo/Bar/Baz", fixture->interest_one); unity_webapps_action_manager_add_action (fixture->action_manager, "/Foo/Bar/Boy", fixture->interest_one); assert_action_manager_equal (fixture, SINGLE_INTEREST_HIERARCHAL3_SERIALIZED); } static void teardown_fixture_single_interest (ActionTestFixture *fixture, gconstpointer user_data) { unity_webapps_interest_manager_remove_interest (fixture->interest_manager, fixture->interest_one, FALSE); assert_action_manager_equal (fixture, "([],)"); g_object_unref (G_OBJECT (fixture->action_manager)); g_object_unref (G_OBJECT (fixture->interest_manager)); g_object_unref (G_OBJECT (fixture->interest_tracker)); } static void teardown_fixture (ActionTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->action_manager)); g_object_unref (G_OBJECT (fixture->interest_manager)); g_object_unref (G_OBJECT (fixture->interest_tracker)); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); unity_webapps_debug_initialize_flags (); g_test_add("/Actions/Flat/SingleInterestAddOne", ActionTestFixture, NULL, setup_fixture_no_server_flat_single_interest, test_single_interest_flat, teardown_fixture_single_interest); g_test_add("/Actions/Flat/SingleInterestWhitespace", ActionTestFixture, NULL, setup_fixture_no_server_flat_single_interest, test_single_interest_flat_whitespace, teardown_fixture_single_interest); g_test_add("/Actions/Flat/SingleInterestAddTwo", ActionTestFixture, NULL, setup_fixture_no_server_flat_single_interest, test_single_interest_flat1, teardown_fixture_single_interest); g_test_add("/Actions/Flat/SingleInterestAddTwoRemoveOne", ActionTestFixture, NULL, setup_fixture_no_server_flat_single_interest, test_single_interest_flat2, teardown_fixture_single_interest); g_test_add("/Actions/Flat/SingleInterestAddTwoRemoveInterest", ActionTestFixture, NULL, setup_fixture_no_server_flat_single_interest, test_single_interest_flat3, teardown_fixture_single_interest); g_test_add("/Actions/Flat/SingleInterestAddTwoRemoveAll", ActionTestFixture, NULL, setup_fixture_no_server_flat_single_interest, test_single_interest_flat4, teardown_fixture_single_interest); g_test_add("/Actions/Flat/MultiInterest/AddOneTwice", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat0, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/AddOneTwiceRemoveOnce", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat1, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/AddOneTwiceRemoveTwice", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat2, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/AddOneTwiceRemoveTwiceSameOwner", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat3, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/AddTwoTwiceRemoveOneInterest", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat4, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/AddTwoTwiceRemoveBothInterest", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat5, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/AddManyTwiceRemoveAllOnce", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat6, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/AddTwoOneInvisible", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat7, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/PathNormalization", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat8, teardown_fixture); g_test_add("/Actions/Flat/MultiInterest/AddHidden", ActionTestFixture, NULL, setup_fixture_no_server_flat_multi_interest, test_multi_interest_flat9, teardown_fixture); g_test_add("/Actions/Hierarchal/SingleInterestAddOne", ActionTestFixture, NULL, setup_fixture_no_server_hierarchal_single_interest, test_single_interest_hierarchal, teardown_fixture_single_interest); g_test_add("/Actions/Hierarchal/SingleInterestAddTwoManyTimes", ActionTestFixture, NULL, setup_fixture_no_server_hierarchal_single_interest, test_single_interest_hierarchal1, teardown_fixture_single_interest); g_test_add("/Actions/Hierarchal/SingleInterestInvalidActions", ActionTestFixture, NULL, setup_fixture_no_server_hierarchal_single_interest, test_single_interest_hierarchal2, teardown_fixture_single_interest); g_test_add("/Actions/Hierarchal/SingleInterestDeepActions", ActionTestFixture, NULL, setup_fixture_no_server_hierarchal_single_interest, test_single_interest_hierarchal3, teardown_fixture_single_interest); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/Makefile.am0000644000015301777760000001230112321247333025733 0ustar pbusernogroup00000000000000DBUS_RUNNER=dbus-test-runner --max-wait=0 EXTRA_DIST = unity-webapps-applications/index.theme AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ -DUNITY_WEBAPPS_ENABLE_DEBUG \ -DTEST_SRCDIR=\"`readlink -f $(srcdir)`\" \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/context-daemon \ -I$(top_srcdir)/src/context-daemon/resource-cache \ -I$(top_srcdir)/src/context-daemon/util \ -I$(top_srcdir)/src/context-daemon/interest-tracking \ -I$(top_srcdir)/src/context-daemon/indicator \ -I$(top_srcdir)/src/context-daemon/presence \ -DUNITY_WEBAPPS_TEST_BUILD \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) REAL_TESTS = \ test-action-manager \ test-indicator-model \ test-indicator-model-controller \ test-interest-manager \ test-interest-tracker RUNNER_TESTS = \ test-application-info-runner noinst_PROGRAMS = \ $(REAL_TESTS) \ test-application-info test-application-info-runner: test-application-info @echo "#!/bin/sh" > $@ @echo export G_DEBUG=fatal_criticals >> $@ @echo xvfb-run $(DBUS_RUNNER) --task ./test-application-info >> $@ @echo rm -Rf test-output-files >> $@ @chmod +x $@ test_application_info_SOURCES = \ test-application-info.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-dirs.c \ $(top_srcdir)/src/unity-webapps-app-db.c \ $(top_srcdir)/src/unity-webapps-string-utils.c \ $(top_srcdir)/src/unity-webapps-desktop-infos.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-db.c \ $(top_srcdir)/src/context-daemon/unity-webapps-application-info.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-icon-theme.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-cache.c \ $(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-factory.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-gio-utils.c \ $(top_srcdir)/src/context-daemon/unity-webapps-debug.c test_application_info_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) test_action_manager_SOURCES = \ test-action-manager.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.c \ unity-webapps-window-tracker-mock.c \ unity-webapps-window-tracker-mock.h \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-tracker.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-manager.c \ $(top_srcdir)/src/unity-webapps-string-utils.c \ $(top_srcdir)/src/unity-webapps-desktop-infos.c \ $(top_srcdir)/src/context-daemon/unity-webapps-action-manager.c \ $(top_srcdir)/src/context-daemon/unity-webapps-debug.c test_action_manager_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) test_indicator_model_SOURCES = \ test-indicator-model.c \ $(top_srcdir)/src/context-daemon/indicator/unity-webapps-indicator-model.c test_indicator_model_LDADD = \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) test_indicator_model_controller_SOURCES = \ test-indicator-model-controller.c \ $(top_srcdir)/src/context-daemon/indicator/unity-webapps-indicator-model.c \ $(top_srcdir)/src/context-daemon/indicator/unity-webapps-indicator-model-controller.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-manager.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-tracker.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.c \ unity-webapps-window-tracker-mock.c \ $(top_srcdir)/src/unity-webapps-string-utils.c \ $(top_srcdir)/src/unity-webapps-desktop-infos.c \ $(top_srcdir)/src/context-daemon/unity-webapps-debug.c test_indicator_model_controller_LDADD = \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) test_interest_manager_SOURCES = \ test-interest-manager.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-manager.c \ $(top_srcdir)/src/unity-webapps-string-utils.c \ $(top_srcdir)/src/unity-webapps-desktop-infos.c \ $(top_srcdir)/src/context-daemon/unity-webapps-debug.c test_interest_manager_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) test_interest_tracker_SOURCES = \ test-interest-tracker.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-tracker.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-manager.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker.c \ $(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.c \ unity-webapps-window-tracker-mock.c \ $(top_srcdir)/src/unity-webapps-string-utils.c \ $(top_srcdir)/src/unity-webapps-desktop-infos.c \ $(top_srcdir)/src/context-daemon/unity-webapps-debug.c test_interest_tracker_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) TESTS = $(REAL_TESTS) $(RUNNER_TESTS) CLEANFILES = $(RUNNER_TESTS) $(REAL_TESTS) libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/test-indicator-model.c0000644000015301777760000004553212321247333030106 0ustar pbusernogroup00000000000000#include #include "unity-webapps-indicator-model.h" typedef struct _IndicatorModelTestFixture { UnityWebappsIndicatorModel *indicator_model; } IndicatorModelTestFixture; static void setup_fixture (IndicatorModelTestFixture *fixture, gconstpointer user_data) { fixture->indicator_model = unity_webapps_indicator_model_new (); } static gchar * print_indicator_model (IndicatorModelTestFixture *fixture) { GVariant *serialized_variant; gchar *serialized_string; serialized_variant = unity_webapps_indicator_model_serialize (fixture->indicator_model); serialized_string = g_variant_print (serialized_variant, FALSE); g_variant_unref (serialized_variant); return serialized_string; } static void assert_indicator_model_equal (IndicatorModelTestFixture *fixture, const gchar *compare_to) { gchar *serialized_model; serialized_model = print_indicator_model (fixture); g_assert_cmpstr(serialized_model, ==, compare_to); g_free (serialized_model); } #define SINGLE_INTEREST_TEST1_SERIALIZED "([('Foo', 1, {})],)" static void test_single_interest_test1 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_TEST1_SERIALIZED); } #define SINGLE_INTEREST_TEST2_SERIALIZED "([('Bar', 1, {}), ('Foo', 1, {})],)" static void test_single_interest_test2 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_TEST2_SERIALIZED); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Bar", 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_TEST1_SERIALIZED); } #define SINGLE_INTEREST_TEST3_SERIALIZED "([('Bar', 1, {}), ('Baz', 1, {}), ('Foo', 1, {})],)" #define EMPTY_INDICATOR_MODEL "([],)" static void test_single_interest_test3 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Baz", 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_TEST3_SERIALIZED); unity_webapps_indicator_model_clear_indicators_for_interest (fixture->indicator_model, 1); assert_indicator_model_equal (fixture, EMPTY_INDICATOR_MODEL); } #define SINGLE_INTEREST_PROPERTY_TEST1_SERIALIZED "([('Foo', 1, {'count': <3>})],)" static void test_single_interest_property_test1 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "count", g_variant_new("i", 3), 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_PROPERTY_TEST1_SERIALIZED); } #define SINGLE_INTEREST_PROPERTY_TEST2_SERIALIZED "([('Foo', 1, {'count': <3>, 'date': <1>})],)" #define SINGLE_INTEREST_PROPERTY_TEST2_0_SERIALIZED "([('Foo', 1, {'count': <3>, 'date': <2>})],)" static void test_single_interest_property_test2 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "count", g_variant_new("i", 3), 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "date", g_variant_new("i", 1), 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_PROPERTY_TEST2_SERIALIZED); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "date", g_variant_new("i", 2), 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_PROPERTY_TEST2_0_SERIALIZED); } #define SINGLE_INTEREST_PROPERTY_TEST4_SERIALIZED "([('Foo', 1, {'count': <3>, 'date': <1>})],)" #define SINGLE_INTEREST_PROPERTY_TEST4_0_SERIALIZED "([],)" static void test_single_interest_property_test4 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "count", g_variant_new("i", 3), 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "date", g_variant_new("i", 1), 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_PROPERTY_TEST4_SERIALIZED); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Foo", 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_PROPERTY_TEST4_0_SERIALIZED); } #define SINGLE_INTEREST_PROPERTY_TEST3_SERIALIZED "([('Foo', 1, {'count': <3>, 'date': <1>})],)" static void test_single_interest_property_test3 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "count", g_variant_new("i", 3), 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "date", g_variant_new("i", 1), 1); assert_indicator_model_equal (fixture, SINGLE_INTEREST_PROPERTY_TEST3_SERIALIZED); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "date", g_variant_new("i", 2), 2); assert_indicator_model_equal (fixture, SINGLE_INTEREST_PROPERTY_TEST3_SERIALIZED); } #define MULTI_INTEREST_TEST1_SERIALIZED "([('Bar', 1, {}), ('Foo', 1, {})],)" static void test_multi_interest_test1 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST1_SERIALIZED); } #define MULTI_INTEREST_TEST2_SERIALIZED "([('Foo', 2, {})],)" static void test_multi_interest_test2 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST2_SERIALIZED); } #define MULTI_INTEREST_TEST3_SERIALIZED "([('Foo', 2, {})],)" static void test_multi_interest_test3 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 2); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST3_SERIALIZED); } #define MULTI_INTEREST_TEST4_SERIALIZED "([('Bar', 1, {}), ('Foo', 1, {})],)" static void test_multi_interest_test4 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 2); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Baz", 2); assert_indicator_model_equal (fixture, SINGLE_INTEREST_TEST3_SERIALIZED); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Baz", 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST4_SERIALIZED); } #define MULTI_INTEREST_TEST5_SERIALIZED "([('Bar', 2, {}), ('Foo', 1, {})],)" #define MULTI_INTEREST_TEST5_0_SERIALIZED "([('Bar', 1, {}), ('Foo', 1, {})],)" static void test_multi_interest_test5 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 2); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 1); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST5_SERIALIZED); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Bar", 1); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST5_0_SERIALIZED); } #define MULTI_INTEREST_TEST6_SERIALIZED "([('Bar', 2, {}), ('Foo', 1, {})],)" #define MULTI_INTEREST_TEST6_0_SERIALIZED "([('Bar', 1, {}), ('Foo', 1, {})],)" static void test_multi_interest_test6 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 2); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 1); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST6_SERIALIZED); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Bar", 1); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Bar", 1); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST6_0_SERIALIZED); } #define MULTI_INTEREST_TEST7_SERIALIZED "([('Bar', 2, {}), ('Foo', 1, {})],)" #define MULTI_INTEREST_TEST7_0_SERIALIZED "([('Foo', 1, {})],)" static void test_multi_interest_test7 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 2); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 1); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST7_SERIALIZED); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Bar", 1); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Bar", 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST7_0_SERIALIZED); } #define MULTI_INTEREST_PROPERTY_TEST1_SERIALIZED "([('Foo', 2, {'label': <4>})],)" static void test_multi_interest_property_test1 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 2); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 3), 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 4), 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_PROPERTY_TEST1_SERIALIZED); } #define MULTI_INTEREST_PROPERTY_TEST2_SERIALIZED "([('Foo', 1, {'label': <3>})],)" static void test_multi_interest_property_test2 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 2); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 3), 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 4), 2); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Foo", 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_PROPERTY_TEST2_SERIALIZED); } #define MULTI_INTEREST_PROPERTY_TEST3_SERIALIZED "([('Foo', 1, {'label': <4>})],)" static void test_multi_interest_property_test3 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 2); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 3), 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 4), 2); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Foo", 1); assert_indicator_model_equal (fixture, MULTI_INTEREST_PROPERTY_TEST3_SERIALIZED); } #define MULTI_INTEREST_PROPERTY_TEST4_SERIALIZED "([('Foo', 1, {'label': <3>})],)" static void test_multi_interest_property_test4 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 2); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 3), 1); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 4), 2); unity_webapps_indicator_model_set_indicator_property_for_interest (fixture->indicator_model, "Foo", "label", g_variant_new ("i", 5), 2); unity_webapps_indicator_model_clear_indicator_for_interest (fixture->indicator_model, "Foo", 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_PROPERTY_TEST4_SERIALIZED); } static void test_invalid_property_reads (IndicatorModelTestFixture *fixture, gconstpointer user_data) { g_assert (unity_webapps_indicator_model_get_indicator_property (fixture->indicator_model, "Foo", "Bar") == NULL); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); g_assert (unity_webapps_indicator_model_get_indicator_property (fixture->indicator_model, "Foo", "Bar") == NULL); } static void teardown_fixture (IndicatorModelTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->indicator_model)); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); g_test_add("/SingleInterest/ShowIndicator", IndicatorModelTestFixture, NULL, setup_fixture, test_single_interest_test1, teardown_fixture); g_test_add("/SingleInterest/ClearIndicator", IndicatorModelTestFixture, NULL, setup_fixture, test_single_interest_test2, teardown_fixture); g_test_add("/SingleInterest/ClearAllIndicators", IndicatorModelTestFixture, NULL, setup_fixture, test_single_interest_test3, teardown_fixture); g_test_add("/SingleInterest/Properties/UpdateProperties", IndicatorModelTestFixture, NULL, setup_fixture, test_single_interest_property_test2, teardown_fixture); g_test_add("/SingleInterest/Properties/UpdatePropertiesRemoveInterest", IndicatorModelTestFixture, NULL, setup_fixture, test_single_interest_property_test4, teardown_fixture); g_test_add("/SingleInterest/Properties/SetProperty", IndicatorModelTestFixture, NULL, setup_fixture, test_single_interest_property_test1, teardown_fixture); g_test_add("/SingleInterest/Properties/UpdatePropertyNoShow", IndicatorModelTestFixture, NULL, setup_fixture, test_single_interest_property_test3, teardown_fixture); g_test_add("/MultiInterest/ShowIndicator/Scenario1",IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_test1, teardown_fixture); g_test_add("/MultiInterest/ShowIndicator/Scenario2",IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_test2, teardown_fixture); g_test_add("/MultiInterest/ShowIndicator/Scenario3",IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_test3, teardown_fixture); g_test_add("/MultiInterest/ClearIndicator/Scenario1",IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_test4, teardown_fixture); g_test_add("/MultiInterest/ClearIndicator/Scenario2",IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_test5, teardown_fixture); g_test_add("/MultiInterest/ClearIndicator/Scenario3",IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_test6, teardown_fixture); g_test_add("/MultiInterest/ClearIndicator/Scenario3",IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_test7, teardown_fixture); g_test_add("/MultiInterest/Properties/Scenario1", IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_property_test1, teardown_fixture); g_test_add("/MultiInterest/Properties/Scenario2", IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_property_test2, teardown_fixture); g_test_add("/MultiInterest/Properties/Scenario3", IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_property_test3, teardown_fixture); g_test_add("/MultiInterest/Properties/Scenario4", IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_property_test4, teardown_fixture); g_test_add("/Misc/Properties/InvalidReads", IndicatorModelTestFixture, NULL, setup_fixture, test_invalid_property_reads, teardown_fixture); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/0000755000015301777760000000000012321250157031173 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/0000755000015301777760000000000012321250157032136 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/48/0000755000015301777760000000000012321250157032371 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/128/0000755000015301777760000000000012321250157032450 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/64/0000755000015301777760000000000012321250157032367 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/22/0000755000015301777760000000000012321250157032361 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/32/0000755000015301777760000000000012321250157032362 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/24/0000755000015301777760000000000012321250157032363 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/16/0000755000015301777760000000000012321250157032364 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/apps/192/0000755000015301777760000000000012321250157032451 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-applications/index.theme0000644000015301777760000000022112321247333033323 0ustar pbusernogroup00000000000000[Icon Theme] Name=Unity WebApps Comment=Webapps Icons Inherits=Humanity Directories=apps/48 [apps/48] Size=48 Context=Applications Type=Fixed libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/test-interest-tracker.c0000644000015301777760000001512112321247333030311 0ustar pbusernogroup00000000000000#include #include "unity-webapps-interest-tracker.h" #include "unity-webapps-window-tracker-mock.h" typedef struct _InterestTestFixture { UnityWebappsInterestManager *interest_manager; UnityWebappsInterestTracker *interest_tracker; UnityWebappsWindowTracker *window_tracker; gint id1; gint id2; gint id3; } InterestTestFixture; static void setup_fixture_scenario_one (InterestTestFixture *fixture, gconstpointer user_data) { UnityWebappsInterestManager *manager; UnityWebappsWindowTracker *tracker; gint most_recent; guint64 active_win; fixture->interest_manager = unity_webapps_interest_manager_new (); fixture->id1 = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":1"); fixture->id2 = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":2"); fixture->id3 = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":3"); fixture->window_tracker = UNITY_WEBAPPS_WINDOW_TRACKER (unity_webapps_window_tracker_mock_new ()); fixture->interest_tracker = unity_webapps_interest_tracker_new (fixture->window_tracker, fixture->interest_manager); g_object_get (fixture->interest_tracker, "interest-manager", &manager, "window-tracker", &tracker, "most-recent-interest", &most_recent, NULL); g_object_get (fixture->window_tracker, "active-window-id", &active_win, NULL); g_assert (manager == fixture->interest_manager); g_assert (tracker == fixture->window_tracker); g_assert (most_recent == -1); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->id1, 1); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->id2, 2); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->id3, 3); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 1); } #define ASSERTMR(i) g_assert(unity_webapps_interest_tracker_get_most_recent_interest (fixture->interest_tracker) == i) static void test_scenario_1_test1 (InterestTestFixture *fixture, gconstpointer user_data) { unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id1, TRUE); ASSERTMR(fixture->id1); } static void test_scenario_1_test2 (InterestTestFixture *fixture, gconstpointer user_data) { unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id1, FALSE); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id2, TRUE); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 2); ASSERTMR(fixture->id2); } static void test_scenario_1_test3 (InterestTestFixture *fixture, gconstpointer user_data) { unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 7); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id2, TRUE); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 2); ASSERTMR(fixture->id2); } static void test_scenario_1_test4 (InterestTestFixture *fixture, gconstpointer user_data) { unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 7); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id2, TRUE); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 2); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 3); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id3, TRUE); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 2); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 1); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 2); ASSERTMR(fixture->id2); } static void test_scenario_1_test5 (InterestTestFixture *fixture, gconstpointer user_data) { unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id1, TRUE); unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id2, TRUE); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 2); ASSERTMR(fixture->id2); } static void test_scenario_1_test6 (InterestTestFixture *fixture, gconstpointer user_data) { unity_webapps_interest_manager_set_interest_is_active (fixture->interest_manager, fixture->id1, TRUE); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 8); ASSERTMR(fixture->id1); unity_webapps_window_tracker_mock_set_active_window (UNITY_WEBAPPS_WINDOW_TRACKER_MOCK (fixture->window_tracker), 1); ASSERTMR(fixture->id1); } static void teardown_fixture (InterestTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->interest_tracker)); g_object_unref (G_OBJECT (fixture->window_tracker)); g_object_unref (G_OBJECT (fixture->interest_manager)); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); g_test_add("/Interest/Scenario1/InterestBecomesActiveFromTab", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_test1, teardown_fixture); g_test_add("/Interest/Scenario1/InterestBecomesActiveFromWindow", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_test2, teardown_fixture); g_test_add("/Interest/Scenario1/InterestBecomesActiveFromWindowWhileInactive", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_test3, teardown_fixture); g_test_add("/Interest/Scenario1/InterestBecomesActiveReturns", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_test4, teardown_fixture); g_test_add("/Interest/Scenario1/StealActivity", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_test5, teardown_fixture); g_test_add("/Interest/Scenario1/BoringWindowRestore", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_test6, teardown_fixture); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/test-application-info.c0000644000015301777760000002775012321247333030272 0ustar pbusernogroup00000000000000#include "unity-webapps-application-info.h" #include "unity-webapps-app-db.h" #include "unity-webapps-resource-db.h" #include #include #include typedef struct _InfoTestFixture { UnityWebappsApplicationInfo *application_info; } InfoTestFixture; #define ICON_URL "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sKBw0vIqzujI4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAGhklEQVRo3t2bT0gbeRTHv/MnMRl3XAoNC81hipeOs0cTTyUFpbsbwZquWHpJKHRprYUKXiK4Pe2G6qXQlka3bEFiD7KSVldoKksKHXpK4nHH9FIa2AjdLJQ1NZpkMtmDras1ycykxiS+o87vl/nMe/N+3/fm9yOKxSJqZG0ATiupZKeSWhMKq5F2ACcAHAPQCkABsAngHcXxa2DaXtOCXQKwAuAlgPVa3BRxwMCckkoOyrFwn7zy3FF4E0cxk9Y1AcXxoIQu0B02kbb1LAGYB5BoKOBiJt2bf/HkSl5c7C8k4gfnDYYFbeuB0elepDj+AYCndQUuZtK9uVDAmwvNOvR6Uq/Rgh3G76+LtGCf/BzwaoG5XCgwkQ36L9YatBS46apvjrRYx6oJdd3AhUT88tb0+J1CIt6KOhnBsDA63RstA9dHADysGXBeXPBvTo9fQ4MYLdhhHr03RTDs8EEDt21Oj/+WFxe+RYMZabHCPHp3meL4C1qWMlXgYib91VZg4ve8uNCFBjWCYcHcnIlQHH8OwNvPAW7L/HzpD1mKNixsCeizlTxdEXhzevyZnjA2OFww2LpBCV0gGBYAoKSSkGNh5J49gpJKVhxH23p2J0cUpEjFcWWglymO/043cDZ4358N+jUlKIrjYRrygeL4itdlg/eRDfp1jStm0sgG/ciFAprf6dZbwbKJrCSwHAtfzty+8atWWObmzI5HNWR6bE6PVz1Oa/Zmfpz5odSStQ+4mElz72+c/bOYSbdqCaHWW0GQFquu9y0XCsBw5rxm2I+2NTup2dMmt3fD6PR8/ak4IUu8txNaYAHA6HTrht0e59ENCwAtA8Oax2WD/lYllZzYF/J7QlmK9sqx8EU9N37Ymdhw5rxWnY+t2cmLAHrLAuce3/fqUTnVeOmz1VVnt+Zr5VgYshT1lgSWpWivLEUdmhUO11EnZXVCX754fN+x28vkrn9c0RdeX9RNSuoxWYpCSSWv7AFWUklOlqL9uqqm1WhdgGVJ/+9mg/5+ANwOsBwLD+qdpPAmXhdgJbGq/yHFwgAwuAOcFxf7quh2fJzoUC337BGqvNc+ACAKf//V9n7km3/1ZGeDwwWqw17VGnxQYS2vPEf+xRPNTUKj0wOT2/slXViNnta6BppH74EW7A1R+NOCHS0Dw9gKTCAvLqi/glIEAE7ThcSrTo2CvC7rrqoThnw7WlulNQUAnaSSWBXUJjaP3m042D33N+TbU1pWgBZIJbXWrqZf1cq+RoFWc0pxI91OKqnkCbWivhnsY9O+snaInCCx/a2nbK1br0xcjRlsqjr7GAnAXPapNREsAIBpU4188iB1azMYie1Plgcm4xrcNkkA7xpNL9dQZ78jAaxV0qBaVEyjmJrOJi3WNZIW7K9VSqvmgA0FVPvXxHHra5I4bpUqhkkqqbk9Wi8rJOKaHEOd5CWS4k6tqF2opydcD9jMT5dUqyaCYUEw7ApNCV0vtUycFxdQWI3C5PZq0q01T1CpJLJBv+YcQwldAPCSpjh+nWBYsZhJO7T8SOb2DRAMC+okD6rDXgfQNSiJOPTuJTHYukUA6zQA0Laepby4oLljWcykt4twKYpmMarDvrTT4jHYuudxhI0W7CAt1vkdYNrWkyAt1sWjCmxwuBbx4RsT+f8f+x8cRViCYWFwuB7s1tIAAKPT85RgWPGoARudbhG79nWRu5+E0emePGreNTo9k59WS9jtZdJinTsqwCbP2BzBsE/LAhMMC5PbOwZg4whk5g2DwzVWqh7ee6GtJ2FwuEaaPZRNV30jKLE1kSwTCg8pjp9qVmDzkG+KtFgflut4lH5CQ75hgmGXmy8re5ZpW89wpRZPaSm2vcvmAsGwkSYSGBGT23uhYhOgov7k+HXm5sy5ZoA2OFwR85DvHFT2W5Kqopvj3zI3Z842cngbHK5l85DvLFT2WQI6tg8XEnFsTY/7C4n4tUaCNbm9U0an58C3D++Uhdmg/3IuFLiD7ZMpdTPSYt0wj94doTi+dhvEP5osRbmtX8YnlFTyYj1gjU7PXMvA8BjBsLU/ArDb27lQoDcXmvVq6ZYckHoSW9xjkxTHH/ohj33geXHxipJK9tcoKS0aHK4HtGCv7zGefaEeC3P52PNBORbu+1yv04JdpDu7lwxnzs9XE7qHAvxJVm8rSJHThcSrzuI/SUFJrbV/+Ba97ygeLdjXwLS9prhTEsXxK5TQ9ZJg2JocxfsPlPjVREHRwK4AAAAASUVORK5CYII=" #define INVALID_DATA_ICON_URL "data:foooasas;fa;sf'asf" #define INVALID_DATA_ICON_MIME "data:foobar/la;base64, validbutwrongmimetype" static void setup_fixture_testts (InfoTestFixture *fixture, gconstpointer user_data) { gchar *name, *domain, *icon_url; fixture->application_info = unity_webapps_application_info_new("Test", "test.ts", ICON_URL, NULL); g_object_get (fixture->application_info, "name", &name, "domain", &domain, "icon-url", &icon_url, NULL); g_assert_cmpstr(name, ==, "Test"); g_assert_cmpstr(domain, ==, "test.ts"); g_assert_cmpstr(icon_url, ==, ICON_URL); g_assert_cmpstr(name, ==, unity_webapps_application_info_get_name (fixture->application_info)); g_assert_cmpstr(domain, ==, unity_webapps_application_info_get_domain (fixture->application_info)); g_assert_cmpstr(icon_url, ==, unity_webapps_application_info_get_icon_url (fixture->application_info)); unity_webapps_app_db_open (); unity_webapps_resource_db_open (); } static void setup_fixture_testts_write_failure (InfoTestFixture *fixture, gconstpointer user_data) { fixture->application_info = unity_webapps_application_info_new("Test", "test.ts", ICON_URL, NULL); system("chmod 000 test-output-files"); } static void setup_fixture_testts_invalid_data_icon (InfoTestFixture *fixture, gconstpointer user_data) { fixture->application_info = unity_webapps_application_info_new("Test", "test.ts", INVALID_DATA_ICON_URL, NULL); } static void setup_fixture_testts_invalid_data_icon_mime (InfoTestFixture *fixture, gconstpointer user_data) { fixture->application_info = unity_webapps_application_info_new("Test", "test.ts", INVALID_DATA_ICON_MIME, NULL); } static void setup_fixture_testts_themed_icon (InfoTestFixture *fixture, gconstpointer user_data) { fixture->application_info = unity_webapps_application_info_new("Test", "test.ts", "icon://Test-themed-application-icons", NULL); } static void setup_fixture_testts_space_in_name (InfoTestFixture *fixture, gconstpointer user_data) { fixture->application_info = unity_webapps_application_info_new("Test Space", "test.ts", ICON_URL, NULL); } static void create_test_output_files_dir (gboolean copy_theme) { system("mkdir test-output-files"); if (copy_theme) { system("cp -R "TEST_SRCDIR"/unity-webapps-applications test-output-files/unity-webapps-applications"); system("chmod -R 777 test-output-files/unity-webapps-applications"); } } static void teardown_fixture (InfoTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->application_info)); system("chmod 777 test-output-files"); system("rm -rf test-output-files"); create_test_output_files_dir (TRUE); } static void setup_unity_webapps_environment () { system("rm -rf test-output-files"); create_test_output_files_dir (TRUE); g_setenv("UNITY_WEBAPPS_CONTEXT_ICON_DIR", "test-output-files", TRUE); g_setenv("UNITY_WEBAPPS_CONTEXT_ICON_THEME_DIR", "test-output-files", TRUE); g_setenv("UNITY_WEBAPPS_CONTEXT_APPLICATION_DIR", "test-output-files", TRUE); g_setenv("UNITY_WEBAPPS_CONTEXT_RESOURCE_DIR", "test-output-files", TRUE); g_setenv("UNITY_WEBAPPS_CONTEXT_USER_DIR", "test-output-files", TRUE); unity_webapps_app_db_open (); unity_webapps_resource_db_open (); } static void test_canonicalization (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; gchar *canonical_name, *canonical_domain, *canonical_full_name; info = fixture->application_info; canonical_name = unity_webapps_application_info_get_canonical_name (info); canonical_domain = unity_webapps_application_info_get_canonical_domain (info); canonical_full_name = unity_webapps_application_info_get_canonical_full_name (info); g_assert (g_strcmp0 ("Test", canonical_name) == 0); g_assert (g_strcmp0 ("testts", canonical_domain) == 0); g_assert (g_strcmp0 ("Testtestts", canonical_full_name) == 0); g_free (canonical_name); g_free (canonical_domain); g_free (canonical_full_name); } static void test_ensure_desktop_file (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; GError *error; info = (fixture)->application_info; error = NULL; unity_webapps_application_info_ensure_desktop_file (info, &error); g_assert (error == NULL); g_assert (g_file_test ("test-output-files/Testtestts.desktop", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); } static void test_write_name_with_spaces_desktop_file (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; GError *error; info = (fixture)->application_info; error = NULL; unity_webapps_application_info_ensure_desktop_file (info, &error); g_assert (error == NULL); g_assert (g_file_test ("test-output-files/TestSpacetestts.desktop", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); } static void test_set_homepage (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; GError *error; info = (fixture)->application_info; error = NULL; unity_webapps_application_info_ensure_desktop_file (info, &error); g_assert (error == NULL); g_assert (g_file_test ("test-output-files/Testtestts.desktop", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); unity_webapps_application_info_set_homepage (info, "http://www.google.com"); } static void test_update_homepage (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; GError *error; info = (fixture)->application_info; error = NULL; unity_webapps_application_info_ensure_desktop_file (info, &error); g_assert (error == NULL); g_assert (g_file_test ("test-output-files/Testtestts.desktop", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); unity_webapps_application_info_set_homepage (info, "http://www.google.com"); unity_webapps_application_info_set_homepage (info, "http://www.foo.com"); } static void test_save_icon (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; GError *error; info = (fixture)->application_info; error = NULL; unity_webapps_application_info_ensure_desktop_file (info, &error); g_assert (error == NULL); unity_webapps_application_info_save_icon_file (info); } static void test_add_icon (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; info = (fixture)->application_info; unity_webapps_application_info_add_icon_at_size (info, ICON_URL, 32); unity_webapps_application_info_add_icon_at_size (info, "icon://Test-themed-application-icons", 32); g_assert (g_file_test ("test-output-files/apps/32/Test-test.ts.png", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); } static void test_add_icon_fail (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; info = (fixture)->application_info; unity_webapps_application_info_add_icon_at_size (info, ICON_URL, 32); unity_webapps_application_info_add_icon_at_size (info, "icon://Test-themed-application-icons", 32); } static void test_add_icon_remove_resource_dir (InfoTestFixture *fixture, gconstpointer user_data) { UnityWebappsApplicationInfo *info; info = (fixture)->application_info; unity_webapps_application_info_add_icon_at_size (info, ICON_URL, 32); system("rm -r test-output-files"); unity_webapps_application_info_add_icon_at_size (info, "icon://Test-themed-application-icons", 32); create_test_output_files_dir (TRUE); } int main (int argc, char **argv) { gtk_init (&argc, &argv); g_test_init (&argc, &argv, NULL); setup_unity_webapps_environment(); g_test_add("/Info/Canonicalization", InfoTestFixture, NULL, setup_fixture_testts, test_canonicalization, teardown_fixture); g_test_add("/Info/WriteDesktopFile", InfoTestFixture, NULL, setup_fixture_testts, test_ensure_desktop_file, teardown_fixture); g_test_add("/Info/WriteNameWithSpacesDesktopFile", InfoTestFixture, NULL, setup_fixture_testts_space_in_name, test_write_name_with_spaces_desktop_file, teardown_fixture); g_test_add("/Info/SetHomepage", InfoTestFixture, NULL, setup_fixture_testts, test_set_homepage, teardown_fixture); g_test_add("/Info/UpdateHomepage", InfoTestFixture, NULL, setup_fixture_testts, test_update_homepage, teardown_fixture); g_test_add("/Icons/SaveIcon", InfoTestFixture, NULL, setup_fixture_testts, test_save_icon, teardown_fixture); g_test_add("/Icons/InvalidDataIcon", InfoTestFixture, NULL, setup_fixture_testts_invalid_data_icon, test_save_icon, teardown_fixture); g_test_add("/Icons/InvalidDataIconMime", InfoTestFixture, NULL, setup_fixture_testts_invalid_data_icon_mime, test_save_icon, teardown_fixture); g_test_add("/Icons/AddSizedIcon", InfoTestFixture, NULL, setup_fixture_testts, test_add_icon, teardown_fixture); g_test_add("/Icons/AddSizedIconRemoveDir", InfoTestFixture, NULL, setup_fixture_testts, test_add_icon_remove_resource_dir, teardown_fixture); g_test_add("/Icons/AddSizedIconFail", InfoTestFixture, NULL, setup_fixture_testts_write_failure, test_add_icon_fail, teardown_fixture); g_test_add("/Icons/ThemedIcon", InfoTestFixture, NULL, setup_fixture_testts_themed_icon, test_save_icon, teardown_fixture); system("rm -rf test-output-files/*"); create_test_output_files_dir (FALSE); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/unity-webapps-window-tracker-mock.h0000644000015301777760000000515612321247333032556 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-window-tracker.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_WINDOW_TRACKER_MOCK_H #define __UNITY_WEBAPPS_WINDOW_TRACKER_MOCK_H #include "unity-webapps-window-tracker.h" #define UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK (unity_webapps_window_tracker_mock_get_type()) #define UNITY_WEBAPPS_WINDOW_TRACKER_MOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK, UnityWebappsWindowTrackerMock)) #define UNITY_WEBAPPS_WINDOW_TRACKER_MOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK, UnityWebappsWindowTrackerMockClass)) #define UNITY_WEBAPPS_IS_WINDOW_TRACKER_MOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK)) #define UNITY_WEBAPPS_IS_WINDOW_TRACKER_MOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK)) #define UNITY_WEBAPPS_WINDOW_TRACKER_MOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK, UnityWebappsWindowTrackerMockClass)) typedef struct _UnityWebappsWindowTrackerMockPrivate UnityWebappsWindowTrackerMockPrivate; typedef struct _UnityWebappsWindowTrackerMock UnityWebappsWindowTrackerMock; struct _UnityWebappsWindowTrackerMock { UnityWebappsWindowTracker object; UnityWebappsWindowTrackerMockPrivate *priv; }; typedef struct _UnityWebappsWindowTrackerMockClass UnityWebappsWindowTrackerMockClass; struct _UnityWebappsWindowTrackerMockClass { UnityWebappsWindowTrackerClass parent_class; }; GType unity_webapps_window_tracker_mock_get_type (void) G_GNUC_CONST; UnityWebappsWindowTrackerMock *unity_webapps_window_tracker_mock_new (); void unity_webapps_window_tracker_mock_set_active_window (UnityWebappsWindowTrackerMock *tracker, guint64 window_id); #endif libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/test-interest-manager.c0000644000015301777760000001233612321247333030275 0ustar pbusernogroup00000000000000#include #include "unity-webapps-interest-manager.h" typedef struct _InterestTestFixture { UnityWebappsInterestManager *interest_manager; gint id1; gint id2; gint id3; } InterestTestFixture; static void setup_fixture_scenario_one (InterestTestFixture *fixture, gconstpointer user_data) { fixture->interest_manager = unity_webapps_interest_manager_new (); fixture->id1 = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":1"); fixture->id2 = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":2"); fixture->id3 = unity_webapps_interest_manager_add_interest (fixture->interest_manager, ":3"); unity_webapps_interest_manager_set_interest_location (fixture->interest_manager, fixture->id1, "Foo"); unity_webapps_interest_manager_set_interest_location (fixture->interest_manager, fixture->id2, "Bar"); } static void test_scenario_1_list_interest_empty (InterestTestFixture *fixture, gconstpointer user_data) { GVariant *interests; interests = unity_webapps_interest_manager_list_interests (fixture->interest_manager); g_assert (g_variant_is_of_type (interests, G_VARIANT_TYPE("ai"))); g_assert_cmpint (g_variant_n_children (interests), ==, 0); g_variant_unref (interests); } static void test_scenario_1_list_interest_full (InterestTestFixture *fixture, gconstpointer user_data) { GVariant *interests; unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->id1, g_random_int()); interests = unity_webapps_interest_manager_list_interests (fixture->interest_manager); g_assert (g_variant_is_of_type (interests, G_VARIANT_TYPE("ai"))); g_assert_cmpint (g_variant_n_children (interests), ==, 1); g_variant_unref (interests); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->id2, g_random_int()); interests = unity_webapps_interest_manager_list_interests (fixture->interest_manager); g_assert (g_variant_is_of_type (interests, G_VARIANT_TYPE("ai"))); g_assert_cmpint (g_variant_n_children (interests), ==, 2); g_variant_unref (interests); unity_webapps_interest_manager_set_interest_window (fixture->interest_manager, fixture->id3, g_random_int()); interests = unity_webapps_interest_manager_list_interests (fixture->interest_manager); g_assert (g_variant_is_of_type (interests, G_VARIANT_TYPE("ai"))); g_assert_cmpint (g_variant_n_children (interests), ==, 3); gint value = 0; g_variant_get_child (interests, 0, "i", &value); g_assert_cmpint(value, ==, fixture->id1); g_variant_get_child (interests, 1, "i", &value); g_assert_cmpint(value, ==, fixture->id2); g_variant_get_child (interests, 2, "i", &value); g_assert_cmpint(value, ==, fixture->id3); g_variant_unref (interests); } static void test_scenario_1_interest_owners (InterestTestFixture *fixture, gconstpointer user_data) { g_assert_cmpstr (unity_webapps_interest_manager_get_interest_owner (fixture->interest_manager, fixture->id1), ==, ":1"); g_assert_cmpstr (unity_webapps_interest_manager_get_interest_owner (fixture->interest_manager, fixture->id2), ==, ":2"); g_assert_cmpstr (unity_webapps_interest_manager_get_interest_owner (fixture->interest_manager, fixture->id3), ==, ":3"); } static void test_scenario_1_interest_locations (InterestTestFixture *fixture, gconstpointer user_data) { g_assert_cmpstr (unity_webapps_interest_manager_get_interest_location (fixture->interest_manager, fixture->id1), ==, "Foo"); g_assert_cmpstr (unity_webapps_interest_manager_get_interest_location (fixture->interest_manager, fixture->id2), ==, "Bar"); } static void test_scenario_1_update_locations (InterestTestFixture *fixture, gconstpointer user_data) { unity_webapps_interest_manager_set_interest_location (fixture->interest_manager, fixture->id1, "Baz"); unity_webapps_interest_manager_set_interest_location (fixture->interest_manager, fixture->id1, "Baz"); } static void teardown_fixture (InterestTestFixture *fixture, gconstpointer user_data) { unity_webapps_interest_manager_remove_interests_with_name (fixture->interest_manager, ":1"); unity_webapps_interest_manager_remove_interests_with_name (fixture->interest_manager, ":2"); unity_webapps_interest_manager_remove_interests_with_name (fixture->interest_manager, ":3"); g_object_unref (G_OBJECT (fixture->interest_manager)); } int main (int argc, char **argv) { g_test_init (&argc, &argv, NULL); g_test_add("/Interest/Scenario1/ListInterests/Empty", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_list_interest_empty, teardown_fixture); g_test_add("/Interest/Scenario1/ListInterests/Full", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_list_interest_full, teardown_fixture); g_test_add("/Interest/Scenario1/InterestOwners", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_interest_owners, teardown_fixture); g_test_add("/Interest/Scenario1/InterestLocations", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_interest_locations, teardown_fixture); g_test_add("/Interest/Scenario1/UpdateLocations", InterestTestFixture, NULL, setup_fixture_scenario_one, test_scenario_1_update_locations, teardown_fixture); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/context-daemon/test-indicator-model-controller.c0000644000015301777760000000707312321247333032265 0ustar pbusernogroup00000000000000#include #include "unity-webapps-indicator-model-controller.h" typedef struct _IndicatorModelTestFixture { UnityWebappsIndicatorModelController *controller; UnityWebappsIndicatorModel *indicator_model; UnityWebappsInterestManager *interest_manager; } IndicatorModelTestFixture; static void setup_fixture (IndicatorModelTestFixture *fixture, gconstpointer user_data) { fixture->indicator_model = unity_webapps_indicator_model_new (); fixture->interest_manager = unity_webapps_interest_manager_new (); fixture->controller = unity_webapps_indicator_model_controller_new (fixture->indicator_model, fixture->interest_manager); g_assert (unity_webapps_indicator_model_controller_get_model (fixture->controller) == fixture->indicator_model); g_assert (unity_webapps_indicator_model_controller_get_interest_manager (fixture->controller) == fixture->interest_manager); } static gchar * print_indicator_model (IndicatorModelTestFixture *fixture) { GVariant *serialized_variant; gchar *serialized_string; serialized_variant = unity_webapps_indicator_model_serialize (fixture->indicator_model); serialized_string = g_variant_print (serialized_variant, FALSE); g_variant_unref (serialized_variant); return serialized_string; } static void assert_indicator_model_equal (IndicatorModelTestFixture *fixture, const gchar *compare_to) { gchar *serialized_model; serialized_model = print_indicator_model (fixture); g_assert_cmpstr(serialized_model, ==, compare_to); g_free (serialized_model); } #define MULTI_INTEREST_TEST1_SERIALIZED "([('Bar', 1, {}), ('Foo', 2, {})],)" #define MULTI_INTEREST_TEST1_0_SERIALIZED "([('Foo', 1, {})],)" static void test_multi_interest_test1 (IndicatorModelTestFixture *fixture, gconstpointer user_data) { gint interest_id2; unity_webapps_interest_manager_add_interest(fixture->interest_manager, "1"); interest_id2 = unity_webapps_interest_manager_add_interest(fixture->interest_manager, "2"); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 1); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Foo", 2); unity_webapps_indicator_model_show_indicator_for_interest (fixture->indicator_model, "Bar", 2); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST1_SERIALIZED); unity_webapps_interest_manager_remove_interest (fixture->interest_manager, interest_id2, FALSE); assert_indicator_model_equal (fixture, MULTI_INTEREST_TEST1_0_SERIALIZED); } static void test_properties (IndicatorModelTestFixture *fixture, gconstpointer user_data) { UnityWebappsIndicatorModel *model; UnityWebappsInterestManager *manager; g_object_get (fixture->controller, "model", &model, "interest-manager", &manager, NULL); g_assert (model == fixture->indicator_model); g_assert (manager == fixture->interest_manager); } static void teardown_fixture (IndicatorModelTestFixture *fixture, gconstpointer user_data) { g_object_unref (G_OBJECT (fixture->indicator_model)); g_object_unref (G_OBJECT (fixture->interest_manager)); g_object_unref (G_OBJECT (fixture->controller)); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); g_test_add("/MultiInterest/Controller/Scenario1",IndicatorModelTestFixture, NULL, setup_fixture, test_multi_interest_test1, teardown_fixture); g_test_add("/MultiInterest/Controller/Properties",IndicatorModelTestFixture, NULL, setup_fixture, test_properties, teardown_fixture); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/0000755000015301777760000000000012321250157023524 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/apt-cache-generator.c0000644000015301777760000000514112321247333027504 0ustar pbusernogroup00000000000000#include "apt-cache-generator.h" #include "apt-cache-generator-entry.h" #include struct _AptCacheGenerator { GList *entries; }; AptCacheGenerator * apt_cache_generator_new () { AptCacheGenerator *generator; generator = g_new0(AptCacheGenerator, 1); generator->entries = NULL; return generator; } static void apt_cache_generator_free_entries (AptCacheGenerator *generator) { GList *w; for (w = generator->entries; w != NULL; w = w->next) { AptCacheGeneratorEntry *entry; entry = (AptCacheGeneratorEntry *)w->data; apt_cache_generator_entry_free (entry); } g_list_free (generator->entries); } void apt_cache_generator_free (AptCacheGenerator *generator) { apt_cache_generator_free_entries (generator); g_free (generator); } gchar * apt_cache_generator_get_available (AptCacheGenerator *generator) { GString *available; GList *w; gchar *ret; available = g_string_new (""); for (w = generator->entries; w != NULL; w = w->next) { AptCacheGeneratorEntry *entry; gchar *entry_serialized; entry = (AptCacheGeneratorEntry *)w->data; entry_serialized = apt_cache_generator_entry_serialize (entry); g_string_append_printf (available, "%s\n", entry_serialized); } ret = available->str; g_string_free (available, FALSE); return ret; } static AptCacheGeneratorEntry * apt_cache_generator_construct_application (AptCacheGenerator *generator, const gchar *name) { AptCacheGeneratorEntry *entry; entry = apt_cache_generator_entry_new (name, "1.0"); return entry; } void apt_cache_generator_add_application (AptCacheGenerator *generator, const gchar *name) { AptCacheGeneratorEntry *entry; entry = apt_cache_generator_construct_application (generator, name); generator->entries = g_list_append (generator->entries, entry); } void apt_cache_generator_add_webapp (AptCacheGenerator *generator, const gchar *name, const gchar *webapp_name, const gchar *webapp_domain, .../*Includes*/) { AptCacheGeneratorEntry *entry; const gchar *include; va_list argp; entry = apt_cache_generator_entry_new (name, "1.0"); apt_cache_generator_entry_set_webapp_name (entry, webapp_name); apt_cache_generator_entry_set_webapp_domain (entry, webapp_domain); va_start (argp, webapp_domain); include = va_arg (argp, gchar *); while (include != NULL) { apt_cache_generator_entry_add_webapp_include (entry, include); include = va_arg (argp, gchar *); } va_end (argp); // TODO: Factor out generator->entries = g_list_append (generator->entries, entry); } libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/Makefile.am0000644000015301777760000000246712321247333025573 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ -DUNITY_WEBAPPS_ENABLE_DEBUG \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/index-updater \ -I$(top_srcdir)/src/context-daemon/util \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) noinst_PROGRAMS = \ test-apt-cache-parser \ test-index-updater \ mock-apt-cache apt_cache_generator_sources = \ apt-cache-generator.c \ apt-cache-generator.h \ apt-cache-generator-entry.c \ apt-cache-generator-entry.h test_index_updater_SOURCES = \ test-ubuntu-webapps-update-index.c \ $(top_srcdir)/src/unity-webapps-url-db.c \ $(top_srcdir)/src/context-daemon/util/unity-webapps-dirs.c \ $(top_srcdir)/src/context-daemon/unity-webapps-debug.c test_index_updater_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) mock_apt_cache_SOURCES = \ mock-apt-cache.c \ $(apt_cache_generator_sources) mock_apt_cache_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) test_apt_cache_parser_SOURCES = \ test-apt-cache-parser.c \ $(apt_cache_generator_sources) \ $(top_srcdir)/src/index-updater/apt-cache-parser.c \ $(top_srcdir)/src/index-updater/webapp-info.c test_apt_cache_parser_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) TESTS = $(noinst_PROGRAMS) CLEANFILES = *.sqlite libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/mock-apt-cache.c0000644000015301777760000000115412321247333026447 0ustar pbusernogroup00000000000000#include "apt-cache-generator.h" #include gint main (gint argc, gchar **argv) { AptCacheGenerator *generator; gchar *available; generator = apt_cache_generator_new (); apt_cache_generator_add_application (generator, "Foo"); apt_cache_generator_add_webapp (generator, "unity-webapps-angrybirds", "AngryBirds", "test.ts", "http://chrome.angrybirds.com/*", NULL); apt_cache_generator_add_application (generator, "Bar"); available = apt_cache_generator_get_available (generator); printf("%s", available); g_free (available); apt_cache_generator_free (generator); } libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/test-ubuntu-webapps-update-index.c0000644000015301777760000000204212321247333032213 0ustar pbusernogroup00000000000000#include #include #include #include "unity-webapps-url-db.h" #include "unity-webapps-debug.h" #define TEST_DB_OUTPUT_PATH "./urldb-v2.sqlite" static void spawn_index_updater () { g_setenv ("UNITY_WEBAPPS_URL_DB_DEFAULT_PATH", TEST_DB_OUTPUT_PATH, TRUE); g_setenv ("UNITY_WEBAPPS_APT_CACHE_BINARY", "./mock-apt-cache", TRUE); system ("../../src/index-updater/ubuntu-webapps-update-index"); } gint main (gint argc, gchar **argv) { UnityWebappsUrlDB *db; UnityWebappsUrlDBRecord *record; GList *records; unity_webapps_debug_initialize_flags (); spawn_index_updater (); db = unity_webapps_url_db_open (TRUE, "./urldb-v2.sqlite"); unity_webapps_url_db_lookup_urls (db, "http://chrome.angrybirds.com/foo", &records); g_assert (records); record = (UnityWebappsUrlDBRecord *)records->data; g_assert_cmpstr (record->package_name, ==, "unity-webapps-angrybirds"); g_assert_cmpstr (record->application_name, ==, "AngryBirds"); g_assert_cmpstr (record->domain, ==, "test.ts"); return 0; } libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/apt-cache-generator-entry.h0000644000015301777760000000131712321247333030651 0ustar pbusernogroup00000000000000#ifndef __APT_CACHE_GENERATOR_ENTRY_H #define __APT_CACHE_GENERATOR_ENTRY_H #include typedef struct _AptCacheGeneratorEntry AptCacheGeneratorEntry; AptCacheGeneratorEntry *apt_cache_generator_entry_new (const gchar *name, const gchar *version); void apt_cache_generator_entry_free (AptCacheGeneratorEntry *entry); gchar *apt_cache_generator_entry_serialize (AptCacheGeneratorEntry *entry); void apt_cache_generator_entry_add_webapp_include (AptCacheGeneratorEntry *entry, const gchar *include); void apt_cache_generator_entry_set_webapp_name (AptCacheGeneratorEntry *entry, const gchar *name); void apt_cache_generator_entry_set_webapp_domain (AptCacheGeneratorEntry *entry, const gchar *domain); #endif libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/apt-cache-generator.h0000644000015301777760000000110712321247333027507 0ustar pbusernogroup00000000000000#ifndef __APT_CACHE_GENERATOR_H #define __APT_CACHE_GENERATOR_H #include typedef struct _AptCacheGenerator AptCacheGenerator; AptCacheGenerator *apt_cache_generator_new (); void apt_cache_generator_free (AptCacheGenerator *generator); gchar *apt_cache_generator_get_available (AptCacheGenerator *generator); void apt_cache_generator_add_application (AptCacheGenerator *generator, const gchar *name); void apt_cache_generator_add_webapp (AptCacheGenerator *generator, const gchar *name, const gchar *webapp_name, const gchar *webapp_domain, ... /* Includes */); #endif libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/test-apt-cache-parser.c0000644000015301777760000001151112321247333027765 0ustar pbusernogroup00000000000000#include #include #include #include #include "apt-cache-generator.h" #include "apt-cache-parser.h" #include "webapp-info.h" typedef struct _AptCacheTestFixture { AptCacheGenerator *generator; AptCacheParser *parser; } AptCacheTestFixture; static gchar * print_parser_results (AptCacheTestFixture *fixture) { GVariant *serialized_variant; gchar *ret; serialized_variant = apt_cache_parser_serialize_results (fixture->parser); ret = g_variant_print (serialized_variant, FALSE); g_variant_unref (serialized_variant); return ret; } static void setup_fixture_one_package (AptCacheTestFixture *fixture, gconstpointer user_data) { AptCacheGenerator *generator; generator = apt_cache_generator_new (); apt_cache_generator_add_application (generator, "foo"); fixture->generator = generator; fixture->parser = apt_cache_parser_new (); } static void setup_fixture_multiple_packages (AptCacheTestFixture *fixture, gconstpointer user_data) { AptCacheGenerator *generator; generator = apt_cache_generator_new (); apt_cache_generator_add_application (generator, "foo"); apt_cache_generator_add_application (generator, "bar"); apt_cache_generator_add_application (generator, "baz"); apt_cache_generator_add_application (generator, "bam"); fixture->generator = generator; fixture->parser = apt_cache_parser_new (); } static void setup_fixture_one_webapp_package (AptCacheTestFixture *fixture, gconstpointer user_data) { AptCacheGenerator *generator; generator = apt_cache_generator_new (); apt_cache_generator_add_webapp (generator, "unity-webapps-angrybirds", "AngryBirds", "test.ts", "http://test.ts/foo/*", "http://test.ts/bar/*", NULL); fixture->generator = generator; fixture->parser = apt_cache_parser_new (); } static void teardown_fixture (AptCacheTestFixture *fixture, gconstpointer user_data) { apt_cache_generator_free (fixture->generator); apt_cache_parser_free (fixture->parser); } static void test_generator_single_app (AptCacheTestFixture *fixture, gconstpointer user_data) { const gchar *const expected_results = "Package: foo\n" "Version: 1.0\n" "Description: Lorum ipsum dolor sit amet\n\n"; gchar *available; available = apt_cache_generator_get_available (fixture->generator); g_assert_cmpstr (available, ==, expected_results); g_free (available); } static void test_generator_single_webapp (AptCacheTestFixture *fixture, gconstpointer user_data) { const gchar *const expected_results = "Package: unity-webapps-angrybirds\n" "Version: 1.0\n" "Description: Lorum ipsum dolor sit amet\n" "Ubuntu-Webapps-Includes: http://test.ts/foo/*;http://test.ts/bar/*\n" "Ubuntu-Webapps-Name: AngryBirds\n" "Ubuntu-Webapps-Domain: test.ts\n\n"; gchar *available; available = apt_cache_generator_get_available (fixture->generator); g_assert_cmpstr (available, ==, expected_results); g_free (available); } static void test_parser_no_webapps (AptCacheTestFixture *fixture, gconstpointer user_data) { gchar *available; gboolean parsed; available = apt_cache_generator_get_available (fixture->generator); parsed = apt_cache_parser_parse_available (fixture->parser, available); g_assert (parsed); g_assert (g_list_length (apt_cache_parser_get_webapp_infos (fixture->parser)) == 0); } static void test_parser_one_webapp (AptCacheTestFixture *fixture, gconstpointer user_data) { gchar *available; gboolean parsed; const gchar *const expected_parser_results = "([('unity-webapps-angrybirds', 'AngryBirds', [('http://test.ts/foo/*',), ('http://test.ts/bar/*',)])],)"; available = apt_cache_generator_get_available (fixture->generator); parsed = apt_cache_parser_parse_available (fixture->parser, available); g_assert (parsed); // Leaks g_assert_cmpstr(print_parser_results (fixture), ==, expected_parser_results); } gint main (gint argc, gchar **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); g_test_add("/Generator/SinglePackage", AptCacheTestFixture, NULL, setup_fixture_one_package, test_generator_single_app, teardown_fixture); g_test_add("/Generator/SingleWebappPackage", AptCacheTestFixture, NULL, setup_fixture_one_webapp_package, test_generator_single_webapp, teardown_fixture); g_test_add("/Parser/SinglePackageNoWebapps", AptCacheTestFixture, NULL, setup_fixture_one_package, test_parser_no_webapps, teardown_fixture); g_test_add("/Parser/MultiplePackagesNoWebapps", AptCacheTestFixture, NULL, setup_fixture_multiple_packages, test_parser_no_webapps, teardown_fixture); g_test_add("/Parser/SingleWebapp", AptCacheTestFixture, NULL, setup_fixture_one_webapp_package, test_parser_one_webapp, teardown_fixture); return g_test_run (); } libunity-webapps-2.5.0~+14.04.20140409/tests/index-updater/apt-cache-generator-entry.c0000644000015301777760000000530012321247333030640 0ustar pbusernogroup00000000000000#include "apt-cache-generator-entry.h" struct _AptCacheGeneratorEntry { gchar *name; gchar *version; gchar *webapp_includes; gchar *webapp_name; gchar *webapp_domain; }; AptCacheGeneratorEntry * apt_cache_generator_entry_new (const gchar *name, const gchar *version) { AptCacheGeneratorEntry *entry; entry = g_new0 (AptCacheGeneratorEntry, 1); entry->name = g_strdup (name); entry->version = g_strdup (version); entry->webapp_includes = NULL; entry->webapp_name = NULL; entry->webapp_domain = NULL; return entry; } void apt_cache_generator_entry_free (AptCacheGeneratorEntry *entry) { g_free (entry->name); g_free (entry->version); if (entry->webapp_includes != NULL) { g_free (entry->webapp_includes); } if (entry->webapp_name != NULL) { g_free (entry->webapp_name); } if (entry->webapp_domain != NULL) { g_free (entry->webapp_domain); } g_free (entry); } static void apt_cache_generator_entry_append_webapps_metadata (AptCacheGeneratorEntry *entry, GString *s) { if (entry->webapp_includes) { g_string_append_printf (s, "Ubuntu-Webapps-Includes: %s\n", entry->webapp_includes); } if (entry->webapp_name) { g_string_append_printf (s, "Ubuntu-Webapps-Name: %s\n", entry->webapp_name); } if (entry->webapp_domain) { g_string_append_printf (s, "Ubuntu-Webapps-Domain: %s\n", entry->webapp_domain); } } gchar * apt_cache_generator_entry_serialize (AptCacheGeneratorEntry *entry) { GString *s; gchar *serialized; s = g_string_new (""); g_string_append_printf (s, "Package: %s\n", entry->name); g_string_append_printf (s, "Version: %s\n", entry->version); s = g_string_append (s, "Description: Lorum ipsum dolor sit amet\n"); apt_cache_generator_entry_append_webapps_metadata (entry, s); serialized = s->str; g_string_free (s, FALSE); return serialized; } void apt_cache_generator_entry_add_webapp_include (AptCacheGeneratorEntry *entry, const gchar *include) { if (entry->webapp_includes == NULL) { entry->webapp_includes = g_strdup (include); } else { gchar *t; t = entry->webapp_includes; entry->webapp_includes = g_strconcat (entry->webapp_includes, ";", include, NULL); g_free (t); } } void apt_cache_generator_entry_set_webapp_name (AptCacheGeneratorEntry *entry, const gchar *webapp_name) { g_assert (entry->webapp_name == NULL); entry->webapp_name = g_strdup (webapp_name); } void apt_cache_generator_entry_set_webapp_domain (AptCacheGeneratorEntry *entry, const gchar *webapp_domain) { g_assert (entry->webapp_domain == NULL); entry->webapp_domain = g_strdup (webapp_domain); } libunity-webapps-2.5.0~+14.04.20140409/Makefile.am.coverage0000644000015301777760000000213712321247333023444 0ustar pbusernogroup00000000000000 # Coverage targets if HAVE_GCOV .PHONY: clean-gcda clean-gcda: @echo Removing old coverage results -find -name '*.gcda' -print | xargs -r rm .PHONY: coverage-html generate-coverage-html clean-coverage-html coverage-html: clean-gcda -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html coverage-xml: clean-gcda -$(MAKE) $(AM_MAKEFLAGS) -k check gcovr --xml -r $(top_builddir) -o "$(top_builddir)/coverage.xml" --exclude='.*tests.*' generate-coverage-html: @echo Collecting coverage data $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool $(LCOV) --remove coverage.info *unity-webapps-gen-* --output-file coverage.info $(LCOV) --extract coverage.info "`pwd`/src/*" --output-file coverage-src.info LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coverage-html --title "Code Coverage" --legend --show-details coverage-src.info clean-coverage-html: clean-gcda -$(LCOV) --directory $(top_builddir) -z -rm -rf coverage.info coverage-src.info coverage-html clean-local: clean-coverage-html endif # HAVE_GCOV libunity-webapps-2.5.0~+14.04.20140409/configure.ac0000644000015301777760000001104712321247333022104 0ustar pbusernogroup00000000000000dnl Process this file with autoconf to produce a configure script. dnl Created by Anjuta application wizard. AC_INIT(unity_webapps, 2.5.1) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([1.11 tar-pax]) AM_SILENT_RULES([yes]) AC_PROG_CC_C99 AC_CONFIG_MACRO_DIR([m4]) dnl *************************************************************************** dnl Internationalization dnl *************************************************************************** IT_PROG_INTLTOOL([0.35.0]) GETTEXT_PACKAGE=unity_webapps AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name]) AM_GLIB_GNU_GETTEXT LT_INIT # Beware: remember that libunity-webapps will be pulled in at runtime in # the browser runtime env. So watch out for bad mix ups in the dependancies/runtimes # e.g. adding some dependancies on gtk3 when chromium & ff are still gtk2 based. PKG_CHECK_MODULES(UNITY_WEBAPPS, [glib-2.0 gobject-2.0 gio-2.0 gio-unix-2.0 json-glib-1.0 libsoup-2.4 packagekit-glib2 polkit-gobject-1]) GLIB_GSETTINGS PKG_CHECK_MODULES(TELEPATHY_GLIB, [telepathy-glib]) PKG_CHECK_MODULES(UNITY_WEBAPPS_DAEMON, [libnotify unity messaging-menu gtk+-3.0 sqlite3 gdk-pixbuf-2.0 libwnck-3.0]) PKG_CHECK_MODULES(UNITY_WEBAPPS_WM_PID_TRACKER, [libwnck-3.0]) PKG_CHECK_MODULES(GEOCLUE, [geoclue]) PKG_CHECK_MODULES(UNITY_WEBAPPS_SERVICE_TRACKER, [gtk+-3.0 dbusmenu-glib-0.4 dbusmenu-gtk3-0.4]) PKG_CHECK_MODULES(UNITY_WEBAPPS_TOOLS, [libwnck-3.0]) GOBJECT_INTROSPECTION_CHECK([0.6.7]) AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen], AC_MSG_ERROR([gdbus-codegen is required but was not found])) AC_CHECK_LIB(gthread-2.0, g_thread_init) AC_DEFINE([UNITY_WEBAPPS_CONTAINER_APP_NAME], ["webapp-container"], [Webapp container application name.]) dnl ========== Tests ========== AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [Enable tests. [default=no]]), [enable_tests="yes"], [enable_tests="no"]) if test "x$enable_tests" = "xyes"; then AC_DEFINE([ENABLE_TESTS], 1, [Enable tests.]) # Tests need debug to be enabled enable_debug="yes" fi AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"]) dnl ===== gcov coverage reporting ===== m4_include([m4/gcov.m4]) AC_TDD_GCOV AC_SUBST(UNITY_WEBAPPS_COVERAGE_CFLAGS) AC_SUBST(UNITY_WEBAPPS_COVERAGE_CXXFLAGS) AC_SUBST(UNITY_WEBAPPS_COVERAGE_LDFLAGS) dnl =============================Debug========================================= AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable verbose debugging. [default=no]]), [enable_debug="yes"],[enable_debug="no"]) if test "x$enable_debug" = "xyes"; then UNITY_WEBAPPS_DEBUG_CFLAGS="-DUNITY_WEBAPPS_ENABLE_DEBUG -g" CFLAGS="$CFLAGS -O0 -Wall" else UNITY_WEBAPPS_DEBUG_CFLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS" CFLAGS="$CFLAGS -Wall" if test "x$need_debug" = "xyes"; then AC_MSG_ERROR([debug must be enabled in order to enable coverage.]) fi fi m4_ifdef([GTK_DOC_CHECK], [ GTK_DOC_CHECK([1.18],[--flavour no-tmpl]) ],[ AM_CONDITIONAL([ENABLE_GTK_DOC], false) ]) AC_SUBST(UNITY_WEBAPPS_DEBUG_CFLAGS) saved_CFLAGS=$CFLAGS saved_LIBS=$LIBS CFLAGS=$JS_CFLAGS LIBS=$JS_LIBS AC_CHECK_LIB(unity, unity_music_player_export) AC_CHECK_FUNC([unity_music_player_export], AC_DEFINE([HAVE_UNITY_MUSIC_PLAYER_EXPORT], [1], [Define if we already have unity_music_player_export]),) CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS AC_OUTPUT([ Makefile src/libunity-webapps/libunity_webapps-0.2.pc src/Makefile src/libunity-webapps/Makefile src/webapps-service/Makefile src/context-daemon/Makefile src/runner/Makefile src/index-updater/Makefile src/libunity-webapps-repository/libunity-webapps-repository.pc src/libunity-webapps-repository/Makefile tests/Makefile tests/context-daemon/Makefile tests/traced/Makefile tests/traced/test-runner/Makefile tests/traced/test-runner/post-actions/Makefile tests/traced/misc/Makefile tests/traced/notification/Makefile tests/traced/indicator/Makefile tests/traced/music-player/Makefile tests/traced/launcher/Makefile tests/traced/fuzz/Makefile tests/traced/actions/Makefile tests/traced/multicontext/Makefile tests/traced/observer-api/Makefile tests/traced/common/Makefile tests/repository/Makefile tests/repository/application-manifest/Makefile tests/repository/available-application/Makefile tests/repository/local-index/Makefile tests/repository/application-repository/Makefile tests/index-updater/Makefile tests/libunity-webapps/Makefile tests/misc/Makefile data/Makefile docs/Makefile docs/dbus/Makefile docs/reference/Makefile docs/reference/libunity-webapps/Makefile tools/Makefile po/Makefile.in]) libunity-webapps-2.5.0~+14.04.20140409/data/0000755000015301777760000000000012321250157020522 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/data/Makefile.am0000644000015301777760000000124012321247333022555 0ustar pbusernogroup00000000000000servicefiledir = $(datadir)/dbus-1/services servicefile_in_files = \ com.canonical.Unity.Webapps.Service.service.in servicefile_DATA = $(servicefile_in_files:.service.in=.service) gsettings_SCHEMAS = \ com.canonical.unity.webapps.gschema.xml @GSETTINGS_RULES@ com.canonical.Unity.Webapps.Service.service: com.canonical.Unity.Webapps.Service.service.in $(AM_V_GEN)sed -e "s|[@]libexecdir[@]|$(libexecdir)|" $< > $@ # Additional step used for test that need access to a compiled schema # to be environment agnostic all: glib-compile-schemas . EXTRA_DIST = \ $(gsettings_SCHEMAS) \ $(servicefile_in_files) CLEANFILES = \ $(servicefile_DATA) gschemas.compiled libunity-webapps-2.5.0~+14.04.20140409/data/com.canonical.unity.webapps.gschema.xml0000644000015301777760000000526112321247333030173 0ustar pbusernogroup00000000000000 Specifies if prompting for unity integration is enabled or not true This key specifies if any new websites that hasn't been integrated yet and is a target for a unity integration can prompt the user for permission to integrate. When disabled, previously integrated websites will still function as expected, while no new website will prompt for integration. A list of domains which are preauthorized to access Unity Integration. ["amazon.ca", "amazon.cn", "amazon.com", "amazon.co.uk", "amazon.de", "amazon.es", "amazon.fr", "amazon.it", "www.amazon.ca", "www.amazon.cn", "www.amazon.com", "www.amazon.co.uk", "www.amazon.de", "www.amazon.es", "www.amazon.fr", "www.amazon.it", "one.ubuntu.com"] This key indicates which web applications (by domain) are preauthorized to access Unity integration. That is to say that passing the permissions check depends on being in the union of this key, or the key allowed-domains. This is a seperate key from allowed-domains, and kept as such so that the default value may be changed during distribution upgrades. A list of domains which are allowed to access unity integration [] This key indicates which web applications (by domain) are allowed to access Unity integration features, such as Sound Menu, Messaging Indicator, etc... A list of domains which we will not ask to enable unity integration for [] This key indicates web applications which the user has blacklisted from accessing Unity integration features. Frequency (in seconds per job) with which unity-webapps-service will spawn the ubuntu-webapps-update-index job. 43200 The ubuntu-webapps-update-index job is responsible for maintaining an index of available applications by URL glob patterns. Currently this index is updated from apt-cache metadata. This key controls the rate at which unity-webapps-service will spawn the index updater. libunity-webapps-2.5.0~+14.04.20140409/data/com.canonical.Unity.Webapps.Service.service.in0000644000015301777760000000014012321247333031320 0ustar pbusernogroup00000000000000[D-BUS Service] Name=com.canonical.Unity.Webapps.Service Exec=@libexecdir@/unity-webapps-servicelibunity-webapps-2.5.0~+14.04.20140409/NEWS0000644000015301777760000000000012321247333020300 0ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/po/0000755000015301777760000000000012321250157020227 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/po/fa.po0000644000015301777760000000161512321247333021162 0ustar pbusernogroup00000000000000# Persian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Persian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "گشودن پنجره‌ای جدید" libunity-webapps-2.5.0~+14.04.20140409/po/kn.po0000644000015301777760000000163512321247333021206 0ustar pbusernogroup00000000000000# Kannada translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-11 14:53+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Kannada \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "ಹೊಸ ಕಿಟಕಿಯಲ್ಲಿ ತೆರೆ" libunity-webapps-2.5.0~+14.04.20140409/po/lv.po0000644000015301777760000000155012321247333021213 0ustar pbusernogroup00000000000000# Latvian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Latvian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/af.po0000644000015301777760000000162312321247333021161 0ustar pbusernogroup00000000000000# Afrikaans translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-19 11:36+0000\n" "Last-Translator: Dawid de Jager \n" "Language-Team: Afrikaans \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Maak 'n Nuwe Venster Oop" libunity-webapps-2.5.0~+14.04.20140409/po/eo.po0000644000015301777760000000155412321247333021201 0ustar pbusernogroup00000000000000# Esperanto translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Esperanto \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/ko.po0000644000015301777760000000154612321247333021210 0ustar pbusernogroup00000000000000# Korean translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Korean \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/te.po0000644000015301777760000000165012321247333021203 0ustar pbusernogroup00000000000000# Telugu translation for libunity-webapps # Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2014. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2014-01-16 19:16+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Telugu \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "ఒక కొత్త కిటికీని తెరువు" libunity-webapps-2.5.0~+14.04.20140409/po/zh_CN.po0000644000015301777760000000160512321247333021574 0ustar pbusernogroup00000000000000# Chinese (Simplified) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese (Simplified) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/it.po0000644000015301777760000000162112321247333021205 0ustar pbusernogroup00000000000000# Italian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-10 19:57+0000\n" "Last-Translator: Milo Casagrande \n" "Language-Team: Italian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Apri una nuova finestra" libunity-webapps-2.5.0~+14.04.20140409/po/en_CA.po0000644000015301777760000000161612321247333021542 0ustar pbusernogroup00000000000000# English (Canada) translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-07-02 21:36+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: English (Canada) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Open a New Window" libunity-webapps-2.5.0~+14.04.20140409/po/es.po0000644000015301777760000000160512321247333021202 0ustar pbusernogroup00000000000000# Spanish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-11 00:57+0000\n" "Last-Translator: Monkey \n" "Language-Team: Spanish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Abrir una ventana nueva" libunity-webapps-2.5.0~+14.04.20140409/po/bg.po0000644000015301777760000000162012321247333021160 0ustar pbusernogroup00000000000000# Bulgarian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-23 16:52+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Bulgarian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Отвори нов прозорец" libunity-webapps-2.5.0~+14.04.20140409/po/os.po0000644000015301777760000000161612321247333021216 0ustar pbusernogroup00000000000000# Ossetian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-08 21:43+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Ossetian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Ног рудзынг бакӕнын" libunity-webapps-2.5.0~+14.04.20140409/po/ro.po0000644000015301777760000000160512321247333021213 0ustar pbusernogroup00000000000000# Romanian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-30 01:45+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Romanian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Deschide o fereastră nouă" libunity-webapps-2.5.0~+14.04.20140409/po/is.po0000644000015301777760000000157612321247333021215 0ustar pbusernogroup00000000000000# Icelandic translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-22 08:46+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Icelandic \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Opna nýjan glugga" libunity-webapps-2.5.0~+14.04.20140409/po/POTFILES.skip0000644000015301777760000000015412321247333022346 0ustar pbusernogroup00000000000000# List of source files not containing translatable strings. tools/context-pane.xml tools/interest-pane.xml libunity-webapps-2.5.0~+14.04.20140409/po/sr.po0000644000015301777760000000162112321247333021215 0ustar pbusernogroup00000000000000# Serbian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-20 13:30+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Serbian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Отвори у новом прозору" libunity-webapps-2.5.0~+14.04.20140409/po/mhr.po0000644000015301777760000000161712321247333021364 0ustar pbusernogroup00000000000000# Mari (Meadow) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-30 06:44+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Mari (Meadow) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "У тӧрзам почаш" libunity-webapps-2.5.0~+14.04.20140409/po/cv.po0000644000015301777760000000163112321247333021202 0ustar pbusernogroup00000000000000# Chuvash translation for libunity-webapps # Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2014. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2014-03-22 15:14+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Chuvash \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Ҫӗнӗ кантӑкран уҫса кӑтарт" libunity-webapps-2.5.0~+14.04.20140409/po/uk.po0000644000015301777760000000163212321247333021212 0ustar pbusernogroup00000000000000# Ukrainian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-25 11:20+0000\n" "Last-Translator: Yuri Chornoivan \n" "Language-Team: Ukrainian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Відкрити нове вікно" libunity-webapps-2.5.0~+14.04.20140409/po/br.po0000644000015301777760000000160012321247333021171 0ustar pbusernogroup00000000000000# Breton translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-18 06:29+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Breton \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Digeriñ ur prenestr nevez" libunity-webapps-2.5.0~+14.04.20140409/po/sv.po0000644000015301777760000000160012321247333021216 0ustar pbusernogroup00000000000000# Swedish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Swedish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Öppna ett nytt fönster" libunity-webapps-2.5.0~+14.04.20140409/po/zh_HK.po0000644000015301777760000000162212321247333021575 0ustar pbusernogroup00000000000000# Chinese (Hong Kong) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-09 15:47+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese (Hong Kong) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "開啟新視窗" libunity-webapps-2.5.0~+14.04.20140409/po/sd.po0000644000015301777760000000160012321247333021174 0ustar pbusernogroup00000000000000# Sindhi translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-05 19:46+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Sindhi \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "نئي ونڊو کوليو" libunity-webapps-2.5.0~+14.04.20140409/po/id.po0000644000015301777760000000157712321247333021177 0ustar pbusernogroup00000000000000# Indonesian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Indonesian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Buka Jendela Baru" libunity-webapps-2.5.0~+14.04.20140409/po/ja.po0000644000015301777760000000155212321247333021166 0ustar pbusernogroup00000000000000# Japanese translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Japanese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/oc.po0000644000015301777760000000160012321247333021167 0ustar pbusernogroup00000000000000# Occitan (post 1500) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Occitan (post 1500) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/si.po0000644000015301777760000000166412321247333021213 0ustar pbusernogroup00000000000000# Sinhalese translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-03-09 05:22+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Sinhalese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "අලුත් කවුළුවක් විවෘත කරන්න" libunity-webapps-2.5.0~+14.04.20140409/po/nl.po0000644000015301777760000000154412321247333021206 0ustar pbusernogroup00000000000000# Dutch translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Dutch \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/pa.po0000644000015301777760000000162712321247333021177 0ustar pbusernogroup00000000000000# Punjabi translation for libunity-webapps # Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2014. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2014-02-02 00:04+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Punjabi \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "ਨਵੀਂ ਵਿੰਡੋ ਖੋਲ੍ਹੋ" libunity-webapps-2.5.0~+14.04.20140409/po/tr.po0000644000015301777760000000157112321247333021222 0ustar pbusernogroup00000000000000# Turkish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-05-25 22:45+0000\n" "Last-Translator: Volkan Gezer \n" "Language-Team: Turkish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Yeni Bir Pencere Aç" libunity-webapps-2.5.0~+14.04.20140409/po/ku.po0000644000015301777760000000155012321247333021211 0ustar pbusernogroup00000000000000# Kurdish translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-06-14 14:29+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Kurdish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/sq.po0000644000015301777760000000155212321247333021217 0ustar pbusernogroup00000000000000# Albanian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Albanian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/ckb.po0000644000015301777760000000164312321247333021334 0ustar pbusernogroup00000000000000# Kurdish (Sorani) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-31 14:18+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Kurdish (Sorani) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "پەنجەرەیەکی نوێ بکەوە" libunity-webapps-2.5.0~+14.04.20140409/po/ug.po0000644000015301777760000000160612321247333021207 0ustar pbusernogroup00000000000000# Uyghur translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-05 01:35+0000\n" "Last-Translator: Gheyret T.Kenji \n" "Language-Team: Uyghur \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "يېڭى كۆزنەك ئېچىش" libunity-webapps-2.5.0~+14.04.20140409/po/fr_CA.po0000644000015301777760000000162712321247333021551 0ustar pbusernogroup00000000000000# French (Canada) translation for libunity-webapps # Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2014. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2014-01-30 00:41+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: French (Canada) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Ouvrir une nouvelle fenêtre" libunity-webapps-2.5.0~+14.04.20140409/po/hr.po0000644000015301777760000000157412321247333021211 0ustar pbusernogroup00000000000000# Croatian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Croatian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Otvori novi prozor" libunity-webapps-2.5.0~+14.04.20140409/po/pl.po0000644000015301777760000000154612321247333021212 0ustar pbusernogroup00000000000000# Polish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Polish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/bn.po0000644000015301777760000000155012321247333021171 0ustar pbusernogroup00000000000000# Bengali translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Bengali \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/uz.po0000644000015301777760000000160612321247333021232 0ustar pbusernogroup00000000000000# Uzbek translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-27 05:39+0000\n" "Last-Translator: Ruslan Rustamov \n" "Language-Team: Uzbek \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Yangi oyna ochish" libunity-webapps-2.5.0~+14.04.20140409/po/am.po0000644000015301777760000000161312321247333021167 0ustar pbusernogroup00000000000000# Amharic translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-08 00:15+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Amharic \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "አዲስ መስኮት መክፈቻ" libunity-webapps-2.5.0~+14.04.20140409/po/wae.po0000644000015301777760000000154712321247333021354 0ustar pbusernogroup00000000000000# Walser translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Walser \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/nn.po0000644000015301777760000000162212321247333021205 0ustar pbusernogroup00000000000000# Norwegian Nynorsk translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-08-09 11:22+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Norwegian Nynorsk \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Opna eit nytt vindauge" libunity-webapps-2.5.0~+14.04.20140409/po/de.po0000644000015301777760000000154612321247333021167 0ustar pbusernogroup00000000000000# German translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/unity_webapps.pot0000644000015301777760000000134612321247333023652 0ustar pbusernogroup00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2012-11-29 08:50-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/da.po0000644000015301777760000000157012321247333021160 0ustar pbusernogroup00000000000000# Danish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Danish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Åbn et nyt vindue" libunity-webapps-2.5.0~+14.04.20140409/po/ca@valencia.po0000644000015301777760000000163712321247333022766 0ustar pbusernogroup00000000000000# Catalan (Valencian) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-19 06:52+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Catalan (Valencian) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Obri una finestra nova" libunity-webapps-2.5.0~+14.04.20140409/po/fo.po0000644000015301777760000000160112321247333021173 0ustar pbusernogroup00000000000000# Faroese translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-29 20:51+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Faroese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Opna í nýggjum vindeyga" libunity-webapps-2.5.0~+14.04.20140409/po/ca.po0000644000015301777760000000161712321247333021161 0ustar pbusernogroup00000000000000# Catalan translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-19 06:19+0000\n" "Last-Translator: David Planella \n" "Language-Team: Catalan \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Obre una finestra nova" libunity-webapps-2.5.0~+14.04.20140409/po/et.po0000644000015301777760000000156612321247333021211 0ustar pbusernogroup00000000000000# Estonian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-25 17:03+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Estonian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Ava uus aken" libunity-webapps-2.5.0~+14.04.20140409/po/en_AU.po0000644000015301777760000000160312321247333021560 0ustar pbusernogroup00000000000000# English (Australia) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: English (Australia) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/ml.po0000644000015301777760000000164412321247333021206 0ustar pbusernogroup00000000000000# Malayalam translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-29 19:54+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Malayalam \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "പുതിയ ജാലകം തുറക്കുക" libunity-webapps-2.5.0~+14.04.20140409/po/gd.po0000644000015301777760000000157212321247333021170 0ustar pbusernogroup00000000000000# Gaelic; Scottish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Gaelic; Scottish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/sl.po0000644000015301777760000000161712321247333021214 0ustar pbusernogroup00000000000000# Slovenian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-07 13:36+0000\n" "Last-Translator: Andrej Znidarsic \n" "Language-Team: Slovenian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Odpri novo okno" libunity-webapps-2.5.0~+14.04.20140409/po/miq.po0000644000015301777760000000157512321247333021367 0ustar pbusernogroup00000000000000# Miskito translation for libunity-webapps # Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2014. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2014-01-07 16:59+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Miskito \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Windar raya kwâkaia" libunity-webapps-2.5.0~+14.04.20140409/po/ta.po0000644000015301777760000000164212321247333021200 0ustar pbusernogroup00000000000000# Tamil translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-09-09 11:34+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Tamil \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "புதியதொரு சாளரத்தை திற" libunity-webapps-2.5.0~+14.04.20140409/po/be.po0000644000015301777760000000162512321247333021163 0ustar pbusernogroup00000000000000# Belarusian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-23 08:00+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Belarusian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Адчыніць у новым акне" libunity-webapps-2.5.0~+14.04.20140409/po/ast.po0000644000015301777760000000160212321247333021357 0ustar pbusernogroup00000000000000# Asturian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-03 01:46+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Asturian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Abrir una ventana nueva" libunity-webapps-2.5.0~+14.04.20140409/po/lb.po0000644000015301777760000000161512321247333021171 0ustar pbusernogroup00000000000000# Luxembourgish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-22 09:37+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Luxembourgish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Eng nei Fënster omaachen" libunity-webapps-2.5.0~+14.04.20140409/po/ky.po0000644000015301777760000000160612321247333021217 0ustar pbusernogroup00000000000000# Kirghiz translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-07 18:56+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Kirghiz \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Жаңы терезе ачуу" libunity-webapps-2.5.0~+14.04.20140409/po/zh_TW.po0000644000015301777760000000160712321247333021630 0ustar pbusernogroup00000000000000# Chinese (Traditional) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese (Traditional) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/gu.po0000644000015301777760000000163412321247333021210 0ustar pbusernogroup00000000000000# Gujarati translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-12 12:03+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Gujarati \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "નવી વિન્ડોમાં ખોલો" libunity-webapps-2.5.0~+14.04.20140409/po/nb.po0000644000015301777760000000161212321247333021170 0ustar pbusernogroup00000000000000# Norwegian Bokmal translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-22 02:11+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Norwegian Bokmal \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Åpne nytt vindu" libunity-webapps-2.5.0~+14.04.20140409/po/LINGUAS0000644000015301777760000000033212321247333021254 0ustar pbusernogroup00000000000000af am ar ast bn bo br bs ca ca cs cy da de el en_AU en_GB eo es eu fa fi fr gd gl gu he hr hu id is it ja ko lt lv ml mr ms my nb nl oc os pl pt_BR pt ro ru ru_RU sd sk sl sq sr sv tr ug uk uz vi wae zh_CN zh_HK zh_TW libunity-webapps-2.5.0~+14.04.20140409/po/ChangeLog0000644000015301777760000000000012321247333021771 0ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/po/ru_RU.po0000644000015301777760000000140612321247333021626 0ustar pbusernogroup00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2012-09-21 15:39+0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:428 msgid "Open a New Window" msgstr "Открыть новое Окно" libunity-webapps-2.5.0~+14.04.20140409/po/en_GB.po0000644000015301777760000000163412321247333021547 0ustar pbusernogroup00000000000000# English (United Kingdom) translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-26 09:56+0000\n" "Last-Translator: Andi Chandler \n" "Language-Team: English (United Kingdom) \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Open a New Window" libunity-webapps-2.5.0~+14.04.20140409/po/sc.po0000644000015301777760000000160112321247333021174 0ustar pbusernogroup00000000000000# Sardinian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-19 23:36+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Sardinian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Aberi una Ventana Noa" libunity-webapps-2.5.0~+14.04.20140409/po/cs.po0000644000015301777760000000161212321247333021176 0ustar pbusernogroup00000000000000# Czech translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-10 11:30+0000\n" "Last-Translator: Vojtěch Trefný \n" "Language-Team: Czech \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Otevřít nové okno" libunity-webapps-2.5.0~+14.04.20140409/po/mr.po0000644000015301777760000000155012321247333021210 0ustar pbusernogroup00000000000000# Marathi translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Marathi \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/ar.po0000644000015301777760000000162012321247333021172 0ustar pbusernogroup00000000000000# Arabic translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-03 17:12+0000\n" "Last-Translator: Ibrahim Saed \n" "Language-Team: Arabic \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "افتح نافذة جديدة" libunity-webapps-2.5.0~+14.04.20140409/po/fi.po0000644000015301777760000000156712321247333021200 0ustar pbusernogroup00000000000000# Finnish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-12 08:31+0000\n" "Last-Translator: Jiri Grönroos \n" "Language-Team: Finnish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Avaa uusi ikkuna" libunity-webapps-2.5.0~+14.04.20140409/po/eu.po0000644000015301777760000000154612321247333021210 0ustar pbusernogroup00000000000000# Basque translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Basque \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/lt.po0000644000015301777760000000155612321247333021217 0ustar pbusernogroup00000000000000# Lithuanian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Lithuanian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/POTFILES.in0000644000015301777760000000015512321247333022007 0ustar pbusernogroup00000000000000# List of source files containing translatable strings. src/context-daemon/unity-webapps-launcher-context.c libunity-webapps-2.5.0~+14.04.20140409/po/az.po0000644000015301777760000000160312321247333021203 0ustar pbusernogroup00000000000000# Azerbaijani translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-02-23 18:00+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Azerbaijani \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Yeni Pəncərə aç" libunity-webapps-2.5.0~+14.04.20140409/po/cy.po0000644000015301777760000000156712321247333021215 0ustar pbusernogroup00000000000000# Welsh translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-15 07:58+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Welsh \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Agor Ffenest Newydd" libunity-webapps-2.5.0~+14.04.20140409/po/sk.po0000644000015301777760000000154612321247333021214 0ustar pbusernogroup00000000000000# Slovak translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Slovak \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/ms.po0000644000015301777760000000155612321247333021217 0ustar pbusernogroup00000000000000# Malay translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-26 12:41+0000\n" "Last-Translator: abuyop \n" "Language-Team: Malay \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Buka Tetingkap Baru" libunity-webapps-2.5.0~+14.04.20140409/po/kk.po0000644000015301777760000000160212321247333021175 0ustar pbusernogroup00000000000000# Kazakh translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-12-23 21:10+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Kazakh \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Жаңа терезе ашу" libunity-webapps-2.5.0~+14.04.20140409/po/gl.po0000644000015301777760000000155212321247333021176 0ustar pbusernogroup00000000000000# Galician translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Galician \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/ga.po0000644000015301777760000000156712321247333021171 0ustar pbusernogroup00000000000000# Irish translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-06-17 23:01+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Irish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Oscail fuinneog nua" libunity-webapps-2.5.0~+14.04.20140409/po/pt_BR.po0000644000015301777760000000163212321247333021601 0ustar pbusernogroup00000000000000# Brazilian Portuguese translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Brazilian Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Abrir uma nova janela" libunity-webapps-2.5.0~+14.04.20140409/po/pt.po0000644000015301777760000000157712321247333021226 0ustar pbusernogroup00000000000000# Portuguese translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-20 00:02+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Abrir Nova Janela" libunity-webapps-2.5.0~+14.04.20140409/po/my.po0000644000015301777760000000155012321247333021217 0ustar pbusernogroup00000000000000# Burmese translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Burmese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/bs.po0000644000015301777760000000155012321247333021176 0ustar pbusernogroup00000000000000# Bosnian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Bosnian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/fr.po0000644000015301777760000000154612321247333021206 0ustar pbusernogroup00000000000000# French translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: French \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/vi.po0000644000015301777760000000155612321247333021216 0ustar pbusernogroup00000000000000# Vietnamese translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Vietnamese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/km.po0000644000015301777760000000156512321247333021207 0ustar pbusernogroup00000000000000# Khmer translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-07-01 07:56+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Khmer \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Open a New Window" libunity-webapps-2.5.0~+14.04.20140409/po/el.po0000644000015301777760000000154412321247333021175 0ustar pbusernogroup00000000000000# Greek translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Greek \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/hi.po0000644000015301777760000000162412321247333021174 0ustar pbusernogroup00000000000000# Hindi translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-12-31 13:52+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Hindi \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "एक नया विंडो खोलें" libunity-webapps-2.5.0~+14.04.20140409/po/hu.po0000644000015301777760000000155412321247333021212 0ustar pbusernogroup00000000000000# Hungarian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Hungarian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/ru.po0000644000015301777760000000163112321247333021220 0ustar pbusernogroup00000000000000# Russian translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-04-26 06:49+0000\n" "Last-Translator: Dennis Kowalski \n" "Language-Team: Russian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Открыть новое окно" libunity-webapps-2.5.0~+14.04.20140409/po/tg.po0000644000015301777760000000162112321247333021203 0ustar pbusernogroup00000000000000# Tajik translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-04-16 06:42+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Tajik \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Кушодан дар равзанаи нав" libunity-webapps-2.5.0~+14.04.20140409/po/hy.po0000644000015301777760000000161412321247333021213 0ustar pbusernogroup00000000000000# Armenian translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-07-08 14:27+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Armenian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Բացել նոր պատուհան" libunity-webapps-2.5.0~+14.04.20140409/po/th.po0000644000015301777760000000154212321247333021206 0ustar pbusernogroup00000000000000# Thai translation for libunity-webapps # Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2013. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2013-10-19 04:10+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Thai \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/he.po0000644000015301777760000000154612321247333021173 0ustar pbusernogroup00000000000000# Hebrew translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-09-21 11:09+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Hebrew \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "" libunity-webapps-2.5.0~+14.04.20140409/po/kw.po0000644000015301777760000000157512321247333021222 0ustar pbusernogroup00000000000000# Cornish translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-11-05 23:28+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Cornish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "Ygeri fenester nowydh" libunity-webapps-2.5.0~+14.04.20140409/po/bo.po0000644000015301777760000000166312321247333021177 0ustar pbusernogroup00000000000000# Tibetan translation for libunity-webapps # Copyright (c) 2012 Rosetta Contributors and Canonical Ltd 2012 # This file is distributed under the same license as the libunity-webapps package. # FIRST AUTHOR , 2012. # msgid "" msgstr "" "Project-Id-Version: libunity-webapps\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2014-04-08 07:05+0000\n" "PO-Revision-Date: 2012-10-07 12:21+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Tibetan \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2014-04-09 06:55+0000\n" "X-Generator: Launchpad (build 16976)\n" #: ../src/context-daemon/unity-webapps-launcher-context.c:74 #: ../src/context-daemon/unity-webapps-launcher-context.c:429 msgid "Open a New Window" msgstr "སྒེའུ་ཁུང་གསར་པ་ཞིག་ཁ་ཕྱེ" libunity-webapps-2.5.0~+14.04.20140409/ChangeLog0000644000015301777760000000000212321247333021355 0ustar pbusernogroup00000000000000 libunity-webapps-2.5.0~+14.04.20140409/autogen.sh0000755000015301777760000001051412321247333021615 0ustar pbusernogroup00000000000000#!/bin/sh # Run this to generate all the initial makefiles, etc. srcdir=`dirname $0` test -z "$srcdir" && srcdir=. DIE=0 if [ -n "$GNOME2_DIR" ]; then ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS" LD_LIBRARY_PATH="$GNOME2_DIR/lib:$LD_LIBRARY_PATH" PATH="$GNOME2_DIR/bin:$PATH" export PATH export LD_LIBRARY_PATH fi (test -f $srcdir/configure.ac) || { echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" echo " top-level package directory" exit 1 } (autoconf --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`autoconf' installed." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } (grep "^IT_PROG_INTLTOOL" $srcdir/configure.ac >/dev/null) && { (intltoolize --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`intltool' installed." echo "You can get it from:" echo " ftp://ftp.gnome.org/pub/GNOME/" DIE=1 } } (grep "^AM_PROG_XML_I18N_TOOLS" $srcdir/configure.ac >/dev/null) && { (xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`xml-i18n-toolize' installed." echo "You can get it from:" echo " ftp://ftp.gnome.org/pub/GNOME/" DIE=1 } } (grep "^LT_INIT" $srcdir/configure.ac >/dev/null) && { (libtool --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`libtool' installed." echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" DIE=1 } } (grep "^AM_GLIB_GNU_GETTEXT" $srcdir/configure.ac >/dev/null) && { (grep "sed.*POTFILES" $srcdir/configure.ac) > /dev/null || \ (glib-gettextize --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`glib' installed." echo "You can get it from: ftp://ftp.gtk.org/pub/gtk" DIE=1 } } (automake --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`automake' installed." echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" DIE=1 NO_AUTOMAKE=yes } # if no automake, don't bother testing for aclocal test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: Missing \`aclocal'. The version of \`automake'" echo "installed doesn't appear recent enough." echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/" DIE=1 } if test "$DIE" -eq 1; then exit 1 fi if test -z "$*"; then echo "**Warning**: I am going to run \`configure' with no arguments." echo "If you wish to pass any to it, please specify them on the" echo \`$0\'" command line." echo fi case $CC in xlc ) am_opt=--include-deps;; esac for coin in `find $srcdir -path $srcdir/CVS -prune -o -name configure.ac -print` do dr=`dirname $coin` if test -f $dr/NO-AUTO-GEN; then echo skipping $dr -- flagged as no auto-gen else echo processing $dr ( cd $dr aclocalinclude="$ACLOCAL_FLAGS" if grep "^AM_GLIB_GNU_GETTEXT" configure.ac >/dev/null; then echo "Creating $dr/aclocal.m4 ..." test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 echo "Running glib-gettextize... Ignore non-fatal messages." echo "no" | glib-gettextize --force --copy echo "Making $dr/aclocal.m4 writable ..." test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 fi if grep "^IT_PROG_INTLTOOL" configure.ac >/dev/null; then echo "Running intltoolize..." intltoolize --copy --force --automake fi if grep "^AM_PROG_XML_I18N_TOOLS" configure.ac >/dev/null; then echo "Running xml-i18n-toolize..." xml-i18n-toolize --copy --force --automake fi if grep "^LT_INIT" configure.ac >/dev/null; then if test -z "$NO_LIBTOOLIZE" ; then echo "Running libtoolize..." libtoolize --force --copy fi fi echo "Running aclocal $aclocalinclude ..." aclocal $aclocalinclude if grep "^A[CM]_CONFIG_HEADER" configure.ac >/dev/null; then echo "Running autoheader..." autoheader fi echo "Running automake --gnu $am_opt ..." automake --add-missing --gnu $am_opt echo "Running autoconf ..." autoconf ) fi done if test x$NOCONFIGURE = x; then echo Running $srcdir/configure "$@" ... $srcdir/configure "$@" \ && echo Now type \`make\' to compile. || exit 1 else echo Skipping configure process. fi libunity-webapps-2.5.0~+14.04.20140409/COPYING0000644000015301777760000001673012321247333020655 0ustar pbusernogroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. libunity-webapps-2.5.0~+14.04.20140409/src/0000755000015301777760000000000012321250157020400 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/Makefile.am0000644000015301777760000000504612321247333022443 0ustar pbusernogroup00000000000000## Process this file with automake to produce Makefile.in ## Created by Anjuta EXTRA_DIST = unity-webapps-url-db.c unity-webapps-url-db.h webapps-service.xml webapps-context-daemon.xml webapps-notification.xml webapps-indicator.xml webapps-music-player.xml webapps-launcher.xml BUILT_SOURCES = CLEANFILES = unity-webapps-gen-service.c unity-webapps-gen-service.h: webapps-service.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --c-namespace UnityWebappsGen \ --generate-c-code unity-webapps-gen-service \ --c-generate-object-manager \ --interface-prefix com.canonical.Unity.Webapps. \ $< unity-webapps-gen-notification.c unity-webapps-gen-notification.h: webapps-notification.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --c-namespace UnityWebappsGen \ --generate-c-code unity-webapps-gen-notification \ --interface-prefix com.canonical.Unity.Webapps. \ $< unity-webapps-gen-indicator.c unity-webapps-gen-indicator.h: webapps-indicator.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --c-namespace UnityWebappsGen \ --generate-c-code unity-webapps-gen-indicator \ --interface-prefix com.canonical.Unity.Webapps. \ $< unity-webapps-gen-music-player.c unity-webapps-gen-music-player.h: webapps-music-player.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --c-namespace UnityWebappsGen \ --generate-c-code unity-webapps-gen-music-player \ --interface-prefix com.canonical.Unity.Webapps. \ $< unity-webapps-gen-context.c unity-webapps-gen-context.h: webapps-context-daemon.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --c-namespace UnityWebappsGen \ --generate-c-code unity-webapps-gen-context \ --interface-prefix com.canonical.Unity.Webapps. \ $< unity-webapps-gen-launcher.c unity-webapps-gen-launcher.h: webapps-launcher.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --c-namespace UnityWebappsGen \ --generate-c-code unity-webapps-gen-launcher \ --interface-prefix com.canonical.Unity.Webapps. \ $< libunity_webapps_gdbus_codegen_sources = \ unity-webapps-gen-service.c \ unity-webapps-gen-context.c \ unity-webapps-gen-notification.c \ unity-webapps-gen-indicator.c \ unity-webapps-gen-music-player.c \ unity-webapps-gen-launcher.c libunity_webapps_gdbus_codegen_headers = \ unity-webapps-gen-service.h \ unity-webapps-gen-context.h \ unity-webapps-gen-notification.h \ unity-webapps-gen-indicator.h \ unity-webapps-gen-music-player.h \ unity-webapps-gen-launcher.h BUILT_SOURCES += $(libunity_webapps_gdbus_codegen_sources) BUILT_SOURCES += $(libunity_webapps_gdbus_codegen_headers) all: $(BUILT_SOURCES) SUBDIRS = libunity-webapps webapps-service context-daemon runner index-updater libunity-webapps-repository libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-url-db.c0000644000015301777760000001473712321247333024554 0ustar pbusernogroup00000000000000#include "unity-webapps-url-db.h" #include "unity-webapps-dirs.h" #include "unity-webapps-debug.h" #include struct _UnityWebappsUrlDB { sqlite3 *db; }; #define CREATE_URL_TABLE_SQL "CREATE TABLE IF NOT EXISTS urls(url TEXT, package TEXT, appname TEXT, domain TEXT, PRIMARY KEY(url));" #define INSERT_URL_SQL_TEMPLATE "INSERT OR REPLACE INTO urls(url, package, appname, domain) VALUES (%Q, %Q, %Q, %Q);" #define LOOKUP_URLS_SQL_TEMPLATE "SELECT package, appname, domain FROM urls WHERE %Q GLOB url;" #define UNITY_WEBAPPS_URL_DB_DEFAULT_PATH_ENV_VARIABLE "UNITY_WEBAPPS_URL_DB_DEFAULT_PATH" static sqlite3_stmt * unity_webapps_url_db_insert_url_prepare_statement (UnityWebappsUrlDB *url_db, const gchar *url, UnityWebappsUrlDBRecord *record) { gchar *statement_sql, *stripped_url, *stripped_package; sqlite3_stmt *statement; gint rc; stripped_url = g_strdup(url); stripped_url = g_strstrip (stripped_url); stripped_package = g_strdup(record->package_name); stripped_package = g_strstrip(stripped_package); statement_sql = sqlite3_mprintf (INSERT_URL_SQL_TEMPLATE, stripped_url, stripped_package, record->application_name, record->domain); statement = NULL; rc = sqlite3_prepare_v2 (url_db->db, statement_sql, -1, &statement, NULL); if (rc != SQLITE_OK) { UNITY_WEBAPPS_NOTE (URL_DB, "Failed to compile URL DB insert URL statement: %s", sqlite3_errmsg (url_db->db)); } sqlite3_free (statement_sql); g_free (stripped_url); g_free (stripped_package); return statement; } static sqlite3_stmt * unity_webapps_url_db_lookup_urls_prepare_statement (UnityWebappsUrlDB *url_db, const gchar *url) { gchar *statement_sql; sqlite3_stmt *statement; gint rc; statement_sql = sqlite3_mprintf (LOOKUP_URLS_SQL_TEMPLATE, url); statement = NULL; rc = sqlite3_prepare_v2 (url_db->db, statement_sql, -1, &statement, NULL); if (rc != SQLITE_OK) { UNITY_WEBAPPS_NOTE (URL_DB, "Failed to compile URL DB lookup URLs statement: %s", sqlite3_errmsg (url_db->db)); } sqlite3_free (statement_sql); return statement; } gboolean unity_webapps_url_db_lookup_urls (UnityWebappsUrlDB *url_db, const gchar *url, GList **out_records) { GList *records; sqlite3_stmt *url_statement; int rc; gboolean ret = TRUE; *out_records = records = NULL; url_statement = unity_webapps_url_db_lookup_urls_prepare_statement (url_db, url); if (url_statement == NULL) { return FALSE; } do { const gchar *package_name; const gchar *app_name; const gchar *app_domain; rc = sqlite3_step (url_statement); if (rc != SQLITE_ROW) { continue; } package_name = (const gchar *)sqlite3_column_text (url_statement, 0); app_name = (const gchar *)sqlite3_column_text (url_statement, 1); app_domain = (const gchar *)sqlite3_column_text (url_statement, 2); records = g_list_append (records, unity_webapps_url_db_record_new (package_name, app_name, app_domain)); } while (rc == SQLITE_ROW); if (rc != SQLITE_DONE) { ret = FALSE; } sqlite3_finalize (url_statement); *out_records = records; return ret; } gboolean unity_webapps_url_db_insert_url (UnityWebappsUrlDB *url_db, const gchar *url, UnityWebappsUrlDBRecord *record) { sqlite3_stmt *url_statement; int rc; gboolean ret = TRUE; url_statement = unity_webapps_url_db_insert_url_prepare_statement (url_db, url, record); if (url_statement == NULL) { return FALSE; } rc = sqlite3_step (url_statement); if (rc != SQLITE_DONE) { g_warning ("Error updating url in url db: %s", sqlite3_errmsg (url_db->db)); ret = FALSE; goto out; } out: sqlite3_finalize (url_statement); return ret; } static int unity_webapps_url_db_create_tables (UnityWebappsUrlDB *url_db) { int rc; gchar *error_message; error_message = NULL; rc = sqlite3_exec (url_db->db, CREATE_URL_TABLE_SQL, NULL, 0, &error_message); if (rc != SQLITE_OK) { UNITY_WEBAPPS_NOTE (URL_DB, "Error creating URL db table: %s\n", error_message); sqlite3_free (error_message); } return rc; } UnityWebappsUrlDB * unity_webapps_url_db_open (gboolean read_only, const gchar *database_path) { UnityWebappsUrlDB *url_db; int rc; url_db = g_malloc0 (sizeof (UnityWebappsUrlDB)); rc = sqlite3_open (database_path, &url_db->db); if (rc != 0) { UNITY_WEBAPPS_NOTE (URL_DB, "Failed to open app url database : %s \n", sqlite3_errmsg(url_db->db)); sqlite3_close (url_db->db); g_free (url_db); return NULL; } rc = unity_webapps_url_db_create_tables (url_db); if (rc != 0) { sqlite3_close (url_db->db); g_free (url_db); return NULL; } return url_db; } void unity_webapps_url_db_free (UnityWebappsUrlDB *url_db) { sqlite3_close (url_db->db); g_free (url_db); } UnityWebappsUrlDB * unity_webapps_url_db_open_default (gboolean read_only) { UnityWebappsUrlDB *default_db; const gchar *uwa_user_dir; const gchar *env_db_path; gchar *db_path; env_db_path = g_getenv (UNITY_WEBAPPS_URL_DB_DEFAULT_PATH_ENV_VARIABLE); if (env_db_path != NULL) { default_db = unity_webapps_url_db_open (read_only, env_db_path); return default_db; } uwa_user_dir = unity_webapps_dirs_get_user_dir (); db_path = g_build_filename (uwa_user_dir, "availableapps-v2.db", NULL); default_db = unity_webapps_url_db_open (read_only, db_path); g_free (db_path); return default_db; } UnityWebappsUrlDBRecord * unity_webapps_url_db_record_new (const gchar *package_name, const gchar *application_name, const gchar *application_domain) { UnityWebappsUrlDBRecord *record; record = g_malloc0 (sizeof (UnityWebappsUrlDBRecord)); record->package_name = g_strdup (package_name); record->application_name = g_strdup (application_name); record->domain = g_strdup (application_domain); return record; } void unity_webapps_url_db_record_free (UnityWebappsUrlDBRecord *record) { g_free (record->package_name); g_free (record->application_name); g_free (record->domain); g_free (record); } void unity_webapps_url_db_record_list_free (GList *record_list) { GList *w; for (w = record_list; w != NULL; w = w->next) { UnityWebappsUrlDBRecord *record; record = (UnityWebappsUrlDBRecord *)w->data; unity_webapps_url_db_record_free (record); } g_list_free (record_list); } libunity-webapps-2.5.0~+14.04.20140409/src/webapps-launcher.xml0000644000015301777760000000225212321247333024365 0ustar pbusernogroup00000000000000 libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-wire-version.h0000644000015301777760000000164612321247333026020 0ustar pbusernogroup00000000000000/* * unity-webapps-wire-version.h * Copyright (C) Canonical LTD 2012 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef _UNITY_WEBAPPS_WIRE_VERSION_H #define _UNITY_WEBAPPS_WIRE_VERSION_H #define UNITY_WEBAPPS_WIRE_PROTOCOL_VERSION "501712" #endif libunity-webapps-2.5.0~+14.04.20140409/src/webapps-notification.xml0000644000015301777760000000044712321247333025256 0ustar pbusernogroup00000000000000 libunity-webapps-2.5.0~+14.04.20140409/src/runner/0000755000015301777760000000000012321250157021711 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/runner/Makefile.am0000644000015301777760000000105012321247333023743 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ $(GEOCLUE_CFLAGS) \ -I$(top_srcdir)/src/libunity-webapps bin_PROGRAMS = \ unity-webapps-runner unity_webapps_runner_SOURCES = \ unity-webapps-runner.c \ unity-webapps-runner-amazon.c \ ../unity-webapps-desktop-infos.c \ ../unity-webapps-string-utils.c \ unity-webapps-runner-amazon.h unity_webapps_runner_LDFLAGS = $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) unity_webapps_runner_LDADD = $(UNITY_WEBAPPS_LIBS) \ $(GEOCLUE_LIBS) \ ../libunity-webapps/libunity-webapps.la libunity-webapps-2.5.0~+14.04.20140409/src/runner/unity-webapps-runner.c0000644000015301777760000002153612321247364026210 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-runner.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include "unity-webapps-service.h" #include "unity-webapps-context.h" #include "../unity-webapps-desktop-infos.h" #include "../unity-webapps-string-utils.h" #include "unity-webapps-runner-amazon.h" #include "config.h" static UnityWebappsService *service = NULL; static gchar *name = NULL; static gchar *domain = NULL; static gchar *homepage = NULL; static gchar *app_id = NULL; static gchar *url_patterns = NULL; static gboolean amazon = FALSE; static gboolean chromeless = TRUE; static gboolean store_session_cookies = FALSE; GMainLoop *loop = NULL; static GOptionEntry option_entries[] = { { "name", 'n',0,G_OPTION_ARG_STRING, &name, "Application name (base64 encoded)", NULL }, { "domain", 'd',0, G_OPTION_ARG_STRING, &domain, "Application domain", NULL}, { "amazon", 'a',0, G_OPTION_ARG_NONE, &amazon, "Launch amazon (with geoclue store selection)", NULL}, { "homepage", 'h',0, G_OPTION_ARG_STRING, &homepage, "Launch a webapp directly from its homepage", NULL}, { "app-id", 'i',0, G_OPTION_ARG_STRING, &app_id, "Launch a webapp with a specific APP_ID", NULL}, { "chrome", 'c',G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &chromeless, "Launch a webapp in default browser", NULL}, { "urlPatterns", 'u',0,G_OPTION_ARG_STRING, &url_patterns, "Add url coma separated patterns to the list that filters allowed urls for container navigation", NULL}, { "store-session-cookies", 's', 0, G_OPTION_ARG_NONE, &store_session_cookies, "Store the session cookies in the cookie jar", NULL}, { NULL } }; gboolean has_context (const gchar *name, const gchar *domain) { gboolean res = FALSE; gchar** it; gchar** contexts = unity_webapps_service_list_contexts (service); for (it = contexts; it && *it; it++) { UnityWebappsContext *context = unity_webapps_context_new_for_context_name (service, *it); res = res || ((g_strcmp0 (unity_webapps_context_get_name (context), name) == 0) && (g_strcmp0 (unity_webapps_context_get_domain (context), domain) == 0)); g_object_unref (context); } return res; } static void on_context_appeared (UnityWebappsService *service, const gchar *context_name, gpointer user_data) { UnityWebappsContext *context = unity_webapps_context_new_for_context_name (service, context_name); if ((g_strcmp0 (unity_webapps_context_get_name (context), name) == 0) && (g_strcmp0 (unity_webapps_context_get_domain (context), domain) == 0)) { g_usleep (G_USEC_PER_SEC * 2); g_main_loop_quit (loop); } g_object_unref (context); } static void open_webapp_with_legacy_chromeless (gchar * name, gchar * domain, gchar **files) { gsize len; len = 0; g_base64_decode_inplace (name, &len); name[len] = 0; g_message("Launching webapp '%s' with the legacy container", name); gboolean has_files = files && files[0]; if (has_files && !has_context (name, domain)) { loop = g_main_loop_new (NULL, FALSE); unity_webapps_service_on_context_appeared (service, on_context_appeared, NULL); unity_webapps_service_activate_application (service, name, domain, (const gchar * const*)files); g_main_loop_run (loop); unity_webapps_service_activate_application (service, name, domain, (const gchar * const*)files); } else { unity_webapps_service_activate_application (service, name, domain, (const gchar * const*)files); } } static gchar * make_url_patterns_arg_for_container(const gchar * const url_patterns) { gchar *url_patterns_args; gchar *default_no_arg; default_no_arg = g_strdup(""); if ( ! url_patterns) return default_no_arg; url_patterns_args = g_strdup(url_patterns); g_strstrip(url_patterns_args); if (strlen(url_patterns_args) == 0) return default_no_arg; return g_strdup_printf("--webappUrlPatterns=%s", url_patterns); } static void open_webapp_with_container_with_url(const gchar *url, const gchar *app_id) { GError *error; g_return_if_fail(url != NULL); g_return_if_fail(app_id != NULL); gchar *url_pattern_args = make_url_patterns_arg_for_container(url_patterns); gchar *session_cookies_arg = store_session_cookies ? g_strdup("--store-session-cookies") : g_strdup(""); gchar *command_line = g_strdup_printf(UNITY_WEBAPPS_CONTAINER_APP_NAME " --app-id='%s' --webapp --enable-back-forward %s %s %s", app_id, url_pattern_args, session_cookies_arg, url); g_free(url_pattern_args); g_free(session_cookies_arg); g_message("Launching webapp container for url '%s' and app_id '%s (command line '%s')", url, app_id, command_line); error = NULL; g_spawn_command_line_async(command_line, &error); if (error != NULL) { g_critical ("Error invoking browser: %s", error->message); g_error_free (error); } } /** * * \param name webapp name * \param domain domain name for the webapp */ static void open_webapp_with_container(gchar * name, gchar * domain, gchar **files) { gsize len; GError *error; gchar * desktop_id; gchar *decoded_name; g_return_if_fail(name != NULL); g_return_if_fail(domain != NULL); len = 0; decoded_name = g_base64_decode (name, &len); desktop_id = unity_webapps_desktop_infos_build_desktop_basename(decoded_name , domain ? domain : ""); gchar *url_pattern_args = make_url_patterns_arg_for_container(url_patterns); gchar *session_cookies_arg = store_session_cookies ? g_strdup("--store-session-cookies") : g_strdup(""); gchar *command_line = g_strdup_printf(UNITY_WEBAPPS_CONTAINER_APP_NAME " --app-id='%s' --webapp='%s' --enable-back-forward %s %s", desktop_id, name, url_pattern_args, session_cookies_arg); g_free(session_cookies_arg); g_free(desktop_id); g_message("Launching webapp '%s' with the webapp container (command line '%s')", decoded_name, command_line); g_free(decoded_name); error = NULL; g_spawn_command_line_async(command_line, &error); if (error != NULL) { g_critical ("Error invoking browser: %s", error->message); g_error_free (error); } } gint main (gint argc, gchar **argv) { gint i; GOptionContext *context; GError *error; gchar *files[argc]; error = NULL; context = g_option_context_new ("- Activate Unity WebApps"); if (!context) { g_error("Could not get proper option context"); return 1; } g_option_context_set_summary (context, "Launches a standalone webapp " "given a domain and a name (e.g." " \"unity-webapps-runner -n 'VHdpdHRlcgA='" " -d 'twitter.com'\")."); // TODO: GETTEXT g_option_context_add_main_entries (context, option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { printf("Failed to parse arguments: %s\n", error->message); exit(1); } service = unity_webapps_service_new (); if (homepage != NULL) { #if ! (defined(__ppc__) || defined(__ppc64__)) open_webapp_with_container_with_url(homepage, app_id); #else unity_webapps_service_open_homepage_sync (service, homepage); #endif exit(0); } if (amazon == TRUE) { gchar *country; const gchar *url; country = unity_webapps_runner_amazon_get_country (); url = unity_webapps_runner_amazon_get_homepage_for_country (country); if (NULL == url) { g_error("Could not retrieve the url associated with the current country %s", country); return 1; } g_free (country); #if ! (defined(__ppc__) || defined(__ppc64__)) open_webapp_with_container_with_url(url, app_id); #else unity_webapps_service_open_homepage_sync (service, url); #endif return 0; } for (i = 1; i < argc; i++) files[i - 1] = argv[i]; files[argc - 1] = NULL; if (!name || !domain) { gchar *help = g_option_context_get_help (context, TRUE, NULL); g_error("Invalid or missing 'domain' or 'name' fields:\n\n%s", help); g_free(help); return 1; } #if ! (defined(__ppc__) || defined(__ppc64__)) open_webapp_with_container(name, domain, &files[0]); #else open_webapp_with_legacy_chromeless(name, domain, &files[0]); #endif return 0; } libunity-webapps-2.5.0~+14.04.20140409/src/runner/unity-webapps-runner-amazon.h0000644000015301777760000000037212321247333027467 0ustar pbusernogroup00000000000000#ifndef __UNITY_WEBAPPS_RUNNER_AMAZON_H #define __UNITY_WEBAPPS_RUNNER_AMAZON_H #include gchar *unity_webapps_runner_amazon_get_country (void); const gchar *unity_webapps_runner_amazon_get_homepage_for_country (const gchar *country); #endif libunity-webapps-2.5.0~+14.04.20140409/src/runner/unity-webapps-runner-amazon.c0000644000015301777760000000577412321247333027475 0ustar pbusernogroup00000000000000#include "unity-webapps-runner-amazon.h" #include #include #define UBUNTU_GEOIP_PROVIDER_SERVICE "org.freedesktop.Geoclue.Providers.UbuntuGeoIP" #define UBUNTU_GEOIP_PROVIDER_PATH "/org/freedesktop/Geoclue/Providers/UbuntuGeoIP" #define DEFAULT_AMAZON_DESKTOP "application://ubuntu-amazon-default.desktop" gchar * unity_webapps_runner_amazon_get_country (void) { GeoclueAddress *address; GeoclueAccuracy * accuracy; GeoclueAccuracyLevel level; GHashTable *address_details; gchar *country; gboolean got_address; GError *error; address = geoclue_address_new (UBUNTU_GEOIP_PROVIDER_SERVICE, UBUNTU_GEOIP_PROVIDER_PATH); error = NULL; country = NULL; accuracy = NULL; got_address = geoclue_address_get_address (address, NULL, &address_details, &accuracy, &error); if (got_address == FALSE) { g_warning ("Failed to fetch address from Geoclue: %s", error->message); g_error_free (error); goto out; } geoclue_accuracy_get_details(accuracy, &level, NULL, NULL); if (GEOCLUE_ACCURACY_LEVEL_NONE == level) { g_warning ("Could not get a proper accuracy from Geoclue (NONE)"); g_hash_table_destroy (address_details); goto out; } country = g_strdup (g_hash_table_lookup (address_details, "country")); g_hash_table_destroy (address_details); out: geoclue_accuracy_free(accuracy); g_object_unref (G_OBJECT (address)); return country; } static GHashTable * unity_webapps_runner_amazon_get_desktops_by_country () { GHashTable *desktops_by_country; desktops_by_country = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); g_hash_table_insert (desktops_by_country, "Canada", "http://amazon.ca/?tag=u1webapp-ca-20"); g_hash_table_insert (desktops_by_country, "China", "http://amazon.cn/?tag=u1webapp-23"); g_hash_table_insert (desktops_by_country, "United Kingdom", "http://amazon.co.uk/?tag=u1webapp-uk-21"); g_hash_table_insert (desktops_by_country, "France", "http://amazon.fr/?tag=u1webapp-fr-21"); g_hash_table_insert (desktops_by_country, "Italy", "http://amazon.it/?tag=u1webapp-it-21"); g_hash_table_insert (desktops_by_country, "Spain", "http://amazon.es/?tag=u1webapp-es-21"); g_hash_table_insert (desktops_by_country, "Germany", "http://amazon.de/?tag=u1webapp-21"); g_hash_table_insert (desktops_by_country, "Japan", "http://amazon.co.jp/?tag=u1webapp-22"); return desktops_by_country; } const gchar * unity_webapps_runner_amazon_get_homepage_for_country (const gchar *country) { static const gchar * DEFAULT_AMAZON_URL = "http://www.amazon.com/?tag=u1webapp-20"; static GHashTable *desktops_by_country = NULL; const gchar *ret; if (desktops_by_country == NULL) { desktops_by_country = unity_webapps_runner_amazon_get_desktops_by_country (); } if (country == NULL) { return DEFAULT_AMAZON_URL; } ret = g_hash_table_lookup (desktops_by_country, country); if (ret == NULL) { return DEFAULT_AMAZON_URL; } return ret; } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/0000755000015301777760000000000012321250157023676 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-rate.h0000644000015301777760000000246012321247333027613 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-rate.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_RATE_H #define __UNITY_WEBAPPS_RATE_H #include "unity-webapps-context.h" gboolean unity_webapps_rate_check_notification_rate_limit (UnityWebappsContext *context); gboolean unity_webapps_rate_check_music_player_rate_limit (UnityWebappsContext *context); gboolean unity_webapps_rate_check_indicator_rate_limit (UnityWebappsContext *context); gboolean unity_webapps_rate_check_launcher_rate_limit (UnityWebappsContext *context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-indicator-context.c0000644000015301777760000003546212321247333032321 0ustar pbusernogroup00000000000000/* * unity-webapps-indicator-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-indicator-context.h" #include "unity-webapps-context-private.h" #include "unity-webapps-sanitizer.h" #include "unity-webapps-dbus-util.h" #include "unity-webapps-rate.h" #include "unity-webapps-debug.h" typedef struct _unity_webapps_indicator_action_data { UnityWebappsContext *context; UnityWebappsIndicatorCallback callback; gpointer user_data; } unity_webapps_indicator_action_data; static void _indicator_context_action_invoked (UnityWebappsGenIndicator *indicator, const gchar *label, gpointer user_data) { UnityWebappsContext *context; unity_webapps_indicator_action_data *data; context = (UnityWebappsContext *)user_data; g_return_if_fail(context != NULL); if (!G_IS_OBJECT(context)) return; data = g_hash_table_lookup (context->priv->indicator_context->menu_callbacks_by_name, label); if ((data != NULL) && (data->callback != NULL)) { UNITY_WEBAPPS_NOTE (INDICATOR, "Menu action invoked: %s", label); data->callback(context, data->user_data); return; } data = g_hash_table_lookup (context->priv->indicator_context->indicator_callbacks_by_name, label); if ((data != NULL) && (data->callback != NULL)) { UNITY_WEBAPPS_NOTE (INDICATOR, "Indicator action invoked: %s", label); data->callback(context, data->user_data); return; } } static void presence_changed_notify (GObject *object, GParamSpec *pspec, gpointer user_data) { unity_webapps_indicator_action_data *data; data = (unity_webapps_indicator_action_data *)user_data; g_return_if_fail(data != NULL); if (!G_IS_OBJECT(data->context)) return; if (data->callback != NULL) data->callback (data->context, data->user_data); } UnityWebappsIndicatorContext * unity_webapps_indicator_context_new (UnityWebappsContext *main_context, GError **error) { UnityWebappsIndicatorContext *context; context = g_malloc0 (sizeof (UnityWebappsIndicatorContext)); context->indicator_rate = 0; context->menu_callbacks_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); context->indicator_callbacks_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); context->indicator_proxy = unity_webapps_gen_indicator_proxy_new_sync (unity_webapps_service_get_connection (main_context->priv->service) , G_DBUS_PROXY_FLAGS_NONE, main_context->priv->context_name, UNITY_WEBAPPS_INDICATOR_PATH, NULL /* Cancellable */, error); if (error && (*error != NULL)) { g_critical ("Error creating indicator context proxy object for %s: %s", main_context->priv->context_name, (*error)->message); return NULL; } g_signal_connect (context->indicator_proxy, "action-invoked", G_CALLBACK (_indicator_context_action_invoked), main_context); return context; } void unity_webapps_indicator_context_free (UnityWebappsIndicatorContext *context) { g_return_if_fail (context != NULL); g_hash_table_destroy (context->menu_callbacks_by_name); g_hash_table_destroy (context->indicator_callbacks_by_name); g_object_unref (G_OBJECT (context->indicator_proxy)); g_free (context); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(show_indicator,indicator,Indicator,INDICATOR,"Indicator succesfully showed"); #define MAXIMUM_NAME_LENGTH 45 void unity_webapps_indicator_show_indicator (UnityWebappsContext *context, const gchar *name) { gchar *sanitized_name; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (name != NULL); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return; } sanitized_name = unity_webapps_sanitizer_limit_string_argument (name, MAXIMUM_NAME_LENGTH); unity_webapps_gen_indicator_call_show_indicator (context->priv->indicator_context->indicator_proxy, sanitized_name, context->priv->interest_id, NULL /* Cancellable */, show_indicator_complete_callback, context); g_free (sanitized_name); UNITY_WEBAPPS_NOTE (INDICATOR, "Showed indicator: %s", name); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(clear_indicator,indicator,Indicator,INDICATOR,"Indicator succesfully cleared"); void unity_webapps_indicator_clear_indicator (UnityWebappsContext *context, const gchar *name) { gchar *sanitized_name; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (name != NULL); sanitized_name = unity_webapps_sanitizer_limit_string_argument (name, MAXIMUM_NAME_LENGTH); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return; } g_return_if_fail (name != NULL); unity_webapps_gen_indicator_call_clear_indicator (context->priv->indicator_context->indicator_proxy, sanitized_name, context->priv->interest_id, NULL /* Cancellable */, clear_indicator_complete_callback, context); g_free (sanitized_name); UNITY_WEBAPPS_NOTE (INDICATOR, "Cleared indicator: %s", name); } void unity_webapps_indicator_clear_indicators (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return; } unity_webapps_gen_indicator_call_clear_indicators (context->priv->indicator_context->indicator_proxy, context->priv->interest_id, NULL /* Cancellable */, clear_indicator_complete_callback, context); UNITY_WEBAPPS_NOTE (INDICATOR, "Clearing indicators"); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(add_action,indicator,Indicator,INDICATOR,"Action succesfully added"); #define MAXIMUM_LABEL_LENGTH 60 void unity_webapps_indicator_add_action (UnityWebappsContext *context, const gchar *label, UnityWebappsIndicatorCallback callback, gpointer user_data) { unity_webapps_indicator_action_data *data; gchar *sanitized_label; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (label != NULL); g_return_if_fail (callback != NULL); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return; } sanitized_label = unity_webapps_sanitizer_limit_string_argument (label, MAXIMUM_LABEL_LENGTH); unity_webapps_gen_indicator_call_add_action (context->priv->indicator_context->indicator_proxy, sanitized_label, context->priv->interest_id, NULL /* Cancellable */, add_action_complete_callback, context); // TODO: Analyze the error case with duplicates. data = g_malloc0 (sizeof (unity_webapps_indicator_action_data)); data->callback = callback; data->user_data = user_data; g_hash_table_insert (context->priv->indicator_context->menu_callbacks_by_name, g_strdup (label), data); g_free (sanitized_label); UNITY_WEBAPPS_NOTE (INDICATOR, "Added action: %s", label); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_property,indicator,Indicator,INDICATOR,"Property succesfully updated"); #define MAXIMUM_PROPERTY_LENGTH 40 #define MAXIMUM_VALUE_LENGTH 1024 void unity_webapps_indicator_set_property (UnityWebappsContext *context, const gchar *name, const gchar *property, const gchar *value) { gchar *sanitized_name, *sanitized_property, *sanitized_value; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (name != NULL); g_return_if_fail (property != NULL); g_return_if_fail (value != NULL); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return; } sanitized_name = unity_webapps_sanitizer_limit_string_argument (name, MAXIMUM_NAME_LENGTH); sanitized_property = unity_webapps_sanitizer_limit_string_argument (property, MAXIMUM_PROPERTY_LENGTH); sanitized_value = unity_webapps_sanitizer_limit_string_argument (value, MAXIMUM_VALUE_LENGTH); unity_webapps_gen_indicator_call_set_property (context->priv->indicator_context->indicator_proxy, sanitized_name, sanitized_property, sanitized_value, context->priv->interest_id, NULL /* Cancellable */, set_property_complete_callback, context); g_free (sanitized_name); g_free (sanitized_property); g_free (sanitized_value); UNITY_WEBAPPS_NOTE (INDICATOR, "Setting property of indicator %s: %s->%s", name, property, value); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_property_icon,indicator,Indicator,INDICATOR,"Icon Property succesfully updated"); void unity_webapps_indicator_set_property_icon (UnityWebappsContext *context, const gchar *name, const gchar *property, const gchar *value) { gchar *sanitized_name, *sanitized_property, *sanitized_value; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (name != NULL); g_return_if_fail (property != NULL); g_return_if_fail (value != NULL); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return; } sanitized_name = unity_webapps_sanitizer_limit_string_argument (name, MAXIMUM_NAME_LENGTH); sanitized_property = unity_webapps_sanitizer_limit_string_argument (property, MAXIMUM_PROPERTY_LENGTH); sanitized_value = unity_webapps_sanitizer_limit_string_argument (value, MAXIMUM_VALUE_LENGTH); unity_webapps_gen_indicator_call_set_property (context->priv->indicator_context->indicator_proxy, sanitized_name, sanitized_property, sanitized_value, context->priv->interest_id, NULL /* Cancellable */, set_property_icon_complete_callback, context); g_free (sanitized_name); g_free (sanitized_property); g_free (sanitized_value); UNITY_WEBAPPS_NOTE (INDICATOR, "Setting icon property of indicator %s: %s->%s", name, property, value); } void unity_webapps_indicator_set_callback (UnityWebappsContext *context, const gchar *name, UnityWebappsIndicatorCallback callback, gpointer user_data) { UnityWebappsIndicatorContext *indicator_context; gchar *sanitized_name; unity_webapps_indicator_action_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (name != NULL); g_return_if_fail (callback != NULL); // The hash table takes ownership of this. sanitized_name = unity_webapps_sanitizer_limit_string_argument (name, MAXIMUM_NAME_LENGTH); indicator_context = context->priv->indicator_context; data = g_malloc0 (sizeof (unity_webapps_indicator_action_data)); data->callback = callback; data->user_data = user_data; g_hash_table_insert (indicator_context->indicator_callbacks_by_name, (gpointer) sanitized_name, data); } gchar * unity_webapps_indicator_get_presence (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return FALSE; } return g_strdup (unity_webapps_gen_indicator_get_presence (context->priv->indicator_context->indicator_proxy)); } static void _free_presence_callback_data (gpointer user_data, GClosure *closure) { unity_webapps_indicator_action_data *data; data = (unity_webapps_indicator_action_data *)user_data; g_free (data); } void unity_webapps_indicator_on_presence_changed_callback (UnityWebappsContext *context, UnityWebappsIndicatorCallback callback, gpointer user_data) { unity_webapps_indicator_action_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); data = g_malloc0 (sizeof (unity_webapps_indicator_action_data)); data->callback = callback; data->user_data = user_data; data->context = context; g_signal_connect_data (context->priv->indicator_context->indicator_proxy, "notify::presence", G_CALLBACK (presence_changed_notify), data, _free_presence_callback_data, 0); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(remove_action,indicator,Indicator,INDICATOR,"Action succesfully removed"); void unity_webapps_indicator_remove_action (UnityWebappsContext *context, const gchar *label) { gchar *sanitized_label; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return; } sanitized_label = unity_webapps_sanitizer_limit_string_argument (label, MAXIMUM_LABEL_LENGTH); unity_webapps_gen_indicator_call_remove_action (context->priv->indicator_context->indicator_proxy, sanitized_label, context->priv->interest_id, NULL /* Cancellable */, remove_action_complete_callback, context); g_hash_table_remove (context->priv->indicator_context->menu_callbacks_by_name, sanitized_label); UNITY_WEBAPPS_NOTE (INDICATOR, "Removing action: %s", label); g_free (sanitized_label); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(remove_actions,indicator,Indicator,INDICATOR,"Action succesfully removed"); void unity_webapps_indicator_remove_actions (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_indicator_rate_limit (context) == FALSE) { return; } unity_webapps_gen_indicator_call_remove_actions (context->priv->indicator_context->indicator_proxy, context->priv->interest_id, NULL /* Cancellable */, remove_actions_complete_callback, context); g_hash_table_remove_all (context->priv->indicator_context->menu_callbacks_by_name); UNITY_WEBAPPS_NOTE (INDICATOR, "Removing all actions"); } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-sanitizer.h0000644000015301777760000000231412321247333030666 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-sanitizer.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_SANITIZER_H__ #define __UNITY_WEBAPPS_SANITIZER_H__ #include "unity-webapps-context.h" gchar *unity_webapps_sanitizer_limit_string_argument (const gchar *string, gsize length); gchar **unity_webapps_sanitizer_limit_strv_argument (const gchar *const *strv, gsize length, gsize element_length); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/Makefile.am0000644000015301777760000000701212321247333025734 0ustar pbusernogroup00000000000000## Process this file with automake to produce Makefile.in ## Created by Anjuta EXTRA_DIST = BUILT_SOURCES = CLEANFILES = AM_CPPFLAGS = \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DEBUG_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src AM_CFLAGS =\ -Wall\ -g lib_LTLIBRARIES = libunity-webapps.la libunity_webapps_gdbus_codegen_sources = \ ../unity-webapps-gen-service.c \ ../unity-webapps-gen-context.c \ ../unity-webapps-gen-notification.c \ ../unity-webapps-gen-indicator.c \ ../unity-webapps-gen-music-player.c \ ../unity-webapps-gen-launcher.c libunity_webapps_gdbus_codegen_headers = \ ../unity-webapps-gen-service.h \ ../unity-webapps-gen-context.h \ ../unity-webapps-gen-notification.h \ ../unity-webapps-gen-indicator.h \ ../unity-webapps-gen-music-player.h \ ../unity-webapps-gen-launcher.h libunity_webapps_headers = \ unity-webapps-notification-context.h \ unity-webapps-indicator-context.h \ unity-webapps-music-player-context.h \ unity-webapps-launcher-context.h \ unity-webapps-dbus-defs.h \ unity-webapps-dbus-util.h \ unity-webapps-service.h \ unity-webapps-rate.h \ unity-webapps-permissions.h \ unity-webapps-sanitizer.h \ unity-webapps-context.h libunity_webapps_sources = \ unity-webapps-service.c \ unity-webapps-context.c \ unity-webapps-context-private.h \ unity-webapps-rate.c \ unity-webapps-sanitizer.c \ unity-webapps-permissions.c \ unity-webapps-notification-context.c \ unity-webapps-indicator-context.c \ unity-webapps-music-player-context.c \ unity-webapps-launcher-context.c \ unity-webapps-debug.c \ ../unity-webapps-debug.h \ ../unity-webapps-wire-version.h libunity_webappsincludedir = $(includedir)/libunity_webapps-0.2 libunity_webappsinclude_HEADERS = \ $(libunity_webapps_gdbus_codegen_headers) \ $(libunity_webapps_headers) libunity_webapps_la_SOURCES = \ $(libunity_webappsinclude_HEADERS) \ $(libunity_webapps_gdbus_codegen_sources) \ $(libunity_webapps_sources) libunity_webapps_la_LDFLAGS = $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ -export-dynamic \ -export-symbols-regex "^unity_webapps_[^g].*" libunity_webapps_la_LIBADD = $(UNITY_WEBAPPS_LIBS) -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = INTROSPECTION_SCANNER_ARGS = \ --add-include-path=$(top_srcdir)/src \ $(addprefix --c-include=src/, $(libunity_webappsinclude_HEADERS)) \ --symbol-prefix=unity_webapps \ --identifier-prefix=UnityWebapps INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_srcdir)/src if HAVE_INTROSPECTION UnityWebapps-0.2.gir: libunity-webapps.la UnityWebapps_0_2_gir_INCLUDES = \ GObject-2.0 \ Gio-2.0 \ GLib-2.0 UnityWebapps_0_2_gir_CFLAGS = $(UNITY_WEBAPPS_CFLAGS) -I$(top_srcdir)/src UnityWebapps_0_2_gir_LIBS = libunity-webapps.la UnityWebapps_0_2_gir_FILES = $(libunity_webapps_headers) $(libunity_webapps_sources) UnityWebapps_0_2_gir_NAMESPACE = UnityWebapps UnityWebapps_0_2_gir_VERSION = 0.2 UnityWebapps_0_2_gir_EXPORT_PACKAGES = unity-webapps-0.2 UnityWebapps_0_2_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) INTROSPECTION_GIRS += UnityWebapps-0.2.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) CLEANFILES += $(gir_DATA) $(typelib_DATA) endif include_HEADERS = pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libunity_webapps-0.2.pc EXTRA_DIST += \ libunity_webapps-0.2.pc.in libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-dbus-defs.h0000644000015301777760000000370512321247333030537 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-dbus-defs.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_DBUS_DEFS_H #define __UNITY_WEBAPPS_DBUS_DEFS_H #define UNITY_WEBAPPS_CONTEXT_IFACE "com.canonical.Unity.Webapps.Context" #define UNITY_WEBAPPS_CONTEXT_PATH "/com/canonical/Unity/Webapps/Context" #define UNITY_WEBAPPS_SERVICE_PATH "/com/canonical/Unity/Webapps/Service" #define UNITY_WEBAPPS_SERVICE_IFACE "com.canonical.Unity.Webapps.Service" #define UNITY_WEBAPPS_SERVICE_NAME "com.canonical.Unity.Webapps.Service" #define UNITY_WEBAPPS_NOTIFICATION_IFACE "com.canonical.Unity.Webapps.Notification" #define UNITY_WEBAPPS_NOTIFICATION_PATH "/com/canonical/Unity/Webapps/Context/Notification" #define UNITY_WEBAPPS_INDICATOR_IFACE "com.canonical.Unity.Webapps.Indicator" #define UNITY_WEBAPPS_INDICATOR_PATH "/com/canonical/Unity/Webapps/Context/Indicator" #define UNITY_WEBAPPS_MUSIC_PLAYER_IFACE "com.canonical.Unity.Webapps.MusicPlayer" #define UNITY_WEBAPPS_MUSIC_PLAYER_PATH "/com/canonical/Unity/Webapps/Context/MusicPlayer" #define UNITY_WEBAPPS_LAUNCHER_IFACE "com.canonical.Unity.Webapps.Launcher" #define UNITY_WEBAPPS_LAUNCHER_PATH "/com/canonical/Unity/Webapps/Launcher" #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-indicator-context.h0000644000015301777760000000476612321247333032331 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-indicator-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INDICATOR_CONTEXT_H #define __UNITY_WEBAPPS_INDICATOR_CONTEXT_H typedef struct _UnityWebappsIndicatorContext UnityWebappsIndicatorContext; #include "unity-webapps-context.h" typedef void (*UnityWebappsIndicatorCallback) (UnityWebappsContext *context, gpointer user_data); void unity_webapps_indicator_show_indicator (UnityWebappsContext *context, const gchar *name); void unity_webapps_indicator_clear_indicator (UnityWebappsContext *context, const gchar *name); void unity_webapps_indicator_clear_indicators (UnityWebappsContext *context); void unity_webapps_indicator_set_callback (UnityWebappsContext *context, const gchar *name, UnityWebappsIndicatorCallback callback, gpointer user_data); void unity_webapps_indicator_set_property (UnityWebappsContext *context, const gchar *name, const gchar *property, const gchar *value); void unity_webapps_indicator_set_property_icon (UnityWebappsContext *context, const gchar *name, const gchar *property, const gchar *icon_url); void unity_webapps_indicator_add_action (UnityWebappsContext *context, const gchar *label, UnityWebappsIndicatorCallback callback, gpointer user_data); void unity_webapps_indicator_remove_action (UnityWebappsContext *context, const gchar *label); void unity_webapps_indicator_remove_actions (UnityWebappsContext *context); gchar *unity_webapps_indicator_get_presence (UnityWebappsContext *context); void unity_webapps_indicator_on_presence_changed_callback (UnityWebappsContext *context, UnityWebappsIndicatorCallback callback, gpointer user_data); gboolean unity_webapps_context_shutdown (UnityWebappsContext *context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-rate.c0000644000015301777760000001406612321247333027613 0ustar pbusernogroup00000000000000/* * unity-webapps-rate.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "unity-webapps-rate.h" #include "unity-webapps-context-private.h" #include "unity-webapps-debug.h" /* Maximum number of service requests (notification, indicators, launcher, music player) per GLOBAL_TICK (in milliseconds) */ #define MAXIMUM_GLOBAL_RATE_PER_TICK 50 /* The tick interval for global service limiting in milliseconds */ #define GLOBAL_TICK 1000 /* Maximum number of notification requests per NOTIFICATION_TICK */ #define MAXIMUM_NOTIFICATION_RATE_PER_TICK 20 /* The tick interval for notification limiting in milliseconds */ #define NOTIFICATION_TICK 1000 /* Maximum number of indicator requests per INDICATOR_TICK */ #define MAXIMUM_INDICATOR_RATE_PER_TICK 30 /* The tick interval for indicator limiting in milliseconds */ #define INDICATOR_TICK 1000 /* Maximum number of music player requests per MUSIC_PLAYER_TICK */ #define MAXIMUM_MUSIC_PLAYER_RATE_PER_TICK 30 /* The tick interval for music player limiting in milliseconds */ #define MUSIC_PLAYER_TICK 1000 /* * Used as a timeout callback, decrement the global rate count */ static gboolean _decrement_global_rate (gpointer user_data) { UnityWebappsContext *context = (UnityWebappsContext *) user_data; context->priv->global_rate--; g_object_unref (G_OBJECT (context)); return FALSE; } /* * Used as a timeout callback, decrement the notification rate count */ static gboolean _decrement_notification_rate (gpointer user_data) { UnityWebappsContext *context = (UnityWebappsContext *) user_data; context->priv->notification_context->notification_rate--; return FALSE; } /* * Used as a timeout callback, decrement the indicator rate count */ static gboolean _decrement_indicator_rate (gpointer user_data) { UnityWebappsContext *context = (UnityWebappsContext *) user_data; context->priv->indicator_context->indicator_rate--; return FALSE; } static gboolean _decrement_launcher_rate (gpointer user_data) { UnityWebappsContext *context = (UnityWebappsContext *) user_data; context->priv->launcher_context->launcher_rate--; return FALSE; } /* * Used as a timeout callback, decrement the music player rate count */ static gboolean _decrement_music_player_rate (gpointer user_data) { UnityWebappsContext *context = (UnityWebappsContext *) user_data; context->priv->music_player_context->music_player_rate--; return FALSE; } /* * Check if a context is below the global rate limit (and log a request) * * The global rate limiting approach works as follows: * * 1. Check if a global rate variable is over MAXIMUM_GLOBAL_RATE_PER_TICK. * 2. If so, we are rate limited. * 3. Otherwise increment the global rate variable, set a timeout to decrement it in GLOBAL_TICK milliseconds, and return true. */ static gboolean unity_webapps_rate_check_global_rate_limit (UnityWebappsContext *context) { if (context->priv->global_rate > MAXIMUM_GLOBAL_RATE_PER_TICK) { UNITY_WEBAPPS_NOTE (RATE, "Global rate limit check failed"); return FALSE; } context->priv->global_rate++; g_object_ref (G_OBJECT (context)); g_timeout_add (GLOBAL_TICK, _decrement_global_rate, context); return TRUE; } gboolean unity_webapps_rate_check_notification_rate_limit (UnityWebappsContext *context) { gboolean ret; if (context->priv->notification_context->notification_rate > MAXIMUM_NOTIFICATION_RATE_PER_TICK) { UNITY_WEBAPPS_NOTE (RATE, "Notification rate limit check failed"); return FALSE; } context->priv->notification_context->notification_rate++; g_timeout_add (NOTIFICATION_TICK, _decrement_notification_rate, context); ret = unity_webapps_rate_check_global_rate_limit (context); return ret; } /** * Check the indicator and global rate limits (and log an access) */ gboolean unity_webapps_rate_check_indicator_rate_limit (UnityWebappsContext *context) { gboolean ret; if (context->priv->indicator_context->indicator_rate > MAXIMUM_INDICATOR_RATE_PER_TICK) { UNITY_WEBAPPS_NOTE (RATE, "Indicator rate limit check failed"); return FALSE; } context->priv->indicator_context->indicator_rate++; g_timeout_add (INDICATOR_TICK, _decrement_indicator_rate, context); ret = unity_webapps_rate_check_global_rate_limit (context); return ret; } /** * Check the music player and global rate limits (and log an access) */ gboolean unity_webapps_rate_check_music_player_rate_limit (UnityWebappsContext *context) { gboolean ret; if (context->priv->music_player_context->music_player_rate > MAXIMUM_MUSIC_PLAYER_RATE_PER_TICK) { UNITY_WEBAPPS_NOTE (RATE, "Music player rate limit check failed"); return FALSE; } context->priv->music_player_context->music_player_rate++; g_timeout_add (MUSIC_PLAYER_TICK, _decrement_music_player_rate, context); ret = unity_webapps_rate_check_global_rate_limit (context); return ret; } gboolean unity_webapps_rate_check_launcher_rate_limit (UnityWebappsContext *context) { gboolean ret; if (context->priv->launcher_context->launcher_rate > MAXIMUM_INDICATOR_RATE_PER_TICK) { UNITY_WEBAPPS_NOTE (RATE, "Launcher rate limit check failed"); return FALSE; } context->priv->launcher_context->launcher_rate++; g_timeout_add (INDICATOR_TICK, _decrement_launcher_rate, context); ret = unity_webapps_rate_check_global_rate_limit (context); return ret; } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/libunity_webapps-0.2.pc.in0000644000015301777760000000050112321247333030502 0ustar pbusernogroup00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ datarootdir=@datarootdir@ datadir=@datadir@ includedir=@includedir@/libunity_webapps-0.2 Name: libunity_webapps Description: Sample library created by Anjuta project wizard. Version: @VERSION@ Requires: Libs: -L${libdir} -lunity-webapps Cflags: -I${includedir} libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-service.h0000644000015301777760000000655012321247333030324 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-service.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_SERVICE_H #define __UNITY_WEBAPPS_SERVICE_H #include #include #include #include "unity-webapps-dbus-defs.h" #define UNITY_WEBAPPS_TYPE_SERVICE (unity_webapps_service_get_type()) #define UNITY_WEBAPPS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_SERVICE, UnityWebappsService)) #define UNITY_WEBAPPS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_SERVICE, UnityWebappsServiceClass)) #define UNITY_WEBAPPS_IS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_SERVICE)) #define UNITY_WEBAPPS_IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_SERVICE)) #define UNITY_WEBAPPS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_SERVICE, UnityWebappsServiceClass)) typedef struct _UnityWebappsServicePrivate UnityWebappsServicePrivate; typedef struct _UnityWebappsService UnityWebappsService; struct _UnityWebappsService { GObject object; UnityWebappsServicePrivate *priv; }; typedef struct _UnityWebappsServiceClass UnityWebappsServiceClass; struct _UnityWebappsServiceClass { GObjectClass parent_class; }; typedef void (*UnityWebappsServiceContextNotifyCallback) (UnityWebappsService *service, const gchar *name, gpointer user_data); GType unity_webapps_service_get_type (void) G_GNUC_CONST; UnityWebappsService *unity_webapps_service_new (); GDBusConnection *unity_webapps_service_get_connection (UnityWebappsService *service); GDBusProxy *unity_webapps_service_get_proxy (UnityWebappsService *service); void unity_webapps_service_activate_application (UnityWebappsService *service, const gchar *name, const gchar *domain, const gchar *const *files); void unity_webapps_service_open_homepage_sync (UnityWebappsService *service, const gchar *homepage); void unity_webapps_service_on_context_appeared (UnityWebappsService *service, UnityWebappsServiceContextNotifyCallback callback, gpointer user_data); void unity_webapps_service_on_context_vanished (UnityWebappsService *service, UnityWebappsServiceContextNotifyCallback callback, gpointer user_data); gchar **unity_webapps_service_list_contexts (UnityWebappsService *service); void unity_webapps_service_shutdown (UnityWebappsService *service); void unity_webapps_service_destroy_interest_for_context (UnityWebappsService *service , const gchar *name, const gchar *domain , gint interest_id , gboolean abandoned); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-sanitizer.c0000644000015301777760000000466012321247333030667 0ustar pbusernogroup00000000000000/* * unity-webapps-sanitizer.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "unity-webapps-sanitizer.h" #include static gboolean _is_valid_utf8 (const gchar *string, gsize length) { const gchar *end; gboolean ret; ret = g_utf8_validate (string, -1, &end); if (ret == FALSE) { gchar *sane_string; sane_string = g_malloc ((length+1) * sizeof(gchar)); g_strlcpy (sane_string, string, end-string < length ? end-string : length); g_warning ("String is invalid UTF8, becomes invalid after: %s", sane_string); g_free (sane_string); } return ret; } gchar ** unity_webapps_sanitizer_limit_strv_argument (const gchar *const *strv, gsize length, gsize element_length) { gchar **limited; gint i,vlen; if (strv == NULL) { limited = g_malloc(sizeof(gchar*)); limited[0] = g_strdup(""); return limited; } vlen = g_strv_length ((gchar **)strv); if (vlen > length) { vlen = length; } limited = g_malloc0((vlen+1) * sizeof(gchar *)); for (i = 0; i < vlen; i++) { limited[i] = unity_webapps_sanitizer_limit_string_argument (strv[i], element_length); } limited[i] = NULL; return limited; } gchar * unity_webapps_sanitizer_limit_string_argument (const gchar *string, gsize length) { gchar *ret_string; if (string == NULL) { return g_strdup (""); } if (_is_valid_utf8 (string, length) == FALSE) { return g_strdup (""); } if (strlen(string) <= length) { return g_strdup (string); } ret_string = g_malloc ((length + 1) * sizeof(gchar)); g_strlcpy (ret_string, string, length); return ret_string; } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-service.c0000644000015301777760000002641212321247333030316 0ustar pbusernogroup00000000000000/* * unity-webapps-service.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ /** * SECTION:unity-webapps-service * @short_description: Unity Webapps Service client bindings. * * Client bindings for the Unity Webapps Service daemon. */ #include #include #include "unity-webapps-service.h" #include "unity-webapps-gen-service.h" #include "unity-webapps-debug.h" struct _UnityWebappsServicePrivate { GDBusConnection *connection; UnityWebappsGenService *service_proxy; }; G_DEFINE_TYPE(UnityWebappsService, unity_webapps_service, G_TYPE_OBJECT) #define UNITY_WEBAPPS_SERVICE_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_SERVICE, UnityWebappsServicePrivate)) static void unity_webapps_service_finalize (GObject *object) { UnityWebappsService *service; service = UNITY_WEBAPPS_SERVICE (object); g_object_unref (G_OBJECT (service->priv->service_proxy)); g_object_unref (G_OBJECT (service->priv->connection)); } static void unity_webapps_service_class_init (UnityWebappsServiceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_service_finalize; g_type_class_add_private (object_class, sizeof(UnityWebappsServicePrivate)); } static void unity_webapps_service_init (UnityWebappsService *service) { GError *error; service->priv = UNITY_WEBAPPS_SERVICE_GET_PRIVATE (service); #ifdef UNITY_WEBAPPS_ENABLE_DEBUG unity_webapps_debug_initialize_flags (); #endif error = NULL; service->priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL /*Cancellable*/, &error /*Error*/); if (error != NULL) { g_critical ("Failed to open session bus! %s", error->message); g_error_free (error); return; } service->priv->service_proxy = unity_webapps_gen_service_proxy_new_sync (service->priv->connection, G_DBUS_PROXY_FLAGS_NONE, UNITY_WEBAPPS_SERVICE_NAME, UNITY_WEBAPPS_SERVICE_PATH, NULL, &error); if (error != NULL) { g_critical ("Failed to create service proxy. %s", error->message); g_error_free (error); return; } } /** * unity_webapps_service_new: * * Creates a new #UnityWebappsService proxy object. If 'com.canonical.Unity.Webapps.Service' * is unowned, the daemon will be started following method invocation by this proxy. * * Return value: (transfer full): The newly constructed #UnityWebappsService objec,tg */ UnityWebappsService * unity_webapps_service_new () { return g_object_new (UNITY_WEBAPPS_TYPE_SERVICE, NULL); } /** * unity_webapps_service_get_connection: * @service: A #UnityWebappsService object. * * Returns the #GDBusConnection used by @service. * * Return value: (transfer none): The #GDBusConnection used by @service. */ GDBusConnection * unity_webapps_service_get_connection (UnityWebappsService *service) { return service->priv->connection; } /** * unity_webapps_service_get_proxy: * @service: A #UnityWebappsService object. * * Returns the internal #GDBusProxy used by @service. * * Return value: (transfer none): The #GDBusProxy used by @service. */ GDBusProxy * unity_webapps_service_get_proxy (UnityWebappsService *service) { return G_DBUS_PROXY (service->priv->service_proxy); } void unity_webapps_service_open_homepage_sync (UnityWebappsService *service, const gchar *homepage) { GError *error; g_return_if_fail (UNITY_WEBAPPS_IS_SERVICE (service)); g_return_if_fail (homepage != NULL); error = NULL; unity_webapps_gen_service_call_open_homepage_sync (service->priv->service_proxy, homepage, NULL, &error); if (error != NULL) { g_warning ("Failure calling OpenHomepage (%s): %s", homepage, error->message); g_error_free (error); } } /** * unity_webapps_service_activate_application: * @service: A #UnityWebappsService object. * @name: Application name. * @domain: Applicatoin domain. * * Invokes the ActivateApplication method of the UnityWebappsService object. This will * activate the application uniquely idenfied by the pair (@name, @domain). */ void unity_webapps_service_activate_application (UnityWebappsService *service, const gchar *name, const gchar *domain, const gchar *const *files) { GError *error; g_return_if_fail (service != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_SERVICE (service)); g_return_if_fail (name != NULL); g_return_if_fail (domain != NULL); error = NULL; unity_webapps_gen_service_call_activate_application_sync (service->priv->service_proxy, name, domain, files, NULL, &error); if (error != NULL) { g_warning ("Failure calling ActivateApplication (%s,%s): %s", name, domain, error->message); g_error_free (error); return; } } typedef struct _unity_webapps_service_notify_data { gpointer user_data; UnityWebappsServiceContextNotifyCallback callback; UnityWebappsService *service; } unity_webapps_service_notify_data; static void on_notify_context_appeared (UnityWebappsGenService *gen_service, const gchar *name, gpointer user_data) { unity_webapps_service_notify_data *data; data = (unity_webapps_service_notify_data *)user_data; data->callback(data->service, name, data->user_data); } /** * unity_webapps_service_on_context_appeared: * @service: A #UnityWebappsService object. * @callback: A callback to be invoked when a new context is registered with @service. * @user_data: User supplied data to be passed to @callback. * * Registers @callback to be invoked when the "ContextAppeared" signal is emitted from the * remote service instance. This indicates a new application context has come online. */ void unity_webapps_service_on_context_appeared (UnityWebappsService *service, UnityWebappsServiceContextNotifyCallback callback, gpointer user_data) { unity_webapps_service_notify_data *data; g_return_if_fail (service != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_SERVICE (service)); g_return_if_fail (callback != NULL); data = g_malloc0 (sizeof (unity_webapps_service_notify_data)); data->user_data = user_data; data->callback = callback; data->service = service; g_signal_connect (service->priv->service_proxy, "context-appeared", G_CALLBACK (on_notify_context_appeared), data); } static void on_notify_context_vanished (UnityWebappsGenService *gen_service, const gchar *name, gpointer user_data) { unity_webapps_service_notify_data *data; data = (unity_webapps_service_notify_data *)user_data; data->callback(data->service, name, data->user_data); } /** * unity_webapps_service_on_context_vanished: * @service: A #UnityWebappsService object. * @callback: A callback to be invoked when a new context is registered with @service. * @user_data: User supplied data to be passed to @callback. * * Registers @callback to be invoked when the "ContextVanished" signal is emitted from the * remote service instance. This indicates an application context has gone offline. */ void unity_webapps_service_on_context_vanished (UnityWebappsService *service, UnityWebappsServiceContextNotifyCallback callback, gpointer user_data) { unity_webapps_service_notify_data *data; g_return_if_fail (service != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_SERVICE (service)); g_return_if_fail (callback != NULL); data = g_malloc0 (sizeof (unity_webapps_service_notify_data)); data->user_data = user_data; data->callback = callback; data->service = service; g_signal_connect (service->priv->service_proxy, "context-vanished", G_CALLBACK (on_notify_context_vanished), data); } /** * unity_webapps_service_list_contexts: * @service: A #UnityWebappsService object. * * Returns a list of context names (unique DBus names), registered with the remote * service. * * Return value: (transfer full): A list of context names. */ gchar ** unity_webapps_service_list_contexts (UnityWebappsService *service) { gchar **out_contexts; GError *error; g_return_val_if_fail (service != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_SERVICE (service), NULL); error = NULL; unity_webapps_gen_service_call_list_contexts_sync (service->priv->service_proxy, &out_contexts, NULL /* Cancellable */, &error); if (error != NULL) { g_warning ("Failure calling ListContexts: %s", error->message); g_error_free (error); return NULL; } return out_contexts; } #include "unity-webapps-context.h" /** * WARNING: this is only kept part of the "ABI" * so that ufe still works (jsctypes still tried to bind with it). * Should be removed ASAP ufe is released. */ void unity_webapps_service_set_xid_for_browser_window_id (UnityWebappsService *service, UnityWebappsContext *context, int window_id) { g_warning("unity_webapps_service_set_xid_for_browser_window_id: called but empty"); } void unity_webapps_service_shutdown (UnityWebappsService *service) { GError *error; g_return_if_fail (UNITY_WEBAPPS_IS_SERVICE (service)); error = NULL; unity_webapps_gen_service_call_shutdown_sync (service->priv->service_proxy, NULL /* Cancellable */, &error); if (error != NULL) { g_warning ("Failure calling service Shutdown: %s", error->message); g_error_free (error); } return; } void unity_webapps_service_destroy_interest_for_context (UnityWebappsService *service, const gchar *name, const gchar *domain, gint interest_id, gboolean abandoned) { GError *error; g_return_if_fail (UNITY_WEBAPPS_IS_SERVICE (service)); error = NULL; unity_webapps_gen_service_call_destroy_interest_for_context_sync (service->priv->service_proxy, name, domain, interest_id, abandoned, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Failure calling service DestroyInterestForContext: %s" , error->message != NULL ? error->message : "(Unknown)"); g_error_free (error); } return; } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-debug.c0000644000015301777760000000233212321247333027737 0ustar pbusernogroup00000000000000/* * unity-webapps-debug.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "unity-webapps-debug.h" #include guint unity_webapps_debug_flags = 0; void unity_webapps_debug_initialize_flags () { const gchar *flags; flags = g_getenv("UNITY_WEBAPPS_DEBUG_FLAGS"); if ((flags == NULL) || (strlen(flags) == 0)) { return; } unity_webapps_debug_flags |= g_parse_debug_string (flags, unity_webapps_debug_keys, G_N_ELEMENTS (unity_webapps_debug_keys)); } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-music-player-context.c0000644000015301777760000004111212321247333032744 0ustar pbusernogroup00000000000000/* * unity-webapps-music-player-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-music-player-context.h" #include "unity-webapps-context-private.h" #include "unity-webapps-sanitizer.h" #include "unity-webapps-dbus-util.h" #include "unity-webapps-rate.h" #include "unity-webapps-debug.h" UnityWebappsMusicPlayerContext * unity_webapps_music_player_context_new (UnityWebappsContext *main_context, GError **error) { UnityWebappsMusicPlayerContext *context; context = g_malloc0 (sizeof (UnityWebappsMusicPlayerContext)); context->music_player_rate = 0; context->music_player_proxy = unity_webapps_gen_music_player_proxy_new_sync (unity_webapps_service_get_connection (main_context->priv->service) , G_DBUS_PROXY_FLAGS_NONE, main_context->priv->context_name, UNITY_WEBAPPS_MUSIC_PLAYER_PATH, NULL /* Cancellable */, error); if (error && (*error != NULL)) { g_critical ("Error creating music_player context proxy object for %s: %s", main_context->priv->context_name, (*error)->message); return NULL; } return context; } void unity_webapps_music_player_context_free (UnityWebappsMusicPlayerContext *context) { g_return_if_fail (context != NULL); g_object_unref (G_OBJECT (context->music_player_proxy)); g_free (context); } // TODO: NOTE: REMOVE IN NEXT RELEASE void unity_webapps_music_player_init (UnityWebappsContext *context, const gchar *title) { return; } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_playlists,music_player,MusicPlayer,MUSIC_PLAYER,"Playlists succesfully set"); #define MAXIMUM_PLAYLIST_LENGTH 60 #define MAXIMUM_PLAYLIST_LIST_LENGTH 20 void unity_webapps_music_player_set_playlists (UnityWebappsContext *context, const gchar *const *playlists) { gchar **sanitized_playlists; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } sanitized_playlists = unity_webapps_sanitizer_limit_strv_argument (playlists, MAXIMUM_PLAYLIST_LIST_LENGTH, MAXIMUM_PLAYLIST_LENGTH); unity_webapps_gen_music_player_call_set_playlists (context->priv->music_player_context->music_player_proxy, (const gchar *const *)sanitized_playlists, NULL /* Cancellable */, set_playlists_complete_callback, context); g_strfreev (sanitized_playlists); UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Setting playlists"); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_track,music_player,MusicPlayer,MUSIC_PLAYER,"Track succesfully set"); #define MAXIMUM_ARTIST_LENGTH 60 #define MAXIMUM_ALBUM_LENGTH 60 #define MAXIMUM_TITLE_LENGTH 60 #define MAXIMUM_ICON_URL_LENGTH 4096 /* For large data URIs...this seems reasonable */ void unity_webapps_music_player_set_track (UnityWebappsContext *context, const gchar *artist, const gchar *album, const gchar *title, const gchar *icon_url) { gchar *sanitized_artist, *sanitized_album, *sanitized_title, *sanitized_icon_url; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (title != NULL); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } sanitized_artist = unity_webapps_sanitizer_limit_string_argument (artist, MAXIMUM_ARTIST_LENGTH); sanitized_album = unity_webapps_sanitizer_limit_string_argument (album, MAXIMUM_ALBUM_LENGTH); sanitized_title = unity_webapps_sanitizer_limit_string_argument (title, MAXIMUM_TITLE_LENGTH); sanitized_icon_url = unity_webapps_sanitizer_limit_string_argument (icon_url, MAXIMUM_ICON_URL_LENGTH); unity_webapps_gen_music_player_call_set_track (context->priv->music_player_context->music_player_proxy, sanitized_artist, sanitized_album, sanitized_title, sanitized_icon_url, context->priv->interest_id, NULL /* Cancellable */, set_track_complete_callback, context); g_free (sanitized_artist); g_free (sanitized_album); g_free (sanitized_title); g_free (sanitized_icon_url); UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Setting track: %s by %s from %s", title, artist, album); } static void _free_callback_data (gpointer user_data, GClosure *closure) { g_free (user_data); } typedef struct _unity_webapps_music_player_playlist_callback_data { UnityWebappsContext *context; UnityWebappsMusicPlayerPlaylistCallback callback; gpointer user_data; } unity_webapps_music_player_playlist_callback_data; static void _do_playlist_callback (UnityWebappsGenMusicPlayer *player, const gchar *playlist_name, gpointer user_data) { unity_webapps_music_player_playlist_callback_data *data; data = (unity_webapps_music_player_playlist_callback_data *)user_data; g_return_if_fail(data != NULL); g_return_if_fail(data->context != NULL); if (!G_IS_OBJECT(data->context)) return; if (data->callback != NULL) { data->callback (data->context, playlist_name, data->user_data); } } void unity_webapps_music_player_on_playlist_activated_callback (UnityWebappsContext *context, UnityWebappsMusicPlayerPlaylistCallback callback, gpointer user_data) { unity_webapps_music_player_playlist_callback_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) { return; } if (callback == NULL) { return; } data = g_malloc0 (sizeof (unity_webapps_music_player_playlist_callback_data)); data->context = context; data->callback = callback; data->user_data = user_data; g_signal_connect_data (context->priv->music_player_context->music_player_proxy, "playlist-activated", G_CALLBACK (_do_playlist_callback), data, _free_callback_data, 0); } typedef struct _unity_webapps_music_player_callback_data { UnityWebappsContext *context; UnityWebappsMusicPlayerCallback callback; gpointer user_data; } unity_webapps_music_player_callback_data; static void _do_callback (UnityWebappsGenMusicPlayer *player, gpointer user_data) { unity_webapps_music_player_callback_data *data; data = (unity_webapps_music_player_callback_data *)user_data; g_return_if_fail(data != NULL); g_return_if_fail(data->context != NULL); if (!G_IS_OBJECT(data->context)) return; if (unity_webapps_context_get_focus_interest (data->context) != data->context->priv->interest_id) return; if (data->callback != NULL) { data->callback (data->context, data->user_data); } } void unity_webapps_music_player_on_play_pause_callback (UnityWebappsContext *context, UnityWebappsMusicPlayerCallback callback, gpointer user_data) { unity_webapps_music_player_callback_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } g_return_if_fail (callback != NULL); data = g_malloc0 (sizeof (unity_webapps_music_player_callback_data)); data->context = context; data->callback = callback; data->user_data = user_data; g_signal_handlers_disconnect_matched (context->priv->music_player_context->music_player_proxy, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC, g_signal_lookup ("play_pause", UNITY_WEBAPPS_GEN_TYPE_MUSIC_PLAYER), 0, NULL, G_CALLBACK (_do_callback), NULL); g_signal_connect_data (context->priv->music_player_context->music_player_proxy, "play_pause", G_CALLBACK (_do_callback), data, _free_callback_data, 0); } void unity_webapps_music_player_on_previous_callback (UnityWebappsContext *context, UnityWebappsMusicPlayerCallback callback, gpointer user_data) { unity_webapps_music_player_callback_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } g_return_if_fail (callback != NULL); data = g_malloc0 (sizeof (unity_webapps_music_player_callback_data)); data->context = context; data->callback = callback; data->user_data = user_data; g_signal_handlers_disconnect_matched (context->priv->music_player_context->music_player_proxy, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC, g_signal_lookup ("previous", UNITY_WEBAPPS_GEN_TYPE_MUSIC_PLAYER), 0, NULL, G_CALLBACK (_do_callback), NULL); g_signal_connect_data (context->priv->music_player_context->music_player_proxy, "previous", G_CALLBACK (_do_callback), data, _free_callback_data, 0); } void unity_webapps_music_player_on_next_callback (UnityWebappsContext *context, UnityWebappsMusicPlayerCallback callback, gpointer user_data) { unity_webapps_music_player_callback_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } g_return_if_fail (callback != NULL); data = g_malloc0 (sizeof (unity_webapps_music_player_callback_data)); data->context = context; data->callback = callback; data->user_data = user_data; g_signal_handlers_disconnect_matched (context->priv->music_player_context->music_player_proxy, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC, g_signal_lookup ("next", UNITY_WEBAPPS_GEN_TYPE_MUSIC_PLAYER), 0, NULL, G_CALLBACK (_do_callback), NULL); g_signal_connect_data (context->priv->music_player_context->music_player_proxy, "next", G_CALLBACK (_do_callback), data, _free_callback_data, 0); } UnityWebappsMusicPlayerPlaybackState unity_webapps_music_player_get_playback_state (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, 0); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), 0); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return FALSE; } gint state; unity_webapps_gen_music_player_call_get_playback_state_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, &state, NULL, NULL); return (UnityWebappsMusicPlayerPlaybackState)state; } gboolean unity_webapps_music_player_get_can_go_previous (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, FALSE); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), FALSE); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return FALSE; } gboolean can_go_previous; unity_webapps_gen_music_player_call_get_can_go_previous_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, &can_go_previous, NULL, NULL); return can_go_previous; } gboolean unity_webapps_music_player_get_can_go_next (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, FALSE); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), FALSE); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return FALSE; } gboolean can_go_next; unity_webapps_gen_music_player_call_get_can_go_next_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, &can_go_next, NULL, NULL); return can_go_next; } gboolean unity_webapps_music_player_get_can_play (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, FALSE); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), FALSE); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return FALSE; } gboolean can_play; unity_webapps_gen_music_player_call_get_can_play_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, &can_play, NULL, NULL); return can_play; } gboolean unity_webapps_music_player_get_can_pause (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, FALSE); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), FALSE); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return FALSE; } gboolean can_pause; unity_webapps_gen_music_player_call_get_can_pause_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, &can_pause, NULL, NULL); return can_pause; } void unity_webapps_music_player_set_playback_state (UnityWebappsContext *context, UnityWebappsMusicPlayerPlaybackState state) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } g_dbus_proxy_set_cached_property (G_DBUS_PROXY (context->priv->music_player_context->music_player_proxy), "PlaybackState", g_variant_new("i", state, NULL)); unity_webapps_gen_music_player_call_set_playback_state_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, (guint) state, NULL, NULL); } void unity_webapps_music_player_set_can_go_previous (UnityWebappsContext *context, gboolean can_go_previous) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } g_dbus_proxy_set_cached_property (G_DBUS_PROXY (context->priv->music_player_context->music_player_proxy), "CanGoPrevious", g_variant_new("b", can_go_previous, NULL)); unity_webapps_gen_music_player_call_set_can_go_previous_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, can_go_previous, NULL, NULL); } void unity_webapps_music_player_set_can_go_next (UnityWebappsContext *context, gboolean can_go_next) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } g_dbus_proxy_set_cached_property (G_DBUS_PROXY (context->priv->music_player_context->music_player_proxy), "CanGoNext", g_variant_new("b", can_go_next, NULL)); unity_webapps_gen_music_player_call_set_can_go_next_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, can_go_next, NULL, NULL); } void unity_webapps_music_player_set_can_play (UnityWebappsContext *context, gboolean can_play) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } g_dbus_proxy_set_cached_property (G_DBUS_PROXY (context->priv->music_player_context->music_player_proxy), "CanPlay", g_variant_new("b", can_play, NULL)); unity_webapps_gen_music_player_call_set_can_play_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, can_play, NULL, NULL); } void unity_webapps_music_player_set_can_pause (UnityWebappsContext *context, gboolean can_pause) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_music_player_rate_limit (context) == FALSE) { return; } g_dbus_proxy_set_cached_property (G_DBUS_PROXY (context->priv->music_player_context->music_player_proxy), "CanPause", g_variant_new("b", can_pause, NULL)); unity_webapps_gen_music_player_call_set_can_pause_sync (context->priv->music_player_context->music_player_proxy, context->priv->interest_id, can_pause, NULL, NULL); } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-context.c0000644000015301777760000014763712321247333030357 0ustar pbusernogroup00000000000000/* * unity-webapps-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-context.h" #include "unity-webapps-gen-service.h" #include "unity-webapps-gen-context.h" #include "unity-webapps-context-private.h" #include "unity-webapps-sanitizer.h" #include "unity-webapps-debug.h" #include "unity-webapps-dbus-util.h" #include "unity-webapps-rate.h" #include "unity-webapps-wire-version.h" static void initable_iface_init (GInitableIface *initable_iface); static void async_initable_iface_init (GAsyncInitableIface *async_initable_iface); G_DEFINE_TYPE_WITH_CODE(UnityWebappsContext, unity_webapps_context, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, initable_iface_init) G_IMPLEMENT_INTERFACE(G_TYPE_ASYNC_INITABLE, async_initable_iface_init)); #define UNITY_WEBAPPS_CONTEXT_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_CONTEXT, UnityWebappsContextPrivate)) enum { PROP_0, PROP_NAME, PROP_DOMAIN, PROP_ICON_URL, PROP_SERVICE, PROP_CONTEXT_NAME, PROP_MIMETYPES }; enum { UNITY_WEBAPPS_INVALID_INTEREST_ID = -1 }; static void unity_webapps_context_on_preview_requested (UnityWebappsGenContext *context_proxy, gint interest_id, gpointer user_data) { UnityWebappsContext *context; const gchar *preview_data; context = (UnityWebappsContext *)user_data; if (context->priv->took_interest == FALSE) { return; } if (context->priv->interest_id != interest_id) { return; } if (context->priv->preview_callback == NULL) { return; } preview_data = context->priv->preview_callback (context, context->priv->preview_user_data); if (preview_data == NULL) { return; } unity_webapps_gen_context_call_preview_ready (context->priv->context_proxy, interest_id, preview_data, NULL /* Cancellable */, NULL /* Callback */, NULL /* User Data */); } typedef struct _unity_webapps_context_action_data { UnityWebappsContextActionCallback callback; gpointer user_data; } unity_webapps_context_action_data; static void _context_action_invoked (UnityWebappsGenContext *context_proxy, const gchar *label, gpointer user_data) { UnityWebappsContext *context; unity_webapps_context_action_data *data; context = (UnityWebappsContext *)user_data; g_return_if_fail(context != NULL); if (!G_IS_OBJECT(context)) return; data = (unity_webapps_context_action_data *)g_hash_table_lookup (context->priv->action_callbacks_by_name, label); if ((data != NULL) && (data->callback != NULL)) { UNITY_WEBAPPS_NOTE (CONTEXT, "Action invoked: %s", label); data->callback (context, data->user_data); return; } UNITY_WEBAPPS_NOTE (CONTEXT, "Action invoked, but we do not have a handler: %s", label); } static void _accept_data_changed_callback (UnityWebappsGenContext *gen_context, const gchar * const *files, gpointer user_data) { UnityWebappsContext *context = (UnityWebappsContext *)user_data; g_signal_emit_by_name (context, "accept-data-changed", files); } static gboolean unity_webapps_context_daemon_initable_init (GInitable *initable, GCancellable *cancellable, GError **error) { UnityWebappsContext *context = (UnityWebappsContext *)initable; gchar *context_name = NULL, *version = NULL; if (context->priv->context_name == NULL) { unity_webapps_gen_service_call_get_context_sync (UNITY_WEBAPPS_GEN_SERVICE (unity_webapps_service_get_proxy (context->priv->service)), context->priv->name, context->priv->domain, context->priv->icon_url ? context->priv->icon_url : "none", context->priv->mime_types ? context->priv->mime_types : "none", &context_name, &version, cancellable, error); if (error && (*error != NULL)) { g_critical ("Error calling GetContext method when constructing new context proxy: %s", (*error)->message); return FALSE; } context->priv->took_interest = TRUE; } else { context_name = context->priv->context_name; } if (version && (g_strcmp0 (UNITY_WEBAPPS_WIRE_PROTOCOL_VERSION, version) != 0)) { g_set_error (error, g_quark_from_string ("unity-webapps"), -1, "Wire protocol version mismatch between context (%s) and client (%s)", version, UNITY_WEBAPPS_WIRE_PROTOCOL_VERSION); context->priv->took_interest = FALSE; return FALSE; } context->priv->global_rate = 0; context->priv->context_proxy = unity_webapps_gen_context_proxy_new_sync (unity_webapps_service_get_connection (context->priv->service), G_DBUS_PROXY_FLAGS_NONE, context_name, UNITY_WEBAPPS_CONTEXT_PATH, cancellable, error); if (error && (*error != NULL)) { g_critical ("Error creating context proxy object for %s: %s", context_name, (*error)->message); g_free (context_name); context->priv->context_proxy = NULL; return FALSE; } UNITY_WEBAPPS_NOTE (CONTEXT, "Created context proxy"); if (context->priv->took_interest) { unity_webapps_gen_context_call_add_interest_sync (context->priv->context_proxy, &(context->priv->interest_id), NULL /* Cancellable */, NULL /* ERROR TODO FIXME */); g_signal_connect (context->priv->context_proxy, "preview-requested", G_CALLBACK (unity_webapps_context_on_preview_requested), context); } context->priv->context_name = context_name; context->priv->notification_context = unity_webapps_notification_context_new (context, error); if (context->priv->notification_context == NULL) { g_critical ("Failed to create notification context proxy"); g_object_unref (G_OBJECT(context->priv->context_proxy)); g_free (context_name); return FALSE; } context->priv->indicator_context = unity_webapps_indicator_context_new (context, error); if (context->priv->indicator_context == NULL) { g_critical("Failed to create indicator context proxy"); unity_webapps_notification_context_free (context->priv->notification_context); g_object_unref (G_OBJECT (context->priv->context_proxy)); g_free (context_name); return FALSE; } context->priv->music_player_context = unity_webapps_music_player_context_new (context, error); if (context->priv->music_player_context == NULL) { g_critical("Failed to create music player context proxy"); unity_webapps_notification_context_free (context->priv->notification_context); unity_webapps_indicator_context_free (context->priv->indicator_context); g_object_unref (G_OBJECT (context->priv->context_proxy)); g_free (context_name); return FALSE; } context->priv->launcher_context = unity_webapps_launcher_context_new (context, error); if (context->priv->launcher_context == NULL) { g_critical ("Failed to create launcher context proxy"); unity_webapps_notification_context_free (context->priv->notification_context); unity_webapps_indicator_context_free (context->priv->indicator_context); unity_webapps_music_player_context_free (context->priv->music_player_context); g_object_unref (G_OBJECT (context->priv->context_proxy)); g_free (context_name); return FALSE; } g_signal_connect (context->priv->context_proxy, "application-action-invoked", G_CALLBACK (_context_action_invoked), context); g_signal_connect (context->priv->context_proxy, "accept-data-changed", G_CALLBACK (_accept_data_changed_callback), context); context->priv->remote_ready = TRUE; return TRUE; } static void initable_iface_init (GInitableIface *initable_iface) { initable_iface->init = unity_webapps_context_daemon_initable_init; } static void async_initable_iface_init (GAsyncInitableIface *async_initable_iface) { // Default implementation } static void unity_webapps_context_finalize (GObject *object) { UnityWebappsContext *context = UNITY_WEBAPPS_CONTEXT (object); GError *error; error = NULL; if (context->priv->took_interest == TRUE) { unity_webapps_gen_context_call_lost_interest_sync (context->priv->context_proxy, context->priv->interest_id, context->priv->user_abandoned, NULL, &error); if (error) { g_warning ("Error calling lost interest for context: %s", error->message); g_error_free (error); error = NULL; } } if (context->priv->notification_context) { unity_webapps_notification_context_free (context->priv->notification_context); } if (context->priv->indicator_context) { unity_webapps_indicator_context_free (context->priv->indicator_context); } if (context->priv->music_player_context) { unity_webapps_music_player_context_free (context->priv->music_player_context); } if (context->priv->launcher_context) { unity_webapps_launcher_context_free (context->priv->launcher_context); } g_free (context->priv->name); g_free (context->priv->domain); g_free (context->priv->icon_url); g_free (context->priv->mime_types); g_free (context->priv->context_name); g_hash_table_destroy (context->priv->action_callbacks_by_name); g_object_unref (G_OBJECT (context->priv->context_proxy)); g_object_unref (G_OBJECT (context->priv->service)); } static void unity_webapps_context_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsContext *context; context = UNITY_WEBAPPS_CONTEXT(object); switch (prop_id) { case PROP_NAME: g_value_set_string (value, context->priv->name); break; case PROP_MIMETYPES: g_value_set_string (value, context->priv->mime_types); break; case PROP_DOMAIN: g_value_set_string (value, context->priv->domain); break; case PROP_ICON_URL: g_value_set_string (value, context->priv->icon_url); break; case PROP_SERVICE: g_value_set_object (value, context->priv->service); break; case PROP_CONTEXT_NAME: g_value_set_string (value, context->priv->context_name); break; } } static void unity_webapps_context_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsContext *context; context = UNITY_WEBAPPS_CONTEXT (object); switch (prop_id) { case PROP_NAME: g_return_if_fail (context->priv->name == NULL); context->priv->name = g_value_dup_string (value); break; case PROP_MIMETYPES: context->priv->mime_types = g_value_dup_string (value); break; case PROP_DOMAIN: g_return_if_fail (context->priv->domain == NULL); context->priv->domain = g_value_dup_string (value); break; case PROP_ICON_URL: g_return_if_fail (context->priv->icon_url == NULL); context->priv->icon_url = g_value_dup_string (value); break; case PROP_SERVICE: g_return_if_fail (context->priv->service == NULL); context->priv->service = g_value_dup_object (value); break; case PROP_CONTEXT_NAME: g_return_if_fail (context->priv->context_name == NULL); context->priv->context_name = g_value_dup_string (value); break; } } static void unity_webapps_context_class_init (UnityWebappsContextClass *klass) { GObjectClass *object_class; object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_context_finalize; object_class->set_property = unity_webapps_context_set_property; object_class->get_property = unity_webapps_context_get_property; g_object_class_install_property (object_class, PROP_NAME, g_param_spec_string ("name", "Name", "Name of the context", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_MIMETYPES, g_param_spec_string ("mime-types", "Mime Types", "Capable of opening files with the given content type", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_DOMAIN, g_param_spec_string ("domain", "Domain", "Domain of the context", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_ICON_URL, g_param_spec_string ("icon-url", "Icon URL", "Icon URL for the context", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_SERVICE, g_param_spec_object ("service", "Service", "The UnityWebappsService for the context", UNITY_WEBAPPS_TYPE_SERVICE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_CONTEXT_NAME, g_param_spec_string ("context-name", "Context DBus Name", "The DBus Name for the context", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_signal_new ("accept-data-changed", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (UnityWebappsContextClass, accept_data_changed), NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_STRV); g_type_class_add_private (object_class ,(sizeof (UnityWebappsContextPrivate))); } static void unity_webapps_context_init(UnityWebappsContext *context) { context->priv = UNITY_WEBAPPS_CONTEXT_GET_PRIVATE (context); context->priv->service = NULL; context->priv->context_proxy = NULL; context->priv->notification_context = NULL; context->priv->indicator_context = NULL; context->priv->music_player_context = NULL; context->priv->global_rate = 0; context->priv->name = NULL; context->priv->domain = NULL; context->priv->icon_url = NULL; context->priv->mime_types = NULL; context->priv->context_name = NULL; context->priv->took_interest = FALSE; context->priv->user_abandoned = TRUE; context->priv->interest_id = UNITY_WEBAPPS_INVALID_INTEREST_ID; context->priv->preview_callback = NULL; context->priv->action_callbacks_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); context->priv->remote_ready = FALSE; } typedef struct _unity_webapps_context_new_data { UnityWebappsContextReadyCallback callback; gpointer user_data; UnityWebappsContext *webapps_context; GMainContext *context; // Async init comes in two flavors: new or new_lazy (where a placeholder // gobject is created in the first place) before actually performing the async // init. The context ready callback is then called in those two contexts // with different "relashionship" to the created gobject (different // ref counts): one is a plain new one, and the other is a placeholder // + the newly async created one (ref counted). gboolean webapps_object_needs_unref; } unity_webapps_context_new_data; static gboolean complete_in_idle_cb (gpointer user_data) { unity_webapps_context_new_data *data; data = (unity_webapps_context_new_data *)user_data; if (!data || !data->webapps_context) return FALSE; // first unref what should be unrefed if (data->webapps_object_needs_unref == TRUE) g_object_unref (G_OBJECT (data->webapps_context)); // ... then see what we have left (object might already have been // unrefed by an abandoned for example. if (data->callback && G_IS_OBJECT(data->webapps_context)) data->callback (data->webapps_context, data->user_data); return FALSE; } static void unity_webapps_context_ready (GObject *source_object, GAsyncResult *res, gpointer user_data) { GAsyncInitable *initable = G_ASYNC_INITABLE (source_object); UnityWebappsContext *context; GSource *source; unity_webapps_context_new_data *data; GError *error; error = NULL; context = UNITY_WEBAPPS_CONTEXT (g_async_initable_new_finish (initable, res, &error)); // TODO: Error if (error != NULL) { g_critical ("Error in unity_webapps_context_ready: %s", error->message); g_error_free (error); return; } data = (unity_webapps_context_new_data *)user_data; data->webapps_context = context; source = g_idle_source_new (); g_source_set_priority (source, G_PRIORITY_DEFAULT); g_source_set_callback (source, complete_in_idle_cb, data, g_free); g_source_attach (source, data->context); g_source_unref (source); } void unity_webapps_context_new (UnityWebappsService *service, const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types, UnityWebappsContextReadyCallback callback, gpointer user_data) { unity_webapps_context_new_data *data; g_return_if_fail (service != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_SERVICE(service)); g_return_if_fail (name != NULL); g_return_if_fail (domain != NULL); g_return_if_fail (icon_url != NULL); g_return_if_fail (callback != NULL); data = g_malloc0 (sizeof (unity_webapps_context_new_data)); data->user_data = user_data; data->callback = callback; data->context = g_main_context_get_thread_default () ? g_main_context_get_thread_default () : g_main_context_default (); data->webapps_object_needs_unref = FALSE; g_async_initable_new_async (UNITY_WEBAPPS_TYPE_CONTEXT, G_PRIORITY_LOW, NULL /* Cancellable */, unity_webapps_context_ready, data, "name", name, "domain", domain, "icon-url", icon_url, "mime-types", mime_types, "service", service, NULL); } UnityWebappsContext * unity_webapps_context_new_lazy (UnityWebappsService *service, const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types) { g_return_val_if_fail (UNITY_WEBAPPS_IS_SERVICE (service), NULL); g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (domain != NULL, NULL); g_return_val_if_fail (icon_url != NULL, NULL); return g_object_new (UNITY_WEBAPPS_TYPE_CONTEXT, "service", service, "name", name, "domain", domain, "icon-url", icon_url, "mime-types", mime_types, NULL); } void unity_webapps_context_prepare (UnityWebappsContext *context, UnityWebappsContextReadyCallback callback, gpointer user_data) { unity_webapps_context_new_data *data; g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == TRUE) { return; } data = g_malloc0 (sizeof (unity_webapps_context_new_data)); data->user_data = user_data; data->callback = callback; data->context = g_main_context_get_thread_default () ? g_main_context_get_thread_default () : g_main_context_default (); data->webapps_object_needs_unref = TRUE; // extension can unref object from another thread, during initialization g_async_initable_init_async (G_ASYNC_INITABLE (context), G_PRIORITY_HIGH, NULL, unity_webapps_context_ready, data); } UnityWebappsContext * unity_webapps_context_new_sync (UnityWebappsService *service, const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types) { g_return_val_if_fail (service != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_SERVICE(service), NULL); g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (domain != NULL, NULL); g_return_val_if_fail (icon_url != NULL, NULL); return UNITY_WEBAPPS_CONTEXT (g_initable_new (UNITY_WEBAPPS_TYPE_CONTEXT, NULL /* Cancellable */, NULL, /* Error */ "name", name, "domain", domain, "icon-url", icon_url, "mime-types", mime_types, "service", service, NULL)); } void unity_webapps_context_destroy (UnityWebappsContext *context, gboolean user_abandoned) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); context->priv->user_abandoned = user_abandoned; g_object_unref (G_OBJECT (context)); } const gchar * unity_webapps_context_get_name (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); if (context->priv->remote_ready == FALSE) { return NULL; } return unity_webapps_gen_context_get_name (context->priv->context_proxy); } const gchar * unity_webapps_context_get_domain (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); if (context->priv->remote_ready == FALSE) { return NULL; } return unity_webapps_gen_context_get_domain (context->priv->context_proxy); } const gchar * unity_webapps_context_get_desktop_name (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); if (context->priv->remote_ready == FALSE) { return NULL; } return unity_webapps_gen_context_get_desktop_name (context->priv->context_proxy); } gchar * unity_webapps_context_get_icon_name (UnityWebappsContext *context) { GError *error; gchar *icon_name; g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); if (context->priv->remote_ready == FALSE) { return NULL; } error = NULL; unity_webapps_gen_context_call_get_icon_name_sync (context->priv->context_proxy, &icon_name, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Failure to invoke proxy method in unity_webapps_context_get_icon_name: %s", error->message); g_error_free (error); return NULL; } return icon_name; } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(add_icon,context,Context,CONTEXT,"Icon succesfully added"); void unity_webapps_context_add_icon (UnityWebappsContext *context, const gchar *icon_url, gint size) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; unity_webapps_gen_context_call_add_icon (context->priv->context_proxy, icon_url, size, NULL /* Cancellable */, add_icon_complete_callback, context); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_homepage,context,Context,CONTEXT,"Homepage succesfully updated"); void unity_webapps_context_set_homepage (UnityWebappsContext *context, const gchar *homepage) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; unity_webapps_gen_context_call_set_homepage (context->priv->context_proxy, homepage, NULL /* Cancellable */, set_homepage_complete_callback, context); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(raise,context,Context,CONTEXT,"Raise succesfully requested"); void unity_webapps_context_raise (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; unity_webapps_gen_context_call_raise (context->priv->context_proxy, NULL, NULL /* Cancellable */, raise_complete_callback, context); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(raise_interest,context,Context,CONTEXT,"Interest raise succesfully requested"); void unity_webapps_context_raise_interest (UnityWebappsContext *context, gint interest_id) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; unity_webapps_gen_context_call_raise_interest (context->priv->context_proxy, interest_id, NULL /* Cancellable */, raise_interest_complete_callback, context); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(close,context,Context,CONTEXT,"Close succesfully requested"); void unity_webapps_context_close (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; unity_webapps_gen_context_call_close (context->priv->context_proxy, NULL /* Cancellable */, close_complete_callback, context); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(close_interest,context,Context,CONTEXT,"Close interest succesfully requested"); void unity_webapps_context_close_interest (UnityWebappsContext *context, gint interest_id) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; unity_webapps_gen_context_call_close_interest (context->priv->context_proxy, interest_id, NULL /* Cancellable */, close_interest_complete_callback, context); } typedef struct _unity_webapps_context_raise_callback_data { UnityWebappsContext *context; UnityWebappsContextRaiseCallback callback; gpointer user_data; } unity_webapps_context_raise_callback_data; typedef struct _unity_webapps_context_close_callback_data { UnityWebappsContext *context; UnityWebappsContextCloseCallback callback; gpointer user_data; } unity_webapps_context_close_callback_data; static void _close_callback (UnityWebappsGenContext *gen_context, gint interest_id, gpointer user_data) { unity_webapps_context_close_callback_data *data; UnityWebappsContext *context; UnityWebappsContextCloseCallback callback; data = (unity_webapps_context_close_callback_data *)user_data; g_return_if_fail (data != NULL); callback = data->callback; g_return_if_fail (callback != NULL); context = data->context; g_return_if_fail (context != NULL); if (!G_IS_OBJECT(context)) return; if (context->priv->took_interest == FALSE) return; if ((context->priv->interest_id == interest_id) || (interest_id == UNITY_WEBAPPS_INVALID_INTEREST_ID)) { callback(data->context, data->user_data); } } static void _raise_callback (UnityWebappsGenContext *gen_context, gint interest_id, const gchar * const *files, gpointer user_data) { unity_webapps_context_raise_callback_data *data; UnityWebappsContext *context; UnityWebappsContextRaiseCallback callback; const gchar * const *it; data = (unity_webapps_context_raise_callback_data *)user_data; g_return_if_fail (data != NULL); callback = data->callback; g_return_if_fail (callback != NULL); context = data->context; g_return_if_fail (context != NULL); if (!G_IS_OBJECT(context)) return; if (context->priv->took_interest == FALSE) return; if ((context->priv->interest_id == interest_id) || (interest_id == UNITY_WEBAPPS_INVALID_INTEREST_ID)) { if (files && files[0]) { for (it = files; *it; it++) callback(data->context, *it, data->user_data); } else callback(data->context, NULL, data->user_data); } } static void _free_close_callback_data (gpointer user_data, GClosure *closure) { unity_webapps_context_close_callback_data *data; data = (unity_webapps_context_close_callback_data *)user_data; g_free (data); } static void _free_raise_callback_data (gpointer user_data, GClosure *closure) { unity_webapps_context_raise_callback_data *data; data = (unity_webapps_context_raise_callback_data *)user_data; g_free (data); } void unity_webapps_context_on_raise_callback (UnityWebappsContext *context, UnityWebappsContextRaiseCallback callback, gpointer user_data) { unity_webapps_context_raise_callback_data *data; g_return_if_fail(context != NULL); g_return_if_fail(UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; data = g_malloc0 (sizeof (unity_webapps_context_raise_callback_data)); data->context = context; data->callback = callback; data->user_data = user_data; g_signal_connect_data (context->priv->context_proxy, "raise-requested", G_CALLBACK (_raise_callback), data, _free_raise_callback_data, 0); } void unity_webapps_context_on_close_callback (UnityWebappsContext *context, UnityWebappsContextCloseCallback callback, gpointer user_data) { unity_webapps_context_close_callback_data *data; g_return_if_fail(context != NULL); g_return_if_fail(UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; data = g_malloc0 (sizeof (unity_webapps_context_close_callback_data)); data->context = context; data->callback = callback; data->user_data = user_data; g_signal_connect_data (context->priv->context_proxy, "close-requested", G_CALLBACK (_close_callback), data, _free_close_callback_data, 0); } gboolean unity_webapps_context_get_view_is_active (UnityWebappsContext *context, gint interest_id) { gboolean is_active; GError *error; g_return_val_if_fail (context != NULL, FALSE); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), FALSE); if (context->priv->remote_ready == FALSE) { return FALSE; } error = NULL; unity_webapps_gen_context_call_get_view_is_active_sync (context->priv->context_proxy, interest_id, &is_active, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Failure to invoke proxy method in unity_webapps_context_get_view_is_active: %s", error->message); g_error_free (error); return FALSE; } return is_active; } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_view_is_active,context,Context,CONTEXT,"Interest activity succesfully updated"); void unity_webapps_context_set_view_is_active (UnityWebappsContext *context, gboolean is_active) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; if (context->priv->took_interest == FALSE) { return; } unity_webapps_gen_context_call_set_view_is_active (context->priv->context_proxy, context->priv->interest_id, is_active, NULL /* Cancellable */, set_view_is_active_complete_callback, context); } typedef struct _unity_webapps_context_notify_data { gpointer user_data; gint interest_id; UnityWebappsContextNotifyCallback callback; UnityWebappsContextViewNotifyCallback view_callback; UnityWebappsContextLocationNotifyCallback location_callback; UnityWebappsContextWindowNotifyCallback window_callback; UnityWebappsContextPreviewReadyCallback preview_callback; UnityWebappsContext *context; } unity_webapps_context_notify_data; static void on_notify_view_is_active (UnityWebappsGenContext *context, gint interest_id, gboolean view_is_active, gpointer user_data) { unity_webapps_context_notify_data *data; data = (unity_webapps_context_notify_data *)user_data; g_return_if_fail (data != NULL); g_return_if_fail (data->context != NULL); if (!G_IS_OBJECT(data->context)) return; if (!data->view_callback) return; data->view_callback(data->context, interest_id, view_is_active, data->user_data); } static void _free_context_notify_data (gpointer user_data, GClosure *closure) { unity_webapps_context_notify_data *data; data = (unity_webapps_context_notify_data *)user_data; g_free (data); } void unity_webapps_context_on_view_is_active_changed (UnityWebappsContext *context, UnityWebappsContextViewNotifyCallback callback, gpointer user_data) { unity_webapps_context_notify_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; data = g_malloc0 (sizeof (unity_webapps_context_notify_data)); data->user_data = user_data; data->view_callback = callback; data->context = context; g_signal_connect_data (context->priv->context_proxy, "view-is-active-changed", G_CALLBACK (on_notify_view_is_active), data, _free_context_notify_data, 0); } gchar * unity_webapps_context_get_view_location (UnityWebappsContext *context, gint interest_id) { gchar *location; GError *error; g_return_val_if_fail (context != NULL, FALSE); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), FALSE); if (context->priv->remote_ready == FALSE) { return NULL; } error = NULL; unity_webapps_gen_context_call_get_view_location_sync (context->priv->context_proxy, interest_id, &location, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Failure to invoke proxy method in unity_webapps_context_get_view_location: %s", error->message); g_error_free (error); return FALSE; } return location; } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_view_location,context,Context,CONTEXT,"Interest location succesfully upadated"); void unity_webapps_context_set_view_location (UnityWebappsContext *context, const gchar *location) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; if (context->priv->took_interest == FALSE) { return; } unity_webapps_gen_context_call_set_view_location (context->priv->context_proxy, context->priv->interest_id, location, NULL /* Cancellable */, set_view_location_complete_callback, context); } static void on_notify_view_location (UnityWebappsGenContext *context, gint interest_id, const gchar *location, gpointer user_data) { unity_webapps_context_notify_data *data; data = (unity_webapps_context_notify_data *)user_data; g_return_if_fail (data != NULL); g_return_if_fail (data->context != NULL); if (!G_IS_OBJECT(data->context)) return; if (!data->location_callback) return; data->location_callback(data->context, interest_id, location, data->user_data); } void unity_webapps_context_on_view_location_changed (UnityWebappsContext *context, UnityWebappsContextLocationNotifyCallback callback, gpointer user_data) { unity_webapps_context_notify_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; data = g_malloc0 (sizeof (unity_webapps_context_notify_data)); data->user_data = user_data; data->location_callback = callback; data->context = context; g_signal_connect_data (context->priv->context_proxy, "view-location-changed", G_CALLBACK (on_notify_view_location), data, _free_context_notify_data, 0); } const gchar * unity_webapps_context_get_context_name (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); if (context->priv->remote_ready == FALSE) { return NULL; } return context->priv->context_name; } UnityWebappsContext * unity_webapps_context_new_for_context_name (UnityWebappsService *service, const gchar *context_name) { g_return_val_if_fail (service != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_SERVICE(service), NULL); g_return_val_if_fail (context_name != NULL, NULL); return UNITY_WEBAPPS_CONTEXT (g_initable_new (UNITY_WEBAPPS_TYPE_CONTEXT, NULL /* Cancellable */, NULL /* Error */, "context-name", context_name, "service", service, NULL)); } GVariant * unity_webapps_context_list_interests (UnityWebappsContext *context) { GVariant *out_interests; GError *error; g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); if (context->priv->remote_ready == FALSE) { return NULL; } error = NULL; unity_webapps_gen_context_call_list_interests_sync (context->priv->context_proxy, &out_interests, NULL /* Cancellable */, &error); if (error != NULL) { g_warning ("Failure calling ListInterests: %s", error->message); g_error_free (error); return NULL; } return out_interests; } static void on_notify_interests_changed (UnityWebappsGenService *gen_service, gint interest_id, gpointer user_data) { unity_webapps_context_notify_data *data; UnityWebappsContext *context; data = (unity_webapps_context_notify_data *)user_data; g_return_if_fail (data != NULL); context = data->context; g_return_if_fail (context != NULL); if (!G_IS_OBJECT (context)) return; data->callback(data->context, interest_id, data->user_data); } void unity_webapps_context_on_interest_appeared (UnityWebappsContext *context, UnityWebappsContextNotifyCallback callback, gpointer user_data) { unity_webapps_context_notify_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; data = g_malloc0 (sizeof (unity_webapps_context_notify_data)); data->user_data = user_data; data->callback = callback; data->context = context; g_signal_connect_data (context->priv->context_proxy, "interest-appeared", G_CALLBACK (on_notify_interests_changed), data, _free_context_notify_data, 0); } void unity_webapps_context_on_interest_vanished (UnityWebappsContext *context, UnityWebappsContextNotifyCallback callback, gpointer user_data) { unity_webapps_context_notify_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; data = g_malloc0 (sizeof (unity_webapps_context_notify_data)); data->user_data = user_data; data->callback = callback; data->context = context; g_signal_connect_data (context->priv->context_proxy, "interest-vanished", G_CALLBACK (on_notify_interests_changed), data, _free_context_notify_data, 0); } gchar * unity_webapps_context_get_interest_owner (UnityWebappsContext *context, gint interest_id) { GError *error; gchar *interest_owner; g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); if (context->priv->remote_ready == FALSE) { return NULL; } error = NULL; unity_webapps_gen_context_call_get_interest_owner_sync (context->priv->context_proxy, interest_id, &interest_owner, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Failure to invoke proxy method in unity_webapps_context_get_interest_owner: %s", error->message); g_error_free (error); return NULL; } return interest_owner; } guint64 unity_webapps_context_get_view_window (UnityWebappsContext *context, gint interest_id) { guint64 window; GError *error; g_return_val_if_fail (context != NULL, FALSE); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), FALSE); if (context->priv->remote_ready == FALSE) { return FALSE; } error = NULL; unity_webapps_gen_context_call_get_view_window_sync (context->priv->context_proxy, interest_id, &window, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Failure to invoke proxy method in unity_webapps_context_get_view_window: %s", error->message); g_error_free (error); return FALSE; } return window; } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_view_window,context,Context,CONTEXT,"Interest window succesfully updated"); void unity_webapps_context_set_view_window (UnityWebappsContext *context, guint64 window) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; if (context->priv->took_interest == FALSE) { return; } unity_webapps_gen_context_call_set_view_window (context->priv->context_proxy, context->priv->interest_id, window, NULL /* Cancellable */, set_view_window_complete_callback, context); } static void on_notify_view_window (UnityWebappsGenContext *context, gint interest_id, guint64 window, gpointer user_data) { unity_webapps_context_notify_data *data; data = (unity_webapps_context_notify_data *)user_data; g_return_if_fail (data != NULL); g_return_if_fail (data->context != NULL); if (!G_IS_OBJECT (data->context)) return; if (data->window_callback != NULL) data->window_callback(data->context, interest_id, window, data->user_data); } void unity_webapps_context_on_view_window_changed (UnityWebappsContext *context, UnityWebappsContextWindowNotifyCallback callback, gpointer user_data) { unity_webapps_context_notify_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; data = g_malloc0 (sizeof (unity_webapps_context_notify_data)); data->user_data = user_data; data->window_callback = callback; data->context = context; g_signal_connect_data (context->priv->context_proxy, "view-window-changed", G_CALLBACK (on_notify_view_window), data, _free_context_notify_data, 0); } void unity_webapps_context_set_preview_requested_callback (UnityWebappsContext *context, UnityWebappsContextPreviewCallback callback, gpointer user_data) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; context->priv->preview_callback = callback; context->priv->preview_user_data = user_data; } static void request_preview_complete_callback (GObject *source_object, GAsyncResult *res, gpointer user_data) { UnityWebappsGenContext *context_proxy; gchar *preview_data; unity_webapps_context_notify_data *data; UnityWebappsContext *context; GError *error; context_proxy = UNITY_WEBAPPS_GEN_CONTEXT (source_object); data = (unity_webapps_context_notify_data *)user_data; g_return_if_fail (data != NULL); context = data->context; g_return_if_fail (context != NULL); if (!G_IS_OBJECT(context)) return; error = NULL; unity_webapps_gen_context_call_request_preview_finish (context_proxy, &preview_data, res, &error); if (error != NULL) { g_warning ("Error calling RequestPreview method: %s", error->message); g_error_free (error); g_free (data); return; } if (data->preview_callback) data->preview_callback (data->context, data->interest_id, preview_data, data->user_data); g_free (data); g_free (preview_data); } void unity_webapps_context_request_preview (UnityWebappsContext *context, gint interest_id, UnityWebappsContextPreviewReadyCallback callback, gpointer user_data) { unity_webapps_context_notify_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (context->priv->remote_ready == FALSE) return; data = g_malloc0 (sizeof (unity_webapps_context_notify_data)); data->preview_callback = callback; data->context = context; data->interest_id = interest_id; data->user_data = user_data; unity_webapps_gen_context_call_request_preview (context->priv->context_proxy, interest_id, NULL /* Cancellable */, request_preview_complete_callback, data); } static void remove_action_complete_callback (GObject *source_object, GAsyncResult *res, gpointer user_data) { UnityWebappsGenContext *proxy; GError *error; proxy = UNITY_WEBAPPS_GEN_CONTEXT (source_object); error = NULL; unity_webapps_gen_context_call_remove_application_action_finish (proxy, res, &error); if (error != NULL) { g_warning ("Error calling RemoveApplicationAction method of Context context: %s", error->message); g_error_free (error); return; } UNITY_WEBAPPS_NOTE (INDICATOR, "Received response, action succesfully removeded"); } gchar** unity_webapps_context_get_application_accept_data (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), NULL); // TODO: Rate limit if (context->priv->remote_ready == FALSE) return NULL; gchar **mimes = NULL; GError *error = NULL; unity_webapps_gen_context_call_get_application_accept_data_sync (context->priv->context_proxy, &mimes, NULL, &error); if (error) { g_warning ("Error calling GetApplicationAcceptData method of Context context: %s", error->message); g_error_free (error); return NULL; } return mimes; } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_application_accept_data, context, Context, CONTEXT, "actions succesfully added"); void unity_webapps_context_set_application_accept_data (UnityWebappsContext *context, UnityWebappsStrWrapperDesc *wmimes, gint len) { gint i; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); // TODO: Rate limit if (context->priv->remote_ready == FALSE || len <= 0) return; const gchar * mimes[len + 1]; for (i = 0; i < len; i++) mimes[i] = wmimes[i].str; mimes[len] = NULL; unity_webapps_gen_context_call_set_application_accept_data (context->priv->context_proxy, mimes, context->priv->interest_id, NULL, set_application_accept_data_complete_callback, context); } #define MAXIMUM_ACTION_LABEL_LENGTH 400 UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(add_application_actions, context, Context, CONTEXT, "actions succesfully added"); void unity_webapps_context_add_application_actions (UnityWebappsContext *context, UnityWebappsApplicationActionDesc *actions, gint len) { gint i, k; gchar *sanitized_path; const char *path; unity_webapps_context_action_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); // TODO: Rate limit? if (context->priv->remote_ready == FALSE || len <= 0) return; const gchar * paths[len + 1]; for (i = 0, k = 0; i < len; i++) { path = actions[i].path; if (!path) continue; paths[k] = path; sanitized_path = unity_webapps_sanitizer_limit_string_argument (path, MAXIMUM_ACTION_LABEL_LENGTH); data = g_malloc0 (sizeof (unity_webapps_context_action_data)); data->callback = actions[i].callback; data->user_data = actions[i].user_data; g_hash_table_insert (context->priv->action_callbacks_by_name, sanitized_path, data); UNITY_WEBAPPS_NOTE (CONTEXT, "Adding application action: %s", path); k++; } paths[k] = NULL; unity_webapps_gen_context_call_add_application_actions (context->priv->context_proxy, paths, context->priv->interest_id, NULL, add_application_actions_complete_callback, context); } void unity_webapps_context_remove_application_action (UnityWebappsContext *context, const gchar *path) { gchar *sanitized_path; g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; sanitized_path = unity_webapps_sanitizer_limit_string_argument (path, MAXIMUM_ACTION_LABEL_LENGTH); unity_webapps_gen_context_call_remove_application_action (context->priv->context_proxy, sanitized_path, context->priv->interest_id, NULL /* Cancellable */, remove_action_complete_callback, context); g_hash_table_remove (context->priv->action_callbacks_by_name, sanitized_path); UNITY_WEBAPPS_NOTE(CONTEXT, "Removing application action: %s", sanitized_path); g_free (sanitized_path); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(remove_application_actions,context,Context,CONTEXT,"Actions succesfully cleared"); void unity_webapps_context_remove_application_actions (UnityWebappsContext *context) { g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (context->priv->remote_ready == FALSE) return; unity_webapps_gen_context_call_remove_application_actions (context->priv->context_proxy, context->priv->interest_id, NULL /* Cancellable */, remove_application_actions_complete_callback, context); g_hash_table_remove_all (context->priv->action_callbacks_by_name); } UnityWebappsService * unity_webapps_context_get_service (UnityWebappsContext *context) { return context->priv->service; } gint unity_webapps_context_get_focus_interest (UnityWebappsContext *context) { if (context->priv->remote_ready == FALSE) { return 0; } return unity_webapps_gen_context_get_focus_interest (context->priv->context_proxy); } gboolean unity_webapps_context_shutdown (UnityWebappsContext *context) { GError *error; if (context->priv->remote_ready == FALSE) { return FALSE; } error = NULL; unity_webapps_gen_context_call_shutdown_sync (context->priv->context_proxy, NULL, &error); if (error != NULL) { g_critical ("Error shutting down context: %s", error->message); g_error_free (error); return FALSE; } return TRUE; } gint unity_webapps_context_get_interest_id (UnityWebappsContext *context) { g_return_val_if_fail (context != NULL, UNITY_WEBAPPS_INVALID_INTEREST_ID); g_return_val_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context), UNITY_WEBAPPS_INVALID_INTEREST_ID); if ( context->priv->remote_ready == FALSE || context->priv->took_interest == FALSE) { return UNITY_WEBAPPS_INVALID_INTEREST_ID; } return context->priv->interest_id; } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-dbus-util.h0000644000015301777760000000275312321247333030575 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-dbus-util.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_DBUS_UTIL_H #define __UNITY_WEBAPPS_DBUS_UTIL_H #define UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(M,l,m,U,S) \ static void M##_complete_callback (GObject *source_object, GAsyncResult *res, gpointer user_data) { \ UnityWebappsGen##m *proxy; GError *error; \ proxy = UNITY_WEBAPPS_GEN_##U (source_object); \ error = NULL; \ unity_webapps_gen_##l##_call_##M##_finish (proxy, res, &error); \ if (error != NULL) { \ g_warning ("Error calling "#M " method of "#m "context: %s" , error->message); \ g_error_free (error); \ } UNITY_WEBAPPS_NOTE (U, "Received response: "#S);} #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-notification-context.h0000644000015301777760000000240012321247333033022 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-notification-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_NOTIFICATION_CONTEXT_H #define __UNITY_WEBAPPS_NOTIFICATION_CONTEXT_H typedef struct _UnityWebappsNotificationContext UnityWebappsNotificationContext; #include "unity-webapps-context.h" void unity_webapps_notification_show_notification (UnityWebappsContext *context, const gchar *summary, const gchar *body, const gchar *icon_url); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-music-player-context.h0000644000015301777760000000667212321247333032765 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-music-player-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_MUSIC_PLAYER_CONTEXT_H #define __UNITY_WEBAPPS_MUSIC_PLAYER_CONTEXT_H typedef struct _UnityWebappsMusicPlayerContext UnityWebappsMusicPlayerContext; typedef enum { UNITY_WEBAPPS_MUSIC_PLAYER_PLAYBACK_STATE_PLAYING, UNITY_WEBAPPS_MUSIC_PLAYER_PLAYBACK_STATE_PAUSED } UnityWebappsMusicPlayerPlaybackState; #include "unity-webapps-context.h" typedef void (*UnityWebappsMusicPlayerCallback) (UnityWebappsContext *context, gpointer user_data); typedef void (*UnityWebappsMusicPlayerPlaylistCallback) (UnityWebappsContext *context, const gchar *playlist_name, gpointer user_data); void unity_webapps_music_player_init (UnityWebappsContext *context, const gchar *title); void unity_webapps_music_player_set_track (UnityWebappsContext *context, const gchar *artist, const gchar *album, const gchar *title, const gchar *icon_url); void unity_webapps_music_player_on_play_pause_callback (UnityWebappsContext *context, UnityWebappsMusicPlayerCallback callback, gpointer user_data); void unity_webapps_music_player_on_previous_callback (UnityWebappsContext *context, UnityWebappsMusicPlayerCallback callback, gpointer user_data); void unity_webapps_music_player_on_next_callback (UnityWebappsContext *context, UnityWebappsMusicPlayerCallback callback, gpointer user_data); UnityWebappsMusicPlayerPlaybackState unity_webapps_music_player_get_playback_state (UnityWebappsContext *context); gboolean unity_webapps_music_player_get_can_go_previous (UnityWebappsContext *context); gboolean unity_webapps_music_player_get_can_go_next (UnityWebappsContext *context); gboolean unity_webapps_music_player_get_can_play (UnityWebappsContext *context); gboolean unity_webapps_music_player_get_can_pause (UnityWebappsContext *context); void unity_webapps_music_player_set_playback_state (UnityWebappsContext *context, UnityWebappsMusicPlayerPlaybackState state); void unity_webapps_music_player_set_can_go_previous (UnityWebappsContext *context, gboolean can_go_previous); void unity_webapps_music_player_set_can_go_next (UnityWebappsContext *context, gboolean can_go_next); void unity_webapps_music_player_set_can_play (UnityWebappsContext *context, gboolean can_go_play); void unity_webapps_music_player_set_can_pause (UnityWebappsContext *context, gboolean can_go_pause); void unity_webapps_music_player_set_playlists (UnityWebappsContext *context, const gchar *const *playlists); void unity_webapps_music_player_on_playlist_activated_callback (UnityWebappsContext *context, UnityWebappsMusicPlayerPlaylistCallback callback, gpointer user_data); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-context.h0000644000015301777760000002214412321247333030345 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_CONTEXT_H #define __UNITY_WEBAPPS_CONTEXT_H #include "unity-webapps-service.h" #define UNITY_WEBAPPS_TYPE_CONTEXT (unity_webapps_context_get_type()) #define UNITY_WEBAPPS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_CONTEXT, UnityWebappsContext)) #define UNITY_WEBAPPS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_CONTEXT, UnityWebappsContextClass)) #define UNITY_WEBAPPS_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_CONTEXT)) #define UNITY_WEBAPPS_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_CONTEXT)) #define UNITY_WEBAPPS_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_CONTEXT, UnityWebappsContextClass)) typedef struct _UnityWebappsContextPrivate UnityWebappsContextPrivate; typedef struct _UnityWebappsContext UnityWebappsContext; #include "unity-webapps-notification-context.h" #include "unity-webapps-indicator-context.h" #include "unity-webapps-music-player-context.h" #include "unity-webapps-launcher-context.h" typedef void (*UnityWebappsContextAcceptDataChanged) (UnityWebappsContext *context, const gchar **file, gpointer user_data); struct _UnityWebappsContext { GObject object; UnityWebappsContextPrivate *priv; }; typedef struct _UnityWebappsContextClass UnityWebappsContextClass; struct _UnityWebappsContextClass { GObjectClass parent_class; UnityWebappsContextAcceptDataChanged accept_data_changed; }; typedef struct { const gchar *str; } UnityWebappsStrWrapperDesc; typedef void (*UnityWebappsContextReadyCallback) (UnityWebappsContext *, gpointer user_data); typedef void (*UnityWebappsContextRaiseCallback) (UnityWebappsContext *context, const gchar *file, gpointer user_data); typedef void (*UnityWebappsContextCloseCallback) (UnityWebappsContext *context, gpointer user_data); typedef void (*UnityWebappsContextNotifyCallback) (UnityWebappsContext *, gint, gpointer); typedef void (*UnityWebappsContextViewNotifyCallback) (UnityWebappsContext *, gint, gboolean, gpointer); typedef void (*UnityWebappsContextLocationNotifyCallback) (UnityWebappsContext *, gint, const gchar *, gpointer); typedef void (*UnityWebappsContextWindowNotifyCallback) (UnityWebappsContext *, gint, guint64, gpointer); typedef const gchar * (*UnityWebappsContextPreviewCallback) (UnityWebappsContext *context, gpointer user_data); typedef void (*UnityWebappsContextPreviewReadyCallback) (UnityWebappsContext *context, gint interest_id, const gchar *preview_data, gpointer user_data); typedef void (*UnityWebappsContextActionCallback) (UnityWebappsContext *context, gpointer user_data); typedef struct { const gchar *path; UnityWebappsContextActionCallback callback; gpointer user_data; } UnityWebappsApplicationActionDesc; #define UNITY_WEBAPPS_CONTEXT_MENU_PATH "/com/canonical/Unity/Webapps/Context/ApplicationActions" GType unity_webapps_context_get_type (void) G_GNUC_CONST; void unity_webapps_context_new (UnityWebappsService *service, const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types, UnityWebappsContextReadyCallback callback, gpointer user_data); UnityWebappsContext * unity_webapps_context_new_lazy (UnityWebappsService *service, const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types); UnityWebappsContext *unity_webapps_context_new_sync (UnityWebappsService *service, const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types); void unity_webapps_context_destroy (UnityWebappsContext *context, gboolean user_abandoned); const gchar *unity_webapps_context_get_context_name (UnityWebappsContext *context); const gchar *unity_webapps_context_get_name (UnityWebappsContext *context); const gchar *unity_webapps_context_get_domain (UnityWebappsContext *context); const gchar *unity_webapps_context_get_desktop_name (UnityWebappsContext *context); gint unity_webapps_context_get_interest_id (UnityWebappsContext *context); gchar *unity_webapps_context_get_icon_name (UnityWebappsContext *context); void unity_webapps_context_add_icon (UnityWebappsContext *context, const gchar *url, gint size); void unity_webapps_context_on_raise_callback (UnityWebappsContext *context, UnityWebappsContextRaiseCallback callback, gpointer user_data); void unity_webapps_context_on_close_callback (UnityWebappsContext *context, UnityWebappsContextCloseCallback callback, gpointer user_data); gboolean unity_webapps_context_get_view_is_active (UnityWebappsContext *context, gint interest_id); void unity_webapps_context_set_view_is_active (UnityWebappsContext *context, gboolean active); void unity_webapps_context_on_view_is_active_changed (UnityWebappsContext *context, UnityWebappsContextViewNotifyCallback callback, gpointer user_data); UnityWebappsContext * unity_webapps_context_new_for_context_name (UnityWebappsService *service, const gchar *context_name); GVariant *unity_webapps_context_list_interests (UnityWebappsContext *context); void unity_webapps_context_on_interest_appeared (UnityWebappsContext *context, UnityWebappsContextNotifyCallback callback, gpointer user_data); void unity_webapps_context_on_interest_vanished (UnityWebappsContext *context, UnityWebappsContextNotifyCallback callback, gpointer user_data); void unity_webapps_context_raise (UnityWebappsContext *context); void unity_webapps_context_raise_interest (UnityWebappsContext *context, gint interest_id); void unity_webapps_context_close (UnityWebappsContext *context); void unity_webapps_context_close_interest (UnityWebappsContext *context, gint interest_id); gchar *unity_webapps_context_get_interest_owner (UnityWebappsContext *context, gint interest_id); gchar * unity_webapps_context_get_view_location (UnityWebappsContext *context, gint interest_id); void unity_webapps_context_set_view_location (UnityWebappsContext *context, const gchar *location); void unity_webapps_context_on_view_location_changed (UnityWebappsContext *context, UnityWebappsContextLocationNotifyCallback callback, gpointer user_data); guint64 unity_webapps_context_get_view_window (UnityWebappsContext *context, gint interest_id); void unity_webapps_context_set_view_window (UnityWebappsContext *context, guint64 window); void unity_webapps_context_on_view_window_changed (UnityWebappsContext *context, UnityWebappsContextWindowNotifyCallback callback, gpointer user_data); void unity_webapps_context_set_preview_requested_callback (UnityWebappsContext *context, UnityWebappsContextPreviewCallback callback, gpointer user_data); void unity_webapps_context_request_preview (UnityWebappsContext *context, gint interest_id, UnityWebappsContextPreviewReadyCallback callback, gpointer user_data); gchar** unity_webapps_context_get_application_accept_data (UnityWebappsContext *context); void unity_webapps_context_set_application_accept_data (UnityWebappsContext *context, UnityWebappsStrWrapperDesc *mimes, gint len); void unity_webapps_context_add_application_actions (UnityWebappsContext *context, UnityWebappsApplicationActionDesc *actions, gint len); void unity_webapps_context_remove_application_action (UnityWebappsContext *context, const gchar *label); void unity_webapps_context_remove_application_actions (UnityWebappsContext *context); UnityWebappsService *unity_webapps_context_get_service (UnityWebappsContext *context); void unity_webapps_context_set_homepage (UnityWebappsContext *context, const gchar *homepage); void unity_webapps_service_set_xid_for_browser_window_id (UnityWebappsService *service, UnityWebappsContext *context, int window_id); void unity_webapps_context_prepare (UnityWebappsContext *context, UnityWebappsContextReadyCallback callback, gpointer user_data); gint unity_webapps_context_get_focus_interest (UnityWebappsContext *context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-notification-context.c0000644000015301777760000000707512321247333033032 0ustar pbusernogroup00000000000000/* * unity-webapps-notification-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-notification-context.h" #include "unity-webapps-context-private.h" #include "unity-webapps-sanitizer.h" #include "unity-webapps-dbus-util.h" #include "unity-webapps-rate.h" #include "unity-webapps-debug.h" UnityWebappsNotificationContext * unity_webapps_notification_context_new (UnityWebappsContext *main_context, GError **error) { UnityWebappsNotificationContext *context; context = g_malloc0 (sizeof (UnityWebappsNotificationContext)); context->notification_rate = 0; context->notification_proxy = unity_webapps_gen_notification_proxy_new_sync (unity_webapps_service_get_connection (main_context->priv->service) , G_DBUS_PROXY_FLAGS_NONE, main_context->priv->context_name, UNITY_WEBAPPS_NOTIFICATION_PATH, NULL /* Cancellable */, error); if (error && (*error != NULL)) { g_critical ("Error creating notification context proxy object for %s: %s", main_context->priv->context_name, (*error)->message); return NULL; } return context; } void unity_webapps_notification_context_free (UnityWebappsNotificationContext *context) { g_return_if_fail (context != NULL); g_object_unref (G_OBJECT (context->notification_proxy)); g_free (context); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(show_notification,notification,Notification,NOTIFICATION,"Notification succesfully sent"); #define MAXIMUM_SUMMARY_LENGTH 80 #define MAXIMUM_BODY_LENGTH 160 #define MAXIMUM_ICON_URL_LENGTH 4096 void unity_webapps_notification_show_notification (UnityWebappsContext *context, const gchar *summary, const gchar *body, const gchar *icon_url) { gchar *sanitized_summary, *sanitized_body, *sanitized_icon_url; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (summary != NULL); g_return_if_fail (body != NULL); if (unity_webapps_rate_check_notification_rate_limit (context) == FALSE) { return; } sanitized_summary = unity_webapps_sanitizer_limit_string_argument (summary, MAXIMUM_SUMMARY_LENGTH); sanitized_body = unity_webapps_sanitizer_limit_string_argument (body, MAXIMUM_BODY_LENGTH); sanitized_icon_url = unity_webapps_sanitizer_limit_string_argument (icon_url, MAXIMUM_ICON_URL_LENGTH); unity_webapps_gen_notification_call_show_notification (context->priv->notification_context->notification_proxy, sanitized_summary, sanitized_body, sanitized_icon_url, NULL /* Cancellable */, show_notification_complete_callback, context); g_free (sanitized_summary); g_free (sanitized_body); g_free (sanitized_icon_url); UNITY_WEBAPPS_NOTE (NOTIFICATION, "Showed notification, summary: %s", summary); } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-permissions.c0000644000015301777760000002554312321247333031235 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-permissions.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "unity-webapps-permissions.h" #include #define G_SETTINGS_ENABLE_BACKEND #include #include #define UNITY_WEBAPPS_SCHEMA_NAME "com.canonical.unity.webapps" #define DONTASK_DOMAINS_KEY "dontask-domains" #define ALLOWED_DOMAINS_KEY "allowed-domains" #define INTEGRATION_ALLOWED_KEY "integration-allowed" #define PREAUTHORIZED_DOMAINS_KEY "preauthorized-domains" static gboolean _unity_webapps_permissions_use_memory_backend = FALSE; static const gchar *_unity_webapps_permissions_test_schema_path = NULL; static GSettingsBackend *_unity_webapps_permissions_memory_backend = NULL; void unity_webapps_permissions_tests_use_memory_backend(const gchar *schema_path) { _unity_webapps_permissions_use_memory_backend = TRUE; _unity_webapps_permissions_memory_backend = g_memory_settings_backend_new(); _unity_webapps_permissions_test_schema_path = schema_path; } gboolean unity_webapps_permissions_schema_exists () { const gchar *const *schemas; guint i, len; // Skip the test when running unit tests & using custom backends/paths if (_unity_webapps_permissions_use_memory_backend && _unity_webapps_permissions_test_schema_path) return TRUE; schemas = g_settings_list_schemas(); len = g_strv_length ((gchar **)schemas); for (i = 0; i < len; i++) { if (g_strcmp0 (schemas[i], UNITY_WEBAPPS_SCHEMA_NAME) == 0) { return TRUE; } } g_critical("Failed to find '%s' schema", UNITY_WEBAPPS_SCHEMA_NAME); return FALSE; } static void filter_settings_strv (GSettings *settings, const gchar *key, const gchar *str) { gchar **it1, **it2; gchar **strv = g_settings_get_strv(settings, key); for (it1 = strv, it2 = strv; it2 && *it2; it2++) { if (g_strcmp0 (*it2, str) != 0) { *it1 = *it2; it1++; } } *it1 = NULL; g_settings_set_strv (settings, key, (const gchar *const *)strv); g_strfreev (strv); } static gboolean is_domain_found_for_keyname(GSettings * settings, const char * const keyname, const char * const domain) { gboolean ret; gint i; gchar **domains; g_return_val_if_fail(settings != NULL, FALSE); g_return_val_if_fail(keyname != NULL, FALSE); g_return_val_if_fail(domain != NULL, FALSE); domains = g_settings_get_strv(settings, keyname); if (!domains) { return FALSE; } ret = FALSE; for (i = 0; domains[i] != NULL; i++) { if (g_strcmp0(domains[i], domain) == 0) { ret = TRUE; break; } } g_strfreev (domains); return ret; } static GSettings * _unity_webapps_permissions_new_settings(void) { GSettings *settings = NULL; if (_unity_webapps_permissions_use_memory_backend && _unity_webapps_permissions_test_schema_path) { GSettingsSchemaSource *source = g_settings_schema_source_new_from_directory( _unity_webapps_permissions_test_schema_path, NULL, TRUE, NULL); GSettingsSchema *schema = g_settings_schema_source_lookup(source, UNITY_WEBAPPS_SCHEMA_NAME, FALSE); settings = g_settings_new_full(schema, _unity_webapps_permissions_memory_backend, NULL); } else settings = g_settings_new(UNITY_WEBAPPS_SCHEMA_NAME); return settings; } /* * Add a domain to the list of "dontask" domains which should be blacklisted from requesting permissions */ void unity_webapps_permissions_dontask_domain (const gchar *domain) { GSettings *settings; gchar **dontask_domains, **new_dontask_domains; int i, length; if (unity_webapps_permissions_schema_exists () == FALSE) { return; } settings = _unity_webapps_permissions_new_settings(); if (!settings) return; g_settings_delay (settings); filter_settings_strv (settings, ALLOWED_DOMAINS_KEY, domain); dontask_domains = NULL; new_dontask_domains = NULL; if (!is_domain_found_for_keyname (settings, DONTASK_DOMAINS_KEY, domain)) { dontask_domains = g_settings_get_strv (settings, DONTASK_DOMAINS_KEY); length = g_strv_length (dontask_domains); new_dontask_domains = g_malloc (sizeof(gchar *) * (length + 2)); for (i = 0; i < length; i++) { new_dontask_domains[i] = g_strdup (dontask_domains[i]); } new_dontask_domains[length] = g_strdup (domain); new_dontask_domains[length+1] = NULL; g_settings_set_strv(settings, DONTASK_DOMAINS_KEY, (const gchar * const*)new_dontask_domains); } g_settings_apply (settings); g_object_unref (G_OBJECT (settings)); g_strfreev (dontask_domains); g_strfreev (new_dontask_domains); } /* * Add a domain to the list of domains which have been granted permissions */ void unity_webapps_permissions_allow_domain (const gchar *domain) { GSettings *settings; gchar **allowed_domains, **new_allowed_domains; int i, length; if (unity_webapps_permissions_schema_exists () == FALSE) { return; } settings = _unity_webapps_permissions_new_settings(); if (!settings) return; g_settings_delay (settings); filter_settings_strv (settings, DONTASK_DOMAINS_KEY, domain); allowed_domains = NULL; new_allowed_domains = NULL; if (!is_domain_found_for_keyname (settings, ALLOWED_DOMAINS_KEY, domain)) { allowed_domains = g_settings_get_strv(settings, ALLOWED_DOMAINS_KEY); length = g_strv_length (allowed_domains); new_allowed_domains = g_malloc (sizeof(gchar *) * (length + 2)); for (i = 0; i < length; i++) { new_allowed_domains[i] = g_strdup (allowed_domains[i]); } new_allowed_domains[length] = g_strdup (domain); new_allowed_domains[length+1] = NULL; g_settings_set_strv(settings, ALLOWED_DOMAINS_KEY, (const gchar * const*)new_allowed_domains); } g_settings_apply (settings); g_object_unref (G_OBJECT (settings)); g_strfreev (allowed_domains); g_strfreev (new_allowed_domains); } /* * Checks if a domain is in the list of domains allowed permissions. */ gboolean unity_webapps_permissions_get_domain_allowed (const gchar *domain) { GSettings *settings; gboolean ret, dontask; dontask = unity_webapps_permissions_get_domain_dontask (domain); if (dontask == TRUE) { return FALSE; } if (unity_webapps_permissions_schema_exists () == FALSE) { return FALSE; } settings = _unity_webapps_permissions_new_settings(); if (!settings) return FALSE; ret = is_domain_found_for_keyname(settings, ALLOWED_DOMAINS_KEY, domain) || is_domain_found_for_keyname(settings, PREAUTHORIZED_DOMAINS_KEY, domain); g_object_unref (G_OBJECT (settings)); return ret; } gboolean unity_webapps_permissions_get_domain_preauthorized (const gchar *domain) { GSettings *settings; gboolean ret; if (unity_webapps_permissions_schema_exists () == FALSE) { return FALSE; } settings = _unity_webapps_permissions_new_settings(); if (!settings) return FALSE; ret = is_domain_found_for_keyname(settings, PREAUTHORIZED_DOMAINS_KEY, domain); g_object_unref (G_OBJECT (settings)); return ret; } /* * Checks if a domain is in the list of blacklisted dontask domains */ gboolean unity_webapps_permissions_get_domain_dontask (const gchar *domain) { GSettings *settings; gboolean ret; if (unity_webapps_permissions_schema_exists () == FALSE) { return TRUE; } settings = _unity_webapps_permissions_new_settings(); if (!settings) return TRUE; ret = is_domain_found_for_keyname(settings, DONTASK_DOMAINS_KEY, domain); g_object_unref (G_OBJECT (settings)); return ret; } static void _json_object_set_strv_memeber (JsonObject *obj, const gchar* name, gchar **strv) { JsonArray *array; gchar **it; array = json_array_new (); for (it = strv; it && *it; it++) { json_array_add_string_element (array, *it); } json_object_set_array_member (obj, name, array); // json_array_unref (array); } gchar* unity_webapps_permissions_get_all_domains (void) { gchar *res; GSettings *settings; JsonGenerator *generator; JsonNode *root; JsonObject *obj; gchar **allowed = NULL, **dontask = NULL; if (unity_webapps_permissions_schema_exists ()) { settings = _unity_webapps_permissions_new_settings(); if (!settings) return NULL; dontask = g_settings_get_strv(settings, DONTASK_DOMAINS_KEY); allowed = g_settings_get_strv(settings, ALLOWED_DOMAINS_KEY); g_object_unref (G_OBJECT (settings)); } root = json_node_new (JSON_NODE_OBJECT); obj = json_object_new (); json_node_set_object (root, obj); json_object_unref (obj); _json_object_set_strv_memeber (obj, "allowed", allowed); _json_object_set_strv_memeber (obj, "dontask", dontask); generator = json_generator_new (); json_generator_set_root (generator, root); res = json_generator_to_data (generator, NULL); json_node_free (root); g_object_unref (generator); g_strfreev (allowed); g_strfreev (dontask); return res; } /** * Removes a given domain name from the list of internal permission sets (either allowed * or not allowed). * */ void unity_webapps_permissions_remove_domain_from_permissions (const gchar *domain) { GSettings *settings = NULL; g_return_if_fail(NULL != domain); if (unity_webapps_permissions_schema_exists () == FALSE) { return; } settings = _unity_webapps_permissions_new_settings(); if (!settings) return; g_settings_delay (settings); filter_settings_strv (settings, DONTASK_DOMAINS_KEY, domain); filter_settings_strv (settings, ALLOWED_DOMAINS_KEY, domain); g_settings_apply (settings); g_object_unref (G_OBJECT (settings)); } gboolean unity_webapps_permissions_is_integration_allowed(void) { GSettings *settings = NULL; if (unity_webapps_permissions_schema_exists () == FALSE) { return TRUE; } settings = _unity_webapps_permissions_new_settings(); if (!settings) return TRUE; gboolean isallowed = g_settings_get_boolean(settings, INTEGRATION_ALLOWED_KEY); g_object_unref (G_OBJECT (settings)); return isallowed; } void unity_webapps_permissions_set_integration_allowed(gboolean allowed) { GSettings *settings = NULL; if (unity_webapps_permissions_schema_exists () == FALSE) { return; } settings = _unity_webapps_permissions_new_settings(); if (!settings) return; g_settings_set_boolean(settings, INTEGRATION_ALLOWED_KEY, allowed); g_object_unref (G_OBJECT (settings)); } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-context-private.h0000644000015301777760000000507012321247333032014 0ustar pbusernogroup00000000000000#ifndef _UNITY_WEBAPPS_CONTEXT_PRIVATE_H__ #define _UNITY_WEBAPPS_CONTEXT_PRIVATE_H__ #include "unity-webapps-gen-context.h" #include "unity-webapps-gen-launcher.h" #include "unity-webapps-gen-notification.h" #include "unity-webapps-gen-indicator.h" #include "unity-webapps-gen-music-player.h" struct _UnityWebappsNotificationContext { UnityWebappsContext *context; UnityWebappsGenNotification *notification_proxy; guint notification_rate; }; struct _UnityWebappsLauncherContext { UnityWebappsContext *context; UnityWebappsGenLauncher *launcher_proxy; GHashTable *quicklist_callbacks_by_name; guint launcher_rate; }; struct _UnityWebappsMusicPlayerContext { UnityWebappsContext *context; UnityWebappsGenMusicPlayer *music_player_proxy; guint music_player_rate; }; struct _UnityWebappsIndicatorContext { UnityWebappsContext *context; UnityWebappsGenIndicator *indicator_proxy; GHashTable *menu_callbacks_by_name; GHashTable *indicator_callbacks_by_name; guint indicator_rate; }; struct _UnityWebappsContextPrivate { UnityWebappsService *service; UnityWebappsGenContext *context_proxy; UnityWebappsNotificationContext *notification_context; UnityWebappsIndicatorContext *indicator_context; UnityWebappsMusicPlayerContext *music_player_context; UnityWebappsLauncherContext *launcher_context; guint global_rate; gchar *name; gchar *domain; gchar *icon_url; gchar *mime_types; /*capable of opening files with the given content type*/ gchar *context_name; gboolean took_interest; gboolean user_abandoned; gint interest_id; UnityWebappsContextPreviewCallback preview_callback; gpointer preview_user_data; GHashTable *action_callbacks_by_name; gboolean remote_ready; }; UnityWebappsIndicatorContext *unity_webapps_indicator_context_new (UnityWebappsContext *main_context, GError **error); void unity_webapps_indicator_context_free (UnityWebappsIndicatorContext *context); UnityWebappsNotificationContext *unity_webapps_notification_context_new (UnityWebappsContext *main_context, GError **error); void unity_webapps_notification_context_free (UnityWebappsNotificationContext *context); UnityWebappsLauncherContext *unity_webapps_launcher_context_new (UnityWebappsContext *main_context, GError **error); void unity_webapps_launcher_context_free (UnityWebappsLauncherContext *context); UnityWebappsMusicPlayerContext *unity_webapps_music_player_context_new (UnityWebappsContext *main_context, GError **error); void unity_webapps_music_player_context_free (UnityWebappsMusicPlayerContext *context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-launcher-context.h0000644000015301777760000000405712321247333032147 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-launcher-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_LAUNCHER_CONTEXT_H #define __UNITY_WEBAPPS_LAUNCHER_CONTEXT_H typedef struct _UnityWebappsLauncherContext UnityWebappsLauncherContext; #include "unity-webapps-context.h" typedef void (*UnityWebappsLauncherCallback) (UnityWebappsContext *context, gpointer user_data); void unity_webapps_launcher_set_count (UnityWebappsContext *context, gint count); void unity_webapps_launcher_clear_count (UnityWebappsContext *context); void unity_webapps_launcher_set_progress (UnityWebappsContext *context, gdouble progress); void unity_webapps_launcher_clear_progress (UnityWebappsContext *context); void unity_webapps_launcher_set_urgent (UnityWebappsContext *context); void unity_webapps_launcher_add_static_action (UnityWebappsContext *context, const gchar *label, const gchar *page); void unity_webapps_launcher_remove_static_actions (UnityWebappsContext *context); void unity_webapps_launcher_add_action (UnityWebappsContext *context, const gchar *label, UnityWebappsLauncherCallback callback, gpointer user_data); void unity_webapps_launcher_remove_action (UnityWebappsContext *context, const gchar *label); void unity_webapps_launcher_remove_actions (UnityWebappsContext *context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-permissions.h0000644000015301777760000000350212321247333031231 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-permissions.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_PERMISSIONS_H #define __UNITY_WEBAPPS_PERMISSIONS_H #include "unity-webapps-context.h" gboolean unity_webapps_permissions_get_domain_allowed (const gchar *domain); gboolean unity_webapps_permissions_get_domain_dontask (const gchar *domain); gboolean unity_webapps_permissions_get_domain_preauthorized (const gchar *domain); void unity_webapps_permissions_allow_domain (const gchar *domain); void unity_webapps_permissions_dontask_domain (const gchar *domain); void unity_webapps_permissions_remove_domain_from_permissions (const gchar *domain); gchar* unity_webapps_permissions_get_all_domains (void); gboolean unity_webapps_permissions_is_integration_allowed(void); void unity_webapps_permissions_set_integration_allowed(gboolean allowed); /** * Only used for tests purposes. Sets up the permissions to use a * memory backend instead of a persistant one. */ void unity_webapps_permissions_tests_use_memory_backend(const gchar *schema_path); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps/unity-webapps-launcher-context.c0000644000015301777760000002553012321247333032141 0ustar pbusernogroup00000000000000/* * unity-webapps-launcher-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-launcher-context.h" #include "unity-webapps-context-private.h" #include "unity-webapps-sanitizer.h" #include "unity-webapps-debug.h" #include "unity-webapps-rate.h" #include "unity-webapps-dbus-util.h" typedef struct _unity_webapps_launcher_action_data { UnityWebappsLauncherCallback callback; gpointer user_data; } unity_webapps_launcher_action_data; static void _launcher_context_action_invoked (UnityWebappsGenLauncher *launcher, const gchar *label, gint interest_id, gpointer user_data) { UnityWebappsContext *context; unity_webapps_launcher_action_data *data; context = (UnityWebappsContext *)user_data; g_return_if_fail(context != NULL); if (!G_IS_OBJECT(context)) return; if (context->priv->interest_id != interest_id) return; data = g_hash_table_lookup (context->priv->launcher_context->quicklist_callbacks_by_name, label); if ((data != NULL) && (data->callback != NULL)) { UNITY_WEBAPPS_NOTE (LAUNCHER, "Quicklist action invoked: %s", label); data->callback(context, data->user_data); return; } UNITY_WEBAPPS_NOTE (LAUNCHER, "Quicklist action invoked, but we do not have a handler: %s", label); } UnityWebappsLauncherContext * unity_webapps_launcher_context_new (UnityWebappsContext *main_context, GError **error) { UnityWebappsLauncherContext *context; context = g_malloc0 (sizeof (UnityWebappsLauncherContext)); context->launcher_rate = 0; context->launcher_proxy = unity_webapps_gen_launcher_proxy_new_sync (unity_webapps_service_get_connection (main_context->priv->service) , G_DBUS_PROXY_FLAGS_NONE, main_context->priv->context_name, UNITY_WEBAPPS_LAUNCHER_PATH, NULL /* Cancellable */, error); if (error && (*error != NULL)) { g_critical ("Error creating launcher context proxy object for %s: %s", main_context->priv->context_name, (*error)->message); return NULL; } context->quicklist_callbacks_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); g_signal_connect (context->launcher_proxy, "action-invoked", G_CALLBACK (_launcher_context_action_invoked), main_context); return context; } void unity_webapps_launcher_context_free (UnityWebappsLauncherContext *context) { g_return_if_fail (context != NULL); g_object_unref (G_OBJECT (context->launcher_proxy)); g_hash_table_destroy (context->quicklist_callbacks_by_name); g_free (context); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_count,launcher,Launcher,LAUNCHER,"Count succesfully set"); void unity_webapps_launcher_set_count (UnityWebappsContext *context, gint count) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } unity_webapps_gen_launcher_call_set_count (context->priv->launcher_context->launcher_proxy, count, NULL /* Cancellable */, set_count_complete_callback, context); UNITY_WEBAPPS_NOTE (LAUNCHER, "Setting count: %d", count); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_progress,launcher,Launcher,LAUNCHER,"Progress succesfully set"); void unity_webapps_launcher_set_progress (UnityWebappsContext *context, gdouble progress) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } unity_webapps_gen_launcher_call_set_progress (context->priv->launcher_context->launcher_proxy, progress, NULL /* Cancellable */, set_progress_complete_callback, context); UNITY_WEBAPPS_NOTE (LAUNCHER, "Setting progress: %f", progress); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(clear_count,launcher,Launcher,LAUNCHER,"Count succesfully cleared"); void unity_webapps_launcher_clear_count (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } unity_webapps_gen_launcher_call_clear_count (context->priv->launcher_context->launcher_proxy, NULL /* Cancellable */, clear_count_complete_callback, context); UNITY_WEBAPPS_NOTE (LAUNCHER, "Clearing count"); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(clear_progress,launcher,Launcher,LAUNCHER,"Progress succesfully cleared"); void unity_webapps_launcher_clear_progress (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } unity_webapps_gen_launcher_call_clear_progress (context->priv->launcher_context->launcher_proxy, NULL /* Cancellable */, clear_progress_complete_callback, context); UNITY_WEBAPPS_NOTE (LAUNCHER, "Clearing progress"); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(set_urgent,launcher,Launcher,LAUNCHER,"Urgent state succesfully set"); void unity_webapps_launcher_set_urgent (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } unity_webapps_gen_launcher_call_set_urgent (context->priv->launcher_context->launcher_proxy, NULL /* Cancellable */, set_urgent_complete_callback, context); UNITY_WEBAPPS_NOTE (LAUNCHER, "Setting urgent state"); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(add_static_action,launcher,Launcher,LAUNCHER,"Static action succesfully added"); #define MAXIMUM_LABEL_LENGTH 60 void unity_webapps_launcher_add_static_action (UnityWebappsContext *context, const gchar *label, const gchar *page) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } unity_webapps_gen_launcher_call_add_static_action (context->priv->launcher_context->launcher_proxy, label, page, NULL, add_static_action_complete_callback, context); UNITY_WEBAPPS_NOTE (LAUNCHER, "Adding static action: %s", label); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(remove_static_actions,launcher,Launcher,LAUNCHER,"Static actions succesfully removed"); void unity_webapps_launcher_remove_static_actions (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } unity_webapps_gen_launcher_call_remove_static_actions (context->priv->launcher_context->launcher_proxy, NULL, remove_static_actions_complete_callback, context); UNITY_WEBAPPS_NOTE (LAUNCHER, "Removing all static actions"); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(add_action,launcher,Launcher,LAUNCHER,"Action succesfully added"); void unity_webapps_launcher_add_action (UnityWebappsContext *context, const gchar *label, UnityWebappsLauncherCallback callback, gpointer user_data) { gchar *sanitized_label; unity_webapps_launcher_action_data *data; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); g_return_if_fail (callback != NULL); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } // The Hash Table takes ownership of this. sanitized_label = unity_webapps_sanitizer_limit_string_argument (label, MAXIMUM_LABEL_LENGTH); unity_webapps_gen_launcher_call_add_action (context->priv->launcher_context->launcher_proxy, sanitized_label, context->priv->interest_id, NULL /* Cancellable */, add_action_complete_callback, context); data = g_malloc0 (sizeof (unity_webapps_launcher_action_data)); data->callback = callback; data->user_data = user_data; g_hash_table_insert (context->priv->launcher_context->quicklist_callbacks_by_name, sanitized_label, data); UNITY_WEBAPPS_NOTE (LAUNCHER, "Adding action: %s", label); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(remove_action,launcher,Launcher,LAUNCHER,"Action succesfully removed"); void unity_webapps_launcher_remove_action (UnityWebappsContext *context, const gchar *label) { gchar *sanitized_label; g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } sanitized_label = unity_webapps_sanitizer_limit_string_argument (label, MAXIMUM_LABEL_LENGTH); unity_webapps_gen_launcher_call_remove_action (context->priv->launcher_context->launcher_proxy, sanitized_label, context->priv->interest_id, NULL /* Cancellable */, remove_action_complete_callback, context); g_hash_table_remove (context->priv->launcher_context->quicklist_callbacks_by_name, sanitized_label); UNITY_WEBAPPS_NOTE (LAUNCHER, "Removing action: %s", label); g_free (sanitized_label); } UNITY_WEBAPPS_DEFINE_VOID_DBUS_HANDLER(remove_actions,launcher,Launcher,LAUNCHER,"Action succesfully removed"); void unity_webapps_launcher_remove_actions (UnityWebappsContext *context) { g_return_if_fail (context != NULL); g_return_if_fail (UNITY_WEBAPPS_IS_CONTEXT (context)); if (unity_webapps_rate_check_launcher_rate_limit (context) == FALSE) { return; } unity_webapps_gen_launcher_call_remove_actions (context->priv->launcher_context->launcher_proxy, context->priv->interest_id, NULL /* Cancellable */, remove_actions_complete_callback, context); g_hash_table_remove_all (context->priv->launcher_context->quicklist_callbacks_by_name); UNITY_WEBAPPS_NOTE (LAUNCHER, "Removing all actions"); } libunity-webapps-2.5.0~+14.04.20140409/src/webapps-service/0000755000015301777760000000000012321250157023477 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/webapps-service/Makefile.am0000644000015301777760000000210612321247333025534 0ustar pbusernogroup00000000000000EXTRA_DIST = BUILT_SOURCES = AM_CPPFLAGS = \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" $(UNITY_WEBAPPS_CFLAGS) $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ $(UNITY_WEBAPPS_DEBUG_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" -I$(top_srcdir)/src -I$(top_srcdir)/src/libunity-webapps libexec_PROGRAMS = \ unity-webapps-service unity_webapps_service_SOURCES = \ unity-webapps-service.c \ unity-webapps-service.h \ unity-webapps-service-preinstalled-app.c \ unity-webapps-service-preinstalled-app.h \ unity-webapps-debug.c \ ../unity-webapps-app-db.c \ ../unity-webapps-app-db.h \ ../context-daemon/util/unity-webapps-dirs.c \ ../unity-webapps-debug.h \ ../unity-webapps-gen-service.c \ ../unity-webapps-gen-service.h \ ../unity-webapps-gen-context.c \ ../unity-webapps-gen-context.h unity_webapps_service_LDFLAGS = $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) unity_webapps_service_LDADD = $(UNITY_WEBAPPS_LIBS) $(UNITY_WEBAPPS_DAEMON_LIBS) libunity-webapps-2.5.0~+14.04.20140409/src/webapps-service/unity-webapps-service-preinstalled-app.h0000644000015301777760000000203112321247333033355 0ustar pbusernogroup00000000000000/* * unity-webapps-service-preinstalled-app.h * Copyright (C) Canonical LTD 2012 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_SERVICE_PREINSTALLED_APP_H #define __UNITY_WEBAPPS_SERVICE_PREINSTALLED_APP_H #include const gchar *unity_webapps_service_get_preinstalled_app_desktop_id (const gchar *name, const gchar *domain); #endif libunity-webapps-2.5.0~+14.04.20140409/src/webapps-service/unity-webapps-service.h0000644000015301777760000000241712321247333030123 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-context-daemon.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_CONTEXT_DAEMON_H #define __UNITY_WEBAPPS_CONTEXT_DAEMON_H #include #include #include typedef struct _UnityWebappsService { GHashTable *contexts; GHashTable *pending_ready; GHashTable *lonely_daemons; } UnityWebappsService; UnityWebappsService * unity_webapps_service_new(); void unity_webapps_service_destroy (UnityWebappsService *service); #endif libunity-webapps-2.5.0~+14.04.20140409/src/webapps-service/unity-webapps-service.c0000644000015301777760000011352712321247333030123 0ustar pbusernogroup00000000000000/* * unity-webapps-service.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include "unity-webapps-service.h" #include "unity-webapps-gen-context.h" #include "unity-webapps-gen-service.h" #include "unity-webapps-service-preinstalled-app.h" #include "unity-webapps-dbus-defs.h" #include "unity-webapps-debug.h" #include "unity-webapps-wire-version.h" #include "unity-webapps-app-db.h" #define UNITY_WEBAPPS_SCHEMA_NAME "com.canonical.unity.webapps" #define INDEX_UPDATE_TIME_KEY "index-update-time" #define MINIMUM_UPDATE_TIME 60*60 static GMainLoop *mainloop = NULL; guint context_ready_signal_subscription; guint context_lost_interest_signal_subscription; static gboolean replace_service = FALSE; static GOptionEntry option_entries[] = { {"replace", 'r', 0, G_OPTION_ARG_NONE, &replace_service, "Replace running service", NULL}, { NULL } }; static void unity_webapps_service_spawn_index_updater () { GError *error; if (!g_strcmp0(g_getenv("UNITY_WEBAPPS_TESTS_DISABLE_INDEX_UPDATER"), "yes")) { UNITY_WEBAPPS_NOTE (SERVICE, "Index updater run explicitly disabled"); return; } error = NULL; g_spawn_command_line_async ("ubuntu-webapps-update-index", &error); if (error != NULL) { g_critical ("Failed to spawn ubuntu-webapps-update-index: %s", error->message); g_error_free (error); } } static void unity_webapps_service_emit_context_appeared (GDBusConnection *connection, const gchar *context) { GError *error; error = NULL; UNITY_WEBAPPS_NOTE (SERVICE, "Emitting ContextAppeared signal for %s", context); g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_SERVICE_PATH, UNITY_WEBAPPS_SERVICE_IFACE, "ContextAppeared", g_variant_new ("(s)", context, NULL), &error); if (error != NULL) { g_warning ("Error emiting ContextAppeared signal in service: %s", error->message); g_error_free (error); return; } } static void unity_webapps_service_emit_context_vanished (GDBusConnection *connection, const gchar *context) { GError *error; error = NULL; UNITY_WEBAPPS_NOTE (SERVICE, "Emitting ContextVanished signal for %s", context); g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_SERVICE_PATH, UNITY_WEBAPPS_SERVICE_IFACE, "ContextVanished", g_variant_new ("(s)", context, NULL), &error); if (error != NULL) { g_warning ("Error emiting ContextVanished signal in service: %s", error->message); g_error_free (error); return; } } static void add_pending_ready (UnityWebappsService *service, const gchar *id, GDBusMethodInvocation *invocation) { GList *invocations; invocations = g_hash_table_lookup (service->pending_ready, id); invocations = g_list_append (invocations, g_object_ref (G_OBJECT (invocation))); g_hash_table_replace (service->pending_ready, g_strdup (id), invocations); } static void remove_pending_ready (UnityWebappsService *service, const gchar *id) { GList *invocations, *walk; invocations = g_hash_table_lookup (service->pending_ready, id); for (walk = invocations; walk != NULL; walk = walk->next) { // GDBusMethodInvocation *invocation; // invocation = (GDBusMethodInvocation *)walk->data; // TODO : Whats happening here? // g_object_unref (G_OBJECT (invocation)); } g_list_free (invocations); g_hash_table_remove (service->pending_ready, id); } UnityWebappsService * unity_webapps_service_new () { UnityWebappsService *service; UNITY_WEBAPPS_NOTE (SERVICE, "Initializing Service object"); service = g_malloc0 (sizeof (UnityWebappsService)); service->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); service->pending_ready = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); service->lonely_daemons = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); return service; } void unity_webapps_service_destroy (UnityWebappsService *service) { g_hash_table_destroy (service->contexts); g_hash_table_destroy (service->pending_ready); g_hash_table_destroy (service->lonely_daemons); g_free (service); } #ifdef UNITY_WEBAPPS_ENABLE_DEBUG static gchar * get_context_log_file_name (const gchar *name) { gchar *log_file_name; time_t current_time; current_time = time (NULL); log_file_name = g_strdup_printf("./%s-%lu", name, (unsigned long) current_time); return log_file_name; } void child_setup (gpointer user_data) { gchar *log_name; int fd; return; if (g_getenv ("UNITY_WEBAPPS_CONTEXT_USE_LOG_FILES") == NULL) { return; } log_name = (gchar *)user_data; fd = open (log_name, O_WRONLY | O_CREAT, 0666); dup2 (fd, STDOUT_FILENO); dup2 (fd, STDERR_FILENO); close (fd); } #endif static gchar ** unity_webapps_service_get_context_daemon_argv (const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types) { gchar **argv; const gchar *execdir; const gchar *preinstalled_desktop; execdir = g_getenv("UNITY_WEBAPPS_DAEMON_EXEC_DIR"); if (execdir == NULL) { execdir = PACKAGE_LIBEXEC_DIR; } preinstalled_desktop = unity_webapps_service_get_preinstalled_app_desktop_id (name, domain); if (preinstalled_desktop == NULL) { argv = g_malloc (6 * sizeof (gchar *)); } else { argv = g_malloc (7 * sizeof (gchar *)); } argv[0] = g_strdup_printf("%s/unity-webapps-context-daemon", execdir); argv[1] = g_strdup (name); argv[2] = g_strdup (domain); argv[3] = icon_url ? g_strdup (icon_url) : g_strdup ("none"); argv[4] = mime_types ? g_strdup (mime_types) : g_strdup("none"); if (preinstalled_desktop == NULL) { argv[5] = NULL; } else { argv[5] = g_strdup (preinstalled_desktop); argv[6] = NULL; } return argv; } static gboolean spawn_context_daemon (const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types, GError **error) { gchar **argv; gboolean ret; UNITY_WEBAPPS_NOTE (SERVICE, "Spawning context daemon %s %s", name, domain); argv = unity_webapps_service_get_context_daemon_argv (name, domain, icon_url, mime_types); *error = NULL; ret = TRUE; #ifdef UNITY_WEBAPPS_ENABLE_DEBUG g_spawn_async_with_pipes (NULL, argv, NULL, 0, NULL, get_context_log_file_name (name), NULL, NULL, NULL, NULL, error); #else g_spawn_async_with_pipes (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, error); #endif if (*error != NULL) { g_critical("Error spawning context daemon: %s", (*error)->message); ret = FALSE; goto out; } out: g_strfreev (argv); return ret; } static UnityWebappsGenContext * make_context_proxy (GDBusConnection *connection, const gchar *context_name) { UnityWebappsGenContext *context_proxy; GError *error; error = NULL; UNITY_WEBAPPS_NOTE (SERVICE, "Creating context proxy for %s", context_name); context_proxy = unity_webapps_gen_context_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, context_name, UNITY_WEBAPPS_CONTEXT_PATH, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Couldn't create proxy for interesting context (%s): %s", context_name, error->message); g_error_free (error); return NULL; } return context_proxy; } typedef struct _context_vanished_user_data { UnityWebappsService *service; guint watcher_id; } context_vanished_user_data; static void context_name_vanished (GDBusConnection *connection, const gchar *name, gpointer user_data) { context_vanished_user_data *data= (context_vanished_user_data *)user_data; GHashTableIter iter; gpointer key, value; guint timeout_id; UNITY_WEBAPPS_NOTE (SERVICE, "Watched context (%s) vanished", name); if ((timeout_id = GPOINTER_TO_UINT (g_hash_table_lookup (data->service->lonely_daemons, name))) != 0) { gboolean removed = FALSE; UNITY_WEBAPPS_NOTE (SERVICE, "Lost context (%s) was slated to be killed, removing it's timeout", name); removed = g_source_remove (timeout_id); if (removed == FALSE) { g_warning ("Failed to remove timeout_id (%u) when context vanished (%s)", timeout_id, name); } g_hash_table_remove (data->service->lonely_daemons, name); } g_hash_table_iter_init (&iter, data->service->contexts); while (g_hash_table_iter_next (&iter, &key, &value)) { if (g_strcmp0(value, name) == 0) { UNITY_WEBAPPS_NOTE (SERVICE, "Unregistering context: %s", (gchar *)key); g_hash_table_remove(data->service->contexts, key); unity_webapps_service_emit_context_vanished (connection, name); g_bus_unwatch_name (data->watcher_id); return; } } } static void clear_queue (GHashTable *pending_ready, GError *error) { GHashTableIter iter; gpointer key, value; UNITY_WEBAPPS_NOTE (SERVICE, "Clearing queue of pending invocations (from GetContext)"); g_hash_table_iter_init (&iter, pending_ready); while (g_hash_table_iter_next (&iter, &key, &value)) { GList *invocations, *walk; invocations = (GList *)value; for (walk = invocations; walk != NULL; walk = walk->next) { GDBusMethodInvocation *invocation = (GDBusMethodInvocation *)walk->data; g_assert (invocation != NULL); g_dbus_method_invocation_return_value (invocation, NULL); g_object_unref (G_OBJECT (invocation)); } } g_hash_table_remove_all (pending_ready); } static void register_proxy (UnityWebappsService *service, GDBusConnection *connection, const gchar *sender, const gchar *object) { GDBusMethodInvocation *invocation; GList *invocations, *walk; UnityWebappsGenContext *context_proxy; const gchar *domain; const gchar *name; gchar *id; UNITY_WEBAPPS_NOTE (SERVICE, "Registering context proxy for context at %s", sender); context_proxy = make_context_proxy (connection, sender); domain = unity_webapps_gen_context_get_domain (context_proxy); name = unity_webapps_gen_context_get_name (context_proxy); if ((name == NULL) || (domain == NULL)) { printf("Error getting Name and Domain of proxy\n"); clear_queue (service->pending_ready, NULL); return; } UNITY_WEBAPPS_NOTE(SERVICE, "Found context information for %s, (%s, %s)", sender, name, domain); id = g_strdup_printf("%s%s", name, domain); invocations = (GList *)g_hash_table_lookup(service->pending_ready, id); for (walk = invocations; walk != NULL; walk = walk->next) { invocation = (GDBusMethodInvocation *)walk->data; if (invocation != NULL) { UNITY_WEBAPPS_NOTE (SERVICE, "Found pending invocation for Context Daemon (%s, %s), Context at %s is ready for %s", name, domain, g_dbus_method_invocation_get_sender (invocation), sender); g_dbus_method_invocation_return_value (invocation, g_variant_new("(ss)", sender, UNITY_WEBAPPS_WIRE_PROTOCOL_VERSION)); } } remove_pending_ready (service, id); unity_webapps_service_emit_context_appeared (connection, sender); g_hash_table_insert (service->contexts, id, g_strdup (sender)); g_object_unref (G_OBJECT (context_proxy)); } static void bus_filter_context_ready (GDBusConnection *connection, const gchar *sender, const gchar *object, const gchar *interface, const gchar *signal, GVariant *params, gpointer user_data) { UnityWebappsService *service = (UnityWebappsService *)user_data; context_vanished_user_data *data; const gchar *wire_version; guint watcher_id; if (g_strcmp0(signal, "ContextReady") != 0) { g_warning ("Unexpected signal for webapps service: %s", signal); return; } UNITY_WEBAPPS_NOTE (SERVICE, "Handling ContextReady signal from %s", sender); g_variant_get (params, "(s)", &wire_version, NULL); if (g_strcmp0 (wire_version, UNITY_WEBAPPS_WIRE_PROTOCOL_VERSION) != 0) { // TODO: FIXME: Should we ask for shutdown here? g_critical ("Wire protocol verison mismatch from service version %s to context version %s, ignoring ContextReady signal", UNITY_WEBAPPS_WIRE_PROTOCOL_VERSION, wire_version); return; } data = g_malloc0 (sizeof (context_vanished_user_data)); data->service = service; watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION, sender, G_BUS_NAME_WATCHER_FLAGS_NONE, NULL, context_name_vanished, data /* User data*/, g_free /* User data free*/); data->watcher_id = watcher_id; register_proxy (service, connection, sender, object); } typedef struct _context_lost_interest_user_data { GDBusConnection *connection; gchar *sender; UnityWebappsService *service; } context_lost_interest_user_data; static void context_lost_interest_user_data_free (gpointer p) { context_lost_interest_user_data *data = (context_lost_interest_user_data *)p; // Sender is managed by the hash table. g_free (data->sender); g_object_unref(data->connection); g_free(data); } static gint context_proxy_get_interest_count (UnityWebappsGenContext *context) { gint interest_count; GError *error; error = NULL; unity_webapps_gen_context_call_get_interest_count_sync (context, &interest_count, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Error calling GetInterestCount: %s", error->message); g_error_free (error); interest_count = 0; } return interest_count; } static gboolean kill_lonely_daemon (gpointer user_data) { context_lost_interest_user_data *data; UnityWebappsGenContext *context_proxy; gint interest_count; GError *error; data = (context_lost_interest_user_data *)user_data; error = NULL; context_proxy = make_context_proxy (data->connection, data->sender); UNITY_WEBAPPS_NOTE (SERVICE, "Killing lonely context at: %s", data->sender); if (context_proxy == NULL) { g_hash_table_remove(data->service->lonely_daemons, data->sender); return FALSE; } interest_count = context_proxy_get_interest_count (context_proxy); if (interest_count != 0) { UNITY_WEBAPPS_NOTE (SERVICE, "Lonely context at %s got an interest. Removing Context from kill list", data->sender); g_hash_table_remove(data->service->lonely_daemons, data->sender); return FALSE; } unity_webapps_gen_context_call_shutdown_sync (context_proxy, NULL /* Cancellable */, &error); if (error != NULL) { g_warning ("Failed to call shutdown on lonely daemon (%s), treating it as dead: %s", data->sender, error->message); g_error_free (error); g_object_unref (G_OBJECT (context_proxy)); g_hash_table_remove(data->service->lonely_daemons, data->sender); return FALSE; } g_object_unref (G_OBJECT (context_proxy)); g_hash_table_remove(data->service->lonely_daemons, data->sender); return FALSE; } static void bus_filter_context_lost_interest (GDBusConnection *connection, const gchar *sender, const gchar *object, const gchar *interface, const gchar *signal, GVariant *params, gpointer user_data) { UnityWebappsService *service = (UnityWebappsService *)user_data; context_lost_interest_user_data *data; gpointer existing_data; gboolean user_abandoned; guint timeout_id; UNITY_WEBAPPS_NOTE (SERVICE, "Context (%s) has no interest", sender); existing_data = g_hash_table_lookup (service->lonely_daemons, sender); if (existing_data != NULL) { UNITY_WEBAPPS_NOTE (SERVICE, "Context (%s) was already slated to be killed, pushing back the sentence", sender); timeout_id = GPOINTER_TO_UINT (existing_data); g_source_remove (timeout_id); g_hash_table_remove (service->lonely_daemons, sender); } data = g_malloc0 (sizeof (context_lost_interest_user_data)); data->sender = g_strdup (sender); data->connection = g_object_ref(connection); data->service = service; // perhaps kill the daemon without the 15 second timeout. g_variant_get (params, "(b)", &user_abandoned, NULL); if (user_abandoned) { UNITY_WEBAPPS_NOTE(SERVICE, "User abandoned the lonely daemon"); timeout_id = g_idle_add_full (G_PRIORITY_LOW, kill_lonely_daemon, data, context_lost_interest_user_data_free); } else { timeout_id = g_timeout_add_seconds_full (G_PRIORITY_LOW, 15, kill_lonely_daemon, data, context_lost_interest_user_data_free); } g_hash_table_insert (service->lonely_daemons, g_strdup (data->sender), GUINT_TO_POINTER(timeout_id)); } static gboolean on_handle_get_context (UnityWebappsGenService *service_interface, GDBusMethodInvocation *invocation, const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types, gpointer user_data) { UnityWebappsService *service; const gchar *context; gchar *id; GError *error; service = (UnityWebappsService *)user_data; UNITY_WEBAPPS_NOTE (SERVICE, "Handling GetContext call for (%s, %s", name, domain); id = g_strdup_printf("%s%s", name, domain); context = g_hash_table_lookup (service->contexts, id); if (context != NULL) { UNITY_WEBAPPS_NOTE (SERVICE, "Found existing context for (%s, %s): %s", name, domain, context); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(ss)", context, UNITY_WEBAPPS_WIRE_PROTOCOL_VERSION)); } else { UNITY_WEBAPPS_NOTE (SERVICE, "No existing context for (%s, %s)", name, domain); if (g_hash_table_lookup (service->pending_ready, id) != NULL) { UNITY_WEBAPPS_NOTE (SERVICE, "Found existing pending invocation for Context (%s, %s)", name, domain); add_pending_ready (service, id, invocation); } else { error = NULL; spawn_context_daemon (name, domain, icon_url, mime_types, &error); if (error != NULL) { g_warning("Couldn't spawn context daemon for %s (%s)", name, domain); g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); } else { UNITY_WEBAPPS_NOTE (SERVICE, "Waiting for context (%s, %s) to send ContextReady", name, domain); add_pending_ready (service, id, invocation); } } } g_free (id); return TRUE; } #if 0 static gchar* _firefox_profile_get_name_for_app (const gchar *homepage) { gchar *res = g_base64_encode ((guchar *)homepage, strlen (homepage) + 1); return res; } static GFile* _firefox_webapps_profile_get_location (GFile *profiles, const gchar *id) { GFile *res = NULL; gchar *profiles_path = g_file_get_path (profiles); GDir *dir = g_dir_open (profiles_path, 0, NULL); if (dir) { for (const gchar *name = g_dir_read_name (dir); name; name = g_dir_read_name (dir)) { if (g_str_has_suffix (name, id)) { res = g_file_get_child (profiles, name); if (g_file_query_file_type (res, G_FILE_QUERY_INFO_NONE, NULL) != G_FILE_TYPE_DIRECTORY) { g_object_unref (res); res = NULL; } else { break; } } } g_dir_close (dir); } g_free (profiles_path); return res; } static GFile* _firefox_default_profile_get_location (GFile *dir) { gchar **i; GFile *res = NULL; GFile *profiles_file = g_file_get_child (dir, "profiles.ini"); GKeyFile *profiles = g_key_file_new (); gchar *profiles_file_path = g_file_get_path (profiles_file); if (g_key_file_load_from_file (profiles, profiles_file_path, G_KEY_FILE_NONE, NULL)) { gchar **groups = g_key_file_get_groups (profiles, NULL); for (i = groups; i && *i && !res; i++) { if (g_str_has_prefix (*i, "Profile")) { if (g_key_file_get_integer (profiles, *i, "Default", NULL)) { gchar *path = g_key_file_get_string (profiles, *i, "Path", NULL); if (g_key_file_get_integer (profiles, *i, "IsRelative", NULL)) { res = g_file_get_child (dir, path); } else { res = g_file_new_for_path (path); } g_free (path); if (g_file_query_file_type (res, G_FILE_QUERY_INFO_NONE, NULL) != G_FILE_TYPE_DIRECTORY) { g_object_unref (res); res = NULL; } break; } } } g_strfreev (groups); } g_free (profiles_file_path); g_key_file_unref (profiles); g_object_unref (profiles_file); return res; } static gboolean _firefox_profile_create (const gchar *id, GFile *dir) { gboolean res = FALSE; GFile *default_dir = NULL; gchar *default_extensions_path = NULL; gchar *default_dir_path = NULL; gchar *res_dir_name = NULL, *res_dir_path = NULL; default_dir = _firefox_default_profile_get_location (dir); if (!default_dir) goto out; default_dir_path = g_file_get_path (default_dir); res_dir_name = g_strdup_printf ("%d.%s", g_random_int() % 10000000, id); res_dir_path = g_strdup_printf ("%s/%s", g_file_get_path(dir), res_dir_name); if (g_mkdir (res_dir_path, 0700) != 0) goto out; #define create_link(name, filename) \ gchar *tmp##name = g_strconcat (res_dir_path, filename, NULL); \ GFile *file##name = g_file_new_for_path (tmp##name); \ g_free (tmp##name); \ tmp##name = g_strconcat (default_dir_path, filename, NULL); \ if (!g_file_make_symbolic_link (file##name, tmp##name, NULL, NULL)) \ { \ g_free (tmp##name); g_object_unref (file##name); \ goto out;\ } \ g_free (tmp##name); g_object_unref (file##name); \ create_link (cookies, "/cookies.sqlite"); #ifdef UNITY_WEBAPPS_ENABLE_DEBUG default_extensions_path = g_strdup_printf ("%s/extensions", default_dir_path); if (!g_file_test (default_extensions_path, G_FILE_TEST_IS_DIR)) { if (g_mkdir (res_dir_path, 0700) != 0) goto out; } create_link (extensions, "/extensions"); create_link (extensions_ini, "/extensions.ini"); #endif #undef create_link res = TRUE; out: g_free (default_extensions_path); g_free (res_dir_name); g_free (res_dir_path); g_free (default_dir_path); g_object_unref (default_dir); return res; } static GFile* _firefox_get_profiles_dir (void) { gchar *tmp = g_strdup_printf ("%s/.mozilla/firefox/", g_get_home_dir ()); GFile *res = g_file_new_for_path (tmp); g_free (tmp); return res; } static gchar* _firefox_get_profile_for_app (const gchar *homepage) { gchar *res = NULL; GFile *dir = _firefox_get_profiles_dir (); gchar *id = _firefox_profile_get_name_for_app (homepage); GFile *location = _firefox_webapps_profile_get_location (dir, id); if (location) { res = g_file_get_path (location); } else { if (_firefox_profile_create (id, dir)) { location = _firefox_webapps_profile_get_location (dir, id); res = g_file_get_path (location); } } g_free (id); g_object_unref (dir); g_object_unref (location); return res; } #endif /** * * @return command line format, have to be freed */ static char * get_browser_command_line_format (const gchar *homepage) { static const char * URI_SCHEME_HTTP = "http"; GAppInfo * info = g_app_info_get_default_for_uri_scheme (URI_SCHEME_HTTP); g_return_val_if_fail (NULL != info, NULL); const char * exe_name = g_app_info_get_executable (info); g_return_val_if_fail (NULL != exe_name, NULL); if (g_str_has_suffix (exe_name, "firefox")) { #if 0 gchar *profile_path = _firefox_get_profile_for_app (homepage); if (profile_path) { return g_strdup_printf ("%s --chromeless -no-remote -profile %s '%%s'", exe_name, profile_path); } #endif return g_strdup_printf ("%s --new-window '%%s'", exe_name); } return g_strdup_printf ("%s --new-window --app='%%s'", exe_name); } /** * * @return command line, have to be freed */ static char * format_browser_commandline_for_homepage (const char * const format, const char * const homepage) { return g_strdup_printf (format, homepage); } static gboolean unity_webapps_service_launch_browser_with_homepage (const gchar *homepage) { gchar *commandline_format = NULL; gchar *commandline = NULL; gboolean ret = FALSE; GError *error; commandline_format = get_browser_command_line_format (homepage); if (commandline_format == NULL) { g_critical ("Error could not retrieve the browser command line format"); goto out; } commandline = format_browser_commandline_for_homepage (commandline_format, homepage); if (commandline == NULL) { g_critical ("Error could not retrieve the browser command line"); goto out; } UNITY_WEBAPPS_NOTE (SERVICE, "Invoking Browser (in response to ActivateApplication): %s", commandline); error = NULL; g_spawn_command_line_async (commandline, &error); ret = TRUE; if (error != NULL) { g_critical ("Error invoking browser: %s", error->message); g_error_free (error); ret = FALSE; } out: g_free (commandline); g_free (commandline_format); return ret; } static gboolean run_application (const gchar *name, const gchar *domain) { gchar *homepage; gboolean success; homepage = unity_webapps_app_db_get_homepage (name, domain); if (homepage == NULL) homepage = g_strdup_printf("http://%s", domain); success = unity_webapps_service_launch_browser_with_homepage (homepage); g_free (homepage); return success; } static gboolean on_handle_activate_application (UnityWebappsGenService *service_interface, GDBusMethodInvocation *invocation, const gchar *name, const gchar *domain, const gchar * const *files, gpointer user_data) { GDBusConnection *connection; UnityWebappsService *service; const gchar *context, *lonely_context; gchar *id; service = (UnityWebappsService *)user_data; connection = g_dbus_method_invocation_get_connection (invocation); UNITY_WEBAPPS_NOTE (SERVICE, "Handling ActivateApplication call: (%s, %s)", name, domain); id = g_strdup_printf("%s%s", name, domain); lonely_context = NULL; context = g_hash_table_lookup (service->contexts, id); if (context != NULL) lonely_context = g_hash_table_lookup (service->lonely_daemons, context); // TODO: When we activate a lonely context maybe we should extend its death to give the page time to load. if ((context != NULL) && (lonely_context == NULL)) { UnityWebappsGenContext *context_proxy; GError *error; context_proxy = make_context_proxy (connection, context); error = NULL; unity_webapps_gen_context_call_raise_sync (context_proxy, files, NULL /* Cancellable */, &error); if (error != NULL) { g_warning ("Error calling DoRaise method of proxy (%s): %s", context, error->message); g_error_free (error); } g_object_unref (G_OBJECT (context_proxy)); g_dbus_method_invocation_return_value (invocation, NULL); } else { gchar *id; run_application (name, domain); id = g_strdup_printf("%s%s", name, domain); // add_pending_ready (service, id, invocation); g_dbus_method_invocation_return_value (invocation, NULL); g_free (id); } return TRUE; } static gboolean on_destroy_interest_for_context (UnityWebappsGenService *service_interface, GDBusMethodInvocation *invocation, const gchar *name, const gchar *domain, gint interest_id, gboolean abandoned, gpointer user_data) { UNITY_WEBAPPS_NOTE (SERVICE, "Handling destroy interest call for (%s, %s) - id %d (abandoned %d)" , name, domain , interest_id , abandoned); UnityWebappsService* service = (UnityWebappsService *)user_data; GDBusConnection* connection = g_dbus_method_invocation_get_connection (invocation); gchar * id = g_strdup_printf("%s%s", name, domain); const gchar *context = g_hash_table_lookup (service->contexts, id); if (context != NULL) { UNITY_WEBAPPS_NOTE (SERVICE, "Found existing context for (%s, %s) %s, sending request" , name, domain, context); UnityWebappsGenContext* context_proxy = make_context_proxy (connection, context); // dispatch & fallback on lost-interest event w/ abandoned semantics GError *error = NULL; unity_webapps_gen_context_call_lost_interest_sync (context_proxy, interest_id, abandoned, NULL /* Cancellable */, &error); if (error != NULL) { g_warning ("Error calling LostInterest method of proxy (%s): %s" , context , error->message); g_error_free (error); } g_object_unref (G_OBJECT (context_proxy)); g_dbus_method_invocation_return_value (invocation, NULL); } else { g_warning("Error handling on destroy interest: context not found (%s, %s)" , name, domain); } g_free(id); return TRUE; } static gboolean on_handle_list_contexts (UnityWebappsGenService *service_interface, GDBusMethodInvocation *invocation, gpointer user_data) { GVariant *ret; GVariantBuilder *builder; UnityWebappsService *service; GHashTableIter iter; gpointer key, value; service = (UnityWebappsService *)user_data; builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); g_hash_table_iter_init (&iter, service->contexts); while (g_hash_table_iter_next (&iter, &key, &value)) { g_variant_builder_add_value (builder, g_variant_new_string ((const gchar *)value)); } if (g_hash_table_size (service->contexts) == 0) { g_variant_builder_add_value (builder, g_variant_new_string ("")); } ret = g_variant_builder_end (builder); g_dbus_method_invocation_return_value (invocation, g_variant_new_tuple (&ret, 1)); g_variant_builder_unref (builder); return TRUE; } static gboolean on_handle_open_homepage (UnityWebappsGenService *service, GDBusMethodInvocation *invocation, const gchar *homepage, gpointer user_data) { UNITY_WEBAPPS_NOTE (SERVICE, "Handling OpenHomepage call"); g_dbus_method_invocation_return_value (invocation, NULL); unity_webapps_service_launch_browser_with_homepage (homepage); return TRUE; } static gboolean on_handle_shutdown (UnityWebappsGenService *service, GDBusMethodInvocation *invocation, gpointer user_data) { UNITY_WEBAPPS_NOTE (SERVICE, "Handling Shutdown call"); g_dbus_method_invocation_return_value (invocation, NULL); g_dbus_connection_flush_sync (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL), NULL, NULL); exit(0); return TRUE; } static void export_object (GDBusConnection *connection, UnityWebappsService *service) { UnityWebappsGenService *service_interface; GError *error; service_interface = unity_webapps_gen_service_skeleton_new (); g_signal_connect (service_interface, "handle-get-context", G_CALLBACK (on_handle_get_context), service); g_signal_connect (service_interface, "handle-activate-application", G_CALLBACK (on_handle_activate_application), service); g_signal_connect (service_interface, "handle-open-homepage", G_CALLBACK (on_handle_open_homepage), service); g_signal_connect (service_interface, "handle-list-contexts", G_CALLBACK (on_handle_list_contexts), service); g_signal_connect (service_interface, "handle-shutdown", G_CALLBACK (on_handle_shutdown), service); g_signal_connect (service_interface, "handle-destroy-interest-for-context", G_CALLBACK (on_destroy_interest_for_context), service); error = NULL; g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service_interface), connection, UNITY_WEBAPPS_SERVICE_PATH, &error); if (error != NULL) { g_error ("Error exporting Unity Webapps Service object: %s", error->message); g_error_free (error); return; } UNITY_WEBAPPS_NOTE (SERVICE, "Exported Service interface"); } static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { UnityWebappsService *service; GError *error; service = (UnityWebappsService *)user_data; export_object (connection, service); error = NULL; context_ready_signal_subscription = g_dbus_connection_signal_subscribe (connection, NULL, UNITY_WEBAPPS_CONTEXT_IFACE, "ContextReady", NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE, bus_filter_context_ready, service /* user data*/, NULL /* destroy notify */); context_lost_interest_signal_subscription = g_dbus_connection_signal_subscribe (connection, NULL, UNITY_WEBAPPS_CONTEXT_IFACE, "NoInterest", NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE, bus_filter_context_lost_interest, service /* user data*/, NULL /* destroy notify */); g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_SERVICE_PATH, UNITY_WEBAPPS_SERVICE_IFACE, "ServiceReady", NULL /* Params*/, &error /* Error */); if (error != NULL) { g_error ("Can not emit signal ServiceReady on com.canonical.Unity.Webapps.Service: %s", error->message); g_error_free (error); return; } } static void on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { } static void on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { g_main_loop_quit (mainloop); } static void replace_existing_service () { GDBusConnection *connection; UnityWebappsGenService *service_proxy; GError *error; UNITY_WEBAPPS_NOTE (SERVICE, "Shutting down existing service"); error = NULL; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL /* Cancellable */, &error); if (error != NULL) { g_error ("Error fetching session bus to shut down existing service: %s", error->message); g_error_free (error); return; } service_proxy = unity_webapps_gen_service_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, "com.canonical.Unity.Webapps.Service", "/com/canonical/Unity/Webapps/Service", NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Couldn't create proxy for existing service: %s", error->message); g_error_free (error); return; } unity_webapps_gen_service_call_shutdown_sync (service_proxy, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Failed to call shutdown method for service: %s", error->message); g_error_free (error); } g_object_unref (G_OBJECT (service_proxy)); return; } static gboolean indexer_spawn_callback (gpointer user_data) { unity_webapps_service_spawn_index_updater (); return TRUE; } static gint unity_webapps_service_get_index_updater_timeout () { GSettings *settings; gint time; settings = g_settings_new (UNITY_WEBAPPS_SCHEMA_NAME); time = g_settings_get_int (settings, INDEX_UPDATE_TIME_KEY); g_object_unref (G_OBJECT (settings)); if (time < MINIMUM_UPDATE_TIME) { time = MINIMUM_UPDATE_TIME; } return time; } gint main (gint argc, gchar **argv) { GOptionContext *context; UnityWebappsService *service; GError *error; guint owner_id; g_type_init(); #ifdef UNITY_WEBAPPS_ENABLE_DEBUG unity_webapps_debug_initialize_flags (); #endif context = g_option_context_new ("- Unity Webapps Service Daemon"); g_option_context_add_main_entries (context, option_entries, NULL); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { printf("Failed to parse arguments: %s\n", error->message); g_error_free (error); exit (1); } if (replace_service == TRUE) replace_existing_service (); UNITY_WEBAPPS_NOTE (SERVICE, "Starting Unity Webapps Service"); unity_webapps_service_spawn_index_updater (); service = unity_webapps_service_new (); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, UNITY_WEBAPPS_SERVICE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, on_name_lost, service /* userdata */, NULL /* userdata free*/); g_timeout_add_seconds (unity_webapps_service_get_index_updater_timeout (), indexer_spawn_callback, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); g_bus_unown_name(owner_id); unity_webapps_service_destroy (service); return 0; } libunity-webapps-2.5.0~+14.04.20140409/src/webapps-service/unity-webapps-debug.c0000644000015301777760000000233212321247333027540 0ustar pbusernogroup00000000000000/* * unity-webapps-debug.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "unity-webapps-debug.h" #include guint unity_webapps_debug_flags = 0; void unity_webapps_debug_initialize_flags () { const gchar *flags; flags = g_getenv("UNITY_WEBAPPS_DEBUG_FLAGS"); if ((flags == NULL) || (strlen(flags) == 0)) { return; } unity_webapps_debug_flags |= g_parse_debug_string (flags, unity_webapps_debug_keys, G_N_ELEMENTS (unity_webapps_debug_keys)); } libunity-webapps-2.5.0~+14.04.20140409/src/webapps-service/unity-webapps-service-preinstalled-app.c0000644000015301777760000000700112321247333033352 0ustar pbusernogroup00000000000000/* * unity-webapps-service-preinstalled-app.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-service-preinstalled-app.h" #define AMAZON_DESKTOP_FILE "ubuntu-amazon-default.desktop" #define UBUNTU_ONE_DESKTOP_FILE "UbuntuOneMusiconeubuntucom.desktop" static GHashTable * unity_webapps_service_get_preinstalled_desktop_ids_by_webapp_id () { GDesktopAppInfo *desktop_file; GHashTable *desktop_ids; desktop_ids = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); desktop_file = g_desktop_app_info_new (AMAZON_DESKTOP_FILE); if (desktop_file) { g_hash_table_insert (desktop_ids, "(Amazon, amazon.com)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, www.amazon.com)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, amazon.ca)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, www.amazon.ca)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, amazon.cn)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, www.amazon.cn)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, amazon.co.uk)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, www.amazon.co.uk)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, amazon.fr)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, www.amazon.fr)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, amazon.it)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, www.amazon.it)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, amazon.es)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, www.amazon.es)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, amazon.de)", AMAZON_DESKTOP_FILE); g_hash_table_insert (desktop_ids, "(Amazon, www.amazon.de)", AMAZON_DESKTOP_FILE); g_object_unref (desktop_file); } desktop_file = g_desktop_app_info_new (UBUNTU_ONE_DESKTOP_FILE); if (desktop_file) { g_hash_table_insert (desktop_ids, "(Ubuntu One Music, one.ubuntu.com)", UBUNTU_ONE_DESKTOP_FILE); g_object_unref (desktop_file); } return desktop_ids; } const gchar * unity_webapps_service_get_preinstalled_app_desktop_id (const gchar *name, const gchar *domain) { // Note this is static if refactoring :) static GHashTable *desktop_ids = NULL; gchar *webapp_id, *desktop_id; if (desktop_ids == NULL) { desktop_ids = unity_webapps_service_get_preinstalled_desktop_ids_by_webapp_id (); } webapp_id = g_strdup_printf("(%s, %s)", name, domain); desktop_id = g_hash_table_lookup (desktop_ids, webapp_id); g_free (webapp_id); return desktop_id; } libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-url-db.h0000644000015301777760000000202612321247333024545 0ustar pbusernogroup00000000000000#ifndef __UNITY_WEBAPPS_URL_DB_H #define __UNITY_WEBAPPS_URL_DB_H #include typedef struct _UnityWebappsUrlDB UnityWebappsUrlDB; typedef struct _UnityWebappsUrlDBRecord { gchar *package_name; gchar *application_name; gchar *domain; } UnityWebappsUrlDBRecord; UnityWebappsUrlDB *unity_webapps_url_db_open (gboolean read_only, const gchar *database_path); void unity_webapps_url_db_free (UnityWebappsUrlDB *db); UnityWebappsUrlDB *unity_webapps_url_db_open_default (gboolean read_only); gboolean unity_webapps_url_db_insert_url (UnityWebappsUrlDB *url_db, const gchar *url, UnityWebappsUrlDBRecord *record); gboolean unity_webapps_url_db_lookup_urls (UnityWebappsUrlDB *url_db, const gchar *url, GList **records); UnityWebappsUrlDBRecord *unity_webapps_url_db_record_new (const gchar *package_name, const gchar *application_name, const gchar *application_domain); void unity_webapps_url_db_record_free (UnityWebappsUrlDBRecord *record); void unity_webapps_url_db_record_list_free (GList *record_list); #endif libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-desktop-infos.c0000644000015301777760000000734312321247333026147 0ustar pbusernogroup00000000000000/* * unity-webapps-desktop-infos.h * Copyright (C) Canonical LTD 2013 * * Author: Alexandre Abreu * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include "unity-webapps-desktop-infos.h" #include "unity-webapps-string-utils.h" #include "config.h" static void uwa_makedir_if_necessary (gchar *path) { if (FALSE == g_file_test(path, G_FILE_TEST_EXISTS)) { g_mkdir(path, 0700); } } gchar* unity_webapps_desktop_infos_build_desktop_basename(const gchar* name, const gchar* domain) { #define ADD_CANONICALIZED_STRING_TO_BASENAME(s) \ { \ const gchar *canonicalized_identifier; \ canonicalized_identifier = \ unity_webapps_string_utils_canonicalize_string ((s), FALSE); \ basename = g_string_append(basename, canonicalized_identifier); \ g_free((gpointer) canonicalized_identifier); \ } GString *basename; g_return_val_if_fail(NULL != name, NULL); g_return_val_if_fail(NULL != domain, NULL); basename = g_string_new(""); ADD_CANONICALIZED_STRING_TO_BASENAME(name); ADD_CANONICALIZED_STRING_TO_BASENAME(domain); return g_string_free (basename, FALSE); } void unity_webapps_desktop_infos_generate_desktop_for_url_launch(const gchar* name, const gchar* domain, const gchar* icon_url, const gchar* url) { const gchar *const DESKTOP_FILE_CONTENT_FORMAT = "[Desktop Entry]\n" "Name=%s\n" "Type=Application\n" "Icon=%s\n" "Actions=S0;S1;S2;S3;S4;S5;S6;S7;S8;S9;S10;\n" "Exec=unity-webapps-runner --app-id='%s' --homepage=%s\n" "StartupWMClass=%s\n"; gchar *desktop_id; gchar *app_id; gchar *icon_name; gchar *applications_path; gchar *desktop_filename; gchar *desktop_file_content; GError *error; g_return_val_if_fail(NULL != name, NULL); g_return_val_if_fail(NULL != domain, NULL); g_return_val_if_fail(NULL != url, NULL); app_id = unity_webapps_desktop_infos_build_desktop_basename(name, domain); desktop_id = g_strdup_printf("%s.desktop", app_id); // Strip icon:// if (g_str_has_prefix(icon_url, "icon://")) { icon_name = g_strdup(icon_url + 7); // sizeof(icon://) } else { icon_name = g_strdup(icon_url); } applications_path = g_build_filename(g_get_user_data_dir(), "applications", NULL); uwa_makedir_if_necessary(applications_path); desktop_filename = g_strdup_printf("%s/%s", applications_path, desktop_id); desktop_file_content = g_strdup_printf(DESKTOP_FILE_CONTENT_FORMAT, name, icon_name ? icon_name : "", app_id, url, app_id); error = NULL; g_file_set_contents (desktop_filename, desktop_file_content, -1, &error); if (error != NULL) { g_critical ("Error generating desktop file: %s", error->message); g_error_free (error); } g_free(desktop_filename); g_free(desktop_file_content); g_free(icon_name); g_free(app_id); g_free(desktop_id); g_free(applications_path); } libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-debug.h0000644000015301777760000000711312321247333024450 0ustar pbusernogroup00000000000000/* * unity-webapps-debug.h * Copyright (C) Canonical LTD 2012 * * Author: Robert Carr * * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; * * Derived from seed-debug.h in turn derived from clutter-note.h. */ #ifndef _UNITY_WEBAPPS_DEBUG_H #define _UNITY_WEBAPPS_DEBUG_H // Borrowed from Seed, where this was borrowed from Clutter, more or less. #include typedef enum { UNITY_WEBAPPS_DEBUG_ALL = 1 << 0, UNITY_WEBAPPS_DEBUG_CONTEXT = 1 << 1, UNITY_WEBAPPS_DEBUG_NOTIFICATION = 1 << 2, UNITY_WEBAPPS_DEBUG_INDICATOR = 1 << 3, UNITY_WEBAPPS_DEBUG_MUSIC_PLAYER = 1 << 4, UNITY_WEBAPPS_DEBUG_LAUNCHER = 1 << 5, UNITY_WEBAPPS_DEBUG_INTEREST = 1 << 6, UNITY_WEBAPPS_DEBUG_SERVICE = 1 << 7, UNITY_WEBAPPS_DEBUG_RESOURCE = 1 << 8, UNITY_WEBAPPS_DEBUG_RATE = 1 << 9, UNITY_WEBAPPS_DEBUG_ACTION = 1 << 10, UNITY_WEBAPPS_DEBUG_WINDOW_TRACKER = 1 << 11, UNITY_WEBAPPS_DEBUG_APPLICATION_INFO = 1 << 12, UNITY_WEBAPPS_DEBUG_INDICATOR_MODEL = 1 << 13, UNITY_WEBAPPS_DEBUG_URL_DB = 1 << 14, UNITY_WEBAPPS_DEBUG_APPLICATION_REPOSITORY = 1 << 15, UNITY_WEBAPPS_DEBUG_INDEX_UPDATER = 1 << 16, UNITY_WEBAPPS_DEBUG_MISC = 1 << 17, } UnityWebappsDebugFlag; static const GDebugKey unity_webapps_debug_keys[] = { {"notification", UNITY_WEBAPPS_DEBUG_NOTIFICATION}, {"context", UNITY_WEBAPPS_DEBUG_CONTEXT}, {"indicator", UNITY_WEBAPPS_DEBUG_INDICATOR}, {"music-player", UNITY_WEBAPPS_DEBUG_MUSIC_PLAYER}, {"launcher", UNITY_WEBAPPS_DEBUG_LAUNCHER}, {"interest", UNITY_WEBAPPS_DEBUG_INTEREST}, {"action", UNITY_WEBAPPS_DEBUG_ACTION}, {"service", UNITY_WEBAPPS_DEBUG_SERVICE}, {"resource", UNITY_WEBAPPS_DEBUG_RESOURCE}, {"rate", UNITY_WEBAPPS_DEBUG_RATE}, {"window-tracker", UNITY_WEBAPPS_DEBUG_WINDOW_TRACKER}, {"application-info", UNITY_WEBAPPS_DEBUG_APPLICATION_INFO}, {"url-db", UNITY_WEBAPPS_DEBUG_URL_DB}, {"misc", UNITY_WEBAPPS_DEBUG_MISC}, {"application-repository", UNITY_WEBAPPS_DEBUG_APPLICATION_REPOSITORY}, {"index-updated", UNITY_WEBAPPS_DEBUG_INDEX_UPDATER} }; #ifdef UNITY_WEBAPPS_ENABLE_DEBUG #define UNITY_WEBAPPS_NOTE(type,...) G_STMT_START { \ if ((unity_webapps_debug_flags & UNITY_WEBAPPS_DEBUG_##type) || \ unity_webapps_debug_flags & UNITY_WEBAPPS_DEBUG_ALL) \ { \ gchar * _fmt = g_strdup_printf (__VA_ARGS__); \ g_message ("[" #type "] " G_STRLOC ": %s",_fmt); \ g_free (_fmt); \ } \ } G_STMT_END #define UNITY_WEBAPPS_MARK() UNITY_WEBAPPS_NOTE(MISC, "== mark ==") #define UNITY_WEBAPPS_DBG(x) { a } #else /* !UNITY_WEBAPPS_ENABLE_DEBUG */ #define UNITY_WEBAPPS_NOTE(type,...) #define UNITY_WEBAPPS_MARK() #define UNITY_WEBAPPS_DBG(x) #endif /* UNITY_WEBAPPS_ENABLE_DEBUG */ extern guint unity_webapps_debug_flags; void unity_webapps_debug_initialize_flags (); #endif libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-desktop-infos.h0000644000015301777760000000240712321247333026150 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-desktop-infos.h * Copyright (C) Canonical LTD 2013 * * Author: Alexandre Abreu * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_DESKTOP_INFOS_H #define __UNITY_WEBAPPS_DESKTOP_INFOS_H gchar* unity_webapps_desktop_infos_build_desktop_basename(const gchar* name, const gchar* domain); void unity_webapps_desktop_infos_generate_desktop_for_url_launch(const gchar* name, const gchar* domain, const gchar* icon_url, const gchar* url); #endif libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-string-utils.h0000644000015301777760000000206612321247333026030 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-string-utils.h * Copyright (C) Canonical LTD 2011 * * Author: Alexandre Abreu * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_STRING_UTILS_H #define __UNITY_WEBAPPS_STRING_UTILS_H gchar * unity_webapps_string_utils_canonicalize_string (const gchar *str, gboolean keep_whitespaces); #endif libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-app-db.c0000644000015301777760000002007312321247333024520 0ustar pbusernogroup00000000000000/* * unity-webapps-app-db.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include "context-daemon/util/unity-webapps-dirs.h" #include "unity-webapps-app-db.h" #include "unity-webapps-debug.h" static sqlite3 *app_db = NULL; #define CREATE_RESOURCES_TABLE_SQL "CREATE TABLE IF NOT EXISTS apps(name TEXT, domain TEXT, homepage TEXT, PRIMARY KEY (name, domain));" #define CREATE_ACTIONS_TABLE_SQL "CREATE TABLE IF NOT EXISTS actions(name TEXT, domain TEXT, label TEXT, page TEXT, PRIMARY KEY (name, domain, label));" #define GET_HOMEPAGE_SQL_TEMPLATE "SELECT homepage FROM apps WHERE name=%Q AND domain=%Q;" static sqlite3_stmt * db_get_homepage_prepare_statement (const gchar *name, const gchar *domain) { gchar *statement_sql; sqlite3_stmt *statement; gint rc; statement_sql = sqlite3_mprintf (GET_HOMEPAGE_SQL_TEMPLATE, name, domain); statement = NULL; rc = sqlite3_prepare_v2 (app_db, statement_sql, -1, &statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile App DB get homepage statement: %s", sqlite3_errmsg (app_db)); } sqlite3_free (statement_sql); return statement; } gchar * unity_webapps_app_db_get_homepage (const gchar *name, const gchar *domain) { sqlite3_stmt *homepage_statement; gchar *homepage; gint rc; if (!app_db) { unity_webapps_app_db_open (); } homepage = NULL; homepage_statement = db_get_homepage_prepare_statement (name, domain); if (homepage_statement == NULL) { return NULL; } rc = sqlite3_step (homepage_statement); if (rc == SQLITE_ROW) { homepage = g_strdup ((const gchar *)sqlite3_column_text (homepage_statement, 0)); } UNITY_WEBAPPS_NOTE (MISC, "Looked up homepage for (%s, %s) got %s", name, domain, homepage); sqlite3_finalize (homepage_statement); return homepage; } #define INSERT_HOMEPAGE_SQL_TEMPLATE "INSERT OR REPLACE INTO apps (name, domain, homepage) VALUES (%Q, %Q, %Q);" static sqlite3_stmt * db_insert_homepage_prepare_statement (const gchar *name, const gchar *domain, const gchar *homepage) { gchar *statement_sql; sqlite3_stmt *statement; gint rc; statement_sql = sqlite3_mprintf (INSERT_HOMEPAGE_SQL_TEMPLATE, name, domain, homepage); statement = NULL; rc = sqlite3_prepare_v2 (app_db, statement_sql, -1, &statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile App DB insert homepage statement: %s", sqlite3_errmsg (app_db)); } sqlite3_free (statement_sql); return statement; } gboolean unity_webapps_app_db_update_homepage (const gchar *name, const gchar *domain, const gchar *homepage) { sqlite3_stmt *homepage_statement; int rc; gboolean ret = TRUE; if (!app_db) { unity_webapps_app_db_open (); } homepage_statement = db_insert_homepage_prepare_statement (name, domain, homepage); if (homepage_statement == NULL) { return FALSE; } rc = sqlite3_step (homepage_statement); if (rc != SQLITE_DONE) { g_warning ("Error updating homepage in app db: %s", sqlite3_errmsg (app_db)); ret = FALSE; goto out; } out: sqlite3_finalize (homepage_statement); return ret; } static void create_apps_table (const gchar *query) { int rc; gchar *error_message; error_message = NULL; rc = sqlite3_exec (app_db, query, NULL, 0, &error_message); if (rc != SQLITE_OK) { g_critical ("Error creating apps table %s \n", error_message); sqlite3_free (error_message); sqlite3_close (app_db); app_db = NULL; } } gboolean unity_webapps_app_db_open () { const gchar *uw_dir; gchar *database_file; gboolean ret; int rc; ret = TRUE; uw_dir = unity_webapps_dirs_get_user_dir (); database_file = g_build_filename (uw_dir, "apps2.db", NULL); UNITY_WEBAPPS_NOTE (RESOURCE, "Opening App DB (%s)", database_file); rc = sqlite3_open (database_file, &app_db); if (rc != 0) { g_critical ("Failed to open apps database: %s", sqlite3_errmsg(app_db)); sqlite3_close (app_db); ret = FALSE; goto out; } create_apps_table (CREATE_RESOURCES_TABLE_SQL); create_apps_table (CREATE_ACTIONS_TABLE_SQL); out: g_free (database_file); return ret; } #define INSERT_ACTION_SQL_TEMPLATE "INSERT OR REPLACE INTO actions (name, domain, label, page) VALUES (%Q, %Q, %Q, %Q);" gboolean unity_webapps_app_db_add_action (const gchar *name, const gchar *domain, const gchar *label, const gchar *page) { sqlite3_stmt *statement; char *statement_sql; gint rc; gboolean res = TRUE; if (!app_db) { unity_webapps_app_db_open (); } statement_sql = sqlite3_mprintf (INSERT_ACTION_SQL_TEMPLATE, name, domain, label, page); rc = sqlite3_prepare_v2 (app_db, statement_sql, -1, &statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile Action DB statement: %s", sqlite3_errmsg (app_db)); sqlite3_free (statement_sql); return FALSE; } sqlite3_free (statement_sql); rc = sqlite3_step (statement); if (rc != SQLITE_DONE) { g_warning ("Error inserting action: %s", sqlite3_errmsg (app_db)); res = FALSE; } sqlite3_finalize (statement); return res; } #define DELETE_ALL_ACTIONS_SQL "DELETE FROM actions WHERE name=%Q AND domain=%Q" gboolean unity_webapps_app_db_clear_actions (const gchar *name, const gchar *domain) { sqlite3_stmt *statement; char *statement_sql; gint rc; gboolean res = TRUE; if (!app_db) { unity_webapps_app_db_open (); } statement_sql = sqlite3_mprintf (DELETE_ALL_ACTIONS_SQL, name, domain); rc = sqlite3_prepare_v2 (app_db, statement_sql, -1, &statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile Action DB statement: %s", sqlite3_errmsg (app_db)); sqlite3_free (statement_sql); return FALSE; } sqlite3_free (statement_sql); rc = sqlite3_step (statement); if (rc != SQLITE_DONE) { g_warning ("Error deleting actions: %s", sqlite3_errmsg (app_db)); res = FALSE; } sqlite3_finalize (statement); return res; } #define MAX_ACTIONS_COUNT 10 #define SELECT_ALL_ACTIONS_SQL "SELECT label, page FROM actions WHERE name=%Q AND domain=%Q" gboolean unity_webapps_app_db_get_actions (const gchar *name, const gchar *domain, gchar ***labels, gchar ***pages) { sqlite3_stmt *statement; char *statement_sql; gint rc, i; gboolean res = TRUE; *labels = NULL; *pages = NULL; if (!app_db) { unity_webapps_app_db_open (); } statement_sql = sqlite3_mprintf (SELECT_ALL_ACTIONS_SQL, name, domain); rc = sqlite3_prepare_v2 (app_db, statement_sql, -1, &statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile Action DB statement: %s", sqlite3_errmsg (app_db)); sqlite3_free (statement_sql); return FALSE; } sqlite3_free (statement_sql); *labels = g_new (gchar*, MAX_ACTIONS_COUNT + 1); *pages = g_new (gchar*, MAX_ACTIONS_COUNT + 1); for (i = 0, rc = sqlite3_step (statement); i < MAX_ACTIONS_COUNT && rc == SQLITE_ROW; i++, rc = sqlite3_step (statement)) { (*labels)[i] = g_strdup ((const gchar *)sqlite3_column_text (statement, 0)); (*pages)[i] = g_strdup ((const gchar *)sqlite3_column_text (statement, 1)); } (*labels)[i] = NULL; (*pages)[i] = NULL; sqlite3_finalize (statement); return res; } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/0000755000015301777760000000000012321250157026113 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-dpkg-available-application.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-dpkg-available-0000644000015301777760000002505712321247333033576 0ustar pbusernogroup00000000000000/* * unity-webapps-dpkg-available-application.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-dpkg-available-application.h" #include "../unity-webapps-debug.h" struct _UnityWebappsDpkgAvailableApplicationPrivate { UnityWebappsPackageMechanism *package_mechanism; gchar *name; gchar *application_name; gchar *application_domain; }; enum { PROP_0, PROP_NAME, PROP_APPLICATION_NAME, PROP_APPLICATION_DOMAIN, PROP_PACKAGE_MECHANISM }; G_DEFINE_TYPE(UnityWebappsDpkgAvailableApplication, unity_webapps_dpkg_available_application, UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION) #define UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_DPKG_AVAILABLE_APPLICATION, UnityWebappsDpkgAvailableApplicationPrivate)) static void unity_webapps_dpkg_available_application_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsDpkgAvailableApplication *app; app = UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION (object); switch (prop_id) { case PROP_NAME: g_value_set_string (value, app->priv->name); break; case PROP_APPLICATION_DOMAIN: g_value_set_string (value, app->priv->application_domain); break; case PROP_APPLICATION_NAME: g_value_set_string (value, app->priv->application_name); break; case PROP_PACKAGE_MECHANISM: g_value_set_object (value, app->priv->package_mechanism); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_dpkg_available_application_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsDpkgAvailableApplication *app; app = UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION (object); switch (prop_id) { case PROP_NAME: g_return_if_fail (app->priv->name == NULL); app->priv->name = g_value_dup_string (value); break; case PROP_APPLICATION_NAME: g_return_if_fail (app->priv->application_name == NULL); app->priv->application_name = g_value_dup_string (value); break; case PROP_APPLICATION_DOMAIN: g_return_if_fail (app->priv->application_domain == NULL); app->priv->application_domain = g_value_dup_string (value); break; case PROP_PACKAGE_MECHANISM: g_return_if_fail (app->priv->package_mechanism == NULL); app->priv->package_mechanism = (UnityWebappsPackageMechanism *)g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } typedef struct _dpkg_install_query_data { UnityWebappsAvailableApplication *application; UnityWebappsAvailableApplicationInstalledQueryCallback callback; gpointer user_data; } dpkg_install_query_data; static void dpkg_available_application_package_status_ready (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageStatus status, gpointer user_data) { dpkg_install_query_data *data; gboolean installed; data = (dpkg_install_query_data *)user_data; installed = FALSE; if (status == UNITY_WEBAPPS_PACKAGE_STATUS_INSTALLED) { installed = TRUE; } data->callback (data->application, installed, data->user_data); g_free (data); } static void dpkg_available_application_get_is_installed (UnityWebappsAvailableApplication *available_application, UnityWebappsAvailableApplicationInstalledQueryCallback callback, gpointer user_data) { UnityWebappsDpkgAvailableApplication *self; dpkg_install_query_data *query_data; self = UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION (available_application); query_data = g_malloc0 (sizeof(dpkg_install_query_data)); query_data->application = available_application; query_data->callback = callback; query_data->user_data = user_data; unity_webapps_package_mechanism_get_package_status (self->priv->package_mechanism, self->priv->name, dpkg_available_application_package_status_ready, query_data); } static const gchar * dpkg_available_application_get_name (UnityWebappsAvailableApplication *available_application) { UnityWebappsDpkgAvailableApplication *self; self = UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION (available_application); return self->priv->name; } static const gchar * dpkg_available_application_get_application_name (UnityWebappsAvailableApplication *available_application) { UnityWebappsDpkgAvailableApplication *self; self = UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION (available_application); return self->priv->application_name; } static const gchar * dpkg_available_application_get_application_domain (UnityWebappsAvailableApplication *available_application) { UnityWebappsDpkgAvailableApplication *self; self = UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION (available_application); return self->priv->application_domain; } static void unity_webapps_dpkg_available_application_finalize (GObject *object) { UnityWebappsDpkgAvailableApplication *self; self = UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION (object); if (self->priv->name) { g_free (self->priv->name); } if (self->priv->application_name) { g_free (self->priv->application_name); } if (self->priv->application_domain) { g_free (self->priv->application_domain); } g_object_unref (G_OBJECT (self->priv->package_mechanism)); } static void unity_webapps_dpkg_available_application_class_init (UnityWebappsDpkgAvailableApplicationClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsAvailableApplicationClass *available_application_class = UNITY_WEBAPPS_AVAILABLE_APPLICATION_CLASS (klass); object_class->finalize = unity_webapps_dpkg_available_application_finalize; object_class->get_property = unity_webapps_dpkg_available_application_get_property; object_class->set_property = unity_webapps_dpkg_available_application_set_property; available_application_class->get_name = dpkg_available_application_get_name; available_application_class->get_application_name = dpkg_available_application_get_application_name; available_application_class->get_application_domain = dpkg_available_application_get_application_domain; available_application_class->get_is_installed = dpkg_available_application_get_is_installed; g_object_class_install_property (object_class, PROP_NAME, g_param_spec_string ("name", "Name", "The Package Name", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_APPLICATION_NAME, g_param_spec_string ("application-name", "Application Name", "The Application Name", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_APPLICATION_DOMAIN, g_param_spec_string ("application-domain", "Application Domain", "The Application Domain", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_PACKAGE_MECHANISM, g_param_spec_object ("package-mechanism", "Package Mechanism", "Mechanism to use for external packaging actions", UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_type_class_add_private (object_class, sizeof(UnityWebappsDpkgAvailableApplicationPrivate)); } static void unity_webapps_dpkg_available_application_init (UnityWebappsDpkgAvailableApplication *self) { self->priv = UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION_GET_PRIVATE (self); self->priv->name = NULL; self->priv->package_mechanism = NULL; } UnityWebappsAvailableApplication * unity_webapps_dpkg_available_application_new (const gchar *name, const gchar *application_name, const gchar *application_domain, UnityWebappsPackageMechanism *package_mechanism) { return UNITY_WEBAPPS_AVAILABLE_APPLICATION (g_object_new (UNITY_WEBAPPS_TYPE_DPKG_AVAILABLE_APPLICATION, "name", name, "application-name", application_name, "application-domain", application_domain, "package-mechanism", package_mechanism, NULL)); } typedef struct _webapp_dpkg_install_data { UnityWebappsDpkgAvailableApplication *application; UnityWebappsAvailableApplicationInstalledQueryCallback callback; gpointer user_data; } webapp_dpkg_install_data; static void dpkg_available_application_installed (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageStatus status, gpointer user_data) { webapp_dpkg_install_data *data; gboolean installed; data = (webapp_dpkg_install_data *)user_data; installed = FALSE; if (status == UNITY_WEBAPPS_PACKAGE_STATUS_INSTALLED) { installed = TRUE; } data->callback ((UnityWebappsAvailableApplication *)data->application, installed, data->user_data); g_free (data); } gboolean unity_webapps_dpkg_available_application_install (UnityWebappsDpkgAvailableApplication *application, UnityWebappsAvailableApplicationInstalledQueryCallback callback, gpointer user_data) { webapp_dpkg_install_data *data; data = g_malloc0 (sizeof (webapp_dpkg_install_data)); data->application = application; data->callback = callback; data->user_data = user_data; unity_webapps_package_mechanism_install_package (application->priv->package_mechanism, application->priv->name, dpkg_available_application_installed, data); return TRUE; } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-apt-package-mechanism.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-apt-package-mec0000644000015301777760000001751212321247333033572 0ustar pbusernogroup00000000000000/* * unity-webapps-apt-package-mechanism.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-apt-package-mechanism.h" #include "unity-webapps-package-mechanism.h" #define I_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE #include #include "../unity-webapps-debug.h" struct _UnityWebappsAptPackageMechanismPrivate { PkClient *pk_client; }; G_DEFINE_TYPE(UnityWebappsAptPackageMechanism, unity_webapps_apt_package_mechanism, UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM) #define UNITY_WEBAPPS_APT_PACKAGE_MECHANISM_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_APT_PACKAGE_MECHANISM, UnityWebappsAptPackageMechanismPrivate)) static void unity_webapps_apt_package_mechanism_finalize (GObject *object) { UnityWebappsAptPackageMechanism *self; self = UNITY_WEBAPPS_APT_PACKAGE_MECHANISM (object); g_object_unref (G_OBJECT (self->priv->pk_client)); } typedef struct _apt_package_mechanism_status_data { UnityWebappsAptPackageMechanism *mechanism; gchar *name; UnityWebappsPackageMechanismStatusCallback callback; gpointer user_data; gboolean install; } apt_package_mechanism_status_data; static void apt_package_mechanism_package_installed (GObject *object, GAsyncResult *res, gpointer user_data) { apt_package_mechanism_status_data *data; PkResults *results; GError *error; UnityWebappsPackageStatus status; data = (apt_package_mechanism_status_data *) user_data; status = UNITY_WEBAPPS_PACKAGE_STATUS_INSTALLED; error = NULL; results = pk_client_generic_finish (PK_CLIENT (object), res, &error); if (error != NULL) { status = UNITY_WEBAPPS_PACKAGE_STATUS_AVAILABLE; g_warning ("Error installing package: %s", error->message); g_error_free (error); goto out; } out: data->callback ((UnityWebappsPackageMechanism *)data->mechanism, data->name, status, data->user_data); g_free (data->name); g_free (data); if (results != NULL) { g_object_unref (G_OBJECT (results)); } } static void unity_webapps_apt_package_mechanism_install_pkpackage (apt_package_mechanism_status_data *data, PkPackage *package) { gchar *package_ids[] = {NULL, NULL}; package_ids[0] = (gchar *)pk_package_get_id (package); pk_client_install_packages_async (data->mechanism->priv->pk_client, FALSE, package_ids, NULL, NULL, NULL, apt_package_mechanism_package_installed, data); } static void apt_package_mechanism_status_resolved (GObject *object, GAsyncResult *res, gpointer user_data) { PkResults *results; apt_package_mechanism_status_data *data; GPtrArray *packages; PkPackage *first_package; GError *error; UnityWebappsPackageStatus status; PkInfoEnum pk_status; status = UNITY_WEBAPPS_PACKAGE_STATUS_UNAVAILABLE; data = (apt_package_mechanism_status_data *)user_data; results = NULL; error = NULL; results = pk_client_generic_finish (PK_CLIENT(object), res, &error); if (error != NULL) { g_warning ("Error resolving package name\n"); g_error_free (error); goto out; } if (!results) { g_warning ("Error resolving package name (%s): empty results but no error\n", data->name); goto out; } packages = pk_results_get_package_array (results); if (!packages || packages->len == 0) { g_warning("Error resolving package name (%s): empty results\n", data->name); goto out; } // only consider the first package first_package = (PkPackage *)g_ptr_array_index (packages, 0); if (first_package == NULL) { g_warning ("No package: %s\n", data->name); goto out; } pk_status = pk_package_get_info (first_package); if (pk_status & PK_INFO_ENUM_AVAILABLE) { status = UNITY_WEBAPPS_PACKAGE_STATUS_AVAILABLE; } else if (pk_status & PK_INFO_ENUM_INSTALLED) { status = UNITY_WEBAPPS_PACKAGE_STATUS_INSTALLED; } if (data->install && status == UNITY_WEBAPPS_PACKAGE_STATUS_AVAILABLE) { unity_webapps_apt_package_mechanism_install_pkpackage (data, first_package); } out: if (data->install == FALSE && status == UNITY_WEBAPPS_PACKAGE_STATUS_AVAILABLE) { data->callback ((UnityWebappsPackageMechanism *)data->mechanism, data->name, status, data->user_data); g_free (data->name); g_free (data); } if (results != NULL) { g_object_unref (G_OBJECT (results)); } } static gboolean unity_webapps_apt_package_mechanism_common_resolve (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data, gboolean install) { UnityWebappsAptPackageMechanism *apt_mechanism; apt_package_mechanism_status_data *data; const gchar *packages[] = {NULL, NULL}; apt_mechanism = (UnityWebappsAptPackageMechanism *)mechanism; data = g_malloc0 (sizeof (apt_package_mechanism_status_data)); data->mechanism = apt_mechanism; data->name = g_strdup (name); data->callback = callback; data->user_data = user_data; data->install = install; packages[0] = name; pk_client_resolve_async (apt_mechanism->priv->pk_client, pk_bitfield_from_enums (PK_FILTER_ENUM_NEWEST, -1), (gchar **)packages, NULL, NULL, NULL, apt_package_mechanism_status_resolved, data); return TRUE; } static gboolean unity_webapps_apt_package_mechanism_get_package_status (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data) { return unity_webapps_apt_package_mechanism_common_resolve (mechanism, name, callback, user_data, FALSE); } static gboolean unity_webapps_apt_package_mechanism_install_package (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data) { return unity_webapps_apt_package_mechanism_common_resolve (mechanism, name, callback, user_data, TRUE); } static void unity_webapps_apt_package_mechanism_class_init (UnityWebappsAptPackageMechanismClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsPackageMechanismClass *mechanism_class = UNITY_WEBAPPS_PACKAGE_MECHANISM_CLASS (klass); object_class->finalize = unity_webapps_apt_package_mechanism_finalize; mechanism_class->get_package_status = unity_webapps_apt_package_mechanism_get_package_status; mechanism_class->install_package = unity_webapps_apt_package_mechanism_install_package; g_type_class_add_private (object_class, sizeof(UnityWebappsAptPackageMechanismPrivate)); } static void unity_webapps_apt_package_mechanism_init (UnityWebappsAptPackageMechanism *self) { self->priv = UNITY_WEBAPPS_APT_PACKAGE_MECHANISM_GET_PRIVATE (self); self->priv->pk_client = pk_client_new (); } UnityWebappsPackageMechanism * unity_webapps_apt_package_mechanism_new () { return UNITY_WEBAPPS_PACKAGE_MECHANISM (g_object_new (UNITY_WEBAPPS_TYPE_APT_PACKAGE_MECHANISM, NULL)); } ././@LongLink0000000000000000000000000000016300000000000011215 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-local-available-application.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-local-available0000644000015301777760000000612112321247333033655 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-local-available-application.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION_H #define __UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION_H #define UNITY_WEBAPPS_TYPE_LOCAL_AVAILABLE_APPLICATION (unity_webapps_local_available_application_get_type()) #define UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_LOCAL_AVAILABLE_APPLICATION, UnityWebappsLocalAvailableApplication)) #define UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_LOCAL_AVAILABLE_APPLICATION, UnityWebappsLocalAvailableApplicationClass)) #define UNITY_WEBAPPS_IS_LOCAL_AVAILABLE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_LOCAL_AVAILABLE_APPLICATION)) #define UNITY_WEBAPPS_IS_LOCAL_AVAILABLE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_LOCAL_AVAILABLE_APPLICATION)) #define UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_LOCALx_AVAILABLE_APPLICATION, UnityWebappsLocalAvailableApplicationClass)) #include "unity-webapps-available-application.h" #include "unity-webapps-application-manifest.h" typedef struct _UnityWebappsLocalAvailableApplicationPrivate UnityWebappsLocalAvailableApplicationPrivate; typedef struct _UnityWebappsLocalAvailableApplication UnityWebappsLocalAvailableApplication; struct _UnityWebappsLocalAvailableApplication { UnityWebappsAvailableApplication app; UnityWebappsLocalAvailableApplicationPrivate *priv; }; typedef struct _UnityWebappsLocalAvailableApplicationClass UnityWebappsLocalAvailableApplicationClass; struct _UnityWebappsLocalAvailableApplicationClass { UnityWebappsAvailableApplicationClass parent_class; }; GType unity_webapps_local_available_application_get_type (void) G_GNUC_CONST; UnityWebappsAvailableApplication *unity_webapps_local_available_application_new (UnityWebappsApplicationManifest *manifest); UnityWebappsApplicationManifest *unity_webapps_local_available_application_get_manifest (UnityWebappsLocalAvailableApplication *app); gboolean unity_webapps_local_available_application_provides_url (UnityWebappsLocalAvailableApplication *application, const gchar *url); #endif ././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-dpkg-available-application.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-dpkg-available-0000644000015301777760000000622412321247333033571 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-dpkg-available-application.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION_H #define __UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION_H #define UNITY_WEBAPPS_TYPE_DPKG_AVAILABLE_APPLICATION (unity_webapps_dpkg_available_application_get_type()) #define UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_DPKG_AVAILABLE_APPLICATION, UnityWebappsDpkgAvailableApplication)) #define UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_DPKG_AVAILABLE_APPLICATION, UnityWebappsDpkgAvailableApplicationClass)) #define UNITY_WEBAPPS_IS_DPKG_AVAILABLE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_DPKG_AVAILABLE_APPLICATION)) #define UNITY_WEBAPPS_IS_DPKG_AVAILABLE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_DPKG_AVAILABLE_APPLICATION)) #define UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_DPKG_AVAILABLE_APPLICATION, UnityWebappsDpkgAvailableApplicationClass)) #include "unity-webapps-available-application.h" #include "unity-webapps-package-mechanism.h" typedef struct _UnityWebappsDpkgAvailableApplicationPrivate UnityWebappsDpkgAvailableApplicationPrivate; typedef struct _UnityWebappsDpkgAvailableApplication UnityWebappsDpkgAvailableApplication; struct _UnityWebappsDpkgAvailableApplication { UnityWebappsAvailableApplication app; UnityWebappsDpkgAvailableApplicationPrivate *priv; }; typedef struct _UnityWebappsDpkgAvailableApplicationClass UnityWebappsDpkgAvailableApplicationClass; struct _UnityWebappsDpkgAvailableApplicationClass { UnityWebappsAvailableApplicationClass parent_class; }; GType unity_webapps_dpkg_available_application_get_type (void) G_GNUC_CONST; UnityWebappsAvailableApplication *unity_webapps_dpkg_available_application_new (const gchar *name, const gchar *application_name, const gchar *application_domain, UnityWebappsPackageMechanism *package_mechanism); gboolean unity_webapps_dpkg_available_application_install (UnityWebappsDpkgAvailableApplication *application, UnityWebappsAvailableApplicationInstalledQueryCallback callback, gpointer user_data); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/Makefile.am0000644000015301777760000001022412321247333030150 0ustar pbusernogroup00000000000000## Process this file with automake to produce Makefile.in ## Created by Anjuta EXTRA_DIST = BUILT_SOURCES = CLEANFILES = AM_CPPFLAGS = \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ $(UNITY_WEBAPPS_DEBUG_CFLAGS) \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/context-daemon/util AM_CFLAGS =\ -Wall\ -g lib_LTLIBRARIES = libunity-webapps-repository.la libunity_webapps_repositoryincludedir = $(includedir)/libunity-webapps-repository libunity_webapps_repositoryinclude_HEADERS = \ unity-webapps-url-index.h \ unity-webapps-script-loader.h \ unity-webapps-dpkg-url-index.h \ unity-webapps-available-application.h \ unity-webapps-local-available-application.h \ unity-webapps-dpkg-available-application.h \ unity-webapps-application-repository.h libunity_webapps_repository_la_SOURCES = \ unity-webapps-url-index.c \ unity-webapps-script-loader.c \ unity-webapps-dpkg-url-index.c \ unity-webapps-available-application.c \ unity-webapps-dpkg-available-application.c \ unity-webapps-application-repository.c \ unity-webapps-application-repository.h \ unity-webapps-application-manifest.c \ unity-webapps-application-manifest.h \ unity-webapps-application-collector.c \ unity-webapps-application-collector.h \ unity-webapps-local-available-application.c \ unity-webapps-local-url-index.c \ unity-webapps-local-url-index.h \ unity-webapps-policy-authorizer.c \ unity-webapps-policy-authorizer.h \ unity-webapps-package-mechanism.c \ unity-webapps-package-mechanism.h \ unity-webapps-apt-package-mechanism.c \ unity-webapps-apt-package-mechanism.h \ ../libunity-webapps/unity-webapps-debug.c \ ../unity-webapps-url-db.c \ ../context-daemon/util/unity-webapps-dirs.c \ ../unity-webapps-string-utils.c \ ../unity-webapps-string-utils.h \ ../unity-webapps-desktop-infos.c \ ../unity-webapps-desktop-infos.h libunity_webapps_repository_la_LDFLAGS = $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) libunity_webapps_repository_la_LIBADD = $(UNITY_WEBAPPS_LIBS) $(UNITY_WEBAPPS_DAEMON_LIBS) -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = INTROSPECTION_SCANNER_ARGS = \ --add-include-path=$(top_srcdir)/src \ $(addprefix --c-include=src/, $(libunity_webapps_repositoryinclude_HEADERS)) \ --symbol-prefix=unity_webapps \ --identifier-prefix=UnityWebapps INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_srcdir)/src if HAVE_INTROSPECTION UnityWebappsRepository-0.2.gir: libunity-webapps-repository.la UnityWebapps_0_2_gir_INCLUDES = \ GObject-2.0 \ Gio-2.0 \ GLib-2.0 # not sure why this isn't getting picked up from the INCLUDES INTROSPECTION_SCANNER_ARGS += \ --include=GObject-2.0 \ --include=Gio-2.0 \ --include=GLib-2.0 UnityWebappsRepository_0_2_gir_CFLAGS = $(UNITY_WEBAPPS_CFLAGS) -I$(top_srcdir)/src UnityWebappsRepository_0_2_gir_LIBS = libunity-webapps-repository.la UnityWebappsRepository_0_2_gir_FILES = $(libunity_webapps_repository_la_SOURCES) UnityWebappsRepository_0_2_gir_NAMESPACE = UnityWebappsRepository UnityWebappsRepository_0_2_gir_VERSION = 0.2 UnityWebappsRepository_0_2_gir_EXPORT_PACKAGES = unity-webapps-repository-0.2 UnityWebappsRepository_0_2_gir_SCANNER_FLAGS = $(INTROSPECTION_SCANNER_ARGS) INTROSPECTION_GIRS += UnityWebappsRepository-0.2.gir girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) CLEANFILES += $(gir_DATA) $(typelib_DATA) endif include_HEADERS = pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libunity-webapps-repository.pc EXTRA_DIST += \ libunity-webapps-repository.pc.in noinst_PROGRAMS = \ ubuntu-webapps-repository-tool \ local-test ubuntu_webapps_repository_tool_SOURCES = \ main.c local_test_SOURCES = \ local-test.c local_test_LDADD = \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ libunity-webapps-repository.la ubuntu_webapps_repository_tool_LDADD = \ $(UNITY_WEBAPPS_LIBS) \ $(UNITY_WEBAPPS_DAEMON_LIBS) \ $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) \ libunity-webapps-repository.la libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-script-loader.c0000644000015301777760000001740012321247333033640 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-script-loader.c * Copyright (C) Canonical LTD 2012 * * Author: Alex Launi * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-application-manifest.h" #include "unity-webapps-script-loader.h" #include "../context-daemon/util/unity-webapps-dirs.h" struct _UnityWebappsScriptLoaderPrivate { GHashTable *found_requires_by_name; }; G_DEFINE_TYPE (UnityWebappsScriptLoader, unity_webapps_script_loader, G_TYPE_OBJECT); #define UNITY_WEBAPPS_SCRIPT_LOADER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_SCRIPT_LOADER, UnityWebappsScriptLoaderPrivate)) static void unity_webapps_script_loader_finalize (GObject *object) { UnityWebappsScriptLoader *loader; loader = (UnityWebappsScriptLoader *)object; g_hash_table_destroy (loader->priv->found_requires_by_name); } static void unity_webapps_script_loader_class_init (UnityWebappsScriptLoaderClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_script_loader_finalize; g_type_class_add_private (object_class, sizeof (UnityWebappsScriptLoaderPrivate)); } static gchar * unity_webapps_script_loader_find_require_path_in_data_dir (UnityWebappsScriptLoader *loader, const gchar *data_dir, const gchar *require) { gchar *require_file; gboolean exists; require_file = g_build_filename (data_dir, "unity-webapps/userscripts/common", require, NULL); exists = g_file_test (require_file, G_FILE_TEST_EXISTS); if (exists) { return require_file; } else { g_free (require_file); } return NULL; } static const gchar * unity_webapps_script_loader_find_require_path (UnityWebappsScriptLoader *loader, const gchar *require) { const gchar * const *system_dirs; const gchar *user_dir; gchar *require_path; gint i, len; require_path = g_hash_table_lookup (loader->priv->found_requires_by_name, require); if (require_path != NULL) { return require_path; } user_dir = unity_webapps_dirs_get_user_dir (); require_path = unity_webapps_script_loader_find_require_path_in_data_dir (loader, user_dir, require); if (require_path != NULL) { g_hash_table_insert (loader->priv->found_requires_by_name, g_strdup (require), require_path); return require_path; } system_dirs = g_get_system_data_dirs (); len = g_strv_length ((gchar **)system_dirs); for (i = 0; i < len; i++) { const gchar *system_data_dir; system_data_dir = system_dirs[i]; require_path = unity_webapps_script_loader_find_require_path_in_data_dir (loader, system_data_dir, require); if (require_path != NULL) { g_hash_table_insert (loader->priv->found_requires_by_name, g_strdup (require), require_path); return require_path; } } return NULL; } static gchar * unity_webapps_script_loader_get_require_contents (UnityWebappsScriptLoader *self, const gchar *require) { const gchar *require_path; gchar *contents; GError *error; require_path = unity_webapps_script_loader_find_require_path (self, require); if (require_path == NULL) { return NULL; } error = NULL; g_file_get_contents (require_path, &contents, NULL, &error); if (error != NULL) { g_warning ("Failed to load required script file: %s \n", error->message); g_error_free (error); return NULL; } return contents; } static gchar * unity_webapps_script_loader_get_combined_requirements (UnityWebappsScriptLoader *self, UnityWebappsApplicationManifest *manifest) { GString *combined_requirements; const gchar **require_files; gchar *ret; gint i, len; require_files = unity_webapps_application_manifest_get_requires (manifest); if (require_files == NULL) { return NULL; } combined_requirements = g_string_new (""); len = g_strv_length ((gchar **)require_files); for (i = 0; i < len; i++) { const gchar *require_file; gchar *contents; require_file = require_files[i]; contents = unity_webapps_script_loader_get_require_contents (self, require_file); if (contents == NULL) { g_string_free (combined_requirements, TRUE); return NULL; } g_string_append_printf (combined_requirements, "\n// imported script: %s\n", require_file); combined_requirements = g_string_append (combined_requirements, contents); g_free (contents); } ret = combined_requirements->str; g_string_free (combined_requirements, FALSE); return ret; } static gchar * unity_webapps_script_loader_get_userscript_content (UnityWebappsScriptLoader *loader, UnityWebappsApplicationManifest *manifest, const gchar *script) { const gchar *base_path; gchar *userscript_path, *contents; GError *error; base_path = unity_webapps_application_manifest_get_base_path (manifest); userscript_path = g_build_filename (base_path, script, NULL); error = NULL; contents = NULL; g_file_get_contents (userscript_path, &contents, NULL, &error); if (error != NULL) { g_warning ("Failed to load userscript contents: %s \n", error->message); g_error_free (error); } g_free (userscript_path); return contents; } static gchar * unity_webapps_script_loader_get_combined_userscripts (UnityWebappsScriptLoader *loader, UnityWebappsApplicationManifest *manifest) { GString *combined_scripts; const gchar **scripts; gchar *ret; gint i, len; scripts = unity_webapps_application_manifest_get_scripts (manifest); if (scripts == NULL) { return NULL; } combined_scripts = g_string_new (""); len = g_strv_length ((gchar **)scripts); for (i = 0; i < len; i++) { const gchar *script; gchar *contents; script = scripts[i]; contents = unity_webapps_script_loader_get_userscript_content (loader, manifest, script); if (contents == NULL) { g_string_free (combined_scripts, TRUE); return NULL; } combined_scripts = g_string_append (combined_scripts, contents); g_free (contents); } ret = combined_scripts->str; g_string_free (combined_scripts, FALSE); return ret; } static void unity_webapps_script_loader_init (UnityWebappsScriptLoader *self) { self->priv = UNITY_WEBAPPS_SCRIPT_LOADER_GET_PRIVATE (self); self->priv->found_requires_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); } UnityWebappsScriptLoader * unity_webapps_script_loader_new () { return g_object_new (UNITY_WEBAPPS_TYPE_SCRIPT_LOADER, NULL); } gchar * unity_webapps_script_loader_get_userscript_contents (UnityWebappsScriptLoader *loader, UnityWebappsLocalAvailableApplication *application) { UnityWebappsApplicationManifest *manifest; gchar *user_scripts; gchar *requirements; gchar *contents; manifest = unity_webapps_local_available_application_get_manifest (application); requirements = unity_webapps_script_loader_get_combined_requirements (loader, manifest); user_scripts = unity_webapps_script_loader_get_combined_userscripts (loader, manifest); contents = g_strconcat (requirements ? requirements : "" , user_scripts, NULL); g_free (requirements); g_free (user_scripts); return contents; } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-policy-authorizer.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-policy-authoriz0000644000015301777760000000530312321247333034010 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-policy-authorizer.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_POLICY_AUTHORIZER_H #define __UNITY_WEBAPPS_POLICY_AUTHORIZER_H #define UNITY_WEBAPPS_TYPE_POLICY_AUTHORIZER (unity_webapps_policy_authorizer_get_type()) #define UNITY_WEBAPPS_POLICY_AUTHORIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_POLICY_AUTHORIZER, UnityWebappsPolicyAuthorizer)) #define UNITY_WEBAPPS_POLICY_AUTHORIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_POLICY_AUTHORIZER, UnityWebappsPolicyAuthorizerClass)) #define UNITY_WEBAPPS_IS_POLICY_AUTHORIZER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_POLICY_AUTHORIZER)) #define UNITY_WEBAPPS_IS_POLICY_AUTHORIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_POLICY_AUTHORIZER)) #define UNITY_WEBAPPS_POLICY_AUTHORIZER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_POLICY_AUTHORIZER, UnityWebappsPolicyAuthorizerClass)) #include typedef struct _UnityWebappsPolicyAuthorizerPrivate UnityWebappsPolicyAuthorizerPrivate; typedef struct _UnityWebappsPolicyAuthorizer UnityWebappsPolicyAuthorizer; struct _UnityWebappsPolicyAuthorizer { GObject object; UnityWebappsPolicyAuthorizerPrivate *priv; }; typedef struct _UnityWebappsPolicyAuthorizerClass UnityWebappsPolicyAuthorizerClass; struct _UnityWebappsPolicyAuthorizerClass { GObjectClass parent_class; }; typedef void (*UnityWebappsPolicyAuthorizerCallback) (UnityWebappsPolicyAuthorizer *authorizer, gboolean authorized, gpointer user_data); GType unity_webapps_policy_authorizer_get_type (void) G_GNUC_CONST; UnityWebappsPolicyAuthorizer *unity_webapps_policy_authorizer_new (); gboolean unity_webapps_policy_authorizer_get_install_authorization (UnityWebappsPolicyAuthorizer *authorizer, UnityWebappsPolicyAuthorizerCallback callback, gpointer user_data); #endif ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-dpkg-url-index.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-dpkg-url-index.0000644000015301777760000000473312321247333033564 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-dpkg-url-index.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_DPKG_URL_INDEX_H #define __UNITY_WEBAPPS_DPKG_URL_INDEX_H #define UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX (unity_webapps_dpkg_url_index_get_type()) #define UNITY_WEBAPPS_DPKG_URL_INDEX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX, UnityWebappsDpkgUrlIndex)) #define UNITY_WEBAPPS_DPKG_URL_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX, UnityWebappsDpkgUrlIndexClass)) #define UNITY_WEBAPPS_IS_DPKG_URL_INDEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX)) #define UNITY_WEBAPPS_IS_DPKG_URL_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX)) #define UNITY_WEBAPPS_DPKG_URL_INDEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX, UnityWebappsDpkgUrlIndexClass)) #include "unity-webapps-url-index.h" #include "unity-webapps-package-mechanism.h" typedef struct _UnityWebappsDpkgUrlIndexPrivate UnityWebappsDpkgUrlIndexPrivate; typedef struct _UnityWebappsDpkgUrlIndex UnityWebappsDpkgUrlIndex; struct _UnityWebappsDpkgUrlIndex { UnityWebappsUrlIndex manager; UnityWebappsDpkgUrlIndexPrivate *priv; }; typedef struct _UnityWebappsDpkgUrlIndexClass UnityWebappsDpkgUrlIndexClass; struct _UnityWebappsDpkgUrlIndexClass { UnityWebappsUrlIndexClass parent_class; }; GType unity_webapps_dpkg_url_index_get_type (void) G_GNUC_CONST; UnityWebappsUrlIndex *unity_webapps_dpkg_url_index_new (UnityWebappsPackageMechanism *mechanism); UnityWebappsUrlIndex *unity_webapps_dpkg_url_index_new_default (); #endif ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-collector.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-col0000644000015301777760000002214012321247333033722 0ustar pbusernogroup00000000000000/* * unity-webapps-application-collector.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include "../unity-webapps-debug.h" #include "unity-webapps-dirs.h" #include "unity-webapps-application-collector.h" #include "unity-webapps-application-manifest.h" #include "unity-webapps-local-available-application.h" struct _UnityWebappsApplicationCollectorPrivate { GHashTable *found_applications; gchar **path; }; // TODO: The path to search should be a property of this object enum { PROP_0, PROP_PATH }; G_DEFINE_TYPE(UnityWebappsApplicationCollector, unity_webapps_application_collector, G_TYPE_OBJECT) #define UNITY_WEBAPPS_APPLICATION_COLLECTOR_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR, UnityWebappsApplicationCollectorPrivate)) static void unity_webapps_application_collector_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsApplicationCollector *self; self = UNITY_WEBAPPS_APPLICATION_COLLECTOR (object); switch (prop_id) { case PROP_PATH: g_value_set_boxed (value, self->priv->path); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_application_collector_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsApplicationCollector *self; self = UNITY_WEBAPPS_APPLICATION_COLLECTOR (object); switch (prop_id) { case PROP_PATH: g_assert (self->priv->path == NULL); self->priv->path = (gchar **)g_value_dup_boxed (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_application_collector_finalize (GObject *object) { UnityWebappsApplicationCollector *collector; collector = UNITY_WEBAPPS_APPLICATION_COLLECTOR (object); if (collector->priv->found_applications) { g_hash_table_destroy (collector->priv->found_applications); } g_strfreev (collector->priv->path); } static void unity_webapps_application_collector_class_init (UnityWebappsApplicationCollectorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_application_collector_finalize; object_class->get_property = unity_webapps_application_collector_get_property; object_class->set_property = unity_webapps_application_collector_set_property; g_object_class_install_property (object_class, PROP_PATH, g_param_spec_boxed ("path", "Path", "Search path for the application collector", G_TYPE_STRV, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_type_class_add_private (object_class, sizeof(UnityWebappsApplicationCollectorPrivate)); } static void unity_webapps_application_collector_init (UnityWebappsApplicationCollector *self) { self->priv = UNITY_WEBAPPS_APPLICATION_COLLECTOR_GET_PRIVATE (self); self->priv->found_applications = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); } static gchar ** unity_webapps_application_collector_get_default_path () { const gchar *const *data_dirs; const gchar *user_dir; gchar **path; gint data_dirs_len, i; user_dir = unity_webapps_dirs_get_user_dir (); data_dirs = g_get_system_data_dirs(); data_dirs_len = g_strv_length ((gchar **)data_dirs); path = g_malloc0 (sizeof(gchar *)*(2+data_dirs_len)); path[0] = g_strdup (user_dir); for (i = 1; i < data_dirs_len+1; i++) { path[i] = g_build_filename (data_dirs[i-1], "unity-webapps", "userscripts", NULL); } path[i] = NULL; return path; } UnityWebappsApplicationCollector * unity_webapps_application_collector_new_with_default_path () { UnityWebappsApplicationCollector *collector; gchar **path; path = unity_webapps_application_collector_get_default_path (); collector = g_object_new (UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR, "path", path, NULL); g_strfreev (path); return collector; } UnityWebappsApplicationCollector * unity_webapps_application_collector_new (const gchar **path) { return g_object_new (UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR, "path", path, NULL); } static gboolean unity_webapps_application_collector_check_path (UnityWebappsApplicationCollector *collector, const gchar *manifest_path) { UnityWebappsApplicationManifest *manifest; UnityWebappsLocalAvailableApplication *app; const gchar *app_name; gboolean manifest_exists, parsed_manifest, ret; ret = TRUE; manifest = NULL; app = NULL; manifest_exists = g_file_test (manifest_path, G_FILE_TEST_EXISTS); if (manifest_exists == FALSE) { UNITY_WEBAPPS_NOTE (APPLICATION_REPOSITORY, "Failed to find manifest.json in app folder: %s", manifest_path); ret = FALSE; goto out; } manifest = unity_webapps_application_manifest_new (); parsed_manifest = unity_webapps_application_manifest_load_from_file (manifest, manifest_path); if (parsed_manifest == FALSE) { UNITY_WEBAPPS_NOTE (APPLICATION_REPOSITORY, "Failed to parse manifest.json from app folder: %s", manifest_path); ret = FALSE; goto out; } app_name = unity_webapps_application_manifest_get_package_name (manifest); app = (UnityWebappsLocalAvailableApplication *) unity_webapps_local_available_application_new (manifest); g_hash_table_replace (collector->priv->found_applications, g_strdup (app_name), g_object_ref (app)); out: if (manifest != NULL) { g_object_unref (G_OBJECT (manifest)); } if (app != NULL) { g_object_unref (G_OBJECT (app)); } return ret; } static gboolean unity_webapps_application_collector_search_app_folder (UnityWebappsApplicationCollector *collector, const gchar *app_folder) { gint i; gchar *manifest_path; gboolean ret; UNITY_WEBAPPS_NOTE (APPLICATION_REPOSITORY, "Application collector searching application folder: %s", app_folder); manifest_path = g_build_filename (app_folder, "manifest.json", NULL); ret = unity_webapps_application_collector_check_path (collector, manifest_path); g_free (manifest_path); if (ret) return ret; for (i = 0; TRUE; i++) { gboolean b; gchar *name = g_strdup_printf ("manifest-%d.json", i); manifest_path = g_build_filename (app_folder, name, NULL); b = unity_webapps_application_collector_check_path (collector, manifest_path); g_free (manifest_path); g_free (name); if (!b) { break; } else { ret = TRUE; } } return ret; } static gboolean unity_webapps_application_collector_search_path_entry (UnityWebappsApplicationCollector *collector, const gchar *path_entry) { GDir *dir; GError *error; const gchar *maybe_app_folder; UNITY_WEBAPPS_NOTE (APPLICATION_REPOSITORY, "Application collector searching path entry: %s", path_entry); error = NULL; dir = g_dir_open (path_entry, 0, &error); if (error != NULL) { g_debug ("Failed to open webapp application path dir %s: %s", path_entry, error->message); g_error_free (error); return FALSE; } // TODO: Error while ((maybe_app_folder = g_dir_read_name (dir)) != NULL) { gchar *dir_path; dir_path = g_build_filename (path_entry, maybe_app_folder, NULL); unity_webapps_application_collector_search_app_folder (collector, dir_path); g_free (dir_path); } g_dir_close (dir); return TRUE; } gboolean unity_webapps_application_collector_search_path (UnityWebappsApplicationCollector *collector) { // Path to search should really be property of object...with default path like // '$(unity_webapps_dirs_get_user_dir)/', /usr/local/share/unity-webapps', '/usr/share/unity-webapps' int i, len; len = g_strv_length ((gchar **)collector->priv->path); for (i = 0; i < len; i++) { const gchar *path_entry = (const gchar *) collector->priv->path[i]; unity_webapps_application_collector_search_path_entry (collector, path_entry); } return TRUE; } // The collector owns the applications GHashTable * unity_webapps_application_collector_get_applications (UnityWebappsApplicationCollector *collector) { return collector->priv->found_applications; } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-apt-package-mechanism.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-apt-package-mec0000644000015301777760000000505712321247333033573 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-apt-package-mechanism.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_APT_PACKAGE_MECHANISM_H #define __UNITY_WEBAPPS_APT_PACKAGE_MECHANISM_H #define UNITY_WEBAPPS_TYPE_APT_PACKAGE_MECHANISM (unity_webapps_apt_package_mechanism_get_type()) #define UNITY_WEBAPPS_APT_PACKAGE_MECHANISM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_APT_PACKAGE_MECHANISM, UnityWebappsAptPackageMechanism)) #define UNITY_WEBAPPS_APT_PACKAGE_MECHANISM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_APT_PACKAGE_MECHANISM, UnityWebappsAptPackageMechanismClass)) #define UNITY_WEBAPPS_IS_APT_PACKAGE_MECHANISM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_APT_PACKAGE_MECHANISM)) #define UNITY_WEBAPPS_IS_APT_PACKAGE_MECHANISM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_APT_PACKAGE_MECHANISM)) #define UNITY_WEBAPPS_APT_PACKAGE_MECHANISM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_APT_PACKAGE_MECHANISM, UnityWebappsAptPackageMechanismClass)) #include "unity-webapps-package-mechanism.h" typedef struct _UnityWebappsAptPackageMechanismPrivate UnityWebappsAptPackageMechanismPrivate; typedef struct _UnityWebappsAptPackageMechanism UnityWebappsAptPackageMechanism; struct _UnityWebappsAptPackageMechanism { UnityWebappsPackageMechanism manager; UnityWebappsAptPackageMechanismPrivate *priv; }; typedef struct _UnityWebappsAptPackageMechanismClass UnityWebappsAptPackageMechanismClass; struct _UnityWebappsAptPackageMechanismClass { UnityWebappsPackageMechanismClass parent_class; }; GType unity_webapps_apt_package_mechanism_get_type (void) G_GNUC_CONST; UnityWebappsPackageMechanism *unity_webapps_apt_package_mechanism_new (); #endif ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-repository.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-rep0000644000015301777760000004052412321247333033741 0ustar pbusernogroup00000000000000/* * unity-webapps-url-repository.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include "unity-webapps-application-repository.h" #include "unity-webapps-local-url-index.h" #include "unity-webapps-dpkg-url-index.h" #include "unity-webapps-dpkg-available-application.h" #include "unity-webapps-local-available-application.h" #include "unity-webapps-script-loader.h" #include "../unity-webapps-debug.h" #include "../unity-webapps-desktop-infos.h" struct _UnityWebappsApplicationRepositoryPrivate { UnityWebappsUrlIndex *available_index; UnityWebappsUrlIndex *local_index; UnityWebappsScriptLoader *script_loader; GHashTable *applications_by_name; }; enum { PROP_0, PROP_AVAILABLE_INDEX, PROP_LOCAL_INDEX }; G_DEFINE_TYPE(UnityWebappsApplicationRepository, unity_webapps_application_repository, G_TYPE_OBJECT) #define UNITY_WEBAPPS_APPLICATION_REPOSITORY_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_APPLICATION_REPOSITORY, UnityWebappsApplicationRepositoryPrivate)) static void unity_webapps_application_repository_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsApplicationRepository *self; self = UNITY_WEBAPPS_APPLICATION_REPOSITORY (object); switch (prop_id) { case PROP_LOCAL_INDEX: g_value_set_object (value, self->priv->local_index); break; case PROP_AVAILABLE_INDEX: g_value_set_object (value, self->priv->available_index); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_application_repository_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsApplicationRepository *self; self = UNITY_WEBAPPS_APPLICATION_REPOSITORY (object); switch (prop_id) { case PROP_AVAILABLE_INDEX: g_assert (self->priv->available_index == NULL); self->priv->available_index = g_value_get_object (value); break; case PROP_LOCAL_INDEX: g_assert (self->priv->local_index == NULL); self->priv->local_index = g_value_get_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_application_repository_finalize (GObject *object) { UnityWebappsApplicationRepository *repository; repository = UNITY_WEBAPPS_APPLICATION_REPOSITORY (object); g_hash_table_destroy (repository->priv->applications_by_name); } static void unity_webapps_application_repository_dispose (GObject *object) { UnityWebappsApplicationRepository *repository; repository = UNITY_WEBAPPS_APPLICATION_REPOSITORY (object); if (repository->priv->available_index) { g_object_unref (G_OBJECT (repository->priv->available_index)); repository->priv->available_index = NULL; } if (repository->priv->local_index) { g_object_unref (G_OBJECT (repository->priv->local_index)); repository->priv->local_index = NULL; } if (repository->priv->script_loader) { g_object_unref (G_OBJECT (repository->priv->script_loader)); repository->priv->script_loader = NULL; } } static void unity_webapps_application_repository_class_init (UnityWebappsApplicationRepositoryClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_application_repository_finalize; object_class->dispose = unity_webapps_application_repository_dispose; object_class->get_property = unity_webapps_application_repository_get_property; object_class->set_property = unity_webapps_application_repository_set_property; g_type_class_add_private (object_class, sizeof(UnityWebappsApplicationRepositoryPrivate)); g_object_class_install_property (object_class, PROP_LOCAL_INDEX, g_param_spec_object ("local-index", "Local Index", "Index for Locally Available Applications", UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_AVAILABLE_INDEX, g_param_spec_object ("available-index", "Available Index", "Index for remotely available applications", UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } static void unity_webapps_application_repository_init (UnityWebappsApplicationRepository *repository) { repository->priv = UNITY_WEBAPPS_APPLICATION_REPOSITORY_GET_PRIVATE (repository); repository->priv->script_loader = unity_webapps_script_loader_new (); repository->priv->applications_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); } UnityWebappsApplicationRepository * unity_webapps_application_repository_new_default () { UnityWebappsUrlIndex *available_index, *local_index; available_index = unity_webapps_dpkg_url_index_new_default (); local_index = unity_webapps_local_url_index_new_default (); return g_object_new (UNITY_WEBAPPS_TYPE_APPLICATION_REPOSITORY, "available-index", available_index, "local-index", local_index, NULL); } gboolean unity_webapps_application_repository_prepare (UnityWebappsApplicationRepository *repository) { return unity_webapps_local_url_index_load_applications (UNITY_WEBAPPS_LOCAL_URL_INDEX (repository->priv->local_index)); } static GList * unity_webapps_application_repository_search_index (UnityWebappsApplicationRepository *repository, UnityWebappsUrlIndex *index, const gchar *url) { GList *available_apps, *apps, *cur_available_app; available_apps = unity_webapps_url_index_lookup_url (index, url); if (available_apps == NULL) { return NULL; } apps = NULL; for (cur_available_app = available_apps; cur_available_app != NULL; cur_available_app = cur_available_app->next) { apps = g_list_append(apps, UNITY_WEBAPPS_AVAILABLE_APPLICATION (cur_available_app->data)); } g_list_free (available_apps); return apps; } GList * unity_webapps_application_repository_resolve_url (UnityWebappsApplicationRepository *repository, const gchar *url) { GList *app, *apps, *names; apps = unity_webapps_application_repository_search_index (repository, repository->priv->local_index, url); if (apps == NULL) { apps = unity_webapps_application_repository_search_index (repository, repository->priv->available_index, url); } if (apps == NULL) { return NULL; } names = NULL; for (app = apps; app != NULL; app = app->next) { UnityWebappsAvailableApplication *available_app; const gchar * name; available_app = (UnityWebappsAvailableApplication *) app->data; name = unity_webapps_available_application_get_name (available_app); if (!g_hash_table_contains(repository->priv->applications_by_name, name)) { g_hash_table_insert (repository->priv->applications_by_name, g_strdup (name), g_object_ref (available_app)); } names = g_list_append(names, (gpointer) g_strdup (name)); } g_list_free (apps); return names; } gchar * unity_webapps_application_repository_resolve_url_as_json (UnityWebappsApplicationRepository *repository, const gchar *url) { JsonArray *array; JsonGenerator *generator; JsonNode *root; gchar *names_as_json; GList *app, *apps; apps = unity_webapps_application_repository_resolve_url (repository, url); root = json_node_new (JSON_NODE_ARRAY); array = json_array_new (); json_node_set_array (root, array); for (app = apps; app != NULL; app = app->next) { json_array_add_string_element (array, (gchar *) app->data); } generator = json_generator_new (); json_generator_set_root (generator, root); names_as_json = json_generator_to_data (generator, NULL); json_array_unref (array); json_node_free (root); g_object_unref (generator); g_list_free_full (apps, g_free); return names_as_json; } UnityWebappsApplicationStatus unity_webapps_application_repository_get_resolved_application_status (UnityWebappsApplicationRepository *repository, const gchar *application) { UnityWebappsAvailableApplication *app; app = g_hash_table_lookup (repository->priv->applications_by_name, application); if (app == NULL) { return UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED; } else if (UNITY_WEBAPPS_IS_DPKG_AVAILABLE_APPLICATION (app)) { return UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE; } else if (UNITY_WEBAPPS_IS_LOCAL_AVAILABLE_APPLICATION (app)) { return UNITY_WEBAPPS_APPLICATION_STATUS_INSTALLED; } else { g_assert_not_reached (); return UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED; } } typedef struct _webapp_repository_install_data { UnityWebappsApplicationRepository *repository; UnityWebappsApplicationRepositoryInstallCallback callback; gpointer user_data; } webapp_repository_install_data; static const gchar* unity_webapps_application_repository_create_application_desktop_name(const gchar* const desktop_name) { g_return_val_if_fail(desktop_name != NULL, NULL); return g_strdup_printf("application://%s.desktop", desktop_name); } static void unity_webapps_application_repository_add_application_to_favorites(UnityWebappsLocalAvailableApplication *app) { #define VALIDATE_APPLICATION_FIELD(field_name) \ if(NULL == field_name || 0 == strlen(field_name)) \ { \ g_warning("Could not add installed webapp to" \ " launcher favorites: invalid '" #field_name "' field in" \ " manifest (or wrongly parsed)"); \ return; \ } gchar *domain, *name, *desktop_basename, *desktop_favorite_name; g_return_if_fail(NULL != app); g_return_if_fail(UNITY_WEBAPPS_IS_LOCAL_AVAILABLE_APPLICATION(app)); name = unity_webapps_available_application_get_application_name(UNITY_WEBAPPS_AVAILABLE_APPLICATION(app)); domain = unity_webapps_available_application_get_application_domain(UNITY_WEBAPPS_AVAILABLE_APPLICATION(app)); VALIDATE_APPLICATION_FIELD(name); VALIDATE_APPLICATION_FIELD(domain); desktop_basename = unity_webapps_desktop_infos_build_desktop_basename(name, domain); desktop_favorite_name = unity_webapps_application_repository_create_application_desktop_name(desktop_basename); unity_webapps_application_repository_add_desktop_to_launcher(desktop_favorite_name); g_free(desktop_basename); g_free(desktop_favorite_name); #undef VALIDATE_APPLICATION_FIELD } static void unity_webapps_application_repository_install_complete (UnityWebappsAvailableApplication *app, gboolean installed, gpointer user_data) { webapp_repository_install_data *data; const gchar *name; data = (webapp_repository_install_data *)user_data; name = unity_webapps_available_application_get_name (UNITY_WEBAPPS_AVAILABLE_APPLICATION (app)); if (installed) { UnityWebappsLocalAvailableApplication *app; UnityWebappsLocalUrlIndex *index; index = (UnityWebappsLocalUrlIndex *)data->repository->priv->local_index; unity_webapps_local_url_index_load_applications (index); app = unity_webapps_local_url_index_get_application_by_name (index, name); g_hash_table_replace (data->repository->priv->applications_by_name, g_strdup (name), g_object_ref (app)); unity_webapps_application_repository_add_application_to_favorites(app); } data->callback (data->repository, name, installed, data->user_data); g_free (data); } void unity_webapps_application_repository_add_desktop_to_launcher (const gchar *const desktop_name) { const gchar *UNITY_LAUNCHER_DBUS_IF_NAME = "com.canonical.Unity.Launcher"; const gchar *UNITY_LAUNCHER_DBUS_PATH = "/com/canonical/Unity/Launcher"; GDBusConnection *connection; g_return_if_fail(NULL != desktop_name || 0 != strlen(desktop_name)); connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); if (NULL == connection) { g_warning("Could not get a connection to DBUS session bus"); return; } GError *error = NULL; g_dbus_connection_call (connection, UNITY_LAUNCHER_DBUS_IF_NAME, UNITY_LAUNCHER_DBUS_PATH, UNITY_LAUNCHER_DBUS_IF_NAME, "UpdateLauncherIconFavoriteState", g_variant_new ("(sb)", desktop_name, TRUE, NULL), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, &error); if (error) { g_error("Could not complete DBUS call to UpdateLauncherIconFavoriteState: %s", error->message); g_error_free (error); } g_dbus_connection_flush_sync (connection, NULL, NULL); } void unity_webapps_application_repository_install_application (UnityWebappsApplicationRepository *repository, const gchar *name, UnityWebappsApplicationRepositoryInstallCallback callback, gpointer user_data) { webapp_repository_install_data *data; UnityWebappsAvailableApplication *app; app = g_hash_table_lookup (repository->priv->applications_by_name, name); if (app == NULL) { callback (repository, name, FALSE, user_data); return; } if (UNITY_WEBAPPS_IS_LOCAL_AVAILABLE_APPLICATION (app)) { callback (repository, name, TRUE, user_data); return; } else if (UNITY_WEBAPPS_IS_DPKG_AVAILABLE_APPLICATION (app) == FALSE) { g_assert_not_reached (); } data = g_malloc0 (sizeof (webapp_repository_install_data)); data->repository = repository; data->callback = callback; data->user_data = user_data; unity_webapps_dpkg_available_application_install (UNITY_WEBAPPS_DPKG_AVAILABLE_APPLICATION (app), unity_webapps_application_repository_install_complete, data); } gchar * unity_webapps_application_repository_get_userscript_contents (UnityWebappsApplicationRepository *repository, const gchar *name) { UnityWebappsAvailableApplication *app; app = g_hash_table_lookup (repository->priv->applications_by_name, name); if (app == NULL) { return NULL; } if (UNITY_WEBAPPS_IS_LOCAL_AVAILABLE_APPLICATION (app)) { UnityWebappsLocalAvailableApplication *local_app; local_app = (UnityWebappsLocalAvailableApplication *)app; return unity_webapps_script_loader_get_userscript_contents (repository->priv->script_loader, local_app); } else if (UNITY_WEBAPPS_IS_DPKG_AVAILABLE_APPLICATION (app)) { return NULL; } else { g_assert_not_reached (); } return NULL; } const gchar * unity_webapps_application_repository_get_resolved_application_name (UnityWebappsApplicationRepository *repository, const gchar *application) { UnityWebappsAvailableApplication *app; app = g_hash_table_lookup (repository->priv->applications_by_name, application); if (app == NULL) { return NULL; } return unity_webapps_available_application_get_application_name (app); } const gchar * unity_webapps_application_repository_get_resolved_application_domain (UnityWebappsApplicationRepository *repository, const gchar *application) { UnityWebappsAvailableApplication *app; app = g_hash_table_lookup (repository->priv->applications_by_name, application); if (app == NULL) { return NULL; } return unity_webapps_available_application_get_application_domain (app); } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-available-application.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-available-appli0000644000015301777760000000715512321247333033700 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-available-application.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_AVAILABLE_APPLICATION_H #define __UNITY_WEBAPPS_AVAILABLE_APPLICATION_H #include #define UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION (unity_webapps_available_application_get_type()) #define UNITY_WEBAPPS_AVAILABLE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION, UnityWebappsAvailableApplication)) #define UNITY_WEBAPPS_AVAILABLE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION, UnityWebappsAvailableApplicationClass)) #define UNITY_WEBAPPS_IS_AVAILABLE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION)) #define UNITY_WEBAPPS_IS_AVAILABLE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION)) #define UNITY_WEBAPPS_AVAILABLE_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION, UnityWebappsAvailableApplicationClass)) typedef struct _UnityWebappsAvailableApplicationPrivate UnityWebappsAvailableApplicationPrivate; typedef struct _UnityWebappsAvailableApplication UnityWebappsAvailableApplication; typedef void (*UnityWebappsAvailableApplicationInstalledQueryCallback) (UnityWebappsAvailableApplication *application, gboolean installed, gpointer user_data); struct _UnityWebappsAvailableApplication { GObject object; UnityWebappsAvailableApplicationPrivate *priv; }; typedef struct _UnityWebappsAvailableApplicationClass UnityWebappsAvailableApplicationClass; struct _UnityWebappsAvailableApplicationClass { GObjectClass parent_class; /* Package name */ const gchar *(*get_name) (UnityWebappsAvailableApplication *self); /* Application name */ const gchar *(*get_application_name) (UnityWebappsAvailableApplication *self); const gchar *(*get_application_domain) (UnityWebappsAvailableApplication *self); void (*get_is_installed) (UnityWebappsAvailableApplication *self, UnityWebappsAvailableApplicationInstalledQueryCallback callback, gpointer user_data); }; GType unity_webapps_available_application_get_type (void) G_GNUC_CONST; const gchar *unity_webapps_available_application_get_name (UnityWebappsAvailableApplication *application); const gchar *unity_webapps_available_application_get_application_name (UnityWebappsAvailableApplication *application); const gchar *unity_webapps_available_application_get_application_domain (UnityWebappsAvailableApplication *application); void unity_webapps_available_application_get_is_installed (UnityWebappsAvailableApplication *self, UnityWebappsAvailableApplicationInstalledQueryCallback callback, gpointer user_data); #endif ././@LongLink0000000000000000000000000000016300000000000011215 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-local-available-application.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-local-available0000644000015301777760000001730412321247333033662 0ustar pbusernogroup00000000000000/* * unity-webapps-local-available-application.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ /* This object is to encapsulate the userscript script loading abstractions as opposed to the manifest contents */ #include #include #include #include #include #include "unity-webapps-local-available-application.h" #include "../unity-webapps-debug.h" struct _UnityWebappsLocalAvailableApplicationPrivate { UnityWebappsApplicationManifest *manifest; GList *pattern_specs; }; enum { PROP_0, PROP_MANIFEST }; G_DEFINE_TYPE(UnityWebappsLocalAvailableApplication, unity_webapps_local_available_application, UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION) #define UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_LOCAL_AVAILABLE_APPLICATION, UnityWebappsLocalAvailableApplicationPrivate)) static void unity_webapps_local_available_application_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsLocalAvailableApplication *app; app = UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION (object); switch (prop_id) { case PROP_MANIFEST: g_value_set_object (value, app->priv->manifest); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_local_available_application_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsLocalAvailableApplication *app; app = UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION (object); switch (prop_id) { case PROP_MANIFEST: g_return_if_fail (app->priv->manifest == NULL); app->priv->manifest = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void local_available_application_get_is_installed (UnityWebappsAvailableApplication *available_application, UnityWebappsAvailableApplicationInstalledQueryCallback callback, gpointer user_data) { callback(available_application, TRUE, user_data); } static const gchar * local_available_application_get_name (UnityWebappsAvailableApplication *available_application) { UnityWebappsLocalAvailableApplication *self; self = UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION (available_application); return unity_webapps_application_manifest_get_package_name (self->priv->manifest); } static const gchar * local_available_application_get_application_name (UnityWebappsAvailableApplication *available_application) { UnityWebappsLocalAvailableApplication *self; self = UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION (available_application); return unity_webapps_application_manifest_get_name (self->priv->manifest); } static const gchar * local_available_application_get_application_domain (UnityWebappsAvailableApplication *available_application) { UnityWebappsLocalAvailableApplication *self; self = UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION (available_application); return unity_webapps_application_manifest_get_domain (self->priv->manifest); } static void unity_webapps_local_available_application_finalize (GObject *object) { UnityWebappsLocalAvailableApplication *self; self = UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION (object); if (self->priv->manifest) { g_object_unref (G_OBJECT (self->priv->manifest)); } if (self->priv->pattern_specs) { GList *l; l = self->priv->pattern_specs; while (l != NULL) { GPatternSpec *pspec; pspec = (GPatternSpec *)l->data; g_pattern_spec_free (pspec); l = l->next; } } } static void unity_webapps_local_available_application_class_init (UnityWebappsLocalAvailableApplicationClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsAvailableApplicationClass *available_application_class = UNITY_WEBAPPS_AVAILABLE_APPLICATION_CLASS (klass); object_class->finalize = unity_webapps_local_available_application_finalize; object_class->get_property = unity_webapps_local_available_application_get_property; object_class->set_property = unity_webapps_local_available_application_set_property; available_application_class->get_name = local_available_application_get_name; available_application_class->get_application_name = local_available_application_get_application_name; available_application_class->get_application_domain = local_available_application_get_application_domain; available_application_class->get_is_installed = local_available_application_get_is_installed; g_type_class_add_private (object_class, sizeof(UnityWebappsLocalAvailableApplicationPrivate)); g_object_class_install_property (object_class, PROP_MANIFEST, g_param_spec_object ("manifest", "Mame", "The Application Manifest", UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); } static void unity_webapps_local_available_application_init (UnityWebappsLocalAvailableApplication *self) { self->priv = UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION_GET_PRIVATE (self); self->priv->manifest = NULL; self->priv->pattern_specs = NULL; } UnityWebappsAvailableApplication * unity_webapps_local_available_application_new (UnityWebappsApplicationManifest *manifest) { return UNITY_WEBAPPS_AVAILABLE_APPLICATION (g_object_new (UNITY_WEBAPPS_TYPE_LOCAL_AVAILABLE_APPLICATION, "manifest", manifest, NULL)); } UnityWebappsApplicationManifest * unity_webapps_local_available_application_get_manifest (UnityWebappsLocalAvailableApplication *app) { return app->priv->manifest; } static gboolean unity_webapps_local_available_application_compile_pattern_specs (UnityWebappsLocalAvailableApplication *app) { const gchar **includes; gint length, i; g_return_val_if_fail (app->priv->manifest != NULL, FALSE); g_return_val_if_fail (app->priv->pattern_specs == NULL, FALSE); includes = unity_webapps_application_manifest_get_includes (app->priv->manifest); length = g_strv_length ((gchar **)includes); for (i = 0; i < length; i++) { GPatternSpec *spec; const gchar *include; include = includes[i]; spec = g_pattern_spec_new (include); app->priv->pattern_specs = g_list_append (app->priv->pattern_specs, spec); } return TRUE; } gboolean unity_webapps_local_available_application_provides_url (UnityWebappsLocalAvailableApplication *application, const gchar *url) { GList *w; if (application->priv->pattern_specs == NULL) { unity_webapps_local_available_application_compile_pattern_specs (application); } for (w = application->priv->pattern_specs; w != NULL; w = w->next) { GPatternSpec *pspec; gboolean matched; pspec = (GPatternSpec *)w->data; matched = g_pattern_match_string (pspec, url); if (matched == TRUE) { return TRUE; } } return FALSE; } ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-dpkg-url-index.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-dpkg-url-index.0000644000015301777760000001463212321247333033563 0ustar pbusernogroup00000000000000/* * unity-webapps-dpkg-url-index.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-dpkg-url-index.h" #include "unity-webapps-url-db.h" #include "unity-webapps-apt-package-mechanism.h" #include "unity-webapps-dpkg-available-application.h" #include "../unity-webapps-debug.h" struct _UnityWebappsDpkgUrlIndexPrivate { UnityWebappsUrlDB *url_db; UnityWebappsPackageMechanism *package_mechanism; // Package name -> Available Application. Available applications are owned by this table. GHashTable *available_applications_by_name; }; enum { PROP_0, PROP_PACKAGE_MECHANISM }; G_DEFINE_TYPE(UnityWebappsDpkgUrlIndex, unity_webapps_dpkg_url_index, UNITY_WEBAPPS_TYPE_URL_INDEX) #define UNITY_WEBAPPS_DPKG_URL_INDEX_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX, UnityWebappsDpkgUrlIndexPrivate)) static UnityWebappsAvailableApplication * dpkg_url_index_get_application_record (UnityWebappsDpkgUrlIndex *self, const gchar *name, const gchar *application_name, const gchar *application_domain) { UnityWebappsAvailableApplication *app; app = g_hash_table_lookup (self->priv->available_applications_by_name, name); if (app != NULL) { return app; } app = unity_webapps_dpkg_available_application_new (name, application_name, application_domain, self->priv->package_mechanism); g_hash_table_insert (self->priv->available_applications_by_name, g_strdup (name), app); return app; } static GList * dpkg_url_index_lookup_url (UnityWebappsUrlIndex *url_index, const gchar *url) { UnityWebappsDpkgUrlIndex *self; GList *applications, *records, *w; self = UNITY_WEBAPPS_DPKG_URL_INDEX (url_index); if (self->priv->url_db == NULL) { return NULL; } unity_webapps_url_db_lookup_urls (self->priv->url_db, url, &records); applications = NULL; for (w = records; w != NULL; w = w->next) { UnityWebappsUrlDBRecord *record; UnityWebappsAvailableApplication *app; record = (UnityWebappsUrlDBRecord *)w->data; app = dpkg_url_index_get_application_record (self, record->package_name, record->application_name, record->domain); g_assert (app); applications = g_list_append (applications, app); } unity_webapps_url_db_record_list_free (records); return applications; } static void unity_webapps_dpkg_url_index_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsDpkgUrlIndex *self; self = UNITY_WEBAPPS_DPKG_URL_INDEX (object); switch (prop_id) { case PROP_PACKAGE_MECHANISM: g_value_set_boxed (value, self->priv->package_mechanism); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_dpkg_url_index_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsDpkgUrlIndex *self;; self = UNITY_WEBAPPS_DPKG_URL_INDEX (object); switch (prop_id) { case PROP_PACKAGE_MECHANISM: g_assert (self->priv->package_mechanism == NULL); self->priv->package_mechanism = (UnityWebappsPackageMechanism *)g_value_get_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_dpkg_url_index_finalize (GObject *object) { UnityWebappsDpkgUrlIndex *self; self = UNITY_WEBAPPS_DPKG_URL_INDEX (object); if (self->priv->url_db) { unity_webapps_url_db_free (self->priv->url_db); } if (self->priv->available_applications_by_name) { g_hash_table_destroy (self->priv->available_applications_by_name); } g_object_unref (G_OBJECT (self->priv->package_mechanism)); } static void unity_webapps_dpkg_url_index_class_init (UnityWebappsDpkgUrlIndexClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsUrlIndexClass *index_class = UNITY_WEBAPPS_URL_INDEX_CLASS (klass); object_class->finalize = unity_webapps_dpkg_url_index_finalize; object_class->get_property = unity_webapps_dpkg_url_index_get_property; object_class->set_property = unity_webapps_dpkg_url_index_set_property; index_class->lookup_url = dpkg_url_index_lookup_url; g_type_class_add_private (object_class, sizeof(UnityWebappsDpkgUrlIndexPrivate)); g_object_class_install_property (object_class, PROP_PACKAGE_MECHANISM, g_param_spec_object("package-mechanism", "Package Mechanism", "The Mechanism to use for external package functionality", UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } static void unity_webapps_dpkg_url_index_init (UnityWebappsDpkgUrlIndex *self) { self->priv = UNITY_WEBAPPS_DPKG_URL_INDEX_GET_PRIVATE (self); self->priv->url_db = unity_webapps_url_db_open_default (TRUE); self->priv->available_applications_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); self->priv->package_mechanism = NULL; } UnityWebappsUrlIndex * unity_webapps_dpkg_url_index_new (UnityWebappsPackageMechanism *package_mechanism) { return UNITY_WEBAPPS_URL_INDEX (g_object_new (UNITY_WEBAPPS_TYPE_DPKG_URL_INDEX, "package-mechanism", package_mechanism, NULL)); } UnityWebappsUrlIndex * unity_webapps_dpkg_url_index_new_default () { UnityWebappsPackageMechanism *mechanism; mechanism = unity_webapps_apt_package_mechanism_new (); return unity_webapps_dpkg_url_index_new (mechanism); } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-policy-authorizer.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-policy-authoriz0000644000015301777760000001034312321247333034010 0ustar pbusernogroup00000000000000/* * unity-webapps-application-loader.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include "../unity-webapps-debug.h" #include "unity-webapps-policy-authorizer.h" struct _UnityWebappsPolicyAuthorizerPrivate { PolkitAuthority *authority; PolkitSubject *policy_subject; }; G_DEFINE_TYPE(UnityWebappsPolicyAuthorizer, unity_webapps_policy_authorizer, G_TYPE_OBJECT) #define UNITY_WEBAPPS_POLICY_AUTHORIZER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_POLICY_AUTHORIZER, UnityWebappsPolicyAuthorizerPrivate)) static void unity_webapps_policy_authorizer_finalize (GObject *object) { UnityWebappsPolicyAuthorizer *authorizer; authorizer = UNITY_WEBAPPS_POLICY_AUTHORIZER (object); g_object_unref (G_OBJECT (authorizer->priv->authority)); g_object_unref (G_OBJECT (authorizer->priv->policy_subject)); } static void unity_webapps_policy_authorizer_class_init (UnityWebappsPolicyAuthorizerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_policy_authorizer_finalize; g_type_class_add_private (object_class, sizeof(UnityWebappsPolicyAuthorizerPrivate)); } static void unity_webapps_policy_authorizer_init (UnityWebappsPolicyAuthorizer *authorizer) { GDBusConnection *system_bus; const gchar *unique_name; authorizer->priv = UNITY_WEBAPPS_POLICY_AUTHORIZER_GET_PRIVATE (authorizer); system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); unique_name = g_dbus_connection_get_unique_name (system_bus); authorizer->priv->authority = polkit_authority_get_sync (NULL, NULL); authorizer->priv->policy_subject = polkit_system_bus_name_new (unique_name); } UnityWebappsPolicyAuthorizer * unity_webapps_policy_authorizer_new () { return g_object_new (UNITY_WEBAPPS_TYPE_POLICY_AUTHORIZER, NULL); } typedef struct _webapp_authorization_data { UnityWebappsPolicyAuthorizer *authorizer; UnityWebappsPolicyAuthorizerCallback callback; gpointer user_data; } webapp_authorization_data; static void policy_authorizer_authorization_callback (GObject *object, GAsyncResult *res, gpointer user_data) { PolkitAuthorizationResult *result; webapp_authorization_data *data; GError *error; gboolean authorized; data = (webapp_authorization_data *)user_data; error = NULL; result = polkit_authority_check_authorization_finish (POLKIT_AUTHORITY (object), res, &error); authorized = FALSE; if (error != NULL) { g_critical ("Error checking authorization: %s\n", error->message); g_error_free (error); } else { authorized = polkit_authorization_result_get_is_authorized (result); } data->callback(data->authorizer, authorized, data->callback); g_free (data); } gboolean unity_webapps_policy_authorizer_get_install_authorization (UnityWebappsPolicyAuthorizer *authorizer, UnityWebappsPolicyAuthorizerCallback callback, gpointer user_data) { webapp_authorization_data *data; data = g_malloc0 (sizeof (webapp_authorization_data)); data->authorizer = authorizer; data->callback = callback; data->user_data = user_data; polkit_authority_check_authorization (authorizer->priv->authority, authorizer->priv->policy_subject, "org.debian.apt.install-or-remove-packages", NULL, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, NULL, policy_authorizer_authorization_callback, data); return TRUE; } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-collector.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-col0000644000015301777760000000554012321247333033727 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-application-manifescolt.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_APPLICATION_COLLECTOR_H #define __UNITY_WEBAPPS_APPLICATION_COLLECTOR_H #define UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR (unity_webapps_application_collector_get_type()) #define UNITY_WEBAPPS_APPLICATION_COLLECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR, UnityWebappsApplicationCollector)) #define UNITY_WEBAPPS_APPLICATION_COLLECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR, UnityWebappsApplicationCollectorClass)) #define UNITY_WEBAPPS_IS_APPLICATION_COLLECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR)) #define UNITY_WEBAPPS_IS_APPLICATION_COLLECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR)) #define UNITY_WEBAPPS_APPLICATION_COLLECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR, UnityWebappsApplicationCollectorClass)) #include #include typedef struct _UnityWebappsApplicationCollectorPrivate UnityWebappsApplicationCollectorPrivate; typedef struct _UnityWebappsApplicationCollector UnityWebappsApplicationCollector; struct _UnityWebappsApplicationCollector { GObject object; UnityWebappsApplicationCollectorPrivate *priv; }; typedef struct _UnityWebappsApplicationCollectorClass UnityWebappsApplicationCollectorClass; struct _UnityWebappsApplicationCollectorClass { GObjectClass parent_class; }; GType unity_webapps_application_collector_get_type (void) G_GNUC_CONST; UnityWebappsApplicationCollector * unity_webapps_application_collector_new (const gchar **path); UnityWebappsApplicationCollector *unity_webapps_application_collector_new_with_default_path (); GHashTable * unity_webapps_application_collector_get_applications (UnityWebappsApplicationCollector *collector); gboolean unity_webapps_application_collector_search_path (UnityWebappsApplicationCollector *collector); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-url-index.h0000644000015301777760000000435612321247333033012 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-url-index.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_URL_INDEX_H #define __UNITY_WEBAPPS_URL_INDEX_H #define UNITY_WEBAPPS_TYPE_URL_INDEX (unity_webapps_url_index_get_type()) #define UNITY_WEBAPPS_URL_INDEX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_URL_INDEX, UnityWebappsUrlIndex)) #define UNITY_WEBAPPS_URL_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_URL_INDEX, UnityWebappsUrlIndexClass)) #define UNITY_WEBAPPS_IS_URL_INDEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_URL_INDEX)) #define UNITY_WEBAPPS_IS_URL_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_URL_INDEX)) #define UNITY_WEBAPPS_URL_INDEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_URL_INDEX, UnityWebappsUrlIndexClass)) typedef struct _UnityWebappsUrlIndexPrivate UnityWebappsUrlIndexPrivate; typedef struct _UnityWebappsUrlIndex UnityWebappsUrlIndex; struct _UnityWebappsUrlIndex { GObject object; UnityWebappsUrlIndexPrivate *priv; }; typedef struct _UnityWebappsUrlIndexClass UnityWebappsUrlIndexClass; struct _UnityWebappsUrlIndexClass { GObjectClass parent_class; GList * (*lookup_url) (UnityWebappsUrlIndex *self, const gchar *url); }; GType unity_webapps_url_index_get_type (void) G_GNUC_CONST; GList *unity_webapps_url_index_lookup_url (UnityWebappsUrlIndex *manager, const gchar *url); #endif ././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-manifest.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-man0000644000015301777760000000666212321247333033733 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-application-manifest.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_APPLICATION_MANIFEST_H #define __UNITY_WEBAPPS_APPLICATION_MANIFEST_H #define UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST (unity_webapps_application_manifest_get_type()) #define UNITY_WEBAPPS_APPLICATION_MANIFEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST, UnityWebappsApplicationManifest)) #define UNITY_WEBAPPS_APPLICATION_MANIFEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST, UnityWebappsApplicationManifestClass)) #define UNITY_WEBAPPS_IS_APPLICATION_MANIFEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST)) #define UNITY_WEBAPPS_IS_APPLICATION_MANIFEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST)) #define UNITY_WEBAPPS_APPLICATION_MANIFEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST, UnityWebappsApplicationManifestClass)) #include typedef struct _UnityWebappsApplicationManifestPrivate UnityWebappsApplicationManifestPrivate; typedef struct _UnityWebappsApplicationManifest UnityWebappsApplicationManifest; struct _UnityWebappsApplicationManifest { GObject object; UnityWebappsApplicationManifestPrivate *priv; }; typedef struct _UnityWebappsApplicationManifestClass UnityWebappsApplicationManifestClass; struct _UnityWebappsApplicationManifestClass { GObjectClass parent_class; }; GType unity_webapps_application_manifest_get_type (void) G_GNUC_CONST; UnityWebappsApplicationManifest *unity_webapps_application_manifest_new (); UnityWebappsApplicationManifest *unity_webapps_application_manifest_new_from_file (const gchar *filename); const gchar *unity_webapps_application_manifest_get_name (UnityWebappsApplicationManifest *manifest); const gchar *unity_webapps_application_manifest_get_package_name (UnityWebappsApplicationManifest *manifest); const gchar *unity_webapps_application_manifest_get_domain (UnityWebappsApplicationManifest *manifest); gboolean unity_webapps_application_manifest_load_from_file (UnityWebappsApplicationManifest *manifest, const gchar *filename); const gchar **unity_webapps_application_manifest_get_scripts (UnityWebappsApplicationManifest *manifest); const gchar **unity_webapps_application_manifest_get_requires (UnityWebappsApplicationManifest *manifest); const gchar **unity_webapps_application_manifest_get_includes (UnityWebappsApplicationManifest *manifest); const gchar * unity_webapps_application_manifest_get_base_path (UnityWebappsApplicationManifest *manifest); #endif ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-repository.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-rep0000644000015301777760000001037512321247333033742 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-application-repository.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_APPLICATION_REPOSITORY_H #define __UNITY_WEBAPPS_APPLICATION_REPOSITORY_H #define UNITY_WEBAPPS_TYPE_APPLICATION_REPOSITORY (unity_webapps_application_repository_get_type()) #define UNITY_WEBAPPS_APPLICATION_REPOSITORY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_APPLICATION_REPOSITORY, UnityWebappsApplicationRepository)) #define UNITY_WEBAPPS_APPLICATION_REPOSITORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_APPLICATION_REPOSITORY, UnityWebappsApplicationRepositoryClass)) #define UNITY_WEBAPPS_IS_APPLICATION_REPOSITORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_APPLICATION_REPOSITORY)) #define UNITY_WEBAPPS_IS_APPLICATION_REPOSITORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_APPLICATION_REPOSITORY)) #define UNITY_WEBAPPS_APPLICATION_REPOSITORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_APPLICATION_REPOSITORY, UnityWebappsApplicationRepositoryClass)) #include "unity-webapps-available-application.h" typedef struct _UnityWebappsApplicationRepositoryPrivate UnityWebappsApplicationRepositoryPrivate; typedef struct _UnityWebappsApplicationRepository UnityWebappsApplicationRepository; struct _UnityWebappsApplicationRepository { GObject object; UnityWebappsApplicationRepositoryPrivate *priv; }; typedef struct _UnityWebappsApplicationRepositoryClass UnityWebappsApplicationRepositoryClass; struct _UnityWebappsApplicationRepositoryClass { GObjectClass parent_class; }; typedef enum { UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE, UNITY_WEBAPPS_APPLICATION_STATUS_INSTALLED, UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED } UnityWebappsApplicationStatus; GType unity_webapps_application_repository_get_type (void) G_GNUC_CONST; UnityWebappsApplicationRepository *unity_webapps_application_repository_new_default (); gboolean unity_webapps_application_repository_prepare (UnityWebappsApplicationRepository *repository); GList * unity_webapps_application_repository_resolve_url (UnityWebappsApplicationRepository *repository, const gchar *url); gchar * unity_webapps_application_repository_resolve_url_as_json (UnityWebappsApplicationRepository *repository, const gchar *url); UnityWebappsApplicationStatus unity_webapps_application_repository_get_resolved_application_status (UnityWebappsApplicationRepository *repository, const gchar *application); const gchar * unity_webapps_application_repository_get_resolved_application_name (UnityWebappsApplicationRepository *repository, const gchar *application); const gchar * unity_webapps_application_repository_get_resolved_application_domain (UnityWebappsApplicationRepository *repository, const gchar *application); typedef void (*UnityWebappsApplicationRepositoryInstallCallback) (UnityWebappsApplicationRepository *repository, const gchar *name, UnityWebappsApplicationStatus status, gpointer user_data); void unity_webapps_application_repository_install_application (UnityWebappsApplicationRepository *repository, const gchar *name, UnityWebappsApplicationRepositoryInstallCallback callback, gpointer user_data); gchar * unity_webapps_application_repository_get_userscript_contents (UnityWebappsApplicationRepository *repository, const gchar *name); void unity_webapps_application_repository_add_desktop_to_launcher (const gchar *const desktop_name); #endif ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/libunity-webapps-repository.pc.inlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/libunity-webapps-repository.p0000644000015301777760000000053612321247333034015 0ustar pbusernogroup00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ datarootdir=@datarootdir@ datadir=@datadir@ includedir=@includedir@/libunity-webapps-repository Name: libunity-webapps-repository Description: Unity Webapps Repository Access and Manipulation Version: @VERSION@ Requires: Libs: -L${libdir} -lunity-webapps-repository Cflags: -I${includedir} ././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-local-url-index.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-local-url-index0000644000015301777760000000550512321247333033651 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-local-url-index.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_LOCAL_URL_INDEX_H #define __UNITY_WEBAPPS_LOCAL_URL_INDEX_H #define UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX (unity_webapps_local_url_index_get_type()) #define UNITY_WEBAPPS_LOCAL_URL_INDEX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX, UnityWebappsLocalUrlIndex)) #define UNITY_WEBAPPS_LOCAL_URL_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX, UnityWebappsLocalUrlIndexClass)) #define UNITY_WEBAPPS_IS_LOCAL_URL_INDEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX)) #define UNITY_WEBAPPS_IS_LOCAL_URL_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX)) #define UNITY_WEBAPPS_LOCAL_URL_INDEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX, UnityWebappsLocalUrlIndexClass)) #include "unity-webapps-url-index.h" #include "unity-webapps-local-available-application.h" #include "unity-webapps-application-collector.h" typedef struct _UnityWebappsLocalUrlIndexPrivate UnityWebappsLocalUrlIndexPrivate; typedef struct _UnityWebappsLocalUrlIndex UnityWebappsLocalUrlIndex; struct _UnityWebappsLocalUrlIndex { UnityWebappsUrlIndex manager; UnityWebappsLocalUrlIndexPrivate *priv; }; typedef struct _UnityWebappsLocalUrlIndexClass UnityWebappsLocalUrlIndexClass; struct _UnityWebappsLocalUrlIndexClass { UnityWebappsUrlIndexClass parent_class; }; GType unity_webapps_local_url_index_get_type (void) G_GNUC_CONST; UnityWebappsUrlIndex *unity_webapps_local_url_index_new (UnityWebappsApplicationCollector *collector); UnityWebappsUrlIndex *unity_webapps_local_url_index_new_default (); gboolean unity_webapps_local_url_index_load_applications (UnityWebappsLocalUrlIndex *index); UnityWebappsLocalAvailableApplication * unity_webapps_local_url_index_get_application_by_name (UnityWebappsLocalUrlIndex *index, const gchar *name); #endif libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/main.c0000644000015301777760000000533312321247333027211 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-dpkg-available-application.h" #include "unity-webapps-local-available-application.h" #include "unity-webapps-policy-authorizer.h" #include "unity-webapps-application-repository.h" #include "unity-webapps-script-loader.h" #include "unity-webapps-debug.h" static GMainLoop *main_loop = NULL; static void print_userscript_contents (UnityWebappsApplicationRepository *repository, const gchar *app) { gchar *contents; contents = unity_webapps_application_repository_get_userscript_contents (repository, app); g_message("Userscript contents: %s \n", contents); g_free (contents); } static void install_response (UnityWebappsApplicationRepository *repository, const gchar *name, UnityWebappsApplicationStatus status, gpointer user_data) { g_message("Found application: %s \n", name); switch (status) { case UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE: g_message("Application available for install \n"); break; case UNITY_WEBAPPS_APPLICATION_STATUS_INSTALLED: g_message("Application installed \n"); break; default: g_assert_not_reached (); } } int main (int argc, gchar **argv) { UnityWebappsApplicationRepository *repository; const GList *names, *name; UnityWebappsApplicationStatus status; g_type_init (); unity_webapps_debug_initialize_flags (); repository = unity_webapps_application_repository_new_default (); unity_webapps_application_repository_prepare (repository); names = unity_webapps_application_repository_resolve_url (repository, argv[1]); g_message("looked up application: %s \n", argv[1]); for (name = names; name != NULL; name = name->next) { const gchar * curname = (gchar *) name->data; g_message("application: %s \n", curname); status = unity_webapps_application_repository_get_resolved_application_status (repository, curname); g_message("Found application: %s \n", curname); switch (status) { case UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE: g_message("Application available for install \n"); unity_webapps_application_repository_install_application (repository, curname, install_response, NULL); break; case UNITY_WEBAPPS_APPLICATION_STATUS_INSTALLED: g_message("Application installed \n"); // print_userscript_contents (repository, curname); break; default: g_assert_not_reached (); } } g_list_free_full ((GList*) names, g_free); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-script-loader.h0000644000015301777760000000473512321247333033654 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-script-loader.h * Copyright (C) Canonical LTD 2012 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_SCRIPT_LOADER_H #define __UNITY_WEBAPPS_SCRIPT_LOADER_H #define UNITY_WEBAPPS_TYPE_SCRIPT_LOADER (unity_webapps_script_loader_get_type()) #define UNITY_WEBAPPS_SCRIPT_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_SCRIPT_LOADER, UnityWebappsScriptLoader)) #define UNITY_WEBAPPS_SCRIPT_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_SCRIPT_LOADER, UnityWebappsScriptLoaderClass)) #define UNITY_WEBAPPS_IS_SCRIPT_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_SCRIPT_LOADER)) #define UNITY_WEBAPPS_IS_SCRIPT_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_SCRIPT_LOADER)) #define UNITY_WEBAPPS_SCRIPT_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_SCRIPT_LOADER, UnityWebappsScriptLoaderClass)) #include #include "unity-webapps-local-available-application.h" typedef struct _UnityWebappsScriptLoaderPrivate UnityWebappsScriptLoaderPrivate; typedef struct _UnityWebappsScriptLoader UnityWebappsScriptLoader; struct _UnityWebappsScriptLoader { GObject object; UnityWebappsScriptLoaderPrivate *priv; }; typedef struct _UnityWebappsScriptLoaderClass UnityWebappsScriptLoaderClass; struct _UnityWebappsScriptLoaderClass { GObjectClass parent_class; }; GType unity_webapps_script_loader_get_type (void) G_GNUC_CONST; UnityWebappsScriptLoader *unity_webapps_script_loader_new (); gchar *unity_webapps_script_loader_get_userscript_contents (UnityWebappsScriptLoader *loader, UnityWebappsLocalAvailableApplication *application); #endif /* __UNITY_WEBAPPS_SCRIPT_LOADER_H */libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-url-index.c0000644000015301777760000000333012321247333032774 0ustar pbusernogroup00000000000000/* * unity-webapps-url-index.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include "unity-webapps-url-index.h" #include "../unity-webapps-debug.h" struct _UnityWebappsUrlIndexPrivate { gpointer fill; }; G_DEFINE_ABSTRACT_TYPE(UnityWebappsUrlIndex, unity_webapps_url_index, G_TYPE_OBJECT) #define UNITY_WEBAPPS_URL_INDEX_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_URL_INDEX, UnityWebappsUrlIndexPrivate)) static void unity_webapps_url_index_class_init (UnityWebappsUrlIndexClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (object_class, sizeof(UnityWebappsUrlIndexPrivate)); } static void unity_webapps_url_index_init (UnityWebappsUrlIndex *index) { index->priv = UNITY_WEBAPPS_URL_INDEX_GET_PRIVATE (index); } GList * unity_webapps_url_index_lookup_url (UnityWebappsUrlIndex *index, const gchar *url) { return UNITY_WEBAPPS_URL_INDEX_GET_CLASS (index)->lookup_url (index, url); } libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/local-test.c0000644000015301777760000000223212321247333030327 0ustar pbusernogroup00000000000000#include #include #include "unity-webapps-application-collector.h" #include "unity-webapps-application-manifest.h" #include "unity-webapps-local-available-application.h" #include "unity-webapps-debug.h" static GMainLoop *main_loop = NULL; int main (int argc, gchar **argv) { UnityWebappsApplicationCollector *collector; GHashTable *applications_by_name; GList *applications, *l; g_type_init (); unity_webapps_debug_initialize_flags(); collector = unity_webapps_application_collector_new_with_default_path (); unity_webapps_application_collector_search_path (collector); applications_by_name = unity_webapps_application_collector_get_applications (collector); applications = g_hash_table_get_values (applications_by_name); for (l = applications; l != NULL; l = l->next) { UnityWebappsLocalAvailableApplication *app; app = (UnityWebappsLocalAvailableApplication *)l->data; g_printf("Found application: %s \n", unity_webapps_application_manifest_get_name (unity_webapps_local_available_application_get_manifest (app))); } g_list_free (applications); return 0; } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-available-application.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-available-appli0000644000015301777760000000510312321247333033667 0ustar pbusernogroup00000000000000/* * unity-webapps-available-application.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-available-application.h" #include "../unity-webapps-debug.h" struct _UnityWebappsAvailableApplicationPrivate { gpointer fill; }; G_DEFINE_ABSTRACT_TYPE(UnityWebappsAvailableApplication, unity_webapps_available_application, G_TYPE_OBJECT) #define UNITY_WEBAPPS_AVAILABLE_APPLICATION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_AVAILABLE_APPLICATION, UnityWebappsAvailableApplicationPrivate)) static void unity_webapps_available_application_class_init (UnityWebappsAvailableApplicationClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (object_class, sizeof(UnityWebappsAvailableApplicationPrivate)); } static void unity_webapps_available_application_init (UnityWebappsAvailableApplication *app) { app->priv = UNITY_WEBAPPS_AVAILABLE_APPLICATION_GET_PRIVATE (app); } const gchar * unity_webapps_available_application_get_name (UnityWebappsAvailableApplication *app) { return UNITY_WEBAPPS_AVAILABLE_APPLICATION_GET_CLASS (app)->get_name (app); } const gchar * unity_webapps_available_application_get_application_name (UnityWebappsAvailableApplication *app) { return UNITY_WEBAPPS_AVAILABLE_APPLICATION_GET_CLASS (app)->get_application_name (app); } const gchar * unity_webapps_available_application_get_application_domain (UnityWebappsAvailableApplication *app) { return UNITY_WEBAPPS_AVAILABLE_APPLICATION_GET_CLASS (app)->get_application_domain (app); } void unity_webapps_available_application_get_is_installed (UnityWebappsAvailableApplication *self, UnityWebappsAvailableApplicationInstalledQueryCallback callback, gpointer user_data) { UNITY_WEBAPPS_AVAILABLE_APPLICATION_GET_CLASS (self)->get_is_installed (self, callback, user_data); } ././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-local-url-index.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-local-url-index0000644000015301777760000001435412321247333033653 0ustar pbusernogroup00000000000000/* * unity-webapps-local-url-index.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-local-url-index.h" #include "unity-webapps-application-collector.h" #include "unity-webapps-local-available-application.h" #include "unity-webapps-dpkg-available-application.h" #include "../unity-webapps-debug.h" struct _UnityWebappsLocalUrlIndexPrivate { UnityWebappsApplicationCollector *collector; GHashTable *available_applications_by_name; }; enum { PROP_0, PROP_COLLECTOR }; G_DEFINE_TYPE(UnityWebappsLocalUrlIndex, unity_webapps_local_url_index, UNITY_WEBAPPS_TYPE_URL_INDEX) #define UNITY_WEBAPPS_LOCAL_URL_INDEX_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX, UnityWebappsLocalUrlIndexPrivate)) static void unity_webapps_local_url_index_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsLocalUrlIndex *self; self = UNITY_WEBAPPS_LOCAL_URL_INDEX (object); switch (prop_id) { case PROP_COLLECTOR: g_value_set_object (value, self->priv->collector); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_local_url_index_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsLocalUrlIndex *self; self = UNITY_WEBAPPS_LOCAL_URL_INDEX (object); switch (prop_id) { case PROP_COLLECTOR: g_assert (self->priv->collector == NULL); self->priv->collector = g_value_get_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static GList * local_url_index_lookup_url (UnityWebappsUrlIndex *url_index, const gchar *url) { UnityWebappsLocalUrlIndex *self; GList *available_applications, *results, *w; self = UNITY_WEBAPPS_LOCAL_URL_INDEX (url_index); results = NULL; available_applications = g_hash_table_get_values (self->priv->available_applications_by_name); for (w = available_applications; w != NULL; w = w->next) { UnityWebappsLocalAvailableApplication *app; gboolean matches; app = UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION (w->data); matches = unity_webapps_local_available_application_provides_url (app, url); if (matches) { results = g_list_append (results, app); } } g_list_free (available_applications); return results; } static void unity_webapps_local_url_index_finalize (GObject *object) { UnityWebappsLocalUrlIndex *self; self = UNITY_WEBAPPS_LOCAL_URL_INDEX (object); g_hash_table_unref (self->priv->available_applications_by_name); } static void unity_webapps_local_url_index_dispose (GObject *object) { UnityWebappsLocalUrlIndex *self; self = (UnityWebappsLocalUrlIndex *)object; if (self->priv->collector) { g_object_unref (G_OBJECT (self->priv->collector)); self->priv->collector = NULL; } } static void unity_webapps_local_url_index_class_init (UnityWebappsLocalUrlIndexClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsUrlIndexClass *index_class = UNITY_WEBAPPS_URL_INDEX_CLASS (klass); object_class->finalize = unity_webapps_local_url_index_finalize; object_class->dispose = unity_webapps_local_url_index_dispose; object_class->get_property = unity_webapps_local_url_index_get_property; object_class->set_property = unity_webapps_local_url_index_set_property; index_class->lookup_url = local_url_index_lookup_url; g_type_class_add_private (object_class, sizeof(UnityWebappsLocalUrlIndexPrivate)); g_object_class_install_property (object_class, PROP_COLLECTOR, g_param_spec_object ("collector", "Application Collector", "The Application Collector to use to build the index", UNITY_WEBAPPS_TYPE_APPLICATION_COLLECTOR, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } static void unity_webapps_local_url_index_init (UnityWebappsLocalUrlIndex *self) { self->priv = UNITY_WEBAPPS_LOCAL_URL_INDEX_GET_PRIVATE (self); self->priv->available_applications_by_name = NULL; self->priv->collector = NULL; } UnityWebappsUrlIndex * unity_webapps_local_url_index_new (UnityWebappsApplicationCollector *collector) { return UNITY_WEBAPPS_URL_INDEX (g_object_new (UNITY_WEBAPPS_TYPE_LOCAL_URL_INDEX, "collector", collector, NULL)); } UnityWebappsUrlIndex * unity_webapps_local_url_index_new_default () { UnityWebappsApplicationCollector *collector; collector = unity_webapps_application_collector_new_with_default_path (); return unity_webapps_local_url_index_new (collector); } gboolean unity_webapps_local_url_index_load_applications (UnityWebappsLocalUrlIndex *index) { GHashTable *manifests_by_name; unity_webapps_application_collector_search_path (index->priv->collector); if (index->priv->available_applications_by_name == NULL) { manifests_by_name = unity_webapps_application_collector_get_applications (index->priv->collector); index->priv->available_applications_by_name = g_hash_table_ref (manifests_by_name); } return TRUE; } UnityWebappsLocalAvailableApplication * unity_webapps_local_url_index_get_application_by_name (UnityWebappsLocalUrlIndex *index, const gchar *name) { return UNITY_WEBAPPS_LOCAL_AVAILABLE_APPLICATION (g_hash_table_lookup (index->priv->available_applications_by_name, name)); } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-package-mechanism.hlibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-package-mechani0000644000015301777760000000670212321247333033647 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-package-mechanism.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_PACKAGE_MECHANISM_H #define __UNITY_WEBAPPS_PACKAGE_MECHANISM_H #define UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM (unity_webapps_package_mechanism_get_type()) #define UNITY_WEBAPPS_PACKAGE_MECHANISM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM, UnityWebappsPackageMechanism)) #define UNITY_WEBAPPS_PACKAGE_MECHANISM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM, UnityWebappsPackageMechanismClass)) #define UNITY_WEBAPPS_IS_PACKAGE_MECHANISM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM)) #define UNITY_WEBAPPS_IS_PACKAGE_MECHANISM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM)) #define UNITY_WEBAPPS_PACKAGE_MECHANISM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM, UnityWebappsPackageMechanismClass)) typedef struct _UnityWebappsPackageMechanismPrivate UnityWebappsPackageMechanismPrivate; typedef struct _UnityWebappsPackageMechanism UnityWebappsPackageMechanism; struct _UnityWebappsPackageMechanism { GObject object; UnityWebappsPackageMechanismPrivate *priv; }; typedef struct _UnityWebappsPackageMechanismClass UnityWebappsPackageMechanismClass; typedef enum { UNITY_WEBAPPS_PACKAGE_STATUS_AVAILABLE, UNITY_WEBAPPS_PACKAGE_STATUS_INSTALLED, UNITY_WEBAPPS_PACKAGE_STATUS_UNAVAILABLE } UnityWebappsPackageStatus; typedef void (*UnityWebappsPackageMechanismStatusCallback) (UnityWebappsPackageMechanism *mechanism, const gchar *package, UnityWebappsPackageStatus status, gpointer user_data); struct _UnityWebappsPackageMechanismClass { GObjectClass parent_class; gboolean (*get_package_status) (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data); gboolean (*install_package) (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data); }; GType unity_webapps_package_mechanism_get_type (void) G_GNUC_CONST; gboolean unity_webapps_package_mechanism_get_package_status (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data); gboolean unity_webapps_package_mechanism_install_package (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data); #endif ././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-manifest.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-application-man0000644000015301777760000002767712321247333033744 0ustar pbusernogroup00000000000000/* * unity-webapps-application-manifest.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include "../unity-webapps-debug.h" #include "unity-webapps-application-manifest.h" struct _UnityWebappsApplicationManifestPrivate { gchar *base_path; gchar *name; gchar *package_name; gchar *domain; gchar *integration_version; GPtrArray *scripts; GPtrArray *requires; GPtrArray *includes; }; enum { PROP_0, PROP_NAME }; G_DEFINE_TYPE(UnityWebappsApplicationManifest, unity_webapps_application_manifest, G_TYPE_OBJECT) #define UNITY_WEBAPPS_APPLICATION_MANIFEST_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST, UnityWebappsApplicationManifestPrivate)) static void unity_webapps_application_manifest_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsApplicationManifest *self; self = UNITY_WEBAPPS_APPLICATION_MANIFEST (object); switch (prop_id) { case PROP_NAME: g_value_set_string (value, self->priv->name); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_application_manifest_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsApplicationManifest *self; self = UNITY_WEBAPPS_APPLICATION_MANIFEST (object); switch (prop_id) { case PROP_NAME: g_return_if_fail (self->priv->name == NULL); self->priv->name = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_application_manifest_finalize (GObject *object) { UnityWebappsApplicationManifest *manifest; manifest = UNITY_WEBAPPS_APPLICATION_MANIFEST (object); g_free (manifest->priv->name); g_free (manifest->priv->base_path); g_free (manifest->priv->package_name); g_free (manifest->priv->integration_version); g_free (manifest->priv->domain); g_ptr_array_unref (manifest->priv->scripts); g_ptr_array_unref (manifest->priv->includes); if (manifest->priv->requires != NULL) g_ptr_array_unref (manifest->priv->requires); } static void unity_webapps_application_manifest_class_init (UnityWebappsApplicationManifestClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_application_manifest_finalize; object_class->get_property = unity_webapps_application_manifest_get_property; object_class->set_property = unity_webapps_application_manifest_set_property; g_type_class_add_private (object_class, sizeof(UnityWebappsApplicationManifestPrivate)); } static void unity_webapps_application_manifest_init (UnityWebappsApplicationManifest *self) { self->priv = UNITY_WEBAPPS_APPLICATION_MANIFEST_GET_PRIVATE (self); self->priv->name = NULL; self->priv->package_name = NULL; self->priv->base_path = NULL; self->priv->integration_version = NULL; self->priv->scripts = NULL; self->priv->includes = NULL; self->priv->requires = NULL; } UnityWebappsApplicationManifest * unity_webapps_application_manifest_new () { return g_object_new (UNITY_WEBAPPS_TYPE_APPLICATION_MANIFEST, NULL); } static gboolean unity_webapps_application_manifest_gptrarray_from_jsonarray (UnityWebappsApplicationManifest *self, JsonArray *jsonarray, GPtrArray *gptrarray) { gint i; guint len; // TODO ADD CHECK TO RETURN FALSE IF PASSED A BAD GPTR_ARRAY len = json_array_get_length (jsonarray); for (i = 0; i < len; i++) { const gchar *element; element = json_array_get_string_element (jsonarray, i); g_ptr_array_add (gptrarray, g_strdup(element)); } g_ptr_array_add (gptrarray, NULL); return TRUE; } static gboolean unity_webapps_application_manifest_load_scripts (UnityWebappsApplicationManifest *self, JsonArray *scripts) { self->priv->scripts = g_ptr_array_new_with_free_func (g_free); return unity_webapps_application_manifest_gptrarray_from_jsonarray (self, scripts, self->priv->scripts); } static gboolean unity_webapps_application_manifest_load_requires (UnityWebappsApplicationManifest *self, JsonArray *requires) { self->priv->requires = g_ptr_array_new_with_free_func (g_free); return unity_webapps_application_manifest_gptrarray_from_jsonarray (self, requires, self->priv->requires); } static gboolean unity_webapps_application_manifest_load_includes (UnityWebappsApplicationManifest *self, JsonArray *includes) { self->priv->includes = g_ptr_array_new_with_free_func (g_free); return unity_webapps_application_manifest_gptrarray_from_jsonarray(self, includes, self->priv->includes); } gboolean unity_webapps_application_manifest_load_string_property (UnityWebappsApplicationManifest *self, JsonObject *root_object, const gchar *property_name, gchar **property) { gboolean has_property; const gchar *property_value; has_property = json_object_has_member (root_object, property_name); if (has_property == FALSE) { g_warning ("Failed to find %s member of JSON manifest", property_name); return FALSE; } property_value = json_object_get_string_member (root_object, property_name); *property = g_strdup (property_value); return TRUE; } gboolean unity_webapps_application_manifest_load_from_json (UnityWebappsApplicationManifest *self, JsonParser *parser) { JsonNode *root; JsonObject *root_object; JsonArray *scripts; JsonArray *includes; JsonArray *requires; gchar *tmp_package_name; gboolean has_scripts, has_includes, has_requires, parsed; parsed = TRUE; root = json_parser_get_root (parser); root_object = json_node_get_object (root); parsed = unity_webapps_application_manifest_load_string_property (self, root_object, "name", &self->priv->name); if (parsed == FALSE) { goto out; } parsed = unity_webapps_application_manifest_load_string_property (self, root_object, "domain", &self->priv->domain); parsed = unity_webapps_application_manifest_load_string_property (self, root_object, "package-name", &self->priv->package_name); if (parsed == FALSE) { goto out; } tmp_package_name = self->priv->package_name; self->priv->package_name = g_strconcat ("unity-webapps-", self->priv->package_name, NULL); g_free (tmp_package_name); tmp_package_name = self->priv->package_name; self->priv->package_name = g_utf8_strdown (tmp_package_name, -1); g_free (tmp_package_name); parsed = unity_webapps_application_manifest_load_string_property (self, root_object, "integration-version", &self->priv->integration_version); if (parsed == FALSE) { goto out; } has_scripts = json_object_has_member (root_object, "scripts"); if (has_scripts == FALSE) { g_warning ("Failed to find scripts member of JSON manifest"); parsed = FALSE; goto out; } scripts = json_object_get_array_member (root_object, "scripts"); unity_webapps_application_manifest_load_scripts (self, scripts); has_includes = json_object_has_member (root_object, "includes"); if (has_includes == FALSE) { g_warning ("Failed to find includes member of JSON manifest"); parsed = FALSE; goto out; } includes = json_object_get_array_member (root_object, "includes"); unity_webapps_application_manifest_load_includes (self, includes); has_requires = json_object_has_member (root_object, "requires"); if (has_requires) { requires = json_object_get_array_member (root_object, "requires"); unity_webapps_application_manifest_load_requires (self, requires); } out: return parsed; } gboolean unity_webapps_application_manifest_load_from_file (UnityWebappsApplicationManifest *self, const gchar *filename) { JsonParser *parser; GError *error; gboolean loaded; self->priv->base_path = g_path_get_dirname (filename); parser = json_parser_new (); error = NULL; json_parser_load_from_file (parser, filename, &error); if (error != NULL) { g_warning ("Failed to parse manifest at %s as json: %s", filename, error->message); g_object_unref (G_OBJECT (parser)); return FALSE; } loaded = unity_webapps_application_manifest_load_from_json (self, parser); g_object_unref (G_OBJECT (parser)); return loaded; } gboolean unity_webapps_application_manifest_load_from_data (UnityWebappsApplicationManifest *self, const gchar *data) { JsonParser *parser; GError *error; gboolean loaded; self->priv->base_path = NULL; parser = json_parser_new (); error = NULL; json_parser_load_from_file (parser, data, &error); if (error != NULL) { g_warning ("Failed to parse manifest as json: %s", error->message); g_object_unref (G_OBJECT (parser)); return FALSE; } loaded = unity_webapps_application_manifest_load_from_json (self, parser); g_object_unref (G_OBJECT (parser)); return loaded; } const gchar * unity_webapps_application_manifest_get_name (UnityWebappsApplicationManifest *manifest) { return manifest->priv->name; } const gchar * unity_webapps_application_manifest_get_domain (UnityWebappsApplicationManifest *manifest) { return manifest->priv->domain; } const gchar * unity_webapps_application_manifest_get_package_name (UnityWebappsApplicationManifest *manifest) { return manifest->priv->package_name; } const gchar ** unity_webapps_application_manifest_get_scripts (UnityWebappsApplicationManifest *manifest) { return (const gchar **)manifest->priv->scripts->pdata; } const gchar ** unity_webapps_application_manifest_get_requires (UnityWebappsApplicationManifest *manifest) { return manifest->priv->requires ? (const gchar **)manifest->priv->requires->pdata : NULL; } const gchar ** unity_webapps_application_manifest_get_includes (UnityWebappsApplicationManifest *manifest) { return (const gchar **)manifest->priv->includes->pdata; } const gchar * unity_webapps_application_manifest_get_base_path (UnityWebappsApplicationManifest *manifest) { return manifest->priv->base_path; } UnityWebappsApplicationManifest * unity_webapps_application_manifest_new_from_file (const gchar *filename) { UnityWebappsApplicationManifest *manifest; gboolean loaded; manifest = unity_webapps_application_manifest_new (); loaded = unity_webapps_application_manifest_load_from_file (manifest, filename); if (loaded == FALSE) { g_object_unref (G_OBJECT (manifest)); return NULL; } return manifest; } UnityWebappsApplicationManifest * unity_webapps_application_manifest_new_from_data (const gchar *data) { UnityWebappsApplicationManifest *manifest; gboolean loaded; manifest = unity_webapps_application_manifest_new (); loaded = unity_webapps_application_manifest_load_from_data (manifest, data); if (loaded == FALSE) { g_object_unref (G_OBJECT (manifest)); return NULL; } return manifest; } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-package-mechanism.clibunity-webapps-2.5.0~+14.04.20140409/src/libunity-webapps-repository/unity-webapps-package-mechani0000644000015301777760000000452012321247333033643 0ustar pbusernogroup00000000000000/* * unity-webapps-package-mechanism.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include "unity-webapps-package-mechanism.h" #include "../unity-webapps-debug.h" struct _UnityWebappsPackageMechanismPrivate { gpointer fill; }; G_DEFINE_ABSTRACT_TYPE(UnityWebappsPackageMechanism, unity_webapps_package_mechanism, G_TYPE_OBJECT) #define UNITY_WEBAPPS_PACKAGE_MECHANISM_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_PACKAGE_MECHANISM, UnityWebappsPackageMechanismPrivate)) static void unity_webapps_package_mechanism_class_init (UnityWebappsPackageMechanismClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (object_class, sizeof(UnityWebappsPackageMechanismPrivate)); } static void unity_webapps_package_mechanism_init (UnityWebappsPackageMechanism *mechanism) { mechanism->priv = UNITY_WEBAPPS_PACKAGE_MECHANISM_GET_PRIVATE (mechanism); } gboolean unity_webapps_package_mechanism_get_package_status (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data) { return UNITY_WEBAPPS_PACKAGE_MECHANISM_GET_CLASS (mechanism)->get_package_status (mechanism, name, callback, user_data); } gboolean unity_webapps_package_mechanism_install_package (UnityWebappsPackageMechanism *mechanism, const gchar *name, UnityWebappsPackageMechanismStatusCallback callback, gpointer user_data) { return UNITY_WEBAPPS_PACKAGE_MECHANISM_GET_CLASS (mechanism)->install_package (mechanism, name, callback, user_data); } libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-app-db.h0000644000015301777760000000274112321247333024527 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-app-db.h * Copyright (C) Canonical LTD 2012 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_APP_DB_H #define __UNITY_WEBAPPS_APP_DB_H gboolean unity_webapps_app_db_update_homepage (const gchar *name, const gchar *domain, const gchar *homepage); gchar *unity_webapps_app_db_get_homepage (const gchar *name, const gchar *domain); gboolean unity_webapps_app_db_open (); gboolean unity_webapps_app_db_add_action (const gchar *name, const gchar *domain, const gchar *label, const gchar *page); gboolean unity_webapps_app_db_clear_actions (const gchar *name, const gchar *domain); gboolean unity_webapps_app_db_get_actions (const gchar *name, const gchar *domain, gchar ***labels, gchar ***pages); #endif libunity-webapps-2.5.0~+14.04.20140409/src/webapps-indicator.xml0000644000015301777760000000276212321247333024546 0ustar pbusernogroup00000000000000 libunity-webapps-2.5.0~+14.04.20140409/src/webapps-context-daemon.xml0000644000015301777760000001230612321247333025512 0ustar pbusernogroup00000000000000 libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/0000755000015301777760000000000012321250157023325 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/util/0000755000015301777760000000000012321250157024302 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/util/unity-webapps-gio-utils.c0000644000015301777760000000454012321247333031174 0ustar pbusernogroup00000000000000/* * unity-webapps-gio-utils.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-dirs.h" #include "unity-webapps-gio-utils.h" #include "../unity-webapps-debug.h" gboolean unity_webapps_gio_utils_splice_files (GFile *resource_file, GFile *local_resource_file) { GInputStream *input_stream; GOutputStream *output_stream; GError *error; gboolean ret; error = NULL; input_stream = G_INPUT_STREAM (g_file_read (resource_file, NULL /* Cancellable */, &error)); if (error != NULL) { g_warning ("Error reading resource file to save: %s", error->message); g_error_free (error); return FALSE; } output_stream = G_OUTPUT_STREAM (g_file_replace (local_resource_file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL /* Cancellable */, &error)); if (error != NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Error opening temporary file to save resource: %s", error->message); g_error_free (error); g_object_unref (G_OBJECT (input_stream)); return FALSE; } g_output_stream_splice (output_stream, input_stream, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, NULL /* Cancellable */, &error); ret = TRUE; if (error != NULL) { g_warning ("Error writing open resource file to saved file: %s", error->message); g_error_free (error); ret = FALSE; } g_object_unref (G_OBJECT (input_stream)); g_object_unref (G_OBJECT (output_stream)); return ret; } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/util/unity-webapps-dirs.h0000644000015301777760000000226112321247333030224 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-dirs.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_DIRS_H #define __UNITY_WEBAPPS_DIRS_H const gchar *unity_webapps_dirs_get_user_dir (); const gchar *unity_webapps_dirs_get_icon_dir (); const gchar *unity_webapps_dirs_get_icon_theme_dir (); const gchar *unity_webapps_dirs_get_application_dir (); const gchar *unity_webapps_dirs_get_resource_dir (); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/util/unity-webapps-icon-theme.c0000644000015301777760000002366712321247333031323 0ustar pbusernogroup00000000000000/* * unity-webapps-icon-theme.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ." */ #include #include #include #include #include #include #include #include #include "unity-webapps-dirs.h" #include "unity-webapps-gio-utils.h" #include "unity-webapps-resource-cache.h" #include "../unity-webapps-debug.h" const gchar *const UNITY_WEBAPPS_ICON_THEME_INDEX_HEADER = "[Icon Theme]\n" "Name=Unity WebApps\n" "Comment=Webapps Icons\n" "Directories=apps/16, apps/22, apps/24, apps/32, apps/48, apps/64, apps/128, apps/192, \n" "[apps/16]\n" "Size=16\n" "Context=Applications\n" "Type=Fixed\n" "[apps/22]\n" "Size=22\n" "Context=Applications\n" "Type=Fixed\n" "[apps/24]\n" "Size=24\n" "Context=Applications\n" "Type=Fixed\n" "[apps/32]\n" "Size=32\n" "Context=Applications\n" "Type=Fixed\n" "[apps/48]\n" "Size=48\n" "Context=Applications\n" "Type=Fixed\n" "[apps/64]\n" "Size=64\n" "Context=Applications\n" "Type=Fixed\n" "[apps/128]\n" "Size=128\n" "Context=Applications\n" "Type=Fixed\n" "[apps/192]\n" "Size=192\n" "Context=Applications\n" "Type=Fixed\n"; #define include "unity-webapps-icon-theme.h" static gboolean theme_dir_has_index (const gchar *theme_dir) { gchar *index_file; gboolean ret; index_file = g_build_filename (theme_dir, "index.theme", NULL); ret = g_file_test (index_file, G_FILE_TEST_EXISTS); g_free (index_file); return ret; } static gboolean write_theme_index (const gchar *theme_dir) { gchar *index_file; gboolean ret; GError *error; index_file = g_build_filename (theme_dir, "index.theme", NULL); error = NULL; ret = g_file_set_contents (index_file, UNITY_WEBAPPS_ICON_THEME_INDEX_HEADER, -1, &error); if (error != NULL) { UNITY_WEBAPPS_NOTE (CONTEXT, "Error writing Unity Webapps Icon Theme Index: %s", error->message); g_error_free (error); } g_free (index_file); return ret; } static gboolean ensure_theme_directory (const gchar *theme_dir, const gchar *size) { gchar *icon_dir; gint status; gboolean ret; if (size != NULL) { icon_dir = g_build_filename (theme_dir, "apps", size, NULL); } else { icon_dir = g_build_filename (theme_dir, "apps", NULL); } ret = TRUE; if (g_file_test (icon_dir, G_FILE_TEST_EXISTS) == TRUE) { goto out; } status = g_mkdir (icon_dir, 0700); if (status < -1) { g_critical ("Error making Unity webapps icon theme dir: %s", g_strerror (errno)); ret = FALSE; goto out; } out: g_free (icon_dir); return ret; } static gboolean ensure_theme_directories (const gchar *theme_dir) { gboolean ret; ret = ensure_theme_directory (theme_dir, NULL); ret = ret && ensure_theme_directory (theme_dir, "16"); ret = ret && ensure_theme_directory (theme_dir, "22"); ret = ret && ensure_theme_directory (theme_dir, "24"); ret = ret && ensure_theme_directory (theme_dir, "32"); ret = ret && ensure_theme_directory (theme_dir, "48"); ret = ret && ensure_theme_directory (theme_dir, "64"); ret = ret && ensure_theme_directory (theme_dir, "128"); ret = ret && ensure_theme_directory (theme_dir, "192"); return ret; } static gboolean create_empty_theme (const gchar *theme_dir) { gboolean ret; ret = write_theme_index (theme_dir); ret = ret && ensure_theme_directories (theme_dir); return ret; } static gboolean ensure_theme_directories_exist () { const gchar *theme_dir; gboolean ret; theme_dir = unity_webapps_dirs_get_icon_theme_dir (); ret = TRUE; if (theme_dir_has_index (theme_dir) == FALSE) { ret = create_empty_theme (theme_dir); } return ret; } gchar * unity_webapps_icon_theme_get_application_icon_path (const gchar *icon_name) { const gchar *icon_dir; gchar *local_icon_path; icon_dir = unity_webapps_dirs_get_icon_dir (); local_icon_path = g_build_filename (icon_dir, icon_name, NULL); return local_icon_path; } static gchar * get_themed_icon_path (const gchar *full_icon_name, const gchar *size) { gchar *path; const gchar *theme_dir; if (ensure_theme_directories_exist() == FALSE) { return NULL; } theme_dir = unity_webapps_dirs_get_icon_theme_dir (); path = g_build_filename (theme_dir, "apps", size, full_icon_name, NULL); return path; } static void write_themed_icon(const gchar *full_icon_name, const gchar *size, GdkPixbuf *pb) { gchar *path; path = get_themed_icon_path (full_icon_name, size); if (path == NULL) { UNITY_WEBAPPS_NOTE (CONTEXT, "Failed to get path to save themed icon at. Icon directory not readable?"); return; } gdk_pixbuf_save (pb, path, "png", NULL, NULL); // TODO: Error g_free (path); } gboolean unity_webapps_icon_theme_add_icon (const gchar *icon_name, const gchar *icon_url, gint size) { GFile *resource_file; GFileInputStream *input_stream; gchar *resource_path, *sizes, *full_icon_name; GdkPixbuf *pb, *scaled_pb; resource_path = unity_webapps_resource_cache_lookup_uri (icon_url); // TODO: Better error handlign? When does this fail if (resource_path == NULL) { return FALSE; } resource_file = g_file_new_for_path (resource_path); input_stream = g_file_read (resource_file, NULL, NULL); // TODO: Error pb = gdk_pixbuf_new_from_stream (G_INPUT_STREAM (input_stream), NULL, NULL); scaled_pb = gdk_pixbuf_scale_simple (pb, size, size, GDK_INTERP_HYPER); full_icon_name = g_strdup_printf("%s.png", icon_name); sizes = g_strdup_printf("%d", size); write_themed_icon (full_icon_name, sizes, scaled_pb); g_object_unref (G_OBJECT (pb)); g_object_unref (G_OBJECT (scaled_pb)); g_object_unref (G_OBJECT (input_stream)); g_object_unref (G_OBJECT (resource_file)); g_free (resource_path); g_free (full_icon_name); g_free (sizes); return TRUE; } static GdkPixbuf * unity_webapps_icon_theme_get_themed_application_icon_pixbuf (const gchar *icon_name) { GtkIconTheme *icon_theme; GdkPixbuf *ret; GError *error; icon_theme = gtk_icon_theme_new (); gtk_icon_theme_set_custom_theme (icon_theme, "unity-webapps-applications"); #ifdef UNITY_WEBAPPS_TEST_BUILD gtk_icon_theme_prepend_search_path (icon_theme, g_getenv ("UNITY_WEBAPPS_CONTEXT_ICON_THEME_DIR")); #endif if (gtk_icon_theme_has_icon (icon_theme, icon_name) == FALSE) icon_name = "application-default-icon"; error = NULL; ret = gtk_icon_theme_load_icon (icon_theme, icon_name, 128, 0, &error); if (error != NULL) { g_warning ("Failed to get themed application icon (%s): %s", icon_name, error->message); g_error_free (error); } g_object_unref (G_OBJECT (icon_theme)); return ret; } static gboolean unity_webapps_icon_theme_copy_themed_application_icon (const gchar *full_icon_name, const gchar *resource_uri) { GdkPixbuf *icon_pb; const gchar *icon_name; gchar *icon_path; gboolean ret; GError *error; icon_name = resource_uri + (7 * sizeof(gchar)); // Strip "icon://" icon_pb = unity_webapps_icon_theme_get_themed_application_icon_pixbuf (icon_name); if (icon_pb == NULL) { return FALSE; } icon_path = unity_webapps_icon_theme_get_application_icon_path (full_icon_name); error = NULL; ret = TRUE; gdk_pixbuf_save (icon_pb, icon_path, "png", &error, NULL); if (error != NULL) { g_warning ("Error saving application icon: %s", error->message); g_error_free (error); ret = FALSE; } g_free (icon_path); g_object_unref (G_OBJECT (icon_pb)); return ret; } gchar * unity_webapps_icon_theme_update_application_icon (const gchar *icon_name, const gchar *resource_uri) { GFile *resource_file; GFileInputStream *input_stream; GdkPixbuf *pb; gchar *resource_path, *icon_path, *full_icon_name; full_icon_name = g_strdup_printf ("%s.png", icon_name); if (g_str_has_prefix (resource_uri, "icon://")) { gboolean copied; copied = unity_webapps_icon_theme_copy_themed_application_icon (full_icon_name, resource_uri); return copied ? full_icon_name : NULL; } resource_path = unity_webapps_resource_cache_lookup_uri (resource_uri); icon_path = unity_webapps_icon_theme_get_application_icon_path (full_icon_name); if (resource_path == NULL) { UNITY_WEBAPPS_NOTE (CONTEXT, "Failed to update application icon"); return full_icon_name; } resource_file = g_file_new_for_path (resource_path); if (resource_file == NULL) { g_warning ("Invalid icon URI: %s", resource_uri); g_free (resource_path); g_free (icon_path); return full_icon_name; } input_stream = g_file_read (resource_file, NULL, NULL); // TODO Error pb = gdk_pixbuf_new_from_stream (G_INPUT_STREAM (input_stream), NULL, NULL); gdk_pixbuf_save (pb, icon_path, "png", NULL, NULL); // TODO: Error write_themed_icon (full_icon_name, "48", pb); g_object_unref (G_OBJECT (resource_file)); g_object_unref (G_OBJECT (input_stream)); g_object_unref (pb); g_free (resource_path); g_free (icon_path); return full_icon_name; } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/util/unity-webapps-dirs.c0000644000015301777760000001050412321247333030216 0ustar pbusernogroup00000000000000/* * unity-webapps-dirs.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include "unity-webapps-dirs.h" /* * Get the unity webapps user storage directory (and ensure it exists). * Currently this is $HOME/.local/share/unity-webapps */ static gchar * unity_webapps_dirs_try_make (gchar *dir) { int status; if (g_file_test (dir, G_FILE_TEST_EXISTS) == TRUE) { return dir; } status = g_mkdir (dir, 0700); if (status < -1) { g_critical("Error making Unity Webapps directory (%s): %s", dir, g_strerror(errno)); return NULL; } return dir; } const gchar * unity_webapps_dirs_get_user_dir () { const gchar *envdir; static gchar *userdir = NULL; if (userdir != NULL) return userdir; envdir = g_getenv ("UNITY_WEBAPPS_CONTEXT_USER_DIR"); if (envdir != NULL) { userdir = g_strdup (envdir); return userdir; } userdir = g_build_filename(g_get_user_data_dir(), "unity-webapps", NULL); userdir = unity_webapps_dirs_try_make (userdir); return userdir; } /* * Get the unity webapps icon storage directory and ensure it exists, * currently this is a folder "icons" inside the user storage directory. */ const gchar * unity_webapps_dirs_get_icon_dir () { static gchar *icondir = NULL; const gchar *envdir; if (icondir != NULL) return icondir; envdir = g_getenv("UNITY_WEBAPPS_CONTEXT_ICON_DIR"); if (envdir != NULL) { icondir = g_strdup (envdir); return icondir; } icondir = g_build_filename (g_get_home_dir(), ".icons", NULL); icondir = unity_webapps_dirs_try_make (icondir); return icondir; } const gchar * unity_webapps_dirs_get_icon_theme_dir () { static gchar *iconthemedir = NULL; gchar *icondir; const gchar *envdir; if (iconthemedir != NULL) return iconthemedir; envdir = g_getenv("UNITY_WEBAPPS_CONTEXT_ICON_THEME_DIR"); if (envdir != NULL) { return g_strdup (envdir); } icondir = g_build_filename (g_get_home_dir(), ".local", "share", "icons", NULL); icondir = unity_webapps_dirs_try_make (icondir); g_free (icondir); iconthemedir = g_build_filename (g_get_home_dir(), ".local", "share", "icons", "unity-webapps", NULL); iconthemedir = unity_webapps_dirs_try_make (iconthemedir); return iconthemedir; } /* * Get the directory to store desktop files in */ const gchar * unity_webapps_dirs_get_application_dir () { static gchar *applicationdir = NULL; const gchar *envdir; if (applicationdir != NULL) return applicationdir; envdir = g_getenv("UNITY_WEBAPPS_CONTEXT_APPLICATION_DIR"); if (envdir != NULL) { applicationdir = g_strdup(envdir); return applicationdir; } /* * This is mostly useful for testing, i.e. we want to write the .desktop file to a temporary directory * and verify its contents. * TODO: We should have a test that does this! */ applicationdir = g_build_filename (g_get_user_data_dir(), "applications", NULL); applicationdir = unity_webapps_dirs_try_make (applicationdir); return applicationdir; } const gchar * unity_webapps_dirs_get_resource_dir () { static gchar *resourcedir = NULL; const gchar *userdir; const gchar *envdir; envdir = g_getenv("UNITY_WEBAPPS_CONTEXT_RESOURCE_DIR"); if (envdir != NULL) { resourcedir = g_strdup(envdir); return resourcedir; } userdir = unity_webapps_dirs_get_user_dir (); resourcedir = g_build_filename (userdir, "resources", NULL); resourcedir = unity_webapps_dirs_try_make (resourcedir); return resourcedir; } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/util/unity-webapps-icon-theme.h0000644000015301777760000000236612321247333031321 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-icon-theme.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_ICON_THEME_H #define __UNITY_WEBAPPS_ICON_THEME_H gchar *unity_webapps_icon_theme_update_application_icon (const gchar *icon_name, const gchar *icon_url); gchar *unity_webapps_icon_theme_get_application_icon_path (const gchar *full_icon_name); gboolean unity_webapps_icon_theme_add_icon (const gchar *icon_name, const gchar *icon_url, gint size); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/util/unity-webapps-gio-utils.h0000644000015301777760000000203412321247333031175 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-gio-utils.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_GIO_UTILS_H #define __UNITY_WEBAPPS_GIO_UTILS_H gboolean unity_webapps_gio_utils_splice_files (GFile *resource_file, GFile *local_resource_file); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-indicator-context.c0000644000015301777760000003330512321247333031742 0ustar pbusernogroup00000000000000/* * unity-webapps-indicator-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-indicator-context.h" #include "unity-webapps-indicator-manager.h" #include "unity-webapps-dbus-defs.h" #include "unity-webapps-dirs.h" #include "unity-webapps-debug.h" #include "unity-webapps-interest-tracker.h" #include "unity-webapps-telepathy-presence-manager.h" #include "config.h" static void emit_action_invoked_signal (UnityWebappsIndicatorContext *indicator_context, const gchar *action) { GError *error; UNITY_WEBAPPS_NOTE (INDICATOR, "Emitting ActionInvoked signal (%s)", action); error = NULL; g_dbus_connection_emit_signal (indicator_context->connection, NULL, UNITY_WEBAPPS_INDICATOR_PATH, UNITY_WEBAPPS_INDICATOR_IFACE, "ActionInvoked", g_variant_new ("(s)", (gchar *)action, NULL), &error); if (error != NULL) { g_warning ("Error emitting ActionInvoked signal (from indicator) in indicator context: %s", error->message); g_error_free (error); } } /* * When an action menuitem is activated. We need to emit our action * signal. */ static void unity_webapps_indicator_context_on_action_invoked (UnityWebappsActionManager *manager, const gchar *action_path, gpointer user_data) { UnityWebappsIndicatorContext *indicator_context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling Menuitem activated signal"); indicator_context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_context_daemon_raise_most_recent (); UNITY_WEBAPPS_NOTE (INDICATOR, "Menuitem label is: %s", action_path); emit_action_invoked_signal (indicator_context, action_path); } static void unity_webapps_indicator_context_application_activated_callback (UnityWebappsInterestManager *manager, gpointer user_data) { UNITY_WEBAPPS_NOTE (INDICATOR, "Got server-displayed callback"); unity_webapps_context_daemon_raise_most_recent (); } static void unity_webapps_indicator_context_indicator_activated_callback (UnityWebappsInterestManager *manager, const gchar *name, gpointer user_data) { UnityWebappsIndicatorContext *indicator_context; UNITY_WEBAPPS_NOTE (INDICATOR, "Got user-displayed callback (%s)", name); indicator_context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_context_daemon_raise_most_recent(); emit_action_invoked_signal (indicator_context, name); } static gboolean on_handle_show_indicator (UnityWebappsGenIndicator *indicator, GDBusMethodInvocation *invocation, const gchar *name, gint interest_id, gpointer user_data) { UnityWebappsIndicatorContext *context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling ShowIndicator call: %s", name); context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_indicator_model_show_indicator_for_interest (context->indicator_model, name, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_clear_indicator (UnityWebappsGenIndicator *indicator, GDBusMethodInvocation *invocation, const gchar *name, gint interest_id, gpointer user_data) { UnityWebappsIndicatorContext *context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling ClearIndicator call: %s", name); context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_indicator_model_clear_indicator_for_interest (context->indicator_model, name, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_clear_indicators (UnityWebappsGenIndicator *indicator, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { UnityWebappsIndicatorContext *context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling ClearIndicator calls"); context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_indicator_model_clear_indicators_for_interest (context->indicator_model, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_set_property (UnityWebappsGenIndicator *indicator, GDBusMethodInvocation *invocation, const gchar *name, const gchar *property, const gchar *value, gint interest_id, gpointer user_data) { UnityWebappsIndicatorContext *context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling SetProperty call for %s: %s->%s", name, property, value); context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_indicator_model_set_indicator_property_for_interest (context->indicator_model, name, property, g_variant_new("s", value, NULL), interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_set_property_icon (UnityWebappsGenIndicator *indicator, GDBusMethodInvocation *invocation, const gchar *name, const gchar *property, const gchar *value, gint interest_id, gpointer user_data) { UnityWebappsIndicatorContext *context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling SetPropertyIcon call for %s: %s->%s", name, property, value); context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_indicator_model_set_indicator_property_for_interest (context->indicator_model, name, property, g_variant_new("s", value, NULL), interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_add_action (UnityWebappsGenIndicator *indicator, GDBusMethodInvocation *invocation, const gchar *label, gint interest_id, gpointer user_data) { UnityWebappsIndicatorContext *context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling AddAction call, label: %s", label); context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_indicator_view_show (context->indicator_view); // TODO: FIXME: // indicate_server_show (unity_webapps_indicator_context_get_server (context)); unity_webapps_action_manager_add_action (context->action_manager, label, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_remove_action (UnityWebappsGenIndicator *indicator, GDBusMethodInvocation *invocation, const gchar *label, gint interest_id, gpointer user_data) { UnityWebappsIndicatorContext *context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling RemoveAction call, label: %s", label); context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_action_manager_remove_action (context->action_manager, label, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_remove_actions (UnityWebappsGenIndicator *indicator, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { UnityWebappsIndicatorContext *context; UNITY_WEBAPPS_NOTE (INDICATOR, "Handling RemoveActions call"); context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_action_manager_remove_all_actions (context->action_manager, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static void export_object (GDBusConnection *connection, UnityWebappsIndicatorContext *indicator_context) { GError *error; indicator_context->indicator_service_interface = unity_webapps_gen_indicator_skeleton_new (); g_signal_connect (indicator_context->indicator_service_interface, "handle-show-indicator", G_CALLBACK (on_handle_show_indicator), indicator_context); g_signal_connect (indicator_context->indicator_service_interface, "handle-clear-indicator", G_CALLBACK (on_handle_clear_indicator), indicator_context); g_signal_connect (indicator_context->indicator_service_interface, "handle-clear-indicators", G_CALLBACK (on_handle_clear_indicators), indicator_context); g_signal_connect (indicator_context->indicator_service_interface, "handle-set-property", G_CALLBACK (on_handle_set_property), indicator_context); g_signal_connect (indicator_context->indicator_service_interface, "handle-set-property-icon", G_CALLBACK (on_handle_set_property_icon), indicator_context); g_signal_connect (indicator_context->indicator_service_interface, "handle-add-action", G_CALLBACK (on_handle_add_action), indicator_context); g_signal_connect (indicator_context->indicator_service_interface, "handle-remove-action", G_CALLBACK (on_handle_remove_action), indicator_context); g_signal_connect (indicator_context->indicator_service_interface, "handle-remove-actions", G_CALLBACK (on_handle_remove_actions), indicator_context); error = NULL; g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (indicator_context->indicator_service_interface), connection, UNITY_WEBAPPS_INDICATOR_PATH, &error); if (error != NULL) { g_error ("Error exporting Unity Webapps Indicator object: %s", error->message); g_error_free (error); return; } UNITY_WEBAPPS_NOTE (INDICATOR, "Exported Indicator object"); } static void on_presence_changed (UnityWebappsPresenceManager *presence_manager, gchar *status, gchar *message, gpointer user_data) { UnityWebappsIndicatorContext *indicator_context; UNITY_WEBAPPS_NOTE (INDICATOR, "Most available presence changed to %s", status); indicator_context = (UnityWebappsIndicatorContext *)user_data; unity_webapps_gen_indicator_set_presence (indicator_context->indicator_service_interface, status); } static void create_presence_manager (UnityWebappsIndicatorContext *indicator_context) { indicator_context->presence_manager = unity_webapps_telepathy_presence_manager_new (); g_signal_connect (indicator_context->presence_manager, "presence-changed", G_CALLBACK (on_presence_changed), indicator_context); } UnityWebappsIndicatorContext * unity_webapps_indicator_context_new (GDBusConnection *connection, const gchar *desktop_path, const gchar *canonical_name, UnityWebappsInterestTracker *interest_tracker) { UnityWebappsIndicatorContext *indicator_context; gchar *menu_dbus_path; UNITY_WEBAPPS_NOTE (INDICATOR, "Creating new UnityWebappsIndicatorContext object"); indicator_context = g_malloc0 (sizeof (UnityWebappsIndicatorContext)); indicator_context->connection = g_object_ref (G_OBJECT (connection)); indicator_context->canonical_name = g_strdup (canonical_name); indicator_context->desktop_path = g_strdup (desktop_path); indicator_context->num_actions = 0; menu_dbus_path = g_strdup_printf("/com/canonical/Unity/WebApps/%s/indicate/menu", indicator_context->canonical_name); indicator_context->action_manager = unity_webapps_action_manager_new_flat (interest_tracker, menu_dbus_path); unity_webapps_action_manager_set_track_activity (indicator_context->action_manager, FALSE); g_signal_connect (indicator_context->action_manager, "action-invoked", G_CALLBACK (unity_webapps_indicator_context_on_action_invoked), indicator_context); indicator_context->indicator_manager = unity_webapps_indicator_manager_new (desktop_path, unity_webapps_interest_tracker_get_interest_manager (interest_tracker)); indicator_context->indicator_model = unity_webapps_indicator_manager_get_model (indicator_context->indicator_manager); indicator_context->indicator_view = unity_webapps_indicator_manager_get_view (indicator_context->indicator_manager); g_signal_connect (indicator_context->indicator_manager, "application-activated", G_CALLBACK (unity_webapps_indicator_context_application_activated_callback), indicator_context); g_signal_connect (indicator_context->indicator_manager, "indicator-activated", G_CALLBACK (unity_webapps_indicator_context_indicator_activated_callback), indicator_context); export_object (connection, indicator_context); // create_indicate_server (indicator_context); create_presence_manager (indicator_context); g_free (menu_dbus_path); return indicator_context; } void unity_webapps_indicator_context_free (UnityWebappsIndicatorContext *indicator_context) { UNITY_WEBAPPS_NOTE (INDICATOR, "Finalizing UnityWebappsIndicatorContext object"); g_object_unref (G_OBJECT (indicator_context->indicator_service_interface)); g_free (indicator_context->canonical_name); g_free (indicator_context->desktop_path); g_object_unref (G_OBJECT (indicator_context->connection)); g_object_unref (G_OBJECT (indicator_context->presence_manager)); g_object_unref (G_OBJECT (indicator_context->action_manager)); g_object_unref (G_OBJECT (indicator_context->indicator_manager)); g_free (indicator_context); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-context-daemon.h0000644000015301777760000000410012321247333031225 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-context-daemon.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_CONTEXT_DAEMON_H #define __UNITY_WEBAPPS_CONTEXT_DAEMON_H #include #include #include typedef struct _UnityWebappsContextDaemon UnityWebappsContextDaemon; #include "unity-webapps-notification-context.h" #include "unity-webapps-indicator-context.h" #include "unity-webapps-music-player-context.h" #include "unity-webapps-launcher-context.h" struct _UnityWebappsContextDaemon { GHashTable *interest_vanished_ids; GHashTable *name_interest_counts; guint interests; gchar **dnd_mimes; gchar *desktop_file_name; gchar *icon_file_name; gchar *icon_theme_dir; UnityWebappsNotificationContext *notification_context; UnityWebappsIndicatorContext *indicator_context; UnityWebappsMusicPlayerContext *music_player_context; UnityWebappsLauncherContext *launcher_context; }; UnityWebappsContextDaemon *unity_webapps_context_daemon_new(); void unity_webapps_context_daemon_free (UnityWebappsContextDaemon *daemon); void unity_webapps_context_daemon_emit_raise (GDBusConnection *connection, gint interest_id, const gchar * const *files); void unity_webapps_context_daemon_raise_interest (gint interest_id); void unity_webapps_context_daemon_raise_most_recent(); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/Makefile.am0000644000015301777760000000716612321247333025375 0ustar pbusernogroup00000000000000EXTRA_DIST = AM_CPPFLAGS = \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ $(TELEPATHY_GLIB_CFLAGS) \ $(UNITY_WEBAPPS_DEBUG_CFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/src/context-daemon/resource-cache \ -I$(top_srcdir)/src/context-daemon/indicator -I$(top_srcdir)/src/context-daemon/util \ -I$(top_srcdir)/src/context-daemon/presence -I$(top_srcdir)/src/context-daemon/interest-tracking \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) libexec_PROGRAMS = \ unity-webapps-context-daemon unity_webapps_context_daemon_SOURCES = \ unity-webapps-context-daemon.c \ unity-webapps-context-daemon.h \ unity-webapps-application-info.c \ unity-webapps-application-info.h \ unity-webapps-preinstalled-application-info.c \ unity-webapps-preinstalled-application-info.h \ interest-tracking/unity-webapps-interest-manager.c \ interest-tracking/unity-webapps-interest-manager.h \ unity-webapps-action-manager.c \ unity-webapps-action-manager.h \ interest-tracking/unity-webapps-window-tracker.c \ interest-tracking/unity-webapps-window-tracker.h \ interest-tracking/unity-webapps-window-tracker-wnck.c \ interest-tracking/unity-webapps-window-tracker-wnck.h \ interest-tracking/unity-webapps-window-tracker-dbus-controllable.c \ interest-tracking/unity-webapps-window-tracker-dbus-controllable.h \ interest-tracking/unity-webapps-interest-tracker.c \ interest-tracking/unity-webapps-interest-tracker.h \ presence/unity-webapps-presence-manager.c \ presence/unity-webapps-presence-manager.h \ presence/unity-webapps-telepathy-presence-manager.c \ presence/unity-webapps-telepathy-presence-manager.h \ resource-cache/unity-webapps-resource-db.c \ resource-cache/unity-webapps-resource-db.h \ resource-cache/unity-webapps-resource-cache.c \ resource-cache/unity-webapps-resource-cache.h \ resource-cache/unity-webapps-resource-factory.c \ resource-cache/unity-webapps-resource-factory.h \ util/unity-webapps-gio-utils.c \ util/unity-webapps-gio-utils.h \ util/unity-webapps-icon-theme.c \ util/unity-webapps-icon-theme.h \ util/unity-webapps-dirs.c \ util/unity-webapps-dirs.h \ unity-webapps-notification-context.c \ unity-webapps-notification-context.h \ indicator/unity-webapps-indicator-model.c \ indicator/unity-webapps-indicator-model.h \ indicator/unity-webapps-indicator-model-controller.c \ indicator/unity-webapps-indicator-model-controller.h \ indicator/unity-webapps-indicator-view.c \ indicator/unity-webapps-indicator-view.h \ indicator/unity-webapps-indicator-view-messaging-menu.c \ indicator/unity-webapps-indicator-view-messaging-menu.h \ indicator/unity-webapps-indicator-manager.c \ indicator/unity-webapps-indicator-manager.h \ unity-webapps-indicator-context.c \ unity-webapps-indicator-context.h \ unity-webapps-music-player-context.c \ unity-webapps-music-player-context.h \ unity-webapps-launcher-context.c \ unity-webapps-launcher-context.h \ unity-webapps-debug.c \ ../unity-webapps-string-utils.c \ ../unity-webapps-string-utils.h \ ../unity-webapps-desktop-infos.c \ ../unity-webapps-desktop-infos.h \ ../unity-webapps-app-db.c \ ../unity-webapps-app-db.h \ ../unity-webapps-debug.h \ ../unity-webapps-gen-context.c \ ../unity-webapps-gen-notification.c \ ../unity-webapps-gen-indicator.c \ ../unity-webapps-gen-music-player.c \ ../unity-webapps-gen-launcher.c unity_webapps_context_daemon_LDADD = $(UNITY_WEBAPPS_LIBS) $(UNITY_WEBAPPS_DAEMON_LIBS) $(TELEPATHY_GLIB_LIBS) $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-context-daemon.c0000644000015301777760000012352012321247333031230 0ustar pbusernogroup00000000000000/* * unity-webapps-context-daemon.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "config.h" #include #include #include #include "unity-webapps-context-daemon.h" #include "unity-webapps-gen-context.h" #include "unity-webapps-dbus-defs.h" #include "unity-webapps-application-info.h" #include "unity-webapps-preinstalled-application-info.h" //#include "unity-webapps-dirs.h" #include "unity-webapps-resource-db.h" #include "unity-webapps-app-db.h" #include "unity-webapps-icon-theme.h" #include "unity-webapps-debug.h" #include "unity-webapps-interest-manager.h" #include "unity-webapps-action-manager.h" #include "unity-webapps-interest-tracker.h" #include "unity-webapps-wire-version.h" #define WNCK_I_KNOW_THIS_IS_UNSTABLE #include /* * If a local icon file has been downloaded more recently than this time (in seconds) we will simply use our existing * download. In the future maybe this should be more intelligent and use HTTP IfModifiedSince * */ #define UNITY_WEBAPPS_CONTEXT_ICON_STALE_TIME 60 /*seconds*/ * 30 /*minutes*/ static GMainLoop *mainloop = NULL; static GDBusConnection *session_bus = NULL; static UnityWebappsGenContext *context_service_interface; static UnityWebappsInterestTracker *interest_tracker = NULL; static UnityWebappsActionManager *action_manager = NULL; static UnityWebappsInterestManager *interest_manager = NULL; static void export_object (GDBusConnection *connection, UnityWebappsContextDaemon *daemon); static void emit_context_ready (GDBusConnection *connection); static void emit_no_interest (GDBusConnection *connection, gboolean user_abandoned); static void emit_interest_appeared (GDBusConnection *connection, gint interest_id); static void emit_interest_vanished (GDBusConnection *connection, gint interest_id); void unity_webapps_context_daemon_emit_close (GDBusConnection *connection, gint interest_id); void unity_webapps_context_daemon_emit_view_is_active_changed (GDBusConnection *connection, gint interest_id, gboolean is_active); void unity_webapps_context_daemon_emit_view_location_changed (GDBusConnection *connection, gint interest_id, const gchar *location); void unity_webapps_context_daemon_emit_view_window_changed (GDBusConnection *connection, gint interest_id, guint64 window); void unity_webapps_context_daemon_emit_preview_requested (GDBusConnection *connection, gint interest_id); void unity_webapps_context_daemon_emit_action_invoked (GDBusConnection *connection, const gchar *name); static UnityWebappsApplicationInfo *application_info = NULL; static void emit_no_interest (GDBusConnection *connection, gboolean user_abandoned) { GError *error; error = NULL; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting NoInterest signal"); g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "NoInterest", g_variant_new ("(b)", user_abandoned, NULL), &error /* Error */); if (error != NULL) { /* * TODO: Should this be fatal? If this fails we can not guarantee that the daemon will ever close... */ g_critical ("Error emitting NoInterest signal (from context daemon): %s", error->message); g_error_free (error); return; } } static void emit_context_ready (GDBusConnection *connection) { GError *error; error = NULL; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting ContextReady signal"); g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "ContextReady", g_variant_new ("(s)", UNITY_WEBAPPS_WIRE_PROTOCOL_VERSION, NULL), &error); /* * TODO: * Maybe this should be a fatal error instead of a critical. * In this case the service isn't managing the daemon, and so we can't be assured * the daemon will ever quit. */ if (error != NULL) { g_critical("Error emiting ContextReady signal: %s", error->message); g_error_free (error); return; } } static void emit_interest_appeared (GDBusConnection *connection, gint interest_id) { GError *error; error = NULL; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting InterestAppeared signal"); g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "InterestAppeared", g_variant_new ("(i)", interest_id, NULL), &error); if (error != NULL) { g_critical("Error emiting InterestAppeared signal: %s", error->message); g_error_free (error); return; } } static void emit_interest_vanished (GDBusConnection *connection, gint interest_id) { GError *error; error = NULL; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting InterestVanished signal"); g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "InterestVanished", g_variant_new ("(i)", interest_id, NULL), &error); if (error != NULL) { g_critical("Error emiting InterestVanished signal: %s", error->message); g_error_free (error); return; } } static void bus_filter_service_ready (GDBusConnection *connection, const gchar *sender, const gchar *object, const gchar *interface, const gchar *signal, GVariant *params, gpointer user_data) { if (g_strcmp0(signal, "ServiceReady") != 0) { g_warning ("Unexpected signal on context daemon instance: %s", signal); return; } /* * If we have received the ServiceReady signal, it means that the service has crashed. * So, we should emit the ContextReady signal again, such that the new service daemon * can track the context. */ UNITY_WEBAPPS_NOTE (CONTEXT, "Got ServiceReady signal"); emit_context_ready (session_bus); } static gint add_interest (GDBusConnection *connection, UnityWebappsContextDaemon *daemon, const gchar *name) { return unity_webapps_interest_manager_add_interest (interest_manager, name); } /* * A client has explicitly removed it's interest. If we have interests we need to emit the signal. */ static void lost_interest (GDBusConnection *connection, UnityWebappsContextDaemon *daemon, gint interest_id, gboolean user_abandoned) { unity_webapps_interest_manager_remove_interest (interest_manager, interest_id, user_abandoned); } static void bus_get_cb (GObject *object, GAsyncResult *res, gpointer user_data) { GError *error = NULL; GDBusConnection *connection = g_bus_get_finish(res, &error); UnityWebappsContextDaemon *daemon; if (error != NULL) { g_error("Unable to get session bus: %s", error->message); g_error_free(error); return; } session_bus = connection; UNITY_WEBAPPS_NOTE (CONTEXT, "Connected to the Session Bus"); // TODO: Investigate free on shutdown, just for correctness. daemon = unity_webapps_context_daemon_new (); export_object (session_bus, daemon); emit_context_ready (session_bus); g_dbus_connection_signal_subscribe (session_bus, NULL, UNITY_WEBAPPS_SERVICE_IFACE, "ServiceReady", NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE, bus_filter_service_ready, daemon /* user data */, NULL /* destroy notify */); } static gboolean parse_args (gint argc, gchar **argv, gchar **name, gchar **domain, gchar **icon_url, gchar **mime_types, gchar **desktop_name) { if (argc != 5 && argc != 6) return FALSE; *name = argv[1]; *domain = argv[2]; *icon_url = argv[3]; *mime_types = argv[4]; if (argc == 6) { *desktop_name = argv[5]; } else { *desktop_name = NULL; } if (g_strcmp0 (*icon_url, "none") == 0) { *icon_url = NULL; } if (g_strcmp0 (*mime_types, "none") == 0) { *mime_types = NULL; } return TRUE; } gint main (gint argc, gchar **argv) { gchar *name, *domain, *icon_url, *mime_types, *desktop_name; gtk_init (&argc, &argv); bindtextdomain (GETTEXT_PACKAGE, NULL); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); desktop_name = NULL; if (!parse_args (argc, argv, &name, &domain, &icon_url, &mime_types, &desktop_name)) return 1; #ifdef UNITY_WEBAPPS_ENABLE_DEBUG unity_webapps_debug_initialize_flags (); #endif unity_webapps_resource_db_open (); if (desktop_name == NULL) { application_info = unity_webapps_application_info_new (name, domain, icon_url, mime_types); } else { application_info = unity_webapps_preinstalled_application_info_new (name, domain, icon_url, mime_types, desktop_name); } wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); g_bus_get(G_BUS_TYPE_SESSION, NULL, /* Cancellable */ bus_get_cb, NULL /* User data */); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); return 0; } static gboolean on_handle_add_icon (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, const gchar *icon_url, gint size, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling AddIcon call %s with size %d", icon_url, size); g_dbus_method_invocation_return_value (invocation, NULL); unity_webapps_application_info_add_icon_at_size (application_info, icon_url, size); return TRUE; } static gboolean on_handle_get_icon_name (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gpointer user_data) { gchar *icon_file_name; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling GetIconName call"); icon_file_name = unity_webapps_application_info_get_desktop_icon_name (application_info, TRUE); UNITY_WEBAPPS_NOTE (CONTEXT, "Icon name is: %s", icon_file_name); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", icon_file_name, NULL)); g_free (icon_file_name); return TRUE; } static gboolean on_handle_add_interest (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gpointer user_data) { UnityWebappsContextDaemon *context_daemon; const gchar *fan; gint interest_id; context_daemon = (UnityWebappsContextDaemon *)user_data; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling AddInterest call"); fan = g_dbus_method_invocation_get_sender (invocation); UNITY_WEBAPPS_NOTE (CONTEXT, "Interest is from %s", fan); interest_id = add_interest (session_bus, context_daemon, fan); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", interest_id, NULL)); return TRUE; } static gboolean on_handle_lost_interest (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gboolean user_abandoned, gpointer user_data) { UnityWebappsContextDaemon *context_daemon; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling LostInterest call"); context_daemon = (UnityWebappsContextDaemon *)user_data; g_dbus_method_invocation_return_value (invocation, NULL); lost_interest (session_bus, context_daemon, interest_id, user_abandoned); return TRUE; } static gboolean on_handle_list_interests (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gpointer user_data) { GVariant *interests_list; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling ListInterests call"); interests_list = unity_webapps_interest_manager_list_interests (interest_manager); if (!interests_list) { GVariant *array; array = g_variant_new ("ai", NULL, 0); g_dbus_method_invocation_return_value (invocation, g_variant_new_tuple (&array, 1)); } else { g_dbus_method_invocation_return_value (invocation, g_variant_new_tuple (&interests_list, 1)); } return TRUE; } static gboolean on_handle_get_interest_count (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gpointer user_data) { gint num_interests; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling GetInterestCount call"); num_interests = (gint) unity_webapps_interest_manager_get_num_interests (interest_manager); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", num_interests, NULL)); UNITY_WEBAPPS_NOTE (CONTEXT, "Number of interests is %d", num_interests); return TRUE; } static gboolean on_handle_get_interest_owner (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { const gchar *owner; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling GetInterestOwner call"); owner = unity_webapps_interest_manager_get_interest_owner (interest_manager, interest_id); if (owner == NULL) { g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "", NULL)); UNITY_WEBAPPS_NOTE (CONTEXT, "Interest not found (%d)", interest_id); } else { g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", owner, NULL)); UNITY_WEBAPPS_NOTE (CONTEXT, "Interest Owner is: %s", owner); } return TRUE; } static gboolean on_handle_get_interest_is_active (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { gboolean is_active; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling GetInterestIsActive call"); is_active = unity_webapps_interest_manager_get_interest_is_active (interest_manager, interest_id); UNITY_WEBAPPS_NOTE (CONTEXT, "Interest %d %s", interest_id, is_active ? "is active" : "is not active"); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", is_active, NULL)); return TRUE; } static gboolean on_handle_set_interest_is_active (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gboolean is_active, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling SetInterestIsActive call (%d)", interest_id); unity_webapps_interest_manager_set_interest_is_active (interest_manager, interest_id, is_active); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_get_interest_window (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { guint64 window; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling GetInterestWindow call (%d)", interest_id); window = unity_webapps_interest_manager_get_interest_window (interest_manager, interest_id); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(t)", window, NULL)); UNITY_WEBAPPS_NOTE (CONTEXT, "Window for interest (%d) is %lu", interest_id, (unsigned long)window); return TRUE; } static gboolean on_handle_set_interest_window (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, guint64 window, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling SetInterestWindow call (%d)", interest_id); unity_webapps_interest_manager_set_interest_window (interest_manager, interest_id, window); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_get_interest_location (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { const gchar *location; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling GetInterestLocation call (%d)", interest_id); location = unity_webapps_interest_manager_get_interest_location (interest_manager, interest_id); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", location ? location : "", NULL)); UNITY_WEBAPPS_NOTE (CONTEXT, "Location for interest (%d) is '%s'", interest_id, location); return TRUE; } static gboolean on_handle_set_interest_location (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, const gchar *location, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling SetInterestLocation call (%d): %s", interest_id, location); unity_webapps_interest_manager_set_interest_location (interest_manager, interest_id, location); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_request_preview (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling RequestPreview call"); unity_webapps_context_daemon_emit_preview_requested (session_bus, interest_id); unity_webapps_interest_manager_add_preview_request (interest_manager, interest_id, invocation); return TRUE; } static gboolean on_handle_preview_ready (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, const gchar *preview_data, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling PreviewReady call"); unity_webapps_interest_manager_clear_preview_requests (interest_manager, interest_id, preview_data); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_raise (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, const gchar * const *files, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling Raise call"); unity_webapps_context_daemon_emit_raise (session_bus, unity_webapps_interest_tracker_get_most_recent_interest (interest_tracker), files); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_raise_interest (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { g_message ("Handling RaiseInterest call (%d)", interest_id); unity_webapps_context_daemon_emit_raise (session_bus, interest_id, NULL); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_close (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling Close call"); unity_webapps_context_daemon_emit_close (session_bus, -1); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_close_interest (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling CloseInterest call (%d)", interest_id); unity_webapps_context_daemon_emit_close (session_bus, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_get_application_accept_data (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gpointer user_data) { UnityWebappsContextDaemon *daemon = (UnityWebappsContextDaemon *)user_data; gchar **mimes = daemon->dnd_mimes; GVariantBuilder *builder; GVariant *value; gchar **it; builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); if (mimes) for (it = mimes; *it; it++) { g_variant_builder_add (builder, "s", *it); } value = g_variant_new ("(as)", builder); g_dbus_method_invocation_return_value (invocation, value); g_variant_builder_unref (builder); return TRUE; } static gboolean on_handle_set_application_accept_data (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, const gchar * const *mimes, gint interest_id, gpointer user_data) { UnityWebappsContextDaemon *daemon = (UnityWebappsContextDaemon *)user_data; if (daemon->dnd_mimes) g_strfreev (daemon->dnd_mimes); daemon->dnd_mimes = g_strdupv ((gchar **)mimes); g_dbus_method_invocation_return_value (invocation, NULL); GVariantBuilder *builder; const gchar * const *it; builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); if (mimes) for (it = mimes; *it; it++) { g_variant_builder_add (builder, "s", *it); } g_dbus_connection_emit_signal (session_bus, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "AcceptDataChanged", g_variant_new ("(as)", builder, NULL), NULL); return TRUE; } static gboolean on_handle_add_application_actions (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, const gchar *labels[], gint interest_id, gpointer user_data) { gint i; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling AddApplicationActions call"); if (interest_id == -1) { UNITY_WEBAPPS_NOTE (CONTEXT, "Ignoring request to add action from uninterested client"); goto out; } for (i = 0; labels[i]; i++) { unity_webapps_action_manager_add_action (action_manager, labels[i], interest_id); } out: g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_remove_application_action (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, const gchar *label, gint interest_id, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling RemoveApplicationAction call (%s)", label); if (interest_id == -1) { UNITY_WEBAPPS_NOTE (CONTEXT, "Ignoring request to add action from uninterested client"); goto out; } unity_webapps_action_manager_remove_action (action_manager, label, interest_id); out: g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_remove_application_actions (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling RemoveApplicationActions call"); if (interest_id == -1) { UNITY_WEBAPPS_NOTE (CONTEXT, "Ignoring request to add action from uninterested client"); goto out; } unity_webapps_action_manager_remove_all_actions (action_manager, interest_id); out: g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_set_homepage (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, const gchar *homepage, gpointer user_data) { UNITY_WEBAPPS_NOTE (CONTEXT, "Handling SetHomepage call"); g_dbus_method_invocation_return_value (invocation, NULL); unity_webapps_application_info_set_homepage (application_info, homepage); return TRUE; } static gboolean on_handle_shutdown (UnityWebappsGenContext *context, GDBusMethodInvocation *invocation, gpointer user_data) { UnityWebappsContextDaemon *context_daemon; UNITY_WEBAPPS_NOTE (CONTEXT, "Handling Shutdown call"); context_daemon = (UnityWebappsContextDaemon *)user_data; g_dbus_method_invocation_return_value (invocation, NULL); g_dbus_connection_flush_sync (session_bus, NULL, NULL); // TODO: Really should only do this in debug mode? unity_webapps_context_daemon_free (context_daemon); exit (0); return TRUE; } static void export_object (GDBusConnection *connection, UnityWebappsContextDaemon *daemon) { GError *error; context_service_interface = unity_webapps_gen_context_skeleton_new (); g_signal_connect (context_service_interface, "handle-add-icon", G_CALLBACK (on_handle_add_icon), daemon); g_signal_connect (context_service_interface, "handle-get-icon-name", G_CALLBACK (on_handle_get_icon_name), daemon); g_signal_connect (context_service_interface, "handle-add-interest", G_CALLBACK (on_handle_add_interest), daemon); g_signal_connect (context_service_interface, "handle-lost-interest", G_CALLBACK (on_handle_lost_interest), daemon); g_signal_connect (context_service_interface, "handle-list-interests", G_CALLBACK (on_handle_list_interests), daemon); g_signal_connect (context_service_interface, "handle-get-interest-count", G_CALLBACK (on_handle_get_interest_count), daemon); g_signal_connect (context_service_interface, "handle-get-interest-owner", G_CALLBACK (on_handle_get_interest_owner), daemon); g_signal_connect (context_service_interface, "handle-get-view-is-active", G_CALLBACK (on_handle_get_interest_is_active), daemon); g_signal_connect (context_service_interface, "handle-set-view-is-active", G_CALLBACK (on_handle_set_interest_is_active), daemon); g_signal_connect (context_service_interface, "handle-get-view-location", G_CALLBACK (on_handle_get_interest_location), daemon); g_signal_connect (context_service_interface, "handle-set-view-location", G_CALLBACK (on_handle_set_interest_location), daemon); g_signal_connect (context_service_interface, "handle-request-preview", G_CALLBACK (on_handle_request_preview), daemon); g_signal_connect (context_service_interface, "handle-preview-ready", G_CALLBACK (on_handle_preview_ready), daemon); g_signal_connect (context_service_interface, "handle-get-view-window", G_CALLBACK (on_handle_get_interest_window), daemon); g_signal_connect (context_service_interface, "handle-set-view-window", G_CALLBACK (on_handle_set_interest_window), daemon); g_signal_connect (context_service_interface, "handle-raise", G_CALLBACK (on_handle_raise), daemon); g_signal_connect (context_service_interface, "handle-raise-interest", G_CALLBACK (on_handle_raise_interest), daemon); g_signal_connect (context_service_interface, "handle-close", G_CALLBACK (on_handle_close), daemon); g_signal_connect (context_service_interface, "handle-close-interest", G_CALLBACK (on_handle_close_interest), daemon); g_signal_connect (context_service_interface, "handle-set-application-accept-data", G_CALLBACK (on_handle_set_application_accept_data), daemon); g_signal_connect (context_service_interface, "handle-get-application-accept-data", G_CALLBACK (on_handle_get_application_accept_data), daemon); g_signal_connect (context_service_interface, "handle-add-application-actions", G_CALLBACK (on_handle_add_application_actions), daemon); g_signal_connect (context_service_interface, "handle-remove-application-action", G_CALLBACK (on_handle_remove_application_action), daemon); g_signal_connect (context_service_interface, "handle-remove-application-actions", G_CALLBACK (on_handle_remove_application_actions), daemon); g_signal_connect (context_service_interface, "handle-set-homepage", G_CALLBACK (on_handle_set_homepage), daemon); g_signal_connect (context_service_interface, "handle-shutdown", G_CALLBACK (on_handle_shutdown), daemon); unity_webapps_gen_context_set_view_is_active (context_service_interface, FALSE); unity_webapps_gen_context_set_name (context_service_interface, unity_webapps_application_info_get_name (application_info)); unity_webapps_gen_context_set_domain (context_service_interface, unity_webapps_application_info_get_domain (application_info)); unity_webapps_gen_context_set_desktop_name (context_service_interface, unity_webapps_application_info_get_desktop_file_name (application_info)); unity_webapps_gen_context_set_focus_interest (context_service_interface, -1); error = NULL; g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (context_service_interface), connection, UNITY_WEBAPPS_CONTEXT_PATH, &error); if (error != NULL) { g_error ("Error exporting Unity Webapps Context object: %s", error->message); g_error_free (error); return; } UNITY_WEBAPPS_NOTE (CONTEXT, "Exported Context object"); } static void on_manager_became_lonely (UnityWebappsInterestManager *manager, gboolean user_abandoned, gpointer user_data) { emit_no_interest (session_bus, user_abandoned); } static void on_manager_interest_added (UnityWebappsInterestManager *manager, UnityWebappsInterest *interest, gpointer user_data) { emit_interest_appeared (session_bus, interest->id); } static void on_manager_interest_removed (UnityWebappsInterestManager *manager, UnityWebappsInterest *interest, gpointer user_data) { emit_interest_vanished (session_bus, interest->id); } static void on_manager_active_changed (UnityWebappsInterestManager *manager, gint interest_id, gboolean is_active, gpointer user_data) { unity_webapps_context_daemon_emit_view_is_active_changed (session_bus, interest_id, is_active); } static void on_manager_window_changed (UnityWebappsInterestManager *manager, gint interest_id, guint64 window, gpointer user_data) { unity_webapps_context_daemon_emit_view_window_changed (session_bus, interest_id, window); } static void on_manager_location_changed (UnityWebappsInterestManager *manager, gint interest_id, const gchar *location, gpointer user_data) { unity_webapps_context_daemon_emit_view_location_changed (session_bus, interest_id, location); } static void on_action_manager_action_activated (UnityWebappsActionManager *manager, const gchar *name, gpointer user_data) { unity_webapps_context_daemon_emit_raise (session_bus, -1, NULL); unity_webapps_context_daemon_emit_action_invoked (session_bus, name); } static void unity_webapps_context_daemon_most_recent_interest_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { UnityWebappsInterestTracker *interest_tracker; gint most_recent_interest; UNITY_WEBAPPS_NOTE (CONTEXT, "Updating FocusWindow property"); interest_tracker = UNITY_WEBAPPS_INTEREST_TRACKER (object); most_recent_interest = unity_webapps_interest_tracker_get_most_recent_interest (interest_tracker); unity_webapps_gen_context_set_focus_interest (context_service_interface, most_recent_interest); } UnityWebappsContextDaemon * unity_webapps_context_daemon_new () { UnityWebappsContextDaemon *daemon; gchar *icon_path, *canonical_name; const gchar *name; UNITY_WEBAPPS_NOTE (CONTEXT, "Constructing new UnityWebappsContextDaemon object"); daemon = g_malloc0 (sizeof (UnityWebappsContextDaemon)); // daemon->icon_theme_dir = unity_webapps_icon_theme_get_theme_dir (); daemon->icon_theme_dir = NULL; daemon->dnd_mimes = NULL; daemon->interests = 0; daemon->interest_vanished_ids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); daemon->name_interest_counts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); daemon->icon_file_name = unity_webapps_application_info_save_icon_file (application_info); // TODO: Error unity_webapps_application_info_ensure_desktop_file (application_info, NULL); daemon->desktop_file_name = unity_webapps_application_info_get_desktop_file_name (application_info); icon_path = unity_webapps_icon_theme_get_application_icon_path (daemon->icon_file_name); canonical_name = unity_webapps_application_info_get_canonical_full_name (application_info); name = unity_webapps_application_info_get_name (application_info); interest_manager = unity_webapps_interest_manager_new(); g_signal_connect (interest_manager, "became-lonely", G_CALLBACK (on_manager_became_lonely), daemon); /* There are some awkward races if we expose an interest before it has a XID i.e. BAMF isn't really prepared to handle the concept of a view without a window So we wait until the interest is 'ready' i.e. has a XID. the DBus side API should probably be updated to reflect this in 13.04 cycle. */ g_signal_connect (interest_manager, "interest-ready", G_CALLBACK (on_manager_interest_added), daemon); g_signal_connect (interest_manager, "interest-removed", G_CALLBACK (on_manager_interest_removed), daemon); g_signal_connect (interest_manager, "active-changed", G_CALLBACK (on_manager_active_changed), daemon); g_signal_connect (interest_manager, "location-changed", G_CALLBACK (on_manager_location_changed), daemon); g_signal_connect (interest_manager, "window-changed", G_CALLBACK (on_manager_window_changed), daemon); { UnityWebappsWindowTracker* window_tracker; // TODO(aau): remove this and make a cleaner abstraction // Keep the #ifdef for now, just to make sure that it does not mess up with // "normal" code path. #if defined(ENABLE_TESTS) if (!g_strcmp0(g_getenv("UNITY_WEBAPPS_USE_DBUS_CONTROLLABLE_WINDOW_TRACKING"), "yes")) { UNITY_WEBAPPS_NOTE (CONTEXT, "Using Dbus Controllable window tracker instance"); window_tracker = unity_webapps_window_tracker_get_dbus_controllable(session_bus); } else #endif { UNITY_WEBAPPS_NOTE (CONTEXT, "Using default window tracker instance"); window_tracker = unity_webapps_window_tracker_get_default(); } interest_tracker = unity_webapps_interest_tracker_new (window_tracker, interest_manager); } g_signal_connect (interest_tracker, "notify::most-recent-interest", G_CALLBACK (unity_webapps_context_daemon_most_recent_interest_changed), daemon); action_manager = unity_webapps_action_manager_new (interest_tracker, "/com/canonical/Unity/Webapps/Context/ApplicationActions"); g_signal_connect (action_manager, "action-invoked", G_CALLBACK (on_action_manager_action_activated), daemon); daemon->notification_context = unity_webapps_notification_context_new (session_bus, name, icon_path); daemon->indicator_context = unity_webapps_indicator_context_new (session_bus, unity_webapps_application_info_get_desktop_file_path (application_info), canonical_name, interest_tracker); daemon->music_player_context = unity_webapps_music_player_context_new (session_bus, interest_manager, interest_tracker, daemon->desktop_file_name, canonical_name, name); daemon->launcher_context = unity_webapps_launcher_context_new (session_bus, daemon->desktop_file_name, interest_tracker, application_info); g_free (canonical_name); g_free (icon_path); return daemon; } /* * TODO: This probably leaks...but in the current implementation this means we are shutting down. * It would be useful to free everything just to aid memory debuggers. */ void unity_webapps_context_daemon_free (UnityWebappsContextDaemon *daemon) { // TODO: Can we come back after this? g_hash_table_destroy (daemon->interest_vanished_ids); g_hash_table_destroy (daemon->name_interest_counts); unity_webapps_notification_context_free (daemon->notification_context); unity_webapps_indicator_context_free (daemon->indicator_context); unity_webapps_music_player_context_free (daemon->music_player_context); unity_webapps_launcher_context_free (daemon->launcher_context); g_free (daemon->desktop_file_name); g_free (daemon->icon_file_name); g_free (daemon->icon_theme_dir); g_strfreev (daemon->dnd_mimes); g_free (daemon); } void unity_webapps_context_daemon_emit_raise (GDBusConnection *connection, gint interest_id, const gchar * const *files) { GError *error; if ((interest_id < 0) && (unity_webapps_interest_tracker_get_most_recent_interest (interest_tracker) > 0)) { interest_id = unity_webapps_interest_tracker_get_most_recent_interest (interest_tracker); } UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting Raise signal to interest: %d", interest_id); GVariantBuilder *builder; const gchar *const *it; builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); if (files) for (it = files; *it; it++) { g_variant_builder_add (builder, "s", *it); } error = NULL; g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "RaiseRequested", g_variant_new ("(ias)", interest_id, builder, NULL), &error); g_variant_builder_unref (builder); if (error != NULL) { g_warning ("Error emitting raise signal in context: %s", error->message); g_error_free (error); return; } } void unity_webapps_context_daemon_emit_close (GDBusConnection *connection, gint interest_id) { GError *error; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting Raise signal to interest: %d", interest_id); error = NULL; g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "CloseRequested", g_variant_new ("(i)", interest_id, NULL), &error); if (error != NULL) { g_warning ("Error emitting close signal in context: %s", error->message); g_error_free (error); return; } } void unity_webapps_context_daemon_emit_view_is_active_changed (GDBusConnection *connection, gint interest_id, gboolean is_active) { GError *error; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting ViewIsActiveChanged signal (interest %d %s)", interest_id, is_active ? "is active" : "is not active"); error = NULL; g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "ViewIsActiveChanged", g_variant_new ("(ib)", interest_id, is_active, NULL), &error); if (error != NULL) { g_warning ("Error emitting ViewIsActiveChanged signal in context: %s", error->message); g_error_free (error); return; } } void unity_webapps_context_daemon_emit_view_window_changed (GDBusConnection *connection, gint interest_id, guint64 window) { GError *error; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting ViewWindowChanged signal (interest %d has window %lu)", interest_id, (unsigned long) window); error = NULL; g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "ViewWindowChanged", g_variant_new ("(it)", interest_id, window, NULL), &error); if (error != NULL) { g_warning ("Error emitting ViewWindowChanged signal in context: %s", error->message); g_error_free (error); return; } } void unity_webapps_context_daemon_emit_view_location_changed (GDBusConnection *connection, gint interest_id, const gchar *location) { GError *error; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting ViewLocationChanged signal (interest %d navigated to %s)", interest_id, location); error = NULL; g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "ViewLocationChanged", g_variant_new ("(is)", interest_id, location, NULL), &error); if (error != NULL) { g_warning ("Error emitting ViewLocationChanged signal in context: %s", error->message); g_error_free (error); return; } } void unity_webapps_context_daemon_emit_preview_requested (GDBusConnection *connection, gint interest_id) { GError *error; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting PreviewRequested signal to interest %d", interest_id); error = NULL; g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "PreviewRequested", g_variant_new ("(i)", interest_id, NULL), &error); if (error != NULL) { g_warning ("Error emitting PreviewRequested signal in context: %s", error->message); g_error_free (error); return; } } void unity_webapps_context_daemon_emit_action_invoked (GDBusConnection *connection, const gchar *name) { GError *error; UNITY_WEBAPPS_NOTE (CONTEXT, "Emitting ApplicationActionInvoked signal (%s)", name); error = NULL; g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_CONTEXT_PATH, UNITY_WEBAPPS_CONTEXT_IFACE, "ApplicationActionInvoked", g_variant_new ("(s)", name, NULL), &error); if (error != NULL) { g_warning ("Error emitting ApplicationActionInvoked signal in context: %s", error->message); g_error_free (error); return; } } void unity_webapps_context_daemon_raise_interest (gint interest_id) { unity_webapps_context_daemon_emit_raise (session_bus, interest_id, NULL); } void unity_webapps_context_daemon_raise_most_recent() { unity_webapps_interest_tracker_raise_most_recent (interest_tracker, 0); unity_webapps_context_daemon_emit_raise (session_bus, -1, NULL); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-action-manager.h0000644000015301777760000000720712321247333031200 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-action-manager.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_ACTION_MANAGER_H #define __UNITY_WEBAPPS_ACTION_MANAGER_H #define UNITY_WEBAPPS_TYPE_ACTION_MANAGER (unity_webapps_action_manager_get_type()) #define UNITY_WEBAPPS_ACTION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_ACTION_MANAGER, UnityWebappsActionManager)) #define UNITY_WEBAPPS_ACTION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_ACTION_MANAGER, UnityWebappsActionManagerClass)) #define UNITY_WEBAPPS_IS_ACTION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_ACTION_MANAGER)) #define UNITY_WEBAPPS_IS_ACTION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_ACTION_MANAGER)) #define UNITY_WEBAPPS_ACTION_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_ACTION_MANAGER, UnityWebappsActionManagerClass)) #include #include #include "unity-webapps-interest-tracker.h" typedef struct _UnityWebappsActionManagerPrivate UnityWebappsActionManagerPrivate; typedef struct _UnityWebappsActionManager UnityWebappsActionManager; struct _UnityWebappsActionManager { GObject object; UnityWebappsActionManagerPrivate *priv; // UnityWebappsGenActionManager *action_manager_proxy; // GDBusConnection *session_bus; }; typedef struct _UnityWebappsActionManagerClass UnityWebappsActionManagerClass; struct _UnityWebappsActionManagerClass { GObjectClass parent_class; }; GType unity_webapps_action_manager_get_type (void) G_GNUC_CONST; UnityWebappsActionManager *unity_webapps_action_manager_new (UnityWebappsInterestTracker *interest_tracker, const gchar *menu_pathx); UnityWebappsActionManager *unity_webapps_action_manager_new_flat (UnityWebappsInterestTracker *interest_tracker, const gchar *menu_path); DbusmenuMenuitem *unity_webapps_action_manager_get_root (UnityWebappsActionManager *manager); DbusmenuServer *unity_webapps_action_manager_get_server (UnityWebappsActionManager *manager); void unity_webapps_action_manager_add_action (UnityWebappsActionManager *manager, const gchar *action_name, gint interest_id); void unity_webapps_action_manager_remove_action (UnityWebappsActionManager *manager, const gchar *action_name, gint interest_id); void unity_webapps_action_manager_remove_all_actions (UnityWebappsActionManager *manager, gint interest_id); void unity_webapps_action_manager_set_track_activity (UnityWebappsActionManager *manager, gboolean track_activity); GVariant *unity_webapps_action_manager_serialize (UnityWebappsActionManager *manager); gint unity_webapps_action_manager_get_most_recent_interest_with_action (UnityWebappsActionManager *manager, const gchar *path); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-application-info.c0000644000015301777760000004034712321247333031544 0ustar pbusernogroup00000000000000/* * unity-webapps-application-info.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include "unity-webapps-application-info.h" #include "unity-webapps-dirs.h" #include "unity-webapps-app-db.h" #include "unity-webapps-icon-theme.h" #include "../unity-webapps-debug.h" #include "../unity-webapps-string-utils.h" #include "../unity-webapps-desktop-infos.h" struct _UnityWebappsApplicationInfoPrivate { gchar *name; gchar *domain; gchar *icon_url; gchar *mime_types; GRegex *whitespace_regex; }; enum { PROP_0, PROP_NAME, PROP_DOMAIN, PROP_ICON_URL, PROP_MIME_TYPES }; G_DEFINE_TYPE(UnityWebappsApplicationInfo, unity_webapps_application_info, G_TYPE_OBJECT) #define UNITY_WEBAPPS_APPLICATION_INFO_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_APPLICATION_INFO, UnityWebappsApplicationInfoPrivate)) static gchar *unity_webapps_application_info_default_get_desktop_file_path (UnityWebappsApplicationInfo *info); static gchar *unity_webapps_application_info_default_get_desktop_file_name (UnityWebappsApplicationInfo *info); static gboolean unity_webapps_application_info_default_ensure_desktop_file (UnityWebappsApplicationInfo *info, GError **error); static void unity_webapps_application_info_finalize (GObject *object) { UnityWebappsApplicationInfo *info; info = UNITY_WEBAPPS_APPLICATION_INFO (object); g_free (info->priv->name); g_free (info->priv->domain); g_free (info->priv->icon_url); g_regex_unref(info->priv->whitespace_regex); } static void unity_webapps_application_info_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsApplicationInfo *info; info = UNITY_WEBAPPS_APPLICATION_INFO (object); switch (prop_id) { case PROP_NAME: g_value_set_string (value, info->priv->name); break; case PROP_DOMAIN: g_value_set_string (value, info->priv->domain); break; case PROP_ICON_URL: g_value_set_string (value, info->priv->icon_url); break; case PROP_MIME_TYPES: g_value_set_string (value, info->priv->mime_types); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_application_info_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsApplicationInfo *info; info = UNITY_WEBAPPS_APPLICATION_INFO (object); switch (prop_id) { case PROP_NAME: g_return_if_fail (info->priv->name == NULL); info->priv->name = g_value_dup_string (value); break; case PROP_DOMAIN: g_return_if_fail (info->priv->domain == NULL); info->priv->domain = g_value_dup_string (value); break; case PROP_ICON_URL: g_return_if_fail (info->priv->icon_url == NULL); info->priv->icon_url = g_value_dup_string (value); break; case PROP_MIME_TYPES: info->priv->mime_types = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void unity_webapps_application_info_class_init (UnityWebappsApplicationInfoClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_application_info_finalize; object_class->finalize = unity_webapps_application_info_finalize; object_class->get_property = unity_webapps_application_info_get_property; object_class->set_property = unity_webapps_application_info_set_property; klass->get_desktop_file_name = unity_webapps_application_info_default_get_desktop_file_name; klass->get_desktop_file_path = unity_webapps_application_info_default_get_desktop_file_path; klass->ensure_desktop_file = unity_webapps_application_info_default_ensure_desktop_file; g_object_class_install_property (object_class, PROP_NAME, g_param_spec_string ("name", "Name", "The Application Name", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_DOMAIN, g_param_spec_string ("domain", "Domain", "Domain of the application", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_ICON_URL, g_param_spec_string ("icon-url", "Icon URL", "URI for the primary application icon", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_MIME_TYPES, g_param_spec_string ("mime-types", "Mime Types", "Capable of opening files with the given content type", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_type_class_add_private (object_class, sizeof(UnityWebappsApplicationInfoPrivate)); } static void unity_webapps_application_info_init (UnityWebappsApplicationInfo *manager) { manager->priv = UNITY_WEBAPPS_APPLICATION_INFO_GET_PRIVATE (manager); manager->priv->name = NULL; manager->priv->domain = NULL; manager->priv->icon_url = NULL; manager->priv->whitespace_regex = g_regex_new("\\s", 0, 0, NULL); } UnityWebappsApplicationInfo * unity_webapps_application_info_new (const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types) { return g_object_new (UNITY_WEBAPPS_TYPE_APPLICATION_INFO, "name", name, "domain", domain, "icon-url", icon_url, "mime-types", mime_types, NULL); } const gchar * unity_webapps_application_info_get_name (UnityWebappsApplicationInfo *info) { g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); return info->priv->name; } const gchar * unity_webapps_application_info_get_domain (UnityWebappsApplicationInfo *info) { g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); return info->priv->domain; } const gchar * unity_webapps_application_info_get_icon_url (UnityWebappsApplicationInfo *info) { g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); return info->priv->icon_url; } gchar * unity_webapps_application_info_get_canonical_name (UnityWebappsApplicationInfo *info) { g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); return unity_webapps_string_utils_canonicalize_string (info->priv->name, TRUE); } gchar * unity_webapps_application_info_get_canonical_domain (UnityWebappsApplicationInfo *info) { g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); return unity_webapps_string_utils_canonicalize_string (info->priv->domain, TRUE); } gchar * unity_webapps_application_info_get_canonical_full_name (UnityWebappsApplicationInfo *info) { gchar *canonical_name, *canonical_domain, *canonical_full_name; g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); canonical_name = unity_webapps_application_info_get_canonical_name (info); canonical_domain = unity_webapps_application_info_get_canonical_domain (info); canonical_full_name = g_strdup_printf ("%s%s", canonical_name, canonical_domain); g_free (canonical_name); g_free (canonical_domain); return canonical_full_name; } static gchar * unity_webapps_application_info_default_get_desktop_file_name (UnityWebappsApplicationInfo *info) { gchar *desktop_file_name, *desktop_basename; const gchar *name, *domain; g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); name = unity_webapps_application_info_get_name (info); domain = unity_webapps_application_info_get_domain (info); desktop_basename = unity_webapps_desktop_infos_build_desktop_basename (name, domain); desktop_file_name = g_strdup_printf("%s.desktop", desktop_basename); g_free(desktop_basename); return desktop_file_name; } static gchar * unity_webapps_application_info_default_get_desktop_file_path (UnityWebappsApplicationInfo *info) { gchar *desktop_file_name, *path; desktop_file_name = unity_webapps_application_info_get_desktop_file_name (info); path = g_build_filename (unity_webapps_dirs_get_application_dir (), desktop_file_name, NULL); g_free (desktop_file_name); return path; } gchar * unity_webapps_application_info_get_desktop_icon_name (UnityWebappsApplicationInfo *info, gboolean check_themed) { gchar *icon_name; // Strip icon:// if (g_str_has_prefix(info->priv->icon_url, "icon://")) { icon_name = g_strdup(info->priv->icon_url + 7); // sizeof(icon://) } else { icon_name = g_strdup(info->priv->icon_url); } return icon_name; } static gchar * validate_mime_str (const gchar *in) { gchar *out = NULL, **it; if (!in) return NULL; gchar **mimes = g_strsplit (in, ";", -1); GList *registered = g_content_types_get_registered (); for (it = mimes; it && *it; it++) { if (g_list_find_custom (registered, *it, (GCompareFunc)g_strcmp0)) { gchar *tmp = g_strconcat (*it, ";", out, NULL); g_free (out); out = tmp; } } g_list_free_full (registered, g_free); g_strfreev (mimes); return out; } static gchar * unity_webapps_application_info_get_desktop_file_contents (UnityWebappsApplicationInfo *info) { gint i; gchar **labels, **pages, **il, **ip; gchar *contents, *icon_name, *mime_types; gchar *name = unity_webapps_string_utils_canonicalize_string (info->priv->name, TRUE); gchar *base64_name = g_base64_encode ((guchar*)info->priv->name, strlen (info->priv->name)); gchar *domain = info->priv->domain ? info->priv->domain : ""; gchar *desktop_id = unity_webapps_desktop_infos_build_desktop_basename (name, domain); icon_name = unity_webapps_application_info_get_desktop_icon_name (info, TRUE); mime_types = validate_mime_str (info->priv->mime_types); if (!mime_types) mime_types = g_strdup (""); contents = g_strdup_printf ("[Desktop Entry]\nName=%s\nType=Application\nIcon=%s\nMimeType=%s\nActions=S0;S1;S2;S3;S4;S5;S6;S7;S8;S9;S10;\nExec=unity-webapps-runner -n '%s' -d '%s' %%u\nStartupWMClass=%s\n", name, icon_name, mime_types, base64_name, info->priv->domain, desktop_id); unity_webapps_app_db_get_actions (info->priv->name, info->priv->domain, &labels, &pages); for (i = 0, il = labels, ip = pages; il && *il; il++, i++, ip++) { gchar *label = unity_webapps_string_utils_canonicalize_string (*il, TRUE); if (!label) continue; SoupURI *uri = soup_uri_new (*ip); if (!uri) { g_free (label); continue; } gchar *page = soup_uri_to_string (uri, FALSE); soup_uri_free (uri); gchar *tmp = g_strdup_printf ("%s\n[Desktop Action S%d]\nName=%s\nOnlyShowIn=Unity;\nExec=xdg-open '%s'\n", contents, i, label, page); g_free (contents); g_free (label); contents = tmp; } g_free (icon_name); g_free (mime_types); g_free (base64_name); g_free (name); g_free (desktop_id); g_strfreev (labels); g_strfreev (pages); return contents; } gboolean unity_webapps_application_info_write_desktop_file_to_path (UnityWebappsApplicationInfo *info, const gchar *desktop_file_path, GError **error) { gchar *desktop_file_contents; gboolean success; g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), FALSE); desktop_file_contents = unity_webapps_application_info_get_desktop_file_contents (info); success = g_file_set_contents (desktop_file_path, desktop_file_contents, -1, error); if (success == TRUE) { g_chmod(desktop_file_path, 0744); } UNITY_WEBAPPS_NOTE (APPLICATION_INFO, "Wrote desktop file: %s", desktop_file_path); g_free (desktop_file_contents); return success; } static gboolean unity_webapps_application_info_default_ensure_desktop_file (UnityWebappsApplicationInfo *info, GError **error) { gchar *desktop_file_path; gboolean success; desktop_file_path = unity_webapps_application_info_get_desktop_file_path (info); success = unity_webapps_application_info_write_desktop_file_to_path (info, desktop_file_path, error); g_free (desktop_file_path); return success; } gchar * unity_webapps_application_info_save_icon_file (UnityWebappsApplicationInfo *info) { gchar *icon_name, *icon_full_name; icon_name = unity_webapps_application_info_get_desktop_icon_name (info, TRUE); icon_full_name = unity_webapps_icon_theme_update_application_icon (icon_name, info->priv->icon_url); g_free (icon_name); return icon_full_name; } gchar * unity_webapps_application_info_get_homepage (UnityWebappsApplicationInfo *info) { gchar *homepage; g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); homepage = unity_webapps_app_db_get_homepage (info->priv->name, info->priv->domain); if (homepage == NULL) { homepage = g_strdup_printf("http://%s", info->priv->domain); } return homepage; } void unity_webapps_application_info_set_homepage (UnityWebappsApplicationInfo *info, const gchar *homepage) { g_return_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info)); unity_webapps_app_db_update_homepage (info->priv->name, info->priv->domain, homepage); } void unity_webapps_application_info_add_icon_at_size (UnityWebappsApplicationInfo *info, const gchar *icon_url, gint size) { gchar *icon_name; icon_name = unity_webapps_application_info_get_desktop_icon_name (info, FALSE); unity_webapps_icon_theme_add_icon (icon_name, icon_url, size); g_free (icon_name); } #define BROWSER_EXEC_STRING "xdg-open" gboolean unity_webapps_application_info_open_new_instance (UnityWebappsApplicationInfo *info) { gchar *commandline, *homepage; GError *error; gboolean ret; g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), FALSE); homepage = unity_webapps_application_info_get_homepage (info); g_assert (homepage); commandline = g_strdup_printf ("%s '%s'", BROWSER_EXEC_STRING, homepage); error = NULL; g_spawn_command_line_async (commandline, &error); ret = TRUE; if (error != NULL) { UNITY_WEBAPPS_NOTE (APPLICATION_INFO, "Error invoking xdg-open to launch new application instance: %s", error->message); g_error_free (error); ret = FALSE; } g_free (homepage); g_free (commandline); return ret; } gchar * unity_webapps_application_info_get_desktop_file_name (UnityWebappsApplicationInfo *info) { g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); if (UNITY_WEBAPPS_APPLICATION_INFO_GET_CLASS (info)->get_desktop_file_name != NULL) { return UNITY_WEBAPPS_APPLICATION_INFO_GET_CLASS (info)->get_desktop_file_name (info); } return NULL; } gchar * unity_webapps_application_info_get_desktop_file_path (UnityWebappsApplicationInfo *info) { g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), NULL); if (UNITY_WEBAPPS_APPLICATION_INFO_GET_CLASS (info)->get_desktop_file_path != NULL) { return UNITY_WEBAPPS_APPLICATION_INFO_GET_CLASS (info)->get_desktop_file_path (info); } return NULL; } gboolean unity_webapps_application_info_ensure_desktop_file (UnityWebappsApplicationInfo *info, GError **error) { g_return_val_if_fail (UNITY_WEBAPPS_IS_APPLICATION_INFO (info), FALSE); if (UNITY_WEBAPPS_APPLICATION_INFO_GET_CLASS (info)->ensure_desktop_file != NULL) { return UNITY_WEBAPPS_APPLICATION_INFO_GET_CLASS (info)->ensure_desktop_file (info, error); } return FALSE; } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-application-info.h0000644000015301777760000001051112321247333031537 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-application-info.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_APPLICATION_INFO_H #define __UNITY_WEBAPPS_APPLICATION_INFO_H #include #define UNITY_WEBAPPS_TYPE_APPLICATION_INFO (unity_webapps_application_info_get_type()) #define UNITY_WEBAPPS_APPLICATION_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_APPLICATION_INFO, UnityWebappsApplicationInfo)) #define UNITY_WEBAPPS_APPLICATION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_APPLICATION_INFO, UnityWebappsApplicationInfoClass)) #define UNITY_WEBAPPS_IS_APPLICATION_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_APPLICATION_INFO)) #define UNITY_WEBAPPS_IS_APPLICATION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_APPLICATION_INFO)) #define UNITY_WEBAPPS_APPLICATION_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_APPLICATION_INFO, UnityWebappsApplicationInfoClass)) typedef struct _UnityWebappsApplicationInfoPrivate UnityWebappsApplicationInfoPrivate; typedef struct _UnityWebappsApplicationInfo UnityWebappsApplicationInfo; struct _UnityWebappsApplicationInfo { GObject object; UnityWebappsApplicationInfoPrivate *priv; }; typedef struct _UnityWebappsApplicationInfoClass UnityWebappsApplicationInfoClass; struct _UnityWebappsApplicationInfoClass { GObjectClass parent_class; gchar *(*get_desktop_file_name) (UnityWebappsApplicationInfo *info); gchar *(*get_desktop_file_path) (UnityWebappsApplicationInfo *info); gboolean (*ensure_desktop_file) (UnityWebappsApplicationInfo *info, GError **error); }; GType unity_webapps_application_info_get_type (void) G_GNUC_CONST; UnityWebappsApplicationInfo *unity_webapps_application_info_new (const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types); const gchar *unity_webapps_application_info_get_name (UnityWebappsApplicationInfo *info); const gchar *unity_webapps_application_info_get_domain (UnityWebappsApplicationInfo *info); const gchar *unity_webapps_application_info_get_icon_url (UnityWebappsApplicationInfo *info); gchar *unity_webapps_application_info_get_canonical_name (UnityWebappsApplicationInfo *info); gchar *unity_webapps_application_info_get_canonical_domain (UnityWebappsApplicationInfo *info); gchar *unity_webapps_application_info_get_canonical_full_name (UnityWebappsApplicationInfo *info); gchar *unity_webapps_application_info_get_desktop_icon_name (UnityWebappsApplicationInfo *info, gboolean may_be_themed); gchar *unity_webapps_application_info_get_desktop_file_name (UnityWebappsApplicationInfo *info); gchar *unity_webapps_application_info_get_desktop_file_path (UnityWebappsApplicationInfo *info); gboolean unity_webapps_application_info_ensure_desktop_file (UnityWebappsApplicationInfo *info, GError **error); gboolean unity_webapps_application_info_write_desktop_file_to_path (UnityWebappsApplicationInfo *info, const gchar *path, GError **error); gchar *unity_webapps_application_info_save_icon_file (UnityWebappsApplicationInfo *info); void unity_webapps_application_info_add_icon_at_size (UnityWebappsApplicationInfo *info, const gchar *icon_url, gint size); void unity_webapps_application_info_set_homepage (UnityWebappsApplicationInfo *info, const gchar *homepage); gchar *unity_webapps_application_info_get_homepage (UnityWebappsApplicationInfo *info); gboolean unity_webapps_application_info_open_new_instance (UnityWebappsApplicationInfo *info); #endif ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-preinstalled-application-info.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-preinstalled-application-inf0000644000015301777760000001426112321247333033624 0ustar pbusernogroup00000000000000/* * unity-webapps-preinstalled-application-info.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include "unity-webapps-preinstalled-application-info.h" #include "../unity-webapps-debug.h" G_DEFINE_TYPE(UnityWebappsPreinstalledApplicationInfo, unity_webapps_preinstalled_application_info, UNITY_WEBAPPS_TYPE_APPLICATION_INFO); enum { PROP_0, PROP_DESKTOP_NAME }; #define UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_PREINSTALLED_APPLICATION_INFO, UnityWebappsPreinstalledApplicationInfoPrivate)) struct _UnityWebappsPreinstalledApplicationInfoPrivate { gchar *desktop_name; }; static void unity_webapps_preinstalled_application_info_finalize (GObject *object) { UnityWebappsPreinstalledApplicationInfo *info; info = UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO (object); g_free (info->priv->desktop_name); } static void unity_webapps_preinstalled_application_info_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { UnityWebappsPreinstalledApplicationInfo *self; self = UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO (object); switch (property_id) { case PROP_DESKTOP_NAME: g_return_if_fail (self->priv->desktop_name == NULL); self->priv->desktop_name = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void unity_webapps_preinstalled_application_info_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { UnityWebappsPreinstalledApplicationInfo *self; self = UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO (object); switch (property_id) { case PROP_DESKTOP_NAME: g_value_set_string (value, self->priv->desktop_name); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static gchar * unity_webapps_preinstalled_application_info_get_desktop_file_name (UnityWebappsApplicationInfo *application_info) { UnityWebappsPreinstalledApplicationInfo *info; info = UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO (application_info); return g_strdup (info->priv->desktop_name); } static gchar * unity_webapps_preinstalled_application_info_get_desktop_file_path (UnityWebappsApplicationInfo *application_info) { UnityWebappsPreinstalledApplicationInfo *info; GDesktopAppInfo *desktop_app_info; gchar *desktop_file_path = NULL; info = UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO (application_info); // TODO: Cache GDesktopAppInfo for lifetime of object? Not without implications desktop_app_info = g_desktop_app_info_new (info->priv->desktop_name); if (desktop_app_info) { desktop_file_path = g_strdup (g_desktop_app_info_get_filename (desktop_app_info)); g_object_unref (G_OBJECT (desktop_app_info)); } return desktop_file_path; } static gboolean unity_webapps_preinstalled_application_info_ensure_desktop_file (UnityWebappsApplicationInfo *application_info, GError **error) { gboolean res = FALSE; UnityWebappsPreinstalledApplicationInfo *info; GDesktopAppInfo *desktop_app_info; info = UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO (application_info); desktop_app_info = g_desktop_app_info_new (info->priv->desktop_name); if (desktop_app_info) { res = TRUE; g_object_unref (G_OBJECT (desktop_app_info)); } return res; } static void unity_webapps_preinstalled_application_info_class_init (UnityWebappsPreinstalledApplicationInfoClass *klass) { GParamSpec *pspec; GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsApplicationInfoClass *application_info_class = UNITY_WEBAPPS_APPLICATION_INFO_CLASS (klass); object_class->finalize = unity_webapps_preinstalled_application_info_finalize; object_class->get_property = unity_webapps_preinstalled_application_info_get_property; object_class->set_property = unity_webapps_preinstalled_application_info_set_property; application_info_class->get_desktop_file_name = unity_webapps_preinstalled_application_info_get_desktop_file_name; application_info_class->get_desktop_file_path = unity_webapps_preinstalled_application_info_get_desktop_file_path; application_info_class->ensure_desktop_file = unity_webapps_preinstalled_application_info_ensure_desktop_file; pspec = g_param_spec_string ("desktop-name", "Desktop Name", "Desktop Name for the Preinstalled .desktop file", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_DESKTOP_NAME, pspec); g_type_class_add_private (object_class, sizeof(UnityWebappsPreinstalledApplicationInfoPrivate)); } static void unity_webapps_preinstalled_application_info_init (UnityWebappsPreinstalledApplicationInfo *info) { info->priv = UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO_GET_PRIVATE (info); } UnityWebappsApplicationInfo * unity_webapps_preinstalled_application_info_new (const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types, const gchar *desktop_name) { return g_object_new (UNITY_WEBAPPS_TYPE_PREINSTALLED_APPLICATION_INFO, "name", name, "domain", domain, "icon-url", icon_url, "mime-types", mime_types, "desktop-name", desktop_name, NULL); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-indicator-context.h0000644000015301777760000000372512321247333031752 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-notification-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INDICATOR_CONTEXT_H #define __UNITY_WEBAPPS_INDICATOR_CONTEXT_H #include "../unity-webapps-gen-indicator.h" #include "unity-webapps-action-manager.h" #include "unity-webapps-indicator-manager.h" #include "unity-webapps-presence-manager.h" typedef struct _UnityWebappsIndicatorContext UnityWebappsIndicatorContext; #include "unity-webapps-context-daemon.h" struct _UnityWebappsIndicatorContext { GDBusConnection *connection; UnityWebappsGenIndicator *indicator_service_interface; UnityWebappsActionManager *action_manager; UnityWebappsIndicatorManager *indicator_manager; UnityWebappsIndicatorView *indicator_view; UnityWebappsIndicatorModel *indicator_model; gchar *canonical_name; gchar *desktop_path; guint num_actions; UnityWebappsPresenceManager *presence_manager; }; UnityWebappsIndicatorContext *unity_webapps_indicator_context_new (GDBusConnection *connection, const gchar *desktop_path, const gchar *canonical_name, UnityWebappsInterestTracker *interest_tracker); void unity_webapps_indicator_context_free (UnityWebappsIndicatorContext *indicator_context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/0000755000015301777760000000000012321250157025301 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-view.c0000644000015301777760000001631512321247333033206 0ustar pbusernogroup00000000000000/* * unity-webapps-action-tracker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-indicator-view.h" #include "../unity-webapps-debug.h" G_DEFINE_ABSTRACT_TYPE(UnityWebappsIndicatorView, unity_webapps_indicator_view, G_TYPE_OBJECT) struct _UnityWebappsIndicatorViewPrivate { UnityWebappsIndicatorModel *model; }; enum { PROP_0, PROP_INDICATOR_MODEL }; enum { SERVER_RAISED, INDICATOR_RAISED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; #define UNITY_WEBAPPS_INDICATOR_VIEW_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW, UnityWebappsIndicatorViewPrivate)) static void unity_webapps_indicator_view_finalize (GObject *object) { } static void unity_webapps_indicator_view_dispose (GObject *object) { UnityWebappsIndicatorView *indicator_view; indicator_view = UNITY_WEBAPPS_INDICATOR_VIEW (object); if (indicator_view->priv->model) g_object_unref (G_OBJECT (indicator_view->priv->model)); } static void unity_webapps_indicator_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsIndicatorView *self; self = UNITY_WEBAPPS_INDICATOR_VIEW (object); switch (prop_id) { case PROP_INDICATOR_MODEL: g_value_set_object (value, self->priv->model); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void unity_webapps_indicator_view_indicator_added (UnityWebappsIndicatorModel *model, const gchar *name, gpointer user_data) { UnityWebappsIndicatorView *view; view = (UnityWebappsIndicatorView *)user_data; unity_webapps_indicator_view_show_indicator (view, name); } static void unity_webapps_indicator_view_indicator_removed (UnityWebappsIndicatorModel *model, const gchar *name, gpointer user_data) { UnityWebappsIndicatorView *view; view = (UnityWebappsIndicatorView *)user_data; unity_webapps_indicator_view_clear_indicator (view, name); } static void unity_webapps_indicator_view_indicator_property_changed (UnityWebappsIndicatorModel *model, const gchar *indicator_name, const gchar *property_name, GVariant *value, gboolean draw_attention, gpointer user_data) { UnityWebappsIndicatorView *view; view = (UnityWebappsIndicatorView *)user_data; unity_webapps_indicator_view_set_indicator_property (view, indicator_name, property_name, value, draw_attention); } static void unity_webapps_indicator_view_setup_model (UnityWebappsIndicatorView *self) { g_signal_connect_object (self->priv->model, "indicator-added", G_CALLBACK (unity_webapps_indicator_view_indicator_added), self, 0); g_signal_connect_object (self->priv->model, "indicator-removed", G_CALLBACK (unity_webapps_indicator_view_indicator_removed), self, 0); g_signal_connect_object (self->priv->model, "indicator-property-changed", G_CALLBACK (unity_webapps_indicator_view_indicator_property_changed), self, 0); } static void unity_webapps_indicator_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsIndicatorView *self; self = UNITY_WEBAPPS_INDICATOR_VIEW (object); switch (prop_id) { case PROP_INDICATOR_MODEL: g_return_if_fail (self->priv->model == NULL); self->priv->model = g_value_dup_object (value); unity_webapps_indicator_view_setup_model (self); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void unity_webapps_indicator_view_class_init (UnityWebappsIndicatorViewClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_indicator_view_finalize; object_class->dispose = unity_webapps_indicator_view_dispose; object_class->get_property = unity_webapps_indicator_view_get_property; object_class->set_property = unity_webapps_indicator_view_set_property; g_type_class_add_private (object_class, sizeof(UnityWebappsIndicatorViewPrivate)); signals[SERVER_RAISED] = g_signal_new("server-raised", UNITY_WEBAPPS_TYPE_INDICATOR_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); signals[INDICATOR_RAISED] = g_signal_new("indicator-raised", UNITY_WEBAPPS_TYPE_INDICATOR_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); g_object_class_install_property (object_class, PROP_INDICATOR_MODEL, g_param_spec_object ("model", "Model", "The UnityWebappsIndicatorModel for the view", UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } static void unity_webapps_indicator_view_init (UnityWebappsIndicatorView *view) { view->priv = UNITY_WEBAPPS_INDICATOR_VIEW_GET_PRIVATE (view); } void unity_webapps_indicator_view_show (UnityWebappsIndicatorView *self) { g_return_if_fail (UNITY_WEBAPPS_IS_INDICATOR_VIEW (self)); if (UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS (self)->show) { UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS (self)->show(self); } } void unity_webapps_indicator_view_show_indicator (UnityWebappsIndicatorView *self, const gchar *name) { g_return_if_fail (UNITY_WEBAPPS_IS_INDICATOR_VIEW (self)); if (UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS (self)->show_indicator) { UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS (self)->show_indicator (self, name); } } void unity_webapps_indicator_view_clear_indicator (UnityWebappsIndicatorView *self, const gchar *name) { g_return_if_fail (UNITY_WEBAPPS_IS_INDICATOR_VIEW (self)); if (UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS (self)->clear_indicator) { UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS (self)->clear_indicator (self, name); } } void unity_webapps_indicator_view_set_indicator_property (UnityWebappsIndicatorView *self, const gchar *indicator_name, const gchar *property_name, GVariant *value, gboolean draw_attention) { g_return_if_fail (UNITY_WEBAPPS_IS_INDICATOR_VIEW (self)); if (UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS (self)->set_indicator_property) { UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS (self)->set_indicator_property (self, indicator_name, property_name, value, draw_attention); } } ././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-model-controller.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-model-co0000644000015301777760000001502012321247333033502 0ustar pbusernogroup00000000000000/* * unity-webapps-action-tracker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-indicator-model-controller.h" #include "../unity-webapps-debug.h" struct _UnityWebappsIndicatorModelControllerPrivate { UnityWebappsIndicatorModel *model; UnityWebappsInterestManager *interest_manager; }; enum { PROP_0, PROP_INDICATOR_MODEL, PROP_INTEREST_MANAGER }; G_DEFINE_TYPE(UnityWebappsIndicatorModelController, unity_webapps_indicator_model_controller, G_TYPE_OBJECT) #define UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL_CONTROLLER, UnityWebappsIndicatorModelControllerPrivate)) static void unity_webapps_indicator_model_controller_dispose (GObject *object) { UnityWebappsIndicatorModelController *controller; controller = UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER (object); if (controller->priv->interest_manager) g_object_unref (controller->priv->interest_manager); if (controller->priv->model) g_object_unref (controller->priv->model); } static void unity_webapps_indicator_model_controller_finalize (GObject *object) { } static void unity_webapps_indicator_model_controller_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsIndicatorModelController *controller; controller = UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER (object); switch (prop_id) { case PROP_INDICATOR_MODEL: g_value_set_object (value, controller->priv->model); break; case PROP_INTEREST_MANAGER: g_value_set_object (value, controller->priv->interest_manager); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void unity_webapps_indicator_model_controller_interest_removed (UnityWebappsInterestManager *manager, UnityWebappsInterest *interest, gpointer user_data) { UnityWebappsIndicatorModelController *controller; controller = (UnityWebappsIndicatorModelController *)user_data; unity_webapps_indicator_model_clear_indicators_for_interest (controller->priv->model, interest->id); } static void unity_webapps_indicator_model_controller_setup_interest_manager (UnityWebappsIndicatorModelController *controller) { g_signal_connect_object (controller->priv->interest_manager, "interest-removed", G_CALLBACK(unity_webapps_indicator_model_controller_interest_removed), controller, 0); } static void unity_webapps_indicator_model_controller_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsIndicatorModelController *controller; controller = UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER (object); switch (prop_id) { case PROP_INDICATOR_MODEL: g_return_if_fail (controller->priv->model == NULL); controller->priv->model = g_value_dup_object (value); break; case PROP_INTEREST_MANAGER: g_return_if_fail (controller->priv->interest_manager == NULL); controller->priv->interest_manager = g_value_dup_object (value); unity_webapps_indicator_model_controller_setup_interest_manager (controller); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void unity_webapps_indicator_model_controller_class_init (UnityWebappsIndicatorModelControllerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_indicator_model_controller_finalize; object_class->dispose = unity_webapps_indicator_model_controller_dispose; object_class->get_property = unity_webapps_indicator_model_controller_get_property; object_class->set_property = unity_webapps_indicator_model_controller_set_property; g_type_class_add_private (object_class, sizeof(UnityWebappsIndicatorModelControllerPrivate)); g_object_class_install_property (object_class, PROP_INDICATOR_MODEL, g_param_spec_object ("model", "Model", "The UnityWebappsIndicatorModel for the controller", UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_INTEREST_MANAGER, g_param_spec_object ("interest-manager", "Interest manager", "The UnityWebappsInterestManager for the controller", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } static void unity_webapps_indicator_model_controller_init (UnityWebappsIndicatorModelController *tracker) { tracker->priv = UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER_GET_PRIVATE (tracker); tracker->priv->model = NULL; tracker->priv->interest_manager = NULL; } UnityWebappsIndicatorModelController * unity_webapps_indicator_model_controller_new (UnityWebappsIndicatorModel *model, UnityWebappsInterestManager *manager) { return g_object_new (UNITY_WEBAPPS_TYPE_INDICATOR_MODEL_CONTROLLER, "model", model, "interest-manager", manager, NULL); } UnityWebappsIndicatorModel * unity_webapps_indicator_model_controller_get_model (UnityWebappsIndicatorModelController *controller) { g_return_val_if_fail (UNITY_WEBAPPS_IS_INDICATOR_MODEL_CONTROLLER (controller), NULL); return controller->priv->model; } UnityWebappsInterestManager * unity_webapps_indicator_model_controller_get_interest_manager (UnityWebappsIndicatorModelController *controller) { g_return_val_if_fail (UNITY_WEBAPPS_IS_INDICATOR_MODEL_CONTROLLER (controller), NULL); return controller->priv->interest_manager; } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-view.h0000644000015301777760000000634612321247333033216 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-indicator-view.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INDICATOR_VIEW_H #define __UNITY_WEBAPPS_INDICATOR_VIEW_H #include "unity-webapps-indicator-model.h" #define UNITY_WEBAPPS_TYPE_INDICATOR_VIEW (unity_webapps_indicator_view_get_type()) #define UNITY_WEBAPPS_INDICATOR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW, UnityWebappsIndicatorView)) #define UNITY_WEBAPPS_INDICATOR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW, UnityWebappsIndicatorViewClass)) #define UNITY_WEBAPPS_IS_INDICATOR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW)) #define UNITY_WEBAPPS_IS_INDICATOR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW)) #define UNITY_WEBAPPS_INDICATOR_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW, UnityWebappsIndicatorViewClass)) typedef struct _UnityWebappsIndicatorViewPrivate UnityWebappsIndicatorViewPrivate; typedef struct _UnityWebappsIndicatorView UnityWebappsIndicatorView; struct _UnityWebappsIndicatorView { GObject object; UnityWebappsIndicatorViewPrivate *priv; }; typedef struct _UnityWebappsIndicatorViewClass UnityWebappsIndicatorViewClass; struct _UnityWebappsIndicatorViewClass { GObjectClass parent_class; void (*show) (UnityWebappsIndicatorView *self); void (*clear_indicator) (UnityWebappsIndicatorView *self, const gchar *name); void (*show_indicator) (UnityWebappsIndicatorView *self, const gchar *name); void (*set_indicator_property) (UnityWebappsIndicatorView *self, const gchar *indicator_name, const gchar *property_name, GVariant *value, gboolean draw_attention); }; GType unity_webapps_indicator_view_get_type (void) G_GNUC_CONST; UnityWebappsIndicatorModel *unity_webapps_indicator_view_get_model (UnityWebappsIndicatorView *view); void unity_webapps_indicator_view_show_indicator (UnityWebappsIndicatorView *self, const gchar *name); void unity_webapps_indicator_view_clear_indicator (UnityWebappsIndicatorView *self, const gchar *name); void unity_webapps_indicator_view_set_indicator_property (UnityWebappsIndicatorView *self, const gchar *indicator_name, const gchar *property_name, GVariant *value, gboolean draw_attention); void unity_webapps_indicator_view_show (UnityWebappsIndicatorView *self); #endif ././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-view-messaging-menu.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-view-mes0000644000015301777760000002561412321247333033551 0ustar pbusernogroup00000000000000/* * unity-webapps-indicator-view-messaging-menu.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * Lars Uebernickel * * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "config.h" #include #include #include "unity-webapps-indicator-view-messaging-menu.h" #include "unity-webapps-action-manager.h" #include "unity-webapps-resource-cache.h" #include "../unity-webapps-debug.h" G_DEFINE_TYPE(UnityWebappsIndicatorViewMessagingMenu, unity_webapps_indicator_view_messaging_menu, UNITY_WEBAPPS_TYPE_INDICATOR_VIEW) enum { PROP_0, PROP_DESKTOP_FILE }; struct _UnityWebappsIndicatorViewMessagingMenuPrivate { gchar *desktop_file; MessagingMenuApp *mmapp; }; static void unity_webapps_indicator_view_messaging_menu_source_activated (MessagingMenuApp *mmapp, const gchar *source_id, gpointer user_data) { UnityWebappsIndicatorViewMessagingMenu *view = user_data; g_signal_emit_by_name (view, "indicator-raised", source_id); } static void unity_webapps_indicator_view_messaging_menu_create_mmapp (UnityWebappsIndicatorViewMessagingMenu *self) { gchar *desktop_id; g_return_if_fail (self->priv->mmapp == NULL); /* The messaging menu only accepts desktop file ids and looks for * corresponding applications in XDG_DATA_DIRS. Since we know that * priv->desktop_file will always be installed correctly, we can * safely extract the file's id (its basename) and pass that to the * messaging menu */ desktop_id = g_path_get_basename (self->priv->desktop_file); self->priv->mmapp = messaging_menu_app_new (desktop_id); messaging_menu_app_register (self->priv->mmapp); g_signal_connect (self->priv->mmapp, "activate-source", G_CALLBACK (unity_webapps_indicator_view_messaging_menu_source_activated), self); g_free (desktop_id); } static MessagingMenuApp * unity_webapps_indicator_view_messaging_menu_get_mmapp (UnityWebappsIndicatorViewMessagingMenu *view) { if (view->priv->mmapp != NULL) { return view->priv->mmapp; } unity_webapps_indicator_view_messaging_menu_create_mmapp (view); return view->priv->mmapp; } static void unity_webapps_indicator_view_messaging_menu_show_indicator (UnityWebappsIndicatorView *indicator_view, const gchar *name) { UnityWebappsIndicatorViewMessagingMenu *self = UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU (indicator_view); MessagingMenuApp *mmapp; mmapp = unity_webapps_indicator_view_messaging_menu_get_mmapp (self); g_return_if_fail (mmapp != NULL); if (!messaging_menu_app_has_source (mmapp, name)) { messaging_menu_app_append_source (mmapp, name, NULL, name); } } static void unity_webapps_indicator_view_messaging_menu_clear_indicator (UnityWebappsIndicatorView *indicator_view, const gchar *name) { UnityWebappsIndicatorViewMessagingMenu *self = UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU (indicator_view); MessagingMenuApp *mmapp; mmapp = unity_webapps_indicator_view_messaging_menu_get_mmapp (self); g_return_if_fail (mmapp != NULL); messaging_menu_app_remove_source (mmapp, name); } static void set_property_icon (MessagingMenuApp *mmapp, const gchar *indicator_name, const gchar *icon_url) { GFile *icon_file; gchar *icon_path; GIcon *icon; icon_path = unity_webapps_resource_cache_lookup_uri (icon_url); if (icon_path == NULL) { UNITY_WEBAPPS_NOTE (INDICATOR, "Resource cache returned NULL for URL (%s)", icon_url); return; } icon_file = g_file_new_for_path (icon_path); if (icon_file == NULL) { UNITY_WEBAPPS_NOTE (INDICATOR, "Failed to construct file from icon path: %s", icon_path); return; } icon = g_file_icon_new (icon_file); messaging_menu_app_set_source_icon (mmapp, indicator_name, icon); g_object_unref (icon_file); g_object_unref (icon); g_free (icon_path); } static void unity_webapps_indicator_view_messaging_menu_set_indicator_property (UnityWebappsIndicatorView *indicator_view, const gchar *indicator_name, const gchar *property_name, GVariant *value, gboolean draw_attention) { UnityWebappsIndicatorViewMessagingMenu *self = UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU (indicator_view); MessagingMenuApp *mmapp; mmapp = unity_webapps_indicator_view_messaging_menu_get_mmapp (self); g_return_if_fail (mmapp != NULL); if (g_strcmp0 (property_name, "icon") == 0) { set_property_icon (mmapp, indicator_name, g_variant_get_string(value, NULL)); } else if (g_strcmp0 (property_name, "label") == 0) { const gchar *label; label = g_variant_get_string (value, NULL); messaging_menu_app_set_source_label (mmapp, indicator_name, label); } else if (g_strcmp0 (property_name, "count") == 0) { gint count; count = atoi (g_variant_get_string (value, NULL)); messaging_menu_app_set_source_count (mmapp, indicator_name, count); } if (draw_attention) messaging_menu_app_draw_attention (mmapp, indicator_name); else messaging_menu_app_remove_attention (mmapp, indicator_name); } static void unity_webapps_indicator_view_messaging_menu_finalize (GObject *object) { UnityWebappsIndicatorViewMessagingMenu *view = UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU (object); g_free (view->priv->desktop_file); G_OBJECT_CLASS (unity_webapps_indicator_view_messaging_menu_parent_class)->finalize(object); } static void unity_webapps_indicator_view_messaging_menu_dispose (GObject *object) { UnityWebappsIndicatorViewMessagingMenu *view; view = UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU (object); #if defined(ENABLE_TESTS) if (G_IS_OBJECT(view->priv->mmapp) && !g_strcmp0(g_getenv("UNITY_WEBAPPS_RUNNING_TRACED_TESTS"), "yes")) { // Remove apps when we run in the context of traced apps, to avoid // over-crowding the messaging menu w/ junk. messaging_menu_app_unregister(view->priv->mmapp); } #endif g_clear_object (&view->priv->mmapp); G_OBJECT_CLASS (unity_webapps_indicator_view_messaging_menu_parent_class)->dispose(object); } static void unity_webapps_indicator_view_messaging_menu_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsIndicatorViewMessagingMenu *view = UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU (object); switch (prop_id) { case PROP_DESKTOP_FILE: g_value_set_string (value, view->priv->desktop_file); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void unity_webapps_indicator_view_messaging_menu_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsIndicatorViewMessagingMenu *view = UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU (object); switch (prop_id) { case PROP_DESKTOP_FILE: g_return_if_fail (view->priv->desktop_file == NULL); view->priv->desktop_file = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void unity_webapps_indicator_view_messaging_menu_class_init (UnityWebappsIndicatorViewMessagingMenuClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsIndicatorViewClass *indicator_view_class = UNITY_WEBAPPS_INDICATOR_VIEW_CLASS (klass); g_type_class_add_private (object_class, sizeof(UnityWebappsIndicatorViewMessagingMenuPrivate)); object_class->finalize = unity_webapps_indicator_view_messaging_menu_finalize; object_class->dispose = unity_webapps_indicator_view_messaging_menu_dispose; object_class->get_property = unity_webapps_indicator_view_messaging_menu_get_property; object_class->set_property = unity_webapps_indicator_view_messaging_menu_set_property; indicator_view_class->show_indicator = unity_webapps_indicator_view_messaging_menu_show_indicator; indicator_view_class->clear_indicator = unity_webapps_indicator_view_messaging_menu_clear_indicator; indicator_view_class->set_indicator_property = unity_webapps_indicator_view_messaging_menu_set_indicator_property; g_object_class_install_property (object_class, PROP_DESKTOP_FILE, g_param_spec_string ("desktop-file", "Desktop File", "Desktop File to use for the Messaging Menu", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } static void unity_webapps_indicator_view_messaging_menu_init (UnityWebappsIndicatorViewMessagingMenu *view) { view->priv = G_TYPE_INSTANCE_GET_PRIVATE (view, UNITY_WEBAPPS_TYPE_INDICATOR_VIEW_MESSAGING_MENU, UnityWebappsIndicatorViewMessagingMenuPrivate); } UnityWebappsIndicatorView * unity_webapps_indicator_view_messaging_menu_new (UnityWebappsIndicatorModel *model, const gchar *desktop_file) { return g_object_new (UNITY_WEBAPPS_TYPE_INDICATOR_VIEW_MESSAGING_MENU, "model", model, "desktop-file", desktop_file, NULL); } ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-manager.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-manager.0000644000015301777760000000542612321247333033504 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-indicator-manager.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INDICATOR_MANAGER_H #define __UNITY_WEBAPPS_INDICATOR_MANAGER_H #include "unity-webapps-indicator-model.h" #include "unity-webapps-indicator-view.h" #include "unity-webapps-interest-manager.h" #define UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER (unity_webapps_indicator_manager_get_type()) #define UNITY_WEBAPPS_INDICATOR_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER, UnityWebappsIndicatorManager)) #define UNITY_WEBAPPS_INDICATOR_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER, UnityWebappsIndicatorManagerClass)) #define UNITY_WEBAPPS_IS_INDICATOR_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER)) #define UNITY_WEBAPPS_IS_INDICATOR_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER)) #define UNITY_WEBAPPS_INDICATOR_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER, UnityWebappsIndicatorManagerClass)) typedef struct _UnityWebappsIndicatorManagerPrivate UnityWebappsIndicatorManagerPrivate; typedef struct _UnityWebappsIndicatorManager UnityWebappsIndicatorManager; struct _UnityWebappsIndicatorManager { GObject object; UnityWebappsIndicatorManagerPrivate *priv; }; typedef struct _UnityWebappsIndicatorManagerClass UnityWebappsIndicatorManagerClass; struct _UnityWebappsIndicatorManagerClass { GObjectClass parent_class; }; GType unity_webapps_indicator_manager_get_type (void) G_GNUC_CONST; UnityWebappsIndicatorManager *unity_webapps_indicator_manager_new (const gchar *desktop_file, UnityWebappsInterestManager *interest_manager); UnityWebappsIndicatorModel *unity_webapps_indicator_manager_get_model (UnityWebappsIndicatorManager *manager); UnityWebappsIndicatorView *unity_webapps_indicator_manager_get_view (UnityWebappsIndicatorManager *manager); #endif ././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-model-controller.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-model-co0000644000015301777760000000603012321247333033503 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-indicator-model.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER_H #define __UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER_H #include "unity-webapps-indicator-model.h" #include "unity-webapps-interest-manager.h" #define UNITY_WEBAPPS_TYPE_INDICATOR_MODEL_CONTROLLER (unity_webapps_indicator_model_controller_get_type()) #define UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL_CONTROLLER, UnityWebappsIndicatorModelController)) #define UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL_CONTROLLER, UnityWebappsIndicatorModelControllerClass)) #define UNITY_WEBAPPS_IS_INDICATOR_MODEL_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL_CONTROLLER)) #define UNITY_WEBAPPS_IS_INDICATOR_MODEL_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL_CONTROLLER)) #define UNITY_WEBAPPS_INDICATOR_MODEL_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL_CONTROLLER, UnityWebappsIndicatorModelControllerClass)) typedef struct _UnityWebappsIndicatorModelControllerPrivate UnityWebappsIndicatorModelControllerPrivate; typedef struct _UnityWebappsIndicatorModelController UnityWebappsIndicatorModelController; struct _UnityWebappsIndicatorModelController { GObject object; UnityWebappsIndicatorModelControllerPrivate *priv; }; typedef struct _UnityWebappsIndicatorModelControllerClass UnityWebappsIndicatorModelControllerClass; struct _UnityWebappsIndicatorModelControllerClass { GObjectClass parent_class; }; GType unity_webapps_indicator_model_controller_get_type (void) G_GNUC_CONST; UnityWebappsIndicatorModelController *unity_webapps_indicator_model_controller_new (UnityWebappsIndicatorModel *model, UnityWebappsInterestManager *manager); UnityWebappsIndicatorModel *unity_webapps_indicator_model_controller_get_model (UnityWebappsIndicatorModelController *controller); UnityWebappsInterestManager *unity_webapps_indicator_model_controller_get_interest_manager (UnityWebappsIndicatorModelController *controller); #endif ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-manager.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-manager.0000644000015301777760000002036412321247333033502 0ustar pbusernogroup00000000000000/* * unity-webapps-indicator-manager.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-indicator-model.h" #include "unity-webapps-indicator-model-controller.h" #include "unity-webapps-indicator-view-messaging-menu.h" #include "unity-webapps-indicator-manager.h" #include "../unity-webapps-debug.h" struct _UnityWebappsIndicatorManagerPrivate { UnityWebappsIndicatorModel *model; UnityWebappsIndicatorView *view; UnityWebappsIndicatorModelController *controller; UnityWebappsInterestManager *interest_manager; gchar *desktop_file; }; enum { PROP_0, PROP_DESKTOP_FILE, PROP_INTEREST_MANAGER }; enum { INDICATOR_ACTIVATED, APPLICATION_ACTIVATED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE(UnityWebappsIndicatorManager, unity_webapps_indicator_manager, G_TYPE_OBJECT) #define UNITY_WEBAPPS_INDICATOR_MANAGER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER, UnityWebappsIndicatorManagerPrivate)) static void unity_webapps_indicator_manager_finalize (GObject *object) { UnityWebappsIndicatorManager *manager; manager = UNITY_WEBAPPS_INDICATOR_MANAGER (object); g_free (manager->priv->desktop_file); } static void unity_webapps_indicator_manager_dispose (GObject *object) { UnityWebappsIndicatorManager *manager; manager = UNITY_WEBAPPS_INDICATOR_MANAGER (object); if (manager->priv->model) { g_object_unref (G_OBJECT (manager->priv->model)); manager->priv->model = NULL; } if (manager->priv->view) { g_object_unref (G_OBJECT (manager->priv->view)); manager->priv->view = NULL; } if (manager->priv->controller) { g_object_unref (G_OBJECT (manager->priv->controller)); manager->priv->controller = NULL; } if (manager->priv->interest_manager) { g_object_unref (G_OBJECT (manager->priv->interest_manager)); manager->priv->interest_manager = NULL; } } static void unity_webapps_indicator_manager_server_raised (UnityWebappsIndicatorView *view, gpointer user_data) { UnityWebappsIndicatorManager *manager; manager = (UnityWebappsIndicatorManager *)user_data; g_signal_emit (manager, signals[APPLICATION_ACTIVATED], 0); } static void unity_webapps_indicator_manager_indicator_raised (UnityWebappsIndicatorView *view, const gchar *name, gpointer user_data) { UnityWebappsIndicatorManager *manager; manager = (UnityWebappsIndicatorManager *)user_data; g_signal_emit (manager, signals[INDICATOR_ACTIVATED], 0, name); } static void unity_webapps_indicator_manager_create_view (UnityWebappsIndicatorManager *self) { self->priv->view = unity_webapps_indicator_view_messaging_menu_new (self->priv->model, self->priv->desktop_file); g_signal_connect_object (self->priv->view, "server-raised", G_CALLBACK (unity_webapps_indicator_manager_server_raised), self, 0); g_signal_connect_object (self->priv->view, "indicator-raised", G_CALLBACK (unity_webapps_indicator_manager_indicator_raised), self, 0); } static void unity_webapps_indicator_manager_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { UnityWebappsIndicatorManager *manager; manager = UNITY_WEBAPPS_INDICATOR_MANAGER (object); switch (prop_id) { case PROP_DESKTOP_FILE: g_value_set_string (value, manager->priv->desktop_file); break; case PROP_INTEREST_MANAGER: g_value_set_object (value, manager->priv->interest_manager); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void unity_webapps_indicator_manager_create_controller (UnityWebappsIndicatorManager *manager) { manager->priv->controller = unity_webapps_indicator_model_controller_new (manager->priv->model, manager->priv->interest_manager); } static void unity_webapps_indicator_manager_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { UnityWebappsIndicatorManager *manager; manager = UNITY_WEBAPPS_INDICATOR_MANAGER (object); switch (prop_id) { case PROP_DESKTOP_FILE: g_return_if_fail (manager->priv->desktop_file == NULL); manager->priv->desktop_file = g_value_dup_string (value); unity_webapps_indicator_manager_create_view (manager); break; case PROP_INTEREST_MANAGER: g_return_if_fail (manager->priv->interest_manager == NULL); manager->priv->interest_manager = UNITY_WEBAPPS_INTEREST_MANAGER (g_value_dup_object (value)); unity_webapps_indicator_manager_create_controller (manager); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void unity_webapps_indicator_manager_class_init (UnityWebappsIndicatorManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_indicator_manager_finalize; object_class->dispose = unity_webapps_indicator_manager_dispose; object_class->get_property = unity_webapps_indicator_manager_get_property; object_class->set_property = unity_webapps_indicator_manager_set_property; g_type_class_add_private (object_class, sizeof(UnityWebappsIndicatorManagerPrivate)); g_object_class_install_property (object_class, PROP_DESKTOP_FILE, g_param_spec_string ("desktop-file", "Desktop File", "Full path to the desktop file to use for the indicator view", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_INTEREST_MANAGER, g_param_spec_object ("interest-manager", "Interest Manager", "Interest manager to use to track indicator references", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); signals[INDICATOR_ACTIVATED] = g_signal_new ("indicator-activated", UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); signals[APPLICATION_ACTIVATED] = g_signal_new ("application-activated", UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); } static void unity_webapps_indicator_manager_init (UnityWebappsIndicatorManager *manager) { manager->priv = UNITY_WEBAPPS_INDICATOR_MANAGER_GET_PRIVATE (manager); manager->priv->model = unity_webapps_indicator_model_new (); } UnityWebappsIndicatorManager * unity_webapps_indicator_manager_new (const gchar *desktop_file, UnityWebappsInterestManager *interest_manager) { return g_object_new (UNITY_WEBAPPS_TYPE_INDICATOR_MANAGER, "desktop-file", desktop_file, "interest-manager", interest_manager, NULL); } UnityWebappsIndicatorModel * unity_webapps_indicator_manager_get_model (UnityWebappsIndicatorManager *manager) { g_return_val_if_fail (manager, NULL); return manager->priv->model; } UnityWebappsIndicatorView * unity_webapps_indicator_manager_get_view (UnityWebappsIndicatorManager *manager) { g_return_val_if_fail (manager, NULL); return manager->priv->view; } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-model.h0000644000015301777760000000663212321247333033342 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-indicator-model.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INDICATOR_MODEL_H #define __UNITY_WEBAPPS_INDICATOR_MODEL_H #define UNITY_WEBAPPS_TYPE_INDICATOR_MODEL (unity_webapps_indicator_model_get_type()) #define UNITY_WEBAPPS_INDICATOR_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, UnityWebappsIndicatorModel)) #define UNITY_WEBAPPS_INDICATOR_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, UnityWebappsIndicatorModelClass)) #define UNITY_WEBAPPS_IS_INDICATOR_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL)) #define UNITY_WEBAPPS_IS_INDICATOR_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL)) #define UNITY_WEBAPPS_INDICATOR_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, UnityWebappsIndicatorModelClass)) typedef struct _UnityWebappsIndicatorModelPrivate UnityWebappsIndicatorModelPrivate; typedef struct _UnityWebappsIndicatorModel UnityWebappsIndicatorModel; struct _UnityWebappsIndicatorModel { GObject object; UnityWebappsIndicatorModelPrivate *priv; // UnityWebappsGenIndicatorModel *indicator_model_proxy; // GDBusConnection *session_bus; }; typedef struct _UnityWebappsIndicatorModelClass UnityWebappsIndicatorModelClass; struct _UnityWebappsIndicatorModelClass { GObjectClass parent_class; }; GType unity_webapps_indicator_model_get_type (void) G_GNUC_CONST; UnityWebappsIndicatorModel *unity_webapps_indicator_model_new (); void unity_webapps_indicator_model_show_indicator_for_interest (UnityWebappsIndicatorModel *model, const gchar *name, gint interest_id); void unity_webapps_indicator_model_clear_indicator_for_interest (UnityWebappsIndicatorModel *model, const gchar *name, gint interest_id); void unity_webapps_indicator_model_clear_indicators_for_interest (UnityWebappsIndicatorModel *model, gint interest_id); GVariant *unity_webapps_indicator_model_serialize (UnityWebappsIndicatorModel *model); void unity_webapps_indicator_model_set_indicator_property_for_interest (UnityWebappsIndicatorModel *model, const gchar *indicator_name, const gchar *property_name, GVariant *value, gint interest_id); GVariant *unity_webapps_indicator_model_get_indicator_property (UnityWebappsIndicatorModel *model, const gchar *indicator_name, const gchar *property_name); #endif ././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-view-messaging-menu.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-view-mes0000644000015301777760000000557312321247333033553 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-indicator-view-messaging-menu.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * Lars Uebernickel * * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU_H #define __UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU_H #include "unity-webapps-indicator-view.h" #define UNITY_WEBAPPS_TYPE_INDICATOR_VIEW_MESSAGING_MENU (unity_webapps_indicator_view_messaging_menu_get_type()) #define UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW_MESSAGING_MENU, UnityWebappsIndicatorViewMessagingMenu)) #define UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW_MESSAGING_MENU, UnityWebappsIndicatorViewMessagingMenuClass)) #define UNITY_WEBAPPS_IS_INDICATOR_VIEW_MESSAGING_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW_MESSAGING_MENU)) #define UNITY_WEBAPPS_IS_INDICATOR_VIEW_MESSAGING_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW_MESSAGING_MENU)) #define UNITY_WEBAPPS_INDICATOR_VIEW_MESSAGING_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_INDICATOR_VIEW_MESSAGING_MENU, UnityWebappsIndicatorViewMessagingMenuClass)) typedef struct _UnityWebappsIndicatorViewMessagingMenuPrivate UnityWebappsIndicatorViewMessagingMenuPrivate; typedef struct _UnityWebappsIndicatorViewMessagingMenu UnityWebappsIndicatorViewMessagingMenu; struct _UnityWebappsIndicatorViewMessagingMenu { UnityWebappsIndicatorView object; UnityWebappsIndicatorViewMessagingMenuPrivate *priv; }; typedef struct _UnityWebappsIndicatorViewMessagingMenuClass UnityWebappsIndicatorViewMessagingMenuClass; struct _UnityWebappsIndicatorViewMessagingMenuClass { UnityWebappsIndicatorViewClass parent_class; }; GType unity_webapps_indicator_view_messaging_menu_get_type (void) G_GNUC_CONST; UnityWebappsIndicatorView *unity_webapps_indicator_view_messaging_menu_new (UnityWebappsIndicatorModel *model, const gchar *desktop_file); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/indicator/unity-webapps-indicator-model.c0000644000015301777760000004650012321247333033333 0ustar pbusernogroup00000000000000/* * unity-webapps-indicator-model.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-indicator-model.h" #include "../unity-webapps-debug.h" typedef struct _UnityWebappsIndicatorModelIndicatorValue { GVariant *value; gint interest_id; } UnityWebappsIndicatorModelIndicatorValue; typedef struct _UnityWebappsIndicatorModelIndicator { gchar *name; gint ref_count; GHashTable *properties_by_name; } UnityWebappsIndicatorModelIndicator; struct _UnityWebappsIndicatorModelPrivate { GHashTable *indicators_for_interest; GHashTable *indicators_by_name; gpointer fill; }; enum { INDICATOR_ADDED, INDICATOR_REMOVED, INDICATOR_PROPERTY_CHANGED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE(UnityWebappsIndicatorModel, unity_webapps_indicator_model, G_TYPE_OBJECT); #define UNITY_WEBAPPS_INDICATOR_MODEL_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, UnityWebappsIndicatorModelPrivate)) UnityWebappsIndicatorModelIndicator *unity_webapps_indicator_model_indicator_new (const gchar *name); void unity_webapps_indicator_model_indicator_free (UnityWebappsIndicatorModelIndicator *indicator); UnityWebappsIndicatorModelIndicatorValue *unity_webapps_indicator_model_indicator_value_new (GVariant *variant_value, gint interest_id); void unity_webapps_indicator_model_indicator_value_free (UnityWebappsIndicatorModelIndicatorValue *indicator_value); void unity_webapps_indicator_model_ref_indicator_for_interest (UnityWebappsIndicatorModel *model, UnityWebappsIndicatorModelIndicator *indicator, gint interest_id); void unity_webapps_indicator_model_unref_indicator_for_interest (UnityWebappsIndicatorModel *model, UnityWebappsIndicatorModelIndicator *indicator, gint interest_id); static gint unity_webapps_indicator_model_compare_indicators (gconstpointer a, gconstpointer b) { UnityWebappsIndicatorModelIndicator *indicator_a, *indicator_b; indicator_a = (UnityWebappsIndicatorModelIndicator *)a; indicator_b = (UnityWebappsIndicatorModelIndicator *)b; return g_strcmp0 (indicator_a->name, indicator_b->name); } static void unity_webapps_indicator_model_free_property_queue (gpointer data) { GQueue *queue; queue = (GQueue *)data; g_queue_free_full (queue, (GDestroyNotify) unity_webapps_indicator_model_indicator_value_free); } UnityWebappsIndicatorModelIndicatorValue * unity_webapps_indicator_model_indicator_value_new (GVariant *variant_value, gint interest_id) { UnityWebappsIndicatorModelIndicatorValue *indicator_value; indicator_value = (UnityWebappsIndicatorModelIndicatorValue *)g_malloc0 (sizeof (UnityWebappsIndicatorModelIndicatorValue)); indicator_value->interest_id = interest_id; indicator_value->value = g_variant_ref (variant_value); return indicator_value; } void unity_webapps_indicator_model_indicator_value_free (UnityWebappsIndicatorModelIndicatorValue *indicator_value) { g_variant_unref (indicator_value->value); g_free (indicator_value); } UnityWebappsIndicatorModelIndicator * unity_webapps_indicator_model_indicator_new (const gchar *name) { UnityWebappsIndicatorModelIndicator *indicator; indicator = g_malloc0 (sizeof (UnityWebappsIndicatorModelIndicator)); indicator->ref_count = 0; indicator->name = g_strdup (name); indicator->properties_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, unity_webapps_indicator_model_free_property_queue); return indicator; } void unity_webapps_indicator_model_indicator_free (UnityWebappsIndicatorModelIndicator *indicator) { g_free (indicator->name); g_hash_table_destroy (indicator->properties_by_name); g_free (indicator); } gboolean unity_webapps_indicator_model_indicator_push_property (UnityWebappsIndicatorModel *model, UnityWebappsIndicatorModelIndicator *indicator, const gchar *name, GVariant *value, gint interest_id) { GQueue *property_queue; UnityWebappsIndicatorModelIndicatorValue *property_value; property_queue = (GQueue *)g_hash_table_lookup (indicator->properties_by_name, name); property_value = NULL; if (property_queue == NULL) { property_queue = g_queue_new (); g_hash_table_insert (indicator->properties_by_name, g_strdup (name), property_queue); } else { property_value = g_queue_peek_tail (property_queue); } if (property_value == NULL || (g_variant_compare (property_value->value, value) != 0)) { property_value = unity_webapps_indicator_model_indicator_value_new (value, interest_id); g_queue_push_tail (property_queue, property_value); return TRUE; } return FALSE; } GVariant * unity_webapps_indicator_model_indicator_value_queue_clear_interest (UnityWebappsIndicatorModelIndicator *indicator, const gchar *property_name, GQueue *value_queue, gint interest_id) { GList *to_remove, *walk; GVariant *current_value_variant, *new_value_variant; UnityWebappsIndicatorModelIndicatorValue *indicator_value; gint i, len; GVariant *ret; indicator_value = (UnityWebappsIndicatorModelIndicatorValue *)g_queue_peek_tail (value_queue); if (indicator_value == NULL) { return NULL; } current_value_variant = g_variant_ref (indicator_value->value); len = g_queue_get_length (value_queue); to_remove = NULL; for (i = 0; i < len; i++) { indicator_value = (UnityWebappsIndicatorModelIndicatorValue *)g_queue_peek_nth (value_queue, i); if (indicator_value->interest_id == interest_id) { to_remove = g_list_append (to_remove, indicator_value); } } for (walk = to_remove; walk != NULL; walk = walk->next) { indicator_value = (UnityWebappsIndicatorModelIndicatorValue *)walk->data; g_queue_remove (value_queue, indicator_value); } indicator_value = (UnityWebappsIndicatorModelIndicatorValue *)g_queue_peek_tail (value_queue); if (indicator_value == NULL) { g_hash_table_remove (indicator->properties_by_name, property_name); ret = NULL; goto out; } new_value_variant = g_variant_ref (indicator_value->value); if (g_variant_compare (new_value_variant, current_value_variant) != 0) { ret = new_value_variant; } else { ret = NULL; } out: g_variant_unref (current_value_variant); g_list_free (to_remove); return ret; } void unity_webapps_indicator_model_remove_indicator_properties_for_interest (UnityWebappsIndicatorModel *model, UnityWebappsIndicatorModelIndicator *indicator, gint interest_id) { GList *property_names, *walk; property_names = g_hash_table_get_keys (indicator->properties_by_name); for (walk = property_names; walk != NULL; walk = walk->next) { GQueue *value_queue; GVariant *new_value; const gchar *name; name = (gchar *)walk->data; value_queue = g_hash_table_lookup (indicator->properties_by_name, name); new_value = unity_webapps_indicator_model_indicator_value_queue_clear_interest (indicator, name, value_queue, interest_id); if (new_value != NULL) { g_signal_emit (model, signals[INDICATOR_PROPERTY_CHANGED], 0, indicator->name, name, new_value, TRUE); } } g_list_free (property_names); } void unity_webapps_indicator_model_ref_indicator_for_interest (UnityWebappsIndicatorModel *model, UnityWebappsIndicatorModelIndicator *indicator, gint interest_id) { GList *indicators_for_interest, *indicator_link; indicators_for_interest = (GList *)g_hash_table_lookup (model->priv->indicators_for_interest, GINT_TO_POINTER (interest_id)); indicator_link = g_list_find (indicators_for_interest, indicator); if (indicator_link != NULL) { return; } indicators_for_interest = g_list_append (indicators_for_interest, (gpointer)indicator); g_hash_table_insert (model->priv->indicators_for_interest, GINT_TO_POINTER (interest_id), indicators_for_interest); indicator->ref_count++; } void unity_webapps_indicator_model_unref_indicator_for_interest (UnityWebappsIndicatorModel *model, UnityWebappsIndicatorModelIndicator *indicator, gint interest_id) { GList *indicators_for_interest, *indicator_link; indicators_for_interest = (GList *)g_hash_table_lookup (model->priv->indicators_for_interest, GINT_TO_POINTER (interest_id)); indicator_link = g_list_find (indicators_for_interest, indicator); if (indicator_link == NULL) { return; } indicators_for_interest = g_list_remove (indicators_for_interest, (gpointer)indicator); g_hash_table_insert (model->priv->indicators_for_interest, GINT_TO_POINTER (interest_id), indicators_for_interest); indicator->ref_count--; if (indicator->ref_count == 0) { g_signal_emit (model, signals[INDICATOR_REMOVED], 0, indicator->name); g_hash_table_remove (model->priv->indicators_by_name, indicator->name); return; } unity_webapps_indicator_model_remove_indicator_properties_for_interest (model, indicator, interest_id); } static void unity_webapps_indicator_model_finalize (GObject *object) { UnityWebappsIndicatorModel *model; model = UNITY_WEBAPPS_INDICATOR_MODEL (object); g_hash_table_destroy (model->priv->indicators_by_name); // TODO: Free contents of indicators_for_interest (the GList) g_hash_table_destroy (model->priv->indicators_for_interest); } static void unity_webapps_indicator_model_class_init (UnityWebappsIndicatorModelClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_indicator_model_finalize; g_type_class_add_private (object_class, sizeof(UnityWebappsIndicatorModelPrivate)); signals[INDICATOR_ADDED] = g_signal_new ("indicator-added", UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); signals[INDICATOR_REMOVED] = g_signal_new ("indicator-removed", UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); signals[INDICATOR_PROPERTY_CHANGED] = g_signal_new ("indicator-property-changed", UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_BOOLEAN); } static void unity_webapps_indicator_model_init (UnityWebappsIndicatorModel *manager) { manager->priv = UNITY_WEBAPPS_INDICATOR_MODEL_GET_PRIVATE (manager); manager->priv->indicators_for_interest = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL); manager->priv->indicators_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)unity_webapps_indicator_model_indicator_free); } UnityWebappsIndicatorModel * unity_webapps_indicator_model_new () { return g_object_new (UNITY_WEBAPPS_TYPE_INDICATOR_MODEL, NULL); } void unity_webapps_indicator_model_show_indicator_for_interest (UnityWebappsIndicatorModel *model, const gchar *name, gint interest_id) { UnityWebappsIndicatorModelIndicator *indicator; indicator = g_hash_table_lookup (model->priv->indicators_by_name, name); if (indicator == NULL) { indicator = unity_webapps_indicator_model_indicator_new (name); g_hash_table_insert (model->priv->indicators_by_name, g_strdup (name), indicator); g_signal_emit (model, signals[INDICATOR_ADDED], 0, indicator->name); } unity_webapps_indicator_model_ref_indicator_for_interest (model, indicator, interest_id); return; } void unity_webapps_indicator_model_clear_indicator_for_interest (UnityWebappsIndicatorModel *model, const gchar *name, gint interest_id) { UnityWebappsIndicatorModelIndicator *indicator; indicator = g_hash_table_lookup (model->priv->indicators_by_name, name); if (indicator == NULL) { return; } unity_webapps_indicator_model_unref_indicator_for_interest (model, indicator, interest_id); } void unity_webapps_indicator_model_clear_indicators_for_interest (UnityWebappsIndicatorModel *model, gint interest_id) { GList *indicators_for_interest, *walk; indicators_for_interest = (GList *) g_hash_table_lookup (model->priv->indicators_for_interest, GINT_TO_POINTER (interest_id)); indicators_for_interest = g_list_copy (indicators_for_interest); for (walk = indicators_for_interest; walk != NULL; walk = walk->next) { UnityWebappsIndicatorModelIndicator *indicator; indicator = (UnityWebappsIndicatorModelIndicator *)walk->data; unity_webapps_indicator_model_unref_indicator_for_interest (model, indicator, interest_id); } g_list_free (indicators_for_interest); } static GVariant * unity_webapps_indicator_model_serialize_indicator_properties (UnityWebappsIndicatorModel *model, UnityWebappsIndicatorModelIndicator *indicator) { GList *properties, *walk; GVariantBuilder b; properties = g_hash_table_get_keys (indicator->properties_by_name); g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}")); // g_variant_builder_open (&b, G_VARIANT_TYPE_ARRAY); for (walk = properties; walk != NULL; walk = walk->next) { GVariant *property_value; const gchar *property_name; property_name = (const gchar *)walk->data; property_value = unity_webapps_indicator_model_get_indicator_property (model, indicator->name, property_name); if (property_value == NULL) { // TODO: FIXME g_warning ("TODO: When does this happen?"); continue; } // g_variant_builder_open (&b, G_VARIANT_TYPE("{sv}")); g_variant_builder_add (&b, "{sv}", property_name, property_value); // g_variant_builder_close (&b); } // g_variant_builder_close (&b); g_list_free (properties); return g_variant_builder_end (&b); } static GVariant * unity_webapps_indicator_model_serialize_indicator (UnityWebappsIndicatorModel *model, UnityWebappsIndicatorModelIndicator *indicator) { GVariant *tuple_values[3]; tuple_values[0] = g_variant_new_string (indicator->name); tuple_values[1] = g_variant_new_int32 (indicator->ref_count); tuple_values[2] = unity_webapps_indicator_model_serialize_indicator_properties (model, indicator); return g_variant_new_tuple (tuple_values, 3); } GVariant * unity_webapps_indicator_model_serialize (UnityWebappsIndicatorModel *model) { GList *indicators, *walk; GVariantBuilder b; g_return_val_if_fail (UNITY_WEBAPPS_IS_INDICATOR_MODEL (model), NULL); indicators = g_hash_table_get_values (model->priv->indicators_by_name); indicators = g_list_sort (indicators, unity_webapps_indicator_model_compare_indicators); g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(sia{sv}))")); g_variant_builder_open (&b, G_VARIANT_TYPE ("a(sia{sv})")); for (walk = indicators; walk != NULL; walk = walk->next) { UnityWebappsIndicatorModelIndicator *indicator; GVariant *indicator_variant; indicator = (UnityWebappsIndicatorModelIndicator *)walk->data; indicator_variant = unity_webapps_indicator_model_serialize_indicator (model, indicator); g_variant_builder_add_value (&b, indicator_variant); } g_list_free (indicators); g_variant_builder_close (&b); return g_variant_builder_end (&b); } static gboolean unity_webapps_indicator_model_property_should_draw_attention (const gchar *property_name, GVariant *value) { if (g_strcmp0(property_name, "count") == 0) { if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) { const gchar *count_val; count_val = g_variant_get_string (value, NULL); if (g_strcmp0 (count_val, "0") == 0) { return FALSE; } } if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)) { gint count_val; count_val = g_variant_get_int32 (value); if (count_val == 0) { return FALSE; } } } return TRUE; } void unity_webapps_indicator_model_set_indicator_property_for_interest (UnityWebappsIndicatorModel *model, const gchar *indicator_name, const gchar *property_name, GVariant *value, gint interest_id) { UnityWebappsIndicatorModelIndicator *indicator; GList *indicators_for_interest, *indicator_link; gboolean changed_property; g_return_if_fail (UNITY_WEBAPPS_IS_INDICATOR_MODEL (model)); g_variant_ref_sink (value); indicator = g_hash_table_lookup (model->priv->indicators_by_name, indicator_name); if (indicator == NULL) { goto out; } indicators_for_interest = (GList *)g_hash_table_lookup (model->priv->indicators_for_interest, GINT_TO_POINTER (interest_id)); indicator_link = g_list_find (indicators_for_interest, indicator); if (indicator_link == NULL) { goto out; } changed_property = unity_webapps_indicator_model_indicator_push_property (model, indicator, property_name, value, interest_id); if (changed_property == TRUE) { gboolean draw_attention; draw_attention = unity_webapps_indicator_model_property_should_draw_attention (property_name, value); g_signal_emit (model, signals[INDICATOR_PROPERTY_CHANGED], 0, indicator_name, property_name, value, draw_attention); } out: g_variant_unref (value); } GVariant * unity_webapps_indicator_model_get_indicator_property (UnityWebappsIndicatorModel *model, const gchar *indicator_name, const gchar *property_name) { UnityWebappsIndicatorModelIndicator *indicator; UnityWebappsIndicatorModelIndicatorValue *indicator_value; GQueue *value_queue; g_return_val_if_fail (UNITY_WEBAPPS_IS_INDICATOR_MODEL (model), NULL); indicator = g_hash_table_lookup (model->priv->indicators_by_name, indicator_name); if (indicator == NULL) { return NULL; } value_queue = g_hash_table_lookup (indicator->properties_by_name, property_name); if (value_queue == NULL) return NULL; indicator_value = g_queue_peek_tail (value_queue); if (indicator_value == NULL) return NULL; // TODO: Floating? FIXME: return g_variant_ref (indicator_value->value); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/0000755000015301777760000000000012321250157026762 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000017500000000000011220 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tra0000644000015301777760000002030512321247333033607 0ustar pbusernogroup00000000000000/* * unity-webapps-window-tracker-dbus-controllable.c * Copyright (C) Canonical LTD 2012 * * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-window-tracker-dbus-controllable.h" #include "../unity-webapps-debug.h" #if defined(WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_PATH) #error WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_PATH already defined #endif #if defined(WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_SIGNAL) #error WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_SIGNAL already defined #endif #define WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_PATH \ "com.canonical.Unity.Webapps.Tests.WindowTracker.DbusControllable" #define WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_SIGNAL \ "UpdateLatestWindowId" struct _UnityWebappsWindowTrackerDbusControllablePrivate { GDBusConnection *connection; guint64 active_window_id; }; G_DEFINE_TYPE(UnityWebappsWindowTrackerDbusControllable, unity_webapps_window_tracker_dbus_controllable, UNITY_WEBAPPS_TYPE_WINDOW_TRACKER) #define UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE, UnityWebappsWindowTrackerDbusControllablePrivate)) enum { PROP_0, PROP_DBUS_CONNECTION, }; static void _window_tracker_dbus_controllable_update_latest_window_id (GDBusConnection *connection, const gchar *sender, const gchar *object, const gchar *interface, const gchar *signal, GVariant *params, gpointer user_data) { UnityWebappsWindowTrackerDbusControllable *tracker; guint64 window_id; tracker = (UnityWebappsWindowTrackerDbusControllable*) user_data; UNITY_WEBAPPS_NOTE (WINDOW_TRACKER, "Received active window id update signal"); if (!tracker) return; if (g_strcmp0(signal, WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_SIGNAL)) return; window_id = 0; g_variant_get (params, "(t)", &window_id, NULL); UNITY_WEBAPPS_NOTE (WINDOW_TRACKER, "Updating active window id changed signal: %" G_GUINT64_FORMAT, window_id); tracker->priv->active_window_id = window_id; g_object_notify (G_OBJECT (tracker), "active-window-id"); } static void unity_webapps_window_tracker_dbus_controllable_finalize (GObject *object) { UnityWebappsWindowTrackerDbusControllable *tracker; tracker = UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE (object); (void)tracker; } static void unity_webapps_window_tracker_dbus_controllable_dispose (GObject * object) { UnityWebappsWindowTrackerDbusControllable *tracker; tracker = UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE (object); if (!tracker) return; g_object_unref(UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE_GET_PRIVATE(tracker)->connection); } static void _setup_dbus_connection(UnityWebappsWindowTrackerDbusControllable *tracker) { if (!tracker->priv->connection) return; UNITY_WEBAPPS_NOTE (WINDOW_TRACKER, "Setting up DBUS connection"); //TODO(aau): a bit weak & risky to subscribe to all g_dbus_connection_signal_subscribe (tracker->priv->connection, NULL, WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_PATH, WINDOW_TRACKER_DBUS_CONTROLLABLE_DBUS_SIGNAL, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE, _window_tracker_dbus_controllable_update_latest_window_id, tracker, NULL); } static void _window_tracker_dbus_controllable_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { UnityWebappsWindowTrackerDbusControllable *tracker; tracker = UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE (object); if (!tracker) return; switch (property_id) { case PROP_DBUS_CONNECTION: g_value_set_object (value, tracker->priv->connection); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void _window_tracker_dbus_controllable_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { UnityWebappsWindowTrackerDbusControllable *tracker; tracker = UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE (object); if (!tracker) return; switch (property_id) { case PROP_DBUS_CONNECTION: tracker->priv->connection = g_object_ref((GDBusConnection*) g_value_dup_object (value)); _setup_dbus_connection(tracker); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static guint64 _window_tracker_dbus_controllable_get_active_window_id (UnityWebappsWindowTracker *tracker) { UnityWebappsWindowTrackerDbusControllable *dbus_tracker; dbus_tracker = UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE (tracker); if (!dbus_tracker || !UNITY_WEBAPPS_IS_WINDOW_TRACKER_DBUS_CONTROLLABLE(dbus_tracker)) return 0; return dbus_tracker->priv->active_window_id; } static void unity_webapps_window_tracker_dbus_controllable_class_init (UnityWebappsWindowTrackerDbusControllableClass *klass) { GParamSpec *pspec; GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsWindowTrackerClass *window_tracker_class = UNITY_WEBAPPS_WINDOW_TRACKER_CLASS (klass); object_class->finalize = unity_webapps_window_tracker_dbus_controllable_finalize; object_class->dispose = unity_webapps_window_tracker_dbus_controllable_dispose; object_class->get_property = _window_tracker_dbus_controllable_get_property; object_class->set_property = _window_tracker_dbus_controllable_set_property; window_tracker_class->get_active_window_id = _window_tracker_dbus_controllable_get_active_window_id; g_type_class_add_private (object_class, sizeof(UnityWebappsWindowTrackerDbusControllablePrivate)); pspec = g_param_spec_object("connection", "Connection", "DBUS session connection", G_TYPE_DBUS_CONNECTION, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_DBUS_CONNECTION, pspec); } static void unity_webapps_window_tracker_dbus_controllable_init (UnityWebappsWindowTrackerDbusControllable *tracker) { tracker->priv = UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE_GET_PRIVATE (tracker); tracker->priv->active_window_id = 0; } UnityWebappsWindowTrackerDbusControllable * unity_webapps_dbus_controllable_window_tracker_new (GDBusConnection *connection) { return g_object_new (UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE, "dbus-connection", connection, NULL); } ././@LongLink0000000000000000000000000000017500000000000011220 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tra0000644000015301777760000000521412321247333033611 0ustar pbusernogroup00000000000000/* * unity-webapps-window-tracker-dbus-controllable.h * Copyright (C) Canonical LTD 2011 * * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE_H #define __UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE_H #include "unity-webapps-window-tracker.h" #define UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE \ (unity_webapps_window_tracker_dbus_controllable_get_type()) #define UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE, UnityWebappsWindowTrackerDbusControllable)) #define UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE, UnityWebappsWindowTrackerDbusControllableClass)) #define UNITY_WEBAPPS_IS_WINDOW_TRACKER_DBUS_CONTROLLABLE(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE)) #define UNITY_WEBAPPS_IS_WINDOW_TRACKER_DBUS_CONTROLLABLE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE)) #define UNITY_WEBAPPS_WINDOW_TRACKER_DBUS_CONTROLLABLE_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE, UnityWebappsWindowTrackerDbusControllableClass)) typedef struct _UnityWebappsWindowTrackerDbusControllablePrivate UnityWebappsWindowTrackerDbusControllablePrivate; typedef struct _UnityWebappsWindowTrackerDbusControllable { UnityWebappsWindowTracker object; UnityWebappsWindowTrackerDbusControllablePrivate *priv; } UnityWebappsWindowTrackerDbusControllable; typedef struct _UnityWebappsWindowTrackerDbusControllableClass { UnityWebappsWindowTrackerClass parent_class; } UnityWebappsWindowTrackerDbusControllableClass; GType unity_webapps_window_tracker_dbus_controllable_get_type (void) G_GNUC_CONST; UnityWebappsWindowTrackerDbusControllable * unity_webapps_window_tracker_dbus_controllable_new (GDBusConnection *connection); #endif ././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tracker-wnck.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tra0000644000015301777760000001242212321247333033610 0ustar pbusernogroup00000000000000/* * unity-webapps-action-tracker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #define WNCK_I_KNOW_THIS_IS_UNSTABLE #include #include "unity-webapps-window-tracker-wnck.h" #include "../unity-webapps-debug.h" struct _UnityWebappsWindowTrackerWnckPrivate { WnckWindow *active_window; }; G_DEFINE_TYPE(UnityWebappsWindowTrackerWnck, unity_webapps_window_tracker_wnck, UNITY_WEBAPPS_TYPE_WINDOW_TRACKER) #define UNITY_WEBAPPS_WINDOW_TRACKER_WNCK_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK, UnityWebappsWindowTrackerWnckPrivate)) static void unity_webapps_window_tracker_wnck_initialize_screen (UnityWebappsWindowTrackerWnck *tracker); static void unity_webapps_window_tracker_wnck_active_window_changed (WnckScreen *screen, WnckWindow *old_active, gpointer user_data); static void unity_webapps_window_tracker_wnck_finalize (GObject *object) { } static gboolean unity_webapps_window_tracker_wnck_name_in_ignore_list (WnckWindow *window) { static const gchar *const ignored_names[] = { "Hud", "DNDCollectionWindow", "launcher", "dash", "Dash", "panel", "hud", "unity-launcher", "unity-2d-shell" }; gboolean ignored; const gchar *window_name; gint i; window_name = wnck_window_get_name (window); if (window_name == NULL) return TRUE; ignored = FALSE; for (i = 0; i < G_N_ELEMENTS (ignored_names); i++) { if (g_str_equal (ignored_names[i], window_name)) { UNITY_WEBAPPS_NOTE (WINDOW_TRACKER, "Ignoring switch to blacklisted window with name: %s", window_name); ignored = TRUE; break; } } return ignored; } // Based off hud_window_source_active_window_changed static void unity_webapps_window_tracker_wnck_active_window_changed (WnckScreen *screen, WnckWindow *old_window, gpointer user_data) { UnityWebappsWindowTrackerWnck *tracker; // WnckApplication *application; WnckWindow *window; // const gchar *desktop_file; tracker = (UnityWebappsWindowTrackerWnck *)user_data; window = wnck_screen_get_active_window (wnck_screen_get_default ()); if (window == tracker->priv->active_window) { UNITY_WEBAPPS_NOTE (WINDOW_TRACKER, "Ignoring switch to already active window"); } if (unity_webapps_window_tracker_wnck_name_in_ignore_list (window)) return; /* if (application == NULL) { UNITY_WEBAPPS_NOTE (WINDOW_TRACKER_WNCK, "Ignoring switch to window with no application"); return; } desktop_file = bamf_application_get_desktop_file (application); if (desktop_file == NULL) { UNITY_WEBAPPS_NOTE (WINDOW_TRACKER_WNCK, "Ignoring switch to window with no desktop file"); return; }*/ tracker->priv->active_window = window; g_object_notify (G_OBJECT (tracker), "active-window-id"); } static void unity_webapps_window_tracker_wnck_initialize_screen (UnityWebappsWindowTrackerWnck *tracker) { WnckScreen *screen; screen = wnck_screen_get_default (); g_signal_connect_object (screen, "active-window-changed", G_CALLBACK (unity_webapps_window_tracker_wnck_active_window_changed), tracker, 0); tracker->priv->active_window = wnck_screen_get_active_window (screen); } static guint64 unity_webapps_window_tracker_wnck_get_active_window_id (UnityWebappsWindowTracker *tracker) { UnityWebappsWindowTrackerWnck *self; self = UNITY_WEBAPPS_WINDOW_TRACKER_WNCK (tracker); return self->priv->active_window ? wnck_window_get_xid (self->priv->active_window) : 0; } static void unity_webapps_window_tracker_wnck_class_init (UnityWebappsWindowTrackerWnckClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsWindowTrackerClass *window_tracker_class = UNITY_WEBAPPS_WINDOW_TRACKER_CLASS (klass); object_class->finalize = unity_webapps_window_tracker_wnck_finalize; window_tracker_class->get_active_window_id = unity_webapps_window_tracker_wnck_get_active_window_id; g_type_class_add_private (object_class, sizeof(UnityWebappsWindowTrackerWnckPrivate)); } static void unity_webapps_window_tracker_wnck_init (UnityWebappsWindowTrackerWnck *tracker) { tracker->priv = UNITY_WEBAPPS_WINDOW_TRACKER_WNCK_GET_PRIVATE (tracker); tracker->priv->active_window = NULL; unity_webapps_window_tracker_wnck_initialize_screen (tracker); } UnityWebappsWindowTrackerWnck * unity_webapps_window_tracker_wnck_new () { return g_object_new (UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK, NULL); } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-interest-tracker.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-interest-t0000644000015301777760000003770312321247333033624 0ustar pbusernogroup00000000000000/* * unity-webapps-action-tracker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #define WNCK_I_KNOW_THIS_IS_UNSTABLE #include #include "unity-webapps-interest-tracker.h" #include "unity-webapps-window-tracker.h" #include "unity-webapps-interest-manager.h" #include "../unity-webapps-debug.h" struct _UnityWebappsInterestTrackerPrivate { UnityWebappsInterestManager *interest_manager; UnityWebappsWindowTracker *window_tracker; gint most_recent_interest; GQueue *most_recent_interest_queue; gboolean most_recent_is_active; }; G_DEFINE_TYPE(UnityWebappsInterestTracker, unity_webapps_interest_tracker, G_TYPE_OBJECT) enum { PROP_0, PROP_MOST_RECENT_INTEREST, PROP_WINDOW_TRACKER, PROP_INTEREST_MANAGER }; enum { INTEREST_BECAME_ACTIVE, INTEREST_LOST_ACTIVE, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; #define UNITY_WEBAPPS_INTEREST_TRACKER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_INTEREST_TRACKER, UnityWebappsInterestTrackerPrivate)) static void unity_webapps_interest_tracker_finalize (GObject *object) { UnityWebappsInterestTracker *tracker; tracker = UNITY_WEBAPPS_INTEREST_TRACKER (object); g_queue_free (tracker->priv->most_recent_interest_queue); } static void unity_webapps_interest_tracker_dispose (GObject *object) { UnityWebappsInterestTracker *tracker; tracker = UNITY_WEBAPPS_INTEREST_TRACKER (object); if (tracker->priv->window_tracker) { g_object_unref (G_OBJECT (tracker->priv->window_tracker)); tracker->priv->window_tracker = NULL; } if (tracker->priv->interest_manager) { g_object_unref (G_OBJECT (tracker->priv->interest_manager)); tracker->priv->interest_manager = NULL; } } static void unity_webapps_interest_tracker_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { UnityWebappsInterestTracker *self; self = UNITY_WEBAPPS_INTEREST_TRACKER (object); switch (property_id) { case PROP_MOST_RECENT_INTEREST: g_value_set_int (value, self->priv->most_recent_interest); break; case PROP_WINDOW_TRACKER: g_value_set_object (value, self->priv->window_tracker); break; case PROP_INTEREST_MANAGER: g_value_set_object (value, self->priv->interest_manager); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void unity_webapps_interest_tracker_set_most_recent_interest (UnityWebappsInterestTracker *tracker, gint interest_id) { gint old_interest_id; UNITY_WEBAPPS_NOTE (INTEREST, "Updating most recent interest to %d in response to window or tab selection", interest_id); old_interest_id = tracker->priv->most_recent_interest; tracker->priv->most_recent_interest = interest_id; tracker->priv->most_recent_is_active = TRUE; g_queue_push_head (tracker->priv->most_recent_interest_queue, GINT_TO_POINTER (interest_id)); if (old_interest_id != -1) g_signal_emit (tracker, signals[INTEREST_LOST_ACTIVE], 0, old_interest_id); if (tracker->priv->most_recent_interest != -1) g_signal_emit (tracker, signals[INTEREST_BECAME_ACTIVE], 0, tracker->priv->most_recent_interest); g_object_notify (G_OBJECT (tracker), "most-recent-interest"); } static void unity_webapps_interest_tracker_active_window_id_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { UnityWebappsInterestTracker *tracker; guint64 active_window_id, current_interest_window_id; tracker = (UnityWebappsInterestTracker *)user_data; active_window_id = unity_webapps_window_tracker_get_active_window_id (tracker->priv->window_tracker); current_interest_window_id = unity_webapps_interest_manager_get_interest_window (tracker->priv->interest_manager, tracker->priv->most_recent_interest); if (current_interest_window_id == active_window_id) { if (tracker->priv->most_recent_is_active == FALSE) { UNITY_WEBAPPS_NOTE (INTEREST, "Window for most recent interest %d became active", tracker->priv->most_recent_interest); tracker->priv->most_recent_is_active = TRUE; g_signal_emit (tracker, signals[INTEREST_BECAME_ACTIVE], 0, tracker->priv->most_recent_interest); return; } else { UNITY_WEBAPPS_NOTE (INTEREST, "Making an interest active when it already was. This may indicate an error"); return; } } else { gint new_active_interest; if (tracker->priv->most_recent_is_active == TRUE) { UNITY_WEBAPPS_NOTE (INTEREST, "Most recent interest %d was active but the window changed", tracker->priv->most_recent_interest); tracker->priv->most_recent_is_active = FALSE; g_signal_emit (tracker, signals[INTEREST_LOST_ACTIVE], 0, tracker->priv->most_recent_interest); } new_active_interest = unity_webapps_interest_manager_get_active_interest_at_window (tracker->priv->interest_manager, active_window_id); if (new_active_interest == -1) { return; } UNITY_WEBAPPS_NOTE (INTEREST, "Found an active interest %d in a newly active window", tracker->priv->most_recent_interest); unity_webapps_interest_tracker_set_most_recent_interest (tracker, new_active_interest); } } static void unity_webapps_interest_tracker_ensure_interest_state (UnityWebappsInterestTracker *tracker, gint interest_id) { guint64 active_window_id, interest_window_id; gboolean is_active; is_active = unity_webapps_interest_manager_get_interest_is_active (tracker->priv->interest_manager, interest_id); if (is_active == FALSE) { if (tracker->priv->most_recent_interest != interest_id) { return; } if (tracker->priv->most_recent_is_active == TRUE) { UNITY_WEBAPPS_NOTE (INTEREST, "Most recent interest (%d) lost activity due to tab selection", interest_id); tracker->priv->most_recent_is_active = FALSE; g_signal_emit (tracker, signals[INTEREST_LOST_ACTIVE], 0, interest_id); } return; } if (interest_id == tracker->priv->most_recent_interest) { UNITY_WEBAPPS_NOTE (INTEREST, "Interest %d became active but was already the most recent interest", interest_id); return; } active_window_id = unity_webapps_window_tracker_get_active_window_id (tracker->priv->window_tracker); if (active_window_id == 0) { UNITY_WEBAPPS_NOTE (INTEREST, "Interest %d became active but we have no active window to compare it to!", interest_id); return; } interest_window_id = unity_webapps_interest_manager_get_interest_window (tracker->priv->interest_manager, interest_id); if (interest_window_id != active_window_id) return; UNITY_WEBAPPS_NOTE (INTEREST, "Interest %d became active at active window", interest_id); unity_webapps_interest_tracker_set_most_recent_interest (tracker, interest_id); } static void unity_webapps_interest_tracker_interest_is_active_changed (UnityWebappsInterestManager *interest_manager, gint interest_id, gboolean is_active, gpointer user_data) { UnityWebappsInterestTracker *tracker; tracker = UNITY_WEBAPPS_INTEREST_TRACKER(user_data); unity_webapps_interest_tracker_ensure_interest_state (tracker, interest_id); } static void unity_webapps_interest_tracker_interest_window_changed (UnityWebappsInterestManager *interest_manager, gint interest_id, guint64 new_window, gpointer user_data) { UnityWebappsInterestTracker *tracker; tracker = UNITY_WEBAPPS_INTEREST_TRACKER (user_data); unity_webapps_interest_tracker_ensure_interest_state (tracker, interest_id); } static void unity_webapps_interest_tracker_interest_removed (UnityWebappsInterestManager *interest_manager, UnityWebappsInterest *interest, gpointer user_data) { UnityWebappsInterestTracker *tracker; gint old_interest, interest_id; tracker = (UnityWebappsInterestTracker *)user_data; interest_id = interest->id; UNITY_WEBAPPS_NOTE (INTEREST, "Interest tracker clearing %d from queue", interest_id); g_queue_remove_all (tracker->priv->most_recent_interest_queue, GINT_TO_POINTER (interest_id)); if (interest_id != tracker->priv->most_recent_interest) return; old_interest = tracker->priv->most_recent_interest; if (g_queue_get_length (tracker->priv->most_recent_interest_queue) == 0) tracker->priv->most_recent_interest = -1; else tracker->priv->most_recent_interest = GPOINTER_TO_INT (g_queue_peek_tail (tracker->priv->most_recent_interest_queue)); UNITY_WEBAPPS_NOTE (INTEREST, "Updating most recent interest to %d in response to removal of the previous most recent interest %d", tracker->priv->most_recent_interest, old_interest); tracker->priv->most_recent_is_active = FALSE; if (old_interest != -1) g_signal_emit (tracker, signals[INTEREST_LOST_ACTIVE], 0, old_interest); if (tracker->priv->most_recent_interest != -1) g_signal_emit (tracker, signals[INTEREST_BECAME_ACTIVE], 0, tracker->priv->most_recent_interest); g_object_notify (G_OBJECT (tracker), "most-recent-interest"); } static void unity_webapps_interest_tracker_initialize_window_tracker (UnityWebappsInterestTracker *tracker) { g_signal_connect_object (tracker->priv->window_tracker, "notify::active-window-id", G_CALLBACK (unity_webapps_interest_tracker_active_window_id_changed), tracker, 0); } static void unity_webapps_interest_tracker_initialize_interest_manager (UnityWebappsInterestTracker *tracker) { g_signal_connect_object (tracker->priv->interest_manager, "active-changed", G_CALLBACK (unity_webapps_interest_tracker_interest_is_active_changed), tracker, 0); g_signal_connect_object (tracker->priv->interest_manager, "window-changed", G_CALLBACK (unity_webapps_interest_tracker_interest_window_changed), tracker, 0); g_signal_connect_object (tracker->priv->interest_manager, "interest-removed", G_CALLBACK (unity_webapps_interest_tracker_interest_removed), tracker, 0); } static void unity_webapps_interest_tracker_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { UnityWebappsInterestTracker *self; self = UNITY_WEBAPPS_INTEREST_TRACKER (object); switch (property_id) { case PROP_WINDOW_TRACKER: g_return_if_fail (self->priv->window_tracker == NULL); self->priv->window_tracker = UNITY_WEBAPPS_WINDOW_TRACKER (g_value_dup_object (value)); unity_webapps_interest_tracker_initialize_window_tracker (self); break; case PROP_INTEREST_MANAGER: g_return_if_fail (self->priv->interest_manager == NULL); self->priv->interest_manager = UNITY_WEBAPPS_INTEREST_MANAGER (g_value_dup_object (value)); unity_webapps_interest_tracker_initialize_interest_manager (self); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void unity_webapps_interest_tracker_class_init (UnityWebappsInterestTrackerClass *klass) { GParamSpec *pspec; GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_interest_tracker_finalize; object_class->dispose = unity_webapps_interest_tracker_dispose; object_class->get_property = unity_webapps_interest_tracker_get_property; object_class->set_property = unity_webapps_interest_tracker_set_property; g_type_class_add_private (object_class, sizeof(UnityWebappsInterestTrackerPrivate)); pspec = g_param_spec_int ("most-recent-interest", "Most recent interest", "Most recently used interest", 0, G_MAXINT, 0, G_PARAM_READABLE); g_object_class_install_property (object_class, PROP_MOST_RECENT_INTEREST, pspec); pspec = g_param_spec_object("window-tracker", "Window tracker", "The window tracker to use to track interest activity", UNITY_WEBAPPS_TYPE_WINDOW_TRACKER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_WINDOW_TRACKER, pspec); pspec = g_param_spec_object("interest-manager", "Interest Manager", "The interest manager to use as a tracking model", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_INTEREST_MANAGER, pspec); signals[INTEREST_BECAME_ACTIVE] = g_signal_new ("interest-became-active", UNITY_WEBAPPS_TYPE_INTEREST_TRACKER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_INT); signals[INTEREST_LOST_ACTIVE] = g_signal_new ("interest-lost-active", UNITY_WEBAPPS_TYPE_INTEREST_TRACKER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_INT); } static void unity_webapps_interest_tracker_init (UnityWebappsInterestTracker *tracker) { tracker->priv = UNITY_WEBAPPS_INTEREST_TRACKER_GET_PRIVATE (tracker); tracker->priv->most_recent_interest = -1; tracker->priv->most_recent_interest_queue = g_queue_new (); tracker->priv->most_recent_is_active = FALSE; tracker->priv->window_tracker = NULL; tracker->priv->interest_manager = NULL; } UnityWebappsInterestTracker * unity_webapps_interest_tracker_new (UnityWebappsWindowTracker *window_tracker, UnityWebappsInterestManager *interest_manager) { return g_object_new (UNITY_WEBAPPS_TYPE_INTEREST_TRACKER, "window-tracker", window_tracker, "interest-manager", interest_manager, NULL); } gint unity_webapps_interest_tracker_get_most_recent_interest (UnityWebappsInterestTracker *tracker) { return tracker->priv->most_recent_interest; } GList* unity_webapps_interest_tracker_get_most_recent_interests (UnityWebappsInterestTracker *tracker) { return tracker->priv->most_recent_interest_queue->head; } gboolean unity_webapps_interest_tracker_get_interest_is_active (UnityWebappsInterestTracker *tracker, gint interest_id) { return (tracker->priv->most_recent_interest == interest_id) && tracker->priv->most_recent_is_active; } void unity_webapps_interest_tracker_raise_most_recent (UnityWebappsInterestTracker *tracker, guint32 timestamp) { WnckWindow *window; gint interest_id; guint64 window_id; interest_id = unity_webapps_interest_tracker_get_most_recent_interest (tracker); if (interest_id <= 0) return; window_id = unity_webapps_interest_manager_get_interest_window (tracker->priv->interest_manager, interest_id); if (window_id == 0) return; window = wnck_window_get (window_id); if (window == NULL) { UNITY_WEBAPPS_NOTE (INTEREST, "Interest tracker requested to raise most " "recent window with invalid id %" G_GUINT64_FORMAT, window_id); return; } wnck_window_activate (window, timestamp); } UnityWebappsInterestManager * unity_webapps_interest_tracker_get_interest_manager (UnityWebappsInterestTracker *tracker) { g_return_val_if_fail (UNITY_WEBAPPS_IS_INTEREST_TRACKER (tracker), NULL); return tracker->priv->interest_manager; } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-interest-manager.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-interest-m0000644000015301777760000004026312321247333033610 0ustar pbusernogroup00000000000000/* * unity-webapps-interest-manager.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-interest-manager.h" #include "unity-webapps-context-daemon.h" #include "unity-webapps-interest-tracker.h" #include "../unity-webapps-debug.h" struct _UnityWebappsInterestManagerPrivate { GHashTable *interests_by_id; gint interest_id_count; gint active_interest_count; }; enum { INTEREST_ADDED, INTEREST_REMOVED, BECAME_LONELY, ACTIVE_CHANGED, LOCATION_CHANGED, WINDOW_CHANGED, INTEREST_READY, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; static UnityWebappsInterest *unity_webapps_interest_new (UnityWebappsInterestManager *manager, const gchar *sender, gint id); static void unity_webapps_interest_free (UnityWebappsInterest *interest); G_DEFINE_TYPE(UnityWebappsInterestManager, unity_webapps_interest_manager, G_TYPE_OBJECT) #define UNITY_WEBAPPS_INTEREST_MANAGER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, UnityWebappsInterestManagerPrivate)) static void unity_webapps_interest_manager_finalize (GObject *object) { UnityWebappsInterestManager *manager; manager = UNITY_WEBAPPS_INTEREST_MANAGER (object); g_hash_table_destroy (manager->priv->interests_by_id); } static void unity_webapps_interest_manager_class_init (UnityWebappsInterestManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_interest_manager_finalize; g_type_class_add_private (object_class, sizeof(UnityWebappsInterestManagerPrivate)); signals[INTEREST_ADDED] = g_signal_new ("interest-added", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_POINTER); signals[INTEREST_REMOVED] = g_signal_new ("interest-removed", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_POINTER); signals[BECAME_LONELY] = g_signal_new ("became-lonely", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); signals[ACTIVE_CHANGED] = g_signal_new ("active-changed", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN); signals[LOCATION_CHANGED] = g_signal_new ("location-changed", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); signals[WINDOW_CHANGED] = g_signal_new ("window-changed", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_UINT64); signals[INTEREST_READY] = g_signal_new ("interest-ready", UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_POINTER); } static void unity_webapps_interest_manager_init (UnityWebappsInterestManager *manager) { manager->priv = UNITY_WEBAPPS_INTEREST_MANAGER_GET_PRIVATE (manager); manager->priv->active_interest_count = 0; manager->priv->interest_id_count = 1; manager->priv->interests_by_id = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)unity_webapps_interest_free); } UnityWebappsInterestManager * unity_webapps_interest_manager_new () { return g_object_new (UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, NULL); } static UnityWebappsInterest * unity_webapps_interest_new (UnityWebappsInterestManager *manager, const gchar *sender, gint id) { UnityWebappsInterest *interest; interest = g_malloc0 (sizeof (UnityWebappsInterest)); interest->sender = g_strdup (sender); interest->active = FALSE; interest->location = NULL; interest->window = 0; interest->manager = manager; interest->id = id; interest->pending_invocations = NULL; interest->ready = FALSE; return interest; } static void unity_webapps_interest_free (UnityWebappsInterest *interest) { if (interest->pending_invocations) { unity_webapps_interest_manager_clear_preview_requests (interest->manager, interest->id, ""); g_list_free (interest->pending_invocations); } if (interest->sender) { g_free (interest->sender); } if (interest->location) { g_free (interest->location); } g_free (interest); } static void remove_interests_by_name (UnityWebappsInterestManager *manager, const gchar *name) { GList *found, *walk; GHashTableIter iter; gpointer key, value; g_hash_table_iter_init (&iter, manager->priv->interests_by_id); found = NULL; while (g_hash_table_iter_next (&iter, &key, &value)) { UnityWebappsInterest *interest; interest = (UnityWebappsInterest *)value; if (g_strcmp0(interest->sender, name) == 0) { UNITY_WEBAPPS_NOTE (INTEREST, "Removing interest %d because owner vanished", GPOINTER_TO_INT (key)); found = g_list_append (found, key); } } for (walk = found; walk != NULL; walk = walk->next) { gint interest_id; interest_id = GPOINTER_TO_INT (walk->data); unity_webapps_interest_manager_remove_interest (manager, interest_id, TRUE); } if (found != NULL) { g_list_free (found); } } static gboolean remove_bus_watch (gpointer user_data) { guint watch_id = GPOINTER_TO_INT(user_data); UNITY_WEBAPPS_NOTE(INTEREST, "REMOVING BUS WATCH FOR %d", watch_id); g_bus_unwatch_name (watch_id); return FALSE; } #ifndef UNITY_WEBAPPS_TEST_BUILD static void interest_name_vanished (GDBusConnection *connection, const gchar *name, gpointer user_data) { UnityWebappsInterestManager *manager; UnityWebappsInterest *interest; gchar *interest_name; manager = (UnityWebappsInterestManager *)user_data; interest = (UnityWebappsInterest *)user_data; if (interest->watcher_id != 0) { g_bus_unwatch_name (interest->watcher_id); } interest_name = g_strdup (name); interest->watcher_id = 0; UNITY_WEBAPPS_NOTE (INTEREST, "Client vanished: %s, removing interests", interest_name); remove_interests_by_name (manager, interest_name); if (manager->priv->active_interest_count == 0) { g_signal_emit (manager, signals[BECAME_LONELY], 0, TRUE); } } #endif gint unity_webapps_interest_manager_add_interest (UnityWebappsInterestManager *manager, const gchar *interest_name) { UnityWebappsInterest *interest; interest = unity_webapps_interest_new (manager, interest_name, manager->priv->interest_id_count); g_hash_table_insert (manager->priv->interests_by_id, GINT_TO_POINTER (manager->priv->interest_id_count), interest); UNITY_WEBAPPS_NOTE (INTEREST, "Added interest %d", manager->priv->interest_id_count); manager->priv->interest_id_count++; manager->priv->active_interest_count++; #ifndef UNITY_WEBAPPS_TEST_BUILD interest->watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION, interest_name, G_BUS_NAME_WATCHER_FLAGS_NONE, NULL, interest_name_vanished, manager, NULL /* User data free */); #else interest->watcher_id = 0; #endif g_signal_emit (manager, signals[INTEREST_ADDED], 0, interest); return interest->id; } void unity_webapps_interest_manager_remove_interest (UnityWebappsInterestManager *manager, gint interest_id, gboolean user_abandoned) { UnityWebappsInterest *interest; guint watch_id; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest != NULL) { UNITY_WEBAPPS_NOTE (INTEREST, "Removing interest %d from %s", interest_id, interest->sender); watch_id = interest->watcher_id; if (watch_id != 0) { #ifndef UNITY_WEBAPPS_TEST_BUILDF g_timeout_add_seconds(15, remove_bus_watch, GINT_TO_POINTER(watch_id)); #endif } manager->priv->active_interest_count--; g_signal_emit (manager, signals[INTEREST_REMOVED], 0, interest); g_hash_table_remove (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); } if (unity_webapps_interest_manager_get_num_interests (manager) == 0) { UNITY_WEBAPPS_NOTE (INTEREST, "Interest manager became lonely"); g_signal_emit (manager, signals[BECAME_LONELY], 0, user_abandoned); } } guint unity_webapps_interest_manager_get_num_interests (UnityWebappsInterestManager *manager) { return g_hash_table_size (manager->priv->interests_by_id); } GVariant * unity_webapps_interest_manager_list_interests (UnityWebappsInterestManager *manager) { GVariant *interests_list; GVariantBuilder *builder; GHashTableIter iter; gpointer key, value; if (g_hash_table_size (manager->priv->interests_by_id) == 0) { return NULL; } builder = g_variant_builder_new (G_VARIANT_TYPE ("ai")); g_hash_table_iter_init (&iter, manager->priv->interests_by_id); while (g_hash_table_iter_next (&iter, &key, &value)) { UnityWebappsInterest *interest; interest = (UnityWebappsInterest *)value; if (interest->ready) { g_variant_builder_add (builder, "i", GPOINTER_TO_INT (key)); } } interests_list = g_variant_builder_end (builder); g_variant_builder_unref (builder); return interests_list; } const gchar * unity_webapps_interest_manager_get_interest_owner (UnityWebappsInterestManager *manager, gint interest_id) { UnityWebappsInterest *interest; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return NULL; } return interest->sender; } void unity_webapps_interest_manager_set_interest_is_active (UnityWebappsInterestManager *manager, gint interest_id, gboolean is_active) { UnityWebappsInterest *interest; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return; } interest->active = is_active; g_signal_emit (manager, signals[ACTIVE_CHANGED], 0, interest_id, is_active); // if (is_active == TRUE) // unity_webapps_context_daemon_set_most_recent_interest (interest_id); } gboolean unity_webapps_interest_manager_get_interest_is_active (UnityWebappsInterestManager *manager, gint interest_id) { UnityWebappsInterest *interest; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return FALSE; } return interest->active; } void unity_webapps_interest_manager_set_interest_location (UnityWebappsInterestManager *manager, gint interest_id, const gchar *location) { UnityWebappsInterest *interest; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return; } if (interest->location != NULL) { if (g_strcmp0 (interest->location, location) == 0) { return; } g_free (interest->location); } interest->location = g_strdup (location); g_signal_emit (manager, signals[LOCATION_CHANGED], 0, interest_id, location); } const gchar * unity_webapps_interest_manager_get_interest_location (UnityWebappsInterestManager *manager, gint interest_id) { UnityWebappsInterest *interest; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return NULL; } return interest->location; } void unity_webapps_interest_manager_set_interest_window (UnityWebappsInterestManager *manager, gint interest_id, guint64 window) { UnityWebappsInterest *interest; gboolean made_ready; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return; } made_ready = FALSE; if ((interest->window == 0) && (window != 0)) { made_ready = TRUE; interest->ready = TRUE; } interest->window = window; if (made_ready == TRUE) { g_signal_emit (manager, signals[INTEREST_READY], 0, interest); } g_signal_emit (manager, signals[WINDOW_CHANGED], 0, interest_id, window); } guint64 unity_webapps_interest_manager_get_interest_window (UnityWebappsInterestManager *manager, gint interest_id) { UnityWebappsInterest *interest; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return FALSE; } return interest->window; } void unity_webapps_interest_manager_clear_preview_requests (UnityWebappsInterestManager *manager, gint interest_id, const gchar *preview_data) { UnityWebappsInterest *interest; GList *walk; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return; } for (walk = interest->pending_invocations; walk != NULL; walk = walk->next) { GDBusMethodInvocation *invocation; invocation = (GDBusMethodInvocation *)walk->data; g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", preview_data, NULL)); } g_list_free (interest->pending_invocations); interest->pending_invocations = NULL; } void unity_webapps_interest_manager_add_preview_request (UnityWebappsInterestManager *manager, gint interest_id, GDBusMethodInvocation *invocation) { UnityWebappsInterest *interest; interest = g_hash_table_lookup (manager->priv->interests_by_id, GINT_TO_POINTER (interest_id)); if (interest == NULL) { return; } interest->pending_invocations = g_list_append (interest->pending_invocations, (gpointer) invocation); } gint unity_webapps_interest_manager_get_active_interest_at_window (UnityWebappsInterestManager *manager, guint64 window_id) { GList *interests, *walk; gint active_interest; interests = g_hash_table_get_values (manager->priv->interests_by_id); active_interest = -1; for (walk = interests; walk != NULL; walk = walk->next) { UnityWebappsInterest *interest; interest = (UnityWebappsInterest *)walk->data; if (interest->active && (interest->window == window_id)) { #ifdef UNITY_WEBAPPS_ENABLE_DEBUG if (active_interest != -1) { g_warning ("Found two active interests in one window (interests %d and %d), this should not happen", interest->id, active_interest); } #endif active_interest = interest->id; #ifndef UNITY_WEBAPPS_ENABLE_DEBUG goto out; #endif } } #ifndef UNITY_WEBAPPS_ENABLE_DEBUG out: #endif g_list_free (interests); return active_interest; } void unity_webapps_interest_manager_remove_interests_with_name (UnityWebappsInterestManager *manager, const gchar *name) { g_return_if_fail (UNITY_WEBAPPS_IS_INTEREST_MANAGER (manager)); remove_interests_by_name (manager, name); } ././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tracker.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tra0000644000015301777760000000515612321247333033616 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-window-tracker.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_WINDOW_TRACKER_H #define __UNITY_WEBAPPS_WINDOW_TRACKER_H #define UNITY_WEBAPPS_TYPE_WINDOW_TRACKER (unity_webapps_window_tracker_get_type()) #define UNITY_WEBAPPS_WINDOW_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER, UnityWebappsWindowTracker)) #define UNITY_WEBAPPS_WINDOW_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER, UnityWebappsWindowTrackerClass)) #define UNITY_WEBAPPS_IS_WINDOW_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER)) #define UNITY_WEBAPPS_IS_WINDOW_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER)) #define UNITY_WEBAPPS_WINDOW_TRACKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER, UnityWebappsWindowTrackerClass)) typedef struct _UnityWebappsWindowTrackerPrivate UnityWebappsWindowTrackerPrivate; typedef struct _UnityWebappsWindowTracker UnityWebappsWindowTracker; struct _UnityWebappsWindowTracker { GObject object; }; typedef struct _UnityWebappsWindowTrackerClass UnityWebappsWindowTrackerClass; struct _UnityWebappsWindowTrackerClass { GObjectClass parent_class; guint64 (*get_active_window_id) (UnityWebappsWindowTracker *self); }; GType unity_webapps_window_tracker_get_type (void) G_GNUC_CONST; UnityWebappsWindowTracker *unity_webapps_window_tracker_new (); UnityWebappsWindowTracker *unity_webapps_window_tracker_get_default (); #if defined(ENABLE_TESTS) UnityWebappsWindowTracker *unity_webapps_window_tracker_get_dbus_controllable (GDBusConnection *connection); #endif guint64 unity_webapps_window_tracker_get_active_window_id (UnityWebappsWindowTracker *tracker); #endif ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-interest-tracker.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-interest-t0000644000015301777760000000610212321247333033611 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-interest-tracker.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INTEREST_TRACKER_H #define __UNITY_WEBAPPS_INTEREST_TRACKER_H #define UNITY_WEBAPPS_TYPE_INTEREST_TRACKER (unity_webapps_interest_tracker_get_type()) #define UNITY_WEBAPPS_INTEREST_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_INTEREST_TRACKER, UnityWebappsInterestTracker)) #define UNITY_WEBAPPS_INTEREST_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_INTEREST_TRACKER, UnityWebappsInterestTrackerClass)) #define UNITY_WEBAPPS_IS_INTEREST_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_INTEREST_TRACKER)) #define UNITY_WEBAPPS_IS_INTEREST_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_INTEREST_TRACKER)) #define UNITY_WEBAPPS_INTEREST_TRACKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_INTEREST_TRACKER, UnityWebappsInterestTrackerClass)) #include "unity-webapps-window-tracker.h" #include "unity-webapps-interest-manager.h" typedef struct _UnityWebappsInterestTrackerPrivate UnityWebappsInterestTrackerPrivate; typedef struct _UnityWebappsInterestTracker UnityWebappsInterestTracker; struct _UnityWebappsInterestTracker { GObject object; UnityWebappsInterestTrackerPrivate *priv; }; typedef struct _UnityWebappsInterestTrackerClass UnityWebappsInterestTrackerClass; struct _UnityWebappsInterestTrackerClass { GObjectClass parent_class; }; GType unity_webapps_interest_tracker_get_type (void) G_GNUC_CONST; UnityWebappsInterestTracker *unity_webapps_interest_tracker_new (UnityWebappsWindowTracker *window_tracker, UnityWebappsInterestManager *interest_manager); gint unity_webapps_interest_tracker_get_most_recent_interest (UnityWebappsInterestTracker *tracker); GList* unity_webapps_interest_tracker_get_most_recent_interests (UnityWebappsInterestTracker *tracker); gboolean unity_webapps_interest_tracker_get_interest_is_active (UnityWebappsInterestTracker *tracker, gint interest_id); void unity_webapps_interest_tracker_raise_most_recent (UnityWebappsInterestTracker *tracker, guint32 timestamp); UnityWebappsInterestManager *unity_webapps_interest_tracker_get_interest_manager (UnityWebappsInterestTracker *tracker); #endif ././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tracker-wnck.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tra0000644000015301777760000000475112321247333033616 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-window-tracker.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_WINDOW_TRACKER_WNCK_H #define __UNITY_WEBAPPS_WINDOW_TRACKER_WNCK_H #include "unity-webapps-window-tracker.h" #define UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK (unity_webapps_window_tracker_wnck_get_type()) #define UNITY_WEBAPPS_WINDOW_TRACKER_WNCK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK, UnityWebappsWindowTrackerWnck)) #define UNITY_WEBAPPS_WINDOW_TRACKER_WNCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK, UnityWebappsWindowTrackerWnckClass)) #define UNITY_WEBAPPS_IS_WINDOW_TRACKER_WNCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK)) #define UNITY_WEBAPPS_IS_WINDOW_TRACKER_WNCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK)) #define UNITY_WEBAPPS_WINDOW_TRACKER_WNCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK, UnityWebappsWindowTrackerWnckClass)) typedef struct _UnityWebappsWindowTrackerWnckPrivate UnityWebappsWindowTrackerWnckPrivate; typedef struct _UnityWebappsWindowTrackerWnck UnityWebappsWindowTrackerWnck; struct _UnityWebappsWindowTrackerWnck { UnityWebappsWindowTracker object; UnityWebappsWindowTrackerWnckPrivate *priv; }; typedef struct _UnityWebappsWindowTrackerWnckClass UnityWebappsWindowTrackerWnckClass; struct _UnityWebappsWindowTrackerWnckClass { UnityWebappsWindowTrackerClass parent_class; }; GType unity_webapps_window_tracker_wnck_get_type (void) G_GNUC_CONST; UnityWebappsWindowTrackerWnck *unity_webapps_window_tracker_wnck_new (); #endif ././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tracker.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-window-tra0000644000015301777760000000726112321247333033615 0ustar pbusernogroup00000000000000/* * unity-webapps-action-tracker.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "config.h" #include #include #include #include #include #include "unity-webapps-window-tracker.h" #include "unity-webapps-window-tracker-wnck.h" #if defined(ENABLE_TESTS) #include "unity-webapps-window-tracker-dbus-controllable.h" #endif #ifdef UNITY_WEBAPPS_TEST_BUILD #include "unity-webapps-window-tracker-mock.h" #endif #include "../unity-webapps-debug.h" G_DEFINE_ABSTRACT_TYPE(UnityWebappsWindowTracker, unity_webapps_window_tracker, G_TYPE_OBJECT) enum { PROP_0, PROP_ACTIVE_WINDOW }; static UnityWebappsWindowTracker *default_tracker = NULL; #define UNITY_WEBAPPS_WINDOW_TRACKER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_WINDOW_TRACKER, UnityWebappsWindowTrackerPrivate)) static void unity_webapps_window_tracker_finalize (GObject *object) { } static void unity_webapps_window_tracker_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { UnityWebappsWindowTracker *self; self = UNITY_WEBAPPS_WINDOW_TRACKER (object); switch (property_id) { case PROP_ACTIVE_WINDOW: g_value_set_uint64 (value, unity_webapps_window_tracker_get_active_window_id (self)); break; } } static void unity_webapps_window_tracker_class_init (UnityWebappsWindowTrackerClass *klass) { GParamSpec *pspec; GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_window_tracker_finalize; object_class->get_property = unity_webapps_window_tracker_get_property; pspec = g_param_spec_uint64 ("active-window-id", "Active Window ID", "Active Window ID which matches certain rules", 0, G_MAXUINT64, 0, G_PARAM_READABLE); g_object_class_install_property (object_class, PROP_ACTIVE_WINDOW, pspec); } static void unity_webapps_window_tracker_init (UnityWebappsWindowTracker *tracker) { } UnityWebappsWindowTracker * unity_webapps_window_tracker_get_default () { if (default_tracker == NULL) { #ifndef UNITY_WEBAPPS_TEST_BUILD default_tracker = g_object_new (UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_WNCK, NULL); #else default_tracker = g_object_new (UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_MOCK, NULL); #endif } return default_tracker; } #if defined(ENABLE_TESTS) UnityWebappsWindowTracker * unity_webapps_window_tracker_get_dbus_controllable (GDBusConnection *connection) { return g_object_new (UNITY_WEBAPPS_TYPE_WINDOW_TRACKER_DBUS_CONTROLLABLE, "connection", connection, NULL); } #endif guint64 unity_webapps_window_tracker_get_active_window_id (UnityWebappsWindowTracker *tracker) { g_return_val_if_fail (UNITY_WEBAPPS_IS_WINDOW_TRACKER (tracker), 0); if (UNITY_WEBAPPS_WINDOW_TRACKER_GET_CLASS (tracker)->get_active_window_id) { return UNITY_WEBAPPS_WINDOW_TRACKER_GET_CLASS (tracker)->get_active_window_id (tracker); } return 0; } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-interest-manager.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/interest-tracking/unity-webapps-interest-m0000644000015301777760000001146212321247333033607 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-interest-manager.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_INTEREST_MANAGER_H #define __UNITY_WEBAPPS_INTEREST_MANAGER_H #define UNITY_WEBAPPS_TYPE_INTEREST_MANAGER (unity_webapps_interest_manager_get_type()) #define UNITY_WEBAPPS_INTEREST_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, UnityWebappsInterestManager)) #define UNITY_WEBAPPS_INTEREST_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, UnityWebappsInterestManagerClass)) #define UNITY_WEBAPPS_IS_INTEREST_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_INTEREST_MANAGER)) #define UNITY_WEBAPPS_IS_INTEREST_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_INTEREST_MANAGER)) #define UNITY_WEBAPPS_INTEREST_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_INTEREST_MANAGER, UnityWebappsInterestManagerClass)) typedef struct _UnityWebappsInterestManagerPrivate UnityWebappsInterestManagerPrivate; typedef struct _UnityWebappsInterestManager UnityWebappsInterestManager; struct _UnityWebappsInterestManager { GObject object; UnityWebappsInterestManagerPrivate *priv; // UnityWebappsGenInterestManager *interest_manager_proxy; // GDBusConnection *session_bus; }; typedef struct _UnityWebappsInterest { gint id; gchar *sender; gint64 window; gboolean active; gchar *location; GList *pending_invocations; guint watcher_id; UnityWebappsInterestManager *manager; gboolean ready; } UnityWebappsInterest; typedef struct _UnityWebappsInterestManagerClass UnityWebappsInterestManagerClass; struct _UnityWebappsInterestManagerClass { GObjectClass parent_class; }; GType unity_webapps_interest_manager_get_type (void) G_GNUC_CONST; UnityWebappsInterestManager *unity_webapps_interest_manager_new (); gint unity_webapps_interest_manager_add_interest (UnityWebappsInterestManager *manager, const gchar *interest_name); void unity_webapps_interest_manager_remove_interest (UnityWebappsInterestManager *manager, gint interest_id, gboolean user_abandoned); guint unity_webapps_interest_manager_get_num_interests (UnityWebappsInterestManager *manager); GVariant *unity_webapps_interest_manager_list_interests (UnityWebappsInterestManager *manager); const gchar *unity_webapps_interest_manager_get_interest_owner (UnityWebappsInterestManager *manager, gint interest_id); gboolean unity_webapps_interest_manager_get_interest_is_active (UnityWebappsInterestManager *manager, gint interest_id); void unity_webapps_interest_manager_set_interest_is_active (UnityWebappsInterestManager *manager, gint interest_id, gboolean is_active); const gchar *unity_webapps_interest_manager_get_interest_location (UnityWebappsInterestManager *manager, gint interest_id); void unity_webapps_interest_manager_set_interest_location (UnityWebappsInterestManager *manager, gint interest_id, const gchar *location); guint64 unity_webapps_interest_manager_get_interest_window (UnityWebappsInterestManager *manager, gint interest_id); void unity_webapps_interest_manager_set_interest_window (UnityWebappsInterestManager *manager, gint interest_id, guint64 window); void unity_webapps_interest_manager_clear_preview_requests (UnityWebappsInterestManager *manager, gint interest_id, const gchar *preview_data); void unity_webapps_interest_manager_add_preview_request (UnityWebappsInterestManager *manager, gint interest_id, GDBusMethodInvocation *invocation); gint unity_webapps_interest_manager_get_active_interest_at_window (UnityWebappsInterestManager *manager, guint64 window_id); void unity_webapps_interest_manager_remove_interests_with_name (UnityWebappsInterestManager *manager, const gchar *name); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-debug.c0000644000015301777760000000233212321247333027366 0ustar pbusernogroup00000000000000/* * unity-webapps-debug.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "unity-webapps-debug.h" #include guint unity_webapps_debug_flags = 0; void unity_webapps_debug_initialize_flags () { const gchar *flags; flags = g_getenv("UNITY_WEBAPPS_DEBUG_FLAGS"); if ((flags == NULL) || (strlen(flags) == 0)) { return; } unity_webapps_debug_flags |= g_parse_debug_string (flags, unity_webapps_debug_keys, G_N_ELEMENTS (unity_webapps_debug_keys)); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-music-player-context.c0000644000015301777760000004530112321247333032377 0ustar pbusernogroup00000000000000/* * unity-webapps-music_player-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include "unity-webapps-music-player-context.h" #include "unity-webapps-dbus-defs.h" #include "unity-webapps-interest-manager.h" #include "unity-webapps-interest-tracker.h" #include "unity-webapps-resource-cache.h" #include "unity-webapps-debug.h" #include "config.h" static void emit_music_player_signal (GDBusConnection *connection, const gchar *signal_name); static void player_raise_callback (UnityMusicPlayer *player, gpointer user_data); static void player_next_callback (UnityMusicPlayer *player, gpointer user_data); static void player_previous_callback (UnityMusicPlayer *player, gpointer user_data); static void player_play_pause_callback (UnityMusicPlayer *player, gpointer user_data); typedef struct { UnityTrackMetadata *metadata; gboolean can_go_next, can_go_previous, can_play, can_pause; gint playback_state; } PlayerState; static PlayerState* player_state_new () { PlayerState *res = g_new0 (PlayerState, 1); res->metadata = unity_track_metadata_new (); return res; } static void player_state_free (PlayerState *state) { g_object_unref (state->metadata); g_free (state); } static void emit_playlist_activated_signal (UnityWebappsMusicPlayerContext *indicator_context, const gchar *playlist) { GError *error; UNITY_WEBAPPS_NOTE (INDICATOR, "Emitting PlaylistActivated signal (%s)", playlist); error = NULL; g_dbus_connection_emit_signal (indicator_context->connection, NULL, UNITY_WEBAPPS_MUSIC_PLAYER_PATH, UNITY_WEBAPPS_MUSIC_PLAYER_IFACE, "PlaylistActivated", g_variant_new ("(s)", (gchar *)playlist, NULL), &error); if (error != NULL) { g_warning ("Error emitting PlaylistActivated signal (from sound menu) in music player context: %s", error->message); g_error_free (error); } } static void unity_webapps_music_player_context_playlist_activated (UnityMusicPlayer *player, gchar *playlist_id, gpointer user_data) { UnityWebappsMusicPlayerContext *context; const gchar *playlist_name; context = (UnityWebappsMusicPlayerContext *)user_data; playlist_name = (const gchar *)g_hash_table_lookup (context->playlist_names_by_id, playlist_id); if (playlist_name == NULL) { UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Got playlist activation for playlist we don't know about"); } emit_playlist_activated_signal (context, playlist_name); } static UnityMusicPlayer * get_unity_music_player (UnityWebappsMusicPlayerContext *context) { UnityMusicPlayer *player; if (context->music_player == NULL) { UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Initializing UnityMusicPlayer"); player = unity_music_player_new (context->desktop_name); g_signal_connect (player, "activate-playlist", G_CALLBACK (unity_webapps_music_player_context_playlist_activated), context); unity_music_player_set_is_blacklisted (player, FALSE); g_signal_connect (player, "raise", G_CALLBACK (player_raise_callback), context); g_signal_connect (player, "play_pause", G_CALLBACK (player_play_pause_callback), context); g_signal_connect (player, "next", G_CALLBACK (player_next_callback), context); g_signal_connect (player, "previous", G_CALLBACK (player_previous_callback), context); #ifdef HAVE_UNITY_MUSIC_PLAYER_EXPORT unity_music_player_export (player); #endif unity_music_player_set_title (player, context->label); context->music_player = player; } return context->music_player; } static void real_set_track (UnityWebappsMusicPlayerContext *music_player_context, gint interest_id, const gchar *artist, const gchar *album, const gchar *title, const gchar *art_location) { PlayerState *state; state = g_hash_table_lookup (music_player_context->state_by_interest_id, GINT_TO_POINTER (interest_id)); if (!state) { state = player_state_new (); g_hash_table_replace (music_player_context->state_by_interest_id, GINT_TO_POINTER (interest_id), state); } unity_track_metadata_set_artist (state->metadata, artist); unity_track_metadata_set_album (state->metadata, album); unity_track_metadata_set_title (state->metadata, title); if (art_location != NULL) { GFile *artwork_file = NULL; artwork_file = g_file_new_for_path (art_location); unity_track_metadata_set_art_location (state->metadata, artwork_file); g_object_unref (G_OBJECT (artwork_file)); } if (unity_webapps_interest_tracker_get_most_recent_interest (music_player_context->interest_tracker) == interest_id) unity_music_player_set_current_track (get_unity_music_player (music_player_context), state->metadata); UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Set track: %s", title); } static void player_raise_callback (UnityMusicPlayer *player, gpointer user_data) { UnityWebappsMusicPlayerContext *music_player_context; UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Got Raise callback"); music_player_context = (UnityWebappsMusicPlayerContext *)user_data; unity_webapps_context_daemon_emit_raise (music_player_context->connection, -1, NULL); } static void emit_music_player_signal (GDBusConnection *connection, const gchar *signal_name) { GError *error; UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Emitting signal %s", signal_name); error = NULL; g_dbus_connection_emit_signal (connection, NULL, UNITY_WEBAPPS_MUSIC_PLAYER_PATH, UNITY_WEBAPPS_MUSIC_PLAYER_IFACE, signal_name, NULL /* Params */, &error); if (error != NULL) { g_warning ("Error emitting %s signal in music player context", signal_name); g_error_free (error); return; } } static void player_play_pause_callback (UnityMusicPlayer *player, gpointer user_data) { UnityWebappsMusicPlayerContext *music_player_context; UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Got PlayPause callback"); music_player_context = (UnityWebappsMusicPlayerContext *)user_data; emit_music_player_signal (music_player_context->connection, "PlayPause"); } static void player_previous_callback (UnityMusicPlayer *player, gpointer user_data) { UnityWebappsMusicPlayerContext *music_player_context; UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Got Previous callback"); music_player_context = (UnityWebappsMusicPlayerContext *)user_data; emit_music_player_signal (music_player_context->connection, "Previous"); } static void player_next_callback (UnityMusicPlayer *player, gpointer user_data) { UnityWebappsMusicPlayerContext *music_player_context; UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Got Next callback"); music_player_context = (UnityWebappsMusicPlayerContext *)user_data; emit_music_player_signal (music_player_context->connection, "Next"); } static void unity_webapps_music_player_context_clear_playlists (UnityWebappsMusicPlayerContext *context) { UnityMusicPlayer *player; UnityPlaylist **playlists, *p; gint num_playlists, i; player = get_unity_music_player (context); playlists = unity_music_player_get_playlists (player, &num_playlists); for (i = 0; i < num_playlists; i++) { p = playlists[i]; unity_music_player_remove_playlist (player, p); } g_hash_table_remove_all (context->playlist_names_by_id); g_free (playlists); } static void unity_webapps_music_player_context_set_playlists (UnityWebappsMusicPlayerContext *context, const gchar *const *playlists) { GIcon *icon; UnityMusicPlayer *player; gint i, len; GError *error = NULL; player = get_unity_music_player (context); len = g_strv_length ((gchar **)playlists); icon = g_icon_new_for_string ("playlist-symbolic", &error); if (error != NULL) { UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Failed to load playlist icon"); icon = NULL; } for (i = 0; i < len; i++) { UnityPlaylist *p; const gchar *playlist_name; gchar *id; playlist_name = playlists[i]; id = g_strdup_printf("/Playlist%d", i); p = unity_playlist_new(id); g_hash_table_insert (context->playlist_names_by_id, g_strdup(id), g_strdup (playlist_name)); g_free (id); unity_playlist_set_icon (p, icon); unity_playlist_set_name (p, playlist_name); unity_music_player_add_playlist (player, p); } UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Added %d playlists", len); } static gboolean on_handle_set_playlists (UnityWebappsGenMusicPlayer *music_player, GDBusMethodInvocation *invocation, const gchar *const *playlists, gpointer user_data) { UnityWebappsMusicPlayerContext *music_player_context; UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Handling SetPlaylists call"); music_player_context = (UnityWebappsMusicPlayerContext *)user_data; unity_webapps_music_player_context_clear_playlists (music_player_context); unity_webapps_music_player_context_set_playlists (music_player_context, playlists); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_set_track (UnityWebappsGenMusicPlayer *indicator, GDBusMethodInvocation *invocation, const gchar *artist, const gchar *album, const gchar *title, const gchar *icon_url, gint interest_id, gpointer user_data) { UnityWebappsMusicPlayerContext *context; UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Handling set track: %s by %s from %s", title, artist, album); context = (UnityWebappsMusicPlayerContext *)user_data; if (g_strcmp0 (icon_url, "") == 0) { // TODO: DEFAULT? real_set_track (context, interest_id, artist, album, title, NULL); } else { gchar *tmp_file; tmp_file = unity_webapps_resource_cache_lookup_uri (icon_url); real_set_track (context, interest_id, artist, album, title, tmp_file); g_free (tmp_file); } g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } #define ADD_HANDLER(field, field_type, field_variant_string_arg) \ static gboolean \ on_handle_set_##field (UnityWebappsGenMusicPlayer *indicator, \ GDBusMethodInvocation *invocation, \ gint interest_id, \ field_type field, \ gpointer user_data) \ { \ PlayerState *state; \ UnityWebappsMusicPlayerContext *context; \ context = (UnityWebappsMusicPlayerContext *)user_data; \ state = g_hash_table_lookup (context->state_by_interest_id, GINT_TO_POINTER (interest_id)); \ if (!state) \ { \ state = player_state_new (); \ g_hash_table_replace (context->state_by_interest_id, GINT_TO_POINTER (interest_id), state); \ } \ state->field = field; \ if (context->music_player && unity_webapps_interest_tracker_get_most_recent_interest (context->interest_tracker) == interest_id) \ { \ unity_music_player_set_##field (get_unity_music_player (context), field); \ } \ g_dbus_method_invocation_return_value (invocation, NULL); \ return TRUE; \ } \ static gboolean \ on_handle_get_##field (UnityWebappsGenMusicPlayer *indicator, \ GDBusMethodInvocation *invocation, \ gint interest_id, \ gpointer user_data) \ { \ PlayerState *state; \ UnityWebappsMusicPlayerContext *context; \ field_type field = 0; \ context = (UnityWebappsMusicPlayerContext *)user_data; \ state = g_hash_table_lookup (context->state_by_interest_id, GINT_TO_POINTER (interest_id)); \ state = g_hash_table_lookup (context->state_by_interest_id, GINT_TO_POINTER (interest_id)); \ if (state) \ field = state->field; \ g_dbus_method_invocation_return_value (invocation, \ g_variant_new (field_variant_string_arg, field, NULL)); \ return TRUE; \ } #define FIELD_VARIANT_STRING_INTEGER "(i)" #define FIELD_VARIANT_STRING_BOOLEAN "(b)" ADD_HANDLER(playback_state, gint, FIELD_VARIANT_STRING_INTEGER) ADD_HANDLER(can_go_next, gboolean, FIELD_VARIANT_STRING_BOOLEAN) ADD_HANDLER(can_go_previous, gboolean, FIELD_VARIANT_STRING_BOOLEAN) ADD_HANDLER(can_play, gboolean, FIELD_VARIANT_STRING_BOOLEAN) ADD_HANDLER(can_pause, gboolean, FIELD_VARIANT_STRING_BOOLEAN) #undef ADD_HANDLER static void export_object (GDBusConnection *connection, UnityWebappsMusicPlayerContext *music_player_context) { GError *error; music_player_context->music_player_service_interface = unity_webapps_gen_music_player_skeleton_new (); g_signal_connect (music_player_context->music_player_service_interface, "handle-set-track", G_CALLBACK (on_handle_set_track), music_player_context); g_signal_connect (music_player_context->music_player_service_interface, "handle-set-playlists", G_CALLBACK (on_handle_set_playlists), music_player_context); #define ADD_HANDLER(field, name) \ g_signal_connect (music_player_context->music_player_service_interface,\ "handle-set-" name,\ G_CALLBACK (on_handle_set_##field),\ music_player_context);\ g_signal_connect (music_player_context->music_player_service_interface,\ "handle-get-" name,\ G_CALLBACK (on_handle_get_##field),\ music_player_context); ADD_HANDLER (playback_state, "playback-state"); ADD_HANDLER(can_go_next, "can-go-next"); ADD_HANDLER(can_go_previous, "can-go-previous"); ADD_HANDLER(can_play, "can-play"); ADD_HANDLER(can_pause, "can-pause"); #undef ADD_HANDLER error = NULL; g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (music_player_context->music_player_service_interface), connection, UNITY_WEBAPPS_MUSIC_PLAYER_PATH, &error); if (error != NULL) { g_error ("Error exporting Unity Webapps Music Player object: %s", error->message); g_error_free (error); return; } UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Exported Music Player object"); } static void on_manager_active_changed (UnityWebappsInterestManager *manager, gint interest_id, gboolean is_active, gpointer user_data) { PlayerState *state; UnityWebappsMusicPlayerContext *music_player_context = user_data; if (!is_active) return; if (!g_hash_table_size (music_player_context->state_by_interest_id)) return; state = g_hash_table_lookup (music_player_context->state_by_interest_id, GINT_TO_POINTER (interest_id)); if (!state) { state = player_state_new (); g_hash_table_replace (music_player_context->state_by_interest_id, GINT_TO_POINTER (interest_id), state); } UnityMusicPlayer *player = get_unity_music_player(music_player_context); if (player) { unity_music_player_set_current_track (player, state->metadata); unity_music_player_set_playback_state (player, state->playback_state); unity_music_player_set_can_go_next (player, state->can_go_next); unity_music_player_set_can_go_previous (player, state->can_go_previous); unity_music_player_set_can_play (player, state->can_play); unity_music_player_set_can_pause (player, state->can_pause); } } static void on_manager_interest_removed (UnityWebappsInterestManager *manager, UnityWebappsInterest *interest, gpointer user_data) { UnityWebappsMusicPlayerContext *music_player_context = user_data; g_hash_table_remove (music_player_context->state_by_interest_id, GINT_TO_POINTER (interest->id)); } UnityWebappsMusicPlayerContext * unity_webapps_music_player_context_new (GDBusConnection *connection, UnityWebappsInterestManager *interest_manager, UnityWebappsInterestTracker *interest_tracker, const gchar *desktop_name, const gchar *canonical_name, const gchar *label) { UnityWebappsMusicPlayerContext *music_player_context; UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Creating new UnityWebappsMusicPlayerContext object"); music_player_context = g_malloc0 (sizeof (UnityWebappsMusicPlayerContext)); music_player_context->interest_manager = interest_manager; music_player_context->interest_tracker = interest_tracker; music_player_context->connection = g_object_ref (connection); music_player_context->playlist_names_by_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); music_player_context->state_by_interest_id = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)player_state_free); g_signal_connect (music_player_context->interest_manager, "interest-removed", G_CALLBACK (on_manager_interest_removed), music_player_context); g_signal_connect (music_player_context->interest_manager, "active-changed", G_CALLBACK (on_manager_active_changed), music_player_context); export_object (connection, music_player_context); music_player_context->desktop_name = g_strdup (desktop_name); music_player_context->canonical_name = g_strdup (canonical_name); music_player_context->label = g_strdup (label); return music_player_context; } void unity_webapps_music_player_context_free (UnityWebappsMusicPlayerContext *music_player_context) { g_signal_handlers_disconnect_by_func(music_player_context->interest_manager, on_manager_interest_removed, music_player_context); g_signal_handlers_disconnect_by_func(music_player_context->interest_manager, on_manager_active_changed, music_player_context); UNITY_WEBAPPS_NOTE (MUSIC_PLAYER, "Finalizing UnityWebappsMusicPlayerContext object"); g_object_unref (G_OBJECT (music_player_context->music_player_service_interface)); g_free (music_player_context->desktop_name); g_free (music_player_context->canonical_name); g_free (music_player_context->label); g_hash_table_destroy (music_player_context->playlist_names_by_id); g_hash_table_destroy (music_player_context->state_by_interest_id); if (music_player_context->music_player) { unity_music_player_set_is_blacklisted (music_player_context->music_player, TRUE); #ifdef HAVE_UNITY_MUSIC_PLAYER_EXPORT unity_music_player_unexport (music_player_context->music_player); #endif g_object_unref (G_OBJECT (music_player_context->music_player)); } g_object_unref (G_OBJECT (music_player_context->connection)); g_free (music_player_context); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/presence/0000755000015301777760000000000012321250157025131 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/presence/unity-webapps-telepathy-presence-manager.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/presence/unity-webapps-telepathy-presence-0000644000015301777760000001144012321247333033541 0ustar pbusernogroup00000000000000/* * unity-webapps-telepathy-presence-manager.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-telepathy-presence-manager.h" #include "../unity-webapps-debug.h" #include struct _UnityWebappsTelepathyPresenceManagerPrivate { TpAccountManager *account_manager; }; G_DEFINE_TYPE(UnityWebappsTelepathyPresenceManager, unity_webapps_telepathy_presence_manager, UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER) #define UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_TELEPATHY_PRESENCE_MANAGER, UnityWebappsTelepathyPresenceManagerPrivate)) static gboolean telepathy_presence_manager_get_presence (UnityWebappsPresenceManager *presence_manager, gchar **status, gchar **message) { UnityWebappsTelepathyPresenceManager *manager; manager = UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER (presence_manager); if (manager->priv->account_manager == NULL) { *status = NULL; *message = NULL; return FALSE; } tp_account_manager_get_most_available_presence (manager->priv->account_manager, status, message); if (*status == NULL) { *status = g_strdup ("available"); } return TRUE; } static void unity_webapps_telepathy_presence_manager_finalize (GObject *object) { UnityWebappsTelepathyPresenceManager *manager; manager = UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER (object); if (manager->priv->account_manager) { g_object_unref (G_OBJECT (manager->priv->account_manager)); } } static void unity_webapps_telepathy_presence_manager_class_init (UnityWebappsTelepathyPresenceManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); UnityWebappsPresenceManagerClass *presence_class = UNITY_WEBAPPS_PRESENCE_MANAGER_CLASS (klass); object_class->finalize = unity_webapps_telepathy_presence_manager_finalize; presence_class->get_presence = telepathy_presence_manager_get_presence; g_type_class_add_private (object_class, sizeof(UnityWebappsTelepathyPresenceManagerPrivate)); } static void on_most_available_presence_changed (TpAccountManager *manager, guint presence, gchar *status, gchar *message, gpointer user_data) { UnityWebappsTelepathyPresenceManager *presence_manager; presence_manager = (UnityWebappsTelepathyPresenceManager *)user_data; g_signal_emit_by_name (presence_manager, "presence-changed", status, message); } static void account_manager_prepared (GObject *source_object, GAsyncResult *res, gpointer user_data) { UnityWebappsTelepathyPresenceManager *manager; gchar *status, *message; GError *error; manager = (UnityWebappsTelepathyPresenceManager *)user_data; error = NULL; tp_proxy_prepare_finish (manager->priv->account_manager, res, &error); if (error != NULL) { g_warning ("Error preparing Telepathy Account Manager object for Presence Tracking: %s", error->message); g_error_free (error); return; } telepathy_presence_manager_get_presence (UNITY_WEBAPPS_PRESENCE_MANAGER (manager), &status, &message); g_signal_emit_by_name (manager, "presence-changed", status, message); g_signal_connect (manager->priv->account_manager, "most-available-presence-changed", G_CALLBACK (on_most_available_presence_changed), manager); g_free (status); g_free (message); } static void unity_webapps_telepathy_presence_manager_init (UnityWebappsTelepathyPresenceManager *manager) { manager->priv = UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER_GET_PRIVATE (manager); manager->priv->account_manager = tp_account_manager_dup (); tp_proxy_prepare_async (manager->priv->account_manager, NULL, account_manager_prepared, manager); } UnityWebappsPresenceManager * unity_webapps_telepathy_presence_manager_new () { return UNITY_WEBAPPS_PRESENCE_MANAGER (g_object_new (UNITY_WEBAPPS_TYPE_TELEPATHY_PRESENCE_MANAGER, NULL)); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/presence/unity-webapps-presence-manager.c0000644000015301777760000000447412321247333033331 0ustar pbusernogroup00000000000000/* * unity-webapps-presence-manager.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-presence-manager.h" #include "../unity-webapps-debug.h" struct _UnityWebappsPresenceManagerPrivate { gpointer fill; }; enum { PRESENCE_CHANGED, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_ABSTRACT_TYPE(UnityWebappsPresenceManager, unity_webapps_presence_manager, G_TYPE_OBJECT) #define UNITY_WEBAPPS_PRESENCE_MANAGER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER, UnityWebappsPresenceManagerPrivate)) static void unity_webapps_presence_manager_class_init (UnityWebappsPresenceManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (object_class, sizeof(UnityWebappsPresenceManagerPrivate)); signals[PRESENCE_CHANGED] = g_signal_new ("presence-changed", UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); } static void unity_webapps_presence_manager_init (UnityWebappsPresenceManager *manager) { manager->priv = UNITY_WEBAPPS_PRESENCE_MANAGER_GET_PRIVATE (manager); } gboolean unity_webapps_presence_manager_get_presence (UnityWebappsPresenceManager *manager, gchar **status, gchar **message) { return UNITY_WEBAPPS_PRESENCE_MANAGER_GET_CLASS (manager)->get_presence (manager, status, message); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/presence/unity-webapps-presence-manager.h0000644000015301777760000000475412321247333033337 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-presence-manager.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_PRESENCE_MANAGER_H #define __UNITY_WEBAPPS_PRESENCE_MANAGER_H #define UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER (unity_webapps_presence_manager_get_type()) #define UNITY_WEBAPPS_PRESENCE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER, UnityWebappsPresenceManager)) #define UNITY_WEBAPPS_PRESENCE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER, UnityWebappsPresenceManagerClass)) #define UNITY_WEBAPPS_IS_PRESENCE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER)) #define UNITY_WEBAPPS_IS_PRESENCE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER)) #define UNITY_WEBAPPS_PRESENCE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_PRESENCE_MANAGER, UnityWebappsPresenceManagerClass)) typedef struct _UnityWebappsPresenceManagerPrivate UnityWebappsPresenceManagerPrivate; typedef struct _UnityWebappsPresenceManager UnityWebappsPresenceManager; struct _UnityWebappsPresenceManager { GObject object; UnityWebappsPresenceManagerPrivate *priv; }; typedef struct _UnityWebappsPresenceManagerClass UnityWebappsPresenceManagerClass; struct _UnityWebappsPresenceManagerClass { GObjectClass parent_class; gboolean (*get_presence) (UnityWebappsPresenceManager *self, gchar **status, gchar **message); }; GType unity_webapps_presence_manager_get_type (void) G_GNUC_CONST; gboolean unity_webapps_presence_manager_get_presence (UnityWebappsPresenceManager *manager, gchar **status, gchar **message); #endif ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/presence/unity-webapps-telepathy-presence-manager.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/presence/unity-webapps-telepathy-presence-0000644000015301777760000000527412321247333033551 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-telepathy-presence-manager.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER_H #define __UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER_H #define UNITY_WEBAPPS_TYPE_TELEPATHY_PRESENCE_MANAGER (unity_webapps_telepathy_presence_manager_get_type()) #define UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_TELEPATHY_PRESENCE_MANAGER, UnityWebappsTelepathyPresenceManager)) #define UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_TELEPATHY_PRESENCE_MANAGER, UnityWebappsTelepathyPresenceManagerClass)) #define UNITY_WEBAPPS_IS_TELEPATHY_PRESENCE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_TELEPATHY_PRESENCE_MANAGER)) #define UNITY_WEBAPPS_IS_TELEPATHY_PRESENCE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_TELEPATHY_PRESENCE_MANAGER)) #define UNITY_WEBAPPS_TELEPATHY_PRESENCE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_TELEPATHY_PRESENCE_MANAGER, UnityWebappsTelepathyPresenceManagerClass)) #include "unity-webapps-presence-manager.h" typedef struct _UnityWebappsTelepathyPresenceManagerPrivate UnityWebappsTelepathyPresenceManagerPrivate; typedef struct _UnityWebappsTelepathyPresenceManager UnityWebappsTelepathyPresenceManager; struct _UnityWebappsTelepathyPresenceManager { UnityWebappsPresenceManager manager; UnityWebappsTelepathyPresenceManagerPrivate *priv; }; typedef struct _UnityWebappsTelepathyPresenceManagerClass UnityWebappsTelepathyPresenceManagerClass; struct _UnityWebappsTelepathyPresenceManagerClass { UnityWebappsPresenceManagerClass parent_class; }; GType unity_webapps_telepathy_presence_manager_get_type (void) G_GNUC_CONST; UnityWebappsPresenceManager *unity_webapps_telepathy_presence_manager_new (); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-notification-context.h0000644000015301777760000000305112321247333032454 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-notification-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_NOTIFICATION_CONTEXT_H #define __UNITY_WEBAPPS_NOTIFICATION_CONTEXT_H typedef struct _UnityWebappsNotificationContext UnityWebappsNotificationContext; #include "unity-webapps-context-daemon.h" #include "../unity-webapps-gen-notification.h" struct _UnityWebappsNotificationContext { GDBusConnection *connection; UnityWebappsGenNotification *notification_service_interface; gchar *icon_file_name; }; UnityWebappsNotificationContext *unity_webapps_notification_context_new (GDBusConnection *connection, const gchar *name, const gchar *icon_file_name); void unity_webapps_notification_context_free (UnityWebappsNotificationContext *notification_context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/sound-service.xml0000644000015301777760000000327712321247333026650 0ustar pbusernogroup00000000000000 libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-music-player-context.h0000644000015301777760000000431212321247333032401 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-music-player-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_MUSIC_PLAYER_CONTEXT_H #define __UNITY_WEBAPPS_MUSIC_PLAYER_CONTEXT_H #include typedef struct _UnityWebappsMusicPlayerContext UnityWebappsMusicPlayerContext; #include "../unity-webapps-gen-music-player.h" #include "unity-webapps-context-daemon.h" #include "unity-webapps-dirs.h" typedef struct _UnityWebappsInterestManager UnityWebappsInterestManager; typedef struct _UnityWebappsInterestTracker UnityWebappsInterestTracker; struct _UnityWebappsMusicPlayerContext { GDBusConnection *connection; UnityWebappsGenMusicPlayer *music_player_service_interface; gchar *desktop_name; gchar *canonical_name; gchar *label; UnityMusicPlayer *music_player; gchar *most_recent_client; GHashTable *playlist_names_by_id; GHashTable *state_by_interest_id; UnityWebappsInterestManager *interest_manager; UnityWebappsInterestTracker *interest_tracker; }; UnityWebappsMusicPlayerContext *unity_webapps_music_player_context_new (GDBusConnection *connection, UnityWebappsInterestManager *interest_manager, UnityWebappsInterestTracker *interest_tracker, const gchar *desktop_file_name, const gchar *canonical_name, const gchar *label); void unity_webapps_music_player_context_free (UnityWebappsMusicPlayerContext *music_player_context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-action-manager.c0000644000015301777760000006722212321247333031176 0ustar pbusernogroup00000000000000/* * unity-webapps-action-manager.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include #include "unity-webapps-action-manager.h" #include "unity-webapps-interest-manager.h" #include "unity-webapps-interest-tracker.h" #include "../unity-webapps-debug.h" struct _UnityWebappsActionManagerPrivate { UnityWebappsInterestTracker *interest_tracker; DbusmenuServer *menu_server; DbusmenuMenuitem *menu_item; UnityWebappsInterestManager *interest_manager; GHashTable *actions_by_path; GHashTable *infos_by_interest_id; gchar *menu_path; gboolean use_hierarchy; gboolean track_activity; }; typedef struct _UnityWebappsActionInfo { UnityWebappsActionManager *manager; DbusmenuMenuitem *item; gchar *path; guint ref_count; struct _UnityWebappsActionInfo *parent; } UnityWebappsActionInfo; typedef struct _UnityWebappsHasActionData { UnityWebappsActionManager *manager; const gchar *path; } UnityWebappsHasActionData; G_DEFINE_TYPE(UnityWebappsActionManager, unity_webapps_action_manager, G_TYPE_OBJECT) enum { ACTION_INVOKED, LAST_SIGNAL }; enum { PROP_0, PROP_MENU_OBJECT_PATH, PROP_USE_HIERARCHY, PROP_TRACK_ACTIVITY, PROP_INTEREST_TRACKER }; static guint signals[LAST_SIGNAL] = { 0 }; static UnityWebappsActionInfo * add_menuitem_by_action_path (UnityWebappsActionManager *manager, const gchar *path); #define UNITY_WEBAPPS_ACTION_MANAGER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), UNITY_WEBAPPS_TYPE_ACTION_MANAGER, UnityWebappsActionManagerPrivate)) static void unity_webapps_action_info_ref (UnityWebappsActionInfo *info) { info->ref_count = info->ref_count + 1; UNITY_WEBAPPS_NOTE (ACTION, "Referenced action (%s) new count is %u", info->path, info->ref_count); if (info->parent != NULL) { unity_webapps_action_info_ref (info->parent); } } static void unity_webapps_action_info_unref (UnityWebappsActionInfo *info) { UnityWebappsActionInfo *parent; info->ref_count = info->ref_count - 1; UNITY_WEBAPPS_NOTE (ACTION, "Unreferenced action (%s) new count is %u", info->path, info->ref_count); parent = info->parent; if (info->ref_count == 0) { dbusmenu_menuitem_child_delete (dbusmenu_menuitem_get_parent (info->item), info->item); g_hash_table_remove (info->manager->priv->actions_by_path, info->path); } if (parent != NULL) { unity_webapps_action_info_unref (parent); } } static UnityWebappsActionInfo * unity_webapps_action_info_new (UnityWebappsActionManager *manager, const gchar *path, DbusmenuMenuitem *item, UnityWebappsActionInfo *parent) { UnityWebappsActionInfo *info; info = g_malloc0 (sizeof (UnityWebappsActionInfo)); info->manager = manager; info->path = g_strdup (path); info->parent = parent; g_object_set_qdata (G_OBJECT (item), g_quark_from_static_string("uwa-action"), info); if (info->parent != NULL) { unity_webapps_action_info_ref (info->parent); } info->item = item; info->ref_count = 1; return info; } static void unity_webapps_action_info_free (UnityWebappsActionInfo *info) { g_free (info->path); g_free (info); } static gboolean interest_has_action (UnityWebappsActionManager *manager, gint interest_id, const gchar *path) { GList *action_paths; action_paths = g_hash_table_lookup (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest_id)); if (action_paths == NULL) { return FALSE; } while (action_paths != NULL) { UnityWebappsActionInfo *info; info = (UnityWebappsActionInfo *)(action_paths->data); if (g_strcmp0 (info->path, path) == 0) return TRUE; action_paths = action_paths->next; } return FALSE; } static gint interest_has_action_comparefunc (gpointer a, gpointer b) { gint interest_id = GPOINTER_TO_INT (a); UnityWebappsHasActionData *data = (UnityWebappsHasActionData*) b; if (interest_has_action (data->manager, interest_id, data->path)) { return 0; } return 1; } static gboolean interest_add_action (UnityWebappsActionManager *manager, gint interest_id, UnityWebappsActionInfo *info) { GList *action_infos; gboolean interest_is_active; #ifdef UNITY_WEBAPPS_ENABLE_DEBUG if (interest_has_action (manager, interest_id, info->path) == TRUE) { g_critical ("Trying to add a reference to an action where one exists...this should never happen"); return FALSE; } #endif action_infos = g_hash_table_lookup (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest_id)); action_infos = g_list_append (action_infos, info); g_hash_table_insert (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest_id), action_infos); interest_is_active = unity_webapps_interest_tracker_get_interest_is_active (manager->priv->interest_tracker, interest_id); if (manager->priv->track_activity == TRUE) { if ((interest_is_active == FALSE) && (info->ref_count == 1)) { dbusmenu_menuitem_property_set_bool (info->item, "visible", FALSE); } else if (interest_is_active == TRUE) { dbusmenu_menuitem_property_set_bool (info->item, "visible", TRUE); } } UNITY_WEBAPPS_NOTE (ACTION, "Interest id %d is interested in action %s", interest_id, info->path); return TRUE; } static gboolean interest_remove_action (UnityWebappsActionManager *manager, gint interest_id, UnityWebappsActionInfo *info) { GList *action_infos; action_infos = g_hash_table_lookup (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest_id)); action_infos = g_list_remove (action_infos, info); g_hash_table_insert (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest_id), action_infos); UNITY_WEBAPPS_NOTE (ACTION, "Interest id %d is no longer interested in action %s", interest_id, info->path); return TRUE; } static gchar ** unity_webapps_action_manager_split_action_path (UnityWebappsActionManager *manager, const gchar *action_path) { gchar **components; if (manager->priv->use_hierarchy == FALSE) { components = g_malloc (2 * sizeof (gchar *)); components[0] = g_strdup (action_path); components[1] = NULL; return components; } if (action_path[0] != '/') { return NULL; } components = g_strsplit (action_path+1, "/", -1); if (g_strv_length (components) > 3) { g_strfreev (components); return NULL; } return components; } static gchar * unity_webapps_action_manager_normalize_path (UnityWebappsActionManager *action_manager, const gchar *path) { GString *normalized_path; gchar **components, *ret; gint i, len; components = unity_webapps_action_manager_split_action_path (action_manager, path); if (components == NULL) { return NULL; } len = g_strv_length (components); if (action_manager->priv->use_hierarchy == TRUE) { normalized_path = g_string_new ("/"); } else { normalized_path = g_string_new (""); } for (i = 0; i < len; i++) { gchar *component; component = g_strstrip(components[i]); normalized_path = g_string_append (normalized_path, component); if ((i + 1) != len) { normalized_path = g_string_append (normalized_path, "/"); } } ret = normalized_path->str; g_string_free (normalized_path, FALSE); g_strfreev (components); return ret; } static void on_menuitem_activated (DbusmenuMenuitem *item, guint timestamp, gpointer user_data) { UnityWebappsActionInfo *info; info = (UnityWebappsActionInfo *)user_data; if (info->path == NULL) { UNITY_WEBAPPS_NOTE(ACTION, "Warning: Got a menu item activation (%p), which we do not have a path for.", item); } UNITY_WEBAPPS_NOTE (ACTION, "Dispatching action: %s", info->path); g_signal_emit (info->manager, signals[ACTION_INVOKED], 0, info->path); } static DbusmenuMenuitem * menuitem_find_child_by_label (DbusmenuMenuitem *item, const gchar *label) { const GList *children; const GList *walk; children = dbusmenu_menuitem_get_children (item); for (walk = children; walk != NULL; walk = walk->next) { DbusmenuMenuitem *child; const gchar *child_label; child = (DbusmenuMenuitem *)walk->data; child_label = dbusmenu_menuitem_property_get (child, "label"); if (g_strcmp0 (child_label, label) == 0) { return child; } } return NULL; } static DbusmenuMenuitem * add_menuitem_by_name (UnityWebappsActionManager *manager, DbusmenuMenuitem *parent, const gchar *name, const gchar *full_path, UnityWebappsActionInfo **out_info) { DbusmenuMenuitem *action_item; UnityWebappsActionInfo *info, *parent_info; if (menuitem_find_child_by_label (parent, name) != NULL) { return menuitem_find_child_by_label (parent, name); } action_item = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (action_item, DBUSMENU_MENUITEM_PROP_LABEL, name); dbusmenu_menuitem_property_set_bool (action_item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); parent_info = g_object_get_qdata (G_OBJECT (parent), g_quark_from_static_string ("uwa-action")); info = unity_webapps_action_info_new (manager, full_path, action_item, parent_info); g_hash_table_insert (manager->priv->actions_by_path, g_strdup (full_path), info); g_signal_connect (action_item, "item-activated", G_CALLBACK(on_menuitem_activated), info); dbusmenu_menuitem_child_append (parent, action_item); if (out_info != NULL) { *out_info = info; } return action_item; } static void remove_menuitem_by_info (UnityWebappsActionManager *action_manager, UnityWebappsActionInfo *info, gint interest_id) { if (interest_has_action (action_manager, interest_id, info->path) == FALSE) { return; } interest_remove_action (action_manager, interest_id, info); unity_webapps_action_info_unref (info); } static void remove_menuitem_by_action_path (UnityWebappsActionManager *action_manager, const gchar *path, gint interest_id) { UnityWebappsActionInfo *info; info = (UnityWebappsActionInfo *)g_hash_table_lookup (action_manager->priv->actions_by_path, path); if (info == NULL) return; remove_menuitem_by_info (action_manager, info, interest_id); } static void on_interest_removed (UnityWebappsInterestManager *interest_manager, UnityWebappsInterest *interest, gpointer user_data) { UnityWebappsActionManager *manager; GList *infos, *walk, *to_remove; manager = (UnityWebappsActionManager *)user_data; infos = g_hash_table_lookup (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest->id)); if (infos == NULL) return; to_remove = g_list_copy (infos); for (walk = to_remove; walk != NULL; walk = walk->next) { UnityWebappsActionInfo *info; info = (UnityWebappsActionInfo *)walk->data; UNITY_WEBAPPS_NOTE (ACTION, "Unreferencing action (%s) because it's owned with ID %d vanished", info->path, interest->id); remove_menuitem_by_info (manager, info, interest->id); } g_list_free (to_remove); g_hash_table_remove (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest->id)); } static UnityWebappsActionInfo * add_menuitem_by_action_path (UnityWebappsActionManager *action_manager, const gchar *path) { UnityWebappsActionInfo *info; DbusmenuMenuitem *parent_menuitem; GString *walking_path; gchar **components; gint i, length; gboolean floating; gboolean was_floating; info = (UnityWebappsActionInfo *) g_hash_table_lookup (action_manager->priv->actions_by_path, path); if (info != NULL) { unity_webapps_action_info_ref (info); return info; } components = unity_webapps_action_manager_split_action_path (action_manager, path); if (components == NULL) { return NULL; } parent_menuitem = action_manager->priv->menu_item; length = g_strv_length (components); info = NULL; if (action_manager->priv->use_hierarchy == TRUE) { walking_path = g_string_new ("/"); } else { walking_path = g_string_new (""); } floating = FALSE; was_floating = FALSE; for (i = 0; i < length; i++) { DbusmenuMenuitem *new_parent; gchar *component; component = components[i]; walking_path = g_string_append (walking_path, component); new_parent = menuitem_find_child_by_label (parent_menuitem, component); if (new_parent == NULL) { new_parent = add_menuitem_by_name (action_manager, parent_menuitem, component, walking_path->str, NULL); floating = TRUE; if (new_parent == NULL) { goto out; } } info = g_object_get_qdata (G_OBJECT (parent_menuitem), g_quark_from_static_string ("uwa-action")); if (info != NULL && was_floating) { unity_webapps_action_info_unref (info); } was_floating = floating; floating = FALSE; parent_menuitem = new_parent; // info = g_object_get_qdata (G_OBJECT (parent_menuitem), g_quark_from_static_string ("uwa-action")); walking_path = g_string_append (walking_path, "/"); } info = g_object_get_qdata (G_OBJECT (parent_menuitem), g_quark_from_static_string ("uwa-action")); out: g_string_free (walking_path, TRUE); g_strfreev (components); return info; } static void unity_webapps_action_manager_dispose (GObject *object) { UnityWebappsActionManager *manager; manager = UNITY_WEBAPPS_ACTION_MANAGER (object); if (manager->priv->menu_item) { g_object_unref (G_OBJECT (manager->priv->menu_item)); manager->priv->menu_item = NULL; } if (manager->priv->menu_server) { g_object_unref (G_OBJECT (manager->priv->menu_server)); manager->priv->menu_server = NULL; } if (manager->priv->interest_tracker) { g_object_unref (G_OBJECT (manager->priv->interest_tracker)); manager->priv->interest_tracker = NULL; } } static void unity_webapps_action_manager_finalize (GObject *object) { UnityWebappsActionManager *manager; manager = UNITY_WEBAPPS_ACTION_MANAGER (object); g_hash_table_destroy (manager->priv->actions_by_path); g_hash_table_destroy (manager->priv->infos_by_interest_id); if (manager->priv->menu_path) { g_free (manager->priv->menu_path); } } static void unity_webapps_action_manager_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { UnityWebappsActionManager *self; self = UNITY_WEBAPPS_ACTION_MANAGER (object); switch (property_id) { case PROP_MENU_OBJECT_PATH: g_value_set_string (value, self->priv->menu_path); break; case PROP_USE_HIERARCHY: g_value_set_boolean (value, self->priv->use_hierarchy); break; case PROP_TRACK_ACTIVITY: g_value_set_boolean (value, self->priv->track_activity); break; case PROP_INTEREST_TRACKER: g_value_set_object (value, G_OBJECT (self->priv->interest_tracker)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void unity_webapps_action_manager_create_menu_server (UnityWebappsActionManager *manager) { if (manager->priv->menu_path == NULL) return; manager->priv->menu_server = dbusmenu_server_new (manager->priv->menu_path); dbusmenu_server_set_root (manager->priv->menu_server, manager->priv->menu_item); } static void unity_webapps_action_manager_update_interest_action_visibility (UnityWebappsActionManager *manager, gint interest_id, gboolean visibility) { GList *action_paths; action_paths = g_hash_table_lookup (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest_id)); while (action_paths != NULL) { UnityWebappsActionInfo *action_info; action_info = (UnityWebappsActionInfo *)action_paths->data; dbusmenu_menuitem_property_set_bool (action_info->item, "visible", visibility); action_paths = action_paths->next; } } static void unity_webapps_action_manager_interest_became_active (UnityWebappsInterestManager *interest_manager, gint interest_id, gpointer user_data) { UnityWebappsActionManager *action_manager; action_manager = (UnityWebappsActionManager *)user_data; if (action_manager->priv->track_activity == FALSE) return; unity_webapps_action_manager_update_interest_action_visibility (action_manager, interest_id, TRUE); } static void unity_webapps_action_manager_interest_lost_active (UnityWebappsInterestManager *manager, gint interest_id, gpointer user_data) { UnityWebappsActionManager *action_manager; action_manager = (UnityWebappsActionManager *)user_data; if (action_manager->priv->track_activity == FALSE) return; unity_webapps_action_manager_update_interest_action_visibility (action_manager, interest_id, FALSE); } static void unity_webapps_action_manager_initialize_interest_tracker (UnityWebappsActionManager *manager) { manager->priv->interest_manager = unity_webapps_interest_tracker_get_interest_manager (manager->priv->interest_tracker); g_signal_connect (manager->priv->interest_manager, "interest-removed", G_CALLBACK (on_interest_removed), manager); g_signal_connect_object (manager->priv->interest_tracker, "interest-became-active", G_CALLBACK (unity_webapps_action_manager_interest_became_active), manager, 0); g_signal_connect_object (manager->priv->interest_tracker, "interest-lost-active", G_CALLBACK (unity_webapps_action_manager_interest_lost_active), manager, 0); } static void unity_webapps_action_manager_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { UnityWebappsActionManager *self; self = UNITY_WEBAPPS_ACTION_MANAGER (object); switch (property_id) { case PROP_MENU_OBJECT_PATH: g_return_if_fail (self->priv->menu_path == NULL); self->priv->menu_path = g_value_dup_string (value); unity_webapps_action_manager_create_menu_server (self); break; case PROP_USE_HIERARCHY: self->priv->use_hierarchy = g_value_get_boolean (value); break; case PROP_TRACK_ACTIVITY: self->priv->track_activity = g_value_get_boolean (value); break; case PROP_INTEREST_TRACKER: self->priv->interest_tracker = g_value_dup_object (value); unity_webapps_action_manager_initialize_interest_tracker (self); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void unity_webapps_action_manager_class_init (UnityWebappsActionManagerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = unity_webapps_action_manager_finalize; object_class->dispose = unity_webapps_action_manager_dispose; object_class->get_property = unity_webapps_action_manager_get_property; object_class->set_property = unity_webapps_action_manager_set_property; g_type_class_add_private (object_class, sizeof(UnityWebappsActionManagerPrivate)); g_object_class_install_property (object_class, PROP_MENU_OBJECT_PATH, g_param_spec_string ("menu-path", "Menu Object Path", "The Menu Object Path to export the menu at", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_USE_HIERARCHY, g_param_spec_boolean ("use-hierarchy", "Use Hierarchy", "Whether to use a hierarchy of actions or flat structure", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_TRACK_ACTIVITY, g_param_spec_boolean ("track-activity", "Track Activity", "Whether to track activity and hide items from inactive interests", TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_INTEREST_TRACKER, g_param_spec_object ("interest-tracker", "Interest Tracker", "The interest tracker to use when tracking activity", UNITY_WEBAPPS_TYPE_INTEREST_TRACKER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); signals[ACTION_INVOKED] = g_signal_new ("action-invoked", UNITY_WEBAPPS_TYPE_ACTION_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); } static void unity_webapps_action_manager_init (UnityWebappsActionManager *manager) { manager->priv = UNITY_WEBAPPS_ACTION_MANAGER_GET_PRIVATE (manager); manager->priv->actions_by_path = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)unity_webapps_action_info_free); manager->priv->infos_by_interest_id = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL); manager->priv->menu_item = dbusmenu_menuitem_new (); manager->priv->menu_path = NULL; manager->priv->menu_server = NULL; manager->priv->track_activity = TRUE; manager->priv->interest_tracker = NULL; } UnityWebappsActionManager * unity_webapps_action_manager_new (UnityWebappsInterestTracker *tracker, const gchar *menu_path) { return g_object_new (UNITY_WEBAPPS_TYPE_ACTION_MANAGER, "menu-path", menu_path, "interest-tracker", tracker, NULL); } UnityWebappsActionManager * unity_webapps_action_manager_new_flat (UnityWebappsInterestTracker *tracker, const gchar *menu_path) { return g_object_new (UNITY_WEBAPPS_TYPE_ACTION_MANAGER, "menu-path", menu_path, "use-hierarchy", FALSE, "interest-tracker", tracker, NULL); } /* unity_webapps_action_manager_get_default () { if (default_manager == NULL) { default_manager = g_object_new (UNITY_WEBAPPS_TYPE_ACTION_MANAGER, "menu-path", "/com/canonical/Unity/Webapps/Context/ApplicationActions", NULL); } return default_manager; }*/ void unity_webapps_action_manager_add_action (UnityWebappsActionManager *manager, const gchar *path, gint interest_id) { UnityWebappsActionInfo *info; gchar *normalized_path; normalized_path = unity_webapps_action_manager_normalize_path (manager, path); if (normalized_path == NULL) { return; } if (interest_has_action (manager, interest_id, normalized_path) == TRUE) { UNITY_WEBAPPS_NOTE (ACTION, "Ignoring request to add action as interest with ID %d has already referenced the action (%s)", interest_id, normalized_path); return; } info = add_menuitem_by_action_path (manager, normalized_path); if (info == NULL) { UNITY_WEBAPPS_NOTE (ACTION, "Failed to add action: %s", normalized_path); return; } interest_add_action (manager, interest_id, info); g_free (normalized_path); } void unity_webapps_action_manager_remove_action (UnityWebappsActionManager *manager, const gchar *path, gint interest_id) { gchar *normalized_path; normalized_path = unity_webapps_action_manager_normalize_path (manager, path); if (normalized_path == NULL) { return; } remove_menuitem_by_action_path (manager, normalized_path, interest_id); g_free (normalized_path); } void unity_webapps_action_manager_remove_all_actions (UnityWebappsActionManager *manager, gint interest_id) { GList *action_infos, *walk; action_infos = g_hash_table_lookup (manager->priv->infos_by_interest_id, GINT_TO_POINTER (interest_id)); if (action_infos == NULL) return; action_infos = g_list_copy (action_infos); for (walk = action_infos; walk != NULL; walk = walk->next) { UnityWebappsActionInfo *info; info = (UnityWebappsActionInfo *)walk->data; unity_webapps_action_manager_remove_action (manager, info->path, interest_id); } g_list_free (action_infos); } DbusmenuMenuitem * unity_webapps_action_manager_get_root (UnityWebappsActionManager *manager) { g_return_val_if_fail (UNITY_WEBAPPS_IS_ACTION_MANAGER (manager), NULL); return manager->priv->menu_item; } DbusmenuServer * unity_webapps_action_manager_get_server (UnityWebappsActionManager *manager) { g_return_val_if_fail (UNITY_WEBAPPS_IS_ACTION_MANAGER (manager), NULL); return manager->priv->menu_server; } void unity_webapps_action_manager_set_track_activity (UnityWebappsActionManager *manager, gboolean track_activity) { g_return_if_fail (UNITY_WEBAPPS_IS_ACTION_MANAGER (manager)); manager->priv->track_activity = track_activity; g_object_notify (G_OBJECT (manager), "track-activity"); } static gint compare_action_infos (gconstpointer a, gconstpointer b) { gchar *info_a, *info_b; info_a = (gchar *)a; info_b = (gchar *)b; return g_strcmp0 (info_a, info_b); } GVariant * unity_webapps_action_manager_serialize (UnityWebappsActionManager *manager) { GList *paths, *walk; GVariantBuilder b; g_return_val_if_fail (UNITY_WEBAPPS_IS_ACTION_MANAGER (manager), NULL); paths = g_hash_table_get_keys (manager->priv->actions_by_path); paths = g_list_sort (paths, compare_action_infos); g_variant_builder_init(&b, G_VARIANT_TYPE ("(a(sib))")); g_variant_builder_open (&b, G_VARIANT_TYPE ("a(sib)")); for (walk = paths; walk != NULL; walk = walk->next) { UnityWebappsActionInfo *info; GVariant *info_variant; info = (UnityWebappsActionInfo *)g_hash_table_lookup (manager->priv->actions_by_path, (gchar *)walk->data); info_variant = g_variant_new ("(sib)", info->path, info->ref_count, dbusmenu_menuitem_property_get_bool (info->item, "visible") ,NULL); g_variant_builder_add_value (&b, info_variant); } g_list_free (paths); g_variant_builder_close (&b); return g_variant_builder_end (&b); } gint unity_webapps_action_manager_get_most_recent_interest_with_action (UnityWebappsActionManager *manager, const gchar* path) { GList *interest; GList *most_recent_interests; UnityWebappsHasActionData *data; UnityWebappsInterestTracker *tracker; data = g_malloc (sizeof (*data)); data->manager = manager; data->path = path; tracker = manager->priv->interest_tracker; most_recent_interests = unity_webapps_interest_tracker_get_most_recent_interests (tracker); interest = g_list_find_custom (most_recent_interests, data, (GCompareFunc) interest_has_action_comparefunc); g_free (data); if (interest == NULL) return -1; return GPOINTER_TO_INT (interest->data); } ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-preinstalled-application-info.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-preinstalled-application-inf0000644000015301777760000000573012321247333033625 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-preinstalled-application-info.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO_H #define __UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO_H #include "unity-webapps-application-info.h" #define UNITY_WEBAPPS_TYPE_PREINSTALLED_APPLICATION_INFO (unity_webapps_preinstalled_application_info_get_type()) #define UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UNITY_WEBAPPS_TYPE_PREINSTALLED_APPLICATION_INFO, UnityWebappsPreinstalledApplicationInfo)) #define UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UNITY_WEBAPPS_TYPE_PREINSTALLED_APPLICATION_INFO, UnityWebappsPreinstalledApplicationInfoClass)) #define UNITY_WEBAPPS_IS_PREINSTALLED_APPLICATION_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UNITY_WEBAPPS_TYPE_PREINSTALLED_APPLICATION_INFO)) #define UNITY_WEBAPPS_IS_PREINSTALLED_APPLICATION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_WEBAPPS_TYPE_PREINSTALLED_APPLICATION_INFO)) #define UNITY_WEBAPPS_PREINSTALLED_APPLICATION_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UNITY_WEBAPPS_TYPE_PREINSTALLED_APPLICATION_INFO, UnityWebappsPreinstalledApplicationInfoClass)) typedef struct _UnityWebappsPreinstalledApplicationInfoPrivate UnityWebappsPreinstalledApplicationInfoPrivate; typedef struct _UnityWebappsPreinstalledApplicationInfo UnityWebappsPreinstalledApplicationInfo; struct _UnityWebappsPreinstalledApplicationInfo { UnityWebappsApplicationInfo object; UnityWebappsPreinstalledApplicationInfoPrivate *priv; }; typedef struct _UnityWebappsPreinstalledApplicationInfoClass UnityWebappsPreinstalledApplicationInfoClass; struct _UnityWebappsPreinstalledApplicationInfoClass { UnityWebappsApplicationInfoClass parent_class; }; GType unity_webapps_preinstalled_application_info_get_type (void) G_GNUC_CONST; UnityWebappsApplicationInfo *unity_webapps_preinstalled_application_info_new (const gchar *name, const gchar *domain, const gchar *icon_url, const gchar *mime_types, const gchar *desktop_name); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-notification-context.c0000644000015301777760000001224412321247333032453 0ustar pbusernogroup00000000000000/* * unity-webapps-notification-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-notification-context.h" #include "unity-webapps-resource-cache.h" #include "unity-webapps-dbus-defs.h" #include "unity-webapps-gen-notification.h" #include "unity-webapps-debug.h" static void real_show_notification (const gchar *summary, const gchar *body, const gchar *icon_url, GError **error) { NotifyNotification *notification; error = NULL; notification = notify_notification_new (summary, body, icon_url); notify_notification_set_timeout (notification, 4); notify_notification_show (notification, error); if ((error != NULL) && (*error != NULL)) { g_warning ("Error showing notification: %s", (*error)->message); } g_object_unref (G_OBJECT (notification)); } static void show_notification (const gchar *summary, const gchar *body, const gchar *icon_url, const gchar *default_path, GError **error) { if ( (icon_url == NULL) || (icon_url[0] == '/') ) { real_show_notification (summary, body, icon_url, error); } else { gchar *icon_path; icon_path = unity_webapps_resource_cache_lookup_uri (icon_url); if (icon_path == NULL) { UNITY_WEBAPPS_NOTE (NOTIFICATION, "Resource path from cache for uri %s was NULL using application icon for notification", icon_url); real_show_notification (summary, body, default_path, error); } else { real_show_notification (summary, body, icon_path, error); } g_free (icon_path); } } static gboolean on_handle_show_notification (UnityWebappsGenNotification *notification, GDBusMethodInvocation *invocation, const gchar *summary, const gchar *body, const gchar *icon_url, gpointer user_data) { UnityWebappsNotificationContext *notification_context = (UnityWebappsNotificationContext *)user_data; GError *error; UNITY_WEBAPPS_NOTE (NOTIFICATION, "Handling ShowNotification call, summary: %s", summary); if ((icon_url == NULL) || (g_strcmp0 (icon_url, "") == 0)) { UNITY_WEBAPPS_NOTE (NOTIFICATION, "Notification contains empty URL, using application icon for notification"); icon_url = notification_context->icon_file_name; } error = NULL; show_notification (summary, body, icon_url, notification_context->icon_file_name, &error); if (error != NULL) { g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); } return TRUE; } static void export_object (GDBusConnection *connection, UnityWebappsNotificationContext *notification_context) { GError *error; notification_context->notification_service_interface = unity_webapps_gen_notification_skeleton_new (); g_signal_connect (notification_context->notification_service_interface, "handle-show-notification", G_CALLBACK (on_handle_show_notification), notification_context); error = NULL; g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (notification_context->notification_service_interface), connection, UNITY_WEBAPPS_NOTIFICATION_PATH, &error); if (error != NULL) { g_error ("Error exporting Unity Webapps Notification object: %s", error->message); g_error_free (error); return; } UNITY_WEBAPPS_NOTE (NOTIFICATION, "Exported Notification object"); } UnityWebappsNotificationContext * unity_webapps_notification_context_new (GDBusConnection *connection, const gchar *name, const gchar *icon_file_name) { UnityWebappsNotificationContext *notification_context; UNITY_WEBAPPS_NOTE (NOTIFICATION, "Creating new Notification Context"); notify_init (name); notification_context = g_malloc0 (sizeof (UnityWebappsNotificationContext)); notification_context->icon_file_name = g_strdup (icon_file_name); notification_context->connection = g_object_ref (G_OBJECT (connection)); export_object (connection, notification_context); return notification_context; } void unity_webapps_notification_context_free (UnityWebappsNotificationContext *notification_context) { UNITY_WEBAPPS_NOTE (NOTIFICATION, "Finalizing Notification Context"); g_object_unref (G_OBJECT (notification_context->notification_service_interface)); g_free (notification_context->icon_file_name); g_object_unref (G_OBJECT (notification_context->connection)); g_free (notification_context); } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/0000755000015301777760000000000012321250157026215 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-factory.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-fact0000644000015301777760000002230512321247333033513 0ustar pbusernogroup00000000000000/* * unity-webapps-resource-factory.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include "unity-webapps-dirs.h" #include "unity-webapps-resource-cache.h" #include "unity-webapps-resource-factory.h" #include "unity-webapps-gio-utils.h" #include "../unity-webapps-debug.h" #define MAXIMUM_DOWNLOAD_SIZE 100*1024 static gboolean check_file_too_large_or_empty (GFile *resource_file) { GFileInfo *resource_file_info; gsize file_size; gboolean too_large; GError *error; UNITY_WEBAPPS_NOTE (RESOURCE, "Resource factory checking size of file: %s", g_file_get_uri (resource_file)); error = NULL; resource_file_info = g_file_query_info (resource_file, "standard::size", G_FILE_QUERY_INFO_NONE, NULL /* Cancellable */, &error); if (error != NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Error querying URI info for resource size check: %s", error->message); g_error_free (error); return TRUE; } file_size = g_file_info_get_size (resource_file_info); too_large = file_size > MAXIMUM_DOWNLOAD_SIZE; #ifdef UNITY_WEBAPPS_ENABLE_DEBUG if (too_large == TRUE) { UNITY_WEBAPPS_NOTE(RESOURCE, "Resource factory found file at URI was too large: %s", g_file_get_uri (resource_file)); } #endif g_object_unref (G_OBJECT (resource_file_info)); return too_large; } static GFile * http_make_file_from_resource_uri (const gchar *resource_uri) { return g_file_new_for_uri (resource_uri); } static gchar * resource_file_name (const gchar *resource_uri) { const gchar *resource_dir; gchar *filename, *checksum; resource_dir = unity_webapps_dirs_get_resource_dir (); checksum = unity_webapps_resource_cache_checksum_for_uri (resource_uri); filename = g_build_filename (resource_dir, checksum, NULL); g_free (checksum); return filename; } static gboolean parse_data_uri (const gchar *data_uri, gchar **mimetype, gchar **data) { gchar **split; int result; g_assert (g_str_has_prefix (data_uri, "data:") == TRUE); split = g_strsplit (data_uri+5, ";base64,", 2); result = g_strv_length (split); if (result != 2) { UNITY_WEBAPPS_NOTE (RESOURCE, "Failed to parse data uri: \n %s \n", data_uri); *mimetype = NULL; *data = NULL; g_strfreev (split); return FALSE; } *mimetype = split[0]; *data = split[1]; g_free (split); if (g_str_has_prefix (*mimetype, "image/") == FALSE) { UNITY_WEBAPPS_NOTE (RESOURCE, "Data URI does not have an image mimetype"); g_free (*data); *mimetype = NULL; *data = NULL; return FALSE; } return TRUE; } static gboolean save_data_to_file (const guchar *data, gsize data_length, const gchar *resource_name) { GFile *resource_file; GFileOutputStream *output_stream; gsize bytes_written; gboolean saved; GError *error; resource_file = g_file_new_for_path (resource_name); error = NULL; output_stream = g_file_replace (resource_file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, &error); if (error != NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Error opening %s to save data URI: %s", resource_name, error->message); g_error_free (error); g_object_unref (G_OBJECT (resource_file)); return FALSE; } saved = g_output_stream_write_all (G_OUTPUT_STREAM (output_stream), data, data_length, &bytes_written, NULL, &error); if (error != NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Error writing to file (%s) in saving data URI: %s", resource_name, error->message); g_error_free (error); } g_object_unref (G_OBJECT (output_stream)); g_object_unref (G_OBJECT (resource_file)); return saved; } static gboolean data_uri_to_file (const gchar *resource_uri, const gchar *resource_name) { gchar *mimetype, *data; guchar *decoded; gsize decoded_length; gboolean parsed, saved; mimetype = NULL; data = NULL; parsed = parse_data_uri (resource_uri, &mimetype, &data); if (parsed == FALSE) { UNITY_WEBAPPS_NOTE (RESOURCE, "Failed to save data uri"); return FALSE; } decoded = g_base64_decode (data, &decoded_length); g_assert (decoded != NULL); saved = save_data_to_file (decoded, decoded_length, resource_name); g_free (mimetype); g_free (data); g_free (decoded); return saved; } static GFile * data_uri_make_file_from_resource_uri (const gchar *icon_uri) { GFile *local_file; gchar *tmp_name; tmp_name = tempnam (NULL, "uwatf"); data_uri_to_file (icon_uri, tmp_name); local_file = g_file_new_for_path (tmp_name); g_free (tmp_name); return local_file; } static gchar * get_themed_resource_path (const gchar *icon_name) { GtkIconTheme *theme; GtkIconInfo *info; gchar *icon_path; if (icon_name == NULL) return NULL; theme = gtk_icon_theme_get_default (); UNITY_WEBAPPS_NOTE (RESOURCE, "Resource factory looking up icon name: %s", icon_name); info = gtk_icon_theme_lookup_icon (theme, icon_name, 48, 0); if (info == NULL) { return NULL; } icon_path = g_strdup (gtk_icon_info_get_filename (info)); gtk_icon_info_free (info); return icon_path; } static GFile * icon_uri_make_file_from_resource_uri (const gchar *resource_uri) { GFile *resource_file; gchar *resource_path; resource_path = get_themed_resource_path (resource_uri+7); resource_file = g_file_new_for_path (resource_path); g_free (resource_path); return resource_file; } static GFile * make_file_from_resource_uri (const gchar *resource_uri, gboolean allow_themed_icons) { GFile *resource_file; gboolean too_large; resource_file = NULL; UNITY_WEBAPPS_NOTE (RESOURCE, "Resource factory making file from resource URI (%s)", resource_uri); if (g_str_has_prefix (resource_uri, "http://") || g_str_has_prefix (resource_uri, "https://")) { UNITY_WEBAPPS_NOTE (RESOURCE, "Making file from HTTP URI"); resource_file = http_make_file_from_resource_uri (resource_uri); } else if (g_str_has_prefix (resource_uri, "data:")) { UNITY_WEBAPPS_NOTE (RESOURCE, "Making file from data URI"); if (strlen (resource_uri) > MAXIMUM_DOWNLOAD_SIZE) { g_warning ("Icon URI greater than maximum download size (size of uri is %d bytes)", (gint)strlen (resource_uri)); resource_file = NULL; } else { resource_file = data_uri_make_file_from_resource_uri (resource_uri); } } else if (g_str_has_prefix (resource_uri, "icon://") && allow_themed_icons) { UNITY_WEBAPPS_NOTE (RESOURCE, "Making file from theme URI"); resource_file = icon_uri_make_file_from_resource_uri (resource_uri); } if (resource_file != NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Succesfully created resource file for URI (%s): %s", resource_uri, g_file_get_uri (resource_file)); too_large = check_file_too_large_or_empty (resource_file); if (too_large == TRUE) { UNITY_WEBAPPS_NOTE (RESOURCE, "Icon file is too large or empty %s", resource_uri); g_object_unref (G_OBJECT (resource_file)); resource_file = NULL; } } return resource_file; } gchar * unity_webapps_resource_factory_resource_path_for_uri (const gchar *resource_uri, gboolean allow_themed_icons) { GFile *resource_file, *local_file; gchar *resource_name; gboolean spliced; UNITY_WEBAPPS_NOTE (RESOURCE, "Resource Factory getting resource path for URI (%s)", resource_uri); if (allow_themed_icons && g_str_has_prefix (resource_uri, "icon://")) { return get_themed_resource_path (resource_uri+7); } resource_file = make_file_from_resource_uri (resource_uri, allow_themed_icons); if (resource_file == NULL) { return NULL; } resource_name = resource_file_name (resource_uri); local_file = g_file_new_for_path (resource_name); UNITY_WEBAPPS_NOTE (RESOURCE, "Resource Factory downloading file at %s to resource file", resource_uri); spliced = unity_webapps_gio_utils_splice_files (resource_file, local_file); if (spliced == FALSE) { UNITY_WEBAPPS_NOTE (RESOURCE, "Error saving resource file (%s) to %s", resource_uri, resource_name); g_free (resource_name); resource_name = NULL; } g_object_unref (G_OBJECT (resource_file)); g_object_unref (G_OBJECT (local_file)); return resource_name; } ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-cache.clibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-cach0000644000015301777760000000524712321247333033502 0ustar pbusernogroup00000000000000/* * unity-webapps-resource-cache.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include "unity-webapps-dirs.h" #include "unity-webapps-resource-db.h" #include "unity-webapps-resource-cache.h" #include "unity-webapps-resource-factory.h" #include "../unity-webapps-debug.h" gchar * unity_webapps_resource_cache_checksum_for_uri (const gchar *resource_uri) { gchar *checksum; checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, resource_uri, -1); return checksum; } gchar * unity_webapps_resource_cache_lookup_uri (const gchar *resource_uri) { gchar *checksum, *path; UNITY_WEBAPPS_NOTE (RESOURCE, "Looking up URI (%s) in resource cache", resource_uri); if (resource_uri == NULL) { return NULL; } if (g_str_has_prefix (resource_uri, "icon://")) { UNITY_WEBAPPS_NOTE (RESOURCE, "Resource (%s) is a themed resource, skipping the cache", resource_uri); path = unity_webapps_resource_factory_resource_path_for_uri (resource_uri, TRUE); return path; } checksum = unity_webapps_resource_cache_checksum_for_uri (resource_uri); path = unity_webapps_resource_db_lookup_path (checksum); if (path == NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Cache miss, creating new resource"); path = unity_webapps_resource_factory_resource_path_for_uri (resource_uri, TRUE); if (path == NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Resource Cache failed to get resource path for URI: %s", resource_uri); goto out; } UNITY_WEBAPPS_NOTE (RESOURCE, "Obtained resource file, storing entry in database for URI: %s", resource_uri); unity_webapps_resource_db_store_entry (checksum, path); } #ifdef UNITY_WEBAPPS_ENABLE_DEBUG else { UNITY_WEBAPPS_NOTE (RESOURCE, "Cache hit for %s: %s", resource_uri, path); } #endif out: g_free (checksum); return path; } libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-db.c0000644000015301777760000003276712321247333033421 0ustar pbusernogroup00000000000000/* * unity-webapps-resource-db.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include #include #include #include #include #include "unity-webapps-dirs.h" #include "unity-webapps-resource-db.h" #include "../unity-webapps-debug.h" static sqlite3 *resource_db = NULL; #ifndef UNITY_WEBAPPS_TEST_BUILD #define MAXIMUM_DIRECTORY_SIZE (1024*1024*10) #else #define MAXIMUM_DIRECTORY_SIZE (1024) #endif #define STALE_TIME (60*10) #define CREATE_RESOURCES_TABLE_SQL "CREATE TABLE IF NOT EXISTS resources(id INTEGER PRIMARY KEY, nameHash TEXT, resourcePath TEXT, lru INTEGER, timestamp INTEGER);" static goffset get_resource_directory_size () { GFileEnumerator *children; GFile *resource_dir; GFileInfo *child; const gchar *resource_dir_path; GError *error; gsize ret; children = NULL; ret = 0; resource_dir_path = unity_webapps_dirs_get_resource_dir(); resource_dir = g_file_new_for_path (resource_dir_path); g_assert (resource_dir); error = NULL; children = g_file_enumerate_children (resource_dir, "standard::name,standard::size", G_FILE_QUERY_INFO_NONE, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Failed to enumerate resources: %s", error->message); g_error_free (error); goto out; } error = NULL; while ((child = g_file_enumerator_next_file (children, NULL /* Cancellable */, &error))) { if (error != NULL) { g_critical ("Failed to enumerate resources: %s", error->message); g_error_free (error); goto out; } ret += g_file_info_get_size (child); g_object_unref (child); } UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB total size computed: %lu", (unsigned long)ret); out: g_object_unref (G_OBJECT (resource_dir)); g_object_unref (G_OBJECT (children)); return ret; } static void create_resources_table () { int rc; gchar *error_message; error_message = NULL; rc = sqlite3_exec (resource_db, CREATE_RESOURCES_TABLE_SQL, NULL, 0, &error_message); if (rc != SQLITE_OK) { g_critical ("Error creating resources table %s \n", error_message); sqlite3_free (error_message); sqlite3_close (resource_db); resource_db = NULL; } } gboolean unity_webapps_resource_db_open () { const gchar *uw_dir; gchar *database_file; gboolean ret; int rc; ret = TRUE; uw_dir = unity_webapps_dirs_get_user_dir (); database_file = g_build_filename (uw_dir, "resources.db", NULL); UNITY_WEBAPPS_NOTE (RESOURCE, "Opening Resource DB (%s)", database_file); rc = sqlite3_open (database_file, &resource_db); if (rc != 0) { g_critical ("Failed to open resources database: %s", sqlite3_errmsg(resource_db)); sqlite3_close (resource_db); ret = FALSE; goto out; } create_resources_table (); out: g_free (database_file); return ret; } #define LRU_LAST_STATEMENT_SQL_TEMPLATE "SELECT lru,nameHash FROM resources ORDER BY lru DESC;" static sqlite3_stmt * db_get_lru_prepare_statement () { sqlite3_stmt *last_statement; int rc; last_statement = NULL; rc = sqlite3_prepare_v2 (resource_db, LRU_LAST_STATEMENT_SQL_TEMPLATE, -1, &last_statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile last LRU SQL statement: %s", sqlite3_errmsg (resource_db)); goto out; } out: return last_statement; } static gchar * db_get_lru () { sqlite3_stmt *lru_statement; gchar *lru; gint rc; lru = NULL; lru_statement = db_get_lru_prepare_statement (); if (lru_statement == NULL) { return NULL; } rc = sqlite3_step (lru_statement); if (rc == SQLITE_ROW) { lru = g_strdup ((const gchar *)sqlite3_column_text (lru_statement, 1)); } UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB found LRU entry: %s", lru); sqlite3_finalize (lru_statement); return lru; } #define DROP_LRU_STATEMENT_SQL_TEMPLATE "DELETE FROM resources WHERE nameHash='%s';" static sqlite3_stmt * db_drop_name_prepare_statement (const gchar *name_hash) { sqlite3_stmt *drop_statement; gchar *drop_sql; gint rc; drop_statement = NULL; if (name_hash == NULL) { UNITY_WEBAPPS_NOTE (CONTEXT, "Trying to drop a name that doesn't exist from the resource database. Probably means it was mangled with."); return NULL; } drop_sql = g_strdup_printf (DROP_LRU_STATEMENT_SQL_TEMPLATE, name_hash); rc = sqlite3_prepare_v2 (resource_db, drop_sql, -1, &drop_statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile drop LRU sql statement: %s", sqlite3_errmsg (resource_db)); goto out; } out: g_free (drop_sql); return drop_statement; } static void db_drop_name_remove_file (const gchar *name_hash) { GFile *resource_file; const gchar *resource_dir; gchar *resource_path; GError *error; resource_dir = unity_webapps_dirs_get_resource_dir(); resource_path = g_build_filename (resource_dir, name_hash, NULL); resource_file = g_file_new_for_path (resource_path); UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB about to delete file: %s", resource_path); if (g_file_test (resource_path, G_FILE_TEST_EXISTS) == FALSE) { UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB found file already deleted"); return; } if (resource_file == NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB couldn't open file for deletion: %s", resource_path); g_free (resource_path); } error = NULL; g_file_delete (resource_file, NULL /* Cancellable */, &error); if (error != NULL) { g_critical ("Error deleting resource file: %s", error->message); g_error_free (error); goto out; } out: g_free (resource_path); } static void db_drop_name (const gchar *name_hash) { sqlite3_stmt *drop_statement; gint rc; UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB dropping name: %s", name_hash); drop_statement = db_drop_name_prepare_statement (name_hash); if (drop_statement == NULL) { return; } rc = sqlite3_step (drop_statement); if (rc != SQLITE_DONE) { UNITY_WEBAPPS_NOTE (CONTEXT, "Error executing Drop statement: %s", sqlite3_errmsg (resource_db)); goto out; } db_drop_name_remove_file (name_hash); out: sqlite3_finalize (drop_statement); } static void db_drop_lru () { gchar *lru; lru = db_get_lru (); db_drop_name (lru); g_free (lru); } #define LRU_STATEMENT_SQL_TEMPLATE "SELECT lru FROM resources ORDER BY LRU DESC;" static sqlite3_stmt * db_get_next_lru_prepare_statement () { sqlite3_stmt *lru_statement; int rc; lru_statement = NULL; rc = sqlite3_prepare_v2 (resource_db, LRU_STATEMENT_SQL_TEMPLATE, -1, &lru_statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile next lru SQL statement: %s", sqlite3_errmsg (resource_db)); goto out; } out: return lru_statement; } static gint db_get_next_lru () { sqlite3_stmt *lru_statement; gint max_lru, rc; lru_statement = db_get_next_lru_prepare_statement (); if (lru_statement == NULL) { return 0; } rc = sqlite3_step (lru_statement); max_lru = 0; if (rc == SQLITE_ROW) { max_lru = sqlite3_column_int (lru_statement, 0); } sqlite3_finalize (lru_statement); return max_lru + 1; } #define UPDATE_LRU_STATEMENT_SQL_TEMPLATE "UPDATE resources SET lru=%d WHERE nameHash='%s';" static sqlite3_stmt * db_update_lru_prepare_statement (const gchar *name_hash) { sqlite3_stmt *update_statement; gchar *update_sql; gint next_lru, rc; update_statement = NULL; next_lru = db_get_next_lru (); update_sql = g_strdup_printf (UPDATE_LRU_STATEMENT_SQL_TEMPLATE, next_lru, name_hash); rc = sqlite3_prepare_v2 (resource_db, update_sql, -1, &update_statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile update LRU SQL statement: %s", sqlite3_errmsg (resource_db)); goto out; } out: g_free (update_sql); return update_statement; } static void db_update_lru (const gchar *name_hash) { sqlite3_stmt *update_statement; gint rc; update_statement = db_update_lru_prepare_statement (name_hash); if (update_statement == NULL) { return; } rc = sqlite3_step (update_statement); if (rc != SQLITE_DONE) { UNITY_WEBAPPS_NOTE (CONTEXT, "Error updating LRU for resource: %s", sqlite3_errmsg (resource_db)); goto out; } out: sqlite3_finalize (update_statement); } #define LOOKUP_STATEMENT_SQL_TEMPLATE "SELECT resourcePath,timestamp FROM resources where nameHash='%s';" static sqlite3_stmt * db_lookup_prepare_statement (const gchar *name_hash) { sqlite3_stmt *lookup_statement = NULL; gchar *lookup_sql; int rc; lookup_sql = g_strdup_printf (LOOKUP_STATEMENT_SQL_TEMPLATE, name_hash); rc = sqlite3_prepare_v2 (resource_db, lookup_sql, -1, &lookup_statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile lookup SQL statement: %s", sqlite3_errmsg (resource_db)); goto out; } out: g_free (lookup_sql); return lookup_statement; } static gboolean timestamp_is_stale (glong timestamp) { time_t current_time; current_time = time (NULL); if (current_time - timestamp > STALE_TIME) { return TRUE; } else { return FALSE; } } gchar * unity_webapps_resource_db_lookup_path (const gchar *name_hash) { sqlite3_stmt *lookup_statement; gchar *resource_path; int rc; resource_path = NULL; lookup_statement = db_lookup_prepare_statement (name_hash); UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB looking up entry: %s", name_hash); if (lookup_statement == NULL) { UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB couldn't find an entry for %s", name_hash); return resource_path; } rc = sqlite3_step (lookup_statement); if (rc == SQLITE_ROW) { glong timestamp; timestamp = sqlite3_column_int (lookup_statement, 1); if (timestamp_is_stale (timestamp)) { UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB found entry for %s but timestamp (%ld) is stale", name_hash, timestamp); db_drop_name (name_hash); } else { resource_path = g_strdup ((const gchar *)sqlite3_column_text (lookup_statement, 0)); db_update_lru (name_hash); } } sqlite3_finalize (lookup_statement); // TODO: FIXME: Maybe should use GIO this is a path not a URI but should it really be? WHO KNOWS -racarr? if (resource_path && g_file_test (resource_path, G_FILE_TEST_EXISTS) == FALSE) { UNITY_WEBAPPS_NOTE (RESOURCE, "Resource DB found entry, but file %s is deleted, purging it from the database", resource_path); db_drop_name (name_hash); g_free (resource_path); return NULL; } return resource_path; } #define INSERT_STATEMENT_SQL_TEMPLATE "INSERT INTO resources (nameHash, resourcePath, timestamp) VALUES ('%s', '%s', %ld)" static sqlite3_stmt * db_insert_prepare_statement (const gchar *name_hash, const gchar *resource_path) { sqlite3_stmt *insert_statement; gchar *insert_sql; GTimeVal current_time; int rc; insert_statement = NULL; g_get_current_time (¤t_time); insert_sql = g_strdup_printf (INSERT_STATEMENT_SQL_TEMPLATE, name_hash, resource_path, time (NULL)); rc = sqlite3_prepare_v2 (resource_db, insert_sql, -1, &insert_statement, NULL); if (rc != SQLITE_OK) { g_critical ("Failed to compile insert SQL statement: %s", sqlite3_errmsg (resource_db)); goto out; } out: g_free (insert_sql); return insert_statement; } static void unity_webapps_resource_db_ensure_within_size () { goffset size; size = get_resource_directory_size (); if (size < MAXIMUM_DIRECTORY_SIZE) { return; } else { UNITY_WEBAPPS_NOTE (RESOURCE, "Resource database too large, dropping LRU"); db_drop_lru (); } } gboolean unity_webapps_resource_db_store_entry (const gchar *name_hash, const gchar *resource_path) { sqlite3_stmt *insert_statement; gint rc; gboolean ret; ret = TRUE; unity_webapps_resource_db_ensure_within_size (); insert_statement = db_insert_prepare_statement (name_hash, resource_path); if (insert_statement == NULL) { return FALSE; } rc = sqlite3_step (insert_statement); if (rc != SQLITE_DONE) { UNITY_WEBAPPS_NOTE (RESOURCE, "Error storing entry in resource db: %s", sqlite3_errmsg (resource_db)); ret = FALSE; goto out; } UNITY_WEBAPPS_NOTE (RESOURCE, "Resource database stored resource: %s at %s", name_hash, resource_path); db_update_lru (name_hash); out: sqlite3_finalize (insert_statement); return ret; } ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-factory.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-fact0000644000015301777760000000210312321247333033505 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-resource-cache.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_RESOURCE_FACTORY_H #define __UNITY_WEBAPPS_RESOURCE_FACTORY_H gchar *unity_webapps_resource_factory_resource_path_for_uri (const gchar *resource_uri, gboolean allow_themed_icons); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-db.h0000644000015301777760000000223512321247333033411 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-resource-factory.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_RESOURCE_DB_H #define __UNITY_WEBAPPS_RESOURCE_DB_H gboolean unity_webapps_resource_db_open (); gchar *unity_webapps_resource_db_lookup_path (const gchar *name_hash); gboolean unity_webapps_resource_db_store_entry (const gchar *name_hash, const gchar *resource_path); #endif ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-cache.hlibunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/resource-cache/unity-webapps-resource-cach0000644000015301777760000000214712321247333033476 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-resource-cache.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_RESOURCE_CACHE_H #define __UNITY_WEBAPPS_RESOURCE_CACHE_H gchar *unity_webapps_resource_cache_checksum_for_uri (const gchar *resource_uri); gchar *unity_webapps_resource_cache_lookup_uri (const gchar *resource_uri); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-launcher-context.h0000644000015301777760000000352412321247333031574 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-launcher-context.h * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #ifndef __UNITY_WEBAPPS_LAUNCHER_CONTEXT_H #define __UNITY_WEBAPPS_LAUNCHER_CONTEXT_H typedef struct _UnityWebappsLauncherContext UnityWebappsLauncherContext; #include "unity-webapps-context-daemon.h" #include "unity-webapps-action-manager.h" #include "unity-webapps-application-info.h" #include "../unity-webapps-gen-launcher.h" #include #include struct _UnityWebappsLauncherContext { GDBusConnection *connection; UnityWebappsGenLauncher *launcher_service_interface; UnityLauncherEntry *launcher_entry; guint num_actions; UnityWebappsActionManager *action_manager; UnityWebappsApplicationInfo *application_info; }; UnityWebappsLauncherContext *unity_webapps_launcher_context_new (GDBusConnection *connection, const gchar *desktop_id, UnityWebappsInterestTracker *interest_tracker, UnityWebappsApplicationInfo *application_info); void unity_webapps_launcher_context_free (UnityWebappsLauncherContext *launcher_context); #endif libunity-webapps-2.5.0~+14.04.20140409/src/context-daemon/unity-webapps-launcher-context.c0000644000015301777760000003223612321247333031571 0ustar pbusernogroup00000000000000/* * unity-webapps-launcher-context.c * Copyright (C) Canonical LTD 2011 * * Author: Robert Carr * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-launcher-context.h" #include "unity-webapps-dbus-defs.h" #include "unity-webapps-debug.h" #include "unity-webapps-interest-manager.h" #include "unity-webapps-action-manager.h" #include "unity-webapps-interest-tracker.h" #include "unity-webapps-app-db.h" #define UNITY_WEBAPPS_LAUNCHER_MAX_ACTIONS 6 static void emit_action_invoked_signal (UnityWebappsLauncherContext *launcher_context, const gchar *label, gint interest_id) { GError *error; UNITY_WEBAPPS_NOTE (LAUNCHER, "Emitting ActionInvoked signal (%s)", label); error = NULL; g_dbus_connection_emit_signal (launcher_context->connection, NULL, UNITY_WEBAPPS_LAUNCHER_PATH, UNITY_WEBAPPS_LAUNCHER_IFACE, "ActionInvoked", g_variant_new("(si)", label, interest_id, NULL), &error); if (error != NULL) { g_warning ("Error emitting ActionInvoked signal (from menuitem) in launcher context: %s", error->message); g_error_free (error); } } static void unity_webapps_launcher_context_on_action_invoked (UnityWebappsActionManager *action_manager, const gchar *action_path, gpointer user_data) { UnityWebappsLauncherContext *launcher_context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Got item-activated signal for menuitem"); launcher_context = (UnityWebappsLauncherContext *)user_data; if (g_strcmp0 (action_path, _("Open a New Window")) == 0) { UNITY_WEBAPPS_NOTE (LAUNCHER, "Opening a new application window from quicklist"); unity_webapps_application_info_open_new_instance (launcher_context->application_info); return; } gint interest_id = unity_webapps_action_manager_get_most_recent_interest_with_action (action_manager, action_path); UNITY_WEBAPPS_NOTE (LAUNCHER, "emmiting action and raising %d", interest_id); if (interest_id != -1) { unity_webapps_context_daemon_raise_interest (interest_id); emit_action_invoked_signal (launcher_context, action_path, interest_id); } else { unity_webapps_context_daemon_raise_most_recent (); } } static void real_set_count (UnityWebappsLauncherContext *context, gint count) { unity_launcher_entry_set_count (context->launcher_entry, count); unity_launcher_entry_set_count_visible (context->launcher_entry, TRUE); } static void real_clear_count (UnityWebappsLauncherContext *context) { unity_launcher_entry_set_count_visible (context->launcher_entry, FALSE); } static void real_set_progress (UnityWebappsLauncherContext *context, gdouble progress) { unity_launcher_entry_set_progress (context->launcher_entry, progress); unity_launcher_entry_set_progress_visible (context->launcher_entry, TRUE); } static void real_clear_progress (UnityWebappsLauncherContext *context) { unity_launcher_entry_set_progress_visible (context->launcher_entry, FALSE); } static void real_set_urgent (UnityWebappsLauncherContext *context) { unity_launcher_entry_set_urgent (context->launcher_entry, TRUE); } static gboolean on_handle_set_count (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, gint count, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling SetCount call, count: %d", count); context = (UnityWebappsLauncherContext *)user_data; real_set_count (context, count); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_clear_count (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling ClearCount call"); context = (UnityWebappsLauncherContext *)user_data; real_clear_count (context); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_set_progress (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, gdouble progress, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling SetProgress call, progress: %f", progress); context = (UnityWebappsLauncherContext *)user_data; real_set_progress (context, progress); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_clear_progress (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling ClearProgress call"); context = (UnityWebappsLauncherContext *)user_data; real_clear_progress (context); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_add_action (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, const gchar *label, gint interest_id, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling AddAction call, action: %s", label); context = (UnityWebappsLauncherContext *)user_data; unity_webapps_action_manager_add_action (context->action_manager, label, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_add_static_action (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, const gchar *label, const gchar *page, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling AddStaticAction call, action: %s", label); context = (UnityWebappsLauncherContext *)user_data; unity_webapps_app_db_add_action (unity_webapps_application_info_get_name (context->application_info), unity_webapps_application_info_get_domain (context->application_info), label, page); // TODO: UGH unity_webapps_application_info_ensure_desktop_file (context->application_info, NULL); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_remove_static_actions (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling RemoveStaticActions call"); context = (UnityWebappsLauncherContext *)user_data; unity_webapps_app_db_clear_actions (unity_webapps_application_info_get_name (context->application_info), unity_webapps_application_info_get_domain (context->application_info)); unity_webapps_application_info_ensure_desktop_file (context->application_info, NULL); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_remove_action (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, const gchar *label, gint interest_id, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling RemoveAction call, action: %s", label); context = (UnityWebappsLauncherContext *)user_data; unity_webapps_action_manager_remove_action (context->action_manager, label, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_remove_actions (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, gint interest_id, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling RemoveActions call"); context = (UnityWebappsLauncherContext *)user_data; unity_webapps_action_manager_remove_all_actions (context->action_manager, interest_id); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static gboolean on_handle_set_urgent (UnityWebappsGenLauncher *launcher, GDBusMethodInvocation *invocation, gpointer user_data) { UnityWebappsLauncherContext *context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Handling SetUrgent call"); context = (UnityWebappsLauncherContext *)user_data; real_set_urgent (context); g_dbus_method_invocation_return_value (invocation, NULL); return TRUE; } static void export_object (GDBusConnection *connection, UnityWebappsLauncherContext *launcher_context) { GError *error; launcher_context->launcher_service_interface = unity_webapps_gen_launcher_skeleton_new (); g_signal_connect (launcher_context->launcher_service_interface, "handle-set-count", G_CALLBACK (on_handle_set_count), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-clear-count", G_CALLBACK (on_handle_clear_count), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-set-progress", G_CALLBACK (on_handle_set_progress), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-clear-progress", G_CALLBACK (on_handle_clear_progress), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-add-static-action", G_CALLBACK (on_handle_add_static_action), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-remove-static-actions", G_CALLBACK (on_handle_remove_static_actions), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-add-action", G_CALLBACK (on_handle_add_action), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-remove-action", G_CALLBACK (on_handle_remove_action), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-remove-actions", G_CALLBACK (on_handle_remove_actions), launcher_context); g_signal_connect (launcher_context->launcher_service_interface, "handle-set-urgent", G_CALLBACK (on_handle_set_urgent), launcher_context); error = NULL; g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (launcher_context->launcher_service_interface), connection, UNITY_WEBAPPS_LAUNCHER_PATH, &error); if (error != NULL) { g_error ("Error exporting Unity Webapps Launcher object: %s", error->message); g_error_free (error); return; } UNITY_WEBAPPS_NOTE (LAUNCHER, "Exported Launcher object"); } UnityWebappsLauncherContext * unity_webapps_launcher_context_new (GDBusConnection *connection, const gchar *desktop_id, UnityWebappsInterestTracker *interest_tracker, UnityWebappsApplicationInfo *application_info) { UnityWebappsLauncherContext *launcher_context; UNITY_WEBAPPS_NOTE (LAUNCHER, "Creating new UnityWebappsLauncherContext object"); launcher_context = g_malloc0 (sizeof (UnityWebappsLauncherContext)); launcher_context->application_info = application_info; launcher_context->connection = g_object_ref (G_OBJECT (connection)); export_object (connection, launcher_context); launcher_context->launcher_entry = unity_launcher_entry_get_for_desktop_id (desktop_id); launcher_context->action_manager = unity_webapps_action_manager_new_flat (interest_tracker, NULL); unity_webapps_action_manager_set_track_activity (launcher_context->action_manager, FALSE); unity_webapps_action_manager_add_action (launcher_context->action_manager, _("Open a New Window"), -1); unity_launcher_entry_set_quicklist (launcher_context->launcher_entry, unity_webapps_action_manager_get_root (launcher_context->action_manager)); g_signal_connect (launcher_context->action_manager, "action-invoked", G_CALLBACK (unity_webapps_launcher_context_on_action_invoked), launcher_context); launcher_context->num_actions = 0; return launcher_context; } void unity_webapps_launcher_context_free (UnityWebappsLauncherContext *launcher_context) { UNITY_WEBAPPS_NOTE (LAUNCHER, "Finalizing UnityWebappsLauncherContext object"); g_object_unref (G_OBJECT (launcher_context->launcher_service_interface)); g_object_unref (G_OBJECT (launcher_context->connection)); g_object_unref (G_OBJECT (launcher_context->launcher_entry)); g_object_unref (G_OBJECT (launcher_context->action_manager)); g_free (launcher_context); } libunity-webapps-2.5.0~+14.04.20140409/src/unity-webapps-string-utils.c0000644000015301777760000000260312321247333026020 0ustar pbusernogroup00000000000000/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * unity-webapps-string-utils.h * Copyright (C) Canonical LTD 2011 * * Author: Alexandre Abreu * unity-webapps is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * unity-webapps 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see ."; */ #include #include "unity-webapps-string-utils.h" gchar * unity_webapps_string_utils_canonicalize_string (const gchar *str, gboolean keep_whitespaces) { gchar *it; GString *res = g_string_sized_new (g_utf8_strlen (str, -1)); for (it = (gchar*)str; *it; it = g_utf8_next_char (it)) { gunichar chr = g_utf8_get_char (it); if (g_unichar_isalnum (chr) || (g_unichar_isspace (chr) && keep_whitespaces)) res = g_string_append_unichar (res, chr); } return g_string_free (res, FALSE); } libunity-webapps-2.5.0~+14.04.20140409/src/webapps-service.xml0000644000015301777760000000271312321247333024226 0ustar pbusernogroup00000000000000 libunity-webapps-2.5.0~+14.04.20140409/src/webapps-music-player.xml0000644000015301777760000000437012321247333025201 0ustar pbusernogroup00000000000000 libunity-webapps-2.5.0~+14.04.20140409/src/index-updater/0000755000015301777760000000000012321250157023151 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/src/index-updater/Makefile.am0000644000015301777760000000127112321247333025210 0ustar pbusernogroup00000000000000AM_CPPFLAGS = \ $(UNITY_WEBAPPS_CFLAGS) \ $(UNITY_WEBAPPS_DAEMON_CFLAGS) \ -I$(top_srcdir)/src/libunity-webapps \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/context-daemon/util \ $(UNITY_WEBAPPS_COVERAGE_CFLAGS) bin_PROGRAMS = \ ubuntu-webapps-update-index ubuntu_webapps_update_index_SOURCES = \ apt-cache-parser.c \ apt-cache-parser.h \ ubuntu-webapps-update-index.c \ webapp-info.c \ webapp-info.h \ ../libunity-webapps/unity-webapps-debug.c \ ../context-daemon/util/unity-webapps-dirs.c \ ../unity-webapps-url-db.c ubuntu_webapps_update_index_LDFLAGS = $(UNITY_WEBAPPS_COVERAGE_LDFLAGS) ubuntu_webapps_update_index_LDADD = $(UNITY_WEBAPPS_LIBS) $(UNITY_WEBAPPS_DAEMON_LIBS) libunity-webapps-2.5.0~+14.04.20140409/src/index-updater/webapp-info.h0000644000015301777760000000153712321247333025541 0ustar pbusernogroup00000000000000#ifndef __WEBAPP_INFO_H #define __WEBAPP_INFO_H #include typedef struct _WebappInfo WebappInfo; WebappInfo *webapp_info_new (const gchar *package_name); void webapp_info_free (WebappInfo *info); const gchar *webapp_info_get_package_name (WebappInfo *info); void webapp_info_add_url (WebappInfo *info, const gchar *url); GPtrArray *webapp_info_get_urls (WebappInfo *info); void webapp_info_set_application_name (WebappInfo *info, const gchar *application_name); const gchar *webapp_info_get_application_name (WebappInfo *info); void webapp_info_set_application_domain (WebappInfo *info, const gchar *application_domain); const gchar *webapp_info_get_application_domain (WebappInfo *info); gboolean webapp_info_has_urls (WebappInfo *info); gboolean webapp_info_verify (WebappInfo *info); GVariant *webapp_info_serialize (WebappInfo *info); #endif libunity-webapps-2.5.0~+14.04.20140409/src/index-updater/ubuntu-webapps-update-index.c0000644000015301777760000000676712321247333030705 0ustar pbusernogroup00000000000000#include #include #include #include #include #include "apt-cache-parser.h" #include "unity-webapps-url-db.h" #include "../unity-webapps-debug.h" static GMainLoop *main_loop = NULL; static AptCacheParser *parser = NULL; static UnityWebappsUrlDB *url_db = NULL; #define UNITY_WEBAPPS_APT_CACHE_BINARY_ENV_VARIABLE "UNITY_WEBAPPS_APT_CACHE_BINARY" gboolean spawn_apt_cache (GIOChannel **available, GError **error) { const gchar *argv[] = {"apt-cache", "dumpavail", NULL}; const gchar *envbinary; gint cstdo; envbinary = g_getenv (UNITY_WEBAPPS_APT_CACHE_BINARY_ENV_VARIABLE); if (envbinary != NULL) { argv[0] = envbinary; } g_spawn_async_with_pipes (NULL, (gchar **)argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &cstdo, NULL, error); *available = NULL; if (*error != NULL) { g_warning ("Failed to spawn apt-cache: %s\n", (*error)->message); return FALSE; } *available = g_io_channel_unix_new (cstdo); return TRUE; } gboolean package_info_available (GIOChannel *channel, GIOCondition condition, gpointer user_data) { gchar *line; GIOStatus ret; ret = G_IO_STATUS_NORMAL; while (ret == G_IO_STATUS_NORMAL) { ret = g_io_channel_read_line (channel, &line, NULL, NULL, NULL); if (line != NULL) { apt_cache_parser_next_line (parser, line); } } return TRUE; } gboolean package_info_done (GIOChannel *channel, GIOCondition condition, gpointer user_data) { GList *infos; infos= apt_cache_parser_get_webapp_infos (parser); while (infos != NULL) { WebappInfo *info; GPtrArray *urls; const gchar *package_name; const gchar *application_name; const gchar *application_domain; int i; UnityWebappsUrlDBRecord *record; info = (WebappInfo *)infos->data; package_name = webapp_info_get_package_name (info); infos = infos->next; application_name = webapp_info_get_application_name (info); application_domain = webapp_info_get_application_domain (info); UNITY_WEBAPPS_NOTE (INDEX_UPDATER, "Found webapp: %s (%s, %s)\n", package_name, application_name, application_domain); urls = webapp_info_get_urls (info); record = unity_webapps_url_db_record_new (package_name, application_name, application_domain); for (i = 0; i < urls->len; i++) { gchar *url; url = (gchar *)g_ptr_array_index (urls, i); unity_webapps_url_db_insert_url (url_db, url, record); } unity_webapps_url_db_record_free (record); } g_main_loop_quit (main_loop); return FALSE; } gboolean list_available_webapps () { GIOChannel *available; GError *error; gboolean spawned; error = NULL; spawned = spawn_apt_cache (&available, &error); if (spawned == FALSE) { g_error ("Error listing available packages: %s \n", error->message); g_error_free (error); return FALSE; } parser = apt_cache_parser_new (); g_io_add_watch (available, G_IO_IN, package_info_available, parser); g_io_add_watch (available, G_IO_HUP, package_info_done, NULL); return TRUE; } int main (gint argc, gchar **argv) { url_db = unity_webapps_url_db_open_default (FALSE); if (!url_db) { g_critical ("can't access URL DB"); return 1; } list_available_webapps(); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); return 0; } libunity-webapps-2.5.0~+14.04.20140409/src/index-updater/apt-cache-parser.h0000644000015301777760000000156012321247333026445 0ustar pbusernogroup00000000000000#ifndef __APT_CACHE_PARSER_H #define __APT_CACHE_PARSER_H #include #include "webapp-info.h" typedef struct _AptCacheParser AptCacheParser; /* States of the parser. */ typedef enum { /* We are looking for a 'Package: ' header. */ APT_CACHE_PARSER_STATE_WANT_PACKAGE, APT_CACHE_PARSER_STATE_WANT_METADATA, APT_CACHE_PARSER_STATE_INVALID } AptCacheParserState; AptCacheParser *apt_cache_parser_new (); void apt_cache_parser_free (AptCacheParser *parser); gboolean apt_cache_parser_next_line (AptCacheParser *parser, const gchar *line); gboolean apt_cache_parser_parse_lines (AptCacheParser *parser, const gchar **lines); gboolean apt_cache_parser_parse_available (AptCacheParser *parse, const gchar *available); GList *apt_cache_parser_get_webapp_infos (AptCacheParser *parser); GVariant *apt_cache_parser_serialize_results (AptCacheParser *parser); #endif libunity-webapps-2.5.0~+14.04.20140409/src/index-updater/webapp-info.c0000644000015301777760000000534512321247333025535 0ustar pbusernogroup00000000000000#include "webapp-info.h" #include struct _WebappInfo { gchar *package_name; gchar *application_name; gchar *domain; GPtrArray *urls; }; WebappInfo * webapp_info_new (const gchar *package_name) { WebappInfo *info; info = g_malloc0(sizeof (WebappInfo)); info->package_name = g_strdup (package_name); info->urls = g_ptr_array_new_full (3, g_free); info->domain = NULL; info->application_name = NULL; return info; } void webapp_info_free (WebappInfo *info) { g_ptr_array_free (info->urls, TRUE); g_free (info->package_name); g_free (info->application_name); g_free (info->domain); g_free (info); } const gchar * webapp_info_get_package_name (WebappInfo *info) { return info->package_name; } const gchar * webapp_info_get_application_name (WebappInfo *info) { return info->application_name; } void webapp_info_set_application_name (WebappInfo *info, const gchar *application_name) { g_return_if_fail (info->application_name == NULL); info->application_name = g_strdup (application_name); } const gchar * webapp_info_get_application_domain (WebappInfo *info) { return info->domain; } void webapp_info_set_application_domain (WebappInfo *info, const gchar *application_domain) { g_return_if_fail (info->domain == NULL); info->domain = g_strdup (application_domain); } void webapp_info_add_url (WebappInfo *info, const gchar *url) { g_ptr_array_add (info->urls, g_strdup (url)); } GPtrArray * webapp_info_get_urls (WebappInfo *info) { return info->urls; } gboolean webapp_info_has_urls (WebappInfo *info) { return (info->urls->len != 0); } gboolean webapp_info_verify (WebappInfo *info) { if (info->package_name == NULL) { return FALSE; } if (g_str_has_prefix (info->package_name, "unity-webapps") == FALSE) { return FALSE; } if (info->application_name == NULL) { return FALSE; } if (strlen (info->application_name) == 0) { return FALSE; } if (info->domain == NULL) { return FALSE; } if (strlen (info->domain) == 0) { return FALSE; } if (webapp_info_has_urls (info) == FALSE) { return FALSE; } return TRUE; } GVariant * webapp_info_serialize (WebappInfo *info) { GVariantBuilder b; int i; g_variant_builder_init (&b, G_VARIANT_TYPE("(ssa(s))")); g_variant_builder_add (&b, "s", info->package_name); g_variant_builder_add (&b, "s", info->application_name); g_variant_builder_open (&b, G_VARIANT_TYPE ("a(s)")); for (i = 0; i < info->urls->len; i++) { gchar *url; url = (gchar *)g_ptr_array_index (info->urls, i); g_variant_builder_add (&b, "(s)", url); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } libunity-webapps-2.5.0~+14.04.20140409/src/index-updater/apt-cache-parser.c0000644000015301777760000002061012321247333026435 0ustar pbusernogroup00000000000000#include "apt-cache-parser.h" #include #define UBUNTU_WEBAPPS_NAME_KEY "Ubuntu-Webapps-Name" #define UBUNTU_WEBAPPS_INCLUDES_KEY "Ubuntu-Webapps-Includes" #define UBUNTU_WEBAPPS_DOMAIN_KEY "Ubuntu-Webapps-Domain" struct _AptCacheParser { /* Current state of the parser */ AptCacheParserState state; /* Webapp we are currently building */ WebappInfo *current_webapp; /* List of found webapps */ GList *webapp_infos; }; AptCacheParser * apt_cache_parser_new () { AptCacheParser *parser; parser = g_malloc0 (sizeof (AptCacheParser)); parser->state = APT_CACHE_PARSER_STATE_WANT_PACKAGE; parser->current_webapp = NULL; parser->webapp_infos = NULL; return parser; } static void apt_cache_parser_free_webapp_infos (AptCacheParser *parser) { GList *w; for (w = parser->webapp_infos; w != NULL; w = w->next) { WebappInfo *info; info = (WebappInfo *)w->data; webapp_info_free (info); } g_list_free (parser->webapp_infos); parser->webapp_infos = NULL; } void apt_cache_parser_free (AptCacheParser *parser) { apt_cache_parser_free_webapp_infos (parser); if (parser->current_webapp != NULL) { webapp_info_free (parser->current_webapp); } g_free (parser); } gboolean apt_cache_parser_parse_metadata_field (const gchar *line, gchar **out_key_name, gchar **out_key_value) { const gchar *walk; gchar *working_line, *key_name, *key_value; guint key_length; gboolean parsed; key_value = NULL; key_name = NULL; working_line = g_strdup (line); // Simplification working_line = g_strstrip (working_line); parsed = FALSE; for (walk = working_line; *walk != '\0'; walk++) { if (*walk == ':') { parsed = TRUE; break; } } if (parsed == FALSE) { goto out; } key_length = walk-working_line; if (key_length == 0) { parsed = FALSE; goto out; } key_name = g_malloc0 ((key_length+1) * sizeof (gchar)); strncpy (key_name, working_line, key_length); key_name[key_length] = '\0'; // Skip ": " key_value = g_strdup(walk + 2 * sizeof (gchar)); out: *out_key_name = key_name; *out_key_value = key_value; g_free (working_line); return parsed; } gboolean apt_cache_parser_parse_package_name (const gchar *line, gchar **package_name) { gboolean parsed; gchar *key; parsed = apt_cache_parser_parse_metadata_field (line, &key, package_name); if (parsed == FALSE) { return FALSE; } parsed = (g_strcmp0 (key, "Package") == 0); g_free (key); return parsed; } gboolean apt_cache_parser_parse_application_name (AptCacheParser *parser, const gchar *name) { gboolean has_name; g_assert (parser->current_webapp); has_name = (webapp_info_get_application_name (parser->current_webapp) != NULL); if (has_name == TRUE) { g_warning ("We found two webapp name fields in one package record (%s)", name); return FALSE; } webapp_info_set_application_name (parser->current_webapp, name); return TRUE; } gboolean apt_cache_parser_parse_application_domain (AptCacheParser *parser, const gchar *name) { gboolean has_name; g_assert (parser->current_webapp); has_name = (webapp_info_get_application_domain (parser->current_webapp) != NULL); if (has_name == TRUE) { g_warning ("We found two webapp name fields in one package record (%s)", name); return FALSE; } webapp_info_set_application_domain (parser->current_webapp, name); return TRUE; } static gboolean apt_cache_parser_parse_application_includes (AptCacheParser *parser, const gchar *includes_value) { gchar **includes; gint i, len; gboolean parsed, has_urls; g_assert (parser->current_webapp); has_urls = webapp_info_has_urls (parser->current_webapp); if (has_urls == TRUE) { g_warning("We found a webapp with two XB-Ubuntu-Webapp-Includes values (%s), includes_value", includes_value); return FALSE; } parsed = TRUE; includes = g_strsplit (includes_value, ";", -1); len = g_strv_length (includes); if (len == 0) { // We need some includes! parsed = FALSE; goto out; } for (i = 0; i < len; i++) { const gchar *include = (const gchar *)includes[i]; webapp_info_add_url (parser->current_webapp, include); } out: g_strfreev (includes); return parsed; } gboolean apt_cache_parser_parse_metadata_keys (AptCacheParser *parser, const gchar *key, const gchar *value) { gboolean parsed; parsed = TRUE; if (g_strcmp0 (key, UBUNTU_WEBAPPS_NAME_KEY) == 0) { parsed = apt_cache_parser_parse_application_name (parser, value); } else if (g_strcmp0 (key, UBUNTU_WEBAPPS_DOMAIN_KEY) == 0) { parsed = apt_cache_parser_parse_application_domain (parser, value); } else if (g_strcmp0 (key, UBUNTU_WEBAPPS_INCLUDES_KEY) == 0) { parsed = apt_cache_parser_parse_application_includes (parser, value); } return parsed; } gboolean apt_cache_parser_next_line (AptCacheParser *parser, const gchar *line) { switch (parser->state) { case APT_CACHE_PARSER_STATE_WANT_PACKAGE: { gchar *package_name; gboolean parsed; parsed = apt_cache_parser_parse_package_name (line, &package_name); if (parsed == FALSE) { break; } if (g_str_has_prefix(package_name, "unity-webapps") == FALSE) { g_free (package_name); break; } g_message("Investigating webapp: %s \n", package_name); parser->current_webapp = webapp_info_new (package_name); parser->state = APT_CACHE_PARSER_STATE_WANT_METADATA; g_free (package_name); break; } case APT_CACHE_PARSER_STATE_WANT_METADATA: { // The lifetime of these is a little awkward to follow, but control flow is a little hard in here :) be careful if changing gchar *key, *value; gboolean parsed; gboolean verified; if (g_strcmp0 (line, "\n") == 0) { g_warning("Found newline before all of metadata, skipping app"); parser->state = APT_CACHE_PARSER_STATE_WANT_PACKAGE; webapp_info_free (parser->current_webapp); parser->current_webapp = NULL; break; } parsed = apt_cache_parser_parse_metadata_field (line, &key, &value); if (parsed == FALSE) { g_warning ("Failed to parse metadata line (%s), skipping package", line); parser->state = APT_CACHE_PARSER_STATE_WANT_PACKAGE; webapp_info_free (parser->current_webapp); parser->current_webapp = NULL; break; } parsed = apt_cache_parser_parse_metadata_keys (parser, key, value); if (parsed == FALSE) { g_warning ("Invalid metadata, skipping package"); parser->state = APT_CACHE_PARSER_STATE_WANT_PACKAGE; webapp_info_free (parser->current_webapp); parser->current_webapp = NULL; g_free (key); g_free (value); break; } verified = webapp_info_verify (parser->current_webapp); if (verified == TRUE) { parser->webapp_infos = g_list_append (parser->webapp_infos, parser->current_webapp); parser->current_webapp = NULL; parser->state = APT_CACHE_PARSER_STATE_WANT_PACKAGE; } g_free (key); g_free (value); break; } case APT_CACHE_PARSER_STATE_INVALID: return FALSE; } return TRUE; } GList * apt_cache_parser_get_webapp_infos (AptCacheParser *parser) { return parser->webapp_infos; } gboolean apt_cache_parser_parse_lines (AptCacheParser *parser, const gchar **lines) { gint i, len; len = g_strv_length ((gchar **)lines); for (i = 0; i < len; i++) { gboolean parsed; parsed = apt_cache_parser_next_line (parser, lines[i]); if (parsed == FALSE) { return FALSE; } } return TRUE; } gboolean apt_cache_parser_parse_available (AptCacheParser *parser, const gchar *available) { gchar **lines; gboolean parsed; lines = g_strsplit (available, "\n", -1); parsed = apt_cache_parser_parse_lines (parser, (const gchar **)lines); g_strfreev (lines); return parsed; } GVariant * apt_cache_parser_serialize_results (AptCacheParser *parser) { GList *w; GVariantBuilder b; g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(ssa(s)))")); g_variant_builder_open (&b, G_VARIANT_TYPE ("a(ssa(s))")); for (w = parser->webapp_infos; w != NULL; w = w->next) { WebappInfo *info; info = (WebappInfo *)w->data; g_variant_builder_add_value (&b, webapp_info_serialize (info)); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } libunity-webapps-2.5.0~+14.04.20140409/m4/0000755000015301777760000000000012321250157020131 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/m4/introspection.m40000644000015301777760000000661412321247333023304 0ustar pbusernogroup00000000000000dnl -*- mode: autoconf -*- dnl Copyright 2009 Johan Dahlin dnl dnl This file is free software; the author(s) gives unlimited dnl permission to copy and/or distribute it, with or without dnl modifications, as long as this notice is preserved. dnl # serial 1 m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], [ AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first AC_BEFORE([LT_INIT],[$0])dnl setup libtool first dnl enable/disable introspection m4_if([$2], [require], [dnl enable_introspection=yes ],[dnl AC_ARG_ENABLE(introspection, AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], [Enable introspection for this build]),, [enable_introspection=auto]) ])dnl AC_MSG_CHECKING([for gobject-introspection]) dnl presence/version checking AS_CASE([$enable_introspection], [no], [dnl found_introspection="no (disabled, use --enable-introspection to enable)" ],dnl [yes],[dnl PKG_CHECK_EXISTS([gobject-introspection-1.0],, AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) ],dnl [auto],[dnl PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) ],dnl [dnl AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) ])dnl AC_MSG_RESULT([$found_introspection]) INTROSPECTION_SCANNER= INTROSPECTION_COMPILER= INTROSPECTION_GENERATE= INTROSPECTION_GIRDIR= INTROSPECTION_TYPELIBDIR= if test "x$found_introspection" = "xyes"; then INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection fi AC_SUBST(INTROSPECTION_SCANNER) AC_SUBST(INTROSPECTION_COMPILER) AC_SUBST(INTROSPECTION_GENERATE) AC_SUBST(INTROSPECTION_GIRDIR) AC_SUBST(INTROSPECTION_TYPELIBDIR) AC_SUBST(INTROSPECTION_CFLAGS) AC_SUBST(INTROSPECTION_LIBS) AC_SUBST(INTROSPECTION_MAKEFILE) AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") ]) dnl Usage: dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], [ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) ]) dnl Usage: dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], [ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) ]) libunity-webapps-2.5.0~+14.04.20140409/m4/gcov.m40000644000015301777760000000473212321247333021341 0ustar pbusernogroup00000000000000# Checks for existence of coverage tools: # * gcov # * lcov # * genhtml # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present # and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], [ AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=yes], [use_gcov=no]) AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes") # if test "x$use_gcov" = "xyes"; then # AM_CONDITIONAL(HAVE_GCOV, true) # else # AM_CONDITIONAL(HAVE_GCOV, false) # fi if test "x$use_gcov" = "xyes"; then # we need gcc: if test "$GCC" != "yes"; then AC_MSG_ERROR([GCC is required for --enable-gcov]) fi # Check if ccache is being used AC_CHECK_PROG(SHTOOL, shtool, shtool) if test "$SHTOOL"; then AS_CASE([`$SHTOOL path $CC`], [*ccache*], [gcc_ccache=yes], [gcc_ccache=no]) fi if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) fi lcov_version_list="1.6 1.7 1.8 1.9 1.10" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ glib_cv_lcov_version=invalid lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` for lcov_check_version in $lcov_version_list; do if test "$lcov_version" = "$lcov_check_version"; then glib_cv_lcov_version="$lcov_check_version (ok)" fi done ]) else lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" AC_MSG_ERROR([$lcov_msg]) fi case $glib_cv_lcov_version in ""|invalid[)] lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." AC_MSG_ERROR([$lcov_msg]) LCOV="exit 0;" ;; esac if test -z "$GENHTML"; then AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi # Remove all optimization flags from CFLAGS changequote({,}) CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` changequote([,]) # Add the special gcc flags UNITY_WEBAPPS_COVERAGE_CFLAGS="--coverage" UNITY_WEBAPPS_COVERAGE_CXXFLAGS="--coverage" UNITY_WEBAPPS_COVERAGE_LDFLAGS="-lgcov" fi ]) # AC_TDD_GCOV libunity-webapps-2.5.0~+14.04.20140409/docs/0000755000015301777760000000000012321250157020541 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/docs/dbus/0000755000015301777760000000000012321250157021476 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/docs/dbus/Makefile.am0000644000015301777760000000345112321247333023537 0ustar pbusernogroup00000000000000DOCBOOK_XML = webapps-service-com.canonical.Unity.Webapps.Service.xml: $(top_srcdir)/src/webapps-service.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --generate-docbook webapps-service \ $(top_srcdir)/src/webapps-service.xml DOCBOOK_XML += webapps-service-com.canonical.Unity.Webapps.Service.xml webapps-context-com.canonical.Unity.Webapps.Context.xml: $(top_srcdir)/src/webapps-context-daemon.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --generate-docbook webapps-context \ $(top_srcdir)/src/webapps-context-daemon.xml DOCBOOK_XML += webapps-context-com.canonical.Unity.Webapps.Context.xml webapps-notification-com.canonical.Unity.Webapps.Notification.xml: $(top_srcdir)/src/webapps-notification.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --generate-docbook webapps-notification \ $(top_srcdir)/src/webapps-notification.xml DOCBOOK_XML += webapps-notification-com.canonical.Unity.Webapps.Notification.xml webapps-indicator-com.canonical.Unity.Webapps.Indicator.xml: $(top_srcdir)/src/webapps-indicator.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --generate-docbook webapps-indicator \ $(top_srcdir)/src/webapps-indicator.xml DOCBOOK_XML += webapps-indicator-com.canonical.Unity.Webapps.Indicator.xml webapps-music-player-com.canonical.Unity.Webapps.MusicPlayer.xml: $(top_srcdir)/src/webapps-music-player.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --generate-docbook webapps-music-player \ $(top_srcdir)/src/webapps-music-player.xml DOCBOOK_XML += webapps-music-player-com.canonical.Unity.Webapps.MusicPlayer.xml webapps-launcher-com.canonical.Unity.Webapps.Launcher.xml: $(top_srcdir)/src/webapps-launcher.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --generate-docbook webapps-launcher \ $(top_srcdir)/src/webapps-launcher.xml DOCBOOK_XML += webapps-launcher-com.canonical.Unity.Webapps.Launcher.xml all: $(DOCBOOK_XML) CLEANFILES = \ $(DOCBOOK_XML) libunity-webapps-2.5.0~+14.04.20140409/docs/reference/0000755000015301777760000000000012321250157022477 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/docs/reference/Makefile.am0000644000015301777760000000003312321247333024531 0ustar pbusernogroup00000000000000SUBDIRS = libunity-webapps libunity-webapps-2.5.0~+14.04.20140409/docs/reference/libunity-webapps/0000755000015301777760000000000012321250157025775 5ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/docs/reference/libunity-webapps/Makefile.am0000644000015301777760000000621512321247333030037 0ustar pbusernogroup00000000000000## Process this file with automake to produce Makefile.in # We require automake 1.6 at least. AUTOMAKE_OPTIONS = 1.6 # This is a blank Makefile.am for using gtk-doc. # Copy this to your project's API docs directory and modify the variables to # suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples # of using the various options. # The name of the module, e.g. 'glib'. DOC_MODULE=libunity-webapps # The top-level SGML file. You can change this if you want to. DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml # The directory containing the source code. Relative to $(srcdir). # gtk-doc will search all .c & .h files beneath here for inline comments # documenting the functions and macros. # e.g. DOC_SOURCE_DIR=../../../gtk DOC_SOURCE_DIR=$(top_srcdir)/src/libunity-webapps # Extra options to pass to gtkdoc-scangobj. Not normally needed. SCANGOBJ_OPTIONS=--nogtkinit --type-init-func="g_type_init()" # Extra options to supply to gtkdoc-scan. # e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" SCAN_OPTIONS= # Extra options to supply to gtkdoc-mkdb. # e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml MKDB_OPTIONS=--sgml-mode --output-format=xml # Extra options to supply to gtkdoc-mktmpl # e.g. MKTMPL_OPTIONS=--only-section-tmpl MKTMPL_OPTIONS= # Extra options to supply to gtkdoc-fixref. Not normally needed. # e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html FIXXREF_OPTIONS= # Used for dependencies. The docs will be rebuilt if any of these change. # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c HFILE_GLOB=$(top_srcdir)/src/libunity-webapps/*.h CFILE_GLOB=$(top_srcdir)/src/libunity-webapps/*.c # Header files to ignore when scanning. # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h IGNORE_HFILES=context-daemon/* # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png HTML_IMAGES= # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). # e.g. content_files=running.sgml building.sgml changes-2.0.sgml content_files=version.xml # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded # These files must be listed here *and* in content_files # e.g. expand_content_files=running.sgml expand_content_files= # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. # Only needed if you are using gtkdoc-scangobj to dynamically query widget # signals and properties. # e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) INCLUDES=-I$(top_srcdir) $(UNITY_WEBAPPS_CFLAGS) GTKDOC_LIBS=$(top_builddir)/src/libunity-webapps/libunity-webapps.la $(UNITY_WEBAPPS_LIBS) # This includes the standard gtk-doc make rules, copied by gtkdocize. include $(top_srcdir)/gtk-doc.make # Other files to distribute # e.g. EXTRA_DIST += version.xml.in # Files not to distribute # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types # for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt #DISTCLEANFILES += # Comment this out if you want your docs-status tested during 'make check' #TESTS = $(GTKDOC_CHECK) version.xml: touch version.xml libunity-webapps-2.5.0~+14.04.20140409/docs/reference/libunity-webapps/webapps-implementation.sgml0000644000015301777760000000417012321247333033351 0ustar pbusernogroup00000000000000 Implementation Tour 3 Implementation Tour Implementation Tour A high level overview of the Unity Webapps Service implementation There are four primary components to the Unity Webapps Service implementation, found in the source directory. DBus interface specifications, located in libunity-webapps/src these XML files describe the DBus protocols various components use to interact with eachother. The Webapps Service daemon, located in libunity-webapps/src/webapps-service. This daemon owns the name com.canonical.Unity.Webapps.Service and implements the interface of the same name (from webapps-service.xml). The Context Daemon, located in libunity-webapps/src/context-daemon. As discussed in "An introduction to the Unity Webapps Service", this is the heart of the implementation. libunity-webapps client bindings. These are both useful to application hosts (to integrate a new browser or web app container in to the service), or to observers of the Webapps Service, such as BAMF and the Unity Shell. As the Unity Webapps Service is new technology. There are not many examples of the API in usage, however a few are available. The Unity Firefox Extension, contained in lp:unity-firefox-extension. The libunity-webapps tests, in libunity-webapps/tests/traced, provide coverage of the C API. The service-tracker tool provides an example of using the service observer API, located in libunity-webapps/tools. A more thorough implementation can be found in the BamfUnityWebappsObserver class (located in lp:bamf). libunity-webapps-2.5.0~+14.04.20140409/docs/reference/libunity-webapps/libunity-webapps-sections.txt0000644000015301777760000001325512321247333033671 0ustar pbusernogroup00000000000000
unity-webapps-context UnityWebappsContext UnityWebappsContext UnityWebappsContextClass unity_webapps_context_new unity_webapps_context_new_sync unity_webapps_context_new_for_context_name unity_webapps_context_get_context_name unity_webapps_context_get_name unity_webapps_context_get_domain unity_webapps_context_get_desktop_name unity_webapps_context_get_icon_name unity_webapps_context_add_icon unity_webapps_context_add_application_action unity_webapps_context_list_interests unity_webapps_context_on_interest_appeared unity_webapps_context_on_interest_vanished unity_webapps_context_get_interest_owner unity_webapps_context_raise unity_webapps_context_raise_interest unity_webapps_context_close unity_webapps_context_close_interest unity_webapps_context_request_preview unity_webapps_context_get_view_is_active unity_webapps_context_set_view_is_active unity_webapps_context_on_view_is_active_changed unity_webapps_context_get_view_location unity_webapps_context_set_view_location unity_webapps_context_on_view_location_changed unity_webapps_context_get_view_window unity_webapps_context_set_view_window unity_webapps_context_on_view_window_changed unity_webapps_context_on_close_callback unity_webapps_context_on_raise_callback unity_webapps_context_set_preview_requested_callback unity_webapps_context_destroy UnityWebappsContextActionCallback UnityWebappsContextLocationNotifyCallback UnityWebappsContextNotifyCallback UnityWebappsContextPreviewCallback UnityWebappsContextPreviewReadyCallback UnityWebappsContextRaiseCallback UnityWebappsContextReadyCallback UnityWebappsContextViewNotifyCallback UnityWebappsContextWindowNotifyCallback UNITY_WEBAPPS_CONTEXT UNITY_WEBAPPS_CONTEXT_CLASS UNITY_WEBAPPS_CONTEXT_GET_CLASS UNITY_WEBAPPS_IS_CONTEXT UNITY_WEBAPPS_IS_CONTEXT_CLASS UNITY_WEBAPPS_TYPE_CONTEXT UnityWebappsContextPrivate unity_webapps_context_get_type
unity-webapps-context-private UnityWebappsContextPrivate
unity-webapps-dbus-defs UNITY_WEBAPPS_CONTEXT_IFACE UNITY_WEBAPPS_CONTEXT_PATH UNITY_WEBAPPS_INDICATOR_IFACE UNITY_WEBAPPS_INDICATOR_PATH UNITY_WEBAPPS_LAUNCHER_IFACE UNITY_WEBAPPS_LAUNCHER_PATH UNITY_WEBAPPS_MUSIC_PLAYER_IFACE UNITY_WEBAPPS_MUSIC_PLAYER_PATH UNITY_WEBAPPS_NOTIFICATION_IFACE UNITY_WEBAPPS_NOTIFICATION_PATH UNITY_WEBAPPS_SERVICE_IFACE UNITY_WEBAPPS_SERVICE_NAME UNITY_WEBAPPS_SERVICE_PATH
unity-webapps-indicator-context UnityWebappsIndicatorCallback UnityWebappsIndicatorContext UnityWebappsPresenceCallback unity_webapps_indicator_add_action unity_webapps_indicator_clear_indicator unity_webapps_indicator_context_free unity_webapps_indicator_context_new unity_webapps_indicator_get_presence unity_webapps_indicator_on_presence_changed_callback unity_webapps_indicator_set_callback unity_webapps_indicator_set_property unity_webapps_indicator_set_property_icon unity_webapps_indicator_show_indicator
unity-webapps-launcher-context UnityWebappsLauncherCallback UnityWebappsLauncherContext unity_webapps_launcher_add_action unity_webapps_launcher_clear_count unity_webapps_launcher_clear_progress unity_webapps_launcher_context_free unity_webapps_launcher_context_new unity_webapps_launcher_set_count unity_webapps_launcher_set_progress unity_webapps_launcher_set_urgent
unity-webapps-music-player-context UnityWebappsMusicPlayerCallback UnityWebappsMusicPlayerContext UnityWebappsMusicPlayerPlaybackState unity_webapps_music_player_context_free unity_webapps_music_player_context_new unity_webapps_music_player_get_can_go_next unity_webapps_music_player_get_can_go_previous unity_webapps_music_player_get_can_pause unity_webapps_music_player_get_can_play unity_webapps_music_player_get_playback_state unity_webapps_music_player_init unity_webapps_music_player_on_next_callback unity_webapps_music_player_on_play_pause_callback unity_webapps_music_player_on_previous_callback unity_webapps_music_player_set_can_go_next unity_webapps_music_player_set_can_go_previous unity_webapps_music_player_set_can_pause unity_webapps_music_player_set_can_play unity_webapps_music_player_set_playback_state unity_webapps_music_player_set_track
unity-webapps-notification-context UnityWebappsNotificationContext unity_webapps_notification_context_free unity_webapps_notification_context_new unity_webapps_notification_show_notification
unity-webapps-permissions unity_webapps_permissions_allow_domain unity_webapps_permissions_dontask_domain unity_webapps_permissions_get_domain_allowed unity_webapps_permissions_get_domain_dontask
unity-webapps-rate unity_webapps_rate_check_indicator_rate_limit unity_webapps_rate_check_launcher_rate_limit unity_webapps_rate_check_music_player_rate_limit unity_webapps_rate_check_notification_rate_limit
unity-webapps-sanitizer unity_webapps_sanitizer_limit_string_argument
unity-webapps-service UnityWebappsService UnityWebappsService UnityWebappsServiceClass unity_webapps_service_new unity_webapps_service_get_connection unity_webapps_service_get_proxy UnityWebappsServiceContextNotifyCallback unity_webapps_service_on_context_appeared unity_webapps_service_on_context_vanished unity_webapps_service_list_contexts unity_webapps_service_activate_application UNITY_WEBAPPS_IS_SERVICE UNITY_WEBAPPS_IS_SERVICE_CLASS UNITY_WEBAPPS_SERVICE UNITY_WEBAPPS_SERVICE_CLASS UNITY_WEBAPPS_SERVICE_GET_CLASS UNITY_WEBAPPS_TYPE_SERVICE UnityWebappsServicePrivate unity_webapps_service_get_type
libunity-webapps-2.5.0~+14.04.20140409/docs/reference/libunity-webapps/libunity-webapps-docs.sgml0000644000015301777760000000432712321247333033115 0ustar pbusernogroup00000000000000 ]> libunity-webapps Reference Manual for libunity-webapps [VERSION]. The latest version of this documentation can be found on-line at http://[SERVER]/libunity-webapps/. Unity Webapps System Overview Unity Webapps Client API Reference This is the documentation for the C client API of the Unity Webapps system. This is suitable for use by browsers, and application hosts, or observers of the webapps server. Interacting with the Service and Contexts Desktop integration APIs bindings of the Context Daemon Object Hierarchy API Index Index of deprecated API libunity-webapps-2.5.0~+14.04.20140409/docs/reference/libunity-webapps/webapps-service.sgml0000644000015301777760000000644612321247333031774 0ustar pbusernogroup00000000000000 The Unity Webapps Service 3 Unity Webapps Service The Unity Webapps Service An introduction to the Unity Webapps Service The Unity Webapps system is designed with a simple goal: Integrate Web applications in to the Unity platform. A first thought here, might view this as a matter of binding various Desktop APIs in to to the Web application host. However, many metaphors are different in the case of Web Applications, and there are a few issues to solve: A WebApp may have multiple application instances, which operate independetly of eachother. This is the client side, view component of the application, such as multiple browser tabs. In this case, how do we avoid multiple instances of an application fighting over API resources (such as Indicator status)? Likewise, a traditional Desktop Application is assosciated with a window, or a group of windows. In the web application case, an application may be split between multiple top level windows, each of which contains multiple applications! There may in fact be no native window at all assosciated with a Web application, how then can other applications ask to activate it, tell if it is active, or dispatch various callbacks to it? A WebApp can not be trusted to use Desktop APIs at arbitrary rates, or download resources of arbitrary size In some sense, a WebApp is always running, and views from it are frequently destroyed and reinstated. For example, on a page reload, GMail should not flicker from the desktop! It is to solve these goals, that the Unity Webapps Service introduces the concepts of Web application Contexts. A Context, is a handle dispensed by the Webapps Service, keyed by application name and domain (for example GMail, mail.google.com) which encapsulates the applications presence on the desktop. Primarly the Context Daemon has two responsibilities. Firstly, the Context Daemon takes ownership of the applications resources, Music Players, Indicators, Launcher Quicklists, Icons, a .desktop file to identify the application, etc... Secondly, the Context Daemon tracks it's "Interests", this maps to the idea of a 'view' of a web application. The Context knows about all it's interests, and can interact with them in various ways (raise an interest, request a screenshot, request the current location, etc...). When a context has no further interests, it is said to become "Lonely" and the Unity Webapps Service will eventually shut it down. This hierarchy of interests is exposed, and other Desktop clients (such as the Unity Shell) can use this information to interact with web applications (for example to show a list of Google Docs instances in the Desktop Application Switcher). The Webapps Service itself is primarily responsible for handing out these contexts, and managing the lifespan of the daemons implementing individual contexts. libunity-webapps-2.5.0~+14.04.20140409/docs/Makefile.am0000644000015301777760000000003112321247333022571 0ustar pbusernogroup00000000000000SUBDIRS = dbus reference libunity-webapps-2.5.0~+14.04.20140409/AUTHORS0000644000015301777760000000000012321247333020651 0ustar pbusernogroup00000000000000libunity-webapps-2.5.0~+14.04.20140409/README0000644000015301777760000000000012321247333020461 0ustar pbusernogroup00000000000000