forked from TokTok/go-toxcore-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroup_intern.go
32 lines (26 loc) · 975 Bytes
/
group_intern.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package tox
/*
#include <stdint.h>
#include <tox/tox.h>
extern uint8_t *tox_conference_get_pubkey(Tox *tox, uint32_t conference_number, void *pkbuf);
extern uint8_t *tox_conference_get_identifier(Tox *tox, uint32_t conference_number, void *idbuf);
*/
import "C"
import (
"encoding/hex"
"strings"
"unsafe"
)
func (this *Tox) ConferenceGetPubkey(groupNumber uint32) (string, error) {
pkbuf := [C.TOX_PUBLIC_KEY_SIZE]byte{}
C.tox_conference_get_pubkey(this.toxcore, C.uint32_t(groupNumber), (unsafe.Pointer)(&pkbuf[0]))
pubkey := strings.ToUpper(hex.EncodeToString(pkbuf[:]))
return pubkey, nil
}
func (this *Tox) ConferenceGetIdentifier(groupNumber uint32) (string, error) {
idbuf := [1 + C.TOX_PUBLIC_KEY_SIZE]byte{}
C.tox_conference_get_identifier(this.toxcore, C.uint32_t(groupNumber), (unsafe.Pointer)(&idbuf[0]))
identifier := strings.ToUpper(hex.EncodeToString(idbuf[:]))
identifier = identifier[2:] // 1B(type)+32B(identifier)
return identifier, nil
}