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

