diff options
Diffstat (limited to 'linden/indra/newview/hippoGridManager.h')
-rw-r--r-- | linden/indra/newview/hippoGridManager.h | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/linden/indra/newview/hippoGridManager.h b/linden/indra/newview/hippoGridManager.h new file mode 100644 index 0000000..9925495 --- /dev/null +++ b/linden/indra/newview/hippoGridManager.h | |||
@@ -0,0 +1,175 @@ | |||
1 | #ifndef __HIPPO_GRID_MANAGER_H__ | ||
2 | #define __HIPPO_GRID_MANAGER_H__ | ||
3 | |||
4 | |||
5 | #include <map> | ||
6 | #include <string> | ||
7 | |||
8 | #ifndef XML_STATIC | ||
9 | #define XML_STATIC | ||
10 | #endif | ||
11 | |||
12 | #ifdef LL_STANDALONE | ||
13 | #include <expat.h> | ||
14 | #else | ||
15 | #include "expat/expat.h" | ||
16 | #endif | ||
17 | |||
18 | class LLSD; | ||
19 | |||
20 | |||
21 | class HippoGridInfo | ||
22 | { | ||
23 | public: | ||
24 | enum Platform { | ||
25 | PLATFORM_OTHER = 0, | ||
26 | PLATFORM_OPENSIM, | ||
27 | PLATFORM_SECONDLIFE, | ||
28 | PLATFORM_LAST | ||
29 | }; | ||
30 | enum SearchType { | ||
31 | SEARCH_ALL_EMPTY, | ||
32 | SEARCH_ALL_QUERY, | ||
33 | SEARCH_ALL_TEMPLATE | ||
34 | }; | ||
35 | |||
36 | explicit HippoGridInfo(const std::string &gridNick); | ||
37 | |||
38 | Platform getPlatform() const { return mPlatform; } | ||
39 | const std::string &getGridNick() const { return mGridNick; } | ||
40 | const std::string &getGridName() const { return mGridName; } | ||
41 | const std::string &getLoginUri() const { return mLoginUri; } | ||
42 | const std::string &getLoginPage() const { return mLoginPage; } | ||
43 | const std::string &getHelperUri() const { return mHelperUri; } | ||
44 | const std::string &getWebSite() const { return mWebSite; } | ||
45 | const std::string &getSupportUrl() const { return mSupportUrl; } | ||
46 | const std::string &getRegisterUrl() const { return mRegisterUrl; } | ||
47 | const std::string &getPasswordUrl() const { return mPasswordUrl; } | ||
48 | const std::string &getSearchUrl() const { return mSearchUrl; } | ||
49 | const std::string &getFirstName() const { return mFirstName; } | ||
50 | const std::string &getLastName() const { return mLastName; } | ||
51 | const std::string &getAvatarPassword() const { return mAvatarPassword; } | ||
52 | std::string getSearchUrl(SearchType ty) const; | ||
53 | bool isRenderCompat() const { return mRenderCompat; } | ||
54 | |||
55 | const std::string &getCurrencySymbol() const { return mCurrencySymbol; } | ||
56 | const std::string &getRealCurrencySymbol() const { return mRealCurrencySymbol; } | ||
57 | std::string getUploadFee() const; | ||
58 | std::string getGroupCreationFee() const; | ||
59 | std::string getDirectoryFee() const; | ||
60 | |||
61 | bool isOpenSimulator() const { return (mPlatform == PLATFORM_OPENSIM ); } | ||
62 | bool isSecondLife() const { return (mPlatform == PLATFORM_SECONDLIFE); } | ||
63 | |||
64 | void setPlatform (const std::string &platform); | ||
65 | void setPlatform (Platform platform); | ||
66 | void setGridName (const std::string &gridName) { mGridName = gridName; } | ||
67 | void setLoginUri (const std::string &loginUri) { mLoginUri = loginUri; cleanUpUri(mLoginUri); } | ||
68 | void setLoginPage(const std::string &loginPage) { mLoginPage = loginPage; } | ||
69 | void setHelperUri(const std::string &helperUri) { mHelperUri = helperUri; cleanUpUri(mHelperUri); } | ||
70 | void setWebSite (const std::string &website) { mWebSite = website; } | ||
71 | void setSupportUrl(const std::string &url) { mSupportUrl = url; } | ||
72 | void setRegisterUrl(const std::string &url) { mRegisterUrl = url; } | ||
73 | void setPasswordUrl(const std::string &url) { mPasswordUrl = url; } | ||
74 | void setSearchUrl(const std::string &url) { mSearchUrl = url; } | ||
75 | void setRenderCompat(bool compat) { mRenderCompat = compat; } | ||
76 | void setFirstName(const std::string &firstName) { mFirstName = firstName; } //aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
77 | void setLastName(const std::string &lastName) { mLastName = lastName; } | ||
78 | void setAvatarPassword(const std::string &avatarPassword) { mAvatarPassword = avatarPassword; } | ||
79 | |||
80 | void setCurrencySymbol(const std::string &sym) { mCurrencySymbol = sym.substr(0, 3); } | ||
81 | void setRealCurrencySymbol(const std::string &sym) { mRealCurrencySymbol = sym.substr(0, 3); } | ||
82 | void setDirectoryFee(int fee) { mDirectoryFee = fee; } | ||
83 | |||
84 | bool retrieveGridInfo(); | ||
85 | |||
86 | static const char *getPlatformString(Platform platform); | ||
87 | static void cleanUpGridNick(std::string &gridnick); | ||
88 | |||
89 | static HippoGridInfo FALLBACK_GRIDINFO; | ||
90 | static void initFallback(); | ||
91 | |||
92 | private: | ||
93 | Platform mPlatform; | ||
94 | std::string mGridNick; | ||
95 | std::string mGridName; | ||
96 | std::string mLoginUri; | ||
97 | std::string mLoginPage; | ||
98 | std::string mHelperUri; | ||
99 | std::string mWebSite; | ||
100 | std::string mSupportUrl; | ||
101 | std::string mRegisterUrl; | ||
102 | std::string mPasswordUrl; | ||
103 | std::string mSearchUrl; | ||
104 | std::string mFirstName; | ||
105 | std::string mLastName; | ||
106 | std::string mAvatarPassword; | ||
107 | bool mRenderCompat; | ||
108 | |||
109 | std::string mCurrencySymbol; | ||
110 | std::string mRealCurrencySymbol; | ||
111 | int mDirectoryFee; | ||
112 | |||
113 | // for parsing grid info XML | ||
114 | enum XmlState { | ||
115 | XML_VOID, XML_GRIDNICK, XML_PLATFORM, XML_GRIDNAME, | ||
116 | XML_LOGINURI, XML_LOGINPAGE, XML_HELPERURI, | ||
117 | XML_WEBSITE, XML_SUPPORT, XML_REGISTER, XML_PASSWORD, XML_SEARCH | ||
118 | }; | ||
119 | XmlState mXmlState; | ||
120 | |||
121 | static void cleanUpUri(std::string &uri); | ||
122 | void formatFee(std::string &fee, int cost, bool showFree) const; | ||
123 | |||
124 | static void onXmlElementStart(void *userData, const XML_Char *name, const XML_Char **atts); | ||
125 | static void onXmlElementEnd(void *userData, const XML_Char *name); | ||
126 | static void onXmlCharacterData(void *userData, const XML_Char *s, int len); | ||
127 | }; | ||
128 | |||
129 | |||
130 | class HippoGridManager | ||
131 | { | ||
132 | public: | ||
133 | HippoGridManager(); | ||
134 | ~HippoGridManager(); | ||
135 | |||
136 | void init(); | ||
137 | void saveFile(); | ||
138 | void discardAndReload(); | ||
139 | |||
140 | HippoGridInfo *getGrid(const std::string &grid) const; | ||
141 | HippoGridInfo *getConnectedGrid() const { return (mConnectedGrid)? mConnectedGrid: getCurrentGrid(); } | ||
142 | HippoGridInfo *getCurrentGrid() const; | ||
143 | const std::string &getDefaultGridNick() const { return mDefaultGrid; } | ||
144 | const std::string &getCurrentGridNick() const { return mCurrentGrid; } | ||
145 | |||
146 | void setDefaultGrid(const std::string &grid); | ||
147 | void setCurrentGrid(const std::string &grid); | ||
148 | void setCurrentGridAsConnected() { mConnectedGrid = getCurrentGrid(); } | ||
149 | |||
150 | void addGrid(HippoGridInfo *grid); | ||
151 | void deleteGrid(const std::string &grid); | ||
152 | |||
153 | typedef std::map<std::string, HippoGridInfo*>::iterator GridIterator; | ||
154 | GridIterator beginGrid() { return mGridInfo.begin(); } | ||
155 | GridIterator endGrid() { return mGridInfo.end(); } | ||
156 | |||
157 | private: | ||
158 | std::map<std::string, HippoGridInfo*> mGridInfo; | ||
159 | std::string mDefaultGrid; | ||
160 | std::string mCurrentGrid; | ||
161 | HippoGridInfo *mConnectedGrid; | ||
162 | int mDefaultGridsVersion; | ||
163 | |||
164 | void cleanup(); | ||
165 | void loadFromFile(); | ||
166 | void parseFile(const std::string &fileName, bool mergeIfNewer); | ||
167 | void parseUrl(const char *url, bool mergeIfNewer); | ||
168 | void parseData(LLSD &gridInfo, bool mergeIfNewer); | ||
169 | }; | ||
170 | |||
171 | |||
172 | extern HippoGridManager *gHippoGridManager; | ||
173 | |||
174 | |||
175 | #endif | ||