binding: media: free sqlite3 prepared query statement
[apps/mediaplayer.git] / binding / mediaplayer-manager.c
index c14f0a4..ca46587 100644 (file)
@@ -83,6 +83,30 @@ void DebugTraceSendMsg(int level, gchar* message)
 
 }
 
+GList* media_local_scan(GList *list)
+{
+    gchar *path = g_strconcat(g_get_home_dir(), "/", "Music", NULL);
+    gchar *tmp = NULL;
+    GDir *dir;
+
+    dir = g_dir_open(path, 0, NULL);
+    if (dir == NULL)
+    {
+        LOGE("Cannot open media path %s\n", path);
+        return list;
+    }
+
+    while ((tmp = (gchar *) g_dir_read_name(dir)) != NULL)
+    {
+        list = g_list_append(list, g_strdup_printf("file://%s/%s", path, tmp));
+    }
+
+    g_free(path);
+    g_dir_close(dir);
+
+    return list;
+}
+
 GList* media_lightmediascanner_scan(void)
 {
     sqlite3 *conn;
@@ -117,6 +141,8 @@ GList* media_lightmediascanner_scan(void)
         list = g_list_append(list, g_strdup_printf("file://%s", path));
     }
 
+    sqlite3_finalize(res);
+
     return list;
 }
 
@@ -159,6 +185,8 @@ on_interface_proxy_properties_changed (GDBusProxy *proxy,
     if (list != NULL && g_RegisterCallback.binding_device_added)
         g_RegisterCallback.binding_device_added(list);
 
+    g_list_free_full(list, g_free);
+
     ListUnlock();
 }