Пример #1
0
/* this function is called every second and dumps the RTP manager stats */
static gboolean print_stats (GstElement * rtpbin)
{
    GObject *session;
    GValueArray *arr;
    GValue *val;
    guint i;

    g_print ("***********************************\n");

    /* get session 0 */
    g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);

    /* print all the sources in the session, this includes the internal source */
    g_object_get (session, "sources", &arr, NULL);

    for (i = 0; i < arr->n_values; i++) {
        GObject *source;

        val = g_value_array_get_nth (arr, i);
        source = g_value_get_object (val);

        print_source_stats (source);
    }
    g_value_array_free (arr);

    g_object_unref (session);

    return TRUE;
}
static void
terminal_profile_get_property (GObject *object,
                               guint prop_id,
                               GValue *value,
                               GParamSpec *pspec)
{
	TerminalProfile *profile = TERMINAL_PROFILE (object);
	TerminalProfilePrivate *priv = profile->priv;

	if (prop_id == 0 || prop_id >= LAST_PROP)
	{
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		return;
	}

	/* Note: When adding things here, do the same in get_prop_value_from_prop_name! */
	switch (prop_id)
	{
	case PROP_BACKGROUND_IMAGE:
		ensure_pixbuf_property (profile, PROP_BACKGROUND_IMAGE_FILE, PROP_BACKGROUND_IMAGE, &priv->background_load_failed);
		break;
	default:
		break;
	}

	g_value_copy (g_value_array_get_nth (priv->properties, prop_id), value);
}
Пример #3
0
Файл: table.c Проект: gbl/vte
/* Print the contents of a GValueArray. */
static void
print_array(GValueArray *array)
{
	int i;
	GValue *value;
	if (array != NULL) {
		printf(" (");
		for (i = 0; i < array->n_values; i++) {
			value = g_value_array_get_nth(array, i);
			if (i > 0) {
				printf(", ");
			}
			if (G_VALUE_HOLDS_LONG(value)) {
				printf("%ld", g_value_get_long(value));
			} else
			if (G_VALUE_HOLDS_STRING(value)) {
				printf("\"%s\"", g_value_get_string(value));
			} else
			if (G_VALUE_HOLDS_POINTER(value)) {
				printf("\"%ls\"",
				       (wchar_t*) g_value_get_pointer(value));
			}
			if (G_VALUE_HOLDS_BOXED(value)) {
				print_array(g_value_get_boxed(value));
			}
		}
		printf(")");
		/* _vte_matcher_free_params_array(array); */
	}
}
Пример #4
0
static void
message_list_view_delete_clicked(struct MessageListViewData *data,
				 Evas_Object * obj, void *event_info)
{
	g_debug("message_list_view_delete_clicked()");
	evas_object_hide(data->hv);

	data->selected_row = etk_tree_selected_row_get(data->tree);
	if (data->selected_row != NULL) {
		GValueArray *message =
			etk_tree_row_data_get(data->selected_row);

		GHashTable *options = g_hash_table_new(g_str_hash, g_str_equal);
		g_hash_table_insert(options, "id",
				    GINT_TO_POINTER(g_value_get_int
						    (g_value_array_get_nth
						     (message, 0))));
		g_hash_table_insert(options, "delete_callback",
				    message_list_view_message_deleted);
		g_hash_table_insert(options, "delete_callback_data", data);

		struct Window *win = window_new(D_("Delete Message"));
		window_init(win);
		window_view_show(win, options, message_delete_view_show,
				 message_delete_view_hide);
	}
}
Пример #5
0
static void
_proxy_items_changed_cb (DBusGProxy *proxy,
                         GPtrArray  *items,
                         gpointer    userdata)
{
  MojitoClientView *view = MOJITO_CLIENT_VIEW (userdata);
  MojitoClientViewPrivate *priv = GET_PRIVATE (view);
  gint i = 0;
  GList *items_list = NULL;

  for (i = 0; i < items->len; i++)
  {
    GValueArray *varray = (GValueArray *)g_ptr_array_index (items, i);
    MojitoItem *item;
    const gchar *uid;

    uid = g_value_get_string (g_value_array_get_nth (varray, 1));

    item = g_hash_table_lookup (priv->uuid_to_items,
                                uid);
    _mojito_item_update_from_value_array (item, varray);

    items_list = g_list_append (items_list, mojito_item_ref (item));
  }

  /* If handler wants a ref then it should ref it up */
  g_signal_emit (view, signals[ITEMS_CHANGED_SIGNAL], 0, items_list);

  g_list_foreach (items_list, (GFunc)mojito_item_unref, NULL);
  g_list_free (items_list);
}
static void
serving_system_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
{
	CdmaDeviceInfo *info = user_data;
	GError *error = NULL;
	GValueArray *array = NULL;
	guint32 new_sid = 0;
	GValue *value;

	if (dbus_g_proxy_end_call (proxy, call, &error,
	                           SERVING_SYSTEM_TYPE, &array,
	                           G_TYPE_INVALID)) {
		if (array->n_values == 3) {
			value = g_value_array_get_nth (array, 2);
			if (G_VALUE_HOLDS_UINT (value))
				new_sid = g_value_get_uint (value);
		}

		g_value_array_free (array);
	}

	if (new_sid != info->sid) {
		info->sid = new_sid;
		g_free (info->provider_name);
		info->provider_name = mobile_helper_parse_3gpp2_operator_name (&(info->mobile_providers_database), info->sid);
	}

	g_clear_error (&error);
}
Пример #7
0
static void
gst_interleave_set_channel_positions (GstInterleave * self, GstStructure * s)
{
  GValue pos_array = { 0, };
  gint i;

  g_value_init (&pos_array, GST_TYPE_ARRAY);

  if (self->channel_positions
      && self->channels == self->channel_positions->n_values
      && gst_interleave_check_channel_positions (self->channel_positions)) {
    GST_DEBUG_OBJECT (self, "Using provided channel positions");
    for (i = 0; i < self->channels; i++)
      gst_value_array_append_value (&pos_array,
          g_value_array_get_nth (self->channel_positions, i));
  } else {
    GValue pos_none = { 0, };

    GST_WARNING_OBJECT (self, "Using NONE channel positions");

    g_value_init (&pos_none, GST_TYPE_AUDIO_CHANNEL_POSITION);
    g_value_set_enum (&pos_none, GST_AUDIO_CHANNEL_POSITION_NONE);

    for (i = 0; i < self->channels; i++)
      gst_value_array_append_value (&pos_array, &pos_none);

    g_value_unset (&pos_none);
  }
  gst_structure_set_value (s, "channel-positions", &pos_array);
  g_value_unset (&pos_array);
}
Пример #8
0
GArray *
gimp_dash_pattern_from_value_array (GValueArray *value_array)
{
  if (value_array == NULL || value_array->n_values == 0)
    {
      return NULL;
    }
  else
    {
      GArray *pattern;
      gint    i;

      pattern = g_array_sized_new (FALSE, FALSE,
                                   sizeof (gdouble), value_array->n_values);

      for (i = 0; i < value_array->n_values; i++)
        {
          GValue *item = g_value_array_get_nth (value_array, i);
          gdouble val;

          g_return_val_if_fail (G_VALUE_HOLDS_DOUBLE (item), NULL);

          val = g_value_get_double (item);

          g_array_append_val (pattern, val);
        }

      return pattern;
    }
}
static gchar *
gst_video_parse_int_valarray_to_string (GValueArray * valarray)
{
  /* holds a 64-bit number as string, which can have max. 20 digits
   * (with extra char for nullbyte) */
  gchar stride_str[21];
  gchar *str = NULL;
  guint i;

  for (i = 0; i < valarray->n_values; i++) {
    GValue *gvalue = g_value_array_get_nth (valarray, i);
    guint val = g_value_get_uint (gvalue);
    g_snprintf (stride_str, sizeof (stride_str), "%u", val);

    if (str == NULL) {
      str = g_strdup (stride_str);
    } else {
      gchar *new_str = g_strdup_printf ("%s,%s", str, stride_str);
      g_free (str);
      str = new_str;
    }
  }

  return str;
}
Пример #10
0
static char *
ip6_array_to_addr_prefix (GValueArray *values)
{
	GValue *prefix_val;
	char *ret = NULL;
	GString *ip6_str;
	char buf[INET6_ADDRSTRLEN + 1];
	gboolean is_unspec = FALSE;

	/* address */
	if (ip6_array_to_addr (values, 0, buf, sizeof (buf), NULL)) {
		/* Enough space for the address, '/', and the prefix */
		ip6_str = g_string_sized_new ((INET6_ADDRSTRLEN * 2) + 5);

		/* prefix */
		g_string_append (ip6_str, buf);
		prefix_val = g_value_array_get_nth (values, 1);
		g_string_append_printf (ip6_str, "/%u", g_value_get_uint (prefix_val));

		if (ip6_array_to_addr (values, 2, buf, sizeof (buf), &is_unspec)) {
			if (!is_unspec)
				g_string_append_printf (ip6_str, ",%s", buf);
		}

		ret = ip6_str->str;
		g_string_free (ip6_str, FALSE);
	}

	return ret;
}
static void
_proxy_items_removed_cb (DBusGProxy *proxy,
                         GPtrArray  *items,
                         gpointer    userdata)
{
  SwClientItemView *view = SW_CLIENT_ITEM_VIEW (userdata);
  SwClientItemViewPrivate *priv = GET_PRIVATE (view);
  gint i = 0;
  GList *items_list = NULL;

  for (i = 0; i < items->len; i++)
  {
    GValueArray *varray = (GValueArray *)g_ptr_array_index (items, i);
    const gchar *uid;
    SwItem *item;

    uid = g_value_get_string (g_value_array_get_nth (varray, 1));

    item = g_hash_table_lookup (priv->uuid_to_items,
                                uid);

    if (item)
    {
      /* Must ref up because g_hash_table_remove drops ref */
      items_list = g_list_append (items_list, sw_item_ref (item));
      g_hash_table_remove (priv->uuid_to_items, uid);
    }
  }

  /* If handler wants a ref then it should ref it up */
  g_signal_emit (view, signals[ITEMS_REMOVED_SIGNAL], 0, items_list);

  g_list_foreach (items_list, (GFunc)sw_item_unref, NULL);
  g_list_free (items_list);
}
Пример #12
0
static gboolean
gst_interleave_channel_positions_to_mask (GValueArray * positions,
    gint default_ordering_map[64], guint64 * mask)
{
  gint i;
  guint channels;
  GstAudioChannelPosition *pos;
  gboolean ret;

  channels = positions->n_values;
  pos = g_new (GstAudioChannelPosition, channels);

  for (i = 0; i < channels; i++) {
    GValue *val;

    val = g_value_array_get_nth (positions, i);
    pos[i] = g_value_get_enum (val);
  }

  /* sort the default ordering map according to the position order */
  for (i = 0; i < channels; i++) {
    default_ordering_map[i] = i;
  }
  g_qsort_with_data (default_ordering_map, channels,
      sizeof (*default_ordering_map), compare_positions, pos);

  ret = gst_audio_channel_positions_to_mask (pos, channels, FALSE, mask);
  g_free (pos);

  return ret;
}
Пример #13
0
gboolean
_capabilities_has_stream_tube (TpCapabilities *caps)
{
  GPtrArray *classes;
  guint i;

  if (caps == NULL)
    return FALSE;

  classes = tp_capabilities_get_channel_classes (caps);
  for (i = 0; i < classes->len; i++)
    {
      GValueArray *arr = g_ptr_array_index (classes, i);
      GHashTable *fixed;
      const gchar *chan_type;
      const gchar *service;
      TpHandleType handle_type;

      fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0));
      chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
      service = tp_asv_get_string (fixed,
          TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE);
      handle_type = tp_asv_get_uint32 (fixed,
          TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL);

      if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE) &&
          handle_type == TP_HANDLE_TYPE_CONTACT &&
          (!tp_capabilities_is_specific_to_contact (caps) ||
           !tp_strdiff (service, TUBE_SERVICE)))
        return TRUE;
    }

  return FALSE;
}
Пример #14
0
static gboolean
gst_interleave_check_channel_positions (GValueArray * positions)
{
  gint i;

  guint channels;

  GstAudioChannelPosition *pos;

  gboolean ret;

  channels = positions->n_values;
  pos = g_new (GstAudioChannelPosition, positions->n_values);

  for (i = 0; i < channels; i++) {
    GValue *v = g_value_array_get_nth (positions, i);

    pos[i] = g_value_get_enum (v);
  }

  ret = gst_audio_check_channel_positions (pos, channels);
  g_free (pos);

  return ret;
}
Пример #15
0
void
gst_cmml_parser_meta_to_string (GstCmmlParser * parser,
    xmlNodePtr parent, GValueArray * array)
{
  gint i;
  xmlNodePtr node;
  GValue *name, *content;

  for (i = 0; i < array->n_values - 1; i += 2) {
    name = g_value_array_get_nth (array, i);
    content = g_value_array_get_nth (array, i + 1);
    node = gst_cmml_parser_new_node (parser, "meta",
        "name", g_value_get_string (name),
        "content", g_value_get_string (content), NULL);
    xmlAddChild (parent, node);
  }
}
Пример #16
0
END_TEST

