diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-08 17:34:37 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-08 17:34:37 (GMT) |
| commit | 346e9d21689c9616dae3f3d858071b7181979663 (patch) | |
| tree | f42a76bc0096ed2231942d01620f752b5f150c39 /src | |
| parent | 73a18998f6791ae21a568996b5d0b884110b87d5 (diff) | |
| download | powder-346e9d21689c9616dae3f3d858071b7181979663.zip powder-346e9d21689c9616dae3f3d858071b7181979663.tar.gz | |
Proxy from command line arg
Diffstat (limited to 'src')
| -rw-r--r-- | src/PowderToySDL.cpp | 28 | ||||
| -rw-r--r-- | src/client/Client.cpp | 24 | ||||
| -rw-r--r-- | src/client/Client.h | 3 |
3 files changed, 45 insertions, 10 deletions
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 0e01c66..82a6856 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -244,9 +244,12 @@ std::map<std::string, std::string> readArguments(int argc, char * argv[]) { arguments["scale"] = std::string(argv[i]+6); } - else if (!strncmp(argv[i], "proxy:", 6) && argv[i]+6) + else if (!strncmp(argv[i], "proxy:", 6)) { - arguments["proxy"] = std::string(argv[i]+6); + if(argv[i]+6) + arguments["proxy"] = std::string(argv[i]+6); + else + arguments["proxy"] = "false"; } else if (!strncmp(argv[i], "nohud", 5)) { @@ -319,6 +322,27 @@ int main(int argc, char * argv[]) Client::Ref().SetPref("Scale", tempScale); } + std::string proxyString = ""; + if(arguments["proxy"].length()) + { + if(arguments["proxy"] == "false") + { + proxyString = ""; + Client::Ref().SetPref("Proxy", ""); + } + else + { + proxyString = (arguments["proxy"]); + Client::Ref().SetPref("Proxy", arguments["proxy"]); + } + } + else if(Client::Ref().GetPrefString("Proxy", "").length()) + { + proxyString = (Client::Ref().GetPrefString("Proxy", "")); + } + + Client::Ref().Initialise(proxyString); + if(tempScale != 1 && tempScale != 2) tempScale = 1; diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 64abe0e..56d436b 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -39,10 +39,10 @@ extern "C" Client::Client(): authUser(0, ""), - updateAvailable(false) + updateAvailable(false), + versionCheckRequest(NULL) { int i = 0; - std::string proxyString(""); for(i = 0; i < THUMB_CACHE_SIZE; i++) { thumbnailCache[i] = NULL; @@ -89,6 +89,10 @@ Client::Client(): } configFile.close(); } +} + +void Client::Initialise(std::string proxyString) +{ if(GetPrefBool("version.update", false)==true) { @@ -96,15 +100,10 @@ Client::Client(): update_finish(); } - proxyString = GetPrefString("proxy", ""); if(proxyString.length()) - { - http_init((char *)proxyString.c_str()); - } + http_init((char*)proxyString.c_str()); else - { http_init(NULL); - } //Read stamps library std::ifstream stampsLib; @@ -125,6 +124,15 @@ Client::Client(): versionCheckRequest = http_async_req_start(NULL, SERVER "/Download/Version.json", NULL, 0, 1); } +void Client::SetProxy(std::string proxy) +{ + http_done(); + if(proxy.length()) + http_init((char*)proxy.c_str()); + else + http_init(NULL); +} + std::vector<std::string> Client::DirectorySearch(std::string directory, std::string search, std::string extension) { std::vector<std::string> extensions; diff --git a/src/client/Client.h b/src/client/Client.h index 9bb9d5f..748c96e 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -88,6 +88,9 @@ public: std::vector<unsigned char> ReadFile(std::string filename); + void Initialise(std::string proxyString); + void SetProxy(std::string proxy); + void WriteFile(std::vector<unsigned char> fileData, std::string filename); void WriteFile(std::vector<char> fileData, std::string filename); bool FileExists(std::string filename); |
