summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rwxr-xr-xmain/src/common/ivug-common.h42
-rwxr-xr-xmain/src/common/ivug-config.c200
-rwxr-xr-xmain/src/common/ivug-config.h50
-rwxr-xr-xmain/src/common/ivug-datatypes.h32
-rwxr-xr-xmain/src/common/ivug-define.h60
-rwxr-xr-xmain/src/common/ivug-string.h112
-rwxr-xr-xmain/src/control/ivug-ext-ug.c75
-rwxr-xr-xmain/src/control/ivug-ext-ug.h34
-rwxr-xr-xmain/src/control/ivug-main.c258
-rwxr-xr-xmain/src/control/ivug-main.h44
-rwxr-xr-xmain/src/control/ivug-parameter.c397
-rwxr-xr-xmain/src/control/ivug-parameter.h104
-rwxr-xr-xmain/src/control/ivug-uuid.c94
-rwxr-xr-xmain/src/control/ivug-uuid.h52
-rwxr-xr-xmain/src/data/ivug-data-filter.c101
-rwxr-xr-xmain/src/data/ivug-data-filter.h56
-rwxr-xr-xmain/src/data/ivug-data-list.c282
-rwxr-xr-xmain/src/data/ivug-data-list.h40
-rwxr-xr-xmain/src/data/ivug-data-priv.h61
-rwxr-xr-xmain/src/data/ivug-data-shuffle.c238
-rwxr-xr-xmain/src/data/ivug-data-shuffle.h54
-rwxr-xr-xmain/src/data/ivug-data.c683
-rwxr-xr-xmain/src/data/ivug-data.h85
-rwxr-xr-xmain/src/data/ivug-mediadata.c301
-rwxr-xr-xmain/src/data/ivug-mediadata.h87
-rwxr-xr-xmain/src/effect/include/ivug-anim.h56
-rwxr-xr-xmain/src/effect/include/ivug-effect.h90
-rwxr-xr-xmain/src/effect/ivug-anim.c178
-rwxr-xr-xmain/src/effect/ivug-effect.c201
-rwxr-xr-xmain/src/effect/ivug-slide.c107
-rwxr-xr-xmain/src/effect/template.c83
-rwxr-xr-xmain/src/ug-image-viewer.c430
-rwxr-xr-xmain/src/ug-image-viewer.h50
-rwxr-xr-xmain/src/util/ivug-file-info.c403
-rwxr-xr-xmain/src/util/ivug-file-info.h57
-rwxr-xr-xmain/src/util/ivug-listpopup.c274
-rwxr-xr-xmain/src/util/ivug-listpopup.h81
-rwxr-xr-xmain/src/util/ivug-util.c286
-rwxr-xr-xmain/src/util/ivug-util.h78
-rwxr-xr-xmain/src/util/ivug-widget.c209
-rwxr-xr-xmain/src/util/ivug-widget.h68
-rwxr-xr-xmain/src/view/ivug-detail-info.c437
-rwxr-xr-xmain/src/view/ivug-detail-info.h80
-rwxr-xr-xmain/src/view/ivug-details-view.c437
-rwxr-xr-xmain/src/view/ivug-details-view.h64
-rwxr-xr-xmain/src/view/ivug-main-view.c1837
-rwxr-xr-xmain/src/view/ivug-main-view.h133
-rwxr-xr-xmain/src/view/ivug-popup.c262
-rwxr-xr-xmain/src/view/ivug-popup.h60
-rwxr-xr-xmain/src/view/ivug-setas-view.c895
-rwxr-xr-xmain/src/view/ivug-setas-view.h97
-rwxr-xr-xmain/src/view/ivug-slider-item.c703
-rwxr-xr-xmain/src/view/ivug-slider-item.h137
-rwxr-xr-xmain/src/view/ivug-slider-mouse.c439
-rwxr-xr-xmain/src/view/ivug-slider-priv.h164
-rwxr-xr-xmain/src/view/ivug-slider-slideshow.c334
-rwxr-xr-xmain/src/view/ivug-slider.c1245
-rwxr-xr-xmain/src/view/ivug-slider.h95
58 files changed, 13612 insertions, 0 deletions
diff --git a/main/src/common/ivug-common.h b/main/src/common/ivug-common.h
new file mode 100755
index 0000000..ba817eb
--- /dev/null
+++ b/main/src/common/ivug-common.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_COMMON_H__
+#define __IVUG_COMMON_H__
+
+#include "ivug-define.h"
+#include "ivug-datatypes.h"
+#include "ivug-uuid.h"
+
+#include <Elementary.h>
+#include <assert.h>
+
+#include "statistics.h"
+#include "ivug-debug.h"
+#include "ivug-string.h"
+#include "ivug-util.h"
+#include "ivug-define.h"
+#include "ivug-config.h"
+#include "ivug-widget.h"
+
+
+#define _EDJ(o) elm_layout_edje_get(o)
+
+#define IMAGE_BETWEEN_MARGIN (30) // The value is width between photocam(unit is pixel).
+
+#endif /* __IVUG_COMMON_H__ */
+
diff --git a/main/src/common/ivug-config.c b/main/src/common/ivug-config.c
new file mode 100755
index 0000000..06efce5
--- /dev/null
+++ b/main/src/common/ivug-config.c
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-define.h"
+#include "ivug-effect.h"
+#include "ivug-config.h"
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+// TODO: Request vconf key to setting part, Slide show setting vconf key
+#define VCONFKEY_GALLERY_INTERVAL_TIME "db/setting/gallery/interval_time" //double
+#define VCONFKEY_GALLERY_REPEAT_STATE "db/setting/gallery/repeat_state" //boolean
+#define VCONFKEY_GALLERY_SHUFFLE_STATE "db/setting/gallery/shuffle_state" //boolean
+#define VCONFKEY_GALLERY_TRANSITION_EFFECT "db/setting/gallery/ss_effect" //char
+
+enum { STATE_FALSE = 0, STATE_TRUE = 1, };
+
+/*
+ Set lock screen with given image.
+
+ CAUTION : does not check filepath integrity
+*/
+bool ivug_config_set_lockscreen_image(const char* filepath)
+{
+ if(filepath == NULL)
+ {
+ MSG_IMAGEVIEW_ERROR("Lock screen path is NULL");
+ return FALSE;
+ }
+
+ if(vconf_set_str( VCONFKEY_IDLE_LOCK_BGSET, filepath ) < 0)
+ {
+ MSG_IMAGEVIEW_ERROR("Lockscreen set Error : %s", filepath);
+ return FALSE;
+ }
+
+ MSG_IMAGEVIEW_HIGH("Set Lockscreen filepath = %s", filepath);
+
+ return TRUE;
+}
+
+/*
+ Set home screen with given image
+
+ CAUTION : does not check filepath integrity
+*/
+bool ivug_config_set_homescreen_image( const char* filepath )
+{
+ if(filepath == NULL)
+ {
+ MSG_IMAGEVIEW_ERROR("Home screen path is NULL");
+ return FALSE;
+ }
+// TODO : Need to check file existence?????
+ if(vconf_set_str(VCONFKEY_BGSET, filepath) < 0)
+ {
+ MSG_IMAGEVIEW_ERROR("Homescreen set Error");
+ return FALSE;
+ }
+
+ MSG_IMAGEVIEW_HIGH("Set Homescreen filepath = %s", filepath);
+ return TRUE;
+}
+
+
+static bool
+_ivug_config_get_slideshow_repeat_state(void)
+{
+ int repeat_state = STATE_FALSE;
+
+ if(vconf_get_bool(VCONFKEY_GALLERY_REPEAT_STATE, &repeat_state) < 0)
+ {
+ MSG_IMAGEVIEW_ERROR("vconf_get_bool failed, set as repeat state as default: false");
+ return false;
+ }
+
+ MSG_IMAGEVIEW_HIGH("repeat state is: %d", repeat_state);
+
+ return (repeat_state == STATE_TRUE ? true : false);
+}
+
+static bool
+_ivug_config_get_slideshow_shuffle_state(void)
+{
+ int shuffle_state = STATE_FALSE;
+
+ if(vconf_get_bool(VCONFKEY_GALLERY_SHUFFLE_STATE, &shuffle_state) < 0)
+ {
+ MSG_IMAGEVIEW_ERROR("vconf_get_bool failed, set as shuffle state as default: false");
+ return false;
+ }
+
+ MSG_IMAGEVIEW_HIGH("shuffle state is: %d", shuffle_state);
+
+ return (shuffle_state == STATE_TRUE ? true : false);
+}
+
+static double
+_ivug_config_get_slideshow_interval_time(void)
+{
+ double interval_time = 0.0;
+
+ if(vconf_get_dbl(VCONFKEY_GALLERY_INTERVAL_TIME, &interval_time) < 0)
+ {
+ MSG_IMAGEVIEW_ERROR("vconf_get_dbl failed, set as interval time as -1");
+
+ interval_time = -1.0;
+ }
+
+ MSG_IMAGEVIEW_HIGH("interval time is: %f", interval_time);
+ return interval_time;
+}
+
+static char *
+_ivug_config_get_slideshow_effect_type(void)
+{
+// TODO : Free returned string??
+ char *effect_str = NULL;
+ effect_str = vconf_get_str(VCONFKEY_GALLERY_TRANSITION_EFFECT);
+
+ if(!effect_str)
+ {
+ MSG_IMAGEVIEW_ERROR("vconf_get_str failed, set as effect type as default");
+
+ effect_str = NULL;
+ }
+
+ MSG_IMAGEVIEW_HIGH("effect is: %s", effect_str);
+
+ return effect_str;
+}
+
+static ivug_effect_type
+_ivug_config_get_effect_type_by_string(char *effect_str)
+{
+ ivug_retv_if(!effect_str, EFFECT_NONE);
+
+ ivug_effect_type type = IVUG_EFFECT_TYPE_SLIDE;
+
+ if(!strncmp(effect_str, "Slide", strlen(effect_str)))
+ {
+ type = IVUG_EFFECT_TYPE_SLIDE;
+ }
+ else //Set all other cases as default NONE
+ {
+ MSG_SLIDER_WARN("Invalid type : %s", effect_str);
+ type = EFFECT_NONE;
+ }
+
+ MSG_IMAGEVIEW_HIGH("effect_str = %s, type = %d", effect_str, type);
+
+ return type;
+}
+
+void
+ivug_config_get_slideshow_setting(slide_show_mode *mode,
+ double *interval_time,
+ ivug_effect_type *effect_type)
+{
+ *mode = SLIDE_SHOW_MODE_NORMAL;
+
+ bool state;
+
+ state = _ivug_config_get_slideshow_repeat_state();
+ if(state == true)
+ {
+ *mode |= SLIDE_SHOW_MODE_REPEAT;
+ }
+
+ state = _ivug_config_get_slideshow_shuffle_state();
+ if(state == true)
+ {
+ *mode |= SLIDE_SHOW_MODE_SHUFFLE;
+ }
+
+ *interval_time = _ivug_config_get_slideshow_interval_time();
+
+ /* EFFECT_NONE, EFFECT_FADE, EFFECT_BLIND, EFFECT_IRIS */
+ char *effect = _ivug_config_get_slideshow_effect_type();
+
+ *effect_type = _ivug_config_get_effect_type_by_string(effect);
+}
+
+
diff --git a/main/src/common/ivug-config.h b/main/src/common/ivug-config.h
new file mode 100755
index 0000000..31d9533
--- /dev/null
+++ b/main/src/common/ivug-config.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_CONFIG_H__
+#define __IVUG_CONFIG_H__
+
+typedef enum {
+ SLIDE_SHOW_MODE_NORMAL = 0x00,
+ SLIDE_SHOW_MODE_REPEAT = 0x01,
+ SLIDE_SHOW_MODE_SHUFFLE = 0x02,
+ SLIDE_SHOW_MODE_SHUFFLE_REPEAT = 0x03,
+} slide_show_mode;
+
+typedef enum {
+ IVUG_EFFECT_TYPE_SLIDE = 0x00,
+ IVUG_EFFECT_TYPE_MAX,
+} ivug_effect_type;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool ivug_config_set_lockscreen_image(const char* filepath);
+
+bool ivug_config_set_homescreen_image(const char* filepath);
+
+void ivug_config_get_slideshow_setting(slide_show_mode * /* OUT */ mode,
+ double * /* OUT */ interval_time,
+ ivug_effect_type * /* OUT */ effect_type);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __IVUG_CONFIG_H__
diff --git a/main/src/common/ivug-datatypes.h b/main/src/common/ivug-datatypes.h
new file mode 100755
index 0000000..dc616e3
--- /dev/null
+++ b/main/src/common/ivug-datatypes.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_DATATYPES_H__
+#define __IVUG_DATATYPES_H__
+
+#include "ivug-define.h"
+
+typedef void *Handle;
+
+#ifdef _USE_MEDIAINFO_STRINGID_
+typedef const char *UUID;
+#else
+typedef int UUID;
+#endif
+
+#endif // __IVUG_DATATYPES_H__
+
diff --git a/main/src/common/ivug-define.h b/main/src/common/ivug-define.h
new file mode 100755
index 0000000..0cddf5b
--- /dev/null
+++ b/main/src/common/ivug-define.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ system widely used definition.
+*/
+
+#pragma once
+
+#define IVUG_MAX_FILE_PATH_LEN (4096)
+
+/*
+Definition "PREFIX" is declared in CMakelist.txt
+ PREFIX is "/opt/ug"
+ PACKAGE is "ug-image-viewer-efl"
+
+ Path name does not include trailing /.
+
+ DATA_PATH is /opt/data
+*/
+#define LOCALE_PATH PREFIX"/res/locale"
+#define IMAGE_PATH PREFIX"/res/images/"PACKAGE
+#define EDJ_PATH PREFIX"/res/edje/"PACKAGE
+
+/*
+ Home screen and Lock screen image should be put in DATA_PATH.
+*/
+#define DATA_PATH DATADIR"/"PACKAGE
+
+// TODO : Add comments
+#define IV_WINDOW_SIZE (41)//41 /* it's better to be odd number */
+#define IV_WINDOW_SIZE_FOR_SLIDE_SHOW (1)
+#define IV_RELOAD_OFFSET (4)//IV_WINDOW_SIZE/10 // it's better to be larger than 2
+
+#define USE_WIN_AS_PARENT
+
+#define NAVI_OPTION_BTN_STYLE "multiline"
+
+#define IVUG_DEFAULT_BG_COLOR 48
+
+#define _USE_MEDIAINFO_STRINGID_
+
+#define FEATURE_DYNAMIC_POPUP_HEIGHT
+
+#define USE_CUSTOM_STYLE
+
diff --git a/main/src/common/ivug-string.h b/main/src/common/ivug-string.h
new file mode 100755
index 0000000..ab4458d
--- /dev/null
+++ b/main/src/common/ivug-string.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_STRING_H__
+#define __IVUG_STRING_H__
+
+#include <libintl.h>
+
+/* Original code is in appcore-common.h */
+#define _(str) gettext(str) /**< gettext alias */
+#define gettext_noop(str) (str) /**< keyword for xgettext to extract translatable strings */
+#define N_(str) gettext_noop(str) /**< gettext_noop alias */
+
+
+#define LOCALE_PATH PREFIX"/res/locale" /*TODO!!!*/
+
+#ifndef PACKAGE
+#error PACKAGE is not defined
+#endif
+
+#ifndef LOCALE_PATH
+#error LOCALE_PATH is not defined
+#endif
+
+//string
+#define IVUG_TEXT_DOMAIN PACKAGE
+#define IVUG_LOCALEDIR LOCALE_PATH
+
+// Not yet translated
+#define IDS_NULL _("")
+
+#define IDS_INVALID_IMAGE_FILE (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_POP_INVALID_IMAGE_FILE"))
+#define IDS_PERMISSION_DENIED (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_POP_PERMISSION_DENIED"))
+#define IDS_APPLICATION_NOT_INSTALLED (dgettext("sys_string","IDS_COM_BODY_APPLICATION_NOT_INSTALLED"))
+
+/*#define Details*/
+#define IDS_FORMAT (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_BODY_FILE_FORMAT"))
+#define IDS_DATE_CREATED (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_BODY_DATE_CREATED"))
+#define IDS_LOCATION (dgettext(IVUG_TEXT_DOMAIN, "IDS_COM_BODY_LOCATION"))
+#define IDS_FILE_LOCATION (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_BODY_FILE_LOCATION"))
+#define IDS_RESOLUTION (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_BODY_RESOLUTION"))
+#define IDS_LATITUDE (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_BODY_LATITUDE"))
+#define IDS_LONGITUDE (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_BODY_LONGITUDE"))
+
+#define IDS_N_A (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_BODY_N_A"))
+#define IDS_PRINT (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_BODY_PRINT"))
+
+/* Registered string in STMS IV */
+#define IDS_ADDED (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_POP_ADDED"))
+#define IDS_SLIDE_SHOW (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_OPT_SLIDE_SHOW"))
+
+#define IDS_SD_CARD_REMOVED (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_POP_SD_CARD_REMOVED"))
+#define IDS_SET_AS (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_OPT_SET_AS"))
+
+#define IDS_HOME_SCREEN_WALLPAPER (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"))
+#define IDS_LOCK_SCREEN_WALLPAPER (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"))
+#define IDS_SET_WALLPAPER_FOR_HOME_SCREEN_AND_LOCK_SCREEN (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_POP_SET_WALLPAPER_FOR_HOME_SCREEN_AND_LOCK_SCREEN"))
+#define IDS_HOME_AND_LOCK_SCREEN_WALLPAPER (dgettext(IVUG_TEXT_DOMAIN, "IDS_IV_OPT_HOME_AND_LOCK_SCREEN_WALLPAPER"))
+
+// System string.
+#define IDS_DELETE_MSG (dgettext("sys_string","IDS_COM_POP_DELETE_Q"))
+#define IDS_NAME (dgettext("sys_string", "IDS_COM_BODY_DETAILS_NAME"))
+#define IDS_SIZE (dgettext("sys_string", "IDS_COM_BODY_SIZE"))
+
+#define IDS_COPY (dgettext("sys_string","IDS_COM_BODY_COPY"))
+
+#define IDS_ERROR (dgettext("sys_string","IDS_COM_POP_ERROR"))
+#define IDS_UNKNOWN (dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"))
+
+#define IDS_LOADING (dgettext("sys_string", "IDS_COM_BODY_LOADING"))
+
+#define IDS_BLUETOOTH (dgettext("sys_string", "IDS_COM_BODY_BLUETOOTH"))
+
+#define IDS_CANCEL (dgettext("sys_string", "IDS_COM_SK_CANCEL"))
+#define IDS_DONE (dgettext("sys_string","IDS_COM_SK_DONE"))
+
+#define IDS_SET (dgettext("sys_string","IDS_COM_SK_SET"))
+#define IDS_BACK (dgettext("sys_string","IDS_COM_BODY_BACK"))
+
+#define IDS_OK (dgettext("sys_string","IDS_COM_SK_OK"))
+#define IDS_DELETE (dgettext("sys_string","IDS_COM_BODY_DELETE"))
+#define IDS_DELETED (dgettext("sys_string","IDS_COM_POP_DELETED"))
+
+#define IDS_SAVED (dgettext("sys_string","IDS_COM_POP_SAVED"))
+#define IDS_NO (dgettext("sys_string","IDS_COM_SK_NO"))
+#define IDS_YES (dgettext("sys_string","IDS_COM_SK_YES"))
+
+#define IDS_SUCCESS (dgettext("sys_string", "IDS_COM_POP_SUCCESS"))
+#define IDS_FAILED (dgettext("sys_string", "IDS_COM_POP_FAILED"))
+
+#define IDS_DETAILS (dgettext("sys_string","IDS_COM_BODY_DETAILS"))
+
+#define IDS_CLOSE (dgettext("sys_string", "IDS_COM_BODY_CLOSE"))
+#define IDS_NO_NAME (dgettext("sys_string", "IDS_COM_BODY_NO_NAME"))
+
+#endif // __IVUG_STRING_H__
+
+
diff --git a/main/src/control/ivug-ext-ug.c b/main/src/control/ivug-ext-ug.c
new file mode 100755
index 0000000..e3c5398
--- /dev/null
+++ b/main/src/control/ivug-ext-ug.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-ext-ug.h"
+#include "ivug-data.h"
+#include "ivug-popup.h"
+
+#include <ui-gadget.h>
+#include <aul.h>
+#include <appsvc.h>
+#include <Ecore_X.h> // UG_INIT_EFL
+
+//define
+#define VIDEOPLAYER_PKG_NAME "org.tizen.video-player"
+#define BLUETOOTH_PKG_NAME "org.tizen.bluetooth"
+
+#define MIME_TYPE_LEN 255
+
+bool
+ivug_ext_aul_launch(Evas_Object *parent, enum IVUG_EXT_AUL_TYPE type, const char *filepath, void *data)
+{
+ if(!filepath)
+ {
+ MSG_UTIL_ERROR("file path is NULL");
+ return false;
+ }
+ MSG_IMAGEVIEW_HIGH("Creating AUL. type=%d file path =%s", type, filepath);
+
+ bundle* b = bundle_create();
+ char mime_type[MIME_TYPE_LEN] = {0,};
+ aul_get_mime_from_file(filepath, mime_type, sizeof(mime_type));
+ MSG_IMAGEVIEW_HIGH("mime type=%s", mime_type);
+
+ IV_ASSERT(b!= NULL);
+ switch( type )
+ {
+ case IVUG_EXT_AUL_VIDEOPLAYER:
+ bundle_add( b, "path", filepath);
+ bundle_add( b, "launching_application", "image_viewer");
+ aul_launch_app(VIDEOPLAYER_PKG_NAME, b);
+ break;
+
+ case IVUG_EXT_AUL_SIMPLE_VIDEOPLAYER:
+ bundle_add( b, "path", filepath);
+ bundle_add( b, "launching_application", "light_play_view");
+// Camera -> Image Viewer -> Video player, In this case, launching_application bundle's value should be "light_play_view"
+
+ aul_launch_app(VIDEOPLAYER_PKG_NAME, b);
+ break;
+
+ default:
+ bundle_free(b);
+ return false;
+ }
+
+ bundle_free(b);
+
+ return true;
+}
+
+
diff --git a/main/src/control/ivug-ext-ug.h b/main/src/control/ivug-ext-ug.h
new file mode 100755
index 0000000..dc4a924
--- /dev/null
+++ b/main/src/control/ivug-ext-ug.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-data.h"
+
+#ifndef __IVUG_EXT_UG_H__
+#define __IVUG_EXT_UG_H__
+
+typedef enum IVUG_EXT_AUL_TYPE{
+ IVUG_EXT_AUL_NONE = 0x00,
+ IVUG_EXT_AUL_VIDEOPLAYER,
+ IVUG_EXT_AUL_SIMPLE_VIDEOPLAYER,
+} _ivug_ext_aul_type;
+
+
+bool
+ivug_ext_aul_launch(Evas_Object *parent, enum IVUG_EXT_AUL_TYPE type, const char *filepath, void *data);
+
+#endif //__IVUG_EXT_UG_H__
diff --git a/main/src/control/ivug-main.c b/main/src/control/ivug-main.c
new file mode 100755
index 0000000..3efb9c8
--- /dev/null
+++ b/main/src/control/ivug-main.c
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-main.h"
+#include "ivug-data.h"
+#include "ivug-util.h"
+
+
+#include <ui-gadget-module.h> // ug_destroy_me
+#include <media-svc.h>
+
+#define MAX_INSTALNCE (5)
+
+typedef struct
+{
+ struct ui_gadget *ug; // ug handle
+
+ Evas_Object *parent_win;
+// EFL theme
+ Elm_Theme *th;
+
+// Window Geometry
+ int win_w, win_h; //size
+
+ MediaSvcHandle *media_svc_hadle;
+
+} AppData;
+
+static Eina_List *ContextList = NULL;
+
+Elm_Theme*
+gGetSystemTheme(void)
+{
+ AppData *ugContext;
+ ugContext = eina_list_data_get(ContextList);
+
+ IV_ASSERT(ugContext != NULL);
+
+ return ugContext->th;
+}
+
+void
+gGetSystemDimension(int *w, int *h)
+{
+ AppData *ugContext;
+ ugContext = eina_list_data_get(ContextList);
+
+ IV_ASSERT(ugContext != NULL);
+ IV_ASSERT(w != NULL);
+ IV_ASSERT(h != NULL);
+
+ *w = ugContext->win_w;
+ *h = ugContext->win_h;
+}
+
+int gGetScreenWidth()
+{
+ AppData *ugContext;
+ ugContext = eina_list_data_get(ContextList);
+
+ IV_ASSERT(ugContext != NULL);
+
+ return ugContext->win_w;
+
+}
+
+int gGetScreenHeight()
+{
+ AppData *ugContext;
+ ugContext = eina_list_data_get(ContextList);
+
+ IV_ASSERT(ugContext != NULL);
+
+ return ugContext->win_h;
+
+}
+
+struct ui_gadget *
+gGetUGHandle(void)
+{
+ AppData *ugContext;
+ ugContext = eina_list_data_get(ContextList);
+
+ IV_ASSERT(ugContext != NULL);
+
+ MSG_IMAGEVIEW_HIGH("Get ug handle = 0x%08x", ugContext->ug);
+
+ return ugContext->ug;
+}
+
+MediaSvcHandle *
+gGetMediaSVCHandle(void)
+{
+ AppData *ugContext;
+ ugContext = eina_list_data_get(ContextList);
+
+ IV_ASSERT(ugContext != NULL);
+
+ return ugContext->media_svc_hadle;
+}
+
+#define IVUG_NAVIFRAME_NAME EDJ_PATH"/ivug-naviframe.edj"
+#define IVUG_TOOLLBAR_NAME EDJ_PATH"/ivug-toolbar.edj"
+#define IVUG_BUTTON_NAME EDJ_PATH"/ivug-button.edj"
+#define IVUG_SELECTION_INFO_NAME EDJ_PATH"/ivug-selectioninfo.edj"
+#define IVUG_GENLIST EDJ_PATH"/ivug-genlist.edj"
+
+static char *edj[] = {
+ IVUG_NAVIFRAME_NAME,
+ IVUG_TOOLLBAR_NAME,
+ IVUG_BUTTON_NAME,
+ IVUG_SELECTION_INFO_NAME,
+ IVUG_GENLIST,
+ NULL,
+};
+
+bool
+ivug_main_init(struct ui_gadget *ug)
+{
+ AppData *Context = malloc(sizeof(AppData));
+ if(Context == NULL)
+ {
+ MSG_IVUG_ERROR("Cannot allock memory");
+ return false;
+ }
+
+ Context->ug = ug;
+ Context->parent_win = ug_get_window();
+
+//get window width, height
+ int w, h;
+
+ evas_object_geometry_get(Context->parent_win, NULL, NULL, &w, &h);
+ MSG_IMAGEVIEW_HIGH("Screen WH(%dx%d)", w, h);
+// ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ Context->win_w = w;
+ Context->win_h = h;
+
+
+ int i = 0;
+
+ Context->th = elm_theme_new();
+
+ IV_ASSERT(Context->th != NULL);
+
+ elm_theme_ref_set(Context->th, NULL);
+
+ for ( i = 0; edj[i] != NULL; i++)
+ {
+ elm_theme_extension_add(Context->th, edj[i]);
+ }
+
+ ContextList = eina_list_prepend(ContextList, Context);
+
+ MSG_IVUG_HIGH("Append to list. Context=0x%08x", Context);
+
+//media browser service.
+ int err = media_svc_connect(&(Context->media_svc_hadle));
+ if (err == MB_SVC_ERROR_NONE)
+ {
+ bindtextdomain(IVUG_TEXT_DOMAIN, IVUG_LOCALEDIR); //bind text domain
+ return TRUE;
+ }
+
+/**** Error routine ****/
+ MSG_SDATA_WARN("media service init error=%d", err);
+
+ Context = eina_list_data_get(ContextList);
+ ContextList = eina_list_remove_list(ContextList, ContextList);
+
+ if(Context->th)
+ {
+ int i = 0;
+ for ( i = 0; edj[i] != NULL; i++)
+ {
+ elm_theme_extension_del(Context->th, edj[i]);
+ }
+
+ elm_theme_free(Context->th);
+ }
+
+ MSG_IVUG_HIGH("Remove from list. Context=0x%08x, ug=0x%08x", Context, Context->ug);
+
+ free(Context);
+
+ return false;
+}
+
+
+bool
+ivug_main_deinit(struct ui_gadget *ug)
+{
+ AppData *Context;
+
+ Eina_List *l = NULL;
+ Eina_List *l_next = NULL;
+
+ EINA_LIST_FOREACH_SAFE(ContextList, l, l_next, Context)
+ {
+ if(Context == NULL)
+ {
+ MSG_SDATA_ERROR("Context is NULL");
+ return false;
+ }
+ if (Context->ug == ug)
+ {
+ ContextList = eina_list_remove_list(ContextList, l);
+ break;
+ }
+ }
+
+ //media browser service.
+ int err = media_svc_disconnect(Context->media_svc_hadle);
+ if (err != MB_SVC_ERROR_NONE)
+ {
+ MSG_SDATA_WARN("media service finalize error=%d", err);
+ // go through
+ }
+ else
+ {
+ MSG_SDATA_HIGH("MInfo finalized");
+ }
+
+ if(Context->th)
+ {
+ int i = 0;
+ for ( i = 0; edj[i] != NULL; i++)
+ {
+ elm_theme_extension_del(Context->th, edj[i]);
+ }
+ elm_theme_free(Context->th);
+ }
+
+ MSG_IVUG_HIGH("Remove from list. Context=0x%08x, ug=0x%08x", Context, Context->ug);
+
+ free(Context);
+
+ return true;
+}
+
+
+
+
diff --git a/main/src/control/ivug-main.h b/main/src/control/ivug-main.h
new file mode 100755
index 0000000..86d9837
--- /dev/null
+++ b/main/src/control/ivug-main.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_MAIN_H__
+#define __IVUG_MAIN_H__
+
+#include "ivug-common.h"
+#include <ui-gadget.h>
+#include <media-svc.h>
+
+bool
+ivug_main_deinit(struct ui_gadget *ug);
+
+bool
+ivug_main_init(struct ui_gadget *ug);
+
+Elm_Theme*
+gGetSystemTheme(void);
+
+struct ui_gadget *
+gGetUGHandle(void);
+
+MediaSvcHandle *
+gGetMediaSVCHandle(void);
+
+int gGetScreenWidth();
+int gGetScreenHeight();
+
+
+#endif //__IVUG_MAIN_H__
diff --git a/main/src/control/ivug-parameter.c b/main/src/control/ivug-parameter.c
new file mode 100755
index 0000000..5717181
--- /dev/null
+++ b/main/src/control/ivug-parameter.c
@@ -0,0 +1,397 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <bundle.h>
+#include <string.h>
+
+#include "ivug-common.h"
+#include "ivug-debug.h"
+#include "ivug-parameter.h"
+
+//bundle key
+#define IVUG_BUNDLE_KEY_VIEW_MODE "View Mode"
+#define IVUG_BUNDLE_KEY_PATH "Path"
+#define IVUG_BUNDLE_KEY_THUMBNAIL_PATH "Thumb Path"
+#define IVUG_BUNDLE_KEY_ALBUM_IDX "Album index"
+#define IVUG_BUNDLE_KEY_VIEW_BY "View By"
+#define IVUG_BUNDLE_KEY_INDEX "Index"
+#define IVUG_BUNDLE_KEY_SORT_BY "Sort By"
+
+#define IVUG_BUNDLE_KEY_MAX_LONGITUDE "LON_MAX"
+#define IVUG_BUNDLE_KEY_MIN_LONGITUDE "LON_MIN"
+#define IVUG_BUNDLE_KEY_MAX_LATITUDE "LAT_MAX"
+#define IVUG_BUNDLE_KEY_MIN_LATITUDE "LAT_MIN"
+
+#define IVUG_BUNDLE_KEY_SETAS_TYPE "Setas type"
+
+#define IVUG_BUNDLE_KEY_MEDIA_TYPE "Media type"
+
+//default values
+#define IVUG_DEFAULT_MODE IVUG_MODE_SINGLE
+#define IVUG_DEFAULT_INDEX (-1)
+
+static ivug_mode
+_get_view_mode(ivug_parameter* data, const char* val)
+{
+ IV_ASSERT(val != NULL);
+
+#define IVUG_BUNDLE_VALUE_VIEW_MODE_ALBUM "ALBUM"
+#define IVUG_BUNDLE_VALUE_VIEW_MODE_NORMAL "NORMAL"
+#define IVUG_BUNDLE_VALUE_VIEW_MODE_SINGLE "SINGLE"
+#define IVUG_BUNDLE_VALUE_VIEW_MODE_GALLERY "GALLERY"
+#define IVUG_BUNDLE_VALUE_VIEW_MODE_CAMERA "CAMERA"
+#define IVUG_BUNDLE_VALUE_VIEW_MODE_DISPLAY "DISPLAY"
+#define IVUG_BUNDLE_VALUE_VIEW_MODE_SETAS "SETAS"
+ int len = strlen(val);
+
+ if (strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_NORMAL, len) == 0
+ || strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_GALLERY, len) == 0 )
+ {
+ return IVUG_MODE_NORMAL;
+ }
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_ALBUM, len) == 0)
+ {
+ // Probably, UnUsed.
+ MSG_IVUG_ERROR("ALBUM is deprecated!!!! plz check");
+ printf("bundle key ALBUM is deprecated!!!! plz check\n");
+ return IVUG_MODE_NORMAL;
+ }
+ else if ( strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_CAMERA, len) == 0)
+ {
+ data->start_index = 1; //apply window loading
+ data->view_by = IVUG_VIEW_BY_FOLDER; // In camera case, All images should be shown in camera folder.
+ return IVUG_MODE_CAMERA;
+ }
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_SINGLE, len) == 0)
+ {
+ data->view_by = IVUG_VIEW_BY_FILE;
+ return IVUG_MODE_SINGLE;
+ }
+ else if ( strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_DISPLAY, len) == 0)
+ {
+ data->view_by = IVUG_VIEW_BY_FILE;
+ return IVUG_MODE_DISPLAY;
+ }
+ else if(strncmp(val, IVUG_BUNDLE_VALUE_VIEW_MODE_SETAS, len) == 0)
+ {
+ data->view_by = IVUG_VIEW_BY_FILE;
+ return IVUG_MODE_SETAS;
+ }
+
+ MSG_IVUG_ERROR("Invalid mode : %s", val);
+ return IVUG_MODE_INVAILD;
+}
+
+
+static ivug_view_by
+_get_view_by(const char* val)
+{
+ //bundle value
+#define IVUG_BUNDLE_VALUE_VIEW_BY_ALL "All"
+#define IVUG_BUNDLE_VALUE_VIEW_BY_FLODER "By Folder"
+#define IVUG_BUNDLE_VALUE_VIEW_BY_PLACES "Places"
+
+ IV_ASSERT(val != NULL);
+
+ int len = strlen(val);
+
+ if (strncmp(val, IVUG_BUNDLE_VALUE_VIEW_BY_FLODER, len) == 0 )
+ {
+ return IVUG_VIEW_BY_FOLDER;
+ }
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_VIEW_BY_ALL, len) == 0 )
+ {
+ return IVUG_VIEW_BY_ALL;
+ }
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_VIEW_BY_PLACES, len) == 0)
+ {
+ return IVUG_VIEW_BY_PLACES;
+ }
+
+ MSG_IVUG_ERROR("Invalid view by : %s", val);
+
+ return IVUG_VIEW_BY_FILE;
+
+}
+
+
+static ivug_setas_type
+_get_setas_type(const char* val)
+{
+ IV_ASSERT(val != NULL);
+
+#define IVUG_BUNDLE_VALUE_SETAS_UG_WALLPAPER "Wallpaper"
+
+ int len = strlen(val);
+
+ if (strncmp(val, IVUG_BUNDLE_VALUE_SETAS_UG_WALLPAPER, len) == 0 )
+ {
+ return IVUG_SET_AS_UG_TYPE_WALLPAPER;
+ }
+
+ MSG_IVUG_ERROR("Invalid setas ug type : %s", val);
+ return IVUG_SET_AS_UG_TYPE_INVALID;
+}
+
+static ivug_media_type
+_get_media_type(const char* val)
+{
+ IV_ASSERT(val != NULL);
+#define IVUG_BUNDLE_VALUE_MEDIA_TYPE_ALL "All"
+#define IVUG_BUNDLE_VALUE_MEDIA_TYPE_IMAGE "Image"
+#define IVUG_BUNDLE_VALUE_MEDIA_TYPE_VIDEO "Video"
+
+ int len = strlen(val);
+
+ if (strncmp(val, IVUG_BUNDLE_VALUE_MEDIA_TYPE_IMAGE, len) == 0 )
+ {
+ return IVUG_MEDIA_TYPE_IMAGE;
+ }
+ else if (strncmp(val, IVUG_BUNDLE_VALUE_MEDIA_TYPE_VIDEO, len) == 0)
+ {
+ return IVUG_MEDIA_TYPE_VIDEO;
+ }
+ else if(strncmp(val, IVUG_BUNDLE_VALUE_MEDIA_TYPE_ALL, len) == 0)
+ {
+ return IVUG_MEDIA_TYPE_ALL;
+ }
+
+ MSG_IVUG_ERROR("Invalid media type : %s", val);
+ return IVUG_MEDIA_TYPE_MAX;
+}
+
+
+
+static void
+_bundle_print(const char *key, const char *val, void *data)
+{
+ MSG_IVUG_HIGH(" %s:%s",key, val);
+}
+
+//parsing bundle
+ivug_parameter*
+ivug_param_create_from_bundle(bundle* b)
+{
+ if (b == NULL)
+ {
+ MSG_IVUG_WARN("bundle value is NULL");
+ return NULL;
+ }
+
+ int nbundle_cnt = bundle_get_count(b);
+
+ if ( nbundle_cnt == 0 )
+ {
+ MSG_IVUG_WARN("bundle count is %d", nbundle_cnt);
+ return NULL;
+ }
+
+ //print key and value.
+ MSG_IVUG_HIGH("**********************************");
+ MSG_IVUG_HIGH(" Bundle Count = %d", nbundle_cnt);
+ bundle_iterate(b, _bundle_print, NULL);
+ MSG_IVUG_HIGH("**********************************");
+
+ //parsing param
+ ivug_parameter* data = (ivug_parameter*)calloc(1, sizeof(ivug_parameter));
+
+ if (data == NULL)
+ {
+ MSG_IMAGEVIEW_FATAL("Cannot allocate memory");
+ return NULL;
+ }
+
+// View By
+ const char* szViewBy = NULL;
+
+ szViewBy = bundle_get_val(b, IVUG_BUNDLE_KEY_VIEW_BY);
+ if (szViewBy != NULL)
+ {
+ MSG_IVUG_HIGH("View By = %s", szViewBy);
+
+ data->view_by = _get_view_by(szViewBy);
+ }
+ else
+ {
+ MSG_IVUG_ERROR("View By is NULL");
+ data->view_by = IVUG_VIEW_BY_INVAILD;
+ }
+
+//parse image index at album
+ const char* val = NULL;
+
+ val = bundle_get_val(b, IVUG_BUNDLE_KEY_INDEX);
+ if(val)
+ {
+ data->start_index = atoi(val);
+ MSG_IVUG_HIGH("Slide Index = %d", data->start_index);
+ }
+ else
+ {
+ data->start_index = IVUG_DEFAULT_INDEX;
+ MSG_IVUG_HIGH("Slide Index is not set. Set as default : %d", data->start_index);
+ }
+
+//parse mode
+ const char* szMode = NULL;
+
+ szMode = bundle_get_val(b, IVUG_BUNDLE_KEY_VIEW_MODE);
+
+ if (szMode != NULL)
+ {
+ data->mode = _get_view_mode(data, szMode);
+ MSG_IVUG_HIGH("View mode is %s(%d)", szMode, data->mode);
+ }
+ else
+ {
+ data->mode = IVUG_DEFAULT_MODE;
+ MSG_IVUG_HIGH("View mode is NULL. Set Default(%d)", data->mode);
+ }
+
+//parse path
+ const char* szFilePath = NULL;
+
+ szFilePath = bundle_get_val(b, IVUG_BUNDLE_KEY_PATH);
+
+ if ( szFilePath != NULL )
+ {
+ data->filepath = strdup(szFilePath);
+ MSG_IVUG_HIGH("Current File = %s", data->filepath);
+ }
+
+ //parse album id -album id is cluster id of media service
+ val = bundle_get_val(b, IVUG_BUNDLE_KEY_ALBUM_IDX);
+
+ if(val && data->view_by != IVUG_VIEW_BY_ALL)
+ {
+ data->album_id = uuid_getuuid(val);
+ MSG_IVUG_HIGH("album_uuid is %s", uuid_getchar(data->album_id));
+ }
+ else
+ {
+ data->album_id = INVALID_UUID;
+ MSG_IVUG_WARN("Album index is NULL");
+ }
+ if (data->mode == IVUG_MODE_CAMERA)
+ {
+/*
+ **********************************
+ Bundle Count = 2
+ View Mode:CAMERA
+ Path:/opt/media/Camera shots/IMAGE0021.jpg
+ **********************************
+*/
+ // Get album id from file path.
+ UUID cluster_id = ivug_get_album_id_from_filepath(data->filepath);
+
+ data->album_id = uuid_assign(cluster_id);
+
+ MSG_IVUG_HIGH("Get Album ID(%s) from file %s", uuid_getchar(data->album_id), data->filepath);
+ }
+
+// TODO : Check parameter integrity
+ val = bundle_get_val(b, IVUG_BUNDLE_KEY_MEDIA_TYPE);
+ if(val != NULL)
+ {
+ data->media_type = _get_media_type(val);
+ MSG_IVUG_HIGH("Media Type=%s(%d)", val, data->media_type);
+ }
+ else
+ {
+ MSG_IVUG_WARN("Media type is not specified.");
+ }
+
+ long long int m = 0;
+ long int e = 0;
+
+ val = bundle_get_val(b, IVUG_BUNDLE_KEY_MAX_LONGITUDE);
+ if(val != NULL)
+ {
+ eina_convert_atod(val, strlen(val), &m, &e);
+ data->max_longitude = ldexp((double)m, e);
+ MSG_IVUG_HIGH("Max Longitude =%f", data->max_longitude);
+ }
+ else
+ {
+ MSG_IVUG_MED("Max Longitude is not specified.");
+ }
+
+ val = bundle_get_val(b, IVUG_BUNDLE_KEY_MIN_LONGITUDE);
+ if(val != NULL)
+ {
+ eina_convert_atod(val, strlen(val), &m, &e);
+ data->min_longitude = ldexp((double)m, e);
+ MSG_IVUG_HIGH("Min Longitude =%f", data->min_longitude);
+ }
+ else
+ {
+ MSG_IVUG_MED("Min Longitude is not specified.");
+ }
+
+ val = bundle_get_val(b, IVUG_BUNDLE_KEY_MAX_LATITUDE);
+ if(val != NULL)
+ {
+ eina_convert_atod(val, strlen(val), &m, &e);
+ data->max_latitude = ldexp((double)m, e);
+ MSG_IVUG_HIGH("Max Latitude =%f", data->max_latitude);
+ }
+ else
+ {
+ MSG_IVUG_MED("Max Latitude is not specified.");
+ }
+
+ val = bundle_get_val(b, IVUG_BUNDLE_KEY_MIN_LATITUDE);
+ if(val != NULL)
+ {
+ eina_convert_atod(val, strlen(val), &m, &e);
+ data->min_latitude = ldexp((double)m, e);
+ MSG_IVUG_HIGH("Min Latitude =%f", data->min_latitude);
+ }
+ else
+ {
+ MSG_IVUG_MED("Min Latitude is not specified.");
+ }
+
+ val = bundle_get_val(b, IVUG_BUNDLE_KEY_SETAS_TYPE);
+ if (val)
+ {
+ MSG_IVUG_HIGH("SetAs UG Type=%s", val);
+ data->setas_type = _get_setas_type(val);
+ }
+
+ return data;
+}
+
+void
+ivug_param_delete(ivug_parameter* data)
+{
+ IV_ASSERT(data != NULL);
+ if (data->filepath)
+ {
+ free(data->filepath);
+ data->filepath = NULL;
+ }
+
+ uuid_free(data->album_id);
+
+ free(data);
+
+ MSG_IVUG_HIGH("Parameter is freed.");
+
+}
+
+
diff --git a/main/src/control/ivug-parameter.h b/main/src/control/ivug-parameter.h
new file mode 100755
index 0000000..1de14c4
--- /dev/null
+++ b/main/src/control/ivug-parameter.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_PARAMETER_H__
+#define __IVUG_PARAMETER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+#include <bundle.h>
+
+typedef enum {
+ IVUG_MODE_INVAILD = 0x00,
+ IVUG_MODE_NORMAL, // normal
+ IVUG_MODE_SINGLE, // just show one slide
+ IVUG_MODE_DISPLAY, // from "take a photo" in messenger
+ IVUG_MODE_FILE, // file viewer(can flick)
+ IVUG_MODE_CAMERA, // camera(can flick)
+ IVUG_MODE_SETAS, // SetAs in setting menu.
+} ivug_mode;
+
+typedef enum {
+ IVUG_VIEW_BY_INVAILD = 0x00,
+ IVUG_VIEW_BY_FILE,
+ IVUG_VIEW_BY_ALL,
+ IVUG_VIEW_BY_FOLDER,
+ IVUG_VIEW_BY_PLACES,
+} ivug_view_by;
+
+//set as ug
+typedef enum {
+ IVUG_SET_AS_UG_TYPE_INVALID = 0x00,
+ IVUG_SET_AS_UG_TYPE_WALLPAPER,
+ IVUG_SET_AS_UG_TYPE_MAX,
+} ivug_setas_type;
+
+typedef enum {
+ IVUG_MEDIA_TYPE_ALL = 0x00, //default value
+ IVUG_MEDIA_TYPE_IMAGE,
+ IVUG_MEDIA_TYPE_VIDEO,
+ IVUG_MEDIA_TYPE_MAX,
+} ivug_media_type;
+
+typedef enum {
+ IVUG_MEDIA_SORT_NONE = 0x00, /**< No sort */
+ IVUG_MEDIA_ASC_BY_NAME, /**< Ascending sort as file name */
+ IVUG_MEDIA_DESC_BY_NAME, /**< Descending sort as file name */
+ IVUG_MEDIA_ASC_BY_DATE, /**< Ascending sort as created date */
+ IVUG_MEDIA_DESC_BY_DATE, /**< Descending sort as created date */
+} ivug_sort_type;
+
+typedef struct {
+ ivug_mode mode;
+
+ char* filepath;
+ UUID album_id; //cluster id of media service
+
+ ivug_view_by view_by;
+ ivug_setas_type setas_type;
+ ivug_media_type media_type;
+ ivug_sort_type sort_type; // TODO : extract from here. sort type can be used in case of default
+
+ /* for places view */
+ double max_longitude;
+ double min_longitude;
+ double max_latitude;
+ double min_latitude;
+
+ int start_index;
+
+} ivug_parameter;
+
+
+ivug_parameter*
+ivug_param_create_from_bundle(bundle* b);
+
+void
+ivug_param_delete(ivug_parameter* data);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif // __IVUG_PARAMETER_H__
+
+
diff --git a/main/src/control/ivug-uuid.c b/main/src/control/ivug-uuid.c
new file mode 100755
index 0000000..b2c8eeb
--- /dev/null
+++ b/main/src/control/ivug-uuid.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-uuid.h"
+
+UUID uuid_assign(UUID id)
+{
+#ifdef _USE_MEDIAINFO_STRINGID_
+ if ( id == NULL )
+ return NULL;
+
+ return strdup(id);
+#else
+ return id;
+#endif
+}
+
+
+void uuid_free(UUID id)
+{
+#ifdef _USE_MEDIAINFO_STRINGID_
+ if ( id != NULL )
+ free((void *)id);
+#endif
+}
+
+
+int uuid_compare(UUID id1, UUID id2)
+{
+#ifdef _USE_MEDIAINFO_STRINGID_
+ return strcmp(id1, id2);
+#else
+ return id1 - id2;
+#endif
+}
+
+const char *uuid_getchar(UUID id)
+{
+#ifdef _USE_MEDIAINFO_STRINGID_
+ if ( id == NULL )
+ {
+ return "NULL";
+ }
+
+ return id;
+#else
+ {
+ static char buffer[255];
+
+ sprintf(buffer, "%d", id);
+
+ return buffer;
+ }
+#endif
+
+}
+
+
+UUID uuid_getuuid(const char *szID)
+{
+ if ( szID == NULL )
+ {
+ return INVALID_UUID;
+ }
+
+#ifdef _USE_MEDIAINFO_STRINGID_
+ return strdup(szID);
+#else
+ return atoi(szID);
+#endif
+
+}
+
+bool uuid_is_valid(UUID id)
+{
+ return (id != INVALID_UUID) ? true : false;
+}
+
+
+
diff --git a/main/src/control/ivug-uuid.h b/main/src/control/ivug-uuid.h
new file mode 100755
index 0000000..e90bf6b
--- /dev/null
+++ b/main/src/control/ivug-uuid.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_UUID_H__
+#define __IVUG_UUID_H__
+
+#include "ivug-common.h"
+#include <stdbool.h>
+
+#ifdef _USE_MEDIAINFO_STRINGID_
+ #define INVALID_UUID ((UUID)NULL)
+#else
+ #define INVALID_UUID ((UUID)-1)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+UUID uuid_assign(UUID id);
+
+void uuid_free(UUID id);
+
+int uuid_compare(UUID id1, UUID id2);
+
+const char *uuid_getchar(UUID id);
+
+UUID uuid_getuuid(const char *szID);
+
+bool uuid_is_valid(UUID id);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __IVUG_UUID_H__
+
diff --git a/main/src/data/ivug-data-filter.c b/main/src/data/ivug-data-filter.c
new file mode 100755
index 0000000..754a723
--- /dev/null
+++ b/main/src/data/ivug-data-filter.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-data-filter.h"
+
+List_Filter *ivug_data_filter_create(const ivug_parameter *param)
+{
+ IV_ASSERT(param != NULL);
+
+ List_Filter *filter = calloc(1, sizeof(List_Filter));
+
+ IV_ASSERT(filter != NULL);
+
+ filter->view_by = param->view_by;
+ filter->media_type = param->media_type;
+ filter->sort_type = param->sort_type;
+
+ MSG_SDATA_HIGH("param->view_by is %d", param->view_by);
+ switch(param->view_by)
+ {
+ case IVUG_VIEW_BY_PLACES:
+ filter->place.max_longitude = param->max_longitude;
+ filter->place.min_longitude = param->min_longitude;
+ filter->place.max_latitude = param->max_latitude;
+ filter->place.min_latitude = param->min_latitude;
+ break;
+ case IVUG_VIEW_BY_FILE:
+ filter->file_path = strdup(param->filepath);
+ break;
+ case IVUG_VIEW_BY_ALL:
+ filter->album_id = uuid_assign(param->album_id);
+ break;
+
+ case IVUG_VIEW_BY_FOLDER:
+ filter->album_id = uuid_assign(param->album_id);
+ break;
+
+ case IVUG_VIEW_BY_INVAILD:
+ default:
+ MSG_SDATA_WARN("Invalid ViewBy : %d", param->view_by);
+ break;
+
+ }
+
+ return filter;
+
+}
+
+void ivug_data_filter_delete(List_Filter *filter)
+{
+ IV_ASSERT(filter != NULL);
+
+ MSG_SDATA_HIGH("Removing filter. ViewBy=%d", filter->view_by);
+
+ switch(filter->view_by)
+ {
+ case IVUG_VIEW_BY_PLACES:
+ break;
+
+ case IVUG_VIEW_BY_FILE:
+ if ( filter->file_path )
+ {
+ free(filter->file_path);
+ }
+ break;
+ case IVUG_VIEW_BY_ALL:
+ uuid_free(filter->album_id);
+ break;
+
+ case IVUG_VIEW_BY_FOLDER:
+ uuid_free(filter->album_id);
+
+ break;
+
+ case IVUG_VIEW_BY_INVAILD:
+ default:
+ MSG_SDATA_WARN("Invalid ViewBy : %d", filter->view_by);
+ break;
+ }
+
+
+ free(filter);
+}
+
+
+
diff --git a/main/src/data/ivug-data-filter.h b/main/src/data/ivug-data-filter.h
new file mode 100755
index 0000000..e4969de
--- /dev/null
+++ b/main/src/data/ivug-data-filter.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_DATA_FILTER_H__
+#define __IVUG_DATA_FILTER_H__
+
+#include "ivug-parameter.h"
+
+typedef struct {
+ ivug_view_by view_by;
+ ivug_media_type media_type;
+ ivug_sort_type sort_type;
+
+ union { /* CAUTION : Union type. check view_by variable before free()*/
+ char *file_path;
+ struct {
+ double max_longitude;
+ double min_longitude;
+ double max_latitude;
+ double min_latitude;
+ } place;
+
+ UUID album_id; // Cluster id
+ };
+
+} List_Filter;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+List_Filter *ivug_data_filter_create(const ivug_parameter *param);
+void ivug_data_filter_delete(List_Filter *filter);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __IVUG_DATA_FILTER_H__
+
diff --git a/main/src/data/ivug-data-list.c b/main/src/data/ivug-data-list.c
new file mode 100755
index 0000000..697b158
--- /dev/null
+++ b/main/src/data/ivug-data-list.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-main.h"
+#include "ivug-common.h"
+
+#include "ivug-data-priv.h"
+
+// List
+static int
+_ivug_list_count_cb(Mitem* item, void* user_data )
+{
+ int *count = (int *)user_data;
+
+ (*count)++;
+
+ return 0;
+}
+
+//Eina List Function.
+static int
+_ivug_list_mitem_cb(Mitem* item, void* user_data )
+{
+ IV_ASSERT(user_data != NULL);
+ Eina_List **list = (Eina_List **)user_data;
+
+ *list = eina_list_prepend(*list, item);
+
+ return 0;
+}
+
+
+Eina_List *
+ivug_list_load_items(List_Filter *filter, int stp, int endp)
+{
+ IV_ASSERT(filter != NULL);
+
+ Eina_List *item_list = NULL;
+
+ if (filter->view_by == IVUG_VIEW_BY_FILE)
+ {
+ Eina_List *list = NULL;
+ Media_Data *mData = ivug_alloc_mediadata_from_filepath(filter->file_path);
+
+ list = eina_list_append(list, mData);
+ return list;
+ }
+
+// TODO : Check idx validation.
+ minfo_item_filter item_filter = {0, }; //create filter
+
+ switch(filter->media_type)
+ {
+ case IVUG_MEDIA_TYPE_IMAGE:
+ item_filter.file_type = MINFO_ITEM_IMAGE;
+ break;
+ case IVUG_MEDIA_TYPE_VIDEO:
+ item_filter.file_type = MINFO_ITEM_VIDEO;
+ break;
+ case IVUG_MEDIA_TYPE_ALL:
+ item_filter.file_type = MINFO_ITEM_IMAGE | MINFO_ITEM_VIDEO;
+ break;
+ default:
+ MSG_SITEM_FATAL("Invalid media type : %d", filter->media_type);
+ return NULL;
+ break;
+ }
+
+ item_filter.favorite = MINFO_MEDIA_FAV_ALL;
+
+ if(filter->view_by == IVUG_VIEW_BY_PLACES)
+ {
+ item_filter.sort_type = MINFO_MEDIA_SORT_BY_NAME_ASC;
+ }
+ else
+ {
+ item_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_DESC; //MINFO_MEDIA_SORT_BY_NAME_ASC; //minfo_media_sort_type
+ }
+
+ item_filter.start_pos = stp;
+ item_filter.end_pos = endp;
+ item_filter.with_meta = false;
+
+ int ret = MB_SVC_ERROR_NONE;
+
+ switch(filter->view_by)
+ {
+ case IVUG_VIEW_BY_FOLDER:
+ ret = minfo_get_item_list(gGetMediaSVCHandle(), filter->album_id, item_filter, _ivug_list_mitem_cb, &item_list);
+ break;
+
+ case IVUG_VIEW_BY_ALL:
+ ret = minfo_get_all_item_list(gGetMediaSVCHandle(), MINFO_CLUSTER_TYPE_LOCAL_ALL, item_filter, _ivug_list_mitem_cb, &item_list);
+ break;
+
+ case IVUG_VIEW_BY_PLACES:
+ ret = minfo_get_geo_item_list(gGetMediaSVCHandle(), INVALID_UUID, MINFO_CLUSTER_TYPE_LOCAL_ALL, item_filter,
+ filter->place.min_longitude, filter->place.max_longitude,
+ filter->place.min_latitude, filter->place.max_latitude,
+ _ivug_list_mitem_cb, &item_list); // NULL means query all folder
+ break;
+ default:
+ MSG_SDATA_FATAL("Invalid Mode=%d", filter->view_by);
+ return NULL;
+ }
+
+ if ( ret != MB_SVC_ERROR_NONE )
+ {
+ MSG_SDATA_ERROR("[%s] Error=%d VieBy=%d", __func__, ret, filter->view_by);
+ return NULL;
+ }
+
+// Creating media_list.
+ Eina_List *slide_list = NULL;
+
+ Eina_List *item;
+ Mitem* mitem;
+
+ Media_Data *mdata = NULL;
+
+ EINA_LIST_FOREACH(item_list, item, mitem)
+ {
+ mdata = ivug_alloc_mediadata_from_mitem(mitem);
+
+ IV_ASSERT(mdata != NULL);
+
+ MSG_SDATA_LOW("Add Mdata. Mdata=0x%08x %s", mdata, mdata->filepath);
+ slide_list = eina_list_prepend(slide_list, mdata);
+ }
+
+ EINA_LIST_FREE(item_list, mitem)
+ {
+ minfo_destroy_mtype_item(mitem);
+ }
+
+ eina_list_free(item_list);
+
+ MSG_SDATA_HIGH("Item loaded(%d~%d)", stp, endp);
+
+ return slide_list;
+}
+
+
+int
+ivug_list_get_item_cnt(List_Filter *filter)
+{
+ IV_ASSERT(filter != NULL);
+
+// TODO : Check idx validation.
+ minfo_item_filter item_filter = {0, }; //create filter
+
+ switch(filter->media_type)
+ {
+ case IVUG_MEDIA_TYPE_IMAGE:
+ item_filter.file_type = MINFO_ITEM_IMAGE;
+ break;
+ case IVUG_MEDIA_TYPE_VIDEO:
+ item_filter.file_type = MINFO_ITEM_VIDEO;
+ break;
+ case IVUG_MEDIA_TYPE_ALL:
+ item_filter.file_type = MINFO_ITEM_IMAGE | MINFO_ITEM_VIDEO;
+ break;
+ default:
+ MSG_SITEM_FATAL("Invalid media type : %d", filter->media_type);
+ return -1;
+ break;
+ }
+
+ item_filter.favorite = MINFO_MEDIA_FAV_ALL;
+
+ if(filter->view_by == IVUG_VIEW_BY_PLACES)
+ {
+ item_filter.sort_type = MINFO_MEDIA_SORT_BY_NAME_ASC;
+ }
+ else
+ {
+ item_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_DESC; //MINFO_MEDIA_SORT_BY_NAME_ASC; //minfo_media_sort_type
+ }
+
+ item_filter.start_pos = -1;
+ item_filter.end_pos = -1;
+ item_filter.with_meta = false;
+
+ int ret = MB_SVC_ERROR_NONE;
+
+ int count = 0;
+
+ switch(filter->view_by)
+ {
+ case IVUG_VIEW_BY_ALL :
+ ret = minfo_get_item_cnt(gGetMediaSVCHandle(), filter->album_id, item_filter, &count);
+ if(ret < 0)
+ {
+ MSG_SDATA_ERROR("Error! AlbumUUID=%s Ret=%d", uuid_getchar(filter->album_id), ret );
+ return -1;
+ }
+
+ MSG_SDATA_HIGH("IVUG_VIEW_BY_ALL. MediaType=%d Count=%d", filter->media_type, count);
+ return count;
+ break;
+
+/* minfo_get_geo_item_list doesn't provide minfo get count api */
+/* So get total count menually by list callback function */
+ case IVUG_VIEW_BY_PLACES:
+ ret = minfo_get_geo_item_list(gGetMediaSVCHandle(), INVALID_UUID, MINFO_CLUSTER_TYPE_LOCAL_ALL, item_filter,
+ filter->place.min_longitude, filter->place.max_longitude,
+ filter->place.min_latitude, filter->place.max_latitude,
+ _ivug_list_count_cb, &count); // NULL means query all folder
+
+ if (ret < 0)
+ {
+ MSG_SDATA_ERROR("minfo_get_geo_item_list ERROR");
+ return -1;
+ }
+
+ MSG_SDATA_HIGH("IVUG_VIEW_BY_PLACES. Count=%d", count);
+ return count;
+
+ break;
+ case IVUG_VIEW_BY_FOLDER:
+ ret = minfo_get_item_cnt(gGetMediaSVCHandle(), filter->album_id, item_filter, &count);
+ if(ret < 0)
+ {
+ MSG_SDATA_ERROR("Error! AlbumUUID=%s Ret=%d", uuid_getchar(filter->album_id), ret );
+ return -1;
+ }
+ MSG_SDATA_HIGH("IVUG_VIEW_BY_FOLDER. Count=%d", count);
+ return count;
+
+ break;
+
+ case IVUG_VIEW_BY_FILE:
+ return 1; // item count is always 1 when by file
+ break;
+
+ default:
+ MSG_SDATA_ERROR("Unhandled view_by : %d", filter->view_by);
+ break;
+ }
+
+ return -1;
+}
+
+
+void ivug_list_delete_items(Eina_List *items)
+{
+ Media_Data* mdata;
+
+ if ( items == NULL )
+ {
+ MSG_SDATA_HIGH("Item list is NULL.");
+ return;
+ }
+
+ MSG_SDATA_HIGH("Removing items");
+
+ EINA_LIST_FREE(items, mdata)
+ {
+ if(mdata == NULL)
+ {
+ MSG_IVUG_ERROR("media list is NULL, can not free all media list");
+ }
+ else
+ {
+ ivug_free_mediadata(mdata);
+ }
+ }
+}
diff --git a/main/src/data/ivug-data-list.h b/main/src/data/ivug-data-list.h
new file mode 100755
index 0000000..59920b7
--- /dev/null
+++ b/main/src/data/ivug-data-list.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_DATA_LIST_H__
+#define __IVUG_DATA_LIST_H__
+
+#include "ivug-data-filter.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+Eina_List *ivug_list_load_items(List_Filter *filter, int stp, int endp);
+
+int ivug_list_get_item_cnt(List_Filter *filter);
+
+void ivug_list_delete_items(Eina_List *items);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/main/src/data/ivug-data-priv.h b/main/src/data/ivug-data-priv.h
new file mode 100755
index 0000000..eb10f3d
--- /dev/null
+++ b/main/src/data/ivug-data-priv.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_DATA_PRIV_H
+#define __IVUG_DATA_PRIV_H
+
+#include "ivug-data.h"
+#include "ivug-parameter.h"
+#include "ivug-data-filter.h"
+
+typedef struct {
+ Eina_List *header;
+
+ /* window loading setting */
+ int window_size;
+ int window_reload_offset;
+ int window_count;
+
+ int left_end;
+ int right_end;
+
+/*save bundle param*/
+ List_Filter *filter;
+
+ Eina_List *ss_shuffle_header;
+ Media_Item *ss_shuffle_current;
+ Media_Item *ss_shuffle_end;
+
+} _Media_List;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+Eina_List *
+_ivug_data_create_window_size_list(Media_List *mList, int start_index, int total_count);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __IVUG_DATA_PRIV_H
+
diff --git a/main/src/data/ivug-data-shuffle.c b/main/src/data/ivug-data-shuffle.c
new file mode 100755
index 0000000..fa4d07d
--- /dev/null
+++ b/main/src/data/ivug-data-shuffle.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-data.h"
+#include "ivug-data-priv.h"
+#include "ivug-data-shuffle.h"
+
+static void _swap_eina_list(Eina_List* list, int i, int j)
+{
+ Eina_List *first;
+ Eina_List *second;
+ int temp;
+
+ if ( i == j ) return ;
+
+ first = eina_list_nth_list(list, i);
+ second = eina_list_nth_list(list, j);
+
+ temp = (int)(first->data);
+ first->data = second->data;
+ second->data = (void *)temp;
+}
+
+void _shuffle_eina_list(Eina_List *list, int count)
+{
+ int i;
+ int r;
+
+ IV_ASSERT(list != NULL);
+
+ srand((unsigned)time(NULL));
+
+ for(i=0; i<count; i++)
+ {
+ r = rand()%count;
+ //MSG_UTIL_HIGH("rand = %d", r);
+ _swap_eina_list(list, i, r);
+ }
+}
+
+static Eina_List *_create_eina_list(int count)
+{
+ int i;
+
+ Eina_List *list = NULL;
+
+ for(i=1; i <= count; i++) /* 1 ~ total count */
+ {
+ list = eina_list_append(list, (void *)i);
+ }
+
+ _shuffle_eina_list(list, count);
+
+ return list;
+}
+
+
+bool ivug_data_init_shuffle_slide_show(Media_List *mList, slide_show_mode ss_mode, int cur_index, int total_count)
+{
+ IV_ASSERT(mList != NULL);
+
+ Eina_List *item = NULL;
+ _Media_List *_mList = (_Media_List *)mList;
+
+ if(total_count == 1 && !(ss_mode & SLIDE_SHOW_MODE_REPEAT))
+ {
+ return false;
+ }
+
+ item = eina_list_data_find_list(_mList->ss_shuffle_header, (void * )cur_index);
+ if(item == NULL)
+ {
+ MSG_SDATA_ERROR("Can't find cur index item %d", cur_index);
+ item = _mList->ss_shuffle_header;
+ }
+ _mList->ss_shuffle_end = item;
+ _mList->ss_shuffle_current = eina_list_next(item);
+
+ if( _mList->ss_shuffle_current == NULL)
+ {
+ _mList->ss_shuffle_current = _mList->ss_shuffle_header; /* back to first */
+ }
+
+ return true;
+}
+
+void ivug_data_deinit_shuffle_slide_show(Media_List *mList, int total_count)
+{
+ IV_ASSERT(mList != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ _mList->ss_shuffle_end = NULL;
+ _mList->ss_shuffle_current = NULL;
+
+ _shuffle_eina_list(_mList->ss_shuffle_header, total_count);
+}
+
+void ivug_data_create_shuffled_list(Media_List *mList, int total_count)
+{
+ _Media_List *_mList = (_Media_List *)mList;
+
+ _mList->ss_shuffle_header = _create_eina_list(total_count);
+ _shuffle_eina_list(_mList->ss_shuffle_header, total_count); // Shuffle
+
+}
+
+int ivug_data_get_next_slide_show_index(Media_List *mList, slide_show_mode ss_mode, int next_index, int total_count, bool increase_flag)
+{
+ IV_ASSERT(mList != NULL);
+ _Media_List *_mList = (_Media_List *)mList;
+ int index = -1;
+ Eina_List *item = NULL;
+ Eina_List *list = NULL;
+
+ if(ss_mode & SLIDE_SHOW_MODE_SHUFFLE)
+ {
+ item = _mList->ss_shuffle_current;
+
+ list = eina_list_next(item);
+ if ( list == NULL)
+ {
+ list = _mList->ss_shuffle_header; /* back to start */
+ }
+ if(list == _mList->ss_shuffle_end && !(ss_mode & SLIDE_SHOW_MODE_REPEAT))
+ {
+ if(increase_flag == true)
+ {
+ _mList->ss_shuffle_current = NULL;
+ }
+ return -1;
+ }
+ if(increase_flag == true)
+ {
+ _mList->ss_shuffle_current = list;
+ }
+ index = (int)eina_list_data_get(list);
+ }
+ else
+ {
+ index = next_index + 1;
+ if(index > total_count && (ss_mode & SLIDE_SHOW_MODE_REPEAT) )
+ {
+ index = 1; /* back to start */
+ }
+ }
+ return index;
+}
+
+Media_Item * ivug_data_get_current_slide_show_item(Media_List *mList, slide_show_mode ss_mode, int cur_index, int *next_index, int total_count)
+{
+ IV_ASSERT(mList != NULL);
+
+ Eina_List *item = NULL;
+ int index;
+ Media_Item *slide_show_item = NULL;
+ _Media_List *_mList = (_Media_List *)mList;
+
+ if(ss_mode & SLIDE_SHOW_MODE_SHUFFLE)
+ {
+ item = _mList->ss_shuffle_current;
+
+ index = (int)eina_list_data_get(item);
+ }
+ else
+ {
+ index = cur_index + 1;
+ if(index > total_count && (ss_mode & SLIDE_SHOW_MODE_REPEAT) )
+ {
+ index = 1; /* back to start */
+ }
+ }
+ MSG_SDATA_HIGH("*******current shuffle index is %d", index);
+
+ slide_show_item = _ivug_data_create_window_size_list(mList, index, total_count);
+ if(slide_show_item == NULL)
+ {
+ MSG_SDATA_HIGH("*******current shuffle item is NULL");
+ return NULL;
+ }
+ *next_index = index;
+
+ return slide_show_item;
+}
+
+Media_Item * ivug_data_set_next_slide_show_item(Media_List *mList, slide_show_mode ss_mode, int *next_index, int total_count)
+{
+ IV_ASSERT(mList != NULL);
+
+ int index;
+ Media_Item *slide_show_item = NULL;
+
+ index = ivug_data_get_next_slide_show_index(mList, ss_mode, *next_index, total_count, false);
+ if(index < 0)
+ {
+ MSG_SDATA_HIGH("*******Next slide show item is NULL");
+ return NULL;
+ }
+
+ MSG_SDATA_HIGH("*******Next slide show index is %d", index);
+
+ slide_show_item = _ivug_data_create_window_size_list(mList, index, total_count);
+ if(slide_show_item == NULL)
+ {
+ MSG_SDATA_HIGH("*******Next slide show item is NULL");
+ return NULL;
+ }
+ ivug_data_append_media_item(mList, slide_show_item);
+
+ return slide_show_item;
+}
+
+
+Media_Item *
+ivug_data_get_next_shuffle_item(Media_List *mList)
+{
+ IV_ASSERT(mList != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ return _mList->ss_shuffle_current; // current is set at next slide
+}
+
diff --git a/main/src/data/ivug-data-shuffle.h b/main/src/data/ivug-data-shuffle.h
new file mode 100755
index 0000000..c478443
--- /dev/null
+++ b/main/src/data/ivug-data-shuffle.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_DATA_SHUFFLER_H__
+#define __IVUG_DATA_SHUFFLER_H__
+
+#include "ivug-config.h"
+#include "ivug-data.h"
+
+typedef struct {
+ Eina_List *ss_shuffle_header;
+ Eina_List *ss_shuffle_current;
+ Eina_List *ss_shuffle_end;
+} SlideShow_List;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool ivug_data_init_shuffle_slide_show(Media_List *mList, slide_show_mode ss_mode, int cur_index, int total_count);
+
+void ivug_data_deinit_shuffle_slide_show(Media_List *mList, int total_count);
+
+Media_Item * ivug_data_get_current_slide_show_item(Media_List *mList, slide_show_mode ss_mode, int cur_index, int *next_index, int total_count);
+
+Media_Item * ivug_data_set_next_slide_show_item(Media_List *mList, slide_show_mode ss_mode, int *cur_index, int total_count);
+
+Media_Item * ivug_data_get_next_shuffle_item(Media_List *mList);
+
+int ivug_data_get_next_slide_show_index(Media_List *mList, slide_show_mode ss_mode, int cur_index, int total_count, bool increase_flag);
+
+void ivug_data_create_shuffled_list(Media_List *mList, int total_count);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __IVUG_DATA_SHUFFLER_H__
+
diff --git a/main/src/data/ivug-data.c b/main/src/data/ivug-data.c
new file mode 100755
index 0000000..4e05214
--- /dev/null
+++ b/main/src/data/ivug-data.c
@@ -0,0 +1,683 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-main.h"
+#include "ivug-common.h"
+
+#include "ivug-data.h"
+#include "ivug-util.h"
+#include "ivug-data-priv.h"
+#include "ivug-data-list.h"
+#include "ivug-data-filter.h"
+
+
+#include <media-svc.h>
+
+static bool
+_ivug_data_set_window_section(Media_List *mList, int start_index, int total_count, int *stp, int *endp)
+{
+ IV_ASSERT(mList != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ //if(total_count > _mList->window_size && start_index > 0) // TODO : IV_ASSERT(start_index > 0); after fix gallery
+ if(start_index > 0 && total_count > 0 && start_index <= total_count) // TODO : IV_ASSERT(start_index > 0); after fix gallery
+ {
+ *stp = (start_index-1) - (_mList->window_size/2);
+ if(*stp < 0)
+ {
+ *stp = 0;
+ }
+ *endp = (start_index-1) + (_mList->window_size/2);
+ if(*endp > total_count-1)
+ {
+ *endp = total_count-1;
+ }
+ if(_mList->window_count > 0)
+ {
+ if(*stp < _mList->left_end) /* load left window */
+ {
+ if(*endp > _mList->left_end-1)
+ {
+ *endp = _mList->left_end -1;
+ }
+ _mList->left_end = *stp;
+ }
+ if(*endp > _mList->right_end) /* load right window */
+ {
+ if(*stp < _mList->right_end+1)
+ {
+ *stp = _mList->right_end +1;
+ }
+ _mList->right_end = *endp;
+ }
+ }
+ else // first window loding
+ {
+ MSG_SDATA_HIGH("First window loading");
+ _mList->left_end = *stp;
+ _mList->right_end = *endp;
+ _mList->window_count++;
+ }
+ MSG_SDATA_HIGH("Window loading [%d~%d]", *stp, *endp);
+
+ MSG_SDATA_HIGH("true : _mlist [%d~%d]", _mList->left_end, _mList->right_end);
+ return true;
+ }
+ else
+ {
+ if(_mList->window_count == 0)
+ {
+ MSG_SDATA_HIGH("Entire loading");
+ _mList->left_end = 0;
+ _mList->right_end = total_count-1;
+ }
+ MSG_SDATA_HIGH("false : _mlist [%d~%d]", _mList->left_end, _mList->right_end);
+ return false;
+ }
+}
+
+
+static bool
+_ivug_data_add_media_item(Eina_List **list, const char *filepath)
+{
+ IV_ASSERT(list != NULL);
+
+ int ret = 0;
+ Mitem* item = NULL;
+
+ if (ivug_is_web_uri(filepath) == false)
+ { //local file.
+ ret = minfo_get_item(gGetMediaSVCHandle(), filepath, &item); //get cluster id
+ if (ret != MB_SVC_ERROR_NONE)
+ {
+ MSG_SDATA_ERROR("Cannot find file in media db for %s", filepath);
+ }
+ }
+
+ Media_Data* mdata = NULL;
+
+ if (item != NULL)
+ {
+ mdata = ivug_alloc_mediadata_from_mitem(item);
+ minfo_destroy_mtype_item(item);
+ }
+ else
+ {
+ mdata = ivug_alloc_mediadata_from_filepath(filepath);
+ }
+
+ if ( mdata == NULL )
+ {
+ MSG_SDATA_ERROR("Cannot create slide data for %s", filepath);
+ return false;
+ }
+
+ *list = eina_list_append(*list, mdata);
+
+ return true;
+
+}
+
+Eina_List *_ivug_data_create_window_size_list(Media_List *mList, int start_index, int total_count)
+{
+ IV_ASSERT(mList != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+ Eina_List* slide_list = NULL;
+
+ MSG_SDATA_HIGH("start index is %d", start_index);
+
+ if(start_index < 1 || start_index > total_count)
+ {
+ MSG_SDATA_ERROR("start index is invalid %d", start_index);
+ return NULL;
+ }
+
+// Eina_List *ivug_list_load_items(List_Filter *filter, int stp, int endp);
+
+ int stp = 0, endp = 0;
+
+ _ivug_data_set_window_section(mList, start_index, total_count, &stp, &endp);
+
+ slide_list = ivug_list_load_items(_mList->filter, stp, endp);
+
+ if(slide_list == NULL)
+ {
+ MSG_SDATA_ERROR("Create list ERROR");
+ return NULL;
+ }
+
+ return slide_list;
+}
+
+static Media_Item *
+_ivug_data_create_list(Media_List *mList, Eina_List **list, const char *filepath, int *start_index, int *total_count)
+{
+ IV_ASSERT(mList != NULL);
+ IV_ASSERT(filepath != NULL);
+
+ MSG_SDATA_HIGH("Creating slide data list");
+
+ _Media_List *_mList = (_Media_List *)mList;
+ Media_Item *item = NULL;
+
+ *total_count = -1;
+
+ if(_mList->filter->view_by == IVUG_VIEW_BY_FILE)
+ {
+ if (filepath == NULL)
+ {
+ MSG_SDATA_ERROR("file path is NULL");
+ return NULL;
+ }
+
+ // No need to create list. just one file only.
+ if ( _ivug_data_add_media_item(list, filepath) == false)
+ {
+ MSG_SDATA_ERROR("Cannot add file : %s", filepath);
+ return NULL;
+ }
+ *total_count = 1;
+ item = *list;
+ return item;
+ }
+ else
+ {
+ *total_count = ivug_list_get_item_cnt(_mList->filter);
+
+ *list = _ivug_data_create_window_size_list(mList, *start_index, *total_count);
+ }
+
+ if(*list == NULL)
+ {
+ MSG_SDATA_ERROR("list is NULL");
+ return NULL;
+ }
+
+ if(*total_count == 1)
+ {
+ item = *list;
+ *start_index = 1;
+ return item;
+ }
+ else if(*start_index > 0 && *start_index <= *total_count)
+ {
+ item = eina_list_nth_list(*list, (*start_index-1)-_mList->left_end);
+ }
+
+ Media_Data *mdata = NULL;
+ bool find = false;
+ int index = 0;
+
+ if(item != NULL)
+ {
+ MSG_SDATA_HIGH("start index exist");
+ mdata = ivug_data_get_data(item);
+
+ if(mdata != NULL)
+ {
+ if ((mdata)->filepath)
+ {
+ if(strncmp(filepath, mdata->filepath, strlen(filepath)) == 0)
+ {
+ MSG_SLIDER_HIGH("Founded Filepath=%s Index=%d", ivug_get_filename(mdata->filepath), *start_index);
+ index = *start_index; // recieve from bundle
+ find = true;
+ }
+ }
+ if (find == false && mdata->fileurl)
+ {
+ if (strncmp(filepath, mdata->fileurl, strlen(filepath)) == 0) //match
+ {
+ MSG_SLIDER_HIGH("Founded Fileurl=%s Index=%d", ivug_get_filename(mdata->fileurl), *start_index);
+ index = *start_index; // recieve from bundle
+ find = true;
+ }
+ }
+ if(find == false)
+ {
+ MSG_SLIDER_WARN("param index is not match to real index");
+ }
+ }
+ }
+ //check indexed item
+ if(item == NULL || find == false) // start index is not exist || can't find filename at window list
+ {
+ item = ivug_data_find_item(*list, filepath, &index);
+
+ if (item == NULL)
+ {
+ // TODO : find file at whole file list
+ MSG_SLIDER_ERROR("Item is not found for file %s", filepath);
+ return NULL;
+ }
+ }
+ *start_index = index;
+ MSG_SDATA_HIGH("Create slide data list END");
+ return item;
+}
+
+Media_List *ivug_data_init_media_list(const ivug_parameter *param)
+{
+ _Media_List *_mList = calloc(1, sizeof(_Media_List));
+ IV_ASSERT(_mList != NULL);
+
+ _mList->window_size = IV_WINDOW_SIZE;
+ _mList->window_reload_offset = IV_RELOAD_OFFSET;
+ _mList->window_count = 0;
+ _mList->left_end = 0;
+
+ _mList->filter = ivug_data_filter_create(param);
+
+ return (Media_List *)_mList;
+}
+
+Media_Item *
+ivug_data_create_media_list_from_param
+ (Media_List *mList, Eina_List **list, const char *filepath, int *start_index, int *total_count)
+{
+ IV_ASSERT(mList != NULL);
+
+ MSG_SDATA_HIGH("Creating slide data list");
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ if(list == NULL)
+ {
+ return _ivug_data_create_list(mList, &(_mList->header), filepath, start_index, total_count);
+ }
+ else
+ {
+ return _ivug_data_create_list(mList, list, filepath, start_index, total_count);
+ }
+}
+
+bool ivug_data_set_window_size(Media_List *mList, int size)
+{
+ _Media_List *_mList = (_Media_List *)mList;
+
+ if(size < 1)
+ {
+ MSG_SDATA_ERROR("Set window size error, size = %d", size);
+ _mList->window_size = 0;
+ return false;
+ }
+
+ _mList->window_size = size;
+ return true;
+}
+
+void ivug_data_reset_window_load_count(Media_List *mList)
+{
+ _Media_List *_mList = (_Media_List *)mList;
+
+ _mList->window_count = 0;
+}
+
+void
+ivug_data_delete_media_list(Media_List *mList)
+{
+ IV_ASSERT(mList != NULL);
+ _Media_List *_mList = (_Media_List *)mList;
+
+ MSG_SDATA_HIGH("Removing all media data");
+
+ ivug_list_delete_items(_mList->header);
+
+ ivug_data_filter_delete(_mList->filter);
+
+ free(_mList);
+}
+
+
+
+#ifdef TRACE_CALLER
+Media_Data *
+dbg_ivug_data_get_data(Media_Item *media_item, const char *func, unsigned int line)
+#else
+Media_Data *
+ivug_data_get_data(Media_Item *media_item)
+#endif // TRACE_CALLER
+{
+#ifdef TRACE_CALLER
+ MSG_SDATA_HIGH("Called by %s(%d) Item=0x%08x", func, line, media_item);
+#endif
+ IV_ASSERT(media_item != NULL);
+
+ Eina_List *item = media_item;
+
+ return eina_list_data_get(item);
+
+}
+
+Media_Item *
+ivug_data_get_first(Media_List *mList)
+{
+ IV_ASSERT(mList != NULL);
+ _Media_List *_mList = (_Media_List *)mList;
+
+ return (Media_Item *)_mList->header;
+}
+
+
+Media_Item *
+ivug_data_get_next(Media_Item *media_item)
+{
+ IV_ASSERT(media_item != NULL);
+
+ Eina_List *item = media_item;
+
+ Eina_List *list;
+
+ list = eina_list_next(item);
+
+ if ( list == NULL )
+ {
+ MSG_SDATA_ERROR("Next item is NULL");
+ return NULL;
+ }
+
+ return list;
+}
+
+Media_Item *
+ivug_data_get_prev(Media_Item *media_item)
+{
+ IV_ASSERT(media_item != NULL);
+
+ Eina_List *item = media_item;
+
+ Eina_List *list;
+
+ list = eina_list_prev(item);
+
+ if ( list == NULL )
+ {
+ MSG_SDATA_ERROR("Prev item is NULL");
+ return NULL;
+ }
+
+ return list;
+}
+
+Media_Item *
+ivug_data_find_item(Eina_List *list, const char* fileuri, int /*OUT*/ *index)
+{
+ IV_ASSERT(list != NULL);
+ IV_ASSERT(fileuri != NULL);
+
+ Eina_List *item;
+ Media_Data* mdata;
+
+ unsigned int i = 1;
+
+ EINA_LIST_FOREACH(list, item, mdata)
+ {
+ if(mdata == NULL)
+ {
+ MSG_SDATA_FATAL("sdata cannot be NULL");
+ return NULL;
+ }
+
+ if (mdata->filepath)
+ {
+ if (strncmp(mdata->filepath, fileuri, strlen(mdata->filepath)) == 0) //match
+ {
+ MSG_SDATA_HIGH("Founded Filepath=%s Index=%d", ivug_get_filename(mdata->filepath), i);
+ *index = i;
+ return item;
+ }
+ }
+
+ if (mdata->fileurl)
+ {
+ if (strncmp(mdata->fileurl, fileuri, strlen(mdata->fileurl)) == 0) //match
+ {
+ MSG_SDATA_HIGH("Founded Fileuri=%s Index=%d", mdata->fileurl, i);
+ *index = i;
+ return item;
+ }
+ }
+ i++;
+ }
+
+ *index = 0;
+ return NULL;
+}
+
+
+bool
+ivug_data_delete_media_item(Media_List *mList, Media_Item *media_item)
+{
+ IV_ASSERT(mList != NULL);
+ IV_ASSERT(media_item != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ int ret;
+
+ Media_Data* mdata;
+
+ mdata = (Media_Data*)eina_list_data_get(media_item);
+
+ IV_ASSERT(mdata != NULL);
+
+ if (uuid_is_valid(mdata->mediaID) == true)
+ {
+ ret = minfo_delete_media_id(gGetMediaSVCHandle(), mdata->mediaID);
+
+ if (ret == MB_SVC_ERROR_NONE)
+ {
+ if (mdata->filepath)
+ {
+ if(ivug_remove_file(mdata->filepath) == false)
+ {
+ MSG_SDATA_ERROR("unlink error , file path =%s", mdata->filepath);
+ }
+ }
+ }
+ else
+ {
+ MSG_SDATA_ERROR("minfo_delete_media_id faild=%d uuid=%s file=%s", ret, uuid_getchar(mdata->mediaID), mdata->filepath);
+ goto ERROR;
+ }
+
+ }
+ else
+ {
+ if (mdata->filepath)
+ {
+ if(ivug_remove_file(mdata->filepath) == false)
+ {
+ MSG_SDATA_ERROR("file remove error , file path =%s", mdata->filepath);
+ }
+ }
+ else
+ {
+ MSG_SDATA_ERROR("delete faild file path is NULL");
+ goto ERROR;
+ }
+
+ }
+
+// TODO : Handle when current is deleted
+ ivug_free_mediadata(mdata); // Free data
+
+ _mList->header = eina_list_remove_list(_mList->header, media_item);
+ _mList->right_end--;
+
+ return true;
+
+ERROR:
+ ivug_free_mediadata(mdata); // Free data
+ _mList->header = eina_list_remove_list(_mList->header, media_item);
+ _mList->right_end--;
+
+ MSG_SDATA_ERROR("ivug_data_delete_slide faild.");
+ return false;
+
+}
+
+/* it delete start ~ end item */
+/* if end is null, it delete until last */
+bool
+ivug_data_delete_window_list(Media_List *mList, Media_Item *start_item, Media_Item *end_item)
+{
+ IV_ASSERT(mList != NULL);
+ IV_ASSERT(start_item != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ Media_Item *current = start_item;
+ Media_Item *next = NULL;
+
+ Media_Data* mdata;
+
+ do
+ {
+ MSG_SDATA_HIGH("delete window list");
+ next = eina_list_next(current);
+
+ mdata = (Media_Data*)eina_list_data_get(current);
+ ivug_free_mediadata(mdata); // Free data
+ _mList->header = eina_list_remove_list(_mList->header, current);
+ if(end_item == NULL) /* delete right window */
+ {
+ /* TODO : _mList->right_end--; */
+ }
+ else /* delete left window */
+ {
+ /* TODO : _mList->left_end++; */
+ }
+ current = next;
+ }while(current && current != end_item);
+
+ if(current) /* delete end item */
+ {
+ mdata = (Media_Data*)eina_list_data_get(current);
+ ivug_free_mediadata(mdata); // Free data
+ _mList->header = eina_list_remove_list(_mList->header, current);
+ _mList->left_end++; /* this case is delete left window */
+ }
+
+ _mList->window_count--;
+
+ return true;
+}
+
+
+void
+ivug_data_delete_all_window_list(Media_List *mList)
+{
+ _Media_List *_mList = (_Media_List *)mList;
+
+ ivug_data_delete_window_list(mList, _mList->header, NULL);
+}
+
+
+void ivug_data_append_media_item(Media_List *mList, Eina_List* list)
+{
+ IV_ASSERT(mList != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ MSG_SDATA_HIGH("original : slide_list_count is %d", eina_list_count(_mList->header));
+ if(_mList->window_count > 3)
+ {
+ /* TODO : delete window item */
+ //ivug_data_delete_window_list(mList, _mList->header, _mList->contact_point);
+ MSG_SDATA_HIGH("after delete : slide_list_count is %d", eina_list_count(_mList->header));
+ }
+ //_mList->contact_point = eina_list_last(_mList->header);
+
+ _mList->header = eina_list_merge(_mList->header, list);
+ MSG_SDATA_HIGH("merge next : slide_list_count is %d", eina_list_count(_mList->header));
+
+ _mList->window_count++;
+}
+
+void ivug_data_prepend_media_item(Media_List *mList, Eina_List* list)
+{
+ IV_ASSERT(mList != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ MSG_SDATA_HIGH("original : slide_list_count is %d", eina_list_count(_mList->header));
+ if(_mList->window_count > 3)
+ {
+ /* TODO : delete window item */
+ //ivug_data_delete_window_list(mList, _mList->contact_point, NULL);
+ MSG_SDATA_HIGH("after delete : slide_list_count is %d", eina_list_count(_mList->header));
+ }
+ //_mList->contact_point = _mList->header;
+
+ _mList->header = eina_list_merge(list, _mList->header);
+ MSG_SDATA_HIGH("merge prev : slide_list_count is %d", eina_list_count(_mList->header));
+
+ _mList->window_count++;
+}
+
+
+Load_State
+ivug_data_set_window_loading(Media_List *mList, int cur_index, int total_count)
+{
+ Eina_List* slide_list_prev = NULL;
+ Eina_List* slide_list_next = NULL;
+ int start = -1;
+
+ IV_ASSERT(mList != NULL);
+
+ _Media_List *_mList = (_Media_List *)mList;
+
+ /* load right widow */
+ if(_mList->right_end < total_count-1 && cur_index-1 > _mList->right_end - _mList->window_reload_offset)
+ {
+ /* start index is basis for view's index(1~total) because +1 needed */
+ start = (_mList->right_end+1) + (_mList->window_size/2+1);
+ if(start > total_count) // index is 1~total
+ {
+ start = total_count;
+ }
+ MSG_SDATA_HIGH("start = %d, _mList->right_end = %d", start, _mList->right_end);
+ slide_list_next = _ivug_data_create_window_size_list(mList, start, total_count);
+ if(slide_list_next != NULL)
+ {
+ ivug_data_append_media_item(mList, slide_list_next);
+ return IVUG_SLIDER_LOADED_RIGHT;
+ }
+ }
+ /* load left widow */
+ else if(_mList->left_end > 0 && cur_index-1 < _mList->left_end + _mList->window_reload_offset)
+ {
+ /* start index is basis for view's index(1~total) because +1 needed */
+ start = (_mList->left_end+1) - (_mList->window_size/2+1);
+ if(start < 1) // index is 1~total
+ {
+ start = 1;
+ }
+ MSG_SDATA_HIGH("start = %d, _mList->left_end = %d", start, _mList->left_end);
+ slide_list_prev = _ivug_data_create_window_size_list(mList, start, total_count);
+ if(slide_list_prev != NULL)
+ {
+ ivug_data_prepend_media_item(mList, slide_list_prev);
+ return IVUG_SLIDER_LOADED_LEFT;
+ }
+ }
+ return IVUG_SLIDER_LOADED_NONE;
+}
+
diff --git a/main/src/data/ivug-data.h b/main/src/data/ivug-data.h
new file mode 100755
index 0000000..2dd9965
--- /dev/null
+++ b/main/src/data/ivug-data.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_DATA_H__
+#define __IVUG_DATA_H__
+
+#include "ivug-common.h"
+#include "ivug-parameter.h"
+#include "ivug-mediadata.h"
+
+
+typedef enum {
+ IVUG_SLIDER_LOADED_NONE = 0x00, /* default value */
+ IVUG_SLIDER_LOADED_LEFT,
+ IVUG_SLIDER_LOADED_RIGHT,
+ IVUG_SLIDER_LOADED_STATUS_MAX,
+} Load_State;
+
+
+/* Opaque pointer for media list. */
+typedef void *Media_List;
+typedef Eina_List Media_Item; // Same as Eina_List
+
+#undef TRACE_CALLER
+
+bool
+ivug_data_set_window_size(Media_List *mList, int size);
+
+Load_State
+ivug_data_set_window_loading(Media_List *mList, int cur_index, int total_count);
+
+void ivug_data_reset_window_load_count(Media_List *mList);
+
+Media_List * ivug_data_init_media_list(const ivug_parameter *param);
+
+Media_Item *
+ivug_data_create_media_list_from_param(Media_List *mList, Eina_List **list, const char *filepath, int *start_index, int *total_count);
+
+void
+ivug_data_delete_media_list(Media_List *mList);
+
+void
+ivug_data_delete_all_window_list(Media_List *mList);
+
+Media_Item *
+ivug_data_get_first(Media_List *mList);
+
+Media_Item *
+ivug_data_get_prev(Media_Item *media_item);
+
+Media_Item *
+ivug_data_get_next(Media_Item *media_item);
+
+#ifdef TRACE_CALLER
+#define ivug_data_get_data(media_item) dbg_ivug_data_get_data(media_item , __func__, __LINE__)
+
+Media_Data *
+dbg_ivug_data_get_data(Media_Item *media_item, const char *func, unsigned int line);
+#else
+Media_Data *
+ivug_data_get_data(Media_Item *media_item);
+#endif
+
+void ivug_data_append_media_item(Media_List *mList, Eina_List* list);
+
+bool ivug_data_delete_media_item(Media_List *mList, Media_Item *media_item);
+
+Media_Item * ivug_data_find_item(Eina_List *list, const char* fileuri, int /*OUT*/ *index);
+
+#endif //__IVUG_DATA_H__
+
diff --git a/main/src/data/ivug-mediadata.c b/main/src/data/ivug-mediadata.c
new file mode 100755
index 0000000..b46a5da
--- /dev/null
+++ b/main/src/data/ivug-mediadata.c
@@ -0,0 +1,301 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-main.h"
+#include "ivug-common.h"
+#include <media-svc.h>
+#include "ivug-mediadata.h"
+#include "ivug-file-info.h"
+
+Media_Data *ivug_alloc_mediadata_from_mitem(Mitem * item)
+{
+ IV_ASSERT(item != NULL);
+ IV_ASSERT(item->file_url != NULL);
+ Media_Data * mdata = NULL;
+ mdata = (Media_Data *) calloc(1, sizeof(Media_Data));
+ if (mdata == NULL)
+ {
+ MSG_SDATA_ERROR("Cannot allocate memory");
+ return NULL;
+ }
+
+ mdata->mediaID = uuid_assign(item->uuid);
+
+ //file url
+ mdata->fileurl = strdup(item->file_url);
+ if (mdata->fileurl == NULL)
+ {
+ MSG_SDATA_ERROR("strdup return NULL");
+ free(mdata);
+ return NULL;
+ }
+
+ if (item->type == MINFO_ITEM_IMAGE)
+ {
+ //check file path.
+ MSG_SDATA_HIGH("Local image : %s. %s", uuid_getchar( mdata->mediaID ), mdata->fileurl);
+
+ mdata->thumbnail_path = NULL;
+
+ mdata->slide_type = SLIDE_TYPE_IMAGE;
+ mdata->filepath = strdup(mdata->fileurl);
+ if (mdata->filepath == NULL)
+ {
+ free(mdata->fileurl);
+ MSG_SDATA_ERROR("strdup return NULL");
+ free(mdata);
+ return NULL;
+ }
+ }
+ else if (item->type == MINFO_ITEM_VIDEO)
+ {
+ MSG_SDATA_HIGH("Local video : %s. %s", uuid_getchar(mdata->mediaID), mdata->fileurl);
+
+ if (item->thumb_url)
+ {
+ mdata->thumbnail_path = strdup(item->thumb_url); //thumbnail address
+ if (mdata->thumbnail_path == NULL)
+ {
+ free(mdata->fileurl);
+ MSG_SDATA_ERROR("strdup return NULL");
+ free(mdata);
+ return NULL;
+ }
+ }
+
+ mdata->slide_type = SLIDE_TYPE_VIDEO;
+ mdata->filepath = strdup(mdata->fileurl);
+ if (mdata->filepath == NULL)
+ {
+ free(mdata->fileurl);
+ if (mdata->thumbnail_path)
+ {
+ free(mdata->thumbnail_path);
+ }
+ MSG_SDATA_ERROR("strdup return NULL");
+ free(mdata);
+ return NULL;
+ }
+ }
+ return mdata;
+}
+
+Media_Data *ivug_alloc_mediadata_from_filepath(const char *filepath)
+{
+ IV_ASSERT(filepath != NULL);
+
+
+ // No need to create list. just one file only.
+ Mitem * item = NULL;
+ if (ivug_is_web_uri(filepath) == false)
+ {
+
+ //local file.
+ int ret = MB_SVC_ERROR_NONE;
+ ret = minfo_get_item(gGetMediaSVCHandle(), filepath, &item); //get cluster id
+ if (ret != MB_SVC_ERROR_NONE)
+ {
+ MSG_SDATA_ERROR("Cannot find file in media db for %s",filepath);
+ // Go through
+ }
+ }
+
+ Media_Data * mdata = NULL;
+ if (item != NULL)
+ {
+ MSG_SDATA_HIGH("File path is given. but founded in DB.");
+ mdata = ivug_alloc_mediadata_from_mitem(item);
+ minfo_destroy_mtype_item(item);
+ if (mdata == NULL)
+ {
+ MSG_SDATA_ERROR("Cannot add file : %s", filepath);
+ return NULL;
+ }
+ return mdata;
+ }
+ mdata = (Media_Data *) calloc(1, sizeof(Media_Data));
+ if (mdata == NULL)
+ {
+ MSG_SDATA_ERROR("Cannot allocate memory");
+ return NULL;
+ }
+ mdata->mediaID = INVALID_UUID; //copy id mitem
+
+ char *mime_type = NULL;
+ mime_type = ivug_fileinfo_get_mime_type(filepath);
+ if (mime_type == NULL)
+ {
+ MSG_SDATA_WARN("file path is not vaild = %s", filepath);
+ mdata->slide_type = SLIDE_TYPE_UNKNOWN;
+ mdata->fileurl = NULL;
+ mdata->filepath = NULL;
+ return mdata;
+ }
+
+
+ Media_Type slide_type = SLIDE_TYPE_NONE;
+
+ //image
+ if (strncmp(mime_type, "image/", strlen("image/")) == 0)
+ {
+ slide_type = SLIDE_TYPE_IMAGE;
+ }
+ else if (strncmp(mime_type, "video/", strlen("video/")) == 0)
+ {
+ slide_type = SLIDE_TYPE_VIDEO;
+ }
+ else
+ {
+ slide_type = SLIDE_TYPE_NONE;
+ }
+ MSG_SDATA_HIGH("File=%s Mime=%s", filepath, mime_type);
+ free(mime_type); //free strdup
+
+ mdata->thumbnail_path = NULL;
+
+ if (slide_type == SLIDE_TYPE_IMAGE)
+ {
+ mdata->slide_type = SLIDE_TYPE_IMAGE;
+ mdata->fileurl = strdup(filepath);
+ if (mdata->fileurl == NULL)
+ {
+ MSG_SDATA_ERROR("strdup return NULL");
+ goto ERROR;
+ }
+ mdata->filepath = strdup(filepath);
+ if (mdata->filepath == NULL)
+ {
+ MSG_SDATA_ERROR("strdup return NULL");
+ free(mdata->fileurl);
+ goto ERROR;
+ }
+ }
+ else if (slide_type == SLIDE_TYPE_VIDEO)
+ {
+ mdata->slide_type = SLIDE_TYPE_VIDEO;
+ mdata->fileurl = strdup(filepath);
+ if (mdata->fileurl == NULL)
+ {
+ MSG_SDATA_ERROR("strdup return NULL");
+ goto ERROR;
+ }
+ mdata->filepath = strdup(filepath);
+ if (mdata->filepath == NULL)
+ {
+ MSG_SDATA_ERROR("strdup return NULL");
+ free(mdata->fileurl);
+ goto ERROR;
+ }
+ }
+ else
+ {
+ MSG_SDATA_WARN("file path is not vaild = %s", filepath);
+ mdata->slide_type = SLIDE_TYPE_UNKNOWN;
+ mdata->fileurl = NULL;
+ mdata->filepath = NULL;
+ }
+ return mdata;
+ERROR:
+
+ if (mdata)
+ {
+ free(mdata);
+ }
+ return NULL;
+}
+
+void ivug_free_mediadata(Media_Data * mdata)
+{
+ IV_ASSERT(mdata != NULL);
+
+ uuid_free(mdata->mediaID);
+
+ //file path
+ if (mdata->filepath)
+ {
+ //IVUG_DEBUG_MSG("filepath =%s", sd->filepath);
+ free(mdata->filepath);
+ mdata->filepath = NULL;
+ }
+
+ //file url
+ if (mdata->fileurl)
+ {
+ MSG_SDATA_HIGH("Remove media data. %s", mdata->fileurl);
+ free(mdata->fileurl);
+ mdata->fileurl = NULL;
+ }
+
+ if (mdata->thumbnail_path)
+ {
+ free(mdata->thumbnail_path);
+ mdata->thumbnail_path = NULL;
+ }
+
+ free(mdata);
+}
+
+bool ivug_delete_mediadata(Media_Data * mdata)
+{
+ IV_ASSERT(mdata != NULL);
+
+ if (uuid_is_valid(mdata->mediaID) == true )
+ {
+ int ret = minfo_delete_media_id(gGetMediaSVCHandle(), mdata->mediaID);
+
+ if (ret == MB_SVC_ERROR_NONE)
+ {
+ if (mdata->filepath)
+ {
+ MSG_SDATA_HIGH("File removed. %s", mdata->filepath);
+ if (ivug_remove_file(mdata->filepath) == false)
+ {
+ MSG_SDATA_ERROR("file remove error : %s", mdata->filepath);
+ }
+ }
+ else
+ {
+ MSG_SDATA_ERROR("File path is NULL", mdata->filepath);
+ }
+ }
+ else
+ {
+ MSG_SDATA_ERROR("minfo_delete_media_id faild=%d uuid=%s file=%s", ret, uuid_getchar(mdata->mediaID), mdata->filepath);
+ return false;
+ }
+ }
+ else
+ {
+ if (mdata->filepath)
+ {
+ MSG_SDATA_HIGH("File removed. %s", mdata->filepath);
+
+ if (ivug_remove_file(mdata->filepath) == false)
+ {
+ MSG_SDATA_ERROR("file remove error : %s", mdata->filepath);
+ }
+ }
+ else
+ {
+ MSG_SDATA_ERROR("File path is NULL", mdata->filepath);
+ }
+
+ }
+
+ return true;
+}
+
diff --git a/main/src/data/ivug-mediadata.h b/main/src/data/ivug-mediadata.h
new file mode 100755
index 0000000..43b5e9e
--- /dev/null
+++ b/main/src/data/ivug-mediadata.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_MEDIADATA_H__
+#define __IVUG_MEDIADATA_H__
+
+#include <media-svc.h>
+#include <visual-svc.h> // Mitem
+
+//slide type
+typedef enum {
+ SLIDE_TYPE_NONE = 0x00,
+ SLIDE_TYPE_IMAGE,
+ SLIDE_TYPE_VIDEO,
+ SLIDE_TYPE_UNKNOWN, // File is exists but it's type is unknown.
+} Media_Type;
+
+/*
+ This struct represents data for slide.
+ thumbnail_path is slide's thumbnail image path.
+ fileurl is saved item in media service.
+ filepath is local file path. if fileurl is http://.../test.jpg, filepath is NULL, when complete download filepath change to saved local file path.
+*/
+typedef struct {
+//Data
+ Media_Type slide_type; //image, video
+
+ UUID mediaID; // Media ID
+
+ char* thumbnail_path; // thumbnail image file path.
+ char* fileurl; // file url.
+ char* filepath; // file path in local file system.
+} Media_Data;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Converting Media_Data from filepath
+ * @param filepath[in]
+ *
+**/
+Media_Data *ivug_alloc_mediadata_from_filepath(const char* filepath);
+
+/**
+ * Converting Mitem to Media_Data
+ * @param item[in]
+ *
+**/
+Media_Data *ivug_alloc_mediadata_from_mitem(Mitem* item);
+
+
+/**
+ * Free memory used by Media_Data
+ * @param mdata[in]
+ *
+**/
+void ivug_free_mediadata(Media_Data* mdata);
+
+/**
+ *
+ * Delete file indicated by @p mdata
+ *
+**/
+bool ivug_delete_mediadata(Media_Data* mdata);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __IVUG_MEDIADATA_H__ \ No newline at end of file
diff --git a/main/src/effect/include/ivug-anim.h b/main/src/effect/include/ivug-anim.h
new file mode 100755
index 0000000..cf7ddfa
--- /dev/null
+++ b/main/src/effect/include/ivug-anim.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_ANIM_H__
+#define __IVUG_ANIM_H__
+
+#include <stdbool.h>
+
+typedef enum {
+ ANIM_TYPE_LINEAR,
+ ANIM_TYPE_QUARTIC_INOUT,
+ ANIM_TYPE_QUINTIC_INOUT,
+ ANIM_TYPE_SINE,
+} anim_type_t;
+
+/*
+ t: current time b: start time c: change in value d: duration
+*/
+typedef double (*anim_transit_func_t) (double t, double b, double c, double d);
+
+typedef struct {
+/* private */
+ double duration;
+ double t_start;
+ double t_varing;
+
+ anim_transit_func_t transit_func;
+
+ void *user_data;
+} anim_handle_t;
+
+anim_handle_t *create_animation();
+
+void delete_animation(anim_handle_t *anim);
+
+bool update_animation(anim_handle_t *anim, double current, int *value);
+
+bool set_animation_type(anim_handle_t *anim, anim_type_t type);
+
+bool set_animation(anim_handle_t *anim, int start, int end, double duration);
+
+#endif
diff --git a/main/src/effect/include/ivug-effect.h b/main/src/effect/include/ivug-effect.h
new file mode 100755
index 0000000..7594c54
--- /dev/null
+++ b/main/src/effect/include/ivug-effect.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_EFFECT_H__
+#define __IVUG_EFFECT_H__
+
+#include <stdbool.h>
+#include <Elementary.h>
+#include "ivug-anim.h"
+
+#define EFFECT_LBYTES_ARGB8888(w) (((w) * 4))
+#define MAX_PERCENT (100.0f)
+#define MIN_PERCENT (0.0f)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *Effect_Data ;
+
+typedef void (*FuncFinished)(void *data);
+
+typedef struct {
+ Effect_Data eng_data;
+
+ FuncFinished pFinishedCB;
+ void *ClientData;
+
+ double t_base; // start time.
+ anim_handle_t *anim;
+ Ecore_Animator *animator;
+
+ struct {
+ Effect_Data (*init) (Evas_Object *src, Evas_Object *dst, int screen_w, int screen_h, int rotation);
+ void (*animate) (Effect_Data data, double percent);
+ void (*pause) (Effect_Data data); /* Not used*/
+ void (*resume) (Effect_Data data); /* Not used*/
+ void (*finalize) (Effect_Data data);
+
+ double (*get_duration)(Effect_Data data);
+ } func;
+
+} Effect_Engine;
+
+typedef enum _Effect_Type {
+ EFFECT_NONE,
+ EFFECT_SLIDE,
+ EFFECT_MAX
+} Effect_Type;
+
+
+Effect_Engine *ivug_effect_add(Effect_Type type);
+
+bool ivug_effect_init(Effect_Engine *engine, Evas_Object *src, Evas_Object *dst, int w, int h, int rotation);
+bool ivug_effect_start(Effect_Engine *engine, FuncFinished pFunc, void *data);
+bool ivug_effect_pause(Effect_Engine *engine);
+bool ivug_effect_resume(Effect_Engine *engine);
+bool ivug_effect_finalize(Effect_Engine *engine);
+
+
+/*
+ Private function for adding effect. Do not use below functions directly..
+*/
+Effect_Engine *ivug_fade_add(void);
+Effect_Engine *ivug_iris_add(void);
+Effect_Engine *ivug_dissolve_add(void);
+Effect_Engine *ivug_blind_add(void);
+Effect_Engine *ivug_slide_add(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __IVUG_EFFECT_H__ */
diff --git a/main/src/effect/ivug-anim.c b/main/src/effect/ivug-anim.c
new file mode 100755
index 0000000..b12d1fb
--- /dev/null
+++ b/main/src/effect/ivug-anim.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stddef.h> /* for NULL */
+#include <memory.h>
+#include <stdlib.h>
+
+#include "ivug-common.h"
+
+#include "ivug-anim.h"
+
+/*
+ t: current time b: start time c: change in value d: duration
+*/
+static double _anim_linear(double t, double b, double c, double d)
+{
+ if(d != 0.0)
+ t /= d;
+ return b + c * (t);
+}
+
+static double _anim_sine(double t, double b, double c, double d)
+{
+/* TODO : Consider below table reconstruct. need only 0.0 ~ 1.0 range*/
+ static const double const SIN_TABLE[91] = {
+ 0.0000f, 0.0174f, 0.0349f, 0.0523f, 0.0698f,
+ 0.0872f, 0.1045f, 0.1219f, 0.1392f, 0.1564f,
+ 0.1736f, 0.1908f, 0.2079f, 0.2249f, 0.2419f,
+ 0.2588f, 0.2756f, 0.2924f, 0.3090f, 0.3256f,
+ 0.3420f, 0.3584f, 0.3746f, 0.3907f, 0.4067f,
+ 0.4226f, 0.4384f, 0.4540f, 0.4695f, 0.4848f,
+ 0.5000f, 0.5150f, 0.5299f, 0.5446f, 0.5592f,
+ 0.5736f, 0.5878f, 0.6018f, 0.6157f, 0.6293f,
+ 0.6528f, 0.6561f, 0.6691f, 0.6820f, 0.6947f,
+ 0.7071f, 0.7193f, 0.7314f, 0.7431f, 0.7547f,
+ 0.7660f, 0.7772f, 0.7880f, 0.7986f, 0.8090f,
+ 0.8191f, 0.8290f, 0.8387f, 0.8480f, 0.8571f,
+ 0.8660f, 0.8746f, 0.8829f, 0.8910f, 0.8988f,
+ 0.9063f, 0.9135f, 0.9205f, 0.9272f, 0.9336f,
+ 0.9397f, 0.9455f, 0.9511f, 0.9563f, 0.9613f,
+ 0.9659f, 0.9703f, 0.9744f, 0.9781f, 0.9816f,
+ 0.9848f, 0.9877f, 0.9903f, 0.9926f, 0.9945f,
+ 0.9962f, 0.9976f, 0.9986f, 0.9994f, 0.9998f,
+ 1.0f
+ };
+
+ if(d != 0.0)
+ t /= d; /* normalize */
+
+ int idx = (int)(90.0 * t);
+
+ return b + c * (SIN_TABLE[idx]);
+
+}
+
+static double _anim_ease_inout_quartic(double t, double b,
+ double c, double d)
+{
+ if(d != 0.0)
+ t /= d;
+ double ts = t * t;
+ double tc = ts * t;
+ return b + c * (-2 * tc + 3 * ts);
+
+}
+
+static double _anim_ease_inout_quintic(double t, double b,
+ double c, double d)
+{
+ if(d != 0.0)
+ t /= d;
+ double ts = t * t;
+ double tc = ts * t;
+ return b + c * (6 * tc * ts + -15 * ts * ts + 10 * tc);
+}
+
+anim_handle_t *create_animation()
+{
+ anim_handle_t *anim;
+
+ anim = calloc(1, sizeof(anim_handle_t));
+
+ if (anim == NULL) {
+ MSG_IVUG_ERROR("Cannot allocate memory");
+ return NULL;
+ }
+
+ return anim;
+
+}
+
+void delete_animation(anim_handle_t *anim)
+{
+ IV_ASSERT(anim != NULL);
+
+ free(anim);
+
+}
+
+bool set_animation_type(anim_handle_t *anim, anim_type_t type)
+{
+ IV_ASSERT(anim != NULL);
+
+ switch (type) {
+ case ANIM_TYPE_LINEAR:
+ anim->transit_func = _anim_linear;
+ break;
+ case ANIM_TYPE_QUARTIC_INOUT:
+ anim->transit_func = _anim_ease_inout_quartic;
+ break;
+
+ case ANIM_TYPE_QUINTIC_INOUT:
+ anim->transit_func = _anim_ease_inout_quintic;
+ break;
+
+ case ANIM_TYPE_SINE:
+ anim->transit_func = _anim_sine;
+ break;
+ default:
+ MSG_IVUG_ERROR("Invalid transition type=%d", type);
+ return false;
+ break;
+ }
+
+ return true;
+}
+
+bool set_animation(anim_handle_t *anim, int start, int end, double duration)
+{
+ IV_ASSERT(anim != NULL);
+
+ MSG_IVUG_MED("Set Anim. Start=%d End=%d Dur=%f", start, end, duration);
+ anim->duration = duration;
+ anim->t_start = start;
+ anim->t_varing = end - start;
+
+ return true;
+}
+
+bool update_animation(anim_handle_t *anim, double current, int *value)
+{
+ IV_ASSERT(anim != NULL);
+ IV_ASSERT(anim->transit_func != NULL);
+
+ if (current >= anim->duration) {
+ *value = anim->t_start + anim->t_varing;
+ MSG_IVUG_MED("End Start:%f Varing:%f Duration=%f",
+ anim->t_start, anim->t_varing, anim->duration);
+
+ MSG_IVUG_MED("End Current=%f Value=%d", current, *value);
+
+ return false; /* End of animation */
+ }
+
+ MSG_IVUG_MED("Start:%f Varing:%f Duration=%f Current=%f", anim->t_start,
+ anim->t_varing, anim->duration, current);
+
+ *value = (int)anim->transit_func(current, anim->t_start, anim->t_varing,
+ anim->duration);
+
+ MSG_IVUG_MED("Value = %d", *value);
+
+ return true;
+}
diff --git a/main/src/effect/ivug-effect.c b/main/src/effect/ivug-effect.c
new file mode 100755
index 0000000..ea17ee5
--- /dev/null
+++ b/main/src/effect/ivug-effect.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-effect.h"
+
+#define SIN_TABLE_NUM 91
+
+/* Animation acceleration table */
+static const float const EFFECT_SIN_TABLE[SIN_TABLE_NUM] = {
+ 0.0000f, 0.0174f, 0.0349f, 0.0523f, 0.0698f,
+ 0.0872f, 0.1045f, 0.1219f, 0.1392f, 0.1564f,
+ 0.1736f, 0.1908f, 0.2079f, 0.2249f, 0.2419f,
+ 0.2588f, 0.2756f, 0.2924f, 0.3090f, 0.3256f,
+ 0.3420f, 0.3584f, 0.3746f, 0.3907f, 0.4067f,
+ 0.4226f, 0.4384f, 0.4540f, 0.4695f, 0.4848f,
+ 0.5000f, 0.5150f, 0.5299f, 0.5446f, 0.5592f,
+ 0.5736f, 0.5878f, 0.6018f, 0.6157f, 0.6293f,
+ 0.6528f, 0.6561f, 0.6691f, 0.6820f, 0.6947f,
+ 0.7071f, 0.7193f, 0.7314f, 0.7431f, 0.7547f,
+ 0.7660f, 0.7772f, 0.7880f, 0.7986f, 0.8090f,
+ 0.8191f, 0.8290f, 0.8387f, 0.8480f, 0.8571f,
+ 0.8660f, 0.8746f, 0.8829f, 0.8910f, 0.8988f,
+ 0.9063f, 0.9135f, 0.9205f, 0.9272f, 0.9336f,
+ 0.9397f, 0.9455f, 0.9511f, 0.9563f, 0.9613f,
+ 0.9659f, 0.9703f, 0.9744f, 0.9781f, 0.9816f,
+ 0.9848f, 0.9877f, 0.9903f, 0.9926f, 0.9945f,
+ 0.9962f, 0.9976f, 0.9986f, 0.9994f, 0.9998f,
+ 1.0f
+};
+
+#define SLIDESHOW_ANI_TIME (1.0f)
+
+
+static Eina_Bool
+_on_effect_animator(void *data)
+{
+ IV_ASSERT( data != NULL);
+ Effect_Engine *engine = data;
+
+ int value = 0;
+
+ if ( update_animation(engine->anim, ecore_loop_time_get() - engine->t_base, &value) == false ) // If last frame
+ {
+ engine->animator = NULL;
+
+ MSG_EFFECT_HIGH("Last effect frame. value=%d", value);
+
+ engine->func.animate(engine->eng_data, value); // Draw last frame.
+ // Inform to user.
+ if ( engine->pFinishedCB )
+ {
+ engine->pFinishedCB(engine->ClientData);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ engine->func.animate(engine->eng_data, value);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+bool ivug_effect_init(Effect_Engine *engine, Evas_Object *src, Evas_Object *dst, int w, int h, int rotation)
+{
+ IV_ASSERT(engine != NULL );
+
+ void *data = engine->func.init(src, dst, w, h, rotation);
+ if (data == NULL) {
+ MSG_EFFECT_ERROR("init returned data is NULL");
+
+ return false;
+ }
+
+ engine->eng_data = data;
+
+ engine->anim = create_animation();
+ return true;
+}
+
+bool ivug_effect_start(Effect_Engine *engine, FuncFinished pFunc, void *data)
+{
+ ivug_retvm_if(engine == NULL, false, "engine is NULL");
+
+ IV_ASSERT(engine->func.animate != NULL);
+ IV_ASSERT(engine->eng_data != NULL);
+
+// Set up slide show animator
+ engine->t_base = ecore_loop_time_get();
+
+ double duration = SLIDESHOW_ANI_TIME;
+
+ if (engine->func.get_duration )
+ {
+ duration = engine->func.get_duration(engine->eng_data);
+ }
+
+ set_animation_type(engine->anim, ANIM_TYPE_LINEAR);
+ set_animation(engine->anim, 0, 100, duration); // 0~100% during 1 seconds
+
+ engine->pFinishedCB = pFunc;
+ engine->ClientData = data;
+
+ if (engine->animator == NULL)
+ {
+ engine->animator = ecore_animator_add(_on_effect_animator, engine);
+ }
+
+ return true;
+}
+
+bool ivug_effect_pause(Effect_Engine *engine)
+{
+/* Unused. */
+ return true;
+}
+
+bool ivug_effect_resume(Effect_Engine *engine)
+{
+/* Unused. */
+ return true;
+}
+
+bool ivug_effect_finalize(Effect_Engine *engine)
+{
+ ivug_retvm_if(engine == NULL, false, "engine is NULL");
+
+ if ( engine->animator )
+ {
+ ecore_animator_del(engine->animator);
+ engine->animator = NULL;
+ }
+
+ if (engine->eng_data)
+ {
+ if (engine->func.finalize)
+ {
+ MSG_EFFECT_HIGH("finalize");
+ engine->func.finalize(engine->eng_data);
+ }
+ else
+ {
+ MSG_EFFECT_ERROR("engine->func.finalize is NULL");
+ }
+
+ engine->eng_data = NULL;
+ }
+ else
+ {
+ MSG_EFFECT_ERROR("engine->eng_data is NULL");
+ }
+
+ if ( engine->anim )
+ {
+ delete_animation(engine->anim);
+ }
+
+ free(engine);
+ engine = NULL;
+
+ return true;
+}
+
+Effect_Engine *ivug_effect_add(Effect_Type type)
+{
+ Effect_Engine *eng = NULL;
+
+ switch (type) {
+ case EFFECT_SLIDE:
+ eng = ivug_slide_add();
+ break;
+
+ default:
+ MSG_EFFECT_ERROR("Unknown effect type=%d", type);
+ return NULL;
+ break;
+ }
+
+ if (eng == NULL)
+ {
+ MSG_EFFECT_ERROR("Cannot create effect enigne. type=%d", type);
+ return NULL;
+ }
+
+ return eng;
+}
diff --git a/main/src/effect/ivug-slide.c b/main/src/effect/ivug-slide.c
new file mode 100755
index 0000000..adb38f9
--- /dev/null
+++ b/main/src/effect/ivug-slide.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ivug-common.h"
+#include "ivug-effect.h"
+
+
+typedef struct {
+ Evas_Object *src;
+ Evas_Object *dst;
+
+ int screen_w;
+ int screen_h;
+} Priv_Data;
+
+
+static Effect_Data __ivug_slide_init(Evas_Object *src, Evas_Object *dst, int screen_w, int screen_h, int rotation)
+{
+ Priv_Data *pData = calloc(1, sizeof(Priv_Data));
+ IV_ASSERT(pData != NULL);
+
+ pData->src = src;
+ pData->dst = dst;
+
+ pData->screen_w = screen_w;
+ pData->screen_h = screen_h;
+
+ evas_object_stack_below(dst, src);
+
+ evas_object_move(pData->src, 0, 0);
+
+// ivug_slider_item_move(sd->slide[NEXT_SLIDE], x + sd->slide[CENTER_SLIDE]->w + IMAGE_BETWEEN_MARGIN , y);
+
+ return (Effect_Data)pData;
+}
+
+static void __ivug_slide_anim(Effect_Data data, double percent)
+{
+ Priv_Data *pData = (Priv_Data *)data;
+
+ int first = 0;
+ int last = -pData->screen_w -IMAGE_BETWEEN_MARGIN;
+
+ int value = (double)first * (1.0f - percent / 100.0f) + (double)last * (percent / 100.0f);
+
+ MSG_EFFECT_MED("Slide animation. Value=%d %f", value, percent);
+
+ Evas_Coord ox, oy, ow, oh;
+ evas_object_geometry_get(pData->src, &ox, &oy, &ow, &oh);
+
+ evas_object_move(pData->src, value, oy);
+ evas_object_move(pData->dst, value + ow + IMAGE_BETWEEN_MARGIN, oy);
+
+}
+
+static void __ivug_slide_pause(Effect_Data data)
+{
+
+}
+
+static void __ivug_slide_resume(Effect_Data data)
+{
+
+}
+
+static void __ivug_slide_finialize(Effect_Data data)
+{
+ Priv_Data *pData = (Priv_Data *)data;
+
+ free(pData);
+
+}
+
+static double __ivug_slide_get_duration(Effect_Data data)
+{
+ return 0.2f;
+}
+
+
+
+Effect_Engine *ivug_slide_add(void)
+{
+ Effect_Engine *eng_slide = calloc(1, sizeof(Effect_Engine));
+ ivug_retvm_if(eng_slide == NULL, NULL, "calloc failed");
+
+ eng_slide->func.init = __ivug_slide_init;
+ eng_slide->func.animate = __ivug_slide_anim;
+ eng_slide->func.pause = __ivug_slide_pause;
+ eng_slide->func.resume = __ivug_slide_resume;
+ eng_slide->func.finalize = __ivug_slide_finialize;
+ eng_slide->func.get_duration = __ivug_slide_get_duration;
+
+ return eng_slide;
+}
diff --git a/main/src/effect/template.c b/main/src/effect/template.c
new file mode 100755
index 0000000..22868eb
--- /dev/null
+++ b/main/src/effect/template.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-effect.h"
+
+
+typedef struct {
+ Evas_Object *src;
+ Evas_Object *dst;
+
+ Evas_Object *object;
+ Evas_Object *orig_cliper;
+
+ Evas_Object *cliper;
+
+ int screen_w;
+ int screen_h;
+} effect_data;
+
+
+static Effect_Data __ivug_init(Evas_Object *src, Evas_Object *dst, int screen_w, int screen_h, int rotation)
+{
+ IVUG_FUNC_ENTER();
+
+ IVUG_FUNC_LEAVE();
+}
+
+static void __ivug_anim(Effect_Data data, double percent)
+{
+/* IVUG_FUNC_ENTER(); */
+
+/* IVUG_FUNC_LEAVE(); */
+}
+
+static void __ivug_pause(Effect_Data data)
+{
+ IVUG_FUNC_ENTER();
+
+ IVUG_FUNC_LEAVE();
+}
+
+static void __ivug_resume(Effect_Data data)
+{
+ IVUG_FUNC_ENTER();
+
+ IVUG_FUNC_LEAVE();
+}
+
+static void __ivug_spin_finialize(Effect_Data data)
+{
+ IVUG_FUNC_ENTER();
+
+ IVUG_FUNC_LEAVE();
+}
+
+Effect_Engine *ivug_xxx_add(void)
+{
+ Effect_Engine *eng_spin = calloc(1, sizeof(Effect_Engine));
+ ivug_retvm_if(eng_spin == NULL, NULL, "calloc failed");
+
+ eng_spin->func.init = &__ivug_init;
+ eng_spin->func.animate = &__ivug_anim;
+ eng_spin->func.pause = &__ivug_pause;
+ eng_spin->func.resume = &__ivug_resume;
+ eng_spin->func.finalize = &__ivug_finialize;
+
+ return eng_spin;
+}
diff --git a/main/src/ug-image-viewer.c b/main/src/ug-image-viewer.c
new file mode 100755
index 0000000..44958fd
--- /dev/null
+++ b/main/src/ug-image-viewer.c
@@ -0,0 +1,430 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <Elementary.h>
+#include <ui-gadget-module.h>
+#include <Ecore_X.h> /*EFL*/
+
+#include "ivug-common.h" //common
+#include "ivug-util.h"
+#include "ivug-main.h"
+#include "ivug-main-view.h"
+#include "ivug-setas-view.h"
+#include "ivug-details-view.h"
+#include "ivug-slider.h"
+
+#include "ug-image-viewer.h"
+
+#include "ivug-data.h"
+#include "ivug-parameter.h"
+
+static Evas_Object *create_fullview(Evas_Object *win, struct ug_data *ugd)
+{
+ Evas_Object *base;
+
+ /* Create Full view */
+ base = elm_layout_add(win);
+
+ Eina_Bool ret;
+
+ ret = elm_layout_file_set(base , EDJ_PATH"/ivug-base.edj", "ivug_base" );
+
+ if ( ret == EINA_FALSE)
+ {
+ MSG_IMAGEVIEW_HIGH("Cannot set layout. EDJ=%s Group=%s", EDJ_PATH"/ivug-base.edj", "ivug_base");
+ evas_object_del(base);
+
+ return NULL;
+ }
+
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(base, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ elm_win_resize_object_add(win, base);
+
+ return base;
+}
+
+static Evas_Object *create_frameview(Evas_Object *parent, struct ug_data *ugd)
+{
+ Evas_Object *base;
+
+ /* Create Frame view */
+ base = elm_layout_add(parent);
+ elm_layout_theme_set(base, "layout", "application", "default");
+
+ return base;
+}
+
+static void *on_create(struct ui_gadget *ug, enum ug_mode mode, bundle *data, void *priv)
+{
+ struct ug_data *ugd;
+
+ PERF_CHECK_BEGIN("On Create");
+
+ MSG_IMAGEVIEW_HIGH("Image Viewer : %s ug=0x%08x", __func__, ug);
+
+ if (!ug || !priv)
+ {
+ MSG_IMAGEVIEW_ERROR("Error. ug=0x%08x priv=0x%08x", ug, priv);
+ return NULL;
+ }
+
+ ugd = priv;
+/*
+ If application call this US, ug_get_parent_layout() returns window ID not layout.
+ Probably, UG bugs.
+*/
+ ugd->parent_layout = ug_get_parent_layout(ug); //parent's layout
+ if (!ugd->parent_layout)
+ {
+ MSG_IMAGEVIEW_ERROR("Cannot get parent's layout. parent=0x%08x", ugd->parent_layout);
+ return NULL;
+ }
+
+ PERF_CHECK_BEGIN(LVL1 "main_init");
+ //init
+ if (!ivug_main_init(ug))
+ {
+ MSG_IMAGEVIEW_ERROR("ivug_main_init error");
+ return NULL;
+ }
+ PERF_CHECK_END(LVL1 "main_init");
+
+ PERF_CHECK_BEGIN(LVL1 "parse bundle");
+
+ ugd->ivug_param = ivug_param_create_from_bundle(data);
+ if ( ugd->ivug_param == NULL )
+ {
+ MSG_IMAGEVIEW_ERROR("Cannot parse parameter");
+ ivug_main_deinit(ug);
+ return NULL;
+ }
+ PERF_CHECK_END(LVL1 "parse bundle");
+
+ //create base
+ if (mode == UG_MODE_FULLVIEW)
+ {
+ MSG_IMAGEVIEW_MED("create base layout for FullView");
+ ugd->base = create_fullview(ug_get_window(), ugd);
+ }
+ else
+ {
+ MSG_IMAGEVIEW_MED("create base layout for FrameView");
+ ugd->base = create_frameview(ug_get_window(), ugd);
+ }
+
+ if ( ugd->base == NULL )
+ {
+ MSG_IMAGEVIEW_ERROR("Cannot create base view");
+ return NULL;
+ }
+
+ if(ugd->ivug_param->mode == IVUG_MODE_SETAS)
+ {
+ MSG_IMAGEVIEW_HIGH("UG types=%d", ugd->ivug_param->setas_type);
+
+ if(ugd->ivug_param->setas_type == IVUG_SET_AS_UG_TYPE_WALLPAPER)
+ {
+ // From Wall paper in Setting
+ ugd->setas_view = ivug_setas_view_screen_ug_create(ugd->base, ugd->ivug_param->filepath);
+ }
+ else
+ {
+ MSG_IMAGEVIEW_ERROR("Invalid SetAS UG Type:%d", ugd->ivug_param->setas_type);
+ return NULL;
+ }
+
+ if(ugd->setas_view == NULL)
+ {
+ MSG_IMAGEVIEW_ERROR("SetAS UG creation failed Type:%d", ugd->ivug_param->setas_type);
+ ivug_main_deinit(ug);
+ if (ugd->base)
+ {
+ evas_object_del(ugd->base);
+ ugd->base = NULL;
+ }
+ return NULL;
+ }
+
+ Evas_Object *layout = ivug_setas_view_object_get(ugd->setas_view);
+
+ elm_object_part_content_set(ugd->base, "elm.swallow.content", layout); //swallow
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ evas_object_show(layout);
+ }
+ else
+ {
+ PERF_CHECK_BEGIN(LVL1 "main_view_create");
+
+ ugd->main_view = ivug_main_view_create(ugd->base, ugd->ivug_param->mode, ugd->ivug_param->view_by);
+
+ if (ugd->main_view == NULL) //set main view.
+ {
+ MSG_IMAGEVIEW_ERROR("Main View Layout Lading Fail");
+ ivug_main_deinit(ug);
+ if (ugd->base)
+ {
+ evas_object_del(ugd->base);
+ ugd->base = NULL;
+ }
+ return NULL;
+ }
+
+ PERF_CHECK_END(LVL1 "main_view_create");
+
+// Load list.
+ if ( ivug_main_view_load_list(ugd->main_view, ugd->ivug_param) == false)
+ {
+ MSG_IMAGEVIEW_ERROR("Cannot load media list.");
+ // Need popup?
+ ivug_main_deinit(ug);
+ if (ugd->base)
+ {
+ evas_object_del(ugd->base);
+ ugd->base = NULL;
+ }
+ return NULL;
+
+ }
+
+ Evas_Object *layout = ivug_main_view_object_get(ugd->main_view);
+
+ elm_object_part_content_set(ugd->base, "elm.swallow.content", layout); //swallow
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ evas_object_show(layout);
+
+ }
+
+ PERF_CHECK_END("On Create");
+
+ return ugd->base;
+}
+
+static void on_start(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ MSG_IMAGEVIEW_HIGH("Image Viewer : %s", __func__);
+}
+
+static void on_pause(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ MSG_IMAGEVIEW_HIGH("Image Viewer : %s", __func__);
+
+ if (!ug || !priv)
+ {
+ MSG_IMAGEVIEW_ERROR("Invalid UG. UG=0x%08x Priv=0x%08x", ug, priv);
+ return ;
+ }
+
+ struct ug_data *ugd = (struct ug_data *)priv;
+
+ if ( ugd->main_view )
+ {
+ ivug_slider_stop_slide_show(ugd->main_view->slider);
+ }
+
+}
+
+static void on_resume(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ MSG_IMAGEVIEW_HIGH("Image Viewer : %s", __func__);
+
+ if (!ug || !priv)
+ {
+ IVUG_DEBUG_MSG("Invalid UG. UG=0x%08x Priv=0x%08x", ug, priv);
+ return ;
+ }
+
+ struct ug_data *ugd = (struct ug_data *)priv;
+
+ if ( ugd->main_view )
+ {
+ ivug_main_view_update(ugd->main_view);
+
+// ivug_slider_resume_slide_show(ugd->main_view->slider);
+ }
+
+}
+
+static void on_destroy(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ MSG_IMAGEVIEW_HIGH("Image Viewer : %s UG=0x%08x", __func__, ug);
+
+ PERF_CHECK_BEGIN("On Destroy");
+
+ if (!ug || !priv)
+ {
+ MSG_IMAGEVIEW_ERROR("Invalid UG. UG=0x%08x Priv=0x%08x", ug, priv);
+ return ;
+ }
+
+ struct ug_data *ugd = (struct ug_data *)priv;
+
+ MSG_IMAGEVIEW_HIGH("On Destroy : ug=0x%08x", ug);
+ //destroy main view.
+ if ( ugd->main_view )
+ {
+ ivug_main_view_destroy(ugd->main_view);
+ ugd->main_view = NULL;
+ }
+
+ if(ugd->setas_view)
+ {
+ ivug_setas_view_destroy(ugd->setas_view);
+ ugd->setas_view = NULL;
+ }
+
+ //delete param.
+ if(ugd->ivug_param)
+ {
+ ivug_param_delete(ugd->ivug_param);
+ ugd->ivug_param = NULL;
+ }
+
+ //finalize data
+ if ( !ivug_main_deinit(ug))
+ {
+ MSG_IMAGEVIEW_ERROR("ivug_main_deinit failed");
+ }
+
+ if (ugd->base)
+ {
+ evas_object_del(ugd->base);
+ ugd->base = NULL;
+ }
+
+ MSG_IMAGEVIEW_HIGH("Destroyed all ug");
+
+ PERF_CHECK_END("On Destroy");
+
+}
+
+
+static void on_message(struct ui_gadget *ug, bundle *msg, bundle *data, void *priv)
+{
+ MSG_IMAGEVIEW_HIGH("Image Viewer : %s UG=0x%08x", __func__, ug); //on message
+}
+
+static void on_event(struct ui_gadget *ug, enum ug_event event, bundle *data, void *priv)
+{
+ if (!ug || !priv)
+ {
+ MSG_IMAGEVIEW_ERROR("Invalid UG. UG=0x%08x Priv=0x%08x", ug, priv);
+ return;
+ }
+ MSG_IMAGEVIEW_HIGH("Image Viewer : %s UG=0x%08x", __func__, ug); //on message
+
+ //struct ug_data *ugd = (struct ug_data *)priv;
+
+ switch (event) {
+ case UG_EVENT_LOW_MEMORY:
+ MSG_IMAGEVIEW_HIGH("Get Event : Low Memory");
+ break;
+ case UG_EVENT_LOW_BATTERY:
+ MSG_IMAGEVIEW_HIGH("Get Event : Low battery");
+ break;
+ case UG_EVENT_LANG_CHANGE:
+ MSG_IMAGEVIEW_HIGH("Get Event : Language changed");
+ break;
+ default:
+ MSG_IMAGEVIEW_ERROR("Unknown event type : %d", event);
+ break;
+ }
+}
+
+UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
+{
+ struct ug_data *ugd;
+
+ MSG_IMAGEVIEW_HIGH("UG_MODULE_INIT");
+
+ if (!ops)
+ {
+ MSG_IMAGEVIEW_ERROR("OPS Pointer is NULL");
+ return -1;
+ }
+
+ ugd = calloc(1, sizeof(struct ug_data)); //alloc ug_data memory
+ if (!ugd)
+ {
+ MSG_IMAGEVIEW_ERROR("Cannot allocate memory.");
+ return -1;
+ }
+
+ PERF_INIT();
+
+ ops->create = on_create;
+ ops->start = on_start;
+ ops->pause = on_pause;
+ ops->resume = on_resume;
+ ops->destroy = on_destroy;
+ ops->message = on_message;
+ ops->event = on_event;
+ ops->priv = ugd;
+ ops->opt = UG_OPT_INDICATOR_ENABLE;
+
+ return 0;
+}
+
+UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
+{
+ struct ug_data *ugd;
+ if (!ops)
+ {
+ MSG_IMAGEVIEW_ERROR("OPS Pointer is NULL");
+ return;
+ }
+
+ ugd = ops->priv;
+
+ if (ugd)
+ {
+ free(ugd);
+ }
+
+ MSG_IMAGEVIEW_HIGH("UG_MODULE_EXIT");
+
+ PERF_SHOW_RESULT(stdout);
+
+ PERF_DEINIT();
+
+}
+
+
+#define _CONSTRUCTOR __attribute__ ((constructor))
+#define _DESTRUCTOR __attribute__ ((destructor))
+
+void _CONSTRUCTOR _DLLInit(void)
+{
+ printf("Image Viewer - Called constructor\n");
+}
+
+void _DESTRUCTOR _DLLExit(void)
+{
+ printf("Image Viewer - Called destructor\n");
+
+}
+
+
+int main()
+{
+/* For detecting undefined symbol */
+ return -1;
+}
+
diff --git a/main/src/ug-image-viewer.h b/main/src/ug-image-viewer.h
new file mode 100755
index 0000000..412a53b
--- /dev/null
+++ b/main/src/ug-image-viewer.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __UG_IMAGE_VIEWER_H__
+#define __UG_IMAGE_VIEWER_H__
+
+#include <Elementary.h>
+#include <libintl.h>
+
+#include "ivug-common.h"
+
+typedef struct ug_data {
+ Evas_Object *parent_layout;
+ Evas_Object *base; // UG layout
+
+// View Data;
+ Ivug_MainView *main_view;
+ Ivug_SetAsView *setas_view;
+
+ ivug_parameter* ivug_param;
+
+ bool bUseBlackTheme; // TODO : SetAs view from setting does not use black theme
+
+} _AppData;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Add functions here */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UG_IMAGE_VIEWER_H__ */
diff --git a/main/src/util/ivug-file-info.c b/main/src/util/ivug-file-info.c
new file mode 100755
index 0000000..6419761
--- /dev/null
+++ b/main/src/util/ivug-file-info.c
@@ -0,0 +1,403 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+
+#include <libexif/exif-data.h> //for exif
+#include <mm_file.h>
+#include <mmf/mm.h>
+#include <mmf/mm_file.h>
+#include <aul.h>
+
+#include "ivug-file-info.h"
+
+bool _get_video_gps_info(const char *filepath, double *latitude, double *longitude)
+{
+ IV_ASSERT(filepath != NULL);
+ IV_ASSERT(latitude != NULL);
+ IV_ASSERT(longitude != NULL);
+
+ MMHandleType tag = (MMHandleType) NULL;
+ int err = -1;
+ char *err_msg = NULL;
+ double gps_value = 0.0;
+
+ *latitude = 0.0;
+ *longitude = 0.0;
+
+ err = mm_file_create_tag_attrs(&tag, filepath);
+ if (!tag)
+ {
+ MSG_UTIL_ERROR("mm_file_create_tag_attrs ERROR %s", filepath);
+ return false;
+ }
+
+ err = mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_LATIDUE, &gps_value, NULL);
+ if (err == 0)
+ {
+ MSG_UTIL_HIGH("latitude: %f", gps_value);
+ if (gps_value != 0.0)
+ {
+ *latitude = gps_value;
+ }
+ }
+ else if (err_msg)
+ {
+ MSG_UTIL_ERROR("mm_file_get_attrs fails : %s", err_msg);
+ free(err_msg);
+ err_msg = NULL;
+ mm_file_destroy_tag_attrs(tag);
+
+ return false;
+ }
+
+ err = mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_LONGITUDE, &gps_value, NULL);
+ if (err == 0)
+ {
+ MSG_UTIL_HIGH("longitude: %f", gps_value);
+ if (gps_value != 0.0)
+ {
+ *longitude = gps_value;
+ }
+ }
+ else if (err_msg)
+ {
+ MSG_UTIL_ERROR("mm_file_get_attrs fails : %s", err_msg);
+ free(err_msg);
+ err_msg = NULL;
+ mm_file_destroy_tag_attrs(tag);
+ return false;
+ }
+
+ mm_file_destroy_tag_attrs(tag);
+ return true;
+}
+
+bool _get_image_gps_info(const char* filepath, double *latitude, double *longitude)
+{
+ IV_ASSERT(filepath != NULL);
+ IV_ASSERT(latitude != NULL);
+ IV_ASSERT(longitude != NULL);
+
+#define BUF_LEN (255)
+
+ ExifData *ed = NULL;
+ ExifEntry *entry = NULL;
+ ExifIfd ifd;
+ ExifTag tag;
+ char buf[BUF_LEN+1] = {'\0',};
+
+ /** get exifdata*/
+ ed = exif_data_new_from_file(filepath);
+ if (!ed)
+ {
+ return false;
+ }
+
+ ifd = EXIF_IFD_GPS;
+ tag = EXIF_TAG_GPS_LATITUDE;
+
+ /** get exifentry*/
+ entry = exif_data_get_entry(ed, tag);
+
+ if (!entry)
+ {
+ return false;
+ }
+
+ /** get value of the entry*/
+ if(exif_entry_get_value(entry, buf, BUF_LEN) == NULL)
+ {
+ exif_data_unref(ed);
+ return false;
+ }
+
+ {
+ buf[strlen(buf)] = '\0';
+ double tmp_arr[3] = { 0.0, 0.0, 0.0 };
+ int count = 0;
+ char* p = strtok(buf, ", ");
+ /** split the buf by , */
+ while(p != NULL)
+ {
+ tmp_arr[count] = atof(p);
+ count++;
+ p=strtok(NULL, ", ");
+ }
+
+ if( count != 3 )
+ {
+ MSG_UTIL_ERROR("Cannot get latitude info : %s", p);
+ exif_data_unref(ed);
+ return false;
+ }
+ *latitude = tmp_arr[0] + tmp_arr[1]/60 + tmp_arr[2]/3600;
+ }
+
+ tag = EXIF_TAG_GPS_LONGITUDE;
+
+ entry = exif_data_get_entry(ed, tag);
+
+ /** get value of the entry*/
+ if(exif_entry_get_value(entry, buf, BUF_LEN) == NULL)
+ {
+ exif_data_unref(ed);
+ return false;
+ }
+
+ {
+ buf[strlen(buf)] = '\0';
+ double tmp_arr[3] = { 0.0, 0.0, 0.0 };
+ int count = 0;
+ char* p = strtok(buf, ", ");
+ /** split the buf by , */
+ while(p != NULL)
+ {
+ tmp_arr[count] = atof(p);
+ count++;
+ p=strtok(NULL, ", ");
+ }
+
+ if( count != 3 )
+ {
+ MSG_UTIL_ERROR("Cannot get Longitude info : %s", p);
+ exif_data_unref(ed);
+ return false;
+ }
+
+ *longitude = tmp_arr[0] + tmp_arr[1]/60 + tmp_arr[2]/3600;
+ }
+
+ exif_data_unref(ed);
+
+ return true;
+}
+
+
+
+static bool _get_image_resolution(const char *path, int * /* OUT */ pWidth, int * /* OUT */pHeight)
+{
+ IV_ASSERT(path != NULL);
+
+ int width = 0;
+ int height = 0;
+
+ Evas *canvas;
+ Ecore_Evas *ee;
+
+ ee = ecore_evas_buffer_new(1, 1);
+ if (!ee)
+ {
+ MSG_DETAIL_ERROR("Cannot get EVAS");
+ return false;
+ }
+
+ canvas = ecore_evas_get(ee);
+
+ Evas_Object *img = evas_object_image_add(canvas);
+
+ evas_object_image_file_set(img, NULL, NULL);
+ evas_object_image_load_orientation_set(img, EINA_TRUE);
+ evas_object_image_load_scale_down_set(img, 0);
+
+ evas_object_image_file_set(img, path, NULL); // TODO : Error check
+ evas_object_image_size_get(img, &width, &height);
+
+ evas_object_image_file_set(img, NULL, NULL);
+ evas_object_del(img);
+
+ ecore_evas_free(ee);
+
+ *pWidth = width;
+ *pHeight = height;
+
+ MSG_DETAIL_HIGH("widht & height is [%d, %d]", width, height);
+
+ return true;
+}
+
+
+static bool
+_get_video_resolution(const char *path, int * /* OUT */ pWidth, int * /* OUT */pHeight)
+{
+ IV_ASSERT(path != NULL);
+
+ int w = 0;
+ int h = 0;
+ int error_code = MM_ERROR_NONE;
+
+ MMHandleType content = 0;
+ char *err_attr_name = NULL;
+
+ error_code = mm_file_create_content_attrs(&content, path);
+
+ if ( error_code != MM_ERROR_NONE )
+ {
+ MSG_UTIL_ERROR("mm_file_create_content_attrs() failed : ret=0x%08x", error_code);
+ return false;
+ }
+
+ error_code = MM_ERROR_NONE;
+ error_code = mm_file_get_attrs(content, &err_attr_name,
+ MM_FILE_CONTENT_VIDEO_WIDTH, &w,
+ MM_FILE_CONTENT_VIDEO_HEIGHT, &h,
+ NULL
+ );
+
+ if (error_code != MM_ERROR_NONE)
+ {
+ MSG_DETAIL_ERROR("mm_file_get_attrs() failed : ret=0x%08x", error_code);
+ MSG_DETAIL_ERROR("Error attribute name : %s", err_attr_name);
+ free(err_attr_name);
+
+ error_code = mm_file_destroy_content_attrs(content);
+ if (error_code != 0)
+ {
+ MSG_DETAIL_ERROR("mm_file_destroy_content_attrs() failed : ret=0x%08x", error_code);
+ }
+
+ return false;
+ }
+
+ *pWidth = w;
+ *pHeight = h;
+
+ error_code = mm_file_destroy_content_attrs(content);
+ if (error_code != 0)
+ {
+ MSG_DETAIL_ERROR("mm_file_destroy_content_attrs() failed : ret=0x%08x", error_code);
+ }
+
+ return true;
+}
+
+bool ivug_fileinfo_get_image_resolution(const char *path, int * /* OUT */ pWidth, int * /* OUT */pHeight)
+{
+ if ( path == NULL )
+ {
+ MSG_UTIL_ERROR("Cannot get image resolution. path is NULL");
+ return false;
+ }
+
+ if(ivug_is_file_exist(path) == false)
+ {
+ MSG_UTIL_ERROR("%s : %s is not exist", __func__, path);
+ return false;
+ }
+
+ return _get_image_resolution(path, pWidth, pHeight);
+}
+
+
+bool ivug_fileinfo_get_video_resolution(const char *path, int * /* OUT */ pWidth, int * /* OUT */pHeight)
+{
+ if ( path == NULL )
+ {
+ MSG_UTIL_ERROR("Cannot get video resolution. path is NULL");
+ return false;
+ }
+
+ if(ivug_is_file_exist(path) == false)
+ {
+ MSG_UTIL_ERROR("%s : %s is not exist", __func__, path);
+ return false;
+ }
+
+ return _get_video_resolution(path, pWidth, pHeight);
+}
+
+bool ivug_fileinfo_get_video_gps_info(const char *path, double *latitude, double *longitude)
+{
+ if ( path == NULL )
+ {
+ MSG_UTIL_ERROR("Cannot get video gps location. path is NULL");
+ return false;
+ }
+
+ if(ivug_is_file_exist(path) == false)
+ {
+ MSG_UTIL_ERROR("%s : %s is not exist", __func__, path);
+ return false;
+ }
+
+ return _get_video_gps_info(path, latitude, longitude);
+}
+
+
+bool ivug_fileinfo_get_image_gps_info(const char* path, double *latitude, double *longitude)
+{
+ if ( path == NULL )
+ {
+ MSG_UTIL_ERROR("Cannot get image gps location. path is NULL");
+ return false;
+ }
+
+ if(ivug_is_file_exist(path) == false)
+ {
+ MSG_UTIL_ERROR("%s : %s is not exist", __func__, path);
+ return false;
+ }
+
+ return _get_image_gps_info(path, latitude, longitude);
+}
+
+
+char *ivug_fileinfo_get_file_extension(const char *path)
+{
+ if ( path == NULL )
+ {
+ MSG_UTIL_ERROR("Cannot get file extension. path is NULL");
+ return NULL;
+ }
+
+ char *ext = NULL;
+
+ ext = strrchr(path, '.');
+
+ if ( (ext != NULL) && ((ext+1) != NULL) )
+ {
+ return strdup(ext + 1);
+ }
+
+ return NULL;
+
+}
+
+char *ivug_fileinfo_get_mime_type(const char *path)
+{
+ if ( path == NULL )
+ {
+ MSG_UTIL_ERROR("Cannot get mine type. path is NULL");
+ return NULL;
+ }
+
+ //check mine type.
+ char *mime_type = NULL;
+
+ efreet_mime_init();
+ const char *type = NULL;
+ type = efreet_mime_type_get(ecore_file_file_get(path));
+ if ( type != NULL )
+ {
+ mime_type = strdup(type);
+ }
+ efreet_mime_shutdown();
+
+ return mime_type;
+}
+
+
diff --git a/main/src/util/ivug-file-info.h b/main/src/util/ivug-file-info.h
new file mode 100755
index 0000000..ac8a3fa
--- /dev/null
+++ b/main/src/util/ivug-file-info.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_FILE_INFO_H__
+#define __IVUG_FILE_INFO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ ivug_fileinfo_*() returns false when error. otherwise return true and fill proper value in [out] param
+*/
+bool ivug_fileinfo_get_image_gps_info(const char* filepath, double * /* OUT */ latitude, double * /* OUT */ longitude);
+bool ivug_fileinfo_get_video_gps_info(const char *filepath, double * /* OUT */ latitude, double * /* OUT */ longitude);
+
+bool ivug_fileinfo_get_video_resolution(const char *filepath, int * /* OUT */ pWidth, int * /* OUT */pHeight);
+bool ivug_fileinfo_get_image_resolution(const char *filepath, int * /* OUT */ pWidth, int * /* OUT */pHeight);
+
+
+/*
+ return file extension string.
+
+ CAUTION : user should free returned string.
+*/
+char *ivug_fileinfo_get_file_extension(const char *filepath);
+
+
+/*
+ return mine type from file.
+
+ CAUTION : user should free returned string.
+*/
+char *ivug_fileinfo_get_mime_type(const char *path);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __IVUG_FILE_INFO_H__
+
diff --git a/main/src/util/ivug-listpopup.c b/main/src/util/ivug-listpopup.c
new file mode 100755
index 0000000..6ea395f
--- /dev/null
+++ b/main/src/util/ivug-listpopup.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-listpopup.h"
+
+
+#define POPUP_RESPONSE_NOT_SELECTED (-99)
+
+
+typedef struct {
+ Evas_Object *popup;
+
+ Evas_Smart_Cb response;
+ void* user_data;
+
+} Selectpopup;
+
+
+static char *
+_on_label_set(void *data, Evas_Object *obj, const char *part)
+{
+ IV_ASSERT( data != NULL);
+
+ ivug_listpopup_item *item = (ivug_listpopup_item *)data;
+
+ return strdup(item->caption); //dump
+}
+
+
+static void
+_on_genlist_selected(void *data, Evas_Object *obj, void *event_info)
+{
+ Selectpopup *pData = data;
+ Evas_Object *genlist = obj;
+ Elm_Object_Item *genitem = (Elm_Object_Item *)event_info;
+
+ IV_ASSERT( genlist != NULL);
+
+ if (genitem == NULL)
+ {
+ MSG_MAIN_ERROR("genlist item is NULL");
+ return;
+ }
+
+ ivug_listpopup_item *item = (ivug_listpopup_item *)elm_object_item_data_get(genitem);
+
+// Call response
+ pData->response(pData->user_data, pData->popup, item);
+
+}
+
+
+static ivug_listpopup_item *_dup_item(ivug_listpopup_item *item)
+{
+ ivug_listpopup_item *newitem = NULL;
+
+ newitem = calloc(1, sizeof(ivug_listpopup_item));
+
+ newitem->index = item->index;
+
+ if ( item->iconpath )
+ newitem->iconpath = strdup(item->iconpath);
+
+ if ( item->caption )
+ newitem->caption = strdup(item->caption); // Should be freed
+
+ newitem->data = item->data;
+
+ return newitem;
+}
+
+
+static void _on_genlist_item_del(void *data, Evas_Object *obj)
+{
+ IV_ASSERT( data != NULL);
+
+ ivug_listpopup_item *item = data;
+
+ MSG_IMAGEVIEW_HIGH("Remove genlist item");
+
+ if ( item->caption )
+ free(item->caption);
+
+ if ( item->iconpath )
+ free(item->iconpath);
+
+ free(item);
+}
+
+
+static void
+_on_popup_close(void *data, Evas_Object *obj, void *event_info)
+{
+ Selectpopup *pData = data;
+
+ pData->response(pData->user_data, pData->popup, NULL); // Call user callback
+}
+
+static void _on_popup_deleted(void * data, Evas * e, Evas_Object * obj, void * event_info)
+{
+ MSG_IMAGEVIEW_HIGH("Remove popup");
+
+ Selectpopup *pData = data;
+
+ free(pData);
+}
+
+
+
+typedef struct {
+ Eina_List *list;
+} _ivug_listpopup_itemlist;
+
+
+ivug_listpopup_itemlist ivug_listpopup_itemlist_new()
+{
+ _ivug_listpopup_itemlist *pList = malloc(sizeof(_ivug_listpopup_itemlist));
+ IV_ASSERT(pList != NULL);
+
+ pList->list = NULL;
+
+ return (ivug_listpopup_itemlist)pList;
+}
+
+unsigned int ivug_listpopup_itemlist_get_count(ivug_listpopup_itemlist items)
+{
+ _ivug_listpopup_itemlist *pList = items;
+ IV_ASSERT(pList != NULL);
+
+ return eina_list_count(pList->list);
+}
+
+ivug_listpopup_item *ivug_listpopup_itemlist_add(ivug_listpopup_itemlist items, int index, const char *iconpath, const char *caption, void *data, bool bDisabled)
+{
+ _ivug_listpopup_itemlist *pList = items;
+ IV_ASSERT(pList != NULL);
+
+ ivug_listpopup_item *item = NULL;
+
+ {
+ item = calloc(1, sizeof(ivug_listpopup_item));
+
+ item->index = index;
+
+ if ( iconpath )
+ item->iconpath = strdup(iconpath);
+
+ if ( caption )
+ item->caption = strdup(caption); // Should be freed
+
+ item->data = data;
+ item->bDisabled = bDisabled;
+ }
+
+ pList->list = eina_list_append(pList->list, item);
+
+ return item;
+
+
+}
+
+void ivug_listpopup_itemlist_free(ivug_listpopup_itemlist items)
+{
+ _ivug_listpopup_itemlist *pList = items;
+ IV_ASSERT(pList != NULL);
+
+ ivug_listpopup_item *item = NULL;
+
+ EINA_LIST_FREE(pList->list, item )
+ {
+ if ( item->caption )
+ free(item->caption);
+
+ if ( item->iconpath )
+ free(item->iconpath);
+
+ free(item);
+ }
+
+ free(pList);
+}
+
+
+Evas_Object *ivug_listpopup_show(Evas_Object *parent, const char* title, ivug_listpopup_itemlist items, Evas_Smart_Cb response, void* user_data)
+{
+ Evas_Object *popup;
+
+// create popup
+ popup = elm_popup_add(parent);
+ if (!popup)
+ {
+ MSG_IMAGEVIEW_ERROR("Error : popup create failed.");
+ return NULL;
+ }
+
+ elm_object_style_set(popup, "menustyle");
+ elm_object_part_text_set(popup, "title,text", title);
+
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ Evas_Object *btn_close = elm_button_add(popup);
+ elm_object_text_set(btn_close, IDS_CLOSE);
+ elm_object_part_content_set(popup, "button1", btn_close);
+
+// create genlist
+ Evas_Object *genlist;
+ static Elm_Genlist_Item_Class itc = {0,};
+
+ genlist = elm_genlist_add(popup);
+
+ itc.version = ELM_GENLIST_ITEM_CLASS_VERSION;
+ itc.item_style = "1text";
+ itc.func.text_get = _on_label_set;
+ itc.func.content_get = NULL;
+ itc.func.state_get = NULL;
+ itc.func.del = _on_genlist_item_del;
+
+ 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);
+
+ Selectpopup *pData = malloc(sizeof(Selectpopup));
+
+ pData->popup = popup;
+ pData->response = response;
+ pData->user_data = user_data;
+
+ _ivug_listpopup_itemlist *pList = items;
+
+ ivug_listpopup_item *pItem = NULL;
+ Eina_List *tmp;
+ Elm_Object_Item *gItem;
+
+
+ EINA_LIST_FOREACH(pList->list, tmp, pItem)
+ {
+ gItem = elm_genlist_item_append(genlist, &itc, _dup_item(pItem), NULL /* parent */, ELM_GENLIST_ITEM_NONE, _on_genlist_selected, pData);
+
+ elm_object_item_disabled_set(gItem, pItem->bDisabled);
+ }
+
+// Put together
+ Evas_Object *box;
+ box = elm_box_add(popup);
+ evas_object_show(genlist);
+ elm_box_pack_end(box, genlist);
+ elm_object_content_set(popup, box);
+
+ evas_object_smart_callback_add(btn_close, "clicked", _on_popup_close, pData);
+
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _on_popup_deleted, pData);
+
+ evas_object_show(popup);
+
+ return popup;
+
+}
+
+
diff --git a/main/src/util/ivug-listpopup.h b/main/src/util/ivug-listpopup.h
new file mode 100755
index 0000000..11715eb
--- /dev/null
+++ b/main/src/util/ivug-listpopup.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_LISTPOPUP_H__
+#define __IVUG_LISTPOPUP_H__
+
+typedef struct {
+ int index;
+
+ char *iconpath;
+ char *caption;
+ void *data;
+
+ bool bDisabled; // Item is disabled when true.
+} ivug_listpopup_item;
+
+typedef void *ivug_listpopup_itemlist;
+
+/*
+ Helper functions for ivug_listpopup_item
+*/
+ivug_listpopup_itemlist ivug_listpopup_itemlist_new();
+
+ivug_listpopup_item *ivug_listpopup_itemlist_add(ivug_listpopup_itemlist items, int index, const char *iconpath, const char *caption, void *data, bool bDisabled);
+
+void ivug_listpopup_itemlist_free(ivug_listpopup_itemlist items);
+
+
+
+/*
+ Create & Show popup including genlist.
+
+ example
+
+ void _on_selected(void *data, Evas_Object *obj, void *event_info)
+ {
+ Evas_Object *popup = genlist;
+ ivug_listpopup_item *item = event_info;
+ int nIndex = event_info;
+
+ if ( nIndex == 1 )
+ printf("1 is selected");
+
+ evas_object_del(popup); // Show destroy popup explicitly
+ mypopup = NULL;
+ }
+
+ ...
+ {
+ ivug_listpopup_itemlist items = ivug_listpopup_itemlist_new();
+
+ ivug_listpopup_itemlist_add(items, 0, NULL, "Select me 1", NULL, false);
+ ivug_listpopup_itemlist_add(items, 1, NULL, "Select me 1", NULL, false);
+ ivug_listpopup_itemlist_add(items, 2, "/data/myicon.png", "Select me 1", NULL, false);
+
+ mypopup = ivug_selectpopup_show(parent, "example", items, v, myData);
+
+ eina_list_free(items);
+ }
+
+
+*/
+Evas_Object *ivug_listpopup_show(Evas_Object *parent, const char* title, ivug_listpopup_itemlist items , Evas_Smart_Cb response, void* user_data);
+
+
+#endif // __IVUG_LISTPOPUP_H__
+
diff --git a/main/src/util/ivug-util.c b/main/src/util/ivug-util.c
new file mode 100755
index 0000000..496f027
--- /dev/null
+++ b/main/src/util/ivug-util.c
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <aul.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <pmapi.h>
+
+#include <media-svc.h>
+#include <visual-svc.h>
+
+/*
+ If filepath is web url, return TRUE.
+
+*/
+bool ivug_is_web_uri(const char* uri)
+{
+//check file url type. local , http, ftp.
+ IV_ASSERT(uri != NULL);
+
+ static const char* web_protocal_name[] =
+ {
+ "http://",
+ "ftp://",
+ NULL,
+ };
+
+ int i = 0;
+ while (web_protocal_name[i] != NULL)
+ {
+ if ( strlen(uri) > strlen(web_protocal_name[i]) )
+ {
+ if (strncmp(uri, web_protocal_name[i], strlen(web_protocal_name[i])) == 0)
+ {
+ return true;
+ }
+ }
+
+ i++;
+ }
+
+ MSG_UTIL_MED("Not web uri. %s", uri);
+
+ return false;
+}
+
+
+unsigned int get_distance(int prevX, int prevY, int X, int Y)
+{
+#include <math.h>
+ int dx = prevX - X;
+ int dy = prevY - Y;
+
+ return sqrt(dx*dx + dy*dy);
+}
+
+
+
+#define USE_ECORE_FILE
+
+#include <Ecore_File.h>
+
+/*
+ Remove fname file.
+ Returns true fname is not exist or removed sucessfully
+*/
+bool ivug_remove_file(const char *filepath)
+{
+ char error_msg[256];
+ if (ecore_file_exists(filepath) == EINA_FALSE)
+ {
+ MSG_UTIL_ERROR("Already removed.%s", filepath);
+ return true;
+ }
+
+#ifdef USE_ECORE_FILE
+ if ( ecore_file_unlink(filepath) == EINA_FALSE)
+ {
+ MSG_UTIL_ERROR("Cannot remove file : %s %s", filepath, strerror_r(errno, error_msg, sizeof(error_msg)) );
+ return false;
+ }
+
+ return true;
+#else
+ if ( unlink(filepath) != 0 )
+ {
+ MSG_UTIL_ERROR("Cannot remove file : %s %s", filepath, strerror_r(errno, error_msg, sizeof(error_msg)) );
+ return false;
+ }
+
+ return true;
+#endif
+}
+
+bool ivug_rename_file(const char *src, const char *dst)
+{
+ if (ecore_file_exists(src) == EINA_FALSE)
+ {
+ MSG_UTIL_ERROR("Source file is not exist : %s", src);
+ return false;
+ }
+
+ if (dst == NULL)
+ {
+ MSG_UTIL_ERROR("Destination file is NULL");
+ return false;
+ }
+
+
+ char error_msg[256];
+
+ if ( rename(src, dst) < 0)
+ {
+ MSG_UTIL_ERROR("Cannot rename from %s to %s : %s", src, dst, strerror_r(errno, error_msg, sizeof(error_msg)) );
+ return false;
+ }
+
+ return true;
+}
+
+char *
+ivug_mktemp(char* filepath, char*ext)
+{
+ ivug_retv_if(!filepath || !ext, NULL);
+
+ MSG_IVUG_HIGH("filepath %s, ext %s", filepath, ext);
+
+ char tempname[IVUG_MAX_FILE_PATH_LEN+1] = {0};
+ snprintf(tempname, sizeof(tempname), "%s_0.%s",filepath, ext);
+ int i = 1;
+
+// TODO : Will implement with another algorithm
+ while(ecore_file_exists(tempname) == EINA_TRUE )
+ {
+ snprintf(tempname, sizeof(tempname),"%s_%d.%s", filepath, i, ext);
+ i++;
+ }
+
+ MSG_IVUG_HIGH( " tempname %s, i %d", tempname, i);
+
+ return strdup(tempname);
+}
+
+
+/*
+ Check whether given filepath file exists
+
+ CAUTION : filepath cannot be NULL.
+*/
+bool ivug_is_file_exist(const char* filepath)
+{
+ IV_ASSERT(filepath != NULL);
+
+ if ( ecore_file_exists(filepath) == EINA_TRUE)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+
+/*
+ Returns start pointer of filename within filepath.
+ No memory allocated in this function. so user do not free returned pointer.
+
+ CAUTION : filepath cannot be NULL.
+*/
+const char * ivug_get_filename(const char *filepath)
+{
+ if ( filepath == NULL )
+ {
+ MSG_UTIL_WARN("File path is NULL");
+ return "NULL";
+ }
+
+#define DIRECORY_SPLITTER '/'
+ const char*pFileName = NULL;
+
+ pFileName = strrchr(filepath, DIRECORY_SPLITTER);
+ pFileName = (NULL == pFileName)? "": (pFileName+1);
+
+ return pFileName;
+}
+
+
+/*
+
+ Media service utility
+
+*/
+
+#include <media-svc.h>
+
+UUID ivug_get_album_id_from_filepath(const char *filepath)
+{
+ int ret = 0;
+ Mitem* item = NULL;
+
+ MediaSvcHandle *dbhandle = NULL;
+
+ int err = media_svc_connect(&dbhandle);
+ if (err != MB_SVC_ERROR_NONE)
+ {
+ MSG_UTIL_ERROR("DB open error. %d", err);
+ return NULL;
+ }
+
+ ret = minfo_get_item(dbhandle, filepath, &item); //get cluster id
+ if (ret != MB_SVC_ERROR_NONE)
+ {
+ MSG_UTIL_ERROR("Cannot find file in media db for %s", filepath);
+ return NULL; // Invalid id
+ }
+
+ UUID cluster_uuid = INVALID_UUID;
+
+ cluster_uuid = uuid_assign(item->cluster_uuid);
+
+ minfo_destroy_mtype_item(item);
+
+ err = media_svc_disconnect(dbhandle);
+ if (err != MB_SVC_ERROR_NONE)
+ {
+ MSG_SDATA_ERROR("media service finalize error=%d", err);
+ }
+
+ return cluster_uuid;
+
+}
+
+int ivug_prohibit_lcd_off(void)
+{
+ MSG_UTIL_MED("START : Sleep disabled");
+ return pm_lock_state(LCD_NORMAL, GOTO_STATE_NOW, 0);
+}
+
+int ivug_allow_lcd_off(void)
+{
+ MSG_UTIL_MED("END : Sleep disabled");
+ return pm_unlock_state(LCD_NORMAL, PM_KEEP_TIMER);
+}
+
+#define MIME_TYPE_LEN (255)
+#define MIME_TYPE_3GPP "video/3gpp"
+#define PATH_CAMERA_LOCAL "/opt/media/Camera shots"
+#define PATH_CAMERA_SDCARD "/opt/storage/sdcard/Camera shots/"
+
+/* Video editor can start when video exist in camera folder and 3gp file format */
+
+bool ivug_is_editable_video_file(char *filepath)
+{
+ MSG_UTIL_MED("path = %s", filepath);
+ if(strncmp(filepath, PATH_CAMERA_LOCAL, strlen(PATH_CAMERA_LOCAL)) == 0
+ || strncmp(filepath, PATH_CAMERA_SDCARD, strlen(PATH_CAMERA_SDCARD)) == 0)
+ {
+ char mime_type[MIME_TYPE_LEN] = {0,};
+ aul_get_mime_from_file(filepath, mime_type, sizeof(mime_type));
+ MSG_UTIL_MED("mime type = %s", mime_type);
+ if(strcmp(mime_type, MIME_TYPE_3GPP) == 0)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
diff --git a/main/src/util/ivug-util.h b/main/src/util/ivug-util.h
new file mode 100755
index 0000000..0c07169
--- /dev/null
+++ b/main/src/util/ivug-util.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_UTIL_H__
+#define __IVUG_UTIL_H__
+
+#include <stdbool.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+
+*/
+bool ivug_is_web_uri(const char* uri);
+
+bool ivug_remove_file(const char *filepath);
+
+bool ivug_is_file_exist(const char* filepath);
+
+bool ivug_rename_file(const char *src, const char *dst);
+
+inline const char *ivug_get_filename(const char *filepath);
+
+inline unsigned int get_distance(int prevX, int prevY, int X, int Y);
+
+/*
+ Generate temporary file name with given path and extension.
+ returned value should free() by user.
+*/
+char *ivug_mktemp(char* filepath, char*ext);
+
+
+/*
+ Media service wrapper utility
+*/
+
+UUID ivug_get_album_id_from_filepath(const char *filepath);
+
+
+/*
+ LCD sleep control.
+*/
+int ivug_prohibit_lcd_off(void);
+int ivug_allow_lcd_off(void);
+
+
+/*
+ Get mime type from file path.
+ should free returned after use.
+*/
+
+bool ivug_is_editable_video_file(char *filepath);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif //__IVUG_UTIL_H__
+
diff --git a/main/src/util/ivug-widget.c b/main/src/util/ivug-widget.c
new file mode 100755
index 0000000..fd43992
--- /dev/null
+++ b/main/src/util/ivug-widget.c
@@ -0,0 +1,209 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-widget.h"
+#include <ui-gadget-module.h>
+
+#include <Elementary.h>
+
+static void _on_obj_deleted(void * data, Evas * e, Evas_Object * obj, void * event_info)
+{
+ char *szMsg = (char *)data;
+ IV_ASSERT(szMsg != NULL);
+
+ MSG_MAIN_HIGH("On Object deleted. %s", szMsg);
+
+ free(szMsg);
+}
+
+void ivug_on_obj_deleted(Evas_Object* obj, char *msg, const char *func, int line)
+{
+ static char buf[1024];
+
+ sprintf(buf, "%s(L%d):%s", func, line, msg);
+
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _on_obj_deleted, strdup(buf));
+}
+
+Evas_Object* ivug_bg_add(Evas_Object* parent, int r, int g, int b)
+{
+ IV_ASSERT(parent != NULL);
+
+ Evas_Object *bg = elm_bg_add(parent);
+ 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);
+
+ elm_bg_color_set(bg, r, g, b);
+
+ evas_object_show(bg);
+
+ return bg;
+}
+
+Evas_Object *
+ivug_layout_add(Evas_Object *win, const char *edj, const char *group)
+{
+ IV_ASSERT(win != NULL);
+
+ Evas_Object *layout;
+
+ layout = elm_layout_add(win);
+
+ if ( layout == NULL )
+ {
+ MSG_SETAS_ERROR("Cannot create layout");
+ return NULL;
+ }
+
+ if (elm_layout_file_set(layout, edj, group) == EINA_FALSE)
+ {
+ MSG_SETAS_ERROR("edj loading fail, filepath=%s Group=%s", edj, group);
+ evas_object_del(layout);
+ return NULL;
+ }
+
+ evas_object_size_hint_expand_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+#ifdef USE_WIN_AS_PARENT
+ elm_win_resize_object_add( ug_get_window(), layout);
+#else
+ Evas_Coord x, y, w, h;
+ evas_object_geometry_get(win, &x, &y, &w, &h);
+
+ evas_object_move(layout, x, y);
+ evas_object_resize(layout, w, h);
+#endif
+
+ evas_object_show(layout);
+ return layout;
+}
+
+Evas_Object*
+ivug_default_layout_add( Evas_Object *win)
+{
+ IV_ASSERT(win != NULL);
+
+ Evas_Object *layout;
+ layout = elm_layout_add(win);
+
+ if ( layout == NULL )
+ {
+ MSG_SETAS_ERROR("Cannot create layout");
+ return NULL;
+ }
+
+ if ( elm_layout_theme_set( layout, "layout", "application", "default") == EINA_FALSE)
+ {
+ MSG_SETAS_ERROR("theme set fail, layout/application/defaulty");
+ evas_object_del(layout);
+ return NULL;
+ }
+
+ evas_object_size_hint_expand_set( layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL );
+
+#ifdef USE_WIN_AS_PARENT
+ elm_win_resize_object_add( ug_get_window(), layout);
+#else
+ Evas_Coord x, y, w, h;
+ evas_object_geometry_get(parent, &x, &y, &w, &h);
+
+ evas_object_move(layout, x, y);
+ evas_object_resize(layout, w, h);
+#endif
+
+ evas_object_show(layout);
+ return layout;
+}
+
+
+Evas_Object *ivug_button_add(Evas_Object *parent, char *style, char *caption, Evas_Object *icon, OnClickCB pFunc, const void * data )
+{
+ IV_ASSERT(parent != NULL);
+
+ Evas_Object *btn;
+
+ btn = elm_button_add(parent);
+ if ( btn == NULL )
+ {
+ return NULL;
+ }
+
+ if ( style )
+ elm_object_style_set(btn, style);
+
+ if ( caption )
+ elm_object_text_set(btn, caption);
+
+ if ( icon )
+ elm_object_part_content_set(btn, "icon", icon);
+
+ elm_object_focus_allow_set(btn, EINA_FALSE);
+ evas_object_propagate_events_set(btn, EINA_FALSE);
+
+ evas_object_smart_callback_add(btn, "clicked", pFunc, (void*)data);
+
+ return btn;
+}
+
+Evas_Object *ivug_icon_add(Evas_Object *parent, char *edjname, char *groupname)
+{
+ Evas_Object *icon;
+
+ icon = elm_icon_add(parent);
+
+ if ( elm_icon_file_set(icon, edjname, groupname) == EINA_FALSE)
+ {
+ MSG_IVUG_ERROR("Cannot file set. EDJ=%s Group=%s", edjname, groupname);
+ evas_object_del(icon);
+ return NULL;
+ }
+
+ evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ elm_icon_resizable_set(icon, EINA_TRUE, EINA_TRUE);
+ evas_object_size_hint_expand_set(icon, 1, 1);
+
+ return icon;
+}
+
+Evas_Object *ivug_controlbar_add(Evas_Object *parent, const char *style)
+{
+ Evas_Object *toolbar = elm_toolbar_add(parent);
+ if (!toolbar)
+ {
+ MSG_MAIN_ERROR("create tool bar failed");
+ return NULL;
+ }
+ elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
+ elm_object_style_set(toolbar, style);
+
+ return toolbar;
+}
+
+
+
+void
+ivug_object_del(Evas_Object *obj)
+{
+ evas_object_del(obj);
+}
+
+
diff --git a/main/src/util/ivug-widget.h b/main/src/util/ivug-widget.h
new file mode 100755
index 0000000..151ee1e
--- /dev/null
+++ b/main/src/util/ivug-widget.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_WIDGET_H__
+#define __IVUG_WIDGET_H__
+
+
+typedef void(*OnClickCB)(void *data, Evas_Object *obj, void *event_info);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ Internal use only... use macro DELETE_LOG instead
+*/
+void ivug_on_obj_deleted(Evas_Object* obj, char *msg, const char *func, int line);
+
+
+#define DELETE_NOTIFY(obj) \
+ ivug_on_obj_deleted(obj, #obj, __func__, __LINE__)
+
+/*
+ Create elm_bg with color - r,g,b
+*/
+Evas_Object *
+ivug_bg_add(Evas_Object* parent, int r, int g, int b);
+
+Evas_Object *
+ivug_layout_add(Evas_Object *win, const char *edjname, const char *groupname);
+
+Evas_Object*
+ivug_default_layout_add( Evas_Object *win);
+
+Evas_Object *
+ivug_button_add(Evas_Object *parent, char *style, char *caption, Evas_Object *icon, OnClickCB pFunc, const void *data );
+
+Evas_Object *
+ivug_icon_add(Evas_Object *parent, char *edjname, char *groupname);
+
+Evas_Object *
+ivug_controlbar_add(Evas_Object *parent, const char *style);
+
+void
+ivug_object_del(Evas_Object *obj);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __IVUG_WIDGET_H__
+
diff --git a/main/src/view/ivug-detail-info.c b/main/src/view/ivug-detail-info.c
new file mode 100755
index 0000000..77061e3
--- /dev/null
+++ b/main/src/view/ivug-detail-info.c
@@ -0,0 +1,437 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-detail-info.h"
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <appcore-efl.h>
+#include <appcore-common.h>
+
+#include <unicode/udat.h>
+#include <unicode/ustring.h>
+#include <unicode/uloc.h>
+#include <unicode/ucal.h>
+#include <unicode/udatpg.h>
+#include <unicode/utmscale.h>
+
+#include "ivug-details-view.h"
+#include <libexif/exif-data.h>
+
+#include "ivug-file-info.h"
+
+
+#define NOMAL_BUF 128
+
+#define DETAILS_DIR_PATH_LEN_MAX 4096
+
+enum IVUG_SIZE_TYPE
+{
+ SIZE_BYTE = 0,
+ SIZE_KB,
+ SIZE_MB,
+ SIZE_GB
+};
+
+/*
+ Shuld free returned value after use
+*/
+static char*
+_get_icu_time_string(const char *locale, const char *customSkeleton, const char *timezone, UDate date)
+{
+#define UG_ICU_ARR_LENGTH 256
+
+ IV_ASSERT(customSkeleton != NULL);
+ IV_ASSERT(timezone != NULL);
+
+ /*
+ Copy a byte string encoded in the default codepage to a ustring.
+ Copies at most n characters. The result will be null terminated if the length of src is less than n. Performs a host byte to UChar conversion
+ */
+ UChar ucustomSkeleton[UG_ICU_ARR_LENGTH] = {0,};
+
+ if(u_uastrncpy(ucustomSkeleton, customSkeleton, UG_ICU_ARR_LENGTH) == NULL)
+ {
+ MSG_UTIL_ERROR("u_uastrncpy() error.");
+ return NULL;
+ }
+
+ UChar utimezone[UG_ICU_ARR_LENGTH] = {0,};
+
+ if ( u_uastrncpy(utimezone, timezone, UG_ICU_ARR_LENGTH) == NULL )
+ {
+ MSG_UTIL_ERROR("u_uastrncpy() error.");
+ return NULL;
+ }
+
+ UErrorCode status = U_ZERO_ERROR;
+ UDateTimePatternGenerator *generator;
+ UDateFormat *formatter;
+
+ UChar bestPattern[UG_ICU_ARR_LENGTH] = {0,};
+ UChar formatted[UG_ICU_ARR_LENGTH] = {0,};
+ char formattedString[UG_ICU_ARR_LENGTH] = {0,};
+ int32_t bestPatternLength, formattedLength;
+
+ ucal_setDefaultTimeZone(utimezone , &status);
+
+ if (U_FAILURE(status))
+ {
+ MSG_UTIL_ERROR("ucal_setDefaultTimeZone() is failed");
+ return NULL;
+ }
+
+ uloc_setDefault(getenv("LC_TIME"), &status);
+
+ if (U_FAILURE(status))
+ {
+ MSG_UTIL_ERROR("ucal_setDefaultTimeZone() is failed");
+ return NULL;
+ }
+
+ generator = udatpg_open(locale, &status);
+ if(generator == NULL)
+ {
+ return NULL;
+ }
+
+ bestPatternLength = udatpg_getBestPattern(generator, ucustomSkeleton, u_strlen(ucustomSkeleton), bestPattern, UG_ICU_ARR_LENGTH, &status);
+ if(bestPatternLength <= 0)
+ {
+ return NULL;
+ }
+
+ formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale, NULL, -1, bestPattern, -1, &status);
+ if(formatter == 0)
+ {
+ return NULL;
+ }
+
+ formattedLength = udat_format(formatter, date, formatted, UG_ICU_ARR_LENGTH, NULL, &status);
+ if(formattedLength <= 0)
+ {
+ return NULL;
+ }
+
+ u_austrcpy(formattedString, formatted);
+ udatpg_close(generator);
+ udat_close(formatter);
+
+ if(strlen(formattedString) == 0)
+ {
+ return NULL;
+ }
+
+ return strdup(formattedString);
+}
+
+
+static char*
+_get_icu_date(time_t mtime)
+{
+#define UG_DATE_FORMAT_12 "yMMMdhms"
+#define UG_DATE_FORMAT_24 "yMMMdHms"
+
+ char* skeleton = NULL;
+
+ enum appcore_time_format timeformat;
+
+ int ret = appcore_get_timeformat(&timeformat);
+ if(ret == -1)
+ {
+ MSG_DETAIL_ERROR("Cannot get timeformat.");
+ timeformat = APPCORE_TIME_FORMAT_12; // Default value.
+// Go through
+ }
+
+ if(timeformat == APPCORE_TIME_FORMAT_12)
+ {
+ skeleton = UG_DATE_FORMAT_12;
+ }
+ else if(timeformat == APPCORE_TIME_FORMAT_24)
+ {
+ skeleton = UG_DATE_FORMAT_24;
+ }
+ else
+ {
+ MSG_DETAIL_ERROR("Invalid time format : %d", timeformat);
+ skeleton = UG_DATE_FORMAT_12; // Default value.
+ }
+
+ char *locale = vconf_get_str(VCONFKEY_REGIONFORMAT); /* eg. en_US.UTF-8*/
+ if(locale == NULL)
+ {
+ MSG_DETAIL_ERROR("Cannot get region format.");
+ locale = "en_US.UTF-8"; // Default value.
+ }
+
+ char *timezone = NULL;
+
+ timezone = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID); // eg Asia/Seoul
+ if(timezone == NULL)
+ {
+// TODO : How to get default time zone????
+ MSG_DETAIL_ERROR("Cannot get time zone");
+ return NULL;
+ }
+
+ MSG_DETAIL_HIGH("Locale:%s TimeZone:%s TimeFormat:%s", locale, skeleton, timezone);
+
+ char* datestr = NULL;
+
+ datestr = _get_icu_time_string(locale, skeleton, timezone, (UDate)mtime * 1000);
+
+ if(datestr == NULL)
+ {
+ MSG_DETAIL_ERROR("Cannot get time string");
+ return NULL;
+ }
+
+ MSG_DETAIL_HIGH("ICU Date : %s", datestr);
+ return datestr;
+
+}
+
+
+
+
+static char *
+_get_filesize_string(size_t size)
+{
+#define FILE_SIZE_LEN_MAX 64
+#define BASIC_SIZE 1024 //used for file size check
+
+ int count = 0;
+
+ unsigned long int lsize = (unsigned long int)size;
+
+ char *tmp = (char *)calloc(1, sizeof(char)*FILE_SIZE_LEN_MAX + 1);
+ if ( tmp == NULL)
+ {
+ return NULL;
+ }
+
+ while(size >= ( BASIC_SIZE ) )
+ {
+ lsize = size;
+ size /= BASIC_SIZE;
+ count++;
+ }
+
+ float remain = ((float)lsize/BASIC_SIZE) - size;
+
+ if(count == SIZE_BYTE)
+ {
+ snprintf(tmp,FILE_SIZE_LEN_MAX,"%zu B", size);
+ }
+ else if(count == SIZE_KB)
+ {
+ snprintf(tmp,FILE_SIZE_LEN_MAX,"%zu KB", size);
+ }
+ else if(count == SIZE_MB)
+ {
+ // need another algorithm
+ snprintf(tmp,FILE_SIZE_LEN_MAX,"%.1f MB", size+remain);
+ }
+ else if(count == SIZE_GB)
+ {
+ snprintf(tmp,FILE_SIZE_LEN_MAX,"%.1f GB", size+remain);
+ }
+
+ MSG_DETAIL_HIGH("Size = %lu, OrigSize=%zu", lsize, size);
+ return tmp;
+}
+
+void
+ivug_details_info_set_file_information(ivug_file_info_t * const pFileInfo, const char *path)
+{
+ ivug_ret_if( NULL == pFileInfo );
+ ivug_ret_if( NULL == path );
+
+/*** get file path*/
+ pFileInfo->filepath = strdup(path);
+
+ struct stat statbuf;
+
+ if(stat(path,&statbuf) == -1)
+ {
+ MSG_DETAIL_ERROR("Cannot get stat()");
+ return ;
+ }
+
+ pFileInfo->size = statbuf.st_size;
+ pFileInfo->date = statbuf.st_mtime;
+
+ pFileInfo->create_date = _get_icu_date(pFileInfo->date);
+
+ if ( pFileInfo->create_date == NULL )
+ {
+ pFileInfo->create_date = strdup(IDS_N_A);
+ }
+
+ pFileInfo->file_ext = ivug_fileinfo_get_file_extension(path);
+
+ if ( pFileInfo->file_ext == NULL )
+ {
+ pFileInfo->file_ext = strdup(IDS_UNKNOWN);
+ }
+
+ pFileInfo->filesize = _get_filesize_string(pFileInfo->size);
+
+ MSG_DETAIL_HIGH("Basic Info : ext=%s size=%s", pFileInfo->file_ext, pFileInfo->filesize);
+
+ return ;
+
+}
+
+
+void
+ivug_details_info_set_gps_info(ivug_file_info_t * const pFileInfo, const char *path)
+{
+#define UG_EXIF_ARR_LENGTH 255
+
+ ivug_retm_if(!pFileInfo, "data is NULL");
+ ivug_retm_if(!path, "path is NULL");
+
+ pFileInfo->longitude = calloc(1, sizeof(char)*UG_EXIF_ARR_LENGTH);
+ if(pFileInfo->longitude == NULL)
+ {
+ return;
+ }
+
+ pFileInfo->latitude = calloc(1, sizeof(char)*UG_EXIF_ARR_LENGTH);
+ if(pFileInfo->latitude == NULL)
+ {
+ return;
+ }
+
+
+ double longtitude = 0.0;
+ double latitude = 0.0;
+
+ bool bret = false;
+
+ if(pFileInfo->file_type == IVUG_DETAIL_IMAGE_TYPE) // this will be removed!!!!
+ {
+ bret = ivug_fileinfo_get_image_gps_info(path, &latitude, &longtitude);
+ }
+ else if(pFileInfo->file_type == IVUG_DETAIL_VIDEO_TYPE)
+ {
+ bret = ivug_fileinfo_get_video_gps_info(path, &latitude, &longtitude);
+ }
+
+ if ( bret == false)
+ {
+ latitude = 0;
+ longtitude = 0;
+ }
+
+ if(latitude != 0.0)
+ {
+ snprintf(pFileInfo->latitude, UG_EXIF_ARR_LENGTH, "%.5f", latitude);
+ }
+ else
+ {
+ snprintf(pFileInfo->latitude, UG_EXIF_ARR_LENGTH, "%s", IDS_UNKNOWN);
+ }
+ if(longtitude != 0.0)
+ {
+ snprintf(pFileInfo->longitude, UG_EXIF_ARR_LENGTH, "%.5f", longtitude);
+ }
+ else
+ {
+ snprintf(pFileInfo->longitude, UG_EXIF_ARR_LENGTH, "%s", IDS_UNKNOWN);
+ }
+}
+
+void
+ivug_details_info_set_resolution(ivug_file_info_t * const pFileInfo, const char *path, int stype)
+{
+ ivug_retm_if(!pFileInfo, "data is NULL");
+ ivug_retm_if(!path, "path is NULL");
+
+ MSG_DETAIL_HIGH("slide type is %d", stype);
+
+ pFileInfo->resolution = (char *)malloc(sizeof(char)*NOMAL_BUF+1);
+ if(pFileInfo->resolution == NULL)
+ {
+ return ;
+ }
+ memset(pFileInfo->resolution,0,(sizeof(char)* NOMAL_BUF + 1));
+
+
+ int width, height;
+
+ switch(stype)
+ {
+ case SLIDE_TYPE_IMAGE:
+ pFileInfo->file_type = IVUG_DETAIL_IMAGE_TYPE;
+
+ if ( ivug_fileinfo_get_image_resolution(path, &width, &height) == false)
+ {
+ snprintf(pFileInfo->resolution, NOMAL_BUF, "%s", IDS_N_A);
+ }
+ else
+ {
+ snprintf(pFileInfo->resolution, NOMAL_BUF,"%dX%d", width, height);
+ }
+
+ break;
+
+ /* Video type */
+ case SLIDE_TYPE_VIDEO:
+ pFileInfo->file_type = IVUG_DETAIL_VIDEO_TYPE;
+
+ if ( ivug_fileinfo_get_video_resolution(path, &width, &height) == false)
+ {
+ snprintf(pFileInfo->resolution, NOMAL_BUF, "%s", IDS_N_A);
+ }
+ else
+ {
+ snprintf(pFileInfo->resolution, NOMAL_BUF,"%dX%d", width, height);
+ }
+
+ break;
+
+ default:
+ break;
+
+ }
+
+}
+
+void
+ivug_details_info_set_location(ivug_file_info_t * const pFileInfo, const char *path)
+{
+ ivug_retm_if(!pFileInfo, "data is NULL");
+ ivug_retm_if(!path, "path is NULL");
+
+ pFileInfo->file_location = strdup(path);
+}
+
+void
+ivug_details_info_set_filename(ivug_file_info_t * const pFileInfo, const char *path)
+{
+ ivug_retm_if(!pFileInfo, "data is NULL");
+ ivug_retm_if(!path, "path is NULL");
+
+ /** get file name */
+ pFileInfo->filename = ecore_file_strip_ext(ecore_file_file_get(path));
+}
+
+
diff --git a/main/src/view/ivug-detail-info.h b/main/src/view/ivug-detail-info.h
new file mode 100755
index 0000000..6b7b9cb
--- /dev/null
+++ b/main/src/view/ivug-detail-info.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_DETAIL_COMMON_H__
+#define __IVUG_DETAIL_COMMON_H__
+
+#include <unicode/udat.h>
+
+#include "ivug-common.h"
+
+typedef enum {
+ IVUG_DETAIL_ERROR_TYPE = -1,
+ IVUG_DETAIL_IMAGE_TYPE,
+ IVUG_DETAIL_VIDEO_TYPE
+} ivug_detail_file_t;
+
+typedef struct {
+/** Common info*/
+ time_t date; // Seconds since 1970-1-1
+ size_t size;
+
+ ivug_detail_file_t file_type;
+
+ char *filesize;
+ char *filepath;
+ char *filename;
+ char *file_ext;
+ char *file_location;
+ char *contains;
+ char *create_date;
+
+
+/**resolution */
+ char *resolution;
+
+/**Gps info */
+ char *latitude;
+ char *longitude;
+
+}ivug_file_info_t;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// TODO : Remove dependacy ivug-detail-view and ivug-detail-info.
+
+void ivug_details_info_set_file_information(ivug_file_info_t * const pFileInfo, const char *path);
+
+void ivug_details_info_set_gps_info(ivug_file_info_t * const pFileInfo, const char *path);
+
+void ivug_details_info_set_resolution(ivug_file_info_t * const pFileInfo, const char *path, int stype);
+
+void ivug_details_info_set_location(ivug_file_info_t * const pFileInfo, const char *path);
+
+void ivug_details_info_set_filename(ivug_file_info_t * const pFileInfo, const char *path);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __IVUG_DETAIL_COMMON_H__
+
diff --git a/main/src/view/ivug-details-view.c b/main/src/view/ivug-details-view.c
new file mode 100755
index 0000000..e66df21
--- /dev/null
+++ b/main/src/view/ivug-details-view.c
@@ -0,0 +1,437 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <ui-gadget-module.h>
+
+#include "ivug-common.h"
+#include "ivug-main.h"
+#include "ivug-main-view.h"
+#include "ivug-string.h"
+
+#include "ivug-details-view.h"
+#include "ivug-detail-info.h"
+
+#include "ivug-widget.h"
+
+#define DETAILS_EDJ_FILE EDJ_PATH"/ivug-details.edj"
+#define TRANSITION_EFFECT
+
+#define FILE_DETILES_NUM 6
+#define FILE_EXIF_INFO_NUM 2
+
+
+/*
+ this structure represent one item in genlist.
+*/
+typedef struct
+{
+ char *m_ItemName;
+ Ivug_DetailsView *pDetailsView;
+} ivug_file_list_item;
+
+
+static void _ivug_details_free_file_info(ivug_file_info_t * const pFileInfo)
+{
+ if(pFileInfo->filename)
+ {
+ free(pFileInfo->filename);
+ pFileInfo->filename = NULL;
+ }
+
+ if(pFileInfo->filepath)
+ {
+ free(pFileInfo->filepath);
+ pFileInfo->filepath = NULL;
+ }
+
+ if(pFileInfo->filesize)
+ {
+ free(pFileInfo->filesize);
+ pFileInfo->filesize = NULL;
+ }
+
+ if(pFileInfo->file_ext)
+ {
+ free(pFileInfo->file_ext);
+ pFileInfo->file_ext = NULL;
+ }
+
+ if(pFileInfo->file_location)
+ {
+ free(pFileInfo->file_location);
+ pFileInfo->file_location = NULL;
+ }
+
+ if(pFileInfo->create_date)
+ {
+ free(pFileInfo->create_date);
+ pFileInfo->create_date = NULL;
+ }
+
+ if(pFileInfo->resolution)
+ {
+ free(pFileInfo->resolution);
+ pFileInfo->resolution = NULL;
+ }
+
+ if(pFileInfo->latitude)
+ {
+ free(pFileInfo->latitude);
+ pFileInfo->latitude = NULL;
+ }
+
+ if(pFileInfo->longitude)
+ {
+ free(pFileInfo->longitude);
+ pFileInfo->longitude = NULL;
+ }
+}
+
+static char *
+_ivug_details_gl_label_get(void *data, Evas_Object *obj, const char *part )
+{
+ ivug_file_list_item *params = (ivug_file_list_item *)data;
+
+ ivug_retvm_if(params == NULL, NULL, "params is NULL");
+
+ Ivug_DetailsView *pDetailsView = (Ivug_DetailsView *)params->pDetailsView;
+ ivug_retvm_if(pDetailsView == NULL, NULL, "pDetailsView is NULL");
+
+ //MSG_DETAIL_HIGH("m_ItemName is %s", params->m_ItemName);
+
+ if(strcmp(part, "elm.text.1") == 0)
+ {
+ if(params->m_ItemName)
+ {
+ return strdup(params->m_ItemName);
+
+ }
+ else
+ {
+ return strdup(IDS_UNKNOWN);
+ }
+ }
+ else if(strcmp(part, "elm.text.2")==0)
+ {
+ char *text2 = NULL;
+ if(strncmp(IDS_NAME, params->m_ItemName, strlen(IDS_NAME)) == 0)
+ {
+ text2 = pDetailsView->file_Info.filename;
+ }
+ else if(strncmp(IDS_SIZE, params->m_ItemName, strlen(IDS_SIZE)) == 0)
+ {
+ text2 = pDetailsView->file_Info.filesize;
+ }
+ else if(strncmp(IDS_FORMAT, params->m_ItemName, strlen(IDS_FORMAT)) == 0)
+ {
+ text2 = pDetailsView->file_Info.file_ext;
+ }
+ else if(strncmp(IDS_RESOLUTION, params->m_ItemName, strlen(IDS_RESOLUTION)) == 0)
+ {
+ text2 = pDetailsView->file_Info.resolution;
+ }
+ else if(strncmp(IDS_DATE_CREATED, params->m_ItemName, strlen(IDS_DATE_CREATED)) == 0)
+ {
+ text2 = pDetailsView->file_Info.create_date;
+ }
+ else if(strncmp(IDS_FILE_LOCATION, params->m_ItemName, strlen(IDS_FILE_LOCATION)) == 0)
+ {
+ text2 = pDetailsView->file_Info.file_location;
+ }
+ else if(strncmp(IDS_LATITUDE, params->m_ItemName, strlen(IDS_LATITUDE)) == 0)
+ {
+ text2 = pDetailsView->file_Info.latitude;
+ }
+ else if(strncmp(IDS_LONGITUDE, params->m_ItemName, strlen(IDS_LONGITUDE)) == 0)
+ {
+ text2 = pDetailsView->file_Info.longitude;
+ }
+
+ if (text2) {
+ return elm_entry_utf8_to_markup(text2);
+ } else {
+ return elm_entry_utf8_to_markup(IDS_UNKNOWN);
+ }
+ }
+
+ else
+ {
+ return NULL;
+ }
+
+}
+
+static void
+_ivug_details_gl_del(void *data, Evas_Object *obj )
+{
+ ivug_ret_if(NULL == data);
+
+ ivug_file_list_item *params = (ivug_file_list_item *)data;
+
+ ivug_retm_if(params == NULL, "params is NULL");
+ if(params)
+ {
+ free(params);
+ params = NULL;
+ }
+
+ return;
+}
+
+static char*
+_ivug_details_gl_label_get_title(void *data, Evas_Object *obj,const char *part )
+{
+ ivug_retv_if(NULL == data, NULL);
+
+ if (!strcmp(part, "elm.text"))
+ {
+ return strdup(data);
+ }
+
+ return NULL;
+}
+
+static Eina_Bool
+_ivug_details_gl_state_get(void *data, Evas_Object *obj, const char *part )
+{
+ return EINA_FALSE;
+}
+
+static Evas_Object *
+_ivug_details_view_genlist_create(Ivug_DetailsView *pDetailsView, Evas_Object *parent)
+{
+ IV_ASSERT(pDetailsView != NULL);
+
+ Evas_Object *genlist = NULL;
+ genlist = elm_genlist_add(parent);
+
+ ivug_retvm_if(NULL == genlist, NULL, "Create Details genlist failed..");
+
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+ elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_NONE);
+
+ elm_object_theme_set(genlist, gGetSystemTheme());
+
+ pDetailsView->file_Status.itc.item_style = "ivug/2text.2";
+ //pDetailsView->file_Status.itc.item_style = "2text.2";
+ pDetailsView->file_Status.itc.func.text_get = _ivug_details_gl_label_get;
+ pDetailsView->file_Status.itc.func.content_get = NULL;
+ pDetailsView->file_Status.itc.func.state_get = _ivug_details_gl_state_get;
+ pDetailsView->file_Status.itc.func.del = _ivug_details_gl_del;
+
+ // Set item class for dialogue group title
+ pDetailsView->file_Status.title_itc.item_style = "ivug/grouptitle";
+ //pDetailsView->file_Status.title_itc.item_style = "grouptitle";
+ pDetailsView->file_Status.title_itc.func.text_get = _ivug_details_gl_label_get_title;
+ pDetailsView->file_Status.title_itc.func.content_get = NULL;
+ pDetailsView->file_Status.title_itc.func.state_get = NULL;
+ pDetailsView->file_Status.title_itc.func.del = NULL;
+
+ pDetailsView->file_Status.multiline_itc.item_style = "ivug/multiline.2text";
+ //pDetailsView->file_Status.multiline_itc.item_style = "multiline.2text";
+ pDetailsView->file_Status.multiline_itc.func.text_get = _ivug_details_gl_label_get;
+ pDetailsView->file_Status.multiline_itc.func.content_get = NULL;
+ pDetailsView->file_Status.multiline_itc.func.state_get = NULL;
+ pDetailsView->file_Status.multiline_itc.func.del = _ivug_details_gl_del;
+
+ return genlist;
+}
+
+static void
+_ivug_detail_genlist_view_gps_create(Ivug_DetailsView *pDetailsView )
+{
+ IV_ASSERT(pDetailsView != NULL);
+
+ Evas_Object *genlist = NULL;
+ int index = 0;
+
+ Elm_Object_Item *it = NULL;
+
+ ivug_file_list_item *m_TempItem = NULL;
+
+ char *m_ItemName[FILE_EXIF_INFO_NUM] = {0,};
+
+ genlist = pDetailsView->genlist;
+
+ m_ItemName[0] = IDS_LATITUDE;
+ m_ItemName[1] = IDS_LONGITUDE;
+
+ for (index = 0; index < FILE_EXIF_INFO_NUM; index++)
+ {
+ m_TempItem = (ivug_file_list_item *)malloc(sizeof(ivug_file_list_item));
+ ivug_retm_if(NULL == m_TempItem, "m_TempItem calloc failed");
+
+ m_TempItem->m_ItemName = strdup(m_ItemName[index]);
+ m_TempItem->pDetailsView = pDetailsView;
+ it = elm_genlist_item_append(genlist, &pDetailsView->file_Status.multiline_itc, m_TempItem, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+
+}
+
+static void
+_ivug_detail_genlist_view_file_view_create(Ivug_DetailsView *pDetailsView)
+{
+ IV_ASSERT(pDetailsView != NULL);
+
+ Evas_Object *genlist = NULL;
+ int index = 0;
+
+ Elm_Object_Item *git = NULL;
+ Elm_Object_Item *it = NULL;
+
+ ivug_file_list_item *m_TempItem = NULL;
+
+ genlist = pDetailsView->genlist;
+
+ char *m_ItemName[FILE_DETILES_NUM] = {0,};
+
+ m_ItemName[0] = IDS_NAME;
+ m_ItemName[1] = IDS_FORMAT;
+ m_ItemName[2] = IDS_DATE_CREATED;
+ m_ItemName[3] = IDS_SIZE;
+ m_ItemName[4] = IDS_RESOLUTION;
+ m_ItemName[5] = IDS_FILE_LOCATION;
+
+ git = elm_genlist_item_append(genlist, &pDetailsView->file_Status.title_itc, strdup(IDS_DETAILS), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ for (index = 0; index < FILE_DETILES_NUM; index++)
+ {
+ if(m_ItemName[index] == NULL)
+ {
+ continue;
+ }
+
+ m_TempItem = (ivug_file_list_item *)malloc(sizeof(ivug_file_list_item));
+ if(m_TempItem == NULL)
+ {
+ continue;
+ }
+ memset(m_TempItem, 0, sizeof(ivug_file_list_item));
+
+ m_TempItem->m_ItemName = strdup(m_ItemName[index]);
+ m_TempItem->pDetailsView = pDetailsView;
+
+ it = elm_genlist_item_append(genlist, &pDetailsView->file_Status.multiline_itc, m_TempItem, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+}
+
+Ivug_DetailsView *
+ivug_details_view_screen_create(Evas_Object *parent, Media_Data *mdata, ivug_view_by view_by)
+{
+ ivug_retv_if(!parent, NULL);
+ ivug_retv_if(!mdata, NULL);
+ ivug_retv_if(!mdata->filepath, NULL);
+
+ char *filepath = mdata->filepath;
+ Media_Type stype = mdata->slide_type;
+
+ Ivug_DetailsView *pDetailsView = (Ivug_DetailsView *)calloc(1, sizeof(Ivug_DetailsView));
+
+ if ( pDetailsView == NULL )
+ {
+ MSG_DETAIL_FATAL("Cannot allocate memory");
+ return NULL;
+ }
+
+ ivug_details_info_set_file_information(&pDetailsView->file_Info, filepath);
+
+ ivug_details_info_set_resolution(&pDetailsView->file_Info, filepath, stype);
+ ivug_details_info_set_gps_info(&pDetailsView->file_Info, filepath);
+
+ ivug_details_info_set_filename(&pDetailsView->file_Info, filepath);
+ ivug_details_info_set_location(&pDetailsView->file_Info, filepath);
+
+// Creating GUI
+ pDetailsView->evas = evas_object_evas_get(parent);
+
+//layout
+ pDetailsView->layout = elm_layout_add(parent);
+ elm_layout_file_set(pDetailsView->layout, DETAILS_EDJ_FILE, "details_view");
+
+ if(pDetailsView->layout == NULL)
+ {
+ free(pDetailsView);
+ return NULL;
+ }
+
+#define IVUG_DETAILS_BG_ALPHA 200
+
+ pDetailsView->bg = evas_object_rectangle_add(evas_object_evas_get(pDetailsView->layout));
+ if (pDetailsView->bg)
+ {
+ evas_object_size_hint_expand_set(pDetailsView->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(pDetailsView->bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_color_set(pDetailsView->bg, IVUG_DEFAULT_BG_COLOR,
+ IVUG_DEFAULT_BG_COLOR, IVUG_DEFAULT_BG_COLOR, IVUG_DETAILS_BG_ALPHA);
+ elm_object_part_content_set(pDetailsView->layout, "details_view.swallow.bg",
+ pDetailsView->bg);
+ }
+
+ //create genlist
+ Evas_Object *genlist = NULL;
+
+ genlist = _ivug_details_view_genlist_create(pDetailsView, pDetailsView->layout);
+ pDetailsView->genlist = genlist;
+
+ _ivug_detail_genlist_view_file_view_create(pDetailsView);
+
+ _ivug_detail_genlist_view_gps_create(pDetailsView);
+
+ elm_object_part_content_set( pDetailsView->layout, "detailsview.genlist" , pDetailsView->genlist );
+
+ MSG_DETAIL_HIGH("Detail view(0x%08x) created for %s", pDetailsView, filepath);
+
+ return pDetailsView;
+}
+
+
+Evas_Object *
+ivug_details_view_object_get(Ivug_DetailsView *pDetailsView)
+{
+ IV_ASSERT(pDetailsView != NULL);
+
+ return pDetailsView->layout;
+}
+
+void
+ivug_details_view_destroy(Ivug_DetailsView *pDetailsView)
+{
+ IV_ASSERT(pDetailsView != NULL);
+ MSG_DETAIL_HIGH("Removing Details VIew");
+
+// Layout removed automatically when popping from navi item.
+ if(pDetailsView->layout)
+ {
+ evas_object_del(pDetailsView->layout);
+ pDetailsView->layout = NULL;
+ }
+
+ _ivug_details_free_file_info(&pDetailsView->file_Info);
+
+ if(pDetailsView)
+ {
+ free(pDetailsView);
+ }
+
+ pDetailsView = NULL;
+}
+
diff --git a/main/src/view/ivug-details-view.h b/main/src/view/ivug-details-view.h
new file mode 100755
index 0000000..af159d5
--- /dev/null
+++ b/main/src/view/ivug-details-view.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __DETAILS_VIEW_H__
+#define __DETAILS_VIEW_H__
+
+#include <unicode/udat.h>
+#include "ivug-data.h"
+#include "ivug-parameter.h"
+#include "ivug-detail-info.h"
+
+
+typedef struct {
+ Elm_Genlist_Item_Class itc;
+ Elm_Genlist_Item_Class title_itc;
+ Elm_Genlist_Item_Class multiline_itc;
+} ivug_file_status_t;
+
+typedef struct {
+ Evas_Object *parent;
+ Evas_Object *bg;
+
+ Evas_Object *layout;
+ Evas *evas;
+ Evas_Object *genlist;
+
+/*
+ |---------------|
+ | naviframe |
+ |---------------|
+ | |
+ | genlist |
+ | |
+ |---------------|
+*/
+
+ ivug_file_status_t file_Status; // TODO : Will remove
+ ivug_file_info_t file_Info;
+} Ivug_DetailsView;
+
+
+Ivug_DetailsView *ivug_details_view_screen_create(Evas_Object *parent, Media_Data *mdata, ivug_view_by view_by);
+
+void ivug_details_view_destroy(Ivug_DetailsView *pDetailsView);
+
+Evas_Object *ivug_details_view_object_get(Ivug_DetailsView *pDetailsView);
+
+#endif // __DETAILS_VIEW_H__
+
+
diff --git a/main/src/view/ivug-main-view.c b/main/src/view/ivug-main-view.c
new file mode 100755
index 0000000..75af879
--- /dev/null
+++ b/main/src/view/ivug-main-view.c
@@ -0,0 +1,1837 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <ui-gadget-module.h> // ug_destroy_me, ug_send_result
+#include <media-svc.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <utilX.h> // Key event
+
+#include "ivug-common.h"
+#include "ivug-parameter.h"
+
+#include "ivug-main-view.h"
+#include "ivug-util.h"
+#include "ivug-data.h"
+#include "ivug-ext-ug.h"
+#include "ivug-popup.h"
+#include "ivug-slider-item.h"
+#include "ivug-slider.h"
+#include "ivug-main.h"
+
+#include "ivug-setas-view.h"
+#include "ivug-details-view.h"
+
+#include "ivug-data.h"
+
+#define ELM_INTERNAL_API_ARGESFSDFEFC
+
+#include <elm_widget.h> // elm_selection_set
+#include <appsvc.h> // app service
+
+#undef HIDE_INDICATOR // For testing.
+
+#define CONTROL_ICON_DIRECTORY_PATH IMAGE_PATH"/01_Control icon"
+
+#define ICON_PATH_DELETE CONTROL_ICON_DIRECTORY_PATH"/T01_controlbar_icon_delete.png"
+#define ICON_PATH_SLIDESHOW CONTROL_ICON_DIRECTORY_PATH"/T01_controlbar_icon_slideshow.png"
+#define ICON_PATH_INFO CONTROL_ICON_DIRECTORY_PATH"/T01_controlbar_icon_info.png"
+
+#define ICON_PATH_OPTIONTRAY IMAGE_PATH"/T01_btn_optiontray.png"
+
+// EDJE
+#define IVUG_MAIN_EDJ EDJ_PATH"/ivug-main.edj"
+
+#define IVUG_RESPONSE_OK (1)
+
+#undef TEST_MOUSE_EVENT
+
+void
+_ivug_main_view_show_menu_bar(Ivug_MainView *pMainView);
+
+void
+_ivug_main_view_hide_menu_bar(Ivug_MainView *pMainView);
+
+static void
+_ivug_main_view_back_cb(void *data, Evas_Object *obj, void *event_info);
+
+Evas_Object *_create_tool_bar(Evas_Object *parent);
+
+static void
+_ivug_main_view_navibar_detail_cb(void *data, Evas_Object *obj, void *event_info);
+
+static void
+_ivug_main_view_navibar_detail_close_cb(void *data, Evas_Object *obj, void *event_info);
+
+static enum CTRL_BAR_TYPE
+_get_ctrl_bar_type(ivug_mode mode, Media_Type slide_type);
+static enum NAVI_BAR_TYPE
+_get_tool_bar_type(ivug_mode mode, Media_Type slide_type );
+
+#define IVUG_MAIN_DESTROY_ME(a) _ivug_main_view_destroy_me(a, __func__, __LINE__);
+
+static void
+_ivug_main_view_destroy_me(Ivug_MainView *pMainView, const char *fname, int nLine)
+{
+ ivug_ret_if(!pMainView);
+
+ MSG_MAIN_WARN("Main view request ug_destroy_me at [%s:%d]", fname, nLine);
+
+ int x = 0;
+ int y = 0;
+ int w = 0;
+ int h = 0;
+
+ MSG_MAIN_WARN("Apply event blocker");
+ pMainView->event_blocker = evas_object_rectangle_add(evas_object_evas_get(pMainView->layout));
+ evas_object_geometry_get(pMainView->layout, &x, &y, &w, &h);
+ evas_object_move(pMainView->event_blocker, x, y);
+ evas_object_resize(pMainView->event_blocker, w, h);
+ evas_object_color_set(pMainView->event_blocker, 0, 0, 0, 0);
+ evas_object_show(pMainView->event_blocker);
+
+ ug_destroy_me(pMainView->ugHandle);
+}
+
+static void
+_selection_info_deleted(void * data, Evas * e, Evas_Object * obj, void * event_info)
+{
+ ivug_retm_if(!data, "data is NULL");
+ MSG_MAIN_WARN("selection info deleted");
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ pMainView->selectioninfo = NULL;
+
+ return;
+}
+
+static inline void
+_main_view_create_selection_info(Ivug_MainView *pMainView, const char *string)
+{
+ IV_ASSERT(pMainView != NULL);
+ if(pMainView->selectioninfo)
+ {
+ evas_object_event_callback_del(pMainView->selectioninfo, EVAS_CALLBACK_DEL,
+ _selection_info_deleted);
+ evas_object_del(pMainView->selectioninfo);
+ pMainView->selectioninfo = NULL;
+ }
+ pMainView->selectioninfo = ivug_popup_selectioninfo(pMainView->layout, string);
+ ivug_retm_if(pMainView->selectioninfo == NULL, "selectioninfo is NULL");
+ evas_object_event_callback_add(pMainView->selectioninfo, EVAS_CALLBACK_DEL,
+ _selection_info_deleted, pMainView);
+}
+
+
+//copy popup
+static void
+_ivug_main_copy_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int response_id = (int)event_info;
+ IV_ASSERT(data != NULL);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ MSG_MAIN_HIGH("Copy popup response : %d", response_id);
+
+ if (pMainView->copy_popup)
+ {
+ evas_object_del(pMainView->copy_popup);
+ pMainView->copy_popup = NULL;
+ }
+ else
+ {
+ MSG_MAIN_WARN("copy popup is NULL");
+ }
+}
+
+static void
+_ivug_main_copy_popup_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ivug_ret_if(!data);
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ //get current file path.
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+
+ if (mdata == NULL)
+ {
+ MSG_MAIN_ERROR("slider data is NULL");
+ return;
+ }
+
+ char *path = NULL;
+ int len = 0;
+ // This Will add to the article
+ char buf[IVUG_MAX_FILE_PATH_LEN] = {0,};
+
+ path = mdata->filepath;
+ len = strlen(mdata->filepath)+strlen("file://")+1;
+ snprintf(buf, IVUG_MAX_FILE_PATH_LEN, "file://%s", mdata->filepath);
+
+ if (len < IVUG_MAX_FILE_PATH_LEN)
+ {
+ MSG_MAIN_HIGH("file path = %s, file url =%s", path, buf);
+ if ( pMainView->parent)
+ {
+ elm_cnp_selection_set(pMainView->layout, ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_IMAGE, buf, sizeof(buf));
+ }
+ }
+ else
+ {
+ MSG_MAIN_ERROR("slider file path is too long");
+ }
+
+ evas_object_del(pMainView->copy_popup);
+ pMainView->copy_popup = NULL;
+}
+
+Evas_Object*
+_ivug_main_create_copy_popup_create(Ivug_MainView *pMainView, int x, int y)
+{
+ ivug_retv_if(!pMainView, NULL);
+
+ Evas_Object* ctx_popup = NULL;
+ ctx_popup = elm_ctxpopup_add(pMainView->layout);
+ elm_ctxpopup_item_append(ctx_popup, IDS_COPY, NULL, _ivug_main_copy_popup_selected_cb, pMainView);
+ evas_object_smart_callback_add( ctx_popup, "hide", _ivug_main_copy_popup_response_cb, pMainView);
+
+ //evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed_cb, ctxpopup);
+ evas_object_move(ctx_popup, x, y);
+
+ evas_object_show(ctx_popup);
+
+ return ctx_popup;
+}
+
+static void
+_ivug_main_view_navibar_detail_close_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ IV_ASSERT(data != NULL);
+
+ MSG_MAIN_HIGH("ENTER : Btn detail close clicked. obj=0x%08x data=0x%08x", obj, data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ IV_ASSERT( pMainView->navi_bar != NULL);
+
+ evas_object_smart_callback_del(obj, "clicked", _ivug_main_view_navibar_detail_close_cb);
+
+ elm_object_item_part_content_unset(pMainView->navi_it, "elm.swallow.detail");
+
+ MSG_MAIN_HIGH("Delete detail view");
+ ivug_details_view_destroy(pMainView->pDetailsView); // Delete detail view.
+ pMainView->pDetailsView = NULL;
+
+// Enable detail view button callback
+ evas_object_smart_callback_add(pMainView->btn_detail, "clicked", _ivug_main_view_navibar_detail_cb, pMainView->btn_detail_data);
+ elm_object_disabled_set(pMainView->btn_detail, EINA_FALSE);
+
+ Evas_Object *btn_close = elm_object_item_part_content_unset(pMainView->navi_it, "title_right_btn");
+ evas_object_del(btn_close);
+
+ MSG_MAIN_HIGH("LEAVE : Btn detail close clicked. obj=0x%08x data=0x%08x", obj, data);
+}
+
+static void _update_title(Ivug_MainView *pMainView)
+{
+ static char title[256];
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+
+ if (mdata == NULL)
+ {
+ MSG_MAIN_ERROR("slider data is NULL");
+ return;
+ }
+
+ if ( pMainView->mode == IVUG_MODE_NORMAL)
+ {
+ snprintf(title, sizeof(title), "%d/%d",
+ ivug_slider_get_current_slide_count(pMainView->slider),
+ ivug_slider_get_total_slide_count(pMainView->slider)); //get title.
+ }
+ else if(mdata->filepath != NULL)
+ {
+ const char* filename = ivug_get_filename(mdata->filepath);
+ if(filename)
+ {
+ snprintf(title, sizeof(title), "%s", filename);
+ }
+ }
+
+ IV_ASSERT(pMainView->navi_bar != NULL);
+
+ MSG_MAIN_HIGH("Update title : %s", title);
+
+ elm_object_item_text_set(pMainView->navi_it, title);
+
+}
+
+static void
+_ivug_main_view_navibar_detail_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("ENTER : Btn detail view clicked. obj=0x%08x data=0x%08x", obj, data);
+ ivug_ret_if(!obj||!data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ if(pMainView->pDetailsView)
+ {
+ MSG_MAIN_ERROR("details view already created");
+ return;
+ }
+
+ pMainView->btn_detail_data = evas_object_smart_callback_del(obj, "clicked", _ivug_main_view_navibar_detail_cb);
+ pMainView->btn_detail = obj;
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+
+ if (mdata == NULL)
+ {
+ MSG_MAIN_ERROR("slider data is NULL");
+ return;
+ }
+
+ pMainView->pDetailsView = ivug_details_view_screen_create(pMainView->navi_bar, mdata, pMainView->view_by);
+
+ if(!pMainView->pDetailsView)
+ {
+ MSG_MAIN_ERROR("create details view failed");
+ return;
+ }
+
+ elm_object_item_part_content_set(pMainView->navi_it, "elm.swallow.detail", ivug_details_view_object_get(pMainView->pDetailsView));
+
+// Transition effect does not comming ocassionally when instant mode is used.
+// evas_object_smart_callback_add(pMainView->navi_bar, "transition,finished", _ivug_main_view_details_transit_finished_cb, pMainView);
+ PERF_CHECK_BEGIN(LVL1 "Update title");
+
+ _update_title(pMainView);
+
+ PERF_CHECK_END(LVL1 "Update title");
+
+ _ctrl_bar_type ctrlbar_type;
+ ctrlbar_type = _get_ctrl_bar_type(pMainView->mode, mdata->slide_type);
+ if(ctrlbar_type == CTRL_BAR_TYPE_FILE || ctrlbar_type == CTRL_BAR_TYPE_CAMERA_IMAGE
+ || ctrlbar_type == CTRL_BAR_TYPE_CAMERA_VIDEO)
+ {
+ MSG_MAIN_HIGH("Disable details button ");
+
+ /* Disable details button in controlbar */
+ if(pMainView->ctrl_bar_item[1])
+ elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_TRUE);
+ }
+ else if(ctrlbar_type == CTRL_BAR_TYPE_IMAGE || ctrlbar_type == CTRL_BAR_TYPE_VIDEO)
+ {
+ /* Disable details button in controlbar */
+ if(pMainView->ctrl_bar_item[2])
+ elm_object_item_disabled_set(pMainView->ctrl_bar_item[2], EINA_TRUE);
+ }
+
+ MSG_MAIN_HIGH("LEAVE : Btn detail view clicked. obj=0x%08x data=0x%08x", obj, data);
+}
+
+#define ZOOM_LEVEL_STEP (0.7)
+#define ZOOM_LEVEL_MAX (3)
+
+static void _show_zoom_icon(void *data)
+{
+ ivug_ret_if(!data);
+
+ MSG_MAIN_ERROR("_show_zoom_icon");
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ if(!sitem)
+ {
+ MSG_MAIN_ERROR("sitem is NULL");
+ return;
+ }
+
+ if(sitem->zoom_level == 0)
+ {
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,disable","elm");
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,enable","elm");
+ }
+ else if(sitem->zoom_level == ZOOM_LEVEL_MAX)
+ {
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,disable","elm");
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,enable","elm");
+ }
+ else
+ {
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,enable","elm");
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,enable","elm");
+ }
+}
+
+static void
+_ivug_main_view_zoom_out_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ ivug_ret_if(!obj);
+ ivug_ret_if(!data);
+
+ MSG_MAIN_ERROR("_ivug_main_view_zoom_out_cb");
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ if(!sitem)
+ {
+ MSG_MAIN_ERROR("sitem is NULL");
+ return;
+ }
+
+ if(sitem->zoom_level == 0)
+ {
+ MSG_MAIN_ERROR("zoom_level is 0");
+ return;
+ }
+
+ double zoom = 0.0;
+ Evas_Coord ix = 0, iy= 0, iw= 0, ih= 0;
+
+ evas_object_geometry_get(sitem->photocam, &ix, &iy, &iw, &ih);
+
+ zoom = ivug_slider_item_zoom_get(sitem);
+ zoom /= ZOOM_LEVEL_STEP;
+ ivug_slider_item_zoom_set(sitem, zoom, iw/2, ih/2);
+
+ ivug_slider_item_hold_set(sitem, EINA_FALSE);
+
+ sitem->zoom_level--;
+
+ _show_zoom_icon(data);
+}
+
+static void
+_ivug_main_view_zoom_in_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ ivug_ret_if(!obj);
+ ivug_ret_if(!data);
+
+ MSG_MAIN_ERROR("_ivug_main_view_zoom_in_cb");
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ if(!sitem)
+ {
+ MSG_MAIN_ERROR("sitem is NULL");
+ return;
+ }
+
+ if(sitem->zoom_level > ZOOM_LEVEL_MAX)
+ {
+ MSG_MAIN_ERROR("zoom_level is %d", sitem->zoom_level);
+ return;
+ }
+
+ double zoom = 0.0;
+ Evas_Coord ix = 0, iy= 0, iw= 0, ih= 0;
+
+ evas_object_geometry_get(sitem->photocam, &ix, &iy, &iw, &ih);
+
+ zoom = ivug_slider_item_zoom_get(sitem);
+ zoom *= ZOOM_LEVEL_STEP;
+ ivug_slider_item_zoom_set(sitem, zoom, iw/2, ih/2);
+
+ ivug_slider_item_hold_set(sitem, EINA_FALSE);
+
+ sitem->zoom_level++;
+
+ _show_zoom_icon(data);
+}
+
+static void
+_ivug_main_view_update_details_item(Ivug_MainView *pMainView)
+{
+ ivug_retm_if(!pMainView, "pMainView is NULL");
+ ivug_retm_if(!pMainView->slider, "pMainView->slider is NULL");
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ if(!sitem)
+ {
+ MSG_MAIN_ERROR("sitem is NULL");
+ return;
+ }
+
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+ if(!mdata)
+ {
+ MSG_MAIN_ERROR("mdata is NULL");
+ return;
+ }
+
+ _ctrl_bar_type ctrlBarType;
+ ctrlBarType = _get_ctrl_bar_type(pMainView->mode, mdata->slide_type);
+ if(ctrlBarType == CTRL_BAR_TYPE_FILE || ctrlBarType == CTRL_BAR_TYPE_CAMERA_IMAGE ||
+ ctrlBarType == CTRL_BAR_TYPE_CAMERA_VIDEO)
+ {
+ /* Enable details button in control bar*/
+ if(pMainView->ctrl_bar_item[1])
+ elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_FALSE);
+ }
+ else if(ctrlBarType == CTRL_BAR_TYPE_IMAGE || ctrlBarType == CTRL_BAR_TYPE_VIDEO)
+ {
+ /* Enable details button in control bar*/
+ if(pMainView->ctrl_bar_item[2])
+ elm_object_item_disabled_set(pMainView->ctrl_bar_item[2], EINA_FALSE);
+ }
+}
+
+static void
+_ivug_main_view_delete_photo_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ IVUG_FUNC_ENTER();
+ ivug_ret_if(!obj||!data||!event_info);
+
+ int response_id = (int)event_info;
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+ if ( response_id == POPUP_RESPONSE_OK )
+ {
+ MSG_MAIN_HIGH("Removing current slide.");
+
+ if(pMainView->pDetailsView)
+ {
+ MSG_MAIN_HIGH("Exit details view");
+ _ivug_main_view_navibar_detail_close_cb(pMainView, NULL, NULL);
+
+ _ivug_main_view_update_details_item(pMainView);
+ }
+
+ ivug_slider_delete_current_slide(pMainView->slider);
+ }
+
+ evas_object_del(obj); //delete popup
+
+}
+
+static void
+_ivug_main_view_ctrlbar_delete_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ IVUG_FUNC_ENTER();
+ ivug_ret_if(!obj||!data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ ivug_popup_question(pMainView->layout, NULL,
+ IDS_DELETE_MSG, _ivug_main_view_delete_photo_cb, pMainView);
+
+ IVUG_FUNC_LEAVE();
+ return;
+}
+
+static void
+_ivug_main_view_ctrlbar_slide_show_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("Start slide show");
+
+ IV_ASSERT(data != NULL);
+ ivug_ret_if(!event_info);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ Elm_Object_Item *ctrl_bar_item = (Elm_Object_Item *)event_info;
+
+ if(elm_object_item_disabled_get(ctrl_bar_item) == EINA_TRUE)
+ {
+ MSG_MAIN_WARN("Slide show already started");
+ return;
+ }
+
+ elm_object_item_disabled_set(ctrl_bar_item, EINA_TRUE);
+
+ if(pMainView->pDetailsView) {
+ MSG_MAIN_HIGH("Exit details view");
+ _ivug_main_view_navibar_detail_close_cb(pMainView, NULL, NULL);
+ }
+
+ ivug_prohibit_lcd_off();
+
+ _ivug_main_view_hide_menu_bar(pMainView);
+
+ ivug_slider_start_slide_show(pMainView->slider, EINA_TRUE);
+
+}
+
+
+static void
+_ivug_main_view_back_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ivug_ret_if(!obj||!data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+ ivug_retm_if(!pMainView->navi_bar, "%s", "navigation value is NULL");
+
+ MSG_MAIN_WARN("Back key pressed");
+
+ if( pMainView->pDetailsView == NULL) // Detail view is not showed,.
+ {
+ evas_object_smart_callback_del(pMainView->back_btn, "clicked", _ivug_main_view_back_cb);
+ IVUG_MAIN_DESTROY_ME(pMainView);
+ return;
+ }
+
+ /* Back from details view */
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ ivug_retm_if(!sitem, "sitem is NULL");
+
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+ ivug_retm_if(!mdata, "mdata is NULL");
+
+ _ctrl_bar_type ctrlBarType;
+ ctrlBarType = _get_ctrl_bar_type(pMainView->mode, mdata->slide_type);
+ if(ctrlBarType == CTRL_BAR_TYPE_FILE ||
+ ctrlBarType == CTRL_BAR_TYPE_CAMERA_IMAGE ||
+ ctrlBarType == CTRL_BAR_TYPE_CAMERA_VIDEO)
+ {
+ // In case that called by my file, camera, UG doest not removed.
+ _ivug_main_view_navibar_detail_close_cb(pMainView, NULL, NULL);
+
+ MSG_MAIN_HIGH("Enable details button");
+ if(pMainView->ctrl_bar_item[1])
+ elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_FALSE);
+
+ return;
+ }
+ else if(ctrlBarType == CTRL_BAR_TYPE_IMAGE || ctrlBarType == CTRL_BAR_TYPE_VIDEO)
+ {
+ // In case that called by my file, camera, UG doest not removed.
+ _ivug_main_view_navibar_detail_close_cb(pMainView, NULL, NULL);
+
+ MSG_MAIN_HIGH("Enable details button");
+ if(pMainView->ctrl_bar_item[2])
+ elm_object_item_disabled_set(pMainView->ctrl_bar_item[2], EINA_FALSE);
+ }
+ else // otherwise, from gallery, ug will be terminated
+ {
+ evas_object_smart_callback_del(pMainView->back_btn, "clicked", _ivug_main_view_back_cb);
+ IVUG_MAIN_DESTROY_ME(pMainView);
+ return;
+ }
+}
+
+
+
+static void
+_send_result(struct ui_gadget *ug, bool selected)
+{
+//result bundle key
+#define IVUG_RESULT_BUNDLE_KEY_SELECTION_RESULT "Result"
+
+//result bundle value
+#define IVUG_RESULT_BUNDLE_VALUE_OK "Ok"
+#define IVUG_RESULT_BUNDLE_VALUE_CANCEL "Cancel"
+
+ ivug_ret_if(!ug);
+
+ bundle *b;
+ b = bundle_create();
+
+ if (selected)
+ {
+ bundle_add(b, IVUG_RESULT_BUNDLE_KEY_SELECTION_RESULT, IVUG_RESULT_BUNDLE_VALUE_OK);
+ }
+ else
+ {
+ bundle_add(b, IVUG_RESULT_BUNDLE_KEY_SELECTION_RESULT, IVUG_RESULT_BUNDLE_VALUE_CANCEL);
+ }
+
+ ug_send_result(ug, b);
+
+ bundle_free(b);
+}
+
+
+//select button
+void
+_ivug_main_view_select_ok_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("Select OK");
+ ivug_ret_if(!obj||!data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ //send result.
+ _send_result(pMainView->ugHandle, true);
+
+ IVUG_MAIN_DESTROY_ME(pMainView);
+}
+
+void
+_ivug_main_view_select_cancel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("Select Cancel");
+
+ ivug_ret_if(!obj||!data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ //send result.
+ _send_result(pMainView->ugHandle, false);
+
+ IVUG_MAIN_DESTROY_ME(pMainView);
+}
+
+
+static bool _is_mmc_inserted(void)
+{
+ int noti_message;
+ int ret = -1;
+
+ ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &noti_message);
+
+ if ( ret != 0 ) // falied
+ {
+ MSG_NOTI_ERROR("Get %s is failed", VCONFKEY_SYSMAN_MMC_STATUS);
+ return false;
+ }
+
+ if(noti_message==VCONFKEY_SYSMAN_MMC_MOUNTED)
+ {
+ return true;
+ }
+
+ return false;
+
+}
+
+static Eina_Bool _key_down_cb(void *user_data, int type, void *event)
+{
+ if (!user_data) {
+ MSG_IMAGEVIEW_ERROR("user data is NULL");
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ Ecore_Event_Key *key_event = (Ecore_Event_Key *) event;
+
+ Ivug_MainView *main_view = (Ivug_MainView *)user_data;
+
+ MSG_IMAGEVIEW_HIGH("Key down : %s", key_event->keyname);
+
+ if (!strcmp(key_event->keyname, KEY_END))
+ {
+ MSG_IMAGEVIEW_HIGH("Bakc(End) key");
+ }
+ else if (!strcmp(key_event->keyname, KEY_SELECT))
+ {
+ MSG_IMAGEVIEW_HIGH("Home key");
+ }
+ else if (!strcmp(key_event->keyname, KEY_POWER))
+ {
+ MSG_IMAGEVIEW_HIGH("Power key");
+ ivug_slider_stop_slide_show(main_view->slider);
+ }
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool _on_exit_timer_expired(void *data)
+{
+ ivug_retv_if(!data, ECORE_CALLBACK_CANCEL);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ pMainView->exit_timer = NULL;
+
+ IVUG_MAIN_DESTROY_ME(pMainView);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void _on_mmc_state_changed(keynode_t* node, void *data)
+{
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ if(_is_mmc_inserted() == false )
+ {
+ MSG_IMAGEVIEW_WARN("MMC Removed!. Request destroy UG=0x%08x", gGetUGHandle());
+
+ if ( pMainView->ext_ug )
+ {
+ MSG_IMAGEVIEW_HIGH("Extern UG is running");
+ }
+
+ ivug_show_popup(pMainView->layout, IDS_ERROR, IDS_SD_CARD_REMOVED, NULL, NULL);
+ pMainView->exit_timer = ecore_timer_add(0.2, _on_exit_timer_expired, data);
+ }
+}
+
+static enum NAVI_BAR_TYPE
+_get_tool_bar_type(ivug_mode mode, Media_Type slide_type )
+{
+ enum NAVI_BAR_TYPE tool_bar_type = NAVI_BAR_TYPE_NONE;
+
+ //calc navi bar style , temporary code.
+ static const char *szType[] = {
+ "[ INVALID ]",
+ "[ ]",
+ "[Set, Info]",
+ "[Ok, Cancel]",
+ };
+
+
+ switch (mode)
+ {
+ case IVUG_MODE_NORMAL:
+ tool_bar_type = NAVI_BAR_TYPE_EMPTY;
+ if (slide_type == SLIDE_TYPE_IMAGE)
+ {
+ tool_bar_type = NAVI_BAR_TYPE_IMAGE;
+ }
+ else if (slide_type == SLIDE_TYPE_VIDEO)
+ {
+ tool_bar_type = NAVI_BAR_TYPE_VIDEO;
+ }
+ else
+ {
+ tool_bar_type = NAVI_BAR_TYPE_EMPTY;
+ }
+ break;
+ case IVUG_MODE_SINGLE:
+ case IVUG_MODE_FILE:
+ tool_bar_type = NAVI_BAR_TYPE_EMPTY;
+
+ break;
+ case IVUG_MODE_DISPLAY:
+ tool_bar_type = NAVI_BAR_TYPE_SELECT;
+
+ break;
+ case IVUG_MODE_CAMERA:
+ tool_bar_type = NAVI_BAR_TYPE_EMPTY;
+ break;
+ default:
+ MSG_MAIN_ERROR("Unhandled mode : %d", mode);
+ tool_bar_type = NAVI_BAR_TYPE_EMPTY;
+
+ break;
+ }
+
+ MSG_MAIN_MED("Mode=%d Slide=%d ToolBar=%s", mode, slide_type, szType[tool_bar_type]);
+
+ return tool_bar_type;
+}
+
+
+static enum CTRL_BAR_TYPE
+_get_ctrl_bar_type(ivug_mode mode, Media_Type slide_type)
+{
+ // this is temporary code.
+ enum CTRL_BAR_TYPE type = CTRL_BAR_TYPE_FILE;
+
+ static const char *szType[] = {
+ "[ Invalid ]",
+ "[ None ]",
+ "[Delete,Info]",
+ "[Delete,Info]",
+ "[Delete,Info]",
+ "[Delete,Slide show]",
+ "[Delete,Slide show]",
+ };
+
+ switch (mode)
+ {
+ case IVUG_MODE_NORMAL:
+ if (slide_type == SLIDE_TYPE_IMAGE)
+ {
+ type = CTRL_BAR_TYPE_IMAGE;
+ }
+ else if (slide_type == SLIDE_TYPE_VIDEO)
+ {
+ type = CTRL_BAR_TYPE_VIDEO;
+ }
+ else if (slide_type == SLIDE_TYPE_UNKNOWN)
+ {
+ type = CTRL_BAR_TYPE_IMAGE; // TODO : Need to check. when web image is invalid????
+ }
+ else
+ {
+ MSG_MAIN_ERROR("Unhandled slide type : %d", slide_type);
+ type = CTRL_BAR_TYPE_FILE;
+ }
+ break;
+ case IVUG_MODE_SINGLE:
+ case IVUG_MODE_FILE:
+ type = CTRL_BAR_TYPE_FILE;
+ break;
+ case IVUG_MODE_CAMERA:
+ if (slide_type == SLIDE_TYPE_IMAGE)
+ {
+ type = CTRL_BAR_TYPE_CAMERA_IMAGE;
+ }
+ else if (slide_type == SLIDE_TYPE_VIDEO)
+ {
+ type = CTRL_BAR_TYPE_CAMERA_VIDEO;
+ }
+ else
+ {
+ MSG_MAIN_ERROR("Unhandled slide type : %d", slide_type);
+ type = CTRL_BAR_TYPE_FILE;
+ }
+ break;
+ case IVUG_MODE_DISPLAY:
+ type = CTRL_BAR_TYPE_EMPTY;
+ break;
+ default:
+ MSG_MAIN_ERROR("Unhandled mode : %d", mode);
+ type = CTRL_BAR_TYPE_FILE;
+ }
+
+ MSG_MAIN_MED("Mode=%d Slide=%d CtrlBar=%s", mode, slide_type, szType[type]);
+
+ return type;
+
+}
+
+Evas_Object *_create_ctrl_bar(Evas_Object *parent, Elm_Theme *th)
+{
+ Evas_Object *toolbar = elm_toolbar_add(parent);
+
+//create control bar
+ if (toolbar == NULL)
+ {
+ MSG_MAIN_ERROR("controlbar create failed");
+ return NULL;
+ }
+
+ elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
+
+#ifdef USE_CUSTOM_STYLE
+ elm_object_theme_set(toolbar, th);
+
+ char *ctrlStyle = NULL;
+
+ ctrlStyle = "ivug-toolbar/default";
+
+ Eina_Bool bstyle = elm_object_style_set(toolbar, ctrlStyle);
+ MSG_MAIN_HIGH("toolbar elm_object_style_set result = %d", bstyle);
+#endif
+
+ MSG_MAIN_HIGH("Create ctrl_bar. Obj=0x%08x", toolbar);
+
+ return toolbar;
+
+}
+
+void
+_update_tool_bar(Ivug_MainView *pMainView, enum NAVI_BAR_TYPE barType)
+{
+
+/*
+ |-------------------|
+ |naviframe(tool_bar)|
+ |-------------------|
+ | |
+ | |
+ | |
+ | |
+ |-------------------|
+ | ctrl_bar |
+ |-------------------|
+*/
+
+ MSG_MAIN_HIGH("Update tool_bar. Type=%d", barType);
+//remove old control bar item.
+ int i = 0;
+
+ for ( i = 0 ; i < MAX_NAVI_ITEM_CNT ; i ++)
+ {
+ if (pMainView->tool_bar_item[i])
+ {
+ evas_object_del(pMainView->tool_bar_item[i]);
+ pMainView->tool_bar_item[i] = NULL;
+ }
+ }
+
+ if ( barType != NAVI_BAR_TYPE_SELECT )
+ {
+ /* other type don't need toolbar */
+ return;
+ }
+
+ pMainView->tool_bar_item[0] = ivug_button_add(pMainView->navi_bar, "naviframe/title/default" , IDS_OK,
+ NULL, _ivug_main_view_select_ok_cb, pMainView );
+
+ pMainView->tool_bar_item[1] = ivug_button_add(pMainView->navi_bar, "naviframe/title/default" , IDS_CANCEL,
+ NULL, _ivug_main_view_select_cancel_cb, pMainView );
+
+ elm_object_item_part_content_set(pMainView->navi_it, "title_left_btn", pMainView->tool_bar_item[0]);
+ elm_object_item_part_content_set(pMainView->navi_it, "title_right_btn", pMainView->tool_bar_item[1]);
+
+ pMainView->option_show = EINA_TRUE;
+}
+
+
+
+void
+_update_ctrl_bar(Ivug_MainView *pMainView, enum CTRL_BAR_TYPE barType)
+{
+ MSG_MAIN_HIGH("Update ctrl_bar. barType=%d", barType);
+
+//remove old control bar item.
+ Evas_Object* ctrl_bar = pMainView->ctrl_bar;
+
+ int i = 0;
+
+ for ( i = 0 ; i < MAX_CTRL_ITEM_CNT ; i ++)
+ {
+ if (pMainView->ctrl_bar_item[i])
+ {
+ elm_object_item_del(pMainView->ctrl_bar_item[i]);
+ pMainView->ctrl_bar_item[i] = NULL;
+ }
+ }
+
+/*
+ IVUG_MODE_NORMAL =>
+ Depends on content
+ Image [Delete, Slide show, Detail] -> CTRL_BAR_TYPE_IMAGE
+ Video [Delete, Slide show, Detail] -> CTRL_BAR_TYPE_VIDEO
+
+ IVUG_MODE_SINGLE, IVUG_MODE_FILE, => CTRL_BAR_TYPE_FILE [Delete,Info]
+ IVUG_MODE_DISPLAY => CTRL_BAR_TYPE_EMPTY
+
+ if ((mode == IVUG_MODE_FILE) || (mode == IVUG_MODE_SINGLE))
+ barType == CTRL_BAR_TYPE_FILE
+
+*/
+ switch(barType)
+ {
+ case CTRL_BAR_TYPE_FILE:
+ pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
+ pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
+ break;
+
+ case CTRL_BAR_TYPE_CAMERA_IMAGE:
+ pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
+ pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
+ break;
+
+ case CTRL_BAR_TYPE_CAMERA_VIDEO:
+ pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
+ pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
+ break;
+
+ case CTRL_BAR_TYPE_IMAGE:
+ pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
+ pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_SLIDESHOW, NULL, _ivug_main_view_ctrlbar_slide_show_cb, pMainView);
+ pMainView->ctrl_bar_item[2] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
+ break;
+
+ case CTRL_BAR_TYPE_VIDEO:
+ pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
+ pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_SLIDESHOW, NULL, _ivug_main_view_ctrlbar_slide_show_cb, pMainView);
+ pMainView->ctrl_bar_item[2] = elm_toolbar_item_append(ctrl_bar,
+ ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
+ break;
+
+ default:
+ MSG_MAIN_ERROR("Unhandled ctrl bar type=%d", barType);
+ break;
+ }
+
+}
+
+static void _update_main_view(Ivug_MainView *pMainView, Slide_Item *sitem)
+{
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+ if(mdata == NULL)
+ {
+ MSG_MAIN_ERROR("mdata is NULL");
+ return;
+ }
+
+ PERF_CHECK_BEGIN(LVL6 "Set menu title");
+
+ _update_title(pMainView);
+
+ PERF_CHECK_END(LVL6 "Set menu title");
+
+ if(pMainView->pDetailsView)
+ {
+ MSG_MAIN_ERROR("In details view, skip update toolbar/controlbar");
+ return;
+ }
+
+ enum CTRL_BAR_TYPE ctrlBarType;
+ enum NAVI_BAR_TYPE toolBarType;
+
+ ctrlBarType = _get_ctrl_bar_type(pMainView->mode, mdata->slide_type);
+ toolBarType = _get_tool_bar_type(pMainView->mode, mdata->slide_type);
+
+ if ( toolBarType != pMainView->tool_bar_type ) // when change toolbar Type
+ {
+ PERF_CHECK_BEGIN(LVL6 "add toolbar item");
+
+ MSG_MAIN_HIGH("ToolBar update. Old=%d Cur=%d", toolBarType , pMainView->tool_bar_type);
+ _update_tool_bar(pMainView, toolBarType);
+ pMainView->tool_bar_type = toolBarType;
+
+ PERF_CHECK_END(LVL6 "add toolbar item");
+ }
+
+ if ( ctrlBarType != pMainView->ctrl_bar_type ) // when change ctrlbar Type
+ {
+ PERF_CHECK_BEGIN(LVL6 "add contolbar item");
+
+ MSG_MAIN_HIGH("CtrlBar update. Old=%d Cur=%d", ctrlBarType , pMainView->ctrl_bar_type);
+ _update_ctrl_bar(pMainView, ctrlBarType);
+ pMainView->ctrl_bar_type = ctrlBarType;
+
+ PERF_CHECK_END(LVL6 "add contolbar item");
+ }
+
+// If Inavalid image, disable all buttons.
+
+ slide_state_t state = ivug_slider_item_get_state(sitem);
+
+ Elm_Object_Item *item = NULL;
+ if ( state == SLIDE_STATE_ERROR)
+ {
+ const char *item_label = NULL;
+ Evas_Object *object = NULL;
+
+ /* Disable all toolbar items */
+ int i = 0;
+ for(i=0; i<MAX_NAVI_ITEM_CNT; i++)
+ {
+ if(pMainView->tool_bar_item[i] && (item_label = elm_object_text_get(pMainView->tool_bar_item[i])) )
+ {
+ if(!strncmp(item_label, IDS_DETAILS, strlen(item_label)))
+ {
+ MSG_MAIN_HIGH("Skip %s", item_label);
+ continue;
+ }
+ }
+ elm_object_disabled_set(pMainView->tool_bar_item[i], EINA_TRUE);
+ }
+
+ /* Disable all controlbar items */
+#ifdef _USE_LABEL_
+ item = elm_toolbar_first_item_get(pMainView->ctrl_bar);
+ for(; item!=NULL; item=elm_toolbar_item_next_get(item)){
+ item_label = elm_object_item_text_get(item);
+ if(item_label && (!strncmp(item_label, IDS_DELETE, strlen(item_label)) ||
+ !strncmp(item_label, IDS_DETAILS, strlen(item_label)) ||
+ !strncmp(item_label, IDS_SLIDE_SHOW, strlen(item_label))))
+ {
+ MSG_MAIN_HIGH("Skip %s", item_label);
+ continue;
+ }
+
+ elm_object_item_disabled_set(item, EINA_TRUE);
+ }
+#else
+ const char *icon_file = NULL;
+ item = elm_toolbar_first_item_get(pMainView->ctrl_bar);
+ for(; item!=NULL; item=elm_toolbar_item_next_get(item))
+ {
+ object = elm_toolbar_item_icon_object_get(item);
+ if(!object)
+ continue;
+
+ elm_icon_file_get(object, &icon_file, NULL);
+
+ if(icon_file && (!strncmp(icon_file, ICON_PATH_DELETE, strlen(icon_file)) ||
+ !strncmp(icon_file, ICON_PATH_INFO, strlen(icon_file)) ||
+ !strncmp(icon_file, ICON_PATH_SLIDESHOW, strlen(icon_file))))
+ {
+ MSG_MAIN_HIGH("Skip %s", icon_file);
+ continue;
+ }
+
+ elm_object_item_disabled_set(item, EINA_TRUE);
+ }
+#endif
+ return ;
+ }
+ else
+ {
+ int i = 0;
+ /* Enable all toolbar items */
+ for(i=0; i<MAX_NAVI_ITEM_CNT; i++)
+ {
+ if(pMainView->tool_bar_item[i])
+ {
+ elm_object_disabled_set(pMainView->tool_bar_item[i], EINA_FALSE);
+ }
+ }
+
+ /* Enable all controlbar items */
+ item = elm_toolbar_first_item_get(pMainView->ctrl_bar);
+ for(; item!=NULL; item=elm_toolbar_item_next_get(item))
+ {
+ elm_object_item_disabled_set(item, EINA_FALSE);
+ }
+ }
+
+ if(mdata->slide_type == SLIDE_TYPE_IMAGE)
+ {
+ _show_zoom_icon(pMainView);
+ }
+ else
+ {
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,hide","elm");
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,hide","elm");
+ }
+}
+
+void
+_ivug_main_view_show_menu_bar(Ivug_MainView *pMainView)
+{
+ MSG_MAIN_HIGH("Show Menu");
+
+ pMainView->bShowMenu = EINA_TRUE;
+ evas_object_show(pMainView->ctrl_bar);
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+
+ _update_main_view(pMainView, sitem);
+
+#ifdef HIDE_INDICATOR
+ elm_win_indicator_mode_set(ug_get_window(), ELM_WIN_INDICATOR_HIDE);
+#else
+ elm_win_indicator_mode_set(ug_get_window(), ELM_WIN_INDICATOR_SHOW);
+#endif
+
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+ if(mdata == NULL)
+ {
+ MSG_MAIN_ERROR("mdata is NULL");
+ return;
+ }
+
+ if(mdata->slide_type == SLIDE_TYPE_IMAGE)
+ {
+ _show_zoom_icon(pMainView);
+ }
+
+ elm_naviframe_item_title_visible_set(pMainView->navi_it, EINA_TRUE);
+ elm_object_item_signal_emit(pMainView->navi_it, "elm,state,controlbar,open", "");
+
+#ifdef TEST_MOUSE_EVENT
+ Eina_List *l = evas_object_clipees_get(pMainView->navi_bar);
+
+ MSG_MAIN_HIGH("Clipper clips %i objects", eina_list_count(l));
+
+ Evas_Object *obj;
+ Eina_List *l1;
+
+ EINA_LIST_FOREACH(l, l1, obj)
+ {
+
+ MSG_MAIN_HIGH("Object Type : %s", evas_object_name_get(obj));
+
+ }
+ Evas_Object *above;
+ Evas_Object *below;
+
+
+ above = evas_object_above_get(pMainView->navi_bar);
+ MSG_MAIN_HIGH("Navi Above : 0x%08x %s %s", above, evas_object_name_get(above), evas_object_type_get(above));
+
+ below = evas_object_below_get(pMainView->navi_bar);
+ MSG_MAIN_HIGH("Navi Below : 0x%08x %s %s", below, evas_object_name_get(below), evas_object_type_get(below));
+
+ above = evas_object_above_get(pMainView->slider);
+ MSG_MAIN_HIGH("Slider Above : 0x%08x %s %s", above, evas_object_name_get(above), evas_object_type_get(above));
+
+ below = evas_object_below_get(pMainView->slider);
+ MSG_MAIN_HIGH("Slider Below : 0x%08x %s %s", below, evas_object_name_get(below), evas_object_type_get(below));
+#endif
+
+
+}
+
+
+void
+_ivug_main_view_hide_menu_bar(Ivug_MainView *pMainView)
+{
+ MSG_MAIN_HIGH("Hide Menu");
+
+ pMainView->bShowMenu = EINA_FALSE;
+ elm_widget_disabled_set(pMainView->ctrl_bar, EINA_TRUE);
+
+ elm_win_indicator_mode_set(ug_get_window(), ELM_WIN_INDICATOR_HIDE);
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,hide","elm");
+ edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,hide","elm");
+ elm_naviframe_item_title_visible_set(pMainView->navi_it, EINA_FALSE);
+ elm_object_item_signal_emit(pMainView->navi_it, "elm,state,controlbar,close", "");
+}
+
+
+static void
+_ivug_main_view_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("Main View Clicked");
+ IV_ASSERT(data != NULL);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+// TODO : Bug. menu bar is blinking when stopping slide show.
+ if (pMainView->bShowMenu)
+ {
+ _ivug_main_view_hide_menu_bar(pMainView);
+ }
+ else
+ {
+ _ivug_main_view_show_menu_bar(pMainView);
+ }
+
+}
+
+static void
+_ivug_main_view_icon_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("Main View Video icon Clicked");
+ IV_ASSERT(data != NULL);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+
+ if (mdata == NULL)
+ {
+ MSG_MAIN_ERROR("slide data is NULL");
+ return;
+ }
+
+ if (pMainView->mode == IVUG_MODE_FILE || pMainView->mode == IVUG_MODE_DISPLAY || pMainView->mode == IVUG_MODE_SINGLE )
+ {
+ MSG_MAIN_HIGH("Launching simple video player. Mode=%d", pMainView->mode);
+ ivug_ext_aul_launch(pMainView->layout, IVUG_EXT_AUL_SIMPLE_VIDEOPLAYER, mdata->filepath, NULL);
+ }
+ else
+ {
+ MSG_MAIN_HIGH("Launching normal video player");
+ ivug_ext_aul_launch(pMainView->layout, IVUG_EXT_AUL_VIDEOPLAYER, mdata->filepath, NULL);
+ }
+
+}
+
+static void
+_ivug_main_view_long_pressed(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Coord_Point* down_pose = (Evas_Coord_Point*)event_info;
+ ivug_ret_if(!data||!down_pose);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ MSG_MAIN_HIGH("LongPressed XY(%d,%d)", down_pose->x, down_pose->y);
+
+ int x = down_pose->x;
+ int y = down_pose->y;
+
+ Slide_Item *si = ivug_slider_get_current_slide_item(pMainView->slider);
+ IV_ASSERT(si != NULL);
+
+ if ( ivug_slider_item_get_state(si) != SLIDE_STATE_LOADED)
+ {
+ MSG_MAIN_ERROR("Long pressed. but state is not ready");
+ return;
+ }
+
+ pMainView->copy_popup = _ivug_main_create_copy_popup_create(pMainView, x, y);
+ if (pMainView->copy_popup == NULL)
+ {
+ IVUG_DEBUG_WARNING("copy popup create failed");
+ return ;
+ }
+
+}
+
+
+static void
+_ivug_main_view_slider_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("Image slider changed callback. ");
+
+ ivug_ret_if(!data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+ Slide_Item *sitem = (Slide_Item *)event_info;
+
+ if ( sitem == NULL || sitem->mitem == NULL)
+ {
+ // There is no item existed. terminate UG
+ MSG_MAIN_ERROR("No item is remained. exit UG. Sitem=0x%08x", sitem);
+ IVUG_MAIN_DESTROY_ME(pMainView);
+ return;
+ }
+
+ if(pMainView->selectioninfo != NULL)
+ {
+ MSG_MAIN_MED("Delete small noti");
+ evas_object_del(pMainView->selectioninfo);
+ pMainView->selectioninfo = NULL;
+ }
+ if (pMainView->copy_popup)
+ {
+ MSG_MAIN_MED("Delete copy popup");
+ evas_object_del(pMainView->copy_popup);
+ pMainView->copy_popup = NULL;
+ }
+
+// Update Main View.
+ if ( pMainView->bShowMenu == true )
+ {
+ PERF_CHECK_BEGIN(LVL5 "Update main view");
+ _update_main_view(pMainView, sitem);
+ PERF_CHECK_END(LVL5 "Update main view");
+ }
+
+}
+
+
+static void
+_ivug_main_view_slider_item_state_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("Image slider item state changed callback. ");
+ ivug_ret_if(!data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+ Slide_Item *sitem = (Slide_Item *)event_info;
+
+ if ( sitem == NULL || sitem->mitem == NULL)
+ {
+ // There is no item existed. terminate UG
+ MSG_MAIN_ERROR("No item is remained. exit UG");
+ IVUG_MAIN_DESTROY_ME(pMainView);
+ return;
+ }
+
+// Update Main View.
+ if ( pMainView->bShowMenu == true )
+ {
+ _update_main_view(pMainView, sitem);
+ }
+}
+
+
+static void
+_ivug_main_view_slider_deleted_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ MSG_MAIN_HIGH("Image slider deleted callback. ");
+ ivug_ret_if(!data);
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+ Slide_Item *sitem = (Slide_Item *)event_info;
+
+ if ( sitem == NULL || sitem->mitem == NULL )
+ {
+ // There is no item existed. terminate UG
+ MSG_MAIN_ERROR("No item is remained. exit UG");
+ IVUG_MAIN_DESTROY_ME(pMainView);
+ return;
+ }
+
+ _main_view_create_selection_info(pMainView, IDS_DELETED);
+
+ if ( pMainView->bShowMenu == true )
+ {
+ _update_main_view(pMainView, sitem);
+ }
+
+}
+
+
+static void
+_ivug_main_view_slider_slideshow_finished_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ IV_ASSERT(data != NULL);
+ MSG_MAIN_HIGH("Slide show finished callback. ");
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ ivug_allow_lcd_off();
+ ivug_slider_stop_slide_show(pMainView->slider);
+
+ elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_FALSE);
+
+ _ivug_main_view_show_menu_bar(pMainView);
+}
+
+static void
+_ivug_main_view_slider_slideshow_interrupted_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ IV_ASSERT(data != NULL);
+ MSG_MAIN_HIGH("Slide show interrupted callback. ");
+
+ Ivug_MainView *pMainView = (Ivug_MainView *)data;
+
+ ivug_allow_lcd_off();
+
+ elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_FALSE);
+
+ _ivug_main_view_show_menu_bar(pMainView);
+}
+
+
+
+#ifdef TEST_MOUSE_EVENT
+void _on_receive_mouse_move (void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ char *tt = data;
+ MSG_MAIN_HIGH("Hmm!!! %s", tt);
+}
+#endif
+
+static void
+_on_menu_state_changed(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ Ivug_MainView *pMainView = data;
+
+ MSG_MAIN_HIGH("Receive %s %s", emission, source);
+
+ if ( strncmp(emission, "menu,show,finished", strlen(emission)) == 0 )
+ {
+ elm_widget_disabled_set(pMainView->ctrl_bar, EINA_FALSE);
+ }
+ else
+ {
+ evas_object_hide(pMainView->ctrl_bar);
+ elm_widget_disabled_set(pMainView->ctrl_bar, EINA_TRUE);
+ }
+}
+
+bool
+ivug_main_view_load_list(Ivug_MainView *pMainView, ivug_parameter* ivug_param)
+{
+ MSG_MAIN_HIGH("Load media list.");
+
+ PERF_CHECK_BEGIN(LVL1 "create media list");
+
+ Media_Data *mdata = ivug_slider_create_media_list(pMainView->slider, ivug_param);
+ if (mdata == NULL)
+ {
+ MSG_MAIN_ERROR("Creating media list is failed");
+ return false;
+ }
+
+ PERF_CHECK_END(LVL1 "create media list");
+
+ return true;
+}
+
+Ivug_MainView *
+ivug_main_view_create(Evas_Object* parent, ivug_mode mode, ivug_view_by view_by)
+{
+ IV_ASSERT(parent != NULL);
+
+ MSG_MAIN_HIGH("Creating main view. Parent=0x%08x Mode=%d ViewBy=%d", parent, mode, view_by);
+
+ PERF_CHECK_BEGIN(LVL2 "Create layout");
+
+//create main view layout
+ Ivug_MainView *pMainView = calloc(1, sizeof(Ivug_MainView) );
+ IV_ASSERT(pMainView != NULL);
+
+// Set default value
+ pMainView->parent = parent;
+ pMainView->bShowMenu = true;
+ pMainView->ugHandle = gGetUGHandle();
+ pMainView->mode = mode;
+ pMainView->view_by = view_by;
+
+ Evas_Object *layout;
+ layout = elm_layout_add(parent);
+ if ( layout == NULL) //if failed
+ {
+ MSG_MAIN_ERROR("main layout create failed");
+ free(pMainView);
+ return NULL;
+ }
+
+ pMainView->layout = layout;
+
+ PERF_CHECK_END(LVL2 "Create layout");
+
+ PERF_CHECK_BEGIN(LVL2 "load EDJ");
+
+ if (elm_layout_file_set(layout, IVUG_MAIN_EDJ, "mainview") == EINA_FALSE)
+ {
+ MSG_MAIN_ERROR("edj loading fail, file=%s group=%s", IVUG_MAIN_EDJ, IVUG_MAIN_EDJ);
+ evas_object_del(layout);
+ free(pMainView);
+ return NULL;
+ }
+
+ edje_object_signal_callback_add(_EDJ(pMainView->layout),
+ "menu,hide,finished",
+ "edc",
+ _on_menu_state_changed,
+ (void *)pMainView);
+
+ edje_object_signal_callback_add(_EDJ(pMainView->layout),
+ "menu,show,finished",
+ "edc",
+ _on_menu_state_changed,
+ (void *)pMainView);
+
+ evas_object_show(layout);
+
+// Navigation bar
+ pMainView->navi_bar = elm_naviframe_add(layout);
+ if ( pMainView->navi_bar == NULL)
+ {
+ MSG_MAIN_ERROR("navigation bar failed");
+ ivug_main_view_destroy(pMainView);
+ return NULL;
+ }
+
+// Layout life cycle is controlled by application explictily.
+ elm_naviframe_content_preserve_on_pop_set(pMainView->navi_bar, EINA_TRUE);
+
+#ifdef USE_CUSTOM_STYLE
+ elm_object_theme_set(pMainView->navi_bar, gGetSystemTheme() );
+ Eina_Bool bstyle = elm_object_style_set(pMainView->navi_bar, "ivug/default");
+ MSG_MAIN_HIGH("navi_bar elm_object_style_set result = %d", bstyle);
+#endif
+
+ elm_object_part_content_set(layout, "mainview.navibar", pMainView->navi_bar); //swallow
+
+ pMainView->empty_layout = elm_layout_add(layout); //create centents layout.
+ if (elm_layout_file_set(pMainView->empty_layout, IVUG_MAIN_EDJ, "navi_content"))
+ {
+ MSG_MAIN_HIGH("create Empty layout for navigation bar. Navi=0x%08x Empty Layout=0x%08x", pMainView->navi_bar, pMainView->empty_layout);
+ }
+ else
+ {
+ IVUG_DEBUG_WARNING("layout sawllow failed");
+ ivug_main_view_destroy(pMainView);
+ return NULL;
+ }
+
+ //create slider
+ pMainView->slider = ivug_slider_add(pMainView->empty_layout);
+ if (pMainView->slider == NULL)
+ {
+ MSG_MAIN_ERROR("image slider create failed");
+ ivug_main_view_destroy(pMainView);
+ return NULL;
+ }
+ elm_object_part_content_set(pMainView->empty_layout, "mainview.slider", pMainView->slider); //swallow
+
+ Evas_Object *back_btn = elm_button_add(pMainView->navi_bar);
+ elm_object_text_set(back_btn, IDS_BACK ); //elm_button_icon_set
+ elm_object_style_set(back_btn, "naviframe/end_btn/default");
+
+ evas_object_smart_callback_add(back_btn, "clicked", _ivug_main_view_back_cb, pMainView);
+
+ pMainView->navi_it = elm_naviframe_item_push(pMainView->navi_bar, IDS_LOADING , back_btn, NULL, pMainView->empty_layout, NULL);
+
+ pMainView->back_btn = back_btn;
+
+ if (pMainView->mode != IVUG_MODE_DISPLAY) // Display mode has no control bar in bottom.
+ {
+ pMainView->ctrl_bar = _create_ctrl_bar(pMainView->navi_bar, gGetSystemTheme());
+ elm_object_item_part_content_set(pMainView->navi_it, "controlbar", pMainView->ctrl_bar);
+ }
+
+ PERF_CHECK_END(LVL2 "load EDJ");
+
+ PERF_CHECK_BEGIN(LVL2 "add slider");
+
+ //elm_object_part_content_set(layout, "mainview.slider", pMainView->slider); //swallow
+
+//register mouse call back.
+ evas_object_smart_callback_add(pMainView->slider, "slider,clicked", _ivug_main_view_clicked, pMainView);
+ evas_object_smart_callback_add(pMainView->slider, "slider,longpressed", _ivug_main_view_long_pressed, pMainView);
+ evas_object_smart_callback_add(pMainView->slider, "slider,clicked,icon", _ivug_main_view_icon_clicked, pMainView);
+
+ evas_object_smart_callback_add(pMainView->slider, "slider,item,changed", _ivug_main_view_slider_changed_cb, pMainView);
+ evas_object_smart_callback_add(pMainView->slider, "slider,item,deleted", _ivug_main_view_slider_deleted_cb, pMainView);
+ evas_object_smart_callback_add(pMainView->slider, "slider,slideshow,finished", _ivug_main_view_slider_slideshow_finished_cb, pMainView);
+ evas_object_smart_callback_add(pMainView->slider, "slider,slideshow,interrupted", _ivug_main_view_slider_slideshow_interrupted_cb, pMainView);
+ evas_object_smart_callback_add(pMainView->slider, "slider,item,state,changed", _ivug_main_view_slider_item_state_changed_cb, pMainView);
+
+#ifdef TEST_MOUSE_EVENT
+ evas_object_event_callback_add(pMainView->navi_bar, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "navigarion");
+ evas_object_event_callback_add(pMainView->layout, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "layout");
+ evas_object_event_callback_add(pMainView->parent, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "base");
+ evas_object_event_callback_add(pMainView->slider, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "slider");
+ evas_object_event_callback_add(edje_object_part_object_get(_EDJ(pMainView->layout) , "clip"), EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "clip");
+ evas_object_event_callback_add(edje_object_part_object_get(_EDJ(pMainView->layout) , "mainview.navibar"), EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "navi swallow");
+ evas_object_event_callback_add(pMainView->ctrl_bar, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "controlbar");
+#endif
+
+ PERF_CHECK_END(LVL2 "add slider");
+
+ PERF_CHECK_BEGIN(LVL2 "add event handler");
+
+ edje_object_signal_callback_add(_EDJ(pMainView->empty_layout),
+ "mainview,zoom_out,clicked",
+ "",
+ _ivug_main_view_zoom_out_cb,
+ (void *)pMainView);
+ edje_object_signal_callback_add(_EDJ(pMainView->empty_layout),
+ "mainview,zoom_in,clicked",
+ "",
+ _ivug_main_view_zoom_in_cb,
+ (void *)pMainView);
+
+ _show_zoom_icon(pMainView);
+
+ int ret = -1;
+ MSG_IMAGEVIEW_HIGH("Register System notifications");
+ ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, _on_mmc_state_changed, pMainView);
+ if ( ret == -1 )
+ {
+ MSG_IMAGEVIEW_ERROR("Register %s is failed", VCONFKEY_SYSMAN_MMC_STATUS);
+ }
+
+ pMainView->keydown_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+ (void *)_key_down_cb,
+ (void *)pMainView);
+
+ MSG_MAIN_HIGH("Main View starting");
+
+// For debugging.
+ DELETE_NOTIFY(pMainView->layout);
+
+ PERF_CHECK_END(LVL2 "add event handler");
+
+ return pMainView;
+
+}
+
+
+Evas_Object *
+ivug_main_view_object_get(Ivug_MainView *pMainView)
+{
+ IV_ASSERT(pMainView != NULL);
+
+ return pMainView->layout;
+}
+
+void
+ivug_main_view_update(Ivug_MainView *pMainView)
+{
+ IV_ASSERT(pMainView != NULL);
+
+ MSG_MAIN_HIGH("Main View Update");
+
+ Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
+ Media_Data *mdata = ivug_data_get_data(sitem->mitem);
+
+ ivug_ret_if(!mdata);
+
+// TODO : Check this routine!.
+// TODO : Should implement again!!
+
+ if (mdata->slide_type == SLIDE_TYPE_IMAGE || mdata->slide_type == SLIDE_TYPE_VIDEO )
+ {
+ if(mdata->filepath && ecore_file_exists(mdata->filepath)) // Current file is not deleted
+ {
+ MSG_MAIN_HIGH("Current filepath : %s", mdata->filepath);
+ }
+ else
+ {
+ /*if file is not exist ug terminated temporally */
+ MSG_MAIN_ERROR("Center slide file is not exist");
+ IVUG_MAIN_DESTROY_ME(pMainView);
+ return ;
+ }
+ }
+
+// When resume, menu bar will be appeared.
+ _ivug_main_view_show_menu_bar(pMainView);
+}
+
+
+void
+ivug_main_view_destroy(Ivug_MainView *pMainView)
+{
+ IV_ASSERT(pMainView != NULL);
+
+ MSG_MAIN_HIGH("ENTER : Main View Destroy. pMainView=0x%08x", pMainView);
+
+ if( pMainView->event_blocker )
+ {
+ MSG_MAIN_HIGH("delete event blocker");
+ evas_object_del(pMainView->event_blocker);
+ pMainView->event_blocker = NULL;
+ }
+
+ if(pMainView->ext_ug)
+ {
+ MSG_MAIN_HIGH("destroy ug");
+ ug_destroy(pMainView->ext_ug);
+ pMainView->ext_ug = NULL;
+ }
+
+ if( pMainView->pDetailsView )
+ {
+ MSG_MAIN_HIGH("Details View Destroy");
+
+ ivug_details_view_destroy(pMainView->pDetailsView);
+ pMainView->pDetailsView = NULL;
+ }
+
+ if(pMainView->layout) // Remove topmost parent in main view.
+ {
+ evas_object_del(pMainView->layout);
+ pMainView->layout = NULL;
+ }
+
+ if (pMainView->exit_timer)
+ {
+ ecore_timer_del(pMainView->exit_timer);
+ pMainView->exit_timer = NULL;
+ }
+
+ int ret = -1;
+
+ MSG_IMAGEVIEW_HIGH("Unregister system notifications");
+
+ if(pMainView->keydown_handler)
+ {
+ ecore_event_handler_del(pMainView->keydown_handler);
+ pMainView->keydown_handler = NULL;
+ }
+
+ ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, _on_mmc_state_changed);
+ if ( ret == -1 )
+ {
+ MSG_IMAGEVIEW_ERROR("Unegister %s is failed", VCONFKEY_SYSMAN_MMC_STATUS);
+ }
+
+ free(pMainView);
+
+ MSG_MAIN_HIGH("LEAVE : Main View Destroy.");
+
+ return ;
+}
+
diff --git a/main/src/view/ivug-main-view.h b/main/src/view/ivug-main-view.h
new file mode 100755
index 0000000..7d1a648
--- /dev/null
+++ b/main/src/view/ivug-main-view.h
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_MAIN_VIEWER_H__
+#define __IVUG_MAIN_VIEWER_H__
+
+#include "ivug-common.h"
+#include "ivug-details-view.h"
+#include "ivug-setas-view.h"
+
+#define MAX_CTRL_ITEM_CNT 5
+#define MAX_NAVI_ITEM_CNT 3
+
+//navigation bar type
+typedef enum NAVI_BAR_TYPE {
+ NAVI_BAR_TYPE_NONE = 0x00,
+ NAVI_BAR_TYPE_EMPTY, // no control bar
+ NAVI_BAR_TYPE_IMAGE, // no control bar
+ NAVI_BAR_TYPE_VIDEO, // no control bar
+ NAVI_BAR_TYPE_SELECT, // [Ok, Cancel] from take photo
+} _navi_bar_type;
+
+//control bar type
+typedef enum CTRL_BAR_TYPE{
+ CTRL_BAR_TYPE_NONE = 0x00,
+ CTRL_BAR_TYPE_EMPTY, // not exist ctrl bar
+ CTRL_BAR_TYPE_FILE, // [Delete,Info] file manager, video at gallery
+ CTRL_BAR_TYPE_CAMERA_IMAGE, // [Delete,Info] camera image file
+ CTRL_BAR_TYPE_CAMERA_VIDEO, // [Delete,Info] camera video file
+ CTRL_BAR_TYPE_IMAGE, // [Delete,Slide show, Info] from gallery
+ CTRL_BAR_TYPE_VIDEO, // [Delete,Slide show, Info] from gallery
+} _ctrl_bar_type;
+
+
+typedef struct {
+ Evas_Object *parent;
+
+ Evas_Object *layout; /*Layout widget based on EDJ*/
+
+ Evas_Object *navi_bar;
+ Elm_Object_Item *navi_it;
+ Evas_Object* empty_layout; //navigation bar contents layout
+ Evas_Object* slider; //image viewer slider
+ Evas_Object* event_blocker;
+
+ Evas_Object* selectioninfo;
+
+ Evas_Object *back_btn;
+
+/*
+ |-------------------|
+ |naviframe(tool_bar)|
+ |-------------------|
+ | |
+ | |
+ | |
+ | |
+ |-------------------|
+ | ctrl_bar |
+ |-------------------|
+*/
+
+// Tool Bar
+ enum NAVI_BAR_TYPE tool_bar_type;
+ Evas_Object* tool_bar_item[MAX_NAVI_ITEM_CNT]; // Control bar item in navigation header. ex) SetAs, Info
+
+// Control Bar
+ Evas_Object *ctrl_bar;
+ enum CTRL_BAR_TYPE ctrl_bar_type;
+ Elm_Object_Item *ctrl_bar_item[MAX_CTRL_ITEM_CNT]; // Bottom control bar item. ex) Delete, etc...
+
+ Evas_Object* popup; //popup
+ Evas_Object* copy_popup; //copy popup
+ Eina_List* popup_list;
+
+ Ivug_SetAsView *pSetAsView;
+
+ Ivug_DetailsView *pDetailsView;
+
+ Evas_Object *btn_detail;
+ Evas_Object *btn_detail_data;
+
+//flag
+ bool bShowMenu;
+
+ ivug_mode mode;
+ ivug_view_by view_by;
+
+ struct ui_gadget *ext_ug;
+
+ struct ui_gadget *ugHandle;
+
+ Ecore_Event_Handler *keydown_handler;
+
+ Ecore_Timer *exit_timer;
+
+ Eina_Bool option_show;
+} Ivug_MainView;
+
+
+/*
+ Create MainView layout
+*/
+Ivug_MainView *
+ivug_main_view_create(Evas_Object* parent, ivug_mode mode, ivug_view_by view_by);
+
+Evas_Object *
+ivug_main_view_object_get(Ivug_MainView *pMainView);
+
+/*
+ Load media list from parameter.
+*/
+bool ivug_main_view_load_list(Ivug_MainView *pMainView, ivug_parameter* ivug_param);
+
+void ivug_main_view_update(Ivug_MainView *pMainView);
+
+void ivug_main_view_destroy(Ivug_MainView *pMainView);
+
+#endif //__IVUG_MAIN_VIEWER_H__
diff --git a/main/src/view/ivug-popup.c b/main/src/view/ivug-popup.c
new file mode 100755
index 0000000..1ad940c
--- /dev/null
+++ b/main/src/view/ivug-popup.c
@@ -0,0 +1,262 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-popup.h"
+
+#include <ui-gadget-module.h> // ug_destroy_me, ug_send_result
+#include <ui-gadget.h>
+
+#define NOTIFY_TIMEOUT 3.0
+
+static void
+_ivug_popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ivug_ret_if(obj == NULL);
+
+ evas_object_del(obj);
+ obj = NULL;
+}
+
+static void _on_warningpopup_response(void *data, Evas_Object *obj, void *event_info )
+{
+
+ IV_ASSERT(data != NULL);
+
+ Evas_Object *popup = (Evas_Object *)data;
+ Popup_Response response = (Popup_Response)evas_object_data_get(obj, "response");
+ MSG_IMAGEVIEW_HIGH("response callback=%d", response);
+
+ evas_object_del(popup); // Remove popup
+}
+
+Evas_Object*
+ivug_popup_warning(Evas_Object* parent, const char* title, const char* contents)
+{
+ Evas_Object *popup;
+ Evas_Object *btn_ok;
+ //create popup
+
+ popup = elm_popup_add(parent);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_text_set(popup, contents);
+ elm_object_part_text_set(popup, "title,text", title);
+
+ btn_ok = elm_button_add(popup);
+ elm_object_text_set(btn_ok, IDS_OK);
+ elm_object_part_content_set(popup, "button1", btn_ok);
+ evas_object_data_set(btn_ok, "response", (void *)POPUP_RESPONSE_OK);
+ evas_object_smart_callback_add(btn_ok, "clicked", _on_warningpopup_response, popup);
+
+ evas_object_show(popup);
+
+ return popup;
+}
+
+static void _on_questionpopup_response(void *data, Evas_Object *obj, void *event_info )
+{
+
+ IV_ASSERT(data != NULL);
+
+ Evas_Object *popup = (Evas_Object *)data;
+ Popup_Response response = (Popup_Response)evas_object_data_get(obj, "response");
+ MSG_IMAGEVIEW_HIGH("response callback=%d", response);
+
+ if ( response == POPUP_RESPONSE_OK )
+ {
+ void *user_data = NULL;
+ Evas_Smart_Cb responseCB = NULL;
+
+ responseCB = evas_object_data_get(popup, "question-response");
+ user_data = evas_object_data_get(popup, "question-data");
+
+ responseCB(user_data, popup, (void *)POPUP_RESPONSE_OK);
+ }
+
+ evas_object_del(popup); // Remove popup
+}
+
+Evas_Object*
+ivug_popup_question(Evas_Object* parent, const char* title, const char* contents,
+ Evas_Smart_Cb response_cb, void* user_data)
+{
+ Evas_Object *popup;
+ Evas_Object *btn_yes;
+ Evas_Object *btn_no;
+ //create popup
+
+ IV_ASSERT(response_cb != NULL);
+
+ popup = elm_popup_add(parent);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_text_set(popup, contents);
+ elm_object_part_text_set(popup, "title,text", title);
+
+ btn_yes = elm_button_add(popup);
+ elm_object_text_set(btn_yes, IDS_YES);
+ elm_object_part_content_set(popup, "button1", btn_yes);
+ evas_object_data_set(btn_yes, "response", (void *)POPUP_RESPONSE_OK);
+ evas_object_smart_callback_add(btn_yes, "clicked", _on_questionpopup_response, popup);
+
+ btn_no = elm_button_add(popup);
+ elm_object_text_set(btn_no, IDS_NO);
+ elm_object_part_content_set(popup, "button2", btn_no);
+ evas_object_data_set(btn_no, "response", (void *)POPUP_RESPONSE_CANCEL);
+ evas_object_smart_callback_add(btn_no, "clicked", _on_questionpopup_response, popup);
+
+ evas_object_data_set(popup, "question-response", response_cb);
+ evas_object_data_set(popup, "question-data", user_data);
+
+ evas_object_show(popup);
+
+ return popup;
+}
+
+Evas_Object*
+ivug_popup_selectioninfo(Evas_Object* parent, const char* contents)
+{
+ Evas_Object *notify;
+
+ notify = elm_notify_add(parent);
+ ivug_retv_if(notify == NULL, NULL);
+ elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
+ evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(notify, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_smart_callback_add(notify, "timeout", _ivug_popup_timeout_cb, NULL);
+ elm_notify_timeout_set(notify, NOTIFY_TIMEOUT);
+
+ Evas_Object* layout = elm_layout_add(parent);
+
+ elm_object_theme_set(layout, gGetSystemTheme());
+
+ elm_layout_theme_set(layout, "standard", "selectioninfo", "vertical/bottom_86");
+
+ 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);
+ elm_object_content_set(notify, layout);
+ edje_object_part_text_set(_EDJ(layout), "elm.text", contents);
+
+ evas_object_show(notify);
+
+ return notify;
+}
+
+
+static void _on_popup_response_exit( void *data, Evas_Object *obj, void *event_info )
+{
+ MSG_IMAGEVIEW_HIGH("response callback=%d",(int)event_info);
+
+ evas_object_del(obj);
+
+ ug_destroy_me(gGetUGHandle());
+}
+
+
+static void _on_popup_response( void *data, Evas_Object *obj, void *event_info )
+{
+ MSG_IMAGEVIEW_HIGH("response callback=%d",(int)event_info);
+
+ evas_object_del(obj); // Remove popup
+}
+
+Evas_Object *ivug_show_exit_popup(Evas_Object *parent, const char *sztitle, const char *szmsg)
+{
+ Evas_Object *popup;
+
+ popup = elm_popup_add(parent);
+
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ if ( szmsg )
+ elm_object_text_set(popup, szmsg);
+
+ if ( sztitle )
+ elm_object_part_text_set(popup, "title,text", sztitle);
+
+ elm_popup_timeout_set(popup, 3.0);
+ evas_object_smart_callback_add(popup, "timeout", _on_popup_response_exit, NULL);
+
+ evas_object_show(popup);
+
+ return popup;
+
+}
+
+Evas_Object *ivug_show_popup(Evas_Object *parent, const char *sztitle,
+ const char *szmsg, Evas_Smart_Cb response_cb, void *user_data)
+{
+ Evas_Object *popup;
+
+ popup = elm_popup_add(parent);
+
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ if ( szmsg )
+ {
+ elm_object_text_set(popup, szmsg);
+ }
+
+ if ( sztitle )
+ elm_object_part_text_set(popup, "title,text", sztitle);
+
+ elm_popup_timeout_set(popup, 3.0);
+
+ if(response_cb)
+ evas_object_smart_callback_add(popup, "timeout", response_cb, user_data);
+ else
+ evas_object_smart_callback_add(popup, "timeout", _on_popup_response, user_data);
+
+ evas_object_show(popup);
+ evas_object_focus_set(popup, EINA_TRUE);
+
+ return popup;
+}
+
+Evas_Object *ivug_show_popup_va(Evas_Object *parent, const char *sztitle, const char *fmt, ...)
+{
+ char buf[1024];
+
+ Evas_Object *popup;
+
+ popup = elm_popup_add(parent);
+
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ vsnprintf(buf, (size_t)sizeof(buf), fmt, ap);
+
+ va_end(ap);
+
+ elm_object_text_set(popup, buf);
+
+ if ( sztitle )
+ elm_object_part_text_set(popup, "title,text", sztitle);
+
+ elm_popup_timeout_set(popup, 3.0);
+ evas_object_smart_callback_add(popup, "timeout", _on_popup_response, NULL);
+
+// evas_object_focus_set(popup, EINA_TRUE);
+
+ evas_object_show(popup);
+
+ return popup;
+
+}
+
+
diff --git a/main/src/view/ivug-popup.h b/main/src/view/ivug-popup.h
new file mode 100755
index 0000000..a0609e7
--- /dev/null
+++ b/main/src/view/ivug-popup.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_POPUP_H__
+#define __IVUG_POPUP_H__
+
+#include "ivug-common.h"
+#include "ivug-main.h"
+
+enum IVUG_LIST_POPUP_TYPE
+{
+ IVUG_LIST_POPUP_SET_WALLPAPER,
+} _ivug_list_popup_type;
+
+
+typedef enum _Popup_Response
+{
+ POPUP_RESPONSE_NONE = -1,
+ POPUP_RESPONSE_TIMEOUT = -2,
+ POPUP_RESPONSE_OK = -3,
+ POPUP_RESPONSE_CANCEL = -4,
+ POPUP_RESPONSE_CLOSE = -5
+} Popup_Response;
+
+// it has one button
+Evas_Object*ivug_popup_warning(Evas_Object* parent, const char* title, const char* contents);
+
+// it has two button
+Evas_Object*
+ivug_popup_question(Evas_Object* parent, const char* title, const char* contents,
+ Evas_Smart_Cb response_cb, void* user_data);
+
+Evas_Object*
+ivug_popup_create_popup_list(Evas_Object *parent ,enum IVUG_LIST_POPUP_TYPE type, const char* title, Eina_List* list,
+ void* lable_func, void* select_func, void* response_func, void *data);
+
+Evas_Object*
+ivug_popup_selectioninfo(Evas_Object* parent, const char* contents);
+
+Evas_Object *ivug_show_exit_popup(Evas_Object *parent, const char *sztitle, const char *szmsg);
+
+Evas_Object *ivug_show_popup(Evas_Object *parent, const char *sztitle, const char *szmsg,
+ void (*response_cb) ( void *data, Evas_Object *obj, void *event_info ), void *user_data);
+Evas_Object *ivug_show_popup_va(Evas_Object *parent, const char *sztitle, const char *fmt, ...);
+
+#endif //__IVUG_POPUP_H__ \ No newline at end of file
diff --git a/main/src/view/ivug-setas-view.c b/main/src/view/ivug-setas-view.c
new file mode 100755
index 0000000..836478b
--- /dev/null
+++ b/main/src/view/ivug-setas-view.c
@@ -0,0 +1,895 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <ui-gadget-module.h>
+#include <Evas.h>
+#include <dlfcn.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "ivug-common.h"
+#include "ivug-parameter.h"
+
+#include "ivug-popup.h"
+#include "ivug-ext-ug.h"
+#include "ivug-widget.h"
+#include "ivug-main.h"
+
+#include "ivug-setas-view.h"
+#include "ivug-slider.h"
+#include "ivug-listpopup.h"
+
+/*
+ Used for storing cropped image.
+*/
+#define IVUG_HOME_SCREEN_TEMP_PATH DATA_PATH"/.homescreen_tmp.jpg";
+#define IVUG_LOCK_SCREEN_TEMP_PATH DATA_PATH"/.lockscreen_tmp.jpg";
+
+/*
+ Final image path
+*/
+#define IVUG_HOME_SCREEN_PATH DATA_PATH"/.homescreen.jpg";
+#define IVUG_LOCK_SCREEN_PATH DATA_PATH"/.lockscreen.jpg";
+
+/*
+ Image displays when incomming call is recevied.
+*/
+
+#define IVUG_RESULT_BUNDLE_KEY_ERROR "Error"
+#define IVUG_RESULT_BUNDLE_VALUE_NOT_SUPPORTED "not_supported_file_type"
+
+#define CLICK_TIME_MAX (500) // click time.
+#define CLICK_WIDTH_MIN (elm_config_finger_size_get() >> 1) //click width, if mouse move under this value and under click time, it is click.
+#define CLICK_INTERVAL_TIME 0.15
+
+#define SETAS_EDJ_FILE EDJ_PATH"/ivug-setas.edj"
+
+#define IVUG_RESPONSE_OK (1)
+
+#define TRANSITION_EFFECT
+
+//set as
+enum {
+ IVUG_SET_AS_TYPE_HOME = 0x00,
+ IVUG_SET_AS_TYPE_LOCK,
+ IVUG_SET_AS_TYPE_BOTH,
+ IVUG_SET_AS_TYPE_MAX,
+};
+
+static void
+_ivug_setas_on_icon_set_clicked(void *data, Evas_Object* obj, const char *emission, const char *source );
+
+/*********************************Common Part**************************************/
+
+static void
+_setas_ug_view_deleted(void * data, Evas * e, Evas_Object * obj, void * event_info)
+{
+ char *szView = (char *)data;
+
+ MSG_SETAS_WARN("%s is destroyed", szView);
+ return;
+}
+
+static void
+_ivug_setas_view_remove(Ivug_SetAsView *pSetAsView)
+{
+ MSG_SETAS_HIGH("Start destroy ug");
+ ug_destroy_me(gGetUGHandle());
+ return;
+}
+
+static void
+_ivug_setas_view_show_icons(Evas_Object *layout)
+{
+ ivug_retm_if(!layout, "pSetAsView->layout is NULL");
+
+ elm_win_indicator_mode_set(ug_get_window(), ELM_WIN_INDICATOR_SHOW);
+
+ edje_object_signal_emit(_EDJ(layout),
+ "setasview,show,btn_cancel","elm");
+
+ edje_object_signal_emit(_EDJ(layout),
+ "setasview,show,btn_ok","elm");
+}
+
+static void
+_ivug_setas_view_hide_icons(Evas_Object *layout)
+{
+ ivug_retm_if(!layout, "pSetAsView->layout is NULL");
+
+ elm_win_indicator_mode_set(ug_get_window(), ELM_WIN_INDICATOR_HIDE);
+
+ edje_object_signal_emit(_EDJ(layout),
+ "setasview,hide,btn_cancel","elm");
+
+ edje_object_signal_emit(_EDJ(layout),
+ "setasview,hide,btn_ok","elm");
+}
+
+static void
+_ivug_setas_view_unregister_set_signal(Evas_Object *layout, void (*func) (void *data, Evas_Object *obj, const char *emission, const char *source))
+{
+ ivug_retm_if(!layout, "pSetAsView->layout is NULL");
+
+ edje_object_signal_callback_del(_EDJ(layout),
+ "setasview,set,clicked",
+ "",
+ func);
+}
+
+static Eina_Bool
+_ivug_setas_view_click_cb(void *data)
+{
+ Ivug_SetAsView *setas_data = (Ivug_SetAsView *)data;
+ if (setas_data->click_timer)
+ {
+ ecore_timer_del(setas_data->click_timer);
+ setas_data->click_timer = NULL;
+ }
+
+ setas_data->b_hide_bar_flag = !(setas_data->b_hide_bar_flag);
+
+ MSG_SETAS_HIGH("Bar flag is %d", setas_data->b_hide_bar_flag);
+ if(setas_data->b_hide_bar_flag)
+ {
+ _ivug_setas_view_hide_icons(setas_data->layout);
+ }
+ else
+ {
+ _ivug_setas_view_show_icons(setas_data->layout);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static void
+_ivug_setas_view_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+
+ Ivug_SetAsView *setas_data = (Ivug_SetAsView *)data;
+ Evas_Event_Mouse_Down *ev = event_info;
+
+ MSG_SETAS_HIGH("Mouse down!");
+ ivug_ret_if(!data);
+
+ setas_data->down_pos.x = ev->canvas.x;
+ setas_data->down_pos.y = ev->canvas.y;
+ setas_data->timestamp = ev->timestamp;
+
+ if (setas_data->click_timer)
+ {
+ ecore_timer_del(setas_data->click_timer);
+ setas_data->click_timer = NULL;
+ }
+}
+
+static void
+_ivug_setas_view_mouse_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ Ivug_SetAsView *setas_data = (Ivug_SetAsView *)data;
+ Evas_Event_Mouse_Up *ev = event_info;
+ int step;
+ unsigned int interval_time;
+
+ MSG_SETAS_HIGH("Mouse up!");
+ ivug_ret_if(!data);
+
+ step = setas_data->down_pos.x - ev->canvas.x;
+ interval_time = ev->timestamp - setas_data->timestamp;
+
+ if(ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
+ {
+ MSG_SETAS_HIGH("double clicked");
+ return;
+ }
+ if ((step < CLICK_WIDTH_MIN && step > -CLICK_WIDTH_MIN) && (interval_time < CLICK_TIME_MAX && interval_time > 0) )
+ {
+ MSG_SETAS_HIGH("clicked");
+ setas_data->click_timer = ecore_timer_add(CLICK_INTERVAL_TIME, _ivug_setas_view_click_cb , data);
+ return ;
+ }
+}
+
+/********************************* Common Function **************************************/
+static void
+_ivug_setas_view_send_result(struct ui_gadget *ug, const char *key1, const char *val1, const char *key2, const char *val2)
+{
+ ivug_ret_if(!ug);
+
+ bundle *b;
+ b = bundle_create();
+ if(key1 && val1)
+ {
+ MSG_SETAS_HIGH("Bundle 1 : [%s = %s]", key1, val1);
+ bundle_add(b, key1, val1);
+ }
+
+ if(key2 && val2)
+ {
+ MSG_SETAS_HIGH("Bundle 2 : [%s = %s]", key2, val2);
+ bundle_add(b, key2, val2);
+ }
+
+ ug_send_result(ug, b);
+ bundle_free(b);
+}
+
+
+
+static void
+_ivug_setas_view_response_cb( void *data, Evas_Object *obj, void *event_info )
+{
+ MSG_SETAS_HIGH( "response callback=%d",(int)event_info);
+
+ evas_object_hide(obj);
+ evas_object_del(obj);
+
+ ivug_retm_if(!data, "data is NULL");
+
+ _ivug_setas_view_remove((Ivug_SetAsView *)data);
+}
+
+/**
+* @brief
+*
+* @param title
+* @param txt_noti
+*/
+static Evas_Object*
+_ivug_setas_view_show_exit_popup( Evas_Object *parent, const char *title, const char *desc, void *data)
+{
+ MSG_SETAS_HIGH( "title: %s, desc %s", title, desc);
+
+ Evas_Object* style1_popup = elm_popup_add(parent);
+ evas_object_size_hint_weight_set(style1_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_popup_timeout_set(style1_popup, (double)2.0);
+ elm_object_text_set(style1_popup, desc);
+ elm_object_part_text_set(style1_popup, "title,text", title);
+ evas_object_smart_callback_add(style1_popup, "timeout", _ivug_setas_view_response_cb, data);
+ evas_object_show(style1_popup);
+ evas_object_layer_set(style1_popup, EVAS_LAYER_MAX);
+
+ return style1_popup;
+}
+
+static Eina_Bool _ivug_setas_view_resize_save(Evas_Object *org, const char *filepath, int w, int h)
+{
+ IV_ASSERT(org != NULL);
+ IV_ASSERT(filepath != NULL);
+
+ if(w <= 0 || h <= 0)
+ {
+ MSG_SETAS_ERROR("input size parameter is invalid, w = %d, h = %d", w, h);
+ return EINA_FALSE;
+ }
+
+ int img_w = 0;
+ int img_h = 0;
+
+ evas_object_image_size_get(org, &img_w, &img_h);
+ MSG_SETAS_LOW("img_w = %d, img_h = %d", img_w, img_h);
+ MSG_SETAS_LOW("w = %d, h = %d", w, h);
+
+ char *ImgBuffer = evas_object_image_data_get(org, EINA_FALSE);
+
+ Ecore_Evas *ee;
+ Evas *evas;
+
+ ee = ecore_evas_buffer_new(w, h);
+ IV_ASSERT(ee != NULL);
+ evas = ecore_evas_get(ee);
+ IV_ASSERT(evas != NULL);
+
+ Evas_Object *input;
+ input = evas_object_image_filled_add(evas);
+ IV_ASSERT(input != NULL);
+
+ evas_object_image_size_set(input, img_w, img_h);
+ evas_object_image_data_set(input, ImgBuffer);
+ evas_object_image_smooth_scale_set(input, EINA_TRUE);
+ evas_object_move(input, 0, 0);
+ evas_object_resize(input, w, h);
+
+ evas_object_show(input);
+ evas_object_image_data_update_add(input, 0, 0, w, h);
+
+ Ecore_Evas *ee_dest;
+ Evas *evas_dest;
+
+ ee_dest = ecore_evas_buffer_new(1, 1);
+ IV_ASSERT(ee_dest != NULL);
+ evas_dest = ecore_evas_get(ee_dest);
+ IV_ASSERT(evas_dest != NULL);
+
+ Evas_Object *output;
+ output = evas_object_image_filled_add(evas_dest);
+ IV_ASSERT(output != NULL);
+
+ void *data = NULL;
+ data = (void*)ecore_evas_buffer_pixels_get(ee);
+ IV_ASSERT(data != NULL);
+
+ evas_object_image_size_set(output, w, h);
+ evas_object_image_data_set(output, data);
+
+ if (evas_object_image_save(output, filepath, NULL, NULL) == EINA_FALSE)
+ {
+ MSG_SETAS_ERROR("evas_object_image_save error. %s", filepath);
+ evas_object_del(input);
+ evas_object_del(output);
+ return EINA_FALSE;
+ }
+ else
+ {
+ int fd = open(filepath, O_RDONLY);
+ if(fd < 0)
+ {
+ MSG_SETAS_ERROR("%s open error[%d]", filepath, fd);
+ evas_object_del(input);
+ evas_object_del(output);
+ return EINA_FALSE;
+ }
+ fsync(fd);
+ int ret = close(fd);
+ if(ret < 0)
+ {
+ MSG_SETAS_ERROR("%s open error[%d]", filepath, ret);
+ }
+ }
+ evas_object_del(input);
+ evas_object_del(output);
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_ivug_setas_view_screen_create_file(Ivug_SetAsView *pSetAsView, char* screen_file)
+ {
+// Delete the home screen file if exist
+ if (ivug_remove_file(screen_file) == false)
+ {
+ MSG_SETAS_ERROR( "Detele file %s failed", screen_file);
+ return EINA_FALSE;
+ }
+
+ int x = 0;
+ int y = 0;
+ int w = 0;
+ int h = 0;
+
+ Evas *canvas;
+ Ecore_Evas *ee;
+ ee = ecore_evas_buffer_new(1, 1);
+ if (!ee)
+ {
+ MSG_DETAIL_ERROR("Cannot get EVAS");
+ return EINA_FALSE;
+ }
+ canvas = ecore_evas_get(ee);
+ Evas_Object *img = evas_object_image_add(canvas);
+
+ evas_object_image_file_set(img, NULL, NULL);
+ evas_object_image_load_orientation_set(img, EINA_TRUE);
+ evas_object_image_load_scale_down_set(img, 0);
+
+ evas_object_image_file_set(img, pSetAsView->file_path, NULL);
+ Evas_Load_Error error = evas_object_image_load_error_get(img);
+ if ( error != EVAS_LOAD_ERROR_NONE)
+ {
+ MSG_SETAS_ERROR("Decoding Error(%d) : %s", error, pSetAsView->file_path);
+ evas_object_image_file_set(img, NULL, NULL);
+ evas_object_del(img);
+ ecore_evas_free(ee);
+ return EINA_FALSE;
+ }
+
+ elm_photocam_image_region_get(pSetAsView->photocam, &x, &y, &w, &h);
+ double zoom = elm_photocam_zoom_get(pSetAsView->photocam);
+ if(zoom != 0.0)
+ {
+ w = w/zoom;
+ h = h/zoom;
+ }
+ MSG_SETAS_HIGH("w = %d, h = %d", w, h);
+ if(_ivug_setas_view_resize_save(img, screen_file, w, h) == EINA_FALSE)
+ {
+ MSG_SETAS_ERROR("setas image save faied.");
+ evas_object_image_file_set(img, NULL, NULL);
+ evas_object_del(img);
+ ecore_evas_free(ee);
+ return EINA_FALSE;
+ }
+
+ evas_object_image_file_set(img, NULL, NULL);
+ evas_object_del(img);
+ ecore_evas_free(ee);
+ return EINA_TRUE;
+}
+
+
+static void
+_ivug_setas_on_change_home_screen(void *data, Evas_Object *obj, void *event_info)
+{
+ IV_ASSERT(data != NULL);
+
+ MSG_SETAS_HIGH("Change Home Screen");
+
+ Ivug_SetAsView *pSetAsView = (Ivug_SetAsView *) data;
+
+// TODO : Remove dependancy
+ char* homescreen_path = IVUG_HOME_SCREEN_PATH;
+
+ Eina_Bool ret = EINA_FALSE;
+
+ if((ret = _ivug_setas_view_screen_create_file(pSetAsView, homescreen_path)) == EINA_FALSE)
+ {
+ MSG_SETAS_ERROR( "Create screen file failed");
+ goto end;
+ }
+
+ if( (ret = ivug_config_set_homescreen_image(homescreen_path)) == EINA_TRUE)
+ {
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, IDS_HOME_SCREEN_WALLPAPER, IDS_SUCCESS, pSetAsView);
+ }
+ else
+ {
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, IDS_HOME_SCREEN_WALLPAPER, IDS_FAILED, pSetAsView);
+ }
+
+ MSG_SETAS_HIGH("Set Home screen: %s", homescreen_path);
+end:
+ if(ret == EINA_TRUE)
+ {
+ _ivug_setas_view_send_result(gGetUGHandle(), "homescreen_path", homescreen_path, NULL, NULL);
+ }
+}
+
+static void
+_ivug_setas_on_change_lock_screen(void *data, Evas_Object *obj, void *event_info)
+{
+ IV_ASSERT(data != NULL);
+
+ MSG_SETAS_HIGH("Change Lock Screen");
+
+ Ivug_SetAsView *pSetAsView = (Ivug_SetAsView *) data;
+
+ char* lockscreen_path = IVUG_LOCK_SCREEN_PATH;
+
+ Eina_Bool ret = EINA_FALSE;
+
+ if((ret = _ivug_setas_view_screen_create_file(pSetAsView, lockscreen_path)) == EINA_FALSE)
+ {
+ MSG_SETAS_ERROR( "Create screen file failed");
+ goto end;
+ }
+
+ //Set the lock screen
+ if((ret = ivug_config_set_lockscreen_image(lockscreen_path)) == EINA_TRUE)
+ {
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, IDS_LOCK_SCREEN_WALLPAPER, IDS_SUCCESS, pSetAsView);
+ }
+ else
+ {
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, IDS_LOCK_SCREEN_WALLPAPER, IDS_FAILED, pSetAsView);
+ }
+
+ MSG_SETAS_HIGH("Set Lock screen: %s", lockscreen_path);
+end:
+ if(ret == EINA_TRUE)
+ {
+ _ivug_setas_view_send_result(gGetUGHandle(), "lockscreen_path", lockscreen_path, NULL, NULL);
+ }
+}
+
+static void
+_ivug_setas_on_change_homeNlock_screen(void *data, Evas_Object *obj, void *event_info)
+{
+ IV_ASSERT(data != NULL);
+
+ MSG_SETAS_HIGH("Change Lock Screen");
+
+ Ivug_SetAsView *pSetAsView = (Ivug_SetAsView *) data;
+
+// Set homescreen image
+ char* homescreen_path = IVUG_HOME_SCREEN_PATH;
+
+ char* lockscreen_path = IVUG_LOCK_SCREEN_PATH;
+
+ Eina_Bool ret = EINA_FALSE;
+
+ if((ret = _ivug_setas_view_screen_create_file(pSetAsView, homescreen_path)) == EINA_FALSE)
+ {
+ MSG_SETAS_ERROR( "Create screen file failed");
+ goto end;
+ }
+
+ char* temp_lock_path = IVUG_LOCK_SCREEN_TEMP_PATH;
+ if (ivug_remove_file(temp_lock_path) == false)
+ {
+ MSG_SETAS_ERROR( "Detele file %s: failed", temp_lock_path);
+ goto end;
+ }
+
+// Make a copy from home screen to lock screen
+ if((ret = ecore_file_cp(homescreen_path, temp_lock_path)) == EINA_FALSE)
+ {
+ MSG_SETAS_ERROR( "File copy failed");
+ goto end;
+ }
+ else
+ {
+ if(ivug_rename_file(temp_lock_path, lockscreen_path) == false)
+ {
+ MSG_SETAS_ERROR( "Rename file %s to %s failed", temp_lock_path, lockscreen_path );
+ if(ivug_remove_file(temp_lock_path)== false)
+ {
+ MSG_SETAS_ERROR( "delete tmp lock file failed %s", temp_lock_path);
+ }
+ ret = EINA_FALSE;
+ goto end;
+ }
+
+ sync(); //sync copied file.
+ }
+
+ char *title = elm_entry_utf8_to_markup(IDS_HOME_AND_LOCK_SCREEN_WALLPAPER);
+
+ ret = ivug_config_set_homescreen_image(homescreen_path);
+
+ if ( ret == false)
+ {
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, title, IDS_FAILED, pSetAsView);
+ }
+ else
+ {
+ ret = ivug_config_set_lockscreen_image(lockscreen_path);
+ if ( ret == false)
+ {
+ // TODO : Do I revet homescreen if either failed?????
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, title, IDS_FAILED, pSetAsView);
+ }
+ else
+ {
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, title, IDS_SUCCESS, pSetAsView);
+ }
+
+ }
+
+ MSG_SETAS_HIGH("Set Home&Lock screen: %s %s", homescreen_path, lockscreen_path);
+ free(title);
+
+end:
+ if(ret == EINA_TRUE)
+ {
+ _ivug_setas_view_send_result(gGetUGHandle(), "homescreen_path", homescreen_path, "lockscreen_path", lockscreen_path);
+ }
+}
+
+
+static void
+_ivug_setas_wallpaper_set_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ IV_ASSERT(data != NULL);
+
+ Ivug_SetAsView *pSetAsView = (Ivug_SetAsView *) data;
+ ivug_listpopup_item *item = event_info;
+
+ edje_object_signal_callback_add(_EDJ(pSetAsView->layout),
+ "setasview,set,clicked",
+ "",
+ _ivug_setas_on_icon_set_clicked,
+ (void *)pSetAsView);
+
+ if ( item == NULL ) // Cancel is selected
+ {
+ MSG_SETAS_HIGH("Cancel is selected");
+ evas_object_del(pSetAsView->genlist_popup);
+ pSetAsView->genlist_popup = NULL;
+
+ return;
+ }
+
+ MSG_SETAS_HIGH("Create SetAsView. name= %s", item->caption);
+
+ switch(item->index)
+ {
+ case IVUG_SET_AS_TYPE_HOME:
+ _ivug_setas_on_change_home_screen(data, NULL, NULL);
+ break;
+
+ case IVUG_SET_AS_TYPE_LOCK:
+ _ivug_setas_on_change_lock_screen(data, NULL, NULL);
+ break;
+
+ case IVUG_SET_AS_TYPE_BOTH:
+ _ivug_setas_on_change_homeNlock_screen(data, NULL, NULL);
+ break;
+
+ default:
+ MSG_SETAS_ERROR("Unknown Set as type : %d", item->index);
+ break;
+ }
+
+ evas_object_del(pSetAsView->genlist_popup);
+ pSetAsView->genlist_popup = NULL;
+}
+
+
+static void
+_ivug_setas_on_icon_cancel_clicked(void *data, Evas_Object* obj, const char *emission, const char *source )
+{
+ MSG_SETAS_HIGH("Cancel button clicked");
+ ivug_ret_if(!data);
+
+ Ivug_SetAsView *pSetAsView = (Ivug_SetAsView *) data;
+
+ _ivug_setas_view_remove(pSetAsView);
+}
+
+static void
+_ivug_setas_on_icon_set_clicked(void *data, Evas_Object* obj, const char *emission, const char *source )
+{
+ MSG_SETAS_HIGH("On Btn Done clicke");
+ ivug_ret_if(!data);
+
+ Ivug_SetAsView *pSetAsView = (Ivug_SetAsView *) data;
+
+ _ivug_setas_view_unregister_set_signal(pSetAsView->layout, _ivug_setas_on_icon_set_clicked);
+
+ if(pSetAsView->set_type == IVUG_CTRLBAR_SET_SCREEN_UNDEFINED)
+ {
+ // In case of setting->wallpaper
+ MSG_SETAS_HIGH("Create setas wallpaper popup");
+
+ ivug_listpopup_itemlist items = ivug_listpopup_itemlist_new();
+
+ ivug_listpopup_itemlist_add(items, IVUG_SET_AS_TYPE_HOME, NULL, IDS_HOME_SCREEN_WALLPAPER, NULL , false);
+ ivug_listpopup_itemlist_add(items, IVUG_SET_AS_TYPE_LOCK, NULL, IDS_LOCK_SCREEN_WALLPAPER, NULL , false);
+ ivug_listpopup_itemlist_add(items, IVUG_SET_AS_TYPE_BOTH, NULL, IDS_HOME_AND_LOCK_SCREEN_WALLPAPER, NULL , false);
+
+ pSetAsView->genlist_popup = ivug_listpopup_show(pSetAsView->layout, IDS_SET_AS, items, _ivug_setas_wallpaper_set_selected_cb, pSetAsView);
+
+ ivug_listpopup_itemlist_free(items);
+
+ }
+}
+
+
+static void
+_ivug_setas_on_photocam_loaded(void *data, Evas_Object *obj, void *event_info)
+{
+ Ivug_SetAsView *pSetAsView = (Ivug_SetAsView *) data;
+
+ IV_ASSERT(pSetAsView != NULL);
+
+ Evas_Load_Error error = (Evas_Load_Error)event_info;
+
+ if ( error != EVAS_LOAD_ERROR_NONE )
+ {
+ MSG_SETAS_ERROR("Error occured during decoding. Error=%d", error);
+
+// Show popup & Exit.
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, IDS_ERROR, IDS_INVALID_IMAGE_FILE, pSetAsView );
+
+ return;
+ }
+
+ elm_object_part_content_set(pSetAsView->layout, "setasview.photocam", pSetAsView->photocam);
+
+ edje_object_signal_emit(_EDJ(pSetAsView->layout), "setasview,enable,btn_ok", "elm");
+
+ edje_object_signal_callback_add(_EDJ(pSetAsView->layout),
+ "setasview,set,clicked",
+ "",
+ _ivug_setas_on_icon_set_clicked,
+ (void *)pSetAsView);
+}
+
+static Ivug_SetAsView *_create_setas_view(Evas_Object *parent, const char* filepath, ivug_set_screen_type screen_type)
+{
+ IV_ASSERT(filepath != NULL);
+
+ Ivug_SetAsView *pSetAsView = (Ivug_SetAsView *)calloc(1, sizeof(Ivug_SetAsView));
+
+ if ( pSetAsView == NULL )
+ {
+ MSG_SETAS_ERROR("Cannot allocate memory");
+ return NULL;
+ }
+
+ pSetAsView->file_path = strdup(filepath);
+ pSetAsView->set_type = screen_type;
+ pSetAsView->layout = ivug_layout_add(parent , SETAS_EDJ_FILE, "setas_view");
+
+ if ( pSetAsView->layout == NULL )
+ {
+ MSG_SETAS_ERROR("Cannot create layout.");
+ free(pSetAsView);
+ return NULL;
+ }
+
+ Evas_Object *photocam;
+ photocam = elm_photocam_add(pSetAsView->layout);
+ elm_photocam_zoom_mode_set(photocam, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
+ elm_photocam_paused_set(photocam, EINA_TRUE);
+
+ edje_object_signal_emit(_EDJ(pSetAsView->layout), "setasview,disable,btn_ok","elm"); // Disable ok button
+
+ _ivug_setas_view_show_icons(pSetAsView->layout);
+
+ evas_object_smart_callback_add(photocam, "loaded", _ivug_setas_on_photocam_loaded, (void *)pSetAsView);
+
+ pSetAsView->photocam = photocam;
+
+ Evas_Load_Error error = EVAS_LOAD_ERROR_NONE;
+
+// Get Screen size
+ Evas_Coord w, h;
+ evas_object_geometry_get(pSetAsView->layout, NULL, NULL, &w, &h);
+
+ evas_object_show(photocam);
+
+ error = elm_photocam_file_set(photocam, filepath);
+
+ if ( error != EVAS_LOAD_ERROR_NONE )
+ {
+ // TODO : What is good for error handing??????
+ MSG_SETAS_ERROR("FileSet Error=%d", error);
+
+ if ( error == EVAS_LOAD_ERROR_UNKNOWN_FORMAT )
+ {
+ _ivug_setas_view_send_result(gGetUGHandle(), IVUG_RESULT_BUNDLE_KEY_ERROR, IVUG_RESULT_BUNDLE_VALUE_NOT_SUPPORTED, NULL, NULL);
+ ivug_setas_view_destroy(pSetAsView);
+
+ return NULL;
+ }
+ else if ( error == EVAS_LOAD_ERROR_PERMISSION_DENIED )
+ {
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, IDS_ERROR, IDS_PERMISSION_DENIED, pSetAsView );
+ return pSetAsView;
+ }
+ else
+ {
+ pSetAsView->popup = _ivug_setas_view_show_exit_popup(pSetAsView->layout, IDS_ERROR, IDS_INVALID_IMAGE_FILE, pSetAsView );
+ return pSetAsView;
+ }
+
+ }
+
+ edje_object_signal_callback_add(_EDJ(pSetAsView->layout),
+ "setasview,cancel,clicked",
+ "",
+ _ivug_setas_on_icon_cancel_clicked,
+ (void *)pSetAsView);
+
+ const Evas_Object *event = edje_object_part_object_get(_EDJ(pSetAsView->layout), "event");
+ if(!event)
+ {
+ MSG_SETAS_ERROR("event object is NULL");
+ }
+ else
+ {
+ evas_object_event_callback_add((Evas_Object *)event, EVAS_CALLBACK_MOUSE_DOWN, _ivug_setas_view_mouse_down_cb, pSetAsView);
+ evas_object_event_callback_add((Evas_Object *)event, EVAS_CALLBACK_MOUSE_UP, _ivug_setas_view_mouse_up_cb, pSetAsView);
+ }
+
+ return pSetAsView;
+
+}
+
+Ivug_SetAsView *
+ivug_setas_view_screen_ug_create(Evas_Object *parent, const char* filepath)
+{
+ Ivug_SetAsView *pSetAsView = NULL;
+
+ MSG_SETAS_HIGH("Wallpaper UG creates");
+
+ pSetAsView = _create_setas_view(parent, filepath, IVUG_CTRLBAR_SET_SCREEN_UNDEFINED);
+
+ if ( pSetAsView == NULL )
+ {
+ MSG_SETAS_ERROR("Cannot create Wallpaper UG");
+ return NULL;
+ }
+
+ evas_object_event_callback_add(pSetAsView->layout, EVAS_CALLBACK_DEL, _setas_ug_view_deleted, "Wallpaper UG");
+
+ return pSetAsView;
+}
+
+
+Evas_Object *
+ivug_setas_view_object_get(Ivug_SetAsView *pSetAsView)
+{
+ IV_ASSERT(pSetAsView != NULL);
+
+ return pSetAsView->layout;
+}
+
+void
+ivug_setas_view_destroy(Ivug_SetAsView *pSetAsView)
+{
+ MSG_SETAS_HIGH("Removing SetAs VIew");
+
+ ivug_ret_if(!pSetAsView);
+
+ const Evas_Object *event = edje_object_part_object_get(_EDJ(pSetAsView->layout), "event");
+ if(event != NULL)
+ {
+ evas_object_event_callback_del((Evas_Object *)event, EVAS_CALLBACK_MOUSE_DOWN, _ivug_setas_view_mouse_down_cb);
+ evas_object_event_callback_del((Evas_Object *)event, EVAS_CALLBACK_MOUSE_UP, _ivug_setas_view_mouse_up_cb);
+ }
+
+ if (pSetAsView->click_timer)
+ {
+ ecore_timer_del(pSetAsView->click_timer);
+ pSetAsView->click_timer = NULL;
+ }
+
+ if(pSetAsView->genlist_popup)
+ {
+ evas_object_del(pSetAsView->genlist_popup);
+ pSetAsView->genlist_popup = NULL;
+ }
+
+ if(pSetAsView->popup)
+ {
+ evas_object_del(pSetAsView->popup);
+ pSetAsView->popup = NULL;
+ }
+
+ if(pSetAsView->select_box)
+ {
+ evas_object_del(pSetAsView->select_box);
+ pSetAsView->select_box = NULL;
+ }
+
+ if(pSetAsView->photocam)
+ {
+ evas_object_del(pSetAsView->photocam);
+ pSetAsView->photocam = NULL;
+ }
+
+ if(pSetAsView->file_path)
+ {
+ free(pSetAsView->file_path);
+ pSetAsView->file_path = NULL;
+ }
+
+ if(pSetAsView->layout)
+ {
+ evas_object_del(pSetAsView->layout);
+ pSetAsView->layout = NULL;
+ }
+
+ if ( pSetAsView->ly_effect)
+ {
+ evas_object_del(pSetAsView->ly_effect);
+ pSetAsView->ly_effect = NULL;
+ }
+
+ if(pSetAsView)
+ {
+ free(pSetAsView);
+ }
+ pSetAsView = NULL;
+
+}
+
+
diff --git a/main/src/view/ivug-setas-view.h b/main/src/view/ivug-setas-view.h
new file mode 100755
index 0000000..2e1dc5c
--- /dev/null
+++ b/main/src/view/ivug-setas-view.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __SETAS_VIEW_H__
+#define __SETAS_VIEW_H__
+
+#include "ivug-common.h"
+
+typedef enum {
+ NOTI_SUCCESS,
+ NOTI_FAIL,
+} TEXT_POPUP_TYPE;
+
+typedef enum {
+ IVUG_CTRLBAR_SET_SCREEN_HOME,
+ IVUG_CTRLBAR_SET_SCREEN_LOCK,
+ IVUG_CTRLBAR_SET_SCREEN_BOTH,
+ IVUG_CTRLBAR_SET_SCREEN_UNDEFINED, // Show select popup when click ok button.
+ IVUG_CTRLBAR_SET_SCREEN_MAX
+} ivug_set_screen_type;
+
+typedef struct {
+ Evas_Object *parent;
+ Evas_Object *ly_effect; // Layout for transition effect
+
+ Evas_Object *layout;
+
+/*
+ |------------------|
+ | naviframe |
+ |------------------|
+ | toolbar |
+ |------------------|
+ | |
+ | |
+ | |
+ | |
+ |------------------|
+ | controlbar |
+ |------------------|
+*/
+ Evas_Object *photocam;
+ Evas_Object *toolbar;
+ Evas_Object *content; // Empty layout
+
+ Evas_Object *select_box;
+
+ struct {
+ int x, y, h, w;
+ } select_rect;
+
+ Evas_Object *popup;
+ Evas_Object *done_button;
+
+ char *file_path;
+
+ Eina_Bool b_hide_bar_flag;
+
+
+ Ecore_Timer *timer_locate_rect;
+
+ // click event
+ Evas_Coord_Point down_pos;
+ unsigned int timestamp;
+ Ecore_Timer *click_timer;
+
+ ivug_set_screen_type set_type;
+
+ Evas_Object *genlist_popup;
+ Eina_List *popup_list;
+} Ivug_SetAsView;
+
+
+Ivug_SetAsView *
+ivug_setas_view_screen_ug_create(Evas_Object *parent, const char* filepath);
+
+void
+ivug_setas_view_destroy(Ivug_SetAsView *data);
+
+Evas_Object *
+ivug_setas_view_object_get(Ivug_SetAsView *pSetAsView);
+
+#endif //__SETAS_VIEW_H__
diff --git a/main/src/view/ivug-slider-item.c b/main/src/view/ivug-slider-item.c
new file mode 100755
index 0000000..1b33e0c
--- /dev/null
+++ b/main/src/view/ivug-slider-item.c
@@ -0,0 +1,703 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+
+#include "ivug-slider-item.h"
+
+#include "ivug-main.h"
+
+#define DEFAULT_THUMBNAIL_PATH IMAGE_PATH"/T01_Nocontents_broken.png"
+
+#define IVUG_SLIDER_EDJ EDJ_PATH"/ivug-slider.edj"
+
+/*
+ Use elm_icon istead of elm_image. elm_icon preserve image ratio. and seems more faster.
+*/
+#define USE_ELM_ICON
+
+bool
+_thumbnail_set( Slide_Item* si, const char *filepath)
+{
+ IV_ASSERT(si != NULL);
+ IV_ASSERT(filepath != NULL);
+
+ if (si->thumbnail == NULL)
+ {
+ MSG_SITEM_FATAL("slide item or thumbnail object is NULL");
+ return false;
+ }
+
+ MSG_SITEM_MED("Set thumbnail : %s", ivug_get_filename(filepath));
+
+#ifdef USE_ELM_ICON
+ if (elm_icon_file_set(si->thumbnail, filepath, NULL) == EINA_FALSE)
+ {
+ MSG_SITEM_ERROR("Cannot load thumbnail : %s", filepath);
+ si->thumbnail_show = EINA_FALSE;
+ return false;
+ }
+
+#else
+ if (elm_image_file_set(si->thumbnail, filepath, NULL) == EINA_FALSE)
+ {
+ MSG_SITEM_ERROR("Cannot load thumbnail : %s", filepath);
+ si->thumbnail_show = EINA_FALSE;
+ return false;
+ }
+#endif
+ edje_object_signal_emit(_EDJ(si->layout), "elm,state,show_thumbnail", "slider");
+
+ si->thumbnail_show = EINA_TRUE;
+ return true;
+}
+
+
+inline
+void _call_user_callback(Slide_Item* si)
+{
+ if ( si->cb )
+ {
+ (si->cb)(si->state, si, si->client_data);
+ }
+
+}
+
+
+static void
+_photocam_loaded_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ IV_ASSERT(data != NULL);
+
+ Slide_Item* si = data;
+
+ //hide progress.
+ elm_progressbar_pulse(si->progress, EINA_FALSE); //stop pluse
+ edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide,progress", "slider");
+
+ if ( si->mitem == NULL)
+ {
+ MSG_SITEM_ERROR("Debug Me! Data item is NULL.");
+ return;
+ }
+
+ Media_Data* sdata = ivug_data_get_data(si->mitem);
+ if(sdata == NULL)
+ {
+ MSG_SITEM_ERROR("ivug_data_get_data failed.");
+ si->state = SLIDE_STATE_ERROR;
+ return;
+ }
+
+ Evas_Load_Error error = (Evas_Load_Error)event_info;
+
+ if ( error != EVAS_LOAD_ERROR_NONE )
+ {
+ MSG_SITEM_ERROR("Image loading failed. Error=%d", error);
+ si->state = SLIDE_STATE_ERROR;
+
+ si->photocam_show = EINA_FALSE;
+ evas_object_hide(obj);
+
+ _thumbnail_set(si, DEFAULT_THUMBNAIL_PATH);
+
+ evas_object_repeat_events_set(si->thumbnail, EINA_FALSE);
+
+ _call_user_callback(si);
+
+ return ;
+ }
+
+ si->state = SLIDE_STATE_LOADED;
+
+ if (sdata->slide_type == SLIDE_TYPE_VIDEO) //if slide type is video,
+ {
+ // TODO : Never get here..
+ MSG_SITEM_FATAL("slide type is video. thumbnail image ");
+ return;
+ }
+
+ si->photocam_show = EINA_TRUE;
+ evas_object_show(obj); //photocam show.
+
+// evas_object_move(obj, si->x, si->y);
+
+//hide thumbnail.
+ if(si->thumbnail_show == EINA_TRUE)
+ {
+ MSG_SITEM_HIGH("Thumbnail Hide");
+ edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide_thumbnail", "slider");
+ si->thumbnail_show = EINA_FALSE;
+ }
+
+ _call_user_callback(si);
+
+ MSG_SITEM_HIGH("Photocam Pre-loaded. File=%s", ivug_get_filename(sdata->filepath));
+}
+
+Slide_Item*
+ivug_slider_item_add(Evas_Object *slider)
+{
+ Slide_Item* si = NULL;
+
+ //create item
+ si = (Slide_Item*)calloc(1, sizeof (Slide_Item));
+
+ if ( si == NULL )
+ {
+ MSG_SITEM_FATAL("Cannot allocated memory : %d.", sizeof (Slide_Item));
+ return NULL;
+ }
+
+ si->state = SLIDE_STATE_NONE; //set slide state
+
+//Create the slider item layout
+ Evas_Object *layout = elm_layout_add(slider);
+ if(elm_layout_file_set(layout, IVUG_SLIDER_EDJ, "slider") == EINA_FALSE)
+ {
+ MSG_SITEM_ERROR("Cannot load file : %s", IVUG_SLIDER_EDJ);
+ free(si);
+
+ return NULL;
+ }
+
+ si->layout = layout;
+
+//Add the photocam
+ si->photocam = elm_photocam_add(slider);
+ elm_photocam_zoom_mode_set(si->photocam, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
+ elm_photocam_paused_set(si->photocam, EINA_TRUE);
+ evas_object_smart_callback_call(si->photocam, "scroll-freeze-on", si->photocam);
+ evas_object_smart_callback_add(si->photocam, "loaded", _photocam_loaded_cb, si);
+
+ elm_object_part_content_set(si->layout, "slider.photocam", si->photocam);
+
+//set thumbnail.
+#ifdef USE_ELM_ICON
+ si->thumbnail = elm_icon_add(slider);
+#else
+ si->thumbnail = elm_image_add(slider);
+#endif
+ elm_object_part_content_set(si->layout, "slider.thumbnail", si->thumbnail);
+
+//set progress
+ si->progress = elm_progressbar_add(slider);
+ elm_object_style_set(si->progress, "list_process");
+ elm_progressbar_pulse(si->progress, EINA_FALSE);
+
+ elm_object_part_content_set(si->layout, "slider.progress", si->progress);
+
+ si->icon = edje_object_part_object_get(_EDJ(si->layout), "slider.icon");
+
+ evas_object_clip_set(si->layout, slider);
+
+// Add ÇÏ´Â ¼ø¼­¿¡ µû¶ó Z-OrderÀÌ °áÁ¤ µÈ´Ù.
+ evas_object_smart_member_add(si->layout, slider);
+
+ si->w = gGetScreenWidth();
+ si->h = gGetScreenHeight();
+
+ MSG_SITEM_HIGH("Creating slider item. 0x%08x. WH(%dx%d)", si, si->w, si->h);
+
+ return si;
+
+}
+
+void
+ivug_slider_item_resize(Slide_Item* si, int w, int h)
+{
+ IV_ASSERT(si != NULL );
+
+ // TODO : Impelement
+ MSG_SITEM_HIGH("SLIDER Resize to WH(%d,%d)", w, h );
+
+// w,h is not Image's scale, but Object's scale
+ si->w = w;
+ si->h = h;
+
+// MSG_SITEM_HIGH("resize layout: %d, %d", si->w, si->h);
+ evas_object_resize(si->layout, si->w, si->h);
+
+ ivug_slider_item_zoom_reset(si, EINA_FALSE, 0,0);
+}
+
+void ivug_slider_item_del(Slide_Item* si)
+{
+ IV_ASSERT(si != NULL );
+
+ if (si->photocam)
+ {
+ evas_object_del(si->photocam); //remove photocam
+ si->photocam = NULL;
+ }
+
+ if (si->thumbnail)
+ {
+ evas_object_del(si->thumbnail);
+ si->thumbnail = NULL;
+ }
+
+ if (si->progress)
+ {
+ evas_object_del(si->progress);
+ si->progress = NULL;
+ }
+
+ if(si->layout)
+ {
+ evas_object_del(si->layout);
+ si->layout = NULL;
+ }
+
+ free(si);
+
+ MSG_SITEM_HIGH("Slide item is deleted");
+}
+
+void ivug_slider_item_hide(Slide_Item* si)
+{
+ IV_ASSERT(si != NULL );
+
+ MSG_SITEM_HIGH("hide bg");
+ evas_object_hide(si->layout);
+}
+
+void ivug_slider_item_show(Slide_Item* si)
+{
+ IV_ASSERT(si != NULL );
+
+// no need to check layout is NULL
+ evas_object_show(si->layout);
+}
+
+void ivug_slider_item_move(Slide_Item* si, int x, int y)
+{
+ IV_ASSERT(si != NULL );
+
+
+// MSG_SITEM_HIGH("SLIDER(%d) Move to XY(%d,%d)", si->idx, x, y );
+ //photocam
+ si->x = x;
+ si->y = y;
+
+// MSG_SITEM_HIGH("move layout: %d, %d", x, y);
+ evas_object_move(si->layout, x, y);
+}
+
+void
+ivug_slider_item_clip_set(Slide_Item* si, Evas_Object *clipper)
+{
+ IV_ASSERT(si != NULL );
+// no need to check layout is NULL
+ MSG_SITEM_HIGH("Clip SET!!");
+
+ evas_object_clip_set(si->layout, clipper);
+}
+
+void
+ivug_slider_item_clip_unset(Slide_Item* si)
+{
+ IV_ASSERT(si != NULL );
+// no need to check layout is NULL
+ evas_object_clip_unset(si->layout);
+}
+
+bool
+ivug_slider_item_set_callback(Slide_Item* si, OnSliderStateChanged cb, void *data)
+{
+ ivug_retv_if(!si, false);
+
+ si->cb = cb;
+ si->client_data = data;
+
+ return true;
+}
+
+bool
+ivug_slider_item_data_loading(Slide_Item *si)
+{
+ IV_ASSERT(si != NULL);
+
+ if ( si->state != SLIDE_STATE_READY)
+ {
+ MSG_SITEM_ERROR("Invalid state : %d", si->state);
+ return false;
+ }
+
+ Media_Data *mdata = ivug_data_get_data(si->mitem);
+ if ( mdata == NULL )
+ {
+ MSG_SITEM_ERROR("Data is NULL");
+ return false;
+ }
+
+ char path[IVUG_MAX_FILE_PATH_LEN] = {0,};
+
+ strncpy(path, mdata->filepath, strlen(mdata->filepath));
+
+ switch(mdata->slide_type)
+ {
+ case SLIDE_TYPE_IMAGE:
+ {
+ MSG_SITEM_HIGH("Load Image. %s", ivug_get_filename(path));
+ si->state = SLIDE_STATE_LOADING;
+
+ if (elm_photocam_file_set(si->photocam, path) != EVAS_LOAD_ERROR_NONE)
+ {
+ MSG_SITEM_ERROR("Failed photocam to set file file=%s", path);
+
+ _photocam_loaded_cb(si, si->photocam, (void *) EVAS_LOAD_ERROR_UNKNOWN_FORMAT);
+
+ return false;
+ }
+
+ return true;
+
+ }
+ break;
+
+ case SLIDE_TYPE_VIDEO:
+ return true;
+ break;
+
+ default:
+ MSG_SITEM_ERROR("slide type invaild. Type=%d", mdata->slide_type);
+ return false;
+ break;
+ }
+
+ return true;
+}
+
+
+bool
+ivug_slider_item_data_set(Slide_Item* si, Media_Item *item)
+{
+ ivug_retv_if(!si, false);
+
+ if ( si->state != SLIDE_STATE_NONE )
+ {
+ MSG_SITEM_ERROR("State is not none... State=%d", si->state);
+ si->state = SLIDE_STATE_NONE;
+ }
+
+ if ( item == NULL )
+ {
+ MSG_SITEM_WARN("Item is NULL");
+ return false;
+ }
+
+ si->mitem = item;
+
+ Media_Data *mdata = ivug_data_get_data(item);
+
+ if ( mdata == NULL )
+ {
+ MSG_SITEM_ERROR("Data is NULL");
+ return false;
+ }
+
+ switch(mdata->slide_type)
+ {
+ case SLIDE_TYPE_IMAGE:
+ MSG_SITEM_HIGH("Set image. %s", ivug_get_filename(mdata->filepath));
+
+ si->state = SLIDE_STATE_READY;
+
+ break;
+ case SLIDE_TYPE_VIDEO:
+ if (mdata->thumbnail_path)
+ {
+ _thumbnail_set(si, mdata->thumbnail_path);
+ // Go through
+ }
+ else
+ {
+ _thumbnail_set(si, DEFAULT_THUMBNAIL_PATH);
+ }
+
+ si->photocam_show = EINA_FALSE;
+
+ evas_object_repeat_events_set(si->thumbnail, EINA_FALSE); // In case of video, photocam should not receive events
+
+ edje_object_signal_emit(_EDJ(si->layout), "elm,state,show_icon", "slider"); // Video icon
+
+ MSG_SITEM_HIGH("Set video. %s", ivug_get_filename(mdata->filepath));
+
+ si->state = SLIDE_STATE_LOADED; // Video dont need to load photocam
+
+ break;
+
+ case SLIDE_TYPE_UNKNOWN:
+ if (mdata->thumbnail_path)
+ {
+ _thumbnail_set(si, mdata->thumbnail_path);
+ // Go through
+ }
+
+ MSG_SITEM_ERROR("Unknown image. %s", ivug_get_filename(mdata->filepath));
+
+ si->state = SLIDE_STATE_ERROR;
+
+ break;
+
+ default:
+ MSG_SITEM_ERROR("slide type invaild. Type=%d", mdata->slide_type);
+ si->state = SLIDE_STATE_ERROR;
+ return false;
+ break;
+
+ }
+
+ si->zoom_level = 0;
+
+ return true;
+}
+
+slide_state_t
+ivug_slider_item_get_state(Slide_Item *si)
+{
+ IV_ASSERT(si != NULL);
+
+ return si->state;
+}
+
+const Media_Item *
+ivug_slider_item_data_get(Slide_Item *si)
+{
+ IV_ASSERT(si != NULL);
+
+ return si->mitem;
+}
+
+
+void
+ivug_slider_item_data_unset(Slide_Item* si)
+{
+ IV_ASSERT(si != NULL);
+
+ if ( si->state == SLIDE_STATE_NONE )
+ {
+ MSG_SITEM_WARN("Slide item is already cleared. just return");
+ return;
+ }
+
+ if(si->progress)
+ {
+ elm_progressbar_pulse(si->progress, EINA_FALSE); //stop pluse
+ edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide,progress", "slider");
+ }
+
+ if ( si->mitem == NULL )
+ {
+ // When delete case, this code is launched.
+ MSG_SITEM_WARN("MItem is NULL.");
+ // Go through
+ }
+ else
+ {
+ Media_Data *mdata = ivug_data_get_data(si->mitem);
+
+ if ( mdata == NULL )
+ {
+ MSG_SITEM_ERROR("Data is NULL");
+ return ;
+ }
+
+ MSG_SITEM_HIGH("Clear Image. %s", ivug_get_filename(mdata->filepath));
+
+ si->mitem = NULL;
+ }
+
+ if (si->thumbnail_show)
+ {
+ si->thumbnail_show = EINA_FALSE;
+ edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide_thumbnail", "slider");
+ }
+
+ if(si->layout)
+ {
+ edje_object_signal_emit(_EDJ(si->layout), "elm,state,hide_icon", "slider");
+ }
+
+// does not check photocam_show flags. because photocam_show only set true when finish preloading.
+// during preloading photocam_show is remains false,
+ si->photocam_show = EINA_FALSE;
+// elm_layout_content_unset(si->layout, "slider.photocam"); //
+
+ evas_object_hide(si->photocam);
+
+ evas_object_del(si->photocam);
+ si->photocam = elm_photocam_add(si->layout);
+ elm_photocam_zoom_mode_set(si->photocam, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
+ elm_photocam_paused_set(si->photocam, EINA_TRUE);
+ evas_object_smart_callback_call(si->photocam, "scroll-freeze-on", si->photocam);
+ evas_object_smart_callback_add(si->photocam, "loaded", _photocam_loaded_cb, si);
+ elm_object_part_content_set(si->layout, "slider.photocam", si->photocam);
+
+ si->state = SLIDE_STATE_NONE;
+
+ si->zoom_level = 0;
+
+ MSG_SITEM_MED("Slider Item is cleared.");
+
+}
+
+
+void ivug_slider_item_change_mitem_pointer(Slide_Item* si, Media_Item *item)
+{
+ IV_ASSERT(si != NULL );
+
+ si->mitem = item;
+}
+
+
+
+// Photocam
+bool
+ivug_slider_item_region_size_get(Slide_Item* si, int *x, int *y, int *w, int *h)
+{
+ IV_ASSERT(si != NULL );
+
+ if ( si->mitem == NULL)
+ {
+ MSG_SITEM_ERROR("Debug Me! Data item is NULL.");
+ return false;
+ }
+
+ Media_Data *mdata = ivug_data_get_data(si->mitem);
+
+ if ( mdata == NULL )
+ {
+ MSG_SITEM_ERROR("slide type is NULL. Item=0x%08x", si);
+ return false; // TODO : Temp..
+ }
+
+ if ( mdata->slide_type == SLIDE_TYPE_VIDEO)
+ {
+ return false;
+ }
+
+ Evas_Object *image = elm_photocam_internal_image_get(si->photocam);
+ evas_object_geometry_get(image, x, y, w, h);
+ MSG_SITEM_MED("x = %d, y = %d, w = %d, h = %d", *x, *y, *w, *h);
+
+ return true;
+}
+
+
+
+void
+ivug_slider_item_hold_set(Slide_Item* si, Eina_Bool hold)
+{
+ IV_ASSERT(si != NULL );
+
+ if(hold == EINA_TRUE)
+ {
+ evas_object_smart_callback_call(si->photocam, "scroll-freeze-on", si->photocam);
+ }
+ else
+ {
+ evas_object_smart_callback_call(si->photocam, "scroll-freeze-off", si->photocam);
+ }
+}
+
+
+void
+ivug_slider_item_zoom_reset(Slide_Item* si, Eina_Bool bAnim, int center_x, int center_y)
+{
+ IV_ASSERT(si != NULL );
+
+ if ( si->photocam_show )
+ {
+ Evas_Point pt;
+
+ pt.x = center_x;
+ pt.y = center_y;
+ elm_photocam_paused_set(si->photocam, !bAnim); //stop photocam animation
+ elm_photocam_zoom_mode_set(si->photocam, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
+
+ si->zoom_level = 0;
+ }
+}
+
+
+void
+ivug_slider_item_zoom_set(Slide_Item* si, double zoom, int center_x, int center_y)
+{
+ IV_ASSERT(si != NULL );
+
+ if ( si->photocam_show )
+ {
+ elm_photocam_paused_set(si->photocam, EINA_FALSE); //stop photocam animation
+ elm_photocam_zoom_mode_set(si->photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
+ elm_photocam_zoom_set(si->photocam, zoom);
+ }
+}
+
+double
+ivug_slider_item_zoom_get(Slide_Item* si)
+{
+ IV_ASSERT(si != NULL );
+
+ double ret = 1.0;
+
+ if ( si->photocam_show )
+ {
+ ret = elm_photocam_zoom_get(si->photocam);
+ }
+ return ret;
+}
+
+
+bool
+ivug_slider_item_icon_click_check(Slide_Item *si, int x, int y)
+{
+ MSG_SITEM_HIGH("Check icon clicked. SI=0x%08x, XY(%d,%d)", si, x, y);
+
+ IV_ASSERT(si != NULL );
+
+ Media_Data *mdata = ivug_data_get_data(si->mitem);
+
+ if ( mdata == NULL )
+ {
+ MSG_SITEM_ERROR("Debug Me! Data item is NULL.");
+ return false;
+ }
+
+ if ( mdata->slide_type == SLIDE_TYPE_VIDEO )
+ {
+ if (si->icon)
+ {
+ Evas_Coord ix,iy,iw,ih;
+
+ evas_object_geometry_get(si->icon, &ix, &iy, &iw, &ih);
+
+ bool bInside = !( (x) > (ix + iw) || (x) < (ix)
+ || (y) > (iy + iw) || (y) < (iy) );
+
+ MSG_SITEM_HIGH("Item XYWH(%d,%d,%d,%d) XY(%d,%d) bInside=%d", ix,iy,iw,ih, x, y, bInside);
+
+ return bInside;
+ }
+ }
+
+ MSG_SITEM_HIGH("Slide type = %d", mdata->slide_type);
+ return false;
+}
+
+
diff --git a/main/src/view/ivug-slider-item.h b/main/src/view/ivug-slider-item.h
new file mode 100755
index 0000000..6bbc54d
--- /dev/null
+++ b/main/src/view/ivug-slider-item.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#pragma once
+
+#include "ivug-data.h"
+
+typedef enum SLIDE_STATE {
+ SLIDE_STATE_NONE = 0x00,
+ SLIDE_STATE_READY,
+ SLIDE_STATE_LOADING, // Load main image or downloading
+ SLIDE_STATE_LOADED, // Image is shown
+ SLIDE_STATE_ERROR,
+} slide_state_t;
+
+typedef struct _Slide_Item Slide_Item;
+
+typedef void (*OnSliderStateChanged)(slide_state_t state, Slide_Item *si, void *client_data);
+
+struct _Slide_Item {
+ int x, y, w, h; // Object geometry
+//Data
+ slide_state_t state; // Currently not used, just for debugging.
+ Media_Item *mitem;
+
+//flag
+ Eina_Bool photocam_show;
+ Eina_Bool thumbnail_show;
+
+// UI
+ Evas_Object* layout;
+ const Evas_Object* icon; //video icon
+ Evas_Object* thumbnail; // thumbnail
+ Evas_Object* photocam; //photocam data.
+ Evas_Object* progress; //progress bar
+
+ unsigned int thumb_w, thumb_h; // thumbnail width height.
+
+ unsigned int zoom_level;
+
+// Callback
+ OnSliderStateChanged cb;
+ void *client_data;
+
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// GUI related
+Slide_Item*
+ivug_slider_item_add(Evas_Object *slider);
+
+void
+ivug_slider_item_del(Slide_Item *si);
+
+void
+ivug_slider_item_hide(Slide_Item *si);
+
+void
+ivug_slider_item_show(Slide_Item *si);
+
+void
+ivug_slider_item_move(Slide_Item *si, int x, int y);
+
+void
+ivug_slider_item_resize(Slide_Item *si, int w, int h);
+
+void
+ivug_slider_item_clip_set(Slide_Item *si, Evas_Object *clipper);
+
+void
+ivug_slider_item_clip_unset(Slide_Item *si);
+
+// Data
+bool
+ivug_slider_item_set_callback(Slide_Item* si, OnSliderStateChanged cb, void *data);
+
+bool
+ivug_slider_item_data_set(Slide_Item *si, Media_Item *item);
+
+bool
+ivug_slider_item_data_loading(Slide_Item *si);
+
+void
+ivug_slider_item_change_mitem_pointer(Slide_Item *si, Media_Item *item); // confused API!!!
+
+void
+ivug_slider_item_data_unset(Slide_Item *si);
+
+slide_state_t
+ivug_slider_item_get_state(Slide_Item *si);
+
+const Media_Item *
+ivug_slider_item_data_get(Slide_Item *si);
+
+// Control
+bool
+ivug_slider_item_region_size_get(Slide_Item *si, int *x, int *y, int *w, int *h);
+
+void
+ivug_slider_item_hold_set(Slide_Item *si, Eina_Bool hold);
+
+void
+ivug_slider_item_zoom_reset(Slide_Item *si, Eina_Bool bAnim, int center_x, int center_y);
+
+void
+ivug_slider_item_zoom_set(Slide_Item *si, double zoom, int center_x, int center_y);
+
+double
+ivug_slider_item_zoom_get(Slide_Item* si);
+
+bool
+ivug_slider_item_icon_click_check(Slide_Item *si, int x, int y);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
diff --git a/main/src/view/ivug-slider-mouse.c b/main/src/view/ivug-slider-mouse.c
new file mode 100755
index 0000000..2f3f190
--- /dev/null
+++ b/main/src/view/ivug-slider-mouse.c
@@ -0,0 +1,439 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-mouse-event.h"
+#include "ivug-anim.h"
+#include "ivug-slider-item.h"
+#include "ivug-slider.h"
+#include "ivug-effect.h"
+
+#include "ivug-slider-priv.h"
+
+#define SIG_CLICKED "slider,clicked"
+#define SIG_LONGPRESSED "slider,longpressed"
+
+#define SHIFT_THRESHOLD (0.0f) // 52%
+
+
+static bool _ivug_slider_check_flick(MouseEvent *down, MouseEvent *up)
+{
+#define FLICK_TIME_MAX (200) //flick time value.
+#define FLICK_WIDTH_MIN (elm_config_finger_size_get() >> 2)
+
+ if ( up->event_flags & EVAS_EVENT_FLAG_ON_HOLD )
+ {
+ MSG_SLIDER_HIGH("On hold detected");
+ return false;
+ }
+
+// Check pinch zoom right before zoom
+ if ( (up->timestamp - down->timestamp) > FLICK_TIME_MAX )
+ {
+ MSG_SLIDER_HIGH("Not flick opertion. TimeGap=%d", up->timestamp - down->timestamp);
+ return false;
+ }
+
+// TODO : Consider Y axis flick.
+ int delta_x = up->x - down->x;
+ int delta_y = up->y - down->y;
+
+ if (abs(delta_x) < FLICK_WIDTH_MIN)
+ {
+ MSG_SLIDER_HIGH("Not flick opertion. Delta X=%d Delta Y=%d", delta_x, delta_y);
+ return false;
+ }
+
+ return true;
+
+}
+
+
+static bool _ivug_slider_check_click(MouseEvent *down, MouseEvent *up)
+{
+#define CLICK_TIME_MIN (7)
+#define CLICK_TIME_MAX (500) /* 500 < long press */
+
+#define CLICK_WIDTH_MAX (elm_config_finger_size_get() >> 2)
+
+ if ( down->device != up->device )
+ {
+ MSG_SLIDER_HIGH("Not click. Device=%d %d", down->device , up->device);
+ return false;
+ }
+
+ if (up->button_flags & EVAS_BUTTON_DOUBLE_CLICK)
+ {
+ MSG_SLIDER_HIGH("Up.. Double clicked!!");
+ return false;
+ }
+
+ int dTS = (up->timestamp - down->timestamp);
+ if ( (dTS < CLICK_TIME_MIN) || (dTS > CLICK_TIME_MAX) )
+ {
+ MSG_SLIDER_HIGH("Not click. TS=%d", (up->timestamp - down->timestamp));
+ return false;
+ }
+
+ unsigned int dist = get_distance(down->x, down->y, up->x, up->y);
+
+ if ( dist < (unsigned int)CLICK_WIDTH_MAX)
+ {
+ MSG_SLIDER_HIGH("Detect Clicked event. TS=%d, Dist=%d", dTS, dist);
+ return true;
+ }
+
+ MSG_SLIDER_HIGH("Not Click : TS=%dms Dis=%d", dTS, dist);
+
+ return false;
+}
+
+static Eina_Bool _long_pressed(void *data)
+{
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(data);
+
+ if (!sd) return ECORE_CALLBACK_CANCEL;
+
+ sd->long_timer = NULL;
+
+ Evas_Coord_Point down;
+
+ down.x = sd->down.x;
+ down.y = sd->down.y;
+
+ evas_object_smart_callback_call(data, SIG_LONGPRESSED, &down);
+
+ MSG_SLIDER_HIGH("Long pressed!!!!!");
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _clicked(void *data)
+{
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(data);
+
+ if (!sd) return ECORE_CALLBACK_CANCEL;
+
+ sd->click_timer = NULL;
+
+ Evas_Coord_Point down;
+
+ down.x = sd->down.x;
+ down.y = sd->down.y;
+
+ // Check video icon clicked or not/
+ Slide_Item *si = sd->slide[CENTER_SLIDE];
+
+ if ( ivug_slider_item_icon_click_check(si, down.x, down.y) == true ) // Video icon clicked.
+ {
+ MSG_SLIDER_HIGH("Video icon clicked!!!!!");
+
+ evas_object_smart_callback_call(data, "slider,clicked,icon", &down);
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if(sd->ss_state == SLIDE_SHOW_RUNNING)/* this click is for stop slide show */
+ {
+ ivug_slider_stop_slide_show(sd->obj);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ evas_object_smart_callback_call(data, SIG_CLICKED, &down); // For change menu visibility
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+void _ivug_on_mouse_down(Evas_Object *obj, MouseEvent *down, void *data)
+{
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(data);
+ Slide_Item* si = sd->slide[CENTER_SLIDE];
+
+ MSG_SLIDER_HIGH("%s. down->XY(%d,%d)", __func__, down->x, down->y);
+
+//save down position.
+ sd->down = *down;
+
+// End animation
+ if(sd->animator)
+ {
+ ecore_animator_del(sd->animator);
+ sd->animator = NULL;
+
+ MSG_SLIDER_HIGH("Animation is working. stopping animation. Current SI->XY(%d,%d)", si->x, si->y);
+ }
+
+ sd->edge = _ivug_slider_edge_state_get(si);
+
+ if (down->button_flags & EVAS_BUTTON_DOUBLE_CLICK)
+ {
+ MSG_SLIDER_HIGH("Double clicked!!");
+ }
+
+ if (sd->long_timer)
+ {
+ ecore_timer_del(sd->long_timer);
+ sd->long_timer = NULL;
+ }
+
+ if (sd->click_timer)
+ {
+ ecore_timer_del(sd->click_timer);
+ sd->click_timer = NULL;
+ }
+
+ if ( sd->ss_state == SLIDE_SHOW_RUNNING)
+ {
+// Stop slide show if running. BUG : When user click , menu bar is not visible.
+// Evas_Object *slider = (Evas_Object *)data;
+ //ivug_slider_stop_slide_show(slider); // data is Evas_Object
+
+ return;
+ }
+
+ if ( abs(si->x) < IMAGE_MOVE_MARGIN)
+ {
+ MSG_SLIDER_HIGH("Creating long pressed timer");
+ sd->long_timer = ecore_timer_add(elm_config_longpress_timeout_get(), _long_pressed, data);
+ }
+}
+
+
+void _ivug_on_mouse_up(Evas_Object *obj, MouseEvent *up, void *data)
+{
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(data);
+
+ sd->up = *up;
+
+ Slide_Item *si = sd->slide[CENTER_SLIDE];
+
+ MSG_SLIDER_HIGH("Mouse Up : si->XYWH(%d,%d,%d,%d)", si->x, si->y, si->w, si->h);
+
+ if (sd->long_timer)
+ {
+ ecore_timer_del(sd->long_timer);
+ sd->long_timer = NULL;
+ }
+
+// Find Scroll Direction
+ shift_direction_t dir = SLIDE_SHIFT_NONE;
+
+// TODO How to make simpler below routine???
+ if ( _ivug_slider_check_flick(&sd->down, up) == true) // If flick
+ {
+ int delta_x = up->x - sd->down.x;
+// int delta_y = up->y - sd->down.y;
+
+ {
+ if ( (sd->edge & SLIDE_RIGHT_EDGE) && (delta_x < 0)) // Mouse : <--
+ {
+ // <---------
+ if ( sd->slide[NEXT_SLIDE]->state != SLIDE_STATE_NONE )
+ {
+ dir = SLIDE_SHIFT_TO_RIGHT;
+ }
+ }
+ else if ( (sd->edge & SLIDE_LEFT_EDGE) && (delta_x > 0) ) // Mouse : -->
+ {
+ // ------>
+ if ( sd->slide[PREV_SLIDE]->state != SLIDE_STATE_NONE )
+ {
+ dir = SLIDE_SHIFT_TO_LEFT;
+ }
+ }
+ }
+ }
+ else
+ {
+ MSG_SLIDER_HIGH("Si->x=%d", si->x);
+// if ( si->x == 0 ) // If not moving state
+// {
+ if ( _ivug_slider_check_click(&sd->down, up) == true )
+ {
+ sd->click_timer = ecore_timer_add(0.2f, _clicked, data);
+ // Clicked event
+// evas_object_smart_callback_call(data, SIG_CLICKED, &sd->down.x);
+ }
+
+// }
+
+ // Not flick. check up position.
+ if ( si->x > sd->w * (SHIFT_THRESHOLD) )
+ {
+ // Scroll to --->
+ if ( sd->slide[PREV_SLIDE]->state != SLIDE_STATE_NONE ) // Check left end
+ {
+ dir = SLIDE_SHIFT_TO_LEFT;
+ }
+ }
+ else if (si->x + si->w < sd->w * (1.0f - SHIFT_THRESHOLD) )
+ {
+ // Scroll to <---
+ if ( sd->slide[NEXT_SLIDE]->state != SLIDE_STATE_NONE ) // Check left end
+ {
+ dir = SLIDE_SHIFT_TO_RIGHT;
+ }
+ }
+ }
+
+ switch(dir)
+ {
+ case SLIDE_SHIFT_TO_LEFT:
+ MSG_SLIDER_HIGH("Scroll --->");
+
+ _ivug_slider_slide_update(sd, sd->slide[CENTER_SLIDE]->x,
+ sd->slide[CENTER_SLIDE]->w + IMAGE_BETWEEN_MARGIN);
+ if(sd->ss_state == SLIDE_SHOW_RUNNING)
+ {
+ sd->bSS_SlideFlag = EINA_TRUE;
+ ivug_slider_stop_slide_show(sd->obj);
+ }
+ break;
+
+ case SLIDE_SHIFT_TO_RIGHT:
+ MSG_SLIDER_HIGH("Scroll <---");
+
+ _ivug_slider_slide_update(sd, sd->slide[CENTER_SLIDE]->x,
+ -sd->slide[CENTER_SLIDE]->w - IMAGE_BETWEEN_MARGIN);
+ if(sd->ss_state == SLIDE_SHOW_RUNNING)
+ {
+ sd->bSS_SlideFlag = EINA_TRUE;
+ ivug_slider_stop_slide_show(sd->obj);
+ }
+ break;
+
+ case SLIDE_SHIFT_NONE:
+
+ MSG_SLIDER_HIGH("Scroll to center");
+
+ if ( sd->slide[CENTER_SLIDE]->x == 0 )
+ {
+ MSG_SLIDER_WARN("No need to animation");
+ return;
+ }
+
+ _ivug_slider_slide_update(sd,sd->slide[CENTER_SLIDE]->x , 0);
+
+ break;
+
+ }
+
+
+
+}
+
+
+void _ivug_on_mouse_move(Evas_Object *obj, MouseEvent *prev, MouseEvent *cur, void *data)
+{
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(data);
+ Slide_Item* si = sd->slide[CENTER_SLIDE];
+
+ if (sd->long_timer)
+ {
+ Evas_Coord dx, dy;
+ dx = sd->down.x - cur->x;
+ dx *= dx;
+ dy =sd->down.y - cur->y;
+ dy *= dy;
+
+ if ((dx + dy) > LONG_PRESS_MARGIN * LONG_PRESS_MARGIN)
+ {
+ MSG_SLIDER_HIGH("%s delete long timer. Move:%d Margin:%d", __func__, (dx + dy), LONG_PRESS_MARGIN * LONG_PRESS_MARGIN );
+ ecore_timer_del(sd->long_timer); //delete long press.
+ sd->long_timer = NULL;
+ }
+ }
+// MSG_SLIDER_HIGH("%s. XY(%d,%d)", __func__, cur->x, cur->y);
+// TODO : check slide move threshhold
+ if ( sd->edge == SLIDE_NO_EDGE )
+ {
+ MSG_SLIDER_MED("Photocam handle this event");
+ return;
+ }
+
+ int dst_x, dst_y;
+
+ dst_x = si->x + (cur->x - prev->x);
+ dst_y = si->y + (cur->y - prev->y);
+
+ MSG_SLIDER_MED("%s. Edge=%d Cur XY(%d,%d) Prev XY(%d,%d) SI->XY(%d,%d) Dest(%d,%d)", __func__,sd->edge,
+ cur->x, cur->y, prev->x, prev->y, si->x, si->y, dst_x, dst_y);
+
+// If left-most or right-most image, do not scroll.
+ if ( ivug_slider_item_data_get(sd->slide[NEXT_SLIDE]) == NULL ) // Is left-most image?
+ {
+ MSG_SLIDER_MED("Next item is NULL. dst_x=%d", dst_x);
+
+ if ( dst_x < 0 )
+ {
+ MSG_SLIDER_MED("No allowed scroll to right");
+ _ivug_slider_pass_event_to_item(sd, EINA_FALSE);
+ return;
+ }
+ }
+
+ if ( ivug_slider_item_data_get(sd->slide[PREV_SLIDE]) == NULL ) // Is right-most image?
+ {
+ MSG_SLIDER_MED("Prev item is NULL. dst_x=%d", dst_x);
+ if ( dst_x > 0 )
+ {
+ MSG_SLIDER_MED("No allowed scroll to left");
+ _ivug_slider_pass_event_to_item(sd, EINA_FALSE);
+ return;
+ }
+ }
+ if ( (sd->edge & SLIDE_LEFT_EDGE) && (dst_x > IMAGE_SCROLL_MARGIN))
+ {
+ MSG_SLIDER_MED("Case 1. edge=%d, X=%d", sd->edge, dst_x);
+
+ _ivug_slider_pass_event_to_item(sd, EINA_FALSE);
+
+ _ivug_slider_slide_update_pos(sd, dst_x , si->y); //update
+ _ivug_slider_slide_update_shift(sd);
+
+ return;
+ }
+
+ if ( (sd->edge & SLIDE_RIGHT_EDGE) && (dst_x < -IMAGE_SCROLL_MARGIN))
+ {
+ MSG_SLIDER_MED("Case 2. edge=%d, X=%d", sd->edge, dst_x);
+ _ivug_slider_pass_event_to_item(sd, EINA_FALSE);
+
+ _ivug_slider_slide_update_pos(sd, dst_x , si->y); //update
+ _ivug_slider_slide_update_shift(sd);
+
+ return;
+ }
+
+ if ( (sd->edge & SLIDE_FIT) != SLIDE_FIT)
+ {
+ MSG_SLIDER_MED("Case 3. edge=%d", sd->edge);
+ _ivug_slider_pass_event_to_item(sd, EINA_TRUE); // Send event to phtocam
+ sd->edge = SLIDE_NO_EDGE;
+ }
+
+ if (dst_x >= -IMAGE_SCROLL_MARGIN && dst_x <= IMAGE_SCROLL_MARGIN)
+ {
+ MSG_SLIDER_MED("Case 4. It isn't over IMAGE_SCROLL_MARGIN");
+ return ;
+ }
+
+ MSG_SLIDER_ERROR("Debug Me NEw edge=%d delta_x=%d si->x=%d", sd->edge, dst_x, si->x);
+ return;
+
+}
+
diff --git a/main/src/view/ivug-slider-priv.h b/main/src/view/ivug-slider-priv.h
new file mode 100755
index 0000000..2bc2f3d
--- /dev/null
+++ b/main/src/view/ivug-slider-priv.h
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-data.h"
+
+#ifndef __IVUG_SLIDER_PRIV_H__
+#define __IVUG_SLIDER_PRIV_H__
+
+/* elm_config_finger_size_get = 40 */
+#define IMAGE_BETWEEN_MARGIN (30) // The value is width between photocam(unit is pixel).
+#define IMAGE_MOVE_MARGIN ((int)IMAGE_BETWEEN_MARGIN*0.8)
+/* If moved width is larger than IMAGE_SCROLL_MARGIN, image is scrolled */
+#define IMAGE_SCROLL_MARGIN (5) /* vertical move doen't over 5 pixel width */
+#define LONG_PRESS_MARGIN ((int)(elm_config_finger_size_get() / 3))
+
+typedef enum {
+ SLIDE_NO_EDGE = (1<<0),
+
+ SLIDE_LEFT_EDGE = (1<<1),
+ SLIDE_RIGHT_EDGE = (1<<2),
+
+ SLIDE_TOP_EDGE = (1<<3),
+ SLIDE_BOTTOM_EDGE = (1<<4),
+
+ SLIDE_FIT = SLIDE_LEFT_EDGE | SLIDE_RIGHT_EDGE | SLIDE_TOP_EDGE | SLIDE_BOTTOM_EDGE,
+} slide_edge_t;
+
+typedef enum {
+ SLIDE_SHIFT_NONE = 0x00,
+ SLIDE_SHIFT_TO_RIGHT, // <---------------------Mouse
+ SLIDE_SHIFT_TO_LEFT, // Mouse--------------------->
+} shift_direction_t;
+
+
+//ENUM
+typedef enum {
+ CENTER_SLIDE,
+ NEXT_SLIDE,
+ PREV_SLIDE,
+ MAX_SLIDE,
+} slide_index_t;
+
+// slider
+typedef struct Smart_Data
+{
+ Evas_Object *obj; // smart object itself.
+
+ Evas_Object *event_obj; // Event receiver layer
+
+ Evas_Coord x, y, w, h; // Geometry of slider
+
+//silde
+ Slide_Item* slide[MAX_SLIDE];
+// Media_Item* mitem[MAX_SLIDE];
+
+//data list
+ Eina_Bool bShow;
+
+ Media_List* media_list; // Storing entire media list.
+ Media_Item* current; // Current medit item. Is it needed??
+
+ int cur_list_idx;
+ int next_list_idx; /* for slide show */
+ int list_total_count;
+
+//Mouse Event
+ MouseEvent down;
+ MouseEvent up;
+
+// for flick anim
+ anim_handle_t *anim;
+ Ecore_Animator *animator;
+ double t_base;
+
+//slider show.
+ slideshow_state_t ss_state;
+
+ Ecore_Timer *ss_timer; //slide show timer
+ ivug_slider_slide_show_finish_cb ss_func; // Callback for slide show finished
+ void* ss_user_data;
+ Eina_Bool bSS_StopFlag; /* request slide show stop flag */
+ Eina_Bool bSS_SlideFlag; /* it was slided by user during slide show */
+
+//Mouse event handler
+ Ivug_Event_Handle mouse_event;
+
+ slide_edge_t edge;
+
+// For detecting long pressed
+ Ecore_Timer *long_timer;
+
+// For detecting click
+ Ecore_Timer *click_timer;
+
+/* For window loading */
+ Ecore_Idler* idler_list;
+
+/* slide show setting */
+ double ss_interval_time;
+ slide_show_mode ss_mode;
+
+/* slide show effect*/
+ Effect_Type effect_type;
+ Effect_Engine* effect_engine;
+
+ Ecore_Idler *load_idler;
+} _Smart_Data;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// Common function between slide show and slider.
+
+#define _ivug_slider_edge_state_get(si) __ivug_slider_edge_state_get(si, __func__, __LINE__)
+
+slide_edge_t __ivug_slider_edge_state_get(Slide_Item *si, const char *func, int line);
+
+void _ivug_slider_slide_update_shift_right(struct Smart_Data *sd);
+
+void _ivug_slider_slide_update_pos(struct Smart_Data *sd, Evas_Coord x, Evas_Coord y);
+
+void _ivug_slider_restore_window_list(struct Smart_Data *sd);
+
+
+// Common function between slide and slide mouse.
+
+void _ivug_slider_slide_update(struct Smart_Data *sd, int x, int y);
+
+void _ivug_slider_pass_event_to_item(struct Smart_Data *sd, Eina_Bool bPass);
+
+void _ivug_slider_slide_update_shift(struct Smart_Data *sd);
+
+
+void _ivug_on_mouse_down(Evas_Object *obj, MouseEvent *down, void *data);
+
+void _ivug_on_mouse_up(Evas_Object *obj, MouseEvent *up, void *data);
+
+void _ivug_on_mouse_move(Evas_Object *obj, MouseEvent *prev, MouseEvent *cur, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif // __IVUG_SLIDER_PRIV_H__
+
diff --git a/main/src/view/ivug-slider-slideshow.c b/main/src/view/ivug-slider-slideshow.c
new file mode 100755
index 0000000..3e2e7bb
--- /dev/null
+++ b/main/src/view/ivug-slider-slideshow.c
@@ -0,0 +1,334 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ivug-common.h"
+#include "ivug-main.h"
+
+#include "ivug-slider.h"
+#include "ivug-mouse-event.h"
+#include "ivug-slider-item.h"
+#include "ivug-anim.h"
+#include "ivug-effect.h"
+#include "ivug-slider-priv.h"
+#include "ivug-data.h"
+#include "ivug-data-shuffle.h"
+
+
+static const char *_get_ss_state(slideshow_state_t state)
+{
+ const char *szMsg[] = {"Stopped", "Running", "Paused" };
+
+ return szMsg[state];
+}
+
+
+void _ivug_slider_effect_finished(void *data)
+{
+ struct Smart_Data* sd = (struct Smart_Data*) data;
+ ivug_ret_if(!sd);
+
+ MSG_SLIDER_HIGH("Slide Effect ended");
+
+ if(sd->effect_engine)
+ {
+ ivug_effect_finalize(sd->effect_engine);
+ sd->effect_engine = NULL;
+ }
+
+ if (sd->slide[NEXT_SLIDE]->mitem && sd->bSS_SlideFlag == EINA_FALSE)
+ {
+ _ivug_slider_slide_update_shift_right(sd);
+ }
+
+ // Update edge state
+ sd->edge = _ivug_slider_edge_state_get(sd->slide[CENTER_SLIDE]);
+
+ if(sd->bSS_StopFlag == EINA_TRUE)
+ {
+ sd->ss_state = SLIDE_SHOW_STOPPED;
+ MSG_SLIDER_HIGH("effect_engine is finished");
+ evas_object_smart_callback_call(sd->obj, "slider,slideshow,interrupted", (void *)sd->slide[CENTER_SLIDE]);
+ ivug_slider_restore_window_list(sd->obj);
+ sd->bSS_StopFlag = EINA_FALSE;
+ }
+}
+
+
+// Slide Show related functions.
+static Eina_Bool
+_ivug_slider_slide_show_cb(void *data)
+{
+ IV_ASSERT(data != NULL);
+
+ struct Smart_Data* sd = (struct Smart_Data*) data;
+
+ if(sd->ss_state == SLIDE_SHOW_STOPPED) /* stopped by other operation */
+ {
+ sd->ss_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ Media_Item *item = NULL;
+
+ if(sd->ss_mode & SLIDE_SHOW_MODE_SHUFFLE)
+ {
+ item = ivug_data_get_next_shuffle_item(sd->media_list);
+ }
+ else // shuffle slideshow is off
+ {
+ item = ivug_data_get_next(sd->slide[CENTER_SLIDE]->mitem);
+ }
+
+ //calc slide show
+ if ( item != NULL || (sd->ss_mode & SLIDE_SHOW_MODE_REPEAT)) /* repeat is endless */
+ {
+ MSG_SLIDER_HIGH("ivug_effect_add Effect=%d", sd->effect_type);
+
+ Effect_Engine *eng = ivug_effect_add(sd->effect_type);
+
+ if(eng == NULL)
+ {
+ MSG_SLIDER_ERROR("Cannot create effect NULL");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ sd->effect_engine = eng;
+ ivug_effect_init(sd->effect_engine, sd->slide[CENTER_SLIDE]->layout, sd->slide[NEXT_SLIDE]->layout, sd->w, sd->h, 0);
+
+ ivug_effect_start(sd->effect_engine, _ivug_slider_effect_finished, sd);
+
+ return ECORE_CALLBACK_RENEW;
+ }
+ else
+ {
+ MSG_SLIDER_HIGH("Reached end of images. Stop slide show");
+
+ sd->ss_timer = NULL;
+ evas_object_smart_callback_call(sd->obj, "slider,slideshow,finished", (void *)sd->slide[CENTER_SLIDE]);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+}
+
+
+static Eina_Bool
+_ivug_slider_slide_finish_cb(void *data)
+{
+ IV_ASSERT(data != NULL);
+
+ struct Smart_Data* sd = (struct Smart_Data*) data;
+
+ sd->ss_timer = NULL;
+
+ evas_object_smart_callback_call(sd->obj, "slider,slideshow,finished", (void *)sd->slide[CENTER_SLIDE]);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static Effect_Type
+ivug_slider_get_trans_effect(ivug_effect_type type)
+{
+ MSG_SLIDER_MED("type %d", type);
+
+ switch(type)
+ {
+ case IVUG_EFFECT_TYPE_SLIDE:
+ return EFFECT_SLIDE;
+ break;
+
+ default:
+ break;
+ }
+
+ return EFFECT_NONE;
+}
+
+
+void
+ivug_slider_start_slide_show(Evas_Object* obj, Eina_Bool bSlideFirst)
+{
+ IV_ASSERT(obj != NULL);
+
+ struct Smart_Data *sd = (struct Smart_Data *)evas_object_smart_data_get(obj);
+ IV_ASSERT(sd != NULL);
+
+ ivug_effect_type ivug_effect = IVUG_EFFECT_TYPE_SLIDE;
+
+ ivug_config_get_slideshow_setting(&(sd->ss_mode), &(sd->ss_interval_time), &ivug_effect);
+
+ MSG_SLIDER_HIGH("Start slide show. Interval=%f Effect=%d", sd->ss_interval_time, ivug_effect);
+
+ if(sd->ss_interval_time < 0)
+ {
+ MSG_SLIDER_HIGH("slide show interval time is invalid !!!");
+ ivug_slider_stop_slide_show(obj);
+ return ;
+ }
+
+// sd->ss_interval_time = 6.0f; // Test
+
+ if ( sd->ss_state == SLIDE_SHOW_RUNNING )
+ {
+ MSG_SLIDER_WARN("Slide show is running. remove previous one.");
+ ivug_slider_stop_slide_show(obj);
+ }
+
+ if ( sd->effect_engine != NULL )
+ {
+ MSG_SLIDER_FATAL("Debug Me!!!");
+ return ;
+ }
+
+ sd->bSS_SlideFlag = EINA_FALSE;
+ sd->bSS_StopFlag = EINA_FALSE;
+
+ sd->effect_type = ivug_slider_get_trans_effect(ivug_effect);
+
+ ivug_data_set_window_size(sd->media_list, IV_WINDOW_SIZE_FOR_SLIDE_SHOW);
+
+ ///////////////////////////////////////////////////////
+ if(sd->ss_mode & SLIDE_SHOW_MODE_SHUFFLE)
+ {
+ {
+ ivug_data_init_shuffle_slide_show(sd->media_list, sd->ss_mode, sd->cur_list_idx, sd->list_total_count);
+ }
+ }
+
+ ivug_slider_item_data_unset(sd->slide[NEXT_SLIDE]);
+// TODO : parameter of ivug_data_get_current_slide_show_item() is too complex!!!!
+ Media_Item *item = ivug_data_get_current_slide_show_item(sd->media_list, sd->ss_mode, sd->cur_list_idx, &(sd->next_list_idx), sd->list_total_count);
+
+ if(item == NULL)
+ {
+ MSG_SLIDER_ERROR("Item is NULL. CurIndex=%d", sd->cur_list_idx);
+
+ ivug_data_set_window_size(sd->media_list, IV_WINDOW_SIZE);
+ if(sd->ss_timer) {
+ ecore_timer_del(sd->ss_timer);
+ sd->ss_timer = NULL;
+ }
+ sd->ss_timer = ecore_timer_add(sd->ss_interval_time, _ivug_slider_slide_finish_cb, sd);
+ return;
+ }
+
+ ivug_data_append_media_item(sd->media_list, item);
+ ivug_slider_item_data_set(sd->slide[NEXT_SLIDE], item); //set iterator
+ ivug_slider_item_data_loading(sd->slide[NEXT_SLIDE]);
+
+ /* set sd->slide[NEXT_SLIDE] 's next item*/
+ ivug_data_set_next_slide_show_item(sd->media_list, sd->ss_mode, &(sd->next_list_idx), sd->list_total_count);
+
+ sd->ss_state = SLIDE_SHOW_RUNNING;
+ if(bSlideFirst == EINA_TRUE)
+ {
+ if ( _ivug_slider_slide_show_cb(sd) == ECORE_CALLBACK_CANCEL )
+ {
+ MSG_SLIDER_WARN("Slide ended????");
+ ivug_data_set_window_size(sd->media_list, IV_WINDOW_SIZE);
+ return;
+ }
+ }
+ if(sd->ss_timer) {
+ ecore_timer_del(sd->ss_timer);
+ sd->ss_timer = NULL;
+ }
+ sd->ss_timer = ecore_timer_add(sd->ss_interval_time, _ivug_slider_slide_show_cb, sd);
+
+ MSG_SLIDER_HIGH("Slide show started!");
+
+// if it is last slide, need hide menu bar
+}
+
+void
+ivug_slider_pause_slide_show(Evas_Object* obj)
+{
+ IV_ASSERT(obj != NULL);
+
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ IV_ASSERT(sd != NULL);
+
+ MSG_SLIDER_HIGH("Pause slide show. state=%s", _get_ss_state(sd->ss_state));
+
+ if(sd->ss_timer)
+ {
+ ecore_timer_freeze(sd->ss_timer);
+ }
+
+ sd->ss_state = SLIDE_SHOW_PAUSE;
+}
+
+void
+ivug_slider_resume_slide_show(Evas_Object* obj)
+{
+ IV_ASSERT(obj != NULL);
+
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ IV_ASSERT(sd != NULL);
+
+ MSG_SLIDER_HIGH("Resume slide show. state=%s", _get_ss_state(sd->ss_state));
+
+ if(sd->ss_timer)
+ {
+ ecore_timer_thaw(sd->ss_timer);
+ }
+
+ sd->ss_state = SLIDE_SHOW_RUNNING; // TODO : Buggy
+}
+
+void
+ivug_slider_stop_slide_show(Evas_Object* obj)
+{
+ IV_ASSERT(obj != NULL);
+
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ IV_ASSERT(sd != NULL);
+
+ if ( sd->ss_state != SLIDE_SHOW_RUNNING )
+ {
+ MSG_SLIDER_WARN("Stop slide show. but not run state. state=%s", _get_ss_state(sd->ss_state) );
+ return;
+ }
+
+ MSG_SLIDER_HIGH("Stop slide show. XY(%d,%d)", sd->x, sd->y);
+ sd->bSS_StopFlag = EINA_TRUE;
+
+ //delete timmer
+ if(sd->ss_timer) {
+ ecore_timer_del(sd->ss_timer);
+ sd->ss_timer = NULL;
+ }
+
+ if(sd->ss_mode & SLIDE_SHOW_MODE_SHUFFLE)
+ {
+ ivug_data_deinit_shuffle_slide_show(sd->media_list,
+ sd->list_total_count);
+ }
+
+ ivug_data_set_window_size(sd->media_list, IV_WINDOW_SIZE);
+
+ if(sd->effect_engine == NULL)
+ {
+ sd->ss_state = SLIDE_SHOW_STOPPED;
+ MSG_SLIDER_HIGH("effect_engine is NULL");
+ evas_object_smart_callback_call(sd->obj, "slider,slideshow,interrupted", (void *)sd->slide[CENTER_SLIDE]);
+ ivug_slider_restore_window_list(sd->obj);
+ sd->bSS_StopFlag = EINA_FALSE;
+ }
+}
+
+
diff --git a/main/src/view/ivug-slider.c b/main/src/view/ivug-slider.c
new file mode 100755
index 0000000..fe5645b
--- /dev/null
+++ b/main/src/view/ivug-slider.c
@@ -0,0 +1,1245 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <ui-gadget-module.h> // ug_destroy_me, ug_send_result
+
+#include "ivug-slider.h"
+#include "ivug-common.h"
+#include "ivug-main.h"
+
+#include "ivug-parameter.h"
+#include "ivug-define.h"
+#include "ivug-effect.h"
+#include "ivug-config.h"
+
+#include "ivug-util.h"
+#include "ivug-data.h"
+#include "ivug-data-shuffle.h"
+
+#include "ivug-mouse-event.h"
+#include "ivug-slider-item.h"
+#include "ivug-anim.h"
+#include "ivug-slider-priv.h"
+
+#undef LOG_TAG
+#define LOG_TAG "IV-SLIDER"
+
+#define DEFFERED_LOADING
+
+#define ANI_TIME_FLICK (0.2f)
+
+static Eina_Bool _ivug_slider_on_animation(void *data);
+
+//smart object
+static void
+_ivug_slider_smart_init(void);
+static void
+_ivug_slider_smart_add(Evas_Object *obj);
+static void
+_ivug_slider_smart_del(Evas_Object *obj);
+static void
+_ivug_slider_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
+static void
+_ivug_slider_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
+static void
+_ivug_slider_smart_show(Evas_Object *obj);
+static void
+_ivug_slider_smart_hide(Evas_Object *obj);
+static void
+_ivug_slider_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
+static void
+_ivug_slider_smart_clip_set(Evas_Object *obj, Evas_Object * clip);
+static void
+_ivug_slider_smart_clip_unset(Evas_Object *obj);
+
+/* local subsystem globals */
+static Evas_Smart *_smart_ = NULL;
+
+// Smart Object
+static void
+_ivug_slider_smart_init(void)
+{
+ if (_smart_) return;
+ {
+ const char* name = eina_stringshare_add("ivug-slider");
+ MSG_SLIDER_MED("name=%s", name);
+ static Evas_Smart_Class sc =
+ {
+ NULL,
+ EVAS_SMART_CLASS_VERSION,
+ _ivug_slider_smart_add,
+ _ivug_slider_smart_del,
+ _ivug_slider_smart_move,
+ _ivug_slider_smart_resize,
+ _ivug_slider_smart_show,
+ _ivug_slider_smart_hide,
+ _ivug_slider_smart_color_set,
+ _ivug_slider_smart_clip_set,
+ _ivug_slider_smart_clip_unset,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ }; //Evas_smart_Class
+ sc.name = name;
+ _smart_ = evas_smart_class_new(&sc);
+ }
+}
+
+
+void
+_ivug_slider_pass_event_to_item(struct Smart_Data *sd, Eina_Bool bPass)
+{
+ int i = 0;
+
+ if ( bPass == EINA_TRUE)
+ {
+ MSG_SLIDER_HIGH("Photocam can get Event");
+// Later, will enable below code.
+// evas_object_repeat_events_set(sd->event_obj, EINA_TRUE );
+ }
+ else
+ {
+ MSG_SLIDER_MED("Photocam can not get Event");
+// evas_object_repeat_events_set(sd->event_obj, EINA_FALSE );
+ }
+
+ for (i = 0; i < MAX_SLIDE; i++)
+ {
+ ivug_slider_item_hold_set(sd->slide[i], !bPass);
+ }
+}
+
+
+#define _ivug_slider_edge_state_get(si) __ivug_slider_edge_state_get(si, __func__, __LINE__)
+
+slide_edge_t __ivug_slider_edge_state_get(Slide_Item *si, const char *func, int line)
+{
+ int nx, ny, nw, nh;
+
+ slide_edge_t result = SLIDE_NO_EDGE;
+
+ if ( ivug_slider_item_region_size_get(si, &nx, &ny, &nw, &nh) == false)
+ {
+ // false means video file item. in this case, no photocam exists.
+ MSG_SLIDER_HIGH("[%20s:%4d] Slide fit. Thumbnail only", func, line);
+ result = SLIDE_FIT;
+ }
+ else
+ {
+ if ( nw <= (si->w + IMAGE_SCROLL_MARGIN) && (nh <= si->h + IMAGE_SCROLL_MARGIN))
+ {
+ MSG_SLIDER_HIGH("[%20s:%4d] Slide fit", func, line);
+ result = SLIDE_FIT;
+ }
+ else
+ {
+ MSG_SLIDER_HIGH("No edge!!");
+ return SLIDE_NO_EDGE;
+ }
+ }
+
+ if ( result == SLIDE_NO_EDGE )
+ {
+ MSG_SLIDER_HIGH("[%20s:%4d] image over screen. %d", func, line, result);
+ }
+
+ return result;
+}
+
+static Eina_Bool _idler_loading_func(void* data)
+{
+ struct Smart_Data *sd = data;
+
+ int i;
+ sd->load_idler = NULL;
+
+ if ( sd->slide[CENTER_SLIDE]->state == SLIDE_STATE_READY ) // Center image must be loaded even while other image is loading.
+ {
+ ivug_slider_item_data_loading(sd->slide[CENTER_SLIDE]);
+ goto end;
+ }
+
+ for ( i = 0; i < MAX_SLIDE ; i++)
+ {
+ if ( sd->slide[i]->state == SLIDE_STATE_LOADING )
+ {
+ goto end;
+ }
+ }
+
+ if ( sd->slide[NEXT_SLIDE]->state == SLIDE_STATE_READY )
+ {
+ ivug_slider_item_data_loading(sd->slide[NEXT_SLIDE]);
+ goto end;
+ }
+
+ if ( sd->slide[PREV_SLIDE]->state == SLIDE_STATE_READY )
+ {
+ ivug_slider_item_data_loading(sd->slide[PREV_SLIDE]);
+ goto end;
+ }
+
+ MSG_SLIDER_WARN("Set Data loading State=%d,%d,%d",
+ sd->slide[PREV_SLIDE]->state,
+ sd->slide[CENTER_SLIDE]->state,
+ sd->slide[NEXT_SLIDE]->state
+ );
+
+
+end:
+ return ECORE_CALLBACK_CANCEL;
+
+}
+
+
+static Eina_Bool
+_ivug_slider_set_window_loading_idler(void* data)
+{
+ ivug_retv_if(!data, ECORE_CALLBACK_CANCEL);
+
+ struct Smart_Data *sd = (struct Smart_Data *)data;
+ ivug_retv_if(!sd, ECORE_CALLBACK_CANCEL);
+
+ Load_State status = IVUG_SLIDER_LOADED_NONE;
+
+ if(sd->ss_state != SLIDE_SHOW_RUNNING)
+ {
+ status = ivug_data_set_window_loading(sd->media_list, sd->cur_list_idx, sd->list_total_count);
+ switch(status)
+ {
+ case IVUG_SLIDER_LOADED_RIGHT:
+ if(sd->slide[NEXT_SLIDE]->mitem == NULL)
+ {
+ Media_Item *item = ivug_data_get_next(sd->slide[CENTER_SLIDE]->mitem);
+ if(item != NULL) /* loaded but not set yet */
+ {
+ MSG_SLIDER_HIGH("SET NEXT!!!!!!!!!!");
+ ivug_slider_item_data_set(sd->slide[NEXT_SLIDE], item); //set data.
+#ifdef DEFFERED_LOADING
+ if ( sd->load_idler == NULL )
+ {
+ sd->load_idler = ecore_idler_add(_idler_loading_func, sd);
+ }
+#else
+ ivug_slider_item_data_loading(sd->slide[NEXT_SLIDE]); //set data.
+#endif
+
+ }
+ }
+ break;
+ case IVUG_SLIDER_LOADED_LEFT:
+ if(sd->slide[PREV_SLIDE]->mitem == NULL)
+ {
+ Media_Item *item = ivug_data_get_prev(sd->slide[CENTER_SLIDE]->mitem);
+ if(item != NULL) /* loaded but not set yet */
+ {
+ MSG_SLIDER_HIGH("SET PREV!!!!!!!!!!");
+ ivug_slider_item_data_set(sd->slide[PREV_SLIDE], item); //set data.
+#ifdef DEFFERED_LOADING
+ if ( sd->load_idler == NULL )
+ {
+ sd->load_idler = ecore_idler_add(_idler_loading_func, sd);
+ }
+#else
+ ivug_slider_item_data_loading(sd->slide[PREV_SLIDE]); //set data.
+#endif
+
+ }
+ }
+ break;
+ default :
+ MSG_SLIDER_WARN("Unhandled state : %d", status);
+ break;
+ }
+ }
+ else
+ {
+ MSG_SLIDER_HIGH("SLIDE_SHOW_RUNNING!!!!!!!!!!");
+ ivug_data_set_next_slide_show_item(sd->media_list, sd->ss_mode, &(sd->next_list_idx), sd->list_total_count);
+ }
+
+ if (sd->idler_list)
+ {
+ ecore_idler_del(sd->idler_list);
+ sd->idler_list = NULL;
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void _ivug_slider_item_changed(slide_state_t state, Slide_Item *si, void *client_data)
+{
+ struct Smart_Data *sd = client_data;
+ IV_ASSERT(sd != NULL);
+
+ if ( state == SLIDE_STATE_LOADED )
+ {
+ if ( sd->slide[CENTER_SLIDE] == si )
+ {
+ MSG_SLIDER_HIGH("Call Item state changed callback State=%d Si->State=%d", state, si->state);
+ evas_object_smart_callback_call(sd->obj, "slider,item,state,changed", si);
+ }
+ }
+ else if (state == SLIDE_STATE_ERROR)
+ {
+ if ( sd->slide[CENTER_SLIDE] == si )
+ {
+ MSG_SLIDER_ERROR("Decoding failed");
+ evas_object_smart_callback_call(sd->obj, "slider,item,state,changed", si);
+ }
+ }
+ else
+ {
+ MSG_SLIDER_ERROR("Unknown state : %d", state);
+ if ( sd->slide[CENTER_SLIDE] == si )
+ {
+ MSG_SLIDER_ERROR("Unknown state");
+ evas_object_smart_callback_call(sd->obj, "slider,item,state,changed", si);
+ }
+ }
+
+ if ( sd->load_idler == NULL )
+ {
+ MSG_SLIDER_HIGH("Add idler for loading.");
+ sd->load_idler = ecore_idler_add(_idler_loading_func, sd);
+ }
+
+}
+
+void ivug_slider_restore_window_list(Evas_Object *obj)
+{
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+
+ MSG_SDATA_HIGH("******* restore slide show index %d", sd->cur_list_idx);
+
+ Media_Item *item = NULL;
+ Eina_List *new_list = NULL;
+ int start_index = sd->cur_list_idx;
+ int list_total_count = sd->list_total_count;
+
+ Media_Data *mdata = ivug_data_get_data(sd->slide[CENTER_SLIDE]->mitem);
+ if(mdata == NULL)
+ {
+ MSG_SLIDER_ERROR("mdata is NULL");
+ return;
+ }
+
+ char *path = mdata->filepath;
+ if(path == NULL)
+ {
+ path = mdata->fileurl;
+ }
+ ivug_data_reset_window_load_count(sd->media_list); /* TODO : it is temp */
+ item = ivug_data_create_media_list_from_param
+ (sd->media_list, &new_list, path, &start_index, &list_total_count); //get list by file path.
+ if(item == NULL)
+ {
+ MSG_SLIDER_ERROR("create media list failed");
+ ug_destroy_me(gGetUGHandle());
+ return;
+ }
+
+ if (!ivug_slider_set_slide_list(sd->obj, sd->media_list, new_list, item, start_index, list_total_count))
+ {
+ MSG_SLIDER_ERROR("slide list set Error");
+ ug_destroy_me(gGetUGHandle());
+ return ;
+ }
+}
+
+
+static void
+_ivug_slider_smart_add(Evas_Object *obj)
+{
+ MSG_SLIDER_HIGH("Slider Add : 0x%08x", obj);
+
+ PERF_CHECK_BEGIN(LVL4 "add slider item");
+
+ struct Smart_Data *sd = calloc(1, sizeof(struct Smart_Data));
+ ivug_ret_if(!sd);
+
+ sd->obj = obj;
+ evas_object_smart_data_set(obj, sd);
+ int idx = 0;
+
+//create slider item.
+ for (idx = 0; idx < MAX_SLIDE; idx++)
+ {
+ sd->slide[idx] = ivug_slider_item_add(obj);
+ ivug_slider_item_set_callback(sd->slide[idx], _ivug_slider_item_changed, sd);
+ }
+
+ PERF_CHECK_END(LVL4 "add slider item");
+
+ PERF_CHECK_BEGIN(LVL4 "remants");
+
+ sd->event_obj = evas_object_rectangle_add(evas_object_evas_get(obj));
+ evas_object_color_set(sd->event_obj , 0, 0, 0, 0); // Fully Transparent object.
+ evas_object_size_hint_align_set(sd->event_obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(sd->event_obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ evas_object_show(sd->event_obj);
+
+ evas_object_smart_member_add(sd->event_obj, obj);
+ evas_object_repeat_events_set(sd->event_obj, EINA_TRUE); // mouse event should pass to phocam
+
+ mouse_callback_t cb = {0,};
+
+ cb.onMouseDown = _ivug_on_mouse_down;
+ cb.onMouseUp = _ivug_on_mouse_up;
+
+ cb.onMouseMove = _ivug_on_mouse_move;
+
+ sd->mouse_event = ivug_mouse_event_add(sd->event_obj, &cb, obj, "SLIDER");
+ sd->edge = SLIDE_FIT;
+
+ sd->idler_list = NULL;
+
+ sd->anim = create_animation();
+ set_animation_type(sd->anim,ANIM_TYPE_QUARTIC_INOUT);
+
+ PERF_CHECK_END(LVL4 "remants");
+ return;
+
+}
+
+static void
+_ivug_slider_smart_del(Evas_Object *obj)
+{
+ MSG_SLIDER_HIGH("Slider delete");
+
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ ivug_ret_if(!sd);
+
+ if(sd->click_timer)
+ {
+ ecore_timer_del(sd->click_timer);
+ sd->click_timer = NULL;
+ }
+
+ if ( sd->load_idler )
+ {
+ ecore_idler_del(sd->load_idler);
+ sd->load_idler = NULL;
+ }
+
+ if(sd->animator)
+ {
+ ecore_animator_del(sd->animator);
+ sd->animator = NULL;
+ }
+
+ if ( sd->anim )
+ {
+ delete_animation(sd->anim);
+ sd->anim = NULL;
+ }
+ if (sd->long_timer)
+ {
+ ecore_timer_del(sd->long_timer);
+ sd->long_timer = NULL;
+ }
+
+ if(sd->ss_timer)
+ {
+ ecore_timer_del(sd->ss_timer);
+ sd->ss_timer = NULL;
+ }
+
+ if (sd->idler_list)
+ {
+ ecore_idler_del(sd->idler_list);
+ sd->idler_list = NULL;
+ }
+
+ if ( sd->event_obj )
+ {
+ ivug_mouse_event_del(sd->mouse_event);
+
+ evas_object_del(sd->event_obj);
+ sd->event_obj = NULL;
+ }
+
+ int i=0;
+ for (i = 0; i < MAX_SLIDE ; i++) //delete layout
+ {
+ ivug_slider_item_del(sd->slide[i]);
+ sd->slide[i] = NULL;
+ }
+
+ if (sd->media_list)
+ {
+ ivug_data_delete_media_list(sd->media_list);
+ }
+
+ free(sd);
+
+ IVUG_FUNC_LEAVE();
+}
+
+
+static void
+_ivug_slider_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+{
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ ivug_ret_if(!sd);
+
+ if ((sd->x == x) && (sd->y == y)) return;
+
+ MSG_SLIDER_MED("Slider Move : XY(%d,%d)", x, y);
+
+ sd->x = x;
+ sd->y = y;
+ _ivug_slider_slide_update_pos(sd, x, y);
+
+ evas_object_move(sd->event_obj, sd->x, sd->y);
+}
+
+static void
+_ivug_slider_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
+{
+ MSG_SLIDER_HIGH("Slider Resize : WH(%d,%d)", w,h);
+
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ ivug_ret_if(!sd);
+
+ if ((sd->w == w) && (sd->h == h)) return;
+
+ sd->w = w;
+ sd->h = h;
+
+ if ( sd->animator != NULL )
+ {
+ // Remove animation during rotation
+ ecore_animator_del(sd->animator);
+ sd->animator = NULL;
+ }
+
+ //resize layout
+ int i = 0;
+ for (i = 0; i < MAX_SLIDE; i++)
+ { //set resize
+ ivug_slider_item_resize(sd->slide[i], w, h);
+ }
+
+// Redraw items.
+ ivug_slider_item_move(sd->slide[CENTER_SLIDE], 0, 0);
+
+// TODO : so as to increas perf, dont draw slide under certain condition
+ ivug_slider_item_move(sd->slide[PREV_SLIDE], - sd->slide[PREV_SLIDE]->w - IMAGE_BETWEEN_MARGIN ,0);
+
+ int right_x;
+
+ if ( sd->w < sd->slide[CENTER_SLIDE]->w )
+ {
+ right_x = sd->w + IMAGE_BETWEEN_MARGIN;
+ }
+ else
+ {
+ right_x = sd->slide[CENTER_SLIDE]->w + IMAGE_BETWEEN_MARGIN;
+ }
+
+ ivug_slider_item_move(sd->slide[NEXT_SLIDE], right_x, 0);
+
+// evas_object_move(sd->event_obj, sd->x, sd->y);
+ evas_object_resize(sd->event_obj, sd->w, sd->h);
+}
+
+static void
+_ivug_slider_smart_show(Evas_Object *obj)
+{
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ ivug_ret_if(!sd);
+
+ if ( sd->bShow == EINA_TRUE) return;
+
+ sd->bShow = EINA_TRUE;
+
+ MSG_SLIDER_HIGH("Slider Show");
+
+ ivug_slider_item_show(sd->slide[CENTER_SLIDE]);
+ ivug_slider_item_show(sd->slide[NEXT_SLIDE]);
+ ivug_slider_item_show(sd->slide[PREV_SLIDE]);
+
+ evas_object_show(sd->event_obj);
+}
+
+static void
+_ivug_slider_smart_hide(Evas_Object *obj)
+{
+ ivug_ret_if(!obj);
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+
+ if ( sd->bShow == EINA_FALSE) return;
+
+ sd->bShow = EINA_FALSE;
+
+ MSG_SLIDER_HIGH("Slider Hide");
+
+ ivug_slider_item_hide(sd->slide[CENTER_SLIDE]);
+ ivug_slider_item_hide(sd->slide[NEXT_SLIDE]);
+ ivug_slider_item_hide(sd->slide[PREV_SLIDE]);
+
+ evas_object_hide(sd->event_obj);
+}
+
+static void
+_ivug_slider_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
+{
+ MSG_SLIDER_HIGH("Slider Color set : RGBA(%d,%d,%d,%d)", r, g, b, a);
+ ivug_ret_if(!obj);
+// struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+}
+
+static void
+_ivug_slider_smart_clip_set(Evas_Object *obj, Evas_Object * clip)
+{
+ MSG_SLIDER_HIGH("Slider Clip set : Clipper=0x%08x");
+ ivug_ret_if(!obj);
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+
+ int i = 0;
+ for (i = 0; i < MAX_SLIDE; i++)
+ { //set resize
+ ivug_slider_item_clip_set(sd->slide[i], clip);
+ }
+
+ evas_object_clip_set(sd->event_obj, clip);
+}
+
+static void
+_ivug_slider_smart_clip_unset(Evas_Object *obj)
+{
+ MSG_SLIDER_HIGH("Slider Clip unset");
+
+ ivug_ret_if(!obj);
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+
+ int i = 0;
+ for (i = 0; i < MAX_SLIDE; i++)
+ { //set resize
+ ivug_slider_item_clip_unset(sd->slide[i]);
+ }
+
+ evas_object_clip_unset(sd->event_obj);
+}
+
+/******* slide UI function *******/
+
+void
+_ivug_slider_slide_update_pos(struct Smart_Data *sd, Evas_Coord x, Evas_Coord y)
+{
+ IV_ASSERT(sd != NULL);
+
+// TODO : If size is smaller than screen's, image should be put in middle
+ ivug_slider_item_move(sd->slide[CENTER_SLIDE], x, y);
+
+// TODO : so as to increas perf, dont draw slide under certain condition
+ ivug_slider_item_move(sd->slide[PREV_SLIDE], x - sd->slide[PREV_SLIDE]->w - IMAGE_BETWEEN_MARGIN , y);
+
+ ivug_slider_item_move(sd->slide[NEXT_SLIDE], x + sd->slide[CENTER_SLIDE]->w + IMAGE_BETWEEN_MARGIN , y);
+}
+
+
+ void
+_ivug_slider_slide_update(struct Smart_Data *sd, int x, int y)
+ {
+ IV_ASSERT(sd != NULL);
+
+ sd->t_base = ecore_loop_time_get();
+ set_animation(sd->anim, x, y, ANI_TIME_FLICK);
+
+ if (sd->animator == NULL)
+ {
+// In elm_config_scroll_zoom_friction_get() returns 0.5. this means 500ms.
+ if(sd->animator)
+ {
+ ecore_animator_del(sd->animator);
+ sd->animator = NULL;
+ }
+
+ sd->animator = ecore_animator_add(_ivug_slider_on_animation, sd);
+
+ return;
+ }
+
+ MSG_SLIDER_WARN("Updata animation is alreay exists.");
+}
+
+
+void
+_ivug_slider_slide_update_shift_right(struct Smart_Data *sd)
+{
+ ivug_ret_if(!sd);
+
+ Slide_Item* PrevSlide = NULL;
+
+ MSG_SLIDER_HIGH( "Slide shited. <-----");
+
+ Media_Item *item = ivug_data_get_next(sd->slide[NEXT_SLIDE]->mitem); //get interator
+
+ PrevSlide = sd->slide[PREV_SLIDE];
+ ivug_slider_item_data_unset(PrevSlide);
+
+ //set init
+ sd->slide[PREV_SLIDE] = sd->slide[CENTER_SLIDE];
+ sd->slide[CENTER_SLIDE] = sd->slide[NEXT_SLIDE];
+ sd->slide[NEXT_SLIDE] = PrevSlide;
+
+ if ( item != NULL )
+ {
+ ivug_slider_item_data_set(sd->slide[NEXT_SLIDE], item); //set iterator
+#ifdef DEFFERED_LOADING
+ if ( sd->load_idler == NULL )
+ {
+ sd->load_idler = ecore_idler_add(_idler_loading_func, sd);
+ }
+#else
+ ivug_slider_item_data_loading(sd->slide[NEXT_SLIDE]); //set data.
+#endif
+ }
+
+ if(sd->ss_state == SLIDE_SHOW_RUNNING )
+ {
+ MSG_SLIDER_HIGH("Slide show.. Update position. XY(%d,%d)", sd->x , sd->y);
+ _ivug_slider_slide_update_pos(sd, sd->x , sd->y); //update
+
+ ivug_slider_item_show(sd->slide[CENTER_SLIDE]);
+ ivug_slider_item_show(sd->slide[NEXT_SLIDE]);
+ ivug_slider_item_show(sd->slide[PREV_SLIDE]);
+ }
+ else
+ {
+ _ivug_slider_slide_update_pos(sd, sd->slide[CENTER_SLIDE]->x , sd->slide[CENTER_SLIDE]->y); //update
+ }
+
+ if(sd->ss_state != SLIDE_SHOW_RUNNING)
+ {
+ sd->cur_list_idx++;
+ }
+ else /* (sd->ss_state == SLIDE_SHOW_RUNNING) */
+ {
+ int ret = 0;
+ sd->cur_list_idx = sd->next_list_idx;
+ ret = ivug_data_get_next_slide_show_index(sd->media_list, sd->ss_mode, sd->next_list_idx, sd->list_total_count, true);
+ if(ret > 0)
+ {
+ sd->next_list_idx = ret;
+ }
+ }
+ //call callback function.
+
+ MSG_SLIDER_HIGH( ">>>cur index %d, total count %d, list_count %d <<<",
+ sd->cur_list_idx, sd->list_total_count, eina_list_count(ivug_data_get_first(sd->media_list)));
+
+
+ ivug_slider_item_zoom_reset(sd->slide[PREV_SLIDE], EINA_FALSE, 0,0);
+
+ evas_object_smart_callback_call(sd->obj, "slider,item,changed", sd->slide[CENTER_SLIDE]);
+
+ if(sd->idler_list == NULL)
+ {
+ sd->idler_list = ecore_idler_add(_ivug_slider_set_window_loading_idler, (void *)sd);
+ }
+}
+
+
+void
+_ivug_slider_slide_update_shift_left(struct Smart_Data *sd)
+{
+ ivug_ret_if(!sd);
+
+ Slide_Item* NextSlide = NULL;
+
+ MSG_SLIDER_HIGH( "Slide shited. ----->");
+
+ Media_Item *item = ivug_data_get_prev(sd->slide[PREV_SLIDE]->mitem); //get interator
+
+ NextSlide = sd->slide[NEXT_SLIDE];
+ ivug_slider_item_data_unset(NextSlide);
+
+ sd->slide[NEXT_SLIDE] = sd->slide[CENTER_SLIDE];
+ sd->slide[CENTER_SLIDE] = sd->slide[PREV_SLIDE];
+ sd->slide[PREV_SLIDE] = NextSlide;
+
+ if ( item != NULL )
+ {
+ ivug_slider_item_data_set(sd->slide[PREV_SLIDE], item); //set data.
+#ifdef DEFFERED_LOADING
+ if ( sd->load_idler == NULL )
+ {
+ sd->load_idler = ecore_idler_add(_idler_loading_func, sd);
+ }
+#else
+ ivug_slider_item_data_loading(sd->slide[PREV_SLIDE]); //set data.
+#endif
+ }
+
+ _ivug_slider_slide_update_pos(sd, sd->slide[CENTER_SLIDE]->x , sd->slide[CENTER_SLIDE]->y); //update
+
+ sd->cur_list_idx--;
+ //call callback function.
+
+ ivug_slider_item_zoom_reset(sd->slide[NEXT_SLIDE], EINA_FALSE, 0,0);
+
+ evas_object_smart_callback_call(sd->obj, "slider,item,changed", sd->slide[CENTER_SLIDE]);
+
+ if(sd->idler_list == NULL)
+ {
+ sd->idler_list = ecore_idler_add(_ivug_slider_set_window_loading_idler, (void *)sd);
+ }
+
+
+}
+
+ void
+_ivug_slider_slide_update_shift(struct Smart_Data *sd)
+{
+ ivug_ret_if(!sd);
+
+ shift_direction_t shift_direction = SLIDE_SHIFT_NONE;
+
+ if ( sd->slide[CENTER_SLIDE]->x + sd->slide[CENTER_SLIDE]->w < 0 )
+ {
+ shift_direction = SLIDE_SHIFT_TO_RIGHT;
+ if ( sd->slide[NEXT_SLIDE]->mitem == NULL ) // most right position.
+ {
+ MSG_SLIDER_HIGH("Most right position");
+
+ _ivug_slider_slide_update(sd, sd->slide[CENTER_SLIDE]->x , 0);
+
+ return;
+ }
+ }
+ else if ( sd->slide[CENTER_SLIDE]->x > sd->w )
+ {
+ shift_direction = SLIDE_SHIFT_TO_LEFT;
+
+ if ( sd->slide[PREV_SLIDE]->mitem == NULL ) // most right position.
+ {
+ MSG_SLIDER_HIGH("Most left position");
+
+ _ivug_slider_slide_update(sd, sd->slide[CENTER_SLIDE]->x , 0);
+
+ return;
+ }
+ }
+
+ if ( shift_direction == SLIDE_SHIFT_TO_RIGHT) // <--------------
+ {
+ _ivug_slider_slide_update_shift_right(sd);
+ }
+ else if (shift_direction == SLIDE_SHIFT_TO_LEFT) // -------------->
+ {
+ _ivug_slider_slide_update_shift_left(sd);
+ }
+
+}
+
+static Eina_Bool
+_ivug_slider_on_animation(void *data)
+{
+ ivug_retv_if(!data, ECORE_CALLBACK_CANCEL);
+ struct Smart_Data* sd = (struct Smart_Data*) data;
+
+ int value = 0;
+
+ if ( update_animation(sd->anim, ecore_loop_time_get() - sd->t_base, &value) == false ) // If last frame
+ {
+ if(sd->animator)
+ {
+ ecore_animator_del(sd->animator);
+ sd->animator = NULL;
+ }
+
+ MSG_SLIDER_HIGH("Last ani frame : X pos(%d,%d,%d)",
+ sd->slide[PREV_SLIDE]->x, sd->slide[CENTER_SLIDE]->x, sd->slide[NEXT_SLIDE]->x);
+
+ _ivug_slider_slide_update_pos(sd, value , sd->y); //update
+
+ _ivug_slider_slide_update_shift(sd);
+
+// Update edge state
+ sd->edge = _ivug_slider_edge_state_get(sd->slide[CENTER_SLIDE]);
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ _ivug_slider_slide_update_pos(sd, value, sd->y);
+
+ return ECORE_CALLBACK_RENEW;
+
+
+ }
+
+
+Evas_Object*
+ivug_slider_add(Evas_Object* parent)
+{
+ Evas_Object *obj = NULL;
+ _ivug_slider_smart_init(); //init smart object for ivug slider
+
+ PERF_CHECK_BEGIN(LVL3 "evas_object_smart_add");
+
+ obj = evas_object_smart_add(evas_object_evas_get(parent), _smart_); //create smart object.
+ ivug_retv_if(!obj, NULL);
+
+
+ PERF_CHECK_END(LVL3 "evas_object_smart_add");
+
+ MSG_SLIDER_HIGH("Slider Added Obj(0x%08x) Evas(0x%08x) Parent(0x%08x)", obj, evas_object_evas_get(parent), parent);
+
+ return obj;
+}
+
+
+int
+ivug_slider_get_total_slide_count(Evas_Object* obj)
+{
+ ivug_retv_if(!obj, -1); // TODO
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ ivug_retv_if(!sd, -1);
+
+ if(sd->list_total_count <= 0) //sd->media_list->left_end == -1 ||
+ {
+ sd->list_total_count = eina_list_count(ivug_data_get_first(sd->media_list));
+ }
+ return sd->list_total_count;
+
+}
+
+int
+ivug_slider_get_current_slide_count(Evas_Object* obj)
+{
+ ivug_retv_if(!obj, -1); // TODO
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ ivug_retv_if(!sd, -1);
+
+ return sd->cur_list_idx;
+}
+
+Slide_Item *
+ivug_slider_get_current_slide_item(Evas_Object* obj)
+{
+ ivug_retv_if(!obj, NULL);
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ ivug_retv_if(!sd, NULL);
+
+ return sd->slide[CENTER_SLIDE];
+}
+
+
+void
+ivug_slider_delete_current_slide(Evas_Object* obj)
+{
+ ivug_ret_if(!obj);
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ IVUG_FUNC_ENTER();
+
+ if (sd == NULL)
+ {
+ MSG_SLIDER_ERROR("Slide data is NULL");
+ return;
+ }
+
+ shift_direction_t direction = SLIDE_SHIFT_NONE;
+ if (sd->slide[NEXT_SLIDE]->state != SLIDE_STATE_NONE)
+ {
+ MSG_SLIDER_HIGH("right slide state = %d ", sd->slide[NEXT_SLIDE]->state);
+ direction = SLIDE_SHIFT_TO_RIGHT;
+ }
+ else if (sd->slide[PREV_SLIDE]->state != SLIDE_STATE_NONE)
+ {
+ MSG_SLIDER_HIGH("left slide state = %d ", sd->slide[PREV_SLIDE]->state);
+ direction = SLIDE_SHIFT_TO_LEFT;
+ }
+
+ MSG_SLIDER_HIGH("shift direction = %d ", direction);
+
+ ivug_data_delete_media_item( sd->media_list , sd->slide[CENTER_SLIDE]->mitem ); //delete data.
+ sd->slide[CENTER_SLIDE]->mitem = NULL;
+
+ ivug_slider_item_data_unset(sd->slide[CENTER_SLIDE]);
+
+ Media_Item* item = NULL;
+
+ //move slide.
+ if ( direction == SLIDE_SHIFT_TO_RIGHT )
+ {
+ Slide_Item *tmp = sd->slide[CENTER_SLIDE];
+
+ item = ivug_data_get_next(sd->slide[NEXT_SLIDE]->mitem); //get next data.
+
+ sd->slide[CENTER_SLIDE] = sd->slide[NEXT_SLIDE];
+ sd->slide[NEXT_SLIDE] = tmp;
+
+ if(item != NULL)
+ {
+ ivug_slider_item_data_set(sd->slide[NEXT_SLIDE], item);
+ ivug_slider_item_data_loading(sd->slide[NEXT_SLIDE]);
+ }
+ }
+ else if ( direction == SLIDE_SHIFT_TO_LEFT) // ----------->
+ {
+ Slide_Item *tmp = sd->slide[CENTER_SLIDE];
+
+ item = ivug_data_get_prev(sd->slide[PREV_SLIDE]->mitem); //get next data.
+
+ sd->slide[CENTER_SLIDE] = sd->slide[PREV_SLIDE];
+ sd->slide[PREV_SLIDE] = tmp;
+
+ sd->cur_list_idx--;
+
+ if(item != NULL)
+ {
+ ivug_slider_item_data_set(sd->slide[PREV_SLIDE], item);
+ ivug_slider_item_data_loading(sd->slide[PREV_SLIDE]);
+ }
+ }
+ else // Shift none
+ {
+ }
+
+ _ivug_slider_slide_update_pos(sd, 0 , 0); //update
+
+ Media_Data *sdata = NULL;
+
+ if ( sd->slide[CENTER_SLIDE]->mitem != NULL )
+ {
+ sdata = ivug_data_get_data(sd->slide[CENTER_SLIDE]->mitem);
+ }
+
+ sd->list_total_count--;
+
+ evas_object_smart_callback_call(sd->obj, "slider,item,deleted", sd->slide[CENTER_SLIDE]);
+
+ if(sd->idler_list == NULL)
+ {
+ sd->idler_list = ecore_idler_add(_ivug_slider_set_window_loading_idler, (void *)sd);
+ }
+
+ IVUG_FUNC_LEAVE();
+}
+
+Eina_Bool
+ivug_slider_set_slide_list(Evas_Object* obj, Media_List *mList, Eina_List *new_list, Media_Item *current, int index, int total_count)
+
+{
+ IV_ASSERT(obj != NULL);
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+
+ ivug_retv_if(!sd, EINA_FALSE); //check smart data.
+
+ sd->media_list = mList;
+ sd->cur_list_idx = index;
+ sd->current = current;
+ sd->list_total_count = total_count;
+
+ //set init
+ PERF_CHECK_BEGIN(LVL4 "unset prev&next");
+
+ ivug_slider_item_data_unset(sd->slide[PREV_SLIDE]);
+ ivug_slider_item_data_unset(sd->slide[NEXT_SLIDE]);
+
+ PERF_CHECK_END(LVL4 "unset prev&next");
+
+ if(new_list != NULL)
+ {
+ ivug_slider_item_change_mitem_pointer(sd->slide[CENTER_SLIDE], current);
+
+ ivug_data_delete_all_window_list(sd->media_list); // clear window list
+ ivug_data_append_media_item(sd->media_list, new_list);
+ }
+ else
+ {
+ PERF_CHECK_BEGIN(LVL4 "set center");
+
+ ivug_slider_item_data_unset( sd->slide[CENTER_SLIDE]);
+ ivug_slider_item_data_set(sd->slide[CENTER_SLIDE], current);
+
+ ivug_slider_item_data_loading(sd->slide[CENTER_SLIDE]);
+
+ PERF_CHECK_END(LVL4 "set center");
+ }
+
+ Media_Item *item = ivug_data_get_next(current);
+ if(item != NULL)
+ {
+ PERF_CHECK_BEGIN(LVL4 "set next");
+
+ ivug_slider_item_data_set(sd->slide[NEXT_SLIDE], item);
+
+#ifdef DEFFERED_LOADING
+ if ( sd->load_idler == NULL )
+ {
+ sd->load_idler = ecore_idler_add(_idler_loading_func, sd);
+ }
+#else
+ ivug_slider_item_data_loading(sd->slide[NEXT_SLIDE]); //set data.
+#endif
+
+
+ PERF_CHECK_END(LVL4 "set next");
+ }
+ item = ivug_data_get_prev(current);
+ if(item != NULL)
+ {
+ PERF_CHECK_BEGIN(LVL4 "set prev");
+
+ ivug_slider_item_data_set(sd->slide[PREV_SLIDE], item);
+
+#ifdef DEFFERED_LOADING
+ if ( sd->load_idler == NULL )
+ {
+ sd->load_idler = ecore_idler_add(_idler_loading_func, sd);
+ }
+#else
+ ivug_slider_item_data_loading(sd->slide[PREV_SLIDE]); //set data.
+#endif
+
+
+ PERF_CHECK_END(LVL4 "set prev");
+ }
+
+ PERF_CHECK_BEGIN(LVL4 "slider,item,changed");
+
+ evas_object_smart_callback_call(sd->obj, "slider,item,changed", sd->slide[CENTER_SLIDE]);
+
+ PERF_CHECK_END(LVL4 "slider,item,changed");
+
+ return EINA_TRUE;
+}//ivug slider set list
+
+Media_Data *
+ivug_slider_create_media_list(Evas_Object* obj, ivug_parameter* ivug_param)
+{
+ // Data List
+ int list_total_count = 0;
+ int start_index = ivug_param->start_index;
+ Media_Item *item = NULL;
+ Media_List *mList = ivug_data_init_media_list(ivug_param);
+ Media_Data *mdata = NULL;
+
+ if (mList == NULL)
+ {
+ MSG_SLIDER_ERROR("media list is NULL");
+ return NULL;
+ }
+
+ PERF_CHECK_BEGIN(LVL3 "get media list");
+ item = ivug_data_create_media_list_from_param
+ (mList, NULL, ivug_param->filepath, &start_index, &list_total_count); //get list by file path.
+ if(item == NULL)
+ {
+ MSG_SLIDER_ERROR("create media list failed");
+ free(mList);
+ return NULL;
+ }
+ PERF_CHECK_END(LVL3 "get media list");
+
+ PERF_CHECK_BEGIN(LVL3 "set slide list");
+
+ if (!ivug_slider_set_slide_list(obj, mList, NULL, item, start_index, list_total_count))
+ {
+ MSG_SLIDER_ERROR("slide list set Error");
+ free(mList);
+ return NULL;
+ }
+
+ PERF_CHECK_END(LVL3 "set slide list");
+
+// struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+// if(sd->ss_mode & SLIDE_SHOW_MODE_SHUFFLE)
+ {
+ PERF_CHECK_BEGIN(LVL3 "make shuffled list");
+
+ ivug_data_create_shuffled_list(mList, list_total_count);
+
+ PERF_CHECK_END(LVL3 "make shuffled list");
+ }
+
+ mdata = ivug_data_get_data(item);
+ return mdata;
+}
+
+
+char*
+ivug_slider_get_next_exist_filepath(Evas_Object* obj)
+{
+ IVUG_FUNC_ENTER();
+ ivug_retv_if(!obj, NULL);
+ struct Smart_Data *sd = (struct Smart_Data *) evas_object_smart_data_get(obj);
+ ivug_retv_if(!sd, NULL);
+
+ char* file_path = NULL;
+
+ Media_Item* next_item = ivug_data_get_next(sd->slide[CENTER_SLIDE]->mitem);
+ Media_Data *sdata = NULL;
+
+ while(next_item)
+ {
+ sdata = ivug_data_get_data(next_item);
+
+ if(sdata != NULL) // TODO : Should review
+ {
+ MSG_SLIDER_HIGH("sl_data%s", sdata->filepath);
+
+ if(sdata->filepath && ecore_file_exists(sdata->filepath))
+ {
+ MSG_SLIDER_HIGH("exist filepath %s", sdata->filepath);
+ file_path = sdata->filepath;
+ break;
+ }
+ }
+
+ next_item = ivug_data_get_next(next_item);
+ }
+
+ //All files from current are deleted, search from beginning
+ if(!file_path)
+ {
+ next_item = ivug_data_get_first(sd->media_list);
+ while(next_item && next_item != ivug_data_get_next(sd->slide[CENTER_SLIDE]->mitem))
+ {
+ sdata = ivug_data_get_data(next_item);
+
+ if(sdata != NULL) // TODO : Should review
+ {
+ MSG_SLIDER_HIGH("sl_data%s", sdata->filepath);
+
+ if(sdata->filepath && ecore_file_exists(sdata->filepath))
+ {
+ MSG_SLIDER_HIGH("exist filepath %s", sdata->filepath);
+ file_path = sdata->filepath;
+ break;
+ }
+ }
+
+ next_item = ivug_data_get_next(next_item);
+ }
+ }
+
+ IVUG_FUNC_LEAVE();
+
+ return file_path;
+}
+
+
diff --git a/main/src/view/ivug-slider.h b/main/src/view/ivug-slider.h
new file mode 100755
index 0000000..bff73c2
--- /dev/null
+++ b/main/src/view/ivug-slider.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __IVUG_SLIDER_H__
+#define __IVUG_SLIDER_H__
+
+#include "ivug-data.h"
+#include "ivug-slider-item.h"
+
+typedef enum {
+ SLIDE_SHOW_STOPPED = 0x00,
+ SLIDE_SHOW_RUNNING,
+ SLIDE_SHOW_PAUSE,
+} slideshow_state_t;
+
+
+//define callback function.
+typedef void (*ivug_slider_shift_cb)(Media_Data *cur_sd, void* user_data);
+typedef void (*ivug_slider_delete_cb)(Media_Data *cur_sd, void* user_data);
+typedef void (*ivug_slider_slide_show_finish_cb)(Media_Data *cur_sd, void* user_data);
+
+/*
+ Slider signal list.
+
+ "slider,clicked" : when click once
+ "slider,clicked,double" : when double click
+ "slider,longpressed" : when long pressed on slider
+ "slider,clicked,icon" : video icon clicked.
+ "slider,item,changed"
+
+ "slider,item,state,changed"
+ "slider,item,deleted"
+ "slider,slideshow,finished" : slide show ended cause last slide
+ "slider,slideshow,interrupted" : slide show stopped by user
+*/
+
+Evas_Object*
+ivug_slider_add(Evas_Object* parent);
+
+Eina_Bool
+ivug_slider_set_slide_list(Evas_Object* obj, Media_List *mList, Eina_List *new_list, Media_Item *current, int index, int total_count);
+
+Media_Data *
+ivug_slider_create_media_list(Evas_Object* obj, ivug_parameter* ivug_param);
+
+void
+ivug_slider_delete_current_slide(Evas_Object* obj);
+
+void ivug_slider_restore_window_list(Evas_Object *obj);
+
+Slide_Item *
+ivug_slider_get_current_slide_item(Evas_Object* obj);
+
+/* Will be deprecated */
+int
+ivug_slider_get_current_slide_count(Evas_Object* obj);
+
+int
+ivug_slider_get_total_slide_count(Evas_Object* obj);
+
+/* Will be deprecated*/
+char*
+ivug_slider_get_next_exist_filepath(Evas_Object* obj);
+
+// Slide Show
+void
+ivug_slider_pause_slide_show(Evas_Object* obj);
+
+void
+ivug_slider_resume_slide_show(Evas_Object* obj);
+
+/* if bSlideFirst == EINA_TRUE, slide and then wait interval time
+ if bSlideFirst == EINA_FALSE, wait interval time and then slide */
+void
+ivug_slider_start_slide_show(Evas_Object* obj, Eina_Bool bSlideFirst);
+
+void
+ivug_slider_stop_slide_show(Evas_Object* obj);
+
+
+#endif