Skip to content

Commit

Permalink
invite: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hbons committed Feb 11, 2012
1 parent bb1ae7c commit cded663
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
1 change: 0 additions & 1 deletion SparkleShare/SparkleControllerBase.cs
Expand Up @@ -130,7 +130,6 @@ public virtual void Initialize ()
SparkleInviteListener invite_listener = new SparkleInviteListener (1987);

invite_listener.InviteReceived += delegate (SparkleInvite invite) {

if (OnInvite != null && !FirstRun)
OnInvite (invite);
};
Expand Down
39 changes: 34 additions & 5 deletions SparkleShare/SparkleInvite.cs
Expand Up @@ -60,7 +60,37 @@ public SparkleInvite (string host, string path, string token)

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;
}
}

Expand Down Expand Up @@ -168,9 +198,8 @@ private void HandleClient (object client)

XmlDocument xml_document = new XmlDocument ();
XmlNode node;
string host = "";
string path = "";
string token = "";

string host = "", path = "", token = "";

try {
xml_document.LoadXml (invite_xml);
Expand All @@ -185,7 +214,7 @@ private void HandleClient (object client)
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;
}

Expand Down

0 comments on commit cded663

Please sign in to comment.