llexperiencelog.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * @file llexperiencelog.h
  3. * @brief llexperiencelog and related class definitions
  4. *
  5. * $LicenseInfo:firstyear=2014&license=viewergpl$
  6. *
  7. * Copyright (c) 2014, 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. #ifndef LL_LLEXPERIENCELOG_H
  33. #define LL_LLEXPERIENCELOG_H
  34. #include "boost/signals2.hpp"
  35. #include "llerror.h"
  36. #include "llsingleton.h"
  37. extern const std::string PUMP_EXPERIENCE;
  38. class LLExperienceLog : public LLSingleton<LLExperienceLog>
  39. {
  40. friend class LLExperienceLogDispatchHandler;
  41. friend class LLSingleton<LLExperienceLog>;
  42. protected:
  43. LOG_CLASS(LLExperienceLog);
  44. LLExperienceLog();
  45. void loadEvents();
  46. void saveEvents();
  47. void eraseExpired();
  48. public:
  49. virtual ~LLExperienceLog();
  50. typedef boost::signals2::signal<void(LLSD&)> callback_signal_t;
  51. typedef callback_signal_t::slot_type callback_slot_t;
  52. typedef boost::signals2::connection callback_connection_t;
  53. callback_connection_t addUpdateSignal(const callback_slot_t& cb);
  54. void initialize();
  55. LL_INLINE U32 getMaxDays() const { return mMaxDays; }
  56. LL_INLINE void setMaxDays(U32 val) { mMaxDays = val; }
  57. LL_INLINE bool getNotifyNewEvent() const { return mNotifyNewEvent; }
  58. void setNotifyNewEvent(bool val);
  59. LL_INLINE U32 getPageSize() const { return mPageSize; }
  60. LL_INLINE void setPageSize(U32 val) { mPageSize = val; }
  61. LL_INLINE const LLSD& getEvents()const { return mEvents; }
  62. LL_INLINE void clear() { mEvents.clear(); }
  63. static void notify(LLSD& message);
  64. static std::string getFilename();
  65. static std::string getPermissionString(const LLSD& message,
  66. const std::string& base);
  67. LL_INLINE void setEventsToSave(LLSD event) { mEventsToSave = event; }
  68. bool isNotExpired(std::string& date);
  69. void handleExperienceMessage(LLSD& message);
  70. protected:
  71. callback_signal_t mSignals;
  72. callback_connection_t mNotifyConnection;
  73. U32 mMaxDays;
  74. U32 mPageSize;
  75. LLSD mEvents;
  76. LLSD mEventsToSave;
  77. bool mNotifyNewEvent;
  78. };
  79. #endif // LL_LLEXPERIENCELOG_H