public void Startup(ConfigurationLoader loader) { HomeURI = loader.HomeURI; m_AgentInventoryService = loader.GetService <InventoryServiceInterface>(m_AgentInventoryServiceName); m_AgentAssetService = loader.GetService <AssetServiceInterface>(m_AgentAssetServiceName); if (m_AgentProfileServiceName?.Length != 0) { m_AgentProfileService = loader.GetService <ProfileServiceInterface>(m_AgentProfileServiceName); } m_AgentFriendsService = loader.GetService <FriendsServiceInterface>(m_AgentFriendsServiceName); m_UserSessionService = loader.GetService <UserSessionServiceInterface>(m_UserSessionServiceName); m_GridService = loader.GetService <GridServiceInterface>(m_GridServiceName); if (m_OfflineIMServiceName?.Length != 0) { m_OfflineIMService = loader.GetService <OfflineIMServiceInterface>(m_OfflineIMServiceName); } if (m_AgentExperienceServiceName?.Length != 0) { loader.GetService(m_AgentExperienceServiceName, out m_AgentExperienceService); } if (m_AgentGroupsServiceName?.Length != 0) { loader.GetService(m_AgentGroupsServiceName, out m_AgentGroupsService); } m_UserAccountService = loader.GetService <UserAccountServiceInterface>(m_UserAccountServiceName); m_AgentUserAgentService = new LocalUserAgentService(m_UserSessionService, m_UserAccountService, m_RequiresInventoryIDAsIMSessionID, HomeURI); m_Scenes = loader.Scenes; m_Commands = loader.CommandRegistry; m_CapsRedirector = loader.CapsRedirector; m_PacketHandlerPlugins = loader.GetServicesByValue <IProtocolExtender>(); }
public InventoryTransferWorkItem( UUID transactionID, UGUI dstAgent, UserAgentServiceInterface dstUserAgentService, InventoryServiceInterface dstInventoryService, AssetServiceInterface dstAssetService, UGUIWithName srcAgent, InventoryServiceInterface srcInventoryService, AssetServiceInterface srcAssetService, UUID assetid, InventoryItem item, IMServiceInterface imService, Action <UUID> inventoryCreate) : base(dstAssetService, srcAssetService, assetid, ReferenceSource.Source) { m_TransactionID = transactionID; m_DstUserAgentService = dstUserAgentService; m_DstInventoryService = dstInventoryService; m_SrcInventoryService = srcInventoryService; m_DestinationAgent = dstAgent; m_Item = item; m_SrcAgent = srcAgent; m_IMService = imService; m_InventoryCreate = inventoryCreate; }
public static void StartTransferLocal( UUID transactionID, UGUI dstAgent, UserAgentServiceInterface dstUserAgentService, InventoryServiceInterface dstInventoryService, AssetServiceInterface dstAssetService, UGUIWithName srcAgent, InventoryServiceInterface srcInventoryService, AssetServiceInterface srcAssetService, AssetType givenAssetType, UUID givenInventoryID, IMServiceInterface imService, Action <UUID> inventoryCreate = null) => StartTransfer( transactionID, dstAgent, dstUserAgentService, dstInventoryService, dstAssetService, srcAgent, null, srcInventoryService, srcAssetService, givenAssetType, givenInventoryID, imService, inventoryCreate);
public void HandleInventoryDeclined(ViewerAgent dstAgent, AgentCircuit circuit, Message m) { var im = (ImprovedInstantMessage)m; UserAgentServiceInterface userAgentService = dstAgent.UserAgentService; InventoryServiceInterface inventorySerice = dstAgent.InventoryService; if (userAgentService == null) { return; } if (userAgentService.SupportsInventoryTransfer) { userAgentService.DeclineInventoryTransfer(dstAgent.ID, im.ID); } else { SceneInterface scene = circuit.Scene; if (scene == null) { return; } UGUI toAgent; if (!scene.AvatarNameService.TryGetValue(im.ToAgentID, out toAgent)) { /* pass the unresolved here */ toAgent = new UGUI(im.ToAgentID); } InventoryFolder trashFolder; if (userAgentService.RequiresInventoryIDAsIMSessionID && inventorySerice != null && inventorySerice.Folder.TryGetValue(dstAgent.ID, AssetType.TrashFolder, out trashFolder)) { if (inventorySerice.Item.ContainsKey(dstAgent.ID, im.ID)) { inventorySerice.Item.Move(dstAgent.ID, im.ID, trashFolder.ID); } else { inventorySerice.Folder.Move(dstAgent.ID, im.ID, trashFolder.ID); } } m_IMService.Send(new GridInstantMessage { ToAgent = toAgent, FromAgent = dstAgent.NamedOwner, Message = string.Empty, IMSessionID = im.ID, Dialog = GridInstantMessageDialog.InventoryDeclined }); } }
private bool TryGetServices(UGUI targetAgentId, out InventoryServiceInterface inventoryService, out AssetServiceInterface assetService) { UserAgentServiceInterface userAgentService = null; inventoryService = null; assetService = null; if (targetAgentId.HomeURI == null) { return(false); } var homeUri = targetAgentId.HomeURI.ToString(); var heloheaders = ServicePluginHelo.HeloRequest(homeUri); foreach (IUserAgentServicePlugin userAgentPlugin in UserAgentServicePlugins) { if (userAgentPlugin.IsProtocolSupported(homeUri, heloheaders)) { userAgentService = userAgentPlugin.Instantiate(homeUri); } } if (userAgentService == null) { return(false); } ServerURIs serverurls = userAgentService.GetServerURLs(targetAgentId); string inventoryServerURI = serverurls.InventoryServerURI; string assetServerURI = serverurls.AssetServerURI; heloheaders = ServicePluginHelo.HeloRequest(inventoryServerURI); foreach (IInventoryServicePlugin inventoryPlugin in InventoryServicePlugins) { if (inventoryPlugin.IsProtocolSupported(inventoryServerURI, heloheaders)) { inventoryService = inventoryPlugin.Instantiate(inventoryServerURI); break; } } heloheaders = ServicePluginHelo.HeloRequest(assetServerURI); foreach (IAssetServicePlugin assetPlugin in AssetServicePlugins) { if (assetPlugin.IsProtocolSupported(assetServerURI, heloheaders)) { assetService = assetPlugin.Instantiate(assetServerURI); break; } } return(inventoryService != null && assetService != null); }
private bool RouteIM(GridInstantMessage im) { if (im.ToAgent.HomeURI == null) { return(false); } string homeUri = im.ToAgent.HomeURI.ToString(); var heloheaders = ServicePluginHelo.HeloRequest(homeUri); UserAgentServiceInterface userAgentService = null; foreach (IUserAgentServicePlugin userAgentPlugin in m_UserAgentServicePlugins) { if (userAgentPlugin.IsProtocolSupported(homeUri, heloheaders)) { userAgentService = userAgentPlugin.Instantiate(homeUri); } } if (userAgentService == null) { return(false); } IMServiceInterface imService; try { imService = userAgentService.GetIMService(im.ToAgent.ID); } catch (Exception e) { m_Log.Debug($"Failed to deliver IM to {homeUri}: User lookup failed", e); return(false); } try { imService.Send(im); } catch (Exception e) { m_Log.Debug($"Failed to deliver IM to {homeUri}: Delivery failed", e); return(false); } return(true); }
public ViewerAgent( SceneList scenes, UUID agentID, string firstName, string lastName, Uri homeURI, UUID sessionID, UUID secureSessionID, ClientInfo clientInfo, UserAccount untrustedAccountInfo, AgentServiceList serviceList) : base(agentID, homeURI) { m_Scenes = scenes; m_TeleportServices = serviceList.GetAll <IAgentTeleportServiceInterface>(); foreach (IAgentTeleportServiceInterface service in m_TeleportServices) { service.Agent = this; } CollisionPlane = Vector4.UnitW; SessionID = sessionID; m_UntrustedAccountInfo = untrustedAccountInfo; m_SecureSessionID = secureSessionID; Client = clientInfo; m_AssetService = serviceList.Get <AssetServiceInterface>(); m_InventoryService = serviceList.Get <InventoryServiceInterface>(); m_GroupsService = serviceList.Get <GroupsServiceInterface>(); m_ExperienceService = serviceList.Get <ExperienceServiceInterface>(); m_ProfileService = serviceList.Get <ProfileServiceInterface>(); m_FriendsService = serviceList.Get <FriendsServiceInterface>(); m_UserAgentService = serviceList.Get <UserAgentServiceInterface>(); m_PresenceService = serviceList.Get <IPresenceServiceInterface>(); EconomyService = serviceList.Get <EconomyServiceInterface>(); OfflineIMService = serviceList.Get <OfflineIMServiceInterface>(); MuteListService = serviceList.Get <MuteListServiceInterface>(); FirstName = firstName; LastName = lastName; OnPositionChange += ChildUpdateOnPositionChange; OnAppearanceUpdate += HandleAppearanceUpdate; }
public void HandleInventoryAccepted(ViewerAgent dstAgent, AgentCircuit circuit, Message m) { var im = (ImprovedInstantMessage)m; UserAgentServiceInterface userAgentService = dstAgent.UserAgentService; if (userAgentService == null) { return; } if (userAgentService.SupportsInventoryTransfer) { userAgentService.AcceptInventoryTransfer(dstAgent.ID, im.ID); } else { SceneInterface scene = circuit.Scene; if (scene == null) { return; } UGUI toAgent; if (!scene.AvatarNameService.TryGetValue(im.ToAgentID, out toAgent)) { /* pass the unresolved here */ toAgent = new UGUI(im.ToAgentID); } m_IMService.Send(new GridInstantMessage { ToAgent = toAgent, FromAgent = dstAgent.NamedOwner, Message = string.Empty, IMSessionID = im.ID, Dialog = GridInstantMessageDialog.InventoryAccepted }); } }
public static bool StartTransfer( UUID transactionID, UGUI dstAgent, IReadOnlyList <IUserAgentServicePlugin> userAgentServicePlugins, IReadOnlyList <IInventoryServicePlugin> inventoryServicePlugins, IReadOnlyList <IAssetServicePlugin> assetServicePlugins, UGUIWithName srcAgent, UserAgentServiceInterface srcUserAgentService, InventoryServiceInterface srcInventoryService, AssetServiceInterface srcAssetService, AssetType givenAssetType, UUID givenInventoryID, IMServiceInterface imService, Action <UUID> inventoryCreate = null) { InventoryServiceInterface dstInventoryService = null; AssetServiceInterface dstAssetService = null; UserAgentServiceInterface dstUserAgentService = null; if (dstAgent.HomeURI == null) { m_Log.ErrorFormat("No route to agent id {0}", dstAgent.ID); return(false); } var homeUri = dstAgent.HomeURI.ToString(); var heloheaders = ServicePluginHelo.HeloRequest(homeUri); foreach (IUserAgentServicePlugin userAgentPlugin in userAgentServicePlugins) { if (userAgentPlugin.IsProtocolSupported(homeUri, heloheaders)) { dstUserAgentService = userAgentPlugin.Instantiate(homeUri); } } if (dstUserAgentService == null) { m_Log.ErrorFormat("No user agent service found to agent id {0}", dstAgent.ID); return(false); } ServerURIs uris = dstUserAgentService.GetServerURLs(dstAgent); heloheaders = ServicePluginHelo.HeloRequest(uris.AssetServerURI); foreach (IAssetServicePlugin assetPlugin in assetServicePlugins) { if (assetPlugin.IsProtocolSupported(homeUri, heloheaders)) { dstAssetService = assetPlugin.Instantiate(homeUri); } } if (dstAssetService == null) { m_Log.ErrorFormat("No asset service found to agent id {0}", dstAgent.ID); return(false); } heloheaders = ServicePluginHelo.HeloRequest(uris.InventoryServerURI); foreach (IInventoryServicePlugin inventoryPlugin in inventoryServicePlugins) { if (inventoryPlugin.IsProtocolSupported(homeUri, heloheaders)) { dstInventoryService = inventoryPlugin.Instantiate(homeUri); } } if (dstInventoryService == null) { m_Log.ErrorFormat("No inventory service found to agent id {0}", dstAgent.ID); return(false); } StartTransfer( transactionID, dstAgent, dstUserAgentService, dstInventoryService, dstAssetService, srcAgent, srcUserAgentService, srcInventoryService, srcAssetService, givenAssetType, givenInventoryID, imService, inventoryCreate); return(true); }
public static void StartTransfer( UUID transactionID, UGUI dstAgent, UserAgentServiceInterface dstUserAgentService, InventoryServiceInterface dstInventoryService, AssetServiceInterface dstAssetService, UGUIWithName srcAgent, UserAgentServiceInterface srcUserAgentService, InventoryServiceInterface srcInventoryService, AssetServiceInterface srcAssetService, AssetType givenAssetType, UUID givenInventoryID, IMServiceInterface imService, Action <UUID> inventoryCreate = null) { if (dstUserAgentService == null) { throw new ArgumentNullException(nameof(dstUserAgentService)); } if (dstInventoryService == null) { throw new ArgumentNullException(nameof(dstInventoryService)); } if (dstAssetService == null) { throw new ArgumentNullException(nameof(dstAssetService)); } if (srcInventoryService == null) { throw new ArgumentNullException(nameof(srcInventoryService)); } if (srcAssetService == null) { throw new ArgumentNullException(nameof(srcAssetService)); } if (imService == null) { throw new ArgumentNullException(nameof(imService)); } if (srcUserAgentService != null && srcUserAgentService.SupportsInventoryTransfer) { srcUserAgentService.InitiateInventoryTransfer(dstAgent, srcAgent, givenAssetType, givenInventoryID, transactionID); return; } if (givenAssetType == AssetType.Folder) { InventoryFolder folder; #if DEBUG m_Log.DebugFormat("Sending folder {0} from {1} to {2}", givenInventoryID, srcAgent, dstAgent); #endif if (srcInventoryService.Folder.TryGetValue(srcAgent.ID, givenInventoryID, out folder)) { /* this has a whole bunch of such entries, but later only the first 17 bytes are kept and adjusted */ var assetids = new List <UUID>(); TransferInventoryFolder transferFolder = GetTree(srcInventoryService, folder, assetids); if (transferFolder != null) { new InventoryTransferWorkItem( transactionID, dstAgent, dstUserAgentService, dstInventoryService, dstAssetService, srcAgent, srcInventoryService, srcAssetService, assetids, transferFolder, imService, inventoryCreate).QueueWorkItem(); } } else { #if DEBUG m_Log.DebugFormat("Sending folder {0} from {1} to {2}: Not found", givenInventoryID, srcAgent, dstAgent); #endif } } else { #if DEBUG m_Log.DebugFormat("Sending item {0} from {1} to {2}", givenInventoryID, srcAgent, dstAgent); #endif /* just some item */ InventoryItem item; if (srcInventoryService.Item.TryGetValue(srcAgent.ID, givenInventoryID, out item) && item.AssetType != AssetType.Link && item.AssetType != AssetType.LinkFolder && item.CheckPermissions(srcAgent, UGI.Unknown, InventoryPermissionsMask.Transfer)) { new InventoryTransferWorkItem( transactionID, dstAgent, dstUserAgentService, dstInventoryService, dstAssetService, srcAgent, srcInventoryService, dstAssetService, item.AssetID, item, imService, inventoryCreate).QueueWorkItem(); } else { #if DEBUG m_Log.DebugFormat("Sending item {0} from {1} to {2}: Not found", givenInventoryID, srcAgent, dstAgent); #endif } } }
private void HandleStatusMsg(KeyValuePair <UGUI, bool> statusMsg) { bool isOnline = statusMsg.Value; UGUI user = statusMsg.Key; var signalingTo = new Dictionary <string, List <FriendInfo> >(); if (isOnline) { foreach (FriendInfo fi in m_FriendsService[user]) { string homeURI = fi.User.HomeURI?.ToString() ?? m_GatekeeperURI; List <FriendInfo> friendsPerHomeURI; if ((fi.FriendGivenFlags & FriendRightFlags.SeeOnline) != 0) { if (!signalingTo.TryGetValue(homeURI, out friendsPerHomeURI)) { friendsPerHomeURI = new List <FriendInfo>(); signalingTo.Add(homeURI, friendsPerHomeURI); } friendsPerHomeURI.Add(fi); } } } else if (!m_UserSessionService.ContainsKey(user)) { foreach (FriendInfo fi in m_FriendsService[user]) { string homeURI = fi.User.HomeURI?.ToString() ?? m_GatekeeperURI; List <FriendInfo> friendsPerHomeURI; if ((fi.FriendGivenFlags & FriendRightFlags.SeeOnline) != 0) { if (!signalingTo.TryGetValue(homeURI, out friendsPerHomeURI)) { friendsPerHomeURI = new List <FriendInfo>(); signalingTo.Add(homeURI, friendsPerHomeURI); } friendsPerHomeURI.Add(fi); } } } if (signalingTo.Count == 0) { return; } foreach (KeyValuePair <string, List <FriendInfo> > kvp in signalingTo) { Dictionary <string, string> heloheaders; try { heloheaders = ServicePluginHelo.HeloRequest(kvp.Key); } catch (Exception e) { m_Log.Debug("Failed to retrieve user agent HELO", e); continue; } if (kvp.Key == m_GatekeeperURI) { /* local stuff */ if (m_FriendsSimStatusNotifierService != null) { try { m_FriendsSimStatusNotifierService.NotifyStatus(user, new List <UGUI>(from x in kvp.Value select x.Friend), isOnline); } catch (Exception e) { m_Log.Debug($"Failed to send status to {kvp.Key}", e); } } } else { UserAgentServiceInterface userAgentService = null; foreach (IUserAgentServicePlugin userAgentPlugin in m_UserAgentServicePlugins) { if (userAgentPlugin.IsProtocolSupported(kvp.Key)) { userAgentService = userAgentPlugin.Instantiate(kvp.Key); break; } } if (userAgentService == null) { continue; } List <KeyValuePair <UGUI, string> > notifiedFriends = new List <KeyValuePair <UGUI, string> >(); foreach (FriendInfo fi in kvp.Value) { notifiedFriends.Add(new KeyValuePair <UGUI, string>(fi.Friend, fi.Secret)); } try { userAgentService.NotifyStatus(notifiedFriends, user, isOnline); } catch (Exception e) { m_Log.Debug($"Failed to send status to {kvp.Key}", e); } } } }
public ProfileServiceData(UserAgentServiceInterface userAgent, ProfileServiceInterface profileService) { UserAgentService = userAgent; ProfileService = profileService; TicksAt = Environment.TickCount; }
private ProfileServiceData LookupProfileService(SceneInterface scene, UUID agentID, out UGUI agentUUI) { ProfileServiceData serviceData = null; ProfileServiceInterface profileService = null; UserAgentServiceInterface userAgentService = null; agentUUI = UGUI.Unknown; if (profileService == null) { try { IAgent agent = scene.Agents[agentID]; agentUUI = agent.NamedOwner; profileService = agent.ProfileService; userAgentService = agent.UserAgentService; if (profileService == null) { profileService = new DummyProfileService(); } if (userAgentService == null) { userAgentService = new DummyUserAgentService(); } serviceData = new ProfileServiceData(userAgentService, profileService); } catch { agentUUI = UGUI.Unknown; } } if (profileService == null && userAgentService == null) { UGUI uui; try { uui = scene.AvatarNameService[agentID]; agentUUI = uui; if (!m_LastKnownProfileServices.TryGetValue(uui.HomeURI.ToString(), out serviceData)) { foreach (IUserAgentServicePlugin userAgentPlugin in m_UserAgentServices) { if (userAgentPlugin.IsProtocolSupported(uui.HomeURI.ToString())) { userAgentService = userAgentPlugin.Instantiate(uui.HomeURI.ToString()); break; } } Dictionary <string, string> urls = userAgentService.GetServerURLs(uui); if (urls.ContainsKey("ProfileServerURI")) { string profileServerURI = urls["ProfileServerURI"]; foreach (IProfileServicePlugin profilePlugin in m_ProfileServices) { if (profilePlugin.IsProtocolSupported(profileServerURI)) { profileService = profilePlugin.Instantiate(profileServerURI); } } } if (userAgentService != null) { if (profileService == null) { profileService = new DummyProfileService(); } serviceData = new ProfileServiceData(userAgentService, profileService); m_LastKnownProfileServices.Add(uui.HomeURI.ToString(), serviceData); } } } catch { agentUUI = UGUI.Unknown; } } return(serviceData); }
public bool TryGetFriendsService(UGUI agent, out FriendsServiceInterface friendsService) { friendsService = null; if (agent.HomeURI == null) { return(false); } string[] handlerType; var homeURI = agent.HomeURI.ToString(); try { handlerType = ServicePluginHelo.HeloRequest_HandleType(homeURI); } catch { return(false); } UserAgentServiceInterface userAgentService = null; foreach (var service in m_UserAgentPlugins) { if (handlerType.Contains(service.Name)) { userAgentService = service.Instantiate(homeURI); break; } } if (userAgentService == null) { return(false); } string friendsUri; Dictionary <string, string> serviceurls; try { serviceurls = userAgentService.GetServerURLs(agent); } catch { return(false); } if (!serviceurls.TryGetValue("FriendsServerURI", out friendsUri)) { return(false); } try { handlerType = ServicePluginHelo.HeloRequest_HandleType(friendsUri); } catch { return(false); } foreach (var service in m_FriendsPlugins) { if (handlerType.Contains(service.Name)) { friendsService = service.Instantiate(friendsUri); return(true); } } return(false); }