* limitations under the License.
*/
-
#include <stdio.h>
+#include <stdbool.h>
+
#include <Elementary.h>
-#include <appcore-efl.h>
-#include <appcore-common.h>
+#include <app.h>
+
#include <utilX.h>
#include <Evas.h>
#include <Ecore_X.h>
#include <ui-gadget-module.h>
#include <ui-gadget.h>
-#include <aul.h>
-#include <appsvc.h>
-#include <stdbool.h>
+
#include <vconf.h>
#include <vconf-keys.h>
#define PACKAGE "image-viewer"
#define LOCALEDIR "/opt/apps/com.image-viewer/res/locale"
-#define UG_MODE_NORMAL "NORMAL"
#define UG_MODE_SINGLE "SINGLE"
#define UG_STANDALONE_VALUE "TRUE"
-void sample_cb(const char *k, const char *v, void *data)
-{
- iv_debug_msg(MB_DEBUG_LOG,"%s -> %s", k, v);
-}
+#define UG_BUNDLE_KEY_VIEW_MODE "View Mode"
+#define UG_BUNDLE_KEY_PATH "Path"
+#define UG_BUNDLE_KEY_SETAS_TYPE "Setas type"
+#define UG_BUNDLE_KEY_STANDALONE "Standalone"
+#define SERVICE_OPERATION_CROP "http://tizen.org/appsvc/operation/crop"
-static bool _parsing_bundle(bundle *b, void *data)
+static const char *_conver_error(int err)
{
- iv_retv_if(data == NULL, false);
- iv_retv_if(b == NULL, false);
-
- appdata_iv *ap = (appdata_iv *)data;
-
- const char *uri = NULL;
- const char *operation = appsvc_get_operation(b);
- if(operation != NULL && strcmp(operation, APPSVC_OPERATION_VIEW) == 0)
+ switch(err)
{
- uri = appsvc_get_uri(b);
- if(uri == NULL)
- {
- iv_debug_msg(MB_DEBUG_LOG, "uri is NULL");
- return false;
- }
-
- ap->iv_param_path = uri;
- ap->view_mode = appsvc_get_data(b, "View Mode");
- ap->sort_type = appsvc_get_data(b, "Sort By");
- ap->view_by = appsvc_get_data(b, "View By");
- ap->media_type = appsvc_get_data(b, "Media type");
-
- iv_debug_msg(MB_DEBUG_LOG,"*****************************");
- iv_debug_msg(MB_DEBUG_LOG,"org.tizen.image-viewer : Case 1");
- iv_debug_msg(MB_DEBUG_LOG," Operation : %s", operation);
- iv_debug_msg(MB_DEBUG_LOG," URI path : %s", ap->iv_param_path);
- iv_debug_msg(MB_DEBUG_LOG," View Mode : %s", ap->view_mode);
- iv_debug_msg(MB_DEBUG_LOG," Sort Type : %s", ap->sort_type);
- iv_debug_msg(MB_DEBUG_LOG," View By : %s", ap->view_by);
- iv_debug_msg(MB_DEBUG_LOG," Media Type: %s", ap->media_type);
- iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-
- }
- else /* it is temp code, for backward compatability */
- {
- uri = bundle_get_val(b, AUL_K_MIME_CONTENT);
- if(uri == NULL)
- {
- iv_debug_msg(MB_DEBUG_LOG, "uri is NULL. %s", AUL_K_MIME_CONTENT);
-
- // iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-
- // bundle_iterate(b, sample_cb, NULL);
-
- // iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-
- if ( ap->iv_param_path == NULL )
- {
- iv_debug_msg(MB_DEBUG_LOG, "URI and Path is all empty. finish appl");
- return false;
- }
- }
- else
+ case SERVICE_ERROR_NONE:
+ return "Successful";
+ case SERVICE_ERROR_INVALID_PARAMETER:
+ return "Invalid parameter";
+ case SERVICE_ERROR_KEY_NOT_FOUND:
+ return "Specified key not found";
+ case SERVICE_ERROR_OUT_OF_MEMORY:
+ return "Out of memory";
+ case SERVICE_ERROR_INVALID_DATA_TYPE:
+ return "Invalid data type";
+ default:
{
- ap->iv_param_path = uri;
+ static char error[128];
+ sprintf(error, "Unknow Error : %d(0x%08x)", err, err);
+ return error;
}
-
- ap->view_mode = bundle_get_val(b, "View Mode");
- ap->sort_type = bundle_get_val(b, "Sort By");
- ap->view_by = bundle_get_val(b, "View By");
- ap->media_type = bundle_get_val(b, "Media type");
-
- iv_debug_msg(MB_DEBUG_LOG,"*****************************");
- iv_debug_msg(MB_DEBUG_LOG,"org.tizen.image-viewer : Case 2");
- iv_debug_msg(MB_DEBUG_LOG," Operation : %s", operation);
- iv_debug_msg(MB_DEBUG_LOG," URI path : %s", ap->iv_param_path);
- iv_debug_msg(MB_DEBUG_LOG," View Mode : %s", ap->view_mode);
- iv_debug_msg(MB_DEBUG_LOG," Sort Type : %s", ap->sort_type);
- iv_debug_msg(MB_DEBUG_LOG," View By : %s", ap->view_by);
- iv_debug_msg(MB_DEBUG_LOG," Media Type: %s", ap->media_type);
- iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-
}
- return true;
+ return NULL;
}
-static void __back_cb(void *data);
+void _orient_changed(app_device_orientation_e orientation, void *user_data);
+
/**
* @brief The win delete function
* @param obj
* @param event_info
*/
-static void win_del(void *data, Evas_Object *obj, void *event_info)
+static void _win_del(void *data, Evas_Object *obj, void *event_info)
{
elm_exit();
}
/**
-* @brief The hard key up exit callback
-*
-* @param data The app data
-* @param type
-* @param event The event key
-*
-* @return 0
-*/
-static Eina_Bool _keydown_event(void *data, int type, void *event)
-{
- iv_retv_if(data == NULL, ECORE_CALLBACK_CANCEL);
-
- Ecore_Event_Key *ev = event;
- appdata_iv *ad = (appdata_iv *)data;
-
- if (!strcmp(ev->keyname, KEY_END))
- {
- iv_debug_msg(MB_DEBUG_LOG, "End Key DOWN");
- if (ad->iv_ug)
- {
- ug_destroy(ad->iv_ug);
- }
-
- elm_exit();
- }
-
- return ECORE_CALLBACK_RENEW;
-}
-
-/**
-* @brief The hard key up exit callback
-*
-* @param data The app data
-* @param type
-* @param event The event key
-*
-* @return 0
-*/
-static Eina_Bool _keyup_event(void *data, int type, void *event)
-{
- Ecore_Event_Key *ev = event;
-
- if (!strcmp(ev->keyname, KEY_END))
- {
- iv_debug_msg(MB_DEBUG_LOG, "End Key UP");
- }
-
- return ECORE_CALLBACK_RENEW;
-
-}
-
-
-/**
-* @brief The language change callback
-*
-* @param data The user data
-*
-* @return 0 on sucess
-*/
-static int lang_changed(void *data)
-{
- ug_send_event( UG_EVENT_LANG_CHANGE );
- return 0;
-}
-
-/**
-* @brief The low batter callback
-*
-* @param data The user data
-*
-* @return 0 on sucess
-*/
-static int low_battery_cb(void *data)
-{
- ug_send_event( APPCORE_EVENT_LOW_BATTERY );
- return 0;
-}
-
-/**
-* @brief The low memory callback
-*
-* @param data The user data
-*
-* @return 0 on sucess
-*/
-static int low_memory_cb(void *data)
-{
- ug_send_event( APPCORE_EVENT_LOW_MEMORY );
- return 0;
-}
-
-
-/**
* @brief Create the main window
*
* @param name The title of the window
*
* @return the win on sucess
*/
-static Evas_Object* create_win(const char *name)
+static Evas_Object* _create_win(const char *name)
{
iv_retv_if(name == NULL, NULL);
Evas_Object *eo;
{
elm_win_title_set(eo, name);
elm_win_borderless_set(eo, EINA_TRUE);
- evas_object_smart_callback_add(eo, "delete,request",
- win_del, NULL);
+ evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
ecore_x_window_size_get(ecore_x_window_root_first_get(),
&w, &h);
evas_object_resize(eo, w, h);
/**
* @brief Create the background
*
-* @param ap The app data
+* @param parent object
*/
-static void
-iv_ui_background_create(appdata_iv* ap)
-{
- iv_ret_if(ap == NULL);
- Evas_Object *black = NULL;
- ap->iv_bg = black = evas_object_rectangle_add(ap->evas);
- evas_object_color_set(black, 0, 0, 0,255);
- elm_win_resize_object_add(ap->win_main, ap->iv_bg);
- evas_object_show(black);
- evas_object_repeat_events_set(black, EINA_FALSE);
-}
-
-
-
-/**
-* @brief The back callback to destroy UG created
-*
-* @param data The app data
-*/
-static void __back_cb(void *data)
-{
- iv_ret_if(data == NULL);
- appdata_iv *ap = (appdata_iv *)data;
-
- if(ap->iv_ug)
- {
- ug_destroy(ap->iv_ug);
- }
-}
-
-static Evas_Object* load_edj(Evas_Object *parent, const char *file,
- const char *group)
+static Evas_Object* _create_bgimg(Evas_Object* parent)
{
- Evas_Object *eo;
- int r;
+ 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);
- eo = elm_layout_add(parent);
- if (eo)
- {
- r = elm_layout_file_set(eo, file, group);
- if (!r) {
- evas_object_del(eo);
- return NULL;
- }
+ elm_win_resize_object_add(parent, bg);
- evas_object_size_hint_weight_set(eo,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- }
+ evas_object_show(bg);
- return eo;
+ return bg;
}
-
/**
* @brief The layout callback after ug created
*
* @param mode The UG mode, FULLVIEW or FRAMEVIEW
* @param priv The privite data
*/
-void ug_layout_cb( struct ui_gadget *ug, enum ug_mode mode, void* priv)
+void _ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void* priv)
{
+ IV_MSG_HIGH("ug Layout CB. UG=0x%08x Priv=0x%08x Mode=%d", ug, priv, mode);
+
Evas_Object *base, *win;
if (!ug || !priv)
{
+ IV_MSG_ERROR("Abnormal value. UG=0x%08x Priv=0x%08x Mode=%d", ug, priv, mode);
return;
}
+ appdata_iv *ap = (appdata_iv *)priv;
+
base = ug_get_layout(ug);
if (!base)
{
+ IV_MSG_HIGH( "ug_get_layout is fail");
return;
}
+ ap->ug_layout = base;
win = ug_get_window();
- switch (mode) {
- case UG_MODE_FULLVIEW:
- evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, base);
- ug_disable_effect(ug);
- evas_object_show(base);
- break;
- default:
- iv_debug_msg(MB_DEBUG_LOG, "Unknow UG mode : %d", mode);
- break;
+ switch (mode)
+ {
+ case UG_MODE_FULLVIEW:
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, base);
+ ug_disable_effect(ug);
+ evas_object_show(base);
+ break;
+ default:
+ IV_MSG_HIGH("Unknow UG mode : %d", mode);
+ break;
}
}
* @param result The result received from ug
* @param priv The privite data
*/
-void ug_return_cb( struct ui_gadget *ug, bundle *result, void *priv)
+void _ug_result_cb(ui_gadget_h ug, service_h reply, void *priv)
{
- appdata_iv *ap;
+ IV_MSG_HIGH("UG Result CB.");
if (!ug || !priv)
{
+ IV_MSG_ERROR("Abnormal value. UG=0x%08x Priv=0x%08x", ug, priv);
return;
}
- ap = priv;
- ug_destroy(ug);
- ap->iv_ug = NULL;
+ appdata_iv *ap = (appdata_iv *)priv;
+
+ int ret = service_reply_to_launch_request(reply, ap->service_handle, SERVICE_RESULT_SUCCEEDED);
+ if (ret != SERVICE_ERROR_NONE)
+ {
+ IV_MSG_ERROR("service_reply_to_launch_request failed! [%s]", _conver_error(ret));
+ }
}
/**
* @param ug The ug created
* @param priv The privite data
*/
-void ug_closed_cb( struct ui_gadget *ug, void *priv)
+void _ug_closed_cb(ui_gadget_h ug, void *priv)
{
- if(ug)
+ IV_MSG_HIGH("UG Destroyed..");
+
+ if (!ug || !priv)
{
- ug_destroy(ug);
+ IV_MSG_ERROR("Abnormal value. UG=0x%08x Priv=0x%08x", ug, priv);
+ return;
}
- elm_exit();
+ //appdata_iv *ap = (appdata_iv *)priv;
+
+ elm_exit(); // will tirgger app_terminated
}
/**
*
* @return ug on sucess, NULL on fail
*/
-struct ui_gadget *create_ug(void* data)
+ui_gadget_h _create_ug(void* data)
{
iv_retv_if(data == NULL, NULL);
- appdata_iv *ap = (struct appdata_iv *)data;
+ appdata_iv *ap = (appdata_iv *)data;
- iv_debug_msg(MB_DEBUG_LOG, "");
- if(!(ap->iv_param_path))
- {
- return NULL;
- }
+ ui_gadget_h ug;
+ struct ug_cbs cbs = {0,};
- struct ui_gadget *ug;
- struct ug_cbs cbs;
- memset(&cbs, 0x0, sizeof(struct ug_cbs));
+ cbs.layout_cb = _ug_layout_cb;
+ cbs.result_cb = _ug_result_cb;
+ cbs.destroy_cb = _ug_closed_cb;
+ cbs.priv = ap;
- bundle *b;
+ ug = ug_create(NULL, "image-viewer-efl", UG_MODE_FULLVIEW, ap->service_handle, &cbs);
- b = bundle_create();
- if (!b)
+ IV_MSG_HIGH("UG Created!");
+ return ug;
+}
+
+static bool _is_rotation_lock(void)
+{
+ int lock = 0;
+ int ret = -1;
+
+ ret = vconf_get_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, &lock);
+
+ if ( ret != 0) // Failed
{
- iv_debug_msg(MB_DEBUG_LOG, "Bundle create error!");
- return NULL;
+ IV_MSG_HIGH( "Rotation locked state is [%d].", lock);
+ return false;
}
- if(ap->view_mode && strcmp(ap->view_mode, UG_MODE_NORMAL) == 0)
+ if ( lock == true)
{
- bundle_add(b, "View Mode", UG_MODE_NORMAL);
+ IV_MSG_HIGH("Rotation is locked");
+ return true;
}
- else
+
+ return false;
+}
+
+static void _on_portrait_lock_changed(keynode_t* node, void *user_data)
+{
+ IV_MSG_HIGH("State changed. %s=%d", vconf_keynode_get_name(node), vconf_keynode_get_bool(node));
+
+ if ( vconf_keynode_get_bool(node) == true )
{
- bundle_add(b, "View Mode", UG_MODE_SINGLE);
+ // When Set portrait lock, Set degree as 0.
+ _orient_changed(APP_DEVICE_ORIENTATION_0, user_data);
}
+}
+
+static bool _app_create(void *user_data)
+{
+// Hook to take necessary actions before main event loop starts
+// Initialize UI resources and application's data
+// If this function returns true, the main loop of application starts
+// If this function returns false, the application is terminated
+ IV_ASSERT(user_data != NULL);
+
+ IV_MSG_HIGH("App Create");
+
+ elm_config_preferred_engine_set("opengl_x11"); //enabling the OpenGL as the backend of the EFL.
- if(ap->sort_type)
+ appdata_iv *ap = (appdata_iv *) user_data;
+
+ Evas_Object *win = _create_win(PACKAGE);
+ if ( win == NULL )
{
- bundle_add(b, "Sort By", ap->sort_type);
+ IV_MSG_ERROR("Cannot create app. pkg=%s", PACKAGE);
+ return false;
}
- if(ap->view_by)
+ ap->win_main = win;
+
+ UG_INIT_EFL(ap->win_main, UG_OPT_INDICATOR_ENABLE); // Init UG module
+
+ ap->bg = _create_bgimg(ap->win_main);
+ if ( ap->bg == NULL )
{
- bundle_add(b, "View By", ap->view_by);
+ IV_MSG_ERROR("Cannot create bg");
+ return false;
}
- if(ap->media_type)
+ int ret = -1;
+
+ ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, _on_portrait_lock_changed, user_data);
+ if ( ret == -1 )
{
- bundle_add(b, "Media type", ap->media_type);
+ IV_MSG_ERROR("Register %s is failed", VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL);
+ return false;
}
- bundle_add(b, "Path", ap->iv_param_path);
+ _orient_changed(app_get_device_orientation(), user_data); // Set initial degree
- bundle_add(b, "Standalone", UG_STANDALONE_VALUE);
+ return true;
+}
- cbs.layout_cb = ug_layout_cb;
- cbs.result_cb = ug_return_cb;
- cbs.destroy_cb = ug_closed_cb;
- cbs.priv = ap;
+bool _iter_extra_data_cb(service_h service, const char *key, void *user_data)
+{
+ char *value = NULL;
- ug = ug_create(NULL, "image-viewer-efl", UG_MODE_FULLVIEW, b, &cbs);
+ IV_MSG_HIGH(" Key=%s Value=%s", key, value);
- bundle_free(b);
+ int ret = service_get_extra_data(service, key, &value);
+ if (ret != SERVICE_ERROR_NONE)
+ {
+ IV_MSG_ERROR("service_get_extra_data %s failed, [%s]", key, _conver_error(ret));
+ return false;
+ }
- iv_debug_msg(MB_DEBUG_LOG, "");
- return ug;
+ free(value);
+
+ return true;
}
-/**
-* @brief Called before main loop
-*
-* @param data The user data
-*
-* @return 0 on sucess
-*/
-static int app_create(void *data)
+
+static void _app_service(service_h service, void *user_data)
{
- iv_retv_if(data == NULL, -1);
- iv_debug_msg(MB_DEBUG_LOG, "");
- appdata_iv *ap = (appdata_iv *) data;
+// How to get Alarm service????
+ appdata_iv *ap = (appdata_iv *)user_data;
- Evas_Object *win = create_win(PACKAGE);
+ IV_MSG_HIGH("%s", __func__);
- Evas_Object *ly;
- iv_retv_if(win == NULL, -1);
+ char *operation = NULL;
+ char *uri = NULL;
- ap->win_main = win;
+ int ret = service_get_operation(service, &operation);
+ if (ret != SERVICE_ERROR_NONE)
+ {
+ IV_MSG_ERROR("service_get_operation failed, [%s]", _conver_error(ret));
+ goto EXIT;
+ }
+
+ if ( operation == NULL )
+ {
+ IV_MSG_ERROR("Operation cannot be NULL.");
+ goto EXIT;
+ }
+
+ ret = service_foreach_extra_data(service, _iter_extra_data_cb, NULL);
+ if (ret != SERVICE_ERROR_NONE)
+ {
+ IV_MSG_ERROR("service_foreach_extra_data failed, [%s]", _conver_error(ret));
+ goto EXIT;
+ }
- UG_INIT_EFL(ap->win_main, UG_OPT_INDICATOR_ENABLE);
+ ret = service_get_uri(service, &uri);
+ if (ret != SERVICE_ERROR_NONE)
+ {
+ IV_MSG_ERROR("service_get_uri failed, [%s]", _conver_error(ret));
+ goto EXIT;
+ }
- lang_changed(ap);
+ IV_MSG_HIGH( "Operation=%s URI=%s", operation, uri);
- /* add system event callback */
- appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, lang_changed, ap);
- appcore_set_event_callback(APPCORE_EVENT_LOW_BATTERY, low_battery_cb, ap);
- appcore_set_event_callback(APPCORE_EVENT_LOW_MEMORY, low_memory_cb, ap);
+ ret = service_clone(&ap->service_handle, service);
+ if (ret != SERVICE_ERROR_NONE)
+ {
+ IV_MSG_ERROR("service_clone failed, [%s]", _conver_error(ret));
+ goto EXIT;
+ }
- ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _keydown_event, ap);
- ecore_event_handler_add(ECORE_EVENT_KEY_UP, _keyup_event, ap);
+ if( strcmp(operation, SERVICE_OPERATION_VIEW) == 0 || strcmp(operation, SERVICE_OPERATION_DEFAULT) == 0)
+ {
+ if(uri) // uri can entered through argv[1]
+ {
+ ap->iv_param_path = uri;
+ }
+ if ( ap->iv_param_path == NULL )
+ {
+ IV_MSG_ERROR("Entered path is NULL");
+ goto EXIT;
+ }
- return 0;
-}
+ IV_MSG_HIGH("*****************************");
+ IV_MSG_HIGH("com.samsung.image-viewer : Case View");
+ IV_MSG_HIGH(" URI path : %s", ap->iv_param_path);
+ IV_MSG_HIGH("*****************************");
-/**
-* @brief Called after main loop, terminate the app
-*
-* @param data The user data
-*
-* @return 0 on sucess
-*/
-static int app_terminate(void *data)
-{
+ free(operation);
+ }
+ else if( strcmp(operation, SERVICE_OPERATION_CROP) == 0)
+ {
+ char *value = NULL; // Will freed on terminate
+
+ if(uri) // uri can entered through argv[1]
+ {
+ ap->iv_param_path = uri;
+ }
+ if ( ap->iv_param_path == NULL )
+ {
+ IV_MSG_ERROR("Entered path is NULL");
+ goto EXIT;
+ }
+
+ service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_VIEW_MODE, "SETAS");
+
+ service_get_extra_data(ap->service_handle, UG_BUNDLE_KEY_SETAS_TYPE, &value);
+ if(value == NULL)
+ {
+ service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_SETAS_TYPE, "Crop");
+ }
+
+ IV_MSG_HIGH("*****************************");
+ IV_MSG_HIGH("com.samsung.image-viewer : Case Crop");
+ IV_MSG_HIGH(" URI path : %s", ap->iv_param_path);
+ IV_MSG_HIGH("*****************************");
- if(data)
+ free(operation);
+ }
+ else
{
- __back_cb(data);
+ IV_MSG_ERROR("Unknown operation. %s", operation);
+ free(operation);
+
+ if ( ap->iv_param_path == NULL )
+ {
+ IV_MSG_ERROR("Entered path is NULL");
+ goto EXIT;
+ }
}
- elm_exit();
+ if(ap->iv_param_path == NULL)
+ {
+ IV_MSG_ERROR("File path is NULL. cannot create UG");
+ goto EXIT;
+ }
+
+ elm_win_activate(ap->win_main);
+ evas_object_show(ap->win_main);
- iv_debug_msg(MB_DEBUG_LOG, "exit");
+ if(ap->iv_ug != NULL)
+ {
+ // Create Previous UG if exist
+ IV_MSG_HIGH("Removing previous UG=0x%08x", ap->iv_ug);
+ ug_destroy(ap->iv_ug);
+ ap->iv_ug = NULL;
+ }
+
+ char *view_mode = NULL;
+ service_get_extra_data(ap->service_handle, UG_BUNDLE_KEY_VIEW_MODE, &view_mode);
+ if(view_mode == NULL)
+ {
+ service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_VIEW_MODE, UG_MODE_SINGLE);
+ }
+
+ service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_PATH, ap->iv_param_path);
+
+ service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_STANDALONE, UG_STANDALONE_VALUE);
+
+ ap->iv_ug = _create_ug(ap);
+ if(ap->iv_ug == NULL)
+ {
+ IV_MSG_HIGH("create_ug failed. Terminated");
+ elm_exit();
+ return;
+ }
+
+ return;
+
+EXIT:
+ if(ap->service_handle)
+ service_destroy(ap->service_handle);
+ ap->service_handle = NULL;
+ elm_exit();
+ return;
- return 0;
}
-/**
-* @brief Called when every window goes back
-*
-* @param data The user data
-*
-* @return 0 on sucess
-*/
-static int app_pause(void *data)
+
+void _app_pause(void *user_data)
{
- iv_debug_msg(MB_DEBUG_LOG, "");
+// Take necessary actions when application becomes invisible.
+ IV_MSG_HIGH("%s", __func__);
+
ug_pause();
- return -1;
}
-/**
-* @brief Called when any window comes on top
-*
-* @param data The user data
-*
-* @return 0 on sucess
-*/
-static int app_resume(void *data)
+void _app_resume(void *user_data)
{
- iv_debug_msg(MB_DEBUG_LOG, "");
+// Take necessary actions when application becomes visible.
+ IV_MSG_HIGH("%s", __func__);
ug_resume();
- return 0;
}
-/**
-* @brief Called at the first idler and every relaunching
-*
-* @param b The bundle param
-* @param data The user data
-*
-* @return 0 on sucess
-*/
-static int app_reset(bundle *b, void *data)
+void _app_terminate(void *user_data)
{
- iv_retv_if(data == NULL, -1);
- iv_debug_msg(MB_DEBUG_LOG, "");
+// Release all resources
+ IV_MSG_HIGH("%s", __func__);
- appdata_iv *ap = (appdata_iv *)data;
+ appdata_iv *ap = (appdata_iv *)user_data;
- if (ap->win_main)
- {
- elm_win_activate(ap->win_main);
- evas_object_show(ap->win_main);
+ if(ap->service_handle) {
+ service_destroy(ap->service_handle);
+ ap->service_handle = NULL;
}
- bool ret = false;
+ if(ap->iv_ug)
+ {
+ ug_destroy(ap->iv_ug);
+ ap->iv_ug = NULL;
+ }
- ret = _parsing_bundle(b, data);
- if(ret == false)
+ if(ap->ug_layout)
{
- iv_debug_msg(MB_DEBUG_LOG, "Cannot lauch Image Viewer");
- return 0;
+ evas_object_del(ap->ug_layout);
+ ap->ug_layout = NULL;
}
- if(ap->iv_ug != NULL)
+ IV_MSG_HIGH("%s terminated.", __func__);
+}
+
+void _region_changed(void *user_data)
+{
+ IV_MSG_HIGH("%s", __func__);
+ // Not used yet.
+}
+
+void _low_battery(void *user_data)
+{
+ IV_MSG_HIGH("%s", __func__);
+ ug_send_event( UG_EVENT_LOW_BATTERY );
+}
+
+void _low_memory(void *user_data)
+{
+ IV_MSG_HIGH("%s", __func__);
+ ug_send_event( UG_EVENT_LOW_MEMORY );
+
+}
+
+void _lang_changed(void *user_data)
+{
+ IV_MSG_HIGH("%s", __func__);
+ ug_send_event( UG_EVENT_LANG_CHANGE );
+
+}
+
+void _orient_changed(app_device_orientation_e orientation, void *user_data)
+{
+ IV_MSG_HIGH("%s. orientation=%d", __func__, orientation);
+
+/*
+ enum app_device_orientation_e
+
+ APP_DEVICE_ORIENTATION_0 The device is oriented in natural position
+
+ APP_DEVICE_ORIENTATION_90 The device's left side is at the top
+
+ APP_DEVICE_ORIENTATION_180 The device is upside down
+
+ APP_DEVICE_ORIENTATION_270 The device's right side is to the top
+
+*/
+ appdata_iv *ap = (appdata_iv *)user_data;
+
+ int degree = 0;
+ enum ug_event evt = UG_EVENT_NONE;
+
+ if ( _is_rotation_lock() == true ) // When rotatation lock is set, show application as portrate mode.
{
- // Create Previous UG if exist
- iv_debug_msg(MB_DEBUG_LOG, "Removing previous UG=0x%08x", ap->iv_ug);
- ug_destroy(ap->iv_ug);
- ap->iv_ug = NULL;
+ orientation = APP_DEVICE_ORIENTATION_0;
}
- ap->iv_ug = create_ug(ap);
- if(ap->iv_ug == NULL)
+ switch(orientation)
{
- iv_debug_msg(MB_DEBUG_LOG, "create_ug failed. Terminated");
- elm_exit();
- return ;
+ case APP_DEVICE_ORIENTATION_0:
+ degree = 0;
+ evt = UG_EVENT_ROTATE_PORTRAIT;
+ break;
+ case APP_DEVICE_ORIENTATION_90:
+ degree = 90;
+ evt = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
+ break;
+
+ case APP_DEVICE_ORIENTATION_180:
+ degree = 180;
+ evt = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
+ break;
+
+ case APP_DEVICE_ORIENTATION_270:
+ evt = UG_EVENT_ROTATE_LANDSCAPE;
+ degree = 270;
+ break;
}
- return 0;
+ ug_send_event( evt );
+
+// IV_MSG_HIGH( "evt = %d, r = %d", evt, r);
+
+ if ( ap->win_main != NULL )
+ {
+ elm_win_rotation_with_resize_set(ap->win_main, degree);
+ }
}
+
/**
* @brief The main function
*
*/
int main(int argc, char *argv[])
{
- struct appcore_ops ops = {
- .create = app_create,
- .terminate = app_terminate,
- .pause = app_pause,
- .resume = app_resume,
- .reset = app_reset,
- };
+ //setenv("ELM_ENGINE", "gl", 1); //changed to elm_config_preferred_engine_set("opengl_x11") at _app_create
+
+ appdata_iv ad = {0,};
+
+ app_event_callback_s event_callback = {0,};
- appdata_iv ap;
+ event_callback.create = _app_create;
+ event_callback.terminate = _app_terminate;
+ event_callback.pause = _app_pause;
+ event_callback.resume = _app_resume;
+ event_callback.service = _app_service;
- memset( &ap, 0x0, sizeof( appdata_iv ) );
- ops.data = ≈
+ event_callback.low_memory = _low_memory;
+ event_callback.low_battery = _low_battery;
+ event_callback.device_orientation = _orient_changed; /* Rotate is not supported in FMRadio */
+ event_callback.language_changed = _lang_changed; /* Currently, Application will terminated when change language */
+ event_callback.region_format_changed = NULL;
- if ( argc == 2 )
+ if ( argc == 2 ) // For command line options.
{
- ap.iv_param_path = strdup(argv[1]);
+ IV_MSG_HIGH("Parsing from cmd line. file=%s", argv[1]);
+ ad.iv_param_path = strdup(argv[1]);
}
- return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+ int ret = APP_ERROR_NONE;
+
+ ret = app_efl_main(&argc, &argv, &event_callback, &ad);
+
+ if ( ret != APP_ERROR_NONE )
+ {
+ IV_MSG_ERROR("app_efl_main() is failed. err=%d", ret);
+ // Go through
+ }
+
+ return ret;
+
}