This commit is contained in:
Hylke Bons 2012-07-28 18:13:50 +02:00
parent 161bfea8b4
commit 4075967199
11 changed files with 66 additions and 187 deletions

View file

@ -4,7 +4,6 @@ TARGET = library
ASSEMBLY_INFO_SOURCE = Defines.cs
SOURCES = \
SparkleAnnouncement.cs \
SparkleBackend.cs \
SparkleConfig.cs \
SparkleExceptions.cs \

View file

@ -1,34 +0,0 @@
// 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;
namespace SparkleLib {
public class SparkleAnnouncement {
public readonly string FolderIdentifier;
public readonly string Message;
public SparkleAnnouncement (string folder_identifier, string message)
{
FolderIdentifier = folder_identifier;
Message = message;
}
}
}

View file

@ -37,7 +37,6 @@
<ItemGroup>
<Compile Include="SparkleRepoBase.cs" />
<Compile Include="SparkleFetcherBase.cs" />
<Compile Include="SparkleAnnouncement.cs" />
<Compile Include="SparkleWrappers.cs" />
<Compile Include="SparkleListenerBase.cs" />
<Compile Include="SparkleListenerFactory.cs" />

View file

@ -37,12 +37,6 @@ namespace SparkleLib {
// This is SparkleShare's centralized notification service.
// It communicates "It's time to sync!" signals between clients.
//
// Here's how it works: the client listens to a channel (the
// folder identifier, a SHA-1 hash) for when it's time to sync.
// Clients also send the current revision hash to the channel
// for other clients to pick up when you've synced up any
// changes.
//
// Please see the SparkleShare wiki if you wish to run
// your own service instead
if (string.IsNullOrEmpty (uri))

View file

@ -22,8 +22,8 @@ namespace SparkleLib {
public class SparkleWatcher : FileSystemWatcher {
public event ChangeEventEventHandler ChangeEvent = delegate { };
public delegate void ChangeEventEventHandler (FileSystemEventArgs args);
public event ChangeEventEventHandler ChangeEvent;
private Object thread_lock = new Object ();
@ -34,25 +34,16 @@ namespace SparkleLib {
EnableRaisingEvents = true;
Filter = "*";
Changed += delegate (object o, FileSystemEventArgs args) {
if (ChangeEvent != null)
ChangeEvent (args);
};
Changed += OnChanged;
Created += OnChanged;
Deleted += OnChanged;
Renamed += OnChanged;
}
Created += delegate (object o, FileSystemEventArgs args) {
if (ChangeEvent != null)
ChangeEvent (args);
};
Deleted += delegate (object o, FileSystemEventArgs args) {
if (ChangeEvent != null)
ChangeEvent (args);
};
Renamed += delegate (object o, RenamedEventArgs args) {
if (ChangeEvent != null)
ChangeEvent (args);
};
private void OnChanged (object sender, FileSystemEventArgs args)
{
ChangeEvent (args);
}

View file

@ -75,4 +75,18 @@ namespace SparkleLib {
Name = name;
}
}
public class SparkleAnnouncement {
public readonly string FolderIdentifier;
public readonly string Message;
public SparkleAnnouncement (string folder_identifier, string message)
{
FolderIdentifier = folder_identifier;
Message = message;
}
}
}

View file

@ -281,12 +281,13 @@ namespace SparkleShare {
private void CreateAnimationFrames ()
{
this.animation_frames = new Gdk.Pixbuf [5];
this.animation_frames [0] = SparkleUIHelpers.GetIcon ("process-syncing-i", 24);
this.animation_frames [1] = SparkleUIHelpers.GetIcon ("process-syncing-ii", 24);
this.animation_frames [2] = SparkleUIHelpers.GetIcon ("process-syncing-iii", 24);
this.animation_frames [3] = SparkleUIHelpers.GetIcon ("process-syncing-iiii", 24);
this.animation_frames [4] = SparkleUIHelpers.GetIcon ("process-syncing-iiiii", 24);
this.animation_frames = new Gdk.Pixbuf [] {
SparkleUIHelpers.GetIcon ("process-syncing-i", 24),
SparkleUIHelpers.GetIcon ("process-syncing-ii", 24),
SparkleUIHelpers.GetIcon ("process-syncing-iii", 24),
SparkleUIHelpers.GetIcon ("process-syncing-iiii", 24),
SparkleUIHelpers.GetIcon ("process-syncing-iiiii", 24)
}
}

View file

@ -102,8 +102,9 @@ namespace SparkleShare {
// There aren't any bindings in MonoMac to support this yet, so
// we call out to an applescript to do the job
Process process = new Process ();
process.StartInfo.FileName = "osascript";
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = "osascript";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.Arguments = "-e 'tell application \"System Events\" to " +
"make login item at end with properties {path:\"" + NSBundle.MainBundle.BundlePath + "\", hidden:false}'";

View file

@ -1,19 +1,3 @@
// 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/>.
// Originally taken from:
// https://github.com/jesse99/Continuum/blob/master/source/shared/DirectoryWatcher.cs
// Modified to use MonoMac and integrate into SparkleShare
@ -120,7 +104,6 @@ namespace SparkleShare {
GC.SuppressFinalize (this);
throw new InvalidOperationException ("Failed to start FSEvent stream for " + path);
}
}
@ -186,36 +169,23 @@ namespace SparkleShare {
private extern static IntPtr CFRunLoopGetMain ();
[DllImport("/System/Library/Frameworks/CoreServices.framework/CoreServices")]
private extern static IntPtr FSEventStreamCreate (
IntPtr allocator,
FSEventStreamCallback callback,
IntPtr context,
IntPtr pathsToWatch,
ulong sinceWhen,
double latency,
FSEventStreamCreateFlags flags);
private extern static IntPtr FSEventStreamCreate (IntPtr allocator, FSEventStreamCallback callback,
IntPtr context, IntPtr pathsToWatch, ulong sinceWhen, double latency, FSEventStreamCreateFlags flags);
[DllImport("/System/Library/Frameworks/CoreServices.framework/CoreServices")]
private extern static void FSEventStreamScheduleWithRunLoop (
IntPtr streamRef,
IntPtr runLoop,
IntPtr runLoopMode);
private extern static void FSEventStreamScheduleWithRunLoop (IntPtr streamRef, IntPtr runLoop, IntPtr runLoopMode);
[DllImport("/System/Library/Frameworks/CoreServices.framework/CoreServices")]
[return: MarshalAs (UnmanagedType.U1)]
private extern static bool FSEventStreamStart (
IntPtr streamRef);
[DllImport("/System/Library/Frameworks/CoreServices.framework/CoreServices")]
private extern static bool FSEventStreamStart (IntPtr streamRef);
[DllImport("/System/Library/Frameworks/CoreServices.framework/CoreServices")]
private extern static void FSEventStreamStop (
IntPtr streamRef);
private extern static void FSEventStreamStop (IntPtr streamRef);
[DllImport("/System/Library/Frameworks/CoreServices.framework/CoreServices")]
private extern static void FSEventStreamInvalidate (
IntPtr streamRef);
private extern static void FSEventStreamInvalidate (IntPtr streamRef);
[DllImport("/System/Library/Frameworks/CoreServices.framework/CoreServices")]
private extern static void FSEventStreamRelease (
IntPtr streamRef);
private extern static void FSEventStreamRelease (IntPtr streamRef);
}
}

View file

@ -113,9 +113,7 @@ namespace SparkleShare {
Controller.UpdateMenuEvent += delegate {
using (var a = new NSAutoreleasePool ())
{
InvokeOnMainThread (delegate {
CreateMenu ();
});
InvokeOnMainThread (() => CreateMenu);
}
};
@ -321,35 +319,26 @@ namespace SparkleShare {
private void CreateAnimationFrames ()
{
this.animation_frames = new NSImage [] {
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-i.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-ii.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-iii.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-iiii.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-iiiii.png"))
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-i.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-ii.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-iii.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-iiii.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-iiiii.png"))
};
this.animation_frames_active = new NSImage [] {
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-i-active.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-ii-active.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-iii-active.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-iiii-active.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "process-syncing-iiiii-active.png"))
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-i-active.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-ii-active.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-iii-active.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-iiii-active.png")),
new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-iiiii-active.png"))
};
this.error_image = new NSImage (NSBundle.MainBundle.ResourcePath +
"/Pixmaps/process-syncing-error.png");
this.error_image_active = new NSImage (NSBundle.MainBundle.ResourcePath +
"/Pixmaps/process-syncing-error-active.png");
this.error_image = new NSImage (
Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error.png"));
this.error_image_active = new NSImage (
Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error.png"));
}
}

View file

@ -29,18 +29,15 @@ namespace SparkleShare {
public static string LocalPluginsPath = new string [] {
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "sparkleshare", "plugins" }.Combine ();
public string Name {
get {
return GetValue ("info", "name");
}
}
public string Description {
get {
return GetValue ("info", "description");
}
}
public string Name { get { return GetValue ("info", "name"); } }
public string Description { get { return GetValue ("info", "description"); } }
public string Backend { get { return GetValue ("info", "backend"); } }
public string Fingerprint { get { return GetValue ("info", "fingerprint"); } }
public string AnnouncementsUrl { get { return GetValue ("info", "announcements_url"); } }
public string Address { get { return GetValue ("address", "value"); } }
public string AddressExample { get { return GetValue ("address", "example"); } }
public string Path { get { return GetValue ("path", "value"); } }
public string PathExample { get { return GetValue ("path", "example"); } }
public string ImagePath {
get {
@ -53,48 +50,6 @@ namespace SparkleShare {
return IO.Path.Combine (PluginsPath, image_file_name);
}
}
public string Backend {
get {
return GetValue ("info", "backend");
}
}
public string Fingerprint {
get {
return GetValue ("info", "fingerprint");
}
}
public string Address {
get {
return GetValue ("address", "value");
}
}
public string AddressExample {
get {
return GetValue ("address", "example");
}
}
public string Path {
get {
return GetValue ("path", "value");
}
}
public string PathExample {
get {
return GetValue ("path", "example");
}
}
public string AnnouncementsUrl {
get {
return GetValue ("info", "announcements_url");
}
}
public bool PathUsesLowerCase {
get {