Exemplo n.º 1
0
 public bool AddClassified (Classified classified)
 {
     bool success = m_localService.AddClassified (classified);
     if (!success)
         success = m_remoteService.AddClassified (classified);
     return success;
 }
Exemplo n.º 2
0
        public Classified FindClassified(UUID classifiedID)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["CLASSIFIEDID"] = classifiedID;
            sendData["METHOD"] = "getclassified";

            string reqString = ServerUtils.BuildXmlResponse(sendData);

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

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


                        Dictionary<string, object>.ValueCollection replyvalues = replyData.Values;
                        Classified classified = null;
                        foreach (object f in replyvalues)
                        {
                            if (f is Dictionary<string, object>)
                            {
                                classified = new Classified((Dictionary<string, object>)f);
                            }
                        }
                        // Success
                        return classified;
                    }

                    else
                        m_log.DebugFormat("[AuroraRemoteProfileConnector]: GetClassified {0} received null response",
                            classifiedID);

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

            return null;
        }
Exemplo n.º 3
0
        public bool AddClassified(Classified classified)
        {
            object remoteValue = DoRemote(classified);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue != null && (bool)remoteValue;

            if (GetUserProfile(classified.CreatorUUID) == null)
                return false;
            //It might be updating, delete the old
            QueryFilter filter = new QueryFilter();
            filter.andFilters["ClassifiedUUID"] = classified.ClassifiedUUID;
            GD.Delete("userclassifieds", filter);
            List<object> values = new List<object>{
                classified.Name.MySqlEscape(),
                classified.Category,
                classified.SimName.MySqlEscape(),
                classified.CreatorUUID,
                classified.ClassifiedUUID,
                OSDParser.SerializeJsonString(classified.ToOSD()),
                classified.ScopeID
            };
            return GD.Insert("userclassifieds", values.ToArray());
        }
        /// <summary>
        ///   Searches for classifieds
        /// </summary>
        /// <param name = "queryText"></param>
        /// <param name = "category"></param>
        /// <param name = "queryFlags"></param>
        /// <param name = "StartQuery"></param>
        /// <returns></returns>
        public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, uint queryFlags, int StartQuery)
        {

            QueryFilter filter = new QueryFilter();

            filter.andLikeFilters["Name"] = "%" + queryText + "%";
            if (int.Parse(category) != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category
            {
                filter.andFilters["Category"] = category;
            }

            List<string> retVal = GD.Query(new string[1] { "*" }, "userclassifieds", filter, null, (uint)StartQuery, 50);
            if (retVal.Count == 0)
            {
                return new DirClassifiedReplyData[0] { };
            }

            List<DirClassifiedReplyData> Data = new List<DirClassifiedReplyData>();
            DirClassifiedReplyData replyData;
            for (int i = 0; i < retVal.Count; i += 6)
            {
                //Pull the classified out of OSD
                Classified classified = new Classified();
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(retVal[i + 5]));

                replyData = new DirClassifiedReplyData
                {
                    classifiedFlags = classified.ClassifiedFlags,
                    classifiedID = classified.ClassifiedUUID,
                    creationDate = classified.CreationDate,
                    expirationDate = classified.ExpirationDate,
                    price = classified.PriceForListing,
                    name = classified.Name
                };
                //Check maturity levels
                if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) == (uint)DirectoryManager.ClassifiedFlags.Mature)
                {
                    if ((queryFlags & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature)
                    {
                        Data.Add(replyData);
                    }
                }
                else
                { //Its PG, add all
                    Data.Add(replyData);
                }
            }
            return Data.ToArray();
        }
