gio2 2.1.0-x86-mingw32 → 2.2.0-x86-mingw32
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.
- 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/1.9/gio2.so +0 -0
- data/lib/2.0/gio2.so +0 -0
- data/lib/2.1/gio2.so +0 -0
- 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/lib/gio2.rb +38 -143
- 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/fixture.rb +24 -0
- data/test/gio2-test-utils/socket-client.rb +59 -0
- data/test/gio2-test-utils.rb +21 -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
@@ -1,152 +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 cSimpleAsyncResult
|
25
|
-
#define _SELF(value) RVAL2GSIMPLEASYNCRESULT(value)
|
26
|
-
|
27
|
-
static VALUE
|
28
|
-
rg_initialize(VALUE self, VALUE object)
|
29
|
-
{
|
30
|
-
VALUE block;
|
31
|
-
|
32
|
-
/* TODO: I have absolutely no idea if this makes sense. Should we even
|
33
|
-
* be providing this method? */
|
34
|
-
block = rb_block_proc();
|
35
|
-
SAVE_BLOCK(block);
|
36
|
-
G_INITIALIZE(self,
|
37
|
-
g_simple_async_result_new(RVAL2GOBJ(object),
|
38
|
-
rbgio_async_ready_callback,
|
39
|
-
(gpointer)block,
|
40
|
-
(gpointer)block));
|
41
|
-
|
42
|
-
return Qnil;
|
43
|
-
}
|
44
|
-
|
45
|
-
/* NOTE: Can't implement g_simple_async_result_new_error. */
|
46
|
-
|
47
|
-
/* NOTE: Can't implement g_simple_async_result_new_from_error. */
|
48
|
-
|
49
|
-
/* NOTE: Can't implement g_simple_async_result_set_op_res_gpointer. */
|
50
|
-
|
51
|
-
/* NOTE: Can't implement g_simple_async_result_get_op_res_gpointer. */
|
52
|
-
|
53
|
-
static VALUE
|
54
|
-
rg_set_op_res_gssize(VALUE self, VALUE op_res)
|
55
|
-
{
|
56
|
-
g_simple_async_result_set_op_res_gssize(_SELF(self),
|
57
|
-
RVAL2GSSIZE(op_res));
|
58
|
-
|
59
|
-
return self;
|
60
|
-
}
|
61
|
-
|
62
|
-
static VALUE
|
63
|
-
rg_op_res_gssize(VALUE self)
|
64
|
-
{
|
65
|
-
return GSSIZE2RVAL(g_simple_async_result_get_op_res_gssize(_SELF(self)));
|
66
|
-
}
|
67
|
-
|
68
|
-
static VALUE
|
69
|
-
rg_set_op_res_gboolean(VALUE self, VALUE op_res)
|
70
|
-
{
|
71
|
-
g_simple_async_result_set_op_res_gboolean(_SELF(self),
|
72
|
-
RVAL2CBOOL(op_res));
|
73
|
-
|
74
|
-
return self;
|
75
|
-
}
|
76
|
-
|
77
|
-
static VALUE
|
78
|
-
rg_op_res_gboolean(VALUE self)
|
79
|
-
{
|
80
|
-
return CBOOL2RVAL(g_simple_async_result_get_op_res_gboolean(_SELF(self)));
|
81
|
-
}
|
82
|
-
|
83
|
-
static VALUE
|
84
|
-
rg_source_tag(VALUE self)
|
85
|
-
{
|
86
|
-
return (VALUE)g_simple_async_result_get_source_tag(_SELF(self));
|
87
|
-
}
|
88
|
-
|
89
|
-
static VALUE
|
90
|
-
rg_valid_p(VALUE self, VALUE source, VALUE source_tag)
|
91
|
-
{
|
92
|
-
return CBOOL2RVAL(g_simple_async_result_is_valid(RVAL2GASYNCRESULT(self),
|
93
|
-
RVAL2GOBJ(source),
|
94
|
-
(gpointer)source_tag));
|
95
|
-
}
|
96
|
-
|
97
|
-
static VALUE
|
98
|
-
rg_set_handle_cancellation(VALUE self, VALUE handle_cancellation)
|
99
|
-
{
|
100
|
-
g_simple_async_result_set_handle_cancellation(_SELF(self),
|
101
|
-
RVAL2CBOOL(handle_cancellation));
|
102
|
-
|
103
|
-
return self;
|
104
|
-
}
|
105
|
-
|
106
|
-
static VALUE
|
107
|
-
rg_complete(VALUE self)
|
108
|
-
{
|
109
|
-
g_simple_async_result_complete(_SELF(self));
|
110
|
-
|
111
|
-
return self;
|
112
|
-
}
|
113
|
-
|
114
|
-
static VALUE
|
115
|
-
rg_complete_in_idle(VALUE self)
|
116
|
-
{
|
117
|
-
g_simple_async_result_complete_in_idle(_SELF(self));
|
118
|
-
|
119
|
-
return self;
|
120
|
-
}
|
121
|
-
|
122
|
-
/* TODO: Should we implement g_simple_async_result_run_in_thread? I'd say no,
|
123
|
-
* but I'm not sure. */
|
124
|
-
|
125
|
-
/* NOTE: Can't implement g_simple_async_result_set_from_error. */
|
126
|
-
|
127
|
-
/* NOTE: Can't implement g_simple_async_result_propagate_error. */
|
128
|
-
|
129
|
-
/* NOTE: Can't implement g_simple_async_result_set_error. */
|
130
|
-
|
131
|
-
/* NOTE: Can't implement g_simple_async_result_set_error_va. */
|
132
|
-
|
133
|
-
/* NOTE: Can't implement g_simple_async_result_report_error_in_idle. */
|
134
|
-
|
135
|
-
/* NOTE: Can't implement g_simple_async_result_report_gerror_in_idle. */
|
136
|
-
|
137
|
-
void
|
138
|
-
Init_gsimpleasyncresult(VALUE mGio)
|
139
|
-
{
|
140
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SIMPLE_ASYNC_RESULT, "SimpleAsyncResult", mGio);
|
141
|
-
|
142
|
-
RG_DEF_METHOD(initialize, 1);
|
143
|
-
RG_DEF_METHOD(set_op_res_gssize, 1);
|
144
|
-
RG_DEF_METHOD(op_res_gssize, 0);
|
145
|
-
RG_DEF_METHOD(set_op_res_gboolean, 1);
|
146
|
-
RG_DEF_METHOD(op_res_gboolean, 0);
|
147
|
-
RG_DEF_METHOD(source_tag, 0);
|
148
|
-
RG_DEF_METHOD_P(valid, 2);
|
149
|
-
RG_DEF_METHOD(set_handle_cancellation, 1);
|
150
|
-
RG_DEF_METHOD(complete, 0);
|
151
|
-
RG_DEF_METHOD(complete_in_idle, 0);
|
152
|
-
}
|
data/ext/gio2/rbgiosocket.c
DELETED
@@ -1,390 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011-2012 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 cSocket
|
25
|
-
#define _SELF(value) RVAL2GSOCKET(value)
|
26
|
-
|
27
|
-
static ID id_call;
|
28
|
-
|
29
|
-
static VALUE
|
30
|
-
rg_initialize(int argc, VALUE *argv, VALUE self)
|
31
|
-
{
|
32
|
-
VALUE family, type, protocol;
|
33
|
-
GError *error = NULL;
|
34
|
-
GSocket *socket;
|
35
|
-
|
36
|
-
rb_scan_args(argc, argv, "21", &family, &type, &protocol);
|
37
|
-
socket = g_socket_new(RVAL2GSOCKETFAMILY(family),
|
38
|
-
RVAL2GSOCKETTYPE(type),
|
39
|
-
RVAL2GSOCKETPROTOCOLDEFAULT(protocol),
|
40
|
-
&error);
|
41
|
-
if (socket == NULL)
|
42
|
-
rbgio_raise_error(error);
|
43
|
-
|
44
|
-
G_INITIALIZE(self, socket);
|
45
|
-
|
46
|
-
return Qnil;
|
47
|
-
}
|
48
|
-
|
49
|
-
static VALUE
|
50
|
-
rg_s_new_from_fd(G_GNUC_UNUSED VALUE self, VALUE id)
|
51
|
-
{
|
52
|
-
GError *error = NULL;
|
53
|
-
GSocket *socket;
|
54
|
-
|
55
|
-
socket = g_socket_new_from_fd(RVAL2FD(id), &error);
|
56
|
-
if (socket == NULL)
|
57
|
-
rbgio_raise_error(error);
|
58
|
-
|
59
|
-
return GOBJ2RVAL_UNREF(socket);
|
60
|
-
}
|
61
|
-
|
62
|
-
static VALUE
|
63
|
-
rg_bind(VALUE self, VALUE address, VALUE allow_reuse)
|
64
|
-
{
|
65
|
-
GError *error = NULL;
|
66
|
-
|
67
|
-
if (!g_socket_bind(_SELF(self),
|
68
|
-
RVAL2GSOCKETADDRESS(address),
|
69
|
-
RVAL2CBOOL(allow_reuse),
|
70
|
-
&error))
|
71
|
-
rbgio_raise_error(error);
|
72
|
-
|
73
|
-
return self;
|
74
|
-
}
|
75
|
-
|
76
|
-
static VALUE
|
77
|
-
rg_listen(VALUE self)
|
78
|
-
{
|
79
|
-
GError *error = NULL;
|
80
|
-
|
81
|
-
if (!g_socket_listen(_SELF(self), &error))
|
82
|
-
rbgio_raise_error(error);
|
83
|
-
|
84
|
-
return self;
|
85
|
-
}
|
86
|
-
|
87
|
-
static VALUE
|
88
|
-
rg_accept(int argc, VALUE *argv, VALUE self)
|
89
|
-
{
|
90
|
-
VALUE cancellable;
|
91
|
-
GError *error = NULL;
|
92
|
-
GSocket *socket;
|
93
|
-
|
94
|
-
rb_scan_args(argc, argv, "01", &cancellable);
|
95
|
-
socket = g_socket_accept(_SELF(self),
|
96
|
-
RVAL2GCANCELLABLE(cancellable),
|
97
|
-
&error);
|
98
|
-
if (socket == NULL)
|
99
|
-
rbgio_raise_error(error);
|
100
|
-
|
101
|
-
return self;
|
102
|
-
}
|
103
|
-
|
104
|
-
static VALUE
|
105
|
-
rg_connect(int argc, VALUE *argv, VALUE self)
|
106
|
-
{
|
107
|
-
VALUE address, cancellable;
|
108
|
-
GError *error = NULL;
|
109
|
-
|
110
|
-
rb_scan_args(argc, argv, "11", &address, &cancellable);
|
111
|
-
if (!g_socket_connect(_SELF(self),
|
112
|
-
RVAL2GSOCKETADDRESS(address),
|
113
|
-
RVAL2GCANCELLABLE(cancellable),
|
114
|
-
&error))
|
115
|
-
rbgio_raise_error(error);
|
116
|
-
|
117
|
-
return self;
|
118
|
-
}
|
119
|
-
|
120
|
-
/* TODO: This makes very little sense in Ruby. How do we deal with it? */
|
121
|
-
static VALUE
|
122
|
-
rg_check_connect_result(VALUE self)
|
123
|
-
{
|
124
|
-
GError *error = NULL;
|
125
|
-
|
126
|
-
if (!g_socket_check_connect_result(_SELF(self), &error))
|
127
|
-
rbgio_raise_error(error);
|
128
|
-
|
129
|
-
return self;
|
130
|
-
}
|
131
|
-
|
132
|
-
static VALUE
|
133
|
-
rg_receive(int argc, VALUE *argv, VALUE self)
|
134
|
-
{
|
135
|
-
VALUE rbbytes, cancellable, result;
|
136
|
-
GError *error = NULL;
|
137
|
-
gsize bytes;
|
138
|
-
gssize read;
|
139
|
-
|
140
|
-
rb_scan_args(argc, argv, "11", &rbbytes, &cancellable);
|
141
|
-
bytes = RVAL2GSIZE(rbbytes);
|
142
|
-
result = rb_str_new(NULL, bytes);
|
143
|
-
read = g_socket_receive(_SELF(self),
|
144
|
-
RSTRING_PTR(result),
|
145
|
-
bytes,
|
146
|
-
RVAL2GCANCELLABLE(cancellable),
|
147
|
-
&error);
|
148
|
-
if (read == -1)
|
149
|
-
rbgio_raise_error(error);
|
150
|
-
|
151
|
-
/* TODO: This is what Ruby does, but I can't figure out why one needs
|
152
|
-
* both. */
|
153
|
-
rb_str_set_len(result, read);
|
154
|
-
rb_str_resize(result, read);
|
155
|
-
OBJ_TAINT(result);
|
156
|
-
|
157
|
-
return result;
|
158
|
-
}
|
159
|
-
|
160
|
-
static VALUE
|
161
|
-
rg_receive_from(int argc, VALUE *argv, VALUE self)
|
162
|
-
{
|
163
|
-
VALUE rbbytes, cancellable, result;
|
164
|
-
GSocketAddress *address;
|
165
|
-
GError *error = NULL;
|
166
|
-
gsize bytes;
|
167
|
-
gssize read;
|
168
|
-
|
169
|
-
rb_scan_args(argc, argv, "11", &rbbytes, &cancellable);
|
170
|
-
bytes = RVAL2GSIZE(rbbytes);
|
171
|
-
result = rb_str_new(NULL, bytes);
|
172
|
-
read = g_socket_receive_from(_SELF(self),
|
173
|
-
&address,
|
174
|
-
RSTRING_PTR(result),
|
175
|
-
bytes,
|
176
|
-
RVAL2GCANCELLABLE(cancellable),
|
177
|
-
&error);
|
178
|
-
if (read == -1)
|
179
|
-
rbgio_raise_error(error);
|
180
|
-
|
181
|
-
rb_str_set_len(result, read);
|
182
|
-
rb_str_resize(result, read);
|
183
|
-
OBJ_TAINT(result);
|
184
|
-
|
185
|
-
return rb_assoc_new(GOBJ2RVAL_UNREF(address), result);
|
186
|
-
}
|
187
|
-
|
188
|
-
static VALUE
|
189
|
-
rg_send(int argc, VALUE *argv, VALUE self)
|
190
|
-
{
|
191
|
-
VALUE buffer, cancellable;
|
192
|
-
GError *error = NULL;
|
193
|
-
gssize sent;
|
194
|
-
|
195
|
-
rb_scan_args(argc, argv, "11", &buffer, &cancellable);
|
196
|
-
StringValue(buffer);
|
197
|
-
sent = g_socket_send(_SELF(self),
|
198
|
-
RSTRING_PTR(buffer),
|
199
|
-
RSTRING_LEN(buffer),
|
200
|
-
RVAL2GCANCELLABLE(cancellable),
|
201
|
-
&error);
|
202
|
-
if (sent == -1)
|
203
|
-
rbgio_raise_error(error);
|
204
|
-
|
205
|
-
return GSSIZE2RVAL(sent);
|
206
|
-
}
|
207
|
-
|
208
|
-
static VALUE
|
209
|
-
rg_send_to(int argc, VALUE *argv, VALUE self)
|
210
|
-
{
|
211
|
-
VALUE address, buffer, cancellable;
|
212
|
-
GError *error = NULL;
|
213
|
-
gssize sent;
|
214
|
-
|
215
|
-
rb_scan_args(argc, argv, "11", &address, &buffer, &cancellable);
|
216
|
-
StringValue(buffer);
|
217
|
-
sent = g_socket_send_to(_SELF(self),
|
218
|
-
RVAL2GSOCKETADDRESS(address),
|
219
|
-
RSTRING_PTR(buffer),
|
220
|
-
RSTRING_LEN(buffer),
|
221
|
-
RVAL2GCANCELLABLE(cancellable),
|
222
|
-
&error);
|
223
|
-
if (sent == -1)
|
224
|
-
rbgio_raise_error(error);
|
225
|
-
|
226
|
-
return GSSIZE2RVAL(sent);
|
227
|
-
}
|
228
|
-
|
229
|
-
static VALUE
|
230
|
-
rg_close(VALUE self)
|
231
|
-
{
|
232
|
-
GError *error = NULL;
|
233
|
-
|
234
|
-
if (!g_socket_close(_SELF(self), &error))
|
235
|
-
rbgio_raise_error(error);
|
236
|
-
|
237
|
-
return self;
|
238
|
-
}
|
239
|
-
|
240
|
-
static VALUE
|
241
|
-
rg_closed_p(VALUE self)
|
242
|
-
{
|
243
|
-
return CBOOL2RVAL(g_socket_is_closed(_SELF(self)));
|
244
|
-
}
|
245
|
-
|
246
|
-
static VALUE
|
247
|
-
rg_shutdown(VALUE self, VALUE shutdown_read, VALUE shutdown_write)
|
248
|
-
{
|
249
|
-
GError *error = NULL;
|
250
|
-
|
251
|
-
if (!g_socket_shutdown(_SELF(self),
|
252
|
-
RVAL2CBOOL(shutdown_read),
|
253
|
-
RVAL2CBOOL(shutdown_write),
|
254
|
-
&error))
|
255
|
-
rbgio_raise_error(error);
|
256
|
-
|
257
|
-
return self;
|
258
|
-
}
|
259
|
-
|
260
|
-
static VALUE
|
261
|
-
rg_connected_p(VALUE self)
|
262
|
-
{
|
263
|
-
return (g_socket_is_connected(_SELF(self)));
|
264
|
-
}
|
265
|
-
|
266
|
-
static gboolean
|
267
|
-
source_func(GSocket *socket, GIOCondition condition, gpointer user_data)
|
268
|
-
{
|
269
|
-
VALUE callback = (VALUE)user_data;
|
270
|
-
return RVAL2CBOOL(rb_funcall(callback, id_call, 2,
|
271
|
-
GOBJ2RVAL(socket),
|
272
|
-
GIOCONDITION2RVAL(condition)));
|
273
|
-
}
|
274
|
-
|
275
|
-
static VALUE
|
276
|
-
rg_create_source(int argc, VALUE *argv, VALUE self)
|
277
|
-
{
|
278
|
-
VALUE condition, cancellable, callback;
|
279
|
-
GSource *source;
|
280
|
-
|
281
|
-
rb_scan_args(argc, argv, "11&", &condition, &cancellable, &callback);
|
282
|
-
|
283
|
-
source = g_socket_create_source(_SELF(self),
|
284
|
-
RVAL2GIOCONDITION(condition),
|
285
|
-
RVAL2GCANCELLABLE(cancellable));
|
286
|
-
G_RELATIVE(self, callback);
|
287
|
-
g_source_set_callback(source,
|
288
|
-
(GSourceFunc)source_func,
|
289
|
-
(gpointer)callback,
|
290
|
-
NULL);
|
291
|
-
return GSOURCE2RVAL(source);
|
292
|
-
}
|
293
|
-
|
294
|
-
static VALUE
|
295
|
-
rg_condition_check(VALUE self, VALUE condition)
|
296
|
-
{
|
297
|
-
return GIOCONDITION2RVAL(g_socket_condition_check(_SELF(self),
|
298
|
-
RVAL2GIOCONDITION(condition)));
|
299
|
-
}
|
300
|
-
|
301
|
-
static VALUE
|
302
|
-
rg_condition_wait(int argc, VALUE *argv, VALUE self)
|
303
|
-
{
|
304
|
-
VALUE condition, cancellable;
|
305
|
-
GError *error = NULL;
|
306
|
-
|
307
|
-
rb_scan_args(argc, argv, "11", &condition, &cancellable);
|
308
|
-
if (!g_socket_condition_wait(_SELF(self),
|
309
|
-
RVAL2GIOCONDITION(condition),
|
310
|
-
RVAL2GCANCELLABLE(cancellable),
|
311
|
-
&error))
|
312
|
-
rbgio_raise_error(error);
|
313
|
-
|
314
|
-
return self;
|
315
|
-
}
|
316
|
-
|
317
|
-
static VALUE
|
318
|
-
socket_get_local_address(VALUE self)
|
319
|
-
{
|
320
|
-
GError *error = NULL;
|
321
|
-
GSocketAddress *address;
|
322
|
-
|
323
|
-
address = g_socket_get_local_address(_SELF(self), &error);
|
324
|
-
if (address == NULL)
|
325
|
-
rbgio_raise_error(error);
|
326
|
-
|
327
|
-
return GOBJ2RVAL_UNREF(address);
|
328
|
-
}
|
329
|
-
|
330
|
-
static VALUE
|
331
|
-
socket_get_remote_address(VALUE self)
|
332
|
-
{
|
333
|
-
GError *error = NULL;
|
334
|
-
GSocketAddress *address;
|
335
|
-
|
336
|
-
address = g_socket_get_remote_address(_SELF(self), &error);
|
337
|
-
if (address == NULL)
|
338
|
-
rbgio_raise_error(error);
|
339
|
-
|
340
|
-
return GOBJ2RVAL_UNREF(address);
|
341
|
-
}
|
342
|
-
|
343
|
-
static VALUE
|
344
|
-
rg_speaks_ipv4_p(VALUE self)
|
345
|
-
{
|
346
|
-
return CBOOL2RVAL(g_socket_speaks_ipv4(_SELF(self)));
|
347
|
-
}
|
348
|
-
|
349
|
-
void
|
350
|
-
Init_gsocket(VALUE mGio)
|
351
|
-
{
|
352
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET, "Socket", mGio);
|
353
|
-
|
354
|
-
id_call = rb_intern("call");
|
355
|
-
|
356
|
-
G_DEF_CLASS(G_TYPE_SOCKET_FAMILY, "Family", RG_TARGET_NAMESPACE);
|
357
|
-
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SOCKET_FAMILY, "G_SOCKET_");
|
358
|
-
|
359
|
-
G_DEF_CLASS(G_TYPE_SOCKET_TYPE, "Type", RG_TARGET_NAMESPACE);
|
360
|
-
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SOCKET_TYPE, "G_SOCKET_");
|
361
|
-
|
362
|
-
G_DEF_CLASS(G_TYPE_SOCKET_PROTOCOL, "Protocol", RG_TARGET_NAMESPACE);
|
363
|
-
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SOCKET_PROTOCOL, "G_SOCKET_");
|
364
|
-
|
365
|
-
G_DEF_CLASS(G_TYPE_SOCKET_MSG_FLAGS, "MsgFlags", RG_TARGET_NAMESPACE);
|
366
|
-
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SOCKET_MSG_FLAGS, "G_SOCKET_");
|
367
|
-
|
368
|
-
RG_DEF_SMETHOD(new_from_fd, 1);
|
369
|
-
|
370
|
-
RG_DEF_METHOD(initialize, -1);
|
371
|
-
RG_DEF_METHOD(bind, 2);
|
372
|
-
RG_DEF_METHOD(listen, 0);
|
373
|
-
RG_DEF_METHOD(accept, -1);
|
374
|
-
RG_DEF_METHOD(connect, -1);
|
375
|
-
RG_DEF_METHOD(check_connect_result, 0);
|
376
|
-
RG_DEF_METHOD(receive, -1);
|
377
|
-
RG_DEF_METHOD(receive_from, -1);
|
378
|
-
RG_DEF_METHOD(send, -1);
|
379
|
-
RG_DEF_METHOD(send_to, -1);
|
380
|
-
RG_DEF_METHOD(close, 0);
|
381
|
-
RG_DEF_METHOD_P(closed, 0);
|
382
|
-
RG_DEF_METHOD(shutdown, 2);
|
383
|
-
RG_DEF_METHOD_P(connected, 0);
|
384
|
-
RG_DEF_METHOD(create_source, -1);
|
385
|
-
RG_DEF_METHOD(condition_check, 1);
|
386
|
-
RG_DEF_METHOD(condition_wait, -1);
|
387
|
-
G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "local_address", socket_get_local_address, 0);
|
388
|
-
G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "remote_address", socket_get_remote_address, 0);
|
389
|
-
RG_DEF_METHOD_P(speaks_ipv4, 0);
|
390
|
-
}
|
@@ -1,34 +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
|
-
/* TODO: new_from_native? */
|
25
|
-
|
26
|
-
/* TODO: to_native? */
|
27
|
-
|
28
|
-
/* TODO: get_native_size? */
|
29
|
-
|
30
|
-
void
|
31
|
-
Init_gsocketaddress(VALUE mGio)
|
32
|
-
{
|
33
|
-
(void)G_DEF_CLASS(G_TYPE_SOCKET_ADDRESS, "SocketAddress", mGio);
|
34
|
-
}
|
@@ -1,83 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
3
|
-
* Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General Public
|
16
|
-
* License along with this library; if not, write to the Free Software
|
17
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
-
* MA 02110-1301 USA
|
19
|
-
*/
|
20
|
-
|
21
|
-
#include "rbgio2private.h"
|
22
|
-
|
23
|
-
#define RG_TARGET_NAMESPACE cSocketAddressEnumerator
|
24
|
-
#define _SELF(value) RVAL2GSOCKETADDRESSENUMERATOR(value)
|
25
|
-
|
26
|
-
static VALUE
|
27
|
-
rg_next(int argc, VALUE *argv, VALUE self)
|
28
|
-
{
|
29
|
-
VALUE cancellable;
|
30
|
-
GError *error = NULL;
|
31
|
-
GSocketAddress *address;
|
32
|
-
|
33
|
-
rb_scan_args(argc, argv, "01", &cancellable);
|
34
|
-
address = g_socket_address_enumerator_next(_SELF(self),
|
35
|
-
RVAL2GCANCELLABLE(cancellable),
|
36
|
-
&error);
|
37
|
-
if (error != NULL)
|
38
|
-
rbgio_raise_error(error);
|
39
|
-
|
40
|
-
return GOBJ2RVAL(address);
|
41
|
-
}
|
42
|
-
|
43
|
-
static VALUE
|
44
|
-
rg_next_async(int argc, VALUE *argv, VALUE self)
|
45
|
-
{
|
46
|
-
VALUE rbcancellable, block;
|
47
|
-
GCancellable *cancellable;
|
48
|
-
|
49
|
-
rb_scan_args(argc, argv, "01&", &rbcancellable, &block);
|
50
|
-
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
51
|
-
SAVE_BLOCK(block);
|
52
|
-
g_socket_address_enumerator_next_async(_SELF(self),
|
53
|
-
cancellable,
|
54
|
-
rbgio_async_ready_callback,
|
55
|
-
(gpointer)block);
|
56
|
-
|
57
|
-
return self;
|
58
|
-
}
|
59
|
-
|
60
|
-
static VALUE
|
61
|
-
rg_next_finish(VALUE self, VALUE result)
|
62
|
-
{
|
63
|
-
GError *error = NULL;
|
64
|
-
GSocketAddress *address;
|
65
|
-
|
66
|
-
address = g_socket_address_enumerator_next_finish(_SELF(self),
|
67
|
-
RVAL2GASYNCRESULT(result),
|
68
|
-
&error);
|
69
|
-
if (address == NULL)
|
70
|
-
rbgio_raise_error(error);
|
71
|
-
|
72
|
-
return GOBJ2RVAL(address);
|
73
|
-
}
|
74
|
-
|
75
|
-
void
|
76
|
-
Init_gsocketaddressenumerator(VALUE mGio)
|
77
|
-
{
|
78
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOCKET_ADDRESS_ENUMERATOR, "SocketAddressEnumerator", mGio);
|
79
|
-
|
80
|
-
RG_DEF_METHOD(next, -1);
|
81
|
-
RG_DEF_METHOD(next_async, -1);
|
82
|
-
RG_DEF_METHOD(next_finish, 1);
|
83
|
-
}
|