llpanelavatar.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:26k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llpanelavatar.cpp
  3.  * @brief LLPanelAvatar and related class implementations
  4.  *
  5.  * $LicenseInfo:firstyear=2004&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2004-2010, Linden Research, Inc.
  8.  * 
  9.  * Second Life Viewer Source Code
  10.  * The source code in this file ("Source Code") is provided by Linden Lab
  11.  * to you under the terms of the GNU General Public License, version 2.0
  12.  * ("GPL"), unless you have obtained a separate licensing agreement
  13.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  14.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16.  * 
  17.  * There are special exceptions to the terms and conditions of the GPL as
  18.  * it is applied to this Source Code. View the full text of the exception
  19.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  20.  * online at
  21.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22.  * 
  23.  * By copying, modifying or distributing this software, you acknowledge
  24.  * that you have read and understood your obligations described above,
  25.  * and agree to abide by those obligations.
  26.  * 
  27.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29.  * COMPLETENESS OR PERFORMANCE.
  30.  * $/LicenseInfo$
  31.  */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llpanelavatar.h"
  34. #include "llagent.h"
  35. #include "llavataractions.h"
  36. #include "llavatarconstants.h" // AVATAR_ONLINE
  37. #include "llcallingcard.h"
  38. #include "llcombobox.h"
  39. #include "lldateutil.h" // ageFromDate()
  40. #include "llimview.h"
  41. #include "llnotificationsutil.h"
  42. #include "lltexteditor.h"
  43. #include "lltexturectrl.h"
  44. #include "lltoggleablemenu.h"
  45. #include "lltooldraganddrop.h"
  46. #include "llscrollcontainer.h"
  47. #include "llavatariconctrl.h"
  48. #include "llweb.h"
  49. #include "llfloaterworldmap.h"
  50. #include "llfloaterreg.h"
  51. #include "llnotificationsutil.h"
  52. #include "llvoiceclient.h"
  53. #include "llnamebox.h"
  54. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. // Class LLDropTarget
  56. //
  57. // This handy class is a simple way to drop something on another
  58. // view. It handles drop events, always setting itself to the size of
  59. // its parent.
  60. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61. class LLDropTarget : public LLView
  62. {
  63. public:
  64. struct Params : public LLInitParam::Block<Params, LLView::Params>
  65. {
  66. Optional<LLUUID> agent_id;
  67. Params()
  68. : agent_id("agent_id")
  69. {
  70. mouse_opaque(false);
  71. follows.flags(FOLLOWS_ALL);
  72. }
  73. };
  74. LLDropTarget(const Params&);
  75. ~LLDropTarget();
  76. void doDrop(EDragAndDropType cargo_type, void* cargo_data);
  77. //
  78. // LLView functionality
  79. virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
  80.    EDragAndDropType cargo_type,
  81.    void* cargo_data,
  82.    EAcceptance* accept,
  83.    std::string& tooltip_msg);
  84. void setAgentID(const LLUUID &agent_id) { mAgentID = agent_id; }
  85. protected:
  86. LLUUID mAgentID;
  87. };
  88. LLDropTarget::LLDropTarget(const LLDropTarget::Params& p) 
  89. : LLView(p),
  90. mAgentID(p.agent_id)
  91. {}
  92. LLDropTarget::~LLDropTarget()
  93. {}
  94. void LLDropTarget::doDrop(EDragAndDropType cargo_type, void* cargo_data)
  95. {
  96. llinfos << "LLDropTarget::doDrop()" << llendl;
  97. }
  98. BOOL LLDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
  99.  EDragAndDropType cargo_type,
  100.  void* cargo_data,
  101.  EAcceptance* accept,
  102.  std::string& tooltip_msg)
  103. {
  104. if(getParent())
  105. {
  106. LLToolDragAndDrop::handleGiveDragAndDrop(mAgentID, LLUUID::null, drop,
  107.  cargo_type, cargo_data, accept);
  108. return TRUE;
  109. }
  110. return FALSE;
  111. }
  112. static LLDefaultChildRegistry::Register<LLDropTarget> r("drop_target");
  113. static LLRegisterPanelClassWrapper<LLPanelAvatarProfile> t_panel_profile("panel_profile");
  114. static LLRegisterPanelClassWrapper<LLPanelMyProfile> t_panel_my_profile("panel_my_profile");
  115. static LLRegisterPanelClassWrapper<LLPanelAvatarNotes> t_panel_notes("panel_notes");
  116. //-----------------------------------------------------------------------------
  117. // LLPanelAvatarNotes()
  118. //-----------------------------------------------------------------------------
  119. LLPanelAvatarNotes::LLPanelAvatarNotes()
  120. : LLPanelProfileTab()
  121. {
  122. }
  123. void LLPanelAvatarNotes::updateData()
  124. {
  125. LLAvatarPropertiesProcessor::getInstance()->
  126. sendAvatarNotesRequest(getAvatarId());
  127. }
  128. BOOL LLPanelAvatarNotes::postBuild()
  129. {
  130. childSetCommitCallback("status_check", boost::bind(&LLPanelAvatarNotes::onCommitRights, this), NULL);
  131. childSetCommitCallback("map_check", boost::bind(&LLPanelAvatarNotes::onCommitRights, this), NULL);
  132. childSetCommitCallback("objects_check", boost::bind(&LLPanelAvatarNotes::onCommitRights, this), NULL);
  133. childSetCommitCallback("add_friend", boost::bind(&LLPanelAvatarNotes::onAddFriendButtonClick, this),NULL);
  134. childSetCommitCallback("im", boost::bind(&LLPanelAvatarNotes::onIMButtonClick, this), NULL);
  135. childSetCommitCallback("call", boost::bind(&LLPanelAvatarNotes::onCallButtonClick, this), NULL);
  136. childSetCommitCallback("teleport", boost::bind(&LLPanelAvatarNotes::onTeleportButtonClick, this), NULL);
  137. childSetCommitCallback("share", boost::bind(&LLPanelAvatarNotes::onShareButtonClick, this), NULL);
  138. childSetCommitCallback("show_on_map_btn", (boost::bind(
  139. &LLPanelAvatarNotes::onMapButtonClick, this)), NULL);
  140. LLTextEditor* te = getChild<LLTextEditor>("notes_edit");
  141. te->setCommitCallback(boost::bind(&LLPanelAvatarNotes::onCommitNotes,this));
  142. te->setCommitOnFocusLost(TRUE);
  143. resetControls();
  144. resetData();
  145. gVoiceClient->addObserver((LLVoiceClientStatusObserver*)this);
  146. return TRUE;
  147. }
  148. void LLPanelAvatarNotes::onOpen(const LLSD& key)
  149. {
  150. LLPanelProfileTab::onOpen(key);
  151. fillRightsData();
  152. //Disable "Add Friend" button for friends.
  153. childSetEnabled("add_friend", !LLAvatarActions::isFriend(getAvatarId()));
  154. }
  155. void LLPanelAvatarNotes::fillRightsData()
  156. {
  157. childSetValue("status_check", FALSE);
  158. childSetValue("map_check", FALSE);
  159. childSetValue("objects_check", FALSE);
  160. const LLRelationship* relation = LLAvatarTracker::instance().getBuddyInfo(getAvatarId());
  161. // If true - we are viewing friend's profile, enable check boxes and set values.
  162. if(relation)
  163. {
  164. S32 rights = relation->getRightsGrantedTo();
  165. childSetValue("status_check",LLRelationship::GRANT_ONLINE_STATUS & rights ? TRUE : FALSE);
  166. childSetValue("map_check",LLRelationship::GRANT_MAP_LOCATION & rights ? TRUE : FALSE);
  167. childSetValue("objects_check",LLRelationship::GRANT_MODIFY_OBJECTS & rights ? TRUE : FALSE);
  168. }
  169. enableCheckboxes(NULL != relation);
  170. }
  171. void LLPanelAvatarNotes::onCommitNotes()
  172. {
  173. std::string notes = childGetValue("notes_edit").asString();
  174. LLAvatarPropertiesProcessor::getInstance()-> sendNotes(getAvatarId(),notes);
  175. }
  176. void LLPanelAvatarNotes::rightsConfirmationCallback(const LLSD& notification,
  177. const LLSD& response, S32 rights)
  178. {
  179. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  180. if (option == 0)
  181. {
  182. LLAvatarPropertiesProcessor::getInstance()->sendFriendRights(
  183. getAvatarId(), rights);
  184. }
  185. else
  186. {
  187. childSetValue("objects_check",
  188. childGetValue("objects_check").asBoolean() ? FALSE : TRUE);
  189. }
  190. }
  191. void LLPanelAvatarNotes::confirmModifyRights(bool grant, S32 rights)
  192. {
  193. std::string first, last;
  194. LLSD args;
  195. if (gCacheName->getName(getAvatarId(), first, last))
  196. {
  197. args["FIRST_NAME"] = first;
  198. args["LAST_NAME"] = last;
  199. }
  200. if (grant)
  201. {
  202. LLNotificationsUtil::add("GrantModifyRights", args, LLSD(),
  203. boost::bind(&LLPanelAvatarNotes::rightsConfirmationCallback, this,
  204. _1, _2, rights));
  205. }
  206. else
  207. {
  208. LLNotificationsUtil::add("RevokeModifyRights", args, LLSD(),
  209. boost::bind(&LLPanelAvatarNotes::rightsConfirmationCallback, this,
  210. _1, _2, rights));
  211. }
  212. }
  213. void LLPanelAvatarNotes::onCommitRights()
  214. {
  215. const LLRelationship* buddy_relationship =
  216. LLAvatarTracker::instance().getBuddyInfo(getAvatarId());
  217. if (NULL == buddy_relationship)
  218. {
  219. // Lets have a warning log message instead of having a crash. EXT-4947.
  220. llwarns << "Trying to modify rights for non-friend avatar. Skipped." << llendl;
  221. return;
  222. }
  223. S32 rights = 0;
  224. if(childGetValue("status_check").asBoolean())
  225. rights |= LLRelationship::GRANT_ONLINE_STATUS;
  226. if(childGetValue("map_check").asBoolean())
  227. rights |= LLRelationship::GRANT_MAP_LOCATION;
  228. if(childGetValue("objects_check").asBoolean())
  229. rights |= LLRelationship::GRANT_MODIFY_OBJECTS;
  230. bool allow_modify_objects = childGetValue("objects_check").asBoolean();
  231. // if modify objects checkbox clicked
  232. if (buddy_relationship->isRightGrantedTo(
  233. LLRelationship::GRANT_MODIFY_OBJECTS) != allow_modify_objects)
  234. {
  235. confirmModifyRights(allow_modify_objects, rights);
  236. }
  237. // only one checkbox can trigger commit, so store the rest of rights
  238. else
  239. {
  240. LLAvatarPropertiesProcessor::getInstance()->sendFriendRights(
  241. getAvatarId(), rights);
  242. }
  243. }
  244. void LLPanelAvatarNotes::processProperties(void* data, EAvatarProcessorType type)
  245. {
  246. if(APT_NOTES == type)
  247. {
  248. LLAvatarNotes* avatar_notes = static_cast<LLAvatarNotes*>(data);
  249. if(avatar_notes && getAvatarId() == avatar_notes->target_id)
  250. {
  251. childSetValue("notes_edit",avatar_notes->notes);
  252. childSetEnabled("notes edit", true);
  253. LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(),this);
  254. }
  255. }
  256. }
  257. void LLPanelAvatarNotes::resetData()
  258. {
  259. childSetValue("notes_edit",LLStringUtil::null);
  260. // Default value is TRUE
  261. childSetValue("status_check", TRUE);
  262. }
  263. void LLPanelAvatarNotes::resetControls()
  264. {
  265. //Disable "Add Friend" button for friends.
  266. childSetEnabled("add_friend", TRUE);
  267. enableCheckboxes(false);
  268. }
  269. void LLPanelAvatarNotes::onAddFriendButtonClick()
  270. {
  271. LLAvatarActions::requestFriendshipDialog(getAvatarId());
  272. }
  273. void LLPanelAvatarNotes::onIMButtonClick()
  274. {
  275. LLAvatarActions::startIM(getAvatarId());
  276. }
  277. void LLPanelAvatarNotes::onTeleportButtonClick()
  278. {
  279. LLAvatarActions::offerTeleport(getAvatarId());
  280. }
  281. void LLPanelAvatarNotes::onCallButtonClick()
  282. {
  283. LLAvatarActions::startCall(getAvatarId());
  284. }
  285. void LLPanelAvatarNotes::onShareButtonClick()
  286. {
  287. //*TODO not implemented.
  288. }
  289. void LLPanelAvatarNotes::enableCheckboxes(bool enable)
  290. {
  291. childSetEnabled("status_check", enable);
  292. childSetEnabled("map_check", enable);
  293. childSetEnabled("objects_check", enable);
  294. }
  295. LLPanelAvatarNotes::~LLPanelAvatarNotes()
  296. {
  297. if(getAvatarId().notNull())
  298. {
  299. LLAvatarTracker::instance().removeParticularFriendObserver(getAvatarId(), this);
  300. if(LLVoiceClient::getInstance())
  301. LLVoiceClient::getInstance()->removeObserver((LLVoiceClientStatusObserver*)this);
  302. }
  303. }
  304. // virtual, called by LLAvatarTracker
  305. void LLPanelAvatarNotes::changed(U32 mask)
  306. {
  307. childSetEnabled("teleport", LLAvatarTracker::instance().isBuddyOnline(getAvatarId()));
  308. // update rights to avoid have checkboxes enabled when friendship is terminated. EXT-4947.
  309. fillRightsData();
  310. }
  311. // virtual
  312. void LLPanelAvatarNotes::onChange(EStatusType status, const std::string &channelURI, bool proximal)
  313. {
  314. if(status == STATUS_JOINING || status == STATUS_LEFT_CHANNEL)
  315. {
  316. return;
  317. }
  318. childSetEnabled("call", LLVoiceClient::voiceEnabled() && gVoiceClient->voiceWorking());
  319. }
  320. void LLPanelAvatarNotes::setAvatarId(const LLUUID& id)
  321. {
  322. if(id.notNull())
  323. {
  324. if(getAvatarId().notNull())
  325. {
  326. LLAvatarTracker::instance().removeParticularFriendObserver(getAvatarId(), this);
  327. }
  328. LLPanelProfileTab::setAvatarId(id);
  329. LLAvatarTracker::instance().addParticularFriendObserver(getAvatarId(), this);
  330. }
  331. }
  332. //////////////////////////////////////////////////////////////////////////
  333. //////////////////////////////////////////////////////////////////////////
  334. //////////////////////////////////////////////////////////////////////////
  335. LLPanelProfileTab::LLPanelProfileTab()
  336. : LLPanel()
  337. , mAvatarId(LLUUID::null)
  338. {
  339. }
  340. LLPanelProfileTab::~LLPanelProfileTab()
  341. {
  342. if(getAvatarId().notNull())
  343. {
  344. LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(),this);
  345. }
  346. }
  347. void LLPanelProfileTab::setAvatarId(const LLUUID& id)
  348. {
  349. if(id.notNull())
  350. {
  351. if(getAvatarId().notNull())
  352. {
  353. LLAvatarPropertiesProcessor::getInstance()->removeObserver(mAvatarId,this);
  354. }
  355. mAvatarId = id;
  356. LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(),this);
  357. }
  358. }
  359. void LLPanelProfileTab::onOpen(const LLSD& key)
  360. {
  361. // Don't reset panel if we are opening it for same avatar.
  362. if(getAvatarId() != key.asUUID())
  363. {
  364. resetControls();
  365. resetData();
  366. scrollToTop();
  367. }
  368. // Update data even if we are viewing same avatar profile as some data might been changed.
  369. setAvatarId(key.asUUID());
  370. updateData();
  371. updateButtons();
  372. }
  373. void LLPanelProfileTab::scrollToTop()
  374. {
  375. LLScrollContainer* scrollContainer = findChild<LLScrollContainer>("profile_scroll");
  376. if (scrollContainer)
  377. scrollContainer->goToTop();
  378. }
  379. void LLPanelProfileTab::onMapButtonClick()
  380. {
  381. std::string name;
  382. gCacheName->getFullName(getAvatarId(), name);
  383. gFloaterWorldMap->trackAvatar(getAvatarId(), name);
  384. LLFloaterReg::showInstance("world_map");
  385. }
  386. void LLPanelProfileTab::updateButtons()
  387. {
  388. bool is_buddy_online = LLAvatarTracker::instance().isBuddyOnline(getAvatarId());
  389. if(LLAvatarActions::isFriend(getAvatarId()))
  390. {
  391. childSetEnabled("teleport", is_buddy_online);
  392. }
  393. else
  394. {
  395. childSetEnabled("teleport", true);
  396. }
  397. bool enable_map_btn = (is_buddy_online &&
  398.        is_agent_mappable(getAvatarId()))
  399. || gAgent.isGodlike();
  400. childSetEnabled("show_on_map_btn", enable_map_btn);
  401. }
  402. //////////////////////////////////////////////////////////////////////////
  403. //////////////////////////////////////////////////////////////////////////
  404. //////////////////////////////////////////////////////////////////////////
  405. bool enable_god()
  406. {
  407. return gAgent.isGodlike();
  408. }
  409. LLPanelAvatarProfile::LLPanelAvatarProfile()
  410. : LLPanelProfileTab()
  411. {
  412. }
  413. BOOL LLPanelAvatarProfile::postBuild()
  414. {
  415. childSetActionTextbox("homepage_edit", boost::bind(&LLPanelAvatarProfile::onHomepageTextboxClicked, this));
  416. childSetCommitCallback("add_friend",(boost::bind(&LLPanelAvatarProfile::onAddFriendButtonClick,this)),NULL);
  417. childSetCommitCallback("im",(boost::bind(&LLPanelAvatarProfile::onIMButtonClick,this)),NULL);
  418. childSetCommitCallback("call",(boost::bind(&LLPanelAvatarProfile::onCallButtonClick,this)),NULL);
  419. childSetCommitCallback("teleport",(boost::bind(&LLPanelAvatarProfile::onTeleportButtonClick,this)),NULL);
  420. childSetCommitCallback("overflow_btn", boost::bind(&LLPanelAvatarProfile::onOverflowButtonClicked, this), NULL);
  421. childSetCommitCallback("share",(boost::bind(&LLPanelAvatarProfile::onShareButtonClick,this)),NULL);
  422. childSetCommitCallback("show_on_map_btn", (boost::bind(
  423. &LLPanelAvatarProfile::onMapButtonClick, this)), NULL);
  424. LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
  425. registrar.add("Profile.Pay",  boost::bind(&LLPanelAvatarProfile::pay, this));
  426. registrar.add("Profile.Share", boost::bind(&LLPanelAvatarProfile::share, this));
  427. registrar.add("Profile.BlockUnblock", boost::bind(&LLPanelAvatarProfile::toggleBlock, this));
  428. registrar.add("Profile.Kick", boost::bind(&LLPanelAvatarProfile::kick, this));
  429. registrar.add("Profile.Freeze", boost::bind(&LLPanelAvatarProfile::freeze, this));
  430. registrar.add("Profile.Unfreeze", boost::bind(&LLPanelAvatarProfile::unfreeze, this));
  431. registrar.add("Profile.CSR", boost::bind(&LLPanelAvatarProfile::csr, this));
  432. LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable;
  433. enable.add("Profile.EnableGod", boost::bind(&enable_god));
  434. enable.add("Profile.EnableBlock", boost::bind(&LLPanelAvatarProfile::enableBlock, this));
  435. enable.add("Profile.EnableUnblock", boost::bind(&LLPanelAvatarProfile::enableUnblock, this));
  436. mProfileMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_profile_overflow.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
  437. LLTextureCtrl* pic = getChild<LLTextureCtrl>("2nd_life_pic");
  438. pic->setFallbackImageName("default_profile_picture.j2c");
  439. pic = getChild<LLTextureCtrl>("real_world_pic");
  440. pic->setFallbackImageName("default_profile_picture.j2c");
  441. gVoiceClient->addObserver((LLVoiceClientStatusObserver*)this);
  442. resetControls();
  443. resetData();
  444. return TRUE;
  445. }
  446. void LLPanelAvatarProfile::onOpen(const LLSD& key)
  447. {
  448. LLPanelProfileTab::onOpen(key);
  449. mGroups.clear();
  450. //Disable "Add Friend" button for friends.
  451. childSetEnabled("add_friend", !LLAvatarActions::isFriend(getAvatarId()));
  452. }
  453. void LLPanelAvatarProfile::updateData()
  454. {
  455. if (getAvatarId().notNull())
  456. {
  457. LLAvatarPropertiesProcessor::getInstance()->
  458. sendAvatarPropertiesRequest(getAvatarId());
  459. LLAvatarPropertiesProcessor::getInstance()->
  460. sendAvatarGroupsRequest(getAvatarId());
  461. }
  462. }
  463. void LLPanelAvatarProfile::resetControls()
  464. {
  465. childSetVisible("status_panel", true);
  466. childSetVisible("profile_buttons_panel", true);
  467. childSetVisible("title_groups_text", true);
  468. childSetVisible("sl_groups", true);
  469. childSetEnabled("add_friend", true);
  470. childSetVisible("status_me_panel", false);
  471. childSetVisible("profile_me_buttons_panel", false);
  472. childSetVisible("account_actions_panel", false);
  473. }
  474. void LLPanelAvatarProfile::resetData()
  475. {
  476. mGroups.clear();
  477. childSetValue("2nd_life_pic",LLUUID::null);
  478. childSetValue("real_world_pic",LLUUID::null);
  479. childSetValue("online_status",LLStringUtil::null);
  480. childSetValue("status_message",LLStringUtil::null);
  481. childSetValue("sl_description_edit",LLStringUtil::null);
  482. childSetValue("fl_description_edit",LLStringUtil::null);
  483. childSetValue("sl_groups",LLStringUtil::null);
  484. childSetValue("homepage_edit",LLStringUtil::null);
  485. childSetValue("register_date",LLStringUtil::null);
  486. childSetValue("acc_status_text",LLStringUtil::null);
  487. childSetTextArg("partner_text", "[FIRST]", LLStringUtil::null);
  488. childSetTextArg("partner_text", "[LAST]", LLStringUtil::null);
  489. }
  490. void LLPanelAvatarProfile::processProperties(void* data, EAvatarProcessorType type)
  491. {
  492. if(APT_PROPERTIES == type)
  493. {
  494. const LLAvatarData* avatar_data = static_cast<const LLAvatarData*>(data);
  495. if(avatar_data && getAvatarId() == avatar_data->avatar_id)
  496. {
  497. processProfileProperties(avatar_data);
  498. }
  499. }
  500. else if(APT_GROUPS == type)
  501. {
  502. LLAvatarGroups* avatar_groups = static_cast<LLAvatarGroups*>(data);
  503. if(avatar_groups && getAvatarId() == avatar_groups->avatar_id)
  504. {
  505. processGroupProperties(avatar_groups);
  506. }
  507. }
  508. }
  509. void LLPanelAvatarProfile::processProfileProperties(const LLAvatarData* avatar_data)
  510. {
  511. fillCommonData(avatar_data);
  512. fillPartnerData(avatar_data);
  513. fillAccountStatus(avatar_data);
  514. }
  515. void LLPanelAvatarProfile::processGroupProperties(const LLAvatarGroups* avatar_groups)
  516. {
  517. // *NOTE dzaporozhan
  518. // Group properties may arrive in two callbacks, we need to save them across
  519. // different calls. We can't do that in textbox as textbox may change the text.
  520. LLAvatarGroups::group_list_t::const_iterator it = avatar_groups->group_list.begin();
  521. const LLAvatarGroups::group_list_t::const_iterator it_end = avatar_groups->group_list.end();
  522. for(; it_end != it; ++it)
  523. {
  524. LLAvatarGroups::LLGroupData group_data = *it;
  525. mGroups[group_data.group_name] = group_data.group_id;
  526. }
  527. // Creating string, containing group list
  528. std::string groups = "";
  529. for (group_map_t::iterator it = mGroups.begin(); it != mGroups.end(); ++it)
  530. {
  531. if (it != mGroups.begin())
  532. groups += ", ";
  533. std::string group_name = LLURI::escape(it->first);
  534. std::string group_url= it->second.notNull()
  535. ? "[secondlife:///app/group/" + it->second.asString() + "/about " + group_name + "]"
  536. : getString("no_group_text");
  537. groups += group_url;
  538. }
  539. childSetValue("sl_groups", groups);
  540. }
  541. void LLPanelAvatarProfile::fillCommonData(const LLAvatarData* avatar_data)
  542. {
  543. //remove avatar id from cache to get fresh info
  544. LLAvatarIconIDCache::getInstance()->remove(avatar_data->avatar_id);
  545. LLStringUtil::format_map_t args;
  546. args["[REG_DATE]"] = avatar_data->born_on;
  547. args["[AGE]"] = LLDateUtil::ageFromDate( avatar_data->born_on, LLDate::now());
  548. std::string register_date = getString("RegisterDateFormat", args);
  549. childSetValue("register_date", register_date );
  550. childSetValue("sl_description_edit", avatar_data->about_text);
  551. childSetValue("fl_description_edit",avatar_data->fl_about_text);
  552. childSetValue("2nd_life_pic", avatar_data->image_id);
  553. childSetValue("real_world_pic", avatar_data->fl_image_id);
  554. childSetValue("homepage_edit", avatar_data->profile_url);
  555. // Hide home page textbox if no page was set to fix "homepage URL appears clickable without URL - EXT-4734"
  556. childSetVisible("homepage_edit", !avatar_data->profile_url.empty());
  557. }
  558. void LLPanelAvatarProfile::fillPartnerData(const LLAvatarData* avatar_data)
  559. {
  560. LLNameBox* name_box = getChild<LLNameBox>("partner_text");
  561. if (avatar_data->partner_id.notNull())
  562. {
  563. name_box->setNameID(avatar_data->partner_id, FALSE);
  564. }
  565. else
  566. {
  567. name_box->setNameID(LLUUID::null, FALSE);
  568. name_box->setText(getString("no_partner_text"));
  569. }
  570. }
  571. void LLPanelAvatarProfile::fillAccountStatus(const LLAvatarData* avatar_data)
  572. {
  573. LLStringUtil::format_map_t args;
  574. args["[ACCTTYPE]"] = LLAvatarPropertiesProcessor::accountType(avatar_data);
  575. args["[PAYMENTINFO]"] = LLAvatarPropertiesProcessor::paymentInfo(avatar_data);
  576. // *NOTE: AVATAR_AGEVERIFIED not currently getting set in 
  577. // dataserver/lldataavatar.cpp for privacy considerations
  578. args["[AGEVERIFICATION]"] = "";
  579. std::string caption_text = getString("CaptionTextAcctInfo", args);
  580. childSetValue("acc_status_text", caption_text);
  581. }
  582. void LLPanelAvatarProfile::pay()
  583. {
  584. LLAvatarActions::pay(getAvatarId());
  585. }
  586. void LLPanelAvatarProfile::share()
  587. {
  588. LLAvatarActions::share(getAvatarId());
  589. }
  590. void LLPanelAvatarProfile::toggleBlock()
  591. {
  592. LLAvatarActions::toggleBlock(getAvatarId());
  593. }
  594. bool LLPanelAvatarProfile::enableBlock()
  595. {
  596. return LLAvatarActions::canBlock(getAvatarId()) && !LLAvatarActions::isBlocked(getAvatarId());
  597. }
  598. bool LLPanelAvatarProfile::enableUnblock()
  599. {
  600. return LLAvatarActions::isBlocked(getAvatarId());
  601. }
  602. void LLPanelAvatarProfile::kick()
  603. {
  604. LLAvatarActions::kick(getAvatarId());
  605. }
  606. void LLPanelAvatarProfile::freeze()
  607. {
  608. LLAvatarActions::freeze(getAvatarId());
  609. }
  610. void LLPanelAvatarProfile::unfreeze()
  611. {
  612. LLAvatarActions::unfreeze(getAvatarId());
  613. }
  614. void LLPanelAvatarProfile::csr()
  615. {
  616. std::string name;
  617. gCacheName->getFullName(getAvatarId(), name);
  618. LLAvatarActions::csr(getAvatarId(), name);
  619. }
  620. void LLPanelAvatarProfile::onUrlTextboxClicked(const std::string& url)
  621. {
  622. LLWeb::loadURL(url);
  623. }
  624. void LLPanelAvatarProfile::onHomepageTextboxClicked()
  625. {
  626. std::string url = childGetValue("homepage_edit").asString();
  627. if(!url.empty())
  628. {
  629. onUrlTextboxClicked(url);
  630. }
  631. }
  632. void LLPanelAvatarProfile::onAddFriendButtonClick()
  633. {
  634. LLAvatarActions::requestFriendshipDialog(getAvatarId());
  635. }
  636. void LLPanelAvatarProfile::onIMButtonClick()
  637. {
  638. LLAvatarActions::startIM(getAvatarId());
  639. }
  640. void LLPanelAvatarProfile::onTeleportButtonClick()
  641. {
  642. LLAvatarActions::offerTeleport(getAvatarId());
  643. }
  644. void LLPanelAvatarProfile::onCallButtonClick()
  645. {
  646. LLAvatarActions::startCall(getAvatarId());
  647. }
  648. void LLPanelAvatarProfile::onShareButtonClick()
  649. {
  650. //*TODO not implemented
  651. }
  652. void LLPanelAvatarProfile::onOverflowButtonClicked()
  653. {
  654. if (!mProfileMenu->toggleVisibility())
  655. return;
  656. LLView* btn = getChild<LLView>("overflow_btn");
  657. if (mProfileMenu->getButtonRect().isEmpty())
  658. {
  659. mProfileMenu->setButtonRect(btn);
  660. }
  661. mProfileMenu->updateParent(LLMenuGL::sMenuContainer);
  662. LLRect rect = btn->getRect();
  663. LLMenuGL::showPopup(this, mProfileMenu, rect.mRight, rect.mTop);
  664. }
  665. LLPanelAvatarProfile::~LLPanelAvatarProfile()
  666. {
  667. if(getAvatarId().notNull())
  668. {
  669. LLAvatarTracker::instance().removeParticularFriendObserver(getAvatarId(), this);
  670. if(LLVoiceClient::getInstance())
  671. LLVoiceClient::getInstance()->removeObserver((LLVoiceClientStatusObserver*)this);
  672. }
  673. }
  674. // virtual, called by LLAvatarTracker
  675. void LLPanelAvatarProfile::changed(U32 mask)
  676. {
  677. childSetEnabled("teleport", LLAvatarTracker::instance().isBuddyOnline(getAvatarId()));
  678. }
  679. // virtual
  680. void LLPanelAvatarProfile::onChange(EStatusType status, const std::string &channelURI, bool proximal)
  681. {
  682. if(status == STATUS_JOINING || status == STATUS_LEFT_CHANNEL)
  683. {
  684. return;
  685. }
  686. childSetEnabled("call", LLVoiceClient::voiceEnabled() && gVoiceClient->voiceWorking());
  687. }
  688. void LLPanelAvatarProfile::setAvatarId(const LLUUID& id)
  689. {
  690. if(id.notNull())
  691. {
  692. if(getAvatarId().notNull())
  693. {
  694. LLAvatarTracker::instance().removeParticularFriendObserver(getAvatarId(), this);
  695. }
  696. LLPanelProfileTab::setAvatarId(id);
  697. LLAvatarTracker::instance().addParticularFriendObserver(getAvatarId(), this);
  698. }
  699. }
  700. //////////////////////////////////////////////////////////////////////////
  701. //////////////////////////////////////////////////////////////////////////
  702. //////////////////////////////////////////////////////////////////////////
  703. LLPanelMyProfile::LLPanelMyProfile()
  704. : LLPanelAvatarProfile()
  705. {
  706. }
  707. BOOL LLPanelMyProfile::postBuild()
  708. {
  709. LLPanelAvatarProfile::postBuild();
  710. mStatusCombobox = getChild<LLComboBox>("status_combo");
  711. childSetCommitCallback("status_combo", boost::bind(&LLPanelMyProfile::onStatusChanged, this), NULL);
  712. childSetCommitCallback("status_me_message_text", boost::bind(&LLPanelMyProfile::onStatusMessageChanged, this), NULL);
  713. resetControls();
  714. resetData();
  715. return TRUE;
  716. }
  717. void LLPanelMyProfile::onOpen(const LLSD& key)
  718. {
  719. LLPanelProfileTab::onOpen(key);
  720. }
  721. void LLPanelMyProfile::processProfileProperties(const LLAvatarData* avatar_data)
  722. {
  723. fillCommonData(avatar_data);
  724. fillPartnerData(avatar_data);
  725. fillStatusData(avatar_data);
  726. fillAccountStatus(avatar_data);
  727. }
  728. void LLPanelMyProfile::fillStatusData(const LLAvatarData* avatar_data)
  729. {
  730. std::string status;
  731. if (gAgent.getAFK())
  732. {
  733. status = "away";
  734. }
  735. else if (gAgent.getBusy())
  736. {
  737. status = "busy";
  738. }
  739. else
  740. {
  741. status = "online";
  742. }
  743. mStatusCombobox->setValue(status);
  744. }
  745. void LLPanelMyProfile::resetControls()
  746. {
  747. childSetVisible("status_panel", false);
  748. childSetVisible("profile_buttons_panel", false);
  749. childSetVisible("title_groups_text", false);
  750. childSetVisible("sl_groups", false);
  751. childSetVisible("status_me_panel", true);
  752. childSetVisible("profile_me_buttons_panel", true);
  753. }
  754. void LLPanelMyProfile::onStatusChanged()
  755. {
  756. LLSD::String status = mStatusCombobox->getValue().asString();
  757. if ("online" == status)
  758. {
  759. gAgent.clearAFK();
  760. gAgent.clearBusy();
  761. }
  762. else if ("away" == status)
  763. {
  764. gAgent.clearBusy();
  765. gAgent.setAFK();
  766. }
  767. else if ("busy" == status)
  768. {
  769. gAgent.clearAFK();
  770. gAgent.setBusy();
  771. LLNotificationsUtil::add("BusyModeSet");
  772. }
  773. }
  774. void LLPanelMyProfile::onStatusMessageChanged()
  775. {
  776. updateData();
  777. }