Exemplo n.º 1
0
        private void RetrieveInstantMessages(IClientAPI client)
        {
            if (m_RestURL != "")
            {
                m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);

                List <GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject <UUID, List <GridInstantMessage> >(
                    "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);

                foreach (GridInstantMessage im in msglist)
                {
                    // client.SendInstantMessage(im);

                    // Send through scene event manager so all modules get a chance
                    // to look at this message before it gets delivered.
                    //
                    // Needed for proper state management for stored group
                    // invitations
                    //
                    Scene s = FindScene(client.AgentId);
                    if (s != null)
                    {
                        s.EventManager.TriggerIncomingInstantMessage(im);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void UndeliveredMessage(GridInstantMessage im)
        {
            if ((im.offline != 0) &&
                (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
            {
                bool success = SynchronousRestObjectPoster.BeginPostObject <GridInstantMessage, bool>(
                    "POST", m_RestURL + "/SaveMessage/", im);

                if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
                {
                    IClientAPI client = FindClient(new UUID(im.fromAgentID));
                    if (client == null)
                    {
                        return;
                    }

                    client.SendInstantMessage(new GridInstantMessage(
                                                  null, new UUID(im.toAgentID),
                                                  "System", new UUID(im.fromAgentID),
                                                  (byte)InstantMessageDialog.MessageFromAgent,
                                                  "User is not logged in. " +
                                                  (success ? "Message saved." : "Message not saved"),
                                                  false, new Vector3()));
                }
            }
        }
Exemplo n.º 3
0
        public void OnRemoveMuteListEntry(IClientAPI client, UUID MuteID, string Name, UUID AgentID)
        {
            //m_log.DebugFormat("[NSL MUTE LIST] OnRemoveMuteListEntry {0}, {1}, {2}", MuteID.ToString(), Name, AgentID.ToString());

            GridMuteList ml      = new GridMuteList(AgentID, MuteID, Name, 0, 0);
            bool         success = SynchronousRestObjectPoster.BeginPostObject <GridMuteList, bool>("POST", m_RestURL + "/DeleteList/", ml);
        }
Exemplo n.º 4
0
        private void UndeliveredMessage(GridInstantMessage im)
        {
            //this does not appear to mean what the coders here thought.
            //it appears to be the type of message this is, online meaning
            //it is coming from an online agent and headed to an online, or
            //not known to not be online agent

            /*if (im.offline != 0)
             * {*/

            if (
                //not an im from the group and not start typing, stoptyping, or request tp
                ((!im.fromGroup) &&
                 im.dialog != (byte)InstantMessageDialog.StartTyping &&
                 im.dialog != (byte)InstantMessageDialog.StopTyping &&
                 im.dialog != (byte)InstantMessageDialog.RequestTeleport)

                ||

                //im from the group and invitation or notice may go through
                (im.fromGroup &&
                 (im.dialog == (byte)InstantMessageDialog.GroupInvitation ||
                  im.dialog == (byte)InstantMessageDialog.GroupNotice))
                )
            {
#if TESTING_OFFLINES
                bool success = true;
                DebugStoreIM(im);
#else
                bool success = SynchronousRestObjectPoster.BeginPostObject <GridInstantMessage, bool>(
                    "POST", m_RestURL + "/SaveMessage/", im);
#endif

                if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
                {
                    IClientAPI client = FindClient(new UUID(im.fromAgentID));
                    if (client == null)
                    {
                        return;
                    }

                    client.SendInstantMessage(new GridInstantMessage(
                                                  null, new UUID(im.toAgentID),
                                                  "System", new UUID(im.fromAgentID),
                                                  (byte)InstantMessageDialog.MessageFromAgent,
                                                  "User is not logged in. " +
                                                  (success ? "Message saved." : "Message not saved"),
                                                  false, new Vector3()));
                }
            }
            //}
        }
Exemplo n.º 5
0
        public InventoryFolderBase QueryFolder(InventoryFolderBase item)
        {
            try
            {
                return(SynchronousRestObjectPoster.BeginPostObject <InventoryFolderBase, InventoryFolderBase>("POST", _inventoryServerUrl + "/QueryFolder/", item));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[OGS1 Inventory Service]: Query inventory item operation failed, {0} {1}", e.Source, e.Message);
            }

            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
        /// </summary>
        public bool DeleteItem(InventoryItemBase item)
        {
            try
            {
                return(SynchronousRestObjectPoster.BeginPostObject <InventoryItemBase, bool>("POST", _inventoryServerUrl + "/DeleteItem/", item));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[OGS1 Inventory Service]: Delete inventory item operation failed, {0} {1}", e.Source, e.Message);
            }

            return(false);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
        /// </summary>
        public bool PurgeFolder(InventoryFolderBase folder)
        {
            try
            {
                return(SynchronousRestObjectPoster.BeginPostObject <InventoryFolderBase, bool>("POST", _inventoryServerUrl + "/PurgeFolder/", folder));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[OGS1 Inventory Service]: Move inventory folder operation failed, {0} {1}", e.Source, e.Message);
            }

            return(false);
        }
        /// <summary>
        /// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
        /// </summary>
        public bool AddItem(InventoryItemBase item)
        {
            try
            {
                return(SynchronousRestObjectPoster.BeginPostObject <InventoryItemBase, bool>(
                           "POST", _inventoryServerUrl + "/NewItem/", item));
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Add new inventory item operation failed, {0} {1}",
                                  e.Source, e.Message);
            }

            return(false);
        }
        public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri)
        {
            if (!m_Channels.ContainsKey(itemID))
            {
                XmlRpcInfo info = new XmlRpcInfo();
                info.channel = channel;
                info.uri     = uri;

                bool success = SynchronousRestObjectPoster.BeginPostObject <XmlRpcInfo, bool>(
                    "POST", m_ServerURI + "/RegisterChannel/", info);

                if (!success)
                {
                    m_log.Error("[XMLRPC GRID ROUTER] Error contacting server");
                }

                m_Channels[itemID] = channel;
            }
        }
        public void ScriptRemoved(UUID itemID)
        {
            if (!m_Enabled)
            {
                return;
            }

            if (m_Channels.ContainsKey(itemID))
            {
                bool success = SynchronousRestObjectPoster.BeginPostObject <UUID, bool>(
                    "POST", m_ServerURI + "/RemoveChannel/", m_Channels[itemID]);

                if (!success)
                {
                    m_log.Error("[XMLRPC GRID ROUTER] Error contacting server");
                }

                m_Channels.Remove(itemID);
            }
        }
Exemplo n.º 11
0
        private void OnMuteListRequest(IClientAPI client, uint crc)
        {
            //m_log.DebugFormat("[NSL MUTE LIST] Got MUTE LIST request for crc {0}", crc);

            int    cnt = 0;
            string str = "";
            string url = m_RestURL + "/RequestList/";

            List <GridMuteList> mllist = SynchronousRestObjectPoster.BeginPostObject <UUID, List <GridMuteList> >("POST", url, client.AgentId);

            while (mllist == null && cnt < 10)                          // retry
            {
                mllist = SynchronousRestObjectPoster.BeginPostObject <UUID, List <GridMuteList> >("POST", url, client.AgentId);
                cnt++;
            }

            if (mllist != null)
            {
                foreach (GridMuteList ml in mllist)
                {
                    str += ml.muteType.ToString() + " " + ml.muteID.ToString() + " " + ml.muteName + "|" + ml.muteFlags.ToString() + "\n";
                }
            }
            else
            {
                m_log.ErrorFormat("[NSL MUTE LIST] Not response from mute.php");
                return;
            }

            string filename = "mutes" + client.AgentId.ToString();
            IXfer  xfer     = client.Scene.RequestModuleInterface <IXfer>();

            if (xfer != null)
            {
                byte[] byteArray = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(str);
                xfer.AddNewFile(filename, byteArray);
                client.SendMuteListUpdate(filename);
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Returns a list of all the active gestures in a user's inventory.
 /// </summary>
 /// <param name="userId">
 /// The <see cref="UUID"/> of the user
 /// </param>
 /// <returns>
 /// A flat list of the gesture items.
 /// </returns>
 public List <InventoryItemBase> GetActiveGestures(UUID userId)
 {
     return(SynchronousRestObjectPoster.BeginPostObject <Guid, List <InventoryItemBase> >(
                "POST", m_inventoryServerUrl + "ActiveGestures/", userId.Guid));
 }
Exemplo n.º 13
0
 /// <summary>
 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public List <InventoryFolderBase> GetInventorySkeleton(UUID userId)
 {
     return(SynchronousRestObjectPoster.BeginPostObject <Guid, List <InventoryFolderBase> >(
                "POST", m_inventoryServerUrl + "RootFolders/", userId.Guid));
 }
Exemplo n.º 14
0
 /// <summary>
 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public bool CreateNewUserInventory(UUID userId)
 {
     return(SynchronousRestObjectPoster.BeginPostObject <Guid, bool>(
                "POST", m_inventoryServerUrl + "CreateInventory/", userId.Guid));
 }
Exemplo n.º 15
0
        public void RunCommand(string module, string[] cmd)
        {
            List <string> args    = new List <string>(cmd);
            string        command = cmd[0];

            args.RemoveAt(0);

            string[] cmdparams = args.ToArray();

            switch (command)
            {
            case "create":
                do_create(cmdparams);
                break;

            case "reset":
                Reset(cmdparams);
                break;


            case "test-inventory":
                //  RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
                // requester.ReturnResponseVal = TestResponse;
                // requester.BeginPostObject<UUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
                SynchronousRestObjectPoster.BeginPostObject <UUID, List <InventoryFolderBase> >(
                    "POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
                break;

            case "logoff-user":
                if (cmdparams.Length >= 3)
                {
                    string firstname = cmdparams[0];
                    string lastname  = cmdparams[1];
                    string message   = String.Empty;

                    for (int i = 2; i < cmdparams.Length; i++)
                    {
                        message += " " + cmdparams[i];
                    }

                    UserProfileData theUser = null;
                    try
                    {
                        theUser = m_loginService.GetTheUser(firstname, lastname);
                    }
                    catch (Exception)
                    {
                        m_log.Error("[LOGOFF]: Error getting user data from the database.");
                    }

                    if (theUser != null)
                    {
                        if (theUser.CurrentAgent != null)
                        {
                            if (theUser.CurrentAgent.AgentOnline)
                            {
                                m_log.Info("[LOGOFF]: Logging off requested user!");
                                m_loginService.LogOffUser(theUser, message);

                                theUser.CurrentAgent.AgentOnline = false;
                                theUser.CurrentAgent.LogoutTime  = Util.UnixTimeSinceEpoch();

                                m_loginService.CommitAgent(ref theUser);
                            }
                            else
                            {
                                m_log.Info(
                                    "[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway.");
                                m_loginService.LogOffUser(theUser, message);

                                theUser.CurrentAgent.AgentOnline = false;

                                m_loginService.CommitAgent(ref theUser);
                            }
                        }
                        else
                        {
                            m_log.Error(
                                "[LOGOFF]: Unable to logoff-user.  User doesn't have an agent record so I can't find the simulator to notify");
                        }
                    }
                    else
                    {
                        m_log.Info("[LOGOFF]: User doesn't exist in the database");
                    }
                }
                else
                {
                    m_log.Error(
                        "[LOGOFF]: Invalid amount of parameters.  logoff-user takes at least three.  Firstname, Lastname, and message");
                }

                break;
            }
        }
Exemplo n.º 16
0
        private void RetrieveInstantMessages(IClientAPI client)
        {
            m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);
            List <GridInstantMessage> msglist = null;

            try
            {
#if TESTING_OFFLINES
                msglist = DebugFetchIMs();
#else
                msglist = SynchronousRestObjectPoster.BeginPostObject <UUID, List <GridInstantMessage> >(
                    "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
#endif
                if (msglist == null)
                {
                    return;
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[OFFLINE MESSAGING]: Exception fetching offline IMs for {0}: {1}",
                                  client.AgentId.ToString(), e.ToString());
                return;
            }

            //I believe the reason some people are not getting offlines or all
            //offlines is because they are not yet a root agent when this module
            //is called into by the client. What we should do in this case
            //is hook into onmakerootagent and send the messages then.
            //for now a workaround is to loop until we get a scene
            Thread.Sleep(2000);
            const int MAX_SCENE_RETRIES = 10;

            int   i = 0;
            Scene s = null;
            for (i = 0; i < MAX_SCENE_RETRIES; i++)
            {
                s = FindScene(client.AgentId);
                if (s != null)
                {
                    break;
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }

            if (s == null)
            {
                m_log.ErrorFormat("[OFFLINE MESSAGING]: Didnt find active scene for user in {0} s", MAX_SCENE_RETRIES);
                return;
            }

            foreach (GridInstantMessage im in msglist)
            {
                // Send through scene event manager so all modules get a chance
                // to look at this message before it gets delivered.
                //
                // Needed for proper state management for stored group
                // invitations
                //
                try
                {
                    s.EventManager.TriggerIncomingInstantMessage(im);
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[OFFLINE MESSAGING]: Exception sending offline IM for {0}: {1}",
                                      client.AgentId.ToString(), e);
                    m_log.ErrorFormat("[OFFLINE MESSAGING]: Problem offline IM was type {0} from {1} to group {2}:\n{3}",
                                      im.dialog.ToString(), im.fromAgentName, im.fromGroup.ToString(), im.message);
                }
            }
        }