clockwerk-opensim-stable – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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;
30 using System.Collections.Generic;
31 using System.IO;
32 using System.Net;
33 using System.Reflection;
34 using System.Text;
35 using OpenSim.Framework;
36 using OpenSim.Services.Interfaces;
37 using OpenSim.Services.Connectors.Simulation;
38 using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 using OpenMetaverse;
40 using OpenMetaverse.StructuredData;
41 using log4net;
42 using Nwc.XmlRpc;
43 using Nini.Config;
44  
45 namespace OpenSim.Services.Connectors.Hypergrid
46 {
47 public class UserAgentServiceConnector : SimulationServiceConnector, IUserAgentService
48 {
49 private static readonly ILog m_log =
50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType);
52  
53 private string m_ServerURL;
54 private GridRegion m_Gatekeeper;
55  
56 public UserAgentServiceConnector(string url) : this(url, true)
57 {
58 }
59  
60 public UserAgentServiceConnector(string url, bool dnsLookup)
61 {
62 m_ServerURL = url;
63  
64 if (dnsLookup)
65 {
66 // Doing this here, because XML-RPC or mono have some strong ideas about
67 // caching DNS translations.
68 try
69 {
70 Uri m_Uri = new Uri(m_ServerURL);
71 IPAddress ip = Util.GetHostFromDNS(m_Uri.Host);
72 m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString());
73 if (!m_ServerURL.EndsWith("/"))
74 m_ServerURL += "/";
75 }
76 catch (Exception e)
77 {
78 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message);
79 }
80 }
81 m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
82 }
83  
84 public UserAgentServiceConnector(IConfigSource config)
85 {
86 IConfig serviceConfig = config.Configs["UserAgentService"];
87 if (serviceConfig == null)
88 {
89 m_log.Error("[USER AGENT CONNECTOR]: UserAgentService missing from ini");
90 throw new Exception("UserAgent connector init error");
91 }
92  
93 string serviceURI = serviceConfig.GetString("UserAgentServerURI",
94 String.Empty);
95  
96 if (serviceURI == String.Empty)
97 {
98 m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService");
99 throw new Exception("UserAgent connector init error");
100 }
101 m_ServerURL = serviceURI;
102 if (!m_ServerURL.EndsWith("/"))
103 m_ServerURL += "/";
104  
105 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
106 }
107  
108 protected override string AgentPath()
109 {
110 return "homeagent/";
111 }
112  
113 // The Login service calls this interface with fromLogin=true
114 // Sims call it with fromLogin=false
115 // Either way, this is verified by the handler
116 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason)
117 {
118 reason = String.Empty;
119  
120 if (destination == null)
121 {
122 reason = "Destination is null";
123 m_log.Debug("[USER AGENT CONNECTOR]: Given destination is null");
124 return false;
125 }
126  
127 GridRegion home = new GridRegion();
128 home.ServerURI = m_ServerURL;
129 home.RegionID = destination.RegionID;
130 home.RegionLocX = destination.RegionLocX;
131 home.RegionLocY = destination.RegionLocY;
132  
133 m_Gatekeeper = gatekeeper;
134  
135 Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
136  
137 uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
138 return CreateAgent(home, aCircuit, flags, out reason);
139 }
140  
141  
142 // The simulators call this interface
143 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
144 {
145 return LoginAgentToGrid(aCircuit, gatekeeper, destination, false, out reason);
146 }
147  
148 protected override void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags)
149 {
150 base.PackData(args, aCircuit, destination, flags);
151 args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI);
152 args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName);
153 args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString());
154 args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
155 }
156  
157 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress)
158 {
159 OSDMap args = null;
160 try
161 {
162 args = aCircuit.PackAgentCircuitData();
163 }
164 catch (Exception e)
165 {
166 m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message);
167 }
168  
169 // Add the input arguments
170 args["gatekeeper_serveruri"] = OSD.FromString(gatekeeper.ServerURI);
171 args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName);
172 args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString());
173 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
174 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
175 args["destination_name"] = OSD.FromString(destination.RegionName);
176 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
177 args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
178  
179 // 10/3/2010
180 // I added the client_ip up to the regular AgentCircuitData, so this doesn't need to be here.
181 // This need cleaning elsewhere...
182 //if (ipaddress != null)
183 // args["client_ip"] = OSD.FromString(ipaddress.Address.ToString());
184  
185 return args;
186 }
187  
188 public void SetClientToken(UUID sessionID, string token)
189 {
190 // no-op
191 }
192  
193 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
194 {
195 position = Vector3.UnitY; lookAt = Vector3.UnitY;
196  
197 Hashtable hash = new Hashtable();
198 hash["userID"] = userID.ToString();
199  
200 IList paramList = new ArrayList();
201 paramList.Add(hash);
202  
203 XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList);
204 XmlRpcResponse response = null;
205 try
206 {
207 response = request.Send(m_ServerURL, 10000);
208 }
209 catch (Exception)
210 {
211 return null;
212 }
213  
214 if (response.IsFault)
215 {
216 return null;
217 }
218  
219 hash = (Hashtable)response.Value;
220 //foreach (Object o in hash)
221 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
222 try
223 {
224 bool success = false;
225 Boolean.TryParse((string)hash["result"], out success);
226 if (success)
227 {
228 GridRegion region = new GridRegion();
229  
230 UUID.TryParse((string)hash["uuid"], out region.RegionID);
231 //m_log.Debug(">> HERE, uuid: " + region.RegionID);
232 int n = 0;
233 if (hash["x"] != null)
234 {
235 Int32.TryParse((string)hash["x"], out n);
236 region.RegionLocX = n;
237 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
238 }
239 if (hash["y"] != null)
240 {
241 Int32.TryParse((string)hash["y"], out n);
242 region.RegionLocY = n;
243 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
244 }
245 if (hash["region_name"] != null)
246 {
247 region.RegionName = (string)hash["region_name"];
248 //m_log.Debug(">> HERE, name: " + region.RegionName);
249 }
250 if (hash["hostname"] != null)
251 region.ExternalHostName = (string)hash["hostname"];
252 if (hash["http_port"] != null)
253 {
254 uint p = 0;
255 UInt32.TryParse((string)hash["http_port"], out p);
256 region.HttpPort = p;
257 }
258 if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
259 region.ServerURI = (string)hash["server_uri"];
260  
261 if (hash["internal_port"] != null)
262 {
263 int p = 0;
264 Int32.TryParse((string)hash["internal_port"], out p);
265 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
266 }
267 if (hash["position"] != null)
268 Vector3.TryParse((string)hash["position"], out position);
269 if (hash["lookAt"] != null)
270 Vector3.TryParse((string)hash["lookAt"], out lookAt);
271  
272 // Successful return
273 return region;
274 }
275  
276 }
277 catch (Exception)
278 {
279 return null;
280 }
281  
282 return null;
283 }
284  
285 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
286 {
287 Hashtable hash = new Hashtable();
288 hash["sessionID"] = sessionID.ToString();
289 hash["externalName"] = thisGridExternalName;
290  
291 IList paramList = new ArrayList();
292 paramList.Add(hash);
293  
294 XmlRpcRequest request = new XmlRpcRequest("agent_is_coming_home", paramList);
295 string reason = string.Empty;
296 return GetBoolResponse(request, out reason);
297 }
298  
299 public bool VerifyAgent(UUID sessionID, string token)
300 {
301 Hashtable hash = new Hashtable();
302 hash["sessionID"] = sessionID.ToString();
303 hash["token"] = token;
304  
305 IList paramList = new ArrayList();
306 paramList.Add(hash);
307  
308 XmlRpcRequest request = new XmlRpcRequest("verify_agent", paramList);
309 string reason = string.Empty;
310 return GetBoolResponse(request, out reason);
311 }
312  
313 public bool VerifyClient(UUID sessionID, string token)
314 {
315 Hashtable hash = new Hashtable();
316 hash["sessionID"] = sessionID.ToString();
317 hash["token"] = token;
318  
319 IList paramList = new ArrayList();
320 paramList.Add(hash);
321  
322 XmlRpcRequest request = new XmlRpcRequest("verify_client", paramList);
323 string reason = string.Empty;
324 return GetBoolResponse(request, out reason);
325 }
326  
327 public void LogoutAgent(UUID userID, UUID sessionID)
328 {
329 Hashtable hash = new Hashtable();
330 hash["sessionID"] = sessionID.ToString();
331 hash["userID"] = userID.ToString();
332  
333 IList paramList = new ArrayList();
334 paramList.Add(hash);
335  
336 XmlRpcRequest request = new XmlRpcRequest("logout_agent", paramList);
337 string reason = string.Empty;
338 GetBoolResponse(request, out reason);
339 }
340  
341 [Obsolete]
342 public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online)
343 {
344 Hashtable hash = new Hashtable();
345 hash["userID"] = userID.ToString();
346 hash["online"] = online.ToString();
347 int i = 0;
348 foreach (string s in friends)
349 {
350 hash["friend_" + i.ToString()] = s;
351 i++;
352 }
353  
354 IList paramList = new ArrayList();
355 paramList.Add(hash);
356  
357 XmlRpcRequest request = new XmlRpcRequest("status_notification", paramList);
358 // string reason = string.Empty;
359  
360 // Send and get reply
361 List<UUID> friendsOnline = new List<UUID>();
362 XmlRpcResponse response = null;
363 try
364 {
365 response = request.Send(m_ServerURL, 6000);
366 }
367 catch
368 {
369 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURL);
370 // reason = "Exception: " + e.Message;
371 return friendsOnline;
372 }
373  
374 if (response.IsFault)
375 {
376 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURL, response.FaultString);
377 // reason = "XMLRPC Fault";
378 return friendsOnline;
379 }
380  
381 hash = (Hashtable)response.Value;
382 //foreach (Object o in hash)
383 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
384 try
385 {
386 if (hash == null)
387 {
388 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
389 // reason = "Internal error 1";
390 return friendsOnline;
391 }
392  
393 // Here is the actual response
394 foreach (object key in hash.Keys)
395 {
396 if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null)
397 {
398 UUID uuid;
399 if (UUID.TryParse(hash[key].ToString(), out uuid))
400 friendsOnline.Add(uuid);
401 }
402 }
403  
404 }
405 catch
406 {
407 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
408 // reason = "Exception: " + e.Message;
409 }
410  
411 return friendsOnline;
412 }
413  
414 [Obsolete]
415 public List<UUID> GetOnlineFriends(UUID userID, List<string> friends)
416 {
417 Hashtable hash = new Hashtable();
418 hash["userID"] = userID.ToString();
419 int i = 0;
420 foreach (string s in friends)
421 {
422 hash["friend_" + i.ToString()] = s;
423 i++;
424 }
425  
426 IList paramList = new ArrayList();
427 paramList.Add(hash);
428  
429 XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList);
430 // string reason = string.Empty;
431  
432 // Send and get reply
433 List<UUID> online = new List<UUID>();
434 XmlRpcResponse response = null;
435 try
436 {
437 response = request.Send(m_ServerURL, 10000);
438 }
439 catch
440 {
441 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURL);
442 // reason = "Exception: " + e.Message;
443 return online;
444 }
445  
446 if (response.IsFault)
447 {
448 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURL, response.FaultString);
449 // reason = "XMLRPC Fault";
450 return online;
451 }
452  
453 hash = (Hashtable)response.Value;
454 //foreach (Object o in hash)
455 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
456 try
457 {
458 if (hash == null)
459 {
460 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
461 // reason = "Internal error 1";
462 return online;
463 }
464  
465 // Here is the actual response
466 foreach (object key in hash.Keys)
467 {
468 if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null)
469 {
470 UUID uuid;
471 if (UUID.TryParse(hash[key].ToString(), out uuid))
472 online.Add(uuid);
473 }
474 }
475  
476 }
477 catch
478 {
479 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
480 // reason = "Exception: " + e.Message;
481 }
482  
483 return online;
484 }
485  
486 public Dictionary<string,object> GetUserInfo (UUID userID)
487 {
488 Hashtable hash = new Hashtable();
489 hash["userID"] = userID.ToString();
490  
491 IList paramList = new ArrayList();
492 paramList.Add(hash);
493  
494 XmlRpcRequest request = new XmlRpcRequest("get_user_info", paramList);
495  
496 Dictionary<string, object> info = new Dictionary<string, object>();
497 XmlRpcResponse response = null;
498 try
499 {
500 response = request.Send(m_ServerURL, 10000);
501 }
502 catch
503 {
504 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUserInfo", m_ServerURL);
505 return info;
506 }
507  
508 if (response.IsFault)
509 {
510 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
511 return info;
512 }
513  
514 hash = (Hashtable)response.Value;
515 try
516 {
517 if (hash == null)
518 {
519 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUserInfo Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
520 return info;
521 }
522  
523 // Here is the actual response
524 foreach (object key in hash.Keys)
525 {
526 if (hash[key] != null)
527 {
528 info.Add(key.ToString(), hash[key]);
529 }
530 }
531 }
532 catch
533 {
534 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
535 }
536  
537 return info;
538 }
539  
540 public Dictionary<string, object> GetServerURLs(UUID userID)
541 {
542 Hashtable hash = new Hashtable();
543 hash["userID"] = userID.ToString();
544  
545 IList paramList = new ArrayList();
546 paramList.Add(hash);
547  
548 XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList);
549 // string reason = string.Empty;
550  
551 // Send and get reply
552 Dictionary<string, object> serverURLs = new Dictionary<string,object>();
553 XmlRpcResponse response = null;
554 try
555 {
556 response = request.Send(m_ServerURL, 10000);
557 }
558 catch
559 {
560 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs", m_ServerURL);
561 // reason = "Exception: " + e.Message;
562 return serverURLs;
563 }
564  
565 if (response.IsFault)
566 {
567 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
568 // reason = "XMLRPC Fault";
569 return serverURLs;
570 }
571  
572 hash = (Hashtable)response.Value;
573 //foreach (Object o in hash)
574 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
575 try
576 {
577 if (hash == null)
578 {
579 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
580 // reason = "Internal error 1";
581 return serverURLs;
582 }
583  
584 // Here is the actual response
585 foreach (object key in hash.Keys)
586 {
587 if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
588 {
589 string serverType = key.ToString().Substring(4); // remove "SRV_"
590 serverURLs.Add(serverType, hash[key].ToString());
591 }
592 }
593  
594 }
595 catch
596 {
597 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
598 // reason = "Exception: " + e.Message;
599 }
600  
601 return serverURLs;
602 }
603  
604 public string LocateUser(UUID userID)
605 {
606 Hashtable hash = new Hashtable();
607 hash["userID"] = userID.ToString();
608  
609 IList paramList = new ArrayList();
610 paramList.Add(hash);
611  
612 XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList);
613 // string reason = string.Empty;
614  
615 // Send and get reply
616 string url = string.Empty;
617 XmlRpcResponse response = null;
618 try
619 {
620 response = request.Send(m_ServerURL, 10000);
621 }
622 catch
623 {
624 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for LocateUser", m_ServerURL);
625 // reason = "Exception: " + e.Message;
626 return url;
627 }
628  
629 if (response.IsFault)
630 {
631 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for LocateUser returned an error: {1}", m_ServerURL, response.FaultString);
632 // reason = "XMLRPC Fault";
633 return url;
634 }
635  
636 hash = (Hashtable)response.Value;
637 //foreach (Object o in hash)
638 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
639 try
640 {
641 if (hash == null)
642 {
643 m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
644 // reason = "Internal error 1";
645 return url;
646 }
647  
648 // Here's the actual response
649 if (hash.ContainsKey("URL"))
650 url = hash["URL"].ToString();
651  
652 }
653 catch
654 {
655 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
656 // reason = "Exception: " + e.Message;
657 }
658  
659 return url;
660 }
661  
662 public string GetUUI(UUID userID, UUID targetUserID)
663 {
664 Hashtable hash = new Hashtable();
665 hash["userID"] = userID.ToString();
666 hash["targetUserID"] = targetUserID.ToString();
667  
668 IList paramList = new ArrayList();
669 paramList.Add(hash);
670  
671 XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList);
672 // string reason = string.Empty;
673  
674 // Send and get reply
675 string uui = string.Empty;
676 XmlRpcResponse response = null;
677 try
678 {
679 response = request.Send(m_ServerURL, 10000);
680 }
681 catch
682 {
683 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUI", m_ServerURL);
684 // reason = "Exception: " + e.Message;
685 return uui;
686 }
687  
688 if (response.IsFault)
689 {
690 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUI returned an error: {1}", m_ServerURL, response.FaultString);
691 // reason = "XMLRPC Fault";
692 return uui;
693 }
694  
695 hash = (Hashtable)response.Value;
696 //foreach (Object o in hash)
697 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
698 try
699 {
700 if (hash == null)
701 {
702 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
703 // reason = "Internal error 1";
704 return uui;
705 }
706  
707 // Here's the actual response
708 if (hash.ContainsKey("UUI"))
709 uui = hash["UUI"].ToString();
710  
711 }
712 catch
713 {
714 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response.");
715 // reason = "Exception: " + e.Message;
716 }
717  
718 return uui;
719 }
720  
721 public UUID GetUUID(String first, String last)
722 {
723 Hashtable hash = new Hashtable();
724 hash["first"] = first;
725 hash["last"] = last;
726  
727 IList paramList = new ArrayList();
728 paramList.Add(hash);
729  
730 XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList);
731 // string reason = string.Empty;
732  
733 // Send and get reply
734 UUID uuid = UUID.Zero;
735 XmlRpcResponse response = null;
736 try
737 {
738 response = request.Send(m_ServerURL, 10000);
739 }
740 catch
741 {
742 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL);
743 // reason = "Exception: " + e.Message;
744 return uuid;
745 }
746  
747 if (response.IsFault)
748 {
749 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString);
750 // reason = "XMLRPC Fault";
751 return uuid;
752 }
753  
754 hash = (Hashtable)response.Value;
755 //foreach (Object o in hash)
756 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
757 try
758 {
759 if (hash == null)
760 {
761 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
762 // reason = "Internal error 1";
763 return uuid;
764 }
765  
766 // Here's the actual response
767 if (hash.ContainsKey("UUID"))
768 UUID.TryParse(hash["UUID"].ToString(), out uuid);
769  
770 }
771 catch
772 {
773 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response.");
774 // reason = "Exception: " + e.Message;
775 }
776  
777 return uuid;
778 }
779  
780 private bool GetBoolResponse(XmlRpcRequest request, out string reason)
781 {
782 //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL);
783 XmlRpcResponse response = null;
784 try
785 {
786 response = request.Send(m_ServerURL, 10000);
787 }
788 catch (Exception e)
789 {
790 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURL);
791 reason = "Exception: " + e.Message;
792 return false;
793 }
794  
795 if (response.IsFault)
796 {
797 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURL, response.FaultString);
798 reason = "XMLRPC Fault";
799 return false;
800 }
801  
802 Hashtable hash = (Hashtable)response.Value;
803 //foreach (Object o in hash)
804 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
805 try
806 {
807 if (hash == null)
808 {
809 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
810 reason = "Internal error 1";
811 return false;
812 }
813 bool success = false;
814 reason = string.Empty;
815 if (hash.ContainsKey("result"))
816 Boolean.TryParse((string)hash["result"], out success);
817 else
818 {
819 reason = "Internal error 2";
820 m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURL);
821 }
822  
823 return success;
824 }
825 catch (Exception e)
826 {
827 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetBoolResponse response.");
828 if (hash.ContainsKey("result") && hash["result"] != null)
829 m_log.ErrorFormat("Reply was ", (string)hash["result"]);
830 reason = "Exception: " + e.Message;
831 return false;
832 }
833  
834 }
835  
836 }
837 }