Mailinglist Archive: opensuse-commit (1124 mails)

< Previous Next >
commit ipod-sharp
  • From: root@xxxxxxxxxxxxxxx (h_root)
  • Date: Mon, 02 Apr 2007 00:58:32 +0200
  • Message-id: <20070401225832.9FDAB67816B@xxxxxxxxxxxxxxx>

Hello community,

here is the log from the commit of package ipod-sharp
checked in at Mon Apr 2 00:58:32 CEST 2007.

--------
--- GNOME/ipod-sharp/ipod-sharp.changes 2007-03-23 03:02:51.000000000 +0100
+++ /mounts/work_src_done/STABLE/ipod-sharp/ipod-sharp.changes  2007-04-01 19:40:08.254785000 +0200
@@ -1,0 +2,9 @@
+Sun Apr  1 19:39:02 CEST 2007 - abockover@xxxxxxx
+
+- Update to version 0.6.3
+  Fixes BNC #257156, parts of #239107
+  Adds support for new DB records introduced by iTunes 7.1
+  Supports second generation Shuffles
+  Better HFS+/read only support
+
+-------------------------------------------------------------------

Old:
----
  ipod-sharp-0.6.2.tar.gz
  itunes-7.1.patch

New:
----
  ipod-sharp-0.6.3.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ipod-sharp.spec ++++++
--- /var/tmp/diff_new_pack.d31313/_old  2007-04-02 00:58:24.000000000 +0200
+++ /var/tmp/diff_new_pack.d31313/_new  2007-04-02 00:58:24.000000000 +0200
@@ -1,5 +1,5 @@
 #
-# spec file for package ipod-sharp (Version 0.6.2)
+# spec file for package ipod-sharp (Version 0.6.3)
 #
 # Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
 # This file and all modifications and additions to the pristine
@@ -16,11 +16,10 @@
 License:        GNU Library General Public License v. 2.0 and 2.1 (LGPL)
 Group:          Development/Libraries/GNOME
 Autoreqprov:    on
-Version:        0.6.2
-Release:        50
+Version:        0.6.3
+Release:        1
 Summary:        Library for Interacting with Apple iPodŽ Devices
 Source:         %{name}-%{version}.tar.gz
-Patch0:         itunes-7.1.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Requires:       libipoddevice mono-core gtk-sharp2 glib-sharp2
 
@@ -37,13 +36,13 @@
 
 %prep
 %setup -q
-%patch0
 
 %build
 export CFLAGS="$RPM_OPT_FLAGS"
 ./configure    --prefix=/usr           \
                --libdir=%{_libdir}     \
-               --mandir=%{_mandir}
+               --mandir=%{_mandir} \
+               --disable-docs
 make
 
 %install
@@ -56,13 +55,16 @@
 %defattr(-,root,root)
 %doc AUTHORS NEWS README COPYING
 %{_prefix}/lib/ipod-sharp
-%{_prefix}/lib/monodoc/sources/ipod-sharp-docs.source
-%{_prefix}/lib/monodoc/sources/ipod-sharp-docs.tree
-%{_prefix}/lib/monodoc/sources/ipod-sharp-docs.zip
 %{_libdir}/pkgconfig/ipod-sharp.pc
 %{_libdir}/pkgconfig/ipod-sharp-ui.pc
 
 %changelog
+* Sun Apr 01 2007 - abockover@xxxxxxx
+- Update to version 0.6.3
+  Fixes BNC #257156, parts of #239107
+  Adds support for new DB records introduced by iTunes 7.1
+  Supports second generation Shuffles
+  Better HFS+/read only support
 * Fri Mar 23 2007 - abockover@xxxxxxx
 - Patch to enable databases touched by iTunes 7.1 to be read
 * Fri Sep 29 2006 - gekker@xxxxxxx

