Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/36a26db7848f4b59fb3ce...
...commit
http://git.netsurf-browser.org/netsurf.git/commit/36a26db7848f4b59fb3ce71...
...tree
http://git.netsurf-browser.org/netsurf.git/tree/36a26db7848f4b59fb3ce716b...
The branch, svenw/cocoa has been updated
via 36a26db7848f4b59fb3ce716b748339ba83c05d2 (commit)
via e77ae190ffde1e9e5f85f7a6cc1a38fe8453a129 (commit)
via 683ef22bd671ac7b75d06600c9bd5596a6842492 (commit)
from 01286d85daa07fabbfca1c889bf1b7c2898cfb0b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=36a26db7848f4b59fb3...
commit 36a26db7848f4b59fb3ce716b748339ba83c05d2
Author: Sven Weidauer <sven(a)5sw.de>
Commit: Sven Weidauer <sven(a)5sw.de>
Fix code to determine MIME type and implement data loading.
diff --git a/frontends/cocoa/fetch.m b/frontends/cocoa/fetch.m
index 1e3e5af..764f254 100644
--- a/frontends/cocoa/fetch.m
+++ b/frontends/cocoa/fetch.m
@@ -26,87 +26,106 @@
static char cocoafiletype[200];
-static const struct mimemap_s {
- const char *const extension;
- const char *const mimetype;
-} cocoamimemap[] = {
- { "css", "text/css" },
- { "f79", "text/css" },
- { "jpg", "image/jpeg" },
- { "jpeg", "image/jpeg" },
- { "gif", "image/gif" },
- { "png", "image/png" },
- { "b60", "image/png" },
- { "jng", "image/jng" },
- { "svg", "image/svg" },
- { NULL, "text/html" }
-};
-
static const char *fetch_filetype(const char *unix_path)
{
- NSString *uti;
- NSString *mimeType = nil;
- NSError *utiError = nil;
-
- uti = [[NSWorkspace sharedWorkspace] typeOfFile:[NSString
stringWithUTF8String:unix_path] error:&utiError];
- if (nil != uti) {
- NSLOG(netsurf, INFO, "Looking for mimetype from uti \"%s\"",
[uti UTF8String]);
- mimeType = (__bridge_transfer NSString
*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)uti, kUTTagClassMIMEType);
- } else {
- NSAlert *utiAlert = [NSAlert alertWithError:utiError];
- [utiAlert runModal]; // Ignore return value.
-
- NSLOG(netsurf, INFO, "uti call failed");
-
- strncpy(cocoafiletype, "text/html", sizeof(cocoafiletype));
- return cocoafiletype;
+ NSString *path = @(unix_path);
+ NSString *uti = [[NSWorkspace sharedWorkspace] typeOfFile:path error:NULL];
+ if (uti == nil) {
+ // If the file was not found look up the UTI from the file extension.
+ uti = (__bridge_transfer NSString
*)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge
CFStringRef)path.pathExtension, nil);
}
- if (nil != mimeType) {
- strncpy(cocoafiletype, [mimeType UTF8String], sizeof(cocoafiletype));
- } else {
- const char *extension;
+ if (uti == nil) {
+ // We can’t determine the UTI, let’s pretend this is HTML.
+ return "text/html";
+ }
- NSLOG(netsurf, INFO, "mimetype from uti failed");
+ NSString *mimeType = (__bridge_transfer NSString
*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)uti, kUTTagClassMIMEType);
- extension = [(__bridge_transfer NSString
*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)uti, kUTTagClassFilenameExtension)
UTF8String];
+ strncpy(cocoafiletype, [mimeType cStringUsingEncoding: NSUTF8StringEncoding], sizeof
cocoafiletype);
- if (extension == NULL) {
- /* give up and go with default */
- NSLOG(netsurf, INFO, "No extension going with default type");
- strncpy(cocoafiletype, "text/html", sizeof(cocoafiletype));
- } else {
- int eidx = 0; /* index of extension entry */
+ NSLOG(netsurf, INFO, "\tMIME type for '%s' is '%s'",
unix_path, cocoafiletype);
- while ((cocoamimemap[eidx].extension != NULL) &&
(strcmp(cocoamimemap[eidx].extension, extension) != 0)) {
- eidx++;
- }
+ return cocoafiletype;
+}
- strncpy(cocoafiletype,
- cocoamimemap[eidx].mimetype,
- sizeof(cocoafiletype));
- }
- }
+static NSString *findResource(const char *path) {
+ NSString *pathString = @(path);
+ NSString *nspath = [[NSBundle mainBundle] pathForResource:pathString
ofType:@""];
- NSLOG(netsurf, INFO, "\tMIME type for '%s' is '%s'",
unix_path, cocoafiletype);
+ if (nspath == nil) {
+ nspath = [[NSBundle mainBundle] pathForResource: pathString ofType:@""
inDirectory:nil forLocalization:@"en"];
+ }
- return cocoafiletype;
+ return nspath;
}
static nsurl *gui_get_resource_url(const char *path)
{
- nsurl *url = NULL;
- NSString *nspath = [[NSBundle mainBundle] pathForResource:[NSString
stringWithUTF8String:path] ofType:@""];
- if (nspath == nil)
+ NSString *nspath = findResource(path);
+ if (nspath == nil) {
return NULL;
+ }
+
+ nsurl *url = NULL;
nsurl_create([[[NSURL fileURLWithPath:nspath] absoluteString] UTF8String],
&url);
return url;
}
+static nserror cocoa_get_resource_data(const char *path, const uint8_t **data, size_t
*data_len)
+{
+ NSString *resourcePath = findResource(path);
+ if (resourcePath == nil) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ int file = open(resourcePath.fileSystemRepresentation, O_RDONLY);
+ if (file < 0) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ int size = lseek(file, 0, SEEK_END);
+ if (size < 0) {
+ close(file);
+ return NSERROR_INVALID;
+ }
+
+ void *buffer = malloc(size);
+ if (buffer == NULL) {
+ close(file);
+ return NSERROR_NOMEM;
+ }
+
+ lseek(file, 0, SEEK_SET);
+ int readAmount = read(file, buffer, size);
+
+ if (size != readAmount) {
+ free(buffer);
+ close(file);
+ return NSERROR_INVALID;
+ }
+
+ *data = buffer;
+ *data_len = size;
+
+ close(file);
+
+ return NSERROR_OK;
+}
+
+static nserror cocoa_release_resource_data(const uint8_t *data)
+{
+ free((void *)data);
+ return NSERROR_OK;
+}
+
static struct gui_fetch_table fetch_table = {
.filetype = fetch_filetype,
.get_resource_url = gui_get_resource_url,
+
+ .get_resource_data = cocoa_get_resource_data,
+ .release_resource_data = cocoa_release_resource_data,
};
struct gui_fetch_table *cocoa_fetch_table = &fetch_table;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=e77ae190ffde1e9e5f8...
commit e77ae190ffde1e9e5f85f7a6cc1a38fe8453a129
Author: Sven Weidauer <sven(a)5sw.de>
Commit: Sven Weidauer <sven(a)5sw.de>
Copy localized html resources.
diff --git a/frontends/cocoa/Makefile b/frontends/cocoa/Makefile
index 2b98353..92dec45 100644
--- a/frontends/cocoa/Makefile
+++ b/frontends/cocoa/Makefile
@@ -153,17 +153,23 @@ R_RESOURCES := $(addprefix
$(FRONTEND_RESOURCES_DIR)/,$(R_RESOURCES))
R_RESOURCES += $(addprefix
$(FRONTEND_SOURCE_DIR)/PSMTabBarControl/Images/,$(TABBAR_RESOURCES))
LANGUAGES := de en fr it nl
-LOCALIZED_RESOURCES := Localizable.strings
+LOCALIZED_RESOURCES := \
+ Localizable.strings \
+ welcome.html \
+ maps.html \
+ licence.html
+
#languiage project macro
# $1 is language name
# $2 is list of resources per language
define make_lproj
R_RESOURCES += $$(OBJROOT)/$(1).lproj
+$(2):
$$(OBJROOT)/$(1).lproj: $(2)
$(VQ)echo Bundling language $(1)
$(Q)$(MKDIR) -p $$@
- $(Q)cp -pLR $(2) $$@
+ $(Q)for file in $(2) ; do if [ -e $$$$file ]; then cp -pLR $$$$file $$@ ; fi; done
$(Q)$(SPLIT_MESSAGES) -l $(1) -p cocoa -f messages resources/FatMessages >
$$@/Messages
endef
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=683ef22bd671ac7b75d...
commit 683ef22bd671ac7b75d06600c9bd5596a6842492
Author: Sven Weidauer <sven(a)5sw.de>
Commit: Sven Weidauer <sven(a)5sw.de>
Add html resources
diff --git a/frontends/cocoa/res/de.lproj/welcome.html
b/frontends/cocoa/res/de.lproj/welcome.html
new file mode 120000
index 0000000..98a53b2
--- /dev/null
+++ b/frontends/cocoa/res/de.lproj/welcome.html
@@ -0,0 +1 @@
+../../../../!NetSurf/Resources/de/welcome.html,faf
\ No newline at end of file
diff --git a/frontends/cocoa/res/en.lproj/licence.html
b/frontends/cocoa/res/en.lproj/licence.html
new file mode 120000
index 0000000..79f7366
--- /dev/null
+++ b/frontends/cocoa/res/en.lproj/licence.html
@@ -0,0 +1 @@
+../../../../!NetSurf/Resources/en/licence.html,faf
\ No newline at end of file
diff --git a/frontends/cocoa/res/en.lproj/maps.html
b/frontends/cocoa/res/en.lproj/maps.html
new file mode 120000
index 0000000..bb3ffcb
--- /dev/null
+++ b/frontends/cocoa/res/en.lproj/maps.html
@@ -0,0 +1 @@
+../../../../!NetSurf/Resources/en/maps.html,faf
\ No newline at end of file
diff --git a/frontends/cocoa/res/en.lproj/welcome.html
b/frontends/cocoa/res/en.lproj/welcome.html
new file mode 120000
index 0000000..6010992
--- /dev/null
+++ b/frontends/cocoa/res/en.lproj/welcome.html
@@ -0,0 +1 @@
+../../../../!NetSurf/Resources/en/welcome.html,faf
\ No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
frontends/cocoa/Makefile | 10 +-
frontends/cocoa/fetch.m | 133 +++++++++++---------
.../res/de => cocoa/res/de.lproj}/welcome.html | 0
.../res/en => cocoa/res/en.lproj}/licence.html | 0
.../{beos/res/en => cocoa/res/en.lproj}/maps.html | 0
.../res/en => cocoa/res/en.lproj}/welcome.html | 0
6 files changed, 84 insertions(+), 59 deletions(-)
copy frontends/{beos/res/de => cocoa/res/de.lproj}/welcome.html (100%)
copy frontends/{beos/res/en => cocoa/res/en.lproj}/licence.html (100%)
copy frontends/{beos/res/en => cocoa/res/en.lproj}/maps.html (100%)
copy frontends/{beos/res/en => cocoa/res/en.lproj}/welcome.html (100%)
diff --git a/frontends/cocoa/Makefile b/frontends/cocoa/Makefile
index 2b98353..92dec45 100644
--- a/frontends/cocoa/Makefile
+++ b/frontends/cocoa/Makefile
@@ -153,17 +153,23 @@ R_RESOURCES := $(addprefix
$(FRONTEND_RESOURCES_DIR)/,$(R_RESOURCES))
R_RESOURCES += $(addprefix
$(FRONTEND_SOURCE_DIR)/PSMTabBarControl/Images/,$(TABBAR_RESOURCES))
LANGUAGES := de en fr it nl
-LOCALIZED_RESOURCES := Localizable.strings
+LOCALIZED_RESOURCES := \
+ Localizable.strings \
+ welcome.html \
+ maps.html \
+ licence.html
+
#languiage project macro
# $1 is language name
# $2 is list of resources per language
define make_lproj
R_RESOURCES += $$(OBJROOT)/$(1).lproj
+$(2):
$$(OBJROOT)/$(1).lproj: $(2)
$(VQ)echo Bundling language $(1)
$(Q)$(MKDIR) -p $$@
- $(Q)cp -pLR $(2) $$@
+ $(Q)for file in $(2) ; do if [ -e $$$$file ]; then cp -pLR $$$$file $$@ ; fi; done
$(Q)$(SPLIT_MESSAGES) -l $(1) -p cocoa -f messages resources/FatMessages >
$$@/Messages
endef
diff --git a/frontends/cocoa/fetch.m b/frontends/cocoa/fetch.m
index 1e3e5af..764f254 100644
--- a/frontends/cocoa/fetch.m
+++ b/frontends/cocoa/fetch.m
@@ -26,87 +26,106 @@
static char cocoafiletype[200];
-static const struct mimemap_s {
- const char *const extension;
- const char *const mimetype;
-} cocoamimemap[] = {
- { "css", "text/css" },
- { "f79", "text/css" },
- { "jpg", "image/jpeg" },
- { "jpeg", "image/jpeg" },
- { "gif", "image/gif" },
- { "png", "image/png" },
- { "b60", "image/png" },
- { "jng", "image/jng" },
- { "svg", "image/svg" },
- { NULL, "text/html" }
-};
-
static const char *fetch_filetype(const char *unix_path)
{
- NSString *uti;
- NSString *mimeType = nil;
- NSError *utiError = nil;
-
- uti = [[NSWorkspace sharedWorkspace] typeOfFile:[NSString
stringWithUTF8String:unix_path] error:&utiError];
- if (nil != uti) {
- NSLOG(netsurf, INFO, "Looking for mimetype from uti \"%s\"",
[uti UTF8String]);
- mimeType = (__bridge_transfer NSString
*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)uti, kUTTagClassMIMEType);
- } else {
- NSAlert *utiAlert = [NSAlert alertWithError:utiError];
- [utiAlert runModal]; // Ignore return value.
-
- NSLOG(netsurf, INFO, "uti call failed");
-
- strncpy(cocoafiletype, "text/html", sizeof(cocoafiletype));
- return cocoafiletype;
+ NSString *path = @(unix_path);
+ NSString *uti = [[NSWorkspace sharedWorkspace] typeOfFile:path error:NULL];
+ if (uti == nil) {
+ // If the file was not found look up the UTI from the file extension.
+ uti = (__bridge_transfer NSString
*)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge
CFStringRef)path.pathExtension, nil);
}
- if (nil != mimeType) {
- strncpy(cocoafiletype, [mimeType UTF8String], sizeof(cocoafiletype));
- } else {
- const char *extension;
+ if (uti == nil) {
+ // We can’t determine the UTI, let’s pretend this is HTML.
+ return "text/html";
+ }
- NSLOG(netsurf, INFO, "mimetype from uti failed");
+ NSString *mimeType = (__bridge_transfer NSString
*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)uti, kUTTagClassMIMEType);
- extension = [(__bridge_transfer NSString
*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)uti, kUTTagClassFilenameExtension)
UTF8String];
+ strncpy(cocoafiletype, [mimeType cStringUsingEncoding: NSUTF8StringEncoding], sizeof
cocoafiletype);
- if (extension == NULL) {
- /* give up and go with default */
- NSLOG(netsurf, INFO, "No extension going with default type");
- strncpy(cocoafiletype, "text/html", sizeof(cocoafiletype));
- } else {
- int eidx = 0; /* index of extension entry */
+ NSLOG(netsurf, INFO, "\tMIME type for '%s' is '%s'",
unix_path, cocoafiletype);
- while ((cocoamimemap[eidx].extension != NULL) &&
(strcmp(cocoamimemap[eidx].extension, extension) != 0)) {
- eidx++;
- }
+ return cocoafiletype;
+}
- strncpy(cocoafiletype,
- cocoamimemap[eidx].mimetype,
- sizeof(cocoafiletype));
- }
- }
+static NSString *findResource(const char *path) {
+ NSString *pathString = @(path);
+ NSString *nspath = [[NSBundle mainBundle] pathForResource:pathString
ofType:@""];
- NSLOG(netsurf, INFO, "\tMIME type for '%s' is '%s'",
unix_path, cocoafiletype);
+ if (nspath == nil) {
+ nspath = [[NSBundle mainBundle] pathForResource: pathString ofType:@""
inDirectory:nil forLocalization:@"en"];
+ }
- return cocoafiletype;
+ return nspath;
}
static nsurl *gui_get_resource_url(const char *path)
{
- nsurl *url = NULL;
- NSString *nspath = [[NSBundle mainBundle] pathForResource:[NSString
stringWithUTF8String:path] ofType:@""];
- if (nspath == nil)
+ NSString *nspath = findResource(path);
+ if (nspath == nil) {
return NULL;
+ }
+
+ nsurl *url = NULL;
nsurl_create([[[NSURL fileURLWithPath:nspath] absoluteString] UTF8String],
&url);
return url;
}
+static nserror cocoa_get_resource_data(const char *path, const uint8_t **data, size_t
*data_len)
+{
+ NSString *resourcePath = findResource(path);
+ if (resourcePath == nil) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ int file = open(resourcePath.fileSystemRepresentation, O_RDONLY);
+ if (file < 0) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ int size = lseek(file, 0, SEEK_END);
+ if (size < 0) {
+ close(file);
+ return NSERROR_INVALID;
+ }
+
+ void *buffer = malloc(size);
+ if (buffer == NULL) {
+ close(file);
+ return NSERROR_NOMEM;
+ }
+
+ lseek(file, 0, SEEK_SET);
+ int readAmount = read(file, buffer, size);
+
+ if (size != readAmount) {
+ free(buffer);
+ close(file);
+ return NSERROR_INVALID;
+ }
+
+ *data = buffer;
+ *data_len = size;
+
+ close(file);
+
+ return NSERROR_OK;
+}
+
+static nserror cocoa_release_resource_data(const uint8_t *data)
+{
+ free((void *)data);
+ return NSERROR_OK;
+}
+
static struct gui_fetch_table fetch_table = {
.filetype = fetch_filetype,
.get_resource_url = gui_get_resource_url,
+
+ .get_resource_data = cocoa_get_resource_data,
+ .release_resource_data = cocoa_release_resource_data,
};
struct gui_fetch_table *cocoa_fetch_table = &fetch_table;
diff --git a/frontends/beos/res/de/welcome.html
b/frontends/cocoa/res/de.lproj/welcome.html
similarity index 100%
copy from frontends/beos/res/de/welcome.html
copy to frontends/cocoa/res/de.lproj/welcome.html
diff --git a/frontends/beos/res/en/licence.html
b/frontends/cocoa/res/en.lproj/licence.html
similarity index 100%
copy from frontends/beos/res/en/licence.html
copy to frontends/cocoa/res/en.lproj/licence.html
diff --git a/frontends/beos/res/en/maps.html b/frontends/cocoa/res/en.lproj/maps.html
similarity index 100%
copy from frontends/beos/res/en/maps.html
copy to frontends/cocoa/res/en.lproj/maps.html
diff --git a/frontends/beos/res/en/welcome.html
b/frontends/cocoa/res/en.lproj/welcome.html
similarity index 100%
copy from frontends/beos/res/en/welcome.html
copy to frontends/cocoa/res/en.lproj/welcome.html
--
NetSurf Browser