Exemple #1
0
static VALUE
rg_lookup_service_finish(VALUE self, VALUE result)
{
        GError *error = NULL;
        GList *targets;

        targets = g_resolver_lookup_service_finish(_SELF(self), RVAL2GASYNCRESULT(result), &error);
        if (targets == NULL)
                rbgio_raise_error(error);

        return GLIST2ARY_UNREF_FREE(targets);
}
static VALUE
asyncinitable_init_finish(VALUE self, VALUE result)
{
        GError *error = NULL;

        if (!g_async_initable_init_finish(_SELF(self),
                                          RVAL2GASYNCRESULT(result),
                                          &error))
                rbgio_raise_error(error);

        return self;
}
Exemple #3
0
static VALUE
connection_finish_method(ConnectionFinishMethod method, VALUE self, VALUE result)
{
        GError *error = NULL;
        GSocketConnection *connection;

        connection = method(_SELF(self), RVAL2GASYNCRESULT(result), &error);
        if (connection == NULL)
                rbgio_raise_error(error);

        return GOBJ2RVAL_UNREF(connection);
}
static VALUE
fileenumerator_close(int argc, VALUE *argv, VALUE self)
{
        VALUE cancellable;
        GError *error = NULL;

        rb_scan_args(argc, argv, "01", &cancellable);
        if (!g_file_enumerator_close(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error))
                rbgio_raise_error(error);

        return self;
}
Exemple #5
0
static VALUE
unixfdlist_append(VALUE self, VALUE fd)
{
        GError *error = NULL;
        int index;

        index = g_unix_fd_list_append(_SELF(self), RVAL2FD(fd), &error);
        if (index == -1)
                rbgio_raise_error(error);

        return self;
}
Exemple #6
0
static VALUE
rg_send_fd(int argc, VALUE *argv, VALUE self)
{
        VALUE fd, cancellable;
        GError *error = NULL;

        rb_scan_args(argc, argv, "11", &fd, &cancellable);
        if (!g_unix_connection_send_fd(_SELF(self), RVAL2FD(fd),
                                       RVAL2GCANCELLABLE(cancellable), &error))
                rbgio_raise_error(error);

        return self;
}
static VALUE
unixfdlist_get(VALUE self, VALUE index)
{
        GError *error = NULL;
        gint fd;

        fd = g_unix_fd_list_get(_SELF(self), RVAL2GINT(index), &error);
        if (fd == -1)
                rbgio_raise_error(error);

        /* TODO: This fd must be closed properly.  How do we deal with that? */
        return FD2RVAL(fd);
}
Exemple #8
0
static VALUE
appinfo_launch_default_for_uri(int argc, VALUE *argv, VALUE self)
{
        VALUE uri, launch_context;
        GError *error;

        rb_scan_args(argc, argv, "11", &uri, &launch_context);
        if (!g_app_info_launch_default_for_uri(RVAL2CSTR(uri),
                                               RVAL2GAPPLAUNCHCONTEXT(launch_context),
                                               &error))
                rbgio_raise_error(error);

        return self;
}
Exemple #9
0
static VALUE
rg_lookup_by_address_finish(VALUE self, VALUE result)
{
        GError *error = NULL;
        gchar *hostname;

        hostname = g_resolver_lookup_by_address_finish(_SELF(self),
                                                       RVAL2GASYNCRESULT(result),
                                                       &error);
        if (hostname == NULL)
                rbgio_raise_error(error);

        return CSTR2RVAL_FREE(hostname);
}
Exemple #10
0
static VALUE
rg_query_info_finish(VALUE self, VALUE result)
{
        GError *error = NULL;
        GFileInfo *info;

        info = g_file_input_stream_query_info_finish(_SELF(self),
                                                     RVAL2GASYNCRESULT(result),
                                                     &error);
        if (info == NULL)
                rbgio_raise_error(error);

        return GOBJ2RVAL_UNREF(info);
}
static VALUE
rg_fill_finish(VALUE self, VALUE result)
{
        GError *error = NULL;
        gsize bytes_read;

        bytes_read = g_buffered_input_stream_fill_finish(_SELF(self),
                                                         RVAL2GASYNCRESULT(result),
                                                         &error);
        if (error != NULL)
                rbgio_raise_error(error);

        return GSSIZE2RVAL(bytes_read);
}
static VALUE
rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE host_and_port, VALUE default_port)
{
        GError *error = NULL;
        GSocketConnectable *connectable;

        connectable = g_network_address_parse(RVAL2CSTR(host_and_port),
                                              RVAL2GUINT16(default_port),
                                              &error);
        if (connectable == NULL)
                rbgio_raise_error(error);

        return GOBJ2RVAL_UNREF(connectable);
}
Exemple #13
0
static VALUE
rg_guess_content_type_finish(VALUE self, VALUE result)
{
        GError *error = NULL;
        gchar **content_types;

        content_types = g_mount_guess_content_type_finish(_SELF(self),
                                                          RVAL2GASYNCRESULT(result),
                                                          &error);
        if (content_types == NULL)
                rbgio_raise_error(error);

        return STRV2RVAL_FREE(content_types);
}
Exemple #14
0
static VALUE
rg_init(int argc, VALUE *argv, VALUE self)
{
        VALUE cancellable;
        GError *error = NULL;

        rb_scan_args(argc, argv, "01", &cancellable);
        if (!g_initable_init(_SELF(self),
                             RVAL2GCANCELLABLE(cancellable),
                             &error))
                rbgio_raise_error(error);

        return self;
}
Exemple #15
0
static VALUE
rg_lookup_by_name_finish(VALUE self, VALUE result)
{
        GError *error = NULL;
        GList *addresses;

        addresses = g_resolver_lookup_by_name_finish(_SELF(self),
                                                     RVAL2GASYNCRESULT(result),
                                                     &error);
        if (addresses == NULL)
                rbgio_raise_error(error);

        return GLIST2ARY_UNREF_FREE(addresses);
}
Exemple #16
0
static VALUE
rg_truncate(int argc, VALUE *argv, VALUE self)
{
        VALUE offset, cancellable;
        GError *error = NULL;

        rb_scan_args(argc, argv, "11", &offset, &cancellable);
        if (!g_seekable_truncate(_SELF(self),
                                 RVAL2GOFFSET(offset),
                                 RVAL2GCANCELLABLE(cancellable),
                                 &error))
                rbgio_raise_error(error);

        return self;
}
Exemple #17
0
static VALUE
rg_lookup_by_name(VALUE self, VALUE hostname, VALUE cancellable)
{
        GError *error = NULL;
        GList *addresses;

        addresses = g_resolver_lookup_by_name(_SELF(self),
                                              RVAL2CSTR(hostname),
                                              RVAL2GCANCELLABLE(cancellable),
                                              &error);
        if (addresses == NULL)
                rbgio_raise_error(error);

        return GLIST2ARY_UNREF_FREE(addresses);
}
Exemple #18
0
static VALUE
rg_receive_fd(int argc, VALUE *argv, VALUE self)
{
        VALUE cancellable;
        GError *error = NULL;
        gint fd;

        rb_scan_args(argc, argv, "01", &cancellable);
        fd = g_unix_connection_receive_fd(_SELF(self),
                                          RVAL2GCANCELLABLE(cancellable),
                                          &error);
        if (fd == -1)
                rbgio_raise_error(error);

        return FD2RVAL(fd);
}
static VALUE
rg_read_byte(int argc, VALUE *argv, VALUE self)
{
        VALUE cancellable;
        GError *error = NULL;
        int byte;

        rb_scan_args(argc, argv, "01", &cancellable);
        byte = g_buffered_input_stream_read_byte(_SELF(self),
                                                 RVAL2GCANCELLABLE(cancellable),
                                                 &error);
        if (error != NULL)
                rbgio_raise_error(error);

        return INT2FIX(byte);
}
static VALUE
rg_initialize(VALUE self, VALUE to, VALUE from)
{
        GError *error = NULL;
        GCharsetConverter *converter;

        converter = g_charset_converter_new(RVAL2CSTR(to),
                                            RVAL2CSTR(from),
                                            &error);
        if (converter == NULL)
                rbgio_raise_error(error);

        G_INITIALIZE(self, converter);

        return Qnil;
}
Exemple #21
0
static VALUE
rg_seek(int argc, VALUE *argv, VALUE self)
{
        VALUE offset, type, cancellable;
        GError *error = NULL;

        rb_scan_args(argc, argv, "12", &offset, &type, &cancellable);
        if (!g_seekable_seek(_SELF(self),
                             RVAL2GOFFSET(offset),
                             RVAL2GSEEKTYPEDEFAULT(type),
                             RVAL2GCANCELLABLE(cancellable),
                             &error))
                rbgio_raise_error(error);

        return self;
}
Exemple #22
0
static VALUE
fileenumerator_next_file(int argc, VALUE *argv, VALUE self)
{
        VALUE cancellable;
        GError *error = NULL;
        GFileInfo *info;

        rb_scan_args(argc, argv, "01", &cancellable);
        info = g_file_enumerator_next_file(_SELF(self),
                                           RVAL2GCANCELLABLE(cancellable),
                                           &error);
        if (error != NULL)
                rbgio_raise_error(error);

        return GOBJ2RVAL_UNREF(info);
}
Exemple #23
0
static VALUE
rg_lookup_by_address(int argc, VALUE *argv, VALUE self)
{
        VALUE address, cancellable;
        GError *error = NULL;
        gchar *hostname;

        rb_scan_args(argc, argv, "11", &address, &cancellable);
        hostname = g_resolver_lookup_by_address(_SELF(self),
                                                RVAL2GINETADDRESS(address),
                                                RVAL2GCANCELLABLE(cancellable),
                                                &error);
        if (hostname == NULL)
                rbgio_raise_error(error);

        return CSTR2RVAL_FREE(hostname);
}
Exemple #24
0
static VALUE
rg_guess_content_type_sync(int argc, VALUE *argv, VALUE self)
{
        VALUE force_rescan, cancellable;
        GError *error = NULL;
        gchar **content_types;

        rb_scan_args(argc, argv, "02", &force_rescan, &cancellable);
        content_types = g_mount_guess_content_type_sync(_SELF(self),
                                                        RVAL2CBOOL(force_rescan),
                                                        RVAL2GCANCELLABLE(cancellable),
                                                        &error);
        if (content_types == NULL)
                rbgio_raise_error(error);

        return STRV2RVAL_FREE(content_types);
}
Exemple #25
0
static VALUE
rg_connect(int argc, VALUE *argv, VALUE self)
{
        VALUE connectable, cancellable;
        GError *error = NULL;
        GSocketConnection *connection;

        rb_scan_args(argc, argv, "11", &connectable, &cancellable);
        connection = g_socket_client_connect(_SELF(self),
                                             RVAL2GSOCKETCONNECTABLE(connectable),
                                             RVAL2GCANCELLABLE(cancellable),
                                             &error);
        if (connection == NULL)
                rbgio_raise_error(error);

        return GOBJ2RVAL_UNREF(connection);
}
Exemple #26
0
static VALUE
appinfo_create_from_commandline(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
        VALUE commandline, application_name, flags;
        GError *error = NULL;
        GAppInfo *info;

        rb_scan_args(argc, argv, "12", &commandline, &application_name, &flags);
        info = g_app_info_create_from_commandline(RVAL2CSTR(commandline),
                                                  RVAL2CSTR_ACCEPT_NIL(application_name),
                                                  RVAL2GAPPINFOCREATEFLAGSDEFAULT(flags),
                                                  &error);
        if (info == NULL)
                rbgio_raise_error(error);

        return GOBJ2RVAL_UNREF(info);
}
Exemple #27
0
static VALUE
rg_skip(int argc, VALUE *argv, VALUE self)
{
        VALUE count, cancellable;
        GError *error = NULL;
        gssize bytes_skipped;

        rb_scan_args(argc, argv, "11", &count, &cancellable);
        bytes_skipped = g_input_stream_skip(_SELF(self),
                                            RVAL2GSIZE(count),
                                            RVAL2GCANCELLABLE(cancellable),
                                            &error);
        if (bytes_skipped == -1)
                rbgio_raise_error(error);

        return GSSIZE2RVAL(bytes_skipped);
}
Exemple #28
0
static VALUE
rg_query_info(int argc, VALUE *argv, VALUE self)
{
        VALUE attributes, cancellable;
        GError *error = NULL;
        GFileInfo *info;

        rb_scan_args(argc, argv, "02", &attributes, &cancellable);
        info = g_file_input_stream_query_info(_SELF(self),
                                              RVAL2ATTRIBUTESDEFAULT(attributes),
                                              RVAL2GCANCELLABLE(cancellable),
                                              &error);
        if (info == NULL)
                rbgio_raise_error(error);

        return GOBJ2RVAL_UNREF(info);
}
static VALUE
asyncinitable_initialize_finish(VALUE self, VALUE result)
{
        GError *error = NULL;
        GObject *object;
        VALUE rbobject;

        object = g_async_initable_new_finish(_SELF(self),
                                             RVAL2GASYNCRESULT(result),
                                             &error);
        if (object == NULL)
                rbgio_raise_error(error);

        rbobject = GOBJ2RVAL(object);
        g_object_unref(object);

        return rbobject;
}
static VALUE
rg_splice(int argc, VALUE *argv, VALUE self)
{
        VALUE source, flags, cancellable;
        GError *error = NULL;
        gssize bytes_spliced;

        rb_scan_args(argc, argv, "12", &source, &flags, &cancellable);
        bytes_spliced = g_output_stream_splice(_SELF(self),
                                               RVAL2GINPUTSTREAM(source),
                                               RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(flags),
                                               RVAL2GCANCELLABLE(cancellable),
                                               &error);
        if (bytes_spliced == -1)
                rbgio_raise_error(error);

        return GSSIZE2RVAL(bytes_spliced);
}