a6962f0b5ac53728de7cb11dec382e34030beff3
[framework/security/cert-svc-ui.git] / view / src / certificates / user_cert / user_cert.c
1 /*
2  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * This file is part of the Manage Applications
5  * Written by Eunmi Son <eunmi.son@samsung.com>
6  *
7  * Author of this file:
8  * Janusz Kozerski <j.kozerski@samsung.com>
9  *
10  * PROPRIETARY/CONFIDENTIAL
11  *
12  * This software is the confidential and proprietary information of
13  * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
14  * disclose such Confidential Information and shall use it only in
15  * accordance with the terms of the license agreement you entered
16  * into with SAMSUNG ELECTRONICS.
17  *
18  * SAMSUNG make no representations or warranties about the suitability
19  * of the software, either express or implied, including but not limited
20  * to the implied warranties of merchantability, fitness for a particular
21  * purpose, or non-infringement. SAMSUNG shall not be liable for any
22  * damages suffered by licensee as a result of using, modifying or
23  * distributing this software or its derivatives.
24  *
25  */
26
27 #include "certificates/certificate_util.h"
28 #include "certificates/certificates.h"
29
30 #include <dirent.h>
31
32 static char *dir_path = PATH_CERT_USER;
33
34 static void install_button_cb(void *data, Evas_Object *obj, void *event_info);
35
36 void user_cert_cb(void *data, Evas_Object *obj, void *event_info) {
37         LOGD("user_cert_cb");
38
39         struct ug_data *ad = (struct ug_data *) data;
40         Evas_Object *list = NULL;
41
42         struct ListElement *firstListElement = NULL;
43         struct ListElement *lastListElement = NULL;
44         firstListElement = initList();
45         lastListElement = firstListElement;
46
47         Evas_Object *toolbar = elm_toolbar_add(ad->win_main);
48         if (!toolbar)
49                 return;
50         elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
51
52         elm_toolbar_item_append(toolbar, NULL, dgettext(PACKAGE, "INSTALL"), install_button_cb, ad);
53         elm_toolbar_item_append(toolbar, NULL, dgettext(PACKAGE, "UNINSTALL"), delete_cert_cb, strdup(dir_path));
54
55         list = elm_list_add(ad->win_main);
56         elm_list_mode_set(list, ELM_LIST_COMPRESS);
57
58         if (make_list(ad, list, dir_path, lastListElement, USER)) {
59                 Evas_Object *no_content = elm_layout_add(ad->win_main);
60                 elm_layout_theme_set(no_content, "layout", "nocontents", "text");
61                 elm_object_part_text_set(no_content, "elm.text", dgettext(PACKAGE, "IDS_COM_BODY_NO_CONTENTS"));
62                 evas_object_size_hint_weight_set(no_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63                 evas_object_show(no_content);
64
65                 Elm_Object_Item *itm = elm_naviframe_item_push(ad->navi_bar, dgettext(PACKAGE, "USER_CERTIFICATE"), NULL, NULL,
66                                 no_content, NULL);
67                 elm_object_item_part_content_set(itm, "controlbar", toolbar);
68         } else {
69
70                 Elm_Object_Item *itm = elm_naviframe_item_push(ad->navi_bar, dgettext(PACKAGE, "USER_CERTIFICATE"), NULL, NULL,
71                                 list, NULL);
72                 elm_object_item_part_content_set(itm, "controlbar", toolbar);
73
74                 Evas_Object *back = NULL;
75                 back = elm_object_item_part_content_get(itm, "prev_btn");
76                 evas_object_smart_callback_add(back, "clicked", back_cb, ad);
77         }
78 }
79
80 static void install_button_cb(void *data, Evas_Object *obj, void *event_info) {
81         struct ug_data *ad = (struct ug_data *) data;
82         char buf[BUF256];
83         strcpy(buf, dgettext(PACKAGE, "INSTALL_CERT_FROM_SD_QUESTION"));
84         create_yes_no_pop(ad, buf);
85 }
86