-
-
Notifications
You must be signed in to change notification settings - Fork 576
Implementing a backend
By default, SparkleShare uses Git to store and sync files. However, you can implement a custom backend to suit your needs with relative ease. It's possible to use an other version control system or some other custom protocol. This page tries to explain how to go about this.
There are two abstract classes that need extending to get a working backend:
- SparkleFetcherBase takes care of the initial fetching and of a remote repository,
- SparkleRepoBase implements the syncing algorithm to keep up to date with the remote repository and handles notifications to/from other clients.
Here's an overview of all the members that need an implementation:
// Constructors
public SparkleRepoGit (string path);
// Methods
public abstract bool SyncUp ();
public abstract bool SyncDown ();
public abstract List<SparkleChangeSet> GetChangeSets (int count);
protected void OnProgressChanged (double progress_percentage, string progress_speed);
// Properties
public abstract string Identifier { get; }
public abstract string CurrentRevision { get; }
public abstract bool HasRemoteChanges { get; }
public abstract bool HasLocalChanges { get; }
public abstract double Size { get; }
public abstract double HistorySize { get; }
// Constructors
public SparkleFetcherBase (string server, string remote_folder, string target_folder);
// Methods
public abstract bool Fetch ();
public abstract void Stop ();
protected void OnProgressChanged (double percentage);
// Properties
public abstract string [] Warnings { get; }
Put your files in SparkleLib/. You can create a subdirectory for your backend if you want like the default backend Git/. Just make sure the files are added to the Makefile.am file for compilation.
It's important that your files and classes are named properly. For example: if your backend is called hg, then name your extended classes SparkleRepoHg and SparkleFetcherHg.
All implemented members need to be blocking/synchronous.
You can specify a backend type to use by appending it's name to the Remote Path value in the Add Hosted Project dialog. For example:
- /home/project.git uses the classes SparkleRepoGit, SparkleFetcherGit as its backend
- /home/project.hg uses the classes SparkleRepoHg, SparkleFetcherHg as its backend