Clean up some exception misusage.
2001-07-17 Peter Williams <peterw@ximian.com> Clean up some exception misusage. * providers/imap/camel-imap-command.c (camel_imap_command): Use our own internal exception for sending the string and transfer it to @ex if anything goes wrong. (imap_read_response): Use our own internal exception for reading the untagged responses and blah blah blah. * camel-session.c (get_service): Use our own internal exception when constructing the service and transfer it to @ex if anything goes wrong. * camel-remote-store.c (remote_recv_line): Instead of having gboolean exception, use our own internal exception and copy it to @ex if anything goes wrong. * camel-store.c (store_sync): Create an internal exception because sync_folder() checks it for validity. Transfer it to @ex when done. * camel-exception.c (camel_exception_get_description): If @ex is NULL, complain - passing NULL exceptions to Camel is okay, but there should be no circumstances under which they're then examined. (camel_exception_get_id): Same here, (camel_exception_xfer): NULL-protect and warn if transferring from a NULL exception. svn path=/trunk/; revision=11177
This commit is contained in:
committed by
Peter Williams
parent
bbfb9268af
commit
e8aa23866a
@ -1,3 +1,33 @@
|
||||
2001-07-17 Peter Williams <peterw@ximian.com>
|
||||
|
||||
Clean up some exception misusage.
|
||||
|
||||
* providers/imap/camel-imap-command.c (camel_imap_command): Use
|
||||
our own internal exception for sending the string and transfer it
|
||||
to @ex if anything goes wrong.
|
||||
(imap_read_response): Use our own internal exception for reading
|
||||
the untagged responses and blah blah blah.
|
||||
|
||||
* camel-session.c (get_service): Use our own internal exception
|
||||
when constructing the service and transfer it to @ex if anything
|
||||
goes wrong.
|
||||
|
||||
* camel-remote-store.c (remote_recv_line): Instead of having
|
||||
gboolean exception, use our own internal exception and copy
|
||||
it to @ex if anything goes wrong.
|
||||
|
||||
* camel-store.c (store_sync): Create an internal exception
|
||||
because sync_folder() checks it for validity. Transfer it to
|
||||
@ex when done.
|
||||
|
||||
* camel-exception.c (camel_exception_get_description): If @ex is
|
||||
NULL, complain - passing NULL exceptions to Camel is okay, but
|
||||
there should be no circumstances under which they're then
|
||||
examined.
|
||||
(camel_exception_get_id): Same here,
|
||||
(camel_exception_xfer): NULL-protect and warn if transferring from
|
||||
a NULL exception.
|
||||
|
||||
2001-07-17 Jeffrey Stedfast <fejj@ximian.com>
|
||||
|
||||
* camel-store.c (init_trash): Use CAMEL_VTRASH_NAME.
|
||||
|
||||
@ -227,6 +227,17 @@ void
|
||||
camel_exception_xfer (CamelException *ex_dst,
|
||||
CamelException *ex_src)
|
||||
{
|
||||
if (ex_src == NULL) {
|
||||
g_warning ("camel_exception_xfer: trying to transfer NULL exception to %p\n", ex_dst);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ex_dst == NULL) {
|
||||
/* must have same side-effects */
|
||||
camel_exception_clear (ex_src);
|
||||
return;
|
||||
}
|
||||
|
||||
CAMEL_EXCEPTION_LOCK(exception);
|
||||
|
||||
if (ex_dst->desc)
|
||||
@ -255,8 +266,10 @@ camel_exception_get_id (CamelException *ex)
|
||||
{
|
||||
if (ex)
|
||||
return ex->id;
|
||||
else
|
||||
else {
|
||||
g_warning ("camel_exception_get_id called with NULL parameter.");
|
||||
return CAMEL_EXCEPTION_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -276,6 +289,8 @@ camel_exception_get_description (CamelException *ex)
|
||||
|
||||
if (ex)
|
||||
ret = ex->desc;
|
||||
|
||||
else
|
||||
g_warning ("camel_exception_get_description called with NULL parameter.");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -453,7 +453,7 @@ remote_recv_line (CamelRemoteStore *store, char **dest, CamelException *ex)
|
||||
CamelStreamBuffer *stream;
|
||||
GByteArray *bytes;
|
||||
gchar buf[1024], *ret;
|
||||
gboolean exception = FALSE;
|
||||
CamelException internal_ex;
|
||||
gint nread;
|
||||
|
||||
*dest = NULL;
|
||||
@ -478,18 +478,18 @@ remote_recv_line (CamelRemoteStore *store, char **dest, CamelException *ex)
|
||||
g_byte_array_append (bytes, buf, nread);
|
||||
} while (nread == sizeof (buf) - 1);
|
||||
|
||||
camel_exception_init (&internal_ex);
|
||||
if (nread == -1) {
|
||||
exception = TRUE;
|
||||
if (errno == EINTR)
|
||||
camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled"));
|
||||
camel_exception_set(&internal_ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled"));
|
||||
else
|
||||
camel_exception_set(ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, strerror(errno));
|
||||
} else if (bytes->len == 0) {
|
||||
exception = TRUE;
|
||||
camel_exception_set(ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
|
||||
camel_exception_set(&internal_ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, strerror(errno));
|
||||
} else if (bytes->len == 0)
|
||||
camel_exception_set(&internal_ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
|
||||
_("Server unexpectedly disconnected"));
|
||||
}
|
||||
if (camel_exception_is_set (ex) || exception) {
|
||||
|
||||
if (camel_exception_is_set (&internal_ex)) {
|
||||
camel_exception_xfer (ex, &internal_ex);
|
||||
g_byte_array_free(bytes, TRUE);
|
||||
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
|
||||
return -1;
|
||||
|
||||
@ -351,7 +351,7 @@ get_service (CamelSession *session, const char *url_string,
|
||||
CamelURL *url;
|
||||
CamelProvider *provider;
|
||||
CamelService *service;
|
||||
|
||||
CamelException internal_ex;
|
||||
url = camel_url_new (url_string, ex);
|
||||
if (!url)
|
||||
return NULL;
|
||||
@ -379,8 +379,10 @@ get_service (CamelSession *session, const char *url_string,
|
||||
}
|
||||
|
||||
service = (CamelService *)camel_object_new (provider->object_types[type]);
|
||||
camel_service_construct (service, session, provider, url, ex);
|
||||
if (camel_exception_is_set (ex)) {
|
||||
camel_exception_init (&internal_ex);
|
||||
camel_service_construct (service, session, provider, url, &internal_ex);
|
||||
if (camel_exception_is_set (&internal_ex)) {
|
||||
camel_exception_xfer (ex, &internal_ex);
|
||||
camel_object_unref (CAMEL_OBJECT (service));
|
||||
service = NULL;
|
||||
} else {
|
||||
|
||||
@ -444,9 +444,13 @@ static void
|
||||
store_sync (CamelStore *store, CamelException *ex)
|
||||
{
|
||||
if (store->folders) {
|
||||
CamelException internal_ex;
|
||||
|
||||
camel_exception_init (&internal_ex);
|
||||
CAMEL_STORE_LOCK(store, cache_lock);
|
||||
g_hash_table_foreach (store->folders, sync_folder, ex);
|
||||
g_hash_table_foreach (store->folders, sync_folder, &internal_ex);
|
||||
CAMEL_STORE_UNLOCK(store, cache_lock);
|
||||
camel_exception_xfer (ex, &internal_ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -86,6 +86,7 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder,
|
||||
{
|
||||
gchar *cmdbuf;
|
||||
va_list ap;
|
||||
CamelException internal_ex;
|
||||
|
||||
CAMEL_IMAP_STORE_LOCK (store, command_lock);
|
||||
|
||||
@ -127,11 +128,13 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder,
|
||||
cmdbuf = imap_command_strdup_vprintf (store, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
camel_remote_store_send_string (CAMEL_REMOTE_STORE (store), ex,
|
||||
camel_exception_init (&internal_ex);
|
||||
camel_remote_store_send_string (CAMEL_REMOTE_STORE (store), &internal_ex,
|
||||
"%c%.5d %s\r\n", store->tag_prefix,
|
||||
store->command++, cmdbuf);
|
||||
g_free (cmdbuf);
|
||||
if (camel_exception_is_set (ex)) {
|
||||
if (camel_exception_is_set (&internal_ex)) {
|
||||
camel_exception_xfer (ex, &internal_ex);
|
||||
CAMEL_IMAP_STORE_UNLOCK (store, command_lock);
|
||||
return NULL;
|
||||
}
|
||||
@ -172,6 +175,7 @@ static CamelImapResponse *
|
||||
imap_read_response (CamelImapStore *store, CamelException *ex)
|
||||
{
|
||||
CamelImapResponse *response;
|
||||
CamelException internal_ex;
|
||||
char *respbuf, *retcode;
|
||||
|
||||
/* Read first line */
|
||||
@ -189,11 +193,13 @@ imap_read_response (CamelImapStore *store, CamelException *ex)
|
||||
}
|
||||
response->untagged = g_ptr_array_new ();
|
||||
|
||||
camel_exception_init (&internal_ex);
|
||||
|
||||
/* Check for untagged data */
|
||||
while (!strncmp (respbuf, "* ", 2)) {
|
||||
/* Read the rest of the response if it is multi-line. */
|
||||
respbuf = imap_read_untagged (store, respbuf, ex);
|
||||
if (camel_exception_is_set (ex))
|
||||
respbuf = imap_read_untagged (store, respbuf, &internal_ex);
|
||||
if (camel_exception_is_set (&internal_ex))
|
||||
break;
|
||||
|
||||
if (!g_strncasecmp (respbuf, "* BYE", 5)) {
|
||||
@ -210,7 +216,8 @@ imap_read_response (CamelImapStore *store, CamelException *ex)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!respbuf || camel_exception_is_set (ex)) {
|
||||
if (!respbuf || camel_exception_is_set (&internal_ex)) {
|
||||
camel_exception_xfer (ex, &internal_ex);
|
||||
camel_imap_response_free_without_processing (store, response);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user