for beta release
authorYong Yeon Kim <yy9875.kim@samsung.com>
Fri, 10 Feb 2012 06:01:05 +0000 (15:01 +0900)
committerYong Yeon Kim <yy9875.kim@samsung.com>
Fri, 10 Feb 2012 06:01:05 +0000 (15:01 +0900)
19 files changed:
common/include/media-server-db-svc.h [new file with mode: 0755]
common/include/media-server-error.h
common/include/media-server-external-storage.h [new file with mode: 0755]
common/include/media-server-global.h
common/include/media-server-inotify-internal.h
common/include/media-server-inotify.h
common/include/media-server-scan-internal.h
common/include/media-server-types.h
common/include/media-server-utils.h [new file with mode: 0755]
common/media-server-db-svc.c [new file with mode: 0755]
common/media-server-external-storage.c [new file with mode: 0755]
common/media-server-inotify-internal.c
common/media-server-inotify.c
common/media-server-main.c
common/media-server-scan-internal.c
common/media-server-scan.c
common/media-server-socket.c
common/media-server-utils.c [new file with mode: 0755]
debian/control

diff --git a/common/include/media-server-db-svc.h b/common/include/media-server-db-svc.h
new file mode 100755 (executable)
index 0000000..f3d9577
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ *  Media Server
+ *
+ * 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-server-db-svc.h
+ * @author     Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version    1.0
+ * @brief
+ */
+#include <media-svc.h>
+#include "media-server-global.h"
+
+int
+ms_update_valid_type(MediaSvcHandle *handle, char *path);
+
+int
+ms_media_db_open(MediaSvcHandle **handle);
+
+int
+ms_media_db_close(MediaSvcHandle *handle);
+
+void
+ms_register_start(MediaSvcHandle *handle);
+
+void
+ms_register_end(MediaSvcHandle *handle);
+
+int
+ms_register_file(MediaSvcHandle *handle, const char *path, GAsyncQueue* queue);
+
+int
+ms_register_scanfile(MediaSvcHandle *handle, const char *path);
+
+void
+ms_update_valid_type_start(MediaSvcHandle *handle);
+
+void
+ms_update_valid_type_end(MediaSvcHandle *handle);
+
+int
+ms_change_valid_type(MediaSvcHandle *handle, ms_store_type_t table_id, bool validation);
+
+#ifdef THUMB_THREAD
+int
+ms_media_db_insert_with_thumb(MediaSvcHandle *handle, const char *path, int category);
+#endif
+
+int
+ms_media_db_insert(MediaSvcHandle *handle, const char *path, int category, bool bulk);
+
+int
+ms_check_file_exist_in_db(MediaSvcHandle *handle, const char *file_full_path);
+
+int
+ms_media_db_delete(MediaSvcHandle *handle, const char *full_file_path);
+
+void
+ms_media_db_move_start(MediaSvcHandle *handle);
+
+void
+ms_media_db_move_end(MediaSvcHandle *handle);
+
+int
+ms_media_db_move(MediaSvcHandle *handle,
+                       ms_store_type_t src_store_type,
+                       ms_store_type_t dest_store_type,
+                       const char *src_file_full_path,
+                       const char *dest_file_full_path);
+
+bool
+ms_delete_all_record(MediaSvcHandle *handle, ms_store_type_t store_type);
+
+bool
+ms_delete_invalid_records(MediaSvcHandle *handle, ms_store_type_t store_type);
\ No newline at end of file
index 131a273..ff2ff1a 100755 (executable)
@@ -28,8 +28,8 @@
  * @brief              
  */
 
-#ifndef _FEXPLORER_ENGINE_ERROR_H_
-#define _FEXPLORER_ENGINE_ERROR_H_
+#ifndef _MEDIA_SERVER_ERROR_H_
+#define _MEDIA_SERVER_ERROR_H_
 
 #define ERROR_MASKL16       0xFFFF
 #define ERROR(X)        (X & ERROR_MASKL16)
@@ -84,8 +84,8 @@
 #define MS_ERR_VCONF_GET_FAIL                          (MID_CONTENTS_MGR_ERROR - ERROR(0x63))   /**< vconf get fail*/
 #define MS_ERR_NOT_MEDIA_FILE                          (MID_CONTENTS_MGR_ERROR - ERROR(0x64))   /**< not media file*/
 
-#define MS_ERR_MAX                                                     (MID_CONTENTS_MGR_ERROR - ERROR(0xff))   /**< Max count*/
-#endif                         /* _FEXPLORER_ENGINE_ERROR_H_ */
+#define MS_ERR_MAX                                                     (MID_CONTENTS_MGR_ERROR - ERROR(0xff))   /**< not media file*/
+#endif/* _MEDIA_SERVER_ERROR_H_ */
 /**
  * @}
  */
diff --git a/common/include/media-server-external-storage.h b/common/include/media-server-external-storage.h
new file mode 100755 (executable)
index 0000000..342d0de
--- /dev/null
@@ -0,0 +1,14 @@
+void\r
+ms_make_default_path_mmc(void);\r
+\r
+int\r
+ms_update_mmc_info(void);
+
+void
+ms_mmc_removed_handler(void);
+
+void
+ms_mmc_vconf_cb(void *data);\r
+\r
+ms_dir_scan_type_t
+ms_get_mmc_state(void);
\ No newline at end of file
index a3c588e..07ca548 100755 (executable)
@@ -28,8 +28,8 @@
  * @brief              
  */
 
-#ifndef _FEXPLORER_ENGINEGLOBAL_H_
-#define _FEXPLORER_ENGINEGLOBAL_H_
+#ifndef _MEDIA_SERVER_GLOBAL_H_
+#define _MEDIA_SERVER_GLOBAL_H_
 #include <malloc.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include "media-server-error.h"
 #include "media-server-types.h"
 
-#define _WITH_MP_PB_
-#define _WITH_DRM_SERVICE_     /*drm-servic3 */
-#define _WITH_SETTING_AND_NOTI_        /*replace gconf-dbus */
 #define FMS_PERF
 
-/* To enable hibernation callback */
-/*#define _USE_HIB*/
-
 /* To enable progress bar in quickpanel */
 /*#define PROGRESS*/
 
-/* To enable thumbnail thread*/
-/*#define THUMB_THREAD*/
-
-#define FEXPLORER_DEBUG
-#ifndef DEPRECATED             /*temp definition for deprecated */
-#define DEPRECATED __attribute__((deprecated))
-#endif
-
-#ifdef FEXPLORER_DEBUG
 #ifdef LOG_TAG
 #undef LOG_TAG
 #endif
 #define MS_DBG_END()                  LOGD("[%d, %s-%d] ========[  END  ]========\n" ,syscall(__NR_gettid), __func__ , __LINE__);
 #define MS_DBG_FUNC_LINE()      LOGD("[%s-%d] debug\n" , __func__ , __LINE__);
 #define MS_DBG(fmt, args...)        LOGD("[%d, %s-%d] " fmt "\n" , syscall(__NR_gettid), __func__ , __LINE__ , ##args);
-#endif                         /*FEXPLORER_DEBUG */
-
-#define MS_DRM_CONTENT_TYPE_LENGTH 100
-#define MS_REGISTER_COUNT 100 /*For bundle commit*/
-#define MS_VALID_COUNT 100 /*For bundle commit*/
-#define MS_MOVE_COUNT 100 /*For bundle commit*/
-
-/* in case of 32 bytes machine*/
-#define DUMMY_FIELD_LEN_32(n)           ((((n-1) / 8 + 1) * 2) / sizeof(long) + 6)
 
 #define MALLOC(a) malloc(a)
 #define FREE(a) free(a)
 #define MS_MMC_ROOT_PATH               "opt/storage/sdcard"
 #define MS_DB_UPDATE_NOTI_PATH "/opt/data/file-manager-service"
 
-#define end_thread 100
-
 /*This macro is used to check the lastest usb mode*/
 #define MS_USB_MODE_KEY "db/Apps/mediaserver/usbmode"
 enum {
        MS_VCONFKEY_NORMAL_MODE = 0x00,
        MS_VCONFKEY_MASS_STORAGE_MODE = 0x01
 };
+
+/*This macro is used to save and check information of inserted memory card*/
 #define MS_MMC_INFO_KEY "db/Apps/mediaserver/mmc_info"
 
-#define MS_THUMB_STATUS "db/Apps/mediaserver/thumb_status"
-enum {
-       MS_VCONFKEY_THUMB_NONE = 0x00,
-       MS_VCONFKEY_THUMB_PAUSE = 0x01,
-       MS_VCONFKEY_THUMB_RESUME = 0x02
-};
 /**
  * @}
  */
 
-#endif /*_FEXPLORER_ENGINEGLOBAL_H_*/
+#endif /*_MEDIA_SERVER_GLOBAL_H_*/
index 88548be..b408b96 100755 (executable)
@@ -48,8 +48,6 @@ int _ms_inoti_delete_create_file_list(ms_create_file_info *node);
 
 ms_create_file_info *_ms_inoti_find_create_file_list(int wd, char *name);
 
-int _fex_is_default_path(const char *path);
-
 bool _ms_inoti_full_path(int wd, char *name, char *path, int sizeofpath);
 
 bool _ms_inoti_get_full_path(int wd, char *name, char *path, int sizeofpath);
index 184a599..845bfcb 100755 (executable)
  * @brief
  */
 
-#ifndef _FEXPLORER_ENGINE_INOTI_H_
-#define _FEXPLORER_ENGINE_INOTI_H_
+#ifndef _MEDIA_SERVER_INOTI_H_
+#define _MEDIA_SERVER_INOTI_H_
 
 #include <glib.h>
