static void
tp_contact_list_got_local_pending_cb (TpConnection            *connection,
				      guint                    n_contacts,
				      EmpathyContact * const * contacts,
				      guint                    n_failed,
				      const TpHandle          *failed,
				      const GError            *error,
				      gpointer                 user_data,
				      GObject                 *list)
{
	EmpathyTpContactListPriv *priv = GET_PRIV (list);
	guint i;

	if (error) {
		DEBUG ("Error: %s", error->message);
		return;
	}

	for (i = 0; i < n_contacts; i++) {
		EmpathyContact *contact = contacts[i];
		TpHandle handle;
		const gchar *message;
		TpChannelGroupChangeReason reason;
		const TpIntSet *members, *remote_pending;

		handle = empathy_contact_get_handle (contact);
		members = tp_channel_group_get_members (priv->subscribe);
		remote_pending = tp_channel_group_get_remote_pending (priv->subscribe);

		if (tp_intset_is_member (members, handle) ||
		    tp_intset_is_member (remote_pending, handle)) {
			GArray handles = {(gchar *) &handle, 1};

			/* This contact is already subscribed, or user requested
			 * to subscribe, auto accept. */
			tp_cli_channel_interface_group_call_add_members (priv->publish,
				-1, &handles, NULL, NULL, NULL, NULL, NULL);
		}
		else if (tp_channel_group_get_local_pending_info (priv->publish,
								  handle,
								  NULL,
								  &reason,
								  &message)) {
			/* Add contact to pendings */
			g_hash_table_insert (priv->pendings, GUINT_TO_POINTER (handle),
					     g_object_ref (contact));
			g_signal_emit_by_name (list, "pendings-changed", contact,
					       contact, reason, message, TRUE);
		}
	}
}
Example #2
0
/**
 * tp_properties_context_has:
 * @ctx: the properties context representing a SetProperties call
 * @property: the property ID
 *
 * <!--Returns: says it all; this comment is to keep gtkdoc happy-->
 *
 * Returns: %TRUE if @ctx indicates that @property still needs to be set on
 * the server.
 */
gboolean
tp_properties_context_has (TpPropertiesContext *ctx, guint property)
{
  g_assert (property < ctx->mixin_cls->num_props);

  return (tp_intset_is_member (ctx->remaining, property));
}
gboolean
mcd_dbus_is_active_optional_interface (TpSvcDBusProperties *object,
                                       GType interface)
{
    return tp_intset_is_member (get_active_optional_interfaces (object),
                                interface);
}
Example #4
0
/**
 * tp_properties_context_has_other_than:
 * @ctx: the properties context representing a SetProperties call
 * @property: the property ID
 *
 * <!--Returns: says it all; this comment is to keep gtkdoc happy-->
 *
 * Returns: %TRUE if @ctx has properties other than @property that still
 * need to be set on the server
 */
gboolean
tp_properties_context_has_other_than (TpPropertiesContext *ctx, guint property)
{
  gboolean has = tp_intset_is_member (ctx->remaining, property);

  g_assert (property < ctx->mixin_cls->num_props);

  return (tp_intset_size (ctx->remaining) > (has ? 1 : 0));
}
static void
remove_from_member_if_needed (EmpathyTpContactList *list,
			      TpHandle handle)
{
	/* remove contact from members if it's not in publish and subscribe */
	EmpathyTpContactListPriv *priv = GET_PRIV (list);
	const TpIntSet *members;

	members = tp_channel_group_get_members (priv->subscribe);
	if (tp_intset_is_member (members, handle))
		return;

	members = tp_channel_group_get_remote_pending (priv->subscribe);
	if (tp_intset_is_member (members, handle))
		return;

	members = tp_channel_group_get_members (priv->publish);
	if (tp_intset_is_member (members, handle))
		return;

	tp_contact_list_remove_handle (list, priv->members, handle);
}
/**
 * tp_channel_group_get_local_pending_info:
 * @self: a channel
 * @local_pending: the handle of a local-pending contact about whom more
 *  information is needed
 * @actor: (out) (allow-none): either %NULL or a location to return the contact
 * who requested the change
 * @reason: (out) (allow-none): either %NULL or a location to return the reason
 * for the change
 * @message: (out) (transfer none) (allow-none): either %NULL or a location to
 * return the user-supplied message
 *
 * If @local_pending is actually the handle of a local-pending contact,
 * write additional information into @actor, @reason and @message and return
 * %TRUE. The handle and message are not referenced or copied, and can only be
 * assumed to remain valid until the main loop is re-entered.
 *
 * If @local_pending is not the handle of a local-pending contact,
 * write 0 into @actor, %TP_CHANNEL_GROUP_CHANGE_REASON_NONE into @reason
 * and "" into @message, and return %FALSE.
 *
 * Returns: %TRUE if the contact is in fact local-pending
 * Since: 0.7.12
 * Deprecated: New code should use
 *  tp_channel_group_get_local_pending_contact_info() instead.
 */
