Beispiel #1
0
static gboolean
gst_gl_mixer_start (GstAggregator * agg)
{
  guint i;
  GstGLMixer *mix = GST_GL_MIXER (agg);
  GstElement *element = GST_ELEMENT (agg);

  if (!GST_AGGREGATOR_CLASS (parent_class)->start (agg))
    return FALSE;

  GST_OBJECT_LOCK (mix);
  mix->array_buffers = g_ptr_array_new_full (element->numsinkpads,
      (GDestroyNotify) _free_glmixer_frame_data);
  mix->frames = g_ptr_array_new_full (element->numsinkpads, NULL);

  g_ptr_array_set_size (mix->array_buffers, element->numsinkpads);
  g_ptr_array_set_size (mix->frames, element->numsinkpads);

  for (i = 0; i < element->numsinkpads; i++)
    mix->frames->pdata[i] = g_slice_new0 (GstGLMixerFrameData);

  GST_OBJECT_UNLOCK (mix);

  return TRUE;
}
static gboolean
gst_gl_stereo_mix_start (GstAggregator * agg)
{
  guint i;
  GstGLStereoMix *mix = GST_GL_STEREO_MIX (agg);
  GstElement *element = GST_ELEMENT (agg);

  if (!GST_AGGREGATOR_CLASS (parent_class)->start (agg))
    return FALSE;

  GST_OBJECT_LOCK (mix);
  mix->array_buffers = g_ptr_array_new_full (element->numsinkpads,
      (GDestroyNotify) _free_glmixer_frame_data);
  mix->frames = g_ptr_array_new_full (element->numsinkpads, NULL);

  g_ptr_array_set_size (mix->array_buffers, element->numsinkpads);
  g_ptr_array_set_size (mix->frames, element->numsinkpads);

  for (i = 0; i < element->numsinkpads; i++)
    mix->frames->pdata[i] = g_slice_new0 (GstGLStereoMixFrameData);

  mix->viewconvert = gst_gl_view_convert_new ();
  g_object_set (G_OBJECT (mix->viewconvert), "downmix-mode",
      mix->downmix_mode, NULL);

  GST_OBJECT_UNLOCK (mix);

  return TRUE;
}
static void
ide_editor_surface_actions_close_all (GSimpleAction *action,
                                      GVariant      *param,
                                      gpointer       user_data)
{
  IdeEditorSurface *self = user_data;
  g_autoptr(GPtrArray) views = NULL;

  g_assert (G_IS_SIMPLE_ACTION (action));
  g_assert (IDE_IS_EDITOR_SURFACE (self));

  /* First collect all the views and hold a reference to them
   * so that we do not need to worry about contains being destroyed
   * as we work through the list.
   */
  views = g_ptr_array_new_full (0, g_object_unref);
  ide_grid_foreach_page (self->grid, collect_pages, views);

  for (guint i = 0; i < views->len; i++)
    {
      IdePage *view = g_ptr_array_index (views, i);

      /* TODO: Should we allow suspending the close with
       *       agree_to_close_async()?
       */

      gtk_widget_destroy (GTK_WIDGET (view));
    }
}
Beispiel #4
0
/* names: list of gchar, values: list of gint */
static gboolean barebox_state_set(GPtrArray *pairs) {
	GSubprocess *sub;
	GError *error = NULL;
	gboolean res = FALSE;
	GPtrArray *args = g_ptr_array_new_full(2*pairs->len+2, g_free);

	g_assert_cmpuint(pairs->len, >, 0);
	
	g_ptr_array_add(args, g_strdup(BAREBOX_STATE_NAME));
	for (guint i = 0; i < pairs->len; i++) {
		g_ptr_array_add(args, g_strdup("-s"));
		g_ptr_array_add(args, g_strdup(pairs->pdata[i]));
	}
	g_ptr_array_add(args, NULL);

	sub = g_subprocess_newv((const gchar * const *)args->pdata,
				  G_SUBPROCESS_FLAGS_NONE, &error);
	if (!sub) {
		g_warning("getting state failed: %s", error->message);
		g_clear_error(&error);
		goto out;
	}

	res = g_subprocess_wait_check(sub, NULL, &error);
	if (!res) {
		g_warning("setting state failed: %s", error->message);
		g_clear_error(&error);
		goto out;
	}

out:
	g_ptr_array_unref(args);
	return res;
}
Beispiel #5
0
/* Set slot status values */
static gboolean grub_set_state(RaucSlot *slot, gboolean good) {
	GPtrArray *pairs = g_ptr_array_new_full(10, g_free);
	gboolean res = FALSE;

	g_assert_nonnull(slot);

	if (good) {
		g_ptr_array_add(pairs, g_strdup_printf("%s_OK=1", slot->bootname));
		g_ptr_array_add(pairs, g_strdup_printf("%s_TRY=0", slot->bootname));
	} else {
		g_ptr_array_add(pairs, g_strdup_printf("%s_OK=0", slot->bootname));
		g_ptr_array_add(pairs, g_strdup_printf("%s_TRY=0", slot->bootname));
	}

	res = grub_env_set(pairs);
	if (!res) {
		g_warning("failed marking as %s", good ? "good" : "bad");
		goto out;
	}

	res = TRUE;
out:
	g_ptr_array_unref(pairs);
	return res;
}
Beispiel #6
0
/* Set slot status values */
static gboolean barebox_set_state(RaucSlot *slot, gboolean good) {
	gboolean res = FALSE;
	GPtrArray *pairs = g_ptr_array_new_full(10, g_free);
	int prio, attempts;

	g_assert_nonnull(slot);

	if (good) {
		prio = 20;
		attempts = 3;
	} else {
		prio = 0;
		attempts = 0;
	}

	g_ptr_array_add(pairs, g_strdup_printf("%s.%s.priority=%i",
			BOOTSTATE_PREFIX, slot->bootname, prio));
	g_ptr_array_add(pairs, g_strdup_printf("%s.%s.remaining_attempts=%i",
			BOOTSTATE_PREFIX, slot->bootname, attempts));

	res = barebox_state_set(pairs);
	if (!res) {
		g_warning("failed marking as %s", good ? "good" : "bad");
		goto out;
	}

	res = TRUE;
out:
	g_ptr_array_unref(pairs);
	return res;
}
Beispiel #7
0
bool deser_msg_addr(unsigned int protover, struct msg_addr *ma,
		    struct const_buffer *buf)
{
	memset(ma, 0, sizeof(*ma));

