gio2 0.90.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/ChangeLog +60 -0
  2. data/README +34 -0
  3. data/Rakefile +76 -0
  4. data/ext/gio2/depend +5 -0
  5. data/ext/gio2/extconf.rb +91 -0
  6. data/ext/gio2/gappinfo.c +318 -0
  7. data/ext/gio2/gapplaunchcontext.c +79 -0
  8. data/ext/gio2/gasyncinitable.c +244 -0
  9. data/ext/gio2/gasyncresult.c +39 -0
  10. data/ext/gio2/gbufferedinputstream.c +184 -0
  11. data/ext/gio2/gbufferedoutputstream.c +82 -0
  12. data/ext/gio2/gcancellable.c +177 -0
  13. data/ext/gio2/gcharsetconverter.c +72 -0
  14. data/ext/gio2/gcontenttype.c +135 -0
  15. data/ext/gio2/gconverter.c +117 -0
  16. data/ext/gio2/gconverterinputstream.c +48 -0
  17. data/ext/gio2/gconverteroutputstream.c +48 -0
  18. data/ext/gio2/gdatainputstream.c +341 -0
  19. data/ext/gio2/gdataoutputstream.c +202 -0
  20. data/ext/gio2/gdesktopappinfo.c +90 -0
  21. data/ext/gio2/gdrive.c +267 -0
  22. data/ext/gio2/gemblem.c +71 -0
  23. data/ext/gio2/gemblemedicon.c +63 -0
  24. data/ext/gio2/gfile.c +2058 -0
  25. data/ext/gio2/gfileattribute.c +263 -0
  26. data/ext/gio2/gfileattributematcher.c +90 -0
  27. data/ext/gio2/gfiledescriptorbased.c +42 -0
  28. data/ext/gio2/gfileenumerator.c +167 -0
  29. data/ext/gio2/gfileicon.c +46 -0
  30. data/ext/gio2/gfileinfo.c +641 -0
  31. data/ext/gio2/gfileinputstream.c +92 -0
  32. data/ext/gio2/gfileiostream.c +98 -0
  33. data/ext/gio2/gfilemonitor.c +63 -0
  34. data/ext/gio2/gfilenamecompleter.c +72 -0
  35. data/ext/gio2/gfileoutputstream.c +100 -0
  36. data/ext/gio2/gfilterinputstream.c +56 -0
  37. data/ext/gio2/gfilteroutputstream.c +56 -0
  38. data/ext/gio2/gicon.c +69 -0
  39. data/ext/gio2/ginetaddress.c +188 -0
  40. data/ext/gio2/ginetsocketaddress.c +54 -0
  41. data/ext/gio2/ginitable.c +195 -0
  42. data/ext/gio2/ginputstream.c +341 -0
  43. data/ext/gio2/gio2.c +120 -0
  44. data/ext/gio2/gio2.def +2 -0
  45. data/ext/gio2/gio2.h +343 -0
  46. data/ext/gio2/gioerror.c +67 -0
  47. data/ext/gio2/giomodule.c +63 -0
  48. data/ext/gio2/gioscheduler.c +195 -0
  49. data/ext/gio2/giostream.c +129 -0
  50. data/ext/gio2/gloadableicon.c +91 -0
  51. data/ext/gio2/gmemoryinputstream.c +65 -0
  52. data/ext/gio2/gmemoryoutputstream.c +65 -0
  53. data/ext/gio2/gmount.c +283 -0
  54. data/ext/gio2/gmountoperation.c +168 -0
  55. data/ext/gio2/gnetworkaddress.c +71 -0
  56. data/ext/gio2/gnetworkservice.c +64 -0
  57. data/ext/gio2/goutputstream.c +343 -0
  58. data/ext/gio2/gresolver.c +230 -0
  59. data/ext/gio2/gseekable.c +89 -0
  60. data/ext/gio2/gsimpleasyncresult.c +153 -0
  61. data/ext/gio2/gsocket.c +451 -0
  62. data/ext/gio2/gsocketaddress.c +45 -0
  63. data/ext/gio2/gsocketclient.c +273 -0
  64. data/ext/gio2/gsocketconnectable.c +97 -0
  65. data/ext/gio2/gsocketconnection.c +82 -0
  66. data/ext/gio2/gsocketcontrolmessage.c +82 -0
  67. data/ext/gio2/gsocketlistener.c +239 -0
  68. data/ext/gio2/gsocketservice.c +64 -0
  69. data/ext/gio2/gsrvtarget.c +77 -0
  70. data/ext/gio2/gtcpconnection.c +48 -0
  71. data/ext/gio2/gthemedicon.c +86 -0
  72. data/ext/gio2/gthreadedsocketservice.c +39 -0
  73. data/ext/gio2/gunixconnection.c +69 -0
  74. data/ext/gio2/gunixfdlist.c +112 -0
  75. data/ext/gio2/gunixfdmessage.c +81 -0
  76. data/ext/gio2/gunixinputstream.c +73 -0
  77. data/ext/gio2/gunixmounts.c +346 -0
  78. data/ext/gio2/gunixoutputstream.c +73 -0
  79. data/ext/gio2/gunixsocketaddress.c +79 -0
  80. data/ext/gio2/gvfs.c +84 -0
  81. data/ext/gio2/gvolume.c +191 -0
  82. data/ext/gio2/gvolumemonitor.c +77 -0
  83. data/ext/gio2/gzlibcompressor.c +47 -0
  84. data/ext/gio2/gzlibdecompressor.c +43 -0
  85. data/ext/gio2/util.c +323 -0
  86. data/extconf.rb +49 -0
  87. data/lib/gio2.rb +141 -0
  88. metadata +184 -0
