2012-06-16 23:24:14 +00:00
|
|
|
|
// 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;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace SparkleLib {
|
|
|
|
|
|
|
|
|
|
public enum SparkleChangeType {
|
|
|
|
|
Added,
|
|
|
|
|
Edited,
|
|
|
|
|
Deleted,
|
|
|
|
|
Moved
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SparkleChangeSet {
|
|
|
|
|
|
|
|
|
|
public SparkleUser User = new SparkleUser ("Unknown", "Unknown");
|
|
|
|
|
|
|
|
|
|
public SparkleFolder Folder;
|
|
|
|
|
public string Revision;
|
|
|
|
|
public DateTime Timestamp;
|
|
|
|
|
public DateTime FirstTimestamp;
|
|
|
|
|
public Uri RemoteUrl;
|
|
|
|
|
|
|
|
|
|
public List<SparkleChange> Changes = new List<SparkleChange> ();
|
2012-11-27 21:57:05 +00:00
|
|
|
|
|
|
|
|
|
public string ToMessage ()
|
|
|
|
|
{
|
|
|
|
|
string message = "added ‘{0}’";
|
|
|
|
|
|
|
|
|
|
switch (Changes [0].Type) {
|
|
|
|
|
case SparkleChangeType.Edited: message = "edited ‘{0}’"; break;
|
|
|
|
|
case SparkleChangeType.Deleted: message = "deleted ‘{0}’"; break;
|
|
|
|
|
case SparkleChangeType.Moved: message = "moved ‘{0}’"; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Changes.Count == 1) {
|
|
|
|
|
return message = string.Format (message, Changes [0].Path);
|
|
|
|
|
|
|
|
|
|
} else if (Changes.Count > 1) {
|
|
|
|
|
message = string.Format (message, Changes [0].Path);
|
|
|
|
|
|
|
|
|
|
if ((Changes.Count - 1) == 1)
|
|
|
|
|
return string.Format (message + " and one other event", Changes.Count - 1);
|
|
|
|
|
else
|
|
|
|
|
return string.Format (message + " and {0} other events", Changes.Count - 1);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return "did something magical";
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-16 23:24:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SparkleChange {
|
|
|
|
|
|
|
|
|
|
public SparkleChangeType Type;
|
2012-10-20 22:25:36 +00:00
|
|
|
|
public DateTime Timestamp;
|
2012-10-14 13:21:22 +00:00
|
|
|
|
public bool IsFolder = false;
|
2012-10-20 22:25:36 +00:00
|
|
|
|
|
2012-06-16 23:24:14 +00:00
|
|
|
|
public string Path;
|
2012-06-19 14:59:54 +00:00
|
|
|
|
public string MovedToPath;
|
2012-06-16 23:24:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SparkleFolder {
|
|
|
|
|
|
|
|
|
|
public string Name;
|
|
|
|
|
public Uri RemoteAddress;
|
|
|
|
|
|
|
|
|
|
public string FullPath {
|
|
|
|
|
get {
|
|
|
|
|
string custom_path = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute (Name, "path");
|
|
|
|
|
|
|
|
|
|
if (custom_path != null)
|
|
|
|
|
return Path.Combine (custom_path, Name);
|
|
|
|
|
else
|
|
|
|
|
return Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, Name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SparkleFolder (string name)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-28 16:13:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SparkleAnnouncement {
|
|
|
|
|
|
|
|
|
|
public readonly string FolderIdentifier;
|
|
|
|
|
public readonly string Message;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SparkleAnnouncement (string folder_identifier, string message)
|
|
|
|
|
{
|
|
|
|
|
FolderIdentifier = folder_identifier;
|
|
|
|
|
Message = message;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-16 23:24:14 +00:00
|
|
|
|
}
|