コード例 #1
0
        // Classifieds Handler
        public void HandleAvatarClassifiedsRequest(Object sender, string method, List <String> args)
        {
            if (!(sender is IClientAPI))
            {
                return;
            }

            IClientAPI remoteClient = (IClientAPI)sender;

            UUID targetID;

            UUID.TryParse(args[0], out targetID);

            // Can't handle NPC yet...
            ScenePresence p = FindPresence(targetID);

            if (null != p && p.PresenceType == PresenceType.Npc)
            {
                remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), new Dictionary <UUID, string>());
                return;
            }

            string serverURI = String.Empty;

            GetUserProfileServerURI(targetID, out serverURI);

            Hashtable ReqHash = new Hashtable();

            ReqHash["uuid"] = args[0];

            Hashtable result = GenericXMLRPCRequest(ReqHash,
                                                    method, serverURI);

            if (!Convert.ToBoolean(result["success"]))
            {
                remoteClient.SendAgentAlertMessage(
                    result["errorMessage"].ToString(), false);
                return;
            }

            ArrayList dataArray = (ArrayList)result["data"];

            Dictionary <UUID, string> classifieds = new Dictionary <UUID, string>();

            foreach (Object o in dataArray)
            {
                Hashtable d = (Hashtable)o;

                classifieds[new UUID(d["classifiedid"].ToString())] = d["name"].ToString();
            }

            remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
        }
コード例 #2
0
ファイル: OpenProfile.cs プロジェクト: lbgrid/halcyon
        // Classifieds Handler

        public void HandleAvatarClassifiedsRequest(Object sender, string method, List <String> args)
        {
            if (!(sender is IClientAPI))
            {
                return;
            }

            IClientAPI remoteClient = (IClientAPI)sender;

            UUID avatarID = new UUID(args[0]);

            using (ISimpleDB db = _connFactory.GetConnection())
            {
                Dictionary <UUID, string> classifieds = new Dictionary <UUID, string>();

                Dictionary <string, object> parms = new Dictionary <string, object>();
                parms.Add("?avatarID", avatarID);

                string query = "SELECT classifieduuid, name from classifieds " +
                               "WHERE creatoruuid=?avatarID";

                List <Dictionary <string, string> > results = db.QueryWithResults(query, parms);

                foreach (Dictionary <string, string> row in results)
                {
                    classifieds[new UUID(row["classifieduuid"].ToString())] = row["name"].ToString();
                }

                remoteClient.SendAvatarClassifiedReply(avatarID,
                                                       classifieds);
            }
        }
コード例 #3
0
        ///////////////////////////////////////////////////////////////////////////////////////////////
        //
        // Classified
        //

        // Request Classifieds Name
        public void HandleAvatarClassifiedsRequest(Object sender, string method, List <String> args)
        {
            if (!(sender is IClientAPI))
            {
                return;
            }

            IClientAPI remoteClient = (IClientAPI)sender;
            Hashtable  ReqHash      = new Hashtable();

            ReqHash["uuid"] = args[0];

            Hashtable result = GenericXMLRPCRequest(ReqHash, method);

            if (!Convert.ToBoolean(result["success"]))
            {
                remoteClient.SendAgentAlertMessage(result["errorMessage"].ToString(), false);
                return;
            }

            Dictionary <UUID, string> classifieds = new Dictionary <UUID, string>();
            ArrayList dataArray = (ArrayList)result["data"];

            string uuid = "";

            foreach (Object o in dataArray)
            {
                Hashtable d = (Hashtable)o;

                uuid = d["creatoruuid"].ToString();
                string name = d["name"].ToString();
                if (Enc != null)
                {
                    name = Enc.GetString(Convert.FromBase64String(name));
                }
                classifieds[new UUID(d["classifiedid"].ToString())] = name;
            }

            UUID agentid;

            if (uuid != "")
            {
                agentid = new UUID(uuid);
            }
            else
            {
                agentid = remoteClient.AgentId;
            }

            remoteClient.SendAvatarClassifiedReply(agentid, classifieds);
        }
