diff options
Diffstat (limited to 'feature/src/ivug-ext-ug.c')
-rwxr-xr-x | feature/src/ivug-ext-ug.c | 500 |
1 files changed, 500 insertions, 0 deletions
diff --git a/feature/src/ivug-ext-ug.c b/feature/src/ivug-ext-ug.c new file mode 100755 index 0000000..e8d1e4e --- /dev/null +++ b/feature/src/ivug-ext-ug.c @@ -0,0 +1,500 @@ +/*
+ * 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.h> + +#include <app.h> +#include <Elementary.h> + +#include "ivug-ext-ug.h" +#include "ivug-util.h" +#include "ivug-debug.h" + +//definition +#define CONTACT_UG_NAME "contacts-list-efl"
+
+#define VIDEOPLAYER_PKG_NAME "org.tizen.video-player"
+#define BROWSER_PKG_NAME "org.tizen.browser"
+
+#define MIME_TYPE_LEN 255
+ +typedef struct { + ug_destroy_cb destroy_func; + ug_result_cb result_func; + void *cb_data; +}ext_ug_t; + +static bool _data_print(service_h service, const char *key, void *user_data) +{ + MSG_IVUG_HIGH(" %s", key); + + return true; +} + +static void print_service_data(service_h service) +{ + int ret = service_foreach_extra_data(service, _data_print, NULL); + + if(SERVICE_ERROR_NONE != ret) + { + MSG_IVUG_ERROR("service_foreach_extra_data ERROR"); + } +} + +static void +_ivug_ext_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv) +{ + Evas_Object *base, *win; + + if (!ug ) return; + + base = ug_get_layout(ug); + if (!base) + { + ug_destroy(ug); + return; + } + + win = ug_get_window(); + + switch (mode) + { + case UG_MODE_FULLVIEW: + MSG_IMAGEVIEW_HIGH("Creating UG layout"); + evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, base); + evas_object_show(base); + break; + default: + MSG_IMAGEVIEW_ERROR("Unhandled Mode : %d", mode); + break; + } +} + + +static void +_ivug_ext_ug_result_cb(ui_gadget_h ug, service_h result, void *priv) +{ + if (!ug ) return; + + if (result) + { + print_service_data(result); + } + + ext_ug_t *ug_struct = (ext_ug_t *)priv; + + if(ug_struct->result_func) + ug_struct->result_func(ug, result, ug_struct->cb_data); +} + + +static void +_ivug_ext_ug_destroy_cb(ui_gadget_h ug, void *priv) +{ + if (!ug ) return; + + ext_ug_t *ug_struct = (ext_ug_t *)priv; + + MSG_IMAGEVIEW_HIGH("Destroy ug"); + ug_destroy(ug); + + ug_struct->destroy_func(ug, ug_struct->cb_data); + + free(ug_struct); +} + +ui_gadget_h _ivug_ext_launch_ug(const char *pkgname, service_h service, ug_destroy_cb func, void *data) +{ + ui_gadget_h ug = NULL; + struct ug_cbs cbs = {0, }; + + ext_ug_t *ug_struct = calloc(1, sizeof(ug_struct)); + ug_struct->result_func = NULL; + ug_struct->destroy_func = func; + ug_struct->cb_data = data; + + cbs.layout_cb = _ivug_ext_ug_layout_cb; + cbs.result_cb = _ivug_ext_ug_result_cb; + cbs.destroy_cb = _ivug_ext_ug_destroy_cb; + cbs.priv = ug_struct; + + ug = ug_create( NULL, pkgname, UG_MODE_FULLVIEW, service, &cbs ); + + return ug; +} + +ui_gadget_h _ivug_ext_launch_ug_with_result(const char *pkgname, + service_h service, ug_result_cb result_func, ug_destroy_cb destroy_func, void *data) +{ + ui_gadget_h ug = NULL; + struct ug_cbs cbs = {0, }; + + ext_ug_t *ug_struct = calloc(1, sizeof(ug_struct)); + ug_struct->result_func = result_func; + ug_struct->destroy_func = destroy_func; + ug_struct->cb_data = data; + + cbs.layout_cb = _ivug_ext_ug_layout_cb; + cbs.result_cb = _ivug_ext_ug_result_cb; + cbs.destroy_cb = _ivug_ext_ug_destroy_cb; + cbs.priv = ug_struct; + + ug = ug_create( NULL, pkgname, UG_MODE_FULLVIEW, service, &cbs ); + + return ug; +} + + +void ivug_ext_service_reply_cb(service_h request, service_h reply, service_result_e result, void *user_data) +{ + MSG_IMAGEVIEW_HIGH("ivug_ext_service_reply_cb"); + switch(result) + { + case SERVICE_RESULT_SUCCEEDED: + MSG_IMAGEVIEW_HIGH("SERVICE_RESULT_SUCCEEDED"); + break; + case SERVICE_RESULT_FAILED: + MSG_IMAGEVIEW_HIGH("SERVICE_RESULT_FAILED"); + break; + case SERVICE_RESULT_CANCELED: + MSG_IMAGEVIEW_HIGH("SERVICE_RESULT_CANCELED"); + break; + default: + MSG_IMAGEVIEW_ERROR("unhandled value %d", result); + break; + } +}
+ + +ui_gadget_h ivug_ext_launch_contact(const char *uri, ug_destroy_cb func, void *data) +{ + MSG_IMAGEVIEW_HIGH("%s. URI=%s", __func__, uri); + + int ret = -1; + + service_h handle; + ui_gadget_h ug = NULL; + + ret = service_create(&handle); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_create failed, %d", ret); + return NULL; + } + + /*ret = service_set_operation(handle, SERVICE_OPERATION_VIEW); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_operation failed, %d", ret); + goto MESSAGE_END; + }*/ + + ret = service_set_uri (handle, uri); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_uri failed, %d", ret); + goto CONTACT_END; + } + + ret = service_add_extra_data(handle, "type", "41"); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_add_extra_data failed, %d", ret); + goto CONTACT_END; + } + + ret = service_add_extra_data(handle, "ct_path", uri); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_add_extra_data failed, %d", ret); + goto CONTACT_END; + } + + /*const char *pkgname = CONTACT_UG_NAME; + + ret = service_set_package(handle, pkgname); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_uri failed, %d", ret); + goto CONTACT_END; + }*/ + + ug = _ivug_ext_launch_ug(CONTACT_UG_NAME, handle, func, data); + +CONTACT_END: + if(service_destroy(handle) != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_destroy failed, %d", ret); + return NULL; + } + + return (ret == SERVICE_ERROR_NONE ? ug : NULL); +} +
+bool ivug_ext_launch_videoplayer(const char *uri) +{ + MSG_IMAGEVIEW_HIGH("%s. URI=%s", __func__, uri); + + int ret = -1; + + service_h handle; + + ret = service_create(&handle); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_create failed, %d", ret); + return false; + } + + ret = service_set_operation(handle, SERVICE_OPERATION_VIEW); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_operation failed, %d", ret); + goto VIDEO_PLAYER_END; + } + + ret = service_set_uri (handle, uri); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_uri failed, %d", ret); + goto VIDEO_PLAYER_END; + } + + ret = service_add_extra_data(handle, "path", uri); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_add_extra_data failed, %d", ret); + goto VIDEO_PLAYER_END; + } + + ret = service_add_extra_data(handle, "launching_application", "image_viewer"); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_add_extra_data failed, %d", ret); + goto VIDEO_PLAYER_END; + } + + const char *pkgname = VIDEOPLAYER_PKG_NAME; + + ret = service_set_package(handle, pkgname); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_uri failed, %d", ret); + goto VIDEO_PLAYER_END; + } + + ret = service_send_launch_request(handle, ivug_ext_service_reply_cb, NULL); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_send_launch_request failed, %d", ret); + goto VIDEO_PLAYER_END; + } + +VIDEO_PLAYER_END: + if(service_destroy(handle) != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_destroy failed, %d", ret); + return false; + } + + return (ret == SERVICE_ERROR_NONE ? true : false); +} + +bool ivug_ext_launch_videoplayer_simple(const char *uri) +{ + MSG_IMAGEVIEW_HIGH("%s. URI=%s", __func__, uri); + + int ret = -1; + + service_h handle; + + ret = service_create(&handle); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_create failed, %d", ret); + return false; + } + + ret = service_set_operation(handle, SERVICE_OPERATION_VIEW); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_operation failed, %d", ret); + goto VIDEO_PLAYER_SIMPLE_END; + } + + ret = service_set_uri (handle, uri); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_uri failed, %d", ret); + goto VIDEO_PLAYER_SIMPLE_END; + } + + ret = service_add_extra_data(handle, "path", uri); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_add_extra_data failed, %d", ret); + goto VIDEO_PLAYER_SIMPLE_END; + } + + // Camera -> Image Viewer -> Video player, In this case, launching_application bundle's value should be "light_play_view" + ret = service_add_extra_data(handle, "launching_application", "light_play_view"); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_add_extra_data failed, %d", ret); + goto VIDEO_PLAYER_SIMPLE_END; + } + + const char *pkgname = VIDEOPLAYER_PKG_NAME; + + ret = service_set_package(handle, pkgname); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_uri failed, %d", ret); + goto VIDEO_PLAYER_SIMPLE_END; + } + + ret = service_send_launch_request(handle, ivug_ext_service_reply_cb, NULL); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_send_launch_request failed, %d", ret); + goto VIDEO_PLAYER_SIMPLE_END; + } + +VIDEO_PLAYER_SIMPLE_END: + if(service_destroy(handle) != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_destroy failed, %d", ret); + return false; + } + + return (ret == SERVICE_ERROR_NONE ? true : false); +} +
+
+ +bool ivug_ext_launch_browser(const char *uri) +{ + MSG_IMAGEVIEW_HIGH("%s. URI=%s", __func__, uri); + + int ret = -1; + + service_h handle; + + ret = service_create(&handle); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_create failed, %d", ret); + return false; + } + + ret = service_set_operation(handle, SERVICE_OPERATION_VIEW); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_operation failed, %d", ret); + goto BROWSER_END; + } + + ret = service_add_extra_data(handle, "url", uri); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_add_extra_data failed, %d", ret); + goto BROWSER_END; + } + + const char *pkgname = BROWSER_PKG_NAME; + + ret = service_set_package(handle, pkgname); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_uri failed, %d", ret); + goto BROWSER_END; + } + + ret = service_send_launch_request(handle, ivug_ext_service_reply_cb, NULL); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_send_launch_request failed, %d", ret); + goto BROWSER_END; + } + +BROWSER_END: + if(service_destroy(handle) != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_destroy failed, %d", ret); + return false; + } + + return (ret == SERVICE_ERROR_NONE ? true : false); +} + +
+ +bool ivug_ext_launch_default(const char *uri, const char *operation, const char *pkg, void *data) +{ + MSG_IMAGEVIEW_HIGH("%s.", __func__); + + int ret = -1; + int destroy_ret = -1; + + service_h handle; + + ret = service_create(&handle); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_create failed, %d", ret); + return NULL; + } + + ret = service_set_operation(handle, operation); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_operation %s failed, %d", operation, ret); + goto LAUNCH_END; + } + + ret = service_set_uri (handle, uri); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_uri %s failed, %d", uri, ret); + goto LAUNCH_END; + } + + ret = service_set_package(handle, pkg); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_set_package %s failed, %d", pkg, ret); + goto LAUNCH_END; + } + + ret = service_send_launch_request(handle, ivug_ext_service_reply_cb, NULL); + if(ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_send_launch_request failed, %d", ret); + goto LAUNCH_END; + } + +LAUNCH_END: + destroy_ret = service_destroy(handle); + if(destroy_ret != SERVICE_ERROR_NONE) + { + MSG_IMAGEVIEW_ERROR("service_destroy failed, %d", destroy_ret); + return NULL; + } + + return (ret == SERVICE_ERROR_NONE ? true : false); +} + |