Exemplo n.º 1
0
        /// <summary>
        /// Cache the friends list or increment the refcount for the existing friends list.
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <returns>
        /// Returns true if the list was fetched, false if it wasn't
        /// </returns>
        protected virtual bool CacheFriends(IClientAPI client)
        {
            bool           result = false;
            UserFriendData friendsData;
            UUID           agentID = client.AgentId;

            if (!m_Friends.TryGetValue(agentID, out friendsData))
            {
                /* better to do some unnecessary fetches outside of an WriterLock instead of trying to reduce that and locking up the FriendsModule */
                friendsData             = new UserFriendData();
                friendsData.PrincipalID = agentID;
                friendsData.Friends     = GetFriendsFromService(client);

                try
                {
                    m_Friends.AddIfNotExists(agentID, delegate()
                    {
                        result = true;
                        return(friendsData);
                    });
                }
                catch (ThreadedClasses.RwLockedDictionary <UUID, UserFriendData> .KeyAlreadyExistsException)
                {
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        // Legacy. Just don't do this.
        // Returns 'null' if region not found
        public double[,] LoadTerrain(UUID regionID)
        {
            HeightMapTerrainData data;

            if (m_terrains.TryGetValue(regionID, out data))
            {
                return(data.GetDoubles());
            }
            return(null);
        }
Exemplo n.º 3
0
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        public JsonStoreNodeType GetNodeType(UUID storeID, string path)
        {
            if (!m_enabled)
            {
                return(JsonStoreNodeType.Undefined);
            }

            JsonStore map = null;

            if (!m_JsonValueStore.TryGetValue(storeID, out map))
            {
                m_log.InfoFormat("[JsonStore] Missing store {0}", storeID);
                return(JsonStoreNodeType.Undefined);
            }

            try
            {
                lock (map)
                    return(map.GetNodeType(path));
            }
            catch (Exception e)
            {
                m_log.Error(string.Format("[JsonStore]: Path test failed for {0} in {1}", path, storeID), e);
            }

            return(JsonStoreNodeType.Undefined);
        }
Exemplo n.º 4
0
        private bool HasEvents(UUID RequestID, UUID sessionID)
        {
            ConsoleConnection c = null;

            if (!m_Connections.TryGetValue(sessionID, out c))
            {
                return(false);
            }
            c.last = System.Environment.TickCount;
            if (c.lastLineSeen < m_LineNumber)
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Returns the item if it exists in this folder or in any of this folder's descendant folders
        /// </summary>
        /// <param name="itemID"></param>
        /// <returns>null if the item is not found</returns>
        public InventoryItemBase FindItem(UUID itemID)
        {
            InventoryItemBase ret;

            if (Items.TryGetValue(itemID, out ret))
            {
                return(ret);
            }

            try
            {
                foreach (InventoryFolderImpl folder in m_childFolders.Values)
                {
                    InventoryItemBase item = folder.FindItem(itemID);

                    if (item != null)
                    {
                        throw new ThreadedClasses.ReturnValueException <InventoryItemBase>(item);
                    }
                }
            }
            catch (ThreadedClasses.ReturnValueException <InventoryItemBase> e)
            {
                return(e.Value);
            }

            return(null);
        }
Exemplo n.º 6
0
        /**********************************************
         * Remote Data Reply
         *
         * Response to RPC message
         *
         *********************************************/

        public void RemoteDataReply(string channel, string message_id, string sdata, int idata)
        {
            UUID message_key = new UUID(message_id);
            UUID channel_key = new UUID(channel);

            RPCRequestInfo rpcInfo = null;

            if (message_key == UUID.Zero)
            {
                m_rpcPendingResponses.ForEach(delegate(RPCRequestInfo oneRpcInfo)
                {
                    if (oneRpcInfo.GetChannelKey() == channel_key)
                    {
                        rpcInfo = oneRpcInfo;
                    }
                });
            }
            else
            {
                m_rpcPendingResponses.TryGetValue(message_key, out rpcInfo);
            }

            if (rpcInfo != null)
            {
                rpcInfo.SetStrRetval(sdata);
                rpcInfo.SetIntRetval(idata);
                rpcInfo.SetProcessed(true);
                m_rpcPendingResponses.Remove(message_key);
            }
            else
            {
                m_log.Warn("[XML RPC MODULE]: Channel or message_id not found");
            }
        }
Exemplo n.º 7
0
        public XGroup GetGroup(UUID groupID)
        {
            XGroup group = null;

            m_groups.TryGetValue(groupID, out group);

            return(group);
        }
        /// <summary>
        /// Get a child folder
        /// </summary>
        /// <param name="folderID"></param>
        /// <returns>The folder if it exists, null if it doesn't</returns>
        public InventoryFolderImpl GetChildFolder(UUID folderID)
        {
            InventoryFolderImpl folder = null;

            m_childFolders.TryGetValue(folderID, out folder);

            return(folder);
        }
        void HandleUUIDNameRequest(UUID uuid, IClientAPI client)
        {
//            m_log.DebugFormat(
//                "[USER MANAGEMENT MODULE]: Handling request for name binding of UUID {0} from {1}",
//                uuid, remote_client.Name);

            if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid))
            {
                client.SendNameReply(uuid, "Mr", "OpenSim");
            }
            else
            {
                UserData user;
                /* bypass that continuation here when entry is already available */
                if (m_UserCache.TryGetValue(uuid, out user))
                {
                    if (!user.IsUnknownUser && user.HasGridUserTried)
                    {
                        client.SendNameReply(uuid, user.FirstName, user.LastName);
                        return;
                    }
                }

                // Not found in cache, queue continuation
                m_ServiceThrottle.Enqueue("name", uuid.ToString(), delegate
                {
                    //m_log.DebugFormat("[YYY]: Name request {0}", uuid);

                    // As least upto September 2013, clients permanently cache UUID -> Name bindings.  Some clients
                    // appear to clear this when the user asks it to clear the cache, but others may not.
                    //
                    // So to avoid clients
                    // (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will
                    // instead drop the request entirely.
                    if (GetUser(uuid, out user))
                    {
                        client.SendNameReply(uuid, user.FirstName, user.LastName);
                    }
//                    else
//                        m_log.DebugFormat(
//                            "[USER MANAGEMENT MODULE]: No bound name for {0} found, ignoring request from {1}",
//                            uuid, client.Name);
                });
            }
        }
Exemplo n.º 10
0
        public string GetInventoryServiceURL(UUID userID)
        {
            string inventoryURL;

            if (m_InventoryURLs.TryGetValue(userID, out inventoryURL))
            {
                return(inventoryURL);
            }

            CacheInventoryServiceURL(userID);

            if (m_InventoryURLs.TryGetValue(userID, out inventoryURL))
            {
                return(inventoryURL);
            }

            return(null); //it means that the methods should forward to local grid's inventory
        }
Exemplo n.º 11
0
 /// <summary>
 /// May return a null queue
 /// </summary>
 /// <param name="agentId"></param>
 /// <returns></returns>
 private ThreadedClasses.BlockingQueue <OSD> GetQueue(UUID agentId)
 {
     ThreadedClasses.BlockingQueue <OSD> queue = null;
     if (queues.TryGetValue(agentId, out queue))
     {
         return(queue);
     }
     return(null);
 }
Exemplo n.º 12
0
        public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response = new XmlRpcResponse();

            Hashtable requestData = (Hashtable)request.Params[0];
            bool      GoodXML     = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
                                     requestData.Contains("StringValue"));

            if (GoodXML)
            {
                UUID           channel = new UUID((string)requestData["Channel"]);
                RPCChannelInfo rpcChanInfo;
                if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
                {
                    string intVal = Convert.ToInt32(requestData["IntValue"]).ToString();
                    string strVal = (string)requestData["StringValue"];

                    RPCRequestInfo rpcInfo;

                    rpcInfo =
                        new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
                                           intVal);
                    m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);

                    int timeoutCtr = 0;

                    while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
                    {
                        Thread.Sleep(RemoteReplyScriptWait);
                        timeoutCtr += RemoteReplyScriptWait;
                    }
                    if (rpcInfo.IsProcessed())
                    {
                        Hashtable param = new Hashtable();
                        param["StringValue"] = rpcInfo.GetStrRetval();
                        param["IntValue"]    = rpcInfo.GetIntRetval();

                        ArrayList parameters = new ArrayList();
                        parameters.Add(param);

                        response.Value = parameters;
                        rpcInfo        = null;
                    }
                    else
                    {
                        response.SetFault(-1, "Script timeout");
                        rpcInfo = null;
                    }
                }
                else
                {
                    response.SetFault(-1, "Invalid channel");
                }
            }

            return(response);
        }
