public IUserProfileInfo GetUserProfile(UUID PrincipalID)
        {
            try
            {
                List<string> serverURIs =
                    m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(PrincipalID.ToString(),
                                                                                           "RemoteServerURI");
                foreach (string url in serverURIs)
                {
                    OSDMap map = new OSDMap();
                    map["Method"] = "getprofile";
                    map["PrincipalID"] = PrincipalID;
                    OSDMap response = WebUtils.PostToService(url + "osd", map, true, true);
                    if (response["_Result"].Type == OSDType.Map)
                    {
                        OSDMap responsemap = (OSDMap) response["_Result"];
                        if (responsemap.Count == 0)
                            continue;
                        IUserProfileInfo info = new IUserProfileInfo();
                        info.FromOSD(responsemap);
                        return info;
                    }
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e);
            }

            return null;
        }
Esempio n. 2
0
        /// <summary>
        /// Get a user's profile
        /// </summary>
        /// <param name="agentID"></param>
        /// <returns></returns>
		public IUserProfileInfo GetUserProfile(UUID agentID)
		{
			IUserProfileInfo UserProfile = new IUserProfileInfo();
            //Try from the user profile first before getting from the DB
            if (UserProfilesCache.TryGetValue(agentID, out UserProfile)) 
				return UserProfile;
            else 
            {
                UserProfile = new IUserProfileInfo();
                List<string> query = null;
                //Grab it from the almost generic interface
                query = GD.Query(new string[]{"ID", "`Key`"}, new object[]{agentID, "LLProfile"}, "userdata", "Value");
                
                if (query == null || query.Count == 0)
					return null;
                //Pull out the OSDmap
                OSDMap profile = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);
                UserProfile.FromOSD(profile);

				//Add to the cache
			    UserProfilesCache[agentID] = UserProfile;

				return UserProfile;
			}
		}
Esempio n. 3
0
        /// <summary>
        /// Update a user's profile (Note: this does not work if the user does not have a profile)
        /// </summary>
        /// <param name="Profile"></param>
        /// <returns></returns>
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            IUserProfileInfo previousProfile = GetUserProfile(Profile.PrincipalID);
            //Make sure the previous one exists
            if (previousProfile == null)
                return false;
            //Now fix values that the sim cannot change
            Profile.Partner = previousProfile.Partner;
            Profile.CustomType = previousProfile.CustomType;
            Profile.MembershipGroup = previousProfile.MembershipGroup;
            Profile.Created = previousProfile.Created;

            List<object> SetValues = new List<object>();
            List<string> SetRows = new List<string>();
            SetRows.Add("Value");
            SetValues.Add(OSDParser.SerializeLLSDXmlString(Profile.ToOSD()));

            List<object> KeyValue = new List<object>();
			List<string> KeyRow = new List<string>();
			KeyRow.Add("ID");
            KeyValue.Add(Profile.PrincipalID.ToString());
            KeyRow.Add("`Key`");
            KeyValue.Add("LLProfile");

            //Update cache
            UserProfilesCache[Profile.PrincipalID] = Profile;

            return GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
		}
        public IUserProfileInfo GetUserProfile(UUID PrincipalID)
        {
            NameValueCollection requestArgs = new NameValueCollection
            {
                { "RequestMethod", "GetUser" },
                { "UserID", PrincipalID.ToString() }
            };

            OSDMap result = PostUserData(PrincipalID, requestArgs);

            if (result == null)
                return null;

            if (result.ContainsKey("Profile"))
            {
                OSDMap profilemap = (OSDMap)OSDParser.DeserializeJson(result["Profile"].AsString());

                IUserProfileInfo profile = new IUserProfileInfo();
                profile.FromOSD(profilemap);

                return profile;
            }

            return null;
        }
        /// <summary>
        ///   Get a user's profile
        /// </summary>
        /// <param name = "agentID"></param>
        /// <returns></returns>
        public IUserProfileInfo GetUserProfile(UUID agentID)
        {
            IUserProfileInfo UserProfile = new IUserProfileInfo();
            //Try from the user profile first before getting from the DB
            if (UserProfilesCache.TryGetValue(agentID, out UserProfile))
                return UserProfile;
            else
            {
                Dictionary<string, object> where = new Dictionary<string, object>();
                where["ID"] = agentID;
                where["`Key`"] = "LLProfile";
                List<string> query = null;
                //Grab it from the almost generic interface
                query = GD.Query(new string[] { "Value" }, "userdata", new QueryFilter
                {
                    andFilters = where
                }, null, null, null);

                if (query == null || query.Count == 0)
                    return null;
                //Pull out the OSDmap
                OSDMap profile = (OSDMap) OSDParser.DeserializeLLSDXml(query[0]);

                UserProfile = new IUserProfileInfo();
                UserProfile.FromOSD(profile);

                //Add to the cache
                UserProfilesCache[agentID] = UserProfile;

                return UserProfile;
            }
        }
