CVS: sylpheed-claws/src/etpan imap-thread.c,1.1.4.34,1.1.4.35
Colin Leroy <[email protected]>
| Newsgroups | gmane.mail.sylpheed.claws.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/sylpheed-claws/sylpheed-claws/src/etpan
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3368/src/etpan
Modified Files:
Tag: gtk2
imap-thread.c
Log Message:
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)
Index: imap-thread.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/etpan/Attic/imap-thread.c,v
retrieving revision 1.1.4.34
retrieving revision 1.1.4.35
diff -u -r1.1.4.34 -r1.1.4.35
--- imap-thread.c 17 Apr 2006 15:57:58 -0000 1.1.4.34
+++ imap-thread.c 23 Apr 2006 11:30:37 -0000 1.1.4.35
@@ -40,26 +40,69 @@
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 (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+
+ 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 (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);
+
+ 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 @@
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 @@
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 @@
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);
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642