=?utf-8?q?=5Bfolks=5D_eds=3A_Hide_the_=E2=80=9CStarred_in_Android?= =?utf-8?q?=E2=80=9D_group_from_the_set_of_groups?=
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] eds: Hide the âStarred in Androidâ group from the set of groups
- Date: Sun, 22 Jul 2012 12:06:41 +0000 (UTC)
commit be282dda2e2913afce09d6140f405d96001c6d4b
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Jul 22 09:10:29 2012 +0100
eds: Hide the âStarred in Androidâ group from the set of groups
For Google address books, itâs used to determine whether a contact is a
favourite, so neednât be shown in the set of groups.
Note that this requires commit 161faab40fa65e813ac98042ef822298dc58cfde
from EDS in order to behave properly.
See: https://bugzilla.gnome.org/show_bug.cgi?id=661490
backends/eds/lib/edsf-persona-store.vala | 52 ++++++++------------
backends/eds/lib/edsf-persona.vala | 77 ++++++++++-------------------
2 files changed, 48 insertions(+), 81 deletions(-)
---
diff --git a/backends/eds/lib/edsf-persona-store.vala b/backends/eds/lib/edsf-persona-store.vala
index 557cc63..031e827 100644
--- a/backends/eds/lib/edsf-persona-store.vala
+++ b/backends/eds/lib/edsf-persona-store.vala
@@ -471,7 +471,7 @@ public class Edsf.PersonaStore : Folks.PersonaStore
PersonaDetail.IS_FAVOURITE))
{
bool is_fav = v.get_boolean ();
- yield this._set_contact_is_favourite (contact, is_fav);
+ this._set_contact_is_favourite (contact, is_fav);
}
}
@@ -1518,29 +1518,14 @@ public class Edsf.PersonaStore : Folks.PersonaStore
_("The contact cannot be marked as favourite."));
}
- yield this._set_contact_is_favourite (persona.contact, is_favourite);
- yield this._commit_modified_property (persona, "is-favourite");
-
+ this._set_contact_is_favourite (persona.contact, is_favourite);
/* If this is a Google Contacts address book, change the user's membership
* of the âStarred in Androidâ group accordingly. See: bgo#661490. */
- if (this._is_google_contacts_address_book ())
- {
- try
- {
- yield persona.change_group (this.android_favourite_group_name,
- is_favourite);
- }
- catch (GLib.Error e1)
- {
- /* We know this will always be a PropertyError. */
- assert (e1 is PropertyError);
- throw (PropertyError) e1;
- }
- }
+ this._set_contact_groups (persona.contact, persona.groups, is_favourite);
+ yield this._commit_modified_property (persona, "is-favourite");
}
- private async void _set_contact_is_favourite (E.Contact contact,
- bool is_favourite)
+ private void _set_contact_is_favourite (E.Contact contact, bool is_favourite)
{
this._remove_attribute (contact, "X-FOLKS-FAVOURITE");
@@ -2016,20 +2001,12 @@ public class Edsf.PersonaStore : Folks.PersonaStore
_("Groups are not writeable on this contact."));
}
- yield this._set_contact_groups (persona.contact, groups);
+ this._set_contact_groups (persona.contact, groups, persona.is_favourite);
yield this._commit_modified_property (persona, "groups");
-
- /* If this is a Google Contacts address book and the user's changing
- * membership of the âStarred in Androidâ group, change our favourite
- * status accordingly. See: bgo#661490. */
- if (this._is_google_contacts_address_book ())
- {
- yield persona.change_is_favourite (
- this.android_favourite_group_name in groups);
- }
}
- private async void _set_contact_groups (E.Contact contact, Set<string> groups)
+ private void _set_contact_groups (E.Contact contact, Set<string> groups,
+ bool is_favourite)
{
var categories = new GLib.List<string> ();
@@ -2039,10 +2016,23 @@ public class Edsf.PersonaStore : Folks.PersonaStore
{
continue;
}
+ else if (this._is_google_contacts_address_book () &&
+ group == Edsf.PersonaStore.android_favourite_group_name)
+ {
+ continue;
+ }
categories.prepend (group);
}
+ /* If this is a Google address book, we must transparently add/remove the
+ * âStarred in Androidâ group to/from the group list, depending on our
+ * favourite status. */
+ if (is_favourite && this._is_google_contacts_address_book ())
+ {
+ categories.prepend (Edsf.PersonaStore.android_favourite_group_name);
+ }
+
contact.set (ContactField.CATEGORY_LIST, categories);
}
diff --git a/backends/eds/lib/edsf-persona.vala b/backends/eds/lib/edsf-persona.vala
index 58cd3c9..85c82c4 100644
--- a/backends/eds/lib/edsf-persona.vala
+++ b/backends/eds/lib/edsf-persona.vala
@@ -1498,6 +1498,14 @@ public class Edsf.Persona : Folks.Persona,
foreach (var category_name in category_names)
{
+ /* Skip the âStarred in Androidâ group for Google personas; we handle
+ * it later. */
+ if (((Edsf.PersonaStore) store)._is_google_contacts_address_book () &&
+ category_name == Edsf.PersonaStore.android_favourite_group_name)
+ {
+ continue;
+ }
+
new_categories.add (category_name);
/* Is this a new category? */
@@ -1512,6 +1520,14 @@ public class Edsf.Persona : Folks.Persona,
foreach (var category_name in this._groups)
{
+ /* Skip the âStarred in Androidâ group for Google personas; we handle
+ * it later. */
+ if (((Edsf.PersonaStore) store)._is_google_contacts_address_book () &&
+ category_name == Edsf.PersonaStore.android_favourite_group_name)
+ {
+ continue;
+ }
+
if (!new_categories.contains (category_name))
{
removed_categories.add (category_name);
@@ -1545,33 +1561,23 @@ public class Edsf.Persona : Folks.Persona,
}
}
+ /* Check whether our favourite status needs updating. */
var old_is_favourite = this._is_favourite;
- /* Make the changes to this._groups and emit signals. */
- foreach (var category_name in removed_categories)
+ if (store._is_google_contacts_address_book ())
{
- /* We link the âStarred in Androidâ group to Google Contacts address
- * books. See: bgo#661490. */
- if (store._is_google_contacts_address_book () &&
- category_name == Edsf.PersonaStore.android_favourite_group_name)
- {
- this._is_favourite = false;
- }
+ this._is_favourite = false;
- this.group_changed (category_name, false);
- this._groups.remove (category_name);
- }
-
- foreach (var category_name in added_categories)
- {
- if (store._is_google_contacts_address_book () &&
- category_name == Edsf.PersonaStore.android_favourite_group_name)
+ foreach (var category_name in category_names)
{
- this._is_favourite = true;
+ /* We link the âStarred in Androidâ group to Google Contacts
+ * address books. See: bgo#661490. */
+ if (category_name ==
+ Edsf.PersonaStore.android_favourite_group_name)
+ {
+ this._is_favourite = true;
+ }
}
-
- this._groups.add (category_name);
- this.group_changed (category_name, true);
}
/* Notify if anything's changed. */
@@ -1790,39 +1796,10 @@ public class Edsf.Persona : Folks.Persona,
}
}
- var store = (Edsf.PersonaStore) this.store;
-
- if (store._is_google_contacts_address_book ())
- {
- is_fav = is_fav ||
- (Edsf.PersonaStore.android_favourite_group_name in this._groups);
- }
-
if (is_fav != this._is_favourite)
{
this._is_favourite = is_fav;
-
- var groups_changed = false;
-
- if (store._is_google_contacts_address_book () &&
- !(Edsf.PersonaStore.android_favourite_group_name in this._groups))
- {
- this._groups.add (Edsf.PersonaStore.android_favourite_group_name);
- this.group_changed (
- Edsf.PersonaStore.android_favourite_group_name, true);
- groups_changed = true;
- }
-
- this.freeze_notify ();
-
- if (groups_changed == true)
- {
- this.notify_property ("groups");
- }
-
this.notify_property ("is-favourite");
-
- this.thaw_notify ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]