OSDN Git Service

76642062371b92e6192dbe43cb800ef773334cf1
[gpet/origin.git] / src / gpet.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /*
3  * Gui Policy Editor for TOMOYO Linux
4  *
5  * gpet.h
6  * Copyright (C) Yoshihiro Kusuno 2010,2011 <yocto@users.sourceforge.jp>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
21  */
22
23 #ifndef __GPET_H__
24 #define __GPET_H__
25
26 #include "ccstools.h"
27 #include "editpolicy.h"
28
29 typedef struct _generic_list_t {
30         GtkWidget       *listview;
31         struct  ccs_generic_acl *list;
32         int     count;
33 } generic_list_t;
34
35 typedef struct _task_list_t {
36         GtkWidget       *treeview;
37         struct  ccs_task_entry  *task;
38         int     count;
39 } task_list_t;
40
41 enum addentry_type {
42         ADDENTRY_DOMAIN_LIST,
43         ADDENTRY_ACL_LIST,
44         ADDENTRY_EXCEPTION_LIST,
45         ADDENTRY_PROFILE_LIST,
46         ADDENTRY_MANAGER_LIST,
47         ADDENTRY_NON
48 };
49
50 typedef struct _transition_t {
51         GtkWidget               *window;
52         GtkWidget               *domainbar;
53         GtkWidget               *treeview;
54         GtkWidget               *statusbar;
55         gint                    contextid;
56         enum ccs_screen_type    current_page;
57         GtkActionGroup          *actions;
58
59         GtkContainer            *container;
60
61         struct ccs_domain_policy        *dp;
62         int                             domain_count;
63         generic_list_t          acl;    // ACL
64         GtkWidget                       *acl_window;
65         gboolean                        acl_detached;
66         generic_list_t          exp;    // exception
67         generic_list_t          prf;    // profile
68         task_list_t                     tsk;    // Process
69         int                             task_flag;      // 1:process
70                                                         // 0:domain
71         enum addentry_type      addentry;
72 } transition_t;
73
74
75 //#define DEBUG
76
77 #ifdef DEBUG
78         #define DEBUG_PRINT(format, ...) \
79         g_print("%s:%d (%s) " format, __FILE__, __LINE__, G_STRFUNC, ##__VA_ARGS__)
80 #else
81         #define DEBUG_PRINT(...)
82 #endif
83
84
85 #define CCS_DISK_POLICY_DIR                     "/policy/current/"
86 #define CCS_DISK_POLICY_DOMAIN_POLICY           "domain_policy.conf"
87 #define CCS_DISK_POLICY_EXCEPTION_POLICY        "exception_policy.conf"
88 #define CCS_DISK_POLICY_MANAGER                 "manager.conf"
89 #define CCS_DISK_POLICY_PROFILE                 "profile.conf"
90
91
92 // ccstools  editpolicy.c
93 int ccs_main(int argc, char *argv[]);
94
95 // interface.inc
96 int get_domain_policy(struct ccs_domain_policy *dp, int *count);
97 int add_domain(char *input, char **err_buff);
98 int set_profile(struct ccs_domain_policy *dp,
99                                 char *profile, char **err_buff);
100 int get_task_list(struct ccs_task_entry **tsk, int *count);
101 int get_acl_list(struct ccs_domain_policy *dp, int current,
102                         struct ccs_generic_acl **ga, int *count);
103 int get_process_acl_list(int current,
104                                 struct ccs_generic_acl **ga, int *count);
105 int get_optimize_acl_list(int current, struct ccs_generic_acl **ga, int count);
106 int add_acl_list(struct ccs_domain_policy *dp, int current,
107                         char *input, char **err_buff);
108 const char *get_transition_name(enum ccs_transition_type type);
109 int get_exception_policy(struct ccs_generic_acl **ga, int *count);
110 int add_exception_policy(char *input, char **err_buff);
111 int get_profile(struct ccs_generic_acl **ga, int *count);
112 int add_profile(char *input, char **err_buff);
113 int set_profile_level(int index, const char *input, char **err_buff);
114 int get_manager(struct ccs_generic_acl **ga, int *count);
115 int add_manager(char *input, char **err_buff);
116 int get_memory(struct ccs_generic_acl **ga, int *count);
117 int set_memory(struct ccs_generic_acl *ga, int count, char **err_buff);
118 int delete_domain_policy(struct ccs_domain_policy *dp, char **err_buff);
119 int delete_acl_policy(struct ccs_domain_policy *dp, char **err_buff,
120                                 struct ccs_generic_acl *ga, int count);
121 int delete_exp_policy(struct ccs_domain_policy *dp, char **err_buff,
122                                 struct ccs_generic_acl *ga, int count);
123 int delete_manager_policy(
124                 struct ccs_generic_acl *ga, int count, char **err_buff);
125 int is_offline(void);
126 int is_network(void);
127 char *get_remote_ip(char *str_ip);
128 const char *get_policy_dir(void);
129 const char *get_domain_last_name(const int index);
130
131 // gpet.c
132 void add_tree_data(GtkTreeView *treeview, struct ccs_domain_policy *dp);
133 void add_list_data(generic_list_t *generic, gboolean alias_flag);
134 gint get_current_domain_index(transition_t *transition);
135 gchar *get_alias_and_operand(GtkWidget *view);
136 void set_position_addentry(transition_t *transition, GtkTreePath **path);
137 void set_sensitive(GtkActionGroup *actions, int task_flag,
138                                 enum ccs_screen_type current_page);
139 gint delete_domain(transition_t *transition,
140                         GtkTreeSelection *selection, gint count);
141 void view_setting(GtkWidget *treeview, gint search_column);
142 gint set_domain_profile(transition_t *transition,
143                         GtkTreeSelection *selection, guint profile);
144 gboolean disp_acl_line(GtkTreeModel *model, GtkTreePath *path,
145                                 GtkTreeIter *iter, generic_list_t *acl);
146 gint select_list_line(generic_list_t *gen);
147 gint delete_acl(transition_t *transition,
148                         GtkTreeSelection *selection, gint count);
149 gint delete_exp(transition_t *transition,
150                         GtkTreeSelection *selection, gint count);
151 gchar *disp_window_title(enum ccs_screen_type current_page);
152 int gpet_main(void);
153
154 // menu.c
155 GtkWidget *create_menu(GtkWidget *parent, transition_t *transition,
156                        GtkWidget **toolbar);
157 void disp_statusbar(transition_t *transition, int scr);
158 void view_cursor_set(GtkWidget *view,
159                         GtkTreePath *path, GtkTreeViewColumn *column);
160 void refresh_transition(GtkAction *action, transition_t *transition);
161 gchar *get_combo_entry_last(void);
162 GdkPixbuf *get_png_file(void);
163
164 // conf.c
165 void read_config(transition_t *tran);
166 void write_config(transition_t *tran);
167
168 // other.c
169 void manager_main(transition_t *transition);
170 void memory_main(transition_t *transition);
171
172 // process.c
173 void add_task_tree_data(GtkTreeView *treeview, task_list_t *tsk);
174 void set_select_flag_process(gpointer data, task_list_t *tsk);
175 GtkWidget *create_task_tree_model(transition_t *transition);
176 gint get_current_process_index(task_list_t *tsk);
177
178 // search.c
179 GList *insert_item(GtkComboBox  *combobox,
180                         GList *cmblist, const gchar *item_label, gint index);
181 GList *remove_item(GtkComboBox *combobox, GList *cmblist, gint index);
182 void search_input(GtkAction *action, transition_t *transition);
183 void search_back(GtkAction *action, transition_t *transition);
184 void search_forward(GtkAction *action, transition_t *transition);
185
186 #endif /* __GPET_H__ */