opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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.Collections.Generic; |
||
30 | using System.Reflection; |
||
31 | |||
32 | using OpenSim.Services.Interfaces; |
||
33 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
||
34 | using OpenSim.Server.Base; |
||
35 | using OpenSim.Framework; |
||
36 | |||
37 | using OpenMetaverse; |
||
38 | using log4net; |
||
39 | |||
40 | namespace OpenSim.Services.Connectors.Friends |
||
41 | { |
||
42 | public class FriendsSimConnector |
||
43 | { |
||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
45 | |||
46 | protected virtual string ServicePath() |
||
47 | { |
||
48 | return "friends"; |
||
49 | } |
||
50 | |||
51 | public bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message) |
||
52 | { |
||
53 | return FriendshipOffered(region, userID, friendID, message, String.Empty); |
||
54 | } |
||
55 | |||
56 | public virtual bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message, string userName) |
||
57 | { |
||
58 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
||
59 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); |
||
60 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); |
||
61 | sendData["METHOD"] = "friendship_offered"; |
||
62 | |||
63 | sendData["FromID"] = userID.ToString(); |
||
64 | sendData["ToID"] = friendID.ToString(); |
||
65 | sendData["Message"] = message; |
||
66 | if (userName != String.Empty) |
||
67 | sendData["FromName"] = userName; |
||
68 | |||
69 | return Call(region, sendData); |
||
70 | } |
||
71 | |||
72 | public bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID) |
||
73 | { |
||
74 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
||
75 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); |
||
76 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); |
||
77 | sendData["METHOD"] = "friendship_approved"; |
||
78 | |||
79 | sendData["FromID"] = userID.ToString(); |
||
80 | sendData["FromName"] = userName; |
||
81 | sendData["ToID"] = friendID.ToString(); |
||
82 | |||
83 | return Call(region, sendData); |
||
84 | } |
||
85 | |||
86 | public bool FriendshipDenied(GridRegion region, UUID userID, string userName, UUID friendID) |
||
87 | { |
||
88 | if (region == null) |
||
89 | return false; |
||
90 | |||
91 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
||
92 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); |
||
93 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); |
||
94 | sendData["METHOD"] = "friendship_denied"; |
||
95 | |||
96 | sendData["FromID"] = userID.ToString(); |
||
97 | sendData["FromName"] = userName; |
||
98 | sendData["ToID"] = friendID.ToString(); |
||
99 | |||
100 | return Call(region, sendData); |
||
101 | } |
||
102 | |||
103 | public bool FriendshipTerminated(GridRegion region, UUID userID, UUID friendID) |
||
104 | { |
||
105 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
||
106 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); |
||
107 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); |
||
108 | sendData["METHOD"] = "friendship_terminated"; |
||
109 | |||
110 | sendData["FromID"] = userID.ToString(); |
||
111 | sendData["ToID"] = friendID.ToString(); |
||
112 | |||
113 | return Call(region, sendData); |
||
114 | } |
||
115 | |||
116 | public bool GrantRights(GridRegion region, UUID userID, UUID friendID, int userFlags, int rights) |
||
117 | { |
||
118 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
||
119 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); |
||
120 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); |
||
121 | sendData["METHOD"] = "grant_rights"; |
||
122 | |||
123 | sendData["FromID"] = userID.ToString(); |
||
124 | sendData["ToID"] = friendID.ToString(); |
||
125 | sendData["UserFlags"] = userFlags.ToString(); |
||
126 | sendData["Rights"] = rights.ToString(); |
||
127 | |||
128 | return Call(region, sendData); |
||
129 | } |
||
130 | |||
131 | public bool StatusNotify(GridRegion region, UUID userID, string friendID, bool online) |
||
132 | { |
||
133 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
||
134 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); |
||
135 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); |
||
136 | sendData["METHOD"] = "status"; |
||
137 | |||
138 | sendData["FromID"] = userID.ToString(); |
||
139 | sendData["ToID"] = friendID; |
||
140 | sendData["Online"] = online.ToString(); |
||
141 | |||
142 | return Call(region, sendData); |
||
143 | } |
||
144 | |||
145 | private bool Call(GridRegion region, Dictionary<string, object> sendData) |
||
146 | { |
||
147 | string reqString = ServerUtils.BuildQueryString(sendData); |
||
148 | //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString); |
||
149 | if (region == null) |
||
150 | return false; |
||
151 | |||
152 | string path = ServicePath(); |
||
153 | if (!region.ServerURI.EndsWith("/")) |
||
154 | path = "/" + path; |
||
155 | string uri = region.ServerURI + path; |
||
156 | // m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); |
||
157 | |||
158 | try |
||
159 | { |
||
160 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); |
||
161 | if (reply != string.Empty) |
||
162 | { |
||
163 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
||
164 | |||
165 | if (replyData.ContainsKey("RESULT")) |
||
166 | { |
||
167 | if (replyData["RESULT"].ToString().ToLower() == "true") |
||
168 | return true; |
||
169 | else |
||
170 | return false; |
||
171 | } |
||
172 | else |
||
173 | m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field"); |
||
174 | |||
175 | } |
||
176 | else |
||
177 | m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply"); |
||
178 | } |
||
179 | catch (Exception e) |
||
180 | { |
||
181 | m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message); |
||
182 | } |
||
183 | |||
184 | return false; |
||
185 | } |
||
186 | } |
||
187 | } |