balsa r8079 - in trunk: . libbalsa libinit_balsa src
- From: pawels svn gnome org
- To: svn-commits-list gnome org
- Subject: balsa r8079 - in trunk: . libbalsa libinit_balsa src
- Date: Mon, 16 Feb 2009 19:24:58 +0000 (UTC)
Author: pawels
Date: Mon Feb 16 19:24:58 2009
New Revision: 8079
URL: http://svn.gnome.org/viewvc/balsa?rev=8079&view=rev
Log:
* src/main-window.c: use g_(malloc|free) instead of malloc and free
* src/sendmsg-window.c, src/ab-main.c, src/main.c:
add missing include of stdlib.h if it is available
* configure.in: always define _XOPEN_SOURCE
* libbalsa/missing.h: declare (local|gm|c)time_r if necessary
* libbalsa/rfc2445.c: add proper casting macros, catch and convert
\r\n line endings (iCal compatibility), work around iCal method
parameter bug, fix crash on NULL pointers passed to conversion funcs.
* libbalsa/filter-funcs.c: use glib for time conversion if available.
lsa/mailbox_imap.c: sync the cache when closing mbox.
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/libbalsa/filter-file.c
trunk/libbalsa/filter-funcs.c
trunk/libbalsa/folder-scanners.c
trunk/libbalsa/libbalsa.c
trunk/libbalsa/mailbox.c
trunk/libbalsa/mailbox_imap.c
trunk/libbalsa/mailbox_maildir.c
trunk/libbalsa/mailbox_mbox.c
trunk/libbalsa/mailbox_mh.c
trunk/libbalsa/mailbox_pop3.c
trunk/libbalsa/misc.c
trunk/libbalsa/missing.h
trunk/libbalsa/rfc2445.c
trunk/libinit_balsa/assistant_page_directory.c
trunk/libinit_balsa/balsa-druid-page-directory.c
trunk/src/ab-main.c
trunk/src/balsa-app.c
trunk/src/filter-edit-callbacks.c
trunk/src/main-window.c
trunk/src/main.c
trunk/src/print.c
trunk/src/save-restore.c
trunk/src/sendmsg-window.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Mon Feb 16 19:24:58 2009
@@ -847,8 +847,9 @@
dnl #####################################################################
AC_C_CONST
AC_STDC_HEADERS
-AC_CHECK_FUNCS([localtime_r gmtime_r ctime_r])
+AC_DEFINE([_XOPEN_SOURCE],[500],[We strive for XOPEN compliance])
+AC_CHECK_FUNCS([localtime_r gmtime_r ctime_r])
# more warnings.
#
Modified: trunk/libbalsa/filter-file.c
==============================================================================
--- trunk/libbalsa/filter-file.c (original)
+++ trunk/libbalsa/filter-file.c Mon Feb 16 19:24:58 2009
@@ -29,8 +29,6 @@
#include "config.h"
-/* define _XOPEN_SOURCE to make strptime visible */
-#define _XOPEN_SOURCE
/* extensions needed additonally on Solaris for strptime */
#define __EXTENSIONS__
#include <stdlib.h>
Modified: trunk/libbalsa/filter-funcs.c
==============================================================================
--- trunk/libbalsa/filter-funcs.c (original)
+++ trunk/libbalsa/filter-funcs.c Mon Feb 16 19:24:58 2009
@@ -25,7 +25,6 @@
*/
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@@ -310,7 +309,11 @@
cond_to_string(LibBalsaCondition * cond, GString *res)
{
char str[80];
+#if GLIB_CHECK_VERSION(2,10,0)
+ GDate date;
+#else
struct tm date;
+#endif
if(cond->negate)
g_string_append(res, "NOT ");
@@ -332,14 +335,24 @@
case CONDITION_DATE:
g_string_append(res, "DATE ");
if (cond->match.date.date_low) {
+#if GLIB_CHECK_VERSION(2,10,0)
+ g_date_set_time_t(&date, cond->match.date.date_low);
+ g_date_strftime(str, sizeof(str), "%Y-%m-%d", &date);
+#else
localtime_r(&cond->match.date.date_low, &date);
strftime(str,sizeof(str),"%Y-%m-%d", &date);
+#endif
} else str[0]='\0';
append_quoted_string(res, str);
g_string_append_c(res, ' ');
if (cond->match.date.date_high) {
+#if GLIB_CHECK_VERSION(2,10,0)
+ g_date_set_time_t(&date, cond->match.date.date_high);
+ g_date_strftime(str, sizeof(str), "%Y-%m-%d", &date);
+#else
localtime_r(&cond->match.date.date_high, &date);
strftime(str,sizeof(str),"%Y-%m-%d", &date);
+#endif
} else str[0]='\0';
append_quoted_string(res, str);
break;
Modified: trunk/libbalsa/folder-scanners.c
==============================================================================
--- trunk/libbalsa/folder-scanners.c (original)
+++ trunk/libbalsa/folder-scanners.c Mon Feb 16 19:24:58 2009
@@ -21,7 +21,6 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <stdlib.h>
#include <string.h>
Modified: trunk/libbalsa/libbalsa.c
==============================================================================
--- trunk/libbalsa/libbalsa.c (original)
+++ trunk/libbalsa/libbalsa.c Mon Feb 16 19:24:58 2009
@@ -22,7 +22,6 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <glib.h>
Modified: trunk/libbalsa/mailbox.c
==============================================================================
--- trunk/libbalsa/mailbox.c (original)
+++ trunk/libbalsa/mailbox.c Mon Feb 16 19:24:58 2009
@@ -21,7 +21,6 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <ctype.h>
#include <string.h>
#include <sys/types.h>
Modified: trunk/libbalsa/mailbox_imap.c
==============================================================================
--- trunk/libbalsa/mailbox_imap.c (original)
+++ trunk/libbalsa/mailbox_imap.c Mon Feb 16 19:24:58 2009
@@ -30,7 +30,6 @@
*/
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <stdlib.h>
#include <dirent.h>
@@ -1071,6 +1070,21 @@
LibBalsaMailboxImap *mbox = LIBBALSA_MAILBOX_IMAP(mailbox);
struct ImapCacheManager *icm = icm_store_cached_data(mbox->handle);
+ mbox->opened = FALSE;
+ g_object_set_data_full(G_OBJECT(mailbox), "cache-manager", icm,
+ (GDestroyNotify) imap_cache_manager_free);
+
+ /* we do not attempt to reconnect here */
+ if (expunge) {
+ if (is_persistent) { /* We appreciate expunge info to simplify
+ next resync. */
+ imap_mbox_expunge_a(mbox->handle);
+ }
+ imap_mbox_close(mbox->handle);
+ } else
+ imap_mbox_unselect(mbox->handle);
+
+ /* We have received last notificiations, we can save the cache now. */
if(is_persistent) {
/* Implement only for persistent. Cache dir is shared for all
non-persistent caches. */
@@ -1080,15 +1094,7 @@
}
clean_cache(mailbox);
- mbox->opened = FALSE;
- g_object_set_data_full(G_OBJECT(mailbox), "cache-manager", icm,
- (GDestroyNotify) imap_cache_manager_free);
- /* we do not attempt to reconnect here */
- if (expunge)
- imap_mbox_close(mbox->handle);
- else
- imap_mbox_unselect(mbox->handle);
free_messages_info(mbox);
libbalsa_mailbox_imap_release_handle(mbox);
mbox->sort_field = -1; /* Invalidate. */
Modified: trunk/libbalsa/mailbox_maildir.c
==============================================================================
--- trunk/libbalsa/mailbox_maildir.c (original)
+++ trunk/libbalsa/mailbox_maildir.c Mon Feb 16 19:24:58 2009
@@ -22,8 +22,6 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
-#define _XOPEN_SOURCE_EXTENDED 1
#include <unistd.h>
#include <fcntl.h>
Modified: trunk/libbalsa/mailbox_mbox.c
==============================================================================
--- trunk/libbalsa/mailbox_mbox.c (original)
+++ trunk/libbalsa/mailbox_mbox.c Mon Feb 16 19:24:58 2009
@@ -22,7 +22,6 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <gmime/gmime-stream-fs.h>
Modified: trunk/libbalsa/mailbox_mh.c
==============================================================================
--- trunk/libbalsa/mailbox_mh.c (original)
+++ trunk/libbalsa/mailbox_mh.c Mon Feb 16 19:24:58 2009
@@ -22,8 +22,6 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
-#define _XOPEN_SOURCE_EXTENDED 1
/* to compile this on BSD/Darwin */
#undef _POSIX_SOURCE
Modified: trunk/libbalsa/mailbox_pop3.c
==============================================================================
--- trunk/libbalsa/mailbox_pop3.c (original)
+++ trunk/libbalsa/mailbox_pop3.c Mon Feb 16 19:24:58 2009
@@ -22,7 +22,6 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <fcntl.h>
Modified: trunk/libbalsa/misc.c
==============================================================================
--- trunk/libbalsa/misc.c (original)
+++ trunk/libbalsa/misc.c Mon Feb 16 19:24:58 2009
@@ -27,7 +27,6 @@
#include "config.h"
#define _SVID_SOURCE 1
-#define _XOPEN_SOURCE 500
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
Modified: trunk/libbalsa/missing.h
==============================================================================
--- trunk/libbalsa/missing.h (original)
+++ trunk/libbalsa/missing.h Mon Feb 16 19:24:58 2009
@@ -26,15 +26,15 @@
#include <time.h>
#ifndef HAVE_CTIME_R
-char * libbalsa_ctime_r(const time_t *clock, char *buf);
+char * ctime_r(const time_t *clock, char *buf);
#endif
#ifndef HAVE_LOCALTIME_R
-struct tm * libbalsa_localtime_r(const time_t *clock, struct tm *result);
+struct tm * localtime_r(const time_t *clock, struct tm *result);
#endif
#ifndef HAVE_GMTIME_R
-struct tm * libbalsa_gmtime_r(const time_t *clock, struct tm *result);
+struct tm * gmtime_r(const time_t *clock, struct tm *result);
#endif
#endif
Modified: trunk/libbalsa/rfc2445.c
==============================================================================
--- trunk/libbalsa/rfc2445.c (original)
+++ trunk/libbalsa/rfc2445.c Mon Feb 16 19:24:58 2009
@@ -20,10 +20,16 @@
*/
#include "config.h"
+
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
#include <glib.h>
#include <glib/gi18n.h>
#include <glib-object.h>
#include "libbalsa.h"
+#include "missing.h"
#include "rfc2445.h"
@@ -71,6 +77,11 @@
static LibBalsaVCalPartStat vcal_str_to_part_stat(const gchar * pstat);
+#define LB_ROLE2PTR(r) GINT_TO_POINTER((gint) (r))
+#define LB_PSTAT2PTR(r) GINT_TO_POINTER((gint) (r))
+#define LB_PTR2ROLE(p) ((LibBalsaVCalRole) GPOINTER_TO_INT(p))
+#define LB_PTR2PSTAT(p) ((LibBalsaVCalPartStat) GPOINTER_TO_INT(p))
+
static struct {
gchar *str_2445;
gchar *hr_text;
@@ -248,16 +259,12 @@
g_return_val_if_fail(body != NULL, NULL);
- /* get the method parameter which is not required, but we ignore all parts
- * which don't have it */
- method = libbalsa_message_body_get_parameter(body, "method");
- g_return_val_if_fail(method != NULL, NULL);
-
/* get the body buffer */
if (libbalsa_message_body_get_content(body, &vcal_buf, NULL) <= 0)
return NULL;
- /* check if the body has a charset (default is utf-8, see '2445, sect 4.1.4) */
+ /* check if the body has a charset (default is utf-8, see '2445,
+ * sect 4.1.4) */
charset = libbalsa_message_body_get_parameter(body, "charset");
if (charset && g_ascii_strcasecmp(charset, "utf-8")) {
gsize written;
@@ -275,8 +282,14 @@
/* o.k., create a new object */
retval = libbalsa_vcal_new();
- retval->method = vcal_str_to_method(method);
- g_free(method);
+
+ /* replace \r\n by \n */
+ p = strchr(vcal_buf, '\r');
+ while (p) {
+ if (p[1] =='\n')
+ memmove(p, p + 1, strlen(p + 1) + 1);
+ p = strchr(p + 1, '\r');
+ }
/* unfold the body and split into lines */
p = strchr(vcal_buf, '\n');
@@ -290,8 +303,11 @@
/* scan lines to extract vevent(s) */
event = NULL;
+ method = NULL;
for (k = 0; lines[k]; k++) {
if (!event) {
+ if (!method && !g_ascii_strncasecmp("METHOD:", lines[k], 7))
+ method = g_strdup(lines[k] + 7);
if (!g_ascii_strcasecmp("BEGIN:VEVENT", lines[k]))
event = libbalsa_vevent_new();
} else {
@@ -336,6 +352,10 @@
if (event)
g_object_unref(event);
+ /* set the method */
+ retval->method = vcal_str_to_method(method);
+ g_free(method);
+
return retval;
}
@@ -354,9 +374,8 @@
retval = g_string_new("");
- role =
- (LibBalsaVCalRole) g_object_get_data(G_OBJECT(person),
- RFC2445_ROLE);
+ role = LB_PTR2ROLE(g_object_get_data(G_OBJECT(person),
+ RFC2445_ROLE));
if (role != VCAL_ROLE_UNKNOWN)
g_string_printf(retval, "%s ", vcal_role_to_str(role));
@@ -364,9 +383,8 @@
retval = g_string_append(retval, str);
g_free(str);
- pstat =
- (LibBalsaVCalPartStat) g_object_get_data(G_OBJECT(person),
- RFC2445_PARTSTAT);
+ pstat = LB_PTR2PSTAT(g_object_get_data(G_OBJECT(person),
+ RFC2445_PARTSTAT));
if (pstat != VCAL_PSTAT_UNKNOWN)
g_string_append_printf(retval, " (%s)",
libbalsa_vcal_part_stat_to_str(pstat));
@@ -596,7 +614,7 @@
retval->address_list = g_list_prepend(NULL, g_strdup(uri + 7));
if (!is_organizer)
g_object_set_data(G_OBJECT(retval), RFC2445_ROLE,
- (gpointer) VCAL_ROLE_REQ_PART);
+ LB_ROLE2PTR(VCAL_ROLE_REQ_PART));
if (attributes) {
int n;
@@ -608,10 +626,10 @@
retval->full_name = g_strdup(the_attr + 3);
else if (!g_ascii_strncasecmp(the_attr, "ROLE=", 5))
g_object_set_data(G_OBJECT(retval), RFC2445_ROLE,
- (gpointer) vcal_str_to_role(the_attr + 5));
+ LB_ROLE2PTR(vcal_str_to_role(the_attr + 5)));
else if (!g_ascii_strncasecmp(the_attr, "PARTSTAT=", 9))
g_object_set_data(G_OBJECT(retval), RFC2445_PARTSTAT,
- (gpointer) vcal_str_to_part_stat(the_attr + 9));
+ LB_PSTAT2PTR(vcal_str_to_part_stat(the_attr + 9)));
else if (!g_ascii_strncasecmp(the_attr, "RSVP=", 5))
g_object_set_data(G_OBJECT(retval), RFC2445_RSVP,
GINT_TO_POINTER(! g_ascii_strcasecmp(the_attr + 5, "TRUE")));
@@ -637,9 +655,10 @@
{ "CANCEL", ITIP_CANCEL },
{ NULL, ITIP_UNKNOWN}
};
-
gint n;
+ if (!method)
+ return ITIP_UNKNOWN;
for (n = 0;
meth_list[n].meth_id
&& g_ascii_strcasecmp(method, meth_list[n].meth_id); n++);
@@ -700,6 +719,8 @@
};
gint n;
+ if (!role)
+ return VCAL_ROLE_UNKNOWN;
for (n = 0;
role_list[n].role_id
&& g_ascii_strcasecmp(role, role_list[n].role_id); n++);
@@ -737,6 +758,8 @@
};
gint n;
+ if (!pstat)
+ return VCAL_PSTAT_UNKNOWN;
for (n = 0;
pstat_list[n].pstat_id
&& g_ascii_strcasecmp(pstat, pstat_list[n].pstat_id); n++);
Modified: trunk/libinit_balsa/assistant_page_directory.c
==============================================================================
--- trunk/libinit_balsa/assistant_page_directory.c (original)
+++ trunk/libinit_balsa/assistant_page_directory.c Mon Feb 16 19:24:58 2009
@@ -19,7 +19,6 @@
* 02111-1307, USA.
*/
-#define _XOPEN_SOURCE 500
#include "config.h"
Modified: trunk/libinit_balsa/balsa-druid-page-directory.c
==============================================================================
--- trunk/libinit_balsa/balsa-druid-page-directory.c (original)
+++ trunk/libinit_balsa/balsa-druid-page-directory.c Mon Feb 16 19:24:58 2009
@@ -19,7 +19,6 @@
* 02111-1307, USA.
*/
-#define _XOPEN_SOURCE 500
#include <sys/types.h>
#include <sys/stat.h>
Modified: trunk/src/ab-main.c
==============================================================================
--- trunk/src/ab-main.c (original)
+++ trunk/src/ab-main.c Mon Feb 16 19:24:58 2009
@@ -31,6 +31,10 @@
# include <gconf/gconf.h>
#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
Modified: trunk/src/balsa-app.c
==============================================================================
--- trunk/src/balsa-app.c (original)
+++ trunk/src/balsa-app.c Mon Feb 16 19:24:58 2009
@@ -23,8 +23,6 @@
#include <string.h>
#include <stdlib.h>
#ifdef BALSA_USE_THREADS
-/* _XOPEN_SOURCE is needed for rwlocks */
-#define _XOPEN_SOURCE 500
#include <pthread.h>
#endif
Modified: trunk/src/filter-edit-callbacks.c
==============================================================================
--- trunk/src/filter-edit-callbacks.c (original)
+++ trunk/src/filter-edit-callbacks.c Mon Feb 16 19:24:58 2009
@@ -25,7 +25,6 @@
#include "config.h"
-#define _XOPEN_SOURCE /* glibc2 needs this */
/* yellow dog has crappy libc and needs pthread.h to be included here */
#ifdef BALSA_USE_THREADS
# include <pthread.h>
Modified: trunk/src/main-window.c
==============================================================================
--- trunk/src/main-window.c (original)
+++ trunk/src/main-window.c Mon Feb 16 19:24:58 2009
@@ -3129,11 +3129,11 @@
ssize_t count;
float fraction;
- msgbuffer = malloc(2049);
+ msgbuffer = g_malloc(2049);
count = read(send_thread_pipes[0], msgbuffer, 2048);
if (count < (ssize_t) sizeof(void *)) {
- free(msgbuffer);
+ g_free(msgbuffer);
return TRUE;
}
@@ -3193,14 +3193,14 @@
fprintf(stderr, " Unknown: %s \n",
threadmessage->message_string);
}
- free(threadmessage);
+ g_free(threadmessage);
currentpos++;
count -= sizeof(void *);
}
gdk_threads_leave();
- free(msgbuffer);
+ g_free(msgbuffer);
return TRUE;
}
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Mon Feb 16 19:24:58 2009
@@ -19,7 +19,6 @@
* 02111-1307, USA.
*/
-#define _XOPEN_SOURCE 500
#include "config.h"
#if HAVE_GNOME
@@ -32,6 +31,9 @@
#endif
#include <signal.h>
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#ifdef BALSA_USE_THREADS
#include <pthread.h>
Modified: trunk/src/print.c
==============================================================================
--- trunk/src/print.c (original)
+++ trunk/src/print.c Mon Feb 16 19:24:58 2009
@@ -21,7 +21,6 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <gnome.h>
#include "balsa-app.h"
Modified: trunk/src/save-restore.c
==============================================================================
--- trunk/src/save-restore.c (original)
+++ trunk/src/save-restore.c Mon Feb 16 19:24:58 2009
@@ -20,7 +20,6 @@
*/
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <stdlib.h>
#include <string.h>
Modified: trunk/src/sendmsg-window.c
==============================================================================
--- trunk/src/sendmsg-window.c (original)
+++ trunk/src/sendmsg-window.c Mon Feb 16 19:24:58 2009
@@ -26,10 +26,12 @@
#include "config.h"
-#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <string.h>
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#if HAVE_GNOME
#include <gnome.h>
#else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]