summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorHyerim Kim <rimi.kim@samsung.com>2017-09-05 21:13:14 +0900
committerHyerim Kim <rimi.kim@samsung.com>2017-09-06 16:24:08 +0900
commitb6609f50613e23d1882331fa5911adca5836b7f9 (patch)
treecf3632c7140369494fd8c831bb745f45b180d714 /src/util.c
parentf0e37edfb011436627c84eef75af65014a57ad6d (diff)
downloadair_livetv-b6609f50613e23d1882331fa5911adca5836b7f9.tar.gz
air_livetv-b6609f50613e23d1882331fa5911adca5836b7f9.tar.bz2
air_livetv-b6609f50613e23d1882331fa5911adca5836b7f9.zip
Modifies Live-tv application for displaying background image on Hometizen_8.0_m2_releasetizen_7.0_m2_releasetizen_6.5.m2_releasetizen_6.0.m2_releasetizen_5.5.m2_releasetizen_4.0.m2_releasetizen_4.0.IoT.p2_releasetizen_4.0.IoT.p1_releasesubmit/tizen_6.5/20211029.140001submit/tizen_6.5/20211028.164001submit/tizen_6.0_hotfix/20201103.115105submit/tizen_6.0_hotfix/20201102.192905submit/tizen_6.0/20201029.205505submit/tizen_5.5_wearable_hotfix/20201026.184309submit/tizen_5.5_mobile_hotfix/20201026.185109submit/tizen_5.5/20191031.000013submit/tizen_5.5/20191031.000011submit/tizen_5.5/20191031.000009submit/tizen_5.0/20181106.000001submit/tizen_5.0/20181101.000009submit/tizen_4.0/20170907.043947submit/tizen/20170906.103347accepted/tizen/unified/20170911.155614accepted/tizen/8.0/unified/20231005.100105accepted/tizen/7.0/unified/hotfix/20221116.112006accepted/tizen/7.0/unified/20221110.061740accepted/tizen/6.0/unified/hotfix/20201103.044959accepted/tizen/6.0/unified/20201030.103300accepted/tizen/5.5/unified/wearable/hotfix/20201027.095200accepted/tizen/5.5/unified/mobile/hotfix/20201027.071204accepted/tizen/5.5/unified/20191031.034729accepted/tizen/5.0/unified/20181106.202933accepted/tizen/4.0/unified/20170911.154210tizen_8.0tizen_7.0_hotfixtizen_7.0tizen_6.5tizen_6.0_hotfixtizen_6.0tizen_5.5_wearable_hotfixtizen_5.5_tvtizen_5.5_mobile_hotfixtizen_5.5tizen_5.0tizen_4.0tizenaccepted/tizen_unifiedaccepted/tizen_8.0_unifiedaccepted/tizen_7.0_unified_hotfixaccepted/tizen_7.0_unifiedaccepted/tizen_6.0_unified_hotfixaccepted/tizen_6.0_unifiedaccepted/tizen_5.5_unified_wearable_hotfixaccepted/tizen_5.5_unified_mobile_hotfixaccepted/tizen_5.5_unifiedaccepted/tizen_5.0_unifiedaccepted/tizen_4.0_unified
Change-Id: I4081ad312fd6e77169e55d33a3c9a3755ec8770e Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c414
1 files changed, 0 insertions, 414 deletions
diff --git a/src/util.c b/src/util.c
deleted file mode 100644
index b1a0711..0000000
--- a/src/util.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
- *
- * 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 <app.h>
-#include <Elementary.h>
-#include <app_debug.h>
-#include <app_define.h>
-#include <viewmgr.h>
-
-#include "define.h"
-#include "view.h"
-
-#define BUF_MAX 128
-#define TOAST_TIMEOUT 5.0
-#define STYLE_TOAST "toast"
-
-Evas_Object *util_add_layout(Evas_Object *parent, const char *group)
-{
- Evas_Object *ly;
-
- if (!parent) {
- _ERR("failed to get parent");
- return NULL;
- }
-
- ly = elm_layout_add(parent);
- if (!ly) {
- _ERR("failed to create layout");
- return NULL;
- }
- elm_layout_file_set(ly, EDJEFILE, group);
-
- evas_object_show(ly);
-
- return ly;
-}
-
-Evas_Object *util_add_box(Evas_Object *parent, bool horizon)
-{
- Evas_Object *box;
-
- if (!parent) {
- _ERR("failed to get parent");
- return NULL;
- }
-
- box = elm_box_add(parent);
- if (!box) {
- _ERR("failed to create box");
- return NULL;
- }
-
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_object_content_set(parent, box);
- if (horizon)
- elm_box_horizontal_set(box, EINA_TRUE);
- else
- elm_box_horizontal_set(box, EINA_FALSE);
-
- evas_object_show(box);
-
- return box;
-}
-
-Evas_Object *util_add_scroller(Evas_Object *parent, const char *part)
-{
- Evas_Object *scroll;
-
- if (!parent) {
- _ERR("failed to get parent");
- return NULL;
- }
-
- scroll = elm_scroller_add(parent);
- if (!scroll) {
- _ERR("failed to create scroll");
- return NULL;
- }
-
- evas_object_size_hint_weight_set(scroll, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_scroller_policy_set(scroll, ELM_SCROLLER_POLICY_OFF,
- ELM_SCROLLER_POLICY_OFF);
-
- elm_object_part_content_set(parent, part, scroll);
-
- evas_object_show(scroll);
-
- return scroll;
-}
-
-Evas_Object *util_add_icon(Evas_Object *parent, const char *file,
- const char *part)
-{
- Evas_Object *ic;
-
- if (!parent) {
- _ERR("failed to get parent");
- return NULL;
- }
-
- ic = elm_icon_add(parent);
- if (!ic) {
- _ERR("failed to create icon");
- return NULL;
- }
-
- if (file)
- elm_image_file_set(ic, file, NULL);
-
- if (part)
- elm_object_part_content_set(parent, part, ic);
-
- elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE);
-
- evas_object_show(ic);
-
- return ic;
-}
-
-Evas_Object *util_add_button(Evas_Object *parent, const char *part,
- const char *text, const char *style)
-{
- Evas_Object *btn;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- btn = elm_button_add(parent);
- if (!btn) {
- _ERR("elm_button_add failed.");
- return NULL;
- }
-
- if (part)
- elm_object_part_content_set(parent, part, btn);
- if (text)
- elm_object_text_set(btn, text);
- if (style)
- elm_object_style_set(btn, style);
-
- evas_object_show(btn);
-
- return btn;
-}
-
-static void _notify_timeout_cb(void *data, Evas_Object *obj, void *ei)
-{
- if (!obj)
- return;
-
- evas_object_del(obj);
-}
-
-Evas_Object *util_add_toast(Evas_Object *parent, char *text)
-{
- Evas_Object *toast, *content;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- toast = elm_notify_add(parent);
- if (!toast) {
- _ERR("elm_popup_add failed");
- return NULL;
- }
-
- elm_object_style_set(toast, STYLE_TOAST);
- elm_notify_align_set(toast, 0.0, 1.0);
- elm_notify_timeout_set(toast, TOAST_TIMEOUT);
- evas_object_smart_callback_add(toast, SIGNAL_TIMEOUT,
- _notify_timeout_cb, NULL);
-
- content = elm_label_add(toast);
- if (!content) {
- _ERR("elm_label_add failed");
- evas_object_del(toast);
- return NULL;
- }
-
- elm_object_text_set(content, text);
- elm_object_style_set(content, STYLE_TOAST);
- elm_object_content_set(toast, content);
- evas_object_show(content);
-
- evas_object_show(toast);
-
- return toast;
-}
-
-static int _get_program_time(char *buf, int buf_len, time_t start_time,
- time_t end_time)
-{
- struct tm tm;
- int r;
-
- if (start_time >= end_time) {
- _ERR("invalid time");
- return -1;
- }
-
- localtime_r(&start_time, &tm);
- r = strftime(buf, buf_len, "%I:%M %P -", &tm);
- if (r <= 0)
- return -1;
-
- localtime_r(&end_time, &tm);
- r = strftime(buf + r, buf_len - r, " %I:%M %P", &tm);
- if (r <= 0)
- return -1;
-
- return 0;
-}
-
-static void _set_icon_box(Evas_Object *obj,
- const struct tv_channel_info *channel_info)
-{
- elm_object_signal_emit(obj, SIGNAL_RESET, SOURCE_PROGRAM);
-
- if (channel_info->locked)
- elm_object_signal_emit(obj, SIGNAL_LOCKED, SOURCE_PROGRAM);
- if (channel_info->favorite)
- elm_object_signal_emit(obj, SIGNAL_FAVORITE, SOURCE_PROGRAM);
-}
-
-static void _load_channel_text(Evas_Object *obj,
- const struct tv_channel_info *channel_info)
-{
- char buf[BUF_MAX];
-
- if (channel_info->channel_minor > 0 &&
- channel_info->channel_minor < MINOR_MAX)
- snprintf(buf, sizeof(buf), "%lu-%lu %s",
- channel_info->channel_major,
- channel_info->channel_minor,
- channel_info->channel_name);
- else
- snprintf(buf, sizeof(buf), "%lu %s",
- channel_info->channel_major,
- channel_info->channel_name);
-
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_CHANNEL, buf);
-
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_TITLE,
- STR_NOTITLE);
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_TIME,
- STR_NOTIME);
-}
-
-static void _load_program_info(Evas_Object *obj,
- const struct tv_program_info *prog)
-{
- char buf[BUF_MAX];
- int r, service_id;
-
- service_id = (int) evas_object_data_get(obj, KEY_SVCID);
- if (service_id != prog->service_id)
- return;
-
- if (prog->start_time && prog->end_time) {
- r = _get_program_time(buf, sizeof(buf),
- prog->start_time,
- prog->end_time);
- if (!r)
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_TIME, buf);
- }
-
- if (strlen(prog->prog_title) > 0)
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_TITLE, prog->prog_title);
-}
-
-static void _tv_program_cb(Eina_List *prog_list, void *data)
-{
- int op;
- Evas_Object *obj;
- struct tv_program_info *prog = NULL;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
-
- obj = data;
-
- prog = (struct tv_program_info *) eina_list_nth(prog_list, 0);
- if (prog)
- _load_program_info(obj, prog);
- else
- _ERR("failed to get tv_program_info");
-
- if (viewmgr_get_view_state(VIEW_CHANNELINFO) == VIEW_STATE_VISIBLE) {
- op = START_HIDE_TIMER;
- viewmgr_update_view(VIEW_CHANNELINFO,
- UPDATE_TYPE_TIMER, &op);
- }
-}
-
-void util_draw_channel_info(Evas_Object *obj,
- const struct tv_channel_info *channel_info)
-{
- struct tv_program_request *prog_req;
- int r, op;
- int current_service;
-
- if (!obj || !channel_info) {
- _ERR("Invalid argument");
-
- return;
- }
-
- r = tv_get_current_service_id(&current_service);
- if (r < 0)
- current_service = -1;
-
- if (viewmgr_get_view_state(VIEW_CHANNELINFO) == VIEW_STATE_VISIBLE) {
- op = STOP_HIDE_TIMER;
- viewmgr_update_view(VIEW_CHANNELINFO,
- UPDATE_TYPE_TIMER, &op);
- }
-
- _load_channel_text(obj, channel_info);
- _set_icon_box(obj, channel_info);
- evas_object_data_set(obj, KEY_SVCID, (void *)channel_info->service_id);
-
- prog_req = calloc(1, sizeof(*prog_req));
- if (!prog_req)
- goto err;
- prog_req->tv_program_cb = _tv_program_cb;
- prog_req->user_data = obj;
-
- r = tv_epg_get_cache_program(channel_info->service_id,
- prog_req);
- if (r < 0)
- free(prog_req);
-
- if (channel_info->service_id == current_service) {
- prog_req = calloc(1, sizeof(*prog_req));
- if (!prog_req)
- goto err;
-
- prog_req->tv_program_cb = _tv_program_cb;
- prog_req->user_data = obj;
- r = tv_epg_get_program(channel_info->service_id, prog_req);
- if (r < 0)
- free(prog_req);
- }
-
-err:
- if (r < 0 && viewmgr_get_view_state(VIEW_CHANNELINFO) ==
- VIEW_STATE_VISIBLE) {
- op = START_HIDE_TIMER;
- viewmgr_update_view(VIEW_CHANNELINFO,
- UPDATE_TYPE_TIMER, &op);
- }
-}
-
-void util_launch_home(void)
-{
- app_control_h app_ctrl;
- int r;
-
- r = app_control_create(&app_ctrl);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to create app control handle");
- return;
- }
-
- r = app_control_set_operation(app_ctrl, APP_CONTROL_OPERATION_DEFAULT);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to set app control operation");
- app_control_destroy(app_ctrl);
- return;
- }
-
- r = app_control_set_app_id(app_ctrl, APP_ID_HOME);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to set app control app id");
- app_control_destroy(app_ctrl);
- return;
- }
-
- r = app_control_send_launch_request(app_ctrl, NULL, NULL);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to send app control launch request");
- app_control_destroy(app_ctrl);
- return;
- }
-
- app_control_destroy(app_ctrl);
-}
-