aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llprimitive/llmediaentry.h
diff options
context:
space:
mode:
authorArmin Weatherwax2010-06-14 12:27:35 +0200
committerArmin Weatherwax2010-09-23 15:40:23 +0200
commit791d4c2de7c0219392aeb625cf7940290dc1e79a (patch)
tree4050377f59ec8532a5d3ee5cc1202b38a1878c7a /linden/indra/llprimitive/llmediaentry.h
parentport SG2.0 Mediaplugs (webkit supports flash now) (diff)
downloadmeta-impy-791d4c2de7c0219392aeb625cf7940290dc1e79a.zip
meta-impy-791d4c2de7c0219392aeb625cf7940290dc1e79a.tar.gz
meta-impy-791d4c2de7c0219392aeb625cf7940290dc1e79a.tar.bz2
meta-impy-791d4c2de7c0219392aeb625cf7940290dc1e79a.tar.xz
port llprimitive from SG2.0
Diffstat (limited to '')
-rwxr-xr-xlinden/indra/llprimitive/llmediaentry.h228
1 files changed, 228 insertions, 0 deletions
diff --git a/linden/indra/llprimitive/llmediaentry.h b/linden/indra/llprimitive/llmediaentry.h
new file mode 100755
index 0000000..ca52e6e
--- /dev/null
+++ b/linden/indra/llprimitive/llmediaentry.h
@@ -0,0 +1,228 @@
1/**
2 * @file llmediaentry.h
3 * @brief This is a single instance of media data related to the face of a prim
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2010, 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
33#ifndef LL_LLMEDIAENTRY_H
34#define LL_LLMEDIAENTRY_H
35
36#include "llsd.h"
37#include "llstring.h"
38
39// For return values of set*
40#include "lllslconstants.h"
41
42class LLMediaEntry
43{
44public:
45 enum MediaControls {
46 STANDARD = 0,
47 MINI
48 };
49
50 // Constructors
51 LLMediaEntry();
52 LLMediaEntry(const LLMediaEntry &rhs);
53
54 LLMediaEntry &operator=(const LLMediaEntry &rhs);
55 virtual ~LLMediaEntry();
56
57 bool operator==(const LLMediaEntry &rhs) const;
58 bool operator!=(const LLMediaEntry &rhs) const;
59
60 // Render as LLSD
61 LLSD asLLSD() const;
62 void asLLSD(LLSD& sd) const;
63 operator LLSD() const { return asLLSD(); }
64 // Returns false iff the given LLSD contains fields that violate any bounds
65 // limits.
66 static bool checkLLSD(const LLSD& sd);
67 // This doesn't merge, it overwrites the data, so will use
68 // LLSD defaults if need be. Note: does not check limits!
69 // Use checkLLSD() above first to ensure the LLSD is valid.
70 void fromLLSD(const LLSD& sd);
71 // This merges data from the incoming LLSD into our fields.
72 // Note that it also does NOT check limits! Use checkLLSD() above first.
73 void mergeFromLLSD(const LLSD& sd);
74
75 // "general" fields
76 bool getAltImageEnable() const { return mAltImageEnable; }
77 MediaControls getControls() const { return mControls; }
78 std::string getCurrentURL() const { return mCurrentURL; }
79 std::string getHomeURL() const { return mHomeURL; }
80 bool getAutoLoop() const { return mAutoLoop; }
81 bool getAutoPlay() const { return mAutoPlay; }
82 bool getAutoScale() const { return mAutoScale; }
83 bool getAutoZoom() const { return mAutoZoom; }
84 bool getFirstClickInteract() const { return mFirstClickInteract; }
85 U16 getWidthPixels() const { return mWidthPixels; }
86 U16 getHeightPixels() const { return mHeightPixels; }
87
88 // "security" fields
89 bool getWhiteListEnable() const { return mWhiteListEnable; }
90 const std::vector<std::string> &getWhiteList() const { return mWhiteList; }
91
92 // "permissions" fields
93 U8 getPermsInteract() const { return mPermsInteract; }
94 U8 getPermsControl() const { return mPermsControl; }
95
96 // Setters. Those that return a U32 return a status error code
97 // See lllslconstants.h
98
99 // "general" fields
100 U32 setAltImageEnable(bool alt_image_enable) { mAltImageEnable = alt_image_enable; return LSL_STATUS_OK; }
101 U32 setControls(MediaControls controls);
102 U32 setCurrentURL(const std::string& current_url);
103 U32 setHomeURL(const std::string& home_url);
104 U32 setAutoLoop(bool auto_loop) { mAutoLoop = auto_loop; return LSL_STATUS_OK; }
105 U32 setAutoPlay(bool auto_play) { mAutoPlay = auto_play; return LSL_STATUS_OK; }
106 U32 setAutoScale(bool auto_scale) { mAutoScale = auto_scale; return LSL_STATUS_OK; }
107 U32 setAutoZoom(bool auto_zoom) { mAutoZoom = auto_zoom; return LSL_STATUS_OK; }
108 U32 setFirstClickInteract(bool first_click) { mFirstClickInteract = first_click; return LSL_STATUS_OK; }
109 U32 setWidthPixels(U16 width);
110 U32 setHeightPixels(U16 height);
111
112 // "security" fields
113 U32 setWhiteListEnable( bool whitelist_enable ) { mWhiteListEnable = whitelist_enable; return LSL_STATUS_OK; }
114 U32 setWhiteList( const std::vector<std::string> &whitelist );
115 U32 setWhiteList( const LLSD &whitelist ); // takes an LLSD array
116
117 // "permissions" fields
118 U32 setPermsInteract( U8 val );
119 U32 setPermsControl( U8 val );
120
121 const LLUUID& getMediaID() const;
122
123 // Helper function to check a candidate URL against the whitelist
124 // Returns true iff candidate URL passes (or if there is no whitelist), false otherwise
125 bool checkCandidateUrl(const std::string& url) const;
126
127public:
128 // Static function to check a URL against a whitelist
129 // Returns true iff url passes the given whitelist
130 static bool checkUrlAgainstWhitelist(const std::string &url,
131 const std::vector<std::string> &whitelist);
132
133public:
134 // LLSD key defines
135 // "general" fields
136 static const char* ALT_IMAGE_ENABLE_KEY;
137 static const char* CONTROLS_KEY;
138 static const char* CURRENT_URL_KEY;
139 static const char* HOME_URL_KEY;
140 static const char* AUTO_LOOP_KEY;
141 static const char* AUTO_PLAY_KEY;
142 static const char* AUTO_SCALE_KEY;
143 static const char* AUTO_ZOOM_KEY;
144 static const char* FIRST_CLICK_INTERACT_KEY;
145 static const char* WIDTH_PIXELS_KEY;
146 static const char* HEIGHT_PIXELS_KEY;
147
148 // "security" fields
149 static const char* WHITELIST_ENABLE_KEY;
150 static const char* WHITELIST_KEY;
151
152 // "permissions" fields
153 static const char* PERMS_INTERACT_KEY;
154 static const char* PERMS_CONTROL_KEY;
155
156 // Field enumerations & constants
157
158 // *NOTE: DO NOT change the order of these, and do not insert values
159 // in the middle!
160 // Add values to the end, and make sure to change PARAM_MAX_ID!
161 enum Fields {
162 ALT_IMAGE_ENABLE_ID = 0,
163 CONTROLS_ID = 1,
164 CURRENT_URL_ID = 2,
165 HOME_URL_ID = 3,
166 AUTO_LOOP_ID = 4,
167 AUTO_PLAY_ID = 5,
168 AUTO_SCALE_ID = 6,
169 AUTO_ZOOM_ID = 7,
170 FIRST_CLICK_INTERACT_ID = 8,
171 WIDTH_PIXELS_ID = 9,
172 HEIGHT_PIXELS_ID = 10,
173 WHITELIST_ENABLE_ID = 11,
174 WHITELIST_ID = 12,
175 PERMS_INTERACT_ID = 13,
176 PERMS_CONTROL_ID = 14,
177 PARAM_MAX_ID = PERMS_CONTROL_ID
178 };
179
180 // "permissions" values
181 // (e.g. (PERM_OWNER | PERM_GROUP) sets permissions on for OWNER and GROUP
182 static const U8 PERM_NONE = 0x0;
183 static const U8 PERM_OWNER = 0x1;
184 static const U8 PERM_GROUP = 0x2;
185 static const U8 PERM_ANYONE = 0x4;
186 static const U8 PERM_ALL = PERM_OWNER|PERM_GROUP|PERM_ANYONE;
187 static const U8 PERM_MASK = PERM_OWNER|PERM_GROUP|PERM_ANYONE;
188
189 // Limits (in bytes)
190 static const U32 MAX_URL_LENGTH = 1024;
191 static const U32 MAX_WHITELIST_SIZE = 1024;
192 static const U32 MAX_WHITELIST_COUNT = 64;
193 static const U16 MAX_WIDTH_PIXELS = 2048;
194 static const U16 MAX_HEIGHT_PIXELS = 2048;
195
196private:
197
198 U32 setStringFieldWithLimit( std::string &field, const std::string &value, U32 limit );
199 U32 setCurrentURLInternal( const std::string &url, bool check_whitelist);
200 bool fromLLSDInternal(const LLSD &sd, bool overwrite);
201
202private:
203 // "general" fields
204 bool mAltImageEnable;
205 MediaControls mControls;
206 std::string mCurrentURL;
207 std::string mHomeURL;
208 bool mAutoLoop;
209 bool mAutoPlay;
210 bool mAutoScale;
211 bool mAutoZoom;
212 bool mFirstClickInteract;
213 U16 mWidthPixels;
214 U16 mHeightPixels;
215
216 // "security" fields
217 bool mWhiteListEnable;
218 std::vector<std::string> mWhiteList;
219
220 // "permissions" fields
221 U8 mPermsInteract;
222 U8 mPermsControl;
223
224 mutable LLUUID *mMediaIDp; // temporary id assigned to media on the viewer
225};
226
227#endif
228