gboolean
tp_channel_group_get_local_pending_info (TpChannel *self,
                                         TpHandle local_pending,
                                         TpHandle *actor,
                                         TpChannelGroupChangeReason *reason,
                                         const gchar **message)
{
  gboolean ret = FALSE;
  TpHandle a = 0;
  TpChannelGroupChangeReason r = TP_CHANNEL_GROUP_CHANGE_REASON_NONE;
  const gchar *m = "";

  g_return_val_if_fail (TP_IS_CHANNEL (self), FALSE);

  if (self->priv->group_local_pending != NULL)
    {
      /* it could conceivably be someone who is local-pending */

      ret = tp_intset_is_member (self->priv->group_local_pending,
          local_pending);

      if (ret && self->priv->group_local_pending_info != NULL)
        {
          /* we might even have information about them */
          LocalPendingInfo *info = g_hash_table_lookup (
              self->priv->group_local_pending_info,
              GUINT_TO_POINTER (local_pending));

          if (info != NULL)
            {
              a = info->actor;
              r = info->reason;

              if (info->message != NULL)
                m = info->message;
            }
          /* else we have no info, which means (0, NONE, NULL) */
        }
    }

  if (actor != NULL)
    *actor = a;

  if (message != NULL)
    *message = m;

  if (reason != NULL)
    *reason = r;

  return ret;
}
Example #7
0
static void
tp_chat_got_added_contacts_cb (EmpathyTpContactFactory *factory,
			       guint                    n_contacts,
			       EmpathyContact * const * contacts,
			       guint                    n_failed,
			       const TpHandle          *failed,
			       const GError            *error,
			       gpointer                 user_data,
			       GObject                 *chat)
{
	EmpathyTpChatPriv *priv = GET_PRIV (chat);
	guint i;
	const TpIntSet *members;
	TpHandle handle;
	EmpathyContact *contact;

	if (error) {
		DEBUG ("Error: %s", error->message);
		return;
	}

	members = tp_channel_group_get_members (priv->channel);
	for (i = 0; i < n_contacts; i++) {
		contact = contacts[i];
		handle = empathy_contact_get_handle (contact);

		/* Make sure the contact is still member */
		if (tp_intset_is_member (members, handle)) {
			priv->members = g_list_prepend (priv->members,
				g_object_ref (contact));
			g_signal_emit_by_name (chat, "members-changed",
					       contact, NULL, 0, NULL, TRUE);
		}
	}

	tp_chat_update_remote_contact (EMPATHY_TP_CHAT (chat));
	tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
}
static GList *
tp_contact_list_get_groups (EmpathyContactList *list,
			    EmpathyContact     *contact)
{
	EmpathyTpContactListPriv  *priv = GET_PRIV (list);
	GList                     *ret = NULL;
	GHashTableIter             iter;
	gpointer                   group_name;
	gpointer                   channel;
	TpHandle                   handle;

	handle = empathy_contact_get_handle (contact);
	g_hash_table_iter_init (&iter, priv->groups);
	while (g_hash_table_iter_next (&iter, &group_name, &channel)) {
		const TpIntSet *members;

		members = tp_channel_group_get_members (channel);
		if (tp_intset_is_member (members, handle)) {
			ret = g_list_prepend (ret, g_strdup (group_name));
		}
	}

	return ret;
}