diff --git a/ext/tox/extconf.rb b/ext/tox/extconf.rb index 1a7d3b0..46cb461 100755 --- a/ext/tox/extconf.rb +++ b/ext/tox/extconf.rb @@ -32,5 +32,6 @@ have_library LIBTOXCORE, 'tox_join_groupchat' and have_library LIBTOXCORE, 'tox_group_message_send' and have_library LIBTOXCORE, 'tox_callback_group_invite' and have_library LIBTOXCORE, 'tox_callback_group_message' and +have_library LIBTOXCORE, 'tox_group_peernumber_is_ours' and create_makefile "#{NAME}/#{NAME}" or exit(1) diff --git a/ext/tox/tox.c b/ext/tox/tox.c index 235440c..24e0dca 100644 --- a/ext/tox/tox.c +++ b/ext/tox/tox.c @@ -42,6 +42,7 @@ static VALUE cTox_friend_add_norequest(VALUE self, VALUE key); static VALUE cTox_friend_send_message(VALUE self, VALUE friend_number, VALUE text); static VALUE cTox_join_groupchat(VALUE self, VALUE friend_number, VALUE data); static VALUE cTox_group_message_send(VALUE self, VALUE group_number, VALUE text); +static VALUE cTox_group_peernumber_is_ours(VALUE self, VALUE group_number, VALUE peer_number); static void on_friend_request( Tox *tox, @@ -102,6 +103,7 @@ void Init_tox() rb_define_method(cTox, "friend_send_message", cTox_friend_send_message, 2); rb_define_method(cTox, "join_groupchat", cTox_join_groupchat, 2); rb_define_method(cTox, "group_message_send", cTox_group_message_send, 2); + rb_define_method(cTox, "group_peernumber_is_ours", cTox_group_peernumber_is_ours, 2); cTox_cOptions = rb_define_class_under(cTox, "Options", rb_cObject); rb_define_alloc_func(cTox_cOptions, cTox_cOptions_alloc); @@ -347,6 +349,29 @@ VALUE cTox_group_message_send(const VALUE self, const VALUE group_number, const )); } +VALUE cTox_group_peernumber_is_ours( + const VALUE self, + const VALUE group_number, + const VALUE peer_number) +{ + cTox_ *tox; + + // Don't know yet how to check for integers + // Check_Type(group_number, T_INTEGER); + // Check_Type(peer_number, T_INTEGER); + + Data_Get_Struct(self, cTox_, tox); + + if (tox_group_peernumber_is_ours( + tox->tox, + NUM2INT(group_number), + NUM2INT(peer_number)) + ) + return Qtrue; + else + return Qfalse; +} + void on_friend_request( Tox *const tox, const uint8_t *const key,