Commit 0241785a authored by winckel's avatar winckel
Browse files

Moved operation running test to cover also reload operations.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4863 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent bb84c46c
......@@ -29,8 +29,9 @@
#include "locate_root.h"
#include "xml_parse.h"
static gboolean refresh_message_list = TRUE;
static gboolean filters_changed = FALSE;
static gboolean refresh_message_list = TRUE;
static gboolean filters_changed = FALSE;
static gboolean operation_running = FALSE;
gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
{
......@@ -38,13 +39,18 @@ gboolean ui_callback_on_open_messages(GtkWidget *widget, gpointer data)
g_message("Open messages event occurred %d", refresh);
if (refresh && (ui_main_data.messages_file_name != NULL))
if (operation_running == FALSE)
{
CHECK_FCT(ui_messages_read (ui_main_data.messages_file_name));
}
else
{
CHECK_FCT(ui_messages_open_file_chooser());
operation_running = TRUE;
if (refresh && (ui_main_data.messages_file_name != NULL))
{
CHECK_FCT(ui_messages_read (ui_main_data.messages_file_name));
}
else
{
CHECK_FCT(ui_messages_open_file_chooser());
}
operation_running = FALSE;
}
return TRUE;
......@@ -54,7 +60,12 @@ gboolean ui_callback_on_save_messages(GtkWidget *widget, gpointer data)
{
g_message("Save messages event occurred");
CHECK_FCT(ui_messages_save_file_chooser());
if (operation_running == FALSE)
{
operation_running = TRUE;
CHECK_FCT(ui_messages_save_file_chooser());
operation_running = FALSE;
}
return TRUE;
}
......@@ -93,13 +104,19 @@ gboolean ui_callback_on_open_filters(GtkWidget *widget, gpointer data)
g_message("Open filters event occurred");
if (refresh && (ui_main_data.filters_file_name != NULL))
{
CHECK_FCT(ui_filters_read (ui_main_data.filters_file_name));
}
else
if (operation_running == FALSE)
{
CHECK_FCT(ui_filters_open_file_chooser());
operation_running = TRUE;
if (refresh && (ui_main_data.filters_file_name != NULL))
{
CHECK_FCT(ui_filters_read (ui_main_data.filters_file_name));
}
else
{
CHECK_FCT(ui_filters_open_file_chooser());
}
operation_running = FALSE;
}
return TRUE;
......@@ -107,8 +124,14 @@ gboolean ui_callback_on_open_filters(GtkWidget *widget, gpointer data)
gboolean ui_callback_on_save_filters(GtkWidget *widget, gpointer data)
{
g_message("Save filters event occurred");
CHECK_FCT(ui_filters_save_file_chooser());
if (operation_running == FALSE)
{
operation_running = TRUE;
g_message("Save filters event occurred");
CHECK_FCT(ui_filters_save_file_chooser());
operation_running = FALSE;
}
return TRUE;
}
......
......@@ -28,7 +28,6 @@
static const itti_message_types_t itti_dump_xml_definition_end = ITTI_DUMP_XML_DEFINITION_END;
static const itti_message_types_t itti_dump_message_type_end = ITTI_DUMP_MESSAGE_TYPE_END;
static gboolean chooser_running;
static FILE *messages_file;
static uint32_t message_number;
static gboolean ui_abort;
......@@ -357,45 +356,40 @@ int ui_messages_open_file_chooser(void)
{
int result = RC_OK;
if (chooser_running == FALSE)
{
GtkWidget *filechooser;
gboolean accept;
char *filename;
GtkWidget *filechooser;
gboolean accept;
char *filename;
chooser_running = TRUE;
filechooser = gtk_file_chooser_dialog_new ("Select file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Log files", "*.log");
gtk_filter_add (filechooser, "All files", "*");
filechooser = gtk_file_chooser_dialog_new ("Select file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Log files", "*.log");
gtk_filter_add (filechooser, "All files", "*");
/* Process the response */
accept = gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT;
/* Process the response */
accept = gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT;
if (accept)
{
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
}
gtk_widget_destroy (filechooser);
if (accept)
if (accept)
{
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
}
gtk_widget_destroy (filechooser);
if (accept)
{
result = ui_messages_read (filename);
if (result == RC_OK)
{
result = ui_messages_read (filename);
if (result == RC_OK)
{
/* Update messages file name for future use */
if (ui_main_data.messages_file_name != NULL)
{
g_free (ui_main_data.messages_file_name);
}
ui_main_data.messages_file_name = filename;
}
else
/* Update messages file name for future use */
if (ui_main_data.messages_file_name != NULL)
{
g_free (filename);
g_free (ui_main_data.messages_file_name);
}
ui_main_data.messages_file_name = filename;
}
else
{
g_free (filename);
}
chooser_running = FALSE;
}
return result;
}
......@@ -403,57 +397,50 @@ int ui_messages_open_file_chooser(void)
int ui_messages_save_file_chooser(void)
{
int result = RC_OK;
GtkWidget *filechooser;
if (chooser_running == FALSE)
/* Check if there is something to save */
if (xml_raw_data_size > 0)
{
GtkWidget *filechooser;
filechooser = gtk_file_chooser_dialog_new ("Save file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Log files", "*.log");
gtk_filter_add (filechooser, "All files", "*");
chooser_running = TRUE;
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (filechooser), TRUE);
/* Check if there is something to save */
if (xml_raw_data_size > 0)
if (ui_main_data.messages_file_name != NULL)
{
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser), ui_main_data.messages_file_name);
}
else
{
filechooser = gtk_file_chooser_dialog_new ("Save file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Log files", "*.log");
gtk_filter_add (filechooser, "All files", "*");
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filechooser), "messages.log");
}
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (filechooser), TRUE);
/* Process the response */
if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
if (ui_main_data.messages_file_name != NULL)
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
result = ui_messages_file_write (filename);
if (result == RC_OK)
{
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser), ui_main_data.messages_file_name);
/* Update filters file name for future use */
if (ui_main_data.messages_file_name != NULL)
{
g_free (ui_main_data.messages_file_name);
}
ui_main_data.messages_file_name = filename;
}
else
{
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filechooser), "messages.log");
}
/* Process the response */
if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
result = ui_messages_file_write (filename);
if (result == RC_OK)
{
/* Update filters file name for future use */
if (ui_main_data.messages_file_name != NULL)
{
g_free (ui_main_data.messages_file_name);
}
ui_main_data.messages_file_name = filename;
}
else
{
g_free (filename);
}
g_free (filename);
}
gtk_widget_destroy (filechooser);
}
chooser_running = FALSE;
gtk_widget_destroy (filechooser);
}
return result;
......@@ -462,47 +449,40 @@ int ui_messages_save_file_chooser(void)
int ui_filters_open_file_chooser(void)
{
int result = RC_OK;
GtkWidget *filechooser;
gboolean accept;
char *filename;
if (chooser_running == FALSE)
{
GtkWidget *filechooser;
gboolean accept;
char *filename;
chooser_running = TRUE;
filechooser = gtk_file_chooser_dialog_new ("Select file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Filters files", "*.xml");
gtk_filter_add (filechooser, "All files", "*");
filechooser = gtk_file_chooser_dialog_new ("Select file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Filters files", "*.xml");
gtk_filter_add (filechooser, "All files", "*");
/* Process the response */
accept = gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT;
/* Process the response */
accept = gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT;
if (accept)
{
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
}
gtk_widget_destroy (filechooser);
if (accept)
if (accept)
{
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
}
gtk_widget_destroy (filechooser);
if (accept)
{
result = ui_filters_read (filename);
if (result == RC_OK)
{
result = ui_filters_read (filename);
if (result == RC_OK)
/* Update filters file name for future use */
if (ui_main_data.filters_file_name != NULL)
{
/* Update filters file name for future use */
if (ui_main_data.filters_file_name != NULL)
{
g_free (ui_main_data.filters_file_name);
}
ui_main_data.filters_file_name = filename;
}
else
{
g_free (filename);
g_free (ui_main_data.filters_file_name);
}
ui_main_data.filters_file_name = filename;
}
else
{
g_free (filename);
}
chooser_running = FALSE;
}
return result;
......@@ -511,54 +491,47 @@ int ui_filters_open_file_chooser(void)
int ui_filters_save_file_chooser(void)
{
int result = RC_OK;
GtkWidget *filechooser;
if (chooser_running == FALSE)
{
GtkWidget *filechooser;
filechooser = gtk_file_chooser_dialog_new ("Save file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Filters files", "*.xml");
gtk_filter_add (filechooser, "All files", "*");
chooser_running = TRUE;
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (filechooser), TRUE);
filechooser = gtk_file_chooser_dialog_new ("Save file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_filter_add (filechooser, "Filters files", "*.xml");
gtk_filter_add (filechooser, "All files", "*");
if (ui_main_data.filters_file_name != NULL)
{
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser), ui_main_data.filters_file_name);
}
else
{
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filechooser), "filters.xml");
}
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (filechooser), TRUE);
/* Process the response */
if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
if (ui_main_data.filters_file_name != NULL)
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
result = ui_filters_file_write (filename);
if (result == RC_OK)
{
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser), ui_main_data.filters_file_name);
/* Update filters file name for future use */
if (ui_main_data.filters_file_name != NULL)
{
g_free (ui_main_data.filters_file_name);
}
ui_main_data.filters_file_name = filename;
}
else
{
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filechooser), "filters.xml");
}
/* Process the response */
if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
result = ui_filters_file_write (filename);
if (result == RC_OK)
{
/* Update filters file name for future use */
if (ui_main_data.filters_file_name != NULL)
{
g_free (ui_main_data.filters_file_name);
}
ui_main_data.filters_file_name = filename;
}
else
{
g_free (filename);
}
g_free (filename);
}
gtk_widget_destroy (filechooser);
chooser_running = FALSE;
}
gtk_widget_destroy (filechooser);
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment