Updated doc downloading to gecko 1.9
This commit is contained in:
parent
fbdc1579f4
commit
54b7420ef0
@ -1,8 +1,22 @@
|
|||||||
#include <nsCExternalHandlerService.h>
|
#include <nsCExternalHandlerService.h>
|
||||||
#include <nsIFile.h>
|
#include <nsIFile.h>
|
||||||
|
#include <nsIFactory.h>
|
||||||
|
|
||||||
#include "GeckoContentHandler.h"
|
#include "GeckoContentHandler.h"
|
||||||
|
|
||||||
|
class GeckoContentHandler : public nsIHelperAppLauncherDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSIHELPERAPPLAUNCHERDIALOG
|
||||||
|
|
||||||
|
GeckoContentHandler();
|
||||||
|
virtual ~GeckoContentHandler();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
GeckoContentHandler::GeckoContentHandler()
|
GeckoContentHandler::GeckoContentHandler()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -38,3 +52,65 @@ GeckoContentHandler::PromptForSaveToFile (nsIHelperAppLauncher *aLauncher,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// GeckoContentHandlerFactory
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
class GeckoContentHandlerFactory : public nsIFactory {
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSIFACTORY
|
||||||
|
|
||||||
|
GeckoContentHandlerFactory();
|
||||||
|
virtual ~GeckoContentHandlerFactory();
|
||||||
|
};
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS1(GeckoContentHandlerFactory, nsIFactory)
|
||||||
|
|
||||||
|
GeckoContentHandlerFactory::GeckoContentHandlerFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
GeckoContentHandlerFactory::~GeckoContentHandlerFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP GeckoContentHandlerFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
|
|
||||||
|
*aResult = NULL;
|
||||||
|
GeckoContentHandler *inst = new GeckoContentHandler;
|
||||||
|
if (!inst)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||||
|
if (rv != NS_OK) {
|
||||||
|
// We didn't get the right interface, so clean up
|
||||||
|
delete inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP GeckoContentHandlerFactory::LockFactory(PRBool lock)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
nsresult NS_NewGeckoContentHandlerFactory(nsIFactory** aFactory)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aFactory);
|
||||||
|
*aFactory = nsnull;
|
||||||
|
|
||||||
|
GeckoContentHandlerFactory *result = new GeckoContentHandlerFactory;
|
||||||
|
if (!result)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
NS_ADDREF(result);
|
||||||
|
*aFactory = result;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
@ -12,17 +12,8 @@
|
|||||||
{0x96, 0x7b, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f} \
|
{0x96, 0x7b, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f} \
|
||||||
}
|
}
|
||||||
|
|
||||||
class GeckoContentHandler : public nsIHelperAppLauncherDialog
|
class nsIFactory;
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSIHELPERAPPLAUNCHERDIALOG
|
|
||||||
|
|
||||||
GeckoContentHandler();
|
extern "C" NS_EXPORT nsresult NS_NewGeckoContentHandlerFactory(nsIFactory** aFactory);
|
||||||
virtual ~GeckoContentHandler();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __GECKO_CONTENT_HANDLER_H */
|
#endif /* __GECKO_CONTENT_HANDLER_H */
|
||||||
|
@ -1,7 +1,27 @@
|
|||||||
|
#include <nsIFactory.h>
|
||||||
|
|
||||||
#include "sugar-download-manager.h"
|
#include "sugar-download-manager.h"
|
||||||
|
|
||||||
#include "GeckoDownload.h"
|
#include "GeckoDownload.h"
|
||||||
|
|
||||||
|
class GeckoDownload : public nsITransfer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GeckoDownload();
|
||||||
|
virtual ~GeckoDownload();
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||||
|
NS_DECL_NSIWEBPROGRESSLISTENER2
|
||||||
|
NS_DECL_NSITRANSFER
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsIURI *mSource;
|
||||||
|
nsCString mTargetFileName;
|
||||||
|
nsIMIMEInfo *mMIMEInfo;
|
||||||
|
nsILocalFile *mTempFile;
|
||||||
|
};
|
||||||
|
|
||||||
GeckoDownload::GeckoDownload ()
|
GeckoDownload::GeckoDownload ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -127,3 +147,65 @@ GeckoDownload::OnSecurityChange (nsIWebProgress *aWebProgress,
|
|||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
//*****************************************************************************
|
||||||
|
// GeckoDownloadFactory
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
class GeckoDownloadFactory : public nsIFactory {
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSIFACTORY
|
||||||
|
|
||||||
|
GeckoDownloadFactory();
|
||||||
|
virtual ~GeckoDownloadFactory();
|
||||||
|
};
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS1(GeckoDownloadFactory, nsIFactory)
|
||||||
|
|
||||||
|
GeckoDownloadFactory::GeckoDownloadFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
GeckoDownloadFactory::~GeckoDownloadFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP GeckoDownloadFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
|
|
||||||
|
*aResult = NULL;
|
||||||
|
GeckoDownload *inst = new GeckoDownload;
|
||||||
|
if (!inst)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||||
|
if (rv != NS_OK) {
|
||||||
|
// We didn't get the right interface, so clean up
|
||||||
|
delete inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP GeckoDownloadFactory::LockFactory(PRBool lock)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
nsresult NS_NewGeckoDownloadFactory(nsIFactory** aFactory)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aFactory);
|
||||||
|
*aFactory = nsnull;
|
||||||
|
|
||||||
|
GeckoDownloadFactory *result = new GeckoDownloadFactory;
|
||||||
|
if (!result)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
NS_ADDREF(result);
|
||||||
|
*aFactory = result;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
@ -18,22 +18,8 @@
|
|||||||
{0x96, 0x7e, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f} \
|
{0x96, 0x7e, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f} \
|
||||||
}
|
}
|
||||||
|
|
||||||
class GeckoDownload : public nsITransfer
|
class nsIFactory;
|
||||||
{
|
|
||||||
public:
|
|
||||||
GeckoDownload();
|
|
||||||
virtual ~GeckoDownload();
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
|
||||||
NS_DECL_NSIWEBPROGRESSLISTENER2
|
|
||||||
NS_DECL_NSITRANSFER
|
|
||||||
|
|
||||||
protected:
|
extern "C" NS_EXPORT nsresult NS_NewGeckoDownloadFactory(nsIFactory** aFactory);
|
||||||
nsIURI *mSource;
|
|
||||||
nsCString mTargetFileName;
|
|
||||||
nsIMIMEInfo *mMIMEInfo;
|
|
||||||
nsILocalFile *mTempFile;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __GECKO_DOWNLOAD_H__
|
#endif // __GECKO_DOWNLOAD_H__
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include <nsIGenericFactory.h>
|
#include <nsIGenericFactory.h>
|
||||||
#include <nsIHelperAppLauncherDialog.h>
|
#include <nsIHelperAppLauncherDialog.h>
|
||||||
#include <nsIComponentRegistrar.h>
|
#include <nsIComponentRegistrar.h>
|
||||||
#include <nsIComponentManager.h>
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -47,28 +46,21 @@ enum {
|
|||||||
PROP_LOADING
|
PROP_LOADING
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef HAVE_GECKO_1_9
|
|
||||||
|
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(GeckoContentHandler)
|
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(GeckoDownload)
|
|
||||||
|
|
||||||
static const nsModuleComponentInfo sSugarComponents[] = {
|
static const nsModuleComponentInfo sSugarComponents[] = {
|
||||||
{
|
{
|
||||||
"Gecko Content Handler",
|
"Gecko Content Handler",
|
||||||
GECKOCONTENTHANDLER_CID,
|
GECKOCONTENTHANDLER_CID,
|
||||||
NS_IHELPERAPPLAUNCHERDLG_CONTRACTID,
|
NS_IHELPERAPPLAUNCHERDLG_CONTRACTID,
|
||||||
GeckoContentHandlerConstructor
|
NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Gecko Download",
|
"Gecko Download",
|
||||||
GECKODOWNLOAD_CID,
|
GECKODOWNLOAD_CID,
|
||||||
NS_TRANSFER_CONTRACTID,
|
NS_TRANSFER_CONTRACTID,
|
||||||
GeckoDownloadConstructor
|
NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_plugin_path ()
|
setup_plugin_path ()
|
||||||
{
|
{
|
||||||
@ -120,49 +112,32 @@ sugar_browser_startup(const char *profile_path, const char *profile_name)
|
|||||||
g_warning ("failed to read user preferences, error: %x", rv);
|
g_warning ("failed to read user preferences, error: %x", rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_GECKO_1_9
|
|
||||||
|
|
||||||
/* Register our components */
|
|
||||||
nsCOMPtr<nsIComponentRegistrar> componentRegistrar;
|
nsCOMPtr<nsIComponentRegistrar> componentRegistrar;
|
||||||
NS_GetComponentRegistrar(getter_AddRefs(componentRegistrar));
|
NS_GetComponentRegistrar(getter_AddRefs(componentRegistrar));
|
||||||
NS_ENSURE_TRUE (componentRegistrar, FALSE);
|
NS_ENSURE_TRUE (componentRegistrar, FALSE);
|
||||||
|
|
||||||
nsCOMPtr<nsIComponentManager> componentManager;
|
nsCOMPtr<nsIFactory> contentHandlerFactory;
|
||||||
NS_GetComponentManager (getter_AddRefs (componentManager));
|
rv = NS_NewGeckoContentHandlerFactory(getter_AddRefs(contentHandlerFactory));
|
||||||
NS_ENSURE_TRUE (componentManager, FALSE);
|
rv = componentRegistrar->RegisterFactory(sSugarComponents[0].mCID,
|
||||||
|
sSugarComponents[0].mDescription,
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(sSugarComponents); i++) {
|
sSugarComponents[0].mContractID,
|
||||||
|
contentHandlerFactory);
|
||||||
nsCOMPtr<nsIGenericFactory> componentFactory;
|
if (NS_FAILED(rv)) {
|
||||||
rv = NS_NewGenericFactory(getter_AddRefs(componentFactory),
|
g_warning ("Failed to register factory for %s\n", sSugarComponents[0].mDescription);
|
||||||
&(sSugarComponents[i]));
|
return FALSE;
|
||||||
if (NS_FAILED(rv) || !componentFactory) {
|
}
|
||||||
g_warning ("Failed to make a factory for %s\n", sSugarComponents[i].mDescription);
|
|
||||||
return FALSE;
|
nsCOMPtr<nsIFactory> downloadFactory;
|
||||||
}
|
rv = NS_NewGeckoDownloadFactory(getter_AddRefs(downloadFactory));
|
||||||
|
rv = componentRegistrar->RegisterFactory(sSugarComponents[1].mCID,
|
||||||
rv = componentRegistrar->RegisterFactory(sSugarComponents[i].mCID,
|
sSugarComponents[1].mDescription,
|
||||||
sSugarComponents[i].mDescription,
|
sSugarComponents[1].mContractID,
|
||||||
sSugarComponents[i].mContractID,
|
downloadFactory);
|
||||||
componentFactory);
|
if (NS_FAILED(rv)) {
|
||||||
if (NS_FAILED(rv)) {
|
g_warning ("Failed to register factory for %s\n", sSugarComponents[1].mDescription);
|
||||||
g_warning ("Failed to register factory for %s\n", sSugarComponents[i].mDescription);
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sSugarComponents[i].mRegisterSelfProc) {
|
|
||||||
rv = sSugarComponents[i].mRegisterSelfProc(componentManager, nsnull,
|
|
||||||
nsnull, nsnull,
|
|
||||||
&sSugarComponents[i]);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
g_warning ("Failed to register-self for %s\n", sSugarComponents[i].mDescription);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user