static void gotmeta(MafwRenderer *renderer,
		    const gchar *name, GValueArray *varr,
		    gboolean *isok)
{
	static guint callcount = 0;

	switch (callcount++) {
	case 0:
		*isok = !strcmp(name, "bitrate")
			&& varr->n_values == 1
			&& g_value_get_int(g_value_array_get_nth(varr, 0)) == 123;
		break;
	case 1:
		*isok = !strcmp(name, "date")
			&& varr->n_values == 3
			&& g_value_get_int(g_value_array_get_nth(varr, 0)) == 2008
			&& g_value_get_int(g_value_array_get_nth(varr, 1)) == 05
			&& g_value_get_int(g_value_array_get_nth(varr, 2)) == 19;
		break;
	case 2:
		*isok = !strcmp(name, "tags")
			&& varr->n_values == 3
			&& !strcmp("epic", g_value_get_string(g_value_array_get_nth(varr, 0)))
			&& !strcmp("fail", g_value_get_string(g_value_array_get_nth(varr, 1)))
			&& !strcmp("aye", g_value_get_string(g_value_array_get_nth(varr, 2)));
		break;
	default:
		fail("invoked too many times");
		break;
	}
}
Пример #17
0
static gint
compare_messages(gconstpointer _a, gconstpointer _b)
{
	GValueArray **a = (GValueArray **) _a;
	GValueArray **b = (GValueArray **) _b;
	GHashTable *h1 = g_value_get_boxed(g_value_array_get_nth(*a, 4));
	GHashTable *h2 = g_value_get_boxed(g_value_array_get_nth(*b, 4));

	long la = g_value_get_long(g_hash_table_lookup(h1, "timestamp_int"));
	long lb = g_value_get_long(g_hash_table_lookup(h2, "timestamp_int"));

	if (la > lb)
		return -1;
	else if (la < lb)
		return 1;
	else
		return 0;
}
static int
values_equal (GParamSpec *pspec,
              const GValue *va,
              const GValue *vb)
{
	/* g_param_values_cmp isn't good enough for some types, since e.g.
	 * it compares colours and font descriptions by pointer value, not
	 * with the correct compare functions. Providing extra
	 * PangoParamSpecFontDescription and GdkParamSpecColor wouldn't
	 * have fixed this either, since it's unclear how to _order_ them.
	 * Luckily we only need to check them for equality here.
	 */

	if (g_param_values_cmp (pspec, va, vb) == 0)
		return TRUE;

	if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR)
		return gdk_color_equal (g_value_get_boxed (va), g_value_get_boxed (vb));

	if (G_PARAM_SPEC_VALUE_TYPE (pspec) == PANGO_TYPE_FONT_DESCRIPTION)
		return pango_font_description_equal (g_value_get_boxed (va), g_value_get_boxed (vb));

	if (G_IS_PARAM_SPEC_VALUE_ARRAY (pspec) &&
	        G_PARAM_SPEC_VALUE_TYPE (G_PARAM_SPEC_VALUE_ARRAY (pspec)->element_spec) == GDK_TYPE_COLOR)
	{
		GValueArray *ara, *arb;
		guint i;

		ara = g_value_get_boxed (va);
		arb = g_value_get_boxed (vb);

		if (!ara || !arb || ara->n_values != arb->n_values)
			return FALSE;

		for (i = 0; i < ara->n_values; ++i)
			if (!gdk_color_equal (g_value_get_boxed (g_value_array_get_nth (ara, i)),
			                      g_value_get_boxed (g_value_array_get_nth (arb, i))))
				return FALSE;

		return TRUE;
	}

	return FALSE;
}
Пример #19
0
static void
tp_chat_properties_changed_cb (TpProxy         *proxy,
			       const GPtrArray *properties,
			       gpointer         user_data,
			       GObject         *chat)
{
	EmpathyTpChatPriv *priv = GET_PRIV (chat);
	guint              i, j;

	if (priv->channel == NULL)
		return;

	if (!priv->had_properties_list || !properties) {
		return;
	}

	for (i = 0; i < properties->len; i++) {
		GValueArray    *prop_struct;
		TpChatProperty *property;
		guint           id;
		GValue         *src_value;

		prop_struct = g_ptr_array_index (properties, i);
		id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
		src_value = g_value_get_boxed (g_value_array_get_nth (prop_struct, 1));

		for (j = 0; j < priv->properties->len; j++) {
			property = g_ptr_array_index (priv->properties, j);
			if (property->id == id) {
				if (property->value) {
					g_value_copy (src_value, property->value);
				} else {
					property->value = tp_g_value_slice_dup (src_value);
				}

				DEBUG ("property %s changed", property->name);
				g_signal_emit (chat, signals[PROPERTY_CHANGED], 0,
					       property->name, property->value);
				break;
			}
		}
	}
}
Пример #20
0
static void g_value_email_free(gpointer data) {
	GValueArray* email = (GValueArray *) data;
	GValue* email_member;
	guint i;
	
	for (i = 0; i < email->n_values; i++) {
		email_member = g_value_array_get_nth(email, i);
		g_value_unset(email_member);
	}
}
/**
 * geoclue_accuracy_get_details:
 * @accuracy: A #GeoclueAccuracy
 * @level: Pointer to returned #GeoclueAccuracyLevel or %NULL
 * @horizontal_accuracy: Pointer to returned horizontal accuracy in meters or %NULL
 * @vertical_accuracy: Pointer to returned vertical accuracy in meters or %NULL
 *
 * @horizontal_accuracy and @vertical_accuracy will only be defined
 * if @level is %GEOCLUE_ACCURACY_LEVEL_DETAILED.
 */