+#include "media-server-global.h"
 
 typedef struct ms_ignore_file_info {
        char *path;
@@ -60,4 +61,4 @@ int ms_inoti_delete_ignore_file(ms_ignore_file_info * delete_node);
 ms_ignore_file_info *ms_inoti_find_ignore_file(const char *path);
 
 void ms_inoti_delete_mmc_ignore_file(void);
-#endif                         /* _FEXPLORER_ENGINE_INOTI_H_ */
+#endif/* _MEDIA_SERVER_INOTI_H_ */
index 7837792..c3563e5 100755 (executable)
@@ -32,7 +32,7 @@
 
 #ifdef PROGRESS
 struct quickpanel;
-void _ms_dir_scan(ms_scan_data_t * scan_data, struct quickpanel *ms_quickpanel);
+void _ms_dir_scan(MediaSvcHandle *handle, ms_scan_data_t * scan_data, struct quickpanel *ms_quickpanel);
 #else
-void _ms_dir_scan(ms_scan_data_t * scan_data);
+void _ms_dir_scan(MediaSvcHandle *handle, ms_scan_data_t * scan_data);
 #endif
index da63a7c..bafe88f 100755 (executable)
@@ -31,8 +31,8 @@
 #include <stdbool.h>
 #include <glib.h>
 
-#ifndef _FEXPLORER_TYPES_H_
-#define _FEXPLORER_TYPES_H_
+#ifndef _MEDIA_SERVER_TYPES_H_
+#define _MEDIA_SERVER_TYPES_H_
 
 #if !defined(__TYPEDEF_INT64__)
 #define __TYPEDEF_INT64__
@@ -96,4 +96,4 @@ typedef struct ms_dir_data {
  * @}
  */
 
-#endif /*_FEXPLORER_TYPES_H_*/
+#endif /*_MEDIA_SERVER_TYPES_H_*/
diff --git a/common/include/media-server-utils.h b/common/include/media-server-utils.h
new file mode 100755 (executable)
index 0000000..f4da8ff
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *  Media Server
+ *
+ * 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-server-utils.h
+ * @author     Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version    1.0
+ * @brief
+ */
+
+#ifndef _MEDIA_SERVER_UTILS_H__
+#define _MEDIA_SERVER_UTILS_H__
+
+#include <sqlite3.h>
+#include "media-server-global.h"
+
+int
+ms_set_db_status(ms_db_status_type_t status);
+
+int
+ms_db_init(bool need_db_create);
+
+bool
+ms_is_mmc_inserted(void);
+
+void
+ms_usb_vconf_cb(void *data);
+
+int
+ms_start(bool need_db_create);
+
+void
+ms_end(void);
+
+int
+ms_get_full_path_from_node(ms_dir_scan_info * const node, char *ret_path);
+
+ms_store_type_t
+ms_get_store_type_by_full(const char *path);
+
+int
+ms_strappend(char *res, const int size, const char *pattern,
+                const char *str1, const char *str2);
+
+int
+ms_strcopy(char *res, const int size, const char *pattern,
+              const char *str1);
+
+bool
+ms_config_get_int(const char *key, int *value);
+
+bool
+ms_config_set_int(const char *key, int value);
+
+bool
+ms_config_get_str(const char *key, char *value);
+
+bool
+ms_config_set_str(const char *key, const char *value);
+
+void
+ms_check_db_updating(void);
+
+int
+ms_get_category_from_mime(const char *path, int *category);
+
+#ifdef FMS_PERF
+void
+ms_check_start_time(struct timeval *start_time);
+
+void
+ms_check_end_time(struct timeval *end_time);
+
+void
+ms_check_time_diff(struct timeval *start_time, struct timeval *end_time);
+#endif/*FMS_PERF */
+
+#ifdef PROGRESS
+struct quickpanel;
+
+void
+ms_create_quickpanel(struct quickpanel *ms_quickpanel);
+
+void
+ms_update_progress(struct quickpanel *ms_quickpanel, double progress);
+
+void
+ms_delete_quickpanel(struct quickpanel *ms_quickpanel);
+#endif /*PROGRSS*/
+/**
+ * @}
+ */
+#endif/*_MEDIA_SERVER_UTILS_H__*/
+
diff --git a/common/media-server-db-svc.c b/common/media-server-db-svc.c
new file mode 100755 (executable)
index 0000000..b72be77
--- /dev/null
@@ -0,0 +1,766 @@
+/*
+ *  Media Server
+ *
+ * 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-server-db-svc.c
+ * @author     Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version    1.0
+ * @brief       This file implements main database operation.
+ */
+#include <db-util.h>
+#include <drm-service.h>
+#include <media-thumbnail.h>
+#include <visual-svc-error.h>
+#include <visual-svc-types.h>
+#include <visual-svc.h>
+#include <audio-svc-error.h>
+#include <audio-svc-types.h>
+#include <audio-svc.h>
+
+#include "media-server-utils.h"
+#include "media-server-inotify.h"
+#include "media-server-db-svc.h"
+
+GMutex * db_mutex;
+extern GMutex *queue_mutex;
+
+GAsyncQueue* soc_queue;
+GArray *reg_list;
+GMutex *list_mutex;
+GMutex *queue_mutex;
+
+#define MS_REGISTER_COUNT 100 /*For bundle commit*/
+#define MS_VALID_COUNT 100 /*For bundle commit*/
+#define MS_MOVE_COUNT 100 /*For bundle commit*/
+
+void _ms_insert_reg_list(const char *path)
+{
+       char *reg_path = strdup(path);
+
+       g_mutex_lock(list_mutex);
+
+       g_array_append_val(reg_list, reg_path);
+
+       g_mutex_unlock(list_mutex);
+}
+
+bool _ms_find_reg_list(const char *path)
+{
+       int i;
+       int len = reg_list->len;
+       char *data;
+       bool ret = false;
+
+       g_mutex_lock(list_mutex);
+       MS_DBG("array length : %d", len);
+
+       for(i = 0; i < len; i++) {
+               data = g_array_index (reg_list, char*, i);
+               if(!strcmp(data, path))
+                       ret = true;
+       }
+
+       g_mutex_unlock(list_mutex);
+
+       return ret;
+}
+
+void _ms_delete_reg_list(const char *path)
+{
+       int i;
+       int len = reg_list->len;
+       char *data;
+
+       MS_DBG("Delete : %s", path);
+       g_mutex_lock(list_mutex);
+
+       for(i = 0; i < len; i++) {
+               data = g_array_index (reg_list, char*, i);
+               MS_DBG("%s", data);
+               if(!strcmp(data, path)) {
+                       MS_DBG("Delete complete : %s", data);
+                       free(data);
+                       g_array_remove_index(reg_list, i);
+                       break;
+               }
+       }
+
+       g_mutex_unlock(list_mutex);
+}
+
+
+
+int
+ms_media_db_open(MediaSvcHandle **handle)
+{
+       int err;
+
+       /*Lock mutex for openning db*/
+       g_mutex_lock(db_mutex);
+
+       err = media_svc_connect(handle);
+       if (err != MEDIA_INFO_ERROR_NONE) {
+               MS_DBG("media_svc_connect() error : %d", err);
+
+               g_mutex_unlock(db_mutex);
+
+               return MS_ERR_DB_CONNECT_FAIL;
+       }
+
+       MS_DBG("connect Media DB");
+
+       g_mutex_unlock(db_mutex);
+
+       return MS_ERR_NONE;
+}
+
+int
+ms_media_db_close(MediaSvcHandle *handle)
+{
+       int err;
+
+       err = media_svc_disconnect(handle);
+       if (err != MEDIA_INFO_ERROR_NONE) {
+               MS_DBG("media_svc_disconnect() error : %d", err);
+               return MS_ERR_DB_DISCONNECT_FAIL;
+       }
+
+       MS_DBG("Disconnect Media DB");
+
+       return MS_ERR_NONE;
+}
+
+int
+ms_update_valid_type(MediaSvcHandle *handle, char *path)
+{
+       MS_DBG_START();
+
+       int res = MS_ERR_NONE;
+       int err;
+       int category = MS_CATEGORY_UNKNOWN;
+
+       MS_DBG("%s", path);
+
+       err = ms_get_category_from_mime(path, &category);
+       if (err < 0) {
+               MS_DBG("ms_get_category_from_mime fails");
+               return err;
+       }
+
+       /*if music, call mp_svc_set_item_valid() */
+       if (category & MS_CATEGORY_MUSIC || category & MS_CATEGORY_SOUND) {
+               /*check exist in Music DB, If file is not exist, insert data in DB. */
+               err = audio_svc_check_item_exist(handle, path);
+               if (err == AUDIO_SVC_ERROR_DB_NO_RECORD) {
+                       MS_DBG("not exist in Music DB. insert data");
+#ifdef THUMB_THREAD
+                       err = ms_media_db_insert_with_thumb(handle, path, category);
+#else
+                       err = ms_media_db_insert(handle, path, category, true);
+#endif
+                       if (err != MS_ERR_NONE) {
+                               MS_DBG ("ms_media_db_insert() error %d", err);
+                               res = err;
+                       }
+               }
+               else if (err == AUDIO_SVC_ERROR_NONE) {
+                       /*if meta data of file exist, change valid field to "1" */
+                       MS_DBG("Item exist");
+
+                       err = audio_svc_set_item_valid(handle, path, true);
+                       if (err != AUDIO_SVC_ERROR_NONE)
+                               MS_DBG("audio_svc_set_item_valid() error : %d", err);
+               }
+               else
+               {
+                       MS_DBG("audio_svc_check_item_exist() error : %d", err);
+                       res = MS_ERR_DB_OPERATION_FAIL;
+               }
+       }
+       /*if file is image file, call mb_svc_set_db_item_valid() */
+       else if (category & MS_CATEGORY_VIDEO || category & MS_CATEGORY_IMAGE) {
+               ms_store_type_t store_type;
+               minfo_store_type mb_stroage;
+
+               store_type = ms_get_store_type_by_full(path);
+               mb_stroage = (store_type == MS_MMC) ? MINFO_MMC : MINFO_PHONE;
+
+               err = minfo_set_item_valid(handle, mb_stroage, path, true);
+               if (err != MB_SVC_ERROR_NONE) {
+                       MS_DBG("not exist in Media DB. insert data");
+
+                       ms_update_valid_type_end(handle);
+
+#ifdef THUMB_THREAD
+                       err = ms_media_db_insert_with_thumb(handle, path, category);
+#else
+                       err = ms_media_db_insert(handle, path, category, true);
+#endif
+                       if (err != MS_ERR_NONE)
+                               MS_DBG("ms_media_db_insert() error : %d", err);
+
+                       ms_update_valid_type_start(handle);
+               }
+               else {
+                       MS_DBG("Item exist");
+               }
+       }
+
+       if (category & MS_CATEGORY_DRM) {
+               DRM_RESULT drm_res;
+
+               ms_inoti_add_ignore_file(path);
+               drm_res = drm_svc_register_file(path);
+               if (drm_res != DRM_RESULT_SUCCESS) {
+                       MS_DBG("drm_svc_register_file error : %d", drm_res);
+                       res = MS_ERR_DRM_REGISTER_FAIL;
+               }
+       }
+
+       MS_DBG_END();
+
+       return res;
+}
+
+int
+ms_change_valid_type(MediaSvcHandle *handle, ms_store_type_t store_type, bool validation)
+{
+       MS_DBG_START();
+       int res = MS_ERR_NONE;
+       int err;
+
+       audio_svc_storage_type_e audio_storage;
+       minfo_store_type visual_storage;
+
+       audio_storage = (store_type == MS_PHONE)
+               ? AUDIO_SVC_STORAGE_PHONE : AUDIO_SVC_STORAGE_MMC;
+       visual_storage = (store_type == MS_PHONE)
+               ? MINFO_PHONE : MINFO_MMC;
+
+       err = audio_svc_set_db_valid(handle, audio_storage, validation);
+       if (err < AUDIO_SVC_ERROR_NONE) {
+               MS_DBG("audio_svc_set_db_valid error :%d", err);
+               res = MS_ERR_DB_OPERATION_FAIL;
+       }
+
+       err = minfo_set_db_valid(handle, visual_storage, validation);
+       if (err < MB_SVC_ERROR_NONE) {
+               MS_DBG("minfo_set_db_valid : error %d", err);
+               res = MS_ERR_DB_OPERATION_FAIL;
+       }
+
+       MS_DBG_END();
+
+       return res;
+}
+
+
+int
+ms_register_file(MediaSvcHandle *handle, const char *path, GAsyncQueue* queue)
+{
+       MS_DBG_START();
+       MS_DBG("[%d]register file : %s", syscall(__NR_gettid), path);
+
+       int err;
+       int category = MS_CATEGORY_UNKNOWN;
+
+       if (path == NULL) {
+               MS_DBG("path == NULL");
+               return MS_ERR_ARG_INVALID;
+       }
+
+       g_mutex_lock(queue_mutex);
+       /*first request for this file*/
+       if(!_ms_find_reg_list(path)) {
+               /*insert registering file list*/
+               _ms_insert_reg_list(path);
+       } else {
+               MS_DBG("______________________ALREADY INSERTING");
+               if(queue != NULL) {
+                       MS_DBG("Need reply");
+                       soc_queue = queue;
+               }
+               g_mutex_unlock(queue_mutex);
+               return MS_ERR_NOW_REGISTER_FILE;
+       }
+       g_mutex_unlock(queue_mutex);
+
+       err = ms_get_category_from_mime(path, &category);
+       if (err != MS_ERR_NONE) {
+               MS_DBG("ms_get_category_from_mime error : %d", err);
+               goto FREE_RESOURCE;
+       }
+
+       if (category <= MS_CATEGORY_ETC) {
+               MS_DBG("This is not media contents");
+               err = MS_ERR_NOT_MEDIA_FILE;
+               goto FREE_RESOURCE;
+       } else {
+#ifdef THUMB_THREAD
+                       err = ms_media_db_insert_with_thumb(handle, path, category);
+#else
+                       err = ms_media_db_insert(handle, path, category, false);
+#endif
+               if (err != MS_ERR_NONE) {
+                       MS_DBG("ms_media_db_insert error : %d", err);
+
+                       /*if music, call mp_svc_set_item_valid() */
+                       if (category & MS_CATEGORY_MUSIC || category & MS_CATEGORY_SOUND) {
+                               /*check exist in Music DB, If file is not exist, insert data in DB. */
+                               err = audio_svc_check_item_exist(handle, path);
+                               if (err == AUDIO_SVC_ERROR_NONE) {
+                                       MS_DBG("Audio Item exist");
+                                       err = MS_ERR_NONE;
+                               }
+                       } else if (category & MS_CATEGORY_VIDEO || category & MS_CATEGORY_IMAGE) {
+                               Mitem *mi = NULL;
+
+                               /*get an item based on its url. */
+                               err = minfo_get_item(handle, path, &mi);
+                               if (err == MB_SVC_ERROR_NONE) {
+                                       MS_DBG("Visual Item exist");
+                                       err = MS_ERR_NONE;
+                               }
+
+                               minfo_destroy_mtype_item(mi);
+                       }
+               }
+
+               if (category & MS_CATEGORY_DRM) {
+                       MS_DBG("THIS IS DRM FILE");
+                       DRM_RESULT res;
+
+                       ms_inoti_add_ignore_file(path);
+                       res = drm_svc_register_file(path);
+                       if (res != DRM_RESULT_SUCCESS) {
+                               MS_DBG("drm_svc_register_file error : %d", res);
+                               err = MS_ERR_DRM_REGISTER_FAIL;
+                       }
+               }
+       }
+
+FREE_RESOURCE:
+       g_mutex_lock(queue_mutex);
+
+       _ms_delete_reg_list(path);
+
+       if (soc_queue != NULL) {
+               MS_DBG("%d", err);
+               g_async_queue_push(soc_queue, GINT_TO_POINTER(err+MS_ERR_MAX));
+               MS_DBG("Return OK");
+       }
+       soc_queue = NULL;
+       g_mutex_unlock(queue_mutex);
+       MS_DBG_END();
+       return err;
+}
+
+int
+ms_register_scanfile(MediaSvcHandle *handle, const char *path)
+{
+       MS_DBG_START();
+       MS_DBG("register scanfile : %s", path);
+
+       int err = MS_ERR_NONE;
+       int category = MS_CATEGORY_UNKNOWN;
+
+       if (path == NULL) {
+               MS_DBG("path == NULL");
+               return MS_ERR_ARG_INVALID;
+       }
+
+       err = ms_get_category_from_mime(path, &category);
+       if (err != MS_ERR_NONE) {
+               MS_DBG("ms_get_category_from_mime error : %d", err);
+               return err;
+       }
+
+       if (category <= MS_CATEGORY_ETC) {
+               MS_DBG("This is not media contents");
+               return MS_ERR_NOT_MEDIA_FILE;
+       }
+
+       err = ms_media_db_insert(handle, path, category, true);
+       if (err != MS_ERR_NONE) {
+               MS_DBG("ms_media_db_insert error : %d", err);
+       }
+
+       if (category & MS_CATEGORY_DRM) {
+               MS_DBG("THIS IS DRM FILE");
+               DRM_RESULT res;
+
+               ms_inoti_add_ignore_file(path);
+
+               res = drm_svc_register_file(path);
+               if (res != DRM_RESULT_SUCCESS) {
+                       MS_DBG("drm_svc_register_file error : %d", err);
+                       err = MS_ERR_DRM_REGISTER_FAIL;
+               }
+       }
+
+       MS_DBG_END();
+       return err;
+}
+
+#ifdef THUMB_THREAD
+int
+ms_media_db_insert_with_thumb(MediaSvcHandle *handle, const char *path, int category)
+{
+       MS_DBG_START();
+       MS_DBG("%s", path);
+
+       int ret = MS_ERR_NONE;
+       int err;
+       ms_store_type_t store_type;
+       audio_svc_category_type_e audio_category;
+       minfo_file_type visual_category;
+       audio_svc_storage_type_e storage;
+
+       if (category & MS_CATEGORY_VIDEO ||category & MS_CATEGORY_IMAGE) {
+               visual_category = (category & MS_CATEGORY_IMAGE)
+                       ? MINFO_ITEM_IMAGE : MINFO_ITEM_VIDEO;
+               err = minfo_add_media(handle, path, visual_category);
+               if (err < 0) {
+                       MS_DBG(" minfo_add_media error %d", err);
+                       ret = MS_ERR_DB_INSERT_RECORD_FAIL;
+               } else {
+                       char thumb_path[1024];
+
+                       err = thumbnail_request_from_db(path, thumb_path, sizeof(thumb_path));
+                       if (err < 0) {
+                               MS_DBG("thumbnail_request_from_db falied: %d", err);
+                       } else {
+                               MS_DBG("thumbnail_request_from_db success: %s", thumb_path);
+                       }
+               }
+
+               MS_DBG("IMAGE");
+       }
+       else if (category & MS_CATEGORY_SOUND || category & MS_CATEGORY_MUSIC) {
+               store_type = ms_get_store_type_by_full(path);
+
+               storage = (store_type == MS_MMC)
+                       ? AUDIO_SVC_STORAGE_MMC : AUDIO_SVC_STORAGE_PHONE;
+               audio_category = (category & MS_CATEGORY_SOUND)
+                       ? AUDIO_SVC_CATEGORY_SOUND : AUDIO_SVC_CATEGORY_MUSIC;
+
+               err = audio_svc_insert_item(handle, storage, path, audio_category);
+               if (err < 0) {
+                       MS_DBG("mp_svc_insert_item fails error %d", err);
+                       ret = MS_ERR_DB_INSERT_RECORD_FAIL;
+               }
+               MS_DBG("SOUND");
+       }
+
+       MS_DBG_END();
+       return ret;
+}
+#endif
+
+int
+ms_media_db_insert(MediaSvcHandle *handle, const char *path, int category, bool bulk)
+{
+       MS_DBG_START();
+       MS_DBG("%s", path);
+
+       int ret = MS_ERR_NONE;
+       int err;
+       ms_store_type_t store_type;
+       audio_svc_category_type_e audio_category;
+       minfo_file_type visual_category;
+       audio_svc_storage_type_e storage;
+
+       if (category & MS_CATEGORY_VIDEO ||category & MS_CATEGORY_IMAGE) {
+               visual_category = (category & MS_CATEGORY_IMAGE)
+                       ? MINFO_ITEM_IMAGE : MINFO_ITEM_VIDEO;
+               if(bulk)
+                       err = minfo_add_media_batch(handle, path, visual_category);
+               else
+                       err = minfo_add_media(handle, path, visual_category);
+               if (err < 0) {
+                       MS_DBG(" minfo_add_media error %d", err);
+                       ret = MS_ERR_DB_INSERT_RECORD_FAIL;
+               }
+#ifndef THUMB_THREAD
+               else {
+                       char thumb_path[1024];
+
+                       err = thumbnail_request_from_db(path, thumb_path, sizeof(thumb_path));
+                       if (err < 0) {
+                               MS_DBG("thumbnail_request_from_db falied: %d", err);
+                       } else {
+                               MS_DBG("thumbnail_request_from_db success: %s", thumb_path);
+                       }
+#endif
+               }
+
+               MS_DBG("IMAGE");
+       }
+       else if (category & MS_CATEGORY_SOUND || category & MS_CATEGORY_MUSIC) {
+               store_type = ms_get_store_type_by_full(path);
+
+               storage = (store_type == MS_MMC)
+                       ? AUDIO_SVC_STORAGE_MMC : AUDIO_SVC_STORAGE_PHONE;
+               audio_category = (category & MS_CATEGORY_SOUND)
+                       ? AUDIO_SVC_CATEGORY_SOUND : AUDIO_SVC_CATEGORY_MUSIC;
+
+               err = audio_svc_insert_item(handle, storage, path, audio_category);
+               if (err < 0) {
+                       MS_DBG("mp_svc_insert_item fails error %d", err);
+                       ret = MS_ERR_DB_INSERT_RECORD_FAIL;
+               }
+               MS_DBG("SOUND");
+       }
+
+       MS_DBG_END();
+       return ret;
+}
+
+
+
+int
+ms_check_file_exist_in_db(MediaSvcHandle *handle, const char *path)
+{
+       int err;
+       int category;
+
+       /*get an item based on its url. */
+       err = minfo_check_item_exist(handle, path);
+       if (err != MS_ERR_NONE) {
+               err = audio_svc_check_item_exist(handle, path);
+               if (err != MS_ERR_NONE)
+                       category = MS_CATEGORY_UNKNOWN;
+               else
+                       category = MS_CATEGORY_MUSIC;
+       } else {
+               category = MS_CATEGORY_IMAGE;
+       }
+
+       MS_DBG("Category : %d", category);
+
+       return category;
+}
+
+int
+ms_media_db_delete(MediaSvcHandle *handle, const char *path)
+{
+       MS_DBG_START();
+       int ret = MS_ERR_NONE;
+       int category;
+       ms_ignore_file_info *ignore_file;
+
+       category = ms_check_file_exist_in_db(handle, path);
+
+       if (category & MS_CATEGORY_VIDEO || category & MS_CATEGORY_IMAGE) {
+               ret = minfo_delete_media(handle, path);
+               if (ret != MS_ERR_NONE) {
+                       MS_DBG("minfo_delete_media error : %d", ret);
+                       return ret;
+               }
+               MS_DBG("VIDEO or IMAGE");
+       } else if (category & MS_CATEGORY_MUSIC || category & MS_CATEGORY_SOUND) {
+               ret = audio_svc_delete_item_by_path(handle, path);
+               if (ret != MS_ERR_NONE) {
+                       MS_DBG("audio_svc_delete_item_by_path error : %d", ret);
+                       return ret;
+               }
+               MS_DBG("MUSIC or SOUND");
+       }
+
+       drm_svc_unregister_file(path, false);
+
+       ignore_file = ms_inoti_find_ignore_file(path);
+       if (ignore_file != NULL)
+               ms_inoti_delete_ignore_file(ignore_file);
+
+       MS_DBG_END();
+
+       return ret;
+}
+
+int
+ms_media_db_move(MediaSvcHandle *handle,
+               ms_store_type_t src_store, ms_store_type_t dst_store,
+               const char *src_path, const char *dst_path)
+{
+       MS_DBG_START();
+
+       int category = MS_CATEGORY_UNKNOWN;
+       minfo_file_type visual_category;
+       audio_svc_storage_type_e dst_storage;
+       audio_svc_storage_type_e src_storage;
+       int ret = 0;
+
+       ret = ms_get_category_from_mime(dst_path, &category);
+       if (ret != MS_ERR_NONE) {
+               MS_DBG("ms_get_category_from_mime error %d", ret);
+               return ret;
+       }
+
+       MS_DBG("category = %d", category);
+
+       if (category & MS_CATEGORY_IMAGE || category & MS_CATEGORY_VIDEO) {
+               visual_category = (category & MS_CATEGORY_IMAGE) ? MINFO_ITEM_IMAGE : MINFO_ITEM_VIDEO;
+               ret = minfo_move_media(handle, src_path, dst_path, visual_category);
+               if (ret != MB_SVC_ERROR_NONE) {
+                       MS_DBG("minfo_move_media error : %d", ret);
+                       return ret;
+               }
+               MS_DBG("VISUAL");
+       } else if (category & MS_CATEGORY_MUSIC || category & MS_CATEGORY_SOUND) {
+               src_storage = (src_store == MS_MMC) ? AUDIO_SVC_STORAGE_MMC : AUDIO_SVC_STORAGE_PHONE;
+               dst_storage = (dst_store == MS_MMC) ? AUDIO_SVC_STORAGE_MMC : AUDIO_SVC_STORAGE_PHONE;
+
+               ret = audio_svc_move_item(handle, src_storage, src_path, dst_storage, dst_path);
+               if (ret < 0) {
+                       MS_DBG("mp_svc_move_item error : %d", ret);
+                       if (ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
+                               MS_DBG(" This is a new file, Add DB");
+                               /*if source file does not exist in DB, it is new file. */
+
+                               ret = ms_register_file(handle, dst_path, NULL);
+
+                               if (ret != MS_ERR_NONE) {
+                                       MS_DBG("ms_register_file error : %d", ret);
+                                       return MS_ERR_DB_INSERT_RECORD_FAIL;
+                               }
+                       }
+
+                       return ret;
+               }
+               MS_DBG("AUDIO");
+       }
+
+       MS_DBG_END();
+
+       return ret;
+}
+
+bool
+ms_delete_all_record(MediaSvcHandle *handle, ms_store_type_t store_type)
+{
+       MS_DBG_START();
+       int err = 0;
+       minfo_store_type visual_storage;
+       audio_svc_storage_type_e audio_storage;
+
+       visual_storage = (store_type == MS_PHONE) ? MINFO_PHONE : MINFO_MMC;
+       audio_storage = (store_type == MS_PHONE) ? AUDIO_SVC_STORAGE_PHONE : AUDIO_SVC_STORAGE_MMC;
+
+       /* To reset media db when differnet mmc is inserted. */
+       err = audio_svc_delete_all(handle, audio_storage);
+       if (err != AUDIO_SVC_ERROR_NONE) {
+               MS_DBG("audio_svc_delete_all error : %d\n", err);
+#if 0 /*except temporary*/
+               return false;
+#endif
+       }
+
+       err = minfo_delete_all_media_records(handle, visual_storage);
+       if (err != MB_SVC_ERROR_NONE) {
+               MS_DBG("minfo_delete_all_media_records error : %d\n", err);
+               return false;
+       }
+
+       MS_DBG_END();
+
+       return true;
+}
+
+
+bool
+ms_delete_invalid_records(MediaSvcHandle *handle, ms_store_type_t store_type)
+{
+       MS_DBG_START();
+       int err;
+       
+       minfo_store_type visual_storage;
+       audio_svc_storage_type_e audio_storage;
+
+       visual_storage = (store_type == MS_PHONE) ? MINFO_PHONE : MINFO_MMC;
+       audio_storage = (store_type == MS_PHONE) ? AUDIO_SVC_STORAGE_PHONE : AUDIO_SVC_STORAGE_MMC;
+
+       err = audio_svc_delete_invalid_items(handle, audio_storage);
+       if (err != AUDIO_SVC_ERROR_NONE) {
+               MS_DBG("audio_svc_delete_invalid_items error : %d\n", err);
+#if 0 /*except temporary*/
+               return false;
+#endif
+       }
+
+       err = minfo_delete_invalid_media_records(handle, visual_storage);
+       if (err != MB_SVC_ERROR_NONE) {
+               MS_DBG("minfo_delete_invalid_media_records error : %d\n", err);
+               return false;
+       }
+
+       MS_DBG_END();
+
+       return true;
+}
+
+/****************************************************************************************************
+FOR BULK COMMIT
+*****************************************************************************************************/
+
+void
+ms_register_start(MediaSvcHandle *handle)
+{
+       minfo_add_media_start(handle, MS_REGISTER_COUNT);
+       audio_svc_insert_item_start(handle, MS_REGISTER_COUNT);
+}
+
+void
+ms_register_end(MediaSvcHandle *handle)
+{
+       minfo_add_media_end(handle);
+       audio_svc_insert_item_end(handle);
+}
+
+void
+ms_update_valid_type_start(MediaSvcHandle *handle)
+{
+       audio_svc_set_item_valid_start(handle, MS_VALID_COUNT);
+       minfo_set_item_valid_start(handle, MS_VALID_COUNT);
+}
+
+void
+ms_update_valid_type_end(MediaSvcHandle *handle)
+{
+       audio_svc_set_item_valid_end(handle);
+       minfo_set_item_valid_end(handle);
+}
+
+void
+ms_media_db_move_start(MediaSvcHandle *handle)
+{
+       audio_svc_move_item_start(handle, MS_MOVE_COUNT);
+       minfo_move_media_start(handle, MS_MOVE_COUNT);
+}
+
+void
+ms_media_db_move_end(MediaSvcHandle *handle)
+{
+       audio_svc_move_item_end(handle);
+       minfo_move_media_end(handle);
+}
diff --git a/common/media-server-external-storage.c b/common/media-server-external-storage.c
new file mode 100755 (executable)
index 0000000..489cbde
--- /dev/null
@@ -0,0 +1,307 @@
+#include <vconf.h>\r
+#include <drm-service.h>\r
+\r
+#include "media-server-utils.h"\r
+#include "media-server-inotify.h"\r
+#include "media-server-external-storage.h"\r
+\r
+#define MMC_INFO_SIZE 256\r
+#define DIR_NUM 5\r
+\r
+int mmc_state = 0;\r
+extern int current_usb_mode;\r
+extern GAsyncQueue *scan_queue;\r
+\r
+void\r
+ms_make_default_path_mmc(void)\r
+{
+       MS_DBG_START();
+
+       int i = 0;
+       int ret = 0;
+       DIR *dp = NULL;
+
+       char default_path[DIR_NUM][MS_FILE_NAME_LEN_MAX + 1] = {
+               {"/opt/storage/sdcard/Images"},
+               {"/opt/storage/sdcard/Videos"},
+               {"/opt/storage/sdcard/Music"},
+               {"/opt/storage/sdcard/Downloads"},
+               {"/opt/storage/sdcard/Camera shots"}
+       };
+
+       for (i = 0; i < DIR_NUM; ++i) {
+               dp = opendir(default_path[i]);
+               if (dp == NULL) {
+                       ret = mkdir(default_path[i], 0777);
+                       if (ret < 0) {
+                               MS_DBG("make fail");
+                       } else {
+                               ms_inoti_add_watch(default_path[i]);
+                       }
+               } else {
+                       closedir(dp);
+               }
+       }
+
+       MS_DBG_END();
+}
+\r
+int\r
+_ms_update_mmc_info(const char *cid)
+{
+       MS_DBG_START();
+       bool res;
+
+       if (cid == NULL) {
+               MS_DBG("Parameters are invalid");
+               return MS_ERR_ARG_INVALID;
+       }
+
+       res = ms_config_set_str(MS_MMC_INFO_KEY, cid);
+       if (!res) {
+               MS_DBG("fail to get MS_MMC_INFO_KEY");
+               return MS_ERR_VCONF_SET_FAIL;
+       }
+
+       MS_DBG_END();
+
+       return MS_ERR_NONE;
+}\r
+\r
+bool\r
+_ms_check_mmc_info(const char *cid)
+{
+       MS_DBG_START();
+
+       char pre_mmc_info[MMC_INFO_SIZE] = { 0 };
+       bool res = false;
+
+       if (cid == NULL) {
+               MS_DBG("Parameters are invalid");
+               return false;
+       }
+
+       res = ms_config_get_str(MS_MMC_INFO_KEY, pre_mmc_info);
+       if (!res) {
+               MS_DBG("fail to get MS_MMC_INFO_KEY");
+               return false;
+       }
+
+       MS_DBG("Last MMC info   = %s", pre_mmc_info);
+       MS_DBG("Current MMC info = %s", cid);
+
+       if (strcmp(pre_mmc_info, cid) == 0) {
+               return true;
+       }
+
+       MS_DBG_END();
+       return false;
+}
+
+static int
+_get_contents(const char *filename, char *buf)
+{
+       FILE *fp;
+
+       MS_DBG("%s", filename);
+
+       fp = fopen(filename, "rt");
+       if (fp == NULL) {
+               MS_DBG("fp is NULL");
+               return MS_ERR_FILE_OPEN_FAIL;
+       }
+       fgets(buf, 255, fp);
+
+       fclose(fp);
+
+       return MS_ERR_NONE;
+}
+
+/*need optimize*/
+int
+_ms_get_mmc_info(char *cid)
+{
+       MS_DBG_START();
+
+       int i;
+       int j;
+       int len;
+       int err = -1;
+       bool getdata = false;
+       bool bHasColon = false;
+       char path[MS_FILE_PATH_LEN_MAX] = { 0 };
+       char mmcpath[MS_FILE_PATH_LEN_MAX] = { 0 };
+
+       DIR *dp;
+       struct dirent ent;
+       struct dirent *res = NULL;
+
+       /* mmcblk0 and mmcblk1 is reserved for movinand */
+       for (j = 1; j < 3; j++) {
+               len = snprintf(mmcpath, MS_FILE_PATH_LEN_MAX, "/sys/class/mmc_host/mmc%d/", j);
+               if (len < 0) {
+                       MS_DBG("FAIL : snprintf");
+                       return MS_ERR_UNKNOWN_ERROR;
+               }
+               else {
+                       mmcpath[len] = '\0';
+               }
+
+               dp = opendir(mmcpath);
+
+               if (dp == NULL) {
+                       MS_DBG("dp is NULL");
+                       {
+                               return MS_ERR_DIR_OPEN_FAIL;
+                       }
+               }
+
+               while (!readdir_r(dp, &ent, &res)) {
+                        /*end of read dir*/
+                       if (res == NULL)
+                               break;
+
+                       bHasColon = false;
+                       if (ent.d_name[0] == '.')
+                               continue;
+
+                       if (ent.d_type == DT_DIR) {
+                               /*ent->d_name is including ':' */
+                               for (i = 0; i < strlen(ent.d_name); i++) {
+                                       if (ent.d_name[i] == ':') {
+                                               bHasColon = true;
+                                               break;
+                                       }
+                               }
+
+                               if (bHasColon) {
+                                       /*check serial */
+                                       err = ms_strappend(path, sizeof(path), "%s%s/cid", mmcpath, ent.d_name);
+                                       if (err < 0) {
+                                               MS_DBG("FAIL : ms_strappend");
+                                               continue;
+                                       }
+
+                                       if (_get_contents(path, cid) != MS_ERR_NONE)
+                                               break;
+                                       else
+                                               getdata = true;
+                                       MS_DBG("MMC serial : %s", cid);
+                               }
+                       }
+               }
+               closedir(dp);
+
+               if (getdata == true) {
+                       break;
+               }
+       }
+\r
+       MS_DBG_END();
+
+       return MS_ERR_NONE;
+}\r
+\r
+ms_dir_scan_type_t
+ms_get_mmc_state(void)
+{
+       char cid[MMC_INFO_SIZE] = { 0 };
+       ms_dir_scan_type_t ret = MS_SCAN_ALL;
+
+       /*get new info */
+       _ms_get_mmc_info(cid);
+
+       /*check it's same mmc */
+       if (_ms_check_mmc_info(cid)) {
+               MS_DBG("Detected same MMC! but needs to update the changes...");
+               ret = MS_SCAN_PART;
+       }
+
+       return ret;
+}\r
+
+int
+ms_update_mmc_info(void)
+{
+       int err;
+       char cid[MMC_INFO_SIZE] = { 0 };
+
+       err = _ms_get_mmc_info(cid);
+
+       err = _ms_update_mmc_info(cid);
+
+       /*Active flush */
+       if (malloc_trim(0))
+               MS_DBG("SUCCESS malloc_trim");
+
+       return err;
+}\r
+\r
+void\r
+ms_mmc_removed_handler(void)
+{
+       ms_scan_data_t *mmc_scan_data;
+
+       mmc_scan_data = malloc(sizeof(ms_scan_data_t));
+
+       mmc_scan_data->scan_type = MS_SCAN_VALID;
+       mmc_scan_data->db_type = MS_MMC;
+
+       g_async_queue_push(scan_queue, GINT_TO_POINTER(mmc_scan_data));
+
+       /*remove added watch descriptors */
+       ms_inoti_remove_watch_recursive(MS_MMC_ROOT_PATH);
+
+       ms_inoti_delete_mmc_ignore_file();
+
+       if (drm_svc_extract_ext_memory() == DRM_RESULT_SUCCESS)
+               MS_DBG("drm_svc_extract_ext_memory OK");
+}
+\r
+void\r
+ms_mmc_vconf_cb(void *data)
+{
+       MS_DBG_START();
+
+       int status = 0;
+       ms_scan_data_t *scan_data;
+
+       MS_DBG("Received MMC noti from vconf : %d", status);
+
+       if (!ms_config_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status)) {
+               MS_DBG("........Get VCONFKEY_SYSMAN_MMC_STATUS failed........");
+       }
+
+       MS_DBG("ms_config_get_int : VCONFKEY_SYSMAN_MMC_STATUS END = %d",
+              status);
+
+       mmc_state = status;
+
+       if (current_usb_mode != VCONFKEY_USB_STORAGE_STATUS_OFF)
+               return;
+
+       if (mmc_state == VCONFKEY_SYSMAN_MMC_REMOVED ||
+               mmc_state == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
+               ms_mmc_removed_handler();
+       }\r
+       else if (mmc_state == VCONFKEY_SYSMAN_MMC_MOUNTED) {
+               scan_data = malloc(sizeof(ms_scan_data_t));
+
+               if (drm_svc_insert_ext_memory() == DRM_RESULT_SUCCESS)
+                       MS_DBG("drm_svc_insert_ext_memory OK");
+
+               ms_make_default_path_mmc();\r
+
+               scan_data->scan_type = ms_get_mmc_state();
+               scan_data->db_type = MS_MMC;
+
+               MS_DBG("ms_get_mmc_state is %d", scan_data->scan_type);
+
+               g_async_queue_push(scan_queue, GINT_TO_POINTER(scan_data));
+       }
+\r
+       MS_DBG_END();
+\r
+       return;
+}
+\r
index 78e2d74..3fb94ce 100755 (executable)
@@ -27,8 +27,7 @@
  * @version    1.0
  * @brief23
  */
