コード例 #1
0
ファイル: certs.c プロジェクト: dagwieers/eid-mw
static enum eid_vwr_result check_cert(char* which) {
	GtkTreeIter *cert_iter = get_iter_for(which);
	GtkTreeIter *ca_iter;
	GByteArray *cert, *ca_cert;
	GValue *val_cert, *val_ca, *val_root;
	int *col_cert, *col_ca, *col_root;
	enum eid_vwr_result verify_result;

	ca_iter = get_iter_for("CA");

	gtk_tree_model_get(GTK_TREE_MODEL(certificates), cert_iter, CERT_COL_DATA, &cert, -1);
	gtk_tree_model_get(GTK_TREE_MODEL(certificates), ca_iter, CERT_COL_DATA, &ca_cert, -1);

	val_cert = calloc(sizeof(GValue), 1);
	col_cert = malloc(sizeof(int));

	*col_cert = CERT_COL_IMAGE;
	g_value_init(val_cert, GDK_TYPE_PIXBUF);
	if(strcmp(which, "CERT_RN_FILE") != 0) {
		verify_result = eid_vwr_verify_cert(cert->data, cert->len, ca_cert->data, ca_cert->len, perform_ocsp_request, free);
	} else {
		verify_result = eid_vwr_verify_rrncert(cert->data, cert->len);
	}

	switch(verify_result) {
		case EID_VWR_RES_SUCCESS:
			g_value_set_instance(val_cert, good_certificate);
			break;
		case EID_VWR_RES_FAILED:
			g_value_set_instance(val_cert, bad_certificate);
			break;
		case EID_VWR_RES_UNKNOWN:
			g_value_set_instance(val_cert, warn_certificate);
			break;
		default:
			free(val_cert);
			free(col_cert);
			return verify_result;
	}
	col_ca = malloc(sizeof(int));
	val_ca = calloc(sizeof(GValue), 1);
	col_root = malloc(sizeof(int));
	val_root = calloc(sizeof(GValue), 1);
	*col_ca = *col_root = *col_cert;
	g_value_init(val_ca, GDK_TYPE_PIXBUF);
	g_value_copy(val_cert, val_ca);
	g_value_init(val_root, GDK_TYPE_PIXBUF);
	g_value_copy(val_cert, val_root);
	tst_set(which, col_cert, val_cert, 1);
	tst_set("CA", col_ca, val_ca, 1);
	tst_set("Root", col_root, val_root, 1);

	return verify_result;
}
コード例 #2
0
static guint get_buffered_amount(OwrDataChannel *data_channel)
{
    OwrDataChannelPrivate *priv = data_channel->priv;
    guint64 bytes_sent = 0;

    if (priv->on_request_bytes_sent) {
        GValue ret_value = G_VALUE_INIT;
        GValue params[1] = { G_VALUE_INIT };

        g_value_init(&ret_value, G_TYPE_UINT64);
        g_value_init(&params[0], OWR_TYPE_DATA_CHANNEL);
        g_value_set_instance(&params[0], data_channel);

        g_closure_invoke(priv->on_request_bytes_sent, &ret_value, 1, (const GValue *)&params, NULL);

        bytes_sent = g_value_get_uint64(&ret_value);

        g_value_unset(&params[0]);
        g_value_unset(&ret_value);
    } else
        g_warning("on_request_bytes_sent closure not set. Cannot get buffered amount.");

    if (priv->bytes_sent < bytes_sent)
        bytes_sent = 0;
    else
        bytes_sent = priv->bytes_sent - bytes_sent;

    if (bytes_sent > G_MAXUINT)
        bytes_sent = G_MAXUINT;

    return (guint) bytes_sent;
}
コード例 #3
0
static gint pacman_manager_fetch_cb (const gchar *url, const gchar *path, int force) {
	PacmanManagerPrivate *priv;
	GValue result = { 0 }, params[4] = { 0 };
	
	g_return_val_if_fail (url != NULL, -1);
	g_return_val_if_fail (path != NULL, -1);
	g_return_val_if_fail (pacman_manager != NULL, -1);
	
	priv = PACMAN_MANAGER_GET_PRIVATE (pacman_manager);
	
	g_value_init (&params[0], PACMAN_TYPE_MANAGER);
	g_value_set_instance (&params[0], pacman_manager);
	
	g_value_init (&params[1], G_TYPE_STRING);
	g_value_set_string (&params[1], url);
	
	g_value_init (&params[2], G_TYPE_STRING);
	g_value_set_string (&params[2], path);
	
	g_value_init (&params[3], G_TYPE_BOOLEAN);
	g_value_set_boolean (&params[3], force != 0);
	
	g_value_init (&result, G_TYPE_INT);
	g_closure_invoke (priv->transfer, &result, 4, params, NULL);
	
	return g_value_get_int (&result);
}
コード例 #4
0
ファイル: autoar-private.c プロジェクト: GNOME/gnome-autoar
/**
 * autoar_common_g_signal_emit:
 * @instance: the instance the signal is being emitted on.
 * @in_thread: %TRUE if you are not call this function inside the main thread.
 * @signal_id: the signal id
 * @detail: the detail
 * @...: parameters to be passed to the signal.
 *
 * This is a wrapper for g_signal_emit(). If @in_thread is %FALSE, this
 * function is the same as g_signal_emit(). If @in_thread is %TRUE, the
 * signal will be emitted from the main thread. This function will send
 * the signal emission job via g_main_context_invoke(), but it does not
 * wait for the signal emission job to be completed. Hence, the signal
 * may emitted after autoar_common_g_signal_emit() is returned.
 **/
G_GNUC_INTERNAL void
autoar_common_g_signal_emit (gpointer instance,
                             gboolean in_thread,
                             guint signal_id,
                             GQuark detail,
                             ...)
{
  va_list ap;

  va_start (ap, detail);
  if (in_thread) {
    int i;
    gchar *error;
    GSignalQuery query;
    AutoarCommonSignalData *data;

    error = NULL;
    data = g_new0 (AutoarCommonSignalData, 1);
    data->signal_id = signal_id;
    data->detail = detail;
    data->used_values = 1;
    g_value_init (data->instance_and_params, G_TYPE_FROM_INSTANCE (instance));
    g_value_set_instance (data->instance_and_params, instance);

    g_signal_query (signal_id, &query);
    if (query.signal_id == 0) {
      autoar_common_signal_data_free (data);
      va_end (ap);
      return;
    }

    for (i = 0; i < query.n_params; i++) {
      G_VALUE_COLLECT_INIT (data->instance_and_params + i + 1,
                            query.param_types[i],
                            ap,
                            0,
                            &error);
      if (error != NULL)
        break;
      data->used_values++;
    }

    if (error == NULL) {
      g_main_context_invoke (NULL, autoar_common_g_signal_emit_main_context, data);
    } else {
      autoar_common_signal_data_free (data);
      g_debug ("G_VALUE_COLLECT_INIT: Error: %s", error);
      g_free (error);
      va_end (ap);
      return;
    }
  } else {
    g_signal_emit_valist (instance, signal_id, detail, ap);
  }
  va_end (ap);
}
コード例 #5
0
static void pacman_manager_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
	g_return_if_fail (object != NULL);
	g_return_if_fail (value != NULL);
	
	PacmanManager *manager;
	manager = PACMAN_MANAGER (object);
	
	switch (prop_id) {
		case PROP_VERSION:
			g_value_set_string (value, pacman_manager_get_version (manager));
			break;
		
		case PROP_TRANSACTION:
			g_value_set_instance (value, pacman_manager_get_transaction (manager));
			break;
		
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
			break;
	}
}