コード例 #4
0
        // Classifieds Handler

        public void HandleAvatarClassifiedsRequest(Object sender, string method, List <String> args)
        {
            IClientAPI remoteClient = (IClientAPI)sender;

            if (m_Debug)
            {
                m_log.DebugFormat("[{0}] HandleAvatarClassifiedsRequest for {1}", m_moduleName, remoteClient.AgentId.ToString());
            }

            if (!(sender is IClientAPI))
            {
                if (m_Debug)
                {
                    m_log.DebugFormat("[{0}] HandleAvatarClassifiedsRequest (!(sender {1} is IClientAPI {2}))", m_moduleName, sender.ToString(), remoteClient.AgentId.ToString());
                }
                return;
            }

            Hashtable ReqHash = new Hashtable();

            ReqHash["uuid"] = args[0];

            Hashtable result = GenericXMLRPCRequest(ReqHash,
                                                    method);

            if (!Convert.ToBoolean(result["success"]))
            {
                remoteClient.SendAgentAlertMessage(
                    result["errorMessage"].ToString(), false);
                return;
            }

            ArrayList dataArray = (ArrayList)result["data"];

            Dictionary <UUID, string> classifieds = new Dictionary <UUID, string>();

            foreach (Object o in dataArray)
            {
                Hashtable d = (Hashtable)o;

                classifieds[new UUID(d["classifiedid"].ToString())] = d["name"].ToString();
            }

            remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
        }
コード例 #5
0
        private void AvatarClassifiedsRequestHandler(Object sender, string method, List <String> args)
        {
            if (!(sender is IClientAPI))
            {
                return;
            }
            IClientAPI client = (IClientAPI)sender;

            UUID targetAvatarID;

            if (args.Count < 1 || !UUID.TryParse(args[0], out targetAvatarID))
            {
                m_log.Error("[SIMIAN PROFILES]: Unrecognized arguments for " + method);
                return;
            }

            // FIXME: Query the generic key/value store for classifieds
            client.SendAvatarClassifiedReply(targetAvatarID, new Dictionary <UUID, string>(0));
        }
コード例 #6
0
        public void HandleAvatarClassifiedsRequest(Object sender, string method, List <String> args)
        {
            if (!(sender is IClientAPI))
            {
                return;
            }

            IClientAPI remoteClient  = (IClientAPI)sender;
            UUID       requestedUUID = new UUID(args[0]);

            Dictionary <UUID, string> classifieds = new Dictionary <UUID, string>();

            foreach (Classified classified in ProfileFrontend.GetClassifieds(requestedUUID))
            {
                classifieds.Add(classified.ClassifiedUUID, classified.Name);
            }

            remoteClient.SendAvatarClassifiedReply(requestedUUID, classifieds);
        }
コード例 #7
0
        public void HandleAvatarClassifiedsRequest(object sender, string method, List <string> args)
        {
            if (!(sender is IClientAPI))
            {
                return;
            }

            IClientAPI remoteClient  = (IClientAPI)sender;
            UUID       requestedUUID = new UUID(args [0]);

            // 20170120 - greythane - May need to check for NPC bots here and send an appropriate reply

            Dictionary <UUID, string> classifieds = new Dictionary <UUID, string> ();

            foreach (Classified classified in ProfileFrontend.GetClassifieds(requestedUUID))
            {
                classifieds.Add(classified.ClassifiedUUID, classified.Name);
            }

            remoteClient.SendAvatarClassifiedReply(requestedUUID, classifieds);
        }
コード例 #8
0
        /// <summary>
        /// Classifieds info update.
        /// </summary>
        /// <param name='queryclassifiedID'>
        /// Queryclassified I.
        /// </param>
        /// <param name='queryCategory'>
        /// Query category.
        /// </param>
        /// <param name='queryName'>
        /// Query name.
        /// </param>
        /// <param name='queryDescription'>
        /// Query description.
        /// </param>
        /// <param name='queryParcelID'>
        /// Query parcel I.
        /// </param>
        /// <param name='queryParentEstate'>
        /// Query parent estate.
        /// </param>
        /// <param name='querySnapshotID'>
        /// Query snapshot I.
        /// </param>
        /// <param name='queryGlobalPos'>
        /// Query global position.
        /// </param>
        /// <param name='queryclassifiedFlags'>
        /// Queryclassified flags.
        /// </param>
        /// <param name='queryclassifiedPrice'>
        /// Queryclassified price.
        /// </param>
        /// <param name='remoteClient'>
        /// Remote client.
        /// </param>
        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)
        {
            Scene s = (Scene)remoteClient.Scene;
            Vector3 pos = remoteClient.SceneAgent.AbsolutePosition;
            ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y);
            UUID creatorId = remoteClient.AgentId;
            ScenePresence p = FindPresence(creatorId);

            UserProfileCacheEntry uce = null;
            lock(m_profilesCache)
                m_profilesCache.TryGetValue(remoteClient.AgentId, out uce);

            string serverURI = string.Empty;
            bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
            if(string.IsNullOrWhiteSpace(serverURI))
            {
                return;
            }

            if(foreign)
            {
                remoteClient.SendAgentAlertMessage("Please change classifieds on your home grid", true);
                if(uce != null && uce.classifiedsLists != null)
                     remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists);
                return;
            }

            OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}};
            OSD Params = (OSD)parameters;
            if (!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString()))
            {
                remoteClient.SendAgentAlertMessage("Error fetching classifieds", false);
                return;
            }
            parameters = (OSDMap)Params;
            OSDArray list = (OSDArray)parameters["result"];
            bool exists = list.Cast<OSDMap>().Where(map => map.ContainsKey("classifieduuid"))
              .Any(map => map["classifieduuid"].AsUUID().Equals(queryclassifiedID));

            IMoneyModule money = null;
            if (!exists)
            {
                money = s.RequestModuleInterface<IMoneyModule>();
                if (money != null)
                {
                    if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice))
                    {
                        remoteClient.SendAgentAlertMessage("You do not have enough money to create this classified.", false);
                        if(uce != null && uce.classifiedsLists != null)
                            remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists);
                        return;
                    }
