From 7f4234a18ddc7f5a3bfa03585d97867c9ae8f883 Mon Sep 17 00:00:00 2001 From: Konstantinos Vaggelakos Date: Mon, 10 Oct 2011 01:43:33 +0200 Subject: [PATCH] Fixed the spacing --- SparkleShare/SparkleControllerBase.cs | 290 ++++++++++++---------- SparkleShare/Windows/SparkleController.cs | 123 ++++----- 2 files changed, 215 insertions(+), 198 deletions(-) diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index f63ae4a1..99641445 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -45,19 +45,19 @@ namespace SparkleShare { public event FolderFetchedEventHandler FolderFetched; public delegate void FolderFetchedEventHandler (); - + public event FolderFetchErrorEventHandler FolderFetchError; public delegate void FolderFetchErrorEventHandler (string remote_url); - + public event FolderFetchingEventHandler FolderFetching; public delegate void FolderFetchingEventHandler (double percentage); - + public event FolderListChangedEventHandler FolderListChanged; public delegate void FolderListChangedEventHandler (); public event FolderSizeChangedEventHandler FolderSizeChanged; public delegate void FolderSizeChangedEventHandler (string folder_size); - + public event AvatarFetchedEventHandler AvatarFetched; public delegate void AvatarFetchedEventHandler (); @@ -98,7 +98,7 @@ namespace SparkleShare { { } - + public virtual void Initialize () { InstallLauncher (); @@ -118,8 +118,8 @@ namespace SparkleShare { // Watch the SparkleShare folder FileSystemWatcher watcher = new FileSystemWatcher (SparkleConfig.DefaultConfig.FoldersPath) { IncludeSubdirectories = false, - EnableRaisingEvents = true, - Filter = "*" + EnableRaisingEvents = true, + Filter = "*" }; // Remove the repository when a delete event occurs @@ -142,13 +142,13 @@ namespace SparkleShare { // Handle invitations when the user saves an // invitation into the SparkleShare folder if (args.Name.EndsWith (".sparkle") && !FirstRun) { - XmlDocument xml_doc = new XmlDocument (); + XmlDocument xml_doc = new XmlDocument (); xml_doc.Load (args.Name); string server = xml_doc.GetElementsByTagName ("server") [0].InnerText; string folder = xml_doc.GetElementsByTagName ("folder") [0].InnerText; - string token = xml_doc.GetElementsByTagName ("token") [0].InnerText; - + string token = xml_doc.GetElementsByTagName ("token") [0].InnerText; + // FIXME: this is broken :\ if (OnInvitation != null) OnInvitation (server, folder, token); @@ -162,8 +162,10 @@ namespace SparkleShare { } - public bool FirstRun { - get { + public bool FirstRun + { + get + { return SparkleConfig.DefaultConfig.User.Email.Equals ("Unknown"); } } @@ -188,8 +190,8 @@ namespace SparkleShare { SparkleHelpers.DebugInfo ("WebRequest", url); - HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url); - HttpWebResponse response = (HttpWebResponse) request.GetResponse(); + HttpWebRequest request = (HttpWebRequest)WebRequest.Create (url); + HttpWebResponse response = (HttpWebResponse)request.GetResponse (); if (response.StatusCode == HttpStatusCode.OK) { response.Close (); @@ -202,8 +204,10 @@ namespace SparkleShare { } - public List Folders { - get { + public List Folders + { + get + { List folders = SparkleConfig.DefaultConfig.Folders; folders.Sort (); return folders; @@ -211,24 +215,28 @@ namespace SparkleShare { } - public List PreviousHosts { - get { + public List PreviousHosts + { + get + { List hosts = SparkleConfig.DefaultConfig.HostsWithUsername; - hosts.AddRange(SparkleConfig.DefaultConfig.Hosts); + hosts.AddRange (SparkleConfig.DefaultConfig.Hosts); hosts.Sort (); return hosts; } } - public List UnsyncedFolders { - get { + public List UnsyncedFolders + { + get + { List unsynced_folders = new List (); foreach (SparkleRepoBase repo in Repositories) { if (repo.HasUnsyncedChanges) unsynced_folders.Add (repo.Name); - } + } return unsynced_folders; } @@ -263,26 +271,26 @@ namespace SparkleShare { if (name == null) return GetLog (); - string path = new string [] {SparkleConfig.DefaultConfig.FoldersPath, name}.Combine (); + string path = new string [] { SparkleConfig.DefaultConfig.FoldersPath, name }.Combine (); int log_size = 50; - + foreach (SparkleRepoBase repo in Repositories) { - if (repo.LocalPath.Equals (path)) + if (repo.LocalPath.Equals (path)) return repo.GetChangeSets (log_size); } return null; } - - + + public abstract string EventLogHTML { get; } public abstract string DayEntryHTML { get; } public abstract string EventEntryHTML { get; } - - + + public string GetHTMLLog (List change_sets) { - List activity_days = new List (); + List activity_days = new List (); List emails = new List (); change_sets.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp))); @@ -297,9 +305,9 @@ namespace SparkleShare { bool change_set_inserted = false; foreach (ActivityDay stored_activity_day in activity_days) { - if (stored_activity_day.DateTime.Year == change_set.Timestamp.Year && + if (stored_activity_day.DateTime.Year == change_set.Timestamp.Year && stored_activity_day.DateTime.Month == change_set.Timestamp.Month && - stored_activity_day.DateTime.Day == change_set.Timestamp.Day) { + stored_activity_day.DateTime.Day == change_set.Timestamp.Day) { bool squash = false; foreach (SparkleChangeSet existing_set in stored_activity_day) { @@ -314,8 +322,8 @@ namespace SparkleShare { existing_set.MovedTo.AddRange (change_set.MovedTo); existing_set.Notes.AddRange (change_set.Notes); - existing_set.Added = existing_set.Added.Distinct ().ToList (); - existing_set.Edited = existing_set.Edited.Distinct ().ToList (); + existing_set.Added = existing_set.Added.Distinct ().ToList (); + existing_set.Edited = existing_set.Edited.Distinct ().ToList (); existing_set.Deleted = existing_set.Deleted.Distinct ().ToList (); if (DateTime.Compare (existing_set.Timestamp, change_set.Timestamp) < 1) { @@ -350,10 +358,10 @@ namespace SparkleShare { FetchAvatars (emails, 48); })).Start (); - string event_log_html = EventLogHTML; - string day_entry_html = DayEntryHTML; + string event_log_html = EventLogHTML; + string day_entry_html = DayEntryHTML; string event_entry_html = EventEntryHTML; - string event_log = ""; + string event_log = ""; foreach (ActivityDay activity_day in activity_days) { string event_entries = ""; @@ -369,31 +377,31 @@ namespace SparkleShare { foreach (string file_path in change_set.Edited) { string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder, file_path}.Combine (); - + if (File.Exists (absolute_file_path)) event_entry += "
" + file_path + "
"; else event_entry += "
" + file_path + "
"; } } - + if (change_set.Added.Count > 0) { foreach (string file_path in change_set.Added) { string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder, file_path}.Combine (); - + if (File.Exists (absolute_file_path)) event_entry += "
" + file_path + "
"; else event_entry += "
" + file_path + "
"; } } - + if (change_set.Deleted.Count > 0) { foreach (string file_path in change_set.Deleted) { string absolute_file_path = new string [] {SparkleConfig.DefaultConfig.FoldersPath, change_set.Folder, file_path}.Combine (); - + if (File.Exists (absolute_file_path)) event_entry += "
" + file_path + "
"; else @@ -444,7 +452,7 @@ namespace SparkleShare { comments += "
" + "

" + - note.User.Name + "

" + + note.User.Name + "

" + note.Body + "
"; } @@ -458,7 +466,7 @@ namespace SparkleShare { else change_set_avatar = ""; - event_entry += ""; + event_entry += ""; string timestamp = change_set.Timestamp.ToString ("H:mm"); @@ -476,19 +484,19 @@ namespace SparkleShare { .Replace ("", comments); } - string day_entry = ""; - DateTime today = DateTime.Now; + string day_entry = ""; + DateTime today = DateTime.Now; DateTime yesterday = DateTime.Now.AddDays (-1); - if (today.Day == activity_day.DateTime.Day && - today.Month == activity_day.DateTime.Month && - today.Year == activity_day.DateTime.Year) { + if (today.Day == activity_day.DateTime.Day && + today.Month == activity_day.DateTime.Month && + today.Year == activity_day.DateTime.Year) { day_entry = day_entry_html.Replace ("", "Today"); - } else if (yesterday.Day == activity_day.DateTime.Day && + } else if (yesterday.Day == activity_day.DateTime.Day && yesterday.Month == activity_day.DateTime.Month && - yesterday.Year == activity_day.DateTime.Year) { + yesterday.Year == activity_day.DateTime.Year) { day_entry = day_entry_html.Replace ("", "Yesterday"); @@ -497,20 +505,20 @@ namespace SparkleShare { // TRANSLATORS: This is the date in the event logs day_entry = day_entry_html.Replace ("", - activity_day.DateTime.ToString (_("dddd, MMMM d, yyyy"))); + activity_day.DateTime.ToString (_ ("dddd, MMMM d, yyyy"))); } else { // TRANSLATORS: This is the date in the event logs, without the year day_entry = day_entry_html.Replace ("", - activity_day.DateTime.ToString (_("dddd, MMMM d"))); + activity_day.DateTime.ToString (_ ("dddd, MMMM d"))); } } event_log += day_entry.Replace ("", event_entries); } - string html = event_log_html.Replace ("", event_log) + string html = event_log_html.Replace ("", event_log) .Replace ("", UserName) .Replace ("", "file://" + GetAvatar (UserEmail, 48)); @@ -542,7 +550,7 @@ namespace SparkleShare { { foreach (SparkleRepoBase repo in Repositories) { if (repo.Status == SyncStatus.SyncDown || - repo.Status == SyncStatus.SyncUp || + repo.Status == SyncStatus.SyncUp || repo.IsBuffering) { if (OnSyncing != null) @@ -579,7 +587,7 @@ namespace SparkleShare { if (backend == null) return; - + SparkleRepoBase repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend); repo.NewChangeSet += delegate (SparkleChangeSet change_set) { @@ -601,13 +609,13 @@ namespace SparkleShare { }; repo.SyncStatusChanged += delegate (SyncStatus status) { -/* if (status == SyncStatus.SyncUp) { - foreach (string path in repo.UnsyncedFilePaths) - Console.WriteLine (path); - } -*/ - if (status == SyncStatus.Idle || - status == SyncStatus.SyncUp || + /* if (status == SyncStatus.SyncUp) { + foreach (string path in repo.UnsyncedFilePaths) + Console.WriteLine (path); + } + */ + if (status == SyncStatus.Idle || + status == SyncStatus.SyncUp || status == SyncStatus.SyncDown || status == SyncStatus.Error) { @@ -661,7 +669,7 @@ namespace SparkleShare { if (FolderListChanged != null) FolderListChanged (); - + FolderSize = GetFolderSize (); if (FolderSizeChanged != null) @@ -669,8 +677,10 @@ namespace SparkleShare { } - public bool NotificationsEnabled { - get { + public bool NotificationsEnabled + { + get + { string notifications_enabled = SparkleConfig.DefaultConfig.GetConfigOption ("notifications"); @@ -682,10 +692,11 @@ namespace SparkleShare { return notifications_enabled.Equals (bool.TrueString); } } - } + } - public void ToggleNotifications () { + public void ToggleNotifications () + { bool notifications_enabled = SparkleConfig.DefaultConfig.GetConfigOption ("notifications") .Equals (bool.TrueString); @@ -709,26 +720,26 @@ namespace SparkleShare { private string FormatMessage (SparkleChangeSet change_set) { string file_name = ""; - string message = ""; + string message = ""; if (change_set.Added.Count > 0) { file_name = change_set.Added [0]; - message = String.Format (_("added ‘{0}’"), file_name); + message = String.Format (_ ("added ‘{0}’"), file_name); } if (change_set.MovedFrom.Count > 0) { file_name = change_set.MovedFrom [0]; - message = String.Format (_("moved ‘{0}’"), file_name); + message = String.Format (_ ("moved ‘{0}’"), file_name); } if (change_set.Edited.Count > 0) { file_name = change_set.Edited [0]; - message = String.Format (_("edited ‘{0}’"), file_name); + message = String.Format (_ ("edited ‘{0}’"), file_name); } if (change_set.Deleted.Count > 0) { file_name = change_set.Deleted [0]; - message = String.Format (_("deleted ‘{0}’"), file_name); + message = String.Format (_ ("deleted ‘{0}’"), file_name); } int changes_count = (change_set.Added.Count + @@ -745,7 +756,7 @@ namespace SparkleShare { #endif } else if (changes_count < 0) { - message += _("did something magical"); + message += _ ("did something magical"); } return message; @@ -767,14 +778,14 @@ namespace SparkleShare { return 0; try { - foreach (FileInfo file in parent.GetFiles()) { + foreach (FileInfo file in parent.GetFiles ()) { if (!file.Exists) return 0; size += file.Length; } - foreach (DirectoryInfo directory in parent.GetDirectories()) + foreach (DirectoryInfo directory in parent.GetDirectories ()) size += CalculateFolderSize (directory); } catch (Exception) { @@ -807,7 +818,7 @@ namespace SparkleShare { OpenSparkleShareFolder (""); } - + // Adds the user's SparkleShare key to the ssh-agent, // so all activity is done with this key public void AddKey () @@ -817,16 +828,18 @@ namespace SparkleShare { Process process = new Process (); process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.UseShellExecute = false; - process.StartInfo.FileName = "ssh-add"; - process.StartInfo.Arguments = "\"" + Path.Combine (keys_path, key_file_name) + "\""; + process.StartInfo.UseShellExecute = false; + process.StartInfo.FileName = "ssh-add"; + process.StartInfo.Arguments = "\"" + Path.Combine (keys_path, key_file_name) + "\""; process.Start (); process.WaitForExit (); } - public bool BackendIsPresent { - get { + public bool BackendIsPresent + { + get + { return SparkleBackend.DefaultBackend.IsPresent; } } @@ -835,11 +848,13 @@ namespace SparkleShare { // Looks up the user's name from the global configuration public string UserName { - get { + get + { return SparkleConfig.DefaultConfig.User.Name; } - set { + set + { SparkleConfig.DefaultConfig.User = new SparkleUser (value, UserEmail); } } @@ -848,20 +863,22 @@ namespace SparkleShare { // Looks up the user's email from the global configuration public string UserEmail { - get { + get + { return SparkleConfig.DefaultConfig.User.Email; } - - set { + + set + { SparkleConfig.DefaultConfig.User = new SparkleUser (UserName, value); } } - + // Generates and installs an RSA keypair to identify this system public void GenerateKeyPair () { - string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath); + string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath); string key_file_name = "sparkleshare." + UserEmail + ".key"; string key_file_path = Path.Combine (keys_path, key_file_name); @@ -878,7 +895,7 @@ namespace SparkleShare { Process process = new Process () { EnableRaisingEvents = true }; - + process.StartInfo.WorkingDirectory = keys_path; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; @@ -898,7 +915,7 @@ namespace SparkleShare { File.Copy (key_file_path + ".pub", Path.Combine (SparklePath, UserName + "'s key.txt")); }; - + process.Start (); process.WaitForExit (); } @@ -909,8 +926,8 @@ namespace SparkleShare { public void FetchAvatars (List emails, int size) { List old_avatars = new List (); - bool avatar_fetched = false; - string avatar_path = new string [] { + bool avatar_fetched = false; + string avatar_path = new string [] { Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "icons", size + "x" + size, "status"}.Combine (); @@ -922,7 +939,7 @@ namespace SparkleShare { foreach (string raw_email in emails) { // Gravatar wants lowercase emails - string email = raw_email.ToLower (); + string email = raw_email.ToLower (); string avatar_file_path = Path.Combine (avatar_path, "avatar-" + email); if (File.Exists (avatar_file_path)) { @@ -935,30 +952,30 @@ namespace SparkleShare { } } else { - WebClient client = new WebClient (); - string url = "http://gravatar.com/avatar/" + GetMD5 (email) + - ".jpg?s=" + size + "&d=404"; + WebClient client = new WebClient (); + string url = "http://gravatar.com/avatar/" + GetMD5 (email) + + ".jpg?s=" + size + "&d=404"; - try { - // Fetch the avatar - byte [] buffer = client.DownloadData (url); + try { + // Fetch the avatar + byte [] buffer = client.DownloadData (url); - // Write the avatar data to a - // if not empty - if (buffer.Length > 255) { - avatar_fetched = true; - File.WriteAllBytes (avatar_file_path, buffer); - SparkleHelpers.DebugInfo ("Controller", "Fetched gravatar for " + email); - } + // Write the avatar data to a + // if not empty + if (buffer.Length > 255) { + avatar_fetched = true; + File.WriteAllBytes (avatar_file_path, buffer); + SparkleHelpers.DebugInfo ("Controller", "Fetched gravatar for " + email); + } - } catch (WebException e) { + } catch (WebException e) { SparkleHelpers.DebugInfo ("Controller", "Failed fetching gravatar for " + email); // Stop downloading further avatars if we have no internet access if (e.Status == WebExceptionStatus.Timeout) break; - } - } + } + } } // Fetch new versions of the avatars that we @@ -992,23 +1009,23 @@ namespace SparkleShare { // Strip the '.git' from the name string canonical_name = Path.GetFileNameWithoutExtension (remote_folder); - string tmp_folder = Path.Combine (tmp_path, canonical_name); + string tmp_folder = Path.Combine (tmp_path, canonical_name); string backend = null; -/* if (remote_folder.EndsWith (".hg")) { - remote_folder = remote_folder.Substring (0, (remote_folder.Length - 3)); - fetcher = new SparkleFetcherHg (server, remote_folder, tmp_folder); - backend = "Hg"; + /* if (remote_folder.EndsWith (".hg")) { + remote_folder = remote_folder.Substring (0, (remote_folder.Length - 3)); + fetcher = new SparkleFetcherHg (server, remote_folder, tmp_folder); + backend = "Hg"; - } else if (remote_folder.EndsWith (".scp")) { - remote_folder = remote_folder.Substring (0, (remote_folder.Length - 4)); - fetcher = new SparkleFetcherScp (server, remote_folder, tmp_folder); - backend = "Scp"; + } else if (remote_folder.EndsWith (".scp")) { + remote_folder = remote_folder.Substring (0, (remote_folder.Length - 4)); + fetcher = new SparkleFetcherScp (server, remote_folder, tmp_folder); + backend = "Scp"; - } else {*/ - this.fetcher = new SparkleFetcherGit (server, remote_folder, tmp_folder); - backend = "Git"; + } else {*/ + this.fetcher = new SparkleFetcherGit (server, remote_folder, tmp_folder); + backend = "Git"; //} bool target_folder_exists = Directory.Exists ( @@ -1070,8 +1087,8 @@ namespace SparkleShare { if (Directory.Exists (tmp_path)) Directory.Delete (tmp_path, true); }; - - + + this.fetcher.ProgressChanged += delegate (double percentage) { if (FolderFetching != null) FolderFetching (percentage); @@ -1093,8 +1110,8 @@ namespace SparkleShare { private string GetMD5 (string s) { MD5 md5 = new MD5CryptoServiceProvider (); - Byte[] bytes = ASCIIEncoding.Default.GetBytes (s); - Byte[] encoded_bytes = md5.ComputeHash (bytes); + Byte [] bytes = ASCIIEncoding.Default.GetBytes (s); + Byte [] encoded_bytes = md5.ComputeHash (bytes); return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", ""); } @@ -1104,17 +1121,17 @@ namespace SparkleShare { public void TryQuit () { foreach (SparkleRepoBase repo in Repositories) { - if (repo.Status == SyncStatus.SyncUp || + if (repo.Status == SyncStatus.SyncUp || repo.Status == SyncStatus.SyncDown || repo.IsBuffering) { if (OnQuitWhileSyncing != null) OnQuitWhileSyncing (); - + return; } } - + Quit (); } @@ -1132,7 +1149,7 @@ namespace SparkleShare { // Also kill the SSH_AGENT try { // Check if we created the process, if so bring it down. Else leave it running - if (!System.Environment.GetEnvironmentVariable ("SSH_AUTH_SOCK").Equals("unknown")) { + if (!System.Environment.GetEnvironmentVariable ("SSH_AUTH_SOCK").Equals ("unknown")) { int pid = Int32.Parse (System.Environment.GetEnvironmentVariable ("SSH_AGENT_PID")); Process.GetProcessById (pid).Kill (); } @@ -1153,7 +1170,7 @@ namespace SparkleShare { public void AddNoteToFolder (string folder_name, string revision, string note) { folder_name = folder_name.Replace ("%20", " "); - note = note.Replace ("%20", " "); + note = note.Replace ("%20", " "); foreach (SparkleRepoBase repo in Repositories) { if (repo.Name.Equals (folder_name)) @@ -1168,20 +1185,19 @@ namespace SparkleShare { private string AssignColor (string s) { - string hash = GetMD5 (s).Substring (0, 8); + string hash = GetMD5 (s).Substring (0, 8); string numbers = Regex.Replace (hash, "[a-z]", ""); - int number = 3 + int.Parse (numbers); + int number = 3 + int.Parse (numbers); return this.tango_palette [number % this.tango_palette.Length]; } } public class ChangeSet : SparkleChangeSet { } - - + + // All change sets that happened on a day - public class ActivityDay : List - { + public class ActivityDay : List { public DateTime DateTime; public ActivityDay (DateTime date_time) diff --git a/SparkleShare/Windows/SparkleController.cs b/SparkleShare/Windows/SparkleController.cs index 18f1a6ba..5846bbd3 100644 --- a/SparkleShare/Windows/SparkleController.cs +++ b/SparkleShare/Windows/SparkleController.cs @@ -30,12 +30,13 @@ namespace SparkleShare { public class SparkleController : SparkleControllerBase { - public SparkleController () : base () - { - } + public SparkleController () + : base () + { + } - public override void Initialize () - { + public override void Initialize () + { Settings settings = new Settings (); BrowserSettings browserSettings = new BrowserSettings (); @@ -46,28 +47,28 @@ namespace SparkleShare { CEF.RegisterScheme ("application", "sparkleshare", new ApplicationSchemeHandlerFactory ()); CEF.RegisterScheme ("application", "file", new FileSchemeHandlerFactory ()); - - Application.EnableVisualStyles (); - Application.SetCompatibleTextRenderingDefault (false); - // Add msysgit to path, as we cannot asume it is added to the path - // Asume it is installed in @"C:\msysgit\bin" for now - string MSysGit=@"C:\msysgit"; + Application.EnableVisualStyles (); + Application.SetCompatibleTextRenderingDefault (false); - string newPath = MSysGit + @"\bin" + ";" - + MSysGit + @"\mingw\bin" + ";" - + MSysGit + @"\cmd" + ";" - + System.Environment.ExpandEnvironmentVariables ("%PATH%"); - System.Environment.SetEnvironmentVariable ("PATH", newPath); - System.Environment.SetEnvironmentVariable ("PLINK_PROTOCOL", "ssh"); + // Add msysgit to path, as we cannot asume it is added to the path + // Asume it is installed in @"C:\msysgit\bin" for now + string MSysGit = @"C:\msysgit"; - if (String.IsNullOrEmpty (System.Environment.GetEnvironmentVariable ("HOME"))) - System.Environment.SetEnvironmentVariable ("HOME", Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%")); + string newPath = MSysGit + @"\bin" + ";" + + MSysGit + @"\mingw\bin" + ";" + + MSysGit + @"\cmd" + ";" + + System.Environment.ExpandEnvironmentVariables ("%PATH%"); + System.Environment.SetEnvironmentVariable ("PATH", newPath); + System.Environment.SetEnvironmentVariable ("PLINK_PROTOCOL", "ssh"); - StartSshAgent(); + if (String.IsNullOrEmpty (System.Environment.GetEnvironmentVariable ("HOME"))) + System.Environment.SetEnvironmentVariable ("HOME", Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%")); - base.Initialize (); - } + StartSshAgent (); + + base.Initialize (); + } public override string EventLogHTML { @@ -111,53 +112,53 @@ namespace SparkleShare { } - // Creates a .desktop entry in autostart folder to - // start SparkleShare automatically at login - public override void EnableSystemAutostart () - { - } - - - // Installs a launcher so the user can launch SparkleShare - // from the Internet category if needed - public override void InstallLauncher () - { - } + // Creates a .desktop entry in autostart folder to + // start SparkleShare automatically at login + public override void EnableSystemAutostart () + { + } - // Adds the SparkleShare folder to the user's - // list of bookmarked places - public override void AddToBookmarks () - { - } + // Installs a launcher so the user can launch SparkleShare + // from the Internet category if needed + public override void InstallLauncher () + { + } - // Creates the SparkleShare folder in the user's home folder - public override bool CreateSparkleShareFolder () - { - if (!Directory.Exists (SparklePaths.SparklePath)) { + // Adds the SparkleShare folder to the user's + // list of bookmarked places + public override void AddToBookmarks () + { + } - Directory.CreateDirectory (SparklePaths.SparklePath); - SparkleHelpers.DebugInfo ("Config", "Created '" + SparklePaths.SparklePath + "'"); - return true; + // Creates the SparkleShare folder in the user's home folder + public override bool CreateSparkleShareFolder () + { + if (!Directory.Exists (SparklePaths.SparklePath)) { - } + Directory.CreateDirectory (SparklePaths.SparklePath); + SparkleHelpers.DebugInfo ("Config", "Created '" + SparklePaths.SparklePath + "'"); - return false; - } + return true; - public override void OpenSparkleShareFolder (string subfolder) - { - Process process = new Process(); - process.StartInfo.Arguments = ",/root," + SparkleHelpers.CombineMore(SparklePaths.SparklePath, subfolder); - process.StartInfo.FileName = "explorer"; - - process.Start(); - } + } - private void StartSshAgent () - { + return false; + } + + public override void OpenSparkleShareFolder (string subfolder) + { + Process process = new Process (); + process.StartInfo.Arguments = ",/root," + SparkleHelpers.CombineMore (SparklePaths.SparklePath, subfolder); + process.StartInfo.FileName = "explorer"; + + process.Start (); + } + + private void StartSshAgent () + { // Check to see if the process is running Process [] ProcessList = Process.GetProcesses (); foreach (Process p in ProcessList) { @@ -196,9 +197,9 @@ namespace SparkleShare { SparkleHelpers.DebugInfo ("SSH", "ssh-agent started, PID=unknown"); } } - } + } - } + } }