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
|
#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();
bool isOpenSimulator() const;
bool isSecondLife() const;
const std::string& getGridNick() const;
const std::string& getGridName() const;
const std::string& getLoginUri() const;
const std::string& getLoginPage() const;
const std::string& getHelperUri() const;
const std::string& getWebSite() const;
const std::string& getSupportUrl() const;
const std::string& getRegisterUrl() const;
const std::string& getPasswordUrl() const;
// Returns the url base used for the Web Search tab
const std::string& getSearchUrl() const;
const std::string& getFirstName() const;
const std::string& getLastName() const;
const std::string& getAvatarPassword() const;
const std::string& getVoiceConnector() const { return mVoiceConnector; }
std::string getSearchUrl(SearchType ty, bool is_web) const;
bool isRenderCompat() const;
int getMaxAgentGroups() const { return mMaxAgentGroups; }
const std::string& getCurrencySymbol() const;
const std::string& getRealCurrencySymbol() const;
std::string getUploadFee() const;
std::string getGroupCreationFee() const;
std::string getDirectoryFee() const;
void setPlatform (const std::string& platform);
void setPlatform (Platform platform);
void setGridName (const std::string& gridName);
void setLoginUri (const std::string& loginUri);
void setLoginPage(const std::string& loginPage);
void setHelperUri(const std::string& helperUri);
void setWebSite (const std::string& website);
void setSupportUrl(const std::string& url);
void setRegisterUrl(const std::string& url);
void setPasswordUrl(const std::string& url);
// sets the url base used for the Web Search tab
void setSearchUrl(const std::string& url);
void setRenderCompat(bool compat);
void setMaxAgentGroups(int max) { mMaxAgentGroups = max; }
void setFirstName(const std::string& firstName);
void setLastName(const std::string& lastName);
void setAvatarPassword(const std::string& avatarPassword);
void setVoiceConnector(const std::string& vc) { mVoiceConnector = vc; }
void setCurrencySymbol(const std::string& sym);
void setRealCurrencySymbol(const std::string& sym);
void setDirectoryFee(int fee);
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 mAvatarPassword;
bool mRenderCompat;
int mMaxAgentGroups;
std::string mCurrencySymbol;
std::string mRealCurrencySymbol;
int 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;
static std::string sanitizeUri(std::string &uri);
void formatFee(std::string &fee, int 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, int 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;
const std::string& getCurrentGridNick() const;
void setDefaultGrid(const std::string& grid);
void setCurrentGrid(const std::string& grid);
void setCurrentGridAsConnected();
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(); }
private:
std::map<std::string, HippoGridInfo*> mGridInfo;
std::string mDefaultGrid;
std::string mCurrentGrid;
HippoGridInfo* mConnectedGrid;
int mDefaultGridsVersion;
void cleanup();
void loadFromFile();
void parseFile(const std::string& fileName, bool mergeIfNewer);
void parseUrl(const char* url, bool mergeIfNewer);
void parseData(LLSD &gridInfo, bool mergeIfNewer);
};
extern HippoGridManager* gHippoGridManager;
#endif
|