void
geoclue_accuracy_get_details (GeoclueAccuracy      *accuracy,
			      GeoclueAccuracyLevel *level,
			      double               *horizontal_accuracy,
			      double               *vertical_accuracy)
{
	GValueArray *vals;

	vals = accuracy;
	if (level != NULL) {
		*level = g_value_get_int (g_value_array_get_nth (vals, 0));
	}
	if (horizontal_accuracy != NULL) {
		*horizontal_accuracy = g_value_get_double (g_value_array_get_nth (vals, 1));
	}
	if (vertical_accuracy != NULL) {
		*vertical_accuracy = g_value_get_double (g_value_array_get_nth (vals, 2));
	}
}
Пример #22
0
static void
ip6_route_writer (GKeyFile *file,
                  const char *keyfile_dir,
                  const char *uuid,
                  NMSetting *setting,
                  const char *key,
                  const GValue *value)
{
	GPtrArray *array;
	const char *setting_name = nm_setting_get_name (setting);
	char *list[3];
	int i, j;

	g_return_if_fail (G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE));

	array = (GPtrArray *) g_value_get_boxed (value);
	if (!array || !array->len)
		return;

	for (i = 0, j = 1; i < array->len; i++) {
		GValueArray *values = g_ptr_array_index (array, i);
		char *key_name;
		guint32 int_val;
		char buf[INET6_ADDRSTRLEN + 1];
		gboolean is_unspec = FALSE;

		memset (list, 0, sizeof (list));

		/* Address and prefix */
		list[0] = ip6_array_to_addr_prefix (values);
		if (!list[0])
			continue;

		/* Next Hop */
		if (!ip6_array_to_addr (values, 2, buf, sizeof (buf), &is_unspec))
			continue;
		if (is_unspec)
			continue;
		list[1] = g_strdup (buf);

		/* Metric */
		value = g_value_array_get_nth (values, 3);
		int_val = g_value_get_uint (value);
		list[2] = g_strdup_printf ("%d", int_val);

		/* Write it out */
		key_name = g_strdup_printf ("%s%d", key, j++);
		g_key_file_set_string_list (file, setting_name, key_name, (const char **) list, 3);
		g_free (key_name);

		g_free (list[0]);
		g_free (list[1]);
		g_free (list[2]);
	}
}
Пример #23
0
/**
 * gst_factory_list_filter:
 * @array: a #GValueArray to filter
 * @caps: a #GstCaps
 *
 * Filter out all the elementfactories in @array that can handle @caps as
 * input.
 *
 * Returns: a #GValueArray of #GstElementFactory elements. Use
 * g_value_array_free() after usage.
 */
