corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /* |
2 | * Copyright (c) 2006-2014, openmetaverse.org |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * - Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions are met: |
||
7 | * |
||
8 | * - Redistributions of source code must retain the above copyright notice, this |
||
9 | * list of conditions and the following disclaimer. |
||
10 | * - Neither the name of the openmetaverse.org nor the names |
||
11 | * of its contributors may be used to endorse or promote products derived from |
||
12 | * this software without specific prior written permission. |
||
13 | * |
||
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
24 | * POSSIBILITY OF SUCH DAMAGE. |
||
25 | */ |
||
26 | |||
27 | using System; |
||
28 | using System.Collections.Generic; |
||
29 | using OpenMetaverse.StructuredData; |
||
30 | |||
31 | namespace OpenMetaverse |
||
32 | { |
||
33 | #region enums |
||
34 | /// <summary> |
||
35 | /// Permissions for control of object media |
||
36 | /// </summary> |
||
37 | [Flags] |
||
38 | public enum MediaPermission : byte |
||
39 | { |
||
40 | None = 0, |
||
41 | Owner = 1, |
||
42 | Group = 2, |
||
43 | Anyone = 4, |
||
44 | All = None | Owner | Group | Anyone |
||
45 | } |
||
46 | |||
47 | /// <summary> |
||
48 | /// Style of cotrols that shold be displayed to the user |
||
49 | /// </summary> |
||
50 | public enum MediaControls |
||
51 | { |
||
52 | Standard = 0, |
||
53 | Mini |
||
54 | } |
||
55 | #endregion enums |
||
56 | |||
57 | /// <summary> |
||
58 | /// Class representing media data for a single face |
||
59 | /// </summary> |
||
60 | public class MediaEntry |
||
61 | { |
||
62 | /// <summary>Is display of the alternative image enabled</summary> |
||
63 | public bool EnableAlterntiveImage; |
||
64 | |||
65 | /// <summary>Should media auto loop</summary> |
||
66 | public bool AutoLoop; |
||
67 | |||
68 | /// <summary>Shoule media be auto played</summary> |
||
69 | public bool AutoPlay; |
||
70 | |||
71 | /// <summary>Auto scale media to prim face</summary> |
||
72 | public bool AutoScale; |
||
73 | |||
74 | /// <summary>Should viewer automatically zoom in on the face when clicked</summary> |
||
75 | public bool AutoZoom; |
||
76 | |||
77 | /// <summary>Should viewer interpret first click as interaction with the media |
||
78 | /// or when false should the first click be treated as zoom in commadn</summary> |
||
79 | public bool InteractOnFirstClick; |
||
80 | |||
81 | /// <summary>Style of controls viewer should display when |
||
82 | /// viewer media on this face</summary> |
||
83 | public MediaControls Controls; |
||
84 | |||
85 | /// <summary>Starting URL for the media</summary> |
||
86 | public string HomeURL; |
||
87 | |||
88 | /// <summary>Currently navigated URL</summary> |
||
89 | public string CurrentURL; |
||
90 | |||
91 | /// <summary>Media height in pixes</summary> |
||
92 | public int Height; |
||
93 | |||
94 | /// <summary>Media width in pixels</summary> |
||
95 | public int Width; |
||
96 | |||
97 | /// <summary>Who can controls the media</summary> |
||
98 | public MediaPermission ControlPermissions; |
||
99 | |||
100 | /// <summary>Who can interact with the media</summary> |
||
101 | public MediaPermission InteractPermissions; |
||
102 | |||
103 | /// <summary>Is URL whitelist enabled</summary> |
||
104 | public bool EnableWhiteList; |
||
105 | |||
106 | /// <summary>Array of URLs that are whitelisted</summary> |
||
107 | public string[] WhiteList; |
||
108 | |||
109 | /// <summary> |
||
110 | /// Serialize to OSD |
||
111 | /// </summary> |
||
112 | /// <returns>OSDMap with the serialized data</returns> |
||
113 | public OSDMap GetOSD() |
||
114 | { |
||
115 | OSDMap map = new OSDMap(); |
||
116 | |||
117 | map["alt_image_enable"] = OSD.FromBoolean(EnableAlterntiveImage); |
||
118 | map["auto_loop"] = OSD.FromBoolean(AutoLoop); |
||
119 | map["auto_play"] = OSD.FromBoolean(AutoPlay); |
||
120 | map["auto_scale"] = OSD.FromBoolean(AutoScale); |
||
121 | map["auto_zoom"] = OSD.FromBoolean(AutoZoom); |
||
122 | map["controls"] = OSD.FromInteger((int)Controls); |
||
123 | map["current_url"] = OSD.FromString(CurrentURL); |
||
124 | map["first_click_interact"] = OSD.FromBoolean(InteractOnFirstClick); |
||
125 | map["height_pixels"] = OSD.FromInteger(Height); |
||
126 | map["home_url"] = OSD.FromString(HomeURL); |
||
127 | map["perms_control"] = OSD.FromInteger((int)ControlPermissions); |
||
128 | map["perms_interact"] = OSD.FromInteger((int)InteractPermissions); |
||
129 | |||
130 | List<OSD> wl = new List<OSD>(); |
||
131 | if (WhiteList != null && WhiteList.Length > 0) |
||
132 | { |
||
133 | for (int i = 0; i < WhiteList.Length; i++) |
||
134 | wl.Add(OSD.FromString(WhiteList[i])); |
||
135 | } |
||
136 | |||
137 | map["whitelist"] = new OSDArray(wl); |
||
138 | map["whitelist_enable"] = OSD.FromBoolean(EnableWhiteList); |
||
139 | map["width_pixels"] = OSD.FromInteger(Width); |
||
140 | |||
141 | return map; |
||
142 | } |
||
143 | |||
144 | /// <summary> |
||
145 | /// Deserialize from OSD data |
||
146 | /// </summary> |
||
147 | /// <param name="osd">Serialized OSD data</param> |
||
148 | /// <returns>Deserialized object</returns> |
||
149 | public static MediaEntry FromOSD(OSD osd) |
||
150 | { |
||
151 | MediaEntry m = new MediaEntry(); |
||
152 | OSDMap map = (OSDMap)osd; |
||
153 | |||
154 | m.EnableAlterntiveImage = map["alt_image_enable"].AsBoolean(); |
||
155 | m.AutoLoop = map["auto_loop"].AsBoolean(); |
||
156 | m.AutoPlay = map["auto_play"].AsBoolean(); |
||
157 | m.AutoScale = map["auto_scale"].AsBoolean(); |
||
158 | m.AutoZoom = map["auto_zoom"].AsBoolean(); |
||
159 | m.Controls = (MediaControls)map["controls"].AsInteger(); |
||
160 | m.CurrentURL = map["current_url"].AsString(); |
||
161 | m.InteractOnFirstClick = map["first_click_interact"].AsBoolean(); |
||
162 | m.Height = map["height_pixels"].AsInteger(); |
||
163 | m.HomeURL = map["home_url"].AsString(); |
||
164 | m.ControlPermissions = (MediaPermission)map["perms_control"].AsInteger(); |
||
165 | m.InteractPermissions = (MediaPermission)map["perms_interact"].AsInteger(); |
||
166 | |||
167 | if (map["whitelist"].Type == OSDType.Array) |
||
168 | { |
||
169 | OSDArray wl = (OSDArray)map["whitelist"]; |
||
170 | if (wl.Count > 0) |
||
171 | { |
||
172 | m.WhiteList = new string[wl.Count]; |
||
173 | for (int i = 0; i < wl.Count; i++) |
||
174 | { |
||
175 | m.WhiteList[i] = wl[i].AsString(); |
||
176 | } |
||
177 | } |
||
178 | } |
||
179 | |||
180 | m.EnableWhiteList = map["whitelist_enable"].AsBoolean(); |
||
181 | m.Width = map["width_pixels"].AsInteger(); |
||
182 | |||
183 | return m; |
||
184 | } |
||
185 | } |
||
186 | |||
187 | public partial class Primitive |
||
188 | { |
||
189 | /// <summary> |
||
190 | /// Current version of the media data for the prim |
||
191 | /// </summary> |
||
192 | public string MediaVersion = string.Empty; |
||
193 | |||
194 | /// <summary> |
||
195 | /// Array of media entries indexed by face number |
||
196 | /// </summary> |
||
197 | public MediaEntry[] FaceMedia; |
||
198 | } |
||
199 | } |