Ejemplo n.º 1
0
static const char *
driver_id_to_name (CoglDriver id)
{
  switch (id)
    {
      case COGL_DRIVER_GL:
        return "gl";
      case COGL_DRIVER_GL3:
        return "gl3";
      case COGL_DRIVER_GLES1:
        return "gles1";
      case COGL_DRIVER_GLES2:
        return "gles2";
      case COGL_DRIVER_WEBGL:
        return "webgl";
      case COGL_DRIVER_NOP:
        return "nop";
      case COGL_DRIVER_ANY:
        g_warn_if_reached ();
        return "any";
    }

  g_warn_if_reached ();
  return "unknown";
}
Ejemplo n.º 2
0
gchar *
_gst_dtls_x509_to_pem (gpointer x509)
{
#define GST_DTLS_BIO_BUFFER_SIZE 4096
  BIO *bio;
  gchar buffer[GST_DTLS_BIO_BUFFER_SIZE] = { 0 };
  gint len;
  gchar *pem = NULL;

  bio = BIO_new (BIO_s_mem ());
  g_return_val_if_fail (bio, NULL);

  if (!PEM_write_bio_X509 (bio, (X509 *) x509)) {
    g_warn_if_reached ();
    goto beach;
  }

  len = BIO_read (bio, buffer, GST_DTLS_BIO_BUFFER_SIZE);
  if (!len) {
    g_warn_if_reached ();
    goto beach;
  }

  pem = g_strndup (buffer, len);

beach:
  BIO_free (bio);

  return pem;
}
Ejemplo n.º 3
0
GHashTable*
virt_viewer_file_get_versions(VirtViewerFile* self)
{
    GHashTable *versions;
    gchar **versions_str;
    gsize length;
    unsigned int i;

    versions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
    versions_str = virt_viewer_file_get_string_list(self, MAIN_GROUP,
                                                     "versions", &length);
    for (i = 0; i < length; i++) {
        GStrv tokens;

        if (versions_str[i] == NULL) {
            g_warn_if_reached();
            break;
        }
        tokens = g_strsplit(versions_str[i], ":", 2);
        if (g_strv_length(tokens) != 2) {
            g_warn_if_reached();
            continue;
        }
        g_debug("Minimum version '%s' for OS id '%s'", tokens[1], tokens[0]);
        g_hash_table_insert(versions, tokens[0], tokens[1]);
        g_free(tokens);
    }
    g_strfreev(versions_str);

    return versions;
}
Ejemplo n.º 4
0
static gboolean
_netns_switch_pop (NMPNetns *self, int ns_types)
{
	int errsv;
	NMPNetns *current;
	int success = TRUE;

	if (   NM_FLAGS_HAS (ns_types, CLONE_NEWNET)
	    && (!self || !_stack_current_ns_types (self, CLONE_NEWNET))) {
		current = _stack_current_netns (CLONE_NEWNET);
		if (!current) {
			g_warn_if_reached ();
			success = FALSE;
		} else if (_setns (current, CLONE_NEWNET) != 0) {
			errsv = errno;
			_LOGE (self, "failed to switch netns: %s", g_strerror (errsv));
			success = FALSE;
		}
	}
	if (   NM_FLAGS_HAS (ns_types, CLONE_NEWNS)
	    && (!self || !_stack_current_ns_types (self, CLONE_NEWNS))) {
		current = _stack_current_netns (CLONE_NEWNS);
		if (!current) {
			g_warn_if_reached ();
			success = FALSE;
		} else if (_setns (current, CLONE_NEWNS) != 0) {
			errsv = errno;
			_LOGE (self, "failed to switch mntns: %s", g_strerror (errsv));
			success = FALSE;
		}
	}

	return success;
}
Ejemplo n.º 5
0
void
rut_property_set_boxed (RutPropertyContext *ctx,
                        RutProperty *property,
                        const RutBoxed *boxed)
{
    /* Handle basic type conversion for scalar types only... */
    if (property->spec->type != boxed->type)
    {
        double intermediate = boxed_to_double (boxed);

        switch (property->spec->type)
        {
#define SCALAR_TYPE(SUFFIX, CTYPE, TYPE) \
        case RUT_PROPERTY_TYPE_ ## TYPE: \
          rut_property_set_ ## SUFFIX (ctx, property, intermediate); \
          return;
#define POINTER_TYPE(SUFFIX, CTYPE, TYPE)
#define COMPOSITE_TYPE(SUFFIX, CTYPE, TYPE)
#define ARRAY_TYPE(SUFFIX, CTYPE, TYPE, LEN)

#include "rut-property-types.h"

#undef SCALAR_TYPE
#undef POINTER_TYPE
#undef COMPOSITE_TYPE
#undef ARRAY_TYPE

        default:
            g_warn_if_reached ();
            return;
        }
    }

    switch (boxed->type)
    {
#define SET_BY_VAL(SUFFIX, CTYPE, TYPE) \
    case RUT_PROPERTY_TYPE_ ## TYPE: \
      rut_property_set_ ## SUFFIX (ctx, property, boxed->d.SUFFIX ## _val); \
      return
#define SCALAR_TYPE(SUFFIX, CTYPE, TYPE) SET_BY_VAL(SUFFIX, CTYPE, TYPE);
#define POINTER_TYPE(SUFFIX, CTYPE, TYPE) SET_BY_VAL(SUFFIX, CTYPE, TYPE);
#define COMPOSITE_TYPE(SUFFIX, CTYPE, TYPE) \
    case RUT_PROPERTY_TYPE_ ## TYPE: \
      rut_property_set_ ## SUFFIX (ctx, property, &boxed->d.SUFFIX ## _val); \
      return;
#define ARRAY_TYPE(SUFFIX, CTYPE, TYPE, LEN) SET_BY_VAL(SUFFIX, CTYPE, TYPE);
        SET_BY_VAL(text, char *, TEXT);

#include "rut-property-types.h"

#undef ARRAY_TYPE
#undef COMPOSITE_TYPE
#undef POINTER_TYPE
#undef SCALAR_TYPE
#undef SET_FROM_BOXED
    }

    g_warn_if_reached ();
}
Ejemplo n.º 6
0
/**
 * _st_get_align_factors:
 * @widget: an #StWidget
 * @x_align: an #StAlign
 * @y_align: an #StAlign
 * @x_align_out: (out) (allow-none): @x_align as a #gdouble
 * @y_align_out: (out) (allow-none): @y_align as a #gdouble
 *
 * Converts @x_align and @y_align to #gdouble values. If @widget has
 * %ST_TEXT_DIRECTION_RTL, the @x_align_out value will be flipped
 * relative to @x_align.
 */