Esempio n. 6
0
 public bool UpdateUserProfile (IUserProfileInfo Profile)
 {
     bool success = m_localService.UpdateUserProfile (Profile);
     if (!success)
         success = m_remoteService.UpdateUserProfile (Profile);
     return success;
 }
Esempio n. 7
0
        public override IDataTransferable Duplicate()
        {
            IUserProfileInfo m = new IUserProfileInfo();

            m.FromOSD(ToOSD());
            return(m);
        }
        public IUserProfileInfo GetUserProfile(UUID agentID)
        {
            object remoteValue = DoRemote(agentID);
            if (remoteValue != null || m_doRemoteOnly)
                return (IUserProfileInfo)remoteValue;

            IUserProfileInfo UserProfile = new IUserProfileInfo();
            //Try from the user profile first before getting from the DB
            if (UserProfilesCache.TryGetValue(agentID, out UserProfile))
                return UserProfile;

            var connector = GetWhetherUserIsForeign(agentID);
            if (connector != null)
                return connector.GetUserProfile(agentID);

            QueryFilter filter = new QueryFilter();
            filter.andFilters["ID"] = agentID;
            filter.andFilters["`Key`"] = "LLProfile";
            List<string> query = null;
            //Grab it from the almost generic interface
            query = GD.Query(new[] { "Value" }, "userdata", filter, null, null, null);

            if (query == null || query.Count == 0)
                return null;
            //Pull out the OSDmap
            OSDMap profile = (OSDMap) OSDParser.DeserializeLLSDXml(query[0]);

            UserProfile = new IUserProfileInfo();
            UserProfile.FromOSD(profile);

            //Add to the cache
            UserProfilesCache[agentID] = UserProfile;

            return UserProfile;
        }
Esempio n. 9
0
		public IUserProfileInfo GetUserProfile(UUID agentID)
		{
			IUserProfileInfo UserProfile = new IUserProfileInfo();
            if (UserProfilesCache.TryGetValue(agentID, out UserProfile)) 
				return UserProfile;
            else 
            {
                UserProfile = new IUserProfileInfo();
                List<string> query = null;
                try
                {
                    query = GD.Query(new string[]{"ID", "`Key`"}, new object[]{agentID, "LLProfile"}, "userdata", "Value");
                }
                catch
                {
                }
                if (query == null || query.Count == 0)
					return null;

                OSDMap profile = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);

				UserProfile.PrincipalID = agentID;
                UserProfile.AllowPublish = profile["AllowPublish"].AsInteger() == 1;
                UserProfile.MaturePublish = profile["MaturePublish"].AsInteger() == 1;
                UserProfile.Partner = profile["Partner"].AsUUID();
                UserProfile.WebURL = profile["WebURL"].AsString();
                UserProfile.AboutText = profile["AboutText"].AsString();
                UserProfile.FirstLifeAboutText = profile["FirstLifeAboutText"].AsString();
                UserProfile.Image = profile["Image"].AsUUID();
                UserProfile.FirstLifeImage = profile["FirstLifeImage"].AsUUID();
                UserProfile.CustomType = profile["CustomType"].AsString();
                UserProfile.Visible = profile["Visible"].AsInteger() == 1;
                UserProfile.IMViaEmail = profile["IMViaEmail"].AsInteger() == 1;
                UserProfile.MembershipGroup = profile["MembershipGroup"].AsString();
                UserProfile.AArchiveName = profile["AArchiveName"].AsString();
                UserProfile.IsNewUser = profile["IsNewUser"].AsInteger() == 1;
                UserProfile.Created = profile["Created"].AsInteger();
                UserProfile.DisplayName = profile["DisplayName"].AsString();
                UserProfile.Interests.CanDoMask = profile["CanDoMask"].AsUInteger();
                UserProfile.Interests.WantToText = profile["WantToText"].AsString();
                UserProfile.Interests.CanDoMask = profile["CanDoMask"].AsUInteger();
                UserProfile.Interests.CanDoText = profile["CanDoText"].AsString();
                UserProfile.Interests.Languages = profile["Languages"].AsString();

                OSD onotes = OSDParser.DeserializeLLSDXml(profile["Notes"].AsString());
                OSDMap notes = onotes.Type == OSDType.Unknown ? new OSDMap() : (OSDMap)onotes;
                UserProfile.Notes = Util.OSDToDictionary(notes);
                OSD opicks = OSDParser.DeserializeLLSDXml(profile["Picks"].AsString());
                OSDMap picks = opicks.Type == OSDType.Unknown ? new OSDMap() : (OSDMap)opicks;
                UserProfile.Picks = Util.OSDToDictionary(picks);
                OSD oclassifieds = OSDParser.DeserializeLLSDXml(profile["Classifieds"].AsString());
                OSDMap classifieds = oclassifieds.Type == OSDType.Unknown ? new OSDMap() : (OSDMap)oclassifieds;
                UserProfile.Classifieds = Util.OSDToDictionary(classifieds);

			    UserProfilesCache[agentID] = UserProfile;

				return UserProfile;
			}
		}
        public IUserProfileInfo GetUserProfile(UUID PrincipalID)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["PRINCIPALID"] = PrincipalID.ToString();
            sendData["METHOD"] = "getprofile";

            string reqString = WebUtils.BuildXmlResponse(sendData);

            try
            {
                foreach (string m_ServerURI in m_ServerURIs)
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                        m_ServerURI + "/auroradata",
                        reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                        if (replyData != null)
                        {
                            if (!replyData.ContainsKey("result"))
                                return null;

                            IUserProfileInfo profile = null;
                            foreach (object f in replyData.Values)
                            {
                                if (f is Dictionary<string, object>)
                                {
                                    profile = new IUserProfileInfo();
                                    profile.FromKVP((Dictionary<string, object>)f);
                                }
                                else
                                    m_log.DebugFormat("[AuroraRemoteProfileConnector]: GetProfile {0} received invalid response type {1}",
                                        PrincipalID, f.GetType());
                            }
                            // Success
                            return profile;
                        }

                        else
                            m_log.DebugFormat("[AuroraRemoteProfileConnector]: GetProfile {0} received null response",
                                PrincipalID);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e.ToString());
            }

            return null;
        }
