Remove Ecore evas dependency
[platform/core/multimedia/libmedia-thumbnail.git] / src / include / util / media-thumb-util.h
1 /*
2  * libmedia-thumbnail
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include "media-thumb-error.h"
23 #include "media-thumb-types.h"
24 #include "media-thumb-debug.h"
25 #include "media-util.h"
26 #include <tzplatform_config.h>
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28
29 #ifndef _MEDIA_THUMB_UTIL_H_
30 #define _MEDIA_THUMB_UTIL_H_
31
32 #define SAFE_FREE(src)      { if(src) {free(src); src = NULL;}}
33
34 #ifndef _USE_NEW_MEDIA_DB_
35 #define THUMB_NONE_TYPE    0x00000000  /* None */
36 #define THUMB_IMAGE_TYPE    0x00000001  /* Image */
37 #define THUMB_VIDEO_TYPE    0x00000002  /* Video */
38 #else
39 #define THUMB_NONE_TYPE    -1   /* None */
40 #define THUMB_IMAGE_TYPE   0    /* Image */
41 #define THUMB_VIDEO_TYPE   1    /* Video */
42 #endif
43
44 #define THUMB_PATH_PHONE        MEDIA_ROOT_PATH_INTERNAL        /**< File path prefix of files stored in phone */
45 #define THUMB_PATH_MMC          MEDIA_ROOT_PATH_SDCARD          /**< File path prefix of files stored in mmc card */
46
47 #define THUMB_PHONE_PATH        tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/phone")
48 #define THUMB_MMC_PATH          tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/mmc")
49
50 #define THUMB_DEFAULT_PATH      tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/thumb_default.png")
51
52 typedef enum
53 {
54         THUMB_PHONE,                    /**< Stored only in phone */
55         THUMB_MMC                               /**< Stored only in MMC */      
56 } media_thumb_store_type;
57
58 int _media_thumb_get_length(media_thumb_type thumb_type);
59
60 int _media_thumb_get_store_type_by_path(const char *full_path);
61
62 int
63 _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len);
64
65 int
66 _media_thumb_get_file_type(const char *file_full_path);
67
68 int
69 _media_thumb_remove_file(const char *path);
70
71 char
72 *_media_thumb_generate_hash_name(const char *file);
73
74 int
75 _media_thumb_get_hash_name(const char *file_full_path,
76                                  char *thumb_hash_path, size_t max_thumb_path, uid_t uid);
77
78 int
79 _media_thumb_save_to_file_with_gdk(GdkPixbuf *data,
80                                                                                         int w,
81                                                                                         int h,
82                                                                                         gboolean alpha,
83                                                                                         char *thumb_path);
84
85 int
86 _media_thumb_get_width(media_thumb_type thumb_type);
87
88 int
89 _media_thumb_get_height(media_thumb_type thumb_type);
90
91 /**
92  *      _thumbnail_get_data:
93  *  This function generates thumbnail raw data, which is wanted by user
94  *  This api is closed for a while until being independent from evas object to be thread-safe
95  *
96  *      @return         This function returns zero(MEDIA_THUMB_ERROR_NONE) on success, or negative value with error code.
97  *                              Please refer 'media-thumb-error.h' to know the exact meaning of the error.
98  *  @param[in]                          origin_path      The path of the original image
99  *  @param[in]                          thumb_type       The type of the returned thumbnail data
100  *  @param[in]                          format           The format of the returned data
101  *  @param[out]                         data             The data of generated thumbnail.
102  *  @param[out]                         size             The size of generated thumbnail.
103  *  @param[out]                         width             The width of generated thumbnail.
104  *  @param[out]                         height             The height of generated thumbnail.
105  *  @param[out]                         origin_width        The width of original image.
106  *  @param[out]                         origin_height       The height of original image.
107  *      @see            None.
108  *      @pre            None.
109  *      @post           None.
110  *      @remark         None.   
111  *      @par example
112  *      @code
113
114 #include <media-thumbnail.h>
115
116 void test_get_thumb_data()
117 {
118         int ret = MEDIA_THUMB_ERROR_NONE;
119         int thumb_type = 0;
120         const char *origin_path = "/opt/usr/media/test.jpg";
121         void *data = NULL;
122         
123
124         ret = _thumbnail_get_data(origin_path, thumb_type, thumb_path, &data);
125
126         if (ret < 0)
127         {
128                 printf( "_thumbnail_get_data fails. error code->%d", ret);
129         }
130
131         return;
132 }
133
134  *      @endcode
135 */
136 int _thumbnail_get_data(const char *origin_path,
137                                                 media_thumb_type thumb_type,
138                                                 media_thumb_format format,
139                                                 unsigned char **data,
140                                                 int *size,
141                                                 int *width,
142                                                 int *height,
143                                                 int *origin_width,
144                                                 int *origin_height,
145                                                 int *alpha,
146                                                 uid_t uid);
147
148 #endif /*_MEDIA_THUMB_UTIL_H_*/
149