lleventnotifier.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * @file lleventnotifier.h
  3. * @brief Viewer code for managing event notifications
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewergpl$
  6. *
  7. * Copyright (c) 2004-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. #ifndef LL_LLEVENTNOTIFIER_H
  33. #define LL_LLEVENTNOTIFIER_H
  34. #include <map>
  35. #include "llframetimer.h"
  36. #include "llvector3d.h"
  37. class LLMessageSystem;
  38. class LLEventInfo
  39. {
  40. public:
  41. LLEventInfo() {}
  42. void unpack(LLMessageSystem* msg);
  43. static void loadCategories(const LLSD& event_options);
  44. public:
  45. std::string mName;
  46. U32 mID;
  47. std::string mDesc;
  48. std::string mCategoryStr;
  49. U32 mDuration;
  50. std::string mTimeStr;
  51. LLUUID mRunByID;
  52. std::string mSimName;
  53. LLVector3d mPosGlobal;
  54. time_t mUnixTime;
  55. U32 mCover;
  56. U32 mEventFlags;
  57. bool mHasCover;
  58. bool mSelected;
  59. typedef std::map<U32, std::string> map_t;
  60. static map_t sCategories;
  61. };
  62. class LLEventNotification final
  63. {
  64. protected:
  65. LOG_CLASS(LLEventNotification);
  66. public:
  67. LLEventNotification();
  68. // In the format it comes in from login
  69. bool load(const LLSD& event_options);
  70. // From existing event_info on the viewer.
  71. bool load(const LLEventInfo& event_info);
  72. #if 0
  73. void setEventID(U32 event_id);
  74. void setEventName(std::string& event_name);
  75. #endif
  76. LL_INLINE U32 getEventID() const { return mEventID; }
  77. LL_INLINE const std::string& getEventName() const { return mEventName; }
  78. LL_INLINE time_t getEventDate() const { return mEventDate; }
  79. LL_INLINE const std::string& getEventDateStr() const { return mEventDateStr; }
  80. LL_INLINE LLVector3d getEventPosGlobal() const { return mEventPosGlobal; }
  81. LL_INLINE bool handleResponse(const LLSD& notif, const LLSD& payload);
  82. protected:
  83. U32 mEventID; // EventID for this event
  84. std::string mEventName;
  85. std::string mEventDateStr;
  86. time_t mEventDate;
  87. LLVector3d mEventPosGlobal;
  88. };
  89. class LLEventNotifier final
  90. {
  91. public:
  92. LLEventNotifier();
  93. ~LLEventNotifier();
  94. void update(); // Notify the user of the event if it is coming up
  95. // In the format that it comes in from login
  96. void load(const LLSD& event_options);
  97. // Add a new notification for an event
  98. void add(LLEventInfo& event_info);
  99. void remove(U32 event_id);
  100. bool hasNotification(U32 event_id);
  101. typedef std::map<U32, LLEventNotification*> map_t;
  102. protected:
  103. map_t mEventNotifications;
  104. LLFrameTimer mNotificationTimer;
  105. };
  106. extern LLEventNotifier gEventNotifier;
  107. constexpr U32 EVENT_FLAG_NONE = 0x0000;
  108. constexpr U32 EVENT_FLAG_MATURE = 0x0001;
  109. constexpr U32 EVENT_FLAG_ADULT = 0x0002;
  110. #endif //LL_LLEVENTNOTIFIER_H