Add notifications for new notes

This commit is contained in:
Hylke Bons 2011-07-23 22:23:14 +01:00
parent 06ede455b7
commit 1eece7806e
2 changed files with 29 additions and 5 deletions

View file

@ -67,9 +67,12 @@ namespace SparkleLib {
public delegate void SyncStatusChangedEventHandler (SyncStatus new_status);
public event SyncStatusChangedEventHandler SyncStatusChanged;
public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set, string source_path);
public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set);
public event NewChangeSetEventHandler NewChangeSet;
public delegate void NewNoteEventHandler (string user_name, string user_email);
public event NewNoteEventHandler NewNote;
public delegate void ConflictResolvedEventHandler ();
public event ConflictResolvedEventHandler ConflictResolved;
@ -441,8 +444,23 @@ namespace SparkleLib {
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Idle);
if (NewChangeSet != null)
NewChangeSet (GetChangeSets (1) [0], LocalPath);
SparkleChangeSet change_set = GetChangeSets (1) [0];
bool note_added = false;
foreach (string added in change_set.Added) {
if (added.StartsWith (".notes")) {
if (NewNote != null)
NewNote (change_set.UserName, change_set.UserEmail);
note_added = true;
break;
}
}
if (!note_added) {
if (NewChangeSet != null)
NewChangeSet (change_set);
}
// There could be changes from a
// resolved conflict. Tries only once,

View file

@ -594,11 +594,17 @@ namespace SparkleShare {
else
repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend);
repo.NewChangeSet += delegate (SparkleChangeSet change_set, string repository_path) {
repo.NewChangeSet += delegate (SparkleChangeSet change_set) {
string message = FormatMessage (change_set);
if (NotificationRaised != null)
NotificationRaised (change_set.UserName, change_set.UserEmail, message, repository_path);
NotificationRaised (change_set.UserName, change_set.UserEmail, message, repo.LocalPath);
};
repo.NewNote += delegate (string user_name, string user_email) {
if (NotificationRaised != null)
NotificationRaised (user_name, user_email,
"added a note to " + Path.GetFileName (repo.LocalPath), repo.LocalPath);
};
repo.ConflictResolved += delegate {