void
_st_get_align_factors (StWidget *widget,
                       StAlign   x_align,
                       StAlign   y_align,
                       gdouble  *x_align_out,
                       gdouble  *y_align_out)
{
  if (x_align_out)
    {
      switch (x_align)
        {
        case ST_ALIGN_START:
          *x_align_out = 0.0;
          break;

        case ST_ALIGN_MIDDLE:
          *x_align_out = 0.5;
          break;

        case ST_ALIGN_END:
          *x_align_out = 1.0;
          break;

        default:
          g_warn_if_reached ();
          break;
        }

      if (st_widget_get_direction (widget) == ST_TEXT_DIRECTION_RTL)
        *x_align_out = 1.0 - *x_align_out;
    }

  if (y_align_out)
    {
      switch (y_align)
        {
        case ST_ALIGN_START:
          *y_align_out = 0.0;
          break;

        case ST_ALIGN_MIDDLE:
          *y_align_out = 0.5;
          break;

        case ST_ALIGN_END:
          *y_align_out = 1.0;
          break;

        default:
          g_warn_if_reached ();
          break;
        }
    }
}
Ejemplo n.º 7
0
/**
 * _st_get_align_factors:
 * @x_align: an #StAlign
 * @y_align: an #StAlign
 * @x_align_out: (out) (allow-none): @x_align as a #gdouble
 * @y_align_out: (out) (allow-none): @y_align as a #gdouble
 *
 * Converts @x_align and @y_align to #gdouble values.
 */
