diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-04-26 20:01:39 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-04-26 20:01:39 +0800 |
commit | cf8d507e4c6272a5e3f1b2a65724f1938d7d246d (patch) | |
tree | 9e53ce6bfc5eab160d37fb094b99bb4df5bdd862 | |
parent | dbf352aded24013b511267d19c82fa017846ea73 (diff) | |
download | gsoc2013-epiphany-cf8d507e4c6272a5e3f1b2a65724f1938d7d246d.tar gsoc2013-epiphany-cf8d507e4c6272a5e3f1b2a65724f1938d7d246d.tar.gz gsoc2013-epiphany-cf8d507e4c6272a5e3f1b2a65724f1938d7d246d.tar.bz2 gsoc2013-epiphany-cf8d507e4c6272a5e3f1b2a65724f1938d7d246d.tar.lz gsoc2013-epiphany-cf8d507e4c6272a5e3f1b2a65724f1938d7d246d.tar.xz gsoc2013-epiphany-cf8d507e4c6272a5e3f1b2a65724f1938d7d246d.tar.zst gsoc2013-epiphany-cf8d507e4c6272a5e3f1b2a65724f1938d7d246d.zip |
Ged rid of all API checks which check for 1.8-only API, and introduce a
2005-04-26 Christian Persch <chpe@cvs.gnome.org>
* configure.ac:
Ged rid of all API checks which check for 1.8-only API, and introduce
a Gecko version check instead.
* embed/mozilla/ContentHandler.cpp:
* embed/mozilla/ContentHandler.h:
* embed/mozilla/EventContext.cpp:
* embed/mozilla/GlobalHistory.cpp:
* embed/mozilla/GtkNSSKeyPairDialogs.cpp:
* embed/mozilla/MozDownload.cpp:
* embed/mozilla/MozDownload.h:
* embed/mozilla/mozilla-download.cpp:
Fix for mozilla API change, and use the new HAVE_GECKO_1_8 define
where appropriate.
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | configure.ac | 144 | ||||
-rw-r--r-- | embed/mozilla/ContentHandler.cpp | 20 | ||||
-rw-r--r-- | embed/mozilla/ContentHandler.h | 4 | ||||
-rw-r--r-- | embed/mozilla/EventContext.cpp | 6 | ||||
-rw-r--r-- | embed/mozilla/GlobalHistory.cpp | 2 | ||||
-rw-r--r-- | embed/mozilla/GtkNSSKeyPairDialogs.cpp | 22 | ||||
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 117 | ||||
-rw-r--r-- | embed/mozilla/MozDownload.h | 52 | ||||
-rw-r--r-- | embed/mozilla/mozilla-download.cpp | 3 |
10 files changed, 184 insertions, 205 deletions
@@ -1,3 +1,22 @@ +2005-04-26 Christian Persch <chpe@cvs.gnome.org> + + * configure.ac: + + Ged rid of all API checks which check for 1.8-only API, and introduce + a Gecko version check instead. + + * embed/mozilla/ContentHandler.cpp: + * embed/mozilla/ContentHandler.h: + * embed/mozilla/EventContext.cpp: + * embed/mozilla/GlobalHistory.cpp: + * embed/mozilla/GtkNSSKeyPairDialogs.cpp: + * embed/mozilla/MozDownload.cpp: + * embed/mozilla/MozDownload.h: + * embed/mozilla/mozilla-download.cpp: + + Fix for mozilla API change, and use the new HAVE_GECKO_1_8 define + where appropriate. + 2005-04-24 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_solve_smart_url): diff --git a/configure.ac b/configure.ac index d644e002e..756e5fb6a 100644 --- a/configure.ac +++ b/configure.ac @@ -278,6 +278,30 @@ AC_RUN_IFELSE( AC_MSG_RESULT([$result]) +dnl Determine gecko version +dnl We don't use the version from the .pc file, since that's the app version +dnl and not the Gecko version + +AC_MSG_CHECKING([[for gecko version]]) + +AC_PREPROC_IFELSE( + [AC_LANG_SOURCE( + [[#include <mozilla-config.h> + #define _DECL_VERSION(major,minor) ((major << 8) + minor) + #if (_DECL_VERSION(MOZILLA_VERSION_MAJOR,MOZILLA_VERSION_MINOR) < _DECL_VERSION(1,8)) + #error No + #endif]] + )], + [have_gecko_1_8=yes gecko_version="1.8"], + [have_gecko_1_8=no gecko_version="1.7"]) + +AC_MSG_RESULT([$gecko_version]) + +if test "x$have_gecko_1_8" = "xyes"; then + AC_DEFINE([HAVE_GECKO_1_8],[1],[Define if we have gecko 1.8]) +fi +AM_CONDITIONAL([HAVE_GECKO_1_8],[test "x$have_gecko_1_8" = "xyes"]) + dnl Changed from PRUnichar* to nsAString& in 1.8a1 and on aviary branch AC_MSG_CHECKING([whether nsIFilePicker methods expect nsAString&]) @@ -294,22 +318,6 @@ AC_COMPILE_IFELSE( AC_MSG_RESULT([$result]) -dnl Changed from char* to nsAString& in 1.8a1 - -AC_MSG_CHECKING([whether nsIMIMEInfo methods expect nsAString&]) - -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include <nsEmbedString.h> - #include <mimetype/nsIMIMEInfo.h>]], - [[nsIMIMEInfo *p; - p->SetDescription (nsEmbedString());]] - )], - [AC_DEFINE([MOZ_NSIMIMEINFO_NSACSTRING_],[1],[Define if nsIMIMEInfo uses nsAString&]) result=yes], - [result=no]) - -AC_MSG_RESULT([$result]) - dnl Changed in 1.8a1 and again in 1.8a3 to its present form (variant 2); dnl variant 1 is on 1.7 branch. Aviary branch also has variant 2. @@ -331,23 +339,6 @@ AC_DEFINE_UNQUOTED([MOZ_NSICONTENTPOLICY_VARIANT], [$variant], [Define the nsICo AC_MSG_RESULT([variant $variant]) -dnl changed in 1.8a4 - -AC_MSG_CHECKING([for whether nsIGlobalHistory2::AddURI takes a referrer]) - -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include <nsIURI.h> - #include <nsIGlobalHistory.h> - #include <docshell/nsIGlobalHistory2.h>]], - [[nsIGlobalHistory2 *p; - p->AddURI(nsnull,PR_FALSE,PR_FALSE,nsnull);]] - )], - [AC_DEFINE([MOZ_NSIGLOBALHISTORY2_ADDURI_WITH_REFERRER],[1],[Define if nsIGlobalHistory2::AddURI takes a referrer]) result=yes], - [result=no]) - -AC_MSG_RESULT([$result]) - dnl Firefox doesn't have this API (?) AC_MSG_CHECKING([for nsIXULChromeRegistry API]) @@ -384,80 +375,12 @@ AC_COMPILE_IFELSE( AC_MSG_RESULT([$result]) -dnl Added in 1.8a6 on trunk -dnl https://bugzilla.mozilla.org/show_bug.cgi?id=223310 - -AC_MSG_CHECKING([whether nsIKeygenThread::StartKeyGeneration takes an nsIObserver]) - -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include <pipnss/nsIKeygenThread.h> - #include <nsIObserver.h>]], - [[nsIKeygenThread *p; - nsIObserver *obs; - p->StartKeyGeneration (obs);]] - )], - [AC_DEFINE([HAVE_NSIKEYGENTHREAD_NSIOBSERVER],[1], - [Define if nsIKeygenThread::StartKeyGeneration takes an nsIObserver]) result=yes], - [result=no]) - -AC_MSG_RESULT([$result]) - -dnl Since 1.8a6 - -AC_MSG_CHECKING([for nsIDownload::GetSize]) - -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include <uriloader/nsIDownload.h>]], - [[nsIDownload *p; - p->GetSize(nsnull);]] - )], - [AC_DEFINE([MOZ_NSIDOWNLOAD_GETSIZE],[1],[Define if nsIDownload::GetSize exists]) result=yes], - [result=no]) - -AC_MSG_RESULT([$result]) - -dnl Changed from PRBool to PRUin32 in 1.8b2 - -AC_MSG_CHECKING([for nsIHelperAppLauncherDialog::Show arguments]) - -AC_COMPILE_IFELSE( - [AC_LANG_SOURCE( - [[#include <exthandler/nsIHelperAppLauncherDialog.h> - - class Test : public nsIHelperAppLauncherDialog - { public: NS_DECL_NSIHELPERAPPLAUNCHERDIALOG }; - - NS_IMETHODIMP Test::Show(nsIHelperAppLauncher *aLauncher, nsISupports *aContext, PRUint32 aReason) - { return NS_ERROR_NOT_IMPLEMENTED; } - ]] - )], - [AC_DEFINE([MOZ_NSIHELPERAPPLAUNCHERDIALOG_UNSIGNED],[1],[Define if nsIHelperAppLauncherDialog::Show takes unsigned integer]) result=unsigned], - [result=signed]) - -AC_MSG_RESULT([$result]) - -dnl exists since 1.8a6 - -AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/nsITransfer.h], - [AC_DEFINE([HAVE_NSITRANSFER_H],[1],[Define if nsITransfer.h exists])], - [AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/uriloader/nsITransfer.h], - [AC_DEFINE([HAVE_NSITRANSFER_H],[1],[Define if nsITransfer.h exists])])]) - -dnl exists since 1.8b2 - -AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/nsICancelable.h], - [AC_DEFINE([HAVE_NSICANCELABLE_H],[1],[Define if nsICancelable.h exists])], - [AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/necko/nsICancelable.h], - [AC_DEFINE([HAVE_NSICANCELABLE_H],[1],[Define if nsICancelable.h exists])])]) - dnl check for broken reload in GtkMozEmbed dnl This is fixed since 1.7.4 on 1.7 branch, and since 1.8a3 on trunk AC_MSG_CHECKING([for broken reload]) -if $PKG_CONFIG --atleast-version 1.7.5 $MOZILLA-gtkmozembed; then +if $PKG_CONFIG --atleast-version=1.7.5 $MOZILLA-gtkmozembed; then broken_reload=no else broken_reload="couldn't autodetect, assuming yes" @@ -466,21 +389,6 @@ fi AC_MSG_RESULT([$broken_reload]) -dnl check for broken contextmenu event -dnl This is fixed since 1.8a4 -dnl https://bugzilla.mozilla.org/show_bug.cgi?id=258193 - -AC_MSG_CHECKING([for broken context menu event]) - -if $PKG_CONFIG --atleast-version 1.8 $MOZILLA-gtkmozembed; then - broken_context_event=no -else - broken_context_event="couldn't autodetect, assuming yes" - AC_DEFINE([MOZ_BROKEN_CTX_MENU_EVENT],[1],[Define if mozilla has a broken context menu event]) -fi - -AC_MSG_RESULT([$broken_context_event]) - dnl changed location in 1.8a6 AC_MSG_CHECKING([for mozilla security compoment]) @@ -529,7 +437,7 @@ AC_MSG_CHECKING([whether to enable native gtk+ filepicker]) AC_ARG_ENABLE([filepicker], AS_HELP_STRING([--enable-filepicker],[Whether to enable the gtk+ native filepicker; not needed when the mozilla build itself has native gtk+ filepicker enabled (default:enabled)]), [filepicker=$enableval], - [filepicker=yes]) + [if test "x$have_gecko_1_8"; then filepicker=no; else filepicker=yes; fi]) AC_MSG_RESULT([$filepicker]) AM_CONDITIONAL([ENABLE_FILEPICKER],[test "x$filepicker" = "xyes"]) diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp index d13114a95..db4edb9f5 100644 --- a/embed/mozilla/ContentHandler.cpp +++ b/embed/mozilla/ContentHandler.cpp @@ -65,7 +65,7 @@ /* FIXME: we don't generally have a timestamp for the user action which initiated this * content handler. */ -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 GContentHandler::GContentHandler() : mUserTime(0) { @@ -84,7 +84,7 @@ GContentHandler::~GContentHandler() { LOG ("GContentHandler dtor (%p)", this); -#ifndef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifndef HAVE_GECKO_1_8 if (mMimeType) { nsMemory::Free (mMimeType); @@ -94,7 +94,7 @@ GContentHandler::~GContentHandler() NS_IMPL_ISUPPORTS1(GContentHandler, nsIHelperAppLauncherDialog) -#ifdef MOZ_NSIHELPERAPPLAUNCHERDIALOG_UNSIGNED +#ifdef HAVE_GECKO_1_8 /* void show (in nsIHelperAppLauncher aLauncher, in nsISupports aContext, in unsigned long aReason); */ NS_IMETHODIMP GContentHandler::Show (nsIHelperAppLauncher *aLauncher, @@ -120,7 +120,7 @@ GContentHandler::Show (nsIHelperAppLauncher *aLauncher, NS_ENSURE_SUCCESS (rv, rv); single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)); -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 g_signal_emit_by_name (single, "handle_content", mMimeType.get(), mUrl.get(), &handled); #else @@ -134,7 +134,7 @@ GContentHandler::Show (nsIHelperAppLauncher *aLauncher, } else { -#ifdef HAVE_NSICANCELABLE_H +#ifdef HAVE_GECKO_1_8 mLauncher->Cancel (NS_BINDING_ABORTED); #else mLauncher->Cancel (); @@ -225,7 +225,7 @@ NS_METHOD GContentHandler::Init () mLauncher->GetMIMEInfo (getter_AddRefs(MIMEInfo)); NS_ENSURE_TRUE (MIMEInfo, NS_ERROR_FAILURE); -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 rv = MIMEInfo->GetMIMEType (mMimeType); #else rv = MIMEInfo->GetMIMEType (&mMimeType); @@ -356,7 +356,7 @@ NS_METHOD GContentHandler::MIMEInitiateAction (void) auto_downloads = eel_gconf_get_boolean (CONF_AUTO_DOWNLOADS); -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 mHelperApp = gnome_vfs_mime_get_default_application (mMimeType.get()); mPermission = ephy_file_check_mime (mMimeType.get()); #else @@ -420,7 +420,7 @@ NS_METHOD GContentHandler::MIMEDoAction (void) /* HACK we use the application description to ask MozDownload to open the file when download is finished */ -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 mimeInfo->SetApplicationDescription (desc); #else mimeInfo->SetApplicationDescription (desc.get()); @@ -428,7 +428,7 @@ NS_METHOD GContentHandler::MIMEDoAction (void) } else { -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 mimeInfo->SetApplicationDescription (nsEmbedString ()); #else mimeInfo->SetApplicationDescription (nsnull); @@ -445,7 +445,7 @@ NS_METHOD GContentHandler::MIMEDoAction (void) } else if (mAction == CONTENT_ACTION_NONE) { -#ifdef HAVE_NSICANCELABLE_H +#ifdef HAVE_GECKO_1_8 mLauncher->Cancel (NS_BINDING_ABORTED); #else mLauncher->Cancel (); diff --git a/embed/mozilla/ContentHandler.h b/embed/mozilla/ContentHandler.h index 1df7e37cf..7498a80f0 100644 --- a/embed/mozilla/ContentHandler.h +++ b/embed/mozilla/ContentHandler.h @@ -22,8 +22,6 @@ #ifndef CONTENT_HANDLER_H #define CONTENT_HANDLER_H -#include "config.h" - #include "ephy-file-helpers.h" #include <libgnomevfs/gnome-vfs-mime-handlers.h> @@ -79,7 +77,7 @@ class GContentHandler : public nsIHelperAppLauncherDialog EphyMimePermission mPermission; nsEmbedCString mUrl; -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 nsEmbedCString mMimeType; #else char *mMimeType; diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp index 21a4f5096..7333907db 100644 --- a/embed/mozilla/EventContext.cpp +++ b/embed/mozilla/EventContext.cpp @@ -619,11 +619,13 @@ nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, Mozilla info->button = 3; break; -#ifdef MOZ_BROKEN_CTX_MENU_EVENT +#ifndef HAVE_GECKO_1_8 case 1729: /* This only appears to happen when getting a mouse context menu * signal, so map it to button 3 (right mouse button) - * http://bugzilla.mozilla.org/show_bug.cgi?id=258193 */ + * http://bugzilla.mozilla.org/show_bug.cgi?id=258193 + * Fixed since 1.8a4 + */ info->button = 3; break; #endif diff --git a/embed/mozilla/GlobalHistory.cpp b/embed/mozilla/GlobalHistory.cpp index 4e4bc29b3..ba6001b9a 100644 --- a/embed/mozilla/GlobalHistory.cpp +++ b/embed/mozilla/GlobalHistory.cpp @@ -46,7 +46,7 @@ MozGlobalHistory::~MozGlobalHistory () { } -#ifdef MOZ_NSIGLOBALHISTORY2_ADDURI_WITH_REFERRER +#ifdef HAVE_GECKO_1_8 /* void addURI (in nsIURI aURI, in boolean aRedirect, in boolean aToplevel, in nsIURI aReferrer); */ NS_IMETHODIMP MozGlobalHistory::AddURI(nsIURI *aURI, PRBool aRedirect, PRBool aToplevel, nsIURI *aReferrer) #else diff --git a/embed/mozilla/GtkNSSKeyPairDialogs.cpp b/embed/mozilla/GtkNSSKeyPairDialogs.cpp index 47d0eb840..83744ba6e 100644 --- a/embed/mozilla/GtkNSSKeyPairDialogs.cpp +++ b/embed/mozilla/GtkNSSKeyPairDialogs.cpp @@ -46,14 +46,14 @@ #include <nsIInterfaceRequestorUtils.h> #include <nsIKeygenThread.h> -#ifdef HAVE_NSIKEYGENTHREAD_NSIOBSERVER +#ifdef HAVE_GECKO_1_8 #include <nsIObserver.h> -#else /* !HAVE_NSIKEYGENTHREAD_NSIOBSERVER */ +#else /* !HAVE_GECKO_1_8 */ #include <nsIDOMWindow.h> #ifdef ALLOW_PRIVATE_API #include "nsIDOMWindowInternal.h" #endif /* ALLOW_PRIVATE_API */ -#endif /* HAVE_NSIKEYGENTHREAD_NSIOBSERVER */ +#endif /* HAVE_GECKO_1_8 */ #include <gtk/gtkdialog.h> #include <gtk/gtkprogressbar.h> @@ -82,7 +82,7 @@ GtkNSSKeyPairDialogs::~GtkNSSKeyPairDialogs () NS_IMPL_ISUPPORTS1 (GtkNSSKeyPairDialogs, nsIGeneratingKeypairInfoDialogs) -#ifdef HAVE_NSIKEYGENTHREAD_NSIOBSERVER +#ifdef HAVE_GECKO_1_8 class KeyPairObserver : public nsIObserver { @@ -105,7 +105,7 @@ NS_IMETHODIMP KeyPairObserver::Observe (nsISupports *aSubject, const char *aTopi return NS_OK; } -#else /* !HAVE_NSIKEYGENTHREAD_NSIOBSERVER */ +#else /* !HAVE_GECKO_1_8 */ /* ------------------------------------------------------------ * A dummy implementation of nsIDomWindowInternal so that @@ -140,7 +140,7 @@ NS_IMETHODIMP KeyPairHelperWindow::Close() return NS_OK; } -#endif /* HAVE_NSIKEYGENTHREAD_NSIOBSERVER */ +#endif /* HAVE_GECKO_1_8 */ /* ------------------------------------------------------------ */ static void @@ -167,11 +167,11 @@ struct KeyPairInfo { GtkWidget *progress; GtkWidget *dialog; -#ifdef HAVE_NSIKEYGENTHREAD_NSIOBSERVER +#ifdef HAVE_GECKO_1_8 KeyPairObserver *helper; #else KeyPairHelperWindow *helper; -#endif /* HAVE_NSIKEYGENTHREAD_NSIOBSERVER */ +#endif /* HAVE_GECKO_1_8 */ }; @@ -238,7 +238,7 @@ GtkNSSKeyPairDialogs::DisplayGeneratingKeypairInfo (nsIInterfaceRequestor *ctx, /* Create a helper class that just waits for close events * from the other thread */ -#ifdef HAVE_NSIKEYGENTHREAD_NSIOBSERVER +#ifdef HAVE_GECKO_1_8 nsCOMPtr<KeyPairObserver> helper = new KeyPairObserver; #else nsCOMPtr<KeyPairHelperWindow> helper = new KeyPairHelperWindow; @@ -268,7 +268,7 @@ GtkNSSKeyPairDialogs::DisplayGeneratingKeypairInfo (nsIInterfaceRequestor *ctx, return NS_OK; } -#ifndef HAVE_NSIKEYGENTHREAD_NSIOBSERVER +#ifndef HAVE_GECKO_1_8 /************************************************************* * Misc functions for the nsIDomWindowInternal implementation @@ -756,4 +756,4 @@ NS_IMETHODIMP KeyPairHelperWindow::GetWindowRoot(nsIDOMEventTarget * *aWindowRoo MOZ_NOT_IMPLEMENTED } -#endif /* !HAVE_NSIKEYGENTHREAD_NSIOBSERVER */ +#endif /* !HAVE_GECKO_1_8 */ diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp index 302c5b41a..d2610b941 100644 --- a/embed/mozilla/MozDownload.cpp +++ b/embed/mozilla/MozDownload.cpp @@ -56,13 +56,18 @@ #include <libgnomevfs/gnome-vfs-utils.h> #include <glib/gi18n.h> +#include <nsIDOMDocument.h> +#include <nsILocalFile.h> +#include <nsIWebBrowserPersist.h> +#include <nsIObserver.h> +#include <nsIRequest.h> #include <nsIFileURL.h> #undef MOZILLA_INTERNAL_API #include <nsEmbedString.h> #define MOZILLA_INTERNAL_API 1 #include <nsMemory.h> +#include <nsNetError.h> -#include <errno.h> #include <stdlib.h> const char* const persistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1"; @@ -85,26 +90,53 @@ MozDownload::~MozDownload() NS_ASSERTION (!mEphyDownload, "MozillaDownload still alive!"); } -#ifdef HAVE_NSITRANSFER_H +#ifdef HAVE_GECKO_1_8 NS_IMPL_ISUPPORTS3(MozDownload, nsIWebProgressListener, nsIWebProgressListener2, nsITransfer) #else NS_IMPL_ISUPPORTS3(MozDownload, nsIWebProgressListener, nsIDownload, nsITransfer) #endif +#ifdef HAVE_GECKO_1_8 +nsresult +MozDownload::InitForEmbed (nsIURI *aSource, nsIURI *aTarget, const nsAString &aDisplayName, + nsIMIMEInfo *aMIMEInfo, PRTime aStartTime, nsICancelable *aCancelable, + MozillaEmbedPersist *aEmbedPersist, PRInt64 aMaxSize) +{ + mEmbedPersist = aEmbedPersist; + mMaxSize = aMaxSize; + return Init (aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime, aCancelable); +} +#else nsresult MozDownload::InitForEmbed (nsIURI *aSource, nsIURI *aTarget, const PRUnichar *aDisplayName, nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist, - MozillaEmbedPersist *aEmbedPersist, PRInt32 aMaxSize) + MozillaEmbedPersist *aEmbedPersist, PRInt64 aMaxSize) { mEmbedPersist = aEmbedPersist; mMaxSize = aMaxSize; return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aPersist); } +#endif +#ifdef HAVE_GECKO_1_8 +/* void init (in nsIURI aSource, in nsIURI aTarget, in AString aDisplayName, in nsIMIMEInfo aMIMEInfo, in PRTime startTime, in nsICancelable aCancelable); */ +NS_IMETHODIMP +MozDownload::Init (nsIURI *aSource, + nsIURI *aTarget, + const nsAString &aDisplayName, + nsIMIMEInfo *aMIMEInfo, + PRTime aStartTime, + nsICancelable *aCancelable) +#else /* void init (in nsIURI aSource, in nsIURI aTarget, in wstring aDisplayName, in nsIMIMEInfo aMIMEInfo, in long long startTime, in nsIWebBrowserPersist aPersist); */ NS_IMETHODIMP -MozDownload::Init(nsIURI *aSource, nsIURI *aTarget, const PRUnichar *aDisplayName, - nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist) +MozDownload::Init (nsIURI *aSource, + nsIURI *aTarget, + const PRUnichar *aDisplayName, + nsIMIMEInfo *aMIMEInfo, + PRInt64 aStartTime, + nsIWebBrowserPersist *aPersist) +#endif { PRBool addToView = PR_TRUE; @@ -119,7 +151,7 @@ MozDownload::Init(nsIURI *aSource, nsIURI *aTarget, const PRUnichar *aDisplayNam mSource = aSource; mDestination = aTarget; - mStartTime = startTime; + mStartTime = aStartTime; mTotalProgress = 0; mCurrentProgress = 0; mPercentComplete = 0; @@ -127,11 +159,16 @@ MozDownload::Init(nsIURI *aSource, nsIURI *aTarget, const PRUnichar *aDisplayNam mLastUpdate = mStartTime; mMIMEInfo = aMIMEInfo; +#ifdef HAVE_GECKO_1_8 + /* This will create a refcount cycle, which needs to be broken in ::OnStateChange */ + mCancelable = aCancelable; +#else if (aPersist) { mWebPersist = aPersist; aPersist->SetProgressListener(this); } +#endif if (addToView) { @@ -161,7 +198,7 @@ MozDownload::GetSource(nsIURI **aSource) return NS_OK; } -#ifndef HAVE_NSITRANSFER_H +#ifndef HAVE_GECKO_1_8 NS_IMETHODIMP MozDownload::GetTarget(nsIURI **aTarget) { @@ -187,7 +224,7 @@ MozDownload::GetTargetFile (nsILocalFile** aTargetFile) return rv; } -#ifndef HAVE_NSITRANSFER_H +#ifndef HAVE_GECKO_1_8 NS_IMETHODIMP MozDownload::GetPersist(nsIWebBrowserPersist **aPersist) { @@ -207,24 +244,7 @@ MozDownload::GetPercentComplete(PRInt32 *aPercentComplete) return NS_OK; } -#ifndef HAVE_NSITRANSFER_H -#ifdef MOZ_NSIDOWNLOAD_GETSIZE -/* readonly attribute PRUint64 amountTransferred; */ -NS_IMETHODIMP -MozDownload::GetAmountTransferred(PRUint64 *aAmountTransferred) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* readonly attribute PRUint64 size; */ -NS_IMETHODIMP -MozDownload::GetSize(PRUint64 *aSize) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -#endif /* MOZ_NSIDOWNLOAD_GETSIZE */ - +#ifndef HAVE_GECKO_1_8 NS_IMETHODIMP MozDownload::GetStartTime(PRInt64 *aStartTime) { @@ -245,7 +265,7 @@ MozDownload::SetDisplayName(const PRUnichar * aDisplayName) { return NS_ERROR_NOT_IMPLEMENTED; } -#endif /* !HAVE_NSITRANSFER_H */ +#endif /* !HAVE_GECKO_1_8 */ NS_IMETHODIMP MozDownload::GetTotalProgress(PRInt64 *aTotalProgress) @@ -292,7 +312,7 @@ MozDownload::GetMIMEInfo(nsIMIMEInfo **aMIMEInfo) return NS_OK; } -#ifndef HAVE_NSITRANSFER_H +#ifndef HAVE_GECKO_1_8 NS_IMETHODIMP MozDownload::GetListener(nsIWebProgressListener **aListener) { @@ -306,7 +326,6 @@ MozDownload::SetListener(nsIWebProgressListener *aListener) { return NS_ERROR_NOT_IMPLEMENTED; } -#endif NS_IMETHODIMP MozDownload::GetObserver(nsIObserver **aObserver) @@ -324,6 +343,7 @@ MozDownload::SetObserver(nsIObserver *aObserver) return NS_OK; } +#endif NS_IMETHODIMP MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, @@ -334,7 +354,7 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, if (NS_FAILED(aStatus) && NS_SUCCEEDED(mStatus)) mStatus = aStatus; - if (aStateFlags & EPHY_EMBED_STATE_START) + if (aStateFlags & STATE_START) { mDownloadState = EPHY_DOWNLOAD_DOWNLOADING; @@ -345,7 +365,7 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, } /* We will get this even in the event of a cancel */ - if (aStateFlags & EPHY_EMBED_STATE_STOP) + if (aStateFlags & STATE_STOP) { /* Keep us alive */ nsCOMPtr<nsITransfer> kungFuDeathGrip(this); @@ -356,11 +376,16 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, g_signal_emit_by_name (mEphyDownload, "changed"); } +#ifdef HAVE_GECKO_1_8 + /* break refcount cycle */ + mCancelable = nsnull; +#else if (mWebPersist) { mWebPersist->SetProgressListener(nsnull); mWebPersist = nsnull; } +#endif if (mEmbedPersist) { @@ -377,7 +402,7 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, { GnomeVFSMimeApplication *helperApp; nsEmbedCString mimeType; -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 rv = mMIMEInfo->GetMIMEType (mimeType); NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); @@ -437,7 +462,7 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, return NS_OK; } -#ifdef HAVE_NSITRANSFER_H +#ifdef HAVE_GECKO_1_8 NS_IMETHODIMP MozDownload::OnProgressChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, @@ -460,7 +485,7 @@ MozDownload::OnProgressChange64 (nsIWebProgress *aWebProgress, PRInt64 aMaxSelfProgress, PRInt64 aCurTotalProgress, PRInt64 aMaxTotalProgress) -#else /* !HAVE_NSITRANSFER_H */ +#else /* !HAVE_GECKO_1_8 */ NS_IMETHODIMP MozDownload::OnProgressChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, @@ -468,7 +493,7 @@ MozDownload::OnProgressChange (nsIWebProgress *aWebProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) -#endif /* HAVE_NSITRANSFER_H */ +#endif /* HAVE_GECKO_1_8 */ { if (mMaxSize >= 0 && ((aMaxTotalProgress > 0 && mMaxSize < aMaxTotalProgress) || @@ -536,7 +561,14 @@ MozDownload::Cancel() { return; } - + +#ifdef HAVE_GECKO_1_8 + if (mCancelable) + { + /* FIXME: error code? */ + mCancelable->Cancel (NS_BINDING_ABORTED); + } +#else if (mWebPersist) { mWebPersist->CancelSave (); @@ -545,7 +577,8 @@ MozDownload::Cancel() if (mObserver) { mObserver->Observe (nsnull, "oncancel", nsnull); - } + } +#endif } void @@ -572,7 +605,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI nsILocalFile* inDestFile, const char *contentType, nsIURI* inOriginalURI, MozillaEmbedPersist *embedPersist, nsIInputStream *postData, nsISupports *aCacheKey, - PRInt32 aMaxSize) + PRInt64 aMaxSize) { nsresult rv = NS_OK; @@ -584,7 +617,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI strcmp (contentType, "text/xml") == 0 || strcmp (contentType, "application/xhtml+xml") == 0)); - nsCOMPtr<nsIWebBrowserPersist> webPersist = do_CreateInstance(persistContractID, &rv); + nsCOMPtr<nsIWebBrowserPersist> webPersist (do_CreateInstance(persistContractID, &rv)); NS_ENSURE_SUCCESS (rv, rv); PRInt64 timeNow = PR_Now(); @@ -601,8 +634,14 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI MozDownload *downloader = new MozDownload (); /* dlListener attaches to its progress dialog here, which gains ownership */ + /* FIXME is that still true? */ +#ifdef HAVE_GECKO_1_8 + rv = downloader->InitForEmbed (inOriginalURI, destURI, fileDisplayName, + nsnull, timeNow, webPersist, embedPersist, aMaxSize); +#else rv = downloader->InitForEmbed (inOriginalURI, destURI, fileDisplayName.get(), nsnull, timeNow, webPersist, embedPersist, aMaxSize); +#endif NS_ENSURE_SUCCESS (rv, rv); PRInt32 flags = nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES; diff --git a/embed/mozilla/MozDownload.h b/embed/mozilla/MozDownload.h index 52c06c94f..c145e0a13 100644 --- a/embed/mozilla/MozDownload.h +++ b/embed/mozilla/MozDownload.h @@ -42,23 +42,18 @@ #ifndef MozDownload_h__ #define MozDownload_h__ -#include "config.h" - #include "mozilla-embed-persist.h" #include "downloader-view.h" #include "ephy-download.h" #include "ephy-embed-shell.h" +#include <nsCOMPtr.h> #include <nsIWebProgressListener.h> -#include <nsIDOMDocument.h> #include <nsIURI.h> -#include <nsILocalFile.h> -#include <nsIWebBrowserPersist.h> -#include <nsIObserver.h> -#include <nsIRequest.h> #include <nsIMIMEInfo.h> -#ifdef HAVE_NSITRANSFER_H +#ifdef HAVE_GECKO_1_8 +#include <nsICancelable.h> #include <nsITransfer.h> #else #include <nsIDownload.h> @@ -66,6 +61,13 @@ #include <libgnomevfs/gnome-vfs-mime-handlers.h> +class nsIDOMDocument; +class nsILocalFile; +class nsIWebBrowserPersist; +class nsIObserver; +class nsIRequest; +class nsIInputStream; + /* MozDownload Holds information used to display a single download in the UI. This object is created in one of two ways: @@ -91,11 +93,11 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceUri nsILocalFile* inDestFile, const char *contentType, nsIURI* inOriginalURI, MozillaEmbedPersist *embedPersist, nsIInputStream *postData, nsISupports *aCacheKey, - PRInt32 aMaxSize); + PRInt64 aMaxSize); nsresult BuildDownloadPath (const char *defaultFileName, nsILocalFile **_retval); class MozDownload : -#ifdef HAVE_NSITRANSFER_H +#ifdef HAVE_GECKO_1_8 public nsITransfer #else public nsIDownload, @@ -108,19 +110,17 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIWEBPROGRESSLISTENER -#ifdef HAVE_NSITRANSFER_H +#ifdef HAVE_GECKO_1_8 NS_DECL_NSIWEBPROGRESSLISTENER2 -#endif NS_DECL_NSITRANSFER -#ifndef HAVE_NSITRANSFER_H - NS_DECL_NSIDOWNLOAD -#endif -#ifdef HAVE_NSITRANSFER_H nsresult GetMIMEInfo (nsIMIMEInfo **aMIMEInfo); nsresult GetTargetFile (nsILocalFile **aFile); nsresult GetSource(nsIURI * *aSource); nsresult GetPercentComplete(PRInt32 *aPercentComplete); +#else + NS_DECL_NSITRANSFER + NS_DECL_NSIDOWNLOAD #endif virtual void Cancel(); @@ -131,18 +131,26 @@ public: nsresult GetCurrentProgress (PRInt64 *aCurrentProgress); nsresult GetTotalProgress (PRInt64 *aTProgress); nsresult GetElapsedTime (PRInt64 *aTProgress); + +#ifdef HAVE_GECKO_1_8 + nsresult InitForEmbed (nsIURI *aSource, nsIURI *aTarget, + const nsAString &aDisplayName, nsIMIMEInfo *aMIMEInfo, + PRTime aStartTime, nsICancelable *aCancelable, + MozillaEmbedPersist *aEmbedPersist, PRInt64 aMaxSize); +#else nsresult InitForEmbed (nsIURI *aSource, nsIURI *aTarget, const PRUnichar *aDisplayName, nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist, - MozillaEmbedPersist *aEmbedPersist, PRInt32 aMaxSize); + MozillaEmbedPersist *aEmbedPersist, PRInt64 aMaxSize); +#endif protected: nsCOMPtr<nsIURI> mSource; nsCOMPtr<nsIURI> mDestination; nsCOMPtr<nsIMIMEInfo> mMIMEInfo; - PRInt64 mLastUpdate; - PRInt64 mStartTime; + PRTime mStartTime; + PRTime mLastUpdate; PRInt64 mElapsed; PRInt32 mInterval; PRInt32 mPercentComplete; @@ -152,8 +160,12 @@ protected: nsresult mStatus; - nsCOMPtr<nsIObserver> mObserver; +#ifdef HAVE_GECKO_1_8 + nsCOMPtr<nsICancelable> mCancelable; +#else nsCOMPtr<nsIWebBrowserPersist> mWebPersist; + nsCOMPtr<nsIObserver> mObserver; +#endif nsCOMPtr<nsIRequest> mRequest; EphyDownload *mEphyDownload; DownloaderView *mDownloaderView; diff --git a/embed/mozilla/mozilla-download.cpp b/embed/mozilla/mozilla-download.cpp index 6d0c5121b..5a412e086 100644 --- a/embed/mozilla/mozilla-download.cpp +++ b/embed/mozilla/mozilla-download.cpp @@ -30,6 +30,7 @@ #undef MOZILLA_INTERNAL_API #include <nsEmbedString.h> #define MOZILLA_INTERNAL_API 1 +#include <nsILocalFile.h> #include <nsMemory.h> static void mozilla_download_class_init (MozillaDownloadClass *klass); @@ -187,7 +188,7 @@ impl_get_mime (EphyDownload *download) mozDownload->GetMIMEInfo (getter_AddRefs(mime)); if (!mime) return g_strdup ("application/octet-stream"); -#ifdef MOZ_NSIMIMEINFO_NSACSTRING_ +#ifdef HAVE_GECKO_1_8 mime->GetMIMEType(mimeType); #else char *tmp = nsnull; |