diff options
author | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2007-05-04 17:32:25 (GMT) |
---|---|---|
committer | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2007-05-04 17:32:25 (GMT) |
commit | bbb96e9c89e6e12fc2a83dc291514ba1859db325 (patch) | |
tree | 76767fd2f2789f27b53655c2a8cd45c064a97868 /browser/GeckoDirectoryProvider.cpp | |
parent | 2ad2b11d6c2751303495dea85dd74f48cb7191b0 (diff) |
Implemented saving web history to the journal. Ifdefed by now while we wait for a patch to be applied to mozilla upstream.
Diffstat (limited to 'browser/GeckoDirectoryProvider.cpp')
-rw-r--r-- | browser/GeckoDirectoryProvider.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/browser/GeckoDirectoryProvider.cpp b/browser/GeckoDirectoryProvider.cpp new file mode 100644 index 0000000..c94a7cf --- /dev/null +++ b/browser/GeckoDirectoryProvider.cpp @@ -0,0 +1,66 @@ +#include "GeckoDirectoryProvider.h" + +#include <nsCOMPtr.h> +#include <nsIIOService.h> +#include <nsNetUtil.h> +#include <nsArrayEnumerator.h> +#include <nsILocalFile.h> +#include <nsDirectoryServiceDefs.h> +#include <nsIToolkitChromeRegistry.h> +#include <nsIDirectoryService.h> +#include <nsCOMArray.h> + +#include <glib.h> + +NS_IMPL_ISUPPORTS2 (GeckoDirectoryProvider, + nsIDirectoryServiceProvider, + nsIDirectoryServiceProvider2) + +GeckoDirectoryProvider::GeckoDirectoryProvider(const char *sugar_path) +{ + mComponentPath = g_strconcat(sugar_path, "/mozilla/components", NULL); +} + +GeckoDirectoryProvider::~GeckoDirectoryProvider() +{ + if(mComponentPath) + g_free(mComponentPath); +} + +/* nsIFile getFile (in string prop, out PRBool persistent); */ +NS_IMETHODIMP +GeckoDirectoryProvider::GetFile (const char *prop, + PRBool *persistent, + nsIFile **_retval) +{ + return NS_ERROR_FAILURE; +} + +/* nsISimpleEnumerator getFiles (in string aProperty); */ +NS_IMETHODIMP +GeckoDirectoryProvider::GetFiles (const char *aProperty, nsISimpleEnumerator **aResult) +{ + nsresult rv = NS_ERROR_FAILURE; + + if (!strcmp(aProperty, NS_XPCOM_COMPONENT_DIR_LIST)) { + if (mComponentPath) { + nsCOMPtr<nsILocalFile> componentDir; + rv = NS_NewNativeLocalFile(nsDependentCString(mComponentPath), + PR_TRUE, + getter_AddRefs (componentDir)); + NS_ENSURE_SUCCESS (rv, rv); + + nsCOMArray<nsIFile> array; + + rv = array.AppendObject (componentDir); + NS_ENSURE_SUCCESS (rv, rv); + + rv = NS_NewArrayEnumerator (aResult, array); + NS_ENSURE_SUCCESS (rv, rv); + + rv = NS_SUCCESS_AGGREGATE_RESULT; + } + } + + return rv; +} |