2006-04-23 [colin] 2.1.1cvs23

* src/etpan/imap-thread.c
		Better logging (line-per-line, hide data in fetch)
		Fix a const warning
	* src/gtk/logwindow.c
	* src/gtk/logwindow.h
		Better logging (color for input/output)
This commit is contained in:
Colin Leroy 2006-04-23 11:30:37 +00:00
parent 82278066e5
commit 5ced13828e
6 changed files with 102 additions and 26 deletions

View file

@ -1,3 +1,12 @@
2006-04-23 [colin] 2.1.1cvs23
* src/etpan/imap-thread.c
Better logging (line-per-line, hide data in fetch)
Fix a const warning
* src/gtk/logwindow.c
* src/gtk/logwindow.h
Better logging (color for input/output)
2006-04-21 [colin] 2.1.1cvs22
* src/gtk/quicksearch.c

View file

@ -1444,3 +1444,4 @@
( cvs diff -u -r 1.179.2.106 -r 1.179.2.107 src/imap.c; cvs diff -u -r 1.34.2.4 -r 1.34.2.5 src/imap.h; cvs diff -u -r 1.105.2.53 -r 1.105.2.54 src/prefs_account.c; ) > 2.1.1cvs20.patchset
( cvs diff -u -r 1.207.2.95 -r 1.207.2.96 src/folderview.c; cvs diff -u -r 1.274.2.107 -r 1.274.2.108 src/mainwindow.c; cvs diff -u -r 1.36.2.60 -r 1.36.2.61 src/common/utils.c; ) > 2.1.1cvs21.patchset
( cvs diff -u -r 1.1.2.41 -r 1.1.2.42 src/gtk/quicksearch.c; ) > 2.1.1cvs22.patchset
( cvs diff -u -r 1.1.4.34 -r 1.1.4.35 src/etpan/imap-thread.c; cvs diff -u -r 1.1.4.14 -r 1.1.4.15 src/gtk/logwindow.c; cvs diff -u -r 1.1.4.3 -r 1.1.4.4 src/gtk/logwindow.h; ) > 2.1.1cvs23.patchset

View file

@ -11,7 +11,7 @@ MINOR_VERSION=1
MICRO_VERSION=1
INTERFACE_AGE=0
BINARY_AGE=0
EXTRA_VERSION=22
EXTRA_VERSION=23
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=

View file

