summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-01-27 21:24:48 +0000
committerRichard Hughes <richard@hughsie.com>2016-01-28 09:33:16 +0000
commitd6eee316ac4a975d5aab6cf306d53f0446ac8d84 (patch)
treeb36afe0bb1dea3957a6912f2084fea3f82a3deb7 /contrib
parent1835d91f71b90137cef82da5acbe0f2598cd9f4e (diff)
Remove the PackageKit browser plugin
Firefox and Chrome are both removing support for npapi later this year and the plugin has not been actively maintained for some years.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/Makefile.am4
-rw-r--r--contrib/PackageKit.spec.in16
-rw-r--r--contrib/browser-plugin/Makefile.am36
-rw-r--r--contrib/browser-plugin/README157
-rw-r--r--contrib/browser-plugin/pk-main.c521
-rw-r--r--contrib/browser-plugin/pk-plugin-install.c1051
-rw-r--r--contrib/browser-plugin/pk-plugin-install.h58
-rw-r--r--contrib/browser-plugin/pk-plugin.c428
-rw-r--r--contrib/browser-plugin/pk-plugin.h105
-rw-r--r--contrib/browser-plugin/tests/test.html45
10 files changed, 1 insertions, 2420 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index e54d7c4b3..cfc252b0f 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -4,10 +4,6 @@ if BACKEND_TYPE_YUM
SUBDIRS += yum-packagekit
endif
-if PK_BUILD_BROWSER_PLUGIN
-SUBDIRS += browser-plugin
-endif
-
if PK_BUILD_GSTREAMER_PLUGIN
SUBDIRS += gstreamer-plugin
endif
diff --git a/contrib/PackageKit.spec.in b/contrib/PackageKit.spec.in
index 0de5e0dbd..8b03deb86 100644
--- a/contrib/PackageKit.spec.in
+++ b/contrib/PackageKit.spec.in
@@ -33,7 +33,6 @@ BuildRequires: perl(XML::Parser)
BuildRequires: intltool
BuildRequires: gettext
BuildRequires: libgudev1-devel
-BuildRequires: xulrunner-devel
BuildRequires: libarchive-devel
BuildRequires: gstreamer1-devel
BuildRequires: gstreamer1-plugins-base-devel
@@ -60,6 +59,7 @@ Obsoletes: udev-packagekit < %{version}-%{release}
# No more GTK+-2 plugin
Obsoletes: PackageKit-gtk-module < %{version}-%{release}
+Obsoletes: PackageKit-browser-plugin < %{version}-%{release}
# No more zif, smart or yum in Fedora
Obsoletes: PackageKit-smart < %{version}-%{release}
@@ -111,17 +111,6 @@ Provides: PackageKit-docs = %{version}-%{release}
%description glib-devel
GLib headers and libraries for PackageKit.
-%package browser-plugin
-Summary: Browser Plugin for PackageKit
-Requires: gtk2
-Requires: %{name}-glib%{?_isa} = %{version}-%{release}
-Requires: mozilla-filesystem
-
-%description browser-plugin
-The PackageKit browser plugin allows web sites to offer the ability to
-users to install and update packages from configured repositories
-using PackageKit.
-
%package gstreamer-plugin
Summary: Install GStreamer codecs using PackageKit
Requires: %{name}-glib%{?_isa} = %{version}-%{release}
@@ -251,9 +240,6 @@ popd > /dev/null
%config %{_sysconfdir}/cron.daily/packagekit-background.cron
%config(noreplace) %{_sysconfdir}/sysconfig/packagekit-background
-%files browser-plugin
-%{_libdir}/mozilla/plugins/packagekit-plugin.so
-
%files gstreamer-plugin
%{_libexecdir}/pk-gstreamer-install
%{_libexecdir}/gst-install-plugins-helper
diff --git a/contrib/browser-plugin/Makefile.am b/contrib/browser-plugin/Makefile.am
deleted file mode 100644
index 5342ede03..000000000
--- a/contrib/browser-plugin/Makefile.am
+++ /dev/null
@@ -1,36 +0,0 @@
-plugindir=$(MOZILLA_PLUGIN_DIR)
-plugin_LTLIBRARIES = packagekit-plugin.la
-
-packagekit_plugin_la_LDFLAGS = -rpath $(plugindir) -module -avoid-version -no-undefined
-packagekit_plugin_la_CPPFLAGS = \
- $(PK_BROWSER_PLUGIN_CFLAGS) \
- -DG_LOG_DOMAIN=\"PK-BrowserPlugin\" \
- -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
- -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE \
- -DMOZ_X11 \
- -DGSEAL_ENABLE \
- -I$(top_builddir) \
- -I$(top_builddir)/lib \
- -I$(top_srcdir) \
- -I$(top_srcdir)/lib
-
-packagekit_plugin_la_CFLAGS = \
- $(WARNINGFLAGS_C)
-
-packagekit_plugin_la_LIBADD = \
- $(PK_BROWSER_PLUGIN_LIBS)
-
-packagekit_plugin_la_LIBADD += \
- $(top_builddir)/lib/packagekit-glib2/libpackagekit-glib2.la
-
-packagekit_plugin_la_SOURCES = \
- pk-plugin.c \
- pk-plugin.h \
- pk-plugin-install.c \
- pk-plugin-install.h \
- pk-main.c
-
-EXTRA_DIST = \
- tests/test.html
-
--include $(top_srcdir)/git.mk
diff --git a/contrib/browser-plugin/README b/contrib/browser-plugin/README
deleted file mode 100644
index 5dbb43bb8..000000000
--- a/contrib/browser-plugin/README
+++ /dev/null
@@ -1,157 +0,0 @@
-package-plugin
-==============
-This is a very simple browser plugin that is meant to allow a website
-to add a box to allow to install or run a particular piece of software
-provided in their distribution's repositories.
-
-If the package is not installed but is available in the package repository, the plugin
-will show:
-
- +------------------------------------+
- | _Install GNU Backgammon Now_ |
- | Version: 20061119-14.fc9 |
- +------------------------------------+
-
-Click on the plugin, and it asks the session service to install the package;
-the display changes to:
-
- +------------------------------------+
- | GNU Backgammon |
- | Installing... |
- +------------------------------------+
-
-once that is done, the plugin will show:
-
- +------------------------------------+
- | _Run GNU Backgammon_ |
- | Installed version: 20061119-14.fc9 |
- +------------------------------------+
-
-Clicking on it launches the application.
-
-Security Considerations
-=======================
-
-The design as a plugin is specifically meant to avoid revealing information about installed
-applications to the web page. None of the information in the plugin is revealed in the DOM
-tree. It might be possible to guess at results by subtle timing attacks, but it would at
-best be a probabilistic thing.
-
-Web pages probably can trick the user into clicking on the plugin
-and installing or running applications they dont' want to install or run:
-
- - The application title is supplied by the web page
- - The web page could put elements over the plugin to make it appear
-
-(The second is why I consider the first to be acceptable.) However, importantly, the
-only applications that could be installed in that way are applications from the package
-repository already configured for the system. The only applications that can be run in
-this way are applications already on the system. And there is no ability to pass command
-line arguments or files to the applications. So, the security risk should be minimal.
-
-Accessibility
-=============
-
-The design as a plugin (for the above security considerations) causes some problems for
-accessibility. In particular, there is no access into the plugin for screenreaders
-or other assistive technologies. Making this work would require the existence of a
-system for integrating accessibility support between the browser and plugins, which,
-to my knowledge does not exist at the moment.
-
-Keyboard navigation is also missing at the moment, but could be added quite easily.
-(Basically, the Return keypress just needs to be treated like clicking on the plugin.)
-
-The fonts, font sizes, and colors used in the plugin come from the system theme, so they
-should not pose a problem for users with special needs. (But see discussion of
-sizing below.)
-
-Cross Browser Support
-=====================
-
-The plugin acts as a standard windowless plugin, so it shouldn't be restricted
-to working in Firefox or in Gecko-based browsers.
-
-The plugin does assume that the toolkit hosting the browser is GTK+ for a couple
-of things:
-
- - To get the theme colors and fonts
- - To get a timestamp from the X server if one isn't provided in the button press
- event when launching an app)
-
-These could be fixed if necessary. (Use XSETTINGS directly for fonts and colors,
-just skip the timestamp and let the newly launched app get placed in the
-background if not running GTK+ and no timestamp is provided.)
-
-More deeply, the plugin requires that the GLib main loop be running, so that
-libpackagekit can receive asynchronous notifications from the PackageKit daemon.
-So, getting it to work in Konqueror is going to be hard unless Qt has been
-compiled to use the GLib main loop.
-
-Trying it out
-=============
-
-packagekit-plugin builds with the standard:
-
- ./autogen.sh
- ./configure
- make
-
-Instead of doing 'make install', you can symlink .libs/packagekit-plugin into
-~/.mozilla/plugins. Then you can restart your browser and load the HTML page
-under tests/.
-
-If you do this, you probably want to delete the symlink when you are
-done so that it doesn't interfere with a system install of the plugin.
-
-Using
-=====
-
-Add the following code to your web page:
-
- <object type="application/x-packagekit-plugin" width="300" height="150">
- <!-- Name that will be used in the user interface -->
- <param name="displayname" value="GNU Backgammon"/>
- <!-- Whitespace separated list of package names -->
- <param name="packagenames" value="gnubg"/>
- </object>
-
-Unfortunately browser plugins have no mechanism for size negotiation, so you
-have to specify a predetermined size in some fashion. You can do it with the pixel
-sizes as above, or you can do it with CSS using 'em' sizes or percentage
-lengths. For example, you could have in your CSS:
-
- .packagekit-plugin {
- width: 30em;
- height: 5em;
- }
-
-And then add class="packagekit-plugin" to the object tag above.
-
-You should make the size generously bigger than what you need on your system
-to deal with translations and with varying font sizes and device resolutions.
-Using em sizes rather than points is probably a good idea to help with the
-font size issue, but it doesn't completely resolve it since the text of the
-plugin will be sized based on the system font size, not on the web pages font.
-
-Customization
-=============
-
-The default appearance of the plugin is very plain, with a rectangular outline
-and a white background. To customize this appearance, you can add the
-optional parameters radius and color to your web page. This will make the
-plugin draw a rectangle with rounded corners, and use the given color
-instead of white.
-
- <!-- radius for rounded corners -->
- <param name="radius" value="10"/>
- <!-- background color, must be parsable by pango_color_parse() -->
- <param name="color" value="#aeaeff"/>
-
-
-Owen Taylor <otaylor@redhat.com>
-July 24, 2008
-
-Last updated:
-
-Matthias Clasen <mclasen@redhat.com>
-August 21, 2009
diff --git a/contrib/browser-plugin/pk-main.c b/contrib/browser-plugin/pk-main.c
deleted file mode 100644
index 848a82944..000000000
--- a/contrib/browser-plugin/pk-main.c
+++ /dev/null
@@ -1,521 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Red Hat, Inc.
- * Copyright (C) 2008-2009 Richard Hughes <richard@hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <config.h>
-#include <glib/gprintf.h>
-#include <glib/gi18n-lib.h>
-
-#include <X11/Xlib.h>
-#include <X11/Intrinsic.h>
-
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-
-#include <npapi.h>
-#include <npfunctions.h>
-#include <npruntime.h>
-
-#define __USE_GNU
-#include <dlfcn.h>
-
-#include "pk-plugin.h"
-#include "pk-plugin-install.h"
-
-static NPNetscapeFuncs *npnfuncs = NULL;
-static void *module_handle = NULL;
-
-#ifndef HIBYTE
-#define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
-#endif
-
-static void pk_main_draw_window (PkPlugin *plugin);
-static void pk_main_event_handler (PkPlugin *plugin, XEvent *event);
-
-/**
- * pk_main_refresh_cb:
- **/
-static void
-pk_main_refresh_cb (PkPlugin *plugin_, NPP instance)
-{
- g_debug ("pk_main_refresh_cb [%p]", instance);
-
- /* invalid */
- if (plugin_ == NULL) {
- g_warning ("NULL plugin");
- return;
- }
-
- pk_main_draw_window (plugin_);
-}
-
-/**
- * pk_main_get_value:
- **/
-static NPError
-pk_main_get_value (NPP instance, NPPVariable variable, void *value)
-{
- NPError err = NPERR_NO_ERROR;
- switch (variable) {
- case NPPVpluginNameString:
- * ((const gchar **)value) = "PackageKit";
- break;
- case NPPVpluginDescriptionString:
- * ((const gchar **)value) = "Plugin for Installing Applications (new)";
- break;
- default:
- err = NPERR_INVALID_PARAM;
- }
- return err;
-}
-
-/**
- * pk_main_newp:
- **/
-static NPError
-pk_main_newp (NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved)
-{
- gint i;
- PkPlugin *plugin;
-
- g_debug ("new [%p]", instance);
-
- /* create new content instance */
- plugin = PK_PLUGIN (pk_plugin_install_new ());
- g_signal_connect (plugin, "refresh", G_CALLBACK (pk_main_refresh_cb), instance);
-
- /* set data */
- for (i = 0; i < argc; i++) {
- if (g_strcmp0 (argn[i], "displayname") == 0 ||
- g_strcmp0 (argn[i], "packagenames") == 0 ||
- g_strcmp0 (argn[i], "radius") == 0 ||
- g_strcmp0 (argn[i], "color") == 0)
- pk_plugin_set_data (plugin, argn[i], argv[i]);
- }
-
- /* add to list */
- instance->pdata = plugin;
-
- return NPERR_NO_ERROR;
-}
-
-/**
- * pk_main_destroy:
- **/
-static NPError
-pk_main_destroy (NPP instance, NPSavedData **save)
-{
- PkPlugin *plugin = PK_PLUGIN (instance->pdata);
-
- g_debug ("pk_main_destroy [%p]", instance);
-
- /* free content instance */
- g_signal_handlers_disconnect_by_func (plugin, G_CALLBACK (pk_main_refresh_cb), instance);
- g_object_unref (plugin);
-
- return NPERR_NO_ERROR;
-}
-
-/**
- * pk_main_plugin_x11_filter_event:
- **/
-static GdkFilterReturn
-pk_main_plugin_x11_filter_event (GdkXEvent *gdkxevent, GdkEvent *unused, gpointer plugin)
-{
- pk_main_event_handler (plugin, gdkxevent);
- return GDK_FILTER_REMOVE;
-}
-
-/**
- * pk_main_create_window:
- **/
-static void
-pk_main_create_window (PkPlugin *plugin)
-{
- gint width;
- gint height;
- Window xwindow;
- Display *xdisplay;
- GdkWindow *gdk_window;
-
- /* get parameters */
- g_object_get (plugin,
- "width", &width,
- "height", &height,
- "display", &xdisplay,
- "window", &xwindow,
- "gdk-window", &gdk_window,
- NULL);
-
-
- if (gdk_window == NULL) {
- GdkWindowAttr attr;
- GdkWindow *parent;
- GdkDisplay *display;
-
- // TODO - is it correct? Do we want to translate xdisplay -> GdkDisplay?
- display = gdk_display_get_default ();
- if (display == NULL) {
- g_debug ("invalid display returned by gdk_display_get_default ()\n");
- return;
- }
-
- /* get parent */
-#if GTK_CHECK_VERSION(2,24,0)
- parent = gdk_x11_window_foreign_new_for_display (display, xwindow);
-#else
- parent = gdk_window_foreign_new (xwindow);
-#endif
- if (parent == NULL) {
- g_debug ("invalid window given for setup (id %lu)\n", xwindow);
- return;
- }
-
- attr.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK |
- GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK;
- attr.x = 0;
- attr.y = 0;
- attr.width = width;
- attr.height = height;
- attr.window_type = GDK_WINDOW_CHILD;
- attr.wclass = GDK_INPUT_OUTPUT;
- gdk_window = gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
- gdk_window_add_filter (gdk_window, pk_main_plugin_x11_filter_event, plugin);
-
- /* show window */
- gdk_window_show (gdk_window);
- g_object_set (plugin, "gdk-window", gdk_window, NULL);
-
- } else {
- gdk_window_move_resize (gdk_window, 0, 0, width, height);
- }
-}
-
-/**
- * pk_main_delete_window:
- **/
-static void
-pk_main_delete_window (PkPlugin *plugin)
-{
- GdkWindow *gdk_window;
-
- /* get drawing window */
- g_object_get (plugin, "gdk-window", &gdk_window, NULL);
-
- if (gdk_window)
- gdk_window_remove_filter (gdk_window, pk_main_plugin_x11_filter_event, plugin);
-
- /* Clear parameters */
- g_object_set (plugin,
- "x", 0,
- "y", 0,
- "width", 0,
- "height", 0,
- "display", NULL,
- "visual", NULL,
- "window", 0,
- "gdk-window", NULL,
- NULL);
-}
-
-/**
- * pk_main_draw_window:
- **/
-static void
-pk_main_draw_window (PkPlugin *plugin)
-{
- cairo_t *cr;
- GdkWindow *gdk_window;
-
- /* get drawing window */
- g_object_get (plugin, "gdk-window", &gdk_window, NULL);
-
- if (gdk_window == NULL) {
- g_debug ("gdk_window is NULL!");
- return;
- }
-
- cr = gdk_cairo_create (gdk_window);
- pk_plugin_draw (plugin, cr);
- cairo_destroy (cr);
-}
-
-/**
- * pk_main_handle_event:
- **/
-static void
-pk_main_event_handler (PkPlugin *plugin, XEvent *event)
-{
- XButtonEvent *xbe;
- XMotionEvent *xme;
- XCrossingEvent *xce;
-
- g_debug ("pk_main_handle_event [%p]", plugin);
-
- /* find plugin */
- if (plugin == NULL)
- return;
-
- switch (event->xany.type) {
- case VisibilityNotify:
- case Expose:
- {
- Display *display;
- Window window;
-
- g_debug ("Expose [%p]", plugin);
-
- /* get parameters */
- g_object_get (plugin, "display", &display, "window", &window, NULL);
-
- /* get rid of all other exposure events */
- while (XCheckTypedWindowEvent (display, window, Expose, event));
- pk_main_draw_window (plugin);
- return;
- }
- case ButtonPress:
- xbe = (XButtonEvent *)event;
- pk_plugin_button_press (plugin, xbe->x, xbe->y, xbe->time);
- return;
- case ButtonRelease:
- xbe = (XButtonEvent *)event;
- pk_plugin_button_release (plugin, xbe->x, xbe->y, xbe->time);
- return;
- case MotionNotify:
- xme = (XMotionEvent *)event;
- pk_plugin_motion (plugin, xme->x, xme->y);
- return;
- case EnterNotify:
- xce = (XCrossingEvent *)event;
- pk_plugin_enter (plugin, xce->x, xce->y);
- return;
- case LeaveNotify:
- xce = (XCrossingEvent *)event;
- pk_plugin_leave (plugin, xce->x, xce->y);
- return;
- }
-}
-
-/**
- * pk_main_set_window:
- **/
-static NPError
-pk_main_set_window (NPP instance, NPWindow* pNPWindow)
-{
- gboolean ret;
- gboolean started;
- PkPlugin *plugin;
- NPSetWindowCallbackStruct *ws_info;
- Window window;
-
- g_debug ("pk_main_set_window [%p]", instance);
-
- /* find plugin */
- plugin = PK_PLUGIN (instance->pdata);
- if (plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- /* shutdown */
- if (pNPWindow == NULL) {
- pk_main_delete_window (plugin);
- return NPERR_NO_ERROR;
- }
-
- /* type */
- g_debug ("type=%i (NPWindowTypeWindow=%i, NPWindowTypeDrawable=%i)",
- pNPWindow->type, NPWindowTypeWindow, NPWindowTypeDrawable);
-
- g_object_get (plugin,
- "window", &window,
- NULL);
-
- /*
- * The page with the plugin is being resized.
- * Save any UI information because the next time
- * around expect a SetWindow with a new window
- * id.
- */
- if ((Window) (pNPWindow->window) == window) {
- g_debug ("resize event will come");
- goto out;
- }
-
- /* do we have a callback struct (WebKit doesn't send this) */
- ws_info = (NPSetWindowCallbackStruct *) pNPWindow->ws_info;
- if (ws_info == NULL) {
- g_debug ("no callback struct");
- goto out;
- }
-
- /* no visual yet */
- if (ws_info->visual == NULL) {
- g_debug ("no visual, so skipping");
- goto out;
- }
-
- /* set parameters */
- g_object_set (plugin,
- "x", 0,
- "y", 0,
- "width", pNPWindow->width,
- "height", pNPWindow->height,
- "display", ws_info->display,
- "visual", ws_info->visual,
- "window", pNPWindow->window,
- NULL);
-
- g_debug ("x=%i, y=%i, width=%i, height=%i, display=%p, visual=%p, window=%ld",
- pNPWindow->x, pNPWindow->y, pNPWindow->width, pNPWindow->height,
- ws_info->display, ws_info->visual, (Window)pNPWindow->window);
-
- /* is already started */
- g_object_get (plugin,
- "started", &started,
- NULL);
- if (!started) {
- /* start plugin */
- ret = pk_plugin_start (plugin);
- if (!ret)
- g_warning ("failed to start plugin");
- }
-
- /* Set-up drawing window */
- pk_main_create_window (plugin);
-
- /* draw plugin */
- pk_main_draw_window (plugin);
-
-out:
- return NPERR_NO_ERROR;
-}
-
-/**
- * pk_main_make_module_resident:
- *
- * If our dependent libraries like libpackagekit get unloaded, bad stuff
- * happens (they may have registered GLib types and so forth) so we need
- * to keep them around. The (GNU extension) RTLD_NODELETE seems useful
- * but isn't so much, since it only refers to a specific library and not
- * its dependent libraries, so we'd have to identify specifically each
- * of our dependencies that is not safe to unload and that is most of
- * the GTK+ stack.
- **/
-static void
-pk_main_make_module_resident (void)
-{
- Dl_info info;
-
- /* get the absolute filename of this module */
- if (!dladdr ((void *)NP_GetMIMEDescription, &info)) {
- g_warning ("Can't find filename for module");
- return;
- }
-
- /* now reopen it to get our own handle */
- module_handle = dlopen (info.dli_fname, RTLD_NOW);
- if (!module_handle) {
- g_warning ("Can't permanently open module %s", dlerror ());
- return;
- }
-}
-
-NPError NP_GetEntryPoints (NPPluginFuncs *nppfuncs);
-
-/**
- * NP_GetEntryPoints:
- **/
-NPError
-NP_GetEntryPoints (NPPluginFuncs *nppfuncs)
-{
- g_debug ("NP_GetEntryPoints");
-
- nppfuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
- nppfuncs->newp = pk_main_newp;
- nppfuncs->destroy = pk_main_destroy;
- nppfuncs->getvalue = pk_main_get_value;
- nppfuncs->setwindow = pk_main_set_window;
-
- return NPERR_NO_ERROR;
-}
-
-/**
- * NP_Initialize:
- **/
-NPError
-NP_Initialize (NPNetscapeFuncs *npnf, NPPluginFuncs *nppfuncs)
-{
- g_debug ("NP_Initialize");
-
- if (npnf == NULL)
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- if (HIBYTE (npnf->version) > NP_VERSION_MAJOR)
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- /* already initialized */
- if (module_handle != NULL)
- return NPERR_NO_ERROR;
-
- /* if libpackagekit get unloaded, bad stuff happens */
- pk_main_make_module_resident ();
-
-#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-#endif
-
- npnfuncs = npnf;
- NP_GetEntryPoints (nppfuncs);
- return NPERR_NO_ERROR;
-}
-
-/**
- * NP_Shutdown:
- **/
-NPError
-NP_Shutdown ()
-{
- g_debug ("NP_Shutdown");
- return NPERR_NO_ERROR;
-}
-
-/**
- * NP_GetMIMEDescription:
- **/
-const char *
-NP_GetMIMEDescription (void)
-{
- g_debug ("NP_GetMIMEDescription");
- return (const gchar*) "application/x-packagekit-plugin:bsc:PackageKit Plugin";
-}
-
-/**
- * NP_GetValue:
- **/
-NPError
-NP_GetValue (void *npp, NPPVariable variable, void *value)
-{
- return pk_main_get_value ((NPP)npp, variable, value);
-}
-
diff --git a/contrib/browser-plugin/pk-plugin-install.c b/contrib/browser-plugin/pk-plugin-install.c
deleted file mode 100644
index 2a4ee3bcd..000000000
--- a/contrib/browser-plugin/pk-plugin-install.c
+++ /dev/null
@@ -1,1051 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008-2014 Richard Hughes <richard@hughsie.com>
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <glib/gi18n-lib.h>
-#include <gio/gdesktopappinfo.h>
-#include <pango/pangocairo.h>
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-#include <math.h>
-#include <packagekit-glib2/packagekit.h>
-
-#include "pk-plugin-install.h"
-
-#include "src/pk-cleanup.h"
-
-#define PK_PLUGIN_INSTALL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_PLUGIN_INSTALL, PkPluginInstallPrivate))
-
-typedef enum {
- IN_PROGRESS, /* looking up package information */
- INSTALLED, /* package installed */
- UPGRADABLE, /* package installed, newer version available */
- AVAILABLE, /* package not installed, version available */
- UNAVAILABLE, /* package not installed or available */
- INSTALLING /* currently installing a new version */
-} PkPluginInstallPackageStatus;
-
-struct PkPluginInstallPrivate
-{
- PkPluginInstallPackageStatus status;
- gchar *available_version;
- gchar *available_package_name;
- gchar *installed_version;
- gchar *installed_package_name;
- GAppInfo *app_info;
- gchar *display_name;
- gchar **package_names;
- PangoLayout *pango_layout;
- PkClient *client;
- GDBusProxy *session_pk_proxy;
- GCancellable *cancellable;
- gint timeout;
- gint current;
- gint update_spinner;
-};
-
-G_DEFINE_TYPE (PkPluginInstall, pk_plugin_install, PK_TYPE_PLUGIN)
-
-/**
- * pk_plugin_install_clear_layout:
- **/
-static void
-pk_plugin_install_clear_layout (PkPluginInstall *self)
-{
- g_debug ("clearing layout");
-
- if (self->priv->pango_layout) {
- g_object_unref (self->priv->pango_layout);
- self->priv->pango_layout = NULL;
- }
-}
-
-/**
- * pk_plugin_install_refresh:
- **/
-static void
-pk_plugin_install_refresh (PkPluginInstall *self)
-{
- pk_plugin_request_refresh (PK_PLUGIN (self));
-}
-
-#define SPINNER_LINES 12
-#define SPINNER_SIZE 24
-
-static gboolean
-spinner_timeout (gpointer data)
-{
- PkPluginInstall *self = data;
-
- self->priv->current++;
- if (self->priv->current >= SPINNER_LINES)
- self->priv->current = 0;
- self->priv->update_spinner = TRUE;
-
- pk_plugin_install_refresh (self);
-
- return TRUE;
-}
-
-/**
- * pk_plugin_install_set_status:
- **/
-static void
-pk_plugin_install_set_status (PkPluginInstall *self, PkPluginInstallPackageStatus status)
-{
- if (self->priv->status != status) {
- g_debug ("setting status %u", status);
- self->priv->status = status;
-
- if (status == INSTALLING) {
- self->priv->timeout = g_timeout_add (80, spinner_timeout, self);
- g_source_set_name_by_id (self->priv->timeout, "[PkPluginInstall] spinner");
- }
- else if (self->priv->timeout) {
- g_source_remove (self->priv->timeout);
- self->priv->timeout = 0;
- }
- }
-
-}
-
-/**
- * pk_plugin_install_set_available_version:
- **/
-static void
-pk_plugin_install_set_available_version (PkPluginInstall *self, const gchar *version)
-{
- g_debug ("setting available version: %s", version);
-
- g_free (self->priv->available_version);
- self->priv->available_version = g_strdup (version);
-}
-
-/**
- * pk_plugin_install_set_available_package_name:
- **/
-static void
-pk_plugin_install_set_available_package_name (PkPluginInstall *self, const gchar *name)
-{
- g_debug ("setting available package name: %s", name);
-
- g_free (self->priv->available_package_name);
- self->priv->available_package_name = g_strdup (name);
-}
-
-/**
- * pk_plugin_install_set_installed_package_name:
- **/
-static void
-pk_plugin_install_set_installed_package_name (PkPluginInstall *self, const gchar *name)
-{
- g_debug ("setting installed package name: %s", name);
-
- g_free (self->priv->installed_package_name);
- self->priv->installed_package_name = g_strdup (name);
-}
-
-/**
- * pk_plugin_install_set_installed_version:
- **/
-static void
-pk_plugin_install_set_installed_version (PkPluginInstall *self, const gchar *version)
-{
- g_debug ("setting installed version: %s", version);
-
- g_free (self->priv->installed_version);
- self->priv->installed_version = g_strdup (version);
-}
-
-/**
- * pk_plugin_install_finished_cb:
- **/
-static void
-pk_plugin_install_finished_cb (GObject *object, GAsyncResult *res, PkPluginInstall *self)
-{
- PkClient *client = PK_CLIENT (object);
- PkPackage *item;
- PkInfoEnum info;
- _cleanup_error_free_ GError *error = NULL;
- _cleanup_free_ gchar *filename = NULL;
- _cleanup_free_ gchar *package_id = NULL;
- _cleanup_free_ gchar *summary = NULL;
- _cleanup_object_unref_ PkError *error_code = NULL;
- _cleanup_object_unref_ PkResults *results = NULL;
- _cleanup_ptrarray_unref_ GPtrArray *packages = NULL;
-
- /* get the results */
- results = pk_client_generic_finish (client, res, &error);
- if (results == NULL) {
- g_warning ("failed to resolve: %s", error->message);
- goto out;
- }
-
- /* check error code */
- error_code = pk_results_get_error_code (results);
- if (error_code != NULL) {
- g_warning ("failed to install: %s, %s",
- pk_error_enum_to_string (pk_error_get_code (error_code)),
- pk_error_get_details (error_code));
- goto out;
- }
-
- /* get packages */
- packages = pk_results_get_package_array (results);
- if (packages->len == 0)
- goto out;
-
- /* no results */
- if (packages->len > 1)
- g_warning ("more than one result (%i), just choosing first", packages->len);
-
- /* choose first package */
- item = g_ptr_array_index (packages, 0);
- g_object_get (item,
- "info", &info,
- "package-id", &package_id,
- "summary", &summary,
- NULL);
-
- /* if we didn't use displayname, use the summary */
- if (self->priv->display_name == NULL)
- self->priv->display_name = g_strdup (summary);
-
- /* parse the data */
- if (info == PK_INFO_ENUM_AVAILABLE) {
- _cleanup_strv_free_ gchar **split = NULL;
- if (self->priv->status == IN_PROGRESS)
- pk_plugin_install_set_status (self, AVAILABLE);
- else if (self->priv->status == INSTALLED)
- pk_plugin_install_set_status (self, UPGRADABLE);
- split = pk_package_id_split (package_id);
- pk_plugin_install_set_available_package_name (self, split[0]);
- pk_plugin_install_set_available_version (self, split[1]);
- pk_plugin_install_clear_layout (self);
- pk_plugin_install_refresh (self);
-
- } else if (info == PK_INFO_ENUM_INSTALLED) {
- _cleanup_strv_free_ gchar **split = NULL;
- if (self->priv->status == IN_PROGRESS)
- pk_plugin_install_set_status (self, INSTALLED);
- else if (self->priv->status == AVAILABLE)
- pk_plugin_install_set_status (self, UPGRADABLE);
- split = pk_package_id_split (package_id);
- pk_plugin_install_set_installed_package_name (self, split[0]);
- pk_plugin_install_set_installed_version (self, split[1]);
- pk_plugin_install_set_status (self, INSTALLED);
- pk_plugin_install_clear_layout (self);
- pk_plugin_install_refresh (self);
- }
-out:
- /* we didn't get any results, or we failed */
- if (self->priv->status == IN_PROGRESS) {
- pk_plugin_install_set_status (self, UNAVAILABLE);
- pk_plugin_install_clear_layout (self);
- pk_plugin_install_refresh (self);
- }
-}
-
-/**
- * pk_plugin_install_recheck:
- **/
-static void
-pk_plugin_install_recheck (PkPluginInstall *self)
-{
- const gchar *data;
-
- self->priv->status = IN_PROGRESS;
- pk_plugin_install_set_available_version (self, NULL);
- pk_plugin_install_set_available_package_name (self, NULL);
- pk_plugin_install_set_installed_version (self, NULL);
- pk_plugin_install_set_installed_package_name (self, NULL);
-
- /* get data, if if does not exist */
- if (self->priv->package_names == NULL) {
- data = pk_plugin_get_data (PK_PLUGIN (self), "displayname");
- self->priv->display_name = g_strdup (data);
- data = pk_plugin_get_data (PK_PLUGIN (self), "packagenames");
- self->priv->package_names = g_strsplit (data, " ", -1);
- }
-
- /* do async resolve */
- pk_client_resolve_async (self->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NEWEST, -1),
- self->priv->package_names, NULL, NULL, NULL,
- (GAsyncReadyCallback) pk_plugin_install_finished_cb, self);
-}
-
-/* just to please -Wmissing-format-attribute */
-static void pk_plugin_install_append_markup (GString *str, const gchar *format, ...) G_GNUC_PRINTF(2,3);
-
-/**
- * pk_plugin_install_append_markup:
- **/
-static void
-pk_plugin_install_append_markup (GString *str, const gchar *format, ...)
-{
- va_list vap;
- _cleanup_free_ gchar *tmp = NULL;
-
- va_start (vap, format);
- tmp = g_markup_vprintf_escaped (format, vap);
- va_end (vap);
- g_string_append (str, tmp);
-}
-
-/**
- * pk_plugin_install_rgba_from_gdk_color:
- **/
-static guint32
-pk_plugin_install_rgba_from_gdk_color (GdkColor *color)
-{
- return (((color->red >> 8) << 24) |
- ((color->green >> 8) << 16) |
- ((color->blue >> 8) << 8) |
- 0xff);
-}
-
-/**
- * pk_plugin_install_set_source_from_rgba:
- **/
-static void
-pk_plugin_install_set_source_from_rgba (cairo_t *cr, guint32 rgba)
-{
- cairo_set_source_rgba (cr,
- ((rgba & 0xff000000) >> 24) / 255.,
- ((rgba & 0x00ff0000) >> 16) / 255.,
- ((rgba & 0x0000ff00) >> 8) / 255.,
- (rgba & 0x000000ff) / 255.);
-}
-
-/**
- * pk_plugin_install_get_style:
- *
- * Retrieve the system colors and fonts.
- * This looks incredibly expensive .... to create a GtkWindow for
- * every expose ... but actually it's only moderately expensive;
- * Creating a GtkWindow is just normal GObject creation overhead --
- * the extra expense beyond that will come when we actually create
- * the window.
- **/
-static void
-pk_plugin_install_get_style (PangoFontDescription **font_desc,
- guint32 *foreground,
- guint32 *background,
- guint32 *linked)
-{
- GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- GtkStyle *style;
- GdkColor link_color = { 0, 0, 0, 0xeeee };
- GdkColor *tmp = NULL;
-
- gtk_widget_ensure_style (window);
-
- style = gtk_widget_get_style (window);
- *foreground = pk_plugin_install_rgba_from_gdk_color (&style->text[GTK_STATE_NORMAL]);
- *background = pk_plugin_install_rgba_from_gdk_color (&style->base[GTK_STATE_NORMAL]);
-
- gtk_widget_style_get (GTK_WIDGET (window), "link-color", &tmp, NULL);
- if (tmp != NULL) {
- link_color = *tmp;
- gdk_color_free (tmp);
- }
-
- *linked = pk_plugin_install_rgba_from_gdk_color (&link_color);
- *font_desc = pango_font_description_copy (style->font_desc);
-
- gtk_widget_destroy (window);
-}
-
-/**
- * pk_plugin_install_ensure_layout:
- **/
-static void
-pk_plugin_install_ensure_layout (PkPluginInstall *self,
- cairo_t *cr,
- PangoFontDescription *font_desc,
- guint32 link_color)
-{
- _cleanup_string_free_ GString *markup = g_string_new (NULL);
-
- if (self->priv->pango_layout != NULL)
- return;
-
- self->priv->pango_layout = pango_cairo_create_layout (cr);
- pango_layout_set_font_description (self->priv->pango_layout, font_desc);
-
- /* WARNING: Any changes to what links are created here will require corresponding
- * changes to the pk_plugin_install_button_release () method
- */
- switch (self->priv->status) {
- case IN_PROGRESS:
- /* TRANSLATORS: when we are getting data from the daemon */
- pk_plugin_install_append_markup (markup, _("Getting package information..."));
- break;
- case INSTALLED:
- if (self->priv->app_info != 0) {
- pk_plugin_install_append_markup (markup, "<span color='#%06x' underline='single'>", link_color >> 8);
- /* TRANSLATORS: run an applicaiton */
- pk_plugin_install_append_markup (markup, _("Run %s"), self->priv->display_name);
- pk_plugin_install_append_markup (markup, "</span>");
- } else
- pk_plugin_install_append_markup (markup, "<big>%s</big>", self->priv->display_name);
- if (self->priv->installed_version != NULL)
- /* TRANSLATORS: show the installed version of a package */
- pk_plugin_install_append_markup (markup, "\n<small>%s: %s</small>", _("Installed version"), self->priv->installed_version);
- break;
- case UPGRADABLE:
- pk_plugin_install_append_markup (markup, "<big>%s</big>", self->priv->display_name);
- if (self->priv->app_info != 0) {
- if (self->priv->installed_version != NULL) {
- pk_plugin_install_append_markup (markup, "\n<span color='#%06x' underline='single'>", link_color >> 8);
- /* TRANSLATORS: run the application now */
- pk_plugin_install_append_markup (markup, _("Run version %s now"), self->priv->installed_version);
- pk_plugin_install_append_markup (markup, "</span>");
- } else {
- pk_plugin_install_append_markup (markup,
- "\n<span color='#%06x' underline='single'>%s</span>",
- /* TRANSLATORS: run the application now */
- link_color >> 8, _("Run now"));
- }
- }
-
- pk_plugin_install_append_markup (markup, "\n<span color='#%06x' underline='single'>", link_color >> 8);
- /* TRANSLATORS: update to a new version of the package */
- pk_plugin_install_append_markup (markup, _("Update to version %s"), self->priv->available_version);
- pk_plugin_install_append_markup (markup, "</span>");
- break;
- case AVAILABLE:
- pk_plugin_install_append_markup (markup, "<span color='#%06x' underline='single'>", link_color >> 8);
- /* TRANSLATORS: To install a package */
- pk_plugin_install_append_markup (markup, _("Install %s now"), self->priv->display_name);
- pk_plugin_install_append_markup (markup, "</span>");
- /* TRANSLATORS: the version of the package */
- pk_plugin_install_append_markup (markup, "\n<small>%s: %s</small>", _("Version"), self->priv->available_version);
- break;
- case UNAVAILABLE:
- pk_plugin_install_append_markup (markup, "<big>%s</big>", self->priv->display_name);
- /* TRANSLATORS: noting found, so can't install */
- pk_plugin_install_append_markup (markup, "\n<small>%s</small>", _("No packages found for your system"));
- break;
- case INSTALLING:
- pk_plugin_install_append_markup (markup, "<big>%s</big>", self->priv->display_name);
- /* TRANSLATORS: package is being installed */
- pk_plugin_install_append_markup (markup, "\n<small>%s</small>", _("Installing..."));
- break;
- }
-
- pango_layout_set_markup (self->priv->pango_layout, markup->str, -1);
-}
-
-/**
- * pk_plugin_install_start:
- **/
-static gboolean
-pk_plugin_install_start (PkPlugin *plugin)
-{
- PkPluginInstall *self = PK_PLUGIN_INSTALL (plugin);
- pk_plugin_install_recheck (self);
- return TRUE;
-}
-
-/**
- * pk_plugin_install_draw_spinner:
- **/
-static void
-pk_plugin_install_draw_spinner (PkPlugin *plugin, cairo_t *cr, int cx, int cy)
-{
- gint width, height;
- double x, y;
- double radius;
- double half;
- gint i;
-
- PkPluginInstall *self = PK_PLUGIN_INSTALL (plugin);
-
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
-
- width = height = SPINNER_SIZE;
- radius = MIN (width / 2.0, height / 2.0);
- half = SPINNER_LINES / 2;
-
- x = cx + width / 2;
- y = cy + height / 2;
-
- for (i = 0; i < SPINNER_LINES; i++) {
- gint inset = 0.7 * radius;
- /* transparency is a function of time and intial value */
- gdouble t = (gdouble) ((i + SPINNER_LINES - self->priv->current) % SPINNER_LINES) / SPINNER_LINES;
- cairo_save (cr);
-
- cairo_set_source_rgba (cr, 0, 0, 0, t);
- cairo_set_line_width (cr, 2.0);
- cairo_move_to (cr,
- x + (radius - inset) * cos (i * G_PI / half),
- y + (radius - inset) * sin (i * G_PI / half));
- cairo_line_to (cr,
- x + radius * cos (i * G_PI / half),
- y + radius * sin (i * G_PI / half));
- cairo_stroke (cr);
- cairo_restore (cr);
- }
-}
-
-/**
- * pk_plugin_install_rounded_rectangle:
- **/
-static void
-pk_plugin_install_rounded_rectangle (cairo_t *cr, gdouble x, gdouble y,
- gdouble w, gdouble h, gdouble radius)
-{
- const gdouble ARC_TO_BEZIER = 0.55228475;
- gdouble c;
-
- if (radius == 0) {
- cairo_rectangle (cr, x, y, w, h);
- return;
- }
-
- if (radius > w - radius)
- radius = w / 2;
- if (radius > h - radius)
- radius = h / 2;
-
- c = ARC_TO_BEZIER * radius;
-
- cairo_new_path (cr);
- cairo_move_to (cr, x + radius, y);
- cairo_rel_line_to (cr, w - 2 * radius, 0);
- cairo_rel_curve_to (cr, c, 0, radius, c, radius, radius);
- cairo_rel_line_to (cr, 0, h - 2 * radius);
- cairo_rel_curve_to (cr, 0, c, c - radius, radius, -radius, radius);
- cairo_rel_line_to (cr, -w + 2 * radius, 0);
- cairo_rel_curve_to (cr, -c, 0, -radius, -c, -radius, -radius);
- cairo_rel_line_to (cr, 0, -h + 2 * radius);
- cairo_rel_curve_to (cr, 0, -c, radius - c, -radius, radius, -radius);
- cairo_close_path (cr);
-}
-
-/**
- * pk_plugin_install_draw:
- **/
-static gboolean
-pk_plugin_install_draw (PkPlugin *plugin, cairo_t *cr)
-{
- guint32 foreground, background, linked;
- PangoFontDescription *font_desc;
- guint x;
- guint y;
- guint width;
- guint height;
- guint radius;
- GtkIconTheme *theme;
- PangoRectangle rect;
- PkPluginInstall *self = PK_PLUGIN_INSTALL (plugin);
- guint sep;
- const gchar *data;
- PangoColor color;
- gboolean has_color;
- _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL;
-
- /* get parameters */
- g_object_get (self,
- "x", &x,
- "y", &y,
- "width", &width,
- "height", &height,
- NULL);
-
- data = pk_plugin_get_data (plugin, "radius");
- if (data)
- radius = atoi (data);
- else
- radius = 0;
-
- data = pk_plugin_get_data (plugin, "color");
- if (data)
- has_color = pango_color_parse (&color, data);
- else
- has_color = FALSE;
-
- sep = MAX ((height - 48) / 2, radius);
-
- g_debug ("drawing on %ux%u (%ux%u)", x, y, width, height);
-
- /* get properties */
- pk_plugin_install_get_style (&font_desc, &foreground, &background, &linked);
- if (self->priv->update_spinner) {
- self->priv->update_spinner = FALSE;
- goto update_spinner;
- }
-
- /* fill background */
- pk_plugin_install_set_source_from_rgba (cr, background);
- cairo_rectangle (cr, x, y, width, height);
- cairo_fill (cr);
- if (has_color)
- cairo_set_source_rgb (cr, color.red / 65536.0, color.green / 65536.0, color.blue / 65536.0);
- else
- pk_plugin_install_set_source_from_rgba (cr, background);
- pk_plugin_install_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1, radius);
- cairo_fill (cr);
-
- /* grey outline */
- cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
- pk_plugin_install_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1, radius);
- cairo_set_line_width (cr, 1);
- cairo_stroke (cr);
-
- /* get themed icon */
- theme = gtk_icon_theme_get_default ();
- pixbuf = gtk_icon_theme_load_icon (theme, "package-x-generic", 48,
- GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
- if (pixbuf == NULL)
- goto skip;
-
- gdk_cairo_set_source_pixbuf (cr, pixbuf, x + sep, y + (height - 48) / 2);
- cairo_rectangle (cr, x + sep, y + (height - 48) / 2, 48, 48);
- cairo_fill (cr);
-
-skip:
- /* write text */
- pk_plugin_install_ensure_layout (self, cr, font_desc, linked);
- pango_layout_get_pixel_extents (self->priv->pango_layout, &rect, NULL);
- cairo_move_to (cr, x + sep + 48 + sep, y + (height - (rect.height + 48) / 2) / 2);
- pk_plugin_install_set_source_from_rgba (cr, foreground);
- pango_cairo_show_layout (cr, self->priv->pango_layout);
-
-update_spinner:
- if (self->priv->status == INSTALLING) {
- pango_layout_get_pixel_extents (self->priv->pango_layout, &rect, NULL);
- if (has_color)
- cairo_set_source_rgb (cr, color.red / 65536.0, color.green / 65536.0, color.blue / 65536.0);
- else
- pk_plugin_install_set_source_from_rgba (cr, background);
- cairo_rectangle (cr,
- x + sep + 48 + sep + rect.width + 2 * sep,
- y + (height - SPINNER_SIZE) / 2,
- SPINNER_SIZE, SPINNER_SIZE);
- cairo_fill (cr);
- pk_plugin_install_set_source_from_rgba (cr, foreground);
-
- pk_plugin_install_draw_spinner (plugin, cr,
- x + sep + 48 + sep + rect.width + 2 * sep,
- y + (height - SPINNER_SIZE) / 2);
- }
- return TRUE;
-}
-
-/**
- * pk_plugin_install_line_is_terminated:
- *
- * Cut and paste from pango-layout.c; determines if a layout iter is on
- * a line terminated by a real line break (rather than a line break from
- * wrapping). We use this to determine whether the empty run at the end
- * of a display line should be counted as a break between links or not.
- *
- * (Code in pango-layout.c is by me, Copyright Red Hat, and hereby relicensed
- * to the license of this file)
- **/
-static gboolean
-pk_plugin_install_line_is_terminated (PangoLayoutIter *iter)
-{
- /* There is a real terminator at the end of each paragraph other
- * than the last.
- */
- PangoLayoutLine *line = pango_layout_iter_get_line (iter);
- GSList *lines = pango_layout_get_lines (pango_layout_iter_get_layout (iter));
- GSList *found = g_slist_find (lines, line);
- if (!found) {
- g_warning ("Can't find line in layout line list");
- return FALSE;
- }
-
- if (found->next) {
- PangoLayoutLine *next_line = (PangoLayoutLine *)found->next->data;
- if (next_line->is_paragraph_start)
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- * pk_plugin_install_get_link_index:
- *
- * This function takes an X,Y position and determines whether it is over one
- * of the underlined portions of the layout (a link). It works by iterating
- * through the runs of the layout (a run is a segment with a consistent
- * font and display attributes, more or less), and counting the underlined
- * segments that we see. A segment that is underlined could be broken up
- * into multiple runs if it is drawn with multiple fonts due to fonts
- * substitution, so we actually count non-underlined => underlined
- * transitions.
- **/
-static gint
-pk_plugin_install_get_link_index (PkPluginInstall *self, gint x, gint y)
-{
- gint idx;
- gint trailing;
- PangoLayoutIter *iter;
- gint seen_links = 0;
- gboolean in_link = FALSE;
- gint result = -1;
- guint height;
- guint radius;
- guint sep;
- PangoRectangle rect;
- const char *data;
-
- /* Coordinates are relative to origin of plugin (different from drawing) */
-
- if (!self->priv->pango_layout)
- return -1;
-
- g_object_get (self, "height", &height, NULL);
- data = pk_plugin_get_data (PK_PLUGIN (self), "radius");
- if (data)
- radius = atoi (data);
- else
- radius = 0;
- sep = MAX ((height - 48) / 2, radius);
- pango_layout_get_pixel_extents (self->priv->pango_layout, &rect, NULL);
- x -= sep + 48 + sep;
- y -= (height - (rect.height + 48) / 2) / 2;
-
- if (!pango_layout_xy_to_index (self->priv->pango_layout, x * PANGO_SCALE, y * PANGO_SCALE, &idx, &trailing))
- return - 1;
-
- iter = pango_layout_get_iter (self->priv->pango_layout);
- while (TRUE) {
- PangoLayoutRun *run = pango_layout_iter_get_run (iter);
- if (run) {
- PangoItem *item = run->item;
- PangoUnderline uline = PANGO_UNDERLINE_NONE;
- GSList *l;
-
- for (l = item->analysis.extra_attrs; l; l = l->next) {
- PangoAttribute *attr = (PangoAttribute *)l->data;
- if (attr->klass->type == PANGO_ATTR_UNDERLINE) {
- uline = (PangoUnderline) ( (PangoAttrInt *)attr)->value;
- }
- }
-
- if (uline == PANGO_UNDERLINE_NONE)
- in_link = FALSE;
- else if (!in_link) {
- in_link = TRUE;
- seen_links++;
- }
-
- if (item->offset <= idx && idx < item->offset + item->length) {
- if (in_link)
- result = seen_links - 1;
-
- break;
- }
- } else {
- /* We have an empty run at the end of each line. A line break doesn't
- * terminate the link, but a real newline does.
- */
- if (pk_plugin_install_line_is_terminated (iter))
- in_link = FALSE;
- }
-
- if (!pango_layout_iter_next_run (iter))
- break;
- }
-
- pango_layout_iter_free (iter);
-
- return result;
-}
-
-/**
- * pk_plugin_install_method_finished_cb:
- **/
-static void
-pk_plugin_install_method_finished_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- PkPluginInstall *self = PK_PLUGIN_INSTALL (user_data);
- GDBusProxy *proxy = G_DBUS_PROXY (source_object);
- _cleanup_error_free_ GError *error = NULL;
- _cleanup_variant_unref_ GVariant *value = NULL;
-
- value = g_dbus_proxy_call_finish (proxy, res, &error);
- if (value == NULL)
- g_warning ("Error occurred during install: %s", error->message);
- pk_plugin_install_recheck (self);
-}
-
-/**
- * pk_plugin_install_install_package:
- **/
-static void
-pk_plugin_install_install_package (PkPluginInstall *self, Time event_time)
-{
- GdkEvent *event;
- GdkWindow *window;
- guint xid = 0;
- _cleanup_strv_free_ gchar **packages = NULL;
-
- if (self->priv->available_package_name == NULL) {
- g_warning ("No available package to install");
- return;
- }
-
- /* will be NULL when activated not using a keyboard or a mouse */
- event = gtk_get_current_event ();
- if (event != NULL && event->any.window != NULL) {
- window = gdk_window_get_toplevel (event->any.window);
- xid = GDK_DRAWABLE_XID (window);
- }
-
- packages = g_strsplit (self->priv->available_package_name, ";", -1);
- g_dbus_proxy_call (self->priv->session_pk_proxy,
- "InstallPackageNames",
- g_variant_new ("(u^a&ss)",
- xid,
- packages,
- "hide-confirm-search,"
- "hide-progress,"
- "hide-confirm-deps,"
- "hide-finished"),
- G_DBUS_CALL_FLAGS_NONE,
- 60 * 60 * 1000, /* 1 hour */
- self->priv->cancellable,
- pk_plugin_install_method_finished_cb,
- self);
-
- pk_plugin_install_set_status (self, INSTALLING);
- pk_plugin_install_clear_layout (self);
- pk_plugin_install_refresh (self);
-}
-
-/**
- * pk_plugin_install_get_server_timestamp:
- **/
-static guint32
-pk_plugin_install_get_server_timestamp ()
-{
- GtkWidget *invisible = gtk_invisible_new ();
- GdkWindow *window;
- guint32 server_time;
-
- gtk_widget_realize (invisible);
- window = gtk_widget_get_window (invisible);
- server_time = gdk_x11_get_server_time (window);
- gtk_widget_destroy (invisible);
- return server_time;
-}
-
-/**
- * pk_plugin_install_run_application:
- **/
-static void
-pk_plugin_install_run_application (PkPluginInstall *self, Time event_time)
-{
- _cleanup_error_free_ GError *error = NULL;
- _cleanup_object_unref_ GdkAppLaunchContext *context = NULL;
-
- if (self->priv->app_info == 0) {
- g_warning ("Didn't find application to launch");
- return;
- }
-
- if (event_time == 0)
- event_time = pk_plugin_install_get_server_timestamp ();
-
- context = gdk_app_launch_context_new ();
- gdk_app_launch_context_set_timestamp (context, event_time);
- if (!g_app_info_launch (self->priv->app_info, NULL,
- G_APP_LAUNCH_CONTEXT (context), &error)) {
- g_warning ("%s", error->message);
- }
-}
-
-/**
- * pk_plugin_install_button_release:
- **/
-static gboolean
-pk_plugin_install_button_release (PkPlugin *plugin, gint x, gint y, Time event_time)
-{
- PkPluginInstall *self = PK_PLUGIN_INSTALL (plugin);
- gint idx = pk_plugin_install_get_link_index (self, x, y);
- if (idx < 0)
- return FALSE;
-
- switch (self->priv->status) {
- case IN_PROGRESS:
- case INSTALLING:
- case UNAVAILABLE:
- break;
- case INSTALLED:
- if (self->priv->app_info != NULL)
- pk_plugin_install_run_application (self, event_time);
- break;
- case UPGRADABLE:
- if (self->priv->app_info != NULL && idx == 0)
- pk_plugin_install_run_application (self, event_time);
- else
- pk_plugin_install_install_package (self, event_time);
- break;
- case AVAILABLE:
- if (self->priv->available_package_name != NULL)
- pk_plugin_install_install_package (self, event_time);
- break;
- }
- return TRUE;
-}
-
-static void
-pk_plugin_set_cursor (GdkWindow *window,
- GdkCursorType cursor)
-{
- Display *display;
- Cursor xcursor;
-
- display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default());
- if (cursor >= 0)
- xcursor = XCreateFontCursor (display, cursor);
- else
- xcursor = None;
- XDefineCursor (display, GDK_WINDOW_XID (window), xcursor);
-}
-
-static gboolean
-pk_plugin_install_motion (PkPlugin *plugin,
- gint x,
- gint y)
-{
- PkPluginInstall *self = PK_PLUGIN_INSTALL (plugin);
- GdkWindow *window;
- gint idx;
-
- idx = pk_plugin_install_get_link_index (self, x, y);
- g_object_get (plugin, "gdk-window", &window, NULL);
-
- if (idx < 0) {
- pk_plugin_set_cursor (window, -1);
- return FALSE;
- }
- switch (self->priv->status) {
- case IN_PROGRESS:
- case INSTALLING:
- case UNAVAILABLE:
- pk_plugin_set_cursor (window, -1);
- break;
- case INSTALLED:
- case UPGRADABLE:
- case AVAILABLE:
- pk_plugin_set_cursor (window, GDK_HAND2);
- break;
- }
- return FALSE;
-}
-
-/**
- * pk_plugin_install_finalize:
- **/
-static void
-pk_plugin_install_finalize (GObject *object)
-{
- PkPluginInstall *self;
- g_return_if_fail (PK_IS_PLUGIN_INSTALL (object));
- self = PK_PLUGIN_INSTALL (object);
-
- pk_plugin_install_clear_layout (self);
-
- if (self->priv->app_info != NULL)
- g_object_unref (self->priv->app_info);
-
- g_cancellable_cancel (self->priv->cancellable);
- g_object_unref (self->priv->session_pk_proxy);
-
- /* remove clients */
- g_object_unref (self->priv->client);
-
- G_OBJECT_CLASS (pk_plugin_install_parent_class)->finalize (object);
-}
-
-/**
- * pk_plugin_install_class_init:
- **/
-static void
-pk_plugin_install_class_init (PkPluginInstallClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- PkPluginClass *plugin_class = PK_PLUGIN_CLASS (klass);
-
- object_class->finalize = pk_plugin_install_finalize;
- plugin_class->start = pk_plugin_install_start;
- plugin_class->draw = pk_plugin_install_draw;
- plugin_class->button_release = pk_plugin_install_button_release;
- plugin_class->motion = pk_plugin_install_motion;
-
- g_type_class_add_private (klass, sizeof (PkPluginInstallPrivate));
-}
-
-/**
- * pk_plugin_install_init:
- **/
-static void
-pk_plugin_install_init (PkPluginInstall *self)
-{
- _cleanup_error_free_ GError *error = NULL;
- self->priv = PK_PLUGIN_INSTALL_GET_PRIVATE (self);
- self->priv->status = IN_PROGRESS;
- self->priv->client = pk_client_new ();
-
- /* connect early to allow the service to start */
- self->priv->session_pk_proxy =
- g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
- G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
- NULL,
- "org.freedesktop.PackageKit",
- "/org/freedesktop/PackageKit",
- "org.freedesktop.PackageKit.Modify",
- self->priv->cancellable,
- &error);
- if (self->priv->session_pk_proxy == NULL) {
- g_warning ("Error connecting to PK session instance: %s",
- error->message);
- }
-}
-
-/**
- * pk_plugin_install_new:
- **/
-PkPluginInstall *
-pk_plugin_install_new (void)
-{
- PkPluginInstall *self;
- self = g_object_new (PK_TYPE_PLUGIN_INSTALL, NULL);
- return PK_PLUGIN_INSTALL (self);
-}
diff --git a/contrib/browser-plugin/pk-plugin-install.h b/contrib/browser-plugin/pk-plugin-install.h
deleted file mode 100644
index 17a7327cc..000000000
--- a/contrib/browser-plugin/pk-plugin-install.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard@hughsie.com>
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __PK_PLUGIN_INSTALL_H
-#define __PK_PLUGIN_INSTALL_H
-
-#include <glib-object.h>
-#include <cairo-xlib.h>
-
-#include "pk-plugin.h"
-
-G_BEGIN_DECLS
-
-#define PK_TYPE_PLUGIN_INSTALL (pk_plugin_install_get_type ())
-#define PK_PLUGIN_INSTALL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_PLUGIN_INSTALL, PkPluginInstall))
-#define PK_PLUGIN_INSTALL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_PLUGIN_INSTALL, PkPluginInstallClass))
-#define PK_IS_PLUGIN_INSTALL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_PLUGIN_INSTALL))
-#define PK_IS_PLUGIN_INSTALL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_PLUGIN_INSTALL))
-#define PK_PLUGIN_INSTALL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_PLUGIN_INSTALL, PkPluginInstallClass))
-
-typedef struct PkPluginInstallPrivate PkPluginInstallPrivate;
-
-typedef struct
-{
- PkPlugin parent;
- PkPluginInstallPrivate *priv;
-} PkPluginInstall;
-
-typedef struct
-{
- PkPluginClass parent_class;
-} PkPluginInstallClass;
-
-GType pk_plugin_install_get_type (void);
-PkPluginInstall *pk_plugin_install_new (void);
-
-G_END_DECLS
-
-#endif /* __PK_PLUGIN_INSTALL_H */
diff --git a/contrib/browser-plugin/pk-plugin.c b/contrib/browser-plugin/pk-plugin.c
deleted file mode 100644
index 9fe7396af..000000000
--- a/contrib/browser-plugin/pk-plugin.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009-2014 Richard Hughes <richard@hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <config.h>
-
-#include <glib-object.h>
-#include <gtk/gtk.h>
-
-#include "pk-plugin.h"
-
-#define PK_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_PLUGIN, PkPluginPrivate))
-
-struct PkPluginPrivate
-{
- gboolean started;
- guint x;
- guint y;
- guint width;
- guint height;
- Display *display;
- Visual *visual;
- Window window;
- GdkWindow *gdk_window;
- GHashTable *data;
-};
-
-enum {
- SIGNAL_REFRESH,
- SIGNAL_LAST
-};
-
-enum {
- PROP_0,
- PROP_X,
- PROP_Y,
- PROP_WIDTH,
- PROP_HEIGHT,
- PROP_DISPLAY,
- PROP_VISUAL,
- PROP_STARTED,
- PROP_WINDOW,
- PROP_GDKWINDOW,
- PROP_LAST,
-};
-
-static guint signals [SIGNAL_LAST] = { 0 };
-
-G_DEFINE_TYPE (PkPlugin, pk_plugin, G_TYPE_OBJECT)
-
-/**
- * pk_plugin_set_data:
- **/
-gboolean
-pk_plugin_set_data (PkPlugin *plugin, const gchar *name, const gchar *value)
-{
- g_return_val_if_fail (PK_IS_PLUGIN (plugin), FALSE);
- g_return_val_if_fail (name != NULL, FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
-
- g_hash_table_insert (plugin->priv->data, g_strdup (name), g_strdup (value));
- g_debug ("SET: name=%s, value=%s <%p>", name, value, plugin);
-
- return TRUE;
-}
-
-/**
- * pk_plugin_get_data:
- **/
-const gchar *
-pk_plugin_get_data (PkPlugin *plugin, const gchar *name)
-{
- const gchar *value;
-
- g_return_val_if_fail (PK_IS_PLUGIN (plugin), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- value = g_hash_table_lookup (plugin->priv->data, name);
- g_debug ("GET: name=%s, value=%s <%p>", name, value, plugin);
-
- return value;
-}
-
-/**
- * pk_plugin_start:
- **/
-gboolean
-pk_plugin_start (PkPlugin *plugin)
-{
- PkPluginClass *klass = PK_PLUGIN_GET_CLASS (plugin);
-
- g_debug ("start <%p>", plugin);
-
- /* already started, don't restart */
- if (plugin->priv->started) {
- g_warning ("already started <%p>", plugin);
- return FALSE;
- }
-
- /* no support */
- if (klass->start == NULL)
- return FALSE;
- plugin->priv->started = klass->start (plugin);
- return plugin->priv->started;
-}
-
-/**
- * pk_plugin_draw:
- **/
-gboolean
-pk_plugin_draw (PkPlugin *plugin, cairo_t *cr)
-{
- PkPluginClass *klass = PK_PLUGIN_GET_CLASS (plugin);
-
- /* no support */
- if (klass->draw == NULL)
- return FALSE;
-
- g_debug ("draw on %p <%p>", cr, plugin);
-
- return klass->draw (plugin, cr);
-}
-
-/**
- * pk_plugin_button_press:
- **/
-gboolean
-pk_plugin_button_press (PkPlugin *plugin, gint x, gint y, Time event_time)
-{
- PkPluginClass *klass = PK_PLUGIN_GET_CLASS (plugin);
-
- /* no support */
- if (klass->button_press == NULL)
- return FALSE;
-
- g_debug ("button_press %i,%i <%p>", x, y, plugin);
-
- return klass->button_press (plugin, x, y, event_time);
-}
-
-/**
- * pk_plugin_button_release:
- **/
-gboolean
-pk_plugin_button_release (PkPlugin *plugin, gint x, gint y, Time event_time)
-{
- PkPluginClass *klass = PK_PLUGIN_GET_CLASS (plugin);
-
- /* no support */
- if (klass->button_release == NULL)
- return FALSE;
-
- g_debug ("button_release %i,%i <%p>", x, y, plugin);
-
- return klass->button_release (plugin, x, y, event_time);
-}
-
-/**
- * pk_plugin_motion:
- **/
-gboolean
-pk_plugin_motion (PkPlugin *plugin, gint x, gint y)
-{
- PkPluginClass *klass = PK_PLUGIN_GET_CLASS (plugin);
-
- /* no support */
- if (klass->motion == NULL)
- return FALSE;
-
- g_debug ("motion %i,%i <%p>", x, y, plugin);
-
- return klass->motion (plugin, x, y);
-}
-
-/**
- * pk_plugin_enter:
- **/
-gboolean
-pk_plugin_enter (PkPlugin *plugin, gint x, gint y)
-{
- PkPluginClass *klass = PK_PLUGIN_GET_CLASS (plugin);
-
- /* no support */
- if (klass->enter == NULL)
- return FALSE;
-
- g_debug ("enter %i,%i <%p>", x, y, plugin);
-
- return klass->enter (plugin, x, y);
-}
-
-/**
- * pk_plugin_leave:
- **/
-gboolean
-pk_plugin_leave (PkPlugin *plugin, gint x, gint y)
-{
- PkPluginClass *klass = PK_PLUGIN_GET_CLASS (plugin);
-
- /* no support */
- if (klass->leave == NULL)
- return FALSE;
-
- g_debug ("leave %i,%i <%p>", x, y, plugin);
-
- return klass->leave (plugin, x, y);
-}
-
-/**
- * pk_plugin_request_refresh:
- **/
-gboolean
-pk_plugin_request_refresh (PkPlugin *plugin)
-{
- g_return_val_if_fail (PK_IS_PLUGIN (plugin), FALSE);
-
- g_debug ("emit refresh <%p>", plugin);
-
- g_signal_emit (plugin, signals [SIGNAL_REFRESH], 0);
- return TRUE;
-}
-
-/**
- * pk_plugin_get_property:
- **/
-static void
-pk_plugin_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- PkPlugin *plugin = PK_PLUGIN (object);
- switch (prop_id) {
- case PROP_X:
- g_value_set_uint (value, plugin->priv->x);
- break;
- case PROP_Y:
- g_value_set_uint (value, plugin->priv->y);
- break;
- case PROP_WIDTH:
- g_value_set_uint (value, plugin->priv->width);
- break;
- case PROP_HEIGHT:
- g_value_set_uint (value, plugin->priv->height);
- break;
- case PROP_DISPLAY:
- g_value_set_pointer (value, plugin->priv->display);
- break;
- case PROP_VISUAL:
- g_value_set_pointer (value, plugin->priv->visual);
- break;
- case PROP_STARTED:
- g_value_set_boolean (value, plugin->priv->started);
- break;
- case PROP_WINDOW:
- g_value_set_ulong (value, plugin->priv->window);
- break;
- case PROP_GDKWINDOW:
- g_value_set_pointer (value, plugin->priv->gdk_window);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/**
- * pk_plugin_set_property:
- **/
-static void
-pk_plugin_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- PkPlugin *plugin = PK_PLUGIN (object);
- switch (prop_id) {
- case PROP_X:
- plugin->priv->x = g_value_get_uint (value);
- break;
- case PROP_Y:
- plugin->priv->y = g_value_get_uint (value);
- break;
- case PROP_WIDTH:
- plugin->priv->width = g_value_get_uint (value);
- break;
- case PROP_HEIGHT:
- plugin->priv->height = g_value_get_uint (value);
- break;
- case PROP_DISPLAY:
- plugin->priv->display = g_value_get_pointer (value);
- break;
- case PROP_VISUAL:
- plugin->priv->visual = g_value_get_pointer (value);
- break;
- case PROP_STARTED:
- plugin->priv->started = g_value_get_boolean (value);
- break;
- case PROP_WINDOW:
- plugin->priv->window = g_value_get_ulong (value);
- break;
- case PROP_GDKWINDOW:
- plugin->priv->gdk_window = g_value_get_pointer (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-/**
- * pk_plugin_finalize:
- **/
-static void
-pk_plugin_finalize (GObject *object)
-{
- PkPlugin *plugin;
- g_return_if_fail (PK_IS_PLUGIN (object));
- plugin = PK_PLUGIN (object);
-
- g_hash_table_unref (plugin->priv->data);
-
- G_OBJECT_CLASS (pk_plugin_parent_class)->finalize (object);
-}
-
-/**
- * pk_plugin_class_init:
- **/
-static void
-pk_plugin_class_init (PkPluginClass *klass)
-{
- GParamSpec *pspec;
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = pk_plugin_finalize;
- object_class->get_property = pk_plugin_get_property;
- object_class->set_property = pk_plugin_set_property;
-
- signals [SIGNAL_REFRESH] =
- g_signal_new ("refresh",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PkPluginClass, refresh),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- pspec = g_param_spec_uint ("x", NULL, NULL,
- 0, G_MAXUINT, 0,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_X, pspec);
-
- pspec = g_param_spec_uint ("y", NULL, NULL,
- 0, G_MAXUINT, 0,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_Y, pspec);
-
- pspec = g_param_spec_uint ("width", NULL, NULL,
- 0, G_MAXUINT, 0,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_WIDTH, pspec);
-
- pspec = g_param_spec_uint ("height", NULL, NULL,
- 0, G_MAXUINT, 0,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_HEIGHT, pspec);
-
- pspec = g_param_spec_pointer ("display", NULL, NULL,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_DISPLAY, pspec);
-
- pspec = g_param_spec_pointer ("visual", NULL, NULL,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_VISUAL, pspec);
-
- pspec = g_param_spec_boolean ("started", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_STARTED, pspec);
-
- pspec = g_param_spec_ulong ("window", NULL, NULL,
- 0, G_MAXULONG, 0,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_WINDOW, pspec);
-
- pspec = g_param_spec_pointer ("gdk-window", NULL, NULL,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_GDKWINDOW, pspec);
-
- g_type_class_add_private (klass, sizeof (PkPluginPrivate));
-}
-
-/**
- * pk_plugin_init:
- **/
-static void
-pk_plugin_init (PkPlugin *plugin)
-{
- plugin->priv = PK_PLUGIN_GET_PRIVATE (plugin);
- plugin->priv->started = FALSE;
- plugin->priv->x = 0;
- plugin->priv->y = 0;
- plugin->priv->width = 0;
- plugin->priv->height = 0;
- plugin->priv->display = NULL;
- plugin->priv->visual = NULL;
- plugin->priv->window = 0;
- plugin->priv->gdk_window = NULL;
- plugin->priv->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-}
-
-/**
- * pk_plugin_new:
- **/
-PkPlugin *
-pk_plugin_new (void)
-{
- PkPlugin *plugin;
- plugin = g_object_new (PK_TYPE_PLUGIN, NULL);
- return PK_PLUGIN (plugin);
-}
diff --git a/contrib/browser-plugin/pk-plugin.h b/contrib/browser-plugin/pk-plugin.h
deleted file mode 100644
index b9019f9c4..000000000
--- a/contrib/browser-plugin/pk-plugin.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard@hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __PK_PLUGIN_H
-#define __PK_PLUGIN_H
-
-#include <glib-object.h>
-#include <cairo-xlib.h>
-
-G_BEGIN_DECLS
-
-#define PK_TYPE_PLUGIN (pk_plugin_get_type ())
-#define PK_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_PLUGIN, PkPlugin))
-#define PK_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_PLUGIN, PkPluginClass))
-#define PK_IS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_PLUGIN))
-#define PK_IS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_PLUGIN))
-#define PK_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_PLUGIN, PkPluginClass))
-
-typedef struct PkPluginPrivate PkPluginPrivate;
-
-typedef struct
-{
- GObject parent;
- PkPluginPrivate *priv;
-} PkPlugin;
-
-typedef struct
-{
- GObjectClass parent_class;
- /* signals */
- void (*refresh) (PkPlugin *plugin);
-
- /* vtable */
- gboolean (*start) (PkPlugin *plugin);
- gboolean (*draw) (PkPlugin *plugin,
- cairo_t *cr);
- gboolean (*button_press) (PkPlugin *plugin,
- gint x,
- gint y,
- Time event_time);
- gboolean (*button_release) (PkPlugin *plugin,
- gint x,
- gint y,
- Time event_time);
- gboolean (*motion) (PkPlugin *plugin,
- gint x,
- gint y);
- gboolean (*enter) (PkPlugin *plugin,
- gint x,
- gint y);
- gboolean (*leave) (PkPlugin *plugin,
- gint x,
- gint y);
-} PkPluginClass;
-
-GType pk_plugin_get_type (void);
-PkPlugin *pk_plugin_new (void);
-gboolean pk_plugin_set_data (PkPlugin *plugin,
- const gchar *name,
- const gchar *value);
-const gchar *pk_plugin_get_data (PkPlugin *plugin,
- const gchar *name);
-gboolean pk_plugin_start (PkPlugin *plugin);
-gboolean pk_plugin_draw (PkPlugin *plugin,
- cairo_t *cr);
-gboolean pk_plugin_button_press (PkPlugin *plugin,
- gint x,
- gint y,
- Time event_time);
-gboolean pk_plugin_button_release (PkPlugin *plugin,
- gint x,
- gint y,
- Time event_time);
-gboolean pk_plugin_motion (PkPlugin *plugin,
- gint x,
- gint y);
-gboolean pk_plugin_enter (PkPlugin *plugin,
- gint x,
- gint y);
-gboolean pk_plugin_leave (PkPlugin *plugin,
- gint x,
- gint y);
-gboolean pk_plugin_request_refresh (PkPlugin *plugin);
-
-G_END_DECLS
-
-#endif /* __PK_PLUGIN_H */
diff --git a/contrib/browser-plugin/tests/test.html b/contrib/browser-plugin/tests/test.html
deleted file mode 100644
index 1d6b2bb48..000000000
--- a/contrib/browser-plugin/tests/test.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<html>
- <head>
- <title>Test for PackageKit Plugin</title>
- <style type="text/css">
- body {
- background: #ffeedd;
- }
-
- .packagekit-plugin {
- width: 30em;
- height: 5em;
- }
- </style>
- </head>
- <body>
- <object type="application/x-packagekit-plugin" width="500" height="200" class="packagekit-plugin">
- <param name="packagenames" value="firefox mozilla-firefox"/>
- <param name="radius" value="10"/>
- <param name="color" value="#aeaeff"/>
- </object>
- <br/><br/>
- <object type="application/x-packagekit-plugin" width="500" height="200" class="packagekit-plugin">
- <param name="displayname" value="KStars"/>
- <param name="packagenames" value="kdeedu"/>
- <param name="radius" value="5"/>
- <param name="color" value="#ffaeff"/>
- </object>
- <br/><br/>
- <object type="application/x-packagekit-plugin" width="500" height="200" class="packagekit-plugin">
- <param name="displayname" value="GNU Backgammon"/>
- <param name="packagenames" value="gnubg"/>
- </object>
- <br/><br/>
- <object type="application/x-packagekit-plugin" width="500" height="200" class="packagekit-plugin">
- <param name="displayname" value="NotGoingToExist"/>
- <param name="packagenames" value="notgoingtoexist"/>
- </object>
- <br/><br/>
- <object type="application/x-packagekit-plugin" width="500" height="200" class="packagekit-plugin">
- <param name="displayname" value="FSpot"/>
- <param name="packagenames" value="f-spot"/>
- </object>
- </body>
-</html>
-