aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/hippoUpdate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/hippoUpdate.cpp')
-rw-r--r--linden/indra/newview/hippoUpdate.cpp184
1 files changed, 92 insertions, 92 deletions
diff --git a/linden/indra/newview/hippoUpdate.cpp b/linden/indra/newview/hippoUpdate.cpp
index 7a33487..872ca30 100644
--- a/linden/indra/newview/hippoUpdate.cpp
+++ b/linden/indra/newview/hippoUpdate.cpp
@@ -1,92 +1,92 @@
1 1
2#include "hippoUpdate.h" 2#include "hippoUpdate.h"
3 3
4#include <cstdio> 4#include <cstdio>
5#include <list> 5#include <list>
6#include <vector> 6#include <vector>
7 7
8#include <stdtypes.h> 8#include <stdtypes.h>
9#include <llhttpclient.h> 9#include <llhttpclient.h>
10#include <llmemory.h> 10#include <llmemory.h>
11#include <llversionviewer.h> 11#include <llversionviewer.h>
12#include "llviewercontrol.h" 12#include "llviewercontrol.h"
13#include "llviewernetwork.h" 13#include "llviewernetwork.h"
14#include "llweb.h" 14#include "llweb.h"
15#include <llwindow.h> 15#include <llwindow.h>
16 16
17 17
18std::string gHippoChannel; 18std::string gHippoChannel;
19 19
20 20
21// static 21// static
22bool HippoUpdate::checkUpdate() 22bool HippoUpdate::checkUpdate()
23{ 23{
24 llinfos << "Hippo Update Check..." << llendl; 24 llinfos << "Hippo Update Check..." << llendl;
25 25
26 // get channel name 26 // get channel name
27 gHippoChannel = gSavedSettings.getString("ChannelName"); 27 gHippoChannel = gSavedSettings.getString("ChannelName");
28 28
29 // get mac address 29 // get mac address
30 char macAddress[18]; 30 char macAddress[18];
31 sprintf(macAddress, "%02x:%02x:%02x:%02x:%02x:%02x", 31 sprintf(macAddress, "%02x:%02x:%02x:%02x:%02x:%02x",
32 gMACAddress[0], gMACAddress[1], gMACAddress[2], gMACAddress[3], gMACAddress[4], gMACAddress[5]); 32 gMACAddress[0], gMACAddress[1], gMACAddress[2], gMACAddress[3], gMACAddress[4], gMACAddress[5]);
33 33
34 // build URL for update check 34 // build URL for update check
35 char url[1000]; 35 char url[1000];
36 snprintf(url, 1000, 36 snprintf(url, 1000,
37/* "http://update.mjm.game-host.org/os/viewer.php?" 37/* "http://update.mjm.game-host.org/os/viewer.php?"
38 "product=%s&channel=%s&" 38 "product=%s&channel=%s&"
39 "version_major=%d&version_minor=%d&version_patch=%d&version_base=%s&" 39 "version_major=%d&version_minor=%d&version_patch=%d&version_base=%s&"
40 "platform=%s&mac=%s", 40 "platform=%s&mac=%s",
41 LL_PRODUCT, LL_CHANNEL_CSTR, 41 LL_PRODUCT, LL_CHANNEL_CSTR,
42 LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BASE, 42 LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BASE,
43 LL_PLATFORM*/"", macAddress); 43 LL_PLATFORM*/"", macAddress);
44 44
45 // query update server 45 // query update server
46 std::string escaped_url = LLWeb::escapeURL(url); 46 std::string escaped_url = LLWeb::escapeURL(url);
47 LLSD response = LLHTTPClient::blockingGet(escaped_url.c_str()); 47 LLSD response = LLHTTPClient::blockingGet(escaped_url.c_str());
48 48
49 // check response, return on error 49 // check response, return on error
50 S32 status = response["status"].asInteger(); 50 S32 status = response["status"].asInteger();
51 if ((status != 200) || !response["body"].isMap()) { 51 if ((status != 200) || !response["body"].isMap()) {
52 llinfos << "Hippo Update failed (" << status << "): " 52 llinfos << "Hippo Update failed (" << status << "): "
53 << (response["body"].isString()? response["body"].asString(): "<unknown error>") 53 << (response["body"].isString()? response["body"].asString(): "<unknown error>")
54 << llendl; 54 << llendl;
55 return true; 55 return true;
56 } 56 }
57 57
58 // get data from response 58 // get data from response
59 LLSD data = response["body"]; 59 LLSD data = response["body"];
60 std::string webpage = (data.has("webpage") && data["webpage"].isString())? data["webpage"].asString(): ""; 60 std::string webpage = (data.has("webpage") && data["webpage"].isString())? data["webpage"].asString(): "";
61 std::string message = (data.has("message") && data["message"].isString())? data["message"].asString(): ""; 61 std::string message = (data.has("message") && data["message"].isString())? data["message"].asString(): "";
62 std::string yourVersion = (data.has("yourVersion") && data["yourVersion"].isString())? data["yourVersion"].asString(): ""; 62 std::string yourVersion = (data.has("yourVersion") && data["yourVersion"].isString())? data["yourVersion"].asString(): "";
63 std::string curVersion = (data.has("curVersion") && data["curVersion"].isString())? data["curVersion"].asString(): ""; 63 std::string curVersion = (data.has("curVersion") && data["curVersion"].isString())? data["curVersion"].asString(): "";
64 bool update = (data.has("update") && data["update"].isBoolean())? data["update"].asBoolean(): false; 64 bool update = (data.has("update") && data["update"].isBoolean())? data["update"].asBoolean(): false;
65 bool mandatory = (data.has("mandatory") && data["mandatory"].isBoolean())? data["mandatory"].asBoolean(): false; 65 bool mandatory = (data.has("mandatory") && data["mandatory"].isBoolean())? data["mandatory"].asBoolean(): false;
66 66
67 // log and return, if no update available 67 // log and return, if no update available
68 llinfos << "Your version is " << yourVersion << ", current version is " << curVersion << '.' << llendl; 68 llinfos << "Your version is " << yourVersion << ", current version is " << curVersion << '.' << llendl;
69 if (!update) return true; 69 if (!update) return true;
70 llinfos << "Update is " << (mandatory? "mandatory.": "optional.") << llendl; 70 llinfos << "Update is " << (mandatory? "mandatory.": "optional.") << llendl;
71 71
72 // show update dialog 72 // show update dialog
73 char msg[1000]; 73 char msg[1000];
74 snprintf(msg, 1000, 74 snprintf(msg, 1000,
75 "There is a new viewer version available.\n" 75 "There is a new viewer version available.\n"
76 "\n" 76 "\n"
77 "Your version: %s\n" 77 "Your version: %s\n"
78 "Current version: %s\n" 78 "Current version: %s\n"
79 "%s\n" 79 "%s\n"
80 "Do you want to visit the web site?", 80 "Do you want to visit the web site?",
81 yourVersion.c_str(), curVersion.c_str(), 81 yourVersion.c_str(), curVersion.c_str(),
82 mandatory? "\nThis is a mandatory update.\n": ""); 82 mandatory? "\nThis is a mandatory update.\n": "");
83 S32 button = OSMessageBox(msg, "Hippo OpenSim Viewer Update", OSMB_YESNO); 83 S32 button = OSMessageBox(msg, "Hippo OpenSim Viewer Update", OSMB_YESNO);
84 if (button == OSBTN_YES) { 84 if (button == OSBTN_YES) {
85 llinfos << "Taking user to " << webpage << llendl; 85 llinfos << "Taking user to " << webpage << llendl;
86 LLWeb::loadURLExternal(webpage); 86 LLWeb::loadURLExternal(webpage);
87 // exit the viewer 87 // exit the viewer
88 return false; 88 return false;
89 } 89 }
90 90
91 return !mandatory; 91 return !mandatory;
92} 92}