PageRenderTime 24ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llrecentpeople.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 128 lines | 73 code | 24 blank | 31 comment | 18 complexity | 7346a82aa5eef933fc8769e7e2ea55ed MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llrecentpeople.cpp
  3. * @brief List of people with which the user has recently interacted.
  4. *
  5. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llrecentpeople.h"
  28. #include "llgroupmgr.h"
  29. #include "llagent.h"
  30. using namespace LLOldEvents;
  31. bool LLRecentPeople::add(const LLUUID& id, const LLSD& userdata)
  32. {
  33. if (id == gAgent.getID())
  34. return false;
  35. bool is_not_group_id = LLGroupMgr::getInstance()->getGroupData(id) == NULL;
  36. if (is_not_group_id)
  37. {
  38. // For each avaline call the id of caller is different even if
  39. // the phone number is the same.
  40. // To avoid duplication of avaline list items in the recent list
  41. // of panel People, deleting id's with similar phone number.
  42. const LLUUID& caller_id = getIDByPhoneNumber(userdata);
  43. if (caller_id.notNull())
  44. mPeople.erase(caller_id);
  45. //[] instead of insert to replace existing id->llsd["date"] with new date value
  46. mPeople[id] = userdata;
  47. mChangedSignal();
  48. }
  49. return is_not_group_id;
  50. }
  51. bool LLRecentPeople::contains(const LLUUID& id) const
  52. {
  53. return mPeople.find(id) != mPeople.end();
  54. }
  55. void LLRecentPeople::get(uuid_vec_t& result) const
  56. {
  57. result.clear();
  58. for (recent_people_t::const_iterator pos = mPeople.begin(); pos != mPeople.end(); ++pos)
  59. result.push_back((*pos).first);
  60. }
  61. const LLDate LLRecentPeople::getDate(const LLUUID& id) const
  62. {
  63. recent_people_t::const_iterator it = mPeople.find(id);
  64. if (it!= mPeople.end()) return it->second["date"].asDate();
  65. static LLDate no_date = LLDate();
  66. return no_date;
  67. }
  68. const LLSD& LLRecentPeople::getData(const LLUUID& id) const
  69. {
  70. recent_people_t::const_iterator it = mPeople.find(id);
  71. if (it != mPeople.end())
  72. return it->second;
  73. static LLSD no_data = LLSD();
  74. return no_data;
  75. }
  76. bool LLRecentPeople::isAvalineCaller(const LLUUID& id) const
  77. {
  78. recent_people_t::const_iterator it = mPeople.find(id);
  79. if (it != mPeople.end())
  80. {
  81. const LLSD& user = it->second;
  82. return user["avaline_call"].asBoolean();
  83. }
  84. return false;
  85. }
  86. const LLUUID& LLRecentPeople::getIDByPhoneNumber(const LLSD& userdata)
  87. {
  88. if (!userdata["avaline_call"].asBoolean())
  89. return LLUUID::null;
  90. for (recent_people_t::const_iterator it = mPeople.begin(); it != mPeople.end(); ++it)
  91. {
  92. const LLSD& user_info = it->second;
  93. if (user_info["call_number"].asString() == userdata["call_number"].asString())
  94. return it->first;
  95. }
  96. return LLUUID::null;
  97. }
  98. // virtual
  99. bool LLRecentPeople::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
  100. {
  101. (void) userdata;
  102. add(event->getValue().asUUID());
  103. return true;
  104. }