GValueArray *
gst_factory_list_filter (GValueArray * array, const GstCaps * caps)
{
  GValueArray *result;
  gint i;

  result = g_value_array_new (0);

  GST_DEBUG ("finding factories");

  /* loop over all the factories */
  for (i = 0; i < array->n_values; i++) {
    GValue *value;
    GstElementFactory *factory;
    const GList *templates;
    GList *walk;

    value = g_value_array_get_nth (array, i);
    factory = g_value_get_object (value);

    /* get the templates from the element factory */
    templates = gst_element_factory_get_static_pad_templates (factory);
    for (walk = (GList *) templates; walk; walk = g_list_next (walk)) {
      GstStaticPadTemplate *templ = walk->data;

      /* we only care about the sink templates */
      if (templ->direction == GST_PAD_SINK) {
        GstCaps *intersect;
        GstCaps *tmpl_caps;

        /* try to intersect the caps with the caps of the template */
        tmpl_caps = gst_static_caps_get (&templ->static_caps);

        /* FIXME, intersect is not the right method, we ideally want to check
         * for a subset here */
        intersect = gst_caps_intersect (caps, tmpl_caps);
        gst_caps_unref (tmpl_caps);

        /* check if the intersection is empty */
        if (!gst_caps_is_empty (intersect)) {
          /* non empty intersection, we can use this element */
          GValue resval = { 0, };
          g_value_init (&resval, G_TYPE_OBJECT);
          g_value_set_object (&resval, factory);
          g_value_array_append (result, &resval);
          g_value_unset (&resval);
          gst_caps_unref (intersect);
          break;
        }
        gst_caps_unref (intersect);
      }
    }
  }
  return result;
}
Пример #24
0
//! memasukkan item ke widget , biasanya dipakai di proses editing
static void modifSetItemToWidget(modifStruct_* modif,GValueArray* hasil){
	//! hari
	GValue *ii = g_value_array_get_nth (hasil	,1 );
	globalSetCurrentIndexCombo(modif->hari , g_value_get_string(ii));
	//!jam dan  menit
	ii = g_value_array_get_nth (hasil	,2 );
	gchar **kalender = g_strsplit_set(g_value_get_string(ii),":",-1);		//is equivalent to ``%H:%M:%S'
	gtk_spin_button_set_value( modif->jam,globalConStrToInt(kalender[0]) );
	gtk_spin_button_set_value( modif->mnt,globalConStrToInt(kalender[1]) );
	g_strfreev (kalender);
	//! bagian
	ii = g_value_array_get_nth (hasil	,3 );
	globalSetCurrentIndexCombo(modif->bagian , g_value_get_string(ii) );
	//! total bunyi
	ii = g_value_array_get_nth (hasil	,4 );
	gtk_spin_button_set_value( modif->total , globalConStrToInt(g_value_get_string(ii))  );
	//! nama file
	ii = g_value_array_get_nth (hasil	,5 );
	gtk_button_set_label(modif->filePilih , g_value_get_string(ii) );
}
Пример #25
0
/*
char* databaseGetDataFromDb(char* sql , GValueArray *where){
	char *tail, *hasil;
	int rc = sqlite3_prepare(sqlite->db, sql, strlen(sql), &sqlite->stmt, &tail);
	if(rc==SQLITE_OK){	
		int ema;
		for(ema=0;ema<1;ema++){
			GValue*  value  = g_value_array_get_nth (where,ema);
			if(G_VALUE_TYPE(value) == G_TYPE_INT){
				sqlite3_bind_int(sqlite->stmt	, ema+1	, g_value_get_int(value)	);
			}
			else if( G_VALUE_TYPE(value) == G_TYPE_STRING ){
				char * tmp = g_value_get_string(value);
				sqlite3_bind_text(sqlite->stmt	, ema+1	, tmp , strlen(tmp), SQLITE_TRANSIENT 	);
			}
		}
//		gint ncols = sqlite3_column_count(sqlite->stmt);
		sqlite3_step(sqlite->stmt);
		hasil = g_strdup_printf ("%s", sqlite3_column_text(sqlite->stmt, 0) ) ;
	}
	else{
		fprintf(stderr, "sqlite3_prepare() : Error: %s\n", tail);
	}
	sqlite3_finalize(sqlite->stmt);	
	return hasil;
}
*/
GValueArray *databaseGetDatasFromDb(char* sql , GValueArray *where , gboolean *status ){
	status = FALSE;
	GValueArray* hasil = 	g_value_array_new (-1);
	char *tail;
	int rc = sqlite3_prepare(sqlite->db, sql, strlen(sql), &sqlite->stmt, &tail);
	if(rc==SQLITE_OK){	
		status = TRUE;
		int ema;
		if(where != NULL){
			for(ema=0;ema<where->n_values;ema++){
				GValue*  value  = g_value_array_get_nth (where,ema);
				if(G_VALUE_TYPE(value) == G_TYPE_INT){
					sqlite3_bind_int(sqlite->stmt	, ema+1	, g_value_get_int(value)	);
				}
				else if( G_VALUE_TYPE(value) == G_TYPE_STRING ){
					char * tmp = g_value_get_string(value);
					sqlite3_bind_text(sqlite->stmt	, ema+1	, tmp , strlen(tmp), SQLITE_TRANSIENT 	);
				}
			}
		}
		int ncols = sqlite3_column_count(sqlite->stmt);
		rc = sqlite3_step(sqlite->stmt);
		//! Print column information
		int i;
		while(rc == SQLITE_ROW) {
			for(i=0; i < ncols; i++) {
				GValue a = {0};
				g_assert (!G_VALUE_HOLDS_STRING (&a));			
				int type = sqlite3_column_type(sqlite->stmt, i);
				if(type==SQLITE_INTEGER){
						g_value_init (&a, G_TYPE_INT);
						int tmp = sqlite3_column_int(sqlite->stmt, i);
						g_value_set_int (&a, 1);
				}
				else if(type==SQLITE_FLOAT){
					g_value_init (&a, G_TYPE_FLOAT);
				}
				else if(type==SQLITE_TEXT){
					char *tmp = g_strdup_printf ("%s", sqlite3_column_text(sqlite->stmt, i) );
					g_value_init (&a, G_TYPE_STRING);
					g_value_set_string (&a, tmp);
					g_free(tmp);
				}
				hasil =	g_value_array_append(hasil,&a);
			}
			rc = sqlite3_step(sqlite->stmt);
		}
	}
	else{
		fprintf(stderr, "sqlite3_prepare() : Error: %s\n", tail);
	}
	sqlite3_finalize(sqlite->stmt);	
	return hasil;
}
static void 
__get_expression_value (GdaConnection *cnc, GValue *src, GString *str)
{
	gchar *escaped_string = NULL;
	switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (src))) {
	
		case G_TYPE_STRING:
			escaped_string = gda_connection_value_to_sql_string(cnc, src);
			g_string_append_printf (str, "%s", escaped_string);
			g_free(escaped_string);
			break;

		case G_TYPE_UINT:
			  g_string_append_printf (str, "%d", g_value_get_uint (src));
			  break;

		case G_TYPE_INT:
			  g_string_append_printf (str, "%d", g_value_get_int (src));
			  break;

		case G_TYPE_FLOAT:
			  g_string_append_printf (str, "%.04f", g_value_get_float (src));
			  break;

		case G_TYPE_BOOLEAN:
			  g_string_append_printf (str, "%d", g_value_get_boolean (src));
			  break;

		case G_TYPE_BOXED:
			  if (G_VALUE_TYPE (src) == G_TYPE_VALUE_ARRAY) {
				GValueArray *array = (GValueArray *) g_value_get_boxed (src);
				if (!array) {
					/* FIXME, add this to validate */
					g_warning ("Empty array given");
					return;
				}
				guint i;
				for (i = 0; i < array->n_values; i++) {
					if (i > 0)
						g_string_append (str, ", ");
					__get_expression_value (cnc, g_value_array_get_nth (array, i), str);
				}
			} else {
				/*FIXME, add this to validate */
				g_warning ("BOXED type '%s' not implemented \n", G_VALUE_TYPE_NAME (src));
			}
			break;

		default:
			break;
	}

	return;
}
static void
gst_audio_iir_filter_update_coefficients (GstAudioIIRFilter * self,
    GValueArray * va, GValueArray * vb)
{
  gdouble *a = NULL, *b = NULL;
  guint i;

  if (va) {
    if (self->a)
      g_value_array_free (self->a);

    self->a = va;
  }
  if (vb) {
    if (self->b)
      g_value_array_free (self->b);

    self->b = vb;
  }

  if (self->a && self->a->n_values > 0) {
    a = g_new (gdouble, self->a->n_values);

    for (i = 0; i < self->a->n_values; i++) {
      GValue *v = g_value_array_get_nth (self->a, i);
      a[i] = g_value_get_double (v);
    }
  }

  if (self->b && self->b->n_values > 0) {
    b = g_new (gdouble, self->b->n_values);
    for (i = 0; i < self->b->n_values; i++) {
      GValue *v = g_value_array_get_nth (self->b, i);
      b[i] = g_value_get_double (v);
    }
  }

  gst_audio_fx_base_iir_filter_set_coefficients (GST_AUDIO_FX_BASE_IIR_FILTER
      (self), a, (self->a) ? self->a->n_values : 0, b,
      (self->b) ? self->b->n_values : 0);
}
Пример #28
0
static void
clutter_list_model_iter_set_value (ClutterModelIter *iter,
                                   guint             column,
                                   const GValue     *value)
{
  ClutterListModelIter *iter_default;
  GValueArray *value_array;
  GValue *iter_value;
  GValue real_value = { 0, };
  gboolean converted = FALSE;

  iter_default = CLUTTER_LIST_MODEL_ITER (iter);
  g_assert (iter_default->seq_iter != NULL);

  value_array = g_sequence_get (iter_default->seq_iter);
  iter_value = g_value_array_get_nth (value_array, column);
  g_assert (iter_value != NULL);

  if (!g_type_is_a (G_VALUE_TYPE (value), G_VALUE_TYPE (iter_value)))
    {
      if (!g_value_type_compatible (G_VALUE_TYPE (value), 
                                    G_VALUE_TYPE (iter_value)) &&
          !g_value_type_compatible (G_VALUE_TYPE (iter_value), 
                                    G_VALUE_TYPE (value)))
        {
          g_warning ("%s: Unable to convert from %s to %s\n",
                     G_STRLOC,
                     g_type_name (G_VALUE_TYPE (value)),
                     g_type_name (G_VALUE_TYPE (iter_value)));
          return;
        }

      if (!g_value_transform (value, &real_value))
        {
          g_warning ("%s: Unable to make conversion from %s to %s\n",
                     G_STRLOC, 
                     g_type_name (G_VALUE_TYPE (value)),
                     g_type_name (G_VALUE_TYPE (iter_value)));
          g_value_unset (&real_value);
        }

      converted = TRUE;
    }
 
  if (converted)
    {
      g_value_copy (&real_value, iter_value);
      g_value_unset (&real_value);
    }
  else
    g_value_copy (value, iter_value);
}
Пример #29
0
/* Check if the given pattern matches part of the given trie, returning an
 * empty string on a partial initial match, a %NULL if there's no match in the
 * works, and the result string if we have an exact match. */
