Default bookmark name is empty string. even though user set name to NULL, get_name... 31/123331/1
authorHaejeong Kim <backto.kim@samsung.com>
Wed, 5 Apr 2017 07:58:12 +0000 (16:58 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Wed, 5 Apr 2017 07:58:12 +0000 (16:58 +0900)
Change-Id: Ifa613ed9a8fe6a173a2bf8c63a8ff43a248bd743

include/media_info_private.h
src/media_bookmark.c

index ddc4e08..ab405d1 100755 (executable)
@@ -66,6 +66,7 @@ extern "C" {
 
 #define MEDIA_CONTENT_THUMB_DEFAULT_PATH               tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/thumb_default.png")
 #define MEDIA_CONTENT_INSERT_FILES_PATH                "/tmp"
+#define MEDIA_CONTENT_EMPTY_STRING                     ""
 
 #define MAX_QUERY_SIZE 4096
 #define DEFAULT_QUERY_SIZE 1024
@@ -613,7 +614,7 @@ typedef struct _media_content_cb_data {
 #define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP                "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d;"
 
 /* Bookmark */
-#define INSERT_BOOKMARK_TO_BOOKMARK                    "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path) VALUES ('%q', '%d', %Q)"
+#define INSERT_BOOKMARK_TO_BOOKMARK                    "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path, name) VALUES ('%q', '%d', %Q, %Q)"
 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID              "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID                       "SELECT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path, b.name FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
 #define UPDATE_BOOKMARK_FROM_BOOKMARK          "UPDATE "DB_TABLE_BOOKMARK" SET name=%Q WHERE bookmark_id=%d;"
index 4aef252..a245784 100755 (executable)
@@ -25,7 +25,7 @@ int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *t
        char *sql = NULL;
 
        if (STRING_VALID(media_id)) {
-               sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path);
+               sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path, MEDIA_CONTENT_EMPTY_STRING);
                ret = _content_query_sql(sql);
                SQLITE3_SAFE_FREE(sql);
        } else {
@@ -198,14 +198,8 @@ int media_bookmark_get_name(media_bookmark_h bookmark, char **name)
        media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
 
        if (_bookmark) {
-               if (STRING_VALID(_bookmark->name)) {
-                       *name = strdup(_bookmark->name);
-                       media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *name = NULL;
-               }
-
-               ret = MEDIA_CONTENT_ERROR_NONE;
+               *name = g_strdup(_bookmark->name);
+               media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
        } else {
                media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
                ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
@@ -220,10 +214,10 @@ int media_bookmark_set_name(media_bookmark_h bookmark, const char *name)
        media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
 
        if (STRING_VALID(name)) {
-               _bookmark->name = strdup(name);
+               _bookmark->name = g_strdup(name);
                media_content_retvm_if(_bookmark->name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
        } else {
-               _bookmark->name = NULL;
+               _bookmark->name = g_strdup(MEDIA_CONTENT_EMPTY_STRING);
        }
 
        return ret;