++++++ ipod-sharp-0.6.2.tar.gz -> ipod-sharp-0.6.3.tar.gz ++++++
++++ 4956 lines of diff (skipped)
++++    retrying with extended exclude list
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ipod-sharp-0.6.2/ChangeLog new/ipod-sharp-0.6.3/ChangeLog
--- old/ipod-sharp-0.6.2/ChangeLog      2006-09-19 18:54:15.000000000 +0200
+++ new/ipod-sharp-0.6.3/ChangeLog      2007-04-01 07:05:07.000000000 +0200
@@ -1,3 +1,60 @@
+2007-04-04  Aaron Bockover  <abock@xxxxxxxxx>
+
+       0.6.3 Released
+
+       * configure.ac: Bump to 0.6.3, require libipoddevice 0.5.3
+
+2007-03-31  James Willcox  <snorp@xxxxxxxxx>
+
+       * src/TrackDatabase.cs: add support for another detail type found in
+       the album list.
+
+2007-03-30  Aaron Bockover  <abock@xxxxxxxxx>
+
+       * src/DeviceModel.cs: Added new model types from libipoddevice (shuffle 2)
+
+       * src/Device.cs: Added an IsShuffle property
+
+2007-03-30  Aaron Bockover  <abock@xxxxxxxxx>
+
+       * src/TrackDatabase.cs: do not copy iTunesDB if read only (HFS+)
+
+2007-03-29  James Willcox  <snorp@xxxxxxxxx>
+
+       * src/TrackDatabase.cs: add write support for this new album list
+       data
+
+2007-03-29  James Willcox  <snorp@xxxxxxxxx>
+
+       * src/TrackDatabase.cs: oops, there are some new mhod types in the
+       album list data.  This adds them.
+
+2007-03-29  James Willcox  <snorp@xxxxxxxxx>
+
+       * src/TrackDatabase.cs: parse the new "album list" data set found on
+       2nd gen nano and shuffle after being synced with iTunes 7.1.
+
+2007-03-29  Aaron Bockover  <abock@xxxxxxxxx>
+
+       * src/TrackDatabase.cs:
+       * src/Track.cs: Add null checks for the artwork DB as on some devices we
+       may not be able to read the format info, and we shouldn't crash if that's
+       the case
+
+2007-03-23  Aaron Bockover  <abock@xxxxxxxxx>
+
+       * src/Firmware/DmgFirmwareExtract.cs: Updated so my old work isn't lost, 
+       but with iTunes 7, they shattered my dreams of firmware updating... for now
+
+2007-03-19  James Willcox  <snorp@xxxxxxxxx>
+
+       * src/TrackDatabase.cs: bump the supported database version to 20
+       (which is what iTunes 7.1 uses)
+
+2006-12-19  Aaron Bockover  <abock@xxxxxxxxx>
+
+       * src/DeviceModel.cs: Added NanoProductRed
+
 2006-09-19  Aaron Bockover  <abock@xxxxxxxxx>
 
        * src/Device.cs: Added ShouldAskIfUnknown and DoNotAskIfUnknown 
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ipod-sharp-0.6.2/configure.ac new/ipod-sharp-0.6.3/configure.ac
--- old/ipod-sharp-0.6.2/configure.ac   2006-09-18 15:49:34.000000000 +0200
+++ new/ipod-sharp-0.6.3/configure.ac   2007-04-01 07:03:34.000000000 +0200
@@ -3,7 +3,7 @@
 
 MAJOR_VERSION=0
 MINOR_VERSION=6
-MICRO_VERSION=2
+MICRO_VERSION=3
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
                                                                                 
 AM_INIT_AUTOMAKE(ipod-sharp, $VERSION)
@@ -18,7 +18,7 @@
 
 AM_MAINTAINER_MODE
 
-PKG_CHECK_MODULES(IPODDEVICE, ipoddevice >= 0.5.0 gtk-sharp-2.0)
+PKG_CHECK_MODULES(IPODDEVICE, ipoddevice >= 0.5.3 gtk-sharp-2.0)
 
 dnl Mono          
 AC_PATH_PROG(MONO, mono)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ipod-sharp-0.6.2/src/Device.cs new/ipod-sharp-0.6.3/src/Device.cs
--- old/ipod-sharp-0.6.2/src/Device.cs  2006-09-19 19:03:18.000000000 +0200
+++ new/ipod-sharp-0.6.3/src/Device.cs  2007-03-30 21:08:12.000000000 +0200
@@ -225,6 +225,14 @@
             }
         }
 
