diff options
Diffstat (limited to '')
15 files changed, 443 insertions, 1074 deletions
diff --git a/OpenSim/Framework/Communications/GenericAsyncResult.cs b/OpenSim/Framework/Communications/GenericAsyncResult.cs deleted file mode 100644 index 8e3f62b..0000000 --- a/OpenSim/Framework/Communications/GenericAsyncResult.cs +++ /dev/null | |||
@@ -1,185 +0,0 @@ | |||
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.Threading; | ||
30 | |||
31 | namespace OpenSim.Framework.Communications | ||
32 | { | ||
33 | internal class SimpleAsyncResult : IAsyncResult | ||
34 | { | ||
35 | private readonly AsyncCallback m_callback; | ||
36 | |||
37 | /// <summary> | ||
38 | /// Is process completed? | ||
39 | /// </summary> | ||
40 | /// <remarks>Should really be boolean, but VolatileRead has no boolean method</remarks> | ||
41 | private byte m_completed; | ||
42 | |||
43 | /// <summary> | ||
44 | /// Did process complete synchronously? | ||
45 | /// </summary> | ||
46 | /// <remarks>I have a hard time imagining a scenario where this is the case, again, same issue about | ||
47 | /// booleans and VolatileRead as m_completed | ||
48 | /// </remarks> | ||
49 | private byte m_completedSynchronously; | ||
50 | |||
51 | private readonly object m_asyncState; | ||
52 | private ManualResetEvent m_waitHandle; | ||
53 | private Exception m_exception; | ||
54 | |||
55 | internal SimpleAsyncResult(AsyncCallback cb, object state) | ||
56 | { | ||
57 | m_callback = cb; | ||
58 | m_asyncState = state; | ||
59 | m_completed = 0; | ||
60 | m_completedSynchronously = 1; | ||
61 | } | ||
62 | |||
63 | #region IAsyncResult Members | ||
64 | |||
65 | public object AsyncState | ||
66 | { | ||
67 | get { return m_asyncState; } | ||
68 | } | ||
69 | |||
70 | public WaitHandle AsyncWaitHandle | ||
71 | { | ||
72 | get | ||
73 | { | ||
74 | if (m_waitHandle == null) | ||
75 | { | ||
76 | bool done = IsCompleted; | ||
77 | ManualResetEvent mre = new ManualResetEvent(done); | ||
78 | if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) | ||
79 | { | ||
80 | mre.Close(); | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | if (!done && IsCompleted) | ||
85 | { | ||
86 | m_waitHandle.Set(); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | return m_waitHandle; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||
96 | public bool CompletedSynchronously | ||
97 | { | ||
98 | get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } | ||
99 | } | ||
100 | |||
101 | |||
102 | public bool IsCompleted | ||
103 | { | ||
104 | get { return Thread.VolatileRead(ref m_completed) == 1; } | ||
105 | } | ||
106 | |||
107 | #endregion | ||
108 | |||
109 | #region class Methods | ||
110 | |||
111 | internal void SetAsCompleted(bool completedSynchronously) | ||
112 | { | ||
113 | m_completed = 1; | ||
114 | if (completedSynchronously) | ||
115 | m_completedSynchronously = 1; | ||
116 | else | ||
117 | m_completedSynchronously = 0; | ||
118 | |||
119 | SignalCompletion(); | ||
120 | } | ||
121 | |||
122 | internal void HandleException(Exception e, bool completedSynchronously) | ||
123 | { | ||
124 | m_completed = 1; | ||
125 | if (completedSynchronously) | ||
126 | m_completedSynchronously = 1; | ||
127 | else | ||
128 | m_completedSynchronously = 0; | ||
129 | m_exception = e; | ||
130 | |||
131 | SignalCompletion(); | ||
132 | } | ||
133 | |||
134 | private void SignalCompletion() | ||
135 | { | ||
136 | if (m_waitHandle != null) m_waitHandle.Set(); | ||
137 | |||
138 | if (m_callback != null) m_callback(this); | ||
139 | } | ||
140 | |||
141 | public void EndInvoke() | ||
142 | { | ||
143 | // This method assumes that only 1 thread calls EndInvoke | ||
144 | if (!IsCompleted) | ||
145 | { | ||
146 | // If the operation isn't done, wait for it | ||
147 | AsyncWaitHandle.WaitOne(); | ||
148 | AsyncWaitHandle.Close(); | ||
149 | m_waitHandle.Close(); | ||
150 | m_waitHandle = null; // Allow early GC | ||
151 | } | ||
152 | |||
153 | // Operation is done: if an exception occured, throw it | ||
154 | if (m_exception != null) throw m_exception; | ||
155 | } | ||
156 | |||
157 | #endregion | ||
158 | } | ||
159 | |||
160 | internal class AsyncResult<T> : SimpleAsyncResult | ||
161 | { | ||
162 | private T m_result = default(T); | ||
163 | |||
164 | public AsyncResult(AsyncCallback asyncCallback, Object state) : | ||
165 | base(asyncCallback, state) | ||
166 | { | ||
167 | } | ||
168 | |||
169 | public void SetAsCompleted(T result, bool completedSynchronously) | ||
170 | { | ||
171 | // Save the asynchronous operation's result | ||
172 | m_result = result; | ||
173 | |||
174 | // Tell the base class that the operation completed | ||
175 | // sucessfully (no exception) | ||
176 | base.SetAsCompleted(completedSynchronously); | ||
177 | } | ||
178 | |||
179 | public new T EndInvoke() | ||
180 | { | ||
181 | base.EndInvoke(); | ||
182 | return m_result; | ||
183 | } | ||
184 | } | ||
185 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs deleted file mode 100644 index dfa059d..0000000 --- a/OpenSim/Framework/Communications/IUserService.cs +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
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 OpenMetaverse; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | |||
33 | namespace OpenSim.Framework.Communications | ||
34 | { | ||
35 | public interface IUserService | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Add a temporary user profile. | ||
39 | /// </summary> | ||
40 | /// A temporary user profile is one that should exist only for the lifetime of the process. | ||
41 | /// <param name="userProfile"></param> | ||
42 | void AddTemporaryUserProfile(UserProfileData userProfile); | ||
43 | |||
44 | /// <summary> | ||
45 | /// Loads a user profile by name | ||
46 | /// </summary> | ||
47 | /// <param name="firstName">First name</param> | ||
48 | /// <param name="lastName">Last name</param> | ||
49 | /// <returns>A user profile. Returns null if no profile is found</returns> | ||
50 | UserProfileData GetUserProfile(string firstName, string lastName); | ||
51 | |||
52 | /// <summary> | ||
53 | /// Loads a user profile from a database by UUID | ||
54 | /// </summary> | ||
55 | /// <param name="userId">The target UUID</param> | ||
56 | /// <returns>A user profile. Returns null if no user profile is found.</returns> | ||
57 | UserProfileData GetUserProfile(UUID userId); | ||
58 | |||
59 | UserProfileData GetUserProfile(Uri uri); | ||
60 | |||
61 | Uri GetUserUri(UserProfileData userProfile); | ||
62 | |||
63 | UserAgentData GetAgentByUUID(UUID userId); | ||
64 | |||
65 | void ClearUserAgent(UUID avatarID); | ||
66 | List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID QueryID, string Query); | ||
67 | |||
68 | UserProfileData SetupMasterUser(string firstName, string lastName); | ||
69 | UserProfileData SetupMasterUser(string firstName, string lastName, string password); | ||
70 | UserProfileData SetupMasterUser(UUID userId); | ||
71 | |||
72 | /// <summary> | ||
73 | /// Update the user's profile. | ||
74 | /// </summary> | ||
75 | /// <param name="data">UserProfileData object with updated data. Should be obtained | ||
76 | /// via a call to GetUserProfile().</param> | ||
77 | /// <returns>true if the update could be applied, false if it could not be applied.</returns> | ||
78 | bool UpdateUserProfile(UserProfileData data); | ||
79 | |||
80 | /// <summary> | ||
81 | /// Adds a new friend to the database for XUser | ||
82 | /// </summary> | ||
83 | /// <param name="friendlistowner">The agent that who's friends list is being added to</param> | ||
84 | /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> | ||
85 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
86 | void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms); | ||
87 | |||
88 | /// <summary> | ||
89 | /// Delete friend on friendlistowner's friendlist. | ||
90 | /// </summary> | ||
91 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
92 | /// <param name="friend">The Ex-friend agent</param> | ||
93 | void RemoveUserFriend(UUID friendlistowner, UUID friend); | ||
94 | |||
95 | /// <summary> | ||
96 | /// Update permissions for friend on friendlistowner's friendlist. | ||
97 | /// </summary> | ||
98 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
99 | /// <param name="friend">The agent that is getting or loosing permissions</param> | ||
100 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
101 | void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); | ||
102 | |||
103 | /// <summary> | ||
104 | /// Logs off a user on the user server | ||
105 | /// </summary> | ||
106 | /// <param name="userid">UUID of the user</param> | ||
107 | /// <param name="regionid">UUID of the Region</param> | ||
108 | /// <param name="regionhandle">regionhandle</param> | ||
109 | /// <param name="position">final position</param> | ||
110 | /// <param name="lookat">final lookat</param> | ||
111 | void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat); | ||
112 | |||
113 | /// <summary> | ||
114 | /// Logs off a user on the user server (deprecated as of 2008-08-27) | ||
115 | /// </summary> | ||
116 | /// <param name="userid">UUID of the user</param> | ||
117 | /// <param name="regionid">UUID of the Region</param> | ||
118 | /// <param name="regionhandle">regionhandle</param> | ||
119 | /// <param name="posx">final position x</param> | ||
120 | /// <param name="posy">final position y</param> | ||
121 | /// <param name="posz">final position z</param> | ||
122 | void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz); | ||
123 | |||
124 | /// <summary> | ||
125 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship | ||
126 | /// for UUID friendslistowner | ||
127 | /// </summary> | ||
128 | /// | ||
129 | /// <param name="friendlistowner">The agent for whom we're retreiving the friends Data.</param> | ||
130 | /// <returns> | ||
131 | /// A List of FriendListItems that contains info about the user's friends. | ||
132 | /// Always returns a list even if the user has no friends | ||
133 | /// </returns> | ||
134 | List<FriendListItem> GetUserFriendList(UUID friendlistowner); | ||
135 | |||
136 | // This probably shouldn't be here, it belongs to IAuthentication | ||
137 | // But since Scenes only have IUserService references, I'm placing it here for now. | ||
138 | bool VerifySession(UUID userID, UUID sessionID); | ||
139 | |||
140 | /// <summary> | ||
141 | /// Authenticate a user by their password. | ||
142 | /// </summary> | ||
143 | /// | ||
144 | /// This is used by callers outside the login process that want to | ||
145 | /// verify a user who has given their password. | ||
146 | /// | ||
147 | /// This should probably also be in IAuthentication but is here for the same reasons as VerifySession() is | ||
148 | /// | ||
149 | /// <param name="userID"></param> | ||
150 | /// <param name="password"></param> | ||
151 | /// <returns></returns> | ||
152 | bool AuthenticateUserByPassword(UUID userID, string password); | ||
153 | |||
154 | // Temporary Hack until we move everything to the new service model | ||
155 | void SetInventoryService(IInventoryService invService); | ||
156 | } | ||
157 | } | ||
diff --git a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs deleted file mode 100644 index 070d106..0000000 --- a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
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 | namespace OpenSim.Framework.Communications.Limit | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// Interface for strategies that can limit requests from the client. Currently only used in the | ||
32 | /// texture modules to deal with repeated requests for certain textures. However, limiting strategies | ||
33 | /// could be used with other requests. | ||
34 | /// </summary> | ||
35 | public interface IRequestLimitStrategy<TId> | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Should the request be allowed? If the id is not monitored, then the request is always allowed. | ||
39 | /// Otherwise, the strategy criteria will be applied. | ||
40 | /// </summary> | ||
41 | /// <param name="id"></param> | ||
42 | /// <returns></returns> | ||
43 | bool AllowRequest(TId id); | ||
44 | |||
45 | /// <summary> | ||
46 | /// Has the request been refused just once? | ||
47 | /// </summary> | ||
48 | /// <returns>False if the request has not yet been refused, or if the request has been refused more | ||
49 | /// than once.</returns> | ||
50 | bool IsFirstRefusal(TId id); | ||
51 | |||
52 | /// <summary> | ||
53 | /// Start monitoring for future AllowRequest calls. If the id is already monitored, then monitoring | ||
54 | /// continues. | ||
55 | /// </summary> | ||
56 | /// <param name="id"></param> | ||
57 | void MonitorRequests(TId id); | ||
58 | |||
59 | /// <summary> | ||
60 | /// Is the id being monitored? | ||
61 | /// </summary> | ||
62 | /// <param name="uuid"> </param> | ||
63 | /// <returns></returns> | ||
64 | bool IsMonitoringRequests(TId id); | ||
65 | } | ||
66 | } | ||
diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs deleted file mode 100644 index 7672653..0000000 --- a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
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 | namespace OpenSim.Framework.Communications.Limit | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// Strategy which polices no limits | ||
32 | /// </summary> | ||
33 | public class NullLimitStrategy<TId> : IRequestLimitStrategy<TId> | ||
34 | { | ||
35 | public bool AllowRequest(TId id) { return true; } | ||
36 | public bool IsFirstRefusal(TId id) { return false; } | ||
37 | public void MonitorRequests(TId id) { /* intentionally blank */ } | ||
38 | public bool IsMonitoringRequests(TId id) { return false; } | ||
39 | } | ||
40 | } | ||
diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs deleted file mode 100644 index 44dd592..0000000 --- a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
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.Collections.Generic; | ||
29 | |||
30 | namespace OpenSim.Framework.Communications.Limit | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// Limit requests by discarding them after they've been repeated a certain number of times. | ||
34 | /// </summary> | ||
35 | public class RepeatLimitStrategy<TId> : IRequestLimitStrategy<TId> | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Record each asset request that we're notified about. | ||
39 | /// </summary> | ||
40 | private readonly Dictionary<TId, int> requestCounts = new Dictionary<TId, int>(); | ||
41 | |||
42 | /// <summary> | ||
43 | /// The maximum number of requests that can be made before we drop subsequent requests. | ||
44 | /// </summary> | ||
45 | private readonly int m_maxRequests; | ||
46 | public int MaxRequests | ||
47 | { | ||
48 | get { return m_maxRequests; } | ||
49 | } | ||
50 | |||
51 | /// <summary></summary> | ||
52 | /// <param name="maxRequests">The maximum number of requests that may be served before all further | ||
53 | /// requests are dropped.</param> | ||
54 | public RepeatLimitStrategy(int maxRequests) | ||
55 | { | ||
56 | m_maxRequests = maxRequests; | ||
57 | } | ||
58 | |||
59 | /// <summary> | ||
60 | /// <see cref="IRequestLimitStrategy"/> | ||
61 | /// </summary> | ||
62 | public bool AllowRequest(TId id) | ||
63 | { | ||
64 | if (requestCounts.ContainsKey(id)) | ||
65 | { | ||
66 | requestCounts[id] += 1; | ||
67 | |||
68 | if (requestCounts[id] > m_maxRequests) | ||
69 | { | ||
70 | return false; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | return true; | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// <see cref="IRequestLimitStrategy"/> | ||
79 | /// </summary> | ||
80 | public bool IsFirstRefusal(TId id) | ||
81 | { | ||
82 | if (requestCounts.ContainsKey(id) && m_maxRequests + 1 == requestCounts[id]) | ||
83 | { | ||
84 | return true; | ||
85 | } | ||
86 | |||
87 | return false; | ||
88 | } | ||
89 | |||
90 | /// <summary> | ||
91 | /// <see cref="IRequestLimitStrategy"/> | ||
92 | /// </summary> | ||
93 | public void MonitorRequests(TId id) | ||
94 | { | ||
95 | if (!IsMonitoringRequests(id)) | ||
96 | { | ||
97 | requestCounts.Add(id, 1); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | /// <summary> | ||
102 | /// <see cref="IRequestLimitStrategy"/> | ||
103 | /// </summary> | ||
104 | public bool IsMonitoringRequests(TId id) | ||
105 | { | ||
106 | return requestCounts.ContainsKey(id); | ||
107 | } | ||
108 | } | ||
109 | } | ||
diff --git a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs deleted file mode 100644 index 7ac8293..0000000 --- a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
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 | |||
31 | namespace OpenSim.Framework.Communications.Limit | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Limit requests by discarding repeat attempts that occur within a given time period | ||
35 | /// | ||
36 | /// XXX Don't use this for limiting texture downloading, at least not until we better handle multiple requests | ||
37 | /// for the same texture at different resolutions. | ||
38 | /// </summary> | ||
39 | public class TimeLimitStrategy<TId> : IRequestLimitStrategy<TId> | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Record the time at which an asset request occurs. | ||
43 | /// </summary> | ||
44 | private readonly Dictionary<TId, Request> requests = new Dictionary<TId, Request>(); | ||
45 | |||
46 | /// <summary> | ||
47 | /// The minimum time period between which requests for the same data will be serviced. | ||
48 | /// </summary> | ||
49 | private readonly TimeSpan m_repeatPeriod; | ||
50 | public TimeSpan RepeatPeriod | ||
51 | { | ||
52 | get { return m_repeatPeriod; } | ||
53 | } | ||
54 | |||
55 | /// <summary></summary> | ||
56 | /// <param name="repeatPeriod"></param> | ||
57 | public TimeLimitStrategy(TimeSpan repeatPeriod) | ||
58 | { | ||
59 | m_repeatPeriod = repeatPeriod; | ||
60 | } | ||
61 | |||
62 | /// <summary> | ||
63 | /// <see cref="IRequestLimitStrategy"/> | ||
64 | /// </summary> | ||
65 | public bool AllowRequest(TId id) | ||
66 | { | ||
67 | if (IsMonitoringRequests(id)) | ||
68 | { | ||
69 | DateTime now = DateTime.Now; | ||
70 | TimeSpan elapsed = now - requests[id].Time; | ||
71 | |||
72 | if (elapsed < RepeatPeriod) | ||
73 | { | ||
74 | requests[id].Refusals += 1; | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | requests[id].Time = now; | ||
79 | } | ||
80 | |||
81 | return true; | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// <see cref="IRequestLimitStrategy"/> | ||
86 | /// </summary> | ||
87 | public bool IsFirstRefusal(TId id) | ||
88 | { | ||
89 | if (IsMonitoringRequests(id)) | ||
90 | { | ||
91 | if (1 == requests[id].Refusals) | ||
92 | { | ||
93 | return true; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | return false; | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// <see cref="IRequestLimitStrategy"/> | ||
102 | /// </summary> | ||
103 | public void MonitorRequests(TId id) | ||
104 | { | ||
105 | if (!IsMonitoringRequests(id)) | ||
106 | { | ||
107 | requests.Add(id, new Request(DateTime.Now)); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | /// <summary> | ||
112 | /// <see cref="IRequestLimitStrategy"/> | ||
113 | /// </summary> | ||
114 | public bool IsMonitoringRequests(TId id) | ||
115 | { | ||
116 | return requests.ContainsKey(id); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /// <summary> | ||
121 | /// Private request details. | ||
122 | /// </summary> | ||
123 | class Request | ||
124 | { | ||
125 | /// <summary> | ||
126 | /// Time of last request | ||
127 | /// </summary> | ||
128 | public DateTime Time; | ||
129 | |||
130 | /// <summary> | ||
131 | /// Number of refusals associated with this request | ||
132 | /// </summary> | ||
133 | public int Refusals; | ||
134 | |||
135 | public Request(DateTime time) | ||
136 | { | ||
137 | Time = time; | ||
138 | } | ||
139 | } | ||
140 | } | ||
diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs deleted file mode 100644 index 6d1c03a..0000000 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
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.Reflection; | ||
29 | using System.Runtime.InteropServices; | ||
30 | |||
31 | // General information about an assembly is controlled through the following | ||
32 | // set of attributes. Change these attribute values to modify the information | ||
33 | // associated with an assembly. | ||
34 | |||
35 | [assembly : AssemblyTitle("OpenSim.Framework.Communications")] | ||
36 | [assembly : AssemblyDescription("")] | ||
37 | [assembly : AssemblyConfiguration("")] | ||
38 | [assembly : AssemblyCompany("http://opensimulator.org")] | ||
39 | [assembly : AssemblyProduct("OpenSim")] | ||
40 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] | ||
41 | [assembly : AssemblyTrademark("")] | ||
42 | [assembly : AssemblyCulture("")] | ||
43 | |||
44 | // Setting ComVisible to false makes the types in this assembly not visible | ||
45 | // to COM components. If you need to access a type in this assembly from | ||
46 | // COM, set the ComVisible attribute to true on that type. | ||
47 | |||
48 | [assembly : ComVisible(false)] | ||
49 | |||
50 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
51 | |||
52 | [assembly : Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")] | ||
53 | |||
54 | // Version information for an assembly consists of the following four values: | ||
55 | // | ||
56 | // Major Version | ||
57 | // Minor Version | ||
58 | // Build Number | ||
59 | // Revision | ||
60 | // | ||
61 | // You can specify all the values or you can default the Revision and Build Numbers | ||
62 | // by using the '*' as shown below: | ||
63 | |||
64 | [assembly : AssemblyVersion("0.7.5.*")] | ||
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | ||
diff --git a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs deleted file mode 100644 index e37ef28..0000000 --- a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
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.Xml; | ||
31 | using System.Xml.Serialization; | ||
32 | |||
33 | namespace OpenSim.Framework.Communications.XMPP | ||
34 | { | ||
35 | public class XmppSerializer | ||
36 | { | ||
37 | // private static readonly ILog _log = | ||
38 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
39 | |||
40 | // need to do it this way, as XmlSerializer(type, extratypes) | ||
41 | // does not work on mono (at least). | ||
42 | private Dictionary<Type, XmlSerializer> _serializerForType = new Dictionary<Type, XmlSerializer>(); | ||
43 | private Dictionary<string, XmlSerializer> _serializerForName = new Dictionary<string, XmlSerializer>(); | ||
44 | private XmlSerializerNamespaces _xmlNs; | ||
45 | private string _defaultNS; | ||
46 | |||
47 | public XmppSerializer(bool server) | ||
48 | { | ||
49 | _xmlNs = new XmlSerializerNamespaces(); | ||
50 | _xmlNs.Add(String.Empty, String.Empty); | ||
51 | if (server) | ||
52 | _defaultNS = "jabber:server"; | ||
53 | else | ||
54 | _defaultNS = "jabber:client"; | ||
55 | |||
56 | // TODO: do this via reflection | ||
57 | _serializerForType[typeof(XmppMessageStanza)] = _serializerForName["message"] = | ||
58 | new XmlSerializer(typeof(XmppMessageStanza), _defaultNS); | ||
59 | } | ||
60 | |||
61 | public void Serialize(XmlWriter xw, object o) | ||
62 | { | ||
63 | if (!_serializerForType.ContainsKey(o.GetType())) | ||
64 | throw new ArgumentException(String.Format("no serializer available for type {0}", o.GetType())); | ||
65 | |||
66 | _serializerForType[o.GetType()].Serialize(xw, o, _xmlNs); | ||
67 | } | ||
68 | |||
69 | public object Deserialize(XmlReader xr) | ||
70 | { | ||
71 | // position on next element | ||
72 | xr.Read(); | ||
73 | if (!_serializerForName.ContainsKey(xr.LocalName)) | ||
74 | throw new ArgumentException(String.Format("no serializer available for name {0}", xr.LocalName)); | ||
75 | |||
76 | return _serializerForName[xr.LocalName].Deserialize(xr); | ||
77 | } | ||
78 | } | ||
79 | } | ||
diff --git a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs b/OpenSim/Framework/DOMap.cs index 1e8c33e..f5b650b 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs +++ b/OpenSim/Framework/DOMap.cs | |||
@@ -25,69 +25,74 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Text; | ||
33 | using System.Xml; | ||
34 | using System.Xml.Schema; | ||
28 | using System.Xml.Serialization; | 35 | using System.Xml.Serialization; |
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
29 | 38 | ||
30 | namespace OpenSim.Framework.Communications.XMPP | 39 | namespace OpenSim.Framework |
31 | { | 40 | { |
32 | /// <summary> | 41 | /// <summary> |
33 | /// Message types. | 42 | /// This class stores and retrieves dynamic objects. |
34 | /// </summary> | 43 | /// </summary> |
35 | public enum XmppMessageType | 44 | /// <remarks> |
45 | /// Experimental - DO NOT USE. Does not yet have namespace support. | ||
46 | /// </remarks> | ||
47 | public class DOMap | ||
36 | { | 48 | { |
37 | [XmlEnum("chat")] chat, | 49 | private IDictionary<string, object> m_map; |
38 | [XmlEnum("error")] error, | 50 | |
39 | [XmlEnum("groupchat")] groupchat, | 51 | public void Add(string ns, string objName, object dynObj) |
40 | [XmlEnum("headline")] headline, | ||
41 | [XmlEnum("normal")] normal, | ||
42 | } | ||
43 | |||
44 | /// <summary> | ||
45 | /// Message body. | ||
46 | /// </summary> | ||
47 | public class XmppMessageBody | ||
48 | { | ||
49 | [XmlText] | ||
50 | public string Text; | ||
51 | |||
52 | public XmppMessageBody() | ||
53 | { | 52 | { |
54 | } | 53 | DAMap.ValidateNamespace(ns); |
55 | 54 | ||
56 | public XmppMessageBody(string message) | 55 | lock (this) |
57 | { | 56 | { |
58 | Text = message; | 57 | if (m_map == null) |
58 | m_map = new Dictionary<string, object>(); | ||
59 | |||
60 | m_map.Add(objName, dynObj); | ||
61 | } | ||
59 | } | 62 | } |
60 | 63 | ||
61 | new public string ToString() | 64 | public bool ContainsKey(string key) |
62 | { | 65 | { |
63 | return Text; | 66 | return Get(key) != null; |
64 | } | 67 | } |
65 | } | ||
66 | 68 | ||
67 | [XmlRoot("message")] | ||
68 | public class XmppMessageStanza: XmppStanza | ||
69 | { | ||
70 | /// <summary> | 69 | /// <summary> |
71 | /// IQ type: one of set, get, result, error | 70 | /// Get a dynamic object |
72 | /// </summary> | 71 | /// </summary> |
73 | [XmlAttribute("type")] | 72 | /// <remarks> |
74 | public XmppMessageType MessageType; | 73 | /// Not providing an index method so that users can't casually overwrite each other's objects. |
75 | 74 | /// </remarks> | |
76 | // [XmlAttribute("error")] | 75 | /// <param name='key'></param> |
77 | // public XmppError Error; | 76 | public object Get(string key) |
78 | |||
79 | [XmlElement("body")] | ||
80 | public XmppMessageBody Body; | ||
81 | |||
82 | public XmppMessageStanza() : base() | ||
83 | { | 77 | { |
78 | lock (this) | ||
79 | { | ||
80 | if (m_map == null) | ||
81 | return null; | ||
82 | else | ||
83 | return m_map[key]; | ||
84 | } | ||
84 | } | 85 | } |
85 | 86 | ||
86 | public XmppMessageStanza(string fromJid, string toJid, XmppMessageType mType, string message) : | 87 | public bool Remove(string key) |
87 | base(fromJid, toJid) | ||
88 | { | 88 | { |
89 | MessageType = mType; | 89 | lock (this) |
90 | Body = new XmppMessageBody(message); | 90 | { |
91 | if (m_map == null) | ||
92 | return false; | ||
93 | else | ||
94 | return m_map.Remove(key); | ||
95 | } | ||
91 | } | 96 | } |
92 | } | 97 | } |
93 | } | 98 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/RestClient.cs index 97b3b60..7080ca5 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/RestClient.cs | |||
@@ -35,7 +35,9 @@ using System.Threading; | |||
35 | using System.Web; | 35 | using System.Web; |
36 | using log4net; | 36 | using log4net; |
37 | 37 | ||
38 | namespace OpenSim.Framework.Communications | 38 | using OpenSim.Framework.ServiceAuth; |
39 | |||
40 | namespace OpenSim.Framework | ||
39 | { | 41 | { |
40 | /// <summary> | 42 | /// <summary> |
41 | /// Implementation of a generic REST client | 43 | /// Implementation of a generic REST client |
@@ -54,7 +56,7 @@ namespace OpenSim.Framework.Communications | |||
54 | /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be | 56 | /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be |
55 | /// invoked by the caller in either synchronous mode or asynchronous modes. | 57 | /// invoked by the caller in either synchronous mode or asynchronous modes. |
56 | /// </remarks> | 58 | /// </remarks> |
57 | public class RestClient | 59 | public class RestClient : IDisposable |
58 | { | 60 | { |
59 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
60 | 62 | ||
@@ -88,7 +90,7 @@ namespace OpenSim.Framework.Communications | |||
88 | private byte[] _readbuf; | 90 | private byte[] _readbuf; |
89 | 91 | ||
90 | /// <summary> | 92 | /// <summary> |
91 | /// MemoryStream representing the resultiong resource | 93 | /// MemoryStream representing the resulting resource |
92 | /// </summary> | 94 | /// </summary> |
93 | private Stream _resource; | 95 | private Stream _resource; |
94 | 96 | ||
@@ -146,6 +148,33 @@ namespace OpenSim.Framework.Communications | |||
146 | 148 | ||
147 | #endregion constructors | 149 | #endregion constructors |
148 | 150 | ||
151 | |||
152 | #region Dispose | ||
153 | |||
154 | private bool disposed = false; | ||
155 | |||
156 | public void Dispose() | ||
157 | { | ||
158 | Dispose(true); | ||
159 | GC.SuppressFinalize(this); | ||
160 | } | ||
161 | |||
162 | protected virtual void Dispose(bool disposing) | ||
163 | { | ||
164 | if (disposed) | ||
165 | return; | ||
166 | |||
167 | if (disposing) | ||
168 | { | ||
169 | _resource.Dispose(); | ||
170 | } | ||
171 | |||
172 | disposed = true; | ||
173 | } | ||
174 | |||
175 | #endregion Dispose | ||
176 | |||
177 | |||
149 | /// <summary> | 178 | /// <summary> |
150 | /// Add a path element to the query, e.g. assets | 179 | /// Add a path element to the query, e.g. assets |
151 | /// </summary> | 180 | /// </summary> |
@@ -299,6 +328,14 @@ namespace OpenSim.Framework.Communications | |||
299 | /// </summary> | 328 | /// </summary> |
300 | public Stream Request() | 329 | public Stream Request() |
301 | { | 330 | { |
331 | return Request(null); | ||
332 | } | ||
333 | |||
334 | /// <summary> | ||
335 | /// Perform a synchronous request | ||
336 | /// </summary> | ||
337 | public Stream Request(IServiceAuth auth) | ||
338 | { | ||
302 | lock (_lock) | 339 | lock (_lock) |
303 | { | 340 | { |
304 | _request = (HttpWebRequest) WebRequest.Create(buildUri()); | 341 | _request = (HttpWebRequest) WebRequest.Create(buildUri()); |
@@ -307,44 +344,54 @@ namespace OpenSim.Framework.Communications | |||
307 | _request.Timeout = 200000; | 344 | _request.Timeout = 200000; |
308 | _request.Method = RequestMethod; | 345 | _request.Method = RequestMethod; |
309 | _asyncException = null; | 346 | _asyncException = null; |
347 | if (auth != null) | ||
348 | auth.AddAuthorization(_request.Headers); | ||
349 | |||
350 | int reqnum = WebUtil.RequestNumber++; | ||
351 | if (WebUtil.DebugLevel >= 3) | ||
352 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri); | ||
310 | 353 | ||
311 | // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); | 354 | // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); |
355 | |||
312 | try | 356 | try |
313 | { | 357 | { |
314 | _response = (HttpWebResponse) _request.GetResponse(); | 358 | using (_response = (HttpWebResponse) _request.GetResponse()) |
359 | { | ||
360 | using (Stream src = _response.GetResponseStream()) | ||
361 | { | ||
362 | int length = src.Read(_readbuf, 0, BufferSize); | ||
363 | while (length > 0) | ||
364 | { | ||
365 | _resource.Write(_readbuf, 0, length); | ||
366 | length = src.Read(_readbuf, 0, BufferSize); | ||
367 | } | ||
368 | |||
369 | // TODO! Implement timeout, without killing the server | ||
370 | // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted | ||
371 | //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); | ||
372 | |||
373 | // _allDone.WaitOne(); | ||
374 | } | ||
375 | } | ||
315 | } | 376 | } |
316 | catch (WebException e) | 377 | catch (WebException e) |
317 | { | 378 | { |
318 | HttpWebResponse errorResponse = e.Response as HttpWebResponse; | 379 | using (HttpWebResponse errorResponse = e.Response as HttpWebResponse) |
319 | if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) | ||
320 | { | ||
321 | m_log.Warn("[REST CLIENT] Resource not found (404)"); | ||
322 | } | ||
323 | else | ||
324 | { | 380 | { |
325 | m_log.Error("[REST CLIENT] Error fetching resource from server " + _request.Address.ToString()); | 381 | if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) |
326 | m_log.Debug(e.ToString()); | 382 | { |
383 | // This is often benign. E.g., requesting a missing asset will return 404. | ||
384 | m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString()); | ||
385 | } | ||
386 | else | ||
387 | { | ||
388 | m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e); | ||
389 | } | ||
327 | } | 390 | } |
328 | 391 | ||
329 | return null; | 392 | return null; |
330 | } | 393 | } |
331 | 394 | ||
332 | Stream src = _response.GetResponseStream(); | ||
333 | int length = src.Read(_readbuf, 0, BufferSize); | ||
334 | while (length > 0) | ||
335 | { | ||
336 | _resource.Write(_readbuf, 0, length); | ||
337 | length = src.Read(_readbuf, 0, BufferSize); | ||
338 | } | ||
339 | |||
340 | |||
341 | // TODO! Implement timeout, without killing the server | ||
342 | // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted | ||
343 | //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); | ||
344 | |||
345 | // _allDone.WaitOne(); | ||
346 | if (_response != null) | ||
347 | _response.Close(); | ||
348 | if (_asyncException != null) | 395 | if (_asyncException != null) |
349 | throw _asyncException; | 396 | throw _asyncException; |
350 | 397 | ||
@@ -354,11 +401,14 @@ namespace OpenSim.Framework.Communications | |||
354 | _resource.Seek(0, SeekOrigin.Begin); | 401 | _resource.Seek(0, SeekOrigin.Begin); |
355 | } | 402 | } |
356 | 403 | ||
404 | if (WebUtil.DebugLevel >= 5) | ||
405 | WebUtil.LogResponseDetail(reqnum, _resource); | ||
406 | |||
357 | return _resource; | 407 | return _resource; |
358 | } | 408 | } |
359 | } | 409 | } |
360 | 410 | ||
361 | public Stream Request(Stream src) | 411 | public Stream Request(Stream src, IServiceAuth auth) |
362 | { | 412 | { |
363 | _request = (HttpWebRequest) WebRequest.Create(buildUri()); | 413 | _request = (HttpWebRequest) WebRequest.Create(buildUri()); |
364 | _request.KeepAlive = false; | 414 | _request.KeepAlive = false; |
@@ -367,24 +417,58 @@ namespace OpenSim.Framework.Communications | |||
367 | _request.Method = RequestMethod; | 417 | _request.Method = RequestMethod; |
368 | _asyncException = null; | 418 | _asyncException = null; |
369 | _request.ContentLength = src.Length; | 419 | _request.ContentLength = src.Length; |
420 | if (auth != null) | ||
421 | auth.AddAuthorization(_request.Headers); | ||
370 | 422 | ||
371 | m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); | ||
372 | m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); | ||
373 | src.Seek(0, SeekOrigin.Begin); | 423 | src.Seek(0, SeekOrigin.Begin); |
374 | m_log.Info("[REST]: Seek is ok"); | 424 | |
425 | int reqnum = WebUtil.RequestNumber++; | ||
426 | if (WebUtil.DebugLevel >= 3) | ||
427 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri); | ||
428 | if (WebUtil.DebugLevel >= 5) | ||
429 | WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src); | ||
430 | |||
375 | Stream dst = _request.GetRequestStream(); | 431 | Stream dst = _request.GetRequestStream(); |
376 | m_log.Info("[REST]: GetRequestStream is ok"); | ||
377 | 432 | ||
378 | byte[] buf = new byte[1024]; | 433 | byte[] buf = new byte[1024]; |
379 | int length = src.Read(buf, 0, 1024); | 434 | int length = src.Read(buf, 0, 1024); |
380 | m_log.Info("[REST]: First Read is ok"); | ||
381 | while (length > 0) | 435 | while (length > 0) |
382 | { | 436 | { |
383 | dst.Write(buf, 0, length); | 437 | dst.Write(buf, 0, length); |
384 | length = src.Read(buf, 0, 1024); | 438 | length = src.Read(buf, 0, 1024); |
385 | } | 439 | } |
386 | 440 | ||
387 | _response = (HttpWebResponse) _request.GetResponse(); | 441 | try |
442 | { | ||
443 | _response = (HttpWebResponse)_request.GetResponse(); | ||
444 | } | ||
445 | catch (WebException e) | ||
446 | { | ||
447 | m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}", | ||
448 | RequestMethod, _request.RequestUri, e.Status, e.Message); | ||
449 | return null; | ||
450 | } | ||
451 | catch (Exception e) | ||
452 | { | ||
453 | m_log.WarnFormat( | ||
454 | "[REST]: Request {0} {1} failed with exception {2} {3}", | ||
455 | RequestMethod, _request.RequestUri, e.Message, e.StackTrace); | ||
456 | return null; | ||
457 | } | ||
458 | |||
459 | if (WebUtil.DebugLevel >= 5) | ||
460 | { | ||
461 | using (Stream responseStream = _response.GetResponseStream()) | ||
462 | { | ||
463 | using (StreamReader reader = new StreamReader(responseStream)) | ||
464 | { | ||
465 | string responseStr = reader.ReadToEnd(); | ||
466 | WebUtil.LogResponseDetail(reqnum, responseStr); | ||
467 | } | ||
468 | } | ||
469 | } | ||
470 | |||
471 | _response.Close(); | ||
388 | 472 | ||
389 | // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); | 473 | // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); |
390 | 474 | ||
@@ -403,7 +487,7 @@ namespace OpenSim.Framework.Communications | |||
403 | /// In case, we are invoked asynchroneously this object will keep track of the state | 487 | /// In case, we are invoked asynchroneously this object will keep track of the state |
404 | /// </summary> | 488 | /// </summary> |
405 | AsyncResult<Stream> ar = new AsyncResult<Stream>(callback, state); | 489 | AsyncResult<Stream> ar = new AsyncResult<Stream>(callback, state); |
406 | Util.FireAndForget(RequestHelper, ar); | 490 | Util.FireAndForget(RequestHelper, ar, "RestClient.BeginRequest"); |
407 | return ar; | 491 | return ar; |
408 | } | 492 | } |
409 | 493 | ||
@@ -423,7 +507,7 @@ namespace OpenSim.Framework.Communications | |||
423 | try | 507 | try |
424 | { | 508 | { |
425 | // Perform the operation; if sucessful set the result | 509 | // Perform the operation; if sucessful set the result |
426 | Stream s = Request(); | 510 | Stream s = Request(null); |
427 | ar.SetAsCompleted(s, false); | 511 | ar.SetAsCompleted(s, false); |
428 | } | 512 | } |
429 | catch (Exception e) | 513 | catch (Exception e) |
@@ -435,4 +519,158 @@ namespace OpenSim.Framework.Communications | |||
435 | 519 | ||
436 | #endregion Async Invocation | 520 | #endregion Async Invocation |
437 | } | 521 | } |
438 | } | 522 | |
523 | internal class SimpleAsyncResult : IAsyncResult | ||
524 | { | ||
525 | private readonly AsyncCallback m_callback; | ||
526 | |||
527 | /// <summary> | ||
528 | /// Is process completed? | ||
529 | /// </summary> | ||
530 | /// <remarks>Should really be boolean, but VolatileRead has no boolean method</remarks> | ||
531 | private byte m_completed; | ||
532 | |||
533 | /// <summary> | ||
534 | /// Did process complete synchronously? | ||
535 | /// </summary> | ||
536 | /// <remarks>I have a hard time imagining a scenario where this is the case, again, same issue about | ||
537 | /// booleans and VolatileRead as m_completed | ||
538 | /// </remarks> | ||
539 | private byte m_completedSynchronously; | ||
540 | |||
541 | private readonly object m_asyncState; | ||
542 | private ManualResetEvent m_waitHandle; | ||
543 | private Exception m_exception; | ||
544 | |||
545 | internal SimpleAsyncResult(AsyncCallback cb, object state) | ||
546 | { | ||
547 | m_callback = cb; | ||
548 | m_asyncState = state; | ||
549 | m_completed = 0; | ||
550 | m_completedSynchronously = 1; | ||
551 | } | ||
552 | |||
553 | #region IAsyncResult Members | ||
554 | |||
555 | public object AsyncState | ||
556 | { | ||
557 | get { return m_asyncState; } | ||
558 | } | ||
559 | |||
560 | public WaitHandle AsyncWaitHandle | ||
561 | { | ||
562 | get | ||
563 | { | ||
564 | if (m_waitHandle == null) | ||
565 | { | ||
566 | bool done = IsCompleted; | ||
567 | ManualResetEvent mre = new ManualResetEvent(done); | ||
568 | if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) | ||
569 | { | ||
570 | mre.Close(); | ||
571 | } | ||
572 | else | ||
573 | { | ||
574 | if (!done && IsCompleted) | ||
575 | { | ||
576 | m_waitHandle.Set(); | ||
577 | } | ||
578 | } | ||
579 | } | ||
580 | |||
581 | return m_waitHandle; | ||
582 | } | ||
583 | } | ||
584 | |||
585 | |||
586 | public bool CompletedSynchronously | ||
587 | { | ||
588 | get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } | ||
589 | } | ||
590 | |||
591 | |||
592 | public bool IsCompleted | ||
593 | { | ||
594 | get { return Thread.VolatileRead(ref m_completed) == 1; } | ||
595 | } | ||
596 | |||
597 | #endregion | ||
598 | |||
599 | #region class Methods | ||
600 | |||
601 | internal void SetAsCompleted(bool completedSynchronously) | ||
602 | { | ||
603 | m_completed = 1; | ||
604 | if (completedSynchronously) | ||
605 | m_completedSynchronously = 1; | ||
606 | else | ||
607 | m_completedSynchronously = 0; | ||
608 | |||
609 | SignalCompletion(); | ||
610 | } | ||
611 | |||
612 | internal void HandleException(Exception e, bool completedSynchronously) | ||
613 | { | ||
614 | m_completed = 1; | ||
615 | if (completedSynchronously) | ||
616 | m_completedSynchronously = 1; | ||
617 | else | ||
618 | m_completedSynchronously = 0; | ||
619 | m_exception = e; | ||
620 | |||
621 | SignalCompletion(); | ||
622 | } | ||
623 | |||
624 | private void SignalCompletion() | ||
625 | { | ||
626 | if (m_waitHandle != null) m_waitHandle.Set(); | ||
627 | |||
628 | if (m_callback != null) m_callback(this); | ||
629 | } | ||
630 | |||
631 | public void EndInvoke() | ||
632 | { | ||
633 | // This method assumes that only 1 thread calls EndInvoke | ||
634 | if (!IsCompleted) | ||
635 | { | ||
636 | // If the operation isn't done, wait for it | ||
637 | AsyncWaitHandle.WaitOne(); | ||
638 | AsyncWaitHandle.Close(); | ||
639 | m_waitHandle.Close(); | ||
640 | m_waitHandle = null; // Allow early GC | ||
641 | } | ||
642 | |||
643 | // Operation is done: if an exception occured, throw it | ||
644 | if (m_exception != null) throw m_exception; | ||
645 | } | ||
646 | |||
647 | #endregion | ||
648 | } | ||
649 | |||
650 | internal class AsyncResult<T> : SimpleAsyncResult | ||
651 | { | ||
652 | private T m_result = default(T); | ||
653 | |||
654 | public AsyncResult(AsyncCallback asyncCallback, Object state) : | ||
655 | base(asyncCallback, state) | ||
656 | { | ||
657 | } | ||
658 | |||
659 | public void SetAsCompleted(T result, bool completedSynchronously) | ||
660 | { | ||
661 | // Save the asynchronous operation's result | ||
662 | m_result = result; | ||
663 | |||
664 | // Tell the base class that the operation completed | ||
665 | // sucessfully (no exception) | ||
666 | base.SetAsCompleted(completedSynchronously); | ||
667 | } | ||
668 | |||
669 | public new T EndInvoke() | ||
670 | { | ||
671 | base.EndInvoke(); | ||
672 | return m_result; | ||
673 | } | ||
674 | } | ||
675 | |||
676 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs b/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs index 4d45ac0..72b3065 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs | |||
@@ -25,45 +25,36 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Xml.Serialization; | 28 | using System.IO; |
29 | 29 | ||
30 | namespace OpenSim.Framework.Communications.XMPP | 30 | namespace OpenSim.Framework.Servers.HttpServer |
31 | { | 31 | { |
32 | /// <summary> | 32 | /// <summary> |
33 | /// Message types. | 33 | /// Base handler for writing to an output stream |
34 | /// </summary> | 34 | /// </summary> |
35 | public enum XmppPresenceType | 35 | /// <remarks> |
36 | /// Inheriting classes should override ProcessRequest() rather than Handle() | ||
37 | /// </remarks> | ||
38 | public abstract class BaseOutputStreamHandler : BaseRequestHandler, IRequestHandler | ||
36 | { | 39 | { |
37 | [XmlEnum("unavailable")] unavailable, | 40 | protected BaseOutputStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} |
38 | [XmlEnum("subscribe")] subscribe, | ||
39 | [XmlEnum("subscribed")] subscribed, | ||
40 | [XmlEnum("unsubscribe")] unsubscribe, | ||
41 | [XmlEnum("unsubscribed")] unsubscribed, | ||
42 | [XmlEnum("probe")] probe, | ||
43 | [XmlEnum("error")] error, | ||
44 | } | ||
45 | 41 | ||
42 | protected BaseOutputStreamHandler(string httpMethod, string path, string name, string description) | ||
43 | : base(httpMethod, path, name, description) {} | ||
46 | 44 | ||
47 | [XmlRoot("message")] | 45 | public virtual void Handle( |
48 | public class XmppPresenceStanza: XmppStanza | 46 | string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
49 | { | 47 | { |
50 | /// <summary> | 48 | RequestsReceived++; |
51 | /// IQ type: one of set, get, result, error | ||
52 | /// </summary> | ||
53 | [XmlAttribute("type")] | ||
54 | public XmppPresenceType PresenceType; | ||
55 | 49 | ||
56 | // [XmlAttribute("error")] | 50 | ProcessRequest(path, request, response, httpRequest, httpResponse); |
57 | // public XmppError Error; | ||
58 | 51 | ||
59 | public XmppPresenceStanza() : base() | 52 | RequestsHandled++; |
60 | { | ||
61 | } | 53 | } |
62 | 54 | ||
63 | public XmppPresenceStanza(string fromJid, string toJid, XmppPresenceType pType) : | 55 | protected virtual void ProcessRequest( |
64 | base(fromJid, toJid) | 56 | string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
65 | { | 57 | { |
66 | PresenceType = pType; | ||
67 | } | 58 | } |
68 | } | 59 | } |
69 | } | 60 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs index 5312a31..78a43db 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs | |||
@@ -26,45 +26,35 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml.Serialization; | 29 | using OpenSim.Region.Framework.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Framework.Communications.XMPP | 31 | namespace OpenSim.Region.CoreModules.World.Terrain |
32 | { | 32 | { |
33 | public abstract class XmppStanza | 33 | public interface ITerrainFeature |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// counter used for generating ID | 36 | /// Creates the feature. |
37 | /// </summary> | 37 | /// </summary> |
38 | [XmlIgnore] | 38 | /// <returns> |
39 | private static ulong _ctr = 0; | 39 | /// Empty string if successful, otherwise error message. |
40 | /// </returns> | ||
41 | /// <param name='map'> | ||
42 | /// ITerrainChannel holding terrain data. | ||
43 | /// </param> | ||
44 | /// <param name='args'> | ||
45 | /// command-line arguments from console. | ||
46 | /// </param> | ||
47 | string CreateFeature(ITerrainChannel map, string[] args); | ||
40 | 48 | ||
41 | /// <summary> | 49 | /// <summary> |
42 | /// recipient JID | 50 | /// Gets a string describing the usage. |
43 | /// </summary> | 51 | /// </summary> |
44 | [XmlAttribute("to")] | 52 | /// <returns> |
45 | public string ToJid; | 53 | /// A string describing parameters for creating the feature. |
46 | 54 | /// Format is "feature-name <arg1> <arg2> ..." | |
47 | /// <summary> | 55 | /// </returns> |
48 | /// sender JID | 56 | string GetUsage(); |
49 | /// </summary> | ||
50 | [XmlAttribute("from")] | ||
51 | public string FromJid; | ||
52 | |||
53 | /// <summary> | ||
54 | /// unique ID. | ||
55 | /// </summary> | ||
56 | [XmlAttribute("id")] | ||
57 | public string MessageId; | ||
58 | |||
59 | public XmppStanza() | ||
60 | { | ||
61 | } | ||
62 | |||
63 | public XmppStanza(string fromJid, string toJid) | ||
64 | { | ||
65 | ToJid = toJid; | ||
66 | FromJid = fromJid; | ||
67 | MessageId = String.Format("OpenSim_{0}{1}", DateTime.UtcNow.Ticks, _ctr++); | ||
68 | } | ||
69 | } | 57 | } |
58 | |||
70 | } | 59 | } |
60 | |||
diff --git a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs b/OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs index 12263f4..a730cfd 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs +++ b/OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs | |||
@@ -25,36 +25,24 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Xml.Serialization; | 28 | using System; |
29 | using OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | using Caps=OpenSim.Framework.Capabilities.Caps; | ||
29 | 32 | ||
30 | namespace OpenSim.Framework.Communications.XMPP | 33 | namespace OpenSim.Region.Framework.Interfaces |
31 | { | 34 | { |
32 | /// <summary> | 35 | public interface IExternalCapsModule |
33 | /// An IQ needs to have one of the follow types set. | ||
34 | /// </summary> | ||
35 | public enum XmppIqType | ||
36 | { | ||
37 | [XmlEnum("set")] set, | ||
38 | [XmlEnum("get")] get, | ||
39 | [XmlEnum("result")] result, | ||
40 | [XmlEnum("error")] error, | ||
41 | } | ||
42 | |||
43 | /// <summary> | ||
44 | /// XmppIqStanza needs to be subclassed as the query content is | ||
45 | /// specific to the query type. | ||
46 | /// </summary> | ||
47 | [XmlRoot("iq")] | ||
48 | public abstract class XmppIqStanza: XmppStanza | ||
49 | { | 36 | { |
50 | /// <summary> | 37 | /// <summary> |
51 | /// IQ type: one of set, get, result, error | 38 | /// This function extends the simple URL configuration in the caps handlers |
39 | /// to facilitate more interesting computation when an external handler is | ||
40 | /// sent to the viewer. | ||
52 | /// </summary> | 41 | /// </summary> |
53 | [XmlAttribute("type")] | 42 | /// <param name="agentID">New user UUID</param> |
54 | public XmppIqType Type; | 43 | /// <param name="caps">Internal caps registry, where the external handler will be registered</param> |
55 | 44 | /// <param name="capName">Name of the specific cap we are registering</param> | |
56 | public XmppIqStanza(): base() | 45 | /// <param name="urlSkel">The skeleton URL provided in the caps configuration</param> |
57 | { | 46 | bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel); |
58 | } | ||
59 | } | 47 | } |
60 | } | 48 | } |
diff --git a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs index 415d808..0be1f4c 100644..100755 --- a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs | |||
@@ -1,57 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.IO; | 28 | using System; |
29 | using System.Text; | 29 | using System.Collections.Generic; |
30 | using System.Xml; | 30 | using System.Linq; |
31 | using IOStream = System.IO.Stream; | 31 | using System.Text; |
32 | 32 | ||
33 | namespace OpenSim.Framework.Communications.XMPP | 33 | using NUnit.Framework; |
34 | { | 34 | using log4net; |
35 | public class XMPPWriter: XmlTextWriter | 35 | |
36 | { | 36 | using OpenSim.Tests.Common; |
37 | public XMPPWriter(TextWriter textWriter) : base(textWriter) | 37 | |
38 | { | 38 | namespace OpenSim.Region.PhysicsModule.BulletS.Tests |
39 | } | 39 | { |
40 | 40 | [TestFixture] | |
41 | public XMPPWriter(IOStream stream) : this(stream, Util.UTF8) | 41 | public class BulletSimTests : OpenSimTestCase |
42 | { | 42 | { |
43 | } | 43 | // Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1 |
44 | 44 | // Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1 | |
45 | public XMPPWriter(IOStream stream, Encoding enc) : base(stream, enc) | 45 | |
46 | { | 46 | [TestFixtureSetUp] |
47 | } | 47 | public void Init() |
48 | 48 | { | |
49 | public override void WriteStartDocument() | 49 | } |
50 | { | 50 | |
51 | } | 51 | [TestFixtureTearDown] |
52 | 52 | public void TearDown() | |
53 | public override void WriteStartDocument(bool standalone) | 53 | { |
54 | { | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
57 | } | ||
diff --git a/OpenSim/Framework/Communications/XMPP/XmppError.cs b/OpenSim/Services/Interfaces/IBakedTextureService.cs index 3d36e9c..69df4a0 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppError.cs +++ b/OpenSim/Services/Interfaces/IBakedTextureService.cs | |||
@@ -25,15 +25,14 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Xml.Serialization; | 28 | using System; |
29 | using Nini.Config; | ||
29 | 30 | ||
30 | namespace OpenSim.Framework.Communications.XMPP | 31 | namespace OpenSim.Services.Interfaces |
31 | { | 32 | { |
32 | [XmlRoot("error")] | 33 | public interface IBakedTextureService |
33 | public class XmppErrorStanza | ||
34 | { | 34 | { |
35 | public XmppErrorStanza() | 35 | string Get(string id); |
36 | { | 36 | void Store(string id, string data); |
37 | } | ||
38 | } | 37 | } |
39 | } | 38 | } |