clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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.Region.Framework.Interfaces;
35 using OpenSim.Region.Framework.Scenes;
36 using OpenSim.Server.Base;
37 using OpenSim.Services.Interfaces;
38  
39 using OpenMetaverse;
40  
41 namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
42 {
43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalGridUserServicesConnector")]
44 public class LocalGridUserServicesConnector : ISharedRegionModule, IGridUserService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49  
50 private IGridUserService m_GridUserService;
51  
52 private ActivityDetector m_ActivityDetector;
53  
54 private bool m_Enabled = false;
55  
56 #region ISharedRegionModule
57  
58 public Type ReplaceableInterface
59 {
60 get { return null; }
61 }
62  
63 public string Name
64 {
65 get { return "LocalGridUserServicesConnector"; }
66 }
67  
68 public void Initialise(IConfigSource source)
69 {
70 IConfig moduleConfig = source.Configs["Modules"];
71 if (moduleConfig != null)
72 {
73 string name = moduleConfig.GetString("GridUserServices", "");
74 if (name == Name)
75 {
76 IConfig userConfig = source.Configs["GridUserService"];
77 if (userConfig == null)
78 {
79 m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from OpenSim.ini");
80 return;
81 }
82  
83 string serviceDll = userConfig.GetString("LocalServiceModule", String.Empty);
84  
85 if (serviceDll == String.Empty)
86 {
87 m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: No LocalServiceModule named in section GridUserService");
88 return;
89 }
90  
91 Object[] args = new Object[] { source };
92 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(serviceDll, args);
93  
94 if (m_GridUserService == null)
95 {
96 m_log.ErrorFormat(
97 "[LOCAL GRID USER SERVICE CONNECTOR]: Cannot load user account service specified as {0}", serviceDll);
98 return;
99 }
100  
101 m_ActivityDetector = new ActivityDetector(this);
102  
103 m_Enabled = true;
104  
105 m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local grid user connector enabled");
106 }
107 }
108 }
109  
110 public void PostInitialise()
111 {
112 if (!m_Enabled)
113 return;
114 }
115  
116 public void Close()
117 {
118 if (!m_Enabled)
119 return;
120 }
121  
122 public void AddRegion(Scene scene)
123 {
124 if (!m_Enabled)
125 return;
126  
127 scene.RegisterModuleInterface<IGridUserService>(m_GridUserService);
128 m_ActivityDetector.AddRegion(scene);
129 }
130  
131 public void RemoveRegion(Scene scene)
132 {
133 if (!m_Enabled)
134 return;
135  
136 scene.UnregisterModuleInterface<IGridUserService>(this);
137 m_ActivityDetector.RemoveRegion(scene);
138 }
139  
140 public void RegionLoaded(Scene scene)
141 {
142 if (!m_Enabled)
143 return;
144  
145 m_log.InfoFormat("[LOCAL GRID USER SERVICE CONNECTOR]: Enabled local grid user for region {0}", scene.RegionInfo.RegionName);
146 }
147  
148 #endregion
149  
150 #region IGridUserService
151  
152 public GridUserInfo LoggedIn(string userID)
153 {
154 return m_GridUserService.LoggedIn(userID);
155 }
156  
157 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
158 {
159 return m_GridUserService.LoggedOut(userID, sessionID, regionID, lastPosition, lastLookAt);
160 }
161  
162 public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt)
163 {
164 return m_GridUserService.SetHome(userID, homeID, homePosition, homeLookAt);
165 }
166  
167 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
168 {
169 return m_GridUserService.SetLastPosition(userID, sessionID, regionID, lastPosition, lastLookAt);
170 }
171  
172 public GridUserInfo GetGridUserInfo(string userID)
173 {
174 return m_GridUserService.GetGridUserInfo(userID);
175 }
176 public GridUserInfo[] GetGridUserInfo(string[] userID)
177 {
178 return m_GridUserService.GetGridUserInfo(userID);
179 }
180  
181 #endregion
182  
183 }
184 }