2007-03-09 20:26:07 +00:00
/ *
2008-07-21 21:12:59 +00:00
* Copyright ( c ) 2006 - 2008 , openmetaverse . org
2007-03-09 20:26:07 +00:00
* All rights reserved .
*
* - Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions are met :
*
* - Redistributions of source code must retain the above copyright notice , this
* list of conditions and the following disclaimer .
2008-07-21 21:12:59 +00:00
* - Neither the name of the openmetaverse . org nor the names
2007-03-09 20:26:07 +00:00
* of its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR
* CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS
* INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN
* CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE )
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE .
* /
using System ;
using System.Collections.Generic ;
using System.Threading ;
2008-07-21 21:12:59 +00:00
using OpenMetaverse.Packets ;
2009-05-09 22:46:38 +00:00
using OpenMetaverse.Interfaces ;
using OpenMetaverse.Messages.Linden ;
2007-03-09 20:26:07 +00:00
2008-07-21 21:12:59 +00:00
namespace OpenMetaverse
2007-03-09 20:26:07 +00:00
{
/// <summary>
2009-10-07 20:13:33 +00:00
/// Access to the dataserver which allows searching for land, events, people, etc
2007-03-09 20:26:07 +00:00
/// </summary>
public class DirectoryManager
{
/// <summary>
/// The different categories a classified ad can be placed in
/// </summary>
public enum ClassifiedCategories
{
2009-10-07 20:13:33 +00:00
/// <summary>Classified is listed in the Any category</summary>
2007-03-09 20:26:07 +00:00
Any = 0 ,
2009-10-07 20:13:33 +00:00
/// <summary>Classified is shopping related</summary>
2007-03-09 20:26:07 +00:00
Shopping ,
2009-10-07 20:13:33 +00:00
/// <summary>Classified is </summary>
2007-03-09 20:26:07 +00:00
LandRental ,
/// <summary></summary>
PropertyRental ,
/// <summary></summary>
SpecialAttraction ,
/// <summary></summary>
NewProducts ,
/// <summary></summary>
Employment ,
/// <summary></summary>
Wanted ,
/// <summary></summary>
Service ,
/// <summary></summary>
Personal
}
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
public enum EventCategories
{
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
All = 0 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Discussion = 18 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Sports = 19 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
LiveMusic = 20 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Commercial = 22 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Nightlife = 23 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Games = 24 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Pageants = 25 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Education = 26 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Arts = 27 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Charity = 28 ,
2009-10-07 20:13:33 +00:00
/// <summary></summary>
2008-01-01 00:29:51 +00:00
Miscellaneous = 29
}
2009-10-08 02:56:37 +00:00
// I can be deleted as soon as the flags for DirLandQuery can be verified to not use
// the below listed combinations. e.g: PgSimsOnly *should not* be necessary any longer as it looks redundant
// -- Jim
//
// <summary>
// Modifier flags sent to DirectoryManager to change the behavior of the
// query
// </summary>
// Land Search Flags required in addition to specify land maturity rating:
// <example>
// <code>PgSimsOnly | SortAsc | PerMeterSort | IncludePG | IncludeAdult</code>
// would sort the results ascending, sort by sale price/m2, Include only Adult and PG Land
// in the search results.
// </example>
// <list type="table">
// <listheader><term>Desired Query</term><description>Required Flags</description></listheader>
// <item><term>PG</term><description>PgSimsOnly | IncludePG</description></item>
// <item><term>PG+Mature</term><description>IncludePG | IncludeMature</description></item>
// <item><term>PG+Mature+Adult</term><description>IncludePG | IncludeMature | IncludeAdult</description></item>
// <item><term>Mature+Adult</term><description>MatureSimsOnly | IncludeMature | IncludeAdult</description></item>
// <item><term>Adult</term><description>IncludeAdult</description></item>
// <item><term>Mature</term><description>MatureSimsOnly | IncludeMature</description></item>
// <item><term>PG+Adult</term><description>PgSimsOnly | IncludePG | IncludeAdult</description></item>
// </list>
2007-03-09 20:26:07 +00:00
/// <summary>
2009-10-08 02:56:37 +00:00
/// Query Flags used in many of the DirectoryManager methods to specify which query to execute and how to return the results.
///
/// Flags can be combined using the | (pipe) character
2007-03-09 20:26:07 +00:00
/// </summary>
[Flags]
public enum DirFindFlags
{
2009-10-08 02:56:37 +00:00
/// <summary>Query the People database</summary>
2007-03-09 20:26:07 +00:00
People = 1 < < 0 ,
/// <summary></summary>
Online = 1 < < 1 ,
2008-07-30 06:51:51 +00:00
// <summary></summary>
2008-07-21 18:56:11 +00:00
//[Obsolete]
//Places = 1 << 2,
2007-03-09 20:26:07 +00:00
/// <summary></summary>
Events = 1 < < 3 ,
/// <summary></summary>
Groups = 1 < < 4 ,
2009-10-08 02:56:37 +00:00
/// <summary>Query the Events database</summary>
2007-03-09 20:26:07 +00:00
DateEvents = 1 < < 5 ,
2009-10-08 02:56:37 +00:00
/// <summary>Query the land holdings database for land owned by the currently connected agent</summary>
2007-03-09 20:26:07 +00:00
AgentOwned = 1 < < 6 ,
/// <summary></summary>
ForSale = 1 < < 7 ,
2009-10-08 02:56:37 +00:00
/// <summary>Query the land holdings database for land which is owned by a Group</summary>
2007-03-09 20:26:07 +00:00
GroupOwned = 1 < < 8 ,
2008-07-30 06:51:51 +00:00
// <summary></summary>
2008-07-21 18:56:11 +00:00
//[Obsolete]
//Auction = 1 << 9,
2009-10-08 02:56:37 +00:00
/// <summary>Specifies the query should pre sort the results based upon traffic
/// when searching the Places database</summary>
2007-03-09 20:26:07 +00:00
DwellSort = 1 < < 10 ,
/// <summary></summary>
PgSimsOnly = 1 < < 11 ,
/// <summary></summary>
PicturesOnly = 1 < < 12 ,
/// <summary></summary>
PgEventsOnly = 1 < < 13 ,
/// <summary></summary>
MatureSimsOnly = 1 < < 14 ,
2009-10-08 02:56:37 +00:00
/// <summary>Specifies the query should pre sort the results in an ascending order when searching the land sales database.
/// This flag is only used when searching the land sales database</summary>
2007-03-09 20:26:07 +00:00
SortAsc = 1 < < 15 ,
2009-10-08 02:56:37 +00:00
/// <summary>Specifies the query should pre sort the results using the SalePrice field when searching the land sales database.
/// This flag is only used when searching the land sales database</summary>
2007-03-09 20:26:07 +00:00
PricesSort = 1 < < 16 ,
2009-10-08 02:56:37 +00:00
/// <summary>Specifies the query should pre sort the results by calculating the average price/sq.m (SalePrice / Area) when searching the land sales database.
/// This flag is only used when searching the land sales database</summary>
2007-03-09 20:26:07 +00:00
PerMeterSort = 1 < < 17 ,
2009-10-08 02:56:37 +00:00
/// <summary>Specifies the query should pre sort the results using the ParcelSize field when searching the land sales database.
/// This flag is only used when searching the land sales database</summary>
2007-03-09 20:26:07 +00:00
AreaSort = 1 < < 18 ,
2009-10-08 02:56:37 +00:00
/// <summary>Specifies the query should pre sort the results using the Name field when searching the land sales database.
/// This flag is only used when searching the land sales database</summary>
2007-03-09 20:26:07 +00:00
NameSort = 1 < < 19 ,
2009-10-08 02:56:37 +00:00
/// <summary>When set, only parcels less than the specified Price will be included when searching the land sales database.
/// This flag is only used when searching the land sales database</summary>
2007-03-09 20:26:07 +00:00
LimitByPrice = 1 < < 20 ,
2009-10-08 02:56:37 +00:00
/// <summary>When set, only parcels greater than the specified Size will be included when searching the land sales database.
/// This flag is only used when searching the land sales database</summary>
2009-10-05 21:56:55 +00:00
LimitByArea = 1 < < 21 ,
/// <summary></summary>
FilterMature = 1 < < 22 ,
/// <summary></summary>
PGOnly = 1 < < 23 ,
2009-10-08 02:56:37 +00:00
/// <summary>Include PG land in results. This flag is used when searching both the Events and Land sales databases</summary>
2009-10-05 21:56:55 +00:00
IncludePG = 1 < < 24 ,
2009-10-08 02:56:37 +00:00
/// <summary>Include Mature land in results. This flag is used when searching both the Events and Land sales databases</summary>
2009-10-05 21:56:55 +00:00
IncludeMature = 1 < < 25 ,
2009-10-08 02:56:37 +00:00
/// <summary>Include Adult land in results. This flag is used when searching both the Events and Land sales databases</summary>
2009-10-05 21:56:55 +00:00
IncludeAdult = 1 < < 26 ,
/// <summary></summary>
AdultOnly = 1 < < 27
2007-03-09 20:26:07 +00:00
}
/// <summary>
2008-03-14 07:11:13 +00:00
/// Land types to search dataserver for
2007-03-09 20:26:07 +00:00
/// </summary>
[Flags]
public enum SearchTypeFlags
{
2009-10-05 21:56:55 +00:00
/// <summary>Search Auction, Mainland and Estate</summary>
Any = - 1 ,
2008-03-14 07:11:13 +00:00
/// <summary>Do not search</summary>
2007-03-09 20:26:07 +00:00
None = 0 ,
2008-03-14 07:11:13 +00:00
/// <summary>Land which is currently up for auction</summary>
2007-03-09 20:26:07 +00:00
Auction = 1 < < 1 ,
2008-07-30 06:51:51 +00:00
// <summary>Land available to new landowners (formerly the FirstLand program)</summary>
2008-07-21 18:56:11 +00:00
//[Obsolete]
//Newbie = 1 << 2,
2008-03-14 07:11:13 +00:00
/// <summary>Parcels which are on the mainland (Linden owned) continents</summary>
2007-03-09 20:26:07 +00:00
Mainland = 1 < < 3 ,
2008-03-14 07:11:13 +00:00
/// <summary>Parcels which are on privately owned simulators</summary>
2007-03-09 20:26:07 +00:00
Estate = 1 < < 4
}
2008-01-01 00:29:51 +00:00
2009-10-08 02:56:37 +00:00
/// <summary>
/// The content rating of the event
/// </summary>
2008-01-01 00:29:51 +00:00
public enum EventFlags
{
2009-10-08 02:56:37 +00:00
/// <summary>Event is PG</summary>
PG = 0 ,
/// <summary>Event is Mature</summary>
Mature = 1 ,
/// <summary>Event is Adult</summary>
Adult = 2
2008-01-01 00:29:51 +00:00
}
2007-03-09 20:26:07 +00:00
/// <summary>
2008-07-21 21:12:59 +00:00
/// A classified ad on the grid
2007-03-09 20:26:07 +00:00
/// </summary>
public struct Classified
{
/// <summary>UUID for this ad, useful for looking up detailed
/// information about it</summary>
2008-07-25 05:15:05 +00:00
public UUID ID ;
2007-03-09 20:26:07 +00:00
/// <summary>The title of this classified ad</summary>
public string Name ;
2009-10-07 20:13:33 +00:00
/// <summary>Flags that show certain options applied to the classified</summary>
public ClassifiedFlags Flags ;
2007-03-09 20:26:07 +00:00
/// <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 ;
2009-10-07 20:13:33 +00:00
/// <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 ,
2007-03-09 20:26:07 +00:00
}
/// <summary>
/// A parcel retrieved from the dataserver such as results from the
2009-10-08 02:56:37 +00:00
/// "For-Sale" listings or "Places" Search
2007-03-09 20:26:07 +00:00
/// </summary>
public struct DirectoryParcel
{
2009-10-08 02:56:37 +00:00
/// <summary>The unique dataserver parcel ID</summary>
/// <remarks>This id is used to obtain additional information from the entry
/// by using the <see cref="ParcelManager.InfoRequest"/> method</remarks>
2008-07-25 05:15:05 +00:00
public UUID ID ;
2009-10-08 02:56:37 +00:00
/// <summary>A string containing the name of the parcel</summary>
2007-03-09 20:26:07 +00:00
public string Name ;
2009-10-08 02:56:37 +00:00
/// <summary>The size of the parcel</summary>
/// <remarks>This field is not returned for Places searches</remarks>
2007-03-09 20:26:07 +00:00
public int ActualArea ;
2009-10-08 02:56:37 +00:00
/// <summary>The price of the parcel</summary>
/// <remarks>This field is not returned for Places searches</remarks>
2007-03-09 20:26:07 +00:00
public int SalePrice ;
2009-10-08 02:56:37 +00:00
/// <summary>If True, this parcel is flagged to be auctioned</summary>
2007-03-09 20:26:07 +00:00
public bool Auction ;
2009-10-08 02:56:37 +00:00
/// <summary>If true, this parcel is currently set for sale</summary>
2007-03-09 20:26:07 +00:00
public bool ForSale ;
2009-08-24 14:23:02 +00:00
/// <summary>Parcel traffic</summary>
public float Dwell ;
2009-10-08 02:56:37 +00:00
/// <summary>
/// Display an entry in a one line human readable format
/// </summary>
/// <returns>A string representing a single parcel entry</returns>
public override string ToString ( )
{
return String . Format ( "Parcel ID: {0}, Name: {1}, Area: {2}, Price: {3}, IsAuction: {4}, IsForSale: {5}, Dwell: {6}" + System . Environment . NewLine ,
this . ID , this . Name , this . ActualArea , this . SalePrice , this . Auction , this . ForSale , this . Dwell ) ;
}
2007-03-09 20:26:07 +00:00
}
2008-03-14 07:11:13 +00:00
/// <summary>
/// An Avatar returned from the dataserver
/// </summary>
2009-08-24 14:23:02 +00:00
public struct AgentSearchData
2007-08-20 20:38:36 +00:00
{
2008-03-14 07:11:13 +00:00
/// <summary>Online status of agent</summary>
2007-04-23 01:39:14 +00:00
public bool Online ;
2008-03-14 07:11:13 +00:00
/// <summary>Agents first name</summary>
2007-04-23 01:39:14 +00:00
public string FirstName ;
2008-03-14 07:11:13 +00:00
/// <summary>Agents last name</summary>
2007-04-23 01:39:14 +00:00
public string LastName ;
2009-10-07 20:13:33 +00:00
/// <summary>Agents <see cref="UUID"/></summary>
2008-07-25 05:15:05 +00:00
public UUID AgentID ;
2007-04-23 01:39:14 +00:00
}
2009-10-07 20:13:33 +00:00
2007-08-16 19:41:30 +00:00
/// <summary>
/// Response to a "Groups" Search
/// </summary>
public struct GroupSearchData
{
2008-07-25 05:15:05 +00:00
public UUID GroupID ;
2007-08-16 19:41:30 +00:00
public string GroupName ;
public int Members ;
}
2007-08-20 20:38:36 +00:00
/// <summary>
2009-05-09 22:46:38 +00:00
/// Response to a "Places" Search, e.g. My Land, Group Land, etc.
2007-08-20 20:38:36 +00:00
/// Note: This is not DirPlacesReply
/// </summary>
public struct PlacesSearchData
{
2008-07-25 05:15:05 +00:00
public UUID OwnerID ;
2007-08-20 20:38:36 +00:00
public string Name ;
public string Desc ;
public int ActualArea ;
public int BillableArea ;
public byte Flags ;
public float GlobalX ;
public float GlobalY ;
public float GlobalZ ;
public string SimName ;
2008-07-25 05:15:05 +00:00
public UUID SnapshotID ;
2007-08-20 20:38:36 +00:00
public float Dwell ;
2009-08-24 14:23:02 +00:00
public int Price ;
2007-08-20 20:38:36 +00:00
}
2008-01-01 00:29:51 +00:00
/// <summary>
/// Response to "Events" search
/// </summary>
public struct EventsSearchData
{
2008-07-25 05:15:05 +00:00
public UUID Owner ;
2008-01-01 00:29:51 +00:00
public string Name ;
public uint ID ;
public string Date ;
public uint Time ;
public EventFlags Flags ;
}
2007-03-09 20:26:07 +00:00
2008-01-01 00:29:51 +00:00
/// <summary>
/// an Event returned from the dataserver
/// </summary>
public struct EventInfo
{
2009-08-24 14:23:02 +00:00
public uint ID ;
public UUID Creator ;
2008-01-01 00:29:51 +00:00
public string Name ;
public EventCategories Category ;
public string Desc ;
public string Date ;
public UInt32 DateUTC ;
public UInt32 Duration ;
public UInt32 Cover ;
public UInt32 Amount ;
public string SimName ;
2008-07-25 05:15:05 +00:00
public Vector3d GlobalPos ;
2008-01-01 00:29:51 +00:00
public EventFlags Flags ;
}
2007-03-09 20:26:07 +00:00
/// <summary>
///
/// </summary>
/// <param name="classifieds"></param>
public delegate void ClassifiedReplyCallback ( List < Classified > classifieds ) ;
/// <summary>
///
/// </summary>
/// <param name="dirParcels"></param>
public delegate void DirLandReplyCallback ( List < DirectoryParcel > dirParcels ) ;
2007-04-23 01:39:14 +00:00
/// <summary>
///
/// </summary>
2008-05-01 10:48:09 +00:00
/// <param name="queryID"></param>
2007-04-23 01:39:14 +00:00
/// <param name="matchedPeople"></param>
2008-07-25 05:15:05 +00:00
public delegate void DirPeopleReplyCallback ( UUID queryID , List < AgentSearchData > matchedPeople ) ;
2007-03-09 20:26:07 +00:00
2007-08-16 19:41:30 +00:00
/// <summary>
///
/// </summary>
/// <param name="queryID"></param>
/// <param name="matchedGroups"></param>
2008-07-25 05:15:05 +00:00
public delegate void DirGroupsReplyCallback ( UUID queryID , List < GroupSearchData > matchedGroups ) ;
2007-08-20 20:38:36 +00:00
2009-08-24 14:23:02 +00:00
/// <summary>
/// Passes results of search -> places
/// </summary>
/// <param name="queryID">UUID of this request</param>
/// <param name="matchedParcels">List of parcels found in search</param>
public delegate void DirPlacesReplyCallback ( UUID queryID , List < DirectoryParcel > matchedParcels ) ;
2007-08-20 20:38:36 +00:00
/// <summary>
///
/// </summary>
/// <param name="queryID"></param>
/// <param name="matchedPlaces"></param>
2008-07-25 05:15:05 +00:00
public delegate void PlacesReplyCallback ( UUID queryID , List < PlacesSearchData > matchedPlaces ) ;
2007-08-20 20:38:36 +00:00
2008-01-01 00:29:51 +00:00
/// <summary>
///
/// </summary>
/// <param name="queryID"></param>
/// <param name="matchedEvents"></param>
2008-07-25 05:15:05 +00:00
public delegate void EventReplyCallback ( UUID queryID , List < EventsSearchData > matchedEvents ) ;
2008-01-01 00:29:51 +00:00
/// <summary>
///
/// </summary>
/// <param name="matchedEvent"></param>
public delegate void EventInfoCallback ( EventInfo matchedEvent ) ;
2007-03-09 20:26:07 +00:00
/// <summary>
///
/// </summary>
public event ClassifiedReplyCallback OnClassifiedReply ;
/// <summary>
///
/// </summary>
public event DirLandReplyCallback OnDirLandReply ;
2007-04-23 01:39:14 +00:00
public event DirPeopleReplyCallback OnDirPeopleReply ;
2007-03-09 20:26:07 +00:00
2007-08-16 19:41:30 +00:00
public event DirGroupsReplyCallback OnDirGroupsReply ;
2009-08-24 14:23:02 +00:00
/// <summary>
/// When we have result of search->places
/// </summary>
public event DirPlacesReplyCallback OnDirPlacesReply ;
2007-08-20 20:38:36 +00:00
public event PlacesReplyCallback OnPlacesReply ;
2008-01-01 00:29:51 +00:00
// List of Events
public event EventReplyCallback OnEventsReply ;
// Event Details
public event EventInfoCallback OnEventInfo ;
2008-07-21 21:12:59 +00:00
private GridClient Client ;
2007-03-09 20:26:07 +00:00
2009-10-07 20:13:33 +00:00
/// <summary>
/// Constructs a new instance of the DirectoryManager class
/// </summary>
/// <param name="client">An instance of GridClient</param>
2008-07-21 21:12:59 +00:00
public DirectoryManager ( GridClient client )
2007-03-09 20:26:07 +00:00
{
Client = client ;
2009-10-08 02:56:37 +00:00
2007-03-09 20:26:07 +00:00
Client . Network . RegisterCallback ( PacketType . DirClassifiedReply , new NetworkManager . PacketCallback ( DirClassifiedReplyHandler ) ) ;
2009-10-08 02:56:37 +00:00
// Deprecated, replies come in over capabilities
2007-03-09 20:26:07 +00:00
Client . Network . RegisterCallback ( PacketType . DirLandReply , new NetworkManager . PacketCallback ( DirLandReplyHandler ) ) ;
2009-09-27 20:19:45 +00:00
Client . Network . RegisterEventCallback ( "DirLandReply" , DirLandReplyEventHandler ) ;
2007-04-23 01:39:14 +00:00
Client . Network . RegisterCallback ( PacketType . DirPeopleReply , new NetworkManager . PacketCallback ( DirPeopleReplyHandler ) ) ;
2007-08-16 19:41:30 +00:00
Client . Network . RegisterCallback ( PacketType . DirGroupsReply , new NetworkManager . PacketCallback ( DirGroupsReplyHandler ) ) ;
2009-05-09 22:46:38 +00:00
// Deprecated as of viewer 1.2.3
2007-08-20 20:38:36 +00:00
Client . Network . RegisterCallback ( PacketType . PlacesReply , new NetworkManager . PacketCallback ( PlacesReplyHandler ) ) ;
2009-05-09 22:46:38 +00:00
Client . Network . RegisterEventCallback ( "PlacesReply" , PlacesReplyEventHandler ) ;
2008-01-01 00:29:51 +00:00
Client . Network . RegisterCallback ( PacketType . DirEventsReply , new NetworkManager . PacketCallback ( EventsReplyHandler ) ) ;
2009-08-24 14:23:02 +00:00
Client . Network . RegisterCallback ( PacketType . EventInfoReply , new NetworkManager . PacketCallback ( EventInfoReplyHandler ) ) ;
Client . Network . RegisterCallback ( PacketType . DirPlacesReply , new NetworkManager . PacketCallback ( DirPlacesReplyHandler ) ) ;
2009-10-07 20:13:33 +00:00
}
2007-04-23 01:39:14 +00:00
2009-10-07 20:13:33 +00:00
// 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 ;
2007-03-09 20:26:07 +00:00
}
2009-10-07 20:13:33 +00:00
/// <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.
///
2009-10-08 02:56:37 +00:00
/// Responses are sent 16 per response packet, there is no way to know how many results a query reply will contain however assuming
2009-10-07 20:13:33 +00:00
/// the reply packets arrived ordered, a response with less than 16 entries would indicate all results have been received
2009-10-08 02:56:37 +00:00
///
/// The <see cref="OnClassifiedReply"/> event is raised when a response is received from the simulator
2009-10-07 20:13:33 +00:00
/// </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 )
2007-03-09 20:26:07 +00:00
{
2009-10-07 20:13:33 +00:00
return StartClassifiedSearch ( searchText , ClassifiedCategories . Any , ClassifiedQueryFlags . All ) ;
}
/// <summary>
/// Query the data server for a list of classified ads which contain specified keywords (Overload)
2009-10-08 02:56:37 +00:00
///
/// The <see cref="OnClassifiedReply"/> event is raised when a response is received from the simulator
2009-10-07 20:13:33 +00:00
/// </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 )
{
2007-03-09 20:26:07 +00:00
DirClassifiedQueryPacket query = new DirClassifiedQueryPacket ( ) ;
2008-07-25 05:15:05 +00:00
UUID queryID = UUID . Random ( ) ;
2007-03-09 20:26:07 +00:00
2007-11-06 09:26:10 +00:00
query . AgentData . AgentID = Client . Self . AgentID ;
query . AgentData . SessionID = Client . Self . SessionID ;
2009-10-07 20:13:33 +00:00
query . QueryData . Category = ( uint ) category ;
query . QueryData . QueryFlags = ( uint ) queryFlags ;
2007-03-09 20:26:07 +00:00
query . QueryData . QueryID = queryID ;
2008-08-12 22:38:02 +00:00
query . QueryData . QueryText = Utils . StringToBytes ( searchText ) ;
2007-03-09 20:26:07 +00:00
Client . Network . SendPacket ( query ) ;
return queryID ;
}
2009-08-24 14:23:02 +00:00
/// <summary>
2009-10-08 02:56:37 +00:00
/// Starts search for places (Overloaded)
///
/// The <see cref="OnDirPlacesReply"/> event is raised when a response is received from the simulator
2009-08-24 14:23:02 +00:00
/// </summary>
/// <param name="searchText">Search text</param>
/// <param name="startAtResult">Start result (we get 100 results at a time, so we start with 0, then 100, etc).</param>
2009-10-08 02:56:37 +00:00
/// <returns>A UUID to correlate the results when the <see cref="OnDirPlacesReply"/> event is raised</returns>
public UUID StartDirPlacesSearch ( string searchText , int queryStart )
2009-08-24 14:23:02 +00:00
{
2009-10-08 02:56:37 +00:00
return StartDirPlacesSearch ( searchText , DirFindFlags . DwellSort | DirFindFlags . IncludePG | DirFindFlags . IncludeMature
| DirFindFlags . IncludeAdult , ParcelCategory . Any , queryStart ) ;
}
/// <summary>
/// Queries the dataserver for parcels of land which are flagged to be shown in search
///
/// The <see cref="OnDirPlacesReply"/> event is raised when a response is received from the simulator
/// </summary>
/// <param name="searchText">A string containing a list of keywords to search for separated by a space character</param>
/// <param name="queryFlags">A set of flags which can be ORed to modify query options
/// such as classified maturity rating.</param>
/// <param name="category">The category to search</param>
/// <param name="queryStart">Each request is limited to 100 places
/// being returned. To get the first 100 result entries of a request use 0,
/// from 100-199 use 1, 200-299 use 2, etc.</param>
/// <returns>A UUID to correlate the results when the <see cref="OnDirPlacesReply"/> event is raised</returns>
/// <example>
/// Search places containing the key words "foo" and "bar" in the "Any" category that are either PG or Adult
/// <code>
/// UUID searchID = StartDirPlacesSearch("foo bar", DirFindFlags.DwellSort | DirFindFlags.IncludePG | DirFindFlags.IncludeAdult, ParcelCategory.Any, 0);
/// </code>
/// </example>
/// <remarks>
/// Additional information on the results can be obtained by using the ParcelManager.InfoRequest method
/// </remarks>
public UUID StartDirPlacesSearch ( string searchText , DirFindFlags queryFlags , ParcelCategory category , int queryStart )
{
2009-08-24 14:23:02 +00:00
DirPlacesQueryPacket query = new DirPlacesQueryPacket ( ) ;
2009-10-08 02:56:37 +00:00
UUID queryID = UUID . Random ( ) ;
2009-08-24 14:23:02 +00:00
query . AgentData . AgentID = Client . Self . AgentID ;
query . AgentData . SessionID = Client . Self . SessionID ;
2009-10-08 02:56:37 +00:00
query . QueryData . Category = ( sbyte ) category ;
query . QueryData . QueryFlags = ( uint ) queryFlags ;
2009-08-24 14:23:02 +00:00
query . QueryData . QueryID = queryID ;
query . QueryData . QueryText = Utils . StringToBytes ( searchText ) ;
2009-10-08 02:56:37 +00:00
query . QueryData . QueryStart = queryStart ;
2009-08-24 14:23:02 +00:00
query . QueryData . SimName = Utils . StringToBytes ( string . Empty ) ;
Client . Network . SendPacket ( query ) ;
return queryID ;
}
2007-03-09 20:26:07 +00:00
/// <summary>
/// Starts a search for land sales using the directory
2009-10-08 02:56:37 +00:00
///
/// The <see cref="OnDirLandReply"/> event is raised when a response is received from the simulator
2007-03-09 20:26:07 +00:00
/// </summary>
/// <param name="typeFlags">What type of land to search for. Auction,
/// estate, mainland, "first land", etc</param>
/// <returns>A unique identifier that can identify packets associated
/// with this query from other queries</returns>
/// <remarks>The OnDirLandReply event handler must be registered before
/// calling this function. There is no way to determine how many
/// results will be returned, or how many times the callback will be
/// fired other than you won't get more than 100 total parcels from
/// each query.</remarks>
2008-07-25 05:15:05 +00:00
public UUID StartLandSearch ( SearchTypeFlags typeFlags )
2007-03-09 20:26:07 +00:00
{
2009-10-07 20:13:33 +00:00
return StartLandSearch ( DirFindFlags . SortAsc | DirFindFlags . PerMeterSort , typeFlags , 0 , 0 , 0 ) ;
2007-03-09 20:26:07 +00:00
}
/// <summary>
/// Starts a search for land sales using the directory
2009-10-08 02:56:37 +00:00
///
/// The <seealso cref="OnDirLandReply"/> event is raised when a response is received from the simulator
2007-03-09 20:26:07 +00:00
/// </summary>
/// <param name="typeFlags">What type of land to search for. Auction,
/// estate, mainland, "first land", etc</param>
/// <param name="priceLimit">Maximum price to search for</param>
/// <param name="areaLimit">Maximum area to search for</param>
/// <param name="queryStart">Each request is limited to 100 parcels
/// being returned. To get the first 100 parcels of a request use 0,
/// from 100-199 use 1, 200-299 use 2, etc.</param>
/// <returns>A unique identifier that can identify packets associated
/// with this query from other queries</returns>
/// <remarks>The OnDirLandReply event handler must be registered before
/// calling this function. There is no way to determine how many
/// results will be returned, or how many times the callback will be
/// fired other than you won't get more than 100 total parcels from
/// each query.</remarks>
2008-07-25 05:15:05 +00:00
public UUID StartLandSearch ( SearchTypeFlags typeFlags , int priceLimit , int areaLimit , int queryStart )
2007-03-09 20:26:07 +00:00
{
2009-08-24 14:23:02 +00:00
return StartLandSearch ( DirFindFlags . SortAsc | DirFindFlags . PerMeterSort | DirFindFlags . LimitByPrice |
2007-03-09 20:26:07 +00:00
DirFindFlags . LimitByArea , typeFlags , priceLimit , areaLimit , queryStart ) ;
}
/// <summary>
2009-10-08 02:56:37 +00:00
/// Request land listed for public sale
2007-03-09 20:26:07 +00:00
/// </summary>
2009-10-08 02:56:37 +00:00
///
/// <param name="findFlags">Flags sent to specify query options
///
/// Available flags:
/// Specify the parcel rating with one or more of the following:
/// IncludePG IncludeMature IncludeAdult
///
/// Specify the field to pre sort the results with ONLY ONE of the following:
/// PerMeterSort NameSort AreaSort PricesSort
///
/// Specify the order the results are returned in, if not specified the results are pre sorted in a Descending Order
/// SortAsc
///
/// Specify additional filters to limit the results with one or both of the following:
/// LimitByPrice LimitByArea
///
/// Flags can be combined by separating them with the | (pipe) character
///
/// Additional details can be found in <see cref="DirFindFlags"/>
/// </param>
2007-03-09 20:26:07 +00:00
/// <param name="typeFlags">What type of land to search for. Auction,
2009-10-08 02:56:37 +00:00
/// Estate or Mainland</param>
/// <param name="priceLimit">Maximum price to search for when the
/// DirFindFlags.LimitByPrice flag is specified in findFlags</param>
/// <param name="areaLimit">Maximum area to search for when the
/// DirFindFlags.LimitByArea flag is specified in findFlags</param>
2007-03-09 20:26:07 +00:00
/// <param name="queryStart">Each request is limited to 100 parcels
/// being returned. To get the first 100 parcels of a request use 0,
2007-04-17 20:48:18 +00:00
/// from 100-199 use 100, 200-299 use 200, etc.</param>
2007-03-09 20:26:07 +00:00
/// <returns>A unique identifier that can identify packets associated
/// with this query from other queries</returns>
2009-10-08 02:56:37 +00:00
/// <remarks><para>The <seealso cref="OnDirLandReply"/> event will be raised with the response from the simulator
///
/// There is no way to determine how many results will be returned, or how many times the callback will be
2007-03-09 20:26:07 +00:00
/// fired other than you won't get more than 100 total parcels from
2009-10-08 02:56:37 +00:00
/// each reply.</para>
///
/// <para>Any land set for sale to either anybody or specific to the connected agent will be included in the
/// results if the land is included in the query</para></remarks>
/// <example>
/// <code>
/// // request all mainland, any maturity rating that is larger than 512 sq.m
/// StartLandSearch(DirFindFlags.SortAsc | DirFindFlags.PerMeterSort | DirFindFlags.LimitByArea | DirFindFlags.IncludePG | DirFindFlags.IncludeMature | DirFindFlags.IncludeAdult, SearchTypeFlags.Mainland, 0, 512, 0);
/// </code></example>
2008-07-25 05:15:05 +00:00
public UUID StartLandSearch ( DirFindFlags findFlags , SearchTypeFlags typeFlags , int priceLimit ,
2007-03-09 20:26:07 +00:00
int areaLimit , int queryStart )
{
2008-07-25 05:15:05 +00:00
UUID queryID = UUID . Random ( ) ;
2009-10-08 02:56:37 +00:00
2007-03-09 20:26:07 +00:00
DirLandQueryPacket query = new DirLandQueryPacket ( ) ;
2007-11-06 09:26:10 +00:00
query . AgentData . AgentID = Client . Self . AgentID ;
query . AgentData . SessionID = Client . Self . SessionID ;
2007-03-09 20:26:07 +00:00
query . QueryData . Area = areaLimit ;
query . QueryData . Price = priceLimit ;
query . QueryData . QueryStart = queryStart ;
query . QueryData . SearchType = ( uint ) typeFlags ;
query . QueryData . QueryFlags = ( uint ) findFlags ;
query . QueryData . QueryID = queryID ;
Client . Network . SendPacket ( query ) ;
return queryID ;
}
2009-10-07 20:13:33 +00:00
2007-08-16 19:41:30 +00:00
/// <summary>
/// Starts a search for a Group in the directory manager
/// </summary>
/// <param name="findFlags"></param>
2009-10-08 02:56:37 +00:00
/// <param name="searchText">A string containing a list of keywords to search for separated by a space character</param>
2007-08-16 19:41:30 +00:00
/// <param name="queryStart">Each request is limited to 100 parcels
/// being returned. To get the first 100 parcels of a request use 0,
/// from 100-199 use 100, 200-299 use 200, etc.</param>
/// <returns>A unique identifier that can identify packets associated
/// with this query from other queries</returns>
/// <remarks>The OnDirLandReply event handler must be registered before
/// calling this function. There is no way to determine how many
/// results will be returned, or how many times the callback will be
/// fired other than you won't get more than 100 total parcels from
/// each query.</remarks>
2008-07-25 05:15:05 +00:00
public UUID StartGroupSearch ( DirFindFlags findFlags , string searchText , int queryStart )
2007-08-16 19:41:30 +00:00
{
2008-07-25 05:15:05 +00:00
return StartGroupSearch ( findFlags , searchText , queryStart , UUID . Random ( ) ) ;
2007-08-16 19:41:30 +00:00
}
2009-10-07 20:13:33 +00:00
/// <summary>
/// Search for groups
/// </summary>
/// <param name="findFlags"></param>
/// <param name="searchText"></param>
/// <param name="queryStart"></param>
/// <param name="queryID"></param>
/// <returns></returns>
2008-07-25 05:15:05 +00:00
public UUID StartGroupSearch ( DirFindFlags findFlags , string searchText , int queryStart , UUID queryID )
2007-08-16 19:41:30 +00:00
{
DirFindQueryPacket find = new DirFindQueryPacket ( ) ;
2007-11-06 09:26:10 +00:00
find . AgentData . AgentID = Client . Self . AgentID ;
find . AgentData . SessionID = Client . Self . SessionID ;
2007-08-16 19:41:30 +00:00
find . QueryData . QueryFlags = ( uint ) findFlags ;
2008-08-12 22:38:02 +00:00
find . QueryData . QueryText = Utils . StringToBytes ( searchText ) ;
2007-08-16 19:41:30 +00:00
find . QueryData . QueryID = queryID ;
find . QueryData . QueryStart = queryStart ;
Client . Network . SendPacket ( find ) ;
return queryID ;
}
2007-03-09 20:26:07 +00:00
2009-10-07 20:13:33 +00:00
/// <summary>
/// Search the people directory for other avatars
2009-10-08 02:56:37 +00:00
///
/// The <see cref="OnDirPeopleReply"/> event is raised when a response is received from the simulator
2009-10-07 20:13:33 +00:00
/// </summary>
/// <param name="findFlags"></param>
2009-10-08 02:56:37 +00:00
/// <param name="searchText">A string containing a list of keywords to search for separated by a space character</param>
2009-10-07 20:13:33 +00:00
/// <param name="queryStart"></param>
/// <returns></returns>
2008-07-25 05:15:05 +00:00
public UUID StartPeopleSearch ( DirFindFlags findFlags , string searchText , int queryStart )
2007-04-23 01:39:14 +00:00
{
2008-07-25 05:15:05 +00:00
return StartPeopleSearch ( findFlags , searchText , queryStart , UUID . Random ( ) ) ;
2007-07-19 06:42:25 +00:00
}
2009-10-07 20:13:33 +00:00
/// <summary>
///
/// </summary>
/// <param name="findFlags"></param>
2009-10-08 02:56:37 +00:00
/// <param name="searchText">A string containing a list of keywords to search for separated by a space character</param>
2009-10-07 20:13:33 +00:00
/// <param name="queryStart"></param>
/// <param name="queryID"></param>
/// <returns></returns>
2008-07-25 05:15:05 +00:00
public UUID StartPeopleSearch ( DirFindFlags findFlags , string searchText , int queryStart , UUID queryID )
2007-07-19 06:42:25 +00:00
{
2007-04-23 01:39:14 +00:00
DirFindQueryPacket find = new DirFindQueryPacket ( ) ;
2007-11-06 09:26:10 +00:00
find . AgentData . AgentID = Client . Self . AgentID ;
find . AgentData . SessionID = Client . Self . SessionID ;
2007-04-23 01:39:14 +00:00
find . QueryData . QueryFlags = ( uint ) findFlags ;
2008-08-12 22:38:02 +00:00
find . QueryData . QueryText = Utils . StringToBytes ( searchText ) ;
2007-04-23 01:39:14 +00:00
find . QueryData . QueryID = queryID ;
2007-05-14 10:18:54 +00:00
find . QueryData . QueryStart = queryStart ;
2007-08-20 20:38:36 +00:00
2007-04-23 01:39:14 +00:00
Client . Network . SendPacket ( find ) ;
2007-08-20 20:38:36 +00:00
2007-04-23 01:39:14 +00:00
return queryID ;
}
2007-08-20 20:38:36 +00:00
/// <summary>
2009-10-07 20:13:33 +00:00
/// Search "places" for parcels of land you personally own
2007-08-20 20:38:36 +00:00
/// </summary>
2008-07-25 05:15:05 +00:00
public UUID StartPlacesSearch ( )
2007-08-20 20:38:36 +00:00
{
2009-08-24 14:23:02 +00:00
return StartPlacesSearch ( DirFindFlags . AgentOwned , ParcelCategory . Any , String . Empty , String . Empty ,
2008-07-25 05:15:05 +00:00
UUID . Zero , UUID . Zero ) ;
2007-08-20 20:38:36 +00:00
}
/// <summary>
/// Searches Places for Land owned by a specific user or group
/// </summary>
/// <param name="findFlags">One of the Values from the DirFindFlags struct, ie: AgentOwned, GroupOwned, etc.</param>
/// <param name="groupID">LLUID of group you want to recieve land list for (You must be in group), or
/// LLUID.Zero for Your own land</param>
/// <returns>Transaction (Query) ID which can be associated with results from your request.</returns>
2008-07-25 05:15:05 +00:00
public UUID StartPlacesSearch ( DirFindFlags findFlags , UUID groupID )
2007-08-20 20:38:36 +00:00
{
2009-08-24 14:23:02 +00:00
return StartPlacesSearch ( findFlags , ParcelCategory . Any , String . Empty , String . Empty , groupID ,
2008-07-25 05:15:05 +00:00
UUID . Random ( ) ) ;
2007-08-20 20:38:36 +00:00
}
/// <summary>
/// Search Places
/// </summary>
/// <param name="findFlags">One of the Values from the DirFindFlags struct, ie: AgentOwned, GroupOwned, etc.</param>
/// <param name="searchCategory">One of the values from the SearchCategory Struct, ie: Any, Linden, Newcomer</param>
2009-10-08 02:56:37 +00:00
/// <param name="groupID">UUID of group you want to recieve results for</param>
2007-08-20 20:38:36 +00:00
/// <param name="transactionID">Transaction (Query) ID which can be associated with results from your request.</param>
/// <returns>Transaction (Query) ID which can be associated with results from your request.</returns>
2009-04-09 01:17:40 +00:00
public UUID StartPlacesSearch ( DirFindFlags findFlags , ParcelCategory searchCategory , UUID groupID , UUID transactionID )
2007-08-20 20:38:36 +00:00
{
return StartPlacesSearch ( findFlags , searchCategory , String . Empty , String . Empty , groupID , transactionID ) ;
}
/// <summary>
/// Search Places - All Options
/// </summary>
/// <param name="findFlags">One of the Values from the DirFindFlags struct, ie: AgentOwned, GroupOwned, etc.</param>
/// <param name="searchCategory">One of the values from the SearchCategory Struct, ie: Any, Linden, Newcomer</param>
2009-10-08 02:56:37 +00:00
/// <param name="searchText">A string containing a list of keywords to search for separated by a space character</param>
2007-08-20 20:38:36 +00:00
/// <param name="simulatorName">String Simulator Name to search in</param>
/// <param name="groupID">LLUID of group you want to recieve results for</param>
/// <param name="transactionID">Transaction (Query) ID which can be associated with results from your request.</param>
/// <returns>Transaction (Query) ID which can be associated with results from your request.</returns>
2009-04-09 01:17:40 +00:00
public UUID StartPlacesSearch ( DirFindFlags findFlags , ParcelCategory searchCategory , string searchText , string simulatorName , UUID groupID , UUID transactionID )
2007-08-20 20:38:36 +00:00
{
PlacesQueryPacket find = new PlacesQueryPacket ( ) ;
2007-11-06 09:26:10 +00:00
find . AgentData . AgentID = Client . Self . AgentID ;
find . AgentData . SessionID = Client . Self . SessionID ;
2007-08-20 20:38:36 +00:00
find . AgentData . QueryID = groupID ;
find . TransactionData . TransactionID = transactionID ;
2008-08-12 22:38:02 +00:00
find . QueryData . QueryText = Utils . StringToBytes ( searchText ) ;
2007-08-20 20:38:36 +00:00
find . QueryData . QueryFlags = ( uint ) findFlags ;
find . QueryData . Category = ( sbyte ) searchCategory ;
2008-08-12 22:38:02 +00:00
find . QueryData . SimName = Utils . StringToBytes ( simulatorName ) ;
2009-08-24 14:23:02 +00:00
2007-08-20 20:38:36 +00:00
Client . Network . SendPacket ( find ) ;
return transactionID ;
}
2008-01-01 00:29:51 +00:00
/// <summary>
2009-10-08 02:56:37 +00:00
/// Search All Events with specifid searchText in all categories, includes PG, Mature and Adult
2008-01-01 00:29:51 +00:00
/// </summary>
2009-10-08 02:56:37 +00:00
/// <param name="searchText">A string containing a list of keywords to search for separated by a space character</param>
/// <param name="queryStart">Each request is limited to 100 entries
/// being returned. To get the first group of entries of a request use 0,
/// from 100-199 use 100, 200-299 use 200, etc.</param>
2008-01-01 00:29:51 +00:00
/// <returns>UUID of query to correlate results in callback.</returns>
2009-10-08 02:56:37 +00:00
public UUID StartEventsSearch ( string searchText , uint queryStart )
2008-01-01 00:29:51 +00:00
{
2009-10-08 02:56:37 +00:00
return StartEventsSearch ( searchText , DirFindFlags . DateEvents | DirFindFlags . IncludePG | DirFindFlags . IncludeMature | DirFindFlags . IncludeAdult , "u" , queryStart , EventCategories . All ) ;
2008-01-01 00:29:51 +00:00
}
/// <summary>
2009-10-08 02:56:37 +00:00
/// Search Events
2008-01-01 00:29:51 +00:00
/// </summary>
2009-10-08 02:56:37 +00:00
/// <param name="searchText">A string containing a list of keywords to search for separated by a space character</param>
/// <param name="queryFlags">One or more of the following flags: DateEvents, IncludePG, IncludeMature, IncludeAdult
/// from the <see cref="DirFindFlags"/> Enum
///
/// Multiple flags can be combined by separating the flags with the | (pipe) character</param>
/// <param name="eventDay">"u" for in-progress and upcoming events, -or- number of days since/until event is scheduled
2008-01-01 00:29:51 +00:00
/// For example "0" = Today, "1" = tomorrow, "2" = following day, "-1" = yesterday, etc.</param>
2009-10-08 02:56:37 +00:00
/// <param name="queryStart">Each request is limited to 100 entries
/// being returned. To get the first group of entries of a request use 0,
/// from 100-199 use 100, 200-299 use 200, etc.</param>
2008-01-01 00:29:51 +00:00
/// <param name="category">EventCategory event is listed under.</param>
2008-07-28 22:23:48 +00:00
/// <param name="queryID">a UUID that can be used to track queries with results.</param>
2008-01-01 00:29:51 +00:00
/// <returns>UUID of query to correlate results in callback.</returns>
2009-10-08 02:56:37 +00:00
public UUID StartEventsSearch ( string searchText , DirFindFlags queryFlags , string eventDay , uint queryStart , EventCategories category )
2008-01-01 00:29:51 +00:00
{
DirFindQueryPacket find = new DirFindQueryPacket ( ) ;
find . AgentData . AgentID = Client . Self . AgentID ;
find . AgentData . SessionID = Client . Self . SessionID ;
2009-08-24 14:23:02 +00:00
2009-10-08 02:56:37 +00:00
UUID queryID = UUID . Random ( ) ;
2008-01-01 00:29:51 +00:00
find . QueryData . QueryID = queryID ;
2008-08-12 22:38:02 +00:00
find . QueryData . QueryText = Utils . StringToBytes ( eventDay + "|" + ( int ) category + "|" + searchText ) ;
2009-10-08 02:56:37 +00:00
find . QueryData . QueryFlags = ( uint ) queryFlags ;
2008-01-01 00:29:51 +00:00
find . QueryData . QueryStart = ( int ) queryStart ;
Client . Network . SendPacket ( find ) ;
return queryID ;
}
2009-10-08 02:56:37 +00:00
2008-01-01 00:29:51 +00:00
/// <summary>Requests Event Details</summary>
/// <param name="eventID">ID of Event returned from Places Search</param>
public void EventInfoRequest ( uint eventID )
{
EventInfoRequestPacket find = new EventInfoRequestPacket ( ) ;
find . AgentData . AgentID = Client . Self . AgentID ;
find . AgentData . SessionID = Client . Self . SessionID ;
find . EventData . EventID = eventID ;
Client . Network . SendPacket ( find ) ;
}
2009-10-08 02:56:37 +00:00
2007-11-30 23:19:05 +00:00
#region Blocking Functions
2009-10-08 02:56:37 +00:00
[Obsolete("Use the async StartPeoplSearch method instead")]
2007-11-30 23:19:05 +00:00
public bool PeopleSearch ( DirFindFlags findFlags , string searchText , int queryStart ,
int timeoutMS , out List < AgentSearchData > results )
{
AutoResetEvent searchEvent = new AutoResetEvent ( false ) ;
2008-07-25 05:15:05 +00:00
UUID id = UUID . Random ( ) ;
2007-11-30 23:19:05 +00:00
List < AgentSearchData > people = null ;
DirPeopleReplyCallback callback =
2008-07-25 05:15:05 +00:00
delegate ( UUID queryid , List < AgentSearchData > matches )
2007-11-30 23:19:05 +00:00
{
if ( id = = queryid )
{
people = matches ;
searchEvent . Set ( ) ;
}
} ;
OnDirPeopleReply + = callback ;
StartPeopleSearch ( findFlags , searchText , queryStart , id ) ;
searchEvent . WaitOne ( timeoutMS , false ) ;
OnDirPeopleReply - = callback ;
results = people ;
return ( results ! = null ) ;
}
#endregion Blocking Functions
#region Packet Handlers
2007-03-09 20:26:07 +00:00
private void DirClassifiedReplyHandler ( Packet packet , Simulator simulator )
{
if ( OnClassifiedReply ! = null )
{
DirClassifiedReplyPacket reply = ( DirClassifiedReplyPacket ) packet ;
List < Classified > classifieds = new List < Classified > ( ) ;
foreach ( DirClassifiedReplyPacket . QueryRepliesBlock block in reply . QueryReplies )
{
Classified classified = new Classified ( ) ;
2008-08-12 22:38:02 +00:00
classified . CreationDate = Utils . UnixTimeToDateTime ( block . CreationDate ) ;
classified . ExpirationDate = Utils . UnixTimeToDateTime ( block . ExpirationDate ) ;
2009-10-07 20:13:33 +00:00
classified . Flags = ( ClassifiedFlags ) block . ClassifiedFlags ;
2007-03-09 20:26:07 +00:00
classified . ID = block . ClassifiedID ;
2008-08-12 22:38:02 +00:00
classified . Name = Utils . BytesToString ( block . Name ) ;
2007-03-09 20:26:07 +00:00
classified . Price = block . PriceForListing ;
classifieds . Add ( classified ) ;
}
try { OnClassifiedReply ( classifieds ) ; }
2008-05-06 23:57:26 +00:00
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
2007-03-09 20:26:07 +00:00
}
}
private void DirLandReplyHandler ( Packet packet , Simulator simulator )
{
if ( OnDirLandReply ! = null )
{
List < DirectoryParcel > parcelsForSale = new List < DirectoryParcel > ( ) ;
DirLandReplyPacket reply = ( DirLandReplyPacket ) packet ;
foreach ( DirLandReplyPacket . QueryRepliesBlock block in reply . QueryReplies )
{
DirectoryParcel dirParcel = new DirectoryParcel ( ) ;
dirParcel . ActualArea = block . ActualArea ;
dirParcel . ID = block . ParcelID ;
2008-08-12 22:38:02 +00:00
dirParcel . Name = Utils . BytesToString ( block . Name ) ;
2007-03-09 20:26:07 +00:00
dirParcel . SalePrice = block . SalePrice ;
dirParcel . Auction = block . Auction ;
2009-09-27 20:19:45 +00:00
dirParcel . ForSale = block . ForSale ;
parcelsForSale . Add ( dirParcel ) ;
}
try { OnDirLandReply ( parcelsForSale ) ; }
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
}
}
private void DirLandReplyEventHandler ( string capsKey , IMessage message , Simulator simulator )
{
if ( OnDirLandReply ! = null )
{
List < DirectoryParcel > parcelsForSale = new List < DirectoryParcel > ( ) ;
DirLandReplyMessage reply = ( DirLandReplyMessage ) message ;
foreach ( DirLandReplyMessage . QueryReply block in reply . QueryReplies )
{
DirectoryParcel dirParcel = new DirectoryParcel ( ) ;
dirParcel . ActualArea = block . ActualArea ;
dirParcel . ID = block . ParcelID ;
dirParcel . Name = block . Name ;
dirParcel . SalePrice = block . SalePrice ;
dirParcel . Auction = block . Auction ;
2007-03-09 20:26:07 +00:00
dirParcel . ForSale = block . ForSale ;
parcelsForSale . Add ( dirParcel ) ;
}
try { OnDirLandReply ( parcelsForSale ) ; }
2008-05-06 23:57:26 +00:00
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
2007-03-09 20:26:07 +00:00
}
}
2007-04-23 01:39:14 +00:00
protected void DirPeopleReplyHandler ( Packet packet , Simulator simulator )
{
if ( OnDirPeopleReply ! = null )
{
DirPeopleReplyPacket peopleReply = packet as DirPeopleReplyPacket ;
List < AgentSearchData > matches = new List < AgentSearchData > ( peopleReply . QueryReplies . Length ) ;
2009-08-24 14:23:02 +00:00
foreach ( DirPeopleReplyPacket . QueryRepliesBlock reply in peopleReply . QueryReplies )
{
2007-04-23 01:39:14 +00:00
AgentSearchData searchData = new AgentSearchData ( ) ;
searchData . Online = reply . Online ;
2008-08-12 22:38:02 +00:00
searchData . FirstName = Utils . BytesToString ( reply . FirstName ) ;
searchData . LastName = Utils . BytesToString ( reply . LastName ) ;
2007-04-23 01:39:14 +00:00
searchData . AgentID = reply . AgentID ;
matches . Add ( searchData ) ;
}
try { OnDirPeopleReply ( peopleReply . QueryData . QueryID , matches ) ; }
2008-05-06 23:57:26 +00:00
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
2007-04-23 01:39:14 +00:00
}
}
2007-08-16 19:41:30 +00:00
protected void DirGroupsReplyHandler ( Packet packet , Simulator simulator )
{
if ( OnDirGroupsReply ! = null )
{
DirGroupsReplyPacket groupsReply = packet as DirGroupsReplyPacket ;
List < GroupSearchData > matches = new List < GroupSearchData > ( groupsReply . QueryReplies . Length ) ;
foreach ( DirGroupsReplyPacket . QueryRepliesBlock reply in groupsReply . QueryReplies )
{
GroupSearchData groupsData = new GroupSearchData ( ) ;
groupsData . GroupID = reply . GroupID ;
2008-08-12 22:38:02 +00:00
groupsData . GroupName = Utils . BytesToString ( reply . GroupName ) ;
2007-08-16 19:41:30 +00:00
groupsData . Members = reply . Members ;
matches . Add ( groupsData ) ;
}
try { OnDirGroupsReply ( groupsReply . QueryData . QueryID , matches ) ; }
2008-05-06 23:57:26 +00:00
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
2007-08-16 19:41:30 +00:00
}
}
2007-08-20 20:38:36 +00:00
2009-05-09 22:46:38 +00:00
private void PlacesReplyEventHandler ( string capsKey , IMessage message , Simulator simulator )
{
2009-08-24 14:23:02 +00:00
if ( OnPlacesReply ! = null )
2009-05-09 22:46:38 +00:00
{
2009-08-24 14:23:02 +00:00
PlacesReplyMessage replyMessage = ( PlacesReplyMessage ) message ;
2009-05-09 22:46:38 +00:00
List < PlacesSearchData > places = new List < PlacesSearchData > ( ) ;
2009-08-24 14:23:02 +00:00
for ( int i = 0 ; i < replyMessage . QueryDataBlocks . Length ; i + + )
2009-05-09 22:46:38 +00:00
{
PlacesSearchData place = new PlacesSearchData ( ) ;
place . ActualArea = replyMessage . QueryDataBlocks [ i ] . ActualArea ;
place . BillableArea = replyMessage . QueryDataBlocks [ i ] . BillableArea ;
place . Desc = replyMessage . QueryDataBlocks [ i ] . Description ;
place . Dwell = replyMessage . QueryDataBlocks [ i ] . Dwell ;
place . Flags = ( byte ) replyMessage . QueryDataBlocks [ i ] . Flags ;
place . GlobalX = replyMessage . QueryDataBlocks [ i ] . GlobalX ;
place . GlobalY = replyMessage . QueryDataBlocks [ i ] . GlobalY ;
place . GlobalZ = replyMessage . QueryDataBlocks [ i ] . GlobalZ ;
place . Name = replyMessage . QueryDataBlocks [ i ] . Name ;
place . OwnerID = replyMessage . QueryDataBlocks [ i ] . OwnerID ;
place . Price = replyMessage . QueryDataBlocks [ i ] . Price ;
place . SimName = replyMessage . QueryDataBlocks [ i ] . SimName ;
place . SnapshotID = replyMessage . QueryDataBlocks [ i ] . SnapShotID ;
places . Add ( place ) ;
}
try { OnPlacesReply ( replyMessage . TransactionID , places ) ; }
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
}
}
2007-08-20 20:38:36 +00:00
private void PlacesReplyHandler ( Packet packet , Simulator simulator )
{
if ( OnPlacesReply ! = null )
{
PlacesReplyPacket placesReply = packet as PlacesReplyPacket ;
List < PlacesSearchData > places = new List < PlacesSearchData > ( ) ;
foreach ( PlacesReplyPacket . QueryDataBlock block in placesReply . QueryData )
{
PlacesSearchData place = new PlacesSearchData ( ) ;
place . OwnerID = block . OwnerID ;
2008-08-12 22:38:02 +00:00
place . Name = Utils . BytesToString ( block . Name ) ;
place . Desc = Utils . BytesToString ( block . Desc ) ;
2007-08-20 20:38:36 +00:00
place . ActualArea = block . ActualArea ;
place . BillableArea = block . BillableArea ;
place . Flags = block . Flags ;
place . GlobalX = block . GlobalX ;
place . GlobalY = block . GlobalY ;
place . GlobalZ = block . GlobalZ ;
2008-08-12 22:38:02 +00:00
place . SimName = Utils . BytesToString ( block . SimName ) ;
2007-08-20 20:38:36 +00:00
place . SnapshotID = block . SnapshotID ;
place . Dwell = block . Dwell ;
place . Price = block . Price ;
2009-08-24 14:23:02 +00:00
2007-08-20 20:38:36 +00:00
places . Add ( place ) ;
}
try { OnPlacesReply ( placesReply . TransactionData . TransactionID , places ) ; }
2008-05-06 23:57:26 +00:00
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
2007-08-20 20:38:36 +00:00
}
}
2007-11-30 23:19:05 +00:00
2008-01-01 00:29:51 +00:00
private void EventsReplyHandler ( Packet packet , Simulator simulator )
{
if ( OnEventsReply ! = null )
{
DirEventsReplyPacket eventsReply = packet as DirEventsReplyPacket ;
List < EventsSearchData > matches = new List < EventsSearchData > ( eventsReply . QueryReplies . Length ) ;
foreach ( DirEventsReplyPacket . QueryRepliesBlock reply in eventsReply . QueryReplies )
{
EventsSearchData eventsData = new EventsSearchData ( ) ;
eventsData . Owner = reply . OwnerID ;
2008-08-12 22:38:02 +00:00
eventsData . Name = Utils . BytesToString ( reply . Name ) ;
2008-01-01 00:29:51 +00:00
eventsData . ID = reply . EventID ;
2008-08-12 22:38:02 +00:00
eventsData . Date = Utils . BytesToString ( reply . Date ) ;
2008-01-01 00:29:51 +00:00
eventsData . Time = reply . UnixTime ;
eventsData . Flags = ( EventFlags ) reply . EventFlags ;
matches . Add ( eventsData ) ;
}
try { OnEventsReply ( eventsReply . QueryData . QueryID , matches ) ; }
2008-05-06 23:57:26 +00:00
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
2008-01-01 00:29:51 +00:00
}
}
2009-08-24 14:23:02 +00:00
2008-01-01 00:29:51 +00:00
private void EventInfoReplyHandler ( Packet packet , Simulator simulator )
{
if ( OnEventInfo ! = null )
{
EventInfoReplyPacket eventReply = ( EventInfoReplyPacket ) packet ;
EventInfo evinfo = new EventInfo ( ) ;
evinfo . ID = eventReply . EventData . EventID ;
2008-08-12 22:38:02 +00:00
evinfo . Name = Utils . BytesToString ( eventReply . EventData . Name ) ;
evinfo . Desc = Utils . BytesToString ( eventReply . EventData . Desc ) ;
2008-01-01 00:29:51 +00:00
evinfo . Amount = eventReply . EventData . Amount ;
2008-10-06 22:34:38 +00:00
evinfo . Category = ( EventCategories ) Utils . BytesToUInt ( eventReply . EventData . Category ) ;
2008-01-01 00:29:51 +00:00
evinfo . Cover = eventReply . EventData . Cover ;
2008-08-12 22:38:02 +00:00
evinfo . Creator = ( UUID ) Utils . BytesToString ( eventReply . EventData . Creator ) ;
evinfo . Date = Utils . BytesToString ( eventReply . EventData . Date ) ;
2008-01-01 00:29:51 +00:00
evinfo . DateUTC = eventReply . EventData . DateUTC ;
evinfo . Duration = eventReply . EventData . Duration ;
evinfo . Flags = ( EventFlags ) eventReply . EventData . EventFlags ;
2008-08-12 22:38:02 +00:00
evinfo . SimName = Utils . BytesToString ( eventReply . EventData . SimName ) ;
2008-01-01 00:29:51 +00:00
evinfo . GlobalPos = eventReply . EventData . GlobalPos ;
try { OnEventInfo ( evinfo ) ; }
2008-05-06 23:57:26 +00:00
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
2008-01-01 00:29:51 +00:00
}
}
2009-08-24 14:23:02 +00:00
private void DirPlacesReplyHandler ( Packet packet , Simulator simulator )
{
if ( OnDirPlacesReply ! = null )
{
DirPlacesReplyPacket reply = ( DirPlacesReplyPacket ) packet ;
List < DirectoryParcel > result = new List < DirectoryParcel > ( ) ;
for ( int i = 0 ; i < reply . QueryReplies . Length ; i + + )
{
DirectoryParcel p = new DirectoryParcel ( ) ;
p . ID = reply . QueryReplies [ i ] . ParcelID ;
p . Name = Utils . BytesToString ( reply . QueryReplies [ i ] . Name ) ;
p . Dwell = reply . QueryReplies [ i ] . Dwell ;
p . Auction = reply . QueryReplies [ i ] . Auction ;
2009-10-08 02:56:37 +00:00
p . ForSale = reply . QueryReplies [ i ] . ForSale ;
2009-08-24 14:23:02 +00:00
result . Add ( p ) ;
}
try { OnDirPlacesReply ( reply . QueryData [ 0 ] . QueryID , result ) ; }
catch ( Exception e ) { Logger . Log ( e . Message , Helpers . LogLevel . Error , Client , e ) ; }
}
}
2007-11-30 23:19:05 +00:00
#endregion Packet Handlers
2007-03-09 20:26:07 +00:00
}
}