tizen 2.3.1 release
[framework/security/cert-svc-ui.git] / view / src / certificates / trusted_root_ca_cert / trusted_root_ca_cert.c
1 /**
2  * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @file        trusted_root_ca_cert.c
18  * @author      Janusz Kozerski (j.kozerski@samsung.com)
19  * @version     1.0
20  * @brief
21  */
22
23 #include <dlog.h>
24
25 #include "certificates/certificate_util.h"
26 #include "certificates/certificates.h"
27
28 #include <dirent.h>
29
30 static Eina_Bool trusted_root_cert_create_genlist(struct ug_data *ad, Evas_Object *parent)
31 {
32         int index;
33         if (!ad)
34                 return EINA_TRUE;
35         ad->list_to_refresh = elm_genlist_add(parent);
36         evas_object_size_hint_weight_set(ad->list_to_refresh, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
37         evas_object_size_hint_align_set(ad->list_to_refresh, EVAS_HINT_FILL, EVAS_HINT_FILL);
38
39         Eina_Bool no_content_bool = EINA_TRUE;
40         if(!make_list(ad, ad->list_to_refresh, PATH_CERT_TRUSTEDUSER, ad->list_element)){
41                 no_content_bool = EINA_FALSE;
42         }
43         ad->list_element = findLastElement(ad->list_element);
44         if(!make_list(ad, ad->list_to_refresh, PATH_CERT_SSL_ETC, ad->list_element)){
45                 no_content_bool = EINA_FALSE;
46         }
47         return no_content_bool;
48 }
49
50 void trusted_root_cert_cb(void *data, Evas_Object *obj, void *event_info)
51 {
52         LOGD("trusted_root_cert_cb()");
53
54         if (!data)
55                 return;
56         struct ug_data *ad = (struct ug_data *) data;
57         struct ListElement *firstListElement = NULL;
58         struct ListElement *lastListElement  = NULL;
59         firstListElement = initList();
60
61         if (!firstListElement) {
62                 LOGD("Fail to initList for firstListElement");
63                 return;
64         }
65
66         lastListElement  = firstListElement;
67         ad->list_element = firstListElement;
68
69         Elm_Object_Item *nf_it;
70         Evas_Object *box = NULL;
71         Evas_Object *genlist = NULL;
72         box = elm_box_add(ad->navi_bar);
73         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74         evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
75
76         Eina_Bool no_content_bool = trusted_root_cert_create_genlist(ad, box);
77         evas_object_show(ad->list_to_refresh);
78         elm_box_pack_end(box, ad->list_to_refresh);
79         evas_object_show(box);
80
81         if (!no_content_bool) { // There is some content
82                 nf_it = elm_naviframe_item_push(ad->navi_bar, "IDS_ST_BODY_TRUSTED_ROOT_CA_CERTIFICATES_ABB", NULL, NULL, box, NULL);
83         } else {
84                 // No content
85                 Evas_Object *no_content = create_no_content_layout(ad);
86                 if(!no_content){
87                         LOGD("Cannot create no_content layout (NULL); return");
88                         return;
89                 }
90
91                 nf_it = elm_naviframe_item_push(ad->navi_bar, "IDS_ST_BODY_TRUSTED_ROOT_CA_CERTIFICATES_ABB", NULL, NULL, no_content, NULL);
92         }
93         elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
94         elm_naviframe_item_pop_cb_set(nf_it, back_cb, (struct Evas_Object *)ad);
95 }