Esempio n. 11
0
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            NameValueCollection requestArgs = new NameValueCollection
            {
                { "RequestMethod", "AddUserData" },
                { "UserID", Profile.PrincipalID.ToString() },
                { "Profile", OSDParser.SerializeJsonString(Profile.ToOSD()) }
            };

            return PostData(Profile.PrincipalID, requestArgs);
        }
Esempio n. 12
0
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            NameValueCollection requestArgs = new NameValueCollection
            {
                { "RequestMethod", "AddUserData" },
                { "AgentID", Profile.PrincipalID.ToString() },
                { "Profile", OSDParser.SerializeJsonString(Util.DictionaryToOSD(Profile.ToKeyValuePairs())) }
            };

            OSDMap result = PostData(Profile.PrincipalID, requestArgs);

            if (result == null)
                return false;

            bool success = result["Success"].AsBoolean();
            return success;
        }
Esempio n. 13
0
        public IUserProfileInfo GetUserProfile(UUID PrincipalID)
        {
            NameValueCollection requestArgs = new NameValueCollection
            {
                { "RequestMethod", "GetUser" },
                { "AgentID", PrincipalID.ToString() }
            };

            OSDMap result = PostData(PrincipalID, requestArgs);

            if (result == null)
                return null;

            Dictionary<string, object> dresult = Util.OSDToDictionary(result);
            IUserProfileInfo profile = new IUserProfileInfo(dresult);

            return profile;
        }