Exemplo n.º 13
0
        public void InsertEmail(UUID to, Email email)
        {
            // It's tempting to create the queue here.  Don't; objects which have
            // not yet called GetNextEmail should have no queue, and emails to them
            // should be silently dropped.
            EmailQueue val;

            if (m_MailQueues.TryGetValue(to, out val))
            {
                if (val.m_Queue.Count >= m_MaxQueueSize)
                {
                    // fail silently
                    return;
                }

                val.m_LastCall = DateTime.Now;
                val.m_Queue.Add(email);
            }
        }
Exemplo n.º 14
0
        public UUID GetAsset(UUID itemID)
        {
            UUID result;

            if (m_items.TryGetValue(itemID, out result))
            {
                return(result);
            }
            return(UUID.Zero);
        }
Exemplo n.º 15
0
        public string LoadRegionEnvironmentSettings(UUID regionUUID)
        {
            string val;

            if (EnvironmentSettings.TryGetValue(regionUUID, out val))
            {
                return(val);
            }
            return(string.Empty);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Get a module commander
        /// </summary>
        /// <param name="name"></param>
        /// <returns>The module commander, null if no module commander with that name was found</returns>
        public ICommander GetCommander(string name)
        {
            ICommander val;

            if (m_moduleCommanders.TryGetValue(name, out val))
            {
                return(val);
            }

            return(null);
        }
Exemplo n.º 17
0
        public void RemoveCompletedRequest(UUID id)
        {
            HttpRequestClass tmpReq;

            if (m_pendingRequests.TryGetValue(id, out tmpReq))
            {
                tmpReq.Stop();
                tmpReq = null;
                m_pendingRequests.Remove(id);
            }
        }
Exemplo n.º 18
0
        public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request)
        {
            m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceSigninHTTPHandler called");
//            string requestbody = (string)request["body"];
//            string uri = (string)request["uri"];
//            string contenttype = (string)request["content-type"];

            Hashtable requestBody = ParseRequestBody((string)request["body"]);

            //string pwd = (string) requestBody["pwd"];
            string userid = (string)requestBody["userid"];

            string avatarName = string.Empty;
            int    pos        = -1;

            if (m_UUIDName.TryGetValue(userid, out avatarName))
            {
                foreach (string s in m_UUIDName.Keys)
                {
                    pos++;
                    if (s == userid)
                    {
                        break;
                    }
                }
            }

            //m_log.DebugFormat("[FreeSwitchVoice]: AUTH, URI: {0}, Content-Type:{1}, Body{2}", uri, contenttype,
            //                  requestbody);
            Hashtable response = new Hashtable();

            response["str_response_string"] = string.Format(@"<response xsi:schemaLocation=""/xsd/signin.xsd"">
                    <level0>
                        <status>OK</status>
                        <body>
                        <code>200</code>
                        <cookie_name>lib_session</cookie_name>
                        <cookie>{0}:{1}:9303959503950::</cookie>
                        <auth_token>{0}:{1}:9303959503950::</auth_token>
                        <primary>1</primary>
                        <account_id>{1}</account_id>
                        <displayname>{2}</displayname>
                        <msg>auth successful</msg>
                        </body>
                    </level0>
                </response>", userid, pos, avatarName);

            response["int_response_code"] = 200;

//            m_log.DebugFormat("[FreeSwitchVoice]: Sending FreeSwitchSLVoiceSigninHTTPHandler response");

            return(response);
        }
Exemplo n.º 19
0
        public bool TryGet <T>(out T iface)
        {
            object o;

            if (m_moduleInterfaces.TryGetValue(typeof(T), out o))
            {
                iface = (T)o;
                return(true);
            }
            iface = default(T);
            return(false);
        }
Exemplo n.º 20
0
        public string LookupModInvocation(string fname)
        {
            ScriptInvocationData sid;

            if (m_scriptInvocation.TryGetValue(fname, out sid))
            {
                if (sid.ReturnType == typeof(string))
                {
                    return("modInvokeS");
                }
                else if (sid.ReturnType == typeof(int))
                {
                    return("modInvokeI");
                }
                else if (sid.ReturnType == typeof(float))
                {
                    return("modInvokeF");
                }
                else if (sid.ReturnType == typeof(UUID))
                {
                    return("modInvokeK");
                }
                else if (sid.ReturnType == typeof(OpenMetaverse.Vector3))
                {
                    return("modInvokeV");
                }
                else if (sid.ReturnType == typeof(OpenMetaverse.Quaternion))
                {
                    return("modInvokeR");
                }
                else if (sid.ReturnType == typeof(object[]))
                {
                    return("modInvokeL");
                }

                m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}", fname, sid.ReturnType.Name);
            }

            return(null);
        }
