gio2 0.90.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +60 -0
- data/README +34 -0
- data/Rakefile +76 -0
- data/ext/gio2/depend +5 -0
- data/ext/gio2/extconf.rb +91 -0
- data/ext/gio2/gappinfo.c +318 -0
- data/ext/gio2/gapplaunchcontext.c +79 -0
- data/ext/gio2/gasyncinitable.c +244 -0
- data/ext/gio2/gasyncresult.c +39 -0
- data/ext/gio2/gbufferedinputstream.c +184 -0
- data/ext/gio2/gbufferedoutputstream.c +82 -0
- data/ext/gio2/gcancellable.c +177 -0
- data/ext/gio2/gcharsetconverter.c +72 -0
- data/ext/gio2/gcontenttype.c +135 -0
- data/ext/gio2/gconverter.c +117 -0
- data/ext/gio2/gconverterinputstream.c +48 -0
- data/ext/gio2/gconverteroutputstream.c +48 -0
- data/ext/gio2/gdatainputstream.c +341 -0
- data/ext/gio2/gdataoutputstream.c +202 -0
- data/ext/gio2/gdesktopappinfo.c +90 -0
- data/ext/gio2/gdrive.c +267 -0
- data/ext/gio2/gemblem.c +71 -0
- data/ext/gio2/gemblemedicon.c +63 -0
- data/ext/gio2/gfile.c +2058 -0
- data/ext/gio2/gfileattribute.c +263 -0
- data/ext/gio2/gfileattributematcher.c +90 -0
- data/ext/gio2/gfiledescriptorbased.c +42 -0
- data/ext/gio2/gfileenumerator.c +167 -0
- data/ext/gio2/gfileicon.c +46 -0
- data/ext/gio2/gfileinfo.c +641 -0
- data/ext/gio2/gfileinputstream.c +92 -0
- data/ext/gio2/gfileiostream.c +98 -0
- data/ext/gio2/gfilemonitor.c +63 -0
- data/ext/gio2/gfilenamecompleter.c +72 -0
- data/ext/gio2/gfileoutputstream.c +100 -0
- data/ext/gio2/gfilterinputstream.c +56 -0
- data/ext/gio2/gfilteroutputstream.c +56 -0
- data/ext/gio2/gicon.c +69 -0
- data/ext/gio2/ginetaddress.c +188 -0
- data/ext/gio2/ginetsocketaddress.c +54 -0
- data/ext/gio2/ginitable.c +195 -0
- data/ext/gio2/ginputstream.c +341 -0
- data/ext/gio2/gio2.c +120 -0
- data/ext/gio2/gio2.def +2 -0
- data/ext/gio2/gio2.h +343 -0
- data/ext/gio2/gioerror.c +67 -0
- data/ext/gio2/giomodule.c +63 -0
- data/ext/gio2/gioscheduler.c +195 -0
- data/ext/gio2/giostream.c +129 -0
- data/ext/gio2/gloadableicon.c +91 -0
- data/ext/gio2/gmemoryinputstream.c +65 -0
- data/ext/gio2/gmemoryoutputstream.c +65 -0
- data/ext/gio2/gmount.c +283 -0
- data/ext/gio2/gmountoperation.c +168 -0
- data/ext/gio2/gnetworkaddress.c +71 -0
- data/ext/gio2/gnetworkservice.c +64 -0
- data/ext/gio2/goutputstream.c +343 -0
- data/ext/gio2/gresolver.c +230 -0
- data/ext/gio2/gseekable.c +89 -0
- data/ext/gio2/gsimpleasyncresult.c +153 -0
- data/ext/gio2/gsocket.c +451 -0
- data/ext/gio2/gsocketaddress.c +45 -0
- data/ext/gio2/gsocketclient.c +273 -0
- data/ext/gio2/gsocketconnectable.c +97 -0
- data/ext/gio2/gsocketconnection.c +82 -0
- data/ext/gio2/gsocketcontrolmessage.c +82 -0
- data/ext/gio2/gsocketlistener.c +239 -0
- data/ext/gio2/gsocketservice.c +64 -0
- data/ext/gio2/gsrvtarget.c +77 -0
- data/ext/gio2/gtcpconnection.c +48 -0
- data/ext/gio2/gthemedicon.c +86 -0
- data/ext/gio2/gthreadedsocketservice.c +39 -0
- data/ext/gio2/gunixconnection.c +69 -0
- data/ext/gio2/gunixfdlist.c +112 -0
- data/ext/gio2/gunixfdmessage.c +81 -0
- data/ext/gio2/gunixinputstream.c +73 -0
- data/ext/gio2/gunixmounts.c +346 -0
- data/ext/gio2/gunixoutputstream.c +73 -0
- data/ext/gio2/gunixsocketaddress.c +79 -0
- data/ext/gio2/gvfs.c +84 -0
- data/ext/gio2/gvolume.c +191 -0
- data/ext/gio2/gvolumemonitor.c +77 -0
- data/ext/gio2/gzlibcompressor.c +47 -0
- data/ext/gio2/gzlibdecompressor.c +43 -0
- data/ext/gio2/util.c +323 -0
- data/extconf.rb +49 -0
- data/lib/gio2.rb +141 -0
- metadata +184 -0
|
@@ -0,0 +1,71 @@
|
|
|
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) G_NETWORK_ADDRESS(RVAL2GOBJ(value))
|
|
24
|
+
|
|
25
|
+
static VALUE
|
|
26
|
+
networkaddress_initialize(VALUE self, VALUE hostname, VALUE port)
|
|
27
|
+
{
|
|
28
|
+
G_INITIALIZE(self, g_network_address_new(RVAL2CSTR(hostname),
|
|
29
|
+
RVAL2GUINT16(port)));
|
|
30
|
+
|
|
31
|
+
return Qnil;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static VALUE
|
|
35
|
+
networkaddress_get_hostname(VALUE self)
|
|
36
|
+
{
|
|
37
|
+
return CSTR2RVAL(g_network_address_get_hostname(_SELF(self)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static VALUE
|
|
41
|
+
networkaddress_get_port(VALUE self)
|
|
42
|
+
{
|
|
43
|
+
return GUINT162RVAL(g_network_address_get_port(_SELF(self)));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static VALUE
|
|
47
|
+
networkaddress_parse(G_GNUC_UNUSED VALUE self, VALUE host_and_port, VALUE default_port)
|
|
48
|
+
{
|
|
49
|
+
GError *error = NULL;
|
|
50
|
+
GSocketConnectable *connectable;
|
|
51
|
+
|
|
52
|
+
connectable = g_network_address_parse(RVAL2CSTR(host_and_port),
|
|
53
|
+
RVAL2GUINT16(default_port),
|
|
54
|
+
&error);
|
|
55
|
+
if (connectable == NULL)
|
|
56
|
+
rbgio_raise_error(error);
|
|
57
|
+
|
|
58
|
+
return GOBJ2RVAL_UNREF(connectable);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void
|
|
62
|
+
Init_gnetworkaddress(VALUE glib)
|
|
63
|
+
{
|
|
64
|
+
VALUE networkaddress = G_DEF_CLASS(G_TYPE_NETWORK_ADDRESS, "NetworkAddress", glib);
|
|
65
|
+
|
|
66
|
+
rb_define_singleton_method(networkaddress, "parse", networkaddress_parse, 2);
|
|
67
|
+
|
|
68
|
+
rb_define_method(networkaddress, "initialize", networkaddress_initialize, 2);
|
|
69
|
+
rb_define_method(networkaddress, "hostname", networkaddress_get_hostname, 0);
|
|
70
|
+
rb_define_method(networkaddress, "port", networkaddress_get_port, 0);
|
|
71
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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) G_NETWORK_SERVICE(RVAL2GOBJ(value))
|
|
24
|
+
|
|
25
|
+
static VALUE
|
|
26
|
+
networkservice_initialize(VALUE self, VALUE service, VALUE protocol, VALUE domain)
|
|
27
|
+
{
|
|
28
|
+
/* TODO: If these are infected, so should they be when returned. How
|
|
29
|
+
* do we deal with that? */
|
|
30
|
+
G_INITIALIZE(self, g_network_service_new(RVAL2CSTR(service),
|
|
31
|
+
RVAL2CSTR(protocol),
|
|
32
|
+
RVAL2CSTR(domain)));
|
|
33
|
+
|
|
34
|
+
return Qnil;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static VALUE
|
|
38
|
+
networkservice_get_service(VALUE self)
|
|
39
|
+
{
|
|
40
|
+
return CSTR2RVAL(g_network_service_get_service(_SELF(self)));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static VALUE
|
|
44
|
+
networkservice_get_protocol(VALUE self)
|
|
45
|
+
{
|
|
46
|
+
return CSTR2RVAL(g_network_service_get_protocol(_SELF(self)));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE
|
|
50
|
+
networkservice_get_domain(VALUE self)
|
|
51
|
+
{
|
|
52
|
+
return CSTR2RVAL(g_network_service_get_domain(_SELF(self)));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void
|
|
56
|
+
Init_gnetworkservice(VALUE glib)
|
|
57
|
+
{
|
|
58
|
+
VALUE networkservice = G_DEF_CLASS(G_TYPE_NETWORK_SERVICE, "NetworkService", glib);
|
|
59
|
+
|
|
60
|
+
rb_define_method(networkservice, "initialize", networkservice_initialize, 3);
|
|
61
|
+
rb_define_method(networkservice, "service", networkservice_get_service, 0);
|
|
62
|
+
rb_define_method(networkservice, "protocol", networkservice_get_protocol, 0);
|
|
63
|
+
rb_define_method(networkservice, "domain", networkservice_get_domain, 0);
|
|
64
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
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) RVAL2GOUTPUTSTREAM(value)
|
|
24
|
+
|
|
25
|
+
#define RVAL2GOUTPUTSTREAMSPLICEFLAGS(value) \
|
|
26
|
+
RVAL2GFLAGS((value), G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS)
|
|
27
|
+
|
|
28
|
+
#define RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(value) \
|
|
29
|
+
RVAL2TYPE_WITH_DEFAULT((value), \
|
|
30
|
+
RVAL2GOUTPUTSTREAMSPLICEFLAGS, \
|
|
31
|
+
G_OUTPUT_STREAM_SPLICE_NONE)
|
|
32
|
+
|
|
33
|
+
static VALUE
|
|
34
|
+
outputstream_write(int argc, VALUE *argv, VALUE self)
|
|
35
|
+
{
|
|
36
|
+
VALUE rbbuffer, rbcancellable;
|
|
37
|
+
const char *buffer;
|
|
38
|
+
gsize count;
|
|
39
|
+
GCancellable *cancellable;
|
|
40
|
+
GError *error = NULL;
|
|
41
|
+
gssize bytes_written;
|
|
42
|
+
|
|
43
|
+
rb_scan_args(argc, argv, "11", &rbbuffer, &rbcancellable);
|
|
44
|
+
buffer = RVAL2CSTR(rbbuffer);
|
|
45
|
+
count = RSTRING_LEN(rbbuffer);
|
|
46
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
|
47
|
+
bytes_written = g_output_stream_write(_SELF(self),
|
|
48
|
+
buffer,
|
|
49
|
+
count,
|
|
50
|
+
cancellable,
|
|
51
|
+
&error);
|
|
52
|
+
if (bytes_written == -1)
|
|
53
|
+
rbgio_raise_error(error);
|
|
54
|
+
|
|
55
|
+
return GSSIZE2RVAL(bytes_written);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static VALUE
|
|
59
|
+
outputstream_write_all(int argc, VALUE *argv, VALUE self)
|
|
60
|
+
{
|
|
61
|
+
VALUE rbbuffer, rbcancellable;
|
|
62
|
+
const char *buffer;
|
|
63
|
+
gsize count;
|
|
64
|
+
gsize bytes_written;
|
|
65
|
+
GCancellable *cancellable;
|
|
66
|
+
GError *error = NULL;
|
|
67
|
+
|
|
68
|
+
rb_scan_args(argc, argv, "11", &rbbuffer, &rbcancellable);
|
|
69
|
+
buffer = RVAL2CSTR(rbbuffer);
|
|
70
|
+
count = RSTRING_LEN(rbbuffer);
|
|
71
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
|
72
|
+
if (!g_output_stream_write_all(_SELF(self),
|
|
73
|
+
buffer,
|
|
74
|
+
count,
|
|
75
|
+
&bytes_written,
|
|
76
|
+
cancellable,
|
|
77
|
+
&error))
|
|
78
|
+
rbgio_raise_error(error);
|
|
79
|
+
|
|
80
|
+
return GSIZE2RVAL(bytes_written);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static VALUE
|
|
84
|
+
outputstream_splice(int argc, VALUE *argv, VALUE self)
|
|
85
|
+
{
|
|
86
|
+
VALUE source, flags, cancellable;
|
|
87
|
+
GError *error = NULL;
|
|
88
|
+
gssize bytes_spliced;
|
|
89
|
+
|
|
90
|
+
rb_scan_args(argc, argv, "12", &source, &flags, &cancellable);
|
|
91
|
+
bytes_spliced = g_output_stream_splice(_SELF(self),
|
|
92
|
+
RVAL2GINPUTSTREAM(source),
|
|
93
|
+
RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(flags),
|
|
94
|
+
RVAL2GCANCELLABLE(cancellable),
|
|
95
|
+
&error);
|
|
96
|
+
if (bytes_spliced == -1)
|
|
97
|
+
rbgio_raise_error(error);
|
|
98
|
+
|
|
99
|
+
return GSSIZE2RVAL(bytes_spliced);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
typedef gboolean (*CancellableMethod)(GOutputStream *, GCancellable *, GError **);
|
|
103
|
+
|
|
104
|
+
static VALUE
|
|
105
|
+
cancellable_method(CancellableMethod method, int argc, VALUE *argv, VALUE self)
|
|
106
|
+
{
|
|
107
|
+
VALUE cancellable;
|
|
108
|
+
GError *error = NULL;
|
|
109
|
+
|
|
110
|
+
rb_scan_args(argc, argv, "01", &cancellable);
|
|
111
|
+
if (!method(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error))
|
|
112
|
+
rbgio_raise_error(error);
|
|
113
|
+
|
|
114
|
+
return self;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static VALUE
|
|
118
|
+
outputstream_flush(int argc, VALUE *argv, VALUE self)
|
|
119
|
+
{
|
|
120
|
+
return cancellable_method(g_output_stream_flush, argc, argv, self);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static VALUE
|
|
124
|
+
outputstream_close(int argc, VALUE *argv, VALUE self)
|
|
125
|
+
{
|
|
126
|
+
return cancellable_method(g_output_stream_close, argc, argv, self);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* TODO: Does it make sense to use buffer and count? We should probably
|
|
130
|
+
* provide a better wrapper that simply pumps out buffer while count hasn’t
|
|
131
|
+
* been reached, calling the callback with the bytes written, then with the
|
|
132
|
+
* result. */
|
|
133
|
+
static VALUE
|
|
134
|
+
outputstream_write_async(int argc, VALUE *argv, VALUE self)
|
|
135
|
+
{
|
|
136
|
+
VALUE rbbuffer, rbcount, rbio_priority, rbcancellable, block;
|
|
137
|
+
const gchar *buffer;
|
|
138
|
+
gsize count;
|
|
139
|
+
int io_priority;
|
|
140
|
+
GCancellable *cancellable;
|
|
141
|
+
|
|
142
|
+
rb_scan_args(argc, argv, "22&", &rbbuffer, &rbcount, &rbio_priority, &rbcancellable, &block);
|
|
143
|
+
buffer = RVAL2CSTR(rbbuffer);
|
|
144
|
+
count = RVAL2GSIZE(rbcount);
|
|
145
|
+
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
|
146
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
|
147
|
+
SAVE_BLOCK(block);
|
|
148
|
+
g_output_stream_write_async(_SELF(self),
|
|
149
|
+
buffer,
|
|
150
|
+
count,
|
|
151
|
+
io_priority,
|
|
152
|
+
cancellable,
|
|
153
|
+
rbgio_async_ready_callback,
|
|
154
|
+
(gpointer)block);
|
|
155
|
+
|
|
156
|
+
return self;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
typedef gssize (*SSizeFinishMethod)(GOutputStream *, GAsyncResult *, GError **);
|
|
160
|
+
|
|
161
|
+
static VALUE
|
|
162
|
+
ssize_finish_method(SSizeFinishMethod method, VALUE self, VALUE result)
|
|
163
|
+
{
|
|
164
|
+
GError *error = NULL;
|
|
165
|
+
gssize bytes_read;
|
|
166
|
+
|
|
167
|
+
bytes_read = method(_SELF(self), RVAL2GASYNCRESULT(result), &error);
|
|
168
|
+
if (error != NULL)
|
|
169
|
+
rbgio_raise_error(error);
|
|
170
|
+
|
|
171
|
+
return GSSIZE2RVAL(bytes_read);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static VALUE
|
|
175
|
+
outputstream_write_finish(VALUE self, VALUE result)
|
|
176
|
+
{
|
|
177
|
+
return ssize_finish_method(g_output_stream_write_finish, self, result);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
static VALUE
|
|
181
|
+
outputstream_splice_async(int argc, VALUE *argv, VALUE self)
|
|
182
|
+
{
|
|
183
|
+
VALUE rbsource, rbflags, rbio_priority, rbcancellable, block;
|
|
184
|
+
GInputStream *source;
|
|
185
|
+
GOutputStreamSpliceFlags flags;
|
|
186
|
+
int io_priority;
|
|
187
|
+
GCancellable *cancellable;
|
|
188
|
+
|
|
189
|
+
rb_scan_args(argc, argv, "12&", &rbsource, &rbflags, &rbio_priority, &rbcancellable, &block);
|
|
190
|
+
source = RVAL2GINPUTSTREAM(rbsource);
|
|
191
|
+
flags = RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(rbflags);
|
|
192
|
+
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
|
193
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
|
194
|
+
SAVE_BLOCK(block);
|
|
195
|
+
g_output_stream_splice_async(_SELF(self),
|
|
196
|
+
source,
|
|
197
|
+
flags,
|
|
198
|
+
io_priority,
|
|
199
|
+
cancellable,
|
|
200
|
+
rbgio_async_ready_callback,
|
|
201
|
+
(gpointer)block);
|
|
202
|
+
|
|
203
|
+
return self;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static VALUE
|
|
207
|
+
outputstream_splice_finish(VALUE self, VALUE result)
|
|
208
|
+
{
|
|
209
|
+
return ssize_finish_method(g_output_stream_splice_finish, self, result);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
static VALUE
|
|
213
|
+
outputstream_flush_async(int argc, VALUE *argv, VALUE self)
|
|
214
|
+
{
|
|
215
|
+
VALUE rbio_priority, rbcancellable, block;
|
|
216
|
+
int io_priority;
|
|
217
|
+
GCancellable *cancellable;
|
|
218
|
+
|
|
219
|
+
rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
|
|
220
|
+
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
|
221
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
|
222
|
+
SAVE_BLOCK(block);
|
|
223
|
+
g_output_stream_flush_async(_SELF(self),
|
|
224
|
+
io_priority,
|
|
225
|
+
cancellable,
|
|
226
|
+
rbgio_async_ready_callback,
|
|
227
|
+
(gpointer)block);
|
|
228
|
+
|
|
229
|
+
return self;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
typedef gboolean (*BooleanFinishMethod)(GOutputStream *, GAsyncResult *, GError **);
|
|
233
|
+
|
|
234
|
+
static VALUE
|
|
235
|
+
boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result)
|
|
236
|
+
{
|
|
237
|
+
GError *error = NULL;
|
|
238
|
+
|
|
239
|
+
if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error))
|
|
240
|
+
rbgio_raise_error(error);
|
|
241
|
+
|
|
242
|
+
return self;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
static VALUE
|
|
246
|
+
outputstream_flush_finish(VALUE self, VALUE result)
|
|
247
|
+
{
|
|
248
|
+
return boolean_finish_method(g_output_stream_flush_finish, self, result);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
static VALUE
|
|
252
|
+
outputstream_close_async(int argc, VALUE *argv, VALUE self)
|
|
253
|
+
{
|
|
254
|
+
VALUE rbio_priority, rbcancellable, block;
|
|
255
|
+
int io_priority;
|
|
256
|
+
GCancellable *cancellable;
|
|
257
|
+
|
|
258
|
+
rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
|
|
259
|
+
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
|
260
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
|
261
|
+
SAVE_BLOCK(block);
|
|
262
|
+
g_output_stream_close_async(_SELF(self),
|
|
263
|
+
io_priority,
|
|
264
|
+
cancellable,
|
|
265
|
+
rbgio_async_ready_callback,
|
|
266
|
+
(gpointer)block);
|
|
267
|
+
|
|
268
|
+
return self;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
static VALUE
|
|
272
|
+
outputstream_close_finish(VALUE self, VALUE result)
|
|
273
|
+
{
|
|
274
|
+
return boolean_finish_method(g_output_stream_close_finish, self, result);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
static VALUE
|
|
278
|
+
outputstream_is_closing(VALUE self)
|
|
279
|
+
{
|
|
280
|
+
return CBOOL2RVAL(g_output_stream_is_closing(_SELF(self)));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
static VALUE
|
|
284
|
+
outputstream_is_closed(VALUE self)
|
|
285
|
+
{
|
|
286
|
+
return CBOOL2RVAL(g_output_stream_is_closed(_SELF(self)));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
static VALUE
|
|
290
|
+
outputstream_has_pending(VALUE self)
|
|
291
|
+
{
|
|
292
|
+
return CBOOL2RVAL(g_output_stream_has_pending(_SELF(self)));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
static VALUE
|
|
296
|
+
outputstream_set_pending(VALUE self)
|
|
297
|
+
{
|
|
298
|
+
GError *error = NULL;
|
|
299
|
+
|
|
300
|
+
if (!g_output_stream_set_pending(_SELF(self), &error))
|
|
301
|
+
rbgio_raise_error(error);
|
|
302
|
+
|
|
303
|
+
return self;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
static VALUE
|
|
307
|
+
outputstream_clear_pending(VALUE self)
|
|
308
|
+
{
|
|
309
|
+
g_output_stream_clear_pending(_SELF(self));
|
|
310
|
+
|
|
311
|
+
return self;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
void
|
|
315
|
+
Init_goutputstream(VALUE glib)
|
|
316
|
+
{
|
|
317
|
+
VALUE outputstream = G_DEF_CLASS(G_TYPE_OUTPUT_STREAM, "OutputStream", glib);
|
|
318
|
+
|
|
319
|
+
G_DEF_CLASS(G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS, "SpliceFlags", outputstream);
|
|
320
|
+
G_DEF_CONSTANTS(outputstream, G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS, "G_OUTPUT_STREAM_");
|
|
321
|
+
|
|
322
|
+
rb_undef_alloc_func(outputstream);
|
|
323
|
+
|
|
324
|
+
rb_define_method(outputstream, "write", outputstream_write, -1);
|
|
325
|
+
rb_define_method(outputstream, "write_all", outputstream_write_all, -1);
|
|
326
|
+
rb_define_method(outputstream, "splice", outputstream_splice, -1);
|
|
327
|
+
rb_define_method(outputstream, "flush", outputstream_flush, -1);
|
|
328
|
+
rb_define_method(outputstream, "close", outputstream_close, -1);
|
|
329
|
+
rb_define_method(outputstream, "write_async", outputstream_write_async, -1);
|
|
330
|
+
rb_define_method(outputstream, "write_finish", outputstream_write_finish, 1);
|
|
331
|
+
rb_define_method(outputstream, "splice_async", outputstream_splice_async, -1);
|
|
332
|
+
rb_define_method(outputstream, "splice_finish", outputstream_splice_finish, 1);
|
|
333
|
+
rb_define_method(outputstream, "flush_async", outputstream_flush_async, -1);
|
|
334
|
+
rb_define_method(outputstream, "flush_finish", outputstream_flush_finish, 1);
|
|
335
|
+
rb_define_method(outputstream, "close_async", outputstream_close_async, -1);
|
|
336
|
+
rb_define_method(outputstream, "close_finish", outputstream_close_finish, 0);
|
|
337
|
+
rb_define_method(outputstream, "closing?", outputstream_is_closing, 0);
|
|
338
|
+
rb_define_method(outputstream, "closed?", outputstream_is_closed, 0);
|
|
339
|
+
rb_define_method(outputstream, "has_pending?", outputstream_has_pending, 0);
|
|
340
|
+
rb_define_method(outputstream, "set_pending", outputstream_set_pending, 0);
|
|
341
|
+
G_DEF_SETTER(outputstream, "pending");
|
|
342
|
+
rb_define_method(outputstream, "clear_pending", outputstream_clear_pending, 0);
|
|
343
|
+
}
|