-#include "media-server-global.h"
-#include "media-server-common.h"
+#include "media-server-utils.h"
 #include "media-server-inotify-internal.h"
 
 int inoti_fd;
@@ -91,25 +90,6 @@ ms_create_file_info *_ms_inoti_find_create_file_list(int wd, char *name)
        return NULL;
 }
 
-int _fex_is_default_path(const char *path)
-{
-       int ret = false;
-
-       if ((strcmp(path, "Images and videos") == 0) ||
-           (strcmp(path, "Sounds and music") == 0) ||
-           (strcmp(path, "Downloads") == 0) ||
-           (strcmp(path, "Camera shots") == 0) ||
-           (strcmp(path, "Wallpapers") == 0) ||
-           (strcmp(path, "Music") == 0) ||
-           (strcmp(path, "Ringtones and Alerts") == 0) ||
-           (strcmp(path, "FM Radio") == 0) ||
-           (strcmp(path, "Voice recorder") == 0)) {
-               ret = true;
-       }
-
-       return ret;
-}
-
 bool _ms_inoti_get_full_path(int wd, char *name, char *path, int sizeofpath)
 {
        int err;
index 845cfd6..c2f495c 100755 (executable)
@@ -27,8 +27,8 @@
  * @version    1.0
  * @brief
  */
-#include "media-server-global.h"
-#include "media-server-common.h"
+#include "media-server-utils.h"
+#include "media-server-db-svc.h"
 #include "media-server-inotify-internal.h"
 #include "media-server-inotify.h"
 
@@ -36,7 +36,7 @@ extern int inoti_fd;
 ms_dir_data *first_inoti_node;
 ms_ignore_file_info *latest_ignore_file;
 
-int _ms_inoti_directory_scan_and_register_file(char *dir_path)
+int _ms_inoti_directory_scan_and_register_file(MediaSvcHandle *handle, char *dir_path)
 {
        MS_DBG_START();
        struct dirent ent;
@@ -71,10 +71,10 @@ int _ms_inoti_directory_scan_and_register_file(char *dir_path)
 
                /*in case of directory */
                if (ent.d_type == DT_DIR) {
-                       _ms_inoti_directory_scan_and_register_file(path);
+                       _ms_inoti_directory_scan_and_register_file(handle, path);
                } else {
 
-                       err = ms_register_file(path, NULL);
+                       err = ms_register_file(handle, path, NULL);
                        if (err != MS_ERR_NONE) {
                                MS_DBG("ms_register_file error : %d", err);
                                continue;
@@ -89,7 +89,7 @@ int _ms_inoti_directory_scan_and_register_file(char *dir_path)
        return 0;
 }
 
-int _ms_inoti_scan_renamed_folder(char *org_path, char *chg_path)
+int _ms_inoti_scan_renamed_folder(MediaSvcHandle *handle, char *org_path, char *chg_path)
 {
        if (org_path == NULL || chg_path == NULL) {
                MS_DBG("Parameter is wrong");
@@ -138,7 +138,7 @@ int _ms_inoti_scan_renamed_folder(char *org_path, char *chg_path)
 
                /*in case of directory */
                if (ent.d_type == DT_DIR) {
-                       _ms_inoti_scan_renamed_folder(path_from, path_to);
+                       _ms_inoti_scan_renamed_folder(handle, path_from, path_to);
                }
 
                /*in case of file */
@@ -148,7 +148,7 @@ int _ms_inoti_scan_renamed_folder(char *org_path, char *chg_path)
 
                        if ((src_storage != MS_ERR_INVALID_FILE_PATH)
                            && (des_storage != MS_ERR_INVALID_FILE_PATH))
-                               ms_media_db_move(src_storage, des_storage, path_from, path_to);
+                               ms_media_db_move(handle, src_storage, des_storage, path_from, path_to);
                        else {
                                MS_DBG("ms_get_store_type_by_full error");
                        }
@@ -476,10 +476,11 @@ gboolean ms_inoti_thread(void *data)
        char buffer[INOTI_BUF_LEN] = { 0 };
        char path[MS_FILE_PATH_LEN_MAX] = { 0 };
        struct inotify_event *event;
+       MediaSvcHandle *handle = NULL;
 
        MS_DBG("START INOTIFY");
 
-       err = ms_media_db_open();
+       err = ms_media_db_open(&handle);
        if (err != MS_ERR_NONE) {
                MS_DBG(" INOTIFY : sqlite3_open: ret = %d", err);
                return false;
@@ -499,15 +500,7 @@ gboolean ms_inoti_thread(void *data)
                        /*it's possible that ums lets reset phone data... */
                        event = (struct inotify_event *)&buffer[i];
 
-                       /*stop this threadfor hibernation */
-                       if (strcmp(event->name, "_HIBERNATION_END") == 0) {
-                               /*db close before capture hibernatio image */
-                               err = ms_media_db_close();
-                               if (err != MS_ERR_NONE) {
-                                       MS_DBG("failed ms_media_db_close : ret = (%d)", err);
-                               }
-                               return false;
-                       } else if(strcmp(event->name, "_FILEOPERATION_END") == 0) {
+                       if(strcmp(event->name, "_FILEOPERATION_END") == 0) {
                                /*file operation is end*/
                                /* announce db is updated*/
                                ms_set_db_status(MS_DB_UPDATED);
@@ -566,41 +559,26 @@ gboolean ms_inoti_thread(void *data)
                                                        goto NEXT_INOTI_EVENT;
                                                }
                                                /*enable bundle commit*/
-                                               ms_media_db_move_start();
+                                               ms_media_db_move_start(handle);
 
                                                /*need update file information under renamed directory */
-                                               _ms_inoti_scan_renamed_folder(full_path_from, path);
+                                               _ms_inoti_scan_renamed_folder(handle, full_path_from, path);
 
                                                /*disable bundle commit*/
-                                               ms_media_db_move_end();
+                                               ms_media_db_move_end(handle);
 
-                                               if (_fex_is_default_path(prev_name)) {
-                                                       if (strstr(path, MS_PHONE_ROOT_PATH)) {
-                                                               fex_make_default_path();
-                                                       } else {
-                                                               fex_make_default_path_mmc();
-                                                       }
-                                               }
                                                prev_mask = prev_wd = 0;        /*reset */
                                        }
                                        else if (event->mask & IN_CREATE) {
                                                MS_DBG("CREATE");
 
-                                               _ms_inoti_directory_scan_and_register_file(path);
+                                               _ms_inoti_directory_scan_and_register_file(handle, path);
                                                prev_mask = event->mask;
                                        }
                                        else if (event->mask & IN_DELETE) {
                                                MS_DBG("DELETE");
 
                                                ms_inoti_remove_watch(path);
-
-                                               if (_fex_is_default_path(name)) {
-                                                       if (strstr(path, MS_PHONE_ROOT_PATH)) {
-                                                               fex_make_default_path();
-                                                       } else {
-                                                               fex_make_default_path_mmc();
-                                                       }
-                                               }
                                        }
                                }
                                else {
@@ -609,7 +587,7 @@ gboolean ms_inoti_thread(void *data)
                                        if (event->mask & IN_MOVED_FROM) {
                                                MS_DBG("MOVED_FROM");
 
-                                               err = ms_media_db_delete(path);
+                                               err = ms_media_db_delete(handle, path);
                                                if (err != MS_ERR_NONE) {
                                                        MS_DBG("ms_media_db_delete fail error : %d", err);
                                                }
@@ -617,7 +595,7 @@ gboolean ms_inoti_thread(void *data)
                                        else if (event->mask & IN_MOVED_TO) {
                                                MS_DBG("MOVED_TO");
 
-                                               err = ms_register_file(path, NULL);
+                                               err = ms_register_file(handle, path, NULL);
                                                if (err != MS_ERR_NONE) {
                                                        MS_DBG("ms_register_file error : %d", err);
                                                }
@@ -630,7 +608,7 @@ gboolean ms_inoti_thread(void *data)
                                        else if (event->mask & IN_DELETE) {
                                                MS_DBG("DELETE");
                                                
-                                               err = ms_media_db_delete(path);
+                                               err = ms_media_db_delete(handle, path);
                                                if (err != MS_ERR_NONE) {
                                                        MS_DBG("ms_media_db_delete error : %d", err);
                                                }
@@ -643,7 +621,7 @@ gboolean ms_inoti_thread(void *data)
 
                                                if (node != NULL || ((prev_mask & IN_ISDIR) & IN_CREATE)) {
 
-                                                       err = ms_register_file(path, NULL);
+                                                       err = ms_register_file(handle, path, NULL);
                                                        if (err != MS_ERR_NONE) {
                                                                MS_DBG("ms_register_file error : %d", err);
                                                        }
@@ -657,12 +635,12 @@ gboolean ms_inoti_thread(void *data)
 
                                                        ignore_file = ms_inoti_find_ignore_file(path);
                                                        if (ignore_file == NULL) {
-                                                               err = ms_media_db_delete(path);
+                                                               err = ms_media_db_delete(handle, path);
                                                                if (err != MS_ERR_NONE) {
                                                                        MS_DBG("ms_media_db_delete error : %d", err);
                                                                }
                                                                /*update = delete + regitster */
-                                                               err = ms_register_file(path, NULL);
+                                                               err = ms_register_file(handle, path, NULL);
                                                                if (err != MS_ERR_NONE) {
                                                                        MS_DBG("ms_register_file error : %d", err);
                                                                        goto NEXT_INOTI_EVENT;
@@ -696,7 +674,7 @@ gboolean ms_inoti_thread(void *data)
 
        close(inoti_fd);
 
-       err = ms_media_db_close();
+       err = ms_media_db_close(handle);
        if (err != MS_ERR_NONE) {
                MS_DBG("ms_media_db_close error : %d", err);
                return false;
index 1f15753..b4c7f6e 100755 (executable)
 /**
  * This file defines api utilities of contents manager engines.
  *
- * @file               media-server-mainl.c
+ * @file               media-server-main.c
  * @author     Yong Yeon Kim(yy9875.kim@samsung.com)
  * @version    1.0
  * @brief
  */
 #include <vconf.h>
+#include <drm-service.h>
 
-#include "media-server-common.h"
-#include "media-server-hibernation.h"
+#include "media-server-utils.h"
+#include "media-server-external-storage.h"
+#include "media-server-db-svc.h"
 #include "media-server-inotify.h"
 #include "media-server-scan.h"
 #include "media-server-socket.h"
-#ifdef THUMB_THREAD
-#include "media-server-thumb.h"
-#endif
-
-#include <heynoti.h>
 
 #define APP_NAME "media-server"
 
-#ifdef _USE_HIB
-int hib_fd = 0;
-#endif
 extern GAsyncQueue *scan_queue;
 extern GAsyncQueue* ret_queue;
 extern GMutex *db_mutex;
 extern GMutex *list_mutex;
 extern GMutex *queue_mutex;
 extern GArray *reg_list;
+extern int mmc_state;
 
 bool check_process(pid_t current_pid)
 {
@@ -115,17 +110,18 @@ void init_process()
 }
 
 static bool _db_clear(void)
-       {
+{
        int err;
        int db_status;
        int usb_status;
        bool need_db_create = false;
+       MediaSvcHandle *handle = NULL;
 
        /*connect to media db, if conneting is failed, db updating is stopped*/
-       ms_media_db_open();
+       ms_media_db_open(&handle);
 
        /*update just valid type*/
-       err = ms_change_valid_type(MS_MMC, false);
+       err = ms_change_valid_type(handle, MS_MMC, false);
        if (err != MS_ERR_NONE)
                MS_DBG("ms_change_valid_type fail");
 
@@ -140,7 +136,7 @@ static bool _db_clear(void)
 
                need_db_create = true;
 
-               err = ms_change_valid_type(MS_PHONE, false);
+               err = ms_change_valid_type(handle, MS_PHONE, false);
                if (err != MS_ERR_NONE)
                        MS_DBG("ms_change_valid_type fail");
        }
@@ -148,7 +144,7 @@ static bool _db_clear(void)
        ms_set_db_status(MS_DB_UPDATED);
 
        /*disconnect form media db*/
-       ms_media_db_close();
+       ms_media_db_close(handle);
 
        return need_db_create;
 }
@@ -161,10 +157,13 @@ int main(int argc, char **argv)
 
        GMainLoop *mainloop = NULL;
        pid_t current_pid = 0;
-       bool check_result = false;
        int err;
+       bool check_result = false;
        bool need_db_create;
 
+       ms_scan_data_t *phone_scan_data;
+       ms_scan_data_t *mmc_scan_data;
+
        current_pid = getpid();
        check_result = check_process(current_pid);
        if (check_result == false)
@@ -178,12 +177,9 @@ int main(int argc, char **argv)
        if (!db_mutex)
                db_mutex = g_mutex_new();
 
+       /*clear previous data of sdcard on media database and check db status for updating*/
        need_db_create = _db_clear();
        
-#ifdef _USE_HIB
-       _hibernation_initialize();
-#endif
-
        MS_DBG("MEDIA SERVER START");
 
        if (!scan_queue)
@@ -199,18 +195,68 @@ int main(int argc, char **argv)
        if (!reg_list)
                reg_list = g_array_new(TRUE, TRUE, sizeof(char*));
 
+       /*inotify setup */
        ms_inoti_init();
 
        ms_inoti_add_watch(MS_DB_UPDATE_NOTI_PATH);
 
-       /*inotify setup */
+       /*create each threads*/
        inoti_tid = g_thread_create((GThreadFunc) ms_inoti_thread, NULL, FALSE, NULL);
        scan_tid = g_thread_create((GThreadFunc) ms_scan_thread, NULL, TRUE, NULL);
        scoket_tid  = g_thread_create((GThreadFunc) ms_socket_thread, NULL, TRUE, NULL);
 
+       /*Init main loop*/
        mainloop = g_main_loop_new(NULL, FALSE);
 
-       ms_start(need_db_create);
+       /*set vconf callback function*/
+       err = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+                                    (vconf_callback_fn) ms_mmc_vconf_cb, NULL);
+       if (err == -1)
+               MS_DBG("add call back function for event %s fails", VCONFKEY_SYSMAN_MMC_STATUS);
+
+       err = vconf_notify_key_changed(VCONFKEY_USB_STORAGE_STATUS,
+                                    (vconf_callback_fn) ms_usb_vconf_cb, NULL);
+       if (err == -1)
+               MS_DBG("add call back function for event %s fails", VCONFKEY_USB_STORAGE_STATUS);
+
+       phone_scan_data = malloc(sizeof(ms_scan_data_t));
+       mmc_scan_data = malloc(sizeof(ms_scan_data_t));
+       MS_DBG("*********************************************************");
+       MS_DBG("*** Begin to check tables of file manager in database ***");
+       MS_DBG("*********************************************************");
+
+       phone_scan_data->db_type = MS_PHONE;
+
+       if (need_db_create) {
+               /*insert records*/
+               MS_DBG("Create DB");
+               phone_scan_data->scan_type = MS_SCAN_ALL;
+       } else {
+               MS_DBG("JUST ADD WATCH");
+               phone_scan_data->scan_type = MS_SCAN_NONE;
+       }
+
+       /*push data to fex_dir_scan_cb */
+       g_async_queue_push(scan_queue, GINT_TO_POINTER(phone_scan_data));
+
+       if (ms_is_mmc_inserted()) {
+               mmc_state = VCONFKEY_SYSMAN_MMC_MOUNTED;
+
+               if (drm_svc_insert_ext_memory() == DRM_RESULT_SUCCESS)
+                       MS_DBG
+                           ("fex_db_service_init : drm_svc_insert_ext_memory OK");
+
+               ms_make_default_path_mmc();
+
+               mmc_scan_data->scan_type = ms_get_mmc_state();
+               mmc_scan_data->db_type = MS_MMC;
+
+               MS_DBG("ms_get_mmc_state is %d", mmc_scan_data->scan_type);
+
+               g_async_queue_push(scan_queue, GINT_TO_POINTER(mmc_scan_data));
+       }
+
+       malloc_trim(0);
 
        MS_DBG("*****************************************");
        MS_DBG("*** Server of File Manager is running ***");
@@ -230,11 +276,16 @@ int main(int argc, char **argv)
        if(reg_list)
                g_array_free(reg_list, true);
 
-       ms_end();
+       /***********
+       **remove call back functions
+       ************/
+       vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+                                (vconf_callback_fn) ms_mmc_vconf_cb);
+       vconf_ignore_key_changed(VCONFKEY_USB_STORAGE_STATUS,
+                                (vconf_callback_fn) ms_usb_vconf_cb);
 
-#ifdef _USE_HIB
-       _hibernation_fianalize();
-#endif
+       /*Clear db mutex variable*/
+       g_mutex_free (db_mutex);
 
        exit(0);
 }
index e3bfcba..0d49196 100755 (executable)
  */
 
 #include <vconf.h>
-#include <audio-svc-error.h>
-#include <audio-svc.h>
-#include <media-svc.h>
-#include "media-server-common.h"
+
+#include "media-server-utils.h"
+#include "media-server-db-svc.h"
 #include "media-server-inotify.h"
 #include "media-server-scan-internal.h"
 
@@ -245,9 +244,9 @@ FREE_RESOURCES:
 }
 
 #ifdef PROGRESS
-void _ms_dir_scan(ms_scan_data_t * scan_data, struct quickpanel *ms_quickpanel)
+void _ms_dir_scan(MediaSvcHandle *handle, ms_scan_data_t * scan_data, struct quickpanel *ms_quickpanel)
 #else
-void _ms_dir_scan(ms_scan_data_t * scan_data)
+void _ms_dir_scan(MediaSvcHandle *handle, ms_scan_data_t * scan_data)
 #endif
 {
        MS_DBG_START();
@@ -301,7 +300,7 @@ void _ms_dir_scan(ms_scan_data_t * scan_data)
 #endif
                if (scan_data->scan_type == MS_SCAN_PART) {
                        /*enable bundle commit*/
-                       ms_update_valid_type_start();
+                       ms_update_valid_type_start(handle);
                }
 
                while (node != NULL) {
@@ -351,9 +350,9 @@ void _ms_dir_scan(ms_scan_data_t * scan_data)
                                                        }
 
                                                        if (scan_data->scan_type == MS_SCAN_PART)       
-                                                               err = ms_update_valid_type(path);
+                                                               err = ms_update_valid_type(handle,path);
                                                        else
-                                                               err = ms_register_scanfile(path);
+                                                               err = ms_register_scanfile(handle, path);
 
                                                        if (err < 0) {
                                                                MS_DBG("failed to update db : %d , %d\n", err, scan_data->scan_type);
@@ -380,10 +379,9 @@ void _ms_dir_scan(ms_scan_data_t * scan_data)
 
                if (scan_data->scan_type == MS_SCAN_PART) {
                        /*disable bundle commit*/
-                       ms_update_valid_type_end();
+                       ms_update_valid_type_end(handle);
 
-                       audio_svc_delete_invalid_items(scan_data->db_type);
-                       minfo_delete_invalid_media_records(scan_data->db_type);
+                       ms_delete_invalid_records(handle, scan_data->db_type);
                }
        } else {
                node = first_inoti_node;
index ae440d5..0795b51 100755 (executable)
  * @brief
  */
 #include <vconf.h>
-#include <minfo-types.h>
+#include <media-svc-types.h>
 
-#include "media-server-common.h"
-#include "media-server-thumb.h"
+#include "media-server-utils.h"
+#include "media-server-db-svc.h"
+#include "media-server-external-storage.h"
 #include "media-server-scan-internal.h"
 #include "media-server-scan.h"
 
@@ -85,6 +86,7 @@ gboolean ms_scan_thread(void *data)
        bool res;
        int length;
        int err;
+       MediaSvcHandle *handle = NULL;
 
 #ifdef PROGRESS
        struct quickpanel *ms_quickpanel = NULL;
@@ -115,16 +117,9 @@ gboolean ms_scan_thread(void *data)
                        continue;
                }
 
-               if (scan_data->scan_type == end_thread) {
-                       MS_DBG("RECEIVE END THREAD");
-                       free(scan_data);
-
-                       if(garray) g_array_free (garray, TRUE);
-
-                       return false;
-               } else if (scan_data->scan_type != MS_SCAN_VALID) {
+               if (scan_data->scan_type != MS_SCAN_VALID) {
                        /*connect to media db, if conneting is failed, db updating is stopped*/
-                       err = ms_media_db_open();
+                       err = ms_media_db_open(&handle);
                        if (err != MS_ERR_NONE)
                                continue;
 
@@ -148,7 +143,7 @@ gboolean ms_scan_thread(void *data)
                        }
 
                        if (scan_data->scan_type == MS_SCAN_ALL) {
-                               res = ms_delete_all_record(scan_data->db_type);
+                               res = ms_delete_all_record(handle, scan_data->db_type);
                                if (res != true) {
                                        MS_DBG("ms_delete_all_record fails");
                                }
@@ -160,11 +155,11 @@ gboolean ms_scan_thread(void *data)
                        }
 #endif
                        /*call for bundle commit*/
-                       ms_register_start();
+                       ms_register_start(handle);
 
 #ifdef PROGRESS
                        /*add inotify watch and insert data into media db */
-                       _ms_dir_scan(scan_data, ms_quickpanel);
+                       _ms_dir_scan(handle, scan_data, ms_quickpanel);
 
                        if (ms_quickpanel != NULL) {
                                ms_delete_quickpanel(ms_quickpanel);
@@ -173,10 +168,10 @@ gboolean ms_scan_thread(void *data)
                        }
 #else
                        /*add inotify watch and insert data into media db */
-                       _ms_dir_scan(scan_data);
+                       _ms_dir_scan(handle, scan_data);
 #endif
                        /*call for bundle commit*/
-                       ms_register_end();
+                       ms_register_end(handle);
 
 #ifdef FMS_PERF
                        if (scan_data->db_type == MS_MMC) {
@@ -190,18 +185,8 @@ gboolean ms_scan_thread(void *data)
                                ms_set_db_status(MS_DB_UPDATED);
 
                        /*disconnect form media db*/
-                       ms_media_db_close();
-#ifdef THUMB_THREAD
-                       /*create making thumbnail thread*/
-                       if (scan_data->scan_type == MS_SCAN_ALL) {
-                               minfo_folder_type db;
-                               if(scan_data->db_type == MS_PHONE)
-                                       db = MINFO_CLUSTER_TYPE_LOCAL_PHONE;
-                               else
-                                       db = MINFO_CLUSTER_TYPE_LOCAL_MMC;
-                               g_thread_create((GThreadFunc) ms_thumb_thread, &db, TRUE, NULL);
-                       }
-#endif
+                       ms_media_db_close(handle);
+
                        /*Active flush */
                        sqlite3_release_memory(-1);
 
@@ -210,19 +195,19 @@ gboolean ms_scan_thread(void *data)
                        }
                } else  {
                        /*connect to media db, if conneting is failed, db updating is stopped*/
-                       err = ms_media_db_open();
+                       err = ms_media_db_open(&handle);
                        if (err != MS_ERR_NONE)
                                continue;
 
                        /*update just valid type*/
-                       err = ms_change_valid_type(scan_data->db_type, false);
+                       err = ms_change_valid_type(handle, scan_data->db_type, false);
                        if (err != MS_ERR_NONE)
                                MS_DBG("ms_change_valid_type fail");
 
                        ms_set_db_status(MS_DB_UPDATED);
 
                        /*disconnect form media db*/
-                       ms_media_db_close();
+                       ms_media_db_close(handle);
 
                        /*Active flush */
                        sqlite3_release_memory(-1);
index bda3145..fdfade8 100755 (executable)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <media-util-err.h>
-#include <media-info.h>
+#include <media-svc.h>
 
 #include "media-server-global.h"
-#include "media-server-common.h"
+#include "media-server-db-svc.h"
 #include "media-server-socket.h"
 
 #define MINFO_REGISTER_PORT 1001
@@ -49,6 +49,7 @@ gboolean ms_socket_thread(void *data)
        int sockfd;
        int send_msg = MEDIA_INFO_ERROR_NONE;
        int client_addr_size;
+       MediaSvcHandle *handle = NULL;
 
        struct sockaddr_in server_addr;
        struct sockaddr_in client_addr;
@@ -77,7 +78,7 @@ gboolean ms_socket_thread(void *data)
                return MS_ERR_SOCKET_BIND;
        }
 
-       err = ms_media_db_open();
+       err = ms_media_db_open(&handle);
        if (err != MS_ERR_NONE) {
                MS_DBG("SOCKET : sqlite3_open: ret = %d", err);
                return false;
@@ -96,7 +97,7 @@ gboolean ms_socket_thread(void *data)
                        MS_DBG("receive: %s\n", recv_buff);
                }
 
-               ret = ms_register_file(recv_buff, ret_queue);
+               ret = ms_register_file(handle, recv_buff, ret_queue);
                if (ret == MS_ERR_NOW_REGISTER_FILE) {
                        MS_DBG("WAIT");
                        ret= GPOINTER_TO_INT(g_async_queue_pop(ret_queue)) - MS_ERR_MAX;
@@ -135,7 +136,7 @@ NEXT:
        close(sockfd);
        MS_DBG("END SOCKET THREAD");
 
-       err = ms_media_db_close();
+       err = ms_media_db_close(handle);
        if (err != MS_ERR_NONE) {
                MS_DBG("ms_media_db_close error : %d", err);
                return false;
diff --git a/common/media-server-utils.c b/common/media-server-utils.c
new file mode 100755 (executable)
index 0000000..40d6424
--- /dev/null
@@ -0,0 +1,667 @@
+/*
+ *  Media Server
+ *
+ * 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-server-utils.c
+ * @author     Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version    1.0
+ * @brief       This file implements main database operation.
+ */
+
+#include <pmapi.h>
+#include <vconf.h>
+#include <drm-service.h>
+#ifdef PROGRESS
+#include <quickpanel.h>
+#endif
+#include <aul/aul.h>
+#include <mmf/mm_file.h>
+
+#include "media-server-inotify.h"
+#include "media-server-utils.h"
+
+#ifdef FMS_PERF
+#include <sys/time.h>
+#define MILLION 1000000L
+struct timeval g_mmc_start_time;
+struct timeval g_mmc_end_time;
+#endif
+
+extern GAsyncQueue *scan_queue;
+
+#define CONTENT_TYPE_NUM 4
+#define MUSIC_MIME_NUM 28
+#define SOUND_MIME_NUM 1
+#define MIME_TYPE_LENGTH 255
+#define MIME_LENGTH 50
+#define _3GP_FILE ".3gp"
+#define _MP4_FILE ".mp4"
+#define MS_DRM_CONTENT_TYPE_LENGTH 100
+
+int ums_mode = 0;
+int current_usb_mode = 0;
+extern int mmc_state;
+
+typedef struct {
+       char content_type[15];
+       int category_by_mime;
+} ms_content_table_t;
+
+static const ms_content_table_t content_category[CONTENT_TYPE_NUM] = {
+       {"audio", MS_CATEGORY_SOUND},
+       {"image", MS_CATEGORY_IMAGE},
+       {"video", MS_CATEGORY_VIDEO},
+       {"application", MS_CATEGORY_ETC},
+};
+
+static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
+       /*known mime types of normal files*/
+       "mpeg",
+       "ogg",
+       "x-ms-wma",
+       "x-flac",
+       "mp4",
+       /* known mime types of drm files*/
+       "mp3",
+       "x-mp3", /*alias of audio/mpeg*/
+       "x-mpeg", /*alias of audio/mpeg*/
+       "3gpp",
+       "x-ogg", /*alias of  audio/ogg*/
+       "vnd.ms-playready.media.pya:*.pya", /*playready*/
+       "wma",
+       "aac",
+       "x-m4a", /*alias of audio/mp4*/
+       /* below mimes are rare*/
+       "x-vorbis+ogg",
+       "x-flac+ogg",
+       "x-matroska",
+       "ac3",
+       "mp2",
+       "x-ape",
+       "x-ms-asx",
+       "vnd.rn-realaudio",
+
+       "x-vorbis", /*alias of audio/x-vorbis+ogg*/
+       "vorbis", /*alias of audio/x-vorbis+ogg*/
+       "x-oggflac",
+       "x-mp2", /*alias of audio/mp2*/
+       "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
+       "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
+};
+
+static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
+       "x-smaf",
+};
+
+static int
+_ms_set_power_mode(ms_db_status_type_t status)
+{
+       int res = MS_ERR_NONE;
+       int err;
+
+       switch (status) {
+       case MS_DB_UPDATING:
+               err = pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+               if (err != 0)
+                       res = MS_ERR_UNKNOWN_ERROR;
+               break;
+       case MS_DB_UPDATED:
+               err = pm_unlock_state(LCD_OFF, STAY_CUR_STATE);
+               if (err != 0)
+                       res = MS_ERR_UNKNOWN_ERROR;
+               break;
+       default:
+               MS_DBG("Unacceptable type : %d", status);
+               break;
+       }
+
+       return res;
+}
+
+int
+ms_set_db_status(ms_db_status_type_t status)
+{
+       int res = MS_ERR_NONE;
+       int err = 0;
+
+       if (status == MS_DB_UPDATING) {
+               if (ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATING))
+                         res = MS_ERR_VCONF_SET_FAIL;
+       } else if (status == MS_DB_UPDATED) {
+               if(ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS,  VCONFKEY_FILEMANAGER_DB_UPDATED))
+                         res = MS_ERR_VCONF_SET_FAIL;
+       }
+
+       err = _ms_set_power_mode(status);
+       if (err != MS_ERR_NONE) {
+               MS_DBG("_ms_set_power_mode fail");
+               res = err;
+       }
+
+       return res;
+}
+
+#ifdef FMS_PERF
+void
+ms_check_start_time(struct timeval *start_time)
+{
+       gettimeofday(start_time, NULL);
+}
+
+void
+ms_check_end_time(struct timeval *end_time)
+{
+       gettimeofday(end_time, NULL);
+}
+
+void
+ms_check_time_diff(struct timeval *start_time, struct timeval *end_time)
+{
+       struct timeval time;
+       long difftime;
+
+       time.tv_sec = end_time->tv_sec - start_time->tv_sec;
+       time.tv_usec = end_time->tv_usec - start_time->tv_usec;
+       difftime = MILLION * time.tv_sec + time.tv_usec;
+       MS_DBG("The function_to_time took %ld microseconds or %f seconds.",
+              difftime, difftime / (double)MILLION);
+}
+#endif
+
+void
+ms_usb_vconf_cb(void *data)
+{
+       MS_DBG_START();
+
+       int status = 0;
+
+       MS_DBG("Received usb noti from vconf : %d", status);
+
+       if (!ms_config_get_int(VCONFKEY_USB_STORAGE_STATUS, &status)) {
+               MS_DBG
+                   ("........Get VCONFKEY_USB_STORAGE_STATUS failed........");
+       }
+
+       MS_DBG("ms_config_get_int : VCONFKEY_USB_STORAGE_STATUS END = %d",
+              status);
+       current_usb_mode = status;
+
+       if (current_usb_mode == VCONFKEY_USB_STORAGE_STATUS_OFF) {
+               if (ums_mode != VCONFKEY_USB_STORAGE_STATUS_OFF) {
+                       ms_scan_data_t *int_scan;
+
+                       int_scan = malloc(sizeof(ms_scan_data_t));
+
+                       int_scan->db_type = MS_PHONE;
+                       int_scan->scan_type = MS_SCAN_PART;
+
+                       /*push data to fex_dir_scan_cb */
+                       g_async_queue_push(scan_queue, GINT_TO_POINTER(int_scan));
+
+                       if (ms_is_mmc_inserted()) {
+                               ms_scan_data_t *ext_scan;
+
+                               /*prepare to insert drm data and delete previous drm datas */
+                               if (drm_svc_insert_ext_memory() ==
+                                   DRM_RESULT_SUCCESS)
+                                       MS_DBG("drm_svc_insert_ext_memory OK");
+
+                               ext_scan = malloc(sizeof(ms_scan_data_t));
+                               mmc_state = VCONFKEY_SYSMAN_MMC_MOUNTED;
+
+                               ext_scan->db_type = MS_MMC;
+                               ext_scan->scan_type = MS_SCAN_PART;
+
+                               /*push data to fex_dir_scan_cb */
+                               g_async_queue_push(scan_queue, GINT_TO_POINTER(ext_scan));
+                       }
+               }
+               ums_mode = VCONFKEY_USB_STORAGE_STATUS_OFF;
+               ms_config_set_int(MS_USB_MODE_KEY, MS_VCONFKEY_NORMAL_MODE);
+       } 
+       else {
+               if (ums_mode == VCONFKEY_USB_STORAGE_STATUS_OFF) {
+                       MS_DBG("VCONFKEY_USB_STORAGE_STATUS : %d", current_usb_mode);
+                       ms_scan_data_t *int_scan;
+
+                       ums_mode = current_usb_mode;
+
+                       int_scan = malloc(sizeof(ms_scan_data_t));                      
+                       int_scan->scan_type = MS_SCAN_VALID;
+                       int_scan->db_type = MS_PHONE;
+
+                       g_async_queue_push(scan_queue, GINT_TO_POINTER(int_scan));
+
+                       ms_inoti_remove_watch_recursive(MS_PHONE_ROOT_PATH);
+
+                       if (ums_mode == VCONFKEY_USB_STORAGE_STATUS_UMS_MMC_ON) {
+
+                               ms_scan_data_t *ext_scan;
+
+                               ext_scan = malloc(sizeof(ms_scan_data_t));
+                               ext_scan->scan_type = MS_SCAN_VALID;
+                               ext_scan->db_type = MS_MMC;
+
+                               g_async_queue_push(scan_queue, GINT_TO_POINTER(ext_scan));
+                               
+                               ms_inoti_remove_watch_recursive(MS_MMC_ROOT_PATH);
+
+                               /*notify to drm-server */
+                               if (drm_svc_extract_ext_memory() == DRM_RESULT_SUCCESS)
+                                       MS_DBG("drm_svc_extract_ext_memory OK");
+                       }
+
+                       /*delete all drm contect from drm server */
+                       if (drm_svc_unregister_all_contents() == DRM_RESULT_SUCCESS)
+                               MS_DBG("drm_svc_unregister_all_contents OK");
+
+                       ms_config_set_int(MS_USB_MODE_KEY, MS_VCONFKEY_MASS_STORAGE_MODE);
+               }
+       }
+
+       MS_DBG_END();
+       return;
+}
+
+bool
+ms_is_mmc_inserted(void)
+{
+       int data = -1;
+       ms_config_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &data);
+       MS_DBG("%s is  %d ", VCONFKEY_SYSMAN_MMC_STATUS, data);
+       if (data != VCONFKEY_SYSMAN_MMC_MOUNTED) {
+               MS_DBG("SD Card is inserted");
+               return false;
+       } else {
+               MS_DBG("SD Card is not inserted");
+               return true;
+       }
+}
+
+int
+ms_get_full_path_from_node(ms_dir_scan_info * const node, char *ret_path)
+{
+       int err = 0;
+       ms_dir_scan_info *cur_node;
+       char path[MS_FILE_PATH_LEN_MAX] = { 0 };
+       char tmp_path[MS_FILE_PATH_LEN_MAX] = { 0 };
+
+       cur_node = node;
+       MS_DBG("%s", cur_node->name);
+
+       while (1) {
+               err = ms_strappend(path, sizeof(path), "/%s%s", cur_node->name, tmp_path);
+               if (err < 0) {
+                       MS_DBG("ms_strappend error : %d", err);
+                       return err;
+               }
+
+               strncpy(tmp_path, path, MS_FILE_PATH_LEN_MAX);
+
+               if (cur_node->parent == NULL)
+                       break;
+
+               cur_node = cur_node->parent;
+               memset(path, 0, MS_FILE_PATH_LEN_MAX);
+       }
+
+       strncpy(ret_path, path, MS_FILE_PATH_LEN_MAX);
+
+       return err;
+}
+
+ms_store_type_t
+ms_get_store_type_by_full(const char *path)
+{
+       if (strncmp(path + 1, MS_PHONE_ROOT_PATH, strlen(MS_PHONE_ROOT_PATH)) == 0) {
+               return MS_PHONE;
+       } else
+           if (strncmp(path + 1, MS_MMC_ROOT_PATH, strlen(MS_MMC_ROOT_PATH)) == 0) {
+               return MS_MMC;
+       } else
+               return MS_ERR_INVALID_FILE_PATH;
+}
+
+int
+ms_strappend(char *res, const int size, const char *pattern,
+            const char *str1, const char *str2)
+{
+       int len = 0;
+       int real_size = size - 1;
+
+       if (!res ||!pattern || !str1 ||!str2 )
+               return MS_ERR_ARG_INVALID;
+
+       if (real_size < (strlen(str1) + strlen(str2)))
+               return MS_ERR_OUT_OF_RANGE;
+
+       len = snprintf(res, real_size, pattern, str1, str2);
+       if (len < 0) {
+               MS_DBG("MS_ERR_ARG_INVALID");
+               return MS_ERR_ARG_INVALID;
+       }
+
+       res[len] = '\0';
+
+       return MS_ERR_NONE;
+}
+
+int
+ms_strcopy(char *res, const int size, const char *pattern, const char *str1)
+{
+       int len = 0;
+       int real_size = size - 1;
+
+       if (!res || !pattern || !str1)
+               return MS_ERR_ARG_INVALID;
+
+       if (real_size < strlen(str1))
+               return MS_ERR_OUT_OF_RANGE;
+
+       len = snprintf(res, real_size, pattern, str1);
+       if (len < 0) {
+               MS_DBG("MS_ERR_ARG_INVALID");
+               return MS_ERR_ARG_INVALID;
+       }
+
+       res[len] = '\0';
+
+       return MS_ERR_NONE;
+}
+
+bool
+ms_config_get_int(const char *key, int *value)
+{
+       int err;
+
+       if (!key || !value) {
+               MS_DBG("Arguments key or value is NULL");
+               return false;
+       }
+
+       err = vconf_get_int(key, value);
+       if (err == 0)
+               return true;
+       else if (err == -1)
+               return false;
+       else
+               MS_DBG("Unexpected error code: %d", err);
+
+       return false;
+}
+
+bool
+ms_config_set_int(const char *key, int value)
+{
+       int err;
+
+       if (!key) {
+               MS_DBG("Arguments key is NULL");
+               return false;
+       }
+
+       err = vconf_set_int(key, value);
+       if (err == 0)
+               return true;
+       else if (err == -1)
+               return false;
+       else
+               MS_DBG("Unexpected error code: %d", err);
+
+       return false;
+}
+
+bool
+ms_config_get_str(const char *key, char *value)
+{
+       char *res;
+       if (!key || !value) {
+               MS_DBG("Arguments key or value is NULL");
+               return false;
+       }
+
+       res = vconf_get_str(key);
+       if (res) {
+               strncpy(value, res, strlen(res) + 1);
+               return true;
+       }
+
+       return false;
+}
+
+bool
+ms_config_set_str(const char *key, const char *value)
+{
+       int err;
+
+       if (!key || !value) {
+               MS_DBG("Arguments key or value is NULL");
+               return false;
+       }
+
+       err = vconf_set_str(key, value);
+       if (err == 0)
+               return true;
+       else
+               MS_DBG("fail to vconf_set_str %d", err);
+
+       return false;
+}
+
+static int
+_ms_get_mime_by_drm_info(const char *path, char *mime)
+{
+       int res;
+       drm_content_info_t contentInfo = { 0 };
+
+       if (path == NULL || mime == NULL)
+               return MS_ERR_ARG_INVALID;
+
+       res = drm_svc_get_content_info(path, &contentInfo);
+       if (res != DRM_RESULT_SUCCESS) {
+               MS_DBG("drm_svc_get_content_info() fails. ");
+               return MS_ERR_DB_OPERATION_FAIL;
+       }
+
+       strncpy(mime, contentInfo.contentType, MS_DRM_CONTENT_TYPE_LENGTH);
+       MS_DBG("DRM contentType : %s", contentInfo.contentType);
+       MS_DBG("DRM mime : %s", mime);
+
+       return MS_ERR_NONE;
+}
+
+int
+ms_get_category_from_mime(const char *path, int *category)
+{
+       int i = 0;
+       int err = 0;
+       char mimetype[MIME_TYPE_LENGTH];
+
+       if (path == NULL || category == NULL)
+               return MS_ERR_ARG_INVALID;
+
+       *category = MS_CATEGORY_UNKNOWN;
+
+       /*get content type and mime type from file. */
+       /*in case of drm file. */
+       if (drm_svc_is_drm_file(path) == DRM_TRUE) {
+               DRM_FILE_TYPE drm_type = DRM_FILE_TYPE_NONE;
+               drm_type = drm_svc_get_drm_type(path);
+               if (drm_type == DRM_FILE_TYPE_NONE) {
+                       *category = MS_CATEGORY_UNKNOWN;
+                       return err;
+               } 
+               else {
+                       err =  _ms_get_mime_by_drm_info(path, mimetype);
+                       if (err < 0) {
+                               *category = MS_CATEGORY_UNKNOWN;
+                               return err;
+                       }
+                       *category |= MS_CATEGORY_DRM;
+               }
+       } 
+       else {
+               /*in case of normal files */
+               if (aul_get_mime_from_file(path, mimetype, sizeof(mimetype)) < 0) {
+                       MS_DBG("aul_get_mime_from_file fail");
+                       *category = MS_CATEGORY_UNKNOWN;
+                       return MS_ERR_ARG_INVALID;
+               }
+       }
+
+       MS_DBG("mime type : %s", mimetype);
+
+       /*categorize from mimetype */
+       for (i = 0; i < CONTENT_TYPE_NUM; i++) {
+               if (strstr(mimetype, content_category[i].content_type) != NULL) {
+                       *category = (*category | content_category[i].category_by_mime);
+                       break;
+               }
+       }
+
+       /*in application type, exitst sound file ex) x-smafs */
+       if (*category & MS_CATEGORY_ETC) {
+               int prefix_len = strlen(content_category[0].content_type);
+
+               for (i = 0; i < SOUND_MIME_NUM; i++) {
+                       if (strstr(mimetype + prefix_len, sound_mime_table[i]) != NULL) {
+                               *category ^= MS_CATEGORY_ETC;
+                               *category |= MS_CATEGORY_SOUND;
+                               break;
+                       }
+               }
+       }
+
+       /*check music file in soun files. */
+       if (*category & MS_CATEGORY_SOUND) {
+               int prefix_len = strlen(content_category[0].content_type) + 1;
+
+               MS_DBG("mime_type : %s", mimetype + prefix_len);
+
+               for (i = 0; i < MUSIC_MIME_NUM; i++) {
+                       if (strcmp(mimetype + prefix_len, music_mime_table[i]) == 0) {
+                               *category ^= MS_CATEGORY_SOUND;
+                               *category |= MS_CATEGORY_MUSIC;
+                               break;
+                       }
+               }
+       } else if (*category & MS_CATEGORY_VIDEO) {
+               /*some video files don't have video stream. in this case it is categorize as music. */
+               char *ext;
+               /*"3gp" and "mp4" must check video stream and then categorize in directly. */
+               ext = strrchr(path, '.');
+               if (ext != NULL) {
+                       if ((strncasecmp(ext, _3GP_FILE, 4) == 0) || (strncasecmp(ext, _MP4_FILE, 5) == 0)) {
+                               int audio = 0;
+                               int video = 0;
+
+                               err = mm_file_get_stream_info(path, &audio, &video);
+                               if (err == 0) {
+                                       if (audio > 0 && video == 0) {
+                                               *category ^= MS_CATEGORY_VIDEO;
+                                               *category |= MS_CATEGORY_MUSIC;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       MS_DBG("category_from_ext : %d", *category);
+
+       return err;
+}
+
+void
+ms_check_db_updating(void)
+{
+       int vconf_value = 0;
+
+       /*wait if phone init is not finished. */
+       while (1) {
+               ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &vconf_value);
+
+               if (vconf_value != VCONFKEY_FILEMANAGER_DB_UPDATED) {
+                       MS_DBG("iNoti waits till init_phone finishes...");
+                       sleep(2);
+               } else {
+                       return;
+               }
+       }
+}
+
+#ifdef PROGRESS
+void
+ms_create_quickpanel(struct quickpanel *ms_quickpanel)
+{
+       MS_DBG_START();
+       int type_id;
+       int ret;
+
+       struct quickpanel_type *qp_type;
+
+       ret = quickpanel_get_type_id(NULL,
+                                  "/opt/apps/com.samsung.myfile/res/icons/default/small/com.samsung.myfile.png",
+                                  0);
+       MS_DBG("return value of quickpanel_get_type_id : %d", ret);
+
+       ms_quickpanel->type = ret;
+       ms_quickpanel->priv_id = getpid();
+       ms_quickpanel->group_id = 0;
+       ms_quickpanel->title = "Media scanning";
+       ms_quickpanel->content = NULL;
+       ms_quickpanel->progress = 0;
+       ms_quickpanel->args = NULL;
+       ms_quickpanel->args_group = NULL;
+       ms_quickpanel->evt = QP_E_ONGOING;
+
+       ret = quickpanel_insert(ms_quickpanel);
+       MS_DBG("return value of quickpanel_insert : %d", ret);
+
+       MS_DBG_END();
+}
+
+void
+ms_update_progress(struct quickpanel *ms_quickpanel, double progress)
+{
+       MS_DBG_START();
+
+       MS_DBG("%lf", progress)
+           quickpanel_update_progress(ms_quickpanel->type,
+                                      ms_quickpanel->priv_id, progress);
+
+       MS_DBG_END();
+}
+
+void
+ms_delete_quickpanel(struct quickpanel *ms_quickpanel)
+{
+       MS_DBG_START();
+       int ret = 0;
+
+       ret = quickpanel_delete(ms_quickpanel->type, ms_quickpanel->priv_id);
+       MS_DBG("return value of quickpanel_delete : %d", ret);
+
+       MS_DBG_END();
+}
+#endif /*PROGRESS*/
+
index 6ca4c50..2979808 100755 (executable)
@@ -6,7 +6,6 @@ Uploaders:
 Build-Depends: debhelper (>= 5), autotools-dev,
                libglib2.0-dev,
                libslp-setting-dev,
-               libheynoti-dev,
                libmedia-service-dev,
                dlog-dev,
                drm-service-dev,