aboutsummaryrefslogtreecommitdiff
path: root/src/fetch-file.c
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2010-11-18 11:13:31 -0500
committerKen VanDine <ken.vandine@canonical.com>2010-11-18 11:13:31 -0500
commit13bc64e0a3c144740c30e2469fdb5f605d58ee39 (patch)
tree21b2af1f4d2d796bdbf2af16761de5be769e87fa /src/fetch-file.c
parent908222c0681fba3c6e1265d0f85a0b667927c169 (diff)
parent0d5c60e9161f4b1b4315bbfac7862ef662f577ee (diff)
downloadayatana-indicator-sound-13bc64e0a3c144740c30e2469fdb5f605d58ee39.tar.gz
ayatana-indicator-sound-13bc64e0a3c144740c30e2469fdb5f605d58ee39.tar.bz2
ayatana-indicator-sound-13bc64e0a3c144740c30e2469fdb5f605d58ee39.zip
Import upstream version 0.5.2
Diffstat (limited to 'src/fetch-file.c')
-rw-r--r--src/fetch-file.c284
1 files changed, 158 insertions, 126 deletions
diff --git a/src/fetch-file.c b/src/fetch-file.c
index 2bf4bbf..680a582 100644
--- a/src/fetch-file.c
+++ b/src/fetch-file.c
@@ -1,4 +1,4 @@
-/* fetch-file.c generated by valac 0.10.0, the Vala compiler
+/* fetch-file.c generated by valac 0.11.2, the Vala compiler
* generated from fetch-file.vala, do not modify */
/*
@@ -56,8 +56,8 @@ struct _FetchFileClass {
};
struct _FetchFilePrivate {
- char* _uri;
- char* _intended_property;
+ gchar* _uri;
+ gchar* _intended_property;
GDataInputStream* stream;
GFile* file;
GByteArray* data;
@@ -65,33 +65,40 @@ struct _FetchFilePrivate {
struct _FetchFileFetchDataData {
int _state_;
+ GObject* _source_object_;
GAsyncResult* _res_;
GSimpleAsyncResult* _async_result;
FetchFile* self;
GFileInputStream* _tmp0_;
GFileInputStream* _tmp1_;
- GDataInputStream* _tmp2_;
+ GFileInputStream* _tmp2_;
+ GDataInputStream* _tmp3_;
+ GDataInputStream* _tmp4_;
GError * e;
GError * _inner_error_;
};
struct _FetchFileReadSomethingAsyncData {
int _state_;
+ GObject* _source_object_;
GAsyncResult* _res_;
GSimpleAsyncResult* _async_result;
FetchFile* self;
gssize size;
- guint8* buffer;
+ guint8* _tmp0_;
gint buffer_length1;
gint _buffer_size_;
- guint8* _tmp0_;
+ guint8* _tmp1_;
+ guint8* buffer;
gssize bufsize;
- gboolean _tmp1_;
- gssize _tmp2_;
- guint8* cpybuf;
+ gboolean _tmp2_;
+ gssize _tmp3_;
+ gssize _tmp4_;
+ guint8* _tmp5_;
gint cpybuf_length1;
gint _cpybuf_size_;
- guint8* _tmp3_;
+ guint8* _tmp6_;
+ guint8* cpybuf;
GError * e;
GError * _inner_error_;
};
@@ -106,8 +113,8 @@ enum {
FETCH_FILE_URI,
FETCH_FILE_INTENDED_PROPERTY
};
-FetchFile* fetch_file_new (const char* uri, const char* prop);
-FetchFile* fetch_file_construct (GType object_type, const char* uri, const char* prop);
+FetchFile* fetch_file_new (const gchar* uri, const gchar* prop);
+FetchFile* fetch_file_construct (GType object_type, const gchar* uri, const gchar* prop);
static void fetch_file_fetch_data_data_free (gpointer _data);
static void fetch_file_fetch_data_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
@@ -118,20 +125,19 @@ static void fetch_file_read_something_finish (FetchFile* self, GAsyncResult* _re
static void fetch_file_read_something_async_data_free (gpointer _data);
static void fetch_file_read_something_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncData* data);
-const char* fetch_file_get_intended_property (FetchFile* self);
-const char* fetch_file_get_uri (FetchFile* self);
-static void fetch_file_set_uri (FetchFile* self, const char* value);
-static void fetch_file_set_intended_property (FetchFile* self, const char* value);
+const gchar* fetch_file_get_intended_property (FetchFile* self);
+const gchar* fetch_file_get_uri (FetchFile* self);
+static void fetch_file_set_uri (FetchFile* self, const gchar* value);
+static void fetch_file_set_intended_property (FetchFile* self, const gchar* value);
+static void g_cclosure_user_marshal_VOID__POINTER_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static GObject * fetch_file_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void fetch_file_finalize (GObject* obj);
-static void fetch_file_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
-static void fetch_file_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
-
+static void _vala_fetch_file_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
+static void _vala_fetch_file_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
-static void g_cclosure_user_marshal_VOID__POINTER_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
-FetchFile* fetch_file_construct (GType object_type, const char* uri, const char* prop) {
- FetchFile * self;
+FetchFile* fetch_file_construct (GType object_type, const gchar* uri, const gchar* prop) {
+ FetchFile * self = NULL;
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (prop != NULL, NULL);
self = (FetchFile*) g_object_new (object_type, "uri", uri, "intended-property", prop, NULL);
@@ -139,7 +145,7 @@ FetchFile* fetch_file_construct (GType object_type, const char* uri, const char*
}
-FetchFile* fetch_file_new (const char* uri, const char* prop) {
+FetchFile* fetch_file_new (const gchar* uri, const gchar* prop) {
return fetch_file_construct (TYPE_FETCH_FILE, uri, prop);
}
@@ -147,17 +153,22 @@ FetchFile* fetch_file_new (const char* uri, const char* prop) {
static void fetch_file_fetch_data_data_free (gpointer _data) {
FetchFileFetchDataData* data;
data = _data;
- g_object_unref (data->self);
+ _g_object_unref0 (data->self);
g_slice_free (FetchFileFetchDataData, data);
}
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
FetchFileFetchDataData* _data_;
_data_ = g_slice_new0 (FetchFileFetchDataData);
_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fetch_file_fetch_data);
g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fetch_file_fetch_data_data_free);
- _data_->self = g_object_ref (self);
+ _data_->self = _g_object_ref0 (self);
fetch_file_fetch_data_co (_data_);
}
@@ -171,6 +182,7 @@ void fetch_file_fetch_data_finish (FetchFile* self, GAsyncResult* _res_) {
static void fetch_file_fetch_data_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
FetchFileFetchDataData* data;
data = _user_data_;
+ data->_source_object_ = source_object;
data->_res_ = _res_;
fetch_file_fetch_data_co (data);
}
@@ -184,24 +196,27 @@ static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) {
g_assert_not_reached ();
}
_state_0:
- {
- data->_tmp0_ = g_file_read (data->self->priv->file, NULL, &data->_inner_error_);
- if (data->_inner_error_ != NULL) {
- goto __catch13_g_error;
- }
- data->self->priv->stream = (data->_tmp2_ = g_data_input_stream_new ((GInputStream*) (data->_tmp1_ = data->_tmp0_)), _g_object_unref0 (data->self->priv->stream), data->_tmp2_);
- _g_object_unref0 (data->_tmp1_);
- g_data_input_stream_set_byte_order (data->self->priv->stream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
+ data->_tmp0_ = NULL;
+ data->_tmp0_ = g_file_read (data->self->priv->file, NULL, &data->_inner_error_);
+ data->_tmp1_ = data->_tmp0_;
+ if (data->_inner_error_ != NULL) {
+ goto __catch13_g_error;
}
+ data->_tmp2_ = data->_tmp1_;
+ data->_tmp3_ = NULL;
+ data->_tmp3_ = g_data_input_stream_new ((GInputStream*) data->_tmp2_);
+ data->_tmp4_ = data->_tmp3_;
+ _g_object_unref0 (data->self->priv->stream);
+ data->self->priv->stream = data->_tmp4_;
+ _g_object_unref0 (data->_tmp2_);
+ g_data_input_stream_set_byte_order (data->self->priv->stream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
goto __finally13;
__catch13_g_error:
{
data->e = data->_inner_error_;
data->_inner_error_ = NULL;
- {
- g_signal_emit_by_name (data->self, "failed");
- _g_error_free0 (data->e);
- }
+ g_signal_emit_by_name (data->self, "failed");
+ _g_error_free0 (data->e);
}
__finally13:
if (data->_inner_error_ != NULL) {
@@ -210,22 +225,20 @@ static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) {
return FALSE;
}
fetch_file_read_something_async (data->self, NULL, NULL);
- {
- if (data->_state_ == 0) {
- g_simple_async_result_complete_in_idle (data->_async_result);
- } else {
- g_simple_async_result_complete (data->_async_result);
- }
- g_object_unref (data->_async_result);
- return FALSE;
+ if (data->_state_ == 0) {
+ g_simple_async_result_complete_in_idle (data->_async_result);
+ } else {
+ g_simple_async_result_complete (data->_async_result);
}
+ g_object_unref (data->_async_result);
+ return FALSE;
}
static void fetch_file_read_something_async_data_free (gpointer _data) {
FetchFileReadSomethingAsyncData* data;
data = _data;
- g_object_unref (data->self);
+ _g_object_unref0 (data->self);
g_slice_free (FetchFileReadSomethingAsyncData, data);
}
@@ -235,7 +248,7 @@ static void fetch_file_read_something_async (FetchFile* self, GAsyncReadyCallbac
_data_ = g_slice_new0 (FetchFileReadSomethingAsyncData);
_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fetch_file_read_something_async);
g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fetch_file_read_something_async_data_free);
- _data_->self = g_object_ref (self);
+ _data_->self = _g_object_ref0 (self);
fetch_file_read_something_async_co (_data_);
}
@@ -249,6 +262,7 @@ static void fetch_file_read_something_finish (FetchFile* self, GAsyncResult* _re
static void fetch_file_read_something_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
FetchFileReadSomethingAsyncData* data;
data = _user_data_;
+ data->_source_object_ = source_object;
data->_res_ = _res_;
fetch_file_read_something_async_co (data);
}
@@ -258,55 +272,62 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD
switch (data->_state_) {
case 0:
goto _state_0;
- default:
- g_assert_not_reached ();
case 1:
goto _state_1;
+ default:
+ g_assert_not_reached ();
}
_state_0:
data->size = (gssize) 1024;
- data->buffer = (data->_tmp0_ = g_new0 (guint8, data->size), data->buffer_length1 = data->size, data->_buffer_size_ = data->buffer_length1, data->_tmp0_);
+ data->_tmp0_ = NULL;
+ data->_tmp0_ = g_new0 (guint8, data->size);
+ data->_tmp1_ = data->_tmp0_;
+ data->buffer_length1 = data->size;
+ data->_buffer_size_ = data->buffer_length1;
+ data->buffer = data->_tmp1_;
data->bufsize = (gssize) 1;
{
- data->_tmp1_ = TRUE;
+ data->_tmp2_ = TRUE;
while (TRUE) {
- if (!data->_tmp1_) {
+ if (!data->_tmp2_) {
if (!(data->bufsize > 0)) {
break;
}
}
- data->_tmp1_ = FALSE;
- {
- data->_state_ = 1;
- g_input_stream_read_async ((GInputStream*) data->self->priv->stream, data->buffer, (gsize) data->size, G_PRIORITY_DEFAULT, NULL, fetch_file_read_something_async_ready, data);
- return FALSE;
- _state_1:
- data->_tmp2_ = g_input_stream_read_finish ((GInputStream*) data->self->priv->stream, data->_res_, &data->_inner_error_);
- if (data->_inner_error_ != NULL) {
- goto __catch14_g_error;
- }
- data->bufsize = data->_tmp2_;
- if (data->bufsize < 1) {
- break;
- }
- if (data->bufsize != data->size) {
- data->cpybuf = (data->_tmp3_ = g_new0 (guint8, data->bufsize), data->cpybuf_length1 = data->bufsize, data->_cpybuf_size_ = data->cpybuf_length1, data->_tmp3_);
- memcpy (data->cpybuf, data->buffer, (gsize) data->bufsize);
- g_byte_array_append (data->self->priv->data, data->cpybuf, data->cpybuf_length1);
- data->cpybuf = (g_free (data->cpybuf), NULL);
- } else {
- g_byte_array_append (data->self->priv->data, data->buffer, data->buffer_length1);
- }
+ data->_tmp2_ = FALSE;
+ data->_state_ = 1;
+ g_input_stream_read_async ((GInputStream*) data->self->priv->stream, data->buffer, (gsize) data->buffer_length1, G_PRIORITY_DEFAULT, NULL, fetch_file_read_something_async_ready, data);
+ return FALSE;
+ _state_1:
+ data->_tmp3_ = g_input_stream_read_finish ((GInputStream*) data->self->priv->stream, data->_res_, &data->_inner_error_);
+ data->_tmp4_ = data->_tmp3_;
+ if (data->_inner_error_ != NULL) {
+ goto __catch14_g_error;
+ }
+ data->bufsize = data->_tmp4_;
+ if (data->bufsize < 1) {
+ break;
+ }
+ if (data->bufsize != data->size) {
+ data->_tmp5_ = NULL;
+ data->_tmp5_ = g_new0 (guint8, data->bufsize);
+ data->_tmp6_ = data->_tmp5_;
+ data->cpybuf_length1 = data->bufsize;
+ data->_cpybuf_size_ = data->cpybuf_length1;
+ data->cpybuf = data->_tmp6_;
+ memcpy (data->cpybuf, data->buffer, (gsize) data->bufsize);
+ g_byte_array_append (data->self->priv->data, data->cpybuf, data->cpybuf_length1);
+ data->cpybuf = (g_free (data->cpybuf), NULL);
+ } else {
+ g_byte_array_append (data->self->priv->data, data->buffer, data->buffer_length1);
}
goto __finally14;
__catch14_g_error:
{
data->e = data->_inner_error_;
data->_inner_error_ = NULL;
- {
- g_signal_emit_by_name (data->self, "failed");
- _g_error_free0 (data->e);
- }
+ g_signal_emit_by_name (data->self, "failed");
+ _g_error_free0 (data->e);
}
__finally14:
if (data->_inner_error_ != NULL) {
@@ -319,63 +340,94 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD
}
g_signal_emit_by_name (data->self, "completed", data->self->priv->data, data->self->priv->_intended_property);
data->buffer = (g_free (data->buffer), NULL);
- {
- if (data->_state_ == 0) {
- g_simple_async_result_complete_in_idle (data->_async_result);
- } else {
- g_simple_async_result_complete (data->_async_result);
- }
- g_object_unref (data->_async_result);
- return FALSE;
+ if (data->_state_ == 0) {
+ g_simple_async_result_complete_in_idle (data->_async_result);
+ } else {
+ g_simple_async_result_complete (data->_async_result);
}
+ g_object_unref (data->_async_result);
+ return FALSE;
}
-const char* fetch_file_get_uri (FetchFile* self) {
- const char* result;
+const gchar* fetch_file_get_uri (FetchFile* self) {
+ const gchar* result;
g_return_val_if_fail (self != NULL, NULL);
result = self->priv->_uri;
return result;
}
-static void fetch_file_set_uri (FetchFile* self, const char* value) {
- char* _tmp0_;
+static void fetch_file_set_uri (FetchFile* self, const gchar* value) {
+ gchar* _tmp0_;
+ gchar* _tmp1_;
g_return_if_fail (self != NULL);
- self->priv->_uri = (_tmp0_ = g_strdup (value), _g_free0 (self->priv->_uri), _tmp0_);
+ _tmp0_ = g_strdup (value);
+ _tmp1_ = _tmp0_;
+ _g_free0 (self->priv->_uri);
+ self->priv->_uri = _tmp1_;
g_object_notify ((GObject *) self, "uri");
}
-const char* fetch_file_get_intended_property (FetchFile* self) {
- const char* result;
+const gchar* fetch_file_get_intended_property (FetchFile* self) {
+ const gchar* result;
g_return_val_if_fail (self != NULL, NULL);
result = self->priv->_intended_property;
return result;
}
-static void fetch_file_set_intended_property (FetchFile* self, const char* value) {
- char* _tmp0_;
+static void fetch_file_set_intended_property (FetchFile* self, const gchar* value) {
+ gchar* _tmp0_;
+ gchar* _tmp1_;
g_return_if_fail (self != NULL);
- self->priv->_intended_property = (_tmp0_ = g_strdup (value), _g_free0 (self->priv->_intended_property), _tmp0_);
+ _tmp0_ = g_strdup (value);
+ _tmp1_ = _tmp0_;
+ _g_free0 (self->priv->_intended_property);
+ self->priv->_intended_property = _tmp1_;
g_object_notify ((GObject *) self, "intended-property");
}
+static void g_cclosure_user_marshal_VOID__POINTER_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
+ typedef void (*GMarshalFunc_VOID__POINTER_STRING) (gpointer data1, gpointer arg_1, const char* arg_2, gpointer data2);
+ register GMarshalFunc_VOID__POINTER_STRING callback;
+ register GCClosure * cc;
+ register gpointer data1, data2;
+ cc = (GCClosure *) closure;
+ g_return_if_fail (n_param_values == 3);
+ if (G_CCLOSURE_SWAP_DATA (closure)) {
+ data1 = closure->data;
+ data2 = param_values->data[0].v_pointer;
+ } else {
+ data1 = param_values->data[0].v_pointer;
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__POINTER_STRING) (marshal_data ? marshal_data : cc->callback);
+ callback (data1, g_value_get_pointer (param_values + 1), g_value_get_string (param_values + 2), data2);
+}
+
+
static GObject * fetch_file_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
GObject * obj;
GObjectClass * parent_class;
FetchFile * self;
+ GFile* _tmp0_ = NULL;
+ GFile* _tmp1_;
+ GByteArray* _tmp2_ = NULL;
+ GByteArray* _tmp3_;
parent_class = G_OBJECT_CLASS (fetch_file_parent_class);
obj = parent_class->constructor (type, n_construct_properties, construct_properties);
self = FETCH_FILE (obj);
- {
- GFile* _tmp0_;
- GByteArray* _tmp1_;
- self->priv->file = (_tmp0_ = g_file_new_for_uri (self->priv->_uri), _g_object_unref0 (self->priv->file), _tmp0_);
- self->priv->data = (_tmp1_ = g_byte_array_new (), _g_byte_array_free0 (self->priv->data), _tmp1_);
- }
+ _tmp0_ = g_file_new_for_uri (self->priv->_uri);
+ _tmp1_ = _tmp0_;
+ _g_object_unref0 (self->priv->file);
+ self->priv->file = _tmp1_;
+ _tmp2_ = g_byte_array_new ();
+ _tmp3_ = _tmp2_;
+ _g_byte_array_free0 (self->priv->data);
+ self->priv->data = _tmp3_;
return obj;
}
@@ -383,8 +435,8 @@ static GObject * fetch_file_constructor (GType type, guint n_construct_propertie
static void fetch_file_class_init (FetchFileClass * klass) {
fetch_file_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (FetchFilePrivate));
- G_OBJECT_CLASS (klass)->get_property = fetch_file_get_property;
- G_OBJECT_CLASS (klass)->set_property = fetch_file_set_property;
+ G_OBJECT_CLASS (klass)->get_property = _vala_fetch_file_get_property;
+ G_OBJECT_CLASS (klass)->set_property = _vala_fetch_file_set_property;
G_OBJECT_CLASS (klass)->constructor = fetch_file_constructor;
G_OBJECT_CLASS (klass)->finalize = fetch_file_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), FETCH_FILE_URI, g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
@@ -423,7 +475,7 @@ GType fetch_file_get_type (void) {
}
-static void fetch_file_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
+static void _vala_fetch_file_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
FetchFile * self;
self = FETCH_FILE (object);
switch (property_id) {
@@ -440,7 +492,7 @@ static void fetch_file_get_property (GObject * object, guint property_id, GValue
}
-static void fetch_file_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
+static void _vala_fetch_file_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
FetchFile * self;
self = FETCH_FILE (object);
switch (property_id) {
@@ -458,23 +510,3 @@ static void fetch_file_set_property (GObject * object, guint property_id, const
-static void g_cclosure_user_marshal_VOID__POINTER_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
- typedef void (*GMarshalFunc_VOID__POINTER_STRING) (gpointer data1, gpointer arg_1, const char* arg_2, gpointer data2);
- register GMarshalFunc_VOID__POINTER_STRING callback;
- register GCClosure * cc;
- register gpointer data1, data2;
- cc = (GCClosure *) closure;
- g_return_if_fail (n_param_values == 3);
- if (G_CCLOSURE_SWAP_DATA (closure)) {
- data1 = closure->data;
- data2 = param_values->data[0].v_pointer;
- } else {
- data1 = param_values->data[0].v_pointer;
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__POINTER_STRING) (marshal_data ? marshal_data : cc->callback);
- callback (data1, g_value_get_pointer (param_values + 1), g_value_get_string (param_values + 2), data2);
-}
-
-
-