| 1 |
using System; |
using System; |
| 2 |
using System.Collections.Generic; |
using System.Collections.Generic; |
| 3 |
|
using System.Reflection; |
| 4 |
using System.Text; |
using System.Text; |
| 5 |
using OpenMetaverse; |
using OpenMetaverse; |
| 6 |
using OpenMetaverse.Rendering; |
using OpenMetaverse.Rendering; |
| 7 |
|
using log4net; |
| 8 |
|
|
| 9 |
|
|
| 10 |
namespace IdealistViewer |
namespace IdealistViewer |
| 11 |
{ |
{ |
| 12 |
public class SLProtocol |
public class SLProtocol |
| 13 |
{ |
{ |
| 14 |
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
| 15 |
|
|
| 16 |
public delegate void GridConnected(); |
public delegate void GridConnected(); |
| 17 |
public delegate void Chat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, |
public delegate void Chat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, |
| 18 |
string fromName, UUID id, UUID ownerid, Vector3 position); |
string fromName, UUID id, UUID ownerid, Vector3 position); |
| 82 |
} |
} |
| 83 |
} |
} |
| 84 |
|
|
| 85 |
public void BeginLogin(string loginURI, string username, string password) |
public void BeginLogin(string loginURI, string username, string password, string startlocation) |
| 86 |
{ |
{ |
| 87 |
LoginParams loginParams = getLoginParams(loginURI, username, password); |
LoginParams loginParams = getLoginParams(loginURI, username, password, startlocation); |
| 88 |
|
|
| 89 |
m_user.Network.BeginLogin(loginParams); |
m_user.Network.BeginLogin(loginParams); |
| 90 |
} |
} |
| 151 |
m_user.Self.Chat(message, 0, ChatType.Shout); |
m_user.Self.Chat(message, 0, ChatType.Shout); |
| 152 |
} |
} |
| 153 |
|
|
| 154 |
private LoginParams getLoginParams(string loginURI, string username, string password) |
private LoginParams getLoginParams(string loginURI, string username, string password, string startlocation) |
| 155 |
{ |
{ |
| 156 |
string firstname; |
string firstname; |
| 157 |
string lastname; |
string lastname; |
| 161 |
LoginParams loginParams = m_user.Network.DefaultLoginParams( |
LoginParams loginParams = m_user.Network.DefaultLoginParams( |
| 162 |
firstname, lastname, password, "IdealistViewer", "0.0.0.1");//Constants.Version); |
firstname, lastname, password, "IdealistViewer", "0.0.0.1");//Constants.Version); |
| 163 |
|
|
| 164 |
loginParams.URI = Util.getSaneLoginURI(loginURI); |
|
| 165 |
|
loginURI = Util.getSaneLoginURI(loginURI); |
| 166 |
|
|
| 167 |
|
if (startlocation.Length == 0) |
| 168 |
|
{ |
| 169 |
|
|
| 170 |
|
if (!loginURI.EndsWith("/")) |
| 171 |
|
loginURI += "/"; |
| 172 |
|
|
| 173 |
|
string[] locationparse = loginURI.Split('/'); |
| 174 |
|
try |
| 175 |
|
{ |
| 176 |
|
startlocation = locationparse[locationparse.Length - 2]; |
| 177 |
|
if (startlocation == locationparse[2]) |
| 178 |
|
{ |
| 179 |
|
startlocation = "last"; |
| 180 |
|
} |
| 181 |
|
else |
| 182 |
|
{ |
| 183 |
|
loginURI = ""; |
| 184 |
|
for (int i = 0; i < locationparse.Length - 2; i++) |
| 185 |
|
{ |
| 186 |
|
loginURI += locationparse[i] + "/"; |
| 187 |
|
} |
| 188 |
|
} |
| 189 |
|
|
| 190 |
|
} |
| 191 |
|
catch (Exception) |
| 192 |
|
{ |
| 193 |
|
startlocation = "last"; |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
} |
| 197 |
|
else |
| 198 |
|
{ |
| 199 |
|
|
| 200 |
|
|
| 201 |
|
if (!loginURI.EndsWith("/")) |
| 202 |
|
loginURI += "/"; |
| 203 |
|
|
| 204 |
|
string[] locationparse = loginURI.Split('/'); |
| 205 |
|
try |
| 206 |
|
{ |
| 207 |
|
string end = locationparse[locationparse.Length - 2]; |
| 208 |
|
if (end != locationparse[2]) |
| 209 |
|
{ |
| 210 |
|
loginURI = ""; |
| 211 |
|
for (int i = 0; i < 3; i++) |
| 212 |
|
{ |
| 213 |
|
if (locationparse[i].Length != 0 || i==1) |
| 214 |
|
loginURI += locationparse[i] + "/"; |
| 215 |
|
} |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
} |
| 219 |
|
catch (Exception) |
| 220 |
|
{ |
| 221 |
|
//startlocation = "last"; |
| 222 |
|
m_log.Warn("[URLPARSING]: Unable to parse URL provided!"); |
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
|
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
loginParams.URI = loginURI; |
| 229 |
|
loginParams.Start = startlocation; |
| 230 |
|
|
| 231 |
return loginParams; |
return loginParams; |
| 232 |
} |
} |