Exemplo n.º 5
0
 public List<Classified> GetClassifieds (UUID ownerID)
 {
     List<Classified> classifieds = new List<Classified> ();
     List<string> query = GD.Query (new string[1] { "OwnerUUID" }, new object[1] { ownerID }, "userclassifieds", "*");
     for (int i = 0; i < query.Count; i+=6)
     {
         Classified classified = new Classified ();
         classified.FromOSD ((OSDMap)OSDParser.DeserializeJson (query[i+5]));
         classifieds.Add (classified);
     }
     return classifieds;
 }
        public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName,
                                         string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos,
                                         byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId);

            if (p == null)
                return; //Just fail

            IMoneyModule money = p.Scene.RequestModuleInterface<IMoneyModule>();
            if (money != null)
            {
                if (!money.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified"))
                {
                    remoteClient.SendAlertMessage("You do not have enough money to complete this upload.");
                    return;
                }
            }

            UUID creatorUUID = remoteClient.AgentId;
            UUID classifiedUUID = queryclassifiedID;
            uint category = queryCategory;
            string name = queryName;
            string description = queryDescription;
            uint parentestate = queryParentEstate;
            UUID snapshotUUID = querySnapshotID;
            string simname = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos = queryGlobalPos;
            byte classifiedFlags = queryclassifiedFlags;
            int classifiedPrice = queryclassifiedPrice;

            UUID parceluuid = p.CurrentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement =
                remoteClient.Scene.RequestModuleInterface<IParcelManagementModule>();
            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.InfoUUID;
                }
            }

            uint creationdate = (uint) Util.UnixTimeSinceEpoch();

            uint expirationdate = (uint) Util.UnixTimeSinceEpoch() + (365*24*60*60);

            Classified classified = new Classified
                                        {
                                            ClassifiedUUID = classifiedUUID,
                                            CreatorUUID = creatorUUID,
                                            CreationDate = creationdate,
                                            ExpirationDate = expirationdate,
                                            Category = category,
                                            Name = name,
                                            Description = description,
                                            ParcelUUID = parceluuid,
                                            ParentEstate = parentestate,
                                            SnapshotUUID = snapshotUUID,
                                            SimName = simname,
                                            GlobalPos = globalpos,
                                            ParcelName = parcelname,
                                            ClassifiedFlags = classifiedFlags,
                                            PriceForListing = classifiedPrice,
                                            ScopeID = remoteClient.ScopeID
                                        };

            ProfileFrontend.AddClassified(classified);
        }
 /// <summary>
 /// Gets all classifieds in the given region
 /// </summary>
 /// <param name="regionName"></param>
 /// <returns></returns>
 public Classified[] GetClassifiedsInRegion(string regionName)
 {
     List<Classified> Classifieds = new List<Classified>();
     List<string> retVal = GD.Query ("SimName", regionName, "userclassifieds", "*");
     
     if (retVal.Count == 0)
         return Classifieds.ToArray();
     
     Classified classified = new Classified();
     for (int i = 0; i < retVal.Count; i += 6)
     {
         //Pull the classified out of OSD
         classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[i + 5]));
         Classifieds.Add(classified);
         classified = new Classified();
     }
     return Classifieds.ToArray();
 }
 /// <summary>
 /// Remove classifieds from the search database
 /// LOCAL Only, called by the profile service
 /// </summary>
 /// <param name="dictionary">objects of the dictionary are OSDMaps made from Classified</param>
 public void RemoveClassifieds(Dictionary<string, object> dictionary)
 {
     //Remove all the UUIDs in the given dictionary from search
     foreach (object o in dictionary.Values)
     {
         //Pull out the OSDMaps
         OSDMap map = (OSDMap)o;
         Classified c = new Classified();
         c.FromOSD(map);
         List<string> Keys = new List<string>();
         Keys.Add("ClassifiedUUID");
         List<object> Values = new List<object>();
         Values.Add(c.ClassifiedUUID);
         GD.Delete("profileclassifieds", Keys.ToArray(), Values.ToArray());
     }
 }
        public Classified GetClassifiedByID(UUID id)
        {
            object remoteValue = DoRemote(id);
            if (remoteValue != null || m_doRemoteOnly)
                return (Classified)remoteValue;

            QueryFilter filter = new QueryFilter();
            Dictionary<string, object> where = new Dictionary<string, object>(1);
            where.Add("ClassifiedUUID", id);
            filter.andFilters = where;
            List<string> retVal = GD.Query(new[] { "*" }, "userclassifieds", filter, null, null, null);
            if ((retVal == null) || (retVal.Count == 0)) return null;
            Classified classified = new Classified();
            classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[6]));
            return classified;
        }
        public List<DirClassifiedReplyData> FindClassifieds(string queryText, string category, uint queryFlags, int StartQuery, UUID scopeID)
        {
            object remoteValue = DoRemote(queryText, category, queryFlags, StartQuery, scopeID);
            if (remoteValue != null || m_doRemoteOnly)
                return (List<DirClassifiedReplyData>)remoteValue;

            QueryFilter filter = new QueryFilter();

            filter.andLikeFilters["Name"] = "%" + queryText + "%";
            if (int.Parse(category) != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category
                filter.andFilters["Category"] = category;
            if (scopeID != UUID.Zero)
                filter.andFilters["ScopeID"] = scopeID;

            List<string> retVal = GD.Query(new[] { "*" }, "userclassifieds", filter, null, (uint)StartQuery, 50);
            if (retVal.Count == 0)
                return new List<DirClassifiedReplyData>();

            List<DirClassifiedReplyData> Data = new List<DirClassifiedReplyData>();
            for (int i = 0; i < retVal.Count; i += 9)
            {
                //Pull the classified out of OSD
                Classified classified = new Classified();
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(retVal[i + 5]));

                DirClassifiedReplyData replyData = new DirClassifiedReplyData
                                                       {
                                                           classifiedFlags = classified.ClassifiedFlags,
                                                           classifiedID = classified.ClassifiedUUID,
                                                           creationDate = classified.CreationDate,
                                                           expirationDate = classified.ExpirationDate,
                                                           price = classified.PriceForListing,
                                                           name = classified.Name
                                                       };
                //Check maturity levels
                if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) != (uint)DirectoryManager.ClassifiedFlags.Mature)
                {
                    if ((queryFlags & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature)
                        Data.Add(replyData);
                }
                else
                    //Its Mature, add all
                    Data.Add(replyData);
            }
            return Data;
        }
