Refactor config and merge with Paths
This commit is contained in:
parent
cd6c77398f
commit
fd62154f6c
|
@ -73,7 +73,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public override bool Fetch ()
|
public override bool Fetch ()
|
||||||
{
|
{
|
||||||
SparkleGit git = new SparkleGit (SparklePaths.SparkleTmpPath,
|
SparkleGit git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
|
||||||
"clone \"" + base.remote_url + "\" " + "\"" + base.target_folder + "\"");
|
"clone \"" + base.remote_url + "\" " + "\"" + base.target_folder + "\"");
|
||||||
|
|
||||||
git.Start ();
|
git.Start ();
|
||||||
|
@ -95,7 +95,7 @@ namespace SparkleLib {
|
||||||
// the newly cloned repository
|
// the newly cloned repository
|
||||||
private void InstallConfiguration ()
|
private void InstallConfiguration ()
|
||||||
{
|
{
|
||||||
string global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config.xml");
|
string global_config_file_path = Path.Combine (SparkleConfig.DefaultConfig.TmpPath, "config.xml");
|
||||||
|
|
||||||
if (!File.Exists (global_config_file_path))
|
if (!File.Exists (global_config_file_path))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -320,7 +320,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
// Append a timestamp to local version
|
// Append a timestamp to local version
|
||||||
string timestamp = DateTime.Now.ToString ("HH:mm MMM d");
|
string timestamp = DateTime.Now.ToString ("HH:mm MMM d");
|
||||||
string their_path = conflicting_path + " (" + SparkleConfig.DefaultConfig.UserName + ", " + timestamp + ")";
|
string their_path = conflicting_path + " (" + SparkleConfig.DefaultConfig.User.Name + ", " + timestamp + ")";
|
||||||
string abs_conflicting_path = Path.Combine (LocalPath, conflicting_path);
|
string abs_conflicting_path = Path.Combine (LocalPath, conflicting_path);
|
||||||
string abs_their_path = Path.Combine (LocalPath, their_path);
|
string abs_their_path = Path.Combine (LocalPath, their_path);
|
||||||
|
|
||||||
|
@ -437,9 +437,9 @@ namespace SparkleLib {
|
||||||
|
|
||||||
change_set.Folder = Name;
|
change_set.Folder = Name;
|
||||||
change_set.Revision = match.Groups [1].Value;
|
change_set.Revision = match.Groups [1].Value;
|
||||||
change_set.UserName = match.Groups [2].Value;
|
change_set.User.Name = match.Groups [2].Value;
|
||||||
change_set.UserEmail = match.Groups [3].Value;
|
change_set.User.Email = match.Groups [3].Value;
|
||||||
change_set.IsMerge = is_merge_commit;
|
change_set.IsMagical = is_merge_commit;
|
||||||
|
|
||||||
change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value),
|
change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value),
|
||||||
int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),
|
int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),
|
||||||
|
|
|
@ -234,11 +234,13 @@ namespace SparkleLib {
|
||||||
|
|
||||||
SparkleChangeSet change_set = new SparkleChangeSet () {
|
SparkleChangeSet change_set = new SparkleChangeSet () {
|
||||||
Revision = match.Groups [9].Value,
|
Revision = match.Groups [9].Value,
|
||||||
UserName = match.Groups [7].Value.Trim (),
|
IsMagical = is_merge_commit
|
||||||
UserEmail = match.Groups [8].Value,
|
|
||||||
IsMerge = is_merge_commit
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
change_set.User.Name = match.Groups [7].Value.Trim ();
|
||||||
|
change_set.User.Email = match.Groups [8].Value;
|
||||||
|
|
||||||
|
|
||||||
change_set.Timestamp = new DateTime (int.Parse (match.Groups [1].Value),
|
change_set.Timestamp = new DateTime (int.Parse (match.Groups [1].Value),
|
||||||
int.Parse (match.Groups [2].Value), int.Parse (match.Groups [3].Value),
|
int.Parse (match.Groups [2].Value), int.Parse (match.Groups [3].Value),
|
||||||
int.Parse (match.Groups [4].Value), int.Parse (match.Groups [5].Value), 0);
|
int.Parse (match.Groups [4].Value), int.Parse (match.Groups [5].Value), 0);
|
||||||
|
|
|
@ -11,10 +11,6 @@ SOURCES = \
|
||||||
Defines.cs \
|
Defines.cs \
|
||||||
Git/SparkleFetcherGit.cs \
|
Git/SparkleFetcherGit.cs \
|
||||||
Git/SparkleRepoGit.cs \
|
Git/SparkleRepoGit.cs \
|
||||||
Hg/SparkleFetcherHg.cs \
|
|
||||||
Hg/SparkleRepoHg.cs \
|
|
||||||
Scp/SparkleFetcherScp.cs \
|
|
||||||
Scp/SparkleRepoScp.cs \
|
|
||||||
SparkleBackend.cs \
|
SparkleBackend.cs \
|
||||||
SparkleChangeSet.cs \
|
SparkleChangeSet.cs \
|
||||||
SparkleConfig.cs \
|
SparkleConfig.cs \
|
||||||
|
@ -24,7 +20,6 @@ SOURCES = \
|
||||||
SparkleListenerIrc.cs \
|
SparkleListenerIrc.cs \
|
||||||
SparkleListenerTcp.cs \
|
SparkleListenerTcp.cs \
|
||||||
SparkleOptions.cs \
|
SparkleOptions.cs \
|
||||||
SparklePaths.cs \
|
|
||||||
SparkleRepoBase.cs \
|
SparkleRepoBase.cs \
|
||||||
SparkleWatcher.cs
|
SparkleWatcher.cs
|
||||||
|
|
||||||
|
|
|
@ -16,20 +16,20 @@
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SparkleLib {
|
namespace SparkleLib {
|
||||||
|
|
||||||
public class SparkleChangeSet {
|
public class SparkleChangeSet {
|
||||||
|
|
||||||
public string UserName;
|
public SparkleUser User = new SparkleUser ("Unknown", "Unknown");
|
||||||
public string UserEmail;
|
|
||||||
|
|
||||||
public string Folder;
|
public string Folder;
|
||||||
public string Revision;
|
public string Revision;
|
||||||
public DateTime Timestamp;
|
public DateTime Timestamp;
|
||||||
public DateTime FirstTimestamp;
|
public DateTime FirstTimestamp;
|
||||||
public bool IsMerge = false;
|
public bool IsMagical = false;
|
||||||
|
|
||||||
public List<string> Added = new List<string> ();
|
public List<string> Added = new List<string> ();
|
||||||
public List<string> Deleted = new List<string> ();
|
public List<string> Deleted = new List<string> ();
|
||||||
|
@ -89,5 +89,31 @@ namespace SparkleLib {
|
||||||
public string Email;
|
public string Email;
|
||||||
|
|
||||||
public string PublicKey;
|
public string PublicKey;
|
||||||
|
|
||||||
|
|
||||||
|
public SparkleUser (string name, string email)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Email = email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class SparkleFolder {
|
||||||
|
|
||||||
|
public string Name;
|
||||||
|
// TODO: Uri
|
||||||
|
|
||||||
|
public string FullPath {
|
||||||
|
get {
|
||||||
|
return Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SparkleFolder (string name)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,15 +26,33 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public class SparkleConfig : XmlDocument {
|
public class SparkleConfig : XmlDocument {
|
||||||
|
|
||||||
public static SparkleConfig DefaultConfig = new SparkleConfig (
|
public static string ConfigPath = Path.Combine (
|
||||||
SparklePaths.SparkleConfigPath, "config.xml");
|
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
|
||||||
|
"sparkleshare");
|
||||||
|
|
||||||
public string Path;
|
public static SparkleConfig DefaultConfig = new SparkleConfig (
|
||||||
|
ConfigPath, "config.xml");
|
||||||
|
|
||||||
|
|
||||||
|
public string FullPath;
|
||||||
|
|
||||||
|
public string HomePath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
||||||
|
public string TmpPath;
|
||||||
|
|
||||||
|
public string FoldersPath {
|
||||||
|
get {
|
||||||
|
if (GetConfigOption ("folders_path") != null)
|
||||||
|
return GetConfigOption ("folders_path");
|
||||||
|
else
|
||||||
|
return Path.Combine (HomePath, "SparkleShare");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public SparkleConfig (string config_path, string config_file_name)
|
public SparkleConfig (string config_path, string config_file_name)
|
||||||
{
|
{
|
||||||
Path = System.IO.Path.Combine (config_path, config_file_name);
|
FullPath = System.IO.Path.Combine (config_path, config_file_name);
|
||||||
|
TmpPath = Path.Combine (FoldersPath, ".tmp");
|
||||||
|
|
||||||
if (!Directory.Exists (config_path)) {
|
if (!Directory.Exists (config_path)) {
|
||||||
Directory.CreateDirectory (config_path);
|
Directory.CreateDirectory (config_path);
|
||||||
|
@ -47,10 +65,10 @@ namespace SparkleLib {
|
||||||
SparkleHelpers.DebugInfo ("Config", "Created \"" + icons_path + "\"");
|
SparkleHelpers.DebugInfo ("Config", "Created \"" + icons_path + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!File.Exists (Path))
|
if (!File.Exists (FullPath))
|
||||||
CreateInitialConfig ();
|
CreateInitialConfig ();
|
||||||
|
|
||||||
Load (Path);
|
Load (FullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +92,7 @@ namespace SparkleLib {
|
||||||
if (string.IsNullOrEmpty (user_name))
|
if (string.IsNullOrEmpty (user_name))
|
||||||
user_name = "Unknown";
|
user_name = "Unknown";
|
||||||
|
|
||||||
TextWriter writer = new StreamWriter (Path);
|
TextWriter writer = new StreamWriter (FullPath);
|
||||||
string n = Environment.NewLine;
|
string n = Environment.NewLine;
|
||||||
|
|
||||||
writer.Write ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + n +
|
writer.Write ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + n +
|
||||||
|
@ -86,36 +104,31 @@ namespace SparkleLib {
|
||||||
"</sparkleshare>");
|
"</sparkleshare>");
|
||||||
writer.Close ();
|
writer.Close ();
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Config", "Created \"" + Path + "\"");
|
SparkleHelpers.DebugInfo ("Config", "Created \"" + FullPath + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string UserName {
|
public SparkleUser User {
|
||||||
get {
|
get {
|
||||||
XmlNode node = SelectSingleNode ("/sparkleshare/user/name/text()");
|
XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()");
|
||||||
return node.Value;
|
string name = name_node.Value;
|
||||||
|
|
||||||
|
XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()");
|
||||||
|
string email = email_node.Value;
|
||||||
|
|
||||||
|
return new SparkleUser (name, email);
|
||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
XmlNode node = SelectSingleNode ("/sparkleshare/user/name/text()");
|
SparkleUser user = (SparkleUser) value;
|
||||||
node.InnerText = value;
|
|
||||||
|
|
||||||
Save ();
|
XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()");
|
||||||
}
|
name_node.InnerText = user.Name;
|
||||||
}
|
|
||||||
|
|
||||||
|
XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()");
|
||||||
|
email_node.InnerText = user.Email;
|
||||||
|
|
||||||
public string UserEmail {
|
this.Save ();
|
||||||
get {
|
|
||||||
XmlNode node = SelectSingleNode ("/sparkleshare/user/email/text()");
|
|
||||||
return node.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
|
||||||
XmlNode node = SelectSingleNode ("/sparkleshare/user/email/text()");
|
|
||||||
node.InnerText = value;
|
|
||||||
|
|
||||||
Save ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,27 +145,6 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<string> FolderPaths {
|
|
||||||
get {
|
|
||||||
List<string> folders = new List<string> ();
|
|
||||||
|
|
||||||
foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder")) {
|
|
||||||
Uri uri = new Uri (node_folder ["url"].InnerText);
|
|
||||||
String path = uri.LocalPath;
|
|
||||||
if (!folders.Contains (path))
|
|
||||||
folders.Add (path);
|
|
||||||
|
|
||||||
if (1 < path.Length && "/" == path.Substring (0, 1))
|
|
||||||
if (!folders.Contains (path.Substring (1)))
|
|
||||||
folders.Add (path.Substring (1));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return folders;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void AddFolder (string name, string url, string backend)
|
public void AddFolder (string name, string url, string backend)
|
||||||
{
|
{
|
||||||
XmlNode node_name = CreateElement ("name");
|
XmlNode node_name = CreateElement ("name");
|
||||||
|
@ -172,22 +164,7 @@ namespace SparkleLib {
|
||||||
XmlNode node_root = SelectSingleNode ("/sparkleshare");
|
XmlNode node_root = SelectSingleNode ("/sparkleshare");
|
||||||
node_root.AppendChild (node_folder);
|
node_root.AppendChild (node_folder);
|
||||||
|
|
||||||
Save ();
|
this.Save ();
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetFolderOptionalAttribute (string name, string key, string value)
|
|
||||||
{
|
|
||||||
XmlNode folder = this.GetFolder(name);
|
|
||||||
if (folder == null) return false;
|
|
||||||
|
|
||||||
if (folder[key] != null) {
|
|
||||||
folder[key].InnerText = value;
|
|
||||||
} else {
|
|
||||||
XmlNode new_node = CreateElement(key);
|
|
||||||
new_node.InnerText = value;
|
|
||||||
folder.AppendChild(new_node);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,35 +175,73 @@ namespace SparkleLib {
|
||||||
SelectSingleNode ("/sparkleshare").RemoveChild (node_folder);
|
SelectSingleNode ("/sparkleshare").RemoveChild (node_folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
Save ();
|
this.Save ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool FolderExists (string name)
|
public bool FolderExists (string name)
|
||||||
{
|
{
|
||||||
XmlNode folder = this.GetFolder(name);
|
XmlNode folder = this.GetFolder (name);
|
||||||
return folder != null;
|
return (folder != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string GetBackendForFolder (string name)
|
public string GetBackendForFolder (string name)
|
||||||
{
|
{
|
||||||
return this.GetFolderValue(name, "backend");
|
return this.GetFolderValue (name, "backend");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string GetUrlForFolder (string name)
|
public string GetUrlForFolder (string name)
|
||||||
{
|
{
|
||||||
return this.GetFolderValue(name, "url");
|
return this.GetFolderValue (name, "url");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool SetFolderOptionalAttribute (string folder_name, string key, string value)
|
||||||
|
{
|
||||||
|
XmlNode folder = this.GetFolder (folder_name);
|
||||||
|
|
||||||
|
if (folder == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (folder [key] != null) {
|
||||||
|
folder [key].InnerText = value;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
XmlNode new_node = CreateElement (key);
|
||||||
|
new_node.InnerText = value;
|
||||||
|
folder.AppendChild (new_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string GetFolderOptionalAttribute (string folder_name, string key)
|
||||||
|
{
|
||||||
|
XmlNode folder = this.GetFolder (folder_name);
|
||||||
|
|
||||||
|
if (folder != null) {
|
||||||
|
if (folder [key] != null)
|
||||||
|
return folder [key].InnerText;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<string> Hosts {
|
public List<string> Hosts {
|
||||||
get {
|
get {
|
||||||
List<string> hosts = new List<string> ();
|
List<string> hosts = new List<string> ();
|
||||||
|
|
||||||
foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder")) {
|
foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder")) {
|
||||||
Uri uri = new Uri (node_folder ["url"].InnerText);
|
Uri uri = new Uri (node_folder ["url"].InnerText);
|
||||||
|
|
||||||
if (!hosts.Contains (uri.Host))
|
if (!hosts.Contains (uri.Host))
|
||||||
hosts.Add (uri.Host);
|
hosts.Add (uri.Host);
|
||||||
}
|
}
|
||||||
|
@ -251,21 +266,25 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetAnnouncementsForFolder (string name)
|
|
||||||
|
private XmlNode GetFolder (string name)
|
||||||
{
|
{
|
||||||
return this.GetFolderValue(name, "announcements");
|
return SelectSingleNode (String.Format("/sparkleshare/folder[name='{0}']", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string GetAnnouncementUrlForFolder (string name)
|
private string GetFolderValue (string name, string key)
|
||||||
{
|
{
|
||||||
// examples?
|
XmlNode folder = this.GetFolder(name);
|
||||||
// tcp://localhost:9999/
|
|
||||||
// xmpp:someuser@somexmppserver?canhavefunnybits
|
if ((folder != null) && (folder [key] != null)) {
|
||||||
// irc://hbons/#somechatroom
|
return folder [key].InnerText;
|
||||||
return this.GetFolderValue(name, "announcements_url");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public string GetConfigOption (string name)
|
public string GetConfigOption (string name)
|
||||||
{
|
{
|
||||||
XmlNode node = SelectSingleNode ("/sparkleshare/" + name);
|
XmlNode node = SelectSingleNode ("/sparkleshare/" + name);
|
||||||
|
@ -293,34 +312,17 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Config", "Updated " + name + ":" + content);
|
SparkleHelpers.DebugInfo ("Config", "Updated " + name + ":" + content);
|
||||||
Save ();
|
this.Save ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Save ()
|
private void Save ()
|
||||||
{
|
{
|
||||||
if (!File.Exists (Path))
|
if (!File.Exists (FullPath))
|
||||||
throw new ConfigFileNotFoundException (Path + " does not exist");
|
throw new ConfigFileNotFoundException (FullPath + " does not exist");
|
||||||
|
|
||||||
Save (Path);
|
this.Save (FullPath);
|
||||||
SparkleHelpers.DebugInfo ("Config", "Updated \"" + Path + "\"");
|
SparkleHelpers.DebugInfo ("Config", "Updated \"" + FullPath + "\"");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private XmlNode GetFolder (string name)
|
|
||||||
{
|
|
||||||
return SelectSingleNode(String.Format("/sparkleshare/folder[name='{0}']", name));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private string GetFolderValue (string name, string key)
|
|
||||||
{
|
|
||||||
XmlNode folder = this.GetFolder(name);
|
|
||||||
|
|
||||||
if ((folder != null) && (folder[key] != null)) {
|
|
||||||
return folder[key].InnerText;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private void DisableHostKeyCheckingForHost (string host)
|
private void DisableHostKeyCheckingForHost (string host)
|
||||||
{
|
{
|
||||||
string path = SparklePaths.HomePath;
|
string path = SparkleConfig.DefaultConfig.HomePath;
|
||||||
|
|
||||||
if (!(SparkleBackend.Platform == PlatformID.Unix ||
|
if (!(SparkleBackend.Platform == PlatformID.Unix ||
|
||||||
SparkleBackend.Platform == PlatformID.MacOSX)) {
|
SparkleBackend.Platform == PlatformID.MacOSX)) {
|
||||||
|
@ -150,7 +150,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private void EnableHostKeyCheckingForHost (string host)
|
private void EnableHostKeyCheckingForHost (string host)
|
||||||
{
|
{
|
||||||
string path = SparklePaths.HomePath;
|
string path = SparkleConfig.DefaultConfig.HomePath;
|
||||||
|
|
||||||
if (!(SparkleBackend.Platform == PlatformID.Unix ||
|
if (!(SparkleBackend.Platform == PlatformID.Unix ||
|
||||||
SparkleBackend.Platform == PlatformID.MacOSX)) {
|
SparkleBackend.Platform == PlatformID.MacOSX)) {
|
||||||
|
|
|
@ -41,7 +41,8 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public static SparkleListenerBase CreateListener (string folder_name, string folder_identifier)
|
public static SparkleListenerBase CreateListener (string folder_name, string folder_identifier)
|
||||||
{
|
{
|
||||||
string uri = SparkleConfig.DefaultConfig.GetAnnouncementUrlForFolder (folder_name);
|
string uri = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute (
|
||||||
|
folder_name, "announcements_url");
|
||||||
|
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
// This is SparkleShare's centralized notification service.
|
// This is SparkleShare's centralized notification service.
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
// SparkleShare, a collaboration and sharing tool.
|
|
||||||
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace SparkleLib {
|
|
||||||
|
|
||||||
public static class SparklePaths {
|
|
||||||
|
|
||||||
public static string HomePath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
|
||||||
public static string SparklePath = Path.Combine (HomePath ,"SparkleShare");
|
|
||||||
public static string SparkleTmpPath = Path.Combine (SparklePath, ".tmp");
|
|
||||||
public static string SparkleConfigPath = Path.Combine (Environment.GetFolderPath (
|
|
||||||
Environment.SpecialFolder.ApplicationData), "sparkleshare");
|
|
||||||
public static string SparkleLocalIconPath = Path.Combine (SparkleConfigPath, "icons");
|
|
||||||
|
|
||||||
public static string SparkleInstallPath = Path.Combine (Defines.PREFIX, "sparkleshare");
|
|
||||||
public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare", "icons");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -365,10 +365,8 @@ namespace SparkleLib {
|
||||||
|
|
||||||
if (match_notes.Success) {
|
if (match_notes.Success) {
|
||||||
SparkleNote note = new SparkleNote () {
|
SparkleNote note = new SparkleNote () {
|
||||||
User = new SparkleUser () {
|
User = new SparkleUser (match_notes.Groups [1].Value,
|
||||||
Name = match_notes.Groups [1].Value,
|
match_notes.Groups [2].Value),
|
||||||
Email = match_notes.Groups [2].Value
|
|
||||||
},
|
|
||||||
Timestamp = new DateTime (1970, 1, 1).AddSeconds (int.Parse (match_notes.Groups [3].Value)),
|
Timestamp = new DateTime (1970, 1, 1).AddSeconds (int.Parse (match_notes.Groups [3].Value)),
|
||||||
Body = match_notes.Groups [4].Value
|
Body = match_notes.Groups [4].Value
|
||||||
};
|
};
|
||||||
|
@ -452,7 +450,7 @@ namespace SparkleLib {
|
||||||
foreach (string added in change_set.Added) {
|
foreach (string added in change_set.Added) {
|
||||||
if (added.Contains (".notes")) {
|
if (added.Contains (".notes")) {
|
||||||
if (NewNote != null)
|
if (NewNote != null)
|
||||||
NewNote (change_set.UserName, change_set.UserEmail);
|
NewNote (change_set.User.Name, change_set.User.Email);
|
||||||
|
|
||||||
note_added = true;
|
note_added = true;
|
||||||
break;
|
break;
|
||||||
|
@ -524,8 +522,8 @@ namespace SparkleLib {
|
||||||
string n = Environment.NewLine;
|
string n = Environment.NewLine;
|
||||||
note = "<note>" + n +
|
note = "<note>" + n +
|
||||||
" <user>" + n +
|
" <user>" + n +
|
||||||
" <name>" + SparkleConfig.DefaultConfig.UserName + "</name>" + n +
|
" <name>" + SparkleConfig.DefaultConfig.User.Name + "</name>" + n +
|
||||||
" <email>" + SparkleConfig.DefaultConfig.UserEmail + "</email>" + n +
|
" <email>" + SparkleConfig.DefaultConfig.User.Email + "</email>" + n +
|
||||||
" </user>" + n +
|
" </user>" + n +
|
||||||
" <timestamp>" + timestamp + "</timestamp>" + n +
|
" <timestamp>" + timestamp + "</timestamp>" + n +
|
||||||
" <body>" + note + "</body>" + n +
|
" <body>" + note + "</body>" + n +
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
// We have to use our own custom made folder watcher, as
|
// We have to use our own custom made folder watcher, as
|
||||||
// System.IO.FileSystemWatcher fails watching subfolders on Mac
|
// System.IO.FileSystemWatcher fails watching subfolders on Mac
|
||||||
private SparkleMacWatcher watcher = new SparkleMacWatcher (SparklePaths.SparklePath);
|
private SparkleMacWatcher watcher = new SparkleMacWatcher (SparkleConfig.DefaultConfig.FoldersPath);
|
||||||
|
|
||||||
public SparkleMacController () : base () { }
|
public SparkleMacController () : base () { }
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
repo_name = repo_name.Trim ("/".ToCharArray ());
|
repo_name = repo_name.Trim ("/".ToCharArray ());
|
||||||
FileSystemEventArgs args = new FileSystemEventArgs (WatcherChangeTypes.Changed,
|
FileSystemEventArgs args = new FileSystemEventArgs (WatcherChangeTypes.Changed,
|
||||||
Path.Combine (SparklePaths.SparklePath, path), Path.GetFileName (path));
|
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, path), Path.GetFileName (path));
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Repositories) {
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
if (repo.Name.Equals (repo_name))
|
if (repo.Name.Equals (repo_name))
|
||||||
|
@ -109,8 +109,8 @@ namespace SparkleShare {
|
||||||
// Creates the SparkleShare folder in the user's home folder
|
// Creates the SparkleShare folder in the user's home folder
|
||||||
public override bool CreateSparkleShareFolder ()
|
public override bool CreateSparkleShareFolder ()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists (SparklePaths.SparklePath)) {
|
if (!Directory.Exists (SparkleConfig.DefaultConfig.FoldersPath)) {
|
||||||
Directory.CreateDirectory (SparklePaths.SparklePath);
|
Directory.CreateDirectory (SparkleConfig.DefaultConfig.FoldersPath);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,7 +122,7 @@ namespace SparkleShare {
|
||||||
// Opens the SparkleShare folder or an (optional) subfolder
|
// Opens the SparkleShare folder or an (optional) subfolder
|
||||||
public override void OpenSparkleShareFolder (string subfolder)
|
public override void OpenSparkleShareFolder (string subfolder)
|
||||||
{
|
{
|
||||||
string folder = Path.Combine (SparklePaths.SparklePath, subfolder);
|
string folder = Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, subfolder);
|
||||||
folder.Replace (" ", "\\ "); // Escape space-characters
|
folder.Replace (" ", "\\ "); // Escape space-characters
|
||||||
|
|
||||||
NSWorkspace.SharedWorkspace.OpenFile (folder);
|
NSWorkspace.SharedWorkspace.OpenFile (folder);
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public List <SparkleRepoBase> Repositories;
|
public List <SparkleRepoBase> Repositories;
|
||||||
public string FolderSize;
|
public string FolderSize;
|
||||||
public readonly string SparklePath = SparklePaths.SparklePath;
|
public readonly string SparklePath = SparkleConfig.DefaultConfig.FoldersPath;
|
||||||
|
|
||||||
public event OnQuitWhileSyncingEventHandler OnQuitWhileSyncing;
|
public event OnQuitWhileSyncingEventHandler OnQuitWhileSyncing;
|
||||||
public delegate void OnQuitWhileSyncingEventHandler ();
|
public delegate void OnQuitWhileSyncingEventHandler ();
|
||||||
|
@ -96,18 +96,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
FolderSize = GetFolderSize ();
|
FolderSize = GetFolderSize ();
|
||||||
|
|
||||||
// TODO: Legacy. Remove at some later point
|
|
||||||
string old_global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config");
|
|
||||||
if (File.Exists (old_global_config_file_path))
|
|
||||||
MigrateConfig ();
|
|
||||||
|
|
||||||
if (FirstRun)
|
if (FirstRun)
|
||||||
SparkleConfig.DefaultConfig.SetConfigOption ("notifications", bool.TrueString);
|
SparkleConfig.DefaultConfig.SetConfigOption ("notifications", bool.TrueString);
|
||||||
else
|
else
|
||||||
AddKey ();
|
AddKey ();
|
||||||
|
|
||||||
// Watch the SparkleShare folder
|
// Watch the SparkleShare folder
|
||||||
FileSystemWatcher watcher = new FileSystemWatcher (SparklePaths.SparklePath) {
|
FileSystemWatcher watcher = new FileSystemWatcher (SparkleConfig.DefaultConfig.FoldersPath) {
|
||||||
IncludeSubdirectories = false,
|
IncludeSubdirectories = false,
|
||||||
EnableRaisingEvents = true,
|
EnableRaisingEvents = true,
|
||||||
Filter = "*"
|
Filter = "*"
|
||||||
|
@ -152,41 +147,16 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public bool FirstRun {
|
public bool FirstRun {
|
||||||
get {
|
get {
|
||||||
return SparkleConfig.DefaultConfig.UserEmail.Equals ("Unknown");
|
return SparkleConfig.DefaultConfig.User.Email.Equals ("Unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void MigrateConfig ()
|
|
||||||
{
|
|
||||||
string old_global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config");
|
|
||||||
|
|
||||||
StreamReader reader = new StreamReader (old_global_config_file_path);
|
|
||||||
string global_config_file = reader.ReadToEnd ();
|
|
||||||
reader.Close ();
|
|
||||||
|
|
||||||
Regex regex = new Regex (@"name.+= (.+)");
|
|
||||||
Match match = regex.Match (global_config_file);
|
|
||||||
|
|
||||||
string user_name = match.Groups [1].Value;
|
|
||||||
|
|
||||||
regex = new Regex (@"email.+= (.+)");
|
|
||||||
match = regex.Match (global_config_file);
|
|
||||||
|
|
||||||
string user_email = match.Groups [1].Value;
|
|
||||||
|
|
||||||
SparkleConfig.DefaultConfig.UserName = user_name;
|
|
||||||
SparkleConfig.DefaultConfig.UserEmail = user_email;
|
|
||||||
|
|
||||||
File.Delete (old_global_config_file_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Uploads the user's public key to the server
|
// Uploads the user's public key to the server
|
||||||
public bool AcceptInvitation (string server, string folder, string token)
|
public bool AcceptInvitation (string server, string folder, string token)
|
||||||
{
|
{
|
||||||
// The location of the user's public key for SparkleShare
|
// The location of the user's public key for SparkleShare
|
||||||
string public_key_file_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".ssh",
|
string public_key_file_path = SparkleHelpers.CombineMore (SparkleConfig.DefaultConfig.HomePath, ".ssh",
|
||||||
"sparkleshare." + UserEmail + ".key.pub");
|
"sparkleshare." + UserEmail + ".key.pub");
|
||||||
|
|
||||||
if (!File.Exists (public_key_file_path))
|
if (!File.Exists (public_key_file_path))
|
||||||
|
@ -224,15 +194,6 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<string> FolderPaths {
|
|
||||||
get {
|
|
||||||
List<string> folders = SparkleConfig.DefaultConfig.FolderPaths;
|
|
||||||
folders.Sort ();
|
|
||||||
return folders;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<string> PreviousHosts {
|
public List<string> PreviousHosts {
|
||||||
get {
|
get {
|
||||||
List<string> hosts = SparkleConfig.DefaultConfig.HostsWithUsername;
|
List<string> hosts = SparkleConfig.DefaultConfig.HostsWithUsername;
|
||||||
|
@ -261,8 +222,14 @@ namespace SparkleShare {
|
||||||
{
|
{
|
||||||
List<SparkleChangeSet> list = new List<SparkleChangeSet> ();
|
List<SparkleChangeSet> list = new List<SparkleChangeSet> ();
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Repositories)
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
list.AddRange (repo.GetChangeSets (50));
|
List<SparkleChangeSet> change_sets = repo.GetChangeSets (50);
|
||||||
|
|
||||||
|
if (change_sets != null)
|
||||||
|
list.AddRange (change_sets);
|
||||||
|
else
|
||||||
|
SparkleHelpers.DebugInfo ("Log", "Could not create log for " + repo.Name);
|
||||||
|
}
|
||||||
|
|
||||||
list.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp)));
|
list.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp)));
|
||||||
list.Reverse ();
|
list.Reverse ();
|
||||||
|
@ -279,7 +246,7 @@ namespace SparkleShare {
|
||||||
if (name == null)
|
if (name == null)
|
||||||
return GetLog ();
|
return GetLog ();
|
||||||
|
|
||||||
string path = Path.Combine (SparklePaths.SparklePath, name);
|
string path = Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, name);
|
||||||
int log_size = 50;
|
int log_size = 50;
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Repositories) {
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
|
@ -308,8 +275,8 @@ namespace SparkleShare {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
foreach (SparkleChangeSet change_set in change_sets) {
|
foreach (SparkleChangeSet change_set in change_sets) {
|
||||||
if (!emails.Contains (change_set.UserEmail))
|
if (!emails.Contains (change_set.User.Email))
|
||||||
emails.Add (change_set.UserEmail);
|
emails.Add (change_set.User.Email);
|
||||||
|
|
||||||
bool change_set_inserted = false;
|
bool change_set_inserted = false;
|
||||||
foreach (ActivityDay stored_activity_day in activity_days) {
|
foreach (ActivityDay stored_activity_day in activity_days) {
|
||||||
|
@ -319,8 +286,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
bool squash = false;
|
bool squash = false;
|
||||||
foreach (SparkleChangeSet existing_set in stored_activity_day) {
|
foreach (SparkleChangeSet existing_set in stored_activity_day) {
|
||||||
if (change_set.UserName.Equals (existing_set.UserName) &&
|
if (change_set.User.Name.Equals (existing_set.User.Name) &&
|
||||||
change_set.UserEmail.Equals (existing_set.UserEmail) &&
|
change_set.User.Email.Equals (existing_set.User.Email) &&
|
||||||
change_set.Folder.Equals (existing_set.Folder)) {
|
change_set.Folder.Equals (existing_set.Folder)) {
|
||||||
|
|
||||||
existing_set.Added.AddRange (change_set.Added);
|
existing_set.Added.AddRange (change_set.Added);
|
||||||
|
@ -377,14 +344,14 @@ namespace SparkleShare {
|
||||||
foreach (SparkleChangeSet change_set in activity_day) {
|
foreach (SparkleChangeSet change_set in activity_day) {
|
||||||
string event_entry = "<dl>";
|
string event_entry = "<dl>";
|
||||||
|
|
||||||
if (change_set.IsMerge) {
|
if (change_set.IsMagical) {
|
||||||
event_entry += "<dd>Did something magical</dd>";
|
event_entry += "<dd>Did something magical</dd>";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (change_set.Edited.Count > 0) {
|
if (change_set.Edited.Count > 0) {
|
||||||
foreach (string file_path in change_set.Edited) {
|
foreach (string file_path in change_set.Edited) {
|
||||||
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
string absolute_file_path = Path.Combine (
|
||||||
change_set.Folder, file_path);
|
SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder, file_path);
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
if (File.Exists (absolute_file_path))
|
||||||
event_entry += "<dd class='document edited'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
event_entry += "<dd class='document edited'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
||||||
|
@ -395,8 +362,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (change_set.Added.Count > 0) {
|
if (change_set.Added.Count > 0) {
|
||||||
foreach (string file_path in change_set.Added) {
|
foreach (string file_path in change_set.Added) {
|
||||||
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
string absolute_file_path = Path.Combine (
|
||||||
change_set.Folder, file_path);
|
SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder, file_path);
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
if (File.Exists (absolute_file_path))
|
||||||
event_entry += "<dd class='document added'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
event_entry += "<dd class='document added'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
||||||
|
@ -407,8 +374,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (change_set.Deleted.Count > 0) {
|
if (change_set.Deleted.Count > 0) {
|
||||||
foreach (string file_path in change_set.Deleted) {
|
foreach (string file_path in change_set.Deleted) {
|
||||||
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
string absolute_file_path = Path.Combine (
|
||||||
change_set.Folder, file_path);
|
SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder, file_path);
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
if (File.Exists (absolute_file_path))
|
||||||
event_entry += "<dd class='document deleted'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
event_entry += "<dd class='document deleted'><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
||||||
|
@ -421,10 +388,10 @@ namespace SparkleShare {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (string file_path in change_set.MovedFrom) {
|
foreach (string file_path in change_set.MovedFrom) {
|
||||||
string to_file_path = change_set.MovedTo [i];
|
string to_file_path = change_set.MovedTo [i];
|
||||||
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
string absolute_file_path = Path.Combine (
|
||||||
change_set.Folder, file_path);
|
SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder, file_path);
|
||||||
string absolute_to_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
string absolute_to_file_path = Path.Combine (
|
||||||
change_set.Folder, to_file_path);
|
SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder, file_path);
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path))
|
if (File.Exists (absolute_file_path))
|
||||||
event_entry += "<dd class='document moved'><a href='" + absolute_file_path + "'>" + file_path + "</a><br/>";
|
event_entry += "<dd class='document moved'><a href='" + absolute_file_path + "'>" + file_path + "</a><br/>";
|
||||||
|
@ -460,8 +427,8 @@ namespace SparkleShare {
|
||||||
comments += "</div>";
|
comments += "</div>";
|
||||||
|
|
||||||
string avatar_email = "";
|
string avatar_email = "";
|
||||||
if (File.Exists (GetAvatar (change_set.UserEmail, 48)))
|
if (File.Exists (GetAvatar (change_set.User.Email, 48)))
|
||||||
avatar_email = change_set.UserEmail;
|
avatar_email = change_set.User.Email;
|
||||||
|
|
||||||
event_entry += "</dl>";
|
event_entry += "</dl>";
|
||||||
|
|
||||||
|
@ -472,7 +439,7 @@ namespace SparkleShare {
|
||||||
" – " + timestamp;
|
" – " + timestamp;
|
||||||
|
|
||||||
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)
|
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)
|
||||||
.Replace ("<!-- $event-user-name -->", change_set.UserName)
|
.Replace ("<!-- $event-user-name -->", change_set.User.Name)
|
||||||
.Replace ("<!-- $event-avatar-url -->", "file://" + GetAvatar (avatar_email, 48))
|
.Replace ("<!-- $event-avatar-url -->", "file://" + GetAvatar (avatar_email, 48))
|
||||||
.Replace ("<!-- $event-time -->", timestamp)
|
.Replace ("<!-- $event-time -->", timestamp)
|
||||||
.Replace ("<!-- $event-folder -->", change_set.Folder)
|
.Replace ("<!-- $event-folder -->", change_set.Folder)
|
||||||
|
@ -574,7 +541,7 @@ namespace SparkleShare {
|
||||||
// Adds a repository to the list of repositories
|
// Adds a repository to the list of repositories
|
||||||
private void AddRepository (string folder_path)
|
private void AddRepository (string folder_path)
|
||||||
{
|
{
|
||||||
if (folder_path.Equals (SparklePaths.SparkleTmpPath))
|
if (folder_path.Equals (SparkleConfig.DefaultConfig.TmpPath))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string folder_name = Path.GetFileName (folder_path);
|
string folder_name = Path.GetFileName (folder_path);
|
||||||
|
@ -585,20 +552,20 @@ namespace SparkleShare {
|
||||||
|
|
||||||
SparkleRepoBase repo = null;
|
SparkleRepoBase repo = null;
|
||||||
|
|
||||||
if (backend.Equals ("Hg"))
|
/* if (backend.Equals ("Hg"))
|
||||||
repo = new SparkleRepoHg (folder_path, new SparkleBackendHg ());
|
repo = new SparkleRepoHg (folder_path, new SparkleBackendHg ());
|
||||||
|
|
||||||
else if (backend.Equals ("Scp"))
|
else if (backend.Equals ("Scp"))
|
||||||
repo = new SparkleRepoScp (folder_path, new SparkleBackendScp ());
|
repo = new SparkleRepoScp (folder_path, new SparkleBackendScp ());
|
||||||
|
|
||||||
else
|
else */
|
||||||
repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend);
|
repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend);
|
||||||
|
|
||||||
repo.NewChangeSet += delegate (SparkleChangeSet change_set) {
|
repo.NewChangeSet += delegate (SparkleChangeSet change_set) {
|
||||||
string message = FormatMessage (change_set);
|
string message = FormatMessage (change_set);
|
||||||
|
|
||||||
if (NotificationRaised != null)
|
if (NotificationRaised != null)
|
||||||
NotificationRaised (change_set.UserName, change_set.UserEmail, message, repo.LocalPath);
|
NotificationRaised (change_set.User.Name, change_set.User.Email, message, repo.LocalPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
repo.NewNote += delegate (string user_name, string user_email) {
|
repo.NewNote += delegate (string user_name, string user_email) {
|
||||||
|
@ -661,7 +628,7 @@ namespace SparkleShare {
|
||||||
Repositories = new List<SparkleRepoBase> ();
|
Repositories = new List<SparkleRepoBase> ();
|
||||||
|
|
||||||
foreach (string folder_name in SparkleConfig.DefaultConfig.Folders) {
|
foreach (string folder_name in SparkleConfig.DefaultConfig.Folders) {
|
||||||
string folder_path = Path.Combine (SparklePaths.SparklePath, folder_name);
|
string folder_path = new SparkleFolder (folder_name).FullPath;
|
||||||
|
|
||||||
if (Directory.Exists (folder_path))
|
if (Directory.Exists (folder_path))
|
||||||
AddRepository (folder_path);
|
AddRepository (folder_path);
|
||||||
|
@ -709,7 +676,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
private string GetFolderSize ()
|
private string GetFolderSize ()
|
||||||
{
|
{
|
||||||
double folder_size = CalculateFolderSize (new DirectoryInfo (SparklePaths.SparklePath));
|
double folder_size = CalculateFolderSize (
|
||||||
|
new DirectoryInfo (SparkleConfig.DefaultConfig.FoldersPath));
|
||||||
|
|
||||||
return FormatFolderSize (folder_size);
|
return FormatFolderSize (folder_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +785,7 @@ namespace SparkleShare {
|
||||||
// so all activity is done with this key
|
// so all activity is done with this key
|
||||||
public void AddKey ()
|
public void AddKey ()
|
||||||
{
|
{
|
||||||
string keys_path = SparklePaths.SparkleConfigPath;
|
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||||
string key_file_name = "sparkleshare." + UserEmail + ".key";
|
string key_file_name = "sparkleshare." + UserEmail + ".key";
|
||||||
|
|
||||||
Process process = new Process ();
|
Process process = new Process ();
|
||||||
|
@ -840,11 +809,11 @@ namespace SparkleShare {
|
||||||
public string UserName
|
public string UserName
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
return SparkleConfig.DefaultConfig.UserName;
|
return SparkleConfig.DefaultConfig.User.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
SparkleConfig.DefaultConfig.UserName = value;
|
SparkleConfig.DefaultConfig.User = new SparkleUser (value, UserEmail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,11 +822,11 @@ namespace SparkleShare {
|
||||||
public string UserEmail
|
public string UserEmail
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
return SparkleConfig.DefaultConfig.UserEmail;
|
return SparkleConfig.DefaultConfig.User.Email;
|
||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
SparkleConfig.DefaultConfig.UserEmail = value;
|
SparkleConfig.DefaultConfig.User = new SparkleUser (UserName, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +834,7 @@ namespace SparkleShare {
|
||||||
// Generates and installs an RSA keypair to identify this system
|
// Generates and installs an RSA keypair to identify this system
|
||||||
public void GenerateKeyPair ()
|
public void GenerateKeyPair ()
|
||||||
{
|
{
|
||||||
string keys_path = SparklePaths.SparkleConfigPath;
|
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||||
string key_file_name = "sparkleshare." + UserEmail + ".key";
|
string key_file_name = "sparkleshare." + UserEmail + ".key";
|
||||||
string key_file_path = Path.Combine (keys_path, key_file_name);
|
string key_file_path = Path.Combine (keys_path, key_file_name);
|
||||||
|
|
||||||
|
@ -914,8 +883,9 @@ namespace SparkleShare {
|
||||||
{
|
{
|
||||||
List<string> old_avatars = new List<string> ();
|
List<string> old_avatars = new List<string> ();
|
||||||
bool avatar_fetched = false;
|
bool avatar_fetched = false;
|
||||||
string avatar_path = SparkleHelpers.CombineMore (
|
string avatar_path = Path.Combine (
|
||||||
SparklePaths.SparkleLocalIconPath, size + "x" + size, "status");
|
Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "icons",
|
||||||
|
size + "x" + size, "status");
|
||||||
|
|
||||||
if (!Directory.Exists (avatar_path)) {
|
if (!Directory.Exists (avatar_path)) {
|
||||||
Directory.CreateDirectory (avatar_path);
|
Directory.CreateDirectory (avatar_path);
|
||||||
|
@ -974,7 +944,8 @@ namespace SparkleShare {
|
||||||
public string GetAvatar (string email, int size)
|
public string GetAvatar (string email, int size)
|
||||||
{
|
{
|
||||||
string avatar_file_path = SparkleHelpers.CombineMore (
|
string avatar_file_path = SparkleHelpers.CombineMore (
|
||||||
SparklePaths.SparkleLocalIconPath, size + "x" + size, "status", "avatar-" + email);
|
Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "icons",
|
||||||
|
size + "x" + size, "status", "avatar-" + email);
|
||||||
|
|
||||||
return avatar_file_path;
|
return avatar_file_path;
|
||||||
}
|
}
|
||||||
|
@ -985,17 +956,18 @@ namespace SparkleShare {
|
||||||
server = server.Trim ();
|
server = server.Trim ();
|
||||||
remote_folder = remote_folder.Trim ();
|
remote_folder = remote_folder.Trim ();
|
||||||
|
|
||||||
if (!Directory.Exists (SparklePaths.SparkleTmpPath))
|
string tmp_path = SparkleConfig.DefaultConfig.TmpPath;
|
||||||
Directory.CreateDirectory (SparklePaths.SparkleTmpPath);
|
if (!Directory.Exists (tmp_path))
|
||||||
|
Directory.CreateDirectory (tmp_path);
|
||||||
|
|
||||||
// Strip the '.git' from the name
|
// Strip the '.git' from the name
|
||||||
string canonical_name = Path.GetFileNameWithoutExtension (remote_folder);
|
string canonical_name = Path.GetFileNameWithoutExtension (remote_folder);
|
||||||
string tmp_folder = Path.Combine (SparklePaths.SparkleTmpPath, canonical_name);
|
string tmp_folder = Path.Combine (tmp_path, canonical_name);
|
||||||
|
|
||||||
SparkleFetcherBase fetcher = null;
|
SparkleFetcherBase fetcher = null;
|
||||||
string backend = null;
|
string backend = null;
|
||||||
|
|
||||||
if (remote_folder.EndsWith (".hg")) {
|
/* if (remote_folder.EndsWith (".hg")) {
|
||||||
remote_folder = remote_folder.Substring (0, (remote_folder.Length - 3));
|
remote_folder = remote_folder.Substring (0, (remote_folder.Length - 3));
|
||||||
fetcher = new SparkleFetcherHg (server, remote_folder, tmp_folder);
|
fetcher = new SparkleFetcherHg (server, remote_folder, tmp_folder);
|
||||||
backend = "Hg";
|
backend = "Hg";
|
||||||
|
@ -1005,12 +977,13 @@ namespace SparkleShare {
|
||||||
fetcher = new SparkleFetcherScp (server, remote_folder, tmp_folder);
|
fetcher = new SparkleFetcherScp (server, remote_folder, tmp_folder);
|
||||||
backend = "Scp";
|
backend = "Scp";
|
||||||
|
|
||||||
} else {
|
} else {*/
|
||||||
fetcher = new SparkleFetcherGit (server, remote_folder, tmp_folder);
|
fetcher = new SparkleFetcherGit (server, remote_folder, tmp_folder);
|
||||||
backend = "Git";
|
backend = "Git";
|
||||||
}
|
//}
|
||||||
|
|
||||||
bool target_folder_exists = Directory.Exists (Path.Combine (SparklePaths.SparklePath, canonical_name));
|
bool target_folder_exists = Directory.Exists (
|
||||||
|
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, canonical_name));
|
||||||
|
|
||||||
// Add a numbered suffix to the nameif a folder with the same name
|
// Add a numbered suffix to the nameif a folder with the same name
|
||||||
// already exists. Example: "Folder (2)"
|
// already exists. Example: "Folder (2)"
|
||||||
|
@ -1018,7 +991,7 @@ namespace SparkleShare {
|
||||||
while (target_folder_exists) {
|
while (target_folder_exists) {
|
||||||
i++;
|
i++;
|
||||||
target_folder_exists = Directory.Exists (
|
target_folder_exists = Directory.Exists (
|
||||||
Path.Combine (SparklePaths.SparklePath, canonical_name + " (" + i + ")"));
|
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, canonical_name + " (" + i + ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
string target_folder_name = canonical_name;
|
string target_folder_name = canonical_name;
|
||||||
|
@ -1029,7 +1002,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
// Needed to do the moving
|
// Needed to do the moving
|
||||||
SparkleHelpers.ClearAttributes (tmp_folder);
|
SparkleHelpers.ClearAttributes (tmp_folder);
|
||||||
string target_folder_path = Path.Combine (SparklePaths.SparklePath, target_folder_name);
|
string target_folder_path = Path.Combine (
|
||||||
|
SparkleConfig.DefaultConfig.FoldersPath, target_folder_name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Directory.Move (tmp_folder, target_folder_path);
|
Directory.Move (tmp_folder, target_folder_path);
|
||||||
|
@ -1053,8 +1027,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
fetcher.Dispose ();
|
fetcher.Dispose ();
|
||||||
|
|
||||||
if (Directory.Exists (SparklePaths.SparkleTmpPath))
|
if (Directory.Exists (tmp_path))
|
||||||
Directory.Delete (SparklePaths.SparkleTmpPath, true);
|
Directory.Delete (tmp_path, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1064,8 +1038,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
fetcher.Dispose ();
|
fetcher.Dispose ();
|
||||||
|
|
||||||
if (Directory.Exists (SparklePaths.SparkleTmpPath))
|
if (Directory.Exists (tmp_path))
|
||||||
Directory.Delete (SparklePaths.SparkleTmpPath, true);
|
Directory.Delete (tmp_path, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue