mirror of
https://github.com/kcozens/OpenSimSearch.git
synced 2026-08-14 08:52:28 +00:00
Cleaning up
git-svn-id: http://forge.opensimulator.org/svn/ossearch/trunk@52 109abde3-1f22-4c10-b5d7-b6b0135cd00c
This commit is contained in:
@@ -20,418 +20,418 @@ namespace OpenSimSearch.Modules.OpenSearch
|
||||
{
|
||||
public class OpenSearchModule : IRegionModule
|
||||
{
|
||||
//
|
||||
// Log module
|
||||
//
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
//
|
||||
// Log module
|
||||
//
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
//
|
||||
// Module vars
|
||||
//
|
||||
private IConfigSource m_gConfig;
|
||||
private List<Scene> m_Scenes = new List<Scene>();
|
||||
private string m_SearchServer = "";
|
||||
private bool m_Enabled = true;
|
||||
//
|
||||
// Module vars
|
||||
//
|
||||
private IConfigSource m_gConfig;
|
||||
private List<Scene> m_Scenes = new List<Scene>();
|
||||
private string m_SearchServer = "";
|
||||
private bool m_Enabled = true;
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
IConfig searchConfig = config.Configs["Search"];
|
||||
|
||||
if (m_Scenes.Count == 0) // First time
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
if (searchConfig == null)
|
||||
{
|
||||
m_log.Info("[SEARCH] Not configured, disabling");
|
||||
m_Enabled = false;
|
||||
return;
|
||||
}
|
||||
m_SearchServer = searchConfig.GetString("SearchURL", "");
|
||||
if (m_SearchServer == "")
|
||||
{
|
||||
m_log.Error("[SEARCH] No search server, disabling search");
|
||||
m_Enabled = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info("[SEARCH] Search module is activated");
|
||||
m_Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
IConfig searchConfig = config.Configs["Search"];
|
||||
if (!m_Scenes.Contains(scene))
|
||||
m_Scenes.Add(scene);
|
||||
|
||||
if (m_Scenes.Count == 0) // First time
|
||||
{
|
||||
if (searchConfig == null)
|
||||
{
|
||||
m_log.Info("[SEARCH] Not configured, disabling");
|
||||
m_Enabled = false;
|
||||
return;
|
||||
}
|
||||
m_SearchServer = searchConfig.GetString("SearchURL", "");
|
||||
if (m_SearchServer == "")
|
||||
{
|
||||
m_log.Error("[SEARCH] No search server, disabling search");
|
||||
m_Enabled = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info("[SEARCH] Search module is activated");
|
||||
m_Enabled = true;
|
||||
}
|
||||
}
|
||||
m_gConfig = config;
|
||||
|
||||
if (!m_Scenes.Contains(scene))
|
||||
m_Scenes.Add(scene);
|
||||
// Hook up events
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
}
|
||||
|
||||
m_gConfig = config;
|
||||
public void PostInitialise()
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
}
|
||||
|
||||
// Hook up events
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "SearchModule"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
/// New Client Event Handler
|
||||
private void OnNewClient(IClientAPI client)
|
||||
{
|
||||
// Subscribe to messages
|
||||
client.OnDirPlacesQuery += DirPlacesQuery;
|
||||
client.OnDirFindQuery += DirFindQuery;
|
||||
client.OnDirPopularQuery += DirPopularQuery;
|
||||
client.OnDirLandQuery += DirLandQuery;
|
||||
client.OnEventInfoRequest += EventInfoRequest;
|
||||
}
|
||||
|
||||
//
|
||||
// Make external XMLRPC request
|
||||
//
|
||||
private Hashtable GenericXMLRPCRequest(Hashtable ReqParams, string method)
|
||||
{
|
||||
ArrayList SendParams = new ArrayList();
|
||||
SendParams.Add(ReqParams);
|
||||
|
||||
// Send Request
|
||||
XmlRpcResponse Resp;
|
||||
try
|
||||
{
|
||||
XmlRpcRequest Req = new XmlRpcRequest(method, SendParams);
|
||||
Resp = Req.Send(m_SearchServer, 30000);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
m_log.ErrorFormat("[SEARCH]: Unable to connect to Search " +
|
||||
"Server {0}. Exception {1}", m_SearchServer, ex);
|
||||
|
||||
Hashtable ErrorHash = new Hashtable();
|
||||
ErrorHash["success"] = false;
|
||||
ErrorHash["errorMessage"] = "Unable to search at this time. ";
|
||||
ErrorHash["errorURI"] = "";
|
||||
|
||||
return ErrorHash;
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[SEARCH]: Unable to connect to Search Server {0}. " +
|
||||
"Exception {1}", m_SearchServer, ex);
|
||||
|
||||
Hashtable ErrorHash = new Hashtable();
|
||||
ErrorHash["success"] = false;
|
||||
ErrorHash["errorMessage"] = "Unable to search at this time. ";
|
||||
ErrorHash["errorURI"] = "";
|
||||
|
||||
return ErrorHash;
|
||||
}
|
||||
catch (XmlException ex)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[SEARCH]: Unable to connect to Search Server {0}. " +
|
||||
"Exception {1}", m_SearchServer, ex);
|
||||
|
||||
Hashtable ErrorHash = new Hashtable();
|
||||
ErrorHash["success"] = false;
|
||||
ErrorHash["errorMessage"] = "Unable to search at this time. ";
|
||||
ErrorHash["errorURI"] = "";
|
||||
|
||||
return ErrorHash;
|
||||
}
|
||||
if (Resp.IsFault)
|
||||
{
|
||||
Hashtable ErrorHash = new Hashtable();
|
||||
ErrorHash["success"] = false;
|
||||
ErrorHash["errorMessage"] = "Unable to search at this time. ";
|
||||
ErrorHash["errorURI"] = "";
|
||||
return ErrorHash;
|
||||
}
|
||||
Hashtable RespData = (Hashtable)Resp.Value;
|
||||
|
||||
return RespData;
|
||||
}
|
||||
|
||||
protected void DirPlacesQuery(IClientAPI remoteClient, UUID queryID,
|
||||
string queryText, int queryFlags, int category, string simName,
|
||||
int queryStart)
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["text"] = queryText;
|
||||
ReqHash["flags"] = queryFlags.ToString();
|
||||
ReqHash["category"] = category.ToString();
|
||||
ReqHash["sim_name"] = simName;
|
||||
ReqHash["query_start"] = queryStart.ToString();
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"dir_places_query");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
|
||||
int count = dataArray.Count;
|
||||
if (count > 100)
|
||||
count = 101;
|
||||
|
||||
DirPlacesReplyData[] data = new DirPlacesReplyData[count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (Object o in dataArray)
|
||||
{
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
Hashtable d = (Hashtable)o;
|
||||
|
||||
data[i] = new DirPlacesReplyData();
|
||||
data[i].parcelID = new UUID(d["parcel_id"].ToString());
|
||||
data[i].name = d["name"].ToString();
|
||||
data[i].forSale = Convert.ToBoolean(d["for_sale"]);
|
||||
data[i].auction = Convert.ToBoolean(d["auction"]);
|
||||
data[i].dwell = Convert.ToSingle(d["dwell"]);
|
||||
i++;
|
||||
if (i >= count)
|
||||
break;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
remoteClient.SendDirPlacesReply(queryID, data);
|
||||
}
|
||||
|
||||
public void DirPopularQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags)
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["flags"] = queryFlags.ToString();
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"dir_popular_query");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
public string Name
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
|
||||
int count = dataArray.Count;
|
||||
if (count > 100)
|
||||
count = 101;
|
||||
|
||||
DirPopularReplyData[] data = new DirPopularReplyData[count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (Object o in dataArray)
|
||||
{
|
||||
get { return "SearchModule"; }
|
||||
Hashtable d = (Hashtable)o;
|
||||
|
||||
data[i] = new DirPopularReplyData();
|
||||
data[i].parcelID = new UUID(d["parcel_id"].ToString());
|
||||
data[i].name = d["name"].ToString();
|
||||
data[i].dwell = Convert.ToSingle(d["dwell"]);
|
||||
i++;
|
||||
if (i >= count)
|
||||
break;
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
remoteClient.SendDirPopularReply(queryID, data);
|
||||
}
|
||||
|
||||
public void DirLandQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags, uint searchType, int price, int area, int queryStart)
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["flags"] = queryFlags.ToString();
|
||||
ReqHash["type"] = searchType.ToString();
|
||||
ReqHash["price"] = price.ToString();
|
||||
ReqHash["area"] = area.ToString();
|
||||
ReqHash["query_start"] = queryStart.ToString();
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"dir_land_query");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
get { return true; }
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
/// New Client Event Handler
|
||||
private void OnNewClient(IClientAPI client)
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
|
||||
int count = dataArray.Count;
|
||||
if (count > 100)
|
||||
count = 101;
|
||||
|
||||
DirLandReplyData[] data = new DirLandReplyData[count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (Object o in dataArray)
|
||||
{
|
||||
// Subscribe to messages
|
||||
client.OnDirPlacesQuery += DirPlacesQuery;
|
||||
client.OnDirFindQuery += DirFindQuery;
|
||||
client.OnDirPopularQuery += DirPopularQuery;
|
||||
client.OnDirLandQuery += DirLandQuery;
|
||||
client.OnEventInfoRequest += EventInfoRequest;
|
||||
Hashtable d = (Hashtable)o;
|
||||
|
||||
data[i] = new DirLandReplyData();
|
||||
data[i].parcelID = new UUID(d["parcel_id"].ToString());
|
||||
data[i].name = d["name"].ToString();
|
||||
data[i].auction = Convert.ToBoolean(d["auction"]);
|
||||
data[i].forSale = Convert.ToBoolean(d["for_sale"]);
|
||||
data[i].salePrice = Convert.ToInt32(d["sale_price"]);
|
||||
data[i].actualArea = Convert.ToInt32(d["area"]);
|
||||
i++;
|
||||
if (i >= count)
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Make external XMLRPC request
|
||||
//
|
||||
private Hashtable GenericXMLRPCRequest(Hashtable ReqParams, string method)
|
||||
remoteClient.SendDirLandReply(queryID, data);
|
||||
}
|
||||
|
||||
public void DirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
|
||||
{
|
||||
if ((queryFlags & 1) != 0)
|
||||
{
|
||||
ArrayList SendParams = new ArrayList();
|
||||
SendParams.Add(ReqParams);
|
||||
DirPeopleQuery(remoteClient, queryID, queryText, queryFlags, queryStart);
|
||||
return;
|
||||
}
|
||||
else if ((queryFlags & 32) != 0)
|
||||
{
|
||||
DirEventsQuery(remoteClient, queryID, queryText, queryFlags, queryStart);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Send Request
|
||||
XmlRpcResponse Resp;
|
||||
try
|
||||
{
|
||||
XmlRpcRequest Req = new XmlRpcRequest(method, SendParams);
|
||||
Resp = Req.Send(m_SearchServer, 30000);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
m_log.ErrorFormat("[SEARCH]: Unable to connect to Search " +
|
||||
"Server {0}. Exception {1}", m_SearchServer, ex);
|
||||
public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
|
||||
{
|
||||
List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
|
||||
AvatarResponses = m_Scenes[0].SceneGridService.GenerateAgentPickerRequestResponse(queryID, queryText);
|
||||
|
||||
Hashtable ErrorHash = new Hashtable();
|
||||
ErrorHash["success"] = false;
|
||||
ErrorHash["errorMessage"] = "Unable to search at this time. ";
|
||||
ErrorHash["errorURI"] = "";
|
||||
DirPeopleReplyData[] data = new DirPeopleReplyData[AvatarResponses.Count];
|
||||
|
||||
return ErrorHash;
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[SEARCH]: Unable to connect to Search Server {0}. " +
|
||||
"Exception {1}", m_SearchServer, ex);
|
||||
int i = 0;
|
||||
foreach (AvatarPickerAvatar item in AvatarResponses)
|
||||
{
|
||||
data[i] = new DirPeopleReplyData();
|
||||
|
||||
Hashtable ErrorHash = new Hashtable();
|
||||
ErrorHash["success"] = false;
|
||||
ErrorHash["errorMessage"] = "Unable to search at this time. ";
|
||||
ErrorHash["errorURI"] = "";
|
||||
|
||||
return ErrorHash;
|
||||
}
|
||||
catch (XmlException ex)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[SEARCH]: Unable to connect to Search Server {0}. " +
|
||||
"Exception {1}", m_SearchServer, ex);
|
||||
|
||||
Hashtable ErrorHash = new Hashtable();
|
||||
ErrorHash["success"] = false;
|
||||
ErrorHash["errorMessage"] = "Unable to search at this time. ";
|
||||
ErrorHash["errorURI"] = "";
|
||||
|
||||
return ErrorHash;
|
||||
}
|
||||
if (Resp.IsFault)
|
||||
{
|
||||
Hashtable ErrorHash = new Hashtable();
|
||||
ErrorHash["success"] = false;
|
||||
ErrorHash["errorMessage"] = "Unable to search at this time. ";
|
||||
ErrorHash["errorURI"] = "";
|
||||
return ErrorHash;
|
||||
}
|
||||
Hashtable RespData = (Hashtable)Resp.Value;
|
||||
|
||||
return RespData;
|
||||
data[i].agentID = item.AvatarID;
|
||||
data[i].firstName = item.firstName;
|
||||
data[i].lastName = item.lastName;
|
||||
data[i].group = "";
|
||||
data[i].online = false;
|
||||
data[i].reputation = 0;
|
||||
i++;
|
||||
}
|
||||
|
||||
protected void DirPlacesQuery(IClientAPI remoteClient, UUID queryID,
|
||||
string queryText, int queryFlags, int category, string simName,
|
||||
int queryStart)
|
||||
remoteClient.SendDirPeopleReply(queryID, data);
|
||||
}
|
||||
|
||||
public void DirEventsQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["text"] = queryText;
|
||||
ReqHash["flags"] = queryFlags.ToString();
|
||||
ReqHash["query_start"] = queryStart.ToString();
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"dir_events_query");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["text"] = queryText;
|
||||
ReqHash["flags"] = queryFlags.ToString();
|
||||
ReqHash["category"] = category.ToString();
|
||||
ReqHash["sim_name"] = simName;
|
||||
ReqHash["query_start"] = queryStart.ToString();
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"dir_places_query");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
|
||||
int count = dataArray.Count;
|
||||
if (count > 100)
|
||||
count = 101;
|
||||
|
||||
DirPlacesReplyData[] data = new DirPlacesReplyData[count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (Object o in dataArray)
|
||||
{
|
||||
Hashtable d = (Hashtable)o;
|
||||
|
||||
data[i] = new DirPlacesReplyData();
|
||||
data[i].parcelID = new UUID(d["parcel_id"].ToString());
|
||||
data[i].name = d["name"].ToString();
|
||||
data[i].forSale = Convert.ToBoolean(d["for_sale"]);
|
||||
data[i].auction = Convert.ToBoolean(d["auction"]);
|
||||
data[i].dwell = Convert.ToSingle(d["dwell"]);
|
||||
i++;
|
||||
if (i >= count)
|
||||
break;
|
||||
}
|
||||
|
||||
remoteClient.SendDirPlacesReply(queryID, data);
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
public void DirPopularQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags)
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
|
||||
int count = dataArray.Count;
|
||||
if (count > 100)
|
||||
count = 101;
|
||||
|
||||
DirEventsReplyData[] data = new DirEventsReplyData[count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (Object o in dataArray)
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["flags"] = queryFlags.ToString();
|
||||
Hashtable d = (Hashtable)o;
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"dir_popular_query");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
|
||||
int count = dataArray.Count;
|
||||
if (count > 100)
|
||||
count = 101;
|
||||
|
||||
DirPopularReplyData[] data = new DirPopularReplyData[count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (Object o in dataArray)
|
||||
{
|
||||
Hashtable d = (Hashtable)o;
|
||||
|
||||
data[i] = new DirPopularReplyData();
|
||||
data[i].parcelID = new UUID(d["parcel_id"].ToString());
|
||||
data[i].name = d["name"].ToString();
|
||||
data[i].dwell = Convert.ToSingle(d["dwell"]);
|
||||
i++;
|
||||
if (i >= count)
|
||||
break;
|
||||
}
|
||||
|
||||
remoteClient.SendDirPopularReply(queryID, data);
|
||||
data[i] = new DirEventsReplyData();
|
||||
data[i].ownerID = new UUID(d["owner_id"].ToString());
|
||||
data[i].name = d["name"].ToString();
|
||||
data[i].eventID = Convert.ToUInt32(d["event_id"]);
|
||||
data[i].date = d["date"].ToString();
|
||||
data[i].unixTime = Convert.ToUInt32(d["unix_time"]);
|
||||
data[i].eventFlags = Convert.ToUInt32(d["event_flags"]);
|
||||
i++;
|
||||
if (i >= count)
|
||||
break;
|
||||
}
|
||||
|
||||
public void DirLandQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags, uint searchType, int price, int area, int queryStart)
|
||||
remoteClient.SendDirEventsReply(queryID, data);
|
||||
}
|
||||
|
||||
public void EventInfoRequest(IClientAPI remoteClient, uint queryEventID)
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["eventID"] = queryEventID;
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"events_info_request");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["flags"] = queryFlags.ToString();
|
||||
ReqHash["type"] = searchType.ToString();
|
||||
ReqHash["price"] = price.ToString();
|
||||
ReqHash["area"] = area.ToString();
|
||||
ReqHash["query_start"] = queryStart.ToString();
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"dir_land_query");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
|
||||
int count = dataArray.Count;
|
||||
if (count > 100)
|
||||
count = 101;
|
||||
|
||||
DirLandReplyData[] data = new DirLandReplyData[count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (Object o in dataArray)
|
||||
{
|
||||
Hashtable d = (Hashtable)o;
|
||||
|
||||
data[i] = new DirLandReplyData();
|
||||
data[i].parcelID = new UUID(d["parcel_id"].ToString());
|
||||
data[i].name = d["name"].ToString();
|
||||
data[i].auction = Convert.ToBoolean(d["auction"]);
|
||||
data[i].forSale = Convert.ToBoolean(d["for_sale"]);
|
||||
data[i].salePrice = Convert.ToInt32(d["sale_price"]);
|
||||
data[i].actualArea = Convert.ToInt32(d["area"]);
|
||||
i++;
|
||||
if (i >= count)
|
||||
break;
|
||||
}
|
||||
|
||||
remoteClient.SendDirLandReply(queryID, data);
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
public void DirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
if (dataArray.Count == 0)
|
||||
{
|
||||
if ((queryFlags & 1) != 0)
|
||||
{
|
||||
DirPeopleQuery(remoteClient, queryID, queryText, queryFlags, queryStart);
|
||||
return;
|
||||
}
|
||||
else if ((queryFlags & 32) != 0)
|
||||
{
|
||||
DirEventsQuery(remoteClient, queryID, queryText, queryFlags, queryStart);
|
||||
return;
|
||||
}
|
||||
// something bad happened here, if we could return an event after the search,
|
||||
// we should be able to find it here
|
||||
// TODO do some (more) sensible error-handling here
|
||||
remoteClient.SendAgentAlertMessage("Couldn't find event.", false);
|
||||
return;
|
||||
}
|
||||
|
||||
public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
|
||||
{
|
||||
List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
|
||||
AvatarResponses = m_Scenes[0].SceneGridService.GenerateAgentPickerRequestResponse(queryID, queryText);
|
||||
Hashtable d = (Hashtable)dataArray[0];
|
||||
EventData data = new EventData();
|
||||
data.eventID = Convert.ToUInt32(d["event_id"]);
|
||||
data.creator = d["Creator"].ToString();
|
||||
data.name = d["Name"].ToString();
|
||||
data.category = d["Category"].ToString();
|
||||
data.description = d["Description"].ToString();
|
||||
data.date = DateTime.ParseExact(d["Date"].ToString(), "yyyy-MM-dd T", DateTimeFormatInfo.InvariantInfo);
|
||||
data.dateUTC = Convert.ToUInt32(d["DateUTC"]);
|
||||
data.duration = Convert.ToUInt32(d["Duration"]);
|
||||
data.cover = Convert.ToUInt32(d["Cover"]);
|
||||
data.amount = Convert.ToUInt32(d["Amount"]);
|
||||
data.simName = d["SimName"].ToString();
|
||||
Vector3.TryParse(d["GlobalPos"].ToString(), out data.globalPos);
|
||||
data.eventFlags = Convert.ToUInt32(d["EventFlags"]);
|
||||
|
||||
DirPeopleReplyData[] data = new DirPeopleReplyData[AvatarResponses.Count];
|
||||
|
||||
int i = 0;
|
||||
foreach (AvatarPickerAvatar item in AvatarResponses)
|
||||
{
|
||||
data[i] = new DirPeopleReplyData();
|
||||
|
||||
data[i].agentID = item.AvatarID;
|
||||
data[i].firstName = item.firstName;
|
||||
data[i].lastName = item.lastName;
|
||||
data[i].group = "";
|
||||
data[i].online = false;
|
||||
data[i].reputation = 0;
|
||||
i++;
|
||||
}
|
||||
|
||||
remoteClient.SendDirPeopleReply(queryID, data);
|
||||
}
|
||||
|
||||
public void DirEventsQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["text"] = queryText;
|
||||
ReqHash["flags"] = queryFlags.ToString();
|
||||
ReqHash["query_start"] = queryStart.ToString();
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"dir_events_query");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
|
||||
int count = dataArray.Count;
|
||||
if (count > 100)
|
||||
count = 101;
|
||||
|
||||
DirEventsReplyData[] data = new DirEventsReplyData[count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (Object o in dataArray)
|
||||
{
|
||||
Hashtable d = (Hashtable)o;
|
||||
|
||||
data[i] = new DirEventsReplyData();
|
||||
data[i].ownerID = new UUID(d["owner_id"].ToString());
|
||||
data[i].name = d["name"].ToString();
|
||||
data[i].eventID = Convert.ToUInt32(d["event_id"]);
|
||||
data[i].date = d["date"].ToString();
|
||||
data[i].unixTime = Convert.ToUInt32(d["unix_time"]);
|
||||
data[i].eventFlags = Convert.ToUInt32(d["event_flags"]);
|
||||
i++;
|
||||
if (i >= count)
|
||||
break;
|
||||
}
|
||||
|
||||
remoteClient.SendDirEventsReply(queryID, data);
|
||||
}
|
||||
|
||||
public void EventInfoRequest(IClientAPI remoteClient, uint queryEventID)
|
||||
{
|
||||
Hashtable ReqHash = new Hashtable();
|
||||
ReqHash["eventID"] = queryEventID;
|
||||
|
||||
Hashtable result = GenericXMLRPCRequest(ReqHash,
|
||||
"events_info_request");
|
||||
|
||||
if (!Convert.ToBoolean(result["success"]))
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage(
|
||||
result["errorMessage"].ToString(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList dataArray = (ArrayList)result["data"];
|
||||
if (dataArray.Count == 0)
|
||||
{
|
||||
// something bad happened here, if we could return an event after the search,
|
||||
// we should be able to find it here
|
||||
// TODO do some (more) sensible error-handling here
|
||||
remoteClient.SendAgentAlertMessage("Couldn't find event.", false);
|
||||
return;
|
||||
}
|
||||
|
||||
Hashtable d = (Hashtable)dataArray[0];
|
||||
EventData data = new EventData();
|
||||
data.eventID = Convert.ToUInt32(d["event_id"]);
|
||||
data.creator = d["Creator"].ToString();
|
||||
data.name = d["Name"].ToString();
|
||||
data.category = d["Category"].ToString();
|
||||
data.description = d["Description"].ToString();
|
||||
data.date = DateTime.ParseExact(d["Date"].ToString(), "yyyy-MM-dd T", DateTimeFormatInfo.InvariantInfo);
|
||||
data.dateUTC = Convert.ToUInt32(d["DateUTC"]);
|
||||
data.duration = Convert.ToUInt32(d["Duration"]);
|
||||
data.cover = Convert.ToUInt32(d["Cover"]);
|
||||
data.amount = Convert.ToUInt32(d["Amount"]);
|
||||
data.simName = d["SimName"].ToString();
|
||||
Vector3.TryParse(d["GlobalPos"].ToString(), out data.globalPos);
|
||||
data.eventFlags = Convert.ToUInt32(d["EventFlags"]);
|
||||
|
||||
remoteClient.SendEventInfoReply(data);
|
||||
remoteClient.SendEventInfoReply(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user