gio2 0.90.3
Sign up to get free protection for your applications and to get access to all the features.
- 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,273 @@
|
|
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_SOCKET_CLIENT(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
socketclient_initialize(VALUE self)
|
27
|
+
{
|
28
|
+
G_INITIALIZE(self, g_socket_client_new());
|
29
|
+
|
30
|
+
return Qnil;
|
31
|
+
}
|
32
|
+
|
33
|
+
static VALUE
|
34
|
+
socketclient_connect(int argc, VALUE *argv, VALUE self)
|
35
|
+
{
|
36
|
+
VALUE connectable, cancellable;
|
37
|
+
GError *error = NULL;
|
38
|
+
GSocketConnection *connection;
|
39
|
+
|
40
|
+
rb_scan_args(argc, argv, "11", &connectable, &cancellable);
|
41
|
+
connection = g_socket_client_connect(_SELF(self),
|
42
|
+
RVAL2GSOCKETCONNECTABLE(connectable),
|
43
|
+
RVAL2GCANCELLABLE(cancellable),
|
44
|
+
&error);
|
45
|
+
if (connection == NULL)
|
46
|
+
rbgio_raise_error(error);
|
47
|
+
|
48
|
+
return GOBJ2RVAL_UNREF(connection);
|
49
|
+
}
|
50
|
+
|
51
|
+
static VALUE
|
52
|
+
socketclient_connect_async(int argc, VALUE *argv, VALUE self)
|
53
|
+
{
|
54
|
+
VALUE rbconnectable, rbcancellable, block;
|
55
|
+
GCancellable *cancellable;
|
56
|
+
GSocketConnectable *connectable;
|
57
|
+
|
58
|
+
rb_scan_args(argc, argv, "11&", &rbconnectable, &rbcancellable, &block);
|
59
|
+
connectable = RVAL2GSOCKETCONNECTABLE(rbconnectable);
|
60
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
61
|
+
SAVE_BLOCK(block);
|
62
|
+
g_socket_client_connect_async(_SELF(self),
|
63
|
+
connectable,
|
64
|
+
cancellable,
|
65
|
+
rbgio_async_ready_callback,
|
66
|
+
(gpointer)block);
|
67
|
+
|
68
|
+
return self;
|
69
|
+
}
|
70
|
+
|
71
|
+
typedef GSocketConnection *(*ConnectionFinishMethod)(GSocketClient *,
|
72
|
+
GAsyncResult *,
|
73
|
+
GError **);
|
74
|
+
|
75
|
+
static VALUE
|
76
|
+
connection_finish_method(ConnectionFinishMethod method, VALUE self, VALUE result)
|
77
|
+
{
|
78
|
+
GError *error = NULL;
|
79
|
+
GSocketConnection *connection;
|
80
|
+
|
81
|
+
connection = method(_SELF(self), RVAL2GASYNCRESULT(result), &error);
|
82
|
+
if (connection == NULL)
|
83
|
+
rbgio_raise_error(error);
|
84
|
+
|
85
|
+
return GOBJ2RVAL_UNREF(connection);
|
86
|
+
}
|
87
|
+
|
88
|
+
static VALUE
|
89
|
+
socketclient_connect_finish(VALUE self, VALUE result)
|
90
|
+
{
|
91
|
+
return connection_finish_method(g_socket_client_connect_finish, self, result);
|
92
|
+
}
|
93
|
+
|
94
|
+
static VALUE
|
95
|
+
socketclient_connect_to_host(int argc, VALUE *argv, VALUE self)
|
96
|
+
{
|
97
|
+
VALUE host_and_port, default_port, cancellable;
|
98
|
+
GError *error = NULL;
|
99
|
+
GSocketConnection *connection;
|
100
|
+
|
101
|
+
rb_scan_args(argc, argv, "21", &host_and_port, &default_port, &cancellable);
|
102
|
+
connection = g_socket_client_connect_to_host(_SELF(self),
|
103
|
+
RVAL2CSTR(host_and_port),
|
104
|
+
RVAL2GUINT16(default_port),
|
105
|
+
RVAL2GCANCELLABLE(cancellable),
|
106
|
+
&error);
|
107
|
+
if (connection == NULL)
|
108
|
+
rbgio_raise_error(error);
|
109
|
+
|
110
|
+
return self;
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
socketclient_connect_to_host_async(int argc, VALUE *argv, VALUE self)
|
115
|
+
{
|
116
|
+
VALUE rbhost_and_port, rbdefault_port, rbcancellable, block;
|
117
|
+
GCancellable *cancellable;
|
118
|
+
const gchar *host_and_port;
|
119
|
+
guint16 default_port;
|
120
|
+
|
121
|
+
rb_scan_args(argc, argv, "21&", &rbhost_and_port, &rbdefault_port, &rbcancellable, &block);
|
122
|
+
host_and_port = RVAL2CSTR(rbhost_and_port);
|
123
|
+
default_port = RVAL2GUINT16(rbdefault_port);
|
124
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
125
|
+
SAVE_BLOCK(block);
|
126
|
+
g_socket_client_connect_to_host_async(_SELF(self),
|
127
|
+
host_and_port,
|
128
|
+
default_port,
|
129
|
+
cancellable,
|
130
|
+
rbgio_async_ready_callback,
|
131
|
+
(gpointer)block);
|
132
|
+
|
133
|
+
return self;
|
134
|
+
}
|
135
|
+
|
136
|
+
static VALUE
|
137
|
+
socketclient_connect_to_host_finish(VALUE self, VALUE result)
|
138
|
+
{
|
139
|
+
return connection_finish_method(g_socket_client_connect_to_host_finish, self, result);
|
140
|
+
}
|
141
|
+
|
142
|
+
static VALUE
|
143
|
+
socketclient_connect_to_service(int argc, VALUE *argv, VALUE self)
|
144
|
+
{
|
145
|
+
VALUE domain, service, cancellable;
|
146
|
+
GError *error = NULL;
|
147
|
+
GSocketConnection *connection;
|
148
|
+
|
149
|
+
rb_scan_args(argc, argv, "21", &domain, &service, &cancellable);
|
150
|
+
connection = g_socket_client_connect_to_service(_SELF(self),
|
151
|
+
RVAL2CSTR(domain),
|
152
|
+
RVAL2CSTR(service),
|
153
|
+
RVAL2GCANCELLABLE(cancellable),
|
154
|
+
&error);
|
155
|
+
if (connection == NULL)
|
156
|
+
rbgio_raise_error(error);
|
157
|
+
|
158
|
+
return self;
|
159
|
+
}
|
160
|
+
|
161
|
+
static VALUE
|
162
|
+
socketclient_connect_to_service_async(int argc, VALUE *argv, VALUE self)
|
163
|
+
{
|
164
|
+
VALUE rbdomain, rbservice, rbcancellable, block;
|
165
|
+
GCancellable *cancellable;
|
166
|
+
const gchar *domain;
|
167
|
+
const gchar *service;
|
168
|
+
|
169
|
+
rb_scan_args(argc, argv, "21&", &domain, &service, &rbcancellable, &block);
|
170
|
+
domain = RVAL2CSTR(rbdomain);
|
171
|
+
service = RVAL2CSTR(rbservice);
|
172
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
173
|
+
SAVE_BLOCK(block);
|
174
|
+
g_socket_client_connect_to_service_async(_SELF(self),
|
175
|
+
domain,
|
176
|
+
service,
|
177
|
+
cancellable,
|
178
|
+
rbgio_async_ready_callback,
|
179
|
+
(gpointer)block);
|
180
|
+
|
181
|
+
return self;
|
182
|
+
}
|
183
|
+
|
184
|
+
static VALUE
|
185
|
+
socketclient_connect_to_service_finish(VALUE self, VALUE result)
|
186
|
+
{
|
187
|
+
return connection_finish_method(g_socket_client_connect_to_service_finish, self, result);
|
188
|
+
}
|
189
|
+
|
190
|
+
static VALUE
|
191
|
+
socketclient_set_family(VALUE self, VALUE family)
|
192
|
+
{
|
193
|
+
g_socket_client_set_family(_SELF(self), RVAL2GSOCKETFAMILY(family));
|
194
|
+
|
195
|
+
return self;
|
196
|
+
}
|
197
|
+
|
198
|
+
static VALUE
|
199
|
+
socketclient_set_local_address(VALUE self, VALUE address)
|
200
|
+
{
|
201
|
+
g_socket_client_set_local_address(_SELF(self), RVAL2GSOCKETADDRESS(address));
|
202
|
+
|
203
|
+
return self;
|
204
|
+
}
|
205
|
+
|
206
|
+
static VALUE
|
207
|
+
socketclient_set_protocol(VALUE self, VALUE protocol)
|
208
|
+
{
|
209
|
+
g_socket_client_set_protocol(_SELF(self), RVAL2GSOCKETPROTOCOL(protocol));
|
210
|
+
|
211
|
+
return self;
|
212
|
+
}
|
213
|
+
|
214
|
+
static VALUE
|
215
|
+
socketclient_set_socket_type(VALUE self, VALUE type)
|
216
|
+
{
|
217
|
+
g_socket_client_set_socket_type(_SELF(self), RVAL2GSOCKETTYPE(type));
|
218
|
+
|
219
|
+
return self;
|
220
|
+
}
|
221
|
+
|
222
|
+
static VALUE
|
223
|
+
socketclient_get_family(VALUE self)
|
224
|
+
{
|
225
|
+
return GSOCKETFAMILY2RVAL(g_socket_client_get_family(_SELF(self)));
|
226
|
+
}
|
227
|
+
|
228
|
+
static VALUE
|
229
|
+
socketclient_get_local_address(VALUE self)
|
230
|
+
{
|
231
|
+
return GOBJ2RVAL(g_socket_client_get_local_address(_SELF(self)));
|
232
|
+
}
|
233
|
+
|
234
|
+
static VALUE
|
235
|
+
socketclient_get_protocol(VALUE self)
|
236
|
+
{
|
237
|
+
return GSOCKETPROTOCOL2RVAL(g_socket_client_get_protocol(_SELF(self)));
|
238
|
+
}
|
239
|
+
|
240
|
+
static VALUE
|
241
|
+
socketclient_get_socket_type(VALUE self)
|
242
|
+
{
|
243
|
+
return GSOCKETTYPE2RVAL(g_socket_client_get_socket_type(_SELF(self)));
|
244
|
+
}
|
245
|
+
|
246
|
+
void
|
247
|
+
Init_gsocketclient(VALUE glib)
|
248
|
+
{
|
249
|
+
VALUE socketclient = G_DEF_CLASS(G_TYPE_SOCKET_CLIENT, "SocketClient", glib);
|
250
|
+
|
251
|
+
rb_define_method(socketclient, "initialize", socketclient_initialize, 0);
|
252
|
+
rb_define_method(socketclient, "connect", socketclient_connect, -1);
|
253
|
+
rb_define_method(socketclient, "connect_async", socketclient_connect_async, -1);
|
254
|
+
rb_define_method(socketclient, "connect_finish", socketclient_connect_finish, 1);
|
255
|
+
rb_define_method(socketclient, "connect_to_host", socketclient_connect_to_host, -1);
|
256
|
+
rb_define_method(socketclient, "connect_to_host_async", socketclient_connect_to_host_async, -1);
|
257
|
+
rb_define_method(socketclient, "connect_to_host_finish", socketclient_connect_to_host_finish, 1);
|
258
|
+
rb_define_method(socketclient, "connect_to_service", socketclient_connect_to_service, -1);
|
259
|
+
rb_define_method(socketclient, "connect_to_service_async", socketclient_connect_to_service_async, -1);
|
260
|
+
rb_define_method(socketclient, "connect_to_service_finish", socketclient_connect_to_service_finish, 1);
|
261
|
+
rb_define_method(socketclient, "set_family", socketclient_set_family, 1);
|
262
|
+
G_DEF_SETTER(socketclient, "family");
|
263
|
+
rb_define_method(socketclient, "set_local_address", socketclient_set_local_address, 1);
|
264
|
+
G_DEF_SETTER(socketclient, "local_address");
|
265
|
+
rb_define_method(socketclient, "set_protocol", socketclient_set_protocol, 1);
|
266
|
+
G_DEF_SETTER(socketclient, "protocol");
|
267
|
+
rb_define_method(socketclient, "set_socket_type", socketclient_set_socket_type, 1);
|
268
|
+
G_DEF_SETTER(socketclient, "socket_type");
|
269
|
+
rb_define_method(socketclient, "family", socketclient_get_family, 0);
|
270
|
+
rb_define_method(socketclient, "local_address", socketclient_get_local_address, 0);
|
271
|
+
rb_define_method(socketclient, "protocol", socketclient_get_protocol, 0);
|
272
|
+
rb_define_method(socketclient, "socket_type", socketclient_get_socket_type, 0);
|
273
|
+
}
|
@@ -0,0 +1,97 @@
|
|
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) RVAL2GSOCKETCONNECTABLE(value)
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
socketconnectable_enumerate(VALUE self)
|
27
|
+
{
|
28
|
+
return GOBJ2RVAL(g_socket_connectable_enumerate(_SELF(self)));
|
29
|
+
}
|
30
|
+
|
31
|
+
#undef _SELF
|
32
|
+
#define _SELF(value) G_SOCKET_ADDRESS_ENUMERATOR(RVAL2GOBJ(value))
|
33
|
+
|
34
|
+
static VALUE
|
35
|
+
socketaddressenumerator_next(int argc, VALUE *argv, VALUE self)
|
36
|
+
{
|
37
|
+
VALUE cancellable;
|
38
|
+
GError *error = NULL;
|
39
|
+
GSocketAddress *address;
|
40
|
+
|
41
|
+
rb_scan_args(argc, argv, "01", &cancellable);
|
42
|
+
address = g_socket_address_enumerator_next(_SELF(self),
|
43
|
+
RVAL2GCANCELLABLE(cancellable),
|
44
|
+
&error);
|
45
|
+
if (error != NULL)
|
46
|
+
rbgio_raise_error(error);
|
47
|
+
|
48
|
+
return GOBJ2RVAL(address);
|
49
|
+
}
|
50
|
+
|
51
|
+
static VALUE
|
52
|
+
socketaddressenumerator_next_async(int argc, VALUE *argv, VALUE self)
|
53
|
+
{
|
54
|
+
VALUE rbcancellable, block;
|
55
|
+
GCancellable *cancellable;
|
56
|
+
|
57
|
+
rb_scan_args(argc, argv, "01&", &rbcancellable, &block);
|
58
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
59
|
+
SAVE_BLOCK(block);
|
60
|
+
g_socket_address_enumerator_next_async(_SELF(self),
|
61
|
+
cancellable,
|
62
|
+
rbgio_async_ready_callback,
|
63
|
+
(gpointer)block);
|
64
|
+
|
65
|
+
return self;
|
66
|
+
}
|
67
|
+
|
68
|
+
static VALUE
|
69
|
+
socketaddressenumerator_next_finish(VALUE self, VALUE result)
|
70
|
+
{
|
71
|
+
GError *error = NULL;
|
72
|
+
GSocketAddress *address;
|
73
|
+
|
74
|
+
address = g_socket_address_enumerator_next_finish(_SELF(self),
|
75
|
+
RVAL2GASYNCRESULT(result),
|
76
|
+
&error);
|
77
|
+
if (address == NULL)
|
78
|
+
rbgio_raise_error(error);
|
79
|
+
|
80
|
+
return GOBJ2RVAL(address);
|
81
|
+
}
|
82
|
+
|
83
|
+
void
|
84
|
+
Init_gsocketconnectable(VALUE glib)
|
85
|
+
{
|
86
|
+
VALUE socketconnectable, socketaddressenumerator;
|
87
|
+
|
88
|
+
socketconnectable = G_DEF_INTERFACE(G_TYPE_SOCKET_CONNECTABLE, "SocketConnectable", glib);
|
89
|
+
|
90
|
+
rb_define_method(socketconnectable, "enumerate", socketconnectable_enumerate, 0);
|
91
|
+
|
92
|
+
socketaddressenumerator = G_DEF_CLASS(G_TYPE_SOCKET_ADDRESS_ENUMERATOR, "SocketAddressEnumerator", glib);
|
93
|
+
|
94
|
+
rb_define_method(socketaddressenumerator, "next", socketaddressenumerator_next, -1);
|
95
|
+
rb_define_method(socketaddressenumerator, "next_async", socketaddressenumerator_next_async, -1);
|
96
|
+
rb_define_method(socketaddressenumerator, "next_finish", socketaddressenumerator_next_finish, 1);
|
97
|
+
}
|
@@ -0,0 +1,82 @@
|
|
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_SOCKET_CONNECTION(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
socketconnection_get_local_address(VALUE self)
|
27
|
+
{
|
28
|
+
GError *error = NULL;
|
29
|
+
GSocketAddress *address;
|
30
|
+
|
31
|
+
address = g_socket_connection_get_local_address(_SELF(self), &error);
|
32
|
+
if (address == NULL)
|
33
|
+
rbgio_raise_error(error);
|
34
|
+
|
35
|
+
return GOBJ2RVAL_UNREF(address);
|
36
|
+
}
|
37
|
+
|
38
|
+
static VALUE
|
39
|
+
socketconnection_get_remote_address(VALUE self)
|
40
|
+
{
|
41
|
+
GError *error = NULL;
|
42
|
+
GSocketAddress *address;
|
43
|
+
|
44
|
+
address = g_socket_connection_get_remote_address(_SELF(self), &error);
|
45
|
+
if (address == NULL)
|
46
|
+
rbgio_raise_error(error);
|
47
|
+
|
48
|
+
return GOBJ2RVAL_UNREF(address);
|
49
|
+
}
|
50
|
+
|
51
|
+
static VALUE
|
52
|
+
socketconnection_get_socket(VALUE self)
|
53
|
+
{
|
54
|
+
return GOBJ2RVAL(g_socket_connection_get_socket(_SELF(self)));
|
55
|
+
}
|
56
|
+
|
57
|
+
static VALUE
|
58
|
+
socketconnectionfactory_create_connection(G_GNUC_UNUSED VALUE self, VALUE socket)
|
59
|
+
{
|
60
|
+
return GOBJ2RVAL_UNREF(g_socket_connection_factory_create_connection(RVAL2GSOCKET(socket)));
|
61
|
+
}
|
62
|
+
|
63
|
+
/* TODO: lookup_type */
|
64
|
+
|
65
|
+
/* TODO: register_type */
|
66
|
+
|
67
|
+
void
|
68
|
+
Init_gsocketconnection(VALUE glib)
|
69
|
+
{
|
70
|
+
VALUE socketconnection, socketconnectionfactory;
|
71
|
+
|
72
|
+
socketconnection = G_DEF_CLASS(G_TYPE_SOCKET_CONNECTION, "SocketConnection", glib);
|
73
|
+
|
74
|
+
rb_define_method(socketconnection, "local_address", socketconnection_get_local_address, 0);
|
75
|
+
rb_define_method(socketconnection, "remote_address", socketconnection_get_remote_address, 0);
|
76
|
+
rb_define_method(socketconnection, "socket", socketconnection_get_socket, 0);
|
77
|
+
|
78
|
+
/* Perhaps just move this to SocketConnection? */
|
79
|
+
socketconnectionfactory = rb_define_module_under(glib, "SocketConnectionFactory");
|
80
|
+
|
81
|
+
rb_define_module_function(socketconnectionfactory, "create_connection", socketconnectionfactory_create_connection, 1);
|
82
|
+
}
|