diff options
author | Jeffrey Stedfast <fejj@novell.com> | 2004-08-04 00:31:47 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-08-04 00:31:47 +0800 |
commit | fa86654782270089197d30bbe94f657bb9a0b529 (patch) | |
tree | c25c75c896f1455392e0db54acbeca6cc262ffd9 /camel | |
parent | 3496b287612773fb2f4048e523b859d0469f54c2 (diff) | |
download | gsoc2013-evolution-fa86654782270089197d30bbe94f657bb9a0b529.tar.gz gsoc2013-evolution-fa86654782270089197d30bbe94f657bb9a0b529.tar.zst gsoc2013-evolution-fa86654782270089197d30bbe94f657bb9a0b529.zip |
Pass a reconnect func.
2004-08-03 Jeffrey Stedfast <fejj@novell.com>
* providers/imap4/camel-imap4-store.c (imap4_construct): Pass a
reconnect func.
* providers/imap4/camel-imap4-engine.c
(camel_imap4_engine_iterate): Reconnect if needed.
(camel_imap4_engine_new): Now takes a reconnect func.
svn path=/trunk/; revision=26813
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 9 | ||||
-rw-r--r-- | camel/providers/imap4/camel-imap4-engine.c | 22 | ||||
-rw-r--r-- | camel/providers/imap4/camel-imap4-engine.h | 7 | ||||
-rw-r--r-- | camel/providers/imap4/camel-imap4-store.c | 3 |
4 files changed, 38 insertions, 3 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index e5251d294a..fc594107c1 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,12 @@ +2004-08-03 Jeffrey Stedfast <fejj@novell.com> + + * providers/imap4/camel-imap4-store.c (imap4_construct): Pass a + reconnect func. + + * providers/imap4/camel-imap4-engine.c + (camel_imap4_engine_iterate): Reconnect if needed. + (camel_imap4_engine_new): Now takes a reconnect func. + 2004-07-30 Jeffrey Stedfast <fejj@novell.com> * providers/imap4/camel-imap4-engine.c diff --git a/camel/providers/imap4/camel-imap4-engine.c b/camel/providers/imap4/camel-imap4-engine.c index b1a2bbc2e9..88c03310ae 100644 --- a/camel/providers/imap4/camel-imap4-engine.c +++ b/camel/providers/imap4/camel-imap4-engine.c @@ -167,7 +167,7 @@ camel_imap4_engine_finalize (CamelObject *object) * Returns a new imap4 engine **/ CamelIMAP4Engine * -camel_imap4_engine_new (CamelService *service) +camel_imap4_engine_new (CamelService *service, CamelIMAP4ReconnectFunc reconnect) { CamelIMAP4Engine *engine; @@ -177,6 +177,7 @@ camel_imap4_engine_new (CamelService *service) engine->session = service->session; engine->url = service->url; engine->service = service; + engine->reconnect = reconnect; return engine; } @@ -1232,6 +1233,25 @@ camel_imap4_engine_iterate (CamelIMAP4Engine *engine) if (e_dlist_empty (&engine->queue)) return 0; + /* This sucks... it would be nicer if we didn't have to check the stream's disconnected status */ + if ((engine->state == CAMEL_IMAP4_ENGINE_DISCONNECTED || engine->istream->disconnected) && !engine->reconnecting) { + CamelException rex; + gboolean connected; + + camel_exception_init (&rex); + engine->reconnecting = TRUE; + connected = engine->reconnect (engine, &rex); + engine->reconnecting = FALSE; + + if (!connected) { + /* pop the first command and act as tho it failed (which, technically, it did...) */ + ic = (CamelIMAP4Command *) e_dlist_remhead (&engine->queue); + ic->status = CAMEL_IMAP4_COMMAND_ERROR; + camel_exception_xfer (&ic->ex, &rex); + return -1; + } + } + /* check to see if we need to pre-queue a SELECT, if so do it */ engine_prequeue_folder_select (engine); diff --git a/camel/providers/imap4/camel-imap4-engine.h b/camel/providers/imap4/camel-imap4-engine.h index 8d97011be4..738a17f7b6 100644 --- a/camel/providers/imap4/camel-imap4-engine.h +++ b/camel/providers/imap4/camel-imap4-engine.h @@ -143,9 +143,14 @@ enum { CAMEL_IMAP4_ENGINE_MAXLEN_TOKEN }; +typedef gboolean (* CamelIMAP4ReconnectFunc) (CamelIMAP4Engine *engine, CamelException *ex); + struct _CamelIMAP4Engine { CamelObject parent_object; + CamelIMAP4ReconnectFunc reconnect; + gboolean reconnecting; + CamelSession *session; CamelService *service; CamelURL *url; @@ -182,7 +187,7 @@ struct _CamelIMAP4EngineClass { CamelType camel_imap4_engine_get_type (void); -CamelIMAP4Engine *camel_imap4_engine_new (CamelService *service); +CamelIMAP4Engine *camel_imap4_engine_new (CamelService *service, CamelIMAP4ReconnectFunc reconnect); /* returns 0 on success or -1 on error */ int camel_imap4_engine_take_stream (CamelIMAP4Engine *engine, CamelStream *stream, CamelException *ex); diff --git a/camel/providers/imap4/camel-imap4-store.c b/camel/providers/imap4/camel-imap4-store.c index 0d47c3252e..ee96800ed5 100644 --- a/camel/providers/imap4/camel-imap4-store.c +++ b/camel/providers/imap4/camel-imap4-store.c @@ -53,6 +53,7 @@ static void imap4_construct (CamelService *service, CamelSession *session, CamelException *ex); static char *imap4_get_name (CamelService *service, gboolean brief); static gboolean imap4_connect (CamelService *service, CamelException *ex); +static gboolean imap4_reconnect (CamelIMAP4Engine *engine, CamelException *ex); static gboolean imap4_disconnect (CamelService *service, gboolean clean, CamelException *ex); static GList *imap4_query_auth_types (CamelService *service, CamelException *ex); @@ -166,7 +167,7 @@ imap4_construct (CamelService *service, CamelSession *session, CamelProvider *pr return; store->storage_path = camel_session_get_storage_path (session, service, ex); - store->engine = camel_imap4_engine_new (service); + store->engine = camel_imap4_engine_new (service, imap4_reconnect); } static char * |