Added the ability to list files based on Mime type 76/86476/3 submit/tizen_mobile/20160907.131247 submit/tizen_mobile/20160908.122032
authorbhutani.92 <bhutani.92@samsung.com>
Thu, 1 Sep 2016 10:13:29 +0000 (15:43 +0530)
committerbhutani.92 <bhutani.92@samsung.com>
Fri, 2 Sep 2016 05:20:17 +0000 (10:50 +0530)
Change-Id: Ib591ea899c237f22320279b2ca96044bc6114c74
Signed-off-by: bhutani.92 <bhutani.92@samsung.com>
inc/mf-ug-main.h
inc/mf-ug-search.h
src/common/mf-ug-search.c
src/mf-ug-main.c
tizen-manifest.xml

index a9fc270..4b4ef72 100644 (file)
@@ -156,6 +156,9 @@ struct _ugUiGadget {
        char *title;
        char *domain;
        char *position;
+       char *mime;
+       char ***file_ext;
+       int ext_len;
 
        Eina_Bool silent;
        Eina_List *ug_pSearchFileList;
index 6584c8d..c78a82b 100644 (file)
@@ -165,7 +165,7 @@ int mf_ug_search_init(mf_search_handle *handle);
 int mf_ug_search_start(mf_search_handle handle,
                    const char **root_path,
                    unsigned int path_num,
-                   const char *needle,
+                   char *needle,
                    mf_search_option option,
                    void *user_data,
                    mf_search_filter_cb func,
index f957d24..511c274 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "mf-ug-dlog.h"
 #include "mf-ug-search.h"
+#include "mf-ug-util.h"
 #include "mf-ug-search-internal.h"
 
 
@@ -56,12 +57,15 @@ int mf_ug_search_init(mf_search_handle *handle)
 int mf_ug_search_start(mf_search_handle handle,
                        const char **root_path,
                        unsigned int path_num,
-                       const char *needle,
+                       char *needle,
                        mf_search_option option,
                        void *user_data,
                        mf_search_filter_cb func,
                        int category)
 {
+       ugData *ugd = (ugData *)user_data;
+       ug_mf_retvm_if(ugd == NULL, MF_SEARCH_ERROR_INVAL_P, "ugd is NULL");
+
        int ret = 0;
        if (!handle) {
                return MF_SEARCH_ERROR_INVAL_P;
@@ -74,10 +78,24 @@ int mf_ug_search_start(mf_search_handle handle,
        if (!needle && !func) {
                return MF_SEARCH_ERROR_INVAL_P;
        }
+       if (ugd->ug_UiGadget.ug_iFilterMode == SHOW_BY_EXTENSION && ugd->ug_UiGadget.mime) {
+               ug_debug("Multiple needle search in haystack...");
+               char mul_ext[1024] = "";
+               strcpy(mul_ext, ugd->ug_UiGadget.file_ext[0]);
+               for (int i = 1; i < ugd->ug_UiGadget.ext_len; i++) {
+                       strcat(mul_ext, ";");
+                       strcat(mul_ext, ugd->ug_UiGadget.file_ext[i]);
+                       if (g_strcmp0(ugd->ug_UiGadget.file_ext[i], "opml") == 0) {
+                               ugd->ug_UiGadget.ug_iImportMode = 1;
+                       }
+               }
+               needle = g_strdup(mul_ext);
+       }
+       ug_debug("needle is : [%s]", needle);
        ret = _mf_ug_search_start((ms_handle_t *) handle, root_path, path_num, needle, option, user_data, func, category);
 
        if (ret < 0) {
-               ms_error("Fail to start search ");
+               ug_error("Fail to start search ");
        }
        return ret;
 }
index cdd356a..5c13c9c 100644 (file)
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <sys/time.h>
 
+#include <mime_type.h>
 #include <media_content.h>
 #include <Elementary.h>
 #include <system_settings.h>
@@ -587,6 +588,24 @@ static void __mf_ug_main_set_filter_by_mime(void *data, const char *mime_type)
                        ugd->ug_UiGadget.ug_iFilterMode = SHOW_FOLDER_LIST;
                } else if (!strncmp(mime_type, UG_FILE_MIME_TYPE_ALL, strlen(mime_type))) {
                        ugd->ug_UiGadget.ug_iFilterMode = SHOW_ALL_LIST;
+               } else {
+                       ugd->ug_UiGadget.ug_iFilterMode = SHOW_BY_EXTENSION;
+                       ugd->ug_UiGadget.mime = mime_type;
+                       char **file_ext = NULL;
+                       int arr_len = 0;
+                       int ret = mime_type_get_file_extension(ugd->ug_UiGadget.mime, &file_ext, &arr_len);
+                       ugd->ug_UiGadget.file_ext = file_ext;
+                       ugd->ug_UiGadget.ext_len = arr_len;
+                       if (ret == MIME_TYPE_ERROR_NONE) {
+                               ug_debug("Various file extensions for mime_type %s are :", ugd->ug_UiGadget.mime);
+                               for (int i = 0; i < arr_len; i++) {
+                                       ug_debug("[%s]", file_ext[i]);
+                               }
+                               ugd->ug_UiGadget.ug_pExtension = strdup(file_ext[0]);
+                               if (g_strcmp0(file_ext[0], "opml") == 0) {
+                                       ugd->ug_UiGadget.ug_iImportMode = 1;
+                               }
+                       }
                }
        }
        if (ugd->ug_UiGadget.ug_iFilterMode != SHOW_BY_EXTENSION) {
@@ -769,6 +788,16 @@ static void __mf_ug_main_set_operation_select_mode(void *data, const char *selec
 }
 #endif
 
+static bool __mf_main_app_control_extra_data_cb(app_control_h app_control, const char *key, void *user_data)
+{
+       char *value = NULL;
+       app_control_get_extra_data(app_control, key, &value);
+       ug_debug("key: %s, value: %s", key, value);
+       UG_SAFE_FREE_CHAR(value);
+
+       return true;
+}
+
 /******************************
 ** Prototype    : __mf_ug_main_set_option_status
 ** Description  : Samsung
@@ -799,6 +828,7 @@ static void __mf_ug_main_set_operation_select_mode(void *data, const char *selec
        char *mime_type = NULL;
        char *title = NULL;
        char *domain = NULL;
+       char *uri = NULL;
        char *key[UG_OPTION_COUNT] = { "path", "select_type", "file_type",
                                       "marked_mode", "default ringtone",
                                       "view_mode", "title", "domain"
@@ -807,7 +837,14 @@ static void __mf_ug_main_set_operation_select_mode(void *data, const char *selec
        char *operation = NULL;
        app_control_clone(&(ugd->service), app_control);
        app_control_get_operation(app_control, &operation);
-       ug_error("operation is [%s]", operation);
+       ug_debug("operation is [%s]", operation);
+       app_control_get_uri(app_control, &uri);
+       ug_debug("uri is [%s]", uri);
+       app_control_get_mime(app_control, &mime_type);
+       ug_debug("mime is [%s]", mime_type);
+       ug_debug(">>>>>>>>>>>>>>>>>>> Listing all app_control key-value pair <<<<<<<<<<<<<<<<<<<");
+       app_control_foreach_extra_data(app_control, __mf_main_app_control_extra_data_cb, NULL);
+       ug_debug(">>>>>>>>>>>>>>>>>>> End Listing all app_control key-value pair <<<<<<<<<<<<<<<<<<<");
        app_control_get_extra_data(app_control, key[0], &path);
        app_control_get_extra_data(app_control, key[1], &select_mode);
        app_control_get_extra_data(app_control, key[2], &filter_mode);
@@ -816,7 +853,6 @@ static void __mf_ug_main_set_operation_select_mode(void *data, const char *selec
        app_control_get_extra_data(app_control, key[5], &view_mode);
        app_control_get_extra_data(app_control, key[6], &title);
        app_control_get_extra_data(app_control, key[7], &domain);
-       app_control_get_mime(app_control, &mime_type);
        SECURE_ERROR("path is [%s] select_mode is [%s] filter_mode is [%s] marked_mode is [%s] default_ringtone is [%s] view_mode is [%s] title is [%s] domain is [%s]",
                     path, select_mode, filter_mode, marked_mode, default_ringtone, view_mode, title, domain);
 
@@ -878,13 +914,6 @@ static void __mf_ug_main_set_operation_select_mode(void *data, const char *selec
        } else {
                __mf_ug_main_set_select_mode(ugd, select_mode);
 
-               ug_error("mime_type is [%s]", mime_type);
-               if (mime_type) {
-                       __mf_ug_main_set_filter_by_mime(ugd, mime_type);
-               } else {
-                       __mf_ug_main_set_filter_mode(ugd, filter_mode);
-               }
-
 #ifdef UG_OPERATION_SELECT_MODE
                char *operation_select_mode = NULL;
                app_control_get_extra_data(app_control, APP_CONTROL_DATA_SELECTION_MODE, &operation_select_mode);
@@ -916,6 +945,43 @@ static void __mf_ug_main_set_operation_select_mode(void *data, const char *selec
        app_control_get_extra_data(app_control, APP_CONTROL_DATA_TOTAL_COUNT, &number);
        __mf_ug_main_set_max_len_option(ugd, number);
 
+       if (mime_type) {
+               ug_debug("Setting filter by mime_type [%s]", mime_type);
+               __mf_ug_main_set_filter_by_mime(ugd, mime_type);
+               ugd->ug_UiGadget.ug_iSelectMode = IMPORT_PATH_SELECT_MODE;
+       } else {
+               ug_debug("Setting filter by filter_mode [%s]", filter_mode);
+               __mf_ug_main_set_filter_mode(ugd, filter_mode);
+       }
+
+       if (mime_type) {
+               char *storage_path = NULL;
+               storage_path = strstr(uri, PHONE_FOLDER);
+               if (storage_path == NULL) {
+                       storage_path = strstr(uri, MEMORY_FOLDER);
+                       if (storage_path == NULL) {
+                               path = NULL;
+                       } else {
+                               path = MEMORY_FOLDER;
+                       }
+               } else {
+                       path = PHONE_FOLDER;
+               }
+
+               if (path != NULL) {
+                       ug_debug("Storage path is: %s", path);
+                       ugd->ug_Status.ug_pPath = g_string_new(path);
+                       if (ugd->ug_Status.ug_iViewType == mf_ug_view_root) {
+                               ugd->ug_Status.ug_iViewType = mf_ug_view_normal;
+                               mf_ug_navi_bar_create_default_view(ugd);
+                               mf_ug_util_path_push(ugd->ug_Status.ug_pPath->str, ugd->ug_Status.ug_iViewType);
+                       } else {
+                               mf_ug_navi_bar_create_default_view(ugd);
+                               mf_ug_util_path_push(ugd->ug_Status.ug_pPath->str, ugd->ug_Status.ug_iViewType);
+                       }
+               }
+       }
+
        UG_SAFE_FREE_CHAR(number);
        UG_SAFE_FREE_CHAR(path);
        UG_SAFE_FREE_CHAR(select_mode);
index 5fac0ae..0859c2f 100644 (file)
@@ -58,9 +58,6 @@
                <icon>ug-myfile-efl.png</icon>
        <app-control>
                <operation name="http://tizen.org/appcontrol/operation/pick"/>
-       </app-control>
-       <app-control>
-               <operation name="http://tizen.org/appcontrol/operation/pick"/>
                <mime name="image/*"/>
                <mime name="video/*"/>
                <mime name="text/vcard"/>