+        public bool IsShuffle {
+            get { 
+                return Model == DeviceModel.Shuffle || (
+                    Model >= DeviceModel.ShuffleSilver &&
+                    Model <= DeviceModel.ShuffleOrange);
+            }
+        }
+
         public string SerialNumber {
             get {
                 return (string) GetProperty ("serial-number").Val;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ipod-sharp-0.6.2/src/DeviceModel.cs new/ipod-sharp-0.6.3/src/DeviceModel.cs
--- old/ipod-sharp-0.6.2/src/DeviceModel.cs     2006-03-07 04:26:31.000000000 +0100
+++ new/ipod-sharp-0.6.3/src/DeviceModel.cs     2007-03-30 21:08:14.000000000 +0200
@@ -17,7 +17,17 @@
         NanoWhite,
         NanoBlack,
         VideoWhite,
-        VideoBlack
+        VideoBlack,
+        NanoSilver,
+        NanoGreen,
+        NanoBlue,
+        NanoPink,
+        NanoProductRed,
+        ShuffleSilver,
+        ShufflePink,
+        ShuffleBlue,
+        ShuffleGreen,
+        ShuffleOrange
     }
 }
 
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ipod-sharp-0.6.2/src/Firmware/DmgFirmwareExtract.cs new/ipod-sharp-0.6.3/src/Firmware/DmgFirmwareExtract.cs
--- old/ipod-sharp-0.6.2/src/Firmware/DmgFirmwareExtract.cs     2006-06-15 01:37:31.000000000 +0200
+++ new/ipod-sharp-0.6.3/src/Firmware/DmgFirmwareExtract.cs     2006-07-06 22:32:12.000000000 +0200
@@ -37,6 +37,7 @@
                 ExtractDmgImage(dmgFile);
                 MountIsoImage();
                 ExtractFirmwareArchive();
+                ExtractLicenseAgreements();
             } finally {
                 UnmountIsoImage();
                 File.Delete(iso_path);
@@ -87,13 +88,21 @@
             }
         }
         
+        private void ExtractLicenseAgreements()
+        {
+            foreach(DirectoryInfo directory in new DirectoryInfo(ResourcesPath).GetDirectories("*.lproj")) {
+                string license_extract_name = String.Format("{0}.rtf", 
+                    directory.Name.Substring(0, directory.Name.Length - 6));
+                File.Copy(Path.Combine(directory.FullName, "License.rtf"), 
+                    Path.Combine(firmware_export_path, license_extract_name));
+            }
+        }
+        
         private void ExtractFirmwareArchive()
         {
             string ipod_package = null;
-            string packages = Path.Combine(dmg_mount, 
-                String.Format("iPod.mpkg{0}Contents{0}Resources", Path.DirectorySeparatorChar));
             
-            foreach(DirectoryInfo directory in new DirectoryInfo(packages).GetDirectories("iPod*.pkg")) {
+            foreach(DirectoryInfo directory in new DirectoryInfo(ResourcesPath).GetDirectories("iPod*.pkg")) {
                 ipod_package = directory.FullName;
                 break;
             }
@@ -155,5 +164,12 @@
                 throw new ApplicationException(message);
             }
         }
+        
+        public string ResourcesPath { 
+            get { 
+                return Path.Combine(dmg_mount, String.Format("iPod.mpkg{0}Contents{0}Resources", 
+                    Path.DirectorySeparatorChar));
+            }
+        }
     }
 }
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ipod-sharp-0.6.2/src/Track.cs new/ipod-sharp-0.6.3/src/Track.cs
--- old/ipod-sharp-0.6.2/src/Track.cs   2006-06-30 03:06:28.000000000 +0200
+++ new/ipod-sharp-0.6.3/src/Track.cs   2007-03-23 17:45:46.000000000 +0100
@@ -269,7 +269,7 @@
         }
 
         private void FindCoverPhoto () {
-            if (coverPhoto == null) {
+            if (coverPhoto == null && db.ArtworkDatabase != null) {
                 coverPhoto = db.ArtworkDatabase.LookupPhotoByTrackId (record.DatabaseId);
             }
         }
@@ -293,8 +293,15 @@
                 if (!createNew)
                     return null;
                 
-                coverPhoto = db.ArtworkDatabase.CreatePhoto ();
-                coverPhoto.Record.TrackId = record.DatabaseId;
+                
+                if (db.ArtworkDatabase != null) {
+                    coverPhoto = db.ArtworkDatabase.CreatePhoto ();
+                    coverPhoto.Record.TrackId = record.DatabaseId;
+                }
+            }
+
+            if (coverPhoto == null) {
+                return null;
             }
 
             Thumbnail thumbnail = coverPhoto.LookupThumbnail (format);