	uint32_t vlen;
	if (!deser_varlen(&vlen, buf)) return false;

	ma->addrs = g_ptr_array_new_full(vlen, g_free);

	unsigned int i;
	for (i = 0; i < vlen; i++) {
		struct bp_address *addr;

		addr = calloc(1, sizeof(*addr));
		if (!deser_bp_addr(protover, addr, buf)) {
			free(addr);
			goto err_out;
		}

		g_ptr_array_add(ma->addrs, addr);
	}

	return true;

err_out:
	msg_addr_free(ma);
	return false;
}
Beispiel #8
0
bool deser_msg_vinv(struct msg_vinv *mv, struct const_buffer *buf)
{
	msg_vinv_free(mv);

	uint32_t vlen;
	if (!deser_varlen(&vlen, buf)) return false;

	mv->invs = g_ptr_array_new_full(vlen, g_free);

	unsigned int i;
	for (i = 0; i < vlen; i++) {
		struct bp_inv *inv;

		inv = calloc(1, sizeof(*inv));
		if (!deser_bp_inv(inv, buf)) {
			free(inv);
			goto err_out;
		}

		g_ptr_array_add(mv->invs, inv);
	}

	return true;

err_out:
	msg_vinv_free(mv);
	return false;
}
static void
parser_cdma_end (MobileParser *parser,
                 const char *name)
{
	if (!strcmp (name, "username")) {
		parser->current_method->username = parser->text_buffer;
		parser->text_buffer = NULL;
	} else if (!strcmp (name, "password")) {
		parser->current_method->password = parser->text_buffer;
		parser->text_buffer = NULL;
	} else if (!strcmp (name, "dns")) {
		if (!parser->current_method->dns)
			parser->current_method->dns = g_ptr_array_new_full (2, g_free);
		g_ptr_array_add (parser->current_method->dns, parser->text_buffer);
		parser->text_buffer = NULL;
	} else if (!strcmp (name, "gateway")) {
		parser->current_method->gateway = parser->text_buffer;
		parser->text_buffer = NULL;
	} else if (!strcmp (name, "cdma")) {
		parser->current_method->family = NMA_MOBILE_FAMILY_CDMA;

		if (!parser->current_method->name)
			parser->current_method->name = g_strdup (parser->current_provider->name);

		if (parser->current_method->dns)
			g_ptr_array_add (parser->current_method->dns, NULL);

		parser->current_provider->methods = g_slist_prepend (parser->current_provider->methods,
		                                                     parser->current_method);
		parser->current_method = NULL;
		g_free (parser->text_buffer);
		parser->text_buffer = NULL;
		parser->state = PARSER_PROVIDER;
	}
}
Beispiel #10
0
static void
gnm_so_path_copy (SheetObject *dst, SheetObject const *src)
{
	GnmSOPath const *sop = GNM_SO_PATH (src);
	GnmSOPath   *new_sop = GNM_SO_PATH (dst);

	g_object_unref (new_sop->style);
	new_sop->style = go_style_dup (sop->style);
	new_sop->x_offset = sop->x_offset;
	new_sop->y_offset = sop->y_offset;
	new_sop->width = sop->width;
	new_sop->height = sop->height;
	if (new_sop->path) {
		go_path_free (new_sop->path);
		new_sop->path = NULL;
	} else if (new_sop->paths) {
		g_ptr_array_unref (new_sop->paths);
		new_sop->paths = NULL;
	}
	if (sop->path)
		new_sop->path = go_path_ref (sop->path);
	else {
		unsigned i;
		new_sop->paths = g_ptr_array_new_full (sop->paths->len,
		                                       (GDestroyNotify) go_path_free);
		for (i = 0; i < sop->paths->len; i++)
			g_ptr_array_add (new_sop->paths, go_path_ref (g_ptr_array_index (sop->paths, i)));
	}
	gnm_so_path_parent_class->copy (dst, src);
}
/* Initialize NmCli structure - set default values */
static void
nmc_init (NmCli *nmc)
{
	nmc->client = NULL;
	nmc->get_client = &nmc_get_client;

	nmc->return_value = NMC_RESULT_SUCCESS;
	nmc->return_text = g_string_new (_("Success"));

	nmc->timeout = -1;

	nmc->connections = NULL;

	nmc->secret_agent = NULL;
	nmc->pwds_hash = NULL;
	nmc->pk_listener = NULL;

	nmc->should_wait = FALSE;
	nmc->nowait_flag = TRUE;
	nmc->print_output = NMC_PRINT_NORMAL;
	nmc->multiline_output = FALSE;
	nmc->mode_specified = FALSE;
	nmc->escape_values = TRUE;
	nmc->required_fields = NULL;
	nmc->output_data = g_ptr_array_new_full (20, g_free);
	memset (&nmc->print_fields, '\0', sizeof (NmcPrintFields));
	nmc->nocheck_ver = FALSE;
	nmc->ask = FALSE;
	nmc->use_colors = NMC_USE_COLOR_AUTO;
	nmc->in_editor = FALSE;
	nmc->editor_status_line = FALSE;
	nmc->editor_save_confirmation = TRUE;
	nmc->editor_show_secrets = FALSE;
	nmc->editor_prompt_color = NMC_TERM_COLOR_NORMAL;
}
/**
 * gst_rtsp_session_media_new:
 * @path: the path
 * @media: (transfer full): the #GstRTSPMedia
 *
 * Create a new #GstRTSPSessionMedia that manages the streams
 * in @media for @path. @media should be prepared.
 *
 * Ownership is taken of @media.
 *
 * Returns: (transfer full): a new #GstRTSPSessionMedia.
 */