Exemplo n.º 11
0
        public List<Classified> GetClassifieds(UUID ownerID)
        {
            object remoteValue = DoRemote(ownerID);
            if (remoteValue != null || m_doRemoteOnly)
                return (List<Classified>)remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["OwnerUUID"] = ownerID;

            List<string> query = GD.Query(new[] { "*" }, "userclassifieds", filter, null, null, null);

            List<Classified> classifieds = new List<Classified>();
            for (int i = 0; i < query.Count; i += 7)
            {
                Classified classified = new Classified();
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(query[i + 5]));
                classifieds.Add(classified);
            }
            return classifieds;
        }
Exemplo n.º 12
0
        public Classified GetClassified(UUID queryClassifiedID)
        {
            object remoteValue = DoRemote(queryClassifiedID);
            if (remoteValue != null || m_doRemoteOnly)
                return (Classified)remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["ClassifiedUUID"] = queryClassifiedID;

            List<string> query = GD.Query(new[] { "*" }, "userclassifieds", filter, null, null, null);

            if (query.Count < 6)
            {
                return null;
            }
            Classified classified = new Classified();
            classified.FromOSD((OSDMap) OSDParser.DeserializeJson(query[5]));
            return classified;
        }
Exemplo n.º 13
0
        public void GodClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient)
        {
            if (m_scene.Permissions.IsGod(remoteClient.AgentId))
            {
                IUserProfileInfo info = ProfileFrontend.GetUserProfile(remoteClient.AgentId);

                if (info == null)
                    return;
                if (info.Classifieds.ContainsKey(queryClassifiedID.ToString()))
                {
                    OSDMap Classifieds = Util.DictionaryToOSD(info.Classifieds);
                    Classified oldClassified = new Classified(Util.OSDToDictionary((OSDMap)Classifieds[queryClassifiedID.ToString()]));
                    if (oldClassified.CreatorUUID != remoteClient.AgentId)
                        return;

                    info.Classifieds.Remove(queryClassifiedID.ToString());
                    ProfileFrontend.UpdateUserProfile(info);
                }
            }
        }
