Re: [Banshee-List] Updated MTP DAP patch available...



Howdy,

Attached is a diff with all my MTP work. Should just be a drop in place patch -p1 < mtp.diff. Also takes care of recent issues with CVS and the OnTrackAdded function changing (I totally missed this in the ChangeLog and wondered why folks couldn't compile it).

Please audit my autotools foo, I think it's right, but I'm not 100% sure. It works for me as far as I can tell to make it so --enable-mtp is explicitly required, regardless of whether libgphoto2-sharp is found. I've also attached a libgphoto2-sharp.pc file for your testing needs if you don't want to bother with grabbing libgphoto2 from svn. They just released 2.2.0 over there, but it still doesn't include the bindings yet. But it will soon, or so I hope :)

Also - I wasn't sure exactly how to license this...I assume since it's going into the Banshee codebase that it has to follow the MIT license, right? Also, is it copyright Novell and me, or just me? I'm just following suit as to Gabriel's mass storage and it's headers...

LMK if you need anything else! Also if this patch goes in good and you commit to CVS, do create the bugzilla component as to help keep track of this, because I'm sure lots of people will find lots of bugs (I can already name quite a few)

Cheers,

Patrick

--
Patrick "Trick" van Staveren
Western Michigan University
Cell: 269.267.6008
http://trick.vanstaveren.us


----- Message from abockover novell com ---------
    Date: Thu, 15 Jun 2006 15:01:02 -0400
    From: Aaron Bockover <abockover novell com>
Reply-To: banshee-list gnome org
 Subject: Re: [Banshee-List] Updated MTP DAP patch available...
      To: banshee-list gnome org


On Thu, 2006-06-15 at 13:05 -0400, Patrick van Staveren wrote:
I'd totally be game for that if we set it to automatically disable
unless --enable-mtp is specified...right now it requires libgphoto2
from their SVN HEAD, so it's not really "release ready" but it's
definitely ready for testing :)

If you fix configure to require --enable-mtp, I'd like to see MTP go
into HEAD.

And if abock would be OK with giving me CVS commit access...

You'll need to follow the standard GNOME accounts/cvs procedures for
getting commit access as accounts are global to GNOME and not given on a
per-project/module basis.

http://developer.gnome.org/doc/policies/accounts/requesting.html

For now, until you're ready to deem it more stable, I'll rather blindly
commit your patches to Banshee.Dap/Mtp (will strictly review patches
outside of this however). I can create an MTP component in bugzilla as
well.

Let me know what needs to go in right now.

--Aaron


Patrick

--
Patrick "Trick" van Staveren
Western Michigan University
Cell: 269.267.6008
http://trick.vanstaveren.us


----- Message from jstembridge gmail com ---------
     Date: Thu, 15 Jun 2006 12:38:38 +0100
     From: James Stembridge <jstembridge gmail com>
Reply-To: banshee-list gnome org
  Subject: Re: [Banshee-List] Updated MTP DAP patch available...
       To: banshee-list gnome org


> Hi Patrick,
>
> On 6/15/06, Patrick van Staveren <trick vanstaveren us> wrote:
>> If you have a MTP DAP, test this patch out...it's time for testing
>> because I'm tired of sitting on this code when I think it belongs in
>> the CVS tree once it's been tested more :)
>
> Why not get this in CVS anyway? If you're worried about stability you
> can always have it disabled by default.
>
> Cheers,
> James.
> _______________________________________________
> Banshee-list mailing list
> Banshee-list gnome org
> http://mail.gnome.org/mailman/listinfo/banshee-list
>


----- End message from jstembridge gmail com -----



_______________________________________________
Banshee-list mailing list
Banshee-list gnome org
http://mail.gnome.org/mailman/listinfo/banshee-list

_______________________________________________
Banshee-list mailing list
Banshee-list gnome org
http://mail.gnome.org/mailman/listinfo/banshee-list



----- End message from abockover novell com -----


diff -Nru -Nru banshee/configure.ac banshee.mtp/configure.ac
--- banshee/configure.ac	2006-06-05 13:18:23.000000000 -0400
+++ banshee.mtp/configure.ac	2006-06-20 01:14:28.000000000 -0400
@@ -35,6 +35,9 @@
 AC_ARG_ENABLE(njb, AC_HELP_STRING([--enable-njb], [Enable NJB DAP support]), , enable_njb="yes")
 enable_njbsharp="${enable_njb}"
 
+AC_ARG_ENABLE(mtp, AC_HELP_STRING([--enable-mtp], [Enable MTP DAP support]), , enable_mtp="no")
+enable_mtp_dap="${enable_mtp}"
+
 AC_ARG_ENABLE(docs, AC_HELP_STRING([--disable-docs], [Do not build documentation]), with_docs=no, with_docs=yes)
 
 AC_ARG_ENABLE(dev-tests, AC_HELP_STRING([--enable-dev-tests], [Whether or not to build various test programs for components in libbanshee and mediaengines]), , enable_dev_tests="no")
@@ -163,6 +166,21 @@
 fi
 AM_CONDITIONAL(ENABLE_NJB, test "x$enable_njbsharp" = "xyes")
 
+LIBGPHOTO2SHARP_REQUIRED=0.0.1
+PKG_CHECK_MODULES(LIBGPHOTO2SHARP,
+	libgphoto2-sharp >= $LIBGPHOTO2SHARP_REQUIRED,
+	enable_mtp_dap="$enable_mtp_dap", enable_mtp_dap=no)
+if test "x$enable_mtp" != "xno" -a "x$enable_mtp_dap" = "xno"; then
+    AC_WARN(libgphoto2-sharp package not found or not up to date.  Please install libgphoto2 from their subversion, or disable MTP support by not passing --enable-mtp.)
+    exit 1
+fi
+if test "x$enable_mtp_dap" = "xyes"; then
+	LIBGPHOTO2SHARP_ASSEMBLIES="`$PKG_CONFIG --variable=Libraries libgphoto2-sharp`"
+	AC_SUBST(LIBGPHOTO2SHARP_ASSEMBLIES)
+	AC_SUBST(LIBGPHOTO2SHARP_LIBS)
+fi
+AM_CONDITIONAL(ENABLE_MTP, test "x$enable_mtp_dap" = "xyes")
+
 dnl dbus
 PKG_CHECK_MODULES(DBUSSHARP, dbus-sharp)
 AC_SUBST(DBUSSHARP)
