diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 8 | ||||
-rw-r--r-- | mail/mail-ops.c | 572 |
2 files changed, 95 insertions, 485 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index ffe6d54400..200f4df407 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,11 @@ +2000-09-25 Dan Winship <danw@helixcode.com> + + * mail-ops.c: CamelException is not for compile-time errors. + Replace lots of argument checks in setup_ functions with + g_return_if_fails in the public functions. Also remove some + prototypes that weren't needed because they were for static + functions that are defined before they're used. + 2000-09-23 Michael Meeks <michael@helixcode.com> * folder-browser-factory.c (set_pixmap): upd. diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 6d049fdfe1..a2fd820dfa 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -5,7 +5,6 @@ * Author : * Dan Winship <danw@helixcode.com> * Peter Williams <peterw@helixcode.com> - * Jeffrey Stedfast <fejj@helixcode.com> * * Copyright 2000 Helix Code, Inc. (http://www.helixcode.com) * @@ -50,28 +49,20 @@ typedef struct fetch_mail_data_s { gboolean empty; } fetch_mail_data_t; -static gchar *describe_fetch_mail (gpointer in_data, gboolean gerund); -static void setup_fetch_mail (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_fetch_mail (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_fetch_mail (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_fetch_mail (gpointer in_data, gboolean gerund) { fetch_mail_input_t *input = (fetch_mail_input_t *) in_data; char *name; - + /*source = camel_session_get_store (session, input->source_url, NULL); *if (source) { * name = camel_service_get_name (CAMEL_SERVICE (source), FALSE); * camel_object_unref (CAMEL_OBJECT (source)); *} else */ - name = input->source_url; - + name = input->source_url; + if (gerund) return g_strdup_printf (_("Fetching email from %s"), name); else @@ -83,25 +74,10 @@ setup_fetch_mail (gpointer in_data, gpointer op_data, CamelException *ex) { fetch_mail_input_t *input = (fetch_mail_input_t *) in_data; fetch_mail_data_t *data = (fetch_mail_data_t *) op_data; - - if (!input->source_url) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - _("You have no remote mail source configured " - "to fetch mail from.")); - return; - } - - if (input->destination == NULL) - return; - - if (!CAMEL_IS_FOLDER (input->destination)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - _("Bad folder passed to fetch_mail")); - return; - } - + data->empty = FALSE; - camel_object_ref (CAMEL_OBJECT (input->destination)); + if (input->destination) + camel_object_ref (CAMEL_OBJECT (input->destination)); } static void @@ -291,6 +267,10 @@ mail_do_fetch_mail (const gchar *source_url, gboolean keep_on_server, { fetch_mail_input_t *input; + g_return_if_fail (source_url != NULL); + g_return_if_fail (destination == NULL || + CAMEL_IS_FOLDER (input->destination)); + input = g_new (fetch_mail_input_t, 1); input->source_url = g_strdup (source_url); input->keep_on_server = keep_on_server; @@ -310,23 +290,9 @@ typedef struct filter_ondemand_input_s CamelFolder *destination; } filter_ondemand_input_t; -typedef struct filter_ondemand_data_s { - gboolean empty; -} filter_ondemand_data_t; - -static gchar *describe_filter_ondemand (gpointer in_data, gboolean gerund); -static void setup_filter_ondemand (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_filter_ondemand (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_filter_ondemand (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_filter_ondemand (gpointer in_data, gboolean gerund) { - /*filter_ondemand_input_t *input = (filter_ondemand_input_t *) in_data;*/ - if (gerund) return g_strdup_printf (_("Filtering email on demand")); else @@ -337,49 +303,21 @@ static void setup_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex) { filter_ondemand_input_t *input = (filter_ondemand_input_t *) in_data; - filter_ondemand_data_t *data = (filter_ondemand_data_t *) op_data; - - if (!IS_FILTER_CONTEXT (input->context)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - _("Bad filter context specified")); - return; - } - - if (input->source == NULL) - return; - - if (!CAMEL_IS_FOLDER (input->source)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - _("Bad input source defined for filtering")); - return; - } - - if (input->destination == NULL) - return; - - if (!CAMEL_IS_FOLDER (input->destination)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - _("Bad default destination folder")); - return; - } - - data->empty = FALSE; - + gtk_object_ref (GTK_OBJECT (input->context)); - camel_object_ref (CAMEL_OBJECT (input->source)); - camel_object_ref (CAMEL_OBJECT (input->destination)); + if (input->source) + camel_object_ref (CAMEL_OBJECT (input->source)); + if (input->destination) + camel_object_ref (CAMEL_OBJECT (input->destination)); } static void do_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex) { filter_ondemand_input_t *input = (filter_ondemand_input_t *) in_data; - filter_ondemand_data_t *data = (filter_ondemand_data_t *) op_data; mail_tool_camel_lock_up (); - if (camel_folder_get_message_count (input->source) == 0) { - data->empty = TRUE; - } else { + if (camel_folder_get_message_count (input->source) != 0) { FilterDriver *driver; GPtrArray *uids; int i; @@ -435,8 +373,6 @@ do_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex) camel_folder_thaw (input->source); camel_folder_free_uids (input->source, uids); - - data->empty = FALSE; } mail_tool_camel_lock_down (); } @@ -445,7 +381,6 @@ static void cleanup_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex) { filter_ondemand_input_t *input = (filter_ondemand_input_t *) in_data; - /*filter_ondemand_data_t *data = (filter_ondemand_data_t *) op_data;*/ if (input->source) camel_object_unref (CAMEL_OBJECT (input->source)); @@ -459,7 +394,7 @@ cleanup_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex) static const mail_operation_spec op_filter_ondemand = { describe_filter_ondemand, - sizeof (filter_ondemand_data_t), + 0, setup_filter_ondemand, do_filter_ondemand, cleanup_filter_ondemand @@ -470,6 +405,10 @@ mail_do_filter_ondemand (FilterContext *context, CamelFolder *source, CamelFolde { filter_ondemand_input_t *input; + g_return_if_fail (IS_FILTER_CONTEXT (context)); + g_return_if_fail (source == NULL || CAMEL_IS_FOLDER (source)); + g_return_if_fail (destination == NULL || CAMEL_IS_FOLDER (destination)); + input = g_new (filter_ondemand_input_t, 1); input->context = context; input->source = source; @@ -496,15 +435,6 @@ typedef struct send_mail_input_s } send_mail_input_t; -static gchar *describe_send_mail (gpointer in_data, gboolean gerund); -static void setup_send_mail (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_send_mail (gpointer in_data, gpointer op_data, - - CamelException *ex); -static void cleanup_send_mail (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_send_mail (gpointer in_data, gboolean gerund) { @@ -532,45 +462,9 @@ setup_send_mail (gpointer in_data, gpointer op_data, CamelException *ex) { send_mail_input_t *input = (send_mail_input_t *) in_data; - if (!input->xport_uri) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't really need i18n */ - "No transport URI specified for send_mail operation."); - return; - } - - if (!CAMEL_IS_MIME_MESSAGE (input->message)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No message specified for send_mail operation."); - return; - } - - /* NOTE THE EARLY EXIT!! */ - - if (input->done_folder == NULL) { - camel_object_ref (CAMEL_OBJECT (input->message)); - if (input->composer) { - gtk_object_ref (GTK_OBJECT (input->composer)); - gtk_widget_hide (GTK_WIDGET (input->composer)); - } - return; - } - - if (!CAMEL_IS_FOLDER (input->done_folder)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "Bad done_folder specified for send_mail operation."); - return; - } - - if (input->done_uid == NULL) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No done_uid specified for send_mail operation."); - return; - } - camel_object_ref (CAMEL_OBJECT (input->message)); - camel_object_ref (CAMEL_OBJECT (input->done_folder)); - + if (input->done_folder) + camel_object_ref (CAMEL_OBJECT (input->done_folder)); if (input->composer) { gtk_object_ref (GTK_OBJECT (input->composer)); gtk_widget_hide (GTK_WIDGET (input->composer)); @@ -671,6 +565,12 @@ mail_do_send_mail (const char *xport_uri, { send_mail_input_t *input; + g_return_if_fail (xport_uri != NULL); + g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message)); + g_return_if_fail (done_folder == NULL || + CAMEL_IS_FOLDER (done_folder)); + g_return_if_fail (done_folder == NULL || done_uid != NULL); + input = g_new (send_mail_input_t, 1); input->xport_uri = g_strdup (xport_uri); input->message = message; @@ -691,14 +591,6 @@ typedef struct send_queue_input_s } send_queue_input_t; -static gchar *describe_send_queue (gpointer in_data, gboolean gerund); -static void setup_send_queue (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_send_queue (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_send_queue (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_send_queue (gpointer in_data, gboolean gerund) { @@ -716,19 +608,6 @@ setup_send_queue (gpointer in_data, gpointer op_data, CamelException *ex) { send_queue_input_t *input = (send_queue_input_t *) in_data; - if (!input->xport_uri) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't really need i18n */ - "No transport URI specified for send_queue operation."); - return; - } - - if (!CAMEL_IS_FOLDER (input->folder_queue)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No queue specified for send_queue operation."); - return; - } - camel_object_ref (CAMEL_OBJECT (input->folder_queue)); } @@ -827,7 +706,10 @@ mail_do_send_queue (CamelFolder *folder_queue, const char *xport_uri) { send_queue_input_t *input; - + + g_return_if_fail (xport_uri != NULL); + g_return_if_fail (CAMEL_IS_FOLDER (folder_queue)); + input = g_new (send_queue_input_t, 1); input->xport_uri = g_strdup (xport_uri); input->folder_queue = folder_queue; @@ -846,14 +728,6 @@ typedef struct append_mail_input_s } append_mail_input_t; -static gchar *describe_append_mail (gpointer in_data, gboolean gerund); -static void setup_append_mail (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_append_mail (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_append_mail (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_append_mail (gpointer in_data, gboolean gerund) { @@ -880,18 +754,6 @@ setup_append_mail (gpointer in_data, gpointer op_data, CamelException *ex) { append_mail_input_t *input = (append_mail_input_t *) in_data; - if (!CAMEL_IS_MIME_MESSAGE (input->message)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No message specified for append_mail operation."); - return; - } - - if (!CAMEL_IS_FOLDER (input->folder)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "Bad done_folder specified for append_mail operation."); - return; - } - camel_object_ref (CAMEL_OBJECT (input->message)); camel_object_ref (CAMEL_OBJECT (input->folder)); } @@ -936,6 +798,9 @@ mail_do_append_mail (CamelFolder *folder, { append_mail_input_t *input; + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message)); + input = g_new (append_mail_input_t, 1); input->folder = folder; input->message = message; @@ -946,14 +811,6 @@ mail_do_append_mail (CamelFolder *folder, /* ** EXPUNGE FOLDER ****************************************************** */ -static gchar *describe_expunge_folder (gpointer in_data, gboolean gerund); -static void setup_expunge_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_expunge_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_expunge_folder (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_expunge_folder (gpointer in_data, gboolean gerund) { @@ -968,13 +825,6 @@ describe_expunge_folder (gpointer in_data, gboolean gerund) static void setup_expunge_folder (gpointer in_data, gpointer op_data, CamelException *ex) { - if (!CAMEL_IS_FOLDER (in_data)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No folder is selected to be expunged"); - return; - } - camel_object_ref (CAMEL_OBJECT (in_data)); } @@ -1004,6 +854,8 @@ static const mail_operation_spec op_expunge_folder = { void mail_do_expunge_folder (CamelFolder *folder) { + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + mail_operation_queue (&op_expunge_folder, folder, FALSE); } @@ -1018,14 +870,6 @@ typedef struct transfer_messages_input_s } transfer_messages_input_t; -static gchar *describe_transfer_messages (gpointer in_data, gboolean gerund); -static void setup_transfer_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_transfer_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_transfer_messages (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_transfer_messages (gpointer in_data, gboolean gerund) { @@ -1051,37 +895,9 @@ describe_transfer_messages (gpointer in_data, gboolean gerund) static void setup_transfer_messages (gpointer in_data, gpointer op_data, - CamelException *ex) + CamelException *ex) { transfer_messages_input_t *input = (transfer_messages_input_t *) in_data; - char *verb; - - if (input->delete_from_source) - /* don't need i18n */ - verb = "move"; - else - verb = "copy"; - - if (!CAMEL_IS_FOLDER (input->source)) { - camel_exception_setv (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No source folder to %s messages from specified.", - verb); - return; - } - - if (input->uids == NULL) { - camel_exception_setv (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No messages to %s have been specified.", - verb); - return; - } - - if (input->dest_uri == NULL) { - camel_exception_setv (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No URI to %s to has been specified.", - verb); - return; - } camel_object_ref (CAMEL_OBJECT (input->source)); } @@ -1133,7 +949,7 @@ do_transfer_messages (gpointer in_data, gpointer op_data, CamelException *ex) static void cleanup_transfer_messages (gpointer in_data, gpointer op_data, - CamelException *ex) + CamelException *ex) { transfer_messages_input_t *input = (transfer_messages_input_t *) in_data; @@ -1152,11 +968,15 @@ static const mail_operation_spec op_transfer_messages = { void mail_do_transfer_messages (CamelFolder *source, GPtrArray *uids, - gboolean delete_from_source, - gchar *dest_uri) + gboolean delete_from_source, + gchar *dest_uri) { transfer_messages_input_t *input; + g_return_if_fail (CAMEL_IS_FOLDER (source)); + g_return_if_fail (uids != NULL); + g_return_if_fail (dest_uri != NULL); + input = g_new (transfer_messages_input_t, 1); input->source = source; input->uids = uids; @@ -1179,14 +999,6 @@ typedef struct flag_messages_input_s } flag_messages_input_t; -static gchar *describe_flag_messages (gpointer in_data, gboolean gerund); -static void setup_flag_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_flag_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_flag_messages (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_flag_messages (gpointer in_data, gboolean gerund) { @@ -1207,19 +1019,6 @@ setup_flag_messages (gpointer in_data, gpointer op_data, CamelException *ex) { flag_messages_input_t *input = (flag_messages_input_t *) in_data; - if (!CAMEL_IS_FOLDER (input->source)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No source folder to flag messages from specified."); - return; - } - - if (!input->flag_all && input->uids == NULL) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No messages to flag have been specified."); - return; - } - camel_object_ref (CAMEL_OBJECT (input->source)); } @@ -1292,6 +1091,9 @@ mail_do_flag_messages (CamelFolder *source, GPtrArray *uids, { flag_messages_input_t *input; + g_return_if_fail (CAMEL_IS_FOLDER (source)); + g_return_if_fail (uids != NULL); + input = g_new (flag_messages_input_t, 1); input->source = source; input->uids = uids; @@ -1309,6 +1111,8 @@ mail_do_flag_all_messages (CamelFolder *source, gboolean invert, { flag_messages_input_t *input; + g_return_if_fail (CAMEL_IS_FOLDER (source)); + input = g_new (flag_messages_input_t, 1); input->source = source; input->uids = NULL; @@ -1343,14 +1147,6 @@ typedef struct scan_subfolders_op_s } scan_subfolders_op_t; -static gchar *describe_scan_subfolders (gpointer in_data, gboolean gerund); -static void setup_scan_subfolders (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_scan_subfolders (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_scan_subfolders (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_scan_subfolders (gpointer in_data, gboolean gerund) { @@ -1371,19 +1167,6 @@ setup_scan_subfolders (gpointer in_data, gpointer op_data, scan_subfolders_input_t *input = (scan_subfolders_input_t *) in_data; scan_subfolders_op_t *data = (scan_subfolders_op_t *) op_data; - if (!input->source_uri) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No source uri to scan subfolders from was provided."); - return; - } - - if (!EVOLUTION_IS_STORAGE (input->storage)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No storage to scan subfolders into was provided."); - return; - } - gtk_object_ref (GTK_OBJECT (input->storage)); data->new_folders = g_ptr_array_new (); } @@ -1475,6 +1258,9 @@ mail_do_scan_subfolders (const gchar *source_uri, EvolutionStorage *storage) { scan_subfolders_input_t *input; + g_return_if_fail (source_uri != NULL); + g_return_if_fail (EVOLUTION_IS_STORAGE (storage)); + input = g_new (scan_subfolders_input_t, 1); input->source_uri = g_strdup (source_uri); input->storage = storage; @@ -1498,14 +1284,6 @@ typedef struct attach_message_data_s } attach_message_data_t; -static gchar *describe_attach_message (gpointer in_data, gboolean gerund); -static void setup_attach_message (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_attach_message (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_attach_message (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_attach_message (gpointer in_data, gboolean gerund) { @@ -1526,25 +1304,6 @@ setup_attach_message (gpointer in_data, gpointer op_data, CamelException *ex) { attach_message_input_t *input = (attach_message_input_t *) in_data; - if (!input->uid) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No UID specified to attach."); - return; - } - - if (!CAMEL_IS_FOLDER (input->folder)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No folder to fetch the message from specified."); - return; - } - - if (!E_IS_MSG_COMPOSER (input->composer)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No message composer from specified."); - return; - } - camel_object_ref (CAMEL_OBJECT (input->folder)); gtk_object_ref (GTK_OBJECT (input->composer)); } @@ -1602,6 +1361,10 @@ mail_do_attach_message (CamelFolder *folder, const char *uid, { attach_message_input_t *input; + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + g_return_if_fail (uid != NULL); + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + input = g_new (attach_message_input_t, 1); input->folder = folder; input->uid = g_strdup (uid); @@ -1628,14 +1391,6 @@ typedef struct forward_messages_data_s } forward_messages_data_t; -static gchar *describe_forward_messages (gpointer in_data, gboolean gerund); -static void setup_forward_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_forward_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_forward_messages (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_forward_messages (gpointer in_data, gboolean gerund) { @@ -1666,31 +1421,6 @@ setup_forward_messages (gpointer in_data, gpointer op_data, { forward_messages_input_t *input = (forward_messages_input_t *) in_data; - if (!input->uids) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No UIDs specified to attach."); - return; - } - - if (!CAMEL_IS_MIME_MESSAGE (input->basis)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No basic message to forward was specified."); - return; - } - - if (!CAMEL_IS_FOLDER (input->source)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No folder to fetch the messages from specified."); - return; - } - - if (!E_IS_MSG_COMPOSER (input->composer)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No message composer from specified."); - return; - } - camel_object_ref (CAMEL_OBJECT (input->basis)); camel_object_ref (CAMEL_OBJECT (input->source)); gtk_object_ref (GTK_OBJECT (input->composer)); @@ -1780,6 +1510,11 @@ mail_do_forward_message (CamelMimeMessage *basis, { forward_messages_input_t *input; + g_return_if_fail (CAMEL_IS_MIME_MESSAGE (basis)); + g_return_if_fail (CAMEL_IS_FOLDER (source)); + g_return_if_fail (uids != NULL); + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + input = g_new (forward_messages_input_t, 1); input->basis = basis; input->source = source; @@ -1798,14 +1533,6 @@ typedef struct load_folder_input_s } load_folder_input_t; -static gchar *describe_load_folder (gpointer in_data, gboolean gerund); -static void setup_load_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_load_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_load_folder (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_load_folder (gpointer in_data, gboolean gerund) { @@ -1823,19 +1550,6 @@ setup_load_folder (gpointer in_data, gpointer op_data, CamelException *ex) { load_folder_input_t *input = (load_folder_input_t *) in_data; - if (!IS_FOLDER_BROWSER (input->fb)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No folder browser specified to load into."); - return; - } - - if (!input->url) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No URL to load was specified."); - return; - } - gtk_object_ref (GTK_OBJECT (input->fb)); if (input->fb->uri) @@ -1897,6 +1611,9 @@ mail_do_load_folder (FolderBrowser *fb, const char *url) { load_folder_input_t *input; + g_return_if_fail (IS_FOLDER_BROWSER (fb)); + g_return_if_fail (url != NULL); + input = g_new (load_folder_input_t, 1); input->fb = fb; input->url = g_strdup (url); @@ -1920,14 +1637,6 @@ typedef struct create_folder_data_s } create_folder_data_t; -static gchar *describe_create_folder (gpointer in_data, gboolean gerund); -static void setup_create_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_create_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_create_folder (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_create_folder (gpointer in_data, gboolean gerund) { @@ -1941,31 +1650,6 @@ describe_create_folder (gpointer in_data, gboolean gerund) } static void -setup_create_folder (gpointer in_data, gpointer op_data, CamelException *ex) -{ - create_folder_input_t *input = (create_folder_input_t *) in_data; - - if (input->listener == CORBA_OBJECT_NIL) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "Invalid listener passed to create_folder"); - return; - } - - if (input->uri == NULL) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "Invalid url passed to create_folder"); - return; - } - - if (input->type == NULL) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No type passed to create_folder"); - return; - } -} - -static void do_create_folder (gpointer in_data, gpointer op_data, CamelException *ex) { create_folder_input_t *input = (create_folder_input_t *) in_data; @@ -2020,7 +1704,7 @@ cleanup_create_folder (gpointer in_data, gpointer op_data, static const mail_operation_spec op_create_folder = { describe_create_folder, sizeof (create_folder_data_t), - setup_create_folder, + NULL, do_create_folder, cleanup_create_folder }; @@ -2032,28 +1716,21 @@ mail_do_create_folder (const Evolution_ShellComponentListener listener, CORBA_Environment ev; create_folder_input_t *input; - CORBA_exception_init (&ev); + g_return_if_fail (uri != NULL); + g_return_if_fail (type != NULL); input = g_new (create_folder_input_t, 1); + CORBA_exception_init (&ev); input->listener = CORBA_Object_duplicate (listener, &ev); + CORBA_exception_free (&ev); input->uri = g_strdup (uri); input->type = g_strdup (type); - CORBA_exception_free (&ev); - mail_operation_queue (&op_create_folder, input, FALSE); } /* ** SYNC FOLDER ********************************************************* */ -static gchar *describe_sync_folder (gpointer in_data, gboolean gerund); -static void setup_sync_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_sync_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_sync_folder (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_sync_folder (gpointer in_data, gboolean gerund) { @@ -2069,13 +1746,6 @@ describe_sync_folder (gpointer in_data, gboolean gerund) static void setup_sync_folder (gpointer in_data, gpointer op_data, CamelException *ex) { - if (!CAMEL_IS_FOLDER (in_data)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No folder is selected to be synced"); - return; - } - camel_object_ref (CAMEL_OBJECT (in_data)); } @@ -2104,6 +1774,8 @@ static const mail_operation_spec op_sync_folder = { void mail_do_sync_folder (CamelFolder *folder) { + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + mail_operation_queue (&op_sync_folder, folder, FALSE); } @@ -2123,14 +1795,6 @@ typedef struct display_message_data_s } display_message_data_t; -static gchar *describe_display_message (gpointer in_data, gboolean gerund); -static void setup_display_message (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_display_message (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_display_message (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_display_message (gpointer in_data, gboolean gerund) { @@ -2158,19 +1822,6 @@ setup_display_message (gpointer in_data, gpointer op_data, display_message_input_t *input = (display_message_input_t *) in_data; display_message_data_t *data = (display_message_data_t *) op_data; - if (!IS_MESSAGE_LIST (input->ml)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "Invalid message list passed to display_message"); - return; - } - - if (!input->timeout) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No timeout callback passed to display_message"); - return; - } - data->msg = NULL; gtk_object_ref (GTK_OBJECT (input->ml)); } @@ -2239,6 +1890,9 @@ mail_do_display_message (MessageList *ml, const char *uid, { display_message_input_t *input; + g_return_if_fail (IS_MESSAGE_LIST (ml)); + g_return_if_fail (timeout != NULL); + input = g_new (display_message_input_t, 1); input->ml = ml; input->uid = g_strdup (uid); @@ -2259,14 +1913,6 @@ typedef struct edit_messages_data_s { GPtrArray *messages; } edit_messages_data_t; -static gchar *describe_edit_messages (gpointer in_data, gboolean gerund); -static void setup_edit_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_edit_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_edit_messages (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_edit_messages (gpointer in_data, gboolean gerund) { @@ -2286,19 +1932,6 @@ setup_edit_messages (gpointer in_data, gpointer op_data, CamelException *ex) { edit_messages_input_t *input = (edit_messages_input_t *) in_data; - if (!input->uids) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No UIDs specified to edit."); - return; - } - - if (!CAMEL_IS_FOLDER (input->folder)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No folder to fetch the messages from specified."); - return; - } - camel_object_ref (CAMEL_OBJECT (input->folder)); } @@ -2370,6 +2003,9 @@ mail_do_edit_messages (CamelFolder *folder, GPtrArray *uids, { edit_messages_input_t *input; + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + g_return_if_fail (uids != NULL); + input = g_new (edit_messages_input_t, 1); input->folder = folder; input->uids = uids; @@ -2385,14 +2021,6 @@ typedef struct setup_folder_input_s { CamelFolder **folder; } setup_folder_input_t; -static gchar *describe_setup_folder (gpointer in_data, gboolean gerund); -static void setup_setup_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_setup_folder (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_setup_folder (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_setup_folder (gpointer in_data, gboolean gerund) { @@ -2405,11 +2033,6 @@ describe_setup_folder (gpointer in_data, gboolean gerund) } static void -setup_setup_folder (gpointer in_data, gpointer op_data, CamelException *ex) -{ -} - -static void do_setup_folder (gpointer in_data, gpointer op_data, CamelException *ex) { setup_folder_input_t *input = (setup_folder_input_t *) in_data; @@ -2433,7 +2056,7 @@ cleanup_setup_folder (gpointer in_data, gpointer op_data, CamelException *ex) static const mail_operation_spec op_setup_folder = { describe_setup_folder, 0, - setup_setup_folder, + NULL, do_setup_folder, cleanup_setup_folder }; @@ -2443,6 +2066,9 @@ mail_do_setup_folder (const char *name, CamelFolder **folder) { setup_folder_input_t *input; + g_return_if_fail (name != NULL); + g_return_if_fail (folder != NULL); + input = g_new (setup_folder_input_t, 1); input->name = g_strdup (name); input->folder = folder; @@ -2461,14 +2087,6 @@ typedef struct view_messages_data_s { GPtrArray *messages; } view_messages_data_t; -static gchar *describe_view_messages (gpointer in_data, gboolean gerund); -static void setup_view_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void do_view_messages (gpointer in_data, gpointer op_data, - CamelException *ex); -static void cleanup_view_messages (gpointer in_data, gpointer op_data, - CamelException *ex); - static gchar * describe_view_messages (gpointer in_data, gboolean gerund) { @@ -2488,26 +2106,6 @@ setup_view_messages (gpointer in_data, gpointer op_data, CamelException *ex) { view_messages_input_t *input = (view_messages_input_t *) in_data; - if (!input->uids) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - /* doesn't need i18n */ - "No UIDs specified to view."); - return; - } - - if (!CAMEL_IS_FOLDER (input->folder)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No folder to fetch the messages from specified."); - return; - } - - if (!IS_FOLDER_BROWSER (input->fb)) { - camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, - "No folder browser was specified."); - return; - } - - camel_object_ref (CAMEL_OBJECT (input->folder)); gtk_object_ref (GTK_OBJECT (input->fb)); } @@ -2584,6 +2182,10 @@ mail_do_view_messages (CamelFolder *folder, GPtrArray *uids, { view_messages_input_t *input; + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + g_return_if_fail (uids != NULL); + g_return_if_fail (IS_FOLDER_BROWSER (fb)); + input = g_new (view_messages_input_t, 1); input->folder = folder; input->uids = uids; |