static TpBaseConnection *
_tp_legacy_protocol_new_connection (TpBaseProtocol *protocol,
    GHashTable *asv,
    GError **error)
{
  _TpLegacyProtocol *self = (_TpLegacyProtocol *) protocol;
  const TpCMProtocolSpec *protospec = self->protocol_spec;
  TpBaseConnectionManagerClass *cls;
  TpBaseConnection *conn = NULL;
  void *params = NULL;
  TpIntset *params_present = NULL;
  TpCMParamSetter set_param;

  if (self->cm == NULL)
    {
      g_set_error (error, TP_ERROR, TP_ERROR_NOT_AVAILABLE,
          "Connection manager no longer available");
      return NULL;
    }

  g_object_ref (self->cm);

  g_assert (protospec->parameters != NULL);
  g_assert (protospec->params_new != NULL);
  g_assert (protospec->params_free != NULL);

  cls = TP_BASE_CONNECTION_MANAGER_GET_CLASS (self->cm);

  params_present = tp_intset_new ();
  params = protospec->params_new ();

  set_param = protospec->set_param;

  if (set_param == NULL)
    set_param = tp_cm_param_setter_offset;

  if (!parse_parameters (protospec->parameters, (GHashTable *) asv,
        params_present, set_param, params, error))
    {
      goto finally;
    }

  conn = (cls->new_connection) (self->cm, protospec->name, params_present,
      params, error);

finally:
  if (params_present != NULL)
    tp_intset_destroy (params_present);

  if (params != NULL)
    protospec->params_free (params);

  g_object_unref (self->cm);

  return conn;
}
static gboolean
add_member (GObject *obj,
            TpHandle handle,
            const gchar *message,
            GError **error)
{
  TpTestsTextChannelGroup *self = TP_TESTS_TEXT_CHANNEL_GROUP (obj);
  TpIntSet *add = tp_intset_new ();

  tp_intset_add (add, handle);
  tp_group_mixin_change_members (obj, message, add, NULL, NULL, NULL,
      self->conn->self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
  tp_intset_destroy (add);

  return TRUE;
}
/**
 * get_active_optional_interfaces:
 *
 * DBus Interfaces marked as optional will only be included in the object's
 * Interfaces property if they appear in this set.
 *
 * Returns: a #TpIntset of the active optional interfaces.
 */
static TpIntset *
get_active_optional_interfaces (TpSvcDBusProperties *object)
{
    TpIntset *aoi = g_object_get_qdata (G_OBJECT (object),
                                        MCD_ACTIVE_OPTIONAL_INTERFACES_QUARK);

    if (G_UNLIKELY (aoi == NULL))
    {
        aoi = tp_intset_new ();

        g_object_set_qdata_full (G_OBJECT (object),
                                 MCD_ACTIVE_OPTIONAL_INTERFACES_QUARK,
                                 aoi,
                                 (GDestroyNotify) tp_intset_destroy);
    }

    return aoi;
}
static void
tp_base_media_call_stream_init (TpBaseMediaCallStream *self)
{
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
      TP_TYPE_BASE_MEDIA_CALL_STREAM, TpBaseMediaCallStreamPrivate);

  self->priv->local_candidates = g_ptr_array_new_with_free_func (
      (GDestroyNotify) tp_value_array_free);
  self->priv->username = g_strdup ("");
  self->priv->password = g_strdup ("");
  self->priv->receiving_requests = tp_intset_new ();
  self->priv->sending_state = TP_STREAM_FLOW_STATE_STOPPED;
  self->priv->receiving_state = TP_STREAM_FLOW_STATE_STOPPED;

  g_signal_connect (self, "notify::remote-members",
      G_CALLBACK (tp_base_media_call_stream_update_receiving_state), NULL);
  g_signal_connect (self, "notify::channel",
      G_CALLBACK (tp_base_media_call_stream_update_receiving_state), NULL);
  g_signal_connect (self, "notify::channel",
      G_CALLBACK (tp_base_media_call_stream_update_sending_state), NULL);
}
static void
service_handles_fetched_cb (TpConnection *tp_conn,
    TpHandleType handle_type,
    guint n_handles,
    const TpHandle *handles,
    const gchar * const *ids,
    const GError *error,
    gpointer user_data G_GNUC_UNUSED,
    GObject *weak)
{
  guint i;
  McdConnection *connection = MCD_CONNECTION (weak);
  TpIntset *e_handles = tp_intset_new ();

  if (error != NULL)
    return;

  for (i = 0; i < n_handles; i++)
    tp_intset_add (e_handles, handles[i]);

  _mcd_connection_take_emergency_handles (connection, e_handles);
}
Example #6
0
/**
 * tp_properties_mixin_set_properties:
 * @obj: An object with this mixin
 * @properties: An array of D-Bus structures containing property ID and value
 * @context: A D-Bus method invocation context for the SetProperties method
 *
 * Start to change properties in response to user request via D-Bus.
 */
void
tp_properties_mixin_set_properties (GObject *obj,
                                    const GPtrArray *properties,
                                    DBusGMethodInvocation *context)
{
  TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj);
  TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS (
                                            G_OBJECT_GET_CLASS (obj));
  TpPropertiesContext *ctx = &mixin->priv->context;
  GError *error = NULL;
  GType value_type = TP_STRUCT_TYPE_PROPERTY_VALUE;
  guint i;

  /* Is another SetProperties request already in progress? */
  if (ctx->dbus_ctx)
    {
      error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
                           "A SetProperties request is already in progress");
      dbus_g_method_return_error (context, error);
      g_error_free (error);
      return;
    }

  ctx->dbus_ctx = context;
  ctx->remaining = tp_intset_new ();
  error = NULL;

  if (properties->len == 0)
    {
      DEBUG ("immediately returning from SetProperties with 0 properties");
      tp_properties_context_return (ctx, NULL);
      return;
    }

  /* Check input property identifiers */
  for (i = 0; i < properties->len; i++)
    {
      GValue val_struct = { 0, };
      guint prop_id;
      GValue *prop_val;

      g_value_init (&val_struct, value_type);
      g_value_set_static_boxed (&val_struct,
          g_ptr_array_index (properties, i));

      dbus_g_type_struct_get (&val_struct,
          0, &prop_id,
          1, &prop_val,
          G_MAXUINT);

      /* Valid? */
      if (prop_id >= mixin_cls->num_props)
        {
          g_value_unset (prop_val);

          error = g_error_new (TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
                               "invalid property identifier %d", prop_id);
          goto ERROR;
        }

      /* Store the value in the context */
      tp_intset_add (ctx->remaining, prop_id);
      ctx->values[prop_id] = prop_val;

      /* Permitted? */
      if (!tp_properties_mixin_is_writable (obj, prop_id))
        {
          error = g_error_new (TP_ERRORS, TP_ERROR_PERMISSION_DENIED,
                               "permission denied for property identifier %d",
                               prop_id);
          goto ERROR;
        }

      /* Compatible type? */
      if (!g_value_type_compatible (G_VALUE_TYPE (prop_val),
                                    mixin_cls->signatures[prop_id].type))
        {
          error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
                               "incompatible value type for property "
                               "identifier %d", prop_id);
          goto ERROR;
        }
    }

  if (mixin_cls->set_properties)
    {
      if (mixin_cls->set_properties (obj, ctx, &error))
        return;
    }
  else
    {
      tp_properties_context_return (ctx, NULL);
      return;
    }

ERROR:
  tp_properties_context_return (ctx, error);
}