4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #ifndef _VISUAL_SVC_H_
23 #define _VISUAL_SVC_H_
26 * This file defines minfo apis for media service..
29 * @author Hyunjun Ko <zzoon.ko@samsung.com>
31 * @brief This file defines apis for visual media service.
34 #include "media-svc-types.h"
35 #include "visual-svc-types.h"
36 #include "visual-svc-error.h"
41 #endif /* __cplusplus */
47 This document provides necessary visual media information for developers who are
48 going to implement gallery application and ug-imageviewer or other
49 3rd party applications.
54 @defgroup VISUAL_SVC_API Media Service
64 * This function gets mitem list, which include all or portion of a cluster or folder specified by
65 * @p cluster_id. @p filter could specify some filter conditions, like, type of got items, sort by type,
66 * start and end positions of items, including meta data or not, whether just get the favorites, etc.
67 * Menawhile data of each mitem instance mainly derive from media table record. However meta data
68 * is composed of video_meta or image_meta record.
70 * @param mb_svc_handle [in] the handle of DB
71 * @param cluster_id [in] the folder id in which media files are in. if the parameter is NULL, then query all folders.
72 * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
73 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
74 * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
76 * @return This function returns 0 on success, or negative value with error code.
77 * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
78 * when free list, it need free every item first and then free list itself.
85 #include <media-svc.h>
87 int mitem_ite_cb(Mitem *item, void *user_data)
89 GList** list = (GList**)user_data;
90 //append an item to linked list.
91 *list = g_list_append(*list, item);
94 void test_minfo_get_item_list(MediaSvcHandle *mb_svc_handle)
99 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
101 minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,3,10,true,true};
103 ret = minfo_get_item_list(mb_svc_handle, cluster_id, item_filter, mitem_ite_cb, &p_list);
106 printf("minfo_get_item_list error\n");
115 minfo_get_item_list(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
118 * minfo_get_all_item_list
119 * This function gets mitem list, which include all or portion of a or many clusters or folders specified by
120 * @p cluster_type. @p filter could specify some filter conditions, like, type of got items, sort by type,
121 * start and end positions of items, including meta data or not, whether just get the favorites, etc.
122 * Meanwhile data of each mitem instance mainly derive from media table record. However meta data
123 * is composed of video_meta or image_meta record.
125 * @param mb_svc_handle [in] the handle of DB
126 * @param cluster_type [in] the folder type which specify media files belong to.
127 * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
128 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
129 * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
131 * @return This function returns 0 on success, or negative value with error code.
132 * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
133 * when free list, it need free every item first and then free list itself.
134 * @see minfo_get_item_list.
140 #include <media-svc.h>
142 int mitem_ite_cb(Mitem *item, void *user_data)
144 GList** list = (GList**)user_data;
145 //append an item to linked list.
146 *list = g_list_append(*list, item);
149 void test_minfo_get_all_item_list(MediaSvcHandle *mb_svc_handle)
153 GList *p_list = NULL;
155 minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,3,10,true,true};
156 //get a set of items, which all reside on local storage, including MMC and phone.
157 ret = minfo_get_all_item_list(mb_svc_handle, MINFO_CLUSTER_TYPE_LOCAL_ALL, item_filter, mitem_ite_cb, &p_list);
160 printf("minfo_get_item_list error\n");
169 minfo_get_all_item_list(MediaSvcHandle *mb_svc_handle, const minfo_folder_type cluster_type, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
172 * minfo_get_item_list_search
173 * This function gets mitem list, which is searched by string specified by user.
174 * @p search_field is a field to want to search. @p search_str could specify string to search.
175 * Menawhile data of each mitem instance mainly derive from media table record. However meta data
176 * is composed of video_meta or image_meta record.
178 * @param mb_svc_handle [in] the handle of DB
179 * @param search_field [in] A field to want search. Please refer the enum type minfo_search_field_t in 'minfo-types.h'.
180 * @param search_str [in] A string to search.
181 * @param folder_type [in] the folder type which specify media files belong to.
182 * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
183 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
184 * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
186 * @return This function returns 0 on success, or negative value with error code.
187 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
188 * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
189 * when free list, it need free every item first and then free list itself.
196 #include <media-svc.h>
198 int mitem_ite_cb(Mitem *item, void *user_data)
200 GList **list = (GList **)user_data;
201 //append an item to linked list.
202 *list = g_list_append(*list, item);
205 void test_minfo_get_item_list_search(MediaSvcHandle *mb_svc_handle)
208 GList *p_list = NULL;
209 const char *search_str = "Hiphop";
210 minfo_search_field_t search_field = MINFO_SEARCH_BY_NAME;
211 minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_ALL;
213 minfo_item_filter item_filter = {MINFO_ITEM_VIDEO, MINFO_MEDIA_SORT_BY_NAME_ASC, 0, 9, false, MINFO_MEDIA_FAV_ALL};
215 ret = minfo_get_item_list_search(mb_svc_handle, search_field, search_str, folder_type, item_filter, mitem_ite_cb, &p_list);
218 printf("minfo_get_item_list_search error\n");
227 minfo_get_item_list_search(MediaSvcHandle *mb_svc_handle, minfo_search_field_t search_field, const char *search_str, minfo_folder_type folder_type, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
230 * minfo_get_all_item_cnt
231 * This function gets count of all records in media table. This function returns the count of all items, which are unlocked excluding web media.
233 * @param cnt [out] returned value, count of all records
234 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
235 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
244 #include <media-svc.h>
246 void test_minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle)
251 ret = minfo_get_all_item_cnt(mb_svc_handle, &cnt);
253 printf("minfo_get_all_item_cnt error\n");
261 minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle, int *cnt);
264 * minfo_get_all_item_count
265 * This function gets count of all records in the specific storage.
266 * User can specify folder type like MINFO_CLUSTER_TYPE_ALL, MINFO_CLUSTER_TYPE_LOCAL_PHONE, etc.
267 * Please refer 'visual-svc-types.h' to know what folder type exists.
268 * This function returns the count of all items, which are unlocked.
270 * @param mb_svc_handle [in] the handle of DB
271 * @param folder_type [in] folder type
272 * @param file_type [in] file type
273 * @param fav_type [in] favortie type
274 * @param cnt [out] returned value, count of all records
275 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
276 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
284 #include <media-svc.h>
286 void test_minfo_get_all_item_count(MediaSvcHandle *mb_svc_handle)
290 minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_LOCAL_PHONE;
291 minfo_file_type file_type = MINFO_ITEM_ALL;
292 minfo_media_favorite_type fav_type = MINFO_MEDIA_FAV_ALL;
294 ret = minfo_get_all_item_count(mb_svc_handle, folder_type, file_type, fav_type, &cnt);
296 printf("minfo_get_all_item_cnt error\n");
303 EXPORT_API int minfo_get_all_item_count(
304 MediaSvcHandle *mb_svc_handle,
305 minfo_folder_type folder_type,
306 minfo_file_type file_type,
307 minfo_media_favorite_type fav_type,
312 * This function gets count of matched records in media table with the specified @p filter, which
313 * specify some filter conditions, like, type of got items, sort by type, start and end positions
314 * of items, including meta data or not, whether just get the favorites, etc.
315 * The detail structure type of @p filter, could refer to the defination 'minfo_item_filter'
316 * in header file, minfo-types.h.
318 * @param mb_svc_handle [in] the handle of DB
319 * @param cluster_id [in] the folder id in which media files are in. if the parameter is -1, then query all folders.
320 * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
321 * @param cnt [out] returned value, count of matched records
323 * @return This function returns 0 on success, or negative value with error code.
324 * @remarks list contains a set of full path string of cover file.
325 * @see minfo_get_item_list.
331 #include <media-svc.h>
333 void test_minfo_get_item_cnt(MediaSvcHandle *mb_svc_handle)
336 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
338 minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,-1,10,true,true};
340 //get count of a set of items.
341 ret = minfo_get_item_cnt(mb_svc_handle, cluster_id, item_filter, &cnt);
343 printf("test_minfo_get_item_cnt error\n");
351 minfo_get_item_cnt(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const minfo_item_filter filter, int *cnt);
355 * minfo_get_cluster_cnt
356 * This function gets count of matched records from folder table with the specified @p filter, which
357 * specify some filter conditions, like, type of got clusters, sort by type, start and end positions
358 * of clusters, etc. The detail structure type of @p filter, could refer to the defination 'minfo_cluster_filter'
359 * in header file, minfo-types.h.
361 * @param mb_svc_handle [in] the handle of DB
362 * @param filter [in] filter to specify some filter conditions, like, type of got clusters, sort by type, start and end positions of clusters
363 * @param cnt [out] returned value, count of matched records
364 * @return This function returns 0 on success, or negative value with error code.
366 * @see minfo_get_cluster_list.
372 #include <media-svc.h>
374 void test_minfo_get_cluster_cnt(MediaSvcHandle *mb_svc_handle)
377 minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,-1,10};
379 //get the count of items which is owned by a cluster.
380 ret = minfo_get_cluster_cnt(mb_svc_handle, cluster_filter, &cnt);
382 printf("test_minfo_get_cluster_cnt error\n");
390 minfo_get_cluster_cnt(MediaSvcHandle *mb_svc_handle, const minfo_cluster_filter filter, int *cnt);
394 * minfo_get_cluster_list
395 * This function gets Mcluster instances list. Data of each instance is composed of the matched records from folder table
396 * with the @p filter, which specify some filter conditions, like, type of got clusters, sort by type, start and end positions
397 * The detail structure type of @p filter, could refer to the defination 'minfo_cluster_filter'
398 * in header file, minfo-types.h.
400 * @param mb_svc_handle [in] the handle of DB
401 * @param filter [in] filter to specify some filter conditions, like, type of got clusters, sort by type, start and end positions of clusters
402 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
403 * @param user_data [out] user's data structure to contain items of the type Mcluster. It is passed to the iterative callback.
404 * @return This function returns 0 on success, or negative value with error code.
405 * @remarks item type in list is pointer to structure mcluster
406 * when free list, it need free every item first and then free list itself.
413 #include <media-svc.h>
415 int mcluster_ite_cb(Mcluster *cluster, void *user_data)
417 GList** list = (GList**)user_data;
418 *list = g_list_append(*list, cluster);
421 void test_minfo_get_cluster_list(MediaSvcHandle *mb_svc_handle)
426 GList *p_list = NULL;
427 Mcluster* cluster = NULL;
429 //get a linked list which include all of clusters based on a specified filter.
430 minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};
432 ret = minfo_get_cluster_list(mb_svc_handle, cluster_filter, mcluster_ite_cb, &p_list);
442 minfo_get_cluster_list(MediaSvcHandle *mb_svc_handle, const minfo_cluster_filter filter, minfo_cluster_ite_cb func, void *user_data);
446 * minfo_get_meta_info
447 * This function gets matched 'Mmeta' instances. Data of the instance is composed of the matched media record from
448 * 'video_meta'/'image_meta' table, when finish using the Mmeta instance, should call API, minfo_mmeta_destroy to
449 * destroy this created instance.
451 * @param mb_svc_handle [in] the handle of DB
452 * @param media_id [in] specified _id field in media table record
453 * @param meta [out] pointer to pointer of matched Mmeta instance
454 * @return This function returns 0 on success, or negative value with error code.
455 * @remarks after using meta, it must be freed.
462 #include <media-svc.h>
464 void test_minfo_get_meta_info(MediaSvcHandle *mb_svc_handle)
468 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
470 //get a matched meta data.
471 ret = minfo_get_meta_info(mb_svc_handle, media_id, &mt);
473 printf("minfo_get_meta_info failed\n");
476 minfo_mmeta_destroy(mt);
483 minfo_get_meta_info(MediaSvcHandle *mb_svc_handle, const char *media_id, Mmeta** meta);
486 * minfo_update_image_meta_info_int
487 * This function will update the corresponding field's value in database 'image_meta' table, this will be decided by the
488 * @p meta_field, whose type is 'minfo_image_meta_field_t', and indicate which field will be replaced by the value of int type
489 * pointered to by @p updated_value.
491 * @param mb_svc_handle [in] the handle of DB
492 * @param media_id [in] specified _id field in media table record
493 * @param meta_field [in] the enum value indicate which field of database table will be updated
494 * @param updated_value [in] value of int, which will replace the original value in database image meta table
495 * @return This function returns 0 on success, or negative value with error code.
496 * @remarks after using meta, it must be freed.
503 #include <media-svc.h>
505 void test_minfo_update_image_meta_info_int(MediaSvcHandle *mb_svc_handle)
510 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
512 // update image meta's 'width and height' member
513 ret = minfo_update_image_meta_info_int(mb_svc_handle, media_id, MINFO_IMAGE_META_WIDTH, width, MINFO_IMAGE_META_HEIGHT, height);
515 printf("minfo_update_image_meta_info_int failed\n");
524 minfo_update_image_meta_info_int(MediaSvcHandle *mb_svc_handle, const char *media_id,
525 minfo_image_meta_field_t meta_field,
526 const int updated_value,
530 * minfo_update_video_meta_info_int
531 * This function will update the corresponding field's value in database 'video_meta' table, this will be decided by the
532 * @p meta_field, whose type is 'minfo_video_meta_field_t', and indicate which field will be replaced by the value of int type
533 * pointered to by @p updated_value.
535 * @param mb_svc_handle [in] the handle of DB
536 * @param media_id [in] specified _id field in media table record
537 * @param meta_field [in] the enum value indicate which field of database table will be updated
538 * @param updated_value [in] value of int, which will replace the original value in database video meta table
539 * @return This function returns 0 on success, or negative value with error code.
540 * @remarks after using meta, it must be freed.
547 #include <media-svc.h>
549 void test_minfo_update_video_meta_info_int(MediaSvcHandle *mb_svc_handle)
553 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
555 //update video meta's 'last_played_time' member
556 ret = minfo_update_video_meta_info_int(mb_svc_handle, media_id, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, _value);
559 printf("minfo_update_video_meta_info_int failed\n");
568 minfo_update_video_meta_info_int(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_video_meta_field_t meta_field, const int updated_value);
572 * minfo_destroy_mtype_item
573 * This function free an type instantiated object, whose type may be any one recognized by media-svc, these type
574 * will include Mitem, Mimage, Mvideo, Mmeta, Mcluster, etc. In this function, it will check the concrete type for the
575 * @p item, and then decide which free function will really be called.
577 * @return This function returns 0 on success, and negativa value on failure.
578 * @param item [in] the input parameter, inlcuding the instanciated object.
580 * @remarks This function is general one, it will be able to destroy any recognized instantiated object
581 * by media-svc, so when you create or get an instantiated object from media-svc, and then
582 * call this function to free it.
589 #include <media-svc.h>
591 void test_minfo_destroy_mtype_item(void)
596 char* file_url = "/opt/media/Images/Wallpapers/Home_01.png";
597 ret = minfo_get_item(file_url, &mi);
599 //destroy an item whose type is 'Mitem'.
600 ret = minfo_destroy_mtype_item(mi);
611 minfo_destroy_mtype_item(void* item);
615 * minfo_add_media_start
616 * This function inserts new media file information into media table,video_meta table/image_meta table.
617 Or updates file information in these tables if the file is updated
619 * @param mb_svc_handle [in] the handle of DB
620 * @param trans_count [in] count of trasaction user wants
621 * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
622 * @remarks if invoke this function with same input parameter, it fails
623 * @see minfo_add_media_end, minfo_add_media_batch
629 #include <media-svc.h>
631 void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
635 err = minfo_add_media_start(mb_svc_handle, 100);
637 printf("minfo_add_media_start failed\n");
641 for (i = 0; i < 200; i++) {
642 err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
645 printf("minfo_add_media_start failed\n");
650 err = minfo_add_media_end(mb_svc_handle);
652 printf("minfo_add_media_end failed\n");
660 minfo_add_media_start(MediaSvcHandle *mb_svc_handle, int trans_count);
664 * minfo_add_media_batch
665 * This function inserts new media file information into media table,video_meta table/image_meta table.
666 Or updates file information in these tables if the file is updated
668 * @param mb_svc_handle [in] the handle of DB
669 * @param file_url [in] the local file full path
670 * @param type [in] the file type, maybe it's video file or image file
671 * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
672 * @remarks if invoke this function with same input parameter, it fails
673 * @see minfo_add_media_start, minfo_add_media_end
679 #include <media-svc.h>
681 void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
685 err = minfo_add_media_start(mb_svc_handle, 100);
687 printf("minfo_add_media_start failed\n");
691 for (i = 0; i < 100; i++) {
692 err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
695 printf("minfo_add_media_start failed\n");
700 err = minfo_add_media_end(mb_svc_handle);
702 printf("minfo_add_media_end failed\n");
710 minfo_add_media_batch(MediaSvcHandle *mb_svc_handle, const char* file_url, minfo_file_type content_type);
713 * minfo_add_media_end
714 * This function inserts new media file information into media table,video_meta table/image_meta table.
715 Or updates file information in these tables if the file is updated
717 * @param mb_svc_handle [in] the handle of DB
718 * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
719 * @remarks if invoke this function with same input parameter, it fails
720 * @see minfo_add_media_start, minfo_add_media_batch
726 #include <media-svc.h>
728 void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
732 err = minfo_add_media_start(100);
734 printf("minfo_add_media_start failed\n");
738 for (i = 0; i < 200; i++) {
739 err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
742 printf("minfo_add_media_start failed\n");
747 err = minfo_add_media_end();
749 printf("minfo_add_media_end failed\n");
757 minfo_add_media_end(MediaSvcHandle *mb_svc_handle);
761 * This function inserts new media file information into media table,video_meta table/image_meta table.
762 Or updates file information in these tables if the file is updated
764 * @param mb_svc_handle [in] the handle of DB
765 * @param file_url [in] the local file full path
766 * @param type [in] the file type, maybe it's video file or image file
767 * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
768 * @remarks if invoke this function with same input parameter, it fails
769 * @see minfo_delete_media
775 #include <media-svc.h>
777 void test_minfo_add_media(MediaSvcHandle *mb_svc_handle)
780 char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
782 //add a new media content whose url is 'file_url'.
783 err = minfo_add_media(mb_svc_handle, file_url, MINFO_ITEM_IMAGE);
786 printf("minfo_add_media failed\n");
795 minfo_add_media(MediaSvcHandle *mb_svc_handle, const char* file_url, minfo_file_type content_type);
801 * This function deletes matched media table record, video_meta/image_meta record. After that, if the folder which this file is in is empty, then delete the folder record.
802 * When user actually delete a media file in file system, he/she should call this function to delete the corresponding record in 'media' table, meanwhile it may delete the
803 * folder record in 'folder' table if this folder will not include any media content.
805 * @param mb_svc_handle [in] the handle of DB
806 * @param file_url [in] matched local file full path
807 * @return This function returns 0 on success, or negative value with error code.
809 * @see minfo_add_media
815 #include <media-svc.h>
817 void test_minfo_delete_media(void)
820 char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
822 //delete a media reord from 'media' table.
823 ret= minfo_delete_media(file_url);
826 printf("minfo_delete_media failed\n");
834 minfo_delete_media(MediaSvcHandle *mb_svc_handle, const char* file_url);
840 * This function moves the media file to another place. When user actually move a media file ( @p old_file_url )in file system to the destination
841 * pathname ( @p new_file_url ), he/she need to call this function to move the record of 'media' table. Meanwhile user is responsible for identifying
842 * the file's type, like image, video, etc.
843 * @param mb_svc_handle [in] the handle of DB
844 * @param old_file_url [in] old local file full path of the media file
845 * @param new_file_url [in] new local file full path of the media file
846 * @param type [in] media file type,maybe vidoe or image
847 * @return This function returns 0 on success, or negative value with error code.
849 * @see minfo_mv_media, minfo_copy_media, minfo_update_media_name.
855 #include <media-svc.h>
857 void test_minfo_move_media(MediaSvcHandle *mb_svc_handle)
860 char* old_file_url = "/opt/media/Images/Wallpapers/Home_01.png";
861 char* new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
863 //move an item to a specified location.
864 ret = minfo_move_media(mb_svc_handle, old_file_url, new_file_url, MINFO_ITEM_IMAGE);
867 printf("minfo_move_media failed\n");
875 minfo_move_media(MediaSvcHandle *mb_svc_handle, const char* old_file_url, const char *new_file_url, minfo_file_type content_type);
878 * minfo_move_media_start
879 * This function starts to move multiple media files
881 * @param mb_svc_handle [in] the handle of DB
882 * @param trans_count [in] count of trasaction user wants
883 * @return This function returns 0/positive on success, or negative value with error code.
884 * @remarks if invoke this function with same input parameter, it fails
885 * @see minfo_move_media_end, minfo_move_media
891 #include <media-svc.h>
893 void test_minfo_move_media_batch(MediaSvcHandle *mb_svc_handle)
897 err = minfo_move_media_start(mb_svc_handle, 100);
899 printf("minfo_move_media_start failed\n");
903 for (i = 0; i < 200; i++) {
904 err = minfo_move_media(mb_svc_handle, src_image_file_path[i], dst_image_file_path[i], MINFO_ITEM_IMAGE);
907 printf("minfo_move_media failed\n");
912 err = minfo_move_media_end(mb_svc_handle);
914 printf("minfo_move_media_end failed\n");
922 minfo_move_media_start(MediaSvcHandle *mb_svc_handle, int trans_count);
927 * minfo_move_media_end
928 * This function ends to move multiple media files
930 * @param mb_svc_handle [in] the handle of DB
931 * @return This function returns 0/positive on success, or negative value with error code.
932 * @remarks if invoke this function with same input parameter, it fails
933 * @see minfo_add_move_start, minfo_move_media
939 #include <media-svc.h>
941 void test_minfo_move_media_batch(void)
945 err = minfo_move_media_start(mb_svc_handle, 100);
947 printf("minfo_add_media_start failed\n");
951 for (i = 0; i < 200; i++) {
952 err = minfo_move_media(mb_svc_handle, src_image_file_path[i], dst_image_file_path[i], MINFO_ITEM_IMAGE);
955 printf("minfo_move_media failed\n");
960 err = minfo_move_media_end(mb_svc_handle);
962 printf("minfo_move_media_end failed\n");
970 minfo_move_media_end(MediaSvcHandle *mb_svc_handle);
975 * This function copies the media file to another place. User should pass the full pathnames for these parameters, @p old_file_url and @ new_file_url
976 * respectively. The @p old_file_url indicate the original full pathname of this media content, and @ new_file_url indicate the destination full pathname of
978 * @param mb_svc_handle [in] the handle of DB
979 * @param old_file_url [in] old local file full path of the media file
980 * @param new_file_url [in] new local file full path of the media file
981 * @param type [in] media file type, maybe vidoe or image
982 * @return This function returns 0 on success, or negative value with error code.
983 * @remarks This function will not return the thumbnail pathname of new media file, user could get this new thumnail file using the function, minfo_get_thumb_path.
984 * @see minfo_cp_media, minfo_update_media_name, minfo_move_media
990 #include <media-svc.h>
992 void test_minfo_copy_media(MediaSvcHandle *mb_svc_handle)
996 char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
997 char *new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
999 //copy a media file to other location whos name is specified by 'new_file_url'.
1000 ret = minfo_copy_media(mb_svc_handle, old_file_url, new_file_url, file_type);
1002 printf("minfo_copy_media failed\n");
1011 minfo_copy_media(MediaSvcHandle *mb_svc_handle, const char* old_file_url, const char *new_file_url, minfo_file_type content_type);
1015 * minfo_update_media_name
1016 * This function rename a image or video file. Here this function will assume the folder name of
1017 * file whose name is changed keep unchanged. That is, this file which is changed name still is located in the same folder.
1018 * This function actually call sqlite3
1019 * UPDATE %s SET ... WHERE _id = _id;
1020 * @param mb_svc_handle [in] the handle of DB
1021 * @param media_id [in] the id of specified media file
1022 * @param new_name [in] new name of the media file
1023 * @return This function returns 0 on success, or negative value with error code.
1025 * @see minfo_move_media, minfo_copy_media.
1031 #include <media-svc.h>
1033 void test_minfo_update_media_name(MediaSvcHandle *mb_svc_handle)
1036 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1039 ret = minfo_update_media_name(mb_svc_handle, media_id, new_name);
1041 printf("test_minfo_update_media_name failed\n");
1049 minfo_update_media_name(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* new_name);
1052 * minfo_update_media_thumb
1053 * This function updates a thumbpath of the media in DB.
1054 * @param mb_svc_handle [in] the handle of DB
1055 * @param media_id [in] the id of specified media file
1056 * @param thumb_path [in] new thumbnail path of the media file
1057 * @return This function returns 0 on success, or negative value with error code.
1065 #include <media-svc.h>
1067 void test_minfo_update_media_thumb(MediaSvcHandle *mb_svc_handle)
1070 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1071 const char *thumb_path = "/opt/media/test.jpg";
1073 //update thumbnail path
1074 ret = minfo_update_media_thumb(mb_svc_handle, media_id, thumb_path);
1076 printf("minfo_update_media_thumb failed\n");
1084 minfo_update_media_thumb(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* thumb_path);
1087 * minfo_update_media_favorite
1088 * This function updates favorite field of image or video file in 'media' table. This function actually call the Sqlite3 UPDATE,
1089 * In Gallery application or ug-imageviewer, user could want to set a media file as favorite or unfovarite, so he/she could call
1090 * this API to do it.
1091 * @param mb_svc_handle [in] the handle of DB
1092 * @param media_id [in] Unique id of the media file
1093 * @param favorite_level [in] new favorite_level of the media file, indicate whether this media content is favorite or unfavorite.
1094 * @return This function returns 0 on success, or negative value with error code.
1102 #include <media-svc.h>
1104 void test_minfo_update_media_favorite(MediaSvcHandle *mb_svc_handle)
1107 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1109 //update an item's favorite record
1110 ret = minfo_update_media_favorite(mb_svc_handle, media_id, favorite_level);
1113 printf("minfo_update_media_favorite failed\n");
1121 minfo_update_media_favorite(MediaSvcHandle *mb_svc_handle, const char *media_id, const int favorite_level);
1125 * minfo_update_media_date
1126 * This function updates modified date of image or video file in 'media' table. This function actually call the Sqlite3 UPDATE.
1127 * In Gallery application or ug-imageviewer, user could want to set moedified date of a media, so he/she could call this API to do it.
1128 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
1129 * @param mb_svc_handle [in] the handle of DB
1130 * @param media_id [in] Unique id of the media file
1131 * @param modified_date [in] date to modify, which is a type of time_t
1132 * @return This function returns 0 on success, or negative value with error code.
1140 #include <media-svc.h>
1142 void test_minfo_update_media_date(MediaSvcHandle *mb_svc_handle)
1145 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1150 //update an item's date record
1151 ret = minfo_update_media_date(mb_svc_handle, media_id, today);
1153 printf("minfo_update_media_date failed\n");
1161 minfo_update_media_date(MediaSvcHandle *mb_svc_handle, const char *media_id, time_t modified_date);
1164 * minfo_update_media_orientation
1165 * This function updates orientation of image file in 'image_meta' table. This function actually call the Sqlite3 UPDATE.
1166 * In Gallery application or ug-imageviewer, user could want to set orientation of an image, so he/she could call this API to do it.
1167 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
1168 * @param mb_svc_handle [in] the handle of DB
1169 * @param media_id [in] Unique id of the media file
1170 * @param orientation [in] orientation to modify, which is a type of int
1171 * @return This function returns 0 on success, or negative value with error code.
1179 #include <media-svc.h>
1181 void test_minfo_update_media_orientation(MediaSvcHandle *mb_svc_handle)
1184 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1185 minfo_exif_orientation_t orientation = MINFO_ORIENT_ROT_90;
1187 //update an image's orientation
1188 ret = minfo_update_media_orientation(mb_svc_handle, media_id, orientation);
1190 printf("minfo_update_media_orientation failed\n");
1197 minfo_update_media_orientation(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_exif_orientation_t orientation);
1201 * This function adds new local folder. This function could be called when user want to add a Album(local folder)
1202 * in Gallery application. This function actually call the sqlite INSERT statement to insert the record in folder
1203 * table. Meanwhile it will return new added local folder's ID to @p id.
1204 * Sqlie3 statement looks like this, INSERT INTO folder (...);
1205 * @param mb_svc_handle [in] the handle of DB
1206 * @param cluster_url [in] the local directory of added folder, it should be full pathname of local folder
1207 * @param id [out] id of the added folder, this function will return a unique ID to calling application
1208 * @return This function returns 0 on success, or negative value with error code.
1209 * @remarks if invoke this function with same input parameter, it fails
1210 * @see minfo_delete_cluster
1216 #include <media-svc.h>
1218 void test_minfo_add_cluster(MediaSvcHandle *mb_svc_handle)
1221 char *cluster_url = "/opt/media/Images/Wallpapers";
1222 char cluster_id[256];
1224 //add a new cluster whose url is 'cluster_url'.
1225 ret = minfo_add_cluster(mb_svc_handle, cluster_url, cluster_id, sizeof(cluster_id));
1227 printf("minfo_add_cluster failed\n");
1235 minfo_add_cluster(MediaSvcHandle *mb_svc_handle, const char* cluster_url, char *id, int max_length);
1239 * minfo_check_cluster_exist
1240 * This function checks to exist the cluster in media database by its path.
1241 * @param mb_svc_handle [in] the handle of DB
1242 * @param path [in] the local directory to check if it exists, it should be full pathname of local folder
1243 * @return This function returns 0 on success, or negative value with error code.
1244 * @remarks if invoke this function with same input parameter, it fails
1245 * @see minfo_check_item_exist
1251 #include <media-svc.h>
1253 void test_minfo_check_cluster_exist(MediaSvcHandle *mb_svc_handle)
1256 char *cluster_url = "/opt/media/Images/Wallpapers";
1258 //check if the cluster exists by path.
1259 ret = minfo_check_cluster_exist(mb_svc_handle, cluster_url);
1261 printf("minfo_check_cluster_exist failed\n");
1269 minfo_check_cluster_exist(MediaSvcHandle *mb_svc_handle, const char *path);
1272 * minfo_check_item_exist
1273 * This function checks to exist the media in media database by its path.
1274 * @param mb_svc_handle [in] the handle of DB
1275 * @param path [in] the local media path to check if it exists, it should be full pathname.
1276 * @return This function returns 0 on success, or negative value with error code.
1277 * @remarks if invoke this function with same input parameter, it fails
1278 * @see minfo_check_cluster_exist
1284 #include <media-svc.h>
1286 void test_minfo_check_item_exist(MediaSvcHandle *mb_svc_handle)
1289 char *media_url = "/opt/media/Images/Wallpapers/Wallpaper1.jpg";
1291 //check if the item exists by path.
1292 ret = minfo_check_item_exist(mb_svc_handle, media_url);
1294 printf("minfo_check_item_exist failed\n");
1302 minfo_check_item_exist(MediaSvcHandle *mb_svc_handle, const char *path);
1305 * minfo_get_item_by_id
1306 * This function gets mitem information. When user could get the unique ID of a media content, he/she
1307 * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
1308 * media content type, media content's thumbnail name, media content's pathname, etc. The detail defination
1309 * of this structute, could refer to the header, minfo-item.h.
1310 * @param mb_svc_handle [in] the handle of DB
1311 * @param media_id [in] the local file media id
1312 * @param mitem [out] the returned data structure whose type is Mitem.
1313 * @return This function returns 0 on success, or negative value with error code.
1314 * @remarks when invoking this function, *mitem must equals NULL, and
1315 * the @p media_id should be valid ID, if it is invalid, like -1 or 0, this
1316 * function will return @p mitem whose content is NULL. If normally, @p mitem must be freed with minfo_mitem_destroy.
1317 * @see minfo_get_item.
1323 #include <media-svc.h>
1325 void test_minfo_get_item_by_id(MediaSvcHandle *mb_svc_handle)
1328 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1331 //get an item based on its media ID.
1332 ret = minfo_get_item_by_id(mb_svc_handle, media_id, &mi);
1337 minfo_destroy_mtype_item(mi);
1343 minfo_get_item_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, Mitem **mitem);
1348 * This function gets mitem information. When user could get the full pathname of a media content, he/she
1349 * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
1350 * media content type, media content's thumbnail name, media content's pathname, etc. The detail defination
1351 * of this structute, could refer to the header, minfo-item.h.
1352 * @param mb_svc_handle [in] the handle of DB
1353 * @param file_url [in] the local file full pathname
1354 * @param mitem [out] the returned data structure whose type is Mitem.
1355 * @return This function returns 0 on success, or negative value with error code.
1356 * @remarks when invoking this function, *mitem must equals NULL, and
1357 * after using mitem, it must be freed with minfo_mitem_destroy.
1358 * @see minfo_get_item_by_id.
1364 #include <media-svc.h>
1366 void test_minfo_get_item(MediaSvcHandle *mb_svc_handle)
1370 char* file_url = "/opt/media/Images/Wallpapers/Home_01.png";
1372 //get an item based on its url.
1373 ret = minfo_get_item(mb_svc_handle, file_url, &mi);
1378 minfo_destroy_mtype_item(mi);
1384 minfo_get_item(MediaSvcHandle *mb_svc_handle, const char* file_url, Mitem **mitem);
1387 * minfo_get_item_by_http_url
1388 * This function gets mitem information. When user could get the http url of a media content, which is downloaded from web, he/she
1389 * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
1390 * media content type, media content's thumbnail name, etc. The detail defination
1391 * of this structute, could refer to the header, minfo_item/minfo-item.h.
1392 * @param mb_svc_handle [in] the handle of DB
1393 * @param http_url [in] the http url of a media, which is downloaded from web.
1394 * @param mitem [out] the returned data structure whose type is Mitem.
1395 * @return This function returns 0 on success, or negative value with error code.
1396 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
1397 * @remarks when invoking this function, *mitem must equals NULL, and
1398 * after using mitem, it must be freed with minfo_mitem_destroy.
1399 * @see minfo_get_item_by_id, minfo_get_item
1405 #include <media-svc.h>
1407 void test_minfo_get_item_by_http_url(MediaSvcHandle *mb_svc_handle)
1411 char* http_url = "http://picasa.com/myaccount/Home_01.png";
1413 //get an item based on its http url.
1414 ret = minfo_get_item_by_http_url(mb_svc_handle, http_url, &mi);
1419 minfo_destroy_mtype_item(mi);
1425 minfo_get_item_by_http_url(MediaSvcHandle *mb_svc_handle, const char* http_url, Mitem **mitem);
1430 * This function gets mcluster information by folder full path or cluster id when user could not know exact url of cluster. When user could get full path of a folder, he/she
1431 * could get the detail information with the type 'Mcluster' about this cluster/local folder, the type 'Mcluster'
1432 * mainly include folder/cluster ID, display name, count of included media content, etc. The detail defination
1433 * of this type could refer to the herder file, minfo-cluster.h.
1435 * @return This function returns 0 on success, or negative value with error code.
1436 * @param mb_svc_handle [in] the handle of DB
1437 * @param cluster_url [in] local folder full path, it indicate which folder user want to get it's detail information
1438 * @param cluster_id [in] the cluster ID which indentify a cluster
1439 * @param mcluster [out] mcluster to be returned, which is a 'Mcluster' type
1441 * @remarks when user could not know exact url of a cluster, he/she could choose alternative way he/she pass cluster id to this function, so that
1442 * this function still could get the wanted cluster.
1443 * when invoking this function, *mcluster must equals NULL, and
1444 * after using mitem, it must be freed with minfo_mcluster_destroy.
1445 * @see minfo_mcluster_destroy
1451 #include <media-svc.h>
1453 void test_minfo_get_cluster(MediaSvcHandle *mb_svc_handle)
1456 Mcluster *mc = NULL;
1457 char *cluster_url = "/opt/media/Images/Wallpapers";
1458 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1460 //get a cluster using cluster's url.
1461 ret = minfo_get_cluster(mb_svc_handle, cluster_url, cluster_id, &mc);
1463 printf("minfo_get_cluster fail: %d \n", ret);
1467 printf("minfo_get_cluster: %s \n", mc->display_name);
1468 minfo_mcluster_destroy(mc);
1474 minfo_get_cluster(MediaSvcHandle *mb_svc_handle, const char* cluster_url, const char *cluster_id, Mcluster **mcluster);
1478 * minfo_get_cluster_cover
1479 * This function gets thumbnail path of cover files by cluster id. This function could get the cover of a cluster
1480 * or folder which may include first several items' thumbnails, maybe 5 or other number, user could specify it
1483 * @param mb_svc_handle [in] the handle of DB
1484 * @param cluster_id [in] the folder id in which media files are in. if the parameter is -1, then query all folders.
1485 * @param img_cnt [in] the count of cover thumbnails
1486 * @param func [in] Iterative callback implemented by a user. This callback is called when an thumbnail path has to be inserted to user's list.
1487 * @param user_data [out] user's data structure to contain items of thumbnail path. It is passed to the iterative callback.
1489 * @return This function returns 0 on success, or negative value with error code.
1490 * @remarks type of item is pointer to char*,
1491 * when free list, needn't free every string.
1498 #include <media-svc.h>
1500 int cover_ite_cb(char *thumb_path, void *user_data)
1502 GList** list = (GList**)user_data;
1503 *list = g_list_append(*list, thumb_path);
1506 void test_minfo_get_cluster_cover(MediaSvcHandle *mb_svc_handle)
1509 GList *p_list = NULL;
1511 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1513 //get the cover of a cluster.
1514 ret = minfo_get_cluster_cover(mb_svc_handle, cluster_id, img_cnt, cover_ite_cb, &p_list);
1516 printf("test_minfo_get_cluster_cover error\n");
1525 minfo_get_cluster_cover(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const int img_cnt, minfo_cover_ite_cb func, void *user_data);
1529 * minfo_get_bookmark_list
1530 * This function gets the type 'Mbookmark' instances list. Data of each this type instance is
1531 * composed of the matched record indentified by the media id from 'video_bookmark' table.
1532 * The type 'Mbookmark' mainly include the these information, like, bookmark id, media id,
1533 * marked time, corresponding thumbnail pathanme, etc.
1535 * @param mb_svc_handle [in] the handle of DB
1536 * @param media_id [in] media_id field of video_bookmark table record
1537 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
1538 * @param user_data [out] User's data structure to contain items of the type Mbookmark. It is passed to the iterative callback.
1539 * @return This function returns 0 on success, or negative value with error code.
1540 * @remarks member data in list is pointer to structure Mbookmark,
1541 * when free list, it need free every item first and then free list itself.
1548 #include <media-svc.h>
1550 int mbookmark_ite_cb(Mbookmark *bm, void *user_data)
1552 GList** list = (GList**)user_data;
1553 *list = g_list_append(*list, bm);
1556 void test_minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle)
1559 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1560 GList *p_list = NULL;
1562 //get a linked list which will include all of bookmarks of a media file.
1563 ret = minfo_get_bookmark_list(mb_svc_handle, media_id, mbookmar_ite_cb, &p_list);
1572 minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_bm_ite_cb func, void *user_data);
1576 * minfo_get_geo_item_list
1577 * This function gets the type 'Mitem' instances list. Data of each instance is composed of the matched record identified
1578 * by @p filter from 'media' table. Except that the got items pass the criterion of @p filter, they should position where the longitude
1579 * is between @p min_longitude and @p max_longitude, and the latitude is between @p min_latitude and @p max_latitude.
1580 * This function gets 'Mitem' list matched with latitude, longitude, filter and cluster id.
1581 * @param mb_svc_handle [in] the handle of DB
1582 * @param cluster_id [in] indicate the value, 'fold_id' field in 'media' table record
1583 * @param filter [in] specified filter to get matched media record
1584 * @param store_filter [in] specified storage filter to get matched media record
1585 * @param min_longitude [in] minimum value of 'longitude' field in 'vidoe_meta'/'image_meta' table
1586 * @param max_longitude [in] maximum value of longitude field in 'vidoe_meta'/'image_meta' table
1587 * @param min_latitude [in] minimum value of 'latitude' field in 'video_meta'/'image_meta' record
1588 * @param max_latitude [in] maximum value of 'latitude' field in 'video_meta'/'image_meta' record
1589 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
1590 * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
1591 * @return This function returns 0 on success, or negative value with error code.
1592 * @remarks item type in list is pointer to structure Mitem,
1593 * when free list, it need free every item first and then free list itself.
1600 #include <media-svc.h>
1602 int mitem_ite_cb(Mitem *item, void *user_data)
1604 GList** list = (GList**)user_data;
1605 *list = g_list_append(*list, item);
1608 void test_minfo_get_geo_item_list(MediaSvcHandle *mb_svc_handle)
1611 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1612 int min_longitude = 120.0;
1613 int max_longitude = 123.0;
1614 int min_latitude = 19.0;
1615 int max_latitude = 24.0;
1616 GList *p_list = NULL;
1618 //get a linked list which include a set of items based on their location.
1619 ret = minfo_get_geo_item_list(mb_svc_handle,
1630 printf("minfo_get_geo_item_list failed\n");
1638 minfo_get_geo_item_list(MediaSvcHandle *mb_svc_handle,
1639 const char *cluster_id,
1640 minfo_folder_type store_filter,
1641 minfo_item_filter filter,
1642 double min_longitude,
1643 double max_longitude,
1644 double min_latitude,
1645 double max_latitude,
1646 minfo_item_ite_cb func,
1652 * minfo_get_thumb_path
1653 * This function gets thumbnail path of specified image file. When user could get the full pathname of a image content.
1654 * He/She wants to get the thumbnail file corresponding to the image content identified by the @p file_url.
1655 * User is responsible for allocating the memory for @p thumb_path so that this function could fill up the thumbnail pathname to it.
1656 * @param mb_svc_handle [in] the handle of DB
1657 * @param file_url [in] local file full path, identify a media record in 'media' table
1658 * @param thumb_path [out] the returned thumbnail path of specified file, user is responsible for allocating memory for it first
1659 * @param max_thumb_path [in] The max length of the returned thumbnail path
1661 * @return This function returns 0 on success, or negative value with error code.
1662 * @remarks one file full path always matches one thumbnail path,
1663 here, it returns thumbnail path , but maybe thumbnail file doesn't exist, return NULL.
1664 * @see minfo_get_thumb_path_for_video.
1670 #include <media-svc.h>
1672 void test_minfo_get_thumb_path(MediaSvcHandle *mb_svc_handle)
1675 char thumb_path[256] = {'\0'};
1676 char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
1678 //get thumbnail pathname of an item.
1679 ret = minfo_get_thumb_path(mb_svc_handle, file_url, thumb_path, sizeof(thumb_path));
1681 printf("minfo_get_thumb_path failed\n");
1689 minfo_get_thumb_path(MediaSvcHandle *mb_svc_handle, const char* file_url, char* thumb_path, size_t max_thumb_path);
1692 * minfo_get_thumb_path_for_video
1693 * This function gets thumbnail path of specified video file. When user could get the full pathname of a video content.
1694 * He/She wants to get the thumbnail file corresponding to the video content identified by the @p file_url.
1695 * User is responsible for allocating the memory for @p thumb_path so that this function could fill up the thumbnail pathname to it.
1696 * @param mb_svc_handle [in] the handle of DB
1697 * @param file_url [in] local file full path, identify a media record in 'media' table
1698 * @param thumb_path [out] the returned thumbnail path of specified file, user is responsible for allocating memory for it first
1699 * @param max_thumb_path [in] The max length of the returned thumbnail path
1701 * @return This function returns 0 on success, or negative value with error code.
1702 * @remarks one file full path always matches one thumbnail path,
1703 here, it returns thumbnail path , but maybe thumbnail file doesn't exist, return NULL.
1704 * @see minfo_get_thumb_path.
1710 #include <media-svc.h>
1712 void test_minfo_get_thumb_path_for_video(MediaSvcHandle *mb_svc_handle)
1715 char thumb_path[256] = {'\0'};
1716 char *file_url = "/opt/media/Images and videos/My video clip/Helicopter.mp4";
1718 //get thumbnail pathname of an item.
1719 ret = minfo_get_thumb_path_for_video(mb_svc_handle, file_url,thumb_path, sizeof(thumb_path));
1721 printf("minfo_get_thumb_path_for_video failed\n");
1729 minfo_get_thumb_path_for_video(MediaSvcHandle *mb_svc_handle, const char* file_url, char* thumb_path, size_t max_thumb_path);
1732 * minfo_delete_media_id
1733 * This function deletes matched record identified by the @p media_id from 'media' table , 'video_meta'/'image_meta' record.
1734 * After that, if the folder which this deleted file is in becomes empty, then delete the folder record from 'folder' table, too.
1735 * In order that user could successfully delete the corresponding record from 'media' table, he/she should be able to the correct _id
1736 * of media content before it.
1738 * @param mb_svc_handle [in] the handle of DB
1739 * @param media_id [in] represent the value, media '_id' in 'media' table record
1740 * @return This function returns 0 on success, or negative value with error code.
1742 * @see minfo_delete_media.
1748 #include <media-svc.h>
1750 void test_minfo_delete_media_id(MediaSvcHandle *mb_svc_handle)
1753 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1755 //delete an item according to its ID.
1756 ret = minfo_delete_media_id(mb_svc_handle, media_id);
1758 printf("test_minfo_delete_media_id failed\n");
1766 minfo_delete_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id);
1769 * minfo_delete_all_media_records:\n
1770 * This function delete all media records in a type of storage like phone or MMC.
1771 * This function is always used for MMC card insert/inject operation, in file manager service library.
1773 * @param mb_svc_handle [in] the handle of DB
1774 * @param storage_type [in] information for storage type
1775 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
1776 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
1784 #include <media-svc.h>
1786 void test_minfo_delete_all_media_records(MediaSvcHandle *mb_svc_handle)
1788 int ret = MB_SVC_ERROR_NONE;
1790 //delete all media records in MMC storage in db.
1791 ret = minfo_delete_all_media_records(mb_svc_handle, MINFO_MMC);
1793 printf( "failed to delete items. error code->%d", ret);
1802 minfo_delete_all_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type);
1806 * This function copies specified media file to another folder, which is identified by the folder id, @p dst_cluster_id. Meanwhile the copied media file
1807 * is identified by it's media id. Compared to API, minfo_copy_media, the different is , this function copy a media content to specified folder,
1808 * according to the media content id and the destination folder's id, however the function, minfo_copy_media, copy a media content to specified folder
1809 * according to the media file's full pathname and folder's full name.
1810 * @param mb_svc_handle [in] the handle of DB
1811 * @param src_media_id [in] id of the source media file, it's value is from '_id' field of the 'media' table
1812 * @param dst_cluster_id [in] id of the destination folder, it's value is from '_id' field of the 'folder' table
1813 * @return This function returns 0 on success, or negative value with error code.
1814 * @remarks This function will implement the same functionality as minfo_copy_media.
1815 * @see minfo_copy_media
1821 #include <media-svc.h>
1823 void test_minfo_cp_media(MediaSvcHandle *mb_svc_handle)
1826 const char *src_media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1827 const char *dst_cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1829 //copy the a media file whose ID is specified by, 'src_media_id', to a cluster.
1830 ret = minfo_cp_media(mb_svc_handle, src_media_id, dst_cluster_id);
1832 printf("minfo_cp_media failed\n");
1840 minfo_cp_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
1846 * This function moves specified media file to another folder, which is identified by the folder id, @p dst_cluster_id. Meanwhile the moved media file
1847 * is identified by it's media id. Compared to API, minfo_move_media, the difference is that this function moves a media content to specified folder,
1848 * according to the media content id and the destination folder's id, however the function, minfo_move_media, move a media content to specified folder
1849 * according to the media file's full pathname and folder's full name.
1850 * @param mb_svc_handle [in] the handle of DB
1851 * @param src_media_id [in] id of the source media file, it's value is from '_id' field of the 'media' table
1852 * @param dst_cluster_id [in] id of the destination folder, it's value is from '_id' field of the 'folder'
1853 * @return This function returns 0 on success, or negative value with error code.
1855 * @see minfo_move_media.
1861 #include <media-svc.h>
1863 void test_minfo_mv_media(MediaSvcHandle *mb_svc_handle)
1866 const char *src_media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
1867 const char *dst_cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1869 //move an item to specified cluster.
1870 ret = minfo_mv_media(mb_svc_handle, src_media_id, dst_cluster_id);
1872 printf("minfo_mv_media failed\n");
1881 minfo_mv_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
1886 * minfo_delete_cluster
1887 * This function deletes specified cluster, which is identified by the @p cluster_id. When user launch Gallery and in edit 'Albums' mode, if he/she
1888 * want to delete a cluster/folder, so call this function to do it. When delete a cluster/folder, the media-svc will not only delete the record in 'folder' table,
1889 * but delete all of records in 'media' table which are located in this folder, meanwhile delete the corresponding records in 'video_bookmark' table, etc.
1890 * @param mb_svc_handle [in] the handle of DB
1891 * @param cluster_id [in] cluster id, to indicate the deleted folder/cluster
1892 * @return This function returns 0 on success, or negative value with error code.
1893 * @remarks delete all releated contents in cluster together with cluster
1894 * like all media files, image/video meta,bookmark information.
1895 * @see minfo_add_cluster
1902 #include <media-svc.h>
1904 void test_minfo_delete_cluster(MediaSvcHandle *mb_svc_handle)
1907 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1909 //delete a cluster record, meanwhile this function will delete all of items owned by this cluster.
1910 ret = minfo_delete_cluster(mb_svc_handle, cluster_id);
1912 printf("minfo_delete_cluster failed\n");
1920 minfo_delete_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_id);
1925 * minfo_update_cluster_name
1926 * This function updates the specified cluster name using @p new_name, which just indicate the new folder name. User could
1927 * call this function, when he/she wants to change some folder/cluster name. This really update the corresponding record in
1929 * @param mb_svc_handle [in] the handle of DB
1930 * @param cluster_id [in] cluster id, this value is from the '_id' field of 'folder' table
1931 * @param new_name [in] new cluster name
1932 * @return This function returns 0 on success, or negative value with error code.
1940 #include <media-svc.h>
1942 void test_minfo_update_cluster_name(MediaSvcHandle *mb_svc_handle)
1945 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1946 char *new_name = "newfolder";
1948 //update a cluster's name
1949 ret = minfo_update_cluster_name(mb_svc_handle, cluster_id,new_name);
1951 printf("minfo_update_cluster_name failed\n");
1959 minfo_update_cluster_name(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* new_name);
1962 * minfo_update_cluster_date
1963 * This function updates the specified cluster modified date using @p modified_date, which just indicate the new modified date. User could
1964 * call this function, when he/she wants to change some clsuter's modified date. This really update the corresponding record in the DB
1965 * @param mb_svc_handle [in] the handle of DB
1966 * @param cluster_id [in] cluster id, this value is the identifier of the cluster
1967 * @param modified_date [in] date to modify, which is a type of time_t
1968 * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
1969 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
1977 #include <media-svc.h>
1980 void test_minfo_update_cluster_date(void)
1983 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
1987 //update a cluster's name
1988 ret = minfo_update_cluster_date(cluster_id, today);
1991 printf("minfo_update_cluster_date failed\n");
1999 minfo_update_cluster_date(MediaSvcHandle *mb_svc_handle, const char *cluster_id, time_t modified_date);
2004 * minfo_add_bookmark
2005 * This function inserts new bookmark record into 'video_bookmark' table. The inserted data should include marked time of video content, @p position
2006 * and @p thumb_path, current extracted thumbnail file in marked time, etc. User should use @p media_id to identify the
2007 * video content, so that add bookmark to it.
2008 * @param mb_svc_handle [in] the handle of DB
2009 * @param media_id [in] media file id, uniquely identify the media content
2010 * @param position [in] marked time of the media file
2011 * @param thumb_path [in] the extracted thumbnail path for this marked time
2012 * @return This function returns 0 on success, or negative value with error code.
2013 * @remarks if add same input parameters twice, it fails
2014 * @see minfo_delete_bookmark
2021 #include <media-svc.h>
2023 void test_minfo_add_bookmark(MediaSvcHandle *mb_svc_handle)
2026 int position = 2346;
2027 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
2028 char *thumb_path = "tmp1";
2030 //add a bookmark which include position, thumbnail, etc. to an item.
2031 ret = minfo_add_bookmark(mb_svc_handle, media_id,position,thumb_path);
2033 printf("minfo_add_bookmark failed\n");
2042 minfo_add_bookmark(MediaSvcHandle *mb_svc_handle, const char *media_id, const int position, const char* thumb_path);
2046 * minfo_delete_bookmark
2047 * This function deletes specified bookmark record from 'video_bookmark' table, the deleted bookmark should be identified by @p bookmark_id.
2048 * This function actually call the sqlite3 statement,
2049 * "DELETE FROM video_bookmark WHERE _id = bookmark_id; "
2050 * In gallery or ug-imageviewer, user could get a linked list bookmark for some media file, so he/she could delete one of them using @p bookmark_id.
2052 * @param mb_svc_handle [in] the handle of DB
2053 * @param bookmark_id [in] _id field in video_bookmark table.
2054 * @return This function returns 0 on success, or negative value with error code.
2055 * @remarks user should give a correct bookmark ID to successfully delete it.
2056 * @see minfo_add_bookmark
2063 #include <media-svc.h>
2065 void test_minfo_delete_bookmark(MediaSvcHandle *mb_svc_handle)
2068 int bookmark_id = 1;
2070 //delete a bookmark record in 'video_bookmark' table.
2071 ret = minfo_delete_bookmark(mb_svc_handle, bookmark_id);
2074 printf("minfo_delete_bookmark failed\n");
2082 minfo_delete_bookmark(MediaSvcHandle *mb_svc_handle, const int bookmark_id);
2088 * minfo_get_cluster_id_by_url
2089 * This function gets some folder's full path. This will be called when user want to know what one folder's unique
2092 * @return This function returns 0 on success, and -1 on failure.
2093 * @param mb_svc_handle [in] the handle of DB
2094 * @param url [in] folder path
2095 * @param cluster_id [out] folder ID
2104 #include <media-svc.h>
2106 void test_minfo_get_cluster_id_by_url(MediaSvcHandle *mb_svc_handle)
2109 char cluster_id[256] = {0,};
2110 char *url = "/opt/media/Images/Wallpapers";
2112 //get cluster's ID using cluster's url.
2113 ret = minfo_get_cluster_id_by_url(url, cluster_id, sizeof(mb_svc_handle, cluster_id));
2115 printf("test_minfo_get_cluster_id_by_url failed\n");
2122 minfo_get_cluster_id_by_url(MediaSvcHandle *mb_svc_handle, const char* url, char* cluster_id, int max_length);
2126 * minfo_get_cluster_name_by_id
2127 * This function gets folder's name. This will be called when user want to know what one folder's name
2129 * @return This function returns 0 on success, and -1 on failure.
2130 * @param[in] mb_svc_handle the handle of DB
2131 * @param[in] cluster_id folder ID
2132 * @param[out] cluster_name folder name
2133 * @param[in] max_length The max length of the returned folder name.
2142 #include <media-svc.h>
2144 void test_minfo_get_cluster_name_by_id(MediaSvcHandle *mb_svc_handle)
2147 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
2148 char *cluster_name[1024];
2150 //get cluster's name using cluster's id.
2151 ret = minfo_get_cluster_name_by_id(mb_svc_handle, cluster_id, cluster_name, sizeof(cluster_name));
2154 printf("test_minfo_get_cluster_name_by_id failed\n");
2157 printf("cluster name is %s\n", cluster_name);
2164 minfo_get_cluster_name_by_id(MediaSvcHandle *mb_svc_handle, const char *cluster_id, char *cluster_name, int max_length );
2167 * minfo_get_cluster_fullpath_by_id
2168 * This function gets folder's full path. This will be called when user want to know what one folder's full path.
2169 * User should specify the maximum length of the @p folder_path, so as to avoid over flow of the string.
2171 * @return This function returns 0 on success, and -1 on failure.
2172 * @param[in] mb_svc_handle the handle of DB
2173 * @param[in] cluster_id folder ID
2174 * @param[out] folder_path folder path name
2175 * @param[in] max_length specify the maximum length of @p folder_path.
2184 #include <media-svc.h>
2186 void test_minfo_get_cluster_fullpath_by_id(MediaSvcHandle *mb_svc_handle)
2189 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
2190 char *folder_path[1024];
2192 //get cluster's path name using cluster's id.
2193 ret = minfo_get_cluster_fullpath_by_id(mb_svc_handle, cluster_id, folder_path, sizeof(folder_path));
2196 printf("test_minfo_get_cluster_fullpath_by_id failed\n");
2199 printf("path name is %s\n", cluster_name);
2207 minfo_get_cluster_fullpath_by_id(MediaSvcHandle *mb_svc_handle, const char *cluster_id, char *folder_path, int max_length);
2212 * minfo_set_cluster_lock_status
2213 * @fn int minfo_set_cluster_lock_status( int cluster_id, int lock_status );
2214 * This function set status for lock to DB. This will be called when user want to set to lock an album.
2216 * @return This function returns 0 on success, and -1 on failure.
2217 * @param[in] mb_svc_handle the handle of DB
2218 * @param[in] cluster_id folder ID
2219 * @param[in] lock_status status for lock to be saved ( 0 : unlock, 1 : lock )
2222 * @see minfo_get_cluster_lock_status.
2228 #include <media-svc.h>
2230 void test_minfo_set_cluster_lock_status(MediaSvcHandle *mb_svc_handle)
2234 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
2236 //set s cluster lock status.
2237 ret = minfo_set_cluster_lock_status(mb_svc_handle, cluster_id, status);
2240 printf("test_minfo_set_cluster_lock_status failed\n");
2248 minfo_set_cluster_lock_status(MediaSvcHandle *mb_svc_handle, const char *cluster_id, int lock_status);
2251 * minfo_get_cluster_lock_status
2252 * @fn int minfo_get_cluster_lock_status( int cluster_id, int *lock_status );
2253 * This function gets status for lock from DB. This will be called when user want to get lock status for an album.
2255 * @return This function returns 0 on success, and -1 on failure.
2256 * @param[in] mb_svc_handle the handle of DB
2257 * @param[in] cluster_id folder ID
2258 * @param[out] lock_status status for cuurent lock status
2261 * @see minfo_set_cluster_lock_status.
2267 #include <media-svc.h>
2269 void test_minfo_get_cluster_lock_status(MediaSvcHandle *mb_svc_handle)
2272 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
2275 //get a cluster's status.
2276 ret = minfo_get_cluster_lock_status(mb_svc_handle, cluster_id, &status);
2279 printf("test_minfo_get_cluster_lock_status failed\n");
2282 print("Current status : %d\n", status);
2290 minfo_get_cluster_lock_status(MediaSvcHandle *mb_svc_handle, const char *cluster_id, int *lock_status );
2293 * @fn int minfo_get_media_path( minfo_store_type storage_type, char* media_path, size_t max_media_path);
2294 * This function gets the path of media. This will be called when user want to get path of direcotry containing media in device.
2296 * @return This function returns 0 on success, and -1 on failure.
2297 * @param[in] storage_type store type, which means type of device containg media.
2298 * @param[out] media_path path of media
2299 * @param[in] max_media_path The max length of the returned media_path.
2308 #include <media-svc.h>
2310 void test_minfo_get_media_path(void)
2313 char media_path[256] = {'\0'};
2315 //get media's fullpath.
2316 ret = minfo_get_media_path(MINFO_PHONE, media_path, sizeof(media_path));
2319 printf("minfo_get_media_path failed\n");
2322 print("The returned path : %s\n", media_path);
2330 minfo_get_media_path(minfo_store_type storage_type, char* media_path, size_t max_media_path );
2334 * minfo_set_db_valid
2335 * This function set whether all the media contents in a type of storage are valid, like phone or MMC.
2336 * Actually media service will filter all the media contents query from database by the media validation.
2337 * This function is always used for MMC card insert/inject operation, in file manager service library.
2338 * When inject a MMC card, the media records for MMC are not deleted really, but are set to be invalid.
2340 * @param[in] mb_svc_handle the handle of DB
2341 * @param[in] storage_type information for storage type
2342 * @param[in] valid whether the track item is valid.
2343 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2344 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2345 * @see minfo_delete_invalid_media_records.
2352 #include <media-svc.h>
2354 void set_db_valid(MediaSvcHandle *mb_svc_handle)
2356 int ret = MB_SVC_ERROR_NONE;
2359 //set the validation of medias in MMC storage in db.
2360 ret = minfo_set_db_valid(mb_svc_handle, MINFO_MMC, valid);
2362 printf( "failed to set db invalid. error code->%d", ret);
2370 int minfo_set_db_valid(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type, int valid);
2373 * minfo_set_item_valid_start
2374 * This function set whether the media content in a type of storage is valid, like phone or MMC.
2375 * Actually media service will filter all the media contents query from database by the media validation.
2377 * @param[in] mb_svc_handle the handle of DB
2378 * @param[in] trans_count count of trasaction user wants
2379 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2380 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2381 * @see minfo_set_item_valid, minfo_set_item_valid_end
2388 #include <media-svc.h>
2390 void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
2393 int ret = MB_SVC_ERROR_NONE;
2396 ret = minfo_set_item_valid_start(mb_svc_handle, 100);
2398 printf( "minfo_set_item_valid_start failed. error code->%d", ret);
2402 for (i = 0; i < 200; i++) {
2403 //set the validation of a media in MMC storage in db.
2404 ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
2406 printf( "failed to set item valid. error code->%d", ret);
2411 ret = minfo_set_item_valid_end(mb_svc_handle);
2413 printf( "minfo_set_item_valid_end failed. error code->%d", ret);
2423 int minfo_set_item_valid_start(MediaSvcHandle *mb_svc_handle, int trans_count);
2427 * minfo_set_item_valid_end
2428 * This function set whether the media content in a type of storage is valid, like phone or MMC.
2429 * Actually media service will filter all the media contents query from database by the media validation.
2431 * @param[in] mb_svc_handle the handle of DB
2432 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2433 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2434 * @see minfo_set_item_valid_start, minfo_set_item_valid
2441 #include <media-svc.h>
2443 void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
2446 int ret = MB_SVC_ERROR_NONE;
2449 ret = minfo_set_item_valid_start(mb_svc_handle, 100);
2451 printf( "minfo_set_item_valid_start failed. error code->%d", ret);
2455 for (i = 0; i < 200; i++) {
2456 //set the validation of a media in MMC storage in db.
2457 ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
2459 printf( "failed to set item valid. error code->%d", ret);
2464 ret = minfo_set_item_valid_end(mb_svc_handle);
2466 printf( "minfo_set_item_valid_end failed. error code->%d", ret);
2475 int minfo_set_item_valid_end(MediaSvcHandle *mb_svc_handle);
2479 * minfo_set_item_valid
2480 * This function set whether the media content in a type of storage is valid, like phone or MMC.
2481 * Actually media service will filter all the media contents query from database by the media validation.
2483 * @param[in] mb_svc_handle the handle of DB
2484 * @param[in] storage_type information for storage type
2485 * @param[in] full_path The path of the media
2486 * @param[in] valid whether the track item is valid.
2487 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2488 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2489 * @see minfo_set_item_valid_start, minfo_set_item_valid_end
2496 #include <media-svc.h>
2498 void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
2501 int ret = MB_SVC_ERROR_NONE;
2504 ret = minfo_set_item_valid_start(mb_svc_handle, 100);
2506 printf( "minfo_set_item_valid_start failed. error code->%d", ret);
2510 for (i = 0; i < 200; i++) {
2511 //set the validation of a media in MMC storage in db.
2512 ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
2514 printf( "failed to set item valid. error code->%d", ret);
2519 ret = minfo_set_item_valid_end(mb_svc_handle);
2521 printf( "minfo_set_item_valid_end failed. error code->%d", ret);
2532 int minfo_set_item_valid(MediaSvcHandle *mb_svc_handle,
2533 const minfo_store_type storage_type,
2534 const char *full_path,
2539 * minfo_delete_invalid_media_records
2540 * This function delete all of invalid media records in a type of storage are valid, like phone or MMC.
2541 * Actually media service will filter all the media contents query from database by the media validation.
2542 * This function is always used for MMC card insert/inject operation, in file manager service library.
2543 * When inject a MMC card, the media records for MMC are not deleted really, but are set to be invalid.
2545 * @param[in] mb_svc_handle the handle of DB
2546 * @param[in] storage_type information for storage type
2547 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2548 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2549 * @see minfo_set_db_valid.
2556 #include <media-svc.h>
2558 void test_minfo_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle)
2560 int ret = MB_SVC_ERROR_NONE;
2562 //delete the invalid media records in MMC storage in db.
2563 ret = minfo_delete_invalid_media_records(mb_svc_handle, MINFO_MMC);
2565 printf( "failed to delete invalid items. error code->%d", ret);
2574 minfo_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type);
2578 * This function could delete a tag or some member of the tag in 'media_tag' table in database. When user pass @p media_id not equal
2579 * to -1, the tag will be deleted, otherwise some member of the tag will be deleted. Whatever cases, user should pass the correct tag name with
2580 * @p tag_name to successfully delete.
2582 * @param[in] mb_svc_handle the handle of DB
2583 * @param[in] media_id identify a media item with this ID
2584 * @param[in] tag_name name of deleted tag
2585 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2586 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2594 #include <media-svc.h>
2596 void delete_a_tag(MediaSvcHandle *mb_svc_handle)
2598 int ret = MB_SVC_ERROR_NONE;
2600 //delete all tag records in 'media_tag' in db, whose tag name is 'test_tag'.
2601 ret = minfo_delete_tag(mb_svc_handle, -1, "test tag");
2603 printf( "failed to delete a tag record. error code->%d", ret);
2612 minfo_delete_tag(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* tag_name);
2617 * This function could rename a tag_name to another tag_name in 'media_tag' table in database. User need to pass @p src_tagname which indicate original
2618 * tag name, @p dst_tag_name which is new tag name replacing @p src_tagname. This function will check whether the new tag name, @p dst_tag_name, has
2619 * existed in 'media_tag' table. If yes, this function will item by item replace old tag name, if no, this function will directly update old tag name to new tag name.
2621 * @param[in] mb_svc_handle the handle of DB
2622 * @param[in] src_tagname identify original tag name
2623 * @param[in] dst_tag_name new tag name.
2624 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2625 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2633 #include <media-svc.h>
2635 void test_minfo_rename_tag(MediaSvcHandle *mb_svc_handle)
2637 int ret = MB_SVC_ERROR_NONE;
2639 //rename all tag records with new tag name 'test_tag2'.
2640 ret = minfo_rename_tag(mb_svc_handle, "test tag1", "test tag2");
2642 printf( "failed to rename tag records. error code->%d", ret);
2651 minfo_rename_tag(MediaSvcHandle *mb_svc_handle, const char* src_tagname, const char* dst_tag_name);
2654 * minfo_rename_tag_by_id:
2655 * This function could rename a tag_name for some tag record to another tag_name in 'media_tag' table in database. User need to pass @p src_tagname which indicate original
2656 * tag name, @p media_id which combine with the @p src_tagname to indentify one tag record, @p dst_tag_name which is new tag name replacing @p src_tagname.
2657 * This function will check whether the new tag name with @p media_id has existed in 'media_tag' table. If yes, this function will delete old tag record, if no, this function will directly
2658 * update old tag record to new tag record.
2660 * @param[in] mb_svc_handle the handle of DB
2661 * @param[in] media_id identify original tag record with @p src_tagname
2662 * @param[in] src_tagname identify original tag record with @p media_id
2663 * @param[in] dst_tag_name new tag name.
2664 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2665 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2673 #include <media-svc.h>
2675 void test_minfo_rename_tag_by_id(MediaSvcHandle *mb_svc_handle)
2677 int ret = MB_SVC_ERROR_NONE;
2678 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
2680 //rename some tag record with new tag name 'test_tag2'.
2681 ret = minfo_rename_tag_by_id(mb_svc_handle, media_id, "test tag1", "test tag2");
2683 printf( "failed to rename tag records. error code->%d", ret);
2692 minfo_rename_tag_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* src_tagname, const char* dst_tag_name);
2699 * This function could add a new tag into 'media_tag' table in database. When user create a new tag and will
2700 * not add any media item to it, he/she should set @p media_id as 0. When user create a new tag and want to add
2701 * some media items to it, he/she should do a loop to insert them into 'media_tag' table in database, meanwhile
2702 * should fill up @p media_id and @p tag_name with appropriate values.
2704 * @param[in] mb_svc_handle the handle of DB
2705 * @param[in] media_id identify a media item with this ID
2706 * @param[in] tag_name name of new added tag
2707 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2708 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2716 #include <media-svc.h>
2718 void add_a_tag(MediaSvcHandle *mb_svc_handle)
2720 int ret = MB_SVC_ERROR_NONE;
2722 //add a tag record in 'media_tag' in db, and not add any media item to it.
2723 ret = minfo_add_tag(mb_svc_handle, NULL, "test tag");
2726 printf( "failed to add a tag record. error code->%d", ret);
2737 minfo_add_tag(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* tag_name);
2740 * minfo_get_media_list_by_tagname:
2741 * This function could get a media items' list who are included to the same tag according to tag name .
2742 * User could dictate whether he/she hope to get meta data of media item with @p with_meta. Yes if TRUE,
2745 * @param[in] mb_svc_handle the handle of DB
2746 * @param[in] tag_name tag name
2747 * @param[in] with_meta indicate whether want to get meta data of media item
2748 * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
2749 * @param[out] user_data user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
2750 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2751 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2759 #include <media-svc.h>
2761 int mitem_ite_cb(Mitem *item, void *user_data)
2763 GList** list = (GList**)user_data;
2764 *list = g_list_append(*list, item);
2768 void get_media_list_tag_name(MediaSvcHandle *mb_svc_handle)
2770 int ret = MB_SVC_ERROR_NONE;
2771 GList *p_list = NULL;
2773 //get a media items' list who are included to the same tag with 'test tag'.
2774 ret = minfo_get_media_list_by_tagname(mb_svc_handle, "test tag", FALSE, mitem_ite_cb, &p_list);
2776 printf( "failed to get a media items' list. error code->%d", ret);
2785 minfo_get_media_list_by_tagname(MediaSvcHandle *mb_svc_handle, const char* tag_name, bool with_meta, minfo_item_ite_cb func, void* user_data );
2788 * minfo_get_media_list_by_tagname_with_filter:
2789 * This function could get a media items' list who are included to the same tag according to tag name and filter.
2790 * User could dictate whether he/she hope to get meta data of media item with @p with_meta. Yes if TRUE,
2793 * @param[in] mb_svc_handle the handle of DB
2794 * @param[in] tag_name tag name
2795 * @param[in] filter the filter to specify some tag filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, etc.
2796 * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
2797 * @param[out] user_data user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
2798 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2799 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2807 #include <media-svc.h>
2809 int mitem_ite_cb(Mitem *item, void *user_data)
2811 GList** list = (GList**)user_data;
2812 *list = g_list_append(*list, item);
2816 void get_media_list_by_tagname_with_filter(MediaSvcHandle *mb_svc_handle)
2818 int ret = MB_SVC_ERROR_NONE;
2819 GList *p_list = NULL;
2820 minfo_tag_filter filter;
2822 filter.start_pos = 0;
2824 filter.file_type = MINFO_ITEM_ALL;
2825 filter.with_meta = FALSE;
2827 //get a media items' list who are included to the same tag with 'test tag'.
2828 ret = minfo_get_media_list_by_tagname_with_filter(mb_svc_handle, "test tag", filter, mitem_ite_cb, &p_list);
2830 printf( "failed to get a media items' list. error code->%d", ret);
2839 minfo_get_media_list_by_tagname_with_filter(MediaSvcHandle *mb_svc_handle, const char* tag_name, minfo_tag_filter filter, minfo_item_ite_cb func, void* user_data );
2842 * minfo_get_media_count_by_tagname:
2843 * This function could get count of media items, which are included to the same tag according to tag name .
2844 * User could dictate whether he/she hope to get count of media items.
2846 * @param[in] mb_svc_handle the handle of DB
2847 * @param[in] tag_name tag name
2848 * @param[out] count count of media items
2849 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2850 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2858 #include <media-svc.h>
2860 void test_minfo_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle)
2862 int ret = MB_SVC_ERROR_NONE;
2865 //get count of media items, which are included to the same tag with 'test tag'.
2866 ret = minfo_get_media_count_by_tagname(mb_svc_handle, "test tag", &count);
2868 printf( "failed to get a media items' list. error code->%d", ret);
2870 printf( "Count is %d\n", count );
2880 minfo_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle, const char* tag_name, int* count );
2883 * minfo_get_tag_list_by_media_id:
2884 * This function could get a tags' list whose memeber is Mtag type. User should pass @p media_id to indicate which
2885 * media item will be searched. Also he/she should define a callback function to be called by this function.
2887 * @param[in] mb_svc_handle the handle of DB
2888 * @param[in] media_id identify a media item with ID
2889 * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
2890 * @param[out] user_data user's data structure to contain items of the type Mtag. It is passed to the iterative callback.
2891 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2892 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2893 * @see minfo_set_db_valid.
2900 #include <media-svc.h>
2902 int mtag_ite_cb(Mtag *i_tag, void *user_data)
2904 GList** list = (GList**)user_data;
2905 *list = g_list_append(*list, item);
2909 void get_tag_list_media_id(MediaSvcHandle *mb_svc_handle)
2911 int ret = MB_SVC_ERROR_NONE;
2912 const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
2913 GList *p_list = NULL;
2915 //get a tags' list which include the same media item and it's media_id is b6a4f4ac-26ea-458c-a228-9aef7f70349d.
2916 ret = minfo_get_tag_list_by_media_id(mb_svc_handle, media_id, mtag_ite_cb, &p_list);
2918 printf( "failed to get a tags' list. error code->%d", ret);
2927 minfo_get_tag_list_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_tag_ite_cb func, void* user_data);
2930 * minfo_add_web_cluster
2931 * This function could add a web album through specifying it's @p name, @p account_id. After adding a web
2932 * album, this function will return @p id.
2934 * @param[in] mb_svc_handle the handle of DB
2935 * @param[in] sns_type sns type, like, facebook, flickr, etc.
2936 * @param[in] name new added web album's name.
2937 * @param[in] account_id account ID.
2938 * @param[out] id return album's id.
2939 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2940 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2941 * @see minfo_add_web_cluster_album_id.
2948 #include <media-svc.h>
2951 void add_web_cluster(MediaSvcHandle *mb_svc_handle)
2953 int ret = MB_SVC_ERROR_NONE;
2954 char cluster_id[256] = {0,};
2957 ret = minfo_add_web_cluster(mb_svc_handle, 1, "web_album", "1", cluster_id, sizeof(cluster_id));
2959 printf( "failed to add a web album. error code->%d", ret);
2969 minfo_add_web_cluster(MediaSvcHandle *mb_svc_handle, int sns_type, const char* name,const char *account_id, char* id, int max_length);
2973 * minfo_add_web_cluster_album_id
2974 * This function could add a web album through specifying it's @p name, @p account_id, @p album_id. After adding a web
2975 * album, this function will return @p id.
2977 * @param[in] mb_svc_handle the handle of DB
2978 * @param[in] sns_type sns type, like, facebook, flickr, etc.
2979 * @param[in] name new added web album's name.
2980 * @param[in] account_id account ID.
2981 * @param[in] album_id web album id
2982 * @param[out] id return album's id.
2983 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
2984 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
2985 * @see minfo_add_web_cluster.
2992 #include <media-svc.h>
2995 void add_web_cluster_album_id(MediaSvcHandle *mb_svc_handle)
2997 int ret = MB_SVC_ERROR_NONE;
2998 char cluster_id[256] = {0,};
3001 ret = minfo_add_web_cluster_album_id(mb_svc_handle, 1, "web_album", "1", "1", cluster_id, sizeof(cluster_id));
3003 printf( "failed to add a web album. error code->%d", ret);
3014 minfo_add_web_cluster_album_id(MediaSvcHandle *mb_svc_handle, int sns_type, const char* name, const char *account_id, const char *album_id, char *id, int max_length);
3017 * minfo_delete_web_cluster
3018 * This function could delete a web album through specifying @p cluster_id. After deleteing a web
3019 * album, the application will not be able to get this web album displaying.
3021 * @param[in] mb_svc_handle the handle of DB
3022 * @param[in] cluster_id cluster ID identifying a web album.
3023 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
3024 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
3032 #include <media-svc.h>
3034 void delete_web_cluster(MediaSvcHandle *mb_svc_handle)
3036 int ret = MB_SVC_ERROR_NONE;
3037 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
3039 //delete a web album.
3040 ret = minfo_delete_web_cluster(mb_svc_handle, cluster_id);
3042 printf( "failed to delete a web album. error code->%d", ret);
3053 minfo_delete_web_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_id);
3056 * minfo_get_web_cluster_by_web_account_id
3057 * This function gets list of mcluster by web account id. User could get the detail information with
3058 * the type 'Mcluster' about this cluster, the type 'Mcluster' mainly include folder/cluster ID, display name,
3059 * count of included media content, etc. The detail defination of this type could refer to the herder file, minfo_item/minfo-cluster.h.
3061 * @return This function returns 0 on success, or negative value with error code.
3062 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
3063 * @param mb_svc_handle [in] the handle of DB
3064 * @param web_account_id [in] the web account ID which indentify a cluster
3065 * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
3066 * @param user_data [out] user's data structure to contain items of the type Mcluster. It is passed to the iterative callback.
3068 * @remarks User could pass web account id to this function, so that
3069 * this function still could get the wanted list of clusters
3070 * when invoking this function.
3078 #include <media-svc.h>
3079 int mcluster_ite_cb(Mcluster *cluster, void *user_data)
3081 GList** list = (GList**)user_data;
3082 *list = g_list_append(*list, cluster);
3085 void test_minfo_get_web_cluster_by_web_account_id(MediaSvcHandle *mb_svc_handle)
3088 const char* account_id = "user";
3089 GList *p_list = NULL;
3091 //get a web cluster using account id.
3092 ret = minfo_get_web_cluster_by_web_account_id(mb_svc_handle, account_id, mcluster_ite_cb, &p_list);
3094 printf("minfo_get_web_cluster_by_web_account_id fail: %d \n", ret);
3102 minfo_get_web_cluster_by_web_account_id(MediaSvcHandle *mb_svc_handle, const char* web_account_id, minfo_cluster_ite_cb func, void *user_data);
3105 * minfo_get_web_cluster_web_album_id
3106 * This function gets mcluster information by web cluster id. User could get the detail information with
3107 * the type 'Mcluster' about this cluster, the type 'Mcluster' mainly include folder/cluster ID, display name,
3108 * count of included media content, etc. The detail defination of this type could refer to the herder file, minfo-cluster.h.
3110 * @return This function returns 0 on success, or negative value with error code.
3111 * @param mb_svc_handle [in] the handle of DB
3112 * @param cluster_id [in] the cluster ID which indentify a cluster
3113 * @param mcluster [out] mcluster to be returned, which is a 'Mcluster' type
3115 * @remarks User could pass cluster id to this function, so that
3116 * this function still could get the wanted cluster.
3117 * when invoking this function, *mcluster must equals NULL, and
3118 * after using mitem, it must be freed with minfo_destroy_mtype_item.
3125 #include <media-svc.h>
3127 void test_minfo_get_web_cluster_web_album_id(MediaSvcHandle *mb_svc_handle)
3130 Mcluster *mc = NULL;
3131 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
3133 //get a cluster using cluster's id.
3134 ret = minfo_get_web_cluster_web_album_id(mb_svc_handle, cluster_id, &mc);
3136 printf("minfo_get_web_cluster_web_album_id fail: %d \n", ret);
3140 minfo_destroy_mtype_item(mc);
3146 minfo_get_web_cluster_web_album_id(MediaSvcHandle *mb_svc_handle, const char *web_album_id, Mcluster **mcluster);
3149 * minfo_add_web_media
3150 * This function could add a web media to web album specified by @p cluster_id, in addition, user need to pass @p http_url, @p file_name
3151 * @p thumb_path. If failed to add it to web album, this function will return an error code.
3153 * @param[in] mb_svc_handle the handle of DB
3154 * @param[in] cluster_id specify cluster id to indentify a web album.
3155 * @param[in] http_url web media's url.
3156 * @param[in] file_name file name.
3157 * @param[in] thumb_path thumbnail full path of this web media
3158 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
3159 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
3167 #include <media-svc.h>
3169 void test_minfo_add_web_media(MediaSvcHandle *mb_svc_handle)
3171 int ret = MB_SVC_ERROR_NONE;
3172 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
3174 //add a web media to a web album.
3175 ret = minfo_add_web_media(mb_svc_handle, cluster_id, "http://user/specifying/address", "web_media", "thumbnail path");
3177 printf( "failed to add to a web album. error code->%d", ret);
3188 minfo_add_web_media(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* http_url, const char* file_name, const char* thumb_path);
3191 * minfo_add_web_media_with_type
3192 * This function could add a web media to web album specified by @p cluster_id, in addition, user need to pass @p http_url, @p file_name, @p content_type,
3193 * @p thumb_path. If failed to add it to web album, this function will return an error code.
3195 * @param[in] mb_svc_handle the handle of DB
3196 * @param[in] cluster_id specify cluster id to indentify a web album.
3197 * @param[in] http_url web media's url.
3198 * @param[in] file_name file name.
3199 * @param[in] content_type type of the media.
3200 * @param[in] thumb_path thumbnail full path of this web media
3201 * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
3202 * Please refer 'media-svc-error.h' to know the exact meaning of the error.
3210 #include <media-svc.h>
3213 void test_minfo_add_web_media_with_type(MediaSvcHandle *mb_svc_handle)
3215 int ret = MB_SVC_ERROR_NONE;
3216 const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
3218 //add a web media to a web album.
3219 ret = minfo_add_web_media_with_type(mb_svc_handle, cluster_id, "http://user/specifying/address", "web_media", MINFO_ITEM_IMAGE, "thumbnail name");
3221 printf( "failed to add to a web album. error code->%d", ret);
3232 minfo_add_web_media_with_type(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* http_url, const char* file_name, minfo_file_type content_type, const char* thumb_path);
3241 #endif /* __cplusplus */
3247 #endif /*_VISUAL_SVC_H_*/