@@ -360,6 +378,7 @@
 src/Banshee.Dap/Ipod/Makefile
 src/Banshee.Dap/Ipod/ipod-sharp.dll.config
 src/Banshee.Dap/MassStorage/Makefile
+src/Banshee.Dap/Mtp/Makefile
 src/Banshee.Dap/Njb/Makefile
 src/Banshee.Dap/Njb/njb-sharp.dll.config
 src/Banshee.Plugins/Makefile
@@ -402,6 +421,7 @@
     Digital Audio Players (DAP):
       iPod:            ${enable_ipodsharp}
       NJB:             ${enable_njbsharp}
+      MTP:             ${enable_mtp_dap}
 
     DAAP Support:      ${enable_daap}${zeroconf_lib}
 "
diff -Nru -Nru banshee/src/Banshee.Dap/Makefile.am banshee.mtp/src/Banshee.Dap/Makefile.am
--- banshee/src/Banshee.Dap/Makefile.am	2006-03-15 12:43:38.000000000 -0500
+++ banshee.mtp/src/Banshee.Dap/Makefile.am	2006-06-20 01:14:43.000000000 -0400
@@ -1,4 +1,4 @@
-SUBDIRS = Ipod MassStorage Njb
+SUBDIRS = Ipod MassStorage Mtp Njb
 
 
 MAINTAINERCLEANFILES = Makefile.in