Esempio n. 14
0
 public bool UpdateUserProfile(IUserProfileInfo Profile)
 {
     try
     {
         List<string> serverURIs = m_registry.RequestModuleInterface<IConfigurationService> ().FindValueOf (Profile.PrincipalID.ToString (), "RemoteServerURI");
         foreach (string url in serverURIs)
         {
             OSDMap map = new OSDMap ();
             map["Method"] = "updateprofile";
             map["Profile"] = Profile.ToOSD();
             WebUtils.PostToService (url + "osd", map);
         }
         return true;
     }
     catch (Exception e)
     {
         m_log.DebugFormat("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e.ToString());
     }
     return false;
 }
Esempio n. 15
0
        protected void HandleSetTitle(string[] cmdparams)
        {
            string firstName;
            string lastName;
            string title;

            firstName = cmdparams.Length < 5 ? MainConsole.Instance.Prompt("First name") : cmdparams[4];

            lastName = cmdparams.Length < 6 ? MainConsole.Instance.Prompt("Last name") : cmdparams[5];

            UserAccount account = GetUserAccount(null, firstName, lastName);

            if (account == null)
            {
                MainConsole.Instance.Info("No such user");
                return;
            }
            title             = cmdparams.Length < 7 ? MainConsole.Instance.Prompt("User Title") : Util.CombineParams(cmdparams, 6);
            account.UserTitle = title;
            Aurora.Framework.IProfileConnector profileConnector = Aurora.DataManager.DataManager.RequestPlugin <Aurora.Framework.IProfileConnector>();
            if (profileConnector != null)
            {
                Aurora.Framework.IUserProfileInfo profile = profileConnector.GetUserProfile(account.PrincipalID);
                profile.MembershipGroup = title;
                profile.CustomType      = title;
                profileConnector.UpdateUserProfile(profile);
            }
            bool success = StoreUserAccount(account);

            if (!success)
            {
                MainConsole.Instance.InfoFormat("Unable to set user profile title for account {0} {1}.", firstName, lastName);
            }
            else
            {
                MainConsole.Instance.InfoFormat("User profile title set for user {0} {1} to {2}", firstName, lastName, title);
            }
        }
        private void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UserAccount account, uint agentOnline)
        {
            Byte[] charterMember;
            if (Profile.MembershipGroup == "")
            {
                charterMember = new Byte[1];
                charterMember[0] = (Byte) ((account.UserFlags & 0xf00) >> 8);
            }
            else
                charterMember = Utils.StringToBytes(Profile.MembershipGroup);

            uint membershipGroupINT = 0;
            if (Profile.MembershipGroup != "")
                membershipGroupINT = 4;

            uint flags = Convert.ToUInt32(Profile.AllowPublish) + Convert.ToUInt32(Profile.MaturePublish) +
                         membershipGroupINT + agentOnline + (uint) account.UserFlags;
            remoteClient.SendAvatarInterestsReply(account.PrincipalID, Convert.ToUInt32(Profile.Interests.WantToMask),
                                                  Profile.Interests.WantToText,
                                                  Convert.ToUInt32(Profile.Interests.CanDoMask),
                                                  Profile.Interests.CanDoText, Profile.Interests.Languages);
            remoteClient.SendAvatarProperties(account.PrincipalID, Profile.AboutText,
                                              Util.ToDateTime(account.Created).ToString("M/d/yyyy",
                                                                                        CultureInfo.InvariantCulture),
                                              charterMember, Profile.FirstLifeAboutText, flags,
                                              Profile.FirstLifeImage, Profile.Image, Profile.WebURL,
                                              new UUID(Profile.Partner));
        }
        protected void HandleLoadAvatarProfile(string[] cmdparams)
        {
            if (cmdparams.Length != 6)
            {
                m_log.Info("[AvatarProfileArchiver] Not enough parameters!");
                return;
            }
            StreamReader reader = new StreamReader(cmdparams[5]);
            string document = reader.ReadToEnd();
            reader.Close();
            reader.Dispose();

            string[] lines = document.Split('\n');
            List<string> file = new List<string>(lines);
            Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(file[1]);

            Dictionary<string, object> results = replyData["result"] as Dictionary<string, object>;
            UserAccount UDA = new UserAccount();
            UDA.Name = cmdparams[3] + cmdparams[4];
            UDA.PrincipalID = UUID.Random();
            UDA.ScopeID = UUID.Zero;
            UDA.UserFlags = int.Parse(results["UserFlags"].ToString());
            UDA.UserLevel = 0; //For security... Don't want everyone loading full god mode.
            UDA.UserTitle = results["UserTitle"].ToString();
            UDA.Email = results["Email"].ToString();
            UDA.Created = int.Parse(results["Created"].ToString());
            UserAccountService.StoreUserAccount(UDA);

            replyData = WebUtils.ParseXmlResponse(file[2]);
            IUserProfileInfo UPI = new IUserProfileInfo();
            UPI.FromKVP(replyData["result"] as Dictionary<string, object>);
            //Update the principle ID to the new user.
            UPI.PrincipalID = UDA.PrincipalID;

            IProfileConnector profileData = Aurora.DataManager.DataManager.RequestPlugin<IProfileConnector>();
            if (profileData.GetUserProfile(UPI.PrincipalID) == null)
                profileData.CreateNewProfile(UPI.PrincipalID);

            profileData.UpdateUserProfile(UPI);

            m_log.Info("[AvatarProfileArchiver] Loaded Avatar Profile from " + cmdparams[5]);
        }
        public byte[] UpdateProfile(OSDMap request)
        {
            IUserProfileInfo UserProfile = new IUserProfileInfo();
            UserProfile.FromOSD((OSDMap)request["Profile"]);
            ProfileConnector.UpdateUserProfile(UserProfile);
            OSDMap result = new OSDMap ();
            result["result"] = "Successful";

            string xmlString = OSDParser.SerializeJsonString (result);
            //m_log.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetBytes(xmlString);
        }
        /// <summary>
        /// Update a user's profile (Note: this does not work if the user does not have a profile)
        /// </summary>
        /// <param name="Profile"></param>
        /// <returns></returns>
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            Dictionary<string, object> Values = new Dictionary<string, object>();
            Values.Add("AllowPublish", Profile.AllowPublish ? 1 : 0);
            Values.Add("MaturePublish", Profile.MaturePublish ? 1 : 0);
            //Can't change from the region
            //Values.Add("Partner");
            Values.Add("WebURL", Profile.WebURL);
            Values.Add("AboutText", Profile.AboutText);
            Values.Add("FirstLifeAboutText", Profile.FirstLifeAboutText);
            Values.Add("Image", Profile.Image);
            Values.Add("FirstLifeImage", Profile.FirstLifeImage);
            //Can't change from the region
            //Values.Add("CustomType");
            Values.Add("Visible", Profile.Visible ? 1 : 0);
            Values.Add("IMViaEmail", Profile.IMViaEmail ? 1 : 0);
            //Can't change from the region
            //Values.Add("MembershipGroup", Profile.MembershipGroup);
            //The next two really shouldn't be able to be changed, but the grid server sets them... so we can't comment them out, but they shouldn't be able to be changed remotely
            Values.Add("AArchiveName", Profile.AArchiveName);
            Values.Add("IsNewUser", Profile.IsNewUser ? 1 : 0);
            //Can't change from the region
            //Values.Add("Created", Profile.Created);
            Values.Add("DisplayName", Profile.DisplayName);
            Values.Add("WantToMask", Profile.Interests.WantToMask);
            Values.Add("WantToText", Profile.Interests.WantToText);
            Values.Add("CanDoMask", Profile.Interests.CanDoMask);
            Values.Add("CanDoText", Profile.Interests.CanDoText);
            Values.Add("Languages", Profile.Interests.Languages);
            Values.Add("Notes", OSDParser.SerializeLLSDXmlString(Util.DictionaryToOSD(Profile.Notes)));
            Values.Add("Picks", OSDParser.SerializeLLSDXmlString(Util.DictionaryToOSD(Profile.Picks)));
            Values.Add("Classifieds", OSDParser.SerializeLLSDXmlString(Util.DictionaryToOSD(Profile.Classifieds)));


            List<object> SetValues = new List<object>();
            List<string> SetRows = new List<string>();
            SetRows.Add("Value");

            //We do do this on purpose. It cuts out values that we should not be putting in the database
            OSDMap map = Util.DictionaryToOSD(Values);
            SetValues.Add(OSDParser.SerializeLLSDXmlString(map));

            List<object> KeyValue = new List<object>();
			List<string> KeyRow = new List<string>();
			KeyRow.Add("ID");
            KeyValue.Add(Profile.PrincipalID.ToString());
            KeyRow.Add("`Key`");
            KeyValue.Add("LLProfile");

            //Update cache
            UserProfilesCache[Profile.PrincipalID] = Profile;

            IUserProfileInfo UPI = GetUserProfile(Profile.PrincipalID);
            if (UPI != null)
            {
                IDirectoryServiceConnector dirServiceConnector = DataManager.DataManager.RequestPlugin<IDirectoryServiceConnector>();
                if (dirServiceConnector != null)
                {
                    dirServiceConnector.RemoveClassifieds(UPI.Classifieds);
                    dirServiceConnector.AddClassifieds(Profile.Classifieds);
                }
            }

            return GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
		}
        private void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UUID target, uint agentOnline)
        {
            UserAccount account = GetRegionUserIsIn(remoteClient.AgentId).UserAccountService.GetUserAccount(UUID.Zero, target);
            if (Profile == null || account == null)
                return;
            Byte[] charterMember;
            if (Profile.MembershipGroup == "")
            {
                charterMember = new Byte[1];
                charterMember[0] = (Byte)((account.UserFlags & 0xf00) >> 8);
            }
            else
            {
                charterMember = OpenMetaverse.Utils.StringToBytes(Profile.MembershipGroup);
            }
            uint membershipGroupINT = 0;
            if (Profile.MembershipGroup != "")
                membershipGroupINT = 4;

            uint flags = Convert.ToUInt32(Profile.AllowPublish) + Convert.ToUInt32(Profile.MaturePublish) + membershipGroupINT + (uint)agentOnline + (uint)account.UserFlags;
            remoteClient.SendAvatarInterestsReply(target, Convert.ToUInt32(Profile.Interests.WantToMask), Profile.Interests.WantToText, Convert.ToUInt32(Profile.Interests.CanDoMask), Profile.Interests.CanDoText, Profile.Interests.Languages);
            remoteClient.SendAvatarProperties(account.PrincipalID, Profile.AboutText,
                                              Util.ToDateTime(account.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture),
                                              charterMember, Profile.FirstLifeAboutText, flags,
                                              Profile.FirstLifeImage, Profile.Image, Profile.WebURL, new UUID(Profile.Partner));
        }
        /// <summary>
        /// Update a user's profile (Note: this does not work if the user does not have a profile)
        /// </summary>
        /// <param name="Profile"></param>
        /// <returns></returns>
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            IUserProfileInfo previousProfile = GetUserProfile(Profile.PrincipalID);
            //Make sure the previous one exists
            if (previousProfile == null)
                return false;
            //Now fix values that the sim cannot change
            Profile.Partner = previousProfile.Partner;
            Profile.CustomType = previousProfile.CustomType;
            Profile.MembershipGroup = previousProfile.MembershipGroup;
            Profile.Created = previousProfile.Created;

            List<object> SetValues = new List<object>();
            List<string> SetRows = new List<string>();
            SetRows.Add("Value");
            SetValues.Add(OSDParser.SerializeLLSDXmlString(Profile.ToOSD()));

            List<object> KeyValue = new List<object>();
			List<string> KeyRow = new List<string>();
			KeyRow.Add("ID");
            KeyValue.Add(Profile.PrincipalID.ToString());
            KeyRow.Add("`Key`");
            KeyValue.Add("LLProfile");

            //Update cache
            UserProfilesCache[Profile.PrincipalID] = Profile;

            IUserProfileInfo UPI = GetUserProfile(Profile.PrincipalID);
            if (UPI != null)
            {
                IDirectoryServiceConnector dirServiceConnector = DataManager.DataManager.RequestPlugin<IDirectoryServiceConnector>();
                if (dirServiceConnector != null)
                {
                    dirServiceConnector.RemoveClassifieds(UPI.Classifieds);
                    dirServiceConnector.AddClassifieds(Profile.Classifieds);
                }
            }

            return GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
		}