//                    money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge);
                }
            }

            UserClassifiedAdd ad = new UserClassifiedAdd();

            ad.ParcelName = land == null ? string.Empty : land.LandData.Name;
            ad.CreatorId = remoteClient.AgentId;
            ad.ClassifiedId = queryclassifiedID;
            ad.Category = Convert.ToInt32(queryCategory);
            ad.Name = queryName;
            ad.Description = queryDescription;
            ad.ParentEstate = Convert.ToInt32(queryParentEstate);
            ad.SnapshotId = querySnapshotID;
            ad.SimName = remoteClient.Scene.RegionInfo.RegionName;
            ad.GlobalPos = queryGlobalPos.ToString ();
            ad.Flags = queryclassifiedFlags;
            ad.Price = queryclassifiedPrice;
            ad.ParcelId = p.currentParcelUUID;

            object Ad = ad;

            OSD.SerializeMembers(Ad);

            if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString()))
            {
                remoteClient.SendAgentAlertMessage("Error updating classified", false);
                if(uce != null && uce.classifiedsLists != null)
                    remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists);
                return;
            }

            // only charge if it worked
            if (money != null)
                money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge);

            // just flush cache for now
            lock(m_profilesCache)
            {
                if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
                {
                    uce.classifieds = null;
                    uce.classifiedsLists = null;
                }
            }

        }
コード例 #9
0
        ///
        /// <summary>
        /// Handles the avatar classifieds request.
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='method'>
        /// Method.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        public void ClassifiedsRequest(Object sender, string method, List <String> args)
        {
            if (!(sender is IClientAPI))
            {
                return;
            }

            IClientAPI remoteClient = (IClientAPI)sender;

            UUID targetID;

            UUID.TryParse(args[0], out targetID);

            // Can't handle NPC yet...
            ScenePresence p = FindPresence(targetID);

            if (null != p)
            {
                if (p.PresenceType == PresenceType.Npc)
                {
                    return;
                }
            }

            string serverURI = string.Empty;

            GetUserProfileServerURI(targetID, out serverURI);
            UUID creatorId = UUID.Zero;
            Dictionary <UUID, string> classifieds = new Dictionary <UUID, string>();

            OSDMap parameters = new OSDMap();

            UUID.TryParse(args[0], out creatorId);
            parameters.Add("creatorId", OSD.FromUUID(creatorId));
            OSD Params = (OSD)parameters;

            if (!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString()))
            {
                remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
                return;
            }

            parameters = (OSDMap)Params;

            OSDArray list = (OSDArray)parameters["result"];

            foreach (OSD map in list)
            {
                OSDMap m    = (OSDMap)map;
                UUID   cid  = m["classifieduuid"].AsUUID();
                string name = m["name"].AsString();

                classifieds[cid] = name;

                lock (m_classifiedCache)
                {
                    if (!m_classifiedCache.ContainsKey(cid))
                    {
                        m_classifiedCache.Add(cid, creatorId);
                        m_classifiedInterest.Add(cid, 0);
                    }

                    m_classifiedInterest[cid]++;
                }
            }

            remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds);
        }