update_presence_pixbuf (self, presence);
}
+
static void
-clean_state (ELHomeApplet *self)
+resolve_contact (ELHomeApplet *self)
+{
+ ELHomeAppletPrivate *priv = self->priv;
+ GList *contacts = NULL;
+
+ if (priv->contact_id) {
+ contacts = osso_abook_aggregator_lookup
+ (OSSO_ABOOK_AGGREGATOR (priv->aggregator),
+ priv->contact_id);
+ }
+ else if (priv->local_id && priv->remote_id) {
+ if (g_strcmp0 (priv->local_id, "ring/tel/ring" == 0)) {
+ contacts = osso_abook_aggregator_find_contacts_for_phone_number
+ (OSSO_ABOOK_AGGREGATOR (priv->aggregator),
+ priv->remote_id,
+ TRUE);
+ }
+ else {
+ McAccount *account;
+ account = osso_abook_account_manager_lookup_by_name
+ (NULL,
+ priv->local_id);
+ if (account) {
+ contacts = osso_abook_aggregator_find_contacts_for_im_contact
+ (OSSO_ABOOK_AGGREGATOR (priv->aggregator),
+ priv->remote_id,
+ account);
+ }
+ }
+ }
+
+ if (contacts && contacts->data) {
+ priv->contact = g_object_ref (OSSO_ABOOK_CONTACT (contacts->data));
+ gtk_label_set_text (GTK_LABEL (priv->sender),
+ osso_abook_contact_get_display_name (priv->contact));
+
+ priv->avatar_pixbuf = osso_abook_avatar_get_image_scaled
+ (OSSO_ABOOK_AVATAR (priv->contact),
+ HILDON_ICON_PIXEL_SIZE_THUMB,
+ HILDON_ICON_PIXEL_SIZE_THUMB,
+ TRUE);
+
+ g_warning ("HAVE avatar");
+ if (priv->avatar_pixbuf) {
+ gtk_widget_set_size_request (priv->sender,
+ C_WIDTH - AVATAR_SIZE - HILDON_MARGIN_DEFAULT,
+ HILDON_ICON_PIXEL_SIZE_THUMB);
+
+ }
+
+ update_presence_pixbuf (self,
+ OSSO_ABOOK_PRESENCE (priv->contact));
+ g_signal_connect (priv->contact,
+ "notify::presence-status",
+ G_CALLBACK (presence_updated),
+ self);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+ }
+
+}
+
+static void
+contacts_added (OssoABookRoster *roster,
+ OssoABookContact **contacts,
+ gpointer userdata)
+{
+ ELHomeApplet *self = EL_HOME_APPLET (userdata);
+ ELHomeAppletPrivate *priv = self->priv;
+
+ if (!priv->contact)
+ resolve_contact (self);
+}
+
+static void
+reset_contact (ELHomeApplet *self)
{
ELHomeAppletPrivate *priv = self->priv;
priv->presence_pixbuf = NULL;
}
+ if (priv->contact) {
+ g_signal_handlers_disconnect_by_func (priv->contact,
+ presence_updated,
+ self);
+ g_object_unref (priv->contact);
+ priv->contact = NULL;
+ }
+}
+
+static void
+contacts_removed (OssoABookRoster *roster,
+ const gchar **ids,
+ gpointer userdata)
+{
+ ELHomeApplet *self = EL_HOME_APPLET (userdata);
+ ELHomeAppletPrivate *priv = self->priv;
+
+ if (priv->contact) {
+ const gchar **contact_id;
+ const gchar *uid = osso_abook_contact_get_uid (priv->contact);
+
+ for (contact_id = ids; *contact_id; contact_id++) {
+ if (strcmp (*contact_id, priv->contact_id) == 0) {
+ reset_contact (self);
+
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+ return;
+ }
+ if (strcmp (*contact_id, uid) == 0) {
+ reset_contact (self);
+ resolve_contact (self);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+ return;
+ }
+ }
+ }
+}
+
+static void
+clean_state (ELHomeApplet *self)
+{
+ ELHomeAppletPrivate *priv = self->priv;
+
+ reset_contact (self);
+
if (priv->message) {
g_free (priv->message);
priv->message = NULL;
priv->group_uid = NULL;
}
- if (priv->contact) {
- g_signal_handlers_disconnect_by_func (priv->contact,
- presence_updated,
- self);
- g_object_unref (priv->contact);
- priv->contact = NULL;
- }
if (priv->aggregator) {
if (priv->aggregator_ready_closure){
osso_abook_waitable_cancel (OSSO_ABOOK_WAITABLE (priv->aggregator),
priv->aggregator_ready_closure);
priv->aggregator_ready_closure = NULL;
}
+ g_signal_handlers_disconnect_by_func (priv->aggregator,
+ contacts_added,
+ self);
+ g_signal_handlers_disconnect_by_func (priv->aggregator,
+ contacts_removed,
+ self);
osso_abook_roster_stop (priv->aggregator);
g_object_unref (priv->aggregator);
priv->aggregator = NULL;
const GError *error,
gpointer userdata)
{
- ELHomeApplet *self = EL_HOME_APPLET(userdata);
+ ELHomeApplet *self = EL_HOME_APPLET (userdata);
ELHomeAppletPrivate *priv = self->priv;
- GList *contacts = NULL;
- g_warning (G_STRFUNC);
+
priv->aggregator_ready_closure = NULL;
if (error) {
return;
}
- if (priv->contact_id) {
- contacts = osso_abook_aggregator_lookup
- (OSSO_ABOOK_AGGREGATOR (priv->aggregator),
- priv->contact_id);
- }
- else if (priv->local_id && priv->remote_id) {
- if (g_strcmp0 (priv->local_id, "ring/tel/ring" == 0)) {
- contacts = osso_abook_aggregator_find_contacts_for_phone_number
- (OSSO_ABOOK_AGGREGATOR (priv->aggregator),
- priv->remote_id,
- TRUE);
- }
- else {
- McAccount *account;
- account = osso_abook_account_manager_lookup_by_name
- (NULL,
- priv->local_id);
- if (account) {
- contacts = osso_abook_aggregator_find_contacts_for_im_contact
- (OSSO_ABOOK_AGGREGATOR (priv->aggregator),
- priv->remote_id,
- account);
- }
- }
- }
-
- if (contacts && contacts->data) {
- priv->contact = g_object_ref (OSSO_ABOOK_CONTACT (contacts->data));
- gtk_label_set_text (GTK_LABEL (priv->sender),
- osso_abook_contact_get_display_name (priv->contact));
-
- priv->avatar_pixbuf = osso_abook_avatar_get_image_scaled
- (OSSO_ABOOK_AVATAR (priv->contact),
- HILDON_ICON_PIXEL_SIZE_THUMB,
- HILDON_ICON_PIXEL_SIZE_THUMB,
- TRUE);
-
- g_warning ("HAVE avatar");
- if (priv->avatar_pixbuf) {
- gtk_widget_set_size_request (priv->sender,
- C_WIDTH - AVATAR_SIZE - HILDON_MARGIN_DEFAULT,
- HILDON_ICON_PIXEL_SIZE_THUMB);
-
- }
+ g_signal_connect (priv->aggregator,
+ "contacts-added",
+ G_CALLBACK (contacts_added),
+ self);
+ g_signal_connect (priv->aggregator,
+ "contacts-removed",
+ G_CALLBACK (contacts_removed),
+ self);
- update_presence_pixbuf (self,
- OSSO_ABOOK_PRESENCE (priv->contact));
- g_signal_connect (priv->contact,
- "notify::presence-status",
- G_CALLBACK (presence_updated),
- self);
- gtk_widget_queue_draw (GTK_WIDGET (self));
- }
+ resolve_contact (self);
}
static void
-resolve_contact (ELHomeApplet *self)
+start_aggregator (ELHomeApplet *self)
{
ELHomeAppletPrivate *priv = self->priv;
EBookQuery *query = NULL;
it = make_query (priv->eventlogger, -1);
show_event (self, it);
- resolve_contact (self);
+ start_aggregator (self);
if (g_strcmp0 (priv->local_id, "ring/tel/ring") == 0) {
icon_name = "general_sms";