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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
/**
* @file hippogridmanager.h
* @brief stores grid information
*
* $LicenseInfo:firstyear=2011&license=viewergpl$
*
* Copyright (c) 2011
* Ported to Imprudence from the Hippo OpenSim Viewer by Jacek Antonelli
*
* Imprudence Viewer Source Code
* The source code in this file ("Source Code") is provided to you
* under the terms of the GNU General Public License, version 2.0
* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
* this distribution, or online at
* http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef __HIPPO_GRID_MANAGER_H__
#define __HIPPO_GRID_MANAGER_H__
#include <map>
#include <string>
#ifndef XML_STATIC
#define XML_STATIC
#endif
#ifdef LL_STANDALONE
#include <expat.h>
#else
#include "expat/expat.h"
#endif
class LLSD;
class HippoGridInfo
{
public:
enum Platform {
PLATFORM_OTHER = 0,
PLATFORM_OPENSIM,
PLATFORM_SECONDLIFE,
PLATFORM_LAST
};
enum SearchType {
SEARCH_ALL_EMPTY,
SEARCH_ALL_QUERY,
SEARCH_ALL_TEMPLATE
};
explicit HippoGridInfo(const std::string& gridNick);
Platform getPlatform() { return mPlatform; }
bool isOpenSimulator() const { return (mPlatform == PLATFORM_OPENSIM); }
bool isSecondLife() const { return (mPlatform == PLATFORM_SECONDLIFE); }
bool isRenderCompat() const { return mRenderCompat; }
// currently only SecondLife grids support username-style logins but Aurora is working on implementing it
bool isUsernameCompat() const { return mUsernameCompat; }
const std::string& getGridNick() const { return mGridNick; }
// returns grid nick if no grid name is available
const std::string& getGridName() const;
const std::string& getLoginURI() const { return mLoginURI; }
const std::string& getLoginPage() const { return mLoginPage; }
const std::string& getHelperURI() const { return mHelperURI; }
const std::string& getWebSite() const { return mWebSite; }
const std::string& getSupportURL() const { return mSupportURL; }
const std::string& getRegisterURL() const { return mRegisterURL; }
const std::string& getPasswordURL() const { return mPasswordURL; }
// Returns the url base used for the Web Search tab
const std::string& getSearchURL() const { return mSearchURL; }
const std::string& getFirstName() const { return mFirstName; }
const std::string& getLastName() const { return mLastName; }
const std::string& getUsername() const { return mUsername; }
std::string getPassword() const;
std::string getEncryptedPassword() const;
const std::string& getVoiceConnector() const { return mVoiceConnector; }
S32 getMaxAgentGroups() const { return mMaxAgentGroups; }
const std::string& getCurrencySymbol() const { return mCurrencySymbol; }
const std::string& getRealCurrencySymbol() const { return mRealCurrencySymbol; }
std::string getUploadFee() const;
std::string getGroupCreationFee() const;
std::string getDirectoryFee() const;
std::string getSearchURL(SearchType ty, bool is_web) const;
void setPlatform (const std::string& platform);
void setPlatform (Platform platform);
void setGridName (const std::string& gridName) { mGridName = gridName; }
void setLoginURI (const std::string& loginURI);
void setLoginPage(const std::string& loginPage) { mLoginPage = loginPage; }
void setHelperURI(const std::string& helperURI);
void setWebSite (const std::string& website) { mWebSite = website; }
void setSupportURL(const std::string& url) { mSupportURL = url; }
void setRegisterURL(const std::string& url) { mRegisterURL = url; }
void setPasswordURL(const std::string& url) { mPasswordURL = url; }
// sets the url base used for the Web Search tab
void setSearchURL(const std::string& url) { mSearchURL = url; }
void setRenderCompat(bool compat) { mRenderCompat = compat; }
void setMaxAgentGroups(S32 max) { mMaxAgentGroups = max; }
void setFirstName(const std::string& firstName) { mFirstName = firstName; }
void setLastName(const std::string& lastName) { mLastName = lastName; }
void setPassword(const std::string& unhashed_password);
void setEncryptedPassword(const std::string& encrypted_password);
void setVoiceConnector(const std::string& vc) { mVoiceConnector = vc; }
void setCurrencySymbol(const std::string& sym) { mCurrencySymbol = sym.substr(0, 3); }
void setRealCurrencySymbol(const std::string& sym) { mRealCurrencySymbol = sym.substr(0, 3); }
void setDirectoryFee(U32 fee) { mDirectoryFee = fee; }
void setUsername(const std::string& username) { mUsername = username; }
void setUsernameCompat(bool compat) { mUsernameCompat = compat; }
bool retrieveGridInfo();
static const char* getPlatformString(Platform platform);
static std::string sanitizeGridNick(std::string &gridnick);
static HippoGridInfo FALLBACK_GRIDINFO;
static void initFallback();
private:
Platform mPlatform;
std::string mGridNick;
std::string mGridName;
std::string mLoginURI;
std::string mLoginPage;
std::string mHelperURI;
std::string mWebSite;
std::string mSupportURL;
std::string mRegisterURL;
std::string mPasswordURL;
std::string mSearchURL;
std::string mVoiceConnector;
std::string mFirstName;
std::string mLastName;
std::string mPasswordAvatar;
std::string mEncryptedPassword;
bool mRenderCompat;
S32 mMaxAgentGroups;
std::string mUsername;
bool mUsernameCompat;
std::string mCurrencySymbol;
std::string mRealCurrencySymbol;
U32 mDirectoryFee;
// for parsing grid info XML
enum XmlState
{
XML_VOID, XML_GRIDNICK, XML_PLATFORM, XML_GRIDNAME,
XML_LOGINURI, XML_LOGINPAGE, XML_HELPERURI,
XML_WEBSITE, XML_SUPPORT, XML_REGISTER, XML_PASSWORD, XML_SEARCH
};
XmlState mXmlState;
void checkLoginURIforSecondLifeness();
static std::string sanitizeURI(std::string &uri);
void formatFee(std::string &fee, S32 cost, bool showFree) const;
static void onXmlElementStart(void* userData, const XML_Char* name, const XML_Char** atts);
static void onXmlElementEnd(void* userData, const XML_Char* name);
static void onXmlCharacterData(void* userData, const XML_Char* s, S32 len);
};
class HippoGridManager
{
public:
HippoGridManager();
~HippoGridManager();
void init();
void saveFile();
void discardAndReload();
HippoGridInfo* getGrid(const std::string& grid) const;
HippoGridInfo* getConnectedGrid() const;
HippoGridInfo* getCurrentGrid() const;
const std::string& getDefaultGridNick() const { return mDefaultGrid; }
const std::string& getCurrentGridNick() const;
void setDefaultGrid(const std::string& grid);
void setCurrentGrid(const std::string& grid);
void setCurrentGridAsConnected() { mConnectedGrid = getCurrentGrid(); }
void addGrid(HippoGridInfo* grid);
void deleteGrid(const std::string& grid);
typedef std::map<std::string, HippoGridInfo*>::iterator GridIterator;
GridIterator beginGrid() { return mGridInfo.begin(); }
GridIterator endGrid() { return mGridInfo.end(); }
// returns true if the grid manager knows of a nickname
bool hasGridNick(const std::string& grid_nick);
private:
std::map<std::string, HippoGridInfo*> mGridInfo;
std::string mDefaultGrid;
std::string mCurrentGrid;
HippoGridInfo* mConnectedGrid;
S32 mDefaultGridsVersion;
void cleanup();
void loadFromFile();
void parseFile(const std::string& fileName, bool mergeIfNewer);
void parseURL(const std::string url, bool mergeIfNewer);
void parseData(LLSD &gridInfo, bool mergeIfNewer);
};
extern HippoGridManager* gHippoGridManager;
#endif
|