static void contact_widget_set_contact (EmpathyContactWidget *information, EmpathyContact *contact) { if (contact == information->contact) return; contact_widget_remove_contact (information); if (contact) { TpConnection *connection; connection = empathy_contact_get_connection (contact); information->contact = g_object_ref (contact); information->factory = empathy_tp_contact_factory_dup_singleton (connection); } /* set the selected account to be the account this contact came from */ if (contact && EMPATHY_IS_ACCOUNT_CHOOSER (information->widget_account)) { empathy_account_chooser_set_account ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), empathy_contact_get_account (contact)); } /* Update information for widgets */ contact_widget_contact_update (information); contact_widget_groups_update (information); contact_widget_details_update (information); contact_widget_client_update (information); contact_widget_location_update (information); }
static void contact_widget_change_contact (EmpathyContactWidget *information) { EmpathyTpContactFactory *factory; TpConnection *connection; connection = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account)); if (!connection) return; factory = empathy_tp_contact_factory_dup_singleton (connection); if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { const gchar *id; id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); if (!EMP_STR_EMPTY (id)) { empathy_tp_contact_factory_get_from_id (factory, id, contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); } } else { empathy_tp_contact_factory_get_from_handle (factory, tp_connection_get_self_handle (connection), contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); } g_object_unref (factory); }
static void megaphone_applet_new_connection_cb (EmpathyAccountManager *manager, TpConnection *connection, EmpathyAccount *account, MegaphoneApplet *applet) { MegaphoneAppletPriv *priv = GET_PRIV (applet); if (priv->contact || !empathy_account_equal (account, priv->account)) { return; } priv->factory = empathy_tp_contact_factory_dup_singleton (connection); empathy_tp_contact_factory_get_from_id (priv->factory, priv->id, megaphone_applet_got_contact_cb, NULL, NULL, G_OBJECT (applet)); }
static void avatar_chooser_set_connection (EmpathyAvatarChooser *self, TpConnection *connection) { EmpathyAvatarChooserPriv *priv = GET_PRIV (self); if (priv->connection != NULL) { g_object_unref (priv->connection); priv->connection = NULL; g_object_unref (priv->factory); priv->factory = NULL; } if (connection != NULL) { priv->connection = g_object_ref (connection); priv->factory = empathy_tp_contact_factory_dup_singleton (connection); } }
static void contact_widget_set_contact (EmpathyContactWidget *information, EmpathyContact *contact) { if (contact == information->contact) return; contact_widget_remove_contact (information); if (contact) { TpConnection *connection; connection = empathy_contact_get_connection (contact); information->contact = g_object_ref (contact); information->factory = empathy_tp_contact_factory_dup_singleton (connection); } /* Update information for widgets */ contact_widget_contact_update (information); contact_widget_groups_update (information); contact_widget_details_update (information); contact_widget_client_update (information); contact_widget_location_update (information); }
static GObject * tp_chat_constructor (GType type, guint n_props, GObjectConstructParam *props) { GObject *chat; EmpathyTpChatPriv *priv; TpConnection *connection; TpHandle handle; chat = G_OBJECT_CLASS (empathy_tp_chat_parent_class)->constructor (type, n_props, props); priv = GET_PRIV (chat); connection = tp_channel_borrow_connection (priv->channel); priv->factory = empathy_tp_contact_factory_dup_singleton (connection); g_signal_connect (priv->channel, "invalidated", G_CALLBACK (tp_chat_invalidated_cb), chat); if (tp_proxy_has_interface_by_id (priv->channel, TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) { const TpIntSet *members; GArray *handles; /* Get self contact from the group's self handle */ handle = tp_channel_group_get_self_handle (priv->channel); empathy_tp_contact_factory_get_from_handle (priv->factory, handle, tp_chat_got_self_contact_cb, NULL, NULL, chat); /* Get initial member contacts */ members = tp_channel_group_get_members (priv->channel); handles = tp_intset_to_array (members); empathy_tp_contact_factory_get_from_handles (priv->factory, handles->len, (TpHandle *) handles->data, tp_chat_got_added_contacts_cb, NULL, NULL, chat); g_signal_connect (priv->channel, "group-members-changed", G_CALLBACK (tp_chat_group_members_changed_cb), chat); } else { /* Get the self contact from the connection's self handle */ handle = tp_connection_get_self_handle (connection); empathy_tp_contact_factory_get_from_handle (priv->factory, handle, tp_chat_got_self_contact_cb, NULL, NULL, chat); /* Get the remote contact */ handle = tp_channel_get_handle (priv->channel, NULL); empathy_tp_contact_factory_get_from_handle (priv->factory, handle, tp_chat_got_remote_contact_cb, NULL, NULL, chat); } if (tp_proxy_has_interface_by_id (priv->channel, TP_IFACE_QUARK_PROPERTIES_INTERFACE)) { tp_cli_properties_interface_call_list_properties (priv->channel, -1, tp_chat_list_properties_cb, NULL, NULL, G_OBJECT (chat)); tp_cli_properties_interface_connect_to_properties_changed (priv->channel, tp_chat_properties_changed_cb, NULL, NULL, G_OBJECT (chat), NULL); tp_cli_properties_interface_connect_to_property_flags_changed (priv->channel, tp_chat_property_flags_changed_cb, NULL, NULL, G_OBJECT (chat), NULL); } return chat; }
static void contact_list_view_drag_data_received (GtkWidget *view, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time) { EmpathyContactListViewPriv *priv; EmpathyAccountManager *account_manager; EmpathyTpContactFactory *factory = NULL; EmpathyAccount *account; GtkTreeModel *model; GtkTreeViewDropPosition position; GtkTreePath *path; const gchar *id; gchar **strv = NULL; const gchar *account_id; const gchar *contact_id; gchar *new_group = NULL; gchar *old_group = NULL; DndGetContactData *data; gboolean is_row; gboolean success = TRUE; priv = GET_PRIV (view); model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); /* Get destination group information. */ is_row = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view), x, y, &path, &position); if (is_row) { new_group = empathy_contact_list_store_get_parent_group (model, path, NULL); gtk_tree_path_free (path); } /* Get source group information. */ if (priv->drag_row) { path = gtk_tree_row_reference_get_path (priv->drag_row); if (path) { old_group = empathy_contact_list_store_get_parent_group ( model, path, NULL); gtk_tree_path_free (path); } } if (!tp_strdiff (old_group, new_group)) { g_free (new_group); g_free (old_group); goto OUT; } id = (const gchar*) gtk_selection_data_get_data (selection); DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'", context->action == GDK_ACTION_MOVE ? "move" : "", context->action == GDK_ACTION_COPY ? "copy" : "", id); strv = g_strsplit (id, "/", 2); account_id = strv[0]; contact_id = strv[1]; account_manager = empathy_account_manager_dup_singleton (); account = empathy_account_manager_lookup (account_manager, account_id); if (account) { TpConnection *connection; connection = empathy_account_get_connection (account); if (connection) { factory = empathy_tp_contact_factory_dup_singleton (connection); } } g_object_unref (account_manager); if (!factory) { DEBUG ("Failed to get factory for account '%s'", account_id); success = FALSE; g_free (new_group); g_free (old_group); goto OUT; } data = g_slice_new0 (DndGetContactData); data->new_group = new_group; data->old_group = old_group; data->action = context->action; /* FIXME: We should probably wait for the cb before calling * gtk_drag_finish */ empathy_tp_contact_factory_get_from_id (factory, contact_id, contact_list_view_drag_got_contact, data, (GDestroyNotify) contact_list_view_dnd_get_contact_free, G_OBJECT (view)); g_object_unref (factory); OUT: g_strfreev (strv); gtk_drag_finish (context, success, FALSE, GDK_CURRENT_TIME); }