Skip to content

Commit

Permalink
Merge 74ee2eb into 7d2dde3
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Feb 22, 2018
2 parents 7d2dde3 + 74ee2eb commit 8e1c84f
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 46 deletions.
24 changes: 16 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ 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.4.x
# if: type IN (push, api, cron)
- go: 1.5.x
# if: type IN (push, api, cron)
- go: 1.6.x
# if: type IN (push, api, cron)
- 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
Expand All @@ -43,6 +50,7 @@ install:
- 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

Expand Down
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
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

0 comments on commit 8e1c84f

Please sign in to comment.