Esempio n. 22
0
 public bool UpdateUserProfile(IUserProfileInfo Profile)
 {
     return false;
 }
        public byte[] UpdateProfile(Dictionary<string, object> request)
        {
            Dictionary<string, object> result = new Dictionary<string, object>();
            
            UUID principalID = UUID.Zero;
            if (request.ContainsKey("PRINCIPALID"))
                UUID.TryParse(request["PRINCIPALID"].ToString(), out principalID);
            else
            {
                m_log.WarnFormat("[AuroraDataServerPostHandler]: no principalID in request to get profile");
                result["result"] = "null";
                string FailedxmlString = WebUtils.BuildXmlResponse(result);
                m_log.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", FailedxmlString);
                UTF8Encoding Failedencoding = new UTF8Encoding();
                return Failedencoding.GetBytes(FailedxmlString);
            }

            IUserProfileInfo UserProfile = new IUserProfileInfo();
            UserProfile.FromKVP(request);
            ProfileConnector.UpdateUserProfile(UserProfile);
            result["result"] = "Successful";

            string xmlString = WebUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetBytes(xmlString);
        }
Esempio n. 24
0
        private void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents)
        {
            OSDMap agentMap = new OSDMap();
            agentMap["username"] = account.Name;
            agentMap["display_name"] = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName;
            agentMap["display_name_next_update"] =
                OSD.FromDate(
                    DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z",
                                        DateTimeFormatInfo.InvariantInfo).ToUniversalTime());
            agentMap["legacy_first_name"] = account.FirstName;
            agentMap["legacy_last_name"] = account.LastName;
            agentMap["id"] = account.PrincipalID;
            agentMap["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name,
                                                                       info == null ? account.Name : info.DisplayName);

            agents.Add(agentMap);
        }