Exemplo n.º 21
0
        public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, string theirversion, out string version, out string reason)
        {
            reason  = "Communications failure";
            version = ServiceVersion;
            if (destination == null)
            {
                return(false);
            }
            Scene scene;

            if (m_scenes.TryGetValue(destination.RegionID, out scene))
            {
//                    m_log.DebugFormat(
//                        "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
//                        s.RegionInfo.RegionName, destination.RegionHandle);

                uint size = scene.RegionInfo.RegionSizeX;

                float    theirVersionNumber = 0f;
                string[] versionComponents  = theirversion.Split(new char[] { '/' });
                if (versionComponents.Length >= 2)
                {
                    float.TryParse(versionComponents[1], out theirVersionNumber);
                }

                // Var regions here, and the requesting simulator is in an older version.
                // We will forbide this, because it crashes the viewers
                if (theirVersionNumber < 0.3f && size > 256)
                {
                    reason = "Destination is a variable-sized region, and source is an old simulator. Consider upgrading.";
                    m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Request to access this variable-sized region from {0} simulator was denied", theirVersionNumber);
                    return(false);
                }

                return(scene.QueryAccess(agentID, agentHomeURI, position, out reason));
            }

            //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
            return(false);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Operation to check for a registered constant
        /// </summary>
        public object LookupModConstant(string cname)
        {
            // m_log.DebugFormat("[MODULE COMMANDS] lookup constant <{0}>",cname);

            object value = null;

            if (m_constants.TryGetValue(cname, out value))
            {
                return(value);
            }

            return(null);
        }
Exemplo n.º 23
0
        public static void Remove(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
            {
                return;
            }

            if (m_timers.TryGetValue(motion.Scene, out timer))
            {
                timer.m_motions.Remove(motion);
            }
        }
Exemplo n.º 24
0
//        private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
//        {
//        }

//        private void OnGridInstantMessage(GridInstantMessage msg)
//        {
//            // Trigger the above event handler
//            OnInstantMessage(null, msg);
//        }

        private void HandleUUIDGroupNameRequest(UUID id, IClientAPI remote_client)
        {
            string groupnamereply = "Unknown";
            UUID   groupUUID      = UUID.Zero;

            GroupMembershipData grp;

            if (m_GroupMap.TryGetValue(id, out grp))
            {
                groupnamereply = grp.GroupName;
                groupUUID      = grp.GroupID;
            }
            remote_client.SendGroupNameReply(groupUUID, groupnamereply);
        }
Exemplo n.º 25
0
        public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
        {
            ThreadedClasses.RwLockedDictionary <AssetType, InventoryFolderBase> ff = null;
            if (m_FolderTypes.TryGetValue(userID, out ff))
            {
                InventoryFolderBase f = null;

                if (ff.TryGetValue(type, out f))
                {
                    return(f);
                }
            }

            return(null);
        }
Exemplo n.º 26
0
        private string ChannelUri(Scene scene, LandData land)
        {
            string channelUri = null;

            string landUUID;
            string landName;

            // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same
            // as the directory ID. Otherwise, it reflects the parcel's ID.

            string parcelAddress;

            if (m_ParcelAddress.TryGetValue(land.GlobalID.ToString(), out parcelAddress))
            {
                m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}",
                                  land.GlobalID, parcelAddress);
                return(parcelAddress);
            }

            if (land.LocalID != 1 && (land.Flags & (uint)ParcelFlags.UseEstateVoiceChan) == 0)
            {
                landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name);
                landUUID = land.GlobalID.ToString();
                m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
                                  landName, land.LocalID, landUUID);
            }
            else
            {
                landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName);
                landUUID = scene.RegionInfo.RegionID.ToString();
                m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
                                  landName, land.LocalID, landUUID);
            }

            // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables
            // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator.
            channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(Encoding.ASCII.GetBytes(landUUID)), m_freeSwitchRealm);

            try
            {
                m_ParcelAddress.Add(land.GlobalID.ToString(), channelUri);
            }
            catch
            {
            }

            return(channelUri);
        }
