From f824ab8af4d3d2e34bd59b860b9c6d5568c3bb44 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Sat, 3 Nov 2012 23:19:28 +0000 Subject: Port save complete to libdom. --- gtk/Makefile.target | 2 +- gtk/gui.c | 3 ++ gtk/save.c | 81 ----------------------------------------------------- gtk/scaffolding.c | 3 +- 4 files changed, 5 insertions(+), 84 deletions(-) delete mode 100644 gtk/save.c (limited to 'gtk') diff --git a/gtk/Makefile.target b/gtk/Makefile.target index c60247392..0018a67d5 100644 --- a/gtk/Makefile.target +++ b/gtk/Makefile.target @@ -107,7 +107,7 @@ $(eval $(foreach V,$(filter GTK_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($( S_GTK := font_pango.c bitmap.c gui.c schedule.c thumbnail.c plotters.c \ treeview.c scaffolding.c gdk.c completion.c login.c throbber.c \ selection.c history.c window.c filetype.c download.c menu.c \ - print.c save.c search.c tabs.c theme.c toolbar.c \ + print.c search.c tabs.c theme.c toolbar.c \ compat.c cookies.c hotlist.c system_colour.c \ $(addprefix dialogs/,options.c about.c source.c) diff --git a/gtk/gui.c b/gtk/gui.c index 891910407..1d15ef743 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -51,6 +51,7 @@ #include "desktop/history_global_core.h" #include "desktop/netsurf.h" #include "desktop/options.h" +#include "desktop/save_complete.h" #include "desktop/save_pdf/pdf_plotters.h" #include "desktop/searchweb.h" #include "desktop/sslcert.h" @@ -417,6 +418,8 @@ static void gui_init(int argc, char** argv, char **respath) filepath_sfinddef(respath, buf, "mime.types", "/etc/"); gtk_fetch_filetype_init(buf); + save_complete_init(); + urldb_load(nsoption_charp(url_file)); urldb_load_cookies(nsoption_charp(cookie_file)); diff --git a/gtk/save.c b/gtk/save.c deleted file mode 100644 index fb8f3e0b9..000000000 --- a/gtk/save.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2009 Mark Benjamin - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "content/content.h" -#include "desktop/save_complete.h" -#include "utils/utils.h" - -/** -* conducts the filesystem save appropriate to the gui -* \param path save path -* \param filename name of file to save -* \param len data length -* \param sourcedata pointer to data to save -* \param type content type -* \return true for success -*/ - -bool save_complete_gui_save(const char *path, const char *filename, - size_t len, const char *sourcedata, lwc_string *mime_type) -{ - int res; - int namelen; - namelen = strlen(path) + strlen(filename) + 2; /* '/', '\0' */ - char *fullpath = malloc(namelen); - if (!fullpath) { - warn_user("NoMemory", 0); - return false; - } - snprintf(fullpath, namelen, "%s/%s", path, filename); - FILE *f; - f = fopen(fullpath, "wb"); - free(fullpath); - if (f == NULL) - return false; - res = fwrite(sourcedata, len, 1, f); - fclose(f); - if (res != 1) - return false; - return true; -} - -/** -* wrapper for lib function htmlSaveFileFormat; front sets path from path -* + filename in a filesystem-specific way -*/ - -int save_complete_htmlSaveFileFormat(const char *path, const char *filename, - xmlDocPtr cur, const char *encoding, int format) -{ - int ret; - int len = strlen(path) + strlen(filename) + 2; - char *fullpath = malloc(len); - if (fullpath == NULL) { - warn_user("NoMemory", 0); - return -1; - } - snprintf(fullpath, len, "%s/%s", path, filename); - ret = htmlSaveFileFormat(fullpath, cur, encoding, format); - free(fullpath); - return ret; -} - diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index 22816cf89..91288a22e 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -668,9 +668,8 @@ MULTIHANDLER(savepage) return TRUE; } closedir(d); - save_complete_init(); save_complete(nsgtk_get_browser_window( - g->top_level)->current_content, path); + g->top_level)->current_content, path, NULL); g_free(path); gtk_widget_destroy(fc); -- cgit v1.2.3