source code open - cert-svc-ui
[framework/security/cert-svc-ui.git] / view / include / certificates / certificate_util.h
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 #ifndef __CERT_UTIL_H__
28 #define __CERT_UTIL_H_
29
30 #include <Elementary.h>
31 #include <assert.h>
32 #include <dlog.h>
33
34 #include "certificates/certificates.h"
35
36 #ifdef _cplusplus
37 extern "C" {
38 #endif
39
40 #define CERT_MAX_DATA_SIZE  256
41 #define MAX_PATH_LENGHT     512
42 #define NO_INFORMATION      "no information"
43
44 enum TypeOfCert{
45         USER,
46         TRUSTED_ROOT,
47         TO_INSTALL,
48         TO_UNINSTALL,
49 };
50
51 struct ListElement {
52         struct ListElement *prev, *next;
53         char name[CERT_MAX_DATA_SIZE];
54         char title[CERT_MAX_DATA_SIZE];
55         char uninstall_path[MAX_PATH_LENGHT];
56         Eina_Bool isChecked;
57         Elm_Object_Item * it;
58 };
59
60 enum PositionOfElement {
61         NONE,                   // This is no element of the list
62         FIRST,                  // First element of list - there is nothing before, but is something after
63         LAST,                   // Last element of the list - there is nothing after, but is something before
64         IN_THE_MIDDLE,  // There are element before and after this element
65         THE_LAST_ONE,   // It means that this is the only one element on the list
66 };
67
68 void list_clicked_cb(void *data, Evas_Object *obj, void *event_info);
69 void genlist_clicked_cb(void *data, Evas_Object *obj, void *event_info);
70 Evas_Object *create_info_pop(const char *content);
71
72 struct ListElement* nextElement(struct ListElement *listElement);
73 struct ListElement* initList();
74 struct ListElement* addListElement(struct ListElement* lastListElement, char name[256]);
75 struct ListElement* addListElementWithTitle(struct ListElement* lastListElement, char name[256], char title[256]);
76 struct ListElement* addListElementSetUninstallPath(struct ListElement* lastListElement, char uninstall_path[256]);
77 struct ListElement* findLastElement(struct ListElement* listElement);
78 struct ListElement* findFirstElement(struct ListElement* listElement);
79 enum PositionOfElement removeListElement(struct ListElement *listElementToRemove);
80 void deleteList(struct ListElement* listElement);
81
82 /**
83  * Path concatenation
84  * Merge two string in a correct path, e.g.:
85  *
86  * char *c1 = "/opt/shared"
87  * char *c2 = "file_1.pdf"
88  * result -> "/opt/shared/file_1.pdf"
89  *
90  * or:
91  *
92  * char *c1 = "/opt/shared/"
93  * char *c2 = "file_1.pdf"
94  * result -> "/opt/shared/file_1.pdf"
95  *
96  * (function put '/' char in the end of first string if it's needed)
97  *
98  * Result is char pointer allocated by malloc()
99  * Should be deallocated by free()
100  **/
101 char *path_cat(const char *str1, char *str2);
102 char *extractDataFromCert(char *path);
103
104 struct ListElement *initList();
105 struct ListElement *addListElement(struct ListElement* lastListElement, char name[256]);
106 struct ListElement *addListElementWithTitle(struct ListElement* lastListElement, char name[256], char title[256]);
107 enum PositionOfElement removeListElement(struct ListElement *listElementToRemove);
108 struct ListElement *findLastElement(struct ListElement* listElement);
109 struct ListElement *findFirstElement(struct ListElement* listElement);
110 void cert_selection_cb(void *data, Evas_Object *obj, void *event_info);
111 void deleteList(struct ListElement* listElement);
112 void back_cb(void *data, Evas_Object *obj, void *event_info);
113 Eina_Bool make_list(struct ug_data *ad, Evas_Object *list, char *dir_path, struct ListElement *lastListElement, enum TypeOfCert type);
114 int set_path(struct ug_data *ad, char const *path);
115 void free_path(struct ug_data *ad);
116 void set_refresh_params(struct ug_data *ad, Evas_Object *list, struct ListElement *lastListElement, char dir[MAX_PATH_LENGHT]);
117 void refresh_list(struct ug_data *ad);
118 Evas_Object *create_yes_no_pop(struct ug_data *ad, const char *content);
119 Evas_Object *create_ok_pop(struct ug_data *ad, const char *content);
120
121 #ifdef _cplusplus
122 }
123 #endif
124
125 #ifdef LOG_TAG
126     #undef LOG_TAG
127 #endif
128
129 #ifndef LOG_TAG
130     #define LOG_TAG "CERT-SVC-UI"
131 #endif
132
133 //temporary enum definition
134 #define ELM_TOOLBAR_SHRINK_EXPAND 4
135
136 #define BUF256 256
137 #define BUF1024 1024
138
139 #endif // end of CERT_UTIL_H
140
141