summaryrefslogtreecommitdiff
path: root/src/dumm/main.c
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:34:14 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:34:14 +0000
commited7d79f96177044949744da10f4431c1d6242241 (patch)
tree3aabaa55ed3b5291daef891cfee9befb5235e2b8 /src/dumm/main.c
parent7410d3c6d6a9a1cd7aa55083c938946af6ff9498 (diff)
downloadvyos-strongswan-ed7d79f96177044949744da10f4431c1d6242241.tar.gz
vyos-strongswan-ed7d79f96177044949744da10f4431c1d6242241.zip
[svn-upgrade] Integrating new upstream version, strongswan (4.3.6)
Diffstat (limited to 'src/dumm/main.c')
-rw-r--r--src/dumm/main.c134
1 files changed, 67 insertions, 67 deletions
diff --git a/src/dumm/main.c b/src/dumm/main.c
index ba2801760..337a1a144 100644
--- a/src/dumm/main.c
+++ b/src/dumm/main.c
@@ -62,7 +62,7 @@ static void child_exited(VteReaper *vtereaper, gint pid, gint status)
{
enumerator_t *enumerator;
page_t *page;
-
+
enumerator = pages->create_enumerator(pages);
while (enumerator->enumerate(enumerator, (void**)&page))
{
@@ -81,7 +81,7 @@ static page_t* get_page(int num)
{
enumerator_t *enumerator;
page_t *page, *found = NULL;
-
+
enumerator = pages->create_enumerator(pages);
while (enumerator->enumerate(enumerator, (void**)&page))
{
@@ -114,7 +114,7 @@ void idle(void)
static void start_guest()
{
page_t *page;
-
+
page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
if (page && page->guest->get_state(page->guest) == GUEST_STOPPED)
{
@@ -128,7 +128,7 @@ static void start_all_guests()
{
enumerator_t *enumerator;
page_t *page;
-
+
enumerator = pages->create_enumerator(pages);
while (enumerator->enumerate(enumerator, (void**)&page))
{
@@ -146,7 +146,7 @@ static void start_all_guests()
static void stop_guest()
{
page_t *page;
-
+
page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
if (page && page->guest->get_state(page->guest) == GUEST_RUNNING)
{
@@ -163,17 +163,17 @@ static void quit()
page_t *page;
dumm->load_template(dumm, NULL);
-
+
enumerator = pages->create_enumerator(pages);
while (enumerator->enumerate(enumerator, &page))
{
if (page->guest->get_state(page->guest) != GUEST_STOPPED)
- {
+ {
page->guest->stop(page->guest, idle);
}
}
enumerator->destroy(enumerator);
- gtk_main_quit();
+ gtk_main_quit();
}
static void error_dialog(char *msg)
@@ -191,32 +191,32 @@ static void create_switch()
{
GtkWidget *dialog, *table, *label, *name;
bridge_t *bridge;
-
+
dialog = gtk_dialog_new_with_buttons("Create new switch", GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL);
-
+
table = gtk_table_new(1, 2, TRUE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
-
+
label = gtk_label_new("Switch name");
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 0, 0);
gtk_widget_show(label);
-
+
name = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
gtk_widget_show(name);
-
+
gtk_widget_show(table);
-
+
while (TRUE)
{
switch (gtk_dialog_run(GTK_DIALOG(dialog)))
{
case GTK_RESPONSE_ACCEPT:
- {
+ {
if (streq(gtk_entry_get_text(GTK_ENTRY(name)), ""))
{
continue;
@@ -250,34 +250,34 @@ static void connect_guest()
bridge_t *bridge;
iface_t *iface;
enumerator_t *enumerator;
-
+
page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
if (!page || page->guest->get_state(page->guest) != GUEST_RUNNING)
{
return;
}
-
+
dialog = gtk_dialog_new_with_buttons("Connect guest", GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL);
-
+
table = gtk_table_new(2, 2, TRUE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
-
+
label = gtk_label_new("Interface name");
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 0, 0);
gtk_widget_show(label);
-
+
name = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
gtk_widget_show(name);
-
+
label = gtk_label_new("Connected switch");
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, 0, 0, 0, 0);
gtk_widget_show(label);
-
+
box = gtk_combo_box_new_text();
gtk_table_attach(GTK_TABLE(table), box, 1, 2, 1, 2,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
@@ -288,20 +288,20 @@ static void connect_guest()
}
enumerator->destroy(enumerator);
gtk_widget_show(box);
-
+
gtk_widget_show(table);
-
+
while (TRUE)
{
switch (gtk_dialog_run(GTK_DIALOG(dialog)))
{
case GTK_RESPONSE_ACCEPT:
- {
+ {
if (streq(gtk_entry_get_text(GTK_ENTRY(name)), ""))
{
continue;
}
-
+
iface = page->guest->create_iface(page->guest,
(char*)gtk_entry_get_text(GTK_ENTRY(name)));
if (!iface)
@@ -337,7 +337,7 @@ static void disconnect_guest()
static void delete_guest()
{
page_t *page;
-
+
page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
if (page)
{
@@ -356,7 +356,7 @@ static page_t* create_page(guest_t *guest)
{
GtkWidget *label;
page_t *page;
-
+
page = g_new(page_t, 1);
page->guest = guest;
page->vte = vte_terminal_new();
@@ -375,55 +375,55 @@ static void create_guest()
{
guest_t *guest;
GtkWidget *dialog, *table, *label, *name, *kernel, *master, *args;
-
+
dialog = gtk_dialog_new_with_buttons("Create new guest", GTK_WINDOW(window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL);
-
+
table = gtk_table_new(4, 2, TRUE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
-
+
label = gtk_label_new("Guest name");
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 0, 0);
gtk_widget_show(label);
-
+
label = gtk_label_new("UML kernel");
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, 0, 0, 0, 0);
gtk_widget_show(label);
-
+
label = gtk_label_new("Master filesystem");
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, 0, 0, 0, 0);
gtk_widget_show(label);
-
+
label = gtk_label_new("Kernel arguments");
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, 0, 0, 0, 0);
gtk_widget_show(label);
-
+
name = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
gtk_widget_show(name);
-
+
kernel = gtk_file_chooser_button_new("Select UML kernel image",
GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_table_attach(GTK_TABLE(table), kernel, 1, 2, 1, 2,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
gtk_widget_show(kernel);
-
+
master = gtk_file_chooser_button_new("Select master filesystem",
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
gtk_table_attach(GTK_TABLE(table), master, 1, 2, 2, 3,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
gtk_widget_show(master);
-
+
args = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), args, 1, 2, 3, 4,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0);
gtk_widget_show(args);
-
+
gtk_widget_show(table);
-
+
while (TRUE)
{
switch (gtk_dialog_run(GTK_DIALOG(dialog)))
@@ -432,12 +432,12 @@ static void create_guest()
{
char *sname, *skernel, *smaster, *sargs;
page_t *page;
-
+
sname = (char*)gtk_entry_get_text(GTK_ENTRY(name));
skernel = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(kernel));
smaster = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(master));
sargs = (char*)gtk_entry_get_text(GTK_ENTRY(args));
-
+
if (!sname[0] || !skernel || !smaster)
{
continue;
@@ -469,10 +469,10 @@ int main(int argc, char *argv[])
GtkWidget *dummMenu, *guestMenu, *switchMenu;
enumerator_t *enumerator;
guest_t *guest;
-
+
library_init(NULL);
gtk_init(&argc, &argv);
-
+
pages = linked_list_create();
dumm = dumm_create(NULL);
@@ -483,7 +483,7 @@ int main(int argc, char *argv[])
gtk_window_set_default_size(GTK_WINDOW (window), 1000, 500);
g_signal_connect(G_OBJECT(vte_reaper_get()), "child-exited",
G_CALLBACK(child_exited), NULL);
-
+
/* add vbox with menubar, notebook */
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), vbox);
@@ -492,15 +492,15 @@ int main(int argc, char *argv[])
notebook = gtk_notebook_new();
g_object_set(G_OBJECT(notebook), "homogeneous", TRUE, NULL);
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);
- gtk_container_add(GTK_CONTAINER(vbox), notebook);
+ gtk_container_add(GTK_CONTAINER(vbox), notebook);
/* Dumm menu */
menu = gtk_menu_new();
- dummMenu = gtk_menu_item_new_with_mnemonic("_Dumm");
+ dummMenu = gtk_menu_item_new_with_mnemonic("_Dumm");
gtk_menu_bar_append(GTK_MENU_BAR(menubar), dummMenu);
gtk_widget_show(dummMenu);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(dummMenu), menu);
-
+
/* Dumm -> exit */
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate",
@@ -510,61 +510,61 @@ int main(int argc, char *argv[])
/* Guest menu */
menu = gtk_menu_new();
- guestMenu = gtk_menu_item_new_with_mnemonic("_Guest");
+ guestMenu = gtk_menu_item_new_with_mnemonic("_Guest");
gtk_menu_bar_append(GTK_MENU_BAR(menubar), guestMenu);
gtk_widget_show(guestMenu);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(guestMenu), menu);
-
+
/* Guest -> new */
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(create_guest), NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
/* Guest -> delete */
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(delete_guest), NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
menuitem = gtk_separator_menu_item_new();
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
/* Guest -> start */
menuitem = gtk_menu_item_new_with_mnemonic("_Start");
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(start_guest), NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
/* Guest -> startall */
menuitem = gtk_menu_item_new_with_mnemonic("Start _all");
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(start_all_guests), NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
/* Guest -> stop */
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_STOP, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(stop_guest), NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
menuitem = gtk_separator_menu_item_new();
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
/* Guest -> connect */
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_CONNECT, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(connect_guest), NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
/* Guest -> disconnect */
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DISCONNECT, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate",
@@ -575,18 +575,18 @@ int main(int argc, char *argv[])
/* Switch menu */
menu = gtk_menu_new();
- switchMenu = gtk_menu_item_new_with_mnemonic("_Switch");
+ switchMenu = gtk_menu_item_new_with_mnemonic("_Switch");
gtk_menu_bar_append(GTK_MENU_BAR(menubar), switchMenu);
gtk_widget_show(switchMenu);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(switchMenu), menu);
-
+
/* Switch -> new */
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(create_switch), NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
-
+
/* Switch -> delete */
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate",
@@ -594,13 +594,13 @@ int main(int argc, char *argv[])
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_set_sensitive(menuitem, FALSE);
gtk_widget_show(menuitem);
-
- /* show widgets */
+
+ /* show widgets */
gtk_widget_show(menubar);
gtk_widget_show(notebook);
gtk_widget_show(vbox);
gtk_widget_show(window);
-
+
/* fill notebook with guests */
enumerator = dumm->create_guest_enumerator(dumm);
while (enumerator->enumerate(enumerator, (void**)&guest))
@@ -608,12 +608,12 @@ int main(int argc, char *argv[])
create_page(guest);
}
enumerator->destroy(enumerator);
-
+
gtk_main();
-
+
dumm->destroy(dumm);
pages->destroy_function(pages, g_free);
-
+
library_deinit();
return 0;
}