aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie2011-06-09 02:05:04 +0100
committerMelanie2011-06-09 02:05:04 +0100
commit326c46ba70cea70ddfe4aef9a6b73edff63e126a (patch)
tree5e76347b0d77f58717d8e5e4f3b8787ff01a18d7 /OpenSim/Services
parentMake the last otem in a list created with llCSV2List findable (diff)
parentConsistency fix on the last commit. (diff)
downloadopensim-SC_OLD-326c46ba70cea70ddfe4aef9a6b73edff63e126a.zip
opensim-SC_OLD-326c46ba70cea70ddfe4aef9a6b73edff63e126a.tar.gz
opensim-SC_OLD-326c46ba70cea70ddfe4aef9a6b73edff63e126a.tar.bz2
opensim-SC_OLD-326c46ba70cea70ddfe4aef9a6b73edff63e126a.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs53
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs206
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs323
-rw-r--r--OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs131
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs25
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs27
-rw-r--r--OpenSim/Services/FreeswitchService/FreeswitchService.cs8
-rw-r--r--OpenSim/Services/Friends/FriendsService.cs38
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs11
-rw-r--r--OpenSim/Services/HypergridService/HGInstantMessageService.cs349
-rw-r--r--OpenSim/Services/HypergridService/HGInventoryService.cs2
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs252
-rw-r--r--OpenSim/Services/Interfaces/IFriendsService.cs4
-rw-r--r--OpenSim/Services/Interfaces/IHypergridServices.cs (renamed from OpenSim/Services/Interfaces/IGatekeeperService.cs)25
-rw-r--r--OpenSim/Services/InventoryService/InventoryService.cs8
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs10
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs14
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs48
18 files changed, 1478 insertions, 56 deletions
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
index 861c475..c5ae0c0 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
@@ -38,7 +38,7 @@ using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39using OpenMetaverse; 39using OpenMetaverse;
40 40
41namespace OpenSim.Services.Connectors 41namespace OpenSim.Services.Connectors.Friends
42{ 42{
43 public class FriendsServicesConnector : IFriendsService 43 public class FriendsServicesConnector : IFriendsService
44 { 44 {
@@ -84,7 +84,7 @@ namespace OpenSim.Services.Connectors
84 84
85 85
86 #region IFriendsService 86 #region IFriendsService
87 87
88 public FriendInfo[] GetFriends(UUID PrincipalID) 88 public FriendInfo[] GetFriends(UUID PrincipalID)
89 { 89 {
90 Dictionary<string, object> sendData = new Dictionary<string, object>(); 90 Dictionary<string, object> sendData = new Dictionary<string, object>();
@@ -92,6 +92,21 @@ namespace OpenSim.Services.Connectors
92 sendData["PRINCIPALID"] = PrincipalID.ToString(); 92 sendData["PRINCIPALID"] = PrincipalID.ToString();
93 sendData["METHOD"] = "getfriends"; 93 sendData["METHOD"] = "getfriends";
94 94
95 return GetFriends(sendData, PrincipalID.ToString());
96 }
97
98 public FriendInfo[] GetFriends(string PrincipalID)
99 {
100 Dictionary<string, object> sendData = new Dictionary<string, object>();
101
102 sendData["PRINCIPALID"] = PrincipalID;
103 sendData["METHOD"] = "getfriends_string";
104
105 return GetFriends(sendData, PrincipalID);
106 }
107
108 protected FriendInfo[] GetFriends(Dictionary<string, object> sendData, string PrincipalID)
109 {
95 string reqString = ServerUtils.BuildQueryString(sendData); 110 string reqString = ServerUtils.BuildQueryString(sendData);
96 111
97 try 112 try
@@ -144,14 +159,10 @@ namespace OpenSim.Services.Connectors
144 159
145 } 160 }
146 161
147 public bool StoreFriend(UUID PrincipalID, string Friend, int flags) 162 public bool StoreFriend(string PrincipalID, string Friend, int flags)
148 { 163 {
149 FriendInfo finfo = new FriendInfo();
150 finfo.PrincipalID = PrincipalID;
151 finfo.Friend = Friend;
152 finfo.MyFlags = flags;
153 164
154 Dictionary<string, object> sendData = finfo.ToKeyValuePairs(); 165 Dictionary<string, object> sendData = ToKeyValuePairs(PrincipalID, Friend, flags);
155 166
156 sendData["METHOD"] = "storefriend"; 167 sendData["METHOD"] = "storefriend";
157 168
@@ -189,6 +200,16 @@ namespace OpenSim.Services.Connectors
189 200
190 } 201 }
191 202
203 public bool Delete(string PrincipalID, string Friend)
204 {
205 Dictionary<string, object> sendData = new Dictionary<string, object>();
206 sendData["PRINCIPALID"] = PrincipalID.ToString();
207 sendData["FRIEND"] = Friend;
208 sendData["METHOD"] = "deletefriend_string";
209
210 return Delete(sendData, PrincipalID, Friend);
211 }
212
192 public bool Delete(UUID PrincipalID, string Friend) 213 public bool Delete(UUID PrincipalID, string Friend)
193 { 214 {
194 Dictionary<string, object> sendData = new Dictionary<string, object>(); 215 Dictionary<string, object> sendData = new Dictionary<string, object>();
@@ -196,6 +217,11 @@ namespace OpenSim.Services.Connectors
196 sendData["FRIEND"] = Friend; 217 sendData["FRIEND"] = Friend;
197 sendData["METHOD"] = "deletefriend"; 218 sendData["METHOD"] = "deletefriend";
198 219
220 return Delete(sendData, PrincipalID.ToString(), Friend);
221 }
222
223 public bool Delete(Dictionary<string, object> sendData, string PrincipalID, string Friend)
224 {
199 string reply = string.Empty; 225 string reply = string.Empty;
200 try 226 try
201 { 227 {
@@ -230,5 +256,16 @@ namespace OpenSim.Services.Connectors
230 } 256 }
231 257
232 #endregion 258 #endregion
259
260 public Dictionary<string, object> ToKeyValuePairs(string principalID, string friend, int flags)
261 {
262 Dictionary<string, object> result = new Dictionary<string, object>();
263 result["PrincipalID"] = principalID;
264 result["Friend"] = friend;
265 result["MyFlags"] = flags;
266
267 return result;
268 }
269
233 } 270 }
234} \ No newline at end of file 271} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs
new file mode 100644
index 0000000..d699f59
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs
@@ -0,0 +1,206 @@
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
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Services.Interfaces;
36using OpenSim.Services.Connectors.Friends;
37using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38using OpenSim.Server.Base;
39using OpenMetaverse;
40
41namespace OpenSim.Services.Connectors.Hypergrid
42{
43 public class HGFriendsServicesConnector
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(
47 MethodBase.GetCurrentMethod().DeclaringType);
48
49 private string m_ServerURI = String.Empty;
50 private string m_ServiceKey = String.Empty;
51 private UUID m_SessionID;
52
53 public HGFriendsServicesConnector()
54 {
55 }
56
57 public HGFriendsServicesConnector(string serverURI)
58 {
59 m_ServerURI = serverURI.TrimEnd('/');
60 }
61
62 public HGFriendsServicesConnector(string serverURI, UUID sessionID, string serviceKey)
63 {
64 m_ServerURI = serverURI.TrimEnd('/');
65 m_ServiceKey = serviceKey;
66 m_SessionID = sessionID;
67 }
68
69 #region IFriendsService
70
71 public uint GetFriendPerms(UUID PrincipalID, UUID friendID)
72 {
73 Dictionary<string, object> sendData = new Dictionary<string, object>();
74
75 sendData["PRINCIPALID"] = PrincipalID.ToString();
76 sendData["FRIENDID"] = friendID.ToString();
77 sendData["METHOD"] = "getfriendperms";
78 sendData["KEY"] = m_ServiceKey;
79 sendData["SESSIONID"] = m_SessionID.ToString();
80
81 string reqString = ServerUtils.BuildQueryString(sendData);
82
83 try
84 {
85 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
86 m_ServerURI + "/hgfriends",
87 reqString);
88 if (reply != string.Empty)
89 {
90 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
91
92 if ((replyData != null) && replyData.ContainsKey("Value") && (replyData["Value"] != null))
93 {
94 uint perms = 0;
95 uint.TryParse(replyData["Value"].ToString(), out perms);
96 return perms;
97 }
98 else
99 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriendPerms {0} received null response",
100 PrincipalID);
101
102 }
103 }
104 catch (Exception e)
105 {
106 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
107 }
108
109 return 0;
110
111 }
112
113 public bool NewFriendship(UUID PrincipalID, string Friend)
114 {
115 FriendInfo finfo = new FriendInfo();
116 finfo.PrincipalID = PrincipalID;
117 finfo.Friend = Friend;
118
119 Dictionary<string, object> sendData = finfo.ToKeyValuePairs();
120
121 sendData["METHOD"] = "newfriendship";
122 sendData["KEY"] = m_ServiceKey;
123 sendData["SESSIONID"] = m_SessionID.ToString();
124
125 string reply = string.Empty;
126 try
127 {
128 reply = SynchronousRestFormsRequester.MakeRequest("POST",
129 m_ServerURI + "/hgfriends",
130 ServerUtils.BuildQueryString(sendData));
131 }
132 catch (Exception e)
133 {
134 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
135 return false;
136 }
137
138 if (reply != string.Empty)
139 {
140 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
141
142 if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
143 {
144 bool success = false;
145 Boolean.TryParse(replyData["Result"].ToString(), out success);
146 return success;
147 }
148 else
149 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: StoreFriend {0} {1} received null response",
150 PrincipalID, Friend);
151 }
152 else
153 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: StoreFriend received null reply");
154
155 return false;
156
157 }
158
159 public bool DeleteFriendship(UUID PrincipalID, UUID Friend, string secret)
160 {
161 FriendInfo finfo = new FriendInfo();
162 finfo.PrincipalID = PrincipalID;
163 finfo.Friend = Friend.ToString();
164
165 Dictionary<string, object> sendData = finfo.ToKeyValuePairs();
166
167 sendData["METHOD"] = "deletefriendship";
168 sendData["SECRET"] = secret;
169
170 string reply = string.Empty;
171 try
172 {
173 reply = SynchronousRestFormsRequester.MakeRequest("POST",
174 m_ServerURI + "/hgfriends",
175 ServerUtils.BuildQueryString(sendData));
176 }
177 catch (Exception e)
178 {
179 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
180 return false;
181 }
182
183 if (reply != string.Empty)
184 {
185 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
186
187 if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
188 {
189 bool success = false;
190 Boolean.TryParse(replyData["Result"].ToString(), out success);
191 return success;
192 }
193 else
194 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Delete {0} {1} received null response",
195 PrincipalID, Friend);
196 }
197 else
198 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: DeleteFriend received null reply");
199
200 return false;
201
202 }
203
204 #endregion
205 }
206} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 7ddcfa6..5028206 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -400,6 +400,329 @@ namespace OpenSim.Services.Connectors.Hypergrid
400 GetBoolResponse(request, out reason); 400 GetBoolResponse(request, out reason);
401 } 401 }
402 402
403 public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online)
404 {
405 Hashtable hash = new Hashtable();
406 hash["userID"] = userID.ToString();
407 hash["online"] = online.ToString();
408 int i = 0;
409 foreach (string s in friends)
410 {
411 hash["friend_" + i.ToString()] = s;
412 i++;
413 }
414
415 IList paramList = new ArrayList();
416 paramList.Add(hash);
417
418 XmlRpcRequest request = new XmlRpcRequest("status_notification", paramList);
419 string reason = string.Empty;
420
421 // Send and get reply
422 List<UUID> friendsOnline = new List<UUID>();
423 XmlRpcResponse response = null;
424 try
425 {
426 response = request.Send(m_ServerURL, 10000);
427 }
428 catch (Exception e)
429 {
430 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
431 reason = "Exception: " + e.Message;
432 return friendsOnline;
433 }
434
435 if (response.IsFault)
436 {
437 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
438 reason = "XMLRPC Fault";
439 return friendsOnline;
440 }
441
442 hash = (Hashtable)response.Value;
443 //foreach (Object o in hash)
444 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
445 try
446 {
447 if (hash == null)
448 {
449 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
450 reason = "Internal error 1";
451 return friendsOnline;
452 }
453
454 // Here is the actual response
455 foreach (object key in hash.Keys)
456 {
457 if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null)
458 {
459 UUID uuid;
460 if (UUID.TryParse(hash[key].ToString(), out uuid))
461 friendsOnline.Add(uuid);
462 }
463 }
464
465 }
466 catch (Exception e)
467 {
468 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
469 reason = "Exception: " + e.Message;
470 }
471
472 return friendsOnline;
473 }
474
475 public List<UUID> GetOnlineFriends(UUID userID, List<string> friends)
476 {
477 Hashtable hash = new Hashtable();
478 hash["userID"] = userID.ToString();
479 int i = 0;
480 foreach (string s in friends)
481 {
482 hash["friend_" + i.ToString()] = s;
483 i++;
484 }
485
486 IList paramList = new ArrayList();
487 paramList.Add(hash);
488
489 XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList);
490 string reason = string.Empty;
491
492 // Send and get reply
493 List<UUID> online = new List<UUID>();
494 XmlRpcResponse response = null;
495 try
496 {
497 response = request.Send(m_ServerURL, 10000);
498 }
499 catch (Exception e)
500 {
501 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
502 reason = "Exception: " + e.Message;
503 return online;
504 }
505
506 if (response.IsFault)
507 {
508 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
509 reason = "XMLRPC Fault";
510 return online;
511 }
512
513 hash = (Hashtable)response.Value;
514 //foreach (Object o in hash)
515 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
516 try
517 {
518 if (hash == null)
519 {
520 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
521 reason = "Internal error 1";
522 return online;
523 }
524
525 // Here is the actual response
526 foreach (object key in hash.Keys)
527 {
528 if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null)
529 {
530 UUID uuid;
531 if (UUID.TryParse(hash[key].ToString(), out uuid))
532 online.Add(uuid);
533 }
534 }
535
536 }
537 catch (Exception e)
538 {
539 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
540 reason = "Exception: " + e.Message;
541 }
542
543 return online;
544 }
545
546 public Dictionary<string, object> GetServerURLs(UUID userID)
547 {
548 Hashtable hash = new Hashtable();
549 hash["userID"] = userID.ToString();
550
551 IList paramList = new ArrayList();
552 paramList.Add(hash);
553
554 XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList);
555 string reason = string.Empty;
556
557 // Send and get reply
558 Dictionary<string, object> serverURLs = new Dictionary<string,object>();
559 XmlRpcResponse response = null;
560 try
561 {
562 response = request.Send(m_ServerURL, 10000);
563 }
564 catch (Exception e)
565 {
566 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
567 reason = "Exception: " + e.Message;
568 return serverURLs;
569 }
570
571 if (response.IsFault)
572 {
573 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
574 reason = "XMLRPC Fault";
575 return serverURLs;
576 }
577
578 hash = (Hashtable)response.Value;
579 //foreach (Object o in hash)
580 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
581 try
582 {
583 if (hash == null)
584 {
585 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
586 reason = "Internal error 1";
587 return serverURLs;
588 }
589
590 // Here is the actual response
591 foreach (object key in hash.Keys)
592 {
593 if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
594 {
595 string serverType = key.ToString().Substring(4); // remove "SRV_"
596 serverURLs.Add(serverType, hash[key].ToString());
597 }
598 }
599
600 }
601 catch (Exception e)
602 {
603 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
604 reason = "Exception: " + e.Message;
605 }
606
607 return serverURLs;
608 }
609
610 public string LocateUser(UUID userID)
611 {
612 Hashtable hash = new Hashtable();
613 hash["userID"] = userID.ToString();
614
615 IList paramList = new ArrayList();
616 paramList.Add(hash);
617
618 XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList);
619 string reason = string.Empty;
620
621 // Send and get reply
622 string url = string.Empty;
623 XmlRpcResponse response = null;
624 try
625 {
626 response = request.Send(m_ServerURL, 10000);
627 }
628 catch (Exception e)
629 {
630 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
631 reason = "Exception: " + e.Message;
632 return url;
633 }
634
635 if (response.IsFault)
636 {
637 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
638 reason = "XMLRPC Fault";
639 return url;
640 }
641
642 hash = (Hashtable)response.Value;
643 //foreach (Object o in hash)
644 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
645 try
646 {
647 if (hash == null)
648 {
649 m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
650 reason = "Internal error 1";
651 return url;
652 }
653
654 // Here's the actual response
655 if (hash.ContainsKey("URL"))
656 url = hash["URL"].ToString();
657
658 }
659 catch (Exception e)
660 {
661 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
662 reason = "Exception: " + e.Message;
663 }
664
665 return url;
666 }
667
668 public string GetUUI(UUID userID, UUID targetUserID)
669 {
670 Hashtable hash = new Hashtable();
671 hash["userID"] = userID.ToString();
672 hash["targetUserID"] = targetUserID.ToString();
673
674 IList paramList = new ArrayList();
675 paramList.Add(hash);
676
677 XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList);
678 string reason = string.Empty;
679
680 // Send and get reply
681 string uui = string.Empty;
682 XmlRpcResponse response = null;
683 try
684 {
685 response = request.Send(m_ServerURL, 10000);
686 }
687 catch (Exception e)
688 {
689 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
690 reason = "Exception: " + e.Message;
691 return uui;
692 }
693
694 if (response.IsFault)
695 {
696 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
697 reason = "XMLRPC Fault";
698 return uui;
699 }
700
701 hash = (Hashtable)response.Value;
702 //foreach (Object o in hash)
703 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
704 try
705 {
706 if (hash == null)
707 {
708 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
709 reason = "Internal error 1";
710 return uui;
711 }
712
713 // Here's the actual response
714 if (hash.ContainsKey("UUI"))
715 uui = hash["UUI"].ToString();
716
717 }
718 catch (Exception e)
719 {
720 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
721 reason = "Exception: " + e.Message;
722 }
723
724 return uui;
725 }
403 726
404 private bool GetBoolResponse(XmlRpcRequest request, out string reason) 727 private bool GetBoolResponse(XmlRpcRequest request, out string reason)
405 { 728 {
diff --git a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
new file mode 100644
index 0000000..dbce9f6
--- /dev/null
+++ b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
@@ -0,0 +1,131 @@
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 */
27using System;
28using System.Collections;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32
33using OpenMetaverse;
34using Nwc.XmlRpc;
35using log4net;
36
37using OpenSim.Framework;
38
39namespace OpenSim.Services.Connectors.InstantMessage
40{
41 public class InstantMessageServiceConnector
42 {
43 private static readonly ILog m_log =
44 LogManager.GetLogger(
45 MethodBase.GetCurrentMethod().DeclaringType);
46
47 /// <summary>
48 /// This actually does the XMLRPC Request
49 /// </summary>
50 /// <param name="url">URL we pull the data out of to send the request to</param>
51 /// <param name="im">The Instant Message </param>
52 /// <returns>Bool if the message was successfully delivered at the other side.</returns>
53 public static bool SendInstantMessage(string url, GridInstantMessage im)
54 {
55 Hashtable xmlrpcdata = ConvertGridInstantMessageToXMLRPC(im);
56 xmlrpcdata["region_handle"] = 0;
57
58 ArrayList SendParams = new ArrayList();
59 SendParams.Add(xmlrpcdata);
60 XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams);
61 try
62 {
63
64 XmlRpcResponse GridResp = GridReq.Send(url, 10000);
65
66 Hashtable responseData = (Hashtable)GridResp.Value;
67
68 if (responseData.ContainsKey("success"))
69 {
70 if ((string)responseData["success"] == "TRUE")
71 {
72 //m_log.DebugFormat("[XXX] Success");
73 return true;
74 }
75 else
76 {
77 //m_log.DebugFormat("[XXX] Fail");
78 return false;
79 }
80 }
81 else
82 {
83 m_log.DebugFormat("[GRID INSTANT MESSAGE]: No response from {0}", url);
84 return false;
85 }
86 }
87 catch (WebException e)
88 {
89 m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} the host didn't respond " + e.ToString(), url);
90 }
91
92 return false;
93 }
94
95 /// <summary>
96 /// Takes a GridInstantMessage and converts it into a Hashtable for XMLRPC
97 /// </summary>
98 /// <param name="msg">The GridInstantMessage object</param>
99 /// <returns>Hashtable containing the XMLRPC request</returns>
100 protected static Hashtable ConvertGridInstantMessageToXMLRPC(GridInstantMessage msg)
101 {
102 Hashtable gim = new Hashtable();
103 gim["from_agent_id"] = msg.fromAgentID.ToString();
104 // Kept for compatibility
105 gim["from_agent_session"] = UUID.Zero.ToString();
106 gim["to_agent_id"] = msg.toAgentID.ToString();
107 gim["im_session_id"] = msg.imSessionID.ToString();
108 gim["timestamp"] = msg.timestamp.ToString();
109 gim["from_agent_name"] = msg.fromAgentName;
110 gim["message"] = msg.message;
111 byte[] dialogdata = new byte[1]; dialogdata[0] = msg.dialog;
112 gim["dialog"] = Convert.ToBase64String(dialogdata, Base64FormattingOptions.None);
113
114 if (msg.fromGroup)
115 gim["from_group"] = "TRUE";
116 else
117 gim["from_group"] = "FALSE";
118 byte[] offlinedata = new byte[1]; offlinedata[0] = msg.offline;
119 gim["offline"] = Convert.ToBase64String(offlinedata, Base64FormattingOptions.None);
120 gim["parent_estate_id"] = msg.ParentEstateID.ToString();
121 gim["position_x"] = msg.Position.X.ToString();
122 gim["position_y"] = msg.Position.Y.ToString();
123 gim["position_z"] = msg.Position.Z.ToString();
124 gim["region_id"] = msg.RegionID.ToString();
125 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None);
126
127 return gim;
128 }
129
130 }
131}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
index 6f2d735..7422d94 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
@@ -78,6 +78,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
78 78
79 public FriendInfo[] GetFriends(UUID principalID) 79 public FriendInfo[] GetFriends(UUID principalID)
80 { 80 {
81 return GetFriends(principalID.ToString());
82 }
83
84 public FriendInfo[] GetFriends(string principalID)
85 {
81 if (String.IsNullOrEmpty(m_serverUrl)) 86 if (String.IsNullOrEmpty(m_serverUrl))
82 return new FriendInfo[0]; 87 return new FriendInfo[0];
83 88
@@ -95,7 +100,14 @@ namespace OpenSim.Services.Connectors.SimianGrid
95 UUID friendID = friendEntry["Key"].AsUUID(); 100 UUID friendID = friendEntry["Key"].AsUUID();
96 101
97 FriendInfo friend = new FriendInfo(); 102 FriendInfo friend = new FriendInfo();
98 friend.PrincipalID = principalID; 103 if (!UUID.TryParse(principalID, out friend.PrincipalID))
104 {
105 string tmp = string.Empty;
106 if (!Util.ParseUniversalUserIdentifier(principalID, out friend.PrincipalID, out tmp, out tmp, out tmp, out tmp))
107 // bad record. ignore this entry
108 continue;
109 }
110
99 friend.Friend = friendID.ToString(); 111 friend.Friend = friendID.ToString();
100 friend.MyFlags = friendEntry["Value"].AsInteger(); 112 friend.MyFlags = friendEntry["Value"].AsInteger();
101 friend.TheirFlags = -1; 113 friend.TheirFlags = -1;
@@ -127,7 +139,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
127 return array; 139 return array;
128 } 140 }
129 141
130 public bool StoreFriend(UUID principalID, string friend, int flags) 142 public bool StoreFriend(string principalID, string friend, int flags)
131 { 143 {
132 if (String.IsNullOrEmpty(m_serverUrl)) 144 if (String.IsNullOrEmpty(m_serverUrl))
133 return true; 145 return true;
@@ -152,6 +164,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
152 164
153 public bool Delete(UUID principalID, string friend) 165 public bool Delete(UUID principalID, string friend)
154 { 166 {
167 return Delete(principalID.ToString(), friend);
168 }
169
170 public bool Delete(string principalID, string friend)
171 {
155 if (String.IsNullOrEmpty(m_serverUrl)) 172 if (String.IsNullOrEmpty(m_serverUrl))
156 return true; 173 return true;
157 174
@@ -174,7 +191,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
174 191
175 #endregion IFriendsService 192 #endregion IFriendsService
176 193
177 private OSDArray GetFriended(UUID ownerID) 194 private OSDArray GetFriended(string ownerID)
178 { 195 {
179 NameValueCollection requestArgs = new NameValueCollection 196 NameValueCollection requestArgs = new NameValueCollection
180 { 197 {
@@ -195,7 +212,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
195 } 212 }
196 } 213 }
197 214
198 private OSDArray GetFriendedBy(UUID ownerID) 215 private OSDArray GetFriendedBy(string ownerID)
199 { 216 {
200 NameValueCollection requestArgs = new NameValueCollection 217 NameValueCollection requestArgs = new NameValueCollection
201 { 218 {
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 725c6df..6fb583c 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -103,16 +103,31 @@ namespace OpenSim.Services.Connectors.Simulation
103 args["teleport_flags"] = OSD.FromString(flags.ToString()); 103 args["teleport_flags"] = OSD.FromString(flags.ToString());
104 104
105 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); 105 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
106 if (result["Success"].AsBoolean()) 106 bool success = result["success"].AsBoolean();
107 return true; 107 if (success && result.ContainsKey("_Result"))
108 108 {
109 OSDMap data = (OSDMap)result["_Result"];
110
111 reason = data["reason"].AsString();
112 success = data["success"].AsBoolean();
113 return success;
114 }
115
116 // Try the old version, uncompressed
109 result = WebUtil.PostToService(uri, args, 30000); 117 result = WebUtil.PostToService(uri, args, 30000);
110 118
111 if (result["Success"].AsBoolean()) 119 if (result["Success"].AsBoolean())
112 { 120 {
113 m_log.WarnFormat( 121 if (result.ContainsKey("_Result"))
114 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); 122 {
115 return true; 123 OSDMap data = (OSDMap)result["_Result"];
124
125 reason = data["reason"].AsString();
126 success = data["success"].AsBoolean();
127 m_log.WarnFormat(
128 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
129 return success;
130 }
116 } 131 }
117 132
118 m_log.WarnFormat( 133 m_log.WarnFormat(
diff --git a/OpenSim/Services/FreeswitchService/FreeswitchService.cs b/OpenSim/Services/FreeswitchService/FreeswitchService.cs
index c3f1056..201e72f 100644
--- a/OpenSim/Services/FreeswitchService/FreeswitchService.cs
+++ b/OpenSim/Services/FreeswitchService/FreeswitchService.cs
@@ -54,10 +54,10 @@ namespace OpenSim.Services.FreeswitchService
54 54
55 Hashtable response = new Hashtable(); 55 Hashtable response = new Hashtable();
56 56
57 foreach (DictionaryEntry item in request) 57// foreach (DictionaryEntry item in request)
58 { 58// {
59// m_log.InfoFormat("[FreeSwitchDirectory]: requestBody item {0} {1}",item.Key, item.Value); 59//// m_log.InfoFormat("[FreeSwitchDirectory]: requestBody item {0} {1}",item.Key, item.Value);
60 } 60// }
61 61
62 string requestcontext = (string) request["Hunt-Context"]; 62 string requestcontext = (string) request["Hunt-Context"];
63 response["content_type"] = "text/xml"; 63 response["content_type"] = "text/xml";
diff --git a/OpenSim/Services/Friends/FriendsService.cs b/OpenSim/Services/Friends/FriendsService.cs
index 3c64ecc..e2033ac 100644
--- a/OpenSim/Services/Friends/FriendsService.cs
+++ b/OpenSim/Services/Friends/FriendsService.cs
@@ -43,17 +43,42 @@ namespace OpenSim.Services.Friends
43 { 43 {
44 } 44 }
45 45
46 public FriendInfo[] GetFriends(UUID PrincipalID) 46 public virtual FriendInfo[] GetFriends(UUID PrincipalID)
47 { 47 {
48 FriendsData[] data = m_Database.GetFriends(PrincipalID); 48 FriendsData[] data = m_Database.GetFriends(PrincipalID);
49 List<FriendInfo> info = new List<FriendInfo>();
50
51 foreach (FriendsData d in data)
52 {
53 FriendInfo i = new FriendInfo();
54
55 i.PrincipalID = new UUID(d.PrincipalID);
56 i.Friend = d.Friend;
57 i.MyFlags = Convert.ToInt32(d.Data["Flags"]);
58 i.TheirFlags = Convert.ToInt32(d.Data["TheirFlags"]);
59
60 info.Add(i);
61 }
62
63 return info.ToArray();
64 }
49 65
66 public virtual FriendInfo[] GetFriends(string PrincipalID)
67 {
68 FriendsData[] data = m_Database.GetFriends(PrincipalID);
50 List<FriendInfo> info = new List<FriendInfo>(); 69 List<FriendInfo> info = new List<FriendInfo>();
51 70
52 foreach (FriendsData d in data) 71 foreach (FriendsData d in data)
53 { 72 {
54 FriendInfo i = new FriendInfo(); 73 FriendInfo i = new FriendInfo();
55 74
56 i.PrincipalID = d.PrincipalID; 75 if (!UUID.TryParse(d.PrincipalID, out i.PrincipalID))
76 {
77 string tmp = string.Empty;
78 if (!Util.ParseUniversalUserIdentifier(d.PrincipalID, out i.PrincipalID, out tmp, out tmp, out tmp, out tmp))
79 // bad record. ignore this entry
80 continue;
81 }
57 i.Friend = d.Friend; 82 i.Friend = d.Friend;
58 i.MyFlags = Convert.ToInt32(d.Data["Flags"]); 83 i.MyFlags = Convert.ToInt32(d.Data["Flags"]);
59 i.TheirFlags = Convert.ToInt32(d.Data["TheirFlags"]); 84 i.TheirFlags = Convert.ToInt32(d.Data["TheirFlags"]);
@@ -64,7 +89,7 @@ namespace OpenSim.Services.Friends
64 return info.ToArray(); 89 return info.ToArray();
65 } 90 }
66 91
67 public bool StoreFriend(UUID PrincipalID, string Friend, int flags) 92 public virtual bool StoreFriend(string PrincipalID, string Friend, int flags)
68 { 93 {
69 FriendsData d = new FriendsData(); 94 FriendsData d = new FriendsData();
70 95
@@ -76,7 +101,12 @@ namespace OpenSim.Services.Friends
76 return m_Database.Store(d); 101 return m_Database.Store(d);
77 } 102 }
78 103
79 public bool Delete(UUID PrincipalID, string Friend) 104 public bool Delete(string principalID, string friend)
105 {
106 return m_Database.Delete(principalID, friend);
107 }
108
109 public virtual bool Delete(UUID PrincipalID, string Friend)
80 { 110 {
81 return m_Database.Delete(PrincipalID, Friend); 111 return m_Database.Delete(PrincipalID, Friend);
82 } 112 }
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index b226971..6d63748 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -327,10 +327,13 @@ namespace OpenSim.Services.GridService
327 else 327 else
328 regInfo.RegionName = externalName; 328 regInfo.RegionName = externalName;
329 329
330 m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName); 330 m_log.DebugFormat("[HYPERGRID LINKER]: naming linked region {0}, handle {1}", regInfo.RegionName, handle.ToString());
331 331
332 // Get the map image 332 // Get the map image
333 regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory); 333 regInfo.TerrainImage = GetMapImage(regionID, imageURL);
334
335 // Store the origin's coordinates somewhere
336 regInfo.RegionSecret = handle.ToString();
334 337
335 AddHyperlinkRegion(regInfo, handle); 338 AddHyperlinkRegion(regInfo, handle);
336 m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID); 339 m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID);
@@ -427,6 +430,10 @@ namespace OpenSim.Services.GridService
427 m_Database.Delete(regionID); 430 m_Database.Delete(regionID);
428 } 431 }
429 432
433 public UUID GetMapImage(UUID regionID, string imageURL)
434 {
435 return m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory);
436 }
430 #endregion 437 #endregion
431 438
432 439
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
new file mode 100644
index 0000000..ded589d
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -0,0 +1,349 @@
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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32
33using OpenSim.Framework;
34using OpenSim.Services.Connectors.Friends;
35using OpenSim.Services.Connectors.Hypergrid;
36using OpenSim.Services.Interfaces;
37using OpenSim.Services.Connectors.InstantMessage;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base;
40using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
41
42using OpenMetaverse;
43using log4net;
44using Nini.Config;
45
46namespace OpenSim.Services.HypergridService
47{
48 /// <summary>
49 /// Inter-grid IM
50 /// </summary>
51 public class HGInstantMessageService : IInstantMessage
52 {
53 private static readonly ILog m_log =
54 LogManager.GetLogger(
55 MethodBase.GetCurrentMethod().DeclaringType);
56
57 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours
58
59 static bool m_Initialized = false;
60
61 protected static IGridService m_GridService;
62 protected static IPresenceService m_PresenceService;
63 protected static IUserAgentService m_UserAgentService;
64
65 protected static IInstantMessageSimConnector m_IMSimConnector;
66
67 protected static Dictionary<UUID, object> m_UserLocationMap = new Dictionary<UUID, object>();
68 private static ExpiringCache<UUID, GridRegion> m_RegionCache;
69
70 private static string m_RestURL;
71 private static bool m_ForwardOfflineGroupMessages;
72 private static bool m_InGatekeeper;
73
74 public HGInstantMessageService(IConfigSource config)
75 : this(config, null)
76 {
77 }
78
79 public HGInstantMessageService(IConfigSource config, IInstantMessageSimConnector imConnector)
80 {
81 if (imConnector != null)
82 m_IMSimConnector = imConnector;
83
84 if (!m_Initialized)
85 {
86 m_Initialized = true;
87
88 IConfig serverConfig = config.Configs["HGInstantMessageService"];
89 if (serverConfig == null)
90 throw new Exception(String.Format("No section HGInstantMessageService in config file"));
91
92 string gridService = serverConfig.GetString("GridService", String.Empty);
93 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
94 string userAgentService = serverConfig.GetString("UserAgentService", String.Empty);
95 m_InGatekeeper = serverConfig.GetBoolean("InGatekeeper", false);
96 m_log.DebugFormat("[HG IM SERVICE]: Starting... InRobust? {0}", m_InGatekeeper);
97
98
99 if (gridService == string.Empty || presenceService == string.Empty)
100 throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function."));
101
102 Object[] args = new Object[] { config };
103 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
104 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
105 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(userAgentService, args);
106
107 m_RegionCache = new ExpiringCache<UUID, GridRegion>();
108
109 IConfig cnf = config.Configs["Messaging"];
110 if (cnf == null)
111 {
112 return;
113 }
114
115 m_RestURL = cnf.GetString("OfflineMessageURL", string.Empty);
116 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", false);
117
118 }
119 }
120
121 public bool IncomingInstantMessage(GridInstantMessage im)
122 {
123 m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID);
124 UUID toAgentID = new UUID(im.toAgentID);
125
126 bool success = false;
127 if (m_IMSimConnector != null)
128 {
129 //m_log.DebugFormat("[XXX] SendIMToRegion local im connector");
130 success = m_IMSimConnector.SendInstantMessage(im);
131 }
132 else
133 {
134 success = TrySendInstantMessage(im, "", true, false);
135 }
136
137 if (!success && m_InGatekeeper) // we do this only in the Gatekeeper IM service
138 UndeliveredMessage(im);
139
140 return success;
141 }
142
143 public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner)
144 {
145 m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url);
146 if (url != string.Empty)
147 return TrySendInstantMessage(im, url, true, foreigner);
148 else
149 {
150 PresenceInfo upd = new PresenceInfo();
151 upd.RegionID = UUID.Zero;
152 return TrySendInstantMessage(im, upd, true, foreigner);
153 }
154
155 }
156
157 protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime, bool foreigner)
158 {
159 UUID toAgentID = new UUID(im.toAgentID);
160
161 PresenceInfo upd = null;
162 string url = string.Empty;
163
164 bool lookupAgent = false;
165
166 lock (m_UserLocationMap)
167 {
168 if (m_UserLocationMap.ContainsKey(toAgentID))
169 {
170 object o = m_UserLocationMap[toAgentID];
171 if (o is PresenceInfo)
172 upd = (PresenceInfo)o;
173 else if (o is string)
174 url = (string)o;
175
176 // We need to compare the current location with the previous
177 // or the recursive loop will never end because it will never try to lookup the agent again
178 if (!firstTime)
179 {
180 lookupAgent = true;
181 upd = null;
182 }
183 }
184 else
185 {
186 lookupAgent = true;
187 }
188 }
189
190 //m_log.DebugFormat("[XXX] Neeed lookup ? {0}", (lookupAgent ? "yes" : "no"));
191
192 // Are we needing to look-up an agent?
193 if (lookupAgent)
194 {
195 // Non-cached user agent lookup.
196 PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { toAgentID.ToString() });
197 if (presences != null && presences.Length > 0)
198 {
199 foreach (PresenceInfo p in presences)
200 {
201 if (p.RegionID != UUID.Zero)
202 {
203 //m_log.DebugFormat("[XXX]: Found presence in {0}", p.RegionID);
204 upd = p;
205 break;
206 }
207 }
208 }
209
210 if (upd == null && !foreigner)
211 {
212 // Let's check with the UAS if the user is elsewhere
213 m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service");
214 url = m_UserAgentService.LocateUser(toAgentID);
215 }
216
217 // check if we've tried this before..
218 // This is one way to end the recursive loop
219 //
220 if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) ||
221 (previousLocation is string && upd == null && previousLocation.Equals(url))))
222 {
223 // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
224 m_log.DebugFormat("[HG IM SERVICE]: Fail 2 {0} {1}", previousLocation, url);
225
226 return false;
227 }
228 }
229
230 if (upd != null)
231 {
232 // ok, the user is around somewhere. Let's send back the reply with "success"
233 // even though the IM may still fail. Just don't keep the caller waiting for
234 // the entire time we're trying to deliver the IM
235 return SendIMToRegion(upd, im, toAgentID, foreigner);
236 }
237 else if (url != string.Empty)
238 {
239 // ok, the user is around somewhere. Let's send back the reply with "success"
240 // even though the IM may still fail. Just don't keep the caller waiting for
241 // the entire time we're trying to deliver the IM
242 return ForwardIMToGrid(url, im, toAgentID, foreigner);
243 }
244 else if (firstTime && previousLocation is string && (string)previousLocation != string.Empty)
245 {
246 return ForwardIMToGrid((string)previousLocation, im, toAgentID, foreigner);
247 }
248 else
249 m_log.DebugFormat("[HG IM SERVICE]: Unable to locate user {0}", toAgentID);
250 return false;
251 }
252
253 bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID, bool foreigner)
254 {
255 bool imresult = false;
256 GridRegion reginfo = null;
257 if (!m_RegionCache.TryGetValue(upd.RegionID, out reginfo))
258 {
259 reginfo = m_GridService.GetRegionByUUID(UUID.Zero /*!!!*/, upd.RegionID);
260 if (reginfo != null)
261 m_RegionCache.AddOrUpdate(upd.RegionID, reginfo, CACHE_EXPIRATION_SECONDS);
262 }
263
264 if (reginfo != null)
265 {
266 imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im);
267 }
268 else
269 {
270 m_log.DebugFormat("[HG IM SERVICE]: Failed to deliver message to {0}", reginfo.ServerURI);
271 return false;
272 }
273
274 if (imresult)
275 {
276 // IM delivery successful, so store the Agent's location in our local cache.
277 lock (m_UserLocationMap)
278 {
279 if (m_UserLocationMap.ContainsKey(toAgentID))
280 {
281 m_UserLocationMap[toAgentID] = upd;
282 }
283 else
284 {
285 m_UserLocationMap.Add(toAgentID, upd);
286 }
287 }
288 return true;
289 }
290 else
291 {
292 // try again, but lookup user this time.
293 // Warning, this must call the Async version
294 // of this method or we'll be making thousands of threads
295 // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
296 // The version that spawns the thread is SendGridInstantMessageViaXMLRPC
297
298 // This is recursive!!!!!
299 return TrySendInstantMessage(im, upd, false, foreigner);
300 }
301 }
302
303 bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID, bool foreigner)
304 {
305 if (InstantMessageServiceConnector.SendInstantMessage(url, im))
306 {
307 // IM delivery successful, so store the Agent's location in our local cache.
308 lock (m_UserLocationMap)
309 {
310 if (m_UserLocationMap.ContainsKey(toAgentID))
311 {
312 m_UserLocationMap[toAgentID] = url;
313 }
314 else
315 {
316 m_UserLocationMap.Add(toAgentID, url);
317 }
318 }
319
320 return true;
321 }
322 else
323 {
324 // try again, but lookup user this time.
325
326 // This is recursive!!!!!
327 return TrySendInstantMessage(im, url, false, foreigner);
328 }
329
330 }
331
332 private bool UndeliveredMessage(GridInstantMessage im)
333 {
334 if (m_RestURL != string.Empty && (im.offline != 0)
335 && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
336 {
337 m_log.DebugFormat("[HG IM SERVICE]: Message saved");
338 return SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
339 "POST", m_RestURL + "/SaveMessage/", im);
340
341 }
342
343 else
344 {
345 return false;
346 }
347 }
348 }
349}
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index 9ee1ae4..4eb61ba 100644
--- a/OpenSim/Services/HypergridService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -134,6 +134,7 @@ namespace OpenSim.Services.HypergridService
134 134
135 public override InventoryFolderBase GetRootFolder(UUID principalID) 135 public override InventoryFolderBase GetRootFolder(UUID principalID)
136 { 136 {
137 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
137 // Warp! Root folder for travelers 138 // Warp! Root folder for travelers
138 XInventoryFolder[] folders = m_Database.GetFolders( 139 XInventoryFolder[] folders = m_Database.GetFolders(
139 new string[] { "agentID", "folderName"}, 140 new string[] { "agentID", "folderName"},
@@ -171,6 +172,7 @@ namespace OpenSim.Services.HypergridService
171 172
172 public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) 173 public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
173 { 174 {
175 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
174 return GetRootFolder(principalID); 176 return GetRootFolder(principalID);
175 } 177 }
176 178
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 09e785f..41d5a88 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -31,10 +31,12 @@ using System.Net;
31using System.Reflection; 31using System.Reflection;
32 32
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Services.Connectors.Friends;
34using OpenSim.Services.Connectors.Hypergrid; 35using OpenSim.Services.Connectors.Hypergrid;
35using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion; 37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38 40
39using OpenMetaverse; 41using OpenMetaverse;
40using log4net; 42using log4net;
@@ -63,19 +65,35 @@ namespace OpenSim.Services.HypergridService
63 protected static IGridService m_GridService; 65 protected static IGridService m_GridService;
64 protected static GatekeeperServiceConnector m_GatekeeperConnector; 66 protected static GatekeeperServiceConnector m_GatekeeperConnector;
65 protected static IGatekeeperService m_GatekeeperService; 67 protected static IGatekeeperService m_GatekeeperService;
68 protected static IFriendsService m_FriendsService;
69 protected static IPresenceService m_PresenceService;
70 protected static IUserAccountService m_UserAccountService;
71 protected static IFriendsSimConnector m_FriendsLocalSimConnector; // standalone, points to HGFriendsModule
72 protected static FriendsSimConnector m_FriendsSimConnector; // grid
66 73
67 protected static string m_GridName; 74 protected static string m_GridName;
68 75
69 protected static bool m_BypassClientVerification; 76 protected static bool m_BypassClientVerification;
70 77
71 public UserAgentService(IConfigSource config) 78 public UserAgentService(IConfigSource config) : this(config, null)
72 { 79 {
80 }
81
82 public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector)
83 {
84 // Let's set this always, because we don't know the sequence
85 // of instantiations
86 if (friendsConnector != null)
87 m_FriendsLocalSimConnector = friendsConnector;
88
73 if (!m_Initialized) 89 if (!m_Initialized)
74 { 90 {
75 m_Initialized = true; 91 m_Initialized = true;
76 92
77 m_log.DebugFormat("[HOME USERS SECURITY]: Starting..."); 93 m_log.DebugFormat("[HOME USERS SECURITY]: Starting...");
78 94
95 m_FriendsSimConnector = new FriendsSimConnector();
96
79 IConfig serverConfig = config.Configs["UserAgentService"]; 97 IConfig serverConfig = config.Configs["UserAgentService"];
80 if (serverConfig == null) 98 if (serverConfig == null)
81 throw new Exception(String.Format("No section UserAgentService in config file")); 99 throw new Exception(String.Format("No section UserAgentService in config file"));
@@ -83,6 +101,9 @@ namespace OpenSim.Services.HypergridService
83 string gridService = serverConfig.GetString("GridService", String.Empty); 101 string gridService = serverConfig.GetString("GridService", String.Empty);
84 string gridUserService = serverConfig.GetString("GridUserService", String.Empty); 102 string gridUserService = serverConfig.GetString("GridUserService", String.Empty);
85 string gatekeeperService = serverConfig.GetString("GatekeeperService", String.Empty); 103 string gatekeeperService = serverConfig.GetString("GatekeeperService", String.Empty);
104 string friendsService = serverConfig.GetString("FriendsService", String.Empty);
105 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
106 string userAccountService = serverConfig.GetString("UserAccountService", String.Empty);
86 107
87 m_BypassClientVerification = serverConfig.GetBoolean("BypassClientVerification", false); 108 m_BypassClientVerification = serverConfig.GetBoolean("BypassClientVerification", false);
88 109
@@ -94,6 +115,9 @@ namespace OpenSim.Services.HypergridService
94 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); 115 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
95 m_GatekeeperConnector = new GatekeeperServiceConnector(); 116 m_GatekeeperConnector = new GatekeeperServiceConnector();
96 m_GatekeeperService = ServerUtils.LoadPlugin<IGatekeeperService>(gatekeeperService, args); 117 m_GatekeeperService = ServerUtils.LoadPlugin<IGatekeeperService>(gatekeeperService, args);
118 m_FriendsService = ServerUtils.LoadPlugin<IFriendsService>(friendsService, args);
119 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
120 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args);
97 121
98 m_GridName = serverConfig.GetString("ExternalName", string.Empty); 122 m_GridName = serverConfig.GetString("ExternalName", string.Empty);
99 if (m_GridName == string.Empty) 123 if (m_GridName == string.Empty)
@@ -155,12 +179,17 @@ namespace OpenSim.Services.HypergridService
155 string myExternalIP = string.Empty; 179 string myExternalIP = string.Empty;
156 string gridName = gatekeeper.ServerURI; 180 string gridName = gatekeeper.ServerURI;
157 181
158 m_log.DebugFormat("[USER AGENT SERVICE]: m_grid - {0}, gn - {1}", m_GridName, gridName); 182 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName);
159 183
160 if (m_GridName == gridName) 184 if (m_GridName == gridName)
161 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason); 185 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
162 else 186 else
187 {
163 success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason); 188 success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason);
189 if (success)
190 // Report them as nowhere
191 m_PresenceService.ReportAgent(agentCircuit.SessionID, UUID.Zero);
192 }
164 193
165 if (!success) 194 if (!success)
166 { 195 {
@@ -168,8 +197,11 @@ namespace OpenSim.Services.HypergridService
168 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason); 197 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
169 198
170 // restore the old travel info 199 // restore the old travel info
171 lock (m_TravelingAgents) 200 if(reason != "Logins Disabled")
172 m_TravelingAgents[agentCircuit.SessionID] = old; 201 {
202 lock (m_TravelingAgents)
203 m_TravelingAgents[agentCircuit.SessionID] = old;
204 }
173 205
174 return false; 206 return false;
175 } 207 }
@@ -179,6 +211,7 @@ namespace OpenSim.Services.HypergridService
179 if (clientIP != null) 211 if (clientIP != null)
180 m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString(); 212 m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString();
181 m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP; 213 m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
214
182 return true; 215 return true;
183 } 216 }
184 217
@@ -289,6 +322,213 @@ namespace OpenSim.Services.HypergridService
289 return false; 322 return false;
290 } 323 }
291 324
325 public List<UUID> StatusNotification(List<string> friends, UUID foreignUserID, bool online)
326 {
327 if (m_FriendsService == null || m_PresenceService == null)
328 {
329 m_log.WarnFormat("[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing");
330 return new List<UUID>();
331 }
332
333 List<UUID> localFriendsOnline = new List<UUID>();
334
335 m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count);
336
337 // First, let's double check that the reported friends are, indeed, friends of that user
338 // And let's check that the secret matches
339 List<string> usersToBeNotified = new List<string>();
340 foreach (string uui in friends)
341 {
342 UUID localUserID;
343 string secret = string.Empty, tmp = string.Empty;
344 if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret))
345 {
346 FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID);
347 foreach (FriendInfo finfo in friendInfos)
348 {
349 if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret))
350 {
351 // great!
352 usersToBeNotified.Add(localUserID.ToString());
353 }
354 }
355 }
356 }
357
358 // Now, let's send the notifications
359 m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: user has {0} local friends", usersToBeNotified.Count);
360
361 // First, let's send notifications to local users who are online in the home grid
362 PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray());
363 if (friendSessions != null && friendSessions.Length > 0)
364 {
365 PresenceInfo friendSession = null;
366 foreach (PresenceInfo pinfo in friendSessions)
367 if (pinfo.RegionID != UUID.Zero) // let's guard against traveling agents
368 {
369 friendSession = pinfo;
370 break;
371 }
372
373 if (friendSession != null)
374 {
375 ForwardStatusNotificationToSim(friendSession.RegionID, foreignUserID, friendSession.UserID, online);
376 usersToBeNotified.Remove(friendSession.UserID.ToString());
377 UUID id;
378 if (UUID.TryParse(friendSession.UserID, out id))
379 localFriendsOnline.Add(id);
380
381 }
382 }
383
384 // Lastly, let's notify the rest who may be online somewhere else
385 foreach (string user in usersToBeNotified)
386 {
387 UUID id = new UUID(user);
388 if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName)
389 {
390 string url = m_TravelingAgents[id].GridExternalName;
391 // forward
392 m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
393 }
394 }
395
396 // and finally, let's send the online friends
397 if (online)
398 {
399 return localFriendsOnline;
400 }
401 else
402 return new List<UUID>();
403 }
404
405 protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online)
406 {
407 UUID userID;
408 if (UUID.TryParse(user, out userID))
409 {
410 if (m_FriendsLocalSimConnector != null)
411 {
412 m_log.DebugFormat("[USER AGENT SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline"));
413 m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online);
414 }
415 else
416 {
417 GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID);
418 if (region != null)
419 {
420 m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline"));
421 m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID, online);
422 }
423 }
424 }
425 }
426
427 public List<UUID> GetOnlineFriends(UUID foreignUserID, List<string> friends)
428 {
429 List<UUID> online = new List<UUID>();
430
431 if (m_FriendsService == null || m_PresenceService == null)
432 {
433 m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get online friends because friends or presence services are missing");
434 return online;
435 }
436
437 m_log.DebugFormat("[USER AGENT SERVICE]: Foreign user {0} wants to know status of {1} local friends", foreignUserID, friends.Count);
438
439 // First, let's double check that the reported friends are, indeed, friends of that user
440 // And let's check that the secret matches and the rights
441 List<string> usersToBeNotified = new List<string>();
442 foreach (string uui in friends)
443 {
444 UUID localUserID;
445 string secret = string.Empty, tmp = string.Empty;
446 if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret))
447 {
448 FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID);
449 foreach (FriendInfo finfo in friendInfos)
450 {
451 if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret) &&
452 (finfo.TheirFlags & (int)FriendRights.CanSeeOnline) != 0 && (finfo.TheirFlags != -1))
453 {
454 // great!
455 usersToBeNotified.Add(localUserID.ToString());
456 }
457 }
458 }
459 }
460
461 // Now, let's find out their status
462 m_log.DebugFormat("[USER AGENT SERVICE]: GetOnlineFriends: user has {0} local friends with status rights", usersToBeNotified.Count);
463
464 // First, let's send notifications to local users who are online in the home grid
465 PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray());
466 if (friendSessions != null && friendSessions.Length > 0)
467 {
468 foreach (PresenceInfo pi in friendSessions)
469 {
470 UUID presenceID;
471 if (UUID.TryParse(pi.UserID, out presenceID))
472 online.Add(presenceID);
473 }
474 }
475
476 return online;
477 }
478
479 public Dictionary<string, object> GetServerURLs(UUID userID)
480 {
481 if (m_UserAccountService == null)
482 {
483 m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get server URLs because user account service is missing");
484 return new Dictionary<string, object>();
485 }
486 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero /*!!!*/, userID);
487 if (account != null)
488 return account.ServiceURLs;
489
490 return new Dictionary<string, object>();
491 }
492
493 public string LocateUser(UUID userID)
494 {
495 foreach (TravelingAgentInfo t in m_TravelingAgents.Values)
496 {
497 if (t == null)
498 {
499 m_log.ErrorFormat("[USER AGENT SERVICE]: Oops! Null TravelingAgentInfo. Please report this on mantis");
500 continue;
501 }
502 if (t.UserID == userID && !m_GridName.Equals(t.GridExternalName))
503 return t.GridExternalName;
504 }
505
506 return string.Empty;
507 }
508
509 public string GetUUI(UUID userID, UUID targetUserID)
510 {
511 // Let's see if it's a local user
512 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, targetUserID);
513 if (account != null)
514 return targetUserID.ToString() + ";" + m_GridName + ";" + account.FirstName + " " + account.LastName ;
515
516 // Let's try the list of friends
517 FriendInfo[] friends = m_FriendsService.GetFriends(userID);
518 if (friends != null && friends.Length > 0)
519 {
520 foreach (FriendInfo f in friends)
521 if (f.Friend.StartsWith(targetUserID.ToString()))
522 {
523 // Let's remove the secret
524 UUID id; string tmp = string.Empty, secret = string.Empty;
525 if (Util.ParseUniversalUserIdentifier(f.Friend, out id, out tmp, out tmp, out tmp, out secret))
526 return f.Friend.Replace(secret, "0");
527 }
528 }
529
530 return string.Empty;
531 }
292 } 532 }
293 533
294 class TravelingAgentInfo 534 class TravelingAgentInfo
diff --git a/OpenSim/Services/Interfaces/IFriendsService.cs b/OpenSim/Services/Interfaces/IFriendsService.cs
index 0ddd5e5..1664f3b 100644
--- a/OpenSim/Services/Interfaces/IFriendsService.cs
+++ b/OpenSim/Services/Interfaces/IFriendsService.cs
@@ -74,7 +74,9 @@ namespace OpenSim.Services.Interfaces
74 public interface IFriendsService 74 public interface IFriendsService
75 { 75 {
76 FriendInfo[] GetFriends(UUID PrincipalID); 76 FriendInfo[] GetFriends(UUID PrincipalID);
77 bool StoreFriend(UUID PrincipalID, string Friend, int flags); 77 FriendInfo[] GetFriends(string PrincipalID);
78 bool StoreFriend(string PrincipalID, string Friend, int flags);
78 bool Delete(UUID PrincipalID, string Friend); 79 bool Delete(UUID PrincipalID, string Friend);
80 bool Delete(string PrincipalID, string Friend);
79 } 81 }
80} 82}
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs
index aac8293..220caef 100644
--- a/OpenSim/Services/Interfaces/IGatekeeperService.cs
+++ b/OpenSim/Services/Interfaces/IHypergridServices.cs
@@ -54,9 +54,34 @@ namespace OpenSim.Services.Interfaces
54 bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, out string reason); 54 bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, out string reason);
55 void LogoutAgent(UUID userID, UUID sessionID); 55 void LogoutAgent(UUID userID, UUID sessionID);
56 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); 56 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
57 Dictionary<string, object> GetServerURLs(UUID userID);
58
59 string LocateUser(UUID userID);
60 // Tries to get the universal user identifier for the targetUserId
61 // on behalf of the userID
62 string GetUUI(UUID userID, UUID targetUserID);
63
64 // Returns the local friends online
65 List<UUID> StatusNotification(List<string> friends, UUID userID, bool online);
66 //List<UUID> GetOnlineFriends(UUID userID, List<string> friends);
57 67
58 bool AgentIsComingHome(UUID sessionID, string thisGridExternalName); 68 bool AgentIsComingHome(UUID sessionID, string thisGridExternalName);
59 bool VerifyAgent(UUID sessionID, string token); 69 bool VerifyAgent(UUID sessionID, string token);
60 bool VerifyClient(UUID sessionID, string reportedIP); 70 bool VerifyClient(UUID sessionID, string reportedIP);
61 } 71 }
72
73 public interface IInstantMessage
74 {
75 bool IncomingInstantMessage(GridInstantMessage im);
76 bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner);
77 }
78 public interface IFriendsSimConnector
79 {
80 bool StatusNotify(UUID userID, UUID friendID, bool online);
81 }
82
83 public interface IInstantMessageSimConnector
84 {
85 bool SendInstantMessage(GridInstantMessage im);
86 }
62} 87}
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs
index e543337..73dd06a 100644
--- a/OpenSim/Services/InventoryService/InventoryService.cs
+++ b/OpenSim/Services/InventoryService/InventoryService.cs
@@ -340,6 +340,9 @@ namespace OpenSim.Services.InventoryService
340 List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); 340 List<InventoryItemBase> itemsList = new List<InventoryItemBase>();
341 341
342 itemsList.AddRange(m_Database.getInventoryInFolder(folderID)); 342 itemsList.AddRange(m_Database.getInventoryInFolder(folderID));
343
344// m_log.DebugFormat(
345// "[INVENTORY SERVICE]: Found {0} items in folder {1} for {2}", itemsList.Count, folderID, userID);
343 346
344 return itemsList; 347 return itemsList;
345 } 348 }
@@ -385,8 +388,9 @@ namespace OpenSim.Services.InventoryService
385 // See IInventoryServices 388 // See IInventoryServices
386 public virtual bool AddItem(InventoryItemBase item) 389 public virtual bool AddItem(InventoryItemBase item)
387 { 390 {
388 m_log.DebugFormat( 391// m_log.DebugFormat(
389 "[INVENTORY SERVICE]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); 392// "[INVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}",
393// item.Name, item.ID, item.Folder, item.Owner);
390 394
391 m_Database.addInventoryItem(item); 395 m_Database.addInventoryItem(item);
392 396
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index 58c59eb..eeab67a 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -40,9 +40,9 @@ namespace OpenSim.Services.InventoryService
40{ 40{
41 public class XInventoryService : ServiceBase, IInventoryService 41 public class XInventoryService : ServiceBase, IInventoryService
42 { 42 {
43// private static readonly ILog m_log = 43 //private static readonly ILog m_log =
44// LogManager.GetLogger( 44 // LogManager.GetLogger(
45// MethodBase.GetCurrentMethod().DeclaringType); 45 // MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 protected IXInventoryData m_Database; 47 protected IXInventoryData m_Database;
48 protected bool m_AllowDelete = true; 48 protected bool m_AllowDelete = true;
@@ -385,8 +385,8 @@ namespace OpenSim.Services.InventoryService
385 385
386 public virtual bool AddItem(InventoryItemBase item) 386 public virtual bool AddItem(InventoryItemBase item)
387 { 387 {
388// m_log.DebugFormat( 388 //m_log.DebugFormat(
389// "[XINVENTORY SERVICE]: Adding item {0} to folder {1} for {2}", item.ID, item.Folder, item.Owner); 389 // "[XINVENTORY SERVICE]: Adding item {0} to folder {1} for {2}", item.ID, item.Folder, item.Owner);
390 390
391 return m_Database.StoreItem(ConvertFromOpenSim(item)); 391 return m_Database.StoreItem(ConvertFromOpenSim(item));
392 } 392 }
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index f8868f5..82acfbc 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -627,7 +627,19 @@ namespace OpenSim.Services.LLLoginService
627 if (finfo.TheirFlags == -1) 627 if (finfo.TheirFlags == -1)
628 continue; 628 continue;
629 LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(finfo.Friend); 629 LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(finfo.Friend);
630 buddyitem.BuddyID = finfo.Friend; 630 // finfo.Friend may not be a simple uuid
631 UUID friendID = UUID.Zero;
632 if (UUID.TryParse(finfo.Friend, out friendID))
633 buddyitem.BuddyID = finfo.Friend;
634 else
635 {
636 string tmp;
637 if (Util.ParseUniversalUserIdentifier(finfo.Friend, out friendID, out tmp, out tmp, out tmp, out tmp))
638 buddyitem.BuddyID = friendID.ToString();
639 else
640 // junk entry
641 continue;
642 }
631 buddyitem.BuddyRightsHave = (int)finfo.TheirFlags; 643 buddyitem.BuddyRightsHave = (int)finfo.TheirFlags;
632 buddyitem.BuddyRightsGiven = (int)finfo.MyFlags; 644 buddyitem.BuddyRightsGiven = (int)finfo.MyFlags;
633 buddylistreturn.AddNewBuddy(buddyitem); 645 buddylistreturn.AddNewBuddy(buddyitem);
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index ffed15e..6683caf 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -523,6 +523,7 @@ namespace OpenSim.Services.LLLoginService
523 // free uri form 523 // free uri form
524 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 524 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34
525 where = "url"; 525 where = "url";
526 GridRegion region = null;
526 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); 527 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
527 Match uriMatch = reURI.Match(startLocation); 528 Match uriMatch = reURI.Match(startLocation);
528 if (uriMatch == null) 529 if (uriMatch == null)
@@ -553,8 +554,18 @@ namespace OpenSim.Services.LLLoginService
553 } 554 }
554 else 555 else
555 { 556 {
556 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not provide default regions.", startLocation); 557 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
557 return null; 558 region = FindAlternativeRegion(scopeID);
559 if (region != null)
560 {
561 where = "safe";
562 return region;
563 }
564 else
565 {
566 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not provide default regions and no alternative found.", startLocation);
567 return null;
568 }
558 } 569 }
559 } 570 }
560 return regions[0]; 571 return regions[0];
@@ -582,7 +593,8 @@ namespace OpenSim.Services.LLLoginService
582 if (parts.Length > 1) 593 if (parts.Length > 1)
583 UInt32.TryParse(parts[1], out port); 594 UInt32.TryParse(parts[1], out port);
584 595
585 GridRegion region = FindForeignRegion(domainName, port, regionName, out gatekeeper); 596// GridRegion region = FindForeignRegion(domainName, port, regionName, out gatekeeper);
597 region = FindForeignRegion(domainName, port, regionName, out gatekeeper);
586 return region; 598 return region;
587 } 599 }
588 } 600 }
@@ -811,16 +823,13 @@ namespace OpenSim.Services.LLLoginService
811 // Old style: get the service keys from the DB 823 // Old style: get the service keys from the DB
812 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) 824 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
813 { 825 {
814 if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty)) 826 if (kvp.Value != null)
815 {
816 aCircuit.ServiceURLs[kvp.Key] = m_LoginServerConfig.GetString(kvp.Key, string.Empty);
817 }
818 else
819 { 827 {
820 aCircuit.ServiceURLs[kvp.Key] = kvp.Value; 828 aCircuit.ServiceURLs[kvp.Key] = kvp.Value;
829
830 if (!aCircuit.ServiceURLs[kvp.Key].ToString().EndsWith("/"))
831 aCircuit.ServiceURLs[kvp.Key] = aCircuit.ServiceURLs[kvp.Key] + "/";
821 } 832 }
822 if (!aCircuit.ServiceURLs[kvp.Key].ToString().EndsWith("/"))
823 aCircuit.ServiceURLs[kvp.Key] = aCircuit.ServiceURLs[kvp.Key] + "/";
824 } 833 }
825 834
826 // New style: service keys start with SRV_; override the previous 835 // New style: service keys start with SRV_; override the previous
@@ -828,16 +837,29 @@ namespace OpenSim.Services.LLLoginService
828 837
829 if (keys.Length > 0) 838 if (keys.Length > 0)
830 { 839 {
840 bool newUrls = false;
831 IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("SRV_")); 841 IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("SRV_"));
832 foreach (string serviceKey in serviceKeys) 842 foreach (string serviceKey in serviceKeys)
833 { 843 {
834 string keyName = serviceKey.Replace("SRV_", ""); 844 string keyName = serviceKey.Replace("SRV_", "");
835 aCircuit.ServiceURLs[keyName] = m_LoginServerConfig.GetString(serviceKey, string.Empty); 845 string keyValue = m_LoginServerConfig.GetString(serviceKey, string.Empty);
836 if (!aCircuit.ServiceURLs[keyName].ToString().EndsWith("/")) 846 if (!keyValue.EndsWith("/"))
837 aCircuit.ServiceURLs[keyName] = aCircuit.ServiceURLs[keyName] + "/"; 847 keyValue = keyValue + "/";
848
849 if (!account.ServiceURLs.ContainsKey(keyName) || (account.ServiceURLs.ContainsKey(keyName) && account.ServiceURLs[keyName] != keyValue))
850 {
851 account.ServiceURLs[keyName] = keyValue;
852 newUrls = true;
853 }
854 aCircuit.ServiceURLs[keyName] = keyValue;
838 855
839 m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]); 856 m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
840 } 857 }
858
859 // The grid operator decided to override the defaults in the
860 // [LoginService] configuration. Let's store the correct ones.
861 if (newUrls)
862 m_UserAccountService.StoreUserAccount(account);
841 } 863 }
842 864
843 } 865 }