aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/nntp/camel-nntp-grouplist.c2
-rw-r--r--camel/providers/nntp/camel-nntp-resp-codes.h1
-rw-r--r--camel/providers/nntp/camel-nntp-store.c17
-rw-r--r--camel/providers/nntp/camel-nntp-store.h17
4 files changed, 35 insertions, 2 deletions
diff --git a/camel/providers/nntp/camel-nntp-grouplist.c b/camel/providers/nntp/camel-nntp-grouplist.c
index e77a28821c..8fdc513832 100644
--- a/camel/providers/nntp/camel-nntp-grouplist.c
+++ b/camel/providers/nntp/camel-nntp-grouplist.c
@@ -37,6 +37,7 @@ camel_nntp_get_grouplist_from_server (CamelNNTPStore *store, CamelException *ex)
gboolean done = FALSE;
CamelNNTPGroupList *list;
+ CAMEL_NNTP_STORE_LOCK(store);
status = camel_nntp_command (store, ex, NULL,
"LIST");
@@ -73,6 +74,7 @@ camel_nntp_get_grouplist_from_server (CamelNNTPStore *store, CamelException *ex)
list->group_list = g_list_prepend (list->group_list, entry);
}
}
+ CAMEL_NNTP_STORE_UNLOCK(store);
list->group_list = g_list_reverse(list->group_list);
return list;
diff --git a/camel/providers/nntp/camel-nntp-resp-codes.h b/camel/providers/nntp/camel-nntp-resp-codes.h
index 56aec79d3c..2f4d9ed540 100644
--- a/camel/providers/nntp/camel-nntp-resp-codes.h
+++ b/camel/providers/nntp/camel-nntp-resp-codes.h
@@ -31,6 +31,7 @@
#define NNTP_GREETING_POSTING_OK 200
#define NNTP_GREETING_NO_POSTING 201
+#define NNTP_EXTENSIONS_SUPPORTED 202
#define NNTP_GROUP_SELECTED 211
#define NNTP_LIST_FOLLOWS 215
#define NNTP_ARTICLE_FOLLOWS 220
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 084fbaa582..19510af334 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -63,9 +63,13 @@ static gboolean ensure_news_dir_exists (CamelNNTPStore *store);
static void
camel_nntp_store_get_extensions (CamelNNTPStore *store, CamelException *ex)
{
+ int rc;
+
store->extensions = 0;
- if (camel_nntp_command (store, ex, NULL, "LIST EXTENSIONS") == NNTP_LIST_FOLLOWS) {
+ CAMEL_NNTP_STORE_LOCK(store);
+ rc = camel_nntp_command(store, ex, NULL, "LIST EXTENSIONS");
+ if (rc == NNTP_LIST_FOLLOWS || rc == NNTP_EXTENSIONS_SUPPORTED) {
gboolean done = FALSE;
CamelException ex;
@@ -98,6 +102,7 @@ camel_nntp_store_get_extensions (CamelNNTPStore *store, CamelException *ex)
g_free (line);
}
}
+ CAMEL_NNTP_STORE_UNLOCK(store);
#ifdef DUMP_EXTENSIONS
g_print ("NNTP Extensions:");
@@ -122,6 +127,7 @@ camel_nntp_store_get_overview_fmt (CamelNNTPStore *store, CamelException *ex)
int i;
gboolean done = FALSE;
+ CAMEL_NNTP_STORE_LOCK(store);
status = camel_nntp_command (store, ex, NULL,
"LIST OVERVIEW.FMT");
@@ -210,6 +216,7 @@ camel_nntp_store_get_overview_fmt (CamelNNTPStore *store, CamelException *ex)
store->extensions &= ~CAMEL_NNTP_EXT_OVER;
}
}
+ CAMEL_NNTP_STORE_UNLOCK(store);
}
static gboolean
@@ -574,6 +581,9 @@ finalize (CamelObject *object)
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (object);
if (nntp_store->newsrc)
camel_nntp_newsrc_write (nntp_store->newsrc);
+#ifdef ENABLE_THREADS
+ e_mutex_destroy(nntp_store->command_lock);
+#endif
}
static void
@@ -608,11 +618,16 @@ static void
camel_nntp_store_init (gpointer object, gpointer klass)
{
CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object);
+ CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(object);
CamelStore *store = CAMEL_STORE (object);
remote_store->default_port = NNTP_PORT;
store->flags = CAMEL_STORE_SUBSCRIPTIONS;
+
+#ifdef ENABLE_THREADS
+ nntp_store->command_lock = e_mutex_new(E_MUTEX_REC);
+#endif
}
CamelType
diff --git a/camel/providers/nntp/camel-nntp-store.h b/camel/providers/nntp/camel-nntp-store.h
index 225180dbcc..8841874e0c 100644
--- a/camel/providers/nntp/camel-nntp-store.h
+++ b/camel/providers/nntp/camel-nntp-store.h
@@ -35,12 +35,17 @@ extern "C" {
#include "camel-nntp-newsrc.h"
#include "camel-nntp-types.h"
+#include "config.h"
+
+#ifdef ENABLE_THREADS
+#include "e-util/e-msgport.h"
+#endif
+
#define CAMEL_NNTP_STORE_TYPE (camel_nntp_store_get_type ())
#define CAMEL_NNTP_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_NNTP_STORE_TYPE, CamelNNTPStore))
#define CAMEL_NNTP_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_NNTP_STORE_TYPE, CamelNNTPStoreClass))
#define CAMEL_IS_NNTP_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_NNTP_STORE_TYPE))
-
enum {
CAMEL_NNTP_OVER_FROM,
CAMEL_NNTP_OVER_SUBJECT,
@@ -79,6 +84,9 @@ struct CamelNNTPStore {
CamelNNTPNewsrc *newsrc;
CamelNNTPGroupList *group_list;
+#ifdef ENABLE_THREADS
+ EMutex *command_lock;
+#endif
};
struct CamelNNTPStoreClass {
@@ -86,6 +94,13 @@ struct CamelNNTPStoreClass {
};
+#ifdef ENABLE_THREADS
+#define CAMEL_NNTP_STORE_LOCK(f) (e_mutex_lock(((CamelNNTPStore *) f)->command_lock))
+#define CAMEL_NNTP_STORE_UNLOCK(f) (e_mutex_unlock(((CamelNNTPStore *) f)->command_lock))
+#else
+#define CAMEL_NNTP_STORE_LOCK(f)
+#define CAMEL_NNTP_STORE_UNLOCK(f)
+#endif
/* public methods */
void camel_nntp_store_open (CamelNNTPStore *store, CamelException *ex);