Add function to support new API on media-content. 05/41405/1
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 15 Jun 2015 06:31:38 +0000 (15:31 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 15 Jun 2015 06:31:38 +0000 (15:31 +0900)
Change-Id: I1fbd23e9a687413f7c433f1f960e9804032fcdc9
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-svc-types.h
include/media-svc.h
plugin/media-content-plugin.c
src/common/media-svc-noti.c
src/common/media-svc.c
src/include/common/media-svc-env.h

index 786631a..e5dbe55 100755 (executable)
@@ -24,6 +24,7 @@
 #ifndef _MEDIA_SVC_TYPES_H_
 #define _MEDIA_SVC_TYPES_H_
 
+#include <time.h>
 
 typedef void MediaSvcHandle;           /**< Handle */
 
@@ -47,4 +48,77 @@ typedef enum{
        MEDIA_SVC_MEDIA_TYPE_OTHER      = 4,    /**< Not media Content*/
 }media_svc_media_type_e;
 
+/**
+ * Media meta data information
+ */
+typedef struct {
+       char    *       title;                          /**< track title*/
+       char    *       album;                          /**< album name*/
+       char    *       artist;                         /**< artist name*/
+       char    *       album_artist;           /**< artist name*/
+       char    *       genre;                          /**< genre of track*/
+       char    *       composer;                       /**< composer name*/
+       char    *       year;                           /**< year*/
+       char    *       recorded_date;          /**< recorded date*/
+       char    *       copyright;                      /**< copyright*/
+       char    *       track_num;                      /**< track number*/
+       char    *       description;                    /**< description*/
+       int             bitrate;                                /**< bitrate*/
+       int             samplerate;                     /**< samplerate*/
+       int             channel;                                /**< channel*/
+       int             duration;                       /**< duration*/
+       float           longitude;                      /**< longitude*/
+       float           latitude;                               /**< latitude*/
+       float           altitude;                               /**< altitude*/
+       char    *       exposure_time;          /**< exposure_time*/
+       float           fnumber;                        /**< fnumber*/
+       int             iso;                            /**< iso*/
+       char    *       model;                          /**< model*/
+       int             width;                          /**< width*/
+       int             height;                         /**< height*/
+       char    *       datetaken;                      /**< datetaken*/
+       int             orientation;                    /**< orientation*/
+       int             rating;                         /**< user defined rating */
+       char    *       weather;                                /**< weather of image */
+       int             bitpersample;                           /**< bitrate*/
+
+       char    *       file_name_pinyin;                               /**< pinyin for file_name*/
+       char    *       title_pinyin;                                   /**< pinyin for title*/
+       char    *       album_pinyin;                           /**< pinyin for album*/
+       char    *       artist_pinyin;                                  /**< pinyin for artist*/
+       char    *       album_artist_pinyin;                    /**< pinyin for album_artist*/
+       char    *       genre_pinyin;                                   /**< pinyin for genre*/
+       char    *       composer_pinyin;                                /**< pinyin for composer*/
+       char    *       copyright_pinyin;                               /**< pinyin for copyright*/
+       char    *       description_pinyin;                     /**< pinyin for description*/
+} media_svc_content_meta_s;
+
+/**
+ * Media data information
+ */
+typedef struct {
+       char    *       media_uuid;                                     /**< Unique ID of item */
+       char    *       path;                                           /**< Full path of media file */
+       char    *       file_name;                                      /**< File name of media file. Display name */
+       char    *       file_name_pinyin;                               /**< File name pinyin of media file. Display name */
+       int             media_type;                                     /**< Type of media file : internal/external */
+       char    *       mime_type;                                      /**< Full path and file name of media file */
+       unsigned long long      size;                                                   /**< size */
+       time_t  added_time;                                     /**< added time, time_t */
+       time_t  modified_time;                          /**< modified time, time_t */
+       time_t  timeline;                                       /**< timeline of media, time_t */
+       char    *       folder_uuid;                                    /**< Unique ID of folder */
+       int             album_id;                                       /**< Unique ID of album */
+       char    *       thumbnail_path;                         /**< Thumbnail image file path */
+       int             played_count;                           /**< played count */
+       int             last_played_time;                               /**< last played time */
+       int             last_played_position;                   /**< last played position */
+       int             favourate;                                      /**< favourate. o or 1 */
+       int             is_drm;                                         /**< is_drm. o or 1 */
+       int             sync_status;                                            /**< sync_status  */
+       int             storage_type;                                   /**< Storage of media file : internal/external */
+       char    *       storage_uuid;                                   /**< Unique ID of storage */
+       media_svc_content_meta_s        media_meta;     /**< meta data structure for audio files */
+} media_svc_content_info_s;
+
 #endif /*_MEDIA_SVC_TYPES_H_*/
index f04c90f..5f1e2e3 100755 (executable)
@@ -47,22 +47,28 @@ int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_sto
 int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt);
 int media_svc_set_item_validity_end(MediaSvcHandle *handle, uid_t uid);
 int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity, uid_t uid);