void
_st_get_align_factors (StAlign   x_align,
                       StAlign   y_align,
                       gdouble  *x_align_out,
                       gdouble  *y_align_out)
{
  if (x_align_out)
    {
      switch (x_align)
        {
        case ST_ALIGN_START:
          *x_align_out = 0.0;
          break;

        case ST_ALIGN_MIDDLE:
          *x_align_out = 0.5;
          break;

        case ST_ALIGN_END:
          *x_align_out = 1.0;
          break;

        default:
          g_warn_if_reached ();
          break;
        }
    }

  if (y_align_out)
    {
      switch (y_align)
        {
        case ST_ALIGN_START:
          *y_align_out = 0.0;
          break;

        case ST_ALIGN_MIDDLE:
          *y_align_out = 0.5;
          break;

        case ST_ALIGN_END:
          *y_align_out = 1.0;
          break;

        default:
          g_warn_if_reached ();
          break;
        }
    }
}
static gboolean
gvir_input_stream_read_ready(GVirStream *stream,
                             GVirStreamIOCondition cond,
                             void *opaque)
{
    GVirInputStream *input_stream = GVIR_INPUT_STREAM(opaque);
    GVirInputStreamPrivate *priv = input_stream->priv;
    GTask *task = priv->task;
    GCancellable *cancellable = g_task_get_cancellable(task);
    GError *error = NULL;
    gssize result;

    priv->task = NULL;

    if (!(cond & GVIR_STREAM_IO_CONDITION_READABLE)) {
        g_warn_if_reached();
        g_task_return_new_error(task,
                                G_IO_ERROR,
                                G_IO_ERROR_INVALID_ARGUMENT,
                                "%s",
                                "Expected stream to be readable");
        goto cleanup;
    }

    result = gvir_stream_receive(stream, priv->buffer, priv->count,
                                 cancellable, &error);
    if (error != NULL) {
        if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
            g_warn_if_reached();
            g_task_return_new_error(task,
                                    G_IO_ERROR,
                                    G_IO_ERROR_INVALID_ARGUMENT,
                                    "%s",
                                    "Expected stream to be readable");
            g_error_free (error);
        } else {
            g_task_return_error(task, error);
        }

        goto cleanup;
    }

    g_task_return_int(task, result);

