aboutsummaryrefslogtreecommitdiffstats
path: root/binding/media-manager.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-10-09 13:40:30 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-10-09 18:29:54 -0700
commitcc0456ed42fe31edc081606d1c1c39d0703a6c05 (patch)
treeb69c52af899b35ba75fb2d096e68028c70142994 /binding/media-manager.c
parent1fe7b9363da7f5cac0641b7ecea249fdcca23970 (diff)
binding: mediascanner: report only playlist for media inserted
Only generate an media_added event with the playlist of the media inserted. Bug-AGL: SPEC-934 Change-Id: I4e0897fbf06651f0d85c7dd5145edc7c898c68bf Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/media-manager.c')
-rw-r--r--binding/media-manager.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/binding/media-manager.c b/binding/media-manager.c
index 5fee748..63dd4ff 100644
--- a/binding/media-manager.c
+++ b/binding/media-manager.c
@@ -109,13 +109,14 @@ GList* media_local_scan(GList *list)
return list;
}
-GList* media_lightmediascanner_scan(void)
+GList* media_lightmediascanner_scan(gchar *uri)
{
sqlite3 *conn;
sqlite3_stmt *res;
GList *list = NULL;
const char *tail;
const gchar *db_path;
+ gchar *query;
int ret = 0;
db_path = scanner1_get_data_base_path(MediaPlayerManage.lms_proxy);
@@ -126,9 +127,16 @@ GList* media_lightmediascanner_scan(void)
return NULL;
}
- ret = sqlite3_prepare_v2(conn, SQL_QUERY, strlen(SQL_QUERY) + 1, &res, &tail);
+ query = g_strdup_printf(SQL_QUERY, uri ? uri : "");
+ if (!query) {
+ LOGE("Cannot allocate memory for query\n");
+ return NULL;
+ }
+
+ ret = sqlite3_prepare_v2(conn, query, strlen(query), &res, &tail);
if (ret) {
- LOGE("Cannot execute query '%s'\n", SQL_QUERY);
+ LOGE("Cannot execute query '%s'\n", query);
+ g_free(query);
return NULL;
}
@@ -151,6 +159,8 @@ GList* media_lightmediascanner_scan(void)
list = g_list_append(list, item);
}
+ g_free(query);
+
return list;
}
@@ -199,7 +209,10 @@ on_interface_proxy_properties_changed (GDBusProxy *proxy,
ListLock();
- list = media_lightmediascanner_scan();
+ list = media_lightmediascanner_scan(MediaPlayerManage.uri_filter);
+
+ g_free(MediaPlayerManage.uri_filter);
+ MediaPlayerManage.uri_filter = NULL;
if (list != NULL && g_RegisterCallback.binding_device_added)
g_RegisterCallback.binding_device_added(list);
@@ -255,17 +268,21 @@ unmount_cb (GFileMonitor *mon,
{
gchar *path = g_file_get_path(file);
gchar *uri = g_strconcat("file://", path, NULL);
- g_free(path);
ListLock();
if (g_RegisterCallback.binding_device_removed &&
event == G_FILE_MONITOR_EVENT_DELETED) {
- g_RegisterCallback.binding_device_removed(uri);
+ g_RegisterCallback.binding_device_removed(uri);
+ g_free(path);
+ } else if (event == G_FILE_MONITOR_EVENT_CREATED) {
+ MediaPlayerManage.uri_filter = path;
+ } else {
+ g_free(path);
}
- ListUnlock();
g_free(uri);
+ ListUnlock();
}
/*