opensim-development – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 eva 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  
28 using System;
29 using System.Collections.Generic;
30 using System.Reflection;
31 using log4net;
32 using Mono.Addins;
33 using Nini.Config;
34 using OpenSim.Framework;
35 using OpenSim.Region.Framework.Interfaces;
36 using OpenSim.Region.Framework.Scenes;
37 using OpenSim.Server.Base;
38 using OpenSim.Services.Interfaces;
39  
40 using OpenMetaverse;
41  
42 namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar
43 {
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalAvatarServicesConnector")]
45 public class LocalAvatarServicesConnector : ISharedRegionModule, IAvatarService
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50  
51 private IAvatarService m_AvatarService;
52  
53 private bool m_Enabled = false;
54  
55 #region ISharedRegionModule
56  
57 public Type ReplaceableInterface
58 {
59 get { return null; }
60 }
61  
62 public string Name
63 {
64 get { return "LocalAvatarServicesConnector"; }
65 }
66  
67 public void Initialise(IConfigSource source)
68 {
69 IConfig moduleConfig = source.Configs["Modules"];
70 if (moduleConfig != null)
71 {
72 string name = moduleConfig.GetString("AvatarServices", "");
73 if (name == Name)
74 {
75 IConfig userConfig = source.Configs["AvatarService"];
76 if (userConfig == null)
77 {
78 m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpenSim.ini");
79 return;
80 }
81  
82 string serviceDll = userConfig.GetString("LocalServiceModule",
83 String.Empty);
84  
85 if (serviceDll == String.Empty)
86 {
87 m_log.Error("[AVATAR CONNECTOR]: No LocalServiceModule named in section AvatarService");
88 return;
89 }
90  
91 Object[] args = new Object[] { source };
92 m_AvatarService =
93 ServerUtils.LoadPlugin<IAvatarService>(serviceDll,
94 args);
95  
96 if (m_AvatarService == null)
97 {
98 m_log.Error("[AVATAR CONNECTOR]: Can't load user account service");
99 return;
100 }
101 m_Enabled = true;
102 m_log.Info("[AVATAR CONNECTOR]: Local avatar connector enabled");
103 }
104 }
105 }
106  
107 public void PostInitialise()
108 {
109 if (!m_Enabled)
110 return;
111 }
112  
113 public void Close()
114 {
115 if (!m_Enabled)
116 return;
117 }
118  
119 public void AddRegion(Scene scene)
120 {
121 if (!m_Enabled)
122 return;
123  
124 scene.RegisterModuleInterface<IAvatarService>(this);
125 }
126  
127 public void RemoveRegion(Scene scene)
128 {
129 if (!m_Enabled)
130 return;
131 }
132  
133 public void RegionLoaded(Scene scene)
134 {
135 if (!m_Enabled)
136 return;
137 }
138  
139 #endregion
140  
141 #region IAvatarService
142  
143 public AvatarAppearance GetAppearance(UUID userID)
144 {
145 return m_AvatarService.GetAppearance(userID);
146 }
147  
148 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
149 {
150 return m_AvatarService.SetAppearance(userID,appearance);
151 }
152  
153 public AvatarData GetAvatar(UUID userID)
154 {
155 return m_AvatarService.GetAvatar(userID);
156 }
157  
158 public bool SetAvatar(UUID userID, AvatarData avatar)
159 {
160 return m_AvatarService.SetAvatar(userID, avatar);
161 }
162  
163 public bool ResetAvatar(UUID userID)
164 {
165 return m_AvatarService.ResetAvatar(userID);
166 }
167  
168 public bool SetItems(UUID userID, string[] names, string[] values)
169 {
170 return m_AvatarService.SetItems(userID, names, values);
171 }
172  
173 public bool RemoveItems(UUID userID, string[] names)
174 {
175 return m_AvatarService.RemoveItems(userID, names);
176 }
177  
178 #endregion
179  
180 }
181 }