Exemplo n.º 14
0
        public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName, string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            //Security check
            IUserProfileInfo info = ProfileFrontend.GetUserProfile(remoteClient.AgentId);

            if (info == null)
                return;
            if (info.Classifieds.ContainsKey(queryclassifiedID.ToString()))
            {
                OSDMap Classifieds = Util.DictionaryToOSD(info.Classifieds);
                Classified oldClassified = new Classified(Util.OSDToDictionary((OSDMap)Classifieds[queryclassifiedID.ToString()]));
                if (oldClassified.CreatorUUID != remoteClient.AgentId)
                    return;

                info.Classifieds.Remove(queryclassifiedID.ToString());
            }

            UUID creatorUUID = remoteClient.AgentId;
            UUID classifiedUUID = queryclassifiedID;
            uint category = queryCategory;
            string name = queryName;
            string description = queryDescription;
            uint parentestate = queryParentEstate;
            UUID snapshotUUID = querySnapshotID;
            string simname = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos = queryGlobalPos;
            byte classifiedFlags = queryclassifiedFlags;
            int classifiedPrice = queryclassifiedPrice;

            ScenePresence p = m_scene.GetScenePresence(remoteClient.AgentId);

            UUID parceluuid = p.currentParcelUUID;
            string parcelname = "Unknown";

            string pos_global = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX * Constants.RegionSize + p.AbsolutePosition.X,
                remoteClient.Scene.RegionInfo.RegionLocY * Constants.RegionSize + p.AbsolutePosition.Y,
                p.AbsolutePosition.Z).ToString();

            ILandObject parcel = m_scene.LandChannel.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
            if(parcel != null)
            {
                parcelname = parcel.LandData.Name;
                parceluuid = parcel.LandData.InfoUUID;
            }

            uint creationdate = (uint)Util.UnixTimeSinceEpoch();
            
            uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60);

            Classified classified = new Classified();
            classified.ClassifiedUUID = classifiedUUID;
            classified.CreatorUUID = creatorUUID;
            classified.CreationDate = creationdate;
            classified.ExpirationDate = expirationdate;
            classified.Category = category;
            classified.Name = name;
            classified.Description = description;
            classified.ParcelUUID = parceluuid;
            classified.ParentEstate = parentestate;
            classified.SnapshotUUID = snapshotUUID;
            classified.SimName = simname;
            classified.GlobalPos = globalpos;
            classified.ParcelName = parcelname;
            classified.ClassifiedFlags = classifiedFlags;
            classified.PriceForListing = classifiedPrice;

            info.Classifieds.Add(classified.ClassifiedUUID.ToString(), Util.DictionaryToOSD(classified.ToKeyValuePairs()));
            ProfileFrontend.UpdateUserProfile(info);
        }
        /// <summary>
        ///   Gets all classifieds in the given region
        /// </summary>
        /// <param name = "regionName"></param>
        /// <returns></returns>
        public Classified[] GetClassifiedsInRegion(string regionName)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["SimName"] = regionName;
            List<string> retVal = GD.Query(new string[] { "*" }, "userclassifieds", filter, null, null, null);

            if (retVal.Count == 0)
            {
                return new Classified[0] { };
            }

            List<Classified> Classifieds = new List<Classified>();
            Classified classified;
            for (int i = 0; i < retVal.Count; i += 6)
            {
                classified = new Classified();
                //Pull the classified out of OSD
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(retVal[i + 5]));
                Classifieds.Add(classified);
            }
            return Classifieds.ToArray();
        }
