1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/* Binding to generate Navigator interface
*
* Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* Released under the terms of the MIT License,
* http://www.opensource.org/licenses/mit-license
*/
#include "dom.bnd"
webidlfile "html.idl";
hdrcomment "Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>";
hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
hdrcomment "Released under the terms of the MIT License,";
hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
#include <assert.h>
#include <stdlib.h>
#include "desktop/netsurf.h"
#include "desktop/options.h"
#include "utils/config.h"
#include "utils/useragent.h"
#include "utils/log.h"
#include "utils/utsname.h"
#include "javascript/jsapi.h"
#include "javascript/jsapi/binding.h"
/*
* navigator properties for netsurf
*
* Property | Everyone else | NetSurf | Notes
* ------------+-----------------+--------------+------------------------------
* appCodeName | "Mozilla" | "NetSurf" | This is kinda a pointless
* | | | constant as everyone returns
* | | | "Mozilla" which is dumb
* ------------+-----------------+--------------+------------------------------
* appName | "<Browsername>" | "NetSurf" | Browsers named other than
* | | | "Netscape", "Mozilla",
* | | | "Netscape Navigator",
* | | | "Microsoft Internet Explorer"
* | | | often other browser have
* | | | "(compatible with Netscape)"
* | | | append.
* ------------+-----------------+--------------+------------------------------
* appVersion | "<ver> (<type>)"| "<ver>" | Actually just the version
* | | | number e.g "3.0".
* ------------+-----------------+--------------+------------------------------
* language | "<lang>" | "<lang>" | The language the frontend is
* | | | configured for
* ------------+-----------------+--------------+------------------------------
* platform | "<krn> <hw>" | "<krn> <hw>" | Efectively uname -s -i,
* | | | eg "Linux x86_64"
* ------------+-----------------+--------------+------------------------------
* userAgent | "Mozilla/5.0 (" | "NetSurf" | The usual useragent string
* | | | with excessive lies
* ------------+-----------------+--------------+------------------------------
*/
#define NAVIGATOR_APPNAME "NetSurf"
#define NAVIGATOR_APPCODENAME "NetSurf"
%}
binding navigator {
type js_libdom; /* the binding type */
interface Navigator; /* Web IDL interface to generate */
}
getter appName %{
jsret = JS_NewStringCopyZ(cx, NAVIGATOR_APPNAME);
%}
getter appCodeName %{
jsret = JS_NewStringCopyZ(cx, NAVIGATOR_APPCODENAME);
%}
getter appVersion %{
jsret = JS_NewStringCopyZ(cx, netsurf_version);
%}
getter language %{
const char *alang = nsoption_charp(accept_language);
if (alang != NULL) {
jsret = JS_NewStringCopyZ(cx, alang);
}
%}
getter platform %{
struct utsname *cutsname;
cutsname = malloc(sizeof(struct utsname));
if ((cutsname != NULL) && (uname(cutsname) >= 0)) {
char *platstr;
int platstrlen;
platstrlen = strlen(cutsname->sysname) + strlen(cutsname->machine) + 2;
platstr = malloc(platstrlen);
if (platstr != NULL) {
snprintf(platstr, platstrlen, "%s %s", cutsname->sysname, cutsname->machine);
jsret = JS_NewStringCopyN(cx, platstr, platstrlen - 1);
free(platstr);
}
}
%}
getter userAgent %{
jsret = JS_NewStringCopyZ(cx, user_agent_string());
%}
|