GstRTSPSessionMedia *
gst_rtsp_session_media_new (const gchar * path, GstRTSPMedia * media)
{
  GstRTSPSessionMediaPrivate *priv;
  GstRTSPSessionMedia *result;
  guint n_streams;
  GstRTSPMediaStatus status;

  g_return_val_if_fail (path != NULL, NULL);
  g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
  status = gst_rtsp_media_get_status (media);
  g_return_val_if_fail (status == GST_RTSP_MEDIA_STATUS_PREPARED || status ==
      GST_RTSP_MEDIA_STATUS_SUSPENDED, NULL);

  result = g_object_new (GST_TYPE_RTSP_SESSION_MEDIA, NULL);
  priv = result->priv;

  priv->path = g_strdup (path);
  priv->path_len = strlen (path);
  priv->media = media;

  /* prealloc the streams now, filled with NULL */
  n_streams = gst_rtsp_media_n_streams (media);
  priv->transports = g_ptr_array_new_full (n_streams, free_session_media);
  g_ptr_array_set_size (priv->transports, n_streams);

  return result;
}
Beispiel #13
0
bool deser_msg_headers(struct msg_headers *mh, struct const_buffer *buf)
{
	msg_headers_free(mh);

	uint32_t vlen;
	if (!deser_varlen(&vlen, buf)) return false;

	mh->headers = g_ptr_array_new_full(vlen, g_free);

	unsigned int i;
	for (i = 0; i < vlen; i++) {
		struct bp_block *block;

		block = calloc(1, sizeof(*block));
		if (!deser_bp_block(block, buf)) {
			free(block);
			goto err_out;
		}

		g_ptr_array_add(mh->headers, block);
	}

	return true;

err_out:
	msg_headers_free(mh);
	return false;
}
Beispiel #14
0
gboolean test_do_chmod(const gchar *path) {
	GSubprocess *sub;
	GError *error = NULL;
	gboolean res = FALSE;
	GPtrArray *args = g_ptr_array_new_full(10, g_free);
	
	if (getuid() != 0) {
		g_ptr_array_add(args, g_strdup("sudo"));
		g_ptr_array_add(args, g_strdup("--non-interactive"));
	}
	g_ptr_array_add(args, g_strdup("chmod"));
	g_ptr_array_add(args, g_strdup("777"));
	g_ptr_array_add(args, g_strdup(path));
	g_ptr_array_add(args, NULL);

	sub = g_subprocess_newv((const gchar * const *)args->pdata,
				  G_SUBPROCESS_FLAGS_NONE, &error);
	if (!sub) {
		g_warning("chmod failed: %s", error->message);
		g_clear_error(&error);
		goto out;
	}

	res = g_subprocess_wait_check(sub, NULL, &error);
	if (!res) {
		g_warning("chmod failed: %s", error->message);
		g_clear_error(&error);
		goto out;
	}

out:
	g_ptr_array_unref(args);
	return res;
}
gboolean
gst_vaapiencode_init_properties (GstVaapiEncode * encode)
{
  GPtrArray *const props = get_properties (GST_VAAPIENCODE_GET_CLASS (encode));
  guint i;

  /* XXX: use base_init()/base_finalize() to avoid multiple initializations */
  if (!props)
    return FALSE;

  encode->prop_values =
      g_ptr_array_new_full (props->len, (GDestroyNotify) prop_value_free);
  if (!encode->prop_values) {
    g_ptr_array_unref (props);
    return FALSE;
  }

  for (i = 0; i < props->len; i++) {
    PropValue *const prop_value = prop_value_new ((GstVaapiEncoderPropInfo *)
        g_ptr_array_index (props, i));
    if (!prop_value)
      return FALSE;
    g_ptr_array_add (encode->prop_values, prop_value);
  }
  return TRUE;
}
Beispiel #16
0
static GPtrArray *
copy_files (GPtrArray *in)
{
  GPtrArray *out = g_ptr_array_new_full (in->len, g_object_unref);
  for (guint i = 0; i < in->len; i++)
    g_ptr_array_add (out, g_file_dup (g_ptr_array_index (in, i)));
  return g_steal_pointer (&out);
}
GPtrArray *token_list_clone(GPtrArray *token_list) {
    GPtrArray *token_list_clone = g_ptr_array_new_full(token_list->len,
                                                       token_free_func);
    for (gsize i = 0; i < token_list->len; ++i) {
        g_ptr_array_add(token_list_clone,
                        token_clone(g_ptr_array_index(token_list, i)));
    }
    return token_list_clone;
}
static GPtrArray *
parse_sendmail_args (const gchar *binary,
                     const gchar *args,
                     const gchar *from_addr,
                     CamelAddress *recipients)
{
	GPtrArray *args_arr;
	gint ii, len, argc = 0;
	gchar **argv = NULL;

	g_return_val_if_fail (binary != NULL, NULL);
	g_return_val_if_fail (args != NULL, NULL);
	g_return_val_if_fail (from_addr != NULL, NULL);

	len = camel_address_length (recipients);

	args_arr = g_ptr_array_new_full (5, g_free);
	g_ptr_array_add (args_arr, g_strdup (binary));

	if (args && g_shell_parse_argv (args, &argc, &argv, NULL) && argc > 0 && argv) {
		for (ii = 0; ii < argc; ii++) {
			const gchar *arg = argv[ii];

			if (g_strcmp0 (arg, "%F") == 0) {
				g_ptr_array_add (args_arr, g_strdup (from_addr));
			} else if (g_strcmp0 (arg, "%R") == 0) {
				gint jj;

				for (jj = 0; jj < len; jj++) {
					const gchar *addr = NULL;

					if (!camel_internet_address_get (
						CAMEL_INTERNET_ADDRESS (recipients), jj, NULL, &addr)) {

						/* should not happen, as the array is checked beforehand */

						g_ptr_array_free (args_arr, TRUE);
						g_strfreev (argv);

						return NULL;
					}

					g_ptr_array_add (args_arr, g_strdup (addr));
				}
			} else {
				g_ptr_array_add (args_arr, g_strdup (arg));
			}
		}

		g_strfreev (argv);
	}

	g_ptr_array_add (args_arr, NULL);

	return args_arr;
}
Beispiel #19
0
/**
 * gdk_pixbuf_remove_option:
 * @pixbuf: a #GdkPixbuf
 * @key: a nul-terminated string representing the key to remove.
 *
 * Remove the key/value pair option attached to a #GdkPixbuf.
 *
 * Return value: %TRUE if an option was removed, %FALSE if not.
 *
 * Since: 2.36
 **/