-int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path, uid_t uid);
+int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path, uid_t uid);
 int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid);
 int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid);
 int media_svc_delete_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, uid_t uid);
 int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity, uid_t uid);
 int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *folder_path, int validity, int recursive, uid_t uid);
-int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
-int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path, uid_t uid);
+int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *storage_id, const char *path, uid_t uid);
+int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, const char *src_path, const char *dst_path, uid_t uid);
 int media_svc_request_update_db(const char *db_query, uid_t uid);
 int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type);
 int media_svc_get_mime_type(const char *path, char *mimetype);
 int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type);
 int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path);
 int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, int *count);
+int media_svc_publish_noti(MediaSvcHandle *handle, media_item_type_e update_item, media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type);
 int media_svc_get_pinyin(MediaSvcHandle *handle, const char * src_str, char **pinyin_str);
 int media_svc_check_pinyin_support(bool *support);
+int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_svc_content_info_s *content_info);
+void media_svc_destroy_content_info(media_svc_content_info_s *content_info);
+char *media_info_generate_uuid(void);
+
+
 
 
 #ifdef __cplusplus
index bc2a1da..fc9f035 100755 (executable)
@@ -473,7 +473,7 @@ int delete_item(void * handle, const char *file_path, int storage_type, uid_t ui
 
        ret = media_svc_check_item_exist_by_path(handle, file_path);
        if(ret == 0) {
-               ret = media_svc_delete_item_by_path(handle, file_path, uid);
+               ret = media_svc_delete_item_by_path(handle, "media", file_path, uid);
 
                if(ret < 0) {
                        __set_error_message(ret, err_msg);
@@ -595,7 +595,7 @@ int refresh_item(void * handle, const char *file_path, int storage_type, uid_t u
                return MEDIA_SVC_PLUGIN_ERROR;
        }
 
-       ret = media_svc_refresh_item(handle, storage_type, file_path, uid);
+       ret = media_svc_refresh_item(handle, storage_type, "media", file_path, uid);
        if(ret < 0) {
                __set_error_message(ret, err_msg);
                return MEDIA_SVC_PLUGIN_ERROR;
index 6fc5ced..54ad73d 100755 (executable)
@@ -58,6 +58,32 @@ static int __media_svc_publish_noti_by_item(media_svc_noti_item *noti_item)
        return ret;
 }
 
+int _media_svc_publish_noti(media_item_type_e update_item,
+                                                       media_item_update_type_e update_type,
+                                                       const char *path,
+                                                       media_type_e media_type,
+                                                       const char *uuid,
+                                                       const char *mime_type
+)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       if(path) {
+               ret = media_db_update_send(getpid(), update_item, update_type, (char *)path, (char *)uuid, media_type, (char *)mime_type);
+               if(ret != MS_MEDIA_ERR_NONE) {
+                       media_svc_error("Send noti failed : %d [%s]", ret, path);
+                       ret = MS_MEDIA_ERR_SEND_NOTI_FAIL;
+               } else {
+                       media_svc_debug("media_db_update_send success");
+               }
+       } else {
+               media_svc_debug("invalid path");
+               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
 media_svc_noti_item *_media_svc_get_noti_list()
 {
        return g_inserted_noti_list;
@@ -185,32 +211,3 @@ int _media_svc_destroy_noti_item(media_svc_noti_item *item)
 
        return MS_MEDIA_ERR_NONE;
 }
-
-int _media_svc_publish_noti(media_item_type_e update_item,
-                                                       media_item_update_type_e update_type,
-                                                       const char *path,
-                                                       media_type_e media_type,
-                                                       const char *uuid,
-                                                       const char *mime_type
-)
-{
-       int err = MS_MEDIA_ERR_NONE;
-
-       if (path) {
-               err = media_db_update_send(getpid(),
-                                                               update_item,
-                                                               update_type,
-                                                               (char *)path,
-                                                               (char *)uuid,
-                                                               media_type,
-                                                               (char *)mime_type);
-               if (err < 0) {
-                       media_svc_error("media_db_update_send failed : %d [%s]", err, path);
-                       return MS_MEDIA_ERR_SEND_NOTI_FAIL;
-               } else {
-                       media_svc_debug("media_db_update_send success");
-               }
-       }
-
-       return err;
-}
index b20ab40..5b877a6 100755 (executable)
@@ -696,7 +696,7 @@ int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int va
        return MS_MEDIA_ERR_NONE;
 }
 
-int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path, uid_t uid)
+int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 * db_handle = (sqlite3 *)handle;
@@ -850,7 +850,7 @@ int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *fold
                return _media_svc_update_folder_item_validity(db_handle, folder_path, validity, uid);
 }
 
-int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *storage_id, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 * db_handle = (sqlite3 *)handle;
@@ -948,7 +948,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e stor
        return ret;
 }
 
