From: HyungKyu Song Date: Fri, 15 Feb 2013 15:00:21 +0000 (+0900) Subject: Tizen 2.0 Release X-Git-Tag: submit/tizen_2.0/20130215.191521^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_2.0;p=apps%2Fcore%2Fpreloaded%2Fgallery.git Tizen 2.0 Release --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..8c5fe00 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,175 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(gallery C) + +SET(RSRC_DIR res) + +SET(EDC_DIR white_theme/edc) +SET(IMG_DIR white_theme/edc/images) +SET(SOUND_DIR white_theme/edc/sounds) +SET(IMG_EDC_DIR white_theme/images_edc) + +SET(SRCS src/gallery.c + src/features/gl-albums.c + src/features/gl-albums-edit.c + src/features/gl-albums-new.c + src/features/gl-albums-sel.c + src/features/gl-thumbs.c + src/features/gl-thumbs-edit.c + src/features/gl-thumbs-sel.c + src/features/gl-tags.c + src/features/gl-tags-edit.c + src/features/gl-tags-new.c + src/features/gl-tags-rename.c + src/features/gl-albums-rename.c + src/widget/gl-button.c + src/widget/gl-controlbar.c + src/widget/gl-editfield.c + src/widget/gl-nocontents.c + src/widget/gl-notify.c + src/widget/gl-popup.c + src/widget/gl-ctxpopup.c + src/widget/gl-progressbar.c + src/widget/gl-rotate-bg.c + src/widget/gl-tile.c + src/widget/gl-thumb.c + src/util/gl-debug.c + src/util/gl-fs.c + src/util/gl-ui-util.c + src/util/gl-ext-exec.c + src/util/gl-ext-ug-load.c + src/util/gl-util.c + src/util/gl-drm.c + src/util/gl-thread-util.c + src/util/gl-lang.c + src/util/gl-exif.c + src/data/gl-data-type.c + src/data/gl-data.c + src/data/gl-data-util.c + src/data/gl-local-data.c +) + +SET(VENDOR "tizen") +SET(PACKAGE ${PROJECT_NAME}) +SET(PKGNAME "org.${VENDOR}.gallery") +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(BINDIR "${PREFIX}/bin") +SET(RESDIR "${PREFIX}/res") +SET(DATADIR "${PREFIX}/data") +SET(LOCALEDIR "${RESDIR}/locale") +SET(ICONDIR "/usr/share/icons/default/small") +SET(EDJDIR "${RESDIR}/edje") + +IF("${CMAKE_BUILD_TYPE}" STREQUAL "") + SET(CMAKE_BUILD_TYPE "Release") +ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") +MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/data) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/util) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/widget) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/features) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED + capi-content-media-content + drm-client + ui-gadget-1 + elementary + ecore-imf + ecore-x + eina + evas + edje + vconf + ecore + ecore-file + ecore-input + dlog + glib-2.0 + gthread-2.0 + capi-appfw-application + capi-appfw-app-manager + haptic + utilX + status +) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fpie") +SET(CMAKE_C_FLAGS_RELEASE "-O2 -fpie") + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" MATCHES "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" MATCHES "arm") + +ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"") +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") +ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"") +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") +ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"") +ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") +ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"") +ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"") + +ADD_DEFINITIONS("-D_USE_DLOG_") +ADD_DEFINITIONS("-D_USE_ROTATE_BG") +ADD_DEFINITIONS("-D_RENAME_ALBUM_SENSITIVE") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") +SET(CMAKE_LDFLAGS "-Wl,-zdefs" ) + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lstdc++ ) + +ADD_CUSTOM_COMMAND(OUTPUT gallery.edj + COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/${IMG_DIR} + -sd ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/${SOUND_DIR} + ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/${EDC_DIR}/gallery.edc ${CMAKE_BINARY_DIR}/gallery.edj + DEPENDS ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/${EDC_DIR}/gallery.edc +) + +ADD_CUSTOM_COMMAND(OUTPUT gl-images.edj + COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/${IMG_EDC_DIR} + ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/${IMG_EDC_DIR}/gl-images.edc ${CMAKE_BINARY_DIR}/gl-images.edj + DEPENDS ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/${IMG_EDC_DIR}/gl-images.edc +) + +ADD_CUSTOM_TARGET(edj_build DEPENDS gallery.edj gl-images.edj) + +ADD_DEPENDENCIES(${PROJECT_NAME} edj_build) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) +INSTALL(FILES ${CMAKE_BINARY_DIR}/gallery.edj DESTINATION ${EDJDIR}) +INSTALL(FILES ${CMAKE_BINARY_DIR}/gl-images.edj DESTINATION ${EDJDIR}) + +# install manifest file & icon +INSTALL(FILES ${CMAKE_BINARY_DIR}/${PKGNAME}.xml DESTINATION /usr/share/packages) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/icon/${PKGNAME}.png DESTINATION ${ICONDIR}) + +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/white_theme/images DESTINATION ${RESDIR}) + +# install content shortcut uri file +INSTALL(FILES ${CMAKE_SOURCE_DIR}/${RSRC_DIR}/gallery.uri DESTINATION /usr/share/miregex) + +# install application HOME directory +INSTALL(DIRECTORY DESTINATION /opt/usr/apps/${PKGNAME}/data) + +# Share APP mo files with Gallery UG +SET(GALLERY_UG_PROJECT_NAME ug-gallery-efl) + +# i18n +ADD_SUBDIRECTORY(res/po) + +# UG +ADD_SUBDIRECTORY(ug/ug-gallery-efl) + diff --git a/INSTALL b/INSTALL new file mode 100755 index 0000000..3f81c54 --- /dev/null +++ b/INSTALL @@ -0,0 +1,33 @@ +1. make the build directory + + ex) + + $ mkdir build + + +2. change the working directory to the build directory + + ex) + + $ cd build + + +3. run 'cmake' + + $ cmake ${SOURCE_DIR} -DCMAKE_INSTALL_PREFIX=/opt/apps/@@PKGNAME@@ + + ex) + + $ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/apps/@@PKGNAME@@ + + or + + $ cmake .. + + +4. make & make install + + ex) + + $ make -j 2 && make install + diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100755 index 0000000..9c95663 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Compatibility Definition Document +and passes the Compatibility Test Suite as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. + +You may add Your own attribution notices within Derivative Works +that You distribute, alongside or as an addendum to the NOTICE text +from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional or +different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works +as a whole, provided Your use, reproduction, and distribution of +the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/NOTICE b/NOTICE new file mode 100755 index 0000000..0d69741 --- /dev/null +++ b/NOTICE @@ -0,0 +1,4 @@ +Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE file for Flora License terms and conditions. + diff --git a/include/data/gl-data-type.h b/include/data/gl-data-type.h new file mode 100755 index 0000000..e6d501b --- /dev/null +++ b/include/data/gl-data-type.h @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_DATA_TYPE_H_ +#define _GL_DATA_TYPE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _cplusplus +extern "C" +{ +#endif + + +#define GL_FREEIF(ptr) \ + do { \ + if(ptr != NULL) \ + { \ + free(ptr); \ + ptr = NULL; \ + } \ + } while (0) + +#define GL_FREE(ptr) \ + do { \ + free(ptr); \ + ptr = NULL; \ + } while (0) + +#define GL_TYPE_ALBUM (0x55551) +#define GL_TYPE_TAG (0x55552) +#define GL_TYPE_MEDIA (0x55553) + +typedef enum { + GL_STORE_T_PHONE = 0, /**< Stored only in phone */ + GL_STORE_T_MMC, /**< Stored only in MMC */ + GL_STORE_T_ALL, /**< Stored only in All albums album */ +} gl_store_type_e; + + +typedef struct _gl_album_t gl_album_s; +typedef struct _gl_media_t gl_media_s; +typedef struct _gl_image_t gl_image_s; +typedef struct _gl_video_t gl_video_s; +typedef struct _gl_tag_t gl_tag_s; + +struct _gl_album_t { + int gtype; /*self-defination type, when free this struct space, use it*/ + media_folder_h folder_h; /*the handle of operating this folder*/ + char *uuid; /*folder UUID*/ + char *display_name; /*album name*/ + char *path; /*the full path of this folder*/ + int type; /*storage type*/ + time_t mtime; /*modified time*/ + int count; /*the media count in this folder*/ + void *_reserved; /*reserved*/ +}; + +struct _gl_media_t { + int gtype; /*self-defination type, when free this struct space, use it*/ + media_info_h media_h; /*the handle of operating this media*/ + char *uuid; /*meida id*/ + int type; /*meida type, image or video*/ + char *thumb_url; /*the thumbnail full path of this meida file*/ + char *file_url; /*the full path of this meida file*/ + time_t mtime; /*modified time*/ + char *album_uuid; /*folder UUID*/ + char *display_name; /*item name*/ + bool favorite; /*favorite level*/ + + char *ext; + + union { + gl_image_s *image_info; /*image information*/ + gl_video_s *video_info; /*video information*/ + }; + + void *_reserved; /*reserved*/ +}; + +struct _gl_image_t { + char *media_uuid; /*media uuid*/ + image_meta_h image_h; /*the handle of operating this image*/ + int orientation; /*the orientation of this image*/ + + void *_reserved; /*reserved*/ +}; + +struct _gl_video_t { + char *media_uuid; /*media uuid*/ + video_meta_h video_h; /*the handle of operating this video*/ + char *title; /*the title of video*/ + time_t last_played_pos; /*the last played position*/ + int duration; /*the duration of this video*/ + int bookmarks; /*whether exist bookmarks*/ + + void *_reserved; /*reserved*/ +}; + +struct _gl_tag_t { + int gtype; /*self-defination type, when free this struct space, use it*/ + media_tag_h tag_h; /*the handle of operating this tag */ + int _id; /*tag id */ + char *tag_name; /*tag name */ + int count; /*the media count included into this tag*/ + + void *_reserved; /*reserved*/ +}; + +int _gl_data_type_new_tag(gl_tag_s **t_item); +int _gl_data_type_new_album(gl_album_s **album); + +int _gl_data_type_free_tag_list(Eina_List **list); +int _gl_data_type_free_glitem(void **item); + +#ifdef _cplusplus +} +#endif + + +#endif /* _GL_DATA_TYPE_H_ */ + diff --git a/include/data/gl-data-util.h b/include/data/gl-data-util.h new file mode 100755 index 0000000..6be2a17 --- /dev/null +++ b/include/data/gl-data-util.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_DATA_UTIL_H_ +#define _GL_DATA_UTIL_H_ + +#include +#include +#include +#include "gl-data.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + +bool _gl_data_util_get_file_dir_name(const char *file_path, char *filename, + char *dir_name, char *dir_path); +gl_item *_gl_data_util_calloc_gitem(void); +int _gl_data_util_free_gitem(gl_item *gitem); +gl_cluster *_gl_data_util_calloc_gcluster(void); +int _gl_data_util_free_gcluster(gl_cluster *gcluster); +gl_cluster *_gl_data_util_new_gcluster_all(void *data, int count); +gl_cluster_list *_gl_data_util_calloc_cluster_list(void); +gl_tag *_gl_data_util_calloc_gtag(void); +int _gl_data_util_free_gtag(gl_tag *gtag); +int _gl_data_util_clear_gtype_item_list(Eina_List **elist); +int _gl_data_util_clear_item_list(Eina_List **elist); +int _gl_data_util_get_selected_cluster_id_list(void *data, + Eina_List **sel_id_list); +int _gl_data_util_get_selected_item_id_list(void *data, + Eina_List **sel_id_list); +bool _gl_data_util_check_selected_id(Eina_List **sel_id_list, const char *id); +int _gl_data_util_free_selected_id_list(Eina_List **sel_id_list); +int _gl_data_util_check_album_selected_files(gl_cluster *album, int *drm_cnt, + int *img_cnt, int *sel_cnt); +int _gl_data_util_check_tag_selected_files(void *data, int *drm_cnt, + int *img_cnt, int *sel_cnt); +int _gl_data_util_free_tag_list(void *data); +gl_tag *_gl_data_util_get_favor_tag(void *data); + +#ifdef _cplusplus +} +#endif +#endif /* _GL_DATA_UTIL_H_ */ + diff --git a/include/data/gl-data.h b/include/data/gl-data.h new file mode 100755 index 0000000..1cd6d0b --- /dev/null +++ b/include/data/gl-data.h @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_DATA_H_ +#define _GL_DATA_H_ + +#include +#include +#include +#include "gl-local-data.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + +/* Specified ID for customed items, which don't exist in DB */ +#define GL_TAG_FAVORITES_ID 0 +#define GL_ALBUM_ALL_ID "GALLERY_ALBUM_ALL_ALBUMS_ID" + +#define GL_MAX_BYTES_FOR_CHAR 3 +#define GL_FILE_PATH_LEN_MAX (4095 * GL_MAX_BYTES_FOR_CHAR + 1) +#define GL_FILE_NAME_LEN_MAX (255 * GL_MAX_BYTES_FOR_CHAR + 1) +#define GL_DIR_PATH_LEN_MAX GL_FILE_PATH_LEN_MAX +#define GL_ARRAY_LEN_MAX 256 +#define GL_FILE_EXT_LEN_MAX 256 +#define GL_FIRST_VIEW_START_POS 0 +#define GL_FIRST_VIEW_END_POS 47 //27 /*maybe 2 pages(=48 medias) is better, especially select album then drag up immediately */ +#define GL_GET_UNTIL_LAST_RECORD 65536 //-1 /* Fixme: Do not use 65536. */ +#define GL_GET_ALL_RECORDS -1 +#define GL_GET_ONE_RECORDS 1 +#define GL_GET_ALL_RECORDS_ID NULL +#define GL_JPEG_FILE_EXT "jpg" + +typedef enum +{ + GL_CATEGORY_NONE, + GL_CATEGORY_FOLDER, + GL_CATEGORY_FAVORITES, + GL_CATEGORY_MAX +} gl_cate_type; + +typedef enum{ + GL_SORT_BY_NONE, /**< No Sort */ + GL_SORT_BY_NAME_DESC, /**< Sort by display name descending */ + GL_SORT_BY_NAME_ASC, /**< Sort by display name ascending */ + GL_SORT_BY_DATE_DESC, /**< Sort by modified_date descending */ + GL_SORT_BY_DATE_ASC, /**< Sort by modified_date ascending */ +} gl_sort_type_e; + +typedef struct +{ + gl_album_s *cluster; + int index; + Elm_Object_Item *item; + bool checked; + + void *ad; /* Save ad to prevent use global variable */ + void *_reserved; +} gl_cluster; + +typedef struct +{ + Eina_List *clist; + /* Editable albums count */ + int edit_cnt; +} gl_cluster_list; + +typedef enum +{ + GL_ICON_NORMAL, + GL_ICON_EXPIRED_DRM, + GL_ICON_CORRUPTED_FILE +}gl_icon_type; + +typedef struct _gl_item +{ + gl_media_s *item; + Elm_Object_Item *elm_item; + Evas_Object *check_obj; + bool checked; + int sequence; + int store_type; + void *ad; /* Save ad to prevent use global variable */ + void *_reserved; +} gl_item; + +typedef struct +{ + gl_tag_s *tag; + Elm_Object_Item *item; + Evas_Object *check_obj; + bool checked; + bool cover_set; + void *ad; /* Save ad to prevent use global variable */ + void *_reserved; +} gl_tag; + +bool _gl_data_get_cluster_list(void *data); +int _gl_data_update_cluster_list(void *data); +int _gl_data_get_cluster_by_id(void *data, const char *cluster_id, + gl_cluster **cluster); +int _gl_data_get_cluster_by_path(void *data, const char *path, + gl_cluster **cluster); +int _gl_data_get_item_cnt(void *data, const char *cluster_id, bool b_favor, + int album_type, int *item_cnt); +int _gl_data_update_item_cnt(gl_cluster *album); +int _gl_data_update_item_list(void *data); +int _gl_data_get_item_list(void *data, gl_cate_type mode, gl_cluster *album, + int start_pos, int end_pos); +bool _gl_data_is_item_cnt_zero(void *data, media_content_type_e type); +int _gl_data_get_first_item(void *data, media_content_type_e type, + gl_item **fitem, bool b_selected); +int _gl_data_clear_default_item_list(void *data); +int _gl_data_get_item_list_without_tag(void *data, gl_cluster *album, + const char *tag_name, int start_pos, + int end_pos); +int _gl_data_update_item_list_without_tag(void *data, gl_cluster *album, + const char *tag_name); +int _gl_data_get_first_several_favor_items(void *data, gl_item *items[], + int *item_count, + media_content_order_e sort_type); +int _gl_data_get_first_several_items(gl_cluster *album, gl_item *items[], + int *item_count, + media_content_order_e sort_type); +int _gl_data_destroy_item(gl_item *gitem); +int _gl_data_get_item_by_index(void *data, int idx, bool select_mode, + gl_item **gitem); +int _gl_data_get_orig_item_by_index(void *data, gl_item **gitem, int idx); +int _gl_data_item_list_remove(void *data, gl_item *gitem); +int _gl_data_remove_item(gl_item * gitem); +int _gl_data_selected_list_append(void *data, gl_item *gitem); +int _gl_data_selected_list_remove(void *data, gl_item *gitem); +gl_item *_gl_data_selected_list_get_nth(void *data, int idx); +int _gl_data_selected_list_finalize(void *data); +int _gl_data_selected_list_count(void *data); +bool _gl_data_is_albums_selected_empty(void *data); +int _gl_data_get_albums_selected_files_path_str(void *data, gchar sep_c, + char **path_str, int *sel_cnt); +int _gl_data_get_albums_selected_cnt(void *data); +int _gl_data_albums_selected_list_append(void *data, gl_cluster *item); +int _gl_data_albums_selected_list_remove(void *data, gl_cluster *item); +int _gl_data_finalize_albums_selected_list(void *data); +bool _gl_data_check_update(void *data, bool b_all); +int _gl_data_init(); +int _gl_data_finalize(void *data); +gl_cluster *_gl_data_new_cluster(void); +bool _gl_data_is_root_path(const char *path); +bool _gl_data_is_default_album(const char *match_folder, gl_album_s *album); +int _gl_data_get_tag_by_index(void *data, gl_tag **tag, int idx); +int _gl_data_get_first_several_tag_items(void *data, unsigned tag_id, + gl_item *items[], int *item_count); +bool _gl_data_is_in_tag_list(void *data, const char *tagname); +int _gl_data_get_tag_count_all(void *data); +int _gl_data_get_tag_list(void *data, Eina_List **elist); +int _gl_data_update_tag_list(void *data, Eina_List **elist); +int _gl_data_tags_list_remove(void *data, gl_tag *gtag); +int _gl_data_get_tag_by_id(void *data, int tag_id, gl_tag **gtag); +int _gl_data_get_item_list_tagname(void *data, unsigned int tag_id, + bool with_meta, Eina_List ** elist); +int _gl_data_tags_selected_list_append(void *data, gl_tag *gtag); +int _gl_data_tags_selected_list_remove(void *data, gl_tag *gtag); +int _gl_data_finalize_tags_selected_list(void *data); +int _gl_data_get_tags_selected_cnt(void *data); +bool _gl_data_is_tags_selected_empty(void *data); +int _gl_data_get_tags_selected_files_path_str(void *data, gchar sep_c, + char **path_str, int *sel_cnt); +int _gl_data_delete_media(void *data, gl_media_s *media_item); +int _gl_data_create_thumb(gl_item *gitem, media_thumbnail_completed_cb callback, + void *user_data); + +#ifdef _cplusplus +} +#endif +#endif /* _GL_DATA_H_ */ diff --git a/include/data/gl-local-data.h b/include/data/gl-local-data.h new file mode 100755 index 0000000..58e36bf --- /dev/null +++ b/include/data/gl-local-data.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_LOCAL_DATA_H_ +#define _GL_LOCAL_DATA_H_ + +#include "gl-data-type.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + + +/*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music*/ +#define GL_CONDITION_IMAGE_VIDEO "(MEDIA_TYPE=0 OR MEDIA_TYPE=1)" +#define GL_CONDITION_WITHOUT_TAG "((MEDIA_TYPE=0 OR MEDIA_TYPE=1) AND (media_uuid NOT IN (SELECT media_uuid FROM tag_map WHERE tag_id=%d)))" +#define GL_CONDITION_WITHOUT_FAVOURITE "((MEDIA_TYPE=0 OR MEDIA_TYPE=1) AND (FAVOURITE=0))" +#define GL_CONDITION_IMAGE "(MEDIA_TYPE=0)" +#define GL_CONDITION_VIDEO "(MEDIA_TYPE=1)" +#define GL_CONDITION_TAG_NAME "(TAG_NAME=\'%s\')" +/**< 0-not favourite, 1-favourite*/ +#define GL_CONDITION_FAV_IMAGE_VIDEO "((MEDIA_TYPE=0 OR MEDIA_TYPE=1) AND MEDIA_FAVORITE=1)" +#define GL_CONDITION_TAG NULL + + +#define CONDITION_LENGTH 200 +#define KEYWORD_LENGTH 20 + +typedef struct _gl_filter_t gl_filter_s; + +struct _gl_filter_t { + char cond[CONDITION_LENGTH]; /*set media type or favorite type, or other query statement*/ + media_content_collation_e collate_type; /*collate type*/ + media_content_order_e sort_type; /*sort type*/ + char sort_keyword[KEYWORD_LENGTH]; /*sort keyword*/ + int offset; /*offset*/ + int count; /*count*/ + bool with_meta; /*whether get image or video info*/ +}; + +int _gl_local_data_connect(void); +int _gl_local_data_disconnect(void); +int _gl_local_data_get_album_by_path(char *path, gl_album_s **album); +int _gl_local_data_get_album_list(gl_filter_s *condition, Eina_List **elist); +int _gl_local_data_get_media_by_path(const char *path, gl_media_s **mitem); +int _gl_local_data_get_media_count(const char *cluster_id, gl_filter_s *condition, + int *item_cnt); +int _gl_local_data_get_all_media_count(gl_filter_s *filter, int *item_cnt); +int _gl_local_data_get_album_media_list(gl_filter_s *condition, + const char *album_id, Eina_List **elist); +int _gl_local_data_get_all_albums_media_list(gl_filter_s *condition, + Eina_List **elist); +int _gl_local_data_get_album_media_list_without_tag(gl_filter_s *condition, + const char *album_id, + const char *tag_name, + Eina_List **elist); +int _gl_local_data_get_media_count_wichout_tag(int tag_id, char *album_uuid); +int _gl_local_data_get_all_albums_media_list_without_tag(gl_filter_s *condition, + const char *tag_name, + Eina_List **elist); +int _gl_local_data_get_tag_list(gl_filter_s *condition, Eina_List **elist); +int _gl_local_data_get_tag_list_by_media_id(gl_filter_s *condition, + const char *media_id, + Eina_List **elist); +int _gl_local_data_get_tag_media_count(int tag_id, gl_filter_s *condtion, + int *item_cnt); +int _gl_local_data_get_tag_media_list(unsigned int tag_id, + gl_filter_s *condition, + Eina_List **elist); +int _gl_local_data_add_tag(const char *tagname, const char *media_uuid); +int _gl_local_data_delete_tag(gl_tag_s *tag); +int _gl_local_data_remove_tag(gl_tag_s *tag, const char *media_uuid); +int _gl_local_data_set_favorite(gl_media_s *item, bool favor); +int _gl_local_data_delete_album(const char *album_uuid); +int _gl_local_data_add_media(const char *file_url, media_info_h *info); +int _gl_local_data_get_thumb(gl_media_s *mitem, char **thumb); +int _gl_local_data_move_media(gl_media_s *mitem, const char *dst); + +#ifdef _cplusplus +} +#endif + + +#endif + diff --git a/include/features/gl-albums-edit.h b/include/features/gl-albums-edit.h new file mode 100755 index 0000000..ca3ebf6 --- /dev/null +++ b/include/features/gl-albums-edit.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_ALBUMS_EDIT_H_ +#define _GL_ALBUMS_EDIT_H_ + +#include +#include "gallery.h" + +int _gl_albums_edit_create_view(void *data); +int _gl_albums_edit_update_view(void *data); +int _gl_albums_edit_pop_view(void *data); +int _gl_albums_edit_share(void *data, const char *label); +int _gl_albums_edit_update_lang(void *data); + +#endif + diff --git a/include/features/gl-albums-new.h b/include/features/gl-albums-new.h new file mode 100755 index 0000000..f33629c --- /dev/null +++ b/include/features/gl-albums-new.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_ALBUMS_NEW_H_ +#define _GL_ALBUMS_NEW_H_ + +#include +#include "gallery.h" + +int _gl_albums_new_create_view(void *data); +int _gl_albums_new_pop_view(void *data); +int _gl_albums_new_process(void *data, bool b_enter); + +#endif + diff --git a/include/features/gl-albums-rename.h b/include/features/gl-albums-rename.h new file mode 100755 index 0000000..7f8254e --- /dev/null +++ b/include/features/gl-albums-rename.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _GL_ALBUMS_RENAME_H_ +#define _GL_ALBUMS_RENAME_H_ + +#include +#include "gallery.h" + +int _gl_albums_rename_create_view(void *data, gl_cluster *album); +int _gl_albums_rename_update_view(void *data); +int _gl_albums_rename_pop_view(void *data); +int _gl_albums_rename_process(void *data, bool b_enter); +int _gl_albums_rename_update_lang(void *data); + +#endif + diff --git a/include/features/gl-albums-sel.h b/include/features/gl-albums-sel.h new file mode 100755 index 0000000..9366a33 --- /dev/null +++ b/include/features/gl-albums-sel.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_ALBUMS_SEL_H_ +#define _GL_ALBUMS_SEL_H_ + +#include +#include "gallery.h" + +int _gl_albums_sel_create_view(void *data); +int _gl_albums_sel_update_view(void *data); +int _gl_albums_sel_pop_view(void *data); +int _gl_albums_sel_update_lang(void *data); + +#endif + diff --git a/include/features/gl-albums.h b/include/features/gl-albums.h new file mode 100755 index 0000000..9c04a15 --- /dev/null +++ b/include/features/gl-albums.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_ALBUMS_H_ +#define _GL_ALBUMS_H_ + +#include +#include "gallery.h" + +Evas_Object *_gl_albums_add_gengrid(void *data, Evas_Object *parent); +Evas_Object *gl_albums_create_view(void *data, Evas_Object * parent); +int gl_albums_update_view(void *data); +int _gl_albums_create_items(void *data, Evas_Object *parent); +int gl_albums_sel_album(gl_cluster * album_item); +int gl_albums_update_items(void *data); +int gl_albums_comeback_from_view(void *data); +int gl_albums_change_to_view(void *data); +int gl_albums_remove_nocontents(void *data); +int gl_albums_free_cover_thumbs(void *data); +int gl_albums_free_data(void *data); +int _gl_albums_reset_view(void *data, const char *uuid, const char *aul_type); + +#endif /* _GL_ALBUMS_H_ */ diff --git a/include/features/gl-tags-edit.h b/include/features/gl-tags-edit.h new file mode 100755 index 0000000..468c0ee --- /dev/null +++ b/include/features/gl-tags-edit.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_TAGS_EDIT_H_ +#define _GL_TAGS_EDIT_H_ + +#include +#include "gallery.h" + +int _gl_tags_edit_create_view(void *data); +int _gl_tags_edit_pop_view(void *data); +int _gl_tags_edit_share(void *data, const char *label); +int _gl_tags_edit_update_lang(void *data); + +#endif + diff --git a/include/features/gl-tags-new.h b/include/features/gl-tags-new.h new file mode 100755 index 0000000..bf9a5f8 --- /dev/null +++ b/include/features/gl-tags-new.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_TAGS_NEW_H_ +#define _GL_TAGS_NEW_H_ + +#include +#include "gallery.h" + +int _gl_tags_new_create_view(void *data); +int _gl_tags_new_pop_view(void *data); +int _gl_tags_new_process(void *data, bool b_enter); + +#endif + diff --git a/include/features/gl-tags-rename.h b/include/features/gl-tags-rename.h new file mode 100755 index 0000000..7f5fead --- /dev/null +++ b/include/features/gl-tags-rename.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_TAGS_RENAME_H_ +#define _GL_TAGS_RENAME_H_ + +#include +#include "gallery.h" + +int _gl_tags_rename_create_view(void *data, gl_tag *gtag); +int _gl_tags_rename_process(void *data); + +#endif + diff --git a/include/features/gl-tags.h b/include/features/gl-tags.h new file mode 100755 index 0000000..95908aa --- /dev/null +++ b/include/features/gl-tags.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_TAGS_H_ +#define _GL_TAGS_H_ + +#include +#include "gallery.h" + +int _gl_tags_add_btns(void *data); +int gl_tag_unset_rename(void *data); +Evas_Object *gl_tag_create_view(void *data, Evas_Object * parent); +int gl_tag_update_view(void *data); +int gl_tag_update_realized_view(void *data); +int _gl_tag_comeback_from_view(void *data); +bool _gl_tags_sel_home_tag(void *data, const char *tag_id); +int _gl_tags_reset_view(void *data, const char *tag_id, const char *aul_type); +const char *_gl_tags_get_current_tag_name(void *data); +int _gl_tags_del(void *data); +int _gl_tags_update_lang(void *data); + +#endif /* _GL_TAGS_H_ */ diff --git a/include/features/gl-thumbs-edit.h b/include/features/gl-thumbs-edit.h new file mode 100755 index 0000000..c0a0b31 --- /dev/null +++ b/include/features/gl-thumbs-edit.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_THUMB_EDIT_H_ +#define _GL_THUMB_EDIT_H_ + +#include +#include "gallery.h" + +int _gl_thumbs_edit_add_btns(void *data, Evas_Object *parent, + Elm_Object_Item *nf_it); +int _gl_thumbs_edit_create_view(void *data); +int _gl_thumbs_edit_pop_view(void *data); +int _gl_thumbs_edit_update_lang(void *data); + +#endif + diff --git a/include/features/gl-thumbs-sel.h b/include/features/gl-thumbs-sel.h new file mode 100755 index 0000000..92fa683 --- /dev/null +++ b/include/features/gl-thumbs-sel.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_THUMB_SEL_H_ +#define _GL_THUMB_SEL_H_ + +#include +#include "gallery.h" + +int _gl_thumbs_sel_create_view(void *data, gl_cluster *album_item); +int _gl_thumbs_sel_pop_view(void *data); +int _gl_thumbs_sel_update_lang(void *data); + +#endif + diff --git a/include/features/gl-thumbs.h b/include/features/gl-thumbs.h new file mode 100755 index 0000000..aa9b6c4 --- /dev/null +++ b/include/features/gl-thumbs.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_GRIDVIEW_H_ +#define _GL_GRIDVIEW_H_ + +#include +#include "gallery.h" + + +typedef enum _gl_thumb_mode { + GL_THUMB_ALL, + GL_THUMB_IMAGES, + GL_THUMB_VIDEOS, + GL_THUMB_ALBUMS, +} gl_thumb_mode; + +void _gl_thumbs_mouse_down(void *data, Evas *e, Evas_Object *obj, + void *event_info); +void _gl_thumbs_mouse_up(void *data, Evas *e, Evas_Object *obj, + void *event_info); +Evas_Object *_gl_thumbs_add_grid(void *data, Evas_Object *parent, + gl_thumb_mode mode, bool b_use_idler); +int _gl_thumbs_show_edit_view(void *data); +int _gl_thumbs_show_view(void *data); +Eina_Bool _gl_thumbs_update_view(void *data); +int _gl_thumbs_create_view(void *data, int nf_mode, char *title, bool b_idler, + Evas_Smart_Cb func); +int _gl_thumbs_update_count(void *data, int new_cnt); +bool _gl_thumbs_get_view(void *data, Evas_Object **view); +int _gl_thumbs_set_nocontents(void *data, Evas_Object *noc); +int _gl_thumbs_set_size(void *data, Evas_Object *gridview); +int _gl_thumbs_clear_cbs(Evas_Object *grid); +int _gl_thumbs_delete_view(void *data); +int _gl_thumbs_update_size(void *data, Evas_Object *view); +int _gl_thumbs_del_append_idler(void *data); + +#endif /* _GL_GRIDVIEW_H_ */ + diff --git a/include/gallery.h b/include/gallery.h new file mode 100755 index 0000000..f504715 --- /dev/null +++ b/include/gallery.h @@ -0,0 +1,500 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GALLERY_H_ +#define _GALLERY_H_ + +#include +#include +#include +#include +#include +#include "gl-data.h" +#include + +#ifdef _cplusplus +extern "C" +{ +#endif + +#if !defined(APPDIR) +# define APPDIR "/usr/apps/org.tizen.gallery" +#endif + +#if !defined(PACKAGE) +# define PACKAGE "gallery" +#endif + +#if !defined(LOCALEDIR) +# define LOCALEDIR APPDIR"/res/locale" +#endif + +#if !defined(EDJDIR) +# define EDJDIR APPDIR"/res/edje" +#endif + +#if !defined(IMAGEDIR) +# define IMAGEDIR APPDIR"/res/images/" +#endif + +#define PKGNAME_GALLERY "org.tizen.gallery" + +/******** EDJ File path ********/ + +#define GL_EDJ_FILE EDJDIR "/" PACKAGE ".edj" + +/******** Groups name ********/ + +#define GL_GRP_CONTROLBAR "gallery/controlbar" +#define GL_GRP_CONTROLBAR_LY "gallery/controlbar_layout" +#define GL_GRP_PHOTOFRAME "photoframe" + +/******* Part name ***********/ + +#define GL_NAVIFRAME_PREV_BTN "prev_btn" +#define GL_NAVIFRAME_TITLE_PREV_BTN "title_prev_btn" +#define GL_NAVIFRAME_TITLE_RIGHT_BTN "title_right_btn" +#define GL_NAVIFRAME_TITLE_BTN1 "title_toolbar_button1" + +#define GL_NAVIFRAME_BTN1 "toolbar_button1" +#define GL_NAVIFRAME_BTN2 "toolbar_button2" +#define GL_NAVIFRAME_MORE "toolbar_more_btn" + + +#define GL_POPUP_TEXT "title,text" +#define GL_NOCONTENTS_TEXT "elm.text" +#define GL_GRID_TEXT "elm.text" + +#define GL_IMF_ON "virtualkeypad,state,on" +#define GL_IMF_OFF "virtualkeypad,state,off" + +/******** Style name ********/ + +#define GL_CLASS_GENGRID "gengrid" +#define GL_BUTTON_STYLE_RENAME "rename" +#define GL_BUTTON_STYLE_NAVI_MORE "naviframe/more/default" +#define GL_BUTTON_STYLE_NAVI_TITLE "naviframe/title/default" +#define GL_BUTTON_STYLE_NAVI_TITLE_PLUS "naviframe/title/icon/plus" +/* TMP: use Done to replace Edit */ +#define GL_BUTTON_STYLE_NAVI_TOOLBAR "naviframe/toolbar/default" +#define GL_BUTTON_STYLE_NAVI_MORE "naviframe/more/default" +#define GL_BUTTON_STYLE_NAVI_TOOLBAR_LEFT "naviframe/toolbar/left" +#define GL_BUTTON_STYLE_NAVI_TOOLBAR_RIGHT "naviframe/toolbar/right" + +#define GL_BUTTON_STYLE_SWEEP "sweep" +#define GL_BUTTON_STYLE_SWEEP_DELETE "sweep/delete" +/* Button object style of previous button of naviframe */ +#define GL_BUTTON_STYLE_NAVI_PRE "naviframe/back_btn/default" + +#define GL_CHECKBOX_STYLE_GRID "gallery/grid" +#define GL_CHECKBOX_STYLE_DEFAULT "gallery/default" +#define GL_GENLIST_STYLE_DEFAULT GL_CHECKBOX_STYLE_DEFAULT + +#define GL_GENLIST_ITEM_STYLE_SWEEP2_TAG "mode/gallery/slide2_tag" + +#define GL_NF_ANI_TABBAR "tabbar" + +/******** String ********/ + +#define GL_SEPERATOR_BT '?' +/* MIME type */ +#define GL_MIME_IMAGE_ALL "image/*" +#define GL_MIME_VIDEO_ALL "video/*" +/* For local album */ +#define GL_AUL_ALBUM "album" +#define GL_AUL_TAG "tag" +/*From live-gallery opening album tab request*/ +#define GL_ALBUM_UUID_DEFAULT "default" + +/******** Numerical value ********/ + +/* Window width and height */ +#define GL_WIN_WIDTH 720 +#define GL_WIN_HEIGHT 1280 + +#define GL_ALBUM_COVER_THUMB_NUM 1 +/* Normal albums cover have maximum 4 thumbnails */ +#define GL_ALBUM_COVER_THUMB_NUM_SEC 4 + +/* Size of thumbnails in gridview */ +#define GL_GRID_ITEM_SIZE_W 178 +#define GL_GRID_ITEM_SIZE_H 193 +/* Thumbnail would be enlarged if medias count is less than 7 */ +#define GL_GRID_ITEM_ZOOM_LEVEL_02 2 +#define GL_GRID_ITEM_ZOOM_LEVEL_02_CNT 6 + +/* String length of mtye item id */ +#define GL_MTYPE_ITEN_ID_LEN_MAX 37 + +/* String length of album name */ +#define GL_ALBUM_NAME_LEN_MAX GL_FILE_NAME_LEN_MAX + +#define GL_DATE_INFO_LEN_MAX 256 +#define GL_POPUP_DESC_LEN_MAX 256 +#define GL_EXT_STR_COUNT_LEN 20 + +/* Maximum number of entry string, 255 Chars of album name (linux system) */ +#define GL_ENTRY_STR_CHAR_MAX 255 +/* Maximum length of entry string, 255 Bytes of tag name */ +#define GL_ENTRY_STR_LEN_MAX (GL_ARRAY_LEN_MAX - 1) + +/* 1s=1000ms */ +#define GL_TIME_MSEC_PER_SEC 1000 +/*1s = 1000000us*/ +#define GL_TIME_USEC_PER_SEC 1000000L +/* 1ms=1000us */ +#define GL_TIME_USEC_PER_MSEC 1000 +/* 1min=60s */ +#define GL_TIME_SEC_PER_MIN 60 +/* 1h=60min */ +#define GL_TIME_MIN_PER_HOUR 60 +/* 1h=(60x60)s */ +#define GL_TIME_SEC_PER_HOUR (GL_TIME_MIN_PER_HOUR * GL_TIME_SEC_PER_MIN) + +/* itoa length max ----> 1(sign) + 10(2^31) + 1(NULL) */ +#define GL_INTERGER_LEN_MAX 12 + +#define GL_ERROR_BUF_LEN 1024 + +/* File system related String definition */ +#define GL_ROOT_PATH_PHONE "/opt/usr/media" +#define GL_ROOT_PATH_MMC "/opt/storage/sdcard" +#define GL_DEFAULT_PATH_IMAGES "/Images and videos" +#define GL_DATA_FOLDER_PATH "/opt/usr/apps/"PKGNAME_GALLERY"/data" + +#define GL_NAVIFRAME_OBJ_DATA_KEY "gl_naviframe_data_key" + +/******** Enumeration ********/ + +typedef enum _gl_aul_launch_type +{ + GL_AUL_T_NONE, + GL_AUL_T_SELECT_ONE, + GL_AUL_T_SELECT_MULTIPLE, + GL_AUL_T_SELECT_SETAS, + GL_AUL_T_SELECT_ALBUM, + GL_AUL_T_VIEW_ALBUM, +} gl_aul_launch_type; + +typedef enum { + GL_AUL_SETAS_T_NONE, + GL_AUL_SETAS_T_WALLPAPER, + GL_AUL_SETAS_T_CROP_WALLPAPER, + GL_AUL_SETAS_T_CALLER_ID, +} gl_aul_setas_type; + +typedef enum _gl_aul_file_type +{ + GL_AUL_FILE_T_NONE, + GL_AUL_FILE_T_IMAGE, + GL_AUL_FILE_T_VIDEO, + GL_AUL_FILE_T_ALL, +} gl_aul_file_type; + +typedef enum _gl_view_mode +{ + GL_VIEW_NONE, + GL_VIEW_ALBUMS, + GL_VIEW_ALBUMS_EDIT, + GL_VIEW_ALBUMS_RENAME, + GL_VIEW_ALBUMS_SELECT, + GL_VIEW_TAGS, + GL_VIEW_TAGS_EDIT, + GL_VIEW_THUMBS, + GL_VIEW_THUMBS_EDIT, + GL_VIEW_THUMBS_SELECT, +} gl_view_mode; + +typedef enum _gl_app_exit_mode +{ + GL_APP_EXIT_NONE, + GL_APP_EXIT_MASS_STORAGE, +} gl_app_exit_mode; + +typedef enum _gl_entry_mode +{ + GL_ENTRY_NONE, + GL_ENTRY_NEW_ALBUM, + GL_ENTRY_RENAME_ALBUM, + GL_ENTRY_NEW_TAG, + GL_ENTRY_RENAME_TAG, +} gl_entry_mode; + +/* Grid view created for different thumbnails view types */ +typedef enum _gl_gird_t gl_grid_t_e; +enum _gl_gird_t { + GL_GRID_T_NONE, + GL_GRID_T_LOCAL, + GL_GRID_T_ALLALBUMS, + GL_GRID_T_TAGS, +}; + +/******** Structure ********/ + +typedef struct +{ + Evas_Object *ctrlbar_ly; + Evas_Object *ctrlbar_edit_view; + Evas_Object *ctrlbar_edit_ly; + Evas_Object *ctrlbar; + /* Layout of albums view/tags view */ + Evas_Object *ctrlbar_view_ly; + /* Naviframe item pushed to stack */ + Elm_Object_Item *nf_it; + Elm_Object_Item *nf_it_edit; + int tab_mode; /* State of controlbar item: Albums, Tags */ + int rotate_mode; /* Save rotation mode of normal view */ +} gl_ctrl_info; + +typedef struct +{ + Elm_Genlist_Item_Class taglic; /* Genlist item class of tags list view */ + /* Genlist item class of tags list view for sweep */ + Elm_Genlist_Item_Class sweeplic; + Evas_Object *tags_view; /* Tags view object */ + Evas_Object *conformant; + /* Edit item state */ + bool b_edit_disable; + Elm_Object_Item *rename_item; /* Save genlist item in rename mode */ + Eina_List *tags_elist; /* List of all tags */ + Eina_List *selected_tags_elist; /* List of all selected tags */ + int tags_cnt; /* Media items count append to listview */ + gl_tag *current_tag; /* 1. Select tag to show medias */ + /* 2. Select tag for rename */ + + /* Tag_name of selected tag or newly created one */ + char new_tag_name[GL_ALBUM_NAME_LEN_MAX]; + /*True: it's favourites tag */ + bool b_favor_tag; +} gl_tag_info; + +typedef struct +{ + Evas_Coord x; + Evas_Coord y; + bool b_pressed; +} gl_grid_touch_info; + +typedef struct +{ + Elm_Gengrid_Item_Class thumbgic; /* Gengrid item class of thumbnails view */ + Evas_Object *navi_content_edit_view; + Evas_Object *navi_content_edit_ly; + Evas_Object *navi_content_ly; + /* Thumbnail selection view for Add tag to photo */ + Evas_Object *select_view; + Evas_Object *select_view_ly; + Evas_Object *all_grid_view; + Evas_Object *all_grid_nocontents; + bool b_slideshow_disable; + Evas_Object *slideshow_btn; + /* Edit */ + Evas_Object *edit_btn; + /* Naviframe item pushed to stack */ + Elm_Object_Item *nf_it; + Elm_Object_Item *nf_it_edit; + Elm_Object_Item *nf_it_select; + gl_grid_touch_info grid_touch_info; /* Added for shrink effect while select thumbnail */ + /* It's thumbnails icon size, not grid item size */ + int icon_size; + Ecore_Idler *grid_append_idler; /* Use idler to append other medias to gridview */ + /* if album contains more than (GL_FIRST_VIEW_END_POS+1) medias */ + /* 1. Indicate view mode(All/Images/Videos) of thumbnails view */ + /* 2. Set types for creating nocontents view */ + int view_mode; + int thumbs_cnt; /* Media items count appended to gridview */ + int updated_thumbs_cnt; /* Media items count appended to gridview while refreshing */ + bool back_to_normal; /* When back from edit mode, reset checkbox state */ + + gl_grid_t_e grid_type; +} gl_grid_info; + +typedef struct +{ + bool app_called_by_me; /* Indicates if any application invoked by Gallery */ + ui_gadget_h ug_called_by_me; + int ug_type; + int iv_type; + void *ug_login_data; + int sort_type; /* Types: wminfo_media_sort_type; pass it to imageviewer */ + ui_gadget_h gallery_ug_called_by_me; /* The gallery-ug called by Gallery for appcontrol */ +} gl_ug_info; + +typedef struct +{ + Elm_Gengrid_Item_Class albumgic; /* Gengrid item class of albums view */ + Evas_Object *albums_view; /* Albums view object */ + Evas_Object *albums_nocontents; /* Nocontents object */ + /* Albums view object for Add tag to photo */ + Evas_Object *select_view; + /* Albums view layout object for Add tag to photo */ + Evas_Object *select_view_ly; + + /* Edit item state */ + bool b_edit_disable; + gl_item *cover_thumbs[GL_ALBUM_COVER_THUMB_NUM]; /* Media items of album cover */ + gl_cluster *current_album; /* Album selected for showing thumbnails view/list view */ + /* Album selected for rename/open locked album */ + gl_cluster *selected_album; + /* Save destination album id while move/save */ + char *path; + char new_album_name[GL_ALBUM_NAME_LEN_MAX]; + Eina_List *selected_albums_elist; /* List of all selected albums */ + gl_cluster_list *cluster_list; /* List of all albums */ + int albums_cnt; /* Albums count appended to gridview */ + int album_medias_cnt; /* Media items count of a album, it is showed in album cover */ + bool update_albums_list; /* Flag indicate to update albums list when back to normal view. */ + /* 1. MMC Inserted/Removed in thumbnails edit mode; */ + char dest_folder[GL_DIR_PATH_LEN_MAX]; /* The full path of destination album of movement */ + bool move_new_album; /* True: move medias to album newly created, */ + /* False: move to album already created */ + /* Variables below are related to gallery launching */ + service_h recv_service; /* The service received when app_reset */ + bool gallery_launched; + /* Launching from shotcut(album added to home) */ + bool aul_launch_by_mime; + int aul_launch_type; + int aul_file_type; + int aul_setas_type; + bool b_show_drm; + char *aul_id; + char *aul_type; + char* aul_homescreen_path; + char* aul_lockscreen_path; + char* aul_callid_size; + char* aul_callid_path; + + Ecore_Idler *create_albums_idler; /* Use idler to append albums to albums view */ + /* Use idler to activate window when launching Gallery UG */ + Ecore_Idler *activate_win_idler; + Elm_Object_Item *nf_it_select; +} gl_album_info; + +typedef struct +{ + Evas_Object *editfield; + Evas_Object *imf_entry; + Ecore_IMF_Context *imf_context; + + /* Type: gl_entry_mode; Indicate usage of entry */ + int entry_mode; + /* Button 'Done' in new album/tag view */ + Evas_Object *done_btn; + Elm_Object_Item *nf_it; + /* Handle for play vibration */ + int haptic_handle; + /* Timer for closing vibration */ + Ecore_Timer *vibration_timer; + haptic_device_h *device_handle; + haptic_effect_h *effect_handle; +} gl_entry_info; + +typedef struct +{ + Elm_Genlist_Item_Class popuplit; /* Genlist item class of list view in popupinfo.popup */ + Evas_Object *popup; + int popup_mode; + /* Selectioninfo popup layout */ + Evas_Object *selinfo_ly; + Ecore_Timer *del_timer; +} gl_popup_info; + +typedef struct { + Eina_List *medias_elist; /* List of all selected medias of a album/tag/marker */ + int images_cnt; /* Images count selected */ + int drms_cnt; /* DRM files count selected */ + int jpeg_cnt; /* JEPG files count selected */ + /* All media count */ + int sel_cnt; + /* Timer for adding frequency when clicking select-all */ + Ecore_Timer *selall_timer; + /* Checkbox state of select-all */ + Eina_Bool ck_state; +} gl_selected_info; + +typedef struct { + Evas_Object *pbar_popup; + Evas_Object *pbar; + Evas_Object *status_label; + /** + * After progressbar showed completely, use timer to + * emit next signal to write pipe to continue to operate medias. + */ + Ecore_Timer *start_thread_timer; + /** + * After thread operation done, use idler to + * delete progressbar after it's showed completely(status is 100%). + */ + Ecore_Idler *del_pbar_idler; + Ecore_Pipe *sync_pipe; /* Pipe for communication between main and child thread */ + pthread_mutex_t pbar_lock; /* Lock for state of 'Cancel' button */ + pthread_mutex_t refresh_lock; /* Lock for progressbar refreshing */ + pthread_cond_t refresh_cond; /* Condition for progressbar refreshing */ + int refresh_flag; /* Indicates progressbar updated or not while moving or deleting */ + int pbar_cancel; /* State of 'Cancel' button on progressbar popup */ + /* Medias count already operated */ + int finished_cnt; +} gl_pbar_info; + +typedef struct +{ + Evas_Object *win; + double win_scale; + Evas_Object *main_layout; + Evas_Object *naviframe; + Evas_Object *bg; + Evas_Object *ctxpopup; + int rotate_mode; /* Type: appcore_rm; Indicate rotation mode of whole application */ + int view_mode; /* Type: gl_view_mode; Indicate view mode of whole application */ + bool reentrant; + /* Mouse down event handle */ + Ecore_Event_Handler *keydown_handler; + /* Font type change event handle */ + Ecore_Event_Handler *font_handler; + int all_medias_cnt; + time_t last_mtime; + Eina_List *medias_elist; /* List of all medias of a album/tag/marker */ + int medias_cnt; /* Count of all medias of a album/tag/marker */ + int medias_op_type; /* Type: Move or Delete medias */ + int mmc_state; /* MMC state(Inserted, Removed) */ + Ecore_Job *rename_album_job; + bool home_key; +} gl_main_info; + +struct _gl_appdata +{ + gl_main_info maininfo; + gl_ctrl_info ctrlinfo; /* Global variables about controlbar */ + gl_album_info albuminfo; /* Global variables about albums view */ + gl_tag_info taginfo; /* Global variables about tags view */ + gl_grid_info gridinfo; /* Global variables about thumbnails view */ + gl_entry_info entryinfo; /* Global variables about entry */ + gl_popup_info popupinfo; /* Global variables about popup */ + gl_pbar_info pbarinfo; /* Global variables about progressbar */ + gl_ug_info uginfo; /* Global variables about ug */ + gl_selected_info selectedinfo; /* Global variables about files selected */ +}; + +typedef struct _gl_appdata gl_appdata; + +int gallery_reset_app(void *data); +void _gallery_rotation_cb(app_device_orientation_e m, void *data); + +#ifdef _cplusplus +} +#endif + +#endif /* _GALLERY_H_ */ diff --git a/include/util/gl-debug.h b/include/util/gl-debug.h new file mode 100755 index 0000000..db134cf --- /dev/null +++ b/include/util/gl-debug.h @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_DEBUG_H_ +#define _GL_DEBUG_H_ + +#include +#include +#include + +#ifdef _cplusplus +extern "C" +{ +#endif + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + + +#define LOG_TAG "GALLERY" +#define LOG_TAG_LAUNCH "GALLERY_LAUNCH" + +/* anci c color type */ +#define FONT_COLOR_RESET "\033[0m" +#define FONT_COLOR_RED "\033[31m" +#define FONT_COLOR_GREEN "\033[32m" +#define FONT_COLOR_YELLOW "\033[33m" +#define FONT_COLOR_BLUE "\033[34m" +#define FONT_COLOR_PURPLE "\033[35m" +#define FONT_COLOR_CYAN "\033[36m" +#define FONT_COLOR_GRAY "\033[37m" + +#ifdef _USE_LOG_FILE_ +FILE *g_log_fp; +#endif // _USE_LOG_FILE_ + +#ifdef _USE_LOG_FILE_ + +#define gl_dbg(fmt,arg...) fprintf(g_log_fp, "[%s: %d]" fmt "\n", __FUNCTION__, __LINE__, ##arg) + +#elif defined _USE_DLOG_ + +#define gl_dbg(fmt, arg...) LOGD("[%s : %d] " fmt "\n", __FUNCTION__, __LINE__, ##arg) +#define gl_dbgW(fmt, arg...) LOGW(FONT_COLOR_GREEN"[%s : %d] " fmt "\n"FONT_COLOR_RESET, __FUNCTION__, __LINE__, ##arg) +#define gl_dbgE(fmt, arg...) LOGE(FONT_COLOR_RED"[%s : %d] " fmt "\n"FONT_COLOR_RESET, __FUNCTION__, __LINE__, ##arg) + +typedef struct { + const char *fname; + int nline; + const char *szcategory; +} debug_msg_type; + +void _custom_debug_msg(debug_msg_type *debug_msg, const char *msg, ...); + +#define __LAUNCH_TEST_LOG(szCat, ...) \ + do { \ + if (1) \ + { \ + static debug_msg_type msg______unique______name___ = { \ + __FILE__, \ + __LINE__, \ + szCat, \ + }; \ + _custom_debug_msg(&msg______unique______name___, ##__VA_ARGS__); \ + } \ + } while(0) + +#define gl_dbg_launch(...) __LAUNCH_TEST_LOG(LOG_TAG_LAUNCH, ##__VA_ARGS__) + + +#elif defined _USE_LOG_CONSOLE_ + +#define gl_dbg(fmt,arg...) fprintf(stdout, "[%s: %d]" fmt "\n", __FUNCTION__, __LINE__, ##arg) +#define gl_dbgW(fmt, arg...) fprintf(stdout, "[%s : %d] " fmt "\n", __FUNCTION__, __LINE__, ##arg) +#define gl_dbgE(fmt, arg...) fprintf(stdout, "[%s : %d] " fmt "\n", __FUNCTION__, __LINE__, ##arg) + +#else + +#define gl_dbg(fmt,arg...) +#define gl_dbgW(fmt, arg...) +#define gl_dbgE(fmt, arg...) +#endif + +//void gl_init_debug_handler (const char *appname); +//void gl_close_debug_handler(); + +#include +#include + +//long gl_get_debug_time(void); +//void gl_reset_debug_time(void); +//void gl_print_debug_time(char* time_string); +void gl_print_debug_time_ex(long start, long end, const char *func_name, char *time_string); + + + +#define gl_retm_if(expr, fmt, arg...) do { \ + if(expr) { \ + gl_dbgE(fmt, ##arg); \ + gl_dbgE("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ +} while (0) + +#define gl_retvm_if(expr, val, fmt, arg...) do { \ + if(expr) { \ + gl_dbgE(fmt, ##arg); \ + gl_dbgE("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ +} while (0) + +#define GL_CHECK_EXCEP(expr) do { \ + if(!(expr)) { \ + gl_dbgE("Critical ERROR ########################################## Check below item.");\ + goto gl_exception;\ + } \ +} while (0) + +#define GL_CHECK_VAL(expr, val) gl_retvm_if(!(expr), val, "Invalid parameter, return ERROR code!") +#define GL_CHECK_NULL(expr) gl_retvm_if(!(expr), NULL, "Invalid parameter, return NULL!") +#define GL_CHECK_FALSE(expr) gl_retvm_if(!(expr), false, "Invalid parameter, return FALSE!") +#define GL_CHECK_CANCEL(expr) gl_retvm_if(!(expr), ECORE_CALLBACK_CANCEL, "Invalid parameter, return ECORE_CALLBACK_CANCEL!") +#define GL_CHECK(expr) gl_retm_if(!(expr), "Invalid parameter, return!") + +#define gl_assert(expr) do { \ + if(!(expr)) { \ + gl_dbgE("Critical ERROR ########################################## Check below item.");\ + assert(false); \ + } \ +} while (0) + +#ifdef _cplusplus +} +#endif + +#endif /* _GL_DEBUG_H_ */ diff --git a/include/util/gl-drm.h b/include/util/gl-drm.h new file mode 100755 index 0000000..f992fb0 --- /dev/null +++ b/include/util/gl-drm.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_DRM_H_ +#define _GL_DRM_H_ + +#include +#include + +Eina_Bool gl_drm_is_drm_file(const char *file_path); +Eina_Bool gl_drm_check_valid_ro(const char *file_path, + drm_permission_type_e permType); +char *gl_drm_get_file_path(void *item); +int gl_drm_get_permtype(int gitem_type); + +#endif /* _GL_DRM_H_ */ + diff --git a/include/util/gl-exif.h b/include/util/gl-exif.h new file mode 100755 index 0000000..e34db87 --- /dev/null +++ b/include/util/gl-exif.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef _USE_ROTATE_BG + +#ifndef _GL_EXIF_H_ +#define _GL_EXIF_H_ + +#include +#include + +#ifdef _cplusplus +extern "C" +{ +#endif + +/* +Orientation - angle +1 - 0 +3 - 180 +6 - 90 +8 - 270 +*/ +typedef enum _gl_orientation_rot_t gl_orientation_rot_e; + +enum _gl_orientation_rot_t { + GL_ORIENTATION_ROT_ERR = 0, + GL_ORIENTATION_ROT_0 = 1, + GL_ORIENTATION_ROT_180 = 3, + GL_ORIENTATION_ROT_90 = 6, + GL_ORIENTATION_ROT_270 = 8, +}; +bool _gl_exif_check_img_type(char *file_path); +int _gl_exif_get_orientation(char *file_path, unsigned int *orientation); +int _gl_exif_set_orientation(char *file_path, unsigned int orientation); +int _gl_exif_get_rotated_orientation(unsigned int orientation, bool b_left); + +#ifdef _cplusplus +} +#endif + +#endif /* _GL_EXIF_H_ */ + +#endif + diff --git a/include/util/gl-ext-exec.h b/include/util/gl-ext-exec.h new file mode 100755 index 0000000..50a44ac --- /dev/null +++ b/include/util/gl-ext-exec.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_EXT_EXEC_H_ +#define _GL_EXT_EXEC_H_ + +typedef enum +{ + GL_LAUNCH_FAIL, + GL_LAUNCH_SUCCESS +} gl_launch_status; + +typedef enum +{ + GL_APP_NONE = -1, + GL_APP_VIDEOPLAYER, +} gl_ext_app_type; + +int gl_ext_exec(void *data, gl_ext_app_type type); +int _gl_ext_load_camera(void); + +#endif /* _GL_EXT_EXEC_H_ */ diff --git a/include/util/gl-ext-ug-load.h b/include/util/gl-ext-ug-load.h new file mode 100755 index 0000000..cf505a5 --- /dev/null +++ b/include/util/gl-ext-ug-load.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_EXT_UG_LOAD_H_ +#define _GL_EXT_UG_LOAD_H_ + +#include +#include "gl-data.h" + +typedef enum +{ + GL_UG_FAIL, + GL_UG_SUCCESS +} gl_ug_load_status; + +typedef enum +{ + GL_UG_MSG, + GL_UG_EMAIL, + GL_UG_BT, + GL_UG_IMAGEVIEWER, + GL_UG_CNT, +} gl_ext_ug_type; + +typedef enum +{ + GL_UG_IV, + /*Invoke imageviewer to slideshow on local album */ + GL_UG_IV_SLIDESHOW, + /*Invoke imageviewer to slideshow selected files */ + GL_UG_IV_SLIDESHOW_SELECTED, + GL_UG_IV_CNT, +} gl_ext_iv_type; + +int gl_ext_load_ug(void *data, gl_ext_ug_type type); +int gl_ext_load_iv_ug(void *data, gl_item *item, gl_ext_iv_type type); +int gl_ext_load_gallery_ug(void *data); +int gl_ext_destroy_gallery_ug(void *data); + +#endif /* _GL_EXT_UG_LOAD_H_ */ diff --git a/include/util/gl-fs.h b/include/util/gl-fs.h new file mode 100755 index 0000000..1e52bb0 --- /dev/null +++ b/include/util/gl-fs.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_FS_H_ +#define _GL_FS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct _gl_node_info_t gl_node_info_s; +struct _gl_node_info_t { + /* Parent path */ + char *path; + /* File/folder name */ + char *name; + /* Modified time */ + time_t mtime; + /* File size / folder's content size */ + long long size; +}; + +int _gl_fs_get_file_stat(const char *filename, gl_node_info_s **node); +long long _gl_fs_get_folder_size(char *path); +int _gl_fs_rm_folder(char *path, long long cut_size, long long max_size, + unsigned int expired_time); +#ifdef _RENAME_ALBUM_SENSITIVE +bool _gl_fs_check_name_case(char *dir, char *exist_name); +#endif +bool _gl_fs_is_low_memory(unsigned long long total_size); +bool _gl_fs_get_ext(const char *file_path, char *file_ext, char *new_path); +Eina_Bool _gl_fs_move(const char *src, const char *dst); +char *_gl_fs_get_unique_full_path(char *file_path, char *ext); +bool _gl_fs_validate_name(const char *new_name); +int _gl_fs_get_default_folder(char *path); +bool _gl_fs_mkdir(const char *path); + +#endif + diff --git a/include/util/gl-icons.h b/include/util/gl-icons.h new file mode 100755 index 0000000..2bb5216 --- /dev/null +++ b/include/util/gl-icons.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_ICONS_H_ +#define _GL_ICONS_H_ + +#include "gallery.h" + +/******** Image path ********/ +#define GL_DEFAULT_THUMB_ICON IMAGEDIR"T01_Nocontents_broken.png" +#define GL_DB_DEFAULT_THUMB "/opt/usr/data/file-manager-service/.thumb/thumb_default.png" + +#define GL_DEFAULT_TAG_COVER IMAGEDIR"gallery_tag_default_thumbnail.png" +#define GL_TAG_FAVORITES_THUMB IMAGEDIR"gallery_tag_favorites_thumbnail.png" +#define GL_CBAR_ICON_ADD IMAGEDIR"T01_controlbar_icon_add.png" + +#define GL_CTRL_ICON_ALBUMS IMAGEDIR"T01_controlbar_icon_albums.png" +#define GL_CTRL_ICON_TAGS IMAGEDIR"T01_controlbar_icon_tag.png" + +/******** Image group in EDC file ********/ + +#define GL_IMAGES_EDJ_FILE EDJDIR"/gl-images.edj" + +#define GL_LOCK_ICON "T01_icon_lock.png" +#define GL_THUMB_FAVOR_ICON "T01_icon_thumbnail_favorite.png" +#define Gl_VIDEO_PLAY_ICON "T01_btn_thumbnail_play.png" +#define GL_THUMB_BOOKMARK "T01_icon_thumbnail_bookmark.png" +#define GL_LIST_BOOKMARK "T01_list_icon_bookmark.png" + +#endif + diff --git a/include/util/gl-lang.h b/include/util/gl-lang.h new file mode 100755 index 0000000..c0d9128 --- /dev/null +++ b/include/util/gl-lang.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_LANG_H_ +#define _GL_LANG_H_ + +#include "gallery.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + +int _gl_lang_update(void *data); +int _gl_lang_update_thumb_edit_button(void *data, Elm_Object_Item *nf_it); + +#ifdef _cplusplus +} +#endif + + +#endif + diff --git a/include/util/gl-strings.h b/include/util/gl-strings.h new file mode 100755 index 0000000..8641eff --- /dev/null +++ b/include/util/gl-strings.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This header file includes all multi language strings which need display */ +#ifndef _GL_STRINGS_H_ +#define _GL_STRINGS_H_ + +#ifdef _cplusplus +extern "C" +{ +#endif + +/* hard code strings and already translated strings in gallery po files */ +#define GL_ALBUM_ALL_NAME _("IDS_MEDIABR_BODY_ALL_ALBUMS") +#define GL_ALBUM_DEFAULT_NAME _("Camera") +#define GL_ALBUM_DOWNLOAD_NAME _("Downloads") +#define GL_STR_UNDER_IMPLEMENTATION _("Under Implementation!") +#define GL_STR_CTRL_ITEM_TAGS _("IDS_MEDIABR_BODY_TAGS") + +#define GL_STR_EDIT dgettext("sys_string", "IDS_COM_BODY_EDIT") +#define GL_STR_DOWNLOAD dgettext("sys_string", "IDS_COM_SK_DOWNLOAD") +#define GL_STR_SLIDESHOW _("IDS_MEDIABR_BUTTON_SLIDE_SHOW") + +#define GL_STR_INVALID_INPUT_PARAMETER _("IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER") +#define GL_STR_ENTRY_IS_EMPTY _("IDS_MEDIABR_POP_ENTRY_IS_EMPTY") +#define GL_STR_SAME_NAME_ALREADY_IN_USE _("IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE") + +#define GL_STR_UNABLE_tO_RENAME _("IDS_MEDIABR_POP_UNABLE_TO_RENAME") +#define GL_STR_NO_ALBUMS_SELECTED _("IDS_MEDIABR_POP_NO_ALBUMS_SELECTED") +#define GL_STR_NO_TAGS_SELECTED _("IDS_MEDIABR_POP_NO_TAGS_SELECTED") +#define GL_STR_SELECT_ALBUM _("IDS_MEDIABR_HEADER_SELECT_ALBUM") +#define GL_STR_SELECT_TAGS _("IDS_MEDIABR_BODY_SELECT_TAGS") +#define GL_STR_SELECT_ITEM _("IDS_MEDIABR_HEADER_SELECT_ITEM") +#define GL_STR_NO_ALBUMS _("IDS_MEDIABR_BODY_NO_ALBUMS") +#define GL_STR_NO_TAGS _("IDS_MEDIABR_POP_NO_TAGS") + +#define GL_STR_EMPTY _("") +#define GL_ALBUM_PHOME_ROOT_NAME _("IDS_MEDIABR_POP_NO_NAME") + +#ifdef _USE_ROTATE_BG +#define GL_STR_ROTATE_LEFT _("IDS_MEDIABR_OPT_ROTATE_LEFT") +#define GL_STR_ROTATE_RIGHT _("IDS_MEDIABR_OPT_ROTATE_RIGHT") +#define GL_STR_ROTATING _("Rotating") +#define GL_STR_ROTATED _("Rotated") +#endif + +#define GL_STR_RETRY_Q _("IDS_MEDIABR_POP_RETRY_Q") +#define GL_STR_CREATE_TAG _("IDS_MEDIABR_OPT_CREATE_TAG") +#define GL_STR_RENAME_TAG dgettext("sys_string", "IDS_COM_BODY_CHANGE_NAME") +#define GL_STR_CREATE_ALBUM _("IDS_MEDIABR_OPT_CREATE_ALBUM") + +/* system strings which are included in sys-string-0 po files */ +#define GL_STR_CAMERA dgettext("sys_string", "IDS_COM_BODY_CAMERA") +#define GL_STR_DOWNLOADS dgettext("sys_string", "IDS_COM_BODY_DOWNLOADS") +#define GL_STR_NO_FAVOR_VIDEOS dgettext("sys_string", "IDS_COM_BODY_NO_VIDEOS") +#define GL_STR_NO_FAVOR_IMAGES dgettext("sys_string", "IDS_COM_BODY_NO_IMAGES") +#define GL_STR_NO_FAVOR_ITEMS dgettext("sys_string", "IDS_COM_BODY_NO_ITEMS") +#define GL_TAG_FAVORITES_NAME dgettext("sys_string", "IDS_COM_BODY_FAVOURITES") +#define GL_ALBUM_IMAGES_NAME dgettext("sys_string", "IDS_COM_BODY_IMAGES") +#define GL_ALBUM_VIDEOS_NAME dgettext("sys_string", "IDS_COM_BODY_VIDEOS") +#define GL_STR_MOVE dgettext("sys_string", "IDS_COM_BODY_MOVE") +#define GL_STR_SHARE dgettext("sys_string", "IDS_COM_BUTTON_SHARE") +#define GL_STR_CANCEL dgettext("sys_string", "IDS_COM_SK_CANCEL") +#define GL_STR_CLOSE dgettext("sys_string", "IDS_COM_BODY_CLOSE") +#define GL_STR_DELETE dgettext("sys_string", "IDS_COM_OPT_DELETE") +#define GL_STR_DONE dgettext("sys_string", "IDS_COM_SK_DONE") +#define GL_STR_CTRL_ITEM_ALBUMS dgettext("sys_string", "IDS_COM_BODY_ALBUMS") +#define GL_SHARE_MESSAGE dgettext("sys_string", "IDS_COM_BODY_MESSAGE") +#define GL_SHARE_EMAIL dgettext("sys_string", "IDS_COM_BODY_EMAIL") +#define GL_SHARE_BLUETOOTH dgettext("sys_string", "IDS_COM_BODY_BLUETOOTH") +#define GL_STR_NO_ITEMS dgettext("sys_string", "IDS_COM_BODY_NO_ITEMS") +#define GL_STR_NO_IMAGES dgettext("sys_string", "IDS_COM_BODY_NO_IMAGES") +#define GL_STR_NO_CONTENTS dgettext("sys_string", "IDS_COM_BODY_NO_CONTENTS") +#define GL_STR_DELETED dgettext("sys_string", "IDS_COM_POP_DELETED") +#define GL_STR_REMOVED dgettext("sys_string", "IDS_COM_POP_REMOVED") +#define GL_STR_REMOVE dgettext("sys_string", "IDS_COM_SK_REMOVE") +#define GL_STR_ALL dgettext("sys_string", "IDS_COM_BODY_ALL") +#define GL_STR_IMAGES dgettext("sys_string", "IDS_COM_BODY_IMAGES") +#define GL_STR_VIDEOS dgettext("sys_string", "IDS_COM_BODY_VIDEOS") +#define GL_STR_YES dgettext("sys_string", "IDS_COM_SK_YES") +#define GL_STR_NO dgettext("sys_string", "IDS_COM_SK_NO") +#define GL_STR_DELETE_COMFIRMATION dgettext("sys_string", "IDS_COM_POP_DELETE_Q") +#define GL_STR_OK dgettext("sys_string", "IDS_COM_SK_OK") +#define GL_STR_ADD dgettext("sys_string", "IDS_COM_SK_ADD") +#define GL_STR_ADD_TAG dgettext("sys_string", "IDS_COM_OPT_ADD_TAG") +#define GL_STR_SELECTED dgettext("sys_string", "IDS_COM_POP_SELECTED") +#define GL_STR_CHNAGE_NAME dgettext("sys_string", "IDS_COM_BODY_CHANGE_NAME") +#define GL_STR_NO_VIDEOS dgettext("sys_string", "IDS_COM_BODY_NO_VIDEOS") +#define GL_STR_ADDED dgettext("sys_string", "IDS_COM_POP_ADDED") +#define GL_STR_MOVED dgettext("sys_string", "IDS_COM_POP_MOVED") +#define GL_STR_DELETING dgettext("sys_string", "IDS_COM_POP_DELETING") +#define GL_STR_MOVING dgettext("sys_string", "IDS_COM_POP_MOVING") +#define GL_STR_RENAME dgettext("sys_string", "IDS_COM_SK_RENAME") +#define GL_STR_SELECT_ALL dgettext("sys_string", "IDS_COM_BODY_SELECT_ALL") +#define GL_STR_NO_FILES_SELECTED dgettext("sys_string", "IDS_COM_POP_NO_FILES_SELECTED") +#define GL_STR_APPLICATION_NOT_INSTALLED dgettext("sys_string", "IDS_COM_BODY_APPLICATION_NOT_INSTALLED") + +#ifdef _cplusplus +} +#endif +#endif + diff --git a/include/util/gl-thread-util.h b/include/util/gl-thread-util.h new file mode 100755 index 0000000..f6e92d9 --- /dev/null +++ b/include/util/gl-thread-util.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_THREAD_UTIL_H_ +#define _GL_THREAD_UTIL_H_ +typedef enum +{ + GL_PB_CANCEL_NONE, /* Initial state */ + GL_PB_CANCEL_NORMAL, /* Moving or deleting is in process */ + GL_PB_CANCEL_BUTTON, /* Cancel button tapped while moving or deleting */ + GL_PB_CANCEL_MMC, /* MMC removed, src album or dest album vanished while moving or deleting */ + GL_PB_CANCEL_ERROR, /* Error happened while moving or deleting */ + GL_PB_CANCEL_RESET, /* Reset gallery while moving or deleting */ +} gl_pb_cancel_mode; + +int gl_thread_emit_next_signal(void *data); +int gl_thread_wait_next_signal(void *data); +int gl_thread_set_cancel_state(void *data, int val); +int gl_thread_get_cancel_state(void *data, int *val); +void gl_thread_write_pipe(void *data, int finished_cnt, int popup_op); +int gl_thread_gen_data_thread(void *data); +int gl_thread_destroy_lock(void *data); +int gl_thread_init_lock(void *data); + +#endif /* _GL_THREAD_UTIL_H_ */ diff --git a/include/util/gl-ui-util.h b/include/util/gl-ui-util.h new file mode 100755 index 0000000..3c8dcca --- /dev/null +++ b/include/util/gl-ui-util.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_UI_UTIL_H_ +#define _GL_UI_UTIL_H_ + +#include "gallery.h" +#include "gl-icons.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + +#define _EDJ(o) elm_layout_edje_get(o) +#define _GET_ICON(_path) \ + ((1 == ecore_file_exists(_path) && (ecore_file_size(_path) > 0)) ? _path : GL_DEFAULT_THUMB_ICON) + +/* Signals used in Gallery's views */ +#define GL_SIGNAL_VIEW_SELALL_SHOW "selectall_show" +#define GL_SIGNAL_VIEW_SELALL_HIDE "selectall_hide" +#define GL_SIGNAL_VIEW_SELALL_TAG "selectall_show_tag" +#define GL_SIGNAL_VIEW_DEFAULT "elm,swallow_view,state,default" +#define GL_SIGNAL_VIEW_EDIT "elm,swallow_view,state,edit" +#define GL_SIGNAL_VIEW_MOVEUP "elm,swallow_view,state,moveup" +#define GL_SIGNAL_VIEW_TABBAR_BG_HIDE "elm,tabbar_bg,state,hide" +#define GL_SIGNAL_VIEW_TABBAR_BG_SHOW_PORT "elm,tabbar_bg,state,show_port" +#define GL_SIGNAL_VIEW_TABBAR_BG_SHOW_LAND "elm,tabbar_bg,state,show_land" +#define GL_SIGNAL_VIEW_TABBAR_DEFAULT "elm,tabbar,state,default" +#define GL_SIGNAL_VIEW_TABBAR_LAND "elm,tabbar,state,landscape" + +#define GL_TRANS_FINISHED "transition,finished" + +typedef enum +{ + GL_NAVI_ALBUMS, + GL_NAVI_ALBUMS_EDIT, + GL_NAVI_ALBUMS_RENAME, + GL_NAVI_ALBUMS_NEW, + GL_NAVI_ALBUMS_SELECT, + GL_NAVI_TAGS, + GL_NAVI_TAGS_EDIT, + GL_NAVI_TAGS_NEW, + GL_NAVI_TAGS_RENAME, + GL_NAVI_THUMBS, + GL_NAVI_THUMBS_WEB, + GL_NAVI_THUMBS_DOWNLOAD, + GL_NAVI_THUMBS_EDIT, + GL_NAVI_THUMBS_SELECT, +} gl_navi_mode; + +typedef enum +{ + GL_POPUP_SHARE_MESSAGE, + GL_POPUP_SHARE_EMAIL, + GL_POPUP_SHARE_BT, + GL_POPUP_SHARE_NUM, +} gl_popup_share_item; + +typedef enum { + GL_POPUP_MOVE_TAG_MOVE, + GL_POPUP_MOVE_TAG_TAG, + GL_POPUP_MOVE_TAG_NUM, +} gl_popup_move_tag_item; + +typedef enum _gl_ui_albums_btn_t gl_ui_albums_btn_e; + +enum _gl_ui_albums_btn_t { + GL_UI_ALBUMS_FIRST, + GL_UI_ALBUMS_REMAKE, +}; + +typedef struct _ctx_share_table +{ + gl_popup_share_item item; + const char *label; +} gl_popup_share_tbl; + +typedef struct _ctx_mv_tag_table { + gl_popup_move_tag_item item; + const char *label; +} gl_popup_mv_tag_tbl; + +Evas_Object *gl_ui_create_main_ly(Evas_Object *parent); +Evas_Object *gl_ui_create_naviframe(Evas_Object *parent); +int gl_ui_set_navi_title_visible(void *data, bool b_visible); +int gl_ui_create_title_and_push(void *data, Evas_Object *parent, + Evas_Object *obj, gl_navi_mode mode, char *title); +Evas_Object *gl_ui_load_edj(Evas_Object * parent, const char *file, const char *group); +Evas_Object *_gl_ui_get_view_layout(void *data, int view_mode); +int _gl_ui_update_selall(void *data, int all_cnt, int selected_cnt); +int gl_ui_update_select_widgets(void *data); +int gl_ui_show_selall(void *data); +int _gl_ui_pop_to_thumb(void *data); +int _gl_ui_disable_slideshow(void *data, bool b_disable); +int _gl_ui_show_add_btn(void *data); +int _gl_ui_clear_btns(void *data); +int _gl_ui_add_btns_albums(void *data, int type); +int _gl_ui_add_conform_cbs(Evas_Object *naviframe); +int _gl_ui_del_conform_cbs(Evas_Object *naviframe); +int _gl_ui_disable_btn(Evas_Object *btn); +int _gl_ui_enable_btn(Evas_Object *btn); +int _gl_ui_disable_each_btn(Elm_Object_Item *nf_it, bool b_more, bool b_btn1, + bool b_btn2); +int _gl_ui_disable_btns(Elm_Object_Item *nf_it, bool b_disable); +Evas_Object *_gl_ui_get_btn(void *data, Elm_Object_Item *nf_it, + const char *part); +void _gl_ui_slideshow_cb(void *data, Evas_Object *obj, void *event_info); +void _gl_ui_edit_cb(void *data, Evas_Object *obj, void *event_info); +int _gl_ui_set_btns_text(Elm_Object_Item *nf_it, char *btn_text, char *btn_text2); + +#ifdef _cplusplus +} +#endif + +#endif // end of _GL_UI_UTIL_H_ diff --git a/include/util/gl-util.h b/include/util/gl-util.h new file mode 100755 index 0000000..41003fc --- /dev/null +++ b/include/util/gl-util.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_UTIL_H_ +#define _GL_UTIL_H_ + +#include "gl-data.h" +#include "gallery.h" + +/* File system related String definition */ + +#define GL_HOME_ALBUM_COVER_NUM 1 + +#define GL_FILE_EXISTS(path) \ + (path && (1 == ecore_file_exists(path)) && (ecore_file_size(path) > 0)) +#define GL_ICON_SET_FILE(icon, img) \ + elm_image_file_set(icon, GL_IMAGES_EDJ_FILE, img) + +#define GL_IF_DEL_TIMER(timer) if(timer){ecore_timer_del(timer); timer = NULL;} +#define GL_IF_DEL_IDLER(idler) if(idler){ecore_idler_del(idler); idler = NULL;} +#define GL_IF_DEL_OBJ(obj) if(obj){evas_object_del(obj); obj = NULL;} + +typedef enum +{ + GL_MMC_STATE_NONE, + GL_MMC_STATE_ADDED, + GL_MMC_STATE_ADDED_MOVING, /* Move medias to MMC or from MMC */ + GL_MMC_STATE_ADDING_MOVING, /* Insert MMC while operate medias */ + GL_MMC_STATE_REMOVED, + GL_MMC_STATE_REMOVED_MOVING, /* Remove MMC while move medias to MMC or from MMC */ +} gl_mmc_state_mode; + +typedef enum +{ + GL_UPDATE_VIEW_NONE, + GL_UPDATE_VIEW_NORMAL, + GL_UPDATE_VIEW_MMC_REMOVED, /* Update view when MMC removed */ + GL_UPDATE_VIEW_MMC_ADDED, /* Update view when MMC inserted */ +} gl_update_view_mode; + +typedef enum +{ + GL_MEDIA_OP_NONE, + GL_MEDIA_OP_MOVE, + GL_MEDIA_OP_DELETE, + /* Add tag to media */ + GL_MEDIA_OP_ADD_TAG, + /* Remove tag from media */ + GL_MEDIA_OP_REMOVE_TAG, +#ifdef _USE_ROTATE_BG + GL_MEDIA_OP_ROTATING_LEFT, + GL_MEDIA_OP_ROTATING_RIGHT, +#endif +} gl_media_op_mode; + +typedef enum +{ + GL_POPUP_OP_NONE, + GL_POPUP_OP_SAME_ALBUM, + GL_POPUP_OP_DUPLICATED_NAME, + GL_POPUP_OP_PROTECTED_FILE, +} gl_popup_op_mode; + +typedef enum +{ + GL_SHARE_NONE, + GL_SHARE_DRM, /* DRM file selected, disable share option */ + GL_SHARE_IMAGE_ONE, /* One image selection */ + GL_SHARE_IMAGE_ONE_JPEG, /* One jpeg image selection */ + GL_SHARE_IMAGE_MULTI, /* Multiple images selection */ + GL_SHARE_IMAGE_MULTI_JPEG, /* Multiple jpeg images selection */ + GL_SHARE_IMAGE_VIDEO, /* Image(s) and Video(s) selection */ + GL_SHARE_VIDEO_ONE, /* One video selection */ + GL_SHARE_VIDEO_MULTI, /* Multiple videos selection */ +} gl_share_mode; + +typedef enum +{ + GL_INVALID_NONE, + GL_INVALID_NEW_ENTRY, + GL_INVALID_NEW_ENTRY_NOC, /* Show nocontents view */ + GL_INVALID_NEW_TAG_VIDEO, +} gl_invalid_mode; + +int gl_get_view_mode(void *data); +int gl_set_view_mode(void *data, int mode); +int _gl_use_thread_operate_medias(void *data, char *pbar_title, int all_cnt, + int op_type); +int _gl_move_media_thumb(gl_item * gitem, char *new_dir_name, + bool is_full_path, int *popup_op); +int _gl_move_media(gl_item *gitem, char *new_dir_name, bool is_full_path); +int gl_move_selected(void *data); +int gl_move_to_album(void *data); +int gl_move_root_album(void* data, gl_cluster* cur_album, char* dest_path); +int gl_update_move_view(void *data); +int gl_del_medias(void *data); +int gl_del_selected(void *data); +int gl_update_del_view(void *data); +int _gl_get_selected_paths(void *data, gchar sep_c, char **path_str, + int *sel_cnt); +int _gl_share_load(void *data, const char *label); +int gl_share_select_item(void *data, const char *label); +int gl_add_to_tag(void *data, const char *tagname); +int gl_add_tag(void *data, gl_tag * gtag); +int gl_add_tag_to_selected(void *data); +int gl_update_add_tag_view(void *data); +int gl_remove_tag_items(void *data); +int gl_remove_tag_from_selected(void *data); +int gl_update_remove_tag_view(void *data); +int gl_check_mmc_state(void *data, char *dest_folder); +int gl_del_albums(void *data); +int gl_refresh_albums_list(void *data); +int gl_reg_db_update_noti(void *data); +int gl_dereg_db_update_noti(void); +void gl_set_mmc_notifd(int fd); +Eina_Bool gl_update_view(void *data, int mode); +int gl_get_selected_files_path_str(void *data, gchar sep_c, char **path_str, + int *sel_cnt); +int gl_make_new_album(const char *name); +bool gl_check_gallery_empty(void* data); +bool gl_is_rotation_locked(void); +bool gl_is_image_valid(void *data, char *filepath); +#ifdef _USE_ROTATE_BG +int _gl_rotate_images(void *data, bool b_left); +int _gl_rotate_selected(void *data, int op_type); +int _gl_update_rotate_view(void *data); +#endif +int _gl_slideshow(void *data); +int gl_get_entry_text(Evas_Object * entry, char *entry_text, int len_max); +int gl_set_entry_text(Evas_Object *entry, char *entry_text); +int _gl_get_valid_album_name(void *data, char* album_name, bool b_new, + bool b_enter); +char* _gl_get_i18n_album_name(gl_cluster *album); +int _gl_get_valid_tag_name(void *data, char* tag_name, bool b_new, bool b_enter); +int gl_get_share_mode(void *data); +int gl_del_invalid_widgets(void *data, int invalid_m); +int _gl_destroy_ctrl_edit_view(void *data); +int _gl_destroy_thumbs_edit_view(void *data); +int gl_destroy_thumbs_view(void *data); +int gl_pop_to_ctrlbar_ly(void *data, bool b_update_albums_list); +int gl_play_vibration(void *data); +char *_gl_get_duration_string(unsigned int v_dur); +gl_icon_type _gl_get_icon_type(gl_item *git); + +#endif /* _GL_UTIL_H_ */ diff --git a/include/widget/gl-button.h b/include/widget/gl-button.h new file mode 100755 index 0000000..6ecc1e2 --- /dev/null +++ b/include/widget/gl-button.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_BUTTON_H_ +#define _GL_BUTTON_H_ + +#include +#include "gallery.h" + +/**< Evas smart objects' "smart callback" function signature */ +typedef void (*But_Smart_Cb) (void *data, Evas_Object *obj, void *event_info); + +Evas_Object *_gl_but_create_but(Evas_Object *parent, const char *icon, + const char *text, const char *style, + But_Smart_Cb cb_func, const void *data); +Evas_Object *_gl_but_create_but_popup(Evas_Object *parent, const char *text, + But_Smart_Cb cb_func, const void *data); + +#endif /* _GL_BUTTON_H_ */ + diff --git a/include/widget/gl-controlbar.h b/include/widget/gl-controlbar.h new file mode 100755 index 0000000..ff466db --- /dev/null +++ b/include/widget/gl-controlbar.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_CONTROLBAR_H_ +#define _GL_CONTROLBAR_H_ + +#include +#include "gallery.h" + +#define GL_CBAR_OCCUPIED_PBAR 4 +#define GL_CBAR_OCCUPIED_SEGMENT 4 + +typedef enum _gl_ctrl_tab_mode +{ + GL_CTRL_TAB_ALBUMS, + GL_CTRL_TAB_TAGS, + GL_CTRL_TAB_CNT, +} gl_ctrl_tab_mode; + +void _gl_ctrl_segment_change_cb(void *data, Evas_Object *obj, void *event_info); +Evas_Object *gl_ctrl_create_ctrlbar_view(Evas_Object * parent); +Evas_Object *gl_ctrl_create_ctrlbar_ly(Evas_Object *parent); +Evas_Object *gl_ctrl_create_ctrlbar(void *data, int mode); +int gl_ctrl_disable_tab_event(void *data, bool disabled); +int _gl_ctrl_sel_tabbar_item(void *data, const char *aul_type); +int _gl_ctrl_show_tabbar(void *data, bool b_show); +bool gl_ctrl_rotate_ctrlbar(void *data, int mode); +int gl_ctrl_disable_ctrlbar(void *data, bool disabled); +int _gl_ctrl_disable_btn(void *data, bool disabled, int mode); +int _gl_ctrl_disable_btns(void *data, Elm_Object_Item *nf_it, bool b_disable); + +#endif /* _GL_CONTROLBAR_H_ */ diff --git a/include/widget/gl-ctxpopup.h b/include/widget/gl-ctxpopup.h new file mode 100755 index 0000000..4fc4f14 --- /dev/null +++ b/include/widget/gl-ctxpopup.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_CTXPOPUP_H_ +#define _GL_CTXPOPUP_H_ + +typedef int (*ctx_append_cb) (void *data, Evas_Object *parent); + +int _gl_ctxpopup_create(void *data, Evas_Object *but, ctx_append_cb append_cb); +int _gl_ctxpopup_del(void *data); +int _gl_ctxpopup_create_albums(void *data, Evas_Object *but); +int _gl_ctxpopup_create_thumbs(void *data, Evas_Object *but); +int _gl_ctxpopup_create_share(void *data, Evas_Object *but); +int _gl_ctxpopup_create_move(void *data); +int _gl_ctxpopup_create_addtag(void *data); + +#endif + diff --git a/include/widget/gl-editfield.h b/include/widget/gl-editfield.h new file mode 100755 index 0000000..4120a84 --- /dev/null +++ b/include/widget/gl-editfield.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_EDITFIELD_H_ +#define _GL_EDITFIELD_H_ + +#include "gallery.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + +Evas_Object *_gl_editfield_create(void *data, Evas_Object *parent, + char *default_label); +Evas_Object *_gl_editfield_create_genlist(void *data, Evas_Object *parent, + char *label); +int _gl_editfield_hide_imf(void *data); +int _gl_editfield_show_imf(void *data); +int _gl_editfield_destroy_imf(void *data); + + +#ifdef _cplusplus +} +#endif + +#endif // end of _GL_EDITFIELD_H_ diff --git a/include/widget/gl-nocontents.h b/include/widget/gl-nocontents.h new file mode 100755 index 0000000..4e8c7af --- /dev/null +++ b/include/widget/gl-nocontents.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_NOCONTENTS_H_ +#define _GL_NOCONTENTS_H_ + +#include "gallery.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + +Evas_Object *_gl_nocontents_create(void *data); +bool _gl_nocontents_update_label(Evas_Object *noc, const char *new_label); +bool _gl_nocontents_show(void *data); + +#ifdef _cplusplus +} +#endif + +#endif // end of _GL_NOCONTENTS_H_ diff --git a/include/widget/gl-notify.h b/include/widget/gl-notify.h new file mode 100755 index 0000000..402ef37 --- /dev/null +++ b/include/widget/gl-notify.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_NOTIFY_H_ +#define _GL_NOTIFY_H_ + +#include "gallery.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + +int _gl_notify_create_notiinfo(void *data, const char *text); +int _gl_notify_create_selinfo(void *data, Evas_Object *parent, + Elm_Object_Item *nf_it, int all_cnt, + int selected_cnt, bool b_update); +int _gl_notify_destroy_selinfo(void *data); +int _gl_notify_update_lang(void *data, int cnt, int view_mode); + +#ifdef _cplusplus +} +#endif + +#endif // end of _GL_NOTIFY_H_ diff --git a/include/widget/gl-popup.h b/include/widget/gl-popup.h new file mode 100755 index 0000000..df11b5c --- /dev/null +++ b/include/widget/gl-popup.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_POPUP_H_ +#define _GL_POPUP_H_ + +#define GL_MOVE_TAG_MOVE GL_STR_MOVE +#define GL_MOVE_TAG_TAG GL_STR_ADD_TAG +#define GL_POPUP_STRING_MAX 256 + +typedef enum _gl_popup_mode { + GL_POPUP_NOBUT, + GL_POPUP_NOBUT_MOV_DEL, + GL_POPUP_NOBUT_APPEXIT, + GL_POPUP_ALBUM_NEW_EMPTY, + GL_POPUP_ALBUM_NEW_DUPLICATE, + GL_POPUP_ALBUM_NEW_INVALID, + GL_POPUP_ALBUM_RENAME_EMPTY, + GL_POPUP_ALBUM_RENAME_DUPLICATE, + GL_POPUP_ALBUM_RENAME_INVALID, + GL_POPUP_ALBUM_DELETE, + GL_POPUP_TAG_DELETE, + GL_POPUP_TAG_NEW_EMPTY, + GL_POPUP_TAG_RENAEM_EMPTY, + GL_POPUP_TAG_RENAME_DUPLICATE, +} gl_popup_mode; + +int gl_popup_create_albums_del_popup(void *data); +int gl_popup_create_tag_del_popup(void *data); +int gl_popup_create_popup(void *data, gl_popup_mode mode, char *desc); + +#endif /* _GL_POPUP_H_ */ diff --git a/include/widget/gl-progressbar.h b/include/widget/gl-progressbar.h new file mode 100755 index 0000000..d75282c --- /dev/null +++ b/include/widget/gl-progressbar.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_PROGRESSBAR_H_ +#define _GL_PROGRESSBAR_H_ + +/* Font style for show label of popup */ +#define GL_FONT_STYLE_POP_S "" +#define GL_FONT_STYLE_POP_E "" + +int gl_pb_make_thread_pbar(void *data, Evas_Object * parent, char *title); +int gl_pb_refresh_thread_pbar(void *data, int cur_cnt, int total_cnt); +int gl_pb_del_pbar(void *data); + +#endif /* _GL_PROGRESSBAR_H_ */ diff --git a/include/widget/gl-rotate-bg.h b/include/widget/gl-rotate-bg.h new file mode 100755 index 0000000..dd29925 --- /dev/null +++ b/include/widget/gl-rotate-bg.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef _USE_ROTATE_BG + +#ifndef _GL_ROTATE_BG_H_ +#define _GL_ROTATE_BG_H_ + +#include "gallery.h" + +Evas_Object *_gl_rotate_bg_add(Evas_Object *parent); +int _gl_rotate_bg_set_file(Evas_Object *bg, const char *file, int w, int h); +int _gl_rotate_bg_rotate_image(Evas_Object *bg, unsigned int orient); +int _gl_rotate_bg_add_image(Evas_Object *bg, int w, int h); +int _gl_rotate_bg_set_image_file(Evas_Object *bg, const char *file); + +#endif + +#endif diff --git a/include/widget/gl-thumb.h b/include/widget/gl-thumb.h new file mode 100755 index 0000000..c98b878 --- /dev/null +++ b/include/widget/gl-thumb.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_THUMB_H_ +#define _GL_THUMB_H_ + +#define GL_GENGRID_ITEM_STYLE_THUMBNAIL "gallery/thumbnail_view" +#define GL_THUMB_ICON "elm.swallow.icon" +#define GL_THUMB_CHECKBOX "elm.swallow.end" + +Evas_Object *_gl_thumb_show_part_icon_image(Evas_Object *obj, char *path, + int orient, bool b_favor, + bool is_expired_drm, int item_size); +Evas_Object *_gl_thumb_show_part_icon_video(Evas_Object *obj, char *path, + unsigned int v_dur, int bk_len, + bool b_favor, bool is_expired_drm, + int item_size); +Evas_Object *_gl_thumb_show_part_checkbox(Evas_Object *obj, bool checked, + Evas_Smart_Cb func, const void *data); +Evas_Object *_gl_thumb_add_gengrid(Evas_Object *parent); +int _gl_thumb_update_gengrid(Evas_Object *view); +int _gl_thumb_set_size(void *data, Evas_Object *view, int count, int *size); + +#endif + diff --git a/include/widget/gl-tile.h b/include/widget/gl-tile.h new file mode 100755 index 0000000..93861e6 --- /dev/null +++ b/include/widget/gl-tile.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_TILE_H_ +#define _GL_TILE_H_ + +#include "gl-data.h" + +#define GL_TILE_THUMB_1 1 +#define GL_TILE_THUMB_2 2 +#define GL_TILE_THUMB_3 3 +#define GL_TILE_THUMB_5 5 +#define GL_TILE_THUMB_6 6 + +#define GT_TILE_ONLYICON "elm.swallow.onlyicon" +#define GT_TILE_ICON "elm.swallow.icon" +#define GT_TILE_LABEL "label_bg" +#define GL_TILE_CHECKBOX "elm.swallow.end" +#define GL_TILE_CHECKBOX_GRID "elm.swallow.check_grid" +#define GL_TILE_RENAME "elm.swallow.rename" + +#define GL_GENGRID_STYLE_ALBUM_VIEW "gallery/albums_view" +#define GL_GENGRID_STYLE_ALBUM_EDIT_VIEW "gallery/albums_edit_view" + +/* Size of album icon */ +#define GL_TILE_SIZE 318 +/* Size of table padding */ +#define GL_TILE_PAD 3 +#define GL_TILE_PAD_2 2 +/* Pure size of album icon; value: 196 */ +#define GL_TILER_ICON_S (GL_TILE_SIZE - 2 * GL_TILE_PAD) +/** +* Album icon is set by elm_table, +* it's divided into 3x3, 9 grids, each grid size is 64 +*/ +#define GL_TILE_GRID_S 102 +/* value: 130 */ +#define GL_TILE_2X_GRID_S (GL_TILER_ICON_S - GL_TILE_GRID_S - GL_TILE_PAD) + +typedef int (*bg_file_set_cb) (Evas_Object *bg, void *data); + +Evas_Object *_gl_tile_show_part_icon(Evas_Object *obj, const char *part, + int length, double scale, + bg_file_set_cb func, void **data); +Evas_Object *_gl_tile_show_part_label(Evas_Object *obj, int index, + bool b_default); +Evas_Object *_gl_tile_show_part_checkbox_grid(Evas_Object *obj, bool checked, + Evas_Smart_Cb func, + const void *data); +Evas_Object *_gl_tile_show_part_checkbox(Evas_Object *obj, bool checked, + Evas_Smart_Cb func, const void *data); +Evas_Object *_gl_tile_show_part_rename(Evas_Object *obj, Evas_Smart_Cb func, + const void *data); +int _gl_tile_get_mtime(time_t *mtime1, time_t *mtime2, char *buf, int max_len); +Evas_Object *_gl_tile_add_gengrid(void *data, Evas_Object *parent); + + +#endif diff --git a/org.tizen.gallery.manifest b/org.tizen.gallery.manifest new file mode 100755 index 0000000..c58eae5 --- /dev/null +++ b/org.tizen.gallery.manifest @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.tizen.gallery.xml b/org.tizen.gallery.xml new file mode 100755 index 0000000..8138156 --- /dev/null +++ b/org.tizen.gallery.xml @@ -0,0 +1,75 @@ + + + + Jiansong Jin + Gallery + + org.tizen.gallery.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/org.tizen.gallery.spec b/packaging/org.tizen.gallery.spec new file mode 100755 index 0000000..2f67a8a --- /dev/null +++ b/packaging/org.tizen.gallery.spec @@ -0,0 +1,97 @@ +%define _optdir /opt/usr +%define _usrdir /usr +%define _appdir %{_usrdir}/apps +%define _appdatadir %{_optdir}/apps +%define _ugdir %{_usrdir}/ug + +Name: org.tizen.gallery +Summary: org.tizen.gallery UX +Version: 1.1.47 +Release: 1 +Group: Applications +License: Flora Software License +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: gettext-tools +BuildRequires: edje-tools +BuildRequires: pkgconfig(capi-content-media-content) +BuildRequires: pkgconfig(drm-client) +BuildRequires: pkgconfig(ui-gadget-1) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(ecore-imf) +BuildRequires: pkgconfig(ecore-x) +BuildRequires: pkgconfig(eina) +BuildRequires: pkgconfig(evas) +BuildRequires: pkgconfig(edje) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ecore-file) +BuildRequires: pkgconfig(ecore-input) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gthread-2.0) +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-appfw-app-manager) +BuildRequires: pkgconfig(haptic) +BuildRequires: pkgconfig(utilX) +BuildRequires: pkgconfig(status) + +Requires: media-server ug-image-viewer-efl + +%description +Description: org.tizen.gallery UX + +%package -n ug-gallery-efl +Summary: gallery UG +Group: TO_BE/FILLED_IN + +%description -n ug-gallery-efl +Description: gallery UG + +%prep +%setup -q + +%build + +%ifarch %{arm} +CXXFLAGS+=" -D_ARCH_ARM_ -mfpu=neon -mfloat-abi=softfp" +%endif + +cmake . -DCMAKE_INSTALL_PREFIX=%{_appdir}/org.tizen.gallery + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post +chown -R 5000:5000 %{_appdatadir}/org.tizen.gallery/data +%postun + +%post -n ug-gallery-efl +mkdir -p /usr/ug/bin/ +ln -sf /usr/bin/ug-client /usr/ug/bin/gallery-efl +%postun -n ug-gallery-efl + +%files -n org.tizen.gallery +%manifest org.tizen.gallery.manifest +%defattr(-,root,root,-) +%{_appdir}/org.tizen.gallery/bin/* +%{_appdir}/org.tizen.gallery/res/locale/* +/usr/share/icons/default/small/* +%{_appdir}/org.tizen.gallery/res/images/* +%{_appdir}/org.tizen.gallery/res/edje/* +%{_appdatadir}/org.tizen.gallery/data +/usr/share/packages/org.tizen.gallery.xml +/usr/share/miregex/* + +%files -n ug-gallery-efl +%manifest ug-gallery-efl.manifest +%defattr(-,root,root,-) +%{_ugdir}/lib/libug-gallery-efl.so* +%{_ugdir}/res/edje/gallery-efl/* +%{_ugdir}/res/images/gallery-efl/* +%{_ugdir}/res/locale/*/*/ug-gallery*.mo +/usr/share/packages/ug-gallery-efl.xml + diff --git a/res/gallery.uri b/res/gallery.uri new file mode 100755 index 0000000..721d80e --- /dev/null +++ b/res/gallery.uri @@ -0,0 +1,2 @@ +(^( )*gallery:)([a-zA-Z0-9]+) +Gallery Album Shortcut Internal diff --git a/res/icon/org.tizen.gallery.png b/res/icon/org.tizen.gallery.png new file mode 100755 index 0000000..e20bd23 Binary files /dev/null and b/res/icon/org.tizen.gallery.png differ diff --git a/res/po/CMakeLists.txt b/res/po/CMakeLists.txt new file mode 100755 index 0000000..bdb759a --- /dev/null +++ b/res/po/CMakeLists.txt @@ -0,0 +1,30 @@ +# for i18n + +SET(POFILES ar.po az.po bg.po ca.po cs.po da.po de_DE.po el_GR.po en.po + en_PH.po en_US.po es_ES.po es_MX.po et.po eu.po fi.po fr_CA.po fr_FR.po + ga.po gl.po hi.po hr.po hu.po hy.po is.po it_IT.po ja_JP.po ka.po kk.po + ko_KR.po lt.po lv.po mk.po nb.po nl_NL.po pl.po pt_BR.po pt_PT.po ro.po + ru_RU.po sk.po sl.po sr.po sv.po tr_TR.po uk.po uz.po zh_CN.po zh_HK.po + zh_SG.po zh_TW.po) + +SET(MSGFMT "/usr/bin/msgfmt") + +FOREACH(pofile ${POFILES}) + SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile}) + MESSAGE("PO: ${pofile}") + GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE) + GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE) + SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo) + ADD_CUSTOM_COMMAND( + OUTPUT ${moFile} + COMMAND ${MSGFMT} -o ${moFile} ${absPofile} + DEPENDS ${absPofile} + ) + INSTALL(FILES ${moFile} DESTINATION res/locale/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo) +#Share mo files with Gallery UG. + INSTALL(FILES ${moFile} DESTINATION /usr/ug/res/locale/${lang}/LC_MESSAGES RENAME ${GALLERY_UG_PROJECT_NAME}.mo) + SET(moFiles ${moFiles} ${moFile}) +ENDFOREACH(pofile) + +MESSAGE(".mo files: ${moFiles}") +ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles}) diff --git a/res/po/POTFILES.in b/res/po/POTFILES.in new file mode 100755 index 0000000..e8ad1de --- /dev/null +++ b/res/po/POTFILES.in @@ -0,0 +1,28 @@ +# List of source files containing translatable strings. +../src/gallery.c +../src/features/gl-albums.c +../src/features/gl-gridview.c +../src/features/gl-listview.c +../src/features/gl-places-footsteps.c +../src/features/gl-places.c +../src/features/gl-tags.c +../src/features/gl-webalbum.c +../src/widget/gl-button.c +../src/widget/gl-controlbar.c +../src/widget/gl-nocontents.c +../src/widget/gl-popup.c +../src/widget/gl-progressbar.c +../src/util/gl-2d-util.c +../src/util/gl-allshare-util.c +../src/util/gl-db-handler.c +../src/util/gl-debug.c +../src/util/gl-ext-exec.c +../src/util/gl-ext-ug-load.c +../src/util/gl-net-if.c +../src/util/gl-ptp-util.c +../src/util/gl-share-login.c +../src/util/gl-sns-util.c +../src/util/gl-ta.c +../src/util/gl-thread-util.c +../src/util/gl-ui-util.c +../src/util/gl-util.c diff --git a/res/po/ar.po b/res/po/ar.po new file mode 100755 index 0000000..14827c2 --- /dev/null +++ b/res/po/ar.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "البطاقات" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "كافة الألبومات" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "الألبومات" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "لا توجد ألبومات" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "تحديد العلامات" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "إنشاء ألبوم" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "غير قادر على تغيير الاسم. جاري استخدام الملف" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "لا يوجد اسم" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "لا توجد ألبومات محددة" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "لم يتم تحديد أية علامات" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "اختيار عنصر" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "تحديد ألبوم‬" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "هل تريد إعادة المحاولة؟" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "نفس الاسم مستخدم مسبقا" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "المدخل خالي" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "متغير إدخال غير صحيح" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "إنشاء ع." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "لا توجد علامات" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "تدوير لليسار" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "تدوير لليمين" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "عرض شرائح" + diff --git a/res/po/az.po b/res/po/az.po new file mode 100755 index 0000000..3932ebd --- /dev/null +++ b/res/po/az.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Yarlıklar" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Bütün albomlar" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albomlar" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Albom yoxdur" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Etiketləri seç" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Albom yaradın" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Yenidən adlandırmaq mümkün deyildir" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Ad yoxdur" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Albom seçilməyib" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Heç bir etiket seçilməyib" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Element seç" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Albom seç" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Yenidən cəhd edilsin?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Eyni ad hazırda istifadə edilir" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Boş qeyd" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Yanlış daxiletmə parametrləri" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Et.yaradın" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Etiket yoxdur" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Sola döndər" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Sağa döndər" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slyd nmyşi" + diff --git a/res/po/bg.po b/res/po/bg.po new file mode 100755 index 0000000..0951d9d --- /dev/null +++ b/res/po/bg.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Тагове" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Всички албуми" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Албуми" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Няма албуми" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Изберете тагове" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Създаване на албум" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Не може да се преименува" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Без име" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Не са избрани албуми" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Няма избрани тагове" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Изберете елемент" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Избор на албум" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Повторен опит?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Такова име вече се използва" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Празен запис" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Невалиден параметър на входа" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Създ. таг" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Без тагове" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Завъртане наляво" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Завъртане надясно" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Слайдшоу" + diff --git a/res/po/ca.po b/res/po/ca.po new file mode 100755 index 0000000..74ac58d --- /dev/null +++ b/res/po/ca.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etiquetes" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Tots els àlbums" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Àlbums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Cap àlbum" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Seleccionar etiquetes" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Crear àlbum" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "No es pot canviar nom" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Sense nom" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Sense àlbums seleccionats" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "No s'ha seleccionat cap etiqueta" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Seleccionar element" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Seleccionar àlbum" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Tornar-ho a intentar?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "El mateix nom ja està en ús" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "L'entrada és buida" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Paràmetre d'entrada no vàlid" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Crear etiq" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Sense etiquetes" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Girar cap a l'esquerra" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Girar cap a la dreta" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diaposit" + diff --git a/res/po/cs.po b/res/po/cs.po new file mode 100755 index 0000000..13a9d60 --- /dev/null +++ b/res/po/cs.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Značky" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "VÅ¡echna alba" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Alba" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Žádná alba" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Vyberte značky" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Vytvořit album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Nelze přejmenovat" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Žádný název" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nejsou vybrána žádná alba" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nejsou vybrány žádné značky" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Vybrat položku" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Vybrat album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Opakovat?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Stejný název je již použit" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Prázdná položka" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Chybný vstupní parametr" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Vytv. zn." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Žádné značky" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Otočit doleva" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Otočit doprava" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Prezent." + diff --git a/res/po/da.po b/res/po/da.po new file mode 100755 index 0000000..3cab903 --- /dev/null +++ b/res/po/da.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tags" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Alle album" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Ingen album" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Vælg koder" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Opret album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Kunne ikke omdøbe" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Intet navn" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Ingen valgte album" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Der er ikke valgt nogen koder" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Vælg element" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Vælg album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Prøv igen?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Det samme navn er allerede i brug" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Posten er tom" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Ugyldigt inputparameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Opret kode" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Ingen tags" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotér mod uret" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotér med uret" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diasshow" + diff --git a/res/po/de_DE.po b/res/po/de_DE.po new file mode 100755 index 0000000..741269f --- /dev/null +++ b/res/po/de_DE.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tags" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Alle Alben" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Alben" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Keine Alben" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Tags auswählen" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Album erstellen" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Umbenennen nicht möglich" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Kein Name" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Keine Alben ausgewählt." + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Keine Tags ausgewählt" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Element auswählen" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Album auswählen" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Erneut versuchen?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Derselbe Name wird bereits verwendet" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Eintrag ist leer" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Ungültiger Eingabeparameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Tag erst." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Keine Markierungen" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Nach links drehen" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Nach rechts drehen" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diashow" + diff --git a/res/po/el_GR.po b/res/po/el_GR.po new file mode 100755 index 0000000..3282ced --- /dev/null +++ b/res/po/el_GR.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Ετικέτες" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Όλα τα άλμπουμ" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Άλμπουμ" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Δεν υπάρχουν άλμπουμ" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Επιλέξτε ετικέτα" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Δημιουργία άλμπουμ" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Δεν είναι δυνατή η μετονομασία" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Κανένα όνομα" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Δεν έχουν επιλεγεί άλμπουμ" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Δεν έχουν επιλεγεί ετικέτες" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Επιλογή στοιχείου" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Επιλογή άλμπουμ" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Επανάληψη;" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Το όνομα χρησιμοποιείται ήδη" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Κενή καταχώρηση" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Μη έγκυρη παράμετρος δεδομένων εισόδου" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Δημ. ετικ." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Δεν υπάρχουν ετικέτες" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Περιστροφή προς τα αριστερά" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Περιστροφή προς τα δεξιά" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Παρ/σίαση" + diff --git a/res/po/en.po b/res/po/en.po new file mode 100755 index 0000000..39c3042 --- /dev/null +++ b/res/po/en.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tags" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "All albums" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "No albums" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Select tags" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Create album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Unable to rename" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "No name" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "No albums selected" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "No tags selected" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Select item" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Select album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Retry?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Same name already in use" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Entry is empty" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Invalid input parameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Create tag" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "No tags" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotate left" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotate right" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slide show" + diff --git a/res/po/en_PH.po b/res/po/en_PH.po new file mode 100755 index 0000000..e244a39 --- /dev/null +++ b/res/po/en_PH.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tags" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "All albums" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "No albums" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Select tags" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Create album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Unable to rename" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "No name" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "No albums selected" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "No tags selected" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Select item" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Select album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Retry?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Same name already in use" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Phone contact is empty" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Invalid input parameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Create tag" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "No tags" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotate left" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotate right" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slide show" + diff --git a/res/po/en_US.po b/res/po/en_US.po new file mode 100755 index 0000000..39c3042 --- /dev/null +++ b/res/po/en_US.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tags" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "All albums" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "No albums" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Select tags" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Create album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Unable to rename" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "No name" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "No albums selected" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "No tags selected" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Select item" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Select album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Retry?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Same name already in use" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Entry is empty" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Invalid input parameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Create tag" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "No tags" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotate left" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotate right" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slide show" + diff --git a/res/po/es_ES.po b/res/po/es_ES.po new file mode 100755 index 0000000..32de096 --- /dev/null +++ b/res/po/es_ES.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etiquetas" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Todos los álbumes" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Álbumes" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "No hay álbumes" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Seleccionar etiquetas" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Crear álbum" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Imposible cambiar el nombre" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Sin nombre" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "No hay álbumes seleccionados" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "No hay etiquetas seleccionadas" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Seleccionar elemento" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Seleccionar álbum" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "¿Volver a intentar?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "El mismo nombre ya está en uso" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Entrada vacía" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Parámetro de entrada no válido" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Crear etiq" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Sin etiquetas" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Girar a la izquierda" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Girar a la derecha" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Pres diap" + diff --git a/res/po/es_MX.po b/res/po/es_MX.po new file mode 100755 index 0000000..e368eaf --- /dev/null +++ b/res/po/es_MX.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etiquetas" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Todos los álbumes" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Álbumes" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "No hay álbumes" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Seleccionar etiquetas" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Crear álbum" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "No se puede renombrar" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Sin nombre" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "No hay álbumes seleccionados" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "No hay etiquetas seleccionadas" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Seleccionar elemento" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Seleccionar álbum" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "¿Volver a intentar?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Ya existe ese nombre" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Entrada vacía" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Parámetro de entrada no válido" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Crear etiq" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Sin etiquetas" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Girar a la izquierda" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Girar a la derecha" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Pres diap" + diff --git a/res/po/et.po b/res/po/et.po new file mode 100755 index 0000000..610f5b4 --- /dev/null +++ b/res/po/et.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Sildid" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Kõik albumid" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumid" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Albumid puuduvad" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Vali silte" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Loo album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Ei saa ümber nimetada" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nimi puudub" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Ühtegi albumit pole valitud" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Silte ei ole valitud" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Vali üksus" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Valige album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Proovi uuesti?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "See nimi on juba kasutusel" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Kirje on tühi" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Vigane sisestusparameeter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Loo silt" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Silte pole" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Pööra vasakule" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Pööra paremale" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slaidis." + diff --git a/res/po/eu.po b/res/po/eu.po new file mode 100755 index 0000000..9f28d55 --- /dev/null +++ b/res/po/eu.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etiketak" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Album guztiak" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumak" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Albumik ez" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Aukeratu etiketak" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Albuma sortu" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Ezin da berrizendatu" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Izenik gabe" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Ez da albumik aukeratu" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Ez da etiketarik aukeratu" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Elementua aukeratu" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Aukeratu albuma" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Berriz saiatu?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Izen bera dagoeneko erabiltzen" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Sarrera hutsik dago" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Sarrera parametro baliogabea" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Sor. etik." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Etiketarik ez" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Ezkerrera biratu" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Eskuinera biratu" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Erakusketa" + diff --git a/res/po/fi.po b/res/po/fi.po new file mode 100755 index 0000000..9128e48 --- /dev/null +++ b/res/po/fi.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tunnisteet" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Kaikki albumit" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumit" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Ei albumeita" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Valitse tunnisteet" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Luo albumi" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Ei voi nimetä uudelleen" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Ei nimeä" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Albumeita ei ole valittu" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Tunnisteita ei ole valittu" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Valitse kohde" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Valitse albumi" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Yritetäänkö uudelleen?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Sama nimi on jo käytössä" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Tyhjä tieto" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Virheellinen syöteparametri" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Luo tunn." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Ei tunnisteita" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Kierrä vastapäivään" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Kierrä myötäpäivään" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diaesitys" + diff --git a/res/po/fr_CA.po b/res/po/fr_CA.po new file mode 100755 index 0000000..8339c84 --- /dev/null +++ b/res/po/fr_CA.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Libellés" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Tous les albums" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Aucun album" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Sélectionner libellés" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Créer un album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Impossible de renommer l'élément" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Aucun nom" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Aucun album sélectionné" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Aucun libellé sélectionné" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Sélectionner un élément" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Sélectionner un album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Réessayer?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Nom déjà utilisé" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Entrée vide" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Paramètre d'entrée non valide" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Nv libellé" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Aucun libellé" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Pivoter vers la gauche" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Pivoter vers la droite" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diaporama" + diff --git a/res/po/fr_FR.po b/res/po/fr_FR.po new file mode 100755 index 0000000..1ca6c92 --- /dev/null +++ b/res/po/fr_FR.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Libellés" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Tous les albums" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Aucun album" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Sélectionner libellés" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Créer un album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Impossible de renommer l'élément" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Aucun nom" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Aucun album sélectionné" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Aucun libellé sélectionné" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Sélectionner un élément" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Sélectionner un album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Réessayer ?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Nom déjà utilisé" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Entrée vide" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Paramètre d'entrée non valide" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Nv libellé" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Aucun tag" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotation à gauche" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotation à droite" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diaporama" + diff --git a/res/po/ga.po b/res/po/ga.po new file mode 100755 index 0000000..6f33824 --- /dev/null +++ b/res/po/ga.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Clibeanna" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Gach albam" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albaim" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Níl albaim ann" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Roghnaigh clibeanna" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Déan albam" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Ní féidir athainmniú" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Níl ainm ann" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Níor roghnaíodh albam" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Níl clib roghnaithe" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Roghnaigh mír" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Roghnaigh albam" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Atriail?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Ainm céanna in úsáid cheana" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Tá an iontráil folamh" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Paraiméadar ionchuir neamhbhailí" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Déan clib" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Níl clibeanna ann" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rothlaigh ar chlé" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rothlaigh ar dheis" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Sleamhnán" + diff --git a/res/po/gl.po b/res/po/gl.po new file mode 100755 index 0000000..f424871 --- /dev/null +++ b/res/po/gl.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etiquetas" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Todos os álbums" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Álbums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Non hai álbums" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Seleccionar etiquetas" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Crear álbum" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Non se pode cambiar o nome" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Sen nome" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Non hai ningún álbum seleccionado" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Non hai etiquetas seleccionadas" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Seleccionar elemento" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Seleccionar álbum" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Volver intentar?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Este nome xa está en uso" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "A entrada está baleira" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Parámetro de entrada non válido" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Crear etiq" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Ningunha etiqueta" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Xirar á esquerda" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Xirar á dereita" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diapos" + diff --git a/res/po/hi.po b/res/po/hi.po new file mode 100755 index 0000000..f336e53 --- /dev/null +++ b/res/po/hi.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "टैग्‍स" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "सभी एलबम्‍स" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "अल्बम्स" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "कोई एल्बम नहीं" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "टैग्स चुनें" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "अल्बम बनाएँ" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "नाम बदलने में अक्षम" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "नाम नहीं" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "कोई अल्बम चुना नहीं गया" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "कोई टैग्स चुने नहीं" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "मद चुनें" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "एल्बम चुनें" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "पुनः प्रयास करें?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "ऐसा ही नाम पहले से इस्तेमाल में है" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "प्रविष्टि खाली है" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "अमान्य इनपुट पैरामीटर" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "टैग बनाएँ" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "कोई टैग्स नहीं" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "बाएँ घुमाएँ" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "दाएँ घुमाएँ" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "स्लाइड शो" + diff --git a/res/po/hr.po b/res/po/hr.po new file mode 100755 index 0000000..2cdee41 --- /dev/null +++ b/res/po/hr.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Oznake" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Svi albumi" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumi" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Nema albuma" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Odaberite oznake" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Novi album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Nemoguće preimenovati" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nema imena" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nema odabranih albuma" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nema odabranih oznaka" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Odaberite stavku" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Odaberi album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Ponoviti?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Već postoji isto ime" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Unos prazan" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Neispravan ulazni parametar" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Nova oznaka" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Nema oznaka" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotiraj ulijevo" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotiraj udesno" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Prezentacija" + diff --git a/res/po/hu.po b/res/po/hu.po new file mode 100755 index 0000000..3455be1 --- /dev/null +++ b/res/po/hu.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Címkék" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Összes album" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumok" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Nincs album" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Jelöljön ki címkéket" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Album létrehozása" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Nem lehet átnevezni" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nincs név" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nincs kijelölt album" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nincs kiválasztott címke" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Elem kiválasztása" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Album kiválasztása" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Újra próbálkozik?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Már van ilyen név" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "A bejegyzés üres" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Érvénytelen bemeneti paraméter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Létrehozás" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Nincs címke" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Forgatás balra" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Forgatás jobbra" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diavet." + diff --git a/res/po/hy.po b/res/po/hy.po new file mode 100755 index 0000000..7b7aa34 --- /dev/null +++ b/res/po/hy.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Հայտանիշեր" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Բոլոր ալբոմները" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Ալբոմներ" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Ալբոմներ Õ¹Õ¯Õ¡Õ¶" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Ընտրել հատկորոշիչներ" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Ստեղծել Õ¡Õ¬Õ¢Õ¸Õ´" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Հնարավոր Õ¹Õ§ վերանվանել" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Անուն Õ¹Õ¯Õ¡" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Ոչ Õ´Õ« Õ¡Õ¬Õ¢Õ¸Õ´ Õ¹Õ« ընտրվել" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Հատկորոշիչներ Õ¹Õ¥Õ¶ ընտրվել" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Ընտրել տարրը" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Ընտրել Õ¡Õ¬Õ¢Õ¸Õ´" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Կրկին փորձե՞լ" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Նույն անունն արդեն օգտագործվում Õ§" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Գրառումը դատարկ Õ§" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Անվավեր ներածված պարամետր" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Ստեղծ ÕºÕ«Õ¿Õ¯" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Հատկորոշիչներ Õ¹Õ¯Õ¡Õ¶" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Պտտել Õ±Õ¡Õ­" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Պտտել Õ¡Õ»" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Սլյդ շոու" + diff --git a/res/po/is.po b/res/po/is.po new file mode 100755 index 0000000..6b2a9f3 --- /dev/null +++ b/res/po/is.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Merki" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Allar plötur" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Möppur" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Engar möppur" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Velja merki" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Búa til albúm" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Mistókst að breyta heiti" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Ekkert heiti" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Engar plötur valdar" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Engin merki valin" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Velja hlut" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Velja plötu" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Reyna aftur" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Þetta heiti er þegar í notkun" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Færsla er tóm" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Ógild ílagsfæribreyta" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Búa til" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Engin merki" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Snúið til vinstri" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Snúið til hægri" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Skyggnur" + diff --git a/res/po/it_IT.po b/res/po/it_IT.po new file mode 100755 index 0000000..69eab7e --- /dev/null +++ b/res/po/it_IT.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tag" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Tutti gli album" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Album" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Nessun album" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Seleziona tag" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Crea album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Impossibile rinominare" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nessun nome" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nessun album selezionato" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nessun tag selezionato" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Seleziona elemento" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Seleziona album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Riprovare?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Stesso nome già in uso" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Voce vuota" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Parametro inserimento non valido" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Crea tag" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Nessun tag" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Ruota a sinistra" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Ruota a destra" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Present." + diff --git a/res/po/ja_JP.po b/res/po/ja_JP.po new file mode 100755 index 0000000..5ccd0bf --- /dev/null +++ b/res/po/ja_JP.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "タグ" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "全アルバム" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "アルバム" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "アルバムがありません。" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "タグを選択" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "アルバム​作成" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "名前を変更できません。" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "名前なし" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "アルバムが選択されていません。" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "タグ​が​選択​されて​いません" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "アイテムを選択" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "アルバムを選択" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "やり直し​ます​か?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "同じ名前が既に使用されています" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "入力されていません。" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "入力パラメータが無効です。" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "タグ​作成" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "タグがありません。" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "左に回転" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "右に回転" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "スライドショー" + diff --git a/res/po/ka.po b/res/po/ka.po new file mode 100755 index 0000000..39abf4d --- /dev/null +++ b/res/po/ka.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "ტეგები" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "ყველა ალბომი" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "ალბომები" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "ალბომები არ არის" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "ჩანართების არჩევა" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "ალბომის შექმნა" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "სახელს ვერ შეცვლით" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "უსახელო" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "ალბომი არ არის არჩეული" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "ჩანართები არ არის არჩეული" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "ელემენტის არჩევა" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "ალბომის არჩევა" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "თავიდან ვცადო?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "იგივე სახელი უკვე გამოყენებულია" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "ცარიელი ჩანაწ." + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "შეყვანილი პარამეტრი არასწორია" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "ჩან.შექმნა" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "იარლიყები არაა" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "მარცხნივ მოტრიალება" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "მარჯვნივ მოტრიალება" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "სლაიდ–შოუ" + diff --git a/res/po/kk.po b/res/po/kk.po new file mode 100755 index 0000000..f65020c --- /dev/null +++ b/res/po/kk.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Белгілер" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Барлық альбомдар" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Альбомдар" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Альбомдар жоқ" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Тегтерді таңдау" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Альбом жасау" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Атын өзгерту мүмкін емес" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Ондай есім жоқ" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Альбомдар таңдалмады" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Ешқандай тег таңдалмады" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Элемент таңдау" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Альбом таңдау" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Қайталау керек пе?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Мұндай атау қолданыста бар" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Енгізбе бос" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Жарамсыз енгізу өлшемі" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Тег жасау" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Тегтер жоқ" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Солға бұру" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Оңға бұру" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Слайдшоу" + diff --git a/res/po/ko_KR.po b/res/po/ko_KR.po new file mode 100755 index 0000000..7583818 --- /dev/null +++ b/res/po/ko_KR.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "태그" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "모든 앨범" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "앨범" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "앨범이 없습니다" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "태그를 선택하세요" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "앨범 추가" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "이름을 변경할 수 없습니다" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "이름이 없습니다" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "선택된 앨범이 없습니다" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "선택된 태그가 없습니다" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "항목 선택" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "앨범 선택" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "다시 시도할까요?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "사용 중인 이름입니다" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "입력된 내용이 없습니다" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "입력값이 바르지 않습니다" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "태그 추가" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "태그 없음" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "왼쪽으로 회전" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "오른쪽으로 회전" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "슬라이드쇼" + diff --git a/res/po/lt.po b/res/po/lt.po new file mode 100755 index 0000000..88f2a12 --- /dev/null +++ b/res/po/lt.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Žymos" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Visi albumai" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumai" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Albumų nėra" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Pasirinkti žymas" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Sukurti albumą" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Neįmanoma pervardinti" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nėra vardo" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nėra pasirinktų albumų" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nėra pasirinktų žymų" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Pasirinkti elementą" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Pasirinkti albumą" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Bandyti dar kartą?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Toks pavadinimas jau yra" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Ä®raÅ¡as tuščias" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Netinkami įvestų duomenų nustatymai" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Kurti žymą" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Žymų nėra" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Sukti į kairę" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Sukti į deÅ¡inę" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Skaid.rod." + diff --git a/res/po/lv.po b/res/po/lv.po new file mode 100755 index 0000000..684a01f --- /dev/null +++ b/res/po/lv.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "AtzÄ«mes" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Visi albumi" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumi" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Nav albumu" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Izvēlēties atzÄ«mes" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Izveidot albumu" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Nevar pārdēvēt" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nav vārda" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nav izvēlēts neviens albums" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nav izvēlēta neviena atzÄ«me" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Izvēlieties vienumu" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Izvēlēties albumu" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Vai mēģināt vēlreiz?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Šāds nosaukums jau tiek lietots" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Ieraksts nav norādÄ«ts" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "NederÄ«gs ievades parametrs" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Izv. atz." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Nav atzÄ«mju" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Pagriezt pa kreisi" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Pagriezt pa labi" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slaidrāde" + diff --git a/res/po/mk.po b/res/po/mk.po new file mode 100755 index 0000000..ddf0d74 --- /dev/null +++ b/res/po/mk.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Ознаки" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Сите албуми" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Албуми" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Нема албуми" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Изберете ознаки" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Нов албум" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Не може да се преименува" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Нема име" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Не се избрани албуми" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Нема избрано ознаки" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Избери запис" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Избери албум" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Повторен обид?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Истото име веќе се користи" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Записот е празен" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Неважечки влезен параметар" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Напр.озн." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Нема ознаки" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Ротирај лево" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Ротирај десно" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Слајдови" + diff --git a/res/po/nb.po b/res/po/nb.po new file mode 100755 index 0000000..3e17f16 --- /dev/null +++ b/res/po/nb.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tagger" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Alle album" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Album" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Ingen album" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Velg tagger" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Lag album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Kan ikke gi nytt navn" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Ingen navn" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Ingen album valgt" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Ingen tagger valgt" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Velg objekt" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Velg album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Prøve pÃ¥ nytt?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Samme navn allerede i bruk" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Oppføringen er tom" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Ugyldig inndataparameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Oppr. tagg" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Ingen tagger" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Roter mot klokken" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Roter med klokken" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Bildevisn" + diff --git a/res/po/nl_NL.po b/res/po/nl_NL.po new file mode 100755 index 0000000..026621f --- /dev/null +++ b/res/po/nl_NL.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Tags" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Alle albums" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albums" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Geen albums" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Tags selecteren" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Album maken" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Kan de naam niet wijzigen" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Geen naam" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Geen albums geselecteerd" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Geen tags geselecteerd" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Item selecteren" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Album selecteren" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Opnieuw?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Naam is al in gebruik" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Geen gegevens" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Ongeldige invoerparameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Tag maken" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Geen tags" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Linksom draaien" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rechtsom draaien" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diashow" + diff --git a/res/po/pl.po b/res/po/pl.po new file mode 100755 index 0000000..9668ddc --- /dev/null +++ b/res/po/pl.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etykiety" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Wszystkie albumy" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumy" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Brak albumów" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Wybierz etykiety" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Utwórz album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Nie można zmienić nazwy" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Bez nazwy" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nie wybrano albumów" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nie wybrano etykiet" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Wybierz element" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Wybierz album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Spróbować ponownie?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Ta sama nazwa jest już w użyciu" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Wpis jest pusty" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Nieprawidłowy parametr wejściowy" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Utw.etyk." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Brak etykiet" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Obróć w lewo" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Obróć w prawo" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Pok. slajd" + diff --git a/res/po/pt_BR.po b/res/po/pt_BR.po new file mode 100755 index 0000000..1b46b0c --- /dev/null +++ b/res/po/pt_BR.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Marcas" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Todos os álbuns" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Álbuns" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Nenhum álbum" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Selecionar tags" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Criar álbum" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Impossível renomear" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Sem nome" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nenhum álbum selecionado" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nenhuma das etiquetas selecionadas" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Selecionar item" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Selecionar álbum" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Repetir?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "O mesmo nome já está sendo utilizado" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Entrada vazia" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Parâmetro de entrada inválido" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Criar tag" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Sem marcas" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Girar para a esquerda" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Girar para a direita" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Ver slides" + diff --git a/res/po/pt_PT.po b/res/po/pt_PT.po new file mode 100755 index 0000000..efac905 --- /dev/null +++ b/res/po/pt_PT.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etiquetas" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Todos os álbuns" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Álbuns" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Nenhuns álbuns" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Seleccionar etiquetas" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Criar álbum" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Impossível mudar nome" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Sem nome" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nenhuns álbuns seleccionados" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nenhumas etiquetas seleccionadas" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Seleccionar item" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Seleccionar álbum" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Tentar novamente?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Já está a ser utilizado o mesmo nome" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Entrada vazia" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Parâmetro de entrada inválido" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Criar etiq." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Sem etiquetas" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rodar para a esquerda" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rodar para a direita" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diaporama" + diff --git a/res/po/ro.po b/res/po/ro.po new file mode 100755 index 0000000..dd1f579 --- /dev/null +++ b/res/po/ro.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etichete" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Toate albumele" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albume" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Nu există albume" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Selectare etichete" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Creare album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Imposibil de redenumit" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nici un nume" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nu sunt albume selectate" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nu a fost selectată nicio etichetă" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "SelectaÅ£i elementul" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Selectare album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "ReîncercaÅ£i?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Acelaşi nume deja în uz" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "LocaÅ£ie liberă" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Parametru de intrare incorect" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Creare" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Nicio etichetă" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotire stânga" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotire dreapta" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Ex. diap." + diff --git a/res/po/ru_RU.po b/res/po/ru_RU.po new file mode 100755 index 0000000..2331f70 --- /dev/null +++ b/res/po/ru_RU.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Метки" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Все альбомы" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Альбомы" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Нет альбомов" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Выберите теги" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Создать альбом" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Невозможно переименовать" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Нет имени" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Альбомы не выбраны" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Не выбраны метки" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Выберите элемент" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Выберите альбом" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Повторить?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Имя уже используется" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Пустая запись" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Неверные параметры ввода" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Создать метку" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Нет меток" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Повернуть влево" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Повернуть вправо" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Слайд-шоу" + diff --git a/res/po/sk.po b/res/po/sk.po new file mode 100755 index 0000000..ad32b2a --- /dev/null +++ b/res/po/sk.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Značky" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "VÅ¡etky albumy" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumy" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Žiadne albumy" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "VybraÅ¥ značky" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "VytvoriÅ¥ album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Nedá sa premenovaÅ¥" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Žiadny názov" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Nie sú vybraté žiadne albumy" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Žiadne vybraté značky" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "VybraÅ¥ položku" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "VybraÅ¥ album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "OpakovaÅ¥?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Rovnaký názov sa už používa" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Prázdna položka" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Neplatný vstupný parameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Vytv. zn." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Žiadne značky" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "OtočiÅ¥ doľava" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "OtočiÅ¥ doprava" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Prezent." + diff --git a/res/po/sl.po b/res/po/sl.po new file mode 100755 index 0000000..80e5304 --- /dev/null +++ b/res/po/sl.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Oznake" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Vsi albumi" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumi" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Ni albumov" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Izberi oznake" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Ustvari album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Ni mogoče preimenovati" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Brez imena" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Ni izbranih albumov" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Ni izbranih oznak" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Izberi predmet" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Izberite album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Poskusim znova?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "XXX se že uporablja" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Prazen vnos" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Neveljaven vhodni parameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Ustv. ozn." + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Brez oznak" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Zavrti v levo" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Zavrti v desno" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Diaproj." + diff --git a/res/po/sr.po b/res/po/sr.po new file mode 100755 index 0000000..54b2164 --- /dev/null +++ b/res/po/sr.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Oznake" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Svi albumi" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albumi" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Nema albuma" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Izaberi oznake" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Kreiraj album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Nemoguće preimenovati" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nema imena" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Albumi nisu izabrani" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Nema izabranih oznaka" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Izaberi objekat" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Izaberi album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Ponovi?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Taj naziv je već u upotrebi" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Unos je prazan" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Neispravan ulazni parametar" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Označi" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Bez oznaka" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotiraj ulevo" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotiraj udesno" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slajd-Å¡ou" + diff --git a/res/po/sv.po b/res/po/sv.po new file mode 100755 index 0000000..da847be --- /dev/null +++ b/res/po/sv.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Taggar" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Alla album" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Album" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Inga album" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Välj taggar" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Skapa album" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Kan inte byta namn" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Inget namn" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Inga valda album" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Inga valda taggar" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Välj objekt" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Välj album" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Försök igen?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Detta namn används redan" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Posten är tom" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Felaktig indataparameter" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Skapa tagg" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Inga taggar" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Rotera moturs" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Rotera medurs" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Bildspel" + diff --git a/res/po/tr_TR.po b/res/po/tr_TR.po new file mode 100755 index 0000000..23a8cbf --- /dev/null +++ b/res/po/tr_TR.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Etiketler" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Tüm albümler" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albümler" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Albüm yok" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "İmleri seçin" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Albüm oluştur" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Yeniden adlandırılamıyor. Dosya kullanımda." + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "İsim yok" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Albüm seçilmedi" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "İm seçili değil" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Öğe seç" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Albüm seç" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Tekrar denensin mi?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "İsim zaten kullanımda" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Girdi yok" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Geçersiz giriş parametresi" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "İm oluştur" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Etiket yok" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Saat yönünün tersine döndür" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Saat yönünde döndür" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slayt şov" + diff --git a/res/po/uk.po b/res/po/uk.po new file mode 100755 index 0000000..cd1df36 --- /dev/null +++ b/res/po/uk.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Теги" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Усі альбоми" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Альбоми" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Немає альбомів" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Виберіть теги" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Створити альбом" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Неможливо перейменувати" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Немає імені" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Не вибрано альбомів" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Не вибрано тегів" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Виберіть елемент" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Вибір альбому" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Повторити?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Ім’я вже використовується" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Запис порожній" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Неправильний вхідний параметр" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Створ. тег" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Без тегів" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Обернути ліворуч" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "Обернути праворуч" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Слайд-шоу" + diff --git a/res/po/update-po.sh b/res/po/update-po.sh new file mode 100755 index 0000000..6e710ce --- /dev/null +++ b/res/po/update-po.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +PACKAGE=gallery +SRCROOT=.. +POTFILES=POTFILES.in + +#ALL_LINGUAS= am az be ca cs da de el en_CA en_GB es et fi fr hr hu it ja ko lv mk ml ms nb ne nl pa pl pt pt_BR ru rw sk sl sr sr@Latn sv ta tr uk vi zh_CN zh_TW +ALL_LINGUAS="en_US en_GB ja ko zh_CN" + +XGETTEXT=/usr/bin/xgettext +MSGMERGE=/usr/bin/msgmerge + +echo -n "Make ${PACKAGE}.pot " +if [ ! -e $POTFILES ] ; then + echo "$POTFILES not found" + exit 1 +fi + +$XGETTEXT --default-domain=${PACKAGE} --directory=${SRCROOT} \ + --add-comments --keyword=_ --keyword=N_ --files-from=$POTFILES +if [ $? -ne 0 ]; then + echo "xgettext error" + exit 1 +fi + +if [ ! -f ${PACKAGE}.po ]; then + echo "No such file: ${PACKAGE}.po" + exit 1 +fi + +rm -f ${PACKAGE}.pot && mv ${PACKAGE}.po ${PACKAGE}.pot +echo "done" + +for LANG in $ALL_LINGUAS; do + echo "$LANG : " + + if [ ! -e $LANG.po ] ; then + sed 's/CHARSET/UTF-8/g' ${PACKAGE}.pot > ${LANG}.po + echo "${LANG}.po created" + else + if $MSGMERGE ${LANG}.po ${PACKAGE}.pot -o ${LANG}.new.po ; then + if cmp ${LANG}.po ${LANG}.new.po > /dev/null 2>&1; then + rm -f ${LANG}.new.po + else + if mv -f ${LANG}.new.po ${LANG}.po; then + echo "" + else + echo "msgmerge for $LANG.po failed: cannot move $LANG.new.po to $LANG.po" 1>&2 + rm -f ${LANG}.new.po + exit 1 + fi + fi + else + echo "msgmerge for $LANG failed!" + rm -f ${LANG}.new.po + fi + fi + echo "" +done + diff --git a/res/po/uz.po b/res/po/uz.po new file mode 100755 index 0000000..e2d881d --- /dev/null +++ b/res/po/uz.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "Teglar" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "Barcha albomlar" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "Albom" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "Albomlar yo‘q" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "Teglarni tanlang" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "Albom yaratish" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "Nomini o‘zgartirib bo‘lmaydi" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "Nom yo‘q" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "Albom tanlanmagan" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "Hech qanday teg tanlanmagan" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "Element tanlang" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "Albom tanlash" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "Qayta urinib ko‘rilsinmi?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "Bunday nom avvaldan ishlatilmoqda" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "Kiritish bo‘sh" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "Noto‘g‘ri kiritish parametri" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "Teg yarat" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "Teglar yo‘q" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "Chapga aylantir." + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "O‘ngga aylantir." + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "Slayd-shou" + diff --git a/res/po/zh_CN.po b/res/po/zh_CN.po new file mode 100755 index 0000000..bc13eaa --- /dev/null +++ b/res/po/zh_CN.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "标签" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "所有相册" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "专辑" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "沒有专辑" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "选择标签" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "新建相册" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "无法重命名" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "无名称" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "未选择音乐库" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "没有选择标签" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "选择项目" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "选择相册" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "重试?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "相同名字已使用" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "空记录" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "输入参数无效" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "创建标签" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "无标签" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "向左旋转" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "向右旋转" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "幻灯片" + diff --git a/res/po/zh_HK.po b/res/po/zh_HK.po new file mode 100755 index 0000000..a9f1c78 --- /dev/null +++ b/res/po/zh_HK.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "標籤" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "全部專輯" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "專輯" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "無專輯" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "選擇標籤" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "建立相簿" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "無法重新命名" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "無名稱" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "未選擇專輯" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "標籤未選取" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "選擇項目" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "選擇專輯" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "要重試嗎?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "相同名稱已被使用" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "空白記錄" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "輸入參數無效" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "建立標籤" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "無標籤" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "左轉" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "右轉" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "投影片放映" + diff --git a/res/po/zh_SG.po b/res/po/zh_SG.po new file mode 100755 index 0000000..f43f61a --- /dev/null +++ b/res/po/zh_SG.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "标签" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "所有相册" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "相册" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "无相册" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "选择标签" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "新建相册" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "无法重命名" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "无名称" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "未选择音乐库" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "没有选择标签" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "选择项目" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "选择音乐库" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "重试?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "相同名称已在使用" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "空记录" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "输入参数无效" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "创建标签" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "无标签" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "向左旋转" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "向右旋转" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "幻灯片" + diff --git a/res/po/zh_TW.po b/res/po/zh_TW.po new file mode 100755 index 0000000..f6effe5 --- /dev/null +++ b/res/po/zh_TW.po @@ -0,0 +1,63 @@ +msgid "IDS_MEDIABR_BODY_TAGS" +msgstr "標籤" + +msgid "IDS_MEDIABR_BODY_ALL_ALBUMS" +msgstr "所有相簿" + +msgid "IDS_MEDIABR_BUTTON_ALBUMS" +msgstr "相簿" + +msgid "IDS_MEDIABR_BODY_NO_ALBUMS" +msgstr "無專輯" + +msgid "IDS_MEDIABR_BODY_SELECT_TAGS" +msgstr "選擇關鍵字" + +msgid "IDS_MEDIABR_OPT_CREATE_ALBUM" +msgstr "建立專輯" + +msgid "IDS_MEDIABR_POP_UNABLE_TO_RENAME" +msgstr "無法重新命名" + +msgid "IDS_MEDIABR_POP_NO_NAME" +msgstr "無姓名" + +msgid "IDS_MEDIABR_POP_NO_ALBUMS_SELECTED" +msgstr "未選擇相簿" + +msgid "IDS_MEDIABR_POP_NO_TAGS_SELECTED" +msgstr "沒有選擇標籤" + +msgid "IDS_MEDIABR_HEADER_SELECT_ITEM" +msgstr "選擇項目" + +msgid "IDS_MEDIABR_HEADER_SELECT_ALBUM" +msgstr "選擇專輯" + +msgid "IDS_MEDIABR_POP_RETRY_Q" +msgstr "要重試嗎?" + +msgid "IDS_MEDIABR_POP_SAME_NAME_ALREADY_IN_USE" +msgstr "相同名稱已在使用中" + +msgid "IDS_MEDIABR_POP_ENTRY_IS_EMPTY" +msgstr "項目為空" + +msgid "IDS_MEDIABR_POP_INVALID_INPUT_PARAMETER" +msgstr "輸入參數無效" + +msgid "IDS_MEDIABR_OPT_CREATE_TAG" +msgstr "建立標籤" + +msgid "IDS_MEDIABR_POP_NO_TAGS" +msgstr "無標籤" + +msgid "IDS_MEDIABR_OPT_ROTATE_LEFT" +msgstr "向左旋轉" + +msgid "IDS_MEDIABR_OPT_ROTATE_RIGHT" +msgstr "向右旋轉" + +msgid "IDS_MEDIABR_BUTTON_SLIDE_SHOW" +msgstr "投影片放映" + diff --git a/res/white_theme/edc/gallery-edc-res.h b/res/white_theme/edc/gallery-edc-res.h new file mode 100755 index 0000000..10b3a6d --- /dev/null +++ b/res/white_theme/edc/gallery-edc-res.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Definition of image path used in edc file */ + +/* gl-nocontents.edc */ +#define GALLERY_EDC_IMAGE_NOCONTENTS_PIC "T01_Nocontents_picture.png" + +/* gl-gengrid-item-albums.edc */ +#define GALLERY_EDC_IMAGE_MAIN_FOLDER_BG "T01_main_folder_bg.png" + +/* gl-gengrid-item-thumbview.edc */ +#define GALLERY_EDC_IMAGE_BUTTON_PLAY "T01_btn_play.png" + +/* gallery.edc */ +#define GALLERY_EDC_IMAGE_CONTROL_TABBAR_BG "00_winset_title_tabbar_bg.png" + +#define GALLERY_EDC_SOUND_TOUCH_30MS "S_Touch_30ms.wav" + +/* gl-check.edc */ +#define GALLERY_EDC_IMAGE_CHECK_BG "T01_checkbox.png" +#define GALLERY_EDC_IMAGE_CHECK_ALBUM_BG "T01_album_checkbox.png" +#define GALLERY_EDC_IMAGE_CHECK_BG_DIM "00_check_bg_dim.png" +#define GALLERY_EDC_IMAGE_CHECK_BG_CHECKING "T01_check.png" +#define GALLERY_EDC_IMAGE_CHECK_ALBUM_BG_CHECKING "T01_album_checkbox_check.png" +#define GALLERY_EDC_IMAGE_CHECK_GRID "T01_grid_select_check.png" + +/* gl-entry.edc */ +#define GALLERY_EDC_IMAGE_EDITFIELD_CLEAR "00_EditField_clear.png" +#define GALLERY_EDC_IMAGE_EDITFIELD_CLEAR_PRESS "00_EditField_clear_press.png" +#define GALLERY_EDC_IMAGE_SEARCH_INPUT_FIELD_BG "00_search_input_field_bg.png" + diff --git a/res/white_theme/edc/gallery.edc b/res/white_theme/edc/gallery.edc new file mode 100755 index 0000000..86ad471 --- /dev/null +++ b/res/white_theme/edc/gallery.edc @@ -0,0 +1,572 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define FONT_ROM "SLP:style=Roman" +#define FONT_MED "SLP:style=Medium" +#define INDICATOR_H 27 +#define NAVI_H 67 +#define GALLERY_EDC_COLOR_THEME_GRAY 91 91 91 255 +#define GALLERY_EDC_COLOR_BG 248 246 239 255 +#define ENTRY_H 112 +#define ENTRY_MAX_W 1280 +#define CONTROLBAR_LARGE_HEIGHT_INC 117 +#define CONTROLBAR_SMALL_HEIGHT_INC 98 +/* Set select all bg color same as genlist */ +#define GENLIST_SELECT_ALL_BG_COLOR 220 218 211 255 +#define SELECT_ALL_BG_COLOR GENLIST_SELECT_ALL_BG_COLOR +#define NAVIFRAME_TITLE_BG_COLOR_INC 248 246 239 255 +#define GENLIST_PART_BOTTOM_LINE_COLOR_VIDEO 82 82 82 255 +#define SELINFO_H 48 + +#include "gallery-edc-res.h" + +collections { +#include "gl-genlist-item-tags.edc" +#include "gl-genlist-sweep.edc" +#include "gl-gengrid-item-thumbview.edc" +#include "gl-gengrid-item-albums.edc" +#include "gl-check.edc" +#include "gl-nocontents.edc" +#include "gl-entry.edc" + + group { + name: "gallery/controlbar_layout"; + parts { + part { + name: "background"; + type, RECT; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; offset: 0 0; } + rel2 { relative: 1.0 1.0; offset: -1 -1; } + color: GALLERY_EDC_COLOR_BG; + } + + } + part { + name: "elm.swallow.tabbar"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + min: 0 CONTROLBAR_LARGE_HEIGHT_INC; + fixed: 1 1; + align: 0.5 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 0.0;} + } + description { + state: "landscape" 0.0; + inherit: "default" 0.0; + min: 0 CONTROLBAR_SMALL_HEIGHT_INC; + } + description { + state: "hide" 0.0; + inherit: "default" 0.0; + min: 0 0; + max: 0 0; + visible: 0; + } +#ifdef _USE_DALI + description { + state: "default_invisible" 0.0; + min: 0 CONTROLBAR_LARGE_HEIGHT_INC; + fixed: 1 1; + align: 0.5 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 0.0;} + visible: 0; + } + description { + state: "landscape_invisible" 0.0; + inherit: "default" 0.0; + min: 0 CONTROLBAR_SMALL_HEIGHT_INC; + visible: 0; + } +#endif + } + part { + name: "elm.swallow.content"; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 1.0; to: "elm.swallow.tabbar"; } + rel2 { relative: 1.0 1.0; } + } + description { + /* Tabbar hide, enlarge size to cover tabbar region */ + state: "fullscreen" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + } + } + programs + { + program { + name: "tabbar_default"; + signal: "elm,tabbar,state,default"; + source: "elm"; + transition: DECELERATE 0.5; + script { + set_state(PART:"elm.swallow.tabbar", "default", 0.0); + set_state(PART:"elm.swallow.content", "default", 0.0); + } + } + program { + name: "tabbar_landscape"; + signal: "elm,tabbar,state,landscape"; + source: "elm"; + script { + set_state(PART:"elm.swallow.tabbar", "landscape", 0.0); + set_state(PART:"elm.swallow.content", "default", 0.0); + } + } + program { + name: "tabbar_hide"; + signal: "elm,tabbar,state,hide"; + source: "elm"; + script { + set_state(PART:"elm.swallow.tabbar", "hide", 0.0); + set_state(PART:"elm.swallow.content", "fullscreen", 0.0); + } + } + } + } + + group { + name: "gallery/controlbar"; + parts { + part { + name: "background"; + type, RECT; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; offset: 0 0; } + rel2 { relative: 1.0 1.0; offset: -1 -1; } + color: 0 0 0 0 ; + } + + } + part { + name: "elm.tabbar.bg"; + //type: IMAGE; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + min: 0 0; + fixed: 1 1; + align: 0.5 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 0.0;} + //image.normal: GALLERY_EDC_IMAGE_CONTROL_TABBAR_BG; + color: NAVIFRAME_TITLE_BG_COLOR_INC; + } + description { + state: "show_port" 0.0; + inherit: "default" 0.0; + min: 0 CONTROLBAR_LARGE_HEIGHT_INC; + } + description { + state: "show_land" 0.0; + inherit: "default" 0.0; + min: 0 CONTROLBAR_SMALL_HEIGHT_INC; + } + } + part { + name: "selectall_bg"; + type: RECT; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + min: 0 112; + fixed: 0 1; + align: 0.5 0.0; + rel1 { relative: 0.0 1.0; to: "elm.tabbar.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.tabbar.bg"; } + color: 0 0 0 0; + } + description { + state: "visible" 0.0; + inherit: "default" 0.0; + color: SELECT_ALL_BG_COLOR; + } + description { + state: "visible_tag" 0.0; + inherit: "default" 0.0; + min: 0 TAG_ITEM_H; + color: SELECT_ALL_BG_COLOR; + } + } + part { + name: "selectall_bottom_line"; + type: RECT; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + min: 0 2; + fixed: 0 1; + align: 0.5 0.0; + rel1 { relative: 0.0 1.0; to: "selectall_bg"; } + rel2 { relative: 1.0 0.0; to: "background"; } + color: 0 0 0 0; + } + description { + state: "visible" 0.0; + inherit: "default" 0.0; + color: GENLIST_PART_BOTTOM_LINE_COLOR_VIDEO; + } + description { + state: "visible_tag" 0.0; + inherit: "default" 0.0; + color: GENLIST_PART_BOTTOM_LINE_COLOR_TAG; + + } + } + part { + name: "selectall_check_leftpadding"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + min: 16 0; + fixed: 1 0; + align: 0.0 0.0; + + color: 0 0 0 255; + visible: 0; + rel1 { relative: 0.0 0.0; to: "selectall_bg"; } + rel2 { relative: 0.0 1.0; to: "selectall_bg"; } + } + description { + state: "visible" 0.0; + inherit: "default" 0.0; + + } + + } + + part { + name: "selectall_check"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 0.5; + fixed: 1 1; + min: 42 42; + rel1 { relative: 1.0 0.0; to: "selectall_check_leftpadding"; } + rel2 { relative: 1.0 1.0; to: "selectall_check_leftpadding"; } + visible : 0; + + } + description { + state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + + } + + part { + name: "selectall_check_rightpadding"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + min: 16 0; + fixed: 1 0; + align: 0.0 0.0; + color: 0 0 0 0; + rel1 { relative: 1.0 0.0; to: "selectall_check"; } + rel2 { relative: 1.0 1.0; to: "selectall_check"; } + visible: 0; + } + description { + state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + + } + + part { + name: "selectall_text"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 0.5; + rel1 { relative: 1.0 0.0; to: "selectall_check_rightpadding"; } + rel2 { relative: 1.0 1.0; to: "selectall_bg"; } + color: 0 0 0 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 44; + text: ""; + align: 0.0 0.5; + } + visible: 0; + } + description { + state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + + part { + name: "selectall_inner"; + type: RECT; + mouse_events: 0; + scale: 1; + + description { + state: "defalut" 0.0; + min: 0 1; + fixed: 0 1; + align: 0.5 0.0; + rel1 { relative: 0.0 1.0; to: "selectall_bg"; } + rel2 { relative: 1.0 1.0; to: "selectall_bottom_line"; } + color: 90 90 90 0; + } + description { + state: "visible" 0.0; + inherit: "default" 0.0; + } + } + part { + name: "contents"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 1.0; to: "elm.tabbar.bg"; } + rel2 { relative: 1.0 1.0; } + } + description { + state: "edit" 0.0; + rel1 { relative: 0.0 1.0; to: "selectall_inner"; } + rel2 { relative: 1.0 1.0; } + } + } + part { + name: "elm.swallow.view"; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + description { + state: "edit" 0.0; + rel1 { relative: 0.0 1.0; to: "selectall_inner"; } + rel2 { relative: 1.0 1.0; } + } + description { //normal thumbnails view for 2d effect + state: "thumb_edit_2d" 0.0; + //min: 480 800-115; + //align: 0.5 1.0; + rel1 { relative: 0.0 0.0; offset: 0 55; } + rel2 { relative: 1.0 1.0;} + } + description { //move edit view up while selectioninfo shown + state: "moveup" 0.0; + rel1 { relative: 0.0 1.0; to: "selectall_inner"; } + rel2 { relative: 1.0 0.0; to: "elm.swallow.selinfo"; } + + } + } + part { + name: "elm.swallow.selinfo"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + min: 0 SELINFO_H; // bottom padding size for selectioninfo + fixed: 0 1; + align: 0.5 1.0; + rel1 { relative: 0.0 1.0; } + rel2 { relative: 1.0 1.0; } + visible: 0; + } + description { state: "show" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "elm.swallow.weblist_view"; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + } + } + } + + programs + { + program { + name: "swallow_view_default"; + signal: "elm,swallow_view,state,default"; + source: "elm"; + script { + set_state(PART:"elm.swallow.view", "default", 0.0); + } + } + program { + name: "swallow_view_edit"; + signal: "elm,swallow_view,state,edit"; + source: "elm"; + script { + set_state(PART:"elm.swallow.view", "edit", 0.0); + set_state(PART:"elm.swallow.selinfo", "default", 0.0); + } + } + program { + name: "selectall_show_after"; + action: STATE_SET "visible" 0.0; + target: "selectall_check_leftpadding"; + target: "selectall_check"; + target: "selectall_check_rightpadding"; + target: "selectall_text"; + target: "selectall_inner"; + } + program { + name: "selectall_show"; + signal: "selectall_show"; + source: "elm"; + action: STATE_SET "visible" 0.0; + target: "selectall_bg"; + target: "selectall_bottom_line"; + after: "selectall_show_after"; + } + program { + name: "selectall_show_tag"; + signal: "selectall_show_tag"; + source: "elm"; + action: STATE_SET "visible_tag" 0.0; + target: "selectall_bg"; + target: "selectall_bottom_line"; + after: "selectall_show_after"; + } + program { + name: "selectall_show_web"; + signal: "selectall_show_web"; + source: "elm"; + action: STATE_SET "visible_web" 0.0; + target: "selectall_bottom_line"; + after: "selectall_show_after"; + } + program { + name: "selectall_hide"; + signal: "selectall_hide"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "selectall_bg"; + target: "selectall_bottom_line"; + target: "selectall_check_leftpadding"; + target: "selectall_check"; + target: "selectall_check_rightpadding"; + target: "selectall_text"; + target: "selectall_inner"; + } + //emit signal to set checkbox state in .c codes + program { name: "selectall_bg_click2"; + signal: "mouse,clicked,1"; + source: "selectall_bg"; + action: SIGNAL_EMIT "elm,action,click" "selectall_bg"; + } + program { + name: "swallow_view_thumb_edit_2d"; + signal: "elm,swallow_view,state,thumb_edit_2d"; + source: "elm"; + script { + set_state(PART:"elm.swallow.view", "thumb_edit_2d", 0.0); + set_state(PART:"elm.swallow.selinfo", "default", 0.0); + } + } + program { + name: "swallow_view_moveup"; + signal: "elm,swallow_view,state,moveup"; + source: "elm"; + script { + set_state(PART:"elm.swallow.view", "moveup", 0.0); + set_state(PART:"elm.swallow.selinfo", "show", 0.0); + } + } + program { + name: "tabbar_bg_default"; + signal: "elm,tabbar_bg,state,hide"; + source: "elm"; + script { + set_state(PART:"elm.tabbar.bg", "default", 0.0); + } + } + program { + name: "tabbar_bg_show_port"; + signal: "elm,tabbar_bg,state,show_port"; + source: "elm"; + script { + set_state(PART:"elm.tabbar.bg", "show_port", 0.0); + } + } + program { + name: "tabbar_bg_show_land"; + signal: "elm,tabbar_bg,state,show_land"; + source: "elm"; + script { + set_state(PART:"elm.tabbar.bg", "show_land", 0.0); + } + } + } + } + group { name: "gl_bg_layout"; + parts { + part { name: "bg"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + color: 0 0 0 45; + } + } + part { name: "elm.swallow.image"; + type: SWALLOW; + description { state: "default" 0.0; + } + } + } + } +} + diff --git a/res/white_theme/edc/gl-check.edc b/res/white_theme/edc/gl-check.edc new file mode 100755 index 0000000..ccf6d26 --- /dev/null +++ b/res/white_theme/edc/gl-check.edc @@ -0,0 +1,969 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define CHECK_STYLE_DEFAULT_BG_NORMAL_MIN_MAX_INC 60 60 + +#define CHECK_DEFAULT_TEXT_NORMAL_COLOR_INC 255 255 255 255 +#define CHECK_DEFAULT_TEXT_PRESSED_COLOR_INC 255 255 255 255 +#define CHECK_DEFAULT_TEXT_DISABLED_COLOR_INC 136 136 136 136 + +//////////////////////////////////////////////////////////////////////////////////////// +// +// check default textblock style +// +/////////////////////////////////////////////////////////////////////////////////////// + styles { + style { name: "check_label_textblock_style"; + base: "font=SLP:style=Roman text_class=slp font_size=32 color=#ffffff wrap=char"; + tag: "br" "\n"; + tag: "ps" "ps"; + tag: "hilight" "+ font=SLP:style=Bold text_class=slp"; + tag: "b" "+ font=SLP:style=Bold text_class=slp"; + tag: "whitecolor" "+ color=#ffffff"; + tag: "tab" "\t"; + } + } + +#define CHECK_STATE_DEFAULT 0 +#define CHECK_STATE_VISIBLE 1 +#define CHECK_STATE_DISABLED_VISIBLE 2 +#define CHECK_STATE_DISABLED 3 + +//////////////////////////////////////////////////////////////////////////////// +#define CHECK_STYLE_DEFAULT(style_name, image_bg, image_checking, min_width, min_height) \ + group { name: "elm/check/base/"style_name; \ + images { \ + image: image_bg COMP; \ + image: GALLERY_EDC_IMAGE_CHECK_BG_DIM COMP; \ + image: image_checking COMP; \ + } \ + script { \ + public check_state = CHECK_STATE_DEFAULT; \ + } \ + parts { \ + part { name: "back_bg"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + rel2.relative: 0.0 1.0; \ + align: 0 0.5; \ + min: min_width min_height; \ + fixed: 1 0; \ + color: 0 0 0 0; \ + } \ + } \ + part { name: "bg"; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: CHECK_STYLE_DEFAULT_BG_NORMAL_MIN_MAX_INC; \ + max: CHECK_STYLE_DEFAULT_BG_NORMAL_MIN_MAX_INC; \ + fixed: 1 1; \ + rel1.to: "back_bg"; \ + rel2.to: "back_bg"; \ + image.normal: image_bg; \ + fill.smooth : 0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + image.normal: GALLERY_EDC_IMAGE_CHECK_BG_DIM; \ + fill.smooth : 0; \ + } \ + } \ + part { name: "check"; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + rel1.to: "bg"; \ + rel2.to: "bg"; \ + visible: 0; \ + image.normal: image_checking; \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + part { name: "elm.swallow.content"; \ + type: SWALLOW; \ + description { state: "default" 0.0; \ + fixed: 1 0; \ + visible: 0; \ + color: 255 255 255 255; \ + align: 0.0 0.5; \ + rel1 { \ + to_x: "bg"; \ + relative: 1.0 0.0; \ + offset: 1 1; \ + } \ + rel2 { \ + to_x: "bg"; \ + relative: 1.0 1.0; \ + offset: 2 -2; \ + } \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + fixed: 1 1; \ + visible: 1; \ + aspect: 1.0 1.0; \ + aspect_preference: VERTICAL; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + color: 128 128 128 128; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + color: 128 128 128 128; \ + fixed: 1 1; \ + visible: 1; \ + aspect: 1.0 1.0; \ + } \ + } \ + part { name: "elm.text"; \ + type: TEXTBLOCK; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + visible: 0; \ + fixed: 0 1; \ + rel1 { \ + relative: 1.0 0.5; \ + offset: 1 1; \ + to_x: "elm.swallow.content"; \ + } \ + rel2 { \ + relative: 1.0 0.5; \ + offset: -2 -2; \ + } \ + align: 0.0 0.5; \ + text { \ + style: "check_label_textblock_style"; \ + min: 0 0; \ + } \ + color: CHECK_DEFAULT_TEXT_NORMAL_COLOR_INC; \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + text.min: 1 1; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + text.min: 1 1; \ + color: CHECK_DEFAULT_TEXT_DISABLED_COLOR_INC; \ + } \ + } \ + part { name: "events1"; \ + type: RECT; \ + ignore_flags: ON_HOLD; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + } \ + } \ + part { name: "events2"; \ + type: RECT; \ + repeat_events: 1; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + } \ + } \ + part { name: "disabler"; \ + type: RECT; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + visible: 0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + } \ + programs { \ + program { name: "click"; \ + signal: "mouse,clicked,1"; \ + source: "events1"; \ + action: SIGNAL_EMIT "elm,action,check,toggle" ""; \ + } \ + program { name: "check_on"; \ + signal: "elm,state,check,on"; \ + source: "elm"; \ + script { \ + set_int(check_state, CHECK_STATE_VISIBLE); \ + set_state(PART:"check", "visible", 0.0); \ + } \ + } \ + program { name: "check_off"; \ + signal: "elm,state,check,off"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "check"; \ + script { \ + if (get_int(check_state) == CHECK_STATE_VISIBLE) \ + { \ + set_int(check_state, CHECK_STATE_DEFAULT); \ + set_state(PART:"check", "default", 0.0); \ + } \ + } \ + } \ + program { name: "text_show"; \ + signal: "elm,state,text,visible"; \ + source: "elm"; \ + action: STATE_SET "visible" 0.0; \ + target: "elm.text"; \ + } \ + program { name: "text_hide"; \ + signal: "elm,state,text,hidden"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text"; \ + } \ + program { name: "icon_show"; \ + signal: "elm,state,icon,visible"; \ + source: "elm"; \ + action: STATE_SET "visible" 0.0; \ + target: "elm.swallow.content"; \ + } \ + program { name: "icon_hide"; \ + signal: "elm,state,icon,hidden"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.swallow.content"; \ + } \ + program { name: "disable"; \ + signal: "elm,state,disabled"; \ + source: "elm"; \ + action: STATE_SET "disabled" 0.0; \ + target: "disabler"; \ + target: "bg"; \ + after: "disable_text"; \ + } \ + program { name: "disable_text"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.text", "disabled_visible", 0.0); \ + else \ + set_state(PART:"elm.text", "disabled", 0.0); \ + get_state(PART:"elm.swallow.content", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.swallow.content", "disabled_visible", 0.0); \ + else \ + set_state(PART:"elm.swallow.content", "disabled", 0.0); \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + { \ + set_state(PART:"check", "disabled_visible", 0.0); \ + set_int(check_state, CHECK_STATE_DISABLED_VISIBLE); \ + } \ + } \ + } \ + program { name: "enable"; \ + signal: "elm,state,enabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "disabler"; \ + target: "bg"; \ + after: "enable_text"; \ + } \ + program { name: "enable_text"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text", st, 30, vl); \ + if (!strcmp(st, "disabled_visible")) \ + set_state(PART:"elm.text", "visible", 0.0); \ + else \ + set_state(PART:"elm.text", "default", 0.0); \ + get_state(PART:"elm.swallow.content", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.swallow.content", "visible", 0.0); \ + else \ + set_state(PART:"elm.swallow.content", "default", 0.0); \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "disabled_visible")) \ + { \ + set_state(PART:"check", "visible", 0.0); \ + set_int(check_state, CHECK_STATE_VISIBLE); \ + } \ + else \ + set_int(check_state, CHECK_STATE_DEFAULT); \ + } \ + } \ + } \ + } + +//////////////////////////////////////////////////////////////////////////////// + CHECK_STYLE_DEFAULT("gallery/default", GALLERY_EDC_IMAGE_CHECK_BG, GALLERY_EDC_IMAGE_CHECK_BG_CHECKING, 42, 42) + +//////////////////////////////////////////////////////////////////////////////// + CHECK_STYLE_DEFAULT("gallery/album", GALLERY_EDC_IMAGE_CHECK_ALBUM_BG, GALLERY_EDC_IMAGE_CHECK_ALBUM_BG_CHECKING, 60, 60) + +//////////////////////////////////////////////////////////////////////////////// +#define CHECK_STYLE_GRID(style_name, image_grid, width, height) \ + group { name: "elm/check/base/"style_name; \ + images.image: image_grid COMP; \ + parts { \ + part { name: "bg"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + } \ + description { state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } \ + } \ + part { name: "icon_bg_img"; \ + type: RECT; \ + mouse_events: 0; \ + scale : 1; \ + description { \ + color: 0 0 0 0; \ + rel1 { relative: GAP_W/W (GAP_H+1)/H;} \ + rel2 { relative: (W-GAP_W)/W 1;} \ + } \ + } \ + part { name: "icon_bg"; \ + type: RECT; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + rel1 { relative: 0 0; to: "icon_bg_img"; } \ + rel2 { relative: 1 1; to: "icon_bg_img"; } \ + } \ + } \ + part { name: "bg2"; \ + type: RECT; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + rel1.to: "icon_bg"; \ + rel2.to: "icon_bg"; \ + align: 0.5 0.5; \ + min: width height; \ + max: width height; \ + color: 0 0 0 0; \ + } \ + description { state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } \ + } \ + part { name: "selected_bg"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + rel1.to: "icon_bg"; \ + rel2.to: "icon_bg"; \ + color: 0 0 0 0; \ + visible: 0; \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + color: 0 0 0 153; \ + visible: 1; \ + } \ + } \ + part { name: "check"; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + rel1.to: "bg2"; \ + rel2.to: "bg2"; \ + visible: 0; \ + image.normal: image_grid; \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + description { state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + part { name: "elm.swallow.content"; \ + type: SWALLOW; \ + description { \ + state: "default" 0.0; \ + fixed: 1 0; \ + visible: 0; \ + color: 255 255 255 255; \ + align: 0.0 0.5; \ + rel1 { \ + to_x: "bg2"; \ + relative: 1.0 0.0; \ + offset: 1 1; \ + } \ + rel2 { \ + to_x: "bg2"; \ + relative: 1.0 1.0; \ + offset: 2 -2; \ + } \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + fixed: 1 1; \ + visible: 1; \ + aspect: 1.0 1.0; \ + aspect_preference: VERTICAL; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + color: 128 128 128 128; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + color: 128 128 128 128; \ + fixed: 1 1; \ + visible: 1; \ + aspect: 1.0 1.0; \ + } \ + } \ + part { name: "elm.text"; \ + type: TEXTBLOCK; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + visible: 0; \ + fixed: 0 1; \ + rel1 { \ + relative: 1.0 0.5; \ + offset: 1 1; \ + to_x: "elm.swallow.content"; \ + } \ + rel2 { \ + relative: 1.0 0.5; \ + offset: -2 -2; \ + } \ + color: 255 255 255 255; \ + align: 0.0 0.5; \ + text { \ + style: "check_label_textblock_style"; \ + min: 0 0; \ + } \ + color: CHECK_DEFAULT_TEXT_NORMAL_COLOR_INC; \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + text.min: 1 1; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + text.min: 1 1; \ + color: CHECK_DEFAULT_TEXT_DISABLED_COLOR_INC; \ + } \ + } \ + part { name: "events"; \ + type: RECT; \ + ignore_flags: ON_HOLD; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + } \ + } \ + part { name: "disabler"; \ + type: RECT; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + visible: 0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + } \ + programs { \ + program { name: "click"; \ + signal: "mouse,up,1"; \ + source: "events"; \ + action: SIGNAL_EMIT "elm,action,check,toggle" ""; \ + after: "bg_normal"; \ + } \ + program { name: "bg_normal"; \ + script { \ + set_state(PART:"bg", "default", 0.0); \ + set_state(PART:"bg2", "default", 0.0); \ + } \ + } \ + program { name: "mouseout"; \ + signal: "mouse,out"; \ + source: "events"; \ + after: "bg_check_normal"; \ + } \ + program { name: "bg_check_normal"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "pressed")) \ + set_state(PART:"check", "visible", 0.0); \ + set_state(PART:"bg", "default", 0.0); \ + set_state(PART:"bg2", "default", 0.0); \ + } \ + } \ + program { name: "pressed"; \ + signal: "mouse,down,1"; \ + source: "events"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"check", "pressed", 0.0); \ + set_state(PART:"bg", "pressed", 0.0); \ + set_state(PART:"bg2", "pressed", 0.0); \ + } \ + } \ + program { name: "check_on"; \ + signal: "elm,state,check,on"; \ + source: "elm"; \ + action: STATE_SET "visible" 0.0; \ + target: "check"; \ + target: "selected_bg"; \ + } \ + program { name: "check_off"; \ + signal: "elm,state,check,off"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "check"; \ + target: "selected_bg"; \ + } \ + program { name: "text_show"; \ + signal: "elm,state,text,visible"; \ + source: "elm"; \ + action: STATE_SET "visible" 0.0; \ + target: "elm.text"; \ + } \ + program { name: "text_hide"; \ + signal: "elm,state,text,hidden"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text"; \ + } \ + program { name: "icon_show"; \ + signal: "elm,state,icon,visible"; \ + source: "elm"; \ + action: STATE_SET "visible" 0.0; \ + target: "elm.swallow.content"; \ + } \ + program { name: "icon_hide"; \ + signal: "elm,state,icon,hidden"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.swallow.content"; \ + } \ + program { name: "disable"; \ + signal: "elm,state,disabled"; \ + source: "elm"; \ + action: STATE_SET "disabled" 0.0; \ + target: "disabler"; \ + target: "bg"; \ + target: "bg2"; \ + after: "disable_text"; \ + } \ + program { name: "disable_text"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.text", "disabled_visible", 0.0); \ + else \ + set_state(PART:"elm.text", "disabled", 0.0); \ + get_state(PART:"elm.swallow.content", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.swallow.content", "disabled_visible", 0.0); \ + else \ + set_state(PART:"elm.swallow.content", "disabled", 0.0); \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"check", "disabled_visible", 0.0); \ + } \ + } \ + program { name: "enable"; \ + signal: "elm,state,enabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "disabler"; \ + target: "bg"; \ + target: "bg2"; \ + after: "enable_text"; \ + } \ + program { name: "enable_text"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text", st, 30, vl); \ + if (!strcmp(st, "disabled_visible")) \ + set_state(PART:"elm.text", "visible", 0.0); \ + else \ + set_state(PART:"elm.text", "default", 0.0); \ + get_state(PART:"elm.swallow.content", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.swallow.content", "visible", 0.0); \ + else \ + set_state(PART:"elm.swallow.content", "default", 0.0); \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "disabled_visible")) \ + set_state(PART:"check", "visible", 0.0); \ + } \ + } \ + } \ + } + +//////////////////////////////////////////////////////////////////////////////// + CHECK_STYLE_GRID("gallery/grid", GALLERY_EDC_IMAGE_CHECK_GRID, 64, 64) + +//////////////////////////////////////////////////////////////////////////////// + group { name: "elm/check/base/gallery/album/grid"; + parts { + part { name: "bg"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + color: 0 0 0 0; + } + description { state: "pressed" 0.0; + inherit: "default" 0.0; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "bg2"; + type: RECT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + align: 0.5 0.5; + min: 40 40; + max: 40 40; + color: 0 0 0 0; + } + description { state: "pressed" 0.0; + inherit: "default" 0.0; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "selected_bg"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + color: 0 0 0 0; + visible: 0; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + color: 0 0 0 153; + visible: 1; + } + } + part { name: "check"; + type: RECT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + rel1.to: "bg2"; + rel2.to: "bg2"; + color: 0 0 0 0; + visible: 0; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + } + description { state: "pressed" 0.0; + inherit: "default" 0.0; + } + description { state: "disabled_visible" 0.0; + inherit: "default" 0.0; + } + } + part { name: "elm.swallow.content"; + type: SWALLOW; + description { + state: "default" 0.0; + fixed: 1 0; + visible: 0; + color: 255 255 255 255; + align: 0.0 0.5; + rel1 { + to_x: "bg2"; + relative: 1.0 0.0; + offset: 1 1; + } + rel2 { + to_x: "bg2"; + relative: 1.0 1.0; + offset: 2 -2; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + fixed: 1 1; + visible: 1; + aspect: 1.0 1.0; + aspect_preference: VERTICAL; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 128 128 128 128; + } + description { state: "disabled_visible" 0.0; + inherit: "default" 0.0; + color: 128 128 128 128; + fixed: 1 1; + visible: 1; + aspect: 1.0 1.0; + } + } + part { name: "elm.text"; + type: TEXTBLOCK; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + visible: 0; + fixed: 0 1; + rel1 { + relative: 1.0 0.5; + offset: 1 1; + to_x: "elm.swallow.content"; + } + rel2 { + relative: 1.0 0.5; + offset: -2 -2; + } + color: 255 255 255 255; + align: 0.0 0.5; + text { + style: "check_label_textblock_style"; + min: 0 0; + } + color: CHECK_DEFAULT_TEXT_NORMAL_COLOR_INC; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + text.min: 1 1; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + } + description { state: "disabled_visible" 0.0; + inherit: "default" 0.0; + visible: 1; + text.min: 1 1; + color: CHECK_DEFAULT_TEXT_DISABLED_COLOR_INC; + } + } + part { name: "events"; + type: RECT; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + color: 0 0 0 0; + } + } + part { name: "disabler"; + type: RECT; + description { state: "default" 0.0; + color: 0 0 0 0; + visible: 0; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + } + programs { + program { name: "click"; + signal: "mouse,up,1"; + source: "events"; + action: SIGNAL_EMIT "elm,action,check,toggle" ""; + after: "bg_normal"; + } + program { name: "bg_normal"; + script { + set_state(PART:"bg", "default", 0.0); + set_state(PART:"bg2", "default", 0.0); + } + } + program { name: "mouseout"; + signal: "mouse,out"; + source: "events"; + after: "bg_check_normal"; + } + program { name: "bg_check_normal"; + script { + new st[31]; + new Float:vl; + get_state(PART:"check", st, 30, vl); + if (!strcmp(st, "pressed")) + set_state(PART:"check", "visible", 0.0); + set_state(PART:"bg", "default", 0.0); + set_state(PART:"bg2", "default", 0.0); + } + } + program { name: "pressed"; + signal: "mouse,down,1"; + source: "events"; + script { + new st[31]; + new Float:vl; + get_state(PART:"check", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"check", "pressed", 0.0); + set_state(PART:"bg", "pressed", 0.0); + set_state(PART:"bg2", "pressed", 0.0); + } + } + program { name: "check_on"; + signal: "elm,state,check,on"; + source: "elm"; + action: STATE_SET "visible" 0.0; + target: "check"; + target: "selected_bg"; + } + program { name: "check_off"; + signal: "elm,state,check,off"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "check"; + target: "selected_bg"; + } + program { name: "text_show"; + signal: "elm,state,text,visible"; + source: "elm"; + action: STATE_SET "visible" 0.0; + target: "elm.text"; + } + program { name: "text_hide"; + signal: "elm,state,text,hidden"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text"; + } + program { name: "icon_show"; + signal: "elm,state,icon,visible"; + source: "elm"; + action: STATE_SET "visible" 0.0; + target: "elm.swallow.content"; + } + program { name: "icon_hide"; + signal: "elm,state,icon,hidden"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.content"; + } + program { name: "disable"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "disabler"; + target: "bg"; + target: "bg2"; + after: "disable_text"; + } + program { name: "disable_text"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.text", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"elm.text", "disabled_visible", 0.0); + else + set_state(PART:"elm.text", "disabled", 0.0); + get_state(PART:"elm.swallow.content", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"elm.swallow.content", "disabled_visible", 0.0); + else + set_state(PART:"elm.swallow.content", "disabled", 0.0); + get_state(PART:"check", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"check", "disabled_visible", 0.0); + } + } + program { name: "enable"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "disabler"; + target: "bg"; + target: "bg2"; + after: "enable_text"; + } + program { name: "enable_text"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.text", st, 30, vl); + if (!strcmp(st, "disabled_visible")) + set_state(PART:"elm.text", "visible", 0.0); + else + set_state(PART:"elm.text", "default", 0.0); + get_state(PART:"elm.swallow.content", st, 30, vl); + if (!strcmp(st, "visible")) + set_state(PART:"elm.swallow.content", "visible", 0.0); + else + set_state(PART:"elm.swallow.content", "default", 0.0); + get_state(PART:"check", st, 30, vl); + if (!strcmp(st, "disabled_visible")) + set_state(PART:"check", "visible", 0.0); + } + } + } + } + +#undef CHECK_STATE_DEFAULT +#undef CHECK_STATE_VISIBLE +#undef CHECK_STATE_DISABLED_VISIBLE +#undef CHECK_STATE_DISABLED diff --git a/res/white_theme/edc/gl-entry.edc b/res/white_theme/edc/gl-entry.edc new file mode 100755 index 0000000..e80cc40 --- /dev/null +++ b/res/white_theme/edc/gl-entry.edc @@ -0,0 +1,714 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/* Refer to: "elm/layout/searchbar/cancel_button" */ + +#define ENTRY_TEXT_SIZE_INC 44 + +#define EDITFIELD_TITLE_SIZE_INC 32 +#define EDITFIELD_TITLE_COLOR_INC 124 124 124 255 +#define EDITFIELD_GUIDE_TEXT_COLOR_INC 144 169 199 255 + +#define SEARCHBAR_BACKGROUND_COLOR_INC 215 225 232 255 +#define SEARCHBAR_CANCEL_BUTTON_W_INC 134 +#define SEARCHBAR_CANCEL_BUTTON_WITH_PADDING_W_INC 150 +#define SEARCHBAR_CANCEL_BUTTON_WITH_DOUBLE_PADDING_W_INC 166 +#define SEARCHBAR_TOP_PADDING_INC 18 +#define SEARCHBAR_BOTTOM_PADDING_INC 18 +#define SEARCHBAR_HEIGHT_INC 74 +#define SEARCHBAR_LEFT_PADDING_INC 16 +#define SEARCHBAR_RIGHT_PADDING_INC 16 +#define SEARCHBAR_INPUTFIELD_BORDER_INC 6 6 6 6 +#define SEARCHBAR_LEFT_ICON_PADDING_INC 0 +#define SEARCHBAR_ICON_MIN_W_INC 42 +#define SEARCHBAR_ICON_MIN_H_INC 42 +#define SEARCHBAR_LEFT_PADDING_SEARCHFIELD_INC 16 +#define SEARCHBAR_RIGHT_PADDING_SEARCHFIELD_INC 8 +#define SEARCHBAR_SEARCH_TEXTFIELD_H_INC 60 + +#define EDITFIELD_SEARCHBAR_TOP1_SINGLE_INC 6 +#define EDITFIELD_SEARCHBAR_TOP1_MULTI_INC 10 +#define EDITFIELD_SEARCHBAR_TOP2_INC 10 +#define EDITFIELD_SEARCHBAR_LEFT1_INC 0 +#define EDITFIELD_SEARCHBAR_LEFT2_INC 0 +#define EDITFIELD_SEARCHBAR_RIGHT1_ERASER_SHOW_INC 56 +#define EDITFIELD_SEARCHBAR_RIGHT2_INC 5 +#define EDITFIELD_SEARCHBAR_BOTTOM1_SINGLE_INC 8 +#define EDITFIELD_SEARCHBAR_BOTTOM1_MULTI_INC 2 +#define EDITFIELD_SEARCHBAR_BOTTOM2_SINGLE_INC 16 +#define EDITFIELD_SEARCHBAR_BOTTOM2_MULTI_INC 2 +#define EDITFIELD_SEARCHBAR_BOTTOM3_SINGLE_INC 50 +#define EDITFIELD_SEARCHBAR_BOTTOM3_MULTI_INC 50 + +#define EDITFIELD_SEARCHBAR_ERASER_MINW_INC 38 +#define EDITFIELD_SEARCHBAR_ERASER_MINH_INC 38 +#define EDITFIELD_SEARCHBAR_ERASER_EVENT_MINW_INC 38 +#define EDITFIELD_SEARCHBAR_ERASER_EVENT_MINH_INC 50 + +group { name: "elm/layout/searchbar/gallery"; + images { + image: GALLERY_EDC_IMAGE_EDITFIELD_CLEAR COMP; + image: GALLERY_EDC_IMAGE_EDITFIELD_CLEAR_PRESS COMP; + image: GALLERY_EDC_IMAGE_SEARCH_INPUT_FIELD_BG COMP; + } + parts { + part { name: "top_padding_rect"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + min: 0 SEARCHBAR_TOP_PADDING_INC; + fixed: 0 1; + align: 0 0; + color: SEARCHBAR_BACKGROUND_COLOR_INC; + rel2.relative: 1.0 0.0; + } + } + part { name: "bottom_padding_rect"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + min: 0 SEARCHBAR_BOTTOM_PADDING_INC; + fixed: 0 1; + align: 0 1; + color: SEARCHBAR_BACKGROUND_COLOR_INC; + rel1.relative: 0.0 1.0; + } + } + part { name: "base_bg"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: 0 SEARCHBAR_HEIGHT_INC; + align: 0 0.5; + fixed: 0 1; + rel1 { + relative: 0.0 1.0; + to: "top_padding_rect"; + } + rel2 { + relative: 1.0 0.0; + to: "bottom_padding_rect"; + } + } + } + part { name: "left_padding_rect"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + min: SEARCHBAR_LEFT_PADDING_INC 0; + fixed: 1 0; + align: 0 0; + rel2.relative: 0.0 1.0; + color: SEARCHBAR_BACKGROUND_COLOR_INC; + } + } + part { name: "right_padding_rect"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + min: SEARCHBAR_RIGHT_PADDING_INC 0; + fixed: 1 0; + align: 1 0; + rel1.relative: 1.0 0.0; + color: SEARCHBAR_BACKGROUND_COLOR_INC; + } + } + part { name: "right_field_and_btn_padding_rect"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + min: SEARCHBAR_CANCEL_BUTTON_WITH_DOUBLE_PADDING_W_INC 0; + fixed: 1 0; + align: 1 0; + rel1.relative: 1.0 0.0; + color: SEARCHBAR_BACKGROUND_COLOR_INC; + } + } + part { name: "right_btn_padding_rect"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + min: SEARCHBAR_CANCEL_BUTTON_WITH_PADDING_W_INC 0; + fixed: 1 0; + align: 1 0; + rel1.relative: 1.0 0.0; + color: SEARCHBAR_BACKGROUND_COLOR_INC; + } + } + part { name: "inputfield_rect"; + type: IMAGE; + scale: 1; + description { state: "default" 0.0; + align: 0.0 0.5; + rel1 { + relative: 1.0 0.0; + to_x: "left_padding_rect"; + to_y: "base_bg"; + } + rel2 { + relative: 0.0 1.0; + to_x: "right_padding_rect"; + to_y: "base_bg"; + } + image { + normal: GALLERY_EDC_IMAGE_SEARCH_INPUT_FIELD_BG; + border: SEARCHBAR_INPUTFIELD_BORDER_INC; + } + } + description { state: "in" 0.0; + inherit: "default" 0.0; + rel2.to_x: "right_field_and_btn_padding_rect"; + } + } + part { name: "left_icon_padding_rect"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: SEARCHBAR_LEFT_ICON_PADDING_INC 0; + fixed: 1 0; + align: 0 0; + rel1.to: "inputfield_rect"; + rel2 { + relative: 0.0 1.0; + to: "inputfield_rect"; + } + } + } + part { name: "left_padding_search_textfield"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: SEARCHBAR_LEFT_PADDING_SEARCHFIELD_INC 0; + fixed: 1 0; + align: 0.0 0.5; + rel1 { + relative: 1.0 0.0; + to_x: "left_icon_padding_rect"; + to_y: "inputfield_rect"; + } + rel2 { + relative: 1.0 1.0; + to_x: "left_icon_padding_rect"; + to_y: "inputfield_rect"; + } + } + } + part { name: "right_padding_search_textfield"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: SEARCHBAR_RIGHT_PADDING_SEARCHFIELD_INC 0; + fixed: 1 0; + align: 1.0 0.5; + rel1 { + relative: 1.0 0.0; + to: "inputfield_rect"; + } + rel2 { + relative: 1.0 1.0; + to: "inputfield_rect"; + } + } + } + part { name: "search_textfield"; + type: RECT; + mouse_events: 1; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + color: 0 0 0 0; + min: 0 SEARCHBAR_SEARCH_TEXTFIELD_H_INC; + fixed: 0 1; + align: 0.0 0.5; + rel1 { + relative: 1.0 0.0; + to: "left_padding_search_textfield"; + } + rel2 { + relative: 0.0 1.0; + to: "right_padding_search_textfield"; + } + } + } + part { name: "button_cancel"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { state: "default" 0.0; + visible: 0; + fixed: 1 1; + min: SEARCHBAR_CANCEL_BUTTON_W_INC 0; + align: 0.0 0.5; + state: "default" 0.0; + rel1 { + relative: 1.0 1.0; + to_x: "base_bg"; + to_y: "top_padding_rect"; + } + rel2 { + relative: 1.0 0.0; + to_x: "base_bg"; + to_y: "bottom_padding_rect"; + } + } + description { state: "in" 0.0; + visible:1; + min: SEARCHBAR_CANCEL_BUTTON_W_INC 0; + align: 1.0 0.5; + rel1 { + relative: 0.0 1.0; + to_x: "right_btn_padding_rect"; + to_y: "top_padding_rect"; + } + rel2 { + relative: 0.0 0.0; + to_x: "right_padding_rect"; + to_y: "bottom_padding_rect"; + } + } + } + part { name: "top1"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: 0 EDITFIELD_SEARCHBAR_TOP1_SINGLE_INC; + fixed: 1 1; + rel1 { + relative: 0.0 0.0; + to: "search_textfield"; + } + rel2 { + relative: 1.0 0.0; + to: "search_textfield"; + } + align: 0.5 0; + } + description { state: "elm.text.show" 0.0; + inherit: "default" 0.0; + min: 0 EDITFIELD_SEARCHBAR_TOP1_MULTI_INC; + } + } + part { name: "top2"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: 0 EDITFIELD_SEARCHBAR_TOP2_INC; + fixed: 1 1; + rel1 { + relative: 0.0 0.0; + to: "search_textfield"; + } + rel2 { + relative: 1.0 0.0; + to: "search_textfield"; + } + align: 0.5 0; + } + } + part { name: "left1"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: EDITFIELD_SEARCHBAR_LEFT1_INC 0; + fixed: 1 1; + align: 0 0; + rel1 { + relative: 0.0 0.0; + to: "search_textfield"; + } + rel2 { + relative: 0.0 1.0; + to: "search_textfield"; + } + } + } + part { name: "left2"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: EDITFIELD_SEARCHBAR_LEFT2_INC 0; + fixed: 1 1; + align: 0 0; + rel1 { + relative: 0.0 0.0; + to: "search_textfield"; + } + rel2 { + relative: 0.0 1.0; + to: "search_textfield"; + } + } + } + part { name: "right1"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: EDITFIELD_SEARCHBAR_RIGHT1_ERASER_SHOW_INC 0; + fixed: 1 1; + align: 1 0; + rel1 { + relative: 1.0 0.0; + to: "search_textfield"; + } + rel2.to: "search_textfield"; + } + } + part { name: "right2"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: EDITFIELD_SEARCHBAR_RIGHT2_INC 0; + fixed: 1 1; + align: 1 0; + rel1 { + relative: 1.0 0.0; + to: "search_textfield"; + } + rel2.to: "search_textfield"; + } + } + part { name: "bottom1"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: 0 EDITFIELD_SEARCHBAR_BOTTOM1_SINGLE_INC; + fixed: 1 1; + align: 0 1; + rel1 { + relative: 0.0 1.0; + to: "search_textfield"; + } + rel2.to: "search_textfield"; + } + description { state: "elm.text.show" 0.0; + inherit: "default" 0.0; + min: 0 EDITFIELD_SEARCHBAR_BOTTOM1_MULTI_INC; + } + } + part { name: "bottom2"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: 0 EDITFIELD_SEARCHBAR_BOTTOM2_SINGLE_INC; + fixed: 0 1; + rel1 { + relative: 0.0 1.0; + to: "search_textfield"; + } + rel2.to: "search_textfield"; + align: 0 1; + } + description { state: "elm.text.show" 0.0; + inherit: "default" 0.0; + min: 0 EDITFIELD_SEARCHBAR_BOTTOM2_MULTI_INC; + } + } + part { name: "bottom3"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + min: 0 EDITFIELD_SEARCHBAR_BOTTOM3_SINGLE_INC; + fixed: 0 1; + rel1 { + relative: 0.0 1.0; + to: "search_textfield"; + } + rel2.to: "search_textfield"; + align: 0 1; + } + description { state: "elm.text.show" 0.0; + inherit: "default" 0.0; + min: 0 EDITFIELD_SEARCHBAR_BOTTOM3_MULTI_INC; + } + } + part { name: "elm.text"; + type: TEXT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + visible: 0; + align: 0.0 0.0; + min: 0 34; + fixed: 1 1; + rel1 { + relative: 1.0 1.0; + to_x: "left2"; + to_y: "top2"; + } + rel2 { + relative: 1.0 1.0; + to_x: "left2"; + to_y: "top2"; + } + color: EDITFIELD_TITLE_COLOR_INC; + text { + font: "SLP:style=Medium"; + size: EDITFIELD_TITLE_SIZE_INC; + min: 1 1; + align: 0.0 0.0; + text_class: "slp"; + } + } + description { state: "elm.text.show" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { name: "elm.guidetext"; + type: TEXT; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + align: 0.0 0.0; + fixed: 1 1; + rel1.to: "elm.swallow.content"; + rel2.to: "elm.swallow.content"; + color: EDITFIELD_GUIDE_TEXT_COLOR_INC; + text { + font: "SLP:style=Roman"; + size: ENTRY_TEXT_SIZE_INC; + min: 0 0; + align: 0.0 0.5; + text_class: "slp"; + } + } + description { state: "hidden" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { + name: "elm.swallow.content"; + type: SWALLOW; + scale: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; + min: 0 40; + rel1 { + relative : 1.0 1.0; + to_x: "left1"; + to_y: "top1"; + } + rel2 { + relative : 0.0 0.0; + to_x: "right1"; + to_y: "bottom1"; + } + align: 0.0 0.5; + } + } + part { name: "eraser_image"; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: EDITFIELD_SEARCHBAR_ERASER_MINW_INC EDITFIELD_SEARCHBAR_ERASER_MINH_INC; + fixed: 1 1; + align: 1 0.5; + rel1 { + relative: 0.0 0.5; + to_x : "right2"; + } + rel2 { + relative: 0.0 0.5; + to_x : "right2"; + } + } + description { state: "elm.eraser.show" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: GALLERY_EDC_IMAGE_EDITFIELD_CLEAR; + border: 10 10 10 10; + border_scale: 1; + } + } + description { + state: "elm.eraser.pressed" 0.0; + inherit: "default" 0.0; + visible: 1; + image { + normal: GALLERY_EDC_IMAGE_EDITFIELD_CLEAR_PRESS; + border: 8 8 8 8; + border_scale: 1; + } + } + } + part { name: "eraser"; + type: RECT; + scale: 1; + mouse_events: 1; + description { state: "default" 0.0; + visible: 0; + min: EDITFIELD_SEARCHBAR_ERASER_EVENT_MINW_INC EDITFIELD_SEARCHBAR_ERASER_EVENT_MINH_INC; + fixed: 1 1; + align: 1 0.5; + color: 0 0 0 0; + rel1 { + relative: 0.0 0.5; + to_x : "right2"; + } + rel2 { + relative: 0.0 0.5; + to_x : "right2"; + } + } + description { state: "elm.eraser.show" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + } + programs { + program { + name: "guidetext_show"; + signal: "elm,state,guidetext,show"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.guidetext"; + } + program { + name: "guidetext_hide"; + signal: "elm,state,guidetext,hide"; + source: "elm"; + action: STATE_SET "hidden" 0.0; + target: "elm.guidetext"; + } + program { + name: "eraser_show"; + signal: "elm,state,eraser,show"; + source: "elm"; + action: STATE_SET "elm.eraser.show" 0.0; + target: "eraser_image"; + target: "eraser"; + } + program { + name: "eraser_hide"; + signal: "elm,state,eraser,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "eraser_image"; + target: "eraser"; + } + program { + name: "label_show"; + signal: "elm,state,title,show"; + source: "elm"; + action: STATE_SET "elm.text.show" 0.0; + target: "elm.text"; + target: "top1"; + target: "bottom1"; + target: "bottom2"; + target: "bottom3"; + } + program { + name: "label_hide"; + signal: "elm,state,title,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text"; + target: "top1"; + target: "bottom1"; + target: "bottom2"; + target: "bottom3"; + } + program { + name: "eraser_clicked"; + signal: "mouse,clicked,1"; + source: "eraser"; + action: SIGNAL_EMIT "elm,eraser,clicked" "elm"; + } + program { + name: "bg_clicked"; + signal: "mouse,clicked,1"; + source: "search_textfield"; + action: SIGNAL_EMIT "elm,bg,clicked" "elm"; + } + program { name: "cancel_in"; + signal: "cancel,in"; + source: ""; + action: STATE_SET "in" 0.0; + target: "button_cancel"; + target: "inputfield_rect"; + transition: ACCELERATE 0.4; + } + program { name: "cancel_out"; + signal: "cancel,out"; + source: ""; + action: STATE_SET "default" 0.0; + target: "button_cancel"; + target: "inputfield_rect"; + transition: ACCELERATE 0.4; + } + program { name: "cancel_show"; + signal: "cancel,show"; + source: ""; + action: STATE_SET "in" 0.0; + target: "button_cancel"; + target: "inputfield_rect"; + } + program { name: "cancel_hide"; + signal: "cancel,hide"; + source: ""; + action: STATE_SET "default" 0.0; + target: "button_cancel"; + target: "inputfield_rect"; + } + program { + name: "eraser_pressed"; + signal: "mouse,down,1"; + source: "eraser"; + action: STATE_SET "elm.eraser.pressed" 0.0; + target: "eraser_image"; + } + program { + name: "eraser_unpressed"; + signal: "mouse,up,1"; + source: "eraser"; + action: STATE_SET "elm.eraser.show" 0.0; + target: "eraser_image"; + } + } +} + diff --git a/res/white_theme/edc/gl-gengrid-item-albums.edc b/res/white_theme/edc/gl-gengrid-item-albums.edc new file mode 100755 index 0000000..2427b97 --- /dev/null +++ b/res/white_theme/edc/gl-gengrid-item-albums.edc @@ -0,0 +1,377 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* 14 + 334 + 10 */ +#define ALBUM_ITEM_W 358 +/* 26 + 334 */ +#define ALBUM_ITEM_H 360 + +#define ALBUM_W 334 +#define ALBUM_H 334 + +#define ALBUM_GAP_L 12 +#define ALBUM_GAP_R 12 +#define ALBUM_GAP_T 26 + +#define ALBUM_ICON_W 318 +#define ALBUM_ICON_H 318 + +#define ALBUM_ICON_GAP_L 8 +#define ALBUM_ICON_GAP_R 8 +#define ALBUM_ICON_GAP_B 16 +#define ALBUM_ICON_PAD 3 + +#define ALBUM_TEXT_AREA_W 207 +#define ALBUM_TEXT_AREA_H 102 +#define ALBUM_TEXT_GAP_L 4 +#define ALBUM_TEXT_GAP_R 4 +#define ALBUM_TEXT_SNS_X 60 +#define ALBUM_TEXT_NAME_H 32 +#define ALBUM_TEXT_DATE_H 25 +#define ALBUM_PBAR_W 183 +#define ALBUM_PBAR_H 10 +#define ALBUM_PBAR_GAP_L 6 +#define ALBUM_PBAR_GAP_T 8 + +#define ALBUM_SNS_ICON_W 32 +#define ALBUM_SNS_ICON_H 32 + +#define ALBUM_RENAME_BTN_W 64 +#define ALBUM_RENAME_BTN_H 64 + +#define ALBUM_CHECKBOX_W 60 +#define ALBUM_CHECKBOX_H 60 +#define ALBUM_CHECKBOX_GAP_L 1 +#define ALBUM_CHECKBOX_GAP_T 8 + +#define ALBUM_ICON_BG_COLOR_INC 190 189 189 255 + +group { + name: "elm/gengrid/item/gallery/albums_view/default"; + + data.item: "texts" "elm.text.name elm.text.date elm.text.count"; + data.item: "contents" "elm.swallow.onlyicon label_bg"; + images { + image: GALLERY_EDC_IMAGE_MAIN_FOLDER_BG COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + color: 255 0 0 0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + } + part { name: "icon_bg_img"; + type: IMAGE; + mouse_events: 1; + scale : 1; + description { + min : ALBUM_W ALBUM_H; + state: "default" 0.0; + image { + normal : GALLERY_EDC_IMAGE_MAIN_FOLDER_BG; + } + rel1 { relative: ALBUM_GAP_L/ALBUM_ITEM_W ALBUM_GAP_T/ALBUM_ITEM_H; to:"bg"; } + rel2 { relative: (ALBUM_ITEM_W-ALBUM_GAP_R-1)/ALBUM_ITEM_W 1.0; to:"bg"; } + } + } + part { name: "icon_bg"; + type: RECT; + mouse_events: 1; + scale : 1; + description { + min : ALBUM_ICON_W ALBUM_ICON_H; + state: "default" 0.0; + color: ALBUM_ICON_BG_COLOR_INC; + rel1 { relative: ALBUM_ICON_GAP_L/ALBUM_ICON_W 0.0; to:"icon_bg_img"; } + rel2 { relative: (ALBUM_ICON_W-ALBUM_ICON_GAP_R+2)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_GAP_B+2)/ALBUM_ICON_H; to:"icon_bg_img"; } + } + } + part { + name: "elm.swallow.onlyicon"; + type: SWALLOW; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: (ALBUM_ICON_PAD/ALBUM_ICON_W) (ALBUM_ICON_PAD/ALBUM_ICON_H); to: "icon_bg"; } + rel2 { relative: (ALBUM_ICON_W-ALBUM_ICON_PAD)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_PAD)/ALBUM_ICON_H; to: "icon_bg"; } + } + } + part { + name: "label_bg"; + type: SWALLOW; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: (ALBUM_ICON_PAD/ALBUM_ICON_W) (ALBUM_ICON_PAD/ALBUM_ICON_H); offset: 0 0; to: "icon_bg"; } + rel2 { relative: ((ALBUM_ICON_PAD+ALBUM_TEXT_AREA_W-1)/ALBUM_ICON_W) ((ALBUM_ICON_PAD+ALBUM_TEXT_AREA_H-1)/ALBUM_ICON_H); offset: 0 0; to: "icon_bg"; } + } + } + part { + name: "edit_text_bg"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + visible: 0; + rel1 { relative: 0.0 0.0; to: "label_bg"; } + rel2 { relative: 1.0 1.0; to: "label_bg"; } + color: 100 100 100 100; + } + } + part { + name: "elm.text.date"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: ALBUM_TEXT_GAP_L/ALBUM_TEXT_AREA_W ALBUM_TEXT_NAME_H/ALBUM_TEXT_AREA_H; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W (ALBUM_TEXT_NAME_H+ALBUM_TEXT_DATE_H-1)/ALBUM_TEXT_AREA_H; to: "label_bg"; } + color: 190 190 190 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 22; + align: 0.0 0.5; + } + } + } + part { + name: "elm.text.count"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + rel1 { relative: ((ALBUM_TEXT_GAP_L+ALBUM_SNS_ICON_W+1)/ALBUM_TEXT_AREA_W) ALBUM_TEXT_SNS_X/ALBUM_TEXT_AREA_H; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W 1.0; to: "label_bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 38; + align: 1.0 0.5; + } + } + } + part { + name: "elm.text.name"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: ALBUM_TEXT_GAP_L/ALBUM_TEXT_AREA_W 0.0; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W (ALBUM_TEXT_NAME_H-1)/ALBUM_TEXT_AREA_H; to: "label_bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 28; + align: 0.0 0.5; + } + } + } + } +} + +group { + name: "elm/gengrid/item/gallery/albums_edit_view/default"; + data.item: "texts" "elm.text.name elm.text.date elm.text.count"; + data.item: "contents" "elm.swallow.onlyicon elm.swallow.end elm.swallow.check_grid label_bg elm.swallow.rename"; + images { + image: GALLERY_EDC_IMAGE_MAIN_FOLDER_BG COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + color: 255 0 0 0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + } + part { name: "icon_bg_img"; + type: IMAGE; + mouse_events: 1; + scale : 1; + description { + min : ALBUM_W ALBUM_H; + state: "default" 0.0; + image { + normal : GALLERY_EDC_IMAGE_MAIN_FOLDER_BG; + } + rel1 { relative: ALBUM_GAP_L/ALBUM_ITEM_W ALBUM_GAP_T/ALBUM_ITEM_H; to:"bg"; } + rel2 { relative: (ALBUM_ITEM_W-ALBUM_GAP_R-1)/ALBUM_ITEM_W 1.0; to:"bg"; } + } + } + part { name: "icon_bg"; + type: RECT; + mouse_events: 1; + scale : 1; + description { + min : ALBUM_ICON_W ALBUM_ICON_H; + state: "default" 0.0; + color: ALBUM_ICON_BG_COLOR_INC; + rel1 { relative: ALBUM_ICON_GAP_L/ALBUM_ICON_W 0.0; to:"icon_bg_img"; } + rel2 { relative: (ALBUM_ICON_W-ALBUM_ICON_GAP_R+2)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_GAP_B+2)/ALBUM_ICON_H; to:"icon_bg_img"; } + } + } + part { + name: "elm.swallow.onlyicon"; + type: SWALLOW; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: (ALBUM_ICON_PAD/ALBUM_ICON_W) (ALBUM_ICON_PAD/ALBUM_ICON_H); to: "icon_bg"; } + rel2 { relative: (ALBUM_ICON_W-ALBUM_ICON_PAD)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_PAD)/ALBUM_ICON_H; to: "icon_bg"; } + } + } + part { + name: "label_bg"; + type: SWALLOW; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: (ALBUM_ICON_PAD/ALBUM_ICON_W) (ALBUM_ICON_PAD/ALBUM_ICON_H); offset: 0 0; to: "icon_bg"; } + rel2 { relative: ((ALBUM_ICON_PAD+ALBUM_TEXT_AREA_W-1)/ALBUM_ICON_W) ((ALBUM_ICON_PAD+ALBUM_TEXT_AREA_H-1)/ALBUM_ICON_H); offset: 0 0; to: "icon_bg"; } + } + } + part { + name: "edit_text_bg"; + type: RECT; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + visible: 0; + rel1 { relative: 0.0 0.0; to: "label_bg"; } + rel2 { relative: 1.0 1.0; to: "label_bg"; } + color: 100 100 100 100; + } + } + part { + name: "elm.text.date"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: ALBUM_TEXT_GAP_L/ALBUM_TEXT_AREA_W ALBUM_TEXT_NAME_H/ALBUM_TEXT_AREA_H; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W (ALBUM_TEXT_NAME_H+ALBUM_TEXT_DATE_H-1)/ALBUM_TEXT_AREA_H; to: "label_bg"; } + color: 190 190 190 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 22; + align: 0.0 0.5; + } + } + } + part { + name: "elm.text.count"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + rel1 { relative: ((ALBUM_TEXT_GAP_L+ALBUM_SNS_ICON_W+1)/ALBUM_TEXT_AREA_W) ALBUM_TEXT_SNS_X/ALBUM_TEXT_AREA_H; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W 1.0; to: "label_bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 38; + align: 1.0 0.5; + } + } + } + part { + name: "elm.text.name"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: (ALBUM_TEXT_GAP_L+25)/ALBUM_TEXT_AREA_W 0.0; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W (ALBUM_TEXT_NAME_H-1)/ALBUM_TEXT_AREA_H; to: "label_bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 28; + align: 0.0 0.5; + } + } + } + part { + name: "elm.swallow.rename"; + type: SWALLOW; + description { + state: "default" 0.0; + min: ALBUM_RENAME_BTN_W ALBUM_RENAME_BTN_H; + max: ALBUM_RENAME_BTN_W ALBUM_RENAME_BTN_H; + rel1 { relative: (ALBUM_ICON_W-ALBUM_ICON_PAD-ALBUM_RENAME_BTN_W)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_PAD-ALBUM_RENAME_BTN_H)/ALBUM_ICON_H); to:"icon_bg"; } + rel2 { relative: (ALBUM_ICON_W-ALBUM_ICON_PAD)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_PAD)/ALBUM_ICON_H); to:"icon_bg"; } + } + } + part { + name: "elm.swallow.check_grid"; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + max : (ALBUM_ICON_W+2) (ALBUM_ICON_H+2); + rel1 { relative: (ALBUM_ICON_GAP_L-1)/ALBUM_ICON_W 0.0; to:"icon_bg_img"; } + rel2 { relative: (ALBUM_ICON_W-ALBUM_ICON_GAP_R+3)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_GAP_B+4)/ALBUM_ICON_H; to:"icon_bg_img"; } + } + } + part { + name: "elm.swallow.end"; + type: SWALLOW; + description { + state: "default" 0.0; + min: ALBUM_CHECKBOX_W ALBUM_CHECKBOX_H; + max: ALBUM_CHECKBOX_W ALBUM_CHECKBOX_H; + rel1 { relative: (ALBUM_CHECKBOX_GAP_L)/ALBUM_ITEM_W (ALBUM_CHECKBOX_GAP_T)/ALBUM_ITEM_H; to:"bg"; } + rel2 { relative: (ALBUM_CHECKBOX_GAP_L+ALBUM_CHECKBOX_W)/ALBUM_ITEM_W (ALBUM_CHECKBOX_GAP_T+ALBUM_CHECKBOX_H+1)/ALBUM_ITEM_H; to:"bg"; } + } + } + } +} + diff --git a/res/white_theme/edc/gl-gengrid-item-thumbview.edc b/res/white_theme/edc/gl-gengrid-item-thumbview.edc new file mode 100755 index 0000000..c536690 --- /dev/null +++ b/res/white_theme/edc/gl-gengrid-item-thumbview.edc @@ -0,0 +1,1014 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Grid item background size W: 10+158+10; H: 24+158 */ +#define W 178 +#define H 193 +#define GAP_W 2 +#define GAP_H 18 + +/* Favourites icon boundary size */ +#define FAVOR_ICON_W 30 +#define FAVOR_ICON_H 30 + +group { + name: "elm/gengrid/item/gallery/thumbnail_view/default"; + + data.item: "contents" "elm.swallow.icon elm.swallow.end"; + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 0; + rel1 { relative: 0.0 0.0; offset: 0 0;} + rel2 { relative: 1.0 1.0; offset: 0 0;} + } + } + part { + name: "icon_bg"; + type: RECT; + scale : 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + visible: 0; + color: 0 0 0 0; + rel1 { relative: 0.0 0.0;to:"bg"; } + rel2 { relative: 1.0 1.0;to:"bg"; } + + } + } + + part { + name: "elm.swallow.icon"; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + rel1 { relative: 0.0 0.0; to: "icon_bg"; } + rel2 { relative: 1.0 1.0; to: "icon_bg"; } + } + } + part { + name: "elm.swallow.end"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to: "elm.swallow.icon"; } + rel2 { relative: 1.0 1.0; to: "elm.swallow.icon"; } + } + } + } + + programs { + program { + name: "movedonw_bg"; + signal: "movedown,bg,show"; + source: "bg"; + action: STATE_SET "move_down" 0.0; + target: "bg"; + } + } +} + + + + +group +{ + name: "elm/gengrid/photoframe/default_layout"; + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + } + + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_favor"; + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "elm.swallow.favoricon"; + type: SWALLOW; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } +#endif + } + + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_video"; + images { + image: GALLERY_EDC_IMAGE_BUTTON_PLAY COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + part { + name: "elm.videoicon_bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } + part { + name: "elm.text.bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 0.0 1.0; + rel1 { relative: 1 0; to: "elm.videoicon_bg";} + rel2 { relative: (W-GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "elm.swallow.videoicon"; + type: IMAGE; + mouse_events: 0; + repeat_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel1 { relative: 0 0; to: "elm.videoicon_bg";} + rel2 { relative: 1 1; to: "elm.videoicon_bg";} + image.normal: GALLERY_EDC_IMAGE_BUTTON_PLAY; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + rel1 { relative: 0.0 0.0; to: "elm.text.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.text.bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: 26; + align: 0.9 0.5; + } + } + } + } + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_video_favor"; + images { + image: GALLERY_EDC_IMAGE_BUTTON_PLAY COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + part { + name: "elm.videoicon_bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "favoricon_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: 1 0; to: "elm.videoicon_bg";} + rel2 { relative: (FAVOR_ICON_W*2+GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } +#endif + part { + name: "elm.text.bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 0.0 1.0; +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + rel1 { relative: 1 0; to: "favoricon_bg";} +#else + rel1 { relative: 1 0; to: "elm.videoicon_bg";} +#endif + rel2 { relative: (W-GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "elm.swallow.videoicon"; + type: IMAGE; + mouse_events: 0; + repeat_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel1 { relative: 0 0; to: "elm.videoicon_bg";} + rel2 { relative: 1 1; to: "elm.videoicon_bg";} + image.normal: GALLERY_EDC_IMAGE_BUTTON_PLAY; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + rel1 { relative: 0.0 0.0; to: "elm.text.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.text.bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: 26; + align: 0.9 0.5; + } + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "elm.swallow.favoricon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: 0.0 0.0; to: "favoricon_bg"; } + rel2 { relative: 1.0 1.0; to: "favoricon_bg"; } + } + } +#endif + } + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_video_bookmark"; + images { + image: GALLERY_EDC_IMAGE_BUTTON_PLAY COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + part { + name: "elm.videoicon_bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "bookmarkicon_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: 1 0; to: "elm.videoicon_bg";} + rel2 { relative: (FAVOR_ICON_W*2+GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } +#endif + part { + name: "elm.text.bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 0.0 1.0; +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + rel1 { relative: 1 0; to: "bookmarkicon_bg";} +#else + rel1 { relative: 1 0; to: "elm.videoicon_bg";} +#endif + rel2 { relative: (W-GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "elm.swallow.videoicon"; + type: IMAGE; + mouse_events: 0; + repeat_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel1 { relative: 0 0; to: "elm.videoicon_bg";} + rel2 { relative: 1 1; to: "elm.videoicon_bg";} + image.normal: GALLERY_EDC_IMAGE_BUTTON_PLAY; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + rel1 { relative: 0.0 0.0; to: "elm.text.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.text.bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: 26; + align: 0.9 0.5; + } + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "elm.swallow.bookmarkicon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + visible: 1; + rel1 { relative: 0.0 0.0; to: "bookmarkicon_bg"; } + rel2 { relative: 1.0 1.0; to: "bookmarkicon_bg"; } + } + } +#endif + } + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_video_favor_bookmark"; + images { + image: GALLERY_EDC_IMAGE_BUTTON_PLAY COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + part { + name: "elm.videoicon_bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "favoricon_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: 1 0; to: "elm.videoicon_bg";} + rel2 { relative: (FAVOR_ICON_W*2+GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "bookmarkicon_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: 1 0; to: "favoricon_bg";} + rel2 { relative: (FAVOR_ICON_W*3+GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } +#endif + part { + name: "elm.text.bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 0.0 1.0; +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + rel1 { relative: 1 0; to: "bookmarkicon_bg";} +#else + rel1 { relative: 1 0; to: "elm.videoicon_bg";} +#endif + rel2 { relative: (W-GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "elm.swallow.videoicon"; + type: IMAGE; + mouse_events: 0; + repeat_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel1 { relative: 0 0; to: "elm.videoicon_bg";} + rel2 { relative: 1 1; to: "elm.videoicon_bg";} + image.normal: GALLERY_EDC_IMAGE_BUTTON_PLAY; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + rel1 { relative: 0.0 0.0; to: "elm.text.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.text.bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: 26; + align: 0.9 0.5; + } + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "elm.swallow.favoricon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: 0.0 0.0; to: "favoricon_bg"; } + rel2 { relative: 1.0 1.0; to: "favoricon_bg"; } + } + } + part { + name: "elm.swallow.bookmarkicon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + visible: 1; + rel1 { relative: 0.0 0.0; to: "bookmarkicon_bg"; } + rel2 { relative: 1.0 1.0; to: "bookmarkicon_bg"; } + } + } +#endif + } + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +/*106+2*/ +#define ZOOMED_W 108 +/*106+10*/ +#define ZOOMED_H 116 + +#define ZOOMED_GAP_H 10 +#define ZOOMED_GAP_W 2 + +group +{ + name: "elm/gengrid/photoframe/zoomed_default_layout"; + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: 0 0;} + rel2 { relative: (ZOOMED_W-ZOOMED_GAP_W)/ZOOMED_W (ZOOMED_H-ZOOMED_GAP_H)/ZOOMED_H;} + } + } + } + + programs { + + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + diff --git a/res/white_theme/edc/gl-genlist-item-tags.edc b/res/white_theme/edc/gl-genlist-item-tags.edc new file mode 100755 index 0000000..e07c696 --- /dev/null +++ b/res/white_theme/edc/gl-genlist-item-tags.edc @@ -0,0 +1,873 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define GENLIST_LIST_BG_COLOR GALLERY_EDC_COLOR_BG +#define GENLIST_LIST_PRESS_COLOR 87 135 194 255 +#define GENLIST_PART_BOTTOM_LINE_INC 169 169 169 255 +#define GENLIST_PART_DISCLIP_COLOR_INC 255 255 255 110 // alpha was 64 +#define GENLIST_PART_BOTTOM_LINE_COLOR_TAG 169 169 169 255 + +#define GENLIST_PART_BASE( param_item_height ) \ + part { name: "base"; \ + type: RECT; \ + repeat_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 param_item_height; \ + color: 0 0 0 0; \ + } \ + } + +#define GENLIST_PART_BASE_SWEEP_COLOR( param_item_height ) \ + part { name: "base"; \ + type: RECT; \ + repeat_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 param_item_height; \ + color: GENLIST_LIST_BG_COLOR; \ + } \ + } + +#define GENLIST_PART_BG_IMAGE \ + part { name: "bg_image"; \ + type: RECT; \ + clip_to: "disclip"; \ + mouse_events: 0; \ + description { state: "default" 0.0; \ + color: GENLIST_LIST_BG_COLOR; \ + } \ + description { state: "selected" 0.0; \ + inherit: "default" 0.0; \ + color: GENLIST_LIST_PRESS_COLOR; \ + } \ + } + +#define GENLIST_PART_BOTTOM_LINE_TAG \ + part { name: "bottom_line"; \ + type: RECT; \ + clip_to: "disclip"; \ + mouse_events: 0; \ + description { state: "default" 0.0; \ + min: 0 1; \ + fixed: 0 1; \ + visible: 1; \ + color: GENLIST_PART_BOTTOM_LINE_COLOR_TAG; \ + rel1 { \ + relative: 0.0 1.0; \ + offset: 0 -1; \ + } \ + } \ + } + +#define GENLIST_PART_PADDING_TOP( param_padding_size ) \ + part { name: "elm.padding.top"; \ + type: RECT; \ + scale: 1; \ + description { \ + state: "default" 0.0; \ + min: 0 param_padding_size; \ + fixed: 0 1; \ + visible: 0; \ + rel2.relative: 1.0 0.0; \ + align: 0.0 0.0; \ + } \ + } + +#define GENLIST_PART_PADDING_BOTTOM( param_padding_size ) \ + part { name: "elm.padding.bottom"; \ + type: RECT; \ + scale: 1; \ + description { \ + state: "default" 0.0; \ + min: 0 param_padding_size; \ + fixed: 0 1; \ + visible: 0; \ + rel1.relative: 0.0 1.0; \ + align: 0.0 1.0; \ + } \ + } + +#define GENLIST_PART_PADDING_LEFT( param_padding_size ) \ + part { name: "elm.padding.left"; \ + type: RECT; \ + scale: 1; \ + description { \ + state: "default" 0.0; \ + min: param_padding_size 0; \ + fixed: 1 0; \ + visible: 0; \ + rel2.relative: 0.0 1.0; \ + align: 0.0 0.0; \ + } \ + } + +#define GENLIST_PART_PADDING_RIGHT( param_padding_size ) \ + part { name: "elm.padding.right"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: param_padding_size 0; \ + fixed: 1 0; \ + visible: 0; \ + rel1.relative: 1.0 0.0; \ + align: 1.0 0.0; \ + } \ + } + +#define GENLIST_PART_DISCLIP \ + part { name: "disclip"; \ + type: RECT; \ + description { state: "default" 0.0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + color: GENLIST_PART_DISCLIP_COLOR_INC; \ + } \ + } + + +#define TAG_COLOR_GAP 190 189 189 255 +#define TAG_COLOR_TITLE 0 0 0 255 +#define TAG_COLOR_COUNT 124 124 124 255 +#define TAG_COLOR_RENAME_BG 255 255 255 255 +#define TAG_FONT_TITLE 44 +#define TAG_FONT_COUNT 32 + +#define TAG_ITEM_H 128 +#define TAG_PAD_L 16 +#define TAG_PAD_R 16 +#define TAG_PAD_ICON_R 16 +#define TAG_PAD_ICON_L 16 +#define TAG_PAD_RENAME_BTN_L 16 +#define TAG_ICON_BG_W 112 +#define TAG_ICON_BG_H 112 +#define TAG_INTER 2 +#define TAG_CHECKBOX_W 42 +#define TAG_CHECKBOX_H 42 +#define TAG_RENAME_BTN_W 64 +#define TAG_RENAME_BTN_H 64 +#define TAG_TITLE_H 64 +#define TAG_DURATION_H 48 +#define TAG_DURATION_W 72 +#define TAG_RENAME_BG_H 112 + +// genlist for tags view +group { name: "elm/genlist/item/tags_list/gallery/default"; + alias: "elm/genlist/item_odd/tags_list/gallery/default"; + + data.item: "stacking" "above"; + data.item: "selectraise" "on"; + data.item: "texts" "elm.text.title elm.text.tag_count"; + data.item: "contents" "elm.icon"; + data.item: "flips" "elm.flip.content"; + parts { + GENLIST_PART_BASE_SWEEP_COLOR( TAG_ITEM_H ) + GENLIST_PART_BG_IMAGE + GENLIST_PART_BOTTOM_LINE_TAG + GENLIST_PART_PADDING_LEFT( TAG_PAD_L ) + GENLIST_PART_PADDING_RIGHT( TAG_PAD_R ) + + part { name: "elm.padding.icon.right"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: TAG_PAD_ICON_R 0; + fixed: 1 0; + rel1 { + relative: 1.0 0.0; + to_x: "elm.icon"; + } + rel2 { + relative: 1.0 1.0; + offset: 0 0; + to_x: "elm.icon"; + } + color: 0 0 0 0; + align: 0.0 0.0; + } + } + part { name: "icon_bg"; + clip_to: "disclip"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: TAG_ICON_BG_W TAG_ICON_BG_H; + max: TAG_ICON_BG_W TAG_ICON_BG_H; + fixed: 1 1; + align: 0.0 0.5; + color: TAG_COLOR_GAP; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.left"; + } + rel2 { + relative: 1.0 1.0; + offset: 0 0; + to_x: "elm.padding.left"; + } + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + } + } +//tag thumbnail + part { name: "elm.icon"; + clip_to: "disclip"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + fixed: 1 1; + align: 0.5 0.5; + rel1 { + relative: TAG_INTER/TAG_ICON_BG_W TAG_INTER/TAG_ICON_BG_H; + to: "icon_bg"; + } + rel2 { + relative: (TAG_ICON_BG_W-TAG_INTER+1)/TAG_ICON_BG_W (TAG_ICON_BG_H-TAG_INTER+1)/TAG_ICON_BG_H; + to: "icon_bg"; + } + } + } +//tag name + part { name: "elm.text.title"; + clip_to: "disclip"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 0 TAG_TITLE_H; + fixed: 0 1; + align: 0.0 0.5; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.icon.right"; + } + rel2 { + relative: 0.0 1.0; + offset: 0 0; + to_x: "elm.text.tag_count"; + } + color: TAG_COLOR_TITLE; + text { + font: "SLP:style=Regular"; + text_class: "slp"; + size: TAG_FONT_TITLE; + min: 0 1; + align: 0.0 0.5; + } + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + +//tag count + part { name: "elm.text.tag_count"; + clip_to: "disclip"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: TAG_DURATION_W TAG_DURATION_H; + max: TAG_DURATION_W TAG_DURATION_H; + fixed: 1 0; + align: 1.0 0.5; + rel1 { + relative: 0.0 0.0; + to_x: "elm.padding.right"; + } + rel2 { + relative: 0.0 1.0; + to_x: "elm.padding.right"; + } + color: TAG_COLOR_COUNT; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: TAG_FONT_COUNT; + min: 0 1; + align: 1.0 0.5; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: TAG_COLOR_COUNT; + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "elm.flip.content.bg"; + clip_to: "disclip"; + type: RECT; + mouse_events: 1; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: 0 TAG_RENAME_BG_H; + fixed: 0 1; + align: 0 0.5; + color: TAG_COLOR_RENAME_BG; + rel1 { + relative: 1.0 0.0; + offset: 50 0; + to_x: "elm.padding.icon.right"; + to_y: "icon_bg"; + } + rel2 { + relative: 0.0 1.0; + offset: -50 0; + to_x: "elm.padding.right"; + to_y: "icon_bg"; + } + } + description { state: "flip_enabled" 0.0; + visible: 1; + min: 0 TAG_RENAME_BG_H; + fixed: 0 1; + align: 0 0.5; + color: TAG_COLOR_RENAME_BG; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.icon.right"; + to_y: "icon_bg"; + } + rel2 { + relative: 0.0 1.0; + offset: 0 0; + to_x: "elm.padding.right"; + to_y: "icon_bg"; + } + } + } + + part { name: "elm.flip.content"; + clip_to: "disclip"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: 0 TAG_RENAME_BG_H; + fixed: 0 1; + align: 0 0.5; + rel1 { + relative: 1.0 0.0; + offset: 50 0; + to_x: "elm.padding.icon.right"; + to_y: "icon_bg"; + } + rel2 { + relative: 0.0 1.0; + offset: -50 0; + to_x: "elm.padding.right"; + to_y: "icon_bg"; + } + } + description { state: "flip_enabled" 0.0; + visible: 1; + min: 0 TAG_RENAME_BG_H; + fixed: 0 1; + align: 0 0.5; + rel1 { + relative: 1.0 0.0; + offset: 5 0; + to_x: "elm.padding.icon.right"; + to_y: "icon_bg"; + } + rel2 { + relative: 0.0 1.0; + offset: -5 0; + to_x: "elm.padding.right"; + to_y: "icon_bg"; + } + } + } + + GENLIST_PART_DISCLIP + } + programs { + program { name: "go_active"; + signal: "elm,state,selected"; + source: "elm"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.flip.content", st, 30, vl); + if (!strcmp(st, "default")) + { + set_state(PART:"bg_image", "selected", 0.0); + set_state(PART:"elm.text.tag_count", "selected", 0.0); + set_state(PART:"elm.text.title", "selected", 0.0); + } + } + //action: STATE_SET "selected" 0.0; + //target: "bg_image"; + //target: "elm.text.tag_count"; + } + program { name: "go_passive"; + signal: "elm,state,unselected"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "bg_image"; + target: "elm.text.tag_count"; + target: "elm.text.title"; + transition: LINEAR 0.1; + } + program { name: "go_disabled"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "disclip"; + } + program { name: "go_enabled"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "disclip"; + } + program { name: "flip_enabled"; + signal: "elm,state,flip,enabled"; + source: "elm"; + action: STATE_SET "flip_enabled" 0.0; + target: "elm.text.tag_count"; + target: "elm.text.title"; + after: "enable_flip_mode_next"; + } + program { name: "enable_flip_mode_next"; + action: STATE_SET "flip_enabled" 0.0; + transition: DECELERATE 0.5; + target: "icon_bg"; + target: "elm.flip.content.bg"; + target: "elm.flip.content"; + } + program { name: "flip_disabled"; + signal: "elm,state,flip,disabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.flip.content"; + target: "elm.flip.content.bg"; + after: "disable_flip_mode_next"; + } + program { name: "disable_flip_mode_next"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "elm.text.tag_count"; + target: "elm.text.title"; + target: "icon_bg"; + } + } +} + +// genlist for tags edit view +group { name: "elm/genlist/item/tags_list_edit/gallery/default"; + alias: "elm/genlist/item_odd/tags_list_edit/gallery/default"; + + data.item: "stacking" "above"; + data.item: "selectraise" "on"; + data.item: "texts" "elm.text.title elm.text.tag_count"; + data.item: "contents" "elm.icon elm.swallow.checkbox elm.swallow.rename"; + data.item: "flips" "elm.flip.content"; + parts { + GENLIST_PART_BASE( TAG_ITEM_H ) + GENLIST_PART_BG_IMAGE + GENLIST_PART_BOTTOM_LINE_TAG + GENLIST_PART_PADDING_LEFT( TAG_PAD_L ) + GENLIST_PART_PADDING_RIGHT( TAG_PAD_R ) + +//checkbox + part { name: "elm.swallow.checkbox"; + clip_to: "disclip"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: TAG_CHECKBOX_W TAG_CHECKBOX_H; + max: TAG_CHECKBOX_W TAG_CHECKBOX_H; + fixed: 1 1; + align: 0.0 0.5; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.left"; + } + rel2 { + relative: 1.0 1.0; + offset: 0 0; + to_x: "elm.padding.left"; + } + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "elm.padding.icon.left"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: TAG_PAD_ICON_L 0; + fixed: 1 0; + rel1 { + relative: 1.0 0.0; + to_x: "elm.swallow.checkbox"; + } + rel2 { + relative: 1.0 1.0; + offset: 0 0; + to_x: "elm.swallow.checkbox"; + } + color: 0 0 0 0; + align: 0.0 0.0; + } + } + part { name: "elm.padding.icon.right"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: TAG_PAD_ICON_R 0; + fixed: 1 0; + rel1 { + relative: 1.0 0.0; + to_x: "elm.icon"; + } + rel2 { + relative: 1.0 1.0; + offset: 0 0; + to_x: "elm.icon"; + } + color: 0 0 0 0; + align: 0.0 0.0; + } + } + part { name: "icon_bg"; + clip_to: "disclip"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: TAG_ICON_BG_W TAG_ICON_BG_H; + max: TAG_ICON_BG_W TAG_ICON_BG_H; + fixed: 1 1; + align: 0.0 0.5; + color: TAG_COLOR_GAP; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.icon.left"; + } + rel2 { + relative: 1.0 1.0; + to_x: "elm.padding.icon.left"; + } + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.left"; + } + rel2 { + relative: 1.0 1.0; + to_x: "elm.padding.left"; + } + } + } +//tag thumbnail + part { name: "elm.icon"; + clip_to: "disclip"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + fixed: 1 1; + align: 0.5 0.5; + rel1 { + relative: TAG_INTER/TAG_ICON_BG_W TAG_INTER/TAG_ICON_BG_H; + to: "icon_bg"; + } + rel2 { + relative: (TAG_ICON_BG_W-TAG_INTER+1)/TAG_ICON_BG_W (TAG_ICON_BG_H-TAG_INTER+1)/TAG_ICON_BG_H; + to: "icon_bg"; + } + } + } +//tag name + part { name: "elm.text.title"; + clip_to: "disclip"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 0 TAG_TITLE_H; + fixed: 0 1; + align: 0.0 0.5; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.icon.right"; + } + rel2 { + relative: 0.0 1.0; + offset: 0 0; + to_x: "elm.text.tag_count"; + } + color: TAG_COLOR_TITLE; + text { + font: "SLP:style=Regular"; + text_class: "slp"; + size: TAG_FONT_TITLE; + min: 0 1; + align: 0.0 0.5; + } + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + +//rename button + part { name: "elm.swallow.rename"; + clip_to: "disclip"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: TAG_RENAME_BTN_W TAG_RENAME_BTN_H; + max: TAG_RENAME_BTN_W TAG_RENAME_BTN_H; + fixed: 1 0; + align: 1.0 0.5; + rel1 { + relative: 0.0 0.0; + to_x: "elm.padding.right"; + } + rel2 { + relative: 0.0 1.0; + to_x: "elm.padding.right"; + } + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "elm.padding.rename.left"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: TAG_PAD_RENAME_BTN_L 0; + fixed: 1 0; + visible: 0; + rel1 { + relative: 0.0 0.0; + to_x: "elm.swallow.rename"; + } + rel2 { + relative: 0.0 1.0; + to_x: "elm.swallow.rename"; + } + align: 1.0 0.0; + } + } +//tag count + part { name: "elm.text.tag_count"; + clip_to: "disclip"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: TAG_DURATION_W TAG_DURATION_H; + max: TAG_DURATION_W TAG_DURATION_H; + fixed: 1 0; + align: 1.0 0.5; + rel1 { + relative: 0.0 0.0; + to_x: "elm.padding.rename.left"; + } + rel2 { + relative: 0.0 1.0; + to_x: "elm.padding.rename.left"; + } + color: TAG_COLOR_COUNT; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: TAG_FONT_COUNT; + min: 0 1; + align: 1.0 0.5; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: TAG_COLOR_COUNT; + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "elm.flip.content.bg"; + clip_to: "disclip"; + type: RECT; + mouse_events: 1; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: 0 TAG_RENAME_BG_H; + fixed: 0 1; + align: 0 0.5; + color: TAG_COLOR_RENAME_BG; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.icon.right"; + to_y: "icon_bg"; + } + rel2 { + relative: 0.0 1.0; + offset: 0 0; + to_x: "elm.swallow.rename"; + to_y: "icon_bg"; + } + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + visible: 1; + rel2 { + relative: 0.0 1.0; + offset: 0 0; + to_x: "elm.padding.right"; + to_y: "icon_bg"; + } + } + } + + part { name: "elm.flip.content"; + clip_to: "disclip"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { state: "default" 0.0; + visible: 0; + min: 0 TAG_RENAME_BG_H; + fixed: 0 1; + align: 0 0.5; + rel1 { + relative: 1.0 0.0; + offset: 5 0; + to_x: "elm.padding.icon.right"; + to_y: "icon_bg"; + } + rel2 { + relative: 0.0 1.0; + offset: -5 0; + to_x: "elm.swallow.rename"; + to_y: "icon_bg"; + } + } + description { state: "flip_enabled" 0.0; + inherit: "default" 0.0; + visible: 1; + rel2 { + relative: 0.0 1.0; + offset: 0 0; + to_x: "elm.padding.right"; + to_y: "icon_bg"; + } + } + } + GENLIST_PART_DISCLIP + } + programs { + program { name: "go_active"; + signal: "elm,state,selected"; + source: "elm"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.flip.content", st, 30, vl); + if (!strcmp(st, "default")) + { + set_state(PART:"bg_image", "selected", 0.0); + set_state(PART:"elm.text.tag_count", "selected", 0.0); + set_state(PART:"elm.text.title", "selected", 0.0); + } + } + //action: STATE_SET "selected" 0.0; + //target: "bg_image"; + //target: "elm.text.tag_count"; + } + program { name: "go_passive"; + signal: "elm,state,unselected"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "bg_image"; + target: "elm.text.title"; + target: "elm.text.tag_count"; + transition: LINEAR 0.1; + } + program { name: "go_disabled"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "disclip"; + } + program { name: "go_enabled"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "disclip"; + } + program { name: "flip_enabled"; + signal: "elm,state,flip,enabled"; + source: "elm"; + action: STATE_SET "flip_enabled" 0.0; + target: "elm.text.tag_count"; + target: "elm.text.title"; + after: "enable_flip_mode_next"; + } + program { name: "enable_flip_mode_next"; + action: STATE_SET "flip_enabled" 0.0; + transition: DECELERATE 0.5; + target: "elm.swallow.checkbox"; + target: "elm.swallow.rename"; + target: "icon_bg"; + target: "elm.flip.content.bg"; + target: "elm.flip.content"; + } + program { name: "flip_disabled"; + signal: "elm,state,flip,disabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.flip.content"; + target: "elm.flip.content.bg"; + after: "disable_flip_mode_next"; + } + program { name: "disable_flip_mode_next"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "elm.swallow.rename"; + target: "elm.text.tag_count"; + target: "elm.text.title"; + target: "icon_bg"; + target: "elm.swallow.checkbox"; + } + } +} diff --git a/res/white_theme/edc/gl-genlist-sweep.edc b/res/white_theme/edc/gl-genlist-sweep.edc new file mode 100755 index 0000000..f4ae82d --- /dev/null +++ b/res/white_theme/edc/gl-genlist-sweep.edc @@ -0,0 +1,371 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define GENLIST_HEIGHT_113_INC 113 +#define GENLIST_HEIGHT_129_INC TAG_ITEM_H + +#define GENLIST_PADDING_6_INC 6 +#define GENLIST_PADDING_11_INC 11 +#define GENLIST_PADDING_13_INC 13 +#define GENLIST_PADDING_16_INC 16 + +#define GENLIST_FONT_32_INC 32 +#define GENLIST_FONT_44_INC 44 + +#define GENLIST_SIZE_13_INC 13 +#define GENLIST_SIZE_16_INC 16 +#define GENLIST_SIZE_45_INC 45 +#define GENLIST_SIZE_56_INC 56 +#define GENLIST_SIZE_57_INC 57 +#define GENLIST_SIZE_SLIDE_60_INC 60 +#define GENLIST_SIZE_SLIDE_165_INC 165 +#define GENLIST_SIZE_SLIDE_220_INC 220 +#define GENLIST_SIZE_390_INC 390 + +#define GENLIST_TREESIZE_32_INC 32 + +#define GENLIST_PART_SLIDE_TEXT_COLOR_INC 0 0 0 255 + +#define GENLIST_SWEEP_BG_COLOR_INC GENLIST_LIST_BG_COLOR + +#define SWEEP_ICON_112_W 112 +#define SWEEP_INTER_2_W 2 +#define SWEEP_COLOR_GAP 190 189 189 255 + + group { name: "elm/genlist/item/mode/gallery/slide2_tag/default"; + alias: "elm/genlist/item_odd/mode/gallery/slide2_tag/default"; + alias: "elm/genlist/item_compress/mode/gallery/slide2_tag/default"; + alias: "elm/genlist/item_compress_odd/mode/gallery/slide2_tag/default"; + data.item: "stacking" "above"; + data.item: "selectraise" "on"; + data.item: "texts" "elm.slide.text.1"; + data.item: "contents" "elm.slide.swallow.1 elm.slide.swallow.2 elm.slide.icon"; + data.item: "mode_part" "elm.swallow.origin"; + data.item: "treesize" "GENLIST_TREESIZE_32_INC"; + + parts { + part { name: "base"; + type: RECT; + clip_to: "disclip"; + scale: 1; + description { state: "default" 0.0; + min: 0 GENLIST_HEIGHT_129_INC; + color: GENLIST_SWEEP_BG_COLOR_INC; + } + } + part { name: "bottom_line"; + type: RECT; + clip_to: "disclip"; + mouse_events: 0; + description { state: "default" 0.0; + min: 0 1; + fixed: 0 1; + visible: 1; + color: GENLIST_PART_BOTTOM_LINE_INC; + rel1 { + relative: 0.0 1.0; + offset: 0 -1; + to: "base"; + } + rel2.to: "base"; + } + } + part { name: "base.padding.left"; + type: RECT; + clip_to: "disclip"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: GENLIST_SIZE_16_INC 0; + fixed: 1 0; + visible: 0; + align: 0 0.5; + rel1.to: "base"; + rel2 { + relative: 0 1; + to: "base"; + } + } + } + part { name: "base.padding.right"; + type: RECT; + clip_to: "disclip"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: GENLIST_SIZE_16_INC 0; + fixed: 1 0; + visible: 0; + align: 1 0.5; + rel1 { + relative: 1 0; + to: "base"; + } + rel2.to: "base"; + } + } + part { name: "base.padding.icon"; + type: RECT; + clip_to: "disclip"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: SWEEP_ICON_112_W 0; + fixed: 1 0; + visible: 0; + align: 1 0.5; + rel1.to: "base.padding.right"; + rel2 { + relative: 0 1; + to: "base.padding.right"; + } + } + } + part { name: "base.padding.icon.left"; + type: RECT; + clip_to: "disclip"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: GENLIST_SIZE_16_INC 0; + fixed: 1 0; + visible: 0; + align: 1 0.5; + rel1.to: "base.padding.icon"; + rel2 { + relative: 0 1; + to: "base.padding.icon"; + } + } + } + part { name: "base.padding.bottom"; + type: RECT; + clip_to: "disclip"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 0 GENLIST_PADDING_11_INC; + fixed: 0 1; + visible: 0; + align: 0.5 1; + rel1 { + relative: 0 1; + to: "base"; + } + rel2 { + relative: 1 1; + to: "base"; + } + } + } + part { name: "elm.slide.text.1"; + type: TEXT; + clip_to: "disclip"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 0 GENLIST_SIZE_56_INC; + fixed: 0 1; + align: 0.5 0; + rel1 { + relative: 1 0; + to_x: "base.padding.left"; + to_y: "base"; + } + rel2 { + relative: 0 0; + to_x: "base.padding.icon.left"; + to_y: "base"; + } + color: GENLIST_PART_SLIDE_TEXT_COLOR_INC; + text { + font: "SLP:style=Roman"; + text_class: "slp"; + size: GENLIST_FONT_32_INC; + min: 0 1; + align: 0.5 0.5; + } + } + } + part { name: "base.padding.center"; + type: RECT; + clip_to: "disclip"; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: GENLIST_SIZE_16_INC 0; + fixed: 1 0; + visible: 0; + align: 0.5 0.5; + rel1 { + relative: 0.5 0; + to_x: "elm.slide.text.1"; + to_y: "base"; + } + rel2 { + relative: 0.5 1; + to_x: "elm.slide.text.1"; + to_y: "base"; + } + } + } + part { name: "elm.slide.swallow.1"; + type: SWALLOW; + clip_to: "disclip"; + description { state: "default" 0.0; + rel1 { + relative: 1 1; + to_x: "base.padding.left"; + to_y: "elm.slide.text.1"; + } + rel2 { + relative: 0 0; + to_x: "base.padding.center"; + to_y: "base.padding.bottom"; + } + } + } + part { name: "elm.slide.swallow.2"; + type: SWALLOW; + clip_to: "disclip"; + description { state: "default" 0.0; + rel1 { + relative: 1 1; + to_x: "base.padding.center"; + to_y: "elm.slide.text.1"; + } + rel2 { + relative: 0 0; + to_x: "base.padding.icon.left"; + to_y: "base.padding.bottom"; + } + } + } + + part { name: "elm.slide.icon_bg"; + clip_to: "disclip"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: TAG_ICON_BG_W TAG_ICON_BG_H; + max: TAG_ICON_BG_W TAG_ICON_BG_H; + fixed: 1 1; + align: 0.0 0.5; + color: SWEEP_COLOR_GAP; + rel1 { + relative: 0.0 0.0; + to: "base.padding.icon"; + } + rel2 { + relative: 1.0 1.0; + offset: 0 0; + to: "base.padding.icon"; + } + } + } + part { name: "elm.slide.icon"; + clip_to: "disclip"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + fixed: 1 1; + align: 0.5 0.5; + rel1 { + relative: SWEEP_INTER_2_W/SWEEP_ICON_112_W SWEEP_INTER_2_W/SWEEP_ICON_112_W; + to: "elm.slide.icon_bg"; + } + rel2 { + relative: (SWEEP_ICON_112_W-SWEEP_INTER_2_W+1)/SWEEP_ICON_112_W (SWEEP_ICON_112_W-SWEEP_INTER_2_W+1)/SWEEP_ICON_112_W; + to: "elm.slide.icon_bg"; + } + } + } + // Transparent part between base parts and slidable parts + part { name: "event_block_layer"; + type: RECT; + clip_to: "disclip"; + mouse_events: 1; + description { state: "default" 0.0; + rel1.to: "base"; + rel2.to: "base"; + color: 0 0 0 0; + } + description { state: "repeat_events" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + // Swallow part for original genlist item style + part { name: "elm.swallow.origin"; + clip_to: "disclip"; + type: SWALLOW; + description { state: "default" 0.0; + } + description { state: "slide" 0.0; + inherit: "default" 0.0; + rel1.relative: 1 0; + rel2.relative: 2 1; + } + } + part { name: "disclip"; + type: RECT; + description { state: "default" 0.0; + rel1.to: "base"; + rel2.to: "base"; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: GENLIST_PART_DISCLIP_COLOR_INC; + } + } + } + programs { + program { + name: "slide_right"; + signal: "elm,state,slide,active"; + source: "elm"; + action: STATE_SET "slide" 0.0; + target: "elm.swallow.origin"; + transition: ACCELERATE 0.5; + after: "unblock_event"; + } + program { + name: "unblock_event"; + action: STATE_SET "repeat_events" 0.0; + target: "event_block_layer"; + } + program { + name: "slide_left"; + signal: "elm,state,slide,passive"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "event_block_layer"; + after: "slide_left2"; + } + program { + name: "slide_left2"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.origin"; + transition: DECELERATE 0.5; + after: "slide_left_finished"; + } + program { + name: "slide_left_finished"; + action: SIGNAL_EMIT "elm,state,slide,passive,finished" "elm"; + } + } + } + diff --git a/res/white_theme/edc/gl-nocontents.edc b/res/white_theme/edc/gl-nocontents.edc new file mode 100755 index 0000000..e54cb58 --- /dev/null +++ b/res/white_theme/edc/gl-nocontents.edc @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define NOCONTENT_TEXT_BLOCK_TEXT_SIZE_INC 32 +#define NOCONTENT_TEXT_BLOCK_STYLE_COLOR_INC 173 170 165 255 + + group { + name: "elm/layout/nocontents/gallery"; + styles{ + style { name: "nocontent_style"; + base: "font=SLP:style=Roman text_class=slp font_size="NOCONTENT_TEXT_BLOCK_TEXT_SIZE_INC" align=center color=#ffffff wrap=word"; + tag: "br" "\n"; + tag: "hilight" "+ font=SLP:style=Bold text_class=slp"; + tag: "b" "+ font=SLP:style=Bold text_class=slp"; + tag: "tab" "\t"; + } + } + images { + image: GALLERY_EDC_IMAGE_NOCONTENTS_PIC COMP; + } + parts { + part { name: "bg"; + scale: 1; + type: RECT; + description { state: "default" 0.0; + visible: 1; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + } + part { name: "nocontents.image"; + description { state: "default" 0.0; + visible: 1; + align: 0.5 0.0; + rel1 { relative: 203/720 296/1016; to: "bg";} + rel2 { relative: (203+314)/720 (296+310)/1016; to: "bg";} + image { + normal: GALLERY_EDC_IMAGE_NOCONTENTS_PIC; + border: 1 1 1 1; + border_scale: 1; + } + aspect: 1.0 1.0; + aspect_preference: BOTH; + } + } + part { name: "middle.padding"; + scale: 1; + type: RECT; + description { state: "default" 0.0; + visible: 0; + align: 0.5 0.0; + rel1 { relative: 0.0 1.0; to_y: "nocontents.image";} + rel2 { relative: 1.0 (296+310+54)/1016; to: "bg";} + } + } + part { name: "elm.text"; + type: TEXTBLOCK; + description { state: "default" 0.0; + fixed: 0 1; + align: 0.5 0.0; + visible: 1; + rel1 { relative: 0.0 1.0; to_x: "bg"; to_y: "middle.padding";} + rel2 { relative: 1.0 1.0; to: "bg";} + color: NOCONTENT_TEXT_BLOCK_STYLE_COLOR_INC; + text { + style: "nocontent_style"; + align: 0.5 0.5; + min: 0 0; + max: 0 1; + } + } + } + } + } diff --git a/res/white_theme/edc/images/00_EditField_clear.png b/res/white_theme/edc/images/00_EditField_clear.png new file mode 100755 index 0000000..0244344 Binary files /dev/null and b/res/white_theme/edc/images/00_EditField_clear.png differ diff --git a/res/white_theme/edc/images/00_EditField_clear_press.png b/res/white_theme/edc/images/00_EditField_clear_press.png new file mode 100755 index 0000000..fe9d9cc Binary files /dev/null and b/res/white_theme/edc/images/00_EditField_clear_press.png differ diff --git a/res/white_theme/edc/images/00_check_bg_dim.png b/res/white_theme/edc/images/00_check_bg_dim.png new file mode 100755 index 0000000..d95649c Binary files /dev/null and b/res/white_theme/edc/images/00_check_bg_dim.png differ diff --git a/res/white_theme/edc/images/00_search_input_field_bg.png b/res/white_theme/edc/images/00_search_input_field_bg.png new file mode 100755 index 0000000..096accf Binary files /dev/null and b/res/white_theme/edc/images/00_search_input_field_bg.png differ diff --git a/res/white_theme/edc/images/00_winset_title_tabbar_bg.png b/res/white_theme/edc/images/00_winset_title_tabbar_bg.png new file mode 100755 index 0000000..aafefef Binary files /dev/null and b/res/white_theme/edc/images/00_winset_title_tabbar_bg.png differ diff --git a/res/white_theme/edc/images/T01_Nocontents_picture.png b/res/white_theme/edc/images/T01_Nocontents_picture.png new file mode 100755 index 0000000..0f98480 Binary files /dev/null and b/res/white_theme/edc/images/T01_Nocontents_picture.png differ diff --git a/res/white_theme/edc/images/T01_album_checkbox.png b/res/white_theme/edc/images/T01_album_checkbox.png new file mode 100755 index 0000000..65946b9 Binary files /dev/null and b/res/white_theme/edc/images/T01_album_checkbox.png differ diff --git a/res/white_theme/edc/images/T01_album_checkbox_check.png b/res/white_theme/edc/images/T01_album_checkbox_check.png new file mode 100755 index 0000000..8f921d7 Binary files /dev/null and b/res/white_theme/edc/images/T01_album_checkbox_check.png differ diff --git a/res/white_theme/edc/images/T01_btn_play.png b/res/white_theme/edc/images/T01_btn_play.png new file mode 100755 index 0000000..0e61ed0 Binary files /dev/null and b/res/white_theme/edc/images/T01_btn_play.png differ diff --git a/res/white_theme/edc/images/T01_check.png b/res/white_theme/edc/images/T01_check.png new file mode 100755 index 0000000..d5057e4 Binary files /dev/null and b/res/white_theme/edc/images/T01_check.png differ diff --git a/res/white_theme/edc/images/T01_checkbox.png b/res/white_theme/edc/images/T01_checkbox.png new file mode 100755 index 0000000..61dc76a Binary files /dev/null and b/res/white_theme/edc/images/T01_checkbox.png differ diff --git a/res/white_theme/edc/images/T01_grid_select_check.png b/res/white_theme/edc/images/T01_grid_select_check.png new file mode 100755 index 0000000..f131f47 Binary files /dev/null and b/res/white_theme/edc/images/T01_grid_select_check.png differ diff --git a/res/white_theme/edc/images/T01_main_folder_bg.png b/res/white_theme/edc/images/T01_main_folder_bg.png new file mode 100755 index 0000000..16d1d59 Binary files /dev/null and b/res/white_theme/edc/images/T01_main_folder_bg.png differ diff --git a/res/white_theme/edc/sounds/S_Touch_30ms.wav b/res/white_theme/edc/sounds/S_Touch_30ms.wav new file mode 100755 index 0000000..99ba74d Binary files /dev/null and b/res/white_theme/edc/sounds/S_Touch_30ms.wav differ diff --git a/res/white_theme/images/T01_Nocontents_broken.png b/res/white_theme/images/T01_Nocontents_broken.png new file mode 100755 index 0000000..c200d0c Binary files /dev/null and b/res/white_theme/images/T01_Nocontents_broken.png differ diff --git a/res/white_theme/images/T01_controlbar_icon_add.png b/res/white_theme/images/T01_controlbar_icon_add.png new file mode 100755 index 0000000..c370376 Binary files /dev/null and b/res/white_theme/images/T01_controlbar_icon_add.png differ diff --git a/res/white_theme/images/T01_controlbar_icon_albums.png b/res/white_theme/images/T01_controlbar_icon_albums.png new file mode 100755 index 0000000..bc6cdc1 Binary files /dev/null and b/res/white_theme/images/T01_controlbar_icon_albums.png differ diff --git a/res/white_theme/images/T01_controlbar_icon_tag.png b/res/white_theme/images/T01_controlbar_icon_tag.png new file mode 100755 index 0000000..3e80a11 Binary files /dev/null and b/res/white_theme/images/T01_controlbar_icon_tag.png differ diff --git a/res/white_theme/images/gallery_tag_default_thumbnail.png b/res/white_theme/images/gallery_tag_default_thumbnail.png new file mode 100755 index 0000000..15b8e1f Binary files /dev/null and b/res/white_theme/images/gallery_tag_default_thumbnail.png differ diff --git a/res/white_theme/images/gallery_tag_favorites_thumbnail.png b/res/white_theme/images/gallery_tag_favorites_thumbnail.png new file mode 100755 index 0000000..b55bdda Binary files /dev/null and b/res/white_theme/images/gallery_tag_favorites_thumbnail.png differ diff --git a/res/white_theme/images_edc/T01_btn_thumbnail_play.png b/res/white_theme/images_edc/T01_btn_thumbnail_play.png new file mode 100755 index 0000000..2ea3599 Binary files /dev/null and b/res/white_theme/images_edc/T01_btn_thumbnail_play.png differ diff --git a/res/white_theme/images_edc/T01_icon_lock.png b/res/white_theme/images_edc/T01_icon_lock.png new file mode 100755 index 0000000..44c98da Binary files /dev/null and b/res/white_theme/images_edc/T01_icon_lock.png differ diff --git a/res/white_theme/images_edc/T01_icon_thumbnail_bookmark.png b/res/white_theme/images_edc/T01_icon_thumbnail_bookmark.png new file mode 100755 index 0000000..bdb690a Binary files /dev/null and b/res/white_theme/images_edc/T01_icon_thumbnail_bookmark.png differ diff --git a/res/white_theme/images_edc/T01_icon_thumbnail_favorite.png b/res/white_theme/images_edc/T01_icon_thumbnail_favorite.png new file mode 100755 index 0000000..aa9c8ef Binary files /dev/null and b/res/white_theme/images_edc/T01_icon_thumbnail_favorite.png differ diff --git a/res/white_theme/images_edc/T01_list_icon_bookmark.png b/res/white_theme/images_edc/T01_list_icon_bookmark.png new file mode 100755 index 0000000..06fa9ac Binary files /dev/null and b/res/white_theme/images_edc/T01_list_icon_bookmark.png differ diff --git a/res/white_theme/images_edc/gl-images.edc b/res/white_theme/images_edc/gl-images.edc new file mode 100755 index 0000000..406fdfa --- /dev/null +++ b/res/white_theme/images_edc/gl-images.edc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + #define RESOURCE_IMAGE( FILE_NAME ) \ + group { \ + name: FILE_NAME; \ + images.image: FILE_NAME COMP; \ + parts { \ + part { name: "image"; \ + description { \ + state: "default" 0.0; \ + image.normal: FILE_NAME; \ + aspect: 1 1; \ + aspect_preference: BOTH; \ + } \ + } \ + } \ + } + +#define RESOURCE_IMAGE_LOSSY( FILE_NAME ) \ + group { \ + name: FILE_NAME; \ + images.image: FILE_NAME LOSSY 85; \ + parts { \ + part { name: "image"; \ + description { \ + state: "default" 0.0; \ + image.normal: FILE_NAME; \ + aspect: 1 1; \ + aspect_preference: BOTH; \ + } \ + } \ + } \ + } + +collections { + RESOURCE_IMAGE("T01_icon_lock.png"); + RESOURCE_IMAGE("T01_icon_thumbnail_favorite.png"); + + RESOURCE_IMAGE("T01_btn_thumbnail_play.png"); + RESOURCE_IMAGE("T01_icon_thumbnail_bookmark.png"); + RESOURCE_IMAGE("T01_list_icon_bookmark.png"); +} + diff --git a/src/data/gl-data-type.c b/src/data/gl-data-type.c new file mode 100755 index 0000000..c00d93f --- /dev/null +++ b/src/data/gl-data-type.c @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "gl-data-type.h" +#include "gl-debug.h" +int _gl_data_type_new_tag(gl_tag_s **t_item) +{ + GL_CHECK_VAL(t_item, -1); + gl_tag_s *tmp_item = (gl_tag_s *)calloc(1, sizeof(gl_tag_s)); + GL_CHECK_VAL(tmp_item, -1); + tmp_item->gtype = GL_TYPE_TAG; + *t_item = tmp_item; + return 0; +} +int _gl_data_type_new_album(gl_album_s **album) +{ + GL_CHECK_VAL(album, -1); + gl_album_s *tmp_item = (gl_album_s *)calloc(1, sizeof(gl_album_s)); + GL_CHECK_VAL(tmp_item, -1); + tmp_item->gtype = GL_TYPE_ALBUM; + *album = tmp_item; + return 0; +} + + +static int __gl_data_type_free_media(gl_media_s **item) +{ + GL_CHECK_VAL(item, -1); + GL_CHECK_VAL(*item, -1); + gl_media_s *tmp_item = *item; + + /* For local medias */ + if (tmp_item->media_h) { + media_info_destroy(tmp_item->media_h); + tmp_item->media_h = NULL; + } + + GL_FREEIF(tmp_item->uuid); + GL_FREEIF(tmp_item->thumb_url); + GL_FREEIF(tmp_item->file_url); + GL_FREEIF(tmp_item->album_uuid); + GL_FREEIF(tmp_item->display_name); + GL_FREEIF(tmp_item->ext); + + if (MEDIA_CONTENT_TYPE_IMAGE == tmp_item->type && + tmp_item->image_info) { + /* For local medias */ + if (tmp_item->image_info->image_h) { + image_meta_destroy(tmp_item->image_info->image_h); + tmp_item->image_info->image_h = NULL; + } + + GL_FREEIF(tmp_item->image_info->media_uuid); + GL_FREE(tmp_item->image_info); + } else if (MEDIA_CONTENT_TYPE_VIDEO == tmp_item->type && + tmp_item->video_info) { + /* For local medias */ + if (tmp_item->video_info->video_h) { + video_meta_destroy(tmp_item->video_info->video_h); + tmp_item->video_info->video_h = NULL; + } + + GL_FREEIF(tmp_item->video_info->media_uuid); + GL_FREEIF(tmp_item->video_info->title); + } + + GL_FREE(tmp_item); + *item = NULL; + return 0; +} + +static int __gl_data_type_free_tag(gl_tag_s **t_item) +{ + GL_CHECK_VAL(t_item, -1); + GL_CHECK_VAL(*t_item, -1); + gl_tag_s *tmp_item = *t_item; + GL_FREEIF(tmp_item->tag_name); + if (tmp_item->tag_h) + media_tag_destroy(tmp_item->tag_h); + GL_FREE(tmp_item); + *t_item = NULL; + return 0; +} + +int _gl_data_type_free_tag_list(Eina_List **list) +{ + GL_CHECK_VAL(list, -1); + GL_CHECK_VAL(*list, -1); + gl_tag_s *item = NULL; + Eina_List *tmp_list = *list; + EINA_LIST_FREE(tmp_list, item) { + if (item) + __gl_data_type_free_tag(&item); + } + eina_list_free(*list); + *list = NULL; + return 0; +} + +static int __gl_data_type_free_album(gl_album_s **album) +{ + GL_CHECK_VAL(album, -1); + GL_CHECK_VAL(*album, -1); + gl_album_s *tmp_album = *album; + + GL_FREEIF(tmp_album->uuid); + GL_FREEIF(tmp_album->display_name); + GL_FREEIF(tmp_album->path); + + if (tmp_album->folder_h) + media_folder_destroy(tmp_album->folder_h); + GL_FREE(tmp_album); + *album = NULL; + return 0; +} + +int _gl_data_type_free_glitem(void **item) +{ + GL_CHECK_VAL(item, -1); + GL_CHECK_VAL(*item, -1); + int ret = -1; + + if(((gl_album_s *)*item)->gtype == GL_TYPE_ALBUM) + ret = __gl_data_type_free_album((gl_album_s **)item); + else if (((gl_tag_s *)*item)->gtype == GL_TYPE_TAG) + ret = __gl_data_type_free_tag((gl_tag_s **)item); + else if (((gl_media_s *)*item)->gtype == GL_TYPE_MEDIA) + ret = __gl_data_type_free_media((gl_media_s **)item); + + if (ret < 0) + return -1; + else + return 0; +} + diff --git a/src/data/gl-data-util.c b/src/data/gl-data-util.c new file mode 100755 index 0000000..00e6238 --- /dev/null +++ b/src/data/gl-data-util.c @@ -0,0 +1,514 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "gl-data-util.h" +#include "gl-controlbar.h" +#include "gallery.h" +#include "gl-debug.h" +#include "gl-drm.h" +#include "gl-util.h" +#include "gl-strings.h" +#include "gl-data-type.h" + +bool _gl_data_util_get_file_dir_name(const char *file_path, char *filename, + char *dir_name, char *dir_path) +{ + GL_CHECK_FALSE(file_path); + gint i = 0; + gint count = 0; + for (i = strlen(file_path); i >= 0; i--) { + if (file_path[i] != '\0') { + count++; + } + if (file_path[i] == '/') { + if (filename != NULL) { + memcpy(filename, &file_path[i + 1], --count); + *(filename + count) = '\0'; + gl_dbg("File Name = %s", filename); + } + if (dir_path != NULL) { + memcpy(dir_path, &file_path[0], i); + *(dir_path + i) = '\0'; + gl_dbg("Directory Name = %s", dir_path); + } + if (dir_name != NULL) { + count = 0; + for (--i; i >= 0; i--) { + count++; + if (file_path[i] == '/') { + memcpy(dir_name, &file_path[i + 1], --count); + *(dir_name + count) = '\0'; + gl_dbg("Directory Name = %s", dir_name); + count = 0; + return true; + } + } + } + return true; + } + } + + return false; +} + +/* +* create a gl_item +*/ +gl_item *_gl_data_util_calloc_gitem(void) +{ + gl_item *gitem = (gl_item *)calloc(1, sizeof(gl_item)); + GL_CHECK_NULL(gitem); + return gitem; +} + +int _gl_data_util_free_gitem(gl_item *gitem) +{ + GL_CHECK_VAL(gitem, -1); + if (gitem->item) { + _gl_data_type_free_glitem((void **)&(gitem->item)); + gitem->item = NULL; + } + + GL_FREEIF(gitem->_reserved); + GL_FREE(gitem); + return 0; +} + +gl_cluster *_gl_data_util_calloc_gcluster(void) +{ + gl_cluster *gcluster = (gl_cluster *)calloc(1, sizeof(gl_cluster)); + GL_CHECK_NULL(gcluster); + return gcluster; +} + +int _gl_data_util_free_gcluster(gl_cluster *gcluster) +{ + GL_CHECK_VAL(gcluster, -1); + if (gcluster->cluster) { + _gl_data_type_free_glitem((void **)&(gcluster->cluster)); + gcluster->cluster = NULL; + } + + GL_FREEIF(gcluster->_reserved); + GL_FREE(gcluster); + return 0; +} + +gl_cluster *_gl_data_util_new_gcluster_all(void *data, int count) +{ + gl_dbg(""); + GL_CHECK_NULL(data); + gl_cluster *gcluster = NULL; + gl_album_s *mcluster = NULL; + + gcluster = _gl_data_util_calloc_gcluster(); + GL_CHECK_NULL(gcluster); + + _gl_data_type_new_album(&mcluster); + if (mcluster == NULL) { + GL_FREE(gcluster); + return NULL; + } + + mcluster->uuid = strdup(GL_ALBUM_ALL_ID); + mcluster->count = count; + mcluster->type = GL_STORE_T_ALL; + mcluster->display_name = strdup(GL_ALBUM_ALL_NAME); + gcluster->ad = data; + gcluster->cluster = mcluster; + return gcluster; +} + +gl_cluster_list *_gl_data_util_calloc_cluster_list(void) +{ + gl_cluster_list *clus_list = (gl_cluster_list *)calloc(1, + sizeof(gl_cluster_list)); + GL_CHECK_NULL(clus_list); + return clus_list; +} + +/* +* create a gl_tag +*/ +gl_tag *_gl_data_util_calloc_gtag(void) +{ + gl_tag *gtag = (gl_tag *)calloc(1, sizeof(gl_tag)); + GL_CHECK_NULL(gtag); + return gtag; +} + +/* +* destroy a gl_tag +*/ +int _gl_data_util_free_gtag(gl_tag *gtag) +{ + GL_CHECK_VAL(gtag, -1); + GL_CHECK_VAL(gtag->tag, -1); + + _gl_data_type_free_glitem((void **)&(gtag->tag)); + gtag->tag = NULL; + GL_FREE(gtag); + return 0; +} + +/* Clear eina_list got from DB */ +int _gl_data_util_clear_gtype_item_list(Eina_List **elist) +{ + void *current = NULL; + + if (elist && *elist) { + gl_dbg("Clear gtype items list"); + EINA_LIST_FREE(*elist, current) { + if (current) { + _gl_data_type_free_glitem((void **)¤t); + current = NULL; + } + } + *elist = NULL; + } + + return 0; +} + +int _gl_data_util_clear_item_list(Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + gl_item *current = NULL; + if (*elist) { + gl_dbg("Clear elist"); + EINA_LIST_FREE(*elist, current) { + _gl_data_util_free_gitem(current); + current = NULL; + } + *elist = NULL; + } + + return 0; + +} + +int _gl_data_util_get_selected_cluster_id_list(void *data, + Eina_List **sel_id_list) +{ + GL_CHECK_VAL(sel_id_list, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->albuminfo.selected_albums_elist, -1); + gl_cluster *gcluster = NULL; + char *item_id = NULL; + + /* Save ID of selected clusters */ + EINA_LIST_FREE(ad->albuminfo.selected_albums_elist, gcluster) { + if (gcluster && gcluster->cluster && gcluster->cluster->uuid) { + item_id = strdup(gcluster->cluster->uuid); + *sel_id_list = eina_list_append(*sel_id_list, + (void *)item_id); + } + } + return 0; +} + +int _gl_data_util_get_selected_item_id_list(void *data, + Eina_List **sel_id_list) +{ + GL_CHECK_VAL(sel_id_list, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->selectedinfo.medias_elist, -1); + gl_item *gitem = NULL; + char *item_id = NULL; + + /* Save ID of selected items */ + EINA_LIST_FREE(ad->selectedinfo.medias_elist, gitem) { + if (gitem && gitem->item && gitem->item->uuid) { + item_id = strdup(gitem->item->uuid); + *sel_id_list = eina_list_append(*sel_id_list, + (void *)item_id); + } + } + return 0; +} + +/* Check ID is in the list or not */ +bool _gl_data_util_check_selected_id(Eina_List **sel_id_list, const char *id) +{ + GL_CHECK_FALSE(sel_id_list); + Eina_List *tmp_elist = NULL; + void *p_id = NULL; + GL_CHECK_FALSE(id); + + if (eina_list_count(*sel_id_list) == 0) { + gl_dbgE("sel_id_list is empty!"); + return false; + } + + EINA_LIST_FOREACH(*sel_id_list, tmp_elist, p_id) { + if (p_id == NULL) { + gl_dbgE("Invalid p_id!"); + continue; + } + /* Get next one if they wasn't equal */ + if (g_strcmp0(id, (char *)p_id)) { + p_id = NULL; + continue; + } + *sel_id_list = eina_list_remove(*sel_id_list, p_id); + GL_FREE(p_id); + return true; + } + return false; +} + +/* Free list of selected IDs */ +int _gl_data_util_free_selected_id_list(Eina_List **sel_id_list) +{ + GL_CHECK_VAL(sel_id_list, -1); + if (*sel_id_list == NULL) { + gl_dbg("sel_id_list is empty!"); + return -1; + } + + void *p_id = NULL; + EINA_LIST_FREE(*sel_id_list, p_id) { + if (p_id == NULL) { + gl_dbgE("Invalid p_id!"); + continue; + } + GL_FREE(p_id); + } + *sel_id_list = NULL; + return 0; +} + +int _gl_data_util_check_album_selected_files(gl_cluster *album, int *drm_cnt, + int *img_cnt, int *sel_cnt) +{ + GL_CHECK_VAL(album, -1); + GL_CHECK_VAL(album->cluster, -1); + GL_CHECK_VAL(album->cluster->uuid, -1); + GL_CHECK_VAL(album->ad, -1); + int _sel_cnt = 0; + int _img_cnt = 0; + int _drm_cnt = 0; + int err = -1; + Eina_List *itemlist = NULL; + gl_filter_s filter; + + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = false; + + if (album->cluster->type == GL_STORE_T_ALL) { + gl_dbg("All albums"); + err = _gl_local_data_get_all_albums_media_list(&filter, + &itemlist); + } else if (album->cluster->type == GL_STORE_T_PHONE || + album->cluster->type == GL_STORE_T_MMC) { + gl_dbg("Local album"); + err = _gl_local_data_get_album_media_list(&filter, + album->cluster->uuid, + &itemlist); + } else { + gl_dbgE("Wrong cluster type!"); + return -1; + } + + if ((err == 0) && (itemlist != NULL)) { + gl_media_s *item = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + + _sel_cnt++; + if (album->cluster->type == GL_STORE_T_PHONE || + album->cluster->type == GL_STORE_T_MMC || + album->cluster->type == GL_STORE_T_ALL) { + if (item->type == MEDIA_CONTENT_TYPE_IMAGE) + _img_cnt++; + /* Update selected DRM files count */ + if (gl_drm_is_drm_file(item->file_url)) + _drm_cnt++; + } else { + /* Checkme: now only image supported for web */ + _img_cnt++; + } + item = NULL; + } + } + gl_dbg("Selected items count: %d, image count: %d, drm count: %d.", + _sel_cnt, _img_cnt, _drm_cnt); + if (sel_cnt) + *sel_cnt = _sel_cnt; + if (drm_cnt) + *drm_cnt = _drm_cnt; + if (img_cnt) + *img_cnt = _img_cnt; + return 0; +} + +int _gl_data_util_check_tag_selected_files(void *data, int *drm_cnt, + int *img_cnt, int *sel_cnt) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->taginfo.selected_tags_elist, -1); + GString *selected_path_list = g_string_new(NULL); + gl_tag *gtag = NULL; + Eina_List *l = NULL; + int err = -1; + Eina_List *itemlist = NULL; + int _sel_cnt = 0; + int _img_cnt = 0; + int _drm_cnt = 0; + + gl_filter_s filter; + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = true; + + EINA_LIST_FOREACH(ad->taginfo.selected_tags_elist, l, gtag) { + if (gtag == NULL || gtag->tag == NULL || + gtag->tag->tag_name == NULL) { + if (selected_path_list) { + g_string_free(selected_path_list, true); + selected_path_list = NULL; + } + return -1; + } + + err = _gl_local_data_get_tag_media_list(gtag->tag->_id, &filter, + &itemlist); + + if ((err == 0) && (itemlist != NULL)) { + gl_media_s *item = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + + if (strstr(selected_path_list->str, item->file_url)) { + gl_dbgW("Already counted!"); + continue; + } + + _sel_cnt++; + + if (item->type == MEDIA_CONTENT_TYPE_IMAGE) + _img_cnt++; + /* Update selected DRM files count */ + if (gl_drm_is_drm_file(item->file_url)) + _drm_cnt++; + + g_string_append(selected_path_list, item->file_url); + g_string_append_c(selected_path_list, '?'); + item = NULL; + } + } + } + + g_string_free(selected_path_list, true); + + gl_dbg("Selected items count: %d, image count: %d, drm count: %d.", + _sel_cnt, _img_cnt, _drm_cnt); + if (sel_cnt) + *sel_cnt = _sel_cnt; + if (drm_cnt) + *drm_cnt = _drm_cnt; + if (img_cnt) + *img_cnt = _img_cnt; + return 0; +} + +/* +* free tag list. +*/ +int _gl_data_util_free_tag_list(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->taginfo.tags_elist) { + gl_tag *gtag = NULL; + Eina_List *tags_list = ad->taginfo.tags_elist; + EINA_LIST_FREE(tags_list, gtag) { + if (gtag) { + _gl_data_util_free_gtag(gtag); + gtag = NULL; + } + } + + ad->taginfo.tags_elist = NULL; + } + + return 0; +} + +/* +* get favorites tag from libmedia-info +*/ +gl_tag *_gl_data_util_get_favor_tag(void *data) +{ + gl_dbg(""); + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + /* add favorites tag */ + gl_tag_s *favor_tag = NULL; + + _gl_data_type_new_tag(&favor_tag); + GL_CHECK_NULL(favor_tag); + favor_tag->tag_name = strdup(GL_TAG_FAVORITES_NAME); + favor_tag->_id = GL_TAG_FAVORITES_ID; + favor_tag->gtype = 0; + + gl_tag *favor_gtag = _gl_data_util_calloc_gtag(); + if (!favor_gtag) { + gl_dbgE("_gl_data_util_calloc_gtag() failed!"); + _gl_data_type_free_glitem((void **)&favor_tag); + return NULL; + } + favor_gtag->tag = favor_tag; + + /* Get favorites item count */ + int item_count = 0; + int err = _gl_data_get_item_cnt(ad, GL_GET_ALL_RECORDS_ID, true, + GL_STORE_T_PHONE, &item_count); + if (err == 0) { + favor_tag->count = item_count; + } else { + gl_dbgE("_gl_data_get_item_cnt failed!"); + favor_tag->count = 0; + } + gl_dbg("===Tag [Favourites] has %d item(s)", favor_tag->count); + + return favor_gtag; +} + diff --git a/src/data/gl-data.c b/src/data/gl-data.c new file mode 100755 index 0000000..ff11e1b --- /dev/null +++ b/src/data/gl-data.c @@ -0,0 +1,2494 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "gl-data.h" +#include "gl-data-util.h" +#include "gl-controlbar.h" +#include "gallery.h" +#include "gl-debug.h" +#include "gl-drm.h" +#include "gl-util.h" +#include "gl-strings.h" +#include "gl-icons.h" +#include "gl-exif.h" + +static int __gl_data_clear_cluster_list(void *data, bool b_force) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_cluster *current = NULL; + Eina_List *tmp_list = NULL; + + // 2011.1.3 han - To reset current album when clear cluster list. + ad->albuminfo.current_album = NULL; + + if (ad->albuminfo.cluster_list) { + if (ad->albuminfo.cluster_list->clist) { + tmp_list = ad->albuminfo.cluster_list->clist; + + EINA_LIST_FREE(tmp_list, current) { + if (current) { + _gl_data_util_free_gcluster(current); + current = NULL; + } + } + ad->albuminfo.cluster_list->clist = NULL; + } + + if (b_force) { + GL_FREE(ad->albuminfo.cluster_list); + } + } + + return 0; +} + +static int __gl_data_get_cluster_list(void *data, bool b_update) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int length = 0; + int all_item_cnt = 0; + Eina_List *item_list = NULL; + gl_album_s *f_data = NULL; + gl_cluster *default_album = NULL; + int err = -1; + int edit_album_cnt = 0; + gl_filter_s filter; + gl_album_s *new_mc = NULL; + Eina_List *sel_id_list = NULL; + bool b_selected = false; + char new_mc_id[GL_MTYPE_ITEN_ID_LEN_MAX] = { 0, }; + char sel_id[GL_MTYPE_ITEN_ID_LEN_MAX] = { 0, }; + gl_dbg(""); + + memset(&filter, 0x00, sizeof(gl_filter_s)); + + if (b_update) { + gl_dbg("Update mode."); + gl_cluster *album_item = ad->albuminfo.selected_album; + if (album_item && album_item->cluster && + album_item->cluster->uuid) { + g_strlcpy(sel_id, album_item->cluster->uuid, + GL_MTYPE_ITEN_ID_LEN_MAX); + gl_dbg("Save selected album ID: %s.", sel_id); + } + ad->albuminfo.selected_album = NULL; + /* Get selected cluster IDs list */ + _gl_data_util_get_selected_cluster_id_list(ad, &sel_id_list); + /* Free old list */ + _gl_data_finalize_albums_selected_list(ad); + /* Clear cluster list */ + __gl_data_clear_cluster_list(ad, false); + } + + + //ad->new_album_name is the cluster name of newly created album + //in moving medias to new album case. + if (strlen(ad->albuminfo.new_album_name)) { + memset(ad->albuminfo.new_album_name, 0x00, GL_ALBUM_NAME_LEN_MAX); + //get gl_media_s from DB via folder full path(URL). + err = _gl_local_data_get_album_by_path(ad->albuminfo.dest_folder, + &new_mc); + if (err != 0) { + gl_dbgE("Faild to get album[%d]!", err); + } else if (new_mc->count == 0) { + //media records of this cluster havn't been inserted to DB. + //save the cluster ID. + //update cluster item count while refresh albums view in _gl_albums_get_label(). + gl_dbg("Get newly created gl_media_s, url: %s.", + ad->albuminfo.dest_folder); + g_strlcpy(new_mc_id, new_mc->uuid, + GL_MTYPE_ITEN_ID_LEN_MAX); + _gl_data_type_free_glitem((void **)&new_mc); + } + } + + //get real albums + memset(filter.cond, 0x00, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, FOLDER_NAME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = false; + + gl_dbg("Get_album_list:start"); + err = _gl_local_data_get_album_list(&filter, &item_list); + gl_dbg("Get_album_list:end, %d", err); + if (err != 0) { + gl_dbg("No record!"); + ad->albuminfo.cluster_list->clist = NULL; + if (item_list) + _gl_data_util_clear_gtype_item_list(&item_list); + } + + gl_cluster *gcluster = NULL; + EINA_LIST_FREE(item_list, f_data) { + if (f_data == NULL || f_data->uuid == NULL) { + gl_dbgE("Invalid gl_media_s!"); + continue; + } + gl_dbg("folder id: %s.", f_data->uuid); + + /** + * To skip MMC albums if MMC already unmounted, + * in case of delay updating in DB. + */ + if ((ad->maininfo.mmc_state == GL_MMC_STATE_REMOVED_MOVING || + ad->maininfo.mmc_state == GL_MMC_STATE_REMOVED) && + f_data->type == GL_STORE_T_MMC) { + gl_dbgW("MMC was unmounted, skip MMC album!"); + _gl_data_type_free_glitem((void **)&f_data); + continue; + } + + if (f_data->type == GL_STORE_T_PHONE || + f_data->type == GL_STORE_T_MMC) { + if (f_data->count == 0) { + if (!g_strcmp0(f_data->uuid, new_mc_id)) { + /* append the newly created cluster to list */ + gl_dbg("empty local album, but it's newly created..."); + } else { + /* Skip empty album */ + gl_dbg("empty local album, skipping it..."); + _gl_data_type_free_glitem((void **)&f_data); + continue; + } + } + all_item_cnt += f_data->count; + } + + gcluster = NULL; + gcluster = _gl_data_new_cluster(); + if (gcluster == NULL) { + gl_dbgE("_gl_data_new_cluster failed!"); + _gl_data_type_free_glitem((void **)&f_data); + continue; + } + + gcluster->ad = ad; + gcluster->cluster = f_data; + + length += f_data->count; + + if (_gl_data_is_default_album(GL_ALBUM_DEFAULT_NAME, f_data)) { + /** + * Default album: Camera Shot + * Now Camera Shot is located in Phone. + * If user can determine the location of default album, + * here we should get the path and check it's in Phone or MMC. + */ + default_album = gcluster; + ad->albuminfo.cluster_list->clist = eina_list_prepend(ad->albuminfo.cluster_list->clist, + gcluster); + } else if (_gl_data_is_default_album(GL_ALBUM_DOWNLOAD_NAME, f_data)) { + if (default_album) + ad->albuminfo.cluster_list->clist = eina_list_append_relative(ad->albuminfo.cluster_list->clist, + gcluster, default_album); + else + ad->albuminfo.cluster_list->clist = eina_list_prepend(ad->albuminfo.cluster_list->clist, + gcluster); + }else { + ad->albuminfo.cluster_list->clist = eina_list_append(ad->albuminfo.cluster_list->clist, + gcluster); + } + /* Default album 'Camera shots' showed in edit view */ + edit_album_cnt++; + + if (sel_id_list) { + b_selected = _gl_data_util_check_selected_id(&sel_id_list, + f_data->uuid); + if (b_selected) { + b_selected = false; + /* Set checkbox state */ + gcluster->checked = true; + /* Append gcluster to selected list */ + _gl_data_albums_selected_list_append(ad, gcluster); + } + } + if (strlen(sel_id) > 0 && !g_strcmp0(sel_id, f_data->uuid)) { + gl_dbgW("Found selected_album."); + ad->albuminfo.selected_album = gcluster; + } + } + + /* Clear list of selected ID */ + if (sel_id_list) { + b_selected = _gl_data_util_check_selected_id(&sel_id_list, + GL_ALBUM_ALL_ID); + _gl_data_util_free_selected_id_list(&sel_id_list); + } + + ad->albuminfo.cluster_list->edit_cnt = edit_album_cnt; + /** + * add "all" album, only inclduing local albums temporarily, + */ + if (all_item_cnt) { + /* Create "All albums" album if any local file exists */ + gcluster = _gl_data_util_new_gcluster_all(ad, all_item_cnt); + if (gcluster == NULL) { + gl_dbgE("_gl_data_util_new_gcluster_all failed!"); + __gl_data_clear_cluster_list(ad, false); + return -1; + } + if (b_selected) { + b_selected = false; + /* Set checkbox state */ + gcluster->checked = true; + /* Append gcluster to selected list */ + _gl_data_albums_selected_list_append(ad, gcluster); + } + + if (default_album) + ad->albuminfo.cluster_list->clist = eina_list_append_relative(ad->albuminfo.cluster_list->clist, + gcluster, default_album); + else + ad->albuminfo.cluster_list->clist = eina_list_prepend(ad->albuminfo.cluster_list->clist, + gcluster); + default_album = gcluster; + + /* Get latest item for saving lastest modified time */ + Eina_List *item_list = NULL; + memset(&filter, 0x00, sizeof(gl_filter_s)); + gl_media_s *mitem = NULL; + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, + CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, + KEYWORD_LENGTH); + filter.offset = GL_FIRST_VIEW_START_POS; + filter.count = GL_GET_ONE_RECORDS; + filter.with_meta = false; + + _gl_local_data_get_all_albums_media_list(&filter, &item_list); + if (item_list) { + gl_dbg("list length is %d", eina_list_count(item_list)); + mitem = eina_list_nth(item_list, 0); + if (mitem) { + ad->maininfo.last_mtime = mitem->mtime; + _gl_data_type_free_glitem((void **)&mitem); + } + eina_list_free(item_list); + } + ad->maininfo.all_medias_cnt = all_item_cnt; + } + + gl_dbg("Cluster Done."); + return length; +} + +gl_cluster *_gl_data_new_cluster(void) +{ + return _gl_data_util_calloc_gcluster(); +} + +/* +* Check it's default album[Camera shot] or not +*/ +bool _gl_data_is_default_album(const char *match_folder, gl_album_s *album) +{ + GL_CHECK_FALSE(album); + GL_CHECK_FALSE(album->display_name); + GL_CHECK_FALSE(album->uuid); + GL_CHECK_FALSE(match_folder); + + /* Name is 'Camera shot and' folder locates in Phone */ + if (!g_strcmp0(album->display_name, match_folder) && + album->type == GL_STORE_T_PHONE) { + char parent_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + + gl_dbg("Full path: %s", album->path); + + _gl_data_util_get_file_dir_name(album->path, NULL, NULL, + parent_path); + gl_dbg("Parent path: %s.", parent_path); + + /* And parent folder is Phone root path, it's default folder */ + return (g_strcmp0(parent_path, GL_ROOT_PATH_PHONE) == 0); + } + + return false; +} + +int _gl_data_clear_default_item_list(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + _gl_data_util_clear_item_list(&(ad->maininfo.medias_elist)); + + return 0; +} + +bool _gl_data_get_cluster_list(void *data) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + int n_entire_items = 0; + + __gl_data_clear_cluster_list(ad, true); + + ad->albuminfo.cluster_list = _gl_data_util_calloc_cluster_list(); + GL_CHECK_FALSE(ad->albuminfo.cluster_list); + n_entire_items = __gl_data_get_cluster_list(ad, false); + if (n_entire_items <= 0) //if error code is returned, negative value is possible + { + return false; + } + gl_dbg("cluster-length:%d", n_entire_items); + + return true; +} + +int _gl_data_update_cluster_list(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int len = 0; + + len = __gl_data_get_cluster_list(ad, true); + gl_dbg("Cluster list length: %d.", len); + if (len <= 0) + return -1; + + return 0; +} + +int _gl_data_get_cluster_by_id(void *data, const char *cluster_id, + gl_cluster **cluster) +{ + GL_CHECK_VAL(data, -1); + GL_CHECK_VAL(cluster, -1); + GL_CHECK_VAL(cluster_id, -1); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + gl_cluster *current = NULL; + + *cluster = NULL; + + GL_CHECK_VAL(ad->albuminfo.cluster_list, -1); + int length = eina_list_count(ad->albuminfo.cluster_list->clist); + gl_dbg("album length: %d, current album id: %s", length, cluster_id); + + for (i = 0; i < length; i++) { + current = eina_list_nth(ad->albuminfo.cluster_list->clist, i); + if (current && current->cluster && current->cluster->uuid) { + gl_dbg("cluster : %s", current->cluster->display_name); + } else { + gl_dbgE("cluster is NULL"); + break; + } + + if (!g_strcmp0(current->cluster->uuid, cluster_id)) { + *cluster = current; + gl_dbgW("Found!"); + return 0; + } + } + return -1; +} + +int _gl_data_get_cluster_by_path(void *data, const char *path, + gl_cluster **cluster) +{ + GL_CHECK_VAL(data, -1); + GL_CHECK_VAL(cluster, -1); + GL_CHECK_VAL(path, -1); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + gl_cluster *current = NULL; + + *cluster = NULL; + + GL_CHECK_VAL(ad->albuminfo.cluster_list, -1); + int length = eina_list_count(ad->albuminfo.cluster_list->clist); + gl_dbg("album length: %d, path: %s", length, path); + + for (i = 0; i < length; i++) { + current = eina_list_nth(ad->albuminfo.cluster_list->clist, i); + if (current && current->cluster && current->cluster->path) { + gl_dbg("cluster : %s", current->cluster->display_name); + } else { + gl_dbgE("cluster is NULL"); + continue; + } + + if (!g_strcmp0(current->cluster->path, path)) { + *cluster = current; + gl_dbgW("Found!"); + return 0; + } + } + return -1; +} + +/* +* get tag by index from tags_elist. +*/ +int _gl_data_get_tag_by_index(void *data, gl_tag **tag, int idx) +{ + GL_CHECK_VAL(tag, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + *tag = eina_list_nth(ad->taginfo.tags_elist, idx); + if (*tag == NULL) + return -1; + + return 0; +} + +/* +* check whether some tag already in tags list. +*/ +bool _gl_data_is_in_tag_list(void *data, const char *tagname) +{ + GL_CHECK_FALSE(tagname); + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_FALSE(ad->taginfo.tags_elist); + gl_dbg(""); + + Eina_List *tmp_elist = NULL; + gl_tag *mtag = NULL; + Eina_List *tags_list = ad->taginfo.tags_elist; + EINA_LIST_FOREACH(tags_list, tmp_elist, mtag) { + if (mtag && mtag->tag) { + if (mtag->tag->tag_name && + (g_strcmp0(mtag->tag->tag_name, tagname) == 0)) { + //debug msg + gl_dbg("Tag already exists--found tag %s***", + mtag->tag->tag_name); + return true; + } + mtag = NULL; + } + } + + gl_dbg("A new tag %s +++", tagname); + + return false; +} + +/* +* get all count of tags list +* 0 returned if tags_elist doesn't exist. +*/ +int _gl_data_get_tag_count_all(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->taginfo.tags_elist) + return eina_list_count(ad->taginfo.tags_elist); + else + return 0; +} + +/* +* get all tags from database via media service, +* tag list(param: elist) would be returned to caller, and also saved as tags_list. +*/ +int _gl_data_get_tag_list(void *data, Eina_List **elist) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Eina_List *taglist = NULL; + int err = -1; + gl_dbg(""); + + _gl_data_util_free_tag_list(ad); + + gl_tag *favor_gtag = _gl_data_util_get_favor_tag(ad); + if (favor_gtag == NULL) { + gl_dbgE("_gl_data_util_get_favor_tag failed!"); + if (elist) + *elist = NULL; + return -1; + } + favor_gtag->ad = ad; + ad->taginfo.tags_elist = eina_list_append(ad->taginfo.tags_elist, + favor_gtag); + + gl_filter_s filter; + memset(&filter, 0x00, sizeof(gl_filter_s)); + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, TAG_NAME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = false; + err = _gl_local_data_get_tag_list(&filter, &taglist); + if ((err != 0) || (taglist == NULL)) { + gl_dbgE("(err != 0) || (taglist == NULL)"); + if (taglist) + _gl_data_util_clear_gtype_item_list(&taglist); + + if (elist) + *elist = ad->taginfo.tags_elist; + + return err; + } + + gl_tag_s *mtag = NULL; + gl_tag *gtag = NULL; + EINA_LIST_FREE(taglist, mtag) { + if (mtag == NULL) { + gl_dbgE("Invalid mtag!"); + continue; + } + gtag = _gl_data_util_calloc_gtag(); + if (gtag == NULL) { + gl_dbgE("_gl_data_util_calloc_gtag failed!"); + _gl_data_type_free_glitem((void **)&mtag); + continue; + } + + gtag->ad = ad; + gtag->tag = mtag; + ad->taginfo.tags_elist = eina_list_append(ad->taginfo.tags_elist, + gtag); + } + + if (elist) + *elist = ad->taginfo.tags_elist; + + return err; +} + +int _gl_data_update_tag_list(void *data, Eina_List **elist) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Eina_List *taglist = NULL; + int err = -1; + char current_tag_name[GL_ALBUM_NAME_LEN_MAX] = { 0, }; + gl_tag *current_tag = ad->taginfo.current_tag; + bool b_reset = false; + gl_dbg(""); + /* Save current tag name */ + if (current_tag && current_tag->tag && current_tag->tag->tag_name) { + gl_dbg("Current tag: %s", current_tag->tag->tag_name); + b_reset = true; + g_strlcpy(current_tag_name, current_tag->tag->tag_name, + sizeof(current_tag_name)); + } + /* Set current_tag NULL */ + ad->taginfo.current_tag = NULL; + /* Clear old tag list */ + _gl_data_util_free_tag_list(ad); + /* Add favourites tag */ + gl_tag *favor_gtag = _gl_data_util_get_favor_tag(ad); + if (favor_gtag == NULL || favor_gtag->tag == NULL) { + gl_dbgE("_gl_data_util_get_favor_tag failed!"); + if (elist) + *elist = NULL; + if (favor_gtag) + _gl_data_util_free_gtag(favor_gtag); + return -1; + } + if (b_reset && favor_gtag->tag->tag_name && + !g_strcmp0(favor_gtag->tag->tag_name, current_tag_name)) { + gl_dbg("Current tag reset."); + b_reset = false; + ad->taginfo.current_tag = favor_gtag; + } + favor_gtag->ad = ad; + ad->taginfo.tags_elist = eina_list_append(ad->taginfo.tags_elist, + favor_gtag); + + /* Get normal tags from DB */ + gl_filter_s filter; + memset(&filter, 0x00, sizeof(gl_filter_s)); + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, TAG_NAME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.count = GL_GET_ALL_RECORDS; + filter.offset = GL_GET_ALL_RECORDS; + filter.with_meta = false; + err = _gl_local_data_get_tag_list(&filter, &taglist); + if ((err != 0) || (taglist == NULL)) { + gl_dbgE("(err != 0) || (taglist == NULL)"); + if (taglist) + _gl_data_util_clear_gtype_item_list(&taglist); + + if (elist) + *elist = ad->taginfo.tags_elist; + + return err; + } + + gl_tag_s *mtag = NULL; + gl_tag *gtag = NULL; + EINA_LIST_FREE(taglist, mtag) { + if (mtag == NULL) { + gl_dbgE("Invalid mtag!"); + continue; + } + gtag = _gl_data_util_calloc_gtag(); + if (gtag == NULL) { + gl_dbgE("_gl_data_util_calloc_gtag failed!"); + _gl_data_type_free_glitem((void **)&mtag); + continue; + } + if (b_reset && !g_strcmp0(mtag->tag_name, current_tag_name)) { + gl_dbg("Current tag reset."); + b_reset = false; + ad->taginfo.current_tag = gtag; + } + gtag->ad = ad; + gtag->tag = mtag; + ad->taginfo.tags_elist = eina_list_append(ad->taginfo.tags_elist, + gtag); + } + + if (elist) + *elist = ad->taginfo.tags_elist; + + return err; +} + +/* +* remove tag from tags_elist +*/ +int _gl_data_tags_list_remove(void *data, gl_tag *gtag) +{ + gl_dbg(""); + GL_CHECK_VAL(gtag, -1); + GL_CHECK_VAL(gtag->tag, -1); + GL_CHECK_VAL(gtag->tag->tag_name, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_tag *current = NULL; + Eina_List *l = NULL; + + Eina_List *tags_list = ad->taginfo.tags_elist; + EINA_LIST_FOREACH(tags_list, l, current) { + if (!current || !current->tag || !current->tag->tag_name) { + gl_dbgE("NULL tag, continue..."); + continue; + } + if (gtag->tag->_id == current->tag->_id){ + gl_dbg("Found!"); + tags_list = eina_list_remove(tags_list, current); + ad->taginfo.tags_elist = tags_list; + _gl_local_data_delete_tag(gtag->tag); + _gl_data_util_free_gtag(gtag); + break; + } + current = NULL; + } + + return 0; +} + +int _gl_data_get_tag_by_id(void *data, int tag_id, gl_tag **gtag) +{ + GL_CHECK_VAL(data, -1); + GL_CHECK_VAL(gtag, -1); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + gl_tag *current = NULL; + + *gtag = NULL; + + GL_CHECK_VAL(ad->taginfo.tags_elist, -1); + int length = eina_list_count(ad->taginfo.tags_elist); + gl_dbg("Tag length: %d, current tag ID: %d", length, tag_id); + + for (i = 0; i < length; i++) { + current = eina_list_nth(ad->taginfo.tags_elist, i); + if (current && current->tag) { + gl_dbg("Tag: %s", current->tag->tag_name); + } else { + gl_dbgE("Tag is NULL"); + break; + } + + if (current->tag->_id == tag_id) { + *gtag = current; + gl_dbgW("Found!"); + return 0; + } + } + return 0; +} + +/* +* get media item list belongs to some tagname(param: tag_name). +* media item list(param: elist) would be returned to caller, and also saved as ad->media_elist. +*/ +int _gl_data_get_item_list_tagname(void *data, unsigned int tag_id, + bool with_meta, Eina_List ** elist) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + Eina_List *itemlist = NULL; + int err = -1; + + _gl_data_clear_default_item_list(ad); //free item list got previously. + + gl_filter_s filter; + memset(&filter,0x00,sizeof(gl_filter_s)); + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, MEDIA_DISPLAY_NAME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = true; + ad->uginfo.sort_type = filter.sort_type; // Media-svc: ORDER BY tag_name ASC; + + err = _gl_local_data_get_tag_media_list(tag_id, &filter, &itemlist); + if ((err == 0) && (itemlist != NULL)) { + gl_media_s *item = NULL; + gl_item *gitem = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item) { + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem() failed"); + _gl_data_type_free_glitem((void **)&item); + continue; + } + + gitem->ad = ad; + gitem->item = item; + ad->maininfo.medias_elist = eina_list_append(ad->maininfo.medias_elist, gitem); + item = NULL; + gitem = NULL; + } + } + + if (elist) + *elist = ad->maininfo.medias_elist; + + ad->maininfo.medias_cnt = eina_list_count(ad->maininfo.medias_elist); + } else { + ad->maininfo.medias_cnt = 0; + if (itemlist) + _gl_data_util_clear_gtype_item_list(&itemlist); + if (elist) + *elist = NULL; + } + + //gl_dbg("DB all count : %d, ad->media_elist=%p", ad->media_cnt, ad->media_elist); + return err; +} + +int _gl_data_get_first_several_tag_items(void *data, unsigned tag_id, + gl_item *items[], int *item_count) +{ + GL_CHECK_VAL(item_count, -1); + GL_CHECK_VAL(items, -1); + GL_CHECK_VAL(data, -1); + Eina_List *itemlist = NULL; + gl_media_s *item = NULL; + gl_item *gitem = NULL; + int result_cnt = 0; + int err = -1; + + gl_filter_s filter; + memset(&filter,0x00,sizeof(gl_filter_s)); + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, MEDIA_DISPLAY_NAME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_FIRST_VIEW_START_POS; + filter.count = *item_count; + filter.with_meta = true; + + //get a media items' list who are included to the same tag with 'tag_name'. + err = _gl_local_data_get_tag_media_list(tag_id, &filter, &itemlist); + if (err != 0 || itemlist == NULL) { + gl_dbg("Failed to get tag medias[%d]!", err); + *item_count = 0; + if (itemlist) + _gl_data_util_clear_gtype_item_list(&itemlist); + return -1; + } + + EINA_LIST_FREE(itemlist, item) { + if (item == NULL) { + gl_dbgE("Invalid gl_media_s!"); + continue; + } + result_cnt++; + if(result_cnt <= *item_count) { + gitem = NULL; + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem failed!"); + _gl_data_type_free_glitem((void **)&item); + result_cnt--; + continue; + } + gitem->item = item; + items[result_cnt-1] = gitem; + } else { + _gl_data_type_free_glitem((void **)&item); + } + item = NULL; + } + + if(*item_count > result_cnt) + *item_count = result_cnt; + + //gl_dbg("count=%d", *item_count); + return 0; +} +/* +* append tag to tags_selected_elist +*/ +int _gl_data_tags_selected_list_append(void *data, gl_tag *gtag) +{ + GL_CHECK_VAL(gtag, -1); + GL_CHECK_VAL(gtag->tag, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + ad->taginfo.selected_tags_elist = eina_list_append(ad->taginfo.selected_tags_elist, + gtag); + _gl_data_util_check_tag_selected_files(data, + &(ad->selectedinfo.drms_cnt), + &(ad->selectedinfo.images_cnt), + &(ad->selectedinfo.sel_cnt)); + + return 0; +} + +/* +* append album to selected_albums_elist +*/ +int _gl_data_albums_selected_list_append(void *data, gl_cluster *item) +{ + GL_CHECK_VAL(item, -1); + GL_CHECK_VAL(item->cluster, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int drm_cnt = 0; + int img_cnt = 0; + int sel_cnt = 0; + + _gl_data_util_check_album_selected_files(item, &drm_cnt, &img_cnt, + &sel_cnt); + + ad->selectedinfo.images_cnt = ad->selectedinfo.images_cnt + img_cnt; + ad->selectedinfo.drms_cnt = ad->selectedinfo.drms_cnt + drm_cnt; + ad->selectedinfo.sel_cnt = ad->selectedinfo.sel_cnt + sel_cnt; + ad->albuminfo.selected_albums_elist = eina_list_append(ad->albuminfo.selected_albums_elist, item); + + return 0; +} + +/* +* remove tag from tags_selected_elist +*/ +int _gl_data_tags_selected_list_remove(void *data, gl_tag *gtag) +{ + GL_CHECK_VAL(gtag, -1); + GL_CHECK_VAL(gtag->tag, -1); + GL_CHECK_VAL(gtag->tag->tag_name, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_tag *current = NULL; + Eina_List *l = NULL; + + Eina_List *tags_list = ad->taginfo.selected_tags_elist; + EINA_LIST_FOREACH(tags_list, l, current) + { + if (!current || !current->tag) { + gl_dbg("NULL tag in selected list, continue..."); + continue; + } + if (gtag->tag->_id == current->tag->_id) { + ad->taginfo.selected_tags_elist = eina_list_remove(ad->taginfo.selected_tags_elist, + current); + _gl_data_util_check_tag_selected_files(data, + &(ad->selectedinfo.drms_cnt), + &(ad->selectedinfo.images_cnt), + &(ad->selectedinfo.sel_cnt)); + break; + } + current = NULL; + } + + return 0; +} + +/* +* free tags_selected_elist +*/ +int _gl_data_finalize_tags_selected_list(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_tag *gtag = NULL; + + Eina_List *tags_list = ad->taginfo.selected_tags_elist; + EINA_LIST_FREE(tags_list, gtag) + { + if (gtag) + gtag->checked = false; + } + + ad->taginfo.selected_tags_elist = NULL; + return 0; +} + +/* +* return selected tags list count +*/ +int _gl_data_get_tags_selected_cnt(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + if (ad->taginfo.selected_tags_elist) + { + return eina_list_count(ad->taginfo.selected_tags_elist); + } + else + { + return 0; + } +} + +bool _gl_data_is_tags_selected_empty(void *data) +{ + GL_CHECK_VAL(data, 1); + gl_appdata *ad = (gl_appdata *)data; + gl_tag *gtag = NULL; + + Eina_List *l = NULL; + EINA_LIST_FOREACH(ad->taginfo.selected_tags_elist, l, gtag) { + if (gtag && gtag->tag && gtag->tag->count) + return false; + gtag = NULL; + } + + return true; +} + +int _gl_data_get_tags_selected_files_path_str(void *data, gchar sep_c, + char **path_str, int *sel_cnt) +{ + GL_CHECK_VAL(path_str, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->taginfo.selected_tags_elist, -1); + GString *selected_path_list = g_string_new(NULL); + gl_tag *gtag = NULL; + int selected_item_cnt = 0; + Eina_List *l = NULL; + int err = -1; + Eina_List *itemlist = NULL; + + gl_filter_s filter; + memset(&filter,0x00,sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, MEDIA_DISPLAY_NAME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = true; + + EINA_LIST_FOREACH(ad->taginfo.selected_tags_elist, l, gtag) { + if (gtag == NULL || gtag->tag == NULL || + gtag->tag->tag_name == NULL) { + if (selected_path_list) { + g_string_free(selected_path_list, true); + selected_path_list = NULL; + } + return -1; + } + + err = _gl_local_data_get_tag_media_list(gtag->tag->_id, &filter, + &itemlist); + if ((err == 0) && (itemlist != NULL)) { + gl_media_s *item = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + + if (strstr(selected_path_list->str, item->file_url)) { + gl_dbgW("Already appended!"); + continue; + } + + selected_item_cnt++; + g_string_append(selected_path_list, item->file_url); + g_string_append_c(selected_path_list, sep_c); + item = NULL; + } + } + } + gl_dbg("Selected items count: %d.", selected_item_cnt); + if (sel_cnt) + *sel_cnt = selected_item_cnt; + int len = strlen(selected_path_list->str); + g_string_truncate(selected_path_list, len - 1); + /** + * Frees the memory allocated for the GString. + * If free_segment is true it also frees the character data. + * If it's false, the caller gains ownership of the buffer + * and must free it after use with g_free(). + */ + *path_str = g_string_free(selected_path_list, false); + GL_CHECK_VAL(*path_str, -1); + gl_dbg("Total string:\n\n\t>>@@:> %s <:@@<<\n", *path_str); + return 0; +} + +/** +* Get medias count of album or favourites tag. +* b_favor, True: it's favourites tag, False: it's album. +*/ +int _gl_data_get_item_cnt(void *data, const char *cluster_id, bool b_favor, + int album_type, int *item_cnt) +{ + GL_CHECK_VAL(item_cnt, -1); + GL_CHECK_VAL(data, -1); + int err = -1; + gl_dbg("cluster_id: %s, b_favor: %d.", cluster_id, b_favor); + + gl_filter_s filter; + memset(&filter,0x00,sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = false; + + if (b_favor) { + /* It's favourites tag */ + g_strlcpy(filter.cond, GL_CONDITION_FAV_IMAGE_VIDEO, + CONDITION_LENGTH); + err = _gl_local_data_get_all_media_count(&filter, item_cnt); + } else { + GL_CHECK_VAL(cluster_id, -1); + if (album_type == GL_STORE_T_PHONE || + album_type == GL_STORE_T_MMC) { + /*It's normal album*/ + err = _gl_local_data_get_media_count(cluster_id, &filter, + item_cnt); + } else if (album_type == GL_STORE_T_ALL) { + /* All albums */ + gl_dbg("All albums media count."); + err = _gl_local_data_get_all_media_count(&filter, item_cnt); + } else { + gl_dbgE("Invalid cluster_id!"); + return -1; + } + } + + if (err < 0) { + gl_dbg("Failed to get item count[err: %d]!", err); + return -1; + } + + gl_dbg("Item count: %d.", *item_cnt); + return 0; +} + +int _gl_data_update_item_cnt(gl_cluster *album) +{ + GL_CHECK_VAL(album, -1); + GL_CHECK_VAL(album->cluster, -1); + int item_count = 0; + int err = -1; + GL_CHECK_VAL(album->cluster->uuid, -1); + err = _gl_data_get_item_cnt(album->ad, album->cluster->uuid, false, + album->cluster->type, &item_count); + if (err != 0) { + gl_dbg("_gl_data_get_item_cnt failed!"); + album->cluster->count = 0; + return -1; + } + + gl_dbg("Media count: old=%d, new=%d", album->cluster->count, + item_count); + album->cluster->count = item_count; + + return 0; +} + +int _gl_data_get_item_list(void *data, gl_cate_type mode, gl_cluster *album, + int start_pos, int end_pos) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Eina_List *itemlist = NULL; + int err = -1; + int store_type = GL_STORE_T_PHONE; + gl_filter_s filter; + + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = start_pos; + filter.count = end_pos - start_pos + 1; + filter.with_meta = true; + + /* get file-type from service when launched by appcontrol */ + if (ad->albuminfo.aul_launch_type == GL_AUL_T_VIEW_ALBUM) { + if (ad->albuminfo.aul_file_type == GL_AUL_FILE_T_IMAGE) { + g_strlcpy(filter.cond, GL_CONDITION_IMAGE, + CONDITION_LENGTH); + } else if (ad->albuminfo.aul_file_type == GL_AUL_FILE_T_VIDEO) { + g_strlcpy(filter.cond, GL_CONDITION_VIDEO, + CONDITION_LENGTH); + } + } + + if (mode == GL_CATEGORY_FOLDER) { + GL_CHECK_VAL(album, -1); + GL_CHECK_VAL(album->cluster, -1); + gl_dbg("db_get_item_list--folder category; start_pos[%d], end_pos[%d]\n", + start_pos, end_pos); + + GL_CHECK_VAL(album->cluster->uuid, -1); + store_type = album->cluster->type; + + /* Real album */ + if (store_type == GL_STORE_T_PHONE || + store_type == GL_STORE_T_MMC) { + ad->uginfo.sort_type = filter.sort_type; + + if (start_pos == (GL_FIRST_VIEW_END_POS + 1) && + end_pos == GL_GET_UNTIL_LAST_RECORD) { + /* Keep medias_elist and medias_cnt unchanged */ + gl_dbg("Gridview append idler; Keep medias_elist unchanged."); + } else { + /*Clear item list before new one got */ + _gl_data_clear_default_item_list(ad); + } + err = _gl_local_data_get_album_media_list(&filter, + album->cluster->uuid, + &itemlist); + } else if (store_type == GL_STORE_T_ALL) { + /* Get "All" album medias */ + gl_dbg("db_get_item_list--all media\n"); + ad->uginfo.sort_type = filter.sort_type; + + if (start_pos == (GL_FIRST_VIEW_END_POS + 1) && + end_pos == GL_GET_UNTIL_LAST_RECORD) { + /* Keep medias_elist and medias_cnt unchanged */ + gl_dbg("Gridview append idler; Keep medias_elist unchanged."); + } else { + /* Clear item list before new one got */ + _gl_data_clear_default_item_list(ad); + } + + err = _gl_local_data_get_all_albums_media_list(&filter, + &itemlist); + } else { + gl_dbgE("Wrong cluster type!"); + return -1; + } + } else if (mode == GL_CATEGORY_FAVORITES) { + _gl_data_clear_default_item_list(ad); + + g_strlcpy(filter.cond, GL_CONDITION_FAV_IMAGE_VIDEO, + CONDITION_LENGTH); + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = true; + + ad->uginfo.sort_type = filter.sort_type; + + err = _gl_local_data_get_all_albums_media_list(&filter, + &itemlist); + } else { + gl_dbg("View by: %d, undefined till now", mode); + } + + gl_dbg("Error code: %d", err); + if ((err == 0) && (itemlist != NULL)) { + gl_media_s *item = NULL; + gl_item *gitem = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem failed!"); + _gl_data_type_free_glitem((void **)&item); + continue; + } + + gitem->ad = ad; + gitem->item = item; + gitem->store_type = store_type; + ad->maininfo.medias_elist = eina_list_append(ad->maininfo.medias_elist, + gitem); + item = NULL; + gitem = NULL; + } + ad->maininfo.medias_cnt = eina_list_count(ad->maininfo.medias_elist); + gl_dbg("View by: %d, ad->maininfo.medias_elist=%p", mode, ad->maininfo.medias_elist); + } else { + ad->maininfo.medias_cnt = 0; + if (start_pos == (GL_FIRST_VIEW_END_POS + 1) && + end_pos == GL_GET_UNTIL_LAST_RECORD) { + /* Keep medias_elist and medias_cnt unchanged */ + ad->maininfo.medias_cnt = eina_list_count(ad->maininfo.medias_elist); + gl_dbg("Gridview append idler; View by: %d, ad->maininfo.medias_elist=%p", + mode, ad->maininfo.medias_elist); + } else { + ad->maininfo.medias_elist = NULL; + } + if (itemlist) + _gl_data_util_clear_gtype_item_list(&itemlist); + } + + gl_dbg("DB all count : %d", ad->maininfo.medias_cnt); + return err; +} + +int _gl_data_update_item_list(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Eina_List *itemlist = NULL; + int err = -1; + int view_mode = gl_get_view_mode(ad); + Eina_List *sel_id_list = NULL; + gl_item *gitem = NULL; + int store_type = GL_STORE_T_PHONE; + gl_filter_s filter; + + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = true; + + if (view_mode == GL_VIEW_THUMBS_EDIT || + view_mode == GL_VIEW_THUMBS_SELECT) { + gl_dbg("Edit view."); + /* Get ID list of selected items */ + _gl_data_util_get_selected_item_id_list(ad, &sel_id_list); + /* Free old list */ + _gl_data_selected_list_finalize(ad); + } + + /* In albums tab, or album select view from tag, current album is available */ + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_ALBUMS || + view_mode == GL_VIEW_THUMBS_SELECT) { + gl_cluster *cur_album = ad->albuminfo.current_album; + GL_CHECK_VAL(cur_album, -1); + GL_CHECK_VAL(cur_album->cluster, -1); + GL_CHECK_VAL(cur_album->cluster->uuid, -1); + store_type = cur_album->cluster->type; + + ad->uginfo.sort_type = filter.sort_type; + /* Clear item list before new one got */ + _gl_data_clear_default_item_list(ad); + + if (store_type == GL_STORE_T_ALL) { + gl_dbg("All albums medias"); + err = _gl_local_data_get_all_albums_media_list(&filter, + &itemlist); + } else { + gl_dbg("Local album medias"); + err = _gl_local_data_get_album_media_list(&filter, + cur_album->cluster->uuid, + &itemlist); + } + } else if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + /* Set current tag */ + gl_tag *cur_tag = ad->taginfo.current_tag; + GL_CHECK_VAL(cur_tag, -1); + GL_CHECK_VAL(cur_tag->tag, -1); + /* get favorites tag */ + if (cur_tag->tag->_id == GL_TAG_FAVORITES_ID) { + gl_dbg("Favourites tag medias"); + /* Clear item list before new one got */ + _gl_data_clear_default_item_list(ad); + g_strlcpy(filter.cond, GL_CONDITION_FAV_IMAGE_VIDEO, + CONDITION_LENGTH); + + ad->uginfo.sort_type = filter.sort_type; + + err = _gl_local_data_get_all_albums_media_list(&filter, + &itemlist); + } else { + gl_dbg("Normal tag medias"); + _gl_data_clear_default_item_list(ad); + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, MEDIA_DISPLAY_NAME, + KEYWORD_LENGTH); + ad->uginfo.sort_type = filter.sort_type; + + err = _gl_local_data_get_tag_media_list(cur_tag->tag->_id, + &filter, + &itemlist); + } + } + + gl_dbg("Error code: %d", err); + if ((err != 0) || (itemlist == NULL)) { + gl_dbgE("(err != 0) || (itemlist == NULL)"); + ad->maininfo.medias_cnt = 0; + ad->maininfo.medias_elist = NULL; + /* Clear list of selected ID */ + if (sel_id_list) { + eina_list_free(sel_id_list); + sel_id_list = NULL; + } + + if (itemlist) + _gl_data_util_clear_gtype_item_list(&itemlist); + + return err; + } + + bool b_selected = false; + gl_media_s *item = NULL; + Eina_List *medias_elist = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem failed!"); + _gl_data_type_free_glitem((void **)&item); + continue; + } + gitem->ad = ad; + gitem->item = item; + gitem->store_type = store_type; + + /* Append item to medias_elist */ + medias_elist = eina_list_append(ad->maininfo.medias_elist, + gitem); + ad->maininfo.medias_elist = medias_elist; + + if (sel_id_list) { + b_selected = _gl_data_util_check_selected_id(&sel_id_list, + item->uuid); + if (b_selected) { + b_selected = false; + /* Set checkbox state */ + gitem->checked = true; + /* Append gitem to selected list */ + _gl_data_selected_list_append(ad, gitem); + } + } + } + + /* Clear list of selected ID */ + if (sel_id_list) + _gl_data_util_free_selected_id_list(&sel_id_list); + + ad->maininfo.medias_cnt = eina_list_count(ad->maininfo.medias_elist); + gl_dbg("All medias count:%d.", ad->maininfo.medias_cnt); + return err; +} + +int _gl_data_get_item_list_without_tag(void *data, gl_cluster *album, + const char *tag_name, int start_pos, + int end_pos) +{ + GL_CHECK_VAL(tag_name, -1); + GL_CHECK_VAL(album, -1); + GL_CHECK_VAL(album->cluster, -1); + GL_CHECK_VAL(album->cluster->uuid, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Eina_List *itemlist = NULL; + int err = -1; + gl_filter_s filter; + + memset(&filter,0x00,sizeof(gl_filter_s)); + if (ad->taginfo.current_tag && ad->taginfo.current_tag->tag && + ad->taginfo.current_tag->tag->_id == GL_TAG_FAVORITES_ID) + g_strlcpy(filter.cond, GL_CONDITION_WITHOUT_FAVOURITE, CONDITION_LENGTH); + else + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = start_pos; + filter.count = end_pos - start_pos + 1; + filter.with_meta = true; + + gl_dbg("tag_name[%s], start_pos[%d], end_pos[%d]", tag_name, start_pos, + end_pos); + + /* Real album */ + if (album->cluster->type == GL_STORE_T_PHONE || + album->cluster->type == GL_STORE_T_MMC) { + if (start_pos == (GL_FIRST_VIEW_END_POS + 1) && + end_pos == GL_GET_UNTIL_LAST_RECORD) { + /* Keep medias_elist and medias_cnt unchanged */ + gl_dbg("Gridview append idler; Keep medias_elist unchanged."); + } else { + /*Clear item list before new one got */ + _gl_data_clear_default_item_list(ad); + } + + err = _gl_local_data_get_album_media_list_without_tag(&filter, + album->cluster->uuid, + tag_name, + &itemlist); + } else if (album->cluster->type == GL_STORE_T_ALL) { + /* All albums */ + gl_dbg("All albums medias"); + if (start_pos == (GL_FIRST_VIEW_END_POS + 1) && + end_pos == GL_GET_UNTIL_LAST_RECORD) { + /* Keep medias_elist and medias_cnt unchanged */ + gl_dbg("Gridview append idler; Keep medias_elist unchanged."); + } else { + /* Clear item list before new one got */ + _gl_data_clear_default_item_list(ad); + } + + err = _gl_local_data_get_all_albums_media_list_without_tag(&filter, + tag_name, + &itemlist); + } else { + gl_dbgE("Wrong album type!"); + return -1; + } + + gl_dbg("Error code: %d", err); + if ((err == 0) && (itemlist != NULL)) { + gl_media_s *item = NULL; + gl_item *gitem = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem failed!"); + _gl_data_type_free_glitem((void **)&item); + continue; + } + + gitem->ad = ad; + gitem->item = item; + gitem->store_type = album->cluster->type; + ad->maininfo.medias_elist = eina_list_append(ad->maininfo.medias_elist, + gitem); + item = NULL; + gitem = NULL; + } + + ad->maininfo.medias_cnt = eina_list_count(ad->maininfo.medias_elist); + gl_dbg("medias_elist=%p", ad->maininfo.medias_elist); + } else { + ad->maininfo.medias_cnt = 0; + if (start_pos == (GL_FIRST_VIEW_END_POS + 1) && + end_pos == GL_GET_UNTIL_LAST_RECORD) { + /* Keep medias_elist and medias_cnt unchanged */ + ad->maininfo.medias_cnt = eina_list_count(ad->maininfo.medias_elist); + gl_dbg("Gridview append idler; medias_elist=%p", + ad->maininfo.medias_elist); + } else { + ad->maininfo.medias_elist = NULL; + } + if (itemlist) + _gl_data_util_clear_gtype_item_list(&itemlist); + } + + gl_dbg("All count: %d", ad->maininfo.medias_cnt); + return err; +} + +int _gl_data_update_item_list_without_tag(void *data, gl_cluster *album, + const char *tag_name) +{ + GL_CHECK_VAL(tag_name, -1); + GL_CHECK_VAL(album, -1); + GL_CHECK_VAL(album->cluster, -1); + GL_CHECK_VAL(album->cluster->uuid, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Eina_List *itemlist = NULL; + int err = -1; + Eina_List *sel_id_list = NULL; + gl_item *gitem = NULL; + gl_filter_s filter; + + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = true; + + /* Get ID list of selected items */ + _gl_data_util_get_selected_item_id_list(ad, &sel_id_list); + /* Free old list */ + _gl_data_selected_list_finalize(ad); + + /* Clear item list before new one got */ + _gl_data_clear_default_item_list(ad); + + /* Real album */ + if (album->cluster->type == GL_STORE_T_PHONE || + album->cluster->type == GL_STORE_T_MMC) { + err = _gl_local_data_get_album_media_list_without_tag(&filter, + album->cluster->uuid, + tag_name, + &itemlist); + } else if (album->cluster->type == GL_STORE_T_ALL) { + /* All albums */ + gl_dbg("All albums medias"); + err = _gl_local_data_get_all_albums_media_list_without_tag(&filter, + tag_name, + &itemlist); + } else { + gl_dbgE("Wrong album type!"); + return -1; + } + + gl_dbg("Error code: %d", err); + if ((err != 0) || (itemlist == NULL)) { + gl_dbgE("(err != 0) || (itemlist == NULL)"); + ad->maininfo.medias_cnt = 0; + ad->maininfo.medias_elist = NULL; + /* Clear list of selected ID */ + if (sel_id_list) { + eina_list_free(sel_id_list); + sel_id_list = NULL; + } + + if (itemlist) + _gl_data_util_clear_gtype_item_list(&itemlist); + + return err; + } + + bool b_selected = false; + gl_media_s *item = NULL; + Eina_List *medias_elist = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem failed!"); + _gl_data_type_free_glitem((void **)&item); + continue; + } + gitem->ad = ad; + gitem->item = item; + gitem->store_type = album->cluster->type; + + /* Append item to medias_elist */ + medias_elist = eina_list_append(ad->maininfo.medias_elist, + gitem); + ad->maininfo.medias_elist = medias_elist; + + if (sel_id_list) { + b_selected = _gl_data_util_check_selected_id(&sel_id_list, + item->uuid); + if (b_selected) { + b_selected = false; + /* Set checkbox state */ + gitem->checked = true; + /* Append gitem to selected list */ + _gl_data_selected_list_append(ad, gitem); + } + } + } + + /* Clear list of selected ID */ + if (sel_id_list) + _gl_data_util_free_selected_id_list(&sel_id_list); + + ad->maininfo.medias_cnt = eina_list_count(ad->maininfo.medias_elist); + gl_dbg("All medias count:%d.", ad->maininfo.medias_cnt); + return err; +} + +int _gl_data_get_first_several_favor_items(void *data, gl_item *items[], + int *item_count, + media_content_order_e sort_type) +{ + GL_CHECK_VAL(items, -1); + GL_CHECK_VAL(item_count, -1); + GL_CHECK_VAL(data, -1); + Eina_List *itemlist = NULL; + gl_media_s *item = NULL; + gl_item *gitem = NULL; + int result_cnt = 0; + int err = -1; + //gl_dbg(""); + + gl_filter_s filter; + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_FAV_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = sort_type; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_FIRST_VIEW_START_POS; + filter.count = *item_count; + filter.with_meta = false; + + err = _gl_local_data_get_all_albums_media_list(&filter, &itemlist); + if (err != 0 || itemlist == NULL) { + gl_dbg("Failed to get all medias[%d]!", err); + *item_count = 0; + if (itemlist) + _gl_data_util_clear_gtype_item_list(&itemlist); + return -1; + } + + EINA_LIST_FREE(itemlist, item) { + if (item == NULL) { + gl_dbgE("Invalid gl_media_s!"); + continue; + } + result_cnt++; + if(result_cnt <= *item_count) { + gitem = NULL; + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem failed!"); + _gl_data_type_free_glitem((void **)&item); + result_cnt--; + continue; + } + gitem->item = item; + items[result_cnt-1] = gitem; + } else { + _gl_data_type_free_glitem((void **)&item); + } + item = NULL; + } + + if(*item_count > result_cnt) + *item_count = result_cnt; + + //gl_dbg("count=%d", *item_count); + return 0; +} + +int _gl_data_get_first_several_items(gl_cluster *album, gl_item *items[], + int *item_count, + media_content_order_e sort_type) +{ + GL_CHECK_VAL(items, -1); + GL_CHECK_VAL(item_count, -1); + GL_CHECK_VAL(album, -1); + GL_CHECK_VAL(album->cluster, -1); + GL_CHECK_VAL(album->cluster->uuid, -1); + GL_CHECK_VAL(album->ad, -1); + gl_appdata *ad = (gl_appdata *)album->ad; + Eina_List *item_list = NULL; + int result_cnt = 0; + gl_media_s *item = NULL; + gl_item *gitem = NULL; + int err = -1; + + if (*item_count <= 0) + return 0; + + gl_filter_s filter; + memset(&filter, 0x00, sizeof(gl_filter_s)); + if (ad->taginfo.current_tag && ad->taginfo.current_tag->tag) { + if (ad->taginfo.current_tag->tag->_id == GL_TAG_FAVORITES_ID) + g_strlcpy(filter.cond, GL_CONDITION_WITHOUT_FAVOURITE, + CONDITION_LENGTH); + else + snprintf(filter.cond, CONDITION_LENGTH, + GL_CONDITION_WITHOUT_TAG, + ad->taginfo.current_tag->tag->_id); + } else { + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + } + filter.sort_type = sort_type; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_FIRST_VIEW_START_POS; + filter.count = *item_count; + filter.with_meta = false; + + if (album->cluster->type == GL_STORE_T_PHONE || + album->cluster->type == GL_STORE_T_MMC) { + /* real album */ + err = _gl_local_data_get_album_media_list(&filter, + album->cluster->uuid, + &item_list); + if (err != 0 || item_list == NULL) { + gl_dbgE("Get album medias failed[%d]", err); + *item_count = 0; + if (item_list) + _gl_data_util_clear_gtype_item_list(&item_list); + return -1; + } + + EINA_LIST_FREE(item_list, item) { + if (item == NULL) { + gl_dbgE("Invalid gl_media_s!"); + continue; + } + result_cnt++; + if(result_cnt <= *item_count) { + gitem = NULL; + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem failed!"); + _gl_data_type_free_glitem((void **)&item); + result_cnt--; + continue; + } + gitem->item = item; + items[result_cnt-1] = gitem; + } else { + _gl_data_type_free_glitem((void **)&item); + } + item = NULL; + } + + if(*item_count > result_cnt) + *item_count = result_cnt; + } else if (album->cluster->type == GL_STORE_T_ALL) { + /* add "All" album */ + gl_dbg("db_get_item_list--all media\n"); + /* use new api to get all local files, mmc status checking would be done in new apis */ + err = _gl_local_data_get_all_albums_media_list(&filter, + &item_list); + if (err != 0 || item_list == NULL) { + gl_dbgE("Failed to get all medias[%d]!", err); + *item_count = 0; + if (item_list) + _gl_data_util_clear_gtype_item_list(&item_list); + + return -1; + } + + EINA_LIST_FREE(item_list, item) { + if (item == NULL) { + gl_dbgE("Invalid gl_media_s!"); + continue; + } + result_cnt++; + if(result_cnt <= *item_count) { + gitem = NULL; + gitem = _gl_data_util_calloc_gitem(); + if (gitem == NULL) { + gl_dbgE("_gl_data_util_calloc_gitem failed!"); + _gl_data_type_free_glitem((void **)&item); + result_cnt--; + continue; + } + gitem->item = item; + gitem->store_type = album->cluster->type; + items[result_cnt-1] = gitem; + } else { + _gl_data_type_free_glitem((void **)&item); + } + item = NULL; + } + + if(*item_count > result_cnt) + *item_count = result_cnt; + } else { + gl_dbgE("Wrong cluster type!"); + return -1; + } + + if (*item_count) { + gl_dbg("first %d items for this album(%s)", + *item_count, album->cluster->display_name); + } + + return 0; +} + +bool _gl_data_is_item_cnt_zero(void *data, media_content_type_e type) +{ + GL_CHECK_VAL(data, false); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + gl_item *gitem = NULL; + + /* Get all medias count of current album */ + int all_cnt = ad->maininfo.medias_cnt; + for (i = 1; i <= all_cnt; i++) { + _gl_data_get_item_by_index(ad, i, false, &gitem); + if (gitem && gitem->item) { + if (gitem->item->type == type) { + return false; + } + } + } + + gl_dbg(" item_cnt = 0 "); + return true; +} + +int _gl_data_get_first_item(void *data, media_content_type_e type, + gl_item **fitem, bool b_selected) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + gl_item *gitem = NULL; + + /* Get first item for 'All' */ + if (type == MEDIA_CONTENT_TYPE_OTHERS) { + _gl_data_get_item_by_index(ad, 1, b_selected, &gitem); + *fitem = gitem; + return 0; + } + + /* Get first item for "Images" or "Videos" */ + for (i = 1; i <= ad->maininfo.medias_cnt; i++) { + _gl_data_get_item_by_index(ad, i, b_selected, &gitem); + if (gitem && gitem->item && gitem->item->type == type) { + *fitem = gitem; + return 0; + } + } + + gl_dbgW("Not found!"); + return -1; +} + +int _gl_data_destroy_item(gl_item *gitem) +{ + GL_CHECK_VAL(gitem, -1); + GL_CHECK_VAL(gitem->item, -1); + _gl_data_util_free_gitem(gitem); + return 0; +} + +/** +* select_mode: true, get item from selected_media_elist; false, get item from media_elist. +*/ +int _gl_data_get_item_by_index(void *data, int idx, bool select_mode, + gl_item **gitem) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (!select_mode) { + if (idx > ad->maininfo.medias_cnt) { + gl_dbg("db_get_item_by_index(%d) is failed, ad->maininfo.medias_cnt=%d\n", + idx, ad->maininfo.medias_cnt); //test + *gitem = NULL; + return -1; + } + + *gitem = eina_list_nth(ad->maininfo.medias_elist, idx - 1); + } else { + Eina_List *sel_list = ad->selectedinfo.medias_elist; + *gitem = (gl_item *) eina_list_nth(sel_list, --idx); + } + return 0; +} + +int _gl_data_get_orig_item_by_index(void *data, gl_item **gitem, int idx) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (idx > ad->maininfo.medias_cnt) + { + gl_dbg("_gl_data_get_orig_item_by_index(%d) is failed(>media_cnt-%d)\n", + idx, ad->maininfo.medias_cnt); //test + *gitem = NULL; + return -1; + } + + *gitem = eina_list_nth(ad->maininfo.medias_elist, idx - 1); + + return 0; +} + +int _gl_data_item_list_remove(void *data, gl_item *gitem) +{ + GL_CHECK_VAL(gitem, -1); + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(gitem->item->uuid, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_item *current = NULL; + Eina_List *l = NULL; + + Eina_List *media_elist = ad->maininfo.medias_elist; + EINA_LIST_FOREACH(media_elist, l, current) { + if (current == NULL || current->item == NULL || + current->item->uuid == NULL) { + gl_dbgE("Invalid gitem!"); + continue; + } + + if (!g_strcmp0(current->item->uuid, gitem->item->uuid)) { + ad->maininfo.medias_elist = eina_list_remove(ad->maininfo.medias_elist, + current); + ad->maininfo.medias_cnt--; + _gl_data_destroy_item(current); + break; + } + current = NULL; + } + + return 0; +} + +/* Remove file from DB and file system */ +int _gl_data_remove_item(gl_item *gitem) +{ + GL_CHECK_VAL(gitem, -1); + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(gitem->item->uuid, -1); + int ret = -1; + + /* Delete record from DB then delete media from file system */ + ret = media_info_delete_from_db(gitem->item->uuid); + if (ret != 0) { + gl_dbgE("media_info_delete_from_db failed[%d]!", ret); + return -1; + } + + if (!ecore_file_unlink(gitem->item->file_url)) { + char *error_msg = calloc(1, GL_ARRAY_LEN_MAX); + GL_CHECK_VAL(error_msg, -1); + gl_dbgE("ecore_file_unlink failed[Err:%s]!", + strerror_r(errno, error_msg, GL_ARRAY_LEN_MAX)); + GL_FREE(error_msg); + return -1; + } + + return 0; +} + +gl_item *_gl_data_selected_list_get_nth(void *data, int idx) +{ + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + + return eina_list_nth(ad->selectedinfo.medias_elist, idx); +} + +int _gl_data_selected_list_append(void *data, gl_item *gitem) +{ + GL_CHECK_VAL(gitem, -1); + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Update selected images count */ + if (gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE) { + ad->selectedinfo.images_cnt++; +#ifdef _USE_ROTATE_BG + gl_dbg("Ext: %s", gitem->item->ext); + if (gitem->item->ext && + !strcasecmp(gitem->item->ext, GL_JPEG_FILE_EXT)) { + unsigned int orientation = 1; + if(_gl_exif_get_orientation(gitem->item->file_url, &orientation) == 0) + ad->selectedinfo.jpeg_cnt++; + } +#endif + } + + /* Update selected DRM files count */ + if (gl_drm_is_drm_file(gitem->item->file_url)) + ad->selectedinfo.drms_cnt++; + + Eina_List *sel_list = ad->selectedinfo.medias_elist; + sel_list = eina_list_append(sel_list, gitem); + ad->selectedinfo.medias_elist = sel_list; + return 0; +} + +int _gl_data_selected_list_remove(void *data, gl_item *gitem) +{ + GL_CHECK_VAL(gitem, -1); + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(gitem->item->uuid, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_item *current = NULL; + Eina_List *l = NULL; + + Eina_List *sel_list = ad->selectedinfo.medias_elist; + EINA_LIST_FOREACH(sel_list, l, current) { + if (current == NULL || current->item == NULL || + current->item->uuid == NULL) { + gl_dbgE("Invalid gitem!"); + continue; + } + if (!g_strcmp0(current->item->uuid, gitem->item->uuid)) { + /* Update selected images count */ + if (current->item->type == MEDIA_CONTENT_TYPE_IMAGE && + ad->selectedinfo.images_cnt > 0) { + ad->selectedinfo.images_cnt--; +#ifdef _USE_ROTATE_BG + if (gitem->item->ext && + !strcasecmp(gitem->item->ext,GL_JPEG_FILE_EXT) && + ad->selectedinfo.jpeg_cnt > 0) { + unsigned int orientation = 1; + if(_gl_exif_get_orientation(gitem->item->file_url, &orientation) == 0) + ad->selectedinfo.jpeg_cnt--; + } +#endif + } + + /* Update selected DRM files count */ + if (gl_drm_is_drm_file(gitem->item->file_url) && + ad->selectedinfo.drms_cnt > 0) + ad->selectedinfo.drms_cnt--; + + sel_list = eina_list_remove(sel_list, current); + ad->selectedinfo.medias_elist = sel_list; + break; + } + current = NULL; + } + return 0; +} + +int _gl_data_selected_list_finalize(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_item *gitem = NULL; + + Eina_List *sel_list = ad->selectedinfo.medias_elist; + EINA_LIST_FREE(sel_list, gitem) { + if (gitem) + gitem->checked = false; + } + + ad->selectedinfo.medias_elist = NULL; + ad->selectedinfo.images_cnt = 0; + ad->selectedinfo.drms_cnt = 0; +#ifdef _USE_ROTATE_BG + ad->selectedinfo.jpeg_cnt = 0; +#endif + return 0; +} + +int _gl_data_selected_list_count(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + return eina_list_count(ad->selectedinfo.medias_elist); +} + +bool _gl_data_is_root_path(const char *path) +{ + if (path == NULL) + return false; + + if (!g_strcmp0(GL_ROOT_PATH_PHONE, path) || + !g_strcmp0(GL_ROOT_PATH_MMC, path)) { + gl_dbg("Root path: %s", path); + return true; + } + + return false; +} + +bool _gl_data_is_albums_selected_empty(void *data) +{ + GL_CHECK_VAL(data, 1); + gl_appdata *ad = (gl_appdata *)data; + gl_cluster *album = NULL; + + Eina_List *l = NULL; + EINA_LIST_FOREACH(ad->albuminfo.selected_albums_elist, l, album) { + if (album && album->cluster && album->cluster->count) + return false; + album = NULL; + } + + return true; +} + +/** + * If 'All albums' selected for share, only append files contained in 'All albums'; + * If both local albums and web albums selected, 'Share' item should be disabled. + */ +int _gl_data_get_albums_selected_files_path_str(void *data, gchar sep_c, + char **path_str, int *sel_cnt) +{ + GL_CHECK_VAL(path_str, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->albuminfo.selected_albums_elist, -1); + GString *selected_path_list = g_string_new(NULL); + gl_cluster *album = NULL; + int selected_item_cnt = 0; + Eina_List *l = NULL; + int err = -1; + Eina_List *itemlist = NULL; + + gl_filter_s filter; + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GL_GET_ALL_RECORDS; + filter.count = GL_GET_ALL_RECORDS; + filter.with_meta = false; + + EINA_LIST_FOREACH(ad->albuminfo.selected_albums_elist, l, album) { + if (album == NULL || album->cluster == NULL || + album->cluster->uuid == NULL) { + if (selected_path_list) { + g_string_free(selected_path_list, true); + selected_path_list = NULL; + } + return -1; + } + if (album->cluster->type == GL_STORE_T_ALL) { + gl_dbg("All albums"); + err = _gl_local_data_get_all_albums_media_list(&filter, + &itemlist); + /** + *Clear previous appended path, + * replaced with All albums content + */ + if (selected_path_list && selected_path_list->str) { + gl_dbgW("Free previous path string!"); + g_string_free(selected_path_list, true); + selected_path_list = g_string_new(NULL); + selected_item_cnt = 0; + } + } else if (album->cluster->type == GL_STORE_T_PHONE || + album->cluster->type == GL_STORE_T_MMC) { + gl_dbg("Local album"); + err = _gl_local_data_get_album_media_list(&filter, + album->cluster->uuid, + &itemlist); + } else { + gl_dbgE("Wrong cluster type!"); + return -1; + } + + if ((err == 0) && (itemlist != NULL)) { + gl_media_s *item = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + + selected_item_cnt++; + g_string_append(selected_path_list, item->file_url); + g_string_append_c(selected_path_list, sep_c); + item = NULL; + } + + /* Break for look if 'All albums' appended */ + if (album->cluster->type == GL_STORE_T_ALL) { + gl_dbg("Appent All albums content."); + break; + } + } + } + gl_dbg("Selected items count: %d.", selected_item_cnt); + if (sel_cnt) + *sel_cnt = selected_item_cnt; + int len = strlen(selected_path_list->str); + g_string_truncate(selected_path_list, len - 1); + /** + * Frees the memory allocated for the GString. + * If free_segment is true it also frees the character data. + * If it's false, the caller gains ownership of the buffer + * and must free it after use with g_free(). + */ + *path_str = g_string_free(selected_path_list, false); + GL_CHECK_VAL(*path_str, -1); + gl_dbg("Total string:\n\n\t>>@@:> %s <:@@<<\n", *path_str); + return 0; +} + +int _gl_data_get_albums_selected_cnt(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + return eina_list_count(ad->albuminfo.selected_albums_elist); +} + +int _gl_data_albums_selected_list_remove(void *data, gl_cluster *item) +{ + GL_CHECK_VAL(item, -1); + GL_CHECK_VAL(item->cluster, -1); + GL_CHECK_VAL(item->cluster->uuid, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_cluster *current = NULL; + Eina_List *l = NULL; + + Eina_List *sel_list = ad->albuminfo.selected_albums_elist; + EINA_LIST_FOREACH(sel_list, l, current) { + if (current == NULL || current->cluster == NULL || + current->cluster->uuid == NULL) { + gl_dbgE("Invalid gcluster!"); + continue; + } + + if (!g_strcmp0(current->cluster->uuid, item->cluster->uuid)) { + int drm_cnt = 0; + int img_cnt = 0; + int sel_cnt = 0; + + _gl_data_util_check_album_selected_files(item, &drm_cnt, + &img_cnt, + &sel_cnt); + + ad->selectedinfo.images_cnt = ad->selectedinfo.images_cnt - img_cnt; + ad->selectedinfo.drms_cnt = ad->selectedinfo.drms_cnt - drm_cnt; + ad->selectedinfo.sel_cnt = ad->selectedinfo.sel_cnt - sel_cnt; + + ad->albuminfo.selected_albums_elist = eina_list_remove(ad->albuminfo.selected_albums_elist, + current); + break; + } + current = NULL; + } + + return 0; +} + +int _gl_data_finalize_albums_selected_list(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_cluster *item = NULL; + + Eina_List *sel_list = ad->albuminfo.selected_albums_elist; + EINA_LIST_FREE(sel_list, item) { + if (item) + item->checked = false; + } + + ad->selectedinfo.images_cnt = 0; + ad->selectedinfo.drms_cnt = 0; + ad->selectedinfo.sel_cnt = 0; + ad->albuminfo.selected_albums_elist = NULL; + return 0; +} + +bool _gl_data_check_update(void *data, bool b_all) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + int err = -1; + Eina_List *item_list = NULL; + gl_media_s *mitem = NULL; + int cnt = 0; + gl_item *gitem = NULL; + + gl_filter_s filter; + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.with_meta = false; + filter.offset = GL_FIRST_VIEW_START_POS; + filter.count = GL_GET_ONE_RECORDS; + + if (b_all) { + /* Get latest item */ + err = _gl_local_data_get_all_albums_media_list(&filter, + &item_list); + if (err != 0 || item_list == NULL) + goto DB_NEED_UPDATE; + + mitem = eina_list_nth(item_list, 0); + /* Compare modified time */ + if (mitem == NULL || mitem->mtime != ad->maininfo.last_mtime) + goto DB_NEED_UPDATE; + + /* Get all medias count */ + err = _gl_data_get_item_cnt(ad, GL_ALBUM_ALL_ID, false, + GL_STORE_T_ALL, &cnt); + if (err != 0) + goto DB_NEED_UPDATE; + + /* Compare medias count */ + if (cnt != ad->maininfo.all_medias_cnt) + goto DB_NEED_UPDATE; + } else { + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + gl_tag *cur_tag = ad->taginfo.current_tag; + if (cur_tag == NULL || cur_tag->tag == NULL) + goto DB_NEED_UPDATE; + + /* Get all medias count */ + if (cur_tag->tag->_id == GL_TAG_FAVORITES_ID) + err = _gl_data_get_item_cnt(ad, + GL_GET_ALL_RECORDS_ID, + true, + GL_STORE_T_PHONE, + &cnt); + else + err = _gl_local_data_get_tag_media_count(cur_tag->tag->_id, + &filter, + &cnt); + if (err != 0) + goto DB_NEED_UPDATE; + /* Compare medias count */ + if (cnt != ad->maininfo.medias_cnt) + goto DB_NEED_UPDATE; + } else { + gitem = eina_list_nth(ad->maininfo.medias_elist, 0); + if (gitem == NULL || gitem->item == NULL) + goto DB_NEED_UPDATE; + + gl_cluster *cur_album = ad->albuminfo.current_album; + if (cur_album == NULL || cur_album->cluster == NULL || + cur_album->cluster->uuid == NULL) + goto DB_NEED_UPDATE; + + /* Get latest item */ + if (cur_album->cluster->type == GL_STORE_T_ALL) { + err = _gl_local_data_get_all_albums_media_list(&filter, + &item_list); + } else if (cur_album->cluster->type == GL_STORE_T_PHONE || + cur_album->cluster->type == GL_STORE_T_MMC) { + err = _gl_local_data_get_album_media_list(&filter, + cur_album->cluster->uuid, + &item_list); + } else { + gl_dbgE("Wrong cluster type!"); + return false; + } + + if (err != 0) + goto DB_NEED_UPDATE; + + mitem = eina_list_nth(item_list, 0); + /* Compare modified time */ + if (mitem == NULL || mitem->mtime != gitem->item->mtime) + goto DB_NEED_UPDATE; + + /* Get all medias count */ + err = _gl_data_get_item_cnt(ad, cur_album->cluster->uuid, + false, + cur_album->cluster->type, + &cnt); + if (err != 0) + goto DB_NEED_UPDATE; + + /* Compare medias count */ + if (cnt != ad->maininfo.medias_cnt) + goto DB_NEED_UPDATE; + } + } + + mitem = NULL; + EINA_LIST_FREE(item_list, mitem) { + _gl_data_type_free_glitem((void **)&mitem); + mitem = NULL; + } + return false; + + DB_NEED_UPDATE: + mitem = NULL; + EINA_LIST_FREE(item_list, mitem) { + _gl_data_type_free_glitem((void **)&mitem); + mitem = NULL; + } + gl_dbgW("Need to update data and view!"); + return true; +} + +int _gl_data_init() +{ + int err = _gl_local_data_connect(); + if (err != 0) + gl_dbgE("Connect to media-content DB failed!"); + + return err; +} + +int _gl_data_finalize(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + __gl_data_clear_cluster_list(ad, true); + _gl_data_clear_default_item_list(ad); + + _gl_data_util_free_tag_list(ad); + + int err = _gl_local_data_disconnect(); + if (err != 0) + gl_dbgE("Disconnect with media-content DB failed!"); + + return err; +} + +int _gl_data_delete_media(void *data, gl_media_s *media_item) +{ + GL_CHECK_VAL(media_item, -1); + int ret = -1; + + if (media_item->gtype == GL_TYPE_MEDIA) + ret = media_info_delete_from_db(media_item->uuid); + return ret; +} + +/* Creates a thumbnail image for given the media, asynchronously */ +int _gl_data_create_thumb(gl_item *gitem, media_thumbnail_completed_cb callback, + void *user_data) +{ + GL_CHECK_VAL(gitem, -1); + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(gitem->item->media_h, -1); + int ret = -1; + gl_dbg("File[%s]", gitem->item->file_url); + + ret = media_info_create_thumbnail(gitem->item->media_h, callback, + user_data); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to create thumbnail!"); + return -1; + } + return 0; +} + diff --git a/src/data/gl-local-data.c b/src/data/gl-local-data.c new file mode 100755 index 0000000..3270f4f --- /dev/null +++ b/src/data/gl-local-data.c @@ -0,0 +1,1479 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "gl-local-data.h" +#include "gl-debug.h" +#include "gl-data.h" + +typedef struct _gl_transfer_data_t gl_transfer_data_s; +typedef struct _gl_foreach_data_t gl_foreach_data_s; + +struct _gl_transfer_data_t { + void **userdata; + filter_h filter; + char *album_id; + bool with_meta; +}; + +struct _gl_foreach_data_t { + void **userdata; + filter_h filter; + char *album_id; + char *tag_name; + bool with_meta; +}; + +static int __gl_local_data_create_filter(gl_filter_s *condition, filter_h *filter) +{ + GL_CHECK_VAL(filter, -1); + GL_CHECK_VAL(condition, -1); + int ret = -1; + filter_h tmp_filter = NULL; + ret = media_filter_create(&tmp_filter); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Fail to create filter"); + return -1; + } + + if (strlen(condition->cond) > 0) { + ret = media_filter_set_condition(tmp_filter, condition->cond, + condition->collate_type); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Fail to set condition"); + goto GL_LOCAL_FAILED; + } + } + + if (strlen(condition->sort_keyword) > 0) { + ret = media_filter_set_order(tmp_filter, condition->sort_type, + condition->sort_keyword, + condition->collate_type); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Fail to set order"); + goto GL_LOCAL_FAILED; + } + } + + if (condition->offset != -1 && condition->count != -1 && + condition->count > 0) { + ret = media_filter_set_offset(tmp_filter, condition->offset, + condition->count); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Fail to set offset"); + goto GL_LOCAL_FAILED; + } + } + + *filter = tmp_filter; + return 0; + + GL_LOCAL_FAILED: + + if (tmp_filter) { + media_filter_destroy(tmp_filter); + tmp_filter = NULL; + *filter = NULL; + } + return -1; +} + +static int __gl_local_data_destroy_filter(filter_h filter) +{ + GL_CHECK_VAL(filter, -1); + if (media_filter_destroy(filter) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to destroy filter!"); + return -1; + } + + return 0; +} + +static bool __gl_local_data_get_album_list_cb(media_folder_h folder, + void *data) +{ + GL_CHECK_FALSE(data); + gl_transfer_data_s *tmp_data = (gl_transfer_data_s *)data; + GL_CHECK_FALSE(tmp_data->userdata); + GL_CHECK_FALSE(tmp_data->filter); + GL_CHECK_FALSE(folder); + + Eina_List **elist = (Eina_List **)(tmp_data->userdata); + gl_album_s *album = NULL; + + album = (gl_album_s *)calloc(1, sizeof(gl_album_s)); + GL_CHECK_FALSE(album); + album->gtype = GL_TYPE_ALBUM; + + if (media_folder_clone(&(album->folder_h), folder) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Clone folder handle failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_folder_get_folder_id(folder, &(album->uuid)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get folder id failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_folder_get_modified_time(folder, &(album->mtime)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get modified time failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_folder_get_storage_type(folder, (media_content_storage_e *)&(album->type)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get storage type failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_folder_get_name(folder, &(album->display_name)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get folder name failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_folder_get_path(folder, &(album->path)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get folder name failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_folder_get_media_count_from_db(album->uuid, tmp_data->filter, &(album->count)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get count[uuid: %s]", album->uuid); + goto GL_LOCAL_FAILED; + } + + *elist = eina_list_append(*elist, album); + + return true; + + GL_LOCAL_FAILED: + + _gl_data_type_free_glitem((void **)(&album)); + return false; +} + +static bool __gl_local_data_get_media_list_cb(media_info_h media, void *data) +{ + GL_CHECK_FALSE(data); + gl_transfer_data_s *tmp_data = (gl_transfer_data_s *)data; + GL_CHECK_FALSE(tmp_data->userdata); + GL_CHECK_FALSE(media); + gl_media_s *item = NULL; + gl_image_s *image_info = NULL; + gl_video_s *video_info = NULL; + image_meta_h image_handle = NULL; + video_meta_h video_handle = NULL; + char *ext = NULL; + + int ret = -1; + Eina_List **elist = (Eina_List **)(tmp_data->userdata); + + item = (gl_media_s *)calloc(1, sizeof(gl_media_s)); + GL_CHECK_FALSE(item); + item->gtype = GL_TYPE_MEDIA; + + if (media_info_clone(&(item->media_h), media) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Clone media handle failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_info_get_media_id(media, &(item->uuid)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media id failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_info_get_display_name(media, &(item->display_name)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media display name failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_info_get_file_path(media, &(item->file_url)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media file path failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_info_get_media_type(media, (media_content_type_e *)&(item->type)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media type failed!"); + goto GL_LOCAL_FAILED; + } + if (media_info_get_thumbnail_path(media, &(item->thumb_url)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media thumbnail path failed!"); + goto GL_LOCAL_FAILED; + } + gl_dbg("thumb_url: %s", item->thumb_url); + if (media_info_get_modified_time(media, &(item->mtime)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media modified time failed!"); + goto GL_LOCAL_FAILED; + } + if (media_info_get_favorite(media, &(item->favorite)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media rating failed!"); + goto GL_LOCAL_FAILED; + } + /* Without meta */ + if (!tmp_data->with_meta) + goto GL_LOCAL_SUCCESS; + + if (item->type == MEDIA_CONTENT_TYPE_IMAGE) { + ret = media_info_get_image(media, &image_handle); + if (ret != MEDIA_CONTENT_ERROR_NONE || image_handle == NULL) { + gl_dbgE("Failed to get image handle[%d]!", ret); + goto GL_LOCAL_FAILED; + } + + image_info = (gl_image_s *)calloc(1, sizeof(gl_image_s)); + if (NULL == image_info){ + gl_dbgE("Failed to calloc!"); + goto GL_LOCAL_FAILED; + } + item->image_info = image_info; + + if (image_meta_clone(&(image_info->image_h), image_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Clone image handle failed!"); + goto GL_LOCAL_FAILED; + } + + if (image_meta_get_media_id(image_handle, &(image_info->media_uuid)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get image id failed!"); + goto GL_LOCAL_FAILED; + } + + if (image_meta_get_orientation(image_handle, (media_content_orientation_e *)&(image_info->orientation)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get image orientation failed!"); + goto GL_LOCAL_FAILED; + } + + if (image_meta_destroy(image_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Destroy image handle failed!"); + goto GL_LOCAL_FAILED; + } + } else if (item->type == MEDIA_CONTENT_TYPE_VIDEO) { + ret = media_info_get_video(media, &video_handle); + if (ret != MEDIA_CONTENT_ERROR_NONE || video_handle == NULL) { + gl_dbgE("Failed to get video handle[%d]!", ret); + goto GL_LOCAL_FAILED; + } + + video_info = (gl_video_s *)calloc(1, sizeof(gl_video_s)); + if (NULL == video_info) { + gl_dbgE("Failed to calloc!"); + goto GL_LOCAL_FAILED; + } + item->video_info = video_info; + + if (video_meta_clone(&(video_info->video_h), video_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Clone video handle failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_get_media_id(video_handle, &(video_info->media_uuid)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get video id failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_get_title(video_handle, &(video_info->title)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get video title failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_get_duration(video_handle, &(video_info->duration)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get video duration failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_get_played_time(video_handle, &(video_info->last_played_pos)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get video last played position failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_destroy(video_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Destroy video handle failed!"); + goto GL_LOCAL_FAILED; + } + + /* Get bookmark elist in case of video */ + if (video_info->media_uuid) { + video_info->bookmarks = 0; + int count = 0; + ret = media_info_get_bookmark_count_from_db(video_info->media_uuid, + NULL, + &count); + if (ret != MEDIA_CONTENT_ERROR_NONE) + gl_dbgE("Failed to get bookmark[%d]", ret); + else + video_info->bookmarks = count; + } + } else { + gl_dbgE("Wrong media type[%d]!", item->type); + } + + GL_LOCAL_SUCCESS: + + /* Get extension */ + ext = strrchr(item->file_url, '.'); + if (ext) + item->ext = strdup(ext + 1); + else + gl_dbgE("Extension is NULL!"); + + /* Save album uuid */ + if (tmp_data->album_id) + item->album_uuid = strdup(tmp_data->album_id); + else + item->album_uuid = NULL; + + *elist = eina_list_append(*elist, item); + return true; + + GL_LOCAL_FAILED: + + if (image_handle) + image_meta_destroy(image_handle); + if (video_handle) + video_meta_destroy(video_handle); + + _gl_data_type_free_glitem((void **)(&item)); + return false; +} + +static bool __gl_local_data_get_tag_list_cb(media_tag_h tag_handle, void* data) +{ + GL_CHECK_FALSE(data); + gl_transfer_data_s *tmp_data = (gl_transfer_data_s *)data; + GL_CHECK_FALSE(tmp_data->userdata); + Eina_List **elist = (Eina_List **)(tmp_data->userdata); + GL_CHECK_FALSE(tag_handle); + + gl_tag_s *t_item = (gl_tag_s *)calloc(1, sizeof(gl_tag_s)); + GL_CHECK_FALSE(t_item); + t_item->gtype = GL_TYPE_TAG; + + if (media_tag_clone(&(t_item->tag_h), tag_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Clone tag handle failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_tag_get_tag_id(tag_handle, &(t_item->_id)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get tag id failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_tag_get_name(tag_handle, &(t_item->tag_name)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get tag name failed!"); + goto GL_LOCAL_FAILED; + } + + if (tmp_data->filter && + media_tag_get_media_count_from_db(t_item->_id, tmp_data->filter, &(t_item->count)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get tag meida count failed!"); + goto GL_LOCAL_FAILED; + } + + *elist = eina_list_append(*elist, t_item); + return true; + + GL_LOCAL_FAILED: + + _gl_data_type_free_glitem((void **)(&t_item)); + return false; +} + +static int __gl_local_data_get_tag_list_by_media_id_without_tag(gl_filter_s *condition, + const char *media_id, + Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + return -1; + } + + gl_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(gl_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = NULL; + tran_data.album_id = NULL; + tran_data.with_meta = false; + + gl_dbg("Get tags by media id without tag--start"); + ret = media_info_foreach_tag_from_db(media_id, filter, + __gl_local_data_get_tag_list_cb, + &tran_data); + gl_dbg("Get tags by media id without tag--over"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get tags[%d]!", ret); + return -1; + } + + return 0; +} + +static bool __gl_local_data_get_media_list_without_tag_cb(media_info_h media, + void *data) +{ + GL_CHECK_FALSE(data); + gl_foreach_data_s *fe_data = (gl_foreach_data_s*)data; + GL_CHECK_FALSE(fe_data->userdata); + GL_CHECK_FALSE(media); + gl_media_s *item = NULL; + gl_image_s *image_info = NULL; + gl_video_s *video_info = NULL; + image_meta_h image_handle = NULL; + video_meta_h video_handle = NULL; + char *ext = NULL; + char *uuid; + + /* Get media uuid first */ + if (media_info_get_media_id(media, &uuid) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media id failed!"); + goto GL_LOCAL_FAILED; + } + + Eina_List *taglist = NULL; + int err = -1; + gl_dbg("UUID: %s", uuid); + gl_filter_s filter; + memset(&filter, 0x00, sizeof(gl_filter_s)); + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, TAG_NAME, KEYWORD_LENGTH); + /* Check media is tagged with current tag_name or not */ + snprintf(filter.cond, CONDITION_LENGTH, + GL_CONDITION_IMAGE_VIDEO" AND "GL_CONDITION_TAG_NAME, + fe_data->tag_name); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + + err = __gl_local_data_get_tag_list_by_media_id_without_tag(&filter, uuid, + &taglist); + + if (taglist) { + gl_dbgW("Media tagged!"); + GL_FREEIF(uuid); + /* If media tagged, then skip it and get next */ + return true; + } + + int ret = -1; + Eina_List **elist = (Eina_List **)(fe_data->userdata); + + item = (gl_media_s *)calloc(1, sizeof(gl_media_s)); + GL_CHECK_FALSE(item); + item->gtype = GL_TYPE_MEDIA; + + if (media_info_clone(&(item->media_h), media) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Clone media handle failed!"); + goto GL_LOCAL_FAILED; + } + + item->uuid = uuid; + + if (media_info_get_display_name(media, &(item->display_name)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media display name failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_info_get_file_path(media, &(item->file_url)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media file path failed!"); + goto GL_LOCAL_FAILED; + } + + if (media_info_get_media_type(media, (media_content_type_e *)&(item->type)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media type failed!"); + goto GL_LOCAL_FAILED; + } + if (media_info_get_thumbnail_path(media, &(item->thumb_url)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media thumbnail path failed!"); + goto GL_LOCAL_FAILED; + } + gl_dbg("thumb_url: %s", item->thumb_url); + if (media_info_get_modified_time(media, &(item->mtime)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media modified time failed!"); + goto GL_LOCAL_FAILED; + } + if (media_info_get_favorite(media, &(item->favorite)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media rating failed!"); + goto GL_LOCAL_FAILED; + } + + /* Without meta */ + if (!fe_data->with_meta) + goto GL_LOCAL_SUCCESS; + + if (item->type == MEDIA_CONTENT_TYPE_IMAGE) { + ret = media_info_get_image(media, &image_handle); + if (ret != MEDIA_CONTENT_ERROR_NONE || image_handle == NULL) { + gl_dbgE("Failed to get image handle[%d]!", ret); + goto GL_LOCAL_FAILED; + } + + image_info = (gl_image_s *)calloc(1, sizeof(gl_image_s)); + if (NULL == image_info){ + gl_dbgE("Failed to calloc!"); + goto GL_LOCAL_FAILED; + } + item->image_info = image_info; + + if (image_meta_clone(&(image_info->image_h), image_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Clone image handle failed!"); + goto GL_LOCAL_FAILED; + } + + if (image_meta_get_media_id(image_handle, &(image_info->media_uuid)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get image id failed!"); + goto GL_LOCAL_FAILED; + } + + if (image_meta_get_orientation(image_handle, (media_content_orientation_e *)&(image_info->orientation)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get image orientation failed!"); + goto GL_LOCAL_FAILED; + } + + if (image_meta_destroy(image_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Destroy image handle failed!"); + goto GL_LOCAL_FAILED; + } + } else if (item->type == MEDIA_CONTENT_TYPE_VIDEO) { + ret = media_info_get_video(media, &video_handle); + if (ret != MEDIA_CONTENT_ERROR_NONE || video_handle == NULL) { + gl_dbgE("Failed to get video handle[%d]!", ret); + goto GL_LOCAL_FAILED; + } + + video_info = (gl_video_s *)calloc(1, sizeof(gl_video_s)); + if (NULL == video_info) { + gl_dbgE("Failed to calloc!"); + goto GL_LOCAL_FAILED; + } + item->video_info = video_info; + + if (video_meta_clone(&(video_info->video_h), video_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Clone video handle failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_get_media_id(video_handle, &(video_info->media_uuid)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get video id failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_get_title(video_handle, &(video_info->title)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get video title failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_get_duration(video_handle, &(video_info->duration)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get video duration failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_get_played_time(video_handle, &(video_info->last_played_pos)) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get video last played position failed!"); + goto GL_LOCAL_FAILED; + } + + if (video_meta_destroy(video_handle) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Destroy video handle failed!"); + goto GL_LOCAL_FAILED; + } + + /* Get bookmark elist in case of video */ + if (video_info->media_uuid) { + video_info->bookmarks = 0; + int count = 0; + ret = media_info_get_bookmark_count_from_db(video_info->media_uuid, + NULL, + &count); + if (ret != MEDIA_CONTENT_ERROR_NONE) + gl_dbgE("Failed to get bookmark[%d]", ret); + else + video_info->bookmarks = count; + } + } else { + gl_dbgE("Wrong media type[%d]!", item->type); + } + + GL_LOCAL_SUCCESS: + + /* Get extension */ + ext = strrchr(item->file_url, '.'); + if (ext) + item->ext = strdup(ext + 1); + else + gl_dbgE("Extension is NULL!"); + + /* Save album uuid */ + if (fe_data->album_id) + item->album_uuid = strdup(fe_data->album_id); + else + item->album_uuid = NULL; + + *elist = eina_list_append(*elist, item); + return true; + + GL_LOCAL_FAILED: + + if (image_handle) + image_meta_destroy(image_handle); + if (video_handle) + video_meta_destroy(video_handle); + + _gl_data_type_free_glitem((void **)(&item)); + return false; +} + +/* Connect to media-content database */ +int _gl_local_data_connect(void) +{ + int ret = -1; + ret = media_content_connect(); + if(ret == MEDIA_CONTENT_ERROR_NONE) { + gl_dbg("DB connection is success"); + return 0; + } else { + gl_dbgE("DB connection is failed[%d]!", ret); + return -1; + } +} + +/* Disconnect from media-content database */ +int _gl_local_data_disconnect(void) +{ + int ret = -1; + ret = media_content_disconnect(); + if(ret == MEDIA_CONTENT_ERROR_NONE) { + gl_dbg("DB disconnection is success"); + return 0; + } else { + gl_dbgE("DB disconnection is failed[%d]!", ret); + return -1; + } +} + +int _gl_local_data_get_album_by_path(char *path, gl_album_s **album) +{ + GL_CHECK_VAL(path, -1); + GL_CHECK_VAL(album, -1); + int ret = -1; + Eina_List *list = NULL; + gl_filter_s condition; + gl_album_s *_item = NULL; + int i = 0; + + if (strlen(path) <=0) { + gl_dbgE("Invalid path!"); + return -1; + } + gl_dbg("path: %s", path); + + memset(&condition, 0x00, sizeof(gl_filter_s)); + g_strlcpy(condition.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + g_strlcpy(condition.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + condition.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + condition.sort_type = MEDIA_CONTENT_ORDER_DESC; + condition.offset = -1; + condition.count = -1; + condition.with_meta = false; + + snprintf(condition.cond, CONDITION_LENGTH, + "(%s=0 OR %s=1) AND %s=\'%s\'", MEDIA_TYPE, MEDIA_TYPE, + FOLDER_PATH, path); + + ret = _gl_local_data_get_album_list(&condition, &list); + if (ret != 0 || NULL == list) { + gl_dbgE("Failed to get album list[%d]!", ret); + ret = -1; + } else if (NULL != list) { + *album = eina_list_nth(list, 0); + i = 1; + ret = 0; + } + + /* Free other items */ + if (list) { + int len = eina_list_count(list); + gl_dbg("len: %d", len); + + for(; i < len; i++) { + _item = eina_list_nth(list, i); + _gl_data_type_free_glitem((void **)(&_item)); + } + + eina_list_free(list); + } + + return ret; +} + +int _gl_local_data_get_album_list(gl_filter_s *condition, Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + filter_h media_filter = NULL; + gl_filter_s media_condition; + memset(&media_condition, 0x00, sizeof(gl_filter_s)); + g_strlcpy(media_condition.cond, GL_CONDITION_IMAGE_VIDEO, + CONDITION_LENGTH); + media_condition.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(media_condition.sort_keyword, MEDIA_MODIFIED_TIME, + KEYWORD_LENGTH); + media_condition.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + media_condition.offset = -1; + media_condition.count = -1; + media_condition.with_meta = false; + + ret = __gl_local_data_create_filter(&media_condition, &media_filter); + if (ret != 0) { + __gl_local_data_destroy_filter(filter); + gl_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + gl_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(gl_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = media_filter; + tran_data.album_id = NULL; + tran_data.with_meta = false; + + gl_dbg("Get folders--start"); + ret = media_folder_foreach_folder_from_db(filter, + __gl_local_data_get_album_list_cb, + &tran_data); + gl_dbg("Get folders---over"); + + __gl_local_data_destroy_filter(media_filter); + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get all folders[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_media_by_path(const char *path, gl_media_s **mitem) +{ + GL_CHECK_VAL(mitem, -1); + GL_CHECK_VAL(path, -1); + int ret = -1; + Eina_List *list = NULL; + gl_filter_s condition; + gl_media_s *_mitem = NULL; + int i = 0; + + if (strlen(path) <=0) { + gl_dbgE("Invalid path!"); + return -1; + } + gl_dbg("path: %s", path); + + memset(&condition, 0x00, sizeof(gl_filter_s)); + g_strlcpy(condition.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + g_strlcpy(condition.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + condition.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + condition.sort_type = MEDIA_CONTENT_ORDER_DESC; + condition.offset = -1; + condition.count = -1; + condition.with_meta = true; + + snprintf(condition.cond, CONDITION_LENGTH, + "(%s=0 OR %s=1) AND %s=\'%s\'", MEDIA_TYPE, MEDIA_TYPE, + MEDIA_PATH, path); + ret = _gl_local_data_get_all_albums_media_list(&condition, &list); + if (ret != 0 || NULL == list) { + gl_dbgE("Failed to get all albums[%d]!", ret); + ret = -1; + } else if (NULL != list) { + *mitem = eina_list_nth(list, 0); + i = 1; + ret = 0; + } + + /* Free other items */ + if (list) { + int len = eina_list_count(list); + gl_dbg("len: %d", len); + + for(; i < len; i++) { + _mitem = eina_list_nth(list, i); + _gl_data_type_free_glitem((void **)(&_mitem)); + } + + eina_list_free(list); + } + + return ret; +} + +int _gl_local_data_get_media_count(const char *cluster_id, gl_filter_s *condition, + int *item_cnt) +{ + GL_CHECK_VAL(cluster_id, -1); + GL_CHECK_VAL(condition, -1); + GL_CHECK_VAL(item_cnt, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + gl_dbg("Get media count--start"); + ret = media_folder_get_media_count_from_db(cluster_id, filter, item_cnt); + gl_dbg("Get media count---over"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get media count[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_all_media_count(gl_filter_s *condtion, int *item_cnt) +{ + GL_CHECK_VAL(condtion, -1); + GL_CHECK_VAL(item_cnt, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condtion, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + gl_dbg("Get media count--start"); + ret = media_info_get_media_count_from_db(filter, item_cnt); + gl_dbg("Get media count---over"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get media count[%d]", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_album_media_list(gl_filter_s *condition, + const char *album_id, Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(album_id, -1); + GL_CHECK_VAL(condition, -1); + gl_dbg("album id: %s", album_id); + + int ret = -1; + filter_h filter = NULL; + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + return -1; + } + + gl_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(gl_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = NULL; + tran_data.album_id = (char *)album_id; + tran_data.with_meta = condition->with_meta; + + gl_dbg("Get medias--start"); + ret = media_folder_foreach_media_from_db(album_id, filter, + __gl_local_data_get_media_list_cb, + &tran_data); + gl_dbg("Get medias--start"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get medias[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_all_albums_media_list(gl_filter_s *condition, + Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + return -1; + } + + gl_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(gl_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = NULL; + tran_data.album_id = NULL; + tran_data.with_meta = condition->with_meta; + + gl_dbg("Get all medias--start"); + ret = media_info_foreach_media_from_db(filter, + __gl_local_data_get_media_list_cb, + &tran_data); + gl_dbg("Get all medias--over"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get medias[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_media_count_wichout_tag(int tag_id, char *album_uuid) +{ + GL_CHECK_VAL(album_uuid, -1); + int ret = -1; + filter_h filter = NULL; + int item_cnt = 0; + + gl_filter_s condtion; + memset(&condtion, 0x00, sizeof(gl_filter_s)); + if (tag_id == GL_TAG_FAVORITES_ID) + snprintf(condtion.cond, CONDITION_LENGTH, + GL_CONDITION_WITHOUT_FAVOURITE); + else + snprintf(condtion.cond, CONDITION_LENGTH, + GL_CONDITION_WITHOUT_TAG, tag_id); + condtion.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(condtion.sort_keyword, MEDIA_MODIFIED_TIME, + KEYWORD_LENGTH); + condtion.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + condtion.offset = -1; + condtion.count = -1; + condtion.with_meta = false; + + ret = __gl_local_data_create_filter(&condtion, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + gl_dbg("Get media count--start"); + if (!g_strcmp0(album_uuid, GL_ALBUM_ALL_ID)) + ret = media_info_get_media_count_from_db(filter, &item_cnt); + else + ret = media_folder_get_media_count_from_db(album_uuid, filter, &item_cnt); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get count[uuid: %s]", album_uuid); + item_cnt = 0; + } + gl_dbg("Get media count---over"); + + __gl_local_data_destroy_filter(filter); + + return item_cnt; +} + +int _gl_local_data_get_album_media_list_without_tag(gl_filter_s *condition, + const char *album_id, + const char *tag_name, + Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(album_id, -1); + GL_CHECK_VAL(condition, -1); + gl_dbg("album id: %s, tag_name: %s", album_id, tag_name); + + int ret = -1; + filter_h filter = NULL; + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + return -1; + } + + gl_foreach_data_s fe_data; + memset(&fe_data, 0x00, sizeof(gl_foreach_data_s)); + fe_data.userdata = (void **)elist; + fe_data.filter = NULL; + fe_data.album_id = (char *)album_id; + fe_data.tag_name = (char *)tag_name; + fe_data.with_meta = condition->with_meta; + + gl_dbg("Get medias without tag--start"); + ret = media_folder_foreach_media_from_db(album_id, filter, + __gl_local_data_get_media_list_without_tag_cb, + &fe_data); + gl_dbg("Get medias without tag--over"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get medias[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_all_albums_media_list_without_tag(gl_filter_s *condition, + const char *tag_name, + Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + gl_dbg("tag_name: %s", tag_name); + + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + return -1; + } + + gl_foreach_data_s fe_data; + memset(&fe_data, 0x00, sizeof(gl_foreach_data_s)); + fe_data.userdata = (void **)elist; + fe_data.filter = NULL; + fe_data.album_id = NULL; + fe_data.tag_name = (char *)tag_name; + fe_data.with_meta = condition->with_meta; + + gl_dbg("Get all medias without tag--start"); + ret = media_info_foreach_media_from_db(filter, + __gl_local_data_get_media_list_without_tag_cb, + &fe_data); + gl_dbg("Get all medias without tag--over"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get medias[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_tag_list(gl_filter_s *condition, Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed"); + return -1; + } + + filter_h media_filter = NULL; + gl_filter_s media_condition; + memset(&media_condition,0x00,sizeof(gl_filter_s)); + g_strlcpy(media_condition.cond, GL_CONDITION_IMAGE_VIDEO, + CONDITION_LENGTH); + media_condition.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(media_condition.sort_keyword, MEDIA_MODIFIED_TIME, + KEYWORD_LENGTH); + media_condition.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + media_condition.offset = -1; + media_condition.count = -1; + media_condition.with_meta = false; + + ret = __gl_local_data_create_filter(&media_condition, &media_filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + __gl_local_data_destroy_filter(filter); + return -1; + } + + gl_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(gl_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = media_filter; + tran_data.album_id = NULL; + tran_data.with_meta = false; + + gl_dbg("Get tags--start"); + ret = media_tag_foreach_tag_from_db(filter, __gl_local_data_get_tag_list_cb, + &tran_data); + gl_dbg("Get tags--over"); + + __gl_local_data_destroy_filter(media_filter); + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get tags[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_tag_list_by_media_id(gl_filter_s *condition, + const char *media_id, + Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + return -1; + } + + gl_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(gl_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = NULL; + tran_data.album_id = NULL; + tran_data.with_meta = false; + + gl_dbg("Get tags--start"); + ret = media_info_foreach_tag_from_db(media_id, filter, + __gl_local_data_get_tag_list_cb, + &tran_data); + gl_dbg("Get tags--over"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get tags[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_tag_media_count(int tag_id, gl_filter_s *condtion, + int *item_cnt) +{ + GL_CHECK_VAL(condtion, -1); + GL_CHECK_VAL(item_cnt, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condtion, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + return -1; + } + + gl_dbg("Get media count--start"); + ret = media_tag_get_media_count_from_db(tag_id, filter, item_cnt); + gl_dbg("Get media count--start"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get media count[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_get_tag_media_list(unsigned int tag_id, + gl_filter_s *condition, + Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + GL_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __gl_local_data_create_filter(condition, &filter); + if (ret != 0) { + gl_dbgE("Create filter failed!"); + return -1; + } + + gl_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(gl_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = NULL; + tran_data.album_id = NULL; + tran_data.with_meta = condition->with_meta; + + gl_dbg("Get tag medias--start"); + ret = media_tag_foreach_media_from_db(tag_id, filter, + __gl_local_data_get_media_list_cb, + &tran_data); + gl_dbg("Get tag medias--over"); + + __gl_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to get tag media[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_add_tag(const char *tagname, const char *media_uuid) +{ + GL_CHECK_VAL(tagname, -1); + int ret = -1; + Eina_List *list = NULL; + media_tag_h tag_h = NULL; + gl_filter_s tag_condition; + + memset(&tag_condition, 0x00, sizeof(gl_filter_s)); + tag_condition.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(tag_condition.sort_keyword, TAG_NAME, KEYWORD_LENGTH); + tag_condition.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + tag_condition.offset = -1; + tag_condition.count = -1; + tag_condition.with_meta = false; + + /* Check tag exits or not */ + _gl_local_data_get_tag_list(&tag_condition, &list); + bool is_exist = false; + if (list) { + Eina_List *tmp = NULL; + gl_tag_s *t_item = NULL; + EINA_LIST_FOREACH(list, tmp, t_item) { + if (!g_strcmp0(t_item->tag_name, tagname)) { + tag_h = t_item->tag_h; + is_exist = true; + gl_dbgW("Found!"); + break; + } + } + } + + /* Add new tag to DB */ + if (!is_exist) { + ret = media_tag_insert_to_db(tagname, &tag_h); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to add new tag[%d]!", ret); + ret = -1; + goto GL_LOCAL_FAILED; + } + } + + if (tag_h && media_uuid) { + gl_dbg("media_uuid: %s", media_uuid); + ret = media_tag_add_media(tag_h, media_uuid); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Add tag to media failed[%d]!", ret); + ret = -1; + goto GL_LOCAL_FAILED; + } + + ret = media_tag_update_to_db(tag_h); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Update tag to DB failed[%d]!", ret); + ret = -1; + goto GL_LOCAL_FAILED; + } + } else { + gl_dbgE("Invalid tag handle or uuid!"); + ret = -1; + goto GL_LOCAL_FAILED; + } + + ret = 0; + + GL_LOCAL_FAILED: + + /* Free new tag handle */ + if (!is_exist) + media_tag_destroy(tag_h); + _gl_data_type_free_tag_list(&list); + return ret; +} + +int _gl_local_data_delete_tag(gl_tag_s *tag) +{ + GL_CHECK_VAL(tag, -1); + GL_CHECK_VAL(tag->_id, -1); + int ret = -1; + + ret = media_tag_delete_from_db(tag->_id); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Delete tag failed[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_remove_tag(gl_tag_s *tag, const char *media_uuid) +{ + GL_CHECK_VAL(tag, -1); + GL_CHECK_VAL(tag->tag_h, -1); + GL_CHECK_VAL(media_uuid, -1); + int ret = -1; + + ret = media_tag_remove_media(tag->tag_h, media_uuid); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Remove tag failed[%d]!", ret); + return -1; + } + + ret = media_tag_update_to_db(tag->tag_h); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Update tag to DB failed[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_set_favorite(gl_media_s *item, bool favor) +{ + GL_CHECK_VAL(item, -1); + GL_CHECK_VAL(item->media_h, -1); + gl_dbg("favor: %d", favor); + + int ret = -1; + ret = media_info_set_favorite(item->media_h, favor); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Set tag favorite failed[%d]!", ret); + return -1; + } + + ret = media_info_update_to_db(item->media_h); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Update tag to DB failed[%d]!", ret); + return -1; + } + + return 0; +} + +int _gl_local_data_delete_album(const char *album_uuid) +{ + GL_CHECK_VAL(album_uuid, -1); + gl_filter_s filter; + int ret = -1; + + memset(&filter, 0x00, sizeof(gl_filter_s)); + g_strlcpy(filter.cond, GL_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.offset = -1; + filter.count = -1; + filter.with_meta = false; + + Eina_List *itemlist = NULL; + gl_media_s *item = NULL; + + ret = _gl_local_data_get_album_media_list(&filter, album_uuid, + &itemlist); + if (ret != 0) { + gl_dbgE("Get album medias failed[%d]!", ret); + return -1; + } + + EINA_LIST_FREE(itemlist, item) { + if (item == NULL) { + gl_dbgE("Invalid item!"); + continue; + } + + media_info_delete_from_db(item->uuid); + _gl_data_type_free_glitem((void **)&item); + } + + return 0; +} + +int _gl_local_data_add_media(const char *file_url, media_info_h *info) +{ + GL_CHECK_VAL(file_url, -1); + int ret = -1; + media_info_h item = NULL; + gl_dbg("file_url is %s", file_url); + + ret = media_info_insert_to_db(file_url, &item); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to insert media to DB[%d]!", ret); + if (item) + media_info_destroy(item); + return -1; + } + + if (info) { + *info = item; + } else { + gl_dbgW("Destroy media_info item!"); + media_info_destroy(item); + } + + return 0; +} + +int _gl_local_data_get_thumb(gl_media_s *mitem, char **thumb) +{ + GL_CHECK_VAL(mitem, -1); + GL_CHECK_VAL(mitem->media_h, -1); + + if (media_info_get_thumbnail_path(mitem->media_h, thumb) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Get media thumbnail path failed!"); + return -1; + } + + return 0; +} + +int _gl_local_data_move_media(gl_media_s *mitem, const char *dst) +{ + GL_CHECK_VAL(dst, -1); + GL_CHECK_VAL(mitem, -1); + GL_CHECK_VAL(mitem->media_h, -1); + + if (media_info_move_to_db(mitem->media_h, dst) != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Move media thumbnail failed!"); + return -1; + } + + return 0; +} + diff --git a/src/features/gl-albums-edit.c b/src/features/gl-albums-edit.c new file mode 100755 index 0000000..8bc6f45 --- /dev/null +++ b/src/features/gl-albums-edit.c @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "gallery.h" +#include "gl-albums.h" +#include "gl-albums-edit.h" +#include "gl-debug.h" +#include "gl-strings.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-data.h" +#include "gl-icons.h" +#include "gl-controlbar.h" +#include "gl-ctxpopup.h" +#include "gl-button.h" +#include "gl-notify.h" +#include "gl-popup.h" + +static void __gl_albums_edit_trans_finished_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbgW("view_mode: %d", view_mode); + evas_object_smart_callback_del(obj, GL_TRANS_FINISHED, + __gl_albums_edit_trans_finished_cb); + + /* Clear previous view after animation finished */ + if (view_mode == GL_VIEW_ALBUMS_EDIT) + elm_gengrid_clear(ad->albuminfo.albums_view); + else + gl_dbgE("Wrong view mode!"); +} + +/* callback after user tap Cancel button in option header in edit view */ +static void __gl_albums_edit_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + GL_CHECK(obj); + gl_dbg(""); + /* Disable item when it is clicked to prevent it is called for many times */ + if (_gl_albums_edit_pop_view(data) == 0) + _gl_ui_disable_btn(obj); +} + +static void __gl_albums_edit_del_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_dbg(""); + + if ((gl_get_view_mode(data) == GL_VIEW_ALBUMS_EDIT)) { + if (_gl_data_get_albums_selected_cnt(data) == 0) { + gl_dbgW("No albums selected!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_ALBUMS_SELECTED); + return; + } + gl_popup_create_albums_del_popup(data); + } else { + gl_dbgE("Unknow mode!"); + } +} + +static void __gl_albums_edit_share_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me) { + gl_dbgW("UG or APP is already loaded!"); + return; + } + + int view_mode = gl_get_view_mode(ad); + int cnt = 0; + if (view_mode == GL_VIEW_ALBUMS_EDIT) { + cnt = _gl_data_get_albums_selected_cnt(ad); + if (cnt == 0) { + gl_dbgW("No albums selected!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_ALBUMS_SELECTED); + return; + } + /* Check albums are empty */ + if (_gl_data_is_albums_selected_empty(ad)) { + gl_dbgW("No thumbs selected!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return; + } + _gl_ctxpopup_create_share(data, obj); + } else { + gl_dbgE("Unknow mode!"); + } +} + +/** + * Use naviframe api to push albums edit view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_albums_edit_push_view(void *data, Evas_Object *parent, + Evas_Object *obj) +{ + gl_dbg("GL_NAVI_ALBUMS_EDIT"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + + /* Add transition finished callback */ + evas_object_smart_callback_add(parent, GL_TRANS_FINISHED, + __gl_albums_edit_trans_finished_cb, + data); + Evas_Object *end_btn = NULL; + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_albums_edit_cancel_cb, data); + GL_CHECK_VAL(end_btn, -1); + /* Push to stack */ + nf_it = elm_naviframe_item_push(parent, NULL, end_btn, NULL, obj, + GL_NF_ANI_TABBAR); + ad->ctrlinfo.nf_it_edit = nf_it; + elm_naviframe_item_title_visible_set(nf_it, EINA_FALSE); + + Evas_Object *btn = NULL; + /* Delete */ + btn = _gl_but_create_but(parent, NULL, GL_STR_DELETE, + GL_BUTTON_STYLE_NAVI_TOOLBAR_RIGHT, + __gl_albums_edit_del_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN2, btn); + _gl_ui_disable_btn(btn); + /* Share */ + btn = _gl_but_create_but(parent, NULL, GL_STR_SHARE, + GL_BUTTON_STYLE_NAVI_TOOLBAR_LEFT, + __gl_albums_edit_share_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, btn); + _gl_ui_disable_btn(btn); + return 0; +} + +int _gl_albums_edit_create_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + + gl_set_view_mode(ad, GL_VIEW_ALBUMS_EDIT); + + ad->ctrlinfo.ctrlbar_edit_ly = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(ad->ctrlinfo.ctrlbar_edit_ly, -1); + ad->ctrlinfo.ctrlbar_edit_view = gl_albums_create_view(ad, + ad->ctrlinfo.ctrlbar_edit_ly); + if (ad->ctrlinfo.ctrlbar_edit_view == NULL) { + gl_dbgE("Failed to create view!"); + evas_object_del(ad->ctrlinfo.ctrlbar_edit_ly); + ad->ctrlinfo.ctrlbar_edit_ly = NULL; + return -1; + } + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_edit_ly, + "elm.swallow.view", + ad->ctrlinfo.ctrlbar_edit_view); + edje_object_signal_emit(_EDJ(ad->ctrlinfo.ctrlbar_edit_ly), + GL_SIGNAL_VIEW_EDIT, "elm"); + /* Display 'Select all' widget */ + gl_ui_show_selall(ad); + __gl_albums_edit_push_view(ad, ad->maininfo.naviframe, + ad->ctrlinfo.ctrlbar_edit_ly); + return 0; +} + +int _gl_albums_edit_update_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + _gl_data_update_cluster_list(data); + + if (gl_check_gallery_empty(data) || + ad->albuminfo.cluster_list->edit_cnt == 0) { + /* Remove invalid widgets */ + gl_del_invalid_widgets(data, GL_INVALID_NONE); + + gl_dbgW("None editable albums, show albums view!"); + _gl_albums_edit_pop_view(data); + return 0; + } + + int sel_cnt = _gl_data_get_albums_selected_cnt(data); + int invalid_m = GL_INVALID_NONE; + /* Album selected for rename was deleted */ + if (sel_cnt == 0) { + /* None albums selected */ + gl_dbgW("None albums selected!"); + /* Disable control bar buttons */ + _gl_ctrl_disable_btns(data, ad->ctrlinfo.nf_it_edit, true); + /* Remove invalid widgets */ + gl_del_invalid_widgets(data, invalid_m); + } + + /* Update edit view, other update view in cancel callback */ + _gl_albums_create_items(data, ad->ctrlinfo.ctrlbar_edit_view); + gl_ctrl_rotate_ctrlbar(data, GL_VIEW_ALBUMS_EDIT); + /* Display selectioninfo */ + _gl_notify_create_selinfo(data, ad->ctrlinfo.ctrlbar_edit_ly, + ad->ctrlinfo.nf_it_edit, + ad->albuminfo.albums_cnt, sel_cnt, true); + return 0; +} + +int _gl_albums_edit_pop_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + ad->albuminfo.selected_album = NULL; + + elm_naviframe_item_pop_to(ad->ctrlinfo.nf_it); + + _gl_destroy_ctrl_edit_view(data); + + _gl_data_finalize_albums_selected_list(data); + /** + * after back to albums view from albums edit view, + * option header should be defaultly closed + */ + + _gl_data_get_cluster_list(data); + GL_CHECK_VAL(ad->albuminfo.cluster_list, -1); + + gl_albums_change_to_view(data); + _gl_notify_destroy_selinfo(data); + if (gl_check_gallery_empty(data)) { + gl_ctrl_disable_ctrlbar(data, true); + _gl_ctrl_disable_btn(data, true, GL_NAVI_ALBUMS); + } else { + gl_ctrl_disable_ctrlbar(data, false); + if (ad->albuminfo.cluster_list->edit_cnt == 0) { + gl_dbg("None editable albums, disable items."); + _gl_ctrl_disable_btn(data, true, GL_NAVI_ALBUMS); + } + } + + gl_ctrl_rotate_ctrlbar(data, GL_VIEW_ALBUMS); + return 0; +} + +/* Share album's content */ +int _gl_albums_edit_share(void *data, const char *label) +{ + GL_CHECK_VAL(label, -1); + GL_CHECK_VAL(data, -1); + gl_dbg("label : %s ", label); + + int cnt = _gl_data_get_albums_selected_cnt(data); + gl_dbg("Selected album(s) count: %d.", cnt); + if (cnt < 1) { + gl_dbgE("None album selected!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_ALBUMS_SELECTED); + return -1; + } + if (_gl_data_is_albums_selected_empty(data)) { + gl_dbgE("None thumb selected!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return -1; + } + + return _gl_share_load(data, label); +} + +int _gl_albums_edit_update_lang(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->ctrlinfo.nf_it_edit, -1); + + /*Reset select info text*/ + int cnt = _gl_data_get_albums_selected_cnt(ad); + _gl_notify_update_lang(ad, cnt, GL_VIEW_ALBUMS_EDIT); + + if (ad->popupinfo.popup) { + if (ad->popupinfo.popup_mode == GL_POPUP_ALBUM_DELETE) + gl_popup_create_albums_del_popup(data); + else if (ad->popupinfo.popup_mode == GL_POPUP_NOBUT) + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_ALBUMS_SELECTED); + } + + /*Album view or 3D normal view*/ + _gl_ui_set_btns_text(ad->ctrlinfo.nf_it_edit, GL_STR_SHARE, + GL_STR_DELETE); + return 0; +} + diff --git a/src/features/gl-albums-new.c b/src/features/gl-albums-new.c new file mode 100755 index 0000000..a985003 --- /dev/null +++ b/src/features/gl-albums-new.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-fs.h" +#include "gl-albums-new.h" +#include "gl-albums.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-data.h" +#include "gl-controlbar.h" +#include "gl-editfield.h" +#include "gl-button.h" +#include "gl-popup.h" +#include "gl-strings.h" +#include "gl-fs.h" + +static void __gl_albums_new_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Delete callback when it is clicked to prevent it is called for many times */ + evas_object_smart_callback_del(obj, "clicked", + __gl_albums_new_cancel_cb); + _gl_albums_new_pop_view(data); +} + +static void __gl_albums_new_done_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Delete callback when it is clicked to prevent it is called for many times */ + if (_gl_albums_new_process(data, false) == 0) + evas_object_smart_callback_del(obj, "clicked", + __gl_albums_new_done_cb); +} + +/** + * Use naviframe api to push new album view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_albums_new_push_view(void *data, Evas_Object *parent, + Evas_Object *obj, char *title) +{ + gl_dbg("GL_NAVI_ALBUMS_NEW"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + Evas_Object *done_btn = NULL; + Evas_Object *cancel_btn = NULL; + Evas_Object *end_btn = NULL; + + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_albums_new_cancel_cb, data); + GL_CHECK_VAL(end_btn, -1); + + nf_it = elm_naviframe_item_push(parent, title, end_btn, NULL, obj, + NULL); + ad->entryinfo.nf_it = nf_it; + /* Add 'Cancel' button */ + cancel_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_albums_new_cancel_cb, data); + GL_CHECK_VAL(cancel_btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_TITLE_PREV_BTN, + cancel_btn); + /* Add 'Done' button */ + done_btn = _gl_but_create_but(parent, NULL, GL_STR_DONE, + GL_BUTTON_STYLE_NAVI_TITLE, + __gl_albums_new_done_cb, data); + GL_CHECK_VAL(done_btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, done_btn); + ad->entryinfo.done_btn = done_btn; + + /* Add callbacks to show/hide title toolbar */ + _gl_ui_add_conform_cbs(parent); + return 0; +} + +int _gl_albums_new_create_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Evas_Object *editfield_ly = NULL; + gl_dbg(""); + + ad->entryinfo.entry_mode = GL_ENTRY_NEW_ALBUM; + editfield_ly = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(data, -1); + Evas_Object *entry = _gl_editfield_create(ad, editfield_ly, NULL); + if (entry == NULL) { + gl_dbgE("Failed to add entry!"); + evas_object_del(editfield_ly); + ad->entryinfo.entry_mode = GL_ENTRY_NONE; + return -1; + } + elm_object_part_content_set(editfield_ly, "elm.swallow.view", entry); + edje_object_signal_emit(_EDJ(editfield_ly), GL_SIGNAL_VIEW_DEFAULT, + "elm"); + __gl_albums_new_push_view(ad, ad->maininfo.naviframe, editfield_ly, + GL_STR_CREATE_ALBUM); + _gl_editfield_show_imf(ad); + return 0; +} + +int _gl_albums_new_pop_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + elm_naviframe_item_pop(ad->maininfo.naviframe); + _gl_editfield_destroy_imf(ad); + + gl_ui_update_select_widgets(ad); + + return 0; +} + +/* +* @param b_enter +* True: Enter key on Keyboard pressed, False: Button Done clicked +*/ +int _gl_albums_new_process(void *data, bool b_enter) +{ + gl_dbg("b_enter: %d", b_enter); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->entryinfo.editfield == NULL) { + gl_dbgE("Edit filed is NULL"); + goto NEW_ALBUM_FAILED; + } + + if (ad->entryinfo.imf_context) + ecore_imf_context_input_panel_hide(ad->entryinfo.imf_context); + + Evas_Object *entry = ad->entryinfo.imf_entry; + char name[GL_ALBUM_NAME_LEN_MAX] = { 0, }; + + /* Get utf8 format string */ + if (gl_get_entry_text(entry, name, GL_ALBUM_NAME_LEN_MAX) != 0) { + gl_dbgE("Get entry text failed!"); + goto NEW_ALBUM_FAILED; + } + + /* Get valid name */ + if (_gl_get_valid_album_name(ad, name, true, b_enter) != 0) { + if (b_enter) + _gl_editfield_hide_imf(ad); + return -1; + } + gl_dbg("Valid album name: %s", name); + + /* Check whether the new folder exist */ + char new_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + char parent[GL_DIR_PATH_LEN_MAX] = { 0, }; + + /* Get default images new_path, make new album under it */ + if (_gl_fs_get_default_folder(parent) != 0) { + gl_dbgE("Failed to get default image dir new_path!"); + goto NEW_ALBUM_FAILED; + } + + /* Make dir full new_path of new album */ + snprintf(new_path, GL_DIR_PATH_LEN_MAX, "%s/%s", parent, name); + gl_dbg("New dir new_path: %s", new_path); +#ifdef _RENAME_ALBUM_SENSITIVE + if (_gl_fs_check_name_case(new_path, name)) +#endif + { + memset(new_path, 0x00, GL_DIR_PATH_LEN_MAX); + snprintf(new_path, GL_DIR_PATH_LEN_MAX, "%s/%s", parent, name); + gl_dbg("New dir new_path: %s", new_path); + int res = ecore_file_dir_is_empty(new_path); + /** + * If dir is empty, 1 is returned, + * if it contains at least 1 file, 0 is returned. + * On failure, -1 is returned. + */ + gl_dbg("ecore_file_dir_is_empty return value: %d", res); + if (res == 0) { + char *popup_desc; + popup_desc = (char*)calloc(GL_POPUP_STRING_MAX, + sizeof(char)); + if (popup_desc == NULL) { + gl_dbgE("memory allocation fail!"); + return -1; + } + + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.
%s", + GL_STR_SAME_NAME_ALREADY_IN_USE, + GL_STR_RETRY_Q); + popup_desc[strlen(popup_desc)] = '\0'; + gl_popup_create_popup(ad, GL_POPUP_ALBUM_NEW_DUPLICATE, + popup_desc); + GL_FREE(popup_desc); + gl_dbgW("New folder already exists!"); + return -1; + } + } + + /* Save new album name */ + char* new_album = ad->albuminfo.new_album_name; + g_strlcpy(new_album, name, GL_ALBUM_NAME_LEN_MAX); + new_album[GL_ALBUM_NAME_LEN_MAX - 1] = '\0'; + _gl_editfield_destroy_imf(ad); + + /* Move/Save files to dest album */ + gl_move_to_album(ad); + return 0; + + NEW_ALBUM_FAILED: + _gl_albums_new_pop_view(ad); + return -1; +} + diff --git a/src/features/gl-albums-rename.c b/src/features/gl-albums-rename.c new file mode 100755 index 0000000..fe7379e --- /dev/null +++ b/src/features/gl-albums-rename.c @@ -0,0 +1,454 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-fs.h" +#include "gl-albums-rename.h" +#include "gl-albums.h" +#include "gl-albums-edit.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-controlbar.h" +#include "gl-editfield.h" +#include "gl-button.h" +#include "gl-popup.h" +#include "gl-strings.h" +#include "gl-fs.h" + +static void __gl_albums_rename_trans_finished_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbgW("view_mode: %d", view_mode); + + evas_object_smart_callback_del(obj, GL_TRANS_FINISHED, + __gl_albums_rename_trans_finished_cb); + + /* Clear previous view after animation finished */ + if (view_mode == GL_VIEW_ALBUMS_RENAME) + elm_gengrid_clear(ad->ctrlinfo.ctrlbar_edit_view); + else + gl_dbgE("Wrong view mode!"); +} + +static void __gl_albums_rename_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Delete callback when it is clicked to prevent it is called for many times */ + evas_object_smart_callback_del(obj, "clicked", + __gl_albums_rename_cancel_cb); + _gl_albums_rename_pop_view(data); +} + +static void __gl_albums_rename_done_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Delete callback when it is clicked to prevent it is called for many times*/ + if (_gl_albums_rename_process(data, false) == 0) + evas_object_smart_callback_del(obj, "clicked", + __gl_albums_rename_done_cb); +} + +/** + * Use naviframe api to push albums rename view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_albums_rename_push_view(void *data, Evas_Object *parent, + Evas_Object *obj, char *title) +{ + gl_dbg("GL_NAVI_ALBUMS_RENAME"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + Evas_Object *done_btn = NULL; + Evas_Object *cancel_btn = NULL; + Evas_Object *end_btn = NULL; + + _gl_ctrl_show_tabbar(ad, false); + + /* Add transition finished callback */ + evas_object_smart_callback_add(parent, GL_TRANS_FINISHED, + __gl_albums_rename_trans_finished_cb, + data); + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_albums_rename_cancel_cb, data); + GL_CHECK_VAL(end_btn, -1); + + nf_it = elm_naviframe_item_push(parent, title, end_btn, NULL, obj, + NULL); + /* Add 'Cancel' button */ + cancel_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_albums_rename_cancel_cb, data); + GL_CHECK_VAL(cancel_btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_TITLE_PREV_BTN, + cancel_btn); + /* Add 'Done' button */ + done_btn = _gl_but_create_but(parent, NULL, GL_STR_DONE, + GL_BUTTON_STYLE_NAVI_TITLE, + __gl_albums_rename_done_cb, data); + GL_CHECK_VAL(done_btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, done_btn); + ad->entryinfo.done_btn = done_btn; + ad->entryinfo.nf_it = nf_it; + + /* Add callbacks to show/hide title toolbar */ + _gl_ui_add_conform_cbs(parent); + return 0; +} + +int _gl_albums_rename_create_view(void *data, gl_cluster *album) +{ + GL_CHECK_VAL(album, -1); + GL_CHECK_VAL(album->cluster, -1); + GL_CHECK_VAL(album->cluster->display_name, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Evas_Object *editfield_ly = NULL; + int view_mode = gl_get_view_mode(data); + gl_dbg(""); + + if(ad->maininfo.rename_album_job) { + ecore_job_del(ad->maininfo.rename_album_job); + ad->maininfo.rename_album_job = NULL; + } + if (view_mode != GL_VIEW_ALBUMS_EDIT) { + gl_dbgE("Unexpected view mode(%d)!", view_mode); + return -1; + } + + gl_set_view_mode(data, GL_VIEW_ALBUMS_RENAME); + ad->entryinfo.entry_mode = GL_ENTRY_RENAME_ALBUM; + + editfield_ly = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(editfield_ly, -1); + Evas_Object *entry = _gl_editfield_create(data, editfield_ly, + album->cluster->display_name); + if (entry == NULL) { + gl_dbgE("Failed to add entry!"); + gl_set_view_mode(data, view_mode); + ad->entryinfo.entry_mode = GL_ENTRY_NONE; + evas_object_del(editfield_ly); + return -1; + } + + elm_object_part_content_set(editfield_ly, "elm.swallow.view", entry); + edje_object_signal_emit(_EDJ(editfield_ly), GL_SIGNAL_VIEW_DEFAULT, + "elm"); + __gl_albums_rename_push_view(data, ad->maininfo.naviframe, editfield_ly, + GL_STR_CHNAGE_NAME); + _gl_editfield_show_imf(data); + return 0; +} + +int _gl_albums_rename_update_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + _gl_data_update_cluster_list(data); + + if (gl_check_gallery_empty(data) || + ad->albuminfo.cluster_list->edit_cnt == 0) { + /* Remove invalid widgets */ + gl_del_invalid_widgets(data, GL_INVALID_NONE); + + gl_dbgW("None editable albums, show albums view!"); + _gl_albums_edit_pop_view(data); + return 0; + } + + /* Album selected for rename was deleted */ + if (ad->albuminfo.selected_album == NULL) { + gl_dbgW("Rename invalid album!"); + /* Remove rename view */ + _gl_albums_rename_pop_view(data); + return 0; + } + + /* Cluster list updated, clear view */ + elm_gengrid_clear(ad->ctrlinfo.ctrlbar_edit_view); + return 0; +} + +int _gl_albums_rename_pop_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + gl_dbg(""); + + /* Hide title from animation */ + gl_ui_set_navi_title_visible(data, EINA_FALSE); + ad->albuminfo.selected_album = NULL; + gl_set_view_mode(data, GL_VIEW_ALBUMS_EDIT); + /* manually popup view after rename album */ + elm_naviframe_item_pop(ad->maininfo.naviframe); + /* Recover the previous UI */ + gl_ctrl_rotate_ctrlbar(data, GL_VIEW_ALBUMS_EDIT); + _gl_editfield_destroy_imf(data); + /* Update edit view */ + gl_albums_update_items(data); + return 0; +} + +/* +* @param b_enter +* True: Enter key on Keyboard pressed, False: Button Done clicked +*/ +int _gl_albums_rename_process(void *data, bool b_enter) +{ + gl_dbg("b_enter: %d", b_enter); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + bool b_root_path = false; + gl_cluster *album_item = NULL; + + if (gl_get_view_mode(ad) != GL_VIEW_ALBUMS_RENAME) { + gl_dbgE("View mode is wrong!"); + goto RENAME_FAILED; + } + + album_item = ad->albuminfo.selected_album; + if (album_item == NULL || album_item->cluster == NULL || + album_item->cluster->uuid == NULL) { + gl_dbgE("selected_album is NULL!"); + goto RENAME_FAILED; + } + + char name[GL_FILE_NAME_LEN_MAX] = { 0, }; + /* Get utf8 format string */ + int ret = -1; + ret = gl_get_entry_text(ad->entryinfo.imf_entry, name, + GL_FILE_NAME_LEN_MAX); + if (ret != 0) { + gl_dbgE("Get entry text failed!"); + goto RENAME_FAILED; + } + + /* Get valid name */ + if (_gl_get_valid_album_name(ad, name, false, b_enter) != 0) { + if (b_enter) + _gl_editfield_hide_imf(ad); + return -1; + } + + gl_dbg("Valid album name: %s", name); + /* Get src folder path */ + char old_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + if (album_item->cluster->path) { + g_strlcpy(old_path, album_item->cluster->path, + GL_DIR_PATH_LEN_MAX); + gl_dbg("Src folder: %s", old_path); + if (_gl_data_is_root_path(old_path)) { + /** + * Root path, couldn't rename root path, + * make the new dest folder + * and move all files for root path to it. + */ + gl_dbg("Rename [No Name] album's name."); + b_root_path = true; + } + } else { + gl_dbgE("gl_db_get_folder_fullpath failed(%d)!", ret); + goto RENAME_FAILED; + } + + /* Get dest folder path */ + char new_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + char parent[GL_DIR_PATH_LEN_MAX] = { 0, }; + + if (b_root_path) { + /* Get default images path, make dest foler under it */ + char default_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + if (_gl_fs_get_default_folder(default_path) != 0) { + gl_dbgW("Failed to get default images path!"); + goto RENAME_FAILED; + } + + snprintf(new_path, GL_DIR_PATH_LEN_MAX, "%s/%s", default_path, + name); + new_path[strlen(new_path)] = '\0'; + g_strlcpy(parent, default_path, GL_DIR_PATH_LEN_MAX); + } else { + g_strlcpy(new_path, old_path, GL_DIR_PATH_LEN_MAX); + g_strlcpy(parent, old_path, GL_DIR_PATH_LEN_MAX); + + int i = 0; + int length = strlen(old_path); + for (i = length; i >= 0; i--) { + if (new_path[i] == '/') { + gl_dbg("length=%d, i=%d", length, i); + /* Path like "/root/abc/" */ + if (i == length - 1) + continue; + memcpy(&new_path[i + 1], name, strlen(name)); + new_path[i + 1 + strlen(name)] = '\0'; + parent[i] = '\0'; + break; + } + } + } + + gl_dbg("Dest folder: %s", new_path); +#ifdef _RENAME_ALBUM_SENSITIVE + if (!strcasecmp(old_path, new_path)) +#else + if (!g_strcmp0(old_path, new_path)) +#endif + { + gl_dbgW("Same as current name!"); + goto RENAME_FAILED; + } + + /** + * If dir is empty, 1 is returned, + * if it contains at least 1 file, 0 is returned. + * On failure, -1 is returned. + */ +#ifdef _RENAME_ALBUM_SENSITIVE + if (_gl_fs_check_name_case(new_path, name)) +#endif + { + memset(new_path, 0x00, GL_DIR_PATH_LEN_MAX); + snprintf(new_path, GL_DIR_PATH_LEN_MAX, "%s/%s", parent, name); + gl_dbg("New dir path: %s", new_path); + int res = ecore_file_dir_is_empty(new_path); + gl_dbg("ecore_file_dir_is_empty return value: %d", res); + if (res == 0) { + char *popup_desc; + popup_desc = (char*)calloc(GL_POPUP_STRING_MAX, + sizeof(char)); + if (popup_desc == NULL) { + gl_dbgE("memory allocation fail!"); + return -1; + } + + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.
%s", + GL_STR_SAME_NAME_ALREADY_IN_USE, GL_STR_RETRY_Q); + popup_desc[strlen(popup_desc)] = '\0'; + gl_popup_create_popup(ad, GL_POPUP_ALBUM_RENAME_DUPLICATE, + popup_desc); + GL_FREE(popup_desc); + gl_dbgW("New folder already exists!"); + return -1; + } + } + + if (b_root_path) { + /** + * Case 1: Rename virtual album 'No Name'. + * It couldn't be done by updating album record in DB directly. + * Cuz it would change the folder path of all folder records, + * to make them invalid. + * + * Create new folder under default images path, + * Move all medias under root path to new folder. + */ + if (gl_make_new_album(name) != 0) { + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_UNABLE_tO_RENAME); + gl_dbgE("Failed to make a new directory!"); + goto RENAME_FAILED; + } + + /* Move medias from 'No Name' album to new album */ + if (gl_move_root_album(ad, album_item, new_path) != 0) { + gl_dbg("gl_move_root_album failed!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_UNABLE_tO_RENAME); + goto RENAME_FAILED; + } else { + gl_dbg("New album added, update albums list."); + ad->albuminfo.selected_album = NULL; + _gl_data_update_cluster_list(ad); + } + } else { + /** + * Case 2: Rename normal album. Update album record in DB. + */ + media_folder_set_name(album_item->cluster->folder_h, name); + ret = media_folder_update_to_db(album_item->cluster->folder_h); + if (ret < 0) { + gl_dbg("media_folder_set_name failed (%d)!", ret); + goto RENAME_FAILED; + } + + /** + * Change folder name in file system + * for some special name, DB update success, but file mv failed. + * So, do this first. + */ + if (ecore_file_exists(old_path)) { + if (!ecore_file_mv(old_path, new_path)) + gl_dbg("ecore_file_mv failed!"); + } else { + gl_dbgW("Source folder path doesn't exist!"); + } + } + /* Update memory */ + if (!b_root_path) { + GL_FREEIF(album_item->cluster->display_name); + album_item->cluster->display_name = strdup(name); + } + + if (album_item->cluster->path) { + free(album_item->cluster->path); + album_item->cluster->path = strdup(new_path); + } + + _gl_albums_rename_pop_view(ad); + return 0; + + RENAME_FAILED: + _gl_albums_rename_pop_view(ad); + return -1; +} + +int _gl_albums_rename_update_lang(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->entryinfo.nf_it, -1); + + elm_object_item_text_set(ad->entryinfo.nf_it, GL_STR_CHNAGE_NAME); + if (ad->popupinfo.popup) { + char *popup_desc = (char*)calloc(GL_POPUP_STRING_MAX, + sizeof(char)); + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.
%s", + GL_STR_SAME_NAME_ALREADY_IN_USE, GL_STR_RETRY_Q); + popup_desc[strlen(popup_desc)] = '\0'; + gl_popup_create_popup(ad, GL_POPUP_ALBUM_RENAME_DUPLICATE, + popup_desc); + GL_FREE(popup_desc); + } + + return 0; +} + diff --git a/src/features/gl-albums-sel.c b/src/features/gl-albums-sel.c new file mode 100755 index 0000000..c41c208 --- /dev/null +++ b/src/features/gl-albums-sel.c @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-albums-sel.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-data.h" +#include "gl-controlbar.h" +#include "gl-button.h" +#include "gl-nocontents.h" +#include "gl-notify.h" +#include "gl-strings.h" +#include "gl-albums.h" +#include "gl-tags.h" +#include "gl-thumbs.h" + +static void __gl_albums_sel_trans_finished_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbgW("view_mode: %d", view_mode); + evas_object_smart_callback_del(obj, GL_TRANS_FINISHED, + __gl_albums_sel_trans_finished_cb); + + /* Clear previous view after animation finished */ + if (view_mode == GL_VIEW_ALBUMS_SELECT) { + if (ad->gridinfo.all_grid_nocontents == NULL) + elm_gengrid_clear(ad->gridinfo.all_grid_view); + } else { + gl_dbgE("Wrong view mode!"); + } +} + +/* callback after user tap Cancel button in option header in select album view */ +static void __gl_albums_sel_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Disable item when it is clicked to prevent it is called for many times */ + if (_gl_albums_sel_pop_view(data) == 0) + _gl_ui_disable_btn(obj); +} + +/** + * Use naviframe api to push new album view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_albums_sel_push_view(void *data, Evas_Object *parent, + Evas_Object *obj, char *title) +{ + gl_dbg("GL_NAVI_ALBUMS_SELECT"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + + /* Add transition finished callback */ + evas_object_smart_callback_add(parent, GL_TRANS_FINISHED, + __gl_albums_sel_trans_finished_cb, data); + Evas_Object *end_btn = NULL; + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_albums_sel_cancel_cb, data); + GL_CHECK_VAL(end_btn, -1); + /* Push to stack */ + nf_it = elm_naviframe_item_push(parent, title, end_btn, NULL, obj, + NULL); + ad->albuminfo.nf_it_select = nf_it; + return 0; +} + +int _gl_albums_sel_create_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + gl_dbg(""); + + /* Create tags view layout for Select album */ + Evas_Object *layout = NULL; + layout = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(layout, -1); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + /* Save view mode */ + int pre_view_m = gl_get_view_mode(data); + /* Set view mode of Select album */ + gl_set_view_mode(data, GL_VIEW_ALBUMS_SELECT); + Evas_Object *view = NULL; + /* Get latest cluster list */ + _gl_data_get_cluster_list(data); + /* Create tags view for Select album */ + view = gl_albums_create_view(data, layout); + if (view == NULL) { + evas_object_del(layout); + /* Reset view mode */ + gl_set_view_mode(data, pre_view_m); + return -1; + } + + /* Set view to layout */ + elm_object_part_content_set(layout, "elm.swallow.view", view); + __gl_albums_sel_push_view(data, ad->maininfo.naviframe, layout, + GL_STR_SELECT_ALBUM); + /* Send signal to show different layout */ + edje_object_signal_emit(_EDJ(layout), GL_SIGNAL_VIEW_DEFAULT, "elm"); + /* Save pointer of View and Layout */ + ad->albuminfo.select_view = view; + ad->albuminfo.select_view_ly = layout; + gl_dbg("Done"); + return 0; +} + +int _gl_albums_sel_update_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Update albums list */ + gl_refresh_albums_list(data); + /* Append griditems */ + _gl_albums_create_items(data, ad->albuminfo.select_view); + + if (ad->albuminfo.albums_cnt == 0) { + gl_dbgE("None albums for selection!"); + GL_CHECK_VAL(ad->taginfo.current_tag, -1); + gl_tag *cur_tag = ad->taginfo.current_tag; + GL_CHECK_VAL(cur_tag->tag, -1); + /* Update item list */ + if (cur_tag->tag->_id == GL_TAG_FAVORITES_ID) + _gl_data_get_item_list(data, GL_CATEGORY_FAVORITES, + NULL, GL_GET_ALL_RECORDS, + GL_GET_ALL_RECORDS); + else + _gl_data_get_item_list_tagname(data, cur_tag->tag->_id, + true, NULL); + if (ad->maininfo.medias_cnt == 0) { + ad->albuminfo.select_view = NULL; + ad->albuminfo.select_view_ly = NULL; + ad->albuminfo.nf_it_select = NULL; + /* Show tags view */ + gl_dbg("Change to tags view"); + _gl_tag_comeback_from_view(data); + + elm_naviframe_item_pop_to(ad->ctrlinfo.nf_it); + if (!_gl_data_get_tag_count_all(data)) + _gl_ctrl_disable_btn(data, true, GL_NAVI_TAGS); + return 0; + } + /* change to previous view */ + _gl_albums_sel_pop_view(data); + } + return 0; +} + +/* callback after user tap Cancel button in option header in select album view */ +int _gl_albums_sel_pop_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Popup naviframe item */ + elm_naviframe_item_pop_to(ad->gridinfo.nf_it); + ad->albuminfo.select_view = NULL; + ad->albuminfo.select_view_ly = NULL; + ad->albuminfo.nf_it_select = NULL; + + GL_CHECK_VAL(ad->taginfo.current_tag, -1); + /* Update new medias list */ + gl_dbg("Update items list"); + if (ad->taginfo.current_tag->tag->_id == GL_TAG_FAVORITES_ID) + _gl_data_get_item_list(ad, GL_CATEGORY_FAVORITES, NULL, + GL_GET_ALL_RECORDS, GL_GET_ALL_RECORDS); + else + _gl_data_get_item_list_tagname(ad, + ad->taginfo.current_tag->tag->_id, + true, NULL); + + /* Reset view mode and update edit view */ + gl_set_view_mode(ad, GL_VIEW_THUMBS); + if (_gl_thumbs_show_view(ad) != 0) { + _gl_nocontents_show(ad); + _gl_notify_destroy_selinfo(ad); + } + return 0; +} + +int _gl_albums_sel_update_lang(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->albuminfo.nf_it_select, -1); + gl_dbg(""); + elm_object_item_text_set(ad->albuminfo.nf_it_select, + GL_STR_SELECT_ALBUM); + return 0; +} + diff --git a/src/features/gl-albums.c b/src/features/gl-albums.c new file mode 100755 index 0000000..06fc7a3 --- /dev/null +++ b/src/features/gl-albums.c @@ -0,0 +1,897 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-albums.h" +#include "gl-thumbs.h" +#include "gl-controlbar.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-drm.h" +#include "gl-button.h" +#include "gl-data.h" +#include "gl-popup.h" +#include "gl-progressbar.h" +#include "gl-tags.h" +#include "gl-tile.h" +#include "gl-thumbs-sel.h" +#include "gl-thumbs-edit.h" +#include "gl-albums-sel.h" +#include "gl-albums-edit.h" +#include "gl-albums-rename.h" +#include "gl-strings.h" +#include "gl-nocontents.h" +#include "gl-notify.h" +#ifdef _USE_ROTATE_BG +#include "gl-rotate-bg.h" +#include "gl-exif.h" +#endif + +void _gl_albums_realized(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbg_launch(" realized"); +} + +static void _gl_albums_comeback_from_view_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + /* Delete callback when it is clicked to prevent it is called for many times */ + evas_object_smart_callback_del(obj, "clicked", + _gl_albums_comeback_from_view_cb); + + /* Hide title from animation */ + gl_ui_set_navi_title_visible(ad, EINA_FALSE); + ad->albuminfo.aul_launch_type = GL_AUL_T_NONE; + if (_gl_data_check_update(ad, true)) + gl_refresh_albums_list(ad); + + gl_albums_comeback_from_view(ad); + + _gl_ctrl_disable_btn(ad, false, GL_NAVI_ALBUMS); +} + +/** +* @Brif Update checkbox state and album cover and update selectioninfo. +* +* @Param data gl_appdata. +* @Param album_item album item. +* @Param check_obj object of checkbox. +* @Param b_ck_box true: Checkbox selection, false: album cover selection. +*/ +static int _gl_albums_update_check_state(void *data, + gl_cluster *album_item, + Evas_Object *check_obj, bool b_ck_box) +{ + GL_CHECK_VAL(album_item, -1); + GL_CHECK_VAL(album_item->cluster, -1); + GL_CHECK_VAL(album_item->cluster->uuid, -1); + GL_CHECK_VAL(check_obj, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("Select checkbox[1]/album_cover[0]: %d.", b_ck_box); + + /* Update state of checkbox */ + album_item->checked = !album_item->checked; + gl_dbg("album (%s) check state: %d", album_item->cluster->display_name, + album_item->checked); + + /** + * If album cover selected, update checkbox icon manually, + * If checkbox selected, its icon is updated by system automatically. + */ + Evas_Object *ck = NULL; + if (b_ck_box == false) + ck = elm_object_item_part_content_get(album_item->item, + GL_TILE_CHECKBOX); + else + ck = elm_object_item_part_content_get(album_item->item, + GL_TILE_CHECKBOX_GRID); + elm_check_state_set(ck, album_item->checked); + + if (album_item->checked) { + gl_dbg("Append:%s, id:%s", album_item->cluster->display_name, + album_item->cluster->uuid); + _gl_data_albums_selected_list_append(ad, album_item); + } else { + gl_dbg("Remove:%s, id:%s", album_item->cluster->display_name, + album_item->cluster->uuid); + _gl_data_albums_selected_list_remove(ad, album_item); + } + + /* Display selectioninfo */ + int cnt = _gl_data_get_albums_selected_cnt(ad); + _gl_notify_create_selinfo(ad, ad->ctrlinfo.ctrlbar_edit_ly, + ad->ctrlinfo.nf_it_edit, + ad->albuminfo.albums_cnt, cnt, false); + return 0; +} + +static void _gl_albums_check_changed(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_cluster *album_item = (gl_cluster *)data; + GL_CHECK(album_item->ad); + gl_appdata *ad = (gl_appdata *)album_item->ad; + gl_dbg(""); + + if (gl_get_view_mode(ad) != GL_VIEW_ALBUMS_EDIT) { + gl_dbgE("Wrong view mode!"); + return; + } + + /* Checkbox selected, b_ck_box=true */ + _gl_albums_update_check_state(ad, album_item, obj, true); +} + +static void _gl_albums_check_grid_changed(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_cluster *album_item = (gl_cluster *)data; + GL_CHECK(album_item->ad); + gl_appdata *ad = (gl_appdata *)album_item->ad; + gl_dbg(""); + + if (gl_get_view_mode(ad) != GL_VIEW_ALBUMS_EDIT) { + gl_dbgE("Wrong view mode!"); + return; + } else { + /* gl_dbg("EditMode"); */ + } + + /* Grid checkbox selected, b_ck_box=false */ + _gl_albums_update_check_state(ad, album_item, obj, false); +} + +/* Callback of album item selection */ +static void __gl_albums_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_cluster *album_item = (gl_cluster *)data; + GL_CHECK(album_item->cluster); + GL_CHECK(album_item->ad); + gl_appdata *ad = (gl_appdata *)album_item->ad; + int view_mode = gl_get_view_mode(ad); + + gl_dbg("view mode: %d.", view_mode); + if (view_mode != GL_VIEW_ALBUMS_EDIT) { + if (album_item->cluster->count == 0) { + gl_dbgW("Empty album, return!"); + return; + } + gl_albums_sel_album(album_item); + } +} + +static void __gl_albums_rename_job_cb(void *data) +{ + GL_CHECK(data); + gl_cluster *album = (gl_cluster *)data; + GL_CHECK(album->ad); + gl_appdata *ad = (gl_appdata *)album->ad; + /* save album selected for rename */ + if (_gl_albums_rename_create_view(album->ad, album) == 0) + ad->albuminfo.selected_album = album; +} + +static void _gl_albums_rename_btn_cb(void *data, Evas_Object *obj, + void *event_info) +{ + gl_dbg(""); + GL_CHECK(data); + gl_cluster *album_item = (gl_cluster *)data; + gl_appdata *ad = (gl_appdata *)album_item->ad; + + /* Return if album selected */ + if (!album_item->checked) { + gl_dbgW("Album checked!"); + return; + } + + /* Album cover selected, b_ck_box=false, deselect checkbox */ + Evas_Object *ck = NULL; + ck = elm_object_item_part_content_get(album_item->item, + GL_TILE_CHECKBOX); + _gl_albums_update_check_state(ad, album_item, ck, false); + + if(ad->maininfo.rename_album_job) { + ecore_job_del(ad->maininfo.rename_album_job); + ad->maininfo.rename_album_job = NULL; + } + ad->maininfo.rename_album_job = ecore_job_add(__gl_albums_rename_job_cb, + album_item); +} + +static char *__gl_albums_get_text(void *data, Evas_Object *obj, const char *part) +{ + GL_CHECK_NULL(part); + GL_CHECK_NULL(strlen(part)); + GL_CHECK_NULL(data); + gl_cluster *album_item = (gl_cluster *)data; + GL_CHECK_NULL(album_item->cluster); + GL_CHECK_NULL(album_item->cluster->display_name); + GL_CHECK_NULL(album_item->cluster->uuid); + GL_CHECK_NULL(album_item->ad); + gl_appdata *ad = (gl_appdata *)album_item->ad; + char buf[GL_ALBUM_NAME_LEN_MAX] = { 0, }; + + if (!g_strcmp0(part, "elm.text.name")) { + gl_dbg_launch(" text.name"); + gl_dbg("text.name"); + if (_gl_data_is_root_path(album_item->cluster->path)) { + snprintf(buf, sizeof(buf), "%s", + GL_ALBUM_PHOME_ROOT_NAME); + } else if (album_item->cluster->display_name && + strlen(album_item->cluster->display_name)) { + char *new_name = _gl_get_i18n_album_name(album_item); + snprintf(buf, sizeof(buf), "%s", new_name); + } else { + gl_dbgE("Album name[%s] is wrong!", + album_item->cluster->display_name); + } + } else if (!g_strcmp0(part, "elm.text.date")) { + int i = 0; + int item_count = GL_ALBUM_COVER_THUMB_NUM; + gl_item **items1 = ad->albuminfo.cover_thumbs; + gl_albums_free_cover_thumbs(ad); + + _gl_data_get_first_several_items(album_item, items1, &item_count, + MEDIA_CONTENT_ORDER_DESC); + if (item_count <= 0) { + gl_dbg("Empty album..."); + ad->albuminfo.album_medias_cnt = 0; + return NULL; + } + + ad->albuminfo.album_medias_cnt = item_count; + if (items1[0] == NULL || items1[0]->item == NULL) { + gl_dbgE("[Error] Invalid item!"); + ad->albuminfo.album_medias_cnt = 0; + return NULL; + } + + item_count = 1; + gl_item *items2[1]; + int sort_t = MEDIA_CONTENT_ORDER_ASC; + memset(items2, 0x00, item_count * sizeof(int)); + _gl_data_get_first_several_items(album_item, + items2, &item_count, + sort_t); + + if (item_count <= 0) { + gl_dbg("Empty album..."); + return NULL; + } + + if (items2[0] == NULL || items2[0]->item == NULL) { + gl_dbgE("Invalid items2[0]!"); + ad->albuminfo.album_medias_cnt = 0; + return NULL; + } + _gl_tile_get_mtime((time_t *)&(items1[0]->item->mtime), + (time_t *)&(items2[0]->item->mtime), + buf, GL_ALBUM_NAME_LEN_MAX); + + for (i = 0; i < item_count; i++) { + _gl_data_destroy_item(items2[i]); + items2[i] = NULL; + } + } else if (!g_strcmp0(part, "elm.text.count")) { + int count = 0; + if (ad->taginfo.current_tag && ad->taginfo.current_tag->tag) { + int tag_id = ad->taginfo.current_tag->tag->_id; + count = _gl_local_data_get_media_count_wichout_tag(tag_id, + album_item->cluster->uuid); + } else { + _gl_data_update_item_cnt(album_item); + count = album_item->cluster->count; + } + + snprintf(buf, sizeof(buf), "%d", count); + } + + return strdup(buf); + +} + +static int __gl_albums_set_bg_file(Evas_Object *bg, void *data) +{ + gl_item *git = (gl_item *)data; + char *bg_path = GL_DEFAULT_THUMB_ICON; + gl_icon_type ret_val = -1; + + if (git == NULL || git->item == NULL) { + gl_dbgE("Invalid item :%p", git); + goto GL_ALBUMS_FAILED; + } + + /* Is it DRM file? Has a valid RO? */ + if(_gl_get_icon_type(git) == GL_ICON_EXPIRED_DRM) { + gl_dbgW("Expired DRM!"); + goto GL_ALBUMS_FAILED; + } + + ret_val= 0; + bg_path = _GET_ICON(git->item->thumb_url); + + GL_ALBUMS_FAILED: + +#ifdef _USE_ROTATE_BG + _gl_rotate_bg_set_image_file(bg, bg_path); +#else + elm_bg_file_set(bg, bg_path, NULL); +#endif + + return ret_val; +} + +static Evas_Object *__gl_albums_get_content(void *data, Evas_Object *obj, const char *part) +{ + GL_CHECK_NULL(part); + GL_CHECK_NULL(strlen(part)); + GL_CHECK_NULL(data); + gl_cluster *album_item = (gl_cluster *)data; + GL_CHECK_NULL(album_item->cluster); + GL_CHECK_NULL(album_item->ad); + gl_appdata *ad = (gl_appdata *)album_item->ad; + GL_CHECK_NULL(album_item->cluster->uuid); + int view_mode = gl_get_view_mode(ad); + + if (view_mode != GL_VIEW_ALBUMS && + view_mode != GL_VIEW_ALBUMS_EDIT && + view_mode != GL_VIEW_ALBUMS_SELECT) + return NULL; + + Evas_Object *_obj = NULL; + if (!g_strcmp0(part, GT_TILE_ONLYICON)) { + _obj = _gl_tile_show_part_icon(obj, part, + ad->albuminfo.album_medias_cnt, + ad->maininfo.win_scale, + __gl_albums_set_bg_file, + (void **)ad->albuminfo.cover_thumbs); + } else if (!g_strcmp0(part, GT_TILE_LABEL)) { + /** + * for "All albums" and "Camera shots", their colors should be + * 25:25:25 by new gui + */ + bool b_default = false; + if (album_item->cluster->type == GL_STORE_T_ALL || + _gl_data_is_default_album(GL_ALBUM_DEFAULT_NAME, album_item->cluster)) + b_default = true; + _obj = _gl_tile_show_part_label(obj, album_item->index, + b_default); + + gl_dbg_launch(" content"); + if (ad->albuminfo.album_medias_cnt <= 0) + gl_dbg("Empty album"); + } else if (!g_strcmp0(part, GL_TILE_CHECKBOX_GRID) && + view_mode == GL_VIEW_ALBUMS_EDIT) { + _obj = _gl_tile_show_part_checkbox_grid(obj, album_item->checked, + _gl_albums_check_grid_changed, + data); + } else if (!g_strcmp0(part, GL_TILE_CHECKBOX) && + view_mode == GL_VIEW_ALBUMS_EDIT) { + _obj = _gl_tile_show_part_checkbox(obj, album_item->checked, + _gl_albums_check_changed, + data); + } else if (!g_strcmp0(part, GL_TILE_RENAME) && + view_mode == GL_VIEW_ALBUMS_EDIT) { + /** + * Fixme: In My Files app, it's unable to rename + * 'My video clips', 'Wallpapers' and 'My photo clips'. + * Maybe we need to remove rename button + * from these three albums cover. + */ + + /** + * Don't add rename button to 'All' and Web albums + * and 'Camera shot'[default album] + */ + if (album_item->cluster->type == GL_STORE_T_ALL || + _gl_data_is_default_album(GL_ALBUM_DEFAULT_NAME, album_item->cluster)) + return NULL; + + _obj = _gl_tile_show_part_rename(obj, _gl_albums_rename_btn_cb, + data); + } + + return _obj; +} + +int _gl_albums_create_items(void *data, Evas_Object *parent) +{ + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + gl_cluster *album_item = NULL; + int length = 0; + gl_dbg(""); + + gl_ctrl_disable_tab_event(ad, true); + /* Clear albums view */ + elm_gengrid_clear(parent); + + if (gl_get_view_mode(ad) == GL_VIEW_ALBUMS_EDIT) + ad->albuminfo.albumgic.item_style = GL_GENGRID_STYLE_ALBUM_EDIT_VIEW; + else + ad->albuminfo.albumgic.item_style = GL_GENGRID_STYLE_ALBUM_VIEW; + ad->albuminfo.albumgic.func.text_get = __gl_albums_get_text; + ad->albuminfo.albumgic.func.content_get = __gl_albums_get_content; + + GL_CHECK_VAL(ad->albuminfo.cluster_list, -1); + GL_CHECK_VAL(ad->albuminfo.cluster_list->clist, -1); + Eina_List *clist = ad->albuminfo.cluster_list->clist; + length = eina_list_count(clist); + gl_dbg("Albums length: %d", length); + const char *al_id = NULL; + Elm_Gengrid_Item_Class *pgic = &(ad->albuminfo.albumgic); + int item_cnt = 0; + + gl_dbg_launch(" for:elm_gengrid_item_append:start"); + for (i = 0; i < length; i++) { + album_item = eina_list_nth(clist, i); + GL_CHECK_VAL(album_item, -1); + GL_CHECK_VAL(album_item->cluster, -1); + GL_CHECK_VAL(album_item->cluster->display_name, -1); + GL_CHECK_VAL(album_item->cluster->uuid, -1); + al_id = album_item->cluster->uuid; + if (ad->maininfo.view_mode == GL_VIEW_ALBUMS_EDIT && + !g_strcmp0(al_id, GL_ALBUM_ALL_ID)) + continue; + if (ad->taginfo.current_tag && ad->taginfo.current_tag->tag) { + int tag_id = ad->taginfo.current_tag->tag->_id; + if (_gl_local_data_get_media_count_wichout_tag(tag_id, album_item->cluster->uuid) < 1) + continue; + } + + album_item->item = elm_gengrid_item_append(parent, pgic, + album_item, + __gl_albums_sel_cb, + album_item); + album_item->index = item_cnt; + item_cnt++; + gl_dbg("Append[%s], id=%s.", album_item->cluster->display_name, + al_id); + } + gl_dbg_launch(" for:elm_gengrid_item_append:end"); + + ad->albuminfo.albums_cnt = item_cnt; + + gl_ctrl_disable_tab_event(ad, false); + + return 0; +} + +static int __gl_albums_reset_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d", view_mode); + + if (view_mode != GL_VIEW_ALBUMS && + view_mode != GL_VIEW_ALBUMS_EDIT && + view_mode != GL_VIEW_ALBUMS_RENAME) { + gl_dbg("Change to albums view"); + gl_destroy_thumbs_view(ad); + gl_refresh_albums_list(ad); + gl_albums_comeback_from_view(ad); + } else if (view_mode == GL_VIEW_ALBUMS_EDIT || + view_mode == GL_VIEW_ALBUMS_RENAME) { + gl_del_invalid_widgets(ad, GL_INVALID_NONE); + _gl_albums_edit_pop_view(ad); + } + + return 0; +} + +int gl_albums_sel_album(gl_cluster *album_item) +{ + GL_CHECK_VAL(album_item, -1); + GL_CHECK_VAL(album_item->cluster, -1); + GL_CHECK_VAL(album_item->cluster->uuid, -1); + GL_CHECK_VAL(album_item->ad, -1); + gl_appdata *ad = (gl_appdata *)album_item->ad; + GL_CHECK_VAL(ad->albuminfo.cluster_list, -1); + GL_CHECK_VAL(ad->albuminfo.cluster_list->clist, -1); + int view_mode = gl_get_view_mode(ad); + + if (view_mode == GL_VIEW_ALBUMS) { + gl_dbg("View mode!"); + } else if (view_mode == GL_VIEW_ALBUMS_SELECT) { + gl_dbg("Select mode!"); + _gl_thumbs_sel_create_view(ad, album_item); + return 0; + } else { + gl_dbgW("Wrong view mode"); + return -1; + } + char *al_na = _gl_get_i18n_album_name(album_item); + gl_dbg("current %s album, id=%s", al_na, album_item->cluster->uuid); + ad->albuminfo.current_album = album_item; + _gl_data_get_item_list(ad, GL_CATEGORY_FOLDER, album_item, + GL_FIRST_VIEW_START_POS, GL_FIRST_VIEW_END_POS); + + gl_navi_mode mode = GL_NAVI_THUMBS; + if (_gl_data_is_root_path(album_item->cluster->path)) { + /* check root case */ + al_na = GL_ALBUM_PHOME_ROOT_NAME; + } else if (ad->albuminfo.aul_launch_type == GL_AUL_T_VIEW_ALBUM) { + /* launch by appcontrol */ + if (ad->albuminfo.aul_file_type == GL_AUL_FILE_T_IMAGE) + al_na = GL_ALBUM_IMAGES_NAME; + else if (ad->albuminfo.aul_file_type == GL_AUL_FILE_T_VIDEO) + al_na = GL_ALBUM_VIDEOS_NAME; + else if (al_na == NULL) + al_na = GL_ALBUM_ALL_NAME; + } + + _gl_thumbs_create_view(ad, mode, al_na, true, + _gl_albums_comeback_from_view_cb); + + /* Checkme: clear albums view for animation effect pause issue */ + elm_gengrid_clear(ad->albuminfo.albums_view); + gl_dbg("albums_view 0x%x cleared", ad->albuminfo.albums_view); + gl_dbg("Done albums selected"); + return 0; +} + +Evas_Object *_gl_albums_add_gengrid(void *data, Evas_Object *parent) +{ + GL_CHECK_NULL(parent); + GL_CHECK_NULL(data); + Evas_Object *grid = _gl_tile_add_gengrid(data, parent); + evas_object_smart_callback_add(grid, "realized", _gl_albums_realized, + data); + evas_object_show(grid); + return grid; +} + +Evas_Object *gl_albums_create_view(void *data, Evas_Object *parent) +{ + GL_CHECK_NULL(parent); + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_NULL(ad->albuminfo.cluster_list); + gl_dbg(""); + gl_dbg_launch(" gl_albums_create_view:start"); + + gl_albums_free_cover_thumbs(ad); + memset(ad->albuminfo.cover_thumbs, 0x00, + GL_ALBUM_COVER_THUMB_NUM * sizeof(int)); + ad->albuminfo.album_medias_cnt = 0; + ad->albuminfo.albums_cnt = 0; + + Evas_Object *grid = _gl_albums_add_gengrid(data, parent); + GL_CHECK_NULL(grid); + + if (ad->maininfo.view_mode != GL_VIEW_THUMBS) + _gl_albums_create_items(ad, grid); + + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d", view_mode); + if (view_mode == GL_VIEW_ALBUMS_SELECT) { + if (ad->albuminfo.albums_cnt == 0) { + gl_dbgE("None albums!"); + evas_object_del(grid); + grid = _gl_nocontents_create(ad); + } else { + evas_object_show(grid); + } + return grid; + } + + /* show no contents none album exists */ + if (gl_check_gallery_empty(ad)) { + evas_object_del(grid); + grid = NULL; + + /* Set the grid view mode for creating nocontents view */ + ad->gridinfo.view_mode = GL_THUMB_ALBUMS; + Evas_Object *noc = _gl_nocontents_create(ad); + evas_object_show(noc); + ad->albuminfo.albums_nocontents = noc; + + return noc; + } else { + ad->albuminfo.albums_nocontents = NULL; + } + + gl_dbg("gl_albums_create_view:done"); + gl_dbg_launch(" gl_albums_create_view:end"); + + return grid; +} + +/* From thumbnails view to albums view */ +int gl_albums_comeback_from_view(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + gl_set_view_mode(ad, GL_VIEW_ALBUMS); + gl_ctrl_rotate_ctrlbar(ad, GL_VIEW_ALBUMS); + + _gl_thumbs_delete_view(ad); + + ad->albuminfo.current_album = NULL; + gl_albums_update_items(ad); + return 0; +} + +/* From albums edit view to albums view */ +int gl_albums_change_to_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->albuminfo.cluster_list, -1); + gl_dbg(""); + + ad->albuminfo.albums_cnt = 0; + GL_CHECK_VAL(ad->albuminfo.albums_view, -1); + gl_set_view_mode(ad, GL_VIEW_ALBUMS); + /* changed to show no contents if needed */ + if (gl_check_gallery_empty(ad)) { + if (ad->albuminfo.albums_view) + evas_object_del(ad->albuminfo.albums_view); + + /* Set the grid view mode for creating nocontents view */ + ad->gridinfo.view_mode = GL_THUMB_ALBUMS; + Evas_Object *noc = _gl_nocontents_create(ad); + ad->albuminfo.albums_nocontents = noc; + ad->albuminfo.albums_view = noc; + evas_object_show(noc); + + Evas_Object *old_view = NULL; + old_view = elm_object_part_content_unset(ad->ctrlinfo.ctrlbar_view_ly, + "contents"); + evas_object_del(old_view); + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_view_ly, + "contents", noc); + } else { + _gl_albums_create_items(ad, ad->albuminfo.albums_view); + } + + return 0; +} + +/* Update albums view */ +int gl_albums_update_items(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->albuminfo.cluster_list, -1); + int view_mode = gl_get_view_mode(ad); + ad->albuminfo.albums_cnt = 0; + gl_dbg(""); + /* Changed to show no contents if needed */ + if (gl_check_gallery_empty(ad)) { + /* Set the grid view mode for creating nocontents view */ + ad->gridinfo.view_mode = GL_THUMB_ALBUMS; + evas_object_del(ad->albuminfo.albums_view); + + Evas_Object *noc = _gl_nocontents_create(ad); + ad->albuminfo.albums_nocontents = noc; + ad->albuminfo.albums_view = noc; + evas_object_show(noc); + + Evas_Object *old_view = NULL; + old_view = elm_object_part_content_unset(ad->ctrlinfo.ctrlbar_view_ly, + "contents"); + evas_object_del(old_view); + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_view_ly, + "contents", noc); + } else { + if (view_mode == GL_VIEW_ALBUMS_EDIT) { + _gl_albums_create_items(ad, + ad->ctrlinfo.ctrlbar_edit_view); + /* Display selectioninfo */ + int cnt = _gl_data_get_albums_selected_cnt(ad); + _gl_notify_create_selinfo(ad, + ad->ctrlinfo.ctrlbar_edit_ly, + ad->ctrlinfo.nf_it_edit, + ad->albuminfo.albums_cnt, cnt, + true); + } else { + if (ad->albuminfo.albums_nocontents) { + /** + * current view is nocontents, + * unset it first then create albums view. + */ + gl_albums_remove_nocontents(ad); + } else { + Evas_Object *al_view = NULL; + al_view = ad->albuminfo.albums_view; + _gl_albums_create_items(ad, al_view); + } + } + } + + return 0; +} + +/* Update albums list and refresh albums view, remove invalid widgets */ +int gl_albums_update_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d.", view_mode); + + gl_albums_free_cover_thumbs(ad); + memset(ad->albuminfo.cover_thumbs, 0x00, + GL_ALBUM_COVER_THUMB_NUM * sizeof(int)); + ad->albuminfo.albums_cnt = 0; + + if (view_mode == GL_VIEW_ALBUMS) { + /* Update albums list*/ + gl_refresh_albums_list(ad); + + /* Only newly downloaded web album */ + if (ad->albuminfo.albums_nocontents) { + gl_albums_remove_nocontents(ad); + } else if (!gl_check_gallery_empty(ad)) { + _gl_albums_create_items(ad, ad->albuminfo.albums_view); + if (ad->albuminfo.cluster_list->edit_cnt) + _gl_ctrl_disable_btn(ad, false, GL_NAVI_ALBUMS); + else + _gl_ctrl_disable_btn(ad, true, GL_NAVI_ALBUMS); + } else { + gl_dbg("View is empty."); + gl_albums_update_items(ad); + _gl_ctrl_disable_btn(ad, true, GL_NAVI_ALBUMS); + gl_ctrl_disable_ctrlbar(ad, true); + } + } else if (view_mode == GL_VIEW_ALBUMS_EDIT) { + _gl_albums_edit_update_view(data); + } else if (view_mode == GL_VIEW_ALBUMS_RENAME) { + _gl_albums_rename_update_view(data); + } else if (view_mode == GL_VIEW_ALBUMS_SELECT) { + /* Update albums selection view */ + _gl_albums_sel_update_view(data); + } + return 0; +} + +/** +* Remove nocontents view and show albums view. +* Case 1, gallery is empty->home key tapped +* ->take photos with camera->back to gallery; +*/ +int gl_albums_remove_nocontents(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *view = NULL; + gl_dbg(""); + + if (ad->albuminfo.albums_nocontents && !gl_check_gallery_empty(ad)) { + gl_dbg("Remove nocontents view then create albums view."); + evas_object_del(ad->albuminfo.albums_nocontents); + ad->albuminfo.albums_nocontents = NULL; + + view = gl_albums_create_view(ad, ad->maininfo.naviframe); + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_view_ly, + "contents", view); + evas_object_show(view); + ad->albuminfo.albums_view = view; + + _gl_ctrl_disable_btn(ad, false, GL_NAVI_ALBUMS); + gl_ctrl_disable_ctrlbar(ad, false); + } else if (ad->albuminfo.albums_nocontents) { + gl_dbg("Gallery is empty!"); + bool b_update = false; + b_update = _gl_nocontents_update_label(ad->albuminfo.albums_nocontents, + GL_STR_NO_ALBUMS); + /* Update toolbar state */ + if (b_update) + _gl_ctrl_disable_btn(ad, false, GL_NAVI_ALBUMS); + } else { + gl_dbg("Nocontents was removed!"); + } + + return 0; +} + +int gl_albums_free_cover_thumbs(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + + for (i = 0; i < GL_ALBUM_COVER_THUMB_NUM; i++) { + if (ad->albuminfo.cover_thumbs[i]) { + _gl_data_destroy_item(ad->albuminfo.cover_thumbs[i]); + ad->albuminfo.cover_thumbs[i] = NULL; + } + } + + return 0; +} + +/* Free resources allocated for albums view */ +int gl_albums_free_data(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + gl_albums_free_cover_thumbs(data); + GL_FREEIF(ad->albuminfo.path); + return 0; +} + +int _gl_albums_reset_view(void *data, const char *uuid, const char *aul_type) +{ + GL_CHECK_VAL(aul_type, -1); + GL_CHECK_VAL(uuid, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + + if (!g_strcmp0(aul_type, GL_AUL_ALBUM) && + g_strcmp0(uuid, GL_ALBUM_UUID_DEFAULT)) { + gl_cluster *album = ad->albuminfo.current_album; + if (album && album->cluster && album->cluster->uuid) { + bool b_cur_album_exists = false; + if (!g_strcmp0(album->cluster->uuid, uuid)) { + int its_cnt = 0; + int ret = -1; + ret = _gl_data_get_item_cnt(ad, uuid, false, + album->cluster->type, + &its_cnt); + if (ret != 0 || its_cnt == 0) + gl_dbgE("Empty current album!"); + else + b_cur_album_exists = true; + } + + /* Current album exists and it's not empty */ + if (b_cur_album_exists) { + gl_dbg("Current album, update view"); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + gl_del_invalid_widgets(ad, GL_INVALID_NONE); + /* Set flag to update albums list */ + ad->albuminfo.update_albums_list = true; + _gl_thumbs_edit_pop_view(ad); + } else { + gl_update_view(ad, GL_UPDATE_VIEW_NORMAL); + } + + return -1; + } + } + + __gl_albums_reset_view(ad); + } else { + __gl_albums_reset_view(ad); + + _gl_ctrl_sel_tabbar_item(ad, aul_type); + } + + return 0; +} + diff --git a/src/features/gl-tags-edit.c b/src/features/gl-tags-edit.c new file mode 100755 index 0000000..83ba1ea --- /dev/null +++ b/src/features/gl-tags-edit.c @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "gl-tags.h" +#include "gl-tags-edit.h" +#include "gl-debug.h" +#include "gl-strings.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-data.h" +#include "gl-icons.h" +#include "gl-controlbar.h" +#include "gl-ctxpopup.h" +#include "gl-button.h" +#include "gl-notify.h" +#include "gl-popup.h" + +/* +* delete selected tags from tags list view. +*/ +static int __gl_tags_edit_del(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_tag *gtag = NULL; + int cnt = _gl_data_get_tags_selected_cnt(ad); + int i = 0; + gl_dbg(""); + + Eina_List *selected_list = ad->taginfo.selected_tags_elist; + if ((selected_list == NULL) || (cnt == 0)) { + gl_dbgE("tags selected list is empty!"); + return -1; + } + + gl_dbg("selected list length=%d", cnt); + for (i = 0; i < cnt; i++) { + gtag = eina_list_nth(selected_list, i); + if (gtag && gtag->tag) { + gl_dbg("tag name: %s", gtag->tag->tag_name); + _gl_local_data_delete_tag(gtag->tag); + } + } + + /* update the tags view */ + _gl_tags_edit_pop_view(ad); + /* add notification */ + _gl_notify_create_notiinfo(ad, GL_STR_DELETED); + return 0; +} + +static void __gl_tags_edit_trans_finished_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbgW("view_mode: %d", view_mode); + evas_object_smart_callback_del(obj, GL_TRANS_FINISHED, + __gl_tags_edit_trans_finished_cb); + + /* Clear previous view after animation finished */ + if (view_mode == GL_VIEW_TAGS_EDIT) + elm_genlist_clear(ad->taginfo.tags_view); + else + gl_dbgE("Wrong view mode!"); +} + +static void __gl_tags_edit_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Disable item when it is clicked to prevent it is called for many times */ + if (_gl_tags_edit_pop_view(data) == 0) + _gl_ui_disable_btn(obj); +} + +static void __gl_tags_edit_del_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + int view_mode = gl_get_view_mode(data); + gl_dbg(""); + + if (view_mode == GL_VIEW_TAGS_EDIT) { + if (_gl_data_get_tags_selected_cnt(data) == 0) { + gl_dbg("No tags selected, return!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_TAGS_SELECTED); + return; + } + + __gl_tags_edit_del(data); + } else { + gl_dbgE("Unkonw mode!"); + } +} + +static void __gl_tags_edit_share_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me) { + gl_dbgW("UG or APP is already loaded!"); + return; + } + + int view_mode = gl_get_view_mode(ad); + if (view_mode == GL_VIEW_TAGS_EDIT) { + if (_gl_data_get_tags_selected_cnt(ad) == 0) { + gl_dbg("No tags selected, return!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_TAGS_SELECTED); + return; + } + /* Check tags are empty */ + if (_gl_data_is_tags_selected_empty(ad)) { + gl_dbg("No thumbs selected, return!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return; + } + } else { + gl_dbgE("Unknow mode!"); + return; + } + + _gl_ctxpopup_create_share(data, obj); +} + +/** + * Use naviframe api to push tags eidt view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_tags_edit_push_view(void *data, Evas_Object *parent, + Evas_Object *obj) +{ + gl_dbg("GL_NAVI_TAGS_EDIT"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + + /* Add transition finished callback */ + evas_object_smart_callback_add(parent, GL_TRANS_FINISHED, + __gl_tags_edit_trans_finished_cb, ad); + Evas_Object *end_btn = NULL; + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_tags_edit_cancel_cb, ad); + GL_CHECK_VAL(end_btn, -1); + /* Push to stack */ + nf_it = elm_naviframe_item_push(parent, NULL, end_btn, NULL, obj, + GL_NF_ANI_TABBAR); + elm_naviframe_item_title_visible_set(nf_it, EINA_FALSE); + ad->ctrlinfo.nf_it_edit = nf_it; + + Evas_Object *btn = NULL; + /* Delete */ + btn = _gl_but_create_but(parent, NULL, GL_STR_DELETE, + GL_BUTTON_STYLE_NAVI_TOOLBAR_RIGHT, + __gl_tags_edit_del_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN2, btn); + _gl_ui_disable_btn(btn); + /* Share */ + btn = _gl_but_create_but(parent, NULL, GL_STR_SHARE, + GL_BUTTON_STYLE_NAVI_TOOLBAR_LEFT, + __gl_tags_edit_share_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, btn); + _gl_ui_disable_btn(btn); + + return 0; +} + +int _gl_tags_edit_create_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Evas_Object *layout = NULL; + Evas_Object *view = NULL; + + gl_set_view_mode(data, GL_VIEW_TAGS_EDIT); + + layout = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(layout, -1); + + view = gl_tag_create_view(ad, layout); + if (view == NULL) { + gl_dbgE("Failed to create tags edit view!"); + evas_object_del(layout); + return -1; + } + + evas_object_show(view); + elm_object_part_content_set(layout, "elm.swallow.view", view); + edje_object_signal_emit(_EDJ(layout), GL_SIGNAL_VIEW_EDIT, "elm"); + + ad->ctrlinfo.ctrlbar_edit_ly = layout; + ad->ctrlinfo.ctrlbar_edit_view = view; + + gl_ui_show_selall(ad); + __gl_tags_edit_push_view(ad, ad->maininfo.naviframe, layout); + return 0; +} + +int _gl_tags_edit_pop_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + + elm_naviframe_item_pop(ad->maininfo.naviframe); + + gl_tag_unset_rename(data); + _gl_destroy_ctrl_edit_view(data); + + /* Set current gtag NULL for rename */ + ad->taginfo.current_tag = NULL; + _gl_data_finalize_tags_selected_list(data); + + gl_set_view_mode(data, GL_VIEW_TAGS); + gl_tag_update_view(data); + + if (_gl_data_get_tag_count_all(data) <= 1) { + _gl_ctrl_disable_btn(data, true, GL_NAVI_TAGS); + } + _gl_notify_destroy_selinfo(data); + return 0; +} + +/* Share tag's content */ +int _gl_tags_edit_share(void *data, const char *label) +{ + GL_CHECK_VAL(label, -1); + GL_CHECK_VAL(data, -1); + gl_dbg("label : %s ", label); + + int cnt = _gl_data_get_tags_selected_cnt(data); + gl_dbg("Selected tag(s) count: %d.", cnt); + if (cnt < 1) { + gl_dbgE("None tag selected!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_TAGS_SELECTED); + return -1; + } + if (_gl_data_is_tags_selected_empty(data)) { + gl_dbgE("None thumb selected!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return -1; + } + + return _gl_share_load(data, label); +} + +int _gl_tags_edit_update_lang(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->ctrlinfo.nf_it_edit, -1); + + /*Reset select info text*/ + int cnt = _gl_data_get_tags_selected_cnt(ad); + _gl_notify_update_lang(ad, cnt, GL_VIEW_TAGS_EDIT); + + if (ad->popupinfo.popup) { + if (ad->popupinfo.popup_mode == GL_POPUP_NOBUT) + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + else if (ad->popupinfo.popup_mode == GL_POPUP_NOBUT) + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_TAGS_SELECTED); + } + + _gl_ui_set_btns_text(ad->ctrlinfo.nf_it_edit, GL_STR_SHARE, + GL_STR_DELETE); + return 0; +} + diff --git a/src/features/gl-tags-new.c b/src/features/gl-tags-new.c new file mode 100755 index 0000000..175e391 --- /dev/null +++ b/src/features/gl-tags-new.c @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-tags-new.h" +#include "gl-tags.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-data.h" +#include "gl-controlbar.h" +#include "gl-editfield.h" +#include "gl-button.h" +#include "gl-strings.h" + +static void __gl_tags_new_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Delete callback when it is clicked to prevent it is called for many times */ + evas_object_smart_callback_del(obj, "clicked", __gl_tags_new_cancel_cb); + _gl_tags_new_pop_view(data); +} + +static void __gl_tags_new_done_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Delete callback when it is clicked to prevent it is called for many times */ + if (_gl_tags_new_process(data, false) == 0) + evas_object_smart_callback_del(obj, "clicked", + __gl_tags_new_done_cb); +} + +/** + * Use naviframe api to push new tag view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_tags_new_push_view(void *data, Evas_Object *parent, + Evas_Object *obj, char *title) +{ + gl_dbg("GL_NAVI_TAGS_NEW"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + Evas_Object *done_btn = NULL; + Evas_Object *cancel_btn = NULL; + Evas_Object *end_btn = NULL; + + if (gl_get_view_mode(ad) != GL_VIEW_ALBUMS) + _gl_ctrl_show_tabbar(ad, false); + + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_tags_new_cancel_cb, data); + GL_CHECK_VAL(end_btn, -1); + + nf_it = elm_naviframe_item_push(parent, title, end_btn, NULL, obj, + NULL); + ad->entryinfo.nf_it = nf_it; + /* Add 'Cancel' button */ + cancel_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_tags_new_cancel_cb, data); + GL_CHECK_VAL(cancel_btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_TITLE_PREV_BTN, + cancel_btn); + /* Add 'Done' button */ + done_btn = _gl_but_create_but(parent, NULL, GL_STR_DONE, + GL_BUTTON_STYLE_NAVI_TOOLBAR, + __gl_tags_new_done_cb, data); + GL_CHECK_VAL(done_btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, done_btn); + ad->entryinfo.done_btn = done_btn; + + /* Add callbacks to show/hide title toolbar */ + _gl_ui_add_conform_cbs(parent); + return 0; +} + +/* +* create a new tag +*/ +int _gl_tags_new_create_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Evas_Object *editfield_ly = NULL; + gl_dbg(""); + + ad->entryinfo.entry_mode = GL_ENTRY_NEW_TAG; + + editfield_ly = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(editfield_ly, -1); + Evas_Object *entry = _gl_editfield_create(ad, editfield_ly, NULL); + if (entry == NULL) { + gl_dbgE("Failed to add entry!"); + ad->entryinfo.entry_mode = GL_ENTRY_NONE; + evas_object_del(entry); + return -1; + } + elm_object_part_content_set(editfield_ly, "elm.swallow.view", entry); + edje_object_signal_emit(_EDJ(editfield_ly), GL_SIGNAL_VIEW_DEFAULT, + "elm"); + __gl_tags_new_push_view(ad, ad->maininfo.naviframe, editfield_ly, + GL_STR_CREATE_TAG); + _gl_editfield_show_imf(ad); + return 0; +} + +/* +* cancel adding a new tag. +*/ +int _gl_tags_new_pop_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + int view_m = gl_get_view_mode(ad); + /* in tags list view case */ + if (view_m == GL_VIEW_TAGS) { + /* Hide title from animation */ + gl_ui_set_navi_title_visible(ad, EINA_FALSE); + elm_naviframe_item_pop(ad->maininfo.naviframe); + _gl_editfield_destroy_imf(ad); + /* Rotate bottom toolbar+tabbar */ + gl_ctrl_rotate_ctrlbar(ad, GL_VIEW_TAGS); + /* Recover the previous UI */ + gl_tag_update_view(ad); + } else { + elm_naviframe_item_pop(ad->maininfo.naviframe); + _gl_editfield_destroy_imf(ad); + gl_ui_update_select_widgets(ad); + } + return 0; +} + +/* +* After adding a new tag, then move selected items to this newly created tag. +* +* @param b_enter +* True: Enter key on Keyboard pressed, False: Button Done clicked +*/ +int _gl_tags_new_process(void *data, bool b_enter) +{ + gl_dbg("b_enter: %d", b_enter); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->entryinfo.editfield == NULL) { + gl_dbgE("Editfield is NULL!"); + goto NEW_TAG_FAILED; + } + + if (ad->entryinfo.imf_context) + ecore_imf_context_input_panel_hide(ad->entryinfo.imf_context); + + Evas_Object *entry = ad->entryinfo.imf_entry; + char tname[GL_ARRAY_LEN_MAX] = { 0, }; + + /* Get utf8 format string */ + if (gl_get_entry_text(entry, tname, GL_ARRAY_LEN_MAX) != 0) { + gl_dbgE("Get entry text failed!"); + goto NEW_TAG_FAILED; + } + + /* Get valid name */ + if (_gl_get_valid_tag_name(ad, tname, true, b_enter) != 0) { + if (b_enter) + _gl_editfield_hide_imf(ad); + return -1; + } + gl_dbg("Valid tag name: %s", tname); + + _gl_editfield_destroy_imf(ad); + /* Add selected items to new tag */ + gl_add_to_tag(ad, tname); + return 0; + + NEW_TAG_FAILED: + _gl_tags_new_pop_view(ad); + return -1; +} + diff --git a/src/features/gl-tags-rename.c b/src/features/gl-tags-rename.c new file mode 100755 index 0000000..2504f7e --- /dev/null +++ b/src/features/gl-tags-rename.c @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-tags-rename.h" +#include "gl-tags.h" +#include "gl-tags-new.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-controlbar.h" +#include "gl-editfield.h" +#include "gl-button.h" +#include "gl-popup.h" +#include "gl-strings.h" + +static void __gl_tags_rename_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Delete callback when it is clicked to prevent it is called for many times */ + evas_object_smart_callback_del(obj, "clicked", + __gl_tags_rename_cancel_cb); + + _gl_tags_new_pop_view(data); +} + +static void __gl_tags_rename_done_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Delete callback when it is clicked to prevent it is called for many times */ + if (_gl_tags_rename_process(data) == 0) + evas_object_smart_callback_del(obj, "clicked", + __gl_tags_rename_done_cb); +} + +/** + * Use naviframe api to push new tag view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_tags_rename_push_view(void *data, Evas_Object *parent, + Evas_Object *obj, char *title) +{ + gl_dbg("GL_NAVI_TAGS_NEW"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + Evas_Object *done_btn = NULL; + Evas_Object *cancel_btn = NULL; + Evas_Object *end_btn = NULL; + + if (gl_get_view_mode(ad) != GL_VIEW_ALBUMS) + _gl_ctrl_show_tabbar(ad, false); + + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_tags_rename_cancel_cb, data); + GL_CHECK_VAL(end_btn, -1); + + nf_it = elm_naviframe_item_push(parent, title, end_btn, NULL, obj, + NULL); + ad->entryinfo.nf_it = nf_it; + /* Add 'Cancel' button */ + cancel_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_tags_rename_cancel_cb, data); + GL_CHECK_VAL(cancel_btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_TITLE_PREV_BTN, + cancel_btn); + /* Add 'Done' button */ + done_btn = _gl_but_create_but(parent, NULL, GL_STR_DONE, + GL_BUTTON_STYLE_NAVI_TITLE, + __gl_tags_rename_done_cb, data); + GL_CHECK_VAL(done_btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, done_btn); + ad->entryinfo.done_btn = done_btn; + + /* Add callbacks to show/hide title toolbar */ + _gl_ui_add_conform_cbs(parent); + return 0; +} + +int _gl_tags_rename_create_view(void *data, gl_tag *gtag) +{ + GL_CHECK_VAL(gtag, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Evas_Object *editfield_ly = NULL; + gl_dbg(""); + + ad->entryinfo.entry_mode = GL_ENTRY_RENAME_TAG; + + editfield_ly = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(editfield_ly, -1); + Evas_Object *entry = _gl_editfield_create(ad, editfield_ly, + gtag->tag->tag_name); + if (entry == NULL) { + gl_dbgE("Failed to add entry!"); + ad->entryinfo.entry_mode = GL_ENTRY_NONE; + evas_object_del(editfield_ly); + return -1; + } + elm_object_part_content_set(editfield_ly, "elm.swallow.view", entry); + edje_object_signal_emit(_EDJ(editfield_ly), GL_SIGNAL_VIEW_DEFAULT, + "elm"); + __gl_tags_rename_push_view(ad, ad->maininfo.naviframe, editfield_ly, + GL_STR_RENAME_TAG); + _gl_editfield_show_imf(ad); + return 0; +} + +int _gl_tags_rename_process(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_tag *gtag = ad->taginfo.current_tag; + char tname[GL_ARRAY_LEN_MAX] = { 0, }; + int ret = 0; + + if (gtag == NULL || gtag->item == NULL || gtag->tag->tag_name == NULL) { + gl_dbgE("Invalid gatag!"); + ret = -1; + goto INVALID_TAG_NAME; + } + /* Get utf8 format string */ + ret = gl_get_entry_text(ad->entryinfo.imf_entry, tname, + GL_ARRAY_LEN_MAX); + if (ret != 0) { + gl_dbgE("Get entry text failed!"); + ret = -1; + goto INVALID_TAG_NAME; + } + + /* Get valid name */ + if (_gl_get_valid_tag_name(ad, tname, false, true) != 0){ + ret = -1; + goto INVALID_TAG_NAME; + } + gl_dbg("Valid tag name: %s", tname); + + if (g_strcmp0(gtag->tag->tag_name, tname)) { + /* Check whether the new tag same as other tag */ + bool res = _gl_data_is_in_tag_list(ad, tname); + if (res) { + gl_popup_create_popup(ad, GL_POPUP_TAG_RENAME_DUPLICATE, + GL_STR_SAME_NAME_ALREADY_IN_USE); + gl_dbgW("New tag already exists!"); + ret = -1; + goto INVALID_TAG_NAME; + } + + /* Rename tag in libmedia-info */ + media_tag_set_name(gtag->tag->tag_h, tname); + media_tag_update_to_db(gtag->tag->tag_h); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Update tag to DB failed[%d]!", ret); + ret = -1; + goto INVALID_TAG_NAME; + } + gl_dbg("Rename tag %s to %s", gtag->tag->tag_name, tname); + /* Update tag name in memory */ + GL_FREEIF(gtag->tag->tag_name); + gtag->tag->tag_name = strdup(tname); + } else { + gl_dbgW("Same as current name!"); + } + + INVALID_TAG_NAME: + + if (ad->entryinfo.nf_it) { + _gl_tags_new_pop_view(ad); + ad->taginfo.current_tag = NULL; + } else { + /* Unset rename mode */ + gl_tag_unset_rename(ad); + } + _gl_editfield_destroy_imf(ad); + + return ret; +} + diff --git a/src/features/gl-tags.c b/src/features/gl-tags.c new file mode 100755 index 0000000..e1c608f --- /dev/null +++ b/src/features/gl-tags.c @@ -0,0 +1,1011 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-tags.h" +#include "gl-tags-edit.h" +#include "gl-tags-new.h" +#include "gl-tags-rename.h" +#include "gl-debug.h" +#include "gl-thumbs.h" +#include "gl-thumbs-edit.h" +#include "gl-controlbar.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-popup.h" +#include "gl-button.h" +#include "gl-data.h" +#include "gl-ext-ug-load.h" +#include "gl-ext-exec.h" +#include "gl-notify.h" +#include "gl-ctxpopup.h" +#include "gl-editfield.h" +#include "gl-strings.h" +#include "gl-icons.h" + +/* 112 -2x2 */ +#define GL_TAG_ICON_SIZE 108 + +#define GL_GENLIST_ITEM_STYLE_TAGS "tags_list" +#define GL_GENLIST_ITEM_STYLE_TAGS_EDIT "tags_list_edit" + +static char *__gl_tag_get_text(void *data, Evas_Object *obj, const char *part) +{ + GL_CHECK_NULL(obj); + GL_CHECK_NULL(part); + GL_CHECK_NULL(data); + gl_tag *gtag = (gl_tag *) data; + GL_CHECK_NULL(gtag->tag); + GL_CHECK_NULL(gtag->tag->tag_name); + char buf[GL_ARRAY_LEN_MAX] = { 0, }; + + if (!g_strcmp0(part, "elm.text.title") || + !g_strcmp0(part, "elm.slide.text.1")) { + return strdup(gtag->tag->tag_name); + } else if (!g_strcmp0(part, "elm.text.tag_count")) { + snprintf(buf, sizeof(buf), "%d", (int)(gtag->tag->count)); + return strdup(buf); + } + return NULL; +} + +static void __gl_tag_rename1_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_tag *gtag = (gl_tag *) data; + GL_CHECK(gtag->ad); + gl_appdata *ad = (gl_appdata *)gtag->ad; + gl_dbg(""); + + gl_tag_unset_rename(ad); + + if (gl_get_view_mode(ad) == GL_VIEW_TAGS) { + /* Mode item */ + Elm_Object_Item *it = NULL; + it = (Elm_Object_Item *)elm_genlist_decorated_item_get(ad->taginfo.tags_view); + /* Finish genlist sweep*/ + if (it) { + elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE); + elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT); + } + } + + if (gtag && gtag->item) { + gl_dbg("Valid tag item."); + /* Disable buttons in toolbar */ + if (gl_get_view_mode(ad) == GL_VIEW_TAGS) + _gl_ctrl_disable_btns(ad, ad->ctrlinfo.nf_it, true); + + elm_genlist_item_flip_set(gtag->item, EINA_TRUE); + /* Set current gtag for rename */ + ad->taginfo.rename_item = gtag->item; + ad->taginfo.current_tag = gtag; + } else { + gl_dbgE("Invalid tag item."); + } +} + +static void __gl_tag_rename2_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_tag *gtag = (gl_tag *)data; + GL_CHECK(gtag->ad); + gl_appdata *ad = (gl_appdata *)gtag->ad; + gl_dbg(""); + ad->taginfo.current_tag = gtag; + _gl_tags_rename_create_view(gtag->ad, gtag); +} + +static void _gl_tag_check_changed(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_tag *gtag = (gl_tag *) data; + GL_CHECK(gtag->ad); + gl_appdata *ad = (gl_appdata *)gtag->ad; + int view_mode = gl_get_view_mode(ad); + gl_dbg(""); + + if (view_mode != GL_VIEW_TAGS_EDIT) { + gl_dbg("ViewMode.%d. now return.", view_mode); + return; + } else { + gl_dbg("Edit Mode"); + } + + gl_tag_unset_rename(ad); + + int cnt = 0; + Eina_Bool checked = elm_check_state_get(obj);; + + gtag->checked = checked; + if (checked) { + gl_dbg("Append:%s", gtag->tag->tag_name); + _gl_data_tags_selected_list_append(ad, gtag); + } else { + gl_dbg("Remove:%s", gtag->tag->tag_name); + _gl_data_tags_selected_list_remove(ad, gtag); + } + + cnt = _gl_data_get_tags_selected_cnt(ad); + + /* Display selectioninfo */ + _gl_notify_create_selinfo(ad, ad->ctrlinfo.ctrlbar_edit_ly, + ad->ctrlinfo.nf_it_edit, ad->taginfo.tags_cnt, + cnt, false); +} + +static void __gl_tag_flick_left_cb(void *data, Evas_Object *obj, void *event_info) +{ + elm_object_scroll_freeze_push(obj); +} + +static void __gl_tag_flick_right_cb(void *data, Evas_Object *obj, void *event_info) +{ + elm_object_scroll_freeze_push(obj); +} + +static void __gl_tag_flick_stop_cb(void *data, Evas_Object *obj, void *event_info) +{ + elm_object_scroll_freeze_pop(obj); +} + +static void __gl_tag_set_sweep(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbg(""); + GL_CHECK(obj); + GL_CHECK(event_info); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_tag *gtag = (gl_tag *)elm_object_item_data_get(event_info); + GL_CHECK(gtag); + GL_CHECK(gtag->tag); + if (gtag->tag->_id == GL_TAG_FAVORITES_ID) { + gl_dbgW("Favourites item"); + return; + } + /* Disable sweep if in wrong view mode */ + if (gl_get_view_mode(ad) != GL_VIEW_TAGS) { + gl_dbgE("Wrong view mode!"); + return; + } + if (elm_genlist_item_flip_get(event_info)) { + gl_dbgW("In flip mode!"); + return; + } + /* Unset rename item first */ + if (ad->taginfo.rename_item) { + gl_dbg("Reset previous rename item first."); + gl_tag_unset_rename(ad); + } + /* Finish other swept item */ + Elm_Object_Item *it = NULL; + it = (Elm_Object_Item *)elm_genlist_decorated_item_get(obj); + if (it && it != event_info) { + gl_dbg("Reset previous swept item first."); + elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE); + elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT); + } + /* Start genlist sweep */ + elm_genlist_item_decorate_mode_set(event_info, "slide", EINA_TRUE); + elm_genlist_item_select_mode_set(event_info, ELM_OBJECT_SELECT_MODE_NONE); +} + +static void __gl_tag_unset_sweep(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbg(""); + GL_CHECK(obj); + GL_CHECK(event_info); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_tag *gtag = (gl_tag *)elm_object_item_data_get(event_info); + GL_CHECK(gtag); + GL_CHECK(gtag->tag); + if (gtag->tag->_id == GL_TAG_FAVORITES_ID) { + gl_dbgW("Favourites item"); + return; + } + /* Disable sweep if in wrong view mode */ + if (gl_get_view_mode(ad) != GL_VIEW_TAGS) { + gl_dbgE("Wrong view mode!"); + return; + } + if (elm_genlist_item_flip_get(event_info)) { + gl_dbgW("In flip mode!"); + return; + } + /* Finish genlist sweep */ + elm_genlist_item_decorate_mode_set(event_info, "slide", EINA_FALSE); + elm_genlist_item_select_mode_set(event_info, ELM_OBJECT_SELECT_MODE_DEFAULT); +} + +static void __gl_tag_cancel_sweep(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbg(""); + GL_CHECK(obj); + /* Get sweeped item */ + Elm_Object_Item *it = NULL; + it = (Elm_Object_Item *)elm_genlist_decorated_item_get(obj); + /* Finish genlist sweep */ + if (it) { + elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE); + elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT); + } +} + +static void __gl_tag_del_cb(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbg(""); + GL_CHECK(data); + gl_tag *gtag = (gl_tag *) data; + GL_CHECK(gtag->ad); + gl_appdata *ad = (gl_appdata *)gtag->ad; + + if (gl_get_view_mode(ad) == GL_VIEW_TAGS) { + gl_popup_create_tag_del_popup(gtag); + return; + } +} + +static Evas_Object *__gl_tag_get_content(void *data, Evas_Object *obj, const char *part) +{ + GL_CHECK_NULL(obj); + GL_CHECK_NULL(part); + GL_CHECK_NULL(data); + gl_tag *gtag = (gl_tag *) data; + GL_CHECK_NULL(gtag->tag); + GL_CHECK_NULL(gtag->tag->tag_name); + GL_CHECK_NULL(gtag->ad); + gl_appdata *ad = (gl_appdata *)gtag->ad; + //gl_dbg("[%s]", part); + //gl_dbg("gtag->tag == %p", gtag->tag); + + if (!g_strcmp0(part, "elm.swallow.checkbox")) { + Evas_Object *ck = NULL; + if (gl_get_view_mode(ad) == GL_VIEW_TAGS_EDIT) { + ck = elm_check_add(obj); + GL_CHECK_NULL(ck); + evas_object_propagate_events_set(ck, EINA_FALSE); + gtag->check_obj = ck; + elm_check_state_set(ck, gtag->checked); + + evas_object_smart_callback_add(ck, "changed", + _gl_tag_check_changed, + data); + evas_object_show(ck); + } + + return ck; + } else if (!g_strcmp0(part, "elm.icon") || !g_strcmp0(part, "elm.slide.icon")) { + /* + * _gl_tag_icon_get() will be invoked twice for each tag item while create list view. + * So return NULL to prevent duplicated setting tag cover at the first time. + * Cause it takes much time(about 200ms for tag containing 1000 items) to get data from DB. + * Only return right cover at the second time. + */ + if (gtag->cover_set == false && g_strcmp0(part, "elm.slide.icon")) { + //gl_dbg("Tag cover will be set next time."); + gtag->cover_set = true; + return NULL; + } + + char image_path[GL_FILE_PATH_LEN_MAX] = { 0, }; + gl_item *gl_tag_items[1]; + int item_count = 1; + + if (gtag->tag->_id == GL_TAG_FAVORITES_ID) { + /* + gl_tag_items[0] = NULL; + _gl_data_get_first_several_favor_items(ad, gl_tag_items, + &item_count, + MEDIA_CONTENT_ORDER_DESC); + if (gl_tag_items[0] && gl_tag_items[0]->item) { + g_strlcpy(image_path, + gl_tag_items[0]->item->thumb_url, + GL_FILE_PATH_LEN_MAX); + _gl_data_destroy_item(gl_tag_items[0]); + gl_tag_items[0] = NULL; + } else */{ + g_strlcpy(image_path, GL_TAG_FAVORITES_THUMB, + GL_FILE_PATH_LEN_MAX); + } + } else if (gtag->tag->count == 0) { + g_strlcpy(image_path, GL_DEFAULT_TAG_COVER, + GL_FILE_PATH_LEN_MAX); + } else { + gl_tag_items[0] = NULL; + _gl_data_get_first_several_tag_items(ad, + gtag->tag->_id, + gl_tag_items, + &item_count); + if (gl_tag_items[0] && gl_tag_items[0]->item) { + g_strlcpy(image_path, + gl_tag_items[0]->item->thumb_url, + GL_FILE_PATH_LEN_MAX); + _gl_data_destroy_item(gl_tag_items[0]); + gl_tag_items[0] = NULL; + } else { + g_strlcpy(image_path, GL_DEFAULT_TAG_COVER, + GL_FILE_PATH_LEN_MAX); + } + } + + Evas_Object *bg = elm_bg_add(obj); + GL_CHECK_NULL(bg); + elm_bg_load_size_set(bg, GL_TAG_ICON_SIZE, GL_TAG_ICON_SIZE); + elm_bg_file_set(bg, _GET_ICON(image_path), NULL); + evas_object_size_hint_max_set(bg, GL_TAG_ICON_SIZE, + GL_TAG_ICON_SIZE); + evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_VERTICAL, + 1, 1); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, + EVAS_HINT_FILL); + return bg; + } else if (!g_strcmp0(part, "elm.swallow.rename")) { + Evas_Object *btn = NULL; + btn = _gl_but_create_but(obj, NULL, NULL, + GL_BUTTON_STYLE_RENAME, + __gl_tag_rename1_cb, data); + GL_CHECK_NULL(btn); + evas_object_propagate_events_set(btn, EINA_FALSE); + return btn; + } else if (!g_strcmp0(part, "elm.flip.content")) { + /* This is used when the flip mode is enabled. */ + Evas_Object *edit_f = NULL; + ad->entryinfo.entry_mode = GL_ENTRY_RENAME_TAG; + edit_f = _gl_editfield_create_genlist(ad, obj, + gtag->tag->tag_name); + return edit_f; + } else if (!g_strcmp0(part, "elm.slide.swallow.1")) { + Evas_Object *rename_btn = NULL; + rename_btn = _gl_but_create_but(obj, NULL, GL_STR_RENAME, + GL_BUTTON_STYLE_SWEEP, + __gl_tag_rename2_cb, gtag); + GL_CHECK_NULL(rename_btn); + return rename_btn; + } else if (!g_strcmp0(part, "elm.slide.swallow.2")) { + Evas_Object *del_btn = NULL; + del_btn = _gl_but_create_but(obj, NULL, GL_STR_DELETE, + GL_BUTTON_STYLE_SWEEP_DELETE, + __gl_tag_del_cb, data); + GL_CHECK_NULL(del_btn); + return del_btn; + } + + return NULL; +} + +static void +_gl_tag_list_sel(void *data, Evas_Object * obj, void *event_info) +{ + gl_dbg(""); +} + +/* +* back to tags list view +*/ +static void __gl_tags_comeback_from_view_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + /* Delete callback when it is clicked to prevent it is called for many times */ + evas_object_smart_callback_del(obj, "clicked", + __gl_tags_comeback_from_view_cb); + + /* Hide title from animation */ + gl_ui_set_navi_title_visible(ad, EINA_FALSE); + + /* Change to tags view */ + _gl_tag_comeback_from_view(data); + _gl_ctrl_disable_btn(ad, false, GL_NAVI_TAGS); +} + +/* +* after tag selected, show medias of this tag. +*/ +static int +_gl_tag_show_thumbs(void *data, gl_tag * gtag) +{ + GL_CHECK_VAL(gtag, -1); + GL_CHECK_VAL(gtag->tag, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (gl_get_view_mode(ad) != GL_VIEW_TAGS) + { + gl_dbg("EditMode.. now return."); + return -1; + } + + gl_dbg("current tag %s , id=%d", gtag->tag->tag_name, gtag->tag->_id); + + if (gtag->tag->_id == GL_TAG_FAVORITES_ID) // get favorites tag + _gl_data_get_item_list(ad, GL_CATEGORY_FAVORITES, NULL, + GL_GET_ALL_RECORDS, GL_GET_UNTIL_LAST_RECORD); + else // get normal tags + _gl_data_get_item_list_tagname(ad, gtag->tag->_id, true, NULL); + + /* Set current tag */ + ad->taginfo.current_tag = gtag; + + _gl_thumbs_create_view(ad, GL_NAVI_THUMBS, gtag->tag->tag_name, false, + __gl_tags_comeback_from_view_cb); + gl_dbg("done _gl_tag_show_thumbs"); + return 0; +} + +/* +* 1. Edit view mode, check checkbox if selected; +* 2. Normal view moce, show thumbnails view of selected tag. +*/ +static void _gl_tag_sel(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_tag *gtag = (gl_tag *) data; + GL_CHECK(gtag->ad); + gl_appdata *ad = (gl_appdata *)gtag->ad; + gl_dbg(""); + + Elm_Object_Item *gen_item = elm_genlist_selected_item_get(obj); + GL_CHECK(gen_item); + elm_genlist_item_selected_set(gen_item, EINA_FALSE); + if (elm_genlist_item_flip_get(gen_item)) + return; + if (ad->taginfo.rename_item) { + gl_tag_unset_rename(ad); + return; + } + + int cnt = 0; + int view_mode = gl_get_view_mode(ad); + gl_dbg("tag %s selected...", gtag->tag->tag_name); + + if (view_mode == GL_VIEW_TAGS_EDIT) { + gtag->checked = !gtag->checked; + elm_check_state_set(gtag->check_obj, gtag->checked); + + if (gtag->checked) { + gl_dbg("Append"); + _gl_data_tags_selected_list_append(ad, gtag); + } else { + gl_dbg("Remove"); + _gl_data_tags_selected_list_remove(ad, gtag); + } + + cnt = _gl_data_get_tags_selected_cnt(ad); + /* Display selectioninfo */ + _gl_notify_create_selinfo(ad, ad->ctrlinfo.ctrlbar_edit_ly, + ad->ctrlinfo.nf_it_edit, + ad->taginfo.tags_cnt, cnt, false); + } else { + _gl_tag_show_thumbs(ad, gtag); + } +} + +// _gl_tag_list_drag_cb is called when the item is dragged +static void +_gl_tag_list_drag_cb(void *data, Evas_Object * obj, void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + + gl_tag_unset_rename(ad); +} + +static void _gl_tag_update_view(void *data, Evas_Object * obj, void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *genlist = obj; + int item_cnt = 0; + Eina_List *tag_elist = NULL; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d.", view_mode); + + elm_genlist_clear(genlist); + + if (view_mode == GL_VIEW_TAGS) { + ad->taginfo.taglic.item_style = GL_GENLIST_ITEM_STYLE_TAGS; + _gl_data_get_tag_list(ad, &tag_elist); + } else { + ad->taginfo.taglic.item_style = GL_GENLIST_ITEM_STYLE_TAGS_EDIT; + tag_elist = ad->taginfo.tags_elist; + } + + if (tag_elist == NULL) { + gl_dbgE("Invalid tag_elist!"); + } + + Eina_List *tmp_elist = NULL; + gl_tag *gtag = NULL; + Elm_Genlist_Item_Class *plic = NULL; + EINA_LIST_FOREACH(tag_elist, tmp_elist, gtag) { + if (gtag == NULL || gtag->tag == NULL) { + gl_dbgE("Invalid gtag!"); + continue; + } + + if (view_mode == GL_VIEW_TAGS_EDIT && + gtag->tag->_id == GL_TAG_FAVORITES_ID) { + gl_dbg("Favorites tag, skipping in edit mode"); + continue; + } else if (view_mode == GL_VIEW_TAGS_EDIT || + gtag->tag->_id == GL_TAG_FAVORITES_ID) { + plic = &(ad->taginfo.taglic); + } else { + plic = &(ad->taginfo.sweeplic); + } + + gl_dbg("===Append tag [%s]", gtag->tag->tag_name); + gtag->item = elm_genlist_item_append(genlist, plic, + (void *)gtag, NULL, + ELM_GENLIST_ITEM_NONE, + _gl_tag_sel, gtag); + item_cnt++; + } + + ad->taginfo.tags_cnt = item_cnt; + evas_object_smart_callback_add(genlist, "selected", _gl_tag_list_sel, + NULL); +} + +static int __gl_tags_reset_view(void *data, bool is_tag) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(data); + gl_dbg("view_mode: %d", view_mode); + + /* Change to Tags view first */ + if (view_mode != GL_VIEW_TAGS && view_mode != GL_VIEW_TAGS_EDIT) { + gl_destroy_thumbs_view(data); + _gl_tag_comeback_from_view(data); + } else if (view_mode == GL_VIEW_TAGS && + ad->entryinfo.entry_mode == GL_ENTRY_NEW_TAG) { + gl_del_invalid_widgets(data, GL_INVALID_NEW_ENTRY); + } else if (view_mode == GL_VIEW_TAGS_EDIT) { + /* is_tag is false, clear edit would be done in view_change_cb of tabbar */ + if (is_tag) + _gl_tags_edit_pop_view(data); + } + + return 0; +} + +static void __gl_tags_edit_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->uginfo.ug_called_by_me || ad->gridinfo.grid_append_idler) { + /** + * Prevent changed to edit view in wrong way. + * 1. When invoke imageviewer UG; + * 2. First show thumbnails view, use idler to append other medias. + */ + gl_dbgW("UG invoked!"); + return; + } + _gl_ctxpopup_del(data); + + int view_mode = gl_get_view_mode(data); + gl_dbg("mode: %d", view_mode); + if (view_mode == GL_VIEW_TAGS) + _gl_tags_edit_create_view(data); + else + gl_dbgE("Wrong view mode!"); +} + +/* +* In tags list view, when tap "add tag button" in title bar, show UI for adding tag. +* Add a new tag to tags list. +*/ +static void _gl_tags_create_tag_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_dbg(""); + _gl_ctxpopup_del(data); + _gl_tags_new_create_view(data); +} + +static int __gl_tags_ctxpopup_append(void *data, Evas_Object *parent) +{ + gl_dbg(""); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Show edit item */ + if (!ad->taginfo.b_edit_disable) + elm_ctxpopup_item_append(parent, GL_STR_EDIT, NULL, + __gl_tags_edit_cb, data); + elm_ctxpopup_item_append(parent, GL_STR_CREATE_TAG, NULL, + _gl_tags_create_tag_cb, data); + return 0; +} + +static void __gl_tags_more_cb(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbg("more button clicked"); + /* Add 'Edit' + 'Create tag' */ + GL_CHECK(data); + _gl_ctxpopup_create(data, obj, __gl_tags_ctxpopup_append); +} + +/** + * Launch camera + */ +static void __gl_tags_camera_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_dbg(""); + _gl_ext_load_camera(); +} + +int _gl_tags_add_btns(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + GL_CHECK_VAL(ad->ctrlinfo.nf_it, -1); + Evas_Object *parent = ad->maininfo.naviframe; + Elm_Object_Item *nf_it = ad->ctrlinfo.nf_it; + Evas_Object *btn = NULL; + + /* Remove btns */ + _gl_ui_clear_btns(data); + + /* More */ + btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_MORE, + __gl_tags_more_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_MORE, btn); + /* not only favorites tag */ + if (_gl_data_get_tag_count_all(ad) > 1) + ad->taginfo.b_edit_disable = false; + else + ad->taginfo.b_edit_disable = true; + /* Camera */ + btn = _gl_but_create_but(parent, NULL, GL_STR_CAMERA, + GL_BUTTON_STYLE_NAVI_TOOLBAR, + __gl_tags_camera_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, btn); + return 0; +} + +/* Unset rename mode if any item is in rename mode */ +int gl_tag_unset_rename(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + _gl_editfield_destroy_imf(ad); + + /* Enable buttons in toolbar */ + if (gl_get_view_mode(ad) == GL_VIEW_TAGS) + _gl_ctrl_disable_btns(ad, ad->ctrlinfo.nf_it, false); + + if (ad->taginfo.rename_item) + elm_genlist_item_flip_set(ad->taginfo.rename_item, EINA_FALSE); + + ad->taginfo.rename_item = NULL; + /* Set current gtag NULL for rename */ + ad->taginfo.current_tag = NULL; + + return 0; +} + +Evas_Object *gl_tag_create_view(void *data, Evas_Object *parent) +{ + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *genlist = NULL; + int item_cnt = 0; + int view_mode = gl_get_view_mode(ad); + gl_dbg(""); + + ad->taginfo.rename_item = NULL; + /* Set current gtag NULL for rename */ + ad->taginfo.current_tag = NULL; + + if (view_mode == GL_VIEW_TAGS_EDIT) { + ad->taginfo.taglic.item_style = GL_GENLIST_ITEM_STYLE_TAGS_EDIT; + } else { + ad->taginfo.taglic.item_style = GL_GENLIST_ITEM_STYLE_TAGS; + /* Sweep class */ + ad->taginfo.sweeplic.item_style = GL_GENLIST_ITEM_STYLE_TAGS; + ad->taginfo.sweeplic.decorate_item_style = GL_GENLIST_ITEM_STYLE_SWEEP2_TAG; + ad->taginfo.sweeplic.func.text_get = __gl_tag_get_text; + ad->taginfo.sweeplic.func.content_get = __gl_tag_get_content; + } + ad->taginfo.taglic.decorate_item_style = NULL; + ad->taginfo.taglic.decorate_all_item_style = NULL; + ad->taginfo.taglic.func.text_get = __gl_tag_get_text; + ad->taginfo.taglic.func.content_get = __gl_tag_get_content; + genlist = elm_genlist_add(parent); + elm_object_style_set(genlist, GL_GENLIST_STYLE_DEFAULT); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + + Eina_List *tag_elist = NULL; + _gl_data_get_tag_list(ad, &tag_elist); + GL_CHECK_NULL(tag_elist); + + Eina_List *tmp_elist = NULL; + gl_tag *gtag = NULL; + Elm_Genlist_Item_Class *plic = NULL; + EINA_LIST_FOREACH(tag_elist, tmp_elist, gtag) { + if (!gtag || !gtag->tag) { + gl_dbgE("Invalid tag!"); + continue; + } + + if (view_mode == GL_VIEW_TAGS_EDIT && + gtag->tag->_id == GL_TAG_FAVORITES_ID) { + gl_dbg("Favorites tag, skipping in edit mode"); + continue; + } else if (view_mode == GL_VIEW_TAGS_EDIT || + gtag->tag->_id == GL_TAG_FAVORITES_ID) { + plic = &(ad->taginfo.taglic); + } else { + plic = &(ad->taginfo.sweeplic); + } + + gl_dbg("===Append tag [%s]", gtag->tag->tag_name); + gtag->item = elm_genlist_item_append(genlist, plic, + (void *)gtag, NULL, + ELM_GENLIST_ITEM_NONE, + _gl_tag_sel, gtag); + item_cnt++; + } + + ad->taginfo.tags_cnt = item_cnt; + if (view_mode == GL_VIEW_TAGS_EDIT) { + evas_object_smart_callback_add(genlist, "drag,start,up", + _gl_tag_list_drag_cb, ad); + evas_object_smart_callback_add(genlist, "drag,start,down", + _gl_tag_list_drag_cb, ad); + } else { + /* Stop flicking(up/down direction) when sweep list item*/ + evas_object_smart_callback_add(genlist, "drag,start,left", + __gl_tag_flick_left_cb, ad); + evas_object_smart_callback_add(genlist, "drag,start,right", + __gl_tag_flick_right_cb, ad); + evas_object_smart_callback_add(genlist, "drag,stop", + __gl_tag_flick_stop_cb, ad); + /* Add callback for sweeping */ + evas_object_smart_callback_add(genlist, "drag,start,right", + __gl_tag_set_sweep, ad); + evas_object_smart_callback_add(genlist, "drag,start,left", + __gl_tag_unset_sweep, ad); + evas_object_smart_callback_add(genlist, "drag,start,up", + __gl_tag_cancel_sweep, ad); + evas_object_smart_callback_add(genlist, "drag,start,down", + __gl_tag_cancel_sweep, ad); + } + + if (item_cnt > 0) + evas_object_smart_callback_add(genlist, "selected", + _gl_tag_list_sel, NULL); + else + gl_dbgE("Favorites tag would be displayed at least!"); + + return genlist; +} + +int gl_tag_update_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + Evas_Object *view_obj = NULL; + gl_dbg("view_mode: %d.", view_mode); + + if (view_mode == GL_VIEW_TAGS) { + GL_CHECK_VAL(ad->taginfo.tags_view, -1); + view_obj = ad->taginfo.tags_view; + } else if (view_mode == GL_VIEW_TAGS_EDIT) { + GL_CHECK_VAL(ad->ctrlinfo.ctrlbar_edit_view, -1); + view_obj = ad->ctrlinfo.ctrlbar_edit_view; + } + + _gl_tag_update_view(ad, view_obj, NULL); + + return 0; +} + +/* Update all realized items */ +int gl_tag_update_realized_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + Evas_Object *view_obj = NULL; + const Elm_Object_Item *mode_it = NULL; + gl_dbg("view_mode: %d.", view_mode); + + if (view_mode == GL_VIEW_TAGS) { + GL_CHECK_VAL(ad->taginfo.tags_view, -1); + view_obj = ad->taginfo.tags_view; + mode_it = elm_genlist_decorated_item_get(view_obj); + } else if (view_mode == GL_VIEW_TAGS_EDIT) { + GL_CHECK_VAL(ad->ctrlinfo.ctrlbar_edit_view, -1); + view_obj = ad->ctrlinfo.ctrlbar_edit_view; + } + + Eina_List *list = NULL; + Eina_List *l = NULL; + Elm_Object_Item *it = NULL; + list = elm_genlist_realized_items_get(view_obj); + EINA_LIST_FOREACH(list, l, it) { + if (elm_genlist_item_flip_get(it)) { + gl_dbg("Flip item."); + continue; + } else if (mode_it && mode_it == it) { + gl_dbg("Sweep item."); + continue; + } + elm_genlist_item_update(it); + } + + return 0; +} + +/* +* back to tags list view +*/ +int _gl_tag_comeback_from_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + gl_ctrl_rotate_ctrlbar(ad, GL_VIEW_TAGS); + gl_set_view_mode(ad, GL_VIEW_TAGS); + ad->taginfo.current_tag = NULL; + gl_tag_update_view(ad); + + _gl_thumbs_delete_view(ad); + gl_dbg("done"); + return 0; +} + +bool _gl_tags_sel_home_tag(void *data, const char *tag_id) +{ + GL_CHECK_FALSE(data); + gl_tag *gtag = NULL; + gl_dbg(""); + + if (tag_id == NULL) { + gl_dbgE("Invalid parameters!"); + goto GL_TAGS_FAILED; + } + + /* Find selected tag */ + _gl_data_get_tag_by_id(data, atoi(tag_id), >ag); + if (gtag == NULL || gtag->tag == NULL || gtag->tag->tag_name == NULL) { + gl_dbgE("Tag doesn't exit!"); + goto GL_TAGS_FAILED; + } + _gl_tag_show_thumbs(data, gtag); + + return true; + + GL_TAGS_FAILED: + + gl_popup_create_popup(data, GL_POPUP_NOBUT_APPEXIT, + GL_STR_NO_TAGS); + /* Update tags view */ + gl_tag_update_view(data); + + return false; +} + +int _gl_tags_reset_view(void *data, const char *tag_id, const char *aul_type) +{ + GL_CHECK_VAL(aul_type, -1); + GL_CHECK_VAL(tag_id, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (!g_strcmp0(aul_type, GL_AUL_TAG)) { + gl_tag *gtag = ad->taginfo.current_tag; + if (gtag && gtag->tag && (gtag->tag->_id == atoi(tag_id))) { + gl_dbg("Current tag, update view"); + int view_mode = gl_get_view_mode(data); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + gl_del_invalid_widgets(data, GL_INVALID_NONE); + _gl_thumbs_edit_pop_view(data); + } else { + gl_update_view(data, GL_UPDATE_VIEW_NORMAL); + } + return -1; + } + + __gl_tags_reset_view(data, true); + } else { + __gl_tags_reset_view(data, false); + + _gl_ctrl_sel_tabbar_item(data, aul_type); + } + + return 0; +} + +const char *_gl_tags_get_current_tag_name(void *data) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_FALSE(ad->taginfo.current_tag); + GL_CHECK_FALSE(ad->taginfo.current_tag->tag); + GL_CHECK_FALSE(ad->taginfo.current_tag->tag->tag_name); + + return ad->taginfo.current_tag->tag->tag_name; +} + +/* Delete one tag item in normal view */ +int _gl_tags_del(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_tag *gtag = (gl_tag *)data; + GL_CHECK_VAL(gtag->ad, -1); + gl_appdata *ad = (gl_appdata *)gtag->ad; + GL_CHECK_VAL(ad->taginfo.tags_view, -1); + gl_dbg(""); + + /* Mode item */ + Elm_Object_Item *it = NULL; + it = (Elm_Object_Item *)elm_genlist_decorated_item_get(ad->taginfo.tags_view); + /* Finish genlist sweep*/ + if (it) { + elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE); + elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_ALWAYS); + } + + GL_CHECK_VAL(gtag->item, -1); + elm_object_item_del(gtag->item); + /* Remove tag from list, destroy it and remove its record from DB */ + _gl_data_tags_list_remove(ad, gtag); + /* Disable edit item if only 'favourites' item exits */ + if (_gl_data_get_tag_count_all(ad) <= 1) { + _gl_ctrl_disable_btn(ad, true, GL_NAVI_TAGS); + } + /* Add notification */ + _gl_notify_create_notiinfo(ad, GL_STR_DELETED); + return 0; +} + +int _gl_tags_update_lang(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_tag_update_view(ad); + GL_CHECK_VAL(ad->ctrlinfo.nf_it, -1); + _gl_ui_set_btns_text(ad->ctrlinfo.nf_it, GL_STR_CAMERA, NULL); + return 0; +} + diff --git a/src/features/gl-thumbs-edit.c b/src/features/gl-thumbs-edit.c new file mode 100755 index 0000000..d7b9833 --- /dev/null +++ b/src/features/gl-thumbs-edit.c @@ -0,0 +1,488 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-thumbs-edit.h" +#include "gl-thumbs.h" +#include "gl-debug.h" +#include "gl-strings.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-data.h" +#include "gl-icons.h" +#include "gl-controlbar.h" +#include "gl-ctxpopup.h" +#include "gl-button.h" +#include "gl-notify.h" +#include "gl-popup.h" +#include "gl-lang.h" +#include "gl-ext-exec.h" +#include "gl-ext-ug-load.h" +#include "gl-fs.h" + +static void __gl_thumbs_edit_trans_finished_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbgW("view_mode: %d", view_mode); + evas_object_smart_callback_del(obj, GL_TRANS_FINISHED, + __gl_thumbs_edit_trans_finished_cb); + + /* Clear previous view after animation finished */ + if (view_mode == GL_VIEW_THUMBS_EDIT) { + if (ad->entryinfo.entry_mode != GL_ENTRY_NONE) + return; + elm_gengrid_clear(ad->gridinfo.all_grid_view); + } else { + gl_dbgE("Wrong view mode!"); + } +} + +/* callback after user tap Cancel button in option header in edit view */ +static void __gl_thumbs_edit_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + GL_CHECK(obj); + gl_dbg(""); + /* Disable item when it is clicked to prevent it is called for many times */ + if (_gl_thumbs_edit_pop_view(data) == 0) + _gl_ui_disable_btn(obj); +} + +static void __gl_thumbs_edit_share_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me) { + gl_dbgW("UG or APP is already loaded!"); + return; + } + + int view_mode = gl_get_view_mode(ad); + int cnt = 0; + if (view_mode == GL_VIEW_THUMBS_EDIT) { + cnt = _gl_data_selected_list_count(ad); + if (cnt == 0) { + gl_dbg("No thumbs selected, return!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return; + } + } else { + gl_dbgE("Unknow mode!"); + return; + } + + _gl_ctxpopup_create_share(data, obj); +} + +static void __gl_thumbs_edit_addtag_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me) { + gl_dbgW("UG or APP is already loaded!"); + return; + } + _gl_ctxpopup_del(data); + + int view_mode = gl_get_view_mode(ad); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + if (_gl_data_selected_list_count(ad) == 0) { + gl_dbg("No thumbs selected, return!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return; + } + } else { + gl_dbgW("Unknow mode!"); + return; + } + + _gl_ctxpopup_create_addtag(ad); +} + +/* move media to album in edit view */ +static void __gl_thumbs_edit_move_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + _gl_ctxpopup_del(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(data); + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me) { + gl_dbgW("UG or APP is already loaded!"); + return; + } + + if (view_mode == GL_VIEW_THUMBS_EDIT) { + if (_gl_data_selected_list_count(data) == 0) { + gl_dbgW("No thumbs selected!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return; + } + + _gl_ctxpopup_create_move(data); + } else { + gl_dbgE("Unknow mode!"); + } +} + +#ifdef _USE_ROTATE_BG +static void __gl_thumbs_edit_rotate_left_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + if (_gl_data_selected_list_count(data) == 0) { + gl_dbgW("No thumbs selected!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return; + } + _gl_ctxpopup_del(data); + _gl_rotate_images(data, true); +} + +static void __gl_thumbs_edit_rotate_right_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + if (_gl_data_selected_list_count(data) == 0) { + gl_dbgW("No thumbs selected!"); + gl_popup_create_popup(data, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return; + } + _gl_ctxpopup_del(data); + _gl_rotate_images(data, false); +} +#endif + +static int __gl_thumbs_edit_ctxpopup_append(void *data, Evas_Object *parent) +{ + gl_dbg(""); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->ctrlinfo.tab_mode != GL_CTRL_TAB_TAGS) { + elm_ctxpopup_item_append(parent, GL_STR_ADD_TAG, NULL, + __gl_thumbs_edit_addtag_cb, data); + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_ALBUMS) + elm_ctxpopup_item_append(parent, GL_STR_MOVE, NULL, + __gl_thumbs_edit_move_cb, + data); + } + + if (!ad->gridinfo.b_slideshow_disable) + elm_ctxpopup_item_append(parent, GL_STR_SLIDESHOW, NULL, + _gl_ui_slideshow_cb, data); + +#ifdef _USE_ROTATE_BG + if (ad->gridinfo.view_mode != GL_THUMB_VIDEOS) { + int share_m = gl_get_share_mode(ad); + if (share_m == GL_SHARE_IMAGE_ONE_JPEG || + share_m == GL_SHARE_IMAGE_MULTI_JPEG) { + gl_dbg("Enable more button"); + elm_ctxpopup_item_append(parent, GL_STR_ROTATE_LEFT, + NULL, + __gl_thumbs_edit_rotate_left_cb, + data); + elm_ctxpopup_item_append(parent, GL_STR_ROTATE_RIGHT, + NULL, + __gl_thumbs_edit_rotate_right_cb, + data); + } + } +#endif + return 0; +} + +static void __gl_thumbs_edit_more_cb(void *data, Evas_Object *obj, + void *event_info) +{ + gl_dbg("more button clicked"); + /* Add items */ + GL_CHECK(data); + _gl_ctxpopup_create(data, obj, __gl_thumbs_edit_ctxpopup_append); +} + +static void __gl_thumbs_edit_del_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me) { + gl_dbgW("UG or APP is already loaded!"); + return; + } + + int view_mode = gl_get_view_mode(ad); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + int cnt = _gl_data_selected_list_count(ad); + if (cnt == 0) + { + gl_dbgW("No thumbs selected!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, GL_STR_NO_FILES_SELECTED); + return; + } + + gl_del_medias(ad); + } else { + gl_dbgW("Unknow mode!"); + } +} + +static void __gl_thumbs_edit_remove_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me) { + gl_dbgW("UG or APP is already loaded!"); + return; + } + + if (_gl_data_selected_list_count(ad) == 0) { + gl_dbgW("No thumbs selected!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return; + } + + int view_mode = gl_get_view_mode(ad); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) + gl_remove_tag_items(data); + } else { + gl_dbgE("Unkonw mode!"); + } +} + +/** + * Use naviframe api to push thumbnails eidt view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_thumbs_edit_push_view(void *data, Evas_Object *parent, + Evas_Object *obj, char *title) +{ + gl_dbg("GL_NAVI_THUMBS_EDIT"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + + /* Add transition finished callback */ + evas_object_smart_callback_add(parent, GL_TRANS_FINISHED, + __gl_thumbs_edit_trans_finished_cb, + data); + Evas_Object *end_btn = NULL; + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_thumbs_edit_cancel_cb, data); + GL_CHECK_VAL(end_btn, -1); + /* Push to stack */ + nf_it = elm_naviframe_item_push(parent, title, end_btn, NULL, obj, NULL); + ad->gridinfo.nf_it_edit = nf_it; + + return _gl_thumbs_edit_add_btns(data, parent, nf_it); +} + +int _gl_thumbs_edit_add_btns(void *data, Evas_Object *parent, + Elm_Object_Item *nf_it) +{ + GL_CHECK_VAL(nf_it, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *btn = NULL; + + /* Remove slideshow button */ + _gl_ui_disable_slideshow(ad, true); + + /* More */ + btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_MORE, + __gl_thumbs_edit_more_cb, + data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, + GL_NAVIFRAME_MORE, + btn); + _gl_ui_disable_btn(btn); + /* Delete */ + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_ALBUMS) + btn = _gl_but_create_but(parent, NULL, GL_STR_DELETE, + GL_BUTTON_STYLE_NAVI_TOOLBAR_RIGHT, + __gl_thumbs_edit_del_cb, data); + else /* Remove */ + btn = _gl_but_create_but(parent, NULL, GL_STR_REMOVE, + GL_BUTTON_STYLE_NAVI_TOOLBAR_RIGHT, + __gl_thumbs_edit_remove_cb, + data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN2, btn); + _gl_ui_disable_btn(btn); + /* Share */ + btn = _gl_but_create_but(parent, NULL, GL_STR_SHARE, + GL_BUTTON_STYLE_NAVI_TOOLBAR_LEFT, + __gl_thumbs_edit_share_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, btn); + _gl_ui_disable_btn(btn); + + return 0; +} + +int _gl_thumbs_edit_create_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + if (ad->uginfo.ug_called_by_me || ad->gridinfo.grid_append_idler) { + /** + * Prevent changed to edit view in wrong way. + * 1. When invoke imageviewer UG; + * 2. First show thumbnails view, use idler to append other medias. + */ + gl_dbg("UG invoked or appending gridview."); + return -1; + } + _gl_ctxpopup_del(data); + + int view_mode = gl_get_view_mode(data); + gl_dbg("mode: %d", view_mode); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + /* Fixme: maybe we should disable edit button until grid append idler is done */ + /** + * Happen in quickly tap edit button, + * it will invoke edit_cb several time + * and push some unuseful views. + */ + gl_dbg("Already in edit mode, return."); + return -1; + } + + Evas_Object *layout = NULL; + layout = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(layout, -1); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + ad->gridinfo.navi_content_edit_ly = layout; + + Evas_Object *view = NULL; + + gl_set_view_mode(ad, GL_VIEW_THUMBS_EDIT); + if (ad->gridinfo.view_mode == GL_THUMB_ALL) + view = _gl_thumbs_add_grid(ad, layout, GL_THUMB_ALL, + false); + else if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS) + view = _gl_thumbs_add_grid(ad, layout, GL_THUMB_VIDEOS, + false); + else + view = _gl_thumbs_add_grid(ad, layout, GL_THUMB_IMAGES, + false); + + if (view == NULL) { + gl_dbgE("View creation failed!"); + evas_object_del(layout); + ad->gridinfo.navi_content_edit_ly = NULL; + return -1; + } + + ad->gridinfo.navi_content_edit_view = view; + + elm_object_part_content_set(layout, "elm.swallow.view", view); + __gl_thumbs_edit_push_view(ad, ad->maininfo.naviframe, layout, + GL_STR_SELECT_ITEM); + edje_object_signal_emit(_EDJ(layout), GL_SIGNAL_VIEW_EDIT, "elm"); + gl_ui_show_selall(ad); + gl_dbg("Done"); + return 0; +} + +int _gl_thumbs_edit_pop_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + elm_naviframe_item_pop_to(ad->gridinfo.nf_it); + + _gl_destroy_thumbs_edit_view(data); + _gl_data_selected_list_finalize(data); + + gl_set_view_mode(data, GL_VIEW_THUMBS); + + if (ad->albuminfo.update_albums_list) { + /* + * Update albums list if MMC added/removed, + * or save web files to local album. + */ + ad->albuminfo.update_albums_list = false; + gl_refresh_albums_list(data); + } + + _gl_thumbs_show_view(data); + _gl_notify_destroy_selinfo(data); + return 0; +} + +int _gl_thumbs_edit_update_lang(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->gridinfo.nf_it_edit, -1); + + elm_object_item_text_set(ad->gridinfo.nf_it_edit, GL_STR_SELECT_ITEM); + + int cnt = _gl_data_selected_list_count(ad); + _gl_notify_update_lang(ad, cnt, GL_VIEW_THUMBS_EDIT); + + if (ad->popupinfo.popup){ + if (ad->popupinfo.popup_mode == GL_POPUP_NOBUT) + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + } + + if (ad->entryinfo.nf_it) { + if (GL_ENTRY_NEW_ALBUM == ad->entryinfo.entry_mode) + elm_object_item_text_set(ad->entryinfo.nf_it, + GL_STR_CREATE_ALBUM); + else if (GL_ENTRY_NEW_TAG == ad->entryinfo.entry_mode) + elm_object_item_text_set(ad->entryinfo.nf_it, + GL_STR_CREATE_TAG); + } + + _gl_lang_update_thumb_edit_button(ad, ad->gridinfo.nf_it_edit); + return 0; +} + diff --git a/src/features/gl-thumbs-sel.c b/src/features/gl-thumbs-sel.c new file mode 100755 index 0000000..13b126c --- /dev/null +++ b/src/features/gl-thumbs-sel.c @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-thumbs-sel.h" +#include "gl-albums-sel.h" +#include "gl-tags.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-data.h" +#include "gl-controlbar.h" +#include "gl-button.h" +#include "gl-nocontents.h" +#include "gl-popup.h" +#include "gl-notify.h" +#include "gl-strings.h" +#include "gl-thumbs.h" + +static void __gl_thumbs_sel_trans_finished_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbgW("view_mode: %d", view_mode); + evas_object_smart_callback_del(obj, GL_TRANS_FINISHED, + __gl_thumbs_sel_trans_finished_cb); + + /* Clear previous view after animation finished */ + if (view_mode == GL_VIEW_THUMBS_SELECT) + elm_gengrid_clear(ad->albuminfo.select_view); + else + gl_dbgE("Wrong view mode!"); +} + +static void __gl_thumbs_sel_cancel_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_dbg(""); + /* Disable item when it is clicked to prevent it is called for many times */ + if (_gl_thumbs_sel_pop_view(data) == 0) + _gl_ui_disable_btn(obj); +} + +static void __gl_thumbs_sel_done_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + + /* Disable item when it is clicked to prevent it is called for many times */ + _gl_ui_disable_btn(obj); + + ad->albuminfo.current_album = NULL; + + GL_CHECK(ad->taginfo.current_tag); + gl_add_tag(data, ad->taginfo.current_tag); +} + +/** + * Use naviframe api to push thumbnails eidt view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_thumbs_sel_push_view(void *data, Evas_Object *parent, + Evas_Object *obj, char *title) +{ + gl_dbg("GL_NAVI_THUMBS_SELECT"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + + /* Add transition finished callback */ + evas_object_smart_callback_add(parent, GL_TRANS_FINISHED, + __gl_thumbs_sel_trans_finished_cb, data); + Evas_Object *end_btn = NULL; + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_thumbs_sel_cancel_cb, data); + GL_CHECK_VAL(end_btn, -1); + /* Push to stack */ + nf_it = elm_naviframe_item_push(parent, title, end_btn, NULL, obj, + NULL); + ad->gridinfo.nf_it_select = nf_it; + + /* Done */ + Evas_Object *btn = NULL; + btn = _gl_but_create_but(parent, NULL, GL_STR_DONE, + GL_BUTTON_STYLE_NAVI_TOOLBAR, + __gl_thumbs_sel_done_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, btn); + _gl_ui_disable_btn(btn); + return 0; +} + +/** + * Album selected for adding tags to photo + */ +int _gl_thumbs_sel_create_view(void *data, gl_cluster *album_item) +{ + GL_CHECK_VAL(album_item, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Get items list without current tag */ + _gl_data_get_item_list_without_tag(data, album_item, + _gl_tags_get_current_tag_name(ad), + GL_GET_ALL_RECORDS, + GL_GET_ALL_RECORDS); + + if (ad->maininfo.medias_cnt <= 0) { + gl_dbgW("All medias are tagged!"); + /* Add notification */ + _gl_notify_create_notiinfo(data, GL_STR_ADDED); + return -1; + } + + Evas_Object *layout = NULL; + /* Add layout */ + layout = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(layout, -1); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + /* Save view mode */ + int pre_view_m = gl_get_view_mode(data); + /* Set new view mode */ + gl_set_view_mode(data, GL_VIEW_THUMBS_SELECT); + /* Save grid view mode */ + int gridview_m = ad->gridinfo.view_mode; + /* Add view */ + Evas_Object *view = NULL; + view = _gl_thumbs_add_grid(data, layout, GL_THUMB_ALL, false); + /* Restore grid view mode */ + if (gridview_m != GL_THUMB_ALL) + ad->gridinfo.view_mode = gridview_m; + if (view == NULL) { + evas_object_del(layout); + gl_popup_create_popup(data, GL_POPUP_NOBUT, GL_STR_NO_ALBUMS); + /* Reset view mode */ + gl_set_view_mode(data, pre_view_m); + return -1; + } + + /* Set view to layout */ + elm_object_part_content_set(layout, "elm.swallow.view", view); + /* Push view to naviframe */ + __gl_thumbs_sel_push_view(data, ad->maininfo.naviframe, layout, + GL_STR_SELECT_ITEM); + edje_object_signal_emit(_EDJ(layout), GL_SIGNAL_VIEW_EDIT, "elm"); + ad->gridinfo.select_view = view; + ad->gridinfo.select_view_ly = layout; + + ad->albuminfo.current_album = album_item; + + /* Show select all widget */ + gl_ui_show_selall(ad); + gl_dbg("Done"); + return 0; +} + +int _gl_thumbs_sel_pop_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + ad->albuminfo.current_album = NULL; + /* Clear selected list */ + _gl_data_selected_list_finalize(data); + _gl_thumbs_clear_cbs(ad->gridinfo.select_view); + ad->gridinfo.select_view= NULL; + ad->gridinfo.select_view_ly= NULL; + /* Pop naviframe item*/ + elm_naviframe_item_pop(ad->maininfo.naviframe); + /* Reset view mode */ + gl_set_view_mode(data, GL_VIEW_ALBUMS_SELECT); + /* Update view */ + _gl_albums_sel_update_view(data); + return 0; +} + +int _gl_thumbs_sel_update_lang(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->gridinfo.nf_it_select, -1); + gl_dbg(""); + elm_object_item_text_set(ad->gridinfo.nf_it_select, + GL_STR_SELECT_ITEM); + int sel_cnt = _gl_data_selected_list_count(ad); + _gl_notify_update_lang(ad, sel_cnt, GL_VIEW_THUMBS_SELECT); + _gl_ui_set_btns_text(ad->gridinfo.nf_it_select, GL_STR_DONE, NULL); + return 0; +} + diff --git a/src/features/gl-thumbs.c b/src/features/gl-thumbs.c new file mode 100755 index 0000000..c0052a5 --- /dev/null +++ b/src/features/gl-thumbs.c @@ -0,0 +1,909 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-thumbs.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-drm.h" +#include "gl-albums.h" +#include "gl-data.h" +#include "gl-ext-ug-load.h" +#include "gl-ext-exec.h" +#include "gl-controlbar.h" +#include "gl-nocontents.h" +#include "gl-notify.h" +#include "gl-strings.h" +#include "gl-icons.h" +#include "gl-thumb.h" +#ifdef _USE_ROTATE_BG +#include "gl-exif.h" +#endif + +/* Icon swallowed to part "elm.swallow.icon" */ +#define GL_GRID_TOUCH_RANGE 20 +typedef struct _gl_thumb_data_t gl_thumb_data_s; + +struct _gl_thumb_data_t{ + void *ad; + gl_item *item; +}; + +static void __gl_thumbs_open_file(void *data) +{ + gl_dbg(""); + GL_CHECK(data); + gl_item *gitem = (gl_item *)data; + GL_CHECK(gitem->item); + GL_CHECK(gitem->item->file_url); + GL_CHECK(strlen(gitem->item->file_url)); + GL_CHECK(gitem->ad); + gl_appdata *ad = (gl_appdata *)gitem->ad; + int view_mode = gl_get_view_mode(ad); + if (view_mode != GL_VIEW_THUMBS) { + gl_dbgE("Error view mode!"); + return; + } + + if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS) { + gl_dbg("Loading VIDEO-PLAYER"); + gl_ext_exec(gitem, GL_APP_VIDEOPLAYER); + } else { + gl_dbg("Loading UG-IMAGE(VIDEO)-VIEWER"); + gl_ext_load_iv_ug(ad, gitem, GL_UG_IV); + } +} + +static void __gl_thumbs_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + __gl_thumbs_open_file(data); +} + +static void __gl_thumbs_longpressed(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(event_info); + void *it_data = elm_object_item_data_get(event_info); + GL_CHECK(it_data); + gl_dbg(""); + if (gl_get_view_mode(data) == GL_VIEW_THUMBS) + __gl_thumbs_open_file(it_data); +} + +static void __gl_thumbs_check_changed(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_item *gitem = (gl_item *) data; + GL_CHECK(gitem->ad); + gl_appdata *ad = (gl_appdata *)gitem->ad; + int view_mode = gl_get_view_mode(ad); + Evas_Object *view_ly = NULL; + Elm_Object_Item *nf_it = NULL; + gl_dbg(""); + + if (view_mode == GL_VIEW_THUMBS_EDIT) { + view_ly = ad->gridinfo.navi_content_edit_ly; + nf_it = ad->gridinfo.nf_it_edit; + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + view_ly = ad->gridinfo.select_view_ly; + nf_it = ad->gridinfo.nf_it_select; + } else { + return; + } + + + Eina_Bool checked = elm_check_state_get(obj); + gitem->checked = checked; + if (checked) { + gl_dbg("Append:%s", gitem->item->file_url); + _gl_data_selected_list_append(ad, gitem); + } else { + gl_dbg("Remove:%s", gitem->item->file_url); + _gl_data_selected_list_remove(ad, gitem); + } + + /* Display selectioninfo */ + int sel_cnt = _gl_data_selected_list_count(ad); + _gl_notify_create_selinfo(ad, view_ly, nf_it, ad->gridinfo.thumbs_cnt, + sel_cnt, false); +} + +/* Only for local medias */ +static void __gl_thumbs_create_thumb_cb(media_content_error_e error, + const char *path, void *user_data) +{ + GL_CHECK(user_data); + gl_thumb_data_s *thumb_data = (gl_thumb_data_s *)user_data; + GL_CHECK(thumb_data->ad); + gl_appdata *ad = (gl_appdata *)thumb_data->ad; + gl_item *gitem = thumb_data->item; + GL_FREE(thumb_data); + + if (gl_get_view_mode(ad) != GL_VIEW_THUMBS && + gl_get_view_mode(ad) != GL_VIEW_THUMBS_EDIT) + return; + + GL_CHECK(gitem); + GL_CHECK(gitem->item); + if (GL_FILE_EXISTS(path)) { + gl_dbg("Update item with new thumb path[%s]", path); + /* Update thumb path */ + GL_FREEIF(gitem->item->thumb_url); + gitem->item->thumb_url = strdup(path); + elm_gengrid_item_update(gitem->elm_item); + } else { + gl_dbgE("Invalid thumb path!"); + } +} + +/* Use file to create new thumb if possible */ +static int __gl_thumbs_create_thumb(gl_item *gitem) +{ + GL_CHECK_VAL(gitem, -1); + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(gitem->item->file_url, -1); + + if (GL_FILE_EXISTS(gitem->item->file_url)) { + gl_thumb_data_s *thumb_data = NULL; + thumb_data = (gl_thumb_data_s *)calloc(1, sizeof(gl_thumb_data_s)); + GL_CHECK_VAL(thumb_data, -1); + thumb_data->ad = gitem->ad; + thumb_data->item = gitem; + _gl_data_create_thumb(gitem, __gl_thumbs_create_thumb_cb, + thumb_data); + return 0; + } + return -1; +} + +static Evas_Object *__gl_thumbs_get_content(void *data, Evas_Object *obj, + const char *part) +{ + GL_CHECK_NULL(part); + GL_CHECK_NULL(strlen(part)); + GL_CHECK_NULL(data); + gl_item *gitem = (gl_item *)data; + GL_CHECK_NULL(gitem->item); + GL_CHECK_NULL(gitem->ad); + gl_appdata *ad = (gl_appdata *)gitem->ad; + int view_mode = gl_get_view_mode(ad); + int item_size = ad->gridinfo.icon_size; + bool is_expired_drm = false; + + if (!g_strcmp0(part, GL_THUMB_ICON)) { + Evas_Object *layout = NULL; + char *path = NULL; + char *drm_path = NULL; + unsigned int orient = 0; + + /* Is it DRM file? Has a valid RO? */ + if(_gl_get_icon_type(gitem) == GL_ICON_EXPIRED_DRM) { + path = GL_DEFAULT_THUMB_ICON; + is_expired_drm = true; + /* Only one photo in a (normal, not web) album */ + } else if (ad->maininfo.medias_cnt < 2 && + gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE) { + if (!g_strcmp0(GL_DB_DEFAULT_THUMB, gitem->item->thumb_url)) { + path = GL_DEFAULT_THUMB_ICON; + } else { + drm_path = gl_drm_get_file_path(gitem); + path = _GET_ICON(drm_path); + if (gl_is_image_valid(ad, path) == false) + path = _GET_ICON(gitem->item->thumb_url); +#ifdef _USE_ROTATE_BG + /* Rotate bg if it's created from original file */ + if (!g_strcmp0(path, gitem->item->file_url)) + _gl_exif_get_orientation(path, &orient); +#endif + } + } else { + /* Use default image */ + if (GL_FILE_EXISTS(gitem->item->thumb_url)) { + path = gitem->item->thumb_url; + } else { + path = GL_DEFAULT_THUMB_ICON; + __gl_thumbs_create_thumb(gitem); + } + } + + if (gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO) { + unsigned int v_dur = 0; + if (gitem->item->video_info) { + v_dur = gitem->item->video_info->duration; + } + int bk_len = 0; + if (gitem->item->video_info == NULL) + bk_len = 0; + else + bk_len = gitem->item->video_info->bookmarks; + layout = _gl_thumb_show_part_icon_video(obj, path, + v_dur, bk_len, + gitem->item->favorite, + is_expired_drm, + item_size); + } else { + layout = _gl_thumb_show_part_icon_image(obj, path, + orient, + gitem->item->favorite, + is_expired_drm, + item_size); + } + + GL_FREEIF(drm_path); + return layout; + } else if (!g_strcmp0(part, GL_THUMB_CHECKBOX) && + (view_mode == GL_VIEW_THUMBS_EDIT || + view_mode == GL_VIEW_THUMBS_SELECT)) { + Evas_Object *ck = NULL; + ck = _gl_thumb_show_part_checkbox(obj, gitem->checked, + __gl_thumbs_check_changed, + data); + GL_CHECK_NULL(ck); + + gitem->check_obj = ck; + return ck; + } + + return NULL; +} + +static int __gl_thumbs_set_type(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + ad->gridinfo.grid_type = GL_GRID_T_NONE;; + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + ad->gridinfo.grid_type = GL_GRID_T_TAGS; + } else { + gl_cluster *cur_album = ad->albuminfo.current_album; + GL_CHECK_VAL(cur_album, -1); + GL_CHECK_VAL(cur_album->cluster, -1); + + if (cur_album->cluster->type == GL_STORE_T_PHONE || + cur_album->cluster->type == GL_STORE_T_MMC) + ad->gridinfo.grid_type = GL_GRID_T_LOCAL; + else if (cur_album->cluster->type == GL_STORE_T_ALL) + ad->gridinfo.grid_type = GL_GRID_T_ALLALBUMS; + else + gl_dbgE("Wrong cluster storage type!"); + } + gl_dbg("Gridview type: %d", ad->gridinfo.grid_type); + return 0; +} + +static bool __gl_thumbs_create_items(void *data, Evas_Object *parent) +{ + GL_CHECK_FALSE(data); + GL_CHECK_FALSE(parent); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + int item_cnt = 0; + gl_item *gitem = NULL; + int ret = -1; + /* Get all medias count of current album */ + int cnt = ad->maininfo.medias_cnt; + gl_dbg("List count : %d gv_mode : %d", cnt, ad->gridinfo.view_mode); + + ad->gridinfo.thumbgic.item_style = GL_GENGRID_ITEM_STYLE_THUMBNAIL; + ad->gridinfo.thumbgic.func.text_get = NULL; + ad->gridinfo.thumbgic.func.content_get = __gl_thumbs_get_content; + + elm_gengrid_clear(parent); + for (i = 1; i <= cnt; i++) { + _gl_data_get_item_by_index(ad, i, false, &gitem); + if (gitem == NULL || gitem->item == NULL || + gitem->item->uuid == NULL) { + gl_dbgE("Invalid gitem. continue..."); + continue; + } + + /* For PTP Album, file_url is NULL untill the file is saved from camera */ + if (!gitem->item->file_url) { + gl_dbg("file_url is invalid."); + ret = _gl_data_delete_media(ad, gitem->item); + if (ret != 0) + continue; + _gl_data_selected_list_remove(ad, gitem); + _gl_data_item_list_remove(ad, gitem); + cnt--; + i--; + gitem = NULL; + continue; + } + + if (ad->gridinfo.back_to_normal) { + gitem->checked = false; + //gitem->check_obj = NULL; + } + + if (ad->gridinfo.view_mode == GL_THUMB_IMAGES && + gitem->item->type != MEDIA_CONTENT_TYPE_IMAGE) + continue; + if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS && + gitem->item->type != MEDIA_CONTENT_TYPE_VIDEO) + continue; + gitem->elm_item = elm_gengrid_item_append(parent, + &(ad->gridinfo.thumbgic), + gitem, + __gl_thumbs_sel_cb, + gitem); + item_cnt++; + gitem->sequence = item_cnt; + + } + + ad->gridinfo.thumbs_cnt = item_cnt; + ad->gridinfo.back_to_normal = false; + + if (item_cnt == 0) + return EINA_FALSE; + else + return EINA_TRUE; +} + +/* +* Set new view to all/image_grid_view. +* +* b_noc, true: it's nocontents view, false: normal view. +*/ +static int __gl_thumbs_set_view(void *data, Evas_Object *view, bool b_noc) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + ad->gridinfo.all_grid_view = view; + if (b_noc) + _gl_thumbs_set_nocontents(ad, view); + else + _gl_thumbs_set_nocontents(ad, NULL); + + return 0; +} + +/* +* When select album, show first (GL_FIRST_VIEW_END_POS+1) medias. +* Then use idler to get other medias from DB and appened +* them to gridview. +* In order to reduce transit time of first show of thumbnails view. +* Cause most of time is spent for getting records from DB, +* so we get first (GL_FIRST_VIEW_END_POS+1) items and show thumbnails view, +* it will accelerate view show. +*/ +static int __gl_thumbs_idler_append_items(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->albuminfo.current_album, -1); + GL_CHECK_VAL(ad->gridinfo.all_grid_view, -1); + int i = 0; + int item_cnt = 0; + gl_item *gitem = NULL; + /* Get all medias count of current album */ + int cnt = ad->maininfo.medias_cnt; + int ret = -1; + + gl_dbg("First view medias count: %d; girdview mode: %d", + cnt, ad->gridinfo.view_mode); + if (ad->maininfo.medias_cnt != (GL_FIRST_VIEW_END_POS + 1)) { + gl_dbg("No any more items, return!"); + return -1; + } + /* Get other items from DB */ + ret = _gl_data_get_item_list(ad, GL_CATEGORY_FOLDER, + ad->albuminfo.current_album, + (GL_FIRST_VIEW_END_POS + 1), + GL_GET_UNTIL_LAST_RECORD); + if (ret < 0) { + gl_dbgE("Get items list failed[%d]!", ret); + return ret; + } + + cnt = ad->maininfo.medias_cnt; + gl_dbg("Grid view all medias count: %d", cnt); + + if (ad->gridinfo.view_mode != GL_THUMB_ALL) { + /* Event gridview mode is wrong, we still need to get other records */ + gl_dbg("Gridview mode is wrong, return!"); + return -1; + } + + /* From (GL_FIRST_VIEW_END_POS + 2)th item to last one */ + i = GL_FIRST_VIEW_END_POS + 2; + + for (; i <= cnt; i++) { + _gl_data_get_item_by_index(ad, i, false, &gitem); + if (gitem == NULL || gitem->item == NULL || + gitem->item->uuid == NULL ) { + gl_dbgE("Invalid gitem, continue..."); + continue; + } + + if (!gitem->item->file_url) { + gl_dbg("file_url is invalid."); + _gl_data_delete_media(ad, gitem->item); + _gl_data_selected_list_remove(ad, gitem); + _gl_data_item_list_remove(ad, gitem); + cnt--; + i--; + gitem = NULL; + continue; + } + + if (ad->gridinfo.view_mode == GL_THUMB_IMAGES && + gitem->item->type != MEDIA_CONTENT_TYPE_IMAGE) + continue; + if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS && + gitem->item->type != MEDIA_CONTENT_TYPE_VIDEO) + continue; + gitem->elm_item = elm_gengrid_item_append(ad->gridinfo.all_grid_view, + &(ad->gridinfo.thumbgic), + gitem, + __gl_thumbs_sel_cb, + gitem); + item_cnt++; + gitem->sequence = item_cnt + GL_FIRST_VIEW_END_POS + 1; + } + + gl_dbgW("\tUse idler to append other medias--Done!"); + if (item_cnt == 0) { + return -1; + } else { + ad->gridinfo.thumbs_cnt = item_cnt + GL_FIRST_VIEW_END_POS + 1; + gl_dbg("All count appended: %d", ad->gridinfo.thumbs_cnt); + return 0; + } +} + +static Eina_Bool __gl_thumbs_append_items_idler_cb(void *data) +{ + GL_CHECK_CANCEL(data); + + /* Try to get other medias from DB and append them to gridview */ + if (__gl_thumbs_idler_append_items(data) < 0) { + gl_dbgE("Failed to append grid items!"); + } else { + gl_dbg("Successful to append grid items!"); + } + + /* Remove idler after all items appended */ + _gl_thumbs_del_append_idler(data); + + return ECORE_CALLBACK_CANCEL; +} + +void _gl_thumbs_mouse_down(void *data, Evas *e, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(event_info); + GL_CHECK(data); + gl_item *gitem = (gl_item *) data; + GL_CHECK(gitem->ad); + gl_appdata *ad = (gl_appdata *)gitem->ad; + Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *) event_info; + + ad->gridinfo.grid_touch_info.x = ev->output.x; + ad->gridinfo.grid_touch_info.y = ev->output.y; +} + +void _gl_thumbs_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_item *gitem = (gl_item *) data; + GL_CHECK(gitem->ad); + gl_appdata *ad = (gl_appdata *)gitem->ad; + + if (!event_info || !obj) + goto RET_WO_EXEC; + + Evas_Event_Mouse_Up *ev = event_info; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD || + ev->event_flags & EVAS_EVENT_FLAG_ON_SCROLL) + goto RET_WO_EXEC; + + if ((abs(ad->gridinfo.grid_touch_info.x - ev->output.x) > GL_GRID_TOUCH_RANGE) || + (abs(ad->gridinfo.grid_touch_info.y - ev->output.y) > GL_GRID_TOUCH_RANGE)) + goto RET_WO_EXEC; + + gl_dbg(""); + __gl_thumbs_open_file(data); + return; + + RET_WO_EXEC: + return; +} + +Evas_Object *_gl_thumbs_add_grid(void *data, Evas_Object *parent, + gl_thumb_mode mode, bool b_use_idler) +{ + GL_CHECK_NULL(parent); + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *grid = NULL; + ad->gridinfo.view_mode = mode; + grid = _gl_thumb_add_gengrid(parent); + evas_object_smart_callback_add(grid, "realized", NULL, data); + evas_object_smart_callback_add(grid, "unrealized", NULL, data); + evas_object_smart_callback_add(grid, "longpressed", + __gl_thumbs_longpressed, data); + + /* Set grid view type */ + __gl_thumbs_set_type(ad); + + int view_mode = gl_get_view_mode(ad); + + if (!__gl_thumbs_create_items(ad, grid)) { + evas_object_del(grid); + grid = NULL; + Evas_Object *noc = _gl_nocontents_create(ad); + _gl_thumbs_set_nocontents(ad, noc); + evas_object_show(noc); + return noc; + } + + gl_dbg("thumbs_cnt : %d", ad->gridinfo.thumbs_cnt); + _gl_thumbs_set_size(ad, grid); + if (view_mode != GL_VIEW_THUMBS_SELECT) + _gl_thumbs_set_nocontents(ad, NULL); + evas_object_show(grid); + + if (b_use_idler && + ad->maininfo.medias_cnt == (GL_FIRST_VIEW_END_POS + 1)) { + gl_dbgW("\tUse idler to append other medias--Start"); + /* Remove idler */ + _gl_thumbs_del_append_idler(ad); + /* Add idler */ + ad->gridinfo.grid_append_idler = ecore_idler_add(__gl_thumbs_append_items_idler_cb, + ad); + } + + return grid; +} + +int _gl_thumbs_show_edit_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + bool b_ret = false; + Evas_Object *view = NULL; + gl_dbg("view_mode: %d", view_mode); + + if (view_mode == GL_VIEW_THUMBS_EDIT) { + view = ad->gridinfo.navi_content_edit_view; + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + view = ad->gridinfo.select_view; + } else { + gl_dbgE("Wrong view mode!"); + return -1; + } + GL_CHECK_VAL(view, -1); + b_ret = __gl_thumbs_create_items(ad, view); + _gl_thumbs_set_size(ad, NULL); + + if (!b_ret) { + gl_dbgE("Create items failed!"); + return -1; + } else { + return 0; + } +} + +int _gl_thumbs_show_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int gridview_mode = ad->gridinfo.view_mode; + bool b_ret = false; + gl_dbg("gridview_mode: %d", gridview_mode); + + if (ad->gridinfo.all_grid_view == NULL) { + gl_dbg("Error : Any gridview doesn't exist"); + return -1; + } + + /* Come back from edit mode, save state */ + ad->gridinfo.back_to_normal = true; + b_ret = __gl_thumbs_create_items(ad, + ad->gridinfo.all_grid_view); + _gl_thumbs_set_size(ad, NULL); + + if (!b_ret) { + gl_dbgE("Create items failed!"); + return -1; + } else { + return 0; + } +} + +Eina_Bool _gl_thumbs_update_view(void *data) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + Eina_Bool res = EINA_FALSE; + Evas_Object *gv = NULL; + int view_mode = gl_get_view_mode(ad); + bool b_view = false; + gl_dbg(""); + + if (view_mode == GL_VIEW_THUMBS_EDIT) { + gl_dbg("\n\nEdit_Mode\n"); + gv = ad->gridinfo.navi_content_edit_view; + } else { + b_view = _gl_thumbs_get_view(ad, &gv); + GL_CHECK_FALSE(gv); + } + if (b_view) { + res = __gl_thumbs_create_items(ad, gv); + if (!res) { + gl_dbg("__gl_thumbs_create_items() return false..."); + evas_object_hide(gv); + evas_object_del(gv); + __gl_thumbs_set_view(ad, NULL, false); + Evas_Object *noc = _gl_nocontents_create(ad); + evas_object_show(noc); + __gl_thumbs_set_view(ad, noc, true); + + elm_object_part_content_unset(ad->gridinfo.navi_content_ly, + "elm.swallow.view"); + elm_object_part_content_set(ad->gridinfo.navi_content_ly, + "elm.swallow.view", noc); + } else { + _gl_thumbs_set_size(ad, gv); + } + } else { + gl_dbg("Remove nocontents view."); + evas_object_hide(gv); + evas_object_del(gv); + __gl_thumbs_set_view(ad, NULL, false); + bool b_noc = false; + int view_m = ad->gridinfo.view_mode; + + Evas_Object *view = NULL; + view = _gl_thumbs_add_grid(ad, ad->gridinfo.navi_content_ly, + view_m, false); + if (ad->gridinfo.all_grid_nocontents) + b_noc = true; + + /* No nocotents removed, gridview created, enable edit button */ + if (!b_noc) { + /* When nocontents removed from webalbum, + * it means this empty album was just refreshed + * to download photo from web, progressbr showed. + */ + _gl_ctrl_disable_btn(ad, false, GL_NAVI_THUMBS); + } + __gl_thumbs_set_view(ad, view, b_noc); + + elm_object_part_content_unset(ad->gridinfo.navi_content_ly, + "elm.swallow.view"); + elm_object_part_content_set(ad->gridinfo.navi_content_ly, + "elm.swallow.view", view); + } + + return res; +} + +int _gl_thumbs_create_view(void *data, int nf_mode, char *title, bool b_idler, + Evas_Smart_Cb func) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Evas_Object *layout = NULL; + Evas_Object *view = NULL; + + gl_set_view_mode(data, GL_VIEW_THUMBS); + layout = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + GL_CHECK_VAL(layout, -1); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + view = _gl_thumbs_add_grid(ad, layout, GL_THUMB_ALL, b_idler); + if (view == NULL) { + evas_object_del(layout); + gl_dbgE("Failed to add gridview!"); + return -1; + } + + elm_object_part_content_set(layout, "elm.swallow.view", view); + ad->gridinfo.all_grid_view = view; + ad->gridinfo.navi_content_ly = layout; + + gl_ui_create_title_and_push(ad, ad->maininfo.naviframe, layout, nf_mode, + title); + + Evas_Object *bk_btn = NULL; + bk_btn = elm_object_item_part_content_get(ad->gridinfo.nf_it, + GL_NAVIFRAME_PREV_BTN); + elm_object_style_set(bk_btn, GL_BUTTON_STYLE_NAVI_PRE); + evas_object_smart_callback_add(bk_btn, "clicked", func, ad); + + edje_object_signal_emit(_EDJ(layout), GL_SIGNAL_VIEW_DEFAULT, "elm"); + gl_dbg("Done"); + return 0; +} + +int _gl_thumbs_update_count(void *data, int new_cnt) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + gl_dbg("gridview display item count=%d", new_cnt); + ad->gridinfo.updated_thumbs_cnt = new_cnt; + + return 0; +} + +/** +* Get all/image_grid_view. +* +* True returned if it's normal view, if it's nocontents view return false. +*/ +bool _gl_thumbs_get_view(void *data, Evas_Object **view) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *gv = NULL; + bool b_view = false; + + gv = ad->gridinfo.all_grid_view; + if (gv && ad->gridinfo.all_grid_nocontents == NULL) + b_view = true; + + /* Nocontents */ + if (!b_view) + gl_dbg("Previous view is Nocontents..."); + + /* Return view */ + if (view) + *view = gv; + + return b_view; +} + +/* Assign new value to all/image_grid_nocontents */ +int _gl_thumbs_set_nocontents(void *data, Evas_Object *noc) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + ad->gridinfo.all_grid_nocontents = noc; + + return 0; +} + +int _gl_thumbs_set_size(void *data, Evas_Object *gridview) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int cnt = 0; + Evas_Object *gv = NULL; + int view_mode = gl_get_view_mode(ad); + + if (gridview) { + gv = gridview; + } else { + bool b_view = false; + if (view_mode == GL_VIEW_THUMBS_EDIT) { + b_view = true; + gv = ad->gridinfo.navi_content_edit_view; + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + b_view = true; + gv = ad->gridinfo.select_view; + } else { + b_view = _gl_thumbs_get_view(ad, &gv); + } + + if (!b_view || !gv) { + gl_dbgE("gridview is invalid!"); + return -1; + } + } + + if (ad->gridinfo.updated_thumbs_cnt <= 0) { + cnt = ad->gridinfo.thumbs_cnt; + } else { + cnt = ad->gridinfo.updated_thumbs_cnt; + ad->gridinfo.updated_thumbs_cnt = 0; + } + + return _gl_thumb_set_size(ad, gv, cnt, &(ad->gridinfo.icon_size)); +} + +int _gl_thumbs_clear_cbs(Evas_Object *grid) +{ + GL_CHECK_VAL(grid, -1); + evas_object_smart_callback_del(grid, "longpressed", + __gl_thumbs_longpressed); + return 0; +} + +int _gl_thumbs_delete_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Destroy idler */ + _gl_thumbs_del_append_idler(data); + + if (ad->gridinfo.all_grid_view != NULL) { + _gl_thumbs_clear_cbs(ad->gridinfo.all_grid_view); + evas_object_del(ad->gridinfo.all_grid_view); + ad->gridinfo.all_grid_view = NULL; + } + ad->gridinfo.grid_type = GL_GRID_T_NONE; + ad->gridinfo.all_grid_nocontents = NULL; + ad->gridinfo.edit_btn = NULL; + return 0; +} + +/* Update griditem size */ +int _gl_thumbs_update_size(void *data, Evas_Object *view) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *_view = NULL; + int view_mode = gl_get_view_mode(ad); + gl_dbg(""); + + if (ad->gridinfo.thumbs_cnt <= GL_GRID_ITEM_ZOOM_LEVEL_02_CNT) { + gl_dbgW("Thumbs count is less than 7!"); + return -1; + } + + if (view) { + _view = view; + } else { + bool b_view = false; + if (view_mode == GL_VIEW_THUMBS_EDIT) { + b_view = true; + _view = ad->gridinfo.navi_content_edit_view; + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + b_view = true; + _view = ad->gridinfo.select_view; + } else { + b_view = _gl_thumbs_get_view(ad, &_view); + } + + if (!b_view || !_view) { + gl_dbgE("gridview is invalid!"); + return -1; + } + } + + _gl_thumbs_set_size(data, _view); + + _gl_thumb_update_gengrid(_view); + + return 0; +} + +int _gl_thumbs_del_append_idler(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->gridinfo.grid_append_idler) { + ecore_idler_del(ad->gridinfo.grid_append_idler); + ad->gridinfo.grid_append_idler = NULL; + } + + return 0; +} + diff --git a/src/gallery.c b/src/gallery.c new file mode 100755 index 0000000..a51bbd2 --- /dev/null +++ b/src/gallery.c @@ -0,0 +1,1145 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include /* Key event */ +#include "gallery.h" +#include "gl-debug.h" +#include "gl-albums.h" +#include "gl-thumbs.h" +#include "gl-controlbar.h" +#include "gl-ui-util.h" +#include "gl-lang.h" +#include "gl-util.h" +#include "gl-data.h" +#include "gl-ext-ug-load.h" +#include "gl-ext-exec.h" +#include "gl-tags.h" +#include "gl-popup.h" +#include "gl-ctxpopup.h" +#include "gl-progressbar.h" +#include "gl-editfield.h" +#include "gl-notify.h" +#include "gl-thread-util.h" +#include "gl-strings.h" + +#define GL_BG_COLOR_R 248 +#define GL_BG_COLOR_G 246 +#define GL_BG_COLOR_B 239 + +#define GL_BD_LAUNCH_TYPE "launch-type" +#define GL_BD_ALBUM_ID "album-id" +#define GL_BD_FILE_TYPE "file-type" +#define GL_BD_DRM_TYPE "drm-type" +#define GL_BD_SETAS_TYPE "setas-type" +#define GL_BD_CALLERID_SIZE "callerid-size" +#define GL_BD_CALLERID_PATH "callerid-path" +#define GL_BD_HOMESCREEN_PATH "homescreen-path" +#define GL_BD_LOCKSCREEN_PATH "lockscreen-path" +#define GL_BD_SELECT_ALBUM "select-album" +#define GL_BD_SELECT_ONE "select-one" +#define GL_BD_SELECT_MULTIPLE "select-multiple" +#define GL_BD_SELECT_SETAS "select-setas" +#define GL_BD_FILE_TYPE_IMAGE "image" +#define GL_BD_FILE_TYPE_VIDEO "video" +#define GL_BD_FILE_TYPE_ALL "all" +#define GL_BD_SETAS_WALLPALER "wallpaper" +#define GL_BD_SETAS_CALLERID "callerid" +#define GL_BD_SHOW_DRM_FILE "true" + +#define GL_AUL_SEP ":" +#define GL_SERVICE_OPERATION_WALLPAPER "http://tizen.org/appcontrol/operation/wallpaper" + +struct text_part { + char *part; + char *msgid; +}; + +static struct text_part main_txt[] = { + {"txt_title", "Application template",}, + {"txt_mesg", "Click to exit",}, +}; + +/* User-defined function */ +static int _gallery_init_app_svc(void *data); + +static void _gallery_win_del_cb(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbgW("_gallery_win_del_cb!!"); + GL_CHECK(data); + + elm_exit(); +} + + +static int _gallery_update_ts(Evas_Object *eo, struct text_part *tp, int size) +{ + int i = 0; + + if (eo == NULL || tp == NULL || size < 0) { + return -1; + } + for (i = 0; i < size; i++) { + if (tp[i].part && tp[i].msgid) { + edje_object_part_text_set(eo, tp[i].part, + tp[i].msgid); + } + } + + return 0; +} + +static void _gallery_lang_changed_cb(void *data) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK(ad->maininfo.main_layout); + + _gallery_update_ts(elm_layout_edje_get(ad->maininfo.main_layout), + main_txt, sizeof(main_txt) / sizeof(main_txt[0])); + _gl_lang_update(data); +} + +static Eina_Bool __gallery_key_down_cb(void *data, int type, void *event) +{ + if (!data) { + gl_dbgE("Invalid parameter!"); + return ECORE_CALLBACK_PASS_ON; + } + + gl_appdata *ad = (gl_appdata *)data; + ad->maininfo.home_key = false; + Ecore_Event_Key *key_event = (Ecore_Event_Key *)event; + + if (!strcmp(key_event->keyname, KEY_END)) { + gl_dbgW("Bakc(End) key"); + } else if (!strcmp(key_event->keyname, KEY_SELECT)) { + gl_dbgW("Home key"); + ad->maininfo.home_key = true; + } else if (!strcmp(key_event->keyname, KEY_POWER)) { + gl_dbgW("Power key"); + } + + gl_dbg("Key down : %s", key_event->keyname); + + return ECORE_CALLBACK_PASS_ON; +} + +static void _gallery_low_battery_cb(void *data) +{ + gl_dbg(""); + + /* ug_send_event(UG_EVENT_LOW_BATTERY); */ + /* 0 : default handler, 1:user handler */ +} + +void _gallery_rotation_cb(app_device_orientation_e m, void *data) +{ + GL_CHECK(data); + gl_dbg("Appcore Rotation mode: %d", m); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK(ad->maininfo.win); + enum ug_event evt = UG_EVENT_NONE; + int r = -1; + + ad->maininfo.rotate_mode = m; + + switch (m) { + case APP_DEVICE_ORIENTATION_0: + r = 0; + evt = UG_EVENT_ROTATE_PORTRAIT; + break; + case APP_DEVICE_ORIENTATION_90: + r = 90; + evt = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN; + break; + case APP_DEVICE_ORIENTATION_180: + r = 180; + evt = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN; + break; + case APP_DEVICE_ORIENTATION_270: + r = 270; + evt = UG_EVENT_ROTATE_LANDSCAPE; + break; + default: + r = -1; + break; + } + + ug_send_event(evt); + + if (r >= 0 && ad->maininfo.win) + elm_win_rotation_with_resize_set(ad->maininfo.win, m); + + int view_mode = gl_get_view_mode(ad); + if (ad->uginfo.ug_called_by_me) { + if (view_mode == GL_VIEW_ALBUMS){ + gl_ctrl_rotate_ctrlbar(ad, GL_VIEW_NONE); + } + return; + } + gl_ctrl_rotate_ctrlbar(ad, GL_VIEW_NONE); +} + +static Eina_Bool __gallery_prop_change(void *data, int ev_type, void *ev) +{ + GL_CHECK_FALSE(ev); + Ecore_X_Event_Window_Property *event = ev; + + if (event->win != ecore_x_window_root_first_get()) + return ECORE_CALLBACK_PASS_ON; + + if (event->atom != ecore_x_atom_get("FONT_TYPE_change")) + return ECORE_CALLBACK_PASS_ON; + + gl_dbg("Font is changed!(FONT_TYPE_change)"); + /* Remove ctxpopup */ + _gl_ctxpopup_del(data); + + return ECORE_CALLBACK_PASS_ON; +} + +void profile_changed_cb(void *data, Evas_Object * obj, void *event) +{ + const char *profile = elm_config_profile_get(); + + if (strcmp(profile, "desktop") == 0) + elm_win_indicator_mode_set (obj, ELM_WIN_INDICATOR_HIDE); + else + elm_win_indicator_mode_set (obj, ELM_WIN_INDICATOR_SHOW); +} + +static Evas_Object *_gallery_create_win(void *data, const char *name) +{ + gl_dbg_launch(" _gallery_create_win:start"); + GL_CHECK_NULL(name); + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *eo = NULL; + + gl_dbg_launch(" elm_win_add:start"); + eo = elm_win_add(NULL, name, ELM_WIN_BASIC); + gl_dbg_launch(" elm_win_add:end"); + if (eo) { + elm_win_autodel_set(eo, EINA_TRUE); + elm_win_title_set(eo, name); + evas_object_smart_callback_add(eo, "profile,changed", + profile_changed_cb, ad); + evas_object_smart_callback_add(eo, "delete,request", + _gallery_win_del_cb, ad); + ad->maininfo.win_scale = elm_config_scale_get(); + gl_dbg("main window scale: %f", ad->maininfo.win_scale); + + /*register x window property change callback */ + ecore_x_event_mask_set(ecore_x_window_root_first_get(), + ECORE_X_EVENT_MASK_WINDOW_PROPERTY); + + ad->maininfo.font_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, + __gallery_prop_change, + evas_object_evas_get(eo)); + } + + gl_dbg("_gallery_create_win:done"); + gl_dbg_launch(" _gallery_create_win:end"); + return eo; +} + +/* Parent is main window */ +static Evas_Object *_gallery_create_bg(Evas_Object *parent) +{ + gl_dbg_launch(" _gallery_create_bg:start"); + GL_CHECK_NULL(parent); + Evas_Object *bg = NULL; + + gl_dbg_launch(" elm_bg_add:start"); + bg = elm_bg_add(parent); + gl_dbg_launch(" elm_bg_add:end"); + /* Show special color of background */ + elm_bg_color_set(bg, GL_BG_COLOR_R, GL_BG_COLOR_G, GL_BG_COLOR_B); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_win_resize_object_add(parent, bg); + evas_object_show(bg); + gl_dbg_launch(" _gallery_create_bg:end"); + + return bg; +} + +/* Parent is main window */ +static Evas_Object *_gallery_create_conform(Evas_Object *parent) +{ + gl_dbg_launch(" _gallery_create_conform:start"); + GL_CHECK_NULL(parent); + Evas_Object *conform = NULL; + + gl_dbg_launch(" elm_conformant_add:start"); + conform = elm_conformant_add(parent); + gl_dbg_launch(" elm_conformant_add:end"); + + evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_win_resize_object_add(parent, conform); + evas_object_show(conform); + gl_dbg_launch(" _gallery_create_conform:end"); + + return conform; +} + +static int _gallery_create_view_ly(gl_appdata *ad) +{ + gl_dbg_launch(" _gallery_create_view_ly:start"); + GL_CHECK_VAL(ad, -1); + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Evas_Object *cbar = NULL; + + Evas_Object *layout = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe); + + ad->ctrlinfo.ctrlbar_view_ly = layout; + + /* create controlbar downside */ + cbar = gl_ctrl_create_ctrlbar(ad, GL_CTRL_TAB_ALBUMS); + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_ly, + "elm.swallow.tabbar", cbar); + _gl_ctrl_show_tabbar(ad, true); + ad->ctrlinfo.ctrlbar = cbar; + + gl_ui_create_title_and_push(ad, ad->maininfo.naviframe, + ad->ctrlinfo.ctrlbar_view_ly, + GL_NAVI_ALBUMS, GL_STR_CTRL_ITEM_ALBUMS); + gl_dbg_launch(" _gallery_create_view_ly:end"); + + return 0; +} + +static Eina_Bool __gallery_activate_win_idler_cb(void *data) +{ + GL_CHECK_CANCEL(data); + gl_appdata *ad = (gl_appdata *)data; + + gl_dbgW("elm_win_activate - start!"); + elm_win_activate(ad->maininfo.win); + gl_dbgW("elm_win_activate - done!"); + + if (ad->albuminfo.activate_win_idler) { + ecore_idler_del(ad->albuminfo.activate_win_idler); + ad->albuminfo.activate_win_idler = NULL; + } + + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool _gallery_create_albums_idler_cb(void *data) +{ + gl_dbg_launch(" _gallery_create_albums_idler_cb:start"); + GL_CHECK_CANCEL(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("_gallery_create_albums_idler_cb:start"); + + gl_dbgW("\tIdler: gallery is launched!"); + + /* Initialize libmedia-info */ + _gl_data_init(); + gl_dbg("DB initialization:done"); + /* Get cluster list from libmedia-info */ + gl_dbg_launch(" _gl_data_get_cluster_list:start"); + _gl_data_get_cluster_list(ad); + gl_dbg_launch(" _gl_data_get_cluster_list:end"); + GL_CHECK_FALSE(ad->albuminfo.cluster_list); + gl_dbg("_gl_data_get_cluster_list:done"); + /* Set view mode */ + gl_set_view_mode(ad, GL_VIEW_ALBUMS); + /** + * Disbale 'edit' button if none editable albums + * (albums except 'All albums'/'Camera shot'/'AllShare') exist. + */ + if (gl_check_gallery_empty(ad) || + ad->albuminfo.cluster_list->edit_cnt == 0) + _gl_ctrl_disable_btn(ad, true, GL_NAVI_ALBUMS); + /* Update albums view, append items */ + gl_albums_update_items(ad); + + /** + * Disable control bar when none album exists. + * or File system is unmounted. + */ + if (gl_check_gallery_empty(ad)) + gl_ctrl_disable_ctrlbar(ad, true); + else + gl_ctrl_disable_ctrlbar(ad, false); + + gl_dbg("_gallery_create_albums_idler_cb:done"); + + if (ad->albuminfo.create_albums_idler) { + ecore_idler_del(ad->albuminfo.create_albums_idler); + ad->albuminfo.create_albums_idler = NULL; + } + + gl_dbg_launch(" _gallery_create_albums_idler_cb:end"); + return ECORE_CALLBACK_CANCEL; +} + +/** + * + * Elm_win + * |-> Elm_bg + * |-> Elm_conformant + * |-> Elm_layout(main_layout) + * |-> Elm_layout(ctrlbar_ly) + * |-> Elm_naviframe(naviframe) + * |-> Elm_layout(ctrlbar_view_ly) + * |-> Elm_gengrid(albums_view/tags_view/places_view/...) +*/ +static int _gallery_init_view(gl_appdata *ad) +{ + gl_dbg_launch(" _gallery_init_view:start"); + gl_dbg(""); + GL_CHECK_VAL(ad, -1); + Evas_Object *ly = NULL; + + /* Background. */ + ad->maininfo.bg = _gallery_create_bg(ad->maininfo.win); + GL_CHECK_VAL(ad->maininfo.bg, -1); + /* Conformant. */ + Evas_Object *conform = _gallery_create_conform(ad->maininfo.win); + GL_CHECK_VAL(conform, -1); + /* Set if this window is an illume conformant window */ + elm_win_conformant_set(ad->maininfo.win, EINA_TRUE); + /* Base Layout */ + ad->maininfo.main_layout = gl_ui_create_main_ly(conform); + GL_CHECK_VAL(ad->maininfo.main_layout, -1); + /* Set base layout to conformant */ + elm_object_content_set(conform, ad->maininfo.main_layout); + /* Indicator */ + elm_win_indicator_mode_set(ad->maininfo.win, ELM_WIN_INDICATOR_SHOW); + gl_dbg("gl_ui_create_main_ly: done"); + /* Create control layout */ + ly = gl_ctrl_create_ctrlbar_ly(ad->maininfo.main_layout); + GL_CHECK_VAL(ly, -1); + ad->ctrlinfo.ctrlbar_ly = ly; + /* Set control layout to main layout */ + elm_object_part_content_set(ad->maininfo.main_layout, + "elm.swallow.content", ly); + /* Create Naviframe */ + ad->maininfo.naviframe = gl_ui_create_naviframe(ad->ctrlinfo.ctrlbar_ly); + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + /* Set Naviframe to control layout */ + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_ly, + "elm.swallow.content", + ad->maininfo.naviframe); + + evas_object_data_set(ad->maininfo.naviframe, GL_NAVIFRAME_OBJ_DATA_KEY, + conform); + + + gl_dbg("gl_ctrl_create_ctrlbar_view: done"); + + if (gl_is_rotation_locked()) { + gl_dbg("Rotation is in locked state!"); + } else { + int mode = APP_DEVICE_ORIENTATION_0; + mode = app_get_device_orientation(); + ad->maininfo.rotate_mode = mode; + } + + /* Create view layout and Set view layout to Naviframe*/ + _gallery_create_view_ly(ad); + + /* Add albums view and append nothing */ + Evas_Object *layout_inner = NULL; + layout_inner = _gl_albums_add_gengrid(ad, ad->ctrlinfo.ctrlbar_view_ly); + GL_CHECK_FALSE(layout_inner); + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_view_ly, "contents", + layout_inner); + ad->albuminfo.albums_view = layout_inner; + ad->albuminfo.gallery_launched = true; + + gl_dbg_launch(" _gallery_init_view:end"); + + return 0; +} + +static bool _gallery_create(void *data) +{ + gl_dbg_launch("create:start"); + gl_dbgW("==Create=="); + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + ad->maininfo.reentrant = TRUE; + Evas_Object *win = NULL; + + elm_theme_extension_add(NULL, GL_EDJ_FILE); + + /* create window */ + win = _gallery_create_win(ad, PACKAGE); + GL_CHECK_FALSE(win); + ad->maininfo.win = win; + + /* initialize gallery view */ + if (_gallery_init_view(ad) != 0) { + gl_dbgE("_gallery_init_view failed"); + return false; + } + /* _gallery_lang_changed_cb(ad); */ + + gl_dbg_launch(" evas_object_show(win):start"); + evas_object_show(win); + gl_dbg_launch(" evas_object_show(win):end"); + gl_dbg("evas_object_show(win):done"); + /* Register callbacks of DB update */ + gl_dbg("system event cb:done"); + + gl_dbg_launch(" register callbacks:start"); + gl_reg_db_update_noti(ad); + /* Register key down handler */ + ad->maininfo.keydown_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, + __gallery_key_down_cb, + data); + gl_dbg_launch(" register callbacks:end"); + + if (ad->albuminfo.create_albums_idler == NULL) { + /* Use idler to load albums view */ + Ecore_Idler *idl = NULL; + idl = ecore_idler_add(_gallery_create_albums_idler_cb, ad); + ad->albuminfo.create_albums_idler = idl; + gl_dbg("create_albums_idler added: 0x%x", + ad->albuminfo.create_albums_idler); + } + gl_dbg_launch("create:end"); + + return true; +} + +static int _gallery_close_app(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->albuminfo.create_albums_idler) { + ecore_idler_del(ad->albuminfo.create_albums_idler); + ad->albuminfo.create_albums_idler = NULL; + } + + if (ad->albuminfo.activate_win_idler) { + ecore_idler_del(ad->albuminfo.activate_win_idler); + ad->albuminfo.activate_win_idler = NULL; + } + /* Destroy idler */ + _gl_thumbs_del_append_idler(ad); + /* destroy rename album job.*/ + if(ad->maininfo.rename_album_job) { + ecore_job_del(ad->maininfo.rename_album_job); + ad->maininfo.rename_album_job = NULL; + } + /* Destroy vibration timer */ + if (ad->entryinfo.vibration_timer) { + ecore_timer_del(ad->entryinfo.vibration_timer); + ad->entryinfo.vibration_timer = NULL; + } + /* Free Ecore_Pipe object created */ + if (ad->pbarinfo.sync_pipe) { + ecore_pipe_del(ad->pbarinfo.sync_pipe); + ad->pbarinfo.sync_pipe = NULL; + } + + if (ad->pbarinfo.start_thread_timer) { + ecore_timer_del(ad->pbarinfo.start_thread_timer); + ad->pbarinfo.start_thread_timer = NULL; + } + + if (ad->pbarinfo.del_pbar_idler) { + ecore_idler_del(ad->pbarinfo.del_pbar_idler); + ad->pbarinfo.del_pbar_idler = NULL; + } + + /* Destroy timer for removing popup */ + if (ad->popupinfo.del_timer) { + ecore_timer_del(ad->popupinfo.del_timer); + ad->popupinfo.del_timer = NULL; + } + + /* Remove down event handler */ + if(ad->maininfo.keydown_handler) { + ecore_event_handler_del(ad->maininfo.keydown_handler); + ad->maininfo.keydown_handler = NULL; + } + + /*Remove font type change event handler*/ + if (ad->maininfo.font_handler) { + ecore_event_handler_del(ad->maininfo.font_handler); + ad->maininfo.font_handler = NULL; + } + + /* Remove key data for confirmant */ + evas_object_data_del(ad->maininfo.naviframe, GL_NAVIFRAME_OBJ_DATA_KEY); + /* Remove IMF */ + _gl_editfield_destroy_imf(ad); + + _gl_ctxpopup_del(ad); + + /* Clear data about thumb callbacks */ + _gl_destroy_thumbs_edit_view(ad); + if (ad->gridinfo.select_view) + _gl_thumbs_clear_cbs(ad->gridinfo.select_view); + _gl_thumbs_delete_view(ad); + + /* DB update callback unregister. */ + gl_dereg_db_update_noti(); + + /* Free memory allocated for appcontrol */ + _gallery_init_app_svc(ad); + + ug_destroy_all(); +#if 0 + if (ad->maininfo.main_layout) + evas_object_del(ad->maininfo.main_layout); +#endif +/*BS launched after connecting to PC while Gallery open in mass storage mode.*/ +#if 0 + if (ad->maininfo.win) + evas_object_del(ad->maininfo.win); +#endif + gl_albums_free_data(data); + + /* disconnet with libmedia-info */ + _gl_data_finalize(ad); + +#ifdef _USE_SBESM + _gl_ext_deinitialize_sbeam(data); +#endif + + gl_dbgW("==Cleaning done=="); + + return 0; +} + +static void _gallery_terminate(void *data) +{ + gl_dbgW("==Terminate=="); + GL_CHECK(data); + _gallery_close_app(data); +} + +static void _gallery_pause(void *data) +{ + gl_dbgW("==Pause=="); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + ad->maininfo.reentrant = TRUE; + + if (ad->maininfo.home_key) { + gl_ext_destroy_gallery_ug(ad); + ad->maininfo.home_key = false; + } + + ug_pause(); +} + +/* auto rotate view after resume if disabling/re-enabling rotate device */ +static int __gallery_resume_update_rotation_mode(gl_appdata *ad) +{ + GL_CHECK_VAL(ad, -1); + int display_mode = -1; + int device_mode = APP_DEVICE_ORIENTATION_0; + + /** + * display_mode is view mode, e.x. view is portrait normal + * device_mode is target mode, e.x. device is portrait normal + */ + display_mode = elm_win_rotation_get(ad->maininfo.win); + device_mode = app_get_device_orientation(); + gl_dbg("display_mode is %d, device_mode is %d\n", display_mode, + device_mode); + + /** + * disable rotate when view isn't portrait normal, then after resume, + * rotate view to portrait + */ + if (gl_is_rotation_locked() && + (display_mode != APP_DEVICE_ORIENTATION_0)) + _gallery_rotation_cb(APP_DEVICE_ORIENTATION_0, (void*)ad); + /** + * re-enable rotate when device isn't in portrait normal + * and view is in portrait normal, then after resume, + * rotate view by device_mode + */ + else if (!gl_is_rotation_locked() && (device_mode != display_mode)) + _gallery_rotation_cb(device_mode, (void*)ad); + return 0; +} + +static void _gallery_resume(void *data) +{ + gl_dbg_launch("resume:start"); + gl_dbgW("==Resume=="); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + + ug_resume(); + /* Video palyer was close when pause Gallery */ + ad->uginfo.app_called_by_me = false; + + /* Show cursor and IMF if not popup showed */ + if (ad->entryinfo.editfield) { + if (ad->popupinfo.popup) { + gl_dbg("Hide Entry cursor and IMF"); + _gl_editfield_hide_imf(ad); + } else { + gl_dbg("Show Entry cursor and IMF"); + _gl_editfield_show_imf(ad); + } + } + + /* Update view */ + gl_update_view(ad, GL_UPDATE_VIEW_NORMAL); + __gallery_resume_update_rotation_mode(ad); + + gl_dbg_launch("resume:done"); +} +static int __gallery_reset_app(void *data, const char *cluster_id, + const char *aul_type) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.win, -1); + int view_mode = gl_get_view_mode(ad); + gl_dbg(""); + + if (cluster_id == NULL || aul_type == NULL) { + gl_dbgE("Invalid aul parameters!"); + goto GALLERY_RESET_FAILED; + } + + if (ad->pbarinfo.sync_pipe) { + gl_dbgW("Cancel move/delete pthread/Pipe!"); + /* Set cancel state to make child thread exit */ + gl_thread_set_cancel_state(ad, GL_PB_CANCEL_RESET); + return -1; + } + + if (view_mode == GL_VIEW_NONE) { + /* First launch gallery then show shortcut album/tag */ + _gl_data_init(); + gl_dbg("Launch gallery at the first time"); + _gl_data_get_cluster_list(ad); + GL_CHECK_VAL(ad->albuminfo.cluster_list, -1); + /* Set view mode */ + gl_set_view_mode(ad, GL_VIEW_ALBUMS); + /* Select tabbar item contains shortcut item */ + _gl_ctrl_sel_tabbar_item(ad, aul_type); + } else if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + gl_dbg("In Tags tab"); + if (_gl_tags_reset_view(ad, cluster_id, aul_type) < 0) + goto GALLERY_RESET_FAILED; + } else { + gl_dbg("In Albums tab"); + if (_gl_albums_reset_view(ad, cluster_id, aul_type) < 0) + goto GALLERY_RESET_FAILED; + } + + if (g_strcmp0(cluster_id, GL_ALBUM_ALL_ID) == 0 && + g_strcmp0(aul_type, GL_AUL_ALBUM) == 0) + goto GALLERY_RESET_SUCCESS; + + /* Remove idler for other tabbar item */ + if (ad->albuminfo.create_albums_idler) { + gl_dbgW("Remove album creation idler!"); + ecore_idler_del(ad->albuminfo.create_albums_idler); + ad->albuminfo.create_albums_idler = NULL; + } + + if (!g_strcmp0(aul_type, GL_AUL_TAG)) { + /* Show shortcut tag */ + if (_gl_tags_sel_home_tag(ad, cluster_id) == false) { + /* Tag doesn't exist */ + gl_dbgE("Tag(livepanel) doesn't exist!"); + goto GALLERY_RESET_FAILED; + } + } else { + gl_dbgE("Wrong type!"); + goto GALLERY_RESET_FAILED; + } + GALLERY_RESET_SUCCESS: + elm_win_activate(ad->maininfo.win); + return 0; + + GALLERY_RESET_FAILED: + elm_win_activate(ad->maininfo.win); + return -1; +} + +/* init appcontrol launch related global variables */ +static int _gallery_init_app_svc(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_dbg(""); + gl_appdata *ad = (gl_appdata *)data; + + ad->albuminfo.aul_launch_type = GL_AUL_T_NONE; + ad->albuminfo.aul_file_type = GL_AUL_FILE_T_NONE; + ad->albuminfo.aul_setas_type = GL_AUL_SETAS_T_NONE; + GL_FREEIF(ad->albuminfo.aul_id); + GL_FREEIF(ad->albuminfo.aul_type); + ad->albuminfo.aul_launch_by_mime = false; + + if(ad->albuminfo.recv_service) { + service_destroy(ad->albuminfo.recv_service); + ad->albuminfo.recv_service = NULL; + } + + GL_FREEIF(ad->albuminfo.aul_callid_size); + GL_FREEIF(ad->albuminfo.aul_callid_path); + GL_FREEIF(ad->albuminfo.aul_homescreen_path); + GL_FREEIF(ad->albuminfo.aul_lockscreen_path); + return 0; +} + +static int __gallery_parse_contain_drm(void *data, service_h service) +{ + GL_CHECK_VAL(service, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + char *contain_drm = NULL; + + ad->albuminfo.b_show_drm = false; + service_get_extra_data(service, GL_BD_DRM_TYPE, &contain_drm); + gl_dbg("DRM: %s", contain_drm); + if (contain_drm) { + if (!strcasecmp(contain_drm, GL_BD_SHOW_DRM_FILE)) + ad->albuminfo.b_show_drm= true; + GL_FREE(contain_drm); + } + + return 0; +} + +static int __gallery_parse_launch_type(void *data, service_h service) +{ + GL_CHECK_VAL(service, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_aul_launch_type launch_type = GL_AUL_T_NONE; + char *launch_type_str = NULL; + char *setas_type_str = NULL; + gl_dbg(""); + + /* get launch-type */ + service_get_extra_data(service, GL_BD_LAUNCH_TYPE, &launch_type_str); + if (launch_type_str == NULL) { + gl_dbg("set to default launch type: select-one"); + ad->albuminfo.aul_launch_type = GL_AUL_T_SELECT_ONE; + return 0; + } else { + gl_dbg("launch-type: %s", launch_type_str); + } + + if(!strcasecmp(launch_type_str, GL_BD_SELECT_ALBUM)) { + launch_type = GL_AUL_T_SELECT_ALBUM; + } else if(!strcasecmp(launch_type_str, GL_BD_SELECT_ONE)) { + launch_type = GL_AUL_T_SELECT_ONE; + } else if(!strcasecmp(launch_type_str, GL_BD_SELECT_MULTIPLE)) { + launch_type = GL_AUL_T_SELECT_MULTIPLE; + } else if(!strcasecmp(launch_type_str, GL_BD_SELECT_SETAS)) { + launch_type = GL_AUL_T_SELECT_SETAS; + + /* get setas-type */ + service_get_extra_data(service, GL_BD_SETAS_TYPE, &setas_type_str); + if(setas_type_str == NULL) { + GL_FREE(launch_type_str); + return 0; + } + gl_dbg("setas-type: %s", setas_type_str); + + gl_aul_setas_type setas_type = GL_AUL_SETAS_T_NONE; + char *path = NULL; + char *size = NULL; + + if (!strcasecmp(setas_type_str, GL_BD_SETAS_WALLPALER)) { + setas_type = GL_AUL_SETAS_T_WALLPAPER; + + /* get homscreen-path */ + service_get_extra_data(service, GL_BD_HOMESCREEN_PATH, + &path); + if (path) { + gl_dbg("homescreen-path: %s", path); + ad->albuminfo.aul_homescreen_path = path; + path = NULL; + } + /* get lockscreen-path */ + service_get_extra_data(service, GL_BD_LOCKSCREEN_PATH, + &path); + if (path) { + gl_dbg("lockscreen-path: %s", path); + ad->albuminfo.aul_lockscreen_path = path; + path = NULL; + } + } else if (!strcasecmp(setas_type_str, GL_BD_SETAS_CALLERID)) { + setas_type = GL_AUL_SETAS_T_CALLER_ID; + /* get callerid-size */ + service_get_extra_data(service, GL_BD_CALLERID_SIZE, + &size); + if (size) { + gl_dbg("callerid-size: %s", size); + ad->albuminfo.aul_callid_size = size; + } + /* get callerid-path */ + service_get_extra_data(service, GL_BD_CALLERID_PATH, + &path); + if (path) { + gl_dbg("callerid-path: %s", path); + ad->albuminfo.aul_callid_path = path; + } + } + + ad->albuminfo.aul_setas_type = setas_type; + GL_FREE(setas_type_str); + } + + ad->albuminfo.aul_launch_type = launch_type; + GL_FREE(launch_type_str); + return 0; +} + +/* analysis parameters */ +static int __gallery_parse_param(void *data, service_h service) +{ + GL_CHECK_VAL(service, -1); + GL_CHECK_VAL(data, -1); + gl_dbg(""); + gl_appdata *ad = (gl_appdata *)data; + char *operation = NULL; + char *uri = NULL; + char *mime = NULL; + + /* init */ + _gallery_init_app_svc(ad); + + /* save current service handle */ + service_clone(&ad->albuminfo.recv_service, service); + + service_get_operation(service, &operation); + gl_dbg("operation: %s", operation); + + service_get_uri(service, &uri); + if(uri) { + gl_dbg("uri: %s", uri); + char *str_pre = NULL; + char *str_suf = NULL; + str_pre = strtok_r(uri, GL_AUL_SEP, &str_suf); + gl_dbg("str_pre: %s, str_suf: %s", str_pre, str_suf); + GL_CHECK_VAL(str_pre, -1); + GL_CHECK_VAL(str_suf, -1); + str_pre = strtok_r(str_suf, GL_AUL_SEP, &str_suf); + gl_dbg("str_pre: %s, str_suf: %s", str_pre, str_suf); + GL_CHECK_VAL(str_pre, -1); + GL_CHECK_VAL(str_suf, -1); + ad->albuminfo.aul_id = strdup(str_suf); + ad->albuminfo.aul_type = strdup(str_pre); + ad->albuminfo.aul_launch_by_mime = true; + gl_dbg("Type: %s, ID: %s", ad->albuminfo.aul_type, + ad->albuminfo.aul_id); + return 0; + } + + if(!strcasecmp(operation, SERVICE_OPERATION_DEFAULT)) { + return -1; + } else if (!strcasecmp(operation, SERVICE_OPERATION_VIEW)) { + /* OPERATION_VIEW */ + ad->albuminfo.aul_launch_type = GL_AUL_T_VIEW_ALBUM; + + /* get file-type from service */ + char *file_type_str = NULL; + ad->albuminfo.aul_file_type = GL_AUL_FILE_T_ALL; /* default */ + service_get_extra_data(service, GL_BD_FILE_TYPE, &file_type_str); + if(file_type_str) { + gl_dbg("file type: %s", file_type_str); + if (!g_strcmp0(file_type_str, GL_BD_FILE_TYPE_IMAGE)) { + ad->albuminfo.aul_file_type = GL_AUL_FILE_T_IMAGE; + } else if (!g_strcmp0(file_type_str, GL_BD_FILE_TYPE_VIDEO)) { + ad->albuminfo.aul_file_type = GL_AUL_FILE_T_VIDEO; + } + GL_FREE(file_type_str); + } + /* get album-id */ + char *album_id_str = NULL; + service_get_extra_data(service, GL_BD_ALBUM_ID, &album_id_str); + + if(album_id_str) { + gl_dbg("album-id: %s", album_id_str); + ad->albuminfo.aul_id = album_id_str; + } else { + gl_dbg("album-id is invalid, set to default (ALL)"); + ad->albuminfo.aul_id = strdup(GL_ALBUM_ALL_ID); + } + /* To show album, so tabbar item must be Albums */ + ad->albuminfo.aul_type = strdup(GL_AUL_ALBUM); + } else if (!strcasecmp(operation, SERVICE_OPERATION_PICK)) { + /* OPERATION_PICK */ + /* get file-type from mime */ + ad->albuminfo.aul_file_type = GL_AUL_FILE_T_ALL; /* default */ + service_get_mime(service, &mime); + if(mime) { + + gl_dbg("mime: %s", mime); + if (!g_strcmp0(mime, GL_MIME_IMAGE_ALL)) { + ad->albuminfo.aul_file_type = GL_AUL_FILE_T_IMAGE; + } else if (!g_strcmp0(mime, GL_MIME_VIDEO_ALL)) { + ad->albuminfo.aul_file_type = GL_AUL_FILE_T_VIDEO; + } + } + + __gallery_parse_launch_type(ad, service); + __gallery_parse_contain_drm(ad, service); + } else if (!strcasecmp(operation, GL_SERVICE_OPERATION_WALLPAPER)) { + /* Wallpaper */ + ad->albuminfo.aul_file_type = GL_AUL_FILE_T_IMAGE; + ad->albuminfo.aul_launch_type = GL_AUL_T_SELECT_SETAS; + /* The wallpaper doesn't need crop currently, but IV ug returns "crop_image_path" */ + ad->albuminfo.aul_setas_type = GL_AUL_SETAS_T_CROP_WALLPAPER; + __gallery_parse_contain_drm(ad, service); + + char *path = NULL; + service_get_extra_data(service, GL_BD_HOMESCREEN_PATH, &path); + if (path) { + gl_dbg("homescreen-path: %s", path); + ad->albuminfo.aul_homescreen_path = path; + } + } + + return 0; +} + +static void _gallery_reset(service_h service, void *data) +{ + gl_dbgW("==Reset=="); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK(ad->maininfo.win); + + if (ad->maininfo.reentrant) { + ad->maininfo.reentrant = FALSE; + } else { + gl_dbgW("Gallery reentrant is not allowed, return!"); + return; + } + + /* Destroy gallery ug */ + if (ad->uginfo.gallery_ug_called_by_me) { + gl_dbgW("Destroy Gallery UG launched, show App view!"); + ug_destroy(ad->uginfo.gallery_ug_called_by_me); + ad->uginfo.gallery_ug_called_by_me = NULL; + } + + /* Parse parameters */ + if(__gallery_parse_param(data, service) != 0) { + if (ad->albuminfo.aul_launch_by_mime == false && + ad->albuminfo.aul_launch_type == GL_AUL_T_NONE) { +/*@@ 1. Launch Gallery from menu screen/Smart search app, albums view showed @@*/ + int view_m = gl_get_view_mode(ad); + gl_dbg("view_m: %d", view_m); + /* Launch Gallery at the first time */ + if (view_m == GL_VIEW_NONE) { + gl_dbg("Set view mode as GL_VIEW_ALBUMS"); + gl_set_view_mode(ad, GL_VIEW_ALBUMS); + } else { + gl_dbg("Update view"); + gl_update_view(ad, GL_UPDATE_VIEW_NORMAL); + } + } else { + gl_dbgE("Failed to parse parameters, update view!"); + gl_update_view(ad, GL_UPDATE_VIEW_NORMAL); + } + /* Rotate window if it's not APP_DEVICE_ORIENTATION_0 mode */ + if (!gl_is_rotation_locked()) { + int mode = APP_DEVICE_ORIENTATION_0; + mode = app_get_device_orientation(); + if (mode != APP_DEVICE_ORIENTATION_0) { + gl_dbg("Rotation window!"); + _gallery_rotation_cb(mode, ad); + } + } + elm_win_activate(ad->maininfo.win); + return; + } + + if (ad->albuminfo.aul_launch_by_mime || + ad->albuminfo.aul_launch_type == GL_AUL_T_VIEW_ALBUM) { +/*@@ 2. Launch Gallery from live-magazine/shortcut(add to home) @@*/ + __gallery_reset_app(data, ad->albuminfo.aul_id, + ad->albuminfo.aul_type); + } else { +/*@@ 3. Load Gallery UG @@*/ + gl_dbg("Start loading Gallery UG"); + if (gl_ext_load_gallery_ug(ad) == GL_UG_SUCCESS) { + if (gl_get_view_mode(ad) == GL_VIEW_NONE) { + gl_dbg("elm_win_activate"); + elm_win_activate(ad->maininfo.win); + } else { + if (ad->albuminfo.activate_win_idler) { + ecore_idler_del(ad->albuminfo.activate_win_idler); + ad->albuminfo.activate_win_idler = NULL; + } + /* To show UG faster then app */ + Ecore_Idler *idler = NULL; + idler = ecore_idler_add(__gallery_activate_win_idler_cb, + ad); + ad->albuminfo.activate_win_idler = idler; + } + } + } +} + +int gallery_reset_app(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("Reset gallery[cluster ID: %s]", ad->albuminfo.aul_id); + return __gallery_reset_app(data, ad->albuminfo.aul_id, + ad->albuminfo.aul_type); +} + +int main(int argc, char *argv[]) +{ + gl_dbg_launch("main:start"); + gl_dbgW("==Gallery=="); + gl_appdata gl_ad; + int ret; + + app_event_callback_s event_callback; + + event_callback.create = _gallery_create; + event_callback.terminate = _gallery_terminate; + event_callback.pause = _gallery_pause; + event_callback.resume = _gallery_resume; + event_callback.service = _gallery_reset; + event_callback.low_memory = NULL; + event_callback.low_battery = _gallery_low_battery_cb; + event_callback.device_orientation = _gallery_rotation_cb; + event_callback.language_changed = _gallery_lang_changed_cb; + event_callback.region_format_changed = NULL; + + /* Enable OpenGL */ + setenv("ELM_ENGINE", "gl", 1); + + memset(&gl_ad, 0x00, sizeof(gl_appdata)); + + ret = app_efl_main(&argc, &argv, &event_callback, &gl_ad); + + gl_dbgW("==Gallery gone=="); + gl_dbg_launch("main:done"); + return ret; +} diff --git a/src/util/gl-debug.c b/src/util/gl-debug.c new file mode 100755 index 0000000..eaaef5c --- /dev/null +++ b/src/util/gl-debug.c @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "gl-debug.h" + +#ifdef _USE_LOG_FILE_ +#include +static char _g_file_path[GL_FILE_PATH_LEN_MAX] = { 0, }; +#endif + +#ifdef _PERFORMANCE_CHECK_ +static long g_time_usec = 0L; +#endif + +void _custom_debug_msg(debug_msg_type *debug_msg, const char *msg, ...) +{ + va_list va; + +#define DIRECORY_SPLITTER '/' + const char*pFileName = NULL; + + pFileName = strrchr(debug_msg->fname, DIRECORY_SPLITTER); + pFileName = (NULL == pFileName)?debug_msg->fname:(pFileName+1); + + va_start(va, msg); + + static char buf[2048]; + int i ; + //i = snprintf(buf, 2048, "[%s : %d] ", pFileName, debug_msg->nline); + i = snprintf(buf, 2048, "[%-16.16s : %5d] ", pFileName, debug_msg->nline); + + vsnprintf( buf + i, 2048 - i, msg, va); + + print_log(DLOG_DEBUG, debug_msg->szcategory, "%s", buf); + + va_end(va); +} + +#if 0 +void +gl_init_debug_handler(const char *appname) +{ +#ifdef _USE_LOG_FILE_ + if (appname == NULL) + return; + + memset(_g_file_path, 0x00, sizeof(_g_file_path)); + + //sprintf(_g_file_path, "/tmp/%s", appname); + snprintf(_g_file_path, sizeof(_g_file_path), "/tmp/%s", appname); + if (ecore_file_can_read(_g_file_path)) + remove(_g_file_path); + + g_log_fp = fopen(_g_file_path, "a"); +#elif defined _USE_DLOG_ + //dlog_init(NULL); +#endif +} + +void +gl_close_debug_handler() +{ +#ifdef _USE_LOG_FILE_ + if (g_log_fp != NULL) + fclose(g_log_fp); +#elif defined _USE_DLOG_ + //dlog_deinit(NULL); +#endif +} +#endif + +#if 0 +long +gl_get_debug_time(void) +{ +#ifdef _PERFORMANCE_CHECK_ + struct timeval time; + memset(&time,0x00,sizeof(struct timeval)); + gettimeofday(&time, NULL); + return time.tv_sec * GL_TIME_USEC_PER_SEC + time.tv_usec; +#else + return 0L; +#endif +} + +void +gl_reset_debug_time(void) +{ +#ifdef _PERFORMANCE_CHECK_ + struct timeval time; + memset(&time,0x00,sizeof(struct timeval)); + gettimeofday(&time, NULL); + g_time_usec = time.tv_sec * GL_TIME_USEC_PER_SEC + time.tv_usec; +#endif +} +#endif + +#if 0 +void +gl_print_debug_time(char *time_string) +{ +#ifdef _PERFORMANCE_CHECK_ + struct timeval time; + double totaltime = 0.0; + memset(&time,0x00,sizeof(struct timeval)); + gettimeofday(&time, NULL); + totaltime = (double)(time.tv_sec * GL_TIME_USEC_PER_SEC + time.tv_usec - g_time_usec) / CLOCKS_PER_SEC; + + gl_dbg("time [%s] : %f \n", time_string, totaltime); +#endif +} + +void +mb_print_debug_time_ex(long start, long end, const char *func_name, char *time_string) +{ +#ifdef _PERFORMANCE_CHECK_ + double totaltime = 0.0; + + totaltime = (double)(end - start) / CLOCKS_PER_SEC; + + gl_dbg("time [%s: %s] : %f \n", func_name, time_string, totaltime); +#endif +} +#endif + +/* EOF */ diff --git a/src/util/gl-drm.c b/src/util/gl-drm.c new file mode 100755 index 0000000..8dac39f --- /dev/null +++ b/src/util/gl-drm.c @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "gallery.h" +#include "gl-debug.h" +#include "gl-drm.h" +#include "gl-icons.h" + +char *gl_drm_get_file_path(void *item) +{ + GL_CHECK_NULL(item); + gl_item *gitem = (gl_item *) item; + GL_CHECK_NULL(gitem->item); + GL_CHECK_NULL(gitem->item->file_url); + gl_dbg("filepath: %s", gitem->item->file_url); + + if (gl_drm_is_drm_file(gitem->item->file_url)) + return strdup(GL_DEFAULT_THUMB_ICON); + else + return strdup(gitem->item->file_url); +} + +Eina_Bool gl_drm_is_drm_file(const char *file_path) +{ + GL_CHECK_FALSE(file_path); + + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + if (drm_is_drm_file(file_path, &is_drm_file) != DRM_RETURN_SUCCESS) { + gl_dbgE("drm_is_drm_file error"); + return EINA_FALSE; + } + + if (DRM_TRUE == is_drm_file) + return EINA_TRUE; + return EINA_FALSE; +} + +int gl_drm_get_permtype(int gitem_type) +{ + switch(gitem_type) { + case MEDIA_CONTENT_TYPE_IMAGE: + return DRM_PERMISSION_TYPE_DISPLAY; + case MEDIA_CONTENT_TYPE_VIDEO: + return DRM_PERMISSION_TYPE_PLAY; + default: + return -1; + } +} + +Eina_Bool gl_drm_check_valid_ro(const char *file_path, + drm_permission_type_e permType) +{ + GL_CHECK_FALSE(file_path); + gl_dbg("file_path: %s", file_path); + int ret = -1; + + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + ret = drm_get_license_status(file_path, permType, &license_status); + if (DRM_RETURN_SUCCESS == ret && + DRM_LICENSE_STATUS_VALID == license_status) { + return EINA_TRUE; + } + else { + gl_dbg("No valid ro, return %d", license_status); + return EINA_FALSE; + } +} + diff --git a/src/util/gl-exif.c b/src/util/gl-exif.c new file mode 100755 index 0000000..f8a9550 --- /dev/null +++ b/src/util/gl-exif.c @@ -0,0 +1,1702 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The Exif specification defines an Orientation Tag to indicate the orientation of the + * camera relative to the captured scene. This can be used by the camera either to + * indicate the orientation automatically by an orientation sensor, + * or to allow the user to indicate the orientation manually by a menu switch, + * without actually transforming the image data itself. + * Here is an explanation given by TsuruZoh Tachibanaya in + * his description of the Exif file format: + * + * The orientation of the camera relative to the scene, when the image was captured. + * The relation of the '0th row' and '0th column' to visual position is shown as below. + * + * Value 0th Row 0th Column + * 1 top left side + * 2 top right side + * 3 bottom right side + * 4 bottom left side + * 5 left side top + * 6 right side top + * 7 right side bottom + * 8 left side bottom + * + * Read this table as follows (thanks to Peter Nielsen for clarifying this - see also below): + * Entry #6 in the table says that the 0th row in the stored image is the right side of + * the captured scene, and the 0th column in the stored image is the top side of + * the captured scene. + * + * Here is another description given by Adam M. Costello: + * + * For convenience, here is what the letter F would look like if it were tagged correctly + * and displayed by a program that ignores the orientation tag + * (thus showing the stored image): + * + * 1 2 3 4 5 6 7 8 + * + * 888888 888888 88 88 8888888888 88 88 8888888888 + * 88 88 88 88 88 88 88 88 88 88 88 88 + * 8888 8888 8888 8888 88 8888888888 8888888888 88 + * 88 88 88 88 + * 88 88 888888 888888 +*/ + +#ifdef _USE_ROTATE_BG + +#include +#include +#include +#include +#include "gl-exif.h" +#include "gl-debug.h" +#include "gallery.h" + +#define GL_EXIF_BUF_LEN_MAX 65536L +#define GL_EXIF_BUF_TIME_LEN_MAX 20 +#define GL_EXIF_DEFAULT_YEAR 1900 + +#define GL_EXIF_SOI 0xD8 +#define GL_EXIF_TAG 0xFF +#define GL_EXIF_APP0 0xE0 +#define GL_EXIF_APP1 0xE1 +#define GL_EXIF_JFIF_00 0x00 +#define GL_EXIF_JFIF_01 0x01 +#define GL_EXIF_JFIF_02 0x02 + +#define GL_EXIF_IFD_DATA_FORMAT_UNSIGNED_BYTE 1 +#define GL_EXIF_IFD_DATA_FORMAT_ASCII_STRINGS 1 +#define GL_EXIF_IFD_DATA_FORMAT_UNSIGNED_SHORT 2 +#define GL_EXIF_IFD_DATA_FORMAT_UNSIGNED_LONG 4 +#define GL_EXIF_IFD_DATA_FORMAT_UNSIGNED_RATIONAL 8 +#define GL_EXIF_IFD_DATA_FORMAT_SIGNED_BYTE 1 +#define GL_EXIF_IFD_DATA_FORMAT_UNDEFINED 1 +#define GL_EXIF_IFD_DATA_FORMAT_SIGNED_SHORT 2 +#define GL_EXIF_IFD_DATA_FORMAT_SIGNED_LONG 4 +#define GL_EXIF_IFD_DATA_FORMAT_SIGNED_RATIONAL 8 +#define GL_EXIF_IFD_DATA_FORMAT_SIGNED_FLOAT 4 +#define GL_EXIF_IFD_DATA_FORMAT_DOUBLE_FLOAT 8 + +#define GL_EXI_TMP_JPEG_FILE GL_DATA_FOLDER_PATH"/.gallery_tmp_write_exif.jpg" + +/* Write one byte, testing for EOF */ +static int __gl_exif_write_1_byte(FILE *fd, int c) +{ + if (fputc(c, fd) < 0) { + gl_dbgE("fputc failed!"); + return -1; + } + + return 0; +} + +/* Read one byte, testing for EOF */ +static int __gl_exif_read_1_byte(FILE *fd) +{ + int c = 0; + + /* Return next input byte, or EOF if no more */ + c = getc(fd); + if (c == EOF) { + gl_dbgE("Premature EOF in JPEG file!"); + return -1; + } + + return c; +} + +/* Read 2 bytes, convert to unsigned int */ +/* All 2-byte quantities in JPEG markers are MSB first */ +static int __gl_exif_read_2_bytes(FILE *fd, unsigned int *len) +{ + int c1 = 0; + int c2 = 0; + + /* Return next input byte, or EOF if no more */ + c1 = getc(fd); + if (c1 == EOF) { + gl_dbgE("Premature EOF in JPEG file!"); + return -1; + } + + /* Return next input byte, or EOF if no more */ + c2 = getc(fd); + if (c2 == EOF) { + gl_dbgE("Premature EOF in JPEG file!"); + return -1; + } + + if (len) + *len = (((unsigned int)c1) << 8) + ((unsigned int)c2); + + return 0; +} + +/* Add raw exif tag and data */ +static int __gl_exif_add_header(FILE *fd, unsigned int *orientation) +{ + GL_CHECK_VAL(orientation, -1); + GL_CHECK_VAL(fd, -1); + int i = 0; + int ret = -1; + char *time_buf = NULL; + unsigned int offset = 0; + + /* raw EXIF header data */ + const unsigned char exif1[] = { + GL_EXIF_TAG, GL_EXIF_SOI, GL_EXIF_TAG, GL_EXIF_APP1 + }; + /* Write File head, check for JPEG SOI + Exif APP1 */ + for (i = 0; i < 4; i++) { + if (__gl_exif_write_1_byte(fd, exif1[i]) < 0) + goto GL_EXIF_FAILED; + } + /* SET the marker parameter length count */ + /* Length includes itself, so must be at least 2 + Following Exif data length must be at least 6; 30+36 bytes*/ + const unsigned char exif2[] = { 0x00, 0x42 }; + for (i = 0; i < 2; i++) { + if (__gl_exif_write_1_byte(fd, exif2[i]) < 0) + goto GL_EXIF_FAILED; + } + + /* Write Exif head -- "Exif" */ + const unsigned char exif3[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; + for (i = 0; i < 6; i++) { + if (__gl_exif_write_1_byte(fd, exif3[i]) < 0) + goto GL_EXIF_FAILED; + } + + /* Set byte order and Tag Mark , "II(0x4949)" */ + const unsigned char exif4[] = { 0x49, 0x49, 0x2A, 0x00 }; + for (i = 0; i < 4; i++) { + if (__gl_exif_write_1_byte(fd, exif4[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 4; + + /* Set first IFD offset (offset to IFD0) , II-08000000 */ + const unsigned char exif5[] = { 0x08, 0x00, 0x00, 0x00 }; + for (i = 0; i < 4; i++) { + if (__gl_exif_write_1_byte(fd, exif5[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 4; + + /* IFD: Image File Directory */ + /* Set the number of directory entries contained in this IFD, - EEEE ; + * 2 entry: orientation, data time */ + const unsigned char exif6[] = { 0x02, 0x00 }; + for (i = 0; i < 2; i++) { + if (__gl_exif_write_1_byte(fd, exif6[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 2; + + /* Add Orientation Tag in IFD0; 0x0112 */ + const unsigned char exif7[] = { 0x12, 0x01 }; + for (i = 0; i < 2; i++) { + if (__gl_exif_write_1_byte(fd, exif7[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 2; + + gl_dbg("Write: %d", *orientation); + const unsigned char exif8[] = { 0x03, 0x00, 0x01, 0x00, 0x00, 0x00 }; + for (i = 0; i < 6; i++) { + if (__gl_exif_write_1_byte(fd, exif8[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 6; + + /* Set the Orientation value */ + if (__gl_exif_write_1_byte(fd, (unsigned char)(*orientation)) < 0) + goto GL_EXIF_FAILED; + + const unsigned char exif9[] = { 0x00, 0x00, 0x00 }; + for (i = 0; i < 3; i++) { + if (__gl_exif_write_1_byte(fd, exif9[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 4; + + /* Add Data Time Tag in IFD0; 0x0132 */ + const unsigned char exif10[] = { 0x32, 0x01 }; + for (i = 0; i < 2; i++) { + if (__gl_exif_write_1_byte(fd, exif10[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 2; + + /* Type: strings */ + const unsigned char exif11[] = { 0x02, 0x00 }; + for (i = 0; i < 2; i++) { + if (__gl_exif_write_1_byte(fd, exif11[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 2; + + /* Data lengh, byte count */ + const unsigned char exif12[] = { 0x14, 0x00, 0x00, 0x00 }; + for (i = 0; i < 4; i++) { + if (__gl_exif_write_1_byte(fd, exif12[i]) < 0) + goto GL_EXIF_FAILED; + } + offset += 8; + + /* 20 bytes larger than 4 bytes, + * so next 4 bytes is data offset start from "II"(0x4949)*/ + + gl_dbg("offset: %2X", offset + 8); + /* Too add data offset, plus 4 bytes self and plus 4 bytes IFD terminator */ + if (__gl_exif_write_1_byte(fd, (unsigned char)(offset + 4)) < 0) + goto GL_EXIF_FAILED; + + const unsigned char exif13[] = { 0x00, 0x00, 0x00 }; + for (i = 0; i < 3; i++) { + if (__gl_exif_write_1_byte(fd, exif13[i]) < 0) + goto GL_EXIF_FAILED; + } + + /*After last directory entry, there is a 4bytes of data('LLLLLLLL' at the chart), + * it means an offset to next IFD. If its value is '0x00000000', + * it means this is the last IFD and there is no linked IFD */ + const unsigned char exif14[] = { 0x00, 0x00, 0x00, 0x00 }; + for (i = 0; i < 4; i++) { + if (__gl_exif_write_1_byte(fd, exif14[i]) < 0) + goto GL_EXIF_FAILED; + } + + /* Date Time of image was last modified. + * Data format is "YYYY:MM:DD HH:MM:SS"+0x00, total 20bytes + */ + time_t t; + struct tm tms; + struct tm *tm; + + t = time (NULL); + tm = localtime_r(&t, &tms); + + time_buf = (char *)calloc(1, GL_EXIF_BUF_TIME_LEN_MAX); + if (time_buf == NULL) { + gl_dbgE("Faild to allocate memory!"); + goto GL_EXIF_FAILED; + } + snprintf(time_buf, GL_EXIF_BUF_TIME_LEN_MAX, + "%04i:%02i:%02i %02i:%02i:%02i", + tm->tm_year + GL_EXIF_DEFAULT_YEAR, tm->tm_mon + 1, + tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); + + gl_dbg("time_buf: %s", time_buf); + if (fwrite(time_buf, 1, GL_EXIF_BUF_TIME_LEN_MAX, fd) != GL_EXIF_BUF_TIME_LEN_MAX) { + gl_dbgW("Write size are diff!"); + goto GL_EXIF_FAILED; + } + + ret = 0; + + GL_EXIF_FAILED: + + gl_dbg("All done"); + GL_FREEIF(time_buf); + return ret; +} + +/* Add exif to jfif , don't have exif */ +static int __gl_exif_add_exif_to_jfif(char *file_path, unsigned int *orientation) +{ + GL_CHECK_VAL(orientation, -1); + GL_CHECK_VAL(file_path, -1); + unsigned char tmp[GL_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + + if ((fd = fopen(file_path, "rb+")) == NULL) { + gl_dbgE("Can't open %s!", file_path); + return -1; + } + + char *tmp_file = GL_EXI_TMP_JPEG_FILE; + FILE *tmp_fd = NULL; + if ((tmp_fd = fopen(tmp_file, "wb+")) == NULL) { + gl_dbgE("Can't open %s!", tmp_file); + goto GL_EXIF_FAILED; + } + + /* Add raw EXIF header data */ + if (__gl_exif_add_header(tmp_fd, orientation) < 0) + goto GL_EXIF_FAILED; + + size_t r_size = 0; + /* Remove start of JPEG image data section, 20 bytes */ + r_size = fread(tmp, sizeof(char), 20, fd); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write JPEG image data to tmp file after EXIF header */ + while ((r_size = fread(tmp, 1, sizeof(tmp), fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, tmp_fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + fclose(fd); + fd = fopen(file_path, "wb"); + if (!fd) { + gl_dbgE("Error creating file %s!", file_path); + goto GL_EXIF_FAILED; + } + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write back tmp file after to JPEG image */ + fseek(tmp_fd, 0, SEEK_SET); + while ((r_size = fread(tmp, 1, sizeof(tmp), tmp_fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + ret = 0; + + GL_EXIF_FAILED: + + if (fd) + fclose(fd); + if (tmp_fd) + fclose(tmp_fd); + + /* Delete tmp file */ + if (!ecore_file_unlink(tmp_file)) + gl_dbgE("Delete file failed"); + + gl_dbg("All done"); + return ret; +} + +#if 0 +/* Add exif to jfif 1.00, to add exif for some cases */ +static int __gl_exif_rw_jfif_1dot00(char *file_path, unsigned int *orientation) +{ + GL_CHECK_VAL(orientation, -1); + GL_CHECK_VAL(file_path, -1); + unsigned char tmp[GL_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + int tmp_exif = -1; + + if ((fd = fopen(file_path, "rb+")) == NULL) { + gl_dbgE("Can't open %s!", file_path); + return -1; + } + + char *tmp_file = GL_EXI_TMP_JPEG_FILE; + FILE *tmp_fd = NULL; + if ((tmp_fd = fopen(tmp_file, "wb+")) == NULL) { + gl_dbgE("Can't open %s!", tmp_file); + goto GL_EXIF_FAILED; + } + + /* Add raw EXIF header data */ + if (__gl_exif_add_header(tmp_fd, orientation) < 0) + goto GL_EXIF_FAILED; + + size_t r_size = 0; + /* Remove start of JPEG image data section, 20 bytes */ + r_size = fread(tmp, sizeof(char), 20, fd); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write JPEG image data from first 0xFF to tmp file after EXIF header */ + while ((r_size = fread(tmp, 1, sizeof(tmp), fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, tmp_fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + fclose(fd); + fd = fopen(file_path, "wb"); + if (!fd) { + gl_dbgE("Error creating file %s!", file_path); + goto GL_EXIF_FAILED; + } + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write back tmp file after to JPEG image */ + fseek(tmp_fd, 0, SEEK_SET); + while ((r_size = fread(tmp, 1, sizeof(tmp), tmp_fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + ret = 0; + + GL_EXIF_FAILED: + + if (fd) + fclose(fd); + if (tmp_fd) + fclose(tmp_fd); + + /* Delete tmp file */ + if (!ecore_file_unlink(tmp_file)) + gl_dbgE("Delete file failed"); + + gl_dbg("All done"); + return ret; +} + +/* Add exif to jfif 1.01, older version, don't have exif */ +static int __gl_exif_rw_jfif_1dot01(char *file_path, unsigned int *orientation) +{ + GL_CHECK_VAL(orientation, -1); + GL_CHECK_VAL(file_path, -1); + unsigned char tmp[GL_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + + if ((fd = fopen(file_path, "rb+")) == NULL) { + gl_dbgE("Can't open %s!", file_path); + return -1; + } + + char *tmp_file = GL_EXI_TMP_JPEG_FILE; + FILE *tmp_fd = NULL; + if ((tmp_fd = fopen(tmp_file, "wb+")) == NULL) { + gl_dbgE("Can't open %s!", tmp_file); + goto GL_EXIF_FAILED; + } + + /* Add raw EXIF header data */ + if (__gl_exif_add_header(tmp_fd, orientation) < 0) + goto GL_EXIF_FAILED; + + size_t r_size = 0; + /* Remove start of JPEG image data section, 20 bytes */ + r_size = fread(tmp, sizeof(char), 20, fd); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write JPEG image data to tmp file after EXIF header */ + while ((r_size = fread(tmp, 1, sizeof(tmp), fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, tmp_fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + fclose(fd); + fd = fopen(file_path, "wb"); + if (!fd) { + gl_dbgE("Error creating file %s!", file_path); + goto GL_EXIF_FAILED; + } + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write back tmp file after to JPEG image */ + fseek(tmp_fd, 0, SEEK_SET); + while ((r_size = fread(tmp, 1, sizeof(tmp), tmp_fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + ret = 0; + + GL_EXIF_FAILED: + + if (fd) + fclose(fd); + if (tmp_fd) + fclose(tmp_fd); + + /* Delete tmp file */ + if (!ecore_file_unlink(tmp_file)) + gl_dbgE("Delete file failed"); + + gl_dbg("All done"); + return ret; +} + +/* Add exif to jfif 1.02, to add exif for some cases */ +static int __gl_exif_rw_jfif_1dot02(char *file_path, unsigned int *orientation) +{ + GL_CHECK_VAL(orientation, -1); + GL_CHECK_VAL(file_path, -1); + unsigned char tmp[GL_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + int tmp_exif = -1; + + if ((fd = fopen(file_path, "rb+")) == NULL) { + gl_dbgE("Can't open %s!", file_path); + return -1; + } + + char *tmp_file = GL_EXI_TMP_JPEG_FILE; + FILE *tmp_fd = NULL; + if ((tmp_fd = fopen(tmp_file, "wb+")) == NULL) { + gl_dbgE("Can't open %s!", tmp_file); + goto GL_EXIF_FAILED; + } + + /* Add raw EXIF header data */ + if (__gl_exif_add_header(tmp_fd, orientation) < 0) + goto GL_EXIF_FAILED; + + size_t r_size = 0; + /* Remove start of JPEG image data section, 20 bytes */ + r_size = fread(tmp, sizeof(char), 20, fd); + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write JPEG image data from first 0xFF to tmp file after EXIF header */ + while ((r_size = fread(tmp, 1, sizeof(tmp), fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, tmp_fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + fclose(fd); + fd = fopen(file_path, "wb"); + if (!fd) { + gl_dbgE("Error creating file %s!", file_path); + goto GL_EXIF_FAILED; + } + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write back tmp file after to JPEG image */ + fseek(tmp_fd, 0, SEEK_SET); + while ((r_size = fread(tmp, 1, sizeof(tmp), tmp_fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + ret = 0; + + GL_EXIF_FAILED: + + if (fd) + fclose(fd); + if (tmp_fd) + fclose(tmp_fd); + /* Delete tmp file */ + if (!ecore_file_unlink(tmp_file)) + gl_dbgE("Delete file failed"); + + gl_dbg("All done"); + return ret; +} +#endif + +/* Add orientation tag to jpegs which have exif tag but do not have orientation tag: include jfif and exif*/ +static int __gl_exif_add_orientation_tag(char *file_path, + unsigned int *orientation){ + + GL_CHECK_VAL(orientation, -1); + GL_CHECK_VAL(file_path, -1); + unsigned char tmp[GL_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + int tmp_exif = -1; + int i = 0; + unsigned int length = 0; + bool is_motorola = false; /* Flag for byte order */ + unsigned int offset = 0; + size_t r_size = 0; + const unsigned char ifd_data_format[13] = { + /*add 0 to ifd_data_format[0] ,for easy to use*/ + 0, + GL_EXIF_IFD_DATA_FORMAT_UNSIGNED_BYTE, + GL_EXIF_IFD_DATA_FORMAT_ASCII_STRINGS, + GL_EXIF_IFD_DATA_FORMAT_UNSIGNED_SHORT, + GL_EXIF_IFD_DATA_FORMAT_UNSIGNED_LONG, + GL_EXIF_IFD_DATA_FORMAT_UNSIGNED_RATIONAL, + GL_EXIF_IFD_DATA_FORMAT_SIGNED_BYTE, + GL_EXIF_IFD_DATA_FORMAT_UNDEFINED, + GL_EXIF_IFD_DATA_FORMAT_SIGNED_SHORT, + GL_EXIF_IFD_DATA_FORMAT_SIGNED_LONG, + GL_EXIF_IFD_DATA_FORMAT_SIGNED_RATIONAL, + GL_EXIF_IFD_DATA_FORMAT_SIGNED_FLOAT, + GL_EXIF_IFD_DATA_FORMAT_DOUBLE_FLOAT + + }; + + if ((fd = fopen(file_path, "rb+")) == NULL) { + gl_dbgE("Can't open %s!", file_path); + return -1; + } + + char *tmp_file = GL_EXI_TMP_JPEG_FILE; + FILE *tmp_fd = NULL; + if ((tmp_fd = fopen(tmp_file, "wb+")) == NULL) { + gl_dbgE("Can't open %s!", tmp_file); + goto GL_EXIF_FAILED; + } + /* Find APP1 */ + bool b_tag_ff = false; + while(1){ + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + /*copy data from jpeg to tmp_fd (from "FF D8" to " FF E1",because those data we needn't modify)*/ + if (__gl_exif_write_1_byte(tmp_fd, tmp_exif) < 0) + goto GL_EXIF_FAILED; + + tmp[0] = (unsigned char)tmp_exif; + + gl_dbg("- %02X", tmp[0]); + if (!b_tag_ff) { + /* Get first tag */ + if (tmp[0] == GL_EXIF_TAG) { + gl_dbgW("0xFF!"); + b_tag_ff = true; + } + continue; + } + + /* Get APP1 */ + if (tmp[0] == GL_EXIF_APP1) { + gl_dbgW("Exif in APP1!"); + break; + } else { + gl_dbgW("0x%02X!",tmp[0]); + b_tag_ff = false; + } + } + + /* Get the marker parameter length count */ + if (__gl_exif_read_2_bytes(fd, &length) < 0) + goto GL_EXIF_FAILED; + gl_dbg("length: %d", length); + /* Length includes itself, so must be at least 2 + Following Exif data length must be at least 6 */ + if (length < 8) { + gl_dbgE("length < 8"); + goto GL_EXIF_FAILED; + } + /*modify the marker parameter length, orientation tag is 12*/ + length += 12; + gl_dbgW("modified length: %d", length); + tmp[0] =( length >> 8 )& 0xff ; + tmp[1] = length & 0xff ; + for(i = 0; i < 2; i++){ + if (__gl_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GL_EXIF_FAILED; + } + + for (i = 0; i < 6; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + gl_dbg("- %02X", tmp[i]); + if (__gl_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GL_EXIF_FAILED; + } + if (tmp[0] == 0x45 && tmp[1] == 0x78 && tmp[2] == 0x69 && tmp[3] == 0x66 && + tmp[4] == 0x00 && tmp[5] == 0x00) { + gl_dbgW("Met Exif!"); + } else { + gl_dbgW("Not met Exif!"); + goto GL_EXIF_FAILED; + } + /* Read Exif body */ + for (i = 0; i < 4; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + tmp[i] = (unsigned char)tmp_exif; + if (__gl_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GL_EXIF_FAILED; + } + + /* Check byte order and Tag Mark , "II(0x4949)" or "MM(0x4d4d)" */ + if (tmp[0] == 0x49 && tmp[1] == 0x49 && tmp[2] == 0x2A && + tmp[3] == 0x00) { + gl_dbg("Intel"); + is_motorola = false; + } else if (tmp[0] == 0x4D && tmp[1] == 0x4D && tmp[2] == 0x00 && + tmp[3] == 0x2A) { + gl_dbg("Motorola"); + is_motorola = true; + } else { + goto GL_EXIF_FAILED; + } + + for (i = 0; i < 4; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + gl_dbg("- %02X", tmp[i]); + if (__gl_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GL_EXIF_FAILED; + } + + /* Get first IFD offset (offset to IFD0) , MM-08000000, II-00000008 */ + if (is_motorola) { + if (tmp[0] != 0 && tmp[1] != 0) + goto GL_EXIF_FAILED; + offset = tmp[2]; + offset <<= 8; + offset += tmp[3]; + } else { + if (tmp[3] != 0 && tmp[2] != 0) + goto GL_EXIF_FAILED; + offset = tmp[1]; + offset <<= 8; + offset += tmp[0]; + } + gl_dbg("offset: %d", offset); + /*if offset >8, copy data from there to IFD start position*/ + if(offset > 8){ + for (i = 0; i < (offset - 8); i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + gl_dbg("- %02X", tmp[i]); + if (__gl_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GL_EXIF_FAILED; + } + } + + /* IFD: Image File Directory */ + /* Get the number of directory entries contained in this IFD, - 2 bytes, EE */ + unsigned int tags_cnt = 0; + for (i = 0; i < 2; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + } + if (is_motorola) { + tags_cnt = tmp[0]; + tags_cnt <<= 8; + tags_cnt += tmp[1]; + } else { + tags_cnt = tmp[1]; + tags_cnt <<= 8; + tags_cnt += tmp[0]; + } + gl_dbg("tags_cnt: %d", tags_cnt); + /*modify tags num,add orientation tag */ + tags_cnt += 1; + gl_dbg("modified tags_cnt: %d", tags_cnt); + if (is_motorola) { + tmp[0] = (tags_cnt >> 8) & 0xff; + tmp[1] = tags_cnt & 0xff; + } else { + tmp[0] = tags_cnt & 0xff; + tmp[1] = (tags_cnt >> 8) & 0xff; + } + for (i = 0; i < 2; i++) { + gl_dbg("modified- %02X", tmp[i]); + if (__gl_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GL_EXIF_FAILED; + + } + /* Add Orientation Tag in IFD0 */ + unsigned int tag_num = 0; + unsigned char orientation_tag[12] = { 0, }; + bool b_found_position = false; + int j = 0; + unsigned int data_type = 0; + unsigned int unit_num = 0; + unsigned int data_length = 0; + unsigned int offset_value = 0; + /*initialize orientation_tag value*/ + if (is_motorola) { + orientation_tag[0] = 0x01; + orientation_tag[1] = 0x12; + + orientation_tag[2] = 0x00; + orientation_tag[3] = 0x03; + + orientation_tag[4] = 0x00; + orientation_tag[5] = 0x00; + orientation_tag[6] = 0x00; + orientation_tag[7] = 0x01; + + orientation_tag[8] = 0x00; + orientation_tag[9] = (unsigned char)(*orientation); + orientation_tag[10] = 0x00; + orientation_tag[11] = 0x00; + + } else { + orientation_tag[0] = 0x12; + orientation_tag[1] = 0x01; + orientation_tag[2] = 0x03; + orientation_tag[3] = 0x00; + orientation_tag[4] = 0x01; + orientation_tag[5] = 0x00; + orientation_tag[6] = 0x00; + orientation_tag[7] = 0x00; + orientation_tag[8] = (unsigned char)(*orientation); + orientation_tag[9] = 0x00; + orientation_tag[10] = 0x00; + orientation_tag[11] = 0x00; + } + /*if there is no other tag, then only insert orientation_tag,don't go to the while(1)*/ + if(tags_cnt == 1) { + for(j = 0; j < 12 ;j++){ + gl_dbg("orientation_tag- %02X", orientation_tag[j]); + if (__gl_exif_write_1_byte(tmp_fd, orientation_tag[j]) < 0) + goto GL_EXIF_FAILED; + } + + } + while(1){ + if (--tags_cnt == 0) { + break; + } + + /* Every directory entry size is 12 */ + for (i = 0; i < 12; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + } + /* Get Tag number */ + if (is_motorola) { + tag_num = tmp[0]; + tag_num <<= 8; + tag_num += tmp[1]; + } else { + tag_num = tmp[1]; + tag_num <<= 8; + tag_num += tmp[0]; + } + gl_dbgW("tag num %02X!" , tag_num); + /* to find Orientation Tag position */ + if (tag_num < 0x0112) { + + } else if (tag_num > 0x0112){ + if(!b_found_position){ + for(j = 0; j < 12 ;j++){ + gl_dbg("orientation_tag- %02X", orientation_tag[j]); + if (__gl_exif_write_1_byte(tmp_fd, orientation_tag[j]) < 0) + goto GL_EXIF_FAILED; + } + b_found_position = true; + } + if (is_motorola) { + data_type = tmp[2]; + data_type <<= 8; + data_type += tmp[3]; + + unit_num = tmp[4]; + unit_num <<= 8; + unit_num += tmp[5]; + unit_num <<= 8; + unit_num += tmp[6]; + unit_num <<= 8; + unit_num += tmp[7]; + } else { + data_type = tmp[3]; + data_type <<= 8; + data_type += tmp[2]; + + unit_num = tmp[7]; + unit_num <<= 8; + unit_num += tmp[6]; + unit_num <<= 8; + unit_num += tmp[5]; + unit_num <<= 8; + unit_num += tmp[4]; + } + gl_dbgW("data_type %02X!" , data_type); + gl_dbgW("unit_num %02X!" , unit_num); + if((data_type < 1) ||(data_type > 12)){ + gl_dbgE("Wrong data type!"); + goto GL_EXIF_FAILED; + } + + data_length = ifd_data_format[data_type] * unit_num; + gl_dbgW("data_length %02X!" , data_length); + /*data_length >4 ,next 4 bytes store the offset, so need to modify the offset*/ + if(data_length > 4){ + if (is_motorola) { + offset_value = tmp[8]; + offset_value <<= 8; + offset_value += tmp[9]; + offset_value <<= 8; + offset_value += tmp[10]; + offset_value <<= 8; + offset_value += tmp[11]; + gl_dbgW("offset_value %02X!" , offset_value); + /*add orientation offset*/ + offset_value += 12; + gl_dbgW("changed offset_value %02X!" , offset_value); + tmp[8] = (offset_value >> 24) & 0xff; + tmp[9] = (offset_value >> 16) & 0xff; + tmp[10] = (offset_value >> 8) & 0xff; + tmp[11] = offset_value & 0xff; + gl_dbg("tmp[8] %02X!" , tmp[8]); + gl_dbg("tmp[9] %02X!" , tmp[9]); + gl_dbg("tmp[10] %02X!" , tmp[10]); + gl_dbg("tmp[11] %02X!" , tmp[11]); + } else { + offset_value = tmp[11]; + offset_value <<= 8; + offset_value += tmp[10]; + offset_value <<= 8; + offset_value += tmp[9]; + offset_value <<= 8; + offset_value += tmp[8]; + gl_dbgW("offset_value %02X!" , offset_value); + /*add orientation offset*/ + offset_value += 12; + gl_dbgW("changed offset_value %02X!" , offset_value); + + tmp[11] = (offset_value >> 24) & 0xff; + tmp[10] = (offset_value >> 16) & 0xff; + tmp[9] = (offset_value >> 8) & 0xff; + tmp[8] = offset_value & 0xff; + gl_dbg("tmp[8] %02X!" , tmp[8]); + gl_dbg("tmp[9] %02X!" , tmp[9]); + gl_dbg("tmp[10] %02X!" , tmp[10]); + gl_dbg("tmp[11] %02X!" , tmp[11]); + + } + + } + + } + for(i = 0; i < 12 ;i++){ + gl_dbg("- %02X", tmp[i]); + if (__gl_exif_write_1_byte(tmp_fd,tmp[i]) < 0) + goto GL_EXIF_FAILED; + + } + memset(tmp, 0x00, 12); + + } + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write JPEG image data to tmp file after EXIF header */ + while ((r_size = fread(tmp, 1, sizeof(tmp), fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, tmp_fd) != r_size) + gl_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + fclose(fd); + fd = NULL; + fd = fopen(file_path, "wb"); + if (!fd) { + gl_dbgE("Error creating file %s!", file_path); + goto GL_EXIF_FAILED; + } + + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + /* Write back tmp file after to JPEG image */ + fseek(tmp_fd, 0, SEEK_SET); + while ((r_size = fread(tmp, 1, sizeof(tmp), tmp_fd)) > 0) { + gl_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, fd) != r_size) + gl_dbgW("Write and read size are diff!"); + memset(tmp, 0x00, GL_EXIF_BUF_LEN_MAX); + } + + ret = 0; + + GL_EXIF_FAILED: + + if (fd){ + fclose(fd); + fd = NULL; + } + + if (tmp_fd){ + fclose(tmp_fd); + tmp_fd = NULL; + } + + /* Delete tmp file */ + if (!ecore_file_unlink(tmp_file)) + gl_dbgE("Delete file failed"); + + gl_dbg("All done"); + return ret; +} + +static int __gl_exif_rw_jfif(FILE *fd, char *file_path, + unsigned int *orientation, bool b_write) +{ + GL_CHECK_VAL(fd, -1); + GL_CHECK_VAL(file_path, -1); + GL_CHECK_VAL(orientation, -1); + unsigned char tmp[GL_EXIF_BUF_LEN_MAX] = { 0, }; + int i = 0; + unsigned int length = 0; + int tmp_exif = -1; + bool is_motorola = false; /* Flag for byte order */ + unsigned int offset = 0; + int ret = -1; + /*unsigned char version = 0x00; */ + + if (__gl_exif_read_2_bytes(fd, &length) < 0) + goto GL_EXIF_FAILED; + gl_dbg("length: %d", length); + + for (i = 0; i < 5; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + tmp[i] = (unsigned char)tmp_exif; + } + + /* JFIF0 */ + if (tmp[0] != 0x4A || tmp[1] != 0x46 || tmp[2] != 0x49 || + tmp[3] != 0x46 || tmp[4] != 0x00) { + gl_dbgE("Not met Jfif!"); + goto GL_EXIF_FAILED; + } + + for (i = 0; i < 2; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + tmp[i] = (unsigned char)tmp_exif; + } + + /* Check JFIF version */ + if (tmp[0] == 0x01 && tmp[1] == GL_EXIF_JFIF_00) { + gl_dbg("Jfif 1.00"); + } else if (tmp[0] == 0x01 && tmp[1] == GL_EXIF_JFIF_01) { + gl_dbg("Jfif 1.01"); + } else if (tmp[0] == 0x01 && tmp[1] == GL_EXIF_JFIF_02) { + gl_dbg("Jfif 1.02"); + } else { + gl_dbgE("Unknow Jfif version[%d.%d]!", tmp[0], tmp[1]); + goto GL_EXIF_FAILED; + } + + /* Save version */ + /*version = tmp[1]; */ + + /* Find APP1 */ + bool b_tag_ff = false; + while(1) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[0] = (unsigned char)tmp_exif; + + gl_dbg("- %02X", tmp[0]); + if (!b_tag_ff) { + /* Get first tag */ + if (tmp[0] == GL_EXIF_TAG) { + gl_dbgW("0xFF!"); + b_tag_ff = true; + } + continue; + } + + /* Get APP1 */ + if (tmp[0] == GL_EXIF_APP1) { + gl_dbgW("Exif in APP1!"); + break; + } + + gl_dbgW("No Exif in APP1!"); + + /* Close file */ + fclose(fd); + if (!b_write) { + /* Normal orientation = 0degree = 1 */ + *orientation = 1; + return -1; + } + return __gl_exif_add_exif_to_jfif(file_path, orientation); +#if 0 + if (version == GL_EXIF_JFIF_00) { + return __gl_exif_rw_jfif_1dot00(file_path, orientation); + } else if (version == GL_EXIF_JFIF_01) { + return __gl_exif_rw_jfif_1dot01(file_path, orientation); + } else { + return __gl_exif_rw_jfif_1dot02(file_path, orientation); + } +#endif + } + + /* Find Exif */ + while(1) { + for (i = 0; i < 6; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) { + gl_dbgW("Not met Exif!"); + goto GL_EXIF_FAILED; + } + + tmp[i] = (unsigned char)tmp_exif; + gl_dbg("- %02X", tmp[i]); + } + if (tmp[0] == 0x45 && tmp[1] == 0x78 && tmp[2] == 0x69 && tmp[3] == 0x66 && + tmp[4] == 0x00 && tmp[5] == 0x00) { + gl_dbgW("Met Exif!"); + break; + } else { + gl_dbg("Not met Exif!"); + fseek(fd, -5, SEEK_CUR); + continue; + } + } + + /* Read Exif body */ + for (i = 0; i < 4; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + tmp[i] = (unsigned char)tmp_exif; + } + + /* Check byte order and Tag Mark , "II(0x4949)" or "MM(0x4d4d)" */ + if (tmp[0] == 0x49 && tmp[1] == 0x49 && tmp[2] == 0x2A && + tmp[3] == 0x00) { + gl_dbg("Intel"); + is_motorola = false; + } else if (tmp[0] == 0x4D && tmp[1] == 0x4D && tmp[2] == 0x00 && + tmp[3] == 0x2A) { + gl_dbg("Motorola"); + is_motorola = true; + } else { + goto GL_EXIF_FAILED; + } + + for (i = 0; i < 4; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + gl_dbg("- %02X", tmp[i]); + } + + /* Get first IFD offset (offset to IFD0) , MM-08000000, II-00000008 */ + if (is_motorola) { + if (tmp[0] != 0 && tmp[1] != 0) + goto GL_EXIF_FAILED; + offset = tmp[2]; + offset <<= 8; + offset += tmp[3]; + } else { + if (tmp[3] != 0 && tmp[2] != 0) + goto GL_EXIF_FAILED; + offset = tmp[1]; + offset <<= 8; + offset += tmp[0]; + } + gl_dbg("offset: %d", offset); + + /* IFD: Image File Directory */ + /* Get the number of directory entries contained in this IFD, - 2 bytes, EE */ + unsigned int tags_cnt = 0; + for (i = 0; i < 2; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + } + if (is_motorola) { + tags_cnt = tmp[0]; + tags_cnt <<= 8; + tags_cnt += tmp[1]; + } else { + tags_cnt = tmp[1]; + tags_cnt <<= 8; + tags_cnt += tmp[0]; + } + gl_dbg("tags_cnt: %d", tags_cnt); + if (tags_cnt == 0) { + gl_dbgE("tags_cnt == 0,no found orientation tag!"); + if (b_write) { + gl_dbgW("to add an orientation tag!"); + fclose(fd); + fd = NULL; + return __gl_exif_add_orientation_tag(file_path, orientation); + + } else{ + /* Normal orientation = 0degree = 1 */ + *orientation = 1; + ret = -1; + } + goto GL_EXIF_FAILED; + } + + /* Search for Orientation Tag in IFD0 */ + unsigned int tag_num = 0; + while (1) { + /* Every directory entry size is 12 */ + for (i = 0; i < 12; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + } + /* Get Tag number */ + if (is_motorola) { + tag_num = tmp[0]; + tag_num <<= 8; + tag_num += tmp[1]; + } else { + tag_num = tmp[1]; + tag_num <<= 8; + tag_num += tmp[0]; + } + /* found Orientation Tag */ + if (tag_num == 0x0112) { + gl_dbgW("Found orientation tag!"); + break; + } + if (--tags_cnt == 0) { + gl_dbgW("tags_cnt == 0, no found orientation tag!"); + if (b_write) { + gl_dbgW("to add an orientation tag!"); + fclose(fd); + fd = NULL; + return __gl_exif_add_orientation_tag(file_path, orientation); + + } else{ + /* Normal orientation = 0degree = 1 */ + *orientation = 1; + ret = -1; + } + goto GL_EXIF_FAILED; + } + } + + /* |TT|ff|NNNN|DDDD| --- TT - 2 bytes, tag NO. ;ff - 2 bytes, data format + NNNN - 4 bytes, entry count; DDDD - 4 bytes Data value */ + if (b_write) { + gl_dbg("Write: %d", *orientation); + /* Set the Orientation value */ + if (is_motorola) + tmp[9] = (unsigned char)(*orientation); + else + tmp[8] = (unsigned char)(*orientation); + + /* Move pointer back to the entry start point */ + if (fseek(fd, -12, SEEK_CUR) < 0) { + gl_dbgE("fseek failed!"); + goto GL_EXIF_FAILED; + } + fwrite(tmp, 1, 10, fd); + } else { + /* Get the Orientation value */ + if (is_motorola) { + if (tmp[8] != 0) { + gl_dbgE("tmp[8] != 0"); + goto GL_EXIF_FAILED; + } + *orientation = (unsigned int)tmp[9]; + } else { + if (tmp[9] != 0) { + gl_dbgE("tmp[9] != 0"); + goto GL_EXIF_FAILED; + } + *orientation = (unsigned int)tmp[8]; + } + if (*orientation > 8) { + gl_dbgE("*orient > 8"); + goto GL_EXIF_FAILED; + } + gl_dbg("Read: %d", *orientation); + } + + ret = 0; + + GL_EXIF_FAILED: + + fclose(fd); + gl_dbg("All done"); + return ret; +} +bool _gl_exif_check_img_type(char *file_path) +{ + GL_CHECK_VAL(file_path, -1); + int tmp_exif = -1; + unsigned int i = 0; + unsigned char exif_data[4] = { 0, }; + FILE *fd = NULL; + bool ret = false; + + if ((fd = fopen(file_path, "rb")) == NULL) { + gl_dbgE("Can't open %s!", file_path); + return -1; + } + + /* Read File head, check for JPEG SOI + Exif APP1 */ + for (i = 0; i < 4; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + exif_data[i] = (unsigned char)tmp_exif; + } + + if (exif_data[0] == GL_EXIF_TAG && exif_data[1] == GL_EXIF_SOI) { + gl_dbg("JPEG file"); + } else { + gl_dbgE("Not a JPEG file!"); + goto GL_EXIF_FAILED; + } + + if (exif_data[2] == GL_EXIF_TAG && exif_data[3] == GL_EXIF_APP1) { + gl_dbgW("Exif in APP1!"); + ret = true; + } else if (exif_data[2] == GL_EXIF_TAG && + exif_data[3] == GL_EXIF_APP0) { + gl_dbgW("Jfif in APP0!"); + ret = true; + } else { + gl_dbgE("Not a Exif in APP1 or Jiff in APP2[%d]!", exif_data[3]); + ret = false; + } + GL_EXIF_FAILED: + + fclose(fd); + gl_dbg(""); + return ret; +} + +static int __gl_exif_rw_orient(char *file_path, unsigned int *orient, bool b_write) +{ + GL_CHECK_VAL(file_path, -1); + gl_dbg("b_write: %d", b_write); + unsigned int length = 0; + unsigned int i = 0; + bool is_motorola = false; /* Flag for byte order */ + unsigned int offset = 0; + unsigned int jfif_offset = 0; + unsigned int tags_cnt = 0; + unsigned int tag_num = 0; + int tmp_exif = -1; + unsigned char exif_data[GL_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + + if (b_write) { + if ((fd = fopen(file_path, "rb+")) == NULL) { + gl_dbgE("Can't open %s!", file_path); + return -1; + } + } else { + if ((fd = fopen(file_path, "rb")) == NULL) { + gl_dbgE("Can't open %s!", file_path); + return -1; + } + } + + /* Read File head, check for JPEG SOI + Exif APP1 */ + for (i = 0; i < 4; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + exif_data[i] = (unsigned char)tmp_exif; + } + + if (exif_data[0] == GL_EXIF_TAG && exif_data[1] == GL_EXIF_SOI) { + gl_dbg("JPEG file"); + } else { + gl_dbgE("Not a JPEG file!"); + goto GL_EXIF_FAILED; + } + + if (exif_data[2] == GL_EXIF_TAG && exif_data[3] == GL_EXIF_APP1) { + gl_dbgW("Exif in APP1!"); + } else if (exif_data[2] == GL_EXIF_TAG && + exif_data[3] == GL_EXIF_APP0) { + gl_dbgW("Jfif in APP0!"); + int ret = __gl_exif_rw_jfif(fd, file_path, orient, b_write); + return ret; + } else { + gl_dbgE("Not a Exif in APP1 or Jiff in APP2[%d]!", exif_data[3]); + goto GL_EXIF_FAILED; + } + + /* Get the marker parameter length count */ + if (__gl_exif_read_2_bytes(fd, &length) < 0) + goto GL_EXIF_FAILED; + gl_dbg("length: %d", length); + /* Length includes itself, so must be at least 2 + Following Exif data length must be at least 6 */ + if (length < 8) { + gl_dbgE("length < 8"); + goto GL_EXIF_FAILED; + } + length -= 8; + + /* Length of an IFD entry */ + if (length < 12) { + gl_dbgE("length < 12"); + goto GL_EXIF_FAILED; + } + + /* Read Exif head, check for "Exif" */ + for (i = 0; i < 6; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + + exif_data[i] = (unsigned char)tmp_exif; + gl_dbg("- %02X", exif_data[i]); + } + + if (exif_data[0] != 0x45 || exif_data[1] != 0x78 || + exif_data[2] != 0x69 || exif_data[3] != 0x66 || + exif_data[4] != 0x00 || exif_data[5] != 0x00) { + gl_dbgE("Not met Exif!"); + goto GL_EXIF_FAILED; + } + + /* Read Exif body */ + for (i = 0; i < length; i++) { + tmp_exif = __gl_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GL_EXIF_FAILED; + exif_data[i] = (unsigned char)tmp_exif; + } + + /* Check byte order and Tag Mark , "II(0x4949)" or "MM(0x4d4d)" */ + if (exif_data[0] == 0x49 && exif_data[1] == 0x49 && + exif_data[2] == 0x2A && exif_data[3] == 0x00) { + gl_dbg("Intel"); + is_motorola = false; + } else if (exif_data[0] == 0x4D && exif_data[1] == 0x4D && + exif_data[2] == 0x00 && exif_data[3] == 0x2A) { + gl_dbg("Motorola"); + is_motorola = true; + } else { + goto GL_EXIF_FAILED; + } + + /* Get first IFD offset (offset to IFD0) , MM-00000008, II-08000000 */ + if (is_motorola) { + if (exif_data[4] != 0 && exif_data[5] != 0) + goto GL_EXIF_FAILED; + offset = exif_data[6]; + offset <<= 8; + offset += exif_data[7]; + } else { + if (exif_data[7] != 0 && exif_data[6] != 0) + goto GL_EXIF_FAILED; + offset = exif_data[5]; + offset <<= 8; + offset += exif_data[4]; + } + /* check end of data segment */ + if (offset > length - 2) { + gl_dbgE("offset > length - 2"); + goto GL_EXIF_FAILED; + } + + /* IFD: Image File Directory */ + /* Get the number of directory entries contained in this IFD, - EEEE */ + if (is_motorola) { + tags_cnt = exif_data[offset]; + tags_cnt <<= 8; + tags_cnt += exif_data[offset+1]; + } else { + tags_cnt = exif_data[offset+1]; + tags_cnt <<= 8; + tags_cnt += exif_data[offset]; + } + if (tags_cnt == 0) { + gl_dbgE("tags_cnt == 0 - 2"); + goto GL_EXIF_FAILED; + } + offset += 2; + + /* check end of data segment */ + if (offset > length - 12) { + gl_dbgE("offset > length - 12"); + goto GL_EXIF_FAILED; + } + + /* Search for Orientation Tag in IFD0 */ + while (1) { + /* Get Tag number */ + if (is_motorola) { + tag_num = exif_data[offset]; + tag_num <<= 8; + tag_num += exif_data[offset+1]; + } else { + tag_num = exif_data[offset+1]; + tag_num <<= 8; + tag_num += exif_data[offset]; + } + /* found Orientation Tag */ + if (tag_num == 0x0112) { + gl_dbgW("Found orientation tag!"); + break; + } + if (--tags_cnt == 0) { + gl_dbgW("tags_cnt == 0, no found orientation tag!"); + if (b_write) { + gl_dbgW("to add an orientation tag!"); + fclose(fd); + fd = NULL; + return __gl_exif_add_orientation_tag(file_path, orient); + + } else{ + /* Normal orientation = 0degree = 1 */ + *orient = 1; + ret = -1; + } + goto GL_EXIF_FAILED; + } + + /* Every directory entry size is 12 */ + offset += 12; + } + + if (b_write) { + gl_dbg("Write: %d", *orient); + /* Set the Orientation value */ + if (is_motorola) + exif_data[offset+9] = (unsigned char)(*orient); + else + exif_data[offset+8] = (unsigned char)(*orient); + + if (fseek(fd, jfif_offset + (4 + 2 + 6 + 2) + offset, SEEK_SET) < 0) { + gl_dbgE("fseek failed!"); + goto GL_EXIF_FAILED; + } + fwrite(exif_data + 2 + offset, 1, 10, fd); + } else { + /* Get the Orientation value */ + if (is_motorola) { + if (exif_data[offset+8] != 0) { + gl_dbgE("exif_data[offset+8] != 0"); + goto GL_EXIF_FAILED; + } + *orient = (unsigned int)exif_data[offset+9]; + } else { + if (exif_data[offset+9] != 0) { + gl_dbgE("exif_data[offset+9] != 0"); + goto GL_EXIF_FAILED; + } + *orient = (unsigned int)exif_data[offset+8]; + } + if (*orient > 8) { + gl_dbgE("*orient > 8"); + goto GL_EXIF_FAILED; + } + gl_dbg("Read: %d", *orient); + } + + ret = 0; + + GL_EXIF_FAILED: + + fclose(fd); + gl_dbg("All done"); + return ret; +} + +int _gl_exif_get_orientation(char *file_path, unsigned int *orientation) +{ + GL_CHECK_VAL(orientation, -1); + GL_CHECK_VAL(file_path, -1); + gl_dbg("file_path: %s", file_path); + + return __gl_exif_rw_orient(file_path, orientation, false); +} + +int _gl_exif_set_orientation(char *file_path, unsigned int orientation) +{ + GL_CHECK_VAL(file_path, -1); + gl_dbg("file_path: %s", file_path); + + return __gl_exif_rw_orient(file_path, &orientation, true); +} + +int _gl_exif_get_rotated_orientation(unsigned int orientation, bool b_left) +{ + int rotated_orientataion; + gl_dbg("b_left: %d", b_left); + + switch (orientation){ + case GL_ORIENTATION_ROT_0: + /* true: 0 -> 270, false: 0 -> 90 */ + if (b_left) + rotated_orientataion = GL_ORIENTATION_ROT_270; + else + rotated_orientataion = GL_ORIENTATION_ROT_90; + break; + case GL_ORIENTATION_ROT_90: + /* true: 90 -> 0, false: 90 -> 180 */ + if (b_left) + rotated_orientataion = GL_ORIENTATION_ROT_0; + else + rotated_orientataion = GL_ORIENTATION_ROT_180; + break; + case GL_ORIENTATION_ROT_180: + /* true: 180 -> 90, false: 180 -> 270 */ + if (b_left) + rotated_orientataion = GL_ORIENTATION_ROT_90; + else + rotated_orientataion = GL_ORIENTATION_ROT_270; + break; + case GL_ORIENTATION_ROT_270: + /* true: 270 -> 180, false: 270 -> 0 */ + if (b_left) + rotated_orientataion = GL_ORIENTATION_ROT_180; + else + rotated_orientataion = GL_ORIENTATION_ROT_0; + break; + default: + gl_dbgE("Wrong oriectation: %d!", orientation); + /* true: 0 -> 270, false: 0 -> 90 */ + if (b_left) + rotated_orientataion = GL_ORIENTATION_ROT_270; + else + rotated_orientataion = GL_ORIENTATION_ROT_90; + break; + } + + gl_dbg("New orientation: %d", rotated_orientataion); + return rotated_orientataion; +} + +#endif + diff --git a/src/util/gl-ext-exec.c b/src/util/gl-ext-exec.c new file mode 100755 index 0000000..ca87675 --- /dev/null +++ b/src/util/gl-ext-exec.c @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "gl-drm.h" +#include "gl-ext-exec.h" +#include "gl-debug.h" +#include "gallery.h" +#include "gl-data.h" +#include "gl-util.h" +#include "gl-popup.h" +#include "gl-controlbar.h" +#include "gl-strings.h" + +#define GL_APP_PKG_VIDEOPLAYER "org.tizen.video-player" +#define GL_APP_PKG_CAMERA "org.tizen.camera-app" + +#define GL_ARGV_VIDEO_LIST_TYPE "video_list_type" +#define GL_ARGV_VIDEO_ALL_FOLDER_VIDEO "all_folder_video" +#define GL_ARGV_VIDEO_FOLDER "folder" +#define GL_ARGV_VIDEO_LIST_FAVORITE "favorite" +#define GL_ARGV_VIDEO_TAG_VIDEO "tag_video" +#define GL_ARGV_VIDEO_TAG_NAME "tag_name" + +#define GL_ARGV_VIDEO_ORDER_TYPE "order_type" +#define GL_ARGV_VIDEO_ORDER_DATE_DESC "date_desc" +#define GL_ARGV_VIDEO_START_POS "start_pos_time" + +#define GL_ARGV_VIDEO_LAUNCH_APP "launching_application" +#define GL_ARGV_VIDEO_LAUNCH_GALLERY "gallery" + +#define GL_ARGV_PATH "path" + +//refer to imageviewer +static int __gl_ext_launch_video_player(void *data, service_h service) +{ + GL_CHECK_VAL(service, -1); + GL_CHECK_VAL(data, -1); + gl_item *gitem = (gl_item *)data; + GL_CHECK_VAL(gitem->ad, -1); + gl_appdata *ad = (gl_appdata *)gitem->ad; + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(gitem->item->uuid, -1); + GL_CHECK_VAL(gitem->item->file_url, -1); + + int last_pos = 0; + char last_pos_str[GL_INTERGER_LEN_MAX] = { 0, }; + + GL_CHECK_VAL(gitem->item->video_info, -1); + last_pos = gitem->item->video_info->last_played_pos; + eina_convert_itoa(last_pos, last_pos_str); + gl_dbg("last_pos : %d", last_pos); + + const char *video_path = gitem->item->file_url; + + bool file_is_drm = gl_drm_is_drm_file(video_path); + + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + /* Tag view */ + gl_dbg("Tags view"); + gl_tag *current_tag = ad->taginfo.current_tag; + if (current_tag && current_tag->tag && current_tag->tag->tag_name) { + gl_dbg("Current tag: %s", current_tag->tag->tag_name); + if (current_tag->tag->_id == GL_TAG_FAVORITES_ID) { + gl_dbg("Favourite tag"); + service_add_extra_data(service, + GL_ARGV_VIDEO_LIST_TYPE, + GL_ARGV_VIDEO_LIST_FAVORITE); + service_add_extra_data(service, + GL_ARGV_VIDEO_ORDER_TYPE, + GL_ARGV_VIDEO_ORDER_DATE_DESC); + service_add_extra_data(service, + GL_ARGV_VIDEO_LAUNCH_APP, + GL_ARGV_VIDEO_LAUNCH_GALLERY); + service_add_extra_data(service, + GL_ARGV_VIDEO_START_POS, + last_pos_str); + } else { + gl_dbg("Normal tag"); + service_add_extra_data(service, + GL_ARGV_VIDEO_LIST_TYPE, + GL_ARGV_VIDEO_TAG_VIDEO); + service_add_extra_data(service, + GL_ARGV_VIDEO_TAG_NAME, + current_tag->tag->tag_name); + service_add_extra_data(service, + GL_ARGV_VIDEO_ORDER_TYPE, + GL_ARGV_VIDEO_ORDER_DATE_DESC); + service_add_extra_data(service, + GL_ARGV_VIDEO_LAUNCH_APP, + GL_ARGV_VIDEO_LAUNCH_GALLERY); + service_add_extra_data(service, + GL_ARGV_VIDEO_START_POS, + last_pos_str); + } + } else { + /* Fixme: return or not? */ + gl_dbgE("Invalid current tag, return?"); + } + } else { + /* Albums view */ + gl_cluster *cur_cluster = ad->albuminfo.current_album; + if (cur_cluster && cur_cluster->cluster) { + gl_dbg("Album: %s", cur_cluster->cluster->display_name); + if (cur_cluster->cluster->type == GL_STORE_T_ALL) { + gl_dbg("All album"); + service_add_extra_data(service, + GL_ARGV_VIDEO_LIST_TYPE, + GL_ARGV_VIDEO_ALL_FOLDER_VIDEO); + service_add_extra_data(service, + GL_ARGV_VIDEO_ORDER_TYPE, + GL_ARGV_VIDEO_ORDER_DATE_DESC); + service_add_extra_data(service, + GL_ARGV_VIDEO_LAUNCH_APP, + GL_ARGV_VIDEO_LAUNCH_GALLERY); + service_add_extra_data(service, + GL_ARGV_VIDEO_START_POS, + last_pos_str); + } else if (cur_cluster->cluster->type == GL_STORE_T_PHONE || + cur_cluster->cluster->type == GL_STORE_T_MMC) { + gl_dbg("Real album"); + service_add_extra_data(service, + GL_ARGV_VIDEO_LIST_TYPE, + GL_ARGV_VIDEO_FOLDER); + service_add_extra_data(service, + GL_ARGV_VIDEO_ORDER_TYPE, + GL_ARGV_VIDEO_ORDER_DATE_DESC); + service_add_extra_data(service, + GL_ARGV_VIDEO_LAUNCH_APP, + GL_ARGV_VIDEO_LAUNCH_GALLERY); + service_add_extra_data(service, + GL_ARGV_VIDEO_START_POS, + last_pos_str); + } else { + gl_dbg("Web album? Under construction..."); + } + } else { + /* Fixme: return or not? */ + gl_dbgE("Invalid current album, return?"); + } + } + + int ret = 0; + if (file_is_drm) { + gl_dbg("DRM file."); + service_add_extra_data(service, GL_ARGV_PATH, video_path); + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + service_set_package(service, GL_APP_PKG_VIDEOPLAYER); + ret = service_send_launch_request(service, NULL, NULL); + } else { + gl_dbg("Not DRM file."); + service_add_extra_data(service, GL_ARGV_PATH, video_path); + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + service_set_package(service, GL_APP_PKG_VIDEOPLAYER); + ret = service_send_launch_request(service, NULL, NULL); + } + + if (ret == SERVICE_ERROR_NONE) + return 0; + else + return -1; +} + +static int __gl_ext_compose_exec_cmd(void *data, gl_ext_app_type type, + char *path, char **pkg_name, + service_h service) +{ + GL_CHECK_VAL(data, -1); + gl_dbg("type:%d, path:%s", type, path); + + switch (type) { + case GL_APP_VIDEOPLAYER: + GL_CHECK_VAL(path, -1); + *pkg_name = GL_APP_PKG_VIDEOPLAYER; + break; + default: + *pkg_name = NULL; + } + + return 0; +} + +static void __gl_ext_service_reply_cb(service_h request, service_h reply, + service_result_e result, void *user_data) +{ + gl_dbg(""); + switch(result) { + case SERVICE_RESULT_SUCCEEDED: + gl_dbg("SERVICE_RESULT_SUCCEEDED"); + break; + case SERVICE_RESULT_FAILED: + gl_dbg("SERVICE_RESULT_FAILED"); + break; + case SERVICE_RESULT_CANCELED: + gl_dbg("SERVICE_RESULT_CANCELED"); + break; + default: + gl_dbgE("Unhandled value: %d!", result); + break; + } +} + +static int __gl_ext_load(const char *operation, const char *pkg) +{ + gl_dbg("operation: %s, pkg: %s", operation, pkg); + int ret = -1; + int destroy_ret = -1; + service_h handle; + + ret = service_create(&handle); + if(ret != SERVICE_ERROR_NONE) { + gl_dbgE("service_create failed[%d]!", ret); + return GL_LAUNCH_FAIL; + } + + ret = service_set_operation(handle, operation); + if(ret != SERVICE_ERROR_NONE) { + gl_dbgE("service_set_operation [%s] failed[%d]!", operation, + ret); + goto GL_EXT_FAILED; + } + + if(pkg) { + ret = service_set_package(handle, pkg); + if(ret != SERVICE_ERROR_NONE) { + gl_dbgE("service_set_package [%s] failed[%d]!", pkg, + ret); + goto GL_EXT_FAILED; + } + } + + ret = service_send_launch_request(handle, __gl_ext_service_reply_cb, + NULL); + if(ret != SERVICE_ERROR_NONE) { + gl_dbgE("service_send_launch_request failed[%d]!", ret); + goto GL_EXT_FAILED; + } + + GL_EXT_FAILED: + destroy_ret = service_destroy(handle); + if(destroy_ret != SERVICE_ERROR_NONE) { + gl_dbgE("service_destroy failed[%d]!", destroy_ret); + return GL_LAUNCH_FAIL; + } + + return (ret == SERVICE_ERROR_NONE ? GL_LAUNCH_SUCCESS : GL_LAUNCH_FAIL); +} + +int gl_ext_exec(void *data, gl_ext_app_type type) +{ + GL_CHECK_VAL(data, -1); + gl_item *gitem = (gl_item *)data; + GL_CHECK_VAL(gitem->ad, -1); + gl_appdata *ad = (gl_appdata *)gitem->ad; + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(gitem->item->file_url, -1); + char *path = gitem->item->file_url; + service_h service = NULL; + char *pkg_name = NULL; + + if (ad->uginfo.app_called_by_me) { + gl_dbgE("APP launched, return!"); + return GL_LAUNCH_FAIL; + } + + service_create(&service); + GL_CHECK_VAL(service, GL_LAUNCH_FAIL); + + __gl_ext_compose_exec_cmd(ad, type, path, &pkg_name, service); + if (pkg_name == NULL) { + service_destroy(service); + return GL_LAUNCH_FAIL; + } + + int ret = 0; + if (type == GL_APP_VIDEOPLAYER) { + if (path == NULL) { + service_destroy(service); + return GL_LAUNCH_FAIL; + } + if (__gl_ext_launch_video_player(data, service) != 0) { + service_destroy(service); + return GL_LAUNCH_FAIL; + } + } else { + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + service_set_package(service, pkg_name); + ret = service_send_launch_request(service, NULL, NULL); + if (ret != SERVICE_ERROR_NONE) { + service_destroy(service); + gl_dbgE("service_send_launch_request failed[%d]!", ret); + return GL_LAUNCH_FAIL; + } + } + + ret = service_destroy(service); + if (ret != SERVICE_ERROR_NONE) { + ad->uginfo.app_called_by_me = true; + return GL_LAUNCH_SUCCESS; + } else { + return GL_LAUNCH_FAIL; + } +} + +/** + * Launching Camera application + */ +int _gl_ext_load_camera(void) +{ + gl_dbg(""); + app_context_h app_context; + + int ret = APP_MANAGER_ERROR_NONE; + ret = app_manager_get_app_context(GL_APP_PKG_CAMERA, &app_context); + if (ret == APP_MANAGER_ERROR_NONE) { + gl_dbg("Resume Camera"); + app_manager_resume_app(app_context); + return GL_LAUNCH_SUCCESS; + } else if (ret == APP_MANAGER_ERROR_NO_SUCH_APP) { + gl_dbg("Launch Camera"); + return __gl_ext_load(SERVICE_OPERATION_DEFAULT, + GL_APP_PKG_CAMERA); + } + + gl_dbgE("Error case[%d]!", ret); + return GL_LAUNCH_FAIL; +} + diff --git a/src/util/gl-ext-ug-load.c b/src/util/gl-ext-ug-load.c new file mode 100755 index 0000000..2d36d35 --- /dev/null +++ b/src/util/gl-ext-ug-load.c @@ -0,0 +1,904 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "gl-ext-ug-load.h" +#include "gl-debug.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-albums.h" +#include "gl-thumbs.h" +#include "gallery.h" +#include "gl-popup.h" +#include "gl-strings.h" +#include "gl-controlbar.h" + +#define GL_UG_PKG_MESSAGE "msg-composer-efl" +#define GL_UG_PKG_EMAIL "email-composer-efl" +#define GL_UG_PKG_IV "image-viewer-efl" +#define GL_UG_PKG_BLUETOOTH "setting-bluetooth-efl" +#define GL_UG_PKG_GALLERY "gallery-efl" + +#define GL_SEPERATOR_MAIL '\n' + +#define GL_ARGV_MSG_ATTACHFILE "ATTACHFILE" +#define GL_ARGV_EMAIL_RUN_TYPE "RUN_TYPE" +#define GL_ARGV_EMAIL_RUN_5 "5" +#define GL_ARGV_EMAIL_ATTACHMENT "ATTACHMENT" +#define GL_ARGV_BT_LAUNCH_TYPE "launch-type" +#define GL_ARGV_BT_LAUNCH_SEND "send" +#define GL_ARGV_BT_FILECOUNT "filecount" +#define GL_ARGV_BT_FILES "files" + +#define GL_ARGV_IV_VIEW_MODE "View Mode" +#define GL_ARGV_IV_VIEW_GALLERY "GALLERY" +#define GL_ARGV_IV_VIEW_SLIDESHOW "SLIDESHOW" +#define GL_ARGV_IV_PATH "Path" +#define GL_ARGV_IV_INDEX "Index" +#define GL_ARGV_IV_VIEW_BY "View By" +#define GL_ARGV_IV_VIEW_BY_FOLER "By Folder" +#define GL_ARGV_IV_VIEW_BY_ALL "All" +#define GL_ARGV_IV_VIEW_BY_FAVOR "Favorites" +#define GL_ARGV_IV_VIEW_BY_TAGS "Tags" +#define GL_ARGV_IV_MEDIA_TYPE "Media type" +#define GL_ARGV_IV_MEDIA_ALL "All" +#define GL_ARGV_IV_MEDIA_IMAGE "Image" +#define GL_ARGV_IV_MEDIA_VIDEO "Video" +#define GL_ARGV_IV_TAG_NAME "Tag name" +#define GL_ARGV_IV_ALBUM_INDEX "Album index" +#define GL_ARGV_IV_SORT_BY "Sort By" +#define GL_ARGV_IV_SORT_NAME "Name" +#define GL_ARGV_IV_SORT_NAMEDESC "NameDesc" +#define GL_ARGV_IV_SORT_DATE "Date" +#define GL_ARGV_IV_SORT_DATEDESC "DateDesc" + +#define GL_ARGV_LAUNCH_TYPE "launch-type" +#define GL_ARGV_FILE_TYPE "file-type" +#define GL_ARGV_DRM_TYPE "drm-type" +#define GL_ARGV_SETAS_TYPE "setas-type" +#define GL_ARGV_CALLERID_SIZE "callerid-size" +#define GL_ARGV_CALLERID_PATH "callerid-path" +#define GL_ARGV_HOMESCREEN_PATH "homescreen-path" +#define GL_ARGV_LOCKSCREEN_PATH "lockscreen-path" + +#define GL_ARGV_SETAS_WALLPALER "wallpaper" +#define GL_ARGV_SETAS_CROP_WALLPALER "crop-wallpaper" +#define GL_ARGV_SETAS_CALLERID "callerid" +#define GL_ARGV_SELECT_ALBUM "select-album" +#define GL_ARGV_SELECT_ONE "select-one" +#define GL_ARGV_SELECT_MULTIPLE "select-multiple" +#define GL_ARGV_SELECT_SETAS "select-setas" +#define GL_ARGV_SELECT_RETURN_FOLDER_PATH "folder-path" +#define GL_ARGV_SELECT_RETURN_COUNT "count" +#define GL_ARGV_SELECT_RETURN_PATH "path" +#define GL_ARGV_SETAS_RETURN_CROP_PATH "crop-image-path" +#define GL_ARGV_SETAS_RETURN_PATH "image-path" +#define GL_ARGV_FILE_TYPE_IMAGE "image" +#define GL_ARGV_FILE_TYPE_VIDEO "video" +#define GL_ARGV_FILE_TYPE_ALL "all" +#define GL_ARGC_SELECTED_FILES "Selected index" +#define GL_ARGV_IV_INDEX_VALUE "1" +#define GL_ARGV_DRM_TRUE "true" + +#define GL_ARGV_SETAS_RETURN_HOMESCREEN_PATH_FROM_IV "homescreen_path" + +static void __gl_ext_destroy_ug(void *data) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK(ad->uginfo.ug_called_by_me); + int view_mode = gl_get_view_mode(data); + gl_dbg("View mode: %d", view_mode); + + ug_destroy(ad->uginfo.ug_called_by_me); + ad->uginfo.ug_called_by_me = NULL; + + bool is_slideshow = false; + if (ad->uginfo.ug_type == GL_UG_IMAGEVIEWER && + ad->uginfo.iv_type != GL_UG_IV) + is_slideshow = true; + /* Clear type first */ + ad->uginfo.ug_type = -1; + ad->uginfo.iv_type = -1; + + /** + * If (1) view_mode is set as GL_VIEW_THUMBS in gridview, + * It means ug_called_by_me is ImageViewer UG. + */ + if (view_mode == GL_VIEW_THUMBS) { + if (!is_slideshow) + gl_update_view(data, GL_UPDATE_VIEW_NORMAL); + } +} + +static void __gl_ext_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv) +{ + gl_dbg(""); + GL_CHECK(ug); + GL_CHECK(priv); + + Evas_Object *base = NULL; + base = ug_get_layout(ug); + if (!base) { + gl_dbgE("ug_get_layout failed!"); + ug_destroy(ug); + return; + } + gl_appdata *ad = (gl_appdata *)priv; + + switch (mode) { + case UG_MODE_FULLVIEW: + evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + /* Disable effect when AUL, other show effect */ + /* Disable effect according to IV for descresing launching time */ + if((ad->albuminfo.aul_launch_type != GL_AUL_T_NONE && + ad->albuminfo.aul_launch_type != GL_AUL_T_VIEW_ALBUM) || + ad->uginfo.ug_type == GL_UG_IMAGEVIEWER) { + gl_dbg("No animation."); + ug_disable_effect(ug); + } + evas_object_show(base); + break; + default: + break; + } +} + +static void __gl_ext_ug_result_cb(ui_gadget_h ug, service_h result, void *priv) +{ + GL_CHECK(priv); + gl_dbg(""); +} + +static void __gl_ext_ug_destroy_cb(ui_gadget_h ug, void *priv) +{ + GL_CHECK(priv); + gl_appdata *ad = (gl_appdata *)priv; + gl_dbg(""); + + if(ad->albuminfo.aul_launch_type == GL_AUL_T_NONE || + ad->albuminfo.aul_launch_type == GL_AUL_T_VIEW_ALBUM) { + GL_CHECK(ad->uginfo.ug_called_by_me); + __gl_ext_destroy_ug(ad); + } else { + GL_CHECK(ug); + gl_dbg("Destroy Gallery UG directly."); + /* init launch-type after gallery-ug is closed */ + ad->albuminfo.aul_launch_type = GL_AUL_T_NONE; + + ug_destroy(ug); + ad->uginfo.gallery_ug_called_by_me = NULL; + + elm_win_lower(ad->maininfo.win); + gl_dbg("Pause Gallery App."); + } +} + +static char **__gl_ext_get_select_index(void *data, int *size) +{ + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_NULL(ad->selectedinfo.medias_elist); + gl_item *current = NULL; + char *index = NULL; + int i = 0; + char **media_index = NULL; + int pos = 0; + int sel_cnt = _gl_data_selected_list_count(ad); + + media_index = (char **)calloc(sel_cnt, sizeof(char *)); + GL_CHECK_NULL(media_index); + gl_dbg("select media count: %d", sel_cnt); + + for (i = 0; i < sel_cnt; ++i) { + _gl_data_get_item_by_index(ad, i+1, true, ¤t); + index = (char *)calloc(1, GL_INTERGER_LEN_MAX); + if (current == NULL || current->item == NULL || index == NULL) { + for (pos = 0; pos < i; ++pos) { + GL_FREEIF(media_index[pos]); + } + + GL_FREEIF(index); + GL_FREE(media_index); + return NULL; + } + gl_dbg("Sequence: %d", current->sequence); + snprintf(index, GL_INTERGER_LEN_MAX, "%d", + current->sequence - 1); + media_index[i] = index; + index = NULL; + } + + if (size) + *size = sel_cnt; + + return media_index; +} + +static int __gl_ext_add_sortby(service_h service, int sort) +{ + GL_CHECK_VAL(service, GL_UG_FAIL); + + switch (sort) { + case GL_SORT_BY_NAME_DESC: + /* Sort by display name descending */ + service_add_extra_data(service, GL_ARGV_IV_SORT_BY, + GL_ARGV_IV_SORT_NAMEDESC); + gl_dbg("Name descending"); + break; + case GL_SORT_BY_NAME_ASC: + /* Sort by display name ascending */ + service_add_extra_data(service, GL_ARGV_IV_SORT_BY, + GL_ARGV_IV_SORT_NAME); + gl_dbg("Name ascending"); + break; + case GL_SORT_BY_DATE_DESC: + /* Sort by modified_date descending */ + service_add_extra_data(service, GL_ARGV_IV_SORT_BY, + GL_ARGV_IV_SORT_DATEDESC); + gl_dbg("Date descending"); + break; + case GL_SORT_BY_DATE_ASC: + /* Sort by modified_date ascending */ + service_add_extra_data(service, GL_ARGV_IV_SORT_BY, + GL_ARGV_IV_SORT_DATE); + gl_dbg("Date ascending"); + break; + default: + /* No Sort, use GL_SORT_BY_NAME_ASC */ + service_add_extra_data(service, GL_ARGV_IV_SORT_BY, + GL_ARGV_IV_SORT_NAME); + gl_dbg("no sort, use default Name ascending"); + break; + } + return 0; +} + +/* Slideshow selected images */ +static int __gl_ext_slideshow_selected(void *data, service_h service) +{ + GL_CHECK_VAL(service, GL_UG_FAIL); + GL_CHECK_VAL(data, GL_UG_FAIL); + gl_appdata *ad = (gl_appdata *)data; + char **media_index = NULL; + int media_size = 0; + + media_index = __gl_ext_get_select_index(ad, &media_size); + if (media_index == NULL) { + gl_dbgE("Invalid select index!"); + return GL_UG_FAIL; + } + gl_dbg("Set selected medias, media_index[%p], size[%d]", media_index, + media_size); + service_add_extra_data_array(service, GL_ARGC_SELECTED_FILES, + (const char **)media_index, media_size); + /*free space of the medias index*/ + int i = 0; + for (i = 0; i < media_size; ++i) { + GL_FREEIF(media_index[i]); + } + GL_FREE(media_index); + media_index = NULL; + + service_add_extra_data(service, GL_ARGV_IV_INDEX, + GL_ARGV_IV_INDEX_VALUE); + return GL_UG_SUCCESS; +} + +static int __gl_ext_set_thumbs_mode(void *data, service_h service, int type) +{ + GL_CHECK_VAL(service, GL_UG_FAIL); + GL_CHECK_VAL(data, GL_UG_FAIL); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d", view_mode); + + /* 2.0, Local file */ + if (GL_UG_IV_SLIDESHOW == type || + GL_UG_IV_SLIDESHOW_SELECTED == type) + service_add_extra_data(service, GL_ARGV_IV_VIEW_MODE, + GL_ARGV_IV_VIEW_SLIDESHOW); + else + service_add_extra_data(service, GL_ARGV_IV_VIEW_MODE, + GL_ARGV_IV_VIEW_GALLERY); + + switch (view_mode) { + case GL_VIEW_THUMBS: + case GL_VIEW_THUMBS_EDIT: + /* Type according to different seg. */ + if (ad->gridinfo.view_mode == GL_THUMB_IMAGES) { + service_add_extra_data(service, GL_ARGV_IV_MEDIA_TYPE, + GL_ARGV_IV_MEDIA_IMAGE); + gl_dbg("Media type: Image"); + } else if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS) { + service_add_extra_data(service, GL_ARGV_IV_MEDIA_TYPE, + GL_ARGV_IV_MEDIA_VIDEO); + gl_dbg("Media type: Video"); + } else { + service_add_extra_data(service, GL_ARGV_IV_MEDIA_TYPE, + GL_ARGV_IV_MEDIA_ALL); + gl_dbg("Media type: All"); + } + break; + default: + service_add_extra_data(service, GL_ARGV_IV_MEDIA_TYPE, + GL_ARGV_IV_MEDIA_ALL); + gl_dbg("Media type: All"); + break; + } + return GL_UG_SUCCESS; +} +static int __gl_ext_albums_set_iv(void *data, service_h service, int type) +{ + GL_CHECK_VAL(service, GL_UG_FAIL); + GL_CHECK_VAL(data, GL_UG_FAIL); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->albuminfo.current_album, GL_UG_FAIL); + gl_cluster *cur_album = ad->albuminfo.current_album; + gl_dbg("type: %d", type); + + /* 2.0, Local file */ + if (__gl_ext_set_thumbs_mode(data, service, type) == GL_UG_FAIL) + return GL_UG_FAIL; + + if (ad->gridinfo.grid_type == GL_GRID_T_ALLALBUMS) { + /* 2.1, 'All' album->thumbnails view */ + service_add_extra_data(service, GL_ARGV_IV_VIEW_BY, + GL_ARGV_IV_VIEW_BY_ALL); + gl_dbg("View By: All"); + } else { + /* 2.3, Other albums->thumbnails view */ + service_add_extra_data(service, GL_ARGV_IV_VIEW_BY, + GL_ARGV_IV_VIEW_BY_FOLER); + gl_dbg("View By: By Folder"); + } + + if (cur_album->cluster && cur_album->cluster->uuid) { + gl_dbg("album id: %s", cur_album->cluster->uuid); + service_add_extra_data(service, GL_ARGV_IV_ALBUM_INDEX, + cur_album->cluster->uuid); + } + return GL_UG_SUCCESS; +} + +static int __gl_ext_tags_set_iv(void *data, service_h service, int type) +{ + GL_CHECK_VAL(service, GL_UG_FAIL); + GL_CHECK_VAL(data, GL_UG_FAIL); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->taginfo.current_tag, GL_UG_FAIL); + gl_dbg("type: %d", type); + + if (__gl_ext_set_thumbs_mode(data, service, type) == GL_UG_FAIL) + return GL_UG_FAIL; + + /* 2.4, Tags->thumbnails view */ + gl_tag *cur_tag = ad->taginfo.current_tag; + if (cur_tag->tag && cur_tag->tag->tag_name) { + if (cur_tag->tag->_id == GL_TAG_FAVORITES_ID) { + /* 2.4.1, Favourites tag->thumbnails view */ + service_add_extra_data(service, GL_ARGV_IV_VIEW_BY, + GL_ARGV_IV_VIEW_BY_FAVOR); + gl_dbg("View By: Favorites"); + } else { + /* 2.4.2, Normal tag->thumbnails view */ + service_add_extra_data(service, GL_ARGV_IV_VIEW_BY, + GL_ARGV_IV_VIEW_BY_TAGS); + gl_dbg("View By: Tags"); + } + + service_add_extra_data(service, GL_ARGV_IV_TAG_NAME, + cur_tag->tag->tag_name); + } else { + gl_dbgE("Invalid tag!"); + return GL_UG_FAIL; + } + return GL_UG_SUCCESS; +} + +/* Invoke Imageviewer UG */ +int gl_ext_load_iv_ug(void *data, gl_item *item, gl_ext_iv_type type) +{ + GL_CHECK_VAL(item, GL_UG_FAIL); + GL_CHECK_VAL(item->item, GL_UG_FAIL); + GL_CHECK_VAL(data, GL_UG_FAIL); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.win, GL_UG_FAIL); + Evas_Object *win = ad->maininfo.win; + struct ug_cbs cbs; + ui_gadget_h ug = NULL; + service_h service = NULL; + gl_dbg("type: %d", type); + + if (ad->uginfo.ug_called_by_me) { + gl_dbgE("Already exits some UG called by me, type(%d)!", type); + return GL_UG_FAIL; + } + + memset(&cbs, 0x00, sizeof(struct ug_cbs)); + cbs.layout_cb = __gl_ext_ug_layout_cb; + cbs.result_cb = __gl_ext_ug_result_cb; + cbs.destroy_cb = __gl_ext_ug_destroy_cb; + cbs.priv = ad; + + service_create(&service); + GL_CHECK_VAL(service, GL_UG_FAIL); + + UG_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE); + ad->uginfo.ug_type = GL_UG_IMAGEVIEWER; + ad->uginfo.iv_type = type; + + int ret = GL_UG_FAIL; + switch (ad->ctrlinfo.tab_mode) { + case GL_CTRL_TAB_ALBUMS: + ret = __gl_ext_albums_set_iv(data, service, type); + break; + case GL_CTRL_TAB_TAGS: + ret = __gl_ext_tags_set_iv(data, service, type); + break; + default: + gl_dbgE("Wrong tab mode!"); + } + + if (ret == GL_UG_FAIL) { + gl_dbgW("Service data setting failed!"); + service_destroy(service); + return GL_UG_FAIL; + } + + service_add_extra_data(service, GL_ARGV_IV_PATH, item->item->file_url); + + /* Sort by type */ + __gl_ext_add_sortby(service, ad->uginfo.sort_type); + + if (type == GL_UG_IV_SLIDESHOW_SELECTED) { + if (__gl_ext_slideshow_selected(ad, service) == GL_UG_FAIL) { + gl_dbgE("Failed to slideshow selected files!"); + service_destroy(service); + return GL_UG_FAIL; + } + } else if (type == GL_UG_IV || type == GL_UG_IV_SLIDESHOW) { + char sequence_str[GL_INTERGER_LEN_MAX] = { 0, }; + eina_convert_itoa(item->sequence, sequence_str); + gl_dbg("sequence : %s", sequence_str); + service_add_extra_data(service, GL_ARGV_IV_INDEX, sequence_str); + } + + ug = ug_create(NULL, GL_UG_PKG_IV, UG_MODE_FULLVIEW, service, &cbs); + ad->uginfo.ug_called_by_me = ug; + service_destroy(service); + + if (ug) { + return GL_UG_SUCCESS; + } else { + gl_dbgE("ug_create failed!"); + return GL_UG_FAIL; + } +} + +int gl_ext_load_ug(void *data, gl_ext_ug_type type) +{ + GL_CHECK_VAL(data, GL_UG_FAIL); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.win, GL_UG_FAIL); + struct ug_cbs cbs; + ui_gadget_h ug = NULL; + service_h service = NULL; + Evas_Object *win = ad->maininfo.win; + int view_m = gl_get_view_mode(ad); + gl_dbg("view_m: %d", view_m); + + if (ad->uginfo.ug_called_by_me) { + gl_dbg("Already exits some UG, Request type(%d)", type); + return GL_UG_FAIL; + } + + ad->uginfo.ug_type = type; + + memset(&cbs,0x00,sizeof(struct ug_cbs)); + char *filepath_arg = NULL; + + cbs.layout_cb = __gl_ext_ug_layout_cb; + cbs.result_cb = __gl_ext_ug_result_cb; + cbs.destroy_cb = __gl_ext_ug_destroy_cb; + cbs.priv = ad; + + service_create(&service); + GL_CHECK_VAL(service, GL_UG_FAIL); + + UG_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE); + + int sel_cnt = 0; + char count_arg[GL_EXT_STR_COUNT_LEN] = { 0, }; + switch (type) { + case GL_UG_MSG: + _gl_get_selected_paths(ad, GL_SEPERATOR_MAIL, &filepath_arg, + NULL); + if(filepath_arg == NULL) + goto EXT_UG_FAILED; + + service_add_extra_data(service, GL_ARGV_MSG_ATTACHFILE, + filepath_arg); + + ug = ug_create(NULL, GL_UG_PKG_MESSAGE, + UG_MODE_FULLVIEW, service, &cbs); + break; + case GL_UG_EMAIL: + _gl_get_selected_paths(ad, GL_SEPERATOR_MAIL, &filepath_arg, + NULL); + if(filepath_arg == NULL) + goto EXT_UG_FAILED; + + service_add_extra_data(service, GL_ARGV_EMAIL_RUN_TYPE, + GL_ARGV_EMAIL_RUN_5); + service_add_extra_data(service, GL_ARGV_EMAIL_ATTACHMENT, + filepath_arg); + + ug = ug_create(NULL, GL_UG_PKG_EMAIL, UG_MODE_FULLVIEW, + service, &cbs); + break; + case GL_UG_BT: + _gl_get_selected_paths(ad, GL_SEPERATOR_BT, &filepath_arg, + &sel_cnt); + if(filepath_arg == NULL) + goto EXT_UG_FAILED; + + service_add_extra_data(service, GL_ARGV_BT_LAUNCH_TYPE, + GL_ARGV_BT_LAUNCH_SEND); + + snprintf(count_arg, sizeof(count_arg), "%d", sel_cnt); + service_add_extra_data(service, GL_ARGV_BT_FILECOUNT, + count_arg); + + service_add_extra_data(service, GL_ARGV_BT_FILES, filepath_arg); + + ug = ug_create(NULL, GL_UG_PKG_BLUETOOTH, UG_MODE_FULLVIEW, + service, &cbs); + break; + default: + gl_dbgE("Wrong UG type!"); + goto EXT_UG_FAILED; + } + + if (filepath_arg) { + g_free(filepath_arg); + filepath_arg = NULL; + } + + ad->uginfo.ug_called_by_me = ug; + service_destroy(service); + + if (ug) { + gl_dbgW("ug_create success!"); + return GL_UG_SUCCESS; + } else { + gl_dbgE("ug_create failed!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_APPLICATION_NOT_INSTALLED); + return GL_UG_FAIL; + } + + EXT_UG_FAILED: + + gl_dbgE("EXT_UG_FAILED!"); + service_destroy(service); + return GL_UG_FAIL; +} + +static void __gl_ext_gallery_ug_result_cb(ui_gadget_h ug, service_h result, + void *priv) +{ + GL_CHECK(priv); + gl_appdata *ad = (gl_appdata *)priv; + char *ret_str = NULL; + int service_ret = -1; + service_h service = ad->albuminfo.recv_service; + service_h reply = NULL; + bool b_reply = false; + gl_dbg(""); + + if (service_create(&reply) != SERVICE_ERROR_NONE) { + gl_dbgE("service_create failed!"); + return; + } + GL_CHECK(reply); + + switch(ad->albuminfo.aul_launch_type) { + case GL_AUL_T_SELECT_ALBUM: + service_get_extra_data(result, + GL_ARGV_SELECT_RETURN_FOLDER_PATH, + &ret_str); + if(ret_str) { + gl_dbg("return folder-path: %s", ret_str); + service_add_extra_data(reply, SERVICE_DATA_SELECTED, + ret_str); + GL_FREE(ret_str); + b_reply = true; + } + break; + + case GL_AUL_T_SELECT_ONE: + service_get_extra_data(result, GL_ARGV_SELECT_RETURN_PATH, + &ret_str); + if(ret_str) { + gl_dbg("return path: %s", ret_str); + service_add_extra_data(reply, SERVICE_DATA_SELECTED, + ret_str); + GL_FREE(ret_str); + b_reply = true; + } + break; + + case GL_AUL_T_SELECT_MULTIPLE: + service_get_extra_data(result, GL_ARGV_SELECT_RETURN_COUNT, + &ret_str); + if(ret_str) { + gl_dbg("return count: %s", ret_str); + service_add_extra_data(reply, + GL_ARGV_SELECT_RETURN_COUNT, + ret_str); + GL_FREE(ret_str); + b_reply = true; + } + + service_get_extra_data(result, GL_ARGV_SELECT_RETURN_PATH, + &ret_str); + if(ret_str) { + gl_dbg("return path: %s", ret_str); + service_add_extra_data(reply, SERVICE_DATA_SELECTED, + ret_str); + GL_FREE(ret_str); + b_reply = true; + } + break; + + case GL_AUL_T_SELECT_SETAS: + service_get_extra_data(result, GL_ARGV_SETAS_RETURN_PATH, + &ret_str); + if(ret_str) { + gl_dbg("return image-path: %s", ret_str); + service_add_extra_data(reply, GL_ARGV_SETAS_RETURN_PATH, + ret_str); + GL_FREE(ret_str); + b_reply = true; + } + + /* When IV ug returns "crop_image_path" */ + service_get_extra_data(result, GL_ARGV_SETAS_RETURN_CROP_PATH, &ret_str); + if (ret_str && + (ad->albuminfo.aul_setas_type == GL_AUL_SETAS_T_CALLER_ID || + ad->albuminfo.aul_setas_type == GL_AUL_SETAS_T_CROP_WALLPAPER)) { + gl_dbg("return image-path: %s", ret_str); + service_add_extra_data(reply, + GL_ARGV_SETAS_RETURN_CROP_PATH, + ret_str); + GL_FREE(ret_str); + b_reply = true; + } + + /* When IV ug returns "homescreen_path" */ + service_get_extra_data(result, GL_ARGV_SETAS_RETURN_HOMESCREEN_PATH_FROM_IV, &ret_str); + if (ret_str && + ad->albuminfo.aul_setas_type == GL_AUL_SETAS_T_WALLPAPER) { + gl_dbg("return image-path: %s", ret_str); + service_add_extra_data(reply, GL_ARGV_SETAS_RETURN_HOMESCREEN_PATH_FROM_IV, ret_str); + GL_FREE(ret_str); + b_reply = true; + } + break; + + default: + break; + } + + /* Send result to caller */ + if(b_reply) { + service_ret = service_reply_to_launch_request(reply, service, + SERVICE_RESULT_SUCCEEDED); + } else { + gl_dbgE("service_get_extra_data failed!"); + service_ret = service_reply_to_launch_request(reply, service, + SERVICE_RESULT_CANCELED); + } + + service_destroy(reply); + if (service_ret != SERVICE_ERROR_NONE) + gl_dbgE("service_reply_to_launch_request failed!"); +} + +int gl_ext_load_gallery_ug(void *data) +{ + GL_CHECK_VAL(data, GL_UG_FAIL); + gl_appdata *ad = (gl_appdata *)data; + struct ug_cbs cbs; + ui_gadget_h ug = NULL; + service_h service = NULL; + Evas_Object *win = ad->maininfo.win; + int launch_type = 0; + int setas_type = 0; + int file_type = 0; + char *val = NULL; + + if (ad->uginfo.gallery_ug_called_by_me) { + gl_dbgW("Gallery UG called by me, destroy it first!"); + ug_destroy(ad->uginfo.gallery_ug_called_by_me); + ad->uginfo.gallery_ug_called_by_me = NULL; + } + + memset(&cbs, 0x00, sizeof(struct ug_cbs)); + + cbs.layout_cb = __gl_ext_ug_layout_cb; + cbs.result_cb = __gl_ext_gallery_ug_result_cb; + cbs.destroy_cb = __gl_ext_ug_destroy_cb; + cbs.priv = ad; + + service_create(&service); + GL_CHECK_VAL(service, GL_UG_FAIL); + + UG_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE); + + /* add launch-type */ + launch_type = ad->albuminfo.aul_launch_type; + gl_dbg("launch-type: %d", launch_type); + switch (launch_type) { + case GL_AUL_T_SELECT_ONE: + service_add_extra_data(service, GL_ARGV_LAUNCH_TYPE, + GL_ARGV_SELECT_ONE); + break; + case GL_AUL_T_SELECT_MULTIPLE: + service_add_extra_data(service, GL_ARGV_LAUNCH_TYPE, + GL_ARGV_SELECT_MULTIPLE); + break; + case GL_AUL_T_SELECT_SETAS: + service_add_extra_data(service, GL_ARGV_LAUNCH_TYPE, + GL_ARGV_SELECT_SETAS); + + setas_type = ad->albuminfo.aul_setas_type; + gl_dbg("setas-type: %d", setas_type); + switch(setas_type) { + case GL_AUL_SETAS_T_WALLPAPER: + case GL_AUL_SETAS_T_CROP_WALLPAPER: + if (setas_type == GL_AUL_SETAS_T_WALLPAPER) { + service_add_extra_data(service, + GL_ARGV_SETAS_TYPE, + GL_ARGV_SETAS_WALLPALER); + } else if ( setas_type == GL_AUL_SETAS_T_CROP_WALLPAPER ) { + service_add_extra_data(service, + GL_ARGV_SETAS_TYPE, + GL_ARGV_SETAS_CROP_WALLPALER); + } + val = ad->albuminfo.aul_homescreen_path; + if(val) { + gl_dbg("homescreen-path: %s", val); + service_add_extra_data(service, + GL_ARGV_HOMESCREEN_PATH, + val); + } + + val = ad->albuminfo.aul_lockscreen_path; + if(val) { + gl_dbg("lockscreen-path: %s", val); + service_add_extra_data(service, + GL_ARGV_LOCKSCREEN_PATH, + val); + } + + break; + case GL_AUL_SETAS_T_CALLER_ID: + service_add_extra_data(service, GL_ARGV_SETAS_TYPE, + GL_ARGV_SETAS_CALLERID); + val = ad->albuminfo.aul_callid_size; + if(val) { + gl_dbg("callerid-size: %s", val); + service_add_extra_data(service, + GL_ARGV_CALLERID_SIZE, + val); + } + + val = ad->albuminfo.aul_callid_path; + if(val) { + gl_dbg("callerid-path: %s", val); + service_add_extra_data(service, + GL_ARGV_CALLERID_PATH, + val); + } + + break; + default: + gl_dbgE("Undefine mode!"); + service_destroy(service); + return GL_UG_FAIL; + } + + break; + case GL_AUL_T_SELECT_ALBUM: + service_add_extra_data(service, GL_ARGV_LAUNCH_TYPE, + GL_ARGV_SELECT_ALBUM); + break; + default: + gl_dbgE("Undefine mode!"); + service_destroy(service); + return GL_UG_FAIL; + } + + /* add file-type */ + file_type = ad->albuminfo.aul_file_type; + gl_dbg("file-type: %d", file_type); + switch (file_type) { + case GL_AUL_FILE_T_IMAGE: + service_add_extra_data(service, GL_ARGV_FILE_TYPE, + GL_ARGV_FILE_TYPE_IMAGE); + break; + case GL_AUL_FILE_T_VIDEO: + service_add_extra_data(service, GL_ARGV_FILE_TYPE, + GL_ARGV_FILE_TYPE_VIDEO); + break; + case GL_AUL_FILE_T_ALL: + service_add_extra_data(service, GL_ARGV_FILE_TYPE, + GL_ARGV_FILE_TYPE_ALL); + break; + default: + gl_dbgE("Undefine mode!"); + service_destroy(service); + return GL_UG_FAIL; + } + /* add whether contain drm file */ + if (ad->albuminfo.b_show_drm) + service_add_extra_data(service, GL_ARGV_DRM_TYPE, + GL_ARGV_DRM_TRUE); + + ug = ug_create(NULL, GL_UG_PKG_GALLERY, UG_MODE_FULLVIEW, service, + &cbs); + service_destroy(service); + + gl_dbg("ug_create: %p.", ug); + ad->uginfo.gallery_ug_called_by_me = ug; + if (ug) { + Evas_Object *ug_ly = ug_get_layout(ug); + if (ug_ly) { + evas_object_raise(ug_ly); + } else { + gl_dbgE("ug_get_layout failed!"); + return GL_UG_FAIL; + } + return GL_UG_SUCCESS; + } else { + gl_dbgE("ug_create failed!"); + return GL_UG_FAIL; + } +} + +int gl_ext_destroy_gallery_ug(void *data) +{ + GL_CHECK_VAL(data, GL_UG_FAIL); + gl_dbg(""); + gl_appdata *ad = (gl_appdata *)data; + + /* For select appcontrol, destory ug when HOME key is pressed */ + if (ad->albuminfo.aul_launch_type != GL_AUL_T_NONE && + ad->albuminfo.aul_launch_type != GL_AUL_T_VIEW_ALBUM && + ad->uginfo.gallery_ug_called_by_me) { + gl_dbg("To destroy UG"); + __gl_ext_ug_destroy_cb(ad->uginfo.gallery_ug_called_by_me, ad); + } else { + gl_dbg("AUL none"); + } + + return GL_UG_SUCCESS; +} + diff --git a/src/util/gl-fs.c b/src/util/gl-fs.c new file mode 100755 index 0000000..84dd63a --- /dev/null +++ b/src/util/gl-fs.c @@ -0,0 +1,683 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include "gl-fs.h" +#include "gallery.h" +#include "gl-debug.h" + +static int __gl_fs_free_node(gl_node_info_s *pnode) +{ + GL_CHECK_VAL(pnode, -1); + if (pnode->path) { + g_free(pnode->path); + pnode->path = NULL; + } + if (pnode->name) { + g_free(pnode->name); + pnode->name = NULL; + } + g_free(pnode); + return 0; +} + +static int __gl_fs_clear_list(Eina_List **elist) +{ + GL_CHECK_VAL(elist, -1); + gl_node_info_s *pnode = NULL; + if (*elist) { + EINA_LIST_FREE(*elist, pnode) { + __gl_fs_free_node(pnode); + pnode = NULL; + } + *elist = NULL; + } + return 0; +} + +/* Append bigger one, prepend smaller one, first node is oldest one */ +static int __gl_fs_compare(const void *data1, const void *data2) +{ + gl_node_info_s *pnode1 = (gl_node_info_s *)data1; + gl_node_info_s *pnode2 = (gl_node_info_s *)data2; + + int ret = -(pnode1->mtime - pnode2->mtime); + gl_dbg("mtime1[%d], mtime2[%d], ret[%d]", pnode1->mtime, pnode2->mtime, + ret); + return ret; +} + +static int __gl_fs_read_dir(char *path, Eina_List **dir_list, + Eina_List **file_list) +{ + GL_CHECK_VAL(file_list, -1); + GL_CHECK_VAL(dir_list, -1); + GL_CHECK_VAL(path, -1); + + DIR *pdir = NULL; + struct dirent *ent = NULL; + int count = 0; + char *childpath = NULL; + int cp_len = 0; + gl_node_info_s *pnode = NULL; + int copiednum = 0; + + pdir = opendir(path); + GL_CHECK_VAL(pdir, -1); + + while ((ent = readdir(pdir)) != NULL) { + if (g_strcmp0(ent->d_name, ".") == 0 || + g_strcmp0(ent->d_name, "..") == 0) { + continue; + } + /*only deal with dirs and regular files*/ + if ((ent->d_type & DT_DIR) == 0 && (ent->d_type & DT_REG) == 0) + continue; + + /*get date & size*/ + cp_len = strlen(path) + 1 + strlen(ent->d_name) + 1; + childpath = g_new0(char, cp_len); + if (childpath == NULL) + continue; + + copiednum = g_snprintf(childpath, cp_len, "%s/%s", path, + ent->d_name); + if (copiednum < 0) { + g_free(childpath); + childpath = NULL; + continue; + } + + pnode = g_new0(gl_node_info_s, 1); + if (pnode == NULL) { + g_free(childpath); + childpath = NULL; + continue; + } + /*get path*/ + pnode->path = g_strdup(path); + /*get name*/ + pnode->name = g_strdup(ent->d_name); + + if (_gl_fs_get_file_stat(childpath, &pnode) < 0) { + g_free(pnode); + pnode = NULL; + g_free(childpath); + childpath = NULL; + continue; + } + g_free(childpath); + childpath = NULL; + + if (ent->d_type & DT_DIR) + *dir_list = eina_list_append(*dir_list, pnode); + else + *file_list = eina_list_append(*file_list, pnode); + count++; + } + closedir(pdir); + + return 0; +} + +static int __gl_fs_get_file_list(GString *folder_name, Eina_List **dir_list, + Eina_List **file_list) +{ + GL_CHECK_VAL(folder_name, -1); + GL_CHECK_VAL(folder_name->str, -1); + GL_CHECK_VAL(folder_name->len, -1); + return __gl_fs_read_dir(folder_name->str, dir_list, file_list); +} + +/* Get sorted folders list by folder's modified time */ +static long long __gl_fs_sort_folders_by_mtime(char *path, + Eina_List **sorted_list) +{ + if (!ecore_file_is_dir(path)) { + gl_dbgE("Not a directory!"); + return 0; + } + + long long size = 0; + long long sub_size = 0; + GString *fullpath = g_string_new(path); + Eina_List *dir_list = NULL; + Eina_List *file_list = NULL; + int error_code = 0; + error_code = __gl_fs_get_file_list(fullpath, &dir_list, &file_list); + + if (error_code == 0) { + int i = 0; + int dir_cnt = eina_list_count(dir_list); + int file_cnt = eina_list_count(file_list); + gl_node_info_s *pnode = NULL; + for (i = 0; i < file_cnt; i++) { + pnode = (gl_node_info_s *)eina_list_nth(file_list, i); + if (pnode == NULL) { + gl_dbgE("Invalid node!"); + continue; + } + size += pnode->size; + pnode = NULL; + } + gl_dbg("file_cnt[%lld], size[%lld]", file_cnt, size); + + i = 0; + pnode = NULL; + char *sub_folder = NULL; + gl_dbg("dir_cnt[%d]", dir_cnt); + for (i = 0; i < dir_cnt; i++) { + pnode = (gl_node_info_s *)eina_list_nth(dir_list, i); + if (pnode == NULL) { + gl_dbgE("Invalid node!"); + continue; + } + sub_folder = g_strconcat(pnode->path, "/", pnode->name, + NULL); + if (sub_folder) { + gl_dbg("sub_folder[%s]", pnode->name); + sub_size = __gl_fs_sort_folders_by_mtime(sub_folder, + sorted_list); + pnode->size = sub_size; + size += sub_size; + gl_dbg("mtime[%d]", pnode->mtime); + *sorted_list = eina_list_sorted_insert(*sorted_list, + __gl_fs_compare, + pnode); + g_free(sub_folder); + sub_folder = NULL; + } else { + gl_dbgE("Invalid sub folder!"); + } + pnode = NULL; + } + } + + if (fullpath) { + g_string_free(fullpath, true); + fullpath = NULL; + } + + if (file_list) + __gl_fs_clear_list(&file_list); + + if (dir_list) { + eina_list_free(dir_list); + dir_list = NULL; + } + + return size; +} + +static unsigned long long __gl_fs_get_free_space(int state) +{ + struct statvfs info; + char *path = NULL; + + if (state == GL_STORE_T_PHONE) + path = GL_ROOT_PATH_PHONE; + else if (state == GL_STORE_T_MMC) + path = GL_ROOT_PATH_MMC; + else + return 0; + + if (-1 == statvfs(path, &info)) + return 0; + + return ((unsigned long long)(info.f_bsize)) * ((unsigned long long)(info.f_bavail)); +} + +int _gl_fs_get_file_stat(const char *filename, gl_node_info_s **node) +{ + struct stat statbuf; + GL_CHECK_VAL(node, -1); + GL_CHECK_VAL(*node, -1); + GL_CHECK_VAL(filename, -1); + + if (stat(filename, &statbuf) == -1) + return -1; + + /* total size, in bytes */ + (*node)->size = statbuf.st_size; + (*node)->mtime = statbuf.st_mtime; + return 0; +} + +long long _gl_fs_get_folder_size(char *path) +{ + if (!ecore_file_is_dir(path)) { + gl_dbgE("Not a directory!"); + return 0; + } + + long long size = 0; + long long sub_size = 0; + GString *fullpath = g_string_new(path); + Eina_List *file_list = NULL; + Eina_List *dir_list = NULL; + int error_code = 0; + error_code = __gl_fs_get_file_list(fullpath, &dir_list, &file_list); + + if (error_code == 0) { + int i = 0; + int dir_cnt = eina_list_count(dir_list); + int file_cnt = eina_list_count(file_list); + gl_node_info_s *pnode = NULL; + for (i = 0; i < file_cnt; i++) { + pnode = (gl_node_info_s *)eina_list_nth(file_list, i); + if (pnode == NULL) { + gl_dbgE("Invalid node!"); + continue; + } + size += pnode->size; + pnode = NULL; + } + gl_dbg("file_cnt[%d], size[%d]", file_cnt, size); + + gl_dbg("dir_cnt[%d]", dir_cnt); + i = 0; + pnode = NULL; + char *sub_folder = NULL; + for (i = 0; i < dir_cnt; i++) { + pnode = (gl_node_info_s *)eina_list_nth(dir_list, i); + if (pnode == NULL) { + gl_dbgE("Invalid node!"); + continue; + } + sub_folder = g_strconcat(pnode->path, "/", pnode->name, + NULL); + if (sub_folder) { + gl_dbg("sub_folder[%s]", pnode->name); + sub_size = _gl_fs_get_folder_size(sub_folder); + pnode->size = sub_size; + size += sub_size; + gl_dbg("mtime[%d]", pnode->mtime); + g_free(sub_folder); + sub_folder = NULL; + } else { + gl_dbgE("Invalid sub folder!"); + } + pnode = NULL; + } + } + + if (fullpath) { + g_string_free(fullpath, true); + fullpath = NULL; + } + + if (file_list) + __gl_fs_clear_list(&file_list); + + if (dir_list) + __gl_fs_clear_list(&dir_list); + return size; +} + +int _gl_fs_rm_folder(char *path, long long cut_size, long long max_size, + unsigned int expired_time) +{ + GL_CHECK_VAL(path, -1); + gl_node_info_s *pnode = NULL; + Eina_List *dir_list = NULL; + Eina_List *l = NULL; + long long size = 0; + gl_dbg("Size cut/max[%lld/%lld]", cut_size, max_size); + + size = __gl_fs_sort_folders_by_mtime(path, &dir_list); + GL_CHECK_VAL(dir_list, -1); + + char *folder = NULL; + long long _cut_size = 0; + if (size > max_size) + _cut_size = size - max_size + cut_size; + else if (size + cut_size > max_size) + _cut_size = cut_size; + gl_dbg("Size cut/total[%lld/%lld]", _cut_size, size); + + unsigned int current_t = 0; + struct timeval tv; + gettimeofday(&tv, NULL); + current_t = tv.tv_sec + tv.tv_usec / GL_TIME_USEC_PER_SEC; + gl_dbg("current time[%d], expired time[%d]", current_t, expired_time); + long long rm_size = 0; + + EINA_LIST_FOREACH(dir_list, l, pnode) { + if (pnode == NULL || pnode->path == NULL || pnode->name == NULL) + continue; + + /* Get full path of folder */ + folder = g_strconcat(pnode->path, "/", pnode->name, NULL); + if (folder == NULL) + continue; + + gl_dbg("mtime[%d], path[%s]", pnode->mtime, folder); + if (pnode->mtime + expired_time < current_t) { + /* Remove folder */ + gl_dbgW("Remove!"); + ecore_file_recursive_rm(folder); + g_free(folder); + folder = NULL; + rm_size += pnode->size; + continue; + } else if (_cut_size == 0 || rm_size >= _cut_size) { + gl_dbgW("Done!"); + break; + } + + /* Remove folder */ + ecore_file_recursive_rm(folder); + g_free(folder); + folder = NULL; + + gl_dbg("size[cut/dir]=%lld/%lld", _cut_size, pnode->size); + if (pnode->size >= _cut_size) { + gl_dbgW("Done!"); + break; + } + + pnode = NULL; + } + __gl_fs_clear_list(&dir_list); + return 0; +} + +#ifdef _RENAME_ALBUM_SENSITIVE +bool _gl_fs_check_name_case(char *dir, char *exist_name) +{ + GL_CHECK_FALSE(dir); + GL_CHECK_FALSE(exist_name); + gl_dbg(""); + + char dest_dir[GL_DIR_PATH_LEN_MAX] = {0}; + char dest_filename[GL_FILE_NAME_LEN_MAX] = {0}; + char *tmp = NULL; + tmp = strrchr(dir, '/'); + if (tmp) { + g_strlcpy(dest_filename, tmp + 1, GL_FILE_NAME_LEN_MAX); + tmp[0] = '\0'; + g_strlcpy(dest_dir, dir, GL_DIR_PATH_LEN_MAX); + tmp[0] = '/'; + } else { + return false; + } + + bool ret = false; + Eina_List *name_list = NULL; + if((name_list = ecore_file_ls(dest_dir)) == NULL) { + gl_dbgE("open dir failed!"); + return false; + } else { + char *dir_name = NULL; + EINA_LIST_FREE(name_list, dir_name) { + if (dir_name && + strcasecmp(dir_name, dest_filename) == 0) { + gl_dbg("Have same name directory"); + ret = true; + memset(exist_name, 0x00, GL_ALBUM_NAME_LEN_MAX); + g_strlcpy(exist_name, dir_name, + GL_ALBUM_NAME_LEN_MAX); + break; + } + GL_FREEIF(dir_name); + } + } + return ret; +} +#endif + +bool _gl_fs_is_low_memory(unsigned long long total_size) +{ + unsigned long long free_size = __gl_fs_get_free_space(GL_STORE_T_PHONE); + if (total_size && free_size < total_size) { + gl_dbgE("Low memory: Free(%llu Byte) < required(%llu Byte)!", + free_size, total_size); + return true; + } + + return false; +} + +/* +* return file extension, f.e. jpg; then return new path without ext. +*/ +bool _gl_fs_get_ext(const char *file_path, char *file_ext, char *new_path) +{ + int i = 0; + for (i = strlen(file_path); i >= 0; i--) { + if ((file_path[i] == '.') && (i < GL_FILE_PATH_LEN_MAX)) { + g_strlcpy(file_ext, &file_path[i + 1], GL_FILE_EXT_LEN_MAX); + g_strlcpy(new_path, file_path, i + 1); + new_path[i] = '\0'; + gl_dbg("path without extension :%s", new_path); + return true; + } + + /* meet the dir. no ext */ + if (file_path[i] == '/') + return true; + } + return true; +} + +/* one copy of function "ecore_file_mv" from the file "ecore_file.c" for lock debugging */ +/* +* Use gl_file_mv() to move medias to other album. +* Media-server, which is different with libmedia-info, watches src and dest folder, +* it updates libmedia-info DB asynchronously. +* While move/copy mass data in My Files appliation, +* After move/copy done in My files, check the dest folder in Gallery. +* You'll find its content is changing. +* gl_file_mv() operate libmedia-info DB synchronously, so it's faster than media-server. +*/ + +/* +* stop using "rename" when moving from mmc to phone for correct db update. +*/ +Eina_Bool _gl_fs_move(const char *src, const char *dst) +{ + GL_CHECK_FALSE(src); + GL_CHECK_FALSE(dst); + + gl_dbg("\n\tSrc: %s\n\tDest: %s", src, dst); + /* + * From->To: MMC->MMC or Phone->Phone + */ + if (rename(src, dst)) { + /* + * File cannot be moved directly because + * it resides on a different mount point. + */ + if (errno == EXDEV) { + /* + * From->To: MMC->Phone or Phone->MMC + */ + gl_dbgW("errno = EXDEV(%d): Cross-device link", errno); + struct stat st; + + /* + * Make sure this is a regular file before + * we do anything fancy. + */ + if (stat(src, &st) < 0) { + gl_dbgE("stat fail[%d]!", errno); + return EINA_FALSE; + } + if (S_ISREG(st.st_mode)) { + /* + * Copy to dst file + */ + if (!ecore_file_cp(src, dst)) { + gl_dbgE("Copy file failed[%d]!", errno); + return EINA_FALSE; + } + + + /* + * Delete src file + */ + if (!ecore_file_unlink(src)) + gl_dbgE("Delete file failed[%d]!", errno); + + /* Write file to filesystem immediately */ + sync(); + return EINA_TRUE; + } + gl_dbgE("S_ISREG fail[%d]!", errno); + return EINA_FALSE; + } + + gl_dbgE("Fail[%d]!", errno); + return EINA_FALSE; + } + /* Write file to filesystem immediately */ + sync(); + return EINA_TRUE; +} + +char *_gl_fs_get_unique_full_path(char *file_path, char *ext) +{ + char *file_name = file_path; + char *extension = ext; + char *final_path = NULL; + int final_path_len = 0; + int extension_len = 0; + int suffix_count = 0; + /* means suffix on file name. up to "_99999" */ + const int max_suffix_count = 99999; + /* 1 means "_" */ + int suffix_len = (int)log10(max_suffix_count + 1) + 1; + + if (!file_path) + return NULL; + + gl_dbg("file_path=[%s], ext=[%s]", file_path, ext); + + if (extension) + extension_len = strlen(extension); + + /* first 1 for ".", last 1 for NULL */ + final_path_len = strlen(file_name) + 1 + suffix_len + extension_len + 1; + + final_path = (char*)calloc(1, final_path_len); + if (!final_path) { + gl_dbgE("calloc failed!"); + return NULL; + } + + do { + /* e.g) /tmp/abc.jpg + * if there is no extension name, just make a file name without extension */ + if (0 == extension_len) { + if (suffix_count == 0) { + snprintf(final_path, final_path_len, "%s", + file_name); + } else { + snprintf(final_path, final_path_len, "%s_%d", + file_name, suffix_count); + } + } else { + if (suffix_count == 0) { + snprintf(final_path, final_path_len, "%s.%s", + file_name, extension); + } else { + snprintf(final_path, final_path_len, "%s_%d.%s", + file_name, suffix_count, extension); + } + } + + if (ecore_file_exists(final_path)) { + suffix_count++; + if (suffix_count > max_suffix_count) { + gl_dbgE("Max suffix count!"); + GL_FREE(final_path); + break; + } else { + memset(final_path, 0x00, final_path_len); + continue; + } + } + + break; + } while (1); + + gl_dbg("Decided path = [%s]", final_path); + return final_path; +} + +bool _gl_fs_validate_name(const char *new_name) +{ + GL_CHECK_FALSE(new_name); + char invalid_chars[] = { '/', '\\', ':', '*', '?', '"', '<', '>', '|', '\0' }; + char *ptr = invalid_chars; + + gl_dbg("new album name is %s\n", new_name); + while (*ptr != '\0') + { + gl_dbg("invalid character is %c", *ptr); + if (strchr(new_name, (*ptr)) != NULL) + { + return false; + } + ++ptr; + } + + return true; +} + +int _gl_fs_get_default_folder(char *path) +{ + int len = 0; + GL_CHECK_VAL(path, -1); + + len = snprintf(path, GL_DIR_PATH_LEN_MAX, "%s", + GL_ROOT_PATH_PHONE); + if (len < 0) { + gl_dbgE("snprintf returns failure!"); + return -1; + } else { + path[len] = '\0'; + len = -1; + } + + len = g_strlcat(path, GL_DEFAULT_PATH_IMAGES, + GL_DIR_PATH_LEN_MAX); + if (len >= GL_DIR_PATH_LEN_MAX) { + gl_dbgE("strlcat returns failure(%d)!", len); + return -1; + } + gl_dbg("Default images path: %s.", path); + + return 0; +} + +bool _gl_fs_mkdir(const char *path) +{ + GL_CHECK_FALSE(path); + struct stat st; + if (stat(path, &st) < 0) { + if (!ecore_file_mkpath(path)) { + gl_dbgE("Failed to mkdir!"); + return false; + } + } + return true; +} + diff --git a/src/util/gl-lang.c b/src/util/gl-lang.c new file mode 100755 index 0000000..d05a5c5 --- /dev/null +++ b/src/util/gl-lang.c @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gallery.h" +#include "gl-lang.h" +#include "gl-strings.h" +#include "gl-popup.h" +#include "gl-ctxpopup.h" +#include "gl-debug.h" +#include "gl-tags.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-progressbar.h" +#include "gl-controlbar.h" +#include "gl-notify.h" +#include "gl-albums-sel.h" +#include "gl-albums-edit.h" +#include "gl-albums-rename.h" +#include "gl-thumbs-sel.h" +#include "gl-thumbs-edit.h" +#include "gl-tags-edit.h" + +static int __gl_lang_update_all_albums_name(void *data); + +static int __gl_lang_update_tabbar(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->ctrlinfo.ctrlbar, -1); + Evas_Object *ctrlbar = ad->ctrlinfo.ctrlbar; + + /*Reset text for tabbar*/ + Elm_Object_Item *item = NULL; + item = elm_toolbar_first_item_get(ctrlbar); + elm_object_item_text_set(item, GL_STR_CTRL_ITEM_ALBUMS); + char *tab_name = NULL; + int i = GL_CTRL_TAB_TAGS; + for (; i < GL_CTRL_TAB_CNT; ++i) { + item = elm_toolbar_item_next_get(item); + switch (i) { + case GL_CTRL_TAB_TAGS: + tab_name = GL_STR_CTRL_ITEM_TAGS; + break; + default: + break; + } + elm_object_item_text_set(item, tab_name); + } + return 0; +} + +static int __gl_lang_update_albums(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->ctrlinfo.nf_it, -1); + + __gl_lang_update_tabbar(data); + + /*Album view */ + _gl_ui_set_btns_text(ad->ctrlinfo.nf_it, GL_STR_CAMERA, NULL); + __gl_lang_update_all_albums_name(ad); + return 0; +} + +static int __gl_lang_update_thumb(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->gridinfo.nf_it, -1); + char *title = NULL; + char *btn_text2 = GL_STR_SLIDESHOW; + + switch (ad->ctrlinfo.tab_mode) { + case GL_CTRL_TAB_ALBUMS: { + GL_CHECK_VAL(ad->albuminfo.current_album, -1); + gl_cluster *album = ad->albuminfo.current_album; + GL_CHECK_VAL(album->cluster, -1); + title = _gl_get_i18n_album_name(album); + if (album->cluster->type == GL_STORE_T_ALL) { + title = GL_ALBUM_ALL_NAME; + } else if (album->cluster->type == GL_STORE_T_PHONE || + album->cluster->type == GL_STORE_T_MMC) { + if (_gl_data_is_root_path(album->cluster->path)) { + /* check root case */ + title = GL_ALBUM_PHOME_ROOT_NAME; + } else if (ad->albuminfo.aul_launch_type == GL_AUL_T_VIEW_ALBUM) { + /* launch by appcontrol */ + if (ad->albuminfo.aul_file_type == GL_AUL_FILE_T_IMAGE) + title = GL_ALBUM_IMAGES_NAME; + else if (ad->albuminfo.aul_file_type == GL_AUL_FILE_T_VIDEO) + title = GL_ALBUM_VIDEOS_NAME; + else + title = GL_ALBUM_ALL_NAME; + } + } + break; + } + case GL_CTRL_TAB_TAGS: { + Evas_Object *btn = NULL; + btn = elm_object_item_part_content_get(ad->gridinfo.nf_it, + GL_NAVIFRAME_TITLE_RIGHT_BTN); + if (btn) + elm_object_text_set(btn, GL_STR_ADD); + gl_tag *gtag = ad->taginfo.current_tag; + if (gtag && gtag->tag && + gtag->tag->_id == GL_TAG_FAVORITES_ID) { + GL_FREEIF(gtag->tag->tag_name); + gtag->tag->tag_name = strdup(GL_TAG_FAVORITES_NAME); + title = gtag->tag->tag_name; + } + break; + } + default: + gl_dbgE("Error tab mode!"); + return -1; + } + + _gl_ui_set_btns_text(ad->gridinfo.nf_it, GL_STR_EDIT, btn_text2); + + if (title) { + elm_object_item_text_set(ad->gridinfo.nf_it, title); + } + + return 0; +} + +static int __gl_lang_update_all_albums_name(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_cluster *album = NULL; + Elm_Object_Item *first_it = NULL; + Elm_Object_Item *next_it = NULL; + Elm_Object_Item *last_it = NULL; + Evas_Object *album_view = NULL; + + if (gl_get_view_mode(ad) == GL_VIEW_ALBUMS) + album_view = ad->albuminfo.albums_view; + else if (gl_get_view_mode(ad) == GL_VIEW_ALBUMS_EDIT) + album_view = ad->ctrlinfo.ctrlbar_edit_view; + GL_CHECK_VAL(album_view, -1); + + first_it = elm_gengrid_first_item_get(album_view); + last_it = elm_gengrid_last_item_get(album_view); + while(first_it) { + album = (gl_cluster *)elm_object_item_data_get(first_it); + if (album == NULL) { + gl_dbgE("Invalid item data!"); + continue; + } + if (!g_strcmp0(album->cluster->uuid, GL_ALBUM_ALL_ID)) { + GL_FREEIF(album->cluster->display_name); + album->cluster->display_name = strdup(GL_ALBUM_ALL_NAME); + elm_gengrid_item_update(first_it); + } else if (_gl_data_is_default_album(GL_ALBUM_DEFAULT_NAME, album->cluster) || + _gl_data_is_default_album(GL_ALBUM_DOWNLOAD_NAME, album->cluster) || + _gl_data_is_root_path(album->cluster->path)) { + elm_gengrid_item_update(first_it); + } + if (last_it == first_it) { + gl_dbg("Update done!"); + break; + } else { + next_it = elm_gengrid_item_next_get(first_it); + first_it = next_it; + } + album = NULL; + } + return 0; +} + +int _gl_lang_update_thumb_edit_button(void *data, Elm_Object_Item *nf_it) +{ + GL_CHECK_VAL(nf_it, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + char *btn_text = NULL; + char *btn_text2 = NULL; + + btn_text = GL_STR_SHARE; + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_ALBUMS) + btn_text2 = GL_STR_DELETE; + else + btn_text2 = GL_STR_REMOVE; + + _gl_ui_set_btns_text(nf_it, btn_text, btn_text2); + return 0; +} + +int _gl_lang_update(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + + /* Remove ctxpopup */ + _gl_ctxpopup_del(data); + + __gl_lang_update_albums(data); + switch (view_mode) { + case GL_VIEW_ALBUMS: + break; + case GL_VIEW_ALBUMS_EDIT: + _gl_albums_edit_update_lang(data); + break; + case GL_VIEW_ALBUMS_RENAME: + _gl_albums_edit_update_lang(data); + _gl_albums_rename_update_lang(data); + break; + case GL_VIEW_ALBUMS_SELECT: + _gl_tags_update_lang(data); + __gl_lang_update_thumb(data); + _gl_albums_sel_update_lang(data); + break; + case GL_VIEW_TAGS: + _gl_tags_update_lang(data); + _gl_albums_rename_update_lang(data); + break; + case GL_VIEW_TAGS_EDIT: + _gl_tags_edit_update_lang(data); + break; + case GL_VIEW_THUMBS: + __gl_lang_update_thumb(data); + break; + case GL_VIEW_THUMBS_EDIT: + __gl_lang_update_thumb(data); + _gl_thumbs_edit_update_lang(data); + break; + case GL_VIEW_THUMBS_SELECT: + _gl_tags_update_lang(data); + __gl_lang_update_thumb(data); + _gl_albums_sel_update_lang(data); + _gl_thumbs_sel_update_lang(data); + break; + default: + gl_dbgW("Other view_mode[%d]", view_mode); + } + + return 0; +} + diff --git a/src/util/gl-thread-util.c b/src/util/gl-thread-util.c new file mode 100755 index 0000000..8c627d5 --- /dev/null +++ b/src/util/gl-thread-util.c @@ -0,0 +1,658 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include "gl-thread-util.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-debug.h" +#include "gl-data.h" +#include "gl-popup.h" +#include "gl-progressbar.h" +#include "gl-strings.h" + +#define GALLERY_MAGIC_MAIN_CONTEXT (0x1983cdaf) +#define GALLERY_MAGIC_DETAIL_LIST_ITEM (0x1977abcd) +#define GALLERY_MAGIC_PIPE_DATA (0x0716ffcc) + +#define GALLERY_MAGIC unsigned int __magic +#define GALLERY_MAGIC_SET(d, m) (d)->__magic = (m) +#define GALLERY_MAGIC_CHECK(d, m) ((d) && ((d)->__magic == (m))) + +typedef struct +{ + GALLERY_MAGIC; + int finished_cnt; + int state; /* 0: operation is over; 1: operation is in process */ + int popup_op; +} gl_thread_pipe_data; + + +static pid_t +_gl_thread_gettid(void) +{ + return syscall(__NR_gettid); +} + +static int _gl_thread_operate_medias(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int ret = -1; + + switch (ad->maininfo.medias_op_type) { + case GL_MEDIA_OP_DELETE: + gl_dbg("Delete!"); + ret = gl_del_selected(data); + break; + case GL_MEDIA_OP_MOVE: + gl_dbg("Move!"); + ret = gl_move_selected(data); + break; + case GL_MEDIA_OP_ADD_TAG: + gl_dbg("Add tag to media!"); + ret = gl_add_tag_to_selected(data); + break; + case GL_MEDIA_OP_REMOVE_TAG: + gl_dbg("Remove tag from media!"); + ret = gl_remove_tag_from_selected(data); + break; +#ifdef _USE_ROTATE_BG + case GL_MEDIA_OP_ROTATING_LEFT: + case GL_MEDIA_OP_ROTATING_RIGHT: + gl_dbg("Rotate!"); + ret = _gl_rotate_selected(data, ad->maininfo.medias_op_type); + break; +#endif + default: + gl_dbgE("Unknow media operation mode!"); + break; + } + + if (ret < 0) { + gl_dbgE("Operation failed!"); + return -1; + } + + return 0; +} + +static int +_gl_thread_update_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + switch (ad->maininfo.medias_op_type) { + case GL_MEDIA_OP_DELETE: + gl_dbg("Delete!"); + gl_update_del_view(data); + break; + case GL_MEDIA_OP_MOVE: + gl_dbg("Move!"); + gl_update_move_view(data); + break; + case GL_MEDIA_OP_ADD_TAG: + gl_dbg("Add tag to media!"); + gl_update_add_tag_view(data); + break; + case GL_MEDIA_OP_REMOVE_TAG: + gl_dbg("Remove tag from media!"); + gl_update_remove_tag_view(data); + break; +#ifdef _USE_ROTATE_BG + case GL_MEDIA_OP_ROTATING_LEFT: + case GL_MEDIA_OP_ROTATING_RIGHT: + gl_dbg("Rotate!"); + _gl_update_rotate_view(data); + break; +#endif + default: + gl_dbgE("Unknow media operation mode!"); + break; + } + + return 0; +} + +static void * +_gl_thread_data_thread(void *data) +{ + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + int cancel_flag = 0; + + gl_dbg("@@@@@@@@@@ :::: Child thread ID = %d :::: @@@@@@@@@@", _gl_thread_gettid()); + /* Media movement/deleting operation/add tag/remove tag */ + _gl_thread_operate_medias(data); + /* send finish signal */ + gl_thread_pipe_data pipe_data; + memset(&pipe_data, 0x00, sizeof(gl_thread_pipe_data)); + GALLERY_MAGIC_SET(&pipe_data, GALLERY_MAGIC_PIPE_DATA); + /* Set over state */ + pipe_data.state = 0; + gl_thread_get_cancel_state(ad, &cancel_flag); + + ecore_pipe_write(ad->pbarinfo.sync_pipe, &pipe_data, sizeof(gl_thread_pipe_data)); + + gl_dbg("@@@@@@@@@@ :::: Child thread done :::: @@@@@@@@@@"); + + return (void *)0; +} + +static Eina_Bool _gl_thread_del_pbar_idler_cb(void *data) +{ + gl_dbg("Delete progressbar..."); + GL_CHECK_CANCEL(data); + gl_appdata *ad = (gl_appdata *)data; + /* Reset pb_cancel */ + gl_thread_set_cancel_state(ad, GL_PB_CANCEL_NONE); + /* Operation done, destroy progressbar */ + gl_pb_del_pbar(ad); + + /* Destroy lock */ + gl_thread_destroy_lock(ad); + + if (ad->pbarinfo.del_pbar_idler) { + ecore_idler_del(ad->pbarinfo.del_pbar_idler); + ad->pbarinfo.del_pbar_idler = NULL; + } + return ECORE_CALLBACK_CANCEL; +} + +static void _gl_thread_pipe_cb(void *data, void *buffer, unsigned int nbyte) +{ + gl_dbg(":::::::::: Main thread ID = %d ::::::::::", _gl_thread_gettid()); + GL_CHECK(data); + GL_CHECK(buffer); + gl_appdata *ad = (gl_appdata *)data; + gl_thread_pipe_data *p_pipe_data = (gl_thread_pipe_data *) buffer; + gl_dbg("Pipe state is %d", p_pipe_data->state); + + if (!GALLERY_MAGIC_CHECK(p_pipe_data, GALLERY_MAGIC_PIPE_DATA)) { + gl_dbgE("##### :: Check p_pipe_data Magic failed :: #####"); + return; + } + + int cancel_flag = false; + gl_thread_get_cancel_state(ad, &cancel_flag); + + if (p_pipe_data->popup_op) + { + if (p_pipe_data->state) + { + /* Check cancel_flag */ + if (cancel_flag != GL_PB_CANCEL_NORMAL) { + gl_dbgE("Failed to kill thread, try again!"); + gl_thread_emit_next_signal(ad); + return; + } + + char msg[GL_FILE_PATH_LEN_MAX] = { 0, }; + gl_item *cur_gitem = NULL; + /* Get selected media */ + _gl_data_get_item_by_index(ad, + p_pipe_data->finished_cnt, + true, &cur_gitem); + GL_CHECK(cur_gitem); + GL_CHECK(cur_gitem->item); + GL_CHECK(cur_gitem->item->display_name); + + if (p_pipe_data->popup_op == GL_POPUP_OP_SAME_ALBUM) + snprintf(msg, sizeof(msg), + "Cannot move %s to the same album!", + cur_gitem->item->display_name); + else if (p_pipe_data->popup_op == GL_POPUP_OP_DUPLICATED_NAME) + snprintf(msg, sizeof(msg), + "%s is duplicated, rename it!", + cur_gitem->item->display_name); + else if (p_pipe_data->popup_op == GL_POPUP_OP_PROTECTED_FILE) + snprintf(msg, sizeof(msg), + "Cannot removed protected file %s!", + cur_gitem->item->display_name); + gl_dbg("Popup description: %s", msg); + gl_popup_create_popup(ad, GL_POPUP_NOBUT_MOV_DEL, msg); + } + else if (ad->popupinfo.popup) + { + /* + * If p_pipe_data->state is equal to 0, + * it means thread should be destoryed. + */ + evas_object_del(ad->popupinfo.popup); + ad->popupinfo.popup = NULL; + } + } + + /* Update progressbar state */ + int all_cnt = 0; + all_cnt = _gl_data_selected_list_count(ad); + + if (p_pipe_data->state) { + /* Check cancel_flag */ + if (cancel_flag != GL_PB_CANCEL_NORMAL) { + gl_dbgE("Failed to kill thread, try again!"); + gl_thread_emit_next_signal(ad); + return; + } + /* 1. Moving/deleting is in porcess */ + gl_pb_refresh_thread_pbar(ad, p_pipe_data->finished_cnt, all_cnt); + gl_dbg("@@@ finished/all = %d/%d, updating progressbar @@@", + p_pipe_data->finished_cnt, all_cnt); + /* Emit signal to notice child thread handle next media */ + gl_dbg("Emit next signal..."); + gl_thread_emit_next_signal(ad); + } else { + /* 2. Moving/deleting is over, show finished count */ + gl_dbg("@@@ finished: %d, updating progressbar @@@", + ad->pbarinfo.finished_cnt); + gl_pb_refresh_thread_pbar(ad, ad->pbarinfo.finished_cnt, + ad->pbarinfo.finished_cnt); + ad->pbarinfo.finished_cnt = 0; + gl_dbg("@@@@@@@ :::: Pipe close && Update view :::: @@@@@@@"); + int cancel_flag = false; + gl_thread_get_cancel_state(ad, &cancel_flag); + + /* Use idler to delete progressbar to refresh status totally */ + if (ad->pbarinfo.del_pbar_idler) { + ecore_idler_del(ad->pbarinfo.del_pbar_idler); + ad->pbarinfo.del_pbar_idler = NULL; + } + Ecore_Idler *idler= NULL; + + idler = ecore_idler_add(_gl_thread_del_pbar_idler_cb, + ad); + ad->pbarinfo.del_pbar_idler = idler; + + int mmc_state = ad->maininfo.mmc_state; + int op_type = ad->maininfo.medias_op_type; + gl_dbg("MMC state: %d, OP type: %d.", mmc_state, op_type); + /* Operate medias related to MMC while moving medias */ + if (mmc_state == GL_MMC_STATE_REMOVED_MOVING) { + ad->maininfo.mmc_state = GL_MMC_STATE_REMOVED; + + /** + * 1, Places: Add tag; + * 2, Tags: Add tag/remove tag; + * 3, Albums: Move/Delete/Add tag. + * + * Case 1: Source folder/tag/marker does exist, update view. + * Case 2: Source folder is MMC, and it vanished. + */ + gl_cluster *cur_album = ad->albuminfo.current_album; + if (cur_album && cur_album->cluster && + cur_album->cluster->type == GL_STORE_T_MMC) { + gl_dbgW("MMC removed, change to albums view!"); + gl_pop_to_ctrlbar_ly(ad, true); + } else { + /* Update albums list when change to normal view */ + if (op_type == GL_MEDIA_OP_ADD_TAG) + ad->albuminfo.update_albums_list = true; + _gl_thread_update_view(ad); + } + } else { + /* Operated files on MMC, reset MMC state */ + if (mmc_state == GL_MMC_STATE_ADDED_MOVING) { + ad->maininfo.mmc_state = GL_MMC_STATE_ADDED; + } else if (mmc_state == GL_MMC_STATE_ADDING_MOVING) { + ad->maininfo.mmc_state = GL_MMC_STATE_ADDED; + /* Update albums list when change to normal view */ + if (op_type == GL_MEDIA_OP_ADD_TAG) + ad->albuminfo.update_albums_list = true; + } + /* Refresh view */ + _gl_thread_update_view(ad); + } + + /* Free Ecore_Pipe object created */ + if (ad->pbarinfo.sync_pipe) { + ecore_pipe_del(ad->pbarinfo.sync_pipe); + ad->pbarinfo.sync_pipe = NULL; + } + + /* Set medias_op_type none to stop refreshing view*/ + ad->maininfo.medias_op_type = GL_MEDIA_OP_NONE; + } +} + +/******************************************************* +** Prototype : gl_thread_emit_next_signal +** Description : Emit signal to notice child thread handle next media. +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +int +gl_thread_emit_next_signal(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + pthread_mutex_lock(&(ad->pbarinfo.refresh_lock)); + gl_dbg("refresh_flag: %d.", ad->pbarinfo.refresh_flag); + if (ad->pbarinfo.refresh_flag == 0) + { + ad->pbarinfo.refresh_flag = 1; + pthread_cond_signal(&(ad->pbarinfo.refresh_cond)); + } + pthread_mutex_unlock(&(ad->pbarinfo.refresh_lock)); + + return 0; +} + +/******************************************************* +** Prototype : gl_thread_wait_next_signal +** Description : Wait start signal to handle next media. +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +int +gl_thread_wait_next_signal(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + pthread_mutex_lock(&(ad->pbarinfo.refresh_lock)); + gl_dbg("refresh_flag: %d.", ad->pbarinfo.refresh_flag); + while (ad->pbarinfo.refresh_flag == 0) + { + gl_dbg("Thread waiting..."); + pthread_cond_wait(&(ad->pbarinfo.refresh_cond), &(ad->pbarinfo.refresh_lock)); + } + ad->pbarinfo.refresh_flag = 0; + pthread_mutex_unlock(&(ad->pbarinfo.refresh_lock)); + + return 0; +} + +/******************************************************* +** Prototype : gl_thread_set_cancel_state +** Description : Set the value of cancel flag. +** Input : void *data +** Input : int val +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +int +gl_thread_set_cancel_state(void *data, int val) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + pthread_mutex_lock(&(ad->pbarinfo.pbar_lock)); + ad->pbarinfo.pbar_cancel = val; + pthread_mutex_unlock(&(ad->pbarinfo.pbar_lock)); + + return 0; +} + +/******************************************************* +** Prototype : gl_thread_get_cancel_state +** Description : Get the value of cancel flag. +** Input : void *data +** Output : int* val +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +int +gl_thread_get_cancel_state(void *data, int *val) +{ + GL_CHECK_VAL(val, -1); + gl_appdata *ad = (gl_appdata *)data; + + pthread_mutex_lock(&(ad->pbarinfo.pbar_lock)); + *val = ad->pbarinfo.pbar_cancel; + pthread_mutex_unlock(&(ad->pbarinfo.pbar_lock)); + + return 0; +} + + +/******************************************************* +** Prototype : gl_thread_write_pipe +** Description : Write date to pipe in order to make progressbar refreshed +** Input : void *data +** Input : int finished_cnt +** Input : int popup_op +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +void +gl_thread_write_pipe(void *data, int finished_cnt, int popup_op) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int cancel_flag = false; + + gl_dbg("Wait next signal..."); + gl_thread_wait_next_signal(ad); + + gl_thread_pipe_data pipe_data; + memset(&pipe_data, 0x00, sizeof(gl_thread_pipe_data)); + GALLERY_MAGIC_SET(&pipe_data, GALLERY_MAGIC_PIPE_DATA); + + pipe_data.state = 1; + pipe_data.finished_cnt = finished_cnt; + pipe_data.popup_op = popup_op; + + gl_thread_get_cancel_state(ad, &cancel_flag); + + if (cancel_flag == GL_PB_CANCEL_BUTTON || + cancel_flag == GL_PB_CANCEL_MMC || + cancel_flag == GL_PB_CANCEL_ERROR || + cancel_flag == GL_PB_CANCEL_RESET) + { + //send cancel signal through pipe + pipe_data.finished_cnt = -1; + /* Set over state */ + pipe_data.state = 0; + ecore_pipe_write(ad->pbarinfo.sync_pipe, &pipe_data, sizeof(gl_thread_pipe_data)); + //exit the child thread + if (cancel_flag == GL_PB_CANCEL_BUTTON) + { + gl_dbg("Cancel button tapped, child thread exit!"); + } + else if (cancel_flag == GL_PB_CANCEL_MMC) + { + gl_dbg("MMC removed, child thread exit!"); + } + else if (cancel_flag == GL_PB_CANCEL_ERROR) + { + gl_dbg("Error happened, child thread exit!"); + } + else if (cancel_flag == GL_PB_CANCEL_RESET) { + gl_dbg("Reset gallery, child thread exit!"); + } + + pthread_exit((void *)1); + } + else + { + gl_dbg("Writing pipe..."); + ecore_pipe_write(ad->pbarinfo.sync_pipe, &pipe_data, sizeof(gl_thread_pipe_data)); + } +} + +/******************************************************* +** Prototype : gl_thread_gen_data_thread +** Description : Create child thread for moving or deleting medias +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +int +gl_thread_gen_data_thread(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + pthread_t tid; + pthread_attr_t attr; + int ret = -1; + + gl_dbg("Creating child thread."); + //add pipe for update progressbar status + ad->pbarinfo.sync_pipe = ecore_pipe_add(_gl_thread_pipe_cb, ad); + //initialize thread attributes + ret = pthread_attr_init(&attr); + if (ret == 0) + { + ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + if (ret == 0) + { + //create child thread + ret = pthread_create(&tid, &attr, _gl_thread_data_thread, ad); + if (ret != 0) + { + gl_dbgE("[Error] ##### :: pthread_create failed :: #####"); + pthread_attr_destroy(&attr); + return -1; + } + } + } + + gl_dbg("\n\n[Done] @@@@@@@@@@ :::: pthread_create successfull :::: @@@@@@@@@@\n"); + pthread_attr_destroy(&attr); + + return 0; +} + +/******************************************************* +** Prototype : gl_thread_destroy_lock +** Description : Destroy mutex lock. +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +int +gl_thread_destroy_lock(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("@@@@@@@@@@ :::: Destroy MUTEX :::: @@@@@@@@@@"); + + /** + * The variable below was accessed without holding a guarding lock. + * In a multithreaded environment, this can lead to a race condition. + * Add lock to prevent from RC. + */ + pthread_mutex_lock(&(ad->pbarinfo.refresh_lock)); + ad->pbarinfo.refresh_flag = 0; + pthread_mutex_unlock(&(ad->pbarinfo.refresh_lock)); + + pthread_cond_destroy(&(ad->pbarinfo.refresh_cond)); + pthread_mutex_destroy(&(ad->pbarinfo.pbar_lock)); + pthread_mutex_destroy(&(ad->pbarinfo.refresh_lock)); + + return 0; +} + +/******************************************************* +** Prototype : gl_thread_init_lock +** Description : Initialize mutex lock +** Input : void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +int +gl_thread_init_lock(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("@@@@@@@@@@ :::: Initialize MUTEX :::: @@@@@@@@@@"); + + pthread_mutex_init(&(ad->pbarinfo.pbar_lock), NULL); + pthread_mutex_init(&(ad->pbarinfo.refresh_lock), NULL); + pthread_cond_init(&(ad->pbarinfo.refresh_cond), NULL); + + /** + * The variable below was accessed without holding a guarding lock. + * In a multithreaded environment, this can lead to a race condition. + * Add lock to prevent from RC. + */ + pthread_mutex_lock(&(ad->pbarinfo.refresh_lock)); + ad->pbarinfo.refresh_flag = 0; + pthread_mutex_unlock(&(ad->pbarinfo.refresh_lock)); + + return 0; +} diff --git a/src/util/gl-ui-util.c b/src/util/gl-ui-util.c new file mode 100755 index 0000000..77bb4cf --- /dev/null +++ b/src/util/gl-ui-util.c @@ -0,0 +1,1073 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "gl-fs.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-ext-ug-load.h" +#include "gl-ext-exec.h" +#include "gl-button.h" +#include "gl-thumbs.h" +#include "gl-controlbar.h" +#include "gl-albums.h" +#include "gl-debug.h" +#include "gl-data.h" +#include "gl-tags.h" +#include "gl-thread-util.h" +#include "gl-popup.h" +#include "gl-ctxpopup.h" +#include "gl-progressbar.h" +#include "gl-albums-sel.h" +#include "gl-albums-new.h" +#include "gl-albums-edit.h" +#include "gl-thumbs-edit.h" +#include "gl-strings.h" +#include "gl-icons.h" +#include "gl-notify.h" + +#define GL_SELALL_TIMER_INT 0.5 + +/** + * Launch camera + */ +static void __gl_ui_camera_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_dbg(""); + _gl_ext_load_camera(); +} + +/* Use timer to prevent lockup when click select-all frequently */ +static Eina_Bool __gl_ui_selall_timer_cb(void *data) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + if (ad->selectedinfo.selall_timer) { + ecore_timer_del(ad->selectedinfo.selall_timer); + ad->selectedinfo.selall_timer = NULL; + } + return ECORE_CALLBACK_CANCEL; +} + +/* Select-all checkbox selected/deselected */ +static void _gl_ui_selall_check_changed(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d.", view_mode); + + if (ad->selectedinfo.selall_timer) { + gl_dbgW("Wait a sec!"); + elm_check_state_set(obj, ad->selectedinfo.ck_state); + return; + } + + ad->selectedinfo.selall_timer = ecore_timer_add(GL_SELALL_TIMER_INT, + __gl_ui_selall_timer_cb, + data); + int i = 0; + int item_cnt = 0; + int sel_all_cnt = 0; + Eina_Bool state = EINA_FALSE; + state = elm_check_state_get(obj); + gl_dbg("Checkbox state: %d.", state); + ad->selectedinfo.ck_state = state; + + if (view_mode == GL_VIEW_TAGS_EDIT) { + item_cnt = _gl_data_get_tag_count_all(ad); + sel_all_cnt = item_cnt - 1; /* minus favorites tag */ + gl_tag *gtag = NULL; + + for (i = 0; i < item_cnt; i++) { + _gl_data_get_tag_by_index(ad, >ag, i); + if (!gtag || !gtag->tag) + continue; + + if (gtag->checked == state || + gtag->tag->_id == GL_TAG_FAVORITES_ID) + continue; + + gtag->checked = state; + if (state == EINA_TRUE) + _gl_data_tags_selected_list_append(ad, gtag); + else + _gl_data_tags_selected_list_remove(ad, gtag); + } + + /* Update all realized items */ + elm_genlist_realized_items_update(ad->ctrlinfo.ctrlbar_edit_view); + } else if (view_mode == GL_VIEW_ALBUMS_EDIT) { + gl_cluster *album = NULL; + Elm_Object_Item *first_it = NULL; + Elm_Object_Item *next_it = NULL; + Elm_Object_Item *last_it = NULL; + first_it = elm_gengrid_first_item_get(ad->ctrlinfo.ctrlbar_edit_view); + last_it = elm_gengrid_last_item_get(ad->ctrlinfo.ctrlbar_edit_view); + while(first_it) { + /* Get data */ + item_cnt++; + album = (gl_cluster *)elm_object_item_data_get(first_it); + if (album == NULL) { + gl_dbgE("Invalid item data!"); + continue; + } + + if (album->checked == state){ + /* Get next item */ + next_it = elm_gengrid_item_next_get(first_it); + first_it = next_it; + album = NULL; + continue; + } + + /* Update checkbox state */ + album->checked = state; + /* Update selected list */ + if (state == EINA_TRUE) + _gl_data_albums_selected_list_append(ad, album); + else + _gl_data_albums_selected_list_remove(ad, album); + /* Update UI */ + /* elm_gengrid_item_update(first_it); */ + + if (last_it == first_it) { + gl_dbg("Update done!"); + break; + } else { + next_it = elm_gengrid_item_next_get(first_it); + first_it = next_it; + } + album = NULL; + } + /* Update all realized items */ + elm_gengrid_realized_items_update(ad->ctrlinfo.ctrlbar_edit_view); + /* Update selected album count */ + sel_all_cnt = item_cnt; + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + /* Get all medias count of current album */ + gl_item *gitem = NULL; + item_cnt = ad->maininfo.medias_cnt; + sel_all_cnt = item_cnt; + for (i = 0; i < item_cnt; i++) { + _gl_data_get_item_by_index(ad, i + 1, false, &gitem); + GL_CHECK(gitem); + GL_CHECK(gitem->item); + + if (gitem->checked == state) + continue; + + gitem->checked = state; + /* elm_gengrid_item_update(gitem->elm_item); */ + + if (state == EINA_TRUE) + _gl_data_selected_list_append(ad, gitem); + else + _gl_data_selected_list_remove(ad, gitem); + } + /* Update all realized items */ + elm_gengrid_realized_items_update(ad->gridinfo.select_view); + } else { + /* Get all medias count of current album */ + item_cnt = ad->maininfo.medias_cnt; + sel_all_cnt = item_cnt; + int grid_mode = ad->gridinfo.view_mode; + media_content_type_e file_type = MEDIA_CONTENT_TYPE_IMAGE; + if (view_mode == GL_VIEW_THUMBS_EDIT) { + if (grid_mode == GL_THUMB_IMAGES) { + file_type = MEDIA_CONTENT_TYPE_IMAGE; + sel_all_cnt = 0; + } else if (grid_mode == GL_THUMB_VIDEOS) { + file_type = MEDIA_CONTENT_TYPE_VIDEO; + sel_all_cnt = 0; + } + } + gl_dbg("grid_mode=%d", grid_mode); + gl_item *gitem = NULL; + for (i = 0; i < item_cnt; i++) { + _gl_data_get_item_by_index(ad, i + 1, false, &gitem); + GL_CHECK(gitem); + GL_CHECK(gitem->item); + + if (gitem->checked == state && grid_mode == GL_THUMB_ALL) + continue; + + if (view_mode == GL_VIEW_THUMBS_EDIT) { + if ((grid_mode == GL_THUMB_IMAGES) || + (grid_mode == GL_THUMB_VIDEOS)) { + if (gitem->item->type != file_type) + continue; + + sel_all_cnt++; + if (gitem->checked == state) + continue; + } + } + gitem->checked = state; + + if (state == EINA_TRUE) + _gl_data_selected_list_append(ad, gitem); + else + _gl_data_selected_list_remove(ad, gitem); + + } + /* Update all realized items */ + elm_gengrid_realized_items_update(ad->gridinfo.navi_content_edit_view); + } + + /* Recreate selection info for both cases */ + if (state == EINA_FALSE) + sel_all_cnt = 0; + + if (view_mode == GL_VIEW_TAGS_EDIT || + view_mode == GL_VIEW_ALBUMS_EDIT) { + _gl_notify_create_selinfo(ad, ad->ctrlinfo.ctrlbar_edit_ly, + ad->ctrlinfo.nf_it_edit, item_cnt, + sel_all_cnt, false); + if (view_mode == GL_VIEW_TAGS_EDIT) + gl_tag_unset_rename(ad); + } else if (view_mode == GL_VIEW_THUMBS_SELECT){ + _gl_notify_create_selinfo(ad, ad->gridinfo.select_view_ly, + ad->gridinfo.nf_it_select, item_cnt, + sel_all_cnt, false); + } else { + _gl_notify_create_selinfo(ad, ad->gridinfo.navi_content_edit_ly, + ad->gridinfo.nf_it_edit, item_cnt, + sel_all_cnt, false); + } +} + +/* Select-all background click, selected/deselected checkbox */ +static void _gl_ui_selall_bg_click_cb(void *data, Evas_Object *o, + const char *emission, + const char *source) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + Evas_Object *ly = NULL; + gl_dbg("view_mode: %d.", view_mode); + + if (ad->selectedinfo.selall_timer) { + gl_dbgW("Wait a sec!"); + return; + } + + ly = _gl_ui_get_view_layout(data, view_mode); + GL_CHECK(ly); + + Evas_Object *check = elm_object_part_content_get(ly, "selectall_check"); + if (check) { + Eina_Bool new_state = EINA_FALSE; + Eina_Bool ck_state = elm_check_state_get(check); + /* uncheck->check */ + if (ck_state == EINA_FALSE) + new_state = EINA_TRUE; + + elm_check_state_set(check, new_state); + + _gl_ui_selall_check_changed(ad, check, NULL); + } else { + gl_dbgE("Get select all checkbox object failed!"); + } +} + +void _gl_ui_edit_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + if (ad->uginfo.ug_called_by_me || ad->gridinfo.grid_append_idler) { + /** + * Prevent changed to edit view in wrong way. + * 1. When invoke imageviewer UG; + * 2. First show thumbnails view, use idler to append other medias. + */ + gl_dbg("UG invoked or appending gridview."); + return; + } + _gl_ctxpopup_del(data); + + int view_mode = gl_get_view_mode(data); + gl_dbg("mode: %d", view_mode); + if (view_mode == GL_VIEW_ALBUMS) { + _gl_albums_edit_create_view(data); + } else if (view_mode == GL_VIEW_THUMBS) { + _gl_thumbs_edit_create_view(data); + } +} + +static void __gl_ui_add_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me) { + gl_dbgW("UG or APP is already loaded!"); + return; + } + + int view_mode = gl_get_view_mode(ad); + if (view_mode == GL_VIEW_THUMBS) { + /* Clear selected list */ + _gl_notify_destroy_selinfo(ad); + /* Clear thumbnails edit view */ + + _gl_albums_sel_create_view(data); + } else { + gl_dbgE("Wrong view mode!"); + } +} + +Evas_Object *_gl_ui_get_view_layout(void *data, int view_mode) +{ + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *view_ly = NULL; + + gl_dbg("view_mode: %d", view_mode); + switch (view_mode) { + case GL_VIEW_ALBUMS_EDIT: + case GL_VIEW_TAGS_EDIT: + view_ly = ad->ctrlinfo.ctrlbar_edit_ly; + break; + case GL_VIEW_THUMBS_EDIT: + view_ly = ad->gridinfo.navi_content_edit_ly; + break; + case GL_VIEW_THUMBS_SELECT: + view_ly = ad->gridinfo.select_view_ly; + break; + default: + gl_dbgE("Wrong view!"); + return NULL; + } + + return view_ly; +} + +/** +* Update checkbox state in select-all widget +*/ +int _gl_ui_update_selall(void *data, int all_cnt, int selected_cnt) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + gl_item *gitem = NULL; + int _all_cnt = 0; + int db_all_cnt = 0; + media_content_type_e file_type = MEDIA_CONTENT_TYPE_IMAGE; + int view_mode = gl_get_view_mode(ad); + Evas_Object *ly = NULL; + + if (view_mode == GL_VIEW_THUMBS_EDIT) { + /* Get all medias count */ + db_all_cnt = ad->maininfo.medias_cnt; + int grid_mode = ad->gridinfo.view_mode; + if (grid_mode == GL_THUMB_ALL) { + _all_cnt = db_all_cnt; + } else { + /* Get all count in diff segments */ + if (grid_mode == GL_THUMB_IMAGES) + file_type = MEDIA_CONTENT_TYPE_IMAGE; + else if (grid_mode == GL_THUMB_VIDEOS) + file_type = MEDIA_CONTENT_TYPE_VIDEO; + + for (i = 1; i <= db_all_cnt; i++) { + _gl_data_get_item_by_index(ad, i, false, &gitem); + if (gitem && gitem->item && + (gitem->item->type == file_type)) + _all_cnt++; + } + } + ly = ad->gridinfo.navi_content_edit_ly; + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + /* Get all medias count */ + _all_cnt = ad->maininfo.medias_cnt; + ly = ad->gridinfo.select_view_ly; + } else if (view_mode == GL_VIEW_TAGS_EDIT) { + db_all_cnt = _gl_data_get_tag_count_all(ad); + /* Minus favorites tag, it's excluded in edit view . */ + _all_cnt = db_all_cnt - 1; + ly = ad->ctrlinfo.ctrlbar_edit_ly; + } else if (view_mode == GL_VIEW_ALBUMS_EDIT) { + _all_cnt = ad->albuminfo.albums_cnt; + ly = ad->ctrlinfo.ctrlbar_edit_ly; + } else { + gl_dbg("Wrong view mode!"); + return 0; + } + + /** + * Set checkbox state + * except in albums edit view and selectioninfo view + */ + gl_dbg("selected_cnt/_all_cnt = %d/%d", selected_cnt, _all_cnt); + Evas_Object *check = NULL; + Eina_Bool state = EINA_FALSE; + /* Set checkbox checked/unchecked */ + if (selected_cnt == _all_cnt) + state = EINA_TRUE; + else + state = EINA_FALSE; + + check = elm_object_part_content_get(ly, "selectall_check"); + if (check) + elm_check_state_set(check, state); + return 0; +} + +static void __gl_ui_albums_more_btn_cb(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbg("more button clicked"); + /* Add 'Edit' + 'Add web album' */ + GL_CHECK(data); + _gl_ctxpopup_create_albums(data, obj); +} + +static void __gl_ui_thumbs_more_btn_cb(void *data, Evas_Object *obj, void *event_info) +{ + gl_dbg("more button clicked"); + /* Add 'Add to home' */ + GL_CHECK(data); + _gl_ctxpopup_create_thumbs(data, obj); +} + +/* pause gallery and change view to background after tap Back button in albums view */ +static void __gl_ui_lower_to_bg_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK(ad->maininfo.win); + gl_dbgW("Lower Gallery to background!"); + elm_win_lower(ad->maininfo.win); +} + +static void __gl_ui_trans_finished_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbgW("view_mode: %d", view_mode); + evas_object_smart_callback_del(obj, GL_TRANS_FINISHED, + __gl_ui_trans_finished_cb); + + /* Clear previous view after animation finished */ + if (view_mode == GL_VIEW_THUMBS) { + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_ALBUMS) + elm_gengrid_clear(ad->albuminfo.albums_view); + else if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) + elm_genlist_clear(ad->taginfo.tags_view); + } else { + gl_dbgE("Wrong view mode!"); + } +} + +static void __gl_ui_show_title_toolbar(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + Evas_Object *done_btn = NULL; + Elm_Object_Item *it = NULL; + gl_dbg("elm,state,sip,shown"); + + it = elm_naviframe_top_item_get((Evas_Object *)data); + GL_CHECK(it); + /* Set button to title toolbar */ + done_btn = elm_object_item_part_content_get(it, + GL_NAVIFRAME_TITLE_BTN1); + if (done_btn == NULL) { + done_btn = elm_object_item_part_content_unset(it, + GL_NAVIFRAME_BTN1); + elm_object_item_part_content_set(it, GL_NAVIFRAME_TITLE_BTN1, + done_btn); + } + elm_object_item_signal_emit(it, "elm,state,sip,shown", ""); +} + +static void __gl_ui_hide_title_toolbar(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + Evas_Object *done_btn = NULL; + Elm_Object_Item *it = NULL; + gl_dbg("elm,state,sip,hidden"); + + it = elm_naviframe_top_item_get((Evas_Object *)data); + GL_CHECK(it); + /* Set button to bottom toolbar */ + done_btn = elm_object_item_part_content_get(it, GL_NAVIFRAME_BTN1); + if (done_btn == NULL) { + done_btn = elm_object_item_part_content_unset(it, + GL_NAVIFRAME_TITLE_BTN1); + elm_object_item_part_content_set(it, GL_NAVIFRAME_BTN1, + done_btn); + } + elm_object_item_signal_emit(it, "elm,state,sip,hidden", ""); +} + +void _gl_ui_slideshow_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + _gl_ctxpopup_del(data); + _gl_slideshow(data); +} + +/** + * Use naviframe api to push albums view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_ui_push_view_albums(void *data, Evas_Object *parent, + Evas_Object *obj) +{ + gl_dbg("GL_NAVI_ALBUMS"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + Evas_Object *end_btn = NULL; + + /** + * add End button in navigation var first view in galery + * with style "naviframe/back_btn/gallery" + * so after tap this button,gallery is paused + * but change view to background + */ + GL_CHECK_VAL(ad->maininfo.win, -1); + end_btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_PRE, + __gl_ui_lower_to_bg_cb, ad); + GL_CHECK_VAL(end_btn, -1); + /* Push view to stack */ + gl_dbg_launch(" elm_naviframe_item_push:start"); + nf_it = elm_naviframe_item_push(parent, NULL, end_btn, NULL, obj, + GL_NF_ANI_TABBAR); + elm_naviframe_item_title_visible_set(nf_it, EINA_FALSE); + gl_dbg_launch(" elm_naviframe_item_push:end"); + ad->ctrlinfo.nf_it = nf_it; + + /* add buttons */ + _gl_ui_add_btns_albums(ad, GL_UI_ALBUMS_FIRST); + return 0; +} + +/** + * Use naviframe api to push thumbnails view to stack. + * @param obj is the content to be pushed. + */ +static int __gl_ui_push_view_thumbs(void *data, Evas_Object *parent, + Evas_Object *obj, char *title) +{ + gl_dbg("GL_NAVI_THUMBS"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *nf_it = NULL; + bool b_add_slideshow = false; + bool b_add_more = false; + + _gl_ctrl_show_tabbar(ad, false); + + /* Add transition finished callback */ + evas_object_smart_callback_add(parent, GL_TRANS_FINISHED, + __gl_ui_trans_finished_cb, ad); + /* Push to stack with basic transition */ + nf_it = elm_naviframe_item_push(parent, title, NULL, NULL, obj, + NULL); + ad->gridinfo.nf_it = nf_it; + + Evas_Object *btn = NULL; + /* Add Edit button */ + btn = _gl_but_create_but(parent, NULL, GL_STR_EDIT, + GL_BUTTON_STYLE_NAVI_TOOLBAR_LEFT, + _gl_ui_edit_cb, data); + GL_CHECK_VAL(btn, -1); + ad->gridinfo.edit_btn = btn; + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, btn); + + gl_dbg("tab_mode: %d", ad->ctrlinfo.tab_mode); + switch (ad->ctrlinfo.tab_mode) { + case GL_CTRL_TAB_ALBUMS: + b_add_slideshow = true; + b_add_more = true; + break; + case GL_CTRL_TAB_TAGS: + b_add_slideshow = true; + b_add_more = true; + _gl_ui_show_add_btn(ad); + break; + default: + gl_dbgE("Wrong tab mode!"); + return -1; + } + + if (b_add_slideshow) { + /* Add slide show button */ + gl_dbg("Add slideshow button"); + btn = _gl_but_create_but(parent, NULL, GL_STR_SLIDESHOW, + GL_BUTTON_STYLE_NAVI_TOOLBAR_RIGHT, + _gl_ui_slideshow_cb, ad); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN2, btn); + ad->gridinfo.slideshow_btn = btn; + if(ad->maininfo.medias_cnt <= 0) + _gl_ui_disable_slideshow(ad, true); + } + + if (b_add_more) { + /* More */ + btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_MORE, + __gl_ui_thumbs_more_btn_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_MORE, btn); + if (ad->maininfo.medias_cnt <= 0) + _gl_ui_disable_btn(btn); + } + + if (ad->maininfo.medias_cnt <= 0) + _gl_ui_disable_btn(ad->gridinfo.edit_btn); + return 0; +} + +int _gl_ui_disable_slideshow(void *data, bool b_disable) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d, b_disable: %d", view_mode, b_disable); + + if (view_mode == GL_VIEW_THUMBS) + elm_object_disabled_set(ad->gridinfo.slideshow_btn, b_disable); + else if (view_mode == GL_VIEW_THUMBS_EDIT) + ad->gridinfo.b_slideshow_disable = b_disable; + return 0; +} + +/* + * @param b_add, true: add 'Add' button, unset 'Add' button otherwise. + */ +int _gl_ui_show_add_btn(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *add_btn = NULL; + bool b_disable = false; + int err = -1; + int item_cnt = 0; + err = _gl_data_get_item_cnt(ad, GL_ALBUM_ALL_ID, false, GL_STORE_T_ALL, + &item_cnt); + if (err != 0 || item_cnt == 0) { + gl_dbg("None local albums, disable button."); + /* Disable button */ + b_disable = true; + } + gl_dbg("b_disable: %d", b_disable); + add_btn = elm_object_item_part_content_get(ad->gridinfo.nf_it, + GL_NAVIFRAME_TITLE_RIGHT_BTN); + if (add_btn) { + elm_object_disabled_set(add_btn, b_disable); + return 0; + } + add_btn = _gl_but_create_but(ad->maininfo.naviframe, GL_CBAR_ICON_ADD, + NULL, GL_BUTTON_STYLE_NAVI_TITLE_PLUS, + __gl_ui_add_cb, ad); + GL_CHECK_VAL(add_btn, -1); + elm_object_disabled_set(add_btn, b_disable); + elm_object_item_part_content_set(ad->gridinfo.nf_it, + GL_NAVIFRAME_TITLE_RIGHT_BTN, add_btn); + return 0; +} + +int _gl_ui_clear_btns(void *data) +{ + GL_CHECK_VAL(data, -1); + Evas_Object *btn = NULL; + gl_dbg(""); + + /* Remove more and camera */ + btn = _gl_ui_get_btn(data, NULL, GL_NAVIFRAME_MORE); + if (btn) { + evas_object_del(btn); + btn = NULL; + } + btn = _gl_ui_get_btn(data, NULL, GL_NAVIFRAME_BTN1); + if (btn) { + evas_object_del(btn); + btn = NULL; + } + btn = _gl_ui_get_btn(data, NULL, GL_NAVIFRAME_BTN2); + if (btn) { + evas_object_del(btn); + btn = NULL; + } + return 0; +} + +/** + * When push albums view for the first time, albums list is empty. + * After albums list got from DB then update edit item state. + * @param bool b_first, true, push albums view for the first time, enable edit item. + */ +int _gl_ui_add_btns_albums(void *data, int type) +{ + gl_dbg("type: %d", type); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + GL_CHECK_VAL(ad->ctrlinfo.nf_it, -1); + Evas_Object *parent = ad->maininfo.naviframe; + Elm_Object_Item *nf_it = ad->ctrlinfo.nf_it; + Evas_Object *btn = NULL; + + /* Remove btns */ + _gl_ui_clear_btns(data); + /* More */ + btn = _gl_but_create_but(parent, NULL, NULL, + GL_BUTTON_STYLE_NAVI_MORE, + __gl_ui_albums_more_btn_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_MORE, btn); + /* Camera */ + btn = _gl_but_create_but(parent, NULL, GL_STR_CAMERA, + GL_BUTTON_STYLE_NAVI_TOOLBAR, + __gl_ui_camera_cb, data); + GL_CHECK_VAL(btn, -1); + elm_object_item_part_content_set(nf_it, GL_NAVIFRAME_BTN1, btn); + + /* Disable items in exit mode */ + if ((!gl_check_gallery_empty(ad) && + ad->albuminfo.cluster_list->edit_cnt) || + (type == GL_UI_ALBUMS_FIRST)) { + ad->albuminfo.b_edit_disable = false; + } else { + ad->albuminfo.b_edit_disable = true; + } + + return 0; +} + +int gl_ui_create_title_and_push(void *data, Evas_Object *parent, + Evas_Object *obj, gl_navi_mode mode, char *title) +{ + gl_dbg_launch(" gl_ui_create_title_and_push:start"); + GL_CHECK_VAL(obj, -1); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + + if (mode == GL_NAVI_ALBUMS) + __gl_ui_push_view_albums(data, parent, obj); + else if (mode == GL_NAVI_THUMBS) + __gl_ui_push_view_thumbs(data, parent, obj, title); + gl_dbg("Done"); + gl_dbg_launch(" gl_ui_create_title_and_push:end"); + return 0; +} + +Evas_Object * +gl_ui_load_edj(Evas_Object * parent, const char *file, const char *group) +{ + Evas_Object *eo = NULL; + int r = 0; + + eo = elm_layout_add(parent); + if (eo) + { + r = elm_layout_file_set(eo, file, group); + if (!r) + { + evas_object_del(eo); + return NULL; + } + + evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL); + } + + return eo; +} + +/* Remove selection and edit view then pop to normal thumbnail view */ +int _gl_ui_pop_to_thumb(void *data) +{ + GL_CHECK_VAL(data, -1); + /* Delete edit view and update thumbnail view */ + _gl_thumbs_edit_pop_view(data); + return 0; +} + +/** +* Update checkbox state and add click signal to Select-all widget. +* Show arrow button in thumbnails/list edit mode. +*/ +int gl_ui_show_selall(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + Eina_Bool ck_state = EINA_FALSE; + Evas_Object *view_ly = NULL; + char *sig = GL_SIGNAL_VIEW_SELALL_SHOW; + + gl_dbg("view_mode: %d.", view_mode); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + view_ly = ad->gridinfo.navi_content_edit_ly; + if (ad->maininfo.medias_cnt == _gl_data_selected_list_count(ad)) + ck_state = EINA_TRUE; + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + view_ly = ad->gridinfo.select_view_ly; + } else if (view_mode == GL_VIEW_TAGS_EDIT) { + /* in Tags view */ + view_ly = ad->ctrlinfo.ctrlbar_edit_ly; + int cnt_all = _gl_data_get_tag_count_all(ad); + /* Check hidden item: "favorites" tag */ + if (cnt_all == _gl_data_get_tags_selected_cnt(ad) + 1) + ck_state = EINA_TRUE; + sig = GL_SIGNAL_VIEW_SELALL_TAG; + } else if (view_mode == GL_VIEW_ALBUMS_EDIT) { + /* in Albums view */ + view_ly = ad->ctrlinfo.ctrlbar_edit_ly; + if (ad->albuminfo.albums_cnt == _gl_data_get_albums_selected_cnt(ad)) + ck_state = EINA_TRUE; + } else { + gl_dbgE("Wrong view!"); + return -1; + } + + const char *text = NULL; + text = edje_object_part_text_get(_EDJ(view_ly), "selectall_text"); + if (text == NULL || g_strcmp0(text, GL_STR_SELECT_ALL)) + edje_object_part_text_set(_EDJ(view_ly), "selectall_text", + GL_STR_SELECT_ALL); + + Evas_Object *old_check = NULL; + old_check = elm_object_part_content_unset(view_ly, "selectall_check"); + if (old_check) + evas_object_del(old_check); + + Evas_Object *check = elm_check_add(view_ly); + evas_object_propagate_events_set(check, EINA_FALSE); + elm_check_state_set(check, ck_state); + + elm_object_part_content_set(view_ly, "selectall_check", check); + evas_object_smart_callback_add(check, "changed", + _gl_ui_selall_check_changed, ad); + edje_object_signal_emit(_EDJ(view_ly), sig, "elm"); + + /* Add signal to select-all bg */ + edje_object_signal_callback_del(_EDJ(view_ly), "elm,action,click", + "selectall_bg", + _gl_ui_selall_bg_click_cb); + edje_object_signal_callback_add(_EDJ(view_ly), "elm,action,click", + "selectall_bg", + _gl_ui_selall_bg_click_cb, ad); + + return 0; +} + +/* Update checkbox state of Select-all and selectioninfo */ +int gl_ui_update_select_widgets(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Update checkbox state of Select-all */ + gl_ui_show_selall(ad); + /* Update selectioninfo */ + int cnt = 0; + int sel_cnt = 0; + Evas_Object *layout = NULL; + Elm_Object_Item *nf_it = NULL; + + cnt = ad->maininfo.medias_cnt; + sel_cnt = _gl_data_selected_list_count(ad); + layout = ad->gridinfo.navi_content_edit_ly; + nf_it = ad->gridinfo.nf_it_edit; + _gl_notify_create_selinfo(ad, layout, nf_it , cnt, sel_cnt, false); + return 0; +} + +Evas_Object *gl_ui_create_main_ly(Evas_Object *parent) +{ + gl_dbg_launch(" gl_ui_create_main_ly:start"); + GL_CHECK_NULL(parent); + Evas_Object *layout = NULL; + + layout = elm_layout_add(parent); + GL_CHECK_NULL(layout); + + /* Apply the layout style */ + gl_dbg_launch(" elm_layout_theme_set:start"); + + const char *profile = elm_config_profile_get(); + if (!g_strcmp0(profile, "mobile")) { + elm_layout_theme_set(layout, "layout", "application", "default"); + } else if (!g_strcmp0(profile,"extension")) { + elm_layout_theme_set(layout, "layout", "application", + "noindicator"); + } + + gl_dbg_launch(" elm_layout_theme_set:end"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_show(layout); + gl_dbg_launch(" gl_ui_create_main_ly:end"); + + return layout; +} + +Evas_Object *gl_ui_create_naviframe(Evas_Object *parent) +{ + GL_CHECK_NULL(parent); + Evas_Object *navi_bar = NULL; + gl_dbg_launch(" gl_ui_create_naviframe:start"); + + navi_bar = elm_naviframe_add(parent); + gl_dbg("elm_naviframe_add:done"); + evas_object_show(navi_bar); + gl_dbg_launch(" gl_ui_create_naviframe:end"); + + return navi_bar; +} + +int gl_ui_set_navi_title_visible(void *data, bool b_visible) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Elm_Object_Item *it = NULL; + it = elm_naviframe_top_item_get(ad->maininfo.naviframe); + GL_CHECK_VAL(it, -1); + /* Hide title from animation */ + elm_naviframe_item_title_visible_set(it, b_visible); + return 0; +} + +int _gl_ui_add_conform_cbs(Evas_Object *naviframe) +{ + GL_CHECK_VAL(naviframe, -1); + Evas_Object *conform = NULL; + + /* Get conformant */ + conform = (Evas_Object *)evas_object_data_get(naviframe, + GL_NAVIFRAME_OBJ_DATA_KEY); + GL_CHECK_VAL(conform, -1); + + evas_object_smart_callback_add(conform, GL_IMF_ON, + __gl_ui_show_title_toolbar, naviframe); + evas_object_smart_callback_add(conform, GL_IMF_OFF, + __gl_ui_hide_title_toolbar, naviframe); + return 0; +} + +int _gl_ui_del_conform_cbs(Evas_Object *naviframe) +{ + GL_CHECK_VAL(naviframe, -1); + Evas_Object *conform = NULL; + + /* Get conformant */ + conform = (Evas_Object *)evas_object_data_get(naviframe, + GL_NAVIFRAME_OBJ_DATA_KEY); + GL_CHECK_VAL(conform, -1); + + evas_object_smart_callback_del(conform, GL_IMF_ON, + __gl_ui_show_title_toolbar); + evas_object_smart_callback_del(conform, GL_IMF_OFF, + __gl_ui_hide_title_toolbar); + return 0; +} + +int _gl_ui_disable_btn(Evas_Object *btn) +{ + if (btn) + elm_object_disabled_set(btn, EINA_TRUE); + return 0; +} + +int _gl_ui_enable_btn(Evas_Object *btn) +{ + if(btn) + elm_object_disabled_set(btn, EINA_FALSE); + return 0; +} + +/* Set each button(more/btn1/btn2) as each state respectively */ +int _gl_ui_disable_each_btn(Elm_Object_Item *nf_it, bool b_more, bool b_btn1, + bool b_btn2) +{ + GL_CHECK_VAL(nf_it, -1); + Evas_Object *btn = NULL; + gl_dbg("more/btn1/btn2 state: %d/%d/%d", b_more, b_btn1, b_btn2); + btn = elm_object_item_part_content_get(nf_it, GL_NAVIFRAME_MORE); + if (btn) + elm_object_disabled_set(btn, b_more); + btn = elm_object_item_part_content_get(nf_it, GL_NAVIFRAME_BTN1); + if (btn) + elm_object_disabled_set(btn, b_btn1); + btn = elm_object_item_part_content_get(nf_it, GL_NAVIFRAME_BTN2); + if (btn) + elm_object_disabled_set(btn, b_btn2); + return 0; +} + +int _gl_ui_set_btns_text(Elm_Object_Item *nf_it, char *btn_text, + char *btn_text2) +{ + GL_CHECK_VAL(nf_it, -1); + + Evas_Object *btn = NULL; + if (btn_text) { + btn = elm_object_item_part_content_get(nf_it, GL_NAVIFRAME_BTN1); + if (btn) + elm_object_text_set(btn, btn_text); + } + if (btn_text2) { + btn = elm_object_item_part_content_get(nf_it, GL_NAVIFRAME_BTN2); + if (btn) + elm_object_text_set(btn, btn_text2); + } + return 0; +} + +/* Set all buttons(more/btn1/btn2) as same state */ +int _gl_ui_disable_btns(Elm_Object_Item *nf_it, bool b_disable) +{ + return _gl_ui_disable_each_btn(nf_it, b_disable, b_disable, b_disable); +} + +/* Get button*/ +Evas_Object *_gl_ui_get_btn(void *data, Elm_Object_Item *nf_it, + const char *part) +{ + Elm_Object_Item *_nf_it = nf_it; + + if (_nf_it == NULL) { + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + _nf_it = elm_naviframe_top_item_get(ad->maininfo.naviframe); + GL_CHECK_NULL(_nf_it); + } + + return elm_object_item_part_content_get(_nf_it, part); +} + diff --git a/src/util/gl-util.c b/src/util/gl-util.c new file mode 100755 index 0000000..42263e2 --- /dev/null +++ b/src/util/gl-util.c @@ -0,0 +1,2539 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "gl-debug.h" +#include "gallery.h" +#include "gl-albums.h" +#include "gl-thumbs.h" +#include "gl-util.h" +#include "gl-ui-util.h" +#include "gl-controlbar.h" +#include "gl-tags.h" +#include "gl-thread-util.h" +#include "gl-popup.h" +#include "gl-ctxpopup.h" +#include "gl-progressbar.h" +#include "gl-ext-ug-load.h" +#include "gl-ext-exec.h" +#include "gl-tags-new.h" +#include "gl-albums-sel.h" +#include "gl-albums-edit.h" +#include "gl-thumbs-sel.h" +#include "gl-drm.h" +#include "gl-nocontents.h" +#include "gl-notify.h" +#include "gl-editfield.h" +#include "gl-strings.h" +#include "gl-icons.h" +#include "gl-data-type.h" +#include "gl-fs.h" +#ifdef _USE_ROTATE_BG +#include "gl-exif.h" +#endif + +#define GL_FILE_COPY_BUF_MAX 16384 +/* Time for displaying progressbar UI compeletely */ +#define GL_TIMER_INTERVAL_PBAR_SHOWED 0.5 +#define GL_TIMER_INTERVAL_VIBRATION 0.5 +#define GL_VIBRATION_DEVICE 0 +#define GL_VIBRATION_DURATION 500 +#ifdef _USE_ROTATE_BG +#define GL_ROTATE_DELAY 0.25 +#endif + +static int __gl_refresh_albums_list(void *data, bool b_path, bool b_select); + +/* Use timer to show progressbar totally before write pipe */ +static Eina_Bool _gl_start_thread_op_timer_cb(void *data) +{ + gl_dbg("Emit START signal..."); + GL_CHECK_CANCEL(data); + gl_appdata *ad = (gl_appdata *)data; + /* Emit signal to notice child thread to handle next item. */ + gl_thread_emit_next_signal(ad); + if (ad->pbarinfo.start_thread_timer) { + ecore_timer_del(ad->pbarinfo.start_thread_timer); + ad->pbarinfo.start_thread_timer = NULL; + } + return ECORE_CALLBACK_CANCEL; +} + +/** +* Use thread to move/delete/add tag to/remove tag from medias +* for displaying progrssabar UI +*/ +int _gl_use_thread_operate_medias(void *data, char *pbar_title, int all_cnt, + int op_type) +{ + gl_dbg("all_cnt: %d, op_type: %d.", all_cnt, op_type); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Initialize thread mutex lock */ + gl_thread_init_lock(ad); + /* Make progressbar */ + gl_pb_make_thread_pbar(ad, ad->maininfo.win, pbar_title); + /* Set pb_cancel, indicates thread operation is beginning */ + gl_thread_set_cancel_state(ad, GL_PB_CANCEL_NORMAL); + /* Initialize progressbar */ + gl_pb_refresh_thread_pbar(ad, 0, all_cnt); + /* Use timer to emit next signal to show progressbarbar totally */ + if (ad->pbarinfo.start_thread_timer) { + ecore_timer_del(ad->pbarinfo.start_thread_timer); + ad->pbarinfo.start_thread_timer = NULL; + } + Ecore_Timer *timer = NULL; + timer = ecore_timer_add(GL_TIMER_INTERVAL_PBAR_SHOWED, + _gl_start_thread_op_timer_cb, ad); + ad->pbarinfo.start_thread_timer = timer; + /* Set media operation type */ + ad->maininfo.medias_op_type = op_type; + /* Generate child thread */ + gl_thread_gen_data_thread(ad); + return 0; +} + +/* +* remove selected items(media) from some tag. +*/ +static int _gl_remove_tag_items(void *data, gl_tag * cur_tag) +{ + gl_dbg(""); + GL_CHECK_VAL(cur_tag, -1); + GL_CHECK_VAL(cur_tag->tag, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Get all selected medias count */ + int cnt = _gl_data_selected_list_count(ad); + if (cnt == 0) { + gl_dbg("No items selected, return!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return -1; + } + + gl_dbg("Remove tag[%s] from medias.", cur_tag->tag->tag_name); + /* Check MMC state for cancel operation */ + gl_check_mmc_state(ad, NULL); + gl_dbg("MMC state: %d.", ad->maininfo.mmc_state); + _gl_use_thread_operate_medias(ad, GL_STR_REMOVE, cnt, + GL_MEDIA_OP_REMOVE_TAG); + return 0; +} + +static void _gl_db_update_noti_cb(keynode_t *key, void *data) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbgW("VCONFKEY_FILEMANAGER_DB_STATUS changed!"); + int mmc_state = -1; + + vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_state); + + if (mmc_state == -1) { + gl_dbgE("Error when check MMC Status"); + return; + } + + if (mmc_state == VCONFKEY_SYSMAN_MMC_MOUNTED) { + gl_dbg("mmc_state[%d] : VCONFKEY_SYSMAN_MMC_MOUNTED", mmc_state); + if (ad->maininfo.mmc_state == GL_MMC_STATE_REMOVED) + ad->maininfo.mmc_state = GL_MMC_STATE_ADDING_MOVING; + else + ad->maininfo.mmc_state = GL_MMC_STATE_ADDED; + + gl_update_view(ad, GL_UPDATE_VIEW_MMC_ADDED); + /* Remove ctxpopup */ + _gl_ctxpopup_del(ad); + } else if (mmc_state == VCONFKEY_SYSMAN_MMC_REMOVED || + mmc_state == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) { + gl_dbg("mmc_state[%d] : VCONFKEY_SYSMAN_MMC_REMOVED", mmc_state); + if (ad->maininfo.mmc_state == GL_MMC_STATE_ADDED_MOVING) { + /* + * Set pb_cancel status, + * indicates MMC removed while moving or deleting. + */ + gl_thread_set_cancel_state(ad, GL_PB_CANCEL_MMC); + /* MMC moved while moving or deleting */ + ad->maininfo.mmc_state = GL_MMC_STATE_REMOVED_MOVING; + } else if (ad->maininfo.mmc_state == GL_MMC_STATE_REMOVED_MOVING) { + gl_dbgW("View updated on GL_MMC_STATE_ADDED_MOVING"); + return; + } else { + /* MMC is extracted */ + ad->maininfo.mmc_state = GL_MMC_STATE_REMOVED; + } + + gl_update_view(ad, GL_UPDATE_VIEW_MMC_REMOVED); + /* Remove ctxpopup */ + _gl_ctxpopup_del(ad); + } +} + +/** +* @param: b_update_albums_list +* True: Update albums list and medias list, then update normal view. +* False: Get new medias for current view from DB +* then update view to synchronize data with Myfile. +* Use case: +* Update edit gridview/listview. +*/ +static int _gl_update_thumb_items(void *data, bool b_update_albums_list) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + bool b_edit_m = false; + + gl_dbg("view_mode: %d, b_update_albums_list: %d.", view_mode, + b_update_albums_list); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + gl_dbg("Edit view."); + b_edit_m = true; + } + + /** + * 1, Update albums list and medias_elist, + * 2, Update medias_elist. + */ + if (b_update_albums_list) + gl_refresh_albums_list(ad); + else + _gl_data_update_item_list(ad); + + if (ad->maininfo.medias_cnt == 0) { + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + gl_dbgW("It's s empty tag!"); + /* Remove invalid widgets */ + gl_del_invalid_widgets(ad, GL_INVALID_NEW_ENTRY_NOC); + /* Show nocontents */ + _gl_nocontents_show(ad); + return 0; + } + /* All items deleted, change to albms view */ + gl_pop_to_ctrlbar_ly(ad, !b_update_albums_list); + } else { + if (_gl_nocontents_show(ad)) { + gl_dbg("none video/image, show nocontents"); + /* Remove invalid widgets */ + gl_del_invalid_widgets(ad, GL_INVALID_NEW_ENTRY_NOC); + } else if (view_mode == GL_VIEW_THUMBS) { + _gl_thumbs_update_view(ad); + } else if (view_mode == GL_VIEW_THUMBS_EDIT) { + _gl_thumbs_show_edit_view(ad); + } + + /* Normal view, return */ + if (!b_edit_m) + return 0; + + /* Get selected medias count */ + int sel_cnt = _gl_data_selected_list_count(ad); + /* Remove invalid widgets */ + if (sel_cnt == 0) + gl_del_invalid_widgets(ad, GL_INVALID_NEW_ENTRY); + + /* Display selectioninfo */ + _gl_notify_create_selinfo(ad, ad->gridinfo.navi_content_edit_ly, + ad->gridinfo.nf_it_edit, + ad->maininfo.medias_cnt, sel_cnt, + true); + + /** + * Update albums list when change to normal view. + * Maybe some empty albums exist. + */ + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_ALBUMS && + !b_update_albums_list) { + gl_dbg("Update albums list when cancelled."); + ad->albuminfo.update_albums_list = true; + } + } + + return 0; +} + +/* Update in select thunb view for Tags */ +static int _gl_update_select_thumb_items(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + + gl_dbg("view_mode: %d", view_mode); + if (view_mode != GL_VIEW_THUMBS_SELECT) { + gl_dbg("Not in Select view."); + return -1; + } + +#ifdef _USE_ROTATE_BG + __gl_refresh_albums_list(data, false, true); +#else + /* Checkme: albums list is not updated */ + _gl_data_update_item_list_without_tag(ad, ad->albuminfo.current_album, + _gl_tags_get_current_tag_name(ad)); +#endif + + if (ad->maininfo.medias_cnt == 0) { + if (ad->gridinfo.select_view) { + _gl_thumbs_clear_cbs(ad->gridinfo.select_view); + ad->gridinfo.select_view = NULL; + } + ad->gridinfo.select_view_ly = NULL; + int err = -1; + int item_cnt = 0; + err = _gl_data_get_item_cnt(ad, GL_ALBUM_ALL_ID, false, + GL_STORE_T_ALL, &item_cnt); + /* Destroy select albums view */ + if (err != 0 || item_cnt == 0) { + gl_dbg("None local albums."); + _gl_albums_sel_pop_view(ad); + } else { + gl_dbg("Empty album."); + _gl_thumbs_sel_pop_view(ad); + } + return 0; + } else { + _gl_thumbs_show_edit_view(ad); + + /* Get selected medias count */ + int sel_cnt = _gl_data_selected_list_count(ad); + /* Remove invalid widgets */ + if (sel_cnt == 0) + gl_del_invalid_widgets(ad, GL_INVALID_NEW_ENTRY); + + /* Display selectioninfo */ + _gl_notify_create_selinfo(ad, ad->gridinfo.select_view_ly, + ad->gridinfo.nf_it_select, + ad->maininfo.medias_cnt, sel_cnt, + true); + } + + return 0; +} + +/* Check if there is any MMC file contained in select_medias_elist */ +static bool _gl_check_mmc_file_selected(void *data) +{ + gl_dbg(""); + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + gl_item *gitem = NULL; + int i = 0; + int on_mmc = -1; + int cnt = _gl_data_selected_list_count(ad); + for (i = 0; i < cnt; i++) { + gitem = NULL; + on_mmc = -1; + + gitem = _gl_data_selected_list_get_nth(ad, i); + /* File on MMC is selected */ + if (gitem && gitem->item && gitem->item->file_url) { + on_mmc = strncmp(GL_ROOT_PATH_MMC, + gitem->item->file_url, + strlen(GL_ROOT_PATH_MMC)); + if (on_mmc == 0) + return true;; + } + } + return false; +} + +/* Stop vibrate device */ +static int _gl_stop_vibration(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->entryinfo.device_handle, -1); + GL_CHECK_VAL(ad->entryinfo.effect_handle, -1); + int ret = -1; + + if (ad->entryinfo.haptic_handle >= 0) { + ret = haptic_stop_effect(*(ad->entryinfo.device_handle), + *(ad->entryinfo.effect_handle)); + if (ret != 0) + gl_dbgE("haptic_stop_effect failed[%d]!", ret); + + ad->entryinfo.haptic_handle = -1; + } + GL_FREEIF(ad->entryinfo.device_handle); + GL_FREEIF(ad->entryinfo.effect_handle); + + return 0; +} + +static Eina_Bool _gl_vibration_timer_cb(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + _gl_stop_vibration(data); + + if (ad->entryinfo.vibration_timer) { + ecore_timer_del(ad->entryinfo.vibration_timer); + ad->entryinfo.vibration_timer = NULL; + } + return ECORE_CALLBACK_CANCEL; +} + +/* Move thumbnail and file */ +static Eina_Bool __gl_file_mv(gl_item *gitem, const char *src, const char *dst) +{ + GL_CHECK_FALSE(src); + GL_CHECK_FALSE(dst); + GL_CHECK_FALSE(gitem); + /* Move thumb first */ + if (_gl_local_data_move_media(gitem->item, dst) < 0) { + gl_dbgE("Move media thumbnail failed!"); + return EINA_FALSE; + } + return _gl_fs_move(src, dst); +} + +#ifdef _USE_ROTATE_BG +/* b_path == true, Use saved folder path to check cluster uuid + * b_select == true, Update albums in select view for tag adding + */ +static int __gl_refresh_albums_list(void *data, bool b_path, bool b_select) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_cluster *current_album = ad->albuminfo.current_album; + char *uuid = NULL; + gl_cluster *current = NULL; + bool b_get_cur_album = false; + /* Albums list would be update, reset flag */ + ad->albuminfo.update_albums_list = false; + + uuid = calloc(1, GL_MTYPE_ITEN_ID_LEN_MAX); + GL_CHECK_VAL(uuid, -1); + + /* Save cluster ID to set new current_album from new albums list */ + if (current_album && current_album->cluster && + current_album->cluster->uuid) { + g_strlcpy(uuid, current_album->cluster->uuid, + GL_MTYPE_ITEN_ID_LEN_MAX); + b_get_cur_album = true; + } else { + gl_dbg("None album selected, current album is unavailable."); + } + + _gl_data_get_cluster_list(ad); + /* need to reset current album */ + ad->albuminfo.current_album = NULL; + + if (b_get_cur_album) { + if (b_path) { + gl_dbg("Path: %s", ad->albuminfo.dest_folder); + if (strlen(ad->albuminfo.dest_folder) > 0 && + GL_FILE_EXISTS(ad->albuminfo.dest_folder)) { + gl_dbgW("Cluster record updated!"); + _gl_data_get_cluster_by_path(ad, + ad->albuminfo.dest_folder, + ¤t); + } else { + gl_dbgE("Invalid folder path!"); + _gl_data_get_cluster_by_id(ad, uuid, ¤t); + } + } else { + _gl_data_get_cluster_by_id(ad, uuid, ¤t); + } + + if(current && current->cluster) { + ad->albuminfo.current_album = current; + gl_dbg("Reset current album: %s", + current->cluster->display_name); + if (b_select) + _gl_data_update_item_list_without_tag(ad, + current, + _gl_tags_get_current_tag_name(ad)); + else + _gl_data_update_item_list(ad); + } else { + /* Clear items list if current album doesn't exist */ + if (ad->selectedinfo.medias_elist) + _gl_data_selected_list_finalize(ad); + _gl_data_clear_default_item_list(ad); + ad->maininfo.medias_cnt = 0; + } + } + + GL_FREEIF(uuid); + return 0; +} + +#endif + +int gl_get_entry_text(Evas_Object * entry, char *entry_text, int len_max) +{ + gl_dbg(""); + GL_CHECK_VAL(entry_text, -1); + GL_CHECK_VAL(entry, -1); + + memset(entry_text, 0x00, len_max); + + char *entry_str = (char *)elm_entry_entry_get(entry); + if (entry_str) + { + if (strlen(entry_str) == 0) + { + gl_dbg("Entry string is empty!"); + } + else + { + char *entry_utf8 = elm_entry_markup_to_utf8(entry_str); // changes user input to utf-8 encoding format + if (entry_utf8 == NULL) + { + gl_dbgE("Make entry string to UTF8 failed!"); + return -1; + } + else if (strlen(entry_utf8) == 0) + { + gl_dbg("Entry text is empty!"); + } + else + { + g_strlcpy(entry_text, entry_utf8, len_max); + entry_text[len_max - 1] = '\0'; + } + + GL_FREE(entry_utf8); + } + } + else + { + gl_dbgE("Get entry string failed!"); + return -1; + } + + return 0; +} + +/** +* Change utf8 string to markup, then set it as entry text. +* To fix special character "&" issue, to convert "&" to "&". f.e. +* Myfiles->rename folder to AB&C->Gallery/Rename ->displayed as "AB" +*/ +int gl_set_entry_text(Evas_Object *entry, char *entry_text) +{ + GL_CHECK_VAL(entry, -1); + char *entry_makeup = NULL; + gl_dbg("Entry UTF8 text: %s.", entry_text); + + if (entry_text) { + entry_makeup = elm_entry_utf8_to_markup(entry_text); + if (entry_makeup == NULL) { + gl_dbgE("Make utf8 string to makeup failed!"); + return -1; + } + gl_dbg("Entry makeup text: %s.", entry_makeup); + } + /* Empty string set if entry_makeup is NULL */ + elm_entry_entry_set(entry, entry_makeup); + + GL_FREEIF(entry_makeup); + return 0; +} + +/** +* Check album name is valid and remove unuseful characters +* 1) not only includes space; +* 2) contains invalid character; +* 3) it's empty. +* +* @param b_new +* true: add a new album ; false: rename a album. +* @param b_enter +* true: Enter key pressed ; false: Button Done clicked. +* +*/ +int _gl_get_valid_album_name(void *data, char* album_name, bool b_new, + bool b_enter) +{ + GL_CHECK_VAL(album_name, -1); + GL_CHECK_VAL(data, -1); + gl_appdata* ad = (gl_appdata*)data; + int mode = 0; + gl_dbg("Input album name: %s", album_name); + char *popup_desc; + popup_desc = (char*)calloc(GL_POPUP_STRING_MAX, sizeof(char)); + if (popup_desc == NULL) { + gl_dbg("memory allocation fail"); + return -1; + } + /* Check album name length */ + if (strlen(album_name) == 0) { + gl_dbgW("Inserted text is empty!"); + if (b_enter) { + gl_dbg("Enter key pressed."); + goto INVALID_ALBUM_NAME; + } + + if (b_new) + mode = GL_POPUP_ALBUM_NEW_EMPTY; + else + mode = GL_POPUP_ALBUM_RENAME_EMPTY; + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.
%s", + GL_STR_ENTRY_IS_EMPTY, GL_STR_RETRY_Q); + popup_desc[strlen(popup_desc)] = '\0'; + gl_popup_create_popup(ad, mode, popup_desc); + goto INVALID_ALBUM_NAME; + } + gl_dbg("Inserted album name: %s, length: %d", album_name, strlen(album_name)); + + /* Removes leading and trailing whitespace */ + g_strstrip((gchar*)album_name); + if (strlen(album_name) == 0) { + gl_dbgW("Album name includes only space!"); + if (b_enter) { + gl_dbg("Enter key pressed."); + goto INVALID_ALBUM_NAME; + } + + if (b_new) + mode = GL_POPUP_ALBUM_NEW_EMPTY; + else + mode = GL_POPUP_ALBUM_RENAME_EMPTY; + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.
%s", + GL_STR_INVALID_INPUT_PARAMETER, GL_STR_RETRY_Q); + popup_desc[strlen(popup_desc)] = '\0'; + gl_popup_create_popup(ad, mode, popup_desc); + goto INVALID_ALBUM_NAME; + } + + /* Check if there is any invalid character in string */ + if (_gl_fs_validate_name(album_name) == false) { + gl_dbgW("Album name includes invalid character!"); + if (b_new) + mode = GL_POPUP_ALBUM_NEW_INVALID; + else + mode = GL_POPUP_ALBUM_RENAME_INVALID; + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.
%s", + GL_STR_INVALID_INPUT_PARAMETER, GL_STR_RETRY_Q); + popup_desc[strlen(popup_desc)] = '\0'; + gl_popup_create_popup(ad, mode, popup_desc); + goto INVALID_ALBUM_NAME; + } + + GL_FREE(popup_desc); + + return 0; + + INVALID_ALBUM_NAME: + GL_FREE(popup_desc); + return -1; +} + +/* * +* In case of system folder, the displayed name should be translated into system language +* +* @param album +* check album display name for getting proper translation +* +* @return +* the translated album display name +*/ +char *_gl_get_i18n_album_name(gl_cluster *album) +{ + GL_CHECK_NULL(album); + GL_CHECK_NULL(album->cluster); + + if(_gl_data_is_default_album(GL_ALBUM_DEFAULT_NAME, album->cluster)) { + /* system folder name: Camera */ + return GL_STR_CAMERA; + } else if(_gl_data_is_default_album(GL_ALBUM_DOWNLOAD_NAME, album->cluster)) { + /* system folder name: Downloads */ + return GL_STR_DOWNLOADS; + } else if(!g_strcmp0(album->cluster->uuid, GL_ALBUM_ALL_ID)) { + GL_FREEIF(album->cluster->display_name); + album->cluster->display_name = strdup(GL_ALBUM_ALL_NAME); + return album->cluster->display_name; + } else { + /* if the folder is not a system folder, return itself */ + return album->cluster->display_name; + } +} + +/** +* Check tag name is valid and remove unuseful characters +* 1) not only includes space; +* 2) it's empty. +* +* @param b_new +* true: add a new tag ; false: rename a tag. +* +* @param b_enter +* true: Enter key pressed ; false: Button Done clicked. +*/ +int _gl_get_valid_tag_name(void *data, char* tag_name, bool b_new, bool b_enter) +{ + GL_CHECK_VAL(tag_name, -1); + GL_CHECK_VAL(data, -1); + gl_appdata* ad = (gl_appdata*)data; + int mode = 0; + gl_dbg("Input tag name: %s", tag_name); + char *popup_desc; + popup_desc = (char*)calloc(GL_POPUP_STRING_MAX, sizeof(char)); + if (popup_desc == NULL) { + gl_dbg("memory allocation fail"); + return -1; + } + + /* Check tag name length */ + if (strlen(tag_name) == 0) { + gl_dbgW("Inserted text is empty!"); + if (b_enter) { + gl_dbg("Enter key pressed."); + goto INVALID_TAG_NAME; + } + + if (b_new) { + mode = GL_POPUP_TAG_NEW_EMPTY; + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.
%s", + GL_STR_ENTRY_IS_EMPTY, GL_STR_RETRY_Q); + } else { + mode = GL_POPUP_TAG_RENAEM_EMPTY; + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s", + GL_STR_ENTRY_IS_EMPTY); + } + + popup_desc[strlen(popup_desc)] = '\0'; + gl_popup_create_popup(ad, mode, popup_desc); + goto INVALID_TAG_NAME; + } + gl_dbg("Inserted tag name: %s, length: %d", tag_name, strlen(tag_name)); + + /* Removes leading and trailing whitespace */ + g_strstrip((gchar*)tag_name); + if (strlen(tag_name) == 0) { + gl_dbgW("Tag name includes only space!"); + if (b_enter) { + gl_dbg("Enter key pressed."); + goto INVALID_TAG_NAME; + } + + if (b_new) { + mode = GL_POPUP_TAG_NEW_EMPTY; + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.
%s", + GL_STR_ENTRY_IS_EMPTY, GL_STR_RETRY_Q); + } else { + mode = GL_POPUP_TAG_RENAEM_EMPTY; + snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s", + GL_STR_ENTRY_IS_EMPTY); + + } + + popup_desc[strlen(popup_desc)] = '\0'; + gl_popup_create_popup(ad, mode, popup_desc); + goto INVALID_TAG_NAME; + } + + GL_FREE(popup_desc); + return 0; + + INVALID_TAG_NAME: + GL_FREE(popup_desc); + return -1; +} + +int gl_get_selected_files_path_str(void *data, gchar sep_c, char **path_str, + int *sel_cnt) +{ + GL_CHECK_VAL(path_str, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->selectedinfo.medias_elist, -1); + GString *selected_path_list = g_string_new(NULL); + gl_item *current = NULL; + int selected_item_cnt = 0; + Eina_List *l = NULL; + + EINA_LIST_FOREACH(ad->selectedinfo.medias_elist, l, current) { + if (current == NULL || current->item == NULL) { + if (selected_path_list) { + g_string_free(selected_path_list, true); + selected_path_list = NULL; + } + return -1; + } + + if (strstr(selected_path_list->str, current->item->file_url)) { + gl_dbgW("Already appended!"); + } else { + selected_item_cnt++; + g_string_append(selected_path_list, + current->item->file_url); + g_string_append_c(selected_path_list, sep_c); + } + + } + gl_dbg("Selected items count: %d.", selected_item_cnt); + if (sel_cnt) + *sel_cnt = selected_item_cnt; + int len = strlen(selected_path_list->str); + g_string_truncate(selected_path_list, len - 1); + /** + * Frees the memory allocated for the GString. + * If free_segment is true it also frees the character data. + * If it's false, the caller gains ownership of the buffer + * and must free it after use with g_free(). + */ + *path_str = g_string_free(selected_path_list, false); + GL_CHECK_VAL(*path_str, -1); + gl_dbg("Total string:\n\n\t>>@@:> %s <:@@<<\n", *path_str); + return 0; +} + +int gl_make_new_album(const char *name) +{ + gl_dbg(""); + char path[GL_DIR_PATH_LEN_MAX] = { 0, }; + char dir_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + + if (_gl_fs_get_default_folder(dir_path) != 0) { + gl_dbg("FAIL to get dir path"); + return -1; + } + + snprintf(path, GL_DIR_PATH_LEN_MAX, "%s/%s", dir_path, name); + path[strlen(path)] = '\0'; + gl_dbg("Making %s directory", path); + + _gl_fs_mkdir(dir_path); + _gl_fs_mkdir(path); + return 0; +} + +/* Used for loal medias, thumbnail was moved to new dest first, then rename file */ +int _gl_move_media_thumb(gl_item * gitem, char *new_dir_name, + bool is_full_path, int *popup_op) +{ + gl_dbg("Move media item START>>>"); + char new_path[GL_FILE_PATH_LEN_MAX] = { 0, }; + char ext[GL_FILE_EXT_LEN_MAX] = { 0, }; + char new_path_noext[GL_FILE_PATH_LEN_MAX] = { 0, }; + char dir_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + if (gitem == NULL || gitem->item == NULL || gitem->item->uuid == NULL || + popup_op == NULL) + { + gl_dbg("gitem == NULL || gitem->item == NULL"); + return -1; + } + + *popup_op = GL_POPUP_OP_NONE; + + if (is_full_path) + { + if (!gitem->item->file_url || + !strlen(gitem->item->file_url) || + !gitem->item->display_name) + { + gl_dbg("file url or name is error."); + return -1; + } + snprintf(new_path, sizeof(new_path), "%s/%s", + new_dir_name, (char *)(gitem->item->display_name)); + gl_dbg("New path : %s", new_path); + + if (!g_strcmp0(new_path, gitem->item->file_url)) //do not need to move. ("All" album case) + { + //create popup in pipe callback + *popup_op = GL_POPUP_OP_SAME_ALBUM; + gl_dbg("File already in destination, do not need to move, just return..."); + /* + snprintf(msg, sizeof(msg), "Cann't move %s to the same album!", gitem->item->display_name); + gl_popup_create_popup(ad, GL_POPUP_NOBUT_MOV_DEL, msg); + */ + + return 0; + } + else if (ecore_file_exists(new_path)) // return true if file exists, rename new file. + { + _gl_fs_get_ext(new_path, ext, new_path_noext); + char *final_path = NULL; + final_path = _gl_fs_get_unique_full_path(new_path_noext, ext); + if (final_path == NULL) + return -1; + gl_dbg("Created unique path: %s", final_path); + memset(new_path, 0x00, GL_FILE_PATH_LEN_MAX); + g_strlcpy(new_path, final_path, GL_FILE_PATH_LEN_MAX); + GL_FREE(final_path); + //create popup in pipe callback + *popup_op = GL_POPUP_OP_DUPLICATED_NAME; + /*memset(msg, 0x00, GL_FILE_PATH_LEN_MAX); + snprintf(msg, sizeof(msg), "%s is duplicated, rename it!", gitem->item->display_name); + gl_popup_create_popup(ad, GL_POPUP_NOBUT_MOV_DEL, msg); + */ + } + } + else + { + if (_gl_fs_get_default_folder(dir_path) != 0) + { + gl_dbg("FAIL to get dir path!"); + return -1; + } + snprintf(new_path, GL_FILE_PATH_LEN_MAX, "%s/%s/%s", + dir_path, new_dir_name, (char *)(gitem->item->display_name)); + } + + new_path[strlen(new_path)] = '\0'; + + // stop using "rename" when moving from mmc to phone for correct db update. + if (!__gl_file_mv(gitem, gitem->item->file_url, new_path)) + { + gl_dbg("Move media item OVER<<<"); + return -1; + } + else + { + gl_dbg("Move media item OVER<<<"); + return 0; + } +} + +/* Used for move file to new dest */ +int _gl_move_media(gl_item *gitem, char *new_dir_name, bool is_full_path) +{ + gl_dbg("Move media START>>>"); + char new_path[GL_FILE_PATH_LEN_MAX] = { 0, }; + char ext[GL_FILE_EXT_LEN_MAX] = { 0, }; + char new_path_noext[GL_FILE_PATH_LEN_MAX] = { 0, }; + char dir_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + if (!gitem || !gitem->item) { + gl_dbgE("Invalid gitem!"); + return -1; + } + + if (is_full_path) { + if (!gitem->item->file_url || !strlen(gitem->item->file_url) || + !gitem->item->display_name) { + gl_dbgE("file url or name is invalid!"); + return -1; + } + snprintf(new_path, sizeof(new_path), "%s/%s", + new_dir_name, (char *)(gitem->item->display_name)); + gl_dbg("New path : %s", new_path); + + if (!g_strcmp0(new_path, gitem->item->file_url)) { + gl_dbgW("File exists!"); + return 0; + } else if (ecore_file_exists(new_path)) { + _gl_fs_get_ext(new_path, ext, new_path_noext); + char *final_path = NULL; + final_path = _gl_fs_get_unique_full_path(new_path_noext, ext); + if (final_path == NULL) + return -1; + gl_dbg("Created unique path: %s", final_path); + memset(new_path, 0x00, GL_FILE_PATH_LEN_MAX); + g_strlcpy(new_path, final_path, GL_FILE_PATH_LEN_MAX); + GL_FREE(final_path); + } + } else { + if (_gl_fs_get_default_folder(dir_path) != 0) { + gl_dbgE("FAIL to get dir path!"); + return -1; + } + snprintf(new_path, GL_FILE_PATH_LEN_MAX, "%s/%s/%s", dir_path, + new_dir_name, (char *)(gitem->item->display_name)); + } + + new_path[strlen(new_path)] = '\0'; + + if (!_gl_fs_move(gitem->item->file_url, new_path)) { + gl_dbg("Move media OVER<<<"); + return -1; + } else { + gl_dbg("Move media OVER<<<"); + return 0; + } +} + +/** +* Check if there is any media in Gallery. +* +* False returned if none medias exist, other return True. +*/ +bool gl_check_gallery_empty(void* data) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->albuminfo.cluster_list == NULL) { + gl_dbgE("ad->albuminfo.cluster_list is empty!"); + return true; + } + + Eina_List *clist = ad->albuminfo.cluster_list->clist; + if (clist == NULL) { + gl_dbgW("Albums list is invalid!"); + return true; + } + + int len = eina_list_count(clist); + if (len == 0) { + gl_dbgW("Albums list is empty!"); + return true; + } + return false; +} + +bool gl_is_image_valid(void *data, char *filepath) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_FALSE(filepath); + + Evas_Object *image = NULL; + int width = 0; + int height = 0; + Evas *evas = NULL; + + evas = evas_object_evas_get(ad->maininfo.win); + GL_CHECK_FALSE(evas); + + image = evas_object_image_add(evas); + GL_CHECK_FALSE(image); + + evas_object_image_filled_set(image, 0); + evas_object_image_load_scale_down_set(image, 0); + evas_object_image_file_set(image, filepath, NULL); + evas_object_image_size_get(image, &width, &height); + if(image) { + evas_object_del(image); + image = NULL; + } + + if (width <= 0 || height <= 0) { + gl_dbg("Cannot load file : %s", filepath); + return false; + } + + return true; +} + +bool gl_is_rotation_locked(void) +{ + gl_dbg_launch(" gl_is_rotation_locked:start"); + int lock = -1; + + if (!vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &lock)) + { + gl_dbg("Rotation locked state[%d].", lock); + gl_dbg_launch(" gl_is_rotation_locked:end"); + return lock; + } + else + { + gl_dbgE("Get rotation lock state failed!"); + gl_dbg_launch(" gl_is_rotation_locked:end"); + return false; + } +} + +/* +* Check MMC state(Inserted/Removed) for Move/Delete/Add tag/Remove. +*/ +int gl_check_mmc_state(void *data, char *dest_folder) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* MMC hasn't been inserted */ + if (ad->maininfo.mmc_state == GL_MMC_STATE_REMOVED) + return 0; + + int on_mmc = -1; + /** + * 1, Places: Add tag; + * 2, Tags: Add tag/remove tag; + * 3, Albums: Move/Delete/Add tag. + */ + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + if (_gl_check_mmc_file_selected(ad)) + goto ON_MMC; + } else { + /* Move files to MMC album */ + if (dest_folder) { + on_mmc = strncmp(GL_ROOT_PATH_MMC, dest_folder, + strlen(GL_ROOT_PATH_MMC)); + if (on_mmc == 0) + goto ON_MMC; + } + + gl_cluster *cur_album = ad->albuminfo.current_album; + char src_folder_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + GL_CHECK_VAL(cur_album, -1); + GL_CHECK_VAL(cur_album->cluster, -1); + /* Move files from MMC album */ + GL_CHECK_VAL(cur_album->cluster->uuid, -1); + g_strlcpy(src_folder_path, cur_album->cluster->path, + GL_DIR_PATH_LEN_MAX); + on_mmc = strncmp(GL_ROOT_PATH_MMC, src_folder_path, + strlen(GL_ROOT_PATH_MMC)); + /* Check MMC files selected in album [All albums] */ + if (on_mmc == 0) { + goto ON_MMC; + } else if (cur_album->cluster->type == GL_STORE_T_ALL) { + gl_dbg("In album [All albums]."); + if (_gl_check_mmc_file_selected(ad)) + goto ON_MMC; + } + } + return 0; + + ON_MMC: + gl_dbgW("Operate medias on MMC!"); + ad->maininfo.mmc_state = GL_MMC_STATE_ADDED_MOVING; + return 0; +} + +int gl_reg_db_update_noti(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int error_code = -1; + int mmc_state = -1; + + vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_state); + /* Save the init status of MMC */ + if (mmc_state == VCONFKEY_SYSMAN_MMC_MOUNTED) + { + gl_dbg("###### :::::: MMC loaded! :::::: ######"); + ad->maininfo.mmc_state = GL_MMC_STATE_ADDED; + } + else if (mmc_state == VCONFKEY_SYSMAN_MMC_REMOVED || + mmc_state == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) + { + gl_dbg("###### :::::: MMC removed! :::::: ######"); + ad->maininfo.mmc_state = GL_MMC_STATE_REMOVED; + } + + gl_dbg("Enable the noti handle for DB update status!"); + /* Set DB update status callback */ + error_code = vconf_notify_key_changed(VCONFKEY_FILEMANAGER_DB_STATUS, + _gl_db_update_noti_cb, ad); + if (error_code == -1) { + gl_dbgE("vconf_notify_key_changed for DB_STATUS failed!"); + return -1; + } + + return 0; +} + +int gl_dereg_db_update_noti(void) +{ + int error_code = -1; + + gl_dbg("Disable the noti handle for DB update status!"); + error_code = vconf_ignore_key_changed(VCONFKEY_FILEMANAGER_DB_STATUS, + _gl_db_update_noti_cb); + if (error_code == -1) { + gl_dbgE("vconf_ignore_key_changed for DB_STATUS failed!"); + return -1; + } + + return 0; +} + +/* +* Get view mode of app +*/ +int gl_get_view_mode(void *data) +{ + GL_CHECK_VAL(data, GL_VIEW_NONE); + gl_appdata *ad = (gl_appdata *)data; + return ad->maininfo.view_mode; +} + +/* +* Set view mode of app +*/ +int gl_set_view_mode(void *data, int mode) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + ad->maininfo.view_mode = mode; + return 0; +} + +int gl_del_invalid_widgets(void *data, int invalid_m) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + if (ad->popupinfo.popup) { + /* Remove popup */ + evas_object_del(ad->popupinfo.popup); + ad->popupinfo.popup = NULL; + } else if (ad->uginfo.ug_called_by_me) { + /* Destroy UG */ + gl_dbg("Destroy UG!"); + if (ad->uginfo.ug_called_by_me) { + ug_destroy(ad->uginfo.ug_called_by_me); + ad->uginfo.ug_called_by_me = NULL; + ad->uginfo.ug_type = -1; + } + if (ad->uginfo.gallery_ug_called_by_me) { + ug_destroy(ad->uginfo.gallery_ug_called_by_me); + ad->uginfo.gallery_ug_called_by_me = NULL; + } + } + + switch (invalid_m) { + case GL_INVALID_NEW_ENTRY: + case GL_INVALID_NEW_ENTRY_NOC: + if (ad->entryinfo.entry_mode == GL_ENTRY_NEW_ALBUM || + ad->entryinfo.entry_mode == GL_ENTRY_NEW_TAG) { + gl_dbg("Destroy New album/tag view!"); + if (invalid_m == GL_INVALID_NEW_ENTRY) { + gl_dbg("Pop to nf_it_edit"); + elm_naviframe_item_pop_to(ad->gridinfo.nf_it_edit); + } + _gl_editfield_destroy_imf(ad); + Evas_Object *edit_ly = NULL; + edit_ly = ad->gridinfo.navi_content_edit_ly; + edje_object_signal_emit(_EDJ(edit_ly), + GL_SIGNAL_VIEW_EDIT, "elm"); + } + break; + case GL_INVALID_NEW_TAG_VIDEO: + if (ad->entryinfo.entry_mode == GL_ENTRY_NEW_TAG) { + gl_dbg("Destroy New tag view!"); + elm_naviframe_item_pop_to(ad->gridinfo.nf_it); + _gl_editfield_destroy_imf(ad); + } + break; + default: + ad->entryinfo.entry_mode = GL_ENTRY_NONE; + break; + } + return 0; +} + +int gl_del_medias(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + /* Get all selected medias count */ + int cnt = _gl_data_selected_list_count(ad); + /* Check MMC state for cancel operation */ + gl_check_mmc_state(ad, NULL); + gl_dbg("MMC state: %d.", ad->maininfo.mmc_state); + _gl_use_thread_operate_medias(ad, GL_STR_DELETING, cnt, + GL_MEDIA_OP_DELETE); + + return 0; +} + +/* 'Delete medias' is available in Albums view */ +int gl_del_selected(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + /* Get all selected medias count */ + int cnt = _gl_data_selected_list_count(ad); + gl_item *gitem = NULL; + int i = 0; + int popup_op = GL_POPUP_OP_NONE; + + /* Removed media from selected_media_elist */ + for (i = 1; i <= cnt; i++) { + _gl_data_get_item_by_index(ad, i, true, &gitem); + if (gitem != NULL && gitem->item != NULL) + _gl_data_remove_item(gitem); + else + gl_dbgE("Invalid item!"); + + gl_dbg("Write pipe, make progressbar updated!"); + gl_thread_write_pipe(ad, i, popup_op); + gitem = NULL; + } + + return 0; +} + +int _gl_update_operation_view(void *data, const char *noti_str) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("String: %s", noti_str); + + if (ad->maininfo.medias_cnt > 0) { + /* Deleting process done, change to normal view */ + _gl_ui_pop_to_thumb(ad); + + if (gl_get_view_mode(ad) == GL_VIEW_THUMBS) + _gl_nocontents_show(ad); + + /* Add notification */ + _gl_notify_create_notiinfo(ad, noti_str); + } else { + gl_dbgW("Empty album, change to Albums view!"); + gl_albums_comeback_from_view(ad); + elm_naviframe_item_pop_to(ad->ctrlinfo.nf_it); + + if (gl_check_gallery_empty(ad)) { + _gl_ctrl_disable_btn(ad, true, GL_NAVI_ALBUMS); + gl_ctrl_disable_ctrlbar(ad, true); + } else if (ad->albuminfo.cluster_list->edit_cnt == 0) { + _gl_ctrl_disable_btn(ad, true, GL_NAVI_ALBUMS); + } + + _gl_notify_destroy_selinfo(ad); + /* Add notification */ + _gl_notify_create_notiinfo(ad, noti_str); + } + return 0; +} + +/* Update view after deleting process done */ +int gl_update_del_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + _gl_data_selected_list_finalize(ad); + + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d.", view_mode); + gl_refresh_albums_list(ad); + + _gl_update_operation_view(ad, GL_STR_DELETED); + + return 0; +} + +int gl_remove_album(void *data, gl_cluster * album_item) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int res = -1; + char dir_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + + if (album_item == NULL || album_item->cluster == NULL || + album_item->cluster->uuid == NULL) { + gl_dbgE("Invalid album!"); + return -1; + } + + gl_dbg("Remove album: %s, id=%s", album_item->cluster->display_name, + album_item->cluster->uuid); + + /* get folder path of album */ + if (album_item->cluster->path && + strlen(album_item->cluster->path) > 0) { + gl_dbg("Folder fullpath: %s", dir_path); + g_strlcpy(dir_path, album_item->cluster->path, + GL_DIR_PATH_LEN_MAX); + } else { + gl_dbgE("Get folder fullpath failed[%d]!", res); + return -1; + } + /* remove all items in the album from file system and db */ + _gl_data_get_item_list(ad, GL_CATEGORY_FOLDER, album_item, + GL_GET_ALL_RECORDS, GL_GET_ALL_RECORDS); + + gl_item *gitem = NULL; + int i = 0; + /* Get all medias count of current album */ + int cnt = ad->maininfo.medias_cnt; + gl_dbg("cnt: %d", cnt); + /* Remove files, _gl_local_data_delete_album would delete medias record */ + for (i = cnt; i >= 1; i--) { + _gl_data_get_item_by_index(ad, i, false, &gitem); + if (gitem && gitem->item && gitem->item->file_url) { + if (!ecore_file_unlink(gitem->item->file_url)) + gl_dbgE("ecore_file_unlink failed!"); + } + } + + /* remove album from db*/ + res = _gl_local_data_delete_album(album_item->cluster->uuid); + if (res != 0) + gl_dbgE("_gl_local_data_delete_album failed[%d]!", res); + + /* remove album from file system */ + if (ecore_file_rmdir(dir_path) == EINA_FALSE) { + gl_dbg("ecore_file_rmdir failed!"); + return -1; + } + + return 0; +} + +int gl_del_albums(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_cluster *album_item = NULL; + int cnt = _gl_data_get_albums_selected_cnt(ad); + int i = 0; + int ret = -1; + gl_dbg(""); + // delete albums + + Eina_List *selected_list = ad->albuminfo.selected_albums_elist; + if ((selected_list == NULL) || (eina_list_count(selected_list) == 0)) + { + gl_dbg("zero length, return!"); + return -1; + } + else + { + gl_dbg("cnt= %d, list length=%d", cnt, eina_list_count(selected_list)); + } + for (i = 0; i < cnt; i++) + { + album_item = eina_list_nth(selected_list, i); + + if (album_item && album_item->cluster && + album_item->cluster->uuid) { + gl_dbg("Delete album: %s, id=%s", + album_item->cluster->display_name, + album_item->cluster->uuid); + ret = gl_remove_album(ad, album_item); + if (ret < 0) + { + gl_dbg("gl_remove_album failed, error=%d", ret); + //return -1; + } + } + } + + // update the albums view + _gl_albums_edit_pop_view(ad); + + //add notification + _gl_notify_create_notiinfo(ad, GL_STR_DELETED); + return 0; +} + +int gl_refresh_albums_list(void *data) +{ +#ifdef _USE_ROTATE_BG + return __gl_refresh_albums_list(data, false, false); +#else + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_cluster *old_current_album = ad->albuminfo.current_album; + char cluster_id[GL_MTYPE_ITEN_ID_LEN_MAX] = { 0, }; + gl_cluster *current = NULL; + bool b_get_cur_album = false; + /* Albums list would be update, reset flag */ + ad->albuminfo.update_albums_list = false; + + /* Save cluster ID to set new current_album from new albums list */ + if (old_current_album && old_current_album->cluster && + old_current_album->cluster->uuid) { + g_strlcpy(cluster_id, old_current_album->cluster->uuid, + GL_MTYPE_ITEN_ID_LEN_MAX); + b_get_cur_album = true; + } else { + gl_dbg("None album selected, current album is unavailable."); + } + + _gl_data_get_cluster_list(ad); + /* need to reset current album */ + ad->albuminfo.current_album = NULL; + + if (b_get_cur_album) { + _gl_data_get_cluster_by_id(ad, cluster_id, ¤t); + if(current && current->cluster) { + ad->albuminfo.current_album = current; + gl_dbg("Reset current album: %s", + current->cluster->display_name); + _gl_data_update_item_list(ad); + return 0; + } else { + /* Clear items list if current album doesn't exist */ + if (ad->selectedinfo.medias_elist) + _gl_data_selected_list_finalize(ad); + _gl_data_clear_default_item_list(ad); + ad->maininfo.medias_cnt = 0; + } + } + + return 0; +#endif +} + +/** +* Move files under root album [/opt/media or /opt/storage/sdcard] to a newly created album. +* Used in 'Rename' album case. +*/ +int +gl_move_root_album(void* data, gl_cluster* cur_album, char* dest_path) +{ + GL_CHECK_VAL(data, -1); + GL_CHECK_VAL(cur_album, -1); + GL_CHECK_VAL(cur_album->cluster, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Get all medias of current album */ + _gl_data_get_item_list(ad, GL_CATEGORY_FOLDER, cur_album, + GL_GET_ALL_RECORDS, GL_GET_ALL_RECORDS); + + Eina_List* tmp_elist = NULL; + gl_item* gitem = NULL; + int popup_op = GL_POPUP_OP_NONE; + GL_CHECK_VAL(ad->maininfo.medias_elist, -1); + + /* Move medias of album to dest folder */ + EINA_LIST_FOREACH(ad->maininfo.medias_elist, tmp_elist, gitem) + { + if (gitem && gitem->item) + { + gl_dbg("Move [%s]", gitem->item->file_url); + if (_gl_move_media_thumb(gitem, dest_path, true, &popup_op) != 0) + gl_dbgW("Failed to move this item"); + + gitem = NULL; + } + else + { + gl_dbgE("Invalid item!"); + _gl_data_clear_default_item_list(ad); + return -1; + } + } + + /* Free item list */ + _gl_data_clear_default_item_list(ad); + + return 0; +} + +/* 'Move medias' is only available in tab Albums */ +int gl_move_selected(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int i = 0; + /* Get selected medias count */ + int cnt = _gl_data_selected_list_count(ad); + gl_item *gitem = NULL; + int popup_op = GL_POPUP_OP_NONE; + + for (i = 1; i <= cnt; i++) + { + _gl_data_get_item_by_index(ad, i, true, &gitem); + if (gitem && gitem->item) + { + gl_dbg("Selected [%s]", gitem->item->file_url); + if (_gl_move_media_thumb(gitem, ad->albuminfo.dest_folder, true, &popup_op) != 0) + gl_dbg("Failed to move this item"); + + gl_dbg("File Moved:::::::%d/%d-->try to update progressbar", i, cnt); + } + else + { + gl_dbg("Invalid item!"); + } + + gl_dbg("Write pipe, make progressbar updated!"); + gl_thread_write_pipe(ad, i, popup_op); + + popup_op = GL_POPUP_OP_NONE; + } + + return 0; +} + +int gl_move_to_album(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + char folder_fullpath[GL_DIR_PATH_LEN_MAX] = { 0, }; + char default_path[GL_DIR_PATH_LEN_MAX] = { 0, }; + gl_cluster *cur_album = ad->albuminfo.current_album; + int cnt = _gl_data_selected_list_count(ad); + + /** + * 'move_album_id == NULL' is new album case, + * other move/save to some existed album. + */ + if (ad->albuminfo.path == NULL) { + gl_dbg("---Popup list item: New album---"); + ad->albuminfo.move_new_album = true; + + if (gl_make_new_album(ad->albuminfo.new_album_name) != 0) + { + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_SAME_NAME_ALREADY_IN_USE); + gl_dbgE("Failed to make a new directory!"); + gl_ui_update_select_widgets(ad); + return -1; + } + if (_gl_fs_get_default_folder(default_path) != 0) + { + gl_dbgE("Failed to get default images path!"); + gl_ui_update_select_widgets(ad); + return -1; + } + snprintf(folder_fullpath, GL_DIR_PATH_LEN_MAX, "%s/%s", + default_path, ad->albuminfo.new_album_name); + } else { + ad->albuminfo.move_new_album = false; + g_strlcpy(folder_fullpath, ad->albuminfo.path, + GL_DIR_PATH_LEN_MAX); + GL_FREE(ad->albuminfo.path); + } + + if (cur_album == NULL || cur_album->cluster == NULL) + { + gl_dbgE("[Error] Current album is NULL!"); + gl_ui_update_select_widgets(ad); + return -1; + } + + memset(ad->albuminfo.dest_folder, 0x00, GL_DIR_PATH_LEN_MAX); + g_strlcpy(ad->albuminfo.dest_folder, folder_fullpath, GL_DIR_PATH_LEN_MAX); + /* Check MMC state for cancel operation */ + gl_check_mmc_state(ad, folder_fullpath); + gl_dbg("MMC state: %d.", ad->maininfo.mmc_state); + _gl_use_thread_operate_medias(ad, GL_STR_MOVING, cnt, + GL_MEDIA_OP_MOVE); + return 0; +} + +/* Update view after moving process done */ +int gl_update_move_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d", view_mode); + _gl_data_selected_list_finalize(ad); + _gl_notify_destroy_selinfo(ad); + /* Update albums list and items list */ + gl_refresh_albums_list(ad); + + _gl_update_operation_view(ad, GL_STR_MOVED); + + return 0; +} + +int _gl_get_selected_paths(void *data, gchar sep_c, char **path_str, + int *sel_cnt) +{ + GL_CHECK_VAL(path_str, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_m = gl_get_view_mode(data); + gl_dbg("view_m: %d", view_m); + + if (view_m == GL_VIEW_ALBUMS_EDIT) { + gl_dbg("Albums"); + if (ad->albuminfo.selected_albums_elist == NULL) { + gl_dbgE("Invalid selected_albums_elist!"); + return -1; + } + /* Get file string */ + _gl_data_get_albums_selected_files_path_str(ad, sep_c, path_str, + sel_cnt); + } else if (view_m == GL_VIEW_TAGS_EDIT) { + gl_dbg("Tags"); + /* Get file string */ + _gl_data_get_tags_selected_files_path_str(ad, sep_c, path_str, + sel_cnt); + } else { + gl_dbg("Normal files"); + gl_get_selected_files_path_str(ad, sep_c, path_str, sel_cnt); + } + return 0; +} + +/* Load selected item for Share album's content */ +int _gl_share_load(void *data, const char *label) +{ + GL_CHECK_VAL(label, -1); + GL_CHECK_VAL(data, -1); + gl_dbg("label : %s ", label); + + if (!g_strcmp0(label, GL_SHARE_MESSAGE)) { + gl_ext_load_ug(data, GL_UG_MSG); + } else if (!g_strcmp0(label, GL_SHARE_EMAIL)) { + gl_ext_load_ug(data, GL_UG_EMAIL); + } else if (!g_strcmp0(label, GL_SHARE_BLUETOOTH)) { + gl_ext_load_ug(data, GL_UG_BT); + } else { + gl_dbgE("Wrong UG name!"); + return -1; + } + return 0; +} + +int gl_share_select_item(void *data, const char *label) +{ + GL_CHECK_VAL(label, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("label : %s ", label); + int cnt = 0; + + cnt = _gl_data_selected_list_count(ad); + + gl_dbg("Selected item(s) count: %d.", cnt); + if (cnt < 1) { + gl_dbgE("None items selected!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + return -1; + } + + if (!g_strcmp0(label, GL_SHARE_MESSAGE)) { + gl_ext_load_ug(ad, GL_UG_MSG); + } else if (!g_strcmp0(label, GL_SHARE_EMAIL)) { + gl_ext_load_ug(ad, GL_UG_EMAIL); + } else if (!g_strcmp0(label, GL_SHARE_BLUETOOTH)) { + gl_ext_load_ug(ad, GL_UG_BT); + } + + return 0; +} + +/* +* add selected medias to some tag +*/ +int gl_add_to_tag(void *data, const char *tagname) +{ + GL_CHECK_VAL(tagname, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_m = gl_get_view_mode(ad); + + if ((view_m != GL_VIEW_THUMBS_SELECT) && + ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + gl_dbg("Add new tag: %s.", tagname); + /* Add an emtpy tag in tags list view */ + int ret = -1; + ret = _gl_local_data_add_tag(tagname, NULL); + if (ret != 0) + gl_dbgW("_gl_local_data_add_tag failed!"); + + /* Hide title from animation */ + gl_ui_set_navi_title_visible(ad, EINA_FALSE); + elm_naviframe_item_pop(ad->maininfo.naviframe); + /* Recover the previous UI */ + gl_ctrl_rotate_ctrlbar(ad, GL_VIEW_ALBUMS_EDIT); + gl_tag_update_view(ad); + _gl_ctrl_disable_btn(ad, false, GL_NAVI_TAGS); + + /* Add notification */ + _gl_notify_create_notiinfo(ad, GL_STR_ADDED); + + } else { + /* Get all selected medias count */ + int cnt = _gl_data_selected_list_count(ad); + if (cnt == 0) { + gl_dbg("No items selected, return!"); + gl_popup_create_popup(ad, GL_POPUP_NOBUT, + GL_STR_NO_FILES_SELECTED); + ad->taginfo.b_favor_tag = false; + return -1; + } + + gl_dbg("Add tag[%s] to medias.", tagname); + g_strlcpy(ad->taginfo.new_tag_name, tagname, + sizeof(ad->taginfo.new_tag_name)); + + /* Check MMC state for cancel operation */ + gl_check_mmc_state(ad, NULL); + gl_dbg("MMC state: %d.", ad->maininfo.mmc_state); + _gl_use_thread_operate_medias(ad, GL_STR_ADD_TAG, cnt, + GL_MEDIA_OP_ADD_TAG); + } + + return 0; +} + +int gl_add_tag_to_selected(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int ret = -1; + int cnt = 0; + gl_item *gitem = NULL; + int i = 0; + int popup_op = GL_POPUP_OP_NONE; + gl_tag *gtag = ad->taginfo.current_tag; + + cnt = _gl_data_selected_list_count(ad); + + if ((gl_get_view_mode(ad) != GL_VIEW_THUMBS_SELECT) && + ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS && gtag && gtag->tag && + gtag->tag->tag_name && + !g_strcmp0(gtag->tag->tag_name, ad->taginfo.new_tag_name)) { + gl_dbgW("Already add current tag to medias!"); + /* To operate one item to show progressbar popup completely */ + cnt = 1; + } + + for (i = 0; i < cnt; i++) { + gitem = _gl_data_selected_list_get_nth(ad, i); + if (gitem && gitem->item) { + if (ad->taginfo.b_favor_tag) { + if (!gitem->item->favorite) { + ret = _gl_local_data_set_favorite(gitem->item, + true); + /* Data not updated from DB, need to set favor */ + if (ret == -1) + gl_dbgW("db_update_favorite failed!"); + else + gitem->item->favorite = true; + } + } else { + /* Add tag to media */ + ret = _gl_local_data_add_tag(ad->taginfo.new_tag_name, + gitem->item->uuid); + if (ret != 0) + gl_dbgW("_gl_local_data_add_tag failed!"); + } + + gl_dbg("Write pipe, make progressbar updated!"); + gl_thread_write_pipe(ad, i+1, popup_op); + + gitem = NULL; + popup_op = GL_POPUP_OP_NONE; + } + } + return 0; +} + +int gl_update_add_tag_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_m = gl_get_view_mode(ad); + gl_dbg("view_m: %d", view_m); + + /* Update items list */ + if (view_m == GL_VIEW_THUMBS_SELECT) { + /* Pop to tags thumbnail view */ + elm_naviframe_item_pop_to(ad->gridinfo.nf_it); + + if (ad->gridinfo.select_view) { + _gl_thumbs_clear_cbs(ad->gridinfo.select_view); + ad->gridinfo.select_view = NULL; + } + ad->gridinfo.select_view_ly = NULL; + ad->gridinfo.nf_it_select = NULL; + + ad->albuminfo.select_view = NULL; + ad->albuminfo.select_view_ly = NULL; + ad->albuminfo.nf_it_select = NULL; + + GL_CHECK_VAL(ad->taginfo.current_tag, -1); + /* Clear selected list */ + _gl_data_selected_list_finalize(ad); + + /* Restore view mode */ + gl_set_view_mode(ad, GL_VIEW_THUMBS); + + _gl_update_thumb_items(ad, false); + } else { + /* Check is it a new tag */ + bool res = _gl_data_is_in_tag_list(ad, ad->taginfo.new_tag_name); + memset(ad->taginfo.new_tag_name, 0x00, + sizeof(ad->taginfo.new_tag_name)); + /* Update tag list in tags view if new tag added */ + if (!res && ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + gl_dbg("New tag added in tags view, update tags list."); + _gl_data_update_tag_list(ad, NULL); + } + + /* Change to normal view */ + _gl_ui_pop_to_thumb(ad); + } + + ad->taginfo.b_favor_tag = false; + /* Add notification */ + _gl_notify_create_notiinfo(ad, GL_STR_ADDED); + return 0; +} + +/* +* In thumbnails view, after tap "Add tag", +* show UI for adding a new tag or just add tag in background. +* Create a new tag, and add selected items to it. +*/ +int gl_add_tag(void *data, gl_tag * gtag) +{ + GL_CHECK_VAL(gtag, -1); + GL_CHECK_VAL(gtag->tag, -1); + GL_CHECK_VAL(gtag->tag->tag_name, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + ad->taginfo.b_favor_tag = false; + + /* add items to favorites */ + if (gtag->tag->_id == GL_TAG_FAVORITES_ID) + ad->taginfo.b_favor_tag = true; + gl_add_to_tag(ad, gtag->tag->tag_name); + + return 0; +} + +int gl_remove_tag_items(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->taginfo.current_tag, -1); + GL_CHECK_VAL(ad->taginfo.current_tag->tag, -1); + + _gl_remove_tag_items(data, ad->taginfo.current_tag); + + return 0; +} + +int gl_remove_tag_from_selected(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int cnt = _gl_data_selected_list_count(ad); + int i = 0; + gl_item *gitem = NULL; + int ret = -1; + int popup_op = GL_POPUP_OP_NONE; + gl_tag * cur_tag = ad->taginfo.current_tag; + + if (!cur_tag || !cur_tag->tag) { + gl_dbgE("Null tag"); + return -1; + } + + for (i = 0; i < cnt; i++) { + gitem = _gl_data_selected_list_get_nth(ad, i); + if (gitem && gitem->item && gitem->item->uuid) { + if (cur_tag->tag->_id == GL_TAG_FAVORITES_ID) { + if (gitem->item->favorite) + _gl_local_data_set_favorite(gitem->item, + false); + } else { + ret = _gl_local_data_remove_tag(cur_tag->tag, + gitem->item->uuid); + if (ret != 0) + gl_dbgW("_gl_local_data_remove_tag failed!"); + } + } else { + gl_dbgE("Invalid item!"); + } + + gl_dbg("Write pipe, make progressbar updated!"); + gl_thread_write_pipe(ad, i+1, popup_op); + + gitem = NULL; + popup_op = GL_POPUP_OP_NONE; + } + return 0; +} + +int gl_update_remove_tag_view(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_tag * cur_tag = ad->taginfo.current_tag; + + if (!cur_tag || !cur_tag->tag) { + gl_dbgE("Null tag"); + return -1; + } + + /* Destroy selection info */ + _gl_notify_destroy_selinfo(ad); + _gl_data_selected_list_finalize(ad); + + /* Update item list */ + if (cur_tag->tag->_id == GL_TAG_FAVORITES_ID) + _gl_data_get_item_list(ad, GL_CATEGORY_FAVORITES, NULL, + GL_GET_ALL_RECORDS, GL_GET_ALL_RECORDS); + else + _gl_data_get_item_list_tagname(ad, cur_tag->tag->_id, true, + NULL); + + if (ad->maininfo.medias_cnt == 0) { + gl_dbg("All items removed, change to tags view"); + _gl_tag_comeback_from_view(ad); + + elm_naviframe_item_pop_to(ad->ctrlinfo.nf_it); + /* Only favorites tag, so disable edit button */ + if (_gl_data_get_tag_count_all(ad) <= 1) + _gl_ctrl_disable_btn(ad, true, GL_NAVI_TAGS); + } else { + if (_gl_nocontents_show(ad)) { + gl_dbg("none video/image, show nocontents"); + /* Add notification */ + _gl_notify_create_notiinfo(ad, GL_STR_REMOVED); + return -1; + } + _gl_thumbs_show_edit_view(ad); + + gl_ui_show_selall(ad); + edje_object_signal_emit(_EDJ(ad->gridinfo.navi_content_edit_ly), + GL_SIGNAL_VIEW_EDIT, "elm"); + _gl_ctrl_disable_btns(ad, ad->gridinfo.nf_it_edit, true); + } + /* Add notification */ + _gl_notify_create_notiinfo(ad, GL_STR_REMOVED); + + return 0; +} + +#ifdef _USE_ROTATE_BG + +int _gl_delay(double sec) +{ + gl_dbg("Start"); + struct timeval tv; + unsigned int start_t = 0; + unsigned int end_t = 0; + unsigned int delay_t = (unsigned int)(sec * GL_TIME_USEC_PER_SEC); + + gettimeofday(&tv, NULL); + start_t = tv.tv_sec * GL_TIME_USEC_PER_SEC + tv.tv_usec; + + for(end_t = start_t; end_t - start_t < delay_t;) { + gettimeofday(&tv, NULL); + end_t = tv.tv_sec * GL_TIME_USEC_PER_SEC + tv.tv_usec; + } + + gl_dbg("End"); + return 0; +} + +int _gl_rotate_images(void *data, bool b_left) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + /* Get all selected medias count */ + int cnt = _gl_data_selected_list_count(ad); + /* Check MMC state for cancel operation */ + gl_check_mmc_state(ad, NULL); + gl_dbg("MMC state: %d.", ad->maininfo.mmc_state); + /* Rotate left */ + int op_type = GL_MEDIA_OP_ROTATING_LEFT; + /* Rotate right */ + if (!b_left) + op_type = GL_MEDIA_OP_ROTATING_RIGHT; + _gl_use_thread_operate_medias(ad, GL_STR_ROTATING, cnt, op_type); + + return 0; +} + +int _gl_rotate_selected(void *data, int op_type) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + /* Get all selected medias count */ + int cnt = _gl_data_selected_list_count(ad); + gl_item *gitem = NULL; + int i = 0; + int popup_op = GL_POPUP_OP_NONE; + unsigned int orient = GL_ORIENTATION_ROT_ERR; + unsigned int new_orient = GL_ORIENTATION_ROT_ERR; + int ret = -1; + bool b_left = false; + + if (op_type == GL_MEDIA_OP_ROTATING_LEFT) + b_left = true; + + gl_cluster *current_album = ad->albuminfo.current_album; + /* Save cluster path to set new current_album from new albums list */ + if (current_album && current_album->cluster && + current_album->cluster->path && + strlen(current_album->cluster->path)) + g_strlcpy(ad->albuminfo.dest_folder, + current_album->cluster->path, GL_DIR_PATH_LEN_MAX); + else + gl_dbgE("Invalid folder path!"); + + /* Removed media from selected_media_elist */ + for (i = 1; i <= cnt; i++) { + _gl_data_get_item_by_index(ad, i, true, &gitem); + if (gitem != NULL && gitem->item != NULL && + gitem->item->file_url && + gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE && + GL_FILE_EXISTS(gitem->item->file_url)) { + /* Save orient in file */ + ret = _gl_exif_get_orientation(gitem->item->file_url, + &orient); + if (ret == 0) { + new_orient = _gl_exif_get_rotated_orientation(orient, + b_left); + _gl_exif_set_orientation(gitem->item->file_url, + new_orient); + /* Update thumbnail */ + media_info_refresh_metadata_to_db(gitem->item->uuid); + } + } else { + gl_dbgE("Invalid item!"); + } + + /* Add some delay for last two images to wait for thumb updated */ + if (i > cnt - 2) + _gl_delay(GL_ROTATE_DELAY); + + if (i == cnt) { + gl_dbgW("Last image rotated!"); + /* Add another delay for last thumb */ + _gl_delay(GL_ROTATE_DELAY); + } + gl_dbg("Write pipe, make progressbar updated!"); + gl_thread_write_pipe(ad, i, popup_op); + gitem = NULL; + } + /* Clear selected list */ + _gl_data_selected_list_finalize(data); + return 0; +} + +/* Update view after deleting process done */ +int _gl_update_rotate_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + _gl_data_selected_list_finalize(ad); + + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d.", view_mode); + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) + _gl_data_update_item_list(ad); + else + __gl_refresh_albums_list(ad, true, false); + + memset(ad->albuminfo.dest_folder, 0x00, GL_DIR_PATH_LEN_MAX); + + _gl_update_operation_view(ad, GL_STR_ROTATED); + + return 0; +} + +#endif + +int _gl_slideshow(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_item *cur_item = NULL; + media_content_type_e type = MEDIA_CONTENT_TYPE_OTHERS; + + if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS) + type = MEDIA_CONTENT_TYPE_VIDEO; + else if (ad->gridinfo.view_mode == GL_THUMB_IMAGES) + type = MEDIA_CONTENT_TYPE_IMAGE; + + bool b_selected = false; + int view_mode = gl_get_view_mode(ad); + if (view_mode == GL_VIEW_THUMBS_EDIT) + b_selected = true; + + _gl_data_get_first_item(ad, type, &cur_item, b_selected); + GL_CHECK_VAL(cur_item, -1); + if (b_selected) + gl_ext_load_iv_ug(ad, cur_item, GL_UG_IV_SLIDESHOW_SELECTED); + else + gl_ext_load_iv_ug(ad, cur_item, GL_UG_IV_SLIDESHOW); + return 0; +} + +Eina_Bool gl_update_view(void *data, int mode) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d", view_mode); + if (mode == GL_UPDATE_VIEW_NONE) { + gl_dbg("Don't need to update"); + return EINA_FALSE; + } + + if (view_mode == GL_VIEW_ALBUMS || + view_mode == GL_VIEW_ALBUMS_EDIT || + view_mode == GL_VIEW_ALBUMS_RENAME) { + /* Albums list should be updated first */ + gl_albums_update_view(ad); + } else if (view_mode == GL_VIEW_TAGS || + view_mode == GL_VIEW_TAGS_EDIT) { + /* Update genlist changed to tab Tags */ + gl_tag_update_realized_view(ad); + } else if (view_mode == GL_VIEW_THUMBS) { + /* Albums list should be updated first in tab Albums*/ + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + _gl_update_thumb_items(ad, false); + return EINA_TRUE; + } + + gl_cluster *cur_album = ad->albuminfo.current_album; + + /* MMC removed, change to albums view if in mmc album */ + if (mode == GL_UPDATE_VIEW_MMC_REMOVED && cur_album && + cur_album->cluster && + cur_album->cluster->type == GL_STORE_T_MMC) { + gl_dbgW("MMC removed, change to albums view!"); + gl_pop_to_ctrlbar_ly(ad, true); + return EINA_TRUE; + } + + /* Albums list should be updated first */ + _gl_update_thumb_items(ad, true); + } else if (view_mode == GL_VIEW_THUMBS_EDIT) { + /* Check thread operation case */ + if (ad->pbarinfo.sync_pipe) { + gl_dbgW("Thread operation is in process!"); + return EINA_TRUE; + } + + /* Albums list should be updated first in tab Albums*/ + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + _gl_update_thumb_items(ad, false); + return EINA_TRUE; + } + + gl_cluster *cur_album = ad->albuminfo.current_album; + /* MMC removed, change to albums view if in mmc album */ + if (mode == GL_UPDATE_VIEW_MMC_REMOVED && cur_album && + cur_album->cluster && + cur_album->cluster->type == GL_STORE_T_MMC) { + gl_dbgW("MMC removed, change to albums view!"); + gl_pop_to_ctrlbar_ly(ad, true); + return EINA_TRUE; + } + + /* Albums list should be updated first */ + _gl_update_thumb_items(ad, true); + return EINA_TRUE; + } else if (view_mode == GL_VIEW_ALBUMS_SELECT) { + gl_albums_update_view(ad); + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + _gl_update_select_thumb_items(ad); + } + return EINA_TRUE; +} + +/** +* Parse medias type and count of selected items, +* and set different type for share items. +*/ +int gl_get_share_mode(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int share_mode = GL_SHARE_NONE; + int image_cnt = 0; + int video_cnt = 0; + int sel_cnt = 0; + int view_m = gl_get_view_mode(ad); + if (view_m == GL_VIEW_ALBUMS_EDIT) { + GL_CHECK_VAL(ad->albuminfo.selected_albums_elist, -1); + gl_cluster *cur_album = NULL; + cur_album = eina_list_nth(ad->albuminfo.selected_albums_elist, 0); + GL_CHECK_VAL(cur_album, -1); + GL_CHECK_VAL(cur_album->cluster, -1); + sel_cnt = ad->selectedinfo.sel_cnt; + } else if (view_m == GL_VIEW_TAGS_EDIT) { + sel_cnt = ad->selectedinfo.sel_cnt; + } else if (view_m == GL_VIEW_ALBUMS) { + sel_cnt = ad->selectedinfo.sel_cnt; + } else { + GL_CHECK_VAL(ad->selectedinfo.medias_elist, -1); + sel_cnt = eina_list_count(ad->selectedinfo.medias_elist); + } + image_cnt = ad->selectedinfo.images_cnt; + if(image_cnt > sel_cnt) { + gl_dbgE("Images count is wrong!"); + return -1; + } + + video_cnt = sel_cnt - image_cnt; + gl_dbg("Selected items count: %d, image count: %d, video count: %d.", + sel_cnt, image_cnt, video_cnt); + + if (ad->selectedinfo.drms_cnt) { + share_mode = GL_SHARE_DRM; + } else if (image_cnt && video_cnt) { + share_mode = GL_SHARE_IMAGE_VIDEO; + } else if (image_cnt) { + if (ad->selectedinfo.jpeg_cnt == sel_cnt) { + if (image_cnt == 1) + share_mode = GL_SHARE_IMAGE_ONE_JPEG; + else + share_mode = GL_SHARE_IMAGE_MULTI_JPEG; + } else { + if (image_cnt == 1) + share_mode = GL_SHARE_IMAGE_ONE; + else + share_mode = GL_SHARE_IMAGE_MULTI; + } + } else if (video_cnt) { + if (video_cnt == 1) { + share_mode = GL_SHARE_VIDEO_ONE; + } else { + share_mode = GL_SHARE_VIDEO_MULTI; + } + } else { + gl_dbgE("Error: no video and image!"); + return -1; + } + gl_dbg("share_mode is %d.", share_mode); + + return share_mode; +} + +int _gl_destroy_ctrl_edit_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->ctrlinfo.ctrlbar_edit_ly) { + evas_object_del(ad->ctrlinfo.ctrlbar_edit_ly); + ad->ctrlinfo.ctrlbar_edit_view = NULL; + ad->ctrlinfo.ctrlbar_edit_ly = NULL; + } + return 0; +} + +int _gl_destroy_thumbs_edit_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (ad->gridinfo.navi_content_edit_ly) { + _gl_thumbs_clear_cbs(ad->gridinfo.navi_content_edit_view); + evas_object_del(ad->gridinfo.navi_content_edit_ly); + ad->gridinfo.navi_content_edit_view = NULL; + ad->gridinfo.navi_content_edit_ly = NULL; + } + return 0; +} + +int gl_destroy_thumbs_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d.", view_mode); + + gl_del_invalid_widgets(ad, GL_INVALID_NONE); + + if(ad->gridinfo.navi_content_edit_view) { + _gl_destroy_thumbs_edit_view(ad); + _gl_data_selected_list_finalize(ad); + } else { + _gl_thumbs_del_append_idler(ad); + } + _gl_notify_destroy_selinfo(ad); + /* destroy imf */ + _gl_editfield_destroy_imf(ad); + + _gl_thumbs_delete_view(ad); + + ad->albuminfo.current_album = NULL; + ad->taginfo.current_tag = NULL; + + /* Pop to controlbar layout */ + elm_naviframe_item_pop_to(ad->ctrlinfo.nf_it); + + if (view_mode == GL_VIEW_THUMBS_SELECT) { + if (ad->gridinfo.select_view) { + _gl_thumbs_clear_cbs(ad->gridinfo.select_view); + ad->gridinfo.select_view = NULL; + } + ad->gridinfo.select_view_ly = NULL; + ad->gridinfo.nf_it_select = NULL; + + ad->albuminfo.select_view = NULL; + ad->albuminfo.select_view_ly = NULL; + ad->albuminfo.nf_it_select = NULL; + } + return 0; +} + +/** +* b_update_albums_list +* True: Update albums list. False: Albums list already updated. +* +* It's in thumbnails view, video list view, or selectioinfo view. +* Destroy invalid widegets or UGs. +* Pop current invalid view to controlbar layout, +*/ +int gl_pop_to_ctrlbar_ly(void *data, bool b_update_albums_list) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("b_update_albums_list: %d", b_update_albums_list); + + /* Destroy thumbnails/video_list view then pop to ctrlbar_ly */ + gl_destroy_thumbs_view(ad); + + /* Update albums list */ + if (b_update_albums_list) + gl_refresh_albums_list(ad); + + if (gl_check_gallery_empty(ad)) { + /* None albums exist, Change to albums view. */ + gl_dbgW("Empty Gallery, change to Albums view."); + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + /* Change to Albums tab. */ + gl_dbg("Not in Albums tab."); + Elm_Object_Item *first_it = NULL; + Evas_Object *ctrlbar = ad->ctrlinfo.ctrlbar; + first_it = elm_toolbar_first_item_get(ctrlbar); + GL_CHECK_VAL(first_it, -1); + elm_toolbar_item_selected_set(first_it, EINA_TRUE); + return 0; + } + gl_albums_comeback_from_view(ad); + /* None albums, disable edit button/controlbar */ + _gl_ctrl_disable_btn(ad, true, GL_NAVI_ALBUMS); + gl_ctrl_disable_ctrlbar(ad, true); + } else if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + /* Change to tags view */ + gl_dbg("Change to Tags view."); + _gl_tag_comeback_from_view(ad); + /* Only favorites tag exists, disable edit button */ + if (_gl_data_get_tag_count_all(ad) <= 1) + _gl_ctrl_disable_btn(ad, true, GL_NAVI_TAGS); + } else { + /* Change to albums view. */ + gl_dbg("Change to Albums view."); + gl_albums_comeback_from_view(ad); + /* None editable albums, disable edit button */ + if (ad->albuminfo.cluster_list->edit_cnt == 0) + _gl_ctrl_disable_btn(ad, true, GL_NAVI_ALBUMS); + } + return 0; +} + +/* Vibrate device */ +int gl_play_vibration(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + haptic_device_h *device_handle = NULL; + haptic_effect_h *effect_handle = NULL; + int ret = -1; + + if (ad->entryinfo.haptic_handle >= 0) { + gl_dbg("Remove previous haptic handle."); + _gl_stop_vibration(ad); + } + device_handle = (haptic_device_h *)malloc(sizeof(haptic_device_h)); + if (device_handle == NULL) { + gl_dbgE("malloc fail"); + return -1; + } + ret = haptic_open(HAPTIC_DEVICE_ALL,device_handle); + if (ret != HAPTIC_ERROR_NONE) { + gl_dbgE("haptic_open failed[%d]!", ret); + GL_FREEIF(device_handle); + return -1; + } + + if (ad->entryinfo.vibration_timer) { + ecore_timer_del(ad->entryinfo.vibration_timer); + ad->entryinfo.vibration_timer = NULL; + } + Ecore_Timer *vibration_timer = NULL; + vibration_timer = ecore_timer_add(GL_TIMER_INTERVAL_VIBRATION, + _gl_vibration_timer_cb, data); + ad->entryinfo.vibration_timer = vibration_timer; + + effect_handle = (haptic_effect_h *)malloc(sizeof(haptic_effect_h)); + if (effect_handle == NULL) { + gl_dbgE("effect_handle malloc fail"); + GL_FREEIF(device_handle); + return -1; + } + ret = haptic_vibrate_monotone(*device_handle, + GL_VIBRATION_DURATION, effect_handle); + if (ret != HAPTIC_ERROR_NONE) { + gl_dbgE("haptic_vibrate_monotone failed[%d]!", ret); + GL_FREEIF(device_handle); + GL_FREEIF(effect_handle); + return -1; + } + + ad->entryinfo.device_handle = device_handle; + ad->entryinfo.effect_handle = effect_handle; + ad->entryinfo.haptic_handle = GL_VIBRATION_DEVICE; + + return 0; +} + +/* Change int to char * of video duration, caller need to free the allocated memory */ +char *_gl_get_duration_string(unsigned int v_dur) +{ + char *dur_str = calloc(1, GL_FILE_PATH_LEN_MAX); + GL_CHECK_NULL(dur_str); + if (v_dur > 0) { + int duration = floor(v_dur / GL_TIME_MSEC_PER_SEC); + int dur_hr = 0; + int dur_min = 0; + int dur_sec = 0; + int tmp = 0; + + if (duration >= GL_TIME_SEC_PER_HOUR) { + dur_sec = duration % GL_TIME_SEC_PER_MIN; + tmp = floor(duration / GL_TIME_SEC_PER_MIN); + dur_min = tmp % GL_TIME_MIN_PER_HOUR; + dur_hr = floor(tmp / GL_TIME_MIN_PER_HOUR); + } else if (duration >= GL_TIME_SEC_PER_MIN) { + dur_hr = 0; + dur_min = floor(duration / GL_TIME_SEC_PER_MIN); + dur_sec = duration % GL_TIME_SEC_PER_MIN; + } else { + dur_hr = 0; + dur_min = 0; + dur_sec = duration % GL_TIME_SEC_PER_MIN; + } + + snprintf(dur_str, GL_FILE_PATH_LEN_MAX, "%02d:%02d:%02d", + dur_hr, dur_min, dur_sec); + } else { + snprintf(dur_str, GL_FILE_PATH_LEN_MAX, "00:00:00"); + } + dur_str[strlen(dur_str)] = '\0'; + return dur_str; +} + +gl_icon_type _gl_get_icon_type(gl_item *git) +{ + if (git == NULL || git->item == NULL || git->item->file_url == NULL) { + gl_dbgE("Invalid item :%p", git); + return GL_ICON_CORRUPTED_FILE; + } + /* Is it DRM file? Has a valid RO? */ + if(gl_drm_is_drm_file(git->item->file_url) && + gl_drm_check_valid_ro(git->item->file_url, gl_drm_get_permtype(git->item->type)) == false) { + return GL_ICON_EXPIRED_DRM; + } + + return GL_ICON_NORMAL; +} + diff --git a/src/widget/gl-button.c b/src/widget/gl-button.c new file mode 100755 index 0000000..2b9b301 --- /dev/null +++ b/src/widget/gl-button.c @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-ui-util.h" +#include "gl-button.h" +#include "gl-strings.h" + +#define GL_BTN_POPUP "popup_button/default" + +/******************************************************* +** Prototype : _gl_but_create_but +** Description : Create button +** Input : Evas_Object *parent +** Input : const char *icon +** Input : const char *text +** Input : const char *style +** Input : But_Smart_Cb cb_func +** Input : const void *data +** Output : None +** Return Value : +** Calls : +** Called By : +** +** History : +** 1.Date : 2011/06/10 +** Author : Samsung +** Modification : Created function +** +*********************************************************/ +Evas_Object *_gl_but_create_but(Evas_Object *parent, const char *icon, + const char *text, const char *style, + But_Smart_Cb cb_func, const void *data) +{ + Evas_Object *btn = NULL; + GL_CHECK_NULL(parent); + + btn = elm_button_add(parent); + GL_CHECK_NULL(btn); + elm_object_focus_allow_set(btn, EINA_FALSE); + + if (style) + elm_object_style_set(btn, style); + evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); + + if (icon) { + gl_dbg("Button icon: %s", icon); + Evas_Object *ic = NULL; + ic = elm_icon_add(btn); + GL_CHECK_NULL(ic); + elm_image_file_set(ic, icon, NULL); + elm_image_aspect_fixed_set(ic, EINA_TRUE); + elm_image_fill_outside_set(ic, EINA_TRUE); + evas_object_size_hint_aspect_set(ic, + EVAS_ASPECT_CONTROL_VERTICAL, + 1, 1); + evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE); + elm_object_content_set(btn, ic); + } + + if (text) { + gl_dbg("Button text: %s", text); + elm_object_text_set(btn, text); + } + + if (cb_func) + evas_object_smart_callback_add(btn, "clicked", cb_func, data); + + return btn; +} + +Evas_Object *_gl_but_create_but_popup(Evas_Object *parent, const char *text, + But_Smart_Cb cb_func, const void *data) +{ + return _gl_but_create_but(parent, NULL, text, GL_BTN_POPUP, cb_func, data); +} + diff --git a/src/widget/gl-controlbar.c b/src/widget/gl-controlbar.c new file mode 100755 index 0000000..334c49f --- /dev/null +++ b/src/widget/gl-controlbar.c @@ -0,0 +1,723 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-controlbar.h" +#include "gl-albums.h" +#include "gl-thumbs.h" +#include "gl-data.h" +#include "gl-tags.h" +#include "gl-strings.h" +#include "gl-icons.h" +#include "gl-notify.h" +#include "gl-progressbar.h" +#include "gl-ctxpopup.h" + +#define GL_CTRL_STYLE_TABBAR "tabbar" +#define GL_CTRL_STYLE_TABBAR_LAND "tabbar/item_horizontal" + +#define GL_CTRL_SEG_STYLE "gallery/default" +/* (144x3) */ +#define GL_SEGMENT_WIDTH_MIN_INC (396*elm_config_scale_get()) + +static int __gl_ctrl_reset_btn(void *data, int grid_mode) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + bool is_zero = false; + gl_dbg("changed between tool tab(all/image/video)"); + if (grid_mode == GL_THUMB_VIDEOS) + is_zero = _gl_data_is_item_cnt_zero(ad, MEDIA_CONTENT_TYPE_VIDEO); + else if (grid_mode == GL_THUMB_IMAGES) + is_zero = _gl_data_is_item_cnt_zero(ad, MEDIA_CONTENT_TYPE_IMAGE); + + /* none items, disable 'edit' button */ + if (is_zero) { + _gl_ui_disable_btn(ad->gridinfo.edit_btn); + _gl_ui_disable_slideshow(ad, true); + } else { + _gl_ui_enable_btn(ad->gridinfo.edit_btn); + _gl_ui_disable_slideshow(ad, false); + } + return 0; +} + +void _gl_ctrl_segment_change_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->uginfo.ug_called_by_me || ad->gridinfo.grid_append_idler) { + gl_dbgW("UG invoked or appending gridview!"); + return; + } + + const char *label = NULL; + label = elm_object_item_text_get((Elm_Object_Item *)event_info); + GL_CHECK(label); + gl_dbg("label: %s", label); + _gl_ctxpopup_del(data); + + int old_m = ad->gridinfo.view_mode; + + if (!g_strcmp0(label, GL_STR_ALL)) { + gl_dbg("Creating all-media view"); + ad->gridinfo.view_mode = GL_THUMB_ALL; + } else if (!g_strcmp0(label, GL_STR_IMAGES)) { + gl_dbg("Creating image view"); + ad->gridinfo.view_mode = GL_THUMB_IMAGES; + } else if (!g_strcmp0(label, GL_STR_VIDEOS)) { + gl_dbg("Creating video view"); + ad->gridinfo.view_mode = GL_THUMB_VIDEOS; + } else { + gl_dbgE("Wrong label!"); + return; + } + + if (ad->gridinfo.view_mode == old_m) { + gl_dbgW("Already showed!"); + return; + } + + if (ad->gridinfo.all_grid_view == NULL) + ad->gridinfo.all_grid_view = _gl_thumbs_add_grid(ad, + ad->gridinfo.navi_content_ly, + ad->gridinfo.view_mode, + false); + else + _gl_thumbs_update_view(ad); + + elm_object_part_content_unset(ad->gridinfo.navi_content_ly, + "elm.swallow.view"); + evas_object_show(ad->gridinfo.all_grid_view); + elm_object_part_content_set(ad->gridinfo.navi_content_ly, + "elm.swallow.view", + ad->gridinfo.all_grid_view); + + __gl_ctrl_reset_btn(ad, ad->gridinfo.view_mode); + gl_set_view_mode(ad, GL_VIEW_THUMBS); +} + +/* Pop naviframe item when show albums/tags edit view */ +static int _gl_ctrl_popup_edit_view(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->ctrlinfo.nf_it, -1); + + elm_naviframe_item_pop_to(ad->ctrlinfo.nf_it); + ad->ctrlinfo.nf_it_edit = NULL; + return 0; +} + +static int __gl_ctrl_reset_albums(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + + if (view_mode == GL_VIEW_ALBUMS_EDIT) { + /* Destroy data */ + _gl_data_finalize_albums_selected_list(ad); + /* Refresh albums list */ + _gl_data_get_cluster_list(ad); + } + + return 0; +} + +static int __gl_ctrl_reset_tags(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + + /* Destroy data */ + if (view_mode == GL_VIEW_TAGS_EDIT) + _gl_data_finalize_tags_selected_list(ad); + + if (ad->taginfo.tags_view) + gl_tag_unset_rename(ad); + ad->taginfo.current_tag = NULL; + + return 0; +} + +static int __gl_ctrl_reset_previous_tab(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + switch (ad->ctrlinfo.tab_mode) { + case GL_CTRL_TAB_ALBUMS: + __gl_ctrl_reset_albums(ad); + break; + case GL_CTRL_TAB_TAGS: + __gl_ctrl_reset_tags(ad); + break; + default: + gl_dbgE("Wrong tabbar mode!"); + return -1; + } + + /* Delete layout and edit view */ + _gl_destroy_ctrl_edit_view(ad); + /* Delete naviframe item */ + _gl_ctrl_popup_edit_view(ad); + + /* Hide previous view */ + Evas_Object *pre_view = NULL; + pre_view = elm_object_part_content_unset(ad->ctrlinfo.ctrlbar_view_ly, + "contents"); + evas_object_hide(pre_view); + + return 0; +} + +static int __gl_ctrl_remake_btns(void *data, gl_ctrl_tab_mode mode) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Reset some flags */ + ad->albuminfo.b_edit_disable = false; + ad->taginfo.b_edit_disable = false; + + switch (mode) { + case GL_CTRL_TAB_ALBUMS: + gl_dbg("GL_CTRL_TAB_ALBUMS"); + /* add items */ + _gl_ui_add_btns_albums(ad, GL_UI_ALBUMS_REMAKE); + break; + case GL_CTRL_TAB_TAGS: + gl_dbg("GL_CTRL_TAB_TAGS"); + _gl_tags_add_btns(ad); + break; + default: + gl_dbgE("Error mode!"); + return -1; + } + gl_dbg("Done"); + + return 0; +} + +static void _gl_ctrl_view_change_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d, tab_mode: %d", view_mode, ad->ctrlinfo.tab_mode); + Elm_Object_Item *it = elm_toolbar_selected_item_get(obj); + GL_CHECK(it); + const char *selected_label = elm_object_item_text_get(it); + GL_CHECK(selected_label); + gl_dbg("Tab %s selected.", selected_label); + _gl_ctxpopup_del(data); + + if (!g_strcmp0(selected_label, GL_STR_CTRL_ITEM_ALBUMS)) { + gl_dbg("Albums"); + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_ALBUMS) { + gl_dbg("Already in Albums Tab."); + return; + } + __gl_ctrl_reset_previous_tab(ad); + gl_set_view_mode(ad, GL_VIEW_ALBUMS); + + _gl_data_get_cluster_list(ad); + gl_albums_update_items(ad); + + if (ad->albuminfo.albums_nocontents) { + gl_ctrl_disable_ctrlbar(ad, true); + } else { + evas_object_show(ad->albuminfo.albums_view); + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_view_ly, + "contents", + ad->albuminfo.albums_view); + } + + ad->ctrlinfo.tab_mode = GL_CTRL_TAB_ALBUMS; + + __gl_ctrl_remake_btns(ad, GL_CTRL_TAB_ALBUMS); + } else if (!g_strcmp0(selected_label, GL_STR_CTRL_ITEM_TAGS)) { + gl_dbg("Tags"); + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + gl_set_view_mode(ad, GL_VIEW_TAGS); + gl_dbg("Already in Tags Tab."); + return; + } + + __gl_ctrl_reset_previous_tab(ad); + gl_set_view_mode(ad, GL_VIEW_TAGS); + + if (ad->taginfo.tags_view) + gl_tag_update_view(ad); + else + ad->taginfo.tags_view = gl_tag_create_view(ad, + ad->ctrlinfo.ctrlbar_view_ly); + evas_object_show(ad->taginfo.tags_view); + elm_object_part_content_set(ad->ctrlinfo.ctrlbar_view_ly, + "contents", ad->taginfo.tags_view); + + ad->taginfo.current_tag = NULL; + ad->ctrlinfo.tab_mode = GL_CTRL_TAB_TAGS; + + __gl_ctrl_remake_btns(ad, GL_CTRL_TAB_TAGS); + } +} + +static int __gl_ctrl_disable_btn(void *data, int mode) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + if (mode == GL_NAVI_ALBUMS) { + gl_dbg("GL_NAVI_ALBUMS"); + /* disable 'edit' button */ + ad->albuminfo.b_edit_disable = true; + } else if (mode == GL_NAVI_TAGS) { + gl_dbg("GL_NAVI_TAGS"); + /* disable 'edit' button */ + ad->taginfo.b_edit_disable = false; + }else if (mode == GL_NAVI_THUMBS) { + gl_dbg("GL_NAVI_THUMBS"); + /* disable 'edit' button */ + _gl_ui_disable_btn(ad->gridinfo.edit_btn); + /* Check title button */ + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) + _gl_ui_show_add_btn(ad); + } else { + gl_dbgE("Unkonw mode"); + return -1; + } + return 0; +} + +static int __gl_ctrl_enable_btn(void *data, int mode) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("mode: %d", mode); + + if (mode == GL_NAVI_ALBUMS) { + gl_dbg("GL_NAVI_ALBUMS"); + /* enable 'edit' item */ + if (!gl_check_gallery_empty(ad) && + ad->albuminfo.cluster_list->edit_cnt) { + ad->albuminfo.b_edit_disable = false; + } else { + ad->albuminfo.b_edit_disable = true; + } + } else if (mode == GL_NAVI_THUMBS) { + gl_dbg("GL_NAVI_THUMBS"); + /* enable 'Edit' button */ + _gl_ui_enable_btn(ad->gridinfo.edit_btn); + /* Check more button */ + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + Evas_Object *more_btn = NULL; + more_btn = _gl_ui_get_btn(ad, NULL, GL_NAVIFRAME_MORE); + if (ad->maininfo.medias_cnt) + _gl_ui_enable_btn(more_btn); + else + _gl_ui_disable_btn(more_btn); + /* Check "+" button */ + _gl_ui_show_add_btn(ad); + } + + if (ad->maininfo.medias_cnt) + _gl_ui_disable_slideshow(ad, false); + else + _gl_ui_disable_slideshow(ad, true); + } else if (mode == GL_NAVI_TAGS) { + gl_dbg("GL_NAVI_TAGS"); + /* enable 'edit' button not only favorites tag */ + if (_gl_data_get_tag_count_all(ad) > 1) + ad->taginfo.b_edit_disable = false; + else + ad->taginfo.b_edit_disable = true; + } else { + gl_dbgE("Unkonw mode"); + return -1; + } + + return 0; +} + +/* Enable all buttons except for some special cases */ +static int __gl_ctrl_enable_btns(gl_appdata *ad, Elm_Object_Item *nf_it) +{ + gl_dbg(""); + GL_CHECK_VAL(ad, -1); + GL_CHECK_VAL(nf_it, -1); + bool b_disable_del = false; + bool b_disable_share = false; + + int view_mode = gl_get_view_mode(ad); + if (view_mode == GL_VIEW_ALBUMS_EDIT) { + GL_CHECK_VAL(ad->albuminfo.selected_albums_elist, -1); + int sel_cnt = 0; + sel_cnt = _gl_data_get_albums_selected_cnt(ad); + + gl_cluster *album_item = NULL; + int i = 0; + for (i = 0; i < sel_cnt; i++) { + if (b_disable_del && b_disable_share) + break; + album_item = eina_list_nth(ad->albuminfo.selected_albums_elist, + i); + if (album_item == NULL || album_item->cluster == NULL || + album_item->cluster->uuid == NULL) { + gl_dbgE("Invlaid album item!"); + continue; + } + /* All albums couldn't be deleted, so disable Delete item */ + if (album_item->cluster->type == GL_STORE_T_ALL) { + gl_dbg("All albums, disable Delete item."); + b_disable_del = true; + /* Disable share*/ + if (sel_cnt > 1) + b_disable_share = true; + } + album_item = NULL; + } + } + int share_m = gl_get_share_mode(ad); + if ((view_mode == GL_VIEW_THUMBS_EDIT || + view_mode == GL_VIEW_ALBUMS_EDIT || + view_mode == GL_VIEW_TAGS_EDIT) && share_m == GL_SHARE_DRM) { + gl_dbgW("Selected item is DRM file!"); + b_disable_share = true; + } + + /* more-share-delete */ + _gl_ui_disable_each_btn(nf_it, false, b_disable_share, b_disable_del); + return 0; +} + +Evas_Object * +gl_ctrl_create_ctrlbar_view(Evas_Object * parent) +{ + gl_dbg(""); + GL_CHECK_NULL(parent); + + Evas_Object *layout = NULL; + layout = gl_ui_load_edj(parent, GL_EDJ_FILE, GL_GRP_CONTROLBAR); + GL_CHECK_NULL(layout); + evas_object_show(layout); + + return layout; +} + +Evas_Object *gl_ctrl_create_ctrlbar_ly(Evas_Object *parent) +{ + gl_dbg(""); + gl_dbg_launch(" gl_ctrl_create_ctrlbar_ly:start"); + GL_CHECK_NULL(parent); + Evas_Object *layout = NULL; + layout = gl_ui_load_edj(parent, GL_EDJ_FILE, GL_GRP_CONTROLBAR_LY); + GL_CHECK_NULL(layout); + evas_object_show(layout); + + gl_dbg_launch(" gl_ctrl_create_ctrlbar_ly:end"); + + return layout; +} + +Evas_Object *gl_ctrl_create_ctrlbar(void *data, int mode) +{ + gl_dbg_launch(" gl_ctrl_create_ctrlbar:start"); + gl_dbg("mode: %d", mode); + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *cbar = NULL; + Elm_Object_Item *item[GL_CTRL_TAB_CNT]; + + if (ad->ctrlinfo.ctrlbar != NULL) { + gl_dbg("Remove the existed control bar"); + evas_object_del(ad->ctrlinfo.ctrlbar); + ad->ctrlinfo.ctrlbar = NULL; + } + + gl_dbg_launch(" elm_toolbar_add:start"); + cbar = elm_toolbar_add(ad->ctrlinfo.ctrlbar_ly); + gl_dbg_launch(" elm_toolbar_add:end"); + GL_CHECK_NULL(cbar); + gl_dbg("elm_toolbar_add:done"); + elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND); + elm_toolbar_transverse_expanded_set(cbar, EINA_TRUE); + + if (mode != GL_CTRL_TAB_ALBUMS) { + ad->ctrlinfo.tab_mode = -1; + gl_dbgW("Set tab_mode as -1!"); + } + + if (mode == GL_CTRL_TAB_ALBUMS || mode == GL_CTRL_TAB_TAGS) { + int rotate_mode = ad->maininfo.rotate_mode; + ad->ctrlinfo.rotate_mode = rotate_mode; + gl_dbg("Rotate_mode is %d", rotate_mode); + if ((rotate_mode == APP_DEVICE_ORIENTATION_270) || + (rotate_mode == APP_DEVICE_ORIENTATION_90)) { + elm_object_style_set(cbar, GL_CTRL_STYLE_TABBAR_LAND); + } else { + elm_object_style_set(cbar, GL_CTRL_STYLE_TABBAR); + } + + gl_dbg_launch(" elm_toolbar_item_append:start"); + item[GL_CTRL_TAB_ALBUMS] = elm_toolbar_item_append(cbar, + GL_CTRL_ICON_ALBUMS, + GL_STR_CTRL_ITEM_ALBUMS, + _gl_ctrl_view_change_cb, + ad); + item[GL_CTRL_TAB_TAGS] = elm_toolbar_item_append(cbar, + GL_CTRL_ICON_TAGS, + GL_STR_CTRL_ITEM_TAGS, + _gl_ctrl_view_change_cb, + ad); + gl_dbg_launch(" elm_toolbar_item_append:end"); + gl_dbg("elm_toolbar_item_append:done"); + elm_toolbar_select_mode_set(cbar, ELM_OBJECT_SELECT_MODE_ALWAYS); + + if (ad->albuminfo.gallery_launched == true) { + if (gl_check_gallery_empty(ad)) { + /** + * disable control bar when none album exists. + * or file system is unmounted. + */ + gl_dbg("Disable tabbar items"); + int i = 0; + for (i = 0; i < GL_CTRL_TAB_CNT; i++) + elm_object_item_disabled_set(item[i], + EINA_TRUE); + } + + elm_toolbar_item_selected_set(item[mode], EINA_TRUE); + } + } + gl_dbg_launch(" gl_ctrl_create_ctrlbar:end"); + + return cbar; +} + +//disable/enable controlbar tab event. +int +gl_ctrl_disable_tab_event(void *data, bool disabled) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->ctrlinfo.ctrlbar, -1); + gl_dbgE("TODO: Check me"); + + if (gl_get_view_mode(ad) == GL_VIEW_ALBUMS) + { + /*if (disabled) + { + evas_object_smart_callback_del(ad->ctrlinfo.ctrlbar, + "view,change,before", + _gl_ctrl_view_change_cb); + } + else + { + evas_object_smart_callback_add(ad->ctrlinfo.ctrlbar, + "view,change,before", + _gl_ctrl_view_change_cb, ad); + }*/ + } + + return 0; +} + +/* Select new tab, view changed callback would be invoked */ +int _gl_ctrl_sel_tabbar_item(void *data, const char *aul_type) +{ + GL_CHECK_VAL(data, -1); + GL_CHECK_VAL(aul_type, -1); + gl_appdata *ad = (gl_appdata *)data; + Elm_Object_Item *cbar_it = NULL; + cbar_it = elm_toolbar_first_item_get(ad->ctrlinfo.ctrlbar); + const char *text = NULL; + int len = strlen(aul_type); + bool b_found = false; + const char *tab_i18n_text = NULL; + gl_dbg("AUL type: %s", aul_type); + + if (strncasecmp(aul_type, GL_AUL_ALBUM, len) == 0) + tab_i18n_text = GL_STR_CTRL_ITEM_ALBUMS; + else if (strncasecmp(aul_type, GL_AUL_TAG, len) == 0) + tab_i18n_text = GL_STR_CTRL_ITEM_TAGS; + else + gl_dbgE("Wrong type!"); + GL_CHECK_VAL(tab_i18n_text, -1); + + /* Get item to be selected */ + while (cbar_it) { + text = elm_object_item_text_get(cbar_it); + if (!strncasecmp(text, tab_i18n_text, len)) { + b_found = true; + break; + } + + cbar_it = elm_toolbar_item_next_get(cbar_it); + } + + if (b_found && cbar_it) { + elm_toolbar_item_selected_set(cbar_it, EINA_TRUE); + return 0; + } else { + gl_dbgE("Failed to get tabbar item!"); + return -1; + } +} + +int _gl_ctrl_show_tabbar(void *data, bool b_show) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->ctrlinfo.ctrlbar_ly, -1); + GL_CHECK_VAL(ad->ctrlinfo.ctrlbar_view_ly, -1); + int rotate_mode = ad->maininfo.rotate_mode; + gl_dbg("Tabbar show: %d, rotate_mode: %d", b_show, rotate_mode); + Evas_Object *view_ly = ad->ctrlinfo.ctrlbar_view_ly; + + if (gl_get_view_mode(ad) == GL_VIEW_ALBUMS_RENAME || + gl_get_view_mode(ad) == GL_VIEW_ALBUMS_EDIT) { + gl_dbg("Rename album, set edit layout"); + view_ly = ad->ctrlinfo.ctrlbar_edit_ly; + } + + if (b_show) { + if ((rotate_mode == APP_DEVICE_ORIENTATION_270) || + (rotate_mode == APP_DEVICE_ORIENTATION_90)) { + edje_object_signal_emit(_EDJ(view_ly), + GL_SIGNAL_VIEW_TABBAR_BG_HIDE, + "elm"); + edje_object_signal_emit(_EDJ(ad->ctrlinfo.ctrlbar_ly), + GL_SIGNAL_VIEW_TABBAR_LAND, + "elm"); + } else { + edje_object_signal_emit(_EDJ(view_ly), + GL_SIGNAL_VIEW_TABBAR_BG_HIDE, + "elm"); + edje_object_signal_emit(_EDJ(ad->ctrlinfo.ctrlbar_ly), + GL_SIGNAL_VIEW_TABBAR_DEFAULT, + "elm"); + } + } else { + if ((rotate_mode == APP_DEVICE_ORIENTATION_270) || + (rotate_mode == APP_DEVICE_ORIENTATION_90)) { + edje_object_signal_emit(_EDJ(view_ly), + GL_SIGNAL_VIEW_TABBAR_BG_SHOW_LAND, + "elm"); + edje_object_signal_emit(_EDJ(ad->ctrlinfo.ctrlbar_ly), + "elm,tabbar,state,hide", "elm"); + } else { + edje_object_signal_emit(_EDJ(view_ly), + GL_SIGNAL_VIEW_TABBAR_BG_SHOW_PORT, + "elm"); + edje_object_signal_emit(_EDJ(ad->ctrlinfo.ctrlbar_ly), + "elm,tabbar,state,hide", "elm"); + } + } + return 0; +} + +bool gl_ctrl_rotate_ctrlbar(void *data, int mode) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + int view_mode = 0; + + /* Rotate top tabbar */ + if (mode) + view_mode = mode; + else + view_mode = gl_get_view_mode(ad); + gl_dbg("view mode: %d.", view_mode); + + bool b_show_tabbar = true; + + if (view_mode == GL_VIEW_ALBUMS || view_mode == GL_VIEW_ALBUMS_EDIT || + view_mode == GL_VIEW_TAGS || view_mode == GL_VIEW_TAGS_EDIT) { + int rotate_mode = ad->maininfo.rotate_mode; + if (view_mode == GL_VIEW_TAGS && + (ad->entryinfo.entry_mode == GL_ENTRY_NEW_TAG || + ad->entryinfo.entry_mode == GL_ENTRY_RENAME_TAG)) { + /* New tag view, return */ + gl_dbg("Add an empty tag."); + return 0; + } + char *cbar_style = GL_CTRL_STYLE_TABBAR; + if (rotate_mode == APP_DEVICE_ORIENTATION_270 || + rotate_mode == APP_DEVICE_ORIENTATION_90) { + gl_dbg("Landscape, small mode."); + /* set horizontal style: icon+text */ + cbar_style = GL_CTRL_STYLE_TABBAR_LAND; + } + elm_object_style_set(ad->ctrlinfo.ctrlbar, cbar_style); + + if (b_show_tabbar) + _gl_ctrl_show_tabbar(ad, b_show_tabbar); + } + + return true; +} + +//disable/enable controlbar items. +int gl_ctrl_disable_ctrlbar(void *data, bool disabled) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->ctrlinfo.ctrlbar, -1); + gl_dbg("Controlbar items disabled: %d.", disabled); + + if (disabled) + elm_toolbar_select_mode_set(ad->ctrlinfo.ctrlbar, + ELM_OBJECT_SELECT_MODE_NONE); + else + elm_toolbar_select_mode_set(ad->ctrlinfo.ctrlbar, + ELM_OBJECT_SELECT_MODE_ALWAYS); + return 0; +} + +int _gl_ctrl_disable_btn(void *data, bool disabled, int mode) +{ + GL_CHECK_VAL(data, -1); + gl_dbg("Title button disabled: %d.", disabled); + if (disabled) + __gl_ctrl_disable_btn(data, mode); + else + __gl_ctrl_enable_btn(data, mode); + + return 0; +} + +int _gl_ctrl_disable_btns(void *data, Elm_Object_Item *nf_it, bool b_disable) +{ + gl_dbg("b_disable: %d", b_disable); + GL_CHECK_VAL(data, -1); + GL_CHECK_VAL(nf_it, -1); + + if (!b_disable) + __gl_ctrl_enable_btns(data, nf_it); + else + _gl_ui_disable_btns(nf_it, true); + return 0; +} + diff --git a/src/widget/gl-ctxpopup.c b/src/widget/gl-ctxpopup.c new file mode 100755 index 0000000..51ceb4e --- /dev/null +++ b/src/widget/gl-ctxpopup.c @@ -0,0 +1,401 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gallery.h" +#include "gl-ctxpopup.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-debug.h" +#include "gl-strings.h" +#include "gl-button.h" +#include "gl-controlbar.h" +#include "gl-thumbs.h" +#include "gl-tags-edit.h" +#include "gl-tags-new.h" +#include "gl-albums-new.h" +#include "gl-albums-edit.h" + +#define GL_CTXPOPUP_OBJ_DATA_KEY "gl_ctxpopup_data_key" + +static void __gl_ctxpopup_hide_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + + evas_object_del(obj); + ad->maininfo.ctxpopup = NULL; + gl_dbg(""); +} + +static int __gl_ctxpopup_show(void *data, Evas_Object *btn, Evas_Object *ctxpopup) +{ + GL_CHECK_VAL(ctxpopup, -1); + GL_CHECK_VAL(btn, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int x_position = 0; + int y_position = 0; + int w = 0; + int h = 0; + + elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP, + ELM_CTXPOPUP_DIRECTION_LEFT, + ELM_CTXPOPUP_DIRECTION_RIGHT, + ELM_CTXPOPUP_DIRECTION_DOWN); + + evas_object_geometry_get(btn, &x_position, &y_position, &w, &h); + if (g_strcmp0(elm_object_style_get(btn), GL_BUTTON_STYLE_NAVI_MORE) == 0) { + evas_object_move(ctxpopup, x_position+w/3, y_position + h/2); + } else { + if (ad->maininfo.rotate_mode == APP_DEVICE_ORIENTATION_90 || + ad->maininfo.rotate_mode == APP_DEVICE_ORIENTATION_270) + evas_object_move(ctxpopup, x_position+w*3/4, + y_position + h/2); + else + evas_object_move(ctxpopup, x_position+w/2, + y_position + h/2); + } + gl_dbg("(%d, %d) - (%d, %d)", x_position, y_position, w, h); + + evas_object_show(ctxpopup); + ad->maininfo.ctxpopup = ctxpopup; + evas_object_smart_callback_add(ctxpopup, "dismissed", + __gl_ctxpopup_hide_cb, data); + return 0; +} + +static void __gl_ctxpopup_share_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(event_info); + GL_CHECK(data); + const char *label = NULL; + + label = elm_object_item_text_get((Elm_Object_Item *)event_info); + GL_CHECK(label); + gl_dbg("label: %s", label); + _gl_ctxpopup_del(data); + + int view_mode = gl_get_view_mode(data); + if (view_mode == GL_VIEW_ALBUMS_EDIT) + _gl_albums_edit_share(data, label); + else if (view_mode == GL_VIEW_TAGS_EDIT) + _gl_tags_edit_share(data, label); + else + gl_share_select_item(data, label); +} + +static void __gl_ctxpopup_move_cb(void *data, Evas_Object *obj, + void *event_info) +{ + gl_dbg(""); + /* Get 'ad' via 'GL_CTXPOPUP_OBJ_DATA_KEY' */ + GL_CHECK(obj); + gl_appdata *ad = NULL; + ad = (gl_appdata *)evas_object_data_get(obj, GL_CTXPOPUP_OBJ_DATA_KEY); + GL_CHECK(ad); + _gl_ctxpopup_del(ad); + + GL_FREEIF(ad->albuminfo.path); + /** + * 'data == NULL' is new album case, + * other move/save to some existed album. + */ + if (data) { + ad->albuminfo.path = strdup((char *)data); + gl_dbg("Dest album path: %s", ad->albuminfo.path); + gl_move_to_album(ad); + } else { + _gl_albums_new_create_view(ad); + } +} + +static void __gl_ctxpopup_addtag_cb(void *data, Evas_Object *obj, + void *event_info) +{ + /* Get 'ad' via 'GL_CTXPOPUP_OBJ_DATA_KEY' */ + GL_CHECK(obj); + gl_appdata *ad = NULL; + ad = (gl_appdata *)evas_object_data_get(obj, GL_CTXPOPUP_OBJ_DATA_KEY); + GL_CHECK(ad); + _gl_ctxpopup_del(ad); + + /** + * 'data == NULL' is new tag case, other add to exist tag + */ + if (data) + gl_add_tag(ad, data); + else + _gl_tags_new_create_view(ad); +} + +static int __gl_ctxpopup_create_move(void *data, Evas_Object *btn, + Evas_Smart_Cb it_cb) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + int i = 0; + Eina_List *album_list = NULL; + int all_count = 0; + const char *label = NULL; + gl_cluster *album_item = NULL; + gl_cluster *current_album = ad->albuminfo.current_album; + + Evas_Object *ctxpopup = elm_ctxpopup_add(ad->maininfo.naviframe); + GL_CHECK_VAL(ctxpopup, -1); + + evas_object_data_set(ctxpopup, GL_CTXPOPUP_OBJ_DATA_KEY, data); + + elm_ctxpopup_item_append(ctxpopup, GL_STR_CREATE_ALBUM, NULL, it_cb, + NULL); + + if (ad->albuminfo.cluster_list && ad->albuminfo.cluster_list->clist) { + album_list = ad->albuminfo.cluster_list->clist; + all_count = eina_list_count(album_list); + } else { + gl_dbgE("cluster list is NULL"); + return -1; + } + + for (i = 0; i < all_count; i++) { + album_item = eina_list_nth(album_list, i); + GL_CHECK_VAL(album_item, -1); + GL_CHECK_VAL(album_item->cluster, -1); + GL_CHECK_VAL(album_item->cluster->display_name, -1); + + /* places view->grid view, current album doesn't exist. */ + GL_CHECK_VAL(album_item->cluster->uuid, -1); + if ((current_album && current_album->cluster && + album_item->cluster->uuid && + g_strcmp0(album_item->cluster->uuid, current_album->cluster->uuid)) && + (album_item->cluster->type == GL_STORE_T_MMC || + album_item->cluster->type == GL_STORE_T_PHONE)) { + if (_gl_data_is_root_path(album_item->cluster->path)) { + /* "root" case, set display name as "No Name" */ + label = GL_ALBUM_PHOME_ROOT_NAME; + } else if (strlen(album_item->cluster->display_name)) { + label = _gl_get_i18n_album_name(album_item); + } else { + gl_dbgE("Album name is wrong!"); + label = GL_ALBUM_PHOME_ROOT_NAME; + } + elm_ctxpopup_item_append(ctxpopup, label, NULL, it_cb, + album_item->cluster->path); + } + } + + Evas_Object *_btn = btn; + if (_btn == NULL) + _btn = _gl_ui_get_btn(data, NULL, GL_NAVIFRAME_MORE); + return __gl_ctxpopup_show(data, _btn, ctxpopup); +} + +int _gl_ctxpopup_create(void *data, Evas_Object *but, ctx_append_cb append_cb) +{ + gl_dbg(""); + GL_CHECK_VAL(append_cb, -1); + GL_CHECK_VAL(but, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + + Evas_Object *ctxpopup = elm_ctxpopup_add(ad->maininfo.naviframe); + GL_CHECK_VAL(ctxpopup, -1); + + /* Append items */ + append_cb(data, ctxpopup); + + return __gl_ctxpopup_show(data, but, ctxpopup); +} + +int _gl_ctxpopup_del(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + if (ad->maininfo.ctxpopup) { + evas_object_data_del(ad->maininfo.ctxpopup, + GL_CTXPOPUP_OBJ_DATA_KEY); + /* Remove callback frist */ + evas_object_smart_callback_del(ad->maininfo.ctxpopup, + "dismissed", + __gl_ctxpopup_hide_cb); + evas_object_del(ad->maininfo.ctxpopup); + ad->maininfo.ctxpopup = NULL; + gl_dbg("Ctxpopup removed"); + } + return 0; +} + +int _gl_ctxpopup_create_albums(void *data, Evas_Object *but) +{ + gl_dbg(""); + GL_CHECK_VAL(but, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + + Evas_Object *ctxpopup = elm_ctxpopup_add(ad->maininfo.naviframe); + GL_CHECK_VAL(ctxpopup, -1); + + /* Show edit item */ + if (!ad->albuminfo.b_edit_disable) + elm_ctxpopup_item_append(ctxpopup, GL_STR_EDIT, NULL, + _gl_ui_edit_cb, data); + return __gl_ctxpopup_show(data, but, ctxpopup); +} + +int _gl_ctxpopup_create_thumbs(void *data, Evas_Object *but) +{ + gl_dbg(""); + GL_CHECK_VAL(but, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + + Evas_Object *ctxpopup = elm_ctxpopup_add(ad->maininfo.naviframe); + GL_CHECK_VAL(ctxpopup, -1); + + /* Add All/Images/Videos of local album and tag */ + elm_ctxpopup_item_append(ctxpopup, GL_STR_ALL, NULL, + _gl_ctrl_segment_change_cb, data); + elm_ctxpopup_item_append(ctxpopup, GL_STR_IMAGES, NULL, + _gl_ctrl_segment_change_cb, data); + elm_ctxpopup_item_append(ctxpopup, GL_STR_VIDEOS, NULL, + _gl_ctrl_segment_change_cb, data); + + return __gl_ctxpopup_show(data, but, ctxpopup); +} + +int _gl_ctxpopup_create_share(void *data, Evas_Object *but) +{ + gl_dbg(""); + GL_CHECK_VAL(but, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + const char *lb = NULL; + int i = 0; + + gl_popup_share_tbl popup_share_tbl[GL_POPUP_SHARE_NUM] = { + {GL_POPUP_SHARE_MESSAGE, GL_SHARE_MESSAGE}, + {GL_POPUP_SHARE_EMAIL, GL_SHARE_EMAIL}, + {GL_POPUP_SHARE_BT, GL_SHARE_BLUETOOTH}, + }; + + /** + * If there is any DRM file selected, + * Share option is unavailable. + */ + int share_mode = gl_get_share_mode(ad); + if (share_mode < 0 || share_mode == GL_SHARE_NONE || + share_mode == GL_SHARE_DRM) { + gl_dbgE("Share mode is wrong!"); + return -1; + } + + Evas_Object *ctxpopup = elm_ctxpopup_add(ad->maininfo.naviframe); + GL_CHECK_VAL(ctxpopup, -1); + + int view_mode = gl_get_view_mode(ad); + /* Share albums */ + if (view_mode == GL_VIEW_ALBUMS_EDIT || + view_mode == GL_VIEW_TAGS_EDIT) { + for (i = 0; i < GL_POPUP_SHARE_NUM; i++) { + lb = popup_share_tbl[i].label; + if (g_strcmp0(lb, GL_SHARE_MESSAGE) && + g_strcmp0(lb, GL_SHARE_EMAIL) && + g_strcmp0(lb, GL_SHARE_BLUETOOTH)) + continue; + + elm_ctxpopup_item_append(ctxpopup, (void *)lb, NULL, + __gl_ctxpopup_share_cb, data); + } + return __gl_ctxpopup_show(data, but, ctxpopup); + } + + for (i = 0; i < GL_POPUP_SHARE_NUM; i++) { + lb = popup_share_tbl[i].label; + if (lb == NULL || strlen(lb) == 0) + continue; + elm_ctxpopup_item_append(ctxpopup, (void *)lb, NULL, + __gl_ctxpopup_share_cb, data); + } + return __gl_ctxpopup_show(data, but, ctxpopup); +} + +int _gl_ctxpopup_create_move(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + return __gl_ctxpopup_create_move(data, NULL, __gl_ctxpopup_move_cb); +} + +int _gl_ctxpopup_create_addtag(void *data) +{ + gl_dbg(""); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->maininfo.naviframe, -1); + Eina_List *tags_elist = NULL; + + Evas_Object *ctxpopup = elm_ctxpopup_add(ad->maininfo.naviframe); + GL_CHECK_VAL(ctxpopup, -1); + + evas_object_data_set(ctxpopup, GL_CTXPOPUP_OBJ_DATA_KEY, data); + + /* normal case, get tags list from media-svc. */ + if (ad->ctrlinfo.tab_mode != GL_CTRL_TAB_TAGS) + _gl_data_get_tag_list(ad, &tags_elist); + /* tags view case, just return tags list already got. */ + else + tags_elist = ad->taginfo.tags_elist; + + /* "New tag" item */ + elm_ctxpopup_item_append(ctxpopup, GL_STR_CREATE_TAG, NULL, + __gl_ctxpopup_addtag_cb, NULL); + + if (tags_elist) { + Eina_List *tmp_elist = NULL; + gl_tag *gtag = NULL; + gl_tag *cur_tag = ad->taginfo.current_tag; + EINA_LIST_FOREACH(tags_elist, tmp_elist, gtag) { + GL_CHECK_VAL(gtag, -1); + GL_CHECK_VAL(gtag->tag, -1); + + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS && + cur_tag && cur_tag->tag && + (cur_tag->tag->_id == gtag->tag->_id)) { + gl_dbg("Skipping current tag"); + /*skip current tag in tags view case */ + continue; + } else { + /* normal tag item. */ + elm_ctxpopup_item_append(ctxpopup, + gtag->tag->tag_name, + NULL, + __gl_ctxpopup_addtag_cb, + gtag); + } + } + } + + Evas_Object *btn= _gl_ui_get_btn(data, NULL, GL_NAVIFRAME_MORE); + return __gl_ctxpopup_show(data, btn, ctxpopup); +} + diff --git a/src/widget/gl-editfield.c b/src/widget/gl-editfield.c new file mode 100755 index 0000000..e85e1fe --- /dev/null +++ b/src/widget/gl-editfield.c @@ -0,0 +1,502 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-editfield.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-popup.h" +#include "gl-tags.h" +#include "gl-tags-new.h" +#include "gl-tags-rename.h" +#include "gl-albums-new.h" +#include "gl-albums-rename.h" +#include "gl-data.h" +#include "gl-strings.h" +#include "gl-debug.h" + +/* The maximun length reached callback */ +static void __gl_editfield_maxlen_reached_cb(void *data, Evas_Object *obj, + void *event_info) +{ + gl_dbg("Entry maximum length reached, vibrate device."); + GL_CHECK(data); + /* Vibrate device if maximum length reached */ + gl_play_vibration(data); +} + +static void __gl_editfield_focused_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + if (!elm_entry_is_empty(obj)) { + gl_dbg("Show eraser."); + elm_object_signal_emit(data, "elm,state,eraser,show", "elm"); + } +} + +static void __gl_editfield_unfocused_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(data); + gl_dbg("Hide eraser."); + elm_object_signal_emit(data, "elm,state,eraser,hide", "elm"); +} + +static void __gl_editfield_eraser_clicked_cb(void *data, Evas_Object *obj, + const char *emission, + const char *source) +{ + GL_CHECK(data); + gl_dbg("Clear emtry after eraser clicked."); + elm_entry_entry_set(data, ""); +} + +static void __gl_editfield_bg_clicked_cb(void *data, Evas_Object *obj, + const char *emission, + const char *source) +{ + GL_CHECK(data); + gl_dbg(""); + elm_object_focus_set(data, EINA_TRUE); +} + +/* +* Callback registered to signal 'changed' of entry. +* It would get the entry string and check whether it's different +* with original string or not, if so, enable 'Done' button, other disable it. +*/ +static void __gl_editfield_space_check_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK(ad->entryinfo.editfield); + + /* Show/hide eraser */ + if (elm_object_focus_get(ad->entryinfo.editfield)) { + if (elm_entry_is_empty(obj)) { + gl_dbg("Hide eraser."); + elm_object_signal_emit(ad->entryinfo.editfield, + "elm,state,eraser,hide", "elm"); + } else { + gl_dbg("Show eraser."); + elm_object_signal_emit(ad->entryinfo.editfield, + "elm,state,eraser,show", "elm"); + } + } + + int view_mode = gl_get_view_mode(ad); + /* There is not done item in tags view */ + if ((view_mode == GL_VIEW_TAGS && + ad->entryinfo.entry_mode != GL_ENTRY_NEW_TAG) || + view_mode == GL_VIEW_TAGS_EDIT) + return; + + GL_CHECK(ad->entryinfo.done_btn); + const char *entry_str = NULL; + + /* Get entry string. */ + entry_str = elm_entry_entry_get(obj); + GL_CHECK(entry_str); + /** + * Changes entry string to utf-8 encoding format, + * other some special characters cannot be showed correctly. + */ + char *entry_utf8 = elm_entry_markup_to_utf8(entry_str); + GL_CHECK(entry_utf8); + /** + * Removes leading and trailing whitespace + * to avoid showing popup when new name is only composed by space + * or avoid showing popup in the case when after trip leading and trailing space, + * new name is same as existing name + */ + g_strstrip((gchar*)entry_utf8); + GL_CHECK(entry_utf8); + gl_dbg("New entry string without space: [%s]", entry_utf8); + + bool b_disabled = false; + /** + * If entry string is empty, disable 'Done' button, + * including create album/tag and rename album/tag. + */ + if (!strlen(entry_utf8)) { + gl_dbg("Entry string is empty!"); + b_disabled = true; + } + + gl_dbg("En/Disable Done button[%d]", b_disabled); + elm_object_disabled_set(ad->entryinfo.done_btn, b_disabled); + + /* Free string got from elm_entry_markup_to_utf8() */ + GL_FREEIF(entry_utf8); +} + + +/* +* make a new tag +*/ +static void __gl_editfield_new_tag_enter_cb(void *data, Evas_Object *obj, + void *event_info) +{ + gl_dbg(""); + GL_CHECK(data); + /* Unfocus to hide cursor */ + _gl_editfield_hide_imf(data); + _gl_tags_new_process(data, true); +} + +/* +* change tag name +*/ +static void __gl_editfield_rename_tag_enter_cb(void *data, Evas_Object *obj, + void *event_info) +{ + gl_dbg(""); + GL_CHECK(data); + /* Unfocus to hide cursor */ + _gl_editfield_hide_imf(data); + _gl_tags_rename_process(data); + + /* Show selectioninfo if needed */ + if (_gl_data_get_tags_selected_cnt(data) > 0) { + gl_appdata *ad = (gl_appdata *)data; + edje_object_signal_emit(_EDJ(ad->ctrlinfo.ctrlbar_edit_ly), + GL_SIGNAL_VIEW_MOVEUP, "elm"); + } +} + +/* +* make a new album +*/ +static void __gl_editfield_new_album_enter_cb(void *data, Evas_Object *obj, + void *event_info) +{ + gl_dbg(""); + GL_CHECK(data); + /* Unfocus to hide cursor */ + _gl_editfield_hide_imf(data); + _gl_albums_new_process(data, true); +} + +/* +* change album album +*/ +static void __gl_editfield_rename_album_enter_cb(void *data, Evas_Object * obj, + void *event_info) +{ + gl_dbg(""); + GL_CHECK(data); + /* Unfocus to hide cursor */ + _gl_editfield_hide_imf(data); + _gl_albums_rename_process(data, true); +} + +static int __gl_editfield_set_entry(void *data, Evas_Object *layout, + Evas_Object *entry, char *default_label) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + static Elm_Entry_Filter_Limit_Size limit_filter_data; + + switch (ad->entryinfo.entry_mode) { + case GL_ENTRY_NEW_ALBUM: + /* New album, Album name, the length is limited to 255 Chars*/ + limit_filter_data.max_char_count = GL_ENTRY_STR_CHAR_MAX; + limit_filter_data.max_byte_count = 0; + evas_object_smart_callback_add(entry, "activated", + __gl_editfield_new_album_enter_cb, + ad); + break; + case GL_ENTRY_RENAME_ALBUM: + /* Rename album, Album name, the length is limited to 255 Chars*/ + limit_filter_data.max_char_count = GL_ENTRY_STR_CHAR_MAX; + limit_filter_data.max_byte_count = 0; + evas_object_smart_callback_add(entry, "activated", + __gl_editfield_rename_album_enter_cb, + ad); + break; + case GL_ENTRY_NEW_TAG: + case GL_ENTRY_RENAME_TAG: + /* New tag, Tag name, the length is limited to 255 Bytes */ + limit_filter_data.max_char_count = 0; + limit_filter_data.max_byte_count = GL_ENTRY_STR_LEN_MAX; + if (ad->entryinfo.entry_mode == GL_ENTRY_NEW_TAG) + evas_object_smart_callback_add(entry, "activated", + __gl_editfield_new_tag_enter_cb, + ad); + else + evas_object_smart_callback_add(entry, "activated", + __gl_editfield_rename_tag_enter_cb, + ad); + break; + default: + gl_dbgW("Wrong entry mode!"); + return -1; + } + + elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, + &limit_filter_data); + + if (gl_set_entry_text(entry, default_label) != 0) { + gl_dbgE("gl_set_entry_text failed!"); + return -1; + } + elm_entry_cursor_end_set(entry); + + gl_dbg("view mode=%d", gl_get_view_mode(ad)); + evas_object_smart_callback_add(entry, "maxlength,reached", + __gl_editfield_maxlen_reached_cb, ad); + + /* Add space check callback */ + evas_object_smart_callback_add(entry, "changed", + __gl_editfield_space_check_cb, ad); + evas_object_smart_callback_add(entry, "preedit,changed", + __gl_editfield_space_check_cb, ad); + evas_object_smart_callback_add(entry, "focused", + __gl_editfield_focused_cb, layout); + evas_object_smart_callback_add(entry, "unfocused", + __gl_editfield_unfocused_cb, layout); + elm_object_signal_callback_add(layout, "elm,eraser,clicked", "elm", + __gl_editfield_eraser_clicked_cb, entry); + elm_object_signal_callback_add(layout, "elm,bg,clicked", "elm", + __gl_editfield_bg_clicked_cb, entry); + return 0; +} + +Evas_Object *_gl_editfield_create(void *data, Evas_Object *parent, + char *default_label) +{ + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_NULL(parent); + Evas_Object *layout = NULL; + Evas_Object *entry_layout = NULL; + Evas_Object *entry = NULL; + + layout = elm_layout_add(parent); + GL_CHECK_NULL(layout); + elm_layout_theme_set(layout, "layout", "application", "searchbar_base"); + elm_object_signal_emit(layout, "elm,state,show,searchbar", "elm"); + + entry_layout = elm_layout_add(layout); + if (entry_layout == NULL) { + evas_object_del(layout); + return NULL; + } + /* Customized theme */ + elm_layout_theme_set(entry_layout, "layout", "searchbar", "gallery"); + elm_object_part_content_set(layout, "searchbar", entry_layout); + + entry = elm_entry_add(entry_layout); + if (entry == NULL) { + evas_object_del(entry_layout); + return NULL; + } + + elm_entry_scrollable_set(entry, EINA_TRUE); + elm_entry_single_line_set(entry, EINA_TRUE); + elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT); + elm_object_part_content_set(entry_layout, "elm.swallow.content", entry); + elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NORMAL); + evas_object_size_hint_weight_set(entry_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(entry_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + ad->entryinfo.imf_entry = entry; + ad->entryinfo.imf_context = elm_entry_imf_context_get(ad->entryinfo.imf_entry); + ad->entryinfo.haptic_handle = -1; + ad->entryinfo.editfield = entry_layout; + /* Set callback */ + __gl_editfield_set_entry(ad, entry_layout, entry, default_label); + evas_object_show(entry_layout); + + return layout; +} + +/* Add editfield to genlist item */ +Evas_Object *_gl_editfield_create_genlist(void *data, Evas_Object *parent, + char *label) +{ + GL_CHECK_NULL(label); + GL_CHECK_NULL(parent); + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + Evas_Object *editfield_ly = NULL; + Evas_Object *entry = NULL; + + _gl_editfield_destroy_imf(ad); + + editfield_ly = elm_layout_add(parent); + GL_CHECK_NULL(editfield_ly); + elm_layout_theme_set(editfield_ly, "layout", "editfield", "default"); + evas_object_size_hint_weight_set(editfield_ly, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(editfield_ly, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + entry = elm_entry_add(editfield_ly); + if (entry == NULL) { + gl_dbgE("elm_entry_add failed!"); + evas_object_del(editfield_ly); + return NULL; + } + elm_entry_scrollable_set(entry, EINA_TRUE); + elm_entry_single_line_set(entry, EINA_TRUE); + elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT); + /* Set entry to editfield layout */ + elm_object_part_content_set(editfield_ly, "elm.swallow.content", entry); + + if (gl_set_entry_text(entry, label) != 0) { + gl_dbgE("gl_set_entry_text failed!"); + evas_object_del(editfield_ly); + return NULL; + } + + static Elm_Entry_Filter_Limit_Size limit_filter_data; + limit_filter_data.max_char_count = 0; + /* Tag name, the length is limited to 255 Bytes */ + limit_filter_data.max_byte_count = GL_ENTRY_STR_LEN_MAX; + elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, + &limit_filter_data); + evas_object_smart_callback_add(entry, "maxlength,reached", + __gl_editfield_maxlen_reached_cb, ad); + evas_object_smart_callback_add(entry, "activated", + __gl_editfield_rename_tag_enter_cb, ad); + /* Add space check callback */ + evas_object_smart_callback_add(entry, "changed", + __gl_editfield_space_check_cb, ad); + evas_object_smart_callback_add(entry, "preedit,changed", + __gl_editfield_space_check_cb, ad); + evas_object_smart_callback_add(entry, "focused", + __gl_editfield_focused_cb, editfield_ly); + evas_object_smart_callback_add(entry, "unfocused", + __gl_editfield_unfocused_cb, + editfield_ly); + elm_object_signal_callback_add(editfield_ly, "elm,eraser,clicked", "elm", + __gl_editfield_eraser_clicked_cb, entry); + + /** + * Do not unset rename mode on unfocused event + *otherwise clipboard does not work properly + */ + ad->entryinfo.imf_entry = entry; + ad->entryinfo.imf_context = elm_entry_imf_context_get(entry); + ad->entryinfo.editfield = editfield_ly; + ad->entryinfo.haptic_handle = -1; + + _gl_editfield_show_imf(data); + elm_entry_cursor_end_set(entry); + + /* Hide selectioninfo if needed */ + edje_object_signal_emit(_EDJ(ad->ctrlinfo.ctrlbar_edit_ly), + GL_SIGNAL_VIEW_EDIT, "elm"); + + return editfield_ly; +} + +/* Hide input panel and entry cursor */ +int _gl_editfield_hide_imf(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata* ad = (gl_appdata*)data; + gl_dbg(""); + + if (ad->entryinfo.imf_context) + ecore_imf_context_input_panel_hide(ad->entryinfo.imf_context); + /* Unfocus to hide cursor */ + if (ad->entryinfo.imf_entry) + elm_object_focus_set(ad->entryinfo.imf_entry, EINA_FALSE); + + return 0; +} + +/* Show input panel and entry cursor */ +int _gl_editfield_show_imf(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata* ad = (gl_appdata*)data; + gl_dbg(""); + + if (ad->entryinfo.imf_entry) { + evas_object_show(ad->entryinfo.imf_entry); + elm_object_focus_set(ad->entryinfo.imf_entry, EINA_TRUE); + } + if (ad->entryinfo.imf_context) + ecore_imf_context_input_panel_show(ad->entryinfo.imf_context); + return 0; +} + +int _gl_editfield_destroy_imf(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + /* Remove callbacks */ + _gl_ui_del_conform_cbs(ad->maininfo.naviframe); + + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode = %d", view_mode); + + if (ad->entryinfo.imf_entry) { + evas_object_smart_callback_del(ad->entryinfo.imf_entry, + "maxlength,reached", + __gl_editfield_maxlen_reached_cb); + if (ad->entryinfo.entry_mode == GL_ENTRY_NEW_ALBUM) + evas_object_smart_callback_del(ad->entryinfo.imf_entry, + "activated", + __gl_editfield_new_album_enter_cb); + else if (ad->entryinfo.entry_mode == GL_ENTRY_NEW_TAG) + evas_object_smart_callback_del(ad->entryinfo.imf_entry, + "activated", + __gl_editfield_new_tag_enter_cb); + else if (ad->entryinfo.entry_mode == GL_ENTRY_RENAME_TAG) + evas_object_smart_callback_del(ad->entryinfo.imf_entry, + "activated", + __gl_editfield_rename_tag_enter_cb); + else if (ad->entryinfo.entry_mode == GL_ENTRY_RENAME_ALBUM) + evas_object_smart_callback_del(ad->entryinfo.imf_entry, + "activated", + __gl_editfield_rename_album_enter_cb); + + evas_object_smart_callback_del(ad->entryinfo.imf_entry, + "changed", + __gl_editfield_space_check_cb); + evas_object_smart_callback_del(ad->entryinfo.imf_entry, + "preedit,changed", + __gl_editfield_space_check_cb); + } + ad->entryinfo.entry_mode = GL_ENTRY_NONE; + + if (ad->entryinfo.imf_context) + ecore_imf_context_input_panel_hide(ad->entryinfo.imf_context); + if (ad->entryinfo.editfield) { + evas_object_del(ad->entryinfo.editfield); + ad->entryinfo.editfield = NULL; + } + + ad->entryinfo.imf_entry = NULL; + ad->entryinfo.imf_context = NULL; + ad->entryinfo.done_btn = NULL; + ad->entryinfo.nf_it = NULL; + + return 0; +} + diff --git a/src/widget/gl-nocontents.c b/src/widget/gl-nocontents.c new file mode 100755 index 0000000..0c56d41 --- /dev/null +++ b/src/widget/gl-nocontents.c @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-nocontents.h" +#include "gl-thumbs.h" +#include "gl-thumbs-edit.h" +#include "gl-controlbar.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-strings.h" +#include "gl-debug.h" + +/** + * Create Nocontents. + */ +Evas_Object *_gl_nocontents_create(void *data) +{ + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *noc_lay = NULL; + char label_str[GL_POPUP_DESC_LEN_MAX] = { 0, }; + bool is_favor_tag = false; + + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + gl_tag *cur_tag = ad->taginfo.current_tag; + if (cur_tag && cur_tag->tag && + cur_tag->tag->_id == GL_TAG_FAVORITES_ID) + is_favor_tag = true; + } + + int grid_mode = ad->gridinfo.view_mode; + switch (grid_mode) { + case GL_THUMB_ALL: + if (is_favor_tag) + snprintf(label_str, sizeof(label_str), "%s", + (char *)(GL_STR_NO_FAVOR_ITEMS)); + else + snprintf(label_str, sizeof(label_str), "%s", + (char *)(GL_STR_NO_ITEMS)); + break; + case GL_THUMB_VIDEOS: + if (is_favor_tag) + snprintf(label_str, sizeof(label_str), "%s", + (char *)(GL_STR_NO_FAVOR_VIDEOS)); + else + snprintf(label_str, sizeof(label_str), "%s", + (char *)(GL_STR_NO_VIDEOS)); + break; + case GL_THUMB_IMAGES: + if (is_favor_tag) + snprintf(label_str, sizeof(label_str), "%s", + (char *)(GL_STR_NO_FAVOR_IMAGES)); + else + snprintf(label_str, sizeof(label_str), "%s", + (char *)(GL_STR_NO_IMAGES)); + break; + case GL_THUMB_ALBUMS: + snprintf(label_str, sizeof(label_str), "%s", + (char *)(GL_STR_NO_ALBUMS)); + break; + default: + snprintf(label_str, sizeof(label_str), "%s", + (char *)(GL_STR_NO_CONTENTS)); + break; + } + + gl_dbg("Nocontents label: %s", label_str); + /* Full view nocontents */ + noc_lay = elm_layout_add(ad->maininfo.naviframe); + GL_CHECK_NULL(noc_lay); + elm_layout_theme_set(noc_lay, "layout", "nocontents", "gallery"); + elm_object_part_text_set(noc_lay, GL_NOCONTENTS_TEXT, label_str); + + return noc_lay; +} + +/** + * Update label of Nocontents. + */ +bool _gl_nocontents_update_label(Evas_Object *noc, const char *new_label) +{ + GL_CHECK_VAL(new_label, -1); + GL_CHECK_VAL(noc, -1); + const char *label = NULL; + + label = elm_object_part_text_get(noc, GL_NOCONTENTS_TEXT); + GL_CHECK_VAL(label, -1); + gl_dbg("Nocontents label: %s", label); + /* Update label if they're different */ + if (g_strcmp0(label, GL_STR_NO_ALBUMS)) { + gl_dbgW("Update nocontents label!"); + elm_object_part_text_set(noc, GL_NOCONTENTS_TEXT, new_label); + return true; + } + return false; +} + +/** + * Show Nocontents in All/Images/Videos segment. + */ +bool _gl_nocontents_show(void *data) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + bool b_video_exist = false; + bool b_image_exist = false; + int grid_mode = ad->gridinfo.view_mode; + gl_item *gitem = NULL; + int i = 0; + bool ret = false; + int view_mode = gl_get_view_mode(ad); + /* Get all medias count of current album */ + int cnt = ad->maininfo.medias_cnt; + + if (cnt == 0) { + if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) { + gl_dbg("None files, show nocontents."); + if (view_mode == GL_VIEW_THUMBS_EDIT) { + gl_dbg("In edit mode, change to normal view."); + _gl_thumbs_edit_pop_view(ad); + } + /* Clear invalid objects if needed */ + _gl_thumbs_delete_view(ad); + /* Reset flags */ + ad->gridinfo.view_mode = GL_THUMB_ALL; + /* Create nocontents widget */ + Evas_Object *noc = NULL; + noc = _gl_nocontents_create(ad); + if (ad->gridinfo.all_grid_view) { + evas_object_del(ad->gridinfo.all_grid_view); + ad->gridinfo.all_grid_view = NULL; + } + ad->gridinfo.all_grid_view = noc; + ad->gridinfo.all_grid_nocontents = noc; + elm_object_part_content_unset(ad->gridinfo.navi_content_ly, + "elm.swallow.view"); + evas_object_show(ad->gridinfo.all_grid_view); + elm_object_part_content_set(ad->gridinfo.navi_content_ly, + "elm.swallow.view", + ad->gridinfo.all_grid_view); + _gl_ctrl_disable_btn(ad, true, GL_NAVI_THUMBS); + } + } else if (grid_mode == GL_THUMB_VIDEOS || + grid_mode == GL_THUMB_IMAGES) { + /* check in video or image segment. */ + for (i = 1; i <= cnt; i++) { + _gl_data_get_item_by_index(ad, i, false, &gitem); + if (gitem == NULL || gitem->item == NULL) { + gl_dbgE("gitem == NULL || gitem->item == NULL"); + continue; + } + + if (grid_mode == GL_THUMB_VIDEOS && !b_video_exist && + gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO) { + b_video_exist = true; + break; + } else if (grid_mode == GL_THUMB_IMAGES && + !b_image_exist && + gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE) { + b_image_exist = true; + break; + } + + } + + gl_dbg("video file exists->%d, image file exists->%d", + b_video_exist, b_image_exist); + if ((grid_mode == GL_THUMB_IMAGES && !b_image_exist) || + (grid_mode == GL_THUMB_VIDEOS && !b_video_exist)) { + if (view_mode == GL_VIEW_THUMBS_EDIT) { + gl_dbg("In edit mode, change to normal view."); + _gl_thumbs_edit_pop_view(ad); + } + + if (ad->gridinfo.all_grid_view) { + evas_object_del(ad->gridinfo.all_grid_view); + ad->gridinfo.all_grid_view = NULL; + ad->gridinfo.all_grid_nocontents = NULL; + } + gl_dbg("None image files, show nocontents..."); + Evas_Object *noc = _gl_nocontents_create(ad); + + ad->gridinfo.all_grid_view = noc; + ad->gridinfo.all_grid_nocontents = noc; + + elm_object_part_content_unset(ad->gridinfo.navi_content_ly, + "elm.swallow.view"); + evas_object_hide(ad->gridinfo.all_grid_view); + elm_object_part_content_set(ad->gridinfo.navi_content_ly, + "elm.swallow.view", + noc); + _gl_ctrl_disable_btn(ad, true, GL_NAVI_THUMBS); + ret = true; + } + } + + return ret; +} diff --git a/src/widget/gl-notify.c b/src/widget/gl-notify.c new file mode 100755 index 0000000..0264e88 --- /dev/null +++ b/src/widget/gl-notify.c @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "gl-notify.h" +#include "gl-thumbs.h" +#include "gl-controlbar.h" +#include "gl-thread-util.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-strings.h" +#include "gl-debug.h" +#include "gl-ext-exec.h" + +/** +* Create a new notify widget +* b_selinfo, True: Create selectioninfo, False: Create notificationinfo. +*/ +static int __gl_notify_add(void *data, Evas_Object *parent) +{ + gl_dbg(""); + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + + _gl_notify_destroy_selinfo(ad); + + ad->popupinfo.selinfo_ly = elm_layout_add(parent); + GL_CHECK_VAL(ad->popupinfo.selinfo_ly, -1); + evas_object_size_hint_weight_set(ad->popupinfo.selinfo_ly, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(ad->popupinfo.selinfo_ly, + EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_layout_theme_set(ad->popupinfo.selinfo_ly, "standard", + "selectioninfo", "center_text"); + + /* Set the content of the notify widget */ + elm_object_part_content_set(parent, "elm.swallow.selinfo", + ad->popupinfo.selinfo_ly); + return 0; +} + +int _gl_notify_create_notiinfo(void *data, const char *text) +{ + GL_CHECK_VAL(text, -1); + int ret = status_message_post(text); + if (ret != 0) + gl_dbgE("status_message_post()... [0x%x]!", ret); + return ret; +} + +/** +* Update selectioinfo widget and view related to it +*/ +static int _gl_notify_update_layout(void *data, Evas_Object *parent, int sel_cnt) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + const char *v_emis = NULL; + int view_mode = gl_get_view_mode(ad); + gl_dbg("view_mode: %d", view_mode); + + if (sel_cnt > 0) { + if (view_mode == GL_VIEW_THUMBS_EDIT) { + v_emis = GL_SIGNAL_VIEW_MOVEUP; + } else if (view_mode == GL_VIEW_THUMBS_SELECT || + view_mode == GL_VIEW_TAGS_EDIT || + view_mode == GL_VIEW_ALBUMS_EDIT) { + v_emis = GL_SIGNAL_VIEW_MOVEUP; + } else { + gl_dbgW("Skip mode!"); + return -1; + } + } else { + /* Restore view while selectioninfo vanished. */ + if (view_mode == GL_VIEW_THUMBS_EDIT || + view_mode == GL_VIEW_THUMBS_SELECT || + view_mode == GL_VIEW_TAGS_EDIT || + view_mode == GL_VIEW_ALBUMS_EDIT) { + v_emis = GL_SIGNAL_VIEW_EDIT; + } else { + gl_dbgW("Skip mode!"); + return -1; + } + } + edje_object_signal_emit(_EDJ(parent), v_emis, "elm"); + return 0; +} + +/** +* Add new notify widget, select-all widget and set view state. +* +* b_update, if true, update text only, other recreate notify widget +*/ +int _gl_notify_create_selinfo(void *data, Evas_Object *parent, + Elm_Object_Item *nf_it, int all_cnt, + int selected_cnt, bool b_update) +{ + GL_CHECK_VAL(parent, -1); + GL_CHECK_VAL(data, -1); + GL_CHECK_VAL(nf_it, -1); + gl_appdata *ad = (gl_appdata *)data; + char text[GL_POPUP_DESC_LEN_MAX] = { 0, }; + int view_mode = gl_get_view_mode(ad); + + gl_dbg("selected_cnt/all_cnt = %d/%d", selected_cnt, all_cnt); + if (selected_cnt > all_cnt) { + _gl_notify_destroy_selinfo(ad); + gl_dbgE("selected_cnt > all_cnt!"); + return -1; + } + + /* Create new notify widget */ + if (b_update == false) + __gl_notify_add(ad, parent); + + /* Update state of checkbox in select-all widget */ + _gl_ui_update_selall(ad, all_cnt, selected_cnt); + + /* Reuse old notify widget in update case */ + GL_CHECK_VAL(ad->popupinfo.selinfo_ly, -1); + + /* Update notify widget and view related to it */ + _gl_notify_update_layout(ad, parent, selected_cnt); + + if (selected_cnt > 0) { + /* Enable/Disable control bar buttons */ + _gl_ctrl_disable_btns(ad, nf_it, false); + /* Add Space */ + snprintf(text, sizeof(text), "%s (%d)", GL_STR_SELECTED, + selected_cnt); + /* Set the text for notify */ + edje_object_part_text_set(_EDJ(ad->popupinfo.selinfo_ly), + "elm.text", text); + + _gl_ui_disable_slideshow(ad, false); + } else if (view_mode == GL_VIEW_THUMBS_SELECT) { + /* Disable control bar buttons */ + _gl_ctrl_disable_btns(ad, nf_it, true); + } else { + /* Disable control bar buttons */ + _gl_ctrl_disable_btns(ad, nf_it, true); + _gl_notify_destroy_selinfo(ad); + _gl_ui_disable_slideshow(ad, true); + } + + return 0; +} + +int _gl_notify_destroy_selinfo(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + if (ad->popupinfo.selinfo_ly) { + evas_object_del(ad->popupinfo.selinfo_ly); + ad->popupinfo.selinfo_ly = NULL; + } + return 0; +} + +int _gl_notify_update_lang(void *data, int cnt, int view_mode) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *view_ly = NULL; + + view_ly = _gl_ui_get_view_layout(data, view_mode); + /*Select all*/ + if (view_ly) + edje_object_part_text_set(_EDJ(view_ly), "selectall_text", + GL_STR_SELECT_ALL); + /*Reset text for select info*/ + if (ad->popupinfo.selinfo_ly) { + char text[GL_POPUP_DESC_LEN_MAX] = {0}; + snprintf(text, sizeof(text), "%s (%d)", GL_STR_SELECTED, cnt); + edje_object_part_text_set(_EDJ(ad->popupinfo.selinfo_ly), + "elm.text", text); + } + + return 0; +} + diff --git a/src/widget/gl-popup.c b/src/widget/gl-popup.c new file mode 100755 index 0000000..a666766 --- /dev/null +++ b/src/widget/gl-popup.c @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gallery.h" +#include "gl-popup.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-debug.h" +#include "gl-tags.h" +#include "gl-tags-new.h" +#include "gl-albums-new.h" +#include "gl-albums-rename.h" +#include "gl-progressbar.h" +#include "gl-strings.h" +#include "gl-button.h" +#include "gl-editfield.h" + +#define GL_POPUP_TIMEOUT_1S 1.0 +#define GL_POPUP_TIMEOUT_2S 2.0 +#define GL_POPUP_TIMEOUT_3S 3.0 + +/* Delete popup contents */ +static int __gl_popup_clear_content(Evas_Object *popup) +{ + GL_CHECK_VAL(popup, -1); + gl_dbg(""); + + Evas_Object *content = elm_object_content_get(popup); + GL_CHECK_VAL(content, -1); + Eina_List *chidren = elm_box_children_get(content); + GL_CHECK_VAL(chidren, -1); + Evas_Object *genlist = eina_list_nth(chidren, 0); + GL_CHECK_VAL(genlist, -1); + elm_genlist_clear(genlist); + elm_box_clear(content); + return 0; +} + +static Eina_Bool __gl_popup_timeout_cb(void *data) +{ + GL_CHECK_FALSE(data); + gl_appdata *ad = (gl_appdata *)data; + if (ad->popupinfo.del_timer) { + ecore_timer_del(ad->popupinfo.del_timer); + ad->popupinfo.del_timer = NULL; + } + + GL_IF_DEL_OBJ(ad->popupinfo.popup); + return ECORE_CALLBACK_CANCEL; +} + +static int __gl_popup_add_timer(void *data, double to_inc) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + if (ad->popupinfo.del_timer) { + ecore_timer_del(ad->popupinfo.del_timer); + ad->popupinfo.del_timer = NULL; + } + + ad->popupinfo.del_timer = ecore_timer_add(to_inc, __gl_popup_timeout_cb, + data); + return 0; +} + +static void __gl_popup_del_resp_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + const char *text = NULL; + + text = elm_object_text_get(obj); + GL_CHECK(text); + gl_dbg("Button: %s, mode: %d", text, ad->popupinfo.popup_mode); + + if (!g_strcmp0(text, GL_STR_DELETE)) { + if (ad->popupinfo.popup_mode == GL_POPUP_ALBUM_DELETE) + gl_del_albums(ad); + } + + GL_IF_DEL_OBJ(ad->popupinfo.popup); +} + +static void _gl_popup_del_tag_resp_cb(void *data, Evas_Object *obj, + void *event_info) +{ + GL_CHECK(obj); + GL_CHECK(data); + gl_tag *gtag = (gl_tag *)data; + GL_CHECK(gtag->ad); + gl_appdata *ad = (gl_appdata *)gtag->ad; + const char *text = NULL; + + text = elm_object_text_get(obj); + GL_CHECK(text); + gl_dbg("Button: %s", text); + + if (!g_strcmp0(text, GL_STR_DELETE)) + _gl_tags_del(data); + + GL_IF_DEL_OBJ(ad->popupinfo.popup); +} + +static void _gl_popup_resp_cb(void *data, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_appdata *ad = (gl_appdata *)data; + int mode = ad->popupinfo.popup_mode; + const char *text = NULL; + + text = elm_object_text_get(obj); + GL_CHECK(text); + gl_dbg("Button: %s, mode: %d", text, mode); + + if (mode == GL_POPUP_ALBUM_NEW_EMPTY || + mode == GL_POPUP_ALBUM_NEW_DUPLICATE || + mode == GL_POPUP_ALBUM_NEW_INVALID) { + if (!g_strcmp0(text, GL_STR_YES) || + !g_strcmp0(text, GL_STR_OK)) { + ad->entryinfo.entry_mode = GL_ENTRY_NEW_ALBUM; + _gl_editfield_show_imf(ad); + } else if (!g_strcmp0(text, GL_STR_NO) || + !g_strcmp0(text, GL_STR_CANCEL)) { + _gl_editfield_hide_imf(ad); + _gl_albums_new_pop_view(ad); + } + } else if (mode == GL_POPUP_ALBUM_RENAME_EMPTY || + mode == GL_POPUP_ALBUM_RENAME_DUPLICATE || + mode == GL_POPUP_ALBUM_RENAME_INVALID) { + if (!g_strcmp0(text, GL_STR_YES) || + !g_strcmp0(text, GL_STR_OK)) { + _gl_editfield_show_imf(ad); + } else if (!g_strcmp0(text, GL_STR_NO) || + !g_strcmp0(text, GL_STR_CANCEL)) { + _gl_editfield_hide_imf(ad); + _gl_albums_rename_pop_view(ad); + } + } else if (mode == GL_POPUP_TAG_NEW_EMPTY) { + if (!g_strcmp0(text, GL_STR_YES) || + !g_strcmp0(text, GL_STR_OK)) { + ad->entryinfo.entry_mode = GL_ENTRY_NEW_TAG; + _gl_editfield_show_imf(ad); + } else if (!g_strcmp0(text, GL_STR_NO) || + !g_strcmp0(text, GL_STR_CANCEL)) { + _gl_editfield_hide_imf(ad); + _gl_tags_new_pop_view(ad); + } + } else if (mode == GL_POPUP_NOBUT_APPEXIT) { + if (ad->popupinfo.popup) { + __gl_popup_clear_content(ad->popupinfo.popup); + evas_object_del(ad->popupinfo.popup); + ad->popupinfo.popup = NULL; + } + elm_exit(); + return; + } + GL_IF_DEL_OBJ(ad->pbarinfo.pbar_popup); + GL_IF_DEL_OBJ(ad->popupinfo.popup); +} + +int gl_popup_create_albums_del_popup(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->popupinfo.popup != NULL) { + gl_dbg("The existed popup is deleted"); + evas_object_del(ad->popupinfo.popup); + } + + Evas_Object *popup = elm_popup_add(ad->maininfo.win); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + Evas_Object *btn1 = NULL; + Evas_Object *btn2 = NULL; + btn1 = _gl_but_create_but_popup(popup, GL_STR_DELETE, + __gl_popup_del_resp_cb, data); + btn2 = _gl_but_create_but_popup(popup, GL_STR_CANCEL, + __gl_popup_del_resp_cb, data); + elm_object_part_content_set(popup, "button1", btn1); + elm_object_part_content_set(popup, "button2", btn2); + + elm_object_text_set(popup, GL_STR_DELETE_COMFIRMATION); + + evas_object_show(popup); + ad->popupinfo.popup = popup; + ad->popupinfo.popup_mode = GL_POPUP_ALBUM_DELETE; + return 0; +} + +int gl_popup_create_tag_del_popup(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_tag *gtag = (gl_tag *)data; + GL_CHECK_VAL(gtag->ad, -1); + gl_appdata *ad = (gl_appdata *)gtag->ad; + gl_dbg(""); + + if (ad->popupinfo.popup) { + gl_dbg("Remove the existed popup."); + evas_object_del(ad->popupinfo.popup); + } + + Evas_Object *popup = NULL; + popup = elm_popup_add(ad->maininfo.win); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + + Evas_Object *btn1 = NULL; + Evas_Object *btn2 = NULL; + btn1 = _gl_but_create_but_popup(popup, GL_STR_DELETE, + _gl_popup_del_tag_resp_cb, data); + btn2 = _gl_but_create_but_popup(popup, GL_STR_CANCEL, + _gl_popup_del_tag_resp_cb, data); + elm_object_part_content_set(popup, "button1", btn1); + elm_object_part_content_set(popup, "button2", btn2); + + elm_object_text_set(popup, GL_STR_DELETE_COMFIRMATION); + + evas_object_show(popup); + ad->popupinfo.popup = popup; + ad->popupinfo.popup_mode = GL_POPUP_TAG_DELETE; + + return 0; +} + +int gl_popup_create_popup(void *data, gl_popup_mode mode, char *desc) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg(""); + + if (ad->popupinfo.popup) { + gl_dbg("The existed popup is deleted"); + evas_object_del(ad->popupinfo.popup); + ad->popupinfo.popup = NULL; + } + + /** + * Pogressbar is showed during moving or deleting medias, + * don't delete it while show popup. + */ + if (mode != GL_POPUP_NOBUT_MOV_DEL) + gl_pb_del_pbar(ad); + + Evas_Object *popup = elm_popup_add(ad->maininfo.win); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_object_text_set(popup, desc); + Evas_Object *btn1 = NULL; + Evas_Object *btn2 = NULL; + + switch (mode) { + case GL_POPUP_NOBUT: + case GL_POPUP_NOBUT_APPEXIT: + __gl_popup_add_timer(ad, GL_POPUP_TIMEOUT_3S); + break; + case GL_POPUP_NOBUT_MOV_DEL: + __gl_popup_add_timer(ad, GL_POPUP_TIMEOUT_1S); + break; + case GL_POPUP_ALBUM_NEW_EMPTY: + case GL_POPUP_ALBUM_NEW_DUPLICATE: + case GL_POPUP_ALBUM_NEW_INVALID: + case GL_POPUP_ALBUM_RENAME_EMPTY: + case GL_POPUP_ALBUM_RENAME_DUPLICATE: + case GL_POPUP_ALBUM_RENAME_INVALID: + case GL_POPUP_TAG_NEW_EMPTY: + btn1 = _gl_but_create_but_popup(popup, GL_STR_YES, + _gl_popup_resp_cb, data); + elm_object_part_content_set(popup, "button1", btn1); + btn2 = _gl_but_create_but_popup(popup, GL_STR_NO, + _gl_popup_resp_cb, data); + elm_object_part_content_set(popup, "button2", btn2); + gl_dbg("Hide Entry cursor and IMF"); + _gl_editfield_hide_imf(ad); + break; + case GL_POPUP_TAG_RENAEM_EMPTY: + case GL_POPUP_TAG_RENAME_DUPLICATE: + __gl_popup_add_timer(ad, GL_POPUP_TIMEOUT_2S); + gl_dbg("Hide Entry cursor and IMF"); + _gl_editfield_hide_imf(ad); + break; + default: + gl_dbgE("Other popup mode..."); + break; + } + + evas_object_show(popup); + + /* Focus popup and IMF hide */ + elm_object_focus_set(popup, EINA_TRUE); + + ad->popupinfo.popup = popup; + ad->popupinfo.popup_mode = mode; + + return 0; +} + diff --git a/src/widget/gl-progressbar.c b/src/widget/gl-progressbar.c new file mode 100755 index 0000000..89fab5e --- /dev/null +++ b/src/widget/gl-progressbar.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gallery.h" +#include "gl-progressbar.h" +#include "gl-ui-util.h" +#include "gl-util.h" +#include "gl-debug.h" +#include "gl-albums.h" +#include "gl-controlbar.h" +#include "gl-thread-util.h" +#include "gl-strings.h" +#include "gl-button.h" + +#define GL_PROGRESSBAR_STYLE_PROGRESS "list_progress" +#define GL_LABEL_STYLE_DEFAULT GL_CHECKBOX_STYLE_DEFAULT + +static void +_gl_pb_cancel_thread_pbar_cb(void *data, Evas_Object * obj, void *event_info) +{ + gl_dbg(""); + //set cancel false value + gl_thread_set_cancel_state(data, GL_PB_CANCEL_BUTTON); + //delete progressbar + gl_pb_del_pbar(data); +} + +int gl_pb_make_thread_pbar(void *data, Evas_Object * parent, char *title) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + Evas_Object *popup = NULL; + Evas_Object *progressbar = NULL; + Evas_Object *box = NULL; + Evas_Object *label = NULL; + + gl_pb_del_pbar(ad); + + popup = elm_popup_add(parent); + elm_object_part_text_set(popup, GL_POPUP_TEXT, title); + + label = elm_label_add(popup); + elm_object_style_set(label, GL_LABEL_STYLE_DEFAULT); + elm_object_text_set(label, GL_STR_EMPTY); + evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_show(label); + + progressbar = elm_progressbar_add(popup); + elm_object_style_set(progressbar, GL_PROGRESSBAR_STYLE_PROGRESS); + elm_progressbar_unit_format_set(progressbar, NULL); + elm_progressbar_value_set(progressbar, 0.0); + evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_show(progressbar); + + box = elm_box_add(popup); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_box_horizontal_set(box, EINA_FALSE); + elm_box_homogeneous_set(box, EINA_TRUE); + elm_box_pack_end(box, progressbar); + elm_box_pack_end(box, label); + evas_object_show(box); + + elm_object_content_set(popup, box); + Evas_Object *btn1 = NULL; + btn1 = _gl_but_create_but_popup(popup, GL_STR_CANCEL, + _gl_pb_cancel_thread_pbar_cb, data); + elm_object_part_content_set(popup, "button1", btn1); + + evas_object_show(popup); + + ad->pbarinfo.pbar_popup = popup; + ad->pbarinfo.pbar = progressbar; + ad->pbarinfo.status_label = label; + ad->pbarinfo.finished_cnt = 0; + + return 0; +} + +int +gl_pb_refresh_thread_pbar(void *data, int cur_cnt, int total_cnt) +{ + GL_CHECK_VAL(data, -1); + char status_info[GL_POPUP_DESC_LEN_MAX] = { 0, }; + double percent = 0.0; + gl_appdata *ad = (gl_appdata *)data; + GL_CHECK_VAL(ad->pbarinfo.pbar, -1); + GL_CHECK_VAL(ad->pbarinfo.status_label, -1); + + snprintf(status_info, sizeof(status_info), + GL_FONT_STYLE_POP_S"%d/%d"GL_FONT_STYLE_POP_E, cur_cnt, + total_cnt); + /* Save medias count already operated */ + ad->pbarinfo.finished_cnt = cur_cnt; + elm_object_text_set(ad->pbarinfo.status_label, status_info); + evas_object_show(ad->pbarinfo.status_label); + + percent = (double)cur_cnt / (double)total_cnt; + elm_progressbar_value_set(ad->pbarinfo.pbar, percent); + + return 0; +} + +int +gl_pb_del_pbar(void *data) +{ + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + gl_dbg("destroy progressbar"); + + if (ad->pbarinfo.pbar_popup) + { + evas_object_del(ad->pbarinfo.pbar_popup); + ad->pbarinfo.pbar_popup = NULL; + ad->pbarinfo.pbar = NULL; + ad->pbarinfo.status_label = NULL; + ad->pbarinfo.finished_cnt = 0; + } + + return 0; +} + diff --git a/src/widget/gl-rotate-bg.c b/src/widget/gl-rotate-bg.c new file mode 100755 index 0000000..ff10743 --- /dev/null +++ b/src/widget/gl-rotate-bg.c @@ -0,0 +1,394 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef _USE_ROTATE_BG + +#include "gl-rotate-bg.h" +#include "gl-exif.h" +#include "gl-debug.h" +#include "gl-icons.h" + +#define GL_ROTATE_BG_DATA_KEY "gl_bg_data" +#define GL_ROTATE_BG_GROUP "gl_bg_layout" + +typedef struct _gl_bg { + Evas_Object *base; + Evas_Object *img; + char *file; +} gl_bg; + +static int __gl_rotate_bg_image_rotate_180(Evas_Object *obj) +{ + GL_CHECK_VAL(obj, -1); + unsigned int *data = NULL; + unsigned int *data2 = NULL; + unsigned int *to = NULL; + unsigned int *from = NULL; + int x = 0; + int hw = 0; + int iw = 0; + int ih = 0; + + evas_object_image_size_get(obj, &iw, &ih); + int size = iw * ih * sizeof(unsigned int); + + /* EINA_FALSE for reading */ + data = evas_object_image_data_get(obj, EINA_FALSE); + /* memcpy */ + data2 = calloc(1, size); + GL_CHECK_VAL(data2, -1); + memcpy(data2, data, size); + + data = evas_object_image_data_get(obj, EINA_TRUE); + + hw = iw * ih; + x = hw; + to = data; + from = data2 + hw - 1; + for (; --x >= 0;) { + *to = *from; + to++; + from--; + } + +#if 0 /* Failed to rotate icon created from original file */ + hw = iw * ih; + x = (hw / 2); + p1 = data; + p2 = data + hw - 1; + for (; --x > 0;) { + tmp = *p1; + *p1 = *p2; + *p2 = tmp; + p1++; + p2--; + } +#endif + + GL_FREE(data2); + + evas_object_image_data_set(obj, data); + evas_object_image_data_update_add(obj, 0, 0, iw, ih); + return 0; +} + +static int __gl_rotate_bg_image_rotate_90(Evas_Object *obj) +{ + GL_CHECK_VAL(obj, -1); + unsigned int *data = NULL; + unsigned int *data2 = NULL; + unsigned int *to = NULL; + unsigned int *from = NULL; + int x = 0; + int y = 0; + int w = 0; + int hw = 0; + int iw = 0; + int ih = 0; + + evas_object_image_size_get(obj, &iw, &ih); + int size = iw * ih * sizeof(unsigned int); + + /* EINA_FALSE for reading */ + data = evas_object_image_data_get(obj, EINA_FALSE); + /* memcpy */ + data2 = calloc(1, size); + GL_CHECK_VAL(data2, -1); + memcpy(data2, data, size); + + /* set width, height */ + w = ih; + ih = iw; + iw = w; + hw = w * ih; + + /* set width, height to image obj */ + evas_object_image_size_set(obj, iw, ih); + data = evas_object_image_data_get(obj, EINA_TRUE); + to = data + w - 1; + hw = -hw - 1; + from = data2; + + for (x = iw; --x >= 0;) { + for (y = ih; --y >= 0;) { + *to = *from; + from++; + to += w; + } + + to += hw; + } + + GL_FREE(data2); + + evas_object_image_data_set(obj, data); + evas_object_image_data_update_add(obj, 0, 0, iw, ih); + return 0; +} + +static int __gl_rotate_bg_image_rotate_270(Evas_Object *obj) +{ + GL_CHECK_VAL(obj, -1); + unsigned int *data = NULL; + unsigned int *data2 = NULL; + unsigned int *to = NULL; + unsigned int *from = NULL; + int x = 0; + int y = 0; + int w = 0; + int hw = 0; + int iw = 0; + int ih = 0; + + evas_object_image_size_get(obj, &iw, &ih); + int size = iw * ih * sizeof(unsigned int); + + /* EINA_FALSE for reading */ + data = evas_object_image_data_get(obj, EINA_FALSE); + /* memcpy */ + data2 = calloc(1, size); + GL_CHECK_VAL(data2, -1); + memcpy(data2, data, size); + + /* set width, height */ + w = ih; + ih = iw; + iw = w; + hw = w * ih; + + /* set width, height to image obj */ + evas_object_image_size_set(obj, iw, ih); + data = evas_object_image_data_get(obj, EINA_TRUE); + + to = data + hw - w; + w = -w; + hw = hw + 1; + from = data2; + + for (x = iw; --x >= 0;) { + for (y = ih; --y >= 0;) { + *to = *from; + from++; + to += w; + } + + to += hw; + } + + GL_FREE(data2); + + evas_object_image_data_set(obj, data); + evas_object_image_data_update_add(obj, 0, 0, iw, ih); + return 0; +} + +/* check its orientation */ +int __gl_rotate_bg_rotate_image(Evas_Object *obj, unsigned int orient) +{ + switch (orient){ + case GL_ORIENTATION_ROT_90: + __gl_rotate_bg_image_rotate_90(obj); + break; + case GL_ORIENTATION_ROT_180: + __gl_rotate_bg_image_rotate_180(obj); + break; + case GL_ORIENTATION_ROT_270: + __gl_rotate_bg_image_rotate_270(obj); + break; + default: + break; + } + + return 0; +} + +static void __gl_rotate_bg_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + if (data) { + gl_bg *bg_data = (gl_bg *)data; + GL_FREEIF(bg_data->file); + GL_FREE(data); + } +} + +static void __gl_rotate_bg_custom_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + GL_CHECK(data); + gl_bg *bg_data = (gl_bg *)data; + Evas_Coord bx = 0; + Evas_Coord by = 0; + Evas_Coord bw = 0; + Evas_Coord bh = 0; + Evas_Coord iw = 0; + Evas_Coord ih = 0; + Evas_Coord fx = 0; + Evas_Coord fy = 0; + Evas_Coord fw = 0; + Evas_Coord fh = 0; + Evas_Coord nx = 0; + Evas_Coord ny = 0; + Evas_Coord nw = 0; + Evas_Coord nh = 0; + + if ((!bg_data->img) || (!bg_data->base)) { + gl_dbgE("Invalid object!"); + return; + } + /* grab image size */ + evas_object_image_size_get(bg_data->img, &iw, &ih); + if ((iw < 1) || (ih < 1)) { + gl_dbgE("(iw < 1) || (ih < 1)!"); + return; + } + + /* grab base object dimensions */ + evas_object_geometry_get(bg_data->base, &bx, &by, &bw, &bh); + + /* set some defaults */ + nx = bx; + ny = by; + nw = bw; + nh = bh; + + + fw = bw; + fh = ((ih * fw) / iw); + if (fh < bh) { + fh = bh; + fw = ((iw * fh) / ih); + } + fx = ((bw - fw) / 2); + fy = ((bh - fh) / 2); + + evas_object_move(bg_data->img, nx, ny); + evas_object_resize(bg_data->img, nw, nh); + evas_object_image_fill_set(bg_data->img, fx, fy, fw, fh); +} + +Evas_Object *_gl_rotate_bg_add_layout(Evas_Object *parent, const char *file, const char *group) +{ + Evas_Object *eo = NULL; + int r = 0; + + eo = elm_layout_add(parent); + if (eo) { + r = elm_layout_file_set(eo, file, group); + if (!r) { + evas_object_del(eo); + return NULL; + } + + evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL); + } + + return eo; +} + +Evas_Object *_gl_rotate_bg_add(Evas_Object *parent) +{ + GL_CHECK_NULL(parent); + + gl_bg *bg_data = (gl_bg *)calloc(1, sizeof(gl_bg)); + GL_CHECK_NULL(bg_data); + + Evas_Object *base = NULL; + base = _gl_rotate_bg_add_layout(parent, GL_EDJ_FILE, + GL_ROTATE_BG_GROUP); + if (base == NULL) { + GL_FREE(bg_data); + return NULL; + } + + bg_data->base= base; + evas_object_event_callback_add(base, EVAS_CALLBACK_RESIZE, + __gl_rotate_bg_custom_resize, bg_data); + evas_object_event_callback_add(base, EVAS_CALLBACK_DEL, + __gl_rotate_bg_delete_cb, bg_data); + + evas_object_data_set(base, GL_ROTATE_BG_DATA_KEY, bg_data); + return base; +} + +int _gl_rotate_bg_set_file(Evas_Object *bg, const char *file, int w, int h) +{ + GL_CHECK_VAL(file, -1); + GL_CHECK_VAL(bg, -1); + + gl_bg *bg_data = evas_object_data_get(bg, GL_ROTATE_BG_DATA_KEY); + GL_CHECK_VAL(bg_data, -1); + + Evas_Object *image_obj = NULL; + image_obj = evas_object_image_add(evas_object_evas_get(bg)); + evas_object_repeat_events_set(image_obj, EINA_TRUE); + bg_data->img = image_obj; + bg_data->file = strdup(file); + elm_object_part_content_set(bg, "elm.swallow.image", image_obj); + evas_object_image_load_size_set(image_obj, w, h); + evas_object_image_file_set(image_obj, file, NULL); + evas_object_image_preload(image_obj, EINA_FALSE); + return 0; +} + +int _gl_rotate_bg_rotate_image(Evas_Object *bg, unsigned int orient) +{ + GL_CHECK_VAL(bg, -1); + + gl_bg *bg_data = evas_object_data_get(bg, GL_ROTATE_BG_DATA_KEY); + GL_CHECK_VAL(bg_data, -1); + + if (bg_data->file && g_strcmp0(bg_data->file, GL_DEFAULT_THUMB_ICON)) + __gl_rotate_bg_rotate_image(bg_data->img, orient); + else + __gl_rotate_bg_rotate_image(bg_data->img, GL_ORIENTATION_ROT_0); + __gl_rotate_bg_custom_resize(bg_data, NULL, NULL, NULL); + return 0; +} + +int _gl_rotate_bg_add_image(Evas_Object *bg, int w, int h) +{ + GL_CHECK_VAL(bg, -1); + + gl_bg *bg_data = evas_object_data_get(bg, GL_ROTATE_BG_DATA_KEY); + GL_CHECK_VAL(bg_data, -1); + + Evas_Object *image_obj = NULL; + image_obj = evas_object_image_add(evas_object_evas_get(bg)); + evas_object_image_size_set(image_obj, w, h); + evas_object_image_fill_set(image_obj, 0, 0, w, h); + evas_object_repeat_events_set(image_obj, EINA_TRUE); + bg_data->img = image_obj; + elm_object_part_content_set(bg, "elm.swallow.image", image_obj); + evas_object_image_load_size_set(image_obj, w, h); + return 0; +} + +int _gl_rotate_bg_set_image_file(Evas_Object *bg, const char *file) +{ + GL_CHECK_VAL(bg, -1); + + gl_bg *bg_data = evas_object_data_get(bg, GL_ROTATE_BG_DATA_KEY); + GL_CHECK_VAL(bg_data, -1); + GL_CHECK_VAL(bg_data->img, -1); + + evas_object_image_file_set(bg_data->img, file, NULL); + evas_object_image_preload(bg_data->img, EINA_FALSE); + + __gl_rotate_bg_custom_resize(bg_data, NULL, NULL, NULL); + return 0; +} + +#endif diff --git a/src/widget/gl-thumb.c b/src/widget/gl-thumb.c new file mode 100755 index 0000000..fd29e0a --- /dev/null +++ b/src/widget/gl-thumb.c @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-util.h" +#include "gl-drm.h" +#include "gl-strings.h" +#include "gl-icons.h" +#ifdef _USE_ROTATE_BG +#include "gl-rotate-bg.h" +#include "gl-exif.h" +#endif + +#define GL_GRID_ICON_SIZE 175 + +#define GL_PHOTOFRAME_STYLE_VIDEO_FAVOR_BOOKMARK "default_layout_video_favor_bookmark" +#define GL_PHOTOFRAME_STYLE_VIDEO_BOOKMARK "default_layout_video_bookmark" +#define GL_PHOTOFRAME_STYLE_VIDEO_FAVOR "default_layout_video_favor" +#define GL_PHOTOFRAME_STYLE_VIDEO "default_layout_video" +#define GL_PHOTOFRAME_STYLE_FAVOR "default_layout_favor" +#define GL_PHOTOFRAME_STYLE_DEFAULT "default_layout" + +Evas_Object *_gl_thumb_show_part_icon_image(Evas_Object *obj, char *path, + unsigned int orient, bool b_favor, + bool is_expired_drm, int item_size) +{ + GL_CHECK_NULL(obj); + + Evas_Object *layout = elm_layout_add(obj); + GL_CHECK_NULL(layout); + +#ifdef _USE_ROTATE_BG + Evas_Object *bg = _gl_rotate_bg_add(layout); +#else + Evas_Object *bg = elm_bg_add(layout); +#endif + if (bg == NULL) { + evas_object_del(layout); + return NULL; + } + +#ifdef _USE_ROTATE_BG + _gl_rotate_bg_set_file(bg, path, item_size, item_size); + _gl_rotate_bg_rotate_image(bg, orient); +#else + elm_bg_file_set(bg, path, NULL); + elm_bg_load_size_set(bg, item_size, item_size); + evas_object_size_hint_max_set(bg, item_size, item_size); + evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); +#endif + + // TODO: Need to check the expired drm icon file... + /* Expired drm icon */ + if (is_expired_drm) { + elm_layout_theme_set(layout, GL_CLASS_GENGRID, GL_GRP_PHOTOFRAME, + GL_PHOTOFRAME_STYLE_FAVOR); + elm_object_part_content_set(layout, "elm.swallow.icon", bg); + + Evas_Object *icon = elm_icon_add(layout); + GL_ICON_SET_FILE(icon, GL_LOCK_ICON); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.favoricon", + icon); + } else if (b_favor) { + /* Set favourites icon */ + elm_layout_theme_set(layout, GL_CLASS_GENGRID, GL_GRP_PHOTOFRAME, + GL_PHOTOFRAME_STYLE_FAVOR); + elm_object_part_content_set(layout, "elm.swallow.icon", bg); + + Evas_Object *icon = elm_icon_add(layout); + GL_ICON_SET_FILE(icon, GL_THUMB_FAVOR_ICON); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.favoricon", + icon); + } else { + elm_layout_theme_set(layout, GL_CLASS_GENGRID, GL_GRP_PHOTOFRAME, + GL_PHOTOFRAME_STYLE_DEFAULT); + elm_object_part_content_set(layout, "elm.swallow.icon", bg); + } + + evas_object_show(layout); + return layout; +} + +Evas_Object *_gl_thumb_show_part_icon_video(Evas_Object *obj, char *path, + unsigned int v_dur, int bk_len, + bool b_favor, bool is_expired_drm, + int item_size) +{ + GL_CHECK_NULL(obj); + + Evas_Object *layout = elm_layout_add(obj); + GL_CHECK_NULL(layout); + +#ifdef _USE_ROTATE_BG + Evas_Object *bg = _gl_rotate_bg_add(layout); +#else + Evas_Object *bg = elm_bg_add(layout); +#endif + if (bg == NULL) { + evas_object_del(layout); + return NULL; + } + +#ifdef _USE_ROTATE_BG + _gl_rotate_bg_set_file(bg, path, item_size, item_size); + _gl_rotate_bg_rotate_image(bg, GL_ORIENTATION_ROT_0); +#else + elm_bg_file_set(bg, path, NULL); + elm_bg_load_size_set(bg, item_size, item_size); + evas_object_size_hint_max_set(bg, item_size, item_size); + evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); +#endif + + if (bk_len && b_favor) + elm_layout_theme_set(layout, GL_CLASS_GENGRID, GL_GRP_PHOTOFRAME, + GL_PHOTOFRAME_STYLE_VIDEO_FAVOR_BOOKMARK); + else if (bk_len) + elm_layout_theme_set(layout, GL_CLASS_GENGRID, GL_GRP_PHOTOFRAME, + GL_PHOTOFRAME_STYLE_VIDEO_BOOKMARK); + else if (is_expired_drm || b_favor) + elm_layout_theme_set(layout, GL_CLASS_GENGRID, GL_GRP_PHOTOFRAME, + GL_PHOTOFRAME_STYLE_VIDEO_FAVOR); + else + elm_layout_theme_set(layout, GL_CLASS_GENGRID, GL_GRP_PHOTOFRAME, + GL_PHOTOFRAME_STYLE_VIDEO); + elm_object_part_content_set(layout, "elm.swallow.icon", bg); + + // TODO: Need to check the expired drm icon file... + /* Expired drm icon */ + if (is_expired_drm) { + Evas_Object *icon = elm_icon_add(layout); + GL_ICON_SET_FILE(icon, GL_LOCK_ICON); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.favoricon", + icon); + /* Set favourites icon */ + } else if (b_favor) { + Evas_Object *icon = elm_icon_add(layout); + GL_ICON_SET_FILE(icon, GL_THUMB_FAVOR_ICON); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.favoricon", + icon); + } + + if (bk_len) { + Evas_Object *icon = elm_icon_add(layout); + GL_ICON_SET_FILE(icon, GL_THUMB_BOOKMARK); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.bookmarkicon", + icon); + } + + char *dur_str = _gl_get_duration_string(v_dur); + GL_CHECK_NULL(dur_str); + elm_object_part_text_set(layout, GL_GRID_TEXT, dur_str); + GL_FREE(dur_str); + + evas_object_show(layout); + return layout; +} + +Evas_Object *_gl_thumb_show_part_checkbox(Evas_Object *obj, bool checked, + Evas_Smart_Cb func, const void *data) +{ + GL_CHECK_NULL(func); + GL_CHECK_NULL(obj); + Evas_Object *ck = NULL; + + ck = elm_check_add(obj); + GL_CHECK_NULL(ck); + elm_object_style_set(ck, GL_CHECKBOX_STYLE_GRID); + evas_object_propagate_events_set(ck, EINA_FALSE); + + elm_check_state_set(ck, checked); + + evas_object_smart_callback_add(ck, "changed", func, data); + + evas_object_show(ck); + return ck; +} + +Evas_Object *_gl_thumb_add_gengrid(Evas_Object *parent) +{ + GL_CHECK_NULL(parent); + Evas_Object *grid = elm_gengrid_add(parent); + GL_CHECK_NULL(grid); + elm_gengrid_align_set(grid, 0.5, 0.0); + elm_gengrid_horizontal_set(grid, EINA_FALSE); + elm_scroller_bounce_set(grid, EINA_FALSE, EINA_TRUE); + elm_gengrid_multi_select_set(grid, EINA_TRUE); + + evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + + return grid; +} + +/* Update all gengrid item, class callback would be called again */ +int _gl_thumb_update_gengrid(Evas_Object *view) +{ + GL_CHECK_VAL(view, -1); + + Elm_Object_Item *_first_it = NULL; + _first_it = elm_gengrid_first_item_get(view); + while(_first_it) { + elm_gengrid_item_update(_first_it); + _first_it = elm_gengrid_item_next_get(_first_it); + } + + return 0; +} + +int _gl_thumb_set_size(void *data, Evas_Object *view, int count, int *size) +{ + GL_CHECK_VAL(view, -1); + GL_CHECK_VAL(data, -1); + gl_appdata *ad = (gl_appdata *)data; + int _size = (int)(GL_GRID_ICON_SIZE * ad->maininfo.win_scale); + int _w = (int)(GL_GRID_ITEM_SIZE_W * ad->maininfo.win_scale); + int _h = (int)(GL_GRID_ITEM_SIZE_H * ad->maininfo.win_scale); + + if (count <= GL_GRID_ITEM_ZOOM_LEVEL_02_CNT) { + _size *= GL_GRID_ITEM_ZOOM_LEVEL_02; + _w *= GL_GRID_ITEM_ZOOM_LEVEL_02; + _h *= GL_GRID_ITEM_ZOOM_LEVEL_02; + } + + elm_gengrid_item_size_set(view, _w, _h); + gl_dbg("Thumb width: %d, height: %d, size: %d", _w, _h, _size); + if (size) + *size = _size; + return 0; +} + diff --git a/src/widget/gl-tile.c b/src/widget/gl-tile.c new file mode 100755 index 0000000..d652b75 --- /dev/null +++ b/src/widget/gl-tile.c @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gl-debug.h" +#include "gl-tile.h" +#include "gl-util.h" +#include "gl-button.h" +#include "gallery.h" +#include "gl-icons.h" +#ifdef _USE_ROTATE_BG +#include "gl-rotate-bg.h" +#endif + +/* Album color level and alpha value */ +#define GL_TILE_TEXT_COLOR_CNT 6 +#define GL_TILE_TEXT_COLOR_ALPHA 255 +/* Width and height of album item (208+28, 210+15) */ +#define GL_TILE_ITEM_WIDTH 358 +#define GL_TILE_ITEM_HEIGHT 360 + +#define GL_CHECKBOX_STYLE_ALBUM "gallery/album" +#define GL_CHECKBOX_STYLE_ALBUM_GRID "gallery/album/grid" +#define GL_GENGRID_STYLE_ALBUM "unclipped" + +typedef struct _gl_tile_color { + int r; + int g; + int b; +} gl_tile_color; + +static gl_tile_color bg_color[] = { + {50, 50, 50}, + {78, 74, 64}, + {49, 125, 174}, + {165, 53, 53}, + {71, 128, 11}, + {56, 78, 116}, + {25, 25, 25}, +}; + +Evas_Object *__gl_tile_add_1_icon_bg(Evas_Object *obj, int len, double scale, + bg_file_set_cb func, void **data) +{ + GL_CHECK_NULL(obj); + GL_CHECK_NULL(func); + Evas_Object *bg = NULL; + +#ifdef _USE_ROTATE_BG + bg = _gl_rotate_bg_add(obj); +#else + bg = elm_bg_add(obj); +#endif + GL_CHECK_NULL(bg); + + int wid = 0; + int hei = 0; + + wid = (int)(GL_TILER_ICON_S * scale); + if (len == 1) + hei = wid; + else + hei = (int)(GL_TILE_2X_GRID_S * scale); + +#ifdef _USE_ROTATE_BG + _gl_rotate_bg_add_image(bg, wid, hei); +#else + elm_bg_load_size_set(bg, wid, hei); +#endif + + func(bg, data[0]); + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, 0.5, 0.5); + evas_object_show(bg); + + return bg; +} + +Evas_Object *_gl_tile_show_part_icon(Evas_Object *obj, const char *part, + int length, double scale, + bg_file_set_cb func, void **data) +{ + GL_CHECK_NULL(part); + GL_CHECK_NULL(strlen(part)); + GL_CHECK_NULL(obj); + + if (!g_strcmp0(part, GT_TILE_ONLYICON)) { + Evas_Object *bg = NULL; + bg = __gl_tile_add_1_icon_bg(obj, GL_TILE_THUMB_1, scale, func, + data); + return bg; + } + return NULL; +} + +Evas_Object *_gl_tile_show_part_label(Evas_Object *obj, int index, + bool b_default) +{ + GL_CHECK_NULL(obj); + + Evas *evas = evas_object_evas_get(obj); + GL_CHECK_NULL(evas); + Evas_Object *bg = NULL; + bg = evas_object_rectangle_add(evas); + GL_CHECK_NULL(bg); + + int j = 0; + if (b_default) + j = GL_TILE_TEXT_COLOR_CNT; + else + j = index % GL_TILE_TEXT_COLOR_CNT; + evas_object_color_set(bg, bg_color[j].r, bg_color[j].g, bg_color[j].b, + GL_TILE_TEXT_COLOR_ALPHA); + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(bg); + return bg; +} + +Evas_Object *_gl_tile_show_part_checkbox_grid(Evas_Object *obj, bool checked, + Evas_Smart_Cb func, + const void *data) +{ + GL_CHECK_NULL(func); + GL_CHECK_NULL(obj); + Evas_Object *ck = NULL; + + ck = elm_check_add(obj); + GL_CHECK_NULL(ck); + elm_object_style_set(ck, GL_CHECKBOX_STYLE_ALBUM_GRID); + evas_object_repeat_events_set(ck, EINA_TRUE); + elm_check_state_set(ck, checked); + evas_object_smart_callback_add(ck, "changed", func, data); + evas_object_show(ck); + return ck; +} + +Evas_Object *_gl_tile_show_part_checkbox(Evas_Object *obj, bool checked, + Evas_Smart_Cb func, const void *data) +{ + GL_CHECK_NULL(func); + GL_CHECK_NULL(obj); + Evas_Object *ck = NULL; + + ck = elm_check_add(obj); + GL_CHECK_NULL(ck); + elm_object_style_set(ck, GL_CHECKBOX_STYLE_ALBUM); + evas_object_propagate_events_set(ck, EINA_FALSE); + elm_check_state_set(ck, checked); + evas_object_smart_callback_add(ck, "changed", func, data); + evas_object_show(ck); + return ck; +} + +Evas_Object *_gl_tile_show_part_rename(Evas_Object *obj, Evas_Smart_Cb func, + const void *data) +{ + GL_CHECK_NULL(func); + GL_CHECK_NULL(obj); + Evas_Object *btn = NULL; + btn = _gl_but_create_but(obj, NULL, NULL, GL_BUTTON_STYLE_RENAME, func, + data); + GL_CHECK_NULL(btn); + evas_object_propagate_events_set(btn, EINA_FALSE); + return btn; +} + +int _gl_tile_get_mtime(time_t *mtime1, time_t *mtime2, char *buf, int max_len) +{ + char *date1 = (char *)calloc(1, GL_DATE_INFO_LEN_MAX); + GL_CHECK_VAL(date1, -1); + char *date2 = (char *)calloc(1, GL_DATE_INFO_LEN_MAX); + if (date2 == NULL) + goto GL_TILE_ERROR; + char *date3 = (char *)calloc(1, GL_DATE_INFO_LEN_MAX); + if (date3 == NULL) + goto GL_TILE_ERROR; + + struct tm t1; + memset(&t1, 0x00, sizeof(struct tm)); + localtime_r(mtime1, &t1); + strftime(date1, GL_DATE_INFO_LEN_MAX, "%Y.%m.%d", &t1); + strftime(date3, GL_DATE_INFO_LEN_MAX, "%Y.%m", &t1); + + struct tm t2; + memset(&t2, 0x00, sizeof(struct tm)); + localtime_r(mtime2, &t2); + strftime(date2, GL_DATE_INFO_LEN_MAX, "%Y.%m.%d", &t2); + + if (!g_strcmp0(date1, date2)) { + g_strlcpy(buf, date1, max_len); + } else { + strftime(date2, GL_DATE_INFO_LEN_MAX, "%Y.%m", &t2); + snprintf(buf, max_len, "%s - %s", date2, date3); + } + + GL_FREEIF(date1); + GL_FREEIF(date2); + GL_FREEIF(date3); + return 0; + + GL_TILE_ERROR: + + GL_FREEIF(date1); + GL_FREEIF(date2); + GL_FREEIF(date3); + return -1; +} + +Evas_Object *_gl_tile_add_gengrid(void *data, Evas_Object *parent) +{ + GL_CHECK_NULL(parent); + GL_CHECK_NULL(data); + gl_appdata *ad = (gl_appdata *)data; + + Evas_Object *grid = elm_gengrid_add(parent); + elm_object_style_set(grid, GL_GENGRID_STYLE_ALBUM); + + double scale_factor = ad->maininfo.win_scale; + gl_dbg("Own scale: %f, elm_config_scale_get =%f", scale_factor, + elm_config_scale_get()); + elm_gengrid_item_size_set(grid, (int)(GL_TILE_ITEM_WIDTH * scale_factor), + (int)(GL_TILE_ITEM_HEIGHT * scale_factor)); + elm_gengrid_align_set(grid, 0.5, 0.0); + + /* Vertical scrolling. */ + elm_gengrid_horizontal_set(grid, EINA_FALSE); + elm_scroller_bounce_set(grid, EINA_FALSE, EINA_TRUE); + + elm_gengrid_multi_select_set(grid, EINA_TRUE); + + evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + return grid; +} + diff --git a/ug-gallery-efl.manifest b/ug-gallery-efl.manifest new file mode 100755 index 0000000..97e8c31 --- /dev/null +++ b/ug-gallery-efl.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/ug/ug-gallery-efl/CMakeLists.txt b/ug/ug-gallery-efl/CMakeLists.txt new file mode 100755 index 0000000..2bb4ccd --- /dev/null +++ b/ug/ug-gallery-efl/CMakeLists.txt @@ -0,0 +1,102 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ug-gallery-efl C) + +SET(SRCS src/gallery-efl.c + src/ge-albums.c + src/ge-gridview.c + src/ge-button.c + src/ge-debug.c + src/ge-ui-util.c + src/ge-ext-ug-load.c + src/ge-util.c + src/ge-drm.c + src/ge-data-type.c + src/ge-local-data.c + src/ge-data.c + src/ge-exif.c + src/ge-rotate-bg.c + src/ge-thumb.c + src/ge-tile.c + src/ge-lang.c +) + +SET(GE_EDC_DIR edc) +SET(GE_IMG_DIR edc/images) + +IF("${CMAKE_BUILD_TYPE}" STREQUAL "") + SET(CMAKE_BUILD_TYPE "Release") +ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") +MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "\${prefix}") +SET(LIBDIR "\${prefix}/lib") +SET(INCLUDEDIR "\${prefix}/include") +SET(VERSION 1.0) + +ADD_DEFINITIONS("-D_USE_DLOG_") +ADD_DEFINITIONS("-D_USE_ROTATE_BG_GE") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED + elementary + ecore-imf + ecore-x + eina + evas + edje + vconf + ecore + ecore-file + ecore-input + dlog + glib-2.0 + capi-appfw-application + capi-content-media-content + ui-gadget-1 + drm-client +) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fpie") +SET(CMAKE_C_FLAGS_RELEASE "-O2 -fpie") +SET(CMAKE_LDFLAGS "-Wl,-zdefs" ) + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0.0.1) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lstdc++ ) + +# EDJE +ADD_CUSTOM_COMMAND(OUTPUT gallery-efl.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/res/${GE_IMG_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/res/${GE_EDC_DIR}/gallery-efl.edc + ${CMAKE_BINARY_DIR}/gallery-efl.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/res/${GE_EDC_DIR}/gallery-efl.edc +) + +ADD_CUSTOM_TARGET(gallery_efl_edj_build DEPENDS gallery-efl.edj) +ADD_DEPENDENCIES(${PROJECT_NAME} gallery_efl_edj_build) + +INSTALL(FILES ${CMAKE_BINARY_DIR}/gallery-efl.edj DESTINATION /usr/ug/res/edje/gallery-efl) + +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/images DESTINATION /usr/ug/res/images/gallery-efl) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/ug/lib) + +INSTALL(FILES ${PROJECT_NAME}.xml DESTINATION /usr/share/packages) + diff --git a/ug/ug-gallery-efl/include/gallery-efl.h b/ug/ug-gallery-efl/include/gallery-efl.h new file mode 100755 index 0000000..d3356a4 --- /dev/null +++ b/ug/ug-gallery-efl/include/gallery-efl.h @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __GALLERY_EFL_H__ +#define __GALLERY_EFL_H__ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ge-data-type.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define GE_UG_RES_DIR "/usr/ug/res/" +#define GE_IMAGES_DIR GE_UG_RES_DIR"images/gallery-efl/images/" +#define GE_EDJ_DIR GE_UG_RES_DIR"edje/gallery-efl/" +#define GE_EDJ_FILE GE_EDJ_DIR"gallery-efl.edj" + +#define GE_GRP_GRIDVIEW "gallery_efl/gridview" +#define GE_GRP_ALBUMVIEW "gallery_efl/albumview" + +#define GE_CHECKBOX_STYLE_GRID "gallery_efl/grid" + +#define GE_ROOT_PATH_PHONE "/opt/usr/media" +#define GE_ROOT_PATH_MMC "/opt/storage/sdcard" + +#define GE_ALBUM_ALL_ID "GALLERY_ALBUM_ALL_ALBUMS_ID" +/* String length of mtye item id */ +#define GE_MTYPE_ITEN_ID_LEN_MAX 37 + +#define GE_GRID_ITEM_SIZE_W 178 +#define GE_GRID_ITEM_SIZE_H 182 + +#define GE_GRID_ITEM_ZOOM_LEVEL_02 2 +#define GE_GRID_ITEM_ZOOM_LEVEL_02_CNT 6 + +#define GE_ALBUM_COVER_THUMB_NUM 1 +#define GE_ALBUM_COVER_THUMB_NUM_SEC 4 /* Other albums cover have maximum 4 thumbnails */ +#define GE_ALBUM_ITEM_WIDTH 358 +#define GE_ALBUM_ITEM_HEIGHT 360 + +#define GE_SELINFO_TEXT_LEN_MAX 64 +#define GE_ALBUM_DATE_LEN_MAX 256 +#define GE_MAX_BYTES_FOR_CHAR 3 +#define GE_ALBUM_NAME_LEN_MAX (255 * GE_MAX_BYTES_FOR_CHAR + 1) +#define GE_NOCONTENTS_LABEL_LEN_MAX 512 +#define GE_FILE_PATH_LEN_MAX (4095 * GE_MAX_BYTES_FOR_CHAR + 1) + +#define GE_FIRST_VIEW_START_POS 0 +#define GE_FIRST_VIEW_END_POS 47 +#define GE_GET_UNTIL_LAST_RECORD 65536 /* Fixme: Do not use 65536. */ +#define GE_GET_ALL_RECORDS -1 + +#define GE_BUNDLE_LAUNCH_TYPE "launch-type" +#define GE_BUNDLE_FILE_TYPE "file-type" +#define GE_BUNDLE_DRM_TYPE "drm-type" +#define GE_BUNDLE_SETAS_TYPE "setas-type" +#define GE_BUNDLE_CALLERID_SIZE "callerid-size" +#define GE_BUNDLE_CALLERID_PATH "callerid-path" +#define GE_BUNDLE_HOMESCREEN_PATH "homescreen-path" +#define GE_BUNDLE_LOCKSCREEN_PATH "lockscreen-path" +#define GE_LAUNCH_SELECT_ALBUM "select-album" +#define GE_ALBUM_SELECT_RETURN_PATH "folder-path" +#define GE_LAUNCH_SELECT_ONE "select-one" +#define GE_LAUNCH_SELECT_MULTIPLE "select-multiple" +#define GE_LAUNCH_SELECT_SETAS "select-setas" + +#define GE_FILE_TYPE_IMAGE "image" +#define GE_FILE_TYPE_VIDEO "video" +#define GE_FILE_TYPE_ALL "all" +#define GE_FILE_TYPE_DRM_TRUE "true" + +#define GE_SETAS_WALLPAPER "wallpaper" +#define GE_SETAS_CROP_WALLPAPER "crop-wallpaper" +#define GE_SETAS_CALLERID "callerid" + +#define GE_FILE_SELECT_RETURN_COUNT "count" +#define GE_FILE_SELECT_RETURN_PATH "path" + +#define GE_FILE_SELECT_RETURN_QUIT "ug-quit" +#define GE_FILE_SELECT_QUIT_STATE "normal" + +#define GE_SETAS_CALLERID_CROP_IMAGE_PATH "crop-image-path" +#define GE_SETAS_IMAGE_PATH "image-path" + +/*Image viewer UG service parameters*/ +#define GE_IMAGEVIEWER_CALLERID_SIZE "Area size" +#define GE_IMAGEVIEWER_CALLERID_PATH "CallerID path" + +#define GE_IMAGEVIEWER_CROP_IMAGE_PATH "crop_image_path" +#define GE_IMAGEVIEWER_IMAGE_PATH "image_path" + +#define GE_IMAGEVIEWER_HOMESCREEN_PATH "Wallpaper path" +#define GE_IMAGEVIEWER_LOCKSCREEN_PATH "Lockscreen path" +#define GE_IMAGEVIEWER_RETURN_ERROR "Error" +/*Image viewer UG service parameters-End*/ + +typedef enum { + GE_ALBUM_SELECT_T_NONE, + GE_ALBUM_SELECT_T_ONE, +} ge_album_select_e; + +typedef enum { + GE_FILE_SELECT_T_NONE, + GE_FILE_SELECT_T_ONE, + GE_FILE_SELECT_T_MULTIPLE, + GE_FILE_SELECT_T_SETAS, +} ge_file_select_e; + +typedef enum { + GE_SETAS_T_NONE, + GE_SETAS_T_WALLPAPER, + GE_SETAS_T_CROP_WALLPAPER, + GE_SETAS_T_CALLERID, +} ge_file_select_setas_e; + +typedef enum { + GE_FILE_T_NONE, + GE_FILE_T_IMAGE, + GE_FILE_T_VIDEO, + GE_FILE_T_ALL, +} ge_file_type_e; + +typedef enum view_by_mode_e { + GE_VIEW_ALBUMS, + GE_VIEW_THUMBS, + GE_VIEW_THUMBS_EDIT, +} ge_view_mode; + +typedef enum { + GE_ROTATE_NONE, + GE_ROTATE_PORTRAIT, + GE_ROTATE_PORTRAIT_UPSIDEDOWN, + GE_ROTATE_LANDSCAPE, + GE_ROTATE_LANDSCAPE_UPSIDEDOWN, +} ge_rotate_mode; + +typedef enum { + GE_UPDATE_NONE, + GE_UPDATE_NORMAL, + GE_UPDATE_MMC_REMOVED, + GE_UPDATE_MMC_ADDED, +} ge_update_mode; + +typedef struct _ge_ugdata ge_ugdata; + +typedef struct { + ge_album_s *cluster; + ge_ugdata *ugd; + int index; + + time_t item_mtime; + Elm_Object_Item *griditem; + void *_reserved; +}ge_cluster; + +typedef struct { + Eina_List* clist; +}ge_cluster_list; + +typedef struct _ge_item { + ge_media_s* item; + ge_ugdata* ugd; + Elm_Object_Item *elm_item; + Evas_Object* check_obj; + bool checked; + + void* _reserved; +}ge_item; + +struct _ge_ugdata { + Evas_Object *win; + double win_scale; + Evas_Object *ly_main; + Evas_Object *bg; + Elm_Theme *th; + /* add more variables here */ + Evas_Object *navi_bar; + Evas_Object *albums_view; + Evas_Object *albums_view_ly; + Evas_Object *thumbs_view; + Evas_Object *thumbs_view_ly; + Elm_Object_Item *thumbs_nf_it; + Elm_Object_Item *albums_nf_it; + Evas_Object *thumbs_nocontents; + Ecore_Idler* grid_append_idler; + Evas_Object *nocontents; + Ecore_Event_Handler* event_handler; + Evas_Object *popup; + Ecore_Timer *del_timer; + int popup_mode; + + ge_cluster_list* cluster_list; + ui_gadget_h ug_called_by_me; + ui_gadget_h ug; + service_h service; /*added for "ug_send_result"*/ + /* It's thumbnails icon size, not grid item size */ + int icon_size; + Ecore_Timer *thumbs_clicked_timer; + + int album_select_mode; + int file_select_mode; + int file_type_mode; + int file_select_setas_mode; + bool b_show_drm; + char* file_setas_callid_size; + char* file_setas_callid_path; + char* file_setas_image_path; + char* file_setas_crop_image_path; + char albums_view_title[GE_ALBUM_NAME_LEN_MAX]; + char* file_setas_homescreen_path; + char* file_setas_lockscreen_path; + + Evas_Object *selinfo_ly; + + bool b_inited_view; /* true: show albums view; false: show popup */ +}; + +#define GE_IF_DEL_TIMER(timer) if(timer){ecore_timer_del(timer); timer = NULL;} +#define GE_IF_DEL_IDLER(idler) if(idler){ecore_idler_del(idler); idler = NULL;} +#define GE_IF_DEL_OBJ(obj) if(obj){evas_object_del(obj); obj = NULL;} + +ge_view_mode _ge_get_view_mode(void); +void _ge_set_view_mode(ge_view_mode mode); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GALLERY_EFL_H__ */ + diff --git a/ug/ug-gallery-efl/include/ge-albums.h b/ug/ug-gallery-efl/include/ge-albums.h new file mode 100755 index 0000000..d32b20f --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-albums.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_ALBUMS_H_ +#define _GE_ALBUMS_H_ + +#include "gallery-efl.h" + +Evas_Object* ge_albums_create_view(ge_ugdata *ugd, Evas_Object* parent); +int ge_albums_sel_album(ge_cluster* album_item); +int ge_albums_update_view(ge_ugdata *ugd); +Evas_Object* ge_albums_create_ly(Evas_Object* parent); +int ge_albums_back_to_view(ge_ugdata *ugd); +int ge_albums_del_callbacks(ge_ugdata *ugd); +int ge_albums_free_cover_thumbs(ge_ugdata *ugd); + +#endif /* _GE_ALBUMS_H_ */ + diff --git a/ug/ug-gallery-efl/include/ge-button.h b/ug/ug-gallery-efl/include/ge-button.h new file mode 100755 index 0000000..f14d5d7 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-button.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_BUTTON_H_ +#define _GE_BUTTON_H_ + +#include "gallery-efl.h" + +/**< Evas smart objects' "smart callback" function signature */ +typedef void (*But_Smart_Cb) (void *data, Evas_Object *obj, void *event_info); + +Evas_Object *_ge_but_create_but(Evas_Object *parent, Elm_Theme *theme, + const char *icon, const char *text, + const char *style, But_Smart_Cb cb_func, + const void *data); + +#endif /* _GE_BUTTON_H_ */ + diff --git a/ug/ug-gallery-efl/include/ge-data-type.h b/ug/ug-gallery-efl/include/ge-data-type.h new file mode 100755 index 0000000..e0a1615 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-data-type.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_TYPE_H_ +#define _GE_TYPE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define GE_FREEIF(ptr) \ + do { \ + if(ptr != NULL) \ + { \ + free(ptr); \ + ptr = NULL; \ + } \ + } while (0) + +#define GE_FREE(ptr) \ + do { \ + free(ptr); \ + ptr = NULL; \ + } while (0) + +#define GE_TYPE_ALBUM (0x55551) +#define GE_TYPE_MEDIA (0x55553) + +typedef enum +{ + GE_PHONE, /**< Stored only in phone */ + GE_MMC, /**< Stored only in MMC */ + GE_SYSTEM, /**< Stored in ALL*/ +} _ge_store_type_t; + + +typedef struct _ge_album_t ge_album_s; +typedef struct _ge_media_t ge_media_s; +typedef struct _ge_image_t ge_image_s; +typedef struct _ge_video_t ge_video_s; + +struct _ge_album_t { + int gtype; /*self-defination type, when free this struct space, use it*/ + media_folder_h folder_h; /*the handle of operating this folder*/ + char *uuid; /*folder UUID*/ + char *display_name; /*album name*/ + char *path; /*the full path of this folder*/ + int type; /*storage type*/ + time_t mtime; /*modified time*/ + int count; /*the media count in this folder*/ + char *thumb_url; /**< thumbnail full path */ + + void *_reserved; /*reserved*/ +}; + +struct _ge_media_t { + int gtype; /*self-defination type, when free this struct space, use it*/ + media_info_h media_h; /*the handle of operating this media*/ + char *uuid; /*meida id*/ + int type; /*meida type, image or video*/ + char *thumb_url; /*the thumbnail full path of this meida file*/ + char *file_url; /*the full path of this meida file*/ + time_t mtime; /*modified time*/ + char *album_uuid; /*folder UUID*/ + char *display_name; /*item name*/ + bool favorite; /*favorite level*/ + union { + ge_image_s *image_info; /*image information*/ + ge_video_s *video_info; /*video information*/ + }; + void *_reserved; /*reserved*/ +}; + +struct _ge_image_t { + char *media_uuid; /*media uuid*/ + image_meta_h image_h; /*the handle of operating this image*/ + media_content_orientation_e orientation; /*the orientation of this image*/ + void *_reserved; /*reserved*/ +}; + +struct _ge_video_t { + char *media_uuid; /*media uuid*/ + video_meta_h video_h; /*the handle of operating this video*/ + char *title; /*the title of video*/ + time_t last_played_pos; /*the last played position*/ + int duration; /*the duration of this video*/ + int bookmarks; /*whether exist bookmarks*/ + void *_reserved; /*reserved*/ +}; + +int _ge_data_type_new_media(ge_media_s **item); +int _ge_data_type_new_album(ge_album_s **album); + +int _ge_data_type_free_media_list(Eina_List **list); +int _ge_data_type_free_album_list(Eina_List **list); +int _ge_data_type_free_geitem(void **item); + +#endif + diff --git a/ug/ug-gallery-efl/include/ge-data.h b/ug/ug-gallery-efl/include/ge-data.h new file mode 100755 index 0000000..f23c6ec --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-data.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_DB_HANDLER_H_ +#define _GE_DB_HANDLER_H_ + +#include "ge-local-data.h" +#include "gallery-efl.h" + +#ifdef _cplusplus +extern "C" { +#endif + +typedef enum { + GE_SORT_BY_NONE, /**< No Sort */ + GE_SORT_BY_NAME_DESC, /**< Sort by display name descending */ + GE_SORT_BY_NAME_ASC, /**< Sort by display name ascending */ + GE_SORT_BY_DATE_DESC, /**< Sort by modified_date descending */ + GE_SORT_BY_DATE_ASC, /**< Sort by modified_date ascending */ +} ge_sort_type_e; + +int _ge_data_update_items_cnt(ge_ugdata* ugd, ge_cluster *album); +int _ge_data_get_clusters_list(ge_ugdata* ugd); +int _ge_data_free_items_list(void); +int _ge_data_get_items_list(ge_ugdata* ugd, ge_cluster *album, int start_pos, + int end_pos); +int _ge_data_update_items_list(ge_ugdata* ugd, ge_cluster *album); +int _ge_data_get_first_several_items(ge_ugdata* ugd, ge_cluster *album, + ge_item* items[], int *item_count, + media_content_order_e sort_type); +int _ge_data_del_media_id(ge_ugdata* ugd, const char *media_id); +int _ge_data_item_list_remove(ge_item* gitem); +int _ge_data_destroy_item(ge_item* gitem); +int _ge_data_get_item_by_index(ge_item** gitem, int idx); +int _ge_data_get_count_all(void); +int _ge_data_get_selected_item_by_index(ge_item** gitem, int idx); +int _ge_data_selected_list_count(void); +Eina_List* _ge_data_get_selected_list(void); +int _ge_data_selected_list_append(ge_item* gitem); +int _ge_data_selected_list_remove(ge_item* gitem); +int _ge_data_selected_list_finalize(void); +bool _ge_data_is_default_album(const char *match_folder, ge_album_s *mcluster); +bool _ge_data_is_root_path(const char *path); +int _ge_data_create_thumb(ge_item *gitem, media_thumbnail_completed_cb callback, + void *user_data); +int _ge_data_init(ge_ugdata* ugd); +int _ge_data_finalize(ge_ugdata* ugd); + +#ifdef _cplusplus +} +#endif +#endif /* _GE_DB_HANDLER_H_ */ + diff --git a/ug/ug-gallery-efl/include/ge-debug.h b/ug/ug-gallery-efl/include/ge-debug.h new file mode 100755 index 0000000..0828bb4 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-debug.h @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GL_DEBUG_H_ +#define _GL_DEBUG_H_ + +#include + +#ifdef _cplusplus +extern "C" { +#endif + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "GALLERY-EFL" + +typedef enum { + DEBUG_CRITICAL, + DEBUG_CHECK, + MB_DEBUG_LOG, + DEBUG_MAX +} GlDebugType; + +/* anci c color type */ +#define FONT_COLOR_RESET "\033[0m" +#define FONT_COLOR_RED "\033[31m" +#define FONT_COLOR_GREEN "\033[32m" +#define FONT_COLOR_YELLOW "\033[33m" +#define FONT_COLOR_BLUE "\033[34m" +#define FONT_COLOR_PURPLE "\033[35m" +#define FONT_COLOR_CYAN "\033[36m" +#define FONT_COLOR_GRAY "\033[37m" + +#ifdef _USE_LOG_FILE_ +FILE* g_log_fp; +#endif // _USE_LOG_FILE_ + +#ifdef _USE_LOG_FILE_ + +#define ge_dbg(fmt,arg...) fprintf(g_log_fp, "[%s: %d]" fmt "\n", __FUNCTION__, __LINE__, ##arg) + +#elif defined _USE_DLOG_ + +#define ge_dbg(fmt, arg...) LOGD("[%s : %d] " fmt "\n", __FUNCTION__, __LINE__, ##arg) +#define ge_dbgW(fmt, arg...) LOGW(FONT_COLOR_GREEN"[%s : %d] " fmt "\n"FONT_COLOR_RESET, __FUNCTION__, __LINE__, ##arg) +#define ge_dbgE(fmt, arg...) LOGE(FONT_COLOR_RED"[%s : %d] " fmt "\n"FONT_COLOR_RESET, __FUNCTION__, __LINE__, ##arg) + +#elif defined _USE_LOG_CONSOLE_ + +#define ge_dbg(fmt,arg...) fprintf(stdout, "[%s: %d] [%s]" fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg) +#define ge_dbgW(fmt, arg...) fprintf(stdout, "[%s : %d] [%s] " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg) +#define ge_dbgE(fmt, arg...) fprintf(stdout, "[%s : %d] [%s] " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg) + +#else + +#define ge_dbg(fmt,arg...) +#define ge_dbgW(fmt, arg...) +#define ge_dbgE(fmt, arg...) +#endif + +#define ge_warn_if(expr, fmt, arg...) do { \ + if(expr) { \ + ge_dbg("(%s) -> "fmt, #expr, ##arg); \ + } \ + } while (0) +#define ge_ret_if(expr) do { \ + if(expr) { \ + ge_dbgE("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ + } while (0) +#define ge_retv_if(expr, val) do { \ + if(expr) { \ + ge_dbgE("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ + } while (0) +#define ge_retm_if(expr, fmt, arg...) do { \ + if(expr) { \ + ge_dbgE(fmt, ##arg); \ + ge_dbgE("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ + } while (0) +#define ge_retvm_if(expr, val, fmt, arg...) do { \ + if(expr) { \ + ge_dbgE(fmt, ##arg); \ + ge_dbgE("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ + } while (0) + + +#define GE_CHECK_VAL(expr, val) ge_retvm_if(!(expr), val, "Invalid parameter, return ERROR code!") +#define GE_CHECK_NULL(expr) ge_retvm_if(!(expr), NULL, "Invalid parameter, return NULL!") +#define GE_CHECK_FALSE(expr) ge_retvm_if(!(expr), false, "Invalid parameter, return FALSE!") +#define GE_CHECK_CANCEL(expr) ge_retvm_if(!(expr), ECORE_CALLBACK_CANCEL, "Invalid parameter, return ECORE_CALLBACK_CANCEL!") +#define GE_CHECK(expr) ge_retm_if(!(expr), "Invalid parameter, return!") + + +#include +#include + +void _ge_print_debug_time_ex(long start, long end, const char* func_name, char* time_string); + +#ifdef _cplusplus +} +#endif + +#endif /* _GL_DEBUG_H_ */ + diff --git a/ug/ug-gallery-efl/include/ge-drm.h b/ug/ug-gallery-efl/include/ge-drm.h new file mode 100755 index 0000000..9270380 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-drm.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_DRM_H_ +#define _GE_DRM_H_ + +#include +#include + +Eina_Bool ge_drm_check_valid_ro(const char *file_path, + drm_permission_type_e permType); +char* ge_drm_get_file_path(void *item); +Eina_Bool ge_drm_is_drm_file(const char* file_path); +int ge_drm_get_permtype(int gitem_type); + +#endif /* _GE_DRM_H_ */ + diff --git a/ug/ug-gallery-efl/include/ge-exif.h b/ug/ug-gallery-efl/include/ge-exif.h new file mode 100755 index 0000000..8c452e8 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-exif.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef _USE_ROTATE_BG_GE + +#ifndef _GE_EXIF_H_ +#define _GE_EXIF_H_ + +#include +#include + +#ifdef _cplusplus +extern "C" +{ +#endif + +/* +Orientation - angle +1 - 0 +3 - 180 +6 - 90 +8 - 270 +*/ +typedef enum _GE_orientation_rot_t ge_orientation_rot_e; + +enum _GE_orientation_rot_t { + GE_ORIENTATION_ROT_ERR = 0, + GE_ORIENTATION_ROT_0 = 1, + GE_ORIENTATION_ROT_180 = 3, + GE_ORIENTATION_ROT_90 = 6, + GE_ORIENTATION_ROT_270 = 8, +}; + +int _ge_exif_get_orientation(char *file_path, unsigned int *orientation); + +#ifdef _cplusplus +} +#endif + +#endif /* _GE_EXIF_H_ */ + +#endif + diff --git a/ug/ug-gallery-efl/include/ge-ext-ug-load.h b/ug/ug-gallery-efl/include/ge-ext-ug-load.h new file mode 100755 index 0000000..28b0419 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-ext-ug-load.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_EXT_UG_LOAD_H_ +#define _GE_EXT_UG_LOAD_H_ + +#include +#include "gallery-efl.h" + + +int ge_ext_load_pw_ug(ge_ugdata *ugd, ge_cluster* album_item); +int ge_ext_load_iv_ug(ge_ugdata* ugd); + +#endif /* _GE_EXT_UG_LOAD_H_ */ + diff --git a/ug/ug-gallery-efl/include/ge-gridview.h b/ug/ug-gallery-efl/include/ge-gridview.h new file mode 100755 index 0000000..216fb72 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-gridview.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_GRIDVIEW_H_ +#define _GE_GRIDVIEW_H_ + +#include "gallery-efl.h" + +Evas_Object* ge_grid_create_ly(Evas_Object* parent); +Evas_Object* ge_grid_create_view(ge_ugdata* ugd, Evas_Object* parent); +int ge_grid_clear_view(ge_ugdata *ugd); +int ge_grid_update_view(ge_ugdata *ugd); +int ge_grid_del_callbacks(ge_ugdata *ugd); +int ge_grid_idler_append_thumbs(void* data); + +#endif /* _GE_GRIDVIEW_H_ */ diff --git a/ug/ug-gallery-efl/include/ge-icon.h b/ug/ug-gallery-efl/include/ge-icon.h new file mode 100755 index 0000000..a68cd4d --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-icon.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __GE_ICON_H__ +#define __GE_ICON_H__ + +#include "gallery-efl.h" + +#define GE_THUMB_FAVOR_ICON GE_IMAGES_DIR"T01_icon_thumbnail_favorite.png" + +#define GE_LOCK_ICON GE_IMAGES_DIR"T01_icon_lock.png" +#define GE_THUMB_BOOKMARK GE_IMAGES_DIR"T01_icon_thumbnail_bookmark.png" +#define GE_DEFAULT_THUMB_ICON GE_IMAGES_DIR"T01_Nocontents_broken.png" +#define GE_CBAR_ICON_DONE GE_IMAGES_DIR"T01_controlbar_icon_done.png" +#define GE_DB_DEFAULT_THUMB "/opt/usr/data/file-manager-service/.thumb/thumb_default.png" + +#endif + diff --git a/ug/ug-gallery-efl/include/ge-lang.h b/ug/ug-gallery-efl/include/ge-lang.h new file mode 100755 index 0000000..0236c43 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-lang.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_LANG_H_ +#define _GE_LANG_H_ + +#include "gallery-efl.h" + +#ifdef _cplusplus +extern "C" +{ +#endif + +int _ge_lang_update(ge_ugdata *ugd); + +#ifdef _cplusplus +} +#endif + + +#endif + diff --git a/ug/ug-gallery-efl/include/ge-local-data.h b/ug/ug-gallery-efl/include/ge-local-data.h new file mode 100755 index 0000000..e7bf9cd --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-local-data.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_LOCAL_DATA_H_ +#define _GE_LOCAL_DATA_H_ + +#include "ge-data-type.h" + +/*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music*/ +#define GE_CONDITION_IMAGE_VIDEO "(MEDIA_TYPE=0 OR MEDIA_TYPE=1)" +#define GE_CONDITION_IMAGE "(MEDIA_TYPE=0)" +#define GE_CONDITION_VIDEO "(MEDIA_TYPE=1)" +/**< 0-not favourite, 1-favourite*/ +#define GE_CONDITION_FAV_IMAGE_VIDEO "((MEDIA_TYPE=0 OR MEDIA_TYPE=1) AND MEDIA_FAVORITE=1)" + +#define GE_CONDITION_DRM " AND "MEDIA_IS_DRM"=0" + +#define CONDITION_LENGTH 200 +#define KEYWORD_LENGTH 20 + +typedef struct _ge_filter_t ge_filter_s; + +struct _ge_filter_t { + char cond[CONDITION_LENGTH]; /*set media type or favorite type, or other query statement*/ + media_content_collation_e collate_type; /*collate type*/ + media_content_order_e sort_type; /*sort type*/ + char sort_keyword[KEYWORD_LENGTH]; /*sort keyword*/ + int offset; /*offset*/ + int count; /*count*/ + bool with_meta; /*whether get image or video info*/ +}; + +int _ge_local_data_connect(void); +int _ge_local_data_disconnect(void); +int _ge_local_data_get_album_list(ge_filter_s *condition, Eina_List **elilst); +int _ge_local_data_get_media_count(const char *cluster_id, ge_filter_s *filter, + int *item_cnt); +int _ge_local_data_get_all_media_count(ge_filter_s *filter, int *item_cnt); +int _ge_local_data_get_media(const char *media_id, ge_media_s **mitem); +int _ge_local_data_get_album_media_list(char *album_id, ge_filter_s *condition, + Eina_List **elist); +int _ge_local_data_get_all_albums_media_list(ge_filter_s *condition, + Eina_List **elist); + +#endif + diff --git a/ug/ug-gallery-efl/include/ge-rotate-bg.h b/ug/ug-gallery-efl/include/ge-rotate-bg.h new file mode 100755 index 0000000..b5f82e0 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-rotate-bg.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef _USE_ROTATE_BG_GE + +#ifndef _GE_ROTATE_BG_H_ +#define _GE_ROTATE_BG_H_ + +#include "gallery-efl.h" + +Evas_Object *_ge_rotate_bg_add(Evas_Object *parent); +int _ge_rotate_bg_set_file(Evas_Object *bg, const char *file, int w, int h); +int _ge_rotate_bg_rotate_image(Evas_Object *bg, unsigned int orient); +int _ge_rotate_bg_add_image(Evas_Object *bg, int w, int h); +int _ge_rotate_bg_set_image_file(Evas_Object *bg, const char *file); + +#endif + +#endif diff --git a/ug/ug-gallery-efl/include/ge-strings.h b/ug/ug-gallery-efl/include/ge-strings.h new file mode 100755 index 0000000..0d1619f --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-strings.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_STRINGS_H_ +#define _GE_STRINGS_H_ + +#ifdef _cplusplus +extern "C" { +#endif + +#define _GE_GETSYSTEMSTR(ID) dgettext("sys_string", (ID)) +#define _GE_GETLOCALSTR(ID) dgettext("ug-gallery-efl", (ID)) +/* hard code strings */ +#define GE_ALBUM_CAMERA_NAME _("Camera") +#define GE_ALBUM_DOWNLOAD_NAME _("Downloads") +#define GE_TITLE_CHANGE_CALLER_ID _("Change caller ID") +#define GE_POPUP_ONLY_SUPPORT_IMAGE _("Only image is supported!") + +#define GE_STR_CAMERA _GE_GETSYSTEMSTR("IDS_COM_BODY_CAMERA") +#define GE_STR_DOWNLOADS _GE_GETSYSTEMSTR("IDS_COM_BODY_DOWNLOADS") + +#define GE_ALBUM_ALL_NAME _GE_GETLOCALSTR("IDS_MEDIABR_BODY_ALL_ALBUMS") +#define GE_LABEL_NO_ALBUMS _GE_GETLOCALSTR("IDS_MEDIABR_BODY_NO_ALBUMS") +#define GE_ALBUM_ROOT_NAME _GE_GETLOCALSTR("IDS_MEDIABR_POP_NO_NAME") + +/* system strings which are included in sys-string-0 po files */ +#define GE_TITLE_ADD _GE_GETSYSTEMSTR("IDS_COM_SK_ADD") +#define GE_TITLE_ALBUMS _GE_GETSYSTEMSTR("IDS_COM_BODY_ALBUMS") +#define GE_TITLE_IMAGE _GE_GETSYSTEMSTR("IDS_COM_OPT_IMAGE") +#define GE_TITLE_FILE _GE_GETSYSTEMSTR("IDS_COM_POP_FILE") +#define GE_TITLE_IMAGES _GE_GETSYSTEMSTR("IDS_COM_BODY_IMAGES") +#define GE_TITLE_VIDEOS _GE_GETSYSTEMSTR("IDS_COM_BODY_VIDEOS") +#define GE_TITLE_FILES _GE_GETSYSTEMSTR("IDS_COM_OPT_FILES") +#define GE_TITLE_CHANGE_WALLPAPER _GE_GETSYSTEMSTR("IDS_COM_HEADER_CHANGE_WALLPAPER") +#define GE_TITLE_VIDEO _GE_GETSYSTEMSTR("IDS_COM_BODY_VIDEO") +#define GE_LABEL_NO_VIDEOS _GE_GETSYSTEMSTR("IDS_COM_BODY_NO_VIDEOS") +#define GE_SELINFO_SELECTED _GE_GETSYSTEMSTR("IDS_COM_POP_SELECTED") +#define GE_POPUP_NO_FILES_SELECTED _GE_GETSYSTEMSTR("IDS_COM_POP_NO_FILES_SELECTED") +#define GE_STR_OK _GE_GETSYSTEMSTR("IDS_COM_SK_OK") +#define GE_STR_CANCEL _GE_GETSYSTEMSTR("IDS_COM_SK_CANCEL") +#define GE_STR_DONE _GE_GETSYSTEMSTR("IDS_COM_SK_DONE") + +#ifdef _cplusplus +} +#endif +#endif diff --git a/ug/ug-gallery-efl/include/ge-thumb.h b/ug/ug-gallery-efl/include/ge-thumb.h new file mode 100755 index 0000000..e863501 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-thumb.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_THUMB_H_ +#define _GE_THUMB_H_ + +Evas_Object *_ge_thumb_show_part_icon_image(Evas_Object *obj, char *path, + unsigned int orient, bool b_favor, + bool is_expired_drm, int item_size); + +Evas_Object *_ge_thumb_show_part_icon_video(Evas_Object *obj, char *path, + unsigned int v_dur, int bk_len, + bool b_favor, bool is_expired_drm, + int item_size); +#endif + diff --git a/ug/ug-gallery-efl/include/ge-tile.h b/ug/ug-gallery-efl/include/ge-tile.h new file mode 100755 index 0000000..034de5a --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-tile.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_TILE_H_ +#define _GE_TILE_H_ + +#include "ge-data.h" + +#define GE_TILE_THUMB_1 1 + +#define GT_TILE_ONLYICON "elm.swallow.onlyicon" +#define GT_TILE_ICON "elm.swallow.icon" +#define GT_TILE_LABEL "label_bg" + +/* Size of album icon */ +#define GE_TILE_SIZE 318 +/* Size of table padding */ +#define GE_TILE_PAD 3 +/* Pure size of album icon; value: 196 */ +#define GE_TILER_ICON_S (GE_TILE_SIZE - 2 * GE_TILE_PAD) +/** +* Album icon is set by elm_table, +* it's divided into 3x3, 9 grids, each grid size is 64 +*/ +#define GE_TILE_GRID_S 102 +/* value: 130 */ +#define GE_TILE_2X_GRID_S (GE_TILER_ICON_S - GE_TILE_GRID_S - GE_TILE_PAD) + +typedef enum +{ + GE_ICON_NORMAL, + GE_ICON_EXPIRED_DRM, + GE_ICON_CORRUPTED_FILE +}ge_icon_type; + +typedef ge_icon_type (*bg_file_set_cb)(Evas_Object *bg, void *data); + +Evas_Object *_ge_tile_show_part_icon(Evas_Object *obj, const char *part, + int length, double scale, + bg_file_set_cb func, void **data); +Evas_Object *_ge_tile_show_part_label(Evas_Object *obj, int index, + bool b_default); + +#endif + diff --git a/ug/ug-gallery-efl/include/ge-ui-util.h b/ug/ug-gallery-efl/include/ge-ui-util.h new file mode 100755 index 0000000..15c4a76 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-ui-util.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_UI_UTIL_H_ +#define _GE_UI_UTIL_H_ + +#include "gallery-efl.h" +#include "ge-icon.h" + +#ifdef _cplusplus +extern "C" { +#endif + +#define _EDJ(o) elm_layout_edje_get(o) + +#define _GE_GET_ICON(_path) \ + ((1 == ecore_file_exists(_path) && (ecore_file_size(_path) > 0)) ? _path : GE_DEFAULT_THUMB_ICON) + +typedef enum { + GE_NAVI_ALBUMS, + GE_NAVI_THUMBS, +} ge_navi_mode_e; + +typedef enum { + GE_POPUP_NOBUT, + GE_POPUP_ONEBUT, + GE_POPUP_TWOBUT, + GE_POPUP_EXIT, +} ge_popup_mode_e; + +int ge_ui_cancel_album_lock(ge_ugdata *ugd); +int ge_ui_set_album_lock(ge_cluster* album); +Evas_Object* ge_ui_create_navibar(ge_ugdata* ugd, Evas_Object* parent); +Evas_Object* ge_ui_create_main_ly(ge_ugdata* ugd, Evas_Object* parent); +int ge_ui_create_title_and_push(ge_ugdata *ugd, Evas_Object* parent, + Evas_Object* obj, ge_navi_mode_e mode, + char* title); +void ge_ui_set_rotate_angle(int rotate_mode); +Evas_Object* ge_ui_load_edj(Evas_Object *parent, const char *file, const char *group); +Evas_Object* ge_ui_create_nocontents(ge_ugdata* ugd); +int ge_ui_lock_albums(ge_cluster* album_item); +Evas_Object* ge_ui_create_popup(ge_ugdata* ugd, ge_popup_mode_e mode, + char* desc); +int _ge_ui_create_selinfo(ge_ugdata *ugd, Evas_Object *parent); +int ge_ui_destroy_selinfo(ge_ugdata* ugd); +char* _ge_ui_get_translated_album_name(ge_cluster *album); + +#ifdef _cplusplus +} +#endif + +#endif // end of _GE_UI_UTIL_H_ diff --git a/ug/ug-gallery-efl/include/ge-util.h b/ug/ug-gallery-efl/include/ge-util.h new file mode 100755 index 0000000..86acde1 --- /dev/null +++ b/ug/ug-gallery-efl/include/ge-util.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _GE_UTIL_H_ +#define _GE_UTIL_H_ + +#include "gallery-efl.h" + +#define GE_FILE_EXISTS(path) \ + (path && (1 == ecore_file_exists(path)) && (ecore_file_size(path) > 0)) + +ge_item* _ge_get_current_item(void); +void _ge_set_current_item(ge_item* gitem); +int ge_reg_db_update_noti(ge_ugdata* ugd); +int ge_dereg_db_update_noti(void); +Eina_Bool ge_update_view(ge_ugdata* ugd, int mode); +int _ge_ug_iv_get(void); +void _ge_ug_iv_set(int ug_iv_state); +ge_cluster* _ge_get_current_album(void); +void _ge_set_current_album(ge_cluster* album_item); +bool _ge_is_image_valid(void *data, char *filepath); +char *_ge_get_duration_string(unsigned int v_dur); +#endif /* _GE_EXT_EXEC_H_ */ + diff --git a/ug/ug-gallery-efl/res/edc/gallery-efl-check.edc b/ug/ug-gallery-efl/res/edc/gallery-efl-check.edc new file mode 100755 index 0000000..28032fb --- /dev/null +++ b/ug/ug-gallery-efl/res/edc/gallery-efl-check.edc @@ -0,0 +1,381 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define CHECK_STYLE_DEFAULT_BG_NORMAL_MIN_MAX_INC 42 42 + +#define CHECK_DEFAULT_TEXT_NORMAL_COLOR_INC 255 255 255 255 +#define CHECK_DEFAULT_TEXT_PRESSED_COLOR_INC 255 255 255 255 +#define CHECK_DEFAULT_TEXT_DISABLED_COLOR_INC 136 136 136 136 + +//////////////////////////////////////////////////////////////////////////////////////// +// +// check default textblock style +// +/////////////////////////////////////////////////////////////////////////////////////// + styles { + style { name: "check_label_textblock_style"; + base: "font=SLP:style=Roman text_class=slp font_size=32 color=#ffffff wrap=char"; + tag: "br" "\n"; + tag: "ps" "ps"; + tag: "hilight" "+ font=SLP:style=Bold text_class=slp"; + tag: "b" "+ font=SLP:style=Bold text_class=slp"; + tag: "whitecolor" "+ color=#ffffff"; + tag: "tab" "\t"; + } + } + +#define CHECK_STATE_DEFAULT 0 +#define CHECK_STATE_VISIBLE 1 +#define CHECK_STATE_DISABLED_VISIBLE 2 +#define CHECK_STATE_DISABLED 3 + +//////////////////////////////////////////////////////////////////////////////// +#define CHECK_STYLE_GRID(style_name, image_grid, width, height) \ + group { name: "elm/check/base/"style_name; \ + images.image: image_grid COMP; \ + parts { \ + part { name: "bg"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + } \ + description { state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } \ + } \ + part { name: "icon_bg_img"; \ + type: RECT; \ + mouse_events: 0; \ + scale : 1; \ + description { \ + color: 0 0 0 0; \ + rel1 { relative: GAP_W/W (GAP_H+1)/H;} \ + rel2 { relative: (W-GAP_W)/W 1;} \ + } \ + } \ + part { name: "icon_bg"; \ + type: RECT; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + rel1 { relative: 0 0; to: "icon_bg_img"; } \ + rel2 { relative: 1 1; to: "icon_bg_img"; } \ + } \ + } \ + part { name: "bg2"; \ + type: RECT; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + rel1.to: "icon_bg"; \ + rel2.to: "icon_bg"; \ + align: 0.5 0.5; \ + min: width height; \ + max: width height; \ + color: 0 0 0 0; \ + } \ + description { state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } \ + } \ + part { name: "selected_bg"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + rel1.to: "icon_bg"; \ + rel2.to: "icon_bg"; \ + color: 0 0 0 0; \ + visible: 0; \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + color: 0 0 0 153; \ + visible: 1; \ + } \ + } \ + part { name: "check"; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + rel1.to: "bg2"; \ + rel2.to: "bg2"; \ + visible: 0; \ + image.normal: image_grid; \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + description { state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + part { name: "elm.swallow.content"; \ + type: SWALLOW; \ + description { \ + state: "default" 0.0; \ + fixed: 1 0; \ + visible: 0; \ + color: 255 255 255 255; \ + align: 0.0 0.5; \ + rel1 { \ + to_x: "bg2"; \ + relative: 1.0 0.0; \ + offset: 1 1; \ + } \ + rel2 { \ + to_x: "bg2"; \ + relative: 1.0 1.0; \ + offset: 2 -2; \ + } \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + fixed: 1 1; \ + visible: 1; \ + aspect: 1.0 1.0; \ + aspect_preference: VERTICAL; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + color: 128 128 128 128; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + color: 128 128 128 128; \ + fixed: 1 1; \ + visible: 1; \ + aspect: 1.0 1.0; \ + } \ + } \ + part { name: "elm.text"; \ + type: TEXTBLOCK; \ + mouse_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + visible: 0; \ + fixed: 0 1; \ + rel1 { \ + relative: 1.0 0.5; \ + offset: 1 1; \ + to_x: "elm.swallow.content"; \ + } \ + rel2 { \ + relative: 1.0 0.5; \ + offset: -2 -2; \ + } \ + color: 255 255 255 255; \ + align: 0.0 0.5; \ + text { \ + style: "check_label_textblock_style"; \ + min: 0 0; \ + } \ + color: CHECK_DEFAULT_TEXT_NORMAL_COLOR_INC; \ + } \ + description { state: "visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + text.min: 1 1; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + } \ + description { state: "disabled_visible" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + text.min: 1 1; \ + color: CHECK_DEFAULT_TEXT_DISABLED_COLOR_INC; \ + } \ + } \ + part { name: "events"; \ + type: RECT; \ + ignore_flags: ON_HOLD; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + } \ + } \ + part { name: "disabler"; \ + type: RECT; \ + description { state: "default" 0.0; \ + color: 0 0 0 0; \ + visible: 0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + } \ + programs { \ + program { name: "click"; \ + signal: "mouse,up,1"; \ + source: "events"; \ + action: SIGNAL_EMIT "elm,action,check,toggle" ""; \ + after: "bg_normal"; \ + } \ + program { name: "bg_normal"; \ + script { \ + set_state(PART:"bg", "default", 0.0); \ + set_state(PART:"bg2", "default", 0.0); \ + } \ + } \ + program { name: "mouseout"; \ + signal: "mouse,out"; \ + source: "events"; \ + after: "bg_check_normal"; \ + } \ + program { name: "bg_check_normal"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "pressed")) \ + set_state(PART:"check", "visible", 0.0); \ + set_state(PART:"bg", "default", 0.0); \ + set_state(PART:"bg2", "default", 0.0); \ + } \ + } \ + program { name: "pressed"; \ + signal: "mouse,down,1"; \ + source: "events"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"check", "pressed", 0.0); \ + set_state(PART:"bg", "pressed", 0.0); \ + set_state(PART:"bg2", "pressed", 0.0); \ + } \ + } \ + program { name: "check_on"; \ + signal: "elm,state,check,on"; \ + source: "elm"; \ + action: STATE_SET "visible" 0.0; \ + target: "check"; \ + target: "selected_bg"; \ + } \ + program { name: "check_off"; \ + signal: "elm,state,check,off"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "check"; \ + target: "selected_bg"; \ + } \ + program { name: "text_show"; \ + signal: "elm,state,text,visible"; \ + source: "elm"; \ + action: STATE_SET "visible" 0.0; \ + target: "elm.text"; \ + } \ + program { name: "text_hide"; \ + signal: "elm,state,text,hidden"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text"; \ + } \ + program { name: "icon_show"; \ + signal: "elm,state,icon,visible"; \ + source: "elm"; \ + action: STATE_SET "visible" 0.0; \ + target: "elm.swallow.content"; \ + } \ + program { name: "icon_hide"; \ + signal: "elm,state,icon,hidden"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.swallow.content"; \ + } \ + program { name: "disable"; \ + signal: "elm,state,disabled"; \ + source: "elm"; \ + action: STATE_SET "disabled" 0.0; \ + target: "disabler"; \ + target: "bg"; \ + target: "bg2"; \ + after: "disable_text"; \ + } \ + program { name: "disable_text"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.text", "disabled_visible", 0.0); \ + else \ + set_state(PART:"elm.text", "disabled", 0.0); \ + get_state(PART:"elm.swallow.content", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.swallow.content", "disabled_visible", 0.0); \ + else \ + set_state(PART:"elm.swallow.content", "disabled", 0.0); \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"check", "disabled_visible", 0.0); \ + } \ + } \ + program { name: "enable"; \ + signal: "elm,state,enabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "disabler"; \ + target: "bg"; \ + target: "bg2"; \ + after: "enable_text"; \ + } \ + program { name: "enable_text"; \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text", st, 30, vl); \ + if (!strcmp(st, "disabled_visible")) \ + set_state(PART:"elm.text", "visible", 0.0); \ + else \ + set_state(PART:"elm.text", "default", 0.0); \ + get_state(PART:"elm.swallow.content", st, 30, vl); \ + if (!strcmp(st, "visible")) \ + set_state(PART:"elm.swallow.content", "visible", 0.0); \ + else \ + set_state(PART:"elm.swallow.content", "default", 0.0); \ + get_state(PART:"check", st, 30, vl); \ + if (!strcmp(st, "disabled_visible")) \ + set_state(PART:"check", "visible", 0.0); \ + } \ + } \ + } \ + } + +//////////////////////////////////////////////////////////////////////////////// + CHECK_STYLE_GRID("gallery_efl/grid", GE_EDC_IMAGE_CHECK_GRID, 64, 64) + + +#undef CHECK_STATE_DEFAULT +#undef CHECK_STATE_VISIBLE +#undef CHECK_STATE_DISABLED_VISIBLE +#undef CHECK_STATE_DISABLED diff --git a/ug/ug-gallery-efl/res/edc/gallery-efl-edc-res.h b/ug/ug-gallery-efl/res/edc/gallery-efl-edc-res.h new file mode 100755 index 0000000..c2c1c49 --- /dev/null +++ b/ug/ug-gallery-efl/res/edc/gallery-efl-edc-res.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Definition of image path used in edc file */ + +/* gallery-efl-nocontents.edc */ +#define GE_EDC_IMAGE_NOCONTENTS_PIC "T01_Nocontents_picture.png" + +/* gallery-efl-gengrid-item-albums.edc */ +#define GE_EDC_IMAGE_MAIN_FOLDER_BG "T01_main_folder_bg.png" + +/* gallery-efl-gengrid-item-thumbview.edc */ +#define GE_EDC_IMAGE_BUTTON_PLAY "T01_btn_play.png" + +/* gallery-efl-check.edc */ +#define GE_EDC_IMAGE_CHECK_GRID "T01_grid_select_check.png" + diff --git a/ug/ug-gallery-efl/res/edc/gallery-efl-gengrid-item-albums.edc b/ug/ug-gallery-efl/res/edc/gallery-efl-gengrid-item-albums.edc new file mode 100755 index 0000000..a6ede1c --- /dev/null +++ b/ug/ug-gallery-efl/res/edc/gallery-efl-gengrid-item-albums.edc @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* 14 + 334 + 10 */ +#define ALBUM_ITEM_W 358 +/* 26 + 334 */ +#define ALBUM_ITEM_H 360 + +#define ALBUM_W 334 +#define ALBUM_H 334 + +#define ALBUM_GAP_L 12 +#define ALBUM_GAP_R 12 +#define ALBUM_GAP_T 26 + +#define ALBUM_ICON_W 318 +#define ALBUM_ICON_H 318 + +#define ALBUM_ICON_GAP_L 8 +#define ALBUM_ICON_GAP_R 8 +#define ALBUM_ICON_GAP_B 16 +#define ALBUM_ICON_PAD 3 + +#define ALBUM_TEXT_AREA_W 207 +#define ALBUM_TEXT_AREA_H 102 +#define ALBUM_TEXT_GAP_L 4 +#define ALBUM_TEXT_GAP_R 4 +#define ALBUM_TEXT_SNS_X 60 +#define ALBUM_TEXT_NAME_H 32 +#define ALBUM_TEXT_DATE_H 25 +#define ALBUM_PBAR_W 183 +#define ALBUM_PBAR_H 10 +#define ALBUM_PBAR_GAP_L 6 +#define ALBUM_PBAR_GAP_T 8 + +#define ALBUM_SNS_ICON_W 32 +#define ALBUM_SNS_ICON_H 32 + +#define ALBUM_RENAME_BTN_W 64 +#define ALBUM_RENAME_BTN_H 64 + +#define ALBUM_CHECKBOX_W 42 +#define ALBUM_CHECKBOX_H 42 +#define ALBUM_CHECKBOX_GAP_L 1 +#define ALBUM_CHECKBOX_GAP_T 8 +#define ALBUM_ICON_BG_COLOR_INC 190 189 189 255 + +group { + name: "elm/gengrid/item/albums_view/gallery_efl/default"; + data.item: "texts" "elm.text.name elm.text.date elm.text.count"; + data.item: "contents" "elm.swallow.onlyicon elm.swallow.check_bg label_bg"; + images { + image: GE_EDC_IMAGE_MAIN_FOLDER_BG COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + color: 255 0 0 0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + } + part { name: "icon_bg_img"; + type: IMAGE; + mouse_events: 1; + scale : 1; + description { + min : ALBUM_W ALBUM_H; + state: "default" 0.0; + image { + normal : GE_EDC_IMAGE_MAIN_FOLDER_BG; + } + rel1 { relative: ALBUM_GAP_L/ALBUM_ITEM_W ALBUM_GAP_T/ALBUM_ITEM_H; to:"bg"; } + rel2 { relative: (ALBUM_ITEM_W-ALBUM_GAP_R-1)/ALBUM_ITEM_W 1.0; to:"bg"; } + } + } + part { name: "icon_bg"; + type: RECT; + mouse_events: 1; + scale : 1; + description { + min : ALBUM_ICON_W ALBUM_ICON_H; + state: "default" 0.0; + color: ALBUM_ICON_BG_COLOR_INC; + rel1 { relative: ALBUM_ICON_GAP_L/ALBUM_ICON_W 0.0; to:"icon_bg_img"; } + rel2 { relative: (ALBUM_ICON_W-ALBUM_ICON_GAP_R+2)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_GAP_B+2)/ALBUM_ICON_H; to:"icon_bg_img"; } + } + } + part { + name: "elm.swallow.onlyicon"; + type: SWALLOW; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: (ALBUM_ICON_PAD/ALBUM_ICON_W) (ALBUM_ICON_PAD/ALBUM_ICON_H); to: "icon_bg"; } + rel2 { relative: (ALBUM_ICON_W-ALBUM_ICON_PAD)/ALBUM_ICON_W (ALBUM_ICON_H-ALBUM_ICON_PAD)/ALBUM_ICON_H; to: "icon_bg"; } + } + } + part { + name: "label_bg"; + type: SWALLOW; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: (ALBUM_ICON_PAD/ALBUM_ICON_W) (ALBUM_ICON_PAD/ALBUM_ICON_H); offset: 0 0; to: "icon_bg"; } + rel2 { relative: ((ALBUM_ICON_PAD+ALBUM_TEXT_AREA_W-1)/ALBUM_ICON_W) ((ALBUM_ICON_PAD+ALBUM_TEXT_AREA_H-1)/ALBUM_ICON_H); offset: 0 0; to: "icon_bg"; } + } + } + part { + name: "elm.text.date"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: ALBUM_TEXT_GAP_L/ALBUM_TEXT_AREA_W ALBUM_TEXT_NAME_H/ALBUM_TEXT_AREA_H; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W (ALBUM_TEXT_NAME_H+ALBUM_TEXT_DATE_H-1)/ALBUM_TEXT_AREA_H; to: "label_bg"; } + color: 190 190 190 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 22; + align: 0.0 0.5; + } + } + } + part { + name: "elm.text.count"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + rel1 { relative: ((ALBUM_TEXT_GAP_L+ALBUM_SNS_ICON_W+1)/ALBUM_TEXT_AREA_W) ALBUM_TEXT_SNS_X/ALBUM_TEXT_AREA_H; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W 1.0; to: "label_bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 38; + align: 1.0 0.5; + } + } + } + part { + name: "elm.text.name"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: (ALBUM_TEXT_GAP_L/ALBUM_TEXT_AREA_W) 0.0; to: "label_bg"; } + rel2 { relative: (ALBUM_TEXT_AREA_W-ALBUM_TEXT_GAP_L-1)/ALBUM_TEXT_AREA_W (ALBUM_TEXT_NAME_H-1)/ALBUM_TEXT_AREA_H; to: "label_bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Medium"; + text_class: "slp"; + size: 28; + align: 0.0 0.5; + } + } + } + } +} + diff --git a/ug/ug-gallery-efl/res/edc/gallery-efl-gengrid-item-thumbview.edc b/ug/ug-gallery-efl/res/edc/gallery-efl-gengrid-item-thumbview.edc new file mode 100755 index 0000000..d54f961 --- /dev/null +++ b/ug/ug-gallery-efl/res/edc/gallery-efl-gengrid-item-thumbview.edc @@ -0,0 +1,931 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define THUMBNAILS_BG_COLOR 190 189 189 255 + +/* Grid item background size W: 14+158+6; H: 24+158 */ +#define W 178 +#define H 193 +#define GAP_W 2 +#define GAP_H 18 + +/* Favourites icon boundary size */ +#define FAVOR_ICON_W 30 +#define FAVOR_ICON_H 30 + +group { + name: "elm/gengrid/item/thumbnail_view/gallery_efl/default"; + + data.item: "contents" "elm.swallow.icon elm.swallow.end"; + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 0; + rel1 { relative: 0.0 0.0; offset: 0 0;} + rel2 { relative: 1.0 1.0; offset: 0 0;} + } + } + part { + name: "icon_bg"; + type: RECT; + scale : 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + visible: 0; + color: 0 0 0 0; + rel1 { relative: 0.0 0.0;to:"bg"; } + rel2 { relative: 1.0 1.0;to:"bg"; } + + } + } + + part { + name: "elm.swallow.icon"; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + rel1 { relative: 0.0 0.0; to: "icon_bg"; } + rel2 { relative: 1.0 1.0; to: "icon_bg"; } + } + } + part { + name: "elm.swallow.end"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to: "elm.swallow.icon"; } + rel2 { relative: 1.0 1.0; to: "elm.swallow.icon"; } + } + } + } + + programs { + program { + name: "movedonw_bg"; + signal: "movedown,bg,show"; + source: "bg"; + action: STATE_SET "move_down" 0.0; + target: "bg"; + } + } +} + + + + +group +{ + name: "elm/gengrid/photoframe/default_layout"; + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + } + + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_favor"; + + parts { + part { + name: "bg"; + type: RECT; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "elm.swallow.favoricon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } +#endif + } + + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_video"; + images { + image: GE_EDC_IMAGE_BUTTON_PLAY COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + part { + name: "elm.videoicon_bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } + part { + name: "elm.text.bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 0.0 1.0; + rel1 { relative: 1 0; to: "elm.videoicon_bg";} + rel2 { relative: (W-GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "elm.swallow.videoicon"; + type: IMAGE; + mouse_events: 0; + repeat_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel1 { relative: 0 0; to: "elm.videoicon_bg";} + rel2 { relative: 1 1; to: "elm.videoicon_bg";} + image.normal: GE_EDC_IMAGE_BUTTON_PLAY; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + rel1 { relative: 0.0 0.0; to: "elm.text.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.text.bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: 26; + align: 0.9 0.5; + } + } + } + } + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_video_favor"; + images { + image: GE_EDC_IMAGE_BUTTON_PLAY COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + part { + name: "elm.videoicon_bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "favoricon_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: 1 0; to: "elm.videoicon_bg";} + rel2 { relative: (FAVOR_ICON_W*2+GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } +#endif + part { + name: "elm.text.bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 0.0 1.0; +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + rel1 { relative: 1 0; to: "favoricon_bg";} +#else + rel1 { relative: 1 0; to: "elm.videoicon_bg";} +#endif + rel2 { relative: (W-GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "elm.swallow.videoicon"; + type: IMAGE; + mouse_events: 0; + repeat_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel1 { relative: 0 0; to: "elm.videoicon_bg";} + rel2 { relative: 1 1; to: "elm.videoicon_bg";} + image.normal: GE_EDC_IMAGE_BUTTON_PLAY; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + rel1 { relative: 0.0 0.0; to: "elm.text.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.text.bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: 26; + align: 0.9 0.5; + } + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "elm.swallow.favoricon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: 0.0 0.0; to: "favoricon_bg"; } + rel2 { relative: 1.0 1.0; to: "favoricon_bg"; } + } + } +#endif + } + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_video_bookmark"; + images { + image: GE_EDC_IMAGE_BUTTON_PLAY COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + part { + name: "elm.videoicon_bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "bookmarkicon_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: 1 0; to: "elm.videoicon_bg";} + rel2 { relative: (FAVOR_ICON_W*2+GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } +#endif + part { + name: "elm.text.bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 0.0 1.0; +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + rel1 { relative: 1 0; to: "bookmarkicon_bg";} +#else + rel1 { relative: 1 0; to: "elm.videoicon_bg";} +#endif + rel2 { relative: (W-GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "elm.swallow.videoicon"; + type: IMAGE; + mouse_events: 0; + repeat_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel1 { relative: 0 0; to: "elm.videoicon_bg";} + rel2 { relative: 1 1; to: "elm.videoicon_bg";} + image.normal: GE_EDC_IMAGE_BUTTON_PLAY; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + rel1 { relative: 0.0 0.0; to: "elm.text.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.text.bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: 26; + align: 0.9 0.5; + } + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "elm.swallow.bookmarkicon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + visible: 1; + rel1 { relative: 0.0 0.0; to: "bookmarkicon_bg"; } + rel2 { relative: 1.0 1.0; to: "bookmarkicon_bg"; } + } + } +#endif + } + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + +group +{ + name: "elm/gengrid/photoframe/default_layout_video_favor_bookmark"; + images { + image: GE_EDC_IMAGE_BUTTON_PLAY COMP; + } + + parts { + part { + name: "bg"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + description { + state: "shrink" 0.0; + rel1 { relative: 0.03 0.03;} + rel2 { relative: 0.97 0.97;} + color: 0 0 0 0; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { relative: GAP_W/W (GAP_H+1)/H;} + rel2 { relative: (W-GAP_W)/W 1;} + } + } + part { + name: "elm.videoicon_bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: GAP_W/W (H-FAVOR_ICON_H+1)/H;} + rel2 { relative: (FAVOR_ICON_W+GAP_W)/W 1;} + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "favoricon_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: 1 0; to: "elm.videoicon_bg";} + rel2 { relative: (FAVOR_ICON_W*2+GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "bookmarkicon_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 1.0 0.0; + rel1 { relative: 1 0; to: "favoricon_bg";} + rel2 { relative: (FAVOR_ICON_W*3+GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } +#endif + part { + name: "elm.text.bg"; + type: RECT; + mouse_events: 0; + scale : 1; + description { + state: "default" 0.0; + color: 0 0 0 130; + align: 0.0 1.0; +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + rel1 { relative: 1 0; to: "bookmarkicon_bg";} +#else + rel1 { relative: 1 0; to: "elm.videoicon_bg";} +#endif + rel2 { relative: (W-GAP_W)/W 1; to_y: "elm.videoicon_bg";} + } + } + part { + name: "elm.swallow.videoicon"; + type: IMAGE; + mouse_events: 0; + repeat_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + aspect: 1.0 1.0; + rel1 { relative: 0 0; to: "elm.videoicon_bg";} + rel2 { relative: 1 1; to: "elm.videoicon_bg";} + image.normal: GE_EDC_IMAGE_BUTTON_PLAY; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + align: 0.0 1.0; + rel1 { relative: 0.0 0.0; to: "elm.text.bg"; } + rel2 { relative: 1.0 1.0; to: "elm.text.bg"; } + color: 255 255 255 255; + text { + font: "SLP:style=Bold"; + text_class: "slp"; + size: 26; + align: 0.9 0.5; + } + } + } +#ifdef _USE_FAVOR_AND_BOOKMARK_ICON + part { + name: "elm.swallow.favoricon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: 0.0 0.0; to: "favoricon_bg"; } + rel2 { relative: 1.0 1.0; to: "favoricon_bg"; } + } + } + part { + name: "elm.swallow.bookmarkicon"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + visible: 1; + rel1 { relative: 0.0 0.0; to: "bookmarkicon_bg"; } + rel2 { relative: 1.0 1.0; to: "bookmarkicon_bg"; } + } + } +#endif + } + programs { + program { + name: "mouse_down_shrink"; + signal: "mouse,down,shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + //after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "mouse_up_expand"; + signal: "mouse,up,expand"; + source: "bg"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + + program { + name: "shrink"; + signal: "shrink"; + source: "bg"; + action: STATE_SET "shrink" 0.0; + target: "bg"; + after: "expand"; + transition: LINEAR 0.1; + } + program { + name: "expand"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: LINEAR 0.05; + after: "shrink,expand,done,icon"; + } + program { + name: "shrink,expand,done,icon"; + action: SIGNAL_EMIT "shrink,expand,done" "bg"; + } + } +} + diff --git a/ug/ug-gallery-efl/res/edc/gallery-efl-nocontents.edc b/ug/ug-gallery-efl/res/edc/gallery-efl-nocontents.edc new file mode 100755 index 0000000..f30ce8a --- /dev/null +++ b/ug/ug-gallery-efl/res/edc/gallery-efl-nocontents.edc @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define NOCONTENT_TEXT_BLOCK_TEXT_SIZE_INC 32 +#define NOCONTENT_TEXT_BLOCK_STYLE_COLOR_INC 173 170 165 255 + + group { + name: "elm/layout/nocontents/gallery_efl"; + styles{ + style { name: "nocontent_style"; + base: "font=SLP:style=Roman text_class=slp font_size="NOCONTENT_TEXT_BLOCK_TEXT_SIZE_INC" align=center color=#ffffff wrap=word"; + tag: "br" "\n"; + tag: "hilight" "+ font=SLP:style=Bold text_class=slp"; + tag: "b" "+ font=SLP:style=Bold text_class=slp"; + tag: "tab" "\t"; + } + } + images { + image: GE_EDC_IMAGE_NOCONTENTS_PIC COMP; + } + parts { + part { name: "bg"; + scale: 1; + type: RECT; + description { state: "default" 0.0; + visible: 1; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + } + } + part { name: "nocontents.image"; + description { state: "default" 0.0; + visible: 1; + align: 0.5 0.0; + rel1 { relative: 203/720 296/1016; to: "bg";} + rel2 { relative: (203+314)/720 (296+310)/1016; to: "bg";} + image { + normal: GE_EDC_IMAGE_NOCONTENTS_PIC; + border: 1 1 1 1; + border_scale: 1; + } + aspect: 1.0 1.0; + aspect_preference: BOTH; + } + } + part { name: "middle.padding"; + scale: 1; + type: RECT; + description { state: "default" 0.0; + visible: 0; + align: 0.5 0.0; + rel1 { relative: 0.0 1.0; to_y: "nocontents.image";} + rel2 { relative: 1.0 (296+310+54)/1016; to: "bg";} + } + } + part { name: "elm.text"; + type: TEXTBLOCK; + description { state: "default" 0.0; + fixed: 0 1; + align: 0.5 0.0; + visible: 1; + rel1 { relative: 0.0 1.0; to_x: "bg"; to_y: "middle.padding";} + rel2 { relative: 1.0 1.0; to: "bg";} + color: NOCONTENT_TEXT_BLOCK_STYLE_COLOR_INC; + text { + style: "nocontent_style"; + align: 0.5 0.5; + min: 0 0; + max: 0 1; + } + } + } + } + } + diff --git a/ug/ug-gallery-efl/res/edc/gallery-efl.edc b/ug/ug-gallery-efl/res/edc/gallery-efl.edc new file mode 100755 index 0000000..5b8b1c8 --- /dev/null +++ b/ug/ug-gallery-efl/res/edc/gallery-efl.edc @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define FONT_ROM "HelveticaNeue:style=Roman" +#define FONT_MED "HelveticaNeue:style=Medium" +#define SELINFO_H 48 + +#include "gallery-efl-edc-res.h" + +collections { +#include "gallery-efl-gengrid-item-thumbview.edc" +#include "gallery-efl-gengrid-item-albums.edc" +#include "gallery-efl-check.edc" +#include "gallery-efl-nocontents.edc" + + group + { + name: "gallery_efl/gridview"; + + parts { + part { + name: "background"; + type, RECT; + + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; offset: 0 0; } + rel2 { relative: 1.0 1.0; offset: -1 -1; } + color, 0 0 0 0; + } + } + + part { + name: "contents"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to: "background";} + rel2 { relative: 1.0 1.0; to: "background";} + } + description { + state: "moveup" 0.0; + rel1 { relative: 0.0 0.0; to: "background";} + rel2 { relative: 1.0 0.0; to: "elm.swallow.selinfo"; } + } + + } + part { + name: "elm.swallow.selinfo"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + min: 0 SELINFO_H; // bottom padding size for selectioninfo + fixed: 0 1; + align: 0.5 1.0; + rel1 { relative: 0.0 1.0; } + rel2 { relative: 1.0 1.0; } + visible: 0; + } + description { state: "show" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + } + + programs { + program { + name: "thumb_view_default"; + signal: "elm,thumb_view,state,default"; + source: "elm"; + script { + set_state(PART:"contents", "default", 0.0); + set_state(PART:"elm.swallow.selinfo", "default", 0.0); + } + } + program { + name: "thumb_view_moveup"; + signal: "elm,thumb_view,state,moveup"; + source: "elm"; + script { + set_state(PART:"contents", "moveup", 0.0); + set_state(PART:"elm.swallow.selinfo", "show", 0.0); + } + } + } + } + + group + { + name: "gallery_efl/albumview"; + + parts { + part { + name: "background"; + type, RECT; + + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; offset: 0 0; } + rel2 { relative: 1.0 1.0; offset: -1 -1; } + color, 0 0 0 0; + } + } + + part { + name: "contents"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to: "background";} + rel2 { relative: 1.0 1.0; to: "background";} + + } + } + } + } + group { name: "ge_bg_layout"; + parts { + part { name: "bg"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + color: 0 0 0 45; + } + } + part { name: "elm.swallow.image"; + type: SWALLOW; + description { state: "default" 0.0; + } + } + } + } diff --git a/ug/ug-gallery-efl/res/edc/images/T01_Nocontents_picture.png b/ug/ug-gallery-efl/res/edc/images/T01_Nocontents_picture.png new file mode 100755 index 0000000..0f98480 Binary files /dev/null and b/ug/ug-gallery-efl/res/edc/images/T01_Nocontents_picture.png differ diff --git a/ug/ug-gallery-efl/res/edc/images/T01_btn_play.png b/ug/ug-gallery-efl/res/edc/images/T01_btn_play.png new file mode 100755 index 0000000..0e61ed0 Binary files /dev/null and b/ug/ug-gallery-efl/res/edc/images/T01_btn_play.png differ diff --git a/ug/ug-gallery-efl/res/edc/images/T01_grid_select_check.png b/ug/ug-gallery-efl/res/edc/images/T01_grid_select_check.png new file mode 100755 index 0000000..f131f47 Binary files /dev/null and b/ug/ug-gallery-efl/res/edc/images/T01_grid_select_check.png differ diff --git a/ug/ug-gallery-efl/res/edc/images/T01_main_folder_bg.png b/ug/ug-gallery-efl/res/edc/images/T01_main_folder_bg.png new file mode 100755 index 0000000..16d1d59 Binary files /dev/null and b/ug/ug-gallery-efl/res/edc/images/T01_main_folder_bg.png differ diff --git a/ug/ug-gallery-efl/res/images/T01_Nocontents_broken.png b/ug/ug-gallery-efl/res/images/T01_Nocontents_broken.png new file mode 100755 index 0000000..9326d0a Binary files /dev/null and b/ug/ug-gallery-efl/res/images/T01_Nocontents_broken.png differ diff --git a/ug/ug-gallery-efl/res/images/T01_icon_lock.png b/ug/ug-gallery-efl/res/images/T01_icon_lock.png new file mode 100755 index 0000000..44c98da Binary files /dev/null and b/ug/ug-gallery-efl/res/images/T01_icon_lock.png differ diff --git a/ug/ug-gallery-efl/res/images/T01_icon_thumbnail_bookmark.png b/ug/ug-gallery-efl/res/images/T01_icon_thumbnail_bookmark.png new file mode 100755 index 0000000..bdb690a Binary files /dev/null and b/ug/ug-gallery-efl/res/images/T01_icon_thumbnail_bookmark.png differ diff --git a/ug/ug-gallery-efl/res/images/T01_icon_thumbnail_favorite.png b/ug/ug-gallery-efl/res/images/T01_icon_thumbnail_favorite.png new file mode 100755 index 0000000..aa9c8ef Binary files /dev/null and b/ug/ug-gallery-efl/res/images/T01_icon_thumbnail_favorite.png differ diff --git a/ug/ug-gallery-efl/src/gallery-efl.c b/ug/ug-gallery-efl/src/gallery-efl.c new file mode 100755 index 0000000..5de55a2 --- /dev/null +++ b/ug/ug-gallery-efl/src/gallery-efl.c @@ -0,0 +1,648 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UG_MODULE_API +#define UG_MODULE_API __attribute__ ((visibility("default"))) +#endif + +#include +#include "gallery-efl.h" +#include "ge-debug.h" +#include "ge-albums.h" +#include "ge-gridview.h" +#include "ge-data.h" +#include "ge-ui-util.h" +#include "ge-util.h" +#include "ge-ext-ug-load.h" +#include "ge-strings.h" +#include "ge-lang.h" + +static ge_view_mode g_view_mode = GE_VIEW_ALBUMS; + +#define GE_BG_COLOR_R 248 +#define GE_BG_COLOR_G 246 +#define GE_BG_COLOR_B 239 + +ge_view_mode _ge_get_view_mode(void) +{ + return g_view_mode; +} + +void _ge_set_view_mode(ge_view_mode mode) +{ + g_view_mode = mode; +} + +static int _ge_create_ly_view(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(ugd->navi_bar, -1); + /** + * Init libmedia-info. + * If failed, records couldn't be got from DB, cluster list is emty. + * Show warning message instead of return -1; + */ + if(_ge_data_init(ugd) != 0) + { + ge_dbgW("_ge_data_init failed!"); + } + /** + * Get cluster list from DB. + * If cluster list is empty, GE_DB_FAILED returned, + * "No contents" view would be created and showed. + * Show warning message instead of return -1; + */ + if(_ge_data_get_clusters_list(ugd) != 0) + ge_dbgW("Get clusters list failed!"); + + /* Create layout of albums view */ + ugd->albums_view_ly = ge_albums_create_ly(ugd->navi_bar); + GE_CHECK_VAL(ugd->albums_view_ly, -1); + /* Create albums view */ + ugd->albums_view = ge_albums_create_view(ugd, ugd->albums_view_ly); + GE_CHECK_VAL(ugd->albums_view, -1); + elm_object_part_content_set(ugd->albums_view_ly, "contents", + ugd->albums_view); + + ge_ui_create_title_and_push(ugd, ugd->navi_bar, ugd->albums_view_ly, + GE_NAVI_ALBUMS, ugd->albums_view_title); + return 0; +} + +static Evas_Object *_ge_create_bg(Evas_Object *parent) +{ + ge_dbg(""); + GE_CHECK_NULL(parent); + Evas_Object *bg = NULL; + + bg = elm_bg_add(parent); + /* Show special color of background */ + elm_bg_color_set(bg, GE_BG_COLOR_R, GE_BG_COLOR_G, GE_BG_COLOR_B); + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(bg); + + return bg; +} + +static int _ge_init_view(ge_ugdata *ugd) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + + /* Base Layout */ + ugd->ly_main = ge_ui_create_main_ly(ugd, ugd->win); + GE_CHECK_VAL(ugd->ly_main, -1); + /* Background */ + ugd->bg = _ge_create_bg(ugd->ly_main); + GE_CHECK_VAL(ugd->bg, -1); + /* Pack bg to swallow */ + elm_object_part_content_set(ugd->ly_main, "elm.swallow.bg", ugd->bg); + + /* Navigation Bar */ + ugd->navi_bar = ge_ui_create_navibar(ugd, ugd->ly_main); + GE_CHECK_VAL(ugd->navi_bar, -1); + + /* Albums view and its layout */ + if(_ge_create_ly_view(ugd) != 0) + { + ge_dbgE("Create albums view and layout failed!"); + return -1; + } + + return 0; +} + +static int _ge_create_view(ge_ugdata *ugd) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + /* Set inited flag as TRUE */ + ugd->b_inited_view = true; + /* Add new theme */ + ugd->th = elm_theme_new(); + GE_CHECK_VAL(ugd->th, -1); + elm_theme_ref_set(ugd->th, NULL); + elm_theme_extension_add(ugd->th, GE_EDJ_FILE); + + /* Initialize gallery ug view */ + if(_ge_init_view(ugd) != 0) + { + ge_dbgE("Initialize view failed!"); + return -1; + } + + /* Register MMC changed callback */ + if(ge_reg_db_update_noti(ugd) != 0) { + ge_dbgE("ge_reg_db_update_noti failed!"); + return -1; + } + + return 0; +} + +static int _ge_close_view(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + + GE_IF_DEL_OBJ(ugd->popup) + + GE_FREEIF(ugd->file_setas_callid_path); + GE_FREEIF(ugd->file_setas_homescreen_path); + GE_FREEIF(ugd->file_setas_lockscreen_path); + GE_FREEIF(ugd->file_setas_callid_size); + GE_FREEIF(ugd->file_setas_image_path); + GE_FREEIF(ugd->file_setas_crop_image_path); + + if(ugd->b_inited_view) { + /* Destroy UG called by me */ + if (ugd->ug_called_by_me) { + ge_dbg("Destroy ug_called_by_me"); + ug_destroy(ugd->ug_called_by_me); + ugd->ug_called_by_me = NULL; + } + + GE_IF_DEL_TIMER(ugd->del_timer) + GE_IF_DEL_TIMER(ugd->thumbs_clicked_timer) + GE_IF_DEL_IDLER(ugd->grid_append_idler) + + ge_dereg_db_update_noti(); + + ge_grid_del_callbacks(ugd); + ge_albums_del_callbacks(ugd); + + GE_IF_DEL_OBJ(ugd->navi_bar) + GE_IF_DEL_OBJ(ugd->bg) + GE_IF_DEL_OBJ(ugd->ly_main) + + ge_albums_free_cover_thumbs(ugd); + + /* Disconnet with libmedia-info */ + _ge_data_finalize(ugd); + if(ugd->th) { + elm_theme_extension_del(ugd->th, GE_EDJ_FILE); + elm_theme_free(ugd->th); + ugd->th = NULL; + } + ugd->b_inited_view = false; + } + + if(ugd->service) { + service_destroy(ugd->service); + ugd->service = NULL; + } + return 0; +} + +static int __ge_parse_param_launch_type_setas(ge_ugdata *ugd, service_h service) +{ + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(service, -1); + char *setas_type = NULL; + char *callerid_size = NULL; + char *callerid_path = NULL; + char *wallpaper_path = NULL; + char *lockscreen_path = NULL; + + service_get_extra_data(service, GE_BUNDLE_SETAS_TYPE, &setas_type); + if(setas_type == NULL) { + ge_dbgW("setas-type NULL"); + return -1; + } + + if (!strcasecmp(setas_type, GE_SETAS_WALLPAPER)) { + ugd->file_select_setas_mode = GE_SETAS_T_WALLPAPER; + g_strlcpy(ugd->albums_view_title, GE_TITLE_CHANGE_WALLPAPER, + GE_ALBUM_NAME_LEN_MAX); + + service_get_extra_data(service, GE_BUNDLE_HOMESCREEN_PATH, + &wallpaper_path); + if (wallpaper_path) { + ge_dbg("path:%s", wallpaper_path); + ugd->file_setas_homescreen_path = wallpaper_path; + } + + service_get_extra_data(service, GE_BUNDLE_LOCKSCREEN_PATH, + &lockscreen_path); + if (lockscreen_path) { + ge_dbg("path:%s", lockscreen_path); + ugd->file_setas_lockscreen_path = lockscreen_path; + } + } else if (!strcasecmp(setas_type, GE_SETAS_CROP_WALLPAPER)) { + ugd->file_select_setas_mode = GE_SETAS_T_CROP_WALLPAPER; + g_strlcpy(ugd->albums_view_title, GE_TITLE_CHANGE_WALLPAPER, + GE_ALBUM_NAME_LEN_MAX); + } else if (!strcasecmp(setas_type, GE_SETAS_CALLERID)) { + ugd->file_select_setas_mode = GE_SETAS_T_CALLERID; + g_strlcpy(ugd->albums_view_title, GE_TITLE_CHANGE_CALLER_ID, + GE_ALBUM_NAME_LEN_MAX); + + service_get_extra_data(service, GE_BUNDLE_CALLERID_SIZE, + &callerid_size); + if (callerid_size) { + ge_dbg("size:%s", callerid_size); + ugd->file_setas_callid_size = callerid_size; + } + + service_get_extra_data(service, GE_BUNDLE_CALLERID_PATH, + &callerid_path); + if (callerid_path) { + ge_dbg("path:%s", callerid_path); + ugd->file_setas_callid_path = callerid_path; + } + } + + GE_FREE(setas_type); + return 0; +} + +static int __ge_parse_param_file_type(ge_ugdata *ugd, service_h service) +{ + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(service, -1); + + char *file_type = NULL; + char file_type_str[GE_ALBUM_NAME_LEN_MAX] = {0,}; + bool b_singular = true; + + if(ugd->file_select_mode == GE_FILE_SELECT_T_MULTIPLE) + b_singular = false; + + /* file-type */ + service_get_extra_data(service, GE_BUNDLE_FILE_TYPE, &file_type); + if(file_type == NULL) { + ge_dbgW("file_type is empty!"); + goto GE_DEFAULT_FILE_TYPE; + } + ge_dbg("file_type: %s", file_type); + + if (!strcasecmp(file_type, GE_FILE_TYPE_IMAGE)) { + ugd->file_type_mode = GE_FILE_T_IMAGE; + if(b_singular) { + g_strlcat(ugd->albums_view_title, GE_TITLE_IMAGE, + sizeof(ugd->albums_view_title)); + } else { + g_strlcat(ugd->albums_view_title, GE_TITLE_IMAGES, + sizeof(ugd->albums_view_title)); + } + + GE_FREE(file_type); + return 0; + } else if (!strcasecmp(file_type, GE_FILE_TYPE_VIDEO)) { + ugd->file_type_mode = GE_FILE_T_VIDEO; + if(b_singular) { + g_strlcat(ugd->albums_view_title, GE_TITLE_VIDEO, + sizeof(ugd->albums_view_title)); + } else { + g_strlcat(ugd->albums_view_title, GE_TITLE_VIDEOS, + sizeof(ugd->albums_view_title)); + } + + GE_FREE(file_type); + return 0; + } + + +GE_DEFAULT_FILE_TYPE: + + ge_dbg("file type is default, set default type(ALL)."); + ugd->file_type_mode = GE_FILE_T_ALL; + if(b_singular) { + g_strlcpy(file_type_str, GE_TITLE_FILE, sizeof(file_type_str)); + } else { + g_strlcpy(file_type_str, GE_TITLE_FILES, sizeof(file_type_str)); + } + + g_strlcat(ugd->albums_view_title, file_type_str, + sizeof(ugd->albums_view_title)); + + return 0; +} + +/* analysis parameters */ +static int _ge_parse_param(ge_ugdata *ugd, service_h service) +{ + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(service, -1); + char *contain_drm = NULL; + char *launch_type = NULL; + + ugd->b_show_drm = false; + service_get_extra_data(service, GE_BUNDLE_DRM_TYPE, &contain_drm); + if (contain_drm) { + if (!strcasecmp(contain_drm, GE_FILE_TYPE_DRM_TRUE)) + ugd->b_show_drm = true; + GE_FREE(contain_drm); + } + + service_get_extra_data(service, GE_BUNDLE_LAUNCH_TYPE, &launch_type); + if (launch_type == NULL) { + ge_dbg("launch-type == NULL"); + return -1; + } + ge_dbg("launch-type [%s]", launch_type); + + if(!strcasecmp(launch_type, GE_LAUNCH_SELECT_ALBUM)) { + ugd->album_select_mode = GE_ALBUM_SELECT_T_ONE; + g_strlcpy(ugd->albums_view_title, GE_TITLE_ALBUMS, + GE_ALBUM_NAME_LEN_MAX); + } else if (!strcasecmp(launch_type, GE_LAUNCH_SELECT_SETAS)) { + ugd->file_select_mode = GE_FILE_SELECT_T_SETAS; + __ge_parse_param_launch_type_setas(ugd, service); + /* Checkme: Only image type is offered in SETAS case */ + ugd->file_type_mode = GE_FILE_T_IMAGE; + } else { + g_strlcpy(ugd->albums_view_title, GE_TITLE_ADD, + GE_ALBUM_NAME_LEN_MAX); + g_strlcat(ugd->albums_view_title, " ", GE_ALBUM_NAME_LEN_MAX); + + if (!strcasecmp(launch_type, GE_LAUNCH_SELECT_ONE)) + ugd->file_select_mode = GE_FILE_SELECT_T_ONE; + else if (!strcasecmp(launch_type, GE_LAUNCH_SELECT_MULTIPLE)) + ugd->file_select_mode = GE_FILE_SELECT_T_MULTIPLE; + else + ge_dbgE("Wrong launch type!"); + + __ge_parse_param_file_type(ugd, service); + } + + GE_FREE(launch_type); + return 0; +} + +/** +* @brief +* +* @param ug +* @param mode +* @param data +* @param priv +* +* @return +*/ +static void * _ge_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) +{ + ge_dbg("Enter..."); + ge_ugdata *ugd = NULL; + GE_CHECK_NULL(priv); + GE_CHECK_NULL(service); + GE_CHECK_NULL(ug); + ge_dbgW("Gallery UG start..."); + + ugd = (ge_ugdata *)priv; + ugd->ug = ug; + /* Get window */ + ugd->win = (Evas_Object *)ug_get_window(); + GE_CHECK_NULL(ugd->win); + /* Bind text domain for internalization */ + bindtextdomain("ug-gallery-efl" , "/usr/ug/res/locale"); + /* Reset inited flag, it would be set as TRUE if albums view created */ + ugd->b_inited_view = false; + /* Set view mode */ + _ge_set_view_mode(GE_VIEW_ALBUMS); + + Ecore_X_Window x_win = ecore_x_window_focus_get(); + GE_CHECK_NULL(x_win); + Ecore_X_Window root_win = ecore_x_window_root_get(x_win); + GE_CHECK_NULL(root_win); + ugd->win_scale = elm_config_scale_get(); + + service_clone(&(ugd->service), service); + + /* Parse parameters passed from parent */ + if(_ge_parse_param(ugd, service) != 0) { + ge_dbgE("Failed to parse parameters!"); + return NULL; + } + + if ((ugd->file_select_mode == GE_FILE_SELECT_T_SETAS) || + (ugd->file_select_mode != GE_FILE_SELECT_T_NONE) || + (ugd->album_select_mode != GE_ALBUM_SELECT_T_NONE)) { + /* create gallery UG */ + if(_ge_create_view(ugd) != 0) { + ge_dbgE("Failed to create Gallery UG view!"); + return NULL; + } + } else { + ge_dbgE("Wrong file_select_mode[%d] or album_select_mode[%d]", + ugd->file_select_mode, ugd->album_select_mode); + } + + return ugd->ly_main; +} + +/** +* @brief +* +* @param ug +* @param data +* @param priv +*/ +static void _ge_start(ui_gadget_h ug, service_h service, void *priv) +{ +} + +/** +* @brief +* +* @param ug +* @param data +* @param priv +*/ +static void _ge_pause(ui_gadget_h ug, service_h service, void *priv) +{ + ge_dbg(""); +} + +/** +* @brief +* +* @param ug +* @param data +* @param priv +*/ +static void _ge_resume(ui_gadget_h ug, service_h service, void *priv) +{ + ge_dbg(""); + GE_CHECK(priv); + ge_ugdata *ugd = (ge_ugdata *)priv; + /*update*/ + if (!_ge_ug_iv_get()) + { + ge_update_view(ugd, GE_UPDATE_NONE); + } +} + +/** +* @brief +* +* @param ug +* @param data +* @param priv +*/ +static void _ge_destroy(ui_gadget_h ug, service_h service, void *priv) +{ + ge_dbgW(""); + GE_CHECK(ug); + GE_CHECK(priv); + ge_ugdata *ugd = (ge_ugdata *)priv; + + _ge_close_view(ugd); + ge_dbgW("End of the gallery UG!"); +} + +/** +* @brief +* +* @param ug +* @param msg +* @param data +* @param priv +*/ +static void _ge_message(ui_gadget_h ug, service_h msg, service_h service, void *priv) +{ + ge_dbg(""); +} + +/** +* @brief +* +* @param ug +* @param event +* @param data +* @param priv +*/ +static void _ge_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv) +{ + GE_CHECK(priv); + ge_ugdata *ugd = (ge_ugdata *)priv; + int rotate_mode = GE_ROTATE_NONE; + + switch (event) + { + case UG_EVENT_LOW_MEMORY: + ge_dbg("UG_EVENT_LOW_MEMORY"); + break; + + case UG_EVENT_LOW_BATTERY: + ge_dbg("UG_EVENT_LOW_BATTERY"); + break; + + case UG_EVENT_LANG_CHANGE: + ge_dbg("UG_EVENT_LANG_CHANGE"); + _ge_lang_update(ugd); + break; + + case UG_EVENT_ROTATE_PORTRAIT: + ge_dbg("UG_EVENT_ROTATE_PORTRAIT"); + rotate_mode = GE_ROTATE_PORTRAIT; + goto UG_ROTATE_EVENT; + break; + + case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN: + ge_dbg("UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN"); + rotate_mode = GE_ROTATE_PORTRAIT_UPSIDEDOWN; + goto UG_ROTATE_EVENT; + break; + + case UG_EVENT_ROTATE_LANDSCAPE: + ge_dbg("UG_EVENT_ROTATE_LANDSCAPE"); + rotate_mode = GE_ROTATE_LANDSCAPE; + goto UG_ROTATE_EVENT; + break; + + case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN: + ge_dbg("UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN"); + rotate_mode = GE_ROTATE_LANDSCAPE_UPSIDEDOWN; + goto UG_ROTATE_EVENT; + break; + + default: + break; + } + + return; + +UG_ROTATE_EVENT: + + ge_ui_set_rotate_angle(rotate_mode); +} + +static void _ge_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv) +{ + ge_dbg(""); + GE_CHECK(ug); + + switch (event) { + case UG_KEY_EVENT_END: + ge_dbg("Receive key end event"); + ug_destroy_me(ug); + break; + + default: + break; + } +} + +/** +* @brief +* +* @param ops +* +* @return +*/ +UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops) +{ + ge_dbgW("UG_MODULE_INIT"); + ge_ugdata *ugd = NULL; + GE_CHECK_VAL(ops, -1); + + ugd = calloc(1, sizeof(ge_ugdata)); + GE_CHECK_VAL(ugd, -1); + + ops->create = _ge_create; + ops->start = _ge_start; + ops->pause = _ge_pause; + ops->resume = _ge_resume; + ops->destroy = _ge_destroy; + ops->message = _ge_message; + ops->event = _ge_event; + ops->key_event = _ge_key_event; + ops->priv = ugd; + ops->opt = UG_OPT_INDICATOR_ENABLE; + + return 0; +} + +/** +* @brief +* +* @param ops +* +* @return +*/ +UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops) +{ + struct ug_data *ugd = NULL; + GE_CHECK(ops); + + ugd = ops->priv; + GE_FREEIF(ugd); + ge_dbgW("UG_MODULE_EXIT"); +} + diff --git a/ug/ug-gallery-efl/src/ge-albums.c b/ug/ug-gallery-efl/src/ge-albums.c new file mode 100755 index 0000000..56687bb --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-albums.c @@ -0,0 +1,648 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge-debug.h" +#include "ge-albums.h" +#include "ge-gridview.h" +#include "ge-ui-util.h" +#include "ge-util.h" +#include "ge-drm.h" +#include "ge-data.h" +#include "ge-strings.h" +#include "ge-icon.h" +#include "ge-tile.h" +#include "ge-rotate-bg.h" + +static Elm_Gengrid_Item_Class album_gic; +static int gl_albums_item_cnt; +static ge_item* gl_album_items[GE_ALBUM_COVER_THUMB_NUM]; +static int gl_album_count; + +static void _ge_albums_drag_up(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_albums_drag_right(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_albums_drag_down(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_albums_drag_left(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_albums_drag_stop(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_albums_realized(void *data, Evas_Object *obj, void *event_info) +{ + //ge_dbg(""); +} + +static void _ge_albums_selected(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_albums_unselected(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_albums_clicked(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_albums_longpress(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static Eina_Bool _ge_albums_append_grid_idler(void *data) +{ + GE_CHECK_CANCEL(data); + ge_ugdata* ugd = (ge_ugdata*)data; + + /* Try to get other medias from DB and append them to gridview*/ + int ret = ge_grid_idler_append_thumbs(data); + if(ret != 0) { + ge_dbg("Failed to append grid items!"); + } else { + ge_dbg("Successful to append grid items!"); + } + + /* Remove idler after all items appended */ + GE_IF_DEL_IDLER(ugd->grid_append_idler) + + return ECORE_CALLBACK_CANCEL; +} + +static void __ge_albums_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + GE_CHECK(data); + ge_cluster *album_item = (ge_cluster*)data; + GE_CHECK(album_item->cluster); + GE_CHECK(album_item->ugd); + ge_ugdata *ugd = album_item->ugd; + if(ugd->ug == NULL) { + ge_dbg("UG already destroyed, return!"); + return; + } + + if (album_item->cluster->count == 0) { + ge_dbgW("Empty album!"); + return; + } + + ge_albums_sel_album(album_item); +} + +static char *__ge_albums_get_text(void *data, Evas_Object *obj, const char *part) +{ + GE_CHECK_NULL(part); + GE_CHECK_NULL(data); + ge_cluster *album_item = (ge_cluster *)data; + GE_CHECK_NULL(album_item->cluster); + GE_CHECK_NULL(album_item->cluster->uuid); + GE_CHECK_NULL(album_item->ugd); + ge_ugdata *ugd = album_item->ugd; + char buf[GE_FILE_PATH_LEN_MAX] = {0,}; + + if (!g_strcmp0(part, "elm.text.name")) + { + GE_CHECK_NULL(album_item->cluster->display_name); + if(_ge_data_is_root_path(album_item->cluster->path)) { + snprintf(buf, sizeof(buf), "%s", GE_ALBUM_ROOT_NAME); + buf[strlen(buf)] = '\0'; + } else if(album_item->cluster->display_name && + strlen(album_item->cluster->display_name)) { + char *new_name = _ge_ui_get_translated_album_name(album_item); + snprintf(buf, sizeof(buf), "%s", new_name); + buf[strlen(buf)] = '\0'; + } + + /* Show blue folder name */ + if (!g_strcmp0(album_item->cluster->uuid, GE_ALBUM_ALL_ID) || + _ge_data_is_default_album(GE_ALBUM_CAMERA_NAME, album_item->cluster)) { + Elm_Object_Item *grid_it = album_item->griditem; + Evas_Object *it_obj = NULL; + it_obj = elm_object_item_widget_get(grid_it); + GE_CHECK_NULL(it_obj); + edje_object_signal_emit(it_obj, "elm,name,show,blue", + "elm"); + edje_object_message_signal_process(it_obj); + } + } + else if (!g_strcmp0(part, "elm.text.date")) + { + struct tm t1; + struct tm t2; + char date1[GE_ALBUM_DATE_LEN_MAX] = {0,}; + char date2[GE_ALBUM_DATE_LEN_MAX] = {0,}; + char date3[GE_ALBUM_DATE_LEN_MAX] = {0,}; + + ge_albums_free_cover_thumbs(ugd); + + int item_count = GE_ALBUM_COVER_THUMB_NUM; + ge_item** items1 = gl_album_items; + + _ge_data_get_first_several_items(ugd, album_item, items1, + &item_count, + MEDIA_CONTENT_ORDER_DESC); + if(item_count <= 0) + { + gl_album_count = 0; + return NULL; + } + + gl_album_count = item_count; + if(items1[0] == NULL || items1[0]->item == NULL) + { + gl_album_count = 0; + return NULL; + } + memcpy(&album_item->item_mtime, &(items1[0]->item->mtime), sizeof(time_t)); + + item_count = 1; + ge_item* items2[1]; + memset(items2, 0x00, item_count * sizeof(int)); + _ge_data_get_first_several_items(ugd, album_item, items2, + &item_count, + MEDIA_CONTENT_ORDER_ASC); + + if(item_count <= 0) + { + return NULL; + } + else + { + memset(&t1, 0x00, sizeof(struct tm)); + localtime_r((time_t *) &(album_item->item_mtime), &t1); + strftime(date1, sizeof(date1), "%Y.%m.%d", &t1); + strftime(date3, sizeof(date3), "%Y.%m", &t1); + + if(items2[0] == NULL || items2[0]->item == NULL) + { + gl_album_count = 0; + return NULL; + } + memset(&t2, 0x00, sizeof(struct tm)); + localtime_r((time_t *) &(items2[0]->item->mtime), &t2); + strftime(date2, sizeof(date2), "%Y.%m.%d", &t2); + + if(!g_strcmp0(date1, date2)) + { + g_strlcpy(buf, date1, sizeof(buf)); + } + else + { + strftime(date2, sizeof(date2), "%Y.%m", &t2); + snprintf(buf, sizeof(buf), "%s - %s", date2, date3); + buf[strlen(buf)] = '\0'; + } + } + + int i = 0; + for(i = 0; i < item_count; i++) + { + _ge_data_destroy_item(items2[i]); + items2[i] = NULL; + } + } + else if (!g_strcmp0(part, "elm.text.count")) + { + _ge_data_update_items_cnt(ugd, album_item); + snprintf(buf, sizeof(buf), "%d", (int)(album_item->cluster->count)); + buf[strlen(buf)] = '\0'; + } + + return strdup(buf); +} + +static ge_icon_type __ge_albums_set_bg_file(Evas_Object *bg, void *data) +{ + ge_item *git = (ge_item *)data; + char *bg_path = GE_DEFAULT_THUMB_ICON; + ge_icon_type ret_val = GE_ICON_CORRUPTED_FILE; + + if (git == NULL || git->item == NULL) { + ge_dbgE("Invalid item :%p", git); + goto GE_ALBUMS_FAILED; + } + + /* Is it DRM file? Has a valid RO? */ + char *path = git->item->file_url; + if(ge_drm_is_drm_file(path) && + !ge_drm_check_valid_ro(path, ge_drm_get_permtype(git->item->type))) { + ret_val = GE_ICON_EXPIRED_DRM; + goto GE_ALBUMS_FAILED; + } + + ret_val= GE_ICON_NORMAL; + bg_path = _GE_GET_ICON(git->item->thumb_url); + + GE_ALBUMS_FAILED: + +#ifdef _USE_ROTATE_BG_GE + _ge_rotate_bg_set_image_file(bg, bg_path); +#else + elm_bg_file_set(bg, bg_path, NULL); +#endif + + return ret_val; +} + +static Evas_Object *__ge_albums_get_content(void *data, Evas_Object *obj, const char *part) +{ + GE_CHECK_NULL(part); + GE_CHECK_NULL(strlen(part)); + GE_CHECK_NULL(data); + ge_cluster *album_item = (ge_cluster *)data; + GE_CHECK_NULL(album_item->cluster); + GE_CHECK_NULL(album_item->ugd); + ge_ugdata *ugd = album_item->ugd; + + GE_CHECK_NULL(album_item->cluster->uuid); + const char *al_id = album_item->cluster->uuid; + ge_dbg(""); + + Evas_Object *_obj = NULL; + if (!g_strcmp0(part, GT_TILE_ONLYICON)) { + _obj = _ge_tile_show_part_icon(obj, part, gl_album_count, + ugd->win_scale, + __ge_albums_set_bg_file, + (void **)gl_album_items); + } else if (!g_strcmp0(part, GT_TILE_LABEL)) { + /** + * for "Camera", its color should be + * 25:25:25 by new gui + */ + bool b_default = false; + if (!g_strcmp0(al_id, GE_ALBUM_ALL_ID) || + _ge_data_is_default_album(GE_ALBUM_CAMERA_NAME, album_item->cluster)) + b_default = true; + _obj = _ge_tile_show_part_label(obj, album_item->index, + b_default); + + if (album_item->cluster->count <= 0) + ge_dbg("Empty album"); + } + return _obj; +} + +static int _ge_albums_create_album(ge_ugdata* ugd, Evas_Object* parent) +{ + ge_dbg(""); + GE_CHECK_VAL(parent, -1); + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(ugd->cluster_list, -1); + int i = 0; + int grid_cnt = 0; + ge_cluster *album_item = NULL; + + album_gic.item_style = "albums_view"; + album_gic.func.text_get = __ge_albums_get_text; + album_gic.func.content_get = __ge_albums_get_content; + + int length = eina_list_count(ugd->cluster_list->clist); + ge_dbg("Albums list length: %d.", length); + + elm_gengrid_clear(parent); + + if(ugd->th) + { + elm_object_theme_set(parent, ugd->th); + } + elm_object_style_set(parent, "gallery_efl/default"); + + for(i = 0; i < length; i++) + { + album_item = eina_list_nth(ugd->cluster_list->clist, i); + GE_CHECK_VAL(album_item, -1); + GE_CHECK_VAL(album_item->cluster, -1); + GE_CHECK_VAL(album_item->cluster->display_name, -1); + album_item->griditem = elm_gengrid_item_append(parent, + &album_gic, + album_item, + __ge_albums_sel_cb, + album_item); + album_item->index = grid_cnt; + grid_cnt++; + ge_dbg("Append [%s], id=%s.", album_item->cluster->display_name, + album_item->cluster->uuid); + } + + gl_albums_item_cnt = grid_cnt; + + if(grid_cnt) + { + return 0; + } + else + { + ge_dbgW("None albums appended to view!"); + return -1; + } +} + +int ge_albums_free_cover_thumbs(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + int i = 0; + + for(i = 0; i < GE_ALBUM_COVER_THUMB_NUM; i++) + { + if(gl_album_items[i]) + { + _ge_data_destroy_item(gl_album_items[i]); + gl_album_items[i] = NULL; + } + } + + return 0; +} + +int ge_albums_back_to_view(ge_ugdata *ugd) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + + if(ugd->file_select_mode == GE_FILE_SELECT_T_MULTIPLE) + { + ge_ui_destroy_selinfo(ugd); + _ge_data_selected_list_finalize(); + } + + GE_IF_DEL_IDLER(ugd->grid_append_idler) + + _ge_set_current_album(NULL); + + ge_albums_update_view(ugd); + ge_grid_clear_view(ugd); + + _ge_set_view_mode(GE_VIEW_ALBUMS); + return 0; +} + +int ge_albums_sel_album(ge_cluster* album_item) +{ + ge_dbg(""); + GE_CHECK_VAL(album_item, -1); + GE_CHECK_VAL(album_item->cluster, -1); + GE_CHECK_VAL(album_item->cluster->uuid, -1); + GE_CHECK_VAL(album_item->ugd, -1); + + if(_ge_get_view_mode() != GE_VIEW_ALBUMS) { + ge_dbgE("Wrong mode!"); + return -1; + } else { + ge_dbg("ViewMode"); + } + + ge_ugdata *ugd = album_item->ugd; + GE_CHECK_VAL(ugd->cluster_list, -1); + GE_CHECK_VAL(ugd->navi_bar, -1); + ge_dbg("Album: %s, id: %s.", album_item->cluster->display_name, + album_item->cluster->uuid); + + if(ugd->album_select_mode == GE_ALBUM_SELECT_T_ONE) { + ge_dbg("One album selected, return album id"); + service_add_extra_data(ugd->service, + GE_ALBUM_SELECT_RETURN_PATH, + album_item->cluster->path); + ge_dbg("return folder-path: %s", album_item->cluster->path); + ug_send_result(ugd->ug, ugd->service); + ug_destroy_me(ugd->ug); + ugd->ug = NULL; + return 0; + } + + /* Set current album */ + _ge_set_current_album(album_item); + /* Remove idler */ + GE_IF_DEL_IDLER(ugd->grid_append_idler) + /* Get album contents from DB */ + _ge_data_get_items_list(ugd, album_item, GE_FIRST_VIEW_START_POS, + GE_FIRST_VIEW_END_POS); + + if(ugd->file_select_mode == GE_FILE_SELECT_T_SETAS) { + ge_dbg("setas mode->thumbnail is view mode"); + _ge_set_view_mode(GE_VIEW_THUMBS); + } else { + ge_dbg("select mode->thumbnail is edit mode"); + _ge_set_view_mode(GE_VIEW_THUMBS_EDIT); + } + + ugd->thumbs_view_ly = ge_grid_create_ly(ugd->navi_bar); + GE_CHECK_VAL(ugd->thumbs_view_ly, -1); + Evas_Object* gv = NULL; + + gv = ge_grid_create_view(ugd, ugd->thumbs_view_ly); + GE_CHECK_VAL(gv, -1); + + elm_object_part_content_set(ugd->thumbs_view_ly, "contents", gv); + ugd->thumbs_view = gv; + if(gv == ugd->nocontents) + { + ugd->thumbs_nocontents = gv; + } + + /* Checkme: clear albums view for animation effect pause issue */ + elm_gengrid_clear(ugd->albums_view); + + if(_ge_get_view_mode() == GE_VIEW_THUMBS) { + /* Check root case */ + if(_ge_data_is_root_path(album_item->cluster->path)) { + ge_ui_create_title_and_push(ugd, ugd->navi_bar, + ugd->thumbs_view_ly, + GE_NAVI_THUMBS, + GE_ALBUM_ROOT_NAME); + } else { + char *new_name = _ge_ui_get_translated_album_name(album_item); + ge_ui_create_title_and_push(ugd, ugd->navi_bar, + ugd->thumbs_view_ly, + GE_NAVI_THUMBS, + new_name); + } + } else { + ge_ui_create_title_and_push(ugd, ugd->navi_bar, + ugd->thumbs_view_ly, + GE_NAVI_THUMBS, + ugd->albums_view_title); + } + + if(_ge_data_get_count_all() == (GE_FIRST_VIEW_END_POS+1)) { + ge_dbg("\n\n>>>>>>>>Use idler to append other medias--Start>>>>>>>>\n"); + ugd->grid_append_idler = ecore_idler_add(_ge_albums_append_grid_idler, ugd); + } + + ge_dbg("Done ge_albums_sel_album"); + return 0; +} + +Evas_Object* ge_albums_create_ly(Evas_Object* parent) +{ + ge_dbg(""); + GE_CHECK_NULL(parent); + Evas_Object* layout = ge_ui_load_edj(parent, GE_EDJ_FILE, GE_GRP_ALBUMVIEW); + GE_CHECK_NULL(layout); + evas_object_show (layout); + + return layout; +} + +int ge_albums_del_callbacks(ge_ugdata* ugd) +{ + GE_CHECK_VAL(ugd, -1); + if(ugd->albums_view) + { + ge_dbg("Delete albums callbacks!"); + evas_object_smart_callback_del(ugd->albums_view, "selected", _ge_albums_selected); + evas_object_smart_callback_del(ugd->albums_view, "unselected", _ge_albums_unselected); + evas_object_smart_callback_del(ugd->albums_view, "clicked", _ge_albums_clicked); + evas_object_smart_callback_del(ugd->albums_view, "longpressed", _ge_albums_longpress); + evas_object_smart_callback_del(ugd->albums_view, "drag,start,up", _ge_albums_drag_up); + evas_object_smart_callback_del(ugd->albums_view, "drag,start,right", _ge_albums_drag_right); + evas_object_smart_callback_del(ugd->albums_view, "drag,start,down", _ge_albums_drag_down); + evas_object_smart_callback_del(ugd->albums_view, "drag,start,left", _ge_albums_drag_left); + evas_object_smart_callback_del(ugd->albums_view, "drag,stop", _ge_albums_drag_stop); + evas_object_smart_callback_del(ugd->albums_view, "realized", _ge_albums_realized); + } + return 0; +} + +Evas_Object* ge_albums_create_view(ge_ugdata* ugd, Evas_Object* parent) +{ + ge_dbg(""); + GE_CHECK_NULL(parent); + GE_CHECK_NULL(ugd); + GE_CHECK_NULL(ugd->cluster_list); + + memset(gl_album_items, 0x00, GE_ALBUM_COVER_THUMB_NUM * sizeof(int)); + gl_album_count = 0; + + if(!ugd->cluster_list->clist || + (eina_list_count(ugd->cluster_list->clist) == 0)) { + ge_dbgW("Clusters list is empty!"); + goto ALBUMS_FAILED; + } + + double scale_factor = ugd->win_scale; + ge_dbg("Own scale facotr: %f, elm_config_scale_get =%f.", scale_factor, elm_config_scale_get()); + + Evas_Object *grid = elm_gengrid_add(parent); + GE_CHECK_NULL(grid); + elm_gengrid_item_size_set(grid, + (int)(GE_ALBUM_ITEM_WIDTH * scale_factor), + (int)(GE_ALBUM_ITEM_HEIGHT * scale_factor)); + elm_gengrid_align_set(grid, 0.5, 0.0); + elm_gengrid_horizontal_set(grid, EINA_FALSE); + elm_scroller_bounce_set(grid, EINA_FALSE, EINA_TRUE); + elm_gengrid_multi_select_set(grid, EINA_TRUE); + evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + if(_ge_albums_create_album(ugd, grid) != 0) + { + ge_dbgW("Failed to append album items!"); + evas_object_del(grid); + grid = NULL; + + goto ALBUMS_FAILED; + } + else + { + evas_object_show (grid); + } + + evas_object_smart_callback_add(grid, "selected", _ge_albums_selected, NULL); + evas_object_smart_callback_add(grid, "unselected", _ge_albums_unselected, NULL); + evas_object_smart_callback_add(grid, "clicked", _ge_albums_clicked, NULL); + evas_object_smart_callback_add(grid, "longpressed", _ge_albums_longpress, NULL); + evas_object_smart_callback_add(grid, "drag,start,up", _ge_albums_drag_up, NULL); + evas_object_smart_callback_add(grid, "drag,start,right", _ge_albums_drag_right, NULL); + evas_object_smart_callback_add(grid, "drag,start,down", _ge_albums_drag_down, NULL); + evas_object_smart_callback_add(grid, "drag,start,left", _ge_albums_drag_left, NULL); + evas_object_smart_callback_add(grid, "drag,stop", _ge_albums_drag_stop, NULL); + evas_object_smart_callback_add(grid, "realized", _ge_albums_realized, NULL); + + return grid; + +ALBUMS_FAILED: + /* Show no contents if none albums exist */ + ge_dbgW("@@@@@@@ To create nocontents view @@@@@@@@"); + ugd->nocontents = ge_ui_create_nocontents(ugd); + ugd->albums_view = ugd->nocontents; + evas_object_show(ugd->nocontents); + + return ugd->nocontents; +} + +int ge_albums_update_view(ge_ugdata *ugd) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(ugd->cluster_list, -1); + /* Changed to show no contents if needed */ + if(!ugd->cluster_list->clist || + (eina_list_count(ugd->cluster_list->clist) == 0)) { + ge_dbgW("Clusters list is empty!"); + goto ALBUMS_FAILED; + } + + if(ugd->nocontents && ugd->nocontents == ugd->albums_view) { + /* It is nocontents, unset it first then create albums view*/ + evas_object_del(ugd->nocontents); + ugd->nocontents = NULL; + + ugd->albums_view = ge_albums_create_view(ugd, ugd->navi_bar); + GE_CHECK_VAL(ugd->albums_view, -1); + elm_object_part_content_set(ugd->albums_view_ly, "contents", + ugd->albums_view); + evas_object_show(ugd->albums_view); + } else { + if(_ge_albums_create_album(ugd, ugd->albums_view) != 0) + goto ALBUMS_FAILED; + } + + return 0; + +ALBUMS_FAILED: + + if(ugd->albums_view && ugd->albums_view != ugd->nocontents) + ge_albums_del_callbacks(ugd); + + evas_object_del(ugd->albums_view); + + ge_dbgW("@@@@@@@ To create nocontents view @@@@@@@@"); + ugd->nocontents = ge_ui_create_nocontents(ugd); + ugd->albums_view = ugd->nocontents; + GE_CHECK_VAL(ugd->albums_view, -1); + evas_object_show(ugd->albums_view); + + elm_object_part_content_set(ugd->albums_view_ly, "contents", + ugd->albums_view); + return -1; +} diff --git a/ug/ug-gallery-efl/src/ge-button.c b/ug/ug-gallery-efl/src/ge-button.c new file mode 100755 index 0000000..1fae8d6 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-button.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge-debug.h" +#include "ge-button.h" + +Evas_Object *_ge_but_create_but(Evas_Object *parent, Elm_Theme *theme, + const char *icon, const char *text, + const char *style, But_Smart_Cb cb_func, + const void *data) +{ + Evas_Object *btn = NULL; + GE_CHECK_NULL(parent); + + btn = elm_button_add(parent); + GE_CHECK_NULL(btn); + elm_object_focus_allow_set(btn, EINA_FALSE); + + if (theme) + elm_object_theme_set(btn, theme); + + if (style) + elm_object_style_set(btn, style); + evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); + + if (icon) { + ge_dbg("Button icon: %s", icon); + Evas_Object *ic = NULL; + ic = elm_icon_add(btn); + GE_CHECK_NULL(ic); + elm_image_file_set(ic, icon, NULL); + elm_image_aspect_fixed_set(ic, EINA_TRUE); + elm_image_fill_outside_set(ic, EINA_TRUE); + evas_object_size_hint_aspect_set(ic, + EVAS_ASPECT_CONTROL_VERTICAL, + 1, 1); + evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE); + elm_object_content_set(btn, ic); + } + + if (text) { + ge_dbg("Button text: %s", text); + elm_object_text_set(btn, text); + } + + if (cb_func) + evas_object_smart_callback_add(btn, "clicked", cb_func, data); + + return btn; +} + diff --git a/ug/ug-gallery-efl/src/ge-data-type.c b/ug/ug-gallery-efl/src/ge-data-type.c new file mode 100755 index 0000000..2d5ccd2 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-data-type.c @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "ge-data-type.h" +#include "ge-debug.h" + +int _ge_data_type_new_media(ge_media_s **item) +{ + GE_CHECK_VAL(item, -1); + ge_media_s *tmp_item = (ge_media_s *)calloc(1, sizeof(ge_media_s)); + GE_CHECK_VAL(tmp_item, -1); + tmp_item->gtype = GE_TYPE_MEDIA; + *item = tmp_item; + return 0; +} + +int _ge_data_type_new_album(ge_album_s **album) +{ + GE_CHECK_VAL(album, -1); + ge_album_s *tmp_item = (ge_album_s *)calloc(1, sizeof(ge_album_s)); + GE_CHECK_VAL(tmp_item, -1); + tmp_item->gtype = GE_TYPE_ALBUM; + *album = tmp_item; + return 0; +} + + +static int __ge_data_type_free_media(ge_media_s **item) +{ + GE_CHECK_VAL(item, -1); + GE_CHECK_VAL(*item, -1); + ge_media_s *tmp_item = *item; + + /* For local medias */ + if (tmp_item->media_h) + media_info_destroy(tmp_item->media_h); + + GE_FREEIF(tmp_item->uuid); + GE_FREEIF(tmp_item->thumb_url); + GE_FREEIF(tmp_item->file_url); + GE_FREEIF(tmp_item->album_uuid); + GE_FREEIF(tmp_item->display_name); + + if (MEDIA_CONTENT_TYPE_IMAGE == tmp_item->type && + tmp_item->image_info) { + /* For local medias */ + if (tmp_item->image_info->image_h) + image_meta_destroy(tmp_item->image_info->image_h); + + GE_FREEIF(tmp_item->image_info->media_uuid); + GE_FREE(tmp_item->image_info); + } else if (MEDIA_CONTENT_TYPE_VIDEO == tmp_item->type && + tmp_item->video_info) { + /* For local medias */ + if (tmp_item->video_info->video_h) + video_meta_destroy(tmp_item->video_info->video_h); + + GE_FREEIF(tmp_item->video_info->media_uuid); + GE_FREEIF(tmp_item->video_info->title); + } + + GE_FREE(tmp_item); + *item = NULL; + return 0; +} + +int _ge_data_type_free_media_list(Eina_List **list) +{ + GE_CHECK_VAL(list, -1); + GE_CHECK_VAL(*list, -1); + ge_media_s *item = NULL; + Eina_List *tmp_list = *list; + EINA_LIST_FREE(tmp_list, item) { + if (item) + __ge_data_type_free_media(&item); + } + eina_list_free(*list); + *list = NULL; + return 0; +} + +static int __ge_data_type_free_album(ge_album_s **album) +{ + GE_CHECK_VAL(album, -1); + GE_CHECK_VAL(*album, -1); + ge_album_s *tmp_album = *album; + + GE_FREEIF(tmp_album->uuid); + GE_FREEIF(tmp_album->display_name); + GE_FREEIF(tmp_album->path); + + if (tmp_album->folder_h) + media_folder_destroy(tmp_album->folder_h); + GE_FREE(tmp_album); + *album = NULL; + return 0; +} + +int _ge_data_type_free_album_list(Eina_List **list) +{ + GE_CHECK_VAL(list, -1); + GE_CHECK_VAL(*list, -1); + ge_album_s *item = NULL; + Eina_List *tmp_list = *list; + EINA_LIST_FREE(tmp_list, item) { + if (item) + __ge_data_type_free_album(&item); + } + eina_list_free(*list); + *list = NULL; + return 0; +} + +int _ge_data_type_free_geitem(void **item) +{ + GE_CHECK_VAL(item, -1); + GE_CHECK_VAL(*item, -1); + int ret = -1; + + if(((ge_album_s *)*item)->gtype == GE_TYPE_ALBUM) + ret = __ge_data_type_free_album((ge_album_s **)item); + else if (((ge_media_s *)*item)->gtype == GE_TYPE_MEDIA) + ret = __ge_data_type_free_media((ge_media_s **)item); + + if (ret < 0) + return -1; + else + return 0; +} + + + diff --git a/ug/ug-gallery-efl/src/ge-data.c b/ug/ug-gallery-efl/src/ge-data.c new file mode 100755 index 0000000..9f0dba0 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-data.c @@ -0,0 +1,988 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge-data.h" +#include "ge-debug.h" +#include "ge-util.h" +#include "ge-drm.h" +#include "ge-strings.h" + +static int ge_all_count = 0; +static Eina_List* ge_db_item_list = NULL; +static Eina_List* ge_item_selected_list = NULL; + +#define ALBUM_ALL_LEN 4 +#define GE_DB_FILE_LEN_MAX 1024 + +/* +* create a gitem +*/ +static ge_item* __ge_data_calloc_geitem(void) +{ + ge_item* gitem = (ge_item*)calloc(1, sizeof(ge_item)); + GE_CHECK_NULL(gitem); + return gitem; +} + +/* +* destroy a ge_item +*/ +static int __ge_data_free_geitem(ge_item* gitem) +{ + if(gitem) { + if(gitem->item) { + _ge_data_type_free_geitem((void **)&(gitem->item)); + gitem->item = NULL; + } + + GE_FREEIF(gitem->_reserved); + GE_FREE(gitem); + } + return 0; +} + +static int __ge_data_free_mtype_items_list(Eina_List **elist) +{ + void *current = NULL; + + if (elist && *elist) { + ge_dbg("Clear Mitems list."); + EINA_LIST_FREE(*elist, current) { + if (current) { + _ge_data_type_free_geitem((void **)¤t); + current = NULL; + } + } + + *elist = NULL; + } + + return 0; +} + +static int __ge_data_free_items_list(void) +{ + ge_item* current = NULL; + + if (ge_db_item_list) { + ge_dbg("Clear items list."); + EINA_LIST_FREE(ge_db_item_list, current) { + __ge_data_free_geitem(current); + current = NULL; + } + } + ge_db_item_list = NULL; + ge_all_count = 0; + return 0; +} + +static int __ge_data_free_cluster(ge_cluster* gcluster) +{ + GE_CHECK_VAL(gcluster, -1); + if(gcluster->cluster) { + _ge_data_type_free_geitem((void **)&(gcluster->cluster)); + gcluster->cluster = NULL; + } + + GE_FREEIF(gcluster->_reserved); + GE_FREE(gcluster); + return 0; +} + +static int __ge_data_free_clusters_list(ge_ugdata* ugd) +{ + GE_CHECK_VAL(ugd, -1); + ge_cluster* current = NULL; + Eina_List* tmp_list = NULL; + + _ge_set_current_album(NULL); + + if(ugd->cluster_list) { + if(ugd->cluster_list->clist) { + ge_dbg("Clear clusters list."); + tmp_list = ugd->cluster_list->clist; + EINA_LIST_FREE(tmp_list, current) { + if(current) + __ge_data_free_cluster(current); + + current = NULL; + } + ugd->cluster_list->clist = NULL; + } + + GE_FREE(ugd->cluster_list); + } + + return 0; +} + +static ge_cluster_list* __ge_data_calloc_clusters_list(void) +{ + ge_cluster_list* clus_list = (ge_cluster_list*)calloc(1, + sizeof(ge_cluster_list)); + GE_CHECK_NULL(clus_list); + return clus_list; +} + +static ge_cluster* __ge_data_calloc_cluster(void) +{ + ge_cluster* gcluster = (ge_cluster*)calloc(1, sizeof(ge_cluster)); + GE_CHECK_NULL(gcluster); + return gcluster; +} + +/* Create 'All' album */ +static ge_cluster* __ge_data_new_cluster_all(ge_ugdata* ugd, int count) +{ + GE_CHECK_NULL(ugd); + ge_cluster* gcluster = __ge_data_calloc_cluster(); + GE_CHECK_NULL(gcluster); + + /* Pass -1 to get a mcluster from libmedia-info, not a real record in DB */ + ge_album_s *cluster = NULL; + _ge_data_type_new_album(&cluster); + if(cluster == NULL) { + GE_FREE(gcluster); + return NULL; + } + + cluster->uuid = strdup(GE_ALBUM_ALL_ID); + cluster->display_name = strdup(GE_ALBUM_ALL_NAME); + cluster->count = count; + cluster->type = GE_PHONE; + gcluster->cluster = cluster; + gcluster->ugd = ugd; + gcluster->index = 0; + + return gcluster; +} + +/* Case 1: Carema shot[0], All[1], ...; Case 2: All[0], ... */ +static int __ge_data_get_clusters_list(ge_ugdata* ugd) +{ + GE_CHECK_VAL(ugd, -1); + int length = 0; + int local_item_cnt = 0; + Eina_List *item_list = NULL; + ge_album_s *f_data = NULL; + ge_cluster *default_album = NULL; + ge_cluster* gcluster = NULL; + int medias_cnt = 0; + int err = -1; + ge_filter_s filter; + + /* Get real albums */ + memset(&filter, 0x00, sizeof(ge_filter_s)); + g_strlcpy(filter.cond, GE_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + if (!ugd->b_show_drm) + g_strlcat(filter.cond, GE_CONDITION_DRM, + CONDITION_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.sort_type = MEDIA_CONTENT_ORDER_ASC; + g_strlcpy(filter.sort_keyword, FOLDER_NAME, KEYWORD_LENGTH); + filter.offset = GE_GET_ALL_RECORDS; + filter.count = GE_GET_ALL_RECORDS; + filter.with_meta = false; + + err = _ge_local_data_get_album_list(&filter, &item_list); + if(err != 0) { + ge_dbgW("No record"); + if (item_list) + __ge_data_free_mtype_items_list(&item_list); + } else { + memset(&filter, 0x00, sizeof(ge_filter_s)); + if (ugd->file_type_mode == GE_FILE_T_IMAGE) + g_strlcpy(filter.cond, GE_CONDITION_IMAGE, + CONDITION_LENGTH); + else if (ugd->file_type_mode == GE_FILE_T_VIDEO) + g_strlcpy(filter.cond, GE_CONDITION_VIDEO, + CONDITION_LENGTH); + else + g_strlcpy(filter.cond, GE_CONDITION_IMAGE_VIDEO, + CONDITION_LENGTH); + if (!ugd->b_show_drm) + g_strlcat(filter.cond, GE_CONDITION_DRM, + CONDITION_LENGTH); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_DISPLAY_NAME, + KEYWORD_LENGTH); + filter.offset = GE_GET_ALL_RECORDS; + filter.count = GE_GET_ALL_RECORDS; + filter.with_meta = false; + } + Eina_List* clist = ugd->cluster_list->clist; + EINA_LIST_FREE(item_list, f_data) { + if (f_data == NULL || f_data->uuid == NULL) { + /* Invalid data, next one */ + ge_dbgE("Invalid ge_album_s!"); + continue; + } + ge_dbg("Cluster ID: %s.", f_data->uuid); + if (f_data->count == 0) { + ge_dbgE("The count of album is zero!"); + _ge_data_type_free_geitem((void **)&f_data); + continue; + } + + /* only image is valid in setas mode. */ + if (ugd->file_type_mode == GE_FILE_T_IMAGE || + ugd->file_type_mode == GE_FILE_T_VIDEO) { + err = _ge_local_data_get_media_count(f_data->uuid, + &filter, + &medias_cnt); + if(err == 0) { + f_data->count = medias_cnt; + } else { + f_data->count = 0; + ge_dbgW("minfo_get_cluster_cnt[err:%d]", err); + } + } + if(f_data->count == 0) { + ge_dbgW("local album is empty, skipping it."); + _ge_data_type_free_geitem((void **)&f_data); + continue; + } else { + local_item_cnt += f_data->count; + } + gcluster = __ge_data_calloc_cluster(); + if(gcluster == NULL) { + ge_dbgE("__ge_data_calloc_cluster failed!"); + _ge_data_type_free_geitem((void **)&f_data); + continue; + } + + gcluster->cluster = f_data; + gcluster->ugd = ugd; + length += f_data->count; + + if (_ge_data_is_default_album(GE_ALBUM_CAMERA_NAME, f_data)) { + /** + * Default album: Camera Shot + * Now Camera Shot is located in Phone. + * If user can determine the location of default album, + * here we should get the path and check it's in Phone or MMC. + */ + default_album = gcluster; + clist = eina_list_prepend(clist, gcluster); + } else if (_ge_data_is_default_album(GE_ALBUM_DOWNLOAD_NAME, f_data)) { + if (default_album) + clist = eina_list_append_relative(clist, gcluster, + default_album); + else + clist = eina_list_prepend(clist, gcluster); + } else { + clist = eina_list_append(clist, gcluster); + } + ugd->cluster_list->clist = clist; + } + ge_dbg("Get local clusters list Done[%d]!", local_item_cnt); + if(local_item_cnt) { + /* Create "All" album if any file exists */ + gcluster = __ge_data_new_cluster_all(ugd, local_item_cnt); + GE_CHECK_VAL(gcluster, -1); + + if(default_album) + clist = eina_list_append_relative(clist, gcluster, + default_album); + else + clist= eina_list_prepend(clist, gcluster); + + ugd->cluster_list->clist = clist; + ge_dbg("Cluster All added!"); + } + + return length; +} + +static int __ge_data_get_selected_item_id_list(Eina_List **sel_id_list) +{ + GE_CHECK_VAL(sel_id_list, -1); + GE_CHECK_VAL(ge_item_selected_list, -1); + ge_item *gitem = NULL; + char *item_id = NULL; + + /* Save ID of selected items */ + EINA_LIST_FREE(ge_item_selected_list, gitem) { + if (gitem && gitem->item && gitem->item->uuid) { + item_id = strdup(gitem->item->uuid); + //ge_dbg("Append item ID: %s", item_id); + *sel_id_list = eina_list_append(*sel_id_list, + (void *)item_id); + } + } + + _ge_data_selected_list_finalize(); + return 0; +} + +/* Free list of selected IDs */ +static int __ge_data_free_selected_id_list(Eina_List **sel_id_list) +{ + GE_CHECK_VAL(sel_id_list, -1); + if (*sel_id_list == NULL) { + ge_dbg("sel_id_list is empty!"); + return -1; + } + + void *p_id = NULL; + EINA_LIST_FREE(*sel_id_list, p_id) { + if (p_id == NULL) { + ge_dbgE("Invalid p_id!"); + continue; + } + GE_FREE(p_id); + } + *sel_id_list = NULL; + return 0; +} + +/* Check ID is in the list or not */ +static bool __ge_data_check_selected_id(Eina_List **sel_id_list, const char *id) +{ + GE_CHECK_FALSE(sel_id_list); + GE_CHECK_FALSE(id); + Eina_List *tmp_elist = NULL; + void *p_id = NULL; + + if (eina_list_count(*sel_id_list) == 0) { + ge_dbgE("sel_id_list is empty!"); + return false; + } + + EINA_LIST_FOREACH(*sel_id_list, tmp_elist, p_id) { + if (p_id == NULL) { + ge_dbgE("Invalid p_id!"); + continue; + } + if (g_strcmp0(id, p_id)) { + p_id = NULL; + continue; + } + + *sel_id_list = eina_list_remove(*sel_id_list, p_id); + GE_FREE(p_id); + return true; + } + return false; +} + +int _ge_data_update_items_cnt(ge_ugdata* ugd, ge_cluster *album) +{ + GE_CHECK_VAL(album, -1); + GE_CHECK_VAL(album->cluster, -1); + GE_CHECK_VAL(album->cluster->uuid, -1); + GE_CHECK_VAL(ugd, -1); + int err = -1; + int item_count = 0; + + ge_filter_s filter; + memset(&filter, 0x00, sizeof(ge_filter_s)); + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.offset = GE_GET_ALL_RECORDS; + filter.count = GE_GET_ALL_RECORDS; + g_strlcpy(filter.cond, GE_CONDITION_IMAGE_VIDEO, CONDITION_LENGTH); + filter.with_meta = false; + + if(ugd->file_type_mode == GE_FILE_T_IMAGE) + g_strlcpy(filter.cond, GE_CONDITION_IMAGE, CONDITION_LENGTH); + else if(ugd->file_type_mode == GE_FILE_T_VIDEO) + g_strlcpy(filter.cond, GE_CONDITION_VIDEO, CONDITION_LENGTH); + + if (!ugd->b_show_drm) + g_strlcat(filter.cond, GE_CONDITION_DRM, CONDITION_LENGTH); + + if(g_strcmp0(album->cluster->uuid, GE_ALBUM_ALL_ID)) { + /* Local album */ + err = _ge_local_data_get_media_count(album->cluster->uuid, + &filter, + &item_count); + } else { + /* "All albums" album */ + ge_dbg("all media count"); + err = _ge_local_data_get_all_media_count(&filter, &item_count); + } + if(err < 0) { + ge_dbgE("Get item count failed(%d)!", err); + return -1; + } + + ge_dbg("cluster media count : old=%d, new=%d", album->cluster->count, + item_count); + album->cluster->count = item_count; + + return 0; +} + +int _ge_data_get_clusters_list(ge_ugdata* ugd) +{ + GE_CHECK_VAL(ugd, -1); + int n_entire_items = 0; + + __ge_data_free_clusters_list(ugd); + + ugd->cluster_list = __ge_data_calloc_clusters_list(); + GE_CHECK_VAL(ugd->cluster_list, -1); + + n_entire_items = __ge_data_get_clusters_list(ugd); + ge_dbg("Total media items count:%d", n_entire_items); + /* if error code is returned, negative value is possible */ + if(n_entire_items <= 0) + return -1; + + return 0; +} + +/* Clear items list */ +int _ge_data_free_items_list(void) +{ + return __ge_data_free_items_list(); +} + +int _ge_data_get_items_list(ge_ugdata* ugd, ge_cluster *album, int start_pos, + int end_pos) +{ + GE_CHECK_VAL(album, -1); + GE_CHECK_VAL(album->cluster, -1); + GE_CHECK_VAL(album->cluster->uuid, -1); + GE_CHECK_VAL(ugd, -1); + Eina_List* itemlist = NULL; + int err = -1; + ge_filter_s filter; + + memset(&filter, 0, sizeof(ge_filter_s)); + ge_dbg("--start_pos[%d], end_pos[%d]--", start_pos, end_pos); + if(ugd->file_type_mode == GE_FILE_T_IMAGE) { + g_strlcpy(filter.cond, GE_CONDITION_IMAGE, CONDITION_LENGTH); + } else if (ugd->file_type_mode == GE_FILE_T_VIDEO) { + g_strlcpy(filter.cond, GE_CONDITION_VIDEO, CONDITION_LENGTH); + } else { + g_strlcpy(filter.cond, GE_CONDITION_IMAGE_VIDEO, + CONDITION_LENGTH); + } + if (!ugd->b_show_drm) + g_strlcat(filter.cond, GE_CONDITION_DRM, CONDITION_LENGTH); + + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.offset = start_pos; + filter.count = end_pos - start_pos + 1; + filter.with_meta = true; + + if (start_pos == (GE_FIRST_VIEW_END_POS+1) && + end_pos == GE_GET_UNTIL_LAST_RECORD) { + /* Keep medias_elist and medias_cnt unchanged */ + ge_dbg("Gridview append idler; Keep ge_db_item_list unchanged."); + } else { + /*Clear item list before new one got */ + __ge_data_free_items_list(); + } + + if(g_strcmp0(album->cluster->uuid, GE_ALBUM_ALL_ID)) { + /* real album */ + ge_dbg("--Real album--"); + err = _ge_local_data_get_album_media_list(album->cluster->uuid, + &filter, + &itemlist); + } else { + /* add "All" album */ + ge_dbg("--Album All--"); + err = _ge_local_data_get_all_albums_media_list(&filter, + &itemlist); + } + + if((err == 0) && (itemlist != NULL)) { + ge_media_s *item = NULL; + ge_item* gitem = NULL; + EINA_LIST_FREE(itemlist, item) + { + if (item == NULL || item->uuid == NULL) { + ge_dbgE("Invalid item!"); + continue; + } + + gitem = __ge_data_calloc_geitem(); + if(gitem == NULL) { + ge_dbgE("__ge_data_calloc_geitem() failed"); + _ge_data_type_free_geitem((void **)&item); + continue; + } + + gitem->item = item; + gitem->ugd = ugd; + ge_db_item_list = eina_list_append(ge_db_item_list, + gitem); + item = NULL; + gitem = NULL; + } + + ge_all_count = eina_list_count(ge_db_item_list); + } else { + /* Free Mitems */ + if (itemlist) + __ge_data_free_mtype_items_list(&itemlist); + + if (start_pos == (GE_FIRST_VIEW_END_POS+1) && + end_pos == GE_GET_UNTIL_LAST_RECORD) { + /* Keep medias_elist and medias_cnt unchanged */ + ge_all_count = eina_list_count(ge_db_item_list); + ge_dbg("Gridview append idler."); + } else { + ge_all_count = 0; + } + } + ge_dbg("DB all count : %d, ge_db_item_list=%p", ge_all_count, + ge_db_item_list); + + return err; +} + +/* Update items list, especially used in thumbnails edit view */ +int _ge_data_update_items_list(ge_ugdata* ugd, ge_cluster *album) +{ + GE_CHECK_VAL(album, -1); + GE_CHECK_VAL(album->cluster, -1); + GE_CHECK_VAL(album->cluster->uuid, -1); + GE_CHECK_VAL(ugd, -1); + Eina_List* itemlist = NULL; + int err = -1; + ge_dbg("Update content of %s", album->cluster->display_name); + int view_mode = _ge_get_view_mode(); + Eina_List *sel_id_list = NULL; + + if (view_mode == GE_VIEW_THUMBS_EDIT && + ugd->file_select_mode != GE_FILE_SELECT_T_ONE) { + ge_dbg("Edit view for multiple selection."); + /* Get ID list of selected items */ + __ge_data_get_selected_item_id_list(&sel_id_list); + } + ge_filter_s filter; + memset(&filter, 0x00, sizeof(ge_filter_s)); + + if(ugd->file_type_mode == GE_FILE_T_IMAGE) { + g_strlcpy(filter.cond, GE_CONDITION_IMAGE, CONDITION_LENGTH); + } else if (ugd->file_type_mode == GE_FILE_T_VIDEO) { + g_strlcpy(filter.cond, GE_CONDITION_VIDEO, CONDITION_LENGTH); + } else { + g_strlcpy(filter.cond, GE_CONDITION_IMAGE_VIDEO, + CONDITION_LENGTH); + } + + if (!ugd->b_show_drm) + g_strlcat(filter.cond, GE_CONDITION_DRM, CONDITION_LENGTH); + + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.offset = GE_GET_ALL_RECORDS; + filter.count = GE_GET_ALL_RECORDS; + filter.with_meta = true; + + /*Clear item list before new one got */ + __ge_data_free_items_list(); + + if(g_strcmp0(album->cluster->uuid, GE_ALBUM_ALL_ID)) { + err = _ge_local_data_get_album_media_list(album->cluster->uuid, + &filter, + &itemlist); + } else { + err = _ge_local_data_get_all_albums_media_list(&filter, + &itemlist); + } + + if ((err != 0) || (itemlist == NULL)) { + ge_dbgE("(err != 0) || (itemlist == NULL)"); + /* Free Mitems */ + if (itemlist) + __ge_data_free_mtype_items_list(&itemlist); + ge_all_count = 0; + return err; + } + + bool b_selected = false; + ge_media_s *item = NULL; + ge_item* gitem = NULL; + EINA_LIST_FREE(itemlist, item) { + if (item == NULL || item->uuid == NULL) { + ge_dbgE("Invalid item!"); + continue; + } + gitem = __ge_data_calloc_geitem(); + if(gitem == NULL) { + ge_dbgE("__ge_data_calloc_geitem() failed"); + _ge_data_type_free_geitem((void **)&item); + continue; + } + + gitem->item = item; + gitem->ugd = ugd; + ge_db_item_list = eina_list_append(ge_db_item_list, gitem); + + if (sel_id_list) { + b_selected = __ge_data_check_selected_id(&sel_id_list, + item->uuid); + if (b_selected) { + b_selected = false; + /* Set checkbox state */ + gitem->checked = true; + /* Append gitem to selected list */ + _ge_data_selected_list_append(gitem); + } + } + + item = NULL; + gitem = NULL; + } + + /* Clear list of selected ID */ + if (sel_id_list) + __ge_data_free_selected_id_list(&sel_id_list); + + ge_all_count = eina_list_count(ge_db_item_list); + ge_dbg("DB all count : %d, ge_db_item_list=%p", ge_all_count, + ge_db_item_list); + + return err; +} + +int _ge_data_get_first_several_items(ge_ugdata* ugd, ge_cluster *album, + ge_item* items[], int *item_count, + media_content_order_e sort_type) +{ + GE_CHECK_VAL(item_count, -1); + GE_CHECK_VAL(items, -1); + GE_CHECK_VAL(album, -1); + GE_CHECK_VAL(album->cluster, -1); + GE_CHECK_VAL(album->cluster->uuid, -1); + GE_CHECK_VAL(ugd, -1); + + Eina_List *item_list = NULL; + int result_cnt = 0; + ge_media_s *item = NULL; + ge_item* gitem = NULL; + int err = -1; + + if (*item_count <= 0) { + ge_dbgE("*item_count <= 0"); + return -1; + } + + ge_filter_s filter; + memset(&filter, 0x00, sizeof(ge_filter_s)); + + if (ugd->file_type_mode == GE_FILE_T_IMAGE) { + g_strlcpy(filter.cond, GE_CONDITION_IMAGE, CONDITION_LENGTH); + } else if (ugd->file_type_mode == GE_FILE_T_VIDEO) { + g_strlcpy(filter.cond, GE_CONDITION_VIDEO, CONDITION_LENGTH); + } else { + g_strlcpy(filter.cond, GE_CONDITION_IMAGE_VIDEO, + CONDITION_LENGTH); + } + if (!ugd->b_show_drm) + g_strlcat(filter.cond, GE_CONDITION_DRM, CONDITION_LENGTH); + + filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + filter.sort_type = sort_type; + g_strlcpy(filter.sort_keyword, MEDIA_MODIFIED_TIME, KEYWORD_LENGTH); + filter.offset = 0; + filter.count = *item_count; + filter.with_meta = false; + + if(g_strcmp0(album->cluster->uuid, GE_ALBUM_ALL_ID)) { + /*real album */ + err = _ge_local_data_get_album_media_list(album->cluster->uuid, + &filter, + &item_list); + if (err != 0 || item_list == NULL) { + ge_dbgE("Get albums media list failed[%d]!", err); + goto DB_FAILED; + } + } else { + /* add "All" album */ + err = _ge_local_data_get_all_albums_media_list(&filter, + &item_list); + if (err != 0 || item_list == NULL) { + ge_dbgE("Get all albums media list failed[%d]!", err); + goto DB_FAILED; + } + } + + EINA_LIST_FREE(item_list, item) { + if (item == NULL) { + ge_dbgE("Invalid ge_meida_s!"); + continue; + } + result_cnt++; + if(result_cnt <= *item_count) { + gitem = NULL; + gitem = __ge_data_calloc_geitem(); + if (gitem == NULL) { + ge_dbgE("__ge_data_calloc_geitem failed!"); + _ge_data_type_free_geitem((void **)&item); + result_cnt--; + continue; + } + gitem->item = item; + items[result_cnt-1] = gitem; + } else { + _ge_data_type_free_geitem((void **)&item); + } + item = NULL; + } + + if(*item_count > result_cnt) + *item_count = result_cnt; + + ge_dbg("First %d items of [%s]", *item_count, + album->cluster->display_name); + return *item_count; + + DB_FAILED: + *item_count = 0; + /* Free Mitems */ + if (item_list) + __ge_data_free_mtype_items_list(&item_list); + return -1; +} + +int _ge_data_del_media_id(ge_ugdata* ugd, const char *media_id) +{ + GE_CHECK_VAL(media_id, -1); + int ret = media_info_delete_from_db(media_id); + if(ret != 0) { + ge_dbgE("Delete media failed[%d]!", ret); + return -1; + } + + return 0; +} + +int _ge_data_item_list_remove(ge_item* gitem) +{ + GE_CHECK_VAL(gitem, -1); + GE_CHECK_VAL(gitem->item, -1); + GE_CHECK_VAL(gitem->item->uuid, -1); + ge_item* current = NULL; + Eina_List* l = NULL; + + EINA_LIST_FOREACH(ge_db_item_list, l, current) { + + if (current == NULL || current->item == NULL || + current->item->uuid == NULL) { + ge_dbgE("Invalid gitem!"); + continue; + } + if (!g_strcmp0(current->item->uuid, gitem->item->uuid)) { + ge_db_item_list = eina_list_remove(ge_db_item_list, + current); + ge_all_count--; + __ge_data_free_geitem(current); + current = NULL; + break; + } + } + return 0; +} + +int _ge_data_destroy_item(ge_item * gitem) +{ + GE_CHECK_VAL(gitem, -1); + + __ge_data_free_geitem(gitem); + return 0; +} + +int _ge_data_get_item_by_index(ge_item** gitem, int idx) +{ + GE_CHECK_VAL(gitem, -1); + + if (idx > ge_all_count) { + ge_dbgW("Get item(%d)failed!", idx); + *gitem = NULL; + return -1; + } + + *gitem = eina_list_nth(ge_db_item_list, idx -1); + return 0; +} + +int _ge_data_get_count_all(void) +{ + return ge_all_count; +} + +int _ge_data_get_selected_item_by_index(ge_item** gitem, int idx) +{ + GE_CHECK_VAL(gitem, -1); + + if (idx > _ge_data_selected_list_count()) { + ge_dbgW("Get selected item(%d)failed!", idx); + *gitem = NULL; + return -1; + } + + *gitem = eina_list_nth(ge_item_selected_list, idx -1); + return 0; +} + +int _ge_data_selected_list_count(void) +{ + return eina_list_count(ge_item_selected_list); +} + +Eina_List* _ge_data_get_selected_list(void) +{ + return ge_item_selected_list; +} + +int _ge_data_selected_list_append(ge_item* gitem) +{ + GE_CHECK_VAL(gitem, -1); + + ge_item_selected_list = eina_list_append(ge_item_selected_list, gitem); + return 0; +} + +int _ge_data_selected_list_remove(ge_item* gitem) +{ + GE_CHECK_VAL(gitem, -1); + GE_CHECK_VAL(gitem->item, -1); + GE_CHECK_VAL(gitem->item->uuid, -1); + ge_item* current = NULL; + Eina_List* l = NULL; + + EINA_LIST_FOREACH(ge_item_selected_list, l, current) { + if(current == NULL || current->item == NULL || + current->item->uuid == NULL) { + ge_dbgE("Invald gitem!"); + continue; + } + if(!g_strcmp0(current->item->uuid, gitem->item->uuid)) { + ge_item_selected_list = eina_list_remove(ge_item_selected_list, + current); + break; + } + } + return 0; +} + +int _ge_data_selected_list_finalize(void) +{ + ge_item* gitem = NULL; + + EINA_LIST_FREE(ge_item_selected_list, gitem) { + if(gitem) + gitem->checked = false; + } + + ge_item_selected_list = NULL; + return 0; +} + +/* +* Check it's default album[Camera shot] or not +*/ +bool _ge_data_is_default_album(const char *match_folder, ge_album_s *album) +{ + GE_CHECK_FALSE(album); + GE_CHECK_FALSE(album->display_name); + GE_CHECK_FALSE(match_folder); + int ret = -1; + + /* Name is 'Camera shot' and folder locates in Phone */ + ret = g_strcmp0(album->display_name, match_folder); + if (ret == 0 && album->type == GE_PHONE) { + ge_dbg("Full path: %s", album->path); + /* Get parent directory */ + char *parent_path = ecore_file_dir_get(album->path); + GE_CHECK_FALSE(parent_path); + ge_dbg("Parent path: %s", parent_path); + + /* Parent directory is same as Phone root path, it's default folder */ + ret = g_strcmp0(parent_path, GE_ROOT_PATH_PHONE); + GE_FREE(parent_path); + + if (ret == 0) { + ge_dbgW("Default folder!"); + return true; + } + } + + return false; +} + +bool _ge_data_is_root_path(const char *path) +{ + GE_CHECK_FALSE(path); + + if(!g_strcmp0(GE_ROOT_PATH_PHONE, path) || + !g_strcmp0(GE_ROOT_PATH_MMC, path)) { + ge_dbg("Root path: %s", path); + return true; + } + + return false; +} + +/* Creates a thumbnail image for given the media, asynchronously */ +int _ge_data_create_thumb(ge_item *gitem, media_thumbnail_completed_cb callback, + void *user_data) +{ + GE_CHECK_VAL(gitem, -1); + GE_CHECK_VAL(gitem->item, -1); + GE_CHECK_VAL(gitem->item->media_h, -1); + int ret = -1; + ge_dbg("File[%s]", gitem->item->file_url); + + ret = media_info_create_thumbnail(gitem->item->media_h, callback, + user_data); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Failed to create thumbnail!"); + return -1; + } + return 0; +} + +int _ge_data_init(ge_ugdata* ugd) +{ + ge_dbg("Connect to DB!"); + GE_CHECK_VAL(ugd, -1); + int err = _ge_local_data_connect(); + if (err != 0) { + ge_dbgE("Local connection failed[%d]!", err); + return -1; + } + + return 0; +} + +int _ge_data_finalize(ge_ugdata* ugd) +{ + ge_dbg("Free memory and disconnect with DB!"); + GE_CHECK_VAL(ugd, -1); + __ge_data_free_clusters_list(ugd); + __ge_data_free_items_list(); + + int err = _ge_local_data_disconnect(); + if (err != 0) { + ge_dbgE("Local disconnection failed[%d]!", err); + return -1; + } + return 0; +} + diff --git a/ug/ug-gallery-efl/src/ge-debug.c b/ug/ug-gallery-efl/src/ge-debug.c new file mode 100755 index 0000000..c624454 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-debug.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "ge-debug.h" + +#ifdef _USE_LOG_FILE_ +static char _g_file_path[GE_DB_FILE_LEN_MAX] = { 0, }; +#endif + + diff --git a/ug/ug-gallery-efl/src/ge-drm.c b/ug/ug-gallery-efl/src/ge-drm.c new file mode 100755 index 0000000..9701a75 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-drm.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "gallery-efl.h" +#include "ge-ui-util.h" +#include "ge-debug.h" +#include "ge-drm.h" +#include "ge-icon.h" + +int ge_drm_get_permtype(int gitem_type) +{ + switch (gitem_type) { + case MEDIA_CONTENT_TYPE_IMAGE: + return DRM_PERMISSION_TYPE_DISPLAY; + case MEDIA_CONTENT_TYPE_VIDEO: + return DRM_PERMISSION_TYPE_PLAY; + default: + return -1; + } +} + +Eina_Bool ge_drm_check_valid_ro(const char *file_path, + drm_permission_type_e permType) +{ + GE_CHECK_FALSE(file_path); + ge_dbg("file_path: %s", file_path); + int ret = -1; + + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + ret = drm_get_license_status(file_path, permType, &license_status); + if (DRM_RETURN_SUCCESS == ret && + DRM_LICENSE_STATUS_VALID == license_status) { + return EINA_TRUE; + } else { + ge_dbg("No valid ro, return %d", license_status); + return EINA_FALSE; + } +} + +Eina_Bool ge_drm_is_drm_file(const char* file_path) +{ + GE_CHECK_FALSE(file_path); + ge_dbg("file_path: %s.", file_path); + + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + if(drm_is_drm_file(file_path, &is_drm_file) != DRM_RETURN_SUCCESS) { + ge_dbgE("drm_is_drm_file error"); + return EINA_FALSE; + } + + if (DRM_TRUE == is_drm_file) + return EINA_TRUE; + return EINA_FALSE; +} + +char* ge_drm_get_file_path(void *item) +{ + ge_item* gitem = (ge_item *)item; + + if(!gitem || !gitem->item || !gitem->item->file_url) + return NULL; + ge_dbg("filepath: %s", gitem->item->file_url); + + if(ge_drm_is_drm_file(gitem->item->file_url)) + return strdup(GE_DEFAULT_THUMB_ICON); + else + return strdup(gitem->item->file_url); +} + diff --git a/ug/ug-gallery-efl/src/ge-exif.c b/ug/ug-gallery-efl/src/ge-exif.c new file mode 100755 index 0000000..a95c72d --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-exif.c @@ -0,0 +1,1361 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The Exif specification defines an Orientation Tag to indicate the orientation of the + * camera relative to the captured scene. This can be used by the camera either to + * indicate the orientation automatically by an orientation sensor, + * or to allow the user to indicate the orientation manually by a menu switch, + * without actually transforming the image data itself. + * Here is an explanation given by TsuruZoh Tachibanaya in + * his description of the Exif file format: + * + * The orientation of the camera relative to the scene, when the image was captured. + * The relation of the '0th row' and '0th column' to visual position is shown as below. + * + * Value 0th Row 0th Column + * 1 top left side + * 2 top right side + * 3 bottom right side + * 4 bottom left side + * 5 left side top + * 6 right side top + * 7 right side bottom + * 8 left side bottom + * + * Read this table as follows (thanks to Peter Nielsen for clarifying this - see also below): + * Entry #6 in the table says that the 0th row in the stored image is the right side of + * the captured scene, and the 0th column in the stored image is the top side of + * the captured scene. + * + * Here is another description given by Adam M. Costello: + * + * For convenience, here is what the letter F would look like if it were tagged correctly + * and displayed by a program that ignores the orientation tag + * (thus showing the stored image): + * + * 1 2 3 4 5 6 7 8 + * + * 888888 888888 88 88 8888888888 88 88 8888888888 + * 88 88 88 88 88 88 88 88 88 88 88 88 + * 8888 8888 8888 8888 88 8888888888 8888888888 88 + * 88 88 88 88 + * 88 88 888888 888888 +*/ + +#ifdef _USE_ROTATE_BG_GE + +#include +#include +#include +#include +#include "ge-exif.h" +#include "ge-debug.h" +#include "ge-data-type.h" + +#define GE_EXIF_BUF_LEN_MAX 65536L +#define GE_EXIF_BUF_TIME_LEN_MAX 20 +#define GE_EXIF_DEFAULT_YEAR 1900 + +#define GE_EXIF_SOI 0xD8 +#define GE_EXIF_TAG 0xFF +#define GE_EXIF_APP0 0xE0 +#define GE_EXIF_APP1 0xE1 +#define GE_EXIF_JFIF_00 0x00 +#define GE_EXIF_JFIF_01 0x01 +#define GE_EXIF_JFIF_02 0x02 + +#define GE_EXIF_IFD_DATA_FORMAT_UNSIGNED_BYTE 1 +#define GE_EXIF_IFD_DATA_FORMAT_ASCII_STRINGS 1 +#define GE_EXIF_IFD_DATA_FORMAT_UNSIGNED_SHORT 2 +#define GE_EXIF_IFD_DATA_FORMAT_UNSIGNED_LONG 4 +#define GE_EXIF_IFD_DATA_FORMAT_UNSIGNED_RATIONAL 8 +#define GE_EXIF_IFD_DATA_FORMAT_SIGNED_BYTE 1 +#define GE_EXIF_IFD_DATA_FORMAT_UNDEFINED 1 +#define GE_EXIF_IFD_DATA_FORMAT_SIGNED_SHORT 2 +#define GE_EXIF_IFD_DATA_FORMAT_SIGNED_LONG 4 +#define GE_EXIF_IFD_DATA_FORMAT_SIGNED_RATIONAL 8 +#define GE_EXIF_IFD_DATA_FORMAT_SIGNED_FLOAT 4 +#define GE_EXIF_IFD_DATA_FORMAT_DOUBLE_FLOAT 8 + +#define GE_EXI_TMP_JPEG_FILE "/opt/usr/apps/org.tizen.gallery/data/.gallery_tmp_write_exif.jpg" + +/* Write one byte, testing for EOF */ +static int __ge_exif_write_1_byte(FILE *fd, int c) +{ + if (fputc(c, fd) < 0) { + ge_dbgE("fputc failed!"); + return -1; + } + + return 0; +} + +/* Read one byte, testing for EOF */ +static int __ge_exif_read_1_byte(FILE *fd) +{ + int c = 0; + + /* Return next input byte, or EOF if no more */ + c = getc(fd); + if (c == EOF) { + ge_dbgE("Premature EOF in JPEG file!"); + return -1; + } + + return c; +} + +/* Read 2 bytes, convert to unsigned int */ +/* All 2-byte quantities in JPEG markers are MSB first */ +static int __ge_exif_read_2_bytes(FILE *fd, unsigned int *len) +{ + int c1 = 0; + int c2 = 0; + + /* Return next input byte, or EOF if no more */ + c1 = getc(fd); + if (c1 == EOF) { + ge_dbgE("Premature EOF in JPEG file!"); + return -1; + } + + /* Return next input byte, or EOF if no more */ + c2 = getc(fd); + if (c2 == EOF) { + ge_dbgE("Premature EOF in JPEG file!"); + return -1; + } + + if (len) + *len = (((unsigned int)c1) << 8) + ((unsigned int)c2); + + return 0; +} + +/* Add raw exif tag and data */ +static int __ge_exif_add_header(FILE *fd, unsigned int *orientation) +{ + GE_CHECK_VAL(orientation, -1); + GE_CHECK_VAL(fd, -1); + int i = 0; + int ret = -1; + char *time_buf = NULL; + unsigned int offset = 0; + + /* raw EXIF header data */ + const unsigned char exif1[] = { + GE_EXIF_TAG, GE_EXIF_SOI, GE_EXIF_TAG, GE_EXIF_APP1 + }; + /* Write File head, check for JPEG SOI + Exif APP1 */ + for (i = 0; i < 4; i++) { + if (__ge_exif_write_1_byte(fd, exif1[i]) < 0) + goto GE_EXIF_FAILED; + } + /* SET the marker parameter length count */ + /* Length includes itself, so must be at least 2 + Following Exif data length must be at least 6; 30+36 bytes*/ + const unsigned char exif2[] = { 0x00, 0x42 }; + for (i = 0; i < 2; i++) { + if (__ge_exif_write_1_byte(fd, exif2[i]) < 0) + goto GE_EXIF_FAILED; + } + + /* Write Exif head -- "Exif" */ + const unsigned char exif3[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; + for (i = 0; i < 6; i++) { + if (__ge_exif_write_1_byte(fd, exif3[i]) < 0) + goto GE_EXIF_FAILED; + } + + /* Set byte order and Tag Mark , "II(0x4949)" */ + const unsigned char exif4[] = { 0x49, 0x49, 0x2A, 0x00 }; + for (i = 0; i < 4; i++) { + if (__ge_exif_write_1_byte(fd, exif4[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 4; + + /* Set first IFD offset (offset to IFD0) , II-08000000 */ + const unsigned char exif5[] = { 0x08, 0x00, 0x00, 0x00 }; + for (i = 0; i < 4; i++) { + if (__ge_exif_write_1_byte(fd, exif5[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 4; + + /* IFD: Image File Directory */ + /* Set the number of directory entries contained in this IFD, - EEEE ; + * 2 entry: orientation, data time */ + const unsigned char exif6[] = { 0x02, 0x00 }; + for (i = 0; i < 2; i++) { + if (__ge_exif_write_1_byte(fd, exif6[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 2; + + /* Add Orientation Tag in IFD0; 0x0112 */ + const unsigned char exif7[] = { 0x12, 0x01 }; + for (i = 0; i < 2; i++) { + if (__ge_exif_write_1_byte(fd, exif7[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 2; + + ge_dbg("Write: %d", *orientation); + const unsigned char exif8[] = { 0x03, 0x00, 0x01, 0x00, 0x00, 0x00 }; + for (i = 0; i < 6; i++) { + if (__ge_exif_write_1_byte(fd, exif8[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 6; + + /* Set the Orientation value */ + if (__ge_exif_write_1_byte(fd, (unsigned char)(*orientation)) < 0) + goto GE_EXIF_FAILED; + + const unsigned char exif9[] = { 0x00, 0x00, 0x00 }; + for (i = 0; i < 3; i++) { + if (__ge_exif_write_1_byte(fd, exif9[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 4; + + /* Add Data Time Tag in IFD0; 0x0132 */ + const unsigned char exif10[] = { 0x32, 0x01 }; + for (i = 0; i < 2; i++) { + if (__ge_exif_write_1_byte(fd, exif10[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 2; + + /* Type: strings */ + const unsigned char exif11[] = { 0x02, 0x00 }; + for (i = 0; i < 2; i++) { + if (__ge_exif_write_1_byte(fd, exif11[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 2; + + /* Data lengh, byte count */ + const unsigned char exif12[] = { 0x14, 0x00, 0x00, 0x00 }; + for (i = 0; i < 4; i++) { + if (__ge_exif_write_1_byte(fd, exif12[i]) < 0) + goto GE_EXIF_FAILED; + } + offset += 8; + + /* 20 bytes larger than 4 bytes, + * so next 4 bytes is data offset start from "II"(0x4949)*/ + + ge_dbg("offset: %2X", offset + 8); + /* Too add data offset, plus 4 bytes self and plus 4 bytes IFD terminator */ + if (__ge_exif_write_1_byte(fd, (unsigned char)(offset + 4)) < 0) + goto GE_EXIF_FAILED; + + const unsigned char exif13[] = { 0x00, 0x00, 0x00 }; + for (i = 0; i < 3; i++) { + if (__ge_exif_write_1_byte(fd, exif13[i]) < 0) + goto GE_EXIF_FAILED; + } + + /*After last directory entry, there is a 4bytes of data('LLLLLLLL' at the chart), + * it means an offset to next IFD. If its value is '0x00000000', + * it means this is the last IFD and there is no linked IFD */ + const unsigned char exif14[] = { 0x00, 0x00, 0x00, 0x00 }; + for (i = 0; i < 4; i++) { + if (__ge_exif_write_1_byte(fd, exif14[i]) < 0) + goto GE_EXIF_FAILED; + } + + /* Date Time of image was last modified. + * Data format is "YYYY:MM:DD HH:MM:SS"+0x00, total 20bytes + */ + time_t t; + struct tm tms; + struct tm *tm; + + t = time (NULL); + tm = localtime_r(&t, &tms); + + time_buf = (char *)calloc(1, GE_EXIF_BUF_TIME_LEN_MAX); + if (time_buf == NULL) { + ge_dbgE("Faild to allocate memory!"); + goto GE_EXIF_FAILED; + } + snprintf(time_buf, GE_EXIF_BUF_TIME_LEN_MAX, + "%04i:%02i:%02i %02i:%02i:%02i", + tm->tm_year + GE_EXIF_DEFAULT_YEAR, tm->tm_mon + 1, + tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); + + ge_dbg("time_buf: %s", time_buf); + if (fwrite(time_buf, 1, GE_EXIF_BUF_TIME_LEN_MAX, fd) != GE_EXIF_BUF_TIME_LEN_MAX) { + ge_dbgW("Write size are diff!"); + goto GE_EXIF_FAILED; + } + + ret = 0; + + GE_EXIF_FAILED: + + ge_dbg("All done"); + GE_FREEIF(time_buf); + return ret; +} + +/* Add exif to jfif , don't have exif */ +static int __ge_exif_add_exif_to_jfif(char *file_path, unsigned int *orientation) +{ + GE_CHECK_VAL(orientation, -1); + GE_CHECK_VAL(file_path, -1); + unsigned char tmp[GE_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + + if ((fd = fopen(file_path, "rb+")) == NULL) { + ge_dbgE("Can't open %s!", file_path); + return -1; + } + + char *tmp_file = GE_EXI_TMP_JPEG_FILE; + FILE *tmp_fd = NULL; + if ((tmp_fd = fopen(tmp_file, "wb+")) == NULL) { + ge_dbgE("Can't open %s!", tmp_file); + goto GE_EXIF_FAILED; + } + + /* Add raw EXIF header data */ + if (__ge_exif_add_header(tmp_fd, orientation) < 0) + goto GE_EXIF_FAILED; + + size_t r_size = 0; + /* Remove start of JPEG image data section, 20 bytes */ + r_size = fread(tmp, sizeof(char), 20, fd); + + memset(tmp, 0x00, GE_EXIF_BUF_LEN_MAX); + /* Write JPEG image data to tmp file after EXIF header */ + while ((r_size = fread(tmp, 1, sizeof(tmp), fd)) > 0) { + ge_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, tmp_fd) != r_size) + ge_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GE_EXIF_BUF_LEN_MAX); + } + + fclose(fd); + fd = fopen(file_path, "wb"); + if (!fd) { + ge_dbgE("Error creating file %s!", file_path); + goto GE_EXIF_FAILED; + } + + memset(tmp, 0x00, GE_EXIF_BUF_LEN_MAX); + /* Write back tmp file after to JPEG image */ + fseek(tmp_fd, 0, SEEK_SET); + while ((r_size = fread(tmp, 1, sizeof(tmp), tmp_fd)) > 0) { + ge_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, fd) != r_size) + ge_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GE_EXIF_BUF_LEN_MAX); + } + + ret = 0; + + GE_EXIF_FAILED: + + if (fd) + fclose(fd); + if (tmp_fd) + fclose(tmp_fd); + + /* Delete tmp file */ + if (!ecore_file_unlink(tmp_file)) + ge_dbgE("Delete file failed"); + + ge_dbg("All done"); + return ret; +} + +/* Add orientation tag to jpegs which have exif tag but do not have orientation tag: include jfif and exif*/ +static int __ge_exif_add_orientation_tag(char *file_path, + unsigned int *orientation){ + + GE_CHECK_VAL(orientation, -1); + GE_CHECK_VAL(file_path, -1); + unsigned char tmp[GE_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + int tmp_exif = -1; + int i = 0; + unsigned int length = 0; + bool is_motorola = false; /* Flag for byte order */ + unsigned int offset = 0; + size_t r_size = 0; + const unsigned char ifd_data_format[13] = { + /*add 0 to ifd_data_format[0] ,for easy to use*/ + 0, + GE_EXIF_IFD_DATA_FORMAT_UNSIGNED_BYTE, + GE_EXIF_IFD_DATA_FORMAT_ASCII_STRINGS, + GE_EXIF_IFD_DATA_FORMAT_UNSIGNED_SHORT, + GE_EXIF_IFD_DATA_FORMAT_UNSIGNED_LONG, + GE_EXIF_IFD_DATA_FORMAT_UNSIGNED_RATIONAL, + GE_EXIF_IFD_DATA_FORMAT_SIGNED_BYTE, + GE_EXIF_IFD_DATA_FORMAT_UNDEFINED, + GE_EXIF_IFD_DATA_FORMAT_SIGNED_SHORT, + GE_EXIF_IFD_DATA_FORMAT_SIGNED_LONG, + GE_EXIF_IFD_DATA_FORMAT_SIGNED_RATIONAL, + GE_EXIF_IFD_DATA_FORMAT_SIGNED_FLOAT, + GE_EXIF_IFD_DATA_FORMAT_DOUBLE_FLOAT + + }; + + if ((fd = fopen(file_path, "rb+")) == NULL) { + ge_dbgE("Can't open %s!", file_path); + return -1; + } + + char *tmp_file = GE_EXI_TMP_JPEG_FILE; + FILE *tmp_fd = NULL; + if ((tmp_fd = fopen(tmp_file, "wb+")) == NULL) { + ge_dbgE("Can't open %s!", tmp_file); + goto GE_EXIF_FAILED; + } + /* Find APP1 */ + bool b_tag_ff = false; + while(1){ + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + /*copy data from jpeg to tmp_fd (from "FF D8" to " FF E1",because those data we needn't modify)*/ + if (__ge_exif_write_1_byte(tmp_fd, tmp_exif) < 0) + goto GE_EXIF_FAILED; + + tmp[0] = (unsigned char)tmp_exif; + + ge_dbg("- %02X", tmp[0]); + if (!b_tag_ff) { + /* Get first tag */ + if (tmp[0] == GE_EXIF_TAG) { + ge_dbgW("0xFF!"); + b_tag_ff = true; + } + continue; + } + + /* Get APP1 */ + if (tmp[0] == GE_EXIF_APP1) { + ge_dbgW("Exif in APP1!"); + break; + } else { + ge_dbgW("0x%02X!",tmp[0]); + b_tag_ff = false; + } + } + + /* Get the marker parameter length count */ + if (__ge_exif_read_2_bytes(fd, &length) < 0) + goto GE_EXIF_FAILED; + ge_dbg("length: %d", length); + /* Length includes itself, so must be at least 2 + Following Exif data length must be at least 6 */ + if (length < 8) { + ge_dbgE("length < 8"); + goto GE_EXIF_FAILED; + } + /*modify the marker parameter length, orientation tag is 12*/ + length += 12; + ge_dbgW("modified length: %d", length); + tmp[0] =( length >> 8 )& 0xff ; + tmp[1] = length & 0xff ; + for(i = 0; i < 2; i++){ + if (__ge_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GE_EXIF_FAILED; + } + + for (i = 0; i < 6; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + ge_dbg("- %02X", tmp[i]); + if (__ge_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GE_EXIF_FAILED; + } + if (tmp[0] == 0x45 && tmp[1] == 0x78 && tmp[2] == 0x69 && tmp[3] == 0x66 && + tmp[4] == 0x00 && tmp[5] == 0x00) { + ge_dbgW("Met Exif!"); + } else { + ge_dbgW("Not met Exif!"); + goto GE_EXIF_FAILED; + } + /* Read Exif body */ + for (i = 0; i < 4; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + tmp[i] = (unsigned char)tmp_exif; + if (__ge_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GE_EXIF_FAILED; + } + + /* Check byte order and Tag Mark , "II(0x4949)" or "MM(0x4d4d)" */ + if (tmp[0] == 0x49 && tmp[1] == 0x49 && tmp[2] == 0x2A && + tmp[3] == 0x00) { + ge_dbg("Intel"); + is_motorola = false; + } else if (tmp[0] == 0x4D && tmp[1] == 0x4D && tmp[2] == 0x00 && + tmp[3] == 0x2A) { + ge_dbg("Motorola"); + is_motorola = true; + } else { + goto GE_EXIF_FAILED; + } + + for (i = 0; i < 4; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + ge_dbg("- %02X", tmp[i]); + if (__ge_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GE_EXIF_FAILED; + } + + /* Get first IFD offset (offset to IFD0) , MM-08000000, II-00000008 */ + if (is_motorola) { + if (tmp[0] != 0 && tmp[1] != 0) + goto GE_EXIF_FAILED; + offset = tmp[2]; + offset <<= 8; + offset += tmp[3]; + } else { + if (tmp[3] != 0 && tmp[2] != 0) + goto GE_EXIF_FAILED; + offset = tmp[1]; + offset <<= 8; + offset += tmp[0]; + } + ge_dbg("offset: %d", offset); + /*if offset >8, copy data from there to IFD start position*/ + if(offset > 8){ + for (i = 0; i < (offset - 8); i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + ge_dbg("- %02X", tmp[i]); + if (__ge_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GE_EXIF_FAILED; + } + } + + /* IFD: Image File Directory */ + /* Get the number of directory entries contained in this IFD, - 2 bytes, EE */ + unsigned int tags_cnt = 0; + for (i = 0; i < 2; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + } + if (is_motorola) { + tags_cnt = tmp[0]; + tags_cnt <<= 8; + tags_cnt += tmp[1]; + } else { + tags_cnt = tmp[1]; + tags_cnt <<= 8; + tags_cnt += tmp[0]; + } + ge_dbg("tags_cnt: %d", tags_cnt); + /*modify tags num,add orientation tag */ + tags_cnt += 1; + ge_dbg("modified tags_cnt: %d", tags_cnt); + if (is_motorola) { + tmp[0] = (tags_cnt >> 8) & 0xff; + tmp[1] = tags_cnt & 0xff; + } else { + tmp[0] = tags_cnt & 0xff; + tmp[1] = (tags_cnt >> 8) & 0xff; + } + for (i = 0; i < 2; i++) { + ge_dbg("modified- %02X", tmp[i]); + if (__ge_exif_write_1_byte(tmp_fd, tmp[i]) < 0) + goto GE_EXIF_FAILED; + + } + /* Add Orientation Tag in IFD0 */ + unsigned int tag_num = 0; + unsigned char orientation_tag[12] = { 0, }; + bool b_found_position = false; + int j = 0; + unsigned int data_type = 0; + unsigned int unit_num = 0; + unsigned int data_length = 0; + unsigned int offset_value = 0; + /*initialize orientation_tag value*/ + if (is_motorola) { + orientation_tag[0] = 0x01; + orientation_tag[1] = 0x12; + + orientation_tag[2] = 0x00; + orientation_tag[3] = 0x03; + + orientation_tag[4] = 0x00; + orientation_tag[5] = 0x00; + orientation_tag[6] = 0x00; + orientation_tag[7] = 0x01; + + orientation_tag[8] = 0x00; + orientation_tag[9] = 0x00; + orientation_tag[10] = 0x00; + orientation_tag[11] = (unsigned char)(*orientation); + + } else { + orientation_tag[0] = 0x12; + orientation_tag[1] = 0x01; + orientation_tag[2] = 0x03; + orientation_tag[3] = 0x00; + orientation_tag[4] = 0x01; + orientation_tag[5] = 0x00; + orientation_tag[6] = 0x00; + orientation_tag[7] = 0x00; + orientation_tag[8] = (unsigned char)(*orientation); + orientation_tag[9] = 0x00; + orientation_tag[10] = 0x00; + orientation_tag[11] = 0x00; + } + + while(1){ + if (--tags_cnt == 0) { + break; + } + + /* Every directory entry size is 12 */ + for (i = 0; i < 12; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + } + /* Get Tag number */ + if (is_motorola) { + tag_num = tmp[0]; + tag_num <<= 8; + tag_num += tmp[1]; + } else { + tag_num = tmp[1]; + tag_num <<= 8; + tag_num += tmp[0]; + } + ge_dbgW("tag num %02X!" , tag_num); + /* to find Orientation Tag position */ + if (tag_num < 0x0112) { + + } else if (tag_num > 0x0112){ + if(!b_found_position){ + for(j = 0; j < 12 ;j++){ + ge_dbg("orientation_tag- %02X", orientation_tag[j]); + if (__ge_exif_write_1_byte(tmp_fd, orientation_tag[j]) < 0) + goto GE_EXIF_FAILED; + } + b_found_position = true; + } + if (is_motorola) { + data_type = tmp[2]; + data_type <<= 8; + data_type += tmp[3]; + + unit_num = tmp[4]; + unit_num <<= 8; + unit_num += tmp[5]; + unit_num <<= 8; + unit_num += tmp[6]; + unit_num <<= 8; + unit_num += tmp[7]; + } else { + data_type = tmp[3]; + data_type <<= 8; + data_type += tmp[2]; + + unit_num = tmp[7]; + unit_num <<= 8; + unit_num += tmp[6]; + unit_num <<= 8; + unit_num += tmp[5]; + unit_num <<= 8; + unit_num += tmp[4]; + } + ge_dbgW("data_type %02X!" , data_type); + ge_dbgW("unit_num %02X!" , unit_num); + if((data_type < 1) ||(data_type > 12)){ + ge_dbgE("Wrong data type!"); + goto GE_EXIF_FAILED; + } + + data_length = ifd_data_format[data_type] * unit_num; + ge_dbgW("data_length %02X!" , data_length); + /*data_length >4 ,next 4 bytes store the offset, so need to modify the offset*/ + if(data_length > 4){ + if (is_motorola) { + offset_value = tmp[8]; + offset_value <<= 8; + offset_value += tmp[9]; + offset_value <<= 8; + offset_value += tmp[10]; + offset_value <<= 8; + offset_value += tmp[11]; + ge_dbgW("offset_value %02X!" , offset_value); + /*add orientation offset*/ + offset_value += 12; + ge_dbgW("changed offset_value %02X!" , offset_value); + tmp[8] = (offset_value >> 24) & 0xff; + tmp[9] = (offset_value >> 16) & 0xff; + tmp[10] = (offset_value >> 8) & 0xff; + tmp[11] = offset_value & 0xff; + ge_dbg("tmp[8] %02X!" , tmp[8]); + ge_dbg("tmp[9] %02X!" , tmp[9]); + ge_dbg("tmp[10] %02X!" , tmp[10]); + ge_dbg("tmp[11] %02X!" , tmp[11]); + } else { + offset_value = tmp[11]; + offset_value <<= 8; + offset_value += tmp[10]; + offset_value <<= 8; + offset_value += tmp[9]; + offset_value <<= 8; + offset_value += tmp[8]; + ge_dbgW("offset_value %02X!" , offset_value); + /*add orientation offset*/ + offset_value += 12; + ge_dbgW("changed offset_value %02X!" , offset_value); + + tmp[11] = (offset_value >> 24) & 0xff; + tmp[10] = (offset_value >> 16) & 0xff; + tmp[9] = (offset_value >> 8) & 0xff; + tmp[8] = offset_value & 0xff; + ge_dbg("tmp[8] %02X!" , tmp[8]); + ge_dbg("tmp[9] %02X!" , tmp[9]); + ge_dbg("tmp[10] %02X!" , tmp[10]); + ge_dbg("tmp[11] %02X!" , tmp[11]); + + } + + } + + } + for(i = 0; i < 12 ;i++){ + ge_dbg("- %02X", tmp[i]); + if (__ge_exif_write_1_byte(tmp_fd,tmp[i]) < 0) + goto GE_EXIF_FAILED; + + } + memset(tmp, 0x00, 12); + + } + memset(tmp, 0x00, GE_EXIF_BUF_LEN_MAX); + /* Write JPEG image data to tmp file after EXIF header */ + while ((r_size = fread(tmp, 1, sizeof(tmp), fd)) > 0) { + ge_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, tmp_fd) != r_size) + ge_dbgW("Write and read size are diff!"); + + memset(tmp, 0x00, GE_EXIF_BUF_LEN_MAX); + } + fclose(fd); + fd = NULL; + fd = fopen(file_path, "wb"); + if (!fd) { + ge_dbgE("Error creating file %s!", file_path); + goto GE_EXIF_FAILED; + } + + memset(tmp, 0x00, GE_EXIF_BUF_LEN_MAX); + /* Write back tmp file after to JPEG image */ + fseek(tmp_fd, 0, SEEK_SET); + while ((r_size = fread(tmp, 1, sizeof(tmp), tmp_fd)) > 0) { + ge_dbg("r_size: %ld", r_size); + if (fwrite(tmp, 1, r_size, fd) != r_size) + ge_dbgW("Write and read size are diff!"); + memset(tmp, 0x00, GE_EXIF_BUF_LEN_MAX); + } + + ret = 0; + + GE_EXIF_FAILED: + + if (fd){ + fclose(fd); + fd = NULL; + } + + if (tmp_fd){ + fclose(tmp_fd); + tmp_fd = NULL; + } + + /* Delete tmp file */ + if (!ecore_file_unlink(tmp_file)) + ge_dbgE("Delete file failed"); + + ge_dbg("All done"); + return ret; +} + +static int __ge_exif_rw_jfif(FILE *fd, char *file_path, + unsigned int *orientation, bool b_write) +{ + GE_CHECK_VAL(fd, -1); + GE_CHECK_VAL(file_path, -1); + GE_CHECK_VAL(orientation, -1); + unsigned char tmp[GE_EXIF_BUF_LEN_MAX] = { 0, }; + int i = 0; + unsigned int length = 0; + int tmp_exif = -1; + bool is_motorola = false; /* Flag for byte order */ + unsigned int offset = 0; + int ret = -1; + /*unsigned char version = 0x00; */ + + if (__ge_exif_read_2_bytes(fd, &length) < 0) + goto GE_EXIF_FAILED; + ge_dbg("length: %d", length); + + for (i = 0; i < 5; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + tmp[i] = (unsigned char)tmp_exif; + } + + /* JFIF0 */ + if (tmp[0] != 0x4A || tmp[1] != 0x46 || tmp[2] != 0x49 || + tmp[3] != 0x46 || tmp[4] != 0x00) { + ge_dbgE("Not met Jfif!"); + goto GE_EXIF_FAILED; + } + + for (i = 0; i < 2; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + tmp[i] = (unsigned char)tmp_exif; + } + + /* Check JFIF version */ + if (tmp[0] == 0x01 && tmp[1] == GE_EXIF_JFIF_00) { + ge_dbg("Jfif 1.00"); + } else if (tmp[0] == 0x01 && tmp[1] == GE_EXIF_JFIF_01) { + ge_dbg("Jfif 1.01"); + } else if (tmp[0] == 0x01 && tmp[1] == GE_EXIF_JFIF_02) { + ge_dbg("Jfif 1.02"); + } else { + ge_dbgE("Unknow Jfif version[%d.%d]!", tmp[0], tmp[1]); + goto GE_EXIF_FAILED; + } + + /* Save version */ + /*version = tmp[1]; */ + + /* Find APP1 */ + bool b_tag_ff = false; + while(1) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[0] = (unsigned char)tmp_exif; + + ge_dbg("- %02X", tmp[0]); + if (!b_tag_ff) { + /* Get first tag */ + if (tmp[0] == GE_EXIF_TAG) { + ge_dbgW("0xFF!"); + b_tag_ff = true; + } + continue; + } + + /* Get APP1 */ + if (tmp[0] == GE_EXIF_APP1) { + ge_dbgW("Exif in APP1!"); + break; + } + + ge_dbgW("No Exif in APP1!"); + + /* Close file */ + fclose(fd); + if (!b_write) { + /* Normal orientation = 0degree = 1 */ + *orientation = 1; + return 0; + } + return __ge_exif_add_exif_to_jfif(file_path, orientation); +#if 0 + if (version == GE_EXIF_JFIF_00) { + return __ge_exif_rw_jfif_1dot00(file_path, orientation); + } else if (version == GE_EXIF_JFIF_01) { + return __ge_exif_rw_jfif_1dot01(file_path, orientation); + } else { + return __ge_exif_rw_jfif_1dot02(file_path, orientation); + } +#endif + } + + /* Find Exif */ + while(1) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[0] = (unsigned char)tmp_exif; + if (tmp[0] != 0x45) + continue; + + for (i = 0; i < 5; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + ge_dbg("- %02X", tmp[i]); + } + if (tmp[0] == 0x78 && tmp[1] == 0x69 && tmp[2] == 0x66 && + tmp[3] == 0x00 && tmp[4] == 0x00) { + ge_dbgW("Met Exif!"); + break; + } else { + ge_dbgW("Not met Exif!"); + goto GE_EXIF_FAILED; + } + } + + /* Read Exif body */ + for (i = 0; i < 4; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + tmp[i] = (unsigned char)tmp_exif; + } + + /* Check byte order and Tag Mark , "II(0x4949)" or "MM(0x4d4d)" */ + if (tmp[0] == 0x49 && tmp[1] == 0x49 && tmp[2] == 0x2A && + tmp[3] == 0x00) { + ge_dbg("Intel"); + is_motorola = false; + } else if (tmp[0] == 0x4D && tmp[1] == 0x4D && tmp[2] == 0x00 && + tmp[3] == 0x2A) { + ge_dbg("Motorola"); + is_motorola = true; + } else { + goto GE_EXIF_FAILED; + } + + for (i = 0; i < 4; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + ge_dbg("- %02X", tmp[i]); + } + + /* Get first IFD offset (offset to IFD0) , MM-08000000, II-00000008 */ + if (is_motorola) { + if (tmp[0] != 0 && tmp[1] != 0) + goto GE_EXIF_FAILED; + offset = tmp[2]; + offset <<= 8; + offset += tmp[3]; + } else { + if (tmp[3] != 0 && tmp[2] != 0) + goto GE_EXIF_FAILED; + offset = tmp[1]; + offset <<= 8; + offset += tmp[0]; + } + ge_dbg("offset: %d", offset); + + /* IFD: Image File Directory */ + /* Get the number of directory entries contained in this IFD, - 2 bytes, EE */ + unsigned int tags_cnt = 0; + for (i = 0; i < 2; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + } + if (is_motorola) { + tags_cnt = tmp[0]; + tags_cnt <<= 8; + tags_cnt += tmp[1]; + } else { + tags_cnt = tmp[1]; + tags_cnt <<= 8; + tags_cnt += tmp[0]; + } + ge_dbg("tags_cnt: %d", tags_cnt); + if (tags_cnt == 0) { + ge_dbgE("tags_cnt == 0 - 2"); + goto GE_EXIF_FAILED; + } + + /* Search for Orientation Tag in IFD0 */ + unsigned int tag_num = 0; + while (1) { + /* Every directory entry size is 12 */ + for (i = 0; i < 12; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + tmp[i] = (unsigned char)tmp_exif; + } + /* Get Tag number */ + if (is_motorola) { + tag_num = tmp[0]; + tag_num <<= 8; + tag_num += tmp[1]; + } else { + tag_num = tmp[1]; + tag_num <<= 8; + tag_num += tmp[0]; + } + /* found Orientation Tag */ + if (tag_num == 0x0112) { + ge_dbgW("Found orientation tag!"); + break; + } + if (--tags_cnt == 0) { + ge_dbgW("tags_cnt == 0, no found orientation tag!"); + if (b_write) { + ge_dbgW("to add an orientation tag!"); + fclose(fd); + fd = NULL; + return __ge_exif_add_orientation_tag(file_path, orientation); + + } else{ + /* Normal orientation = 0degree = 1 */ + *orientation = 1; + ret = 0; + } + goto GE_EXIF_FAILED; + } + } + + /* |TT|ff|NNNN|DDDD| --- TT - 2 bytes, tag NO. ;ff - 2 bytes, data format + NNNN - 4 bytes, entry count; DDDD - 4 bytes Data value */ + if (b_write) { + ge_dbg("Write: %d", *orientation); + /* Set the Orientation value */ + if (is_motorola) + tmp[9] = (unsigned char)(*orientation); + else + tmp[8] = (unsigned char)(*orientation); + + /* Move pointer back to the entry start point */ + if (fseek(fd, -12, SEEK_CUR) < 0) { + ge_dbgE("fseek failed!"); + goto GE_EXIF_FAILED; + } + fwrite(tmp, 1, 10, fd); + } else { + /* Get the Orientation value */ + if (is_motorola) { + if (tmp[8] != 0) { + ge_dbgE("tmp[8] != 0"); + goto GE_EXIF_FAILED; + } + *orientation = (unsigned int)tmp[9]; + } else { + if (tmp[9] != 0) { + ge_dbgE("tmp[9] != 0"); + goto GE_EXIF_FAILED; + } + *orientation = (unsigned int)tmp[8]; + } + if (*orientation > 8) { + ge_dbgE("*orient > 8"); + goto GE_EXIF_FAILED; + } + ge_dbg("Read: %d", *orientation); + } + + ret = 0; + + GE_EXIF_FAILED: + + fclose(fd); + ge_dbg("All done"); + return ret; +} + +static int __ge_exif_rw_orient(char *file_path, unsigned int *orient, bool b_write) +{ + GE_CHECK_VAL(file_path, -1); + ge_dbg("b_write: %d", b_write); + unsigned int length = 0; + unsigned int i = 0; + bool is_motorola = false; /* Flag for byte order */ + unsigned int offset = 0; + unsigned int jfif_offset = 0; + unsigned int tags_cnt = 0; + unsigned int tag_num = 0; + int tmp_exif = -1; + unsigned char exif_data[GE_EXIF_BUF_LEN_MAX] = { 0, }; + FILE *fd = NULL; + int ret = -1; + + if (b_write) { + if ((fd = fopen(file_path, "rb+")) == NULL) { + ge_dbgE("Can't open %s!", file_path); + return -1; + } + } else { + if ((fd = fopen(file_path, "rb")) == NULL) { + ge_dbgE("Can't open %s!", file_path); + return -1; + } + } + + /* Read File head, check for JPEG SOI + Exif APP1 */ + for (i = 0; i < 4; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + exif_data[i] = (unsigned char)tmp_exif; + } + + if (exif_data[0] == GE_EXIF_TAG && exif_data[1] == GE_EXIF_SOI) { + ge_dbg("JPEG file"); + } else { + ge_dbgE("Not a JPEG file!"); + goto GE_EXIF_FAILED; + } + + if (exif_data[2] == GE_EXIF_TAG && exif_data[3] == GE_EXIF_APP1) { + ge_dbgW("Exif in APP1!"); + } else if (exif_data[2] == GE_EXIF_TAG && + exif_data[3] == GE_EXIF_APP0) { + ge_dbgW("Jfif in APP0!"); + int ret = __ge_exif_rw_jfif(fd, file_path, orient, b_write); + return ret; + } else { + ge_dbgE("Not a Exif in APP1 or Jiff in APP2[%d]!", exif_data[3]); + goto GE_EXIF_FAILED; + } + + /* Get the marker parameter length count */ + if (__ge_exif_read_2_bytes(fd, &length) < 0) + goto GE_EXIF_FAILED; + ge_dbg("length: %d", length); + /* Length includes itself, so must be at least 2 + Following Exif data length must be at least 6 */ + if (length < 8) { + ge_dbgE("length < 8"); + goto GE_EXIF_FAILED; + } + length -= 8; + + /* Length of an IFD entry */ + if (length < 12) { + ge_dbgE("length < 12"); + goto GE_EXIF_FAILED; + } + + /* Read Exif head, check for "Exif" */ + for (i = 0; i < 6; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + + exif_data[i] = (unsigned char)tmp_exif; + ge_dbg("- %02X", exif_data[i]); + } + + if (exif_data[0] != 0x45 || exif_data[1] != 0x78 || + exif_data[2] != 0x69 || exif_data[3] != 0x66 || + exif_data[4] != 0x00 || exif_data[5] != 0x00) { + ge_dbgE("Not met Exif!"); + goto GE_EXIF_FAILED; + } + + /* Read Exif body */ + for (i = 0; i < length; i++) { + tmp_exif = __ge_exif_read_1_byte(fd); + if (tmp_exif < 0) + goto GE_EXIF_FAILED; + exif_data[i] = (unsigned char)tmp_exif; + } + + /* Check byte order and Tag Mark , "II(0x4949)" or "MM(0x4d4d)" */ + if (exif_data[0] == 0x49 && exif_data[1] == 0x49 && + exif_data[2] == 0x2A && exif_data[3] == 0x00) { + ge_dbg("Intel"); + is_motorola = false; + } else if (exif_data[0] == 0x4D && exif_data[1] == 0x4D && + exif_data[2] == 0x00 && exif_data[3] == 0x2A) { + ge_dbg("Motorola"); + is_motorola = true; + } else { + goto GE_EXIF_FAILED; + } + + /* Get first IFD offset (offset to IFD0) , MM-00000008, II-08000000 */ + if (is_motorola) { + if (exif_data[4] != 0 && exif_data[5] != 0) + goto GE_EXIF_FAILED; + offset = exif_data[6]; + offset <<= 8; + offset += exif_data[7]; + } else { + if (exif_data[7] != 0 && exif_data[6] != 0) + goto GE_EXIF_FAILED; + offset = exif_data[5]; + offset <<= 8; + offset += exif_data[4]; + } + /* check end of data segment */ + if (offset > length - 2) { + ge_dbgE("offset > length - 2"); + goto GE_EXIF_FAILED; + } + + /* IFD: Image File Directory */ + /* Get the number of directory entries contained in this IFD, - EEEE */ + if (is_motorola) { + tags_cnt = exif_data[offset]; + tags_cnt <<= 8; + tags_cnt += exif_data[offset+1]; + } else { + tags_cnt = exif_data[offset+1]; + tags_cnt <<= 8; + tags_cnt += exif_data[offset]; + } + if (tags_cnt == 0) { + ge_dbgE("tags_cnt == 0 - 2"); + goto GE_EXIF_FAILED; + } + offset += 2; + + /* check end of data segment */ + if (offset > length - 12) { + ge_dbgE("offset > length - 12"); + goto GE_EXIF_FAILED; + } + + /* Search for Orientation Tag in IFD0 */ + while (1) { + /* Get Tag number */ + if (is_motorola) { + tag_num = exif_data[offset]; + tag_num <<= 8; + tag_num += exif_data[offset+1]; + } else { + tag_num = exif_data[offset+1]; + tag_num <<= 8; + tag_num += exif_data[offset]; + } + /* found Orientation Tag */ + if (tag_num == 0x0112) { + ge_dbgW("Found orientation tag!"); + break; + } + if (--tags_cnt == 0) { + ge_dbgW("tags_cnt == 0, no found orientation tag!"); + if (b_write) { + ge_dbgW("to add an orientation tag!"); + fclose(fd); + fd = NULL; + return __ge_exif_add_orientation_tag(file_path, orient); + + } else{ + /* Normal orientation = 0degree = 1 */ + *orient = 1; + ret = 0; + } + goto GE_EXIF_FAILED; + } + + /* Every directory entry size is 12 */ + offset += 12; + } + + if (b_write) { + ge_dbg("Write: %d", *orient); + /* Set the Orientation value */ + if (is_motorola) + exif_data[offset+9] = (unsigned char)(*orient); + else + exif_data[offset+8] = (unsigned char)(*orient); + + if (fseek(fd, jfif_offset + (4 + 2 + 6 + 2) + offset, SEEK_SET) < 0) { + ge_dbgE("fseek failed!"); + goto GE_EXIF_FAILED; + } + fwrite(exif_data + 2 + offset, 1, 10, fd); + } else { + /* Get the Orientation value */ + if (is_motorola) { + if (exif_data[offset+8] != 0) { + ge_dbgE("exif_data[offset+8] != 0"); + goto GE_EXIF_FAILED; + } + *orient = (unsigned int)exif_data[offset+9]; + } else { + if (exif_data[offset+9] != 0) { + ge_dbgE("exif_data[offset+9] != 0"); + goto GE_EXIF_FAILED; + } + *orient = (unsigned int)exif_data[offset+8]; + } + if (*orient > 8) { + ge_dbgE("*orient > 8"); + goto GE_EXIF_FAILED; + } + ge_dbg("Read: %d", *orient); + } + + ret = 0; + + GE_EXIF_FAILED: + + fclose(fd); + ge_dbg("All done"); + return ret; +} + +int _ge_exif_get_orientation(char *file_path, unsigned int *orientation) +{ + GE_CHECK_VAL(orientation, -1); + GE_CHECK_VAL(file_path, -1); + ge_dbg("file_path: %s", file_path); + + return __ge_exif_rw_orient(file_path, orientation, false); +} + +#endif + diff --git a/ug/ug-gallery-efl/src/ge-ext-ug-load.c b/ug/ug-gallery-efl/src/ge-ext-ug-load.c new file mode 100755 index 0000000..92ac9b0 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-ext-ug-load.c @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "ge-ext-ug-load.h" +#include "ge-debug.h" +#include "ge-ui-util.h" +#include "ge-util.h" +#include "ge-albums.h" +#include "ge-gridview.h" + +#define GE_IV_UG_NAME "image-viewer-efl" +#define GE_IV_STR_LEN_MAX 32 + +static bool ge_destroy_me = false; + +static void _ge_ext_destroy_me(ge_ugdata *ugd) +{ + ge_dbg(""); + GE_CHECK(ugd); + GE_CHECK(ugd->ug_called_by_me); + GE_CHECK(ugd->ug); + GE_CHECK(ugd->service); + bool send_result = false; + + if (_ge_ug_iv_get()) + { + _ge_ug_iv_set(false); + } + + if(ge_destroy_me == false) + { + ge_dbg("Destroy ug_called_by_me"); + ug_destroy(ugd->ug_called_by_me); + ugd->ug_called_by_me = NULL; + } + if(ugd->file_select_mode == GE_FILE_SELECT_T_SETAS) + { + if(ugd->file_setas_image_path) + { + ge_dbg("GE_SETAS_IMAGE_PATH:%s", ugd->file_setas_image_path); + service_add_extra_data(ugd->service, + GE_SETAS_IMAGE_PATH, + ugd->file_setas_image_path); + + GE_FREE(ugd->file_setas_image_path); + send_result = true; + } + + if(ugd->file_setas_crop_image_path && + (ugd->file_select_setas_mode == GE_SETAS_T_CALLERID || + ugd->file_select_setas_mode == GE_SETAS_T_CROP_WALLPAPER)) { + ge_dbg("GE_SETAS_CALLERID_CROP_IMAGE_PATH:%s", + ugd->file_setas_crop_image_path); + service_add_extra_data(ugd->service, + GE_SETAS_CALLERID_CROP_IMAGE_PATH, + ugd->file_setas_crop_image_path); + + GE_FREE(ugd->file_setas_crop_image_path); + send_result = true; + } + + if(send_result) + { + ge_dbg("Call ug_send_result() to send result."); + ug_send_result(ugd->ug, ugd->service); + } + } + + if(ge_destroy_me) + { + ge_dbg("Setting is appllied, destroy gallery UG."); + ge_destroy_me = false; + /* Destroy self */ + ug_destroy_me(ugd->ug); + /* ug_called_by_me would be destroyed by ui-gadget */ + ugd->ug_called_by_me = NULL; + } + else + { + ge_dbg("Cancel button tapped, back to thumbnails view."); + } +} + +static void _ge_ext_iv_layout_cb(ui_gadget_h ug, enum ug_mode mode, void* priv) +{ + ge_dbg(""); + GE_CHECK(ug); + + Evas_Object *base = (Evas_Object *) ug_get_layout(ug); + if (!base) { + ge_dbgE("ug_get_layout failed!"); + ug_destroy(ug); + return; + } + + evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + /* Disable effect to avoid BS caused by ui-gadget to + unset ug layout after deleting it */ + ug_disable_effect(ug); + evas_object_show(base); +} + +static void _ge_ext_iv_result_cb(ui_gadget_h ug, service_h result, void *priv) +{ + ge_dbg(""); + GE_CHECK(priv); + GE_CHECK(result); + ge_ugdata *ugd = (ge_ugdata *)priv; + char* path = NULL; + + if(ugd->file_select_mode == GE_FILE_SELECT_T_SETAS) + { + service_get_extra_data(result, GE_IMAGEVIEWER_IMAGE_PATH, &path); + ge_dbg("SETAS_IMAGE_PATH"); + ge_destroy_me = true; + if(path) + { + ge_dbg(":%s", path); + ugd->file_setas_image_path = path; + path = NULL; + } + + if(ugd->file_select_setas_mode == GE_SETAS_T_CALLERID || + ugd->file_select_setas_mode == GE_SETAS_T_CROP_WALLPAPER) { + service_get_extra_data(result, + GE_IMAGEVIEWER_CROP_IMAGE_PATH, + &path); + ge_dbg("CALLERID_CROP_IMAGE_PATH"); + if(path) + { + ge_dbg(":%s", path); + ugd->file_setas_crop_image_path = path; + } + } + } + + char *error_state = NULL; + service_get_extra_data(result, GE_IMAGEVIEWER_RETURN_ERROR, + &error_state); + if (error_state) + { + ge_dbg("error string : %s", error_state); + + if (!g_strcmp0(error_state, "not_supported_file_type")) { + ge_destroy_me = FALSE; + ge_item* cur_item = _ge_get_current_item(); + if(cur_item == NULL || cur_item->item == NULL || + cur_item->item->file_url == NULL) { + ge_dbgE("current item is NULL"); + GE_FREE(error_state); + return; + } + service_h service; + service_create(&service); + GE_CHECK(service); + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_item->item->file_url); + service_send_launch_request(service, NULL, NULL); + service_destroy(service); + } + GE_FREE(error_state); + } +} + +static void _ge_ext_iv_destroy_cb(ui_gadget_h ug, void *priv) +{ + ge_dbg(""); + GE_CHECK(priv); + ge_ugdata *ad = (ge_ugdata *) priv; + + _ge_ext_destroy_me(ad); +} + +int ge_ext_load_iv_ug(ge_ugdata* ugd) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + + struct ug_cbs cbs; + ui_gadget_h ug = NULL; + service_h service = NULL; + + if(ugd->ug_called_by_me) + { + ge_dbg("Already exits some UG called by me"); + return -1; + } + + ge_item* cur_item = _ge_get_current_item(); + if(cur_item == NULL || cur_item->item == NULL) + { + ge_dbg("current item is NULL"); + return -1; + } + memset(&cbs,0x00,sizeof(struct ug_cbs)); + cbs.layout_cb = _ge_ext_iv_layout_cb; + cbs.result_cb = _ge_ext_iv_result_cb; + cbs.destroy_cb = _ge_ext_iv_destroy_cb; + cbs.priv = ugd; + + service_create(&service); + GE_CHECK_VAL(service, -1); + + _ge_ug_iv_set(true); + + service_add_extra_data(service, "View Mode", "SETAS" ); + service_add_extra_data(service, "Path", cur_item->item->file_url); + + if(ugd->file_select_setas_mode == GE_SETAS_T_WALLPAPER) { + service_add_extra_data(service, "Setas type", "Wallpaper"); + + if(ugd->file_setas_homescreen_path) + { + ge_dbg("homescreen_path:%s", ugd->file_setas_homescreen_path); + service_add_extra_data(service, GE_IMAGEVIEWER_HOMESCREEN_PATH, ugd->file_setas_homescreen_path); + GE_FREE(ugd->file_setas_homescreen_path); + } + + if(ugd->file_setas_lockscreen_path) + { + ge_dbg("lockscreen_path:%s", ugd->file_setas_lockscreen_path); + service_add_extra_data(service, GE_IMAGEVIEWER_LOCKSCREEN_PATH, ugd->file_setas_lockscreen_path); + GE_FREE(ugd->file_setas_lockscreen_path); + } + } else if(ugd->file_select_setas_mode == GE_SETAS_T_CROP_WALLPAPER) { + service_add_extra_data(service, "Setas type", "Wallpaper Crop"); + service_add_extra_data(service, "Fixed ratio", "TRUE"); + + int w = 0; + int h = 0; + ecore_x_window_size_get(ecore_x_window_root_first_get(), + &w, &h); + char *reso_str = (char *)calloc(1, GE_IV_STR_LEN_MAX); + if (reso_str == NULL) { + ge_dbgE("Calloc failed!"); + service_destroy(service); + return -1; + } + snprintf(reso_str, GE_IV_STR_LEN_MAX, "%dx%d", w, h); + ge_dbgW("Window Resolution: %dx%d, %s", w, h, reso_str); + service_add_extra_data(service, "Resolution", reso_str); + GE_FREE(reso_str); + } else if(ugd->file_select_setas_mode == GE_SETAS_T_CALLERID) { + service_add_extra_data(service, "Setas type", "CallerID"); + if(ugd->file_setas_callid_size) + { + ge_dbg("callerid_size:%s", ugd->file_setas_callid_size); + service_add_extra_data(service, GE_IMAGEVIEWER_CALLERID_SIZE, ugd->file_setas_callid_size); + GE_FREE(ugd->file_setas_callid_size); + } + + if(ugd->file_setas_callid_path) + { + ge_dbg("callerid_path:%s", ugd->file_setas_callid_path); + service_add_extra_data(service, GE_IMAGEVIEWER_CALLERID_PATH, ugd->file_setas_callid_path); + GE_FREE(ugd->file_setas_callid_path); + } + } + ug = ug_create(ugd->ug, GE_IV_UG_NAME, UG_MODE_FULLVIEW, service, &cbs); + ugd->ug_called_by_me = ug; + service_destroy(service); + if (ug != NULL) { + ge_dbg("Create UG successully"); + return 0; + } else { + ge_dbgE("Create UG failed!"); + return -1; + } +} + diff --git a/ug/ug-gallery-efl/src/ge-gridview.c b/ug/ug-gallery-efl/src/ge-gridview.c new file mode 100755 index 0000000..a20dde8 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-gridview.c @@ -0,0 +1,711 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge-debug.h" +#include "ge-gridview.h" +#include "ge-ui-util.h" +#include "ge-util.h" +#include "ge-ext-ug-load.h" +#include "ge-data.h" +#include "ge-strings.h" +#include "ge-icon.h" +#include "ge-drm.h" +#include "ge-exif.h" +#include "ge-thumb.h" + +/* Icon swallowed to part "elm.swallow.icon" */ +#define GE_GRID_ICON_SIZE 156 +#define GE_ITEM_MOUSE_UP_DISTANCE_X 20 +#define GE_ITEM_MOUSE_UP_DISTANCE_Y 20 +#define GE_GIRD_ICON_CLICK_TIME_DELAY 0.01f + +static Elm_Gengrid_Item_Class gic; +static int ge_grid_item_cnt = 0; + +typedef struct +{ + Evas_Coord x; + Evas_Coord y; + bool b_pressed; +}ge_grid_touch_info; + +static ge_grid_touch_info ge_touch_info; + +static void _ge_grid_drag_up(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_drag_right(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_drag_down(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_drag_left(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_drag_stop(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_selected(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_unselected(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_clicked(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_longpress(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); +} + +static void _ge_grid_sel(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); + GE_CHECK(data); + if (_ge_get_view_mode() != GE_VIEW_THUMBS) { + ge_dbgE("Wrong mode!"); + return; + } else { + ge_dbg("ViewMode"); + } + + ge_item* gitem = (ge_item*)data; + GE_CHECK(gitem->item); + GE_CHECK(gitem->ugd); + ge_ugdata* ugd = gitem->ugd; + + if (gitem->item->file_url == NULL || strlen(gitem->item->file_url) <= 0) { + ge_dbgE("file_url is invalid!"); + return; + } else { + ge_dbg("file_url: %s.", gitem->item->file_url); + } + + if (ugd->file_select_mode == GE_FILE_SELECT_T_SETAS) { + /* imageviewer only supprot image type while setting wallpaper */ + if(gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE) { + _ge_set_current_item(gitem); + ge_dbg("Loading UG-IMAGE(VIDEO)-VIEWER"); + ge_ext_load_iv_ug(ugd); + } else if (gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO && + ugd->popup == NULL) { + ge_ui_create_popup(ugd, GE_POPUP_ONEBUT, + GE_POPUP_ONLY_SUPPORT_IMAGE); + } + + } else if (gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE || + gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO) { + _ge_set_current_item(gitem); + ge_dbg("Loading UG-IMAGE(VIDEO)-VIEWER"); + ge_ext_load_iv_ug(ugd); + } +} + +static void _ge_grid_icon_clicked(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); + GE_CHECK(data); + _ge_grid_sel(data, obj, event_info); +} + +static void _ge_grid_item_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down*)event_info; + if(ev) + { + GE_CHECK(data); + GE_CHECK(obj); + ge_item *gitem = (ge_item *)data; + GE_CHECK(gitem->ugd); + ge_ugdata *ugd = gitem->ugd; + + ge_touch_info.x = ev->output.x; + ge_touch_info.y = ev->output.y; + + if(ugd->ug_called_by_me == NULL) + { + edje_object_signal_emit(_EDJ(obj), "mouse,down,shrink", "bg"); + ge_touch_info.b_pressed = true; + } + } +} +/* +static Eina_Bool _ge_grid_clicked_timer_cb(void *data) +{ + GE_CHECK_CANCEL(data); + ge_item *gitem = (ge_item *)data; + GE_CHECK_CANCEL(gitem->ugd); + ge_ugdata *ugd = gitem->ugd; + + _ge_grid_icon_clicked(data, NULL, NULL); + + GE_IF_DEL_TIMER(ugd->thumbs_clicked_timer) + + return ECORE_CALLBACK_CANCEL; +} +*/ + +static void _ge_grid_shrink_resp_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + ge_dbg(""); + GE_CHECK(obj); + GE_CHECK(data); + ge_item *gitem = (ge_item *)data; + GE_CHECK(gitem->ugd); +/* ge_ugdata *ugd = gitem->ugd; + + ugd->thumbs_clicked_timer = ecore_timer_add(GE_GIRD_ICON_CLICK_TIME_DELAY, _ge_grid_clicked_timer_cb, data); +*/ + _ge_grid_icon_clicked(data, obj, NULL); + + edje_object_signal_callback_del(obj, "shrink,expand,done", "bg", _ge_grid_shrink_resp_cb); +} + +static void _ge_grid_item_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + GE_CHECK(obj); + Evas_Event_Mouse_Up *ev = event_info; + + if(!ev) + { + goto RET_WO_EXEC; + } + + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD || ev->event_flags & EVAS_EVENT_FLAG_ON_SCROLL) + { + goto RET_WO_EXEC; + } + if((abs(ge_touch_info.x - ev->output.x) > GE_ITEM_MOUSE_UP_DISTANCE_X) || (abs(ge_touch_info.y - ev->output.y) > GE_ITEM_MOUSE_UP_DISTANCE_Y)) + { + goto RET_WO_EXEC; + } + + ge_dbg(""); + + if(ge_touch_info.b_pressed) + { + edje_object_signal_emit(_EDJ(obj), "mouse,up,expand", "bg"); + edje_object_signal_callback_add(_EDJ(obj), "shrink,expand,done", "bg", _ge_grid_shrink_resp_cb, data); + ge_touch_info.b_pressed = false; + } + return; + +RET_WO_EXEC: + if(ge_touch_info.b_pressed) + { + edje_object_signal_emit(_EDJ(obj), "mouse,up,expand", "bg"); + ge_touch_info.b_pressed = false; + } +} + +static void _ge_grid_check_changed(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); + GE_CHECK(obj); + GE_CHECK(data); + ge_item *gitem = (ge_item *)data; + GE_CHECK(gitem->item); + GE_CHECK(gitem->item->file_url); + GE_CHECK(gitem->ugd); + ge_ugdata *ugd = gitem->ugd; + GE_CHECK(ugd->service); + + if(_ge_get_view_mode() != GE_VIEW_THUMBS_EDIT) { + ge_dbgE("Wrong view mode!"); + return; + } + + + Eina_Bool checked = elm_check_state_get(obj); + if(checked) { + /* add for one file selection */ + if(ugd->file_select_mode == GE_FILE_SELECT_T_ONE) { + ge_dbg("Service add:%s", gitem->item->file_url); + /* Hide checked state in one file selection */ + elm_check_state_set(obj, false); + + service_add_extra_data(ugd->service, + GE_FILE_SELECT_RETURN_PATH, + gitem->item->file_url); + ug_send_result(ugd->ug, ugd->service); + ug_destroy_me(ugd->ug); + return; + } else { + ge_dbg("Append:%s", gitem->item->file_url); + _ge_data_selected_list_append( gitem ); + } + } else if (ugd->file_select_mode != GE_FILE_SELECT_T_ONE) { + ge_dbg("Remove:%s", gitem->item->file_url); + _ge_data_selected_list_remove( gitem ); + } + + if(ugd->file_select_mode != GE_FILE_SELECT_T_ONE) { + gitem->checked = checked; + _ge_ui_create_selinfo(ugd, ugd->thumbs_view_ly); + } +} + +static void __ge_grid_thumb_created_cb(media_content_error_e error, + const char *path, void *user_data) +{ + GE_CHECK(user_data); + ge_item *gitem = (ge_item *)user_data; + GE_CHECK(gitem->item); + + if (GE_FILE_EXISTS(path)) { + ge_dbg("Update item with new thumb path[%s]", path); + /* Update thumb path */ + GE_FREEIF(gitem->item->thumb_url); + gitem->item->thumb_url = strdup(path); + elm_gengrid_item_update(gitem->elm_item); + } else { + ge_dbgE("Invalid thumb path!"); + } +} + +static Evas_Object *__ge_grid_get_content(void *data, Evas_Object *obj, const char *part) +{ + GE_CHECK_NULL(data); + GE_CHECK_NULL(part); + GE_CHECK_NULL(obj); + ge_item *gitem = NULL; + bool is_expired_drm = false; + + if(strlen(part) <= 0) { + ge_dbgE("part length <= 0"); + return NULL; + } + + gitem = (ge_item*)data; + GE_CHECK_NULL(gitem->item); + GE_CHECK_NULL(gitem->ugd); + ge_ugdata *ugd = gitem->ugd; + GE_CHECK_NULL(ugd->thumbs_view); + + if (!g_strcmp0(part, "elm.swallow.icon")) { + Evas_Object *layout = NULL; + char *path = NULL; + char *drm_path = NULL; + unsigned int orient = 0; + + /* Is it DRM file? Has a valid RO? */ + if(ge_drm_is_drm_file(gitem->item->file_url) && + ge_drm_check_valid_ro(gitem->item->file_url, ge_drm_get_permtype(gitem->item->type)) == false) { + path = GE_DEFAULT_THUMB_ICON;; + is_expired_drm = true; + } else if (ge_grid_item_cnt < 2 && + gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE) { + if (!g_strcmp0(GE_DB_DEFAULT_THUMB, gitem->item->thumb_url)) { + path = GE_DEFAULT_THUMB_ICON; + } else { + drm_path = ge_drm_get_file_path(gitem); + path = _GE_GET_ICON(drm_path); + if (_ge_is_image_valid(ugd, path) == false) + path = _GE_GET_ICON(gitem->item->thumb_url); +#ifdef _USE_ROTATE_BG_GE + /* Rotate bg if it's created from original file */ + if (!g_strcmp0(path, gitem->item->file_url)) + _ge_exif_get_orientation(path, &orient); +#endif + } + } else { + /* Use default image */ + if (GE_FILE_EXISTS(gitem->item->thumb_url)) { + path = gitem->item->thumb_url; + } else { + path = GE_DEFAULT_THUMB_ICON; + if (GE_FILE_EXISTS(gitem->item->file_url)) + _ge_data_create_thumb(gitem, + __ge_grid_thumb_created_cb, + gitem); + } + } + + if(gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO){ + unsigned int v_dur = 0; + if (gitem->item->video_info) { + v_dur = gitem->item->video_info->duration; + } + int bk_len = 0; + if (gitem->item->video_info == NULL) + bk_len = 0; + else + bk_len = gitem->item->video_info->bookmarks; + layout = _ge_thumb_show_part_icon_video(obj, path, + v_dur, bk_len, + gitem->item->favorite, + is_expired_drm, + ugd->icon_size); + + } else { + layout = _ge_thumb_show_part_icon_image(obj, path, + orient, + gitem->item->favorite, + is_expired_drm, + ugd->icon_size); + } + GE_FREEIF(drm_path); + + evas_object_event_callback_add(layout, + EVAS_CALLBACK_MOUSE_DOWN, _ge_grid_item_mouse_down, gitem); + evas_object_event_callback_add(layout, + EVAS_CALLBACK_MOUSE_UP, _ge_grid_item_mouse_up, gitem); + + return layout; + } else if (!g_strcmp0(part, "elm.swallow.end") && + (_ge_get_view_mode() == GE_VIEW_THUMBS_EDIT)) { + Evas_Object* ck = NULL; + + ck = elm_check_add(obj); + GE_CHECK_NULL(ck); + elm_object_style_set(ck, GE_CHECKBOX_STYLE_GRID); + evas_object_propagate_events_set(ck, EINA_FALSE); + + gitem->check_obj = ck; + elm_check_state_set(ck, gitem->checked); + + evas_object_smart_callback_add(ck, "changed", + _ge_grid_check_changed, data); + evas_object_show(ck); + + return ck; + } + + return NULL; +} + +static bool _ge_grid_create_thumb(ge_ugdata* ugd, Evas_Object* parent) +{ + ge_dbg(""); + GE_CHECK_FALSE(parent); + GE_CHECK_FALSE(ugd); + int i = 0; + ge_item* gitem = NULL; + int cnt = _ge_data_get_count_all(); + int item_cnt = 0; + ge_dbg("List count : %d", cnt); + + gic.item_style = "thumbnail_view"; + gic.func.text_get = NULL; + gic.func.content_get = __ge_grid_get_content; + + elm_gengrid_clear(parent); + if(ugd->th) + { + elm_object_theme_set(parent, ugd->th); + } + elm_object_style_set(parent, "gallery_efl/default"); + + for(i = 1; i <= cnt; i++) + { + _ge_data_get_item_by_index(&gitem, i); + if(gitem == NULL || gitem->item == NULL || + gitem->item->uuid == NULL) { + ge_dbgE("Invalid gitem, continue..."); + continue; + } + + if(!gitem->item->file_url) + { + _ge_data_del_media_id(ugd, gitem->item->uuid); + _ge_data_item_list_remove(gitem); + --i; + --cnt; + continue; + } + + /*if(_ge_get_view_mode() == GE_VIEW_THUMBS_EDIT) + { + ge_media_s *new_item = NULL; + _ge_local_data_get_media(gitem->item->uuid, &new_item); + if(!new_item) + { + ge_dbg("item or file doesn't exist, remove it..."); + _ge_data_selected_list_remove(gitem); + _ge_data_item_list_remove(gitem); + + if(new_item) + { + _ge_data_type_free_geitem((void **)&new_item); + new_item = NULL; + } + --i; + --cnt; + continue; + } + + if(new_item) + { + _ge_data_type_free_geitem((void **)&new_item); + new_item = NULL; + } + }*/ + + gitem->elm_item = elm_gengrid_item_append(parent, &gic, gitem, _ge_grid_sel, gitem); + gitem->check_obj = NULL; + item_cnt++; + + } + + elm_gengrid_select_mode_set(parent, ELM_OBJECT_SELECT_MODE_NONE); + ge_grid_item_cnt = item_cnt; + if(item_cnt == 0) + { + return EINA_FALSE; + } + else + { + return EINA_TRUE; + } +} + +Evas_Object* ge_grid_create_ly(Evas_Object* parent) +{ + ge_dbg(""); + GE_CHECK_NULL(parent); + Evas_Object* layout = NULL; + + layout = ge_ui_load_edj(parent, GE_EDJ_FILE, GE_GRP_GRIDVIEW); + GE_CHECK_NULL(layout); + evas_object_show (layout); + + return layout; +} + +int ge_grid_del_callbacks(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + if(ugd->thumbs_view) + { + ge_dbg("Delete thumbnails callbacks!"); + evas_object_smart_callback_del(ugd->thumbs_view, "selected", _ge_grid_selected); + evas_object_smart_callback_del(ugd->thumbs_view, "unselected", _ge_grid_unselected); + evas_object_smart_callback_del(ugd->thumbs_view, "clicked", _ge_grid_clicked); + evas_object_smart_callback_del(ugd->thumbs_view, "longpressed", _ge_grid_longpress); + evas_object_smart_callback_del(ugd->thumbs_view, "drag,start,up", _ge_grid_drag_up); + evas_object_smart_callback_del(ugd->thumbs_view, "drag,start,right", _ge_grid_drag_right); + evas_object_smart_callback_del(ugd->thumbs_view, "drag,start,down", _ge_grid_drag_down); + evas_object_smart_callback_del(ugd->thumbs_view, "drag,start,left", _ge_grid_drag_left); + evas_object_smart_callback_del(ugd->thumbs_view, "drag,stop", _ge_grid_drag_stop); + } + return 0; +} + +/* +* When select album, show first (GE_FIRST_VIEW_END_POS+1) medias. +* Then use idler to get other medias from DB and appened +* them to gridview. +* In order to reduce transit time of first show of thumbnails view. +* Cause most of time is spent for getting records from DB, +* so we get first (GE_FIRST_VIEW_END_POS+1) items and show thumbnails view, +* it will accelerate view show. +*/ +int ge_grid_idler_append_thumbs(void* data) +{ + GE_CHECK_VAL(data, -1); + ge_ugdata *ugd = (ge_ugdata *)data; + GE_CHECK_VAL(ugd->thumbs_view, -1); + int i = 0; + int item_cnt = 0; + ge_item* gitem = NULL; + /* Get all medias count of current album */ + int cnt = _ge_data_get_count_all(); + int ret = -1; + ge_cluster* cur_album = _ge_get_current_album(); + GE_CHECK_VAL(cur_album, -1); + GE_CHECK_VAL(cur_album->cluster, -1); + ge_dbg("First view medias count: %d;", cnt); + + if(cnt != (GE_FIRST_VIEW_END_POS+1)) + { + ge_dbg("No any more items, return!"); + return -1; + } + /* Get other items from DB */ + ret = _ge_data_get_items_list(ugd, cur_album, (GE_FIRST_VIEW_END_POS+1), + GE_GET_UNTIL_LAST_RECORD); + ge_dbgW("###Get items list over[%d]###", ret); + if(ret < 0) { + ge_dbg("Get items list failed!"); + return ret; + } + + cnt = _ge_data_get_count_all(); + ge_dbg("Grid view all medias count: %d", cnt); + + + /* From (GL_FIRST_VIEW_END_POS + 2)th item to last one */ + i = GE_FIRST_VIEW_END_POS + 2; + + for(; i <= cnt; i++) + { + _ge_data_get_item_by_index(&gitem, i); + if(gitem == NULL || gitem->item == NULL || + gitem->item->uuid == NULL) { + ge_dbgE("Invalid gitem, continue..."); + continue; + } + + if(!gitem->item->file_url) + { + ge_dbg("file_url is invalid."); + _ge_data_del_media_id(ugd, gitem->item->uuid); + _ge_data_selected_list_remove(gitem); + _ge_data_item_list_remove(gitem); + cnt--; + i--; + gitem = NULL; + continue; + } + + gitem->elm_item = elm_gengrid_item_append(ugd->thumbs_view, &gic, gitem, _ge_grid_sel, gitem); + item_cnt++; + } + + ge_dbg("\n\n<<<<<<<win_scale; + item_w = (int)(GE_GRID_ITEM_SIZE_W * scale_factor); + item_h = (int)(GE_GRID_ITEM_SIZE_H * scale_factor); + icon_size = (int)(GE_GRID_ICON_SIZE * scale_factor); + ge_dbg("Own scale: %f, elm_config_scale_get =%f", scale_factor, elm_config_scale_get()); + + if(!_ge_grid_create_thumb(ugd, grid)) { + evas_object_del(grid); + grid = NULL; + + ugd->nocontents = ge_ui_create_nocontents(ugd); + evas_object_show (ugd->nocontents); + + return ugd->nocontents; + } else { + ge_dbg("ge_grid_item_cnt : %d", ge_grid_item_cnt); + if(ge_grid_item_cnt <= GE_GRID_ITEM_ZOOM_LEVEL_02_CNT) { + item_w *= GE_GRID_ITEM_ZOOM_LEVEL_02; + item_h *= GE_GRID_ITEM_ZOOM_LEVEL_02; + icon_size *= GE_GRID_ITEM_ZOOM_LEVEL_02; + } + + ugd->icon_size = icon_size; + evas_object_show (grid); + } + + + elm_gengrid_item_size_set(grid, item_w, item_h); + ge_dbg("Gengrid item w: %d, h: %d.", item_w, item_h); + elm_gengrid_align_set(grid, 0.5, 0.0); + elm_gengrid_horizontal_set(grid, EINA_FALSE); + elm_scroller_bounce_set(grid, EINA_FALSE, EINA_TRUE); + elm_gengrid_multi_select_set(grid, EINA_TRUE); + + evas_object_smart_callback_add(grid, "selected", _ge_grid_selected, NULL); + evas_object_smart_callback_add(grid, "unselected", _ge_grid_unselected, NULL); + evas_object_smart_callback_add(grid, "clicked", _ge_grid_clicked, NULL); + evas_object_smart_callback_add(grid, "longpressed", _ge_grid_longpress, NULL); + evas_object_smart_callback_add(grid, "drag,start,up", _ge_grid_drag_up, NULL); + evas_object_smart_callback_add(grid, "drag,start,right", _ge_grid_drag_right, NULL); + evas_object_smart_callback_add(grid, "drag,start,down", _ge_grid_drag_down, NULL); + evas_object_smart_callback_add(grid, "drag,start,left", _ge_grid_drag_left, NULL); + evas_object_smart_callback_add(grid, "drag,stop", _ge_grid_drag_stop, NULL); + evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + return grid; +} + +int ge_grid_clear_view(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + if(ugd->file_select_mode == GE_FILE_SELECT_T_ONE) + service_remove_extra_data(ugd->service, + GE_FILE_SELECT_RETURN_PATH); + + if(ugd->thumbs_view) { + if(ugd->thumbs_nocontents != ugd->thumbs_view) + ge_grid_del_callbacks(ugd); + + evas_object_del(ugd->thumbs_view); + ugd->thumbs_view = NULL; + ugd->thumbs_nocontents = NULL; + ugd->thumbs_nf_it = NULL; + } + + return 0; +} +int ge_grid_update_view(ge_ugdata *ugd) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + if(_ge_grid_create_thumb(ugd, ugd->thumbs_view) == EINA_FALSE) { + ge_grid_del_callbacks(ugd); + } else { + double scale_factor = ugd->win_scale; + int item_w = (int)(GE_GRID_ITEM_SIZE_W * scale_factor); + int item_h = (int)(GE_GRID_ITEM_SIZE_H * scale_factor); + int icon_size = (int)(GE_GRID_ICON_SIZE * scale_factor); + + ge_dbg("ge_grid_item_cnt : %d", ge_grid_item_cnt); + if(ge_grid_item_cnt <= GE_GRID_ITEM_ZOOM_LEVEL_02_CNT) { + item_w *= GE_GRID_ITEM_ZOOM_LEVEL_02; + item_h *= GE_GRID_ITEM_ZOOM_LEVEL_02; + icon_size *= GE_GRID_ITEM_ZOOM_LEVEL_02; + } + + ugd->icon_size = icon_size; + elm_gengrid_item_size_set(ugd->thumbs_view, item_w, item_h); + } + + return 0; +} + diff --git a/ug/ug-gallery-efl/src/ge-lang.c b/ug/ug-gallery-efl/src/ge-lang.c new file mode 100755 index 0000000..f30c87d --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-lang.c @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge-lang.h" +#include "ge-strings.h" +#include "ge-ui-util.h" +#include "ge-util.h" +#include "ge-debug.h" +#include "ge-data.h" + +static int __ge_lang_get_view_title(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + if (ugd->album_select_mode == GE_ALBUM_SELECT_T_ONE) { + g_strlcpy(ugd->albums_view_title, GE_TITLE_ALBUMS, + GE_ALBUM_NAME_LEN_MAX); + } else { + if (ugd->file_select_mode == GE_FILE_SELECT_T_SETAS) { + if (ugd->file_select_setas_mode == GE_SETAS_T_WALLPAPER) + g_strlcpy(ugd->albums_view_title, + GE_TITLE_CHANGE_WALLPAPER, + GE_ALBUM_NAME_LEN_MAX); + else if (ugd->file_select_setas_mode == GE_SETAS_T_CROP_WALLPAPER) + g_strlcpy(ugd->albums_view_title, + GE_TITLE_CHANGE_WALLPAPER, + GE_ALBUM_NAME_LEN_MAX); + else if (ugd->file_select_setas_mode == GE_SETAS_T_CALLERID) + g_strlcpy(ugd->albums_view_title, + GE_TITLE_CHANGE_CALLER_ID, + GE_ALBUM_NAME_LEN_MAX); + } else { + g_strlcpy(ugd->albums_view_title, GE_TITLE_ADD, + GE_ALBUM_NAME_LEN_MAX); + g_strlcat(ugd->albums_view_title, " ", + GE_ALBUM_NAME_LEN_MAX); + bool b_singular = true; + if(ugd->file_select_mode == GE_FILE_SELECT_T_MULTIPLE) { + b_singular = false; + } + if (ugd->file_type_mode == GE_FILE_T_IMAGE) { + if(b_singular) { + g_strlcat(ugd->albums_view_title, + GE_TITLE_IMAGE, + sizeof(ugd->albums_view_title)); + } else { + g_strlcat(ugd->albums_view_title, + GE_TITLE_IMAGES, + sizeof(ugd->albums_view_title)); + } + } else if (ugd->file_type_mode == GE_FILE_T_VIDEO) { + if(b_singular) { + g_strlcat(ugd->albums_view_title, + GE_TITLE_VIDEO, + sizeof(ugd->albums_view_title)); + } else { + g_strlcat(ugd->albums_view_title, + GE_TITLE_VIDEOS, + sizeof(ugd->albums_view_title)); + } + } else { + if(b_singular) { + g_strlcat(ugd->albums_view_title, + GE_TITLE_FILE, + sizeof(ugd->albums_view_title)); + } else { + g_strlcat(ugd->albums_view_title, + GE_TITLE_FILES, + sizeof(ugd->albums_view_title)); + } + } + } + } + return 0; +} + +static int __ge_lang_update_all_albums_name(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + + ge_cluster *album = NULL; + Elm_Object_Item *first_it = NULL; + Elm_Object_Item *next_it = NULL; + Elm_Object_Item *last_it = NULL; + Evas_Object *grid_view = NULL; + GE_CHECK_VAL(ugd->albums_view, -1); + grid_view = ugd->albums_view; + + first_it = elm_gengrid_first_item_get(grid_view); + last_it = elm_gengrid_last_item_get(grid_view); + while(first_it) { + album = (ge_cluster *)elm_object_item_data_get(first_it); + if (album == NULL) { + ge_dbgE("Invalid item data!"); + continue; + } + if (!g_strcmp0(album->cluster->uuid, GE_ALBUM_ALL_ID)) { + GE_FREEIF(album->cluster->display_name); + album->cluster->display_name = strdup(GE_ALBUM_ALL_NAME); + elm_gengrid_item_update(first_it); + } else if (_ge_data_is_default_album(GE_ALBUM_CAMERA_NAME, album->cluster) || + _ge_data_is_default_album(GE_ALBUM_DOWNLOAD_NAME, album->cluster) || + _ge_data_is_root_path(album->cluster->path)) { + elm_gengrid_item_update(first_it); + } + if (last_it == first_it) { + ge_dbg("Update done!"); + break; + } else { + next_it = elm_gengrid_item_next_get(first_it); + first_it = next_it; + } + album = NULL; + } + return 0; +} + +static int __ge_lang_update_select_info(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(ugd->selinfo_ly, -1); + + int count = 0; + char text[GE_SELINFO_TEXT_LEN_MAX] = {0,}; + + count = _ge_data_selected_list_count(); + if (count <= 0) + return -1; + snprintf(text, sizeof(text), "%s (%d)", GE_SELINFO_SELECTED, count); + text[strlen(text)] = '\0'; + edje_object_part_text_set(_EDJ(ugd->selinfo_ly), "elm.text", text); + return 0; +} + +int _ge_lang_update(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + ge_dbg(""); + if(_ge_get_view_mode() == GE_VIEW_THUMBS) { + if (ugd->thumbs_nf_it) { + ge_cluster *album_item = _ge_get_current_album(); + if(_ge_data_is_root_path(album_item->cluster->path)) { + elm_object_item_text_set(ugd->thumbs_nf_it, + GE_ALBUM_ROOT_NAME); + } else { + char *new_name = _ge_ui_get_translated_album_name(album_item); + elm_object_item_text_set(ugd->thumbs_nf_it, + new_name); + } + __ge_lang_update_select_info(ugd); + } + } else { + __ge_lang_get_view_title(ugd); + + if (_ge_get_view_mode() == GE_VIEW_ALBUMS) { + elm_object_item_text_set(ugd->albums_nf_it, + ugd->albums_view_title); + __ge_lang_update_all_albums_name(ugd); + } else { + elm_object_item_text_set(ugd->thumbs_nf_it, + ugd->albums_view_title); + __ge_lang_update_select_info(ugd); + } + } + + return 0; +} + diff --git a/ug/ug-gallery-efl/src/ge-local-data.c b/ug/ug-gallery-efl/src/ge-local-data.c new file mode 100755 index 0000000..81c52cb --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-local-data.c @@ -0,0 +1,612 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "ge-local-data.h" +#include "ge-debug.h" + +typedef struct _ge_transfer_data_t ge_transfer_data_s; + +struct _ge_transfer_data_t { + void **userdata; + filter_h filter; + char *album_id; + bool with_meta; +}; + +static int __ge_local_data_create_filter(ge_filter_s *condition, filter_h *filter) +{ + GE_CHECK_VAL(filter, -1); + GE_CHECK_VAL(condition, -1); + int ret = -1; + filter_h tmp_filter = NULL; + + ret = media_filter_create(&tmp_filter); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Fail to create filter!"); + return -1; + } + + if (strlen(condition->cond) > 0) { + ret = media_filter_set_condition(tmp_filter, condition->cond, + condition->collate_type); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Fail to set condition!"); + goto GE_LOCAL_FAILED; + } + } + + if (strlen(condition->sort_keyword) > 0) { + ret = media_filter_set_order(tmp_filter, condition->sort_type, + condition->sort_keyword, + condition->collate_type); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Fail to set order!"); + goto GE_LOCAL_FAILED; + } + } + + ge_dbg("offset: %d, count: %d", condition->offset, condition->count); + if (condition->offset != -1 && condition->count != -1 && + condition->count > 0) { + ret = media_filter_set_offset(tmp_filter, condition->offset, + condition->count); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Fail to set offset!"); + goto GE_LOCAL_FAILED; + } + } + + *filter = tmp_filter; + return 0; + + GE_LOCAL_FAILED: + + if (tmp_filter) { + media_filter_destroy(tmp_filter); + tmp_filter = NULL; + *filter = NULL; + } + return -1; +} + +static int __ge_local_data_destroy_filter(filter_h filter) +{ + GE_CHECK_VAL(filter, -1); + + if (media_filter_destroy(filter) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Failed to destroy filter!"); + return -1; + } + + return 0; +} + +static bool __ge_local_data_get_album_list_cb(media_folder_h folder, + void *data) +{ + GE_CHECK_FALSE(data); + ge_transfer_data_s *tmp_data = (ge_transfer_data_s *)data; + GE_CHECK_FALSE(tmp_data->userdata); + GE_CHECK_FALSE(tmp_data->filter); + GE_CHECK_FALSE(folder); + + Eina_List **elist = (Eina_List **)(tmp_data->userdata); + ge_album_s *album = NULL; + + album = (ge_album_s *)calloc(1, sizeof(ge_album_s)); + GE_CHECK_FALSE(album); + album->gtype = GE_TYPE_ALBUM; + + if (media_folder_clone(&(album->folder_h), folder) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Clone folder handle error"); + goto GE_LOCAL_FAILED; + } + + if (media_folder_get_folder_id(folder, &(album->uuid)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get folder id error"); + goto GE_LOCAL_FAILED; + } + + if (media_folder_get_modified_time(folder, &(album->mtime)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get modified time error"); + goto GE_LOCAL_FAILED; + } + + if (media_folder_get_storage_type(folder, (media_content_storage_e *)&(album->type)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get storage type error"); + goto GE_LOCAL_FAILED; + } + + if (media_folder_get_name(folder, &(album->display_name)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get folder name error"); + goto GE_LOCAL_FAILED; + } + + if (media_folder_get_path(folder, &(album->path)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get folder name error"); + goto GE_LOCAL_FAILED; + } + + if (media_folder_get_media_count_from_db(album->uuid, tmp_data->filter, &(album->count)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media count error, %d", album->count); + goto GE_LOCAL_FAILED; + } + + *elist = eina_list_append(*elist, album); + + return true; + + GE_LOCAL_FAILED: + + _ge_data_type_free_geitem((void **)(&album)); + return false; +} + +static bool __ge_local_data_get_media_list_cb(media_info_h media, void *data) +{ + GE_CHECK_FALSE(data); + ge_transfer_data_s *tmp_data = (ge_transfer_data_s *)data; + GE_CHECK_FALSE(tmp_data->userdata); + GE_CHECK_FALSE(media); + ge_media_s *item = NULL; + ge_image_s *image_info = NULL; + ge_video_s *video_info = NULL; + image_meta_h image_handle = NULL; + video_meta_h video_handle = NULL; + int ret = -1; + + Eina_List **elist = (Eina_List **)(tmp_data->userdata); + + item = (ge_media_s *)calloc(1, sizeof(ge_media_s)); + GE_CHECK_FALSE(item); + item->gtype = GE_TYPE_MEDIA; + + if (media_info_clone(&(item->media_h), media) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Clone media handle error"); + goto GE_LOCAL_FAILED; + } + + if (media_info_get_media_id(media, &(item->uuid)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media id error"); + goto GE_LOCAL_FAILED; + } + + if (media_info_get_display_name(media, &(item->display_name)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media display name error"); + goto GE_LOCAL_FAILED; + } + if (media_info_get_file_path(media, &(item->file_url)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media file path error"); + goto GE_LOCAL_FAILED; + } + + if (media_info_get_media_type(media, (media_content_type_e *)&(item->type)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media type error"); + goto GE_LOCAL_FAILED; + } + + if (media_info_get_thumbnail_path(media, &(item->thumb_url)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media thumbnail path error"); + goto GE_LOCAL_FAILED; + } + ge_dbg("thumb_url: %s", item->thumb_url); + + if (media_info_get_modified_time(media, &(item->mtime)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media modified time error"); + goto GE_LOCAL_FAILED; + } + + if (media_info_get_favorite(media, &(item->favorite)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media rating error"); + goto GE_LOCAL_FAILED; + } + /* Without meta */ + if (!tmp_data->with_meta) + goto GE_LOCAL_SUCCESS; + + if (item->type == MEDIA_CONTENT_TYPE_IMAGE) { + ret = media_info_get_image(media, &image_handle); + if (ret != MEDIA_CONTENT_ERROR_NONE || image_handle == NULL) { + ge_dbgE("Failed to get image handle[%d]!", ret); + goto GE_LOCAL_FAILED; + } + + image_info = (ge_image_s *)calloc(1, sizeof(ge_image_s)); + if (NULL == image_info){ + ge_dbgE("calloc failed!"); + goto GE_LOCAL_FAILED; + } + item->image_info = image_info; + + if (image_meta_clone(&(image_info->image_h), image_handle) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Clone image handle error"); + goto GE_LOCAL_FAILED; + + } + if (image_meta_get_media_id(image_handle, &(image_info->media_uuid)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get image id error"); + goto GE_LOCAL_FAILED; + } + + if (image_meta_get_orientation(image_handle, &(image_info->orientation)) != 0) { + ge_dbgE("Get image orientation error"); + goto GE_LOCAL_FAILED; + } + + if (image_meta_destroy(image_handle) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Destroy image handle error"); + goto GE_LOCAL_FAILED; + } + } else if (item->type == MEDIA_CONTENT_TYPE_VIDEO) { + ret = media_info_get_video(media, &video_handle); + if (ret != MEDIA_CONTENT_ERROR_NONE || video_handle == NULL) { + ge_dbgE("Failed to get video handle[%d]!", ret); + goto GE_LOCAL_FAILED; + } + + video_info = (ge_video_s *)calloc(1, sizeof(ge_video_s)); + if (NULL == video_info) { + goto GE_LOCAL_FAILED; + } + + item->video_info = video_info; + if (video_meta_clone(&(video_info->video_h), video_handle) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Clone video handle error"); + goto GE_LOCAL_FAILED; + } + if (video_meta_get_media_id(video_handle, &(video_info->media_uuid)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get video id error"); + goto GE_LOCAL_FAILED; + } + if (video_meta_get_title(video_handle, &(video_info->title)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get video title error"); + goto GE_LOCAL_FAILED; + } + if (video_meta_get_duration(video_handle, &(video_info->duration)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get video duration error"); + goto GE_LOCAL_FAILED; + } + if (video_meta_get_played_time(video_handle, &(video_info->last_played_pos)) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get video last played position error"); + goto GE_LOCAL_FAILED; + } + + if (video_meta_destroy(video_handle) != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Destroy video handle error"); + goto GE_LOCAL_FAILED; + } + + /* Get bookmar elist in case of video */ + if (video_info->media_uuid) { + video_info->bookmarks = 0; + int count = 0; + ret = media_info_get_bookmark_count_from_db(video_info->media_uuid, + NULL, + &count); + if (ret != MEDIA_CONTENT_ERROR_NONE) + ge_dbgE("Failed to get bookmark[%d]", ret); + else + video_info->bookmarks = count; + } + } + + GE_LOCAL_SUCCESS: + + if (tmp_data->album_id) + item->album_uuid = strdup(tmp_data->album_id); + else + item->album_uuid = NULL; + + *elist = eina_list_append(*elist, item); + return true; + + GE_LOCAL_FAILED: + + if (image_handle) + image_meta_destroy(image_handle); + if (video_handle) + video_meta_destroy(video_handle); + + _ge_data_type_free_geitem((void **)(&item)); + return false; +} + +int _ge_local_data_connect(void) +{ + int ret = -1; + + ret = media_content_connect(); + if(ret == MEDIA_CONTENT_ERROR_NONE) { + ge_dbg("DB connection is success"); + return 0; + } else { + ge_dbgE("DB connection is failed!"); + return -1; + } +} + +int _ge_local_data_disconnect(void) +{ + int ret = -1; + + ret = media_content_disconnect(); + if(ret == MEDIA_CONTENT_ERROR_NONE) { + ge_dbg("DB disconnection is success"); + return 0; + } else { + ge_dbgE("DB disconnection is failed!"); + return -1; + } +} + +int _ge_local_data_get_album_list(ge_filter_s *condition, Eina_List **elilst) +{ + GE_CHECK_VAL(elilst, -1); + GE_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __ge_local_data_create_filter(condition, &filter); + if (ret != 0) { + ge_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + filter_h media_filter = NULL; + ge_filter_s media_condition; + memset(&media_condition, 0x00, sizeof(ge_filter_s)); + if (strlen(condition->cond)) + g_strlcpy(media_condition.cond, condition->cond, + CONDITION_LENGTH); + memset(condition->cond, 0x00, CONDITION_LENGTH); + media_condition.sort_type = MEDIA_CONTENT_ORDER_DESC; + g_strlcpy(media_condition.sort_keyword, MEDIA_MODIFIED_TIME, + KEYWORD_LENGTH); + media_condition.collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + media_condition.offset = -1; + media_condition.count = -1; + media_condition.with_meta = false; + + ret = __ge_local_data_create_filter(&media_condition, &media_filter); + if (ret != 0) { + __ge_local_data_destroy_filter(filter); + ge_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + ge_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(ge_transfer_data_s)); + tran_data.userdata = (void **)elilst; + tran_data.filter = media_filter; + tran_data.album_id = NULL; + tran_data.with_meta = false; + + ge_dbg("Get folders--start"); + ret = media_folder_foreach_folder_from_db(filter, + __ge_local_data_get_album_list_cb, + &tran_data); + ge_dbg("Get folders--over"); + + __ge_local_data_destroy_filter(media_filter); + __ge_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get folders failed[%d]!", ret); + return -1; + } + + return 0; +} + +int _ge_local_data_get_media_count(const char *cluster_id, ge_filter_s *condition, + int *item_cnt){ + GE_CHECK_VAL(cluster_id, -1); + GE_CHECK_VAL(condition, -1); + GE_CHECK_VAL(item_cnt, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __ge_local_data_create_filter(condition, &filter); + if (ret != 0) { + ge_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + ge_dbg("Get media count--start"); + ret = media_folder_get_media_count_from_db(cluster_id, filter, + item_cnt); + ge_dbg("Get media count--over"); + + __ge_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media count failed[d]!", ret); + return -1; + } + + return 0; +} + +int _ge_local_data_get_all_media_count(ge_filter_s *condtion, int *item_cnt) +{ + GE_CHECK_VAL(condtion, -1); + GE_CHECK_VAL(item_cnt, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __ge_local_data_create_filter(condtion, &filter); + if (ret != 0) { + ge_dbgE("Create filter failed[%d]!", ret); + return -1; + } + + ge_dbg("Get media count--start"); + ret = media_info_get_media_count_from_db(filter, item_cnt); + ge_dbg("Get media count--over"); + + __ge_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media count failed[d]!", ret); + return -1; + } + + return 0; +} + +int _ge_local_data_get_media(const char *media_id, ge_media_s **mitem) +{ + GE_CHECK_VAL(mitem, -1); + + if (media_id == NULL) { + ge_dbg("Create a empty media"); + _ge_data_type_new_media(mitem); + return 0; + } + + int ret = -1; + Eina_List *list = NULL; + ge_media_s *_mitem = NULL; + int i = 0; + + ge_dbg("media id: %s", media_id); + media_info_h media_h = NULL; + + ret = media_info_get_media_from_db(media_id, &media_h); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get media handle failed[%d]!", ret); + if (media_h) + media_info_destroy(media_h); + return -1; + } + + ge_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(ge_transfer_data_s)); + tran_data.userdata = (void **)&list; + tran_data.filter = NULL; + tran_data.album_id = NULL; + tran_data.with_meta = false; + + ge_dbg("Get media list--start"); + bool b_ret = __ge_local_data_get_media_list_cb(media_h, &tran_data); + ge_dbg("Get media list--over"); + + media_info_destroy(media_h); + + if (b_ret && list) { + *mitem = eina_list_nth(list, 0); + i = 1; + ret = 0; + } else { + ge_dbgE("Failed to get media list!"); + ret = -1; + } + + /* Free other items */ + if (list) { + int len = eina_list_count(list); + ge_dbg("len: %d", len); + + for(; i < len; i++) { + _mitem = eina_list_nth(list, i); + _ge_data_type_free_geitem((void **)(&_mitem)); + } + + eina_list_free(list); + } + + return ret; +} + +int _ge_local_data_get_album_media_list(char *album_id, ge_filter_s *condition, + Eina_List **elist) +{ + GE_CHECK_VAL(elist, -1); + GE_CHECK_VAL(album_id, -1); + GE_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __ge_local_data_create_filter(condition, &filter); + if (ret != 0) { + ge_dbgE("Create filter failed!"); + return -1; + } + + ge_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(ge_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = NULL; + tran_data.album_id = album_id; + tran_data.with_meta = condition->with_meta; + + ge_dbg("Get medias--start"); + ret = media_folder_foreach_media_from_db(album_id, filter, + __ge_local_data_get_media_list_cb, + &tran_data); + ge_dbg("Get medias--over"); + + __ge_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get medias failed[d]!", ret); + return -1; + } + + return 0; +} + +int _ge_local_data_get_all_albums_media_list(ge_filter_s *condition, + Eina_List **elist) +{ + GE_CHECK_VAL(elist, -1); + GE_CHECK_VAL(condition, -1); + int ret = -1; + filter_h filter = NULL; + + ret = __ge_local_data_create_filter(condition, &filter); + if (ret != 0) { + ge_dbgE("Create filter failed!"); + return -1; + } + + ge_transfer_data_s tran_data; + memset(&tran_data, 0x00, sizeof(ge_transfer_data_s)); + tran_data.userdata = (void **)elist; + tran_data.filter = NULL; + tran_data.album_id = NULL; + tran_data.with_meta = condition->with_meta; + + ge_dbg("Get all medias--start"); + ret = media_info_foreach_media_from_db(filter, + __ge_local_data_get_media_list_cb, + &tran_data); + ge_dbg("Get all medias--over"); + + __ge_local_data_destroy_filter(filter); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Get all medias failed[d]!", ret); + return -1; + } + + return 0; +} + diff --git a/ug/ug-gallery-efl/src/ge-rotate-bg.c b/ug/ug-gallery-efl/src/ge-rotate-bg.c new file mode 100755 index 0000000..8b0a369 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-rotate-bg.c @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef _USE_ROTATE_BG_GE + +#include "ge-rotate-bg.h" +#include "ge-exif.h" +#include "ge-debug.h" +#include "ge-icon.h" + +#define GE_ROTATE_BG_DATA_KEY "ge_bg_data" +#define GE_ROTATE_BG_GROUP "ge_bg_layout" + +typedef struct _ge_bg { + Evas_Object *base; + Evas_Object *img; + char *file; +} ge_bg; + +static int __ge_rotate_bg_image_rotate_180(Evas_Object *obj) +{ + GE_CHECK_VAL(obj, -1); + unsigned int *data = NULL; + unsigned int *data2 = NULL; + unsigned int *to = NULL; + unsigned int *from = NULL; + int x = 0; + int hw = 0; + int iw = 0; + int ih = 0; + + evas_object_image_size_get(obj, &iw, &ih); + int size = iw * ih * sizeof(unsigned int); + + /* EINA_FALSE for reading */ + data = evas_object_image_data_get(obj, EINA_FALSE); + /* memcpy */ + data2 = calloc(1, size); + GE_CHECK_VAL(data2, -1); + memcpy(data2, data, size); + + data = evas_object_image_data_get(obj, EINA_TRUE); + + hw = iw * ih; + x = hw; + to = data; + from = data2 + hw - 1; + for (; --x >= 0;) { + *to = *from; + to++; + from--; + } + +#if 0 /* Failed to rotate icon created from original file */ + hw = iw * ih; + x = (hw / 2); + p1 = data; + p2 = data + hw - 1; + for (; --x > 0;) { + tmp = *p1; + *p1 = *p2; + *p2 = tmp; + p1++; + p2--; + } +#endif + + GE_FREE(data2); + + evas_object_image_data_set(obj, data); + evas_object_image_data_update_add(obj, 0, 0, iw, ih); + return 0; +} + +static int __ge_rotate_bg_image_rotate_90(Evas_Object *obj) +{ + GE_CHECK_VAL(obj, -1); + unsigned int *data = NULL; + unsigned int *data2 = NULL; + unsigned int *to = NULL; + unsigned int *from = NULL; + int x = 0; + int y = 0; + int w = 0; + int hw = 0; + int iw = 0; + int ih = 0; + + evas_object_image_size_get(obj, &iw, &ih); + int size = iw * ih * sizeof(unsigned int); + + /* EINA_FALSE for reading */ + data = evas_object_image_data_get(obj, EINA_FALSE); + /* memcpy */ + data2 = calloc(1, size); + GE_CHECK_VAL(data2, -1); + memcpy(data2, data, size); + + /* set width, height */ + w = ih; + ih = iw; + iw = w; + hw = w * ih; + + /* set width, height to image obj */ + evas_object_image_size_set(obj, iw, ih); + data = evas_object_image_data_get(obj, EINA_TRUE); + to = data + w - 1; + hw = -hw - 1; + from = data2; + + for (x = iw; --x >= 0;) { + for (y = ih; --y >= 0;) { + *to = *from; + from++; + to += w; + } + + to += hw; + } + + GE_FREE(data2); + + evas_object_image_data_set(obj, data); + evas_object_image_data_update_add(obj, 0, 0, iw, ih); + return 0; +} + +static int __ge_rotate_bg_image_rotate_270(Evas_Object *obj) +{ + GE_CHECK_VAL(obj, -1); + unsigned int *data = NULL; + unsigned int *data2 = NULL; + unsigned int *to = NULL; + unsigned int *from = NULL; + int x = 0; + int y = 0; + int w = 0; + int hw = 0; + int iw = 0; + int ih = 0; + + evas_object_image_size_get(obj, &iw, &ih); + int size = iw * ih * sizeof(unsigned int); + + /* EINA_FALSE for reading */ + data = evas_object_image_data_get(obj, EINA_FALSE); + /* memcpy */ + data2 = calloc(1, size); + GE_CHECK_VAL(data2, -1); + memcpy(data2, data, size); + + /* set width, height */ + w = ih; + ih = iw; + iw = w; + hw = w * ih; + + /* set width, height to image obj */ + evas_object_image_size_set(obj, iw, ih); + data = evas_object_image_data_get(obj, EINA_TRUE); + + to = data + hw - w; + w = -w; + hw = hw + 1; + from = data2; + + for (x = iw; --x >= 0;) { + for (y = ih; --y >= 0;) { + *to = *from; + from++; + to += w; + } + + to += hw; + } + + GE_FREE(data2); + + evas_object_image_data_set(obj, data); + evas_object_image_data_update_add(obj, 0, 0, iw, ih); + return 0; +} + +/* check its orientation */ +int __ge_rotate_bg_rotate_image(Evas_Object *obj, unsigned int orient) +{ + switch (orient){ + case GE_ORIENTATION_ROT_90: + __ge_rotate_bg_image_rotate_90(obj); + break; + case GE_ORIENTATION_ROT_180: + __ge_rotate_bg_image_rotate_180(obj); + break; + case GE_ORIENTATION_ROT_270: + __ge_rotate_bg_image_rotate_270(obj); + break; + default: + break; + } + + return 0; +} + +static void __ge_rotate_bg_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + if (data) { + ge_bg *bg_data = (ge_bg *)data; + GE_FREEIF(bg_data->file); + GE_FREE(data); + } +} + +static void __ge_rotate_bg_custom_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + GE_CHECK(data); + ge_bg *bg_data = (ge_bg *)data; + Evas_Coord bx = 0; + Evas_Coord by = 0; + Evas_Coord bw = 0; + Evas_Coord bh = 0; + Evas_Coord iw = 0; + Evas_Coord ih = 0; + Evas_Coord fx = 0; + Evas_Coord fy = 0; + Evas_Coord fw = 0; + Evas_Coord fh = 0; + Evas_Coord nx = 0; + Evas_Coord ny = 0; + Evas_Coord nw = 0; + Evas_Coord nh = 0; + + if ((!bg_data->img) || (!bg_data->base)) { + ge_dbgE("Invalid object!"); + return; + } + /* grab image size */ + evas_object_image_size_get(bg_data->img, &iw, &ih); + if ((iw < 1) || (ih < 1)) { + ge_dbgE("(iw < 1) || (ih < 1)!"); + return; + } + + /* grab base object dimensions */ + evas_object_geometry_get(bg_data->base, &bx, &by, &bw, &bh); + + /* set some defaults */ + nx = bx; + ny = by; + nw = bw; + nh = bh; + + + fw = bw; + fh = ((ih * fw) / iw); + if (fh < bh) { + fh = bh; + fw = ((iw * fh) / ih); + } + fx = ((bw - fw) / 2); + fy = ((bh - fh) / 2); + + evas_object_move(bg_data->img, nx, ny); + evas_object_resize(bg_data->img, nw, nh); + evas_object_image_fill_set(bg_data->img, fx, fy, fw, fh); +} + +Evas_Object *_ge_rotate_bg_add_layout(Evas_Object *parent, const char *file, const char *group) +{ + Evas_Object *eo = NULL; + int r = 0; + + eo = elm_layout_add(parent); + if (eo) { + r = elm_layout_file_set(eo, file, group); + if (!r) { + evas_object_del(eo); + return NULL; + } + + evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL); + } + + return eo; +} + +Evas_Object *_ge_rotate_bg_add(Evas_Object *parent) +{ + GE_CHECK_NULL(parent); + ge_dbg(""); + + ge_bg *bg_data = (ge_bg *)calloc(1, sizeof(ge_bg)); + GE_CHECK_NULL(bg_data); + + Evas_Object *base = NULL; + base = _ge_rotate_bg_add_layout(parent, GE_EDJ_FILE, + GE_ROTATE_BG_GROUP); + if (base == NULL) { + GE_FREE(bg_data); + return NULL; + } + + bg_data->base= base; + evas_object_event_callback_add(base, EVAS_CALLBACK_RESIZE, + __ge_rotate_bg_custom_resize, bg_data); + evas_object_event_callback_add(base, EVAS_CALLBACK_DEL, + __ge_rotate_bg_delete_cb, bg_data); + + evas_object_data_set(base, GE_ROTATE_BG_DATA_KEY, bg_data); + ge_dbg("base %p", base); + return base; +} + +int _ge_rotate_bg_set_file(Evas_Object *bg, const char *file, int w, int h) +{ + GE_CHECK_VAL(file, -1); + GE_CHECK_VAL(bg, -1); + + ge_bg *bg_data = evas_object_data_get(bg, GE_ROTATE_BG_DATA_KEY); + GE_CHECK_VAL(bg_data, -1); + + Evas_Object *image_obj = NULL; + image_obj = evas_object_image_add(evas_object_evas_get(bg)); + evas_object_repeat_events_set(image_obj, EINA_TRUE); + bg_data->img = image_obj; + bg_data->file = strdup(file); + elm_object_part_content_set(bg, "elm.swallow.image", image_obj); + evas_object_image_load_size_set(image_obj, w, h); + evas_object_image_file_set(image_obj, file, NULL); + evas_object_image_preload(image_obj, EINA_FALSE); + return 0; +} + +int _ge_rotate_bg_rotate_image(Evas_Object *bg, unsigned int orient) +{ + GE_CHECK_VAL(bg, -1); + + ge_bg *bg_data = evas_object_data_get(bg, GE_ROTATE_BG_DATA_KEY); + GE_CHECK_VAL(bg_data, -1); + + if (bg_data->file && g_strcmp0(bg_data->file, GE_DEFAULT_THUMB_ICON)) + __ge_rotate_bg_rotate_image(bg_data->img, orient); + else + __ge_rotate_bg_rotate_image(bg_data->img, GE_ORIENTATION_ROT_0); + __ge_rotate_bg_custom_resize(bg_data, NULL, NULL, NULL); + return 0; +} + +int _ge_rotate_bg_add_image(Evas_Object *bg, int w, int h) +{ + GE_CHECK_VAL(bg, -1); + + ge_bg *bg_data = evas_object_data_get(bg, GE_ROTATE_BG_DATA_KEY); + GE_CHECK_VAL(bg_data, -1); + + Evas_Object *image_obj = NULL; + image_obj = evas_object_image_add(evas_object_evas_get(bg)); + evas_object_image_size_set(image_obj, w, h); + evas_object_image_fill_set(image_obj, 0, 0, w, h); + evas_object_repeat_events_set(image_obj, EINA_TRUE); + bg_data->img = image_obj; + elm_object_part_content_set(bg, "elm.swallow.image", image_obj); + evas_object_image_load_size_set(image_obj, w, h); + return 0; +} + +int _ge_rotate_bg_set_image_file(Evas_Object *bg, const char *file) +{ + GE_CHECK_VAL(bg, -1); + + ge_bg *bg_data = evas_object_data_get(bg, GE_ROTATE_BG_DATA_KEY); + GE_CHECK_VAL(bg_data, -1); + GE_CHECK_VAL(bg_data->img, -1); + + evas_object_image_file_set(bg_data->img, file, NULL); + evas_object_image_preload(bg_data->img, EINA_FALSE); + + __ge_rotate_bg_custom_resize(bg_data, NULL, NULL, NULL); + return 0; +} + +#endif diff --git a/ug/ug-gallery-efl/src/ge-thumb.c b/ug/ug-gallery-efl/src/ge-thumb.c new file mode 100755 index 0000000..6b49ec7 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-thumb.c @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge-debug.h" +#include "ge-util.h" +#include "ge-drm.h" +#include "ge-strings.h" +#include "ge-icon.h" +#ifdef _USE_ROTATE_BG_GE +#include "ge-rotate-bg.h" +#include "ge-exif.h" +#endif + +#define GE_PHOTOFRAME_STYLE_VIDEO_FAVOR_BOOKMARK "default_layout_video_favor_bookmark" +#define GE_PHOTOFRAME_STYLE_VIDEO_BOOKMARK "default_layout_video_bookmark" +#define GE_PHOTOFRAME_STYLE_VIDEO_FAVOR "default_layout_video_favor" +#define GE_PHOTOFRAME_STYLE_VIDEO "default_layout_video" +#define GE_PHOTOFRAME_STYLE_FAVOR "default_layout_favor" +#define GE_PHOTOFRAME_STYLE_DEFAULT "default_layout" + +#define GE_CLASS_GENGRID "gengrid" +#define GE_GRP_PHOTOFRAME "photoframe" +#define GE_GRID_TEXT "elm.text" + +Evas_Object *_ge_thumb_show_part_icon_image(Evas_Object *obj, char *path, + unsigned int orient, bool b_favor, + bool is_expired_drm, int item_size) +{ + GE_CHECK_NULL(obj); + + Evas_Object *layout = elm_layout_add(obj); + GE_CHECK_NULL(layout); + +#ifdef _USE_ROTATE_BG_GE + Evas_Object *bg = _ge_rotate_bg_add(layout); +#else + Evas_Object *bg = elm_bg_add(layout); +#endif + if (bg == NULL) { + evas_object_del(layout); + return NULL; + } + +#ifdef _USE_ROTATE_BG_GE + _ge_rotate_bg_set_file(bg, path, item_size, item_size); + _ge_rotate_bg_rotate_image(bg, orient); +#else + elm_bg_file_set(bg, path, NULL); + elm_bg_load_size_set(bg, item_size, item_size); + evas_object_size_hint_max_set(bg, item_size, item_size); + evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); +#endif + + // TODO: Need to check the expired drm icon file... + /* Expired drm icon */ + if (is_expired_drm) { + elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME, + GE_PHOTOFRAME_STYLE_FAVOR); + elm_object_part_content_set(layout, "elm.swallow.icon", bg); + + Evas_Object *icon = elm_icon_add(layout); + elm_image_file_set(icon, GE_LOCK_ICON, NULL); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.favoricon", + icon); + } else if (b_favor) { + /* Set favourites icon */ + elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME, + GE_PHOTOFRAME_STYLE_FAVOR); + elm_object_part_content_set(layout, "elm.swallow.icon", bg); + + Evas_Object *icon = elm_icon_add(layout); + elm_image_file_set(icon, GE_THUMB_FAVOR_ICON, NULL); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.favoricon", + icon); + } else { + elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME, + GE_PHOTOFRAME_STYLE_DEFAULT); + elm_object_part_content_set(layout, "elm.swallow.icon", bg); + } + + evas_object_show(layout); + return layout; +} + +Evas_Object *_ge_thumb_show_part_icon_video(Evas_Object *obj, char *path, + unsigned int v_dur, int bk_len, + bool b_favor, bool is_expired_drm, + int item_size) +{ + GE_CHECK_NULL(obj); + + Evas_Object *layout = elm_layout_add(obj); + GE_CHECK_NULL(layout); + +#ifdef _USE_ROTATE_BG_GE + Evas_Object *bg = _ge_rotate_bg_add(layout); +#else + Evas_Object *bg = elm_bg_add(layout); +#endif + if (bg == NULL) { + evas_object_del(layout); + return NULL; + } + +#ifdef _USE_ROTATE_BG_GE + _ge_rotate_bg_set_file(bg, path, item_size, item_size); + _ge_rotate_bg_rotate_image(bg, GE_ORIENTATION_ROT_0); +#else + elm_bg_file_set(bg, path, NULL); + elm_bg_load_size_set(bg, item_size, item_size); + evas_object_size_hint_max_set(bg, item_size, item_size); + evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); +#endif + + if (bk_len && b_favor) + elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME, + GE_PHOTOFRAME_STYLE_VIDEO_FAVOR_BOOKMARK); + else if (bk_len) + elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME, + GE_PHOTOFRAME_STYLE_VIDEO_BOOKMARK); + else if (is_expired_drm || b_favor) + elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME, + GE_PHOTOFRAME_STYLE_VIDEO_FAVOR); + else + elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME, + GE_PHOTOFRAME_STYLE_VIDEO); + elm_object_part_content_set(layout, "elm.swallow.icon", bg); + + // TODO: Need to check the expired drm icon file... + /* Expired drm icon */ + if (is_expired_drm) { + Evas_Object *icon = elm_icon_add(layout); + elm_image_file_set(icon, GE_LOCK_ICON, NULL); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.favoricon", + icon); + /* Set favourites icon */ + } else if (b_favor) { + Evas_Object *icon = elm_icon_add(layout); + elm_image_file_set(icon, GE_THUMB_FAVOR_ICON, NULL); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.favoricon", + icon); + } + + if (bk_len) { + Evas_Object *icon = elm_icon_add(layout); + elm_image_file_set(icon, GE_THUMB_BOOKMARK, NULL); + evas_object_show(icon); + elm_object_part_content_set(layout, "elm.swallow.bookmarkicon", + icon); + } + + char *dur_str = _ge_get_duration_string(v_dur); + GE_CHECK_NULL(dur_str); + elm_object_part_text_set(layout, GE_GRID_TEXT, dur_str); + GE_FREE(dur_str); + + evas_object_show(layout); + return layout; +} + diff --git a/ug/ug-gallery-efl/src/ge-tile.c b/ug/ug-gallery-efl/src/ge-tile.c new file mode 100755 index 0000000..82aa4a0 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-tile.c @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge-debug.h" +#include "ge-tile.h" +#include "ge-button.h" +#include "ge-icon.h" +#ifdef _USE_ROTATE_BG_GE +#include "ge-rotate-bg.h" +#endif + +/* Album color level and alpha value */ +#define GE_TILE_TEXT_COLOR_CNT 6 +#define GE_TILE_TEXT_COLOR_ALPHA 255 + +typedef struct _ge_tile_color { + int r; + int g; + int b; +} ge_tile_color; + +static ge_tile_color bg_color[] = { + {50, 50, 50}, + {78, 74, 64}, + {49, 125, 174}, + {165, 53, 53}, + {71, 128, 11}, + {56, 78, 116}, + {25, 25, 25}, +}; + +Evas_Object *__ge_tile_add_1_icon_bg(Evas_Object *obj, int len, double scale, + bg_file_set_cb func, void **data) +{ + GE_CHECK_NULL(obj); + GE_CHECK_NULL(func); + Evas_Object *bg = NULL; + +#ifdef _USE_ROTATE_BG_GE + bg = _ge_rotate_bg_add(obj); +#else + bg = elm_bg_add(obj); +#endif + GE_CHECK_NULL(bg); + + int wid = 0; + int hei = 0; + + wid = (int)(GE_TILER_ICON_S * scale); + if (len == 1) + hei = wid; + else + hei = (int)(GE_TILE_2X_GRID_S * scale); + +#ifdef _USE_ROTATE_BG_GE + _ge_rotate_bg_add_image(bg, wid, hei); +#else + elm_bg_load_size_set(bg, wid, hei); +#endif + + func(bg, data[0]); + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, 0.5, 0.5); + evas_object_show(bg); + + return bg; +} + +Evas_Object *_ge_tile_show_part_icon(Evas_Object *obj, const char *part, + int length, double scale, + bg_file_set_cb func, void **data) +{ + GE_CHECK_NULL(part); + GE_CHECK_NULL(strlen(part)); + GE_CHECK_NULL(obj); + ge_dbg("part is %s", part); + + if (!g_strcmp0(part, GT_TILE_ONLYICON)) { + Evas_Object *bg = NULL; + bg = __ge_tile_add_1_icon_bg(obj, GE_TILE_THUMB_1, scale, func, + data); + return bg; + } + return NULL; +} + +Evas_Object *_ge_tile_show_part_label(Evas_Object *obj, int index, + bool b_default) +{ + GE_CHECK_NULL(obj); + + Evas *evas = evas_object_evas_get(obj); + GE_CHECK_NULL(evas); + Evas_Object *bg = NULL; + bg = evas_object_rectangle_add(evas); + GE_CHECK_NULL(bg); + + int j = 0; + if (b_default) + j = GE_TILE_TEXT_COLOR_CNT; + else + j = index % GE_TILE_TEXT_COLOR_CNT; + evas_object_color_set(bg, bg_color[j].r, bg_color[j].g, bg_color[j].b, + GE_TILE_TEXT_COLOR_ALPHA); + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(bg); + return bg; +} + diff --git a/ug/ug-gallery-efl/src/ge-ui-util.c b/ug/ug-gallery-efl/src/ge-ui-util.c new file mode 100755 index 0000000..84c2771 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-ui-util.c @@ -0,0 +1,558 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge-ui-util.h" +#include "ge-util.h" +#include "ge-button.h" +#include "ge-gridview.h" +#include "ge-albums.h" +#include "ge-debug.h" +#include "ge-data.h" +#include "ge-strings.h" +#include "ge-icon.h" + +#define GE_FILE_PATH_SEPERATOR ';' + +#define HOME_ALBUM_COVER_NUM 1 +#define VIDEO_SHARE_NUM 1 +#define GE_NOBUT_EXIT_POPUP_HIDE_TIME_DELAY 3.0 +#define GE_SELINFO_HIDE_TIME_DELAY 3.0 +#define GE_CTRLBAR_STYLE_NAVIFRAME "naviframe" +#define GE_BTN_NAVI_PRE "naviframe/back_btn/default" +#define GE_BTN_NAVI_TOOLBAR "naviframe/toolbar/default" +#define GE_NAVIFRAME_BTN1 "toolbar_button1" +#define GE_BTN_POPUP "popup_button/default" +#define GE_NAVIFRAME_PREB_BTN "prev_btn" +#define GE_TRANS_FINISHED "transition,finished" +///This variable is used only for emulator. +static int g_angle = 0; + +static void _ge_ui_response_cb(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg("event_info: %d", (int)event_info); + GE_CHECK(data); + ge_ugdata *ugd = (ge_ugdata *)data; + ge_dbg("popup mode: %d", ugd->popup_mode); + + evas_object_del(obj); + ugd->popup = NULL; +} + +static Eina_Bool __ge_popup_timeout_cb(void *data) +{ + GE_CHECK_FALSE(data); + ge_ugdata *ugd = (ge_ugdata *)data; + if (ugd->del_timer) { + ecore_timer_del(ugd->del_timer); + ugd->del_timer = NULL; + } + + /* Used for adding shortcut failed */ + if (ugd->popup_mode == GE_POPUP_EXIT) { + ge_dbgW("Terminate me!"); + ug_destroy_me(ugd->ug); + ugd->ug = NULL; + } + + GE_IF_DEL_OBJ(ugd->popup); + return ECORE_CALLBACK_CANCEL; +} + +static int __ge_popup_add_timer(void *data, double to_inc) +{ + GE_CHECK_VAL(data, -1); + ge_ugdata *ugd = (ge_ugdata *)data; + if (ugd->del_timer) { + ecore_timer_del(ugd->del_timer); + ugd->del_timer = NULL; + } + + ugd->del_timer = ecore_timer_add(to_inc, __ge_popup_timeout_cb, data); + return 0; +} + +static void __ge_ui_done_cb(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); + GE_CHECK(data); + ge_ugdata *ugd = (ge_ugdata *)data; + int i = 0; + + elm_object_item_disabled_set((Elm_Object_Item *)event_info, EINA_TRUE); + + if(ugd->file_select_mode) //file selection mode + { + ge_item* sel_item = NULL; + char* filepath_arg = NULL; + int sel_cnt = _ge_data_selected_list_count(); + + if(sel_cnt == 0) + { + ge_dbg("No thumbs selected, return!"); + ge_ui_create_popup(ugd, GE_POPUP_NOBUT, + GE_POPUP_NO_FILES_SELECTED); + return; + } + + if(ugd->file_select_mode == GE_FILE_SELECT_T_MULTIPLE) { + GString* selected_path = g_string_new(NULL); + + for(i = 1; i <= sel_cnt; i++ ) { + _ge_data_get_selected_item_by_index(&sel_item, i); + if(sel_item && sel_item->item) { + ge_dbg("Selected [%s]", sel_item->item->file_url); + g_string_append(selected_path, sel_item->item->file_url); + g_string_append_c(selected_path, + GE_FILE_PATH_SEPERATOR); + } + } + int str_len = strlen(selected_path->str); + ge_dbg("path string length = %d", str_len); + g_string_truncate(selected_path, str_len - 1); + + filepath_arg = g_string_free(selected_path, false); + + char t_str[32] = { 0, }; + eina_convert_itoa(sel_cnt, t_str); + + service_add_extra_data(ugd->service, + GE_FILE_SELECT_RETURN_COUNT, + t_str); + service_add_extra_data(ugd->service, + GE_FILE_SELECT_RETURN_PATH, + filepath_arg); + ug_send_result(ugd->ug, ugd->service); + + if(filepath_arg) { + g_free(filepath_arg); + filepath_arg = NULL; + } + } + + _ge_data_selected_list_finalize(); + + ug_destroy_me(ugd->ug); + } +} + +static int __ge_ui_disable_done(ge_ugdata *ugd, bool disabled) +{ + ge_dbg("Disable Done(%d)?", disabled); + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(ugd->thumbs_nf_it, -1); + + Evas_Object *btn = NULL; + btn = elm_object_item_part_content_get(ugd->thumbs_nf_it, + GE_NAVIFRAME_BTN1); + elm_object_disabled_set(btn, disabled); + return 0; +} + +static void __ge_ui_trans_finished_cb(void *data, Evas_Object *obj, void *event_info) +{ + GE_CHECK(data); + ge_ugdata *ugd = (ge_ugdata *)data; + ge_dbgW(""); + evas_object_smart_callback_del(obj, GE_TRANS_FINISHED, + __ge_ui_trans_finished_cb); + + /* Clear previous view after animation finished */ + elm_gengrid_clear(ugd->albums_view); +} + +static void _ge_ui_destroy_me_cb(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); + GE_CHECK(data); + ge_ugdata *ugd = (ge_ugdata *)data; + /* Delete callback when it is clicked to prevent it is called for many times */ + evas_object_smart_callback_del(obj, "clicked", _ge_ui_destroy_me_cb); + + if (_ge_get_view_mode() != GE_VIEW_ALBUMS) { + if(ugd->file_select_mode == GE_FILE_SELECT_T_MULTIPLE) { + ge_ui_destroy_selinfo(ugd); + _ge_data_selected_list_finalize(); + } + ge_grid_clear_view(ugd); + } + + service_add_extra_data(ugd->service, GE_FILE_SELECT_RETURN_QUIT, + GE_FILE_SELECT_QUIT_STATE); + ug_send_result(ugd->ug, ugd->service); + + ug_destroy_me(ugd->ug); + ge_dbg("ug_destroy_me"); +} + +static void _ge_ui_back_to_albums_cb(void *data, Evas_Object *obj, void *event_info) +{ + ge_dbg(""); + GE_CHECK(data); + ge_ugdata *ugd = (ge_ugdata *)data; + /* Delete callback when it is clicked to prevent it is called for many times */ + evas_object_smart_callback_del(obj, "clicked", + _ge_ui_back_to_albums_cb); + + ge_albums_back_to_view(ugd); +} + +int _ge_ui_get_rotate_angle(void) +{ + return g_angle; +} + +int ge_ui_create_title_and_push(ge_ugdata *ugd, Evas_Object *parent, + Evas_Object *obj, ge_navi_mode_e mode, + char* title) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(parent, -1); + GE_CHECK_VAL(obj, -1); + GE_CHECK_VAL(title, -1); + Elm_Object_Item *nf_it = NULL; + + if (mode == GE_NAVI_ALBUMS) { + ge_dbg("GE_NAVI_ALBUMS"); + /* Add cancel button */ + Evas_Object *cancel_btn = NULL; + cancel_btn = _ge_but_create_but(obj, ugd->th, NULL, GE_STR_OK, + GE_BTN_NAVI_PRE, + _ge_ui_destroy_me_cb, ugd); + GE_CHECK_VAL(cancel_btn, -1); + nf_it = elm_naviframe_item_push(parent, title, cancel_btn, NULL, + obj, NULL); + ugd->albums_nf_it = nf_it; + } else if (mode == GE_NAVI_THUMBS) { + if(ugd->file_select_mode == GE_FILE_SELECT_T_NONE) { + ge_dbgE("file_select_mode == GE_FILE_SELECT_T_NONE!"); + return -1; + } + + ge_dbg("GE_NAVI_THUMBS"); + /* Add transition finished callback */ + evas_object_smart_callback_add(parent, GE_TRANS_FINISHED, + __ge_ui_trans_finished_cb, ugd); + nf_it = elm_naviframe_item_push(parent, title, NULL, NULL, obj, + NULL); + /* Set pre_btn style to back button */ + Evas_Object *back_btn = NULL; + back_btn = elm_object_item_part_content_get(nf_it, + GE_NAVIFRAME_PREB_BTN); + if(ugd->th) + elm_object_theme_set(back_btn, ugd->th); + elm_object_style_set(back_btn, GE_BTN_NAVI_PRE); + evas_object_smart_callback_add(back_btn, "clicked", + _ge_ui_back_to_albums_cb, ugd); + + /** + * Add 'Done' item. + */ + if (ugd->file_select_mode != GE_FILE_SELECT_T_ONE && + (_ge_get_view_mode() == GE_VIEW_THUMBS_EDIT)) { + ge_dbg("Multiple selection, show Done"); + /* Done */ + Evas_Object *btn = NULL; + btn = _ge_but_create_but(parent, ugd->th, NULL, + GE_STR_DONE, + GE_BTN_NAVI_TOOLBAR, + __ge_ui_done_cb, ugd); + GE_CHECK_VAL(btn, -1); + elm_object_disabled_set(btn, true); + elm_object_item_part_content_set(nf_it, + GE_NAVIFRAME_BTN1, + btn); + } + ugd->thumbs_nf_it = nf_it; + } + + return 0; +} + +Evas_Object* ge_ui_load_edj(Evas_Object *parent, const char *file, const char *group) +{ + GE_CHECK_NULL(parent); + GE_CHECK_NULL(file); + GE_CHECK_NULL(group); + Evas_Object *eo; + int r; + + eo = elm_layout_add(parent); + if (eo) + { + r = elm_layout_file_set(eo, file, group); + if (!r) + { + evas_object_del(eo); + return NULL; + } + + evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL); + } + + return eo; +} + +void ge_ui_set_rotate_angle(int rotate_mode) +{ + g_angle = rotate_mode; +} + +Evas_Object* ge_ui_create_nocontents(ge_ugdata* ugd) +{ + GE_CHECK_NULL(ugd); + Evas_Object *layout = NULL; + char label_str[GE_NOCONTENTS_LABEL_LEN_MAX] ={0,}; + + if(_ge_get_view_mode() == GE_VIEW_THUMBS || + _ge_get_view_mode() == GE_VIEW_THUMBS_EDIT) { + if(ugd->file_type_mode) { + if (ugd->file_type_mode == GE_FILE_T_IMAGE) + snprintf(label_str, sizeof(label_str), + "%s", + (char*)(_GE_GETSYSTEMSTR("IDS_COM_BODY_NO_IMAGES"))); + else if (ugd->file_type_mode == GE_FILE_T_VIDEO) + snprintf(label_str, sizeof(label_str), + "%s", + (char*)GE_LABEL_NO_VIDEOS); + else + snprintf(label_str, sizeof(label_str), + "%s", + (char*)(_GE_GETSYSTEMSTR("IDS_COM_BODY_NO_ITEMS"))); + } else { + snprintf(label_str, sizeof(label_str), "%s", + (char*)(_GE_GETSYSTEMSTR("IDS_COM_BODY_NO_ITEMS"))); + } + } else if(_ge_get_view_mode() == GE_VIEW_ALBUMS) { + snprintf(label_str, sizeof(label_str), "%s", + (char*)GE_LABEL_NO_ALBUMS); + } else { + ge_dbgE("view mode is error."); + } + + ge_dbg("\nNocontents label: %s", label_str); + /* Full nocontents view layout */ + layout = elm_layout_add(ugd->navi_bar); + GE_CHECK_NULL(layout); + elm_layout_theme_set(layout, "layout", "nocontents", "gallery_efl"); + elm_object_part_text_set(layout, "elm.text", label_str); + + return layout; +} + +Evas_Object* ge_ui_create_main_ly(ge_ugdata* ugd, Evas_Object* parent) +{ + GE_CHECK_NULL(ugd); + GE_CHECK_NULL(parent); + Evas_Object *layout = NULL; + + layout = elm_layout_add(parent); + GE_CHECK_NULL(layout); + + /* Apply the layout style */ + const char *profile = elm_config_profile_get(); + if (!g_strcmp0(profile, "mobile")) { + elm_layout_theme_set(layout, "layout", "application", "default"); + } else if (!g_strcmp0(profile,"extension")) { + elm_layout_theme_set(layout, "layout", "application", "noindicator"); + } + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_show(layout); + + return layout; +} + +Evas_Object* ge_ui_create_navibar(ge_ugdata* ugd, Evas_Object* parent) +{ + GE_CHECK_NULL(ugd); + GE_CHECK_NULL(parent); + Evas_Object *navi_bar = NULL; + + navi_bar = elm_naviframe_add(parent); + GE_CHECK_NULL(navi_bar); + + if(ugd->th) + { + elm_object_theme_set(navi_bar, ugd->th); + } + elm_object_part_content_set(parent, "elm.swallow.content", navi_bar); + + evas_object_show(navi_bar); + + return navi_bar; +} + +Evas_Object* ge_ui_create_popup(ge_ugdata* ugd, ge_popup_mode_e mode, + char* desc) +{ + ge_dbg(""); + GE_CHECK_NULL(ugd); + GE_CHECK_NULL(desc); + + if(ugd->popup) + { + ge_dbg("The existed popup is deleted"); + evas_object_del(ugd->popup); + ugd->popup = NULL; + } + + Evas_Object *popup = NULL; + + popup = elm_popup_add(ugd->ly_main); + GE_CHECK_NULL(popup); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_object_text_set(popup, desc); + + switch (mode) { + case GE_POPUP_NOBUT: + case GE_POPUP_EXIT: + __ge_popup_add_timer(ugd, GE_NOBUT_EXIT_POPUP_HIDE_TIME_DELAY); + break; + case GE_POPUP_ONEBUT: + { + Evas_Object *btn = NULL; + btn = _ge_but_create_but(popup, ugd->th, NULL, GE_STR_OK, + GE_BTN_POPUP, _ge_ui_response_cb, ugd); + elm_object_part_content_set(popup, "button1", btn); + break; + } + case GE_POPUP_TWOBUT: + { + Evas_Object *btn1 = NULL; + btn1 = _ge_but_create_but(popup, ugd->th, NULL, GE_STR_OK, + GE_BTN_POPUP, _ge_ui_response_cb, + ugd); + elm_object_part_content_set(popup, "button1", btn1); + Evas_Object *btn2 = NULL; + btn2 = _ge_but_create_but(popup, ugd->th, NULL, GE_STR_CANCEL, + GE_BTN_POPUP, _ge_ui_response_cb, + ugd); + elm_object_part_content_set(popup, "button2", btn2); + break; + } + default: + ge_dbgE("mode is not supported..."); + break; + } + + evas_object_show(popup); + + ugd->popup = popup; + ugd->popup_mode = mode; + + return popup; +} + +int _ge_ui_create_selinfo(ge_ugdata *ugd, Evas_Object *parent) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(parent, -1); + int count = 1; + int all_count = 0; + char text[GE_SELINFO_TEXT_LEN_MAX] = {0,}; + + count = _ge_data_selected_list_count(); + if(count <= 0) { + __ge_ui_disable_done(ugd, true); + if(ugd->file_select_mode == GE_FILE_SELECT_T_MULTIPLE) + ge_ui_destroy_selinfo(ugd); + ge_dbg("@@@[Warning] no item selected@@@"); + return -1; + } + + __ge_ui_disable_done(ugd, false); + + if(ugd->file_select_mode == GE_FILE_SELECT_T_ONE) { + ge_dbgW("In select one mode!"); + return -1; + } + + all_count = _ge_data_get_count_all(); + ge_dbg("New count , all count : %d,%d", count, all_count); + + ge_ui_destroy_selinfo(ugd); + + ugd->selinfo_ly = elm_layout_add(parent); + GE_CHECK_VAL(ugd->selinfo_ly, -1); + evas_object_size_hint_weight_set(ugd->selinfo_ly, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(ugd->selinfo_ly, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_layout_theme_set(ugd->selinfo_ly, "standard", "selectioninfo", + "center_text"); + + /* Set the content of the notify widget */ + elm_object_part_content_set(parent, "elm.swallow.selinfo", + ugd->selinfo_ly); + /* Add Space */ + snprintf(text, sizeof(text), "%s (%d)", GE_SELINFO_SELECTED, count); + text[strlen(text)] = '\0'; + + /* move view up while selection view shown.*/ + edje_object_signal_emit(_EDJ(parent), + "elm,thumb_view,state,moveup", "elm"); + edje_object_part_text_set(_EDJ(ugd->selinfo_ly), "elm.text", text); + return 0; +} + +int ge_ui_destroy_selinfo(ge_ugdata* ugd) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + GE_CHECK_VAL(ugd->thumbs_view_ly, -1); + + /* reset view to default status.*/ + edje_object_signal_emit(_EDJ(ugd->thumbs_view_ly), + "elm,thumb_view,state,default", "elm"); + + if(ugd->selinfo_ly) { + evas_object_del(ugd->selinfo_ly); + ugd->selinfo_ly = NULL; + } + return 0; +} + +/* * +* In case of system folder, the displayed name should be translated into system language +* +* @param name +* check album display name for getting proper translation +* +* @return +* the translated album display name +*/ +char *_ge_ui_get_translated_album_name(ge_cluster *album) +{ + GE_CHECK_NULL(album); + GE_CHECK_NULL(album->cluster); + + if(_ge_data_is_default_album(GE_ALBUM_CAMERA_NAME, album->cluster)) { + /* system folder name: Camera */ + return GE_STR_CAMERA; + } else if(_ge_data_is_default_album(GE_ALBUM_DOWNLOAD_NAME, album->cluster)) { + /* system folder name: Downloads */ + return GE_STR_DOWNLOADS; + } else { + /* if the folder is not a system folder, return itself */ + return album->cluster->display_name; + } +} + diff --git a/ug/ug-gallery-efl/src/ge-util.c b/ug/ug-gallery-efl/src/ge-util.c new file mode 100755 index 0000000..e5c9e65 --- /dev/null +++ b/ug/ug-gallery-efl/src/ge-util.c @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "ge-debug.h" +#include "ge-albums.h" +#include "ge-gridview.h" +#include "ge-data.h" +#include "ge-util.h" +#include "ge-ui-util.h" +#include "ge-strings.h" +#include "ge-icon.h" +#include "ge-drm.h" + +#define GE_TIME_MSEC_PER_SEC 1000 +#define GE_TIME_SEC_PER_MIN 60 +#define GE_TIME_MIN_PER_HOUR 60 +#define GE_TIME_SEC_PER_HOUR (GE_TIME_MIN_PER_HOUR * GE_TIME_SEC_PER_MIN) + +/* Global evas objects, which is used in the entire application */ +static ge_item* ge_current_mb_item; +static ge_cluster* ge_current_album_item; +static int ge_ug_iv_enter = 0; + +ge_item* _ge_get_current_item(void) +{ + return ge_current_mb_item; +} + +void _ge_set_current_item(ge_item* gitem) +{ + ge_current_mb_item = gitem; +} + +ge_cluster* _ge_get_current_album(void) +{ + return ge_current_album_item; +} + +void _ge_set_current_album(ge_cluster* album_item) +{ + ge_current_album_item = album_item; +} + +int _ge_ug_iv_get(void) +{ + return ge_ug_iv_enter; +} + +void _ge_ug_iv_set(int ug_iv_state) +{ + ge_ug_iv_enter = ug_iv_state; +} + +static int _ge_refresh_albums_list(ge_ugdata *ugd) +{ + GE_CHECK_VAL(ugd, -1); + ge_cluster* old_cur_cluster = _ge_get_current_album(); + char cluster_id[GE_MTYPE_ITEN_ID_LEN_MAX] = { 0, }; + int i = 0; + ge_cluster *current = NULL; + bool b_get_cur_album = false; + + if(old_cur_cluster && old_cur_cluster->cluster && + old_cur_cluster->cluster->uuid) + { + g_strlcpy(cluster_id, old_cur_cluster->cluster->uuid, + GE_MTYPE_ITEN_ID_LEN_MAX); + b_get_cur_album = true; + } + else + { + ge_dbg("None album selected, current album is unavailable\n"); + } + _ge_data_get_clusters_list(ugd); + + GE_CHECK_VAL(ugd->cluster_list, -1); + int length = eina_list_count(ugd->cluster_list->clist); + ge_dbg("album length: %d, current album id: %s", length, cluster_id); + + //need to reset current cluster + _ge_set_current_album(NULL); + if(b_get_cur_album) + { + for (i = 0; i < length; i++) + { + current = eina_list_nth(ugd->cluster_list->clist, i); + if(current && current->cluster && + current->cluster->uuid) { + ge_dbg("current album : %s", current->cluster->display_name); + } else { + ge_dbgE("Current is NULL"); + break; + } + if(!g_strcmp0(current->cluster->uuid, cluster_id)) + { + _ge_data_update_items_list(ugd, current); + _ge_set_current_album(current); + return 0; + } + } + /* Current album was removed, clear items list */ + if (_ge_data_get_selected_list()) + _ge_data_selected_list_finalize(); + _ge_data_free_items_list(); + } + + return -1; +} + +static void _ge_db_update_noti_cb(keynode_t *key, void* data) +{ + ge_dbgW("VCONFKEY_FILEMANAGER_DB_STATUS changed!"); + GE_CHECK(data); + ge_ugdata* ugd = (ge_ugdata*)data; + int mmc_state = -1; + int mode = GE_UPDATE_NONE; + + vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_state); + if(mmc_state == -1) { + ge_dbgE("vconf_get_int failed!"); + return; + } + + if (mmc_state == VCONFKEY_SYSMAN_MMC_MOUNTED) { + ge_dbg("mmc_state[%d]: VCONFKEY_SYSMAN_MMC_MOUNTED", mmc_state); + mode = GE_UPDATE_MMC_ADDED; + } else if (mmc_state == VCONFKEY_SYSMAN_MMC_REMOVED || + mmc_state == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) { + ge_dbg("mmc_state[%d]: VCONFKEY_SYSMAN_MMC_REMOVED", mmc_state); + mode = GE_UPDATE_MMC_REMOVED; + } + + /* Update view */ + ge_update_view(ugd, mode); +} + +Eina_Bool ge_update_view(ge_ugdata* ugd, int mode) +{ + ge_dbg("mode: %d", mode); + GE_CHECK_FALSE(ugd); + int view_mode = _ge_get_view_mode(); + ge_dbg("view_mode: %d", view_mode); + + if (view_mode == GE_VIEW_ALBUMS) { + _ge_refresh_albums_list(ugd); + ge_albums_update_view(ugd); + } else if (view_mode == GE_VIEW_THUMBS) { + _ge_refresh_albums_list(ugd); + if(_ge_get_current_album() == NULL) + { + ge_dbg("current album is empty, back to albums view!"); + ge_albums_back_to_view(ugd); + elm_naviframe_item_pop(ugd->navi_bar); + + return EINA_FALSE; + } + + ge_grid_update_view(ugd); + } else if (view_mode == GE_VIEW_THUMBS_EDIT) { + ge_cluster* cur_album = _ge_get_current_album(); + + /* MMC removed */ + if(mode == GE_UPDATE_MMC_REMOVED && cur_album && + cur_album->cluster && + cur_album->cluster->type == GE_MMC) { + ge_dbgW("MMC album, change to albums view!"); + _ge_refresh_albums_list(ugd); + ge_albums_back_to_view(ugd); + elm_naviframe_item_pop(ugd->navi_bar); + return EINA_FALSE; + } + + /* Update albums list and items list */ + _ge_refresh_albums_list(ugd); + if(_ge_data_get_count_all() <= 0) { + ge_dbgW("current album is empty, back to albums view!"); + ge_albums_back_to_view(ugd); + elm_naviframe_item_pop(ugd->navi_bar); + return EINA_FALSE; + } + + ge_grid_update_view(ugd); + + if(_ge_data_get_count_all() <= 0) { + ge_dbgW("current album is empty, back to albums view!"); + ge_albums_back_to_view(ugd); + elm_naviframe_item_pop(ugd->navi_bar); + return EINA_FALSE; + } + } + + return EINA_TRUE; +} + +int ge_reg_db_update_noti(ge_ugdata* ugd) +{ + ge_dbg(""); + GE_CHECK_VAL(ugd, -1); + int error_code = 0; + + error_code = vconf_notify_key_changed(VCONFKEY_FILEMANAGER_DB_STATUS, + _ge_db_update_noti_cb, ugd); + if(error_code == -1) + ge_dbgE("vconf_notify_key_changed FAIL!"); + + return 0; +} + +int ge_dereg_db_update_noti(void) +{ + ge_dbg(""); + int error_code = -1; + + error_code = vconf_ignore_key_changed(VCONFKEY_FILEMANAGER_DB_STATUS, + _ge_db_update_noti_cb); + if(error_code == -1) + ge_dbgE("vconf_ignore_key_changed FAIL!"); + + return 0; +} + +bool _ge_is_image_valid(void *data, char *filepath) +{ + GE_CHECK_FALSE(data); + ge_ugdata *ugd = (ge_ugdata *)data; + GE_CHECK_FALSE(filepath); + + Evas_Object *image = NULL; + int width = 0; + int height = 0; + Evas *evas = NULL; + + evas = evas_object_evas_get(ugd->win); + GE_CHECK_FALSE(evas); + + image = evas_object_image_add(evas); + GE_CHECK_FALSE(image); + + evas_object_image_filled_set(image, 0); + evas_object_image_load_scale_down_set(image, 0); + evas_object_image_file_set(image, filepath, NULL); + evas_object_image_size_get(image, &width, &height); + if(image) { + evas_object_del(image); + image = NULL; + } + + if (width <= 0 || height <= 0) { + ge_dbg("Cannot load file : %s", filepath); + return false; + } + + return true; +} + +/* Change int to char * of video duration, caller need to free the allocated memory */ +char *_ge_get_duration_string(unsigned int v_dur) +{ + char *dur_str = calloc(1, GE_FILE_PATH_LEN_MAX); + GE_CHECK_NULL(dur_str); + if (v_dur > 0) { + int duration = floor(v_dur / GE_TIME_MSEC_PER_SEC); + int dur_hr = 0; + int dur_min = 0; + int dur_sec = 0; + int tmp = 0; + + if (duration >= GE_TIME_SEC_PER_HOUR) { + dur_sec = duration % GE_TIME_SEC_PER_MIN; + tmp = floor(duration / GE_TIME_SEC_PER_MIN); + dur_min = tmp % GE_TIME_MIN_PER_HOUR; + dur_hr = floor(tmp / GE_TIME_MIN_PER_HOUR); + } else if (duration >= GE_TIME_SEC_PER_MIN) { + dur_hr = 0; + dur_min = floor(duration / GE_TIME_SEC_PER_MIN); + dur_sec = duration % GE_TIME_SEC_PER_MIN; + } else { + dur_hr = 0; + dur_min = 0; + dur_sec = duration % GE_TIME_SEC_PER_MIN; + } + + snprintf(dur_str, GE_FILE_PATH_LEN_MAX, "%02d:%02d:%02d", + dur_hr, dur_min, dur_sec); + } else { + snprintf(dur_str, GE_FILE_PATH_LEN_MAX, "00:00:00"); + } + dur_str[strlen(dur_str)] = '\0'; + return dur_str; +} + diff --git a/ug/ug-gallery-efl/ug-gallery-efl.xml b/ug/ug-gallery-efl/ug-gallery-efl.xml new file mode 100755 index 0000000..f12a725 --- /dev/null +++ b/ug/ug-gallery-efl/ug-gallery-efl.xml @@ -0,0 +1,60 @@ + + + + Jiansong Jin + Gallery application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +