* Updates to DirectoryManager, specifically Classified Ads that add missing adult rating functionality for queries, adds an enum to interpret flags in replies
* Adds additional documentation to both ParcelManager and DirectoryManager * Adds Example TestClient command to search classified ads * Updates to PacketDecoder to better interpret some additional flag fields git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3132 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -34,7 +34,7 @@ using OpenMetaverse.Messages.Linden;
|
||||
namespace OpenMetaverse
|
||||
{
|
||||
/// <summary>
|
||||
/// Access to the Linden dataserver which allows searching for land, events, people, etc
|
||||
/// Access to the dataserver which allows searching for land, events, people, etc
|
||||
/// </summary>
|
||||
public class DirectoryManager
|
||||
{
|
||||
@@ -43,11 +43,11 @@ namespace OpenMetaverse
|
||||
/// </summary>
|
||||
public enum ClassifiedCategories
|
||||
{
|
||||
/// <summary></summary>
|
||||
/// <summary>Classified is listed in the Any category</summary>
|
||||
Any = 0,
|
||||
/// <summary></summary>
|
||||
/// <summary>Classified is shopping related</summary>
|
||||
Shopping,
|
||||
/// <summary></summary>
|
||||
/// <summary>Classified is </summary>
|
||||
LandRental,
|
||||
/// <summary></summary>
|
||||
PropertyRental,
|
||||
@@ -65,24 +65,37 @@ namespace OpenMetaverse
|
||||
Personal
|
||||
}
|
||||
|
||||
/// <summary></summary>
|
||||
public enum EventCategories
|
||||
{
|
||||
/// <summary></summary>
|
||||
All = 0,
|
||||
/// <summary></summary>
|
||||
Discussion = 18,
|
||||
/// <summary></summary>
|
||||
Sports = 19,
|
||||
/// <summary></summary>
|
||||
LiveMusic = 20,
|
||||
/// <summary></summary>
|
||||
Commercial = 22,
|
||||
/// <summary></summary>
|
||||
Nightlife = 23,
|
||||
/// <summary></summary>
|
||||
Games = 24,
|
||||
/// <summary></summary>
|
||||
Pageants = 25,
|
||||
/// <summary></summary>
|
||||
Education = 26,
|
||||
/// <summary></summary>
|
||||
Arts = 27,
|
||||
/// <summary></summary>
|
||||
Charity = 28,
|
||||
/// <summary></summary>
|
||||
Miscellaneous = 29
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modifier flags sent to DirectoryManager to select the behaviour of the
|
||||
/// Modifier flags sent to DirectoryManager to change the behavior of the
|
||||
/// query
|
||||
/// </summary>
|
||||
/// Land Search Flags required in addition to specify land maturity rating:
|
||||
@@ -202,14 +215,56 @@ namespace OpenMetaverse
|
||||
public UUID ID;
|
||||
/// <summary>The title of this classified ad</summary>
|
||||
public string Name;
|
||||
/// <summary>Unknown</summary>
|
||||
public byte Flags;
|
||||
/// <summary>Flags that show certain options applied to the classified</summary>
|
||||
public ClassifiedFlags Flags;
|
||||
/// <summary>Creation date of the ad</summary>
|
||||
public DateTime CreationDate;
|
||||
/// <summary>Expiration date of the ad</summary>
|
||||
public DateTime ExpirationDate;
|
||||
/// <summary>Price that was paid for this ad</summary>
|
||||
public int Price;
|
||||
|
||||
/// <summary>
|
||||
/// Display a classified ad in a one line human readable format
|
||||
/// </summary>
|
||||
/// <returns>A string representing a single classified ad</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("Classified Ad: ID: {0}, Name: {1}, Flags: [{2}] {3}, Created: {4}, Expires: {5}, Paid: {6}",
|
||||
this.ID, this.Name, this.Flags, this.Flags.ToString(), this.CreationDate, this.ExpirationDate, this.Price);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classified Ad Options
|
||||
/// </summary>
|
||||
/// <remarks>There appear to be two formats the flags are packed in.
|
||||
/// This set of flags is for the newer style</remarks>
|
||||
[Flags]
|
||||
public enum ClassifiedFlags : byte
|
||||
{
|
||||
None = 1 << 0,
|
||||
Mature = 1 << 1,
|
||||
Enabled = 1 << 2,
|
||||
// HasPrice = 1 << 3, // Deprecated
|
||||
UpdateTime = 1 << 4,
|
||||
AutoRenew = 1 << 5
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classified ad query options
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ClassifiedQueryFlags
|
||||
{
|
||||
/// <summary>Include all ads in results</summary>
|
||||
All = PG | Mature | Adult,
|
||||
/// <summary>Include PG ads in results</summary>
|
||||
PG = 1 << 2,
|
||||
/// <summary>Include Mature ads in results</summary>
|
||||
Mature = 1 << 3,
|
||||
/// <summary>Include Adult ads in results</summary>
|
||||
Adult = 1 << 6,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -245,9 +300,10 @@ namespace OpenMetaverse
|
||||
public string FirstName;
|
||||
/// <summary>Agents last name</summary>
|
||||
public string LastName;
|
||||
/// <summary>Agents <seealso cref="T:OpenMetaverse.UUID"/></summary>
|
||||
/// <summary>Agents <see cref="UUID"/></summary>
|
||||
public UUID AgentID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Response to a "Groups" Search
|
||||
/// </summary>
|
||||
@@ -394,7 +450,10 @@ namespace OpenMetaverse
|
||||
|
||||
private GridClient Client;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of the DirectoryManager class
|
||||
/// </summary>
|
||||
/// <param name="client">An instance of GridClient</param>
|
||||
public DirectoryManager(GridClient client)
|
||||
{
|
||||
Client = client;
|
||||
@@ -410,18 +469,58 @@ namespace OpenMetaverse
|
||||
Client.Network.RegisterCallback(PacketType.DirEventsReply, new NetworkManager.PacketCallback(EventsReplyHandler));
|
||||
Client.Network.RegisterCallback(PacketType.EventInfoReply, new NetworkManager.PacketCallback(EventInfoReplyHandler));
|
||||
Client.Network.RegisterCallback(PacketType.DirPlacesReply, new NetworkManager.PacketCallback(DirPlacesReplyHandler));
|
||||
|
||||
}
|
||||
|
||||
public UUID StartClassifiedSearch(string searchText, ClassifiedCategories categories, bool mature)
|
||||
// Obsoleted due to new Adult search option
|
||||
[Obsolete("Use Overload with ClassifiedQueryFlags option instead")]
|
||||
public UUID StartClassifiedSearch(string searchText, ClassifiedCategories category, bool mature)
|
||||
{
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query the data server for a list of classified ads containing the specified string.
|
||||
/// Defaults to searching for classified placed in any category, and includes PG, Adult and Mature
|
||||
/// results.
|
||||
///
|
||||
/// Responses are sent 16 at a time, there is no way to know how many results a query reply will contain however assuming
|
||||
/// the reply packets arrived ordered, a response with less than 16 entries would indicate all results have been received
|
||||
/// </summary>
|
||||
/// <param name="searchText">A string containing a list of keywords to search for</param>
|
||||
/// <returns>A UUID to correlate the results when the <see cref="OnClassifiedReply"/> event is raised</returns>
|
||||
public UUID StartClassifiedSearch(string searchText)
|
||||
{
|
||||
return StartClassifiedSearch(searchText, ClassifiedCategories.Any, ClassifiedQueryFlags.All);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query the data server for a list of classified ads which contain specified keywords (Overload)
|
||||
/// </summary>
|
||||
/// <param name="searchText">A string containing a list of keywords to search for</param>
|
||||
/// <param name="category">The category to search</param>
|
||||
/// <param name="queryFlags">A set of flags which can be ORed to modify query options
|
||||
/// such as classified maturity rating.</param>
|
||||
/// <returns>A UUID to correlate the results when the <see cref="OnClassifiedReply"/> event is raised</returns>
|
||||
/// <example>
|
||||
/// Search classified ads containing the key words "foo" and "bar" in the "Any" category that are either PG or Mature
|
||||
/// <code>
|
||||
/// UUID searchID = StartClassifiedSearch("foo bar", ClassifiedCategories.Any, ClassifiedQueryFlags.PG | ClassifiedQueryFlags.Mature);
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <remarks>
|
||||
/// Responses are sent 16 at a time, there is no way to know how many results a query reply will contain however assuming
|
||||
/// the reply packets arrived ordered, a response with less than 16 entries would indicate all results have been received
|
||||
/// </remarks>
|
||||
public UUID StartClassifiedSearch(string searchText, ClassifiedCategories category, ClassifiedQueryFlags queryFlags)
|
||||
{
|
||||
DirClassifiedQueryPacket query = new DirClassifiedQueryPacket();
|
||||
UUID queryID = UUID.Random();
|
||||
|
||||
query.AgentData.AgentID = Client.Self.AgentID;
|
||||
query.AgentData.SessionID = Client.Self.SessionID;
|
||||
query.QueryData.Category = (uint)categories;
|
||||
query.QueryData.QueryFlags = (uint)(mature ? 0 : 2);
|
||||
|
||||
query.QueryData.Category = (uint)category;
|
||||
query.QueryData.QueryFlags = (uint)queryFlags;
|
||||
query.QueryData.QueryID = queryID;
|
||||
query.QueryData.QueryText = Utils.StringToBytes(searchText);
|
||||
|
||||
@@ -474,7 +573,7 @@ namespace OpenMetaverse
|
||||
/// each query.</remarks>
|
||||
public UUID StartLandSearch(SearchTypeFlags typeFlags)
|
||||
{
|
||||
return StartLandSearch(DirFindFlags.SortAsc | DirFindFlags.PerMeterSort, typeFlags, 0, 0, 0);
|
||||
return StartLandSearch(DirFindFlags.SortAsc | DirFindFlags.PerMeterSort, typeFlags, 0, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -541,6 +640,7 @@ namespace OpenMetaverse
|
||||
|
||||
return queryID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a search for a Group in the directory manager
|
||||
/// </summary>
|
||||
@@ -561,6 +661,14 @@ namespace OpenMetaverse
|
||||
return StartGroupSearch(findFlags, searchText, queryStart, UUID.Random());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search for groups
|
||||
/// </summary>
|
||||
/// <param name="findFlags"></param>
|
||||
/// <param name="searchText"></param>
|
||||
/// <param name="queryStart"></param>
|
||||
/// <param name="queryID"></param>
|
||||
/// <returns></returns>
|
||||
public UUID StartGroupSearch(DirFindFlags findFlags, string searchText, int queryStart, UUID queryID)
|
||||
{
|
||||
DirFindQueryPacket find = new DirFindQueryPacket();
|
||||
@@ -574,11 +682,26 @@ namespace OpenMetaverse
|
||||
return queryID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search the people directory for other avatars
|
||||
/// </summary>
|
||||
/// <param name="findFlags"></param>
|
||||
/// <param name="searchText"></param>
|
||||
/// <param name="queryStart"></param>
|
||||
/// <returns></returns>
|
||||
public UUID StartPeopleSearch(DirFindFlags findFlags, string searchText, int queryStart)
|
||||
{
|
||||
return StartPeopleSearch(findFlags, searchText, queryStart, UUID.Random());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="findFlags"></param>
|
||||
/// <param name="searchText"></param>
|
||||
/// <param name="queryStart"></param>
|
||||
/// <param name="queryID"></param>
|
||||
/// <returns></returns>
|
||||
public UUID StartPeopleSearch(DirFindFlags findFlags, string searchText, int queryStart, UUID queryID)
|
||||
{
|
||||
DirFindQueryPacket find = new DirFindQueryPacket();
|
||||
@@ -595,7 +718,7 @@ namespace OpenMetaverse
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search "places" for Land you personally own
|
||||
/// Search "places" for parcels of land you personally own
|
||||
/// </summary>
|
||||
public UUID StartPlacesSearch()
|
||||
{
|
||||
@@ -764,7 +887,7 @@ namespace OpenMetaverse
|
||||
|
||||
classified.CreationDate = Utils.UnixTimeToDateTime(block.CreationDate);
|
||||
classified.ExpirationDate = Utils.UnixTimeToDateTime(block.ExpirationDate);
|
||||
classified.Flags = block.ClassifiedFlags;
|
||||
classified.Flags = (ClassifiedFlags)block.ClassifiedFlags;
|
||||
classified.ID = block.ClassifiedID;
|
||||
classified.Name = Utils.BytesToString(block.Name);
|
||||
classified.Price = block.PriceForListing;
|
||||
|
||||
@@ -115,10 +115,13 @@ namespace OpenMetaverse.Packets
|
||||
AddCallback("TransferInfo.TargetType", DecodeTransferTargetType);
|
||||
AddCallback("TransferData.ChannelType", DecodeTransferChannelType);
|
||||
// Directory Manager
|
||||
AddCallback("DirClassifiedQuery.QueryData.QueryFlags", DecodeDirClassifiedQueryFlags);
|
||||
AddCallback("QueryData.QueryFlags", DecodeDirQueryFlags);
|
||||
AddCallback("Category", DecodeCategory);
|
||||
AddCallback("QueryData.SearchType", SearchTypeFlags);
|
||||
|
||||
AddCallback("ClassifiedFlags", DecodeDirClassifiedFlags);
|
||||
|
||||
AddCallback("ParcelAccessListRequest.Data.Flags", DecodeParcelACL);
|
||||
AddCallback("ParcelAccessListReply.Data.Flags", DecodeParcelACL);
|
||||
//AddCallback("ParcelAccessListReply.List.Flags", DecodeParcelACLReply);
|
||||
@@ -845,6 +848,22 @@ namespace OpenMetaverse.Packets
|
||||
"(" + (DirectoryManager.DirFindFlags)(uint)fieldData + ")");
|
||||
}
|
||||
|
||||
private static string DecodeDirClassifiedQueryFlags(string fieldName, object fieldData)
|
||||
{
|
||||
return String.Format("{0,30}: {1,-10} {2,-29} [ClassifiedQueryFlags]",
|
||||
fieldName,
|
||||
fieldData,
|
||||
"(" + (DirectoryManager.ClassifiedQueryFlags)(uint)fieldData + ")");
|
||||
}
|
||||
|
||||
private static string DecodeDirClassifiedFlags(string fieldName, object fieldData)
|
||||
{
|
||||
return String.Format("{0,30}: {1,-10} {2,-29} [ClassifiedFlags]",
|
||||
fieldName,
|
||||
fieldData,
|
||||
"(" + (DirectoryManager.ClassifiedFlags)(byte)fieldData + ")");
|
||||
}
|
||||
|
||||
private static string DecodeParcelACL(string fieldName, object fieldData)
|
||||
{
|
||||
return String.Format("{0,30}: {1,-10} {2,-29} [AccessList]",
|
||||
|
||||
@@ -117,34 +117,34 @@ namespace OpenMetaverse
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// The tool to use when modifying terrain levels
|
||||
/// </summary>
|
||||
public enum TerraformAction : byte
|
||||
{
|
||||
/// <summary></summary>
|
||||
/// <summary>Level the terrain</summary>
|
||||
Level = 0,
|
||||
/// <summary></summary>
|
||||
/// <summary>Raise the terrain</summary>
|
||||
Raise = 1,
|
||||
/// <summary></summary>
|
||||
/// <summary>Lower the terrain</summary>
|
||||
Lower = 2,
|
||||
/// <summary></summary>
|
||||
/// <summary>Smooth the terrain</summary>
|
||||
Smooth = 3,
|
||||
/// <summary></summary>
|
||||
/// <summary>Add random noise to the terrain</summary>
|
||||
Noise = 4,
|
||||
/// <summary></summary>
|
||||
/// <summary>Revert terrain to simulator default</summary>
|
||||
Revert = 5
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// The tool size to use when changing terrain levels
|
||||
/// </summary>
|
||||
public enum TerraformBrushSize : byte
|
||||
{
|
||||
/// <summary></summary>
|
||||
/// <summary>Small</summary>
|
||||
Small = 1,
|
||||
/// <summary></summary>
|
||||
/// <summary>Medium</summary>
|
||||
Medium = 2,
|
||||
/// <summary></summary>
|
||||
/// <summary>Large</summary>
|
||||
Large = 4
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@ namespace OpenMetaverse
|
||||
/// the BorderWest and BorderSouth values are bit flags that get attached
|
||||
/// to the value stored in the first three bits. Bits four, five, and six
|
||||
/// are unused</remarks>
|
||||
[Flags]
|
||||
public enum ParcelOverlayType : byte
|
||||
{
|
||||
/// <summary>Public land</summary>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenMetaverse.TestClient.Commands
|
||||
{
|
||||
class SearchClassifiedsCommand : Command
|
||||
{
|
||||
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
||||
int resultCount;
|
||||
|
||||
public SearchClassifiedsCommand(TestClient testClient)
|
||||
{
|
||||
Name = "searchclassifieds";
|
||||
Description = "Searches Classified Ads. Usage: searchclassifieds [search text]";
|
||||
Category = CommandCategory.Other;
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return "Usage: searchclassifieds [search text]";
|
||||
|
||||
string searchText = string.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
searchText += args[i] + " ";
|
||||
searchText = searchText.TrimEnd();
|
||||
waitQuery.Reset();
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
DirectoryManager.ClassifiedReplyCallback callback = delegate(List<DirectoryManager.Classified> classifieds)
|
||||
{
|
||||
result.AppendFormat("Your search string '{0}' returned {1} classified ads" + System.Environment.NewLine,
|
||||
searchText, classifieds.Count);
|
||||
foreach (DirectoryManager.Classified ad in classifieds)
|
||||
{
|
||||
result.AppendLine(ad.ToString());
|
||||
}
|
||||
|
||||
// classifieds are sent 16 ads at a time
|
||||
if (classifieds.Count < 16)
|
||||
{
|
||||
waitQuery.Set();
|
||||
}
|
||||
};
|
||||
|
||||
Client.Directory.OnClassifiedReply += callback;
|
||||
|
||||
UUID searchID = Client.Directory.StartClassifiedSearch(searchText, DirectoryManager.ClassifiedCategories.Any, DirectoryManager.ClassifiedQueryFlags.Mature | DirectoryManager.ClassifiedQueryFlags.PG);
|
||||
|
||||
if (!waitQuery.WaitOne(20000, false) && Client.Network.Connected)
|
||||
{
|
||||
result.AppendLine("Timeout waiting for simulator to respond to query.");
|
||||
}
|
||||
|
||||
Client.Directory.OnClassifiedReply -= callback;
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user