Esempio n. 25
0
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            Dictionary<string, object> Values = new Dictionary<string, object>();
            Values.Add("AllowPublish", Profile.AllowPublish ? 1 : 0);
            Values.Add("MaturePublish", Profile.MaturePublish ? 1 : 0);
            //Values.Add("Partner");
            Values.Add("WebURL", Profile.WebURL);
            Values.Add("AboutText", Profile.AboutText);
            Values.Add("FirstLifeAboutText", Profile.FirstLifeAboutText);
            Values.Add("Image", Profile.Image);
            Values.Add("FirstLifeImage", Profile.FirstLifeImage);
            //Values.Add("CustomType");
            Values.Add("Visible", Profile.Visible ? 1 : 0);
            Values.Add("IMViaEmail", Profile.IMViaEmail ? 1 : 0);
            Values.Add("MembershipGroup", Profile.MembershipGroup);
            Values.Add("AArchiveName", Profile.AArchiveName);
            Values.Add("IsNewUser", Profile.IsNewUser ? 1 : 0);
            //Values.Add("Created", Profile.Created);
            Values.Add("DisplayName", Profile.DisplayName);
            Values.Add("WantToMask", Profile.Interests.WantToMask);
            Values.Add("WantToText", Profile.Interests.WantToText);
            Values.Add("CanDoMask", Profile.Interests.CanDoMask);
            Values.Add("CanDoText", Profile.Interests.CanDoText);
            Values.Add("Languages", Profile.Interests.Languages);
            Values.Add("Notes", OSDParser.SerializeLLSDXmlString(Util.DictionaryToOSD(Profile.Notes)));
            Values.Add("Picks", OSDParser.SerializeLLSDXmlString(Util.DictionaryToOSD(Profile.Picks)));
            Values.Add("Classifieds", OSDParser.SerializeLLSDXmlString(Util.DictionaryToOSD(Profile.Classifieds)));


            List<object> SetValues = new List<object>();
            List<string> SetRows = new List<string>();
            SetRows.Add("Value");

            OSDMap map = Util.DictionaryToOSD(Values);
            SetValues.Add(OSDParser.SerializeLLSDXmlString(map));

            List<object> KeyValue = new List<object>();
			List<string> KeyRow = new List<string>();
			KeyRow.Add("ID");
            KeyValue.Add(Profile.PrincipalID.ToString());
            KeyRow.Add("`Key`");
            KeyValue.Add("LLProfile");

            //Update cache
            UserProfilesCache[Profile.PrincipalID] = Profile;

            return GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
		}
