summaryrefslogtreecommitdiff
path: root/main/src/util/ivug-file-info.c
diff options
context:
space:
mode:
authorJisung Ahn <jcastle.ahn@samsung.com>2012-08-21 21:33:06 +0900
committerJisung Ahn <jcastle.ahn@samsung.com>2012-08-21 21:48:17 +0900
commita914248a31229bb81ed4ede970ca23e2490e0387 (patch)
tree8e3d763e83861131c778b442b3333496be1b23b7 /main/src/util/ivug-file-info.c
parent8b42d4bb33943903b7160bb963bf7e7c6824e9ef (diff)
downloadug-image-viewer-efl-a914248a31229bb81ed4ede970ca23e2490e0387.tar.gz
ug-image-viewer-efl-a914248a31229bb81ed4ede970ca23e2490e0387.tar.bz2
ug-image-viewer-efl-a914248a31229bb81ed4ede970ca23e2490e0387.zip
initial upload
Change-Id: Ie9df15e2a3ce6a47e65f48aa0cfb43c2622b74d7
Diffstat (limited to 'main/src/util/ivug-file-info.c')
-rwxr-xr-xmain/src/util/ivug-file-info.c403
1 files changed, 0 insertions, 403 deletions
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 <libexif/exif-data.h> //for exif
-#include <mm_file.h>
-#include <mmf/mm.h>
-#include <mmf/mm_file.h>
-#include <aul.h>
-
-#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;
-}
-
-