Ejemplo n.º 1
0
static void
on_pipe_read (CockpitPipe *pipe,
              GByteArray *data,
              gboolean end_of_data,
              gpointer user_data)
{
  CockpitTextStream *self = user_data;
  CockpitChannel *channel = user_data;
  GBytes *message;
  GBytes *clean;

  if (data->len || !end_of_data)
    {
      /* When array is reffed, this just clears byte array */
      g_byte_array_ref (data);
      message = g_byte_array_free_to_bytes (data);
      clean = check_utf8_and_force_if_necessary (message);
      cockpit_channel_send (channel, clean);
      g_bytes_unref (message);
      g_bytes_unref (clean);
    }

  /* Close the pipe when writing is done */
  if (end_of_data && self->open)
    {
      g_debug ("%s: end of data, closing pipe", self->name);
      cockpit_pipe_close (pipe, NULL);
    }
}
Ejemplo n.º 2
0
static void
g_tls_database_real_lookup_certificates_issued_by_async (GTlsDatabase           *self,
                                                         GByteArray             *issuer,
                                                         GTlsInteraction        *interaction,
                                                         GTlsDatabaseLookupFlags flags,
                                                         GCancellable           *cancellable,
                                                         GAsyncReadyCallback     callback,
                                                         gpointer                user_data)
{
  GSimpleAsyncResult *res;
  AsyncLookupCertificatesIssuedBy *args;

  g_return_if_fail (callback);

  args = g_slice_new0 (AsyncLookupCertificatesIssuedBy);
  args->issuer = g_byte_array_ref (issuer);
  args->flags = flags;
  args->interaction = interaction ? g_object_ref (interaction) : NULL;

  res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
                                   g_tls_database_real_lookup_certificates_issued_by_async);
  g_simple_async_result_set_op_res_gpointer (res, args, async_lookup_certificates_issued_by_free);
  g_simple_async_result_run_in_thread (res, async_lookup_certificates_issued_by_thread,
                                       G_PRIORITY_DEFAULT, cancellable);
  g_object_unref (res);
}
Ejemplo n.º 3
0
Util::Buffer::Buffer( const Buffer & other )
:
    bytes( other.bytes )
{
	if ( bytes )
	{
		g_byte_array_ref( bytes );
	}
}
Ejemplo n.º 4
0
Util::Buffer::Buffer( GByteArray * _bytes )
:
    bytes( _bytes )
{
	if ( bytes )
	{
		g_byte_array_ref( bytes );
	}
}
Ejemplo n.º 5
0
 DecodeBufferTask( GByteArray * _bytes , bool _read_tags , const gchar * _content_type , Image::DecodeAsyncCallback _callback , gpointer _user , GDestroyNotify _destroy_notify )
 :
     DecodeTask( _callback , _user , _destroy_notify ),
     bytes( _bytes ),
     read_tags( _read_tags ),
     content_type( _content_type ? _content_type : "" )
 {
     g_byte_array_ref( bytes );
 }
