aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs176
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs88
-rw-r--r--bin/OpenSim.ini.example4
3 files changed, 193 insertions, 75 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs
new file mode 100644
index 0000000..bf24030
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs
@@ -0,0 +1,176 @@
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 */
27using System;
28using System.Collections;
29using System.Collections.Generic;
30using System.Globalization;
31using System.Reflection;
32
33using OpenMetaverse;
34using log4net;
35using Nini.Config;
36using Mono.Addins;
37
38using OpenSim.Framework;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Services.Interfaces;
42
43namespace 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 m_log.DebugFormat("[PROFILE MODULE]: Basic Profile Module enabled");
61 m_Enabled = true;
62 }
63
64 public void AddRegion(Scene scene)
65 {
66 if (!m_Enabled)
67 return;
68
69 lock (m_Scenes)
70 {
71 if (!m_Scenes.Contains(scene))
72 {
73 m_Scenes.Add(scene);
74 // Hook up events
75 scene.EventManager.OnNewClient += OnNewClient;
76 scene.RegisterModuleInterface<IProfileModule>(this);
77 }
78 }
79 }
80
81 public void RegionLoaded(Scene scene)
82 {
83 if (!m_Enabled)
84 return;
85 }
86
87 public void RemoveRegion(Scene scene)
88 {
89 if (!m_Enabled)
90 return;
91
92 lock (m_Scenes)
93 {
94 m_Scenes.Remove(scene);
95 }
96 }
97
98 public void PostInitialise()
99 {
100 }
101
102 public void Close()
103 {
104 }
105
106 public string Name
107 {
108 get { return "BasicProfileModule"; }
109 }
110
111 public Type ReplaceableInterface
112 {
113 get { return typeof(IProfileModule); }
114 }
115
116 #endregion
117
118 /// New Client Event Handler
119 private void OnNewClient(IClientAPI client)
120 {
121 //Profile
122 client.OnRequestAvatarProperties += RequestAvatarProperties;
123 }
124
125 public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
126 {
127 IScene s = remoteClient.Scene;
128 if (!(s is Scene))
129 return;
130
131// Scene scene = (Scene)s;
132
133 string profileUrl = String.Empty;
134 string aboutText = String.Empty;
135 string firstLifeAboutText = String.Empty;
136 UUID image = UUID.Zero;
137 UUID firstLifeImage = UUID.Zero;
138 UUID partner = UUID.Zero;
139 uint wantMask = 0;
140 string wantText = String.Empty;
141 uint skillsMask = 0;
142 string skillsText = String.Empty;
143 string languages = String.Empty;
144
145 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, avatarID);
146
147 string name = "Avatar";
148 int created = 0;
149 if (account != null)
150 {
151 name = account.FirstName + " " + account.LastName;
152 created = account.Created;
153 }
154 Byte[] charterMember = Utils.StringToBytes(name);
155
156 profileUrl = "No profile data";
157 aboutText = string.Empty;
158 firstLifeAboutText = string.Empty;
159 image = UUID.Zero;
160 firstLifeImage = UUID.Zero;
161 partner = UUID.Zero;
162
163 remoteClient.SendAvatarProperties(avatarID, aboutText,
164 Util.ToDateTime(created).ToString(
165 "M/d/yyyy", CultureInfo.InvariantCulture),
166 charterMember, firstLifeAboutText,
167 (uint)(0 & 0xff),
168 firstLifeImage, image, profileUrl, partner);
169
170 //Viewer expects interest data when it asks for properties.
171 remoteClient.SendAvatarInterestsReply(avatarID, wantMask, wantText,
172 skillsMask, skillsText, languages);
173 }
174
175 }
176}
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index 563617d..5b228ee 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -124,8 +124,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
124 public void Initialise(IConfigSource source) 124 public void Initialise(IConfigSource source)
125 { 125 {
126 Config = source; 126 Config = source;
127 ReplaceableInterface = typeof(IProfileModule);
127 128
128 IConfig profileConfig = Config.Configs["Profile"]; 129 IConfig profileConfig = Config.Configs["UserProfiles"];
129 130
130 if (profileConfig == null) 131 if (profileConfig == null)
131 { 132 {
@@ -135,18 +136,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
135 136
136 // If we find ProfileURL then we configure for FULL support 137 // If we find ProfileURL then we configure for FULL support
137 // else we setup for BASIC support 138 // else we setup for BASIC support
138 ProfileServerUri = profileConfig.GetString("ProfileURL", ""); 139 ProfileServerUri = profileConfig.GetString("ProfileServiceURL", "");
139 if (ProfileServerUri == "") 140 if (ProfileServerUri == "")
140 { 141 {
141 m_log.Info("[PROFILES] UserProfiles module is activated in BASIC mode");
142 Enabled = false; 142 Enabled = false;
143 return; 143 return;
144 } 144 }
145 else 145
146 { 146 m_log.Debug("[PROFILES]: Full Profiles Enabled");
147 m_log.Info("[PROFILES] UserProfiles module is activated in FULL mode"); 147 ReplaceableInterface = null;
148 Enabled = true; 148 Enabled = true;
149 }
150 } 149 }
151 150
152 /// <summary> 151 /// <summary>
@@ -157,6 +156,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
157 /// </param> 156 /// </param>
158 public void AddRegion(Scene scene) 157 public void AddRegion(Scene scene)
159 { 158 {
159 if(!Enabled)
160 return;
161
160 Scene = scene; 162 Scene = scene;
161 Scene.RegisterModuleInterface<IProfileModule>(this); 163 Scene.RegisterModuleInterface<IProfileModule>(this);
162 Scene.EventManager.OnNewClient += OnNewClient; 164 Scene.EventManager.OnNewClient += OnNewClient;
@@ -178,6 +180,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
178 /// </param> 180 /// </param>
179 public void RemoveRegion(Scene scene) 181 public void RemoveRegion(Scene scene)
180 { 182 {
183 if(!Enabled)
184 return;
181 } 185 }
182 186
183 /// <summary> 187 /// <summary>
@@ -191,6 +195,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
191 /// </param> 195 /// </param>
192 public void RegionLoaded(Scene scene) 196 public void RegionLoaded(Scene scene)
193 { 197 {
198 if(!Enabled)
199 return;
194 } 200 }
195 201
196 /// <summary> 202 /// <summary>
@@ -206,7 +212,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
206 /// </value> 212 /// </value>
207 public Type ReplaceableInterface 213 public Type ReplaceableInterface
208 { 214 {
209 get { return typeof(IProfileModule); } 215 get; private set;
210 } 216 }
211 217
212 /// <summary> 218 /// <summary>
@@ -237,13 +243,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
237 /// </param> 243 /// </param>
238 void OnNewClient(IClientAPI client) 244 void OnNewClient(IClientAPI client)
239 { 245 {
240 // Basic or Full module?
241 if(!Enabled)
242 {
243 client.OnRequestAvatarProperties += BasicRequestProperties;
244 return;
245 }
246
247 //Profile 246 //Profile
248 client.OnRequestAvatarProperties += RequestAvatarProperties; 247 client.OnRequestAvatarProperties += RequestAvatarProperties;
249 client.OnUpdateAvatarProperties += AvatarPropertiesUpdate; 248 client.OnUpdateAvatarProperties += AvatarPropertiesUpdate;
@@ -839,63 +838,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
839 } 838 }
840 } 839 }
841 840
842 public void BasicRequestProperties(IClientAPI remoteClient, UUID avatarID)
843 {
844 IScene s = remoteClient.Scene;
845 if (!(s is Scene))
846 return;
847
848 string profileUrl = String.Empty;
849 string aboutText = String.Empty;
850 string firstLifeAboutText = String.Empty;
851 UUID image = UUID.Zero;
852 UUID firstLifeImage = UUID.Zero;
853 UUID partner = UUID.Zero;
854 uint wantMask = 0;
855 string wantText = String.Empty;
856 uint skillsMask = 0;
857 string skillsText = String.Empty;
858 string languages = String.Empty;
859
860 UserAccount account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, avatarID);
861
862 string name = "Avatar";
863 int created = 0;
864 if (account != null)
865 {
866 name = account.FirstName + " " + account.LastName;
867 created = account.Created;
868 }
869 Byte[] charterMember = Utils.StringToBytes(name);
870
871 profileUrl = "No profile data";
872 aboutText = string.Empty;
873 firstLifeAboutText = string.Empty;
874 image = UUID.Zero;
875 firstLifeImage = UUID.Zero;
876 partner = UUID.Zero;
877
878 remoteClient.SendAvatarProperties(avatarID, aboutText,
879 Util.ToDateTime(created).ToString(
880 "M/d/yyyy", CultureInfo.InvariantCulture),
881 charterMember, firstLifeAboutText,
882 (uint)(0 & 0xff),
883 firstLifeImage, image, profileUrl, partner);
884
885 //Viewer expects interest data when it asks for properties.
886 remoteClient.SendAvatarInterestsReply(avatarID, wantMask, wantText,
887 skillsMask, skillsText, languages);
888 }
889
890 /// <summary>
891 /// Requests the avatar properties.
892 /// </summary>
893 /// <param name='remoteClient'>
894 /// Remote client.
895 /// </param>
896 /// <param name='avatarID'>
897 /// Avatar I.
898 /// </param>
899 public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) 841 public void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
900 { 842 {
901 if ( String.IsNullOrEmpty(avatarID.ToString()) || String.IsNullOrEmpty(remoteClient.AgentId.ToString())) 843 if ( String.IsNullOrEmpty(avatarID.ToString()) || String.IsNullOrEmpty(remoteClient.AgentId.ToString()))
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 38e2a07..3015c08 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -1032,11 +1032,11 @@
1032 ;# {InitialTerrain} {} {Initial terrain type} {pinhead-island flat} pinhead-island 1032 ;# {InitialTerrain} {} {Initial terrain type} {pinhead-island flat} pinhead-island
1033 ; InitialTerrain = "pinhead-island" 1033 ; InitialTerrain = "pinhead-island"
1034 1034
1035[Profile] 1035[UserProfiles]
1036 ;# {ProfileURL} {} {Set url to UserProfilesService} {} 1036 ;# {ProfileURL} {} {Set url to UserProfilesService} {}
1037 ;; Set the value of the url to your UserProfilesService 1037 ;; Set the value of the url to your UserProfilesService
1038 ;; If un-set / "" the module is disabled 1038 ;; If un-set / "" the module is disabled
1039 ;; ProfileURL = http://127.0.0.1:8002 1039 ;; ProfileServiceURL = http://127.0.0.1:8002
1040 1040
1041[Architecture] 1041[Architecture]
1042 ;# {Include-Architecture} {} {Choose one of the following architectures} {config-include/Standalone.ini config-include/StandaloneHypergrid.ini config-include/Grid.ini config-include/GridHypergrid.ini config-include/SimianGrid.ini config-include/HyperSimianGrid.ini} config-include/Standalone.ini 1042 ;# {Include-Architecture} {} {Choose one of the following architectures} {config-include/Standalone.ini config-include/StandaloneHypergrid.ini config-include/Grid.ini config-include/GridHypergrid.ini config-include/SimianGrid.ini config-include/HyperSimianGrid.ini} config-include/Standalone.ini