97dd7265a2b51f8d1825039419b921d52faeec45
[apps/home/settings.git] / setting-phone / src / setting-phone-license-divx-main.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 #include <setting-phone-license-divx-main.h>
22
23 static int setting_phone_license_divx_main_create(void *cb);
24 static int setting_phone_license_divx_main_destroy(void *cb);
25 static int setting_phone_license_divx_main_update(void *cb);
26 static int setting_phone_license_divx_main_cleanup(void *cb);
27
28 setting_view setting_view_phone_license_divx_main = {
29         .create = setting_phone_license_divx_main_create,
30         .destroy = setting_phone_license_divx_main_destroy,
31         .update = setting_phone_license_divx_main_update,
32         .cleanup = setting_phone_license_divx_main_cleanup,
33 };
34
35 /* ***************************************************
36  *
37  *basic func
38  *
39  ***************************************************/
40
41 static int setting_phone_license_divx_main_create(void *cb)
42 {
43         SETTING_TRACE_BEGIN;
44         /* error check */
45         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
46
47         SettingPhoneUG *ad = (SettingPhoneUG *) cb;
48
49         Evas_Object *scroller;
50         /* scroller is a genlist */
51         setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get,
52                                              _("IDS_ST_HEADER_DIVX_VOD"),
53                                              dgettext("sys_string",
54                                                       "IDS_COM_BODY_BACK"),
55                                              NULL,
56                                              setting_phone_license_divx_main_click_softkey_back_cb,
57                                              NULL, ad, &scroller, ad->navi_bar);
58
59         Elm_Object_Item *item = NULL;;
60
61         item =
62             elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
63                                     ELM_GENLIST_ITEM_NONE, NULL, NULL);
64         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
65
66         ad->data_reg =
67             setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
68                                              setting_phone_license_divx_main_mouse_up_Gendial_list_cb,
69                                              ad, SWALLOW_Type_INVALID, NULL,
70                                              NULL, 0,
71                                              "IDS_ST_MBODY_REGISTER",
72                                              NULL, NULL);
73
74         ad->data_dereg =
75             setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
76                                              setting_phone_license_divx_main_mouse_up_Gendial_list_cb,
77                                              ad, SWALLOW_Type_INVALID, NULL,
78                                              NULL, 0,
79                                              "IDS_ST_MBODY_DEREGISTER",
80                                              NULL, NULL);
81         int result;
82         drm_bool_type_e is_first = 0;
83         result = drm_is_action_allowed(DRM_IS_DEVICE_ACTIVATED, NULL, &is_first);
84         SETTING_TRACE_DEBUG("%s*** drm status - result=%d, is_first=%d ***%s",
85                             SETTING_FONT_BGREEN, (int)result, is_first,
86                             SETTING_FONT_BLACK);
87         if (!result) {
88                 if (is_first) { /* disable de-reg */
89                         if (ad->data_dereg) {
90                                 elm_object_item_disabled_set(ad->data_dereg->item,
91                                                               EINA_TRUE);
92                         } else {
93                                 SETTING_TRACE_ERROR("ad->data_dereg is NULL");
94                         }
95                 }
96         } else {                /* disable reg */
97                 if (ad->data_reg) {
98                         elm_object_item_disabled_set(ad->data_reg->item,
99                                                       EINA_TRUE);
100                 } else {
101                         SETTING_TRACE_ERROR("ad->data_reg is NULL");
102                 }
103         }
104
105         setting_view_phone_license_divx_main.is_create = 1;
106         return SETTING_RETURN_SUCCESS;
107 }
108
109 static int setting_phone_license_divx_main_destroy(void *cb)
110 {
111
112         /* error check */
113         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
114
115         SettingPhoneUG *ad = (SettingPhoneUG *) cb;
116
117         elm_naviframe_item_pop(ad->navi_bar);
118         setting_view_phone_license_divx_main.is_create = 0;
119
120         return SETTING_RETURN_SUCCESS;
121 }
122
123 static int setting_phone_license_divx_main_update(void *cb)
124 {
125         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
126
127         SettingPhoneUG *ad = (SettingPhoneUG *) cb;
128
129         if(ad->mode == SETTING_DIVX_MODE_REG)
130         {
131                 setting_disable_genlist_item(ad->data_reg->item);
132                 setting_enable_genlist_item(ad->data_dereg->item);
133         }
134         else if(ad->mode == SETTING_DIVX_MODE_DEREG)
135         {
136                 setting_enable_genlist_item(ad->data_reg->item);
137                 setting_disable_genlist_item(ad->data_dereg->item);
138         }
139
140         return SETTING_RETURN_SUCCESS;
141 }
142
143 static int setting_phone_license_divx_main_cleanup(void *cb)
144 {
145         return setting_phone_license_divx_main_destroy(cb);
146 }
147
148 /* ***************************************************
149  *
150  *general func
151  *
152  ***************************************************/
153
154 static void setting_phone_license_ask_deregistration_resp_cb(void *data,
155                                                              Evas_Object *obj,
156                                                              void *event_info)
157 {
158         int response_type = btn_type(obj);
159         if (POPUP_RESPONSE_OK == response_type) {
160                 setting_phone_license_divx_main_click_popup_dereg_cb(data);
161         } else if (POPUP_RESPONSE_CANCEL == response_type) {
162                 setting_phone_license_divx_main_click_popup_cancel_cb(data);
163         }
164 }
165
166 static Evas_Object *setting_phone_license_divx_main_create_dereg_popup(void
167                                                                        *data)
168 {
169         /* error check */
170         retvm_if(data == NULL, NULL,
171                  "[Setting > About] Data parameter is NULL");
172
173         SettingPhoneUG *ad = (SettingPhoneUG *) data;
174
175         Evas_Object *notify;
176         notify =
177             setting_create_popup_with_btn(ad, ad->win_get, NULL,
178                                  _(ASK_DEREG_PHONE),
179                                  setting_phone_license_ask_deregistration_resp_cb,
180                                  0, 2, _("IDS_COM_SK_OK"),_("IDS_COM_SK_CANCEL"));
181
182         return notify;
183 }
184
185 /* ***************************************************
186  *
187  *call back func
188  *
189  ***************************************************/
190
191 static void
192 setting_phone_license_divx_main_click_softkey_back_cb(void *data,
193                                                       Evas_Object *obj,
194                                                       void *event_info)
195 {
196         SETTING_TRACE_BEGIN;
197         /* error check */
198         setting_retm_if(data == NULL, "Data parameter is NULL");
199
200         SettingPhoneUG *ad = (SettingPhoneUG *) data;
201
202         setting_view_change(&setting_view_phone_license_divx_main, &setting_view_phone_license_main, ad);
203 }
204
205 static void
206 setting_phone_license_divx_main_mouse_up_Gendial_list_cb(void *data,
207                                                          Evas_Object *obj,
208                                                          void *event_info)
209 {
210         /* error check */
211         setting_retm_if(data == NULL, "Data parameter is NULL");
212
213         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
214         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
215         elm_genlist_item_selected_set(item, 0);
216         Setting_GenGroupItem_Data *list_item =
217             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
218
219         SettingPhoneUG *ad = (SettingPhoneUG *) data;
220
221         SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
222         if (!safeStrCmp("IDS_ST_MBODY_REGISTER", list_item->keyStr)) {
223                 ad->mode = SETTING_DIVX_MODE_REG;
224                 setting_view_change(&setting_view_phone_license_divx_main,
225                                     &setting_view_phone_license_divx_mode, ad);
226         } else
227             if (!safeStrCmp
228                 ("IDS_ST_MBODY_DEREGISTER", list_item->keyStr)) {
229                 ad->pop_dereg =
230                     setting_phone_license_divx_main_create_dereg_popup(ad);
231         }
232 }
233
234 static void setting_phone_license_divx_main_click_popup_dereg_cb(void *data)
235 {
236         /* error check */
237         setting_retm_if(data == NULL, "Data parameter is NULL");
238
239         SettingPhoneUG *ad = (SettingPhoneUG *) data;
240
241         if (ad->pop_dereg) {
242                 evas_object_del(ad->pop_dereg);
243                 ad->pop_dereg = NULL;
244         }
245
246         ad->mode = SETTING_DIVX_MODE_DEREG;
247         setting_view_change(&setting_view_phone_license_divx_main,
248                             &setting_view_phone_license_divx_mode, ad);
249 }
250
251 static void setting_phone_license_divx_main_click_popup_cancel_cb(void *data)
252 {
253         /* error check */
254         setting_retm_if(data == NULL, "Data parameter is NULL");
255
256         SettingPhoneUG *ad = (SettingPhoneUG *) data;
257
258         if (ad->pop_dereg) {
259                 evas_object_del(ad->pop_dereg);
260                 ad->pop_dereg = NULL;
261         }
262 }