@@ -319,7 +326,7 @@
         public void RemoveCoverArt () {
             FindCoverPhoto ();
 
-            if (coverPhoto != null) {
+            if (coverPhoto != null && db.ArtworkDatabase != null) {
                 db.ArtworkDatabase.RemovePhoto (coverPhoto);
             }
         }
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/ipod-sharp-0.6.2/src/TrackDatabase.cs new/ipod-sharp-0.6.3/src/TrackDatabase.cs
--- old/ipod-sharp-0.6.2/src/TrackDatabase.cs   2006-09-13 00:26:06.000000000 +0200
+++ new/ipod-sharp-0.6.3/src/TrackDatabase.cs   2007-03-31 20:24:34.000000000 +0200
@@ -637,7 +637,10 @@
         PlaylistData = 50,
         PlaylistRules = 51,
         LibraryIndex = 52,
-        Misc = 100
+        Misc = 100,
+        AlbumListAlbum = 200,
+        AlbumListArtist = 201,
+        AlbumListPodcastUrl = 203
     }
 
     internal enum IndexType {
@@ -681,13 +684,14 @@
             
             Type = (DetailType) ToInt32 (body, 0);
 
-            if ((int) Type > 50 && Type != DetailType.Misc && Type != DetailType.LibraryIndex)
+            if ((int) Type > 50 && Type != DetailType.Misc && Type != DetailType.LibraryIndex &&
+                Type != DetailType.AlbumListArtist && Type != DetailType.AlbumListAlbum && Type != DetailType.AlbumListPodcastUrl)
                 throw new DatabaseReadException ("Unsupported detail type: " + Type);
 
             unknownOne = ToInt32 (body, 4);
             unknownTwo = ToInt32 (body, 8);
             
-            if ((int) Type < 50) {
+            if ((int) Type < 50 || Type == DetailType.AlbumListArtist || Type == DetailType.AlbumListAlbum || Type == DetailType.AlbumListPodcastUrl) {
                 if (Type == DetailType.PodcastUrl ||
                     Type == DetailType.PodcastUrl2) {
 
@@ -704,7 +708,7 @@
                     int strlen = 0;
                     //int strenc = 0;
             
-                    if ((int) Type < 50) {
+                    if ((int) Type < 50 || Type == DetailType.AlbumListArtist || Type == DetailType.AlbumListAlbum || Type == DetailType.AlbumListPodcastUrl) {
                         // 'string' mhods       
                         strlen = ToInt32 (body, 16);
                         //strenc = ToInt32 (body, 20); // 0 == UTF16, 1 == UTF8
@@ -754,7 +758,8 @@
 
             byte[] valbytes = null;
 
-            if ((int) Type < 50) {
+            if ((int) Type < 50 || Type == DetailType.AlbumListArtist || Type == DetailType.AlbumListAlbum ||
+                Type == DetailType.AlbumListPodcastUrl) {
                 if (Type == DetailType.PodcastUrl || Type == DetailType.PodcastUrl2) {
                     valbytes = Encoding.UTF8.GetBytes (Value);
                     writer.Write (24 + valbytes.Length);
@@ -781,7 +786,8 @@
             writer.Write (unknownOne);
             writer.Write (unknownTwo);
 
-            if ((int) Type < 50) {
+            if ((int) Type < 50 || Type == DetailType.AlbumListArtist || Type == DetailType.AlbumListAlbum ||
+                Type == DetailType.AlbumListPodcastUrl) {
                 if (Type == DetailType.PodcastUrl || Type == DetailType.PodcastUrl2 ||
                     Type == DetailType.ChapterData) {
                     writer.Write (valbytes);
@@ -1244,10 +1250,138 @@
         }
     }
 
+    // should be AlbumListRecord, but that exists in PhotoDatabase already, sigh
+    internal class TrackAlbumListRecord : TrackDbRecord {
+
+        private List<TrackAlbumItemRecord> albums = new List<TrackAlbumItemRecord> ();
+
+        public IList<TrackAlbumItemRecord> Albums {
+            get { return new ReadOnlyCollection<TrackAlbumItemRecord> (albums); }
+        }
+
+        public TrackAlbumListRecord (bool isbe) : base (isbe) {
+            this.Name = "mhla";
+        }
+
+        public void Clear () {
+            albums.Clear ();
+        }
+
+        public void Remove (TrackAlbumItemRecord item) {
+            albums.Remove (item);
+        }
+
+        public void Add (TrackAlbumItemRecord item) {
+            albums.Add (item);
+        }
+        
+        public override void Read (DatabaseRecord db, BinaryReader reader) {
+
+            base.Read (db, reader);
+            
+            reader.ReadBytes (this.HeaderOne - 12);
+
+            int albumCount = this.HeaderTwo;
+
+            albums.Clear ();
+
+            for (int i = 0; i < albumCount; i++) {
+                TrackAlbumItemRecord rec = new TrackAlbumItemRecord (IsBE);
+                rec.Read (db, reader);
+                albums.Add (rec);
+            }
+        }
+
+        public override void Save (DatabaseRecord db, BinaryWriter writer) {
+
+            MemoryStream stream = new MemoryStream ();
+            BinaryWriter childWriter = new EndianBinaryWriter (stream, IsBE);
+
+            foreach (TrackAlbumItemRecord rec in albums) {
+                rec.Save (db, childWriter);
+            }
+
+            childWriter.Flush ();
+            byte[] childData = stream.GetBuffer ();
+            int childDataLength = (int) stream.Length;
+            childWriter.Close ();
+
+            WriteName (writer);
+            writer.Write (12 + PadLength);
+            writer.Write (albums.Count);
+            writer.Write (new byte[PadLength]);
+            writer.Write (childData, 0, childDataLength);
+        }
+    }
+
+    internal class TrackAlbumItemRecord : TrackDbRecord {
+
+        private List<DetailRecord> details = new List<DetailRecord> ();
+
+        public IList<DetailRecord> Details {
+            get { return new ReadOnlyCollection<DetailRecord> (details); }
+        }
+
+        public TrackAlbumItemRecord (bool isbe) : base (isbe) {
+            this.Name = "mhia";
+        }
+
+        public void Clear () {
+            details.Clear ();
+        }
+
+        public void Remove (DetailRecord item) {
+            details.Remove (item);
+        }
+
+        public void Add (DetailRecord item) {
+            details.Add (item);
+        }
+        
+        public override void Read (DatabaseRecord db, BinaryReader reader) {
+
+            base.Read (db, reader);
+            
+            byte[] body = reader.ReadBytes (this.HeaderOne - 12);
+
+            int detailCount = ToInt32 (body, 0);
+
+            details.Clear ();
+
+            for (int i = 0; i < detailCount; i++) {
+                DetailRecord detail = new DetailRecord (IsBE);
+                detail.Read (db, reader);
+                details.Add (detail);
+            }
+        }
+
+        public override void Save (DatabaseRecord db, BinaryWriter writer) {
+
+            MemoryStream stream = new MemoryStream ();
+            BinaryWriter childWriter = new EndianBinaryWriter (stream, IsBE);
+
+            foreach (DetailRecord detail in details) {
+                detail.Save (db, childWriter);
+            }
+
+            childWriter.Flush ();
+            byte[] childData = stream.GetBuffer ();
+            int childDataLength = (int) stream.Length;
+            childWriter.Close ();
+
+            WriteName (writer);
+            writer.Write (16);
+            writer.Write (16 + childDataLength);
+            writer.Write (details.Count);
+            writer.Write (childData, 0, childDataLength);
+        }
+    }
+
     internal enum DataSetIndex {
         Library = 1,
         Playlist = 2,
-        PlaylistDuplicate = 3
+        PlaylistDuplicate = 3,
+        AlbumList = 4
     }
 
     internal class DataSetRecord : TrackDbRecord {
@@ -1256,6 +1390,7 @@
 
         public TrackListRecord TrackList;
         public PlaylistListRecord PlaylistList;
+        public TrackAlbumListRecord AlbumList;
 
         public PlaylistRecord Library {
             get {
@@ -1298,6 +1433,10 @@
                 this.PlaylistList = new PlaylistListRecord (IsBE);
                 this.PlaylistList.Read (db, reader);
                 break;
+            case DataSetIndex.AlbumList:
+                this.AlbumList = new TrackAlbumListRecord (IsBE);
+                this.AlbumList.Read (db, reader);
+                break;
             default:
                 throw new DatabaseReadException ("Can't handle dataset index: " + Index);
             }
@@ -1319,6 +1458,9 @@
             case DataSetIndex.PlaylistDuplicate:
                 PlaylistList.Save (db, childWriter);
                 break;
+            case DataSetIndex.AlbumList:
+                AlbumList.Save (db, childWriter);
+                break;
             default:
                 throw new DatabaseReadException ("Can't handle DataSet record index: " + Index);
             }
@@ -1339,7 +1481,7 @@
 
     internal class DatabaseRecord : TrackDbRecord {
 
-        private const int MaxSupportedVersion = 19;
+        private const int MaxSupportedVersion = 20;
         private const int TrackIdStart = 1000;
 
         private int unknownOne = 1;
@@ -1421,7 +1563,6 @@
         }
 
         public override void Save (DatabaseRecord db, BinaryWriter writer) {
-
             ReassignTrackIds ();
             
             MemoryStream stream = new MemoryStream ();
@@ -1611,13 +1752,17 @@
         internal TrackDatabase (Device device, bool createFresh) {
             this.device = device;
             
-            if(createFresh && File.Exists(TrackDbPath)) {
+            if(createFresh && File.Exists(TrackDbPath) && device.CanWrite) {
                 File.Copy (TrackDbPath, TrackDbBackupPath, true);
             }
 
             Reload (createFresh);
 
-            artdb = new PhotoDatabase (device, false, createFresh);
+            try {
+                artdb = new PhotoDatabase (device, false, createFresh);
+            } catch {
+                artdb = null;
+            }
         }
         
         
@@ -1811,7 +1956,7 @@
 
                 uniqueName += ext;
             } while(File.Exists(basePath + uniqueName));
-                               
+
             return uniqueName.Replace("/", ":");
         }
 
@@ -1856,9 +2001,51 @@
             }
         }
 
+        private void CreateAlbumList () {
+            DataSetRecord ds = dbrec[DataSetIndex.AlbumList];
+
+            // FIXME: figure out when we should create one of these if it doesn't exit
+            if (ds == null)
+                return;
+
+            TrackAlbumListRecord albumList = ds.AlbumList;
+
+            albumList.Clear ();
+            
+            List<string> albums = new List<string> ();
+            
+            foreach (Track track in tracks) {
+                string key = track.Album + "|" + track.Artist;
+                if (!albums.Contains (key)) {
+                    albums.Add (key);
+                }
+            }
+            
+            foreach (string album in albums) {
+                TrackAlbumItemRecord item = new TrackAlbumItemRecord (dbrec.IsBE);
+                
+                string[] splitAlbum = album.Split(new char[] {'|'}, 2);
+                if (splitAlbum.Length != 2)
+                    continue;
+                
+                DetailRecord albumDetail = new DetailRecord (dbrec.IsBE);
+                albumDetail.Type = DetailType.AlbumListAlbum;
+                albumDetail.Value = splitAlbum[0];
+                
+                DetailRecord artistDetail = new DetailRecord (dbrec.IsBE);
+                artistDetail.Type = DetailType.AlbumListArtist;
+                artistDetail.Value = splitAlbum[1];
+                
+                item.Add (albumDetail);
+                item.Add (artistDetail);
+                albumList.Add (item);
+            }
+        }
+
         public void Save () {
 
             CheckFreeSpace ();
+            CreateAlbumList ();
 
             // make sure all the new tracks have file names, and that they exist
             foreach (Track track in tracksToAdd) {
@@ -1874,7 +2061,7 @@
                 SaveStarted (this, new EventArgs ());
 
             // Back up the current track db
-            if (File.Exists (TrackDbPath))
+            if (File.Exists (TrackDbPath) && device.CanWrite)
                 File.Copy (TrackDbPath, TrackDbBackupPath, true);
             
             try {
@@ -1904,7 +2091,9 @@
                 }
 
                 // Save artwork database
-                artdb.Save ();
+                if (artdb != null) {
+                    artdb.Save ();
+                }
 
                 // Save the shuffle tracks db (will only create if device is shuffle);
                 try {
@@ -1938,7 +2127,7 @@
                 Mono.Unix.Native.Syscall.sync ();
             } catch (Exception e) {
                 // rollback the track db
-                if (File.Exists (TrackDbBackupPath))
+                if (File.Exists (TrackDbBackupPath) && device.CanWrite)
                     File.Copy (TrackDbBackupPath, TrackDbPath, true);
 
                 throw new DatabaseWriteException (e, "Failed to save database");
@@ -2020,11 +2209,13 @@
                 dbrec[DataSetIndex.Playlist].Library.RemoveTrack (track.Record.Id);
 
                 // remove from cover art db
-                Photo artPhoto = artdb.LookupPhotoByTrackId (track.Record.DatabaseId);
-                if (artPhoto != null) {
-                    artdb.RemovePhoto (artPhoto);
+                if (artdb != null) {
+                    Photo artPhoto = artdb.LookupPhotoByTrackId (track.Record.DatabaseId);
+                    if (artPhoto != null) {
+                        artdb.RemovePhoto (artPhoto);
+                    }
                 }
-                    
+
                 // remove from the "normal" playlists
                 foreach (Playlist list in playlists) {
                     list.RemoveTrack (track);


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages