[Banshee-List] Dap support in trunk
- From: "Alan McGovern" <alan mcgovern gmail com>
- To: banshee-list gnome org
- Subject: [Banshee-List] Dap support in trunk
- Date: Sun, 10 Feb 2008 22:04:02 +0000
I just want to push this into the mailing list to get feedback before work progresses too far on this. The other day on #banshee, rubenv was saying that he was going to port the Dap code from old banshee to new banshee. His aim was to implement it as an extension. I jumped in at this stage and said to him that if he's rewriting it to be an extension, it might be worth rewriting the Dap plugins at the same time, to simplify them and make them more consistant with each other.
Currently there is little to no code sharing between Dap implementations. Every device replicates some chunks of code. Every device has potentially buggy implementations of those chunks. My suggestion was to pull all those chunks into a separate class and make a Dap object much simpler. As a preliminary idea, this is what i have:
Each Dap implementation (IPod, MTP, MassStorage) will inherit a base class something like the one in DapInterface.cs (attached). This would result in a much simpler implementation of each dap device. The only logic contained in the Dap implementation would be the logic necessary to push data to and from the device. Existing logic like importing logic, synchronizing logic and updating the GUI with progress reports could all be removed. That logic will all be handled inside another class, which i'll refer to as the 'DapManager' class.
When a Dap is instantiated, it will be placed inside a DapManager. The DapManager is what banshee will communicate with. This class would deal with tasks which are common to all dap implemenatations such as providing feedback to the UI and maintaining the list of tracks which need to be modified. For example, i drag n drop 100 tracks from banshee to my mp3 player and immediately i drag and drop 50 tracks from the mp3 player to banshee. The DapManager will receive these requests, store the tasks in a queue, and complete them one by one.
My outline of the class is currently along these lines:
* Importing Tracks
- it will figure out the correct place to store the track on the filesystem
- it will check to see which tracks already exist before importing them from the device
* Uploading Tracks
- it will skip a track if the device already contains the track.
- it will ensure the track exists before telling the device to upload it (where feasable)
* Playlists
- When a new playlist is to be added, it will pass the playlist name and a list of tracks which should be in the playlist
- When an existing playlist is modified, it will pass a list of tracks to be removed and a list of tracks to be added along with the playlist name
- When a playlist is to be renamed, it will pass the old playlist name and the new name
- If a playlist is renamed and modified at the same time, two separate calls will be made into the device. One to rename, one to modify.
* Album Art
- The correct image will be generated based on stats reported by the device, this image will then be passed into the device to be uploaded
* Video?
- Should video syncing ever be required, it can be added easily enough.
* It will ensure an accurate view of the FreeSpace will displayed at all times. If a user queues 100 tracks to be transferred onto the device, the space used by these tracks will be reflected immediately. If 100 tracks are queued to be removed, the free space should show up immediately.
Any advice, feedback or psuedo code on the class/interfaces required for the above would be pretty sweet.
Alan.
public abstract class AbstractDevice : IDevice
{
private string name = "DAP";
private string owner = "Owner";
public virtual bool CanSetName {
get { return false; }
}
public virtual bool CanSetOwner {
get { return false; }
}
public virtual string Name {
get { return name; }
set {
if (!CanSetName)
throw new InvalidOperationException ();
name = value;
}
}
public virtual string Owner {
get { return owner; }
set {
if (!CanSetOwner)
throw new InvalidOperationException ();
}
}
public virtual ulong Capacity {
get { return 0; }
}
public virtual ulong FreeSpace {
get { return 0; }
}
public virtual bool IsReadOnly {
get { return false; }
}
public virtual bool IsPlaybackSupported {
get { return false; }
}
public virtual void Dispose ()
{
}
// Copies the specified track from the device to the filepath
public abstract void DownloadTrack (TrackInfo track, string destination);
// Disconnects the device and cleans up any resources
public abstract void Eject();
// Initializes the device like banshee currently does
public abstract bool Initialize (Hal.Device device);
// Returns all tracks on the device so that banshee can display them
public abstract List<TrackInfo> LoadTracks ();
// Removes the speciifed track from the device
public abstract void RemoveTrack (TrackInfo track);
// Pushes the metadata in the track to the device
public abstract void UpdateMetadata (TrackInfo track);
// Uploads the specified track to the device
public abstract void UploadTrack (TrackInfo track);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]