aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Interfaces/IAvatarService.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs204
1 files changed, 204 insertions, 0 deletions
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
new file mode 100644
index 0000000..ea08ea5
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -0,0 +1,204 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
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 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31
32using OpenSim.Framework;
33
34using OpenMetaverse;
35
36namespace OpenSim.Services.Interfaces
37{
38 public interface IAvatarService
39 {
40 /// <summary>
41 /// Called by the login service
42 /// </summary>
43 /// <param name="userID"></param>
44 /// <returns></returns>
45 AvatarData GetAvatar(UUID userID);
46
47 /// <summary>
48 /// Called by everyone who can change the avatar data (so, regions)
49 /// </summary>
50 /// <param name="userID"></param>
51 /// <param name="avatar"></param>
52 /// <returns></returns>
53 bool SetAvatar(UUID userID, AvatarData avatar);
54
55 /// <summary>
56 /// Not sure if it's needed
57 /// </summary>
58 /// <param name="userID"></param>
59 /// <returns></returns>
60 bool ResetAvatar(UUID userID);
61
62 /// <summary>
63 /// These methods raison d'etre:
64 /// No need to send the entire avatar data (SetAvatar) for changing attachments
65 /// </summary>
66 /// <param name="userID"></param>
67 /// <param name="attach"></param>
68 /// <returns></returns>
69 bool SetItems(UUID userID, string[] names, string[] values);
70 bool RemoveItems(UUID userID, string[] names);
71 }
72
73 /// <summary>
74 /// Each region/client that uses avatars will have a data structure
75 /// of this type representing the avatars.
76 /// </summary>
77 public class AvatarData
78 {
79 // This pretty much determines which name/value pairs will be
80 // present below. The name/value pair describe a part of
81 // the avatar. For SL avatars, these would be "shape", "texture1",
82 // etc. For other avatars, they might be "mesh", "skin", etc.
83 // The value portion is a URL that is expected to resolve to an
84 // asset of the type required by the handler for that field.
85 // It is required that regions can access these URLs. Allowing
86 // direct access by a viewer is not required, and, if provided,
87 // may be read-only. A "naked" UUID can be used to refer to an
88 // asset int he current region's asset service, which is not
89 // portable, but allows legacy appearance to continue to
90 // function. Closed, LL-based grids will never need URLs here.
91
92 public int AvatarType;
93 public Dictionary<string,string> Data;
94
95 public AvatarData()
96 {
97 }
98
99 public AvatarData(Dictionary<string, object> kvp)
100 {
101 Data = new Dictionary<string, string>();
102
103 if (kvp.ContainsKey("AvatarType"))
104 Int32.TryParse(kvp["AvatarType"].ToString(), out AvatarType);
105
106 foreach (KeyValuePair<string, object> _kvp in kvp)
107 {
108 if (_kvp.Value != null)
109 Data[_kvp.Key] = _kvp.Value.ToString();
110 }
111 }
112
113 /// <summary>
114 /// </summary>
115 /// <returns></returns>
116 public Dictionary<string, object> ToKeyValuePairs()
117 {
118 Dictionary<string, object> result = new Dictionary<string, object>();
119
120 result["AvatarType"] = AvatarType.ToString();
121 foreach (KeyValuePair<string, string> _kvp in Data)
122 {
123 if (_kvp.Value != null)
124 result[_kvp.Key] = _kvp.Value;
125 }
126 return null;
127 }
128
129 public AvatarData(AvatarAppearance appearance)
130 {
131 AvatarType = 1; // SL avatars
132 Data = new Dictionary<string, string>();
133
134 // Wearables
135 Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
136 Data["BodyItem"] = appearance.BodyItem.ToString();
137 Data["EyesItem"] = appearance.EyesItem.ToString();
138 Data["GlovesItem"] = appearance.GlovesItem.ToString();
139 Data["HairItem"] = appearance.HairItem.ToString();
140 //Data["HipOffset"] = appearance.HipOffset.ToString();
141 Data["JacketItem"] = appearance.JacketItem.ToString();
142 Data["Owner"] = appearance.Owner.ToString();
143 Data["PantsItem"] = appearance.PantsItem.ToString();
144 Data["Serial"] = appearance.Serial.ToString();
145 Data["ShirtItem"] = appearance.ShirtItem.ToString();
146 Data["ShoesItem"] = appearance.ShoesItem.ToString();
147 Data["SkinItem"] = appearance.SkinItem.ToString();
148 Data["SkirtItem"] = appearance.SkirtItem.ToString();
149 Data["SocksItem"] = appearance.SocksItem.ToString();
150 Data["UnderPantsItem"] = appearance.UnderPantsItem.ToString();
151 Data["UnderShirtItem"] = appearance.UnderShirtItem.ToString();
152
153 // Attachments
154 Hashtable attachs = appearance.GetAttachments();
155 foreach (KeyValuePair<int, Hashtable> kvp in attachs)
156 {
157 Data["_ap_" + kvp.Key] = kvp.Value["item"].ToString();
158 }
159 }
160
161 public AvatarAppearance ToAvatarAppearance()
162 {
163 AvatarAppearance appearance = new AvatarAppearance();
164 // Wearables
165 appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
166 appearance.BodyItem = UUID.Parse(Data["BodyItem"]);
167 appearance.EyesItem = UUID.Parse(Data["EyesItem"]);
168 appearance.GlovesItem = UUID.Parse(Data["GlovesItem"]);
169 appearance.HairItem = UUID.Parse(Data["HairItem"]);
170 //appearance.HipOffset = float.Parse(Data["HipOffset"]);
171 appearance.JacketItem = UUID.Parse(Data["JacketItem"]);
172 appearance.Owner = UUID.Parse(Data["Owner"]);
173 appearance.PantsItem = UUID.Parse(Data["PantsItem"]);
174 appearance.Serial = Int32.Parse(Data["Serial"]);
175 appearance.ShirtItem = UUID.Parse(Data["ShirtItem"]);
176 appearance.ShoesItem = UUID.Parse(Data["ShoesItem"]);
177 appearance.SkinItem = UUID.Parse(Data["SkinItem"]);
178 appearance.SkirtItem = UUID.Parse(Data["SkirtItem"]);
179 appearance.SocksItem = UUID.Parse(Data["SocksItem"]);
180 appearance.UnderPantsItem = UUID.Parse(Data["UnderPantsItem"]);
181 appearance.UnderShirtItem = UUID.Parse(Data["UnderShirtItem"]);
182
183 // Attachments
184 Dictionary<string, string> attchs = new Dictionary<string, string>();
185 foreach (KeyValuePair<string, string> _kvp in Data)
186 if (_kvp.Key.StartsWith("_ap_"))
187 attchs[_kvp.Key] = _kvp.Value;
188 Hashtable aaAttachs = new Hashtable();
189 foreach (KeyValuePair<string, string> _kvp in attchs)
190 {
191 string pointStr = _kvp.Key.Substring(4);
192 int point = 0;
193 if (!Int32.TryParse(pointStr, out point))
194 continue;
195 Hashtable tmp = new Hashtable();
196 tmp["item"] = _kvp.Value;
197 tmp["asset"] = UUID.Zero.ToString();
198 aaAttachs[point] = tmp;
199 }
200
201 return appearance;
202 }
203 }
204}