Exemplo n.º 16
0
        public void GodClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient)
        {
            if (GetRegionUserIsIn(remoteClient.AgentId).Permissions.IsGod(remoteClient.AgentId))
            {
                IUserProfileInfo info = ProfileFrontend.GetUserProfile(remoteClient.AgentId);

                if (info == null)
                    return;
                if (info.Classifieds.ContainsKey(queryClassifiedID.ToString()))
                {
                    Classified oldClassified = new Classified();
                    oldClassified.FromOSD((OSDMap)info.Classifieds[queryClassifiedID.ToString()]);

                    info.Classifieds.Remove(queryClassifiedID.ToString());
                    ProfileFrontend.UpdateUserProfile(info);
                }
            }
        }
 public Classified[] GetClassifiedsInRegion(string regionName)
 {
     //TODO: BROKEN!
     List<Classified> Classifieds = new List<Classified>();
     List<string> retVal = GD.Query("simname", regionName, "profileclassifieds", "*");
     if (retVal.Count == 0)
         return Classifieds.ToArray();
     int a = 0;
     Classified classified = new Classified();
     for (int i = 0; i < retVal.Count; i++)
     {
         if (a == 0)
             classified.ClassifiedUUID = UUID.Parse(retVal[i]);
         if (a == 1)
             classified.CreatorUUID = UUID.Parse(retVal[i]);
         if (a == 2)
             classified.CreationDate = uint.Parse(retVal[i]);
         if (a == 3)
             classified.ExpirationDate = uint.Parse(retVal[i]);
         if (a == 4)
             classified.Category = uint.Parse(retVal[i]);
         if (a == 5)
             classified.Name = retVal[i];
         if (a == 6)
             classified.Description = retVal[i];
         if (a == 7)
             classified.ParcelUUID = UUID.Parse(retVal[i]);
         if (a == 8)
             classified.ParentEstate = uint.Parse(retVal[i]);
         if (a == 9)
             classified.SnapshotUUID = UUID.Parse(retVal[i]);
         if (a == 10)
             classified.SimName = retVal[i];
         if (a == 11)
             classified.GlobalPos = Vector3.Parse(retVal[i]);
         if (a == 12)
             classified.ParcelName = retVal[i];
         if (a == 13)
             classified.ClassifiedFlags = byte.Parse(retVal[i]);
         if (a == 14)
             classified.PriceForListing = int.Parse(retVal[i]);
         a++;
         if (a == 15)
         {
             a = 0;
             Classifieds.Add(classified);
             classified = new Classified();
         }
     }
     return Classifieds.ToArray();
 }
Exemplo n.º 18
0
 public bool AddClassified (Classified classified)
 {
     try
     {
         List<string> serverURIs = m_registry.RequestModuleInterface<IConfigurationService> ().FindValueOf (classified.CreatorUUID.ToString (), "RemoteServerURI");
         foreach (string url in serverURIs)
         {
             OSDMap map = new OSDMap ();
             map["Method"] = "addclassified";
             map["Classified"] = classified.ToOSD ();
             WebUtils.PostToService (url + "osd", map, false, false);
         }
     }
     catch (Exception e)
     {
         m_log.DebugFormat ("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e.ToString ());
     }
     return true;
 }
        public List<Classified> GetClassifiedsInRegion(string regionName)
        {
            object remoteValue = DoRemote(regionName);
            if (remoteValue != null || m_doRemoteOnly)
                return (List<Classified>)remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["SimName"] = regionName;
            List<string> retVal = GD.Query(new[] { "*" }, "userclassifieds", filter, null, null, null);

            if (retVal.Count == 0)
            {
                return new List<Classified>();
            }

            List<Classified> Classifieds = new List<Classified>();
            for (int i = 0; i < retVal.Count; i += 9)
            {
                Classified classified = new Classified();
                //Pull the classified out of OSD
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(retVal[i + 6]));
                Classifieds.Add(classified);
            }
            return Classifieds;
        }
