[PackageKit-commit] packagekit: Branch 'master' - 10 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Mon Dec 8 14:18:43 PST 2008
configure.ac | 2
contrib/Makefile.am | 2
contrib/browser-plugin/.gitignore | 25
contrib/browser-plugin/Makefile.am | 28
contrib/browser-plugin/README | 152 ++++
contrib/browser-plugin/sdk/np_entry.cpp | 320 +++++++++
contrib/browser-plugin/sdk/npn_gate.cpp | 215 ++++++
contrib/browser-plugin/sdk/npp_gate.cpp | 358 ++++++++++
contrib/browser-plugin/sdk/npplat.h | 150 ++++
contrib/browser-plugin/sdk/pluginbase.h | 96 ++
contrib/browser-plugin/src/contents.cpp | 800 +++++++++++++++++++++++
contrib/browser-plugin/src/contents.h | 126 +++
contrib/browser-plugin/src/plugin.cpp | 297 ++++++++
contrib/browser-plugin/src/plugin.h | 81 ++
contrib/browser-plugin/tests/test.html | 41 +
contrib/command-not-found/CommandNotFound.conf | 2
contrib/command-not-found/pk-command-not-found.c | 100 ++
contrib/packagekit-plugin/.gitignore | 25
contrib/packagekit-plugin/Makefile.am | 28
contrib/packagekit-plugin/README | 152 ----
contrib/packagekit-plugin/sdk/np_entry.cpp | 320 ---------
contrib/packagekit-plugin/sdk/npn_gate.cpp | 215 ------
contrib/packagekit-plugin/sdk/npp_gate.cpp | 358 ----------
contrib/packagekit-plugin/sdk/npplat.h | 150 ----
contrib/packagekit-plugin/sdk/pluginbase.h | 96 --
contrib/packagekit-plugin/src/contents.cpp | 800 -----------------------
contrib/packagekit-plugin/src/contents.h | 126 ---
contrib/packagekit-plugin/src/plugin.cpp | 297 --------
contrib/packagekit-plugin/src/plugin.h | 81 --
contrib/packagekit-plugin/tests/test.html | 41 -
data/20packagekit | 2
data/org.freedesktop.PackageKit.conf.in | 2
po/POTFILES.in | 2
33 files changed, 2796 insertions(+), 2694 deletions(-)
New commits:
commit c1daf6f4fe5404b1241a30315687d1d4751b3efb
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Dec 8 22:02:14 2008 +0000
bugfix: allow all clients to send to all interfaces of the server. Fixes DBus introspection.
diff --git a/data/org.freedesktop.PackageKit.conf.in b/data/org.freedesktop.PackageKit.conf.in
index 3bc91b8..3c5ec48 100644
--- a/data/org.freedesktop.PackageKit.conf.in
+++ b/data/org.freedesktop.PackageKit.conf.in
@@ -15,6 +15,7 @@
<policy context="default">
<allow send_interface="org.freedesktop.PackageKit"/>
<allow send_interface="org.freedesktop.PackageKit.Transaction"/>
+ <allow send_destination="org.freedesktop.PackageKit"/>
</policy>
</busconfig>
commit bcb71d2de23bc8167ae6eb7e26b8a4def1821bca
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Dec 8 16:05:31 2008 +0000
trivial: fix make check
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7c24197..9887fec 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,7 +6,7 @@ client/pk-generate-pack.c
client/pk-monitor.c
client/pk-tools-common.c
contrib/command-not-found/pk-command-not-found.c
-contrib/packagekit-plugin/src/contents.cpp
+contrib/browser-plugin/src/contents.cpp
data/packagekit-catalog.xml.in
data/packagekit-package-list.xml.in
data/packagekit-servicepack.xml.in
commit 27859373fb199c3df953b0c9f3c84b7b7a66719a
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Dec 8 15:39:26 2008 +0000
trivial: rename packagekit-plugin to browser-plugin in the source tree. no code changes
diff --git a/configure.ac b/configure.ac
index ad4c9ee..f78e27c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -599,7 +599,7 @@ docs/api/Makefile
docs/api/dbus/Makefile
docs/api/version.xml
contrib/Makefile
-contrib/packagekit-plugin/Makefile
+contrib/browser-plugin/Makefile
contrib/gstreamer-plugin/Makefile
contrib/gtk-module/Makefile
contrib/udev/Makefile
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index b0e7879..8326ced 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -5,7 +5,7 @@ SUBDIRS += yum-packagekit
endif
if PK_BUILD_BROWSER_PLUGIN
-SUBDIRS += packagekit-plugin
+SUBDIRS += browser-plugin
endif
if PK_BUILD_GSTREAMER_PLUGIN
diff --git a/contrib/browser-plugin/.gitignore b/contrib/browser-plugin/.gitignore
new file mode 100644
index 0000000..7ec02d6
--- /dev/null
+++ b/contrib/browser-plugin/.gitignore
@@ -0,0 +1,25 @@
+\COPYING
+INSTALL
+LIBS
+aclocal.m4
+autom4te.cache
+config.*
+configure
+depcomp
+install-sh
+intltool-*
+libtool
+ltmain.sh
+missing
+Makefile
+Makefile.in
+stamp-h1
+.deps
+.libs
+*.lo
+*.o
+*.la
+po/Makefile*
+po/POTFILES
+po/stamp-it
+
diff --git a/contrib/browser-plugin/Makefile.am b/contrib/browser-plugin/Makefile.am
new file mode 100644
index 0000000..40fdd09
--- /dev/null
+++ b/contrib/browser-plugin/Makefile.am
@@ -0,0 +1,28 @@
+plugindir=$(libdir)/mozilla/plugins
+plugin_LTLIBRARIES = packagekit-plugin.la
+
+packagekit_plugin_la_LDFLAGS = -rpath $(plugindir) -module -avoid-version -no-undefined
+packagekit_plugin_la_CPPFLAGS = \
+ $(PK_BROWSER_PLUGIN_CFLAGS) \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ -I$(top_srcdir)/lib \
+ -I$(srcdir)/sdk
+
+packagekit_plugin_la_LIBADD = \
+ $(PK_BROWSER_PLUGIN_LIBS) \
+ $(top_builddir)/lib/packagekit-glib/libpackagekit-glib.la
+
+packagekit_plugin_la_SOURCES = \
+ sdk/np_entry.cpp \
+ sdk/npn_gate.cpp \
+ sdk/npp_gate.cpp \
+ sdk/npplat.h \
+ sdk/pluginbase.h \
+ \
+ src/contents.cpp \
+ src/contents.h \
+ src/plugin.cpp \
+ src/plugin.h
+
+EXTRA_DIST = \
+ tests/test.html
diff --git a/contrib/browser-plugin/README b/contrib/browser-plugin/README
new file mode 100644
index 0000000..3a5b901
--- /dev/null
+++ b/contrib/browser-plugin/README
@@ -0,0 +1,152 @@
+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"/>
+ <!-- List of basenames of possible desktop files (no .desktop extension) -->
+ <param name="desktopnames" value="gnubg fedora-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.
+
+License and Copyright
+=====================
+
+You may distribute the code under the terms of the Mozilla Public License 1.1,
+GNU General Public License Version 2 or later (the "GPL"), or the
+GNU Lesser General Public License Version 2.1 or later (the "LGPL"). See the
+source files for details and for copyright information.
+
+The plugin infrastructure (The sdk/ directory and much of src/plugin.cpp
+and src/plugin.h) is derived from the Mozilla plugin SDK; other code under
+src/ is new code written by Red Hat, Inc.
+
+Owen Taylor <otaylor at redhat.com>
+July 24, 2008
+
diff --git a/contrib/browser-plugin/sdk/np_entry.cpp b/contrib/browser-plugin/sdk/np_entry.cpp
new file mode 100644
index 0000000..05323e9
--- /dev/null
+++ b/contrib/browser-plugin/sdk/np_entry.cpp
@@ -0,0 +1,320 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+//////////////////////////////////////////////////////////////
+//
+// Main plugin entry point implementation -- exports from the
+// plugin library
+//
+#include "npplat.h"
+#include "pluginbase.h"
+
+NPNetscapeFuncs NPNFuncs;
+
+NPError OSCALL NP_Shutdown()
+{
+ NS_PluginShutdown();
+ return NPERR_NO_ERROR;
+}
+
+static NPError fillPluginFunctionTable(NPPluginFuncs* aNPPFuncs)
+{
+ if(aNPPFuncs == NULL)
+ return NPERR_INVALID_FUNCTABLE_ERROR;
+
+ // Set up the plugin function table that Netscape will use to
+ // call us. Netscape needs to know about our version and size
+ // and have a UniversalProcPointer for every function we implement.
+
+ aNPPFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
+#ifdef XP_MAC
+ aNPPFuncs->newp = NewNPP_NewProc(Private_New);
+ aNPPFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
+ aNPPFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
+ aNPPFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
+ aNPPFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
+ aNPPFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
+ aNPPFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
+ aNPPFuncs->write = NewNPP_WriteProc(Private_Write);
+ aNPPFuncs->print = NewNPP_PrintProc(Private_Print);
+ aNPPFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent);
+ aNPPFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
+ aNPPFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue);
+ aNPPFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue);
+#else
+ aNPPFuncs->newp = NPP_New;
+ aNPPFuncs->destroy = NPP_Destroy;
+ aNPPFuncs->setwindow = NPP_SetWindow;
+ aNPPFuncs->newstream = NPP_NewStream;
+ aNPPFuncs->destroystream = NPP_DestroyStream;
+ aNPPFuncs->asfile = NPP_StreamAsFile;
+ aNPPFuncs->writeready = NPP_WriteReady;
+ aNPPFuncs->write = NPP_Write;
+ aNPPFuncs->print = NPP_Print;
+ aNPPFuncs->event = NPP_HandleEvent;
+ aNPPFuncs->urlnotify = NPP_URLNotify;
+ aNPPFuncs->getvalue = NPP_GetValue;
+ aNPPFuncs->setvalue = NPP_SetValue;
+#endif
+#ifdef OJI
+ aNPPFuncs->javaClass = NULL;
+#endif
+
+ return NPERR_NO_ERROR;
+}
+
+static NPError fillNetscapeFunctionTable(NPNetscapeFuncs* aNPNFuncs)
+{
+ if(aNPNFuncs == NULL)
+ return NPERR_INVALID_FUNCTABLE_ERROR;
+
+ if(HIBYTE(aNPNFuncs->version) > NP_VERSION_MAJOR)
+ return NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ if(aNPNFuncs->size < sizeof(NPNetscapeFuncs))
+ return NPERR_INVALID_FUNCTABLE_ERROR;
+
+ NPNFuncs.size = aNPNFuncs->size;
+ NPNFuncs.version = aNPNFuncs->version;
+ NPNFuncs.geturlnotify = aNPNFuncs->geturlnotify;
+ NPNFuncs.geturl = aNPNFuncs->geturl;
+ NPNFuncs.posturlnotify = aNPNFuncs->posturlnotify;
+ NPNFuncs.posturl = aNPNFuncs->posturl;
+ NPNFuncs.requestread = aNPNFuncs->requestread;
+ NPNFuncs.newstream = aNPNFuncs->newstream;
+ NPNFuncs.write = aNPNFuncs->write;
+ NPNFuncs.destroystream = aNPNFuncs->destroystream;
+ NPNFuncs.status = aNPNFuncs->status;
+ NPNFuncs.uagent = aNPNFuncs->uagent;
+ NPNFuncs.memalloc = aNPNFuncs->memalloc;
+ NPNFuncs.memfree = aNPNFuncs->memfree;
+ NPNFuncs.memflush = aNPNFuncs->memflush;
+ NPNFuncs.reloadplugins = aNPNFuncs->reloadplugins;
+#ifdef OJI
+ NPNFuncs.getJavaEnv = aNPNFuncs->getJavaEnv;
+ NPNFuncs.getJavaPeer = aNPNFuncs->getJavaPeer;
+#endif
+ NPNFuncs.getvalue = aNPNFuncs->getvalue;
+ NPNFuncs.setvalue = aNPNFuncs->setvalue;
+ NPNFuncs.invalidaterect = aNPNFuncs->invalidaterect;
+ NPNFuncs.invalidateregion = aNPNFuncs->invalidateregion;
+ NPNFuncs.forceredraw = aNPNFuncs->forceredraw;
+
+ return NPERR_NO_ERROR;
+}
+
+//
+// Some exports are different on different platforms
+//
+
+/**************************************************/
+/* */
+/* Windows */
+/* */
+/**************************************************/
+#ifdef XP_WIN
+
+NPError OSCALL NP_Initialize(NPNetscapeFuncs* aNPNFuncs)
+{
+ NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
+ if(rv != NPERR_NO_ERROR)
+ return rv;
+
+ return NS_PluginInitialize();
+}
+
+NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* aNPPFuncs)
+{
+ return fillPluginFunctionTable(aNPPFuncs);
+}
+
+#endif //XP_WIN
+
+/**************************************************/
+/* */
+/* Unix */
+/* */
+/**************************************************/
+#ifdef XP_UNIX
+
+NPError NP_Initialize(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs)
+{
+ NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
+ if(rv != NPERR_NO_ERROR)
+ return rv;
+
+ rv = fillPluginFunctionTable(aNPPFuncs);
+ if(rv != NPERR_NO_ERROR)
+ return rv;
+
+ return NS_PluginInitialize();
+}
+
+char * NP_GetMIMEDescription(void)
+{
+ return NPP_GetMIMEDescription();
+}
+
+NPError NP_GetValue(void *future, NPPVariable aVariable, void *aValue)
+{
+ return NS_PluginGetValue(aVariable, aValue);
+}
+
+#endif //XP_UNIX
+
+/**************************************************/
+/* */
+/* Mac */
+/* */
+/**************************************************/
+#ifdef XP_MAC
+
+#if !TARGET_API_MAC_CARBON
+QDGlobals* gQDPtr; // Pointer to Netscape's QuickDraw globals
+#endif
+
+short gResFile; // Refnum of the plugin's resource file
+
+NPError Private_Initialize(void)
+{
+ NPError rv = NS_PluginInitialize();
+ return rv;
+}
+
+void Private_Shutdown(void)
+{
+ NS_PluginShutdown();
+ __destroy_global_chain();
+}
+
+void SetUpQD(void);
+
+void SetUpQD(void)
+{
+ ProcessSerialNumber PSN;
+ FSSpec myFSSpec;
+ Str63 name;
+ ProcessInfoRec infoRec;
+ OSErr result = noErr;
+ CFragConnectionID connID;
+ Str255 errName;
+
+ // Memorize the plugin¹s resource file refnum for later use.
+ gResFile = CurResFile();
+
+#if !TARGET_API_MAC_CARBON
+ // Ask the system if CFM is available.
+ long response;
+ OSErr err = Gestalt(gestaltCFMAttr, &response);
+ Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
+
+ if (hasCFM) {
+ // GetProcessInformation takes a process serial number and
+ // will give us back the name and FSSpec of the application.
+ // See the Process Manager in IM.
+ infoRec.processInfoLength = sizeof(ProcessInfoRec);
+ infoRec.processName = name;
+ infoRec.processAppSpec = &myFSSpec;
+
+ PSN.highLongOfPSN = 0;
+ PSN.lowLongOfPSN = kCurrentProcess;
+
+ result = GetProcessInformation(&PSN, &infoRec);
+ }
+ else
+ // If no CFM installed, assume it must be a 68K app.
+ result = -1;
+
+ if (result == noErr) {
+ // Now that we know the app name and FSSpec, we can call GetDiskFragment
+ // to get a connID to use in a subsequent call to FindSymbol (it will also
+ // return the address of ³main² in app, which we ignore). If GetDiskFragment
+ // returns an error, we assume the app must be 68K.
+ Ptr mainAddr;
+ result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
+ kReferenceCFrag, &connID, (Ptr*)&mainAddr, errName);
+ }
+
+ if (result == noErr) {
+ // The app is a PPC code fragment, so call FindSymbol
+ // to get the exported ³qd² symbol so we can access its
+ // QuickDraw globals.
+ CFragSymbolClass symClass;
+ result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
+ }
+ else {
+ // The app is 68K, so use its A5 to compute the address
+ // of its QuickDraw globals.
+ gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
+ }
+#endif /* !TARGET_API_MAC_CARBON */
+}
+
+NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
+
+#if !TARGET_API_MAC_CARBON
+#pragma export on
+#if GENERATINGCFM
+RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
+#endif
+#pragma export off
+#endif /* !TARGET_API_MAC_CARBON */
+
+
+NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownUPP* aUnloadUpp)
+{
+ NPError rv = NPERR_NO_ERROR;
+
+ if (aUnloadUpp == NULL)
+ rv = NPERR_INVALID_FUNCTABLE_ERROR;
+
+ if (rv == NPERR_NO_ERROR)
+ rv = fillNetscapeFunctionTable(aNPNFuncs);
+
+ if (rv == NPERR_NO_ERROR) {
+ // defer static constructors until the global functions are initialized.
+ __InitCode__();
+ rv = fillPluginFunctionTable(aNPPFuncs);
+ }
+
+ *aUnloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
+ SetUpQD();
+ rv = Private_Initialize();
+
+ return rv;
+}
+#endif //XP_MAC
diff --git a/contrib/browser-plugin/sdk/npn_gate.cpp b/contrib/browser-plugin/sdk/npn_gate.cpp
new file mode 100644
index 0000000..f5caa32
--- /dev/null
+++ b/contrib/browser-plugin/sdk/npn_gate.cpp
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+////////////////////////////////////////////////////////////
+//
+// Implementation of Netscape entry points (NPN_*)
+//
+#include "npplat.h"
+
+extern NPNetscapeFuncs NPNFuncs;
+
+void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
+{
+ *plugin_major = NP_VERSION_MAJOR;
+ *plugin_minor = NP_VERSION_MINOR;
+ *netscape_major = HIBYTE(NPNFuncs.version);
+ *netscape_minor = LOBYTE(NPNFuncs.version);
+}
+
+NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
+{
+ int navMinorVers = NPNFuncs.version & 0xFF;
+ NPError rv = NPERR_NO_ERROR;
+
+ if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
+ rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target, notifyData);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ return rv;
+}
+
+NPError NPN_GetURL(NPP instance, const char *url, const char *target)
+{
+ NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target);
+ return rv;
+}
+
+NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
+{
+ int navMinorVers = NPNFuncs.version & 0xFF;
+ NPError rv = NPERR_NO_ERROR;
+
+ if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
+ rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ return rv;
+}
+
+NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
+{
+ NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len, buf, file);
+ return rv;
+}
+
+NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
+{
+ NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList);
+ return rv;
+}
+
+NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
+{
+ int navMinorVersion = NPNFuncs.version & 0xFF;
+
+ NPError rv = NPERR_NO_ERROR;
+
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
+ rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, stream);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ return rv;
+}
+
+int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
+{
+ int navMinorVersion = NPNFuncs.version & 0xFF;
+ int32 rv = 0;
+
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
+ rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer);
+ else
+ rv = -1;
+
+ return rv;
+}
+
+NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
+{
+ int navMinorVersion = NPNFuncs.version & 0xFF;
+ NPError rv = NPERR_NO_ERROR;
+
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
+ rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, reason);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ return rv;
+}
+
+void NPN_Status(NPP instance, const char *message)
+{
+ CallNPN_StatusProc(NPNFuncs.status, instance, message);
+}
+
+const char* NPN_UserAgent(NPP instance)
+{
+ const char * rv = NULL;
+ rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance);
+ return rv;
+}
+
+void* NPN_MemAlloc(uint32 size)
+{
+ void * rv = NULL;
+ rv = CallNPN_MemAllocProc(NPNFuncs.memalloc, size);
+ return rv;
+}
+
+void NPN_MemFree(void* ptr)
+{
+ CallNPN_MemFreeProc(NPNFuncs.memfree, ptr);
+}
+
+uint32 NPN_MemFlush(uint32 size)
+{
+ uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size);
+ return rv;
+}
+
+void NPN_ReloadPlugins(NPBool reloadPages)
+{
+ CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages);
+}
+
+#ifdef OJI
+JRIEnv* NPN_GetJavaEnv(void)
+{
+ JRIEnv * rv = NULL;
+ rv = CallNPN_GetJavaEnvProc(NPNFuncs.getJavaEnv);
+ return rv;
+}
+
+jref NPN_GetJavaPeer(NPP instance)
+{
+ jref rv;
+ rv = CallNPN_GetJavaPeerProc(NPNFuncs.getJavaPeer, instance);
+ return rv;
+}
+#endif
+
+NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
+{
+ NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value);
+ return rv;
+}
+
+NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
+{
+ NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value);
+ return rv;
+}
+
+void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
+{
+ CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect);
+}
+
+void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
+{
+ CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegion);
+}
+
+void NPN_ForceRedraw(NPP instance)
+{
+ CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance);
+}
diff --git a/contrib/browser-plugin/sdk/npp_gate.cpp b/contrib/browser-plugin/sdk/npp_gate.cpp
new file mode 100644
index 0000000..3e22783
--- /dev/null
+++ b/contrib/browser-plugin/sdk/npp_gate.cpp
@@ -0,0 +1,358 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+////////////////////////////////////////////////////////////
+//
+// Implementation of plugin entry points (NPP_*)
+//
+#include "pluginbase.h"
+
+// here the plugin creates a plugin instance object which
+// will be associated with this newly created NPP instance and
+// will do all the necessary job
+NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
+{
+ if(instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ NPError rv = NPERR_NO_ERROR;
+
+ // create a new plugin instance object
+ // initialization will be done when the associated window is ready
+ nsPluginCreateData ds;
+
+ ds.instance = instance;
+ ds.type = pluginType;
+ ds.mode = mode;
+ ds.argc = argc;
+ ds.argn = argn;
+ ds.argv = argv;
+ ds.saved = saved;
+
+ nsPluginInstanceBase * plugin = NS_NewPluginInstance(&ds);
+ if(plugin == NULL)
+ return NPERR_OUT_OF_MEMORY_ERROR;
+
+ // associate the plugin instance object with NPP instance
+ instance->pdata = (void *)plugin;
+ return rv;
+}
+
+// here is the place to clean up and destroy the nsPluginInstance object
+NPError NPP_Destroy (NPP instance, NPSavedData** save)
+{
+ if(instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ NPError rv = NPERR_NO_ERROR;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin != NULL) {
+ plugin->shut();
+ NS_DestroyPluginInstance(plugin);
+ }
+ return rv;
+}
+
+// during this call we know when the plugin window is ready or
+// is about to be destroyed so we can do some gui specific
+// initialization and shutdown
+NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
+{
+ if(instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ NPError rv = NPERR_NO_ERROR;
+
+ if(pNPWindow == NULL)
+ return NPERR_GENERIC_ERROR;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+
+ if(plugin == NULL)
+ return NPERR_GENERIC_ERROR;
+
+ // window just created
+ if(!plugin->isInitialized() && (pNPWindow->window != NULL)) {
+ if(!plugin->init(pNPWindow)) {
+ NS_DestroyPluginInstance(plugin);
+ return NPERR_MODULE_LOAD_FAILED_ERROR;
+ }
+ }
+
+ // window goes away
+ if((pNPWindow->window == NULL) && plugin->isInitialized())
+ return plugin->SetWindow(pNPWindow);
+
+ // window resized?
+ if(plugin->isInitialized() && (pNPWindow->window != NULL))
+ return plugin->SetWindow(pNPWindow);
+
+ // this should not happen, nothing to do
+ if((pNPWindow->window == NULL) && !plugin->isInitialized())
+ return plugin->SetWindow(pNPWindow);
+
+ return rv;
+}
+
+NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
+{
+ if(instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return NPERR_GENERIC_ERROR;
+
+ NPError rv = plugin->NewStream(type, stream, seekable, stype);
+ return rv;
+}
+
+int32 NPP_WriteReady (NPP instance, NPStream *stream)
+{
+ if(instance == NULL)
+ return 0x0fffffff;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return 0x0fffffff;
+
+ int32 rv = plugin->WriteReady(stream);
+ return rv;
+}
+
+int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
+{
+ if(instance == NULL)
+ return len;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return len;
+
+ int32 rv = plugin->Write(stream, offset, len, buffer);
+ return rv;
+}
+
+NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
+{
+ if(instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return NPERR_GENERIC_ERROR;
+
+ NPError rv = plugin->DestroyStream(stream, reason);
+ return rv;
+}
+
+void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname)
+{
+ if(instance == NULL)
+ return;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return;
+
+ plugin->StreamAsFile(stream, fname);
+}
+
+void NPP_Print (NPP instance, NPPrint* printInfo)
+{
+ if(instance == NULL)
+ return;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return;
+
+ plugin->Print(printInfo);
+}
+
+void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
+{
+ if(instance == NULL)
+ return;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return;
+
+ plugin->URLNotify(url, reason, notifyData);
+}
+
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
+{
+ if(instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return NPERR_GENERIC_ERROR;
+
+ NPError rv = plugin->GetValue(variable, value);
+ return rv;
+}
+
+NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
+{
+ if(instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return NPERR_GENERIC_ERROR;
+
+ NPError rv = plugin->SetValue(variable, value);
+ return rv;
+}
+
+int16 NPP_HandleEvent(NPP instance, void* event)
+{
+ if(instance == NULL)
+ return 0;
+
+ nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
+ if(plugin == NULL)
+ return 0;
+
+ uint16 rv = plugin->HandleEvent(event);
+ return rv;
+}
+
+#ifdef OJI
+jref NPP_GetJavaClass (void)
+{
+ return NULL;
+}
+#endif
+
+/**************************************************/
+/* */
+/* Mac */
+/* */
+/**************************************************/
+
+// Mac needs these wrappers, see npplat.h for more info
+
+#ifdef XP_MAC
+
+NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
+{
+ NPError rv = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
+ return rv;
+}
+
+NPError Private_Destroy(NPP instance, NPSavedData** save)
+{
+ NPError rv = NPP_Destroy(instance, save);
+ return rv;
+}
+
+NPError Private_SetWindow(NPP instance, NPWindow* window)
+{
+ NPError rv = NPP_SetWindow(instance, window);
+ return rv;
+}
+
+NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
+{
+ NPError rv = NPP_NewStream(instance, type, stream, seekable, stype);
+ return rv;
+}
+
+int32 Private_WriteReady(NPP instance, NPStream* stream)
+{
+ int32 rv = NPP_WriteReady(instance, stream);
+ return rv;
+}
+
+int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
+{
+ int32 rv = NPP_Write(instance, stream, offset, len, buffer);
+ return rv;
+}
+
+void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
+{
+ NPP_StreamAsFile(instance, stream, fname);
+}
+
+
+NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
+{
+ NPError rv = NPP_DestroyStream(instance, stream, reason);
+ return rv;
+}
+
+int16 Private_HandleEvent(NPP instance, void* event)
+{
+ int16 rv = NPP_HandleEvent(instance, event);
+ return rv;
+}
+
+void Private_Print(NPP instance, NPPrint* platformPrint)
+{
+ NPP_Print(instance, platformPrint);
+}
+
+void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
+{
+ NPP_URLNotify(instance, url, reason, notifyData);
+}
+
+jref Private_GetJavaClass(void)
+{
+ return NULL;
+}
+
+NPError Private_GetValue(NPP instance, NPPVariable variable, void *result)
+{
+ NPError rv = NPP_GetValue(instance, variable, result);
+ return rv;
+}
+
+NPError Private_SetValue(NPP instance, NPNVariable variable, void *value)
+{
+ NPError rv = NPP_SetValue(instance, variable, value);
+ return rv;
+}
+
+#endif //XP_MAC
diff --git a/contrib/browser-plugin/sdk/npplat.h b/contrib/browser-plugin/sdk/npplat.h
new file mode 100644
index 0000000..637ac36
--- /dev/null
+++ b/contrib/browser-plugin/sdk/npplat.h
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _NPPLAT_H_
+#define _NPPLAT_H_
+
+#include "npapi.h"
+#include "npupp.h"
+
+/**************************************************/
+/* */
+/* Windows */
+/* */
+/**************************************************/
+#ifdef XP_WIN
+#include "windows.h"
+#endif //XP_WIN
+
+/**************************************************/
+/* */
+/* Unix */
+/* */
+/**************************************************/
+#ifdef XP_UNIX
+#include <stdio.h>
+#endif //XP_UNIX
+
+/**************************************************/
+/* */
+/* Mac */
+/* */
+/**************************************************/
+#ifdef XP_MAC
+
+#include <Processes.h>
+#include <Gestalt.h>
+#include <CodeFragments.h>
+#include <Timer.h>
+#include <Resources.h>
+#include <ToolUtils.h>
+
+#include "jri.h"
+
+// The Mixed Mode procInfos defined in npupp.h assume Think C-
+// style calling conventions. These conventions are used by
+// Metrowerks with the exception of pointer return types, which
+// in Metrowerks 68K are returned in A0, instead of the standard
+// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
+// Mixed Mode will return the values to a 68K plugin in D0, but
+// a 68K plugin compiled by Metrowerks will expect the result in
+// A0. The following pragma forces Metrowerks to use D0 instead.
+//
+#ifdef __MWERKS__
+#ifndef powerc
+#pragma pointers_in_D0
+#endif
+#endif
+
+#ifdef __MWERKS__
+#ifndef powerc
+#pragma pointers_in_A0
+#endif
+#endif
+
+// The following fix for static initializers (which fixes a preious
+// incompatibility with some parts of PowerPlant, was submitted by
+// Jan Ulbrich.
+#ifdef __MWERKS__
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ #ifndef powerc
+ extern void __InitCode__(void);
+ #else
+ extern void __sinit(void);
+ #define __InitCode__ __sinit
+ #endif
+ extern void __destroy_global_chain(void);
+ #ifdef __cplusplus
+ }
+ #endif // __cplusplus
+#endif // __MWERKS__
+
+// Wrapper functions for all calls from Netscape to the plugin.
+// These functions let the plugin developer just create the APIs
+// as documented and defined in npapi.h, without needing to
+// install those functions in the function table or worry about
+// setting up globals for 68K plugins.
+NPError Private_Initialize(void);
+void Private_Shutdown(void);
+NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
+NPError Private_Destroy(NPP instance, NPSavedData** save);
+NPError Private_SetWindow(NPP instance, NPWindow* window);
+NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
+NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
+int32 Private_WriteReady(NPP instance, NPStream* stream);
+int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
+void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
+void Private_Print(NPP instance, NPPrint* platformPrint);
+int16 Private_HandleEvent(NPP instance, void* event);
+void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
+jref Private_GetJavaClass(void);
+NPError Private_GetValue(NPP instance, NPPVariable variable, void *result);
+NPError Private_SetValue(NPP instance, NPNVariable variable, void *value);
+
+#endif //XP_MAC
+
+#ifndef HIBYTE
+#define HIBYTE(i) (i >> 8)
+#endif
+
+#ifndef LOBYTE
+#define LOBYTE(i) (i & 0xff)
+#endif
+
+#endif //_NPPLAT_H_
diff --git a/contrib/browser-plugin/sdk/pluginbase.h b/contrib/browser-plugin/sdk/pluginbase.h
new file mode 100644
index 0000000..b7e3327
--- /dev/null
+++ b/contrib/browser-plugin/sdk/pluginbase.h
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef __PLUGININSTANCEBASE_H__
+#define __PLUGININSTANCEBASE_H__
+
+#include "npplat.h"
+
+struct nsPluginCreateData
+{
+ NPP instance;
+ NPMIMEType type;
+ uint16 mode;
+ int16 argc;
+ char** argn;
+ char** argv;
+ NPSavedData* saved;
+};
+
+class nsPluginInstanceBase
+{
+public:
+ // these three methods must be implemented in the derived
+ // class platform specific way
+ virtual NPBool init(NPWindow* aWindow) = 0;
+ virtual void shut() = 0;
+ virtual NPBool isInitialized() = 0;
+
+ // implement all or part of those methods in the derived
+ // class as needed
+ virtual NPError SetWindow(NPWindow* pNPWindow) { return NPERR_NO_ERROR; }
+ virtual NPError NewStream(NPMIMEType type, NPStream* stream,
+ NPBool seekable, uint16* stype) { return NPERR_NO_ERROR; }
+ virtual NPError DestroyStream(NPStream *stream, NPError reason) { return NPERR_NO_ERROR; }
+ virtual void StreamAsFile(NPStream* stream, const char* fname) { return; }
+ virtual int32 WriteReady(NPStream *stream) { return 0x0fffffff; }
+ virtual int32 Write(NPStream *stream, int32 offset,
+ int32 len, void *buffer) { return len; }
+ virtual void Print(NPPrint* printInfo) { return; }
+ virtual uint16 HandleEvent(void* event) { return 0; }
+ virtual void URLNotify(const char* url, NPReason reason,
+ void* notifyData) { return; }
+ virtual NPError GetValue(NPPVariable variable, void *value) { return NPERR_NO_ERROR; }
+ virtual NPError SetValue(NPNVariable variable, void *value) { return NPERR_NO_ERROR; }
+};
+
+// functions that should be implemented for each specific plugin
+
+// creation and destruction of the object of the derived class
+nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct);
+void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin);
+
+// global plugin initialization and shutdown
+NPError NS_PluginInitialize();
+void NS_PluginShutdown();
+
+#ifdef XP_UNIX
+// global to get plugins name & description
+NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue);
+#endif
+
+#endif // __PLUGININSTANCEBASE_H__
diff --git a/contrib/browser-plugin/src/contents.cpp b/contrib/browser-plugin/src/contents.cpp
new file mode 100644
index 0000000..39a3515
--- /dev/null
+++ b/contrib/browser-plugin/src/contents.cpp
@@ -0,0 +1,800 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is packagekit-plugin code.
+ *
+ * The Initial Developer of the Original Code is
+ * Red Hat, Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#define MOZ_X11
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib/gi18n-lib.h>
+
+#include <cairo-xlib.h>
+#include <dlfcn.h>
+#include <pango/pangocairo.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <gio/gdesktopappinfo.h>
+#include <packagekit-glib/packagekit.h>
+
+#include "plugin.h"
+
+#define MARGIN 5
+
+#if !GTK_CHECK_VERSION(2,14,0)
+#define GTK_ICON_LOOKUP_FORCE_SIZE (GtkIconLookupFlags) 0
+#endif
+
+////////////////////////////////////////
+//
+// PkpContents class implementation
+//
+
+static std::vector<std::string>
+splitString(const gchar *str)
+{
+ std::vector<std::string> v;
+
+ if (str) {
+ char **split = g_strsplit(str, " ", -1);
+ for (char **s = split; *s; s++) {
+ char *stripped = strdup(*s);
+ g_strstrip(stripped);
+ v.push_back(stripped);
+ g_free(stripped);
+ }
+
+ g_strfreev(split);
+ }
+
+ return v;
+}
+
+PkpContents::PkpContents(const gchar *displayName, const gchar *packageNames) :
+ mPlugin(0),
+ mStatus(IN_PROGRESS),
+ mAppInfo(0),
+ mDisplayName(displayName),
+ mPackageNames(splitString(packageNames)),
+ mLayout(0),
+ mInstallPackageProxy(0),
+ mInstallPackageCall(0)
+{
+ recheck();
+}
+
+PkpContents::~PkpContents()
+{
+ clearLayout();
+
+ if (mAppInfo != 0) {
+ g_object_unref(mAppInfo);
+ mAppInfo = 0;
+ }
+
+ if (mInstallPackageCall != 0) {
+ dbus_g_proxy_cancel_call(mInstallPackageProxy, mInstallPackageCall);
+ g_object_unref(mInstallPackageProxy);
+ mInstallPackageProxy = 0;
+ mInstallPackageCall = 0;
+ }
+
+ while (!mClients.empty())
+ removeClient(mClients.front());
+}
+
+void PkpContents::recheck()
+{
+ mStatus = IN_PROGRESS;
+ mAvailableVersion = "";
+ mAvailablePackageName = "";
+ mInstalledPackageName = "";
+
+ for (std::vector<std::string>::iterator i = mPackageNames.begin(); i != mPackageNames.end(); i++) {
+ GError *error = NULL;
+ PkClient *client = pk_client_new();
+ gchar **package_ids;
+ package_ids = pk_package_ids_from_id (i->c_str());
+ if (!pk_client_resolve(client, PK_FILTER_ENUM_NONE, package_ids, &error)) {
+ g_warning("%s", error->message);
+ g_clear_error(&error);
+ g_object_unref(client);
+ } else {
+ g_signal_connect(client, "package", G_CALLBACK(onClientPackage), this);
+ g_signal_connect(client, "error-code", G_CALLBACK(onClientErrorCode), this);
+ g_signal_connect(client, "finished", G_CALLBACK(onClientFinished), this);
+ mClients.push_back(client);
+ }
+ g_strfreev (package_ids);
+ }
+
+ if (mClients.empty() && getStatus() == IN_PROGRESS)
+ setStatus(UNAVAILABLE);
+}
+
+void PkpContents::removeClient(PkClient *client)
+{
+ for (std::vector<PkClient *>::iterator i = mClients.begin(); i != mClients.end(); i++) {
+ if (*i == client) {
+ mClients.erase(i);
+ g_signal_handlers_disconnect_by_func(client, (void *)onClientPackage, this);
+ g_signal_handlers_disconnect_by_func(client, (void *)onClientErrorCode, this);
+ g_signal_handlers_disconnect_by_func(client, (void *)onClientFinished, this);
+ g_object_unref(client);
+ break;
+ }
+ }
+
+ if (mClients.empty()) {
+ if (getStatus() == IN_PROGRESS)
+ setStatus(UNAVAILABLE);
+ }
+}
+
+void
+PkpContents::setStatus(PackageStatus status)
+{
+ if (mStatus != status) {
+ mStatus = status;
+ clearLayout();
+ refresh();
+ }
+}
+
+void
+PkpContents::setAvailableVersion(const gchar *version)
+{
+ mAvailableVersion = version;
+ clearLayout();
+ refresh();
+}
+
+void
+PkpContents::setAvailablePackageName(const gchar *name)
+{
+ mAvailablePackageName = name;
+}
+
+void
+PkpContents::setInstalledPackageName(const gchar *name)
+{
+ mInstalledPackageName = name;
+}
+
+void
+PkpContents::setInstalledVersion(const gchar *version)
+{
+ mInstalledVersion = version;
+ clearLayout();
+ refresh();
+}
+
+void
+PkpContents::clearLayout()
+{
+ if (mLayout) {
+ g_object_unref(mLayout);
+ mLayout = 0;
+ }
+}
+
+static void
+append_markup(GString *str, const gchar *format, ...)
+{
+ va_list vap;
+
+ va_start(vap, format);
+ char *tmp = g_markup_vprintf_escaped(format, vap);
+ va_end(vap);
+
+ g_string_append(str, tmp);
+ g_free(tmp);
+}
+
+static guint32
+rgba_from_gdk_color(GdkColor *color)
+{
+ return (((color->red >> 8) << 24) |
+ ((color->green >> 8) << 16) |
+ ((color->blue >> 8) << 8) |
+ 0xff);
+}
+
+static void
+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.);
+
+}
+
+/* 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
+get_style(PangoFontDescription **font_desc, guint32 *foreground, guint32 *background, guint32 *link)
+{
+ GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+ gtk_widget_ensure_style(window);
+
+ *foreground = rgba_from_gdk_color(&window->style->text[GTK_STATE_NORMAL]);
+ *background = rgba_from_gdk_color(&window->style->base[GTK_STATE_NORMAL]);
+
+ GdkColor link_color = { 0, 0, 0, 0xeeee };
+ GdkColor *tmp = NULL;
+
+ gtk_widget_style_get (GTK_WIDGET (window), "link-color", &tmp, NULL);
+ if (tmp != NULL) {
+ link_color = *tmp;
+ gdk_color_free(tmp);
+ }
+
+ *link = rgba_from_gdk_color(&link_color);
+
+ *font_desc = pango_font_description_copy(window->style->font_desc);
+
+ gtk_widget_destroy(window);
+}
+
+void
+PkpContents::ensureLayout(cairo_t *cr, PangoFontDescription *font_desc, guint32 link_color)
+{
+ GString *markup = g_string_new(NULL);
+
+ if (mLayout)
+ return;
+
+ mLayout = pango_cairo_create_layout(cr);
+ pango_layout_set_font_description(mLayout, font_desc);
+
+ /* WARNING: Any changes to what links are created here will require corresponding
+ * changes to the buttonRelease() method
+ */
+ switch (mStatus) {
+ case IN_PROGRESS:
+ /* TRANSLATORS: when we are getting data from the daemon */
+ append_markup(markup, _("Getting package information..."));
+ break;
+ case INSTALLED:
+ if (mAppInfo != 0) {
+ append_markup(markup, "<span color='#%06x' underline='single'>", link_color >> 8);
+ /* TRANSLATORS: run an applicaiton */
+ append_markup(markup, _("Run %s"), mDisplayName.c_str());
+ append_markup(markup, "</span>");
+ } else
+ append_markup(markup, "<big>%s</big>", mDisplayName.c_str());
+ if (!mInstalledVersion.empty())
+ /* TRANSLATORS: show the installed version of a package */
+ append_markup(markup, "\n<small>%s: %s</small>", _("Installed version"), mInstalledVersion.c_str());
+ break;
+ case UPGRADABLE:
+ append_markup(markup, "<big>%s</big>", mDisplayName.c_str());
+ if (mAppInfo != 0) {
+ if (!mInstalledVersion.empty()) {
+ append_markup(markup, "\n<span color='#%06x' underline='single'>", link_color >> 8);
+ /* TRANSLATORS: run the application now */
+ append_markup(markup, _("Run version %s now"), mInstalledVersion.c_str());
+ append_markup(markup, "</span>");
+ } else {
+ /* TRANSLATORS: run the application now */
+ append_markup(markup,
+ "\n<span color='#%06x' underline='single'>%s</span>",
+ _("Run now"), link_color >> 8);
+ }
+ }
+
+ append_markup(markup, "\n<span color='#%06x' underline='single'>", link_color >> 8);
+ /* TRANSLATORS: update to a new version of the package */
+ append_markup(markup, _("Update to version %s"), mAvailableVersion.c_str());
+ append_markup(markup, "</span>");
+ break;
+ case AVAILABLE:
+ append_markup(markup, "<span color='#%06x' underline='single'>", link_color >> 8);
+ /* TRANSLATORS: To install a package */
+ append_markup(markup, _("Install %s now"), mDisplayName.c_str());
+ append_markup(markup, "</span>");
+ /* TRANSLATORS: the version of the package */
+ append_markup(markup, "\n<small>%s: %s</small>", _("Version"), mAvailableVersion.c_str());
+ break;
+ case UNAVAILABLE:
+ append_markup(markup, "<big>%s</big>", mDisplayName.c_str());
+ /* TRANSLATORS: noting found, so can't install */
+ append_markup(markup, "\n<small>%s</small>", _("No packages found for your system"));
+ break;
+ case INSTALLING:
+ append_markup(markup, "<big>%s</big>", mDisplayName.c_str());
+ /* TRANSLATORS: package is being installed */
+ append_markup(markup, "\n<small>%s</small>", _("Installing..."));
+ break;
+ }
+
+ pango_layout_set_markup(mLayout, markup->str, -1);
+ g_string_free(markup, TRUE);
+}
+
+void
+PkpContents::refresh()
+{
+ if (mPlugin != 0)
+ mPlugin->refresh();
+}
+
+void
+PkpContents::setPlugin(PkpPluginInstance *plugin)
+{
+ mPlugin = plugin;
+}
+
+gchar *
+PkpContents::getBestDesktopFile()
+{
+ GPtrArray *array = NULL;
+ PkDesktop *desktop;
+ gboolean ret;
+ gchar *data = NULL;
+ const gchar *package;
+
+ /* open desktop database */
+ desktop = pk_desktop_new();
+ ret = pk_desktop_open_database(desktop, NULL);
+ if (!ret)
+ goto out;
+
+ /* get files */
+ package = mInstalledPackageName.c_str();
+ array = pk_desktop_get_shown_for_package(desktop, package, NULL);
+ if (array == NULL)
+ goto out;
+ if (array->len == 0)
+ goto out;
+
+ /* just use the first entry */
+ data = g_strdup((const gchar*) g_ptr_array_index(array, 0));
+
+out:
+ if (array != NULL) {
+ g_ptr_array_foreach(array, (GFunc) g_free, NULL);
+ g_ptr_array_free (array, TRUE);
+ }
+ g_object_unref(desktop);
+ return data;
+}
+
+gchar *
+PkpContents::getPackageIcon()
+{
+ gboolean ret;
+ GKeyFile *file;
+ gchar *data = NULL;
+ const gchar *filename;
+
+ /* get data from the best file */
+ file = g_key_file_new();
+ filename = getBestDesktopFile();
+ if (filename == NULL)
+ goto out;
+
+ ret = g_key_file_load_from_file(file, filename, G_KEY_FILE_NONE, NULL);
+ if (!ret) {
+ g_warning("failed to open %s", filename);
+ goto out;
+ }
+ data = g_key_file_get_string(file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
+ g_key_file_free(file);
+out:
+ return data;
+}
+
+void
+PkpContents::draw(cairo_t *cr)
+{
+ guint32 foreground, background, link;
+ PangoFontDescription *font_desc;
+ guint x = mPlugin->getX();
+ guint y = mPlugin->getY();
+ cairo_surface_t *surface = NULL;
+ const gchar *filename;
+ GtkIconTheme *theme;
+ GdkPixbuf *pixbuf;
+
+ /* get properties */
+ get_style(&font_desc, &foreground, &background, &link);
+
+ /* fill background */
+ set_source_from_rgba(cr, background);
+ cairo_rectangle(cr, x, y, mPlugin->getWidth(), mPlugin->getHeight());
+ cairo_fill(cr);
+
+ /* grey outline */
+ cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
+ cairo_rectangle(cr, x + 0.5, y + 0.5, mPlugin->getWidth() - 1, mPlugin->getHeight() - 1);
+ cairo_set_line_width(cr, 1);
+ cairo_stroke(cr);
+
+
+ /* get themed icon */
+ filename = getPackageIcon();
+ if (filename == NULL)
+ filename = "package-x-generic";
+ theme = gtk_icon_theme_get_default();
+ pixbuf = gtk_icon_theme_load_icon(theme, filename, 48, GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
+ if (pixbuf == NULL)
+ goto skip;
+ gdk_cairo_set_source_pixbuf(cr, pixbuf, x + MARGIN, y + MARGIN);
+ cairo_rectangle(cr, x + MARGIN, y + MARGIN, 48, 48);
+ cairo_fill(cr);
+ cairo_surface_destroy(surface);
+ g_object_unref(pixbuf);
+
+skip:
+ /* write text */
+ ensureLayout(cr, font_desc, link);
+ cairo_move_to(cr,(x + MARGIN*2) + 48, y + MARGIN + MARGIN);
+ set_source_from_rgba(cr, foreground);
+ pango_cairo_show_layout(cr, mLayout);
+}
+
+/* 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
+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 *link = g_slist_find(lines, line);
+ if (!link) {
+ g_warning("Can't find line in layout line list\n");
+ return FALSE;
+ }
+
+ if (link->next) {
+ PangoLayoutLine *next_line = (PangoLayoutLine *)link->next->data;
+ if (next_line->is_paragraph_start)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* 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.
+ */
+int
+PkpContents::getLinkIndex(int x, int y)
+{
+ /* Coordinates are relative to origin of plugin (different from drawing) */
+
+ if (!mLayout)
+ return -1;
+
+ x -= (MARGIN * 2) + 48;
+ y -= (MARGIN * 2);
+
+ int index;
+ int trailing;
+ if (!pango_layout_xy_to_index(mLayout, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing))
+ return - 1;
+
+ PangoLayoutIter *iter = pango_layout_get_iter(mLayout);
+ int seen_links = 0;
+ bool in_link = false;
+ int result = -1;
+
+ while (TRUE) {
+ PangoLayoutRun *run = pango_layout_iter_get_run(iter);
+ if (run) {
+ PangoItem *item = run->item;
+ PangoUnderline uline = PANGO_UNDERLINE_NONE;
+
+ for (GSList *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 <= index && index < 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 (line_is_terminated(iter))
+ in_link = FALSE;
+ }
+
+ if (!pango_layout_iter_next_run (iter))
+ break;
+ }
+
+ pango_layout_iter_free(iter);
+
+ return result;
+}
+
+void
+PkpContents::buttonPress(int x, int y, Time time)
+{
+}
+
+void
+PkpContents::buttonRelease(int x, int y, Time time)
+{
+ int index = getLinkIndex(x, y);
+ if (index < 0)
+ return;
+
+ switch (mStatus) {
+ case IN_PROGRESS:
+ case INSTALLING:
+ case UNAVAILABLE:
+ break;
+ case INSTALLED:
+ if (mAppInfo != 0)
+ runApplication(time);
+ break;
+ case UPGRADABLE:
+ if (mAppInfo != 0 && index == 0)
+ runApplication(time);
+ else
+ installPackage(time);
+ break;
+ case AVAILABLE:
+ if (!mAvailablePackageName.empty())
+ installPackage(time);
+ break;
+ }
+}
+
+void
+PkpContents::motion(int x, int y)
+{
+}
+
+void
+PkpContents::enter(int x, int y)
+{
+}
+
+void
+PkpContents::leave(int x, int y)
+{
+}
+
+static guint32
+get_server_timestamp()
+{
+ GtkWidget *invisible = gtk_invisible_new();
+ gtk_widget_realize(invisible);
+ return gdk_x11_get_server_time(invisible->window);
+ gtk_widget_destroy(invisible);
+}
+
+void
+PkpContents::runApplication (Time time)
+{
+ GError *error = NULL;
+#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
+ GdkAppLaunchContext *context;
+#endif
+
+ if (mAppInfo == 0) {
+ g_warning("Didn't find application to launch");
+ return;
+ }
+
+ if (time == 0)
+ time = get_server_timestamp();
+
+#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
+ context = gdk_app_launch_context_new();
+ gdk_app_launch_context_set_timestamp(context, time);
+ if (!g_app_info_launch(mAppInfo, NULL, G_APP_LAUNCH_CONTEXT (context), &error)) {
+#else
+ if (!g_app_info_launch(mAppInfo, NULL, NULL, &error)) {
+#endif
+ g_warning("%s\n", error->message);
+ g_clear_error(&error);
+ return;
+ }
+
+#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
+ if (context != NULL)
+ g_object_unref(context);
+#endif
+}
+
+void
+PkpContents::installPackage (Time time)
+{
+ GdkEvent *event;
+ GdkWindow *window;
+ guint xid = 0;
+
+ if (mAvailablePackageName.empty()) {
+ g_warning("No available package to install");
+ return;
+ }
+
+ if (mInstallPackageCall != 0) {
+ g_warning("Already installing package");
+ return;
+ }
+
+ /* Get a proxy to the *session* PackageKit service */
+ DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ mInstallPackageProxy = dbus_g_proxy_new_for_name(connection,
+ "org.freedesktop.PackageKit",
+ "/org/freedesktop/PackageKit",
+ "org.freedesktop.PackageKit");
+
+ /* 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);
+ }
+
+ mInstallPackageCall = dbus_g_proxy_begin_call_with_timeout(mInstallPackageProxy,
+ "InstallPackageName",
+ onInstallPackageFinished,
+ this,
+ (GDestroyNotify)0,
+ 24 * 60 * 1000 * 1000, /* one day */
+ G_TYPE_UINT, xid, /* xid */
+ G_TYPE_UINT, 0, /* timespec */
+ G_TYPE_STRING, mAvailablePackageName.c_str(),
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ setStatus(INSTALLING);
+}
+
+void
+PkpContents::onClientPackage(PkClient *client, const PkPackageObj *obj, PkpContents *contents)
+{
+ gchar *filename;
+
+ /* if we didn't use displayname, use the summary */
+ if (contents->mDisplayName.size() == 0)
+ contents->mDisplayName = obj->summary;
+
+ /* parse the data */
+ if (obj->info == PK_INFO_ENUM_AVAILABLE) {
+ if (contents->getStatus() == IN_PROGRESS)
+ contents->setStatus(AVAILABLE);
+ else if (contents->getStatus() == INSTALLED)
+ contents->setStatus(UPGRADABLE);
+ contents->setAvailableVersion(obj->id->version);
+ contents->setAvailablePackageName(obj->id->name);
+
+#if 0
+ /* if we have data from the repo, override the user:
+ * * we don't want the remote site pretending to install another package
+ * * it might be localised if the backend supports it */
+ if (obj->summary != NULL && obj->summary[0] != '\0')
+ contents->mDisplayName = obj->summary;
+#endif
+
+ } else if (obj->info == PK_INFO_ENUM_INSTALLED) {
+ if (contents->getStatus() == IN_PROGRESS)
+ contents->setStatus(INSTALLED);
+ else if (contents->getStatus() == AVAILABLE)
+ contents->setStatus(UPGRADABLE);
+ contents->setInstalledVersion(obj->id->version);
+ contents->setInstalledPackageName(obj->id->name);
+
+ /* get desktop file information */
+ filename = contents->getBestDesktopFile();
+ if (filename != NULL) {
+ contents->mAppInfo = G_APP_INFO(g_desktop_app_info_new_from_filename(filename));
+#if 0
+ /* override, as this will have translation */
+ contents->mDisplayName = g_app_info_get_name(contents->mAppInfo);
+#endif
+ }
+ g_free(filename);
+
+ if (contents->mAppInfo != 0)
+ contents->setStatus(INSTALLED);
+ }
+}
+
+void
+PkpContents::onClientErrorCode(PkClient *client, PkErrorCodeEnum code, const gchar *details, PkpContents *contents)
+{
+ g_warning("Error getting data from PackageKit: %s\n", details);
+ contents->removeClient(client);
+}
+
+void
+PkpContents::onClientFinished(PkClient *client, PkExitEnum exit, guint runtime, PkpContents *contents)
+{
+ contents->removeClient(client);
+}
+
+void
+PkpContents::onInstallPackageFinished (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ PkpContents *contents = (PkpContents *)user_data;
+
+ GError *error = NULL;
+ if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID)) {
+ g_warning("Error occurred during install: %s", error->message);
+ g_clear_error(&error);
+ }
+
+ g_object_unref(contents->mInstallPackageProxy);
+ contents->mInstallPackageProxy = 0;
+ contents->mInstallPackageCall = 0;
+
+ contents->recheck();
+}
diff --git a/contrib/browser-plugin/src/contents.h b/contrib/browser-plugin/src/contents.h
new file mode 100644
index 0000000..40d45c8
--- /dev/null
+++ b/contrib/browser-plugin/src/contents.h
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is packagekit-plugin code.
+ *
+ * The Initial Developer of the Original Code is
+ * Red Hat, Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+#ifndef __CONTENTS_H__
+#define __CONTENTS_H__
+
+#include <X11/Xlib.h>
+#include <gio/gio.h>
+#include <pango/pango.h>
+#include <packagekit-glib/packagekit.h>
+#include <cairo.h>
+#include <dbus/dbus-glib.h>
+#include <gtk/gtk.h>
+
+#include <string>
+#include <vector>
+
+class PkpPluginInstance;
+
+enum PackageStatus {
+ 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 */
+};
+
+class PkpContents
+{
+public:
+ PkpContents(const gchar *displayName, const gchar *packageNames);
+ virtual ~PkpContents();
+
+ void setPlugin(PkpPluginInstance *plugin);
+
+ void draw(cairo_t *cr);
+ void buttonPress(int x, int y, Time time);
+ void buttonRelease(int x, int y, Time time);
+ void motion(int x, int y);
+ void enter(int x, int y);
+ void leave(int x, int y);
+
+private:
+ void recheck();
+ void findAppInfo();
+ void runApplication(Time time);
+ void installPackage(Time time);
+
+ int getLinkIndex(int x, int y);
+
+ void setStatus(PackageStatus status);
+ PackageStatus getStatus() { return mStatus; }
+ void setAvailableVersion(const gchar *version);
+ void setAvailablePackageName(const gchar *name);
+ void setInstalledVersion(const gchar *version);
+ void setInstalledPackageName(const gchar *name);
+
+ void ensureLayout(cairo_t *cr, PangoFontDescription *font_desc, guint32 link_color);
+ void clearLayout();
+ void refresh();
+ gchar *getPackageIcon();
+ gchar *getBestDesktopFile();
+
+ void removeClient(PkClient *client);
+
+ static void onClientPackage(PkClient *client, const PkPackageObj *obj, PkpContents *contents);
+ static void onClientErrorCode(PkClient *client, PkErrorCodeEnum code, const gchar *details, PkpContents *contents);
+ static void onClientFinished(PkClient *client, PkExitEnum exit, guint runtime, PkpContents *contents);
+ static void onInstallPackageFinished(DBusGProxy *proxy, DBusGProxyCall *call, void *user_data);
+
+ PkpPluginInstance *mPlugin;
+ PackageStatus mStatus;
+ std::string mAvailableVersion;
+ std::string mAvailablePackageName;
+ std::string mInstalledVersion;
+ std::string mInstalledPackageName;
+ GAppInfo *mAppInfo;
+
+ std::string mDisplayName;
+ std::vector<std::string> mPackageNames;
+
+ PangoLayout *mLayout;
+
+ std::vector<PkClient *> mClients;
+
+ DBusGProxy *mInstallPackageProxy;
+ DBusGProxyCall *mInstallPackageCall;
+};
+
+#endif // __CONTENTS_H__
diff --git a/contrib/browser-plugin/src/plugin.cpp b/contrib/browser-plugin/src/plugin.cpp
new file mode 100644
index 0000000..d842b94
--- /dev/null
+++ b/contrib/browser-plugin/src/plugin.cpp
@@ -0,0 +1,297 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Red Hat, Inc.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#define MOZ_X11
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib/gi18n-lib.h>
+
+#include <cairo-xlib.h>
+#include <dlfcn.h>
+
+#include "plugin.h"
+
+#define MIME_TYPES_HANDLED "application/x-packagekit-plugin"
+#define PLUGIN_NAME "Plugin for Installing Applications"
+#define MIME_TYPES_DESCRIPTION MIME_TYPES_HANDLED":bsc:"PLUGIN_NAME
+#define PLUGIN_DESCRIPTION PLUGIN_NAME
+
+char* NPP_GetMIMEDescription(void)
+{
+ return (char *)(MIME_TYPES_DESCRIPTION);
+}
+
+static void *module_handle = 0;
+
+/////////////////////////////////////
+// general initialization and shutdown
+//
+
+/* 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
+make_module_resident()
+{
+ Dl_info info;
+
+ /* Get the (absolute) filename of this module */
+ if (!dladdr((void *)NPP_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;
+ }
+
+ /* the module will never be closed */
+}
+
+NPError NS_PluginInitialize()
+{
+ if (module_handle != 0) /* Already initialized */
+ return NPERR_NO_ERROR;
+
+ make_module_resident();
+
+#ifdef ENABLE_NLS
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+
+ return NPERR_NO_ERROR;
+}
+
+void NS_PluginShutdown()
+{
+}
+
+// get values per plugin
+NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue)
+{
+ NPError err = NPERR_NO_ERROR;
+ switch (aVariable) {
+ case NPPVpluginNameString:
+ *((char **)aValue) = (char *)PLUGIN_NAME;
+ break;
+ case NPPVpluginDescriptionString:
+ *((char **)aValue) = (char *)PLUGIN_DESCRIPTION;
+ break;
+ default:
+ err = NPERR_INVALID_PARAM;
+ break;
+ }
+ return err;
+}
+
+/////////////////////////////////////////////////////////////
+//
+// construction and destruction of our plugin instance object
+//
+nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct)
+{
+ const gchar *displayName = "";
+ const gchar *packageNames = NULL;
+
+ if(!aCreateDataStruct)
+ return NULL;
+
+ for (int i = 0; i < aCreateDataStruct->argc; i++) {
+ if (strcmp(aCreateDataStruct->argn[i], "displayname") == 0)
+ displayName = aCreateDataStruct->argv[i];
+ else if (strcmp(aCreateDataStruct->argn[i], "packagenames") == 0)
+ packageNames = aCreateDataStruct->argv[i];
+ }
+
+ PkpPluginInstance * plugin = new PkpPluginInstance(aCreateDataStruct->instance, displayName, packageNames);
+
+ NPN_SetValue(aCreateDataStruct->instance, NPPVpluginWindowBool, (void *)FALSE);
+
+ return plugin;
+}
+
+void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin)
+{
+ if(aPlugin)
+ delete (PkpPluginInstance *)aPlugin;
+}
+
+////////////////////////////////////////
+//
+// nsPluginInstance class implementation
+//
+
+PkpPluginInstance::PkpPluginInstance(NPP aInstance, const gchar *displayName, const gchar *packageNames) :
+ nsPluginInstanceBase(),
+ mInstance(aInstance),
+ mInitialized(FALSE),
+ mContents(displayName, packageNames),
+ mWindow(0)
+{
+ mContents.setPlugin(this);
+}
+
+PkpPluginInstance::~PkpPluginInstance()
+{
+}
+
+NPBool PkpPluginInstance::init(NPWindow* aWindow)
+{
+ if(aWindow == NULL)
+ return FALSE;
+
+ if (SetWindow(aWindow))
+ mInitialized = TRUE;
+
+ return mInitialized;
+}
+
+void PkpPluginInstance::shut()
+{
+ mInitialized = FALSE;
+}
+
+NPError PkpPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
+{
+ NPError err = NPERR_NO_ERROR;
+ switch (aVariable) {
+ case NPPVpluginNameString:
+ case NPPVpluginDescriptionString:
+ return NS_PluginGetValue(aVariable, aValue) ;
+ break;
+ default:
+ err = NPERR_INVALID_PARAM;
+ break;
+ }
+ return err;
+
+}
+
+NPError PkpPluginInstance::SetWindow(NPWindow* aWindow)
+{
+ if (aWindow == NULL)
+ return FALSE;
+
+ mX = aWindow->x;
+ mY = aWindow->y;
+ mWidth = aWindow->width;
+ mHeight = aWindow->height;
+
+ mWindow = (Window) aWindow->window;
+ NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct *)aWindow->ws_info;
+ mDisplay = ws_info->display;
+ mVisual = ws_info->visual;
+ mDepth = ws_info->depth;
+ mColormap = ws_info->colormap;
+
+ return NPERR_NO_ERROR;
+}
+
+void
+PkpPluginInstance::refresh()
+{
+ NPRect rect;
+
+ /* Coordinates here are relative to the plugin's origin (mX,mY) */
+
+ rect.left = 0;
+ rect.right = mWidth;
+ rect.top = 0;
+ rect.bottom = mHeight;
+
+ NPN_InvalidateRect(mInstance, &rect);
+}
+
+uint16
+PkpPluginInstance::HandleEvent(void *event)
+{
+ XEvent *xev = (XEvent *)event;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ XButtonEvent *xbe;
+ XGraphicsExposeEvent *xge;
+ XMotionEvent *xme;
+ XCrossingEvent *xce;
+
+ switch (xev->xany.type) {
+ case GraphicsExpose:
+ xge = (XGraphicsExposeEvent *)event;
+ surface = cairo_xlib_surface_create (mDisplay, xge->drawable, mVisual, mX + mWidth, mY + mHeight);
+ cr = cairo_create(surface);
+ cairo_rectangle(cr, xge->x, xge->y, xge->width, xge->height);
+ cairo_clip(cr);
+ mContents.draw(cr);
+ cairo_destroy(cr);
+ cairo_surface_destroy(surface);
+ return 1;
+ case ButtonPress:
+ xbe = (XButtonEvent *)event;
+ mContents.buttonPress(xbe->x, xbe->y, xbe->time);
+ return 1;
+ case ButtonRelease:
+ xbe = (XButtonEvent *)event;
+ mContents.buttonRelease(xbe->x, xbe->y, xbe->time);
+ return 1;
+ case MotionNotify:
+ xme = (XMotionEvent *)event;
+ mContents.motion(xme->x, xme->y);
+ return 1;
+ case EnterNotify:
+ xce = (XCrossingEvent *)event;
+ mContents.enter(xce->x, xce->y);
+ return 1;
+ case LeaveNotify:
+ xce = (XCrossingEvent *)event;
+ mContents.leave(xce->x, xce->y);
+ return 1;
+ }
+ return 0;
+}
diff --git a/contrib/browser-plugin/src/plugin.h b/contrib/browser-plugin/src/plugin.h
new file mode 100644
index 0000000..ded4b69
--- /dev/null
+++ b/contrib/browser-plugin/src/plugin.h
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef __PLUGIN_H__
+#define __PLUGIN_H__
+
+#include <X11/Xlib.h>
+
+#include "contents.h"
+#include "pluginbase.h"
+
+class PkpPluginInstance : public nsPluginInstanceBase
+{
+public:
+ PkpPluginInstance(NPP aInstance, const gchar *displayName, const gchar *packageNames);
+ virtual ~PkpPluginInstance();
+
+ NPBool init(NPWindow* aWindow);
+ void shut();
+ NPBool isInitialized() {return mInitialized;}
+ NPError GetValue(NPPVariable variable, void *value);
+ NPError SetWindow(NPWindow* aWindow);
+ uint16 HandleEvent(void *event);
+
+ void refresh();
+
+ int getX() { return mX; }
+ int getY() { return mY; }
+ int getWidth() { return mWidth; }
+ int getHeight() { return mHeight; }
+
+private:
+ NPP mInstance;
+ NPBool mInitialized;
+
+ PkpContents mContents;
+
+ Window mWindow;
+ Display *mDisplay;
+ int mX, mY;
+ int mWidth, mHeight;
+ Visual* mVisual;
+ Colormap mColormap;
+ unsigned int mDepth;
+};
+
+#endif // __PLUGIN_H__
diff --git a/contrib/browser-plugin/tests/test.html b/contrib/browser-plugin/tests/test.html
new file mode 100644
index 0000000..24766ac
--- /dev/null
+++ b/contrib/browser-plugin/tests/test.html
@@ -0,0 +1,41 @@
+<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"/>
+ </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"/>
+ </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>
+
diff --git a/contrib/packagekit-plugin/.gitignore b/contrib/packagekit-plugin/.gitignore
deleted file mode 100644
index 7ec02d6..0000000
--- a/contrib/packagekit-plugin/.gitignore
+++ /dev/null
@@ -1,25 +0,0 @@
-\COPYING
-INSTALL
-LIBS
-aclocal.m4
-autom4te.cache
-config.*
-configure
-depcomp
-install-sh
-intltool-*
-libtool
-ltmain.sh
-missing
-Makefile
-Makefile.in
-stamp-h1
-.deps
-.libs
-*.lo
-*.o
-*.la
-po/Makefile*
-po/POTFILES
-po/stamp-it
-
diff --git a/contrib/packagekit-plugin/Makefile.am b/contrib/packagekit-plugin/Makefile.am
deleted file mode 100644
index 40fdd09..0000000
--- a/contrib/packagekit-plugin/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-plugindir=$(libdir)/mozilla/plugins
-plugin_LTLIBRARIES = packagekit-plugin.la
-
-packagekit_plugin_la_LDFLAGS = -rpath $(plugindir) -module -avoid-version -no-undefined
-packagekit_plugin_la_CPPFLAGS = \
- $(PK_BROWSER_PLUGIN_CFLAGS) \
- -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
- -I$(top_srcdir)/lib \
- -I$(srcdir)/sdk
-
-packagekit_plugin_la_LIBADD = \
- $(PK_BROWSER_PLUGIN_LIBS) \
- $(top_builddir)/lib/packagekit-glib/libpackagekit-glib.la
-
-packagekit_plugin_la_SOURCES = \
- sdk/np_entry.cpp \
- sdk/npn_gate.cpp \
- sdk/npp_gate.cpp \
- sdk/npplat.h \
- sdk/pluginbase.h \
- \
- src/contents.cpp \
- src/contents.h \
- src/plugin.cpp \
- src/plugin.h
-
-EXTRA_DIST = \
- tests/test.html
diff --git a/contrib/packagekit-plugin/README b/contrib/packagekit-plugin/README
deleted file mode 100644
index 3a5b901..0000000
--- a/contrib/packagekit-plugin/README
+++ /dev/null
@@ -1,152 +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"/>
- <!-- List of basenames of possible desktop files (no .desktop extension) -->
- <param name="desktopnames" value="gnubg fedora-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.
-
-License and Copyright
-=====================
-
-You may distribute the code under the terms of the Mozilla Public License 1.1,
-GNU General Public License Version 2 or later (the "GPL"), or the
-GNU Lesser General Public License Version 2.1 or later (the "LGPL"). See the
-source files for details and for copyright information.
-
-The plugin infrastructure (The sdk/ directory and much of src/plugin.cpp
-and src/plugin.h) is derived from the Mozilla plugin SDK; other code under
-src/ is new code written by Red Hat, Inc.
-
-Owen Taylor <otaylor at redhat.com>
-July 24, 2008
-
diff --git a/contrib/packagekit-plugin/sdk/np_entry.cpp b/contrib/packagekit-plugin/sdk/np_entry.cpp
deleted file mode 100644
index 05323e9..0000000
--- a/contrib/packagekit-plugin/sdk/np_entry.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-//////////////////////////////////////////////////////////////
-//
-// Main plugin entry point implementation -- exports from the
-// plugin library
-//
-#include "npplat.h"
-#include "pluginbase.h"
-
-NPNetscapeFuncs NPNFuncs;
-
-NPError OSCALL NP_Shutdown()
-{
- NS_PluginShutdown();
- return NPERR_NO_ERROR;
-}
-
-static NPError fillPluginFunctionTable(NPPluginFuncs* aNPPFuncs)
-{
- if(aNPPFuncs == NULL)
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- // Set up the plugin function table that Netscape will use to
- // call us. Netscape needs to know about our version and size
- // and have a UniversalProcPointer for every function we implement.
-
- aNPPFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
-#ifdef XP_MAC
- aNPPFuncs->newp = NewNPP_NewProc(Private_New);
- aNPPFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
- aNPPFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
- aNPPFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
- aNPPFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
- aNPPFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
- aNPPFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
- aNPPFuncs->write = NewNPP_WriteProc(Private_Write);
- aNPPFuncs->print = NewNPP_PrintProc(Private_Print);
- aNPPFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent);
- aNPPFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
- aNPPFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue);
- aNPPFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue);
-#else
- aNPPFuncs->newp = NPP_New;
- aNPPFuncs->destroy = NPP_Destroy;
- aNPPFuncs->setwindow = NPP_SetWindow;
- aNPPFuncs->newstream = NPP_NewStream;
- aNPPFuncs->destroystream = NPP_DestroyStream;
- aNPPFuncs->asfile = NPP_StreamAsFile;
- aNPPFuncs->writeready = NPP_WriteReady;
- aNPPFuncs->write = NPP_Write;
- aNPPFuncs->print = NPP_Print;
- aNPPFuncs->event = NPP_HandleEvent;
- aNPPFuncs->urlnotify = NPP_URLNotify;
- aNPPFuncs->getvalue = NPP_GetValue;
- aNPPFuncs->setvalue = NPP_SetValue;
-#endif
-#ifdef OJI
- aNPPFuncs->javaClass = NULL;
-#endif
-
- return NPERR_NO_ERROR;
-}
-
-static NPError fillNetscapeFunctionTable(NPNetscapeFuncs* aNPNFuncs)
-{
- if(aNPNFuncs == NULL)
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- if(HIBYTE(aNPNFuncs->version) > NP_VERSION_MAJOR)
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- if(aNPNFuncs->size < sizeof(NPNetscapeFuncs))
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- NPNFuncs.size = aNPNFuncs->size;
- NPNFuncs.version = aNPNFuncs->version;
- NPNFuncs.geturlnotify = aNPNFuncs->geturlnotify;
- NPNFuncs.geturl = aNPNFuncs->geturl;
- NPNFuncs.posturlnotify = aNPNFuncs->posturlnotify;
- NPNFuncs.posturl = aNPNFuncs->posturl;
- NPNFuncs.requestread = aNPNFuncs->requestread;
- NPNFuncs.newstream = aNPNFuncs->newstream;
- NPNFuncs.write = aNPNFuncs->write;
- NPNFuncs.destroystream = aNPNFuncs->destroystream;
- NPNFuncs.status = aNPNFuncs->status;
- NPNFuncs.uagent = aNPNFuncs->uagent;
- NPNFuncs.memalloc = aNPNFuncs->memalloc;
- NPNFuncs.memfree = aNPNFuncs->memfree;
- NPNFuncs.memflush = aNPNFuncs->memflush;
- NPNFuncs.reloadplugins = aNPNFuncs->reloadplugins;
-#ifdef OJI
- NPNFuncs.getJavaEnv = aNPNFuncs->getJavaEnv;
- NPNFuncs.getJavaPeer = aNPNFuncs->getJavaPeer;
-#endif
- NPNFuncs.getvalue = aNPNFuncs->getvalue;
- NPNFuncs.setvalue = aNPNFuncs->setvalue;
- NPNFuncs.invalidaterect = aNPNFuncs->invalidaterect;
- NPNFuncs.invalidateregion = aNPNFuncs->invalidateregion;
- NPNFuncs.forceredraw = aNPNFuncs->forceredraw;
-
- return NPERR_NO_ERROR;
-}
-
-//
-// Some exports are different on different platforms
-//
-
-/**************************************************/
-/* */
-/* Windows */
-/* */
-/**************************************************/
-#ifdef XP_WIN
-
-NPError OSCALL NP_Initialize(NPNetscapeFuncs* aNPNFuncs)
-{
- NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
- if(rv != NPERR_NO_ERROR)
- return rv;
-
- return NS_PluginInitialize();
-}
-
-NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* aNPPFuncs)
-{
- return fillPluginFunctionTable(aNPPFuncs);
-}
-
-#endif //XP_WIN
-
-/**************************************************/
-/* */
-/* Unix */
-/* */
-/**************************************************/
-#ifdef XP_UNIX
-
-NPError NP_Initialize(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs)
-{
- NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
- if(rv != NPERR_NO_ERROR)
- return rv;
-
- rv = fillPluginFunctionTable(aNPPFuncs);
- if(rv != NPERR_NO_ERROR)
- return rv;
-
- return NS_PluginInitialize();
-}
-
-char * NP_GetMIMEDescription(void)
-{
- return NPP_GetMIMEDescription();
-}
-
-NPError NP_GetValue(void *future, NPPVariable aVariable, void *aValue)
-{
- return NS_PluginGetValue(aVariable, aValue);
-}
-
-#endif //XP_UNIX
-
-/**************************************************/
-/* */
-/* Mac */
-/* */
-/**************************************************/
-#ifdef XP_MAC
-
-#if !TARGET_API_MAC_CARBON
-QDGlobals* gQDPtr; // Pointer to Netscape's QuickDraw globals
-#endif
-
-short gResFile; // Refnum of the plugin's resource file
-
-NPError Private_Initialize(void)
-{
- NPError rv = NS_PluginInitialize();
- return rv;
-}
-
-void Private_Shutdown(void)
-{
- NS_PluginShutdown();
- __destroy_global_chain();
-}
-
-void SetUpQD(void);
-
-void SetUpQD(void)
-{
- ProcessSerialNumber PSN;
- FSSpec myFSSpec;
- Str63 name;
- ProcessInfoRec infoRec;
- OSErr result = noErr;
- CFragConnectionID connID;
- Str255 errName;
-
- // Memorize the plugin¹s resource file refnum for later use.
- gResFile = CurResFile();
-
-#if !TARGET_API_MAC_CARBON
- // Ask the system if CFM is available.
- long response;
- OSErr err = Gestalt(gestaltCFMAttr, &response);
- Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
-
- if (hasCFM) {
- // GetProcessInformation takes a process serial number and
- // will give us back the name and FSSpec of the application.
- // See the Process Manager in IM.
- infoRec.processInfoLength = sizeof(ProcessInfoRec);
- infoRec.processName = name;
- infoRec.processAppSpec = &myFSSpec;
-
- PSN.highLongOfPSN = 0;
- PSN.lowLongOfPSN = kCurrentProcess;
-
- result = GetProcessInformation(&PSN, &infoRec);
- }
- else
- // If no CFM installed, assume it must be a 68K app.
- result = -1;
-
- if (result == noErr) {
- // Now that we know the app name and FSSpec, we can call GetDiskFragment
- // to get a connID to use in a subsequent call to FindSymbol (it will also
- // return the address of ³main² in app, which we ignore). If GetDiskFragment
- // returns an error, we assume the app must be 68K.
- Ptr mainAddr;
- result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
- kReferenceCFrag, &connID, (Ptr*)&mainAddr, errName);
- }
-
- if (result == noErr) {
- // The app is a PPC code fragment, so call FindSymbol
- // to get the exported ³qd² symbol so we can access its
- // QuickDraw globals.
- CFragSymbolClass symClass;
- result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
- }
- else {
- // The app is 68K, so use its A5 to compute the address
- // of its QuickDraw globals.
- gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
- }
-#endif /* !TARGET_API_MAC_CARBON */
-}
-
-NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
-
-#if !TARGET_API_MAC_CARBON
-#pragma export on
-#if GENERATINGCFM
-RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
-#endif
-#pragma export off
-#endif /* !TARGET_API_MAC_CARBON */
-
-
-NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownUPP* aUnloadUpp)
-{
- NPError rv = NPERR_NO_ERROR;
-
- if (aUnloadUpp == NULL)
- rv = NPERR_INVALID_FUNCTABLE_ERROR;
-
- if (rv == NPERR_NO_ERROR)
- rv = fillNetscapeFunctionTable(aNPNFuncs);
-
- if (rv == NPERR_NO_ERROR) {
- // defer static constructors until the global functions are initialized.
- __InitCode__();
- rv = fillPluginFunctionTable(aNPPFuncs);
- }
-
- *aUnloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
- SetUpQD();
- rv = Private_Initialize();
-
- return rv;
-}
-#endif //XP_MAC
diff --git a/contrib/packagekit-plugin/sdk/npn_gate.cpp b/contrib/packagekit-plugin/sdk/npn_gate.cpp
deleted file mode 100644
index f5caa32..0000000
--- a/contrib/packagekit-plugin/sdk/npn_gate.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-////////////////////////////////////////////////////////////
-//
-// Implementation of Netscape entry points (NPN_*)
-//
-#include "npplat.h"
-
-extern NPNetscapeFuncs NPNFuncs;
-
-void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
-{
- *plugin_major = NP_VERSION_MAJOR;
- *plugin_minor = NP_VERSION_MINOR;
- *netscape_major = HIBYTE(NPNFuncs.version);
- *netscape_minor = LOBYTE(NPNFuncs.version);
-}
-
-NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
-{
- int navMinorVers = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
-
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
- rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target, notifyData);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return rv;
-}
-
-NPError NPN_GetURL(NPP instance, const char *url, const char *target)
-{
- NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target);
- return rv;
-}
-
-NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
-{
- int navMinorVers = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
-
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
- rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return rv;
-}
-
-NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
-{
- NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len, buf, file);
- return rv;
-}
-
-NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
-{
- NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList);
- return rv;
-}
-
-NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
-{
- int navMinorVersion = NPNFuncs.version & 0xFF;
-
- NPError rv = NPERR_NO_ERROR;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, stream);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return rv;
-}
-
-int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
-{
- int navMinorVersion = NPNFuncs.version & 0xFF;
- int32 rv = 0;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer);
- else
- rv = -1;
-
- return rv;
-}
-
-NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
-{
- int navMinorVersion = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
-
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, reason);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return rv;
-}
-
-void NPN_Status(NPP instance, const char *message)
-{
- CallNPN_StatusProc(NPNFuncs.status, instance, message);
-}
-
-const char* NPN_UserAgent(NPP instance)
-{
- const char * rv = NULL;
- rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance);
- return rv;
-}
-
-void* NPN_MemAlloc(uint32 size)
-{
- void * rv = NULL;
- rv = CallNPN_MemAllocProc(NPNFuncs.memalloc, size);
- return rv;
-}
-
-void NPN_MemFree(void* ptr)
-{
- CallNPN_MemFreeProc(NPNFuncs.memfree, ptr);
-}
-
-uint32 NPN_MemFlush(uint32 size)
-{
- uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size);
- return rv;
-}
-
-void NPN_ReloadPlugins(NPBool reloadPages)
-{
- CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages);
-}
-
-#ifdef OJI
-JRIEnv* NPN_GetJavaEnv(void)
-{
- JRIEnv * rv = NULL;
- rv = CallNPN_GetJavaEnvProc(NPNFuncs.getJavaEnv);
- return rv;
-}
-
-jref NPN_GetJavaPeer(NPP instance)
-{
- jref rv;
- rv = CallNPN_GetJavaPeerProc(NPNFuncs.getJavaPeer, instance);
- return rv;
-}
-#endif
-
-NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
-{
- NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value);
- return rv;
-}
-
-NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
-{
- NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value);
- return rv;
-}
-
-void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
-{
- CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect);
-}
-
-void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
-{
- CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegion);
-}
-
-void NPN_ForceRedraw(NPP instance)
-{
- CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance);
-}
diff --git a/contrib/packagekit-plugin/sdk/npp_gate.cpp b/contrib/packagekit-plugin/sdk/npp_gate.cpp
deleted file mode 100644
index 3e22783..0000000
--- a/contrib/packagekit-plugin/sdk/npp_gate.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-////////////////////////////////////////////////////////////
-//
-// Implementation of plugin entry points (NPP_*)
-//
-#include "pluginbase.h"
-
-// here the plugin creates a plugin instance object which
-// will be associated with this newly created NPP instance and
-// will do all the necessary job
-NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- NPError rv = NPERR_NO_ERROR;
-
- // create a new plugin instance object
- // initialization will be done when the associated window is ready
- nsPluginCreateData ds;
-
- ds.instance = instance;
- ds.type = pluginType;
- ds.mode = mode;
- ds.argc = argc;
- ds.argn = argn;
- ds.argv = argv;
- ds.saved = saved;
-
- nsPluginInstanceBase * plugin = NS_NewPluginInstance(&ds);
- if(plugin == NULL)
- return NPERR_OUT_OF_MEMORY_ERROR;
-
- // associate the plugin instance object with NPP instance
- instance->pdata = (void *)plugin;
- return rv;
-}
-
-// here is the place to clean up and destroy the nsPluginInstance object
-NPError NPP_Destroy (NPP instance, NPSavedData** save)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- NPError rv = NPERR_NO_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin != NULL) {
- plugin->shut();
- NS_DestroyPluginInstance(plugin);
- }
- return rv;
-}
-
-// during this call we know when the plugin window is ready or
-// is about to be destroyed so we can do some gui specific
-// initialization and shutdown
-NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- NPError rv = NPERR_NO_ERROR;
-
- if(pNPWindow == NULL)
- return NPERR_GENERIC_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
-
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- // window just created
- if(!plugin->isInitialized() && (pNPWindow->window != NULL)) {
- if(!plugin->init(pNPWindow)) {
- NS_DestroyPluginInstance(plugin);
- return NPERR_MODULE_LOAD_FAILED_ERROR;
- }
- }
-
- // window goes away
- if((pNPWindow->window == NULL) && plugin->isInitialized())
- return plugin->SetWindow(pNPWindow);
-
- // window resized?
- if(plugin->isInitialized() && (pNPWindow->window != NULL))
- return plugin->SetWindow(pNPWindow);
-
- // this should not happen, nothing to do
- if((pNPWindow->window == NULL) && !plugin->isInitialized())
- return plugin->SetWindow(pNPWindow);
-
- return rv;
-}
-
-NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- NPError rv = plugin->NewStream(type, stream, seekable, stype);
- return rv;
-}
-
-int32 NPP_WriteReady (NPP instance, NPStream *stream)
-{
- if(instance == NULL)
- return 0x0fffffff;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return 0x0fffffff;
-
- int32 rv = plugin->WriteReady(stream);
- return rv;
-}
-
-int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
-{
- if(instance == NULL)
- return len;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return len;
-
- int32 rv = plugin->Write(stream, offset, len, buffer);
- return rv;
-}
-
-NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- NPError rv = plugin->DestroyStream(stream, reason);
- return rv;
-}
-
-void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname)
-{
- if(instance == NULL)
- return;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return;
-
- plugin->StreamAsFile(stream, fname);
-}
-
-void NPP_Print (NPP instance, NPPrint* printInfo)
-{
- if(instance == NULL)
- return;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return;
-
- plugin->Print(printInfo);
-}
-
-void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
-{
- if(instance == NULL)
- return;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return;
-
- plugin->URLNotify(url, reason, notifyData);
-}
-
-NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- NPError rv = plugin->GetValue(variable, value);
- return rv;
-}
-
-NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
-{
- if(instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return NPERR_GENERIC_ERROR;
-
- NPError rv = plugin->SetValue(variable, value);
- return rv;
-}
-
-int16 NPP_HandleEvent(NPP instance, void* event)
-{
- if(instance == NULL)
- return 0;
-
- nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
- if(plugin == NULL)
- return 0;
-
- uint16 rv = plugin->HandleEvent(event);
- return rv;
-}
-
-#ifdef OJI
-jref NPP_GetJavaClass (void)
-{
- return NULL;
-}
-#endif
-
-/**************************************************/
-/* */
-/* Mac */
-/* */
-/**************************************************/
-
-// Mac needs these wrappers, see npplat.h for more info
-
-#ifdef XP_MAC
-
-NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
-{
- NPError rv = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
- return rv;
-}
-
-NPError Private_Destroy(NPP instance, NPSavedData** save)
-{
- NPError rv = NPP_Destroy(instance, save);
- return rv;
-}
-
-NPError Private_SetWindow(NPP instance, NPWindow* window)
-{
- NPError rv = NPP_SetWindow(instance, window);
- return rv;
-}
-
-NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
-{
- NPError rv = NPP_NewStream(instance, type, stream, seekable, stype);
- return rv;
-}
-
-int32 Private_WriteReady(NPP instance, NPStream* stream)
-{
- int32 rv = NPP_WriteReady(instance, stream);
- return rv;
-}
-
-int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
-{
- int32 rv = NPP_Write(instance, stream, offset, len, buffer);
- return rv;
-}
-
-void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
-{
- NPP_StreamAsFile(instance, stream, fname);
-}
-
-
-NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
-{
- NPError rv = NPP_DestroyStream(instance, stream, reason);
- return rv;
-}
-
-int16 Private_HandleEvent(NPP instance, void* event)
-{
- int16 rv = NPP_HandleEvent(instance, event);
- return rv;
-}
-
-void Private_Print(NPP instance, NPPrint* platformPrint)
-{
- NPP_Print(instance, platformPrint);
-}
-
-void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
-{
- NPP_URLNotify(instance, url, reason, notifyData);
-}
-
-jref Private_GetJavaClass(void)
-{
- return NULL;
-}
-
-NPError Private_GetValue(NPP instance, NPPVariable variable, void *result)
-{
- NPError rv = NPP_GetValue(instance, variable, result);
- return rv;
-}
-
-NPError Private_SetValue(NPP instance, NPNVariable variable, void *value)
-{
- NPError rv = NPP_SetValue(instance, variable, value);
- return rv;
-}
-
-#endif //XP_MAC
diff --git a/contrib/packagekit-plugin/sdk/npplat.h b/contrib/packagekit-plugin/sdk/npplat.h
deleted file mode 100644
index 637ac36..0000000
--- a/contrib/packagekit-plugin/sdk/npplat.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _NPPLAT_H_
-#define _NPPLAT_H_
-
-#include "npapi.h"
-#include "npupp.h"
-
-/**************************************************/
-/* */
-/* Windows */
-/* */
-/**************************************************/
-#ifdef XP_WIN
-#include "windows.h"
-#endif //XP_WIN
-
-/**************************************************/
-/* */
-/* Unix */
-/* */
-/**************************************************/
-#ifdef XP_UNIX
-#include <stdio.h>
-#endif //XP_UNIX
-
-/**************************************************/
-/* */
-/* Mac */
-/* */
-/**************************************************/
-#ifdef XP_MAC
-
-#include <Processes.h>
-#include <Gestalt.h>
-#include <CodeFragments.h>
-#include <Timer.h>
-#include <Resources.h>
-#include <ToolUtils.h>
-
-#include "jri.h"
-
-// The Mixed Mode procInfos defined in npupp.h assume Think C-
-// style calling conventions. These conventions are used by
-// Metrowerks with the exception of pointer return types, which
-// in Metrowerks 68K are returned in A0, instead of the standard
-// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
-// Mixed Mode will return the values to a 68K plugin in D0, but
-// a 68K plugin compiled by Metrowerks will expect the result in
-// A0. The following pragma forces Metrowerks to use D0 instead.
-//
-#ifdef __MWERKS__
-#ifndef powerc
-#pragma pointers_in_D0
-#endif
-#endif
-
-#ifdef __MWERKS__
-#ifndef powerc
-#pragma pointers_in_A0
-#endif
-#endif
-
-// The following fix for static initializers (which fixes a preious
-// incompatibility with some parts of PowerPlant, was submitted by
-// Jan Ulbrich.
-#ifdef __MWERKS__
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifndef powerc
- extern void __InitCode__(void);
- #else
- extern void __sinit(void);
- #define __InitCode__ __sinit
- #endif
- extern void __destroy_global_chain(void);
- #ifdef __cplusplus
- }
- #endif // __cplusplus
-#endif // __MWERKS__
-
-// Wrapper functions for all calls from Netscape to the plugin.
-// These functions let the plugin developer just create the APIs
-// as documented and defined in npapi.h, without needing to
-// install those functions in the function table or worry about
-// setting up globals for 68K plugins.
-NPError Private_Initialize(void);
-void Private_Shutdown(void);
-NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
-NPError Private_Destroy(NPP instance, NPSavedData** save);
-NPError Private_SetWindow(NPP instance, NPWindow* window);
-NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
-NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
-int32 Private_WriteReady(NPP instance, NPStream* stream);
-int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
-void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
-void Private_Print(NPP instance, NPPrint* platformPrint);
-int16 Private_HandleEvent(NPP instance, void* event);
-void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
-jref Private_GetJavaClass(void);
-NPError Private_GetValue(NPP instance, NPPVariable variable, void *result);
-NPError Private_SetValue(NPP instance, NPNVariable variable, void *value);
-
-#endif //XP_MAC
-
-#ifndef HIBYTE
-#define HIBYTE(i) (i >> 8)
-#endif
-
-#ifndef LOBYTE
-#define LOBYTE(i) (i & 0xff)
-#endif
-
-#endif //_NPPLAT_H_
diff --git a/contrib/packagekit-plugin/sdk/pluginbase.h b/contrib/packagekit-plugin/sdk/pluginbase.h
deleted file mode 100644
index b7e3327..0000000
--- a/contrib/packagekit-plugin/sdk/pluginbase.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __PLUGININSTANCEBASE_H__
-#define __PLUGININSTANCEBASE_H__
-
-#include "npplat.h"
-
-struct nsPluginCreateData
-{
- NPP instance;
- NPMIMEType type;
- uint16 mode;
- int16 argc;
- char** argn;
- char** argv;
- NPSavedData* saved;
-};
-
-class nsPluginInstanceBase
-{
-public:
- // these three methods must be implemented in the derived
- // class platform specific way
- virtual NPBool init(NPWindow* aWindow) = 0;
- virtual void shut() = 0;
- virtual NPBool isInitialized() = 0;
-
- // implement all or part of those methods in the derived
- // class as needed
- virtual NPError SetWindow(NPWindow* pNPWindow) { return NPERR_NO_ERROR; }
- virtual NPError NewStream(NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16* stype) { return NPERR_NO_ERROR; }
- virtual NPError DestroyStream(NPStream *stream, NPError reason) { return NPERR_NO_ERROR; }
- virtual void StreamAsFile(NPStream* stream, const char* fname) { return; }
- virtual int32 WriteReady(NPStream *stream) { return 0x0fffffff; }
- virtual int32 Write(NPStream *stream, int32 offset,
- int32 len, void *buffer) { return len; }
- virtual void Print(NPPrint* printInfo) { return; }
- virtual uint16 HandleEvent(void* event) { return 0; }
- virtual void URLNotify(const char* url, NPReason reason,
- void* notifyData) { return; }
- virtual NPError GetValue(NPPVariable variable, void *value) { return NPERR_NO_ERROR; }
- virtual NPError SetValue(NPNVariable variable, void *value) { return NPERR_NO_ERROR; }
-};
-
-// functions that should be implemented for each specific plugin
-
-// creation and destruction of the object of the derived class
-nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct);
-void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin);
-
-// global plugin initialization and shutdown
-NPError NS_PluginInitialize();
-void NS_PluginShutdown();
-
-#ifdef XP_UNIX
-// global to get plugins name & description
-NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue);
-#endif
-
-#endif // __PLUGININSTANCEBASE_H__
diff --git a/contrib/packagekit-plugin/src/contents.cpp b/contrib/packagekit-plugin/src/contents.cpp
deleted file mode 100644
index 39a3515..0000000
--- a/contrib/packagekit-plugin/src/contents.cpp
+++ /dev/null
@@ -1,800 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is packagekit-plugin code.
- *
- * The Initial Developer of the Original Code is
- * Red Hat, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2008
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#define MOZ_X11
-
-#include <config.h>
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <cairo-xlib.h>
-#include <dlfcn.h>
-#include <pango/pangocairo.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-#include <gio/gdesktopappinfo.h>
-#include <packagekit-glib/packagekit.h>
-
-#include "plugin.h"
-
-#define MARGIN 5
-
-#if !GTK_CHECK_VERSION(2,14,0)
-#define GTK_ICON_LOOKUP_FORCE_SIZE (GtkIconLookupFlags) 0
-#endif
-
-////////////////////////////////////////
-//
-// PkpContents class implementation
-//
-
-static std::vector<std::string>
-splitString(const gchar *str)
-{
- std::vector<std::string> v;
-
- if (str) {
- char **split = g_strsplit(str, " ", -1);
- for (char **s = split; *s; s++) {
- char *stripped = strdup(*s);
- g_strstrip(stripped);
- v.push_back(stripped);
- g_free(stripped);
- }
-
- g_strfreev(split);
- }
-
- return v;
-}
-
-PkpContents::PkpContents(const gchar *displayName, const gchar *packageNames) :
- mPlugin(0),
- mStatus(IN_PROGRESS),
- mAppInfo(0),
- mDisplayName(displayName),
- mPackageNames(splitString(packageNames)),
- mLayout(0),
- mInstallPackageProxy(0),
- mInstallPackageCall(0)
-{
- recheck();
-}
-
-PkpContents::~PkpContents()
-{
- clearLayout();
-
- if (mAppInfo != 0) {
- g_object_unref(mAppInfo);
- mAppInfo = 0;
- }
-
- if (mInstallPackageCall != 0) {
- dbus_g_proxy_cancel_call(mInstallPackageProxy, mInstallPackageCall);
- g_object_unref(mInstallPackageProxy);
- mInstallPackageProxy = 0;
- mInstallPackageCall = 0;
- }
-
- while (!mClients.empty())
- removeClient(mClients.front());
-}
-
-void PkpContents::recheck()
-{
- mStatus = IN_PROGRESS;
- mAvailableVersion = "";
- mAvailablePackageName = "";
- mInstalledPackageName = "";
-
- for (std::vector<std::string>::iterator i = mPackageNames.begin(); i != mPackageNames.end(); i++) {
- GError *error = NULL;
- PkClient *client = pk_client_new();
- gchar **package_ids;
- package_ids = pk_package_ids_from_id (i->c_str());
- if (!pk_client_resolve(client, PK_FILTER_ENUM_NONE, package_ids, &error)) {
- g_warning("%s", error->message);
- g_clear_error(&error);
- g_object_unref(client);
- } else {
- g_signal_connect(client, "package", G_CALLBACK(onClientPackage), this);
- g_signal_connect(client, "error-code", G_CALLBACK(onClientErrorCode), this);
- g_signal_connect(client, "finished", G_CALLBACK(onClientFinished), this);
- mClients.push_back(client);
- }
- g_strfreev (package_ids);
- }
-
- if (mClients.empty() && getStatus() == IN_PROGRESS)
- setStatus(UNAVAILABLE);
-}
-
-void PkpContents::removeClient(PkClient *client)
-{
- for (std::vector<PkClient *>::iterator i = mClients.begin(); i != mClients.end(); i++) {
- if (*i == client) {
- mClients.erase(i);
- g_signal_handlers_disconnect_by_func(client, (void *)onClientPackage, this);
- g_signal_handlers_disconnect_by_func(client, (void *)onClientErrorCode, this);
- g_signal_handlers_disconnect_by_func(client, (void *)onClientFinished, this);
- g_object_unref(client);
- break;
- }
- }
-
- if (mClients.empty()) {
- if (getStatus() == IN_PROGRESS)
- setStatus(UNAVAILABLE);
- }
-}
-
-void
-PkpContents::setStatus(PackageStatus status)
-{
- if (mStatus != status) {
- mStatus = status;
- clearLayout();
- refresh();
- }
-}
-
-void
-PkpContents::setAvailableVersion(const gchar *version)
-{
- mAvailableVersion = version;
- clearLayout();
- refresh();
-}
-
-void
-PkpContents::setAvailablePackageName(const gchar *name)
-{
- mAvailablePackageName = name;
-}
-
-void
-PkpContents::setInstalledPackageName(const gchar *name)
-{
- mInstalledPackageName = name;
-}
-
-void
-PkpContents::setInstalledVersion(const gchar *version)
-{
- mInstalledVersion = version;
- clearLayout();
- refresh();
-}
-
-void
-PkpContents::clearLayout()
-{
- if (mLayout) {
- g_object_unref(mLayout);
- mLayout = 0;
- }
-}
-
-static void
-append_markup(GString *str, const gchar *format, ...)
-{
- va_list vap;
-
- va_start(vap, format);
- char *tmp = g_markup_vprintf_escaped(format, vap);
- va_end(vap);
-
- g_string_append(str, tmp);
- g_free(tmp);
-}
-
-static guint32
-rgba_from_gdk_color(GdkColor *color)
-{
- return (((color->red >> 8) << 24) |
- ((color->green >> 8) << 16) |
- ((color->blue >> 8) << 8) |
- 0xff);
-}
-
-static void
-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.);
-
-}
-
-/* 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
-get_style(PangoFontDescription **font_desc, guint32 *foreground, guint32 *background, guint32 *link)
-{
- GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-
- gtk_widget_ensure_style(window);
-
- *foreground = rgba_from_gdk_color(&window->style->text[GTK_STATE_NORMAL]);
- *background = rgba_from_gdk_color(&window->style->base[GTK_STATE_NORMAL]);
-
- GdkColor link_color = { 0, 0, 0, 0xeeee };
- GdkColor *tmp = NULL;
-
- gtk_widget_style_get (GTK_WIDGET (window), "link-color", &tmp, NULL);
- if (tmp != NULL) {
- link_color = *tmp;
- gdk_color_free(tmp);
- }
-
- *link = rgba_from_gdk_color(&link_color);
-
- *font_desc = pango_font_description_copy(window->style->font_desc);
-
- gtk_widget_destroy(window);
-}
-
-void
-PkpContents::ensureLayout(cairo_t *cr, PangoFontDescription *font_desc, guint32 link_color)
-{
- GString *markup = g_string_new(NULL);
-
- if (mLayout)
- return;
-
- mLayout = pango_cairo_create_layout(cr);
- pango_layout_set_font_description(mLayout, font_desc);
-
- /* WARNING: Any changes to what links are created here will require corresponding
- * changes to the buttonRelease() method
- */
- switch (mStatus) {
- case IN_PROGRESS:
- /* TRANSLATORS: when we are getting data from the daemon */
- append_markup(markup, _("Getting package information..."));
- break;
- case INSTALLED:
- if (mAppInfo != 0) {
- append_markup(markup, "<span color='#%06x' underline='single'>", link_color >> 8);
- /* TRANSLATORS: run an applicaiton */
- append_markup(markup, _("Run %s"), mDisplayName.c_str());
- append_markup(markup, "</span>");
- } else
- append_markup(markup, "<big>%s</big>", mDisplayName.c_str());
- if (!mInstalledVersion.empty())
- /* TRANSLATORS: show the installed version of a package */
- append_markup(markup, "\n<small>%s: %s</small>", _("Installed version"), mInstalledVersion.c_str());
- break;
- case UPGRADABLE:
- append_markup(markup, "<big>%s</big>", mDisplayName.c_str());
- if (mAppInfo != 0) {
- if (!mInstalledVersion.empty()) {
- append_markup(markup, "\n<span color='#%06x' underline='single'>", link_color >> 8);
- /* TRANSLATORS: run the application now */
- append_markup(markup, _("Run version %s now"), mInstalledVersion.c_str());
- append_markup(markup, "</span>");
- } else {
- /* TRANSLATORS: run the application now */
- append_markup(markup,
- "\n<span color='#%06x' underline='single'>%s</span>",
- _("Run now"), link_color >> 8);
- }
- }
-
- append_markup(markup, "\n<span color='#%06x' underline='single'>", link_color >> 8);
- /* TRANSLATORS: update to a new version of the package */
- append_markup(markup, _("Update to version %s"), mAvailableVersion.c_str());
- append_markup(markup, "</span>");
- break;
- case AVAILABLE:
- append_markup(markup, "<span color='#%06x' underline='single'>", link_color >> 8);
- /* TRANSLATORS: To install a package */
- append_markup(markup, _("Install %s now"), mDisplayName.c_str());
- append_markup(markup, "</span>");
- /* TRANSLATORS: the version of the package */
- append_markup(markup, "\n<small>%s: %s</small>", _("Version"), mAvailableVersion.c_str());
- break;
- case UNAVAILABLE:
- append_markup(markup, "<big>%s</big>", mDisplayName.c_str());
- /* TRANSLATORS: noting found, so can't install */
- append_markup(markup, "\n<small>%s</small>", _("No packages found for your system"));
- break;
- case INSTALLING:
- append_markup(markup, "<big>%s</big>", mDisplayName.c_str());
- /* TRANSLATORS: package is being installed */
- append_markup(markup, "\n<small>%s</small>", _("Installing..."));
- break;
- }
-
- pango_layout_set_markup(mLayout, markup->str, -1);
- g_string_free(markup, TRUE);
-}
-
-void
-PkpContents::refresh()
-{
- if (mPlugin != 0)
- mPlugin->refresh();
-}
-
-void
-PkpContents::setPlugin(PkpPluginInstance *plugin)
-{
- mPlugin = plugin;
-}
-
-gchar *
-PkpContents::getBestDesktopFile()
-{
- GPtrArray *array = NULL;
- PkDesktop *desktop;
- gboolean ret;
- gchar *data = NULL;
- const gchar *package;
-
- /* open desktop database */
- desktop = pk_desktop_new();
- ret = pk_desktop_open_database(desktop, NULL);
- if (!ret)
- goto out;
-
- /* get files */
- package = mInstalledPackageName.c_str();
- array = pk_desktop_get_shown_for_package(desktop, package, NULL);
- if (array == NULL)
- goto out;
- if (array->len == 0)
- goto out;
-
- /* just use the first entry */
- data = g_strdup((const gchar*) g_ptr_array_index(array, 0));
-
-out:
- if (array != NULL) {
- g_ptr_array_foreach(array, (GFunc) g_free, NULL);
- g_ptr_array_free (array, TRUE);
- }
- g_object_unref(desktop);
- return data;
-}
-
-gchar *
-PkpContents::getPackageIcon()
-{
- gboolean ret;
- GKeyFile *file;
- gchar *data = NULL;
- const gchar *filename;
-
- /* get data from the best file */
- file = g_key_file_new();
- filename = getBestDesktopFile();
- if (filename == NULL)
- goto out;
-
- ret = g_key_file_load_from_file(file, filename, G_KEY_FILE_NONE, NULL);
- if (!ret) {
- g_warning("failed to open %s", filename);
- goto out;
- }
- data = g_key_file_get_string(file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL);
- g_key_file_free(file);
-out:
- return data;
-}
-
-void
-PkpContents::draw(cairo_t *cr)
-{
- guint32 foreground, background, link;
- PangoFontDescription *font_desc;
- guint x = mPlugin->getX();
- guint y = mPlugin->getY();
- cairo_surface_t *surface = NULL;
- const gchar *filename;
- GtkIconTheme *theme;
- GdkPixbuf *pixbuf;
-
- /* get properties */
- get_style(&font_desc, &foreground, &background, &link);
-
- /* fill background */
- set_source_from_rgba(cr, background);
- cairo_rectangle(cr, x, y, mPlugin->getWidth(), mPlugin->getHeight());
- cairo_fill(cr);
-
- /* grey outline */
- cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
- cairo_rectangle(cr, x + 0.5, y + 0.5, mPlugin->getWidth() - 1, mPlugin->getHeight() - 1);
- cairo_set_line_width(cr, 1);
- cairo_stroke(cr);
-
-
- /* get themed icon */
- filename = getPackageIcon();
- if (filename == NULL)
- filename = "package-x-generic";
- theme = gtk_icon_theme_get_default();
- pixbuf = gtk_icon_theme_load_icon(theme, filename, 48, GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
- if (pixbuf == NULL)
- goto skip;
- gdk_cairo_set_source_pixbuf(cr, pixbuf, x + MARGIN, y + MARGIN);
- cairo_rectangle(cr, x + MARGIN, y + MARGIN, 48, 48);
- cairo_fill(cr);
- cairo_surface_destroy(surface);
- g_object_unref(pixbuf);
-
-skip:
- /* write text */
- ensureLayout(cr, font_desc, link);
- cairo_move_to(cr,(x + MARGIN*2) + 48, y + MARGIN + MARGIN);
- set_source_from_rgba(cr, foreground);
- pango_cairo_show_layout(cr, mLayout);
-}
-
-/* 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
-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 *link = g_slist_find(lines, line);
- if (!link) {
- g_warning("Can't find line in layout line list\n");
- return FALSE;
- }
-
- if (link->next) {
- PangoLayoutLine *next_line = (PangoLayoutLine *)link->next->data;
- if (next_line->is_paragraph_start)
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* 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.
- */
-int
-PkpContents::getLinkIndex(int x, int y)
-{
- /* Coordinates are relative to origin of plugin (different from drawing) */
-
- if (!mLayout)
- return -1;
-
- x -= (MARGIN * 2) + 48;
- y -= (MARGIN * 2);
-
- int index;
- int trailing;
- if (!pango_layout_xy_to_index(mLayout, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing))
- return - 1;
-
- PangoLayoutIter *iter = pango_layout_get_iter(mLayout);
- int seen_links = 0;
- bool in_link = false;
- int result = -1;
-
- while (TRUE) {
- PangoLayoutRun *run = pango_layout_iter_get_run(iter);
- if (run) {
- PangoItem *item = run->item;
- PangoUnderline uline = PANGO_UNDERLINE_NONE;
-
- for (GSList *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 <= index && index < 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 (line_is_terminated(iter))
- in_link = FALSE;
- }
-
- if (!pango_layout_iter_next_run (iter))
- break;
- }
-
- pango_layout_iter_free(iter);
-
- return result;
-}
-
-void
-PkpContents::buttonPress(int x, int y, Time time)
-{
-}
-
-void
-PkpContents::buttonRelease(int x, int y, Time time)
-{
- int index = getLinkIndex(x, y);
- if (index < 0)
- return;
-
- switch (mStatus) {
- case IN_PROGRESS:
- case INSTALLING:
- case UNAVAILABLE:
- break;
- case INSTALLED:
- if (mAppInfo != 0)
- runApplication(time);
- break;
- case UPGRADABLE:
- if (mAppInfo != 0 && index == 0)
- runApplication(time);
- else
- installPackage(time);
- break;
- case AVAILABLE:
- if (!mAvailablePackageName.empty())
- installPackage(time);
- break;
- }
-}
-
-void
-PkpContents::motion(int x, int y)
-{
-}
-
-void
-PkpContents::enter(int x, int y)
-{
-}
-
-void
-PkpContents::leave(int x, int y)
-{
-}
-
-static guint32
-get_server_timestamp()
-{
- GtkWidget *invisible = gtk_invisible_new();
- gtk_widget_realize(invisible);
- return gdk_x11_get_server_time(invisible->window);
- gtk_widget_destroy(invisible);
-}
-
-void
-PkpContents::runApplication (Time time)
-{
- GError *error = NULL;
-#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
- GdkAppLaunchContext *context;
-#endif
-
- if (mAppInfo == 0) {
- g_warning("Didn't find application to launch");
- return;
- }
-
- if (time == 0)
- time = get_server_timestamp();
-
-#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
- context = gdk_app_launch_context_new();
- gdk_app_launch_context_set_timestamp(context, time);
- if (!g_app_info_launch(mAppInfo, NULL, G_APP_LAUNCH_CONTEXT (context), &error)) {
-#else
- if (!g_app_info_launch(mAppInfo, NULL, NULL, &error)) {
-#endif
- g_warning("%s\n", error->message);
- g_clear_error(&error);
- return;
- }
-
-#ifdef HAVE_GDK_APP_LAUNCH_CONTEXT_NEW
- if (context != NULL)
- g_object_unref(context);
-#endif
-}
-
-void
-PkpContents::installPackage (Time time)
-{
- GdkEvent *event;
- GdkWindow *window;
- guint xid = 0;
-
- if (mAvailablePackageName.empty()) {
- g_warning("No available package to install");
- return;
- }
-
- if (mInstallPackageCall != 0) {
- g_warning("Already installing package");
- return;
- }
-
- /* Get a proxy to the *session* PackageKit service */
- DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
- mInstallPackageProxy = dbus_g_proxy_new_for_name(connection,
- "org.freedesktop.PackageKit",
- "/org/freedesktop/PackageKit",
- "org.freedesktop.PackageKit");
-
- /* 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);
- }
-
- mInstallPackageCall = dbus_g_proxy_begin_call_with_timeout(mInstallPackageProxy,
- "InstallPackageName",
- onInstallPackageFinished,
- this,
- (GDestroyNotify)0,
- 24 * 60 * 1000 * 1000, /* one day */
- G_TYPE_UINT, xid, /* xid */
- G_TYPE_UINT, 0, /* timespec */
- G_TYPE_STRING, mAvailablePackageName.c_str(),
- G_TYPE_INVALID,
- G_TYPE_INVALID);
-
- setStatus(INSTALLING);
-}
-
-void
-PkpContents::onClientPackage(PkClient *client, const PkPackageObj *obj, PkpContents *contents)
-{
- gchar *filename;
-
- /* if we didn't use displayname, use the summary */
- if (contents->mDisplayName.size() == 0)
- contents->mDisplayName = obj->summary;
-
- /* parse the data */
- if (obj->info == PK_INFO_ENUM_AVAILABLE) {
- if (contents->getStatus() == IN_PROGRESS)
- contents->setStatus(AVAILABLE);
- else if (contents->getStatus() == INSTALLED)
- contents->setStatus(UPGRADABLE);
- contents->setAvailableVersion(obj->id->version);
- contents->setAvailablePackageName(obj->id->name);
-
-#if 0
- /* if we have data from the repo, override the user:
- * * we don't want the remote site pretending to install another package
- * * it might be localised if the backend supports it */
- if (obj->summary != NULL && obj->summary[0] != '\0')
- contents->mDisplayName = obj->summary;
-#endif
-
- } else if (obj->info == PK_INFO_ENUM_INSTALLED) {
- if (contents->getStatus() == IN_PROGRESS)
- contents->setStatus(INSTALLED);
- else if (contents->getStatus() == AVAILABLE)
- contents->setStatus(UPGRADABLE);
- contents->setInstalledVersion(obj->id->version);
- contents->setInstalledPackageName(obj->id->name);
-
- /* get desktop file information */
- filename = contents->getBestDesktopFile();
- if (filename != NULL) {
- contents->mAppInfo = G_APP_INFO(g_desktop_app_info_new_from_filename(filename));
-#if 0
- /* override, as this will have translation */
- contents->mDisplayName = g_app_info_get_name(contents->mAppInfo);
-#endif
- }
- g_free(filename);
-
- if (contents->mAppInfo != 0)
- contents->setStatus(INSTALLED);
- }
-}
-
-void
-PkpContents::onClientErrorCode(PkClient *client, PkErrorCodeEnum code, const gchar *details, PkpContents *contents)
-{
- g_warning("Error getting data from PackageKit: %s\n", details);
- contents->removeClient(client);
-}
-
-void
-PkpContents::onClientFinished(PkClient *client, PkExitEnum exit, guint runtime, PkpContents *contents)
-{
- contents->removeClient(client);
-}
-
-void
-PkpContents::onInstallPackageFinished (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
-{
- PkpContents *contents = (PkpContents *)user_data;
-
- GError *error = NULL;
- if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID)) {
- g_warning("Error occurred during install: %s", error->message);
- g_clear_error(&error);
- }
-
- g_object_unref(contents->mInstallPackageProxy);
- contents->mInstallPackageProxy = 0;
- contents->mInstallPackageCall = 0;
-
- contents->recheck();
-}
diff --git a/contrib/packagekit-plugin/src/contents.h b/contrib/packagekit-plugin/src/contents.h
deleted file mode 100644
index 40d45c8..0000000
--- a/contrib/packagekit-plugin/src/contents.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is packagekit-plugin code.
- *
- * The Initial Developer of the Original Code is
- * Red Hat, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2008
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef __CONTENTS_H__
-#define __CONTENTS_H__
-
-#include <X11/Xlib.h>
-#include <gio/gio.h>
-#include <pango/pango.h>
-#include <packagekit-glib/packagekit.h>
-#include <cairo.h>
-#include <dbus/dbus-glib.h>
-#include <gtk/gtk.h>
-
-#include <string>
-#include <vector>
-
-class PkpPluginInstance;
-
-enum PackageStatus {
- 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 */
-};
-
-class PkpContents
-{
-public:
- PkpContents(const gchar *displayName, const gchar *packageNames);
- virtual ~PkpContents();
-
- void setPlugin(PkpPluginInstance *plugin);
-
- void draw(cairo_t *cr);
- void buttonPress(int x, int y, Time time);
- void buttonRelease(int x, int y, Time time);
- void motion(int x, int y);
- void enter(int x, int y);
- void leave(int x, int y);
-
-private:
- void recheck();
- void findAppInfo();
- void runApplication(Time time);
- void installPackage(Time time);
-
- int getLinkIndex(int x, int y);
-
- void setStatus(PackageStatus status);
- PackageStatus getStatus() { return mStatus; }
- void setAvailableVersion(const gchar *version);
- void setAvailablePackageName(const gchar *name);
- void setInstalledVersion(const gchar *version);
- void setInstalledPackageName(const gchar *name);
-
- void ensureLayout(cairo_t *cr, PangoFontDescription *font_desc, guint32 link_color);
- void clearLayout();
- void refresh();
- gchar *getPackageIcon();
- gchar *getBestDesktopFile();
-
- void removeClient(PkClient *client);
-
- static void onClientPackage(PkClient *client, const PkPackageObj *obj, PkpContents *contents);
- static void onClientErrorCode(PkClient *client, PkErrorCodeEnum code, const gchar *details, PkpContents *contents);
- static void onClientFinished(PkClient *client, PkExitEnum exit, guint runtime, PkpContents *contents);
- static void onInstallPackageFinished(DBusGProxy *proxy, DBusGProxyCall *call, void *user_data);
-
- PkpPluginInstance *mPlugin;
- PackageStatus mStatus;
- std::string mAvailableVersion;
- std::string mAvailablePackageName;
- std::string mInstalledVersion;
- std::string mInstalledPackageName;
- GAppInfo *mAppInfo;
-
- std::string mDisplayName;
- std::vector<std::string> mPackageNames;
-
- PangoLayout *mLayout;
-
- std::vector<PkClient *> mClients;
-
- DBusGProxy *mInstallPackageProxy;
- DBusGProxyCall *mInstallPackageCall;
-};
-
-#endif // __CONTENTS_H__
diff --git a/contrib/packagekit-plugin/src/plugin.cpp b/contrib/packagekit-plugin/src/plugin.cpp
deleted file mode 100644
index d842b94..0000000
--- a/contrib/packagekit-plugin/src/plugin.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Red Hat, Inc.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#define MOZ_X11
-
-#include <config.h>
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <cairo-xlib.h>
-#include <dlfcn.h>
-
-#include "plugin.h"
-
-#define MIME_TYPES_HANDLED "application/x-packagekit-plugin"
-#define PLUGIN_NAME "Plugin for Installing Applications"
-#define MIME_TYPES_DESCRIPTION MIME_TYPES_HANDLED":bsc:"PLUGIN_NAME
-#define PLUGIN_DESCRIPTION PLUGIN_NAME
-
-char* NPP_GetMIMEDescription(void)
-{
- return (char *)(MIME_TYPES_DESCRIPTION);
-}
-
-static void *module_handle = 0;
-
-/////////////////////////////////////
-// general initialization and shutdown
-//
-
-/* 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
-make_module_resident()
-{
- Dl_info info;
-
- /* Get the (absolute) filename of this module */
- if (!dladdr((void *)NPP_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;
- }
-
- /* the module will never be closed */
-}
-
-NPError NS_PluginInitialize()
-{
- if (module_handle != 0) /* Already initialized */
- return NPERR_NO_ERROR;
-
- make_module_resident();
-
-#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-#endif
-
- return NPERR_NO_ERROR;
-}
-
-void NS_PluginShutdown()
-{
-}
-
-// get values per plugin
-NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue)
-{
- NPError err = NPERR_NO_ERROR;
- switch (aVariable) {
- case NPPVpluginNameString:
- *((char **)aValue) = (char *)PLUGIN_NAME;
- break;
- case NPPVpluginDescriptionString:
- *((char **)aValue) = (char *)PLUGIN_DESCRIPTION;
- break;
- default:
- err = NPERR_INVALID_PARAM;
- break;
- }
- return err;
-}
-
-/////////////////////////////////////////////////////////////
-//
-// construction and destruction of our plugin instance object
-//
-nsPluginInstanceBase * NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct)
-{
- const gchar *displayName = "";
- const gchar *packageNames = NULL;
-
- if(!aCreateDataStruct)
- return NULL;
-
- for (int i = 0; i < aCreateDataStruct->argc; i++) {
- if (strcmp(aCreateDataStruct->argn[i], "displayname") == 0)
- displayName = aCreateDataStruct->argv[i];
- else if (strcmp(aCreateDataStruct->argn[i], "packagenames") == 0)
- packageNames = aCreateDataStruct->argv[i];
- }
-
- PkpPluginInstance * plugin = new PkpPluginInstance(aCreateDataStruct->instance, displayName, packageNames);
-
- NPN_SetValue(aCreateDataStruct->instance, NPPVpluginWindowBool, (void *)FALSE);
-
- return plugin;
-}
-
-void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin)
-{
- if(aPlugin)
- delete (PkpPluginInstance *)aPlugin;
-}
-
-////////////////////////////////////////
-//
-// nsPluginInstance class implementation
-//
-
-PkpPluginInstance::PkpPluginInstance(NPP aInstance, const gchar *displayName, const gchar *packageNames) :
- nsPluginInstanceBase(),
- mInstance(aInstance),
- mInitialized(FALSE),
- mContents(displayName, packageNames),
- mWindow(0)
-{
- mContents.setPlugin(this);
-}
-
-PkpPluginInstance::~PkpPluginInstance()
-{
-}
-
-NPBool PkpPluginInstance::init(NPWindow* aWindow)
-{
- if(aWindow == NULL)
- return FALSE;
-
- if (SetWindow(aWindow))
- mInitialized = TRUE;
-
- return mInitialized;
-}
-
-void PkpPluginInstance::shut()
-{
- mInitialized = FALSE;
-}
-
-NPError PkpPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
-{
- NPError err = NPERR_NO_ERROR;
- switch (aVariable) {
- case NPPVpluginNameString:
- case NPPVpluginDescriptionString:
- return NS_PluginGetValue(aVariable, aValue) ;
- break;
- default:
- err = NPERR_INVALID_PARAM;
- break;
- }
- return err;
-
-}
-
-NPError PkpPluginInstance::SetWindow(NPWindow* aWindow)
-{
- if (aWindow == NULL)
- return FALSE;
-
- mX = aWindow->x;
- mY = aWindow->y;
- mWidth = aWindow->width;
- mHeight = aWindow->height;
-
- mWindow = (Window) aWindow->window;
- NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct *)aWindow->ws_info;
- mDisplay = ws_info->display;
- mVisual = ws_info->visual;
- mDepth = ws_info->depth;
- mColormap = ws_info->colormap;
-
- return NPERR_NO_ERROR;
-}
-
-void
-PkpPluginInstance::refresh()
-{
- NPRect rect;
-
- /* Coordinates here are relative to the plugin's origin (mX,mY) */
-
- rect.left = 0;
- rect.right = mWidth;
- rect.top = 0;
- rect.bottom = mHeight;
-
- NPN_InvalidateRect(mInstance, &rect);
-}
-
-uint16
-PkpPluginInstance::HandleEvent(void *event)
-{
- XEvent *xev = (XEvent *)event;
- cairo_surface_t *surface;
- cairo_t *cr;
- XButtonEvent *xbe;
- XGraphicsExposeEvent *xge;
- XMotionEvent *xme;
- XCrossingEvent *xce;
-
- switch (xev->xany.type) {
- case GraphicsExpose:
- xge = (XGraphicsExposeEvent *)event;
- surface = cairo_xlib_surface_create (mDisplay, xge->drawable, mVisual, mX + mWidth, mY + mHeight);
- cr = cairo_create(surface);
- cairo_rectangle(cr, xge->x, xge->y, xge->width, xge->height);
- cairo_clip(cr);
- mContents.draw(cr);
- cairo_destroy(cr);
- cairo_surface_destroy(surface);
- return 1;
- case ButtonPress:
- xbe = (XButtonEvent *)event;
- mContents.buttonPress(xbe->x, xbe->y, xbe->time);
- return 1;
- case ButtonRelease:
- xbe = (XButtonEvent *)event;
- mContents.buttonRelease(xbe->x, xbe->y, xbe->time);
- return 1;
- case MotionNotify:
- xme = (XMotionEvent *)event;
- mContents.motion(xme->x, xme->y);
- return 1;
- case EnterNotify:
- xce = (XCrossingEvent *)event;
- mContents.enter(xce->x, xce->y);
- return 1;
- case LeaveNotify:
- xce = (XCrossingEvent *)event;
- mContents.leave(xce->x, xce->y);
- return 1;
- }
- return 0;
-}
diff --git a/contrib/packagekit-plugin/src/plugin.h b/contrib/packagekit-plugin/src/plugin.h
deleted file mode 100644
index ded4b69..0000000
--- a/contrib/packagekit-plugin/src/plugin.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __PLUGIN_H__
-#define __PLUGIN_H__
-
-#include <X11/Xlib.h>
-
-#include "contents.h"
-#include "pluginbase.h"
-
-class PkpPluginInstance : public nsPluginInstanceBase
-{
-public:
- PkpPluginInstance(NPP aInstance, const gchar *displayName, const gchar *packageNames);
- virtual ~PkpPluginInstance();
-
- NPBool init(NPWindow* aWindow);
- void shut();
- NPBool isInitialized() {return mInitialized;}
- NPError GetValue(NPPVariable variable, void *value);
- NPError SetWindow(NPWindow* aWindow);
- uint16 HandleEvent(void *event);
-
- void refresh();
-
- int getX() { return mX; }
- int getY() { return mY; }
- int getWidth() { return mWidth; }
- int getHeight() { return mHeight; }
-
-private:
- NPP mInstance;
- NPBool mInitialized;
-
- PkpContents mContents;
-
- Window mWindow;
- Display *mDisplay;
- int mX, mY;
- int mWidth, mHeight;
- Visual* mVisual;
- Colormap mColormap;
- unsigned int mDepth;
-};
-
-#endif // __PLUGIN_H__
diff --git a/contrib/packagekit-plugin/tests/test.html b/contrib/packagekit-plugin/tests/test.html
deleted file mode 100644
index 24766ac..0000000
--- a/contrib/packagekit-plugin/tests/test.html
+++ /dev/null
@@ -1,41 +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"/>
- </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"/>
- </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>
-
commit 5f7e968105c78b2646821814bc920fb26ad4cdb4
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Dec 7 16:57:45 2008 +0000
bugfix: add the org.freedesktop.PackageKit.Transaction interface now that the default send interface is now deny
diff --git a/data/org.freedesktop.PackageKit.conf.in b/data/org.freedesktop.PackageKit.conf.in
index 8d93fcb..3bc91b8 100644
--- a/data/org.freedesktop.PackageKit.conf.in
+++ b/data/org.freedesktop.PackageKit.conf.in
@@ -14,6 +14,7 @@
<!-- Allow anyone to call into the service - we'll reject callers using PolicyKit -->
<policy context="default">
<allow send_interface="org.freedesktop.PackageKit"/>
+ <allow send_interface="org.freedesktop.PackageKit.Transaction"/>
</policy>
</busconfig>
commit 52b531e8a528b3d256138a9601eb268af84c98d1
Author: Sebastian Heinlein <devel at glatzor.de>
Date: Sat Dec 6 10:49:14 2008 -0800
Fix apt configuration
diff --git a/data/20packagekit b/data/20packagekit
index bd33356..3b6478c 100644
--- a/data/20packagekit
+++ b/data/20packagekit
@@ -1 +1 @@
-APT::Update::Post-Invoke-Success:: { "/usr/bin/dbus-send --system --dest=org.freedesktop.PackageKit --type=method_call /org/freedesktop/PackageKit org.freedesktop.PackageKit.StateHasChanged string:'cache-update'"; };
+APT::Update::Post-Invoke-Success { "/usr/bin/dbus-send --system --dest=org.freedesktop.PackageKit --type=method_call /org/freedesktop/PackageKit org.freedesktop.PackageKit.StateHasChanged string:'cache-update'"; };
commit d51658df891e88e74c102666c9dc7dfb665f0d81
Author: Richard Hughes <richard at hughsie.com>
Date: Sat Dec 6 10:51:06 2008 +0000
trivial: all upper and lowe case
diff --git a/contrib/command-not-found/pk-command-not-found.c b/contrib/command-not-found/pk-command-not-found.c
index 8098f54..b543e23 100644
--- a/contrib/command-not-found/pk-command-not-found.c
+++ b/contrib/command-not-found/pk-command-not-found.c
@@ -226,6 +226,24 @@ pk_cnf_find_alternatives_case (const gchar *cmd, guint len, GPtrArray *array)
g_ptr_array_add (array, possible);
}
}
+
+ /* all lower */
+ possible = g_strdup (cmd);
+ for (i=0; i<len; i++)
+ possible[i] = g_ascii_tolower (cmd[i]);
+ if (strcmp (possible, cmd) != 0)
+ g_ptr_array_add (array, possible);
+ else
+ g_free (possible);
+
+ /* all upper */
+ possible = g_strdup (cmd);
+ for (i=0; i<len; i++)
+ possible[i] = g_ascii_toupper (cmd[i]);
+ if (strcmp (possible, cmd) != 0)
+ g_ptr_array_add (array, possible);
+ else
+ g_free (possible);
}
/**
commit 191830f4328edb6d8d973714b35de1140272bd03
Author: Richard Hughes <richard at hughsie.com>
Date: Sat Dec 6 10:48:37 2008 +0000
trivial: some upper case commands too
diff --git a/contrib/command-not-found/pk-command-not-found.c b/contrib/command-not-found/pk-command-not-found.c
index 6d71369..8098f54 100644
--- a/contrib/command-not-found/pk-command-not-found.c
+++ b/contrib/command-not-found/pk-command-not-found.c
@@ -219,6 +219,12 @@ pk_cnf_find_alternatives_case (const gchar *cmd, guint len, GPtrArray *array)
possible[i] = temp;
g_ptr_array_add (array, possible);
}
+ temp = g_ascii_toupper (cmd[i]);
+ if (temp != cmd[i]) {
+ possible = g_strdup (cmd);
+ possible[i] = temp;
+ g_ptr_array_add (array, possible);
+ }
}
}
commit e13bef68e7e9f8fa611ab2274c15b7216638fc3d
Author: Richard Hughes <richard at hughsie.com>
Date: Sat Dec 6 10:44:49 2008 +0000
trivial: German k,c difference
diff --git a/contrib/command-not-found/pk-command-not-found.c b/contrib/command-not-found/pk-command-not-found.c
index 4699358..6d71369 100644
--- a/contrib/command-not-found/pk-command-not-found.c
+++ b/contrib/command-not-found/pk-command-not-found.c
@@ -119,6 +119,16 @@ pk_cnf_find_alternatives_replace (const gchar *cmd, guint len, GPtrArray *array)
possible[i] = 's';
g_ptr_array_add (array, possible);
}
+ if (temp == 'k') {
+ possible = g_strdup (cmd);
+ possible[i] = 'c';
+ g_ptr_array_add (array, possible);
+ }
+ if (temp == 'c') {
+ possible = g_strdup (cmd);
+ possible[i] = 'k';
+ g_ptr_array_add (array, possible);
+ }
}
}
commit 8e85b5526bcc4607f9afef8d7bfa70adbb187d82
Author: Richard Hughes <richard at hughsie.com>
Date: Sat Dec 6 10:42:58 2008 +0000
trivial: Unbritishize words
diff --git a/contrib/command-not-found/pk-command-not-found.c b/contrib/command-not-found/pk-command-not-found.c
index f6f6217..4699358 100644
--- a/contrib/command-not-found/pk-command-not-found.c
+++ b/contrib/command-not-found/pk-command-not-found.c
@@ -99,6 +99,26 @@ pk_cnf_find_alternatives_replace (const gchar *cmd, guint len, GPtrArray *array)
possible[i] = 'o';
g_ptr_array_add (array, possible);
}
+ if (temp == 'c') {
+ possible = g_strdup (cmd);
+ possible[i] = 's';
+ g_ptr_array_add (array, possible);
+ }
+ if (temp == 's') {
+ possible = g_strdup (cmd);
+ possible[i] = 'c';
+ g_ptr_array_add (array, possible);
+ }
+ if (temp == 's') {
+ possible = g_strdup (cmd);
+ possible[i] = 'z';
+ g_ptr_array_add (array, possible);
+ }
+ if (temp == 'z') {
+ possible = g_strdup (cmd);
+ possible[i] = 's';
+ g_ptr_array_add (array, possible);
+ }
}
}
@@ -149,6 +169,28 @@ pk_cnf_find_alternatives_remove_double (const gchar *cmd, guint len, GPtrArray *
}
/**
+ * pk_cnf_find_alternatives_locale:
+ *
+ * Fix British spellings, e.g. colourdiff -> colordiff
+ **/
+static void
+pk_cnf_find_alternatives_locale (const gchar *cmd, guint len, GPtrArray *array)
+{
+ guint i, j;
+ gchar *possible;
+
+ for (i=1; i<len; i++) {
+ if (cmd[i-1] == 'o' && cmd[i] == 'u') {
+ possible = g_strdup (cmd);
+ for (j=i; j<len; j++)
+ possible[j] = possible[j+1];
+ possible[len-1] = '\0';
+ g_ptr_array_add (array, possible);
+ }
+ }
+}
+
+/**
* pk_cnf_find_alternatives_case:
*
* Remove double chars, e.g. Lshal -> lshal
@@ -197,6 +239,7 @@ pk_cnf_find_alternatives (const gchar *cmd, guint len)
pk_cnf_find_alternatives_truncate (cmd, len, possible);
pk_cnf_find_alternatives_remove_double (cmd, len, possible);
pk_cnf_find_alternatives_case (cmd, len, possible);
+ pk_cnf_find_alternatives_locale (cmd, len, possible);
/* remove duplicates using a helper array */
for (i=0; i<possible->len; i++) {
commit 217bdc8555ca5153a783d0bee18d8ff94769ce71
Author: Richard Hughes <richard at hughsie.com>
Date: Sat Dec 6 10:38:15 2008 +0000
bugfix: add a case mode to command not found
diff --git a/contrib/command-not-found/CommandNotFound.conf b/contrib/command-not-found/CommandNotFound.conf
index 9f32dbe..0f52570 100644
--- a/contrib/command-not-found/CommandNotFound.conf
+++ b/contrib/command-not-found/CommandNotFound.conf
@@ -33,7 +33,7 @@ SoftwareSourceSearch=true
#
# Allowed values are 'ignore', 'install', 'ask' or 'warn'
#
-# default=warn
+# default=ask
SingleInstall=ask
# This policy controls what to do when a more than one possible package
diff --git a/contrib/command-not-found/pk-command-not-found.c b/contrib/command-not-found/pk-command-not-found.c
index a058564..f6f6217 100644
--- a/contrib/command-not-found/pk-command-not-found.c
+++ b/contrib/command-not-found/pk-command-not-found.c
@@ -149,6 +149,28 @@ pk_cnf_find_alternatives_remove_double (const gchar *cmd, guint len, GPtrArray *
}
/**
+ * pk_cnf_find_alternatives_case:
+ *
+ * Remove double chars, e.g. Lshal -> lshal
+ **/
+static void
+pk_cnf_find_alternatives_case (const gchar *cmd, guint len, GPtrArray *array)
+{
+ guint i;
+ gchar *possible;
+ gchar temp;
+
+ for (i=0; i<len; i++) {
+ temp = g_ascii_tolower (cmd[i]);
+ if (temp != cmd[i]) {
+ possible = g_strdup (cmd);
+ possible[i] = temp;
+ g_ptr_array_add (array, possible);
+ }
+ }
+}
+
+/**
* pk_cnf_find_alternatives:
*
* Generate a list of commands it might be
@@ -174,6 +196,7 @@ pk_cnf_find_alternatives (const gchar *cmd, guint len)
if (len > 3)
pk_cnf_find_alternatives_truncate (cmd, len, possible);
pk_cnf_find_alternatives_remove_double (cmd, len, possible);
+ pk_cnf_find_alternatives_case (cmd, len, possible);
/* remove duplicates using a helper array */
for (i=0; i<possible->len; i++) {
More information about the PackageKit-commit
mailing list