Ejemplo n.º 1
0
        /// <summary>
        /// Gets the profile data.
        /// </summary>
        /// <returns>
        /// The profile data.
        /// </returns>
        bool GetProfileData(ref UserProfileProperties properties, bool foreign, string serverURI, out string message)
        {
            if (String.IsNullOrEmpty(serverURI))
            {
                message = "User profile service unknown at this time";
                return false;
            }

            object Prop = (object)properties;
            if (!rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString()))
            {
                // If it's a foreign user then try again using OpenProfile, in case that's what the grid is using
                bool secondChanceSuccess = false;
                if (foreign)
                {
                    try
                    {
                        OpenProfileClient client = new OpenProfileClient(serverURI);
                        if (client.RequestAvatarPropertiesUsingOpenProfile(ref properties))
                            secondChanceSuccess = true;
                    }
                    catch (Exception e)
                    {
                        m_log.Debug(
                            string.Format(
                                "[PROFILES]: Request using the OpenProfile API for user {0} to {1} failed", 
                                properties.UserId, serverURI),
                            e);

                        // Allow the return 'message' to say "JsonRpcRequest" and not "OpenProfile", because
                        // the most likely reason that OpenProfile failed is that the remote server
                        // doesn't support OpenProfile, and that's not very interesting.
                    }
                }

                if (!secondChanceSuccess)
                {
                    message = string.Format("JsonRpcRequest for user {0} to {1} failed", properties.UserId, serverURI);
                    m_log.DebugFormat("[PROFILES]: {0}", message);

                    return false;
                }
            }
                      
            properties = (UserProfileProperties)Prop;
            if(foreign)
            {
                cacheForeignImage(properties.UserId, properties.ImageId);
                cacheForeignImage(properties.UserId, properties.FirstLifeImageId);
            }

            message = "Success";
            return true;
        }
        /// <summary>
        /// Gets the profile data.
        /// </summary>
        /// <returns>
        /// The profile data.
        /// </returns>
        bool GetProfileData(ref UserProfileProperties properties, bool foreign, out string message)
        {
            // Can't handle NPC yet...
            ScenePresence p = FindPresence(properties.UserId);

            if (null != p)
            {
                if (p.PresenceType == PresenceType.Npc)
                {
                    message = "Id points to NPC";
                    return false;
                }
            }

            string serverURI = string.Empty;
            GetUserProfileServerURI(properties.UserId, out serverURI);

            // This is checking a friend on the home grid
            // Not HG friend
            if (String.IsNullOrEmpty(serverURI))
            {
                message = "No Presence - foreign friend";
                return false;
            }

            object Prop = (object)properties;
            if (!rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString()))
            {
                // If it's a foreign user then try again using OpenProfile, in case that's what the grid is using
                bool secondChanceSuccess = false;
                if (foreign)
                {
                    try
                    {
                        OpenProfileClient client = new OpenProfileClient(serverURI);
                        if (client.RequestAvatarPropertiesUsingOpenProfile(ref properties))
                            secondChanceSuccess = true;
                    }
                    catch (Exception e)
                    {
                        m_log.Debug(string.Format("Request using the OpenProfile API to {0} failed", serverURI), e);
                        // Allow the return 'message' to say "JsonRpcRequest" and not "OpenProfile", because
                        // the most likely reason that OpenProfile failed is that the remote server
                        // doesn't support OpenProfile, and that's not very interesting.
                    }
                }

                if (!secondChanceSuccess)
                {
                    message = string.Format("JsonRpcRequest to {0} failed", serverURI);
                    return false;
                }
                // else, continue below
            }
            
            properties = (UserProfileProperties)Prop;

            message = "Success";
            return true;
        }
        /// <summary>
        /// Gets the profile data.
        /// </summary>
        /// <returns>
        /// The profile data.
        /// </returns>
        private bool GetProfileData(ref UserProfileProperties properties, bool foreign, out string message)
        {
            // Can't handle NPC yet...
            ScenePresence p = FindPresence(properties.UserId);

            if (null != p)
            {
                if (p.PresenceType == PresenceType.Npc)
                {
                    message = "Id points to NPC";
                    return(false);
                }
            }

            string serverURI = string.Empty;

            GetUserProfileServerURI(properties.UserId, out serverURI);

            // This is checking a friend on the home grid
            // Not HG friend
            if (String.IsNullOrEmpty(serverURI))
            {
                message = "No Presence - foreign friend";
                return(false);
            }

            object Prop = (object)properties;

            if (!rpc.JsonRpcRequest(ref Prop, "avatar_properties_request", serverURI, UUID.Random().ToString()))
            {
                // If it's a foreign user then try again using OpenProfile, in case that's what the grid is using
                bool secondChanceSuccess = false;
                if (foreign)
                {
                    try
                    {
                        OpenProfileClient client = new OpenProfileClient(serverURI);
                        if (client.RequestAvatarPropertiesUsingOpenProfile(ref properties))
                        {
                            secondChanceSuccess = true;
                        }
                    }
                    catch (Exception e)
                    {
                        m_log.Debug(string.Format("Request using the OpenProfile API to {0} failed", serverURI), e);
                        // Allow the return 'message' to say "JsonRpcRequest" and not "OpenProfile", because
                        // the most likely reason that OpenProfile failed is that the remote server
                        // doesn't support OpenProfile, and that's not very interesting.
                    }
                }

                if (!secondChanceSuccess)
                {
                    message = string.Format("JsonRpcRequest to {0} failed", serverURI);
                    return(false);
                }
                // else, continue below
            }

            properties = (UserProfileProperties)Prop;

            message = "Success";
            return(true);
        }