From 7e306ebb29a9cdafae366522d3038b8169ac5caa Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 14 May 2007 10:18:54 +0000 Subject: [PATCH] * Login no longer writes loginreply.xml in debug mode. Instead NetworkManager.RawLoginReply was added to access the raw XML-RPC response * DirectoryManager.StartPeopleSearch() now takes a queryStart parameter to allow searching past the first 100 results (fixes issue 115, thanks DeltaCzuk) git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1188 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/DirectoryManager.cs | 4 +- libsecondlife/Login.cs | 58 +++++++++---------- .../examples/TestClient/ClientManager.cs | 2 +- .../TestClient/Commands/SetMasterCommand.cs | 2 +- libsecondlife/examples/name2key/name2key.cs | 2 +- 5 files changed, 33 insertions(+), 35 deletions(-) diff --git a/libsecondlife/DirectoryManager.cs b/libsecondlife/DirectoryManager.cs index 5898ba1a..4ae8705c 100644 --- a/libsecondlife/DirectoryManager.cs +++ b/libsecondlife/DirectoryManager.cs @@ -341,7 +341,7 @@ namespace libsecondlife return queryID; } - public LLUUID StartPeopleSearch(DirFindFlags findFlags, String searchText) + public LLUUID StartPeopleSearch(DirFindFlags findFlags, string searchText, int queryStart) { LLUUID queryID = LLUUID.Random(); DirFindQueryPacket find = new DirFindQueryPacket(); @@ -350,7 +350,7 @@ namespace libsecondlife find.QueryData.QueryFlags = (uint)findFlags; find.QueryData.QueryText = Helpers.StringToField(searchText); find.QueryData.QueryID = queryID; - find.QueryData.QueryStart = 0; + find.QueryData.QueryStart = queryStart; Client.Network.SendPacket(find); return queryID; } diff --git a/libsecondlife/Login.cs b/libsecondlife/Login.cs index a420703f..88263383 100644 --- a/libsecondlife/Login.cs +++ b/libsecondlife/Login.cs @@ -126,6 +126,10 @@ namespace libsecondlife /// type of login error that occurred public string LoginErrorKey { get { return InternalErrorKey; } } + /// The raw XML-RPC reply from the login server, exactly as it + /// was received (minus the HTTP header) + public string RawLoginReply { get { return InternalRawLoginReply; } } + /// During login this contains a descriptive version of /// LoginStatusCode. After a successful login this will contain the /// message of the day, and after a failed login a descriptive error @@ -145,6 +149,7 @@ namespace libsecondlife private LoginStatus InternalStatusCode = LoginStatus.None; private string InternalErrorKey = String.Empty; private string InternalLoginMessage = String.Empty; + private string InternalRawLoginReply = String.Empty; /// /// @@ -453,38 +458,31 @@ namespace libsecondlife xmlStream = response.GetResponseStream(); - if (Client.Settings.DEBUG) + MemoryStream memStream = new MemoryStream(); + BinaryReader streamReader = new BinaryReader(xmlStream); + BinaryWriter streamWriter = new BinaryWriter(memStream); + + // Put the entire response in to a byte array + byte[] buffer; + while ((buffer = streamReader.ReadBytes(1024)) != null) { - try - { - MemoryStream memStream = new MemoryStream(); - BinaryReader streamReader = new BinaryReader(xmlStream); - BinaryWriter streamWriter = new BinaryWriter(memStream); - - byte[] buffer; - while ((buffer = streamReader.ReadBytes(1024)) != null) - { - if (buffer.Length == 0) - break; - streamWriter.Write(buffer); - } - streamWriter.Flush(); - xmlStream.Close(); - xmlStream = memStream; - - memStream.Seek(0, SeekOrigin.Begin); - FileStream fileStream = File.Open("loginreply.xml", FileMode.Create, FileAccess.Write, FileShare.Read); - memStream.WriteTo(fileStream); - memStream.Seek(0, SeekOrigin.Begin); - fileStream.Close(); - memStream.Seek(0, SeekOrigin.Begin); - } - catch (Exception) - { - // This is debug code, we don't care if we fail for whatever reason, like another SL instance is already - // writing the file - } + if (buffer.Length == 0) + break; + streamWriter.Write(buffer); } + streamWriter.Flush(); + xmlStream.Close(); + + // Write the entire memory stream out to a byte array + buffer = memStream.ToArray(); + + // Reset the position in the stream to the beginning + memStream.Seek(0, SeekOrigin.Begin); + + // The memory stream will become an XML stream shortly + xmlStream = memStream; + + InternalRawLoginReply = Encoding.UTF8.GetString(buffer); reader = XmlReader.Create(xmlStream); diff --git a/libsecondlife/examples/TestClient/ClientManager.cs b/libsecondlife/examples/TestClient/ClientManager.cs index db1df60b..e8d46a71 100644 --- a/libsecondlife/examples/TestClient/ClientManager.cs +++ b/libsecondlife/examples/TestClient/ClientManager.cs @@ -126,7 +126,7 @@ namespace libsecondlife.TestClient // Find master's key from name DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler); client.Directory.OnDirPeopleReply += callback; - client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, account.MasterName); + client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, account.MasterName, 0); if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false)) { account.MasterKey = resolvedMasterKey; diff --git a/libsecondlife/examples/TestClient/Commands/SetMasterCommand.cs b/libsecondlife/examples/TestClient/Commands/SetMasterCommand.cs index a6ecbdcb..66f009ef 100644 --- a/libsecondlife/examples/TestClient/Commands/SetMasterCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/SetMasterCommand.cs @@ -33,7 +33,7 @@ namespace libsecondlife.TestClient DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler); Client.Directory.OnDirPeopleReply += callback; - query = Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, masterName); + query = Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, masterName, 0); if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false)) { Client.MasterKey = resolvedMasterKey; diff --git a/libsecondlife/examples/name2key/name2key.cs b/libsecondlife/examples/name2key/name2key.cs index 675238f6..a0afd3e1 100644 --- a/libsecondlife/examples/name2key/name2key.cs +++ b/libsecondlife/examples/name2key/name2key.cs @@ -86,7 +86,7 @@ namespace name2key } // Send the Query - queryID = client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, args[3] + " " + args[4]); + queryID = client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, args[3] + " " + args[4], 0); // Wait for the event to trigger queryEvent.WaitOne(8000, false);