commit fce84f9d23a8e6a9cd153c4b41f348e240507d1d Author: Christophe Fergeau <cferg...@mandriva.com> Date: Wed Jun 16 14:42:49 2010 +0200
get ShadowDB version from SysInfoExtended when possible src/itdb_device.c | 56 ++++++++++++++++++++++++++++++++++++ src/itdb_device.h | 1 + src/itdb_itunesdb.c | 16 +--------- src/itdb_private.h | 6 ++++ src/itdb_sysinfo_extended_parser.c | 9 ++++++ src/itdb_sysinfo_extended_parser.h | 2 + 6 files changed, 75 insertions(+), 15 deletions(-) --- diff --git a/src/itdb_device.c b/src/itdb_device.c index 15d3a78..1eafb0b 100644 --- a/src/itdb_device.c +++ b/src/itdb_device.c @@ -2162,3 +2162,59 @@ gboolean itdb_device_is_iphone_family (const Itdb_Device *device) g_return_val_if_reached (FALSE); } } + +enum ItdbShadowDBVersion itdb_device_get_shadowdb_version (const Itdb_Device *device) +{ + int version; + + version = 0; + if (device->sysinfo_extended != NULL) { + version = itdb_sysinfo_properties_get_shadow_db_version (device->sysinfo_extended); + } + + if (version == 0) { + const Itdb_IpodInfo *info; + + info = itdb_device_get_ipod_info (device); + switch (info->ipod_generation) { + case ITDB_IPOD_GENERATION_UNKNOWN: + case ITDB_IPOD_GENERATION_FIRST: + case ITDB_IPOD_GENERATION_SECOND: + case ITDB_IPOD_GENERATION_THIRD: + case ITDB_IPOD_GENERATION_MOBILE: + case ITDB_IPOD_GENERATION_FOURTH: + case ITDB_IPOD_GENERATION_PHOTO: + case ITDB_IPOD_GENERATION_MINI_1: + case ITDB_IPOD_GENERATION_MINI_2: + case ITDB_IPOD_GENERATION_NANO_1: + case ITDB_IPOD_GENERATION_NANO_2: + case ITDB_IPOD_GENERATION_NANO_3: + case ITDB_IPOD_GENERATION_NANO_4: + case ITDB_IPOD_GENERATION_NANO_5: + case ITDB_IPOD_GENERATION_VIDEO_1: + case ITDB_IPOD_GENERATION_VIDEO_2: + case ITDB_IPOD_GENERATION_CLASSIC_1: + case ITDB_IPOD_GENERATION_CLASSIC_2: + case ITDB_IPOD_GENERATION_CLASSIC_3: + case ITDB_IPOD_GENERATION_TOUCH_1: + case ITDB_IPOD_GENERATION_TOUCH_2: + case ITDB_IPOD_GENERATION_TOUCH_3: + case ITDB_IPOD_GENERATION_IPHONE_1: + case ITDB_IPOD_GENERATION_IPHONE_2: + case ITDB_IPOD_GENERATION_IPHONE_3: + case ITDB_IPOD_GENERATION_IPAD_1: + version = ITDB_SHADOW_DB_UNKNOWN; + break; + case ITDB_IPOD_GENERATION_SHUFFLE_1: + case ITDB_IPOD_GENERATION_SHUFFLE_2: + version = ITDB_SHADOW_DB_V1; + break; + case ITDB_IPOD_GENERATION_SHUFFLE_3: + case ITDB_IPOD_GENERATION_SHUFFLE_4: + version = ITDB_SHADOW_DB_V2; + break; + } + } + + return version; +} diff --git a/src/itdb_device.h b/src/itdb_device.h index 4c86041..a252100 100644 --- a/src/itdb_device.h +++ b/src/itdb_device.h @@ -181,6 +181,7 @@ G_GNUC_INTERNAL void itdb_device_set_timezone_info (Itdb_Device *device); G_GNUC_INTERNAL gboolean itdb_device_is_iphone_family (const Itdb_Device *device); G_GNUC_INTERNAL gboolean itdb_device_is_shuffle (const Itdb_Device *device); G_GNUC_INTERNAL ItdbChecksumType itdb_device_get_checksum_type (const Itdb_Device *device); +G_GNUC_INTERNAL enum ItdbShadowDBVersion itdb_device_get_shadowdb_version (const Itdb_Device *device); const Itdb_IpodInfo * itdb_ipod_info_from_serial (const char *serial); diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c index 0879d9b..2a19ff7 100644 --- a/src/itdb_itunesdb.c +++ b/src/itdb_itunesdb.c @@ -6534,21 +6534,7 @@ static gboolean write_bdhs (FExport *fexp) static gboolean is_shuffle_2g (Itdb_Device *device) { - const Itdb_IpodInfo *shuffle_info; - Itdb_IpodGeneration generation; - - if (!itdb_device_is_shuffle (device)) { - return FALSE; - } - - shuffle_info = itdb_device_get_ipod_info (device); - - if (!shuffle_info) { - return FALSE; - } - generation = shuffle_info->ipod_generation; - return ((generation == ITDB_IPOD_GENERATION_SHUFFLE_1) - || (generation == ITDB_IPOD_GENERATION_SHUFFLE_2)); + return (itdb_device_get_shadowdb_version (device) == ITDB_SHADOW_DB_V1); } /** diff --git a/src/itdb_private.h b/src/itdb_private.h index c584f72..501d07b 100644 --- a/src/itdb_private.h +++ b/src/itdb_private.h @@ -42,6 +42,12 @@ enum ItdbPlType { /* types for playlist->type */ not visible in iPod */ }; +enum ItdbShadowDBVersion { + ITDB_SHADOW_DB_UNKNOWN, + ITDB_SHADOW_DB_V1, + ITDB_SHADOW_DB_V2, +}; + /* always use itdb_playlists_is_podcasts() to check for podcasts PL */ enum ItdbPlFlag { /* types for playlist->podcastflag */ ITDB_PL_FLAG_NORM = 0, /* normal playlist, visible under diff --git a/src/itdb_sysinfo_extended_parser.c b/src/itdb_sysinfo_extended_parser.c index 4516871..a1f5cb2 100644 --- a/src/itdb_sysinfo_extended_parser.c +++ b/src/itdb_sysinfo_extended_parser.c @@ -80,6 +80,7 @@ struct _SysInfoIpodProperties { gint oem_id; gint oem_u; gint db_version; + int shadowdb_version; char *min_build_id; char *language; gboolean voice_memos_supported; @@ -218,6 +219,7 @@ static const DictFieldMapping sysinfo_ipod_properties_fields_mapping[] = { { "GamesPlatformVersion", G_TYPE_INT, G_STRUCT_OFFSET (SysInfoIpodProperties, games_platform_version) }, { "RentalClockBias", G_TYPE_INT, G_STRUCT_OFFSET (SysInfoIpodProperties, rental_clock_bias) }, { "SQLiteDB", G_TYPE_BOOLEAN, G_STRUCT_OFFSET (SysInfoIpodProperties, sqlite_db) }, + { "ShadowDBVersion", G_TYPE_INT, G_STRUCT_OFFSET (SysInfoIpodProperties, shadowdb_version) }, { NULL, G_TYPE_NONE, 0 } }; @@ -712,3 +714,10 @@ itdb_sysinfo_properties_get_db_version (const SysInfoIpodProperties *props) g_return_val_if_fail (props != NULL, FALSE); return props->db_version; } + +gint +itdb_sysinfo_properties_get_shadow_db_version (const SysInfoIpodProperties *props) +{ + g_return_val_if_fail (props != NULL, 0); + return props->shadowdb_version; +} diff --git a/src/itdb_sysinfo_extended_parser.h b/src/itdb_sysinfo_extended_parser.h index 046e1f9..5ac3bae 100644 --- a/src/itdb_sysinfo_extended_parser.h +++ b/src/itdb_sysinfo_extended_parser.h @@ -72,6 +72,8 @@ G_GNUC_INTERNAL gint itdb_sysinfo_properties_get_family_id (const SysInfoIpodProperties *props); G_GNUC_INTERNAL gint itdb_sysinfo_properties_get_db_version (const SysInfoIpodProperties *props); +G_GNUC_INTERNAL gint +itdb_sysinfo_properties_get_shadow_db_version (const SysInfoIpodProperties *props); G_END_DECLS ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ gtkpod-cvs2 mailing list gtkpod-cvs2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2