[0.1.1-8] support for iceball:// URLs in the client. iceball:// URL binder to come (no, that .sh does not work here).

This commit is contained in:
Ben Russell (300178622) 2013-08-01 17:40:30 +12:00
parent e145f9a362
commit df38567cc3
7 changed files with 70 additions and 20 deletions

View File

@ -115,7 +115,7 @@ class HTTPClient:
s += "<tr>" s += "<tr>"
s += "<td>" + sanestr(d["address"]) + "</td>" s += "<td>" + sanestr(d["address"]) + "</td>"
s += "<td>" + sanestr(d["port"]) + "</td>" s += "<td>" + sanestr(d["port"]) + "</td>"
s += "<td>" + sanestr(d["name"]) + "</td>" s += "<td>" + "<a href=\"iceball://" + sanestr(d["address"]) + ":" + sanestr(d["port"]) + "\">" + sanestr(d["name"]) + "</a>" + "</td>"
s += "<td>" + sanestr(d["version"]) + "</td>" s += "<td>" + sanestr(d["version"]) + "</td>"
s += "<td>" + sanestr(d["players_current"]) + " / " + sanestr(d["players_max"]) + "</td>" s += "<td>" + sanestr(d["players_current"]) + " / " + sanestr(d["players_max"]) + "</td>"
s += "<td>" + sanestr(d["mode"]) + "</td>" s += "<td>" + sanestr(d["mode"]) + "</td>"

View File

@ -19,7 +19,7 @@
#define VERSION_X 1 #define VERSION_X 1
#define VERSION_Y 1 #define VERSION_Y 1
#define VERSION_A 0 #define VERSION_A 0
#define VERSION_Z 7 #define VERSION_Z 8
// Remember to bump "Z" basically every time you change the engine! // Remember to bump "Z" basically every time you change the engine!
// Remember to bump the version in Lua too! // Remember to bump the version in Lua too!
// Remember to document API changes in a new version! // Remember to document API changes in a new version!
@ -467,6 +467,7 @@ extern int force_redraw;
extern int net_port; extern int net_port;
extern char *net_addr; extern char *net_addr;
extern char net_addr_xbuf[];
extern int boot_mode; extern int boot_mode;
extern char *mod_basedir; extern char *mod_basedir;

View File

@ -101,12 +101,15 @@ function string.trim(s, sep)
return string.triml(string.trimr(s, sep), sep) return string.triml(string.trimr(s, sep), sep)
end end
function parse_commandline_options(options) function parse_commandline_options(options, nocheckdash, na, nb, nc)
local user_toggles = {} -- toggle options (key is name, value is position) local loose = na or {} -- loose strings, filenames, etc.
local user_settings = {} -- key-value pairs local user_toggles = nb or {} -- toggle options (key is name, value is position)
local loose = {} -- loose strings, filenames, etc. local user_settings = nc or {} -- key-value pairs
for k, v in pairs(options) do for k, v in pairs(options) do
if nocheckdash then
v = "-" .. v
end
local setting_pair = string.split(v, "=") local setting_pair = string.split(v, "=")
local first = string.byte(v,1) local first = string.byte(v,1)
if first==string.byte('-') then -- we are toggling an option or setting a value if first==string.byte('-') then -- we are toggling an option or setting a value
@ -116,6 +119,17 @@ function parse_commandline_options(options)
else else
user_toggles[string.triml(v, '-')]=k user_toggles[string.triml(v, '-')]=k
end end
elseif first == string.byte('/') then -- optional extra arg on URI
-- look for a ? thing
local npair = string.split(v:sub(2), "?")
if npair[1] ~= "" then
user_settings[" "] = npair[1]
end
if npair[2] then
-- TODO: URI-decode
local nopts = string.split(npair[2], "&")
parse_commandline_options(nopts, true, loose, user_toggles, user_settings)
end
else -- add to the loose values else -- add to the loose values
loose[#loose+1] = v loose[#loose+1] = v
end end

View File

@ -16,9 +16,9 @@
]] ]]
VERSION_ENGINE = { VERSION_ENGINE = {
cmp={0,1,1,0,5}, cmp={0,1,1,0,8},
num=4227072+5, num=4227072+8,
str="0.1.1-5", str="0.1.1-8",
} }
-- 0.1: 4194304 -- 0.1: 4194304
@ -108,5 +108,6 @@ VERSION_BUGS = {
{renderer="softgm", intro=4227072+5, fix=4227072+7, msg="[softgm] Image scaling not supported"}, {renderer="softgm", intro=4227072+5, fix=4227072+7, msg="[softgm] Image scaling not supported"},
{intro=4227072+5, fix=4227072+6, msg="Image scaling accidentally only supported integers for scale parameters"}, {intro=4227072+5, fix=4227072+6, msg="Image scaling accidentally only supported integers for scale parameters"},
{intro=4227072+5, fix=4227072+7, msg="Incompatible semantics for image scaling"}, {intro=4227072+5, fix=4227072+7, msg="Incompatible semantics for image scaling"},
{intro=nil, fix=4227072+8, msg="iceball:// URL scheme not supported"},
} }

View File

