diff options
author | Sebastien Bacher <seb128@ubuntu.com> | 2012-02-14 19:29:13 +0100 |
---|---|---|
committer | Sebastien Bacher <seb128@ubuntu.com> | 2012-02-14 19:29:13 +0100 |
commit | 302256286a5e443a67592b7addd02c0633531cfc (patch) | |
tree | 1623ee0440ce55bbfe49ea420363dd32d1833522 /src/fetch-file.c | |
parent | c157f744805b87d39eb49ee162645d9af25b05b5 (diff) | |
parent | bd884a0a4b3a64c2f8d6757a0598993ee9297eef (diff) | |
download | ayatana-indicator-sound-302256286a5e443a67592b7addd02c0633531cfc.tar.gz ayatana-indicator-sound-302256286a5e443a67592b7addd02c0633531cfc.tar.bz2 ayatana-indicator-sound-302256286a5e443a67592b7addd02c0633531cfc.zip |
Import upstream version 0.8.1.0
Diffstat (limited to 'src/fetch-file.c')
-rw-r--r-- | src/fetch-file.c | 313 |
1 files changed, 120 insertions, 193 deletions
diff --git a/src/fetch-file.c b/src/fetch-file.c index e5f36b1..401c53f 100644 --- a/src/fetch-file.c +++ b/src/fetch-file.c @@ -1,4 +1,4 @@ -/* fetch-file.c generated by valac 0.14.0, the Vala compiler +/* fetch-file.c generated by valac 0.12.1, the Vala compiler * generated from fetch-file.vala, do not modify */ /* @@ -69,13 +69,11 @@ struct _FetchFileFetchDataData { GAsyncResult* _res_; GSimpleAsyncResult* _async_result; FetchFile* self; - GFile* _tmp0_; + GFileInputStream* _tmp0_; GFileInputStream* _tmp1_; GFileInputStream* _tmp2_; - GFileInputStream* _tmp3_; - GDataInputStream* _tmp4_; - GDataInputStream* _tmp5_; - GError* e; + GDataInputStream* _tmp3_; + GError * e; GError * _inner_error_; }; @@ -86,42 +84,19 @@ struct _FetchFileReadSomethingAsyncData { GSimpleAsyncResult* _async_result; FetchFile* self; gssize size; - gssize _tmp0_; - guint8* _tmp1_; + guint8* _tmp0_; guint8* buffer; gint buffer_length1; gint _buffer_size_; gssize bufsize; - gboolean _tmp2_; - gboolean _tmp3_; - gssize _tmp4_; - GDataInputStream* _tmp5_; - guint8* _tmp6_; - gint _tmp6__length1; - gssize _tmp7_; - gssize _tmp8_; - gssize _tmp9_; - gssize _tmp10_; - gssize _tmp11_; - gssize _tmp12_; - guint8* _tmp13_; + gboolean _tmp1_; + gssize _tmp2_; + gssize _tmp3_; + guint8* _tmp4_; guint8* cpybuf; gint cpybuf_length1; gint _cpybuf_size_; - guint8* _tmp14_; - gint _tmp14__length1; - guint8* _tmp15_; - gint _tmp15__length1; - gssize _tmp16_; - GByteArray* _tmp17_; - guint8* _tmp18_; - gint _tmp18__length1; - GByteArray* _tmp19_; - guint8* _tmp20_; - gint _tmp20__length1; - GError* e; - GByteArray* _tmp21_; - const gchar* _tmp22_; + GError * e; GError * _inner_error_; }; @@ -140,11 +115,11 @@ FetchFile* fetch_file_construct (GType object_type, const gchar* uri, const gcha static void fetch_file_fetch_data_data_free (gpointer _data); void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_); void fetch_file_fetch_data_finish (FetchFile* self, GAsyncResult* _res_); -static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* _data_); +static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data); static void fetch_file_read_something_async (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_); static void fetch_file_read_something_finish (FetchFile* self, GAsyncResult* _res_); static void fetch_file_read_something_async_data_free (gpointer _data); -static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncData* _data_); +static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncData* data); static void fetch_file_read_something_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_); const gchar* fetch_file_get_intended_property (FetchFile* self); const gchar* fetch_file_get_uri (FetchFile* self); @@ -159,13 +134,9 @@ static void _vala_fetch_file_set_property (GObject * object, guint property_id, FetchFile* fetch_file_construct (GType object_type, const gchar* uri, const gchar* prop) { FetchFile * self = NULL; - const gchar* _tmp0_; - const gchar* _tmp1_; g_return_val_if_fail (uri != NULL, NULL); g_return_val_if_fail (prop != NULL, NULL); - _tmp0_ = uri; - _tmp1_ = prop; - self = (FetchFile*) g_object_new (object_type, "uri", _tmp0_, "intended-property", _tmp1_, NULL); + self = (FetchFile*) g_object_new (object_type, "uri", uri, "intended-property", prop, NULL); return self; } @@ -176,10 +147,10 @@ FetchFile* fetch_file_new (const gchar* uri, const gchar* prop) { static void fetch_file_fetch_data_data_free (gpointer _data) { - FetchFileFetchDataData* _data_; - _data_ = _data; - _g_object_unref0 (_data_->self); - g_slice_free (FetchFileFetchDataData, _data_); + FetchFileFetchDataData* data; + data = _data; + _g_object_unref0 (data->self); + g_slice_free (FetchFileFetchDataData, data); } @@ -190,12 +161,10 @@ static gpointer _g_object_ref0 (gpointer self) { void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_) { FetchFileFetchDataData* _data_; - FetchFile* _tmp0_; _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); - _tmp0_ = _g_object_ref0 (self); - _data_->self = _tmp0_; + _data_->self = _g_object_ref0 (self); fetch_file_fetch_data_co (_data_); } @@ -206,71 +175,66 @@ void fetch_file_fetch_data_finish (FetchFile* self, GAsyncResult* _res_) { } -static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* _data_) { - switch (_data_->_state_) { +static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) { + switch (data->_state_) { case 0: goto _state_0; default: g_assert_not_reached (); } _state_0: - { - _data_->_tmp0_ = _data_->self->priv->file; - _data_->_tmp1_ = NULL; - _data_->_tmp1_ = g_file_read (_data_->_tmp0_, NULL, &_data_->_inner_error_); - _data_->_tmp2_ = _data_->_tmp1_; - if (_data_->_inner_error_ != NULL) { - goto __catch14_g_error; - } - _data_->_tmp3_ = _data_->_tmp2_; - _data_->_tmp4_ = g_data_input_stream_new ((GInputStream*) _data_->_tmp3_); - _g_object_unref0 (_data_->self->priv->stream); - _data_->self->priv->stream = _data_->_tmp4_; - _g_object_unref0 (_data_->_tmp3_); - _data_->_tmp5_ = _data_->self->priv->stream; - g_data_input_stream_set_byte_order (_data_->_tmp5_, 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 __catch14_g_error; } + data->_tmp2_ = data->_tmp1_; + data->_tmp3_ = NULL; + data->_tmp3_ = g_data_input_stream_new ((GInputStream*) data->_tmp2_); + _g_object_unref0 (data->self->priv->stream); + data->self->priv->stream = data->_tmp3_; + _g_object_unref0 (data->_tmp2_); + g_data_input_stream_set_byte_order (data->self->priv->stream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN); 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); + data->e = data->_inner_error_; + data->_inner_error_ = NULL; + g_signal_emit_by_name (data->self, "failed"); + _g_error_free0 (data->e); } __finally14: - if (_data_->_inner_error_ != NULL) { - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code); - g_clear_error (&_data_->_inner_error_); + if (data->_inner_error_ != NULL) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code); + g_clear_error (&data->_inner_error_); 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); + 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_simple_async_result_complete (data->_async_result); } - g_object_unref (_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_unref0 (_data_->self); - g_slice_free (FetchFileReadSomethingAsyncData, _data_); + FetchFileReadSomethingAsyncData* data; + data = _data; + _g_object_unref0 (data->self); + g_slice_free (FetchFileReadSomethingAsyncData, data); } static void fetch_file_read_something_async (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_) { FetchFileReadSomethingAsyncData* _data_; - FetchFile* _tmp0_; _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); - _tmp0_ = _g_object_ref0 (self); - _data_->self = _tmp0_; + _data_->self = _g_object_ref0 (self); fetch_file_read_something_async_co (_data_); } @@ -282,16 +246,16 @@ 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_); + FetchFileReadSomethingAsyncData* data; + data = _user_data_; + data->_source_object_ = source_object; + data->_res_ = _res_; + fetch_file_read_something_async_co (data); } -static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncData* _data_) { - switch (_data_->_state_) { +static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncData* data) { + switch (data->_state_) { case 0: goto _state_0; case 1: @@ -300,142 +264,108 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD g_assert_not_reached (); } _state_0: - _data_->size = (gssize) 1024; - _data_->_tmp0_ = _data_->size; - _data_->_tmp1_ = NULL; - _data_->_tmp1_ = g_new0 (guint8, _data_->_tmp0_); - _data_->buffer = _data_->_tmp1_; - _data_->buffer_length1 = _data_->_tmp0_; - _data_->_buffer_size_ = _data_->buffer_length1; - _data_->bufsize = (gssize) 1; + data->size = (gssize) 1024; + data->_tmp0_ = NULL; + data->_tmp0_ = g_new0 (guint8, data->size); + data->buffer = data->_tmp0_; + data->buffer_length1 = data->size; + data->_buffer_size_ = data->size; + data->bufsize = (gssize) 1; { - _data_->_tmp2_ = TRUE; + data->_tmp1_ = TRUE; while (TRUE) { - _data_->_tmp3_ = _data_->_tmp2_; - if (!_data_->_tmp3_) { - _data_->_tmp4_ = _data_->bufsize; - if (!(_data_->_tmp4_ > ((gssize) 0))) { + if (!data->_tmp1_) { + if (!(data->bufsize > 0)) { break; } } - _data_->_tmp2_ = FALSE; - { - _data_->_tmp5_ = _data_->self->priv->stream; - _data_->_tmp6_ = _data_->buffer; - _data_->_tmp6__length1 = _data_->buffer_length1; - _data_->_state_ = 1; - g_input_stream_read_async ((GInputStream*) _data_->_tmp5_, _data_->_tmp6_, (gsize) _data_->_tmp6__length1, G_PRIORITY_DEFAULT, NULL, fetch_file_read_something_async_ready, _data_); - return FALSE; - _state_1: - _data_->_tmp7_ = 0L; - _data_->_tmp7_ = g_input_stream_read_finish ((GInputStream*) _data_->_tmp5_, _data_->_res_, &_data_->_inner_error_); - _data_->_tmp8_ = _data_->_tmp7_; - if (_data_->_inner_error_ != NULL) { - goto __catch15_g_error; - } - _data_->bufsize = _data_->_tmp8_; - _data_->_tmp9_ = _data_->bufsize; - if (_data_->_tmp9_ < ((gssize) 1)) { - break; - } - _data_->_tmp10_ = _data_->bufsize; - _data_->_tmp11_ = _data_->size; - if (_data_->_tmp10_ != _data_->_tmp11_) { - _data_->_tmp12_ = _data_->bufsize; - _data_->_tmp13_ = NULL; - _data_->_tmp13_ = g_new0 (guint8, _data_->_tmp12_); - _data_->cpybuf = _data_->_tmp13_; - _data_->cpybuf_length1 = _data_->_tmp12_; - _data_->_cpybuf_size_ = _data_->cpybuf_length1; - _data_->_tmp14_ = _data_->cpybuf; - _data_->_tmp14__length1 = _data_->cpybuf_length1; - _data_->_tmp15_ = _data_->buffer; - _data_->_tmp15__length1 = _data_->buffer_length1; - _data_->_tmp16_ = _data_->bufsize; - memcpy (_data_->_tmp14_, _data_->_tmp15_, (gsize) _data_->_tmp16_); - _data_->_tmp17_ = _data_->self->priv->data; - _data_->_tmp18_ = _data_->cpybuf; - _data_->_tmp18__length1 = _data_->cpybuf_length1; - g_byte_array_append (_data_->_tmp17_, _data_->_tmp18_, _data_->_tmp18__length1); - _data_->cpybuf = (g_free (_data_->cpybuf), NULL); - } else { - _data_->_tmp19_ = _data_->self->priv->data; - _data_->_tmp20_ = _data_->buffer; - _data_->_tmp20__length1 = _data_->buffer_length1; - g_byte_array_append (_data_->_tmp19_, _data_->_tmp20_, _data_->_tmp20__length1); - } + data->_tmp1_ = 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->_tmp2_ = g_input_stream_read_finish ((GInputStream*) data->self->priv->stream, data->_res_, &data->_inner_error_); + data->_tmp3_ = data->_tmp2_; + if (data->_inner_error_ != NULL) { + goto __catch15_g_error; + } + data->bufsize = data->_tmp3_; + if (data->bufsize < 1) { + break; + } + if (data->bufsize != data->size) { + data->_tmp4_ = NULL; + data->_tmp4_ = g_new0 (guint8, data->bufsize); + data->cpybuf = data->_tmp4_; + data->cpybuf_length1 = data->bufsize; + data->_cpybuf_size_ = data->bufsize; + 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 __finally15; __catch15_g_error: { - _data_->e = _data_->_inner_error_; - _data_->_inner_error_ = NULL; - g_signal_emit_by_name (_data_->self, "failed"); - _g_error_free0 (_data_->e); + data->e = data->_inner_error_; + data->_inner_error_ = NULL; + g_signal_emit_by_name (data->self, "failed"); + _g_error_free0 (data->e); } __finally15: - if (_data_->_inner_error_ != NULL) { - _data_->buffer = (g_free (_data_->buffer), NULL); - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code); - g_clear_error (&_data_->_inner_error_); + if (data->_inner_error_ != NULL) { + data->buffer = (g_free (data->buffer), NULL); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code); + g_clear_error (&data->_inner_error_); return FALSE; } } } - _data_->_tmp21_ = _data_->self->priv->data; - _data_->_tmp22_ = _data_->self->priv->_intended_property; - g_signal_emit_by_name (_data_->self, "completed", _data_->_tmp21_, _data_->_tmp22_); - _data_->buffer = (g_free (_data_->buffer), NULL); - if (_data_->_state_ == 0) { - g_simple_async_result_complete_in_idle (_data_->_async_result); + 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_simple_async_result_complete (data->_async_result); } - g_object_unref (_data_->_async_result); + g_object_unref (data->_async_result); return FALSE; } const gchar* fetch_file_get_uri (FetchFile* self) { const gchar* result; - const gchar* _tmp0_; g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = self->priv->_uri; - result = _tmp0_; + result = self->priv->_uri; return result; } static void fetch_file_set_uri (FetchFile* self, const gchar* value) { - const gchar* _tmp0_; - gchar* _tmp1_; + gchar* _tmp0_; g_return_if_fail (self != NULL); - _tmp0_ = value; - _tmp1_ = g_strdup (_tmp0_); + _tmp0_ = g_strdup (value); _g_free0 (self->priv->_uri); - self->priv->_uri = _tmp1_; + self->priv->_uri = _tmp0_; g_object_notify ((GObject *) self, "uri"); } const gchar* fetch_file_get_intended_property (FetchFile* self) { const gchar* result; - const gchar* _tmp0_; g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = self->priv->_intended_property; - result = _tmp0_; + result = self->priv->_intended_property; return result; } static void fetch_file_set_intended_property (FetchFile* self, const gchar* value) { - const gchar* _tmp0_; - gchar* _tmp1_; + gchar* _tmp0_; g_return_if_fail (self != NULL); - _tmp0_ = value; - _tmp1_ = g_strdup (_tmp0_); + _tmp0_ = g_strdup (value); _g_free0 (self->priv->_intended_property); - self->priv->_intended_property = _tmp1_; + self->priv->_intended_property = _tmp0_; g_object_notify ((GObject *) self, "intended-property"); } @@ -444,8 +374,7 @@ static void g_cclosure_user_marshal_VOID__POINTER_STRING (GClosure * closure, GV 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; - register gpointer data2; + register gpointer data1, data2; cc = (GCClosure *) closure; g_return_if_fail (n_param_values == 3); if (G_CCLOSURE_SWAP_DATA (closure)) { @@ -464,19 +393,17 @@ static GObject * fetch_file_constructor (GType type, guint n_construct_propertie GObject * obj; GObjectClass * parent_class; FetchFile * self; - const gchar* _tmp0_; - GFile* _tmp1_ = NULL; - GByteArray* _tmp2_; + GFile* _tmp0_ = NULL; + GByteArray* _tmp1_ = NULL; parent_class = G_OBJECT_CLASS (fetch_file_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = FETCH_FILE (obj); - _tmp0_ = self->priv->_uri; - _tmp1_ = g_file_new_for_uri (_tmp0_); + _tmp0_ = g_file_new_for_uri (self->priv->_uri); _g_object_unref0 (self->priv->file); - self->priv->file = _tmp1_; - _tmp2_ = g_byte_array_new (); + self->priv->file = _tmp0_; + _tmp1_ = g_byte_array_new (); _g_byte_array_free0 (self->priv->data); - self->priv->data = _tmp2_; + self->priv->data = _tmp1_; return obj; } |