Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-05-20 10:48:17 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-05-20 10:48:17 (GMT)
commitdd658dc8bbd6b38c434e0dc0805a97dabbf34516 (patch)
tree019560304e084912cfbbecf7095664cb15cadcf0 /src
parente085068631d4c891dc66e588d88f59c2f393ac92 (diff)
Implement components and profile support
Diffstat (limited to 'src')
-rw-r--r--src/HulahopDirectoryProvider.cpp53
-rw-r--r--src/HulahopDirectoryProvider.h11
-rw-r--r--src/__init__.py1
-rw-r--r--src/hulahop-browser.cpp17
-rw-r--r--src/hulahop-browser.h2
-rw-r--r--src/hulahop.defs16
6 files changed, 96 insertions, 4 deletions
diff --git a/src/HulahopDirectoryProvider.cpp b/src/HulahopDirectoryProvider.cpp
index dd7bf41..7d5d404 100644
--- a/src/HulahopDirectoryProvider.cpp
+++ b/src/HulahopDirectoryProvider.cpp
@@ -17,6 +17,11 @@
* Boston, MA 02111-1307, USA.
*/
+#include <nsILocalFile.h>
+#include <nsAppDirectoryServiceDefs.h>
+#include <nsDirectoryServiceDefs.h>
+#include <nsArrayEnumerator.h>
+
#include "HulahopDirectoryProvider.h"
NS_IMPL_QUERY_INTERFACE2(HulahopDirectoryProvider,
@@ -40,6 +45,25 @@ HulahopDirectoryProvider::GetFile(const char *aKey,
PRBool *aPersist,
nsIFile **aResult)
{
+ nsresult rv;
+
+ if (!strcmp(aKey, NS_APP_USER_PROFILE_50_DIR) && mProfilePath) {
+ NS_ADDREF(*aResult = mProfilePath);
+ return NS_OK;
+ }
+
+ if (!strcmp(aKey, NS_XPCOM_COMPONENT_REGISTRY_FILE) && mProfilePath) {
+ nsCOMPtr<nsIFile> file;
+ rv = mProfilePath->Clone(getter_AddRefs(file));
+ NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+
+ rv = file->AppendNative(nsCString("compreg.dat"));
+ NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+
+ NS_ADDREF(*aResult = file);
+ return NS_OK;
+ }
+
return NS_ERROR_FAILURE;
}
@@ -47,5 +71,32 @@ NS_IMETHODIMP
HulahopDirectoryProvider::GetFiles(const char *aKey,
nsISimpleEnumerator **aResult)
{
- return NS_ERROR_FAILURE;
+ nsresult rv = NS_ERROR_FAILURE;
+
+ if (!strcmp(aKey, NS_XPCOM_COMPONENT_DIR_LIST)) {
+ rv = NS_NewArrayEnumerator(aResult, mComponentsDirs);
+ }
+
+ return rv;
}
+
+void
+HulahopDirectoryProvider::SetProfilePath(const char *path)
+{
+ NS_NewNativeLocalFile(nsCString(path),
+ PR_TRUE, getter_AddRefs(mProfilePath));
+}
+
+void
+HulahopDirectoryProvider::AddComponentsPath(const char *path)
+{
+ nsresult rv;
+
+ nsCOMPtr<nsILocalFile> localFile;
+ rv = NS_NewNativeLocalFile(nsCString(path),
+ PR_TRUE, getter_AddRefs(localFile));
+ if (localFile) {
+ mComponentsDirs.AppendObject(localFile);
+ }
+}
+
diff --git a/src/HulahopDirectoryProvider.h b/src/HulahopDirectoryProvider.h
index c6b5669..5ddc891 100644
--- a/src/HulahopDirectoryProvider.h
+++ b/src/HulahopDirectoryProvider.h
@@ -17,13 +17,24 @@
* Boston, MA 02111-1307, USA.
*/
+#include <nsCOMPtr.h>
+#include <nsCOMArray.h>
#include <nsIDirectoryService.h>
class HulahopDirectoryProvider : public nsIDirectoryServiceProvider2
{
public:
+
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
+
+ void SetProfilePath (const char *path);
+ void AddComponentsPath (const char *path);
+
+ private:
+
+ nsCOMPtr<nsILocalFile> mProfilePath;
+ nsCOMArray<nsILocalFile> mComponentsDirs;
};
diff --git a/src/__init__.py b/src/__init__.py
index 879b38b..5052a51 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -16,6 +16,7 @@
# Boston, MA 02111-1307, USA.
from hulahop._hulahop import startup, shutdown
+from hulahop._hulahop import set_profile_path, add_components_path
startup()
diff --git a/src/hulahop-browser.cpp b/src/hulahop-browser.cpp
index f092ffc..6c09964 100644
--- a/src/hulahop-browser.cpp
+++ b/src/hulahop-browser.cpp
@@ -53,7 +53,7 @@ G_DEFINE_TYPE(HulahopBrowser, hulahop_browser, GTK_TYPE_BIN)
static GObjectClass *parent_class = NULL;
-static const HulahopDirectoryProvider kDirectoryProvider;
+static HulahopDirectoryProvider kDirectoryProvider;
gboolean
hulahop_startup()
@@ -75,8 +75,6 @@ hulahop_startup()
&kDirectoryProvider), nsnull, 0);
NS_ENSURE_SUCCESS(rv, FALSE);
- XRE_NotifyProfile();
-
return TRUE;
}
@@ -86,6 +84,19 @@ hulahop_shutdown()
XRE_TermEmbedding();
}
+void
+hulahop_set_profile_path(const char *path)
+{
+ kDirectoryProvider.SetProfilePath(path);
+ XRE_NotifyProfile();
+}
+
+void
+hulahop_add_components_path(const char *path)
+{
+ kDirectoryProvider.AddComponentsPath(path);
+}
+
static gboolean
child_focus_in_cb(GtkWidget *widget,
GdkEventFocus *event,
diff --git a/src/hulahop-browser.h b/src/hulahop-browser.h
index 0f15821..72c2d0c 100644
--- a/src/hulahop-browser.h
+++ b/src/hulahop-browser.h
@@ -37,6 +37,8 @@ typedef struct _HulahopBrowserClass HulahopBrowserClass;
gboolean hulahop_startup (void);
void hulahop_shutdown (void);
+void hulahop_set_profile_path (const char *path);
+void hulahop_add_components_path (const char *path);
GType hulahop_browser_get_type (void);
PyObject *hulahop_browser_get_browser (HulahopBrowser *browser);
diff --git a/src/hulahop.defs b/src/hulahop.defs
index 2278a9c..8df394b 100644
--- a/src/hulahop.defs
+++ b/src/hulahop.defs
@@ -26,3 +26,19 @@
(c-name "hulahop_shutdown")
(return-type "none")
)
+
+(define-function set_profile_path
+ (c-name "hulahop_set_profile_path")
+ (parameters
+ '("gchar*" "path")
+ )
+ (return-type "none")
+)
+
+(define-function add_components_path
+ (c-name "hulahop_add_components_path")
+ (parameters
+ '("gchar*" "path")
+ )
+ (return-type "none")
+)