@ -289,6 +289,11 @@ int icelua_initfetch(void)
printf("Client loaded! Initialising...\n"); printf("Client loaded! Initialising...\n");
for(i = 0; i < argct; i++) for(i = 0; i < argct; i++)
lua_pushstring(lstate_client, main_argv[i+main_largstart]); lua_pushstring(lstate_client, main_argv[i+main_largstart]);
if((boot_mode & 1) && net_addr_xbuf[1] != '\x00')
{
lua_pushstring(lstate_client, net_addr_xbuf);
argct++;
}
if(lua_pcall(lstate_client, argct, 0, 0) != 0) if(lua_pcall(lstate_client, argct, 0, 0) != 0)
{ {
printf("ERROR running client Lua: %s\n", lua_tostring(lstate_client, -1)); printf("ERROR running client Lua: %s\n", lua_tostring(lstate_client, -1));

View File

@ -46,6 +46,8 @@ int boot_mode = 0;
char *mod_basedir = NULL; char *mod_basedir = NULL;
char *net_addr; char *net_addr;
char net_addr_buf[1024];
char net_addr_xbuf[1024];
int net_port; int net_port;
int main_argc; int main_argc;
@ -564,8 +566,10 @@ int print_usage(char *rname)
fprintf(stderr, "usage:\n" fprintf(stderr, "usage:\n"
#ifndef DEDI #ifndef DEDI
"\tfor clients:\n" "\tfor clients:\n"
"\t\t%s -c address port {clargs} <-- connect via ENet protocol (UDP)\n" "\t\t%s -c iceball://address:port {clargs} <-,_ connect via ENet protocol (UDP)\n"
"\t\t%s -C address port {clargs} <-- connect via TCP protocol\n" "\t\t%s -c address port {clargs} <-'\n"
"\t\t%s -C iceball://address:port {clargs} <-,_ connect via TCP protocol\n"
"\t\t%s -C address port {clargs} <-'\n"
"\tfor servers (quick-start, not recommended for anything serious!):\n" "\tfor servers (quick-start, not recommended for anything serious!):\n"
"\t\t%s -s port mod {args}\n" "\t\t%s -s port mod {args}\n"
#endif #endif
@ -590,7 +594,7 @@ int print_usage(char *rname)
#endif #endif
"\targs: arguments to send to the server Lua script\n" "\targs: arguments to send to the server Lua script\n"
#ifndef DEDI #ifndef DEDI
,rname,rname,rname ,rname,rname,rname,rname,rname
#endif #endif
,rname,rname); ,rname,rname);
@ -630,25 +634,45 @@ int main_dbghelper(int argc, char *argv[])
if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "/?")) || (!strcmp(argv[1], "-?")) || (!strcmp(argv[1], "--help"))) { if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "/?")) || (!strcmp(argv[1], "-?")) || (!strcmp(argv[1], "--help"))) {
return print_usage(argv[0]); return print_usage(argv[0]);
} else if(!strcmp(argv[1], "-c")) { } else if(!strcmp(argv[1], "-c")) {
if(argc <= 3) if(argc <= 2 || (argc <= 3 && memcmp(argv[2], "iceball://", 10)))
return print_usage(argv[0]); return print_usage(argv[0]);
net_addr = argv[2]; net_port = 20737;
net_port = atoi(argv[3]); main_largstart = 3;
net_addr = net_addr_buf;
net_addr_xbuf[0] = '/';
net_addr_xbuf[1] = '\x00';
if(sscanf(argv[2], "iceball://%[^:]:%i/%s", net_addr, &net_port, &net_addr_xbuf[1]) < 1)
{
if(argc <= 3)
return print_usage(argv[0]);
net_addr = argv[2];
net_port = atoi(argv[3]);
main_largstart = 4;
}
printf("Connecting to \"%s\" port %i (ENet mode)\n", net_addr, net_port); printf("Connecting to \"%s\" port %i (ENet mode)\n", net_addr, net_port);
mod_basedir = NULL; mod_basedir = NULL;
main_largstart = 4;
boot_mode = 1 | 16; boot_mode = 1 | 16;
} else if(!strcmp(argv[1], "-C")) { } else if(!strcmp(argv[1], "-C")) {
if(argc <= 3) if(argc <= 2 || (argc <= 3 && memcmp(argv[2], "iceball://", 10)))
return print_usage(argv[0]); return print_usage(argv[0]);
net_addr = argv[2]; net_port = 20737;
net_port = atoi(argv[3]); main_largstart = 3;
net_addr = net_addr_buf;
net_addr_xbuf[0] = '/';
net_addr_xbuf[1] = '\x00';
if(sscanf(argv[2], "iceball://%[^:]:%i/%s", net_addr, &net_port, &net_addr_xbuf[1]) < 1)
{
if(argc <= 3)
return print_usage(argv[0]);
net_addr = argv[2];
net_port = atoi(argv[3]);
main_largstart = 4;
}
printf("Connecting to \"%s\" port %i (TCP mode)\n", net_addr, net_port); printf("Connecting to \"%s\" port %i (TCP mode)\n", net_addr, net_port);
mod_basedir = NULL; mod_basedir = NULL;
main_largstart = 4;
boot_mode = 1; boot_mode = 1;
//return 101; //return 101;

5
url-set-unix-gnome.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
gconftool-2 -s /desktop/gnome/url-handlers/iceball/command "$(pwd)/iceball-gl -c %s" --type String
gconftool-2 -s /desktop/gnome/url-handlers/iceball/enabled --type Boolean true
gconftool-2 -s /desktop/gnome/url-handlers/iceball/needs-terminal --type Boolean true