PresenceOwner,
IMable,
NameOwner,
+ Phoneable,
URLable
{
private bool _is_favourite;
}
}
- private GLib.List<FieldDetails> _email_addresses;
- /**
- * {@inheritDoc}
- */
- public GLib.List<FieldDetails> email_addresses
- {
- get { return this._email_addresses; }
- private set
- {
- this._email_addresses = new GLib.List<FieldDetails> ();
- foreach (unowned FieldDetails fd in value)
- this._email_addresses.prepend (fd);
- this._email_addresses.reverse ();
- }
- }
-
/**
* Whether this Individual is a user-defined favourite.
*
this._update_urls ();
}
+ private void _notify_phone_numbers_cb ()
+ {
+ this._update_phone_numbers ();
+ }
+
/**
* Add or remove the Individual from the specified group.
*
this._update_nickname ();
this._update_gender ();
this._update_urls ();
+ this._update_phone_numbers ();
}
private void _update_groups ()
persona.notify["nickname"].connect (this._notify_nickname_cb);
persona.notify["gender"].connect (this._notify_gender_cb);
persona.notify["urls"].connect (this._notify_urls_cb);
+ persona.notify["phone-numbers"].connect (this._notify_phone_numbers_cb);
if (persona is Groupable)
{
persona.notify["nickname"].disconnect (this._notify_nickname_cb);
persona.notify["gender"].disconnect (this._notify_gender_cb);
persona.notify["urls"].disconnect (this._notify_urls_cb);
+ persona.notify["phone-numbers"].disconnect (
+ this._notify_phone_numbers_cb);
if (persona is Groupable)
{
this.notify_property ("urls");
}
+ private void _update_phone_numbers ()
+ {
+ /* Populate the phone numberss as the union of our Personas' numbers
+ * If the same number exist multiple times we merge the parameters. */
+ /* FIXME: We should handle phone numbers better, just string comparison
+ doesn't work. */
+ var phone_numbers_set =
+ new HashTable<unowned string, unowned FieldDetails> (
+ str_hash, str_equal);
+ foreach (var persona in this._persona_list)
+ {
+ var phoneable = persona as Phoneable;
+ if (phoneable != null)
+ {
+ foreach (unowned FieldDetails fd in phoneable.phone_numbers)
+ {
+ var existing = phone_numbers_set.lookup (fd.value);
+ if (existing != null)
+ existing.extend_parameters (fd.parameters);
+ else
+ phone_numbers_set.insert (fd.value, fd);
+ }
+ }
+ }
+ this._phone_numbers = phone_numbers_set.get_values ();
+
+ this.notify_property ("phone-numbers");
+ }
+
private void _set_personas (GLib.List<Persona>? persona_list,
Individual? replacement_individual)
{
--- /dev/null
+/*
+ * 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>
+ */
+
+using GLib;
+
+/**
+ * Interface for classes that can provide a phone number, such as
+ * {@link Persona} and {@link Individual}.
+ *
+ * @since 0.3.UNRELEASED
+ */
+public interface Folks.Phoneable : Object
+{
+ /**
+ * The phone numbers of the contact.
+ *
+ * A list of phone numbers associated to the contact.
+ *
+ * @since 0.3.UNRELEASED
+ */
+ public abstract List<FieldDetails> phone_numbers { get; set; }
+}