Exemplo n.º 20
0
 public Classified GetClassified (UUID queryClassifiedID)
 {
     try
     {
         List<string> serverURIs = m_registry.RequestModuleInterface<IConfigurationService> ().FindValueOf ("RemoteServerURI");
         foreach (string url in serverURIs)
         {
             OSDMap map = new OSDMap ();
             map["Method"] = "getclassified";
             map["ClassifiedUUID"] = queryClassifiedID;
             OSDMap response = WebUtils.PostToService (url + "osd", map, true, true);
             if (response["_Result"].Type == OSDType.Map)
             {
                 OSDMap responsemap = (OSDMap)response["_Result"];
                 Classified info = new Classified ();
                 info.FromOSD (responsemap);
                 return info;
             }
         }
     }
     catch (Exception e)
     {
         m_log.DebugFormat ("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e.ToString ());
     }
     return null;
 }
 /// <summary>
 /// Add classifieds to the search database
 /// LOCAL Only, called by the profile service
 /// </summary>
 /// <param name="dictionary">objects of the dictionary are OSDMaps made from Classified</param>
 public void AddClassifieds(Dictionary<string, object> dictionary)
 {
     //Add a dictionary of classifieds
     foreach (object o in dictionary.Values)
     {
         //Pull out the OSD map and make it into a classified
         OSDMap map = (OSDMap)o;
         Classified c = new Classified();
         c.FromOSD(map);
         List<object> Values = new List<object>();
         Values.Add(c.Name);
         Values.Add(c.Category);
         Values.Add(c.SimName);
         Values.Add(c.ClassifiedUUID);
         Values.Add(OSDParser.SerializeJsonString(map));
         GD.Insert("profileclassifieds", Values.ToArray());
     }
 }
Exemplo n.º 22
0
 public List<Classified> GetClassifieds (UUID ownerID)
 {
     try
     {
         List<string> serverURIs = m_registry.RequestModuleInterface<IConfigurationService> ().FindValueOf (ownerID.ToString (), "RemoteServerURI");
         foreach (string url in serverURIs)
         {
             OSDMap map = new OSDMap ();
             map["Method"] = "getclassifieds";
             map["PrincipalID"] = ownerID;
             OSDMap response = WebUtils.PostToService (url + "osd", map, true, true);
             if (response["_Result"].Type == OSDType.Map)
             {
                 OSDMap responsemap = (OSDMap)response["_Result"];
                 if (responsemap.ContainsKey ("Result"))
                 {
                     List<Classified> list = new List<Classified> ();
                     OSDArray picks = (OSDArray)responsemap["Result"];
                     foreach (OSD o in picks)
                     {
                         Classified info = new Classified ();
                         info.FromOSD ((OSDMap)o);
                         list.Add (info);
                     }
                     return list;
                 }
                 return new List<Classified> ();
             }
         }
     }
     catch (Exception e)
     {
         m_log.DebugFormat ("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e.ToString ());
     }
     return null;
 }
        /// <summary>
        /// Searches for classifieds
        /// </summary>
        /// <param name="queryText"></param>
        /// <param name="category"></param>
        /// <param name="queryFlags"></param>
        /// <param name="StartQuery"></param>
        /// <returns></returns>
        public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, string queryFlags, int StartQuery)
        {
            List<DirClassifiedReplyData> Data = new List<DirClassifiedReplyData>();

            string whereClause = "";
            string classifiedClause = "";
            uint cqf = uint.Parse(queryFlags);

            if (int.Parse(category) != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category
                classifiedClause = " and Category = '" + category + "'";

            whereClause = " Name LIKE '%" + queryText + "%'" + classifiedClause + " LIMIT " + StartQuery.ToString() + ",50 ";
            List<string> retVal = GD.Query (whereClause, "userclassifieds", "*");
            if (retVal.Count == 0)
                return Data.ToArray();

            DirClassifiedReplyData replyData = null;
            for (int i = 0; i < retVal.Count; i += 6)
            {
                //Pull the classified out of OSD
                Classified classified = new Classified();
                classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[i + 5]));

                replyData = new DirClassifiedReplyData();
                replyData.classifiedFlags = classified.ClassifiedFlags;
                replyData.classifiedID = classified.ClassifiedUUID;
                replyData.creationDate = classified.CreationDate;
                replyData.expirationDate = classified.ExpirationDate;
                replyData.price = classified.PriceForListing;
                replyData.name = classified.Name;
                //Check maturity levels
                if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) == (uint)DirectoryManager.ClassifiedFlags.Mature)
                {
                    if ((cqf & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature)
                        Data.Add(replyData);
                }
                else //Its PG, add all
                    Data.Add(replyData);
            }
            return Data.ToArray();
        }
