diff options
author | irungentoo <irungentoo@gmail.com> | 2014-09-25 16:48:18 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-09-25 16:48:18 -0400 |
commit | d67624bf99d03ecb754a5f406a971ad41de1cd04 (patch) | |
tree | 9913ee9d24468b9dbd1c0026abfe269d88eb7415 /toxcore/group_chats.h | |
parent | aca2d618435388fb3029c9db6d9ea1c5ba427cbe (diff) |
Removed groupchats from core.
Diffstat (limited to 'toxcore/group_chats.h')
-rw-r--r-- | toxcore/group_chats.h | 199 |
1 files changed, 0 insertions, 199 deletions
diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h deleted file mode 100644 index 1a7a2e04..00000000 --- a/toxcore/group_chats.h +++ /dev/null | |||
@@ -1,199 +0,0 @@ | |||
1 | /* group_chats.h | ||
2 | * | ||
3 | * An implementation of massive text only group chats. | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
7 | * | ||
8 | * This file is part of Tox. | ||
9 | * | ||
10 | * Tox is free software: you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation, either version 3 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * Tox is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #ifndef GROUP_CHATS_H | ||
26 | #define GROUP_CHATS_H | ||
27 | |||
28 | #define MAX_NICK_BYTES 128 | ||
29 | |||
30 | typedef struct { | ||
31 | uint8_t client_id[crypto_box_PUBLICKEYBYTES]; | ||
32 | uint64_t pingid; | ||
33 | uint64_t last_pinged; | ||
34 | IP_Port ping_via; | ||
35 | |||
36 | uint64_t last_recv; | ||
37 | uint64_t last_recv_msgping; | ||
38 | uint32_t last_message_number; | ||
39 | |||
40 | uint8_t nick[MAX_NICK_BYTES]; | ||
41 | uint16_t nick_len; | ||
42 | |||
43 | uint8_t deleted; | ||
44 | uint64_t deleted_time; | ||
45 | } Group_Peer; | ||
46 | |||
47 | typedef struct { | ||
48 | uint8_t client_id[crypto_box_PUBLICKEYBYTES]; | ||
49 | IP_Port ip_port; | ||
50 | uint64_t last_recv; | ||
51 | } Group_Close; | ||
52 | |||
53 | #define GROUP_CLOSE_CONNECTIONS 6 | ||
54 | |||
55 | typedef struct Group_Chat { | ||
56 | Networking_Core *net; | ||
57 | uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; | ||
58 | uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; | ||
59 | |||
60 | Group_Peer *group; | ||
61 | Group_Close close[GROUP_CLOSE_CONNECTIONS]; | ||
62 | uint32_t numpeers; | ||
63 | |||
64 | uint32_t message_number; | ||
65 | void (*group_message)(struct Group_Chat *m, int, const uint8_t *, uint16_t, void *); | ||
66 | void *group_message_userdata; | ||
67 | void (*group_action)(struct Group_Chat *m, int, const uint8_t *, uint16_t, void *); | ||
68 | void *group_action_userdata; | ||
69 | void (*peer_namelistchange)(struct Group_Chat *m, int peer, uint8_t change, void *); | ||
70 | void *group_namelistchange_userdata; | ||
71 | |||
72 | uint64_t last_sent_ping; | ||
73 | |||
74 | uint8_t nick[MAX_NICK_BYTES]; | ||
75 | uint16_t nick_len; | ||
76 | uint64_t last_sent_nick; | ||
77 | |||
78 | struct Assoc *assoc; | ||
79 | } Group_Chat; | ||
80 | |||
81 | #define GROUP_CHAT_PING 0 | ||
82 | #define GROUP_CHAT_NEW_PEER 16 | ||
83 | #define GROUP_CHAT_QUIT 24 | ||
84 | #define GROUP_CHAT_PEER_NICK 48 | ||
85 | #define GROUP_CHAT_CHAT_MESSAGE 64 | ||
86 | #define GROUP_CHAT_ACTION 63 | ||
87 | |||
88 | /* Copy the name of peernum to name. | ||
89 | * name must be at least MAX_NICK_BYTES long. | ||
90 | * | ||
91 | * return length of name if success | ||
92 | * return -1 if failure | ||
93 | */ | ||
94 | int group_peername(const Group_Chat *chat, int peernum, uint8_t *name); | ||
95 | |||
96 | /* | ||
97 | * Set callback function for chat messages. | ||
98 | * | ||
99 | * format of function is: function(Group_Chat *chat, peer number, message, message length, userdata) | ||
100 | */ | ||
101 | void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, int, const uint8_t *, uint16_t, void *), | ||
102 | void *userdata); | ||
103 | |||
104 | /* | ||
105 | * Set callback function for actions. | ||
106 | * | ||
107 | * format of function is: function(Group_Chat *chat, peer number, action, action length, userdata) | ||
108 | */ | ||
109 | void callback_groupaction(Group_Chat *chat, void (*function)(Group_Chat *chat, int, const uint8_t *, uint16_t, void *), | ||
110 | void *userdata); | ||
111 | |||
112 | /* | ||
113 | * Set callback function for peer name list changes. | ||
114 | * | ||
115 | * It gets called every time the name list changes(new peer/name, deleted peer) | ||
116 | * | ||
117 | * format of function is: function(Group_Chat *chat, userdata) | ||
118 | */ | ||
119 | typedef enum { | ||
120 | CHAT_CHANGE_PEER_ADD, | ||
121 | CHAT_CHANGE_PEER_DEL, | ||
122 | CHAT_CHANGE_PEER_NAME, | ||
123 | } CHAT_CHANGE; | ||
124 | |||
125 | void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat, int peer, uint8_t change, void *), | ||
126 | void *userdata); | ||
127 | |||
128 | /* | ||
129 | * Send a message to the group. | ||
130 | * | ||
131 | * returns the number of peers it has sent it to. | ||
132 | */ | ||
133 | uint32_t group_sendmessage(Group_Chat *chat, const uint8_t *message, uint32_t length); | ||
134 | |||
135 | /* | ||
136 | * Send an action to the group. | ||
137 | * | ||
138 | * returns the number of peers it has sent it to. | ||
139 | */ | ||
140 | uint32_t group_sendaction(Group_Chat *chat, const uint8_t *action, uint32_t length); | ||
141 | |||
142 | /* | ||
143 | * Set our nick for this group. | ||
144 | * | ||
145 | * returns -1 on failure, 0 on success. | ||
146 | */ | ||
147 | int set_nick(Group_Chat *chat, const uint8_t *nick, uint16_t nick_len); | ||
148 | |||
149 | /* | ||
150 | * Tell everyone about a new peer (a person we are inviting for example.) | ||
151 | * | ||
152 | */ | ||
153 | uint32_t group_newpeer(Group_Chat *chat, const uint8_t *client_id); | ||
154 | |||
155 | |||
156 | /* Create a new group chat. | ||
157 | * | ||
158 | * Returns a new group chat instance if success. | ||
159 | * | ||
160 | * Returns a NULL pointer if fail. | ||
161 | */ | ||
162 | Group_Chat *new_groupchat(Networking_Core *net); | ||
163 | |||
164 | |||
165 | /* Return the number of peers in the group chat. | ||
166 | */ | ||
167 | uint32_t group_numpeers(const Group_Chat *chat); | ||
168 | |||
169 | /* List all the peers in the group chat. | ||
170 | * | ||
171 | * Copies the names of the peers to the name[length][MAX_NICK_BYTES] array. | ||
172 | * | ||
173 | * returns the number of peers. | ||
174 | */ | ||
175 | uint32_t group_client_names(const Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], | ||
176 | uint16_t length); | ||
177 | |||
178 | /* Kill a group chat | ||
179 | * | ||
180 | * Frees the memory and everything. | ||
181 | */ | ||
182 | void kill_groupchat(Group_Chat *chat); | ||
183 | |||
184 | /* | ||
185 | * This is the main loop. | ||
186 | */ | ||
187 | void do_groupchat(Group_Chat *chat); | ||
188 | |||
189 | /* if we receive a group chat packet we call this function so it can be handled. | ||
190 | return 0 if packet is handled correctly. | ||
191 | return 1 if it didn't handle the packet or if the packet was shit. */ | ||
192 | int handle_groupchatpacket(Group_Chat *chat, IP_Port source, const uint8_t *packet, uint32_t length); | ||
193 | |||
194 | |||
195 | void chat_bootstrap(Group_Chat *chat, IP_Port ip_port, const uint8_t *client_id); | ||
196 | void chat_bootstrap_nonlazy(Group_Chat *chat, IP_Port ip_port, const uint8_t *client_id); | ||
197 | |||
198 | |||
199 | #endif | ||