CONFIGURE_FILE(libmedia-service.pc.in libmedia-service.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmedia-service.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-#ADD_SUBDIRECTORY(test)
IF(BUILD_GTESTS)
ADD_SUBDIRECTORY(unittest)
ENDIF(BUILD_GTESTS)
typedef void MediaSvcHandle; /**< Handle */
/**
- * Type definition for storage type
- */
-typedef enum {
- MEDIA_SVC_STORAGE_INTERNAL = 0, /**< The device's internal storage */
- MEDIA_SVC_STORAGE_EXTERNAL = 1, /**< The device's external storage like sd card*/
- MEDIA_SVC_STORAGE_EXTERNAL_USB = 2, /**< The external USB storage (Since 2.4) */
- MEDIA_SVC_STORAGE_MAX, /**< Invalid storage*/
-} media_svc_storage_type_e;
-
-/**
* Type definition for content type
*/
typedef enum {
#define _MEDIA_SVC_H_
#include "media-svc-types.h"
-#include <media-util-noti-internal.h>
+#include <media-util.h>
#include <time.h>
#include <stdbool.h>
#ifdef __cplusplus
int media_svc_get_user_version(MediaSvcHandle *handle, int *user_version);
int media_svc_create_table(uid_t uid);
int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path);
-int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
int media_svc_insert_item_begin(int with_noti, int data_cnt, int from_pid);
int media_svc_insert_item_end(uid_t uid);
-int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
-int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
int media_svc_move_item(MediaSvcHandle *handle, const char *src_path, const char *dest_path, uid_t uid);
int media_svc_set_item_validity_begin(int data_cnt);
int media_svc_set_item_validity_end(uid_t uid);
int media_svc_set_item_validity(const char *storage_id, const char *path, int validity, 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_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid);
-int media_svc_set_all_storage_items_validity(const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid);
+int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid);
+int media_svc_set_all_storage_items_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid);
int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid);
-int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *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, uid_t uid);
int media_svc_get_file_info(MediaSvcHandle *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size);
int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid);
int media_svc_check_db_upgrade(MediaSvcHandle *handle, int user_version, uid_t uid);
int media_svc_generate_uuid(char **uuid);
int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid);
-int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid);
+int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid);
int media_svc_update_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, uid_t uid);
int media_svc_set_storage_validity(MediaSvcHandle *handle, const char *storage_id, int validity, uid_t uid);
int media_svc_get_storage_id(MediaSvcHandle *handle, const char *path, char *storage_id, uid_t uid);
return ret;
}
-static int __media_svc_append_folder(const char *storage_id, media_svc_storage_type_e storage_type,
+static int __media_svc_append_folder(const char *storage_id, ms_user_storage_type_e storage_type,
const char *folder_id, const char *folder_path, bool stack_query, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
return ret;
}
-static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid)
+static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
unsigned int next_pos = 0;
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid)
+int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
int validity = -1;
return ret;
}
-int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid)
+int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid)
{
char *dir_path = NULL;
int ret = MS_MEDIA_ERR_NONE;
return ret;
}
-int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid)
+int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid)
{
char *path_name = NULL;
int ret = MS_MEDIA_ERR_NONE;
return ret;
}
-int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
+int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
GArray *thumb_list = NULL;
thumb_list = g_array_new(FALSE, FALSE, sizeof(char*));
/*If external USB, no need this process */
- if (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) {
+ if (storage_type != MS_USER_STORAGE_EXTERNAL_USB) {
ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_id, &thumb_list);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when get thumbnail record");
return ret;
}
-int _media_svc_update_storage_item_validity(const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid)
+int _media_svc_update_storage_item_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
return ret;
}
-int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, media_svc_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, uid_t uid)
+int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, ms_user_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, uid_t uid)
{
/* update path, filename, modified_time, folder_uuid, thumbnail_path, */
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_append_storage(const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid)
+int _media_svc_append_storage(const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *sql = sqlite3_mprintf("INSERT INTO %q (storage_uuid, storage_path, storage_type) values (%Q, %Q, %d);",
return ret;
}
-int _media_svc_delete_invalid_storage(sqlite3 *handle, media_svc_storage_type_e storage_type, uid_t uid)
+int _media_svc_delete_invalid_storage(sqlite3 *handle, ms_user_storage_type_e storage_type, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *sql = NULL;
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, media_svc_storage_type_e storage_type,
+int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type,
const char *path, media_svc_media_type_e *media_type, bool refresh)
{
int ret = MS_MEDIA_ERR_NONE;
}
/*Do not extract artwork for the USB Storage content*/
- if (content_info->storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) {
+ if (content_info->storage_type != MS_USER_STORAGE_EXTERNAL_USB) {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
if (mmf_error != FILEINFO_ERROR_NONE) {
media_svc_error("fail to get tag artwork - err(%x)", mmf_error);
#include <string.h>
#include <errno.h>
-#include <media-util.h>
#include "media-svc.h"
#include "media-svc-media.h"
#include "media-svc-debug.h"
#define BATCH_REQUEST_MAX 300
-static bool __media_svc_check_storage(media_svc_storage_type_e storage_type)
+static bool __media_svc_check_storage(ms_user_storage_type_e storage_type)
{
- if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL)
- && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)
- && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB)) {
+ if ((storage_type != MS_USER_STORAGE_INTERNAL)
+ && (storage_type != MS_USER_STORAGE_EXTERNAL)
+ && (storage_type != MS_USER_STORAGE_EXTERNAL_USB)) {
media_svc_error("storage type is incorrect[%d]", storage_type);
return FALSE;
}
return ret;
}
-int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type, uid_t uid)
-{
- int ret = MS_MEDIA_ERR_NONE;
- ms_user_storage_type_e type = -1;
-
- ret = ms_user_get_storage_type(uid, path, &type);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_storage_type failed : %d", ret);
-
- *storage_type = type;
-
- return ret;
-}
-
int media_svc_get_file_info(MediaSvcHandle *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size)
{
int ret = MS_MEDIA_ERR_NONE;
return ret;
}
-int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *db_handle = (sqlite3 *)handle;
return MS_MEDIA_ERR_NONE;
}
-int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *db_handle = (sqlite3 *)handle;
return MS_MEDIA_ERR_NONE;
}
-int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
+int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid)
{
sqlite3 *db_handle = (sqlite3 *)handle;
return _media_svc_delete_invalid_items(db_handle, storage_id, storage_type, uid);
}
-int media_svc_set_all_storage_items_validity(const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid)
+int media_svc_set_all_storage_items_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid)
{
media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
return _media_svc_update_folder_item_validity(db_handle, storage_id, folder_path, validity, uid);
}
-int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *db_handle = (sqlite3 *)handle;
return _media_svc_update_storage_path(db_handle, storage_id, storage_path, uid);
}
-int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid)
+int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *db_handle = (sqlite3 *)handle;
return ret;
}
-int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
#include <sqlite3.h>
#include <stdbool.h>
#include "media-svc-types.h"
+#include <media-util.h>
int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid);
int _media_svc_get_folder_id_by_foldername_with_validity(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid, int *validity);
int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, uid_t uid);
-int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid);
-int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid);
-int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid);
+int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid);
+int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid);
+int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid);
int _media_svc_delete_invalid_folder(const char *storage_id, int storage_type, uid_t uid);
int _media_svc_set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid);
GList ** _media_svc_get_folder_list_ptr(void);
int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, char *thumbnail_path);
int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *storage_id, const char *path, int *media_type);
int _media_svc_delete_item_by_path(const char *storage_id, const char *path, bool stack_query, uid_t uid);
-int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid);
-int _media_svc_update_storage_item_validity(const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid);
+int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid);
+int _media_svc_update_storage_item_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid);
int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, uid_t uid);
int _media_svc_update_recursive_folder_item_validity(const char *storage_id, const char *folder_path, int validity, uid_t uid);
int _media_svc_update_item_validity(const char *storage_id, const char *path, int validity, bool stack_query, uid_t uid);
-int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, media_svc_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, uid_t uid);
+int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, ms_user_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, uid_t uid);
int _media_svc_list_query_do(media_svc_query_type_e query_type, uid_t uid);
int _media_svc_update_thumbnail_path(const char *storage_id, const char *path, const char *thumb_path, uid_t uid);
int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, int update_item, media_svc_noti_item **item);
#include <sqlite3.h>
int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid);
-int _media_svc_append_storage(const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid);
+int _media_svc_append_storage(const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid);
int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
-int _media_svc_delete_invalid_storage(sqlite3 *handle, media_svc_storage_type_e storage_type, uid_t uid);
+int _media_svc_delete_invalid_storage(sqlite3 *handle, ms_user_storage_type_e storage_type, uid_t uid);
int _media_svc_update_storage_validity(const char *storage_id, int validity, uid_t uid);
int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage_id, uid_t uid);
int _media_svc_get_all_storage(sqlite3 *handle, char ***storage_list, char ***storage_id_list, int *count);
#define STRING_VALID(str) \
((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
-#define STORAGE_VALID(storage)\
- (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL_USB)) ? TRUE : FALSE)
-
#define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n);
#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
int _media_svc_get_thumbnail_path(media_svc_media_type_e media_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid);
int _media_svc_get_file_time(const char *full_path);
int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool refresh);
-int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, media_svc_storage_type_e storage_type,
+int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type,
const char *path, media_svc_media_type_e *media_type, bool refresh);
int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s *content_info);
int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, uid_t uid);
+++ /dev/null
-SET(fw_name "media-service")
-SET(fw_test "${fw_name}-test")
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog libmedia-utils libtzplatform-config)
-FOREACH(flag ${${fw_test}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
-
-aux_source_directory(. sources)
-FOREACH(src ${sources})
- GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
- MESSAGE("${src_name}")
- ADD_EXECUTABLE(${src_name} ${src})
- TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
-ENDFOREACH()
+++ /dev/null
-/*
- * libmedia-service
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <media-svc.h>
-#include <media-svc-noti.h>
-
-#define SAFE_FREE(src) { if (src) { free(src); src = NULL; } }
-
-GMainLoop *g_loop = NULL;
-MediaSvcHandle *g_db_handle = NULL;
-
-void _noti_cb(int pid,
- media_item_type_e update_item,
- media_item_update_type_e update_type,
- char *path,
- char *uuid,
- media_type_e content_type,
- char *mime_type,
- void *user_data)
-{
- media_svc_debug("Noti from PID(%d)", pid);
-
- if (update_item == MS_MEDIA_ITEM_FILE)
- media_svc_debug("Noti item : MS_MEDIA_ITEM_FILE");
- else if (update_item == MS_MEDIA_ITEM_DIRECTORY)
- media_svc_debug("Noti item : MS_MEDIA_ITEM_DIRECTORY");
-
- if (update_type == MS_MEDIA_ITEM_INSERT)
- media_svc_debug("Noti type : MS_MEDIA_ITEM_INSERT");
- else if (update_type == MS_MEDIA_ITEM_DELETE)
- media_svc_debug("Noti type : MS_MEDIA_ITEM_DELETE");
- else if (update_type == MS_MEDIA_ITEM_UPDATE)
- media_svc_debug("Noti type : MS_MEDIA_ITEM_UPDATE");
-
- /*media_svc_debug("content type : %d", content_type); */
- printf("content type : %d\n", content_type);
-
- if (path)
- printf("path : %s\n", path);
- else
- printf("path not");
-
- if (mime_type)
- printf("mime_type : %s", mime_type);
- else
- printf("mime not");
-
- if (user_data) printf("String : %s\n", (char *)user_data);
- else
- printf("user not");
-
- return;
-}
-
-#if 1
-gboolean _send_noti_batch_operations(gpointer data)
-{
- int ret = MS_MEDIA_ERR_NONE;
-
- /* First of all, noti subscription */
- char *user_str = strdup("hi");
- /* 1. media_svc_insert_item_immediately */
- char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
-
- media_svc_storage_type_e storage_type;
-
- ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("media_svc_get_storage_type failed : %d (%s)", ret, path);
- SAFE_FREE(user_str);
- return FALSE;
- }
-
- int idx = 0;
- char *file_list[10];
-
- ret = media_svc_insert_item_begin(100, TRUE, getpid());
- /*ret = media_svc_insert_item_begin(g_db_handle, 100); */
- for (idx = 0; idx < 10; idx++) {
- char filepath[255] = {0, };
- snprintf(filepath, sizeof(filepath), "%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), idx + 1);
- media_svc_debug("File : %s\n", filepath);
- file_list[idx] = strdup(filepath);
- ret = media_svc_insert_item_bulk(g_db_handle, storage_type, file_list[idx], FALSE);
- if (ret != 0)
- media_svc_error("media_svc_insert_item_bulk[%d] failed", idx);
- else
- media_svc_debug("media_svc_insert_item_bulk[%d] success", idx);
- }
-
- ret = media_svc_insert_item_end(tzplatform_getuid(TZ_USER_NAME));
-
- SAFE_FREE(user_str);
- return FALSE;
-}
-#endif
-
-gboolean _send_noti_operations(gpointer data)
-{
- int ret = MS_MEDIA_ERR_NONE;
-
- /* First of all, noti subscription */
- char *user_str = strdup("hi");
-
- /* 1. media_svc_insert_item_immediately */
- char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
- media_svc_storage_type_e storage_type;
-
- ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("media_svc_get_storage_type failed : %d (%s)", ret, path);
- SAFE_FREE(user_str);
- return FALSE;
- }
-
- ret = media_svc_insert_item_immediately(g_db_handle, storage_type, path);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("media_svc_insert_item_immediately failed : %d", ret);
- SAFE_FREE(user_str);
- return FALSE;
- }
-
- media_svc_debug("media_svc_insert_item_immediately success");
-
- /* 2. media_svc_move_item */
- const char *dst_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image11.jpg");
- ret = media_svc_move_item(g_db_handle, path, dst_path);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("media_svc_move_item failed : %d", ret);
- return FALSE;
- }
- media_svc_debug("media_svc_move_item success");
-
- ret = media_svc_move_item(g_db_handle, storage_type, dst_path, storage_type, path);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("media_svc_move_item failed : %d", ret);
- return FALSE;
- }
- media_svc_debug("media_svc_move_item success");
-
- /* 4. media_svc_delete_item_by_path */
- ret = media_svc_delete_item_by_path(g_db_handle, path);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("media_svc_delete_item_by_path failed : %d", ret);
- return FALSE;
- }
- media_svc_debug("media_svc_delete_item_by_path success");
-
- return FALSE;
-}
-
-int test_noti()
-{
- GSource *source = NULL;
- GMainContext *context = NULL;
-
- g_loop = g_main_loop_new(NULL, FALSE);
- context = g_main_loop_get_context(g_loop);
- source = g_idle_source_new();
-#if 0
- g_source_set_callback(source, _send_noti_operations, NULL, NULL);
-#else
- g_source_set_callback(source, _send_noti_batch_operations, NULL, NULL);
-#endif
- g_source_attach(source, context);
-
- g_main_loop_run(g_loop);
-
- g_main_loop_unref(g_loop);
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int main()
-{
- int ret = MS_MEDIA_ERR_NONE;
- ret = media_svc_connect(&g_db_handle, tzplatform_getuid(TZ_USER_NAME), true);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("media_svc_connect failed : %d", ret);
- else
- media_svc_debug("media_svc_connect success");
-
- ret = test_noti();
- if (ret < MS_MEDIA_ERR_NONE)
- media_svc_error("test_noti failed : %d", ret);
- else
- media_svc_debug("test_noti success");
-
- media_svc_disconnect(g_db_handle);
- return ret;
-}
-
+++ /dev/null
-CC =gcc
-LIBS = libmedia-service
-
-OBJS = media_svc_plugin_test.o
-SRCS = media_svc_plugin_test.c
-TARGET = plugin_test
-
-TARGET : $(OBJS)
- $(CC) -o $(TARGET) $(OBJS) -ldl `pkg-config $(LIBS) --cflags --libs` -g
-$(OBJS) : $(SRCS)
- $(CC) -c $(SRCS) -I../../include -L../../cmake_build_tmp `pkg-config $(LIBS) --cflags --libs` -g
-clean :
- rm $(TARGET)
- rm $(OBJS)
+++ /dev/null
-/*
- * libmedia-service
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <dlfcn.h>
-#include <stdbool.h>
-#include <media-svc.h>
-
-#include <tzplatform_config.h>
-
-#define PLUGIN_SO_FILE_NAME "/usr/lib/libmedia-content-plugin.so"
-void *funcHandle = NULL;
-
-static void msg_print(int line, char *msg);
-
-int (*svc_connect)(void **handle, char **err_msg);
-int (*svc_disconnect)(void *handle, char **err_msg);
-int (*svc_check_item_exist)(void *handle, const char *file_path, bool *modified, char **err_msg);
-int (*svc_insert_item_immediately)(void *handle, const char *file_path, int storage_type, const char *mime_type, char **err_msg);
-int (*svc_set_folder_item_validity)(void *handle, const char *folder_path, int validity, int recursive, char **err_msg);
-int (*svc_delete_all_invalid_items_in_folder)(void *handle, const char *folder_path, char **err_msg);
-
-int __load_functions()
-{
- msg_print(__LINE__, "__load_functions");
-
- funcHandle = dlopen(PLUGIN_SO_FILE_NAME, RTLD_LAZY);
- if (!funcHandle)
- fprintf(stderr, "error: %s\n", dlerror());
-
- svc_connect = dlsym(funcHandle, "connect");
- svc_disconnect = dlsym(funcHandle, "disconnect");
- svc_check_item_exist = dlsym(funcHandle, "check_item_exist");
- svc_insert_item_immediately = dlsym(funcHandle, "insert_item_immediately");
- svc_set_folder_item_validity = dlsym(funcHandle, "set_folder_item_validity");
- svc_delete_all_invalid_items_in_folder = dlsym(funcHandle, "delete_all_invalid_items_in_folder");
-
- if (!svc_connect || !svc_disconnect || !svc_insert_item_immediately || !svc_set_folder_item_validity || !svc_delete_all_invalid_items_in_folder || !svc_check_item_exist) {
- fprintf(stderr, "error: %s\n", dlerror());
- return -1;
- }
-
- return 0;
-}
-
-int __unload_functions(void)
-{
- msg_print(__LINE__, "__unload_functions");
-
- if (funcHandle)
- dlclose(funcHandle);
-
- return 0;
-}
-
-int main()
-{
- int ret = 0;
- MediaSvcHandle *db_handle = NULL;
- char *err_msg = NULL;
- char path[1024] = {0, };
- char type[1024] = {0, };
-
- ret = __load_functions();
- if (ret < 0) {
- msg_print(__LINE__, "__load_functions error");
- return -1;
- } else {
- msg_print(__LINE__, "__load_functions success");
- }
-
- /*db open ================================================== */
- ret = svc_connect(&db_handle, &err_msg);
- if (ret < 0) {
- msg_print(__LINE__, "svc_connect error");
- if (err_msg != NULL) {
- printf("err_msg[%s]\n", err_msg);
- free(err_msg);
- err_msg = NULL;
- }
- __unload_functions();
- return -1;
- } else {
- msg_print(__LINE__, "svc_connect success");
- }
-
-#if 1
- ret = media_svc_create_table(tzplatform_getuid(TZ_USER_NAME));
- if (ret < 0)
- msg_print(__LINE__, "table already exists");
- else
- msg_print(__LINE__, "table create success");
-#endif
-
-#if 1
- while (1) {
-
- printf("Enter path and mimetype ( ex. %s image ) : ", tzplatform_mkpath(TZ_USER_CONTENT, "a.jpg"));
- scanf("%s %s", path, type);
- bool modified = false;
- /*check_item_exist ============================================ */
- ret = svc_check_item_exist(db_handle, path, &modified, &err_msg);
- if (ret < 0) {
- msg_print(__LINE__, "svc_check_item_exist error");
- if (err_msg != NULL) {
- printf("err_msg[%s]\n", err_msg);
- free(err_msg);
- err_msg = NULL;
- }
- /*__unload_functions(); */
- /*return -1; */
- } else {
- if (modified)
- msg_print(__LINE__, "svc_check_item_exist success. Modified");
- else
- msg_print(__LINE__, "svc_check_item_exist success. Not modified");
- }
-
- /* svc_check_item_exist ============================================ */
- ret = svc_insert_item_immediately(db_handle, path, 0, type, &err_msg);
- if (ret < 0) {
- msg_print(__LINE__, "svc_insert_item_immediately error");
- if (err_msg != NULL) {
- printf("err_msg[%s]\n", err_msg);
- free(err_msg);
- err_msg = NULL;
- }
- /*__unload_functions(); */
- /*return -1; */
- } else {
- msg_print(__LINE__, "svc_insert_item_immediately success");
- }
- } /* End of While */
-
- ret = media_svc_insert_folder(db_handle, 0, path);
- if (ret < 0)
- msg_print(__LINE__, "media_svc_insert_folder error ");
- else
- msg_print(__LINE__, "media_svc_insert_folder success");
-#endif
-
- /*folder test ================================================== */
- char *folder_path = tzplatform_mkpath(TZ_USER_CONTENT, "Sounds");
- ret = svc_set_folder_item_validity(db_handle, folder_path, 0, 1, &err_msg);
- if (ret < 0) {
- msg_print(__LINE__, "svc_set_folder_item_validity error");
- if (err_msg != NULL) {
- printf("err_msg[%s]\n", err_msg);
- free(err_msg);
- err_msg = NULL;
- }
- } else {
- msg_print(__LINE__, "svc_insert_item_immediately success");
- }
-
- ret = svc_delete_all_invalid_items_in_folder(db_handle, folder_path, &err_msg);
- if (ret < 0) {
- msg_print(__LINE__, "svc_delete_all_invalid_items_in_folder error");
- if (err_msg != NULL) {
- printf("err_msg[%s]\n", err_msg);
- free(err_msg);
- err_msg = NULL;
- }
- } else {
- msg_print(__LINE__, "svc_insert_item_immediately success");
- }
-
- /*db close ================================================== */
- ret = svc_disconnect(db_handle, &err_msg);
- if (ret < 0) {
- msg_print(__LINE__, "svc_disconnect error");
- if (err_msg != NULL) {
- printf("err_msg[%s]\n", err_msg);
- free(err_msg);
- err_msg = NULL;
- }
- __unload_functions();
- return -1;
- } else {
- msg_print(__LINE__, "svc_disconnect success");
- }
-
- __unload_functions();
-
- return 0;
-}
-
-
-static void msg_print(int line, char *msg)
-{
- fprintf(stderr, "[%d]%s\n", line, msg);
-}
-