Skip to content

Implementing a backend

hbons edited this page Feb 9, 2012 · 32 revisions

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.

Overview

There are two abstract classes that need implementing 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.

Here's an overview of all the members that need an implementation:

SparkleRepoBase

// 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; }

SparkleFetcherBase

// 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; }

Getting started

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 for compilation.

Notes

All implemented members need to be blocking/synchronous.

Testing