Permalink
Browse files

Make extension work in both 3.6 and 4.0 at the same time

  • Loading branch information...
mdlavin committed Jan 18, 2011
1 parent 6a716d9 commit a2ef5138ca50feb0d77e1664902c04b2e19d5e5f
Showing with 88 additions and 48 deletions.
  1. +75 −40 GnomeKeyring.cpp
  2. +2 −1 GnomeKeyring.h
  3. +4 −4 Makefile
  4. +2 −1 install.rdf
  5. BIN lib/i386/libxpcomglue_s_nomozalloc.a
  6. +2 −0 xpi/chrome.manifest
  7. +3 −2 xpi/install.rdf
View
@@ -26,7 +26,7 @@
* 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
+-8 * 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
@@ -37,11 +37,10 @@
* ***** END LICENSE BLOCK ***** */
#include "GnomeKeyring.h"
+#include "nsMemory.h"
#include "nsILoginInfo.h"
-#include "nsIGenericFactory.h"
-#include "nsMemory.h"
-#include "nsICategoryManager.h"
+#include "mozilla/ModuleUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsStringAPI.h"
#include "nsIXULAppInfo.h"
@@ -475,7 +474,25 @@ findLogins(const nsAString & aHostname,
}
/* Implementation file */
-NS_IMPL_ISUPPORTS1(GnomeKeyring, nsILoginManagerStorage)
+
+/// The following code works around the problem that newILoginManagerStorage has a new UUID in
+/// Firefox 4.0, but this component should be compatible with both 3.6 and 4.0.
+
+#define LOGIN_MANAGER_STORAGE_3_6_CID {0xe66c97cd, 0x3bcf, 0x4eee, { 0x99, 0x37, 0x38, 0xf6, 0x50, 0x37, 0x2d, 0x77 }}
+NS_DEFINE_NAMED_CID(LOGIN_MANAGER_STORAGE_3_6_CID);
+
+NS_IMPL_ADDREF(GnomeKeyring)
+NS_IMPL_RELEASE(GnomeKeyring)
+
+NS_INTERFACE_MAP_BEGIN(GnomeKeyring)
+NS_INTERFACE_MAP_ENTRY(nsILoginManagerStorage)
+ if ( aIID.Equals(kLOGIN_MANAGER_STORAGE_3_6_CID ) )
+ foundInterface = static_cast<nsILoginManagerStorage*>(this);
+ else
+NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsILoginManagerStorage)
+NS_INTERFACE_MAP_END
+
+// End code to deal with 4.0 / 3.6 compatibility
NS_IMETHODIMP GnomeKeyring::Init()
{
@@ -806,48 +823,66 @@ NS_IMETHODIMP GnomeKeyring::CountLogins(const nsAString & aHostname,
return NS_OK;
}
-
-/* End of implementation class template. */
-
-static NS_METHOD
-GnomeKeyringRegisterSelf(nsIComponentManager *compMgr, nsIFile *path,
- const char *loaderStr, const char *type,
- const nsModuleComponentInfo *info)
+/**
+ * True when a master password prompt is being shown.
+ */
+/* readonly attribute boolean uiBusy; */
+NS_IMETHODIMP GnomeKeyring::GetUiBusy(PRBool *aUiBusy)
{
- nsCOMPtr<nsICategoryManager> cat =
- do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
- NS_ENSURE_STATE(cat);
-
- cat->AddCategoryEntry("login-manager-storage", "nsILoginManagerStorage",
- kGnomeKeyringContractID, PR_TRUE, PR_TRUE, nsnull);
+ *aUiBusy = FALSE;
return NS_OK;
}
-static NS_METHOD
-GnomeKeyringUnregisterSelf(nsIComponentManager *compMgr, nsIFile *path,
- const char *loaderStr,
- const nsModuleComponentInfo *info)
-{
- nsCOMPtr<nsICategoryManager> cat =
- do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
- NS_ENSURE_STATE(cat);
- cat->DeleteCategoryEntry("login-manager-storage", "nsILoginManagerStorage",
- PR_TRUE);
- return NS_OK;
-}
+
+/* End of implementation class template. */
NS_GENERIC_FACTORY_CONSTRUCTOR(GnomeKeyring)
-static const nsModuleComponentInfo components[] = {
- {
- "GnomeKeyring",
- GNOMEKEYRING_CID,
- kGnomeKeyringContractID,
- GnomeKeyringConstructor,
- GnomeKeyringRegisterSelf,
- GnomeKeyringUnregisterSelf
- }
+NS_DEFINE_NAMED_CID(GNOMEKEYRING_CID);
+
+// Build a table of ClassIDs (CIDs) which are implemented by this module. CIDs
+// should be completely unique UUIDs.
+// each entry has the form { CID, service, factoryproc, constructorproc }
+// where factoryproc is usually NULL.
+static const mozilla::Module::CIDEntry kPasswordsCIDs[] = {
+ { &kGNOMEKEYRING_CID, false, NULL, GnomeKeyringConstructor },
+ { NULL }
+};
+
+// Build a table which maps contract IDs to CIDs.
+// A contract is a string which identifies a particular set of functionality. In some
+// cases an extension component may override the contract ID of a builtin gecko component
+// to modify or extend functionality.
+static const mozilla::Module::ContractIDEntry kPasswordsContracts[] = {
+ { GNOMEPASSWORD_CONTRACTID, &kGNOMEKEYRING_CID },
+ { NULL }
};
-NS_IMPL_NSGETMODULE(GnomeKeyring, components)
+// Category entries are category/key/value triples which can be used
+// to register contract ID as content handlers or to observe certain
+// notifications. Most modules do not need to register any category
+// entries: this is just a sample of how you'd do it.
+// @see nsICategoryManager for information on retrieving category data.
+static const mozilla::Module::CategoryEntry kPasswordsCategories[] = {
+ { "login-manager-storage", "nsILoginManagerStorage", GNOMEPASSWORD_CONTRACTID },
+ { NULL }
+};
+
+static const mozilla::Module kPasswordsModule = {
+ mozilla::Module::kVersion,
+ kPasswordsCIDs,
+ kPasswordsContracts,
+ kPasswordsCategories
+};
+
+
+// The following line implements the one-and-only "NSModule" symbol exported from this
+// shared library.
+NSMODULE_DEFN(nsGnomeKeypassModule) = &kPasswordsModule;
+
+// The following line implements the one-and-only "NSGetModule" symbol
+// for compatibility with mozilla 1.9.2. You should only use this
+// if you need a binary which is backwards-compatible and if you use
+// interfaces carefully across multiple versions.
+NS_IMPL_MOZILLA192_NSGETMODULE(&kPasswordsModule)
View
@@ -39,10 +39,11 @@ extern "C" {
#include "gnome-keyring.h"
}
+
#define GNOMEKEYRING_CID \
{ 0xda355706, 0x2b26, 0x4682, { 0xbe, 0x76, 0xd6, 0x87, 0x13, 0x12, 0xd3, 0xa1}}
-static const char kGnomeKeyringContractID[] = "@mozilla.org/gnome-keyring;1";
+#define GNOMEPASSWORD_CONTRACTID "@mozilla.org/gnome-keyring;1"
#ifdef PR_LOGGING
// (NSPR_LOG_MODULES=GnomeKeyringLog:5)
View
@@ -1,9 +1,9 @@
-CPPFLAGS += -fno-rtti -fno-exceptions -shared -fPIC
+CPPFLAGS += -fno-rtti -fno-exceptions -shared -fPIC -g
-DEPENDENCY_CFLAGS = `pkg-config --cflags libxul gnome-keyring-1`
+DEPENDENCY_CFLAGS = `pkg-config --cflags libxul gnome-keyring-1` -DMOZ_NO_MOZALLOC
GNOME_LDFLAGS = `pkg-config --libs gnome-keyring-1`
-XUL_LDFLAGS = `pkg-config --libs libxul ` -L lib/i386
-VERSION = 0.4.2
+XUL_LDFLAGS = `pkg-config --libs libxul | sed 's/xpcomglue_s/xpcomglue_s_nomozalloc/' | sed 's/-lmozalloc//'` -L lib/i386
+VERSION = 0.5.0
FILES = GnomeKeyring.cpp
TARGET = libgnomekeyring.so
View
@@ -22,7 +22,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.5</em:minVersion>
- <em:maxVersion>3.6.*</em:maxVersion>
+ <em:maxVersion>4.0.*</em:maxVersion>
</Description>
</em:targetApplication>
@@ -32,5 +32,6 @@
<em:name>Gnome-keyring password integration</em:name>
<em:description>An extension to enable passwords and form logins to be stored in gnome-keyring</em:description>
<em:creator>Matt Lavin</em:creator>
+ <em:unpack>true</em:unpack>
</Description>
</RDF>
Binary file not shown.
View
@@ -0,0 +1,2 @@
+binary-component platform/Linux_x86_64-gcc3/components/libgnomekeyring.so ABI=Linux_x86_64-gcc3
+binary-component platform/Linux_x86-gcc3/components/libgnomekeyring.so ABI=Linux_x86-gcc3
View
@@ -5,7 +5,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>{6f9d85e0-794d-11dd-ad8b-0800200c9a66}</em:id>
- <em:version>0.4.2</em:version>
+ <em:version>0.5.0</em:version>
<em:type>2</em:type>
<!-- Thunderbird -->
@@ -22,7 +22,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.5</em:minVersion>
- <em:maxVersion>3.6.*</em:maxVersion>
+ <em:maxVersion>4.0.*</em:maxVersion>
</Description>
</em:targetApplication>
@@ -32,5 +32,6 @@
<em:name>Gnome-keyring password integration</em:name>
<em:description>An extension to enable passwords and form logins to be stored in gnome-keyring</em:description>
<em:creator>Matt Lavin</em:creator>
+ <em:unpack>true</em:unpack>
</Description>
</RDF>

0 comments on commit a2ef513

Please sign in to comment.