Fixed the spacing

This commit is contained in:
Konstantinos Vaggelakos 2011-10-10 01:43:33 +02:00
parent 940c5ae159
commit 7f4234a18d
2 changed files with 215 additions and 198 deletions

View file

@ -162,8 +162,10 @@ namespace SparkleShare {
} }
public bool FirstRun { public bool FirstRun
get { {
get
{
return SparkleConfig.DefaultConfig.User.Email.Equals ("Unknown"); return SparkleConfig.DefaultConfig.User.Email.Equals ("Unknown");
} }
} }
@ -188,8 +190,8 @@ namespace SparkleShare {
SparkleHelpers.DebugInfo ("WebRequest", url); SparkleHelpers.DebugInfo ("WebRequest", url);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url); HttpWebRequest request = (HttpWebRequest)WebRequest.Create (url);
HttpWebResponse response = (HttpWebResponse) request.GetResponse(); HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
if (response.StatusCode == HttpStatusCode.OK) { if (response.StatusCode == HttpStatusCode.OK) {
response.Close (); response.Close ();
@ -202,8 +204,10 @@ namespace SparkleShare {
} }
public List<string> Folders { public List<string> Folders
get { {
get
{
List<string> folders = SparkleConfig.DefaultConfig.Folders; List<string> folders = SparkleConfig.DefaultConfig.Folders;
folders.Sort (); folders.Sort ();
return folders; return folders;
@ -211,18 +215,22 @@ namespace SparkleShare {
} }
public List<string> PreviousHosts { public List<string> PreviousHosts
get { {
get
{
List<string> hosts = SparkleConfig.DefaultConfig.HostsWithUsername; List<string> hosts = SparkleConfig.DefaultConfig.HostsWithUsername;
hosts.AddRange(SparkleConfig.DefaultConfig.Hosts); hosts.AddRange (SparkleConfig.DefaultConfig.Hosts);
hosts.Sort (); hosts.Sort ();
return hosts; return hosts;
} }
} }
public List<string> UnsyncedFolders { public List<string> UnsyncedFolders
get { {
get
{
List<string> unsynced_folders = new List<string> (); List<string> unsynced_folders = new List<string> ();
foreach (SparkleRepoBase repo in Repositories) { foreach (SparkleRepoBase repo in Repositories) {
@ -263,7 +271,7 @@ namespace SparkleShare {
if (name == null) if (name == null)
return GetLog (); return GetLog ();
string path = new string [] {SparkleConfig.DefaultConfig.FoldersPath, name}.Combine (); string path = new string [] { SparkleConfig.DefaultConfig.FoldersPath, name }.Combine ();
int log_size = 50; int log_size = 50;
foreach (SparkleRepoBase repo in Repositories) { foreach (SparkleRepoBase repo in Repositories) {
@ -282,7 +290,7 @@ namespace SparkleShare {
public string GetHTMLLog (List<SparkleChangeSet> change_sets) public string GetHTMLLog (List<SparkleChangeSet> change_sets)
{ {
List <ActivityDay> activity_days = new List <ActivityDay> (); List<ActivityDay> activity_days = new List<ActivityDay> ();
List<string> emails = new List<string> (); List<string> emails = new List<string> ();
change_sets.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp))); change_sets.Sort ((x, y) => (x.Timestamp.CompareTo (y.Timestamp)));
@ -497,13 +505,13 @@ namespace SparkleShare {
// TRANSLATORS: This is the date in the event logs // TRANSLATORS: This is the date in the event logs
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->", day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
activity_day.DateTime.ToString (_("dddd, MMMM d, yyyy"))); activity_day.DateTime.ToString (_ ("dddd, MMMM d, yyyy")));
} else { } else {
// TRANSLATORS: This is the date in the event logs, without the year // TRANSLATORS: This is the date in the event logs, without the year
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->", day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
activity_day.DateTime.ToString (_("dddd, MMMM d"))); activity_day.DateTime.ToString (_ ("dddd, MMMM d")));
} }
} }
@ -601,11 +609,11 @@ namespace SparkleShare {
}; };
repo.SyncStatusChanged += delegate (SyncStatus status) { repo.SyncStatusChanged += delegate (SyncStatus status) {
/* if (status == SyncStatus.SyncUp) { /* if (status == SyncStatus.SyncUp) {
foreach (string path in repo.UnsyncedFilePaths) foreach (string path in repo.UnsyncedFilePaths)
Console.WriteLine (path); Console.WriteLine (path);
} }
*/ */
if (status == SyncStatus.Idle || if (status == SyncStatus.Idle ||
status == SyncStatus.SyncUp || status == SyncStatus.SyncUp ||
status == SyncStatus.SyncDown || status == SyncStatus.SyncDown ||
@ -669,8 +677,10 @@ namespace SparkleShare {
} }
public bool NotificationsEnabled { public bool NotificationsEnabled
get { {
get
{
string notifications_enabled = string notifications_enabled =
SparkleConfig.DefaultConfig.GetConfigOption ("notifications"); SparkleConfig.DefaultConfig.GetConfigOption ("notifications");
@ -685,7 +695,8 @@ namespace SparkleShare {
} }
public void ToggleNotifications () { public void ToggleNotifications ()
{
bool notifications_enabled = bool notifications_enabled =
SparkleConfig.DefaultConfig.GetConfigOption ("notifications") SparkleConfig.DefaultConfig.GetConfigOption ("notifications")
.Equals (bool.TrueString); .Equals (bool.TrueString);
@ -713,22 +724,22 @@ namespace SparkleShare {
if (change_set.Added.Count > 0) { if (change_set.Added.Count > 0) {
file_name = change_set.Added [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) { if (change_set.MovedFrom.Count > 0) {
file_name = change_set.MovedFrom [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) { if (change_set.Edited.Count > 0) {
file_name = change_set.Edited [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) { if (change_set.Deleted.Count > 0) {
file_name = change_set.Deleted [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 + int changes_count = (change_set.Added.Count +
@ -745,7 +756,7 @@ namespace SparkleShare {
#endif #endif
} else if (changes_count < 0) { } else if (changes_count < 0) {
message += _("did something magical"); message += _ ("did something magical");
} }
return message; return message;
@ -767,14 +778,14 @@ namespace SparkleShare {
return 0; return 0;
try { try {
foreach (FileInfo file in parent.GetFiles()) { foreach (FileInfo file in parent.GetFiles ()) {
if (!file.Exists) if (!file.Exists)
return 0; return 0;
size += file.Length; size += file.Length;
} }
foreach (DirectoryInfo directory in parent.GetDirectories()) foreach (DirectoryInfo directory in parent.GetDirectories ())
size += CalculateFolderSize (directory); size += CalculateFolderSize (directory);
} catch (Exception) { } catch (Exception) {
@ -825,8 +836,10 @@ namespace SparkleShare {
} }
public bool BackendIsPresent { public bool BackendIsPresent
get { {
get
{
return SparkleBackend.DefaultBackend.IsPresent; return SparkleBackend.DefaultBackend.IsPresent;
} }
} }
@ -835,11 +848,13 @@ namespace SparkleShare {
// Looks up the user's name from the global configuration // Looks up the user's name from the global configuration
public string UserName public string UserName
{ {
get { get
{
return SparkleConfig.DefaultConfig.User.Name; return SparkleConfig.DefaultConfig.User.Name;
} }
set { set
{
SparkleConfig.DefaultConfig.User = new SparkleUser (value, UserEmail); SparkleConfig.DefaultConfig.User = new SparkleUser (value, UserEmail);
} }
} }
@ -848,11 +863,13 @@ namespace SparkleShare {
// Looks up the user's email from the global configuration // Looks up the user's email from the global configuration
public string UserEmail public string UserEmail
{ {
get { get
{
return SparkleConfig.DefaultConfig.User.Email; return SparkleConfig.DefaultConfig.User.Email;
} }
set { set
{
SparkleConfig.DefaultConfig.User = new SparkleUser (UserName, value); SparkleConfig.DefaultConfig.User = new SparkleUser (UserName, value);
} }
} }
@ -996,7 +1013,7 @@ namespace SparkleShare {
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";
@ -1093,8 +1110,8 @@ namespace SparkleShare {
private string GetMD5 (string s) private string GetMD5 (string s)
{ {
MD5 md5 = new MD5CryptoServiceProvider (); MD5 md5 = new MD5CryptoServiceProvider ();
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s); Byte [] bytes = ASCIIEncoding.Default.GetBytes (s);
Byte[] encoded_bytes = md5.ComputeHash (bytes); Byte [] encoded_bytes = md5.ComputeHash (bytes);
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", ""); return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
} }
@ -1132,7 +1149,7 @@ namespace SparkleShare {
// Also kill the SSH_AGENT // Also kill the SSH_AGENT
try { try {
// Check if we created the process, if so bring it down. Else leave it running // 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")); int pid = Int32.Parse (System.Environment.GetEnvironmentVariable ("SSH_AGENT_PID"));
Process.GetProcessById (pid).Kill (); Process.GetProcessById (pid).Kill ();
} }
@ -1180,8 +1197,7 @@ namespace SparkleShare {
// All change sets that happened on a day // All change sets that happened on a day
public class ActivityDay : List <SparkleChangeSet> public class ActivityDay : List<SparkleChangeSet> {
{
public DateTime DateTime; public DateTime DateTime;
public ActivityDay (DateTime date_time) public ActivityDay (DateTime date_time)

View file

@ -30,7 +30,8 @@ namespace SparkleShare {
public class SparkleController : SparkleControllerBase { public class SparkleController : SparkleControllerBase {
public SparkleController () : base () public SparkleController ()
: base ()
{ {
} }
@ -52,7 +53,7 @@ namespace SparkleShare {
// Add msysgit to path, as we cannot asume it is added to the path // Add msysgit to path, as we cannot asume it is added to the path
// Asume it is installed in @"C:\msysgit\bin" for now // Asume it is installed in @"C:\msysgit\bin" for now
string MSysGit=@"C:\msysgit"; string MSysGit = @"C:\msysgit";
string newPath = MSysGit + @"\bin" + ";" string newPath = MSysGit + @"\bin" + ";"
+ MSysGit + @"\mingw\bin" + ";" + MSysGit + @"\mingw\bin" + ";"
@ -64,7 +65,7 @@ namespace SparkleShare {
if (String.IsNullOrEmpty (System.Environment.GetEnvironmentVariable ("HOME"))) if (String.IsNullOrEmpty (System.Environment.GetEnvironmentVariable ("HOME")))
System.Environment.SetEnvironmentVariable ("HOME", Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%")); System.Environment.SetEnvironmentVariable ("HOME", Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%"));
StartSshAgent(); StartSshAgent ();
base.Initialize (); base.Initialize ();
} }
@ -149,11 +150,11 @@ namespace SparkleShare {
public override void OpenSparkleShareFolder (string subfolder) public override void OpenSparkleShareFolder (string subfolder)
{ {
Process process = new Process(); Process process = new Process ();
process.StartInfo.Arguments = ",/root," + SparkleHelpers.CombineMore(SparklePaths.SparklePath, subfolder); process.StartInfo.Arguments = ",/root," + SparkleHelpers.CombineMore (SparklePaths.SparklePath, subfolder);
process.StartInfo.FileName = "explorer"; process.StartInfo.FileName = "explorer";
process.Start(); process.Start ();
} }
private void StartSshAgent () private void StartSshAgent ()