From: <jc...@us...> - 2006-03-29 13:54:57
|
Update of /cvsroot/gtkpod/libgpod/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17839/src Modified Files: itdb.h itdb_itunesdb.c Log Message: * itunesdb.c: set filetype identifier when transfering track to the iPod. Index: itdb.h =================================================================== RCS file: /cvsroot/gtkpod/libgpod/src/itdb.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- itdb.h 23 Mar 2006 15:06:32 -0000 1.30 +++ itdb.h 29 Mar 2006 13:54:43 -0000 1.31 @@ -1,4 +1,4 @@ -/* Time-stamp: <2006-03-23 23:30:34 jcs> +/* Time-stamp: <2006-03-24 00:38:39 jcs> | | Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net> | Part of the gtkpod project. @@ -585,15 +585,16 @@ guint32 visible; /* If this value is 1, the song is visible on the iPod. All other values cause the file to be hidden. */ - gchar filetype_marker[4]; /* This appears to always be 0 on hard + guint32 filetype_marker; /* This appears to always be 0 on hard drive based iPods, but for the iTunesDB that is written to an iPod Shuffle, iTunes 4.7.1 writes out the file's type as an ANSI string(!). For example, a MP3 file has a filetype of 0x4d503320 -> 0x4d = 'M', 0x50 = 'P', - 0x33 = '3', 0x20 = <space>. (always - left set to 0 by itdb)*/ + 0x33 = '3', 0x20 = <space>. (set to + the filename extension by itdb when + copying track to iPod)*/ guint16 artwork_count; /* The number of album artwork items associated with this song. libgpod updates this value when syncing */ Index: itdb_itunesdb.c =================================================================== RCS file: /cvsroot/gtkpod/libgpod/src/itdb_itunesdb.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- itdb_itunesdb.c 23 Mar 2006 15:06:32 -0000 1.52 +++ itdb_itunesdb.c 29 Mar 2006 13:54:43 -0000 1.53 @@ -1,4 +1,4 @@ -/* Time-stamp: <2006-03-23 23:30:35 jcs> +/* Time-stamp: <2006-03-24 00:40:16 jcs> | | Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net> | Part of the gtkpod project. @@ -2013,7 +2013,7 @@ guint32 val32; track->id = get32lint(cts, seek+16); /* iPod ID */ track->visible = get32lint (cts, seek+20); - seek_get_n_bytes (cts, track->filetype_marker, seek+24, 4); + track->filetype_marker = get32lint (cts, seek+24); track->type1 = get8int (cts, seek+28); track->type2 = get8int (cts, seek+29); track->compilation = get8int (cts, seek+30); @@ -3183,7 +3183,7 @@ put32lint (cts, track->id); /* track index number */ put32lint (cts, track->visible); - put_data (cts, track->filetype_marker, 4); + put32lint (cts, track->filetype_marker); put8int (cts, track->type1); put8int (cts, track->type2); put8int (cts, track->compilation); @@ -4683,7 +4683,7 @@ If @track->transferred is set to TRUE, nothing is done. Upon successful transfer @track->transferred is set to TRUE. - For storage, the directories "f00 ... f19" will be + For storage, the directories "f00 ... fnn" will be cycled through. The filename is constructed as "gtkpod"<random number> and copied @@ -4692,7 +4692,10 @@ If @track->ipod_path is already set, this one will be used instead. If a file with this name already exists, it will be - overwritten. */ + overwritten. + + @track->filetype_marker is set according to the filename extension + */ gboolean itdb_cp_track_to_ipod (Itdb_Track *track, gchar *filename, GError **error) { @@ -4700,6 +4703,7 @@ gchar *track_db_path, *ipod_fullfile; gboolean success; gint mplen = 0; + gint i; const gchar *mountpoint; Itdb_iTunesDB *itdb; @@ -4779,6 +4783,16 @@ string. Note: the iPod will most certainly ignore this file... */ if (!original_suffix) original_suffix = ""; + /* set filetype from the suffix, e.g. '.mp3' -> 'MP3 ' */ + track->filetype_marker = 0; + for (i=1; i<=4; ++i) /* start with i=1 to skip the '.' */ + { + track->filetype_marker = track->filetype_marker << 8; + if (strlen (original_suffix) > i) + track->filetype_marker |= g_ascii_toupper (original_suffix[i]); + else + track->filetype_marker |= g_ascii_toupper (' '); + } do { /* we need to loop until we find an unused filename */ dest_components[1] = |