Exemplo n.º 24
0
        public void HandleAvatarClassifiedsRequest(Object sender, string method, List<String> args)
        {
            if (!(sender is IClientAPI))
                return;

            IClientAPI remoteClient = (IClientAPI)sender;
            Dictionary<UUID, string> classifieds = new Dictionary<UUID, string>();
            UUID requestedUUID = new UUID(args[0]);

            //Does this person have the power to view this person's profile?
            bool isFriend = IsFriendOfUser(remoteClient.AgentId, requestedUUID);
            if (isFriend)
            {
                IUserProfileInfo profile = ProfileFrontend.GetUserProfile(requestedUUID);
                if (profile == null)
                    return;
                foreach (object classified in profile.Classifieds.Values)
                {
                    Classified Classified = new Classified();
                    Classified.FromOSD((OSDMap)classified);
                    classifieds.Add(Classified.ClassifiedUUID, Classified.Name);
                }
            }

            remoteClient.SendAvatarClassifiedReply(requestedUUID, classifieds);        
        }
        public byte[] AddClassified (OSDMap request)
        {
            Classified info = new Classified ();
            info.FromOSD ((OSDMap)request["Classified"]);

            ProfileConnector.AddClassified (info);

            string xmlString = OSDParser.SerializeJsonString (new OSDMap ());
            //m_log.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding ();
            return encoding.GetBytes (xmlString);
        }
Exemplo n.º 26
0
 public void ClassifiedInfoRequest(UUID queryClassifiedID, IClientAPI remoteClient)
 {
     IUserProfileInfo info = ProfileFrontend.GetUserProfile(remoteClient.AgentId);
     if (info == null)
         return;
     if (info.Classifieds.ContainsKey(queryClassifiedID.ToString()))
     {
         Classified classified = new Classified();
         classified.FromOSD((OSDMap)info.Classifieds[queryClassifiedID.ToString()]);
         remoteClient.SendClassifiedInfoReply(queryClassifiedID, classified.CreatorUUID, classified.CreationDate, classified.ExpirationDate, classified.Category, classified.Name, classified.Description, classified.ParcelUUID, classified.ParentEstate, classified.SnapshotUUID, classified.SimName, classified.GlobalPos, classified.ParcelName, classified.ClassifiedFlags, classified.PriceForListing);
     }
 }
Exemplo n.º 27
0
 public bool AddClassified (Classified classified)
 {
     if (GetUserProfile (classified.CreatorUUID) == null)
         return false;
     //It might be updating, delete the old
     GD.Delete ("userclassifieds", new string[1] { "ClassifiedUUID" }, new object[1] { classified.ClassifiedUUID });
     List<object> values = new List<object>();
     values.Add(classified.Name);
     values.Add(classified.Category);
     values.Add(classified.SimName);
     values.Add(classified.CreatorUUID);
     values.Add(classified.ClassifiedUUID);
     values.Add(OSDParser.SerializeJsonString(classified.ToOSD()));
     return GD.Insert("userclassifieds", values.ToArray());
 }