Esempio n. 26
0
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            object remoteValue = DoRemote(Profile);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue != null && (bool)remoteValue;

            IUserProfileInfo previousProfile = GetUserProfile(Profile.PrincipalID);
            //Make sure the previous one exists
            if (previousProfile == null)
                return false;
            //Now fix values that the sim cannot change
            Profile.Partner = previousProfile.Partner;
            Profile.CustomType = previousProfile.CustomType;
            Profile.MembershipGroup = previousProfile.MembershipGroup;
            Profile.Created = previousProfile.Created;

            Dictionary<string, object> values = new Dictionary<string, object>(1);
            values["Value"] = OSDParser.SerializeLLSDXmlString(Profile.ToOSD());

            QueryFilter filter = new QueryFilter();
            filter.andFilters["ID"] = Profile.PrincipalID.ToString();
            filter.andFilters["`Key`"] = "LLProfile";

            //Update cache
            UserProfilesCache[Profile.PrincipalID] = Profile;

            return GD.Update("userdata", values, null, filter, null, null);
        }
Esempio n. 27
0
        public void CreateNewProfile(UUID AgentID)
		{
			List<object> values = new List<object>();
            values.Add(AgentID.ToString()); //ID
            values.Add("LLProfile"); //Key
            IUserProfileInfo profile = new IUserProfileInfo();
            profile.PrincipalID = AgentID;
            values.Add(OSDParser.SerializeLLSDXmlString(Util.DictionaryToOSD(profile.ToKeyValuePairs()))); //Value which is a default Profile
			GD.Insert("userdata", values.ToArray());
		}
Esempio n. 28
0
        /// <summary>
        /// Create a new profile for a user
        /// </summary>
        /// <param name="AgentID"></param>
        public void CreateNewProfile(UUID AgentID)
		{
			List<object> values = new List<object>();
            values.Add(AgentID.ToString()); //ID
            values.Add("LLProfile"); //Key

            //Create a new basic profile for them
            IUserProfileInfo profile = new IUserProfileInfo();
            profile.PrincipalID = AgentID;

            values.Add(OSDParser.SerializeLLSDXmlString(profile.ToOSD())); //Value which is a default Profile
			
            GD.Insert("userdata", values.ToArray());
		}
