Fixed the spacing
This commit is contained in:
parent
940c5ae159
commit
7f4234a18d
|
@ -118,8 +118,8 @@ namespace SparkleShare {
|
||||||
// Watch the SparkleShare folder
|
// Watch the SparkleShare folder
|
||||||
FileSystemWatcher watcher = new FileSystemWatcher (SparkleConfig.DefaultConfig.FoldersPath) {
|
FileSystemWatcher watcher = new FileSystemWatcher (SparkleConfig.DefaultConfig.FoldersPath) {
|
||||||
IncludeSubdirectories = false,
|
IncludeSubdirectories = false,
|
||||||
EnableRaisingEvents = true,
|
EnableRaisingEvents = true,
|
||||||
Filter = "*"
|
Filter = "*"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove the repository when a delete event occurs
|
// Remove the repository when a delete event occurs
|
||||||
|
@ -147,7 +147,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
string server = xml_doc.GetElementsByTagName ("server") [0].InnerText;
|
string server = xml_doc.GetElementsByTagName ("server") [0].InnerText;
|
||||||
string folder = xml_doc.GetElementsByTagName ("folder") [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 :\
|
// FIXME: this is broken :\
|
||||||
if (OnInvitation != null)
|
if (OnInvitation != null)
|
||||||
|
@ -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,24 +215,28 @@ 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) {
|
||||||
if (repo.HasUnsyncedChanges)
|
if (repo.HasUnsyncedChanges)
|
||||||
unsynced_folders.Add (repo.Name);
|
unsynced_folders.Add (repo.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return unsynced_folders;
|
return unsynced_folders;
|
||||||
}
|
}
|
||||||
|
@ -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)));
|
||||||
|
@ -297,9 +305,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
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) {
|
||||||
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.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;
|
bool squash = false;
|
||||||
foreach (SparkleChangeSet existing_set in stored_activity_day) {
|
foreach (SparkleChangeSet existing_set in stored_activity_day) {
|
||||||
|
@ -314,8 +322,8 @@ namespace SparkleShare {
|
||||||
existing_set.MovedTo.AddRange (change_set.MovedTo);
|
existing_set.MovedTo.AddRange (change_set.MovedTo);
|
||||||
existing_set.Notes.AddRange (change_set.Notes);
|
existing_set.Notes.AddRange (change_set.Notes);
|
||||||
|
|
||||||
existing_set.Added = existing_set.Added.Distinct ().ToList ();
|
existing_set.Added = existing_set.Added.Distinct ().ToList ();
|
||||||
existing_set.Edited = existing_set.Edited.Distinct ().ToList ();
|
existing_set.Edited = existing_set.Edited.Distinct ().ToList ();
|
||||||
existing_set.Deleted = existing_set.Deleted.Distinct ().ToList ();
|
existing_set.Deleted = existing_set.Deleted.Distinct ().ToList ();
|
||||||
|
|
||||||
if (DateTime.Compare (existing_set.Timestamp, change_set.Timestamp) < 1) {
|
if (DateTime.Compare (existing_set.Timestamp, change_set.Timestamp) < 1) {
|
||||||
|
@ -350,10 +358,10 @@ namespace SparkleShare {
|
||||||
FetchAvatars (emails, 48);
|
FetchAvatars (emails, 48);
|
||||||
})).Start ();
|
})).Start ();
|
||||||
|
|
||||||
string event_log_html = EventLogHTML;
|
string event_log_html = EventLogHTML;
|
||||||
string day_entry_html = DayEntryHTML;
|
string day_entry_html = DayEntryHTML;
|
||||||
string event_entry_html = EventEntryHTML;
|
string event_entry_html = EventEntryHTML;
|
||||||
string event_log = "";
|
string event_log = "";
|
||||||
|
|
||||||
foreach (ActivityDay activity_day in activity_days) {
|
foreach (ActivityDay activity_day in activity_days) {
|
||||||
string event_entries = "";
|
string event_entries = "";
|
||||||
|
@ -444,7 +452,7 @@ namespace SparkleShare {
|
||||||
comments += "<div class=\"comment-text\">" +
|
comments += "<div class=\"comment-text\">" +
|
||||||
"<p class=\"comment-author\"" +
|
"<p class=\"comment-author\"" +
|
||||||
" style=\"background-image: url('" + note_avatar + "');\">" +
|
" style=\"background-image: url('" + note_avatar + "');\">" +
|
||||||
note.User.Name + "</p>" +
|
note.User.Name + "</p>" +
|
||||||
note.Body +
|
note.Body +
|
||||||
"</div>";
|
"</div>";
|
||||||
}
|
}
|
||||||
|
@ -458,7 +466,7 @@ namespace SparkleShare {
|
||||||
else
|
else
|
||||||
change_set_avatar = "<!-- $no-buddy-icon-background-image -->";
|
change_set_avatar = "<!-- $no-buddy-icon-background-image -->";
|
||||||
|
|
||||||
event_entry += "</dl>";
|
event_entry += "</dl>";
|
||||||
|
|
||||||
string timestamp = change_set.Timestamp.ToString ("H:mm");
|
string timestamp = change_set.Timestamp.ToString ("H:mm");
|
||||||
|
|
||||||
|
@ -476,19 +484,19 @@ namespace SparkleShare {
|
||||||
.Replace ("<!-- $event-comments -->", comments);
|
.Replace ("<!-- $event-comments -->", comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
string day_entry = "";
|
string day_entry = "";
|
||||||
DateTime today = DateTime.Now;
|
DateTime today = DateTime.Now;
|
||||||
DateTime yesterday = DateTime.Now.AddDays (-1);
|
DateTime yesterday = DateTime.Now.AddDays (-1);
|
||||||
|
|
||||||
if (today.Day == activity_day.DateTime.Day &&
|
if (today.Day == activity_day.DateTime.Day &&
|
||||||
today.Month == activity_day.DateTime.Month &&
|
today.Month == activity_day.DateTime.Month &&
|
||||||
today.Year == activity_day.DateTime.Year) {
|
today.Year == activity_day.DateTime.Year) {
|
||||||
|
|
||||||
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->", "Today");
|
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->", "Today");
|
||||||
|
|
||||||
} else if (yesterday.Day == activity_day.DateTime.Day &&
|
} else if (yesterday.Day == activity_day.DateTime.Day &&
|
||||||
yesterday.Month == activity_day.DateTime.Month &&
|
yesterday.Month == activity_day.DateTime.Month &&
|
||||||
yesterday.Year == activity_day.DateTime.Year) {
|
yesterday.Year == activity_day.DateTime.Year) {
|
||||||
|
|
||||||
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->", "Yesterday");
|
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->", "Yesterday");
|
||||||
|
|
||||||
|
@ -497,20 +505,20 @@ 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")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event_log += day_entry.Replace ("<!-- $day-entry-content -->", event_entries);
|
event_log += day_entry.Replace ("<!-- $day-entry-content -->", event_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log)
|
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log)
|
||||||
.Replace ("<!-- $username -->", UserName)
|
.Replace ("<!-- $username -->", UserName)
|
||||||
.Replace ("<!-- $user-avatar-url -->", "file://" + GetAvatar (UserEmail, 48));
|
.Replace ("<!-- $user-avatar-url -->", "file://" + GetAvatar (UserEmail, 48));
|
||||||
|
|
||||||
|
@ -542,7 +550,7 @@ namespace SparkleShare {
|
||||||
{
|
{
|
||||||
foreach (SparkleRepoBase repo in Repositories) {
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
if (repo.Status == SyncStatus.SyncDown ||
|
if (repo.Status == SyncStatus.SyncDown ||
|
||||||
repo.Status == SyncStatus.SyncUp ||
|
repo.Status == SyncStatus.SyncUp ||
|
||||||
repo.IsBuffering) {
|
repo.IsBuffering) {
|
||||||
|
|
||||||
if (OnSyncing != null)
|
if (OnSyncing != null)
|
||||||
|
@ -601,13 +609,13 @@ 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 ||
|
||||||
status == SyncStatus.Error) {
|
status == SyncStatus.Error) {
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -709,26 +720,26 @@ namespace SparkleShare {
|
||||||
private string FormatMessage (SparkleChangeSet change_set)
|
private string FormatMessage (SparkleChangeSet change_set)
|
||||||
{
|
{
|
||||||
string file_name = "";
|
string file_name = "";
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -817,16 +828,18 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Process process = new Process ();
|
Process process = new Process ();
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
process.StartInfo.FileName = "ssh-add";
|
process.StartInfo.FileName = "ssh-add";
|
||||||
process.StartInfo.Arguments = "\"" + Path.Combine (keys_path, key_file_name) + "\"";
|
process.StartInfo.Arguments = "\"" + Path.Combine (keys_path, key_file_name) + "\"";
|
||||||
process.Start ();
|
process.Start ();
|
||||||
process.WaitForExit ();
|
process.WaitForExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -861,7 +878,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 = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
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);
|
||||||
|
|
||||||
|
@ -909,8 +926,8 @@ namespace SparkleShare {
|
||||||
public void FetchAvatars (List<string> emails, int size)
|
public void FetchAvatars (List<string> emails, int size)
|
||||||
{
|
{
|
||||||
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 = new string [] {
|
string avatar_path = new string [] {
|
||||||
Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath),
|
Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath),
|
||||||
"icons", size + "x" + size, "status"}.Combine ();
|
"icons", size + "x" + size, "status"}.Combine ();
|
||||||
|
|
||||||
|
@ -922,7 +939,7 @@ namespace SparkleShare {
|
||||||
foreach (string raw_email in emails) {
|
foreach (string raw_email in emails) {
|
||||||
|
|
||||||
// Gravatar wants lowercase 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);
|
string avatar_file_path = Path.Combine (avatar_path, "avatar-" + email);
|
||||||
|
|
||||||
if (File.Exists (avatar_file_path)) {
|
if (File.Exists (avatar_file_path)) {
|
||||||
|
@ -935,30 +952,30 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
WebClient client = new WebClient ();
|
WebClient client = new WebClient ();
|
||||||
string url = "http://gravatar.com/avatar/" + GetMD5 (email) +
|
string url = "http://gravatar.com/avatar/" + GetMD5 (email) +
|
||||||
".jpg?s=" + size + "&d=404";
|
".jpg?s=" + size + "&d=404";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch the avatar
|
// Fetch the avatar
|
||||||
byte [] buffer = client.DownloadData (url);
|
byte [] buffer = client.DownloadData (url);
|
||||||
|
|
||||||
// Write the avatar data to a
|
// Write the avatar data to a
|
||||||
// if not empty
|
// if not empty
|
||||||
if (buffer.Length > 255) {
|
if (buffer.Length > 255) {
|
||||||
avatar_fetched = true;
|
avatar_fetched = true;
|
||||||
File.WriteAllBytes (avatar_file_path, buffer);
|
File.WriteAllBytes (avatar_file_path, buffer);
|
||||||
SparkleHelpers.DebugInfo ("Controller", "Fetched gravatar for " + email);
|
SparkleHelpers.DebugInfo ("Controller", "Fetched gravatar for " + email);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (WebException e) {
|
} catch (WebException e) {
|
||||||
SparkleHelpers.DebugInfo ("Controller", "Failed fetching gravatar for " + email);
|
SparkleHelpers.DebugInfo ("Controller", "Failed fetching gravatar for " + email);
|
||||||
|
|
||||||
// Stop downloading further avatars if we have no internet access
|
// Stop downloading further avatars if we have no internet access
|
||||||
if (e.Status == WebExceptionStatus.Timeout)
|
if (e.Status == WebExceptionStatus.Timeout)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch new versions of the avatars that we
|
// Fetch new versions of the avatars that we
|
||||||
|
@ -992,23 +1009,23 @@ namespace SparkleShare {
|
||||||
|
|
||||||
// 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 (tmp_path, canonical_name);
|
string tmp_folder = Path.Combine (tmp_path, canonical_name);
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
} else if (remote_folder.EndsWith (".scp")) {
|
} else if (remote_folder.EndsWith (".scp")) {
|
||||||
remote_folder = remote_folder.Substring (0, (remote_folder.Length - 4));
|
remote_folder = remote_folder.Substring (0, (remote_folder.Length - 4));
|
||||||
fetcher = new SparkleFetcherScp (server, remote_folder, tmp_folder);
|
fetcher = new SparkleFetcherScp (server, remote_folder, tmp_folder);
|
||||||
backend = "Scp";
|
backend = "Scp";
|
||||||
|
|
||||||
} else {*/
|
} else {*/
|
||||||
this.fetcher = new SparkleFetcherGit (server, remote_folder, tmp_folder);
|
this.fetcher = new SparkleFetcherGit (server, remote_folder, tmp_folder);
|
||||||
backend = "Git";
|
backend = "Git";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
bool target_folder_exists = Directory.Exists (
|
bool target_folder_exists = Directory.Exists (
|
||||||
|
@ -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 ("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1104,7 +1121,7 @@ namespace SparkleShare {
|
||||||
public void TryQuit ()
|
public void TryQuit ()
|
||||||
{
|
{
|
||||||
foreach (SparkleRepoBase repo in Repositories) {
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
if (repo.Status == SyncStatus.SyncUp ||
|
if (repo.Status == SyncStatus.SyncUp ||
|
||||||
repo.Status == SyncStatus.SyncDown ||
|
repo.Status == SyncStatus.SyncDown ||
|
||||||
repo.IsBuffering) {
|
repo.IsBuffering) {
|
||||||
|
|
||||||
|
@ -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 ();
|
||||||
}
|
}
|
||||||
|
@ -1153,7 +1170,7 @@ namespace SparkleShare {
|
||||||
public void AddNoteToFolder (string folder_name, string revision, string note)
|
public void AddNoteToFolder (string folder_name, string revision, string note)
|
||||||
{
|
{
|
||||||
folder_name = folder_name.Replace ("%20", " ");
|
folder_name = folder_name.Replace ("%20", " ");
|
||||||
note = note.Replace ("%20", " ");
|
note = note.Replace ("%20", " ");
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Repositories) {
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
if (repo.Name.Equals (folder_name))
|
if (repo.Name.Equals (folder_name))
|
||||||
|
@ -1168,9 +1185,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
private string AssignColor (string s)
|
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]", "");
|
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];
|
return this.tango_palette [number % this.tango_palette.Length];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -30,12 +30,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleController : SparkleControllerBase {
|
public class SparkleController : SparkleControllerBase {
|
||||||
|
|
||||||
public SparkleController () : base ()
|
public SparkleController ()
|
||||||
{
|
: base ()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public override void Initialize ()
|
public override void Initialize ()
|
||||||
{
|
{
|
||||||
Settings settings = new Settings ();
|
Settings settings = new Settings ();
|
||||||
BrowserSettings browserSettings = new BrowserSettings ();
|
BrowserSettings browserSettings = new BrowserSettings ();
|
||||||
|
|
||||||
|
@ -47,27 +48,27 @@ namespace SparkleShare {
|
||||||
CEF.RegisterScheme ("application", "sparkleshare", new ApplicationSchemeHandlerFactory ());
|
CEF.RegisterScheme ("application", "sparkleshare", new ApplicationSchemeHandlerFactory ());
|
||||||
CEF.RegisterScheme ("application", "file", new FileSchemeHandlerFactory ());
|
CEF.RegisterScheme ("application", "file", new FileSchemeHandlerFactory ());
|
||||||
|
|
||||||
Application.EnableVisualStyles ();
|
Application.EnableVisualStyles ();
|
||||||
Application.SetCompatibleTextRenderingDefault (false);
|
Application.SetCompatibleTextRenderingDefault (false);
|
||||||
|
|
||||||
// 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" + ";"
|
||||||
+ MSysGit + @"\cmd" + ";"
|
+ MSysGit + @"\cmd" + ";"
|
||||||
+ System.Environment.ExpandEnvironmentVariables ("%PATH%");
|
+ System.Environment.ExpandEnvironmentVariables ("%PATH%");
|
||||||
System.Environment.SetEnvironmentVariable ("PATH", newPath);
|
System.Environment.SetEnvironmentVariable ("PATH", newPath);
|
||||||
System.Environment.SetEnvironmentVariable ("PLINK_PROTOCOL", "ssh");
|
System.Environment.SetEnvironmentVariable ("PLINK_PROTOCOL", "ssh");
|
||||||
|
|
||||||
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 ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string EventLogHTML
|
public override string EventLogHTML
|
||||||
{
|
{
|
||||||
|
@ -111,53 +112,53 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Creates a .desktop entry in autostart folder to
|
// Creates a .desktop entry in autostart folder to
|
||||||
// start SparkleShare automatically at login
|
// start SparkleShare automatically at login
|
||||||
public override void EnableSystemAutostart ()
|
public override void EnableSystemAutostart ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Installs a launcher so the user can launch SparkleShare
|
// Installs a launcher so the user can launch SparkleShare
|
||||||
// from the Internet category if needed
|
// from the Internet category if needed
|
||||||
public override void InstallLauncher ()
|
public override void InstallLauncher ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Adds the SparkleShare folder to the user's
|
// Adds the SparkleShare folder to the user's
|
||||||
// list of bookmarked places
|
// list of bookmarked places
|
||||||
public override void AddToBookmarks ()
|
public override void AddToBookmarks ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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 (SparklePaths.SparklePath)) {
|
||||||
|
|
||||||
Directory.CreateDirectory (SparklePaths.SparklePath);
|
Directory.CreateDirectory (SparklePaths.SparklePath);
|
||||||
SparkleHelpers.DebugInfo ("Config", "Created '" + SparklePaths.SparklePath + "'");
|
SparkleHelpers.DebugInfo ("Config", "Created '" + SparklePaths.SparklePath + "'");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ()
|
||||||
{
|
{
|
||||||
// Check to see if the process is running
|
// Check to see if the process is running
|
||||||
Process [] ProcessList = Process.GetProcesses ();
|
Process [] ProcessList = Process.GetProcesses ();
|
||||||
foreach (Process p in ProcessList) {
|
foreach (Process p in ProcessList) {
|
||||||
|
@ -196,9 +197,9 @@ namespace SparkleShare {
|
||||||
SparkleHelpers.DebugInfo ("SSH", "ssh-agent started, PID=unknown");
|
SparkleHelpers.DebugInfo ("SSH", "ssh-agent started, PID=unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue