/indra/newview/llrecentpeople.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 127 lines · 29 code · 17 blank · 81 comment · 0 complexity · 9b82df4973444d6a559d58ca067b6336 MD5 · raw file

  1. /**
  2. * @file llrecentpeople.h
  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. #ifndef LL_LLRECENTPEOPLE_H
  27. #define LL_LLRECENTPEOPLE_H
  28. #include "llevent.h"
  29. #include "llsingleton.h"
  30. #include "lluuid.h"
  31. #include <vector>
  32. #include <set>
  33. #include <boost/signals2.hpp>
  34. class LLDate;
  35. /**
  36. * List of people the agent recently interacted with.
  37. *
  38. * Includes: anyone with whom the user IM'd or called
  39. * (1:1 and ad-hoc but not SL Group chat),
  40. * anyone with whom the user has had a transaction
  41. * (inventory offer, friend request, etc),
  42. * and anyone that has chatted within chat range of the user in-world.
  43. *
  44. *TODO: purge least recently added items?
  45. */
  46. class LLRecentPeople: public LLSingleton<LLRecentPeople>, public LLOldEvents::LLSimpleListener
  47. {
  48. LOG_CLASS(LLRecentPeople);
  49. public:
  50. typedef boost::signals2::signal<void ()> signal_t;
  51. /**
  52. * Add specified avatar to the list if it's not there already.
  53. *
  54. * @param id avatar to add.
  55. *
  56. * @param userdata additional information about last interaction party.
  57. * For example when last interaction party is not an avatar
  58. * but an avaline caller, additional info (such as phone
  59. * number, session id and etc.) should be added.
  60. *
  61. * @return false if the avatar is in the list already, true otherwise
  62. */
  63. bool add(const LLUUID& id, const LLSD& userdata = LLSD().with("date", LLDate::now()));
  64. /**
  65. * @param id avatar to search.
  66. * @return true if the avatar is in the list, false otherwise.
  67. */
  68. bool contains(const LLUUID& id) const;
  69. /**
  70. * Get the whole list.
  71. *
  72. * @param result where to put the result.
  73. */
  74. void get(uuid_vec_t& result) const;
  75. /**
  76. * Returns last interaction time with specified participant
  77. *
  78. */
  79. const LLDate getDate(const LLUUID& id) const;
  80. /**
  81. * Returns data about specified participant
  82. *
  83. * @param id identifier of specific participant
  84. */
  85. const LLSD& getData(const LLUUID& id) const;
  86. /**
  87. * Checks whether specific participant is an avaline caller
  88. *
  89. * @param id identifier of specific participant
  90. */
  91. bool isAvalineCaller(const LLUUID& id) const;
  92. /**
  93. * Set callback to be called when the list changed.
  94. *
  95. * Multiple callbacks can be set.
  96. *
  97. * @return no connection; use boost::bind + boost::signals2::trackable to disconnect slots.
  98. */
  99. void setChangedCallback(const signal_t::slot_type& cb) { mChangedSignal.connect(cb); }
  100. /**
  101. * LLSimpleListener interface.
  102. */
  103. /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  104. private:
  105. const LLUUID& getIDByPhoneNumber(const LLSD& userdata);
  106. typedef std::map<LLUUID, LLSD> recent_people_t;
  107. recent_people_t mPeople;
  108. signal_t mChangedSignal;
  109. };
  110. #endif // LL_LLRECENTPEOPLE_H