コード例 #1
0
static gboolean
contact_manager_is_favourite (EmpathyContactList *manager,
			      EmpathyContact     *contact)
{
	EmpathyContactManagerPriv *priv;
	TpAccount *account;
	const gchar *account_name;
	GHashTable *contact_hash;

	g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), FALSE);
	g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);

	priv = GET_PRIV (manager);

	account = empathy_contact_get_account (contact);
	account_name = tp_proxy_get_object_path (TP_PROXY (account));
	contact_hash = g_hash_table_lookup (priv->favourites, account_name);

	if (contact_hash != NULL) {
		const gchar *contact_id = empathy_contact_get_id (contact);

		if (g_hash_table_lookup (contact_hash, contact_id) != NULL)
			return TRUE;
	}

	return FALSE;
}
コード例 #2
0
EmpathyTpContactList *
empathy_contact_manager_get_list (EmpathyContactManager *manager,
				  TpConnection          *connection)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);

	g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);
	g_return_val_if_fail (TP_IS_CONNECTION (connection), NULL);

	return g_hash_table_lookup (priv->lists, connection);
}
コード例 #3
0
static void
contact_manager_remove_group (EmpathyContactList *manager,
			      const gchar *group)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);

	g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));

	g_hash_table_foreach (priv->lists,
			      (GHFunc) contact_manager_remove_group_foreach,
			      (gpointer) group);
}
コード例 #4
0
static GList *
contact_manager_get_all_groups (EmpathyContactList *manager)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);
	GList                     *groups = NULL;

	g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);

	g_hash_table_foreach (priv->lists,
			      (GHFunc) contact_manager_get_all_groups_foreach,
			      &groups);

	return groups;
}
コード例 #5
0
gboolean
empathy_contact_manager_can_add (EmpathyContactManager *manager,
				 TpConnection          *connection)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);
	EmpathyTpContactList      *list;

	g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), FALSE);
	g_return_val_if_fail (connection != NULL, FALSE);

	list = g_hash_table_lookup (priv->lists, connection);
	if (list == NULL)
		return FALSE;

	return empathy_tp_contact_list_can_add (list);
}
コード例 #6
0
static void
contact_manager_rename_group (EmpathyContactList *manager,
			      const gchar        *old_group,
			      const gchar        *new_group)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);
	RenameGroupData            data;

	g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));

	data.old_group = old_group;
	data.new_group = new_group;
	g_hash_table_foreach (priv->lists,
			      (GHFunc) contact_manager_rename_group_foreach,
			      &data);
}
コード例 #7
0
static void
contact_manager_remove_from_group (EmpathyContactList *manager,
				   EmpathyContact     *contact,
				   const gchar        *group)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);
	EmpathyContactList        *list;
	TpConnection              *connection;

	g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));

	connection = empathy_contact_get_connection (contact);
	list = g_hash_table_lookup (priv->lists, connection);

	if (list) {
		empathy_contact_list_remove_from_group (list, contact, group);
	}
}
コード例 #8
0
static GList *
contact_manager_get_groups (EmpathyContactList *manager,
			    EmpathyContact     *contact)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);
	EmpathyContactList        *list;
	TpConnection              *connection;

	g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);

	connection = empathy_contact_get_connection (contact);
	list = g_hash_table_lookup (priv->lists, connection);

	if (list) {
		return empathy_contact_list_get_groups (list, contact);
	}

	return NULL;
}
コード例 #9
0
static gboolean
contact_manager_get_blocked (EmpathyContactList *manager,
			     EmpathyContact     *contact)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);
	EmpathyContactList        *list;
	TpConnection              *connection;

	g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), FALSE);

	connection = empathy_contact_get_connection (contact);
	list = g_hash_table_lookup (priv->lists, connection);

	if (list != NULL) {
		return empathy_contact_list_get_blocked (list, contact);
	} else {
		return FALSE;
	}
}
コード例 #10
0
EmpathyContactListFlags
empathy_contact_manager_get_flags_for_connection (
				EmpathyContactManager *manager,
				TpConnection          *connection)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);
	EmpathyContactList        *list;
	EmpathyContactListFlags    flags;

	g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), FALSE);
	g_return_val_if_fail (connection != NULL, FALSE);

	list = g_hash_table_lookup (priv->lists, connection);
	if (list == NULL) {
		return FALSE;
	}
	flags = empathy_contact_list_get_flags (list);

	return flags;
}
コード例 #11
0
static void
contact_manager_set_blocked (EmpathyContactList *manager,
			     EmpathyContact     *contact,
			     gboolean            blocked,
			     gboolean            abusive)
{
	EmpathyContactManagerPriv *priv = GET_PRIV (manager);
	EmpathyContactList        *list;
	TpConnection              *connection;

	g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));

	connection = empathy_contact_get_connection (contact);
	list = g_hash_table_lookup (priv->lists, connection);

	if (list != NULL) {
		empathy_contact_list_set_blocked (list, contact,
						  blocked, abusive);
	}
}
コード例 #12
0
static void
contact_manager_remove_favourite (EmpathyContactList *manager,
				  EmpathyContact *contact)
{
	EmpathyContactManagerPriv *priv;
	TpAccount *account;
	const gchar *account_name;

	g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
	g_return_if_fail (EMPATHY_IS_CONTACT (contact));

	priv = GET_PRIV (manager);

	account = empathy_contact_get_account (contact);
	account_name = tp_proxy_get_object_path (TP_PROXY (account));

	emp_cli_logger_call_remove_favourite_contact (priv->logger, -1,
						      account_name,
						      empathy_contact_get_id (contact),
						      remove_favourite_contact_cb, NULL, NULL, G_OBJECT (manager));
}
コード例 #13
0
static void
contact_list_store_add_contact (EmpathyContactListStore *store,
				EmpathyContact          *contact)
{
	EmpathyContactListStorePriv *priv;
	GtkTreeIter                 iter;
	GList                      *groups = NULL, *l;
	TpConnection               *connection;
	EmpathyContactListFlags     flags = 0;

	priv = GET_PRIV (store);

	if (EMP_STR_EMPTY (empathy_contact_get_name (contact)) ||
	    (!priv->show_offline && !empathy_contact_is_online (contact))) {
		return;
	}

	if (priv->show_groups) {
		groups = empathy_contact_list_get_groups (priv->list, contact);
	}

	connection = empathy_contact_get_connection (contact);
	if (EMPATHY_IS_CONTACT_MANAGER (priv->list)) {
		flags = empathy_contact_manager_get_flags_for_connection (
			EMPATHY_CONTACT_MANAGER (priv->list), connection);
	}
	/* If no groups just add it at the top level. */
	if (!groups) {
		GtkTreeModel *model = GTK_TREE_MODEL (store);

		if (gtk_tree_model_get_iter_first (model, &iter)) do {
			EmpathyContact *c;

			gtk_tree_model_get (model, &iter,
				EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &c,
				-1);

			if (c == contact) {
				g_object_unref (c);
				return;
			}
			if (c != NULL)
				g_object_unref (c);
		} while (gtk_tree_model_iter_next (model, &iter));

		gtk_tree_store_append (GTK_TREE_STORE (store), &iter, NULL);
		gtk_tree_store_set (GTK_TREE_STORE (store), &iter,
				    EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact),
				    EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact,
				    EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE,
				    EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE,
				    EMPATHY_CONTACT_LIST_STORE_COL_CAN_AUDIO_CALL,
				      empathy_contact_get_capabilities (contact) &
				        EMPATHY_CAPABILITIES_AUDIO,
				    EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL,
				      empathy_contact_get_capabilities (contact) &
				        EMPATHY_CAPABILITIES_VIDEO,
				    EMPATHY_CONTACT_LIST_STORE_COL_FLAGS, flags,
				    -1);
	}

	/* Else add to each group. */
	for (l = groups; l; l = l->next) {
		GtkTreeIter iter_group;

		contact_list_store_get_group (store, l->data, &iter_group, NULL, NULL);

		gtk_tree_store_insert_after (GTK_TREE_STORE (store), &iter,
					     &iter_group, NULL);
		gtk_tree_store_set (GTK_TREE_STORE (store), &iter,
				    EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact),
				    EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact,
				    EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE,
				    EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE,
				    EMPATHY_CONTACT_LIST_STORE_COL_CAN_AUDIO_CALL,
				      empathy_contact_get_capabilities (contact) &
				        EMPATHY_CAPABILITIES_AUDIO,
				    EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL,
				      empathy_contact_get_capabilities (contact) &
				        EMPATHY_CAPABILITIES_VIDEO,
				    EMPATHY_CONTACT_LIST_STORE_COL_FLAGS, flags,
				    -1);
		g_free (l->data);
	}
	g_list_free (groups);

	contact_list_store_contact_update (store, contact);

}