]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into samual/keepaway
authorunknown <samual@xonotic.org>
Sat, 27 Nov 2010 01:36:53 +0000 (20:36 -0500)
committerunknown <samual@xonotic.org>
Sat, 27 Nov 2010 01:36:53 +0000 (20:36 -0500)
qcsrc/menu/gamecommand.qc
qcsrc/menu/mbuiltin.qh
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

index 4b2b9cf0c921345dd48d4032b745a9971b2600b3..104c8840e58cda121daecb6afd36c6b68f2083cf 100644 (file)
@@ -31,6 +31,30 @@ void _dumptree_close(entity pass, entity me)
        }
 }
 
+float curl_uri_get_pos;
+float curl_uri_get_exec[URI_GET_CURL_END - URI_GET_CURL + 1];
+string curl_uri_get_cvar[URI_GET_CURL_END - URI_GET_CURL + 1];
+void Curl_URI_Get_Callback(float id, float status, string data)
+{
+       float i;
+       float do_exec;
+       string do_cvar;
+       i = id - URI_GET_CURL;
+       do_exec = curl_uri_get_exec[i];
+       do_cvar = curl_uri_get_cvar[i];
+       if(status != 0)
+       {
+               print("error: status is ", ftos(status), "\n");
+               return;
+       }
+       if(do_exec)
+               localcmd(data);
+       if(do_cvar)
+               cvar_set(do_cvar, data);
+       if(!do_exec && !do_cvar)
+               print(data);
+}
+
 void GameCommand(string theCommand)
 {
        float argc;
@@ -100,6 +124,72 @@ void GameCommand(string theCommand)
                return;
        }
 
+       if(argv(0) == "curl")
+       {
+               float do_exec;
+               string do_cvar;
+               float key;
+               float i, j;
+               string url;
+               float buf;
+               float r;
+
+               do_exec = FALSE;
+               do_cvar = string_null;
+               key = -1;
+
+               for(i = 1; i+1 < argc; ++i)
+               {
+                       if(argv(i) == "--cvar" && i+2 < argc)
+                       {
+                               ++i;
+                               do_cvar = argv(i);
+                               continue;
+                       }
+                       if(argv(i) == "--exec")
+                       {
+                               do_exec = TRUE;
+                               continue;
+                       }
+                       if(argv(i) == "--key" && i+2 < argc)
+                       {
+                               ++i;
+                               key = stof(argv(i));
+                               continue;
+                       }
+                       break;
+               }
+
+               // now, argv(i) is the URL
+               // following args may be POST parameters
+               url = argv(i);
+               ++i;
+               buf = buf_create();
+               j = 0;
+               for(; i+1 < argc; i += 2)
+                       bufstr_set(buf, ++j, sprintf("%s=%s", uri_escape(argv(i)), uri_escape(argv(i+1))));
+               if(i < argc)
+                       bufstr_set(buf, ++j, sprintf("submit=%s", uri_escape(argv(i))));
+
+               if(j == 0) // no args: GET
+                       r = crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, string_null, string_null, -1, key);
+               else // with args: POST
+                       r = crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, "application/x-www-form-urlencoded", "&", buf, key);
+
+               if(r)
+               {
+                       curl_uri_get_exec[curl_uri_get_pos] = do_exec;
+                       curl_uri_get_cvar[curl_uri_get_pos] = do_cvar;
+                       curl_uri_get_pos = mod(curl_uri_get_pos + 1, URI_GET_CURL_END - URI_GET_CURL + 1);
+               }
+               else
+                       print("error creating curl handle\n");
+
+               buf_del(buf);
+
+               return;
+       }
+
 #if 0
        if(argv(0) == "tokentest")
        {
index 699548197bc668e151ee279eb061960ec77eb97d..761b63a83b30dc1a97990cdc7a172e6c53e3de40 100644 (file)
@@ -381,4 +381,5 @@ string(string format, ...) sprintf = #627;
 string crypto_getkeyfp(string serveraddress) = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address
 string crypto_getidfp(string serveraddress) = #634; // retrieves the cached host key fingerprint of a server given by IP address
 string crypto_getencryptlevel(string serveraddress) = #635; // 0 if never encrypting, 1 supported, 2 requested, 3 required, appended by list of allowed methods in order of preference ("AES128"), preceded by a space each
+float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
 //description:
index 6f5b037acff686485fba7aeef08c1b75ed2e118c..0bacab7a49baa63160dc158f6286f04ffa35501e 100644 (file)
@@ -234,11 +234,6 @@ void setDependentWeird(entity e, float(entity) func)
 float _Nex_ExtResponseSystem_Queried;
 string _Nex_ExtResponseSystem_UpdateTo;
 
-float URI_GET_DISCARD = 0;
-
-float URI_GET_UPDATENOTIFICATION = 1;
-void UpdateNotification_URI_Get_Callback(float id, float status, string data);
-
 void URI_Get_Callback(float id, float status, string data)
 {
        if (id == URI_GET_DISCARD)
@@ -247,9 +242,12 @@ void URI_Get_Callback(float id, float status, string data)
        }
        else if(id == URI_GET_UPDATENOTIFICATION)
        {
-               // online ban list
                UpdateNotification_URI_Get_Callback(id, status, data);
        }
+       else if(id >= URI_GET_CURL && id <= URI_GET_CURL_END)
+       {
+               Curl_URI_Get_Callback(id, status, data);
+       }
        else
        {
                print("Received HTTP request data for an invalid id ", ftos(id), ".\n");
@@ -361,7 +359,8 @@ void preMenuDraw()
                if(!_Nex_ExtResponseSystem_Queried)
                {
                        _Nex_ExtResponseSystem_Queried = 1;
-                       uri_get(sprintf("http://www.xonotic.org/dl/checkupdate.txt?version=%s", uri_escape(cvar_string("g_xonoticversion"))), URI_GET_UPDATENOTIFICATION);
+                       //uri_get(sprintf("http://www.xonotic.org/dl/checkupdate.txt?version=%s", uri_escape(cvar_string("g_xonoticversion"))), URI_GET_UPDATENOTIFICATION);
+                       crypto_uri_postbuf(sprintf("http://www.xonotic.org/dl/t/checkupdate2.cgi?version=%s", uri_escape(cvar_string("g_xonoticversion"))), URI_GET_UPDATENOTIFICATION, "application/x-www-urlencoded", "hello=world&foo=bar", -1, 0);
                }
        }
 
index 78eb7c1c43caa7cea3019c50652e7ab4173497db..ace912dc21394bbcde6a5a6e9398eb443eecbd7a 100644 (file)
@@ -20,3 +20,14 @@ string getZonedTooltipForIdentifier(string s);
 string resolvemod(string m);
 
 string HUD_Panel_GetSettingName(float setting);
+
+float URI_GET_DISCARD = 0;
+
+float URI_GET_UPDATENOTIFICATION = 1;
+void UpdateNotification_URI_Get_Callback(float id, float status, string data);
+
+float URI_GET_CURL = 2;
+float URI_GET_CURL_END = 9;
+void Curl_URI_Get_Callback(float id, float status, string data);
+
+void URI_Get_Callback(float id, float status, string data);