Update scanner process 95/48995/1 accepted/tizen/mobile/20151005.055538 accepted/tizen/tv/20151005.055554 accepted/tizen/wearable/20151005.055605 submit/tizen/20151005.042745
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 5 Oct 2015 02:11:36 +0000 (11:11 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 5 Oct 2015 02:11:36 +0000 (11:11 +0900)
Change-Id: I2ba748e6772b169dba181aec04c1d7615bd04da7
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
24 files changed:
Makefile.am
configure.ac
lib/include/media-util-noti-internal.h [new file with mode: 0755]
lib/include/media-util.h
lib/media-util-noti-internal.c [new file with mode: 0755]
lib/media-util-noti.c
media_content_config.ini [new file with mode: 0644]
packaging/media-server.spec
src/common/include/media-common-db-svc.h
src/common/include/media-common-system.h
src/common/include/media-common-types.h
src/common/media-common-db-svc.c
src/common/media-common-system.c
src/common/media-common-utils.c
src/scanner/include/media-scanner-device-block.h
src/scanner/media-scanner-device-block.c
src/scanner/media-scanner-scan.c
src/scanner/media-scanner.c
src/server/include/media-server-device-block.h
src/server/include/media-server-thumb.h
src/server/media-server-device-block.c
src/server/media-server-main.c
src/server/media-server-scanner.c
src/server/media-server-thumb.c

index 908c6d7..906b2d5 100755 (executable)
@@ -1,4 +1,5 @@
 ACLOCAL_AMFLAGS = -I m4
+AUTOMAKE_OPTIONS = subdir-objects
 
 SUBDIRS = .
 
@@ -61,7 +62,8 @@ dist_fmsvc_DATA = ./data/mediasvr
 #libmedia utils
 ######################################################
 lib_LTLIBRARIES = libmedia-utils.la
-libmedia_utils_la_SOURCES = lib/media-util-noti.c \
+libmedia_utils_la_SOURCES = lib/media-util-noti-internal.c \
+                            lib/media-util-noti.c \
                             lib/media-util-ipc.c \
                             lib/media-util-db.c \
                             lib/media-util-register.c \
@@ -164,6 +166,7 @@ mediadb_update_LDADD = libmedia-utils.la \
 ### includeheaders ###
 includeheadersdir = $(includedir)/media-utils
 includeheaders_HEADERS = lib/include/media-util-noti-common.h \
+                         lib/include/media-util-noti-internal.h \
                          lib/include/media-util-noti.h \
                          lib/include/media-util-register.h \
                          lib/include/media-util-err.h \
index 40f4b0e..5354794 100755 (executable)
@@ -6,7 +6,7 @@ AC_INIT([media-server], [1.0])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_HEADERS([config.h:config.in])
 
-AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 
 # for platform setting
 AC_CONFIG_MACRO_DIR([m4])
@@ -94,6 +94,10 @@ PKG_CHECK_MODULES(DB_UTIL, db-util)
 AC_SUBST(DB_UTIL_CFLAGS)
 AC_SUBST(DB_UTIL_LIBS)
 
+PKG_CHECK_MODULES(INIPARSER, iniparser)
+AC_SUBST(INIPARSER_CFLAGS)
+AC_SUBST(INIPARSER_LIBS)
+
 #tz-platform-config lib
 PKG_CHECK_MODULES(TZ_PLATFORM_CONFIG, libtzplatform-config)
 AC_SUBST(TZ_PLATFORM_CONFIG_CFLAGS)
diff --git a/lib/include/media-util-noti-internal.h b/lib/include/media-util-noti-internal.h
new file mode 100755 (executable)
index 0000000..3e58f4a
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ *  Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file               media-util-noti.h
+ * @author     Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version    1.0
+ * @brief
+ */
+ #ifndef _MEDIA_UTIL_NOTI_INTERNAL_H_
+#define _MEDIA_UTIL_NOTI_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "media-util-noti-common.h"
+
+/**
+* @fn          int media_db_update_subscribe(void);
+* @brief               This function announce media database is updated to other applications.<br>
+* @return      This function returns 0 on success, and -1 on failure.
+* @param[in]   none
+* @remark      This function is recommandation for other application being aware of database updating.<br>
+* @par example
+* @code
+
+#include <stdio.h>
+#include <glib.h>
+#include <media-util-noti.h>
+
+void callback()
+{
+        printf("listen dbus from media-server\n");
+}
+
+int
+main (int argc, char **argv)
+{
+       GMainLoop *loop;
+
+       loop = g_main_loop_new (NULL, FALSE);
+
+       media_db_update_subscribe(callback);
+
+       g_main_loop_run (loop);
+
+       return 0;
+}
+
+*/
+
+int media_db_update_send_internal(int pid, /* mandatory */
+                                                       media_item_type_e item, /* mandatory */
+                                                       media_item_update_type_e update_type, /* mandatory */
+                                                       char* path, /* mandatory */
+                                                       char* uuid, /* optional */
+                                                       media_type_e media_type, /* optional */
+                                                       char *mime_type /* optional */
+                                                       );
+
+int media_db_update_subscribe_internal(MediaNotiHandle *handle, db_update_cb user_cb, void *user_data);
+
+int media_db_update_unsubscribe_internal(MediaNotiHandle handle, clear_user_data_cb clear_cb);
+
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_MEDIA_UTIL_NOTI_INTERNAL_H_*/
index f342e1d..b97fd23 100755 (executable)
@@ -26,6 +26,7 @@
 #include <media-util-register.h>
 #include <media-util-db.h>
 #include <media-util-noti.h>
+#include <media-util-noti-internal.h>
 #include <media-util-ipc.h>
 #include <media-util-cynara.h>
 
diff --git a/lib/media-util-noti-internal.c b/lib/media-util-noti-internal.c
new file mode 100755 (executable)
index 0000000..4ce1932
--- /dev/null
@@ -0,0 +1,373 @@
+/*
+ *  Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file               media-util-noti.c
+ * @author     Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version    1.0
+ * @brief
+ */
+
+#include <sys/errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "media-util-internal.h"
+#include "media-util-dbg.h"
+#include "media-util.h"
+#include "media-util-noti-internal.h"
+
+GArray *handle_list_internal;
+static GMutex mutex_internal;
+int ref_count;
+
+#define MS_MEDIA_DBUS_NAME_INTERNAL "ms_db_updated_internal"
+
+typedef struct internal_noti_cb_data{
+       DBusConnection *dbus;
+       db_update_cb user_callback;
+       void *user_data;
+} internal_noti_cb_data;
+
+int media_db_update_send_internal(int pid, /* mandatory */
+                                                       media_item_type_e item, /* mandatory */
+                                                       media_item_update_type_e update_type, /* mandatory */
+                                                       char* path, /* mandatory */
+                                                       char* uuid, /* optional */
+                                                       media_type_e media_type, /* optional */
+                                                       char *mime_type /* optional */
+                                                       )
+{
+       DBusMessage *message = NULL;
+       DBusConnection *bus = NULL;
+       DBusError error;
+       unsigned char *path_array = NULL;
+       int path_length = strlen(path) + 1;
+
+       /* Get a connection to the session bus */
+       dbus_error_init (&error);
+       bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+       if (!bus) {
+               MSAPI_DBG ("Failed to connect to the D-BUS daemon: %s", error.message);
+               dbus_error_free (&error);
+               return MS_MEDIA_ERR_INTERNAL;
+       }
+
+       message = dbus_message_new_signal (MS_MEDIA_DBUS_PATH, MS_MEDIA_DBUS_INTERFACE, MS_MEDIA_DBUS_NAME_INTERNAL);
+       if (message != NULL) {
+               path_array = malloc(sizeof(unsigned char) * path_length);
+               memcpy(path_array, path, path_length);
+
+               if (item == MS_MEDIA_ITEM_FILE) {
+                       MSAPI_DBG("FILE CHANGED");
+                       if (uuid != NULL && mime_type != NULL) {
+                       /* fill all datas */
+                               dbus_message_append_args (message,
+                                                                               DBUS_TYPE_INT32, &item,
+                                                                               DBUS_TYPE_INT32, &pid,
+                                                                               DBUS_TYPE_INT32, &update_type,
+                                                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &path_array, path_length,
+                                                                               DBUS_TYPE_STRING, &uuid,
+                                                                               DBUS_TYPE_INT32, &media_type,
+                                                                               DBUS_TYPE_STRING, &mime_type,
+                                                                               DBUS_TYPE_INVALID);
+                       } else {
+                               MSAPI_DBG_ERR("uuid or mime_type is NULL");
+                               MS_SAFE_FREE(path_array);
+                               dbus_message_unref (message);
+                               return MS_MEDIA_ERR_INVALID_PARAMETER;
+                       }
+               } else if (item == MS_MEDIA_ITEM_DIRECTORY) {
+                       MSAPI_DBG("DIRECTORY CHANGED");
+                       /* fill all datas */
+                       if(uuid != NULL) {
+                               dbus_message_append_args (message,
+                                                                               DBUS_TYPE_INT32, &item,
+                                                                               DBUS_TYPE_INT32, &pid,
+                                                                               DBUS_TYPE_INT32, &update_type,
+                                                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &path_array, path_length,
+                                                                               DBUS_TYPE_STRING, &uuid,
+                                                                               DBUS_TYPE_INVALID);
+                       } else {
+                               dbus_message_append_args (message,
+                                                                               DBUS_TYPE_INT32, &item,
+                                                                               DBUS_TYPE_INT32, &pid,
+                                                                               DBUS_TYPE_INT32, &update_type,
+                                                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &path_array, path_length,
+                                                                               DBUS_TYPE_INVALID);
+                       }
+               } else {
+                       MSAPI_DBG("this request is wrong");
+               }
+
+               MS_SAFE_FREE(path_array);
+
+               /* Send the signal */
+               dbus_connection_send (bus, message, NULL);
+
+               /* Free the signal now we have finished with it */
+               dbus_message_unref (message);
+
+               MSAPI_DBG_ERR("success send notification");
+       } else {
+               MSAPI_DBG_ERR("dbus_message_new_signal failed");
+       }
+
+       dbus_connection_unref(bus);
+
+       /* Return TRUE to tell the event loop we want to be called again */
+       return MS_MEDIA_ERR_NONE;
+}
+
+
+DBusHandlerResult
+__get_message_internal(DBusMessage *message, db_update_cb user_cb, void *userdata)
+{
+       /* A Ping signal on the com.burtonini.dbus.Signal interface */
+       if (dbus_message_is_signal (message, MS_MEDIA_DBUS_INTERFACE, MS_MEDIA_DBUS_NAME_INTERNAL)) {
+               int i = 0;
+               int current_type = DBUS_TYPE_INVALID;
+               DBusError error;
+               DBusMessageIter read_iter;
+               DBusBasicValue value[6];
+
+               dbus_int32_t item = -1;
+               dbus_int32_t pid = 0;
+               dbus_int32_t update_type = MS_MEDIA_UNKNOWN;
+               dbus_int32_t content_type = -1;
+               char *update_path = NULL;
+               char *uuid = NULL;
+               char *mime_type = NULL;
+               void *recevie_path = NULL;
+               int path_len = 0;
+
+               dbus_error_init (&error);
+               MSAPI_DBG("size [%d]", sizeof(value));
+               memset(value, 0x0, sizeof(value));
+
+               /* get data from dbus message */
+               dbus_message_iter_init (message, &read_iter);
+               while ((current_type = dbus_message_iter_get_arg_type (&read_iter)) != DBUS_TYPE_INVALID){
+                       if (current_type == DBUS_TYPE_ARRAY) {
+                               DBusMessageIter sub;
+                               dbus_message_iter_recurse(&read_iter, &sub);
+                               dbus_message_iter_get_fixed_array(&sub, &recevie_path, &path_len);
+                       } else {
+                               dbus_message_iter_get_basic (&read_iter, &value[i]);
+                               i ++;
+                       }
+                       dbus_message_iter_next (&read_iter);
+               }
+
+               item = value[0].i32;
+               pid = value[1].i32;
+               update_type = value[2].i32;
+               update_path = strndup(recevie_path, path_len);
+               if (value[3].str != NULL) uuid = strdup(value[3].str);
+               content_type = value[4].i32;
+               if (value[5].str != NULL) mime_type = strdup(value[5].str);
+
+               if (item == MS_MEDIA_ITEM_DIRECTORY)
+                       content_type = MS_MEDIA_UNKNOWN;
+
+               /* getting data complete */
+               MSAPI_DBG("update type[%d]", update_type);
+               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);
+
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+
+       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+DBusHandlerResult
+__message_filter_internal(DBusConnection *connection, DBusMessage *message, void *user_data)
+{
+       db_update_cb user_cb = ((internal_noti_cb_data*)user_data)->user_callback;
+       void *userdata = ((internal_noti_cb_data*)user_data)->user_data;
+       DBusHandlerResult ret;
+
+       ret = __get_message_internal(message, user_cb, userdata);
+
+       return ret;
+}
+
+int media_db_update_subscribe_internal(MediaNotiHandle *handle, db_update_cb user_cb, void *user_data)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       internal_noti_cb_data *noti_data = NULL;
+       DBusError error;
+       DBusConnection *dbus;
+
+       dbus_g_thread_init();
+
+       dbus_error_init (&error);
+
+       dbus = dbus_bus_get_private (DBUS_BUS_SYSTEM, &error);
+       if (!dbus) {
+               MSAPI_DBG ("Failed to connect to the D-BUS daemon: %s", error.message);
+               dbus_error_free (&error);
+               ret = MS_MEDIA_ERR_INTERNAL;
+               goto ERROR;
+       }
+
+       dbus_connection_setup_with_g_main (dbus, NULL);
+
+       MS_MALLOC(noti_data, sizeof(internal_noti_cb_data));
+       if (noti_data == NULL) {
+               MSAPI_DBG_ERR("MS_MALLOC failed");
+               ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
+               goto ERROR;
+       }
+       noti_data->user_callback = user_cb;
+       noti_data->user_data = user_data;
+
+       /* listening to messages from all objects as no path is specified */
+       dbus_bus_add_match (dbus, MS_MEDIA_DBUS_MATCH_RULE, &error);
+       if( !dbus_connection_add_filter (dbus, __message_filter_internal, noti_data, NULL)) {
+               dbus_bus_remove_match (dbus, MS_MEDIA_DBUS_MATCH_RULE, NULL);
+               ret =  MS_MEDIA_ERR_INTERNAL;
+               goto ERROR;
+       }
+
+       noti_data->dbus = dbus;
+       *handle = noti_data;
+
+       g_mutex_lock(&mutex_internal);
+
+       if (handle_list_internal == NULL) {
+               handle_list_internal = g_array_new(FALSE, FALSE, sizeof(MediaNotiHandle));
+               if (handle_list_internal == NULL) {
+                       g_mutex_unlock(&mutex_internal);
+                       ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
+                       goto ERROR;
+               }
+       }
+
+       g_array_append_val(handle_list_internal, *handle);
+
+       g_mutex_unlock(&mutex_internal);
+
+       return MS_MEDIA_ERR_NONE;
+
+ERROR:
+
+       if (dbus != NULL) {
+               dbus_connection_close(dbus);
+               dbus_connection_unref(dbus);
+               dbus = NULL;
+       }
+
+       MS_SAFE_FREE(noti_data);
+
+       return ret;
+}
+
+static int _find_handle(MediaNotiHandle handle, int *idx)
+{
+       unsigned int i;
+       int ret = MS_MEDIA_ERR_NONE;
+       bool find_flag = false;
+       MediaNotiHandle data;
+
+       /*delete all node*/
+       if(handle_list_internal != NULL) {
+               for (i =0; i < handle_list_internal->len; i++) {
+                       data = g_array_index(handle_list_internal , MediaNotiHandle, i);
+                       MSAPI_DBG_ERR("%x %x", handle, data);
+                       if (data == handle) {
+                               MSAPI_DBG("FIND HANDLE");
+                               *idx = i;
+                               find_flag = true;
+                               break;
+                       }
+               }
+       } else {
+               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       if (find_flag == false)
+               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+
+       return ret;
+}
+
+int media_db_update_unsubscribe_internal(MediaNotiHandle handle, clear_user_data_cb clear_cb)
+{
+       int idx = -1;
+       int ret = MS_MEDIA_ERR_NONE;
+       int err;
+
+       if (handle == NULL) {
+               MSAPI_DBG_ERR("INVALID PARAMETER");
+               return MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       g_mutex_lock(&mutex_internal);
+
+       err = _find_handle(handle, &idx);
+       if(err == MS_MEDIA_ERR_NONE) {
+               DBusConnection *dbus = ((internal_noti_cb_data*)handle)->dbus;
+
+               dbus_connection_remove_filter(dbus, __message_filter_internal, (internal_noti_cb_data*)handle);
+               dbus_bus_remove_match (dbus, MS_MEDIA_DBUS_MATCH_RULE, NULL);
+               dbus_connection_close(dbus);
+               dbus_connection_unref(dbus);
+               g_array_remove_index(handle_list_internal, idx);
+
+               if (clear_cb != NULL)
+                       clear_cb(((internal_noti_cb_data*)handle)->user_data);
+
+               MS_SAFE_FREE(handle);
+
+               if ((handle_list_internal != NULL) && (handle_list_internal->len == 0)) {
+                       g_array_free(handle_list_internal, FALSE);
+                       handle_list_internal = NULL;
+               }
+       } else {
+               MSAPI_DBG_ERR("PARAMETER DOES NOT FIND");
+               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       g_mutex_unlock(&mutex_internal);
+
+       return ret;
+}
+
+
index 6011333..938a974 100755 (executable)
@@ -272,3 +272,86 @@ int media_db_update_send(int pid, /* mandatory */
        /* Return TRUE to tell the event loop we want to be called again */
        return MS_MEDIA_ERR_NONE;
 }
+
+int media_db_update_send_v2(int pid, /* mandatory */
+                                                       media_item_type_e item, /* mandatory */
+                                                       media_item_update_type_e update_type, /* mandatory */
+                                                       char* path, /* mandatory */
+                                                       char* uuid, /* optional */
+                                                       media_type_e media_type, /* optional */
+                                                       char *mime_type /* optional */
+                                                       )
+{
+       GVariant *message = NULL;
+       GDBusConnection *bus = NULL;
+       GError *error = NULL;
+
+       bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!bus) {
+               MSAPI_DBG ("Failed to get gdbus connection: %s", error->message);
+               g_error_free (error);
+               return MS_MEDIA_ERR_INTERNAL;
+       }
+
+       if (item == MS_MEDIA_ITEM_FILE) {
+               MSAPI_DBG("FILE CHANGED");
+               if (uuid != NULL && mime_type != NULL) {
+                       /* fill all datas */
+                       message = g_variant_new("(iiissis)", item, pid, update_type, path, uuid, media_type, mime_type);
+               } else {
+                       MSAPI_DBG_ERR("uuid or mime_type is NULL");
+                       return MS_MEDIA_ERR_INVALID_PARAMETER;
+               }
+       } else if (item == MS_MEDIA_ITEM_DIRECTORY) {
+               MSAPI_DBG("DIRECTORY CHANGED");
+               /* fill all datas */
+               if(uuid != NULL) {
+                       message = g_variant_new("(iiiss)", item, pid, update_type, path, uuid);
+               } else {
+                       message = g_variant_new("(iiis)", item, pid, update_type, path);
+               }
+       } else {
+               MSAPI_DBG("this request is wrong");
+       }
+
+       gboolean emmiting = g_dbus_connection_emit_signal(
+                                       bus,
+                                       NULL,
+                                       MS_MEDIA_DBUS_PATH,
+                                       MS_MEDIA_DBUS_INTERFACE,
+                                       MS_MEDIA_DBUS_NAME,
+                                       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);
+               }
+               return MS_MEDIA_ERR_INTERNAL;
+       }
+       MSAPI_DBG("success send notification");
+
+       gboolean flush = FALSE;
+       flush = g_dbus_connection_flush_sync(bus, NULL, &error);
+       if (!flush)
+       {
+               MSAPI_DBG_ERR("g_dbus_connection_flush_sync failed");
+               if (error)
+               {
+                       MSAPI_DBG_ERR("error : [%s]", error->message);
+                       g_object_unref(bus);
+                       g_error_free(error);
+                       return MS_MEDIA_ERR_INTERNAL;
+               }
+       }
+
+       g_object_unref(bus);
+
+       /* Return TRUE to tell the event loop we want to be called again */
+       return MS_MEDIA_ERR_NONE;
+}
+
diff --git a/media_content_config.ini b/media_content_config.ini
new file mode 100644 (file)
index 0000000..582874c
--- /dev/null
@@ -0,0 +1,12 @@
+;thumbnail_activation level
+; 0 = Deny all requests related thumbnail (never activate thumbnail server)
+; 1 = Allow all requests related thumbnail
+; 2 = Allow user request only
+
+[media-content-config]
+thumbnail_activation=1
+
+;scanner_type
+; 0 = extract all data at once
+; 1 = 2 step scanning
+scanner_type=0
index 481247a..6ad4032 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    File manager service server.
-Version:    0.2.59
+Version:    0.2.60
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
@@ -21,6 +21,7 @@ BuildRequires:  pkgconfig(dbus-glib-1)
 BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(db-util)
 BuildRequires:  pkgconfig(notification)
+BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(cynara-client)
@@ -80,6 +81,10 @@ install -m 0775 ./data-media/dbspace/file-manager-service/.thumb/phone/PHONE_THU
 install -m 0775 ./data-media/dbspace/file-manager-service/.thumb/phone/.jpg* %{buildroot}%{TZ_SYS_DATA}/file-manager-service/.thumb/phone/
 install -D -m 0775 ./data-media/dbspace/file-manager-service/* %{buildroot}%{TZ_SYS_DATA}/file-manager-service/
 
+#ini file
+mkdir -p %{buildroot}/usr/etc
+cp -rf %{_builddir}/%{name}-%{version}/media_content_config.ini %{buildroot}/usr/etc/
+
 %post
 vconftool set -t int db/filemanager/dbupdate "1" -f
 vconftool set -t int memory/filemanager/Mmc "0" -i -f
@@ -110,6 +115,7 @@ ln -sf ../media-server-user.path  %{_unitdir_user}/default.target.wants/
 %{_unitdir}/multi-user.target.wants/media-server.service
 %{_unitdir_user}/media-server-user.service
 %{_unitdir_user}/media-server-user.path
+/usr/etc/media_content_config.ini
 %license LICENSE.APLv2.0
 %{TZ_SYS_DATA}/data-media/*
 %{TZ_SYS_DATA}/file-manager-service/.thumb/*
index ccb29a6..648c04d 100755 (executable)
@@ -45,6 +45,12 @@ typedef enum {
        MS_NOTI_SWITCH_OFF = 1,
 } ms_noti_switch_e;
 
+typedef enum {
+       MS_ITEM_INSERT          = 0,
+       MS_ITEM_DELETE          = 1,
+       MS_ITEM_UPDATE          = 2,
+}ms_noti_type_e;
+
 typedef int (*CONNECT)(void**, uid_t, char **);
 typedef int (*DISCONNECT)(void*, char **);
 typedef int (*INSERT_ITEM_BEGIN)(void*, int, int, int, char **);
@@ -54,20 +60,20 @@ typedef int (*SET_ITEM_VALIDITY_END)(void*, uid_t, char **);
 typedef int (*UPDATE_BEGIN)(void);
 typedef int (*UPDATE_END)(const char *, uid_t);
 
-typedef int (*SEND_DIR_UPDATE_NOTI)(void *, const char *, const char *, char **);
+typedef int (*SEND_DIR_UPDATE_NOTI)(void *, const char *, const char *, const char *, int, int, char **);
 typedef int (*CHECK_ITEM_EXIST)(void*, const char *, const char *, bool*, char **);
-typedef int (*INSERT_ITEM)(void*, const char*, const char *, int, uid_t, char **);
-typedef int (*INSERT_ITEM_IMMEDIATELY)(void*, const char *, const char *, int, uid_t, char **);
+typedef int (*INSERT_ITEM)(void*, const char *, const char *, int, uid_t, char **);
+typedef int (*INSERT_ITEM_IMMEDIATELY)(void *, const char *, const char *, int, uid_t, char **);
 typedef int (*INSERT_BURST_ITEM)(void *, const char *, const char *, int, uid_t, char **);
-typedef int (*SET_ALL_STORAGE_ITEMS_VALIDITY)(void*, const char *, int, int, uid_t, char **);
-typedef int (*SET_FOLDER_ITEM_VALIDITY)(void*, const char*, const char *, int, int, uid_t, char**);
-typedef int (*SET_ITEM_VALIDITY)(void*, const char*, const char *, int, int, uid_t, char **);
+typedef int (*SET_ALL_STORAGE_ITEMS_VALIDITY)(void *, const char *, int, int, uid_t, char **);
+typedef int (*SET_FOLDER_ITEM_VALIDITY)(void *, const char *, const char *, int, int, uid_t, char**);
+typedef int (*SET_ITEM_VALIDITY)(void *, const char *, const char *, int, int, uid_t, char **);
 typedef int (*DELETE_ITEM)(void *, const char *, const char *, uid_t, char **);
-typedef int (*DELETE_ALL_ITEMS_IN_STORAGE)(void*, const char *, int, uid_t, char **);
-typedef int (*DELETE_ALL_INVALID_ITMES_IN_STORAGE)(void*, const char *, int, uid_t, char **);
-typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(void*, const char *, const char*, bool, uid_t, char**);
+typedef int (*DELETE_ALL_ITEMS_IN_STORAGE)(void *, const char *, int, uid_t, char **);
+typedef int (*DELETE_ALL_INVALID_ITMES_IN_STORAGE)(void *, const char *, int, uid_t, char **);
+typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(void *, const char *, const char *, bool, uid_t, char**);
 typedef int (*COUNT_DELETE_ITEMS_IN_FOLDER)(void *, const char *, const char *, int *, char **);
-typedef int (*GET_FOLDER_LIST)(void *, const char *, char*, char ***, int **, int *, char **);
+typedef int (*GET_FOLDER_LIST)(void *, const char *, char *, char ***, int **, int **, int *, char **);
 typedef int (*UPDATE_FOLDER_TIME)(void *, const char *, const char *, uid_t, char **);
 typedef int (*GET_STORAGE_ID)(void *, const char *, char *, char **);
 typedef int (*GET_STORAGE_SCAN_STATUS)(void *, const char *, int *, char **);
@@ -94,6 +100,11 @@ typedef int (*UPDATE_ITEM_META)(void *, const char *, int, uid_t, char **);
 typedef int (*UPDATE_ITEM_BEGIN)(void *, int, char **);
 typedef int (*UPDATE_ITEM_END)(void *, uid_t, char **);
 
+typedef int (*DELETE_INVALID_FOLDER_BY_PATH)(void*, const char*, const char*, uid_t, int *, char **);
+typedef int (*CHECK_FOLDER_EXIST)(void*, const char*, const char*, char **);
+typedef int (*COUNT_SUBFOLDER)(void*, const char*, const char*, int *, char **);
+typedef int (*GET_FOLDER_ID)(void *, const char *, const char *, char *, char **);
+
 int ms_load_functions(void);
 void ms_unload_functions(void);
 int ms_get_insert_count();
@@ -110,7 +121,7 @@ int ms_validaty_change_all_items(void **handle, const char *storage_id, ms_stora
 bool ms_delete_invalid_items(void **handle, const char *storage_id, ms_storage_type_t store_type, uid_t uid);
 int ms_set_folder_item_validity(void **handle, const char *storage_id, const char *path, int validity, int recursive, uid_t uid);
 int ms_delete_invalid_items_in_folder(void **handle, const char *storage_id, const char *path, bool is_recursive, uid_t uid);
-int ms_send_dir_update_noti(void **handle, const char *storage_id, const char *path);
+int ms_send_dir_update_noti(void **handle, const char *storage_id, const char *path, const char *folder_id, ms_noti_type_e noti_type, int pid);
 int ms_count_delete_items_in_folder(void **handle, const char *storage_id, const char*path, int *count);
 int ms_get_folder_list(void **handle, const char *storage_id, char* start_path, GArray **dir_array);
 int ms_update_folder_time(void **handle, const char *storage_id, char *folder_path, uid_t uid);
@@ -133,6 +144,12 @@ int ms_delete_storage(void **handle, const char *storage_id, const char *storage
 int ms_set_storage_validity(void **handle, const char *storage_id, int validity, uid_t uid);
 int ms_set_all_storage_validity(void **handle, int validity, uid_t uid);
 int ms_update_meta_batch(void **handle, const char *path, uid_t uid);
+int ms_delete_invalid_folder_by_path(void **handle, const char *storage_id, const char *folder_path, uid_t uid, int *delete_count);
+int ms_check_folder_exist(void **handle, const char *storage_id, const char *folder_path);
+int ms_check_subfolder_count(void **handle, const char *storage_id, const char *folder_path, int *count);
+int ms_get_folder_id(void **handle, const char *storage_id, const char *path, char **folder_id);
+int ms_get_delete_count();
+void ms_reset_delete_count();
 
 /****************************************************************************************************
 FOR BULK COMMIT
index 944b8f3..5101682 100755 (executable)
@@ -42,13 +42,17 @@ typedef struct ms_block_info_s{
        int block_type;
 } ms_block_info_s;
 
-typedef void (*block_changed_cb)(const char *mount_path, int block_type, ms_stg_status_e mount_status, void *user_data);
+typedef void (*block_changed_cb)(ms_block_info_s *block_info, void *user_data);
 int ms_sys_set_device_block_event_cb(block_changed_cb usr_callback, void *usr_data);
 int ms_sys_unset_device_block_event_cb(void);
 int ms_sys_get_device_list(ms_stg_type_e stg_type, GArray **dev_list);
 int ms_sys_release_device_list(GArray **dev_list);
 
-typedef void (*power_off_cb)(void *user_data);
+typedef struct ms_power_info_s{
+       int option;
+} ms_power_info_s;
+
+typedef void (*power_off_cb)(ms_power_info_s *power_info, void *user_data);
 int ms_sys_set_poweroff_cb(power_off_cb user_callback, void *user_data);
 int ms_sys_unset_poweroff_cb(void);
 
index cdbf708..9e7b3f7 100755 (executable)
@@ -59,6 +59,8 @@
 
 #define MS_SOCK_NOT_ALLOCATE -1
 
+#define MS_INI_DEFAULT_PATH "/usr/etc/media_content_config.ini"
+
 typedef enum {
        MS_STORAGE_INTERNAL = 0,        /**< The device's internal storage */
        MS_STORAGE_EXTERNAL = 1,        /**< The device's external storage */
index 26feabc..5cfbbe6 100755 (executable)
@@ -39,6 +39,7 @@ static void ***func_array;
 static int lib_num;
 static void **func_handle = NULL; /*dlopen handel*/
 static int insert_count;
+static int delete_count;
 
 enum func_list {
        eCONNECT,
@@ -86,6 +87,10 @@ enum func_list {
        eUPDATE_ITEM_META,
        eUPDATE_ITEM_BEGIN,
        eUPDATE_ITEM_END,
+       eDELETE_INVALID_FOLDER_BY_PATH,
+       eCHECK_FOLDER_EXIST,
+       eCOUNT_SUBFOLDER,
+       eGET_FOLDER_ID,
        eFUNC_MAX
 };
 
@@ -185,6 +190,10 @@ int ms_load_functions(void)
                "update_item_meta",
                "update_item_begin",
                "update_item_end",
+               "delete_invalid_folder_by_path",
+               "check_folder_exist",
+               "count_subfolder",
+               "get_folder_id",
                };
        /*init array for adding name of so*/
        so_array = g_array_new(FALSE, FALSE, sizeof(char*));
@@ -301,11 +310,21 @@ int ms_get_insert_count()
        return insert_count;
 }
 
