diff options
90 files changed, 1232 insertions, 961 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 8e126d0260..bf6cf9e47a 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -217,14 +217,19 @@ e_contact_editor_contact_added (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error adding contact"), error); + window = eab_editor_get_window (editor); + message = _("Error adding contact"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -232,14 +237,19 @@ e_contact_editor_contact_modified (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error modifying contact"), error); + window = eab_editor_get_window (editor); + message = _("Error modifying contact"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -247,14 +257,19 @@ e_contact_editor_contact_deleted (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error removing contact"), error); + window = eab_editor_get_window (editor); + message = _("Error removing contact"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -3063,22 +3078,27 @@ init_all (EContactEditor *editor) } if (requisition.width > 0 && requisition.height > 0) { - GtkWindow *window; + GtkWidget *window; GdkScreen *screen; GdkRectangle monitor_area; gint x = 0, y = 0, monitor, width, height; - window = GTK_WINDOW (e_builder_get_widget (editor->builder, "contact editor")); + window = e_builder_get_widget ( + editor->builder, "contact editor"); - gtk_widget_get_preferred_size (GTK_WIDGET (window), &tab_req, NULL); + gtk_widget_get_preferred_size (window, &tab_req, NULL); width = tab_req.width - 320 + 24; height = tab_req.height - 240 + 24; - screen = gtk_window_get_screen (window); - gtk_window_get_position (window, &x, &y); + screen = gtk_window_get_screen (GTK_WINDOW (window)); + gtk_window_get_position (GTK_WINDOW (window), &x, &y); monitor = gdk_screen_get_monitor_at_point (screen, x, y); - if (monitor < 0 || monitor >= gdk_screen_get_n_monitors (screen)) + + if (monitor < 0) + monitor = 0; + + if (monitor >= gdk_screen_get_n_monitors (screen)) monitor = 0; gdk_screen_get_monitor_workarea (screen, monitor, &monitor_area); @@ -3090,7 +3110,10 @@ init_all (EContactEditor *editor) requisition.height = monitor_area.height - height; if (requisition.width > 0 && requisition.height > 0) - gtk_window_set_default_size (window, width + requisition.width, height + requisition.height); + gtk_window_set_default_size ( + GTK_WINDOW (window), + width + requisition.width, + height + requisition.height); } } @@ -3114,8 +3137,7 @@ contact_editor_get_client_cb (GObject *source_object, ((client != NULL) && (error == NULL)) || ((client == NULL) && (error != NULL))); - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_warn_if_fail (client == NULL); g_error_free (error); goto exit; @@ -3547,7 +3569,7 @@ contact_removed_cb (GObject *source_object, sensitize_all (ce); } - if (error) + if (error != NULL) g_error_free (error); g_object_unref (ce); @@ -3635,7 +3657,7 @@ contact_modified_ready_cb (GObject *source_object, contact_modified_cb (book_client, error, user_data); - if (error) + if (error != NULL) g_error_free (error); } diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c index 5814205c4d..638bac68e9 100644 --- a/addressbook/gui/contact-editor/e-contact-quick-add.c +++ b/addressbook/gui/contact-editor/e-contact-quick-add.c @@ -137,8 +137,7 @@ merge_cb (GObject *source_object, ((client == NULL) && (error != NULL))); /* Ignore cancellations. */ - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_warn_if_fail (client == NULL); g_error_free (error); return; @@ -239,7 +238,7 @@ ce_have_contact (EBookClient *book_client, { QuickAdd *qa = (QuickAdd *) closure; - if (error) { + if (error != NULL) { if (book_client) g_object_unref (book_client); g_warning ( @@ -305,8 +304,7 @@ ce_have_book (GObject *source_object, ((client == NULL) && (error != NULL))); /* Ignore cancellations. */ - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_warn_if_fail (client == NULL); g_error_free (error); return; diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 2eac787950..4f5e397f88 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -1584,14 +1584,19 @@ contact_list_editor_contact_added (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error adding list"), error); + window = eab_editor_get_window (editor); + message = _("Error adding list"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -1599,14 +1604,19 @@ contact_list_editor_contact_modified (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error modifying list"), error); + window = eab_editor_get_window (editor); + message = _("Error modifying list"); + + eab_error_dialog (NULL, window, message, error); } static void @@ -1614,14 +1624,19 @@ contact_list_editor_contact_deleted (EABEditor *editor, const GError *error, EContact *contact) { - if (!error) + GtkWindow *window; + const gchar *message; + + if (error == NULL) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) return; - eab_error_dialog (NULL, eab_editor_get_window (editor), _("Error removing list"), error); + window = eab_editor_get_window (editor); + message = _("Error removing list"); + + eab_error_dialog (NULL, window, message, error); } static void diff --git a/addressbook/gui/merging/eab-contact-merging.c b/addressbook/gui/merging/eab-contact-merging.c index fb11e37629..56fef2bc40 100644 --- a/addressbook/gui/merging/eab-contact-merging.c +++ b/addressbook/gui/merging/eab-contact-merging.c @@ -197,7 +197,7 @@ modify_contact_ready_cb (GObject *source_object, else final_cb (book_client, error, lookup); - if (error) + if (error != NULL) g_error_free (error); } @@ -214,12 +214,11 @@ add_contact_ready_cb (GObject *source_object, g_return_if_fail (book_client != NULL); g_return_if_fail (lookup != NULL); - if (!e_book_client_add_contact_finish (book_client, result, &uid, &error)) - uid = NULL; + e_book_client_add_contact_finish (book_client, result, &uid, &error); final_id_cb (book_client, error, uid, lookup); - if (error) + if (error != NULL) g_error_free (error); } @@ -239,7 +238,10 @@ doit (EContactMergingLookup *lookup, static void cancelit (EContactMergingLookup *lookup) { - GError *error = e_client_error_create (E_CLIENT_ERROR_CANCELLED, NULL); + GError *error; + + error = g_error_new_literal ( + G_IO_ERROR, G_IO_ERROR_CANCELLED, _("Cancelled")); if (lookup->op == E_CONTACT_MERGING_ADD) { final_id_cb (lookup->book_client, error, NULL, lookup); diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index 683eed3499..1cd13294a0 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -360,11 +360,17 @@ client_view_ready_cb (GObject *source_object, EAddressbookModel *model = user_data; GError *error = NULL; - if (!e_book_client_get_view_finish (book_client, result, &client_view, &error)) - client_view = NULL; + e_book_client_get_view_finish ( + book_client, result, &client_view, &error); - if (error) { - eab_error_dialog (NULL, NULL, _("Error getting book view"), error); + /* Sanity check. */ + g_return_if_fail ( + ((client_view != NULL) && (error == NULL)) || + ((client_view == NULL) && (error != NULL))); + + if (error != NULL) { + eab_error_dialog ( + NULL, NULL, _("Error getting book view"), error); g_error_free (error); return; } diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index a7f1f6bb5b..b539b602b2 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -199,8 +199,9 @@ contact_modified_cb (EBookClient *book_client, const GError *error, gpointer user_data) { - if (error) - eab_error_dialog (NULL, NULL, _("Error modifying card"), error); + if (error != NULL) + eab_error_dialog ( + NULL, NULL, _("Error modifying card"), error); } static void diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 38d7196217..f7261d338c 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -1238,8 +1238,7 @@ report_and_free_error_if_any (GError *error) if (!error) return; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_error_free (error); return; } @@ -1538,8 +1537,8 @@ all_contacts_ready_cb (GObject *source_object, g_return_if_fail (book_client != NULL); g_return_if_fail (tcd != NULL); - if (!e_book_client_get_contacts_finish (book_client, result, &contacts, &error)) - contacts = NULL; + e_book_client_get_contacts_finish ( + book_client, result, &contacts, &error); shell_view = e_addressbook_view_get_shell_view (tcd->view); shell_content = e_shell_view_get_shell_content (shell_view); @@ -1548,12 +1547,13 @@ all_contacts_ready_cb (GObject *source_object, model = e_addressbook_view_get_model (tcd->view); client_cache = e_addressbook_model_get_client_cache (model); - if (error) { + if (error != NULL) { e_alert_submit ( alert_sink, "addressbook:search-error", error->message, NULL); g_error_free (error); - } else if (contacts) { + + } else if (contacts != NULL) { ESourceRegistry *registry; registry = e_client_cache_ref_registry (client_cache); diff --git a/addressbook/gui/widgets/e-contact-map-window.c b/addressbook/gui/widgets/e-contact-map-window.c index 1dbe694d50..483dde7ea1 100644 --- a/addressbook/gui/widgets/e-contact-map-window.c +++ b/addressbook/gui/widgets/e-contact-map-window.c @@ -87,8 +87,7 @@ book_contacts_received_cb (GObject *source_object, GSList *contacts = NULL, *p; GError *error = NULL; - if (!e_book_client_get_contacts_finish (client, result, &contacts, &error)) - contacts = NULL; + e_book_client_get_contacts_finish (client, result, &contacts, &error); if (error != NULL) { g_warning ( diff --git a/addressbook/gui/widgets/e-contact-map.c b/addressbook/gui/widgets/e-contact-map.c index 57e7e55b97..15b512fa47 100644 --- a/addressbook/gui/widgets/e-contact-map.c +++ b/addressbook/gui/widgets/e-contact-map.c @@ -91,7 +91,6 @@ contact_map_address_resolved_cb (GObject *source, AsyncContext *async_context = user_data; ChamplainMarkerLayer *marker_layer; ChamplainMarker *marker; - GError *error = NULL; g_return_if_fail (async_context != NULL); g_return_if_fail (E_IS_CONTACT_MAP (async_context->map)); @@ -109,13 +108,12 @@ contact_map_address_resolved_cb (GObject *source, goto exit; resolved = geocode_object_resolve_finish ( - GEOCODE_OBJECT (source), result, &error); + GEOCODE_OBJECT (source), result, NULL); if (resolved == NULL || !geocode_object_get_coords (resolved, &longitude, &latitude)) { const gchar *name; - if (error) - g_error_free (error); + name = champlain_label_get_text (CHAMPLAIN_LABEL (marker)); g_signal_emit ( async_context->map, diff --git a/addressbook/gui/widgets/e-contact-marker.c b/addressbook/gui/widgets/e-contact-marker.c index 9ac9417c9f..9d7863785d 100644 --- a/addressbook/gui/widgets/e-contact-marker.c +++ b/addressbook/gui/widgets/e-contact-marker.c @@ -122,53 +122,31 @@ texture_new_from_pixbuf (GdkPixbuf *pixbuf, static ClutterActor * contact_photo_to_texture (EContactPhoto *photo) { - GdkPixbuf *pixbuf; + ClutterActor *texture = NULL; + GdkPixbuf *pixbuf = NULL; if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { - GError *error = NULL; - GdkPixbufLoader *loader = gdk_pixbuf_loader_new (); + gdk_pixbuf_loader_write ( loader, photo->data.inlined.data, photo->data.inlined.length, NULL); gdk_pixbuf_loader_close (loader, NULL); pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (pixbuf) + if (pixbuf != NULL) g_object_ref (pixbuf); g_object_unref (loader); - if (error) { - g_error_free (error); - return NULL; - } } else if (photo->type == E_CONTACT_PHOTO_TYPE_URI) { - GError *error = NULL; - - pixbuf = gdk_pixbuf_new_from_file (photo->data.uri, &error); - - if (error) { - g_error_free (error); - return NULL; - } - } else - return NULL; - - if (pixbuf) { - ClutterActor *texture; - GError *error = NULL; - - texture = texture_new_from_pixbuf (pixbuf, &error); - if (error) { - g_error_free (error); - g_object_unref (pixbuf); - return NULL; - } + pixbuf = gdk_pixbuf_new_from_file (photo->data.uri, NULL); + } + if (pixbuf != NULL) { + texture = texture_new_from_pixbuf (pixbuf, NULL); g_object_unref (pixbuf); - return texture; } - return NULL; + return texture; } static void @@ -177,15 +155,15 @@ draw_box (cairo_t *cr, gint height, gint point) { - cairo_move_to (cr, RADIUS, 0); - cairo_line_to (cr, width - RADIUS, 0); - cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0); - cairo_line_to (cr, width, height - RADIUS); - cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS - 1, 0, M_PI / 2.0); - cairo_line_to (cr, point, height); - cairo_line_to (cr, 0, height + point); - cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0); - cairo_close_path (cr); + cairo_move_to (cr, RADIUS, 0); + cairo_line_to (cr, width - RADIUS, 0); + cairo_arc (cr, width - RADIUS, RADIUS, RADIUS - 1, 3 * M_PI / 2.0, 0); + cairo_line_to (cr, width, height - RADIUS); + cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS - 1, 0, M_PI / 2.0); + cairo_line_to (cr, point, height); + cairo_line_to (cr, 0, height + point); + cairo_arc (cr, RADIUS, RADIUS, RADIUS - 1, M_PI, 3 * M_PI / 2.0); + cairo_close_path (cr); } static void diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index 5f155ad1b1..70e5682bbc 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -77,7 +77,7 @@ typedef enum { void eab_error_dialog (EAlertSink *alert_sink, - GtkWindow *parent, + GtkWindow *parent, const gchar *msg, const GError *error) { @@ -166,12 +166,14 @@ eab_load_error_dialog (GtkWidget *parent, "is unreachable."); } - if (can_detail_error) { - /* do not show repository offline message, it's kind of generic error */ - if (error && !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE)) { - label = g_strconcat (label_string, "\n\n", _("Detailed error message:"), " ", error->message, NULL); - label_string = label; - } + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE)) { + /* Do not show a detailed message; too generic. */ + } else if (can_detail_error && error != NULL) { + label = g_strconcat ( + label_string, "\n\n", + _("Detailed error message:"), + " ", error->message, NULL); + label_string = label; } if (alert_sink) { @@ -492,15 +494,14 @@ contact_added_cb (EBookClient *book_client, { ContactCopyProcess *process = user_data; - if (error && !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) && - !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { process->book_status = FALSE; - eab_error_dialog (process->alert_sink, NULL, _("Error adding contact"), error); - } else if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + } else if (error != NULL) { process->book_status = FALSE; - } - else { + eab_error_dialog ( + process->alert_sink, NULL, + _("Error adding contact"), error); + } else { /* success */ process->book_status = TRUE; } @@ -803,7 +804,7 @@ get_address_format (AddressFormat address_format, error = NULL; key_file = g_key_file_new (); g_key_file_load_from_file (key_file, EVOLUTION_RULEDIR "/address_formats.dat", 0, &error); - if (error) { + if (error != NULL) { g_warning ("%s: Failed to load address_formats.dat file: %s", G_STRFUNC, error->message); *format = g_strdup (ADDRESS_DEFAULT_FORMAT); *country_position = g_strdup (ADDRESS_DEFAULT_COUNTRY_POSITION); diff --git a/addressbook/importers/evolution-csv-importer.c b/addressbook/importers/evolution-csv-importer.c index 6d5423e064..fea7e5b5b6 100644 --- a/addressbook/importers/evolution-csv-importer.c +++ b/addressbook/importers/evolution-csv-importer.c @@ -726,7 +726,10 @@ csv_import_contacts (gpointer d) while ((contact = getNextCSVEntry (gci, gci->file))) { gchar *uid = NULL; - if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) { + + e_book_client_add_contact_sync ( + gci->book_client, contact, &uid, NULL, NULL); + if (uid != NULL) { e_contact_set (contact, E_CONTACT_UID, uid); g_free (uid); } diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c index ae8fb5ac95..0d54182e8d 100644 --- a/addressbook/importers/evolution-ldif-importer.c +++ b/addressbook/importers/evolution-ldif-importer.c @@ -506,7 +506,11 @@ ldif_import_contacts (gpointer d) add_to_notes (contact, E_CONTACT_OFFICE); add_to_notes (contact, E_CONTACT_SPOUSE); add_to_notes (contact, E_CONTACT_BLOG_URL); - if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) { + + e_book_client_add_contact_sync ( + gci->book_client, + contact, &uid, NULL, NULL); + if (uid != NULL) { e_contact_set (contact, E_CONTACT_UID, uid); g_free (uid); } @@ -525,7 +529,9 @@ ldif_import_contacts (gpointer d) contact = iter->data; resolve_list_card (gci, contact); - if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) { + e_book_client_add_contact_sync ( + gci->book_client, contact, &uid, NULL, NULL); + if (uid != NULL) { e_contact_set (contact, E_CONTACT_UID, uid); g_free (uid); } diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c index 09778b5f21..3cef9e6773 100644 --- a/addressbook/importers/evolution-vcard-importer.c +++ b/addressbook/importers/evolution-vcard-importer.c @@ -247,7 +247,9 @@ vcard_import_contact (VCardImporter *gci, add_to_notes (contact, E_CONTACT_BLOG_URL); /* FIXME Error checking */ - if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) { + e_book_client_add_contact_sync ( + gci->book_client, contact, &uid, NULL, NULL); + if (uid != NULL) { e_contact_set (contact, E_CONTACT_UID, uid); g_free (uid); } diff --git a/addressbook/tools/evolution-addressbook-export-list-cards.c b/addressbook/tools/evolution-addressbook-export-list-cards.c index d6e9ecca57..86caa5ae8a 100644 --- a/addressbook/tools/evolution-addressbook-export-list-cards.c +++ b/addressbook/tools/evolution-addressbook-export-list-cards.c @@ -734,8 +734,8 @@ action_list_cards_init (ActionContext *p_actctx) query_str = e_book_query_to_string (query); e_book_query_unref (query); - if (!e_book_client_get_contacts_sync (book_client, query_str, &contacts, NULL, &error)) - contacts = NULL; + e_book_client_get_contacts_sync ( + book_client, query_str, &contacts, NULL, &error); action_list_cards (contacts, p_actctx); @@ -743,7 +743,7 @@ action_list_cards_init (ActionContext *p_actctx) g_slist_free (contacts); g_object_unref (book_client); - if (error) { + if (error != NULL) { g_warning ("Failed to get contacts: %s", error->message); g_error_free (error); } diff --git a/calendar/alarm-notify/alarm-queue.c b/calendar/alarm-notify/alarm-queue.c index 7ea3222631..bd044e5381 100644 --- a/calendar/alarm-notify/alarm-queue.c +++ b/calendar/alarm-notify/alarm-queue.c @@ -370,13 +370,16 @@ remove_queued_alarm (CompQueuedAlarms *cqa, id->rid, qa->instance->auid, NULL, &error); cqa->expecting_update = FALSE; - if (error) { - if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED)) - g_warning ( - "%s: Failed to discard alarm: %s", - G_STRFUNC, error->message); + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED)) { + g_error_free (error); + + } else if (error != NULL) { + g_warning ( + "%s: Failed to discard alarm: %s", + G_STRFUNC, error->message); g_error_free (error); } + e_cal_component_free_id (id); } } @@ -776,7 +779,7 @@ get_alarms_for_object (ECalClient *cal_client, time_t end, ECalComponentAlarms **alarms) { - icalcomponent *icalcomp; + icalcomponent *icalcomp = NULL; ECalComponent *comp; ECalComponentAlarmAction omit[] = {-1}; @@ -786,11 +789,10 @@ get_alarms_for_object (ECalClient *cal_client, g_return_val_if_fail (start >= 0 && end >= 0, FALSE); g_return_val_if_fail (start <= end, FALSE); - if (!e_cal_client_get_object_sync ( - cal_client, id->uid, id->rid, &icalcomp, NULL, NULL)) - return FALSE; + e_cal_client_get_object_sync ( + cal_client, id->uid, id->rid, &icalcomp, NULL, NULL); - if (!icalcomp) + if (icalcomp == NULL) return FALSE; comp = e_cal_component_new (); diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index a271100167..8ad8bd54f9 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -106,7 +106,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, ECalComponentDateTime start_datetime, end_datetime; const gchar *tzid; gboolean retval = FALSE; - icaltimezone *start_zone, *end_zone; + icaltimezone *start_zone = NULL; + icaltimezone *end_zone = NULL; gint offset1, offset2; tzid = icaltimezone_get_tzid (zone); @@ -150,8 +151,9 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, /* If the TZIDs differ, we have to compare the UTC offsets * of the start and end times, using their own timezones and * the given timezone. */ - if (!e_cal_client_get_timezone_sync (client, start_datetime.tzid, - &start_zone, NULL, NULL)) + e_cal_client_get_timezone_sync ( + client, start_datetime.tzid, &start_zone, NULL, NULL); + if (start_zone == NULL) goto out; if (start_datetime.value) { @@ -167,8 +169,9 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, goto out; } - if (!e_cal_client_get_timezone_sync (client, end_datetime.tzid, - &end_zone, NULL, NULL)) + e_cal_client_get_timezone_sync ( + client, end_datetime.tzid, &end_zone, NULL, NULL); + if (end_zone == NULL) goto out; if (end_datetime.value) { @@ -242,7 +245,10 @@ cal_comp_is_on_server (ECalComponent *comp, rid = e_cal_component_get_recurid_as_string (comp); } - if (e_cal_client_get_object_sync (client, uid, rid, &icalcomp, NULL, &error)) { + e_cal_client_get_object_sync ( + client, uid, rid, &icalcomp, NULL, &error); + + if (icalcomp != NULL) { icalcomponent_free (icalcomp); g_free (rid); @@ -298,13 +304,14 @@ cal_comp_event_new_with_defaults (ECalClient *client, gint default_reminder_interval, EDurationType default_reminder_units) { - icalcomponent *icalcomp; + icalcomponent *icalcomp = NULL; ECalComponent *comp; ECalComponentAlarm *alarm; icalproperty *icalprop; ECalComponentAlarmTrigger trigger; - if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) + e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL); + if (icalcomp == NULL) icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT); comp = e_cal_component_new (); @@ -407,9 +414,10 @@ ECalComponent * cal_comp_task_new_with_defaults (ECalClient *client) { ECalComponent *comp; - icalcomponent *icalcomp; + icalcomponent *icalcomp = NULL; - if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) + e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL); + if (icalcomp == NULL) icalcomp = icalcomponent_new (ICAL_VTODO_COMPONENT); comp = e_cal_component_new (); @@ -426,9 +434,10 @@ ECalComponent * cal_comp_memo_new_with_defaults (ECalClient *client) { ECalComponent *comp; - icalcomponent *icalcomp; + icalcomponent *icalcomp = NULL; - if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) + e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL); + if (icalcomp == NULL) icalcomp = icalcomponent_new (ICAL_VJOURNAL_COMPONENT); comp = e_cal_component_new (); diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 39ca3a81e1..0459e4797a 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -390,12 +390,14 @@ changes_view_ready_cb (GObject *source_object, G_STRFUNC, error->message); g_error_free (error); } - } else if (error) { - if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) && - !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - g_warning ( - "%s: Failed to get view: %s", - G_STRFUNC, error->message); + + } else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + + } else if (error != NULL) { + g_warning ( + "%s: Failed to get view: %s", + G_STRFUNC, error->message); g_error_free (error); } } @@ -619,7 +621,7 @@ save_comp (CompEditor *editor) gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - if (error) + if (error != NULL) g_error_free (error); g_free (orig_uid_copy); @@ -1055,35 +1057,23 @@ save_and_close_editor (CompEditor *editor, rid = e_cal_component_get_recurid_as_string (priv->comp); source_type = e_cal_client_get_source_type (priv->cal_client); - if (!e_cal_client_get_object_sync (priv->cal_client, uid, rid, &icalcomp, NULL, &error)) { - if (error != NULL) { - switch (source_type) { - case (E_CAL_CLIENT_SOURCE_TYPE_TASKS): - g_warning ("Unable to retrieve saved component from the task list, returned error was: %s", error->message); - break; - case (E_CAL_CLIENT_SOURCE_TYPE_MEMOS): - g_warning ("Unable to retrieve saved component from the memo list, returned error was: %s", error->message); - break; - case (E_CAL_CLIENT_SOURCE_TYPE_EVENTS): - default: - g_warning ("Unable to retrieve saved component from the calendar, returned error was: %s", error->message); - break; - } - g_clear_error (&error); - } else { - switch (source_type) { - case (E_CAL_CLIENT_SOURCE_TYPE_TASKS): - g_warning ("Unable to retrieve saved component from the task list"); + e_cal_client_get_object_sync ( + priv->cal_client, uid, rid, + &icalcomp, NULL, &error); + if (error != NULL) { + switch (source_type) { + case (E_CAL_CLIENT_SOURCE_TYPE_TASKS): + g_warning ("Unable to retrieve saved component from the task list, returned error was: %s", error->message); + break; + case (E_CAL_CLIENT_SOURCE_TYPE_MEMOS): + g_warning ("Unable to retrieve saved component from the memo list, returned error was: %s", error->message); + break; + case (E_CAL_CLIENT_SOURCE_TYPE_EVENTS): + default: + g_warning ("Unable to retrieve saved component from the calendar, returned error was: %s", error->message); break; - case (E_CAL_CLIENT_SOURCE_TYPE_MEMOS): - g_warning ("Unable to retrieve saved component from the memo list"); - break; - case (E_CAL_CLIENT_SOURCE_TYPE_EVENTS): - default: - g_warning ("Unable to retrieve saved component from the calendar"); - break; - } } + g_clear_error (&error); e_notice ( GTK_WINDOW (editor), GTK_MESSAGE_ERROR, @@ -3438,7 +3428,9 @@ real_send_comp (CompEditor *editor, const gchar *uid = NULL; e_cal_component_get_uid (priv->comp, &uid); - if (e_cal_client_get_object_sync (priv->cal_client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { + e_cal_client_get_object_sync ( + priv->cal_client, uid, NULL, &icalcomp, NULL, NULL); + if (icalcomp != NULL) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c index 0f0dc0545e..e9e35b892c 100644 --- a/calendar/gui/dialogs/copy-source-dialog.c +++ b/calendar/gui/dialogs/copy-source-dialog.c @@ -77,8 +77,11 @@ add_timezone_to_cal_cb (icalparameter *param, if (!tzid || !*tzid) return; - if (e_cal_client_get_timezone_sync (ftd->source_client, tzid, &tz, NULL, NULL) && tz) - e_cal_client_add_timezone_sync (ftd->dest_client, tz, NULL, NULL); + e_cal_client_get_timezone_sync ( + ftd->source_client, tzid, &tz, NULL, NULL); + if (tz != NULL) + e_cal_client_add_timezone_sync ( + ftd->dest_client, tz, NULL, NULL); } static void @@ -128,7 +131,10 @@ dest_source_connected_cb (GObject *source_object, show_error (csdd, _("Destination is read only"), NULL); } else { GSList *obj_list = NULL; - if (e_cal_client_get_object_list_sync (csdd->source_client, "#t", &obj_list, NULL, NULL)) { + + e_cal_client_get_object_list_sync ( + csdd->source_client, "#t", &obj_list, NULL, NULL); + if (obj_list != NULL) { GSList *l; icalcomponent *icalcomp; struct ForeachTzidData ftd; @@ -139,12 +145,16 @@ dest_source_connected_cb (GObject *source_object, for (l = obj_list; l != NULL; l = l->next) { /* FIXME: process recurrences */ /* FIXME: process errors */ - if (e_cal_client_get_object_sync (csdd->dest_client, icalcomponent_get_uid (l->data), NULL, - &icalcomp, NULL, NULL)) { - e_cal_client_modify_object_sync (csdd->dest_client, l->data, CALOBJ_MOD_ALL, NULL, NULL); + e_cal_client_get_object_sync ( + csdd->dest_client, + icalcomponent_get_uid (l->data), + NULL, &icalcomp, NULL, NULL); + if (icalcomp != NULL) { + e_cal_client_modify_object_sync ( + csdd->dest_client, l->data, + CALOBJ_MOD_ALL, NULL, NULL); icalcomponent_free (icalcomp); } else { - gchar *uid = NULL; GError *error = NULL; icalcomp = l->data; @@ -155,13 +165,13 @@ dest_source_connected_cb (GObject *source_object, icalcomp, add_timezone_to_cal_cb, &ftd); - if (e_cal_client_create_object_sync (csdd->dest_client, icalcomp, &uid, NULL, &error)) { - g_free (uid); - } else { - if (error) { - show_error (csdd, _("Cannot create object"), error); - g_error_free (error); - } + e_cal_client_create_object_sync ( + csdd->dest_client, + icalcomp, NULL, NULL, &error); + + if (error != NULL) { + show_error (csdd, _("Cannot create object"), error); + g_error_free (error); break; } } diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index f1f7c05e89..f4d9658ccb 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -992,8 +992,10 @@ event_page_load_locations_list (CompEditorPage *page, error = NULL; g_file_get_contents (file_name, &contents, NULL, &error); - if (error) { - g_warning ("%s: Failed to load locations list: %s", G_STRFUNC, error->message); + if (error != NULL) { + g_warning ( + "%s: Failed to load locations list: %s", + G_STRFUNC, error->message); g_error_free (error); g_free (file_name); return; @@ -1081,8 +1083,10 @@ event_page_save_locations_list (CompEditorPage *page, error = NULL; g_file_set_contents (file_name, contents->str, -1, &error); - if (error) { - g_warning ("%s: Failed to save locations: %s", G_STRFUNC, error->message); + if (error != NULL) { + g_warning ( + "%s: Failed to save locations: %s", + G_STRFUNC, error->message); g_error_free (error); } @@ -2997,8 +3001,7 @@ epage_get_client_cb (GObject *source_object, ((client != NULL) && (error == NULL)) || ((client == NULL) && (error != NULL))); - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } @@ -3006,7 +3009,7 @@ epage_get_client_cb (GObject *source_object, editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); priv = epage->priv; - if (error) { + if (error != NULL) { GtkWidget *dialog; ECalClient *old_client; diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c index c202444a2b..1fd9221a54 100644 --- a/calendar/gui/dialogs/memo-page.c +++ b/calendar/gui/dialogs/memo-page.c @@ -946,8 +946,7 @@ mpage_get_client_cb (GObject *source_object, ((client != NULL) && (error == NULL)) || ((client == NULL) && (error != NULL))); - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index 3ceb08476e..4fcd34794b 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -234,7 +234,9 @@ preview_recur (RecurrencePage *rpage) e_cal_component_get_dtstart (priv->comp, &cdt); if (cdt.tzid != NULL) { /* FIXME Will e_cal_client_get_timezone_sync really not return builtin zones? */ - if (!e_cal_client_get_timezone_sync (client, cdt.tzid, &zone, NULL, NULL)) + e_cal_client_get_timezone_sync ( + client, cdt.tzid, &zone, NULL, NULL); + if (zone == NULL) zone = icaltimezone_get_builtin_timezone_from_tzid (cdt.tzid); } e_cal_component_set_dtstart (comp, &cdt); @@ -630,8 +632,7 @@ rpage_get_objects_for_uid_cb (GObject *source_object, if (result && !e_cal_client_get_objects_for_uid_finish (client, result, &ecalcomps, &error)) { ecalcomps = NULL; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } @@ -658,8 +659,7 @@ rpage_get_object_cb (GObject *source_object, if (result && !e_cal_client_get_object_finish (client, result, &icalcomp, &error)) { icalcomp = NULL; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } diff --git a/calendar/gui/dialogs/send-comp.c b/calendar/gui/dialogs/send-comp.c index 9be9406965..b71c46427d 100644 --- a/calendar/gui/dialogs/send-comp.c +++ b/calendar/gui/dialogs/send-comp.c @@ -121,7 +121,10 @@ send_component_dialog (GtkWindow *parent, if (strip_alarms) *strip_alarms = TRUE; - if (e_cal_client_check_save_schedules (client) || !itip_component_has_recipients (comp)) + if (e_cal_client_check_save_schedules (client)) + return FALSE; + + if (!itip_component_has_recipients (comp)) return FALSE; vtype = e_cal_component_get_vtype (comp); @@ -210,15 +213,19 @@ send_dragged_or_resized_component_dialog (GtkWindow *parent, if (strip_alarms) *strip_alarms = TRUE; - if (e_cal_client_check_save_schedules (client) || !itip_component_has_recipients (comp)) + if (e_cal_client_check_save_schedules (client)) + save_schedules = TRUE; + + if (!itip_component_has_recipients (comp)) save_schedules = TRUE; vtype = e_cal_component_get_vtype (comp); switch (vtype) { case E_CAL_COMPONENT_EVENT: - id = save_schedules ? "calendar:prompt-save-meeting-dragged-or-resized" : - "calendar:prompt-send-updated-meeting-info-dragged-or-resized"; + id = save_schedules ? + "calendar:prompt-save-meeting-dragged-or-resized" : + "calendar:prompt-send-updated-meeting-info-dragged-or-resized"; break; default: g_message ( diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index b1f68d3381..084e519c28 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -718,7 +718,9 @@ task_page_fill_widgets (CompEditorPage *page, comp_editor_set_classification (editor, cl); e_cal_component_get_uid (comp, &uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &icalcomp, NULL, NULL); + if (icalcomp != NULL) { icalcomponent_free (icalcomp); task_page_hide_options (tpage); } @@ -2056,15 +2058,15 @@ tpage_get_client_cb (GObject *source_object, ((client != NULL) && (error == NULL)) || ((client == NULL) && (error != NULL))); - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage)); priv = tpage->priv; - if (error) { + + if (error != NULL) { GtkWidget *dialog; ECalClient *old_client; diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c index 0647f9bcab..ffaba3f84b 100644 --- a/calendar/gui/e-cal-component-preview.c +++ b/calendar/gui/e-cal-component-preview.c @@ -164,22 +164,19 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, gboolean use_24_hour_format) { struct icaltimetype itt; - icaltimezone *zone; + icaltimezone *zone = NULL; struct tm tm; gchar buf[256]; - if (dt->tzid) { - /* If we can't find the zone, we'll guess its "local" */ - if (!e_cal_client_get_timezone_sync (client, dt->tzid, &zone, NULL, NULL)) - zone = NULL; + if (dt->tzid != NULL) { + e_cal_client_get_timezone_sync ( + client, dt->tzid, &zone, NULL, NULL); } else if (dt->value->is_utc) { zone = icaltimezone_get_utc_timezone (); - } else { - zone = NULL; } itt = *dt->value; - if (zone) + if (zone != NULL) icaltimezone_convert_time (&itt, zone, default_zone); tm = icaltimetype_to_tm (&itt); diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c index cc1e5a46e0..b24d96a40d 100644 --- a/calendar/gui/e-cal-model-calendar.c +++ b/calendar/gui/e-cal-model-calendar.c @@ -329,7 +329,10 @@ cal_model_calendar_set_value_at (ETableModel *etm, const gchar *uid = NULL; e_cal_component_get_uid (comp, &uid); - if (e_cal_client_get_object_sync (comp_data->client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { + e_cal_client_get_object_sync ( + comp_data->client, uid, NULL, + &icalcomp, NULL, NULL); + if (icalcomp != NULL) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index bb9e8f4bbf..c14371c090 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -375,7 +375,7 @@ get_due_status (ECalModelTasks *model, return E_CAL_MODEL_TASKS_DUE_NEVER; else { struct icaltimetype now_tt, due_tt; - icaltimezone *zone; + icaltimezone *zone = NULL; /* Second, is it already completed? */ if (is_complete (comp_data)) @@ -404,7 +404,9 @@ get_due_status (ECalModelTasks *model, /* Get the current time in the same timezone as the DUE date.*/ tzid = icalparameter_get_tzid (param); - if (!e_cal_client_get_timezone_sync (comp_data->client, tzid, &zone, NULL, NULL)) + e_cal_client_get_timezone_sync ( + comp_data->client, tzid, &zone, NULL, NULL); + if (zone == NULL) return E_CAL_MODEL_TASKS_DUE_FUTURE; now_tt = icaltime_current_time_with_zone (zone); diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c index 1b0ee913b3..9557c44f9a 100644 --- a/calendar/gui/e-calendar-selector.c +++ b/calendar/gui/e-calendar-selector.c @@ -47,11 +47,15 @@ calendar_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { gchar *uid; - icalcomponent *tmp_icalcomp; + icalcomponent *tmp_icalcomp = NULL; + gboolean success; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, NULL); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); return e_cal_client_modify_object_sync ( @@ -59,14 +63,15 @@ calendar_selector_update_single_object (ECalClient *client, } uid = NULL; - if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) - return FALSE; + success = e_cal_client_create_object_sync ( + client, icalcomp, &uid, NULL, NULL); - if (uid) + if (uid != NULL) { icalcomponent_set_uid (icalcomp, uid); - g_free (uid); + g_free (uid); + } - return TRUE; + return success; } static gboolean @@ -152,6 +157,64 @@ client_connect_cb (GObject *source_object, } static void +calendar_selector_set_shell_view (ECalendarSelector *selector, + EShellView *shell_view) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + g_return_if_fail (selector->priv->shell_view == NULL); + + selector->priv->shell_view = g_object_ref (shell_view); +} + +static void +calendar_selector_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + calendar_selector_set_shell_view ( + E_CALENDAR_SELECTOR (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +calendar_selector_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + g_value_set_object ( + value, + e_calendar_selector_get_shell_view ( + E_CALENDAR_SELECTOR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +calendar_selector_dispose (GObject *object) +{ + ECalendarSelectorPrivate *priv; + + priv = E_CALENDAR_SELECTOR_GET_PRIVATE (object); + + g_clear_object (&priv->shell_view); + + /* Chain up to the parent' s dispose() method. */ + G_OBJECT_CLASS (e_calendar_selector_parent_class)->dispose (object); +} + +static void calendar_selector_constructed (GObject *object) { ESourceSelector *selector; @@ -212,71 +275,6 @@ exit: return success; } -EShellView * -e_calendar_selector_get_shell_view (ECalendarSelector *calendar_selector) -{ - g_return_val_if_fail (E_IS_CALENDAR_SELECTOR (calendar_selector), NULL); - - return calendar_selector->priv->shell_view; -} - -static void -e_calendar_selector_set_shell_view (ECalendarSelector *calendar_selector, - EShellView *shell_view) -{ - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_return_if_fail (calendar_selector->priv->shell_view == NULL); - - calendar_selector->priv->shell_view = g_object_ref (shell_view); -} - -static void -calendar_selector_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - e_calendar_selector_set_shell_view ( - E_CALENDAR_SELECTOR (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -calendar_selector_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - g_value_set_object ( - value, - e_calendar_selector_get_shell_view (E_CALENDAR_SELECTOR (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -calendar_selector_dispose (GObject *object) -{ - ECalendarSelectorPrivate *priv; - - priv = E_CALENDAR_SELECTOR_GET_PRIVATE (object); - - g_clear_object (&priv->shell_view); - - /* Chain up to the parent' s dispose() method. */ - G_OBJECT_CLASS (e_calendar_selector_parent_class)->dispose (object); -} - static void e_calendar_selector_class_init (ECalendarSelectorClass *class) { @@ -321,7 +319,7 @@ e_calendar_selector_init (ECalendarSelector *selector) GtkWidget * e_calendar_selector_new (EClientCache *client_cache, - EShellView *shell_view) + EShellView *shell_view) { ESourceRegistry *registry; GtkWidget *widget; @@ -343,3 +341,12 @@ e_calendar_selector_new (EClientCache *client_cache, return widget; } + +EShellView * +e_calendar_selector_get_shell_view (ECalendarSelector *selector) +{ + g_return_val_if_fail (E_IS_CALENDAR_SELECTOR (selector), NULL); + + return selector->priv->shell_view; +} + diff --git a/calendar/gui/e-calendar-selector.h b/calendar/gui/e-calendar-selector.h index 2e39c4b571..6429cb0110 100644 --- a/calendar/gui/e-calendar-selector.h +++ b/calendar/gui/e-calendar-selector.h @@ -62,7 +62,7 @@ GType e_calendar_selector_get_type (void); GtkWidget * e_calendar_selector_new (EClientCache *client_cache, EShellView *shell_backend); EShellView * e_calendar_selector_get_shell_view - (ECalendarSelector *calendar_selector); + (ECalendarSelector *selector); G_END_DECLS diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 61a88850cd..b60dee47ee 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -196,11 +196,12 @@ calendar_view_delete_event (ECalendarView *cal_view, comp, retract_comment, CALOBJ_MOD_ALL); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_client_send_objects_sync (event->comp_data->client, icalcomp, &users, - &mod_comp, NULL, &error)) { + e_cal_client_send_objects_sync ( + event->comp_data->client, icalcomp, + &users, &mod_comp, NULL, &error); + if (error != NULL) { delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); - error = NULL; } else { if (mod_comp) @@ -527,10 +528,13 @@ add_related_timezones (icalcomponent *des_icalcomp, GError *error = NULL; icaltimezone *zone = NULL; - if (!e_cal_client_get_timezone_sync (client, tzid, &zone, NULL, &error)) { - g_warning ("%s: Cannot get timezone for '%s'. %s", G_STRFUNC, tzid, error ? error->message : ""); - if (error) - g_error_free (error); + e_cal_client_get_timezone_sync ( + client, tzid, &zone, NULL, &error); + if (error != NULL) { + g_warning ( + "%s: Cannot get timezone for '%s'. %s", + G_STRFUNC, tzid, error->message); + g_error_free (error); } else if (zone && icalcomponent_get_timezone (des_icalcomp, icaltimezone_get_tzid (zone)) == NULL) { /* do not duplicate timezones in the component */ @@ -660,12 +664,24 @@ clipboard_get_calendar_data (ECalendarView *cal_view, zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - if (!e_cal_client_add_timezone_sync (client, zone, NULL, &error)) { - icalproperty *tzidprop = icalcomponent_get_first_property (subcomp, ICAL_TZID_PROPERTY); - - g_warning ("%s: Add zone '%s' failed. %s", G_STRFUNC, tzidprop ? icalproperty_get_tzid (tzidprop) : "???", error ? error->message : ""); - if (error) - g_error_free (error); + e_cal_client_add_timezone_sync ( + client, zone, NULL, &error); + if (error != NULL) { + icalproperty *tzidprop; + const gchar *tzid; + + tzidprop = icalcomponent_get_first_property ( + subcomp, ICAL_TZID_PROPERTY); + if (tzidprop != NULL) + tzid = icalproperty_get_tzid (tzidprop); + else + tzid = "???"; + + g_warning ( + "%s: Add zone '%s' failed. %s", + G_STRFUNC, tzid, error->message); + + g_error_free (error); } icaltimezone_free (zone, 1); @@ -778,14 +794,25 @@ calendar_view_paste_clipboard (ESelectable *selectable) /* when cutting detached instances, only cut that instance */ rid = e_cal_component_get_recurid_as_string (comp); - if (e_cal_client_get_object_sync (comp_data->client, uid, rid, &icalcomp, NULL, NULL)) { - e_cal_client_remove_object_sync (comp_data->client, uid, rid, CALOBJ_MOD_THIS, NULL, &error); + e_cal_client_get_object_sync ( + comp_data->client, uid, rid, + &icalcomp, NULL, NULL); + if (icalcomp != NULL) { + e_cal_client_remove_object_sync ( + comp_data->client, uid, rid, + CALOBJ_MOD_THIS, NULL, &error); icalcomponent_free (icalcomp); - } else - e_cal_client_remove_object_sync (comp_data->client, uid, NULL, CALOBJ_MOD_ALL, NULL, &error); + } else { + e_cal_client_remove_object_sync ( + comp_data->client, uid, NULL, + CALOBJ_MOD_ALL, NULL, &error); + } g_free (rid); - } else - e_cal_client_remove_object_sync (comp_data->client, uid, NULL, CALOBJ_MOD_ALL, NULL, &error); + } else { + e_cal_client_remove_object_sync ( + comp_data->client, uid, NULL, + CALOBJ_MOD_ALL, NULL, &error); + } delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); @@ -1139,7 +1166,10 @@ e_calendar_view_add_event (ECalendarView *cal_view, e_cal_component_commit_sequence (comp); uid = NULL; - if (e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) { + e_cal_client_create_object_sync ( + client, e_cal_component_get_icalcomponent (comp), + &uid, NULL, &error); + if (error == NULL) { gboolean strip_alarms = TRUE; if (uid) { @@ -1159,9 +1189,10 @@ e_calendar_view_add_event (ECalendarView *cal_view, FALSE); } } else { - g_message (G_STRLOC ": Could not create the object! %s", error ? error->message : ""); - if (error) - g_error_free (error); + g_message ( + "%s: Could not create the object! %s", + G_STRFUNC, error->message); + g_error_free (error); ret = FALSE; } @@ -1396,11 +1427,12 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) comp, retract_comment, CALOBJ_MOD_THIS); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_client_send_objects_sync (event->comp_data->client, icalcomp, &users, - &mod_comp, NULL, &error)) { + e_cal_client_send_objects_sync ( + event->comp_data->client, icalcomp, + &users, &mod_comp, NULL, &error); + if (error != NULL) { delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); - error = NULL; } else { if (mod_comp) icalcomponent_free (mod_comp); @@ -1429,7 +1461,7 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) GError *error = NULL; e_cal_client_get_timezone_sync (event->comp_data->client, dt.tzid, &zone, NULL, &error); - if (error) { + if (error != NULL) { zone = e_calendar_view_get_timezone (cal_view); g_clear_error (&error); } @@ -1839,7 +1871,9 @@ e_calendar_view_send (ECalendarView *cal_view, const gchar *uid = NULL; e_cal_component_get_uid (comp, &uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { + e_cal_client_get_object_sync ( + client, uid, NULL, &icalcomp, NULL, NULL); + if (icalcomp != NULL) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c index 695188f6cd..4e749f13d7 100644 --- a/calendar/gui/e-meeting-store.c +++ b/calendar/gui/e-meeting-store.c @@ -2063,15 +2063,17 @@ start_async_read (const gchar *uri, istream = G_INPUT_STREAM (g_file_read (file, NULL, &error)); - if (error && g_error_matches (error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) { + if (g_error_matches (error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) { download_with_libsoup (uri, qdata); g_object_unref (file); g_error_free (error); return; } - if (error) { - g_warning ("Unable to access free/busy url: %s", error->message); + if (error != NULL) { + g_warning ( + "Unable to access free/busy url: %s", + error->message); g_error_free (error); process_callbacks (qdata); g_object_unref (file); @@ -2081,10 +2083,11 @@ start_async_read (const gchar *uri, if (!istream) { process_callbacks (qdata); g_object_unref (file); - } else + } else { g_input_stream_read_async ( istream, qdata->buffer, BUF_SIZE - 1, G_PRIORITY_DEFAULT, NULL, async_read, qdata); + } } void diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c index a1cc8a7e30..8952a67258 100644 --- a/calendar/gui/e-memo-list-selector.c +++ b/calendar/gui/e-memo-list-selector.c @@ -49,27 +49,31 @@ static gboolean memo_list_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { - gchar *uid = NULL; - icalcomponent *tmp_icalcomp; + gchar *uid; + icalcomponent *tmp_icalcomp = NULL; + gboolean success; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, NULL); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); return e_cal_client_modify_object_sync ( client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL); } - if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) - return FALSE; + success = e_cal_client_create_object_sync ( + client, icalcomp, &uid, NULL, NULL); - if (uid) + if (uid != NULL) { icalcomponent_set_uid (icalcomp, uid); + g_free (uid); + } - g_free (uid); - - return TRUE; + return success; } static gboolean @@ -184,13 +188,23 @@ memo_list_selector_process_data (ESourceSelector *selector, if (old_uid == NULL) old_uid = g_strdup (uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) { + success = e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, &error); + + /* Sanity check. */ + g_return_val_if_fail ( + (success && (error == NULL)) || + (!success && (error != NULL)), FALSE); + + if (success) { icalcomponent_free (tmp_icalcomp); - success = TRUE; goto exit; } - if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { + if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) + g_clear_error (&error); + + if (error != NULL) { g_message ( "Failed to search the object in destination " "task list: %s", error->message); @@ -198,9 +212,6 @@ memo_list_selector_process_data (ESourceSelector *selector, goto exit; } - if (error) - g_error_free (error); - success = memo_list_selector_update_objects (client, icalcomp); if (!success || action != GDK_ACTION_MOVE) @@ -222,8 +233,7 @@ exit: return success; } -struct DropData -{ +struct DropData { ESourceSelector *selector; GdkDragAction action; GSList *list; @@ -290,71 +300,24 @@ exit: } static void -memo_list_selector_constructed (GObject *object) -{ - ESourceSelector *selector; - ESourceRegistry *registry; - ESource *source; - - selector = E_SOURCE_SELECTOR (object); - registry = e_source_selector_get_registry (selector); - source = e_source_registry_ref_default_memo_list (registry); - e_source_selector_set_primary_selection (selector, source); - g_object_unref (source); - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (e_memo_list_selector_parent_class)-> - constructed (object); -} - -static gboolean -memo_list_selector_data_dropped (ESourceSelector *selector, - GtkSelectionData *selection_data, - ESource *destination, - GdkDragAction action, - guint info) -{ - struct DropData *dd; - - dd = g_new0 (struct DropData, 1); - dd->selector = g_object_ref (selector); - dd->action = action; - dd->list = cal_comp_selection_get_string_list (selection_data); - - e_client_selector_get_client ( - E_CLIENT_SELECTOR (selector), destination, NULL, - client_connect_for_drop_cb, dd); - - return TRUE; -} - -EShellView * -e_memo_list_selector_get_shell_view (EMemoListSelector *memo_list_selector) -{ - g_return_val_if_fail (E_IS_MEMO_LIST_SELECTOR (memo_list_selector), NULL); - - return memo_list_selector->priv->shell_view; -} - -static void -e_memo_list_selector_set_shell_view (EMemoListSelector *memo_list_selector, - EShellView *shell_view) +memo_list_selector_set_shell_view (EMemoListSelector *selector, + EShellView *shell_view) { g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_return_if_fail (memo_list_selector->priv->shell_view == NULL); + g_return_if_fail (selector->priv->shell_view == NULL); - memo_list_selector->priv->shell_view = g_object_ref (shell_view); + selector->priv->shell_view = g_object_ref (shell_view); } static void memo_list_selector_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_SHELL_VIEW: - e_memo_list_selector_set_shell_view ( + memo_list_selector_set_shell_view ( E_MEMO_LIST_SELECTOR (object), g_value_get_object (value)); return; @@ -365,15 +328,16 @@ memo_list_selector_set_property (GObject *object, static void memo_list_selector_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_SHELL_VIEW: g_value_set_object ( value, - e_memo_list_selector_get_shell_view (E_MEMO_LIST_SELECTOR (object))); + e_memo_list_selector_get_shell_view ( + E_MEMO_LIST_SELECTOR (object))); return; } @@ -389,11 +353,50 @@ memo_list_selector_dispose (GObject *object) g_clear_object (&priv->shell_view); - /* Chain up to the parent' s dispose() method. */ + /* Chain up to the parent's dispose() method. */ G_OBJECT_CLASS (e_memo_list_selector_parent_class)->dispose (object); } static void +memo_list_selector_constructed (GObject *object) +{ + ESourceSelector *selector; + ESourceRegistry *registry; + ESource *source; + + selector = E_SOURCE_SELECTOR (object); + registry = e_source_selector_get_registry (selector); + source = e_source_registry_ref_default_memo_list (registry); + e_source_selector_set_primary_selection (selector, source); + g_object_unref (source); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (e_memo_list_selector_parent_class)-> + constructed (object); +} + +static gboolean +memo_list_selector_data_dropped (ESourceSelector *selector, + GtkSelectionData *selection_data, + ESource *destination, + GdkDragAction action, + guint info) +{ + struct DropData *dd; + + dd = g_new0 (struct DropData, 1); + dd->selector = g_object_ref (selector); + dd->action = action; + dd->list = cal_comp_selection_get_string_list (selection_data); + + e_client_selector_get_client ( + E_CLIENT_SELECTOR (selector), destination, NULL, + client_connect_for_drop_cb, dd); + + return TRUE; +} + +static void e_memo_list_selector_class_init (EMemoListSelectorClass *class) { GObjectClass *object_class; @@ -437,7 +440,7 @@ e_memo_list_selector_init (EMemoListSelector *selector) GtkWidget * e_memo_list_selector_new (EClientCache *client_cache, - EShellView *shell_view) + EShellView *shell_view) { ESourceRegistry *registry; GtkWidget *widget; @@ -458,3 +461,12 @@ e_memo_list_selector_new (EClientCache *client_cache, return widget; } + +EShellView * +e_memo_list_selector_get_shell_view (EMemoListSelector *selector) +{ + g_return_val_if_fail (E_IS_MEMO_LIST_SELECTOR (selector), NULL); + + return selector->priv->shell_view; +} + diff --git a/calendar/gui/e-memo-list-selector.h b/calendar/gui/e-memo-list-selector.h index 0a68a76965..3199fef5ed 100644 --- a/calendar/gui/e-memo-list-selector.h +++ b/calendar/gui/e-memo-list-selector.h @@ -67,7 +67,7 @@ GType e_memo_list_selector_get_type (void); GtkWidget * e_memo_list_selector_new (EClientCache *client_cache, EShellView *shell_view); EShellView * e_memo_list_selector_get_shell_view - (EMemoListSelector *memo_list_selector); + (EMemoListSelector *selector); G_END_DECLS diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 4609356914..5afff70b1b 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -905,10 +905,11 @@ clipboard_get_calendar_data (EMemoTable *memo_table, /* FIXME Should we convert start/due/complete * times? Also, need error handling.*/ - if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (tmp_comp), &uid, NULL, &error)) - uid = NULL; + e_cal_client_create_object_sync ( + client, + e_cal_component_get_icalcomponent (tmp_comp), + NULL, NULL, &error); - g_free (uid); g_object_unref (tmp_comp); if (error != NULL) { @@ -929,12 +930,13 @@ clipboard_get_calendar_data (EMemoTable *memo_table, uid = e_cal_component_gen_uid (); e_cal_component_set_uid (comp, (const gchar *) uid); g_free (uid); - uid = NULL; - if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) - uid = NULL; - g_free (uid); + e_cal_client_create_object_sync ( + client, + e_cal_component_get_icalcomponent (comp), + NULL, NULL, &error); + g_object_unref (comp); if (error != NULL) { diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c index dc1340eb00..c35a6610ad 100644 --- a/calendar/gui/e-task-list-selector.c +++ b/calendar/gui/e-task-list-selector.c @@ -49,27 +49,31 @@ static gboolean task_list_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { - gchar *uid = NULL; - icalcomponent *tmp_icalcomp; + gchar *uid; + icalcomponent *tmp_icalcomp = NULL; + gboolean success; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, NULL); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); return e_cal_client_modify_object_sync ( client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL); } - if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) - return FALSE; + success = e_cal_client_create_object_sync ( + client, icalcomp, &uid, NULL, NULL); - if (uid) + if (uid != NULL) { icalcomponent_set_uid (icalcomp, uid); + g_free (uid); + } - g_free (uid); - - return TRUE; + return success; } static gboolean @@ -185,13 +189,19 @@ task_list_selector_process_data (ESourceSelector *selector, if (old_uid == NULL) old_uid = g_strdup (uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, &error); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); success = TRUE; goto exit; } - if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { + if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { + g_clear_error (&error); + + } else if (error != NULL) { g_message ( "Failed to search the object in destination " "task list: %s", error->message); @@ -199,10 +209,6 @@ task_list_selector_process_data (ESourceSelector *selector, goto exit; } - if (error) - g_error_free (error); - error = NULL; - success = task_list_selector_update_objects (client, icalcomp); if (!success || action != GDK_ACTION_MOVE) @@ -224,8 +230,7 @@ exit: return success; } -struct DropData -{ +struct DropData { ESourceSelector *selector; GdkDragAction action; GSList *list; @@ -292,6 +297,51 @@ exit: } static void +task_list_selector_set_shell_view (ETaskListSelector *selector, + EShellView *shell_view) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + g_return_if_fail (selector->priv->shell_view == NULL); + + selector->priv->shell_view = g_object_ref (shell_view); +} + +static void +task_list_selector_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + task_list_selector_set_shell_view ( + E_TASK_LIST_SELECTOR (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +task_list_selector_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + g_value_set_object ( + value, + e_task_list_selector_get_shell_view ( + E_TASK_LIST_SELECTOR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void task_list_selector_constructed (GObject *object) { ESourceSelector *selector; @@ -330,58 +380,6 @@ task_list_selector_data_dropped (ESourceSelector *selector, return TRUE; } -EShellView * -e_task_list_selector_get_shell_view (ETaskListSelector *task_list_selector) -{ - g_return_val_if_fail (E_IS_TASK_LIST_SELECTOR (task_list_selector), NULL); - - return task_list_selector->priv->shell_view; -} - -static void -e_task_list_selector_set_shell_view (ETaskListSelector *task_list_selector, - EShellView *shell_view) -{ - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_return_if_fail (task_list_selector->priv->shell_view == NULL); - - task_list_selector->priv->shell_view = g_object_ref (shell_view); -} - -static void -task_list_selector_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - e_task_list_selector_set_shell_view ( - E_TASK_LIST_SELECTOR (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -task_list_selector_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - g_value_set_object ( - value, - e_task_list_selector_get_shell_view (E_TASK_LIST_SELECTOR (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - static void task_list_selector_dispose (GObject *object) { @@ -439,7 +437,7 @@ e_task_list_selector_init (ETaskListSelector *selector) GtkWidget * e_task_list_selector_new (EClientCache *client_cache, - EShellView *shell_view) + EShellView *shell_view) { ESourceRegistry *registry; GtkWidget *widget; @@ -460,3 +458,12 @@ e_task_list_selector_new (EClientCache *client_cache, return widget; } + +EShellView * +e_task_list_selector_get_shell_view (ETaskListSelector *selector) +{ + g_return_val_if_fail (E_IS_TASK_LIST_SELECTOR (selector), NULL); + + return selector->priv->shell_view; +} + diff --git a/calendar/gui/e-task-list-selector.h b/calendar/gui/e-task-list-selector.h index c296d7d973..0f42b42ef0 100644 --- a/calendar/gui/e-task-list-selector.h +++ b/calendar/gui/e-task-list-selector.h @@ -67,7 +67,7 @@ GType e_task_list_selector_get_type (void); GtkWidget * e_task_list_selector_new (EClientCache *client_cache, EShellView *shell_view); EShellView * e_task_list_selector_get_shell_view - (ETaskListSelector *task_list_selector); + (ETaskListSelector *selector); G_END_DECLS diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c index ddcc54dce0..d60ff21d34 100644 --- a/calendar/gui/e-task-table.c +++ b/calendar/gui/e-task-table.c @@ -1203,8 +1203,10 @@ clipboard_get_calendar_data (ETaskTable *task_table, /* FIXME should we convert start/due/complete * times? Also, need error handling. */ - if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (tmp_comp), &uid, NULL, &error)) - uid = NULL; + e_cal_client_create_object_sync ( + client, + e_cal_component_get_icalcomponent (tmp_comp), + NULL, NULL, &error); if (error != NULL) { g_warning ( @@ -1214,7 +1216,6 @@ clipboard_get_calendar_data (ETaskTable *task_table, } g_object_unref (tmp_comp); - g_free (uid); } subcomp = icalcomponent_get_next_component ( vcal_comp, ICAL_ANY_COMPONENT); @@ -1229,8 +1230,10 @@ clipboard_get_calendar_data (ETaskTable *task_table, g_free (uid); uid = NULL; - if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) - uid = NULL; + e_cal_client_create_object_sync ( + client, + e_cal_component_get_icalcomponent (comp), + NULL, NULL, &error); if (error != NULL) { g_warning ( @@ -1240,7 +1243,6 @@ clipboard_get_calendar_data (ETaskTable *task_table, } g_object_unref (comp); - g_free (uid); } task_table_emit_status_message (task_table, NULL, -1.0); @@ -1414,10 +1416,12 @@ task_table_delete_selection (ESelectable *selectable) add_retract_data (comp, retract_comment); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_client_send_objects_sync (comp_data->client, icalcomp, &users, &mod_comp, NULL, &error)) { + e_cal_client_send_objects_sync ( + comp_data->client, icalcomp, + &users, &mod_comp, NULL, &error); + if (error != NULL) { delete_error_dialog (error, E_CAL_COMPONENT_TODO); g_clear_error (&error); - error = NULL; } else { if (mod_comp) @@ -1704,17 +1708,21 @@ hide_completed_rows_ready (GObject *source_object, e_cal_client_get_object_list_finish ( E_CAL_CLIENT (source_object), result, &objects, &error); - if (error != NULL) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && - !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { - ESource *source = e_client_get_source (E_CLIENT (source_object)); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + return; + + } else if (error != NULL) { + ESource *source; + + source = e_client_get_source (E_CLIENT (source_object)); + + g_warning ( + "%s: Could not get the objects from '%s': %s", + G_STRFUNC, + e_source_get_display_name (source), + error->message); - g_debug ( - "%s: Could not get the objects from '%s': %s", - G_STRFUNC, - e_source_get_display_name (source), - error->message); - } g_error_free (error); return; } @@ -1770,17 +1778,21 @@ show_completed_rows_ready (GObject *source_object, e_cal_client_get_object_list_finish ( E_CAL_CLIENT (source_object), result, &objects, &error); - if (error != NULL) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && - !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { - ESource *source = e_client_get_source (E_CLIENT (source_object)); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + return; + + } else if (error != NULL) { + ESource *source; + + source = e_client_get_source (E_CLIENT (source_object)); + + g_debug ( + "%s: Could not get the objects from '%s': %s", + G_STRFUNC, + e_source_get_display_name (source), + error->message); - g_debug ( - "%s: Could not get the objects from '%s': %s", - G_STRFUNC, - e_source_get_display_name (source), - error->message); - } g_error_free (error); return; } diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index b00a3afa18..3751e64f25 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -4372,9 +4372,9 @@ e_week_view_on_editing_stopped (EWeekView *week_view, E_CALENDAR_VIEW (week_view), client); } - if (uid) - g_free (uid); - if (error) + g_free (uid); + + if (error != NULL) g_error_free (error); /* we remove the object since we either got the update from the server or failed */ diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 02f346d0d8..d8cc740a3b 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -1133,30 +1133,29 @@ comp_server_send (ECalComponentItipMethod method, top_level = comp_toplevel_with_zones (method, comp, cal_client, zones); d (printf ("itip-utils.c: comp_server_send: calling e_cal_send_objects... \n")); - if (!e_cal_client_send_objects_sync (cal_client, top_level, users, &returned_icalcomp, NULL, &error)) { - /* FIXME Really need a book problem status code */ - d (printf ("itip-utils.c: return value from e_cal_send_objects is: %d", error->code)); - if (error) { - if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS)) { - e_notice ( - NULL, GTK_MESSAGE_ERROR, - _("Unable to book a resource, the " - "new event collides with some other.")); - } else { - e_notice ( - NULL, GTK_MESSAGE_ERROR, - _("Unable to book a resource, error: %s"), error->message); - } - retval = FALSE; - } - } else { - d (printf ("itip-utils.c: e_cal_send_objects returned without errors\n")); + e_cal_client_send_objects_sync ( + cal_client, top_level, users, + &returned_icalcomp, NULL, &error); + + if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS)) { + e_notice ( + NULL, GTK_MESSAGE_ERROR, + _("Unable to book a resource, the " + "new event collides with some other.")); + g_error_free (error); + retval = FALSE; + + } else if (error != NULL) { + e_notice ( + NULL, GTK_MESSAGE_ERROR, + _("Unable to book a resource, error: %s"), + error->message); + g_error_free (error); + retval = FALSE; } - g_clear_error (&error); - - if (returned_icalcomp) + if (returned_icalcomp != NULL) icalcomponent_free (returned_icalcomp); icalcomponent_free (top_level); diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c index 3cda9da6ac..2368643877 100644 --- a/calendar/importers/icalendar-importer.c +++ b/calendar/importers/icalendar-importer.c @@ -854,9 +854,9 @@ default_client_connect_cb (GObject *source_object, /* Client may be NULL; don't use a type cast macro. */ odsd->opened_cb ((ECalClient *) client, error, odsd->ici); - if (client) - g_object_unref (client); - if (error) + g_clear_object (&client); + + if (error != NULL) g_error_free (error); g_free (odsd); diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c index 2914e13ffb..4ca523e6ed 100644 --- a/composer/e-composer-private.c +++ b/composer/e-composer-private.c @@ -128,10 +128,14 @@ composer_spell_languages_changed (EMsgComposer *composer, GList *languages) { EComposerHeader *header; - EComposerHeaderTable *table = e_msg_composer_get_header_table (composer); + EComposerHeaderTable *table; + + table = e_msg_composer_get_header_table (composer); + header = e_composer_header_table_get_header ( + table, E_COMPOSER_HEADER_SUBJECT); - header = e_composer_header_table_get_header (table, E_COMPOSER_HEADER_SUBJECT); - e_composer_spell_header_set_languages (E_COMPOSER_SPELL_HEADER (header), languages); + e_composer_spell_header_set_languages ( + E_COMPOSER_SPELL_HEADER (header), languages); } void diff --git a/e-util/e-alert-dialog.c b/e-util/e-alert-dialog.c index 8b495c17db..2803687ea4 100644 --- a/e-util/e-alert-dialog.c +++ b/e-util/e-alert-dialog.c @@ -160,7 +160,8 @@ alert_dialog_constructed (GObject *object) if (!actions) { GtkAction *action; - /* Make sure there is at least one action, thus the dialog can be closed. */ + /* Make sure there is at least one action, + * thus the dialog can be closed. */ action = gtk_action_new ( "alert-response-0", _("_Dismiss"), NULL, NULL); e_alert_add_action (alert, action, GTK_RESPONSE_CLOSE); @@ -344,19 +345,20 @@ e_alert_run_dialog (GtkWindow *parent, dialog = e_alert_dialog_new (parent, alert); - if (parent) { + if (parent != NULL) { gtk_window_set_urgency_hint (parent, TRUE); - signal_id = g_signal_connect (dialog, "focus-in-event", G_CALLBACK (dialog_focus_in_event_cb), parent); + signal_id = g_signal_connect ( + dialog, "focus-in-event", + G_CALLBACK (dialog_focus_in_event_cb), parent); } else { gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE); } response = gtk_dialog_run (GTK_DIALOG (dialog)); - if (parent) { + if (signal_id > 0) { gtk_window_set_urgency_hint (parent, FALSE); - if (signal_id) - g_signal_handler_disconnect (dialog, signal_id); + g_signal_handler_disconnect (dialog, signal_id); } gtk_widget_destroy (dialog); diff --git a/e-util/e-attachment-store.c b/e-util/e-attachment-store.c index 08d7dc49e8..3720baf16b 100644 --- a/e-util/e-attachment-store.c +++ b/e-util/e-attachment-store.c @@ -1079,6 +1079,7 @@ attachment_store_move_file (SaveContext *save_context, { gchar *tmpl; gchar *path; + GError *local_error = NULL; g_return_if_fail (save_context != NULL); g_return_if_fail (source != NULL); @@ -1109,12 +1110,16 @@ attachment_store_move_file (SaveContext *save_context, g_file_move ( destination, save_context->trash_directory, - G_FILE_COPY_NONE, NULL, NULL, NULL, error); + G_FILE_COPY_NONE, NULL, NULL, + NULL, &local_error); - if (*error != NULL && !g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) - return; + if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) + g_clear_error (&local_error); - g_clear_error (error); + if (local_error != NULL) { + g_propagate_error (error, local_error); + return; + } /* Now we can move the file from the temporary directory * to the user-specified destination. */ @@ -1143,19 +1148,23 @@ attachment_store_save_cb (EAttachment *attachment, if (file != NULL) { /* Assemble the file's final URI from its basename. */ + GFile *source = NULL; + GFile *destination = NULL; gchar *basename; gchar *uri; - GFile *source = NULL, *destination = NULL; + const gchar *prefix; basename = g_file_get_basename (file); g_object_unref (file); - source = g_file_get_child (save_context->fresh_directory, basename); + source = g_file_get_child ( + save_context->fresh_directory, basename); - if (save_context->filename_prefix && *save_context->filename_prefix) { - gchar *tmp = basename; + prefix = save_context->filename_prefix; - basename = g_strconcat (save_context->filename_prefix, basename, NULL); + if (prefix != NULL && *prefix != '\0') { + gchar *tmp = basename; + basename = g_strconcat (prefix, basename, NULL); g_free (tmp); } @@ -1164,9 +1173,10 @@ attachment_store_save_cb (EAttachment *attachment, uri = g_file_get_uri (destination); /* move them file-by-file */ - attachment_store_move_file (save_context, source, destination, &error); + attachment_store_move_file ( + save_context, source, destination, &error); - if (!error) + if (error == NULL) save_context->uris[save_context->index++] = uri; g_object_unref (source); diff --git a/e-util/e-attachment-view.c b/e-util/e-attachment-view.c index 994f7ba2e1..383fc12e21 100644 --- a/e-util/e-attachment-view.c +++ b/e-util/e-attachment-view.c @@ -661,27 +661,6 @@ attachment_view_uris (EAttachmentView *view, gtk_drag_finish (drag_context, TRUE, FALSE, time); } -static gboolean -executable_is_evolution (const gchar *app_executable) -{ - const gchar *dash; - const gchar *evo_name; - - g_return_val_if_fail (app_executable != NULL, FALSE); - - dash = strrchr (app_executable, G_DIR_SEPARATOR); - if (dash) - app_executable = dash + 1; - - #ifdef G_OS_WIN32 - evo_name = "evolution.exe"; - #else - evo_name = "evolution"; - #endif - - return g_ascii_strcasecmp (app_executable, evo_name) == 0; -} - static void attachment_view_update_actions (EAttachmentView *view) { @@ -784,23 +763,27 @@ attachment_view_update_actions (EAttachmentView *view) GAppInfo *app_info = iter->data; GtkAction *action; GIcon *app_icon; - const gchar *app_executable; + const gchar *app_id; const gchar *app_name; gchar *action_tooltip; gchar *action_label; gchar *action_name; - app_executable = g_app_info_get_executable (app_info); + app_id = g_app_info_get_id (app_info); + app_icon = g_app_info_get_icon (app_info); + app_name = g_app_info_get_name (app_info); - /* skip evolution from the list */ - if (executable_is_evolution (app_executable)) + if (app_id == NULL) continue; - app_icon = g_app_info_get_icon (app_info); - app_name = g_app_info_get_name (app_info); + /* Don't list 'Open With "Evolution"'. */ + if (g_str_equal (app_id, "evolution.desktop")) + continue; + + action_name = g_strdup_printf ("open-with-%s", app_id); - action_name = g_strdup_printf ("open-with-%s", app_executable); - action_label = g_strdup_printf (_("Open With \"%s\""), app_name); + action_label = g_strdup_printf ( + _("Open With \"%s\""), app_name); action_tooltip = g_strdup_printf ( _("Open this attachment in %s"), app_name); @@ -1163,6 +1146,7 @@ e_attachment_view_open_path (EAttachmentView *view, EAttachment *attachment; GtkTreeModel *model; GtkTreeIter iter; + gboolean iter_valid; gpointer parent; gint column_id; @@ -1173,7 +1157,9 @@ e_attachment_view_open_path (EAttachmentView *view, store = e_attachment_view_get_store (view); model = GTK_TREE_MODEL (store); - g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path)); + iter_valid = gtk_tree_model_get_iter (model, &iter, path); + g_return_if_fail (iter_valid); + gtk_tree_model_get (model, &iter, column_id, &attachment, -1); parent = gtk_widget_get_toplevel (GTK_WIDGET (view)); diff --git a/e-util/e-attachment.c b/e-util/e-attachment.c index bfde09d900..bad4e0b460 100644 --- a/e-util/e-attachment.c +++ b/e-util/e-attachment.c @@ -559,11 +559,6 @@ attachment_set_saving (EAttachment *attachment, attachment->priv->percent = 0; attachment->priv->saving = saving; attachment->priv->last_percent_notify = 0; - - /* g_object_freeze_notify (G_OBJECT (attachment)); - g_object_notify (G_OBJECT (attachment), "percent"); - g_object_notify (G_OBJECT (attachment), "saving"); - g_object_thaw_notify (G_OBJECT (attachment)); */ } static void @@ -585,10 +580,8 @@ attachment_progress_cb (goffset current_num_bytes, new_percent = (current_num_bytes * 100) / total_num_bytes; - if (new_percent != attachment->priv->percent) { + if (new_percent != attachment->priv->percent) attachment->priv->percent = new_percent; - /* g_object_notify (G_OBJECT (attachment), "percent"); */ - } } static gboolean @@ -1827,13 +1820,13 @@ attachment_load_finish (LoadContext *load_context) load_context->mime_part = mime_part; g_simple_async_result_set_op_res_gpointer ( - simple, load_context, (GDestroyNotify) attachment_load_context_free); + simple, load_context, + (GDestroyNotify) attachment_load_context_free); g_simple_async_result_complete (simple); - /* make sure it's freed on operation end */ - load_context->simple = NULL; - g_object_unref (simple); + /* Make sure it's freed on operation end. */ + g_clear_object (&load_context->simple); } static void @@ -2077,7 +2070,9 @@ attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple, } } else { decoded_string = camel_header_decode_string (string, "UTF-8"); - if (decoded_string && *decoded_string && !g_str_equal (decoded_string, string)) { + if (decoded_string != NULL && + *decoded_string != '\0' && + !g_str_equal (decoded_string, string)) { string = decoded_string; } else { g_free (decoded_string); @@ -2105,9 +2100,8 @@ attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple, load_context->mime_part = g_object_ref (mime_part); - /* make sure it's freed on operation end */ - g_object_unref (load_context->simple); - load_context->simple = NULL; + /* Make sure it's freed on operation end. */ + g_clear_object (&load_context->simple); g_simple_async_result_set_op_res_gpointer ( simple, load_context, @@ -2290,7 +2284,8 @@ e_attachment_load (EAttachment *attachment, closure = e_async_closure_new (); - e_attachment_load_async (attachment, e_async_closure_callback, closure); + e_attachment_load_async ( + attachment, e_async_closure_callback, closure); result = e_async_closure_wait (closure); @@ -2597,7 +2592,9 @@ e_attachment_open (EAttachment *attachment, closure = e_async_closure_new (); - e_attachment_open_async (attachment, app_info, e_async_closure_callback, closure); + e_attachment_open_async ( + attachment, app_info, + e_async_closure_callback, closure); result = e_async_closure_wait (closure); @@ -3142,11 +3139,14 @@ e_attachment_save (EAttachment *attachment, closure = e_async_closure_new (); - e_attachment_save_async (attachment, in_destination, e_async_closure_callback, closure); + e_attachment_save_async ( + attachment, in_destination, + e_async_closure_callback, closure); result = e_async_closure_wait (closure); - *out_destination = e_attachment_save_finish (attachment, result, error); + *out_destination = + e_attachment_save_finish (attachment, result, error); e_async_closure_free (closure); diff --git a/e-util/e-contact-store.c b/e-util/e-contact-store.c index 8e34c20546..2b9f326b62 100644 --- a/e-util/e-contact-store.c +++ b/e-util/e-contact-store.c @@ -858,8 +858,8 @@ client_view_ready_cb (GObject *source_object, book_client = E_BOOK_CLIENT (source_object); g_return_if_fail (book_client != NULL); - if (!e_book_client_get_view_finish (book_client, result, &client_view, NULL)) - client_view = NULL; + e_book_client_get_view_finish ( + book_client, result, &client_view, NULL); source_idx = find_contact_source_by_client (contact_store, book_client); if (source_idx >= 0) { diff --git a/e-util/e-file-request.c b/e-util/e-file-request.c index 4ec56d2829..8cce9cacbb 100644 --- a/e-util/e-file-request.c +++ b/e-util/e-file-request.c @@ -55,7 +55,8 @@ handle_file_request (GSimpleAsyncResult *res, if (g_file_get_contents (uri->path, &contents, &length, NULL)) { - request->priv->content_type = g_content_type_guess (uri->path, NULL, 0, NULL); + request->priv->content_type = + g_content_type_guess (uri->path, NULL, 0, NULL); request->priv->content_length = length; stream = g_memory_input_stream_new_from_data ( diff --git a/e-util/e-mail-signature-editor.c b/e-util/e-mail-signature-editor.c index da5e3389e0..d27fec570c 100644 --- a/e-util/e-mail-signature-editor.c +++ b/e-util/e-mail-signature-editor.c @@ -157,11 +157,16 @@ mail_signature_editor_loaded_cb (GObject *object, gtkhtml_editor_insert_text ( GTKHTML_EDITOR (editor), contents); - gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "cursor-position-save"); - gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "select-all"); - gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "style-pre"); - gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "unselect-all"); - gtkhtml_editor_run_command (GTKHTML_EDITOR (editor), "cursor-position-restore"); + gtkhtml_editor_run_command ( + GTKHTML_EDITOR (editor), "cursor-position-save"); + gtkhtml_editor_run_command ( + GTKHTML_EDITOR (editor), "select-all"); + gtkhtml_editor_run_command ( + GTKHTML_EDITOR (editor), "style-pre"); + gtkhtml_editor_run_command ( + GTKHTML_EDITOR (editor), "unselect-all"); + gtkhtml_editor_run_command ( + GTKHTML_EDITOR (editor), "cursor-position-restore"); } g_free (contents); diff --git a/e-util/e-mail-signature-preview.c b/e-util/e-mail-signature-preview.c index 2ccfa55c8b..d5e809f778 100644 --- a/e-util/e-mail-signature-preview.c +++ b/e-util/e-mail-signature-preview.c @@ -59,7 +59,9 @@ G_DEFINE_TYPE ( static void replace_local_image_links (WebKitDOMElement *element) { - if (!element) + WebKitDOMElement *child; + + if (element == NULL) return; if (WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (element)) { @@ -90,11 +92,13 @@ replace_local_image_links (WebKitDOMElement *element) replace_local_image_links (WEBKIT_DOM_ELEMENT (frame_document)); } - replace_local_image_links (webkit_dom_element_get_first_element_child (element)); + child = webkit_dom_element_get_first_element_child (element); + replace_local_image_links (child); - while (element = webkit_dom_element_get_next_element_sibling (element), element) { + do { + element = webkit_dom_element_get_next_element_sibling (element); replace_local_image_links (element); - } + } while (element != NULL); } static void @@ -362,7 +366,9 @@ e_mail_signature_preview_init (EMailSignaturePreview *preview) { preview->priv = E_MAIL_SIGNATURE_PREVIEW_GET_PRIVATE (preview); - g_signal_connect (preview, "document-load-finished", G_CALLBACK (signature_preview_document_loaded_cb), NULL); + g_signal_connect ( + preview, "document-load-finished", + G_CALLBACK (signature_preview_document_loaded_cb), NULL); } GtkWidget * diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c index 59e6e67eb2..ae034d6a3b 100644 --- a/e-util/e-misc-utils.c +++ b/e-util/e-misc-utils.c @@ -363,12 +363,20 @@ e_restore_window (GtkWindow *window, data->premax_height = height; monitor = gdk_screen_get_monitor_at_point (screen, x, y); - if (monitor < 0 || monitor >= gdk_screen_get_n_monitors (screen)) + if (monitor < 0) monitor = 0; - gdk_screen_get_monitor_workarea (screen, monitor, &monitor_area); + if (monitor >= gdk_screen_get_n_monitors (screen)) + monitor = 0; + + gdk_screen_get_monitor_workarea ( + screen, monitor, &monitor_area); + + gtk_window_resize ( + window, + monitor_area.width, + monitor_area.height); - gtk_window_resize (window, monitor_area.width, monitor_area.height); gtk_window_maximize (window); } } diff --git a/e-util/e-name-selector-dialog.c b/e-util/e-name-selector-dialog.c index d986f11c3a..be1ba5a9c4 100644 --- a/e-util/e-name-selector-dialog.c +++ b/e-util/e-name-selector-dialog.c @@ -148,17 +148,6 @@ name_selector_dialog_populate_categories (ENameSelectorDialog *name_selector_dia } static void -name_selector_dialog_realize_cb (ENameSelectorDialog *name_selector_dialog, - gpointer user_data) -{ - g_return_if_fail (E_IS_NAME_SELECTOR_DIALOG (name_selector_dialog)); - - source_changed ( - name_selector_dialog, - E_CLIENT_COMBO_BOX (name_selector_dialog->priv->client_combo)); -} - -static void name_selector_dialog_set_client_cache (ENameSelectorDialog *name_selector_dialog, EClientCache *client_cache) { @@ -589,15 +578,32 @@ name_selector_dialog_constructed (GObject *object) _("Select Contacts from Address Book")); gtk_widget_grab_focus (search); - g_signal_connect (object, "realize", G_CALLBACK (name_selector_dialog_realize_cb), NULL); - e_extensible_load_extensions (E_EXTENSIBLE (object)); } static void +name_selector_dialog_realize (GtkWidget *widget) +{ + ENameSelectorDialog *name_selector_dialog; + GtkWidget *client_combo; + + /* Chain up to parent's realize() method. */ + GTK_WIDGET_CLASS (e_name_selector_dialog_parent_class)-> + realize (widget); + + name_selector_dialog = E_NAME_SELECTOR_DIALOG (widget); + client_combo = name_selector_dialog->priv->client_combo; + + source_changed ( + name_selector_dialog, + E_CLIENT_COMBO_BOX (client_combo)); +} + +static void e_name_selector_dialog_class_init (ENameSelectorDialogClass *class) { GObjectClass *object_class; + GtkWidgetClass *widget_class; g_type_class_add_private (class, sizeof (ENameSelectorDialogPrivate)); @@ -608,6 +614,9 @@ e_name_selector_dialog_class_init (ENameSelectorDialogClass *class) object_class->finalize = name_selector_dialog_finalize; object_class->constructed = name_selector_dialog_constructed; + widget_class = GTK_WIDGET_CLASS (class); + widget_class->realize = name_selector_dialog_realize; + /** * ENameSelectorDialog:client-cache: * diff --git a/e-util/e-name-selector.c b/e-util/e-name-selector.c index 9f2f48cea8..3c5340c37c 100644 --- a/e-util/e-name-selector.c +++ b/e-util/e-name-selector.c @@ -100,6 +100,7 @@ name_selector_get_client_cb (GObject *source_object, GArray *sections; SourceBook source_book; guint ii; + gboolean ignore_error; GError *error = NULL; client = e_client_cache_get_client_finish ( @@ -110,11 +111,18 @@ name_selector_get_client_cb (GObject *source_object, ((client != NULL) && (error == NULL)) || ((client == NULL) && (error != NULL))); + ignore_error = + g_error_matches ( + error, E_CLIENT_ERROR, + E_CLIENT_ERROR_REPOSITORY_OFFLINE) || + g_error_matches ( + error, E_CLIENT_ERROR, + E_CLIENT_ERROR_OFFLINE_UNAVAILABLE) || + g_error_matches ( + error, G_IO_ERROR, G_IO_ERROR_CANCELLED); + if (error != NULL) { - if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE) - && !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OFFLINE_UNAVAILABLE) - && !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) - && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (!ignore_error) g_warning ("%s: %s", G_STRFUNC, error->message); g_error_free (error); goto exit; diff --git a/e-util/e-source-config.c b/e-util/e-source-config.c index ba75b7c8bb..c56eb65071 100644 --- a/e-util/e-source-config.c +++ b/e-util/e-source-config.c @@ -174,6 +174,7 @@ source_config_add_candidate (ESourceConfig *config, GtkBox *backend_box; GtkLabel *type_label; GtkComboBoxText *type_combo; + GtkWidget *widget; ESource *parent_source; ESourceRegistry *registry; const gchar *display_name; @@ -194,8 +195,9 @@ source_config_add_candidate (ESourceConfig *config, candidate->scratch_source = g_object_ref (scratch_source); /* Do not show the page here. */ - candidate->page = g_object_ref_sink (gtk_box_new (GTK_ORIENTATION_VERTICAL, 6)); - gtk_box_pack_start (backend_box, candidate->page, FALSE, FALSE, 0); + widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + gtk_box_pack_start (backend_box, widget, FALSE, FALSE, 0); + candidate->page = g_object_ref_sink (widget); g_ptr_array_add (config->priv->candidates, candidate); @@ -1385,8 +1387,7 @@ void e_source_config_add_secure_connection_for_webdav (ESourceConfig *config, ESource *scratch_source) { - GtkWidget *widget1; - GtkWidget *widget2; + GtkWidget *widget; ESourceExtension *extension; ESourceAuthentication *authentication_extension; const gchar *extension_name; @@ -1399,18 +1400,19 @@ e_source_config_add_secure_connection_for_webdav (ESourceConfig *config, extension = e_source_get_extension (scratch_source, extension_name); label = _("Use a secure connection"); - widget1 = gtk_check_button_new_with_label (label); - e_source_config_insert_widget (config, scratch_source, NULL, widget1); - gtk_widget_show (widget1); + widget = gtk_check_button_new_with_label (label); + e_source_config_insert_widget (config, scratch_source, NULL, widget); + gtk_widget_show (widget); g_object_bind_property ( extension, "secure", - widget1, "active", + widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); extension_name = E_SOURCE_EXTENSION_AUTHENTICATION; - authentication_extension = e_source_get_extension (scratch_source, extension_name); + authentication_extension = + e_source_get_extension (scratch_source, extension_name); g_object_bind_property_full ( extension, "secure", @@ -1422,19 +1424,22 @@ e_source_config_add_secure_connection_for_webdav (ESourceConfig *config, extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND; extension = e_source_get_extension (scratch_source, extension_name); - widget2 = gtk_button_new_with_mnemonic (_("Unset _trust for SSL certificate")); - gtk_widget_set_margin_left (widget2, 24); - e_source_config_insert_widget (config, scratch_source, NULL, widget2); - gtk_widget_show (widget2); + widget = gtk_button_new_with_mnemonic ( + _("Unset _trust for SSL certificate")); + gtk_widget_set_margin_left (widget, 24); + e_source_config_insert_widget (config, scratch_source, NULL, widget); + gtk_widget_show (widget); g_object_bind_property_full ( extension, "ssl-trust", - widget2, "sensitive", + widget, "sensitive", G_BINDING_SYNC_CREATE, webdav_source_ssl_trust_to_sensitive_cb, NULL, NULL, NULL); - g_signal_connect (widget2, "clicked", G_CALLBACK (webdav_unset_ssl_trust_clicked_cb), extension); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (webdav_unset_ssl_trust_clicked_cb), extension); } void diff --git a/e-util/e-tree.c b/e-util/e-tree.c index 208b2687f2..60f1d272ab 100644 --- a/e-util/e-tree.c +++ b/e-util/e-tree.c @@ -1245,8 +1245,8 @@ table_canvas_focus_event_cb (GtkWidget *widget, static void e_tree_table_canvas_scrolled_cb (GtkAdjustment *vadjustment, - GParamSpec *param, - ETree *tree) + GParamSpec *param, + ETree *tree) { g_return_if_fail (E_IS_TREE (tree)); @@ -1272,7 +1272,8 @@ et_setup_table_canvas_vadjustment (ETree *tree) if (vadjustment) { tree->priv->table_canvas_vadjustment = g_object_ref (vadjustment); - g_signal_connect (vadjustment, "notify::value", + g_signal_connect ( + vadjustment, "notify::value", G_CALLBACK (e_tree_table_canvas_scrolled_cb), tree); } } @@ -1324,7 +1325,8 @@ e_tree_setup_table (ETree *tree) G_CALLBACK (tree_canvas_reflow), tree); et_setup_table_canvas_vadjustment (tree); - g_signal_connect_swapped (tree->priv->table_canvas, "notify::vadjustment", + g_signal_connect_swapped ( + tree->priv->table_canvas, "notify::vadjustment", G_CALLBACK (et_setup_table_canvas_vadjustment), tree); widget = GTK_WIDGET (tree->priv->table_canvas); diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c index bc0b2648ce..4257152ca8 100644 --- a/e-util/e-web-view.c +++ b/e-util/e-web-view.c @@ -2220,9 +2220,11 @@ e_web_view_add_highlight (EWebView *web_view, &web_view->priv->highlights, g_strdup (highlight)); - webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW (web_view), highlight, FALSE, 0); + webkit_web_view_mark_text_matches ( + WEBKIT_WEB_VIEW (web_view), highlight, FALSE, 0); - webkit_web_view_set_highlight_text_matches (WEBKIT_WEB_VIEW (web_view), TRUE); + webkit_web_view_set_highlight_text_matches ( + WEBKIT_WEB_VIEW (web_view), TRUE); } void diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c index 1c9dcbb544..6402e26a65 100644 --- a/libemail-engine/e-mail-session-utils.c +++ b/libemail-engine/e-mail-session-utils.c @@ -625,6 +625,8 @@ skip_send: /* Run filters on the outgoing message. */ if (context->driver != NULL) { + CamelMessageFlags message_flags; + camel_filter_driver_filter_message ( context->driver, context->message, context->info, NULL, NULL, NULL, "", cancellable, &error); @@ -640,7 +642,9 @@ skip_send: g_clear_error (&error); } - if ((camel_message_info_flags (context->info) & CAMEL_MESSAGE_DELETED) != 0) + message_flags = camel_message_info_flags (context->info); + + if (message_flags & CAMEL_MESSAGE_DELETED) copy_to_sent = FALSE; } diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c index e8da91544b..58d217d9c2 100644 --- a/libemail-engine/e-mail-session.c +++ b/libemail-engine/e-mail-session.c @@ -175,10 +175,13 @@ user_message_response_cb (GObject *source, struct _user_message_msg *m = user_data; GError *local_error = NULL; - m->result = e_user_prompter_prompt_finish (E_USER_PROMPTER (source), result, &local_error); + m->result = e_user_prompter_prompt_finish ( + E_USER_PROMPTER (source), result, &local_error); - if (local_error) { - g_print ("%s: Failed to prompt user: %s\n", G_STRFUNC, local_error->message); + if (local_error != NULL) { + g_warning ( + "%s: Failed to prompt user: %s", + G_STRFUNC, local_error->message); g_clear_error (&local_error); } @@ -1412,6 +1415,7 @@ mail_session_trust_prompt (CamelSession *session, CamelCertTrust response; gchar *errors_code; GList *iter; + gint button_index; gint ii; prompter = e_user_prompter_new (); @@ -1433,19 +1437,23 @@ mail_session_trust_prompt (CamelSession *session, g_free (name); } - switch (e_user_prompter_extension_prompt_sync (prompter, "ETrustPrompt::trust-prompt", parameters, NULL, cancellable, NULL)) { - case 0: - response = CAMEL_CERT_TRUST_NEVER; - break; - case 1: - response = CAMEL_CERT_TRUST_FULLY; - break; - case 2: - response = CAMEL_CERT_TRUST_TEMPORARY; - break; - default: - response = CAMEL_CERT_TRUST_UNKNOWN; - break; + button_index = e_user_prompter_extension_prompt_sync ( + prompter, "ETrustPrompt::trust-prompt", + parameters, NULL, cancellable, NULL); + + switch (button_index) { + case 0: + response = CAMEL_CERT_TRUST_NEVER; + break; + case 1: + response = CAMEL_CERT_TRUST_FULLY; + break; + case 2: + response = CAMEL_CERT_TRUST_TEMPORARY; + break; + default: + response = CAMEL_CERT_TRUST_UNKNOWN; + break; } g_free (errors_code); diff --git a/libemail-engine/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c index a48a92c61f..edffb9a593 100644 --- a/libemail-engine/mail-folder-cache.c +++ b/libemail-engine/mail-folder-cache.c @@ -895,8 +895,9 @@ folder_changed_cb (CamelFolder *folder, parent_store = camel_folder_get_parent_store (folder); session = camel_service_ref_session (CAMEL_SERVICE (parent_store)); - if (!last_newmail_per_folder) - last_newmail_per_folder = g_hash_table_new (g_direct_hash, g_direct_equal); + if (last_newmail_per_folder == NULL) + last_newmail_per_folder = g_hash_table_new ( + g_direct_hash, g_direct_equal); /* it's fine to hash them by folder pointer here */ latest_received = GPOINTER_TO_INT ( diff --git a/libemail-engine/mail-tools.c b/libemail-engine/mail-tools.c index 00cd653509..5961de67f6 100644 --- a/libemail-engine/mail-tools.c +++ b/libemail-engine/mail-tools.c @@ -192,14 +192,22 @@ mail_tool_generate_forward_subject (CamelMimeMessage *msg) struct _camel_header_raw * mail_tool_remove_xevolution_headers (CamelMimeMessage *message) { + struct _camel_header_raw *headers; struct _camel_header_raw *scan, *list = NULL; - for (scan = ((CamelMimePart *) message)->headers; scan; scan = scan->next) - if (!strncmp (scan->name, "X-Evolution", 11)) - camel_header_raw_append (&list, scan->name, scan->value, scan->offset); + headers = CAMEL_MIME_PART (message)->headers; - for (scan = list; scan; scan = scan->next) - camel_medium_remove_header ((CamelMedium *) message, scan->name); + for (scan = headers; scan != NULL; scan = scan->next) { + if (strncmp (scan->name, "X-Evolution", 11) == 0) + camel_header_raw_append ( + &list, scan->name, + scan->value, scan->offset); + } + + for (scan = list; scan; scan = scan->next) { + camel_medium_remove_header ( + CAMEL_MEDIUM (message), scan->name); + } return list; } diff --git a/mail/e-mail-label-list-store.c b/mail/e-mail-label-list-store.c index bdb4f16a76..f00a0ec56e 100644 --- a/mail/e-mail-label-list-store.c +++ b/mail/e-mail-label-list-store.c @@ -277,7 +277,7 @@ labels_model_changed_cb (EMailLabelListStore *store) g_return_if_fail (E_IS_MAIL_LABEL_LIST_STORE (store)); /* do the actual save and signal emission on idle, - to accumulate as many changes as possible */ + * to accumulate as many changes as possible */ if (!store->priv->idle_changed_id) store->priv->idle_changed_id = g_idle_add (labels_model_changed_idle_cb, store); } @@ -300,7 +300,7 @@ labels_settings_changed_cb (GSettings *settings, strv = g_settings_get_strv (store->priv->mail_settings, "labels"); /* Check if any label changed first, because GSettings can claim - change when nothing changed at all */ + * change when nothing changed at all */ changed_labels = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); if (gtk_tree_model_get_iter_first (model, &iter)) { do { @@ -312,7 +312,6 @@ labels_settings_changed_cb (GSettings *settings, g_hash_table_insert (changed_labels, label_str, NULL); } while (gtk_tree_model_iter_next (model, &iter)); - for (i = 0; strv[i] != NULL; i++) { if (!g_hash_table_remove (changed_labels, strv[i])) { g_hash_table_insert (changed_labels, g_strdup (""), NULL); diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index d8d9eb7496..0926363ad2 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -1027,10 +1027,14 @@ em_utils_composer_print_cb (EMsgComposer *composer, g_object_unref (operation); - if (error) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - g_warning ("%s: Failed to run print operation: %s", G_STRFUNC, error->message); - g_clear_error (&error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + + } else if (error != NULL) { + g_warning ( + "%s: Failed to run print operation: %s", + G_STRFUNC, error->message); + g_error_free (error); } #else EMailParser *parser; diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c index d2fe86e0ca..125f3c36d6 100644 --- a/modules/addressbook/e-book-shell-view-actions.c +++ b/modules/addressbook/e-book-shell-view-actions.c @@ -212,17 +212,22 @@ address_book_refresh_done_cb (GObject *source_object, client = E_CLIENT (source_object); - if (!e_client_refresh_finish (client, result, &error)) { - ESource *source = e_client_get_source (client); + e_client_refresh_finish (client, result, &error); - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && - !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) - g_warning ( - "%s: Failed to refresh '%s', %s", - G_STRFUNC, e_source_get_display_name (source), - error ? error->message : "Unknown error"); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + + } else if (error != NULL) { + ESource *source; + + source = e_client_get_source (client); - g_clear_error (&error); + g_warning ( + "%s: Failed to refresh '%s', %s", + G_STRFUNC, e_source_get_display_name (source), + error ? error->message : "Unknown error"); + + g_error_free (error); } } @@ -267,7 +272,7 @@ contact_editor_contact_modified_cb (EABEditor *editor, EContactMap *map; const gchar *contact_uid; - if (error) { + if (error != NULL) { g_warning ("Error modifying contact: %s", error->message); return; } diff --git a/modules/backup-restore/evolution-backup-tool.c b/modules/backup-restore/evolution-backup-tool.c index 93a56bd672..4b8ad9f8cb 100644 --- a/modules/backup-restore/evolution-backup-tool.c +++ b/modules/backup-restore/evolution-backup-tool.c @@ -242,7 +242,8 @@ replace_in_file (const gchar *filename, } g_free (content); - } else if (error) { + + } else if (error != NULL) { g_warning ( "%s: Cannot read file content, error: %s", G_STRFUNC, error->message); @@ -296,7 +297,7 @@ write_dir_file (void) g_file_set_contents (filename->str, content->str, content->len, &error); - if (error) { + if (error != NULL) { g_warning ("Failed to write file '%s': %s\n", filename->str, error->message); g_error_free (error); } @@ -389,7 +390,7 @@ extract_backup_data (const gchar *filename, key_file = g_key_file_new (); g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &error); - if (error) { + if (error != NULL) { g_warning ("Failed to read '%s': %s", filename, error->message); g_error_free (error); diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index 295b6de60d..ff8bc955e9 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -208,16 +208,10 @@ cal_shell_sidebar_handle_connect_error (EActivity *activity, const GError *error) { EAlertSink *alert_sink; - gboolean cancelled = FALSE; gboolean offline_error; alert_sink = e_activity_get_alert_sink (activity); - cancelled |= g_error_matches ( - error, G_IO_ERROR, G_IO_ERROR_CANCELLED); - cancelled |= g_error_matches ( - error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED); - offline_error = g_error_matches ( error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE); diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c index aa890c26ef..7d3315b020 100644 --- a/modules/calendar/e-cal-shell-view-actions.c +++ b/modules/calendar/e-cal-shell-view-actions.c @@ -1000,8 +1000,7 @@ action_event_occurrence_movable_cb (GtkAction *action, g_object_unref (recurring_component); icalcomp = e_cal_component_get_icalcomponent (exception_component); - if (e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) - g_free (uid); + e_cal_client_create_object_sync (client, icalcomp, NULL, NULL, NULL); g_object_unref (exception_component); diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index 6b93828f65..46f89e8b4d 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -1015,8 +1015,11 @@ add_timezone_to_cal_cb (icalparameter *param, if (!tzid || !*tzid) return; - if (e_cal_client_get_timezone_sync (ftd->source_client, tzid, &tz, NULL, NULL) && tz) - e_cal_client_add_timezone_sync (ftd->dest_client, tz, NULL, NULL); + e_cal_client_get_timezone_sync ( + ftd->source_client, tzid, &tz, NULL, NULL); + if (tz != NULL) + e_cal_client_add_timezone_sync ( + ftd->dest_client, tz, NULL, NULL); } void @@ -1367,9 +1370,9 @@ cal_searching_got_instance_cb (ECalComponent *comp, if (dt.tzid && dt.value) { icaltimezone *zone = NULL; - if (!e_cal_client_get_timezone_sync (gid->client, dt.tzid, &zone, gid->cancellable, NULL)) { - zone = NULL; - } + + e_cal_client_get_timezone_sync ( + gid->client, dt.tzid, &zone, gid->cancellable, NULL); if (g_cancellable_is_cancelled (gid->cancellable)) return FALSE; @@ -1405,14 +1408,17 @@ cal_search_get_object_list_cb (GObject *source, g_return_if_fail (result != NULL); g_return_if_fail (cal_shell_view != NULL); - if (!e_cal_client_get_object_list_finish (client, result, &icalcomps, &error) || !icalcomps) { - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_clear_error (&error); - return; - } + e_cal_client_get_object_list_finish ( + client, result, &icalcomps, &error); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_warn_if_fail (icalcomps == NULL); + g_error_free (error); + + } else if (error != NULL) { + g_warn_if_fail (icalcomps == NULL); + g_error_free (error); - g_clear_error (&error); cal_shell_view->priv->search_pending_count--; if (!cal_shell_view->priv->search_pending_count) { cal_shell_view->priv->search_hit_cache = @@ -1421,6 +1427,7 @@ cal_search_get_object_list_cb (GObject *source, cal_time_t_ptr_compare); cal_iterate_searching (cal_shell_view); } + } else { GSList *iter; GCancellable *cancellable; @@ -1478,7 +1485,9 @@ cal_searching_check_candidates (ECalShellView *cal_shell_view) if (!e_calendar_view_get_selected_time_range (calendar_view, &value, NULL)) return FALSE; - if (cal_shell_view->priv->search_direction > 0 && (view_type == GNOME_CAL_WEEK_VIEW || view_type == GNOME_CAL_MONTH_VIEW)) + if (cal_shell_view->priv->search_direction > 0 && + (view_type == GNOME_CAL_WEEK_VIEW || + view_type == GNOME_CAL_MONTH_VIEW)) value = time_add_day (value, 1); for (iter = cal_shell_view->priv->search_hit_cache; iter; iter = iter->next) { diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index 1654e1096c..eeab5f53b5 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -206,16 +206,10 @@ memo_shell_sidebar_handle_connect_error (EActivity *activity, const GError *error) { EAlertSink *alert_sink; - gboolean cancelled = FALSE; gboolean offline_error; alert_sink = e_activity_get_alert_sink (activity); - cancelled |= g_error_matches ( - error, G_IO_ERROR, G_IO_ERROR_CANCELLED); - cancelled |= g_error_matches ( - error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED); - offline_error = g_error_matches ( error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE); diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c index 8dc20d4b84..f1837f82cf 100644 --- a/modules/calendar/e-task-shell-sidebar.c +++ b/modules/calendar/e-task-shell-sidebar.c @@ -206,16 +206,10 @@ task_shell_sidebar_handle_connect_error (EActivity *activity, const GError *error) { EAlertSink *alert_sink; - gboolean cancelled = FALSE; gboolean offline_error; alert_sink = e_activity_get_alert_sink (activity); - cancelled |= g_error_matches ( - error, G_IO_ERROR, G_IO_ERROR_CANCELLED); - cancelled |= g_error_matches ( - error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED); - offline_error = g_error_matches ( error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE); diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c index 1e4a549a82..45f0b1d393 100644 --- a/modules/itip-formatter/itip-view.c +++ b/modules/itip-formatter/itip-view.c @@ -3501,7 +3501,7 @@ adjust_item (EMailPartItip *pitip, static gboolean same_attendee_status (EMailPartItip *pitip, - ECalComponent *received_comp) + ECalComponent *received_comp) { ECalComponent *saved_comp; GSList *received_attendees = NULL, *saved_attendees = NULL, *riter, *siter; @@ -3527,7 +3527,7 @@ same_attendee_status (EMailPartItip *pitip, } /* no need to create a hash table for quicker searches, there might - be one attendee in the received component only */ + * be one attendee in the received component only */ for (siter = saved_attendees; siter; siter = g_slist_next (siter)) { const ECalComponentAttendee *sattendee = siter->data; @@ -3614,8 +3614,7 @@ itip_view_cal_opened_cb (GObject *source_object, ((client == NULL) && (error != NULL))); /* Ignore cancellations. */ - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_error_free (error); goto exit; @@ -3941,11 +3940,9 @@ get_object_without_rid_ready_cb (GObject *source_object, icalcomponent *icalcomp = NULL; GError *error = NULL; - if (!e_cal_client_get_object_finish (cal_client, result, &icalcomp, &error)) - icalcomp = NULL; + e_cal_client_get_object_finish (cal_client, result, &icalcomp, &error); - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || g_cancellable_is_cancelled (fd->cancellable)) { g_clear_error (&error); find_cal_update_ui (fd, cal_client); @@ -3992,11 +3989,9 @@ get_object_with_rid_ready_cb (GObject *source_object, icalcomponent *icalcomp = NULL; GError *error = NULL; - if (!e_cal_client_get_object_finish (cal_client, result, &icalcomp, &error)) - icalcomp = NULL; + e_cal_client_get_object_finish (cal_client, result, &icalcomp, &error); - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || g_cancellable_is_cancelled (fd->cancellable)) { g_clear_error (&error); find_cal_update_ui (fd, cal_client); @@ -4048,8 +4043,8 @@ get_object_list_ready_cb (GObject *source_object, GSList *objects = NULL; GError *error = NULL; - if (!e_cal_client_get_object_list_finish (cal_client, result, &objects, &error)) - objects = NULL; + e_cal_client_get_object_list_finish ( + cal_client, result, &objects, &error); if (g_cancellable_is_cancelled (fd->cancellable)) { g_clear_error (&error); @@ -4057,21 +4052,24 @@ get_object_list_ready_cb (GObject *source_object, return; } - if (error) { - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_error_free (error); - decrease_find_data (fd); - return; - } + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + decrease_find_data (fd); + return; + } else if (error != NULL) { g_error_free (error); + } else { - g_hash_table_insert (fd->conflicts, cal_client, GINT_TO_POINTER (g_slist_length (objects))); + g_hash_table_insert ( + fd->conflicts, cal_client, + GINT_TO_POINTER (g_slist_length (objects))); e_cal_client_free_icalcomp_slist (objects); } - e_cal_client_get_object (cal_client, fd->uid, fd->rid, fd->cancellable, get_object_with_rid_ready_cb, fd); + e_cal_client_get_object ( + cal_client, fd->uid, fd->rid, fd->cancellable, + get_object_with_rid_ready_cb, fd); } static void @@ -4098,8 +4096,7 @@ find_cal_opened_cb (GObject *source_object, ((client == NULL) && (error != NULL))); /* Ignore cancellations. */ - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { decrease_find_data (fd); g_error_free (error); return; @@ -4111,7 +4108,7 @@ find_cal_opened_cb (GObject *source_object, return; } - if (error) { + if (error != NULL) { /* FIXME Do we really want to warn here? If we fail * to find the item, this won't be cleared but the * selector might be shown */ @@ -4643,17 +4640,18 @@ receive_objects_ready_cb (GObject *ecalclient, e_cal_client_receive_objects_finish (client, result, &error); - if (error != NULL) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && - !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { - update_item_progress_info (pitip, view, NULL); - pitip->update_item_error_info_id = - itip_view_add_lower_info_item_printf ( - view, ITIP_VIEW_INFO_ITEM_TYPE_INFO, - _("Unable to send item to calendar '%s'. %s"), - e_source_get_display_name (source), - error->message); - } + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + return; + + } else if (error != NULL) { + update_item_progress_info (pitip, view, NULL); + pitip->update_item_error_info_id = + itip_view_add_lower_info_item_printf ( + view, ITIP_VIEW_INFO_ITEM_TYPE_INFO, + _("Unable to send item to calendar '%s'. %s"), + e_source_get_display_name (source), + error->message); g_error_free (error); return; } @@ -4999,13 +4997,10 @@ modify_object_cb (GObject *ecalclient, e_cal_client_modify_object_finish (client, result, &error); - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || - g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_error_free (error); - return; - } - if (error != NULL) { + } else if (error != NULL) { update_item_progress_info (pitip, view, NULL); pitip->update_item_error_info_id = itip_view_add_lower_info_item_printf ( @@ -5013,6 +5008,7 @@ modify_object_cb (GObject *ecalclient, _("Unable to update attendee. %s"), error->message); g_error_free (error); + } else { update_item_progress_info (pitip, view, NULL); itip_view_add_lower_info_item ( @@ -5187,24 +5183,25 @@ update_attendee_status_get_object_without_rid_cb (GObject *ecalclient, icalcomponent *icalcomp = NULL; GError *error = NULL; - if (!e_cal_client_get_object_finish (client, result, &icalcomp, &error)) { - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || - g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { - g_clear_error (&error); - return; - } + e_cal_client_get_object_finish (client, result, &icalcomp, &error); - g_clear_error (&error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + + } else if (error != NULL) { + g_error_free (error); update_item_progress_info (pitip, view, NULL); - pitip->update_item_error_info_id = itip_view_add_lower_info_item ( - view, - ITIP_VIEW_INFO_ITEM_TYPE_WARNING, - _("Attendee status can not be updated because the item no longer exists")); - return; - } + pitip->update_item_error_info_id = + itip_view_add_lower_info_item ( + view, + ITIP_VIEW_INFO_ITEM_TYPE_WARNING, + _("Attendee status can not be updated " + "because the item no longer exists")); - update_attendee_status_icalcomp (pitip, view, icalcomp); + } else { + update_attendee_status_icalcomp (pitip, view, icalcomp); + } } static void @@ -5218,45 +5215,43 @@ update_attendee_status_get_object_with_rid_cb (GObject *ecalclient, icalcomponent *icalcomp = NULL; GError *error = NULL; - if (!e_cal_client_get_object_finish (client, result, &icalcomp, &error)) { + e_cal_client_get_object_finish (client, result, &icalcomp, &error); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + + } else if (error != NULL) { const gchar *uid; gchar *rid; - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || - g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { - g_clear_error (&error); - return; - } - - g_clear_error (&error); + g_error_free (error); e_cal_component_get_uid (pitip->comp, &uid); rid = e_cal_component_get_recurid_as_string (pitip->comp); - if (!rid || !*rid) { - g_free (rid); - + if (rid == NULL || *rid == '\0') { update_item_progress_info (pitip, view, NULL); - pitip->update_item_error_info_id = itip_view_add_lower_info_item ( - view, - ITIP_VIEW_INFO_ITEM_TYPE_WARNING, - _("Attendee status can not be updated because the item no longer exists")); - return; + pitip->update_item_error_info_id = + itip_view_add_lower_info_item ( + view, + ITIP_VIEW_INFO_ITEM_TYPE_WARNING, + _("Attendee status can not be updated " + "because the item no longer exists")); + } else { + e_cal_client_get_object ( + pitip->current_client, + uid, + NULL, + pitip->cancellable, + update_attendee_status_get_object_without_rid_cb, + view); } - e_cal_client_get_object ( - pitip->current_client, - uid, - NULL, - pitip->cancellable, - update_attendee_status_get_object_without_rid_cb, - view); - g_free (rid); - return; - } - update_attendee_status_icalcomp (pitip, view, icalcomp); + } else { + update_attendee_status_icalcomp (pitip, view, icalcomp); + } } static void diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index e451574ecf..a0191effa3 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -112,21 +112,25 @@ account_refresh_folder_info_received_cb (GObject *source, GError *error = NULL; store = CAMEL_STORE (source); - activity = user_data; + activity = E_ACTIVITY (user_data); + info = camel_store_get_folder_info_finish (store, result, &error); - if (info) { - /* provider takes care of notifications of new/removed folders, - * thus it's enough to free the returned list */ + + if (info != NULL) { + /* Provider takes care of notifications of new/removed + * folders, thus it's enough to free the returned list. */ camel_store_free_folder_info (store, info); } - if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - g_message ("%s: Failed: %s", G_STRFUNC, error->message); + if (e_activity_handle_cancellation (activity, error)) { + g_error_free (error); - g_clear_error (&error); + } else if (error != NULL) { + g_warning ("%s: %s", G_STRFUNC, error->message); + g_error_free (error); + } - if (activity) - g_object_unref (activity); + g_clear_object (&activity); } static void @@ -458,7 +462,7 @@ mark_all_read_thread (GSimpleAsyncResult *simple, g_object_unref (folder); } - if (error) + if (error != NULL) g_simple_async_result_take_error (simple, error); } diff --git a/modules/offline-alert/evolution-offline-alert.c b/modules/offline-alert/evolution-offline-alert.c index 767f41a757..d6cb0463bc 100644 --- a/modules/offline-alert/evolution-offline-alert.c +++ b/modules/offline-alert/evolution-offline-alert.c @@ -108,6 +108,7 @@ offline_alert_window_added_cb (GtkApplication *application, { EShell *shell = E_SHELL (application); GtkAction *action; + const gchar *alert_id; if (!E_IS_SHELL_WINDOW (window)) return; @@ -137,7 +138,11 @@ offline_alert_window_added_cb (GtkApplication *application, action = E_SHELL_WINDOW_ACTION_WORK_ONLINE (window); - extension->alert = e_alert_new (e_shell_get_network_available (shell) ? "offline-alert:offline" : "offline-alert:no-network", NULL); + if (e_shell_get_network_available (shell)) + alert_id = "offline-alert:offline"; + else + alert_id = "offline-alert:no-network"; + extension->alert = e_alert_new (alert_id, NULL); e_alert_add_action (extension->alert, action, GTK_RESPONSE_NONE); g_object_add_weak_pointer ( diff --git a/modules/settings/e-settings-deprecated.c b/modules/settings/e-settings-deprecated.c index 1249288d92..902e6bf42f 100644 --- a/modules/settings/e-settings-deprecated.c +++ b/modules/settings/e-settings-deprecated.c @@ -99,8 +99,8 @@ settings_deprecated_header_start_element (GMarkupParseContext *context, static void e_settings_deprecated_set_int_with_change_test (GSettings *settings, - const gchar *key, - gint value) + const gchar *key, + gint value) { if (g_settings_get_int (settings, key) != value) g_settings_set_int (settings, key, value); @@ -108,8 +108,8 @@ e_settings_deprecated_set_int_with_change_test (GSettings *settings, static void e_settings_deprecated_set_string_with_change_test (GSettings *settings, - const gchar *key, - const gchar *value) + const gchar *key, + const gchar *value) { gchar *stored = g_settings_get_string (settings, key); @@ -121,8 +121,8 @@ e_settings_deprecated_set_string_with_change_test (GSettings *settings, static void e_settings_deprecated_set_strv_with_change_test (GSettings *settings, - const gchar *key, - const gchar * const *value) + const gchar *key, + const gchar * const *value) { gchar **stored = g_settings_get_strv (settings, key); gboolean changed; diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c index bfb6959047..31aebceff2 100644 --- a/plugins/bbdb/bbdb.c +++ b/plugins/bbdb/bbdb.c @@ -272,7 +272,7 @@ bbdb_do_it (EBookClient *client, const gchar *name, const gchar *email) { - gchar *query_string, *delim, *temp_name = NULL, *uid; + gchar *query_string, *delim, *temp_name = NULL; GSList *contacts = NULL; gboolean status; EContact *contact; @@ -334,8 +334,14 @@ bbdb_do_it (EBookClient *client, contact = (EContact *) contacts->data; add_email_to_contact (contact, email); - if (!e_book_client_modify_contact_sync (client, contact, NULL, &error)) { - g_warning ("bbdb: Could not modify contact: %s\n", error->message); + + e_book_client_modify_contact_sync ( + client, contact, NULL, &error); + + if (error != NULL) { + g_warning ( + "bbdb: Could not modify contact: %s\n", + error->message); g_error_free (error); } @@ -350,14 +356,16 @@ bbdb_do_it (EBookClient *client, add_email_to_contact (contact, email); g_free (temp_name); - uid = NULL; - if (!e_book_client_add_contact_sync (client, contact, &uid, NULL, &error)) { - g_warning ("bbdb: Failed to add new contact: %s", error->message); + e_book_client_add_contact_sync (client, contact, NULL, NULL, &error); + + if (error != NULL) { + g_warning ( + "bbdb: Failed to add new contact: %s", + error->message); g_error_free (error); } g_object_unref (contact); - g_free (uid); } EBookClient * diff --git a/plugins/bbdb/gaimbuddies.c b/plugins/bbdb/gaimbuddies.c index 7f55c18fde..d0f2a066cf 100644 --- a/plugins/bbdb/gaimbuddies.c +++ b/plugins/bbdb/gaimbuddies.c @@ -224,7 +224,7 @@ bbdb_sync_buddy_list_in_thread (gpointer data) for (link = head; link != NULL; link = g_list_next (link)) { GaimBuddy *b = link->data; EBookQuery *query; - gchar *query_string, *uid; + gchar *query_string; GSList *contacts = NULL; EContact *c; @@ -268,8 +268,13 @@ bbdb_sync_buddy_list_in_thread (gpointer data) } /* Write it out to the addressbook */ - if (!e_book_client_modify_contact_sync (client, c, NULL, &error)) { - g_warning ("bbdb: Could not modify contact: %s", error->message); + e_book_client_modify_contact_sync ( + client, c, NULL, &error); + + if (error != NULL) { + g_warning ( + "bbdb: Could not modify contact: %s", + error->message); g_clear_error (&error); } @@ -287,15 +292,17 @@ bbdb_sync_buddy_list_in_thread (gpointer data) continue; } - uid = NULL; - if (!e_book_client_add_contact_sync (client, c, &uid, NULL, &error)) { - g_warning ("bbdb: Failed to add new contact: %s", error->message); + e_book_client_add_contact_sync (client, c, NULL, NULL, &error); + + if (error != NULL) { + g_warning ( + "bbdb: Failed to add new contact: %s", + error->message); g_clear_error (&error); goto exit; } g_object_unref (c); - g_free (uid); } g_idle_add (store_last_sync_idle_cb, NULL); diff --git a/plugins/face/face.c b/plugins/face/face.c index 06a6bc675b..7ebfcf67a3 100644 --- a/plugins/face/face.c +++ b/plugins/face/face.c @@ -176,7 +176,7 @@ prepare_image (const gchar *image_filename, if (can_claim) e_alert_run_dialog_for_args (NULL, "org.gnome.evolution.plugins.face:not-an-image", err, NULL); - if (error) + if (error != NULL) g_error_free (error); } else { gint width, height; diff --git a/plugins/mail-notification/mail-notification.c b/plugins/mail-notification/mail-notification.c index 99abfdec20..f68cf35c41 100644 --- a/plugins/mail-notification/mail-notification.c +++ b/plugins/mail-notification/mail-notification.c @@ -163,7 +163,7 @@ send_dbus_message (const gchar *name, /* Frees the message */ g_object_unref (message); - if (error) { + if (error != NULL) { g_warning ("%s: %s", G_STRFUNC, error->message); g_error_free (error); } @@ -202,7 +202,7 @@ init_gdbus (void) return TRUE; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); - if (error) { + if (error != NULL) { g_warning ("could not get system bus: %s\n", error->message); g_error_free (error); diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index be27242544..28ce0b1d50 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -120,8 +120,7 @@ get_component_editor (EShell *shell, editor = memo_editor_new (client, shell, flags); break; default: - if (error) - *error = e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL); + g_warn_if_reached (); break; } @@ -382,7 +381,7 @@ attachment_save_finished (EAttachmentStore *store, GError *error = NULL; uris = e_attachment_store_save_finish (store, result, &error); - if (error) + if (error != NULL) data->uris = NULL; else data->uris = uris; @@ -811,12 +810,16 @@ do_manage_comp_idle (struct _manage_comp *mc) g_cond_signal (&mc->cond); } } else { - /* User canceled editing already existing event, so treat it as if he just closed the editor window */ + /* User canceled editing already existing event, so + * treat it as if he just closed the editor window. */ comp_editor_closed (NULL, FALSE, mc); } - if (error) { - e_notice (NULL, GTK_MESSAGE_ERROR, _("An error occurred during processing: %s"), error->message); + if (error != NULL) { + e_notice ( + NULL, GTK_MESSAGE_ERROR, + _("An error occurred during processing: %s"), + error->message); g_clear_error (&error); } @@ -1008,8 +1011,10 @@ do_mail_to_event (AsyncData *data) break; } - if (!e_cal_client_get_object_sync (E_CAL_CLIENT (client), icalcomponent_get_uid (icalcomp), NULL, &(mc->stored_comp), NULL, NULL)) - mc->stored_comp = NULL; + e_cal_client_get_object_sync ( + E_CAL_CLIENT (client), + icalcomponent_get_uid (icalcomp), + NULL, &mc->stored_comp, NULL, NULL); /* Prioritize ahead of GTK+ redraws. */ g_idle_add_full ( @@ -1193,9 +1198,11 @@ mail_to_event (ECalClientSourceType source_type, } else if (!source && default_source) { source = default_source; } else if (!source) { - e_notice (NULL, GTK_MESSAGE_ERROR, _("No writable calendar is available.")); + e_notice ( + NULL, GTK_MESSAGE_ERROR, + _("No writable calendar is available.")); - if (error) + if (error != NULL) g_error_free (error); goto exit; } diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c index 25ce9217fb..f5d4d5ada8 100644 --- a/plugins/pst-import/pst-importer.c +++ b/plugins/pst-import/pst-importer.c @@ -614,16 +614,18 @@ pst_get_client_cb (GObject *source_object, ((client != NULL) && (error == NULL)) || ((client == NULL) && (error != NULL))); - if (error) - g_debug ("%s: %s", G_STRFUNC, error->message); - g_clear_error (&error); - - if (client) { - if (E_IS_BOOK_CLIENT (client)) { - m->addressbook = E_BOOK_CLIENT (client); - } else if (E_IS_CAL_CLIENT (client)) { - ECalClient *cal_client = E_CAL_CLIENT (client); - switch (e_cal_client_get_source_type (cal_client)) { + if (error != NULL) { + g_warning ("%s: %s", G_STRFUNC, error->message); + g_error_free (error); + } + + if (E_IS_BOOK_CLIENT (client)) + m->addressbook = E_BOOK_CLIENT (client); + + if (E_IS_CAL_CLIENT (client)) { + ECalClient *cal_client = E_CAL_CLIENT (client); + + switch (e_cal_client_get_source_type (cal_client)) { case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: m->calendar = cal_client; break; @@ -634,13 +636,8 @@ pst_get_client_cb (GObject *source_object, m->journal = cal_client; break; default: - g_object_unref (client); g_warn_if_reached (); break; - } - } else { - g_object_unref (client); - g_warn_if_reached (); } } @@ -1518,7 +1515,6 @@ pst_process_contact (PstImporter *m, pst_item_contact *c; EContact *ec; GString *notes; - gchar *uid = NULL; GError *error = NULL; c = item->contact; @@ -1659,11 +1655,10 @@ pst_process_contact (PstImporter *m, contact_set_string (ec, E_CONTACT_NOTE, notes->str); g_string_free (notes, TRUE); - if (!e_book_client_add_contact_sync (m->addressbook, ec, &uid, NULL, &error)) - uid = NULL; + e_book_client_add_contact_sync ( + m->addressbook, ec, NULL, NULL, &error); g_object_unref (ec); - g_free (uid); if (error != NULL) { g_warning ( @@ -2008,7 +2003,6 @@ pst_process_component (PstImporter *m, ECalClient *cal) { ECalComponent *ec; - gchar *uid = NULL; GError *error = NULL; g_return_if_fail (item->appointment != NULL); @@ -2019,15 +2013,18 @@ pst_process_component (PstImporter *m, fill_calcomponent (m, item, ec, comp_type); set_cal_attachments (cal, ec, m, item->attach); - if (!e_cal_client_create_object_sync (cal, e_cal_component_get_icalcomponent (ec), &uid, NULL, &error)) { - uid = NULL; - g_warning ("Creation of %s failed: %s", comp_type, error ? error->message : "Unknown error"); + e_cal_client_create_object_sync ( + cal, e_cal_component_get_icalcomponent (ec), + NULL, NULL, &error); + + if (error != NULL) { + g_warning ( + "Creation of %s failed: %s", + comp_type, error->message); + g_error_free (error); } g_object_unref (ec); - g_free (uid); - if (error) - g_error_free (error); } static void diff --git a/plugins/publish-calendar/publish-calendar.c b/plugins/publish-calendar/publish-calendar.c index 2f1480187e..2713f00dd2 100644 --- a/plugins/publish-calendar/publish-calendar.c +++ b/plugins/publish-calendar/publish-calendar.c @@ -200,41 +200,48 @@ publish_online (EPublishUri *uri, GOutputStream *stream; GError *error = NULL; - stream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error)); + stream = G_OUTPUT_STREAM (g_file_replace ( + file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error)); - if (!stream || error) { - if (stream) - g_object_unref (stream); + /* Sanity check. */ + g_return_if_fail ( + ((stream != NULL) && (error == NULL)) || + ((stream == NULL) && (error != NULL))); - if (perror) { + if (error != NULL) { + if (perror != NULL) { *perror = error; - } else if (error) { - - error_queue_add (g_strdup_printf (_("Could not open %s:"), uri->location), error); } else { - error_queue_add (g_strdup_printf (_("Could not open %s: Unknown error"), uri->location), NULL); + error_queue_add ( + g_strdup_printf ( + _("Could not open %s:"), + uri->location), + error); } return; } switch (uri->publish_format) { - case URI_PUBLISH_AS_ICAL: - publish_calendar_as_ical (stream, uri, &error); - break; - case URI_PUBLISH_AS_FB: - publish_calendar_as_fb (stream, uri, &error); - break; - /* - case URI_PUBLISH_AS_HTML: - publish_calendar_as_html (handle, uri); - break; - */ + case URI_PUBLISH_AS_ICAL: + publish_calendar_as_ical (stream, uri, &error); + break; + case URI_PUBLISH_AS_FB: + publish_calendar_as_fb (stream, uri, &error); + break; } - if (error) - error_queue_add (g_strdup_printf (_("There was an error while publishing to %s:"), uri->location), error); + if (error != NULL) + error_queue_add ( + g_strdup_printf ( + _("There was an error while publishing to %s:"), + uri->location), + error); else if (can_report_success) - error_queue_add (g_strdup_printf (_("Publishing to %s finished successfully"), uri->location), NULL); + error_queue_add ( + g_strdup_printf ( + _("Publishing to %s finished successfully"), + uri->location), + NULL); update_timestamp (uri); @@ -251,7 +258,7 @@ unmount_done_cb (GObject *source_object, g_mount_unmount_with_operation_finish (G_MOUNT (source_object), result, &error); - if (error) { + if (error != NULL) { g_warning ("Unmount failed: %s", error->message); g_error_free (error); } @@ -277,8 +284,12 @@ mount_ready_cb (GObject *source_object, g_file_mount_enclosing_volume_finish (G_FILE (source_object), result, &error); - if (error) { - error_queue_add (g_strdup_printf (_("Mount of %s failed:"), ms ? ms->uri->location : "???"), error); + if (error != NULL) { + error_queue_add ( + g_strdup_printf ( + _("Mount of %s failed:"), + ms ? ms->uri->location : "???"), + error); if (ms) g_object_unref (ms->mount_op); @@ -467,8 +478,12 @@ publish (EPublishUri *uri, mount_first (uri, file, can_report_success); } - if (error) - error_queue_add (g_strdup_printf (_("Could not open %s:"), uri->location), error); + if (error != NULL) + error_queue_add ( + g_strdup_printf ( + _("Could not open %s:"), + uri->location), + error); g_object_unref (file); } else { diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c index 28393040da..e343445ece 100644 --- a/plugins/publish-calendar/publish-format-fb.c +++ b/plugins/publish-calendar/publish-format-fb.c @@ -66,7 +66,7 @@ write_calendar (const gchar *uid, icalcomponent *top_level; gchar *email = NULL; GSList *users = NULL; - gboolean res = FALSE; + gboolean success = FALSE; utc = icaltimezone_get_utc_timezone (); start = time_day_begin_with_zone (start, utc); @@ -114,7 +114,9 @@ write_calendar (const gchar *uid, client, "free-busy-data", G_CALLBACK (free_busy_data_cb), &objects); - if (e_cal_client_get_free_busy_sync (E_CAL_CLIENT (client), start, end, users, NULL, error)) { + success = e_cal_client_get_free_busy_sync ( + E_CAL_CLIENT (client), start, end, users, NULL, error); + if (success) { gchar *ical_string; GSList *iter; gboolean done = FALSE; @@ -135,7 +137,11 @@ write_calendar (const gchar *uid, } ical_string = icalcomponent_as_ical_string_r (top_level); - res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL, error); + + success = g_output_stream_write_all ( + stream, ical_string, + strlen (ical_string), + NULL, NULL, error); e_cal_client_free_ecalcomp_slist (objects); g_free (ical_string); @@ -148,7 +154,7 @@ write_calendar (const gchar *uid, g_object_unref (client); icalcomponent_free (top_level); - return res; + return success; } void diff --git a/plugins/publish-calendar/publish-format-ical.c b/plugins/publish-calendar/publish-format-ical.c index 95e5dd8aef..c875904495 100644 --- a/plugins/publish-calendar/publish-format-ical.c +++ b/plugins/publish-calendar/publish-format-ical.c @@ -51,8 +51,13 @@ insert_tz_comps (icalparameter *param, if (g_hash_table_lookup (tdata->zones, tzid)) return; - if (!e_cal_client_get_timezone_sync (tdata->client, tzid, &zone, NULL, &error)) { - g_warning ("Could not get the timezone information for %s : %s \n", tzid, error->message); + e_cal_client_get_timezone_sync ( + tdata->client, tzid, &zone, NULL, &error); + + if (error != NULL) { + g_warning ( + "Could not get the timezone information for %s: %s", + tzid, error->message); g_error_free (error); return; } @@ -78,7 +83,7 @@ write_calendar (const gchar *uid, ESource *source; ESourceRegistry *registry; EClient *client = NULL; - GSList *objects; + GSList *objects = NULL; icalcomponent *top_level; gboolean res = FALSE; @@ -103,7 +108,10 @@ write_calendar (const gchar *uid, top_level = e_cal_util_new_top_level (); - if (e_cal_client_get_object_list_sync (E_CAL_CLIENT (client), "#t", &objects, NULL, error)) { + e_cal_client_get_object_list_sync ( + E_CAL_CLIENT (client), "#t", &objects, NULL, error); + + if (objects != NULL) { GSList *iter; gchar *ical_string; CompTzData tdata; diff --git a/plugins/save-calendar/csv-format.c b/plugins/save-calendar/csv-format.c index 1e1bf4a7e1..4374d98143 100644 --- a/plugins/save-calendar/csv-format.c +++ b/plugins/save-calendar/csv-format.c @@ -548,14 +548,12 @@ do_save_calendar_csv (FormatHandler *handler, g_free (config->newline); g_free (config); - if (error) { + if (error != NULL) { display_error_message ( gtk_widget_get_toplevel (GTK_WIDGET (selector)), error); g_error_free (error); } - - return; } static GtkWidget * diff --git a/plugins/save-calendar/ical-format.c b/plugins/save-calendar/ical-format.c index a007811708..10f71f1507 100644 --- a/plugins/save-calendar/ical-format.c +++ b/plugins/save-calendar/ical-format.c @@ -36,7 +36,10 @@ display_error_message (GtkWidget *parent, { GtkWidget *dialog; - dialog = gtk_message_dialog_new (GTK_WINDOW (parent), 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message); + dialog = gtk_message_dialog_new ( + GTK_WINDOW (parent), 0, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + "%s", message); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } @@ -61,8 +64,13 @@ insert_tz_comps (icalparameter *param, if (g_hash_table_lookup (tdata->zones, tzid)) return; - if (!e_cal_client_get_timezone_sync (tdata->client, tzid, &zone, NULL, &error)) { - g_warning ("Could not get the timezone information for %s : %s \n", tzid, error->message); + e_cal_client_get_timezone_sync ( + tdata->client, tzid, &zone, NULL, &error); + + if (error != NULL) { + g_warning ( + "Could not get the timezone information for %s: %s", + tzid, error->message); g_error_free (error); return; } @@ -105,7 +113,7 @@ do_save_calendar_ical (FormatHandler *handler, ((source_client != NULL) && (error == NULL)) || ((source_client == NULL) && (error != NULL))); - if (source_client == NULL) { + if (error != NULL) { display_error_message ( gtk_widget_get_toplevel (GTK_WIDGET (selector)), error->message); @@ -116,8 +124,10 @@ do_save_calendar_ical (FormatHandler *handler, /* create destination file */ top_level = e_cal_util_new_top_level (); - error = NULL; - if (e_cal_client_get_object_list_sync (E_CAL_CLIENT (source_client), "#t", &objects, NULL, &error)) { + e_cal_client_get_object_list_sync ( + E_CAL_CLIENT (source_client), "#t", &objects, NULL, &error); + + if (objects != NULL) { CompTzData tdata; GOutputStream *stream; GSList *iter; @@ -153,8 +163,10 @@ do_save_calendar_ical (FormatHandler *handler, e_cal_client_free_icalcomp_slist (objects); } - if (error) { - display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), error->message); + if (error != NULL) { + display_error_message ( + gtk_widget_get_toplevel (GTK_WIDGET (selector)), + error->message); g_error_free (error); } @@ -163,7 +175,8 @@ do_save_calendar_ical (FormatHandler *handler, icalcomponent_free (top_level); } -FormatHandler *ical_format_handler_new (void) +FormatHandler * +ical_format_handler_new (void) { FormatHandler *handler = g_new (FormatHandler, 1); diff --git a/plugins/save-calendar/rdf-format.c b/plugins/save-calendar/rdf-format.c index 391f60cfa7..c261083986 100644 --- a/plugins/save-calendar/rdf-format.c +++ b/plugins/save-calendar/rdf-format.c @@ -368,17 +368,16 @@ do_save_calendar_rdf (FormatHandler *handler, g_object_unref (source_client); - if (error) { + if (error != NULL) { display_error_message ( gtk_widget_get_toplevel (GTK_WIDGET (selector)), error->message); g_error_free (error); } - - return; } -FormatHandler *rdf_format_handler_new (void) +FormatHandler * +rdf_format_handler_new (void) { FormatHandler *handler = g_new (FormatHandler, 1); diff --git a/shell/e-convert-local-mail.c b/shell/e-convert-local-mail.c index f7e9ac3eea..81c9e04771 100644 --- a/shell/e-convert-local-mail.c +++ b/shell/e-convert-local-mail.c @@ -108,7 +108,8 @@ copy_folders (CamelStore *mail_store, gchar *maildir_folder_name; /* sanitize folder names and copy folders */ - maildir_folder_name = sanitize_maildir_folder_name (fi->full_name); + maildir_folder_name = + sanitize_maildir_folder_name (fi->full_name); copy_folder ( mail_store, maildir_store, fi->full_name, maildir_folder_name); diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c index a60a634942..53841e526b 100644 --- a/shell/e-shell-content.c +++ b/shell/e-shell-content.c @@ -305,7 +305,9 @@ shell_content_size_allocate (GtkWidget *widget, child_allocation.y += child_requisition.height; if (gtk_widget_get_visible (child)) - gtk_widget_get_preferred_height_for_width (child, child_allocation.width, &child_requisition.height, NULL); + gtk_widget_get_preferred_height_for_width ( + child, child_allocation.width, + &child_requisition.height, NULL); else child_requisition.height = 0; diff --git a/shell/e-shell-switcher.c b/shell/e-shell-switcher.c index 84adfe6d11..1a7b283b95 100644 --- a/shell/e-shell-switcher.c +++ b/shell/e-shell-switcher.c @@ -168,7 +168,8 @@ shell_switcher_layout_actions (EShellSwitcher *switcher) child_allocation.width = max_width + extra_width; child_allocation.height = max_height; - gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation); + gtk_widget_size_allocate ( + GTK_WIDGET (p->data), &child_allocation); x += child_allocation.width + H_PADDING; } diff --git a/shell/e-shell-utils.c b/shell/e-shell-utils.c index 655f785ba0..97982cfbf9 100644 --- a/shell/e-shell-utils.c +++ b/shell/e-shell-utils.c @@ -168,11 +168,14 @@ e_shell_run_save_dialog (EShell *shell, gtk_file_filter_add_pattern (filter, flt); if (g_ascii_strcasecmp (flt, "*.mbox") == 0) - gtk_file_filter_set_name (filter, _("Berkeley Mailbox (mbox)")); + gtk_file_filter_set_name ( + filter, _("Berkeley Mailbox (mbox)")); else if (g_ascii_strcasecmp (flt, "*.vcf") == 0) - gtk_file_filter_set_name (filter, _("vCard (.vcf)")); + gtk_file_filter_set_name ( + filter, _("vCard (.vcf)")); else if (g_ascii_strcasecmp (flt, "*.ics") == 0) - gtk_file_filter_set_name (filter, _("iCalendar (.ics)")); + gtk_file_filter_set_name ( + filter, _("iCalendar (.ics)")); while (delim) { delim++; diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index e5ba407d7b..b7813eacc6 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -1869,7 +1869,8 @@ e_shell_view_update_actions_in_idle (EShellView *shell_view) return; if (shell_view->priv->update_actions_idle_id == 0) - shell_view->priv->update_actions_idle_id = g_idle_add (shell_view_call_update_actions_idle, shell_view); + shell_view->priv->update_actions_idle_id = g_idle_add ( + shell_view_call_update_actions_idle, shell_view); } /** diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c index 38645d2cdf..5fdca5fc1c 100644 --- a/smime/gui/certificate-manager.c +++ b/smime/gui/certificate-manager.c @@ -321,7 +321,7 @@ report_and_free_error (CertPage *cp, GTK_MESSAGE_ERROR, "%s: %s", where, error ? error->message : _("Unknown error")); - if (error) + if (error != NULL) g_error_free (error); } |