Example #1
0
        public LSL_Key llRequestDisplayName(LSL_Key uuid)
        {
            UUID userID = UUID.Zero;

            if (!UUID.TryParse(uuid, out userID))
            {
                // => complain loudly, as specified by the LSL docs
                Error("llRequestDisplayName", "Failed to parse uuid for avatar.");

                return(UUID.Zero.ToString());
            }

            DataserverPlugin dataserverPlugin = (DataserverPlugin)m_ScriptEngine.GetScriptPlugin("Dataserver");
            UUID             tid = dataserverPlugin.RegisterRequest(m_host.UUID, m_itemID, uuid.ToString());

            Util.FireAndForget(delegate {
                string name = "";
                IProfileConnector connector =
                    Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>();
                if (connector != null)
                {
                    IUserProfileInfo info = connector.GetUserProfile(userID);
                    if (info != null)
                    {
                        name = info.DisplayName;
                    }
                }
                dataserverPlugin.AddReply(uuid.ToString(),
                                          name, 100);
            });

            PScriptSleep(m_sleepMsOnRequestUserName);
            return(tid.ToString());
        }
Example #2
0
        public LSL_Key llRequestUsername(LSL_Key uuid)
        {
            UUID userID = UUID.Zero;

            if (!UUID.TryParse(uuid, out userID))
            {
                // => complain loudly, as specified by the LSL docs
                Error("llRequestUsername", "Failed to parse uuid for avatar.");

                return(UUID.Zero.ToString());
            }

            DataserverPlugin dataserverPlugin = (DataserverPlugin)m_ScriptEngine.GetScriptPlugin("Dataserver");
            UUID             tid = dataserverPlugin.RegisterRequest(m_host.UUID, m_itemID, uuid.ToString());

            Util.FireAndForget(delegate {
                string name          = "";
                UserAccount userAcct =
                    World.UserAccountService.GetUserAccount(World.RegionInfo.AllScopeIDs, userID);
                name = userAcct.Name;
                dataserverPlugin.AddReply(uuid.ToString(), name, 100);
            });

            PScriptSleep(m_sleepMsOnRequestUserName);
            return(tid.ToString());
        }
Example #3
0
        public LSL_Key llRequestInventoryData(string name)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return("");
            }


            TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();

            foreach (TaskInventoryItem item in itemDictionary.Values)
            {
                if (item.Type == 3 && item.Name == name)
                {
                    UUID             rq = UUID.Random();
                    DataserverPlugin dataserverPlugin = (DataserverPlugin)m_ScriptEngine.GetScriptPlugin("Dataserver");

                    UUID tid = dataserverPlugin.RegisterRequest(m_host.UUID,
                                                                m_itemID, rq.ToString());

                    Vector3 region = new Vector3(
                        World.RegionInfo.RegionLocX,
                        World.RegionInfo.RegionLocY,
                        0);

                    World.AssetService.Get(item.AssetID.ToString(), this,
                                           delegate(string i, object sender, AssetBase a) {
                        if (a != null)
                        {
                            AssetLandmark lm = new AssetLandmark(a);

                            float rx = (uint)(lm.RegionHandle >> 32);
                            float ry = (uint)lm.RegionHandle;
                            region   = lm.Position + new Vector3(rx, ry, 0) - region;

                            string reply = region.ToString();
                            dataserverPlugin.AddReply(rq.ToString(),
                                                      reply, 1000);
                        }
                    });

                    PScriptSleep(m_sleepMsOnRequestInventoryData);
                    return(tid.ToString());
                }
            }
            PScriptSleep(m_sleepMsOnRequestInventoryData);
            return(string.Empty);
        }
