summaryrefslogtreecommitdiff
path: root/main/src/data/ivug-mediadata.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/data/ivug-mediadata.c')
-rwxr-xr-xmain/src/data/ivug-mediadata.c301
1 files changed, 0 insertions, 301 deletions
diff --git a/main/src/data/ivug-mediadata.c b/main/src/data/ivug-mediadata.c
deleted file mode 100755
index b46a5da..0000000
--- a/main/src/data/ivug-mediadata.c
+++ /dev/null
@@ -1,301 +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-main.h"
-#include "ivug-common.h"
-#include <media-svc.h>
-#include "ivug-mediadata.h"
-#include "ivug-file-info.h"
-
-Media_Data *ivug_alloc_mediadata_from_mitem(Mitem * item)
-{
- IV_ASSERT(item != NULL);
- IV_ASSERT(item->file_url != NULL);
- Media_Data * mdata = NULL;
- mdata = (Media_Data *) calloc(1, sizeof(Media_Data));
- if (mdata == NULL)
- {
- MSG_SDATA_ERROR("Cannot allocate memory");
- return NULL;
- }
-
- mdata->mediaID = uuid_assign(item->uuid);
-
- //file url
- mdata->fileurl = strdup(item->file_url);
- if (mdata->fileurl == NULL)
- {
- MSG_SDATA_ERROR("strdup return NULL");
- free(mdata);
- return NULL;
- }
-
- if (item->type == MINFO_ITEM_IMAGE)
- {
- //check file path.
- MSG_SDATA_HIGH("Local image : %s. %s", uuid_getchar( mdata->mediaID ), mdata->fileurl);
-
- mdata->thumbnail_path = NULL;
-
- mdata->slide_type = SLIDE_TYPE_IMAGE;
- mdata->filepath = strdup(mdata->fileurl);
- if (mdata->filepath == NULL)
- {
- free(mdata->fileurl);
- MSG_SDATA_ERROR("strdup return NULL");
- free(mdata);
- return NULL;
- }
- }
- else if (item->type == MINFO_ITEM_VIDEO)
- {
- MSG_SDATA_HIGH("Local video : %s. %s", uuid_getchar(mdata->mediaID), mdata->fileurl);
-
- if (item->thumb_url)
- {
- mdata->thumbnail_path = strdup(item->thumb_url); //thumbnail address
- if (mdata->thumbnail_path == NULL)
- {
- free(mdata->fileurl);
- MSG_SDATA_ERROR("strdup return NULL");
- free(mdata);
- return NULL;
- }
- }
-
- mdata->slide_type = SLIDE_TYPE_VIDEO;
- mdata->filepath = strdup(mdata->fileurl);
- if (mdata->filepath == NULL)
- {
- free(mdata->fileurl);
- if (mdata->thumbnail_path)
- {
- free(mdata->thumbnail_path);
- }
- MSG_SDATA_ERROR("strdup return NULL");
- free(mdata);
- return NULL;
- }
- }
- return mdata;
-}
-
-Media_Data *ivug_alloc_mediadata_from_filepath(const char *filepath)
-{
- IV_ASSERT(filepath != NULL);
-
-
- // No need to create list. just one file only.
- Mitem * item = NULL;
- if (ivug_is_web_uri(filepath) == false)
- {
-
- //local file.
- int ret = MB_SVC_ERROR_NONE;
- ret = minfo_get_item(gGetMediaSVCHandle(), filepath, &item); //get cluster id
- if (ret != MB_SVC_ERROR_NONE)
- {
- MSG_SDATA_ERROR("Cannot find file in media db for %s",filepath);
- // Go through
- }
- }
-
- Media_Data * mdata = NULL;
- if (item != NULL)
- {
- MSG_SDATA_HIGH("File path is given. but founded in DB.");
- mdata = ivug_alloc_mediadata_from_mitem(item);
- minfo_destroy_mtype_item(item);
- if (mdata == NULL)
- {
- MSG_SDATA_ERROR("Cannot add file : %s", filepath);
- return NULL;
- }
- return mdata;
- }
- mdata = (Media_Data *) calloc(1, sizeof(Media_Data));
- if (mdata == NULL)
- {
- MSG_SDATA_ERROR("Cannot allocate memory");
- return NULL;
- }
- mdata->mediaID = INVALID_UUID; //copy id mitem
-
- char *mime_type = NULL;
- mime_type = ivug_fileinfo_get_mime_type(filepath);
- if (mime_type == NULL)
- {
- MSG_SDATA_WARN("file path is not vaild = %s", filepath);
- mdata->slide_type = SLIDE_TYPE_UNKNOWN;
- mdata->fileurl = NULL;
- mdata->filepath = NULL;
- return mdata;
- }
-
-
- Media_Type slide_type = SLIDE_TYPE_NONE;
-
- //image
- if (strncmp(mime_type, "image/", strlen("image/")) == 0)
- {
- slide_type = SLIDE_TYPE_IMAGE;
- }
- else if (strncmp(mime_type, "video/", strlen("video/")) == 0)
- {
- slide_type = SLIDE_TYPE_VIDEO;
- }
- else
- {
- slide_type = SLIDE_TYPE_NONE;
- }
- MSG_SDATA_HIGH("File=%s Mime=%s", filepath, mime_type);
- free(mime_type); //free strdup
-
- mdata->thumbnail_path = NULL;
-
- if (slide_type == SLIDE_TYPE_IMAGE)
- {
- mdata->slide_type = SLIDE_TYPE_IMAGE;
- mdata->fileurl = strdup(filepath);
- if (mdata->fileurl == NULL)
- {
- MSG_SDATA_ERROR("strdup return NULL");
- goto ERROR;
- }
- mdata->filepath = strdup(filepath);
- if (mdata->filepath == NULL)
- {
- MSG_SDATA_ERROR("strdup return NULL");
- free(mdata->fileurl);
- goto ERROR;
- }
- }
- else if (slide_type == SLIDE_TYPE_VIDEO)
- {
- mdata->slide_type = SLIDE_TYPE_VIDEO;
- mdata->fileurl = strdup(filepath);
- if (mdata->fileurl == NULL)
- {
- MSG_SDATA_ERROR("strdup return NULL");
- goto ERROR;
- }
- mdata->filepath = strdup(filepath);
- if (mdata->filepath == NULL)
- {
- MSG_SDATA_ERROR("strdup return NULL");
- free(mdata->fileurl);
- goto ERROR;
- }
- }
- else
- {
- MSG_SDATA_WARN("file path is not vaild = %s", filepath);
- mdata->slide_type = SLIDE_TYPE_UNKNOWN;
- mdata->fileurl = NULL;
- mdata->filepath = NULL;
- }
- return mdata;
-ERROR:
-
- if (mdata)
- {
- free(mdata);
- }
- return NULL;
-}
-
-void ivug_free_mediadata(Media_Data * mdata)
-{
- IV_ASSERT(mdata != NULL);
-
- uuid_free(mdata->mediaID);
-
- //file path
- if (mdata->filepath)
- {
- //IVUG_DEBUG_MSG("filepath =%s", sd->filepath);
- free(mdata->filepath);
- mdata->filepath = NULL;
- }
-
- //file url
- if (mdata->fileurl)
- {
- MSG_SDATA_HIGH("Remove media data. %s", mdata->fileurl);
- free(mdata->fileurl);
- mdata->fileurl = NULL;
- }
-
- if (mdata->thumbnail_path)
- {
- free(mdata->thumbnail_path);
- mdata->thumbnail_path = NULL;
- }
-
- free(mdata);
-}
-
-bool ivug_delete_mediadata(Media_Data * mdata)
-{
- IV_ASSERT(mdata != NULL);
-
- if (uuid_is_valid(mdata->mediaID) == true )
- {
- int ret = minfo_delete_media_id(gGetMediaSVCHandle(), mdata->mediaID);
-
- if (ret == MB_SVC_ERROR_NONE)
- {
- if (mdata->filepath)
- {
- MSG_SDATA_HIGH("File removed. %s", mdata->filepath);
- if (ivug_remove_file(mdata->filepath) == false)
- {
- MSG_SDATA_ERROR("file remove error : %s", mdata->filepath);
- }
- }
- else
- {
- MSG_SDATA_ERROR("File path is NULL", mdata->filepath);
- }
- }
- else
- {
- MSG_SDATA_ERROR("minfo_delete_media_id faild=%d uuid=%s file=%s", ret, uuid_getchar(mdata->mediaID), mdata->filepath);
- return false;
- }
- }
- else
- {
- if (mdata->filepath)
- {
- MSG_SDATA_HIGH("File removed. %s", mdata->filepath);
-
- if (ivug_remove_file(mdata->filepath) == false)
- {
- MSG_SDATA_ERROR("file remove error : %s", mdata->filepath);
- }
- }
- else
- {
- MSG_SDATA_ERROR("File path is NULL", mdata->filepath);
- }
-
- }
-
- return true;
-}
-