gboolean
gdk_pixbuf_remove_option (GdkPixbuf   *pixbuf,
                          const gchar *key)
{
        GQuark  quark;
        gchar **options;
        guint n;
        GPtrArray *array;
        gboolean found;

        g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
        g_return_val_if_fail (key != NULL, FALSE);

        quark = g_quark_from_static_string ("gdk_pixbuf_options");

        options = g_object_get_qdata (G_OBJECT (pixbuf), quark);
        if (!options)
                return FALSE;

        g_object_steal_qdata (G_OBJECT (pixbuf), quark);

        /* There's at least a nul-terminator */
        array = g_ptr_array_new_full (1, g_free);

        found = FALSE;
        for (n = 0; options[2*n]; n++) {
                if (strcmp (options[2*n], key) != 0) {
                        g_ptr_array_add (array, g_strdup (options[2*n]));   /* key */
                        g_ptr_array_add (array, g_strdup (options[2*n+1])); /* value */
                } else {
                        found = TRUE;
                }
        }

        if (array->len == 0) {
                g_ptr_array_unref (array);
                g_strfreev (options);
                return found;
        }

        if (!found) {
                g_ptr_array_free (array, TRUE);
                g_object_set_qdata_full (G_OBJECT (pixbuf), quark,
                                         options, (GDestroyNotify) g_strfreev);
                return FALSE;
        }

        g_ptr_array_add (array, NULL);
        g_object_set_qdata_full (G_OBJECT (pixbuf), quark,
                                 g_ptr_array_free (array, FALSE), (GDestroyNotify) g_strfreev);
        g_strfreev (options);

        return TRUE;
}
Beispiel #20
0
static GPtrArray *create_buses(guint count)
{
    GPtrArray *buses;
    guint i;

    buses = g_ptr_array_new_full(count, (GDestroyNotify) g_object_unref);
    for (i = 0; i < count; i++) {
        g_ptr_array_add(buses, owr_bus_new());
    }
    return buses;
}
Beispiel #21
0
void msg_vinv_push(struct msg_vinv *mv, uint32_t msg_type,
		   const bu256_t *hash_in)
{
	if (!mv->invs)
		mv->invs = g_ptr_array_new_full(512, g_free);

	struct bp_inv *inv = malloc(sizeof(struct bp_inv));
	inv->type = msg_type;
	bu256_copy(&inv->hash, hash_in);

	g_ptr_array_add(mv->invs, inv);
}
Beispiel #22
0
static void test_mass_messaging()
{
    GPtrArray *buses;
    GPtrArray *origins;
    GAsyncQueue *queue;
    GAsyncQueue *unref_queue;
    const guint size = 20;
    guint i;

    queue = g_async_queue_new();
    unref_queue = g_async_queue_new();

    buses = g_ptr_array_new_full(size, (GDestroyNotify) g_object_unref);
    origins = g_ptr_array_new_full(size, (GDestroyNotify) g_object_unref);

    for (i = 0; i < size; i++) {
        g_ptr_array_add(buses, owr_bus_new());
        g_ptr_array_add(origins, mock_origin_new());
    }

    g_ptr_array_foreach(origins, (GFunc) add_buses, buses);
    g_ptr_array_foreach(buses, (GFunc) add_callback, queue);
    g_ptr_array_foreach(origins, (GFunc) post_messages, NULL);
    pop_queue_n_times(queue, size * size);

    g_ptr_array_foreach(origins, (GFunc) post_messages_from_new_thread, NULL);
    pop_queue_n_times(queue, size * size);

    g_ptr_array_foreach(buses, (GFunc) add_object_to_unref_queue, unref_queue);

    g_ptr_array_foreach(origins, (GFunc) mock_origin_assert_bus_table_size, GUINT_TO_POINTER(size));
    g_ptr_array_foreach(origins, (GFunc) post_messages_from_new_thread, NULL);
    g_ptr_array_foreach(origins, (GFunc) post_messages, NULL);
    g_ptr_array_foreach(buses, (GFunc) unref_bus_from_new_thread, NULL);

    pop_queue_n_times(unref_queue, size);

    g_ptr_array_foreach(origins, (GFunc) post_messages, NULL);
    g_ptr_array_foreach(origins, (GFunc) mock_origin_assert_bus_table_size, GUINT_TO_POINTER(0));
}
Beispiel #23
0
static void
ev_page_accessible_initialize_children (EvPageAccessible *self)
{
	EvView *view;
	EvMappingList *images;
	EvMappingList *links;
	EvMappingList *fields;
	GList *children = NULL;
	GList *list;

	if (self->priv->children_initialized)
		return;

	view = ev_page_accessible_get_view (self);
	if (!ev_page_cache_is_page_cached (view->page_cache, self->priv->page))
		return;

	self->priv->children_initialized = TRUE;

	links = ev_page_cache_get_link_mapping (view->page_cache, self->priv->page);
	images = ev_page_cache_get_image_mapping (view->page_cache, self->priv->page);
	fields = ev_page_cache_get_form_field_mapping (view->page_cache, self->priv->page);
	if (!links && !images && !fields)
		return;

	children = g_list_copy (ev_mapping_list_get_list (links));
	children = g_list_concat (children, g_list_copy (ev_mapping_list_get_list (images)));
	children = g_list_concat (children, g_list_copy (ev_mapping_list_get_list (fields)));

	children = g_list_sort (children, (GCompareFunc) compare_mappings);
	self->priv->children = g_ptr_array_new_full (g_list_length (children), (GDestroyNotify) g_object_unref);

	for (list = children; list && list->data; list = list->next) {
		EvMapping *mapping = list->data;
		AtkObject *child = NULL;

		if (links && ev_mapping_list_find (links, mapping->data)) {
			EvLinkAccessible *link = ev_link_accessible_new (self, EV_LINK (mapping->data), &mapping->area);
			AtkHyperlink *atk_link = atk_hyperlink_impl_get_hyperlink (ATK_HYPERLINK_IMPL (link));

			child = atk_hyperlink_get_object (atk_link, 0);
		} else if (images && ev_mapping_list_find (images, mapping->data))
			child = ATK_OBJECT (ev_image_accessible_new (self, EV_IMAGE (mapping->data), &mapping->area));
		else if (fields && ev_mapping_list_find (fields, mapping->data))
			child = ATK_OBJECT (ev_form_field_accessible_new (self, EV_FORM_FIELD (mapping->data), &mapping->area));

		if (child)
			g_ptr_array_add (self->priv->children, child);
	}

	g_list_free (children);
}
Beispiel #24
0
static gboolean barebox_state_get_int(const gchar* name, int *value) {
	GSubprocess *sub;
	GError *error = NULL;
	gboolean res = FALSE;
	GInputStream *instream;
	GDataInputStream *datainstream;
	gchar* outline;
	guint64 result = 0;
	GPtrArray *args = g_ptr_array_new_full(10, g_free);
	
	g_ptr_array_add(args, g_strdup(BAREBOX_STATE_NAME));
	g_ptr_array_add(args, g_strdup("-g"));
	g_ptr_array_add(args, g_strdup(name));
	g_ptr_array_add(args, NULL);

	sub = g_subprocess_newv((const gchar * const *)args->pdata,
				  G_SUBPROCESS_FLAGS_NONE, &error);
	if (!sub) {
		g_warning("getting state failed: %s", error->message);
		g_clear_error(&error);
		goto out;
	}

	instream = g_subprocess_get_stdout_pipe(sub);
	datainstream = g_data_input_stream_new(instream);

	outline = g_data_input_stream_read_line(datainstream, NULL, NULL, NULL);
	if (!outline) {
		g_warning("failed reading state");
		goto out;
	}


	result = g_ascii_strtoull(outline, NULL, 10);
	if (errno != 0) {
		g_warning("Invalid return value: '%s'\n", outline);
		goto out;
	}

	res = g_subprocess_wait_check(sub, NULL, &error);
	if (!res) {
		g_warning("getting state failed: %s", error->message);
		g_clear_error(&error);
		goto out;
	}

out:
	g_ptr_array_unref(args);
	*value = result;
	return res;
}
Beispiel #25
0
static GPtrArray *
ct_name_get_props (DonnaColumnType  *ct,
                   gpointer          data)
{
    GPtrArray *props;

    g_return_val_if_fail (DONNA_IS_COLUMN_TYPE_NAME (ct), NULL);

    props = g_ptr_array_new_full (2, g_free);
    g_ptr_array_add (props, g_strdup ("name"));
    g_ptr_array_add (props, g_strdup ("icon"));

    return props;
}
Beispiel #26
0
static void create_overlay_badges(MosesOverview* self)
{
    MosesOverviewPrivate* priv = self->priv;
    if (!priv->badges) {
        priv->badges = g_ptr_array_new_full(0, (GDestroyNotify)clutter_actor_destroy);

    } else if (priv->badges->len) {
        g_ptr_array_set_size(priv->badges, 0);
    }

    int order = 1;
    for (int i = 0; i < priv->clones->len; i++) {
        create_window_badge(self, g_ptr_array_index(priv->clones, i), order++);
    }
}
Beispiel #27
0
void
sample_set_metadata(Sample* sample, const char* str)
{
	if(sample->meta_data) g_ptr_array_unref(sample->meta_data);
	sample->meta_data = g_ptr_array_new_full(32, g_free);

	gchar** items = g_strsplit(str, "\n", 32);
	int i; for(i=0;i<g_strv_length(items);i++){
		gchar** split = g_strsplit(items[i], ":", 2);
		g_ptr_array_add(sample->meta_data, g_strdup(split[0]));
		g_ptr_array_add(sample->meta_data, g_strdup(split[1]));
		g_strfreev(split);
	}
	g_strfreev(items);
}
Beispiel #28
0
int ad_info_ffmpeg(void *sf, struct adinfo *nfo) {
	ffmpeg_audio_decoder *priv = (ffmpeg_audio_decoder*) sf;
	if (!priv) return -1;
	if (nfo) {
		nfo->sample_rate = priv->samplerate;
		nfo->channels    = priv->channels;
		nfo->frames      = priv->length;
		if (!nfo->sample_rate) return -1;
		nfo->length      = (nfo->frames * 1000) / nfo->sample_rate;
		nfo->bit_rate    = priv->formatContext->bit_rate;
		nfo->bit_depth   = 0;
		nfo->meta_data   = NULL;

		GPtrArray* tags = g_ptr_array_new_full(32, g_free);

		AVDictionaryEntry *tag = NULL;
		// Tags in container
		while ((tag = av_dict_get(priv->formatContext->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
			dbg(2, "FTAG: %s=%s", tag->key, tag->value);
			g_ptr_array_add(tags, g_utf8_strdown(tag->key, -1));
			g_ptr_array_add(tags, g_strdup(tag->value));
		}
		// Tags in stream
		tag = NULL;
		AVStream *stream = priv->formatContext->streams[priv->audioStream];
		while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
			dbg(2, "STAG: %s=%s", tag->key, tag->value);
			g_ptr_array_add(tags, g_utf8_strdown(tag->key, -1));
			g_ptr_array_add(tags, g_strdup(tag->value));
		}

		while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
			g_ptr_array_add(tags, g_utf8_strdown(tag->key, -1));
			g_ptr_array_add(tags, g_strdup(tag->value));
		}

		if(tags->len){
			// sort tags
			char* order[] = {"artist", "title", "album", "track", "date"};
			int p = 0;
			int i; for(i=0;i<G_N_ELEMENTS(order);i++) if(ad_metadata_array_set_tag_postion(tags, order[i], p)) p++;

			nfo->meta_data = tags;
		}else
			g_ptr_array_free(tags, true);
	}
	return 0;
}
Beispiel #29
0
struct rspamd_re_cache *
rspamd_re_cache_new (void)
{
	struct rspamd_re_cache *cache;

	cache = g_slice_alloc (sizeof (*cache));
	cache->re_classes = g_hash_table_new (g_int64_hash, g_int64_equal);
	cache->nre = 0;
	cache->re = g_ptr_array_new_full (256, rspamd_re_cache_elt_dtor);
#ifdef WITH_HYPERSCAN
	cache->hyperscan_loaded = FALSE;
#endif
	REF_INIT_RETAIN (cache, rspamd_re_cache_destroy);

	return cache;
}
Beispiel #30
0
static GPtrArray *
ct_text_get_props (DonnaColumnType  *ct,
                   gpointer          _data)
{
    struct tv_col_data *data = _data;
    GPtrArray *props;

    g_return_val_if_fail (DONNA_IS_COLUMN_TYPE_TEXT (ct), NULL);

    props = g_ptr_array_new_full ((data->property_tooltip) ? 2 : 1, g_free);
    g_ptr_array_add (props, g_strdup (data->property));
    if (data->property_tooltip)
        g_ptr_array_add (props, g_strdup (data->property_tooltip));

    return props;
}