aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-03-10 19:20:16 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-05-18 10:43:02 +0800
commita389d921d384916612835142d90300fb1365aba9 (patch)
tree440c2dff4a6aef94c14af965e7320e20b6cd8b26
parentdf30bb0dc150ced91aaf8dc992a11e7718d56c40 (diff)
downloadgsoc2013-empathy-a389d921d384916612835142d90300fb1365aba9.tar
gsoc2013-empathy-a389d921d384916612835142d90300fb1365aba9.tar.gz
gsoc2013-empathy-a389d921d384916612835142d90300fb1365aba9.tar.bz2
gsoc2013-empathy-a389d921d384916612835142d90300fb1365aba9.tar.lz
gsoc2013-empathy-a389d921d384916612835142d90300fb1365aba9.tar.xz
gsoc2013-empathy-a389d921d384916612835142d90300fb1365aba9.tar.zst
gsoc2013-empathy-a389d921d384916612835142d90300fb1365aba9.zip
Update our local fields having Overwritten_By_Nickname when updating our nickname (#644298)
-rw-r--r--libempathy-gtk/empathy-contact-widget.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 2081db663..4efa9a0da 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -1079,6 +1079,46 @@ set_nickname_cb (GObject *source,
}
}
+/* Update all the contact info fields having the
+* Overwritten_By_Nickname flag to the new alias. This avoid accidentally
+* reseting the alias when calling SetContactInfo(). See bgo #644298 for
+* details. */
+static void
+update_nickname_in_contact_info (EmpathyContactWidget *self,
+ TpConnection *connection,
+ const gchar *nickname)
+{
+ GList *specs, *l;
+
+ specs = tp_connection_get_contact_info_supported_fields (connection);
+
+ for (l = self->details_to_set; l != NULL; l= g_list_next (l))
+ {
+ TpContactInfoField *field = l->data;
+ TpContactInfoFieldSpec *spec;
+
+ spec = get_spec_from_list (specs, field->field_name);
+ /* We shouldn't have added the field to details_to_set if it's not
+ * supported by the CM */
+ g_assert (spec != NULL);
+
+ if (spec->flags & TP_CONTACT_INFO_FIELD_FLAG_OVERWRITTEN_BY_NICKNAME)
+ {
+ const gchar *strv[] = { nickname, NULL };
+
+ DEBUG ("Updating field '%s' to '%s' as it has the "
+ "Overwritten_By_Nickname flag and Account.Nickname has "
+ "been updated", field->field_name, nickname);
+
+ if (field->field_value != NULL)
+ g_strfreev (field->field_value);
+ field->field_value = g_strdupv ((GStrv) strv);
+ }
+ }
+
+ g_list_free (specs);
+}
+
static gboolean
contact_widget_entry_alias_focus_event_cb (GtkEditable *editable,
GdkEventFocus *event,
@@ -1104,6 +1144,9 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable *editable,
tp_account_set_nickname_async (account, alias, set_nickname_cb,
NULL);
+
+ update_nickname_in_contact_info (information,
+ empathy_contact_get_connection (information->contact), alias);
}
}
else