summaryrefslogtreecommitdiff
path: root/main/src/util/ivug-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/util/ivug-util.c')
-rwxr-xr-xmain/src/util/ivug-util.c286
1 files changed, 0 insertions, 286 deletions
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 <unistd.h>
-#include <stdlib.h>
-#include <aul.h>
-
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <pmapi.h>
-
-#include <media-svc.h>
-#include <visual-svc.h>
-
-/*
- 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 <math.h>
- int dx = prevX - X;
- int dy = prevY - Y;
-
- return sqrt(dx*dx + dy*dy);
-}
-
-
-
-#define USE_ECORE_FILE
-
-#include <Ecore_File.h>
-
-/*
- 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 <media-svc.h>
-
-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;
-}
-