+int ms_get_delete_count()
+{
+       return delete_count;
+}
+
 void ms_reset_insert_count()
 {
        insert_count = 0;
 }
 
+void ms_reset_delete_count()
+{
+       delete_count = 0;
+}
+
 int ms_connect_db(void ***handle, uid_t uid)
 {
        int lib_index;
@@ -668,14 +687,14 @@ int ms_delete_invalid_items_in_folder(void **handle, const char* storage_id, con
        return MS_MEDIA_ERR_NONE;
 }
 
-int ms_send_dir_update_noti(void **handle, const char* storage_id, const char*path)
+int ms_send_dir_update_noti(void **handle, const char* storage_id, const char*path, const char*folder_id, ms_noti_type_e noti_type, int pid)
 {
        int lib_index;
        int ret;
        char *err_msg = NULL;
 
        for (lib_index = 0; lib_index < lib_num; lib_index++) {
-               ret = ((SEND_DIR_UPDATE_NOTI)func_array[lib_index][eSEND_DIR_UPDATE_NOTI])(handle[lib_index], storage_id, path, &err_msg); /*dlopen*/
+               ret = ((SEND_DIR_UPDATE_NOTI)func_array[lib_index][eSEND_DIR_UPDATE_NOTI])(handle[lib_index], storage_id, path, folder_id, (int)noti_type, pid, &err_msg); /*dlopen*/
                if (ret != 0) {
                        MS_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
                        MS_SAFE_FREE(err_msg);
@@ -701,6 +720,8 @@ int ms_count_delete_items_in_folder(void **handle, const char *storage_id, const
                }
        }
 
+       delete_count = *count;
+
        return MS_MEDIA_ERR_NONE;
 }
 
@@ -712,6 +733,7 @@ int ms_get_folder_list(void **handle, const char* storage_id, char* start_path,
 
        char **folder_list = NULL;
        int *modified_time_list = NULL;
+       int *item_num_list = NULL;
        int count = 0;
        int i = 0;
 
@@ -719,7 +741,7 @@ int ms_get_folder_list(void **handle, const char* storage_id, char* start_path,
        MS_DBG("start path: %s", start_path);
 
        for (lib_index = 0; lib_index < lib_num; lib_index++) {
-               ret = ((GET_FOLDER_LIST)func_array[lib_index][eGET_FOLDER_LIST])(handle[lib_index], storage_id, start_path, &folder_list, &modified_time_list, &count, &err_msg); /*dlopen*/
+               ret = ((GET_FOLDER_LIST)func_array[lib_index][eGET_FOLDER_LIST])(handle[lib_index], storage_id, start_path, &folder_list, &modified_time_list, &item_num_list, &count, &err_msg); /*dlopen*/
                if (ret != 0) {
                        MS_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
                        MS_SAFE_FREE(err_msg);
@@ -734,6 +756,7 @@ int ms_get_folder_list(void **handle, const char* storage_id, char* start_path,
                        if (dir_info != NULL) {
                                dir_info->dir_path = strdup(folder_list[i]);
                                dir_info->modified_time = modified_time_list[i];
+                               dir_info->item_num= item_num_list[i];
                                g_array_append_val(*dir_array, dir_info);
                        } else {
                                MS_DBG_ERR("malloc failed");
@@ -1144,6 +1167,95 @@ int ms_update_meta_batch(void **handle, const char *path, uid_t uid)
        return res;
 }
 
+int ms_delete_invalid_folder_by_path(void **handle, const char *storage_id, const char *folder_path, uid_t uid, int *delete_count)
+{
+       int lib_index;
+       int res = MS_MEDIA_ERR_NONE;
+       int ret;
+       char *err_msg = NULL;
+
+       for (lib_index = 0; lib_index < lib_num; lib_index++) {
+               ret = ((DELETE_INVALID_FOLDER_BY_PATH)func_array[lib_index][eDELETE_INVALID_FOLDER_BY_PATH])(handle[lib_index], storage_id, folder_path, uid, delete_count, &err_msg); /*dlopen*/
+               if (ret != 0) {
+                       MS_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, storage_id);
+                       MS_SAFE_FREE(err_msg);
+                       res = MS_MEDIA_ERR_DB_INSERT_FAIL;
+               }
+       }
+
+       return res;
+}
+
+int ms_check_folder_exist(void **handle, const char *storage_id, const char *folder_path)
+{
+       int lib_index;
+       int res = MS_MEDIA_ERR_NONE;
+       int ret;
+       char *err_msg = NULL;
+
+       for (lib_index = 0; lib_index < lib_num; lib_index++) {
+               ret = ((CHECK_FOLDER_EXIST)func_array[lib_index][eCHECK_FOLDER_EXIST])(handle[lib_index], storage_id, folder_path, &err_msg); /*dlopen*/
+               if (ret != 0) {
+                       MS_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, storage_id);
+                       MS_SAFE_FREE(err_msg);
+                       res = MS_MEDIA_ERR_DB_INSERT_FAIL;
+               }
+       }
+
+       return res;
+}
+
+int ms_check_subfolder_count(void **handle, const char *storage_id, const char *folder_path, int *count)
+{
+       int lib_index;
+       int res = MS_MEDIA_ERR_NONE;
+       int ret;
+       int cnt = 0;
+       char *err_msg = NULL;
+
+       for (lib_index = 0; lib_index < lib_num; lib_index++) {
+               ret = ((COUNT_SUBFOLDER)func_array[lib_index][eCOUNT_SUBFOLDER])(handle[lib_index], storage_id, folder_path, &cnt, &err_msg); /*dlopen*/
+               if (ret != 0) {
+                       MS_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, storage_id);
+                       MS_SAFE_FREE(err_msg);
+                       res = MS_MEDIA_ERR_DB_INSERT_FAIL;
+               }
+       }
+
+       *count = cnt;
+
+       return res;
+}
+
+int ms_get_folder_id(void **handle, const char *storage_id, const char *path, char **folder_id)
+{
+       int lib_index;
+       int res = MS_MEDIA_ERR_NONE;
+       int ret;
+       char *err_msg = NULL;
+       char folder_uuid[MS_UUID_SIZE] = {0,};
+
+       MS_DBG_FENTER();
+
+       for (lib_index = 0; lib_index < lib_num; lib_index++) {
+               ret = ((GET_FOLDER_ID)func_array[lib_index][eGET_FOLDER_ID])(handle[lib_index], storage_id, path, folder_uuid, &err_msg); /*dlopen*/
+               if (ret != 0) {
+                       MS_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
+                       MS_SAFE_FREE(err_msg);
+                       res = MS_MEDIA_ERR_DB_UPDATE_FAIL;
+               }
+       }
+
+       if (strlen(folder_uuid) == (MS_UUID_SIZE-1)) {
+               *folder_id = strdup(folder_uuid);
+       } else {
+               *folder_id = NULL;
+       }
+
+       MS_DBG("folder_id [%s]", folder_id);
+
+       return res;
+}
 
 /****************************************************************************************************
 FOR BULK COMMIT
index 43f6ecb..41d371f 100755 (executable)
@@ -79,32 +79,43 @@ static void __ms_block_changed(GDBusConnection* connection,
                                        gpointer user_data)
 {
        const char *devnode = NULL;
-       const char *mount_point = NULL;
+       const char *mount_path = NULL;
        GVariant *tmp;
-       int block_type;
-       int state;
        gsize size = 0;
        block_cb_data *cb_data = (block_cb_data *)user_data;
        void *usr_cb = cb_data->usr_cb;
        void *usr_data = cb_data->usr_data;
+       ms_block_info_s *block_info = NULL;
+
+       MS_MALLOC(block_info, sizeof(ms_block_info_s));
+       if (block_info == NULL) {
+               MS_DBG_ERR("malloc failed");
+               return;
+       }
 
        tmp = g_variant_get_child_value(parameters, 0);
-       block_type = g_variant_get_int32(tmp);
-       MS_DBG_ERR("block_type : %d", block_type);
+       block_info->block_type = g_variant_get_int32(tmp);
+       MS_DBG_ERR("block_type : %d", block_info->block_type);
 
        tmp = g_variant_get_child_value(parameters, 1);
        devnode = g_variant_get_string (tmp, &size);
        MS_DBG_ERR("devnode : %s", devnode);
 
        tmp = g_variant_get_child_value(parameters, 8);
-       mount_point = g_variant_get_string (tmp, &size);
-       MS_DBG_ERR("mount_point : %s", mount_point);
+       mount_path = g_variant_get_string (tmp, &size);
+       if (mount_path != NULL) {
+               block_info->mount_path = strdup(mount_path);
+               MS_DBG_ERR("mount_point : %s", block_info->mount_path);
+       }
 
        tmp = g_variant_get_child_value(parameters, 9);
-       state = g_variant_get_int32 (tmp);
-       MS_DBG_ERR("state : %d", state);
+       block_info->state = g_variant_get_int32 (tmp);
+       MS_DBG_ERR("state : %d", block_info->state);
+
+       ((block_changed_cb)usr_cb)(block_info, usr_data);
+       MS_SAFE_FREE(block_info->mount_path);
+       MS_SAFE_FREE(block_info);
 
-       ((block_changed_cb)usr_cb)(mount_point, block_type, state, usr_data);
        MS_DBG_ERR("user callback done");
 }
 
@@ -472,6 +483,7 @@ static DBusHandlerResult __poweroff_msg_filter (DBusConnection *connection, DBus
                DBusMessageIter read_iter;
                DBusBasicValue value;
                power_off_cb cb_func = (power_off_cb)usr_cb;
+               ms_power_info_s *power_info = NULL;
 
                dbus_error_init (&error);
 
@@ -497,7 +509,7 @@ static DBusHandlerResult __poweroff_msg_filter (DBusConnection *connection, DBus
                }
 
                if (value.i32 == 2 || value.i32 == 3)
-                       cb_func(usr_data);
+                       cb_func(power_info, usr_data);
 
                return DBUS_HANDLER_RESULT_HANDLED;
        }
index 4bba92d..62b7cb7 100755 (executable)
@@ -94,7 +94,6 @@ static char* __media_get_path(uid_t uid)
 {
        char *result_psswd = NULL;
        struct group *grpinfo = NULL;
-       int err = 0;
 
        if (uid == getuid()) {
                result_psswd = strndup(MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL));
index 59cc8ba..bb73520 100755 (executable)
@@ -24,6 +24,6 @@
 
 #include "media-common-system.h"
 
-void msc_device_block_changed_cb(const char *mount_path, int block_type, ms_stg_status_e mount_status, void *user_data);
+void msc_device_block_changed_cb(ms_block_info_s *block_info, void *user_data);
 
 #endif
\ No newline at end of file
index 5d10c79..7ac1c34 100755 (executable)
@@ -53,17 +53,17 @@ void _msc_mmc_changed_event(const char *mount_path, ms_stg_status_e mount_status
 }
 
 
-void msc_device_block_changed_cb(const char *mount_path, int block_type, ms_stg_status_e mount_status, void *user_data)
+void msc_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
 {
-       if (block_type == 0) {
+       if (block_info->block_type == 0) {
                MS_DBG_ERR("GET THE USB EVENT");
-               if (mount_status == MS_STG_INSERTED) {
+               if (block_info->state == MS_STG_INSERTED) {
                        /*DO NOT THING*/
                } else {
-                       __msc_usb_remove_event(mount_path);
+                       __msc_usb_remove_event(block_info->mount_path);
                }
        } else {
                MS_DBG_ERR("GET THE MMC EVENT");
-               _msc_mmc_changed_event(mount_path, mount_status);
+               _msc_mmc_changed_event(block_info->mount_path, block_info->state);
        }
 }
index 5ae6a35..f499056 100755 (executable)
@@ -65,7 +65,8 @@ extern struct timeval g_mmc_end_time;
 static int __msc_set_power_mode(ms_db_status_type_t status);
 static int __msc_set_db_status(ms_db_status_type_t status, ms_storage_type_t storage_type);
 static int __msc_check_stop_status(ms_storage_type_t storage_type);
-static int __msc_dir_scan(void **handle, const char *storage_id, const char*start_path, ms_storage_type_t storage_type, int scan_type, uid_t uid);
+static int __msc_stg_scan(void **handle, const char *storage_id, const char*start_path, ms_storage_type_t storage_type, int scan_type, uid_t uid);
+static int __msc_dir_scan(void **handle, const char *storage_id, const char*start_path, ms_storage_type_t storage_type, int scan_type, bool is_recursive, uid_t uid);
 static int __msc_db_update(void **handle, const char *storage_id, const ms_comm_msg_s * scan_data);
 static int __msc_check_file_path(const char *file_path, uid_t uid);
 static bool __msc_check_folder_path(const char *folder_path);
@@ -75,7 +76,7 @@ static int __msc_pop_register_request(GArray *register_array, ms_comm_msg_s **re
 static int __msc_clear_file_list(GArray *path_array);
 static bool __msc_check_scan_ignore(char * path);
 static bool __msc_is_valid_path(const char *path, uid_t uid);
-static void __msc_check_dir_path(char *dir_path);
+static void __msc_trim_dir_path(char *dir_path);
 static void __msc_insert_register_request(GArray *register_array, ms_comm_msg_s *insert_data);
 static void __msc_bacth_commit_enable(void* handle, bool ins_status, bool valid_status, bool noti_enable, int pid);
 static void __msc_bacth_commit_disable(void* handle, bool ins_status, bool valid_status, const char *path, uid_t uid);
@@ -270,7 +271,7 @@ static int __msc_check_stop_status(ms_storage_type_t storage_type)
        return ret;
 }
 
-static void __msc_check_dir_path(char *dir_path)
+static void __msc_trim_dir_path(char *dir_path)
 {
        /* need implementation */
        /* if dir_path is not NULL terminated, this function will occure crash */
@@ -296,7 +297,155 @@ static bool __msc_check_mount_storage(const char* start_path)
        return ret;
 }
 
-static int __msc_dir_scan(void **handle, const char *storage_id, const char*start_path, ms_storage_type_t storage_type, int scan_type, uid_t uid)
+static int __msc_read_dir(void **handle, GArray *dir_array, const char *start_path, const char *storage_id, ms_storage_type_t storage_type, int scan_type, uid_t uid)
+{
+       DIR *dp = NULL;
+       struct dirent entry;
+       struct dirent *result = NULL;
+       int ret = MS_MEDIA_ERR_NONE;
+       char *new_path = NULL;
+       char *current_path = NULL;
+       char path[MS_FILE_PATH_LEN_MAX] = { 0 };
+       int (*scan_function)(void **, const char*, const char*, uid_t) = NULL;
+
+       if (dir_array != NULL) {
+               MS_DBG_ERR("dir_array is NULL");
+               return MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       /* make new array for storing directory */
+       dir_array = g_array_new (FALSE, FALSE, sizeof (char*));
+       if (dir_array == NULL){
+               MS_DBG_ERR("g_array_new failed");
+               return MS_MEDIA_ERR_OUT_OF_MEMORY;
+       }
+
+       g_array_append_val (dir_array, start_path);
+
+       scan_function = (scan_type == MS_MSG_STORAGE_ALL) ? ms_insert_item_batch : ms_validate_item;
+
+       /*start db update. the number of element in the array , db update is complete.*/
+       while (dir_array->len != 0) {
+               /*check poweroff status*/
+               ret = __msc_check_stop_status(storage_type);
+               if (ret != MS_MEDIA_ERR_NONE) {
+                       goto STOP_DIR_SCAN;
+               }
+               /* get the current path from directory array */
+               current_path = g_array_index(dir_array , char*, 0);
+               g_array_remove_index (dir_array, 0);
+               MS_DBG_SLOG("%d", dir_array->len);
+
+               if (__msc_check_scan_ignore(current_path)) {
+                       MS_DBG_ERR("%s is ignore", current_path);
+                       MS_SAFE_FREE(current_path);
+                       continue;
+               }
+
+               ms_insert_folder_start(handle);
+
+               dp = opendir(current_path);
+               if (dp != NULL) {
+                       /*insert current directory*/
+                       if(ms_insert_folder(handle, storage_id, current_path, uid) != MS_MEDIA_ERR_NONE) {
+                               MS_DBG_ERR("insert folder failed");
+                       }
+
+                       while (!readdir_r(dp, &entry, &result)) {
+                               /*check poweroff status*/
+                               ret = __msc_check_stop_status(storage_type);
+                               if (ret != MS_MEDIA_ERR_NONE) {
+                                       ms_insert_folder_end(handle, uid);
+                                       goto STOP_DIR_SCAN;
+                               }
+
+                               if (result == NULL)
+                                       break;
+
+                               if (entry.d_name[0] == '.')
+                                       continue;
+
+                               if (ms_strappend(path, sizeof(path), "%s/%s", current_path, entry.d_name) != MS_MEDIA_ERR_NONE) {
+                                       MS_DBG_ERR("ms_strappend failed");
+                                       continue;
+                               }
+
+                               if (entry.d_type & DT_REG) {
+                                       /* insert into media DB */
+                                       if (scan_function(handle,storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+                                               MS_DBG_ERR("failed to update db : %d", scan_type);
+                                               continue;
+                                       }
+                               } else if (entry.d_type & DT_DIR) {
+                                       if      (scan_type != MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
+                                               /* this request is recursive scanning */
+                                               /* add new directory to dir_array */
+                                               new_path = strdup(path);
+                                               if (new_path != NULL) {
+                                                       g_array_append_val (dir_array, new_path);
+                                               } else {
+                                                       MS_DBG_ERR("strdup failed");
+                                                       continue;
+                                               }
+                                       } else {
+                                               /* this request is recursive scanning */
+                                               /* don't add new directory to dir_array */
+                                               if(ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+                                                       MS_DBG_ERR("insert folder failed");
+                                               }
+                                       }
+                               }
+                       }
+               } else {
+                       MS_DBG_ERR("%s folder opendir fails", current_path);
+               }
+               if (dp) closedir(dp);
+               dp = NULL;
+
+               ms_insert_folder_end(handle, uid);
+
+               MS_SAFE_FREE(current_path);
+       }
+
+STOP_DIR_SCAN:
+       if (dp) closedir(dp);
+       __msc_clear_file_list(dir_array);
+
+       return ret;
+
+}
+
+static int __msc_dir_scan(void **handle, const char *storage_id, const char*start_path, ms_storage_type_t storage_type, int scan_type, bool is_recursive, uid_t uid)
+{
+       GArray *dir_array = NULL;
+       int ret = MS_MEDIA_ERR_NONE;
+       char *new_start_path = NULL;
+
+       new_start_path = strdup(start_path);
+       if (new_start_path == NULL) {
+               MS_DBG_ERR("g_array_new failed");
+               return MS_MEDIA_ERR_OUT_OF_MEMORY;
+       }
+
+       MS_DBG_ERR("[No-Error] start path [%s]", new_start_path);
+
+       /*call for bundle commit*/
+       __msc_bacth_commit_enable(handle, TRUE, TRUE, MS_NOTI_SWITCH_OFF, 0);
+
+       __msc_read_dir(handle, dir_array, start_path, storage_id, storage_type, scan_type, uid);
+
+       /*call for bundle commit*/
+       __msc_bacth_commit_disable(handle, TRUE, TRUE, new_start_path, uid);
+
+       MS_SAFE_FREE(new_start_path);
+
+       MS_DBG_INFO("ret : %d", ret);
+
+       return ret;
+}
+
+
+static int __msc_stg_scan(void **handle, const char *storage_id, const char*start_path, ms_storage_type_t storage_type, int scan_type, uid_t uid)
 {
        DIR *dp = NULL;
        GArray *dir_array = NULL;
@@ -415,7 +564,7 @@ static int __msc_dir_scan(void **handle, const char *storage_id, const char*star
                                }
                        }
                        /* update modified time of directory */
-                       if (scan_type == MS_MSG_STORAGE_PARTIAL && storage_type == MS_STORAGE_INTERNAL)
+                       if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE && storage_type == MS_STORAGE_INTERNAL)
                                ms_update_folder_time(handle, INTERNAL_STORAGE_ID, current_path, uid);
                } else {
                        MS_DBG_ERR("%s folder opendir fails", current_path);
@@ -429,16 +578,15 @@ static int __msc_dir_scan(void **handle, const char *storage_id, const char*star
        }               /*db update while */
 
                /*remove invalid folder in folder table.*/
-       if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL) {
-               if (__msc_check_mount_storage(new_start_path)) {
-                       if(ms_delete_invalid_folder(handle, storage_id, uid) != MS_MEDIA_ERR_NONE) {
-                               MS_DBG_ERR("delete invalid folder failed");
-                               ret =  MS_MEDIA_ERR_DB_DELETE_FAIL;
-                       }
-               } else {
-                       MS_DBG_ERR("start path is unmounted");
+       if (__msc_check_mount_storage(new_start_path)) {
+               if(ms_delete_invalid_folder(handle, storage_id, uid) != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("delete invalid folder failed");
+                       ret =  MS_MEDIA_ERR_DB_DELETE_FAIL;
                }
+       } else {
+               MS_DBG_ERR("start path is unmounted");
        }
+
 STOP_SCAN:
        if (dp) closedir(dp);
 
@@ -466,7 +614,7 @@ static int __msc_db_update(void **handle, const char *storage_id, const ms_comm_
        if (scan_type != MS_MSG_STORAGE_INVALID) {
                MS_DBG_INFO("INSERT");
 
-               err = __msc_dir_scan(handle, storage_id, start_path, storage_type, scan_type, scan_data->uid);
+               err = __msc_stg_scan(handle, storage_id, start_path, storage_type, scan_type, scan_data->uid);
                if (err != MS_MEDIA_ERR_NONE) {
                        MS_DBG_ERR("error : %d", err);
                }
@@ -492,12 +640,19 @@ static int __msc_db_update(void **handle, const char *storage_id, const ms_comm_
 gboolean msc_directory_scan_thread(void *data)
 {
        ms_comm_msg_s *scan_data = NULL;
-       int err;
-       int ret;
+       int ret = MS_MEDIA_ERR_NONE;
        void **handle = NULL;
        int scan_type;
-       char *noti_path = NULL;
        char *storage_id = NULL;
+       bool is_recursive = true;
+       char *start_path = NULL;
+       ms_storage_type_t storage_type;
+       ms_noti_type_e noti_type = MS_ITEM_INSERT;
+       int before_count = 0;
+       int after_count = 0;
+       int delete_count = 0;
+       int delete_folder_count = 0;
+       char *folder_uuid = NULL;
 
        while (1) {
                scan_data = g_async_queue_pop(scan_queue);
@@ -509,9 +664,11 @@ gboolean msc_directory_scan_thread(void *data)
                MS_DBG_ERR("DIRECTORY SCAN START [%s %d]", scan_data->msg, scan_data->msg_type);
 
                /*connect to media db, if conneting is failed, db updating is stopped*/
-               err = ms_connect_db(&handle, scan_data->uid);
-               if (err != MS_MEDIA_ERR_NONE)
+               ret = ms_connect_db(&handle, scan_data->uid);
+               if (ret != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("ms_connect_db failed");
                        continue;
+               }
 
                scan_type = scan_data->msg_type;
 
@@ -520,7 +677,6 @@ gboolean msc_directory_scan_thread(void *data)
                else
                        storage_id = strdup("media");
 
-               //storage_id = strdup(scan_data->storage_id);
                if (storage_id == NULL) {
                        MS_DBG_ERR("storage_id NULL");
                        ret = MS_MEDIA_ERR_INVALID_PARAMETER;
@@ -542,49 +698,89 @@ gboolean msc_directory_scan_thread(void *data)
                        goto NEXT;
                }
 
-               __msc_check_dir_path(scan_data->msg);
+               __msc_trim_dir_path(scan_data->msg);
 
-               /*change validity before scanning*/
-               if (scan_type == MS_MSG_DIRECTORY_SCANNING)
-                       err = ms_set_folder_item_validity(handle, storage_id, scan_data->msg, MS_INVALID, MS_RECURSIVE, scan_data->uid);
-               else
-                       err = ms_set_folder_item_validity(handle, storage_id, scan_data->msg, MS_INVALID, MS_NON_RECURSIVE, scan_data->uid);
-               if (err != MS_MEDIA_ERR_NONE)
-                       MS_DBG_ERR("error : %d", err);
+               if (__msc_check_folder_path(scan_data->msg)) {
+                       is_recursive = (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) ? false : true;
 
-               /*call for bundle commit*/
-               __msc_bacth_commit_enable(handle, TRUE, TRUE, MS_NOTI_SWITCH_OFF, 0);
+                       if (ms_check_folder_exist(handle, storage_id, scan_data->msg) == MS_MEDIA_ERR_NONE) {
+                               /*already exist in media DB*/
+                               noti_type = MS_ITEM_UPDATE;
+                               MS_DBG_ERR("[%s] already exist", scan_data->msg);
+                       } else {
+                               noti_type = MS_ITEM_INSERT;
+                               MS_DBG_ERR("[%s] new insert path", scan_data->msg);
+                       }
+               } else {
+                       /*directory is deleted*/
+                       is_recursive = true;
+                       noti_type = MS_ITEM_DELETE;
+
+                       /*get the UUID of deleted folder*/
+                       ms_get_folder_id(handle, storage_id, scan_data->msg, &folder_uuid);
+
+                       MS_DBG_ERR("[%s][%s] delete path", scan_data->msg, folder_uuid);
+               }
+
+               ms_check_subfolder_count(handle, storage_id, scan_data->msg, &before_count);
+               MS_DBG_ERR("BEFORE COUNT[%d]", before_count);
+
+               /* folder validity set 0 under the start_path in folder table*/
+               if(ms_set_folder_validity(handle, storage_id, scan_data->msg, MS_INVALID, is_recursive, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("set_folder_validity failed [%d] ", scan_type);
+               }
+
+               /*change validity before scanning*/
+               if (ms_set_folder_item_validity(handle, storage_id, scan_data->msg, MS_INVALID, is_recursive, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("set_folder_validity failed [%d] ", scan_type);
+               }
 
                /*insert data into media db */
-               ret = __msc_db_update(handle, storage_id, scan_data);
+               storage_type = ms_get_storage_type_by_full(scan_data->msg, scan_data->uid);
+               start_path = strndup(scan_data->msg, scan_data->msg_size);
 
-               /*call for bundle commit*/
-               __msc_bacth_commit_disable(handle, TRUE, TRUE, scan_data->msg, scan_data->uid);
+               ret = __msc_dir_scan(handle, storage_id, start_path, storage_type, scan_data->msg_type, is_recursive, scan_data->uid);
 
-               if (ret == MS_MEDIA_ERR_NONE) {
-                       MS_DBG_INFO("working normally");
-                       int count = 0;
-                       bool is_recursive = true;
-                       int insert_count = ms_get_insert_count();
+               ms_check_subfolder_count(handle, storage_id, scan_data->msg, &after_count);
+               MS_DBG_ERR("BEFORE COUNT[%d]", before_count);
+
+               if (ms_count_delete_items_in_folder(handle, storage_id, scan_data->msg, &delete_count) != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("counting invalid items failed");
+               }
+               
+               if (ms_delete_invalid_items_in_folder(handle, storage_id, scan_data->msg, is_recursive, scan_data->uid)  != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("deleting invalid items in folder failed");
+               }
+               
+               /*remove invalid folder in folder table.*/
+               if(ms_delete_invalid_folder_by_path(handle, storage_id, scan_data->msg, scan_data->uid, &delete_folder_count) != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("deleting invalid folder failed");
+               }
 
-                       noti_path = strndup(scan_data->msg, scan_data->msg_size);
-                       ms_count_delete_items_in_folder(handle, storage_id, noti_path, &count);
+               MS_DBG_SLOG("delete folder count %d", delete_folder_count);
 
-                       MS_DBG_SLOG("delete count %d", count);
-                       MS_DBG_SLOG("insert count %d", insert_count);
+               if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
+                       MS_DBG_INFO("working normally");
 
-                       if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE)
-                               is_recursive = false;
+                       if (noti_type != MS_ITEM_UPDATE) {
+                               ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
+                       } else {
+                               int insert_count = ms_get_insert_count();
+                               int delete_count = ms_get_delete_count();
 
-                       ms_delete_invalid_items_in_folder(handle, storage_id, scan_data->msg, is_recursive, scan_data->uid);
+                               MS_DBG_SLOG("delete count %d", delete_count);
+                               MS_DBG_SLOG("insert count %d", insert_count);
 
-                       if ( !(count == 0 && insert_count == 0)) {
-                               ms_send_dir_update_noti(handle, storage_id, noti_path);
+                               if (!(delete_count == 0 && insert_count == 0) 
+                                       || !(before_count == after_count)
+                                       || delete_folder_count != 0) {
+                                       ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
+                               }
                        }
-                       MS_SAFE_FREE(noti_path);
                }
 
                ms_reset_insert_count();
+               ms_reset_delete_count();
 
                if (power_off) {
                        MS_DBG_WARN("power off");
@@ -601,6 +797,7 @@ NEXT:
 
                MS_SAFE_FREE(scan_data);
                MS_SAFE_FREE(storage_id);
+               MS_SAFE_FREE(folder_uuid);
 
                MS_DBG_INFO("DIRECTORY SCAN END [%d]", ret);
        }                       /*thread while*/
@@ -699,7 +896,7 @@ static int __msc_compare_with_db(void **handle, const char *storage_id, const ch
                /* get the current path from directory array */
                current_path = g_array_index(read_dir_array , char*, 0);
                g_array_remove_index (read_dir_array, 0);
-//             MSC_DBG_ERR("%s", current_path);
+//             MS_DBG_ERR("%s", current_path);
 
                if (__msc_check_scan_ignore(current_path)) {
                        MS_DBG_ERR("%s is ignore", current_path);
@@ -769,7 +966,7 @@ static int _msc_db_update_partial(void **handle, const char *storage_id, ms_stor
                        }
                }
 
-               __msc_dir_scan(handle, storage_id, update_path, storage_type, MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE, uid);
+               __msc_stg_scan(handle, storage_id, update_path, storage_type, MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE, uid);
 
 //             if (dir_info->modified_time != -1) {
 //                     ms_update_folder_time(handle, tmp_path);
@@ -901,7 +1098,7 @@ gboolean msc_storage_scan_thread(void *data)
                }
 
                /* send notification */
-               ms_send_dir_update_noti(handle,  storage_id, update_path);
+               ms_send_dir_update_noti(handle,  storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
 
 #ifdef FMS_PERF
                ms_check_end_time(&g_mmc_end_time);
@@ -1474,8 +1671,7 @@ STOP_SCAN:
 gboolean msc_metadata_update(void *data)
 {
        ms_comm_msg_s *scan_data = data;
-       int err;
-       int ret;
+       int ret = MS_MEDIA_ERR_NONE;
        void **handle = NULL;
        char *start_path = NULL;
        ms_storage_type_t storage_type = MS_STORAGE_INTERNAL;
@@ -1483,27 +1679,26 @@ gboolean msc_metadata_update(void *data)
        MS_DBG_INFO("META UPDATE START");
 
        /*connect to media db, if conneting is failed, db updating is stopped*/
-       err = ms_connect_db(&handle, scan_data->uid);
-       if (err != MS_MEDIA_ERR_NONE)
+       ret = ms_connect_db(&handle, scan_data->uid);
+       if (ret != MS_MEDIA_ERR_NONE)
                return false;
 
        /*call for bundle commit*/
        ms_update_start(handle);
 
        /*insert data into media db */
-
        start_path = strdup(__msc_get_path(scan_data->uid));
        ret = __msc_dir_scan_meta_update(handle, start_path, storage_type, scan_data->uid);
 
        /* send notification */
-       ms_send_dir_update_noti(handle, INTERNAL_STORAGE_ID, __msc_get_path(scan_data->uid));
+       ms_send_dir_update_noti(handle, INTERNAL_STORAGE_ID, __msc_get_path(scan_data->uid), NULL, MS_ITEM_UPDATE, scan_data->pid);
 
        if (mmc_state == MS_STG_INSERTED) {
                storage_type = MS_STORAGE_EXTERNAL;
                start_path = strdup(MEDIA_ROOT_PATH_SDCARD);
                ret = __msc_dir_scan_meta_update(handle, start_path, storage_type, scan_data->uid);
                /* send notification */
-               ms_send_dir_update_noti(handle, MMC_STORAGE_ID, MEDIA_ROOT_PATH_SDCARD);
+               ms_send_dir_update_noti(handle, MMC_STORAGE_ID, MEDIA_ROOT_PATH_SDCARD, NULL, MS_ITEM_UPDATE, scan_data->pid);
        }
 
        /*FIX ME*/
index bcfd537..b41c6b9 100755 (executable)
@@ -39,7 +39,7 @@
 
 static GMainLoop *scanner_mainloop = NULL;
 
-static void __msc_power_off_cb(void* data);
+static void __msc_power_off_cb(ms_power_info_s *power_info, void* data);
 static void __msc_add_event_receiver(void *data);
 static void __msc_remove_event_receiver(void);
 
@@ -141,7 +141,7 @@ EXIT:
        return 0;
 }
 
-static void __msc_power_off_cb(void* data)
+static void __msc_power_off_cb(ms_power_info_s *power_info, void* data)
 {
        msc_send_power_off_request();
 
index 111d3cd..d55075c 100755 (executable)
@@ -27,6 +27,6 @@ int ms_mmc_insert_handler(const char *mount_path);
 int ms_mmc_remove_handler(const char *mount_path);
 int ms_usb_insert_handler(const char *mount_path);
 int ms_usb_remove_handler(const char *mount_path);
-void ms_device_block_changed_cb(const char *mount_path, int block_type, ms_stg_status_e mount_status, void *user_data);
+void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data);
 
 #endif
\ No newline at end of file
index 40045b6..62d5588 100755 (executable)
@@ -22,6 +22,7 @@
 #include <glib.h>
 #include <sys/un.h>
 #include <arpa/inet.h>
+#include <iniparser.h>
 #include "media-common-types.h"
 #include "media-server-ipc.h"
 
@@ -34,6 +35,7 @@ GMainLoop * ms_get_thumb_thread_mainloop(void);
 int ms_thumb_get_server_pid();
 void ms_thumb_reset_server_status();
 gpointer ms_thumb_agent_start_thread(gpointer data);
+int ms_thumb_get_config();
 
 #endif /*_MEDIA_SERVER_THUMB_H_*/
 
index b13caa2..ecd45b4 100755 (executable)
@@ -361,14 +361,14 @@ void _ms_usb_changed_event(const char *mount_path, ms_stg_status_e mount_status)
        return;
 }
 
-void ms_device_block_changed_cb(const char *mount_path, int block_type, ms_stg_status_e mount_status, void *user_data)
+void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
 {
-       if (block_type == 0) {
+       if (block_info->block_type == 0) {
                MS_DBG_ERR("GET THE USB EVENT");
-               _ms_usb_changed_event(mount_path, mount_status);
+               _ms_usb_changed_event(block_info->mount_path, block_info->state);
        } else {
                MS_DBG_ERR("GET THE MMC EVENT");
-               _ms_mmc_changed_event(mount_path, mount_status);
+               _ms_mmc_changed_event(block_info->mount_path, block_info->state);
        }
 }
 
index 8445233..152c7a4 100755 (executable)
@@ -56,7 +56,7 @@ static int __ms_check_usb_status(void);
 
 static char *priv_lang = NULL;
 
-void _power_off_cb(void* data)
+void _power_off_cb(ms_power_info_s *power_info, void* data)
 {
        MS_DBG_ERR("POWER OFF");
 
@@ -231,6 +231,8 @@ int main(int argc, char **argv)
        /*Active flush */
        malloc_trim(0);
 
+       /*Read ini file */
+       ms_thumb_get_config();
 
        MS_DBG_ERR("*** Media Server is running ***");
 
index 93931c3..9ceee0b 100755 (executable)
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <iniparser.h>
 
 #include "media-util.h"
 #include "media-server-ipc.h"
@@ -40,6 +41,7 @@
 #define MS_NO_REMAIN_TASK 0
 
 #define MEDIA_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN,"media-scanner")
+#define MEDIA_SERVER_PATH_V2 tzplatform_mkpath(TZ_SYS_BIN,"media-scanner-v2")
 
 extern GMainLoop *mainloop;
 extern GArray *owner_list;
@@ -128,6 +130,25 @@ static gboolean _ms_stop_scanner (gpointer user_data)
        return FALSE;
 }
 
+static int _ms_get_ini_config(const char *key)
+{
+       dictionary *dict = NULL;
+       int value = 0;
+
+       dict = iniparser_load(MS_INI_DEFAULT_PATH);
+       if(!dict) {
+               MS_DBG_ERR("%s load failed", MS_INI_DEFAULT_PATH);
+               return 0;
+       }
+
+       value = iniparser_getint(dict, key, 0);
+       MS_DBG("Key = [%s], Value = [%d]", key, value);
+
+       iniparser_freedict(dict);
+
+       return value;
+}
+
 void ms_cleanup_scanner(void)
 {
        g_mutex_lock(&scanner_mutex);
@@ -251,7 +272,11 @@ int ms_scanner_start(void)
                MS_DBG_ERR("[No-Error] CHILD PROCESS");
                MS_DBG("[No-Error] EXECUTE MEDIA SCANNER");
 
-               execl(MEDIA_SERVER_PATH, "media-scanner", NULL);
+               if(_ms_get_ini_config("media-content-config:scanner_type") == 1)
+                       execl(MEDIA_SERVER_PATH_V2, "media-scanner-v2", NULL);
+               else
+                       execl(MEDIA_SERVER_PATH, "media-scanner", NULL);
+
                g_mutex_unlock(&scanner_mutex);
        }
 
index db9ebe9..bbaaba2 100755 (executable)
 
 #define THUMB_SERVER_NAME "media-thumbnail"
 #define MS_SOCK_BLOCK_SIZE 512
+#define MS_INI_GET_INT(dict, key, value, default) \
+       do { \
+               value = iniparser_getint(dict, key, default); \
+               MS_DBG("get %s = %d", key, value); \
+       } while(0)
 #define THUMB_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN,"media-thumbnail-server")
 
 gboolean _ms_thumb_agent_timer();
@@ -50,6 +55,7 @@ static gboolean g_thumb_server_queued_all_extracting_request = FALSE;
 static int g_communicate_sock = 0;
 static int g_timer_id = 0;
 static int g_server_pid = 0;
+static int g_thumb_server_active = -1;
 
 static GQueue *g_request_queue = NULL;
 static int g_queue_work = 0;
@@ -1030,6 +1036,23 @@ gboolean _ms_thumb_agent_prepare_tcp_socket(int *sock_fd, unsigned short serv_po
        return TRUE;
 }
 
+int ms_thumb_get_config()
+{
+       dictionary *dict = NULL;
+
+       dict = iniparser_load(MS_INI_DEFAULT_PATH);
+       if(!dict) {
+               MS_DBG_ERR("%s load failed", MS_INI_DEFAULT_PATH);
+               return -1;
+       }
+
+       MS_INI_GET_INT(dict, "media-content-config:thumbnail_activation",g_thumb_server_active, 0);
+       MS_DBG("Thumb-server activation level = %d", g_thumb_server_active);
+
+       iniparser_freedict(dict);
+       return 0;
+}
+
 gpointer ms_thumb_agent_start_thread(gpointer data)
 {
        MS_DBG("");