Esempio n. 29
0
 public override IDataTransferable Duplicate()
 {
     IUserProfileInfo m = new IUserProfileInfo();
     m.FromOSD(ToOSD());
     return m;
 }
        protected void HandleLoadAvatarProfile(string module, string[] cmdparams)
        {
            if (cmdparams.Length != 6)
            {
                m_log.Debug("[AvatarProfileArchiver] Not enough parameters!");
                return;
            }
            StreamReader reader = new StreamReader(cmdparams[5]);

            string document = reader.ReadToEnd();
            string[] lines = document.Split('\n');
            List<string> file = new List<string>(lines);
            Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(file[1]);

            Dictionary<string, object> results = replyData["result"] as Dictionary<string, object>;
            UserAccount UDA = new UserAccount();
            UDA.FirstName = cmdparams[3];
            UDA.LastName = cmdparams[4];
            UDA.PrincipalID = UUID.Random();
            UDA.ScopeID = UUID.Zero;
            UDA.UserFlags = int.Parse(results["UserFlags"].ToString());
            UDA.UserLevel = 0; //For security... Don't want everyone loading full god mode.
            UDA.UserTitle = "";
            UDA.Email = results["Email"].ToString();
            UDA.Created = int.Parse(results["Created"].ToString());
            if (results.ContainsKey("ServiceURLs") && results["ServiceURLs"] != null)
            {
                UDA.ServiceURLs = new Dictionary<string, object>();
                string str = results["ServiceURLs"].ToString();
                if (str != string.Empty)
                {
                    string[] parts = str.Split(new char[] { ';' });
                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    foreach (string s in parts)
                    {
                        string[] parts2 = s.Split(new char[] { '*' });
                        if (parts2.Length == 2)
                            UDA.ServiceURLs[parts2[0]] = parts2[1];
                    }
                }
            }
            m_scene.UserAccountService.StoreUserAccount(UDA);


            replyData = ServerUtils.ParseXmlResponse(file[2]);
            IUserProfileInfo UPI = new IUserProfileInfo();
            UPI.FromKVP(replyData["result"] as Dictionary<string, object>);
            //Update the principle ID to the new user.
            UPI.PrincipalID = UDA.PrincipalID;

            IProfileConnector profileData = DataManager.DataManager.RequestPlugin<IProfileConnector>();
            if (profileData.GetUserProfile(UPI.PrincipalID) == null)
                profileData.CreateNewProfile(UPI.PrincipalID);

            profileData.UpdateUserProfile(UPI);


            reader.Close();
            reader.Dispose();

            m_log.Debug("[AvatarProfileArchiver] Loaded Avatar Profile from " + cmdparams[5]);
        }
Esempio n. 31
0
        public void CreateNewProfile(UUID AgentID)
        {
            object remoteValue = DoRemote(AgentID);
            if (remoteValue != null || m_doRemoteOnly)
                return;

            List<object> values = new List<object> {AgentID.ToString(), "LLProfile"};

            //Create a new basic profile for them
            IUserProfileInfo profile = new IUserProfileInfo {PrincipalID = AgentID};

            values.Add(OSDParser.SerializeLLSDXmlString(profile.ToOSD())); //Value which is a default Profile

            GD.Insert("userdata", values.ToArray());
        }
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            Dictionary<string, object> sendData = Profile.ToKeyValuePairs();

            sendData["PRINCIPALID"] = Profile.PrincipalID.ToString();
            sendData["METHOD"] = "updateprofile";

            string reqString = WebUtils.BuildXmlResponse(sendData);

            try
            {
                foreach (string m_ServerURI in m_ServerURIs)
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                        m_ServerURI + "/auroradata",
                        reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                        if (replyData != null)
                        {
                            if (replyData.ContainsKey("result") && (replyData["result"].ToString().ToLower() == "null"))
                            {
                                m_log.DebugFormat("[AuroraRemoteProfileConnector]: UpdateProfile {0} received null response",
                                    Profile.PrincipalID);
                                return false;
                            }
                        }

                        else
                        {
                            m_log.DebugFormat("[AuroraRemoteProfileConnector]: UpdateProfile {0} received null response",
                                Profile.PrincipalID);
                            return false;
                        }

                    }
                }
                return true;
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e.ToString());
            }
            return false;
        }