llfloaterexperiences.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * @file llfloaterexperiences.h
  3. * @brief LLFloaterExperiences class definition
  4. *
  5. * $LicenseInfo:firstyear=2012&license=viewergpl$
  6. *
  7. * Copyright (c) 2012, 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_LLFLOATEREXPERIENCES_H
  33. #define LL_LLFLOATEREXPERIENCES_H
  34. #include <map>
  35. #include "llcorehttputil.h"
  36. #include "llfloater.h"
  37. class LLButton;
  38. class LLScrollListCtrl;
  39. class LLTabContainer;
  40. class LLPanelExperiences : public LLPanel
  41. {
  42. public:
  43. LLPanelExperiences();
  44. static LLPanelExperiences* create(const std::string& name);
  45. bool postBuild() override;
  46. void setExperienceList(const LLSD& experiences);
  47. void addExperience(const LLUUID& id);
  48. void removeExperience(const LLUUID& id);
  49. void removeExperiences(const LLSD& ids);
  50. typedef void (*click_callback)(void*);
  51. void setButtonAction(const std::string& label, void (*cb)(void*),
  52. void* data = NULL);
  53. void enableButton(bool enable);
  54. #if 0 // not used
  55. std::string getSelectedExperienceName() const;
  56. LLUUID getSelectedExperienceId() const;
  57. #endif
  58. private:
  59. static void cacheCallback(LLHandle<LLPanelExperiences> handle,
  60. const LLSD& experience);
  61. static void onDoubleClickProfile(void* data);
  62. private:
  63. LLButton* mActionBtn;
  64. LLScrollListCtrl* mExperiencesList;
  65. bool mListEmpty;
  66. };
  67. class LLFloaterExperiences final : public LLFloater,
  68. public LLFloaterSingleton<LLFloaterExperiences>
  69. {
  70. friend class LLUISingleton<LLFloaterExperiences,
  71. VisibilityPolicy<LLFloater> >;
  72. friend class LLExperienceListResponder;
  73. protected:
  74. LOG_CLASS(LLFloaterExperiences);
  75. public:
  76. ~LLFloaterExperiences() override;
  77. bool postBuild() override;
  78. void onClose(bool app_quitting) override;
  79. void onOpen() override;
  80. static void show();
  81. protected:
  82. LLFloaterExperiences(const LLSD&);
  83. void refreshContents();
  84. LLPanelExperiences* addTab(const std::string& name, bool select);
  85. bool updatePermissions(const LLSD& permission);
  86. void checkPurchaseInfo(LLPanelExperiences* panel, const LLSD& content);
  87. void updateInfo(const char* experiences, const char* tab);
  88. void doSendPurchaseRequest();
  89. static void sendPurchaseRequest(void* data);
  90. static void onCloseBtn(void* data);
  91. typedef std::map<std::string, std::string> name_map_t;
  92. typedef boost::function<void(LLPanelExperiences*, const LLSD&)> Callback_t;
  93. void retrieveExperienceList(const std::string& url,
  94. const LLHandle<LLFloaterExperiences>& handle,
  95. const name_map_t& tab_map,
  96. const std::string& error_notify = "ErrorMessage",
  97. Callback_t cb = Callback_t());
  98. void requestNewExperience(const std::string& url,
  99. const LLHandle<LLFloaterExperiences>& handle,
  100. const name_map_t& tab_map,
  101. const std::string& error_notify,
  102. Callback_t cb);
  103. private:
  104. typedef boost::function<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t,
  105. const std::string, LLCore::HttpOptions::ptr_t,
  106. LLCore::HttpHeaders::ptr_t)> invokationFn_t;
  107. static void retrieveExperienceListCoro(std::string url,
  108. LLHandle<LLFloaterExperiences> handle,
  109. name_map_t tab_map,
  110. std::string error_notify,
  111. Callback_t cb,
  112. invokationFn_t invoker);
  113. private:
  114. LLTabContainer* mTabContainer;
  115. static S32 sLastTab;
  116. };
  117. #endif //LL_LLFLOATEREXPERIENCES_H