llmimetypes.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * @file llmimetypes.h
  3. * @brief Translates a MIME type like "video/quicktime" into a
  4. * localizable user-friendly string like "QuickTime Movie"
  5. *
  6. * $LicenseInfo:firstyear=2007&license=viewergpl$
  7. *
  8. * Copyright (c) 2007-2009, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #ifndef LLMIMETYPES_H
  34. #define LLMIMETYPES_H
  35. #include <map>
  36. #include <string>
  37. #include "llerror.h"
  38. class LLMIMETypes
  39. {
  40. protected:
  41. LOG_CLASS(LLMIMETypes);
  42. public:
  43. // Loads the MIME string definition XML file from the application settings
  44. // directory
  45. static bool parseMIMETypes(const std::string& xml_file_path);
  46. // Returns "QuickTime Movie" from "video/quicktime"
  47. static std::string translate(const std::string& mime_type);
  48. // Type of control widgets for this MIME type
  49. // Returns "movie" from "video/quicktime"
  50. static std::string widgetType(const std::string& mime_type);
  51. // Type of Impl to use for decoding media.
  52. static std::string implType(const std::string& mime_type);
  53. // Icon from control widget type for this MIME type
  54. static std::string findIcon(const std::string& mime_type);
  55. // Tool tip from control widget type for this MIME type
  56. static std::string findToolTip(const std::string& mime_type);
  57. // Play button tool tip from control widget type for this MIME type
  58. static std::string findPlayTip(const std::string& mime_type);
  59. // Canonical mime type associated with this widget set
  60. static std::string findDefaultMimeType(const std::string& widget_type);
  61. static const std::string& getDefaultMimeType();
  62. // Accessor for flag to enable/disable media size edit fields
  63. static bool findAllowResize(const std::string& mime_type);
  64. // Accessor for flag to enable/disable media looping checkbox
  65. static bool findAllowLooping(const std::string& mime_type);
  66. // Determines if the specific mime type is handled by the media system
  67. static bool isTypeHandled(const std::string& mime_type);
  68. // Re-loads the MIME types file from the file path last passed into
  69. // parseMIMETypes
  70. static void reload(void*);
  71. public:
  72. struct LLMIMEInfo
  73. {
  74. std::string mLabel; // friendly label like "QuickTime Movie"
  75. std::string mWidgetType; // "web" means use web media UI widgets
  76. std::string mImpl; // which impl to use with this mime type
  77. };
  78. typedef std::map<std::string, LLMIMEInfo> mime_info_map_t;
  79. struct LLMIMEWidgetSet
  80. {
  81. std::string mLabel; // friendly label like "QuickTime Movie"
  82. std::string mIcon; // Name of icon asset to display in toolbar
  83. // Mime type string to use in absence of a specific one
  84. std::string mDefaultMimeType;
  85. std::string mToolTip; // custom tool tip for this mime type
  86. std::string mPlayTip; // custom tool tip to display for Play button
  87. bool mAllowResize; // enable/disable media size edit fields
  88. bool mAllowLooping; // enable/disable media looping checkbox
  89. };
  90. typedef std::map<std::string, LLMIMEWidgetSet> mime_widget_set_map_t;
  91. // Public so users can iterate over it
  92. static mime_info_map_t sMap;
  93. static mime_widget_set_map_t sWidgetMap;
  94. };
  95. #endif