cleanup:
    g_object_unref(task);
    return FALSE;
}
Ejemplo n.º 9
0
static void
get_modem_ready (GObject      *source,
                 GAsyncResult *result,
                 gpointer      none)
{
    ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
    ctx->modem_time = mm_object_get_modem_time (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_time)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_time));

    ensure_modem_time ();

    /* Request to get network time from the modem? */
    if (time_flag) {
        g_debug ("Asynchronously getting network time from the modem...");

        mm_modem_time_get_network_time (ctx->modem_time,
                                        ctx->cancellable,
                                        (GAsyncReadyCallback)get_network_time_ready,
                                        NULL);
        return;
    }

    g_warn_if_reached ();
}
Ejemplo n.º 10
0
GstElement * _owr_payload_create_payload_packetizer(OwrPayload *payload)
{
    GstElement * pay = NULL;
    gchar *element_name = NULL;
    OwrMediaType media_type;

    g_return_val_if_fail(payload, NULL);

    element_name = g_strdup_printf("pay_%s_%u", OwrCodecTypePayElementName[payload->priv->codec_type], get_unique_id());
    pay = gst_element_factory_make(OwrCodecTypePayElementName[payload->priv->codec_type], element_name);
    g_free(element_name);

    g_object_bind_property(payload, "mtu", pay, "mtu", G_BINDING_SYNC_CREATE);

    g_object_get(payload, "media-type", &media_type, NULL);
    switch (media_type) {
    case OWR_MEDIA_TYPE_AUDIO:
        if (OWR_IS_AUDIO_PAYLOAD(payload)) {
            g_object_bind_property(OWR_AUDIO_PAYLOAD(payload), "ptime", pay, "min-ptime", G_BINDING_SYNC_CREATE);
            g_object_bind_property(OWR_AUDIO_PAYLOAD(payload), "ptime", pay, "max-ptime", G_BINDING_SYNC_CREATE);
        }

        break;

    case OWR_MEDIA_TYPE_VIDEO:
        if (payload->priv->codec_type == OWR_CODEC_TYPE_H264)
            g_object_set(pay, "config-interval", 1, NULL);
        break;

    default:
        g_warn_if_reached();
    }

    return pay;
}
Ejemplo n.º 11
0
static const gchar *
get_new_line (XeditDocumentInputStream *stream)
{
	const gchar *ret;

	switch (stream->priv->newline_type)
	{
		case XEDIT_DOCUMENT_NEWLINE_TYPE_CR:
			ret = "\r";
			break;

		case XEDIT_DOCUMENT_NEWLINE_TYPE_LF:
			ret = "\n";
			break;

		case XEDIT_DOCUMENT_NEWLINE_TYPE_CR_LF:
			ret = "\r\n";
			break;

		default:
			g_warn_if_reached ();
			ret = "\n";
			break;
	}

	return ret;
}
Ejemplo n.º 12
0
static const gchar *
axis_type_name (ClutterInputAxis axis)
{
  switch (axis)
    {
    case CLUTTER_INPUT_AXIS_X:
      return "Absolute X";

    case CLUTTER_INPUT_AXIS_Y:
      return "Absolute Y";

    case CLUTTER_INPUT_AXIS_PRESSURE:
      return "Pressure";

    case CLUTTER_INPUT_AXIS_XTILT:
      return "X Tilt";

    case CLUTTER_INPUT_AXIS_YTILT:
      return "Y Tilt";

    case CLUTTER_INPUT_AXIS_WHEEL:
      return "Wheel";

    default:
      return "Unknown";
    }

  g_warn_if_reached ();

  return NULL;
}
Ejemplo n.º 13
0
static void
response (GtkWidget *dialog,
          gint response,
          EContactMergingLookup *lookup)
{
	switch (response) {
	case GTK_RESPONSE_OK:
		doit (lookup, FALSE);
		break;
	case GTK_RESPONSE_CANCEL:
		cancelit (lookup);
		break;
	case GTK_RESPONSE_APPLY:
		if (mergeit (lookup))
			break;
		return;
	case GTK_RESPONSE_DELETE_EVENT:
		cancelit (lookup);
		break;
	default:
		g_warn_if_reached ();
		break;
	}

	gtk_widget_destroy (dialog);
}
Ejemplo n.º 14
0
static void client_set_property(GObject *object, guint property_id,const GValue *value, GParamSpec *pspec)
{
	Client * obj = CLIENT(object);

	switch (property_id)
	{
	case CLIENT_NAME:
		obj->name = g_value_dup_string(value);
		break;
	case CLIENT_ID:
		obj->id = g_value_dup_string(value);
		break;
	case CLIENT_ID_TYPE:
		obj->idtype = g_value_dup_string(value);
		break;
	case CLIENT_IP_STR:
		obj->ip = inet_addr(g_value_get_string(value));
		break;
	case CLIENT_ROOM:
		obj->room = g_value_dup_string(value);
		break;
	case CLIENT_IP:
		obj->ip = g_value_get_uint(value);
		break;
	case CLIENT_ENABLE:
		obj->enable = g_value_get_boolean(value);
		break;
	default:
		g_warn_if_reached();
		break;
	}
}
Ejemplo n.º 15
0
void luaconfig_polling_rate_frame_set_value(LuaconfigPollingRateFrame *frame, guint rmp_value) {
	guint lua_value;
	guint roccat_value;

	lua_value = lua_value_to_polling_rate(rmp_value);

	switch (lua_value) {
	case LUA_POLLING_RATE_125:
		roccat_value = ROCCAT_POLLING_RATE_SELECTOR_125;
		break;
	case LUA_POLLING_RATE_250:
		roccat_value = ROCCAT_POLLING_RATE_SELECTOR_250;
		break;
	case LUA_POLLING_RATE_500:
		roccat_value = ROCCAT_POLLING_RATE_SELECTOR_500;
		break;
	case LUA_POLLING_RATE_1000:
		roccat_value = ROCCAT_POLLING_RATE_SELECTOR_1000;
		break;
	default:
		g_warn_if_reached();
		roccat_value = ROCCAT_POLLING_RATE_SELECTOR_NONE;
		break;
	}

	roccat_polling_rate_selector_set_value(frame->priv->selector, roccat_value);
}
Ejemplo n.º 16
0
void g_sql_result_set_property(GObject *object, guint property_id,const GValue *value, GParamSpec *pspec)
{
	GSQLResult * mobj = (GSQLResult*) object;

	g_return_if_fail(IS_G_SQL_RESULT(mobj));

	switch (property_id)
	{
	case G_SQL_RESULT_PROPERTY_TYPE:
		mobj->connector_type = g_value_get_gtype(value);
		break;
	case G_SQL_RESULT_PROPERTY_TYPE_INSTANCE:
		mobj->connector = g_value_get_object(value);
		break;
	case G_SQL_RESULT_PROPERTY_RESULT:
		mobj->result = g_value_get_pointer(value);
		break;
	case G_SQL_RESULT_PROPERTY_FIELDS:
		mobj->fields = g_value_get_int(value);
		break;
	default:
		g_warn_if_reached();
		break;
	}
}
void
qmicli_pbm_run (QmiDevice *device,
                QmiClientPbm *client,
                GCancellable *cancellable)
{
    /* Initialize context */
    ctx = g_slice_new (Context);
    ctx->device = g_object_ref (device);
    ctx->client = g_object_ref (client);
    ctx->cancellable = g_object_ref (cancellable);

    /* Request to get all capabilities? */
    if (get_all_capabilities_flag) {
        g_debug ("Asynchronously getting phonebook capabilities...");
        qmi_client_pbm_get_all_capabilities (ctx->client,
                                             NULL,
                                             10,
                                             ctx->cancellable,
                                             (GAsyncReadyCallback)get_all_capabilities_ready,
                                             NULL);
        return;
    }

    /* Just client allocate/release? */
    if (noop_flag) {
        g_idle_add (noop_cb, NULL);
        return;
    }

    g_warn_if_reached ();
}
Ejemplo n.º 18
0
static void
gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
                          const GtkCssMatcher     *matcher,
                          GtkCssLookup            *lookup)
{
  GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
  GtkStyleCascadeIter iter;
  GtkStyleProvider *item;

  for (item = gtk_style_cascade_iter_init (cascade, &iter);
       item;
       item = gtk_style_cascade_iter_next (cascade, &iter))
    {
      if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
        {
          _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (item),
                                              matcher,
                                              lookup);
        }
      else
        {
          /* you lose */
          g_warn_if_reached ();
        }
    }
}
Ejemplo n.º 19
0
void
mmcli_modem_time_run_synchronous (GDBusConnection *connection)
{
    GError *error = NULL;

    /* Initialize context */
    ctx = g_new0 (Context, 1);
    ctx->object = mmcli_get_modem_sync (connection,
                                        mmcli_get_common_modem_string (),
                                        &ctx->manager);
    ctx->modem_time = mm_object_get_modem_time (ctx->object);

    /* Setup operation timeout */
    if (ctx->modem_time)
        mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_time));

    ensure_modem_time ();

    /* Request to get network time from the modem? */
    if (time_flag) {
        gchar *time_string;
        MMNetworkTimezone *timezone;

        g_debug ("Synchronously getting network time from the modem...");

        time_string = mm_modem_time_get_network_time_sync (ctx->modem_time,
                                                           NULL,
                                                           &error);
        timezone = mm_modem_time_get_network_timezone (ctx->modem_time);
        get_network_time_process_reply (time_string, timezone, error);
        return;
    }

    g_warn_if_reached ();
}
Ejemplo n.º 20
0
static void
try_next_usbif (MMDevice *device)
{
    FirstInterfaceContext *fi_ctx;
    GList *l;
    gint closest;

    fi_ctx = g_object_get_data (G_OBJECT (device), TAG_FIRST_INTERFACE_CONTEXT);
    g_assert (fi_ctx != NULL);

    /* Look for the next closest one among the list of interfaces in the device,
     * and enable that one as being first */
    closest = G_MAXINT;
    for (l = mm_device_peek_port_probe_list (device); l; l = g_list_next (l)) {
        gint usbif;

        usbif = g_udev_device_get_property_as_int (mm_port_probe_peek_port (MM_PORT_PROBE (l->data)), "ID_USB_INTERFACE_NUM");
        if (usbif == fi_ctx->first_usbif) {
            g_warn_if_reached ();
        } else if (usbif > fi_ctx->first_usbif &&
                   usbif < closest) {
            closest = usbif;
        }
    }

    if (closest == G_MAXINT) {
        /* Retry with interface 0... */
        closest = 0;
    }

    mm_dbg ("(Huawei) Will try initial probing with interface '%d' instead", closest);

    fi_ctx->first_usbif = closest;
}
Ejemplo n.º 21
0
static void
on_combo_box_changed (GtkComboBox *widget, GvcComboBox *combobox)
{
        GtkTreeIter            iter;
        gchar                 *name;
        MateMixerSwitchOption *option;

        if (G_UNLIKELY (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter) == FALSE))
                return;

        gtk_tree_model_get (combobox->priv->model, &iter,
                            COL_NAME, &name,
                            -1);

        option = mate_mixer_switch_get_option (combobox->priv->swtch, name);
        if (G_UNLIKELY (option == NULL)) {
                g_warn_if_reached ();
                g_free (name);
                return;
        }

        /* Inform that we are about to change the active option of the switch */
        g_signal_emit (combobox, signals[CHANGING], 0, option);

        mate_mixer_switch_set_active_option (combobox->priv->swtch, option);
        g_free (name);
}
Ejemplo n.º 22
0
guint luaconfig_polling_rate_frame_get_value(LuaconfigPollingRateFrame *frame) {
	guint roccat_value;
	guint lua_value;

	roccat_value = roccat_polling_rate_selector_get_value(frame->priv->selector);

	switch (roccat_value) {
	case ROCCAT_POLLING_RATE_SELECTOR_125:
		lua_value = LUA_POLLING_RATE_125;
		break;
	case ROCCAT_POLLING_RATE_SELECTOR_250:
		lua_value = LUA_POLLING_RATE_250;
		break;
	case ROCCAT_POLLING_RATE_SELECTOR_500:
		lua_value = LUA_POLLING_RATE_500;
		break;
	case ROCCAT_POLLING_RATE_SELECTOR_1000:
		lua_value = LUA_POLLING_RATE_1000;
		break;
	default:
		g_warn_if_reached();
	case ROCCAT_POLLING_RATE_SELECTOR_NONE:
		lua_value = LUA_POLLING_RATE_1000;
		break;
	}

	return lua_polling_rate_to_value(lua_value);
}
Ejemplo n.º 23
0
/**
 * camel_object_bag_rekey:
 * @bag: a #CamelObjectBag
 * @object: a #GObject
 * @new_key: a new key for @object
 *
 * Changes the key for @object to @new_key, atomically.
 *
 * It is considered a programming error if @object is not found in @bag.
 * In such case the function will emit a terminal warning and return.
 **/
