Back to index

libunity  5.92.0
unity-io.c
Go to the documentation of this file.
00001 /* unity-io.c generated by valac 0.17.2, the Vala compiler
00002  * generated from unity-io.vala, do not modify */
00003 
00004 /*
00005  * Copyright (C) 2010 Canonical, Ltd.
00006  *
00007  * This library is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU Lesser General Public License
00009  * version 3.0 as published by the Free Software Foundation.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License version 3.0 for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library. If not, see
00018  * <http://www.gnu.org/licenses/>.
00019  *
00020  * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
00021  *
00022  */
00023 /*
00024  * IMPLEMENTATION NOTE:
00025  * We want the generatedd C API to be nice and not too Vala-ish. We must
00026  * anticipate that place daemons consuming libunity will be written in
00027  * both Vala and C.
00028  *
00029  */
00030 
00031 #include <glib.h>
00032 #include <glib-object.h>
00033 #include <gio/gio.h>
00034 #include "unity.h"
00035 #include <stdlib.h>
00036 #include <string.h>
00037 
00038 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
00039 typedef struct _UnityIoReadStreamAsyncData UnityIoReadStreamAsyncData;
00040 #define _g_free0(var) (var = (g_free (var), NULL))
00041 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
00042 typedef struct _UnityIoOpenFromDirsData UnityIoOpenFromDirsData;
00043 typedef struct _UnityIoOpenFromDataDirsData UnityIoOpenFromDataDirsData;
00044 
00045 struct _UnityIoReadStreamAsyncData {
00046        int _state_;
00047        GObject* _source_object_;
00048        GAsyncResult* _res_;
00049        GSimpleAsyncResult* _async_result;
00050        GInputStream* input;
00051        gint io_priority;
00052        GCancellable* cancellable;
00053        guint8* data;
00054        gint data_length1;
00055        gsize size;
00056        GMemoryOutputStream* _tmp0_;
00057        GMemoryOutputStream* output;
00058        GMemoryOutputStream* _tmp1_;
00059        GInputStream* _tmp2_;
00060        gint _tmp3_;
00061        GCancellable* _tmp4_;
00062        GMemoryOutputStream* _tmp5_;
00063        GMemoryOutputStream* _tmp6_;
00064        guint8* _tmp7_;
00065        GMemoryOutputStream* _tmp8_;
00066        gsize _tmp9_;
00067        GInputStream* _tmp10_;
00068        GError * _inner_error_;
00069 };
00070 
00071 struct _UnityIoOpenFromDirsData {
00072        int _state_;
00073        GObject* _source_object_;
00074        GAsyncResult* _res_;
00075        GSimpleAsyncResult* _async_result;
00076        gchar* filename;
00077        gchar** dirs;
00078        gint dirs_length1;
00079        GFileInputStream* result;
00080        gchar* path;
00081        GFile* datafile;
00082        gchar** _tmp0_;
00083        gint _tmp0__length1;
00084        gchar** dir_collection;
00085        gint dir_collection_length1;
00086        gint _dir_collection_size_;
00087        gint dir_it;
00088        gchar* _tmp1_;
00089        gchar* dir;
00090        const gchar* _tmp2_;
00091        const gchar* _tmp3_;
00092        gchar* _tmp4_;
00093        const gchar* _tmp5_;
00094        GFile* _tmp6_;
00095        GFile* _tmp7_;
00096        GFileInputStream* _tmp8_;
00097        GFileInputStream* _tmp9_;
00098        GError* ee;
00099        GError* _tmp10_;
00100        GError* _tmp11_;
00101        GError* _tmp12_;
00102        GError * _inner_error_;
00103 };
00104 
00105 struct _UnityIoOpenFromDataDirsData {
00106        int _state_;
00107        GObject* _source_object_;
00108        GAsyncResult* _res_;
00109        GSimpleAsyncResult* _async_result;
00110        gchar* filename;
00111        GFileInputStream* result;
00112        const gchar* _tmp0_;
00113        const gchar* _tmp1_;
00114        gchar* _tmp2_;
00115        gchar* path;
00116        const gchar* _tmp3_;
00117        GFile* _tmp4_;
00118        GFile* f;
00119        GFile* _tmp5_;
00120        GFileInputStream* _tmp6_;
00121        GFileInputStream* _tmp7_;
00122        GError* e;
00123        GError* _tmp8_;
00124        GError* _tmp9_;
00125        GError* _tmp10_;
00126        gint _tmp11_;
00127        gchar** _tmp12_;
00128        gchar** dirs;
00129        gint dirs_length1;
00130        gint _dirs_size_;
00131        const gchar* _tmp13_;
00132        gchar** _tmp14_;
00133        gint _tmp14__length1;
00134        GFileInputStream* _tmp15_;
00135        GFileInputStream* _tmp16_;
00136        GError * _inner_error_;
00137 };
00138 
00139 
00140 extern gchar** unity_io_system_data_dirs;
00141 extern gint unity_io_system_data_dirs_length1;
00142 gchar** unity_io_system_data_dirs = NULL;
00143 gint unity_io_system_data_dirs_length1 = 0;
00144 static gint _unity_io_system_data_dirs_size_ = 0;
00145 
00146 static void unity_io_read_stream_async_data_free (gpointer _data);
00147 static gboolean unity_io_read_stream_async_co (UnityIoReadStreamAsyncData* _data_);
00148 static void* _g_realloc_grealloc_func (void* data, gsize size);
00149 static void unity_io_read_stream_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
00150 static void unity_io_open_from_dirs_data_free (gpointer _data);
00151 static gboolean unity_io_open_from_dirs_co (UnityIoOpenFromDirsData* _data_);
00152 static void unity_io_open_from_dirs_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
00153 static void unity_io_open_from_data_dirs_data_free (gpointer _data);
00154 static gboolean unity_io_open_from_data_dirs_co (UnityIoOpenFromDataDirsData* _data_);
00155 static void unity_io_open_from_data_dirs_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
00156 static gchar** _vala_array_dup1 (gchar** self, int length);
00157 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
00158 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
00159 static gint _vala_array_length (gpointer array);
00160 
00161 
00162 static void unity_io_read_stream_async_data_free (gpointer _data) {
00163        UnityIoReadStreamAsyncData* _data_;
00164        _data_ = _data;
00165        _g_object_unref0 (_data_->input);
00166        _g_object_unref0 (_data_->cancellable);
00167        g_slice_free (UnityIoReadStreamAsyncData, _data_);
00168 }
00169 
00170 
00171 static gpointer _g_object_ref0 (gpointer self) {
00172        return self ? g_object_ref (self) : NULL;
00173 }
00174 
00175 
00176 void unity_io_read_stream_async (GInputStream* input, gint io_priority, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
00177        UnityIoReadStreamAsyncData* _data_;
00178        GInputStream* _tmp0_;
00179        GInputStream* _tmp1_;
00180        gint _tmp2_;
00181        GCancellable* _tmp3_;
00182        GCancellable* _tmp4_;
00183        _data_ = g_slice_new0 (UnityIoReadStreamAsyncData);
00184        _data_->_async_result = g_simple_async_result_new (g_object_newv (G_TYPE_OBJECT, 0, NULL), _callback_, _user_data_, unity_io_read_stream_async);
00185        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_io_read_stream_async_data_free);
00186        _tmp0_ = input;
00187        _tmp1_ = _g_object_ref0 (_tmp0_);
00188        _data_->input = _tmp1_;
00189        _tmp2_ = io_priority;
00190        _data_->io_priority = _tmp2_;
00191        _tmp3_ = cancellable;
00192        _tmp4_ = _g_object_ref0 (_tmp3_);
00193        _data_->cancellable = _tmp4_;
00194        unity_io_read_stream_async_co (_data_);
00195 }
00196 
00197 
00198 void unity_io_read_stream_finish (GAsyncResult* _res_, guint8** data, int* data_length1, gsize* size, GError** error) {
00199        UnityIoReadStreamAsyncData* _data_;
00200        if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
00201               return;
00202        }
00203        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
00204        if (data) {
00205               *data = _data_->data;
00206        } else {
00207               _data_->data = (g_free (_data_->data), NULL);
00208        }
00209        if (data_length1) {
00210               *data_length1 = _data_->data_length1;
00211        }
00212        _data_->data = NULL;
00213        if (size) {
00214               *size = _data_->size;
00215        }
00216 }
00217 
00218 
00223 static void* _g_realloc_grealloc_func (void* data, gsize size) {
00224        void* result;
00225        result = g_realloc (data, size);
00226        return result;
00227 }
00228 
00229 
00230 static void unity_io_read_stream_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
00231        UnityIoReadStreamAsyncData* _data_;
00232        _data_ = _user_data_;
00233        _data_->_source_object_ = source_object;
00234        _data_->_res_ = _res_;
00235        unity_io_read_stream_async_co (_data_);
00236 }
00237 
00238 
00239 static gboolean unity_io_read_stream_async_co (UnityIoReadStreamAsyncData* _data_) {
00240        switch (_data_->_state_) {
00241               case 0:
00242               goto _state_0;
00243               case 1:
00244               goto _state_1;
00245               default:
00246               g_assert_not_reached ();
00247        }
00248        _state_0:
00249        _data_->_tmp0_ = (GMemoryOutputStream*) g_memory_output_stream_new (NULL, 0, _g_realloc_grealloc_func, NULL);
00250        _data_->output = _data_->_tmp0_;
00251        _data_->_tmp1_ = _data_->output;
00252        _data_->_tmp2_ = _data_->input;
00253        _data_->_tmp3_ = _data_->io_priority;
00254        _data_->_tmp4_ = _data_->cancellable;
00255        _data_->_state_ = 1;
00256        g_output_stream_splice_async ((GOutputStream*) _data_->_tmp1_, _data_->_tmp2_, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE, _data_->_tmp3_, _data_->_tmp4_, unity_io_read_stream_async_ready, _data_);
00257        return FALSE;
00258        _state_1:
00259        g_output_stream_splice_finish ((GOutputStream*) _data_->_tmp1_, _data_->_res_, &_data_->_inner_error_);
00260        if (_data_->_inner_error_ != NULL) {
00261               if (_data_->_inner_error_->domain == G_IO_ERROR) {
00262                      g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
00263                      g_error_free (_data_->_inner_error_);
00264                      _g_object_unref0 (_data_->output);
00265                      if (_data_->_state_ == 0) {
00266                             g_simple_async_result_complete_in_idle (_data_->_async_result);
00267                      } else {
00268                             g_simple_async_result_complete (_data_->_async_result);
00269                      }
00270                      g_object_unref (_data_->_async_result);
00271                      return FALSE;
00272               } else {
00273                      _g_object_unref0 (_data_->output);
00274                      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);
00275                      g_clear_error (&_data_->_inner_error_);
00276                      return FALSE;
00277               }
00278        }
00279        _data_->_tmp5_ = _data_->output;
00280        g_output_stream_close ((GOutputStream*) _data_->_tmp5_, NULL, &_data_->_inner_error_);
00281        if (_data_->_inner_error_ != NULL) {
00282               if (_data_->_inner_error_->domain == G_IO_ERROR) {
00283                      g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
00284                      g_error_free (_data_->_inner_error_);
00285                      _g_object_unref0 (_data_->output);
00286                      if (_data_->_state_ == 0) {
00287                             g_simple_async_result_complete_in_idle (_data_->_async_result);
00288                      } else {
00289                             g_simple_async_result_complete (_data_->_async_result);
00290                      }
00291                      g_object_unref (_data_->_async_result);
00292                      return FALSE;
00293               } else {
00294                      _g_object_unref0 (_data_->output);
00295                      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);
00296                      g_clear_error (&_data_->_inner_error_);
00297                      return FALSE;
00298               }
00299        }
00300        _data_->_tmp6_ = _data_->output;
00301        _data_->_tmp7_ = NULL;
00302        _data_->_tmp7_ = g_memory_output_stream_steal_data (_data_->_tmp6_);
00303        _data_->data = (g_free (_data_->data), NULL);
00304        _data_->data = _data_->_tmp7_;
00305        _data_->data_length1 = -1;
00306        _data_->_tmp8_ = _data_->output;
00307        _data_->_tmp9_ = 0UL;
00308        _data_->_tmp9_ = g_memory_output_stream_get_data_size (_data_->_tmp8_);
00309        _data_->size = _data_->_tmp9_;
00310        _data_->_tmp10_ = _data_->input;
00311        g_input_stream_close_async (_data_->_tmp10_, G_PRIORITY_LOW, NULL, NULL, NULL);
00312        _g_object_unref0 (_data_->output);
00313        if (_data_->_state_ == 0) {
00314               g_simple_async_result_complete_in_idle (_data_->_async_result);
00315        } else {
00316               g_simple_async_result_complete (_data_->_async_result);
00317        }
00318        g_object_unref (_data_->_async_result);
00319        return FALSE;
00320 }
00321 
00322 
00323 static void unity_io_open_from_dirs_data_free (gpointer _data) {
00324        UnityIoOpenFromDirsData* _data_;
00325        _data_ = _data;
00326        _g_free0 (_data_->filename);
00327        _g_object_unref0 (_data_->result);
00328        g_slice_free (UnityIoOpenFromDirsData, _data_);
00329 }
00330 
00331 
00332 void unity_io_open_from_dirs (const gchar* filename, gchar** dirs, int dirs_length1, GAsyncReadyCallback _callback_, gpointer _user_data_) {
00333        UnityIoOpenFromDirsData* _data_;
00334        const gchar* _tmp0_;
00335        gchar* _tmp1_;
00336        gchar** _tmp2_;
00337        gint _tmp2__length1;
00338        _data_ = g_slice_new0 (UnityIoOpenFromDirsData);
00339        _data_->_async_result = g_simple_async_result_new (g_object_newv (G_TYPE_OBJECT, 0, NULL), _callback_, _user_data_, unity_io_open_from_dirs);
00340        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_io_open_from_dirs_data_free);
00341        _tmp0_ = filename;
00342        _tmp1_ = g_strdup (_tmp0_);
00343        _data_->filename = _tmp1_;
00344        _tmp2_ = dirs;
00345        _tmp2__length1 = dirs_length1;
00346        _data_->dirs = _tmp2_;
00347        _data_->dirs_length1 = _tmp2__length1;
00348        unity_io_open_from_dirs_co (_data_);
00349 }
00350 
00351 
00352 GFileInputStream* unity_io_open_from_dirs_finish (GAsyncResult* _res_, GError** error) {
00353        GFileInputStream* result;
00354        UnityIoOpenFromDirsData* _data_;
00355        if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
00356               return NULL;
00357        }
00358        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
00359        result = _data_->result;
00360        _data_->result = NULL;
00361        return result;
00362 }
00363 
00364 
00371 static void unity_io_open_from_dirs_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
00372        UnityIoOpenFromDirsData* _data_;
00373        _data_ = _user_data_;
00374        _data_->_source_object_ = source_object;
00375        _data_->_res_ = _res_;
00376        unity_io_open_from_dirs_co (_data_);
00377 }
00378 
00379 
00380 static gpointer _g_error_copy0 (gpointer self) {
00381        return self ? g_error_copy (self) : NULL;
00382 }
00383 
00384 
00385 static gboolean unity_io_open_from_dirs_co (UnityIoOpenFromDirsData* _data_) {
00386        switch (_data_->_state_) {
00387               case 0:
00388               goto _state_0;
00389               case 1:
00390               goto _state_1;
00391               default:
00392               g_assert_not_reached ();
00393        }
00394        _state_0:
00395        _data_->_tmp0_ = _data_->dirs;
00396        _data_->_tmp0__length1 = _data_->dirs_length1;
00397        {
00398               _data_->dir_collection_length1 = 0;
00399               _data_->_dir_collection_size_ = 0;
00400               _data_->dir_collection = _data_->_tmp0_;
00401               _data_->dir_collection_length1 = _data_->_tmp0__length1;
00402               for (_data_->dir_it = 0; _data_->dir_it < _data_->_tmp0__length1; _data_->dir_it = _data_->dir_it + 1) {
00403                      _data_->_tmp1_ = g_strdup (_data_->dir_collection[_data_->dir_it]);
00404                      _data_->dir = _data_->_tmp1_;
00405                      {
00406                             _data_->_tmp2_ = _data_->dir;
00407                             _data_->_tmp3_ = _data_->filename;
00408                             _data_->_tmp4_ = NULL;
00409                             _data_->_tmp4_ = g_build_filename (_data_->_tmp2_, _data_->_tmp3_, NULL, NULL);
00410                             _g_free0 (_data_->path);
00411                             _data_->path = _data_->_tmp4_;
00412                             _data_->_tmp5_ = _data_->path;
00413                             _data_->_tmp6_ = NULL;
00414                             _data_->_tmp6_ = g_file_new_for_path (_data_->_tmp5_);
00415                             _g_object_unref0 (_data_->datafile);
00416                             _data_->datafile = _data_->_tmp6_;
00417                             {
00418                                    _data_->_tmp7_ = _data_->datafile;
00419                                    _data_->_state_ = 1;
00420                                    g_file_read_async (_data_->_tmp7_, G_PRIORITY_DEFAULT, NULL, unity_io_open_from_dirs_ready, _data_);
00421                                    return FALSE;
00422                                    _state_1:
00423                                    _data_->_tmp8_ = NULL;
00424                                    _data_->_tmp8_ = g_file_read_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error_);
00425                                    _data_->_tmp9_ = _data_->_tmp8_;
00426                                    if (_data_->_inner_error_ != NULL) {
00427                                           goto __catch12_g_error;
00428                                    }
00429                                    _data_->result = _data_->_tmp9_;
00430                                    _g_free0 (_data_->dir);
00431                                    _g_object_unref0 (_data_->datafile);
00432                                    _g_free0 (_data_->path);
00433                                    if (_data_->_state_ == 0) {
00434                                           g_simple_async_result_complete_in_idle (_data_->_async_result);
00435                                    } else {
00436                                           g_simple_async_result_complete (_data_->_async_result);
00437                                    }
00438                                    g_object_unref (_data_->_async_result);
00439                                    return FALSE;
00440                             }
00441                             goto __finally12;
00442                             __catch12_g_error:
00443                             {
00444                                    _data_->ee = _data_->_inner_error_;
00445                                    _data_->_inner_error_ = NULL;
00446                                    _data_->_tmp10_ = _data_->ee;
00447                                    if (!g_error_matches (_data_->_tmp10_, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
00448                                           _data_->_tmp11_ = _data_->ee;
00449                                           _data_->_tmp12_ = _g_error_copy0 (_data_->_tmp11_);
00450                                           _data_->_inner_error_ = _data_->_tmp12_;
00451                                           _g_error_free0 (_data_->ee);
00452                                           goto __finally12;
00453                                    }
00454                                    _g_error_free0 (_data_->ee);
00455                             }
00456                             __finally12:
00457                             if (_data_->_inner_error_ != NULL) {
00458                                    g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
00459                                    g_error_free (_data_->_inner_error_);
00460                                    _g_free0 (_data_->dir);
00461                                    _g_object_unref0 (_data_->datafile);
00462                                    _g_free0 (_data_->path);
00463                                    if (_data_->_state_ == 0) {
00464                                           g_simple_async_result_complete_in_idle (_data_->_async_result);
00465                                    } else {
00466                                           g_simple_async_result_complete (_data_->_async_result);
00467                                    }
00468                                    g_object_unref (_data_->_async_result);
00469                                    return FALSE;
00470                             }
00471                             _g_free0 (_data_->dir);
00472                      }
00473               }
00474        }
00475        _data_->result = NULL;
00476        _g_object_unref0 (_data_->datafile);
00477        _g_free0 (_data_->path);
00478        if (_data_->_state_ == 0) {
00479               g_simple_async_result_complete_in_idle (_data_->_async_result);
00480        } else {
00481               g_simple_async_result_complete (_data_->_async_result);
00482        }
00483        g_object_unref (_data_->_async_result);
00484        return FALSE;
00485        _g_object_unref0 (_data_->datafile);
00486        _g_free0 (_data_->path);
00487        if (_data_->_state_ == 0) {
00488               g_simple_async_result_complete_in_idle (_data_->_async_result);
00489        } else {
00490               g_simple_async_result_complete (_data_->_async_result);
00491        }
00492        g_object_unref (_data_->_async_result);
00493        return FALSE;
00494 }
00495 
00496 
00497 static void unity_io_open_from_data_dirs_data_free (gpointer _data) {
00498        UnityIoOpenFromDataDirsData* _data_;
00499        _data_ = _data;
00500        _g_free0 (_data_->filename);
00501        _g_object_unref0 (_data_->result);
00502        g_slice_free (UnityIoOpenFromDataDirsData, _data_);
00503 }
00504 
00505 
00506 void unity_io_open_from_data_dirs (const gchar* filename, GAsyncReadyCallback _callback_, gpointer _user_data_) {
00507        UnityIoOpenFromDataDirsData* _data_;
00508        const gchar* _tmp0_;
00509        gchar* _tmp1_;
00510        _data_ = g_slice_new0 (UnityIoOpenFromDataDirsData);
00511        _data_->_async_result = g_simple_async_result_new (g_object_newv (G_TYPE_OBJECT, 0, NULL), _callback_, _user_data_, unity_io_open_from_data_dirs);
00512        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_io_open_from_data_dirs_data_free);
00513        _tmp0_ = filename;
00514        _tmp1_ = g_strdup (_tmp0_);
00515        _data_->filename = _tmp1_;
00516        unity_io_open_from_data_dirs_co (_data_);
00517 }
00518 
00519 
00520 GFileInputStream* unity_io_open_from_data_dirs_finish (GAsyncResult* _res_, GError** error) {
00521        GFileInputStream* result;
00522        UnityIoOpenFromDataDirsData* _data_;
00523        if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
00524               return NULL;
00525        }
00526        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
00527        result = _data_->result;
00528        _data_->result = NULL;
00529        return result;
00530 }
00531 
00532 
00537 static void unity_io_open_from_data_dirs_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
00538        UnityIoOpenFromDataDirsData* _data_;
00539        _data_ = _user_data_;
00540        _data_->_source_object_ = source_object;
00541        _data_->_res_ = _res_;
00542        unity_io_open_from_data_dirs_co (_data_);
00543 }
00544 
00545 
00546 static gboolean unity_io_open_from_data_dirs_co (UnityIoOpenFromDataDirsData* _data_) {
00547        switch (_data_->_state_) {
00548               case 0:
00549               goto _state_0;
00550               case 1:
00551               goto _state_1;
00552               case 2:
00553               goto _state_2;
00554               default:
00555               g_assert_not_reached ();
00556        }
00557        _state_0:
00558        _data_->_tmp0_ = NULL;
00559        _data_->_tmp0_ = g_get_user_data_dir ();
00560        _data_->_tmp1_ = _data_->filename;
00561        _data_->_tmp2_ = NULL;
00562        _data_->_tmp2_ = g_build_filename (_data_->_tmp0_, _data_->_tmp1_, NULL, NULL);
00563        _data_->path = _data_->_tmp2_;
00564        _data_->_tmp3_ = _data_->path;
00565        _data_->_tmp4_ = NULL;
00566        _data_->_tmp4_ = g_file_new_for_path (_data_->_tmp3_);
00567        _data_->f = _data_->_tmp4_;
00568        {
00569               _data_->_tmp5_ = _data_->f;
00570               _data_->_state_ = 1;
00571               g_file_read_async (_data_->_tmp5_, G_PRIORITY_DEFAULT, NULL, unity_io_open_from_data_dirs_ready, _data_);
00572               return FALSE;
00573               _state_1:
00574               _data_->_tmp6_ = NULL;
00575               _data_->_tmp6_ = g_file_read_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error_);
00576               _data_->_tmp7_ = _data_->_tmp6_;
00577               if (_data_->_inner_error_ != NULL) {
00578                      goto __catch13_g_error;
00579               }
00580               _data_->result = _data_->_tmp7_;
00581               _g_object_unref0 (_data_->f);
00582               _g_free0 (_data_->path);
00583               if (_data_->_state_ == 0) {
00584                      g_simple_async_result_complete_in_idle (_data_->_async_result);
00585               } else {
00586                      g_simple_async_result_complete (_data_->_async_result);
00587               }
00588               g_object_unref (_data_->_async_result);
00589               return FALSE;
00590        }
00591        goto __finally13;
00592        __catch13_g_error:
00593        {
00594               _data_->e = _data_->_inner_error_;
00595               _data_->_inner_error_ = NULL;
00596               _data_->_tmp8_ = _data_->e;
00597               if (!g_error_matches (_data_->_tmp8_, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
00598                      _data_->_tmp9_ = _data_->e;
00599                      _data_->_tmp10_ = _g_error_copy0 (_data_->_tmp9_);
00600                      _data_->_inner_error_ = _data_->_tmp10_;
00601                      _g_error_free0 (_data_->e);
00602                      goto __finally13;
00603               }
00604               _g_error_free0 (_data_->e);
00605        }
00606        __finally13:
00607        if (_data_->_inner_error_ != NULL) {
00608               g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
00609               g_error_free (_data_->_inner_error_);
00610               _g_object_unref0 (_data_->f);
00611               _g_free0 (_data_->path);
00612               if (_data_->_state_ == 0) {
00613                      g_simple_async_result_complete_in_idle (_data_->_async_result);
00614               } else {
00615                      g_simple_async_result_complete (_data_->_async_result);
00616               }
00617               g_object_unref (_data_->_async_result);
00618               return FALSE;
00619        }
00620        _data_->_tmp11_ = 0;
00621        _data_->_tmp12_ = NULL;
00622        _data_->_tmp12_ = unity_io_get_system_data_dirs (&_data_->_tmp11_);
00623        _data_->dirs = _data_->_tmp12_;
00624        _data_->dirs_length1 = _data_->_tmp11_;
00625        _data_->_dirs_size_ = _data_->dirs_length1;
00626        _data_->_tmp13_ = _data_->filename;
00627        _data_->_tmp14_ = _data_->dirs;
00628        _data_->_tmp14__length1 = _data_->dirs_length1;
00629        _data_->_state_ = 2;
00630        unity_io_open_from_dirs (_data_->_tmp13_, _data_->_tmp14_, _data_->_tmp14__length1, unity_io_open_from_data_dirs_ready, _data_);
00631        return FALSE;
00632        _state_2:
00633        _data_->_tmp15_ = NULL;
00634        _data_->_tmp15_ = unity_io_open_from_dirs_finish (_data_->_res_, &_data_->_inner_error_);
00635        _data_->_tmp16_ = _data_->_tmp15_;
00636        if (_data_->_inner_error_ != NULL) {
00637               g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
00638               g_error_free (_data_->_inner_error_);
00639               _data_->dirs = (_vala_array_free (_data_->dirs, _data_->dirs_length1, (GDestroyNotify) g_free), NULL);
00640               _g_object_unref0 (_data_->f);
00641               _g_free0 (_data_->path);
00642               if (_data_->_state_ == 0) {
00643                      g_simple_async_result_complete_in_idle (_data_->_async_result);
00644               } else {
00645                      g_simple_async_result_complete (_data_->_async_result);
00646               }
00647               g_object_unref (_data_->_async_result);
00648               return FALSE;
00649        }
00650        _data_->result = _data_->_tmp16_;
00651        _data_->dirs = (_vala_array_free (_data_->dirs, _data_->dirs_length1, (GDestroyNotify) g_free), NULL);
00652        _g_object_unref0 (_data_->f);
00653        _g_free0 (_data_->path);
00654        if (_data_->_state_ == 0) {
00655               g_simple_async_result_complete_in_idle (_data_->_async_result);
00656        } else {
00657               g_simple_async_result_complete (_data_->_async_result);
00658        }
00659        g_object_unref (_data_->_async_result);
00660        return FALSE;
00661        _data_->dirs = (_vala_array_free (_data_->dirs, _data_->dirs_length1, (GDestroyNotify) g_free), NULL);
00662        _g_object_unref0 (_data_->f);
00663        _g_free0 (_data_->path);
00664        if (_data_->_state_ == 0) {
00665               g_simple_async_result_complete_in_idle (_data_->_async_result);
00666        } else {
00667               g_simple_async_result_complete (_data_->_async_result);
00668        }
00669        g_object_unref (_data_->_async_result);
00670        return FALSE;
00671 }
00672 
00673 
00674 static gchar** _vala_array_dup1 (gchar** self, int length) {
00675        gchar** result;
00676        int i;
00677        result = g_new0 (gchar*, length + 1);
00678        for (i = 0; i < length; i++) {
00679               gchar* _tmp0_;
00680               _tmp0_ = g_strdup (self[i]);
00681               result[i] = _tmp0_;
00682        }
00683        return result;
00684 }
00685 
00686 
00687 gchar** unity_io_get_system_data_dirs (int* result_length1) {
00688        gchar** result = NULL;
00689        gchar** _tmp0_;
00690        gint _tmp0__length1;
00691        gchar** _tmp8_;
00692        gint _tmp8__length1;
00693        gchar** _tmp9_;
00694        gint _tmp9__length1;
00695        gchar** _tmp10_;
00696        gint _tmp10__length1;
00697        _tmp0_ = unity_io_system_data_dirs;
00698        _tmp0__length1 = unity_io_system_data_dirs_length1;
00699        if (_tmp0_ == NULL) {
00700               const gchar* _tmp1_ = NULL;
00701               gchar* _tmp2_;
00702               gchar* dirs;
00703               const gchar* _tmp3_;
00704               _tmp1_ = g_getenv ("XDG_DATA_DIRS");
00705               _tmp2_ = g_strdup (_tmp1_);
00706               dirs = _tmp2_;
00707               _tmp3_ = dirs;
00708               if (_tmp3_ != NULL) {
00709                      const gchar* _tmp4_;
00710                      gchar** _tmp5_;
00711                      gchar** _tmp6_ = NULL;
00712                      _tmp4_ = dirs;
00713                      _tmp6_ = _tmp5_ = g_strsplit (_tmp4_, ":", 0);
00714                      unity_io_system_data_dirs = (_vala_array_free (unity_io_system_data_dirs, unity_io_system_data_dirs_length1, (GDestroyNotify) g_free), NULL);
00715                      unity_io_system_data_dirs = _tmp6_;
00716                      unity_io_system_data_dirs_length1 = _vala_array_length (_tmp5_);
00717                      _unity_io_system_data_dirs_size_ = unity_io_system_data_dirs_length1;
00718               } else {
00719                      gchar** _tmp7_ = NULL;
00720                      _tmp7_ = g_new0 (gchar*, 0 + 1);
00721                      unity_io_system_data_dirs = (_vala_array_free (unity_io_system_data_dirs, unity_io_system_data_dirs_length1, (GDestroyNotify) g_free), NULL);
00722                      unity_io_system_data_dirs = _tmp7_;
00723                      unity_io_system_data_dirs_length1 = 0;
00724                      _unity_io_system_data_dirs_size_ = unity_io_system_data_dirs_length1;
00725               }
00726               _g_free0 (dirs);
00727        }
00728        _tmp8_ = unity_io_system_data_dirs;
00729        _tmp8__length1 = unity_io_system_data_dirs_length1;
00730        _tmp9_ = (_tmp8_ != NULL) ? _vala_array_dup1 (_tmp8_, _tmp8__length1) : ((gpointer) _tmp8_);
00731        _tmp9__length1 = _tmp8__length1;
00732        _tmp10_ = _tmp9_;
00733        _tmp10__length1 = _tmp9__length1;
00734        if (result_length1) {
00735               *result_length1 = _tmp10__length1;
00736        }
00737        result = _tmp10_;
00738        return result;
00739 }
00740 
00741 
00742 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
00743        if ((array != NULL) && (destroy_func != NULL)) {
00744               int i;
00745               for (i = 0; i < array_length; i = i + 1) {
00746                      if (((gpointer*) array)[i] != NULL) {
00747                             destroy_func (((gpointer*) array)[i]);
00748                      }
00749               }
00750        }
00751 }
00752 
00753 
00754 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
00755        _vala_array_destroy (array, array_length, destroy_func);
00756        g_free (array);
00757 }
00758 
00759 
00760 static gint _vala_array_length (gpointer array) {
00761        int length;
00762        length = 0;
00763        if (array) {
00764               while (((gpointer*) array)[length]) {
00765                      length++;
00766               }
00767        }
00768        return length;
00769 }
00770 
00771 
00772