From: Minje Ahn Date: Wed, 1 Apr 2020 03:18:11 +0000 (+0900) Subject: Change function name X-Git-Tag: accepted/tizen/unified/20200402.155617^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c77cc8d6c89033dff655ef2cdc9a129834e3fec;p=platform%2Fcore%2Fmultimedia%2Fmedia-server.git Change function name Change-Id: Ia0b013ba11ae6c5ba179fd9ed6d580b20130d8ce Signed-off-by: Minje Ahn --- diff --git a/Makefile.am b/Makefile.am index 1369587..95f5751 100755 --- a/Makefile.am +++ b/Makefile.am @@ -57,7 +57,7 @@ dist_pkgconfig_DATA = libmedia-utils.pc #libmedia utils ###################################################### lib_LTLIBRARIES = libmedia-utils.la -libmedia_utils_la_SOURCES = lib/media-util-noti-internal.c \ +libmedia_utils_la_SOURCES = lib/media-util-noti.c \ lib/media-util-ipc.c \ lib/media-util-db.c \ lib/media-util-register.c \ @@ -217,7 +217,7 @@ mediadb_update_LDADD = libmedia-utils.la \ ### includeheaders ### includeheadersdir = $(includedir)/media-utils -includeheaders_HEADERS = lib/include/media-util-noti-internal.h \ +includeheaders_HEADERS = lib/include/media-util-noti.h \ lib/include/media-util-register.h \ lib/include/media-util-err.h \ lib/include/media-util-db.h \ diff --git a/lib/include/media-util-noti-internal.h b/lib/include/media-util-noti.h similarity index 75% rename from lib/include/media-util-noti-internal.h rename to lib/include/media-util-noti.h index d516dfe..6bc630f 100755 --- a/lib/include/media-util-noti-internal.h +++ b/lib/include/media-util-noti.h @@ -54,34 +54,29 @@ typedef enum { MS_MEDIA_OTHER = 4, /**< Invalid Content*/ } media_type_e; -typedef void (*db_update_cb)(int pid, /* mandatory */ +typedef void (*db_updated_cb)(int pid, /* mandatory */ media_item_type_e item, /* mandatory */ media_item_update_type_e update_type, /* mandatory */ - char* path, /* mandatory */ - char* uuid, /* optional */ + char *path, /* mandatory */ + char *uuid, /* optional */ media_type_e media_type, /* optional */ char *mime_type, /* optional */ void *user_data); typedef void *MediaNotiHandle; /**< Handle */ -#define MS_MEDIA_DBUS_PATH "/com/mediaserver/dbus/notify" -#define MS_MEDIA_DBUS_INTERFACE "com.mediaserver.dbus.Signal" -#define MS_MEDIA_DBUS_MATCH_RULE "type='signal',interface='com.mediaserver.dbus.Signal'" - - -int media_db_update_send_internal(int pid, /* mandatory */ +int media_db_update_send(int pid, /* mandatory */ media_item_type_e item, /* mandatory */ media_item_update_type_e update_type, /* mandatory */ - char* path, /* mandatory */ - char* uuid, /* optional */ + const char *path, /* mandatory */ + const char *uuid, /* optional */ media_type_e media_type, /* optional */ - char *mime_type /* optional */ + const char *mime_type /* optional */ ); -int media_db_update_subscribe_internal(MediaNotiHandle *handle, db_update_cb user_cb, void *user_data); +int media_db_update_subscribe(MediaNotiHandle *handle, db_updated_cb user_cb, void *user_data); -int media_db_update_unsubscribe_internal(MediaNotiHandle handle); +int media_db_update_unsubscribe(MediaNotiHandle handle); /** diff --git a/lib/include/media-util.h b/lib/include/media-util.h index 6ea0d99..3656c7e 100755 --- a/lib/include/media-util.h +++ b/lib/include/media-util.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/media-util-noti-internal.c b/lib/media-util-noti.c similarity index 63% rename from lib/media-util-noti-internal.c rename to lib/media-util-noti.c index f9d8f23..fb95935 100755 --- a/lib/media-util-noti-internal.c +++ b/lib/media-util-noti.c @@ -37,29 +37,32 @@ #include "private.h" static GList *handle_list; -static GMutex mutex_internal; +static GMutex noti_mutex; -#define MS_MEDIA_DBUS_NAME_INTERNAL "ms_db_updated_internal" +#define MS_DBUS_NAME "ms_db_updated" +#define MS_DBUS_PATH "/com/mediaserver/dbus/notify" +#define MS_DBUS_INTERFACE "com.mediaserver.dbus.Signal" -typedef struct internal_noti_cb_data { +typedef struct noti_cb_data { GDBusConnection *gdbus; int handler; - db_update_cb user_callback; + db_updated_cb user_callback; void *user_data; -} internal_noti_cb_data; +} noti_cb_data; -int media_db_update_send_internal(int pid, /* mandatory */ +int media_db_update_send(int pid, /* mandatory */ media_item_type_e item, /* mandatory */ media_item_update_type_e update_type, /* mandatory */ - char* path, /* mandatory */ - char* uuid, /* optional */ + const char *path, /* mandatory */ + const char *uuid, /* optional */ media_type_e media_type, /* optional */ - char *mime_type /* optional */ + const char *mime_type /* optional */ ) { GVariant *message = NULL; GDBusConnection *bus = NULL; GError *error = NULL; + gboolean ret = FALSE; bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); if (!bus) { @@ -70,17 +73,13 @@ int media_db_update_send_internal(int pid, /* mandatory */ if (item == MS_MEDIA_ITEM_FILE) { MSAPI_DBG("FILE CHANGED"); - if (uuid != NULL && mime_type != NULL) { - /* fill all datas */ + if (uuid && mime_type) message = g_variant_new("(iiissis)", item, pid, update_type, path, uuid, media_type, mime_type); - } else { + else MSAPI_DBG_ERR("uuid or mime_type is NULL"); - return MS_MEDIA_ERR_INTERNAL; - } } else if (item == MS_MEDIA_ITEM_DIRECTORY) { MSAPI_DBG("DIRECTORY CHANGED"); - /* fill all datas */ - if (uuid != NULL) + if (uuid) message = g_variant_new("(iiiss)", item, pid, update_type, path, uuid); else message = g_variant_new("(iiis)", item, pid, update_type, path); @@ -88,45 +87,32 @@ int media_db_update_send_internal(int pid, /* mandatory */ MSAPI_DBG("this request is wrong"); } - if (message == NULL) { - MSAPI_DBG_ERR("g_dbus_message_new_signal failed"); - return MS_MEDIA_ERR_INTERNAL; + if (!message) { + g_object_unref(bus); + return MS_MEDIA_ERR_INVALID_PARAMETER; } /* Send the signal */ - gboolean emmiting = g_dbus_connection_emit_signal( - bus, - NULL, - MS_MEDIA_DBUS_PATH, - MS_MEDIA_DBUS_INTERFACE, - MS_MEDIA_DBUS_NAME_INTERNAL, - message, - &error); - if (!emmiting) { - MSAPI_DBG_ERR("g_dbus_connection_emit_signal failed : %s", error ? error->message : "none"); - if (error) { - MSAPI_DBG_ERR("Error in g_dbus_connection_emit_signal"); - g_object_unref(bus); - g_error_free(error); - } + ret = g_dbus_connection_emit_signal(bus, NULL, MS_DBUS_PATH, MS_DBUS_INTERFACE, MS_DBUS_NAME, message, &error); + g_object_unref(bus); + if (!ret) { + MSAPI_DBG_ERR("g_dbus_connection_emit_signal failed : %s", error->message); + g_error_free(error); return MS_MEDIA_ERR_INTERNAL; } - - g_object_unref(bus); - return MS_MEDIA_ERR_NONE; } static bool __gdbus_message_is_signal(const char *iface, const char *signal) { - if ((strcmp(iface, MS_MEDIA_DBUS_INTERFACE) == 0) && (strcmp(signal, MS_MEDIA_DBUS_NAME_INTERNAL) == 0)) - return TRUE; + if ((strcmp(iface, MS_DBUS_INTERFACE) == 0) && (strcmp(signal, MS_DBUS_NAME) == 0)) + return true; return false; } -static void __get_message_internal(GVariant *message, db_update_cb user_cb, void *userdata) +static void __get_message(GVariant *message, db_updated_cb user_cb, void *userdata) { gint32 item = -1; gint32 pid = 0; @@ -149,59 +135,50 @@ static void __get_message_internal(GVariant *message, db_update_cb user_cb, void content_type = MS_MEDIA_UNKNOWN; /* getting data complete */ - user_cb(pid, - item, - update_type, - update_path, - uuid, - content_type, - mime_type, - userdata); + user_cb(pid, item, update_type, update_path, uuid, content_type, mime_type, userdata); MS_SAFE_FREE(update_path); MS_SAFE_FREE(uuid); MS_SAFE_FREE(mime_type); - } -static void __message_filter_internal(GDBusConnection* connection, - const gchar* sender_name, - const gchar* object_path, - const gchar* interface_name, - const gchar* signal_name, - GVariant* parameters, +static void __message_filter(GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, gpointer user_data) { if (__gdbus_message_is_signal(interface_name, signal_name)) { - db_update_cb user_cb = ((internal_noti_cb_data*)user_data)->user_callback; - void *userdata = ((internal_noti_cb_data*)user_data)->user_data; + db_updated_cb user_cb = ((noti_cb_data *)user_data)->user_callback; + void *userdata = ((noti_cb_data *)user_data)->user_data; - __get_message_internal(parameters, user_cb, userdata); + __get_message(parameters, user_cb, userdata); } } -int media_db_update_subscribe_internal(MediaNotiHandle *handle, db_update_cb user_cb, void *user_data) +int media_db_update_subscribe(MediaNotiHandle *handle, db_updated_cb user_cb, void *user_data) { - int ret = MS_MEDIA_ERR_NONE; int handler = 0; - internal_noti_cb_data *noti_data = NULL; + noti_cb_data *noti_data = NULL; GError *error = NULL; GDBusConnection *gdbus = NULL; if (gdbus == NULL) { gdbus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); if (!gdbus) { - MSAPI_DBG_ERR("Failed to connect to the g D-BUS daemon: %s", error ? error->message : "none"); + MSAPI_DBG_ERR("Failed to connect to the g D-BUS daemon: %s", error->message); g_error_free(error); return MS_MEDIA_ERR_INTERNAL; } } - MS_MALLOC(noti_data, sizeof(internal_noti_cb_data)); + MS_MALLOC(noti_data, sizeof(noti_cb_data)); if (noti_data == NULL) { MSAPI_DBG_ERR("MS_MALLOC failed"); - ret = MS_MEDIA_ERR_OUT_OF_MEMORY; - goto ERROR; + g_object_unref(gdbus); + return MS_MEDIA_ERR_OUT_OF_MEMORY; } noti_data->user_callback = user_cb; noti_data->user_data = user_data; @@ -209,12 +186,12 @@ int media_db_update_subscribe_internal(MediaNotiHandle *handle, db_update_cb use handler = g_dbus_connection_signal_subscribe( gdbus, NULL, - MS_MEDIA_DBUS_INTERFACE, - MS_MEDIA_DBUS_NAME_INTERNAL, - MS_MEDIA_DBUS_PATH, + MS_DBUS_INTERFACE, + MS_DBUS_NAME, + MS_DBUS_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, - __message_filter_internal, + __message_filter, noti_data, NULL); @@ -222,38 +199,27 @@ int media_db_update_subscribe_internal(MediaNotiHandle *handle, db_update_cb use noti_data->handler = handler; *handle = noti_data; - g_mutex_lock(&mutex_internal); + g_mutex_lock(¬i_mutex); handle_list = g_list_append(handle_list, *handle); - g_mutex_unlock(&mutex_internal); + g_mutex_unlock(¬i_mutex); return MS_MEDIA_ERR_NONE; - -ERROR: - - if (gdbus != NULL) { - g_object_unref(gdbus); - gdbus = NULL; - } - - MS_SAFE_FREE(noti_data); - - return ret; } -int media_db_update_unsubscribe_internal(MediaNotiHandle handle) +int media_db_update_unsubscribe(MediaNotiHandle handle) { - internal_noti_cb_data *_handle = (internal_noti_cb_data *)handle; + noti_cb_data *_handle = (noti_cb_data *)handle; GList *found = NULL; MSAPI_RETVM_IF(!handle, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid parameter"); - g_mutex_lock(&mutex_internal); + g_mutex_lock(¬i_mutex); found = g_list_find(handle_list, handle); if (!found) { - g_mutex_unlock(&mutex_internal); + g_mutex_unlock(¬i_mutex); MSAPI_DBG_ERR("Does not found handle"); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -266,7 +232,7 @@ int media_db_update_unsubscribe_internal(MediaNotiHandle handle) MS_SAFE_FREE(_handle->user_data); MS_SAFE_FREE(_handle); - g_mutex_unlock(&mutex_internal); + g_mutex_unlock(¬i_mutex); return MS_MEDIA_ERR_NONE; }