Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt new conference peer nick/list_changed callbacks. #9

Merged
merged 1 commit into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: go
compiler: clang
sudo: required

addons:
Expand All @@ -12,21 +11,22 @@ addons:
- libsodium-dev
- libvpx-dev

go:
#- 1.4.x
#- 1.5.x
#- 1.6.x
#- 1.7.x
#- 1.8.x
#- 1.9.x
- master
matrix:
include:
- go: 1.7.x
if: type IN (push, api, cron)
- go: 1.8.x
if: type IN (push, api, cron)
- go: 1.9.x
if: type IN (push, api, cron)
- go: master

before_install:
- go get github.com/mattn/goveralls

install:
# Add libclang's lib directory to search path for Go.
- export CGO_LDFLAGS="-L`llvm-config --libdir`"
- export CGO_LDFLAGS="-L`llvm-config-3.4 --libdir`"
# Install toxcore.
- git clone https://github.com/TokTok/c-toxcore
- cd c-toxcore
Expand All @@ -37,14 +37,16 @@ install:
- sudo ldconfig > /dev/null
# Install Go packages.
- go get github.com/bitly/go-simplejson
- go get github.com/go-clang/v3.8/clang
- go get github.com/go-clang/v3.4/clang
- go get github.com/kitech/godsts/maps/hashbidimap
- go get github.com/kitech/godsts/maps/hashmap
- go get github.com/kitech/godsts/sets/hashset
- go get github.com/masatana/go-textdistance
- go get github.com/sasha-s/go-deadlock
- go get github.com/streamrail/concurrent-map
- go get github.com/sysr-q/gopp/gopp
- go get github.com/xrash/smetrics

script:
- go run tools/generrmsg.go > const_auto.go && git diff --exit-code
- $GOPATH/bin/goveralls -service=travis-ci
7 changes: 0 additions & 7 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ const (
CONFERENCE_TYPE_AV = uint8(C.TOX_CONFERENCE_TYPE_AV)
)

type ChatChangeType int

const (
CONFERENCE_STATE_CHANGE_LIST_CHANGED = int(C.TOX_CONFERENCE_STATE_CHANGE_LIST_CHANGED)
CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE = int(C.TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE)
)

type CallControlType int