Example #4
0
        public LSL_Key llRequestSimulatorData(string simulator, int data)
        {
            UUID tid = UUID.Zero;

            try {
                if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
                {
                    return("");
                }

                string reply = string.Empty;

                GridRegion info = World.RegionInfo.RegionName == simulator
                                      ? new GridRegion(World.RegionInfo)
                                      : World.GridService.GetRegionByName(World.RegionInfo.AllScopeIDs, simulator);


                switch (data)
                {
                case 5:     // DATA_SIM_POS
                    if (info == null)
                    {
                        break;
                    }

                    reply = new LSL_Vector(
                        info.RegionLocX,
                        info.RegionLocY,
                        0).ToString();
                    break;

                case 6:     // DATA_SIM_STATUS
                    if (info != null)
                    {
                        reply = (info.Flags & (int)RegionFlags.RegionOnline) != 0 ? "up" : "down";
                    }
                    //if() starting
                    //if() stopping
                    //if() crashed
                    else
                    {
                        reply = "unknown";
                    }
                    break;

                case 7:     // DATA_SIM_RATING
                    if (info == null)
                    {
                        break;
                    }

                    uint access = Util.ConvertAccessLevelToMaturity(info.Access);
                    if (access == 0)
                    {
                        reply = "PG";
                    }
                    else if (access == 1)
                    {
                        reply = "MATURE";
                    }
                    else if (access == 2)
                    {
                        reply = "ADULT";
                    }
                    else
                    {
                        reply = "UNKNOWN";
                    }
                    break;

                case 128:
                    try {
                        if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "llRequestSimulatorData", m_host,
                                                               "LSL", m_itemID))
                        {
                            return("");
                        }

                        reply = "WhiteCore";
                    } catch {
                        reply = "";
                    }
                    break;
                }
                if (reply != "")
                {
                    UUID rq = UUID.Random();

                    DataserverPlugin dataserverPlugin = (DataserverPlugin)m_ScriptEngine.GetScriptPlugin("Dataserver");

                    tid = dataserverPlugin.RegisterRequest(m_host.UUID, m_itemID, rq.ToString());

                    dataserverPlugin.AddReply(rq.ToString(), reply, 1000);
                }
            } catch {
            }

            PScriptSleep(m_sleepMsOnRequestSimulatorData);
            return(tid.ToString());
        }
Example #5
0
        public LSL_Key llRequestAgentData(string id, int data)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return("");
            }

            UUID        uuid  = (UUID)id;
            UserInfo    pinfo = null;
            UserAccount userAcct;

            UserInfoCacheEntry ce;

            if (!m_userInfoCache.TryGetValue(uuid, out ce))
            {
                userAcct = World.UserAccountService.GetUserAccount(World.RegionInfo.AllScopeIDs, uuid);
                if (!userAcct.Valid)
                {
                    m_userInfoCache[uuid] = null; // Cache negative
                    return(UUID.Zero.ToString());
                }

                ce = new UserInfoCacheEntry {
                    time = Util.EnvironmentTickCount(), account = userAcct
                };
                pinfo    = World.RequestModuleInterface <IAgentInfoService>().GetUserInfo(uuid.ToString());
                ce.pinfo = pinfo;
                m_userInfoCache[uuid] = ce;
            }
            else
            {
                if (ce == null)
                {
                    return(UUID.Zero.ToString());
                }
                userAcct = ce.account;
                pinfo    = ce.pinfo;
            }

            if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000)
            {
                ce.time  = Util.EnvironmentTickCount();
                ce.pinfo = World.RequestModuleInterface <IAgentInfoService>().GetUserInfo(uuid.ToString());
                pinfo    = ce.pinfo;
            }

            string reply = string.Empty;

            switch (data)
            {
            case 1:     // DATA_ONLINE (0|1)
                if (pinfo != null && pinfo.IsOnline)
                {
                    reply = "1";
                }
                else
                {
                    reply = "0";
                }
                break;

            case 2:     // DATA_NAME (First Last)
                reply = userAcct.Name;
                break;

            case 3:     // DATA_BORN (YYYY-MM-DD)
                DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                born  = born.AddSeconds(userAcct.Created);
                reply = born.ToString("yyyy-MM-dd");
                break;

            case 4:     // DATA_RATING (0,0,0,0,0,0)
                reply = "0,0,0,0,0,0";
                break;

            case 8:     // DATA_PAYINFO (0|1|2|3)
                if ((userAcct.UserFlags & ScriptBaseClass.PAYMENT_INFO_ON_FILE) ==
                    ScriptBaseClass.PAYMENT_INFO_ON_FILE)
                {
                    reply = ScriptBaseClass.PAYMENT_INFO_ON_FILE.ToString();
                }
                if ((userAcct.UserFlags & ScriptBaseClass.PAYMENT_INFO_USED) == ScriptBaseClass.PAYMENT_INFO_USED)
                {
                    reply = ScriptBaseClass.PAYMENT_INFO_USED.ToString();
                }
                reply = "0";
                break;

            default:
                return(UUID.Zero.ToString());    // Raise no event
            }

            UUID rq = UUID.Random();

            DataserverPlugin dataserverPlugin = (DataserverPlugin)m_ScriptEngine.GetScriptPlugin("Dataserver");
            UUID             tid = dataserverPlugin.RegisterRequest(m_host.UUID,
                                                                    m_itemID, rq.ToString());

            dataserverPlugin.AddReply(rq.ToString(), reply, 100);

            PScriptSleep(m_sleepMsOnRequestAgentData);
            return(tid.ToString());
        }