opensim – 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 using System;
28 using System.Collections;
29 using System.Collections.Generic;
30 using System.Globalization;
31 using System.Reflection;
32  
33 using OpenMetaverse;
34 using log4net;
35 using Nini.Config;
36 using Mono.Addins;
37  
38 using OpenSim.Framework;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Services.Interfaces;
42  
43 namespace OpenSim.Region.CoreModules.Avatar.Profile
44 {
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BasicProfileModule")]
46 public class BasicProfileModule : IProfileModule, ISharedRegionModule
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49  
50 //
51 // Module vars
52 //
53 private List<Scene> m_Scenes = new List<Scene>();
54 private bool m_Enabled = false;
55  
56 #region ISharedRegionModule
57  
58 public void Initialise(IConfigSource config)
59 {
60 if(config.Configs["UserProfiles"] != null)
61 return;
62  
63 m_log.DebugFormat("[PROFILE MODULE]: Basic Profile Module enabled");
64 m_Enabled = true;
65 }
66  
67 public void AddRegion(Scene scene)
68 {
69 if (!m_Enabled)
70 return;
71  
72 lock (m_Scenes)
73 {
74 if (!m_Scenes.Contains(scene))
75 {
76 m_Scenes.Add(scene);
77 // Hook up events
78 scene.EventManager.OnNewClient += OnNewClient;
79 scene.RegisterModuleInterface<IProfileModule>(this);
80 }
81 }
82 }
83  
84 public void RegionLoaded(Scene scene)
85 {
86 if (!m_Enabled)
87 return;
88 }
89  
90 public void RemoveRegion(Scene scene)
91 {
92 if (!m_Enabled)
93 return;
94  
95 lock (m_Scenes)
96 {
97 m_Scenes.Remove(scene);
98 }
99 }
100  
101 public void PostInitialise()
102 {
103 }
104  
105 public void Close()
106 {
107 }
108  
109 public string Name
110 {
111 get { return "BasicProfileModule"; }
112 }
113  
114 public Type ReplaceableInterface
115 {
116 get { return typeof(IProfileModule); }
117 }
118  
119 #endregion
120  
121 /// New Client Event Handler
122 private void OnNewClient(IClientAPI client)
123 {
124 //Profile
125 client.OnRequestAvatarProperties += RequestAvatarProperties;
126 }
127  
128 public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
129 {
130 IScene s = remoteClient.Scene;
131 if (!(s is Scene))
132 return;
133  
134 // Scene scene = (Scene)s;
135  
136 string profileUrl = String.Empty;
137 string aboutText = String.Empty;
138 string firstLifeAboutText = String.Empty;
139 UUID image = UUID.Zero;
140 UUID firstLifeImage = UUID.Zero;
141 UUID partner = UUID.Zero;
142 uint wantMask = 0;
143 string wantText = String.Empty;
144 uint skillsMask = 0;
145 string skillsText = String.Empty;
146 string languages = String.Empty;
147  
148 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, avatarID);
149  
150 string name = "Avatar";
151 int created = 0;
152 if (account != null)
153 {
154 name = account.FirstName + " " + account.LastName;
155 created = account.Created;
156 }
157 Byte[] charterMember = Utils.StringToBytes(name);
158  
159 profileUrl = "No profile data";
160 aboutText = string.Empty;
161 firstLifeAboutText = string.Empty;
162 image = UUID.Zero;
163 firstLifeImage = UUID.Zero;
164 partner = UUID.Zero;
165  
166 remoteClient.SendAvatarProperties(avatarID, aboutText,
167 Util.ToDateTime(created).ToString(
168 "M/d/yyyy", CultureInfo.InvariantCulture),
169 charterMember, firstLifeAboutText,
170 (uint)(0 & 0xff),
171 firstLifeImage, image, profileUrl, partner);
172  
173 //Viewer expects interest data when it asks for properties.
174 remoteClient.SendAvatarInterestsReply(avatarID, wantMask, wantText,
175 skillsMask, skillsText, languages);
176 }
177  
178 }
179 }