upnpsoap: Add additonal bookmark support

Add support for upnp:playbackCount and upnp:lastPlaybackPosition tags.
These are used by Kodi to keep track of bookmark information as well as
determining whether to show the checkmark to indicate that the video
has been played.

Also add support for the UpdateObject command, which Kodi uses to
update the playbackCount and lastPlaybackPosition information.

This change requires a DB schema update, which should be done
automatically on the first run.

Inspired by SF user Karsten's patch #167.
This commit is contained in:
Justin Maggard
2017-05-17 12:01:04 -07:00
parent 2b3bdb8373
commit 4f926639b2
9 changed files with 286 additions and 100 deletions

30
sql.c
View File

@ -1,5 +1,5 @@
/* MiniDLNA media server
* Copyright (C) 2008-2009 Justin Maggard
* Copyright (C) 2008-2017 Justin Maggard
*
* This file is part of MiniDLNA.
*
@ -93,10 +93,10 @@ sql_get_int_field(sqlite3 *db, const char *fmt, ...)
for (counter = 0;
((result = sqlite3_step(stmt)) == SQLITE_BUSY || result == SQLITE_LOCKED) && counter < 2;
counter++) {
/* While SQLITE_BUSY has a built in timeout,
SQLITE_LOCKED does not, so sleep */
if (result == SQLITE_LOCKED)
sleep(1);
/* While SQLITE_BUSY has a built in timeout,
* SQLITE_LOCKED does not, so sleep */
if (result == SQLITE_LOCKED)
sleep(1);
}
switch (result)
@ -117,7 +117,7 @@ sql_get_int_field(sqlite3 *db, const char *fmt, ...)
DPRINTF(E_WARN, L_DB_SQL, "%s: step failed: %s\n%s\n", __func__, sqlite3_errmsg(db), sql);
ret = -1;
break;
}
}
sqlite3_free(sql);
sqlite3_finalize(stmt);
@ -152,10 +152,10 @@ sql_get_int64_field(sqlite3 *db, const char *fmt, ...)
for (counter = 0;
((result = sqlite3_step(stmt)) == SQLITE_BUSY || result == SQLITE_LOCKED) && counter < 2;
counter++) {
/* While SQLITE_BUSY has a built in timeout,
SQLITE_LOCKED does not, so sleep */
if (result == SQLITE_LOCKED)
sleep(1);
/* While SQLITE_BUSY has a built in timeout,
* SQLITE_LOCKED does not, so sleep */
if (result == SQLITE_LOCKED)
sleep(1);
}
switch (result)
@ -176,7 +176,7 @@ sql_get_int64_field(sqlite3 *db, const char *fmt, ...)
DPRINTF(E_WARN, L_DB_SQL, "%s: step failed: %s\n%s\n", __func__, sqlite3_errmsg(db), sql);
ret = -1;
break;
}
}
sqlite3_free(sql);
sqlite3_finalize(stmt);
@ -263,6 +263,7 @@ int
db_upgrade(sqlite3 *db)
{
int db_vers;
int ret;
db_vers = sql_get_int_field(db, "PRAGMA user_version");
@ -274,6 +275,13 @@ db_upgrade(sqlite3 *db)
return -1;
if (db_vers < 9)
return db_vers;
if (db_vers < 10)
{
DPRINTF(E_WARN, L_DB_SQL, "Updating DB version to v%d\n", 10);
ret = sql_exec(db, "ALTER TABLE BOOKMARKS ADD WATCH_COUNT INTEGER");
if (ret != SQLITE_OK)
return 9;
}
sql_exec(db, "PRAGMA user_version = %d", DB_VERSION);
return 0;