-int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path, uid_t uid)
+int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, const char *src_path, const char *dst_path, uid_t uid)
 {
        sqlite3 * db_handle = (sqlite3 *)handle;
        int ret = MS_MEDIA_ERR_NONE;
@@ -969,8 +969,8 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const
 
        /* Update all folder record's path, which are matched by old parent path */
        char *update_folder_path_sql = NULL;
-       char src_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1];
-       char dst_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1];
+       char src_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,};
+       char dst_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,};
 
        snprintf(src_path_slash, sizeof(src_path_slash), "%s/", src_path);
        snprintf(dst_path_slash, sizeof(dst_path_slash), "%s/", dst_path);
@@ -1198,15 +1198,27 @@ int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *
        return _media_svc_count_invalid_folder_items(db_handle, folder_path, count);
 }
 
+int media_svc_publish_noti(MediaSvcHandle *handle, media_item_type_e update_item, media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type)
+{
+       return _media_svc_publish_noti(update_item, update_type, path, media_type, uuid, mime_type);
+}
+
 int media_svc_get_pinyin(MediaSvcHandle *handle, const char * src_str, char **pinyin_str)
 {
        media_svc_retvm_if(!STRING_VALID(src_str), MS_MEDIA_ERR_INVALID_PARAMETER, "String is NULL");
 
        return _media_svc_get_pinyin_str(src_str, pinyin_str);
 }
+
 int media_svc_check_pinyin_support(bool *support)
 {
        *support = _media_svc_check_pinyin_support();
 
        return MS_MEDIA_ERR_NONE;
 }
+
+
+char *media_info_generate_uuid(void)
+{
+       return _media_info_generate_uuid();
+}
index 889e6ce..d9ae2f0 100755 (executable)
@@ -84,132 +84,6 @@ enum Exif_Orientation {
     ROT_270 =8
 };
 
