/backends/telepathy/tpf-persona.c
/backends/telepathy/tpf-persona-store.c
/folks/alias.c
+/folks/avatar.c
/folks/backend.c
/folks/backend-store.c
/folks/capabilities.c
using Tp;
using Folks;
-public class Tpf.Persona : Folks.Persona, Alias, Folks.Capabilities, Groups,
- Presence
+public class Tpf.Persona : Folks.Persona, Alias, Avatar, Folks.Capabilities,
+ Groups, Presence
{
private HashTable<string, bool> _groups;
/* interface Alias */
public override string alias { get; set; }
+ /* interface Avatar */
+ public override File avatar { get; set; }
+
/* interface Capabilities */
public override CapabilitiesFlags capabilities { get; private set; }
this._groups = new HashTable<string, bool> (str_hash, str_equal);
+ contact.notify["avatar-file"].connect ((s, p) =>
+ {
+ this.set_avatar_from_contact ();
+ });
+ this.set_avatar_from_contact ();
+
contact.notify["presence-message"].connect ((s, p) =>
{
this.contact_notify_presence_message ((Tp.Contact) s);
return PresenceType.UNKNOWN;
}
}
+
+ private void set_avatar_from_contact ()
+ {
+ var file = this.contact.get_avatar_file ();
+ if (this.avatar != file)
+ this.avatar = file;
+ }
}
m4_define([folks_major_version], [0])
m4_define([folks_minor_version], [1])
-m4_define([folks_micro_version], [1])
+m4_define([folks_micro_version], [2])
m4_define([folks_nano_version], [0])
dnl Display the nano_version only if it's not '0'
libfolks_la_VALASOURCES = \
alias.vala \
+ avatar.vala \
backend.vala \
backend-store.vala \
capabilities.vala \
--- /dev/null
+/*
+ * Copyright (C) 2010 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:
+ * Travis Reitter <travis.reitter@collabora.co.uk>
+ */
+
+using GLib;
+
+public interface Folks.Avatar : Object
+{
+ public abstract File avatar { get; set; }
+}
using Gee;
using GLib;
-using Folks.Alias;
-using Folks.Capabilities;
-using Folks.Groups;
-using Folks.PersonaStore;
-using Folks.Presence;
+using Folks;
-public class Folks.Individual : Object, Alias, Capabilities, Groups, Presence
+public class Folks.Individual : Object, Alias, Avatar, Capabilities, Groups,
+ Presence
{
private HashTable<string, bool> _groups;
private GLib.List<Persona> _personas;
/* XXX: should setting this push it down into the Persona (to foward along to
* the actual store if possible?) */
public string alias { get; set; }
+ public File avatar { get; set; }
public CapabilitiesFlags capabilities { get; private set; }
public string id { get; private set; }
public Folks.PresenceType presence_type { get; private set; }
var persona = (Persona) p;
var groups = (p is Groups) ? (Groups) p : null;
+ persona.notify["avatar"].disconnect (this.notify_avatar_cb);
persona.notify["presence-message"].disconnect (
this.notify_presence_cb);
persona.notify["presence-type"].disconnect (
var persona = (Persona) p;
var groups = (p is Groups) ? (Groups) p : null;
+ persona.notify["avatar"].connect (this.notify_avatar_cb);
persona.notify["presence-message"].connect (
this.notify_presence_cb);
persona.notify["presence-type"].connect (this.notify_presence_cb);
}
}
+ private void notify_avatar_cb (Object obj, ParamSpec ps)
+ {
+ this.update_avatar ();
+ }
+
private void persona_group_changed_cb (string group, bool is_member)
{
this.change_group (group, is_member);
this.update_groups ();
this.update_presence ();
+ this.update_avatar ();
}
private void update_groups ()
this.presence_type = presence_type;
}
+ private void update_avatar ()
+ {
+ File avatar = null;
+
+ this._personas.foreach ((p) =>
+ {
+ var persona = (Persona) p;
+
+ if (avatar == null)
+ {
+ avatar = persona.avatar;
+ return;
+ }
+ });
+
+ /* only notify if the value has changed */
+ if (this.avatar != avatar)
+ this.avatar = avatar;
+ }
+
public CapabilitiesFlags get_capabilities ()
{
return this.capabilities;
*/
using GLib;
-using Folks.Alias;
-using Folks.Capabilities;
-using Folks.PersonaStore;
-using Folks.Presence;
+using Folks;
-public abstract class Folks.Persona : Object, Alias, Capabilities, Presence
+public abstract class Folks.Persona : Object, Alias, Avatar, Capabilities,
+ Presence
{
/* interface Alias */
public abstract string alias { get; set; }
+ /* interface Avatar */
+ public abstract File avatar { get; set; }
+
/* interface Capabilities */
public abstract CapabilitiesFlags capabilities { get; set; }