void
camel_object_bag_rekey (CamelObjectBag *bag,
                        gpointer object,
                        gconstpointer new_key)
{
	gpointer key;
	ObjRef *ref;

	g_return_if_fail (bag != NULL);
	g_return_if_fail (G_IS_OBJECT (object));
	g_return_if_fail (new_key != NULL);

	g_mutex_lock (&bag->mutex);

	key = g_hash_table_lookup (bag->key_table, object);
	if (key != NULL) {
		/* Remove the old key. */
		ref = g_hash_table_lookup (bag->object_table, key);
		g_hash_table_steal (bag->object_table, key);
		g_hash_table_remove (bag->key_table, object);

		/* Insert the new key. */
		key = bag->key_copy_func (new_key);
		g_hash_table_insert (bag->object_table, key, ref);
		g_hash_table_insert (bag->key_table, object, key);
	} else
		g_warn_if_reached ();

	g_mutex_unlock (&bag->mutex);
}
static void
cell_error_data_func (GtkTreeViewColumn *tree_column,
                      GtkCellRenderer *cell,
                      GtkTreeModel *tree_model,
                      GtkTreeIter *iter,
                      gpointer data)
{
	guint32 col = GPOINTER_TO_UINT (data);
	char *value = NULL;
	char *addr, *next_hop;
	guint32 prefix;
	gint64 metric;
	const char *color = "red";
	gboolean invalid = FALSE;

	if (col == COL_ADDRESS)
		invalid = !utils_tree_model_get_address (tree_model, iter, COL_ADDRESS, AF_INET, TRUE, &addr, &value);
	else if (col == COL_PREFIX)
		invalid =    !utils_tree_model_get_ip4_prefix (tree_model, iter, COL_PREFIX, TRUE, &prefix, &value)
		          || prefix == 0;
	else if (col == COL_NEXT_HOP)
		invalid = !utils_tree_model_get_address (tree_model, iter, COL_NEXT_HOP, AF_INET, FALSE, &next_hop, &value);
	else if (col == COL_METRIC)
		invalid = !utils_tree_model_get_int64 (tree_model, iter, COL_METRIC, 0, G_MAXUINT32, FALSE, &metric, &value);
	else
		g_warn_if_reached ();

	if (invalid)
		utils_set_cell_background (cell, color, value);
	else
		utils_set_cell_background (cell, NULL, NULL);
	g_free (value);
}
Ejemplo n.º 25
0
static const gchar *
get_question_add_all_mails (ECalClientSourceType source_type,
                            gint count)
{
	const gchar *ask = NULL;

	switch (source_type) {
	case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
		/* Translators: Note there are always more than 10 mails selected */
		ask = ngettext (
			"You have selected %d mails to be converted to events. Do you really want to add them all?",
			"You have selected %d mails to be converted to events. Do you really want to add them all?",
			count);
		break;
	case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
		/* Translators: Note there are always more than 10 mails selected */
		ask = ngettext (
			"You have selected %d mails to be converted to tasks. Do you really want to add them all?",
			"You have selected %d mails to be converted to tasks. Do you really want to add them all?",
			count);
		break;
	case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
		/* Translators: Note there are always more than 10 mails selected */
		ask = ngettext (
			"You have selected %d mails to be converted to memos. Do you really want to add them all?",
			"You have selected %d mails to be converted to memos. Do you really want to add them all?",
			count);
		break;
	default:
		g_warn_if_reached ();
		break;
	}

	return ask;
}
Ejemplo n.º 26
0
static void
cell_error_data_func (GtkTreeViewColumn *tree_column,
                      GtkCellRenderer *cell,
                      GtkTreeModel *tree_model,
                      GtkTreeIter *iter,
                      gpointer data)
{
	guint32 col = GPOINTER_TO_UINT (data);
	char *value = NULL;
	const char *color = NULL;
	guint32 prefix;
	gboolean invalid = FALSE;

	gtk_tree_model_get (tree_model, iter, col, &value, -1);

	if (col == COL_ADDRESS)
		invalid =    !value || !*value || !nm_utils_ipaddr_valid (AF_INET, value)
		          || is_address_unspecified (value);
	else if (col == COL_PREFIX)
		invalid = !parse_netmask (value, &prefix);
	else if (col == COL_GATEWAY) {
		invalid = value && *value && !nm_utils_ipaddr_valid (AF_INET, value);

		/* Check gateway against address and prefix */
		if (!invalid && possibly_wrong_gateway (tree_model, iter, value))
			color = "#DDC000"; /* darker than "yellow", else selected text is hard to read */
	} else
		g_warn_if_reached ();

	if (invalid)
		color = "red";
	utils_set_cell_background (cell, color, color ? value : NULL);
	g_free (value);
}
Ejemplo n.º 27
0
static void
get_sms_ready (GObject      *source,
               GAsyncResult *result,
               gpointer      none)
{
    ctx->sms = mmcli_get_sms_finish (result,
                                     &ctx->manager,
                                     &ctx->object);

    if (info_flag)
        g_assert_not_reached ();

    /* Requesting to send the SMS? */
    if (send_flag) {
        mm_sms_send (ctx->sms,
                     ctx->cancellable,
                     (GAsyncReadyCallback)send_ready,
                     NULL);
        return;
    }

    /* Requesting to store the SMS? */
    if (store_flag) {
        mm_sms_store (ctx->sms,
                      ctx->cancellable,
                      (GAsyncReadyCallback)store_ready,
                      NULL);
        return;
    }

    g_warn_if_reached ();
}
Ejemplo n.º 28
0
static gpointer
iris_thread_worker (IrisThread *thread)
{
	IrisMessage *message;
	GTimeVal     timeout = {0,0};

	g_return_val_if_fail (thread != NULL, NULL);
	g_return_val_if_fail (thread->queue != NULL, NULL);

#if LINUX
	my_thread = thread;
#else
	pthread_setspecific (my_thread, thread);
#endif

	iris_debug_init_thread ();
	iris_debug (IRIS_DEBUG_THREAD);

next_message:
	if (thread->exclusive) {
		message = g_async_queue_pop (thread->queue);
	}
	else {
		/* If we do not get any schedulers to work for within our
		 * timeout period, we can safely shutdown. */
		g_get_current_time (&timeout);
		g_time_val_add (&timeout, G_USEC_PER_SEC * 5);
		message = g_async_queue_timed_pop (thread->queue, &timeout);

		if (!message) {
			/* Make sure that the manager removes us from the
			 * free thread list. */
			iris_scheduler_manager_destroy (thread);

			/* make sure nothing was added while we
			 * removed ourselves */
			message = g_async_queue_try_pop (thread->queue);
		}
	}

	if (!message)
		return NULL;

	switch (message->what) {
	case MSG_MANAGE:
		iris_thread_handle_manage (thread,
		                           iris_message_get_pointer (message, "queue"),
		                           iris_message_get_boolean (message, "exclusive"),
		                           iris_message_get_boolean (message, "leader"));
		break;
	case MSG_SHUTDOWN:
		iris_thread_handle_shutdown (thread);
		break;
	default:
		g_warn_if_reached ();
		break;
	}

	goto next_message;
}
Ejemplo n.º 29
0
static void info_bar_response_cb(GtkInfoBar *info_bar, gint response_id, gpointer user_data)
{
	GSList *library_dir = NULL;

	struct con_win *cwin = user_data;
	const gchar *dir = g_get_user_special_dir(G_USER_DIRECTORY_MUSIC);

	gtk_widget_destroy(GTK_WIDGET(info_bar));

	switch (response_id)
	{
		case GTK_RESPONSE_CANCEL:
			break;
		case GTK_RESPONSE_YES:
			library_dir = g_slist_append(library_dir, g_strdup(dir));
			pragha_preferences_set_filename_list(cwin->preferences,
				                             GROUP_LIBRARY,
				                             KEY_LIBRARY_DIR,
				                             library_dir);
			free_str_list(library_dir);

			pragha_scanner_scan_library(cwin->scanner);
			break;
		default:
			g_warn_if_reached();
	}
}
Ejemplo n.º 30
0
static bool qauthz_list_is_allowed(QAuthZ *authz,
                                   const char *identity,
                                   Error **errp)
{
    QAuthZList *lauthz = QAUTHZ_LIST(authz);
    QAuthZListRuleList *rules = lauthz->rules;

    while (rules) {
        QAuthZListRule *rule = rules->value;
        QAuthZListFormat format = rule->has_format ? rule->format :
            QAUTHZ_LIST_FORMAT_EXACT;

        trace_qauthz_list_check_rule(authz, rule->match, identity,
                                     format, rule->policy);
        switch (format) {
        case QAUTHZ_LIST_FORMAT_EXACT:
            if (g_str_equal(rule->match, identity)) {
                return rule->policy == QAUTHZ_LIST_POLICY_ALLOW;
            }
            break;
        case QAUTHZ_LIST_FORMAT_GLOB:
            if (g_pattern_match_simple(rule->match, identity)) {
                return rule->policy == QAUTHZ_LIST_POLICY_ALLOW;
            }
            break;
        default:
            g_warn_if_reached();
            return false;
        }
        rules = rules->next;
    }

    trace_qauthz_list_default_policy(authz, identity, lauthz->policy);
    return lauthz->policy == QAUTHZ_LIST_POLICY_ALLOW;
}