diff options
author | Melanie | 2011-06-20 03:08:56 +0200 |
---|---|---|
committer | Melanie | 2011-06-20 03:08:56 +0200 |
commit | f4f55c4d6bdbe9a86b5343159916977b331fefe0 (patch) | |
tree | 08fb85f2aa0193bf8549e684b98501c2c52faa1a /OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | |
parent | Add some flags to control content in search better (diff) | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
download | opensim-SC-f4f55c4d6bdbe9a86b5343159916977b331fefe0.zip opensim-SC-f4f55c4d6bdbe9a86b5343159916977b331fefe0.tar.gz opensim-SC-f4f55c4d6bdbe9a86b5343159916977b331fefe0.tar.bz2 opensim-SC-f4f55c4d6bdbe9a86b5343159916977b331fefe0.tar.xz |
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | 65 |
1 files changed, 60 insertions, 5 deletions
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index b168bb3..fc97d8c 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | |||
@@ -82,12 +82,18 @@ namespace OpenSim.Server.Handlers.Friends | |||
82 | case "getfriends": | 82 | case "getfriends": |
83 | return GetFriends(request); | 83 | return GetFriends(request); |
84 | 84 | ||
85 | case "getfriends_string": | ||
86 | return GetFriendsString(request); | ||
87 | |||
85 | case "storefriend": | 88 | case "storefriend": |
86 | return StoreFriend(request); | 89 | return StoreFriend(request); |
87 | 90 | ||
88 | case "deletefriend": | 91 | case "deletefriend": |
89 | return DeleteFriend(request); | 92 | return DeleteFriend(request); |
90 | 93 | ||
94 | case "deletefriend_string": | ||
95 | return DeleteFriendString(request); | ||
96 | |||
91 | } | 97 | } |
92 | m_log.DebugFormat("[FRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); | 98 | m_log.DebugFormat("[FRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); |
93 | } | 99 | } |
@@ -111,7 +117,25 @@ namespace OpenSim.Server.Handlers.Friends | |||
111 | m_log.WarnFormat("[FRIENDS HANDLER]: no principalID in request to get friends"); | 117 | m_log.WarnFormat("[FRIENDS HANDLER]: no principalID in request to get friends"); |
112 | 118 | ||
113 | FriendInfo[] finfos = m_FriendsService.GetFriends(principalID); | 119 | FriendInfo[] finfos = m_FriendsService.GetFriends(principalID); |
114 | //m_log.DebugFormat("[FRIENDS HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | 120 | |
121 | return PackageFriends(finfos); | ||
122 | } | ||
123 | |||
124 | byte[] GetFriendsString(Dictionary<string, object> request) | ||
125 | { | ||
126 | string principalID = string.Empty; | ||
127 | if (request.ContainsKey("PRINCIPALID")) | ||
128 | principalID = request["PRINCIPALID"].ToString(); | ||
129 | else | ||
130 | m_log.WarnFormat("[FRIENDS HANDLER]: no principalID in request to get friends"); | ||
131 | |||
132 | FriendInfo[] finfos = m_FriendsService.GetFriends(principalID); | ||
133 | |||
134 | return PackageFriends(finfos); | ||
135 | } | ||
136 | |||
137 | private byte[] PackageFriends(FriendInfo[] finfos) | ||
138 | { | ||
115 | 139 | ||
116 | Dictionary<string, object> result = new Dictionary<string, object>(); | 140 | Dictionary<string, object> result = new Dictionary<string, object>(); |
117 | if ((finfos == null) || ((finfos != null) && (finfos.Length == 0))) | 141 | if ((finfos == null) || ((finfos != null) && (finfos.Length == 0))) |
@@ -136,9 +160,9 @@ namespace OpenSim.Server.Handlers.Friends | |||
136 | 160 | ||
137 | byte[] StoreFriend(Dictionary<string, object> request) | 161 | byte[] StoreFriend(Dictionary<string, object> request) |
138 | { | 162 | { |
139 | FriendInfo friend = new FriendInfo(request); | 163 | string principalID = string.Empty, friend = string.Empty; int flags = 0; |
140 | 164 | FromKeyValuePairs(request, out principalID, out friend, out flags); | |
141 | bool success = m_FriendsService.StoreFriend(friend.PrincipalID, friend.Friend, friend.MyFlags); | 165 | bool success = m_FriendsService.StoreFriend(principalID, friend, flags); |
142 | 166 | ||
143 | if (success) | 167 | if (success) |
144 | return SuccessResult(); | 168 | return SuccessResult(); |
@@ -163,7 +187,25 @@ namespace OpenSim.Server.Handlers.Friends | |||
163 | else | 187 | else |
164 | return FailureResult(); | 188 | return FailureResult(); |
165 | } | 189 | } |
166 | 190 | ||
191 | byte[] DeleteFriendString(Dictionary<string, object> request) | ||
192 | { | ||
193 | string principalID = string.Empty; | ||
194 | if (request.ContainsKey("PRINCIPALID")) | ||
195 | principalID = request["PRINCIPALID"].ToString(); | ||
196 | else | ||
197 | m_log.WarnFormat("[FRIENDS HANDLER]: no principalID in request to delete friend"); | ||
198 | string friend = string.Empty; | ||
199 | if (request.ContainsKey("FRIEND")) | ||
200 | friend = request["FRIEND"].ToString(); | ||
201 | |||
202 | bool success = m_FriendsService.Delete(principalID, friend); | ||
203 | if (success) | ||
204 | return SuccessResult(); | ||
205 | else | ||
206 | return FailureResult(); | ||
207 | } | ||
208 | |||
167 | #endregion | 209 | #endregion |
168 | 210 | ||
169 | #region Misc | 211 | #region Misc |
@@ -233,6 +275,19 @@ namespace OpenSim.Server.Handlers.Friends | |||
233 | return ms.ToArray(); | 275 | return ms.ToArray(); |
234 | } | 276 | } |
235 | 277 | ||
278 | void FromKeyValuePairs(Dictionary<string, object> kvp, out string principalID, out string friend, out int flags) | ||
279 | { | ||
280 | principalID = string.Empty; | ||
281 | if (kvp.ContainsKey("PrincipalID") && kvp["PrincipalID"] != null) | ||
282 | principalID = kvp["PrincipalID"].ToString(); | ||
283 | friend = string.Empty; | ||
284 | if (kvp.ContainsKey("Friend") && kvp["Friend"] != null) | ||
285 | friend = kvp["Friend"].ToString(); | ||
286 | flags = 0; | ||
287 | if (kvp.ContainsKey("MyFlags") && kvp["MyFlags"] != null) | ||
288 | Int32.TryParse(kvp["MyFlags"].ToString(), out flags); | ||
289 | } | ||
290 | |||
236 | #endregion | 291 | #endregion |
237 | } | 292 | } |
238 | } | 293 | } |