@ -40,26 +40,69 @@ static gboolean thread_manager_event(GIOChannel * source,
return TRUE;
}
void imap_logger(int direction, const char * str, size_t size)
void imap_logger_cmd(int direction, const char * str, size_t size)
{
gchar buf[512];
gchar *buf;
gchar **lines;
int i = 0;
buf = malloc(size+1);
memset(buf, 0, size+1);
strncpy(buf, str, size);
buf[size] = '\0';
memset(buf, 0, 512);
strncpy(buf, str, size > 510 ? 510:size);
buf[511] = '\0';
if (size < 511)
buf[size] = '\0';
if (!strncmp(buf, "<<<<<<<", 7)
|| !strncmp(buf, ">>>>>>>", 7)
|| buf[0] == '\r' || buf[0] == '\n')
|| !strncmp(buf, ">>>>>>>", 7)) {
free(buf);
return;
}
while (strstr(buf, "\r"))
*strstr(buf, "\r") = ' ';
while (strstr(buf, "\n"))
*strstr(buf, "\n") = ' ';
while (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
buf[strlen(buf)-1] = '\0';
log_print("IMAP4%c %s\n", direction?'>':'<', buf);
lines = g_strsplit(buf, "\n", -1);
while (lines[i] && *lines[i]) {
log_print("IMAP4%c %s\n", direction?'>':'<', lines[i]);
i++;
}
g_strfreev(lines);
free(buf);
}
void imap_logger_fetch(int direction, const char * str, size_t size)
{
gchar *buf;
gchar **lines;
int i = 0;
buf = malloc(size+1);
memset(buf, 0, size+1);
strncpy(buf, str, size);
buf[size] = '\0';
if (!strncmp(buf, "<<<<<<<", 7)
|| !strncmp(buf, ">>>>>>>", 7)) {
free(buf);
return;
}
while (strstr(buf, "\r"))
*strstr(buf, "\r") = ' ';
while (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
buf[strlen(buf)-1] = '\0';
lines = g_strsplit(buf, "\n", -1);
if (direction != 0 || (buf[0] == '*' && buf[1] == ' ') || size < 32) {
while (lines[i] && *lines[i]) {
log_print("IMAP4%c %s\n", direction?'>':'<', lines[i]);
i++;
}
} else {
log_print("IMAP4%c [data - %zd bytes]\n", direction?'>':'<', size);
}
g_strfreev(lines);
free(buf);
}
#define ETPAN_DEFAULT_NETWORK_TIMEOUT 60
@ -72,7 +115,7 @@ void imap_main_init(void)
mailstream_network_delay.tv_usec = 0;
mailstream_debug = 1;
mailstream_logger = imap_logger;
mailstream_logger = imap_logger_cmd;
imap_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE);
session_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE);
@ -285,7 +328,7 @@ int imap_threaded_connect(Folder * folder, const char * server, int port)
return result.error;
}
static int etpan_certificate_check(unsigned char *certificate, int len, void *data)
static int etpan_certificate_check(const unsigned char *certificate, int len, void *data)
{
#ifdef USE_OPENSSL
struct connect_param *param = (struct connect_param *)data;
@ -1391,9 +1434,13 @@ static int imap_fetch(mailimap * imap,
goto free_fetch_att;
}
mailstream_logger = imap_logger_fetch;
r = mailimap_uid_fetch(imap, set,
fetch_type, &fetch_result);
mailstream_logger = imap_logger_cmd;
mailimap_fetch_type_free(fetch_type);
mailimap_set_free(set);

View file

@ -138,26 +138,30 @@ void log_window_init(LogWindow *logwin)
{
GtkTextBuffer *buffer;
GdkColormap *colormap;
GdkColor color[3] =
{{0, 0, 0xafff, 0}, {0, 0xefff, 0, 0}, {0, 0xefff, 0, 0}};
gboolean success[3];
GdkColor color[5] =
{{0, 0, 0xafff, 0}, {0, 0xefff, 0, 0}, {0, 0xefff, 0, 0},
{0, 0, 0, 0}, {0, 0, 0, 0xefff}};
gboolean success[5];
gint i;
logwin->msg_color = color[0];
logwin->warn_color = color[1];
logwin->error_color = color[2];
logwin->in_color = color[3];
logwin->out_color = color[4];
colormap = gdk_drawable_get_colormap(logwin->window->window);
gdk_colormap_alloc_colors(colormap, color, 3, FALSE, TRUE, success);
gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
for (i = 0; i < 3; i++) {
for (i = 0; i < 5; i++) {
if (success[i] == FALSE) {
GtkStyle *style;
g_warning("LogWindow: color allocation failed\n");
style = gtk_widget_get_style(logwin->window);
logwin->msg_color = logwin->warn_color =
logwin->error_color = style->black;
logwin->error_color = logwin->in_color =
logwin->out_color = style->black;
break;
}
}
@ -172,6 +176,12 @@ void log_window_init(LogWindow *logwin)
gtk_text_buffer_create_tag(buffer, "error",
"foreground-gdk", &logwin->error_color,
NULL);
gtk_text_buffer_create_tag(buffer, "input",
"foreground-gdk", &logwin->in_color,
NULL);
gtk_text_buffer_create_tag(buffer, "output",
"foreground-gdk", &logwin->out_color,
NULL);
}
void log_window_show(LogWindow *logwin)
@ -201,7 +211,6 @@ static gboolean log_window_append(gpointer source, gpointer data)
GtkTextView *text;
GtkTextBuffer *buffer;
GtkTextIter iter;
GdkColor *color = NULL;
gchar *head = NULL;
const gchar *tag;
@ -218,17 +227,14 @@ static gboolean log_window_append(gpointer source, gpointer data)
switch (logtext->type) {
case LOG_MSG:
color = &logwindow->msg_color;
tag = "message";
head = "* ";
break;
case LOG_WARN:
color = &logwindow->warn_color;
tag = "warn";
head = "** ";
break;
case LOG_ERROR:
color = &logwindow->error_color;
tag = "error";
head = "*** ";
break;
@ -237,6 +243,17 @@ static gboolean log_window_append(gpointer source, gpointer data)
break;
}
if (tag == NULL) {
if (strstr(logtext->text, "] POP3>")
|| strstr(logtext->text, "] IMAP4>")
|| strstr(logtext->text, "] NNTP>"))
tag = "output";
if (strstr(logtext->text, "] POP3<")
|| strstr(logtext->text, "] IMAP4<")
|| strstr(logtext->text, "] NNTP<"))
tag = "input";
}
if (head)
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, head, -1,
tag, NULL);

View file

@ -34,6 +34,8 @@ struct _LogWindow
GdkColor msg_color;
GdkColor warn_color;
GdkColor error_color;
GdkColor in_color;
GdkColor out_color;
gboolean clip;
guint clip_length;