fetch mimetype and missing fetch resource path
This commit is contained in:
parent
4664d6a1d4
commit
d4186faa09
|
@ -3,6 +3,7 @@
|
|||
#import "netsurf/netsurf.h"
|
||||
#import "utils/nsoption.h"
|
||||
#import "utils/nsurl.h"
|
||||
#import "utils/log.h"
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "BrowserWindowController.h"
|
||||
|
@ -58,6 +59,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
|
|||
int main(int argc, char **argv) {
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
|
||||
nslog_init(NULL, &argc, argv);
|
||||
nserror error;
|
||||
struct netsurf_table gnustep_table = {
|
||||
.misc = &gnustep_misc_table,
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "netsurf/netsurf.h"
|
||||
#import <string.h>
|
||||
#import <libgen.h>
|
||||
#import "utils/url.h"
|
||||
#import "netsurf/fetch.h"
|
||||
|
||||
|
||||
/*******************/
|
||||
/****** Fetch ******/
|
||||
/*******************/
|
||||
|
@ -10,11 +12,41 @@
|
|||
// Return the MIME type of the specified file. Returned string can be inval on next req.
|
||||
static const char *gnustep_fetch_filetype(const char *unix_path) {
|
||||
NSLog(@"gnustep_fetch_filetype");
|
||||
static char filetype[100];
|
||||
filetype[0] = '\0';
|
||||
return filetype;
|
||||
char *bnam;
|
||||
char *ext;
|
||||
|
||||
bnam = basename(unix_path);
|
||||
ext = strrchr(bnam, '.');
|
||||
if (ext == NULL) {
|
||||
return "text/html";
|
||||
}
|
||||
ext += 1;
|
||||
|
||||
if (strncmp(ext, "css", 3) == 0) {
|
||||
return "text/css";
|
||||
} else if (strncmp(ext, "jpeg", 4) == 0 || strncmp(ext, "jpg", 3) == 0) {
|
||||
return "image/jpeg";
|
||||
} else if (strncmp(ext, "gif", 3) == 0) {
|
||||
return "image/gif";
|
||||
} else if (strncmp(ext, "png", 3) == 0) {
|
||||
return "image/png";
|
||||
} else {
|
||||
return "text/html";
|
||||
}
|
||||
}
|
||||
|
||||
static const char *gnustep_fetch_get_resource_url(const char *path) {
|
||||
struct nsurl *url = NULL;
|
||||
NSString *nspath = [[NSBundle mainBundle] pathForResource: [NSString
|
||||
stringWithUTF8String: path] ofType: @""];
|
||||
if (nspath == nil) {
|
||||
return NULL;
|
||||
}
|
||||
nsurl_create([[[NSURL fileURLWithPath: nspath] absoluteString] UTF8String], &url);
|
||||
return url;
|
||||
}
|
||||
|
||||
struct gui_fetch_table gnustep_fetch_table = {
|
||||
.filetype = gnustep_fetch_filetype
|
||||
.filetype = gnustep_fetch_filetype,
|
||||
.get_resource_url = gnustep_fetch_get_resource_url
|
||||
};
|
|
@ -10,10 +10,10 @@
|
|||
/*******************/
|
||||
|
||||
// Schedule a callback to be run after t ms, or removed if ngtv, func and param.
|
||||
static nserror gnustep_misc_schedule(int t, void (*callback)(void *p), void *p) {
|
||||
NSLog(@"gnustep_misc_schedule in %dms", t);
|
||||
static nserror gnustep_misc_schedule(int t, void (*callback)(void *p), void *cbctx) {
|
||||
//NSLog(@"gnustep_misc_schedule in %dms", t);
|
||||
NetsurfCallback *nsCallback = [NetsurfCallback newOrScheduledWithFunctionPointer:
|
||||
callback parameter: p];
|
||||
callback parameter: cbctx];
|
||||
if (t < 0) {
|
||||
[nsCallback cancel];
|
||||
return NSERROR_OK;
|
||||
|
|
|
@ -105,6 +105,8 @@ nserror nsgtk_schedule(int t, void (*callback)(void *p), void *cbctx)
|
|||
_nsgtk_callback_t *cb;
|
||||
nserror res;
|
||||
|
||||
printf("nsgtk_schedule %p in %dms\n", callback, t);
|
||||
|
||||
/* Kill any pending schedule of this kind. */
|
||||
res = schedule_remove(callback, cbctx);
|
||||
|
||||
|
|
Loading…
Reference in New Issue