Exemplo n.º 27
0
        private static void UpdateThread(int threadID)
        {
            ThreadWatchdogInfo threadInfo;

            // Although TryGetValue is not a thread safe operation, we use a try/catch here instead
            // of a lock for speed. Adding/removing threads is a very rare operation compared to
            // UpdateThread(), and a single UpdateThread() failure here and there won't break
            // anything
            if (m_threads.TryGetValue(threadID, out threadInfo))
            {
                threadInfo.LastTick   = Environment.TickCount;
                threadInfo.IsTimedOut = false;
            }
            else
            {
                m_log.WarnFormat("[WATCHDOG]: Asked to update thread {0} which is not being monitored", threadID);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Get listeners matching the input parameters.
        /// </summary>
        /// <remarks>
        /// Theres probably a more clever and efficient way to do this, maybe
        /// with regex.
        /// PM2008: Ha, one could even be smart and define a specialized
        /// Enumerator.
        /// </remarks>
        /// <param name="itemID"></param>
        /// <param name="channel"></param>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public List <ListenerInfo> GetListeners(UUID itemID, int channel,
                                                string name, UUID id, string msg)
        {
            List <ListenerInfo> collection = new List <ListenerInfo>();

            ThreadedClasses.RwLockedList <ListenerInfo> listeners;
            if (!m_listeners.TryGetValue(channel, out listeners))
            {
                return(collection);
            }

            listeners.ForEach(delegate(ListenerInfo li)
            {
                if (!li.IsActive())
                {
                    return;
                }
                if (!itemID.Equals(UUID.Zero) &&
                    !li.GetItemID().Equals(itemID))
                {
                    return;
                }
                if (li.GetName().Length > 0 && (
                        ((li.RegexBitfield & OS_LISTEN_REGEX_NAME) != OS_LISTEN_REGEX_NAME && !li.GetName().Equals(name)) ||
                        ((li.RegexBitfield & OS_LISTEN_REGEX_NAME) == OS_LISTEN_REGEX_NAME && !Regex.IsMatch(name, li.GetName()))
                        ))
                {
                    return;
                }
                if (!li.GetID().Equals(UUID.Zero) && !li.GetID().Equals(id))
                {
                    return;
                }
                if (li.GetMessage().Length > 0 && (
                        ((li.RegexBitfield & OS_LISTEN_REGEX_MESSAGE) != OS_LISTEN_REGEX_MESSAGE && !li.GetMessage().Equals(msg)) ||
                        ((li.RegexBitfield & OS_LISTEN_REGEX_MESSAGE) == OS_LISTEN_REGEX_MESSAGE && !Regex.IsMatch(msg, li.GetMessage()))
                        ))
                {
                    return;
                }
                collection.Add(li);
            });
            return(collection);
        }
Exemplo n.º 29
0
        public void HttpContentType(UUID request, string type)
        {
            UrlData urlData;

            if (m_RequestMap.TryGetValue(request, out urlData))
            {
                urlData.requests[request].responseType = type;
            }
            else
            {
                m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
            }
        }
Exemplo n.º 30
0
        public IServiceRequest GetNextCompletedSRDRequest()
        {
            try
            {
                m_pendingSRDResponses.ForEach(delegate(UUID luid)
                {
                    SendRemoteDataRequest tmpReq;

                    if (m_pendingSRDResponses.TryGetValue(luid, out tmpReq))
                    {
                        if (tmpReq.Finished)
                        {
                            throw new ThreadedClasses.ReturnValueException <SendRemoteDataRequest>(tmpReq);
                        }
                    }
                });
            }
            catch (ThreadedClasses.ReturnValueException <SendRemoteDataRequest> e)
            {
                return(e.Value);
            }
            return(null);
        }