TRIE_MAYBE_STATIC const char *
_vte_trie_match(struct _vte_trie *trie, const gunichar *pattern, gsize length,
		const char **res, const gunichar **consumed,
		GQuark *quark, GValueArray **array)
{
	const char *ret = NULL;
	GQuark tmpquark;
	GValueArray *valuearray;
	GValue *value;
	const gunichar *dummyconsumed;
	gboolean greedy = FALSE;
	guint i;

	if (array != NULL && *array != NULL) {
		valuearray = *array;
	} else {
		valuearray = g_value_array_new(0);
	}
	if (quark == NULL) {
		quark = &tmpquark;
	}
	*quark = 0;

	if (consumed == NULL) {
		consumed = &dummyconsumed;
	}
	*consumed = pattern;

	ret = _vte_trie_matchx(trie, pattern, length, greedy,
			       res, consumed, quark, valuearray);

	if (((ret == NULL) || (ret[0] == '\0')) || (valuearray->n_values == 0)){
		if (valuearray != NULL) {
			for (i = 0; i < valuearray->n_values; i++) {
				value = g_value_array_get_nth(valuearray, i);
				if (G_VALUE_HOLDS_POINTER(value)) {
					g_free(g_value_get_pointer(value));
					g_value_set_pointer(value, NULL);
				}
			}
			if (array == NULL || valuearray != *array) {
				_vte_matcher_free_params_array(NULL, valuearray);
			}
		}
	} else {
		if (array == NULL) {
			_vte_matcher_free_params_array(NULL, valuearray);
		}
	}

	return ret;
}
Пример #30
0
static void
tp_contact_factory_got_capabilities (TpConnection    *connection,
				     const GPtrArray *capabilities,
				     const GError    *error,
				     gpointer         user_data,
				     GObject         *weak_object)
{
	EmpathyTpContactFactory *tp_factory;
	guint i;

	tp_factory = EMPATHY_TP_CONTACT_FACTORY (weak_object);

	if (error) {
		DEBUG ("Error: %s", error->message);
		/* FIXME Should set the capabilities of the contacts for which this request
		 * originated to NONE */
		return;
	}

	for (i = 0; i < capabilities->len; i++)	{
		GValueArray *values;
		guint        handle;
		const gchar *channel_type;
		guint        generic;
		guint        specific;

		values = g_ptr_array_index (capabilities, i);
		handle = g_value_get_uint (g_value_array_get_nth (values, 0));
		channel_type = g_value_get_string (g_value_array_get_nth (values, 1));
		generic = g_value_get_uint (g_value_array_get_nth (values, 2));
		specific = g_value_get_uint (g_value_array_get_nth (values, 3));

		tp_contact_factory_update_capabilities (tp_factory,
							handle,
							channel_type,
							generic,
							specific);
	}
}