diff options
author | Not Zed <NotZed@Ximian.com> | 2003-09-16 07:21:16 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2003-09-16 07:21:16 +0800 |
commit | cf2b82e85864db8c0bfebceb84fd230691adc3f4 (patch) | |
tree | fbbcd7e3e2cb21afb724d6a76e449a43c22408bb /camel | |
parent | 99274a95701e007c22cbfc3f7d42a123b0464ea4 (diff) | |
download | gsoc2013-evolution-cf2b82e85864db8c0bfebceb84fd230691adc3f4.tar gsoc2013-evolution-cf2b82e85864db8c0bfebceb84fd230691adc3f4.tar.gz gsoc2013-evolution-cf2b82e85864db8c0bfebceb84fd230691adc3f4.tar.bz2 gsoc2013-evolution-cf2b82e85864db8c0bfebceb84fd230691adc3f4.tar.lz gsoc2013-evolution-cf2b82e85864db8c0bfebceb84fd230691adc3f4.tar.xz gsoc2013-evolution-cf2b82e85864db8c0bfebceb84fd230691adc3f4.tar.zst gsoc2013-evolution-cf2b82e85864db8c0bfebceb84fd230691adc3f4.zip |
removed dead code.
2003-09-15 Not Zed <NotZed@Ximian.com>
* providers/imapp/camel-imapp-store.c (store_resp_list)
(imap_login, try_sasl, imap_try_authenticate): removed dead code.
* providers/imapp/camel-imapp-stream.c: return -1 if stream not
set.
* providers/imapp/camel-imapp-engine.c (iterate_completion): put
done request on the done queue, so all requests are always
somewhere.
(camel_imapp_engine_command_free): just spit warnings of active
messages being freed, but abort if the item isn't in any list.
Also remove the node from its list before going on.
(iterate_untagged, iterate_continuation, iterate_completion):
staticifiy.
* providers/imapp/camel-imapp-provider.c
(camel_imapp_module_init): move camel_exception_setup call here.
* providers/imapp/camel-imapp-driver.c
(camel_imapp_driver_get_type): remove execption setup here, it
isn't early enough.
(camel_imapp_driver_list): handle exceptions.
svn path=/trunk/; revision=22583
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 25 | ||||
-rw-r--r-- | camel/providers/imapp/camel-imapp-driver.c | 54 | ||||
-rw-r--r-- | camel/providers/imapp/camel-imapp-engine.c | 34 | ||||
-rw-r--r-- | camel/providers/imapp/camel-imapp-engine.h | 1 | ||||
-rw-r--r-- | camel/providers/imapp/camel-imapp-provider.c | 6 | ||||
-rw-r--r-- | camel/providers/imapp/camel-imapp-store.c | 215 | ||||
-rw-r--r-- | camel/providers/imapp/camel-imapp-stream.c | 4 |
7 files changed, 100 insertions, 239 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 66a7e8f731..7f898f9d54 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,28 @@ +2003-09-15 Not Zed <NotZed@Ximian.com> + + * providers/imapp/camel-imapp-store.c (store_resp_list) + (imap_login, try_sasl, imap_try_authenticate): removed dead code. + + * providers/imapp/camel-imapp-stream.c: return -1 if stream not + set. + + * providers/imapp/camel-imapp-engine.c (iterate_completion): put + done request on the done queue, so all requests are always + somewhere. + (camel_imapp_engine_command_free): just spit warnings of active + messages being freed, but abort if the item isn't in any list. + Also remove the node from its list before going on. + (iterate_untagged, iterate_continuation, iterate_completion): + staticifiy. + + * providers/imapp/camel-imapp-provider.c + (camel_imapp_module_init): move camel_exception_setup call here. + + * providers/imapp/camel-imapp-driver.c + (camel_imapp_driver_get_type): remove execption setup here, it + isn't early enough. + (camel_imapp_driver_list): handle exceptions. + 2003-09-12 Jeffrey Stedfast <fejj@ximian.com> * providers/local/camel-mbox-folder.c diff --git a/camel/providers/imapp/camel-imapp-driver.c b/camel/providers/imapp/camel-imapp-driver.c index f9daced770..b0644dc199 100644 --- a/camel/providers/imapp/camel-imapp-driver.c +++ b/camel/providers/imapp/camel-imapp-driver.c @@ -69,10 +69,6 @@ camel_imapp_driver_get_type (void) NULL, (CamelObjectInitFunc) object_init, (CamelObjectFinalizeFunc) object_finalise); - - /* blah ... could just use it in object setup? */ - /* TEMPORARY */ - camel_exception_setup(); } return type; @@ -475,7 +471,7 @@ camel_imapp_driver_fetch(CamelIMAPPDriver *id, CamelIMAPPFolder *folder, const c GPtrArray * camel_imapp_driver_list(CamelIMAPPDriver *id, const char *name, guint32 flags) { - CamelIMAPPCommand *ic; + CamelIMAPPCommand * volatile ic; GPtrArray *res; g_assert(id->list_commands == NULL); @@ -490,23 +486,47 @@ camel_imapp_driver_list(CamelIMAPPDriver *id, const char *name, guint32 flags) id->list_result = g_ptr_array_new(); id->list_flags = flags; - ic = camel_imapp_engine_command_new(id->engine, "LIST", NULL, "LIST \"\" %f", name[0]?name:"%"); - camel_imapp_engine_command_queue(id->engine, ic); - while (ic) { - while (camel_imapp_engine_iterate(id->engine, ic)>0) - ; + CAMEL_TRY { + ic = camel_imapp_engine_command_new(id->engine, "LIST", NULL, "LIST \"\" %f", name[0]?name:"%"); + camel_imapp_engine_command_queue(id->engine, ic); + while (ic) { + while (camel_imapp_engine_iterate(id->engine, ic)>0) + ; + camel_imapp_engine_command_free(id->engine, ic); + + if (id->list_commands) { + GSList *top = id->list_commands; + + id->list_commands = top->next; + ic = top->data; + g_slist_free_1(top); + } else { + ic = NULL; + } + } + } CAMEL_CATCH(e) { + GSList *top = id->list_commands; + int i; + camel_imapp_engine_command_free(id->engine, ic); - if (id->list_commands) { - GSList *top = id->list_commands; + while (top) { + GSList *topn = top->next; - id->list_commands = top->next; - ic = top->data; + camel_imapp_engine_command_free(id->engine, ic); g_slist_free_1(top); - } else { - ic = NULL; + top = topn; } - } + id->list_commands = NULL; + + res = id->list_result; + for (i=0;i<res->len;i++) + imap_free_list(res->pdata[i]); + g_ptr_array_free(res, TRUE); + id->list_result = NULL; + + camel_exception_throw_ex(e); + } CAMEL_DONE; res = id->list_result; id->list_result = NULL; diff --git a/camel/providers/imapp/camel-imapp-engine.c b/camel/providers/imapp/camel-imapp-engine.c index f6cfcbf86c..df14903c5a 100644 --- a/camel/providers/imapp/camel-imapp-engine.c +++ b/camel/providers/imapp/camel-imapp-engine.c @@ -43,6 +43,7 @@ object_init(CamelIMAPPEngine *ie, CamelIMAPPEngineClass *ieclass) ie->handlers = g_hash_table_new(g_str_hash, g_str_equal); e_dlist_init(&ie->active); e_dlist_init(&ie->queue); + e_dlist_init(&ie->done); ie->tagprefix = ieclass->tagprefix; ieclass->tagprefix++; @@ -339,7 +340,7 @@ camel_imapp_engine_skip(CamelIMAPPEngine *imap) } /* handle any untagged responses */ -int +static int iterate_untagged(CamelIMAPPEngine *imap) { unsigned int id, len; @@ -535,6 +536,7 @@ iterate_completion(CamelIMAPPEngine *imap, unsigned char *token) printf("%p: removing command from qwueue, we were at '%s'\n", ic, ic->current->data); printf("%p: removing command\n", ic); e_dlist_remove((EDListNode *)ic); + e_dlist_addtail(&imap->done, (EDListNode *)ic); if (imap->literal == ic) imap->literal = NULL; ic->status = imap_parse_status(imap->stream); @@ -559,6 +561,7 @@ iterate_completion(CamelIMAPPEngine *imap, unsigned char *token) ic = imap->literal; /* set the command complete with a failure code? */ e_dlist_remove((EDListNode *)ic); + e_dlist_addtail(&imap->done, (EDListNode *)ic); imap->literal = NULL; } @@ -660,21 +663,42 @@ camel_imapp_engine_command_free (CamelIMAPPEngine *imap, CamelIMAPPCommand *ic) /* maybe we should just have another queue to keep them? */ { CamelIMAPPCommand *iw; + int found = 0; iw = (CamelIMAPPCommand *)imap->active.head; while (iw->next) { - if (iw == ic) - abort(); + if (iw == ic) { + found = 1; + g_warning("command '%s' still in active queue", iw->name); + break; + } iw = iw->next; } iw = (CamelIMAPPCommand *)imap->queue.head; while (iw->next) { - if (iw == ic) - abort(); + if (iw == ic) { + found = 1; + g_warning("command '%s' still in waiting queue", iw->name); + break; + } + iw = iw->next; + } + iw = (CamelIMAPPCommand *)imap->done.head; + while (iw->next) { + if (iw == ic) { + found = 1; + break; + } iw = iw->next; } + if (!found) { + g_warning("command '%s' not found anywhere", ic->name); + abort(); + } } + e_dlist_remove((EDListNode *)ic); + if (ic->mem) camel_object_unref((CamelObject *)ic->mem); imap_free_status(ic->status); diff --git a/camel/providers/imapp/camel-imapp-engine.h b/camel/providers/imapp/camel-imapp-engine.h index 6db9968d48..5f74d0654a 100644 --- a/camel/providers/imapp/camel-imapp-engine.h +++ b/camel/providers/imapp/camel-imapp-engine.h @@ -115,6 +115,7 @@ struct _CamelIMAPPEngine { CamelIMAPPCommand *literal;/* current literal op */ EDList active; /* active queue */ EDList queue; /* outstanding queue */ + EDList done; /* done queue, awaiting reclamation */ /* keep track of running a select */ struct _CamelIMAPPSelectResponse *select_response; diff --git a/camel/providers/imapp/camel-imapp-provider.c b/camel/providers/imapp/camel-imapp-provider.c index 4abc633498..6b0cdd2d43 100644 --- a/camel/providers/imapp/camel-imapp-provider.c +++ b/camel/providers/imapp/camel-imapp-provider.c @@ -74,6 +74,8 @@ CamelServiceAuthType camel_imapp_password_authtype = { void camel_imapp_module_init(CamelSession *session) { + extern void camel_exception_setup(void); + imapp_provider.object_types[CAMEL_PROVIDER_STORE] = camel_imapp_store_get_type(); imapp_provider.url_hash = camel_url_hash; imapp_provider.url_equal = camel_url_equal; @@ -81,6 +83,10 @@ camel_imapp_module_init(CamelSession *session) imapp_provider.authtypes = g_list_prepend(imapp_provider.authtypes, camel_sasl_authtype_list(FALSE)); imapp_provider.authtypes = g_list_prepend(imapp_provider.authtypes, &camel_imapp_password_authtype); + /* blah ... could just use it in object setup? */ + /* TEMPORARY */ + camel_exception_setup(); + camel_session_register_provider(session, &imapp_provider); } diff --git a/camel/providers/imapp/camel-imapp-store.c b/camel/providers/imapp/camel-imapp-store.c index ae02bcb54e..9123102a03 100644 --- a/camel/providers/imapp/camel-imapp-store.c +++ b/camel/providers/imapp/camel-imapp-store.c @@ -337,203 +337,6 @@ imap_query_auth_types (CamelService *service, CamelException *ex) return types; } -#if 0 -static int -try_sasl(CamelIMAPPStore *store, const char *mech, CamelException *ex) -{ - CamelIMAPPStream *stream = store->engine->stream; - unsigned char *line, *resp; - CamelSasl *sasl; - unsigned int len; - int ret; - - sasl = camel_sasl_new("imap", mech, (CamelService *)store); - if (sasl == NULL) { - camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - _("Unable to connect to POP server.\n" - "No support for requested " - "authentication mechanism.")); - return -1; - } - - if (camel_stream_printf((CamelStream *)stream, "AUTH %s\r\n", mech) == -1) - goto ioerror; - - while (1) { - if (camel_imapp_stream_line(stream, &line, &len) == -1) - goto ioerror; - if (strncmp(line, "+OK", 3) == 0) - break; - if (strncmp(line, "-ERR", 4) == 0) { - camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - _("SASL `%s' Login failed: %s"), mech, line); - goto done; - } - /* If we dont get continuation, or the sasl object's run out of work, or we dont get a challenge, - its a protocol error, so fail, and try reset the server */ - if (strncmp(line, "+ ", 2) != 0 - || camel_sasl_authenticated(sasl) - || (resp = camel_sasl_challenge_base64(sasl, line+2, ex)) == NULL) { - camel_stream_printf((CamelStream *)stream, "*\r\n"); - camel_imapp_stream_line(stream, &line, &len); - camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - _("SASL Protocol error")); - goto done; - } - - ret = camel_stream_printf((CamelStream *)stream, "%s\r\n", resp); - g_free(resp); - if (ret == -1) - goto ioerror; - - } - camel_object_unref((CamelObject *)sasl); - return 0; - -ioerror: - camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - _("I/O Error: %s"), strerror(errno)); -done: - camel_object_unref((CamelObject *)sasl); - return -1; -} - -static gboolean -imap_try_authenticate (CamelService *service, const char *errmsg, CamelException *ex) -{ - CamelIMAPPStore *store = (CamelIMAPPStore *)service; - CamelIMAPPCommand *pcu = NULL, *pcp = NULL; - int status; - - /* override, testing only */ - /*printf("Forcing authmech to 'login'\n"); - service->url->authmech = g_strdup("LOGIN");*/ - - if (!service->url->passwd) { - char *prompt; - - prompt = g_strdup_printf (_("%sPlease enter the POP password for %s@%s"), - errmsg ? errmsg : "", - service->url->user, - service->url->host); - service->url->passwd = camel_session_get_password (camel_service_get_session (service), - prompt, TRUE, service, "password", ex); - g_free (prompt); - if (!service->url->passwd) - return FALSE; - } - - if (!service->url->authmech) { - /* pop engine will take care of pipelining ability */ - pcu = camel_imapp_engine_command_new(store->engine, 0, NULL, NULL, "USER %s\r\n", service->url->user); - pcp = camel_imapp_engine_command_new(store->engine, 0, NULL, NULL, "PASS %s\r\n", service->url->passwd); - } else if (strcmp(service->url->authmech, "+APOP") == 0 && store->engine->apop) { - char *secret, md5asc[33], *d; - unsigned char md5sum[16], *s; - - secret = alloca(strlen(store->engine->apop)+strlen(service->url->passwd)+1); - sprintf(secret, "%s%s", store->engine->apop, service->url->passwd); - md5_get_digest(secret, strlen (secret), md5sum); - - for (s = md5sum, d = md5asc; d < md5asc + 32; s++, d += 2) - sprintf (d, "%.2x", *s); - - pcp = camel_imapp_engine_command_new(store->engine, 0, NULL, NULL, "APOP %s %s\r\n", service->url->user, md5asc); - } else { - CamelServiceAuthType *auth; - GList *l; - - l = store->engine->auth; - while (l) { - auth = l->data; - if (strcmp(auth->authproto, service->url->authmech) == 0) - return try_sasl(store, service->url->authmech, ex) == -1; - l = l->next; - } - - camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - _("Unable to connect to POP server.\n" - "No support for requested " - "authentication mechanism.")); - return FALSE; - } - - while ((status = camel_imapp_engine_iterate (store->engine, pcp)) > 0) - ; - - if (pcp->state != CAMEL_IMAPP_COMMAND_OK) { - if (status == -1) - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to connect to POP server.\nError sending password: %s"), - errno ? g_strerror (errno) : _("Unknown error")); - else - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - _("Unable to connect to POP server.\nError sending password: %s"), - store->engine->line); - } - camel_imapp_engine_command_free(store->engine, pcp); - - if (pcu) - camel_imapp_engine_command_free(store->engine, pcu); - - return status; -} -#endif - -static gboolean -imap_login(CamelService *service, char *msg) -{ - CamelIMAPPStore *store = (CamelIMAPPStore *)service; - CamelIMAPPCommand * volatile ic = NULL; - - /* override, testing only */ - /*printf("Forcing authmech to 'login'\n"); - service->url->authmech = g_strdup("LOGIN");*/ - - CAMEL_TRY { - if (!service->url->passwd) { - char *prompt; - CamelException *ex = camel_exception_new(); - - prompt = g_strdup_printf (_("%sPlease enter the IMAP password for %s@%s"), - msg?msg:"", - service->url->user, - service->url->host); - service->url->passwd = camel_session_get_password(camel_service_get_session(service), prompt, FALSE, TRUE, service, "password", ex); - g_free (prompt); - if (camel_exception_is_set(ex)) - camel_exception_throw_ex(ex); - } - - if (service->url->authmech) { - CamelSasl *sasl = camel_sasl_new("imap", service->url->authmech, service); - - if (sasl == NULL) - camel_exception_throw(1, "unsupported authentication mechanism: %s", service->url->authmech); - ic = camel_imapp_engine_command_new(store->driver->engine, "AUTHENTICATE", NULL, "AUTHENTICATE %A", sasl); - camel_object_unref((CamelObject *)sasl); - } else { - ic = camel_imapp_engine_command_new(store->driver->engine, "LOGIN", NULL, "LOGIN %s %s", service->url->user, service->url->passwd); - } - - camel_imapp_engine_command_queue(store->driver->engine, ic); - while (camel_imapp_engine_iterate(store->driver->engine, ic) > 0) - ; - - if (ic->status->result != IMAP_OK) - camel_exception_throw(CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, "Login failed: %s", ic->status->text); - } CAMEL_CATCH(ex) { - if (ic) - camel_imapp_engine_command_free(store->driver->engine, ic); - camel_exception_throw_ex(ex); - } CAMEL_DONE; - - if (ic) - camel_imapp_engine_command_free(store->driver->engine, ic); - - return TRUE; -} - static void store_get_pass(CamelIMAPPStore *store) { @@ -977,24 +780,6 @@ imap_create_folder(CamelStore *store, const char *parent_name, const char *folde } /* ********************************************************************** */ - -static int store_resp_list(CamelIMAPPEngine *ie, guint32 id, void *data) -{ - struct _list_info *linfo; - CamelIMAPPStore *istore = data; - - linfo = imap_parse_list(ie->stream); - printf("store list: '%s' ('%c')\n", linfo->name, linfo->separator); - if (istore->pending_list) - g_ptr_array_add(istore->pending_list, linfo); - else { - g_warning("unexpected list response\n"); - imap_free_list(linfo); - } - - return camel_imapp_engine_skip(ie); -} - #if 0 static int store_resp_fetch(CamelIMAPPEngine *ie, guint32 id, void *data) { diff --git a/camel/providers/imapp/camel-imapp-stream.c b/camel/providers/imapp/camel-imapp-stream.c index a9567bf4f8..20876beae2 100644 --- a/camel/providers/imapp/camel-imapp-stream.c +++ b/camel/providers/imapp/camel-imapp-stream.c @@ -70,9 +70,9 @@ stream_fill(CamelIMAPPStream *is) } } - printf("camel_imapp_read: 0\n"); + printf("camel_imapp_read: -1\n"); - return 0; + return -1; } static ssize_t |