diff --git a/ext/tox/extconf.rb b/ext/tox/extconf.rb index c2a2cdd..2919b2b 100755 --- a/ext/tox/extconf.rb +++ b/ext/tox/extconf.rb @@ -16,5 +16,6 @@ have_library LIBTOXCORE, 'tox_kill' and have_library LIBTOXCORE, 'tox_version_is_compatible' and have_library LIBTOXCORE, 'tox_iteration_interval' and have_library LIBTOXCORE, 'tox_iterate' and +have_library LIBTOXCORE, 'tox_friend_add_norequest' and create_makefile "#{NAME}/#{NAME}" or exit(1) diff --git a/ext/tox/tox.c b/ext/tox/tox.c index 5cd9361..493622d 100644 --- a/ext/tox/tox.c +++ b/ext/tox/tox.c @@ -37,6 +37,7 @@ static VALUE cTox_id(VALUE self); static VALUE cTox_bootstrap(VALUE self, VALUE options); static VALUE cTox_kill(VALUE self); static VALUE cTox_loop(VALUE self); +static VALUE cTox_friend_add_norequest(VALUE self, VALUE key); typedef struct Tox_Options cTox_cOptions_; @@ -59,6 +60,7 @@ void Init_tox() rb_define_method(cTox, "bootstrap", cTox_bootstrap, 1); rb_define_method(cTox, "kill", cTox_kill, 0); rb_define_method(cTox, "loop", cTox_loop, 0); + rb_define_method(cTox, "friend_add_norequest", cTox_friend_add_norequest, 1); cTox_cOptions = rb_define_class_under(cTox, "Options", rb_cObject); rb_define_alloc_func(cTox_cOptions, cTox_cOptions_alloc); @@ -227,6 +229,17 @@ VALUE cTox_loop(const VALUE self) return self; } +VALUE cTox_friend_add_norequest(const VALUE self, const VALUE key) +{ + cTox_ *tox; + + Check_Type(key, T_STRING); + + Data_Get_Struct(self, cTox_, tox); + + return LONG2FIX(tox_friend_add_norequest(tox->tox, (uint8_t*)RSTRING_PTR(key), NULL)); +} + /****************************************************************************** * Tox::Options ******************************************************************************/