From cf8d507e4c6272a5e3f1b2a65724f1938d7d246d Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Tue, 26 Apr 2005 12:01:39 +0000 Subject: Ged rid of all API checks which check for 1.8-only API, and introduce a 2005-04-26 Christian Persch * 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. --- embed/mozilla/ContentHandler.cpp | 20 +++--- embed/mozilla/ContentHandler.h | 4 +- embed/mozilla/EventContext.cpp | 6 +- embed/mozilla/GlobalHistory.cpp | 2 +- embed/mozilla/GtkNSSKeyPairDialogs.cpp | 22 +++---- embed/mozilla/MozDownload.cpp | 117 ++++++++++++++++++++++----------- embed/mozilla/MozDownload.h | 52 +++++++++------ embed/mozilla/mozilla-download.cpp | 3 +- 8 files changed, 139 insertions(+), 87 deletions(-) (limited to 'embed') 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 @@ -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 #include -#ifdef HAVE_NSIKEYGENTHREAD_NSIOBSERVER +#ifdef HAVE_GECKO_1_8 #include -#else /* !HAVE_NSIKEYGENTHREAD_NSIOBSERVER */ +#else /* !HAVE_GECKO_1_8 */ #include #ifdef ALLOW_PRIVATE_API #include "nsIDOMWindowInternal.h" #endif /* ALLOW_PRIVATE_API */ -#endif /* HAVE_NSIKEYGENTHREAD_NSIOBSERVER */ +#endif /* HAVE_GECKO_1_8 */ #include #include @@ -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 helper = new KeyPairObserver; #else nsCOMPtr 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 #include +#include +#include +#include +#include +#include #include #undef MOZILLA_INTERNAL_API #include #define MOZILLA_INTERNAL_API 1 #include +#include -#include #include 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 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 webPersist = do_CreateInstance(persistContractID, &rv); + nsCOMPtr 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 #include -#include #include -#include -#include -#include -#include #include -#ifdef HAVE_NSITRANSFER_H +#ifdef HAVE_GECKO_1_8 +#include #include #else #include @@ -66,6 +61,13 @@ #include +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 mSource; nsCOMPtr mDestination; nsCOMPtr mMIMEInfo; - PRInt64 mLastUpdate; - PRInt64 mStartTime; + PRTime mStartTime; + PRTime mLastUpdate; PRInt64 mElapsed; PRInt32 mInterval; PRInt32 mPercentComplete; @@ -152,8 +160,12 @@ protected: nsresult mStatus; - nsCOMPtr mObserver; +#ifdef HAVE_GECKO_1_8 + nsCOMPtr mCancelable; +#else nsCOMPtr mWebPersist; + nsCOMPtr mObserver; +#endif nsCOMPtr 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 #define MOZILLA_INTERNAL_API 1 +#include #include 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; -- cgit v1.2.3