const (
Expand Down
51 changes: 38 additions & 13 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ void callbackConferenceMessageWrapperForC(Tox *, uint32_t, uint32_t, TOX_MESSAGE
// void callbackConferenceActionWrapperForC(Tox*, uint32_t, uint32_t, uint8_t*, size_t, void*);

void callbackConferenceTitleWrapperForC(Tox*, uint32_t, uint32_t, uint8_t*, size_t, void*);
void callbackConferenceNameListChangeWrapperForC(Tox*, uint32_t, uint32_t, TOX_CONFERENCE_STATE_CHANGE, void*);
void callbackConferencePeerNameWrapperForC(Tox*, uint32_t, uint32_t, uint8_t*, size_t, void*);
void callbackConferencePeerListChangedWrapperForC(Tox*, uint32_t, void*);

// fix nouse compile warning
static inline __attribute__((__unused__)) void fixnousetoxgroup() {
Expand All @@ -33,7 +34,8 @@ type cb_conference_message_ftype func(this *Tox, groupNumber uint32, peerNumber

type cb_conference_action_ftype func(this *Tox, groupNumber uint32, peerNumber uint32, action string, userData interface{})
type cb_conference_title_ftype func(this *Tox, groupNumber uint32, peerNumber uint32, title string, userData interface{})
type cb_conference_namelist_change_ftype func(this *Tox, groupNumber uint32, peerNumber uint32, change uint8, userData interface{})
type cb_conference_peer_name_ftype func(this *Tox, groupNumber uint32, peerNumber uint32, name string, userData interface{})
type cb_conference_peer_list_changed_ftype func(this *Tox, groupNumber uint32, userData interface{})

// tox_callback_conference_***

Expand Down Expand Up @@ -135,26 +137,49 @@ func (this *Tox) CallbackConferenceTitleAdd(cbfn cb_conference_title_ftype, user
C.tox_callback_conference_title(this.toxcore, (*C.tox_conference_title_cb)(C.callbackConferenceTitleWrapperForC))
}

//export callbackConferenceNameListChangeWrapperForC
func callbackConferenceNameListChangeWrapperForC(m *C.Tox, a0 C.uint32_t, a1 C.uint32_t, a2 C.TOX_CONFERENCE_STATE_CHANGE, a3 unsafe.Pointer) {
//export callbackConferencePeerNameWrapperForC
func callbackConferencePeerNameWrapperForC(m *C.Tox, a0 C.uint32_t, a1 C.uint32_t, a2 *C.uint8_t, a3 C.size_t, a4 unsafe.Pointer) {
var this = cbUserDatas.get(m)
for cbfni, ud := range this.cb_conference_namelist_changes {
cbfn := *(*cb_conference_namelist_change_ftype)(cbfni)
this.putcbevts(func() { cbfn(this, uint32(a0), uint32(a1), uint8(a2), ud) })
for cbfni, ud := range this.cb_conference_peer_names {
cbfn := *(*cb_conference_peer_name_ftype)(cbfni)
peer_name := C.GoStringN((*C.char)((unsafe.Pointer)(a2)), C.int(a3))
this.putcbevts(func() { cbfn(this, uint32(a0), uint32(a1), peer_name, ud) })
}
}

func (this *Tox) CallbackConferenceNameListChange(cbfn cb_conference_namelist_change_ftype, userData interface{}) {
this.CallbackConferenceNameListChangeAdd(cbfn, userData)
func (this *Tox) CallbackConferencePeerName(cbfn cb_conference_peer_name_ftype, userData interface{}) {
this.CallbackConferencePeerNameAdd(cbfn, userData)
}
func (this *Tox) CallbackConferenceNameListChangeAdd(cbfn cb_conference_namelist_change_ftype, userData interface{}) {
func (this *Tox) CallbackConferencePeerNameAdd(cbfn cb_conference_peer_name_ftype, userData interface{}) {
cbfnp := (unsafe.Pointer)(&cbfn)
if _, ok := this.cb_conference_namelist_changes[cbfnp]; ok {
if _, ok := this.cb_conference_peer_names[cbfnp]; ok {
return
}
this.cb_conference_namelist_changes[cbfnp] = userData
this.cb_conference_peer_names[cbfnp] = userData

C.tox_callback_conference_namelist_change(this.toxcore, (*C.tox_conference_namelist_change_cb)(C.callbackConferenceNameListChangeWrapperForC))
C.tox_callback_conference_peer_name(this.toxcore, (*C.tox_conference_peer_name_cb)(C.callbackConferencePeerNameWrapperForC))
}

//export callbackConferencePeerListChangedWrapperForC
func callbackConferencePeerListChangedWrapperForC(m *C.Tox, a0 C.uint32_t, a1 unsafe.Pointer) {
var this = cbUserDatas.get(m)
for cbfni, ud := range this.cb_conference_peer_list_changeds {
cbfn := *(*cb_conference_peer_list_changed_ftype)(cbfni)
this.putcbevts(func() { cbfn(this, uint32(a0), ud) })
}
}

func (this *Tox) CallbackConferencePeerListChanged(cbfn cb_conference_peer_list_changed_ftype, userData interface{}) {
this.CallbackConferencePeerListChangedAdd(cbfn, userData)
}
func (this *Tox) CallbackConferencePeerListChangedAdd(cbfn cb_conference_peer_list_changed_ftype, userData interface{}) {
cbfnp := (unsafe.Pointer)(&cbfn)
if _, ok := this.cb_conference_peer_list_changeds[cbfnp]; ok {
return
}
this.cb_conference_peer_list_changeds[cbfnp] = userData

C.tox_callback_conference_peer_list_changed(this.toxcore, (*C.tox_conference_peer_list_changed_cb)(C.callbackConferencePeerListChangedWrapperForC))
}

// methods tox_conference_*
Expand Down
10 changes: 0 additions & 10 deletions group_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ func (this *Tox) CallbackGroupTitleAdd(cbfn cb_group_title_ftype, userData inter
this.CallbackConferenceTitleAdd(cbfn_, userData)
}

func (this *Tox) CallbackGroupNameListChange(cbfn cb_group_namelist_change_ftype, userData interface{}) {
this.CallbackGroupNameListChangeAdd(cbfn, userData)
}
func (this *Tox) CallbackGroupNameListChangeAdd(cbfn cb_group_namelist_change_ftype, userData interface{}) {
cbfn_ := func(this *Tox, groupNumber uint32, peerNumber uint32, change uint8, userData interface{}) {
cbfn(this, int(groupNumber), int(peerNumber), change, userData)
}
this.CallbackConferenceNameListChangeAdd(cbfn_, userData)
}

// methods
func (this *Tox) AddGroupChat() (int, error) {
gn, err := this.ConferenceNew()
Expand Down
7 changes: 3 additions & 4 deletions tools/generrmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"strings"

"github.com/go-clang/v3.8/clang"
"github.com/go-clang/v3.4/clang"
)

func main() {
Expand All @@ -22,9 +22,8 @@ func main() {
_ = tuArgs
cmdArgs := []string{
"-std=c99",
"-I/usr/include/",
"-I/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include"}
tu := idx.ParseTranslationUnit("/usr/include/tox/tox.h", cmdArgs, nil, 0)
"-I/usr/lib/clang/3.4/include"}
tu := idx.ParseTranslationUnit("/usr/local/include/tox/tox.h", cmdArgs, nil, 0)
defer tu.Dispose()

for _, d := range tu.Diagnostics() {
Expand Down
14 changes: 8 additions & 6 deletions tox.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ type Tox struct {
cb_friend_lossless_packets map[unsafe.Pointer]interface{}
cb_self_connection_statuss map[unsafe.Pointer]interface{}

cb_conference_invites map[unsafe.Pointer]interface{}
cb_conference_messages map[unsafe.Pointer]interface{}
cb_conference_actions map[unsafe.Pointer]interface{}
cb_conference_titles map[unsafe.Pointer]interface{}
cb_conference_namelist_changes map[unsafe.Pointer]interface{}
cb_conference_invites map[unsafe.Pointer]interface{}
cb_conference_messages map[unsafe.Pointer]interface{}
cb_conference_actions map[unsafe.Pointer]interface{}
cb_conference_titles map[unsafe.Pointer]interface{}
cb_conference_peer_names map[unsafe.Pointer]interface{}
cb_conference_peer_list_changeds map[unsafe.Pointer]interface{}

cb_file_recv_controls map[unsafe.Pointer]interface{}
cb_file_recvs map[unsafe.Pointer]interface{}
Expand Down Expand Up @@ -500,7 +501,8 @@ func NewTox(opt *ToxOptions) *Tox {
tox.cb_conference_messages = make(map[unsafe.Pointer]interface{})
tox.cb_conference_actions = make(map[unsafe.Pointer]interface{})
tox.cb_conference_titles = make(map[unsafe.Pointer]interface{})
tox.cb_conference_namelist_changes = make(map[unsafe.Pointer]interface{})
tox.cb_conference_peer_names = make(map[unsafe.Pointer]interface{})
tox.cb_conference_peer_list_changeds = make(map[unsafe.Pointer]interface{})

tox.cb_file_recv_controls = make(map[unsafe.Pointer]interface{})
tox.cb_file_recvs = make(map[unsafe.Pointer]interface{})
Expand Down
2 changes: 1 addition & 1 deletion tox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ func TestGroup(t *testing.T) {
}, nil)

groupNameChangeTimes := 0
t2.t.CallbackGroupNameListChange(func(_ *Tox, groupNumber int, peerNumber int, change uint8, ud interface{}) {
t2.t.CallbackConferencePeerListChanged(func(_ *Tox, groupNumber uint32, ud interface{}) {
groupNameChangeTimes += 1
}, nil)

Expand Down
2 changes: 1 addition & 1 deletion toxav.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func (this *Tox) JoinAVGroupChat(friendNumber uint32, cookie string) (int, error
if err != nil {
return 0, errors.New("Invalid cookie:" + cookie)
}
var _fn = C.int32_t(friendNumber)
var _fn = C.uint32_t(friendNumber)
var _data = (*C.uint8_t)((unsafe.Pointer)(&data[0]))
var length = len(data)
var _length = C.uint16_t(length)
Expand Down