aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/MozDownload.cpp
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-02-27 06:01:48 +0800
committerChristian Persch <chpe@src.gnome.org>2005-02-27 06:01:48 +0800
commitfbf4b15ed54be3abfe2c3c937c50b9c623804cb5 (patch)
tree27639ff5895028fd04bcc8c4ce800354b040fa73 /embed/mozilla/MozDownload.cpp
parentcaba7f03132e463c48405eb602a8b77764c3ec75 (diff)
downloadgsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.gz
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.bz2
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.lz
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.xz
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.zst
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.zip
Depend on gnome-desktop for gnome-desktop-item, and up the gnome-vfs
2005-02-26 Christian Persch <chpe@cvs.gnome.org> * configure.ac: Depend on gnome-desktop for gnome-desktop-item, and up the gnome-vfs dependency version. * embed/ephy-embed-persist.c: (ephy_embed_persist_set_user_time), (ephy_embed_persist_get_user_time), (ephy_embed_persist_set_property), (ephy_embed_persist_get_property), (ephy_embed_persist_init), (ephy_embed_persist_class_init): * embed/ephy-embed-persist.h: Add user time property. * embed/mozilla/ContentHandler.cpp: * embed/mozilla/ContentHandler.h: Forward user time to MozDownload via a string. Not perfect, but better than nothing. * embed/mozilla/EphyHeaderSniffer.cpp: Set user time on filechooser. * embed/mozilla/MozDownload.cpp: Get user time from content handler, and use it when launching the external handler app. * lib/ephy-file-helpers.c: (ephy_file_check_mime), (launch_desktop_item), (ephy_file_launch_desktop_file), (ephy_file_launch_application), (ephy_file_launch_handler): * lib/ephy-file-helpers.h: Convenience functions to launch an app, or a desktop item, with user time. * lib/ephy-gui.c: (ephy_gui_confirm_overwrite_file), (ephy_gui_window_update_user_time), (ephy_gui_window_present): * lib/ephy-gui.h: Make our own gtk_window_present, to correctly update user time. Check if the path is writable in ephy_gui_confirm_overwrite_file(). * src/ephy-session.c: (ephy_session_autoresume): After showing the recovery dialogue, don't use the old user time to launch the windows; use the current event time instead. * src/popup-commands.c: (background_download_completed), (image_open_uri), (save_source_completed_cb), (popup_cmd_open_image): * src/window-commands.c: (window_cmd_file_save_as), (save_source_completed_cb), (save_temp_source), (window_cmd_view_page_source): Launch handlers with user time.
Diffstat (limited to 'embed/mozilla/MozDownload.cpp')
-rw-r--r--embed/mozilla/MozDownload.cpp52
1 files changed, 29 insertions, 23 deletions
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 8160f2715..140eb98fc 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -61,6 +61,9 @@
#include <nsEmbedString.h>
#undef MOZILLA_STRICT_API
+#include <errno.h>
+#include <stdlib.h>
+
const char* const persistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1";
MozDownload::MozDownload() :
@@ -365,58 +368,61 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
else if (NS_SUCCEEDED (aStatus))
{
GnomeVFSMimeApplication *helperApp;
-#ifdef MOZ_NSIMIMEINFO_NSACSTRING_
nsEmbedCString mimeType;
+#ifdef MOZ_NSIMIMEINFO_NSACSTRING_
rv = mMIMEInfo->GetMIMEType (mimeType);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
- helperApp = gnome_vfs_mime_get_default_application (mimeType.get());
-
nsEmbedString description;
mMIMEInfo->GetApplicationDescription (description);
nsEmbedCString cDesc;
NS_UTF16ToCString (description, NS_CSTRING_ENCODING_UTF8, cDesc);
-
- /* HACK we use the application description to decide
- if we have to open the saved file */
- if ((strcmp (cDesc.get(), "gnome-default") == 0) &&
- helperApp)
#else
char *mimeType;
rv = mMIMEInfo->GetMIMEType (&mimeType);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
- helperApp = gnome_vfs_mime_get_default_application (mimeType);
+ if (mime)
+ {
+ mimeType.Assign (mime);
+ nsMemory::Free (mime);
+ }
PRUnichar *description;
mMIMEInfo->GetApplicationDescription (&description);
+ NS_ENSURE_TRUE (description, NS_ERROR_FAILURE);
nsEmbedCString cDesc;
NS_UTF16ToCString (nsEmbedString(description),
NS_CSTRING_ENCODING_UTF8, cDesc);
+ nsMemory::Free (description);
+#endif
+
/* HACK we use the application description to decide
if we have to open the saved file */
- if (strcmp (cDesc.get(), "gnome-default") == 0 &&
- helperApp)
-#endif
+ if (g_str_has_suffix (cDesc.get(), "gnome-default:"))
{
- GList *params = NULL;
- char *param;
- nsEmbedCString aDest;
+ /* Format gnome-default:<usertime>:<helperapp id> */
+ char **str = g_strsplit (cDesc.get(), ":", -1);
+ g_return_val_if_fail (g_strv_length (str) != 3, NS_ERROR_FAILURE);
- mDestination->GetSpec (aDest);
+ char *end;
+ guint32 user_time = strtoul (str[1], &end, 0);
- param = gnome_vfs_make_uri_canonical (aDest.get ());
- params = g_list_append (params, param);
- gnome_vfs_mime_application_launch (helperApp, params);
- g_free (param);
+ helperApp = gnome_vfs_mime_application_new_from_desktop_id (str[2]);
+ if (!helperApp) return NS_ERROR_FAILURE;
- g_list_free (params);
- }
+ nsEmbedCString aDest;
+ rv = mDestination->GetSpec (aDest);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
- gnome_vfs_mime_application_free (helperApp);
+ ephy_file_launch_application (helperApp, aDest.get (), user_time);
+
+ gnome_vfs_mime_application_free (helperApp);
+ g_strfreev (str);
+ }
}
}