4 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
25 #include "indicator.h"
31 #define ICON_PRIORITY INDICATOR_PRIORITY_NOTI_1
32 #define MODULE_NAME "downloading"
33 #define TIMER_INTERVAL 0.3
36 static int register_downloading_module(void *data);
37 static int unregister_downloading_module(void);
38 static int wake_up_cb(void *data);
40 icon_s downloading = {
41 .type = INDICATOR_IMG_ICON,
43 .priority = ICON_PRIORITY,
44 .always_top = EINA_FALSE,
45 .exist_in_view = EINA_FALSE,
47 .obj_exist = EINA_FALSE,
48 .area = INDICATOR_ICON_AREA_NOTI,
49 .init = register_downloading_module,
50 .fini = unregister_downloading_module,
54 static const char *icon_path[] = {
55 "Processing/B03_Processing_download_ani_00.png",
56 "Processing/B03_Processing_download_ani_01.png",
57 "Processing/B03_Processing_download_ani_02.png",
58 "Processing/B03_Processing_download_ani_03.png",
59 "Processing/B03_Processing_download_ani_04.png",
60 "Processing/B03_Processing_download_ani_05.png",
61 "Processing/B03_Processing_download_ani_06.png",
65 static Ecore_Timer *timer;
66 static int icon_index = 0;
67 static int updated_while_lcd_off = 0;
69 static void set_app_state(void* data)
71 downloading.ad = data;
74 static void show_image_icon(void* data, int index)
76 downloading.img_obj.data = icon_path[index];
77 icon_show(&downloading);
80 static void hide_image_icon(void)
82 icon_hide(&downloading);
85 static Eina_Bool show_downloading_icon_cb(void* data)
88 show_image_icon(data,icon_index);
90 icon_index = (icon_index % ICON_NUM) ? icon_index : 0;
92 return ECORE_CALLBACK_RENEW;
95 static void show_downloading_icon(void* data)
99 timer = ecore_timer_add(TIMER_INTERVAL, show_downloading_icon_cb, data);
103 _E("show_downloading_icon!, timer");
107 static void hide_downloading_icon(void)
110 ecore_timer_del(timer);
119 static void indicator_downloading_change_cb(keynode_t *node, void *data)
123 retm_if(data == NULL, "Invalid parameter!");
125 if(icon_get_update_flag()==0)
127 updated_while_lcd_off = 1;
130 updated_while_lcd_off = 0;
132 vconf_get_int(VCONFKEY_WIFI_DIRECT_RECEIVING_STATE, &status);
135 show_downloading_icon(data);
137 hide_downloading_icon();
140 static void indicator_downloading_pm_state_change_cb(keynode_t *node, void *data)
144 retm_if(data == NULL, "Invalid parameter!");
146 if (vconf_get_int(VCONFKEY_PM_STATE, &status) < 0)
148 _E("Error getting VCONFKEY_PM_STATE value");
152 ecore_timer_del(timer);
159 if(status == VCONFKEY_PM_STATE_LCDOFF)
162 ecore_timer_del(timer);
168 static int wake_up_cb(void *data)
170 if(updated_while_lcd_off == 0 && downloading.obj_exist == EINA_FALSE)
175 indicator_downloading_change_cb(NULL, data);
179 static int register_downloading_module(void *data)
183 retvm_if(data == NULL, FAIL, "Invalid parameter!");
187 ret = ret | vconf_notify_key_changed(VCONFKEY_WIFI_DIRECT_RECEIVING_STATE, indicator_downloading_change_cb, data);
189 ret = ret | vconf_notify_key_changed(VCONFKEY_PM_STATE,
190 indicator_downloading_pm_state_change_cb, data);
192 indicator_downloading_change_cb(NULL, data);
197 static int unregister_downloading_module(void)
201 ret = ret | vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_RECEIVING_STATE, indicator_downloading_change_cb);
203 ret = ret | vconf_ignore_key_changed(VCONFKEY_PM_STATE,
204 indicator_downloading_pm_state_change_cb);