From a914248a31229bb81ed4ede970ca23e2490e0387 Mon Sep 17 00:00:00 2001 From: Jisung Ahn Date: Tue, 21 Aug 2012 21:33:06 +0900 Subject: initial upload Change-Id: Ie9df15e2a3ce6a47e65f48aa0cfb43c2622b74d7 --- main/src/util/ivug-file-info.c | 403 ----------------------------------------- main/src/util/ivug-file-info.h | 57 ------ main/src/util/ivug-listpopup.c | 274 ---------------------------- main/src/util/ivug-listpopup.h | 81 --------- main/src/util/ivug-util.c | 286 ----------------------------- main/src/util/ivug-util.h | 78 -------- main/src/util/ivug-widget.c | 209 --------------------- main/src/util/ivug-widget.h | 68 ------- 8 files changed, 1456 deletions(-) delete mode 100755 main/src/util/ivug-file-info.c delete mode 100755 main/src/util/ivug-file-info.h delete mode 100755 main/src/util/ivug-listpopup.c delete mode 100755 main/src/util/ivug-listpopup.h delete mode 100755 main/src/util/ivug-util.c delete mode 100755 main/src/util/ivug-util.h delete mode 100755 main/src/util/ivug-widget.c delete mode 100755 main/src/util/ivug-widget.h (limited to 'main/src/util') diff --git a/main/src/util/ivug-file-info.c b/main/src/util/ivug-file-info.c deleted file mode 100755 index 6419761..0000000 --- a/main/src/util/ivug-file-info.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - - -#include "ivug-common.h" - -#include //for exif -#include -#include -#include -#include - -#include "ivug-file-info.h" - -bool _get_video_gps_info(const char *filepath, double *latitude, double *longitude) -{ - IV_ASSERT(filepath != NULL); - IV_ASSERT(latitude != NULL); - IV_ASSERT(longitude != NULL); - - MMHandleType tag = (MMHandleType) NULL; - int err = -1; - char *err_msg = NULL; - double gps_value = 0.0; - - *latitude = 0.0; - *longitude = 0.0; - - err = mm_file_create_tag_attrs(&tag, filepath); - if (!tag) - { - MSG_UTIL_ERROR("mm_file_create_tag_attrs ERROR %s", filepath); - return false; - } - - err = mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_LATIDUE, &gps_value, NULL); - if (err == 0) - { - MSG_UTIL_HIGH("latitude: %f", gps_value); - if (gps_value != 0.0) - { - *latitude = gps_value; - } - } - else if (err_msg) - { - MSG_UTIL_ERROR("mm_file_get_attrs fails : %s", err_msg); - free(err_msg); - err_msg = NULL; - mm_file_destroy_tag_attrs(tag); - - return false; - } - - err = mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_LONGITUDE, &gps_value, NULL); - if (err == 0) - { - MSG_UTIL_HIGH("longitude: %f", gps_value); - if (gps_value != 0.0) - { - *longitude = gps_value; - } - } - else if (err_msg) - { - MSG_UTIL_ERROR("mm_file_get_attrs fails : %s", err_msg); - free(err_msg); - err_msg = NULL; - mm_file_destroy_tag_attrs(tag); - return false; - } - - mm_file_destroy_tag_attrs(tag); - return true; -} - -bool _get_image_gps_info(const char* filepath, double *latitude, double *longitude) -{ - IV_ASSERT(filepath != NULL); - IV_ASSERT(latitude != NULL); - IV_ASSERT(longitude != NULL); - -#define BUF_LEN (255) - - ExifData *ed = NULL; - ExifEntry *entry = NULL; - ExifIfd ifd; - ExifTag tag; - char buf[BUF_LEN+1] = {'\0',}; - - /** get exifdata*/ - ed = exif_data_new_from_file(filepath); - if (!ed) - { - return false; - } - - ifd = EXIF_IFD_GPS; - tag = EXIF_TAG_GPS_LATITUDE; - - /** get exifentry*/ - entry = exif_data_get_entry(ed, tag); - - if (!entry) - { - return false; - } - - /** get value of the entry*/ - if(exif_entry_get_value(entry, buf, BUF_LEN) == NULL) - { - exif_data_unref(ed); - return false; - } - - { - buf[strlen(buf)] = '\0'; - double tmp_arr[3] = { 0.0, 0.0, 0.0 }; - int count = 0; - char* p = strtok(buf, ", "); - /** split the buf by , */ - while(p != NULL) - { - tmp_arr[count] = atof(p); - count++; - p=strtok(NULL, ", "); - } - - if( count != 3 ) - { - MSG_UTIL_ERROR("Cannot get latitude info : %s", p); - exif_data_unref(ed); - return false; - } - *latitude = tmp_arr[0] + tmp_arr[1]/60 + tmp_arr[2]/3600; - } - - tag = EXIF_TAG_GPS_LONGITUDE; - - entry = exif_data_get_entry(ed, tag); - - /** get value of the entry*/ - if(exif_entry_get_value(entry, buf, BUF_LEN) == NULL) - { - exif_data_unref(ed); - return false; - } - - { - buf[strlen(buf)] = '\0'; - double tmp_arr[3] = { 0.0, 0.0, 0.0 }; - int count = 0; - char* p = strtok(buf, ", "); - /** split the buf by , */ - while(p != NULL) - { - tmp_arr[count] = atof(p); - count++; - p=strtok(NULL, ", "); - } - - if( count != 3 ) - { - MSG_UTIL_ERROR("Cannot get Longitude info : %s", p); - exif_data_unref(ed); - return false; - } - - *longitude = tmp_arr[0] + tmp_arr[1]/60 + tmp_arr[2]/3600; - } - - exif_data_unref(ed); - - return true; -} - - - -static bool _get_image_resolution(const char *path, int * /* OUT */ pWidth, int * /* OUT */pHeight) -{ - IV_ASSERT(path != NULL); - - int width = 0; - int height = 0; - - Evas *canvas; - Ecore_Evas *ee; - - ee = ecore_evas_buffer_new(1, 1); - if (!ee) - { - MSG_DETAIL_ERROR("Cannot get EVAS"); - return false; - } - - canvas = ecore_evas_get(ee); - - Evas_Object *img = evas_object_image_add(canvas); - - evas_object_image_file_set(img, NULL, NULL); - evas_object_image_load_orientation_set(img, EINA_TRUE); - evas_object_image_load_scale_down_set(img, 0); - - evas_object_image_file_set(img, path, NULL); // TODO : Error check - evas_object_image_size_get(img, &width, &height); - - evas_object_image_file_set(img, NULL, NULL); - evas_object_del(img); - - ecore_evas_free(ee); - - *pWidth = width; - *pHeight = height; - - MSG_DETAIL_HIGH("widht & height is [%d, %d]", width, height); - - return true; -} - - -static bool -_get_video_resolution(const char *path, int * /* OUT */ pWidth, int * /* OUT */pHeight) -{ - IV_ASSERT(path != NULL); - - int w = 0; - int h = 0; - int error_code = MM_ERROR_NONE; - - MMHandleType content = 0; - char *err_attr_name = NULL; - - error_code = mm_file_create_content_attrs(&content, path); - - if ( error_code != MM_ERROR_NONE ) - { - MSG_UTIL_ERROR("mm_file_create_content_attrs() failed : ret=0x%08x", error_code); - return false; - } - - error_code = MM_ERROR_NONE; - error_code = mm_file_get_attrs(content, &err_attr_name, - MM_FILE_CONTENT_VIDEO_WIDTH, &w, - MM_FILE_CONTENT_VIDEO_HEIGHT, &h, - NULL - ); - - if (error_code != MM_ERROR_NONE) - { - MSG_DETAIL_ERROR("mm_file_get_attrs() failed : ret=0x%08x", error_code); - MSG_DETAIL_ERROR("Error attribute name : %s", err_attr_name); - free(err_attr_name); - - error_code = mm_file_destroy_content_attrs(content); - if (error_code != 0) - { - MSG_DETAIL_ERROR("mm_file_destroy_content_attrs() failed : ret=0x%08x", error_code); - } - - return false; - } - - *pWidth = w; - *pHeight = h; - - error_code = mm_file_destroy_content_attrs(content); - if (error_code != 0) - { - MSG_DETAIL_ERROR("mm_file_destroy_content_attrs() failed : ret=0x%08x", error_code); - } - - return true; -} - -bool ivug_fileinfo_get_image_resolution(const char *path, int * /* OUT */ pWidth, int * /* OUT */pHeight) -{ - if ( path == NULL ) - { - MSG_UTIL_ERROR("Cannot get image resolution. path is NULL"); - return false; - } - - if(ivug_is_file_exist(path) == false) - { - MSG_UTIL_ERROR("%s : %s is not exist", __func__, path); - return false; - } - - return _get_image_resolution(path, pWidth, pHeight); -} - - -bool ivug_fileinfo_get_video_resolution(const char *path, int * /* OUT */ pWidth, int * /* OUT */pHeight) -{ - if ( path == NULL ) - { - MSG_UTIL_ERROR("Cannot get video resolution. path is NULL"); - return false; - } - - if(ivug_is_file_exist(path) == false) - { - MSG_UTIL_ERROR("%s : %s is not exist", __func__, path); - return false; - } - - return _get_video_resolution(path, pWidth, pHeight); -} - -bool ivug_fileinfo_get_video_gps_info(const char *path, double *latitude, double *longitude) -{ - if ( path == NULL ) - { - MSG_UTIL_ERROR("Cannot get video gps location. path is NULL"); - return false; - } - - if(ivug_is_file_exist(path) == false) - { - MSG_UTIL_ERROR("%s : %s is not exist", __func__, path); - return false; - } - - return _get_video_gps_info(path, latitude, longitude); -} - - -bool ivug_fileinfo_get_image_gps_info(const char* path, double *latitude, double *longitude) -{ - if ( path == NULL ) - { - MSG_UTIL_ERROR("Cannot get image gps location. path is NULL"); - return false; - } - - if(ivug_is_file_exist(path) == false) - { - MSG_UTIL_ERROR("%s : %s is not exist", __func__, path); - return false; - } - - return _get_image_gps_info(path, latitude, longitude); -} - - -char *ivug_fileinfo_get_file_extension(const char *path) -{ - if ( path == NULL ) - { - MSG_UTIL_ERROR("Cannot get file extension. path is NULL"); - return NULL; - } - - char *ext = NULL; - - ext = strrchr(path, '.'); - - if ( (ext != NULL) && ((ext+1) != NULL) ) - { - return strdup(ext + 1); - } - - return NULL; - -} - -char *ivug_fileinfo_get_mime_type(const char *path) -{ - if ( path == NULL ) - { - MSG_UTIL_ERROR("Cannot get mine type. path is NULL"); - return NULL; - } - - //check mine type. - char *mime_type = NULL; - - efreet_mime_init(); - const char *type = NULL; - type = efreet_mime_type_get(ecore_file_file_get(path)); - if ( type != NULL ) - { - mime_type = strdup(type); - } - efreet_mime_shutdown(); - - return mime_type; -} - - diff --git a/main/src/util/ivug-file-info.h b/main/src/util/ivug-file-info.h deleted file mode 100755 index ac8a3fa..0000000 --- a/main/src/util/ivug-file-info.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - - -#ifndef __IVUG_FILE_INFO_H__ -#define __IVUG_FILE_INFO_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - ivug_fileinfo_*() returns false when error. otherwise return true and fill proper value in [out] param -*/ -bool ivug_fileinfo_get_image_gps_info(const char* filepath, double * /* OUT */ latitude, double * /* OUT */ longitude); -bool ivug_fileinfo_get_video_gps_info(const char *filepath, double * /* OUT */ latitude, double * /* OUT */ longitude); - -bool ivug_fileinfo_get_video_resolution(const char *filepath, int * /* OUT */ pWidth, int * /* OUT */pHeight); -bool ivug_fileinfo_get_image_resolution(const char *filepath, int * /* OUT */ pWidth, int * /* OUT */pHeight); - - -/* - return file extension string. - - CAUTION : user should free returned string. -*/ -char *ivug_fileinfo_get_file_extension(const char *filepath); - - -/* - return mine type from file. - - CAUTION : user should free returned string. -*/ -char *ivug_fileinfo_get_mime_type(const char *path); - - -#ifdef __cplusplus -} -#endif - - -#endif // __IVUG_FILE_INFO_H__ - diff --git a/main/src/util/ivug-listpopup.c b/main/src/util/ivug-listpopup.c deleted file mode 100755 index 6ea395f..0000000 --- a/main/src/util/ivug-listpopup.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - - -#include "ivug-common.h" -#include "ivug-listpopup.h" - - -#define POPUP_RESPONSE_NOT_SELECTED (-99) - - -typedef struct { - Evas_Object *popup; - - Evas_Smart_Cb response; - void* user_data; - -} Selectpopup; - - -static char * -_on_label_set(void *data, Evas_Object *obj, const char *part) -{ - IV_ASSERT( data != NULL); - - ivug_listpopup_item *item = (ivug_listpopup_item *)data; - - return strdup(item->caption); //dump -} - - -static void -_on_genlist_selected(void *data, Evas_Object *obj, void *event_info) -{ - Selectpopup *pData = data; - Evas_Object *genlist = obj; - Elm_Object_Item *genitem = (Elm_Object_Item *)event_info; - - IV_ASSERT( genlist != NULL); - - if (genitem == NULL) - { - MSG_MAIN_ERROR("genlist item is NULL"); - return; - } - - ivug_listpopup_item *item = (ivug_listpopup_item *)elm_object_item_data_get(genitem); - -// Call response - pData->response(pData->user_data, pData->popup, item); - -} - - -static ivug_listpopup_item *_dup_item(ivug_listpopup_item *item) -{ - ivug_listpopup_item *newitem = NULL; - - newitem = calloc(1, sizeof(ivug_listpopup_item)); - - newitem->index = item->index; - - if ( item->iconpath ) - newitem->iconpath = strdup(item->iconpath); - - if ( item->caption ) - newitem->caption = strdup(item->caption); // Should be freed - - newitem->data = item->data; - - return newitem; -} - - -static void _on_genlist_item_del(void *data, Evas_Object *obj) -{ - IV_ASSERT( data != NULL); - - ivug_listpopup_item *item = data; - - MSG_IMAGEVIEW_HIGH("Remove genlist item"); - - if ( item->caption ) - free(item->caption); - - if ( item->iconpath ) - free(item->iconpath); - - free(item); -} - - -static void -_on_popup_close(void *data, Evas_Object *obj, void *event_info) -{ - Selectpopup *pData = data; - - pData->response(pData->user_data, pData->popup, NULL); // Call user callback -} - -static void _on_popup_deleted(void * data, Evas * e, Evas_Object * obj, void * event_info) -{ - MSG_IMAGEVIEW_HIGH("Remove popup"); - - Selectpopup *pData = data; - - free(pData); -} - - - -typedef struct { - Eina_List *list; -} _ivug_listpopup_itemlist; - - -ivug_listpopup_itemlist ivug_listpopup_itemlist_new() -{ - _ivug_listpopup_itemlist *pList = malloc(sizeof(_ivug_listpopup_itemlist)); - IV_ASSERT(pList != NULL); - - pList->list = NULL; - - return (ivug_listpopup_itemlist)pList; -} - -unsigned int ivug_listpopup_itemlist_get_count(ivug_listpopup_itemlist items) -{ - _ivug_listpopup_itemlist *pList = items; - IV_ASSERT(pList != NULL); - - return eina_list_count(pList->list); -} - -ivug_listpopup_item *ivug_listpopup_itemlist_add(ivug_listpopup_itemlist items, int index, const char *iconpath, const char *caption, void *data, bool bDisabled) -{ - _ivug_listpopup_itemlist *pList = items; - IV_ASSERT(pList != NULL); - - ivug_listpopup_item *item = NULL; - - { - item = calloc(1, sizeof(ivug_listpopup_item)); - - item->index = index; - - if ( iconpath ) - item->iconpath = strdup(iconpath); - - if ( caption ) - item->caption = strdup(caption); // Should be freed - - item->data = data; - item->bDisabled = bDisabled; - } - - pList->list = eina_list_append(pList->list, item); - - return item; - - -} - -void ivug_listpopup_itemlist_free(ivug_listpopup_itemlist items) -{ - _ivug_listpopup_itemlist *pList = items; - IV_ASSERT(pList != NULL); - - ivug_listpopup_item *item = NULL; - - EINA_LIST_FREE(pList->list, item ) - { - if ( item->caption ) - free(item->caption); - - if ( item->iconpath ) - free(item->iconpath); - - free(item); - } - - free(pList); -} - - -Evas_Object *ivug_listpopup_show(Evas_Object *parent, const char* title, ivug_listpopup_itemlist items, Evas_Smart_Cb response, void* user_data) -{ - Evas_Object *popup; - -// create popup - popup = elm_popup_add(parent); - if (!popup) - { - MSG_IMAGEVIEW_ERROR("Error : popup create failed."); - return NULL; - } - - elm_object_style_set(popup, "menustyle"); - elm_object_part_text_set(popup, "title,text", title); - - evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_weight_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL); - - Evas_Object *btn_close = elm_button_add(popup); - elm_object_text_set(btn_close, IDS_CLOSE); - elm_object_part_content_set(popup, "button1", btn_close); - -// create genlist - Evas_Object *genlist; - static Elm_Genlist_Item_Class itc = {0,}; - - genlist = elm_genlist_add(popup); - - itc.version = ELM_GENLIST_ITEM_CLASS_VERSION; - itc.item_style = "1text"; - itc.func.text_get = _on_label_set; - itc.func.content_get = NULL; - itc.func.state_get = NULL; - itc.func.del = _on_genlist_item_del; - - evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); - - Selectpopup *pData = malloc(sizeof(Selectpopup)); - - pData->popup = popup; - pData->response = response; - pData->user_data = user_data; - - _ivug_listpopup_itemlist *pList = items; - - ivug_listpopup_item *pItem = NULL; - Eina_List *tmp; - Elm_Object_Item *gItem; - - - EINA_LIST_FOREACH(pList->list, tmp, pItem) - { - gItem = elm_genlist_item_append(genlist, &itc, _dup_item(pItem), NULL /* parent */, ELM_GENLIST_ITEM_NONE, _on_genlist_selected, pData); - - elm_object_item_disabled_set(gItem, pItem->bDisabled); - } - -// Put together - Evas_Object *box; - box = elm_box_add(popup); - evas_object_show(genlist); - elm_box_pack_end(box, genlist); - elm_object_content_set(popup, box); - - evas_object_smart_callback_add(btn_close, "clicked", _on_popup_close, pData); - - evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _on_popup_deleted, pData); - - evas_object_show(popup); - - return popup; - -} - - diff --git a/main/src/util/ivug-listpopup.h b/main/src/util/ivug-listpopup.h deleted file mode 100755 index 11715eb..0000000 --- a/main/src/util/ivug-listpopup.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - - -#ifndef __IVUG_LISTPOPUP_H__ -#define __IVUG_LISTPOPUP_H__ - -typedef struct { - int index; - - char *iconpath; - char *caption; - void *data; - - bool bDisabled; // Item is disabled when true. -} ivug_listpopup_item; - -typedef void *ivug_listpopup_itemlist; - -/* - Helper functions for ivug_listpopup_item -*/ -ivug_listpopup_itemlist ivug_listpopup_itemlist_new(); - -ivug_listpopup_item *ivug_listpopup_itemlist_add(ivug_listpopup_itemlist items, int index, const char *iconpath, const char *caption, void *data, bool bDisabled); - -void ivug_listpopup_itemlist_free(ivug_listpopup_itemlist items); - - - -/* - Create & Show popup including genlist. - - example - - void _on_selected(void *data, Evas_Object *obj, void *event_info) - { - Evas_Object *popup = genlist; - ivug_listpopup_item *item = event_info; - int nIndex = event_info; - - if ( nIndex == 1 ) - printf("1 is selected"); - - evas_object_del(popup); // Show destroy popup explicitly - mypopup = NULL; - } - - ... - { - ivug_listpopup_itemlist items = ivug_listpopup_itemlist_new(); - - ivug_listpopup_itemlist_add(items, 0, NULL, "Select me 1", NULL, false); - ivug_listpopup_itemlist_add(items, 1, NULL, "Select me 1", NULL, false); - ivug_listpopup_itemlist_add(items, 2, "/data/myicon.png", "Select me 1", NULL, false); - - mypopup = ivug_selectpopup_show(parent, "example", items, v, myData); - - eina_list_free(items); - } - - -*/ -Evas_Object *ivug_listpopup_show(Evas_Object *parent, const char* title, ivug_listpopup_itemlist items , Evas_Smart_Cb response, void* user_data); - - -#endif // __IVUG_LISTPOPUP_H__ - diff --git a/main/src/util/ivug-util.c b/main/src/util/ivug-util.c deleted file mode 100755 index 496f027..0000000 --- a/main/src/util/ivug-util.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - - -#include "ivug-common.h" - -#include -#include -#include - -#include -#include -#include - -#include -#include - -/* - If filepath is web url, return TRUE. - -*/ -bool ivug_is_web_uri(const char* uri) -{ -//check file url type. local , http, ftp. - IV_ASSERT(uri != NULL); - - static const char* web_protocal_name[] = - { - "http://", - "ftp://", - NULL, - }; - - int i = 0; - while (web_protocal_name[i] != NULL) - { - if ( strlen(uri) > strlen(web_protocal_name[i]) ) - { - if (strncmp(uri, web_protocal_name[i], strlen(web_protocal_name[i])) == 0) - { - return true; - } - } - - i++; - } - - MSG_UTIL_MED("Not web uri. %s", uri); - - return false; -} - - -unsigned int get_distance(int prevX, int prevY, int X, int Y) -{ -#include - int dx = prevX - X; - int dy = prevY - Y; - - return sqrt(dx*dx + dy*dy); -} - - - -#define USE_ECORE_FILE - -#include - -/* - Remove fname file. - Returns true fname is not exist or removed sucessfully -*/ -bool ivug_remove_file(const char *filepath) -{ - char error_msg[256]; - if (ecore_file_exists(filepath) == EINA_FALSE) - { - MSG_UTIL_ERROR("Already removed.%s", filepath); - return true; - } - -#ifdef USE_ECORE_FILE - if ( ecore_file_unlink(filepath) == EINA_FALSE) - { - MSG_UTIL_ERROR("Cannot remove file : %s %s", filepath, strerror_r(errno, error_msg, sizeof(error_msg)) ); - return false; - } - - return true; -#else - if ( unlink(filepath) != 0 ) - { - MSG_UTIL_ERROR("Cannot remove file : %s %s", filepath, strerror_r(errno, error_msg, sizeof(error_msg)) ); - return false; - } - - return true; -#endif -} - -bool ivug_rename_file(const char *src, const char *dst) -{ - if (ecore_file_exists(src) == EINA_FALSE) - { - MSG_UTIL_ERROR("Source file is not exist : %s", src); - return false; - } - - if (dst == NULL) - { - MSG_UTIL_ERROR("Destination file is NULL"); - return false; - } - - - char error_msg[256]; - - if ( rename(src, dst) < 0) - { - MSG_UTIL_ERROR("Cannot rename from %s to %s : %s", src, dst, strerror_r(errno, error_msg, sizeof(error_msg)) ); - return false; - } - - return true; -} - -char * -ivug_mktemp(char* filepath, char*ext) -{ - ivug_retv_if(!filepath || !ext, NULL); - - MSG_IVUG_HIGH("filepath %s, ext %s", filepath, ext); - - char tempname[IVUG_MAX_FILE_PATH_LEN+1] = {0}; - snprintf(tempname, sizeof(tempname), "%s_0.%s",filepath, ext); - int i = 1; - -// TODO : Will implement with another algorithm - while(ecore_file_exists(tempname) == EINA_TRUE ) - { - snprintf(tempname, sizeof(tempname),"%s_%d.%s", filepath, i, ext); - i++; - } - - MSG_IVUG_HIGH( " tempname %s, i %d", tempname, i); - - return strdup(tempname); -} - - -/* - Check whether given filepath file exists - - CAUTION : filepath cannot be NULL. -*/ -bool ivug_is_file_exist(const char* filepath) -{ - IV_ASSERT(filepath != NULL); - - if ( ecore_file_exists(filepath) == EINA_TRUE) - { - return true; - } - - return false; -} - - -/* - Returns start pointer of filename within filepath. - No memory allocated in this function. so user do not free returned pointer. - - CAUTION : filepath cannot be NULL. -*/ -const char * ivug_get_filename(const char *filepath) -{ - if ( filepath == NULL ) - { - MSG_UTIL_WARN("File path is NULL"); - return "NULL"; - } - -#define DIRECORY_SPLITTER '/' - const char*pFileName = NULL; - - pFileName = strrchr(filepath, DIRECORY_SPLITTER); - pFileName = (NULL == pFileName)? "": (pFileName+1); - - return pFileName; -} - - -/* - - Media service utility - -*/ - -#include - -UUID ivug_get_album_id_from_filepath(const char *filepath) -{ - int ret = 0; - Mitem* item = NULL; - - MediaSvcHandle *dbhandle = NULL; - - int err = media_svc_connect(&dbhandle); - if (err != MB_SVC_ERROR_NONE) - { - MSG_UTIL_ERROR("DB open error. %d", err); - return NULL; - } - - ret = minfo_get_item(dbhandle, filepath, &item); //get cluster id - if (ret != MB_SVC_ERROR_NONE) - { - MSG_UTIL_ERROR("Cannot find file in media db for %s", filepath); - return NULL; // Invalid id - } - - UUID cluster_uuid = INVALID_UUID; - - cluster_uuid = uuid_assign(item->cluster_uuid); - - minfo_destroy_mtype_item(item); - - err = media_svc_disconnect(dbhandle); - if (err != MB_SVC_ERROR_NONE) - { - MSG_SDATA_ERROR("media service finalize error=%d", err); - } - - return cluster_uuid; - -} - -int ivug_prohibit_lcd_off(void) -{ - MSG_UTIL_MED("START : Sleep disabled"); - return pm_lock_state(LCD_NORMAL, GOTO_STATE_NOW, 0); -} - -int ivug_allow_lcd_off(void) -{ - MSG_UTIL_MED("END : Sleep disabled"); - return pm_unlock_state(LCD_NORMAL, PM_KEEP_TIMER); -} - -#define MIME_TYPE_LEN (255) -#define MIME_TYPE_3GPP "video/3gpp" -#define PATH_CAMERA_LOCAL "/opt/media/Camera shots" -#define PATH_CAMERA_SDCARD "/opt/storage/sdcard/Camera shots/" - -/* Video editor can start when video exist in camera folder and 3gp file format */ - -bool ivug_is_editable_video_file(char *filepath) -{ - MSG_UTIL_MED("path = %s", filepath); - if(strncmp(filepath, PATH_CAMERA_LOCAL, strlen(PATH_CAMERA_LOCAL)) == 0 - || strncmp(filepath, PATH_CAMERA_SDCARD, strlen(PATH_CAMERA_SDCARD)) == 0) - { - char mime_type[MIME_TYPE_LEN] = {0,}; - aul_get_mime_from_file(filepath, mime_type, sizeof(mime_type)); - MSG_UTIL_MED("mime type = %s", mime_type); - if(strcmp(mime_type, MIME_TYPE_3GPP) == 0) - { - return true; - } - } - return false; -} - diff --git a/main/src/util/ivug-util.h b/main/src/util/ivug-util.h deleted file mode 100755 index 0c07169..0000000 --- a/main/src/util/ivug-util.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - - -#ifndef __IVUG_UTIL_H__ -#define __IVUG_UTIL_H__ - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - -*/ -bool ivug_is_web_uri(const char* uri); - -bool ivug_remove_file(const char *filepath); - -bool ivug_is_file_exist(const char* filepath); - -bool ivug_rename_file(const char *src, const char *dst); - -inline const char *ivug_get_filename(const char *filepath); - -inline unsigned int get_distance(int prevX, int prevY, int X, int Y); - -/* - Generate temporary file name with given path and extension. - returned value should free() by user. -*/ -char *ivug_mktemp(char* filepath, char*ext); - - -/* - Media service wrapper utility -*/ - -UUID ivug_get_album_id_from_filepath(const char *filepath); - - -/* - LCD sleep control. -*/ -int ivug_prohibit_lcd_off(void); -int ivug_allow_lcd_off(void); - - -/* - Get mime type from file path. - should free returned after use. -*/ - -bool ivug_is_editable_video_file(char *filepath); - -#ifdef __cplusplus -} -#endif - - - -#endif //__IVUG_UTIL_H__ - diff --git a/main/src/util/ivug-widget.c b/main/src/util/ivug-widget.c deleted file mode 100755 index fd43992..0000000 --- a/main/src/util/ivug-widget.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - - -#include "ivug-common.h" -#include "ivug-widget.h" -#include - -#include - -static void _on_obj_deleted(void * data, Evas * e, Evas_Object * obj, void * event_info) -{ - char *szMsg = (char *)data; - IV_ASSERT(szMsg != NULL); - - MSG_MAIN_HIGH("On Object deleted. %s", szMsg); - - free(szMsg); -} - -void ivug_on_obj_deleted(Evas_Object* obj, char *msg, const char *func, int line) -{ - static char buf[1024]; - - sprintf(buf, "%s(L%d):%s", func, line, msg); - - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _on_obj_deleted, strdup(buf)); -} - -Evas_Object* ivug_bg_add(Evas_Object* parent, int r, int g, int b) -{ - IV_ASSERT(parent != NULL); - - Evas_Object *bg = elm_bg_add(parent); - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); - -// elm_win_resize_object_add(parent, bg); - - elm_bg_color_set(bg, r, g, b); - - evas_object_show(bg); - - return bg; -} - -Evas_Object * -ivug_layout_add(Evas_Object *win, const char *edj, const char *group) -{ - IV_ASSERT(win != NULL); - - Evas_Object *layout; - - layout = elm_layout_add(win); - - if ( layout == NULL ) - { - MSG_SETAS_ERROR("Cannot create layout"); - return NULL; - } - - if (elm_layout_file_set(layout, edj, group) == EINA_FALSE) - { - MSG_SETAS_ERROR("edj loading fail, filepath=%s Group=%s", edj, group); - evas_object_del(layout); - return NULL; - } - - evas_object_size_hint_expand_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_fill_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - -#ifdef USE_WIN_AS_PARENT - elm_win_resize_object_add( ug_get_window(), layout); -#else - Evas_Coord x, y, w, h; - evas_object_geometry_get(win, &x, &y, &w, &h); - - evas_object_move(layout, x, y); - evas_object_resize(layout, w, h); -#endif - - evas_object_show(layout); - return layout; -} - -Evas_Object* -ivug_default_layout_add( Evas_Object *win) -{ - IV_ASSERT(win != NULL); - - Evas_Object *layout; - layout = elm_layout_add(win); - - if ( layout == NULL ) - { - MSG_SETAS_ERROR("Cannot create layout"); - return NULL; - } - - if ( elm_layout_theme_set( layout, "layout", "application", "default") == EINA_FALSE) - { - MSG_SETAS_ERROR("theme set fail, layout/application/defaulty"); - evas_object_del(layout); - return NULL; - } - - evas_object_size_hint_expand_set( layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_fill_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL ); - -#ifdef USE_WIN_AS_PARENT - elm_win_resize_object_add( ug_get_window(), layout); -#else - Evas_Coord x, y, w, h; - evas_object_geometry_get(parent, &x, &y, &w, &h); - - evas_object_move(layout, x, y); - evas_object_resize(layout, w, h); -#endif - - evas_object_show(layout); - return layout; -} - - -Evas_Object *ivug_button_add(Evas_Object *parent, char *style, char *caption, Evas_Object *icon, OnClickCB pFunc, const void * data ) -{ - IV_ASSERT(parent != NULL); - - Evas_Object *btn; - - btn = elm_button_add(parent); - if ( btn == NULL ) - { - return NULL; - } - - if ( style ) - elm_object_style_set(btn, style); - - if ( caption ) - elm_object_text_set(btn, caption); - - if ( icon ) - elm_object_part_content_set(btn, "icon", icon); - - elm_object_focus_allow_set(btn, EINA_FALSE); - evas_object_propagate_events_set(btn, EINA_FALSE); - - evas_object_smart_callback_add(btn, "clicked", pFunc, (void*)data); - - return btn; -} - -Evas_Object *ivug_icon_add(Evas_Object *parent, char *edjname, char *groupname) -{ - Evas_Object *icon; - - icon = elm_icon_add(parent); - - if ( elm_icon_file_set(icon, edjname, groupname) == EINA_FALSE) - { - MSG_IVUG_ERROR("Cannot file set. EDJ=%s Group=%s", edjname, groupname); - evas_object_del(icon); - return NULL; - } - - evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - elm_icon_resizable_set(icon, EINA_TRUE, EINA_TRUE); - evas_object_size_hint_expand_set(icon, 1, 1); - - return icon; -} - -Evas_Object *ivug_controlbar_add(Evas_Object *parent, const char *style) -{ - Evas_Object *toolbar = elm_toolbar_add(parent); - if (!toolbar) - { - MSG_MAIN_ERROR("create tool bar failed"); - return NULL; - } - elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND); - elm_object_style_set(toolbar, style); - - return toolbar; -} - - - -void -ivug_object_del(Evas_Object *obj) -{ - evas_object_del(obj); -} - - diff --git a/main/src/util/ivug-widget.h b/main/src/util/ivug-widget.h deleted file mode 100755 index 151ee1e..0000000 --- a/main/src/util/ivug-widget.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - - -#ifndef __IVUG_WIDGET_H__ -#define __IVUG_WIDGET_H__ - - -typedef void(*OnClickCB)(void *data, Evas_Object *obj, void *event_info); - -#ifdef __cplusplus -extern "C" { -#endif - -/* - Internal use only... use macro DELETE_LOG instead -*/ -void ivug_on_obj_deleted(Evas_Object* obj, char *msg, const char *func, int line); - - -#define DELETE_NOTIFY(obj) \ - ivug_on_obj_deleted(obj, #obj, __func__, __LINE__) - -/* - Create elm_bg with color - r,g,b -*/ -Evas_Object * -ivug_bg_add(Evas_Object* parent, int r, int g, int b); - -Evas_Object * -ivug_layout_add(Evas_Object *win, const char *edjname, const char *groupname); - -Evas_Object* -ivug_default_layout_add( Evas_Object *win); - -Evas_Object * -ivug_button_add(Evas_Object *parent, char *style, char *caption, Evas_Object *icon, OnClickCB pFunc, const void *data ); - -Evas_Object * -ivug_icon_add(Evas_Object *parent, char *edjname, char *groupname); - -Evas_Object * -ivug_controlbar_add(Evas_Object *parent, const char *style); - -void -ivug_object_del(Evas_Object *obj); - - -#ifdef __cplusplus -} -#endif - - -#endif // __IVUG_WIDGET_H__ - -- cgit v1.2.3