gio2 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +26 -9
- data/ext/gio2/extconf.rb +38 -28
- data/ext/gio2/rb-gio2-pollable-source.c +59 -0
- data/ext/gio2/{rbgiofilteroutputstream.c → rb-gio2.c} +9 -5
- data/ext/gio2/{gio2.c → rb-gio2.h} +5 -10
- data/extconf.rb +22 -6
- data/lib/gio2.rb +38 -143
- data/lib/gio2/deprecated.rb +16 -0
- data/lib/gio2/inet-address.rb +33 -0
- data/lib/gio2/input-stream.rb +39 -0
- data/lib/gio2/loader.rb +244 -0
- data/lib/gio2/output-stream.rb +24 -0
- data/lib/gio2/pollable-input-stream.rb +51 -0
- data/lib/gio2/pollable-output-stream.rb +32 -0
- data/lib/gio2/resources.rb +62 -0
- data/test/fixture/content-type/x-content/unix-software/autorun.sh +1 -0
- data/test/fixture/resource/Rakefile +32 -0
- data/test/fixture/resource/logo.png +0 -0
- data/test/fixture/resource/ruby-gio2.gresource +0 -0
- data/test/fixture/resource/ruby-gio2.gresource.xml +6 -0
- data/test/gio2-test-utils.rb +21 -0
- data/test/gio2-test-utils/fixture.rb +24 -0
- data/test/gio2-test-utils/socket-client.rb +59 -0
- data/test/run-test.rb +45 -9
- data/test/test-buffered-input-stream.rb +23 -0
- data/test/test-charset-converter.rb +23 -0
- data/test/test-content-type.rb +31 -0
- data/test/test-data-input-stream.rb +21 -0
- data/test/test-file-enumerator.rb +26 -0
- data/test/test-file-monitor.rb +33 -0
- data/test/test-file.rb +28 -0
- data/test/test-inet-address.rb +34 -0
- data/test/test-input-stream.rb +36 -0
- data/test/test-output-stream.rb +39 -0
- data/test/test-pollable-input-stream.rb +54 -0
- data/test/test-pollable-output-stream.rb +53 -0
- data/test/test-resources.rb +58 -0
- metadata +49 -107
- data/README +0 -34
- data/ext/gio2/depend +0 -11
- data/ext/gio2/gio2.def +0 -2
- data/ext/gio2/gio2.h +0 -30
- data/ext/gio2/rbgio.c +0 -133
- data/ext/gio2/rbgio2.h +0 -158
- data/ext/gio2/rbgio2conversions.h +0 -154
- data/ext/gio2/rbgio2private.h +0 -148
- data/ext/gio2/rbgioappinfo.c +0 -317
- data/ext/gio2/rbgioapplaunchcontext.c +0 -81
- data/ext/gio2/rbgioasyncinitable.c +0 -246
- data/ext/gio2/rbgioasyncresult.c +0 -41
- data/ext/gio2/rbgiobufferedinputstream.c +0 -167
- data/ext/gio2/rbgiobufferedoutputstream.c +0 -50
- data/ext/gio2/rbgiocancellable.c +0 -180
- data/ext/gio2/rbgiocharsetconverter.c +0 -57
- data/ext/gio2/rbgiocontenttype.c +0 -131
- data/ext/gio2/rbgioconverter.c +0 -113
- data/ext/gio2/rbgioconverterinputstream.c +0 -43
- data/ext/gio2/rbgioconverteroutputstream.c +0 -43
- data/ext/gio2/rbgiodatainputstream.c +0 -309
- data/ext/gio2/rbgiodataoutputstream.c +0 -186
- data/ext/gio2/rbgiodesktopappinfo.c +0 -87
- data/ext/gio2/rbgiodrive.c +0 -266
- data/ext/gio2/rbgioemblem.c +0 -52
- data/ext/gio2/rbgioemblemedicon.c +0 -65
- data/ext/gio2/rbgiofile.c +0 -2045
- data/ext/gio2/rbgiofileattribute.c +0 -114
- data/ext/gio2/rbgiofileattributeinfo.c +0 -86
- data/ext/gio2/rbgiofileattributeinfolist.c +0 -108
- data/ext/gio2/rbgiofileattributematcher.c +0 -95
- data/ext/gio2/rbgiofiledescriptorbased.c +0 -45
- data/ext/gio2/rbgiofileenumerator.c +0 -166
- data/ext/gio2/rbgiofileicon.c +0 -41
- data/ext/gio2/rbgiofileinfo.c +0 -617
- data/ext/gio2/rbgiofileinputstream.c +0 -91
- data/ext/gio2/rbgiofileiostream.c +0 -98
- data/ext/gio2/rbgiofilemonitor.c +0 -46
- data/ext/gio2/rbgiofilenamecompleter.c +0 -73
- data/ext/gio2/rbgiofileoutputstream.c +0 -98
- data/ext/gio2/rbgiofilterinputstream.c +0 -28
- data/ext/gio2/rbgioicon.c +0 -69
- data/ext/gio2/rbgioinetaddress.c +0 -118
- data/ext/gio2/rbgioinetsocketaddress.c +0 -41
- data/ext/gio2/rbgioinitable.c +0 -199
- data/ext/gio2/rbgioinputstream.c +0 -341
- data/ext/gio2/rbgioio.c +0 -73
- data/ext/gio2/rbgioiomodule.c +0 -45
- data/ext/gio2/rbgioiomodules.c +0 -47
- data/ext/gio2/rbgioioscheduler.c +0 -102
- data/ext/gio2/rbgioioschedulerjob.c +0 -121
- data/ext/gio2/rbgioiostream.c +0 -107
- data/ext/gio2/rbgioloadableicon.c +0 -92
- data/ext/gio2/rbgiomemoryinputstream.c +0 -67
- data/ext/gio2/rbgiomemoryoutputstream.c +0 -44
- data/ext/gio2/rbgiomount.c +0 -286
- data/ext/gio2/rbgiomountoperation.c +0 -53
- data/ext/gio2/rbgionetworkaddress.c +0 -59
- data/ext/gio2/rbgionetworkservice.c +0 -45
- data/ext/gio2/rbgiooutputstream.c +0 -331
- data/ext/gio2/rbgioresolver.c +0 -230
- data/ext/gio2/rbgioseekable.c +0 -91
- data/ext/gio2/rbgiosimpleasyncresult.c +0 -152
- data/ext/gio2/rbgiosocket.c +0 -390
- data/ext/gio2/rbgiosocketaddress.c +0 -34
- data/ext/gio2/rbgiosocketaddressenumerator.c +0 -83
- data/ext/gio2/rbgiosocketclient.c +0 -207
- data/ext/gio2/rbgiosocketconnectable.c +0 -41
- data/ext/gio2/rbgiosocketconnection.c +0 -66
- data/ext/gio2/rbgiosocketconnectionfactory.c +0 -39
- data/ext/gio2/rbgiosocketcontrolmessage.c +0 -82
- data/ext/gio2/rbgiosocketlistener.c +0 -246
- data/ext/gio2/rbgiosocketservice.c +0 -66
- data/ext/gio2/rbgiosrvtarget.c +0 -76
- data/ext/gio2/rbgiotcpconnection.c +0 -28
- data/ext/gio2/rbgiothemedicon.c +0 -83
- data/ext/gio2/rbgiothreadedsocketservice.c +0 -43
- data/ext/gio2/rbgiotlscertificate.c +0 -89
- data/ext/gio2/rbgiounixconnection.c +0 -71
- data/ext/gio2/rbgiounixfdlist.c +0 -115
- data/ext/gio2/rbgiounixfdmessage.c +0 -74
- data/ext/gio2/rbgiounixinputstream.c +0 -51
- data/ext/gio2/rbgiounixmount.c +0 -164
- data/ext/gio2/rbgiounixmountmonitor.c +0 -65
- data/ext/gio2/rbgiounixmountpoint.c +0 -136
- data/ext/gio2/rbgiounixmountpoints.c +0 -58
- data/ext/gio2/rbgiounixmounts.c +0 -58
- data/ext/gio2/rbgiounixoutputstream.c +0 -51
- data/ext/gio2/rbgiounixsocketaddress.c +0 -69
- data/ext/gio2/rbgiovfs.c +0 -84
- data/ext/gio2/rbgiovolume.c +0 -193
- data/ext/gio2/rbgiovolumemonitor.c +0 -77
- data/ext/gio2/rbgiozlibcompressor.c +0 -52
- data/ext/gio2/rbgiozlibdecompressor.c +0 -45
- data/ext/gio2/util.c +0 -303
- data/test/test_bufferedinputstream.rb +0 -9
- data/test/test_charsetconverter.rb +0 -9
- data/test/test_datainputstream.rb +0 -7
- data/test/test_fileenumerator.rb +0 -8
- data/test/test_filemonitor.rb +0 -17
- data/test/test_inetaddress.rb +0 -8
data/ext/gio2/rbgiovolume.c
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
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, or (at your option) any later version.
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
-
* MA 02110-1301 USA
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE mVolume
|
25
|
-
#define _SELF(value) RVAL2GVOLUME(value)
|
26
|
-
|
27
|
-
static VALUE
|
28
|
-
rg_name(VALUE self)
|
29
|
-
{
|
30
|
-
return CSTR2RVAL_FREE(g_volume_get_name(_SELF(self)));
|
31
|
-
}
|
32
|
-
|
33
|
-
static VALUE
|
34
|
-
rg_uuid(VALUE self)
|
35
|
-
{
|
36
|
-
return CSTR2RVAL_FREE(g_volume_get_uuid(_SELF(self)));
|
37
|
-
}
|
38
|
-
|
39
|
-
static VALUE
|
40
|
-
rg_icon(VALUE self)
|
41
|
-
{
|
42
|
-
return GOBJ2RVAL_UNREF(g_volume_get_icon(_SELF(self)));
|
43
|
-
}
|
44
|
-
|
45
|
-
static VALUE
|
46
|
-
rg_drive(VALUE self)
|
47
|
-
{
|
48
|
-
return GOBJ2RVAL_UNREF(g_volume_get_drive(_SELF(self)));
|
49
|
-
}
|
50
|
-
|
51
|
-
static VALUE
|
52
|
-
rg_get_mount(VALUE self)
|
53
|
-
{
|
54
|
-
return GOBJ2RVAL_UNREF(g_volume_get_mount(_SELF(self)));
|
55
|
-
}
|
56
|
-
|
57
|
-
static VALUE
|
58
|
-
rg_can_mount_p(VALUE self)
|
59
|
-
{
|
60
|
-
return CBOOL2RVAL(g_volume_can_mount(_SELF(self)));
|
61
|
-
}
|
62
|
-
|
63
|
-
static VALUE
|
64
|
-
rg_should_automount_p(VALUE self)
|
65
|
-
{
|
66
|
-
return CBOOL2RVAL(g_volume_should_automount(_SELF(self)));
|
67
|
-
}
|
68
|
-
|
69
|
-
static VALUE
|
70
|
-
rg_activation_root(VALUE self)
|
71
|
-
{
|
72
|
-
return GOBJ2RVAL_UNREF(g_volume_get_activation_root(_SELF(self)));
|
73
|
-
}
|
74
|
-
|
75
|
-
static VALUE
|
76
|
-
rg_mount(int argc, VALUE *argv, VALUE self)
|
77
|
-
{
|
78
|
-
VALUE rbflags, rbmount_operation, rbcancellable, block;
|
79
|
-
GMountMountFlags flags;
|
80
|
-
GMountOperation *mount_operation;
|
81
|
-
GCancellable *cancellable;
|
82
|
-
|
83
|
-
rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block);
|
84
|
-
flags = RVAL2GMOUNTMOUNTFLAGSDEFAULT(rbflags);
|
85
|
-
mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation);
|
86
|
-
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
87
|
-
SAVE_BLOCK(block);
|
88
|
-
g_volume_mount(_SELF(self),
|
89
|
-
flags,
|
90
|
-
mount_operation,
|
91
|
-
cancellable,
|
92
|
-
rbgio_async_ready_callback,
|
93
|
-
(gpointer)block);
|
94
|
-
|
95
|
-
return self;
|
96
|
-
}
|
97
|
-
|
98
|
-
typedef gboolean (*BooleanFinishMethod)(GVolume *,
|
99
|
-
GAsyncResult *,
|
100
|
-
GError **);
|
101
|
-
|
102
|
-
static VALUE
|
103
|
-
boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result)
|
104
|
-
{
|
105
|
-
GError *error = NULL;
|
106
|
-
|
107
|
-
if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error))
|
108
|
-
rbgio_raise_error(error);
|
109
|
-
|
110
|
-
return self;
|
111
|
-
}
|
112
|
-
|
113
|
-
static VALUE
|
114
|
-
rg_mount_finish(VALUE self, VALUE result)
|
115
|
-
{
|
116
|
-
return boolean_finish_method(g_volume_mount_finish, self, result);
|
117
|
-
}
|
118
|
-
|
119
|
-
static VALUE
|
120
|
-
rg_can_eject_p(VALUE self)
|
121
|
-
{
|
122
|
-
return CBOOL2RVAL(g_volume_can_eject(_SELF(self)));
|
123
|
-
}
|
124
|
-
|
125
|
-
static VALUE
|
126
|
-
rg_eject_with_operation(int argc, VALUE *argv, VALUE self)
|
127
|
-
{
|
128
|
-
VALUE rbflags, rbmount_operation, rbcancellable, block;
|
129
|
-
GMountUnmountFlags flags;
|
130
|
-
GMountOperation *mount_operation;
|
131
|
-
GCancellable *cancellable;
|
132
|
-
|
133
|
-
rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block);
|
134
|
-
flags = RVAL2GMOUNTUNMOUNTFLAGSDEFAULT(rbflags);
|
135
|
-
mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation);
|
136
|
-
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
137
|
-
SAVE_BLOCK(block);
|
138
|
-
g_volume_eject_with_operation(_SELF(self),
|
139
|
-
flags,
|
140
|
-
mount_operation,
|
141
|
-
cancellable,
|
142
|
-
rbgio_async_ready_callback,
|
143
|
-
(gpointer)block);
|
144
|
-
|
145
|
-
return self;
|
146
|
-
}
|
147
|
-
|
148
|
-
static VALUE
|
149
|
-
rg_eject_with_operation_finish(VALUE self, VALUE result)
|
150
|
-
{
|
151
|
-
return boolean_finish_method(g_volume_eject_with_operation_finish, self, result);
|
152
|
-
}
|
153
|
-
|
154
|
-
static VALUE
|
155
|
-
rg_enumerate_identifiers(VALUE self)
|
156
|
-
{
|
157
|
-
return STRV2RVAL_FREE(g_volume_enumerate_identifiers(_SELF(self)));
|
158
|
-
}
|
159
|
-
|
160
|
-
static VALUE
|
161
|
-
rg_get_identifier(VALUE self, VALUE kind)
|
162
|
-
{
|
163
|
-
return CSTR2RVAL_FREE(g_volume_get_identifier(_SELF(self), RVAL2CSTR(kind)));
|
164
|
-
}
|
165
|
-
|
166
|
-
void
|
167
|
-
Init_gvolume(VALUE mGio)
|
168
|
-
{
|
169
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_VOLUME, "Volume", mGio);
|
170
|
-
|
171
|
-
rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_HAL_UDI", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_HAL_UDI));
|
172
|
-
rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_LABEL", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_LABEL));
|
173
|
-
rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_NFS_MOUNT", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT));
|
174
|
-
rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_UNIX_DEVICE", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE));
|
175
|
-
rb_define_const(RG_TARGET_NAMESPACE, "IDENTIFIER_KIND_UUID", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_UUID));
|
176
|
-
|
177
|
-
RG_DEF_METHOD(name, 0);
|
178
|
-
RG_DEF_METHOD(uuid, 0);
|
179
|
-
RG_DEF_METHOD(icon, 0);
|
180
|
-
RG_DEF_METHOD(drive, 0);
|
181
|
-
RG_DEF_METHOD(get_mount, 0);
|
182
|
-
RG_DEF_METHOD_P(can_mount, 0);
|
183
|
-
RG_DEF_METHOD_P(should_automount, 0);
|
184
|
-
RG_DEF_METHOD(activation_root, 0);
|
185
|
-
RG_DEF_METHOD(mount, -1);
|
186
|
-
RG_DEF_METHOD(mount_finish, 1);
|
187
|
-
RG_DEF_METHOD_P(can_eject, 0);
|
188
|
-
RG_DEF_METHOD(eject_with_operation, -1);
|
189
|
-
RG_DEF_METHOD(eject_with_operation_finish, 1);
|
190
|
-
RG_DEF_METHOD(enumerate_identifiers, -1);
|
191
|
-
RG_DEF_ALIAS("identifiers", "enumerate_identifiers");
|
192
|
-
RG_DEF_METHOD(get_identifier, 1);
|
193
|
-
}
|
@@ -1,77 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
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, or (at your option) any later version.
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
-
* MA 02110-1301 USA
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE cVolumeMonitor
|
25
|
-
#define _SELF(value) RVAL2GVOLUMEMONITOR(value)
|
26
|
-
|
27
|
-
static VALUE
|
28
|
-
rg_s_get(G_GNUC_UNUSED VALUE self)
|
29
|
-
{
|
30
|
-
return GOBJ2RVAL_UNREF(g_volume_monitor_get());
|
31
|
-
}
|
32
|
-
|
33
|
-
static VALUE
|
34
|
-
rg_connected_drives(VALUE self)
|
35
|
-
{
|
36
|
-
return GLIST2ARY_FREE(g_volume_monitor_get_connected_drives(_SELF(self)));
|
37
|
-
}
|
38
|
-
|
39
|
-
static VALUE
|
40
|
-
rg_volumes(VALUE self)
|
41
|
-
{
|
42
|
-
return GLIST2ARY_FREE(g_volume_monitor_get_volumes(_SELF(self)));
|
43
|
-
}
|
44
|
-
|
45
|
-
static VALUE
|
46
|
-
rg_mounts(VALUE self)
|
47
|
-
{
|
48
|
-
return GLIST2ARY_FREE(g_volume_monitor_get_mounts(_SELF(self)));
|
49
|
-
}
|
50
|
-
|
51
|
-
static VALUE
|
52
|
-
rg_get_mount_for_uuid(VALUE self, VALUE value)
|
53
|
-
{
|
54
|
-
return GOBJ2RVAL_UNREF(g_volume_monitor_get_mount_for_uuid(_SELF(self), RVAL2CSTR(value)));
|
55
|
-
}
|
56
|
-
|
57
|
-
static VALUE
|
58
|
-
rg_get_volume_for_uuid(VALUE self, VALUE value)
|
59
|
-
{
|
60
|
-
return GOBJ2RVAL_UNREF(g_volume_monitor_get_volume_for_uuid(_SELF(self), RVAL2CSTR(value)));
|
61
|
-
}
|
62
|
-
|
63
|
-
void
|
64
|
-
Init_gvolumemonitor(VALUE mGio)
|
65
|
-
{
|
66
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VOLUME_MONITOR, "VolumeMonitor", mGio);
|
67
|
-
|
68
|
-
rb_define_const(RG_TARGET_NAMESPACE, "EXTENSION_POINT_NAME", CSTR2RVAL(G_VOLUME_MONITOR_EXTENSION_POINT_NAME));
|
69
|
-
|
70
|
-
RG_DEF_SMETHOD(get, 0);
|
71
|
-
|
72
|
-
RG_DEF_METHOD(connected_drives, 0);
|
73
|
-
RG_DEF_METHOD(volumes, 0);
|
74
|
-
RG_DEF_METHOD(mounts, 0);
|
75
|
-
RG_DEF_METHOD(get_mount_for_uuid, 0);
|
76
|
-
RG_DEF_METHOD(get_volume_for_uuid, 0);
|
77
|
-
}
|
@@ -1,52 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
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, or (at your option) any later version.
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
-
* MA 02110-1301 USA
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE cZlibCompressor
|
25
|
-
#define _SELF(value) RVAL2GZLIBCOMPRESSOR(value)
|
26
|
-
|
27
|
-
#define RVAL2ZLIBCOMPRESSORLEVELDEFAULT(value) \
|
28
|
-
RVAL2TYPE_WITH_DEFAULT((value), FIX2INT, -1)
|
29
|
-
|
30
|
-
static VALUE
|
31
|
-
rg_initialize(int argc, VALUE *argv, VALUE self)
|
32
|
-
{
|
33
|
-
VALUE format, level;
|
34
|
-
|
35
|
-
rb_scan_args(argc, argv, "02", &format, &level);
|
36
|
-
G_INITIALIZE(self,
|
37
|
-
g_zlib_compressor_new(RVAL2GZLIBCOMPRESSORFORMATDEFAULT(format),
|
38
|
-
RVAL2GZLIBCOMPRESSORFORMATDEFAULT(level)));
|
39
|
-
|
40
|
-
return Qnil;
|
41
|
-
}
|
42
|
-
|
43
|
-
void
|
44
|
-
Init_gzlibcompressor(VALUE mGio)
|
45
|
-
{
|
46
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ZLIB_COMPRESSOR, "ZlibCompressor", mGio);
|
47
|
-
|
48
|
-
G_DEF_CLASS(G_TYPE_ZLIB_COMPRESSOR_FORMAT, "Format", RG_TARGET_NAMESPACE);
|
49
|
-
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_ZLIB_COMPRESSOR_FORMAT, "G_ZLIB_");
|
50
|
-
|
51
|
-
RG_DEF_METHOD(initialize, -1);
|
52
|
-
}
|
@@ -1,45 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
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, or (at your option) any later version.
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
-
* MA 02110-1301 USA
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE cZlibDecompressor
|
25
|
-
#define _SELF(value) RVAL2GZLIBDECOMPRESSOR(value)
|
26
|
-
|
27
|
-
static VALUE
|
28
|
-
rg_initialize(int argc, VALUE *argv, VALUE self)
|
29
|
-
{
|
30
|
-
VALUE format;
|
31
|
-
|
32
|
-
rb_scan_args(argc, argv, "01", &format);
|
33
|
-
G_INITIALIZE(self,
|
34
|
-
g_zlib_decompressor_new(RVAL2GZLIBCOMPRESSORFORMATDEFAULT(format)));
|
35
|
-
|
36
|
-
return Qnil;
|
37
|
-
}
|
38
|
-
|
39
|
-
void
|
40
|
-
Init_gzlibdecompressor(VALUE mGio)
|
41
|
-
{
|
42
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ZLIB_DECOMPRESSOR, "ZlibDecompressor", mGio);
|
43
|
-
|
44
|
-
RG_DEF_METHOD(initialize, -1);
|
45
|
-
}
|
data/ext/gio2/util.c
DELETED
@@ -1,303 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
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, or (at your option) any later version.
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
-
* MA 02110-1301 USA
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
|
25
|
-
#ifndef HAVE_RB_ERRINFO
|
26
|
-
# define rb_errinfo() (ruby_errinfo)
|
27
|
-
#endif
|
28
|
-
|
29
|
-
|
30
|
-
static ID s_id_enum_name;
|
31
|
-
static ID s_id_errors;
|
32
|
-
|
33
|
-
static VALUE s_errors;
|
34
|
-
|
35
|
-
|
36
|
-
VALUE
|
37
|
-
rbgio_cstr_to_rval_tainted(const char *string, gsize length)
|
38
|
-
{
|
39
|
-
VALUE result;
|
40
|
-
|
41
|
-
if (string == NULL)
|
42
|
-
return Qnil;
|
43
|
-
|
44
|
-
result = rb_str_new(string, length);
|
45
|
-
OBJ_TAINT(result);
|
46
|
-
|
47
|
-
return result;
|
48
|
-
}
|
49
|
-
|
50
|
-
struct rbgio_cstr_to_rval_tainted_free_data
|
51
|
-
{
|
52
|
-
char *string;
|
53
|
-
gsize length;
|
54
|
-
};
|
55
|
-
|
56
|
-
static VALUE
|
57
|
-
rbgio_cstr_to_rval_tainted_free_body(VALUE data)
|
58
|
-
{
|
59
|
-
struct rbgio_cstr_to_rval_tainted_free_data *real;
|
60
|
-
|
61
|
-
real = (struct rbgio_cstr_to_rval_tainted_free_data *)data;
|
62
|
-
|
63
|
-
return rbgio_cstr_to_rval_tainted(real->string, real->length);
|
64
|
-
}
|
65
|
-
|
66
|
-
static VALUE
|
67
|
-
rbgio_cstr_to_rval_tainted_free_ensure(VALUE data)
|
68
|
-
{
|
69
|
-
g_free(((struct rbgio_cstr_to_rval_tainted_free_data *)data)->string);
|
70
|
-
|
71
|
-
return Qnil;
|
72
|
-
}
|
73
|
-
|
74
|
-
VALUE
|
75
|
-
rbgio_cstr_to_rval_tainted_free(char *string, gsize length)
|
76
|
-
{
|
77
|
-
struct rbgio_cstr_to_rval_tainted_free_data data = { string, length };
|
78
|
-
|
79
|
-
return rb_ensure(rbgio_cstr_to_rval_tainted_free_body, (VALUE)&data,
|
80
|
-
rbgio_cstr_to_rval_tainted_free_ensure, (VALUE)&data);
|
81
|
-
}
|
82
|
-
|
83
|
-
VALUE
|
84
|
-
rbgio_glist_to_ary_unref_free(GList *list)
|
85
|
-
{
|
86
|
-
VALUE ary;
|
87
|
-
GList *i;
|
88
|
-
|
89
|
-
ary = rb_ary_new();
|
90
|
-
for (i = list; i != NULL; i = i->next)
|
91
|
-
rb_ary_push(ary, GOBJ2RVAL_UNREF(i->data));
|
92
|
-
g_list_free(list);
|
93
|
-
|
94
|
-
return ary;
|
95
|
-
}
|
96
|
-
|
97
|
-
VALUE
|
98
|
-
rbgio_fds_to_ary(const gint *fds)
|
99
|
-
{
|
100
|
-
int i, n;
|
101
|
-
VALUE ary;
|
102
|
-
|
103
|
-
for (i = n = 0; fds[i] != -1; i++)
|
104
|
-
n++;
|
105
|
-
|
106
|
-
ary = rb_ary_new2(n);
|
107
|
-
for (i = 0; i < n; i++)
|
108
|
-
RARRAY_PTR(ary)[i] = FD2RVAL(fds[i]);
|
109
|
-
|
110
|
-
return ary;
|
111
|
-
}
|
112
|
-
|
113
|
-
static VALUE
|
114
|
-
rbgio_fds_to_ary_free_ensure(gint *fds)
|
115
|
-
{
|
116
|
-
g_free(fds);
|
117
|
-
|
118
|
-
return Qnil;
|
119
|
-
}
|
120
|
-
|
121
|
-
VALUE
|
122
|
-
rbgio_fds_to_ary_free(gint *fds)
|
123
|
-
{
|
124
|
-
return rb_ensure(rbgio_fds_to_ary, (VALUE)fds,
|
125
|
-
rbgio_fds_to_ary_free_ensure, (VALUE)fds);
|
126
|
-
}
|
127
|
-
|
128
|
-
struct rbgio_gfile_ary_to_glist_args {
|
129
|
-
VALUE ary;
|
130
|
-
long n;
|
131
|
-
GList *result;
|
132
|
-
};
|
133
|
-
|
134
|
-
static VALUE
|
135
|
-
rbgio_gfile_ary_to_glist_body(VALUE value)
|
136
|
-
{
|
137
|
-
long i;
|
138
|
-
struct rbgio_gfile_ary_to_glist_args *args = (struct rbgio_gfile_ary_to_glist_args *)value;
|
139
|
-
|
140
|
-
for (i = 0; i < args->n; i++)
|
141
|
-
args->result = g_list_append(args->result, RVAL2GFILE(RARRAY_PTR(args->ary)[i]));
|
142
|
-
|
143
|
-
return Qnil;
|
144
|
-
}
|
145
|
-
|
146
|
-
static G_GNUC_NORETURN VALUE
|
147
|
-
rbgio_gfile_ary_to_glist_rescue(VALUE value)
|
148
|
-
{
|
149
|
-
g_list_free(((struct rbgio_gfile_ary_to_glist_args *)value)->result);
|
150
|
-
|
151
|
-
rb_exc_raise(rb_errinfo());
|
152
|
-
}
|
153
|
-
|
154
|
-
GList *
|
155
|
-
rbgio_gfile_ary_to_glist(VALUE value)
|
156
|
-
{
|
157
|
-
struct rbgio_gfile_ary_to_glist_args args;
|
158
|
-
|
159
|
-
args.ary = rb_ary_to_ary(value);
|
160
|
-
args.n = RARRAY_LEN(args.ary);
|
161
|
-
args.result = NULL;
|
162
|
-
|
163
|
-
rb_rescue(rbgio_gfile_ary_to_glist_body, (VALUE)&args,
|
164
|
-
rbgio_gfile_ary_to_glist_rescue, (VALUE)&args);
|
165
|
-
|
166
|
-
return args.result;
|
167
|
-
}
|
168
|
-
|
169
|
-
GList *
|
170
|
-
rbgio_gfile_ary_to_glist_accept_nil(VALUE ary)
|
171
|
-
{
|
172
|
-
if (NIL_P(ary))
|
173
|
-
return NULL;
|
174
|
-
|
175
|
-
return rbgio_gfile_ary_to_glist(ary);
|
176
|
-
}
|
177
|
-
|
178
|
-
void
|
179
|
-
rbgio_rval_to_gtimeval(VALUE value, GTimeVal *time)
|
180
|
-
{
|
181
|
-
if (rb_respond_to(value, rb_intern("tv_sec"))) {
|
182
|
-
time->tv_sec = RVAL2GLONG(rb_funcall(value, rb_intern("tv_sec"), 0));
|
183
|
-
time->tv_usec = rb_respond_to(value, rb_intern("tv_usec")) ?
|
184
|
-
RVAL2GLONG(rb_funcall(value, rb_intern("tv_usec"), 0)) :
|
185
|
-
0;
|
186
|
-
} else if (rb_respond_to(value, rb_intern("to_ary"))) {
|
187
|
-
VALUE ary = rb_ary_to_ary(value);
|
188
|
-
if (RARRAY_LEN(ary) < 1 || RARRAY_LEN(ary) > 2)
|
189
|
-
rb_raise(rb_eArgError, "Array of length 1 or 2 expected");
|
190
|
-
time->tv_sec = RVAL2GLONG(RARRAY_PTR(ary)[0]);
|
191
|
-
time->tv_usec = RARRAY_LEN(ary) > 1 ? RVAL2GLONG(RARRAY_PTR(ary)[1]) : 0;
|
192
|
-
} else {
|
193
|
-
time->tv_sec = RVAL2GLONG(value);
|
194
|
-
time->tv_usec = 0;
|
195
|
-
}
|
196
|
-
}
|
197
|
-
|
198
|
-
struct async_ready_callback_data
|
199
|
-
{
|
200
|
-
GAsyncResult *result;
|
201
|
-
gpointer data;
|
202
|
-
};
|
203
|
-
|
204
|
-
static VALUE
|
205
|
-
rbgio_async_ready_callback_call(VALUE data)
|
206
|
-
{
|
207
|
-
static VALUE s_id_call;
|
208
|
-
struct async_ready_callback_data *real;
|
209
|
-
VALUE block;
|
210
|
-
|
211
|
-
if (s_id_call == 0)
|
212
|
-
s_id_call = rb_intern("call");
|
213
|
-
|
214
|
-
real = (struct async_ready_callback_data *)data;
|
215
|
-
block = USE_BLOCK(real->data);
|
216
|
-
if (!NIL_P(block))
|
217
|
-
rb_funcall(block, s_id_call, 1, GOBJ2RVAL_UNREF(real->result));
|
218
|
-
|
219
|
-
return Qnil;
|
220
|
-
}
|
221
|
-
|
222
|
-
void
|
223
|
-
rbgio_async_ready_callback(G_GNUC_UNUSED GObject *source,
|
224
|
-
GAsyncResult *result,
|
225
|
-
gpointer data)
|
226
|
-
{
|
227
|
-
struct async_ready_callback_data real = { result, data };
|
228
|
-
|
229
|
-
G_PROTECT_CALLBACK(rbgio_async_ready_callback_call, &real);
|
230
|
-
}
|
231
|
-
|
232
|
-
VALUE
|
233
|
-
rbgio_child_remove_and_return(VALUE parent, VALUE child)
|
234
|
-
{
|
235
|
-
G_CHILD_REMOVE(parent, child);
|
236
|
-
|
237
|
-
return child;
|
238
|
-
}
|
239
|
-
|
240
|
-
VALUE
|
241
|
-
rbgio_define_domain_error(VALUE module,
|
242
|
-
const char *name,
|
243
|
-
GQuark domain,
|
244
|
-
const char *enum_name,
|
245
|
-
VALUE parent)
|
246
|
-
{
|
247
|
-
VALUE error;
|
248
|
-
|
249
|
-
error = rb_define_class_under(module, name, parent);
|
250
|
-
rb_ivar_set(error, s_id_enum_name, CSTR2RVAL(enum_name));
|
251
|
-
rb_ivar_set(error, s_id_errors, rb_hash_new());
|
252
|
-
rb_hash_aset(s_errors, UINT2NUM(domain), error);
|
253
|
-
|
254
|
-
return error;
|
255
|
-
}
|
256
|
-
|
257
|
-
VALUE
|
258
|
-
rbgio_define_error(VALUE module,
|
259
|
-
const char *name,
|
260
|
-
gint code,
|
261
|
-
VALUE domain_error)
|
262
|
-
{
|
263
|
-
VALUE error;
|
264
|
-
|
265
|
-
error = rb_define_class_under(module, name, domain_error);
|
266
|
-
rb_hash_aset(rb_ivar_get(domain_error, s_id_errors),
|
267
|
-
INT2NUM(code),
|
268
|
-
error);
|
269
|
-
|
270
|
-
return error;
|
271
|
-
}
|
272
|
-
|
273
|
-
void
|
274
|
-
rbgio_raise_error(GError *error)
|
275
|
-
{
|
276
|
-
VALUE domain_error, rberror;
|
277
|
-
|
278
|
-
domain_error = rb_hash_aref(s_errors, UINT2NUM(error->domain));
|
279
|
-
if (NIL_P(domain_error))
|
280
|
-
RAISE_GERROR(error);
|
281
|
-
|
282
|
-
rberror = rb_hash_aref(rb_ivar_get(domain_error, s_id_errors),
|
283
|
-
INT2NUM(error->code));
|
284
|
-
if (NIL_P(rberror)) {
|
285
|
-
VALUE enum_name = rb_ivar_get(domain_error, s_id_enum_name);
|
286
|
-
|
287
|
-
rb_raise(rb_eNotImpError,
|
288
|
-
"%s contains error codes that have not been implemented: %d",
|
289
|
-
RVAL2CSTR(enum_name), error->code);
|
290
|
-
}
|
291
|
-
|
292
|
-
rb_raise(rberror, "%s", error->message);
|
293
|
-
}
|
294
|
-
|
295
|
-
void
|
296
|
-
Init_util(void)
|
297
|
-
{
|
298
|
-
s_id_enum_name = rb_intern("@enum_name");
|
299
|
-
s_id_errors = rb_intern("@errors");
|
300
|
-
|
301
|
-
s_errors = rb_hash_new();
|
302
|
-
rb_global_variable(&s_errors);
|
303
|
-
}
|