diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2004-01-19 22:06:41 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2004-01-19 22:06:41 +0800 |
commit | dd0b02c40b5d202794d03299f2d190833b63bb22 (patch) | |
tree | 4e8dc109ed36ca01584e1a7d39d5649cc6adbd6e /embed/mozilla/MozDownload.cpp | |
parent | eaba78e8dfd1cdad90bed57cc536cbfe40a9509e (diff) | |
download | gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.gz gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.bz2 gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.lz gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.xz gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.zst gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.zip |
Add a way to store paths.
2004-01-19 Marco Pesenti Gritti <marco@gnome.org>
* lib/eel-gconf-extensions.c: (tilde_compress),
(eel_gconf_set_path):
* lib/eel-gconf-extensions.h:
Add a way to store paths.
* embed/mozilla/ContentHandler.cpp:
* embed/mozilla/ContentHandler.h:
* embed/mozilla/MozDownload.cpp:
* embed/mozilla/MozDownload.h:
Actually save the file in downloads dir and then
open it. It doesnt seem to open it but it's prolly
a gnome-vfs bug.
* src/prefs-dialog.c: (get_download_button_label),
(download_path_response_cb):
Simplify the label logic using ~.
Diffstat (limited to 'embed/mozilla/MozDownload.cpp')
-rw-r--r-- | embed/mozilla/MozDownload.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp index 53205702a..003573402 100644 --- a/embed/mozilla/MozDownload.cpp +++ b/embed/mozilla/MozDownload.cpp @@ -55,6 +55,7 @@ #include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceUtils.h" #include "nsIRequest.h" +#include "nsIMIMEInfo.h" #include "netCore.h" const char* const persistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1"; @@ -88,6 +89,7 @@ MozDownload::Init(nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisp nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist) { PRBool addToView = PR_TRUE; + nsresult rv; if (mEmbedPersist) { @@ -106,6 +108,7 @@ MozDownload::Init(nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisp mPercentComplete = 0; mInterval = 4000; /* in ms */ mLastUpdate = mStartTime; + mMIMEInfo = aMIMEInfo; if (aPersist) { @@ -262,6 +265,8 @@ NS_IMETHODIMP MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) { + nsresult rv; + /* For a file download via the external helper app service, we will never get a start notification. The helper app service has gotten that notification before it created us. */ if (!mGotFirstStateChange) @@ -302,6 +307,41 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, mozilla_embed_persist_cancelled (mEmbedPersist); } } + else if (NS_SUCCEEDED (aStatus)) + { + GnomeVFSMimeApplication *helperApp; + char *mimeType; + + rv = mMIMEInfo->GetMIMEType (&mimeType); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + + helperApp = gnome_vfs_mime_get_default_application (mimeType); + + PRUnichar *description; + mMIMEInfo->GetApplicationDescription (&description); + + /* HACK we use the application description to decide + if we have to open the saved file */ + if ((strcmp (NS_ConvertUCS2toUTF8 (description).get(), "gnome-default") == 0) && + helperApp) + { + GList *params = NULL; + char *param; + nsCAutoString aDest; + + mDestination->GetNativePath (aDest); + + param = g_strdup (aDest.get ()); + params = g_list_append (params, param); + gnome_vfs_mime_application_launch (helperApp, params); + g_free (param); + + g_list_free (params); + } + + nsMemory::Free (mimeType); + gnome_vfs_mime_application_free (helperApp); + } } return NS_OK; |