diff options
author | UbitUmarov | 2015-09-01 11:43:07 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-01 11:43:07 +0100 |
commit | fb78b182520fc9bb0f971afd0322029c70278ea6 (patch) | |
tree | b4e30d383938fdeef8c92d1d1c2f44bb61d329bd /OpenSim/Services/Friends | |
parent | lixo (diff) | |
parent | Mantis #7713: fixed bug introduced by 1st MOSES patch. (diff) | |
download | opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.zip opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.gz opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.bz2 opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.xz |
Merge remote-tracking branch 'os/master'
Diffstat (limited to 'OpenSim/Services/Friends')
-rw-r--r-- | OpenSim/Services/Friends/FriendsService.cs | 115 | ||||
-rw-r--r-- | OpenSim/Services/Friends/FriendsServiceBase.cs | 89 | ||||
-rw-r--r-- | OpenSim/Services/Friends/Properties/AssemblyInfo.cs | 33 |
3 files changed, 237 insertions, 0 deletions
diff --git a/OpenSim/Services/Friends/FriendsService.cs b/OpenSim/Services/Friends/FriendsService.cs new file mode 100644 index 0000000..e2033ac --- /dev/null +++ b/OpenSim/Services/Friends/FriendsService.cs | |||
@@ -0,0 +1,115 @@ | |||
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 OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | using OpenSim.Data; | ||
34 | using Nini.Config; | ||
35 | using log4net; | ||
36 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
37 | |||
38 | namespace OpenSim.Services.Friends | ||
39 | { | ||
40 | public class FriendsService : FriendsServiceBase, IFriendsService | ||
41 | { | ||
42 | public FriendsService(IConfigSource config) : base(config) | ||
43 | { | ||
44 | } | ||
45 | |||
46 | public virtual FriendInfo[] GetFriends(UUID PrincipalID) | ||
47 | { | ||
48 | FriendsData[] data = m_Database.GetFriends(PrincipalID); | ||
49 | List<FriendInfo> info = new List<FriendInfo>(); | ||
50 | |||
51 | foreach (FriendsData d in data) | ||
52 | { | ||
53 | FriendInfo i = new FriendInfo(); | ||
54 | |||
55 | i.PrincipalID = new UUID(d.PrincipalID); | ||
56 | i.Friend = d.Friend; | ||
57 | i.MyFlags = Convert.ToInt32(d.Data["Flags"]); | ||
58 | i.TheirFlags = Convert.ToInt32(d.Data["TheirFlags"]); | ||
59 | |||
60 | info.Add(i); | ||
61 | } | ||
62 | |||
63 | return info.ToArray(); | ||
64 | } | ||
65 | |||
66 | public virtual FriendInfo[] GetFriends(string PrincipalID) | ||
67 | { | ||
68 | FriendsData[] data = m_Database.GetFriends(PrincipalID); | ||
69 | List<FriendInfo> info = new List<FriendInfo>(); | ||
70 | |||
71 | foreach (FriendsData d in data) | ||
72 | { | ||
73 | FriendInfo i = new FriendInfo(); | ||
74 | |||
75 | if (!UUID.TryParse(d.PrincipalID, out i.PrincipalID)) | ||
76 | { | ||
77 | string tmp = string.Empty; | ||
78 | if (!Util.ParseUniversalUserIdentifier(d.PrincipalID, out i.PrincipalID, out tmp, out tmp, out tmp, out tmp)) | ||
79 | // bad record. ignore this entry | ||
80 | continue; | ||
81 | } | ||
82 | i.Friend = d.Friend; | ||
83 | i.MyFlags = Convert.ToInt32(d.Data["Flags"]); | ||
84 | i.TheirFlags = Convert.ToInt32(d.Data["TheirFlags"]); | ||
85 | |||
86 | info.Add(i); | ||
87 | } | ||
88 | |||
89 | return info.ToArray(); | ||
90 | } | ||
91 | |||
92 | public virtual bool StoreFriend(string PrincipalID, string Friend, int flags) | ||
93 | { | ||
94 | FriendsData d = new FriendsData(); | ||
95 | |||
96 | d.PrincipalID = PrincipalID; | ||
97 | d.Friend = Friend; | ||
98 | d.Data = new Dictionary<string, string>(); | ||
99 | d.Data["Flags"] = flags.ToString(); | ||
100 | |||
101 | return m_Database.Store(d); | ||
102 | } | ||
103 | |||
104 | public bool Delete(string principalID, string friend) | ||
105 | { | ||
106 | return m_Database.Delete(principalID, friend); | ||
107 | } | ||
108 | |||
109 | public virtual bool Delete(UUID PrincipalID, string Friend) | ||
110 | { | ||
111 | return m_Database.Delete(PrincipalID, Friend); | ||
112 | } | ||
113 | |||
114 | } | ||
115 | } | ||
diff --git a/OpenSim/Services/Friends/FriendsServiceBase.cs b/OpenSim/Services/Friends/FriendsServiceBase.cs new file mode 100644 index 0000000..6ab0bff --- /dev/null +++ b/OpenSim/Services/Friends/FriendsServiceBase.cs | |||
@@ -0,0 +1,89 @@ | |||
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.Reflection; | ||
30 | using log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Base; | ||
36 | |||
37 | namespace OpenSim.Services.Friends | ||
38 | { | ||
39 | public class FriendsServiceBase : ServiceBase | ||
40 | { | ||
41 | protected IFriendsData m_Database = null; | ||
42 | |||
43 | public FriendsServiceBase(IConfigSource config) : base(config) | ||
44 | { | ||
45 | string dllName = String.Empty; | ||
46 | string connString = String.Empty; | ||
47 | |||
48 | // | ||
49 | // Try reading the [FriendsService] section first, if it exists | ||
50 | // | ||
51 | IConfig friendsConfig = config.Configs["FriendsService"]; | ||
52 | if (friendsConfig != null) | ||
53 | { | ||
54 | dllName = friendsConfig.GetString("StorageProvider", dllName); | ||
55 | connString = friendsConfig.GetString("ConnectionString", connString); | ||
56 | } | ||
57 | |||
58 | // | ||
59 | // Try reading the [DatabaseService] section, if it exists | ||
60 | // | ||
61 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
62 | if (dbConfig != null) | ||
63 | { | ||
64 | if (dllName == String.Empty) | ||
65 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
66 | if (connString == String.Empty) | ||
67 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
68 | } | ||
69 | |||
70 | // | ||
71 | // We tried, but this doesn't exist. We can't proceed. | ||
72 | // | ||
73 | if (String.Empty.Equals(dllName)) | ||
74 | throw new Exception("No StorageProvider configured"); | ||
75 | |||
76 | string realm = "Friends"; | ||
77 | if (friendsConfig != null) | ||
78 | realm = friendsConfig.GetString("Realm", realm); | ||
79 | |||
80 | m_Database = LoadPlugin<IFriendsData>(dllName, new Object[] { connString, realm }); | ||
81 | if (m_Database == null) | ||
82 | { | ||
83 | throw new Exception( | ||
84 | string.Format( | ||
85 | "Could not find a storage interface {0} in the given StorageProvider {1}", "IFriendsData", dllName)); | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
diff --git a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f258f94 --- /dev/null +++ b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Services.FriendsService")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("a265d071-e152-42cc-9674-3ddd053977f5")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.8.2.*")] | ||
33 | |||