mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-03-30 19:02:52 +03:00
Port save complete to libdom.
This commit is contained in:
parent
3f1b683845
commit
f824ab8af4
@ -75,7 +75,7 @@ EXETARGET := NetSurf
|
||||
S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c file.c \
|
||||
thumbnail.c misc.c bitmap.c font.c filetype.c utf8.c login.c \
|
||||
plotters.c object.c menu.c save_pdf.c arexx.c version.c \
|
||||
cookies.c context_menu.c clipboard.c save_complete.c \
|
||||
cookies.c context_menu.c clipboard.c \
|
||||
launch.c search.c history_local.c download.c iff_dr2d.c \
|
||||
sslcert.c gui_options.c print.c theme.c drag.c icon.c system_colour.c \
|
||||
datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \
|
||||
|
32
amiga/file.c
32
amiga/file.c
@ -99,6 +99,36 @@ void ami_file_open(struct gui_window_2 *gwin)
|
||||
}
|
||||
}
|
||||
|
||||
static void ami_file_set_type(const char *path, lwc_string *mime_type)
|
||||
{
|
||||
content_type type = content_factory_type_from_mime_type(mime_type);
|
||||
const char *default_type;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case CONTENT_HTML:
|
||||
default_type = "html";
|
||||
break;
|
||||
case CONTENT_CSS:
|
||||
default_type = "css";
|
||||
break;
|
||||
default:
|
||||
default_type = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (default_type != NULL) {
|
||||
struct DiskObject *dobj = NULL;
|
||||
|
||||
dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,default_type,
|
||||
ICONGETA_GetDefaultType,WBPROJECT,
|
||||
TAG_DONE);
|
||||
|
||||
PutIconTags(path, dobj,
|
||||
ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
void ami_file_save(int type, char *fname, struct Window *win,
|
||||
struct hlcache_handle *object, struct hlcache_handle *favicon,
|
||||
struct selection *sel)
|
||||
@ -134,7 +164,7 @@ void ami_file_save(int type, char *fname, struct Window *win,
|
||||
if(lock = CreateDir(fname))
|
||||
{
|
||||
UnLock(lock);
|
||||
save_complete(object, fname);
|
||||
save_complete(object, fname, ami_file_set_type);
|
||||
amiga_icon_superimpose_favicon(fname, favicon, NULL);
|
||||
}
|
||||
break;
|
||||
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
* Copyright 2004-2007 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
#include "desktop/save_complete.h"
|
||||
#include "utils/utils.h"
|
||||
#include <proto/icon.h>
|
||||
#include <workbench/icon.h>
|
||||
#include "content/content.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, NULL when all data in c
|
||||
* \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)
|
||||
{
|
||||
content_type type = content_factory_type_from_mime_type(mime_type);
|
||||
int res;
|
||||
int namelen;
|
||||
char deftype[5];
|
||||
struct DiskObject *dobj = NULL;
|
||||
namelen = strlen(path) + strlen(filename) + 2;
|
||||
char *fullpath = malloc(namelen);
|
||||
if (!fullpath) {
|
||||
warn_user("NoMemory", 0);
|
||||
return false;
|
||||
}
|
||||
snprintf(fullpath, namelen, "%s/%s", path, filename);
|
||||
FILE *f = fopen(fullpath, "w");
|
||||
if (f == NULL)
|
||||
return false;
|
||||
res = fwrite(sourcedata, len, 1, f);
|
||||
fclose(f);
|
||||
switch(type)
|
||||
{
|
||||
case CONTENT_HTML:
|
||||
strcpy(deftype,"html");
|
||||
break;
|
||||
case CONTENT_CSS:
|
||||
strcpy(deftype,"css");
|
||||
break;
|
||||
default:
|
||||
free(fullpath);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,deftype,
|
||||
ICONGETA_GetDefaultType,WBPROJECT,
|
||||
TAG_DONE);
|
||||
|
||||
PutIconTags(fullpath, dobj,
|
||||
ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE);
|
||||
free(fullpath);
|
||||
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;
|
||||
struct DiskObject *dobj = NULL;
|
||||
char *fullpath = malloc(len);
|
||||
if (!fullpath){
|
||||
warn_user("NoMemory", 0);
|
||||
return -1;
|
||||
}
|
||||
snprintf(fullpath, len, "%s/%s", path, filename);
|
||||
ret = htmlSaveFileFormat(fullpath, cur, encoding, format);
|
||||
dobj = GetIconTags(NULL,ICONGETA_GetDefaultName, "html",
|
||||
ICONGETA_GetDefaultType,WBPROJECT,
|
||||
TAG_DONE);
|
||||
|
||||
PutIconTags(fullpath, dobj,
|
||||
ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE);
|
||||
|
||||
free(fullpath);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
* Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Save HTML document with dependencies (interface).
|
||||
*/
|
||||
|
||||
#ifndef AMIGA_SAVE_COMPLETE_H
|
||||
#define AMIGA_SAVE_COMPLETE_H
|
||||
|
||||
#include "content/content.h"
|
||||
|
||||
void save_complete_init(void);
|
||||
bool save_complete(hlcache_handle *c, const char *path);
|
||||
|
||||
#endif
|
@ -82,7 +82,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
|
||||
redrawslots.c encoding.c \
|
||||
browser_win.c toolbar.c statusbar.c browser.c \
|
||||
global_evnt.c osspec.c dragdrop.c system_colour.c \
|
||||
ctxmenu.c save.c settings.c
|
||||
ctxmenu.c settings.c
|
||||
S_ATARI := $(addprefix atari/,$(S_ATARI))
|
||||
|
||||
# This is the final source build list
|
||||
|
@ -176,7 +176,7 @@ static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
|
||||
} while( !is_folder && path != NULL );
|
||||
|
||||
if( path != NULL ){
|
||||
save_complete( input_window->browser->bw->current_content, path );
|
||||
save_complete( input_window->browser->bw->current_content, path, NULL );
|
||||
}
|
||||
|
||||
}
|
||||
|
88
atari/save.c
88
atari/save.c
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
|
||||
#include "content/content.h"
|
||||
#include "desktop/save_complete.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/*
|
||||
This code was simply taken from GTK frontend. It requires adjustment
|
||||
within the core or frontend to work well.
|
||||
( mime type detection fails on load of the saved webpage, that's because
|
||||
no file extension is saved. )
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
@ -85,8 +85,8 @@
|
||||
|
||||
# S_BEOS are sources purely for the BeOS build
|
||||
S_BEOS := about.cpp bitmap.cpp fetch_rsrc.cpp \
|
||||
filetype.cpp font.cpp gui.cpp login.cpp \
|
||||
gui_options.cpp plotters.cpp save_complete.cpp \
|
||||
filetype.cpp font.cpp gui.cpp login.cpp \
|
||||
gui_options.cpp plotters.cpp \
|
||||
scaffolding.cpp search.cpp schedule.cpp \
|
||||
thumbnail.cpp treeview.cpp throbber.cpp \
|
||||
window.cpp system_colour.cpp
|
||||
@ -134,4 +134,4 @@ install-beos:
|
||||
# Package target
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
package-beos:
|
||||
package-beos:
|
||||
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008 François Revol <mmu_man@users.sourceforge.net>
|
||||
* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define __STDBOOL_H__ 1
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
extern "C" {
|
||||
#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 = (char *)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 = (char *)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;
|
||||
}
|
||||
|
@ -95,7 +95,6 @@ S_COCOA := \
|
||||
font.m \
|
||||
gui.m \
|
||||
plotter.m \
|
||||
save.m \
|
||||
schedule.m \
|
||||
selection.m \
|
||||
thumbnail.m \
|
||||
|
37
cocoa/save.m
37
cocoa/save.m
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "desktop/save_complete.h"
|
||||
|
||||
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
|
||||
|
||||
bool save_complete_gui_save(const char *path, const char *filename,
|
||||
size_t len, const char *sourcedata, lwc_string *mime_type)
|
||||
{
|
||||
UNIMPL();
|
||||
return false;
|
||||
}
|
||||
|
||||
int save_complete_htmlSaveFileFormat(const char *path, const char *filename,
|
||||
xmlDocPtr cur, const char *encoding, int format)
|
||||
{
|
||||
UNIMPL();
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -25,19 +25,34 @@
|
||||
#define _NETSURF_DESKTOP_SAVE_COMPLETE_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
|
||||
#include <libwapcaplet/libwapcaplet.h>
|
||||
|
||||
struct hlcache_handle;
|
||||
|
||||
/**
|
||||
* Callback to set type of a file
|
||||
*
|
||||
* \param path Native path of file
|
||||
* \param mime_type MIME type of file content
|
||||
*/
|
||||
typedef void (*save_complete_set_type_cb)(const char *path,
|
||||
lwc_string *mime_type);
|
||||
|
||||
/**
|
||||
* Initialise save complete module.
|
||||
*/
|
||||
void save_complete_init(void);
|
||||
bool save_complete(struct hlcache_handle *c, const char *path);
|
||||
|
||||
bool save_complete_gui_save(const char *path, const char *filename,
|
||||
size_t len, const char *sourcedata, lwc_string *mime_type);
|
||||
|
||||
int save_complete_htmlSaveFileFormat(const char *path, const char *filename,
|
||||
xmlDocPtr cur, const char *encoding, int format);
|
||||
/**
|
||||
* Save an HTML page with all dependencies.
|
||||
*
|
||||
* \param c CONTENT_HTML to save
|
||||
* \param path Native path to directory to save in to (must exist)
|
||||
* \param set_type Callback to set type of a file, or NULL
|
||||
* \return true on success, false on error and error reported
|
||||
*/
|
||||
bool save_complete(struct hlcache_handle *c, const char *path,
|
||||
save_complete_set_type_cb set_type);
|
||||
|
||||
#endif
|
||||
|
@ -139,7 +139,7 @@ $(eval $(foreach V,$(filter FB_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($(V
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# S_FRAMEBUFFER are sources purely for the framebuffer build
|
||||
S_FRAMEBUFFER := gui.c framebuffer.c tree.c save.c schedule.c \
|
||||
S_FRAMEBUFFER := gui.c framebuffer.c tree.c schedule.c \
|
||||
thumbnail.c misc.c bitmap.c filetype.c login.c findfile.c \
|
||||
localhistory.c system_colour.c clipboard.c
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "desktop/save_complete.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, NULL when all data in c
|
||||
* \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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
81
gtk/save.c
81
gtk/save.c
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "desktop/save_complete.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
|
||||
#include "utils/utils.h"
|
||||
@ -138,20 +137,6 @@ utf8_from_local_encoding(const char *string, size_t len,
|
||||
return (*result == NULL) ? UTF8_CONVERT_NOMEM : UTF8_CONVERT_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
save_complete_gui_save(const char *path, const char *filename,
|
||||
size_t len, const char *sourcedata, lwc_string *mime_type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
save_complete_htmlSaveFileFormat(const char *path, const char *filename,
|
||||
xmlDocPtr cur, const char *encoding, int format)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
|
@ -975,71 +975,16 @@ void ro_gui_save_done(void)
|
||||
gui_save_content = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, NULL when all data in c
|
||||
* \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)
|
||||
static void ro_gui_save_set_file_type(const char *path, lwc_string *mime_type)
|
||||
{
|
||||
char *fullpath;
|
||||
int rotype = ro_content_filetype_from_mime_type(mime_type);
|
||||
os_error *error;
|
||||
int namelen = strlen(path) + strlen(filename) + 2;
|
||||
int rotype;
|
||||
fullpath = malloc(namelen);
|
||||
if (fullpath == NULL) {
|
||||
warn_user("NoMemory", 0);
|
||||
return false;
|
||||
}
|
||||
snprintf(fullpath, namelen, "%s.%s", path, filename);
|
||||
rotype = ro_content_filetype_from_mime_type(mime_type);
|
||||
error = xosfile_save_stamped(fullpath, rotype, (byte *) sourcedata,
|
||||
(byte *) sourcedata + len);
|
||||
free(fullpath);
|
||||
if (error) {
|
||||
LOG(("xosfile_save_stamped: 0x%x: %s",
|
||||
|
||||
error = xosfile_set_type(path, rotype);
|
||||
if (error != NULL) {
|
||||
LOG(("xosfile_set_type: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("SaveError", error->errmess);
|
||||
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)
|
||||
{
|
||||
os_error *error;
|
||||
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);
|
||||
|
||||
error = xosfile_set_type(fullpath, 0xFAF);
|
||||
if (error) {
|
||||
LOG(("xosfile_save_stamped: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
/* Don't warn the user here -- they probably don't care */
|
||||
}
|
||||
|
||||
free(fullpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1130,7 +1075,7 @@ bool ro_gui_save_complete(hlcache_handle *h, char *path)
|
||||
content_get_title(h), LINK_ANT, buf))
|
||||
return false;
|
||||
|
||||
return save_complete(h, path);
|
||||
return save_complete(h, path, ro_gui_save_set_file_type);
|
||||
}
|
||||
|
||||
bool ro_gui_save_object_native(hlcache_handle *h, char *path)
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/options.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/save_complete.h"
|
||||
#include "desktop/selection.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "render/html.h"
|
||||
@ -1691,27 +1690,6 @@ gui_window_set_search_ico(hlcache_handle *ico)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
save_complete_gui_save(const char *path,
|
||||
const char *filename,
|
||||
size_t len,
|
||||
const char *sourcedata,
|
||||
lwc_string *mime_type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
save_complete_htmlSaveFileFormat(const char *path,
|
||||
const char *filename,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding,
|
||||
int format)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void gui_window_new_content(struct gui_window *w)
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user