change partition
[apps/core/preloaded/settings.git] / setting-fileview / src / setting-fileview-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-fileview-main.h>
22
23 static int setting_fileview_create(void *cb);
24 static int setting_fileview_destroy(void *cb);
25 static int setting_fileview_update(void *cb);
26 static int setting_fileview_cleanup(void *cb);
27
28 setting_view setting_view_fileview_main = {
29         .create = setting_fileview_create,
30         .destroy = setting_fileview_destroy,
31         .update = setting_fileview_update,
32         .cleanup = setting_fileview_cleanup,
33 };
34
35 /* ***************************************************
36  *
37  *basic func
38  *
39  ***************************************************/
40 #if DISABLED_CODE
41 static Eina_Bool __web_on_idle(void *data)
42 {
43         SETTING_TRACE_BEGIN;
44         SettingFileviewUG *ad = (SettingFileviewUG *) data;
45         if (ad->progress_bar) {
46                 evas_object_del(ad->progress_bar);
47                 ad->progress_bar = NULL;
48         }
49         return FALSE;
50 }
51
52 static void __setting_fileview_policy_navigation_decide(void *data, Evas_Object *webview, void *event_info)
53 {
54         SETTING_TRACE_BEGIN;
55         setting_retm_if(data == NULL, "data is NULL");
56         setting_retm_if(event_info == NULL, "event_info is NULL");
57
58         SettingFileviewUG *ad = (SettingFileviewUG *)data;
59
60         Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info;
61         ewk_policy_decision_ignore(policy_decision);
62
63         char *url = (char *)ewk_policy_decision_url_get(policy_decision);
64         char *scheme = (char *)ewk_policy_decision_scheme_get(policy_decision);
65         SETTING_TRACE("url : %s", url);
66         SETTING_TRACE("scheme : %s", scheme);
67
68         int ret = 0;
69         service_h service = NULL;
70         ret = service_create(&service);
71         setting_retm_if(service == NULL, "service is NULL");
72
73         ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
74         ret = service_set_uri(service, url);
75         ret = service_send_launch_request(service, NULL, NULL);
76         ret = service_destroy(service);
77 }
78 #endif
79
80 static int setting_fileview_create(void *cb)
81 {
82         SETTING_TRACE_BEGIN;
83         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
84
85         SettingFileviewUG *ad = (SettingFileviewUG *) cb;
86
87         Evas_Object *scroller;
88         //ad->progress_bar = setting_create_popup_with_progressbar(ad, ad->win_get, "pending_list", NULL, NULL, NULL, 0, TRUE, TRUE);
89
90         ad->ly_main = setting_create_layout_navi_bar_scroller(ad->win_main_layout,
91                                         ad->win_get,
92                                         _(ad->input_title),//_("IDS_ST_BODY_OPEN_SOURCE_LICENCES"),
93                                         _("IDS_COM_BODY_BACK"),
94                                         NULL,
95                                         setting_fileview_click_back_cb,
96                                         NULL, ad, &scroller,
97                                         &(ad->navi_bar));
98
99         //Evas *evas = evas_object_evas_get(ad->win_get);
100         //Evas_Object *webview = ewk_view_add(evas);
101         //ad->webkit = webview;
102
103         SETTING_TRACE("ad->input_file:%s", ad->input_file);
104         //ewk_view_uri_set(ad->webkit, ad->input_file);
105
106         elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE);
107
108         //elm_object_content_set(scroller, ad->webkit);
109         //evas_object_show(ad->webkit);
110         //ecore_idler_add(__web_on_idle, ad);
111
112         //evas_object_smart_callback_add(ad->webkit, "policy,navigation,decide", __setting_fileview_policy_navigation_decide, ad);
113
114         setting_view_fileview_main.is_create = 1;
115
116         return SETTING_RETURN_SUCCESS;
117 }
118
119 static int setting_fileview_destroy(void *cb)
120 {
121         /* error check */
122         SETTING_TRACE_BEGIN;
123         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
124         SettingFileviewUG *ad = (SettingFileviewUG *) cb;
125         //evas_object_smart_callback_del(ad->webkit, "policy,navigation,decide", __setting_fileview_policy_navigation_decide);
126
127         //if (ad->webkit) {
128         //      evas_object_del(ad->webkit);
129         //      ad->webkit = NULL;
130         //}
131
132         if (ad->ly_main != NULL) {
133                 evas_object_del(ad->ly_main);
134                 ad->ly_main = NULL;
135                 setting_view_fileview_main.is_create = 0;
136         }
137
138         return SETTING_RETURN_SUCCESS;
139 }
140
141 static int setting_fileview_update(void *cb)
142 {
143         SETTING_TRACE_BEGIN;
144         SettingFileviewUG *ad = (SettingFileviewUG *) cb;
145
146         if (ad->ly_main != NULL) {
147                 evas_object_show(ad->ly_main);
148         }
149         return SETTING_RETURN_SUCCESS;
150
151 }
152
153 static int setting_fileview_cleanup(void *cb)
154 {
155         SETTING_TRACE_BEGIN;
156         SettingFileviewUG *ad = (SettingFileviewUG *) cb;
157
158         if (ad->ly_main != NULL) {
159                 evas_object_hide(ad->ly_main);
160         }
161         return SETTING_RETURN_SUCCESS;
162 }
163
164 /* ***************************************************
165  *
166  *call back func
167  *
168  ***************************************************/
169
170 static void
171 setting_fileview_click_back_cb(void *data, Evas_Object *obj,
172                                             void *event_info)
173 {
174         /* error check */
175         setting_retm_if(data == NULL, " Data parameter is NULL");
176
177         SettingFileviewUG *ad = (SettingFileviewUG *) data;
178         /* Send destroy request */
179         ug_destroy_me(ad->ug);
180         return;
181 }