-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathgroup_legacy.go
148 lines (118 loc) · 5.33 KB
/
group_legacy.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package tox
/*
#include <stdlib.h>
#include <string.h>
#include <tox/tox.h>
*/
import "C"
// legacy group callback type
type cb_group_invite_ftype func(this *Tox, friendNumber uint32, itype uint8, data []byte, userData interface{})
type cb_group_message_ftype func(this *Tox, groupNumber int, peerNumber int, message string, userData interface{})
type cb_group_action_ftype func(this *Tox, groupNumber int, peerNumber int, action string, userData interface{})
type cb_group_title_ftype func(this *Tox, groupNumber int, peerNumber int, title string, userData interface{})
type cb_group_namelist_change_ftype func(this *Tox, groupNumber int, peerNumber int, change uint8, userData interface{})
// tox_callback_group_***
func (this *Tox) CallbackGroupInvite(cbfn cb_group_invite_ftype, userData interface{}) {
this.CallbackGroupInviteAdd(cbfn, userData)
}
func (this *Tox) CallbackGroupInviteAdd(cbfn cb_group_invite_ftype, userData interface{}) {
cbfn_ := func(this *Tox, friendNumber uint32, itype uint8, data []byte, userData interface{}) {
cbfn(this, friendNumber, itype, data, userData)
}
this.CallbackConferenceInviteAdd(cbfn_, userData)
}
func (this *Tox) CallbackGroupMessage(cbfn cb_group_message_ftype, userData interface{}) {
this.CallbackGroupMessageAdd(cbfn, userData)
}
func (this *Tox) CallbackGroupMessageAdd(cbfn cb_group_message_ftype, userData interface{}) {
cbfn_ := func(this *Tox, groupNumber uint32, peerNumber uint32, message string, userData interface{}) {
cbfn(this, int(groupNumber), int(peerNumber), message, userData)
}
this.CallbackConferenceMessageAdd(cbfn_, userData)
}
func (this *Tox) CallbackGroupAction(cbfn cb_group_action_ftype, userData interface{}) {
this.CallbackGroupActionAdd(cbfn, userData)
}
func (this *Tox) CallbackGroupActionAdd(cbfn cb_group_action_ftype, userData interface{}) {
cbfn_ := func(this *Tox, groupNumber uint32, peerNumber uint32, message string, userData interface{}) {
cbfn(this, int(groupNumber), int(peerNumber), message, userData)
}
this.CallbackConferenceActionAdd(cbfn_, userData)
}
func (this *Tox) CallbackGroupTitle(cbfn cb_group_title_ftype, userData interface{}) {
this.CallbackGroupTitleAdd(cbfn, userData)
}
func (this *Tox) CallbackGroupTitleAdd(cbfn cb_group_title_ftype, userData interface{}) {
cbfn_ := func(this *Tox, groupNumber uint32, peerNumber uint32, title string, userData interface{}) {
cbfn(this, int(groupNumber), int(peerNumber), title, userData)
}
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()
return int(gn), err
}
func (this *Tox) DelGroupChat(groupNumber int) (int, error) {
return this.ConferenceDelete(uint32(groupNumber))
}
func (this *Tox) GroupPeerName(groupNumber int, peerNumber int) (string, error) {
return this.ConferencePeerGetName(uint32(groupNumber), uint32(peerNumber))
}
func (this *Tox) GroupPeerPubkey(groupNumber int, peerNumber int) (string, error) {
return this.ConferencePeerGetPublicKey(uint32(groupNumber), peerNumber)
}
func (this *Tox) InviteFriend(friendNumber uint32, groupNumber int) (int, error) {
return this.ConferenceInvite(friendNumber, uint32(groupNumber))
}
func (this *Tox) JoinGroupChat(friendNumber uint32, data []byte) (int, error) {
groupNumber, err := this.ConferenceJoin(friendNumber, data)
return int(groupNumber), err
}
func (this *Tox) GroupActionSend(groupNumber int, action string) (int, error) {
return this.ConferenceSendMessage(uint32(groupNumber), MESSAGE_TYPE_ACTION, action)
}
func (this *Tox) GroupMessageSend(groupNumber int, message string) (int, error) {
return this.ConferenceSendMessage(uint32(groupNumber), MESSAGE_TYPE_NORMAL, message)
}
func (this *Tox) GroupSetTitle(groupNumber int, title string) (int, error) {
return this.ConferenceSetTitle(uint32(groupNumber), title)
}
func (this *Tox) GroupGetTitle(groupNumber int) (string, error) {
return this.ConferenceGetTitle(uint32(groupNumber))
}
func (this *Tox) GroupPeerNumberIsOurs(groupNumber int, peerNumber uint32) bool {
return this.ConferencePeerNumberIsOurs(uint32(groupNumber), peerNumber)
}
func (this *Tox) GroupNumberPeers(groupNumber int) int {
cnt := this.ConferencePeerCount(uint32(groupNumber))
return int(cnt)
}
// extra combined api
func (this *Tox) GroupGetNames(groupNumber int) []string {
return this.ConferenceGetNames(uint32(groupNumber))
}
func (this *Tox) GroupGetPeerPubkeys(groupNumber int) []string {
return this.ConferenceGetPeerPubkeys(uint32(groupNumber))
}
func (this *Tox) GroupGetPeers(groupNumber int) map[int]string {
return this.ConferenceGetPeers(uint32(groupNumber))
}
func (this *Tox) CountChatList() uint32 {
return this.ConferenceGetChatlistSize()
}
func (this *Tox) GetChatList() []int32 {
return this.ConferenceGetChatlist()
}
func (this *Tox) GroupGetType(groupNumber uint32) (int, error) {
return this.ConferenceGetType(groupNumber)
}