commit 25d79c5d85e54264130182c7a1c03693a2da3a51
Author: Nikias Bassen <[email protected]>
Date: Sun Dec 6 17:50:38 2009 +0100
Dynamic.itdb: support for fw 3.1 changes
src/itdb_sqlite.c | 66 ++++++++++++++++++++++++++++++++++++++-------
src/itdb_sqlite_queries.h | 6 ++--
2 files changed, 59 insertions(+), 13 deletions(-)
---
diff --git a/src/itdb_sqlite.c b/src/itdb_sqlite.c
index 12261fa..393799e 100644
--- a/src/itdb_sqlite.c
+++ b/src/itdb_sqlite.c
@@ -59,6 +59,7 @@ static int mk_Dynamic(Itdb_iTunesDB *itdb, const char
*outpath)
char *errmsg = NULL;
struct stat fst;
int idx = 0;
+ GList *gl = NULL;
dbf = g_build_filename(outpath, "Dynamic.itdb", NULL);
printf("[%s] Processing '%s'\n", __func__, dbf);
@@ -99,12 +100,9 @@ static int mk_Dynamic(Itdb_iTunesDB *itdb, const char
*outpath)
sqlite3_exec(db, "BEGIN;", NULL, NULL, NULL);
if (itdb->tracks) {
- GList *gl = NULL;
-
printf("[%s] - processing %d tracks\n", __func__,
g_list_length(itdb->tracks));
- if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item_stats\"
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt, NULL)) {
+ if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item_stats\"
(item_pid,has_been_played,date_played,play_count_user,play_count_recent,date_skipped,skip_count_user,skip_count_recent,bookmark_time_ms,bookmark_time_ms_common,user_rating,user_rating_common)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt, NULL)) {
fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__,
sqlite3_errmsg(db));
- printf("[%s] -- inserting into \"item_stats\"\n", __func__);
goto leave;
}
for (gl=itdb->tracks; gl; gl=gl->next) {
@@ -143,12 +141,6 @@ static int mk_Dynamic(Itdb_iTunesDB *itdb, const char
*outpath)
/* user_rating_common */
/* FIXME: don't know if this is the right value */
sqlite3_bind_int(stmt, ++idx, track->app_rating);
- /* hidden */
- sqlite3_bind_int(stmt, ++idx, 0);
- /* deleted */
- sqlite3_bind_int(stmt, ++idx, 0);
- /* has_changes */
- sqlite3_bind_int(stmt, ++idx, 0);
res = sqlite3_step(stmt);
if (res == SQLITE_DONE) {
@@ -165,8 +157,62 @@ static int mk_Dynamic(Itdb_iTunesDB *itdb, const char
*outpath)
printf("[%s] - No tracks available, none written.\n", __func__);
}
+ /* add playlist info to container_ui */
+ if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"container_ui\"
VALUES(?,?,?,?,?,?,?);", -1, &stmt, NULL)) {
+ fprintf(stderr, "[%s] 2 sqlite3_prepare error: %s\n", __func__,
sqlite3_errmsg(db));
+ goto leave;
+ }
+
+ printf("[%s] - processing %d playlists\n", __func__,
g_list_length(itdb->playlists));
+ for (gl = itdb->playlists; gl; gl = gl->next) {
+ Itdb_Playlist *pl = (Itdb_Playlist*)gl->data;
+
+ res = sqlite3_reset(stmt);
+ if (res != SQLITE_OK) {
+ fprintf(stderr, "[%s] 2 sqlite3_reset returned %d\n", __func__,
res);
+ }
+ idx = 0;
+ /* container_pid */
+ sqlite3_bind_int64(stmt, ++idx, pl->id);
+ /* play_order TODO: where does this value come from? */
+ /* FIXME: 5 --> 7, 24 --> 39 ??!? */
+ switch (pl->sortorder) {
+ case 5:
+ sqlite3_bind_int(stmt, ++idx, 7);
+ break;
+ case 24:
+ sqlite3_bind_int(stmt, ++idx, 39);
+ break;
+ default:
+ sqlite3_bind_int(stmt, ++idx, 7);
+ break;
+ }
+ /* is_reversed TODO where does this value come from? */
+ sqlite3_bind_int(stmt, ++idx, 0);
+ /* album_field_order TODO where does this value come from? */
+ sqlite3_bind_int(stmt, ++idx, 1);
+ /* repeat_mode TODO where does this value come from? */
+ sqlite3_bind_int(stmt, ++idx, 0);
+ /* shuffle_items TODO where does this value come from? */
+ sqlite3_bind_int(stmt, ++idx, 0);
+ /* has_been_shuffled TODO where does this value come from? */
+ sqlite3_bind_int(stmt, ++idx, 0);
+
+ res = sqlite3_step(stmt);
+ if (res == SQLITE_DONE) {
+ /* expected result */
+ } else {
+ fprintf(stderr, "[%s] 2 sqlite3_step returned %d\n", __func__, res);
+ }
+ }
+
sqlite3_exec(db, "COMMIT;", NULL, NULL, NULL);
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ }
+
res = 0;
printf("[%s] done.\n", __func__);
leave:
diff --git a/src/itdb_sqlite_queries.h b/src/itdb_sqlite_queries.h
index fc26029..616ad64 100644
--- a/src/itdb_sqlite_queries.h
+++ b/src/itdb_sqlite_queries.h
@@ -22,9 +22,9 @@
/** creation statement for 'Dynamic.itdb' */
static const char Dynamic_create[] =
"BEGIN TRANSACTION;" \
- "CREATE TABLE item_stats (item_pid INTEGER NOT NULL, has_been_played
INTEGER DEFAULT 0, date_played INTEGER DEFAULT 0, play_count_user INTEGER
DEFAULT 0, play_count_recent INTEGER DEFAULT 0, date_skipped INTEGER DEFAULT 0,
skip_count_user INTEGER DEFAULT 0, skip_count_recent INTEGER DEFAULT 0,
bookmark_time_ms REAL, bookmark_time_ms_common REAL, user_rating INTEGER
DEFAULT 0, user_rating_common INTEGER DEFAULT 0, hidden INTEGER DEFAULT 0,
deleted INTEGER DEFAULT 0, has_changes INTEGER DEFAULT 0, PRIMARY KEY
(item_pid));" \
- "CREATE TABLE rental_info (rental_date_started INTEGER DEFAULT 0,
rental_duration INTEGER DEFAULT 0, rental_playback_date_started INTEGER DEFAULT
0, rental_playback_duration INTEGER DEFAULT 0);" \
- "ANALYZE sqlite_master;" \
+ "CREATE TABLE item_stats (item_pid INTEGER NOT NULL, has_been_played
INTEGER DEFAULT 0, date_played INTEGER DEFAULT 0, play_count_user INTEGER
DEFAULT 0, play_count_recent INTEGER DEFAULT 0, date_skipped INTEGER DEFAULT 0,
skip_count_user INTEGER DEFAULT 0, skip_count_recent INTEGER DEFAULT 0,
bookmark_time_ms REAL, bookmark_time_ms_common REAL, user_rating INTEGER
DEFAULT 0, user_rating_common INTEGER DEFAULT 0, rental_expired INTEGER DEFAULT
0, hidden INTEGER DEFAULT 0, deleted INTEGER DEFAULT 0, has_changes INTEGER
DEFAULT 0, PRIMARY KEY (item_pid));" \
+ "CREATE TABLE container_ui (container_pid INTEGER NOT NULL, play_order
INTEGER DEFAULT 0, is_reversed INTEGER DEFAULT 0, album_field_order INTEGER
DEFAULT 0, repeat_mode INTEGER DEFAULT 0, shuffle_items INTEGER DEFAULT 0,
has_been_shuffled INTEGER DEFAULT 0, PRIMARY KEY (container_pid));" \
+ "CREATE TABLE rental_info (item_pid INTEGER NOT NULL,
rental_date_started INTEGER DEFAULT 0, rental_duration INTEGER DEFAULT 0,
rental_playback_date_started INTEGER DEFAULT 0, rental_playback_duration
INTEGER DEFAULT 0, is_demo INTEGER DEFAULT 0, PRIMARY KEY (item_pid));" \
"COMMIT;";
/** creation statement for 'Extras.itdb' */
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2