summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon.ko@samsung.com>2013-04-09 07:47:30 (GMT)
committerHyunjun Ko <zzoon.ko@samsung.com>2013-04-09 07:47:30 (GMT)
commit26b05feb5117117b1fb53545ef7cbe967beb7fbd (patch)
treee592fa26f81df61ce62456e7599e7f5e32256986
parentdff61810f30c4543a6be9fa44256a77a744beb1f (diff)
downloadlibmedia-thumbnail-26b05feb5117117b1fb53545ef7cbe967beb7fbd.zip
libmedia-thumbnail-26b05feb5117117b1fb53545ef7cbe967beb7fbd.tar.gz
libmedia-thumbnail-26b05feb5117117b1fb53545ef7cbe967beb7fbd.tar.bz2
1. Monitoring MMC_STATUS 2. Fix prevent defects
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xserver/include/thumb-server-internal.h1
-rwxr-xr-xserver/thumb-server-internal.c49
-rwxr-xr-xserver/thumb-server.c7
-rwxr-xr-xsrc/include/util/media-thumb-db.h1
5 files changed, 56 insertions, 4 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index 324849d..945214f 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -1,6 +1,6 @@
Name: libmedia-thumbnail
Summary: Media thumbnail service library for multimedia applications.
-Version: 0.1.69
+Version: 0.1.75
Release: 1
Group: utils
License: Apache
diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h
index d8a16f3..bcf5f4d 100755
--- a/server/include/thumb-server-internal.h
+++ b/server/include/thumb-server-internal.h
@@ -46,6 +46,7 @@ gboolean _thumb_daemon_udp_thread(void *data);
gboolean _thumb_daemon_start_jobs(gpointer data);
void _thumb_daemon_finish_jobs();
+void _thumb_daemon_mmc_eject_vconf_cb(void *data);
void _thumb_daemon_vconf_cb(void *data);
gboolean _thumb_server_prepare_socket(int *sock_fd);
gboolean _thumb_server_read_socket(GIOChannel *src,
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index a993e59..83f3186 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -72,6 +72,46 @@ void _thumb_daemon_finish_jobs()
return;
}
+int _thumb_daemon_mmc_status()
+{
+ int err = -1;
+ int status = -1;
+
+ err = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status);
+ if (err == 0) {
+ return status;
+ } else if (err == -1) {
+ thumb_err("vconf_get_int failed : %d", err);
+ } else {
+ thumb_err("vconf_get_int Unexpected error code: %d", err);
+ }
+
+ return status;
+}
+
+void _thumb_daemon_mmc_eject_vconf_cb(void *data)
+{
+ int err = -1;
+ int status = 0;
+
+ thumb_warn("_thumb_daemon_vconf_cb called");
+
+ err = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status);
+ if (err == 0) {
+ if (status == VCONFKEY_SYSMAN_MMC_REMOVED || status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
+ thumb_warn("SD card is ejected or not mounted. So media-thumbnail-server stops jobs to extract all thumbnails");
+
+ _thumb_daemon_stop_job();
+ }
+ } else if (err == -1) {
+ thumb_err("vconf_get_int failed : %d", err);
+ } else {
+ thumb_err("vconf_get_int Unexpected error code: %d", err);
+ }
+
+ return;
+}
+
void _thumb_daemon_vconf_cb(void *data)
{
int err = -1;
@@ -153,8 +193,13 @@ int _thumb_daemon_all_extract()
return MEDIA_THUMB_ERROR_DB;
}
- snprintf(query_string, sizeof(query_string), SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA);
- thumb_dbg("Query: %s", query_string);
+ if (_thumb_daemon_mmc_status() == VCONFKEY_SYSMAN_MMC_MOUNTED) {
+ snprintf(query_string, sizeof(query_string), SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA);
+ } else {
+ snprintf(query_string, sizeof(query_string), SELECT_PATH_FROM_UNEXTRACTED_THUMB_INTERNAL_MEDIA);
+ }
+
+ thumb_warn("Query: %s", query_string);
err = sqlite3_prepare_v2(sqlite_db_handle, query_string, strlen(query_string), &sqlite_stmt, NULL);
if (SQLITE_OK != err) {
diff --git a/server/thumb-server.c b/server/thumb-server.c
index 9e7c1e1..2e9cda4 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -82,7 +82,12 @@ int main()
/* Set VCONFKEY_SYSMAN_MMC_FORMAT callback to get noti for SD card format */
err = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_FORMAT, (vconf_callback_fn) _thumb_daemon_vconf_cb, NULL);
if (err == -1)
- thumb_err("vconf_notify_key_changed %s fails", VCONFKEY_SYSMAN_MMC_FORMAT);
+ thumb_err("vconf_notify_key_changed : %s fails", VCONFKEY_SYSMAN_MMC_FORMAT);
+
+ /* Set VCONFKEY_SYSMAN_MMC_STATUS callback to get noti when SD card is ejected */
+ err = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, (vconf_callback_fn) _thumb_daemon_mmc_eject_vconf_cb, NULL);
+ if (err == -1)
+ thumb_err("vconf_notify_key_changed : %s fails", VCONFKEY_SYSMAN_MMC_STATUS);
/* Create and bind new UDP socket */
if (!_thumb_server_prepare_socket(&sockfd)) {
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
index f8e37f9..effd3f4 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -39,6 +39,7 @@
#else
#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from media where thumbnail_path is null and validity=1 and (media_type=0 or media_type=1);"
+#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_INTERNAL_MEDIA "SELECT path from media where thumbnail_path is null and validity=1 and (media_type=0 or media_type=1) and storage_type=0;"
#define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM media WHERE path='%q';"
#define SELECT_TYPE_BY_PATH "SELECT media_type FROM media WHERE path='%q';"
#define SELECT_WH_BY_PATH "SELECT width, height FROM media WHERE path='%q';"