/**
 * tp_base_media_call_stream_set_stun_servers:
 * @self: a #TpBaseMediaCallStream
 * @stun_servers: the new stun servers
 *
 * Set the STUN servers. The #GPtrArray should have a free_func defined such as
 * g_ptr_array_ref() is enough to keep the data and g_ptr_array_unref() is
 * enough to release it later.
 *
 * Note that this replaces the previously set STUN servers, it is not an
 * addition.
 *
 * Since: 0.17.5
 */
void
tp_base_media_call_stream_set_stun_servers (TpBaseMediaCallStream *self,
    GPtrArray *stun_servers)
{
  g_return_if_fail (TP_IS_BASE_MEDIA_CALL_STREAM (self));
  g_return_if_fail (stun_servers != NULL);

  if (self->priv->stun_servers != NULL)
    {
      if (stun_servers->len == self->priv->stun_servers->len)
        {
          guint i;
          gboolean equal = TRUE;

          for (i = 0; i < stun_servers->len; i++)
            {
              GValueArray *gva1 = g_ptr_array_index (stun_servers, i);
              GValueArray *gva2 = g_ptr_array_index (self->priv->stun_servers,
                  i);
              gchar *ip1, *ip2;
              guint port1, port2;

              tp_value_array_unpack (gva1, 2, &ip1, &port1);
              tp_value_array_unpack (gva2, 2, &ip2, &port2);

              if (port1 != port2 || strcmp (ip1, ip2))
                {
                  equal = FALSE;
                  break;
                }
            }

          if (equal)
            {
              g_ptr_array_unref (stun_servers);
              return;
            }
        }

      g_ptr_array_unref (self->priv->stun_servers);
    }

  self->priv->stun_servers = g_ptr_array_ref (stun_servers);

  tp_svc_call_stream_interface_media_emit_stun_servers_changed (self,
      self->priv->stun_servers);

  maybe_got_server_info (self);
}
Пример #2
0
static void
got_hats_cb (TpConnection *conn,
    const GPtrArray *hats,
    const GError *error,
    gpointer user_data,
    GObject *weak_object)
{
  guint i;

  if (die_if (error, "GetHats()"))
    return;

  for (i = 0; i < hats->len; i++)
    {
      GValueArray *vals = g_ptr_array_index (hats, i);
      guint handle;
      const gchar *color;
      guint style;
      GHashTable *details;

      tp_value_array_unpack (vals, 4,
          &handle, &color, &style, &details);
      g_message ("Contact #%u has hat style %u, color \"%s\", with %u "
          "properties", handle, style, color, g_hash_table_size (details));
    }

  tp_cli_connection_call_disconnect (conn, -1, disconnect_cb,
      NULL, NULL, NULL);
}
static void
set_telepathy_codecs (RakiaCallContent *self, GHashTable *md_properties)
{
  RakiaCallContentPrivate *priv = self->priv;
  guint i;
  GPtrArray *tpcodecs = tp_asv_get_boxed (md_properties,
      TP_PROP_CALL_CONTENT_MEDIA_DESCRIPTION_CODECS,
      TP_ARRAY_TYPE_CODEC_LIST);
  GPtrArray *sipcodecs = g_ptr_array_new_with_free_func (
      (GDestroyNotify) rakia_sip_codec_free);

  for (i = 0; i < tpcodecs->len; i++)
    {
      GValueArray *tpcodec = g_ptr_array_index (tpcodecs, i);
      guint id;
      const gchar *name;
      guint clock_rate;
      guint channels;
      gboolean updated;
      GHashTable *extra_params;
      RakiaSipCodec *sipcodec;
      GHashTableIter iter;
      gpointer key, value;

      tp_value_array_unpack (tpcodec, 6, &id, &name, &clock_rate,
          &channels, &updated, &extra_params);

      sipcodec = rakia_sip_codec_new (id, name, clock_rate, channels);

      g_hash_table_iter_init (&iter, extra_params);

      while (g_hash_table_iter_next (&iter, &key, &value))
        rakia_sip_codec_add_param (sipcodec, key, value);

      g_ptr_array_add (sipcodecs, sipcodec);
    }

  rakia_sip_media_take_local_codecs (priv->media, sipcodecs);
}
static void
presence_chooser_set_statuses (PresenceChooser *self,
                               GHashTable      *statuses)
{
  g_return_if_fail (IS_PRESENCE_CHOOSER (self));
  g_return_if_fail (statuses != NULL);

  PresenceChooserPrivate *priv = GET_PRIVATE (self);

  gtk_list_store_clear (priv->store);

  GHashTableIter iter;
  gpointer k, v;

  g_hash_table_iter_init (&iter, statuses);
  while (g_hash_table_iter_next (&iter, &k, &v))
    {
      char *status = k;
      GValueArray *array = v;

      guint type;
      gboolean set_on_self, can_have_message;

      tp_value_array_unpack (array, 3,
          &type, &set_on_self, &can_have_message);

      if (!set_on_self) continue;

      gtk_list_store_insert_with_values (priv->store, NULL, -1,
          ICON_NAME, presence_icons[type],
          PRESENCE_TYPE, type,
          STATUS, status,
          CAN_HAVE_MESSAGE, can_have_message,
          STATUS_MESSAGE, status,
          -1);
    }
}
Пример #5
0
gboolean
conn_location_properties_setter (GObject *object,
                                GQuark interface,
                                GQuark name,
                                const GValue *value,
                                gpointer setter_data,
                                GError **error)
{
  guint access_control_type;
  GValue *access_control_argument;

  g_return_val_if_fail (interface ==
      TP_IFACE_QUARK_CONNECTION_INTERFACE_LOCATION, FALSE);

  /* There is only one property with write access. So TpDBusPropertiesMixin
   * already checked this. */
  g_assert (name == g_quark_from_static_string ("LocationAccessControl"));

  /* TpDBusPropertiesMixin already checked that it was a (uv). */
  g_assert (G_VALUE_HOLDS (value,
        TP_STRUCT_TYPE_RICH_PRESENCE_ACCESS_CONTROL));

  tp_value_array_unpack (g_value_get_boxed (value), 2,
      &access_control_type,
      &access_control_argument);

  if (access_control_type !=
      TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST)
    {
      g_set_error (error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED,
          "Access control type not implemented");
      return FALSE;
    }

  return TRUE;
}
static gboolean
set_content_hash_type_from_classes (EmpathyFTHandler *handler,
    GPtrArray *classes)
{
  GArray *possible_values;
  guint value;
  gboolean valid;
  EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
  gboolean support_ft = FALSE;
  guint i;

  possible_values = g_array_new (TRUE, TRUE, sizeof (guint));

  for (i = 0; i < classes->len; i++)
    {
      GHashTable *fixed;
      GStrv allowed;
      const gchar *chan_type;

      tp_value_array_unpack (g_ptr_array_index (classes, i), 2,
          &fixed, &allowed);

      chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);

      if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
        continue;

      if (tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL) !=
          TP_HANDLE_TYPE_CONTACT)
        continue;

      support_ft = TRUE;

      value = tp_asv_get_uint32
        (fixed, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH_TYPE,
         &valid);

      if (valid)
        g_array_append_val (possible_values, value);
    }

  if (!support_ft)
    {
      g_array_free (possible_values, TRUE);
      return FALSE;
    }

  if (possible_values->len == 0)
    {
      /* there are no channel classes with hash support, disable it. */
      priv->use_hash = FALSE;
      priv->content_hash_type = TP_FILE_HASH_TYPE_NONE;

      goto out;
    }

  priv->use_hash = TRUE;

  if (possible_values->len == 1)
    {
      priv->content_hash_type = g_array_index (possible_values, guint, 0);
    }
  else
    {
      /* order the array and pick the first non zero, so that MD5
       * is the preferred value.
       */
      g_array_sort (possible_values, empathy_uint_compare);

      if (g_array_index (possible_values, guint, 0) == 0)
        priv->content_hash_type = g_array_index (possible_values, guint, 1);
      else
        priv->content_hash_type = g_array_index (possible_values, guint, 0);
    }

out:
  g_array_free (possible_values, TRUE);

  DEBUG ("Hash enabled %s; setting content hash type as %u",
         priv->use_hash ? "True" : "False", priv->content_hash_type);

  return TRUE;
}