[invitation] add early logic

This commit is contained in:
Hylke Bons 2010-08-14 19:11:22 +01:00
parent 4475c27000
commit 2acd8fa1f0
2 changed files with 32 additions and 6 deletions

View file

@ -22,9 +22,17 @@ namespace SparkleShare {
class SparkleInvitation {
public string Server;
public string Repository;
public string Key;
public SparkleInvitation (string file_path)
{
if (!File.Exists (file_path))
return;
XmlDocument xml_doc = new XmlDocument ();
xml_doc.Load (file_path);
@ -32,9 +40,18 @@ namespace SparkleShare {
XmlNodeList repository_xml = xml_doc.GetElementsByTagName ("repository");
XmlNodeList key_xml = xml_doc.GetElementsByTagName ("key");
string server = server_xml [0].InnerText;
string repository = repository_xml [0].InnerText;
string key = key_xml [0].InnerText;
Server = server_xml [0].InnerText;
Repository = repository_xml [0].InnerText;
Key = key_xml [0].InnerText;
}
public void Activate ()
{
string url = "http://" + Server + "/repo=" + Repository + "&key=" + Key;
Console.WriteLine (url);
}

View file

@ -49,8 +49,6 @@ namespace SparkleShare {
BusG.Init ();
Gtk.Application.Init ();
// SparkleInvitation i = new SparkleInvitation ("/home/hbons/SparkleShare/sparkleshare.invitation");
SetProcessName ("sparkleshare");
Repositories = new List <SparkleRepo> ();
@ -89,7 +87,18 @@ namespace SparkleShare {
watcher.Created += delegate (object o, FileSystemEventArgs args) {
AddRepository (args.FullPath);
if (args.Name.EndsWith ("sparkleshare.invitation")) {
SparkleInvitation invitation;
invitation = new SparkleInvitation (args.FullPath);
invitation.Activate ();
} else if (Directory.Exists (args.FullPath)) {
AddRepository (args.FullPath);
}
};