Exemplo n.º 28
0
        public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName, string queryDescription, UUID queryParcelID,
                                         uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags,
                                         int queryclassifiedPrice, IClientAPI remoteClient)
        {
            //Security check
            IUserProfileInfo info = ProfileFrontend.GetUserProfile(remoteClient.AgentId);

            if (info == null)
                return;

            ScenePresence p = GetRegionUserIsIn(remoteClient.AgentId).GetScenePresence(remoteClient.AgentId);

            if(p == null)
                return; //Just fail

            IMoneyModule money = p.Scene.RequestModuleInterface<IMoneyModule>();
            if (money != null)
            {
                if (money.AmountCovered(remoteClient, queryclassifiedPrice))
                    money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified");
                else
                {
                    remoteClient.SendAlertMessage("You do not have enough money to complete this upload.");
                    return;
                }
            }

            if (info.Classifieds.ContainsKey(queryclassifiedID.ToString()))
            {
                Classified oldClassified = new Classified();
                oldClassified.FromOSD((OSDMap)info.Classifieds[queryclassifiedID.ToString()]);
                if (oldClassified.CreatorUUID != remoteClient.AgentId)
                    return;

                info.Classifieds.Remove(queryclassifiedID.ToString());
            }

            UUID creatorUUID = remoteClient.AgentId;
            UUID classifiedUUID = queryclassifiedID;
            uint category = queryCategory;
            string name = queryName;
            string description = queryDescription;
            uint parentestate = queryParentEstate;
            UUID snapshotUUID = querySnapshotID;
            string simname = remoteClient.Scene.RegionInfo.RegionName;
            Vector3 globalpos = queryGlobalPos;
            byte classifiedFlags = queryclassifiedFlags;
            int classifiedPrice = queryclassifiedPrice;

            UUID parceluuid = p.currentParcelUUID;
            string parcelname = "Unknown";
            IParcelManagementModule parcelManagement = GetRegionUserIsIn(remoteClient.AgentId).RequestModuleInterface<IParcelManagementModule>();
            if (parcelManagement != null)
            {
                ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y);
                if (parcel != null)
                {
                    parcelname = parcel.LandData.Name;
                    parceluuid = parcel.LandData.InfoUUID;
                }
            }

            uint creationdate = (uint)Util.UnixTimeSinceEpoch();
            
            uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60);

            Classified classified = new Classified();
            classified.ClassifiedUUID = classifiedUUID;
            classified.CreatorUUID = creatorUUID;
            classified.CreationDate = creationdate;
            classified.ExpirationDate = expirationdate;
            classified.Category = category;
            classified.Name = name;
            classified.Description = description;
            classified.ParcelUUID = parceluuid;
            classified.ParentEstate = parentestate;
            classified.SnapshotUUID = snapshotUUID;
            classified.SimName = simname;
            classified.GlobalPos = globalpos;
            classified.ParcelName = parcelname;
            classified.ClassifiedFlags = classifiedFlags;
            classified.PriceForListing = classifiedPrice;

            info.Classifieds.Add(classified.ClassifiedUUID.ToString(), classified.ToOSD());
            ProfileFrontend.UpdateUserProfile(info);
        }
Exemplo n.º 29
0
 public Classified GetClassified (UUID queryClassifiedID)
 {
     List<string> query = GD.Query (new string[1] { "ClassifiedUUID" }, new object[1] { queryClassifiedID }, "userclassifieds", "*");
     if (query.Count < 6)
         return null;
     Classified classified = new Classified ();
     classified.FromOSD ((OSDMap)OSDParser.DeserializeJson (query[5]));
     return classified;
 }
Exemplo n.º 30
0
        public void ClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient)
        {
            //Security check
            IUserProfileInfo info = ProfileFrontend.GetUserProfile(remoteClient.AgentId);

            if (info == null)
                return;
            if (info.Classifieds.ContainsKey(queryClassifiedID.ToString()))
            {
                Classified oldClassified = new Classified();
                oldClassified.FromOSD((OSDMap)info.Classifieds[queryClassifiedID.ToString()]);
                if (oldClassified.CreatorUUID != remoteClient.AgentId)
                    return;

                info.Classifieds.Remove(queryClassifiedID.ToString());
                ProfileFrontend.UpdateUserProfile(info);
            }
        }