static void
grl_dpap_record_set_property (GObject *object,
                                guint prop_id,
                                const GValue *value,
                                GParamSpec *pspec)
{
  GrlDPAPRecord *record = SIMPLE_DPAP_RECORD (object);

  switch (prop_id) {
  case PROP_LOCATION:
    g_free (record->priv->location);
    record->priv->location = g_value_dup_string (value);
    break;
  case PROP_LARGE_FILESIZE:
    record->priv->largefilesize = g_value_get_int (value);
    break;
  case PROP_CREATION_DATE:
    record->priv->creationdate = g_value_get_int (value);
    break;
  case PROP_RATING:
    record->priv->rating = g_value_get_int (value);
    break;
  case PROP_FILENAME:
    g_free (record->priv->filename);
    record->priv->filename = g_value_dup_string (value);
    break;
  case PROP_ASPECT_RATIO:
    g_free (record->priv->aspectratio);
    record->priv->aspectratio = g_value_dup_string (value);
    break;
  case PROP_PIXEL_HEIGHT:
    record->priv->height = g_value_get_int (value);
    break;
  case PROP_PIXEL_WIDTH:
    record->priv->width = g_value_get_int (value);
    break;
  case PROP_FORMAT:
    g_free (record->priv->format);
    record->priv->format = g_value_dup_string (value);
    break;
  case PROP_COMMENTS:
    g_free (record->priv->comments);
    record->priv->comments = g_value_dup_string (value);
    break;
  case PROP_THUMBNAIL:
    if (record->priv->thumbnail)
      g_byte_array_unref (record->priv->thumbnail);
    record->priv->thumbnail = g_byte_array_ref (g_value_get_pointer (value));
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    break;
  }
}
Ejemplo n.º 7
0
GByteArray *
gjs_byte_array_get_byte_array (JSContext   *context,
                               JSObject    *obj)
{
    ByteArrayInstance *priv;
    priv = priv_from_js(context, obj);
    g_assert(priv != NULL);

    byte_array_ensure_array(priv);

    return g_byte_array_ref (priv->array);
}
Ejemplo n.º 8
0
static void
add_assertion_to_trust (GkmXdgTrust *self, GkmAssertion *assertion,
                        GkmTransaction *transaction)
{
	GByteArray *key;

	key = lookup_or_create_assertion_key (assertion);
	g_assert (key);

	g_hash_table_insert (self->pv->assertions, g_byte_array_ref (key), g_object_ref (assertion));
	gkm_object_expose (GKM_OBJECT (assertion), gkm_object_is_exposed (GKM_OBJECT (self)));

	if (transaction != NULL)
		gkm_transaction_add (transaction, self, complete_add_assertion, g_object_ref (assertion));
}
Ejemplo n.º 9
0
static GByteArray*
lookup_or_create_assertion_key (GkmAssertion *assertion)
{
	GByteArray *key;

	key = lookup_assertion_key (assertion);
	if (key == NULL) {
		key = create_assertion_key (gkm_assertion_get_purpose (assertion),
		                            gkm_assertion_get_peer (assertion));
		g_object_set_qdata_full (G_OBJECT (assertion), QDATA_ASSERTION_KEY,
		                         g_byte_array_ref (key), (GDestroyNotify)g_byte_array_unref);
	}

	return key;
}
Ejemplo n.º 10
0
Archivo: msg.c Proyecto: spk121/jozabad
JzMsg *
jz_msg_new_data (guint16 lcn, guint8 q, guint16 pr, guint16 ps, guint8 *data, gsize len)
{
  JzMsg *self = g_new0(JzMsg, 1);

  MSG_HEADER(self);
  self->id = JZ_MSG_DATA;
  self->lcn = lcn;
  self->q = q;
  self->pr = pr;
  self->ps = ps;
  self->data = g_byte_array_new_take (data, len);
  MSG_ERROR_CHECK(self);
  g_byte_array_ref (self->data);
  return self;
}
Ejemplo n.º 11
0
const Util::Buffer & Util::Buffer::operator = ( const Buffer & other )
{
	GByteArray * old = bytes;

	bytes = other.bytes;

	if ( bytes )
	{
		g_byte_array_ref( bytes );
	}

	if ( old )
	{
		g_byte_array_unref( old );
	}

	return * this;
}
Ejemplo n.º 12
0
static GError*
_client_request(struct gridd_client_s *client, GByteArray *req,
		gpointer ctx, client_on_reply cb)
{
	EXTRA_ASSERT(client != NULL);
	EXTRA_ASSERT(client->abstract.vtable == &VTABLE_CLIENT);

	if ( NULL == req)
		return NEWERROR(CODE_INTERNAL_ERROR, "Invalid parameter");

	switch (client->step) {
		case NONE:
		case CONNECTING:
		case CONNECTED:
			if (client->request != NULL)
				return NEWERROR(500, "Request already pending");
			/* ok */
			break;
		case REQ_SENDING:
		case REP_READING_SIZE:
		case REP_READING_DATA:
			return NEWERROR(500, "Request not terminated");
		case STATUS_OK:
		case STATUS_FAILED:
			/* ok */
			if (client->fd >= 0)
				client->step = REQ_SENDING;
			else
				client->step = CONNECTING;
			break;
	}

	/* if any, reset the last reply */
	_client_reset_reply(client);
	_client_reset_request(client);
	_client_reset_error(client);

	/* Now set the new request components */
	client->ctx = ctx;
	client->on_reply = cb;
	client->request = g_byte_array_ref(req);
	return NULL;
}
static void
g_tls_client_connection_gnutls_get_property (GObject    *object,
					     guint       prop_id,
					     GValue     *value,
					     GParamSpec *pspec)
{
  GTlsClientConnectionGnutls *gnutls = G_TLS_CLIENT_CONNECTION_GNUTLS (object);
  GList *accepted_cas;
  gint i;

  switch (prop_id)
    {
    case PROP_VALIDATION_FLAGS:
      g_value_set_flags (value, gnutls->priv->validation_flags);
      break;

    case PROP_SERVER_IDENTITY:
      g_value_set_object (value, gnutls->priv->server_identity);
      break;

    case PROP_USE_SSL3:
      g_value_set_boolean (value, gnutls->priv->use_ssl3);
      break;

    case PROP_ACCEPTED_CAS:
      accepted_cas = NULL;
      if (gnutls->priv->accepted_cas)
        {
          for (i = 0; i < gnutls->priv->accepted_cas->len; ++i)
            {
              accepted_cas = g_list_prepend (accepted_cas, g_byte_array_ref (
                                             gnutls->priv->accepted_cas->pdata[i]));
            }
          accepted_cas = g_list_reverse (accepted_cas);
        }
      g_value_set_pointer (value, accepted_cas);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}
Ejemplo n.º 14
0
void hev_serial_port_queue_command_async(HevSerialPort *self, GByteArray *command,
			HevSerialPortReadSizeCallback read_callback, GCancellable *cancellable,
			GAsyncReadyCallback callback, gpointer user_data)
{
	HevSerialPortPrivate *priv = NULL;
	GSimpleAsyncResult *simple = NULL;
	HevSerialPortQueueCommandData *data = NULL;
	gboolean empty = FALSE;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	g_return_if_fail(HEV_IS_SERIAL_PORT(self));
	g_return_if_fail(NULL != command);
	g_return_if_fail(NULL != read_callback);
	priv = HEV_SERIAL_PORT_GET_PRIVATE(self);

	/* Queue is empty */
	empty = g_queue_is_empty(priv->queue);
	
	/* Simple async result */
	simple = g_simple_async_result_new(G_OBJECT(self),
				callback, user_data, hev_serial_port_queue_command_async);
	g_simple_async_result_set_check_cancellable(simple, cancellable);

	/* Queue command data */
	data = g_malloc0(sizeof(HevSerialPortQueueCommandData));
	data->command = g_byte_array_ref(command);
	data->read_callback = read_callback;
	data->cancellable = cancellable;
	data->user_data = user_data;
	g_simple_async_result_set_op_res_gpointer(simple, data, NULL);

	/* Push head */
	g_queue_push_head(priv->queue, simple);

	if(empty)
	  hev_serial_port_queue_command_handler(self);
}
Ejemplo n.º 15
0
template <> GByteArray* refGPtr(GByteArray* ptr)
{
    if (ptr)
        g_byte_array_ref(ptr);
    return ptr;
}