1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
3 *
4 * SISSI diagram - adapted by Luc Cessieux
5 * This class could draw the system security
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <assert.h>
27 #undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu, gtk_object_get_user_data, ... */
28 #include <gtk/gtk.h>
29 #include <math.h>
30 #include <string.h>
31
32 #include "object.h"
33 #include "objchange.h"
34 #include "intl.h"
35 #include "sissi.h"
36
37 #include "sissi_dialog.h"
38
39 /************* creation of variable repeat for each object based on EBIOS method */
40
41 static SISSI_Property property_classification_data[] = {
42 { N_("No Protection"), "NO_PROTECTION" ,NULL},
43 { N_("Restricted Diffusion"), "RESTRICTED_DIFFUSION" ,NULL},
44 { N_("Special Country Confidential"), "SPECIAL_COUNTRY_CONFIDENTIAL" ,NULL},
45 { N_("NATO Confidential"), "NATO_CONFIDENTIAL" ,NULL},
46 { N_("Personal Confidential"), "PERSONAL_CONFIDENTIAL" ,NULL},
47 { N_("Medical Confidential"), "MEDICAL_CONFIDENTIAL" ,NULL},
48 { N_("Industrial Confidential"), "INDUSTRIE_CONFIDENTIAL" ,NULL},
49 { N_("Secret"), "SECRET" ,NULL},
50 { N_("Secret special country"), "SECRET_SPECIAL_COUNTRY" ,NULL},
51 { N_("NATO Secret"), "NATO_SECRET" ,NULL},
52 { N_("Very Secret"), "VERY_SECRET" ,NULL},
53 { N_("NATO Very Secret"), "NATO_VERY_SECRET" ,NULL},
54 { NULL,0,NULL}
55 };
56
57 static SISSI_Property property_integrity_data[] = {
58 { N_("No integrity"), "NULL" ,NULL},
59 { N_("Low integrity"), "LOW_INTEGRITY" ,NULL},
60 { N_("Average software integrity"), "AVERAGE_SOFTWARE_INTEGRITY" ,NULL},
61 { N_("High software integrity"), "HIGHT_SOFTWARE_INTEGRITY" ,NULL},
62 { N_("Average hardware integrity"), "AVERAGE_HARDWARE_INTEGRITY" ,NULL},
63 { N_("High hardware integrity"), "HIGHT_HARDWARE_INTEGRITY" ,NULL},
64 { NULL,0,NULL}
65 };
66
67 static SISSI_Property property_disponibility_level_data[] = {
68 { N_("Millisecond"), "MILLISECOND" ,NULL},
69 { N_("Second"), "SECOND" ,NULL},
70 { N_("Minute"), "MINUTE" ,NULL},
71 { N_("Hour"), "HOUR" ,NULL},
72 { N_("Day"), "DAY" ,NULL},
73 { N_("Week"), "WEEK" ,NULL},
74 { NULL,0,NULL}
75 };
76
77 static SISSI_Property property_system_data[] = {
78 { N_("SYSTEM"), "SYS",NULL},
79 { N_("Internet access device"), "SYS_INT",NULL},
80 { N_("Electronic messaging"), "SYS_MAIL",NULL},
81 { N_("Intranet"), "SYS_ITR",NULL},
82 { N_("Company directory"), "SYS_DIRECTORY",NULL},
83 { N_("External portal"), "SYS_WEB",NULL},
84 { NULL,0,NULL}
85 };
86
87 static SISSI_Property property_organisation_data[] = {
88 { N_("ORGANISATION"), "ORG",NULL},
89 { N_("Higher-tier organisation"), "ORG_DEP",NULL},
90 { N_("Structure of the organisation"), "ORG_GEN",NULL},
91 { N_("Project or system organisation"), "ORG_PRO",NULL},
92 { N_("Subcontractors / Suppliers / Manufacturers"),"ORG_EXT",NULL},
93 { NULL,0,NULL}
94 };
95
96 static SISSI_Property property_physic_data[] = {
97 { N_("SITE"), "PHY",NULL},
98 { N_("Places"), "PHY_LIE",NULL},
99 { N_("External environment"), "PHY_LIE1",NULL},
100 { N_("Premises"), "PHY_LIE2",NULL},
101 { N_("Zone"), "PHY_LIE3",NULL},
102 { N_("Essential Services"), "PHY_SRV",NULL},
103 { N_("Communication"), "PHY_SRV1",NULL},
104 { N_("Power"), "PHY_SRV2",NULL},
105 { N_("Cooling / Pollution"), "PHY_SRV3",NULL},
106 { NULL, 0,NULL}
107 };
108 static SISSI_Property property_physic_detecTHERMIC_data[] = {
109 { N_("Thermal detection"), "PHY_DETECTION_THERMIC",NULL},
110 { NULL, 0,NULL}
111 };
112 static SISSI_Property property_physic_detecFIRE_data[] = {
113 { N_("Fire detection"), "PHY_DETECTION_FIRE",NULL},
114 { NULL, 0,NULL}
115 };
116 static SISSI_Property property_physic_detecWATER_data[] = {
117 { N_("Water detection"), "PHY_DETECTION_WATER",NULL},
118 { NULL, 0,NULL}
119 };
120 static SISSI_Property property_physic_detecAIR_data[] = {
121 { N_("Air detection"), "PHY_DETECTION_AIR",NULL},
122 { NULL, 0,NULL}
123 };
124 static SISSI_Property property_physic_detecENERGY_data[] = {
125 { N_("Energy detection"), "PHY_DETECTION_ENERGY",NULL},
126 { NULL, 0,NULL}
127 };
128 static SISSI_Property property_physic_detecINTRUSION_data[] = {
129 { N_("Intrusion detection"), "PHY__DETECTION_INTRUSION",NULL},
130 { NULL, 0,NULL}
131 };
132 static SISSI_Property property_physic_actionTHERMIC_data[] = {
133 { N_("Thermal action"), "PHY_ACTION_THERMIC",NULL},
134 { NULL, 0,NULL}
135 };
136 static SISSI_Property property_physic_actionFIRE_data[] = {
137 { N_("Fire action"), "PHY_ACTION_FIRE",NULL},
138 { NULL, 0,NULL}
139 };
140 static SISSI_Property property_physic_actionWATER_data[] = {
141 { N_("Water action"), "PHY_ACTION_WATER",NULL},
142 { NULL, 0,NULL}
143 };
144 static SISSI_Property property_physic_actionAIR_data[] = {
145 { N_("Air action"), "PHY_ACTION_AIR",NULL},
146 { NULL, 0,NULL}
147 };
148 static SISSI_Property property_physic_actionENERGY_data[] = {
149 { N_("Energy action"), "PHY_ACTION_ENERGY",NULL},
150 { NULL, 0,NULL}
151 };
152 static SISSI_Property property_physic_actionINTRUSION_data[] = {
153 { N_("Intrusion action"), "PHY_ACTION_INTRUSION",NULL},
154 { NULL, 0,NULL}
155 };
156
157 static SISSI_Property property_personnel_data[] = {
158 { N_("Personal"), "PER",NULL},
159 { N_("Decision maker"), "PER_DEC",NULL},
160 { N_("SSI Responsible"), "PER_RESP_SSI",NULL},
161 { N_("Users"), "PER_UTI",NULL},
162 { N_("Functional administrator"), "PER_FONC_ADMIN",NULL},
163 { N_("Technical administrator"), "PER_TECH_ADMIN",NULL},
164 { N_("SSI administrator"), "PER_SSI_ADMIN",NULL},
165 { N_("Developer"), "PER_DEV",NULL},
166 { N_("Operator / Maintenance"), "PER_EXP",NULL},
167 { NULL, 0,NULL}
168 };
169
170 static SISSI_Property property_reseau_data[] = {
171 { N_("Network"), "RES",NULL},
172 { N_("Medium and support"), "RES_INF",NULL},
173 { N_("Passive or active relay"), "RES_REL",NULL},
174 { N_("Communication interface"), "RES_INT",NULL},
175 { NULL, 0,NULL}
176 };
177
178 static SISSI_Property property_logiciel_data[] = {
179 { N_("Software"), "LOG",NULL},
180 { N_("Operating System"), "LOG_OS",NULL},
181 { N_("Service - maintenance or administration software"), "LOG_SRV",NULL},
182 { N_("Packaged software or standard software"), "LOG_STD",NULL},
183 { N_("Business application"), "LOG_APP",NULL},
184 { N_("Standard business application"), "LOG_APP1",NULL},
185 { N_("Specific business application"), "LOG_APP2",NULL},
186 { NULL, 0,NULL}
187 };
188
189 static SISSI_Property property_material_data[] = {
190 { N_("HARDWARE"), "MAT",NULL},
191 { N_("Data-processing equipment (active)"), "MAT_ACT",NULL},
192 { N_("Mobile equipment"), "MAT_ACT1",NULL},
193 { N_("Fixed equipment"), "MAT_ACT2",NULL},
194 { N_("Peripheral processing"), "MAT_ACT3",NULL},
195 { N_("Electronic medium"), "MAT_PAS1",NULL},
196 { N_("Other media"), "MAT_PAS2",NULL},
197 { N_("Data medium (passive)"), "MAT_PAS",NULL},
198 { NULL, 0,NULL}
199 };
200
201
clear_list_property_widget(GList * list)202 static GList *clear_list_property_widget(GList *list)
203 {
204 while (list != NULL) {
205 SISSI_Property_Widget *property = (SISSI_Property_Widget *) list->data;
206 gtk_widget_destroy((GtkWidget *)property->label);
207 gtk_widget_destroy((GtkWidget *)property->value);
208 gtk_widget_destroy((GtkWidget *)property->description);
209 g_free(property);
210 list = g_list_next(list);
211 }
212 g_list_free(list);
213 list=NULL;
214 return list;
215 }
216
clear_list_url_doc_widget(GList * list)217 static GList *clear_list_url_doc_widget(GList *list)
218 {
219 while (list != NULL) {
220 Url_Docs_Widget *url_doc = (Url_Docs_Widget *) list->data;
221 gtk_widget_destroy((GtkWidget *)url_doc->label);
222 gtk_widget_destroy((GtkWidget *)url_doc->url);
223 gtk_widget_destroy((GtkWidget *)url_doc->description);
224 g_free(url_doc);
225 list = g_list_next(list);
226 }
227 g_list_free(list);
228 list=NULL;
229 return list;
230 }
231
232
233 static void
object_sissi_change_apply(SISSIChange * change,DiaObject * obj)234 object_sissi_change_apply(SISSIChange *change, DiaObject *obj)
235 {
236 /* fprintf(stderr,"espion object_sissi_change_apply\n"); */
237 }
238
object_sissi_change_revert(SISSIChange * change,DiaObject * obj)239 static void object_sissi_change_revert(SISSIChange *change, DiaObject *obj)
240 {
241 /*
242 fprintf(stderr,"espion object_sissi_change_revert\n");*/
243 }
244
object_sissi_change_free(SISSIChange * change)245 static void object_sissi_change_free(SISSIChange *change)
246 {
247 /*
248 g_list_free(free_list);
249 */
250 }
251
new_sissi_change(ObjetSISSI * object_sissi,SISSIState * state,GList * added,GList * deleted,GList * disconnected)252 static ObjectChange *new_sissi_change(ObjetSISSI *object_sissi, SISSIState *state, GList *added, GList *deleted, GList *disconnected)
253 {
254 SISSIChange *change;
255
256 change = g_new0(SISSIChange, 1);
257
258 change->obj_change.apply =
259 (ObjectChangeApplyFunc) object_sissi_change_apply;
260 change->obj_change.revert =
261 (ObjectChangeRevertFunc) object_sissi_change_revert;
262 change->obj_change.free =
263 (ObjectChangeFreeFunc) object_sissi_change_free;
264
265 return (ObjectChange *)change;
266 }
267
268 /********************************************************
269 ******************** menace part **********************
270 ********************************************************/
271
properties_menaces_read_from_dialog(ObjetSISSI * object_sissi,SISSIDialog * prop_dialog)272 static void properties_menaces_read_from_dialog(ObjetSISSI *object_sissi, SISSIDialog *prop_dialog)
273 {
274
275 unsigned int i;
276 /************ copy the list of menaces *******/
277 for (i=0;i<g_list_length(object_sissi->properties_menaces);i++)
278 {
279
280 ((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->comments = g_strdup(gtk_entry_get_text((GtkEntry *)(((SISSI_Property_Menace_Widget *)(g_list_nth(prop_dialog->properties_menaces,i)->data))->comments)));
281
282 ((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->action = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(((SISSI_Property_Menace_Widget *)(g_list_nth(prop_dialog->properties_menaces,i)->data))->action));
283 ((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->detection = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(((SISSI_Property_Menace_Widget *)(g_list_nth(prop_dialog->properties_menaces,i)->data))->detection));
284 ((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->vulnerability = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(((SISSI_Property_Menace_Widget *)(g_list_nth(prop_dialog->properties_menaces,i)->data))->vulnerability));
285 }
286 /* fprintf(stderr,"espion properties_menaces_read_from_dialog fin\n");*/
287 }
288
properties_menaces_create_page(GtkNotebook * notebook,ObjetSISSI * object_sissi)289 static void properties_menaces_create_page(GtkNotebook *notebook, ObjetSISSI *object_sissi)
290 {
291 unsigned int i;
292 SISSIDialog *prop_dialog;
293 GtkWidget *page_label;
294 GtkWidget *label;
295 GtkWidget *pScroll;
296 GtkWidget *vbox;
297 GtkWidget *table;
298 prop_dialog = object_sissi->properties_dialog;
299
300 /* Class page:*/
301 page_label = gtk_label_new_with_mnemonic (_("_Menace"));
302
303 vbox = gtk_vbox_new(FALSE, 0);
304
305
306 gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
307
308 pScroll = gtk_scrolled_window_new(NULL, NULL);
309 /*gtk_window_set_default_size(GTK_WINDOW(pScroll), 300, 200);*/
310 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pScroll), vbox);
311
312
313 table = gtk_table_new (43, 8, FALSE);
314 gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
315
316 /********** label of board **********/
317 label = gtk_label_new (_("Menace"));
318 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
319 label = gtk_label_new (_("P Action"));
320 gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 0, 1);
321 label = gtk_label_new (_("P Detection"));
322 gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 0, 1);
323 label = gtk_label_new (_("Vulnerability"));
324
325 gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, 0, 1);
326 label = gtk_label_new (_("Menace"));
327 gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 5, 0, 1);
328 label = gtk_label_new (_("P Action"));
329 gtk_table_attach_defaults (GTK_TABLE (table), label, 5, 6, 0, 1);
330 label = gtk_label_new (_("P Detection"));
331 gtk_table_attach_defaults (GTK_TABLE (table), label, 6, 7, 0, 1);
332 label = gtk_label_new (_("Vulnerability"));
333 gtk_table_attach_defaults (GTK_TABLE (table), label, 7, 8, 0, 1);
334
335 /************* values of board *********/
336 /********* GtkObject *adj; **********/
337 for (i=0;i<g_list_length(object_sissi->properties_menaces);i++)
338 {
339 SISSI_Property_Menace_Widget *property_menace_widget;
340 property_menace_widget=g_malloc0(sizeof(SISSI_Property_Menace_Widget));
341
342 property_menace_widget->label = gtk_label_new (NULL);
343 gtk_label_set_text(GTK_LABEL(property_menace_widget->label), _(((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->label));
344
345
346 property_menace_widget->comments = gtk_entry_new();
347
348 /* adj = gtk_adjustment_new( umlclass->wrap_after_char, 0.0, 200.0, 1.0, 5.0, 0);
349 // prop_dialog->wrap_after_char = GTK_SPIN_BUTTON(gtk_spin_button_new( GTK_ADJUSTMENT( adj), 0.1, 0));
350 // gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( prop_dialog->wrap_after_char), TRUE);
351 // gtk_spin_button_set_snap_to_ticks( GTK_SPIN_BUTTON( prop_dialog->wrap_after_char), TRUE);*/
352
353 property_menace_widget->action = gtk_spin_button_new_with_range(0, 3, 1);
354 property_menace_widget->detection = gtk_spin_button_new_with_range(0, 3, 1);
355 property_menace_widget->vulnerability = gtk_spin_button_new_with_range(0, 3, 1);
356
357 gtk_table_attach_defaults (GTK_TABLE (table), property_menace_widget->label, (i%2)*4, (i%2)*4+1, i*2+1-2*(i%2), i*2+2-2*(i%2));
358 gtk_table_attach_defaults (GTK_TABLE (table), property_menace_widget->action, (i%2)*4+1, (i%2)*4+2, i*2+1-2*(i%2), i*2+2-2*(i%2));
359 gtk_table_attach_defaults (GTK_TABLE (table), property_menace_widget->detection, (i%2)*4+2, (i%2)*4+3, i*2+1-2*(i%2), i*2+2-2*(i%2));
360 gtk_table_attach_defaults (GTK_TABLE (table), property_menace_widget->vulnerability, (i%2)*4+3,(i%2)*4+4, i*2+1-2*(i%2), i*2+2-2*(i%2));
361 gtk_table_attach_defaults (GTK_TABLE (table), property_menace_widget->comments, (i%2)*4, (i%2)*4+4, i*2+2-2*(i%2), i*2+3-2*(i%2));
362
363 /* after the création of the elements, we put there in the widget list */
364 prop_dialog->properties_menaces=g_list_append(prop_dialog->properties_menaces,property_menace_widget);
365 }
366
367 gtk_widget_show_all (vbox);
368 gtk_widget_show_all (pScroll);
369 gtk_widget_show (page_label);
370 gtk_notebook_append_page(notebook, pScroll, page_label);
371 }
372
373
properties_others_read_from_dialog(ObjetSISSI * object_sissi,SISSIDialog * prop_dialog)374 static void properties_others_read_from_dialog(ObjetSISSI *object_sissi, SISSIDialog *prop_dialog)
375 {
376 /* GList *list; */
377 unsigned int i;
378 /************** classification list box *************/
379 if (GTK_IS_OPTION_MENU(object_sissi->properties_dialog->confidentiality)) {
380 object_sissi->confidentiality = g_strdup((char *)(gtk_object_get_user_data(
381 GTK_OBJECT(GTK_OPTION_MENU(object_sissi->properties_dialog->confidentiality)->menu_item))));
382 } else {
383 object_sissi->confidentiality = g_strdup((char *)strtol(gtk_entry_get_text(GTK_ENTRY(object_sissi->properties_dialog->confidentiality)), NULL, 0));
384 }
385
386 if (GTK_IS_OPTION_MENU(object_sissi->properties_dialog->integrity)) {
387 object_sissi->integrity = g_strdup((char *)(gtk_object_get_user_data(
388 GTK_OBJECT(GTK_OPTION_MENU(object_sissi->properties_dialog->integrity)->menu_item))));
389 } else {
390 object_sissi->integrity = g_strdup((char *)strtol(gtk_entry_get_text(GTK_ENTRY(object_sissi->properties_dialog->integrity)), NULL, 0));
391 }
392
393 if (GTK_IS_OPTION_MENU(object_sissi->properties_dialog->disponibility_level)) {
394 object_sissi->disponibility_level = g_strdup((char *)(gtk_object_get_user_data(
395 GTK_OBJECT(GTK_OPTION_MENU(object_sissi->properties_dialog->disponibility_level)->menu_item))));
396 } else {
397 object_sissi->disponibility_level = g_strdup((char *)strtol(gtk_entry_get_text(GTK_ENTRY(object_sissi->properties_dialog->disponibility_level)), NULL, 0));
398 }
399
400 object_sissi->disponibility_value = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(object_sissi->properties_dialog->disponibility_value));
401
402
403 /************ Entity list box*******************/
404 if (GTK_IS_OPTION_MENU(object_sissi->properties_dialog->entity)) {
405 object_sissi->entity = g_strdup((char *)(gtk_object_get_user_data(
406 GTK_OBJECT(GTK_OPTION_MENU(object_sissi->properties_dialog->entity)->menu_item))));
407 } else {
408 object_sissi->entity = g_strdup((char *)strtol(gtk_entry_get_text(GTK_ENTRY(object_sissi->properties_dialog->entity)), NULL, 0));
409 }
410
411
412 /* to copy the properties box list of dialog to propreties object */
413
414 object_sissi->properties_others=clear_list_property(object_sissi->properties_others);
415 for (i=0;i<g_list_length(prop_dialog->properties_others);i++)
416 {
417 SISSI_Property *properties_others;
418 properties_others=g_malloc0(sizeof(SISSI_Property));
419 if (i < object_sissi->nb_others_fixes)
420 {
421 properties_others->label = g_strdup(gtk_label_get_text(GTK_LABEL(((SISSI_Property_Widget *)(g_list_nth(prop_dialog->properties_others,i)->data))->label)));
422 properties_others->description = g_strdup(gtk_label_get_text(GTK_LABEL(((SISSI_Property_Widget *)(g_list_nth(prop_dialog->properties_others,i)->data))->description)));
423 }
424 else
425 {
426 properties_others->label = g_strdup(gtk_entry_get_text((GtkEntry *)(((SISSI_Property_Widget *)(g_list_nth(prop_dialog->properties_others,i)->data))->label)));
427 properties_others->description = g_strdup(gtk_entry_get_text((GtkEntry *)(((SISSI_Property_Widget *)(g_list_nth(prop_dialog->properties_others,i)->data))->description)));
428 }
429 properties_others->value = g_strdup(gtk_entry_get_text((GtkEntry *)(((SISSI_Property_Widget *)(g_list_nth(prop_dialog->properties_others,i)->data))->value)));
430 if((strcmp(properties_others->label,"")==0) && (strcmp(properties_others->value,"")==0) && (strcmp(properties_others->description,"")==0))
431 {
432 g_free(properties_others->label);
433 g_free(properties_others->value);
434 g_free(properties_others->description);
435 g_free(properties_others);
436 }
437 else
438 {
439 object_sissi->properties_others=g_list_append(object_sissi->properties_others, properties_others);
440 }
441 }
442 object_sissi->name = g_strdup(gtk_entry_get_text((GtkEntry *)prop_dialog->name));
443 }
444
445 static void
others_new_callback(GtkWidget * button,ObjetSISSI * object_sissi)446 others_new_callback(GtkWidget *button, ObjetSISSI *object_sissi)
447 {
448 unsigned int i;
449 SISSI_Property_Widget *property_other;
450 SISSIDialog *prop_dialog;
451 /* DiaObject *obj; */
452 prop_dialog = object_sissi->properties_dialog;
453 i=prop_dialog->nb_properties_others;
454
455 property_other=g_malloc0(sizeof(SISSI_Property_Widget));
456
457 property_other->label = gtk_entry_new();
458 property_other->value = gtk_entry_new();
459 property_other->description= gtk_entry_new();
460
461 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), (GtkWidget *)property_other->label, 0, 1, i+5, i+6);
462 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), (GtkWidget *)property_other->value, 1,2,i+5,i+6);
463 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), (GtkWidget *)property_other->description, 2,3,i+5,i+6);
464 /* after creation we put elemnts in widget list */
465 prop_dialog->properties_others=g_list_append(prop_dialog->properties_others,property_other);
466
467 gtk_widget_show (prop_dialog->table_others);
468 gtk_widget_show_all (prop_dialog->vbox_others);
469 gtk_widget_show (prop_dialog->page_label_others);
470 prop_dialog->nb_properties_others=i+1;
471 }
472
473
properties_others_create_page(GtkNotebook * notebook,ObjetSISSI * object_sissi)474 static void properties_others_create_page(GtkNotebook *notebook, ObjetSISSI *object_sissi)
475 {
476 SISSIDialog *prop_dialog;
477 GtkWidget *label,*button;
478 GtkWidget *pScroll_others;
479
480
481 GtkWidget *menu_classification, *menu_integrity, *menu_disponibility_level/* , *disponibility_value */;
482 GtkWidget *menu_entity;
483 unsigned int j;
484
485 prop_dialog = object_sissi->properties_dialog;
486
487 /* Other properties of page: */
488 prop_dialog->page_label_others = gtk_label_new_with_mnemonic (_("Other properties"));
489
490 prop_dialog->vbox_others = gtk_vbox_new(FALSE, 0);
491 gtk_container_set_border_width (GTK_CONTAINER (prop_dialog->vbox_others), 0);
492
493
494 pScroll_others = gtk_scrolled_window_new(NULL, NULL);
495 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pScroll_others),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC);
496 /*gtk_window_set_default_size(GTK_WINDOW(pScroll_others), 300, 200);*/
497
498 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pScroll_others), prop_dialog->vbox_others);
499
500 prop_dialog->table_others = gtk_table_new (43, 3, FALSE);
501 gtk_box_pack_start (GTK_BOX (prop_dialog->vbox_others), prop_dialog->table_others, FALSE, FALSE, 0);
502
503 /**** Selection menu of classification ****/
504
505 object_sissi->properties_dialog->confidentiality = gtk_option_menu_new();
506 menu_classification = gtk_menu_new();
507 object_sissi->properties_dialog->integrity= gtk_option_menu_new();
508 menu_integrity = gtk_menu_new();
509 object_sissi->properties_dialog->disponibility_level = gtk_option_menu_new();
510 menu_disponibility_level = gtk_menu_new();
511
512 for (j = 0; property_classification_data[j].label != NULL; j++) {
513 GtkWidget *item = gtk_menu_item_new_with_label(_(property_classification_data[j].label));
514 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_classification_data[j].value));
515 gtk_container_add(GTK_CONTAINER(menu_classification), item);
516 gtk_widget_show(item);
517 }
518 gtk_option_menu_set_menu(GTK_OPTION_MENU(object_sissi->properties_dialog->confidentiality), menu_classification);
519 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), object_sissi->properties_dialog->confidentiality, 0, 2, 0, 1);
520 /************* end of menu **********/
521 for (j = 0; property_integrity_data[j].label != NULL; j++) {
522 GtkWidget *item = gtk_menu_item_new_with_label(_(property_integrity_data[j].label));
523 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_integrity_data[j].value));
524 gtk_container_add(GTK_CONTAINER(menu_integrity), item);
525 gtk_widget_show(item);
526 }
527 gtk_option_menu_set_menu(GTK_OPTION_MENU(object_sissi->properties_dialog->integrity), menu_integrity);
528 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), object_sissi->properties_dialog->integrity, 2, 4, 0, 1);
529
530 object_sissi->properties_dialog->disponibility_value = gtk_spin_button_new_with_range(0, 100, 1);
531 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), object_sissi->properties_dialog->disponibility_value, 0, 1, 1, 2);
532
533 for (j = 0; property_disponibility_level_data[j].label != NULL; j++) {
534 GtkWidget *item = gtk_menu_item_new_with_label(_(property_disponibility_level_data[j].label));
535 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_disponibility_level_data[j].value));
536 gtk_container_add(GTK_CONTAINER(menu_disponibility_level), item);
537 gtk_widget_show(item);
538 }
539 gtk_option_menu_set_menu(GTK_OPTION_MENU(object_sissi->properties_dialog->disponibility_level), menu_disponibility_level);
540 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), object_sissi->properties_dialog->disponibility_level, 1, 2, 1, 2);
541
542 /*********************** Selection of entity menu ***************************/
543 object_sissi->properties_dialog->entity = gtk_option_menu_new();
544 menu_entity = gtk_menu_new();
545 /****** Choice of list in function of object type ***********/
546 if (0==strcmp(object_sissi->entity_type,"MATERIAL"))
547 {
548 for (j = 0; property_material_data[j].label != NULL; j++) {
549 GtkWidget *item = gtk_menu_item_new_with_label(_(property_material_data[j].label));
550 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_material_data[j].value));
551 gtk_container_add(GTK_CONTAINER(menu_entity), item);
552 gtk_widget_show(item);
553 }
554 }
555 if (0==strcmp(object_sissi->entity_type,"SOFTWARE"))
556 {
557 for (j = 0; property_logiciel_data[j].label != NULL; j++) {
558 GtkWidget *item = gtk_menu_item_new_with_label(_(property_logiciel_data[j].label));
559 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_logiciel_data[j].value));
560 gtk_container_add(GTK_CONTAINER(menu_entity), item);
561 gtk_widget_show(item);
562 }
563 }
564 if (0==strcmp(object_sissi->entity_type,"NETWORK"))
565 {
566 for (j = 0; property_reseau_data[j].label != NULL; j++) {
567 GtkWidget *item = gtk_menu_item_new_with_label(_(property_reseau_data[j].label));
568 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_reseau_data[j].value));
569 gtk_container_add(GTK_CONTAINER(menu_entity), item);
570 gtk_widget_show(item);
571 }
572 }
573 if (0==strcmp(object_sissi->entity_type,"PERSON"))
574 {
575 for (j = 0; property_personnel_data[j].label != NULL; j++) {
576 GtkWidget *item = gtk_menu_item_new_with_label(_(property_personnel_data[j].label));
577 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_personnel_data[j].value));
578 gtk_container_add(GTK_CONTAINER(menu_entity), item);
579 gtk_widget_show(item);
580 }
581 }
582 if (0==strcmp(object_sissi->entity_type,"PHYSIC"))
583 {
584 for (j = 0; property_physic_data[j].label != NULL; j++) {
585 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_data[j].label));
586 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_data[j].value));
587 gtk_container_add(GTK_CONTAINER(menu_entity), item);
588 gtk_widget_show(item);
589 }
590 }
591 if (0==strcmp(object_sissi->entity_type,"PHY_DETECTION_THERMIC"))
592 {
593 for (j = 0; property_physic_detecTHERMIC_data[j].label != NULL; j++) {
594 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_detecTHERMIC_data[j].label));
595 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_detecTHERMIC_data[j].value));
596 gtk_container_add(GTK_CONTAINER(menu_entity), item);
597 gtk_widget_show(item);
598 }
599 }
600 if (0==strcmp(object_sissi->entity_type,"PHY_DETECTION_FIRE"))
601 {
602 for (j = 0; property_physic_detecFIRE_data[j].label != NULL; j++) {
603 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_detecFIRE_data[j].label));
604 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_detecFIRE_data[j].value));
605 gtk_container_add(GTK_CONTAINER(menu_entity), item);
606 gtk_widget_show(item);
607 }
608 }
609 if (0==strcmp(object_sissi->entity_type,"PHY_DETECTION_WATER"))
610 {
611 for (j = 0; property_physic_detecWATER_data[j].label != NULL; j++) {
612 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_detecWATER_data[j].label));
613 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_detecWATER_data[j].value));
614 gtk_container_add(GTK_CONTAINER(menu_entity), item);
615 gtk_widget_show(item);
616 }
617 }
618 if (0==strcmp(object_sissi->entity_type,"PHY_DETECTION_AIR"))
619 {
620 for (j = 0; property_physic_detecAIR_data[j].label != NULL; j++) {
621 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_detecAIR_data[j].label));
622 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_detecAIR_data[j].value));
623 gtk_container_add(GTK_CONTAINER(menu_entity), item);
624 gtk_widget_show(item);
625 }
626 }
627 if (0==strcmp(object_sissi->entity_type,"PHY_DETECTION_ENERGY"))
628 {
629 for (j = 0; property_physic_detecENERGY_data[j].label != NULL; j++) {
630 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_detecENERGY_data[j].label));
631 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_detecENERGY_data[j].value));
632 gtk_container_add(GTK_CONTAINER(menu_entity), item);
633 gtk_widget_show(item);
634 }
635 }
636 if (0==strcmp(object_sissi->entity_type,"PHY_DETECTION_INTRUSION"))
637 {
638 for (j = 0; property_physic_detecINTRUSION_data[j].label != NULL; j++) {
639 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_detecINTRUSION_data[j].label));
640 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_detecINTRUSION_data[j].value));
641 gtk_container_add(GTK_CONTAINER(menu_entity), item);
642 gtk_widget_show(item);
643 }
644 }
645 if (0==strcmp(object_sissi->entity_type,"PHY_ACTION_THERMIC"))
646 {
647 for (j = 0; property_physic_actionTHERMIC_data[j].label != NULL; j++) {
648 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_actionTHERMIC_data[j].label));
649 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_actionTHERMIC_data[j].value));
650 gtk_container_add(GTK_CONTAINER(menu_entity), item);
651 gtk_widget_show(item);
652 }
653 }
654 if (0==strcmp(object_sissi->entity_type,"PHY_ACTION_FIRE"))
655 {
656 for (j = 0; property_physic_actionFIRE_data[j].label != NULL; j++) {
657 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_actionFIRE_data[j].label));
658 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_actionFIRE_data[j].value));
659 gtk_container_add(GTK_CONTAINER(menu_entity), item);
660 gtk_widget_show(item);
661 }
662 }
663 if (0==strcmp(object_sissi->entity_type,"PHY_ACTION_WATER"))
664 {
665 for (j = 0; property_physic_actionWATER_data[j].label != NULL; j++) {
666 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_actionWATER_data[j].label));
667 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_actionWATER_data[j].value));
668 gtk_container_add(GTK_CONTAINER(menu_entity), item);
669 gtk_widget_show(item);
670 }
671 }
672 if (0==strcmp(object_sissi->entity_type,"PHY_ACTION_AIR"))
673 {
674 for (j = 0; property_physic_actionAIR_data[j].label != NULL; j++) {
675 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_actionAIR_data[j].label));
676 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_actionAIR_data[j].value));
677 gtk_container_add(GTK_CONTAINER(menu_entity), item);
678 gtk_widget_show(item);
679 }
680 }
681 if (0==strcmp(object_sissi->entity_type,"PHY_ACTION_ENERGY"))
682 {
683 for (j = 0; property_physic_actionENERGY_data[j].label != NULL; j++) {
684 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_actionENERGY_data[j].label));
685 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_actionENERGY_data[j].value));
686 gtk_container_add(GTK_CONTAINER(menu_entity), item);
687 gtk_widget_show(item);
688 }
689 }
690 if (0==strcmp(object_sissi->entity_type,"PHY_ACTION_INTRUSION"))
691 {
692 for (j = 0; property_physic_actionINTRUSION_data[j].label != NULL; j++) {
693 GtkWidget *item = gtk_menu_item_new_with_label(_(property_physic_actionINTRUSION_data[j].label));
694 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_physic_actionINTRUSION_data[j].value));
695 gtk_container_add(GTK_CONTAINER(menu_entity), item);
696 gtk_widget_show(item);
697 }
698 }
699 if (0==strcmp(object_sissi->entity_type,"ORGANIZATION"))
700 {
701 for (j = 0; property_organisation_data[j].label != NULL; j++) {
702 GtkWidget *item = gtk_menu_item_new_with_label(_(property_organisation_data[j].label));
703 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_organisation_data[j].value));
704 gtk_container_add(GTK_CONTAINER(menu_entity), item);
705 gtk_widget_show(item);
706 }
707 }
708 if (0==strcmp(object_sissi->entity_type,"SYSTEM"))
709 {
710 for (j = 0; property_system_data[j].label != NULL; j++) {
711 GtkWidget *item = gtk_menu_item_new_with_label(_(property_system_data[j].label));
712 gtk_object_set_user_data(GTK_OBJECT(item),GUINT_TO_POINTER(property_system_data[j].value));
713 gtk_container_add(GTK_CONTAINER(menu_entity), item);
714 gtk_widget_show(item);
715 }
716 }
717
718 gtk_option_menu_set_menu(GTK_OPTION_MENU(object_sissi->properties_dialog->entity), menu_entity);
719 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), object_sissi->properties_dialog->entity, 2, 4, 1, 2);
720 /********** selection menu of entity *********/
721
722
723
724
725 /********** Label of board **********/
726 label = gtk_label_new (_("Label"));
727 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), label, 0, 1, 2, 3);
728 label = gtk_label_new (_("value"));
729 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), label, 1, 2, 2, 3);
730 label = gtk_label_new (_("Description"));
731 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), label, 2, 3, 2, 3);
732
733 /**** board of value ***************/
734 label = gtk_label_new (_("Name"));
735 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), label, 0, 1, 3, 4);
736 object_sissi->properties_dialog->name=gtk_entry_new();
737 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), (GtkWidget *)object_sissi->properties_dialog->name, 1,2,3,4);
738
739 button = gtk_button_new_with_mnemonic (_("_New"));
740 gtk_signal_connect (GTK_OBJECT (button), "clicked",
741 GTK_SIGNAL_FUNC(others_new_callback),
742 object_sissi);
743
744 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), button, 2, 3, 3, 4);
745
746
747 object_sissi->properties_dialog->nb_properties_others=4;
748
749 gtk_widget_show_all (prop_dialog->vbox_others);
750 gtk_widget_show (prop_dialog->page_label_others);
751 gtk_widget_show_all (pScroll_others);
752
753 gtk_notebook_append_page(notebook, pScroll_others, prop_dialog->page_label_others);
754
755 }
756
757 /******************************************
758 * List of documents *
759 *******************************************/
760
761 static void
document_new_callback(GtkWidget * button,ObjetSISSI * object_sissi)762 document_new_callback(GtkWidget *button, ObjetSISSI *object_sissi)
763 {
764 unsigned int i;
765 Url_Docs_Widget *doc_widget;
766 SISSIDialog *prop_dialog;
767
768 prop_dialog = object_sissi->properties_dialog;
769 i=prop_dialog->nb_doc +1;
770
771 doc_widget=g_malloc0(sizeof(Url_Docs_Widget));
772
773 doc_widget->label = gtk_entry_new();
774 doc_widget->url = gtk_entry_new();
775 doc_widget->description= gtk_entry_new();
776
777 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), (GtkWidget *)doc_widget->label, 0, 1, i+1, i+2);
778 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), (GtkWidget *)doc_widget->url, 1,2,i+1,i+2);
779 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), (GtkWidget *)doc_widget->description, 2,3,i+1,i+2);
780 /* after create we add element in the wideget list */
781 prop_dialog->url_docs=g_list_append(prop_dialog->url_docs,doc_widget);
782
783 gtk_widget_show (prop_dialog->table_document);
784 gtk_widget_show_all (prop_dialog->vbox_document);
785 gtk_widget_show (prop_dialog->page_label_document);
786 prop_dialog->nb_doc=i+1;
787 }
788
789 static void
document_fill_in_dialog(ObjetSISSI * object_sissi)790 document_fill_in_dialog(ObjetSISSI *object_sissi)
791 {
792 /* GList *list; */
793 SISSIDialog *prop_dialog;
794 unsigned int i;
795
796 prop_dialog = object_sissi->properties_dialog;
797 prop_dialog->url_docs=clear_list_url_doc_widget(prop_dialog->url_docs);
798
799 g_list_free (prop_dialog->url_docs);
800 prop_dialog->url_docs = NULL;
801
802 for (i=0;i<g_list_length(object_sissi->url_docs);i++)
803 {
804 Url_Docs_Widget *doc_widget;
805 doc_widget=g_malloc0(sizeof(Url_Docs_Widget));
806 doc_widget->label = gtk_entry_new();
807 gtk_entry_set_text((GtkEntry *)doc_widget->label, (((Url_Docs *)(g_list_nth(object_sissi->url_docs,i)->data))->label));
808 doc_widget->url = gtk_entry_new();
809 gtk_entry_set_text((GtkEntry *)doc_widget->url, (((Url_Docs *)(g_list_nth(object_sissi->url_docs,i)->data))->url));
810 doc_widget->description= gtk_entry_new();
811 gtk_entry_set_text((GtkEntry *)doc_widget->description, (((Url_Docs *)(g_list_nth(object_sissi->url_docs,i)->data))->description));
812
813 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), (GtkWidget *)doc_widget->label, 0, 1, i+2, i+3);
814 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), (GtkWidget *)doc_widget->url, 1,2,i+2, i+3);
815 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), (GtkWidget *)doc_widget->description, 2,3,i+2, i+3);
816 /************ idem ************/
817 prop_dialog->url_docs=g_list_append(prop_dialog->url_docs,doc_widget);
818 }
819 prop_dialog->nb_doc=i;
820 gtk_widget_show (prop_dialog->table_document);
821 gtk_widget_show_all (prop_dialog->vbox_document);
822 gtk_widget_show (prop_dialog->page_label_document);
823 }
824
document_read_from_dialog(ObjetSISSI * object_sissi,SISSIDialog * prop_dialog)825 static void document_read_from_dialog(ObjetSISSI *object_sissi, SISSIDialog *prop_dialog)
826 {
827 /* GList *list; */
828 unsigned int i;
829
830 object_sissi->url_docs=clear_list_url_doc(object_sissi->url_docs);
831 for (i=0;i<g_list_length(prop_dialog->url_docs);i++)
832 {
833 Url_Docs *doc;
834 doc=g_malloc0(sizeof(Url_Docs));
835 doc->label = g_strdup(gtk_entry_get_text((GtkEntry *)(((Url_Docs_Widget *)(g_list_nth(prop_dialog->url_docs,i)->data))->label)));
836 doc->url = g_strdup(gtk_entry_get_text((GtkEntry *)(((Url_Docs_Widget *)(g_list_nth(prop_dialog->url_docs,i)->data))->url)));
837 doc->description = g_strdup(gtk_entry_get_text((GtkEntry *)(((Url_Docs_Widget *)(g_list_nth(prop_dialog->url_docs,i)->data))->description)));
838 if((strcmp(doc->label,"")==0)&&(strcmp(doc->url,"")==0)&&(strcmp(doc->description,"")==0))
839 {
840 g_free(doc->label);
841 g_free(doc->url);
842 g_free(doc->description);
843 g_free(doc);
844 }
845 else
846 {
847 object_sissi->url_docs=g_list_append(object_sissi->url_docs, doc);
848 }
849 }
850 }
851
document_create_page(GtkNotebook * notebook,ObjetSISSI * object_sissi)852 static void document_create_page(GtkNotebook *notebook, ObjetSISSI *object_sissi)
853 {
854 SISSIDialog *prop_dialog;
855 GtkWidget *label,*button;
856 /* GtkWidget *menu_classification, *menu_integrity, *menu_disponibility_level, *disponibility_value;
857 GtkWidget *menu_entity; */
858
859 prop_dialog = object_sissi->properties_dialog;
860
861 /* Other properties of page */
862 prop_dialog->page_label_document = gtk_label_new_with_mnemonic (_("Documents"));
863
864 prop_dialog->vbox_document = gtk_vbox_new(FALSE, 1);
865 gtk_container_set_border_width (GTK_CONTAINER (prop_dialog->vbox_document), 0);
866
867 prop_dialog->table_document = gtk_table_new (43, 3, FALSE);
868 gtk_box_pack_start (GTK_BOX (prop_dialog->vbox_document), prop_dialog->table_document, FALSE, FALSE, 0);
869
870
871 button = gtk_button_new_with_mnemonic (_("_New"));
872 gtk_signal_connect (GTK_OBJECT (button), "clicked",
873 GTK_SIGNAL_FUNC(document_new_callback),
874 object_sissi);
875
876 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), button, 0, 1, 0, 1);
877
878 label = gtk_label_new (_("Document title"));
879 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), label, 0, 1, 1, 2);
880 label = gtk_label_new (_("URL"));
881 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), label, 1, 2, 1, 2);
882 label = gtk_label_new (_("Description"));
883 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_document), label, 2, 3, 1, 2);
884
885 gtk_widget_show_all (prop_dialog->vbox_document);
886 gtk_widget_show (prop_dialog->page_label_document);
887 gtk_notebook_append_page(notebook, prop_dialog->vbox_document, prop_dialog->page_label_document);
888 prop_dialog->nb_doc=0;
889 }
890
891
switch_page_callback(GtkNotebook * notebook,GtkNotebookPage * page)892 static void switch_page_callback(GtkNotebook *notebook, GtkNotebookPage *page)
893 {
894 ObjetSISSI *object_sissi;
895 SISSIDialog *prop_dialog;
896
897 object_sissi = (ObjetSISSI *)
898 gtk_object_get_user_data(GTK_OBJECT(notebook));
899
900 prop_dialog = object_sissi->properties_dialog;
901
902 if (prop_dialog != NULL) {
903 }
904 }
905
906 static void
destroy_properties_dialog(GtkWidget * widget,gpointer user_data)907 destroy_properties_dialog (GtkWidget* widget, gpointer user_data)
908 {
909
910 ObjetSISSI *object_sissi = (ObjetSISSI *)user_data;
911 object_sissi->properties_dialog->properties_menaces=clear_list_property_menace_widget(object_sissi->properties_dialog->properties_menaces);
912 object_sissi->properties_dialog->properties_others=clear_list_property_widget(object_sissi->properties_dialog->properties_others);
913 object_sissi->properties_dialog->url_docs=clear_list_url_doc_widget(object_sissi->properties_dialog->url_docs);
914 gtk_widget_destroy(object_sissi->properties_dialog->confidentiality);
915 gtk_widget_destroy(object_sissi->properties_dialog->integrity);
916 gtk_widget_destroy(object_sissi->properties_dialog->disponibility_level);
917 gtk_widget_destroy(object_sissi->properties_dialog->disponibility_value);
918 gtk_widget_destroy(object_sissi->properties_dialog->entity);
919 gtk_widget_destroy((GtkWidget *)object_sissi->properties_dialog->name);
920
921 g_free(object_sissi->properties_dialog);
922 object_sissi->properties_dialog = NULL;
923 }
924
fill_in_dialog(ObjetSISSI * object_sissi)925 static void fill_in_dialog(ObjetSISSI *object_sissi)
926 {
927 unsigned int i,pos=0;
928 SISSIDialog *prop_dialog;
929
930 prop_dialog = object_sissi->properties_dialog;
931 /********* update the classification ***********/
932 if (object_sissi->confidentiality!=NULL){
933 for (i = 0; property_classification_data[i].label != NULL; i++) {
934 if (0==strcmp(property_classification_data[i].value,object_sissi->confidentiality)) {
935 pos = i;
936 break;
937 }
938 }
939 }
940 gtk_option_menu_set_history(GTK_OPTION_MENU(prop_dialog->confidentiality), pos);
941
942 if (object_sissi->integrity!=NULL){
943 for (i = 0; property_integrity_data[i].label != NULL; i++) {
944 if (0==strcmp(property_integrity_data[i].value,object_sissi->integrity)) {
945 pos = i;
946 break;
947 }
948 }
949 }
950 gtk_option_menu_set_history(GTK_OPTION_MENU(prop_dialog->integrity), pos);
951
952 if (object_sissi->disponibility_level!=NULL){
953 for (i = 0; property_disponibility_level_data[i].label != NULL; i++) {
954 if (0==strcmp(property_disponibility_level_data[i].value,object_sissi->disponibility_level)) {
955 pos = i;
956 break;
957 }
958 }
959 }
960 gtk_option_menu_set_history(GTK_OPTION_MENU(prop_dialog->disponibility_level), pos);
961 gtk_spin_button_set_value(GTK_SPIN_BUTTON(prop_dialog->disponibility_value),object_sissi->disponibility_value);
962
963 /****** update the entity ******/
964 if (object_sissi->entity!=NULL){
965 /*** choice of list by rntite type */
966 if (0==strcmp(object_sissi->entity_type,"SYSTEM")){
967 for (i = 0; property_system_data[i].label != NULL; i++) {
968 if (0==strcmp(property_system_data[i].value,object_sissi->entity)) {
969 pos = i;
970 break;
971 }
972 }
973 }
974 if (0==strcmp(object_sissi->entity_type,"ORGANIZATION")){
975 for (i = 0; property_organisation_data[i].label != NULL; i++) {
976 if (0==strcmp(property_organisation_data[i].value,object_sissi->entity)) {
977 pos = i;
978 break;
979 }
980 }
981 }
982 if (0==strcmp(object_sissi->entity_type,"PHYSIC")){
983 for (i = 0; property_physic_data[i].label != NULL; i++) {
984 if (0==strcmp(property_physic_data[i].value,object_sissi->entity)) {
985 pos = i;
986 break;
987 }
988 }
989 }
990 if (0==strcmp(object_sissi->entity_type,"PERSON")){
991 for (i = 0; property_personnel_data[i].label != NULL; i++) {
992 if (0==strcmp(property_personnel_data[i].value,object_sissi->entity)) {
993 pos = i;
994 break;
995 }
996 }
997 }
998 if (0==strcmp(object_sissi->entity_type,"NETWORK")){
999 for (i = 0; property_reseau_data[i].label != NULL; i++) {
1000 if (0==strcmp(property_reseau_data[i].value,object_sissi->entity)) {
1001 pos = i;
1002 break;
1003 }
1004 }
1005 }
1006 if (0==strcmp(object_sissi->entity_type,"SOFTWARE")){
1007 for (i = 0; property_logiciel_data[i].label != NULL; i++) {
1008 if (0==strcmp(property_logiciel_data[i].value,object_sissi->entity)) {
1009 pos = i;
1010 break;
1011 }
1012 }
1013 }
1014 if (0==strcmp(object_sissi->entity_type,"MATERIAL")){
1015 for (i = 0; property_material_data[i].label != NULL; i++) {
1016 if (0==strcmp(property_material_data[i].value,object_sissi->entity)) {
1017 pos = i;
1018 break;
1019 }
1020 }
1021 }
1022 }
1023 gtk_option_menu_set_history(GTK_OPTION_MENU(prop_dialog->entity), pos);
1024
1025 /*********** update the properties list **********/
1026 for (i=0;i<g_list_length(object_sissi->properties_menaces);i++)
1027 {
1028 gtk_spin_button_set_value(GTK_SPIN_BUTTON(((SISSI_Property_Menace_Widget *)(g_list_nth(prop_dialog->properties_menaces,i)->data))->action), (((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->action));
1029 /**********************************/
1030 gtk_spin_button_set_value(GTK_SPIN_BUTTON(((SISSI_Property_Menace_Widget *)(g_list_nth(prop_dialog->properties_menaces,i)->data))->detection), (((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->detection));
1031 /**********************************/
1032 gtk_spin_button_set_value(GTK_SPIN_BUTTON(((SISSI_Property_Menace_Widget *)(g_list_nth(prop_dialog->properties_menaces,i)->data))->vulnerability), (((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->vulnerability));
1033 gtk_entry_set_text((GtkEntry *)((SISSI_Property_Menace_Widget *)(g_list_nth(prop_dialog->properties_menaces,i)->data))->comments, (((SISSI_Property_Menace *)(g_list_nth(object_sissi->properties_menaces,i)->data))->comments));
1034 /*fprintf(stderr,"espion fill 2\n");*/
1035 }
1036
1037 if (object_sissi->name != NULL)
1038 gtk_entry_set_text((GtkEntry *)prop_dialog->name,(char *)object_sissi->name);
1039 else
1040 gtk_entry_set_text((GtkEntry *)prop_dialog->name, "");
1041
1042 document_fill_in_dialog(object_sissi);
1043
1044 prop_dialog->properties_others=clear_list_property_widget(prop_dialog->properties_others);
1045 for (i=0;i<g_list_length(object_sissi->properties_others);i++)
1046 {
1047 SISSI_Property_Widget *property_others_widget;
1048 property_others_widget=g_malloc0(sizeof(SISSI_Property_Widget));
1049 if(i < object_sissi->nb_others_fixes)
1050 {
1051 /* if the case is empty we put NULL for no have problem in traduction */
1052 if ((((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->label)!=NULL)
1053 {
1054 if (strcmp((((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->label),"")==0)
1055 { property_others_widget->label = gtk_label_new (NULL);}
1056 else
1057 { property_others_widget->label = gtk_label_new (_(((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->label));}
1058 }
1059 else
1060 {
1061 property_others_widget->label = gtk_label_new (NULL);
1062 }
1063
1064 if ((((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->description)!=NULL)
1065 {
1066 if (strcmp((((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->description),"")==0)
1067 { property_others_widget->description = gtk_label_new (NULL);}
1068 else
1069 { property_others_widget->description = gtk_label_new (_(((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->description));}
1070 }
1071 else
1072 {
1073 property_others_widget->description = gtk_label_new (NULL);
1074 }
1075
1076 }
1077 else
1078 {
1079 property_others_widget->label = gtk_entry_new();
1080 gtk_entry_set_text((GtkEntry *)property_others_widget->label, (((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->label));
1081 property_others_widget->description= gtk_entry_new();
1082 gtk_entry_set_text((GtkEntry *)property_others_widget->description, (((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->description));
1083 }
1084 property_others_widget->value = gtk_entry_new();
1085 if ((((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->value)!=NULL)
1086 gtk_entry_set_text((GtkEntry *)property_others_widget->value, (((SISSI_Property *)(g_list_nth(object_sissi->properties_others,i)->data))->value));
1087
1088 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), (GtkWidget *)property_others_widget->label, 0, 1, i+5, i+6);
1089 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), (GtkWidget *)property_others_widget->value, 1,2,i+5,i+6);
1090 gtk_table_attach_defaults (GTK_TABLE (prop_dialog->table_others), (GtkWidget *)property_others_widget->description, 2,3,i+5,i+6);
1091 prop_dialog->properties_others=g_list_append(prop_dialog->properties_others,property_others_widget);
1092 }
1093 prop_dialog->nb_properties_others=i;
1094
1095 gtk_widget_show (prop_dialog->table_others);
1096 gtk_widget_show_all (prop_dialog->vbox_others);
1097 gtk_widget_show (prop_dialog->page_label_others);
1098
1099 }
1100 /* apply the properties of dialog box to Object */
1101 ObjectChange *
object_sissi_apply_properties_dialog(ObjetSISSI * object_sissi)1102 object_sissi_apply_properties_dialog(ObjetSISSI *object_sissi)
1103 {
1104 SISSIDialog *prop_dialog;
1105 DiaObject *obj;
1106 GList *added = NULL;
1107 GList *deleted = NULL;
1108 GList *disconnected = NULL;
1109 SISSIState *old_state = NULL;
1110 prop_dialog = object_sissi->properties_dialog;
1111
1112
1113 g_return_val_if_fail(prop_dialog != NULL, NULL);
1114
1115 obj = &object_sissi->element.object;
1116 properties_menaces_read_from_dialog(object_sissi, prop_dialog);
1117 properties_others_read_from_dialog(object_sissi, prop_dialog);
1118 document_read_from_dialog(object_sissi, prop_dialog);
1119 object_sissi_update_data(object_sissi, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
1120 return new_sissi_change(object_sissi, old_state, added, deleted, disconnected);
1121 }
1122
create_dialog_pages(GtkNotebook * notebook,ObjetSISSI * object_sissi)1123 static void create_dialog_pages(GtkNotebook *notebook, ObjetSISSI *object_sissi)
1124 {
1125 properties_others_create_page(notebook, object_sissi);
1126 properties_menaces_create_page(notebook, object_sissi);
1127 document_create_page(notebook, object_sissi);
1128 }
1129
object_sissi_get_properties_dialog(ObjetSISSI * object_sissi,gboolean is_default)1130 extern GtkWidget *object_sissi_get_properties_dialog(ObjetSISSI *object_sissi, gboolean is_default)
1131 {
1132 SISSIDialog *prop_dialog;
1133 GtkWidget *vbox;
1134 GtkWidget *notebook;
1135 /* GtkObject *Adjust; */
1136
1137 if (object_sissi->properties_dialog == NULL) {
1138 prop_dialog = g_new(SISSIDialog, 1);
1139 object_sissi->properties_dialog = prop_dialog;
1140
1141 /**** initialisation of properties list **********/
1142
1143 vbox = gtk_vbox_new(FALSE, 0);
1144 gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
1145
1146 gtk_object_ref(GTK_OBJECT(vbox));
1147 gtk_object_sink(GTK_OBJECT(vbox));
1148
1149 prop_dialog->dialog = vbox;
1150
1151
1152 /************ initialisation of data ****************/
1153 prop_dialog->properties_menaces=NULL;
1154 prop_dialog->properties_others = NULL;
1155 prop_dialog->url_docs = NULL;
1156
1157 notebook = gtk_notebook_new ();
1158
1159 gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
1160 gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
1161 /* fixing the width of dialog box */
1162 gtk_container_set_border_width (GTK_CONTAINER (notebook), 0);
1163
1164 gtk_object_set_user_data(GTK_OBJECT(notebook), (gpointer) object_sissi);
1165
1166 gtk_signal_connect (GTK_OBJECT (notebook),
1167 "switch_page",
1168 GTK_SIGNAL_FUNC(switch_page_callback),
1169 (gpointer) object_sissi);
1170 gtk_signal_connect (GTK_OBJECT (object_sissi->properties_dialog->dialog),
1171 "destroy",
1172 GTK_SIGNAL_FUNC(destroy_properties_dialog),
1173 (gpointer) object_sissi);
1174
1175 create_dialog_pages(GTK_NOTEBOOK( notebook ), object_sissi);
1176
1177 gtk_widget_show (notebook);
1178 }
1179
1180 fill_in_dialog(object_sissi);
1181 gtk_widget_show (object_sissi->properties_dialog->dialog);
1182 return object_sissi->properties_dialog->dialog;
1183 }
1184
1185