Hello community,
here is the log from the commit of package ipod-sharp for openSUSE:Factory
checked in at Mon Mar 15 14:11:29 CET 2010.
--------
--- GNOME/ipod-sharp/ipod-sharp.changes 2009-10-13 22:24:32.000000000 +0200
+++ /mounts/work_src_done/STABLE/ipod-sharp/ipod-sharp.changes 2009-11-21 01:59:19.000000000 +0100
@@ -1,0 +2,5 @@
+Sat Nov 21 01:05:38 UTC 2009 - abockover@novell.com
+
+- Updated to 0.8.5
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
ipod-sharp-0.8.3.tar.bz2
New:
----
ipod-sharp-0.8.5.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ipod-sharp.spec ++++++
--- /var/tmp/diff_new_pack.D4LFox/_old 2010-03-15 14:11:23.000000000 +0100
+++ /var/tmp/diff_new_pack.D4LFox/_new 2010-03-15 14:11:23.000000000 +0100
@@ -1,7 +1,7 @@
#
-# spec file for package ipod-sharp (Version 0.8.3)
+# spec file for package ipod-sharp (Version 0.8.5)
#
-# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -21,10 +21,10 @@
Name: ipod-sharp
BuildRequires: glib-sharp2 gtk-sharp2 mono-devel ndesk-dbus-glib-devel podsleuth-devel
Url: http://www.snorp.net/log/?page_id=53
-License: LGPL v2.1 or later
+License: LGPLv2.1+
Group: Development/Libraries/GNOME
AutoReqProv: on
-Version: 0.8.3
+Version: 0.8.5
Release: 1
Summary: Library for Interacting with Apple(R) iPod(R) Devices
Source: %{name}-%{version}.tar.bz2
@@ -44,7 +44,7 @@
James Willcox
%package devel
-License: LGPL v2.1 or later
+License: LGPLv2.1+
Summary: Library for Interacting with Apple(R) iPod(R) Devices
Group: Development/Libraries/Other
Requires: %{name} = %{version}
++++++ ipod-sharp-0.8.3.tar.bz2 -> ipod-sharp-0.8.5.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipod-sharp-0.8.3/ChangeLog new/ipod-sharp-0.8.5/ChangeLog
--- old/ipod-sharp-0.8.3/ChangeLog 2009-10-02 01:28:15.000000000 +0200
+++ new/ipod-sharp-0.8.5/ChangeLog 2009-11-21 00:41:51.000000000 +0100
@@ -1,3 +1,31 @@
+2009-11-20 Gabriel Burt
+
+ * configure.ac:
+ * NEWS: Update for 0.8.5 release
+
+2009-11-16 Gabriel Burt
+
+ * src/TrackDatabase.cs: Patch from Carl Reinke fixing encoding issue that
+ prevented some databases from being read correctly (BGO #596526)
+
+2009-11-03 Gabriel Burt
+
+ Released 0.8.4
+
+ * NEWS: Updated
+
+2009-11-02 Gabriel Burt
+
+ * configure.ac: Bumped Version
+
+2009-10-27 Gabriel Burt
+
+ * src/Track.cs: Add podcast-related properties, including DateReleased,
+ Description, and more.
+
+ * src/TrackDatabase.cs: Support reading and writing the podcast playlist.
+ Most of the fix needed for BGO #434237
+
2009-10-01 Aaron Bockover
Released 0.8.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipod-sharp-0.8.3/NEWS new/ipod-sharp-0.8.5/NEWS
--- old/ipod-sharp-0.8.3/NEWS 2009-10-02 01:27:35.000000000 +0200
+++ new/ipod-sharp-0.8.5/NEWS 2009-11-21 00:40:32.000000000 +0100
@@ -1,3 +1,5 @@
+2009-11-20: Released 0.8.5
+2009-11-03: Released 0.8.4
2009-10-01: Released 0.8.3
2009-01-20: Released 0.8.2
2008-09-11: Released 0.8.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipod-sharp-0.8.3/configure new/ipod-sharp-0.8.5/configure
--- old/ipod-sharp-0.8.3/configure 2009-10-02 01:28:57.000000000 +0200
+++ new/ipod-sharp-0.8.5/configure 2009-11-21 00:39:53.000000000 +0100
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for ipod-sharp 0.8.3.
+# Generated by GNU Autoconf 2.63 for ipod-sharp 0.8.5.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@@ -594,8 +594,8 @@
# Identity of this package.
PACKAGE_NAME='ipod-sharp'
PACKAGE_TARNAME='ipod-sharp'
-PACKAGE_VERSION='0.8.3'
-PACKAGE_STRING='ipod-sharp 0.8.3'
+PACKAGE_VERSION='0.8.5'
+PACKAGE_STRING='ipod-sharp 0.8.5'
PACKAGE_BUGREPORT=''
ac_subst_vars='LTLIBOBJS
@@ -1266,7 +1266,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures ipod-sharp 0.8.3 to adapt to many kinds of systems.
+\`configure' configures ipod-sharp 0.8.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1337,7 +1337,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of ipod-sharp 0.8.3:";;
+ short | recursive ) echo "Configuration of ipod-sharp 0.8.5:";;
esac
cat <<\_ACEOF
@@ -1433,7 +1433,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-ipod-sharp configure 0.8.3
+ipod-sharp configure 0.8.5
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1447,7 +1447,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by ipod-sharp $as_me 0.8.3, which was
+It was created by ipod-sharp $as_me 0.8.5, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
@@ -2290,7 +2290,7 @@
# Define the identity of the package.
PACKAGE='ipod-sharp'
- VERSION='0.8.3'
+ VERSION='0.8.5'
cat >>confdefs.h <<_ACEOF
@@ -3925,7 +3925,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by ipod-sharp $as_me 0.8.3, which was
+This file was extended by ipod-sharp $as_me 0.8.5, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -3975,7 +3975,7 @@
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-ipod-sharp config.status 0.8.3
+ipod-sharp config.status 0.8.5
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipod-sharp-0.8.3/configure.ac new/ipod-sharp-0.8.5/configure.ac
--- old/ipod-sharp-0.8.3/configure.ac 2009-10-02 01:28:49.000000000 +0200
+++ new/ipod-sharp-0.8.5/configure.ac 2009-11-21 00:38:59.000000000 +0100
@@ -1,4 +1,4 @@
-AC_INIT([ipod-sharp], [0.8.3])
+AC_INIT([ipod-sharp], [0.8.5])
AC_CANONICAL_SYSTEM
AC_PREREQ(2.13)
AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipod-sharp-0.8.3/src/Track.cs new/ipod-sharp-0.8.5/src/Track.cs
--- old/ipod-sharp-0.8.3/src/Track.cs 2009-10-02 00:32:37.000000000 +0200
+++ new/ipod-sharp-0.8.5/src/Track.cs 2009-10-27 22:42:39.000000000 +0100
@@ -47,7 +47,24 @@
public MediaType Type {
get { return record.MediaType; }
- set { record.MediaType = value; }
+ set {
+ if (record.MediaType == value)
+ return;
+
+ record.MediaType = value;
+
+ if (value == MediaType.Podcast || value == MediaType.VideoPodcast) {
+ record.UnknownPodcastFlag = true;
+ if (db.Podcasts != null) {
+ db.Podcasts.AddTrack (this);
+ }
+ } else {
+ record.UnknownPodcastFlag = false;
+ if (db.Podcasts != null) {
+ db.Podcasts.RemoveTrack (this);
+ }
+ }
+ }
}
public string FileName {
@@ -138,6 +155,26 @@
get { return record.Year; }
set { record.Year = value; }
}
+
+ public DateTime DateReleased {
+ get { return record.DateReleased; }
+ set { record.DateReleased = value; }
+ }
+
+ public bool NotPlayedMark {
+ get { return record.NotPlayedMark; }
+ set { record.NotPlayedMark = value; }
+ }
+
+ public bool RememberPosition {
+ get { return record.RememberPosition; }
+ set { record.RememberPosition = value; }
+ }
+
+ public int BookmarkTime {
+ get { return record.BookmarkTime; }
+ set { record.BookmarkTime = value; }
+ }
public int BitRate {
get { return record.BitRate; }
@@ -203,6 +240,15 @@
}
}
+ public string Description {
+ get {
+ DetailRecord detail = record.GetDetail (DetailType.Description);
+ return detail.Value;
+ } set {
+ SetDetailValue (DetailType.Description, value);
+ }
+ }
+
public string Composer {
get {
DetailRecord detail = record.GetDetail(DetailType.Composer);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ipod-sharp-0.8.3/src/TrackDatabase.cs new/ipod-sharp-0.8.5/src/TrackDatabase.cs
--- old/ipod-sharp-0.8.3/src/TrackDatabase.cs 2009-10-02 00:32:37.000000000 +0200
+++ new/ipod-sharp-0.8.5/src/TrackDatabase.cs 2009-11-17 05:30:56.000000000 +0100
@@ -14,6 +14,7 @@
internal abstract class Record
{
+ internal bool DEBUG = false;
public const int PadLength = 8;
@@ -154,6 +155,7 @@
base.Read(db, reader);
data = reader.ReadBytes(this.HeaderTwo - 12);
+ if (DEBUG) Console.WriteLine (" {0}", this.Name);
}
public override void Save(DatabaseRecord db, BinaryWriter writer)
@@ -167,23 +169,23 @@
internal class PlaylistItemRecord : TrackDbRecord
{
-
- private int unknownOne = 0;
- private int unknownTwo = 0;
- private List<DetailRecord> details = new List<DetailRecord>();
+ public bool IsPodcastGroup;
+ private Int16 unknownOne = 0;
+ public int GroupID = 0;
+ internal List<DetailRecord> details = new List<DetailRecord>();
private DetailRecord posrec;
public int TrackId;
- public int Position
- {
+
+ public int Position {
get { return posrec.Position; }
set { posrec.Position = value; }
}
public int Timestamp;
+ public int PodcastGroupRef;
- public PlaylistItemRecord(bool isbe)
- : base(isbe)
+ public PlaylistItemRecord(bool isbe) : base(isbe)
{
this.Name = "mhip";
posrec = new DetailRecord(isbe);
@@ -198,13 +200,24 @@
byte[] body = reader.ReadBytes(this.HeaderOne - 12);
int numDataObjects = ToInt32(body, 0);
- unknownOne = ToInt32(body, 4);
- unknownTwo = ToInt32(body, 8);
+ IsPodcastGroup = ToInt16(body, 4) == 0x100;
+ unknownOne = ToInt16(body, 6);
+ GroupID = ToInt32(body, 8);
TrackId = ToInt32(body, 12);
Timestamp = ToInt32(body, 16);
+ PodcastGroupRef = ToInt32(body, 20);
details.Clear();
+ if (DEBUG) {
+ if (IsPodcastGroup)
+ Console.WriteLine (" mhip (podcast group, id {0})", GroupID);
+ else if (PodcastGroupRef > 0)
+ Console.WriteLine (" mhip (trackid {0}, podcast {1})", TrackId, PodcastGroupRef);
+ else
+ Console.WriteLine (" mhip (trackid {0})", TrackId);
+ }
+
for (int i = 0; i < numDataObjects; i++)
{
DetailRecord detail = new DetailRecord(IsBE);
@@ -220,9 +233,13 @@
}
}
- public override void Save(DatabaseRecord db, BinaryWriter writer)
+ public void AddDetail (DetailRecord detail)
{
+ details.Insert (0, detail);
+ }
+ public override void Save(DatabaseRecord db, BinaryWriter writer)
+ {
int childrenLength = 0;
byte[] childrenData = new byte[0];
@@ -241,23 +258,28 @@
}
WriteName(writer);
- writer.Write(32 + PadLength);
+ writer.Write(52 + PadLength);
// as of version 13, the detail record counts as a child
if (db.Version >= 13)
{
- writer.Write(32 + childrenLength + PadLength);
+ writer.Write(52 + childrenLength + PadLength);
}
else
{
- writer.Write(32 + PadLength);
+ writer.Write(52 + PadLength);
}
writer.Write(details.Count);
+ writer.Write((Int16) (IsPodcastGroup ? 0x100 : 0));
writer.Write(unknownOne);
- writer.Write(unknownTwo);
+ writer.Write(GroupID);
writer.Write(TrackId);
writer.Write(Timestamp);
+ writer.Write(PodcastGroupRef);
+ writer.Write((int)0); // unk4
+ writer.Write((int)0); // unk5
+ writer.Write((long)0);// unk6
writer.Write(new byte[PadLength]);
writer.Write(childrenData, 0, childrenLength);
}
@@ -304,7 +326,7 @@
private bool isLibrary;
private List<DetailRecord> stringDetails = new List<DetailRecord>();
- private List<Record> otherDetails = new List<Record>();
+ internal List<Record> otherDetails = new List<Record>();
private List<PlaylistItemRecord> playlistItems = new List<PlaylistItemRecord>();
private DetailRecord nameRecord;
@@ -312,16 +334,14 @@
public bool IsHidden;
public int Timestamp;
public int Id;
- public bool IsPodcast;
public SortOrder Order = SortOrder.Manual;
- public string PlaylistName
- {
+ public bool IsPodcast;
+
+ public string PlaylistName {
get { return nameRecord.Value; }
- set
- {
- if (nameRecord == null)
- {
+ set {
+ if (nameRecord == null) {
nameRecord = new DetailRecord(IsBE);
nameRecord.Type = DetailType.Title;
stringDetails.Add(nameRecord);
@@ -331,14 +351,18 @@
}
}
- public ReadOnlyCollection<PlaylistItemRecord> Items
- {
+ public ReadOnlyCollection<PlaylistItemRecord> Items {
get
{
return new ReadOnlyCollection<PlaylistItemRecord>(playlistItems);
}
}
+ public bool IsLibrary {
+ get { return isLibrary; }
+ set { isLibrary = value; }
+ }
+
public PlaylistRecord(bool isLibrary, bool isbe)
: base(isbe)
{
@@ -351,6 +375,10 @@
playlistItems.Clear();
}
+ public int Count {
+ get { return playlistItems.Count; }
+ }
+
public bool RemoveItem(int index)
{
if (index < 0 || index >= playlistItems.Count)
@@ -372,6 +400,11 @@
}
}
+ public void RemoveItem (PlaylistItemRecord item)
+ {
+ playlistItems.Remove (item);
+ }
+
public void AddItem(PlaylistItemRecord rec)
{
InsertItem(-1, rec);
@@ -394,6 +427,11 @@
return new PlaylistItemRecord(IsBE);
}
+ public int IndexOf (PlaylistItemRecord item)
+ {
+ return playlistItems.IndexOf (item);
+ }
+
public int IndexOf(int trackid)
{
@@ -419,10 +457,7 @@
int numdetails = ToInt32(body, 0);
int numitems = ToInt32(body, 4);
- int hiddenFlag = ToInt32(body, 8);
-
- if (hiddenFlag == 1)
- IsHidden = true;
+ IsHidden = body[8] == 1;
Timestamp = ToInt32(body, 12);
Id = ToInt32(body, 16);
@@ -430,18 +465,18 @@
if (db.Version >= 13)
{
- IsPodcast = ToInt16(body, 30) == 1 ? true : false;
+ IsPodcast = body[30] == 1;
Order = (SortOrder)ToInt32(body, 32);
}
+ if (DEBUG) Console.WriteLine (" mhyp (id {0}, w/ {1} items, podcast pl? {2})", Id, numitems, IsPodcast);
+
stringDetails.Clear();
otherDetails.Clear();
playlistItems.Clear();
- for (int i = 0; i < numdetails; i++)
- {
- if (i == 0)
- {
+ for (int i = 0; i < numdetails; i++) {
+ if (i == 0) {
nameRecord = new DetailRecord(IsBE);
nameRecord.Read(db, reader);
stringDetails.Add(nameRecord);
@@ -523,32 +558,98 @@
public override void Save(DatabaseRecord db, BinaryWriter writer)
{
+ Save (db, writer, false);
+ }
- if (isLibrary)
- {
+ public void Save(DatabaseRecord db, BinaryWriter writer, bool podcast_mhsd)
+ {
+ if (isLibrary) {
CreateLibraryIndices(db[DataSetIndex.Library].TrackList);
}
MemoryStream stream = new MemoryStream();
BinaryWriter childWriter = new EndianBinaryWriter(stream, IsBE);
- foreach (TrackDbRecord rec in stringDetails)
- {
+ foreach (DetailRecord rec in stringDetails) {
rec.Save(db, childWriter);
}
- foreach (TrackDbRecord rec in otherDetails)
- {
+ foreach (TrackDbRecord rec in otherDetails) {
rec.Save(db, childWriter);
}
- int pos = 1;
- foreach (PlaylistItemRecord item in playlistItems)
- {
- item.Position = pos++;
- item.Save(db, childWriter);
+ int item_count = 0;
+ if (IsPodcast && podcast_mhsd) {
+ // the podcast playlist has a different structure than normal playlists.
+ // namely, instead of just a list of tracks, it contains an entry for a podcast
+ // followed by the episodes for that podcast, repeat
+ var items = new List<PlaylistItemRecord> ();
+
+ // Identify unique albums (podcast/groups) and create special mhip entries for them
+ int current_group_id = 1;
+ var groups = new Dictionary ();
+ var group_counts = new Dictionary ();
+ var tracks = db[DataSetIndex.Library].TrackList;
+
+ // some podcast entries are already in the list of playlistItems (eg ones that were
+ // already on the iPod); for new episodes, the podcast entry doesn't exist, so create it
+ foreach (var item in playlistItems) {
+
+ // found an existing podcast entry
+ if (item.IsPodcastGroup) {
+ groups[item.Name] = item;
+ group_counts[item] = 0;
+ items.Add (item);
+ continue;
+ }
+
+ var track = tracks.LookupTrack (item.TrackId);
+ if (track == null)
+ continue;
+
+ // see if we already have a podcast entry for this episode's podcast
+ // if so, reuse it, if not, make a new one
+ var name = track.GetDetail (DetailType.Album).Value;
+ if (!groups.ContainsKey (name)) {
+ var group = new PlaylistItemRecord (IsBE);
+ group.IsPodcastGroup = true;
+ group.TrackId = 0;
+ group.GroupID = current_group_id++;
+ group.details.Clear ();
+ group.AddDetail (new DetailRecord (DetailType.Title, name, IsBE));
+ groups[name] = group;
+ group_counts[group] = 0;
+ items.Add (group);
+ }
+
+ var podcast = groups[name];
+ group_counts[podcast]++;
+ item.PodcastGroupRef = podcast.GroupID;
+ items.Insert (items.IndexOf (podcast) + 1, item);
+ }
+
+ int pos = 1;
+ playlistItems.Clear ();
+ foreach (PlaylistItemRecord item in items) {
+ if (!item.IsPodcastGroup) {
+ item.Position = pos++;
+ } else if (group_counts[item] == 0) {
+ // skip podcast entries that no longer have any episodes
+ continue;
+ }
+
+ item.Save(db, childWriter);
+ playlistItems.Add (item);
+ }
+ } else {
+ // normal playlist; just add all the items
+ foreach (PlaylistItemRecord item in playlistItems) {
+ item.Save(db, childWriter);
+ }
}
+ item_count = playlistItems.Count;
+
childWriter.Flush();
byte[] childData = stream.GetBuffer();
int childDataLength = (int)stream.Length;
@@ -570,8 +671,11 @@
writer.Write(reclen + PadLength);
writer.Write(reclen + PadLength + childDataLength);
writer.Write(stringDetails.Count + otherDetails.Count);
- writer.Write(playlistItems.Count);
- writer.Write(IsHidden ? 1 : 0);
+ writer.Write(item_count);
+ writer.Write(IsHidden ? (byte)1 : (byte)0);
+ writer.Write((byte)0); // three unknown flags
+ writer.Write((byte)0);
+ writer.Write((byte)0);
writer.Write(Timestamp);
writer.Write(Id);
writer.Write(unknownOne);
@@ -580,7 +684,8 @@
if (db.Version >= 13)
{
- writer.Write(IsPodcast ? (short)1 : (short)0);
+ writer.Write(IsPodcast ? (byte)1 : (byte)0);
+ writer.Write((byte)0);
writer.Write((int)Order);
}
@@ -695,6 +800,11 @@
public override void Save(DatabaseRecord db, BinaryWriter writer)
{
+ Save (db, writer, false);
+ }
+
+ public void Save(DatabaseRecord db, BinaryWriter writer, bool podcast_mhsd)
+ {
WriteName(writer);
writer.Write(12 + PadLength);
writer.Write(playlists.Count);
@@ -702,7 +812,7 @@
foreach (PlaylistRecord rec in playlists)
{
- rec.Save(db, writer);
+ rec.Save(db, writer, podcast_mhsd);
}
}
@@ -743,6 +853,7 @@
Category = 9,
Composer = 12,
Grouping = 13,
+ Description = 14,
PodcastUrl = 15,
PodcastUrl2 = 16,
ChapterData = 17,
@@ -771,6 +882,8 @@
{
private static UnicodeEncoding encoding = new UnicodeEncoding(false, false);
+ private static readonly Encoding[] encodings = { Encoding.BigEndianUnicode, Encoding.Unicode, Encoding.UTF8 };
+ private static readonly byte[][] encodingPreambles = { Encoding.BigEndianUnicode.GetPreamble(), Encoding.Unicode.GetPreamble(), Encoding.UTF8.GetPreamble() };
private int unknownOne;
private int unknownTwo;
@@ -840,27 +953,43 @@
Position = ToInt32(body, 12);
int strlen = 0;
- //int strenc = 0;
+ int strenc = 0;
if ((int)Type < 50 || (int)Type >= 200)
{
// 'string' mhods
strlen = ToInt32(body, 16);
- //strenc = ToInt32 (body, 20); // 0 == UTF16, 1 == UTF8
+ strenc = ToInt32(body, 20); // 0 or 1: UTF16, 2: UTF8
unknownThree = ToInt32(body, 24);
}
- // the strenc field is not what it was thought to be
- // latest DBs have the field set to 1 even when the encoding
- // is UTF-16. For now I'm just encoding as UTF-16
- if (strlen >= 2 && body[29] == '\0')
+ Encoding mhodEncoding = (strenc == 2) ? Encoding.UTF8 : Encoding.Unicode;
+
+ // check for BOM to override encoding (is this the correct behavior?)
+ for (int i = 0; i < encodings.Length; ++i)
{
- Value = encoding.GetString(body, 28, strlen);
- }
- else
- {
- Value = Encoding.UTF8.GetString(body, 28, strlen);
+ if (strlen >= encodingPreambles[i].Length)
+ {
+ bool preambleFound = true;
+
+ for (int j = 0; j < encodingPreambles[i].Length; ++j)
+ {
+ if (body[28 + j] != encodingPreambles[i][j])
+ {
+ preambleFound = false;
+ break;
+ }
+ }
+
+ if (preambleFound)
+ {
+ mhodEncoding = encodings[i];
+ break;
+ }
+ }
}
+
+ Value = mhodEncoding.GetString(body, 28, strlen);
}
}
else if (Type == DetailType.LibraryIndex ||
@@ -889,11 +1018,17 @@
{
Position = ToInt32(body, 12);
}
+
+ if (DEBUG) {
+ if (Type == DetailType.Misc)
+ Console.WriteLine (" mhod (misc, pos {0})", Position);
+ else
+ Console.WriteLine (" mhod ({1}, val {0})", Value, Type);
+ }
}
public override void Save(DatabaseRecord db, BinaryWriter writer)
{
-
if (Value == null)
Value = String.Empty;
@@ -1198,7 +1333,6 @@
public override void Save(DatabaseRecord db, BinaryWriter writer)
{
-
MemoryStream stream = new MemoryStream();
BinaryWriter childWriter = new EndianBinaryWriter(stream, IsBE);
@@ -1645,7 +1779,7 @@
Unknown = -1,
Library = 1,
Playlist = 2,
- PlaylistDuplicate = 3,
+ Podcast = 3,
AlbumList = 4,
PlaylistDuplicateDuplicate = 5
}
@@ -1700,6 +1834,7 @@
byte[] body = reader.ReadBytes(this.HeaderOne - 12);
Index = (DataSetIndex)ToInt32(body, 0);
+ if (DEBUG) Console.WriteLine (" mhsd {0}", Index);
switch (Index)
{
@@ -1708,8 +1843,8 @@
this.TrackList.Read(db, reader);
break;
case DataSetIndex.Playlist:
- case DataSetIndex.PlaylistDuplicate:
case DataSetIndex.PlaylistDuplicateDuplicate:
+ case DataSetIndex.Podcast:
this.PlaylistList = new PlaylistListRecord(IsBE);
this.PlaylistList.Read(db, reader);
break;
@@ -1737,10 +1872,15 @@
TrackList.Save(db, childWriter);
break;
case DataSetIndex.Playlist:
- case DataSetIndex.PlaylistDuplicate:
case DataSetIndex.PlaylistDuplicateDuplicate:
PlaylistList.Save(db, childWriter);
break;
+ case DataSetIndex.Podcast:
+ // Write out the same playlists as the normal playlist dataset,
+ // except write the podcast playlist in a modified way (grouped by
+ // album/podcast)
+ db[DataSetIndex.Playlist].PlaylistList.Save (db, childWriter, true);
+ break;
case DataSetIndex.AlbumList:
AlbumList.Save(db, childWriter);
break;
@@ -1781,6 +1921,8 @@
public long Id;
public byte[] Hash = new byte[20];
+ public Device Device;
+
public DataSetRecord this[DataSetIndex index]
{
get
@@ -1795,13 +1937,13 @@
}
}
- public DatabaseRecord(bool isbe)
+ public DatabaseRecord(Device device, bool isbe)
: base(isbe)
{
+ this.Device = device;
datasets.Add(new DataSetRecord(DataSetIndex.Library, isbe));
-
- DataSetRecord plrec = new DataSetRecord(DataSetIndex.Playlist, isbe);
- datasets.Add(plrec);
+ datasets.Add(new DataSetRecord(DataSetIndex.Podcast, isbe));
+ datasets.Add(new DataSetRecord(DataSetIndex.Playlist, isbe));
this.Name = "mhbd";
}
@@ -1837,14 +1979,27 @@
DataSetRecord rec = new DataSetRecord(IsBE);
rec.Read(this, reader);
- if (rec.Index != DataSetIndex.PlaylistDuplicate &&
- rec.Index != DataSetIndex.PlaylistDuplicateDuplicate &&
+ if (rec.Index != DataSetIndex.PlaylistDuplicateDuplicate &&
rec.Index != DataSetIndex.AlbumList) {
datasets.Add(rec);
}
}
+
+ if (this[DataSetIndex.Podcast] == null) {
+ datasets.Add (new DataSetRecord(DataSetIndex.Podcast, IsBE));
+ }
+
+ datasets.Sort ((a, b) => {
+ return Array.IndexOf (data_set_order, a.Index) - Array.IndexOf (data_set_order, b.Index);
+ });
}
+ // Podcast comes before Playlist, even though its enum-int val is higher
+ private static DataSetIndex [] data_set_order = new DataSetIndex [] {
+ DataSetIndex.Library, DataSetIndex.Podcast, DataSetIndex.Playlist,
+ DataSetIndex.AlbumList, DataSetIndex.PlaylistDuplicateDuplicate
+ };
+
private void ReassignTrackIds()
{
Hashtable oldids = new Hashtable();
@@ -1879,9 +2034,14 @@
MemoryStream stream = new MemoryStream();
BinaryWriter childWriter = new EndianBinaryWriter(stream, IsBE);
- foreach (DataSetRecord rec in datasets)
- {
- rec.Save(db, childWriter);
+ int datasets_count = datasets.Count;
+ bool supports_podcasts = Device.ModelInfo.HasCapability ("podcast");
+ foreach (DataSetRecord rec in datasets) {
+ if (rec.Index == DataSetIndex.Podcast && !supports_podcasts) {
+ datasets_count--;
+ } else {
+ rec.Save(db, childWriter);
+ }
}
childWriter.Flush();
@@ -1900,7 +2060,7 @@
writer.Write(unknownOne);
writer.Write(Version);
- writer.Write(datasets.Count);
+ writer.Write(datasets_count);
writer.Write(Id);
writer.Write(unknownTwo);
writer.Write(unknownThree);
@@ -2029,7 +2189,6 @@
public class TrackDatabase
{
-
private const int CopyBufferSize = 8192;
private const double PercentThreshold = 0.10;
@@ -2040,6 +2199,7 @@
private List<Track> tracksToRemove = new List<Track>();
private List<Playlist> playlists = new List<Playlist>();
+ private Playlist podcast_playlist;
private List<Playlist> otgPlaylists = new List<Playlist>();
private Random random = new Random();
@@ -2143,16 +2303,18 @@
}
}
- public int Version
- {
+ public int Version {
get { return dbrec.Version; }
}
- internal PhotoDatabase ArtworkDatabase
- {
+ internal PhotoDatabase ArtworkDatabase {
get { return artdb; }
}
+ internal Playlist Podcasts {
+ get { return podcast_playlist; }
+ }
+
internal TrackDatabase(Device device)
: this(device, false)
{
@@ -2175,7 +2337,6 @@
}
}
-
private void Clear()
{
dbrec = null;
@@ -2183,6 +2344,7 @@
tracksToAdd.Clear();
tracksToRemove.Clear();
playlists.Clear();
+ podcast_playlist = null;
otgPlaylists.Clear();
}
@@ -2195,7 +2357,6 @@
using (BinaryReader reader = new BinaryReader(File.OpenRead(PlayCountsPath)))
{
-
byte[] header = reader.ReadBytes(96);
int entryLength = dbrec.ToInt32(header, 8);
int numEntries = dbrec.ToInt32(header, 12);
@@ -2298,7 +2459,6 @@
private void Reload(bool createFresh)
{
-
Clear();
// This blows, we need to use the device model number or something
@@ -2308,42 +2468,65 @@
if (!File.Exists(TrackDbPath) || createFresh)
{
Console.WriteLine ("Creating fresh track db: " + TrackDbPath);
- dbrec = new DatabaseRecord(useBE);
+ dbrec = new DatabaseRecord(device, useBE);
+
LoadOnTheGo();
+ CreatePodcastPlaylist ();
return;
}
- using (BinaryReader reader = new BinaryReader(File.OpenRead(TrackDbPath)))
- {
+ dbrec = new DatabaseRecord(device, useBE);
- dbrec = new DatabaseRecord(useBE);
+ using (BinaryReader reader = new BinaryReader(File.OpenRead(TrackDbPath))) {
dbrec.Read(null, reader);
+ }
- // Load the tracks
- foreach (TrackRecord track in dbrec[DataSetIndex.Library].TrackList)
- {
- Track t = new Track(this, track);
- tracks.Add(t);
- }
+ // Load the tracks
+ foreach (TrackRecord track in dbrec[DataSetIndex.Library].TrackList)
+ {
+ Track t = new Track(this, track);
+ tracks.Add(t);
+ }
- // Load the play counts
- LoadPlayCounts();
+ // Load the play counts
+ LoadPlayCounts();
- // Load the playlists
- foreach (PlaylistRecord listrec in dbrec[DataSetIndex.Playlist].PlaylistList)
- {
- if (listrec.IsHidden)
- continue;
+ // Load the playlists
+ foreach (PlaylistRecord listrec in dbrec[DataSetIndex.Playlist].PlaylistList)
+ {
+ if (listrec.IsHidden)
+ continue;
- Playlist list = new Playlist(this, listrec);
+ Playlist list = new Playlist(this, listrec);
+
+ if (listrec.IsPodcast)
+ podcast_playlist = list;
+ else
playlists.Add(list);
- }
+ }
- // Load the On-The-Go playlist
- LoadOnTheGo();
+ CreatePodcastPlaylist ();
- if (Reloaded != null)
- Reloaded(this, new EventArgs());
+ // Load the On-The-Go playlist
+ LoadOnTheGo();
+
+ if (Reloaded != null)
+ Reloaded(this, new EventArgs());
+ }
+
+ private void CreatePodcastPlaylist ()
+ {
+ if (podcast_playlist == null && device.ModelInfo.HasCapability ("podcast")) {
+ var record = new PlaylistRecord (false, dbrec.IsBE) {
+ IsLibrary = false,
+ IsHidden = false,
+ IsPodcast = true,
+ PlaylistName = "Podcasts",
+ Order = SortOrder.ReleaseDate
+ };
+
+ podcast_playlist = new Playlist (this, record);
+ dbrec[DataSetIndex.Playlist].PlaylistList.AddPlaylist (record);
}
}
@@ -2744,6 +2927,10 @@
list.RemoveTrack(track);
}
+ if (podcast_playlist != null) {
+ podcast_playlist.RemoveTrack (track);
+ }
+
// remove from On-The-Go playlists
foreach (Playlist list in otgPlaylists)
{
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org