Annotation of /trunk/indra/newview/llfloateravatarinfo.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llfloateravatarinfo.cpp | ||
| 3 : | * @brief LLFloaterAvatarInfo class implementation | ||
| 4 : | * Avatar information as shown in a floating window from right-click | ||
| 5 : | * Profile. Used for editing your own avatar info. Just a wrapper | ||
| 6 : | * for LLPanelAvatar, shared with the Find directory. | ||
| 7 : | * | ||
| 8 : | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
| 9 : | * | ||
| 10 : | mjm | 137 | * Copyright (c) 2002-2010, Linden Research, Inc. |
| 11 : | mjm | 135 | * |
| 12 : | * Second Life Viewer Source Code | ||
| 13 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 14 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 15 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 16 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 17 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 18 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 19 : | * | ||
| 20 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 21 : | * it is applied to this Source Code. View the full text of the exception | ||
| 22 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 23 : | * online at | ||
| 24 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 25 : | * | ||
| 26 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 27 : | * that you have read and understood your obligations described above, | ||
| 28 : | * and agree to abide by those obligations. | ||
| 29 : | * | ||
| 30 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 31 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 32 : | * COMPLETENESS OR PERFORMANCE. | ||
| 33 : | * $/LicenseInfo$ | ||
| 34 : | */ | ||
| 35 : | #include "llviewerprecompiledheaders.h" | ||
| 36 : | |||
| 37 : | #include "llfloateravatarinfo.h" | ||
| 38 : | |||
| 39 : | // viewer project includes | ||
| 40 : | #include "llagentdata.h" | ||
| 41 : | #include "llcommandhandler.h" | ||
| 42 : | #include "llpanelavatar.h" | ||
| 43 : | #include "lluictrlfactory.h" | ||
| 44 : | |||
| 45 : | // linden library includes | ||
| 46 : | #include "llinventory.h" | ||
| 47 : | #include "lluuid.h" | ||
| 48 : | #include "message.h" | ||
| 49 : | |||
| 50 : | const char FLOATER_TITLE[] = "Profile"; | ||
| 51 : | const LLRect FAI_RECT(0, 530, 420, 0); | ||
| 52 : | |||
| 53 : | //----------------------------------------------------------------------------- | ||
| 54 : | // Globals | ||
| 55 : | //----------------------------------------------------------------------------- | ||
| 56 : | |||
| 57 : | LLMap< const LLUUID, LLFloaterAvatarInfo* > gAvatarInfoInstances; | ||
| 58 : | |||
| 59 : | class LLAgentHandler : public LLCommandHandler | ||
| 60 : | { | ||
| 61 : | public: | ||
| 62 : | // requires trusted browser to trigger | ||
| 63 : | LLAgentHandler() : LLCommandHandler("agent", true) { } | ||
| 64 : | |||
| 65 : | bool handle(const LLSD& params, const LLSD& query_map, | ||
| 66 : | LLWebBrowserCtrl* web) | ||
| 67 : | { | ||
| 68 : | if (params.size() < 2) return false; | ||
| 69 : | LLUUID agent_id; | ||
| 70 : | if (!agent_id.set(params[0], FALSE)) | ||
| 71 : | { | ||
| 72 : | return false; | ||
| 73 : | } | ||
| 74 : | |||
| 75 : | if (params[1].asString() == "about") | ||
| 76 : | { | ||
| 77 : | LLFloaterAvatarInfo::show(agent_id); | ||
| 78 : | return true; | ||
| 79 : | } | ||
| 80 : | return false; | ||
| 81 : | } | ||
| 82 : | }; | ||
| 83 : | LLAgentHandler gAgentHandler; | ||
| 84 : | |||
| 85 : | //----------------------------------------------------------------------------- | ||
| 86 : | // Member functions | ||
| 87 : | //----------------------------------------------------------------------------- | ||
| 88 : | |||
| 89 : | //---------------------------------------------------------------------------- | ||
| 90 : | |||
| 91 : | void* LLFloaterAvatarInfo::createPanelAvatar(void* data) | ||
| 92 : | { | ||
| 93 : | LLFloaterAvatarInfo* self = (LLFloaterAvatarInfo*)data; | ||
| 94 : | self->mPanelAvatarp = new LLPanelAvatar("PanelAv", LLRect(), TRUE); // allow edit self | ||
| 95 : | return self->mPanelAvatarp; | ||
| 96 : | } | ||
| 97 : | |||
| 98 : | //---------------------------------------------------------------------------- | ||
| 99 : | |||
| 100 : | |||
| 101 : | BOOL LLFloaterAvatarInfo::postBuild() | ||
| 102 : | { | ||
| 103 : | return TRUE; | ||
| 104 : | } | ||
| 105 : | |||
| 106 : | LLFloaterAvatarInfo::LLFloaterAvatarInfo(const std::string& name, const LLRect &rect, const LLUUID &avatar_id) | ||
| 107 : | : LLPreview(name, rect, FLOATER_TITLE, LLUUID::null, LLUUID::null), | ||
| 108 : | mAvatarID( avatar_id ), | ||
| 109 : | mSuggestedOnlineStatus(ONLINE_STATUS_NO) | ||
| 110 : | { | ||
| 111 : | setAutoFocus(TRUE); | ||
| 112 : | |||
| 113 : | LLCallbackMap::map_t factory_map; | ||
| 114 : | |||
| 115 : | factory_map["Panel Avatar"] = LLCallbackMap(createPanelAvatar, this); | ||
| 116 : | |||
| 117 : | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_profile.xml", &factory_map); | ||
| 118 : | |||
| 119 : | if(mPanelAvatarp) | ||
| 120 : | { | ||
| 121 : | mPanelAvatarp->selectTab(0); | ||
| 122 : | } | ||
| 123 : | |||
| 124 : | gAvatarInfoInstances.addData(avatar_id, this); // must be done before callback below is called. | ||
| 125 : | gCacheName->get(avatar_id, FALSE, callbackLoadAvatarName); | ||
| 126 : | } | ||
| 127 : | |||
| 128 : | // virtual | ||
| 129 : | LLFloaterAvatarInfo::~LLFloaterAvatarInfo() | ||
| 130 : | { | ||
| 131 : | // child views automatically deleted | ||
| 132 : | gAvatarInfoInstances.removeData(mAvatarID); | ||
| 133 : | } | ||
| 134 : | |||
| 135 : | void LLFloaterAvatarInfo::resetGroupList() | ||
| 136 : | { | ||
| 137 : | // only get these updates asynchronously via the group floater, which works on the agent only | ||
| 138 : | if (mAvatarID != gAgentID) | ||
| 139 : | { | ||
| 140 : | return; | ||
| 141 : | } | ||
| 142 : | |||
| 143 : | mPanelAvatarp->resetGroupList(); | ||
| 144 : | } | ||
| 145 : | |||
| 146 : | // static | ||
| 147 : | LLFloaterAvatarInfo* LLFloaterAvatarInfo::show(const LLUUID &avatar_id) | ||
| 148 : | { | ||
| 149 : | if (avatar_id.isNull()) | ||
| 150 : | { | ||
| 151 : | return NULL; | ||
| 152 : | } | ||
| 153 : | |||
| 154 : | LLFloaterAvatarInfo *floater; | ||
| 155 : | if (gAvatarInfoInstances.checkData(avatar_id)) | ||
| 156 : | { | ||
| 157 : | // ...bring that window to front | ||
| 158 : | floater = gAvatarInfoInstances.getData(avatar_id); | ||
| 159 : | floater->open(); /*Flawfinder: ignore*/ | ||
| 160 : | } | ||
| 161 : | else | ||
| 162 : | { | ||
| 163 : | floater = new LLFloaterAvatarInfo("avatarinfo", FAI_RECT, | ||
| 164 : | avatar_id ); | ||
| 165 : | floater->center(); | ||
| 166 : | floater->open(); /*Flawfinder: ignore*/ | ||
| 167 : | } | ||
| 168 : | return floater; | ||
| 169 : | } | ||
| 170 : | |||
| 171 : | // Open profile to a certain tab. | ||
| 172 : | // static | ||
| 173 : | void LLFloaterAvatarInfo::showFromObject( | ||
| 174 : | const LLUUID& avatar_id, | ||
| 175 : | std::string tab_name) | ||
| 176 : | { | ||
| 177 : | LLFloaterAvatarInfo *floater = show(avatar_id); | ||
| 178 : | if (floater) | ||
| 179 : | { | ||
| 180 : | floater->mPanelAvatarp->setAvatarID(avatar_id, LLStringUtil::null, ONLINE_STATUS_NO); | ||
| 181 : | floater->mPanelAvatarp->selectTabByName(tab_name); | ||
| 182 : | } | ||
| 183 : | } | ||
| 184 : | |||
| 185 : | // static | ||
| 186 : | void LLFloaterAvatarInfo::showFromDirectory(const LLUUID &avatar_id) | ||
| 187 : | { | ||
| 188 : | LLFloaterAvatarInfo *floater = show(avatar_id); | ||
| 189 : | if (floater) | ||
| 190 : | { | ||
| 191 : | floater->mPanelAvatarp->setAvatarID(avatar_id, LLStringUtil::null, ONLINE_STATUS_NO); | ||
| 192 : | } | ||
| 193 : | } | ||
| 194 : | |||
| 195 : | |||
| 196 : | // static | ||
| 197 : | void LLFloaterAvatarInfo::showFromFriend(const LLUUID& agent_id, BOOL online) | ||
| 198 : | { | ||
| 199 : | LLFloaterAvatarInfo *floater = show(agent_id); | ||
| 200 : | if (floater) | ||
| 201 : | { | ||
| 202 : | floater->mSuggestedOnlineStatus = online ? ONLINE_STATUS_YES : ONLINE_STATUS_NO; | ||
| 203 : | } | ||
| 204 : | } | ||
| 205 : | |||
| 206 : | |||
| 207 : | // static | ||
| 208 : | void LLFloaterAvatarInfo::showFromProfile(const LLUUID &avatar_id, LLRect rect) | ||
| 209 : | { | ||
| 210 : | if (avatar_id.isNull()) | ||
| 211 : | { | ||
| 212 : | return; | ||
| 213 : | } | ||
| 214 : | |||
| 215 : | LLFloaterAvatarInfo *floater; | ||
| 216 : | if (gAvatarInfoInstances.checkData(avatar_id)) | ||
| 217 : | { | ||
| 218 : | // ...bring that window to front | ||
| 219 : | floater = gAvatarInfoInstances.getData(avatar_id); | ||
| 220 : | } | ||
| 221 : | else | ||
| 222 : | { | ||
| 223 : | floater = new LLFloaterAvatarInfo("avatarinfo", FAI_RECT, | ||
| 224 : | avatar_id); | ||
| 225 : | floater->translate(rect.mLeft - floater->getRect().mLeft + 16, | ||
| 226 : | rect.mTop - floater->getRect().mTop - 16); | ||
| 227 : | floater->mPanelAvatarp->setAvatarID(avatar_id, LLStringUtil::null, ONLINE_STATUS_NO); | ||
| 228 : | } | ||
| 229 : | if (floater) | ||
| 230 : | { | ||
| 231 : | floater->open(); | ||
| 232 : | } | ||
| 233 : | } | ||
| 234 : | |||
| 235 : | void LLFloaterAvatarInfo::showProfileCallback(S32 option, void *userdata) | ||
| 236 : | { | ||
| 237 : | if (option == 0) | ||
| 238 : | { | ||
| 239 : | showFromObject(gAgentID); | ||
| 240 : | } | ||
| 241 : | } | ||
| 242 : | |||
| 243 : | // static | ||
| 244 : | void LLFloaterAvatarInfo::callbackLoadAvatarName(const LLUUID& id, | ||
| 245 : | const std::string& first, | ||
| 246 : | const std::string& last, | ||
| 247 : | BOOL is_group, | ||
| 248 : | void* data) | ||
| 249 : | { | ||
| 250 : | LLFloaterAvatarInfo *floater = gAvatarInfoInstances.getIfThere(id); | ||
| 251 : | |||
| 252 : | if (floater) | ||
| 253 : | { | ||
| 254 : | // Build a new title including the avatar name. | ||
| 255 : | std::ostringstream title; | ||
| 256 : | title << first << " " << last << " - " << floater->getTitle(); | ||
| 257 : | floater->setTitle(title.str()); | ||
| 258 : | } | ||
| 259 : | } | ||
| 260 : | |||
| 261 : | //// virtual | ||
| 262 : | void LLFloaterAvatarInfo::draw() | ||
| 263 : | { | ||
| 264 : | // skip LLPreview::draw() | ||
| 265 : | LLFloater::draw(); | ||
| 266 : | } | ||
| 267 : | |||
| 268 : | // virtual | ||
| 269 : | BOOL LLFloaterAvatarInfo::canClose() | ||
| 270 : | { | ||
| 271 : | return mPanelAvatarp && mPanelAvatarp->canClose(); | ||
| 272 : | } | ||
| 273 : | |||
| 274 : | LLFloaterAvatarInfo* LLFloaterAvatarInfo::getInstance(const LLUUID &id) | ||
| 275 : | { | ||
| 276 : | return gAvatarInfoInstances.getIfThere(gAgentID); | ||
| 277 : | } | ||
| 278 : | |||
| 279 : | void LLFloaterAvatarInfo::loadAsset() | ||
| 280 : | { | ||
| 281 : | if (mPanelAvatarp) { | ||
| 282 : | mPanelAvatarp->setAvatarID(mAvatarID, LLStringUtil::null, mSuggestedOnlineStatus); | ||
| 283 : | mAssetStatus = PREVIEW_ASSET_LOADING; | ||
| 284 : | } | ||
| 285 : | } | ||
| 286 : | |||
| 287 : | LLPreview::EAssetStatus LLFloaterAvatarInfo::getAssetStatus() | ||
| 288 : | { | ||
| 289 : | if (mPanelAvatarp && mPanelAvatarp->haveData()) | ||
| 290 : | { | ||
| 291 : | mAssetStatus = PREVIEW_ASSET_LOADED; | ||
| 292 : | } | ||
| 293 : | return mAssetStatus; | ||
| 294 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

