[folks] Add URLable interface for contacts with associated websites
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Add URLable interface for contacts with associated websites
- Date: Wed, 2 Feb 2011 02:00:43 +0000 (UTC)
commit 4b82bef6acfeedac468ce08733e222cd0ddaa078
Author: Travis Reitter <travis reitter collabora co uk>
Date: Tue Jan 18 13:30:33 2011 -0800
Add URLable interface for contacts with associated websites
folks/Makefile.am | 1 +
folks/individual.vala | 38 +++++++++++++++++++++++++++++++++++++-
folks/urlable.vala | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/folks/Makefile.am b/folks/Makefile.am
index 181d4f7..412e94b 100644
--- a/folks/Makefile.am
+++ b/folks/Makefile.am
@@ -28,6 +28,7 @@ libfolks_la_SOURCES = \
persona.vala \
persona-store.vala \
types.vala \
+ urlable.vala \
debug.vala \
$(NULL)
diff --git a/folks/individual.vala b/folks/individual.vala
index 182deb8..932f89f 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -69,7 +69,8 @@ public class Folks.Individual : Object,
AvatarOwner,
PresenceOwner,
IMable,
- NameOwner
+ NameOwner,
+ URLable
{
private bool _is_favourite;
private string _alias;
@@ -350,6 +351,11 @@ public class Folks.Individual : Object,
this._update_groups ();
}
+ private void _notify_urls_cb ()
+ {
+ this._update_urls ();
+ }
+
/**
* Add or remove the Individual from the specified group.
*
@@ -481,6 +487,7 @@ public class Folks.Individual : Object,
this._update_structured_name ();
this._update_full_name ();
this._update_nickname ();
+ this._update_urls ();
}
private void _update_groups ()
@@ -757,6 +764,7 @@ public class Folks.Individual : Object,
this._notify_structured_name_cb);
persona.notify["full-name"].connect (this._notify_full_name_cb);
persona.notify["nickname"].connect (this._notify_nickname_cb);
+ persona.notify["urls"].connect (this._notify_urls_cb);
if (persona is Groupable)
{
@@ -840,6 +848,7 @@ public class Folks.Individual : Object,
this._notify_structured_name_cb);
persona.notify["full-name"].disconnect (this._notify_full_name_cb);
persona.notify["nickname"].disconnect (this._notify_nickname_cb);
+ persona.notify["urls"].disconnect (this._notify_urls_cb);
if (persona is Groupable)
{
@@ -848,6 +857,33 @@ public class Folks.Individual : Object,
}
}
+ private void _update_urls ()
+ {
+ /* Populate the URLs as the union of our Personas' URLs.
+ * If the same URL exist multiple times we merge the parameters. */
+ var urls_set = new HashTable<unowned string, unowned FieldDetails> (
+ str_hash, str_equal);
+ foreach (var persona in this._persona_list)
+ {
+ var urlable = persona as URLable;
+ if (urlable != null)
+ {
+ foreach (unowned FieldDetails ps in urlable.urls)
+ {
+ var existing = urls_set.lookup (ps.value);
+ if (existing != null)
+ existing.extend_parameters (ps.parameters);
+ else
+ urls_set.insert (ps.value, ps);
+ }
+ }
+ }
+ /* Set the private member directly to avoid iterating this list again */
+ this._urls = urls_set.get_values ();
+
+ this.notify_property ("urls");
+ }
+
private void _set_personas (GLib.List<Persona>? persona_list,
Individual? replacement_individual)
{
diff --git a/folks/urlable.vala b/folks/urlable.vala
new file mode 100644
index 0000000..cba5c6c
--- /dev/null
+++ b/folks/urlable.vala
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 Collabora Ltd.
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Marco Barisione <marco barisione collabora co uk>
+ * Travis Reitter <travis reitter collabora co uk>
+ */
+
+using GLib;
+
+/**
+ * Associates a list of URLs with a contact.
+ *
+ * @since 0.3.UNRELEASED
+ */
+public interface Folks.URLable : Object
+{
+ /**
+ * The websites of the contact.
+ *
+ * A list or websites associated to the contact.
+ *
+ * @since 0.3.UNRELEASED
+ */
+ public abstract List<FieldDetails> urls { get; set; }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]