Hi,

have been looking at the problems that David Van Assche has found
while trying to put Gears to work in Browse and reached the point
where the extension installs itself successfully. Hopefully, after we
fix these issues other extensions will be installable in Browse.

Unfortunately, gears is not working yet because we fail to properly
display the popup that requests permission from the user to run the
gears app. Hopefully it's some small bug in our dialog handling code.

The patch isn't ready to be committed yet, help in polishing will be
appreciated.

Summary:

* handle NS_XPCOM_XPTI_REGISTRY_FILE in our directory provider, so
mozilla doesn't try (and fail) to keep that file in /usr/lib:

+    if (!strcmp(aKey, NS_XPCOM_XPTI_REGISTRY_FILE) && mProfilePath) {
...
+        rv = file->AppendNative(nsCString("xpti.dat"));
...
+    }

* Set the binDir path to /usr/lib/xulrunner-1.9, mozilla will add
"components" to the path when autoregistering components:

-    rv = NS_NewNativeLocalFile(nsCString(LIBXUL_DIR"/components"), PR_TRUE,
+    rv = NS_NewNativeLocalFile(nsCString(LIBXUL_DIR), PR_TRUE,

* Add an implementation of the service @mozilla.org/xre/app-info;1,
extensions use this interface to tell if they should load in a given
xulrunner environment. Many absurd values there, we need to decide
better ones. Perhaps this should live in a components dir inside the
activity bundle? So every activity can provide its own values? One
more hack: had to name xulappinfo.js as axulappinfo.js so it loads
before the gears extension.

-components_DATA = hulahopAddCertException.js
+components_DATA = hulahopAddCertException.js   \
+                 axulappinfo.js

Won't be around this weekend, so would be great if someone could take
this task (David?). Also, perhaps we should start filing tickets about
it.

Thanks,

Tomeu
From 2be3184a9298bdbadae05fd46a3574eef0426e8a Mon Sep 17 00:00:00 2001
From: Tomeu Vizoso <[EMAIL PROTECTED]>
Date: Fri, 11 Jul 2008 10:09:59 +0200
Subject: [PATCH] Some fixes for component registration. Add NSXULAppInfo service.

---
 components/Makefile.am           |    3 +-
 components/axulappinfo.js        |   93 ++++++++++++++++++++++++++++++++++++++
 src/HulahopDirectoryProvider.cpp |   14 +++++-
 src/hulahop.cpp                  |    2 +-
 4 files changed, 109 insertions(+), 3 deletions(-)
 create mode 100644 components/axulappinfo.js

diff --git a/components/Makefile.am b/components/Makefile.am
index 1f4466a..b36d986 100644
--- a/components/Makefile.am
+++ b/components/Makefile.am
@@ -6,7 +6,8 @@ xpt_DATA = $(xpt_in_files:.idl=.xpt)
 	$(LIBXUL_SDK_DIR)/bin/xpidl -m typelib -w -v -I $(LIBXUL_SDK_DIR)/idl -e $@ $< 
 
 componentsdir = $(pkglibdir)/components
-components_DATA = hulahopAddCertException.js
+components_DATA = hulahopAddCertException.js	\
+		  axulappinfo.js
 
 EXTRA_DIST = $(xpt_in_files) $(components_DATA)
 
diff --git a/components/axulappinfo.js b/components/axulappinfo.js
new file mode 100644
index 0000000..23c4a18
--- /dev/null
+++ b/components/axulappinfo.js
@@ -0,0 +1,93 @@
+const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
+const XULAPPINFO_CID = Components.ID("{18eec982-b411-4f07-9fca-79d33ee6e4b5}");
+
+const nsIXULAppInfo = Components.interfaces.nsIXULAppInfo;
+const nsIXULRuntime = Components.interfaces.nsIXULRuntime;
+const nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar;
+const nsIFactory = Components.interfaces.nsIFactory;
+
+function XULAppInfoService()
+{}
+
+XULAppInfoService.prototype.ID = '{ab9fc198-f515-477b-843f-8fb52810a3e0}'
+XULAppInfoService.prototype.vendor = 'Sugar'
+XULAppInfoService.prototype.name = 'Browser Activity'
+XULAppInfoService.prototype.version = '999'
+XULAppInfoService.prototype.appBuildID = '9999999999'
+XULAppInfoService.prototype.platformVersion = '1.9'
+XULAppInfoService.prototype.platformBuildID = '2008051202'
+XULAppInfoService.prototype.inSafeMode = false
+XULAppInfoService.prototype.logConsoleErrors = true
+XULAppInfoService.prototype.OS = 'Linux'
+XULAppInfoService.prototype.XPCOMABI = 'x86-gcc3'
+
+XULAppInfoService.prototype.QueryInterface =
+function appinfo_QueryInterface(iid)
+{
+    if (!iid.equals(nsIXULAppInfo) &&
+        !iid.equals(nsIXULRuntime) &&
+        !iid.equals(nsISupports))
+    {
+        throw Components.results.NS_ERROR_NO_INTERFACE;
+    }
+
+    return this;
+}
+
+var XULAppInfoFactory = new Object();
+
+XULAppInfoFactory.createInstance =
+function(outer, iid)
+{
+    if (outer != null)
+        throw Components.results.NS_ERROR_NO_AGGREGATION;
+
+    if (!iid.equals(nsIXULAppInfo) && !iid.equals(nsISupports))
+        throw Components.results.NS_ERROR_INVALID_ARG;
+
+    return new XULAppInfoService();
+}
+
+
+var XULAppInfoModule = new Object();
+
+XULAppInfoModule.registerSelf =
+function mod_registerSelf(compMgr, fileSpec, location, type)
+{
+    compMgr = compMgr.QueryInterface(nsIComponentRegistrar);
+
+    compMgr.registerFactoryLocation(XULAPPINFO_CID,
+                                    "XUL AppInfo service",
+                                    XULAPPINFO_CONTRACTID,
+                                    fileSpec, location, type);
+}
+
+XULAppInfoModule.unregisterSelf =
+function mod_unregisterSelf(compMgr, fileSpec, location)
+{
+}
+
+XULAppInfoModule.getClassObject =
+function mod_getClassObject(compMgr, cid, iid)
+{
+    if (cid.equals(XULAPPINFO_CID))
+        return XULAppInfoFactory;
+
+    if (!iid.equals(nsIFactory))
+        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+
+    throw Components.results.NS_ERROR_NO_INTERFACE;
+}
+
+XULAppInfoModule.canUnload =
+function mod_canUnload(compMgr)
+{
+    return true;
+}
+
+/* entrypoint */
+function NSGetModule(compMgr, fileSpec)
+{
+    return XULAppInfoModule;
+}
+
diff --git a/src/HulahopDirectoryProvider.cpp b/src/HulahopDirectoryProvider.cpp
index fb21d69..2f5e74f 100644
--- a/src/HulahopDirectoryProvider.cpp
+++ b/src/HulahopDirectoryProvider.cpp
@@ -67,7 +67,19 @@ HulahopDirectoryProvider::GetFile(const char *aKey,
         NS_ADDREF(*aResult = file);
         return NS_OK;
     }
-    
+
+    if (!strcmp(aKey, NS_XPCOM_XPTI_REGISTRY_FILE) && mProfilePath) {
+        nsCOMPtr<nsIFile> file;
+        rv = mProfilePath->Clone(getter_AddRefs(file));
+        NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+        
+        rv = file->AppendNative(nsCString("xpti.dat"));
+        NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+
+        NS_ADDREF(*aResult = file);
+        return NS_OK;
+    }
+
     if (!strcmp(aKey, NS_APP_PREF_DEFAULTS_50_DIR)) {
         nsCOMPtr<nsILocalFile> dataDir;
         NS_NewNativeLocalFile(nsCString(DATA_DIR),
diff --git a/src/hulahop.cpp b/src/hulahop.cpp
index 8d90c6f..3e3b963 100644
--- a/src/hulahop.cpp
+++ b/src/hulahop.cpp
@@ -56,7 +56,7 @@ hulahop_startup()
     NS_ENSURE_SUCCESS(rv, FALSE);
 
     nsCOMPtr<nsILocalFile> binDir;
-    rv = NS_NewNativeLocalFile(nsCString(LIBXUL_DIR"/components"), PR_TRUE,
+    rv = NS_NewNativeLocalFile(nsCString(LIBXUL_DIR), PR_TRUE,
                                getter_AddRefs(binDir));
     NS_ENSURE_SUCCESS(rv, FALSE);
 
-- 
1.5.4.3

_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar

Reply via email to