Commit ae9db3ed authored by Matthew Barnes's avatar Matthew Barnes Committed by Rodrigo Moya
Browse files

Coding style and whitespace cleanup.

parent db969c7f
......@@ -121,44 +121,51 @@ quick_add_set_vcard (QuickAdd *qa, const gchar *vcard)
}
static void
merge_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
merge_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
ESource *source = E_SOURCE (source_object);
QuickAdd *qa = user_data;
EClient *client = NULL;
GError *error = NULL;
if (!e_client_utils_open_new_finish (source, result, &client, &error))
client = NULL;
e_client_utils_open_new_finish (source, result, &client, &error);
/* 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)) {
g_warn_if_fail (client == NULL);
g_error_free (error);
return;
}
if (!error) {
if (!e_client_is_readonly (client))
eab_merging_book_add_contact (E_BOOK_CLIENT (client), qa->contact, NULL, NULL);
else
e_alert_run_dialog_for_args (e_shell_get_active_window (NULL),
"addressbook:error-read-only",
e_source_peek_name (e_client_get_source (client)),
NULL);
if (qa->cb)
qa->cb (qa->contact, qa->closure);
g_object_unref (client);
} else {
/* Something went wrong. */
if (client)
g_object_unref (client);
if (error != NULL) {
g_warn_if_fail (client == NULL);
if (qa->cb)
qa->cb (NULL, qa->closure);
g_error_free (error);
quick_add_unref (qa);
return;
}
g_return_if_fail (E_IS_CLIENT (client));
if (!e_client_is_readonly (client))
eab_merging_book_add_contact (
E_BOOK_CLIENT (client), qa->contact, NULL, NULL);
else
e_alert_run_dialog_for_args (
e_shell_get_active_window (NULL),
"addressbook:error-read-only",
e_source_peek_name (source),
NULL);
if (qa->cb)
qa->cb (qa->contact, qa->closure);
g_object_unref (client);
quick_add_unref (qa);
}
......@@ -172,7 +179,9 @@ quick_add_merge_contact (QuickAdd *qa)
qa->cancellable = g_cancellable_new ();
e_client_utils_open_new (qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, qa->cancellable,
e_client_utils_open_new (
qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS,
FALSE, qa->cancellable,
e_client_utils_authenticate_handler, NULL,
merge_cb, qa);
}
......@@ -186,10 +195,11 @@ contact_added_cb (EContactEditor *ce,
EContact *contact,
gpointer closure)
{
QuickAdd *qa = (QuickAdd *) g_object_get_data (G_OBJECT (ce), "quick_add");
QuickAdd *qa;
if (qa) {
qa = g_object_get_data (G_OBJECT (ce), "quick_add");
if (qa) {
if (qa->cb)
qa->cb (qa->contact, qa->closure);
......@@ -199,9 +209,12 @@ contact_added_cb (EContactEditor *ce,
}
static void
editor_closed_cb (GtkWidget *w, gpointer closure)
editor_closed_cb (GtkWidget *w,
gpointer closure)
{
QuickAdd *qa = (QuickAdd *) g_object_get_data (G_OBJECT (w), "quick_add");
QuickAdd *qa;
qa = g_object_get_data (G_OBJECT (w), "quick_add");
if (qa)
/* We don't need to unref qa because we set_data_full below */
......@@ -252,46 +265,51 @@ ce_have_contact (EBookClient *book_client,
G_OBJECT (contact_editor), "quick_add", qa,
(GDestroyNotify) quick_add_unref);
g_signal_connect (contact_editor,
"contact_added",
G_CALLBACK (contact_added_cb),
NULL);
g_signal_connect (contact_editor,
"editor_closed",
G_CALLBACK (editor_closed_cb),
NULL);
g_signal_connect (
contact_editor, "contact_added",
G_CALLBACK (contact_added_cb), NULL);
g_signal_connect (
contact_editor, "editor_closed",
G_CALLBACK (editor_closed_cb), NULL);
g_object_unref (book_client);
}
}
static void
ce_have_book (GObject *source_object, GAsyncResult *result, gpointer user_data)
ce_have_book (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
ESource *source = E_SOURCE (source_object);
QuickAdd *qa = user_data;
EClient *client = NULL;
GError *error = NULL;
if (!e_client_utils_open_new_finish (source, result, &client, &error))
client = NULL;
e_client_utils_open_new_finish (source, result, &client, &error);
/* 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)) {
g_warn_if_fail (client == NULL);
g_error_free (error);
return;
}
if (error) {
if (client)
g_object_unref (client);
g_warning ("Couldn't open local address book (%s).", error->message);
if (error != NULL) {
g_warn_if_fail (client == NULL);
g_warning (
"Couldn't open local address book (%s).",
error->message);
quick_add_unref (qa);
g_error_free (error);
} else {
eab_merging_book_find_contact (E_BOOK_CLIENT (client), qa->contact, ce_have_contact, qa);
return;
}
g_return_if_fail (E_IS_CLIENT (client));
eab_merging_book_find_contact (
E_BOOK_CLIENT (client), qa->contact, ce_have_contact, qa);
}
static void
......@@ -304,7 +322,9 @@ edit_contact (QuickAdd *qa)
qa->cancellable = g_cancellable_new ();
e_client_utils_open_new (qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, qa->cancellable,
e_client_utils_open_new (
qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS,
FALSE, qa->cancellable,
e_client_utils_authenticate_handler, NULL,
ce_have_book, qa);
}
......
......@@ -187,7 +187,7 @@ contact_list_editor_notify_cb (EContactListEditor *editor,
static gboolean
contact_list_editor_add_destination (GtkWidget *widget,
EDestination *dest)
EDestination *dest)
{
EContactListEditor *editor = contact_list_editor_extract (widget);
EContactListModel *model = E_CONTACT_LIST_MODEL (editor->priv->model);
......@@ -200,20 +200,26 @@ contact_list_editor_add_destination (GtkWidget *widget,
const gchar *name = e_destination_get_name (dest);
if (e_contact_list_model_has_uid (model, id)) {
if (e_alert_run_dialog_for_args (GTK_WINDOW (WIDGET (DIALOG)),
"addressbook:ask-list-add-list-exists", name, NULL) != GTK_RESPONSE_YES)
gint response;
response = e_alert_run_dialog_for_args (
GTK_WINDOW (WIDGET (DIALOG)),
"addressbook:ask-list-add-list-exists",
name, NULL);
if (response != GTK_RESPONSE_YES)
return FALSE;
} else {
const GList *l_dests, *l_dest;
gint reply;
/* Check the new list mail-by-mail for conflicts and eventually ask user what to do
with all conflicts */
/* Check the new list mail-by-mail for conflicts and
* eventually ask user what to do with all conflicts. */
l_dests = e_destination_list_get_dests (dest);
for (l_dest = l_dests; l_dest; l_dest = l_dest->next) {
if (e_contact_list_model_has_email (model, e_destination_get_email (l_dest->data))) {
reply = e_alert_run_dialog_for_args (GTK_WINDOW (WIDGET (DIALOG)),
"addressbook:ask-list-add-some-mails-exist", NULL);
reply = e_alert_run_dialog_for_args (
GTK_WINDOW (WIDGET (DIALOG)),
"addressbook:ask-list-add-some-mails-exist", NULL);
if (reply == GTK_RESPONSE_YES) {
ignore_conflicts = TRUE;
break;
......@@ -237,7 +243,8 @@ contact_list_editor_add_destination (GtkWidget *widget,
}
/* always add to the root level */
path = e_contact_list_model_add_destination (model, dest, NULL, ignore_conflicts);
path = e_contact_list_model_add_destination (
model, dest, NULL, ignore_conflicts);
if (path) {
contact_list_editor_scroll_to_end (editor);
gtk_tree_view_expand_to_path (treeview, path);
......@@ -268,7 +275,8 @@ contact_list_editor_add_email (EContactListEditor *editor,
}
g_object_unref (addr);
priv->changed = contact_list_editor_add_destination (WIDGET (DIALOG), dest) || priv->changed;
priv->changed = contact_list_editor_add_destination (
WIDGET (DIALOG), dest) || priv->changed;
contact_list_editor_update (editor);
}
......@@ -292,6 +300,8 @@ contact_list_editor_book_loaded_cb (GObject *source_object,
if (error != NULL) {
GtkWindow *parent;
g_warn_if_fail (client == NULL);
parent = eab_editor_get_window (EAB_EDITOR (editor));
eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error);
......@@ -303,15 +313,16 @@ contact_list_editor_book_loaded_cb (GObject *source_object,
goto exit;
}
g_return_if_fail (E_IS_CLIENT (client));
book_client = E_BOOK_CLIENT (client);
g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
entry = E_NAME_SELECTOR_ENTRY (WIDGET (EMAIL_ENTRY));
contact_store = e_name_selector_entry_peek_contact_store (entry);
e_contact_store_add_client (contact_store, book_client);
e_contact_list_editor_set_client (editor, book_client);
g_object_unref (book_client);
g_object_unref (client);
exit:
g_object_unref (editor);
......@@ -905,9 +916,12 @@ contact_list_editor_source_menu_changed_cb (GtkWidget *widget)
if (e_source_equal (e_client_get_source (E_CLIENT (editor->priv->book_client)), source))
return;
e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
e_client_utils_authenticate_handler, eab_editor_get_window (EAB_EDITOR (editor)),
contact_list_editor_book_loaded_cb, g_object_ref (editor));
e_client_utils_open_new (
source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
e_client_utils_authenticate_handler,
eab_editor_get_window (EAB_EDITOR (editor)),
contact_list_editor_book_loaded_cb,
g_object_ref (editor));
}
gboolean
......@@ -1148,7 +1162,9 @@ setup_custom_widgets (EContactListEditor *editor)
g_object_unref (source_list);
if (error) {
g_debug ("%s: Failed to get sources: %s", G_STRFUNC, error->message);
g_warning (
"%s: Failed to get sources: %s",
G_STRFUNC, error->message);
g_error_free (error);
}
......@@ -1650,7 +1666,7 @@ e_contact_list_editor_get_client (EContactListEditor *editor)
void
e_contact_list_editor_set_client (EContactListEditor *editor,
EBookClient *book_client)
EBookClient *book_client)
{
g_return_if_fail (E_IS_CONTACT_LIST_EDITOR (editor));
g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
......@@ -1659,7 +1675,8 @@ e_contact_list_editor_set_client (EContactListEditor *editor,
g_object_unref (editor->priv->book_client);
editor->priv->book_client = g_object_ref (book_client);
editor->priv->allows_contact_lists = e_client_check_capability (E_CLIENT (editor->priv->book_client), "contact-lists");
editor->priv->allows_contact_lists = e_client_check_capability (
E_CLIENT (editor->priv->book_client), "contact-lists");
contact_list_editor_update (editor);
......@@ -1667,7 +1684,10 @@ e_contact_list_editor_set_client (EContactListEditor *editor,
}
static void
save_contact_list (GtkTreeModel *model, GtkTreeIter *iter, GSList **attrs, gint *parent_id)
save_contact_list (GtkTreeModel *model,
GtkTreeIter *iter,
GSList **attrs,
gint *parent_id)
{
EDestination *dest;
EVCardAttribute *attr;
......@@ -1704,7 +1724,6 @@ save_contact_list (GtkTreeModel *model, GtkTreeIter *iter, GSList **attrs, gint
e_vcard_attribute_add_param_with_value (attr,
e_vcard_attribute_param_new (EVC_PARENT_CL), pid_str);
*attrs = g_slist_prepend (*attrs, attr);
g_object_unref (dest);
......@@ -1788,8 +1807,10 @@ e_contact_list_editor_set_contact (EContactListEditor *editor,
/* The root destination */
EDestination *list_dest = e_destination_new ();
file_as = e_contact_get_const (priv->contact, E_CONTACT_FILE_AS);
show_addresses = GPOINTER_TO_INT (e_contact_get (priv->contact, E_CONTACT_LIST_SHOW_ADDRESSES));
file_as = e_contact_get_const (
priv->contact, E_CONTACT_FILE_AS);
show_addresses = GPOINTER_TO_INT (e_contact_get (
priv->contact, E_CONTACT_LIST_SHOW_ADDRESSES));
if (file_as == NULL)
file_as = "";
......@@ -1810,7 +1831,9 @@ e_contact_list_editor_set_contact (EContactListEditor *editor,
dests = e_destination_list_get_root_dests (list_dest);
for (dest = dests; dest; dest = dest->next) {
GtkTreePath *path;
path = e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (priv->model), dest->data, NULL, TRUE);
path = e_contact_list_model_add_destination (
E_CONTACT_LIST_MODEL (priv->model),
dest->data, NULL, TRUE);
gtk_tree_path_free (path);
}
......
......@@ -132,7 +132,7 @@ e_contact_list_model_has_email (EContactListModel *model,
gboolean
e_contact_list_model_has_uid (EContactListModel *model,
const gchar* uid)
const gchar *uid)
{
return (g_hash_table_lookup (model->priv->uids_table, uid) != NULL);
}
......
......@@ -573,7 +573,9 @@ match_search_info_free (MatchSearchInfo *info)
}
static void
query_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
query_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
MatchSearchInfo *info = (MatchSearchInfo *) user_data;
EABContactMatchType best_match = EAB_CONTACT_MATCH_NONE;
......@@ -584,12 +586,21 @@ query_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
GError *error = NULL;
const GSList *ii;
if (result && !e_book_client_get_contacts_finish (book_client, result, &contacts, &error)) {
g_debug ("%s: Failed to get contacts: %s\n", G_STRFUNC, error ? error->message : "Unknown error");
if (error)
g_error_free (error);
if (result != NULL)
e_book_client_get_contacts_finish (
book_client, result, &contacts, &error);
if (error != NULL) {
g_warning (
"%s: Failed to get contacts: %s\n",
G_STRFUNC, error->message);
g_error_free (error);
info->cb (
info->contact, NULL,
EAB_CONTACT_MATCH_NONE,
info->closure);
info->cb (info->contact, NULL, EAB_CONTACT_MATCH_NONE, info->closure);
match_search_info_free (info);
g_object_unref (book_client);
return;
......@@ -751,10 +762,10 @@ book_loaded_cb (GObject *source_object,
MatchSearchInfo *info = user_data;
EClient *client = NULL;
if (!e_client_utils_open_new_finish (source, result, &client, NULL))
client = NULL;
e_client_utils_open_new_finish (source, result, &client, NULL);
use_common_book_client (client ? E_BOOK_CLIENT (client): NULL, info);
/* Client may be NULL; don't use a type cast macro. */
use_common_book_client ((EBookClient *) client, info);
}
void
......
......@@ -96,7 +96,9 @@ finished_lookup (void)
merging_queue = g_list_remove_link (merging_queue, merging_queue);
running_merge_requests++;
eab_contact_locate_match_full (lookup->book_client, lookup->contact, lookup->avoid, match_query_callback, lookup);
eab_contact_locate_match_full (
lookup->book_client, lookup->contact,
lookup->avoid, match_query_callback, lookup);
}
}
......@@ -112,7 +114,10 @@ free_lookup (EContactMergingLookup *lookup)
}
static void
final_id_cb (EBookClient *book_client, const GError *error, const gchar *id, gpointer closure)
final_id_cb (EBookClient *book_client,
const GError *error,
const gchar *id,
gpointer closure)
{
EContactMergingLookup *lookup = closure;
......@@ -125,12 +130,19 @@ final_id_cb (EBookClient *book_client, const GError *error, const gchar *id, gpo
}
static void
final_cb_as_id (EBookClient *book_client, const GError *error, gpointer closure)
final_cb_as_id (EBookClient *book_client,
const GError *error,
gpointer closure)
{
EContactMergingLookup *lookup = closure;
if (lookup->id_cb)
lookup->id_cb (lookup->book_client, error, lookup->contact ? e_contact_get_const (lookup->contact, E_CONTACT_UID) : NULL, lookup->closure);
lookup->id_cb (
lookup->book_client, error,
lookup->contact ?
e_contact_get_const (
lookup->contact, E_CONTACT_UID) : NULL,
lookup->closure);
free_lookup (lookup);
......@@ -138,7 +150,9 @@ final_cb_as_id (EBookClient *book_client, const GError *error, gpointer closure)
}
static void
final_cb (EBookClient *book_client, const GError *error, gpointer closure)
final_cb (EBookClient *book_client,
const GError *error,
gpointer closure)
{
EContactMergingLookup *lookup = closure;
......@@ -151,7 +165,9 @@ final_cb (EBookClient *book_client, const GError *error, gpointer closure)
}
static void
modify_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
modify_contact_ready_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
EBookClient *book_client = E_BOOK_CLIENT (source_object);
EContactMergingLookup *lookup = user_data;
......@@ -172,7 +188,9 @@ modify_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer
}
static void
add_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
add_contact_ready_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
EBookClient *book_client = E_BOOK_CLIENT (source_object);
EContactMergingLookup *lookup = user_data;
......@@ -251,7 +269,9 @@ dropdown_changed (GtkWidget *dropdown, dropdown_data *data)
}
static void
remove_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
remove_contact_ready_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
EBookClient *book_client = E_BOOK_CLIENT (source_object);
EContactMergingLookup *lookup = user_data;
......@@ -262,12 +282,16 @@ remove_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer
e_book_client_remove_contact_finish (book_client, result, &error);
if (error) {
g_debug ("%s: Failed to remove contact: %s", G_STRFUNC, error->message);
if (error != NULL) {
g_warning (
"%s: Failed to remove contact: %s",
G_STRFUNC, error->message);
g_error_free (error);
}
e_book_client_add_contact (book_client, lookup->contact, NULL, add_contact_ready_cb, lookup);
e_book_client_add_contact (
book_client, lookup->contact, NULL,
add_contact_ready_cb, lookup);
}
static gint
......
......@@ -130,8 +130,11 @@ remove_book_view (EAddressbookModel *model)
GError *error = NULL;
e_book_client_view_stop (model->priv->client_view, &error);
if (error) {
g_debug ("%s: Failed to stop client view: %s", G_STRFUNC, error->message);
if (error != NULL) {
g_warning (
"%s: Failed to stop client view: %s",
G_STRFUNC, error->message);
g_error_free (error);
}
......@@ -166,7 +169,9 @@ update_folder_bar_message (EAddressbookModel *model)
}
static void
view_create_contact_cb (EBookClientView *client_view, const GSList *contact_list, EAddressbookModel *model)
view_create_contact_cb (EBookClientView *client_view,
const GSList *contact_list,
EAddressbookModel *model)
{
GPtrArray *array;
guint count;
......@@ -198,7 +203,9 @@ sort_descending (gconstpointer ca,
}
static void
view_remove_contact_cb (EBookClientView *client_view, const GSList *ids, EAddressbookModel *model)
view_remove_contact_cb (EBookClientView *client_view,
const GSList *ids,
EAddressbookModel *model)
{
/* XXX we should keep a hash around instead of this O(n*m) loop */
const GSList *iter;
......@@ -252,7 +259,9 @@ view_remove_contact_cb (EBookClientView *client_view, const GSList *ids, EAddres
}
static void
view_modify_contact_cb (EBookClientView *client_view, const GSList *contact_list, EAddressbookModel *model)
view_modify_contact_cb (EBookClientView *client_view,
const GSList *contact_list,
EAddressbookModel *model)
{
GPtrArray *array;
......@@ -291,7 +300,10 @@ view_modify_contact_cb (EBookClientView *client_view, const GSList *contact_list
}
static void
view_progress_cb (EBookClientView *client_view, guint percent, const gchar *message, EAddressbookModel *model)
view_progress_cb (EBookClientView *client_view,
guint percent,
const gchar *message,
EAddressbookModel *model)
{
if (model->priv->remove_status_id)
g_source_remove (model->priv->remove_status_id);
......@@ -301,7 +313,9 @@ view_progress_cb (EBookClientView *client_view, guint percent, const gchar *mess
}
static void
view_complete_cb (EBookClientView *client_view, const GError *error, EAddressbookModel *model)
view_complete_cb (EBookClientView *client_view,
const GError *error,
EAddressbookModel *model)
{
model->priv->search_in_progress = FALSE;
view_progress_cb (client_view, -1, NULL, model);
......@@ -310,23 +324,30 @@ view_complete_cb (EBookClientView *client_view, const GError *error, EAddressboo
}