diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-09-07 17:18:19 +0100 |
---|---|---|
committer | Jfreegman <jfreegman@gmail.com> | 2016-09-17 19:11:28 -0400 |
commit | c0397a0a4614671679d409c428b47549a01fdf7f (patch) | |
tree | 525f0efd2241dc921588949598cd8a1767d19425 /other/apidsl | |
parent | 21f8db12c45bd56293262cd4abfb73cd9abec821 (diff) |
ApiDSL'ing old group chats (now: conference).
Diffstat (limited to 'other/apidsl')
-rw-r--r-- | other/apidsl/tox.in.h | 266 |
1 files changed, 251 insertions, 15 deletions
diff --git a/other/apidsl/tox.in.h b/other/apidsl/tox.in.h index d14e48ba..cd802a94 100644 --- a/other/apidsl/tox.in.h +++ b/other/apidsl/tox.in.h | |||
@@ -1470,7 +1470,8 @@ namespace friend { | |||
1470 | * containing the message text. | 1470 | * containing the message text. |
1471 | * @param length Length of the message to be sent. | 1471 | * @param length Length of the message to be sent. |
1472 | */ | 1472 | */ |
1473 | uint32_t message(uint32_t friend_number, MESSAGE_TYPE type, const uint8_t[length <= MAX_MESSAGE_LENGTH] message) { | 1473 | uint32_t message(uint32_t friend_number, MESSAGE_TYPE type, |
1474 | const uint8_t[length <= MAX_MESSAGE_LENGTH] message) { | ||
1474 | NULL, | 1475 | NULL, |
1475 | /** | 1476 | /** |
1476 | * The friend number did not designate a valid friend. | 1477 | * The friend number did not designate a valid friend. |
@@ -1537,8 +1538,8 @@ namespace friend { | |||
1537 | * @param length The size of the message byte array. | 1538 | * @param length The size of the message byte array. |
1538 | */ | 1539 | */ |
1539 | typedef void(const uint8_t[PUBLIC_KEY_SIZE] public_key | 1540 | typedef void(const uint8_t[PUBLIC_KEY_SIZE] public_key |
1540 | //, uint32_t time_delta | 1541 | //, uint32_t time_delta |
1541 | , const uint8_t[length <= MAX_MESSAGE_LENGTH] message); | 1542 | , const uint8_t[length <= MAX_MESSAGE_LENGTH] message); |
1542 | } | 1543 | } |
1543 | 1544 | ||
1544 | 1545 | ||
@@ -1555,8 +1556,9 @@ namespace friend { | |||
1555 | * @see ${event request} for more information on time_delta. | 1556 | * @see ${event request} for more information on time_delta. |
1556 | */ | 1557 | */ |
1557 | typedef void(uint32_t friend_number | 1558 | typedef void(uint32_t friend_number |
1558 | //, uint32_t time_delta | 1559 | //, uint32_t time_delta |
1559 | , MESSAGE_TYPE type, const uint8_t[length <= MAX_MESSAGE_LENGTH] message); | 1560 | , MESSAGE_TYPE type, |
1561 | const uint8_t[length <= MAX_MESSAGE_LENGTH] message); | ||
1560 | } | 1562 | } |
1561 | 1563 | ||
1562 | } | 1564 | } |
@@ -1766,8 +1768,10 @@ namespace file { | |||
1766 | * | 1768 | * |
1767 | * @return true on success. | 1769 | * @return true on success. |
1768 | */ | 1770 | */ |
1769 | const bool get_file_id(uint32_t friend_number, uint32_t file_number, uint8_t[FILE_ID_LENGTH] file_id) | 1771 | uint8_t[FILE_ID_LENGTH] file_id { |
1770 | with error for get; | 1772 | get(uint32_t friend_number, uint32_t file_number) |
1773 | with error for get; | ||
1774 | } | ||
1771 | 1775 | ||
1772 | } | 1776 | } |
1773 | 1777 | ||
@@ -1830,7 +1834,7 @@ namespace file { | |||
1830 | * unknown or streaming. | 1834 | * unknown or streaming. |
1831 | * @param file_id A file identifier of length $FILE_ID_LENGTH that can be used to | 1835 | * @param file_id A file identifier of length $FILE_ID_LENGTH that can be used to |
1832 | * uniquely identify file transfers across core restarts. If NULL, a random one will | 1836 | * uniquely identify file transfers across core restarts. If NULL, a random one will |
1833 | * be generated by core. It can then be obtained by using $get_file_id(). | 1837 | * be generated by core. It can then be obtained by using ${file_id.get}(). |
1834 | * @param filename Name of the file. Does not need to be the actual name. This | 1838 | * @param filename Name of the file. Does not need to be the actual name. This |
1835 | * name will be sent along with the file send request. | 1839 | * name will be sent along with the file send request. |
1836 | * @param filename_length Size in bytes of the filename. | 1840 | * @param filename_length Size in bytes of the filename. |
@@ -2019,12 +2023,245 @@ namespace file { | |||
2019 | * | 2023 | * |
2020 | ******************************************************************************/ | 2024 | ******************************************************************************/ |
2021 | 2025 | ||
2026 | error for conference { | ||
2027 | /** | ||
2028 | * Some error occurred. | ||
2029 | */ | ||
2030 | FAILURE, | ||
2031 | } | ||
2032 | |||
2033 | namespace conference { | ||
2022 | 2034 | ||
2023 | /****************************************************************************** | 2035 | /** |
2024 | * | 2036 | * Conference types for the ${event invite} event. |
2025 | * :: Group chat message sending and receiving | 2037 | */ |
2026 | * | 2038 | enum class TYPE { |
2027 | ******************************************************************************/ | 2039 | /** |
2040 | * Text-only conferences that must be accepted with the $join function. | ||
2041 | */ | ||
2042 | TEXT, | ||
2043 | /** | ||
2044 | * Video conference. The function to accept these is in toxav. | ||
2045 | */ | ||
2046 | AV, | ||
2047 | } | ||
2048 | |||
2049 | |||
2050 | /** | ||
2051 | * This event is triggered when the client is invited to join a conference. | ||
2052 | */ | ||
2053 | event invite { | ||
2054 | /** | ||
2055 | * The invitation will remain valid until the inviting friend goes offline | ||
2056 | * or exits the conference. | ||
2057 | * | ||
2058 | * @param friend_number The friend who invited us. | ||
2059 | * @param type The conference type (text only or audio/video). | ||
2060 | * @param cookie A piece of data of variable length required to join the | ||
2061 | * conference. | ||
2062 | * @param length The length of the cookie. | ||
2063 | */ | ||
2064 | typedef void(uint32_t friend_number, TYPE type, const uint8_t[length] cookie); | ||
2065 | } | ||
2066 | |||
2067 | |||
2068 | /** | ||
2069 | * Set the callback for group messages. | ||
2070 | */ | ||
2071 | event message { | ||
2072 | /** | ||
2073 | * TODO | ||
2074 | */ | ||
2075 | typedef void(uint32_t group_number, uint32_t peer_number, MESSAGE_TYPE type, | ||
2076 | const uint8_t[length] message); | ||
2077 | } | ||
2078 | |||
2079 | |||
2080 | /** | ||
2081 | * Set callback function for title changes. | ||
2082 | * | ||
2083 | * if peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the group) | ||
2084 | */ | ||
2085 | event title { | ||
2086 | /** | ||
2087 | * TODO | ||
2088 | */ | ||
2089 | typedef void(uint32_t group_number, uint32_t peer_number, const uint8_t[length] title); | ||
2090 | } | ||
2091 | |||
2092 | |||
2093 | // rename CHANGE to something different that is a good prefix for the three | ||
2094 | // things below. | ||
2095 | enum class CHANGE { | ||
2096 | PEER_ADD, // JOINED? | ||
2097 | PEER_DEL, // PARTED? | ||
2098 | PEER_NAME, // NAME_CHANGE? | ||
2099 | } | ||
2100 | |||
2101 | /** | ||
2102 | * Set callback function for peer name list changes. | ||
2103 | * | ||
2104 | * It gets called every time the name list changes(new peer/name, deleted peer) | ||
2105 | */ | ||
2106 | event namelist_change { | ||
2107 | /** | ||
2108 | * TODO | ||
2109 | */ | ||
2110 | typedef void(uint32_t group_number, uint32_t peer_number, CHANGE change); | ||
2111 | } | ||
2112 | |||
2113 | |||
2114 | /** | ||
2115 | * Creates a new groupchat. | ||
2116 | * | ||
2117 | * @return the group number. | ||
2118 | */ | ||
2119 | uint32_t new() | ||
2120 | with error for conference; | ||
2121 | |||
2122 | /** | ||
2123 | * Delete a groupchat. | ||
2124 | * | ||
2125 | * @return true on success. | ||
2126 | */ | ||
2127 | bool delete(uint32_t group_number) | ||
2128 | with error for conference; | ||
2129 | |||
2130 | |||
2131 | namespace peer { | ||
2132 | |||
2133 | /** | ||
2134 | * Return the number of peers in the group chat. | ||
2135 | */ | ||
2136 | const uint32_t count(uint32_t group_number) | ||
2137 | with error for conference; | ||
2138 | |||
2139 | uint8_t[size] name { | ||
2140 | size(uint32_t group_number, uint32_t peer_number) | ||
2141 | with error for conference; | ||
2142 | |||
2143 | /** | ||
2144 | * Copy the name of peer_number who is in group_number to name. | ||
2145 | * name must be at least $MAX_NAME_LENGTH long. | ||
2146 | * | ||
2147 | * return length of name if success | ||
2148 | * return -1 if failure | ||
2149 | */ | ||
2150 | get(uint32_t group_number, uint32_t peer_number) | ||
2151 | with error for conference; | ||
2152 | } | ||
2153 | |||
2154 | /** | ||
2155 | * Copy the public key of peer_number who is in group_number to public_key. | ||
2156 | * public_key must be $PUBLIC_KEY_SIZE long. | ||
2157 | * | ||
2158 | * returns 0 on success | ||
2159 | * returns -1 on failure | ||
2160 | */ | ||
2161 | uint8_t[PUBLIC_KEY_SIZE] public_key { | ||
2162 | get(uint32_t group_number, uint32_t peer_number) | ||
2163 | with error for conference; | ||
2164 | } | ||
2165 | |||
2166 | /** | ||
2167 | * Check if the current peer_number corresponds to ours. | ||
2168 | * | ||
2169 | * return 1 if the peer_number corresponds to ours. | ||
2170 | * return 0 on failure. | ||
2171 | */ | ||
2172 | const bool number_is_ours(uint32_t group_number, uint32_t peer_number); | ||
2173 | |||
2174 | } | ||
2175 | |||
2176 | |||
2177 | /** | ||
2178 | * invite friend_number to group_number | ||
2179 | * return 0 on success | ||
2180 | * return -1 on failure | ||
2181 | */ | ||
2182 | bool invite(uint32_t friend_number, uint32_t group_number) | ||
2183 | with error for conference; | ||
2184 | |||
2185 | |||
2186 | /** | ||
2187 | * Join a group (you need to have been invited first.) using cookie of length obtained | ||
2188 | * in the group invite callback. | ||
2189 | * | ||
2190 | * returns group number on success | ||
2191 | * returns -1 on failure. | ||
2192 | */ | ||
2193 | uint32_t join(uint32_t friend_number, const uint8_t[length] cookie) | ||
2194 | with error for conference; | ||
2195 | |||
2196 | |||
2197 | namespace send { | ||
2198 | |||
2199 | /** | ||
2200 | * send a group message | ||
2201 | * return 0 on success | ||
2202 | * return -1 on failure | ||
2203 | */ | ||
2204 | bool message(uint32_t group_number, MESSAGE_TYPE type, const uint8_t[length] message) | ||
2205 | with error for conference; | ||
2206 | |||
2207 | } | ||
2208 | |||
2209 | |||
2210 | uint8_t[length <= MAX_NAME_LENGTH] title { | ||
2211 | size(uint32_t group_number) | ||
2212 | with error for conference; | ||
2213 | |||
2214 | /** | ||
2215 | * Get group title from group_number and put it in title. | ||
2216 | * title needs to be a valid memory location with a max_length size of at least MAX_NAME_LENGTH (128) bytes. | ||
2217 | * | ||
2218 | * return length of copied title if success. | ||
2219 | * return -1 if failure. | ||
2220 | */ | ||
2221 | get(uint32_t group_number) | ||
2222 | with error for conference; | ||
2223 | |||
2224 | /** | ||
2225 | * set the group's title, limited to MAX_NAME_LENGTH | ||
2226 | * return 0 on success | ||
2227 | * return -1 on failure | ||
2228 | */ | ||
2229 | set(uint32_t group_number) | ||
2230 | with error for conference; | ||
2231 | } | ||
2232 | |||
2233 | |||
2234 | uint32_t[size] chatlist { | ||
2235 | /** | ||
2236 | * Return the number of chats in the instance m. | ||
2237 | * You should use this to determine how much memory to allocate | ||
2238 | * for copy_chatlist. | ||
2239 | */ | ||
2240 | size(); | ||
2241 | |||
2242 | /** | ||
2243 | * Copy a list of valid chat IDs into the array out_list. | ||
2244 | * If out_list is NULL, returns 0. | ||
2245 | * Otherwise, returns the number of elements copied. | ||
2246 | * If the array was too small, the contents | ||
2247 | * of out_list will be truncated to list_size. | ||
2248 | */ | ||
2249 | get(); | ||
2250 | } | ||
2251 | |||
2252 | |||
2253 | /** | ||
2254 | * return the type of groupchat ($TYPE) that group_number is. | ||
2255 | * | ||
2256 | * return -1 on failure. | ||
2257 | * return type on success. | ||
2258 | */ | ||
2259 | TYPE type { | ||
2260 | get(uint32_t group_number) | ||
2261 | with error for conference; | ||
2262 | } | ||
2263 | |||
2264 | } | ||
2028 | 2265 | ||
2029 | 2266 | ||
2030 | /******************************************************************************* | 2267 | /******************************************************************************* |
@@ -2188,11 +2425,10 @@ inline namespace self { | |||
2188 | 2425 | ||
2189 | } | 2426 | } |
2190 | 2427 | ||
2428 | |||
2191 | } // class tox | 2429 | } // class tox |
2192 | 2430 | ||
2193 | %{ | 2431 | %{ |
2194 | #include "tox_group.h" | ||
2195 | |||
2196 | #ifdef __cplusplus | 2432 | #ifdef __cplusplus |
2197 | } | 2433 | } |
2198 | #endif | 2434 | #endif |