aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-08-21 05:44:29 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-08-21 05:44:29 +0800
commit164f4653dd98cd41fc7e3dd64b09145dec04bed8 (patch)
tree04d58b72775bf962314eb9a98870408407f6f48e /camel
parent07c805c9f58f4b025960ea5718f4e1448bf9c4cc (diff)
downloadgsoc2013-evolution-164f4653dd98cd41fc7e3dd64b09145dec04bed8.tar
gsoc2013-evolution-164f4653dd98cd41fc7e3dd64b09145dec04bed8.tar.gz
gsoc2013-evolution-164f4653dd98cd41fc7e3dd64b09145dec04bed8.tar.bz2
gsoc2013-evolution-164f4653dd98cd41fc7e3dd64b09145dec04bed8.tar.lz
gsoc2013-evolution-164f4653dd98cd41fc7e3dd64b09145dec04bed8.tar.xz
gsoc2013-evolution-164f4653dd98cd41fc7e3dd64b09145dec04bed8.tar.zst
gsoc2013-evolution-164f4653dd98cd41fc7e3dd64b09145dec04bed8.zip
Override the default noop implementation.
2002-08-20 Jeffrey Stedfast <fejj@ximian.com> * providers/imap/camel-imap-store.c (imap_noop): Override the default noop implementation. * camel-store.c (camel_store_noop): New virtual method to ping a store. * camel-session.c (get_service): Register a timeout that calls camel_store_noop() every 10 minutes. svn path=/trunk/; revision=17822
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog11
-rw-r--r--camel/camel-session.c40
-rw-r--r--camel/camel-store.c25
-rw-r--r--camel/camel-store.h5
-rw-r--r--camel/providers/imap/camel-imap-store.c22
5 files changed, 100 insertions, 3 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 23ae418cbe..340a3f75cf 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,14 @@
+2002-08-20 Jeffrey Stedfast <fejj@ximian.com>
+
+ * providers/imap/camel-imap-store.c (imap_noop): Override the
+ default noop implementation.
+
+ * camel-store.c (camel_store_noop): New virtual method to ping a
+ store.
+
+ * camel-session.c (get_service): Register a timeout that calls
+ camel_store_noop() every 10 minutes.
+
2002-08-19 Peter Williams <peterw@ximian.com>
Plug some large leaks in the indexing code.
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 0cf493ae80..b65d460211 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -398,6 +398,29 @@ service_cache_remove (CamelService *service, gpointer event_data, gpointer user_
CAMEL_SESSION_UNLOCK(session, lock);
}
+static gboolean
+noop_cb (gpointer user_data)
+{
+ CamelStore *store = (CamelStore *) user_data;
+ CamelException ex;
+
+ camel_exception_init (&ex);
+ camel_store_noop (store, &ex);
+ camel_exception_clear (&ex);
+
+ return TRUE;
+}
+
+static void
+unregister_noop (CamelObject *object, gpointer event_data, gpointer user_data)
+{
+ CamelService *service = (CamelService *) object;
+ guint id;
+
+ id = GPOINTER_TO_INT (user_data);
+
+ camel_session_remove_timeout (service->session, id);
+}
static CamelService *
get_service (CamelSession *session, const char *url_string,
@@ -407,6 +430,7 @@ get_service (CamelSession *session, const char *url_string,
CamelProvider *provider;
CamelService *service;
CamelException internal_ex;
+
url = camel_url_new (url_string, ex);
if (!url)
return NULL;
@@ -420,6 +444,7 @@ get_service (CamelSession *session, const char *url_string,
url->protocol);
provider = NULL;
}
+
if (!provider) {
camel_url_free (url);
return NULL;
@@ -430,7 +455,7 @@ get_service (CamelSession *session, const char *url_string,
*/
if (url->path && !CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_PATH))
camel_url_set_path (url, NULL);
-
+
/* Now look up the service in the provider's cache */
service = g_hash_table_lookup (provider->service_cache[type], url);
if (service != NULL) {
@@ -447,8 +472,19 @@ get_service (CamelSession *session, const char *url_string,
camel_object_unref (CAMEL_OBJECT (service));
service = NULL;
} else {
+ if (type == CAMEL_PROVIDER_STORE) {
+ guint id;
+
+ id = camel_session_register_timeout (session, 36000, noop_cb, service);
+ camel_object_hook_event (CAMEL_OBJECT (service), "finalize",
+ (CamelObjectEventHookFunc) unregister_noop,
+ GINT_TO_POINTER (id));
+ }
+
g_hash_table_insert (provider->service_cache[type], url, service);
- camel_object_hook_event (CAMEL_OBJECT (service), "finalize", (CamelObjectEventHookFunc) service_cache_remove, GINT_TO_POINTER (type));
+ camel_object_hook_event (CAMEL_OBJECT (service), "finalize",
+ (CamelObjectEventHookFunc) service_cache_remove,
+ GINT_TO_POINTER (type));
}
return service;
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 23a7e9109d..1987ea4ddd 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -71,6 +71,8 @@ static gboolean folder_subscribed (CamelStore *store, const char *folder_name);
static void subscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex);
static void unsubscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex);
+static void noop (CamelStore *store, CamelException *ex);
+
static void construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
CamelException *ex);
@@ -102,6 +104,7 @@ camel_store_class_init (CamelStoreClass *camel_store_class)
camel_store_class->folder_subscribed = folder_subscribed;
camel_store_class->subscribe_folder = subscribe_folder;
camel_store_class->unsubscribe_folder = unsubscribe_folder;
+ camel_store_class->noop = noop;
/* virtual method overload */
camel_service_class->construct = construct;
@@ -1115,6 +1118,28 @@ camel_store_unsubscribe_folder (CamelStore *store,
}
+static void
+noop (CamelStore *store, CamelException *ex)
+{
+ /* no-op */
+ ;
+}
+
+
+/**
+ * camel_store_noop:
+ * @store: CamelStore
+ * @ex: exception
+ *
+ * Pings @store so that its connection doesn't timeout.
+ **/
+void
+camel_store_noop (CamelStore *store, CamelException *ex)
+{
+ CS_CLASS (store)->noop (store, ex);
+}
+
+
int
camel_mkdir_hier (const char *path, mode_t mode)
{
diff --git a/camel/camel-store.h b/camel/camel-store.h
index 8aaa820d64..e054ab7224 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -155,6 +155,8 @@ typedef struct {
void (*unsubscribe_folder) (CamelStore *store,
const char *folder_name,
CamelException *ex);
+ void (*noop) (CamelStore *store,
+ CamelException *ex);
} CamelStoreClass;
@@ -218,6 +220,9 @@ void camel_store_unsubscribe_folder (CamelStore *store,
const char *folder_name,
CamelException *ex);
+void camel_store_noop (CamelStore *store,
+ CamelException *ex);
+
gboolean camel_store_uri_cmp (CamelStore *store, const char *uria, const char *urib);
/* utility needed by some stores */
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index f54b129e27..9950849539 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -86,6 +86,7 @@ static gboolean imap_connect_online (CamelService *service, CamelException *ex);
static gboolean imap_connect_offline (CamelService *service, CamelException *ex);
static gboolean imap_disconnect_online (CamelService *service, gboolean clean, CamelException *ex);
static gboolean imap_disconnect_offline (CamelService *service, gboolean clean, CamelException *ex);
+static void imap_noop (CamelStore *store, CamelException *ex);
static GList *query_auth_types (CamelService *service, CamelException *ex);
static guint hash_folder_name (gconstpointer key);
static gint compare_folder_name (gconstpointer a, gconstpointer b);
@@ -108,7 +109,6 @@ static void subscribe_folder (CamelStore *store, const char *folder_name,
static void unsubscribe_folder (CamelStore *store, const char *folder_name,
CamelException *ex);
-
static void get_folders_online (CamelImapStore *imap_store, const char *pattern,
GPtrArray *folders, gboolean lsub, CamelException *ex);
@@ -153,6 +153,7 @@ camel_imap_store_class_init (CamelImapStoreClass *camel_imap_store_class)
camel_store_class->folder_subscribed = folder_subscribed;
camel_store_class->subscribe_folder = subscribe_folder;
camel_store_class->unsubscribe_folder = unsubscribe_folder;
+ camel_store_class->noop = imap_noop;
camel_disco_store_class->can_work_offline = can_work_offline;
camel_disco_store_class->connect_online = imap_connect_online;
@@ -1404,6 +1405,25 @@ imap_disconnect_online (CamelService *service, gboolean clean, CamelException *e
return TRUE;
}
+static void
+imap_noop (CamelStore *store, CamelException *ex)
+{
+ CamelImapStore *imap_store = (CamelImapStore *) store;
+ CamelDiscoStore *disco = (CamelDiscoStore *) store;
+ CamelImapResponse *response;
+
+ switch (camel_disco_store_status (disco)) {
+ case CAMEL_DISCO_STORE_ONLINE:
+ case CAMEL_DISCO_STORE_RESYNCING:
+ response = camel_imap_command (imap_store, NULL, NULL, "NOOP");
+ if (response)
+ camel_imap_response_free (imap_store, response);
+ break;
+ case CAMEL_DISCO_STORE_OFFLINE:
+ break;
+ }
+}
+
static guint
hash_folder_name (gconstpointer key)
{