invite: cleanup

This commit is contained in:
Hylke Bons 2012-02-11 19:52:49 +01:00
parent cc0098b6aa
commit 9ddcb28ef9
2 changed files with 34 additions and 6 deletions

View file

@ -130,7 +130,6 @@ namespace SparkleShare {
SparkleInviteListener invite_listener = new SparkleInviteListener (1987);
invite_listener.InviteReceived += delegate (SparkleInvite invite) {
if (OnInvite != null && !FirstRun)
OnInvite (invite);
};

View file

@ -60,7 +60,37 @@ namespace SparkleShare {
public SparkleInvite (string xml_file_path)
{
// TODO
XmlDocument xml_document = new XmlDocument ();
XmlNode node;
string host = "", path = "", token = "";
try {
xml_document.Load (xml_file_path);
node = xml_document.SelectSingleNode ("/sparkleshare/invite/host/text()");
if (node != null) { host = node.Value; }
node = xml_document.SelectSingleNode ("/sparkleshare/invite/path/text()");
if (node != null) { path = node.Value; }
node = xml_document.SelectSingleNode ("/sparkleshare/invite/token/text()");
if (node != null) { token = node.Value; }
} catch (XmlException e) {
SparkleHelpers.DebugInfo ("Invite", "Invalid XML: " + e.Message);
return;
}
if (path.StartsWith ("/"))
path = path.Substring (1);
if (!host.EndsWith ("/"))
host = host + "/";
FullAddress = new Uri ("ssh://" + host + path);
Token = token;
}
}
@ -168,9 +198,8 @@ namespace SparkleShare {
XmlDocument xml_document = new XmlDocument ();
XmlNode node;
string host = "";
string path = "";
string token = "";
string host = "", path = "", token = "";
try {
xml_document.LoadXml (invite_xml);
@ -185,7 +214,7 @@ namespace SparkleShare {
if (node != null) { token = node.Value; }
} catch (XmlException e) {
SparkleHelpers.DebugInfo ("Invite", "Not valid XML: " + received_message + " " + e.Message);
SparkleHelpers.DebugInfo ("Invite", "Invalid XML: " + received_message + " " + e.Message);
return;
}