diff -Nru -Nru banshee/src/Banshee.Dap/Mtp/.cvsignore banshee.mtp/src/Banshee.Dap/Mtp/.cvsignore
--- banshee/src/Banshee.Dap/Mtp/.cvsignore	1969-12-31 19:00:00.000000000 -0500
+++ banshee.mtp/src/Banshee.Dap/Mtp/.cvsignore	2006-06-20 01:16:11.000000000 -0400
@@ -0,0 +1,7 @@
+Makefile
+Makefile.in
+*.exe
+*.dll
+*.config
+*.mdb
+
diff -Nru -Nru banshee/src/Banshee.Dap/Mtp/GPhotoDevice.cs banshee.mtp/src/Banshee.Dap/Mtp/GPhotoDevice.cs
--- banshee/src/Banshee.Dap/Mtp/GPhotoDevice.cs	1969-12-31 19:00:00.000000000 -0500
+++ banshee.mtp/src/Banshee.Dap/Mtp/GPhotoDevice.cs	2006-06-20 01:34:59.000000000 -0400
@@ -0,0 +1,295 @@
+/***************************************************************************
+ *  GPhotoDevice.cs
+ *
+ *  Copyright (C) 2006 Novell and Patrick van Staveren
+ *  Written by Patrick van Staveren (trick vanstaveren us)
+ ****************************************************************************/
+
+/*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),  
+ *  to deal in the Software without restriction, including without limitation  
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,  
+ *  and/or sell copies of the Software, and to permit persons to whom the  
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in 
+ *  all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Text;
+using LibGPhoto2;
+
+namespace Banshee.Dap.Mtp{
+
+public class GPhotoDevice
+{
+    private Context context;
+    private Camera camera;
+    private CameraFilesystem fs;
+    private CameraList camera_list;
+    private PortInfoList port_info_list;
+    private CameraAbilitiesList abilities_list;
+
+    private ArrayList files;
+    public string Store;
+    
+    public GPhotoDevice()
+    {
+        context = new Context();
+
+        port_info_list = new PortInfoList ();
+        port_info_list.Load ();
+            
+        abilities_list = new CameraAbilitiesList ();
+        abilities_list.Load (context);
+        
+        camera_list = new CameraList();
+    }
+        
+    public int Detect ()
+    {
+        abilities_list.Detect (port_info_list, camera_list, context);
+        return CameraCount;
+    }
+    
+    public int CameraCount {
+        get {
+            return camera_list.Count();
+        }
+    }
+    
+    public CameraList CameraList {
+        get {
+            return camera_list;
+        }
+    }
+    
+    public CameraAbilitiesList AbilitiesList {
+       get {
+           return abilities_list;
+       }
+    }
+        
+    public void SelectCamera (int index)
+    {
+        camera = new Camera ();
+
+        camera.SetAbilities(abilities_list.GetAbilities(
+            abilities_list.LookupModel(camera_list.GetName (index))
+        ));
+
+        camera.SetPortInfo(port_info_list.GetInfo(
+            port_info_list.LookupPath(camera_list.GetValue(index)))
+        );
+
+        Store = "/store_00010001/"; //FIXME: autodetect this
+    }
+    
+    public void InitializeCamera ()
+    {
+        if (camera == null) 
+            throw new InvalidOperationException();
+
+        try{
+            camera.Init (context);
+        } catch(LibGPhoto2.GPhotoException e){
+            Console.WriteLine("Init() Exception: {0}", e.ToString());
+        }
+        fs = camera.GetFS ();
+        
+        files = new ArrayList ();
+        GetFileList ();
+        Console.WriteLine("initialized");
+    }
+
+/*  public short UsbVendorID {
+        get {
+            Console.WriteLine("USB Vendor: {0}", camera.GetAbilities.usb_vendor);
+            return (short) camera.GetAbilities.usb_vendor;
+        }
+    }
+    
+    public int UsbProductID {
+        get {
+            Console.WriteLine("USB ProdID: {0}", camera.GetAbilities.usb_product);
+            return (short) camera.GetAbilities.usb_product;
+        }
+    }*/
+    
+    public int DiskFree {
+        get {
+            //FIXME: find DiskFree
+            return 1;
+        }
+    }
+    
+    public int DiskTotal {
+        get {
+            //FIXME: find DiskTotal
+            return 1;
+        }
+    }
+    
+    public string About {
+        get {
+            return camera.GetAbout(context).Text;
+        }
+    }
+    
+    private void GetFileList ()
+    {
+        GetFileList (Store);
+    }
+        
+    private void GetFileList (string dir)
+    {
+        if (fs == null) 
+            throw new InvalidOperationException ();
+        
+        //files
+        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
+        CameraList filelist = fs.ListFiles(dir, context);
+        Console.Write("Reading metadata for " + dir + "...");
+        for (int i = 0; i < filelist.Count(); i++) {
+            Console.Write("{0}.", i);
+            string metadata;
+            
+            try{
+                CameraFile meta = fs.GetFile(dir, filelist.GetName(i), CameraFileType.MetaData, context);
+                metadata = encoding.GetString(meta.GetDataAndSize());
+            }catch{
+                metadata = "<Name>No Metadata Available</Name>";
+            }
+            //      fs.GetFile(dir, filelist.GetName(i), CameraFileType.Normal, context),
+            if(filelist.GetName(i).IndexOf(".mp3") > 0){
+                files.Add(
+                    new GPhotoDeviceFile(
+                        dir, filelist.GetName(i), metadata, this
+                    )
+                );
+            }
+        }
+        Console.Write("\n");
+    
+        //subdirectories
+        CameraList folderlist = fs.ListFolders(dir, context);
+        for (int i = 0; i < folderlist.Count(); i++) {
+            GetFileList(dir + folderlist.GetName(i) + "/");
+        }
+    }
+    
+    public ArrayList FileList
+    {
+        get {
+            return files;
+        }
+    }
+    
+    public void PutFile (GPhotoDeviceFile file)
+    {
+        if (fs == null || file == null)
+            return;
+
+        /*  FIXME: handle store_x locally
+            save it as a class variable as it could be different per camera
+            detect on Initialize()
+        */
+        
+        file.GenerateProperPath();
+
+        // FIXME: don't assume path separator is "/" - use Path.getseparator or whatev
+        string[] path_split = file.Directory.Split('/'); // split up the path
+        string path_base = Store.Remove(Store.Length - 1, 1); // take store, minus the trailing slash
+        string path_build = path_base; // the path_build variable is basically the "working directory" (aka cwd) here as we search for and if necessary create directories.
+
+        for(int i = 2; i < path_split.GetLength(0); i++) {
+            if (path_split[i].Trim() == "") { // if it's blank for some reason (like an extra slash or something)
+                Console.WriteLine("Blank parameter found at {0}, skipping...", i);
+                continue;
+            }
+            
+            Console.Write("Checking for {0} in {1}...", path_split[i], path_build);
+            
+            // enumerate a list of folders in the current working directory (aka path_build)
+            CameraList folders = fs.ListFolders(path_build, context);
+            
+            bool found = false;
+            for(int j = 0; j < folders.Count(); j++) // loop thru folders that exist in path_build (aka cwd)
+                if(folders.GetName(j) == path_split[i]) // check to see if the folder at current index j is what we need
+                    found = true; // if so, set found to true 
+            
+            if(!found) { // then the directory was not found.  create it!
+                Console.WriteLine("not found; creating {0} in {1}...", path_split[i], path_build);
+                fs.MakeDirectory(path_build, path_split[i], context);
+            } else {
+                Console.WriteLine("OK");
+            }
+            
+            //Console.Write("Path element: {0}...", path_split[i]);
+            //Console.WriteLine("Path: {0}", path_build);
+            path_build += "/" + path_split[i]; // tack on the directory to the path_build string so next iteration we'll be looking in it
+        }
+
+        // drops the file in the directory
+        fs.PutFile(file.Directory, file.CameraFile, context);
+
+        // drops the metadata in place
+        PutMetadata(file);
+
+        // adds the file to the local array of files.  should this array be depreciated?
+        files.Add(file);
+    }
+    
+    public void PutMetadata (GPhotoDeviceFile file)
+    {
+        try {
+            CameraFile meta = new CameraFile();
+            meta.SetName(file.Filename);
+            UTF8Encoding encoding = new UTF8Encoding();
+            meta.SetDataAndSize(encoding.GetBytes(file.Metadata));
+            
+            meta.SetFileType(CameraFileType.MetaData);
+            fs.PutFile(file.Directory, meta, context);
+        } catch(Exception e){
+            Console.WriteLine("Failed send track metadata.  Are you using the right version of the C# bindings and libgphoto2?  Exception: {0}", e.ToString());
+        }
+    }
+
+    public void DeleteFile (GPhotoDeviceFile file)
+    {
+        files.Remove(file);
+        fs.DeleteFile(file.Directory, file.Filename, context);
+        file = null;
+    }
+    
+    ~GPhotoDevice() {
+        Dispose();
+    }
+
+    public void Dispose() {
+        foreach(GPhotoDeviceFile file in files)
+            file.Dispose();
+        files = null;
+
+        if (fs != null) 
+            fs.Dispose ();
+        if (camera != null)
+            camera.Dispose ();
+        context.Dispose ();
+    }
+}
+
+}
diff -Nru -Nru banshee/src/Banshee.Dap/Mtp/GPhotoDeviceFile.cs banshee.mtp/src/Banshee.Dap/Mtp/GPhotoDeviceFile.cs
--- banshee/src/Banshee.Dap/Mtp/GPhotoDeviceFile.cs	1969-12-31 19:00:00.000000000 -0500
+++ banshee.mtp/src/Banshee.Dap/Mtp/GPhotoDeviceFile.cs	2006-06-20 01:34:57.000000000 -0400
@@ -0,0 +1,189 @@
+/***************************************************************************
+ *  GPhotoDeviceFile.cs
+ *
+ *  Copyright (C) 2006 Novell and Patrick van Staveren
+ *  Written by Patrick van Staveren (trick vanstaveren us)
+ ****************************************************************************/
+
+/*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),  
+ *  to deal in the Software without restriction, including without limitation  
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,  
+ *  and/or sell copies of the Software, and to permit persons to whom the  
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in 
+ *  all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Text;
+using LibGPhoto2;
+using Banshee.Base;
+
+namespace Banshee.Dap.Mtp{
+
+public class GPhotoDeviceFile
+{
+    public GPhotoDevice Dev;
+    
+    public CameraFile CameraFile;
+    private string directory;
+    private string filename;
+    
+    private string extension;
+    
+    public string Artist;
+    public double Duration;
+    public uint Track;
+    public string Genre;
+    public int Year;
+    public string AlbumName;
+    public string Name;
+    public uint UseCount;
+    
+    /* new constructor for adding tracks in Synchronize()
+    / allows for full internal checking for bad characters, and a self constructed path*/
+    public GPhotoDeviceFile (SafeUri uri, GPhotoDevice device)
+    {
+        Dev = device;
+        CameraFile = new CameraFile();
+        CameraFile.Open(uri.LocalPath);
+        extension = Path.GetExtension(uri.LocalPath);
+        filename = null;
+        directory = null;
+    }
+
+    public GPhotoDeviceFile (string dir, string file, string meta, GPhotoDevice device)
+    {
+        Dev = device;
+        directory = dir;
+        filename = file;
+        CameraFile = null;
+        Metadata = meta;
+    }
+
+    // old constructor for sending tracks from Sync
+/*  public GPhotoDeviceFile (string dir, string file, SafeUri uri, GPhotoDevice device) 
+    {
+        // FIXME: could this be where we're crashing with cvs?
+        Dev = device;
+        directory = dir;
+        filename = file;
+        CameraFile = new CameraFile();
+        CameraFile.Open(uri.LocalPath);
+        CameraFile.SetName(Filename);
+    }*/
+
+    public void GenerateProperPath() {
+        directory = Dev.Store + "Music/" + GetValidName(Artist) + "/" + GetValidName(AlbumName);
+        filename = GetValidName(String.Format("{0}. {1}{2}", Track, Name, extension));
+        CameraFile.SetName(filename);
+        Console.WriteLine("proper path: dir={0} file={1}", directory, filename);
+    }        
+
+    private string GetValidName(string input) {
+        string output = "";
+
+        for(int i = 0; i < input.Length; i++) {
+            if(input[i] == '/' || input[i] == '\\' || input[i] == ':' || input[i] == '?') {
+                output = output + '_';
+            } else {
+                if(output == "")
+                    output = input[i].ToString().ToUpper();
+                else
+                    output = output + input[i];
+            }
+        }
+        return output;
+    }
+
+    public string Filename {
+        get {
+            return filename;
+        }
+        set {
+            filename = value;
+        }
+    }
+
+    public string Directory {
+        get {
+            return directory;
+        }
+        set {
+            directory = value;
+        }
+    }
+
+    private string LookupMetaValue(string meta, string tag, bool isNumeric)
+    {
+        int loc_start = meta.IndexOf("<" + tag + ">");
+        int loc_end   = meta.IndexOf("</" + tag + ">");
+        if(loc_start <= 0 || loc_end <= 0){
+            if(isNumeric)
+                return "0000";
+            return "";
+        }
+        int start = loc_start + 1 + tag.Length + 1;
+        string metaValue = meta.Substring(start, loc_end - start);
+        if(metaValue == "(null)" && isNumeric)
+            metaValue = "0000";
+        return(metaValue);
+    }
+
+    public string Metadata {
+        get {
+            return(String.Format("<Duration>{0}</Duration>\n", Duration) +
+                String.Format("<Artist>{0}</Artist>\n", (Artist == "" || Artist == null) ? "Unknown" : Artist) + 
+                String.Format("<AlbumName>{0}</AlbumName>\n", (AlbumName == null)   ? "" : AlbumName) +
+                String.Format("<Name>{0}</Name>\n", (Name == "" || Name == null)     ? "Unknown" : Name) + 
+                String.Format("<Track>{0}</Track>\n", Track) + 
+                String.Format("<Genre>{0}</Genre>\n", Genre) + 
+                String.Format("<UseCount>{0}</UseCount>\n", UseCount) + 
+                String.Format("<OriginalReleaseDate>{0:0000}0101T0000.0</OriginalReleaseDate>", Year) +
+                String.Format("<ObjectFileName>{0}</ObjectFileName>", Filename)
+            );
+        }
+        set {
+            Artist = LookupMetaValue(value, "Artist", false);
+            Duration = double.Parse(LookupMetaValue(value, "Duration", true));
+            Track = uint.Parse(LookupMetaValue(value, "Track", true));
+            Genre = LookupMetaValue(value, "Genre", false);
+            Year = int.Parse(LookupMetaValue(value, "OriginalReleaseDate", true).Substring(0, 4));
+            AlbumName = LookupMetaValue(value, "AlbumName", false);
+            Name = LookupMetaValue(value, "Name", false);
+            UseCount = uint.Parse(LookupMetaValue(value, "UseCount", true));
+        }
+    }
+
+    public void SaveMetadata()
+    {
+        Dev.PutMetadata(this);
+    }
+
+    ~GPhotoDeviceFile () {
+        Dispose();
+    }
+    
+    public void Dispose () {
+        if (CameraFile != null) 
+            CameraFile.Dispose ();
+
+        Dev = null;
+    }
+}
+
+}
diff -Nru -Nru banshee/src/Banshee.Dap/Mtp/Makefile.am banshee.mtp/src/Banshee.Dap/Mtp/Makefile.am
--- banshee/src/Banshee.Dap/Mtp/Makefile.am	1969-12-31 19:00:00.000000000 -0500
+++ banshee.mtp/src/Banshee.Dap/Mtp/Makefile.am	2006-06-20 01:14:56.000000000 -0400
@@ -0,0 +1,41 @@
+MCS_FLAGS = -debug
+ASSEMBLY_NAME = Banshee.Dap.Mtp
+ASSEMBLY = $(ASSEMBLY_NAME).dll
+EXTRA_DIST = $(ASSEMBLY_SOURCES)
+
+CLEANFILES = $(ASSEMBLY) *.dll *.exe *.mdb
+DISTCLEANFILES = *.mdb
+MAINTAINERCLEANFILES = Makefile.in 
+
+ASSEMBLY_SOURCES = \
+	$(srcdir)/MtpDap.cs \
+	$(srcdir)/MtpDapTrackInfo.cs \
+	$(srcdir)/MtpDeviceId.cs \
+	$(srcdir)/GPhotoDevice.cs \
+	$(srcdir)/GPhotoDeviceFile.cs
+
+if ENABLE_MTP
+bansheedapdir = $(pkglibdir)/Banshee.Dap
+bansheedap_SCRIPTS = $(ASSEMBLY) $(ASSEMBLY).mdb
+endif
+
+$(ASSEMBLY): $(ASSEMBLY_SOURCES)
+	$(MCS) $(MCS_FLAGS) -target:library -out:$@ -r:$(top_builddir)/src/Banshee.Base/Banshee.Base.dll \
+	-r:$(top_builddir)/src/Banshee.Widgets/Banshee.Widgets.dll -r:$(top_builddir)/hal-sharp/hal-sharp.dll \
+	-r:Mono.Posix $(GTKSHARP_LIBS) $(LIBGPHOTO2SHARP_LIBS) $(ASSEMBLY_SOURCES)
+
+install-data-hook:
+	for cur in $(LIBGPHOTO2SHARP_ASSEMBLIES); do \
+		$(INSTALL) -m 0755 $$cur $(DESTDIR)$(bansheedapdir); \
+		$(INSTALL) -m 0755 $${cur}.mdb $(DESTDIR)$(bansheedapdir); \
+		$(INSTALL) -m 0755 $${cur}.config $(DESTDIR)$(bansheedapdir); \
+	done;
+
+uninstall-hook:
+	for cur in $(LIBGPHOTO2SHARP_ASSEMBLIES); do \
+		rm -f $(DESTDIR)$(bansheedapdir)/`basename $$cur`; \
+		rm -f $(DESTDIR)$(bansheedapdir)/`basename $${cur}.mdb`; \
+		rm -f $(DESTDIR)$(bansheedapdir)/`basename $${cur}.config`; \
+	done;
+	
+
diff -Nru -Nru banshee/src/Banshee.Dap/Mtp/MtpDap.cs banshee.mtp/src/Banshee.Dap/Mtp/MtpDap.cs
--- banshee/src/Banshee.Dap/Mtp/MtpDap.cs	1969-12-31 19:00:00.000000000 -0500
+++ banshee.mtp/src/Banshee.Dap/Mtp/MtpDap.cs	2006-06-20 01:34:53.000000000 -0400
@@ -0,0 +1,337 @@
+/***************************************************************************
+ *  MtpDap.cs
+ *
+ *  Copyright (C) 2006 Novell and Patrick van Staveren
+ *  Written by Patrick van Staveren (trick vanstaveren us)
+ ****************************************************************************/
+
+/*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),  
+ *  to deal in the Software without restriction, including without limitation  
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,  
+ *  and/or sell copies of the Software, and to permit persons to whom the  
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in 
+ *  all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Threading;
+using Hal;
+using LibGPhoto2;
+using Banshee.Dap;
+using Banshee.Base;
+using Banshee.Widgets;
+using Mono;
+using Mono.Unix;
+using Gtk;
+
+namespace Banshee.Dap.Mtp
+{
+    [DapProperties(DapType = DapType.NonGeneric)]
+    [SupportedCodec(CodecType.Mp3)]
+    [SupportedCodec(CodecType.Wma)]
+
+    public sealed class MtpDap : DapDevice
+    {
+        private static GPhotoDevice dev;
+        private DeviceId device_id;
+        private int sync_total;
+        private int sync_finished;
+        private Queue remove_queue = new Queue();
+        //private bool firstDatabaseLoad = true;
+        private ActiveUserEvent userEvent;
+        private int GPhotoDeviceID;
+        private Hal.Device hal_device;
+        
+        static MtpDap() {
+            Console.WriteLine("MtpDap made");
+        }
+
+        public override InitializeResult Initialize(Hal.Device halDevice)
+        {
+            Console.WriteLine("MtpDap: initialize...");
+            if(/*       !halDevice.PropertyExists("usb.bus_number") ||
+                    !halDevice.PropertyExists("usb.linux.device_number") ||*/
+                    !halDevice.PropertyExists("usb.vendor_id") ||
+                    !halDevice.PropertyExists("usb.product_id")) {
+                return InitializeResult.Invalid;
+            }
+
+            try {
+                dev = new GPhotoDevice ();
+                dev.Detect ();
+            } catch (Exception e) {
+                Console.WriteLine("Failed to run libgphoto2 DetectCameras.  Exception: {0}", e.ToString());
+                return InitializeResult.Invalid;
+            }
+
+            short hal_product_id = (short) halDevice.GetPropertyInt("usb.product_id");
+            short hal_vendor_id  = (short) halDevice.GetPropertyInt("usb.vendor_id");
+            
+            device_id = DeviceId.GetDeviceId(hal_vendor_id, hal_product_id);
+            Console.WriteLine("Device: vendor={0}, prod={1}", hal_vendor_id, hal_product_id);
+
+            if(device_id == null) {
+                Console.WriteLine("Device id is null.  This can mean one of two things:\n" + 
+                    "(1) Your device is not supported by this MTP driver.\n" +
+                    "(2) You improperly installed libgphoto2_port by enabling disk support, which conflicts with this driver.\n" +
+                    "Contact the MTP developers for help.");
+                return InitializeResult.Invalid;
+            }
+            
+            int found = 0;
+            GPhotoDeviceID = -1;
+            
+            for (int i = 0; i < dev.CameraList.Count(); i++) {
+                int abilities_index = dev.AbilitiesList.LookupModel(dev.CameraList.GetName(i));
+                CameraAbilities a = dev.AbilitiesList.GetAbilities(abilities_index);
+                if (a.usb_vendor != hal_vendor_id || a.usb_product != hal_product_id)
+                    return InitializeResult.Invalid;
+                found++;
+                GPhotoDeviceID = i;
+            }
+            
+            if(found > 1)
+                Console.WriteLine("Found more than one matching device.  File a bug!  Do you have more than one MTP DAP plugged in?                    Multiple MTP DAPs are not supported.");
+            
+            InstallProperty("Model", device_id.Name);
+            InstallProperty("Vendor", halDevice["usb.vendor"]);
+            //InstallProperty("Firmware Revision", "FIXME: implement");
+            //InstallProperty("Hardware Revision", "FIXME: implement");
+            InstallProperty("Serial Number", halDevice["usb.serial"]);
+            hal_device = halDevice;
+            ThreadAssist.Spawn(InitializeBackgroundThread);
+
+            CanCancelSave = false;
+            return InitializeResult.Valid;
+        }
+
+        public void InitializeBackgroundThread()
+        {
+            userEvent = new ActiveUserEvent("MTP Initialization");
+            userEvent.CanCancel = false;
+            userEvent.Header = Catalog.GetString(device_id.Name + ": Initializing");
+            userEvent.Message = Catalog.GetString("Reading library information");
+            try{
+                Console.WriteLine("libgphoto2/MTP: Selecting device {0}", GPhotoDeviceID);
+                dev.SelectCamera(GPhotoDeviceID);
+                dev.InitializeCamera();
+            } catch (Exception e){
+                Console.WriteLine("failed with exception: {0}", e);
+                userEvent.Dispose();
+                Dispose();
+            }
+
+            userEvent.Message = Catalog.GetString("Loading device");
+            base.Initialize(hal_device);
+            ReloadDatabase();
+
+            userEvent.Message = Catalog.GetString("Ready for use");;
+            userEvent.Header = Catalog.GetString(device_id.Name + ": Ready");
+            userEvent.Progress = 1;
+            GLib.Timeout.Add(3000, delegate {
+                userEvent.Dispose();
+                userEvent = null;
+                return false;
+            });
+        }
+
+        public override void Dispose()
+        {
+            Console.WriteLine("MTP: Dispose()");
+            dev.Dispose();
+            base.Dispose();
+        }
+
+        private void ReloadDatabase()
+        {
+            //if(firstDatabaseLoad){
+                //Console.WriteLine("ReloadDatabase...must be first time!");
+                //firstDatabaseLoad = false;
+                ClearTracks(false);
+                
+                foreach (GPhotoDeviceFile file in dev.FileList)
+                {
+                    MtpDapTrackInfo track = new MtpDapTrackInfo(file);
+                    AddTrack(track);
+                }
+            //}else{
+                //Console.WriteLine("ReloadDatabase called again...doing nothing");
+            //}
+        }
+
+        protected override void OnTrackRemoved(TrackInfo track)
+        {
+            if (IsReadOnly || !(track is MtpDapTrackInfo))
+                return;
+
+            Console.WriteLine("mtp: will remove {0}", track.Title);
+            remove_queue.Enqueue(track);
+        }
+
+        public override void AddTrack (TrackInfo track)
+        {
+            if (track is MtpDapTrackInfo || !TrackExistsInList(track, Tracks)) {
+                tracks.Add (track);
+                OnTrackAdded (track);
+            }
+        }
+
+        public override void Synchronize()
+        {
+        try {
+            Console.WriteLine("Made it to Mtp.Synchronize()");
+            int remove_total = remove_queue.Count;
+            
+            while(remove_queue.Count > 0) {
+                Console.WriteLine("Removing...queue count at {0}", remove_queue.Count);
+                MtpDapTrackInfo track = remove_queue.Dequeue() as MtpDapTrackInfo;
+                UpdateSaveProgress(Catalog.GetString("Synchronizing Device"), Catalog.GetString(String.Format("Removing: {0} - {1}", track.Artist, track.Title)),
+                    (double)(remove_total - remove_queue.Count) / (double)remove_total);
+                dev.DeleteFile(track.DeviceFile);
+            }
+            
+            sync_finished = 0;
+            sync_total = 0;
+
+            foreach(TrackInfo track in Tracks) {
+                if(track is MtpDapTrackInfo) {
+                    continue;
+                }
+                
+                sync_total++;
+            }
+            
+            
+            
+            foreach(TrackInfo track in Tracks) {
+                if(track == null ||  track is MtpDapTrackInfo || track.Uri == null) {
+                    continue;
+                }
+                
+                FileInfo file;
+                
+                try {
+                    file = new FileInfo(track.Uri.LocalPath);
+                    if(!file.Exists) {
+                        continue;
+                    }
+                } catch {
+                    continue;
+                }
+                
+                try {
+                    UpdateSaveProgress(Catalog.GetString("Synchronizing Device"),
+                        Catalog.GetString(String.Format("Adding: {0} - {1}", track.Artist, track.Title)),
+                        (double) sync_finished / (double) sync_total);
+                    Console.WriteLine("MtpDap: about to add file...");
+
+                    /*  this appears to be the most logical path for my Zen Micro
+                        LMK if your device traditionally uses something different and it'll be changed :)
+                    */
+                    
+                    /*  FIXME: MtpDap shouldn't be aware of the store_x prefix.
+                        per gphoto devels, it may be removed in the future
+                        MtpDap never needs to know about it.
+                    */
+                    
+                    GPhotoDeviceFile newfile = new GPhotoDeviceFile(track.Uri, dev);
+                    
+                    newfile.Duration = track.Duration.TotalMilliseconds;
+                    newfile.Artist = track.Artist;
+                    newfile.AlbumName = track.Album;
+                    newfile.Name = track.Title;
+                    newfile.Track = track.TrackNumber;
+                    newfile.Genre = track.Genre;
+                    newfile.UseCount = track.PlayCount;
+                    newfile.Year = track.Year;
+
+                    dev.PutFile(newfile);
+
+                    Console.WriteLine("MtpDap: file add finished.");
+
+                    sync_finished++;
+                } catch (Exception e){
+                    Console.WriteLine("Could not sync song: Exception: {0}", e.ToString());   
+                }
+            }
+            
+        } catch(Exception e) {
+            Console.WriteLine(e);
+        } finally {
+            FinishSave();
+            ReloadDatabase();
+        }   
+        }
+
+        public override Gdk.Pixbuf GetIcon(int size)
+        {
+            string prefix = "multimedia-player-";
+            string id = "dell-pocket-dj";
+            Gdk.Pixbuf icon = IconThemeUtils.LoadIcon(prefix + id, size);
+            return icon == null? base.GetIcon(size) : icon;
+        }
+
+        public override string Name {
+            get {
+                return device_id.DisplayName;
+            }
+        }
+
+        public override void SetOwner (string owner) {
+            //FIXME: SetOwner not implemented in libgphoto2-ptp
+            Console.WriteLine("fixme: SetOwner to {0}", owner);
+        }
+
+        public override string Owner {
+            get {
+                return "Unknown";  //FIXME: Owner not implemented in libgphoto2-ptp
+            }
+        }
+
+        public override string GenericName {
+            get {
+                return device_id.DisplayName;
+            }
+        }
+
+        public override ulong StorageCapacity {
+            get {
+                return (ulong) dev.DiskTotal;
+            }
+        }
+
+        public override ulong StorageUsed {
+            get {
+                return (ulong) dev.DiskTotal - (ulong) dev.DiskFree;
+            }
+        }
+
+        public override bool IsReadOnly {
+            get {
+                return false;
+            }
+        }
+
+        public override bool IsPlaybackSupported {
+            get {
+                return false;
+            }
+        }
+    }
+}
diff -Nru -Nru banshee/src/Banshee.Dap/Mtp/MtpDapTrackInfo.cs banshee.mtp/src/Banshee.Dap/Mtp/MtpDapTrackInfo.cs
--- banshee/src/Banshee.Dap/Mtp/MtpDapTrackInfo.cs	1969-12-31 19:00:00.000000000 -0500
+++ banshee.mtp/src/Banshee.Dap/Mtp/MtpDapTrackInfo.cs	2006-06-20 01:34:48.000000000 -0400
@@ -0,0 +1,86 @@
+/***************************************************************************
+ *  MtpDapTrackInfo.cs
+ *
+ *  Copyright (C) 2006 Novell and Patrick van Staveren
+ *  Written by Patrick van Staveren (trick vanstaveren us)
+ ****************************************************************************/
+
+/*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),  
+ *  to deal in the Software without restriction, including without limitation  
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,  
+ *  and/or sell copies of the Software, and to permit persons to whom the  
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in 
+ *  all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+using System; 
+using Banshee.Base;
+using Banshee.Dap;
+using LibGPhoto2;
+
+namespace Banshee.Dap.Mtp
+{
+    public sealed class MtpDapTrackInfo : DapTrackInfo
+    {
+        GPhotoDeviceFile GpDeviceFile;
+        public MtpDapTrackInfo(GPhotoDeviceFile DevFile) : base()
+        {
+            GpDeviceFile = DevFile;
+            //uri = new SafeUri(String.Format("dap://{0}/{1}", DevFile.Directory, DevFile.Filename));
+                        // uri commented out on upgrade to banshee cvs on 2006-04-20 from a 2 month old snapshot - apparently safeuri is causing crashes in transcode in my system.  urgh.
+            //uri = new SafeUri(String.Format("dap://{0}/{1}/{2}", dap.Uid, DevFile.Directory, DevFile.Filename));
+            album = DevFile.AlbumName;
+            artist = DevFile.Artist;
+            title = DevFile.Name;
+            genre = DevFile.Genre;
+            duration = TimeSpan.FromMilliseconds(DevFile.Duration);;
+            play_count = DevFile.UseCount;
+            track_number = DevFile.Track;
+            year = DevFile.Year;
+            CanPlay = false;
+            this.NeedSync = false;
+        }
+
+        public GPhotoDeviceFile DeviceFile {
+            get {
+                return GpDeviceFile;
+            }
+        }
+            
+        public override void Save() {
+            Console.WriteLine("track saving doesn't work.");
+            /*GpDeviceFile.AlbumName = album;
+            GpDeviceFile.Artist = artist;
+            GpDeviceFile.Genre = genre;
+            GpDeviceFile.Name = title;
+            GpDeviceFile.Track = track_number;
+            GpDeviceFile.UseCount = play_count;
+            GpDeviceFile.Year = year;
+            
+            GpDeviceFile.SaveMetadata();
+            Console.WriteLine("Track Save just might have worked!");*/
+        }
+
+        public override void IncrementPlayCount() {
+            play_count++;
+            Save();
+        }
+
+        protected override void SaveRating() {
+            Save();
+        }
+    }
+}
diff -Nru -Nru banshee/src/Banshee.Dap/Mtp/MtpDeviceId.cs banshee.mtp/src/Banshee.Dap/Mtp/MtpDeviceId.cs
--- banshee/src/Banshee.Dap/Mtp/MtpDeviceId.cs	1969-12-31 19:00:00.000000000 -0500
+++ banshee.mtp/src/Banshee.Dap/Mtp/MtpDeviceId.cs	2006-06-20 01:34:41.000000000 -0400
@@ -0,0 +1,129 @@
+/***************************************************************************
+ *  MtpDeviceId.cs
+ *
+ *  Copyright (C) 2006 Novell and Patrick van Staveren
+ *  Written by Patrick van Staveren (trick vanstaveren us)
+ ****************************************************************************/
+
+/*  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: 
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),  
+ *  to deal in the Software without restriction, including without limitation  
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,  
+ *  and/or sell copies of the Software, and to permit persons to whom the  
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in 
+ *  all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+namespace Banshee.Dap.Mtp
+{
+    public class DeviceId
+    {
+        private static DeviceId [] device_id_list = {
+            /*
+                Device list taken from libgphoto2/camlibs/library.c starting around line 580
+                Last updated: 2006-05-07
+
+                Please note: just beause your device exists in this list, does not mean
+                it will work (flawlessly) with Banshee.
+                Many players are still in the progress of being supported.
+                
+                There are known issues with the iRiver players (2006-May)
+
+                         Full Device Name                               Display/Short Name      Vendor ID   Product ID */
+            new DeviceId("iRiver T10 (alternative)",                    "iRiver T10",           0x4102,     0x1113),
+            new DeviceId("iRiver U10",                                  "iRiver U10",           0x4102,     0x1116),
+            new DeviceId("iRiver T10",                                  "iRiver T10",           0x4102,     0x1117),
+            new DeviceId("iRiver T20",                                  "iRiver T20",           0x4102,     0x1118),
+            new DeviceId("iRiver T30",                                  "iRiver T30",           0x4102,     0x1119),
+            new DeviceId("iRiver H10",                                  "iRiver H10",           0x4102,     0x2102),
+            /* iRiver H30? Anyone? */
+            new DeviceId("iRiver Portable Media Center",                "iRiver PMC",           0x1006,     0x4002),
+            new DeviceId("iRiver Portable Media Center",                "iRiver PMC",           0x1006,     0x4003),
+            new DeviceId("Phillips HDD6320",                            "HDD6320",              0x0471,     0x01eb),
+            new DeviceId("Creative Zen Vision",                         "Zen Vision",           0x041e,     0x411f),
+            new DeviceId("Creative Portable Media Center",              "Media Center",         0x041e,     0x4123),
+            new DeviceId("Creative Zen Xtra",                           "Zen Xtra",             0x041e,     0x4128),
+            new DeviceId("Second Generation Dell DJ",                   "Dell DJ",              0x041e,     0x412f),
+            new DeviceId("Creative Zen Micro",                          "Zen Micro",            0x041e,     0x4130),
+            new DeviceId("Creative Zen Touch",                          "Zen Touch",            0x041e,     0x4131),
+            new DeviceId("Creative Zen Sleek",                          "Zen Sleek",            0x041e,     0x4137),
+            new DeviceId("Creative Zen MicroPhoto",                     "Zen MicroPhoto",       0x041e,     0x413c),
+            new DeviceId("Creative Zen Sleek Photo",                    "Zen Sleek Photo",      0x041e,     0x413d),
+            new DeviceId("Creative Zen Vision:M",                       "Zen Vision:M",         0x041e,     0x413e),
+            new DeviceId("Samsung YP-T7J",                              "Samsung YP-T7J",       0x04e8,     0x5047),
+            new DeviceId("Samsung YH-999 Portable Media Center",        "Samsung YH-999",       0x04e8,     0x5a0f),
+            new DeviceId("Dell DJ Ditty",                               "DJ Ditty",             0x413c,     0x4500),
+            new DeviceId("Toshiba Gigabeat",                            "Gigabeat",             0x0930,     0x000c),
+            new DeviceId("Intel Bandon Portable Media Center",          "Intel Bandon",         0x045e,     0x00c9)
+        };
+
+        public static DeviceId [] ListAll {
+            get {
+                return device_id_list;
+            }
+        }
+
+        public static bool IsMtpDevice(short vendorId, short productId) {
+            return GetDeviceId(vendorId, productId) != null;
+        }
+
+        public static DeviceId GetDeviceId(short vendorId, short productId)
+        {
+            foreach(DeviceId id in ListAll) {
+                if(id.VendorId == vendorId && id.ProductId == productId) {
+                    return id;
+                }
+            }
+            return null;
+        }
+
+        private string name;
+        private string display_name;
+        private short vendor_id;
+        private short product_id;
+
+        private DeviceId(string name, string displayName, short vendorId, short productId)
+        {
+            this.name = name;
+            this.display_name = displayName;
+            this.vendor_id = vendorId;
+            this.product_id = productId;
+        }
+
+        public string Name {
+            get {
+                return name;
+            }
+        }
+
+        public string DisplayName {
+            get {
+                return display_name;
+            }
+        }
+
+        public short VendorId {
+            get {
+                return vendor_id;
+            }
+        }
+
+        public short ProductId {
+            get {
+                return product_id;
+            }
+        }
+    }
+}

Attachment: libgphoto2-sharp.pc
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]