forked from enlightenment/enlightenment
Add a way to save error messages from e_app_error dialogue. Logs default to ~/<appname>.log . Add 2 missing function protos. Some formatting.
SVN revision: 20560
This commit is contained in:
parent
47e7c5f243
commit
3c25682444
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
#include "e.h"
|
||||
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
char *label;
|
||||
|
@ -11,12 +10,14 @@ struct _E_Config_Dialog_Data
|
|||
char *signal;
|
||||
};
|
||||
|
||||
|
||||
/* Protos */
|
||||
static void * _e_app_error_dialog_create_data(E_Config_Dialog *cfd);
|
||||
static void _e_app_error_dialog_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_e_app_error_dialog_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_e_app_error_dialog_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _e_app_error_dialog_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static Evas_Object *_e_app_error_dialog_scrolltext_create(Evas *evas, char *title, Ecore_Exe_Event_Data_Line *lines);
|
||||
static void _e_app_error_dialog_save_cb(void *data, void *data2);
|
||||
|
||||
EAPI void
|
||||
e_app_error_dialog(E_Container *con, E_App_Autopsy *app)
|
||||
|
@ -90,7 +91,7 @@ _e_app_error_dialog_fill_data(E_App_Autopsy *app, E_Config_Dialog_Data *cfdata)
|
|||
snprintf(buf, sizeof(buf), _("%s was interrupted by the signal number %i"),
|
||||
app->app->exe, app->del.exit_signal);
|
||||
cfdata->signal = strdup(buf);
|
||||
/* FIXME: Add sigchld_info stuff
|
||||
/* FIXME: Add sigchld_info stuff
|
||||
* app->del.data
|
||||
* siginfo_t
|
||||
* {
|
||||
|
@ -226,6 +227,9 @@ _e_app_error_dialog_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Con
|
|||
e_widget_list_object_append(o, ob, 1, 1, 0.5);
|
||||
}
|
||||
|
||||
ob = e_widget_button_add(evas, _("Save This Message"), "enlightenment/run", _e_app_error_dialog_save_cb, app, cfdata);
|
||||
e_widget_list_object_append(o, ob, 0, 0, 0.5);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -268,8 +272,8 @@ _e_app_error_dialog_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_
|
|||
if (read_length)
|
||||
{
|
||||
of = _e_app_error_dialog_scrolltext_create(evas, _("Output Data"), app->read->lines);
|
||||
/* FIXME: Add stdout "start". */
|
||||
/* FIXME: Add stdout "end". */
|
||||
/* FIXME: Add stdout "start". */
|
||||
/* FIXME: Add stdout "end". */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -284,8 +288,8 @@ _e_app_error_dialog_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_
|
|||
if (error_length)
|
||||
{
|
||||
of = _e_app_error_dialog_scrolltext_create(evas, _("Error Logs"), app->error->lines);
|
||||
/* FIXME: Add stderr "start". */
|
||||
/* FIXME: Add stderr "end". */
|
||||
/* FIXME: Add stderr "start". */
|
||||
/* FIXME: Add stderr "end". */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -297,5 +301,100 @@ _e_app_error_dialog_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_
|
|||
|
||||
e_widget_list_object_append(o, ot, 1, 1, 0.5);
|
||||
|
||||
ob = e_widget_button_add(evas, _("Save This Message"), "enlightenment/run", _e_app_error_dialog_save_cb, app, cfdata);
|
||||
e_widget_list_object_append(o, ob, 0, 0, 0.5);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_app_error_dialog_save_cb(void *data, void *data2)
|
||||
{
|
||||
E_App_Autopsy *app;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
FILE *f;
|
||||
char *text;
|
||||
char buf[1024];
|
||||
char buffer[4096];
|
||||
int read_length = 0;
|
||||
int i, tlen;
|
||||
|
||||
app = data;
|
||||
cfdata = data2;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s.log", e_user_homedir_get(), app->app->name);
|
||||
f = fopen(buf, "w");
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
if (cfdata->exit)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Error Information:\n\t%s\n\n", cfdata->exit);
|
||||
fwrite(buffer, sizeof(char), strlen(buffer), f);
|
||||
}
|
||||
if (cfdata->signal)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Error Signal Information:\n\t%s\n\n", cfdata->signal);
|
||||
fwrite(buffer, sizeof(char), strlen(buffer), f);
|
||||
}
|
||||
|
||||
if (app->read)
|
||||
read_length = app->read->size;
|
||||
|
||||
if (read_length)
|
||||
{
|
||||
tlen = 0;
|
||||
for (i = 0; app->read->lines[i].line != NULL; i++)
|
||||
tlen += app->read->lines[i].size + 1;
|
||||
text = alloca(tlen + 1);
|
||||
if (text)
|
||||
{
|
||||
text[0] = 0;
|
||||
for (i = 0; app->read->lines[i].line != NULL; i++)
|
||||
{
|
||||
strcat(text, "\t");
|
||||
strcat(text, app->read->lines[i].line);
|
||||
strcat(text, "\n");
|
||||
}
|
||||
snprintf(buffer, sizeof(buffer), "Output Data:\n%s\n\n", text);
|
||||
fwrite(buffer, sizeof(char), strlen(buffer), f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Output Data:\n\tThere was no output\n\n");
|
||||
fwrite(buffer, sizeof(char), strlen(buffer), f);
|
||||
}
|
||||
|
||||
/* Reusing this var */
|
||||
read_length = 0;
|
||||
if (app->error)
|
||||
read_length = app->error->size;
|
||||
|
||||
if (read_length)
|
||||
{
|
||||
tlen = 0;
|
||||
for (i = 0; app->error->lines[i].line != NULL; i++)
|
||||
tlen += app->error->lines[i].size + 1;
|
||||
text = alloca(tlen + 1);
|
||||
if (text)
|
||||
{
|
||||
text[0] = 0;
|
||||
for (i = 0; app->error->lines[i].line != NULL; i++)
|
||||
{
|
||||
strcat(text, "\t");
|
||||
strcat(text, app->error->lines[i].line);
|
||||
strcat(text, "\n");
|
||||
}
|
||||
snprintf(buffer, sizeof(buffer), "Error Logs:\n%s\n", text);
|
||||
fwrite(buffer, sizeof(char), strlen(buffer), f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Error Logs:\n\tThere was no error message\n");
|
||||
fwrite(buffer, sizeof(char), strlen(buffer), f);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue