llfloatergroupinvite.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. /**
  2. * @file llfloatergroupinvite.cpp
  3. * @brief Floater to invite new members into a group.
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewergpl$
  6. *
  7. * Copyright (c) 2006-2009, 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 "llfloatergroupinvite.h"
  34. #include "llbutton.h"
  35. #include "llcombobox.h"
  36. #include "llnamelistctrl.h"
  37. #include "lltextbox.h"
  38. #include "lluictrlfactory.h"
  39. #include "llagent.h"
  40. #include "llfloateravatarpicker.h"
  41. #include "llgroupmgr.h"
  42. #include "llviewerobjectlist.h"
  43. #include "llvoavatar.h"
  44. //
  45. // Globals
  46. //
  47. LLFloaterGroupInvite::instances_map_t LLFloaterGroupInvite::sInstances;
  48. class LLFloaterGroupInviteData
  49. {
  50. public:
  51. LLFloaterGroupInviteData(LLFloater* self, const LLUUID& group_id)
  52. : mSelf(self),
  53. mGroupId(group_id),
  54. mPanel(NULL)
  55. {
  56. }
  57. ~LLFloaterGroupInviteData()
  58. {
  59. }
  60. LLFloater* mSelf;
  61. LLUUID mGroupId;
  62. LLPanelGroupInvite* mPanel;
  63. };
  64. //////////////////////////////////////////////////////////////////////
  65. // LLPanelGroupInvite (forward declaration)
  66. //////////////////////////////////////////////////////////////////////
  67. class LLPanelGroupInvite final : public LLPanel
  68. {
  69. protected:
  70. LOG_CLASS(LLPanelGroupInvite);
  71. void updateLists();
  72. public:
  73. LLPanelGroupInvite(const LLUUID& group_id, LLFloater* parent);
  74. ~LLPanelGroupInvite() override;
  75. void draw() override;
  76. bool postBuild() override;
  77. void clear() override;
  78. void addUsers(uuid_vec_t& agent_ids);
  79. void update();
  80. protected:
  81. class impl;
  82. impl* mImplementation;
  83. bool mPendingUpdate;
  84. LLUUID mStoreSelected;
  85. };
  86. //////////////////////////////////////////////////////////////////////
  87. // LLPanelGroupInvite::impl (*TODO: use LLPanelGroupBulk instead)
  88. //////////////////////////////////////////////////////////////////////
  89. class LLPanelGroupInvite::impl
  90. {
  91. public:
  92. impl(const LLUUID& group_id, LLFloater* parent);
  93. void addUsers(const std::vector<std::string>& names,
  94. const uuid_vec_t& agent_ids);
  95. void submitInvitations();
  96. void addRoleNames(LLGroupMgrGroupData* gdatap);
  97. void handleRemove();
  98. void handleSelection();
  99. static void callbackClickCancel(void* userdata);
  100. static void callbackClickOK(void* userdata);
  101. static void callbackClickAdd(void* userdata);
  102. static void callbackClickRemove(void* userdata);
  103. static void callbackSelect(LLUICtrl* ctrl, void* userdata);
  104. static void callbackAddUsers(const std::vector<std::string>& names,
  105. const uuid_vec_t& agent_ids,
  106. void* user_data);
  107. bool inviteOwnerCallback(const LLSD& notification, const LLSD& response);
  108. public:
  109. LLFloater* mParentFloater;
  110. LLUUID mGroupID;
  111. LLNameListCtrl* mInvitees;
  112. LLComboBox* mRoleNames;
  113. LLButton* mOKButton;
  114. LLButton* mRemoveButton;
  115. LLTextBox* mGroupName;
  116. std::string mLoadingText;
  117. std::string mOwnerWarning;
  118. std::string mTooManySelected;
  119. bool mConfirmedOwnerInvite;
  120. uuid_list_t mInviteeIDs;
  121. };
  122. LLPanelGroupInvite::impl::impl(const LLUUID& group_id, LLFloater* parent)
  123. : mGroupID(group_id),
  124. mParentFloater(parent),
  125. mLoadingText(),
  126. mInvitees(NULL),
  127. mRoleNames(NULL),
  128. mOKButton(NULL),
  129. mRemoveButton(NULL),
  130. mGroupName(NULL),
  131. mConfirmedOwnerInvite(false)
  132. {
  133. }
  134. void LLPanelGroupInvite::impl::addUsers(const std::vector<std::string>& names,
  135. const uuid_vec_t& agent_ids)
  136. {
  137. if ((U32)(names.size() + mInviteeIDs.size()) > MAX_GROUP_INVITES)
  138. {
  139. // Fail !... Show a warning and don't add any names.
  140. LLSD msg;
  141. msg["MESSAGE"] = mTooManySelected;
  142. gNotifications.add("GenericAlert", msg);
  143. return;
  144. }
  145. for (S32 i = 0, count = names.size(); i < count; ++i)
  146. {
  147. const std::string& name = names[i];
  148. const LLUUID& id = agent_ids[i];
  149. if (mInviteeIDs.count(id))
  150. {
  151. continue; // Already in list, skip...
  152. }
  153. // add the name to the names list
  154. LLSD row;
  155. row["id"] = id;
  156. row["columns"][0]["value"] = name;
  157. mInvitees->addElement(row);
  158. mInviteeIDs.emplace(id);
  159. }
  160. }
  161. void LLPanelGroupInvite::impl::submitInvitations()
  162. {
  163. LLGroupMgrGroupData* gdatap = gGroupMgr.getGroupData(mGroupID);
  164. if (!gdatap) return;
  165. // Default to everyone role.
  166. LLUUID role_id;
  167. if (mRoleNames)
  168. {
  169. role_id = mRoleNames->getCurrentID();
  170. // Owner role: display confirmation and wait for callback
  171. if (role_id == gdatap->mOwnerRole && !mConfirmedOwnerInvite)
  172. {
  173. LLSD args;
  174. args["MESSAGE"] = mOwnerWarning;
  175. gNotifications.add("GenericAlertYesCancel", args, LLSD(),
  176. boost::bind(&LLPanelGroupInvite::impl::inviteOwnerCallback,
  177. this, _1, _2));
  178. return; // We will be called again if user confirms
  179. }
  180. }
  181. // Loop over the users
  182. LLGroupMgr::role_member_pairs_t role_member_pairs;
  183. std::vector<LLScrollListItem*> items = mInvitees->getAllData();
  184. for (S32 i = 0, count = items.size(); i < count; ++i)
  185. {
  186. LLScrollListItem* item = items[i];
  187. role_member_pairs[item->getUUID()] = role_id;
  188. }
  189. if ((U32)role_member_pairs.size() > MAX_GROUP_INVITES)
  190. {
  191. // Fail !
  192. LLSD msg;
  193. msg["MESSAGE"] = mTooManySelected;
  194. gNotifications.add("GenericAlert", msg);
  195. if (mParentFloater) // Paranoia
  196. {
  197. mParentFloater->close();
  198. }
  199. return;
  200. }
  201. gGroupMgr.sendGroupMemberInvites(mGroupID, role_member_pairs);
  202. // Then close
  203. if (mParentFloater) // Paranoia
  204. {
  205. mParentFloater->close();
  206. }
  207. }
  208. bool LLPanelGroupInvite::impl::inviteOwnerCallback(const LLSD& notification,
  209. const LLSD& response)
  210. {
  211. if (LLNotification::getSelectedOption(notification, response) == 0)
  212. {
  213. // User confirmed that they really want a new group owner
  214. mConfirmedOwnerInvite = true;
  215. submitInvitations();
  216. }
  217. return false;
  218. }
  219. void LLPanelGroupInvite::impl::addRoleNames(LLGroupMgrGroupData* gdatap)
  220. {
  221. if (!gdatap) return;
  222. // Loop over the agent's roles in the group then add those roles to the
  223. // list of roles that the agent can invite people to be. If the user is the
  224. // owner then we add all of the roles in the group, else if they have the
  225. // "add to roles" power we add every role but owner, else if they have the
  226. // limited add to roles power we add every role the user is in, else we
  227. // just add to everyone.
  228. bool is_owner = false;
  229. bool can_assign_any = gAgent.hasPowerInGroup(mGroupID,
  230. GP_ROLE_ASSIGN_MEMBER);
  231. bool can_assign_limited =
  232. gAgent.hasPowerInGroup(mGroupID, GP_ROLE_ASSIGN_MEMBER_LIMITED);
  233. LLGroupMemberData* member_data = NULL;
  234. // Get the member data for the agent if it exists
  235. LLGroupMgrGroupData::member_list_t::iterator agent_iter =
  236. gdatap->mMembers.find(gAgentID);
  237. if (agent_iter != gdatap->mMembers.end())
  238. {
  239. member_data = agent_iter->second;
  240. if (member_data && mRoleNames)
  241. {
  242. is_owner = member_data->isOwner();
  243. }
  244. }
  245. // Populate the role list
  246. for (LLGroupMgrGroupData::role_list_t::iterator
  247. it = gdatap->mRoles.begin(), end = gdatap->mRoles.end();
  248. it != end; ++it)
  249. {
  250. const LLUUID& role_id = it->first;
  251. LLRoleData rd;
  252. if (gdatap->getRoleData(role_id, rd))
  253. {
  254. // Owners can add any role.
  255. if (is_owner ||
  256. // Even 'can_assign_any' cannot add owner role.
  257. (can_assign_any && role_id != gdatap->mOwnerRole) ||
  258. // Add all roles user is in
  259. (can_assign_limited && member_data &&
  260. member_data->isInRole(role_id)) ||
  261. // Everyone role.
  262. role_id.isNull())
  263. {
  264. mRoleNames->add(rd.mRoleName, role_id, ADD_BOTTOM);
  265. }
  266. }
  267. }
  268. }
  269. //static
  270. void LLPanelGroupInvite::impl::callbackClickAdd(void* userdata)
  271. {
  272. LLPanelGroupInvite* self = (LLPanelGroupInvite*)userdata;
  273. if (self)
  274. {
  275. LLFloater* childp = LLFloaterAvatarPicker::show(callbackAddUsers,
  276. self->mImplementation);
  277. if (gFloaterViewp)
  278. {
  279. LLFloater* parentp = gFloaterViewp->getParentFloater(self);
  280. if (parentp)
  281. {
  282. parentp->addDependentFloater(childp);
  283. }
  284. }
  285. }
  286. }
  287. //static
  288. void LLPanelGroupInvite::impl::callbackClickRemove(void* userdata)
  289. {
  290. impl* self = (impl*)userdata;
  291. if (self)
  292. {
  293. self->handleRemove();
  294. }
  295. }
  296. void LLPanelGroupInvite::impl::handleRemove()
  297. {
  298. // Check if there is anything selected.
  299. std::vector<LLScrollListItem*> selection = mInvitees->getAllSelected();
  300. if (selection.empty()) return;
  301. for (S32 i = 0, count = selection.size(); i < count; ++i)
  302. {
  303. mInviteeIDs.erase(selection[i]->getUUID());
  304. }
  305. // Remove all selected invitees.
  306. mInvitees->deleteSelectedItems();
  307. mRemoveButton->setEnabled(false);
  308. mInviteeIDs.clear();
  309. }
  310. // static
  311. void LLPanelGroupInvite::impl::callbackSelect(LLUICtrl* ctrl, void* userdata)
  312. {
  313. impl* self = (impl*)userdata;
  314. if (self)
  315. {
  316. self->handleSelection();
  317. }
  318. }
  319. void LLPanelGroupInvite::impl::handleSelection()
  320. {
  321. // Check if there is anything selected.
  322. mRemoveButton->setEnabled(mInvitees->getFirstSelected() != NULL);
  323. }
  324. void LLPanelGroupInvite::impl::callbackClickCancel(void* userdata)
  325. {
  326. impl* self = (impl*)userdata;
  327. if (self && self->mParentFloater)
  328. {
  329. self->mParentFloater->close();
  330. }
  331. }
  332. void LLPanelGroupInvite::impl::callbackClickOK(void* userdata)
  333. {
  334. impl* self = (impl*)userdata;
  335. if (self)
  336. {
  337. self->submitInvitations();
  338. }
  339. }
  340. //static
  341. void LLPanelGroupInvite::impl::callbackAddUsers(const std::vector<std::string>& names,
  342. const uuid_vec_t& ids,
  343. void* user_data)
  344. {
  345. impl* self = (impl*)user_data;
  346. if (self)
  347. {
  348. self->addUsers(names, ids);
  349. }
  350. }
  351. //////////////////////////////////////////////////////////////////////
  352. // LLPanelGroupInvite
  353. //////////////////////////////////////////////////////////////////////
  354. LLPanelGroupInvite::LLPanelGroupInvite(const LLUUID& group_id,
  355. LLFloater* parent)
  356. : LLPanel(group_id.asString()),
  357. mImplementation(new impl(group_id, parent)),
  358. mPendingUpdate(false),
  359. mStoreSelected()
  360. {
  361. }
  362. LLPanelGroupInvite::~LLPanelGroupInvite()
  363. {
  364. if (mImplementation)
  365. {
  366. delete mImplementation;
  367. mImplementation = NULL;
  368. }
  369. }
  370. bool LLPanelGroupInvite::postBuild()
  371. {
  372. if (!mImplementation) return false;
  373. mImplementation->mLoadingText = getString("loading");
  374. mImplementation->mRoleNames = getChild<LLComboBox>("role_name",
  375. true, false);
  376. mImplementation->mGroupName = getChild<LLTextBox>("group_name_text",
  377. true, false);
  378. LLNameListCtrl* list = getChild<LLNameListCtrl>("invitee_list",
  379. true, false);
  380. mImplementation->mInvitees = list;
  381. if (list)
  382. {
  383. list->setCallbackUserData(mImplementation);
  384. list->setCommitOnSelectionChange(true);
  385. list->setCommitCallback(impl::callbackSelect);
  386. }
  387. LLButton* button = getChild<LLButton>("add_button");
  388. // Default to opening avatarpicker automatically
  389. // (*impl::callbackClickAdd)((void*)this);
  390. button->setClickedCallback(impl::callbackClickAdd);
  391. button->setCallbackUserData(this);
  392. button = getChild<LLButton>("cancel_button");
  393. button->setClickedCallback(impl::callbackClickCancel);
  394. button->setCallbackUserData(mImplementation);
  395. button = getChild<LLButton>("remove_button", true, false);
  396. mImplementation->mRemoveButton = button;
  397. if (button)
  398. {
  399. button->setClickedCallback(impl::callbackClickRemove);
  400. button->setCallbackUserData(mImplementation);
  401. button->setEnabled(false);
  402. }
  403. button = getChild<LLButton>("invite_button", true, false);
  404. mImplementation->mOKButton = button;
  405. if (button)
  406. {
  407. button->setClickedCallback(impl::callbackClickOK);
  408. button->setCallbackUserData(mImplementation);
  409. button->setEnabled(false);
  410. }
  411. mImplementation->mOwnerWarning = getString("confirm_invite_owner_str");
  412. mImplementation->mTooManySelected =
  413. getString("invite_selection_too_large");
  414. update();
  415. return true;
  416. }
  417. void LLPanelGroupInvite::clear()
  418. {
  419. mStoreSelected.setNull();
  420. if (!mImplementation) return;
  421. if (mImplementation->mInvitees)
  422. {
  423. mImplementation->mInvitees->deleteAllItems();
  424. }
  425. if (mImplementation->mRoleNames)
  426. {
  427. mImplementation->mRoleNames->clear();
  428. mImplementation->mRoleNames->removeall();
  429. }
  430. if (mImplementation->mOKButton)
  431. {
  432. mImplementation->mOKButton->setEnabled(false);
  433. }
  434. }
  435. void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids)
  436. {
  437. std::vector<std::string> names;
  438. for (S32 i = 0, count = agent_ids.size(); i < count; ++i)
  439. {
  440. LLUUID agent_id = agent_ids[i];
  441. LLVOAvatar* avatarp = gObjectList.findAvatar(agent_id);
  442. if (avatarp)
  443. {
  444. std::string fullname;
  445. LLSD args;
  446. LLNameValue* nvfirst = avatarp->getNVPair("FirstName");
  447. LLNameValue* nvlast = avatarp->getNVPair("LastName");
  448. if (nvfirst && nvlast)
  449. {
  450. args["FIRST"] = std::string(nvfirst->getString());
  451. args["LAST"] = std::string(nvlast->getString());
  452. fullname = std::string(nvfirst->getString()) + " " +
  453. std::string(nvlast->getString());
  454. }
  455. if (!fullname.empty())
  456. {
  457. names.emplace_back(fullname);
  458. }
  459. else
  460. {
  461. llwarns << "Selected avatar has no name: " << avatarp->getID()
  462. << llendl;
  463. names.emplace_back("(Unknown)");
  464. }
  465. }
  466. }
  467. mImplementation->addUsers(names, agent_ids);
  468. }
  469. void LLPanelGroupInvite::draw()
  470. {
  471. if (mPendingUpdate)
  472. {
  473. updateLists();
  474. }
  475. LLPanel::draw();
  476. }
  477. void LLPanelGroupInvite::update()
  478. {
  479. mPendingUpdate = false;
  480. if (!mImplementation) return;
  481. if (mImplementation->mGroupName)
  482. {
  483. mImplementation->mGroupName->setText(mImplementation->mLoadingText);
  484. }
  485. if (mImplementation->mRoleNames)
  486. {
  487. mStoreSelected = mImplementation->mRoleNames->getCurrentID();
  488. mImplementation->mRoleNames->clear();
  489. mImplementation->mRoleNames->removeall();
  490. mImplementation->mRoleNames->add(mImplementation->mLoadingText,
  491. LLUUID::null, ADD_BOTTOM);
  492. mImplementation->mRoleNames->setCurrentByID(LLUUID::null);
  493. }
  494. updateLists();
  495. }
  496. void LLPanelGroupInvite::updateLists()
  497. {
  498. if (!mImplementation) return;
  499. bool waiting = false;
  500. LLGroupMgrGroupData* gdatap =
  501. gGroupMgr.getGroupData(mImplementation->mGroupID);
  502. if (gdatap)
  503. {
  504. if (gdatap->isGroupPropertiesDataComplete())
  505. {
  506. if (mImplementation->mGroupName)
  507. {
  508. mImplementation->mGroupName->setText(gdatap->mName);
  509. }
  510. }
  511. else
  512. {
  513. waiting = true;
  514. }
  515. if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete() &&
  516. (gdatap->isRoleMemberDataComplete() ||
  517. // MAINT-5270: large groups receives an empty members list
  518. // without some powers, so RoleMemberData would not be complete
  519. // for them.
  520. !gdatap->mMembers.size()))
  521. {
  522. if (mImplementation->mRoleNames)
  523. {
  524. mImplementation->mRoleNames->clear();
  525. mImplementation->mRoleNames->removeall();
  526. // Add the role names and select the everybody role by default
  527. mImplementation->addRoleNames(gdatap);
  528. mImplementation->mRoleNames->setCurrentByID(mStoreSelected);
  529. }
  530. }
  531. else
  532. {
  533. waiting = true;
  534. }
  535. }
  536. else
  537. {
  538. waiting = true;
  539. }
  540. if (waiting)
  541. {
  542. if (!mPendingUpdate)
  543. {
  544. // NOTE: this will partially fail if some requests are already in
  545. // progress
  546. gGroupMgr.sendGroupPropertiesRequest(mImplementation->mGroupID);
  547. gGroupMgr.sendGroupRoleDataRequest(mImplementation->mGroupID);
  548. gGroupMgr.sendGroupRoleMembersRequest(mImplementation->mGroupID);
  549. gGroupMgr.sendCapGroupMembersRequest(mImplementation->mGroupID);
  550. }
  551. else if (gdatap)
  552. {
  553. // Restart requests that were interrupted/dropped/failed to start
  554. if (!gdatap->isRoleDataPending() && !gdatap->isRoleDataComplete())
  555. {
  556. gGroupMgr.sendGroupRoleDataRequest(mImplementation->mGroupID);
  557. }
  558. if (!gdatap->isRoleMemberDataPending() &&
  559. !gdatap->isRoleMemberDataComplete())
  560. {
  561. gGroupMgr.sendGroupRoleMembersRequest(mImplementation->mGroupID);
  562. }
  563. // sendCapGroupMembersRequest() has a per frame send limitation
  564. // that could have interrupted previous request
  565. if (!gdatap->isMemberDataPending() && !gdatap->isMemberDataComplete())
  566. {
  567. gGroupMgr.sendCapGroupMembersRequest(mImplementation->mGroupID);
  568. }
  569. }
  570. mPendingUpdate = true;
  571. }
  572. else
  573. {
  574. mPendingUpdate = false;
  575. if (mImplementation->mOKButton &&
  576. mImplementation->mRoleNames->getItemCount())
  577. {
  578. mImplementation->mOKButton->setEnabled(true);
  579. }
  580. }
  581. }
  582. //////////////////////////////////////////////////////////////////////
  583. // LLFloaterGroupInvite
  584. //////////////////////////////////////////////////////////////////////
  585. // static
  586. void* LLFloaterGroupInvite::createPanel(void* userdata)
  587. {
  588. LLFloaterGroupInviteData* data = (LLFloaterGroupInviteData*)userdata;
  589. if (data)
  590. {
  591. data->mPanel = new LLPanelGroupInvite(data->mGroupId, data->mSelf);
  592. return data->mPanel;
  593. }
  594. else
  595. {
  596. return NULL;
  597. }
  598. }
  599. LLFloaterGroupInvite::LLFloaterGroupInvite(const LLUUID& group_id)
  600. : LLFloater(group_id.asString()),
  601. mGroupID(group_id),
  602. mInvitePanelp(NULL)
  603. {
  604. // Create the group bulk ban panel together with this floater
  605. LLFloaterGroupInviteData* data;
  606. data = new LLFloaterGroupInviteData(this, group_id);
  607. LLCallbackMap::map_t factory_map;
  608. factory_map["invite_panel"] = LLCallbackMap(createPanel, data);
  609. LLUICtrlFactory::getInstance()->buildFloater(this,
  610. "floater_group_invite.xml",
  611. &factory_map);
  612. mInvitePanelp = data->mPanel;
  613. delete data;
  614. }
  615. //virtual
  616. LLFloaterGroupInvite::~LLFloaterGroupInvite()
  617. {
  618. if (mGroupID.notNull())
  619. {
  620. sInstances.erase(mGroupID);
  621. }
  622. if (mInvitePanelp)
  623. {
  624. delete mInvitePanelp;
  625. mInvitePanelp = NULL;
  626. }
  627. }
  628. //static
  629. void LLFloaterGroupInvite::showForGroup(const LLUUID& group_id,
  630. uuid_vec_t* agent_ids,
  631. LLView* parent)
  632. {
  633. if (group_id.isNull())
  634. {
  635. llwarns << "Null group_id passed ! Aborting." << llendl;
  636. return;
  637. }
  638. // If we do not have a floater for this group, create one.
  639. LLFloaterGroupInvite* fgi = get_ptr_in_map(sInstances, group_id);
  640. if (!fgi)
  641. {
  642. fgi = new LLFloaterGroupInvite(group_id);
  643. if (!fgi || !fgi->mInvitePanelp)
  644. {
  645. llwarns << "Could not create the floater ! Aborting." << llendl;
  646. return;
  647. }
  648. if (parent && gFloaterViewp && gFloaterViewp->getParentFloater(parent))
  649. {
  650. gFloaterViewp->getParentFloater(parent)->addDependentFloater(fgi);
  651. }
  652. sInstances[group_id] = fgi;
  653. fgi->mInvitePanelp->clear();
  654. }
  655. if (!fgi->mInvitePanelp) // Paranoia
  656. {
  657. llwarns << "NULL panel in floater ! Aborting." << llendl;
  658. return;
  659. }
  660. if (agent_ids)
  661. {
  662. fgi->mInvitePanelp->addUsers(*agent_ids);
  663. }
  664. fgi->open();
  665. fgi->mInvitePanelp->update();
  666. }