diff --git a/libsecondlife/Login.cs b/libsecondlife/Login.cs
index 437b14c7..a420703f 100644
--- a/libsecondlife/Login.cs
+++ b/libsecondlife/Login.cs
@@ -119,27 +119,18 @@ namespace libsecondlife
/// Seed CAPS URL returned from the login server
public string LoginSeedCapability = String.Empty;
- /// String holding the login message. Can be either a tip of
- /// the day style message or a description of the login error depending
- /// on whether the login was successful or not
- public string MOTD { get { return InternalMOTD; } }
-
/// Current state of logging in
public LoginStatus LoginStatusCode { get { return InternalStatusCode; } }
- /// Current state of logging in, in text form
- public string LoginStatusMessage { get { return InternalStatusMessage; } }
- #region BackwardsCompat
- /// Maintained for backwards compatibility
- [Obsolete("This is no longer used. If you want error messages, use the callback. If you want the MOTD, see MOTD.", false)]
- public string LoginMessage = String.Empty;
- /// Maintained for backwards compatibility
- [Obsolete("This is no longer used. If you want error messages, use the callback. If you want the MOTD, see MOTD.", false)]
- public string LoginErrorKey = String.Empty;
- /// Maintained for backwards compatibility
- [Obsolete("This has been broken up in to LoginErrorKey and LoginMessage", false)]
- public string LoginError { get { return String.Format("{0}: {1}", LoginErrorKey, LoginMessage); } }
- #endregion
+ /// Upon login failure, contains a short string key for the
+ /// type of login error that occurred
+ public string LoginErrorKey { get { return InternalErrorKey; } }
+
+ /// 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
+ /// message will be returned
+ public string LoginMessage { get { return InternalLoginMessage; } }
private class LoginContext
{
@@ -151,9 +142,9 @@ namespace libsecondlife
private object LockObject = new object();
private LoginContext CurrentContext = null;
private ManualResetEvent LoginEvent = new ManualResetEvent(false);
- private string InternalMOTD = String.Empty;
private LoginStatus InternalStatusCode = LoginStatus.None;
- private string InternalStatusMessage = String.Empty;
+ private string InternalErrorKey = String.Empty;
+ private string InternalLoginMessage = String.Empty;
///
///
@@ -264,7 +255,7 @@ namespace libsecondlife
CurrentContext.Request.Abort();
CurrentContext = null; // Will force any pending callbacks to bail out early
InternalStatusCode = LoginStatus.Failed;
- InternalStatusMessage = "Timed out";
+ InternalLoginMessage = "Timed out";
return false;
}
@@ -343,7 +334,7 @@ namespace libsecondlife
}
catch (WebException e)
{
- UpdateLoginStatus(LoginStatus.Failed, "Error opening thelogin server connection: " + e.Message);
+ UpdateLoginStatus(LoginStatus.Failed, "Error opening the login server connection: " + e.Message);
}
}
@@ -380,10 +371,13 @@ namespace libsecondlife
private void UpdateLoginStatus(LoginStatus status, string message)
{
InternalStatusCode = status;
- InternalStatusMessage = message;
+ InternalLoginMessage = message;
if (OnLogin != null)
- OnLogin(status, message);
+ {
+ try { OnLogin(status, message); }
+ catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); }
+ }
if (status == LoginStatus.Success || status == LoginStatus.Failed)
{
@@ -502,7 +496,8 @@ namespace libsecondlife
IPAddress simIP = IPAddress.Loopback;
ushort simPort = 0;
bool loginSuccess = false;
- string reason = null;
+ string reason = String.Empty;
+ string message = String.Empty;
reader.ReadStartElement("methodResponse");
@@ -533,6 +528,7 @@ namespace libsecondlife
break;
case "reason":
reason = ReadStringValue(reader);
+ InternalErrorKey = reason;
break;
case "agent_id":
LLUUID.TryParse(ReadStringValue(reader), out Client.Network.AgentID);
@@ -582,7 +578,7 @@ namespace libsecondlife
Client.Self.AgentAccess = ReadStringValue(reader);
break;
case "message":
- InternalMOTD = ReadStringValue(reader);
+ message = ReadStringValue(reader);
break;
case "region_x":
//FIXME:
@@ -957,7 +953,8 @@ namespace libsecondlife
// Request the economy data right after login
SendPacket(new EconomyDataRequestPacket());
- UpdateLoginStatus(LoginStatus.Success, "Connected to simulator");
+ // Update the login message with the MOTD returned from the server
+ UpdateLoginStatus(LoginStatus.Success, message);
// Fire an event for connecting to the grid
if (OnConnected != null)
@@ -973,10 +970,13 @@ namespace libsecondlife
}
else
{
- if (reason != null)
- UpdateLoginStatus(LoginStatus.Failed, reason);
+ // Make sure a usable error key is set
+ if (!String.IsNullOrEmpty(reason))
+ InternalErrorKey = reason;
else
- UpdateLoginStatus(LoginStatus.Failed, "Unspecified reason and/or bad response from login server");
+ InternalErrorKey = "unknown";
+
+ UpdateLoginStatus(LoginStatus.Failed, message);
}
}
else
diff --git a/libsecondlife/examples/Heightmap/frmHeightmap.cs b/libsecondlife/examples/Heightmap/frmHeightmap.cs
index 9deee285..96cb60a6 100644
--- a/libsecondlife/examples/Heightmap/frmHeightmap.cs
+++ b/libsecondlife/examples/Heightmap/frmHeightmap.cs
@@ -66,7 +66,7 @@ namespace Heightmap
if (!Client.Network.Login(FirstName, LastName, Password, "Heightmap", "jhurliman@wsu.edu"))
{
- Console.WriteLine("Login failed: " + Client.Network.LoginStatusMessage);
+ Console.WriteLine("Login failed: " + Client.Network.LoginMessage);
Console.ReadKey();
this.Close();
return;
diff --git a/libsecondlife/examples/IA_ImageTool/ImageTool.cs b/libsecondlife/examples/IA_ImageTool/ImageTool.cs
index b4cdac96..e4934f1e 100644
--- a/libsecondlife/examples/IA_ImageTool/ImageTool.cs
+++ b/libsecondlife/examples/IA_ImageTool/ImageTool.cs
@@ -132,7 +132,7 @@ namespace IA_ImageTool
if (!_Client.Network.Login(FirstName, LastName, Password, "ImageTool", "static.sprocket@gmail.com"))
{
// Login failed
- Console.WriteLine("Error logging in: " + _Client.Network.LoginStatusMessage);
+ Console.WriteLine("Error logging in: " + _Client.Network.LoginMessage);
return false;
}
diff --git a/libsecondlife/examples/IA_NotecardTool/NotecardTool.cs b/libsecondlife/examples/IA_NotecardTool/NotecardTool.cs
index c43a7695..46faff2c 100644
--- a/libsecondlife/examples/IA_NotecardTool/NotecardTool.cs
+++ b/libsecondlife/examples/IA_NotecardTool/NotecardTool.cs
@@ -118,7 +118,7 @@ namespace IA_NotecardTool
if (!_Client.Network.Login(FirstName, LastName, Password, "createnotecard", "static.sprocket@gmail.com"))
{
// Login failed
- Console.WriteLine("Error logging in: " + _Client.Network.LoginStatusMessage);
+ Console.WriteLine("Error logging in: " + _Client.Network.LoginMessage);
return false;
}
diff --git a/libsecondlife/examples/IA_SimpleInventory/IA_SimpleInventory.cs b/libsecondlife/examples/IA_SimpleInventory/IA_SimpleInventory.cs
index a1c3e1ab..cce63417 100644
--- a/libsecondlife/examples/IA_SimpleInventory/IA_SimpleInventory.cs
+++ b/libsecondlife/examples/IA_SimpleInventory/IA_SimpleInventory.cs
@@ -93,7 +93,7 @@ namespace IA_SimpleInventory
if (!client.Network.Login(FirstName, LastName, Password, "IA_SimpleInventory", "static.sprocket@gmail.com"))
{
// Login failed
- Console.WriteLine("Error logging in: " + client.Network.LoginStatusMessage);
+ Console.WriteLine("Error logging in: " + client.Network.LoginMessage);
return false;
}
diff --git a/libsecondlife/examples/Key2Name/key2name.cs b/libsecondlife/examples/Key2Name/key2name.cs
index a4e9465e..3135b57b 100644
--- a/libsecondlife/examples/Key2Name/key2name.cs
+++ b/libsecondlife/examples/Key2Name/key2name.cs
@@ -21,7 +21,7 @@ namespace Key2Name
if (!client.Network.Login(args[0], args[1], args[2], "key2name", "jessemalthus@gmail.com"))
{
// Login failed
- Console.WriteLine("Error logging in: " + client.Network.LoginStatusMessage);
+ Console.WriteLine("Error logging in: " + client.Network.LoginMessage);
return;
}
diff --git a/libsecondlife/examples/TestClient/ClientManager.cs b/libsecondlife/examples/TestClient/ClientManager.cs
index 0e431427..db1df60b 100644
--- a/libsecondlife/examples/TestClient/ClientManager.cs
+++ b/libsecondlife/examples/TestClient/ClientManager.cs
@@ -114,7 +114,7 @@ namespace libsecondlife.TestClient
contactPerson))
{
Console.WriteLine("Failed to login " + account.FirstName + " " + account.LastName + ": " +
- client.Network.LoginStatusMessage);
+ client.Network.LoginMessage);
}
}
diff --git a/libsecondlife/examples/TestClient/Commands/LoginCommand.cs b/libsecondlife/examples/TestClient/Commands/LoginCommand.cs
index 64675f51..737ad406 100644
--- a/libsecondlife/examples/TestClient/Commands/LoginCommand.cs
+++ b/libsecondlife/examples/TestClient/Commands/LoginCommand.cs
@@ -27,7 +27,7 @@ namespace libsecondlife.TestClient
}
else
{
- return "Failed to login: " + newClient.Network.LoginStatusMessage;
+ return "Failed to login: " + newClient.Network.LoginMessage;
}
}
}
diff --git a/libsecondlife/examples/groupmanager/frmGroupManager.cs b/libsecondlife/examples/groupmanager/frmGroupManager.cs
index f5a112fa..f9a0a240 100644
--- a/libsecondlife/examples/groupmanager/frmGroupManager.cs
+++ b/libsecondlife/examples/groupmanager/frmGroupManager.cs
@@ -75,7 +75,7 @@ namespace groupmanager
}
else
{
- MessageBox.Show(this, "Error logging in: " + Client.Network.LoginStatusMessage);
+ MessageBox.Show(this, "Error logging in: " + Client.Network.LoginMessage);
cmdConnect.Text = "Connect";
txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
groupBox.Enabled = false;
diff --git a/libsecondlife/examples/name2key/name2key.cs b/libsecondlife/examples/name2key/name2key.cs
index d073b0a4..675238f6 100644
--- a/libsecondlife/examples/name2key/name2key.cs
+++ b/libsecondlife/examples/name2key/name2key.cs
@@ -81,7 +81,7 @@ namespace name2key
if (!client.Network.Login(args[0], args[1], args[2], "name2key", "jhurliman@wsu.edu"))
{
// Login failed
- Console.WriteLine("ERROR: " + client.Network.LoginStatusMessage);
+ Console.WriteLine("ERROR: " + client.Network.LoginMessage);
return;
}
diff --git a/libsecondlife/examples/primexport/frmPrimExport.cs b/libsecondlife/examples/primexport/frmPrimExport.cs
index 3b62eafb..6af868bb 100644
--- a/libsecondlife/examples/primexport/frmPrimExport.cs
+++ b/libsecondlife/examples/primexport/frmPrimExport.cs
@@ -589,7 +589,7 @@ namespace primexport
}
else
{
- MessageBox.Show(this, "Error logging in: " + client.Network.LoginStatusMessage);
+ MessageBox.Show(this, "Error logging in: " + client.Network.LoginMessage);
cmdConnect.Text = "Connect";
txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
}
diff --git a/libsecondlife/examples/slaccountant/frmSLAccountant.cs b/libsecondlife/examples/slaccountant/frmSLAccountant.cs
index 860a4f4e..18a2a2a9 100644
--- a/libsecondlife/examples/slaccountant/frmSLAccountant.cs
+++ b/libsecondlife/examples/slaccountant/frmSLAccountant.cs
@@ -440,7 +440,7 @@ namespace SLAccountant
}
else
{
- MessageBox.Show(this, "Error logging in: " + client.Network.LoginStatusMessage);
+ MessageBox.Show(this, "Error logging in: " + client.Network.LoginMessage);
cmdConnect.Text = "Connect";
txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
txtFind.Enabled = cmdFind.Enabled = false;
diff --git a/libsecondlife/examples/sldump/sldump.cs b/libsecondlife/examples/sldump/sldump.cs
index dfd2ad1a..b94d9966 100644
--- a/libsecondlife/examples/sldump/sldump.cs
+++ b/libsecondlife/examples/sldump/sldump.cs
@@ -124,11 +124,11 @@ namespace sldump
if (!LoginSuccess)
{
- Console.WriteLine("Login failed: {0}", client.Network.LoginStatusMessage);
+ Console.WriteLine("Login failed: {0}", client.Network.LoginMessage);
return;
}
- Console.WriteLine("Message of the day: " + client.Network.MOTD);
+ Console.WriteLine("Message of the day: " + client.Network.LoginMessage);
int start = Environment.TickCount;
int milliseconds = Int32.Parse(args[3]) * 1000;
diff --git a/libsecondlife/libsecondlife.Utilities/Utilities.cs b/libsecondlife/libsecondlife.Utilities/Utilities.cs
index e24bb534..be8f9329 100644
--- a/libsecondlife/libsecondlife.Utilities/Utilities.cs
+++ b/libsecondlife/libsecondlife.Utilities/Utilities.cs
@@ -120,29 +120,29 @@ namespace libsecondlife.Utilities
}
else
{
- if (client.Network.LoginStatusMessage == "god")
+ if (client.Network.LoginErrorKey == "god")
{
client.Log("Grid is down, waiting 10 minutes", Helpers.LogLevel.Warning);
LoginWait(10);
goto Start;
}
- else if (client.Network.LoginStatusMessage == "key")
+ else if (client.Network.LoginErrorKey == "key")
{
client.Log("Bad username or password, giving up on login", Helpers.LogLevel.Error);
return false;
}
- else if (client.Network.LoginStatusMessage == "presence")
+ else if (client.Network.LoginErrorKey == "presence")
{
client.Log("Server is still logging us out, waiting 1 minute", Helpers.LogLevel.Warning);
LoginWait(1);
goto Start;
}
- else if (client.Network.LoginStatusMessage == "disabled")
+ else if (client.Network.LoginErrorKey == "disabled")
{
client.Log("This account has been banned! Giving up on login", Helpers.LogLevel.Error);
return false;
}
- else if (client.Network.LoginStatusMessage == "timed out")
+ else if (client.Network.LoginErrorKey == "timed out")
{
client.Log("Login request timed out, waiting 1 minute", Helpers.LogLevel.Warning);
LoginWait(1);
@@ -154,7 +154,7 @@ namespace libsecondlife.Utilities
if (unknownLogins < 5)
{
- client.Log("Unknown login error, waiting 2 minutes: " + client.Network.LoginStatusMessage,
+ client.Log("Unknown login error, waiting 2 minutes: " + client.Network.LoginErrorKey,
Helpers.LogLevel.Warning);
LoginWait(2);
goto Start;