aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/HGFriendsService.cs
diff options
context:
space:
mode:
authorDiva Canto2011-05-19 16:54:46 -0700
committerDiva Canto2011-05-19 16:54:46 -0700
commitd21e9c755f004d8fe03b11bc57b810dbd401435a (patch)
tree1efd9e48308192d21ca73d8ff12d6a48c186077c /OpenSim/Services/HypergridService/HGFriendsService.cs
parentAccidentally committed too early (diff)
downloadopensim-SC-d21e9c755f004d8fe03b11bc57b810dbd401435a.zip
opensim-SC-d21e9c755f004d8fe03b11bc57b810dbd401435a.tar.gz
opensim-SC-d21e9c755f004d8fe03b11bc57b810dbd401435a.tar.bz2
opensim-SC-d21e9c755f004d8fe03b11bc57b810dbd401435a.tar.xz
HG Friends working to some extent: friendships offered and accepted correctly handled. Friends list showing correct foreign names. TODO: GrantRights.
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/HypergridService/HGFriendsService.cs95
1 files changed, 95 insertions, 0 deletions
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
new file mode 100644
index 0000000..fa4ec5d
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGFriendsService.cs
@@ -0,0 +1,95 @@
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
28using OpenMetaverse;
29using OpenSim.Framework;
30using System;
31using System.Collections.Generic;
32using OpenSim.Services.Interfaces;
33using OpenSim.Services.Friends;
34using OpenSim.Data;
35using Nini.Config;
36using log4net;
37using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38
39namespace OpenSim.Services.HypergridService
40{
41 public class HGFriendsService : FriendsService, IFriendsService
42 {
43 public HGFriendsService(IConfigSource config) : base(config)
44 {
45 }
46
47 /// <summary>
48 /// Overrides base.
49 /// Storing new friendships from the outside is a tricky, sensitive operation, and it
50 /// needs to be done under certain restrictions.
51 /// First of all, if the friendship already exists, this is a no-op. In other words,
52 /// we cannot change just the flags, it needs to be a new friendship.
53 /// Second, we store it as flags=0 always, independent of what the caller sends. The
54 /// owner of the friendship needs to confirm when it gets back home.
55 /// </summary>
56 /// <param name="PrincipalID"></param>
57 /// <param name="Friend"></param>
58 /// <param name="flags"></param>
59 /// <returns></returns>
60 public override bool StoreFriend(string PrincipalID, string Friend, int flags)
61 {
62 UUID userID;
63 if (UUID.TryParse(PrincipalID, out userID))
64 {
65 FriendsData[] friendsData = m_Database.GetFriends(userID);
66 List<FriendsData> fList = new List<FriendsData>(friendsData);
67 if (fList.Find(delegate(FriendsData fdata)
68 {
69 return fdata.Friend == Friend;
70 }) != null)
71 return false;
72 }
73
74 FriendsData d = new FriendsData();
75 d.PrincipalID = PrincipalID;
76 d.Friend = Friend;
77 d.Data = new Dictionary<string, string>();
78 d.Data["Flags"] = "0";
79
80 return m_Database.Store(d);
81 }
82
83 /// <summary>
84 /// Overrides base. Cannot delete friendships while away from home.
85 /// </summary>
86 /// <param name="PrincipalID"></param>
87 /// <param name="Friend"></param>
88 /// <returns></returns>
89 public override bool Delete(UUID PrincipalID, string Friend)
90 {
91 return false;
92 }
93
94 }
95}