balsa r7909 - in trunk: . libbalsa libbalsa/imap src



Author: pawels
Date: Wed Apr  9 20:07:49 2008
New Revision: 7909
URL: http://svn.gnome.org/viewvc/balsa?rev=7909&view=rev

Log:
* src/sendmsg-window.c: make postpone button and menu entry work.
* libbalsa/message.c: do not complain when setting headers->from again.
* libbalsa/imap/imap-handle.[ch]: make set_timeout() return the old value.
* libbalsa/imap/imap_private.h: add HANDLE_TRYLOCK macro.
* libbalsa/imap/imap-commands.c: use it for noop().


Modified:
   trunk/ChangeLog
   trunk/libbalsa/imap/imap-commands.c
   trunk/libbalsa/imap/imap-handle.c
   trunk/libbalsa/imap/imap-handle.h
   trunk/libbalsa/imap/imap_private.h
   trunk/libbalsa/message.c
   trunk/src/sendmsg-window.c

Modified: trunk/libbalsa/imap/imap-commands.c
==============================================================================
--- trunk/libbalsa/imap/imap-commands.c	(original)
+++ trunk/libbalsa/imap/imap-commands.c	Wed Apr  9 20:07:49 2008
@@ -151,9 +151,13 @@
 ImapResponse
 imap_mbox_handle_noop(ImapMboxHandle *handle)
 {
+  ImapResponse rc;
   IMAP_REQUIRED_STATE3(handle, IMHS_CONNECTED, IMHS_AUTHENTICATED,
                        IMHS_SELECTED, IMR_BAD);
-  return imap_cmd_exec(handle, "NOOP");
+  if(HANDLE_TRYLOCK(handle) != 0) return IMR_OK;
+  rc = imap_cmd_exec(handle, "NOOP");
+  HANDLE_UNLOCK(handle);
+  return rc;
 }
 
 /* 6.1.3 LOGOUT Command */
@@ -1250,12 +1254,14 @@
   gchar* cmd;
 
   IMAP_REQUIRED_STATE1(h, IMHS_SELECTED, IMR_BAD);
+  HANDLE_LOCK(h);
   cmd = imap_store_prepare(h, msgcnt, seqno, flg, state);
   if(cmd) {
     res = imap_cmd_exec(h, cmd);
     g_free(cmd);
-    return res;
-  } else return IMR_OK;
+  } res = IMR_OK;
+  HANDLE_UNLOCK(h);
+  return res;
 }
 
 ImapResponse

Modified: trunk/libbalsa/imap/imap-handle.c
==============================================================================
--- trunk/libbalsa/imap/imap-handle.c	(original)
+++ trunk/libbalsa/imap/imap-handle.c	Wed Apr  9 20:07:49 2008
@@ -317,12 +317,15 @@
 cmdi_empty(ImapMboxHandle *h, void *d)
 { return TRUE; }
 
-void
+/** Sets new timeout. Returns the old one. */
+int
 imap_handle_set_timeout(ImapMboxHandle *h, int milliseconds)
 {
+  int old_timeout = h->timeout;
   h->timeout = milliseconds;
   if(h->sio)
     sio_set_timeout(h->sio, milliseconds);
+  return old_timeout;
 }
 
 /* imap_handle_idle_enable: enables calling IDLE command after seconds

Modified: trunk/libbalsa/imap/imap-handle.h
==============================================================================
--- trunk/libbalsa/imap/imap-handle.h	(original)
+++ trunk/libbalsa/imap/imap-handle.h	Wed Apr  9 20:07:49 2008
@@ -123,7 +123,7 @@
 void imap_handle_set_infocb(ImapMboxHandle* h, ImapInfoCb cb, void*);
 void imap_handle_set_usercb(ImapMboxHandle* h, ImapUserCb cb, void*);
 void imap_handle_set_flagscb(ImapMboxHandle* h, ImapFlagsCb cb, void*);
-void imap_handle_set_timeout(ImapMboxHandle *, int milliseconds);
+int imap_handle_set_timeout(ImapMboxHandle *, int milliseconds);
 gboolean imap_handle_idle_enable(ImapMboxHandle *, int seconds);
 gboolean imap_handle_idle_disable(ImapMboxHandle *);
 gboolean imap_handle_op_cancelled(ImapMboxHandle *h);

Modified: trunk/libbalsa/imap/imap_private.h
==============================================================================
--- trunk/libbalsa/imap/imap_private.h	(original)
+++ trunk/libbalsa/imap/imap_private.h	Wed Apr  9 20:07:49 2008
@@ -26,6 +26,7 @@
 #if defined(BALSA_USE_THREADS)
 #include <pthread.h>
 #define HANDLE_LOCK(h)   pthread_mutex_lock(&h->mutex)
+#define HANDLE_TRYLOCK(h) pthread_mutex_trylock(&h->mutex)
 #define HANDLE_UNLOCK(h) pthread_mutex_unlock(&h->mutex)
 #else
 #define HANDLE_LOCK(h) 

Modified: trunk/libbalsa/message.c
==============================================================================
--- trunk/libbalsa/message.c	(original)
+++ trunk/libbalsa/message.c	Wed Apr  9 20:07:49 2008
@@ -1112,8 +1112,8 @@
     if (g_ascii_strcasecmp(name, "Date") == 0) {
 	message->headers->date = g_mime_utils_header_decode_date(value, NULL);
     } else
-    if (g_ascii_strcasecmp(name, "From") == 0) {
-	g_return_val_if_fail(message->headers->from == NULL, FALSE);
+    if (message->headers->from == NULL &&
+	g_ascii_strcasecmp(name, "From") == 0) {
         message->headers->from = internet_address_parse_string(value);
     } else
     if (g_ascii_strcasecmp(name, "To") == 0) {

Modified: trunk/src/sendmsg-window.c
==============================================================================
--- trunk/src/sendmsg-window.c	(original)
+++ trunk/src/sendmsg-window.c	Wed Apr  9 20:07:49 2008
@@ -6002,7 +6002,7 @@
 static void
 postpone_message_cb(GtkAction * action, BalsaSendmsg * bsmsg)
 {
-    if (!gtk_action_group_get_sensitive(bsmsg->ready_action_group)) {
+    if (gtk_action_group_get_sensitive(bsmsg->ready_action_group)) {
         if(message_postpone(bsmsg)) {
             balsa_information_parented(GTK_WINDOW(bsmsg->window),
                                        LIBBALSA_INFORMATION_MESSAGE,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]