tizen 2.3.1 release
[framework/security/cert-svc-ui.git] / view / include / certificates / certificate_util.h
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        certificate_util.h
18  * @author      Janusz Kozerski (j.kozerski@samsung.com)
19  * @version     1.0
20  * @brief
21  */
22
23 #ifndef __CERT_UTIL_H__
24 #define __CERT_UTIL_H_
25
26 #include <Elementary.h>
27 #include <assert.h>
28 #include <dlog.h>
29 #include <cert-svc/cstring.h>
30
31 #include "certificates/certificates.h"
32
33 #ifdef _cplusplus
34 extern "C" {
35 #endif
36
37 enum TypeOfCert {
38         USER,
39         TRUSTED_ROOT,
40         PKCS12,
41         TO_INSTALL,
42         TO_UNINSTALL,
43 };
44
45 typedef struct ListElement {
46         struct ListElement *prev;
47         struct ListElement *next;
48         char *name;
49         char *title;
50         char *path;
51         Eina_Bool isChecked;
52         Elm_Object_Item *it;
53 } ListElement_t;
54
55 enum PositionOfElement {
56         NONE,          // This is no element of the list
57         FIRST,         // First element of list - there is nothing before, but is something after
58         LAST,          // Last element of the list - there is nothing after, but is something before
59         IN_THE_MIDDLE, // There are element before and after this element
60         THE_LAST_ONE,  // It means that this is the only one element on the list
61 };
62
63 enum CountOfSelected {
64         SELECTED_NONE, // NONE element is selected
65         SELECTED_FEW,  // At least one, but not all element are selected
66         SELECTED_ALL,  // ALL element are selected
67 };
68
69 Eina_Bool quit_cb(void *data, Elm_Object_Item *it);
70 void list_clicked_cb(void *data, Evas_Object *obj, void *event_info);
71 void genlist_clicked_cb(void *data, Evas_Object *obj, void *event_info);
72
73 struct ListElement* initList();
74 struct ListElement* nextElement(struct ListElement *listElement);
75 struct ListElement* addListElement(struct ListElement* lastListElement, const char *name);
76 struct ListElement* addListElementWithTitle(struct ListElement* lastListElement, const char *name, const char *title);
77 struct ListElement* addListElementWithPath(struct ListElement* lastListElement, const char *name, const char *path);
78 struct ListElement* addListElementWithPathAndTitle(struct ListElement* lastListElement, const char *name, const char *path, const char *title);
79 struct ListElement* findLastElement(struct ListElement* listElement);
80 struct ListElement* findFirstElement(struct ListElement* listElement);
81 enum PositionOfElement removeListElement(struct ListElement *listElementToRemove);
82 void deleteList(struct ListElement* listElement);
83 void clear_pfx_genlist_data();
84
85 /**
86  * Path concatenation
87  * Merge two string in a correct path, e.g.:
88  *
89  * char *c1 = "/opt/shared"
90  * char *c2 = "file_1.pdf"
91  * result -> "/opt/shared/file_1.pdf"
92  *
93  * or:
94  *
95  * char *c1 = "/opt/shared/"
96  * char *c2 = "file_1.pdf"
97  * result -> "/opt/shared/file_1.pdf"
98  *
99  * (function put '/' char in the end of first string if it's needed)
100  *
101  * Result is char pointer allocated by malloc()
102  * Should be deallocated by free()
103  **/
104 char *path_cat(const char *str1, char *str2);
105 char *extractDataFromCert(char *path);
106 const char* get_email(CertSvcString alias);
107
108 //void back_cb (void *data, Evas_Object *obj, void *event_info);
109 Eina_Bool back_cb(void *data, Elm_Object_Item *it);
110 void back_install_cb(void *data, Evas_Object *obj, void *event_info);
111 void install_button_cb(void *data, Evas_Object *obj, void *event_info);
112
113 Evas_Object *create_yes_no_pop(struct ug_data *ad, const char *content);
114 Evas_Object *create_ok_pop(struct ug_data *ad, const char *content);
115
116 Evas_Object *create_no_content_layout(struct ug_data *ad);
117
118 Eina_Bool make_list(
119         struct ug_data *ad,
120         Evas_Object *list,
121         const char *dir_path,
122         struct ListElement *lastListElement);
123
124 #ifdef _cplusplus
125 }
126 #endif
127
128 #ifdef LOG_TAG
129         #undef LOG_TAG
130 #endif
131 #define LOG_TAG "CERT_SVC_UI"
132
133 //temporary enum definition
134 #define ELM_TOOLBAR_SHRINK_EXPAND 4
135
136 #define BUF256 256
137
138 #endif // end of CERT_UTIL_H