aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/FriendsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/FriendsModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/FriendsModule.cs138
1 files changed, 138 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs
index 7560c90..fc14df7 100644
--- a/OpenSim/Region/Environment/Modules/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs
@@ -27,6 +27,7 @@
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using libsecondlife; 29using libsecondlife;
30using libsecondlife.Packets;
30using Nini.Config; 31using Nini.Config;
31using Nwc.XmlRpc; 32using Nwc.XmlRpc;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -45,6 +46,8 @@ namespace OpenSim.Region.Environment.Modules
45 46
46 Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>(); 47 Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
47 48
49 Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
50
48 public void Initialise(Scene scene, IConfigSource config) 51 public void Initialise(Scene scene, IConfigSource config)
49 { 52 {
50 lock (m_scene) 53 lock (m_scene)
@@ -78,11 +81,92 @@ namespace OpenSim.Region.Environment.Modules
78 // Generated by LoginService. The friends are retreived from the database by the UserManager 81 // Generated by LoginService. The friends are retreived from the database by the UserManager
79 82
80 // Subscribe to instant messages 83 // Subscribe to instant messages
84
81 client.OnInstantMessage += OnInstantMessage; 85 client.OnInstantMessage += OnInstantMessage;
82 client.OnApproveFriendRequest += OnApprovedFriendRequest; 86 client.OnApproveFriendRequest += OnApprovedFriendRequest;
83 client.OnDenyFriendRequest += OnDenyFriendRequest; 87 client.OnDenyFriendRequest += OnDenyFriendRequest;
84 client.OnTerminateFriendship += OnTerminateFriendship; 88 client.OnTerminateFriendship += OnTerminateFriendship;
89
90 List<FriendListItem> fl = new List<FriendListItem>();
91 lock (FriendLists)
92 {
93 if (FriendLists.ContainsKey(client.AgentId))
94 {
95 fl = FriendLists[client.AgentId];
96 }
97 else
98 {
99 fl = m_scene[0].GetFriendList(client.AgentId);
100 lock (FriendLists)
101 {
102 if (!FriendLists.ContainsKey(client.AgentId))
103 FriendLists.Add(client.AgentId, fl);
104 }
105 }
106 }
85 107
108 List<LLUUID> UpdateUsers = new List<LLUUID>();
109
110 foreach (FriendListItem f in fl)
111 {
112 if (m_rootAgents.ContainsKey(f.Friend))
113 {
114 if (f.onlinestatus == false)
115 {
116 UpdateUsers.Add(f.Friend);
117 f.onlinestatus = true;
118 }
119 }
120 }
121 foreach (LLUUID user in UpdateUsers)
122 {
123 ScenePresence av = GetPresenceFromAgentID(user);
124 if (av != null)
125 {
126 List<FriendListItem> usrfl = new List<FriendListItem>();
127
128 lock (FriendLists)
129 {
130 usrfl = FriendLists[user];
131 }
132
133 lock (usrfl)
134 {
135 foreach (FriendListItem fli in usrfl)
136 {
137 if (fli.Friend == client.AgentId)
138 {
139 fli.onlinestatus = true;
140 OnlineNotificationPacket onp = new OnlineNotificationPacket();
141 OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[1];
142 OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
143 onpbl.AgentID = client.AgentId;
144 onpb[0] = onpbl;
145 onp.AgentBlock = onpb;
146 av.ControllingClient.OutPacket(onp, ThrottleOutPacketType.Task);
147 }
148 }
149 }
150 }
151 }
152
153 if (UpdateUsers.Count > 0)
154 {
155 OnlineNotificationPacket onp = new OnlineNotificationPacket();
156 OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[UpdateUsers.Count];
157 for (int i = 0; i < UpdateUsers.Count; i++)
158 {
159 OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
160 onpbl.AgentID = UpdateUsers[i];
161 onpb[i] = onpbl;
162 }
163 onp.AgentBlock = onpb;
164 client.OutPacket(onp, ThrottleOutPacketType.Task);
165 }
166
167
168
169
86 } 170 }
87 171
88 private void ClientLoggedOut(LLUUID AgentId) 172 private void ClientLoggedOut(LLUUID AgentId)
@@ -95,6 +179,60 @@ namespace OpenSim.Region.Environment.Modules
95 m_log.Info("[FRIEND]: Removing " + AgentId + ". Agent logged out."); 179 m_log.Info("[FRIEND]: Removing " + AgentId + ". Agent logged out.");
96 } 180 }
97 } 181 }
182 List<FriendListItem> lfli = new List<FriendListItem>();
183 lock (FriendLists)
184 {
185 if (FriendLists.ContainsKey(AgentId))
186 {
187 lfli = FriendLists[AgentId];
188 }
189 }
190 List<LLUUID> updateUsers = new List<LLUUID>();
191 foreach (FriendListItem fli in lfli)
192 {
193 if (fli.onlinestatus = true)
194 {
195 updateUsers.Add(fli.Friend);
196 }
197 }
198 for (int i = 0; i < updateUsers.Count; i++)
199 {
200 List<FriendListItem> flfli = new List<FriendListItem>();
201 lock (FriendLists)
202 {
203 if (FriendLists.ContainsKey(updateUsers[i]))
204 flfli = FriendLists[updateUsers[i]];
205 }
206 for (int j = 0; j < flfli.Count; j++)
207 {
208 if (flfli[i].Friend == AgentId)
209 {
210 flfli[i].onlinestatus = false;
211 }
212
213 }
214
215 }
216 for (int i = 0; i < updateUsers.Count; i++)
217 {
218 ScenePresence av = GetPresenceFromAgentID(updateUsers[i]);
219 if (av != null)
220 {
221
222 OfflineNotificationPacket onp = new OfflineNotificationPacket();
223 OfflineNotificationPacket.AgentBlockBlock[] onpb = new OfflineNotificationPacket.AgentBlockBlock[1];
224 OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
225 onpbl.AgentID = AgentId;
226 onpb[0] = onpbl;
227 onp.AgentBlock = onpb;
228 av.ControllingClient.OutPacket(onp, ThrottleOutPacketType.Task);
229 }
230 }
231 lock (FriendLists)
232 {
233 FriendLists.Remove(AgentId);
234 }
235
98 } 236 }
99 237
100 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID) 238 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)