clockwerk-opensim-stable – Blame information for rev 1
?pathlinks?
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; |
||
30 | using System.Collections.Specialized; |
||
31 | using System.Drawing; |
||
32 | using System.Drawing.Imaging; |
||
33 | using System.Reflection; |
||
34 | using System.IO; |
||
35 | using System.Web; |
||
36 | using log4net; |
||
37 | using Nini.Config; |
||
38 | using Mono.Addins; |
||
39 | using OpenMetaverse; |
||
40 | using OpenMetaverse.StructuredData; |
||
41 | using OpenSim.Framework; |
||
42 | using OpenSim.Framework.Servers; |
||
43 | using OpenSim.Framework.Servers.HttpServer; |
||
44 | using OpenSim.Region.Framework.Interfaces; |
||
45 | using OpenSim.Region.Framework.Scenes; |
||
46 | using OpenSim.Services.Interfaces; |
||
47 | using Caps = OpenSim.Framework.Capabilities.Caps; |
||
48 | using OpenSim.Capabilities.Handlers; |
||
49 | |||
50 | namespace OpenSim.Region.ClientStack.Linden |
||
51 | { |
||
52 | |||
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AvatarPickerSearchModule")] |
||
54 | public class AvatarPickerSearchModule : INonSharedRegionModule |
||
55 | { |
||
56 | private static readonly ILog m_log = |
||
57 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
58 | |||
59 | private Scene m_scene; |
||
60 | private IPeople m_People; |
||
61 | private bool m_Enabled = false; |
||
62 | |||
63 | private string m_URL; |
||
64 | |||
65 | #region ISharedRegionModule Members |
||
66 | |||
67 | public void Initialise(IConfigSource source) |
||
68 | { |
||
69 | IConfig config = source.Configs["ClientStack.LindenCaps"]; |
||
70 | if (config == null) |
||
71 | return; |
||
72 | |||
73 | m_URL = config.GetString("Cap_AvatarPickerSearch", string.Empty); |
||
74 | // Cap doesn't exist |
||
75 | if (m_URL != string.Empty) |
||
76 | m_Enabled = true; |
||
77 | } |
||
78 | |||
79 | public void AddRegion(Scene s) |
||
80 | { |
||
81 | if (!m_Enabled) |
||
82 | return; |
||
83 | |||
84 | m_scene = s; |
||
85 | } |
||
86 | |||
87 | public void RemoveRegion(Scene s) |
||
88 | { |
||
89 | if (!m_Enabled) |
||
90 | return; |
||
91 | |||
92 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; |
||
93 | m_scene = null; |
||
94 | } |
||
95 | |||
96 | public void RegionLoaded(Scene s) |
||
97 | { |
||
98 | if (!m_Enabled) |
||
99 | return; |
||
100 | |||
101 | m_People = m_scene.RequestModuleInterface<IPeople>(); |
||
102 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
||
103 | } |
||
104 | |||
105 | public void PostInitialise() |
||
106 | { |
||
107 | } |
||
108 | |||
109 | public void Close() { } |
||
110 | |||
111 | public string Name { get { return "AvatarPickerSearchModule"; } } |
||
112 | |||
113 | public Type ReplaceableInterface |
||
114 | { |
||
115 | get { return null; } |
||
116 | } |
||
117 | |||
118 | #endregion |
||
119 | |||
120 | public void RegisterCaps(UUID agentID, Caps caps) |
||
121 | { |
||
122 | UUID capID = UUID.Random(); |
||
123 | |||
124 | if (m_URL == "localhost") |
||
125 | { |
||
126 | // m_log.DebugFormat("[AVATAR PICKER SEARCH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); |
||
127 | caps.RegisterHandler( |
||
128 | "AvatarPickerSearch", |
||
129 | new AvatarPickerSearchHandler("/CAPS/" + capID + "/", m_People, "AvatarPickerSearch", "Search for avatars by name")); |
||
130 | } |
||
131 | else |
||
132 | { |
||
133 | // m_log.DebugFormat("[AVATAR PICKER SEARCH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); |
||
134 | caps.RegisterHandler("AvatarPickerSearch", m_URL); |
||
135 | } |
||
136 | } |
||
137 | |||
138 | } |
||
139 | } |