@@ -0,0 +1,341 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
4
+ * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #define _SELF(value) RVAL2GINPUTSTREAM(value)
24
+
25
+ static VALUE s_cReadAsyncResult;
26
+
27
+ static VALUE
28
+ inputstream_read(int argc, VALUE *argv, VALUE self)
29
+ {
30
+ VALUE rbcount, cancellable, result;
31
+ gsize count;
32
+ GError *error = NULL;
33
+ gssize bytes_read;
34
+
35
+ rb_scan_args(argc, argv, "11", &rbcount, &cancellable);
36
+ count = RVAL2GSIZE(rbcount);
37
+ result = rb_str_new(NULL, count);
38
+ bytes_read = g_input_stream_read(_SELF(self),
39
+ RSTRING_PTR(result),
40
+ count,
41
+ RVAL2GCANCELLABLE(cancellable),
42
+ &error);
43
+ if (bytes_read == -1)
44
+ rbgio_raise_error(error);
45
+
46
+ rb_str_set_len(result, bytes_read);
47
+ rb_str_resize(result, bytes_read);
48
+ OBJ_TAINT(result);
49
+
50
+ return result;
51
+ }
52
+
53
+ static VALUE
54
+ inputstream_read_all(int argc, VALUE *argv, VALUE self)
55
+ {
56
+ VALUE rbcount, cancellable, result;
57
+ gsize count;
58
+ GError *error = NULL;
59
+ gsize bytes_read;
60
+
61
+ rb_scan_args(argc, argv, "11", &rbcount, &cancellable);
62
+ count = RVAL2GSIZE(rbcount);
63
+ result = rb_str_new(NULL, count);
64
+ if (!g_input_stream_read_all(_SELF(self),
65
+ RSTRING_PTR(result),
66
+ count,
67
+ &bytes_read,
68
+ RVAL2GCANCELLABLE(cancellable),
69
+ &error))
70
+ rbgio_raise_error(error);
71
+
72
+ rb_str_set_len(result, bytes_read);
73
+ rb_str_resize(result, bytes_read);
74
+ OBJ_TAINT(result);
75
+
76
+ return result;
77
+ }
78
+
79
+ static VALUE
80
+ inputstream_skip(int argc, VALUE *argv, VALUE self)
81
+ {
82
+ VALUE count, cancellable;
83
+ GError *error = NULL;
84
+ gssize bytes_skipped;
85
+
86
+ rb_scan_args(argc, argv, "11", &count, &cancellable);
87
+ bytes_skipped = g_input_stream_skip(_SELF(self),
88
+ RVAL2GSIZE(count),
89
+ RVAL2GCANCELLABLE(cancellable),
90
+ &error);
91
+ if (bytes_skipped == -1)
92
+ rbgio_raise_error(error);
93
+
94
+ return GSSIZE2RVAL(bytes_skipped);
95
+ }
96
+
97
+ static VALUE
98
+ inputstream_close(int argc, VALUE *argv, VALUE self)
99
+ {
100
+ VALUE cancellable;
101
+ GError *error = NULL;
102
+
103
+ rb_scan_args(argc, argv, "01", &cancellable);
104
+ if (!g_input_stream_close(_SELF(self),
105
+ RVAL2GCANCELLABLE(cancellable),
106
+ &error))
107
+ rbgio_raise_error(error);
108
+
109
+ return self;
110
+ }
111
+
112
+ struct read_async_result
113
+ {
114
+ VALUE string;
115
+ GAsyncResult *result;
116
+ };
117
+
118
+ static void
119
+ read_async_result_mark(struct read_async_result *result)
120
+ {
121
+ rb_gc_mark(result->string);
122
+ }
123
+
124
+ struct read_async_callback_data
125
+ {
126
+ GAsyncResult *result;
127
+ gpointer user_data;
128
+ };
129
+
130
+ static VALUE
131
+ read_async_callback_call(VALUE data)
132
+ {
133
+ static ID s_id_call;
134
+ struct read_async_callback_data *real;
135
+ VALUE ary;
136
+ struct read_async_result *result;
137
+
138
+ if (s_id_call == 0)
139
+ s_id_call = rb_intern("call");
140
+
141
+ real = (struct read_async_callback_data *)data;
142
+
143
+ ary = (VALUE)real->user_data;
144
+ G_CHILD_REMOVE(mGLib, ary);
145
+ if (NIL_P(RARRAY_PTR(ary)[1]))
146
+ return Qnil;
147
+
148
+ result = g_new(struct read_async_result, 1);
149
+ result->string = RARRAY_PTR(ary)[0];
150
+ result->result = real->result;
151
+
152
+ rb_funcall(RARRAY_PTR(ary)[1], s_id_call, 1,
153
+ Data_Wrap_Struct(s_cReadAsyncResult,
154
+ read_async_result_mark,
155
+ g_free,
156
+ result));
157
+
158
+ return Qnil;
159
+ }
160
+
161
+ static void
162
+ read_async_callback(G_GNUC_UNUSED GObject *source,
163
+ GAsyncResult *result,
164
+ gpointer user_data)
165
+ {
166
+ struct read_async_callback_data real = { result, user_data };
167
+
168
+ G_PROTECT_CALLBACK(read_async_callback_call, &real);
169
+ }
170
+
171
+ static VALUE
172
+ inputstream_read_async(int argc, VALUE *argv, VALUE self)
173
+ {
174
+ VALUE rbcount, rbio_priority, rbcancellable, block, data;
175
+ gsize count;
176
+ int io_priority;
177
+ GCancellable *cancellable;
178
+
179
+ rb_scan_args(argc, argv, "12&", &rbcount, &rbio_priority, &rbcancellable, &block);
180
+ count = RVAL2GSIZE(rbcount);
181
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
182
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
183
+ data = rb_assoc_new(rb_str_new(NULL, count), block);
184
+ G_CHILD_ADD(mGLib, data);
185
+ g_input_stream_read_async(_SELF(self),
186
+ RSTRING_PTR(RARRAY_PTR(data)[0]),
187
+ count,
188
+ io_priority,
189
+ cancellable,
190
+ read_async_callback,
191
+ (gpointer)data);
192
+
193
+ return self;
194
+ }
195
+
196
+ static VALUE
197
+ inputstream_read_finish(VALUE self, VALUE rbresult)
198
+ {
199
+ struct read_async_result *result;
200
+ GError *error = NULL;
201
+ gssize bytes_read;
202
+
203
+ Data_Get_Struct(rbresult, struct read_async_result, result);
204
+ bytes_read = g_input_stream_read_finish(_SELF(self),
205
+ result->result,
206
+ &error);
207
+ if (bytes_read == -1)
208
+ rbgio_raise_error(error);
209
+
210
+ rb_str_set_len(result->string, bytes_read);
211
+ rb_str_resize(result->string, bytes_read);
212
+ OBJ_TAINT(result->string);
213
+
214
+ return result->string;
215
+ }
216
+
217
+ static VALUE
218
+ inputstream_skip_async(int argc, VALUE *argv, VALUE self)
219
+ {
220
+ VALUE rbcount, rbio_priority, rbcancellable, block;
221
+ gsize count;
222
+ int io_priority;
223
+ GCancellable *cancellable;
224
+
225
+ rb_scan_args(argc, argv, "12&", &rbcount, &rbio_priority, &rbcancellable, &block);
226
+ count = RVAL2GSIZE(rbcount);
227
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
228
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
229
+ SAVE_BLOCK(block);
230
+ g_input_stream_skip_async(_SELF(self),
231
+ count,
232
+ io_priority,
233
+ cancellable,
234
+ rbgio_async_ready_callback,
235
+ (gpointer)block);
236
+
237
+ return self;
238
+ }
239
+
240
+ static VALUE
241
+ inputstream_skip_finish(VALUE self, VALUE result)
242
+ {
243
+ GError *error = NULL;
244
+ gssize skipped_bytes;
245
+
246
+ skipped_bytes = g_input_stream_skip_finish(_SELF(self),
247
+ RVAL2GASYNCRESULT(result),
248
+ &error);
249
+ if (skipped_bytes == -1)
250
+ rbgio_raise_error(error);
251
+
252
+ return GSSIZE2RVAL(skipped_bytes);
253
+ }
254
+
255
+ static VALUE
256
+ inputstream_close_async(int argc, VALUE *argv, VALUE self)
257
+ {
258
+ VALUE rbio_priority, rbcancellable, block;
259
+ int io_priority;
260
+ GCancellable *cancellable;
261
+
262
+ rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
263
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
264
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
265
+ SAVE_BLOCK(block);
266
+ g_input_stream_close_async(_SELF(self),
267
+ io_priority,
268
+ cancellable,
269
+ rbgio_async_ready_callback,
270
+ (gpointer)block);
271
+
272
+ return self;
273
+ }
274
+
275
+ static VALUE
276
+ inputstream_close_finish(VALUE self, VALUE result)
277
+ {
278
+ GError *error = NULL;
279
+ if (!g_input_stream_skip_finish(_SELF(self),
280
+ RVAL2GASYNCRESULT(result),
281
+ &error))
282
+ rbgio_raise_error(error);
283
+
284
+ return self;
285
+ }
286
+
287
+ static VALUE
288
+ inputstream_is_closed(VALUE self)
289
+ {
290
+ return CBOOL2RVAL(g_input_stream_is_closed(_SELF(self)));
291
+ }
292
+
293
+ static VALUE
294
+ inputstream_has_pending(VALUE self)
295
+ {
296
+ return CBOOL2RVAL(g_input_stream_has_pending(_SELF(self)));
297
+ }
298
+
299
+ static VALUE
300
+ inputstream_set_pending(VALUE self)
301
+ {
302
+ GError *error = NULL;
303
+
304
+ if (!g_input_stream_set_pending(_SELF(self), &error))
305
+ rbgio_raise_error(error);
306
+
307
+ return self;
308
+ }
309
+
310
+ static VALUE
311
+ inputstream_clear_pending(VALUE self)
312
+ {
313
+ g_input_stream_clear_pending(_SELF(self));
314
+
315
+ return self;
316
+ }
317
+
318
+ void
319
+ Init_ginputstream(VALUE glib)
320
+ {
321
+ VALUE inputstream = G_DEF_CLASS(G_TYPE_INPUT_STREAM, "InputStream", glib);
322
+
323
+ s_cReadAsyncResult = rb_define_class_under(inputstream, "ReadAsyncResult", rb_cObject);
324
+
325
+ rb_undef_alloc_func(inputstream);
326
+
327
+ rb_define_method(inputstream, "read", inputstream_read, -1);
328
+ rb_define_method(inputstream, "read_all", inputstream_read_all, -1);
329
+ rb_define_method(inputstream, "skip", inputstream_skip, -1);
330
+ rb_define_method(inputstream, "close", inputstream_close, -1);
331
+ rb_define_method(inputstream, "read_async", inputstream_read_async, -1);
332
+ rb_define_method(inputstream, "read_finish", inputstream_read_finish, 1);
333
+ rb_define_method(inputstream, "skip_async", inputstream_skip_async, -1);
334
+ rb_define_method(inputstream, "skip_finish", inputstream_skip_finish, 1);
335
+ rb_define_method(inputstream, "close_async", inputstream_close_async, -1);
336
+ rb_define_method(inputstream, "close_finish", inputstream_close_finish, 1);
337
+ rb_define_method(inputstream, "closed?", inputstream_is_closed, 0);
338
+ rb_define_method(inputstream, "has_pending?", inputstream_has_pending, 0);
339
+ rb_define_method(inputstream, "set_pending", inputstream_set_pending, 0);
340
+ rb_define_method(inputstream, "clear_pending", inputstream_clear_pending, 0);
341
+ }
@@ -0,0 +1,120 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
4
+ * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ void Init_gio2(void);
24
+
25
+ static VALUE
26
+ gio_has_unix(G_GNUC_UNUSED VALUE self)
27
+ {
28
+ #ifdef HAVE_GIO_UNIX
29
+ return Qtrue;
30
+ #else
31
+ return Qfalse;
32
+ #endif
33
+ }
34
+
35
+ void
36
+ Init_gio2(void)
37
+ {
38
+ VALUE glib = mGLib;
39
+
40
+ rb_define_module_function(glib, "gio_has_unix?", gio_has_unix, 0);
41
+
42
+ Init_util();
43
+
44
+ Init_gappinfo(glib);
45
+ Init_gapplaunchcontext(glib);
46
+ Init_gasyncinitable(glib);
47
+ Init_gasyncresult(glib);
48
+ Init_gbufferedinputstream(glib);
49
+ Init_gbufferedoutputstream(glib);
50
+ Init_gcancellable(glib);
51
+ Init_gcharsetconverter(glib);
52
+ Init_gcontenttype(glib);
53
+ Init_gconverter(glib);
54
+ Init_gconverterinputstream(glib);
55
+ Init_gconverteroutputstream(glib);
56
+ Init_gdatainputstream(glib);
57
+ Init_gdesktopappinfo(glib);
58
+ Init_gfileattributematcher(glib);
59
+ Init_gdataoutputstream(glib);
60
+ Init_gdrive(glib);
61
+ Init_gemblem(glib);
62
+ Init_gemblemedicon(glib);
63
+ Init_gfile(glib);
64
+ Init_gfileattribute(glib);
65
+ Init_gfiledescriptorbased(glib);
66
+ Init_gfileenumerator(glib);
67
+ Init_gfileicon(glib);
68
+ Init_gfileinfo(glib);
69
+ Init_gfileinputstream(glib);
70
+ Init_gfileiostream(glib);
71
+ Init_gfilemonitor(glib);
72
+ Init_gfilenamecompleter(glib);
73
+ Init_gfileoutputstream(glib);
74
+ Init_gfilterinputstream(glib);
75
+ Init_gfilteroutputstream(glib);
76
+ Init_gicon(glib);
77
+ Init_ginetaddress(glib);
78
+ Init_ginetsocketaddress(glib);
79
+ Init_ginitable(glib);
80
+ Init_ginputstream(glib);
81
+ Init_gioerror(glib);
82
+ Init_giomodule(glib);
83
+ Init_gioscheduler(glib);
84
+ Init_giostream(glib);
85
+ Init_gloadableicon(glib);
86
+ Init_gmemoryinputstream(glib);
87
+ Init_gmemoryoutputstream(glib);
88
+ Init_gmount(glib);
89
+ Init_gmountoperation(glib);
90
+ Init_gnetworkaddress(glib);
91
+ Init_gnetworkservice(glib);
92
+ Init_goutputstream(glib);
93
+ Init_gresolver(glib);
94
+ Init_gseekable(glib);
95
+ Init_gsimpleasyncresult(glib);
96
+ Init_gsocket(glib);
97
+ Init_gsocketaddress(glib);
98
+ Init_gsocketclient(glib);
99
+ Init_gsocketconnectable(glib);
100
+ Init_gsocketconnection(glib);
101
+ Init_gsocketcontrolmessage(glib);
102
+ Init_gsocketlistener(glib);
103
+ Init_gsocketservice(glib);
104
+ Init_gsrvtarget(glib);
105
+ Init_gtcpconnection(glib);
106
+ Init_gthemedicon(glib);
107
+ Init_gthreadedsocketservice(glib);
108
+ Init_gunixconnection(glib);
109
+ Init_gunixfdlist(glib);
110
+ Init_gunixfdmessage(glib);
111
+ Init_gunixinputstream(glib);
112
+ Init_gunixmounts(glib);
113
+ Init_gunixoutputstream(glib);
114
+ Init_gunixsocketaddress(glib);
115
+ Init_gvfs(glib);
116
+ Init_gvolume(glib);
117
+ Init_gvolumemonitor(glib);
118
+ Init_gzlibcompressor(glib);
119
+ Init_gzlibdecompressor(glib);
120
+ }