tizen 2.3 release
[apps/home/settings.git] / setting-security / src / setting-security-mmc-encryption.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-common-data-type.h>
22 #include <setting-common-data-slp-setting.h>
23 #include <setting-common-draw-widget.h>
24
25 #include <setting-security-mmc-encryption.h>
26 #include <setting-debug.h>
27
28 static int setting_security_mmc_encryption_create(void *cb);
29 static int setting_security_mmc_encryption_destroy(void *cb);
30 static int setting_security_mmc_encryption_update(void *cb);
31 static int setting_security_mmc_encryption_cleanup(void *cb);
32
33 setting_view setting_view_security_mmc_encryption = {
34         .create = setting_security_mmc_encryption_create,
35         .destroy = setting_security_mmc_encryption_destroy,
36         .update = setting_security_mmc_encryption_update,
37         .cleanup = setting_security_mmc_encryption_cleanup,
38 };
39
40 /* ***************************************************
41  **
42  **basic func
43  **
44  ****************************************************/
45
46 static void __enc_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
47 {
48         SETTING_TRACE_BEGIN;
49         ret_if(data == NULL);
50
51         SettingSecurityUG *ad = (SettingSecurityUG*)data;
52
53 }
54
55 static int setting_security_mmc_encryption_create(void *cb)
56 {
57         SETTING_TRACE_BEGIN;
58         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
59
60         SettingSecurityUG *ad = (SettingSecurityUG *) cb;
61
62         Elm_Object_Item *item = NULL;
63         int is_top_view = 0;
64
65         /* add basic layout */
66         char setBtnStr[MAX_DISPLAY_NAME_LEN_ON_UI];
67         snprintf(setBtnStr, sizeof(setBtnStr), "%s",
68                  (char *)dgettext("sys_string", "IDS_COM_BODY_BACK"));
69
70         if(setting_view_get_topview(&setting_view_security_mmc_encryption) == NULL)
71         {
72                 is_top_view = 1;
73         }
74
75         if(is_top_view)
76         {
77                 ad->ly_main = setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get, _("IDS_DN_BODY_ENCRYPT_SD_CARD"),
78                                                         setBtnStr, NULL, NULL,
79                                                         setting_security_mmc_encryption_click_softkey_back_cb,
80                                                         NULL, NULL,
81                                                         ad, NULL,
82                                                         &(ad->navi_bar), NULL);
83         }
84         else
85         {
86                         setting_push_layout_navi_bar(_("IDS_DN_BODY_ENCRYPT_SD_CARD"),
87                                                                                         setBtnStr, NULL, NULL,
88                                                                                         setting_security_mmc_encryption_click_softkey_back_cb,
89                                                                                         NULL, NULL,
90                                                                                         ad, NULL,
91                                                                                         ad->navi_bar, NULL);
92         }
93
94         /* 1. Radio : Encrypt new files
95                                         sub1                    */
96
97         /* 2. Radio : Encrypt all
98                                         sub2                    */
99
100
101         /* 3. Check : Exclude multimedia files */
102
103         /* 4. Help text */
104
105         setting_view_security_mmc_encryption.is_create = 1;
106
107         return SETTING_RETURN_SUCCESS;
108
109 }
110
111 static int setting_security_mmc_encryption_destroy(void *cb)
112 {
113         /* error check */
114         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
115
116         SettingSecurityUG *ad = (SettingSecurityUG *) cb;
117
118         if(setting_view_get_topview(&setting_view_security_mmc_encryption) == NULL)
119         {
120                 if (ad->ly_main != NULL)
121                 {
122                         evas_object_del(ad->ly_main);
123                         ad->ly_main = NULL;
124                 }
125         }
126         else
127         {
128                 elm_naviframe_item_pop(ad->navi_bar);
129         }
130
131         setting_view_security_mmc_encryption.is_create = 0;
132
133         return SETTING_RETURN_SUCCESS;
134 }
135
136 static int setting_security_mmc_encryption_update(void *cb)
137 {
138         SETTING_TRACE_BEGIN;
139         /* error check */
140
141         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
142
143         return SETTING_RETURN_SUCCESS;
144 }
145
146 static int setting_security_mmc_encryption_cleanup(void *cb)
147 {
148         /* error check */
149         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
150
151         setting_security_mmc_encryption_destroy(cb);
152
153         return SETTING_RETURN_SUCCESS;
154 }
155
156 /* ***************************************************
157  **
158  **call back func
159  **
160  ****************************************************/
161 static void
162 setting_security_mmc_encryption_click_softkey_back_cb(void *data, Evas_Object *obj,
163                                             void *event_info)
164 {
165         /* error check */
166         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
167
168         SettingSecurityUG *ad = (SettingSecurityUG *) data;
169
170         if(setting_view_get_topview(&setting_view_security_mmc_encryption) == NULL)
171         {
172                 ug_destroy_me(ad->ug);
173         }
174         else
175         {
176                 setting_view_change(&setting_view_security_mmc_encryption, &setting_view_security_main, ad);
177         }
178 }