-#if 0
-/**
- * Media meta data information
- */
-typedef struct {
-       char            title[MEDIA_SVC_METADATA_LEN_MAX];                              /**< track title*/
-       char            album[MEDIA_SVC_METADATA_LEN_MAX];                      /**< album name*/
-       char            artist[MEDIA_SVC_METADATA_LEN_MAX];                     /**< artist name*/
-       char            genre[MEDIA_SVC_METADATA_LEN_MAX];                      /**< genre of track*/
-       char            author[MEDIA_SVC_METADATA_LEN_MAX];                     /**< author name*/
-       char            year[MEDIA_SVC_METADATA_LEN_MAX];                               /**< author name*/
-       char            recorded_date[MEDIA_SVC_METADATA_LEN_MAX];              /**< recorded date*/
-       char            copyright[MEDIA_SVC_METADATA_LEN_MAX];                  /**< copyright*/
-       char            track_num[MEDIA_SVC_METADATA_LEN_MAX];          /**< track number*/
-       char            description[MEDIA_SVC_METADATA_DESCRIPTION_MAX];        /**< description*/
-       int             bitrate;                                                                                        /**< bitrate*/
-       int             samplerate;                                                                             /**< samplerate*/
-       int             channel;                                                                                        /**< channel*/
-       int             duration;                                                                               /**< duration*/
-       float           longitude;                                                                              /**< longitude*/
-       float           latitude;                                                                                       /**< latitude*/
-       float           altitude;                                                                                       /**< altitude*/
-       int             width;                                                                                  /**< width*/
-       int             height;                                                                                 /**< height*/
-       char            datetaken[MEDIA_SVC_METADATA_LEN_MAX];          /**< datetaken*/
-       char            timetaken[MEDIA_SVC_METADATA_LEN_MAX];          /**< timetaken*/
-       int             orientation;                                                                            /**< orientation*/
-       int             rating;                                                                                 /**< user defined rating */
-} media_svc_content_meta_s;
-
-
-/**
- * Media data information
- */
-typedef struct {
-       char            media_uuid[MEDIA_SVC_UUID_SIZE+1];                      /**< Unique ID of item */
-       char            path[MEDIA_SVC_PATHNAME_SIZE];                          /**< Full path and file name of media file */
-       char            file_name[MEDIA_SVC_PATHNAME_SIZE];                     /**< Full path and file name of media file */
-       int             media_type;                                                                     /**< Type of media file : internal/external */
-       char            mime_type[MEDIA_SVC_PATHNAME_SIZE];                     /**< Full path and file name of media file */
-       int             size;
-       int             added_time;                                                                     /**< added time */
-       int             modified_time;                                                          /**< modified time */
-       char            folder_uuid[MEDIA_SVC_UUID_SIZE+1];                     /**< Unique ID of folder */
-       int             album_id;                                                                       /**< Unique ID of album */
-       char            thumbnail_path[MEDIA_SVC_PATHNAME_SIZE];                /**< Thumbnail image file path */
-       int             played_count;                                                           /**< played count */
-       int             last_played_time;                                                                       /**< last played time */
-       int             last_played_position;
-       int             favourate;                                                                      /**< favourate. o or 1 */
-       int             hiding;                                                                         /**< hiding. o or 1 */
-       int             is_drm;                                                                         /**< is_drm. o or 1 */
-       int             storage_type;                                                                   /**< Storage of media file : internal/external */
-       media_svc_content_meta_s                media_meta;                                     /**< meta data structure for audio files */
-} media_svc_content_info_s;
-#else
-/**
- * Media meta data information
- */
-typedef struct {
-       char    *       title;                          /**< track title*/
-       char    *       album;                          /**< album name*/
-       char    *       artist;                         /**< artist name*/
-       char    *       album_artist;           /**< artist name*/
-       char    *       genre;                          /**< genre of track*/
-       char    *       composer;                       /**< composer name*/
-       char    *       year;                           /**< year*/
-       char    *       recorded_date;          /**< recorded date*/
-       char    *       copyright;                      /**< copyright*/
-       char    *       track_num;                      /**< track number*/
-       char    *       description;                    /**< description*/
-       int             bitrate;                                /**< bitrate*/
-       int             samplerate;                     /**< samplerate*/
-       int             channel;                                /**< channel*/
-       int             duration;                       /**< duration*/
-       float           longitude;                      /**< longitude*/
-       float           latitude;                               /**< latitude*/
-       float           altitude;                               /**< altitude*/
-       int             width;                          /**< width*/
-       int             height;                         /**< height*/
-       char    *       datetaken;                      /**< datetaken*/
-       int             orientation;                    /**< orientation*/
-       int             rating;                         /**< user defined rating */
-       char    *       weather;                                /**< weather of image */
-       int             bitpersample;                           /**< bitrate*/
-
-       char    *       file_name_pinyin;                               /**< pinyin for file_name*/
-       char    *       title_pinyin;                                   /**< pinyin for title*/
-       char    *       album_pinyin;                           /**< pinyin for album*/
-       char    *       artist_pinyin;                                  /**< pinyin for artist*/
-       char    *       album_artist_pinyin;                    /**< pinyin for album_artist*/
-       char    *       genre_pinyin;                                   /**< pinyin for genre*/
-       char    *       composer_pinyin;                                /**< pinyin for composer*/
-       char    *       copyright_pinyin;                               /**< pinyin for copyright*/
-       char    *       description_pinyin;                     /**< pinyin for description*/
-} media_svc_content_meta_s;
-
-
-/**
- * Media data information
- */
-typedef struct {
-       char    *       media_uuid;                                     /**< Unique ID of item */
-       char    *       path;                                           /**< Full path of media file */
-       char    *       file_name;                                      /**< File name of media file. Display name */
-       char    *       file_name_pinyin;                               /**< File name pinyin of media file. Display name */
-       int             media_type;                                     /**< Type of media file : internal/external */
-       char    *       mime_type;                                      /**< Full path and file name of media file */
-       unsigned long long      size;                                                   /**< size */
-       time_t  added_time;                                     /**< added time, time_t */
-       time_t  modified_time;                          /**< modified time, time_t */
-       time_t  timeline;                                       /**< timeline of media, time_t */
-       char    *       folder_uuid;                                    /**< Unique ID of folder */
-       int             album_id;                                       /**< Unique ID of album */
-       char    *       thumbnail_path;                         /**< Thumbnail image file path */
-       int             played_count;                           /**< played count */
-       int             last_played_time;                               /**< last played time */
-       int             last_played_position;                   /**< last played position */
-       int             favourate;                                      /**< favourate. o or 1 */
-       int             is_drm;                                         /**< is_drm. o or 1 */
-       int             sync_status;                                            /**< sync_status  */
-       int             storage_type;                                   /**< Storage of media file : internal/external */
-       media_svc_content_meta_s        media_meta;     /**< meta data structure for audio files */
-} media_svc_content_info_s;
-#endif
-
 typedef enum{
        MEDIA_SVC_QUERY_INSERT_ITEM,
        MEDIA_SVC_QUERY_SET_ITEM_VALIDITY,