Add binding for tox_get_friendlist.
authorDavid Thompson <dthompson2@worcester.edu>
Sun, 13 Jul 2014 01:07:08 +0000 (21:07 -0400)
committerDavid Thompson <dthompson2@worcester.edu>
Sun, 13 Jul 2014 01:07:08 +0000 (21:07 -0400)
* tox.scm (tox-friend-list): New procedure.
* tox/bindings.scm (tox-get-friendlist): New procedure.

tox.scm
tox/bindings.scm

diff --git a/tox.scm b/tox.scm
index 8f4e751..2ab9055 100644 (file)
--- a/tox.scm
+++ b/tox.scm
@@ -51,7 +51,8 @@
             tox-friend-last-online
             set-tox-friend-typing tox-friend-typing?
             set-tox-send-receipts
-            tox-friend-count tox-online-friend-count))
+            tox-friend-count tox-online-friend-count
+            tox-friend-list))
 
 (define-enumeration tox-friend-add-error
   (too-long -1)
@@ -385,3 +386,12 @@ the messenger TOX.  SEND-RECEIPTS? should be either #t of #f."
   "Return the number of online friends in the friend list for the messenger
 TOX."
   %tox-get-num-online-friends)
+
+(define (tox-friend-list tox)
+  "Return a list of all friend numbers for the messenger TOX."
+  (let* ((length (tox-friend-count tox))
+         (bv (make-s32vector length)))
+    (%tox-get-friendlist (unwrap-tox tox)
+                         (bytevector->pointer bv)
+                         length)
+    (bytevector->sint-list bv (native-endianness) (sizeof int32))))
index 4d1d26e..ddbdad9 100644 (file)
 
 (define-tox tox-get-num-online-friends
   uint32 "tox_get_num_online_friends" '(*))
+
+(define-tox tox-get-friendlist
+  uint32 "tox_get_friendlist" (list '* '* uint32))