SparkleShare/Sparkles/ChangeSet.cs

112 lines
3 KiB
C#
Raw Normal View History

2012-06-16 23:24:14 +00:00
// SparkleShare, a collaboration and sharing tool.
2017-07-23 12:47:54 +00:00
// Copyright (C) 2010 Hylke Bons <hi@planetpeanut.uk>
2012-06-16 23:24:14 +00:00
//
// This program is free software: you can redistribute it and/or modify
2013-10-11 15:13:46 +00:00
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
2012-06-16 23:24:14 +00:00
//
// 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;
2016-03-31 08:35:26 +00:00
namespace Sparkles {
2012-06-16 23:24:14 +00:00
2016-03-30 23:56:48 +00:00
public enum ChangeType {
2012-06-16 23:24:14 +00:00
Added,
Edited,
Deleted,
Moved
}
2016-03-30 23:36:31 +00:00
public class ChangeSet {
2012-06-16 23:24:14 +00:00
2016-03-30 23:36:31 +00:00
public User User = new User ("Unknown", "Unknown");
2012-06-16 23:24:14 +00:00
public SparkleFolder Folder;
public string Revision;
public DateTime Timestamp;
public DateTime FirstTimestamp;
public Uri RemoteUrl;
2016-03-30 23:56:48 +00:00
public List<Change> Changes = new List<Change> ();
public string ToMessage ()
{
string message = "added: {0}";
2018-02-18 14:06:14 +00:00
switch (Changes [0].Type) {
2016-03-30 23:56:48 +00:00
case ChangeType.Edited: message = "edited: {0}"; break;
case ChangeType.Deleted: message = "deleted: {0}"; break;
case ChangeType.Moved: message = "moved: {0}"; break;
}
if (Changes.Count > 0)
return string.Format (message, Changes [0].Path);
else
return "did something magical";
}
2012-06-16 23:24:14 +00:00
}
2016-03-30 23:56:48 +00:00
public class Change {
2012-06-16 23:24:14 +00:00
2016-03-30 23:56:48 +00:00
public ChangeType Type;
2012-10-20 22:25:36 +00:00
public DateTime Timestamp;
public bool IsFolder;
2018-02-18 14:06:14 +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 = Configuration.DefaultConfiguration.GetFolderOptionalAttribute (Name, "path");
2012-06-16 23:24:14 +00:00
if (custom_path != null)
return Path.Combine (custom_path, Name);
return Path.Combine (Configuration.DefaultConfiguration.FoldersPath,
new Uri (Configuration.DefaultConfiguration.UrlByName (Name)).Host,
Name);
2012-06-16 23:24:14 +00:00
}
}
public SparkleFolder (string name)
{
Name = name;
}
}
2012-07-28 16:13:50 +00:00
2016-03-30 23:56:48 +00:00
public class Announcement {
2012-07-28 16:13:50 +00:00
public readonly string FolderIdentifier;
public readonly string Message;
2016-03-30 23:56:48 +00:00
public Announcement (string folder_identifier, string message)
2012-07-28 16:13:50 +00:00
{
FolderIdentifier = folder_identifier;
Message = message;
}
}
2012-06-16 23:24:14 +00:00
}