Compare commits

...

10 Commits

Author SHA1 Message Date
4edbf98dc4 update 2024-03-09 03:46:27 +00:00
3a3d8ab5e4 updates 2024-03-08 04:02:20 +00:00
d200a55938 fixed 2024-03-07 09:36:36 +00:00
emdee
553a192910 updates 2024-03-07 02:46:11 +00:00
emdee
8a6e08470e Works now 2022-11-20 02:54:42 +00:00
emdee
b72ca69a8a First 2022-11-11 11:40:14 +00:00
emdee
d40d314f6a git mv twc-group-invite.h twc-conf-invite.h 2022-11-11 07:11:47 +00:00
Håvard Pettersson
80319b30cd Fix printf format warnings on certain platforms 2019-01-19 15:14:44 +01:00
Håvard Pettersson
40894df778 readme: improve build & install instructions 2019-01-19 14:41:35 +01:00
Håvard Pettersson
ac6d97192f cmake: find WeeChat as REQUIRED 2019-01-19 14:22:38 +01:00
20 changed files with 730 additions and 226 deletions

View File

@ -20,6 +20,9 @@
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 2.8.12)
project(tox-weechat C) project(tox-weechat C)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/src/c-toxcore/toxcore -I/var/local/src/c-toxcore/toxav -I/usr/local/src/c-toxcore/toxencryptsave")
set(LD_FLAGS "${LD_FLAGS} -I/usr/local/src/c-toxcore/_build")
add_library(tox MODULE add_library(tox MODULE
src/twc.c src/twc.c
src/twc-bootstrap.c src/twc-bootstrap.c
@ -29,7 +32,7 @@ add_library(tox MODULE
src/twc-config.c src/twc-config.c
src/twc-friend-request.c src/twc-friend-request.c
src/twc-gui.c src/twc-gui.c
src/twc-group-invite.c src/twc-conf-invite.c
src/twc-list.c src/twc-list.c
src/twc-message-queue.c src/twc-message-queue.c
src/twc-profile.c src/twc-profile.c
@ -44,7 +47,7 @@ target_compile_options(tox PRIVATE -Wall -Wextra -Wno-unused-parameter)
# find include and shared library locations # find include and shared library locations
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(WeeChat) find_package(WeeChat REQUIRED)
find_package(Tox REQUIRED CORE OPTIONAL_COMPONENTS AV ENCRYPTSAVE) find_package(Tox REQUIRED CORE OPTIONAL_COMPONENTS AV ENCRYPTSAVE)
target_include_directories(tox PRIVATE target_include_directories(tox PRIVATE

View File

@ -1,45 +1,59 @@
# Tox-WeeChat # Tox-WeeChat
Tox-WeeChat is a [Tox][1] protocol plugin for [WeeChat][2]. It is functional, Tox-WeeChat is a [Tox][1] protocol plugin for [WeeChat][2]. It is functional,
but lacks certain features that might be expected of a full-fledged Tox client. but lacks certain features that might be expected of a full-fledged Tox client.
Originally from the abandonned https://github.com/haavard/tox-weechat
Tox-WeeChat is compliant with all "Required" points in the [Tox Client Tox-WeeChat is compliant with all "Required" points in the
Standard][3]. [Tox Client Standard][3]. There is no support for NGC groups.
[![Build Status](https://travis-ci.org/haavard/tox-weechat.svg?branch=master)][4]
## Features ## Features
- One-to-one chats - One-to-one chats
- Group chats (text only) - Conference chats (text only)
- Proxy support - Proxy support
- Multiple profiles - Multiple profiles
- Encrypted save files - Encrypted save files
- File transfer - File transfer
No NGC groups yet.
## Installation ## Installation
Tox-WeeChat is tested with [WeeChat][2] 2.3 and [TokTok c-toxcore][5] 0.2.8.
It also requires CMake 2.8.12 or newer to be built. Installation is fairly Tox-WeeChat requires [WeeChat][2] (tested with version 4.1.2) and [TokTok
simple; after getting the source code, compile and install with CMake: c-toxcore][4] (tested with version 0.2.18). CMake 2.8.12 or newer is also
required to build.
Installation is fairly simple; after getting the source code, compile
and install using CMake:
$ mkdir build && cd build $ mkdir build && cd build
$ cmake -DPLUGIN_PATH=~/.weechat/plugins .. $ cmake -DPLUGIN_PATH=~/.cache/weechat/plugins ..
$ make install $ make install
This installs the plugin binary `tox.so` to the recommended location This installs the plugin binary `tox.so` to the recommended location
`~/.weechat/plugins`. The default location is `/usr/local/lib/weechat/plugins`. `~/.cache/weechat/plugins`. The default location is `/usr/local/lib/weechat/plugins`.
If WeeChat or toxcore are installed in a non-standard location, you can try
specifying `CMAKE_PREFIX_PATH` to find them; see [.travis.yml](.travis.yml) for
an example.
## Usage ## Usage
- If the plugin does not load automatically, load it with `/plugin load tox`. - If the plugin does not load automatically, load it with `/plugin load tox`.
You may have to specify the full path to the plugin binary if you installed You may have to specify the full path to the plugin binary if you installed
it to a non-standard location. it to a non-standard location.
- Create a new profile with `/tox create <profile name>`. The data file is - Create a new profile with `/tox create <profile name>`. The data file is
stored in `~/.weechat/tox/` by default. stored in `~/.cache/weechat/tox/` by default.
- Load your profile and connect to the Tox network with - Load your profile and connect to the Tox network with
`/tox load <profile name>`. `/tox load <profile name>` (see also /bootstrap, /conf, /friend, /invite,
/me, /msg, /myid, /name, /names, /nospam, /part, /send,
/status, /statusmsg, /topic, /tox).
- Run `/help -listfull tox` to get a list of all available commands, and - Run `/help -listfull tox` to get a list of all available commands, and
`/set tox.*` for a list of options. `/set tox.*` for a list of options, including proxies.
### Common issues ### Common issues
#### Long Tox names messing up WeeChat layout #### Long Tox names messing up WeeChat layout
Tox allows names up to 128 bytes long. To prevent long names from taking all Tox allows names up to 128 bytes long. To prevent long names from taking all
your screen space, you can set the following options in WeeChat: your screen space, you can set the following options in WeeChat:
- `weechat.bar.nicklist.size_max` - `weechat.bar.nicklist.size_max`
@ -47,8 +61,10 @@ your screen space, you can set the following options in WeeChat:
- `buffers.look.name_size_max` (if using buffers.pl) - `buffers.look.name_size_max` (if using buffers.pl)
#### Tox won't connect through my proxy #### Tox won't connect through my proxy
Make sure the proxy type, address and port is correct, and that UDP is Make sure the proxy type, address and port is correct, and that UDP is
disabled (`/set tox.profile.*.udp`). disabled (`/set tox.profile.*.udp`) and it is required to disable IPv6
(`/set tox.profile.*.ipv6`).
## License ## License
Copyright (c) 2018 Håvard Pettersson <mail@haavard.me> Copyright (c) 2018 Håvard Pettersson <mail@haavard.me>
@ -71,6 +87,11 @@ along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
[1]: http://tox.chat [1]: http://tox.chat
[2]: http://weechat.org [2]: http://weechat.org
[3]: https://github.com/Tox/Tox-Client-Standard [3]: https://github.com/Tox/Tox-Client-Standard
[4]: https://travis-ci.org/haavard/tox-weechat [4]: https://github.com/TokTok/c-toxcore
[5]: https://github.com/TokTok/c-toxcore
---
This is a hard fork of https://github.com/haavard/tox-weechat/
now at https://git.macaw.me/emdee/tox-weechat You can also run weechat under
toxygen https://git.macaw.me/emdee/toxygen using qweechat
https://git.macaw.me/emdee/qweechat

11
cmake.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
mkdir _build || exit 1
cd _build
# -DTox_INCLUDE_DIRS="/usr/local/src/c-toxcore/toxencryptsave /usr/local/src/c-toxcore/toxav /usr/local/src/c-toxcore/toxcore"
cmake -DPLUGIN_PATH=~/.cache/weechat/plugins -DCMAKE_PREFIX_PATH=/usr/local \
-DTox_INCLUDE_DIRS="/usr/local/src/c-toxcore" \
-DTox_LIBRARIES=/usr/local/src/c-toxcore/_build \
.. >> cmake.log 2>&1 || exit 2$?
make >> make.log 2>&1 || exit 3$?

View File

@ -21,14 +21,19 @@
import re import re
import sys import sys
import os
import json import json
import datetime import datetime
import textwrap import textwrap
import urllib.request import urllib.request
if __name__ == '__main__': def iMain(surl):
with urllib.request.urlopen('https://nodes.tox.chat/json') as response: if os.path.exists(surl):
data = json.load(response) with open(surl, 'rt') as response:
data = json.load(response)
else:
with urllib.request.urlopen(surl) as response:
data = json.load(response)
# get online nodes that are defined by IP address # get online nodes that are defined by IP address
nodes = [node for node in data['nodes'] nodes = [node for node in data['nodes']
@ -52,3 +57,32 @@ if __name__ == '__main__':
print(' {{"{}",'.format(key)) print(' {{"{}",'.format(key))
print(' "{}", {}}},'.format(address, port)) print(' "{}", {}}},'.format(address, port))
print('};') print('};')
# get online nodes that are defined by IP address
nodes = [node for node in data['nodes']
if (node['status_tcp'] and node['tcp_ports'])
and re.match(r'^\d+\.\d+\.\d+\.\d+$', node['ipv4'])]
print('static struct t_twc_bootstrap_node const twc_bootstrap_relays[] = {')
for node in nodes:
for port in node['tcp_ports']:
# extract relevant values from node dictionaries
address = node['ipv4']
key = node['public_key']
comment = 'Maintainer: {}, location: {}'.format(
node['maintainer'], node['location'])
print(' /* {} */'.format(comment))
print(' {{"{}",'.format(key))
print(' "{}", {}}},'.format(address, port))
print('};')
return 0
if __name__ == '__main__':
if len(sys.argv) > 1:
surl = sys.argv[1]
else:
surl = 'https://nodes.tox.chat/json'
sys.exit(iMain(surl))

129
src/getnodes.c Normal file
View File

@ -0,0 +1,129 @@
/* bootstrap nodes generated by /o/var/local/src/tox-weechat.git/misc/getnodes.py
* last generated 2024-03-07T09:12:04.788351 */
static struct t_twc_bootstrap_node const twc_bootstrap_nodes[] = {
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"144.217.167.73", 33445},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 53},
/* Maintainer: kotelnik, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 33445},
/* Maintainer: Toxdaemon, location: RU */
{"DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
"5.19.249.240", 38296},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 33445},
/* Maintainer: Gabe, location: US */
{"933BA20B2E258B4C0D475B6DECE90C7E827FE83EFA9655414E7841251B19A72C",
"104.225.141.59", 43334},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 33445},
/* Maintainer: amr, location: CA */
{"D46E97CF995DC1820B92B7D899E152A217D36ABE22730FEA4B6BF1BFC06C617C",
"172.105.109.31", 33445},
/* Maintainer: Toxdaemon, location: EE */
{"B5E7DAC610DBDE55F359C7F8690B294C8E4FCEC4385DE9525DBFA5523EAD9D53",
"91.146.66.26", 33445},
/* Maintainer: zero-one, location: US */
{"DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
"172.104.215.182", 33445},
/* Maintainer: turambar, location: EG */
{"2A9F7A620581D5D1B09B004624559211C5ED3D1D712E8066ACDB0896A7335705",
"188.214.122.30", 33445},
/* Maintainer: UR1229SWL, location: NL */
{"99E8460035E45C0A6B6DC2C02B14440F7F876518E9D054D028209B5669827645",
"194.36.190.71", 33445},
/* Maintainer: Alexsandr, location: RU */
{"52BD37D53357701CB9C69ABA81E7741C5F14105523C89153A770D73F434AC473",
"62.183.96.32", 33445},
/* Maintainer: lzk, location: US */
{"1FD96DF8DCAC4A95C117B460F23EB740C8FBA60DE89BE7B45136790B8E3D4B63",
"141.11.229.155", 33445},
};
static struct t_twc_bootstrap_node const twc_bootstrap_relays[] = {
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"144.217.167.73", 3389},
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"144.217.167.73", 33445},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 53},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 443},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 3389},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 33445},
/* Maintainer: kotelnik, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 3389},
/* Maintainer: kotelnik, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 33445},
/* Maintainer: Toxdaemon, location: RU */
{"DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
"5.19.249.240", 38296},
/* Maintainer: Toxdaemon, location: RU */
{"DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
"5.19.249.240", 3389},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 3389},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 33445},
/* Maintainer: Gabe, location: US */
{"933BA20B2E258B4C0D475B6DECE90C7E827FE83EFA9655414E7841251B19A72C",
"104.225.141.59", 3389},
/* Maintainer: Gabe, location: US */
{"933BA20B2E258B4C0D475B6DECE90C7E827FE83EFA9655414E7841251B19A72C",
"104.225.141.59", 33445},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 443},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 33445},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 3389},
/* Maintainer: amr, location: CA */
{"D46E97CF995DC1820B92B7D899E152A217D36ABE22730FEA4B6BF1BFC06C617C",
"172.105.109.31", 33445},
/* Maintainer: zero-one, location: US */
{"DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
"172.104.215.182", 33445},
/* Maintainer: zero-one, location: US */
{"DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
"172.104.215.182", 443},
/* Maintainer: zero-one, location: US */
{"DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
"172.104.215.182", 3389},
/* Maintainer: turambar, location: EG */
{"2A9F7A620581D5D1B09B004624559211C5ED3D1D712E8066ACDB0896A7335705",
"188.214.122.30", 3389},
/* Maintainer: turambar, location: EG */
{"2A9F7A620581D5D1B09B004624559211C5ED3D1D712E8066ACDB0896A7335705",
"188.214.122.30", 33445},
/* Maintainer: UR1229SWL, location: NL */
{"99E8460035E45C0A6B6DC2C02B14440F7F876518E9D054D028209B5669827645",
"194.36.190.71", 33445},
/* Maintainer: Alexsandr, location: RU */
{"52BD37D53357701CB9C69ABA81E7741C5F14105523C89153A770D73F434AC473",
"62.183.96.32", 33445},
/* Maintainer: lzk, location: US */
{"1FD96DF8DCAC4A95C117B460F23EB740C8FBA60DE89BE7B45136790B8E3D4B63",
"141.11.229.155", 33445},
/* Maintainer: lzk, location: US */
{"1FD96DF8DCAC4A95C117B460F23EB740C8FBA60DE89BE7B45136790B8E3D4B63",
"141.11.229.155", 3389},
};

View File

@ -30,81 +30,134 @@ struct t_twc_bootstrap_node
uint16_t const port; uint16_t const port;
}; };
/* bootstrap nodes generated by misc/getnodes.py /* bootstrap nodes generated by /o/var/local/src/tox-weechat.git/misc/getnodes.py
* last generated 2018-04-12T22:40:44.123211 */ * last generated 2024-03-07T09:12:04.788351 */
static struct t_twc_bootstrap_node const twc_bootstrap_nodes[] = { static struct t_twc_bootstrap_node const twc_bootstrap_nodes[] = {
/* Maintainer: Manolis, location: DE */
{"461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F",
"130.133.110.14", 33445},
/* Maintainer: Busindre, location: US */
{"A179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702",
"205.185.116.116", 33445},
/* Maintainer: Busindre, location: US */
{"1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F",
"198.98.51.198", 33445},
/* Maintainer: ray65536, location: RU */
{"8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832",
"85.172.30.117", 33445},
/* Maintainer: fluke571, location: SI */
{"3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B",
"194.249.212.109", 33445},
/* Maintainer: MAH69K, location: UA */
{"DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43",
"185.25.116.107", 33445},
/* Maintainer: pucetox, location: FR */
{"7AED21F94D82B05774F697B209628CD5A9AD17E0C073D9329076A4C28ED28147",
"217.182.143.254", 2306},
/* Maintainer: ru_maniac, location: US */
{"0FB96EEBFB1650DDB52E70CF773DDFCABE25A95CC3BB50FC251082E4B63EF82A",
"104.223.122.15", 33445},
/* Maintainer: a68366, location: FR */
{"AEC204B9A4501412D5F0BB67D9C81B5DB3EE6ADA64122D32A3E9B093D544327D",
"51.254.84.212", 33445},
/* Maintainer: Skey, location: NL */
{"B71E91E2F5029B0A84D3B1136319CDD3D1DB6D3702B6CEFA66A4BEB25A635916",
"213.183.51.211", 33445},
/* Maintainer: t3mp, location: RU */
{"5625A62618CB4FCA70E147A71B29695F38CC65FF0CBD68AD46254585BE564802",
"92.54.84.70", 33445},
/* Maintainer: HooinKyoma, location: SE */
{"672DBE27B4ADB9D5FB105A6BB648B2F8FDB89B3323486A7A21968316E012023C",
"95.215.44.78", 33445},
/* Maintainer: LittleVulpix, location: FR */
{"2C289F9F37C20D09DA83565588BF496FAB3764853FA38141817A72E3F18ACA0B",
"163.172.136.118", 33445},
/* Maintainer: Yani, location: NL */
{"E59A0E71ADA20D35BD1B0957059D7EF7E7792B3D680AE25C6F4DBBA09114D165",
"37.97.185.116", 33445},
/* Maintainer: linxon, location: RU */
{"B38255EE4B054924F6D79A5E6E5889EC94B6ADF6FE9906F97A3D01E3D083223A",
"80.87.193.193", 33445},
/* Maintainer: Stranger, location: UA */
{"813C8F4187833EF0655B10F7752141A352248462A567529A38B6BBF73E979307",
"46.229.52.198", 33445},
/* Maintainer: velusip, location: CA */ /* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C", {"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"149.56.140.5", 33445}, "144.217.167.73", 33445},
/* Maintainer: dvor, location: NL */ /* Maintainer: GDR!, location: US */
{"2555763C8C460495B14157D234DD56B86300A2395554BCAE4621AC345B8C1B1B", {"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"185.14.30.213", 443}, "205.185.115.131", 53},
/* Maintainer: CeBe, location: DE */ /* Maintainer: kotelnik, location: DE */
{"6EE1FADE9F55CC7938234CC07C864081FC606D8FE7B751EDA217F268F1078A39",
"136.243.141.187", 443},
/* Maintainer: Pokemon, location: NL */
{"1B5A8AB25FFFB66620A531C4646B47F0F32B74C547B30AF8BD8266CA50A3AB59",
"37.48.122.22", 33445},
/* Maintainer: warlomak, location: RU */
{"FFAC871E85B1E1487F87AE7C76726AE0E60318A85F6A1669E04C47EB8DC7C72D",
"79.140.30.52", 33445},
/* Maintainer: ru_maniac, location: US */
{"3925752E43BF2F8EB4E12B0E9414311064FF2D76707DC7D5D2CCB43F75081F6B",
"104.223.122.204", 33445},
/* Maintainer: GDR!, location: PL */
{"B9D109CC820C69A5D97A4A1A15708107C6BA85C13BC6188CC809D374AFF18E63",
"77.55.211.53", 53},
/* Maintainer: clearmartin, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707", {"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 443}, "46.101.197.175", 33445},
/* Maintainer: Toxdaemon, location: RU */
{"DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
"5.19.249.240", 38296},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 33445},
/* Maintainer: Gabe, location: US */
{"933BA20B2E258B4C0D475B6DECE90C7E827FE83EFA9655414E7841251B19A72C",
"104.225.141.59", 43334},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 33445},
/* Maintainer: amr, location: CA */
{"D46E97CF995DC1820B92B7D899E152A217D36ABE22730FEA4B6BF1BFC06C617C",
"172.105.109.31", 33445},
/* Maintainer: Toxdaemon, location: EE */
{"B5E7DAC610DBDE55F359C7F8690B294C8E4FCEC4385DE9525DBFA5523EAD9D53",
"91.146.66.26", 33445},
/* Maintainer: zero-one, location: US */
{"DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
"172.104.215.182", 33445},
/* Maintainer: turambar, location: EG */
{"2A9F7A620581D5D1B09B004624559211C5ED3D1D712E8066ACDB0896A7335705",
"188.214.122.30", 33445},
/* Maintainer: UR1229SWL, location: NL */
{"99E8460035E45C0A6B6DC2C02B14440F7F876518E9D054D028209B5669827645",
"194.36.190.71", 33445},
/* Maintainer: Alexsandr, location: RU */
{"52BD37D53357701CB9C69ABA81E7741C5F14105523C89153A770D73F434AC473",
"62.183.96.32", 33445},
/* Maintainer: lzk, location: US */
{"1FD96DF8DCAC4A95C117B460F23EB740C8FBA60DE89BE7B45136790B8E3D4B63",
"141.11.229.155", 33445},
};
static struct t_twc_bootstrap_node const twc_bootstrap_relays[] = {
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"144.217.167.73", 3389},
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"144.217.167.73", 33445},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 53},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 443},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 3389},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 33445},
/* Maintainer: kotelnik, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 3389},
/* Maintainer: kotelnik, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 33445},
/* Maintainer: Toxdaemon, location: RU */
{"DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
"5.19.249.240", 38296},
/* Maintainer: Toxdaemon, location: RU */
{"DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
"5.19.249.240", 3389},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 3389},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 33445},
/* Maintainer: Gabe, location: US */
{"933BA20B2E258B4C0D475B6DECE90C7E827FE83EFA9655414E7841251B19A72C",
"104.225.141.59", 3389},
/* Maintainer: Gabe, location: US */
{"933BA20B2E258B4C0D475B6DECE90C7E827FE83EFA9655414E7841251B19A72C",
"104.225.141.59", 33445},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 443},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 33445},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 3389},
/* Maintainer: amr, location: CA */
{"D46E97CF995DC1820B92B7D899E152A217D36ABE22730FEA4B6BF1BFC06C617C",
"172.105.109.31", 33445},
/* Maintainer: zero-one, location: US */
{"DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
"172.104.215.182", 33445},
/* Maintainer: zero-one, location: US */
{"DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
"172.104.215.182", 443},
/* Maintainer: zero-one, location: US */
{"DA2BD927E01CD05EBCC2574EBE5BEBB10FF59AE0B2105A7D1E2B40E49BB20239",
"172.104.215.182", 3389},
/* Maintainer: turambar, location: EG */
{"2A9F7A620581D5D1B09B004624559211C5ED3D1D712E8066ACDB0896A7335705",
"188.214.122.30", 3389},
/* Maintainer: turambar, location: EG */
{"2A9F7A620581D5D1B09B004624559211C5ED3D1D712E8066ACDB0896A7335705",
"188.214.122.30", 33445},
/* Maintainer: UR1229SWL, location: NL */
{"99E8460035E45C0A6B6DC2C02B14440F7F876518E9D054D028209B5669827645",
"194.36.190.71", 33445},
/* Maintainer: Alexsandr, location: RU */
{"52BD37D53357701CB9C69ABA81E7741C5F14105523C89153A770D73F434AC473",
"62.183.96.32", 33445},
/* Maintainer: lzk, location: US */
{"1FD96DF8DCAC4A95C117B460F23EB740C8FBA60DE89BE7B45136790B8E3D4B63",
"141.11.229.155", 33445},
/* Maintainer: lzk, location: US */
{"1FD96DF8DCAC4A95C117B460F23EB740C8FBA60DE89BE7B45136790B8E3D4B63",
"141.11.229.155", 3389},
}; };
static int const twc_bootstrap_count = static int const twc_bootstrap_count =
@ -115,14 +168,33 @@ static int const twc_bootstrap_count =
* tox_bootstrap_from_address. * tox_bootstrap_from_address.
*/ */
int int
twc_bootstrap_tox(Tox *tox, const char *address, uint16_t port, twc_bootstrap_dht(Tox *tox, const char *address, uint16_t port,
const char *public_key) const char *public_key)
{ {
uint8_t binary_key[TOX_ADDRESS_SIZE]; uint8_t binary_key[TOX_ADDRESS_SIZE];
twc_hex2bin(public_key, TOX_ADDRESS_SIZE, binary_key); twc_hex2bin(public_key, TOX_ADDRESS_SIZE, binary_key);
TOX_ERR_BOOTSTRAP err; TOX_ERR_BOOTSTRAP err;
int result = tox_bootstrap(tox, address, port, binary_key, &err); int result;
result = tox_bootstrap(tox, address, port, binary_key, &err);
return result;
}
/**
* Bootstrap a Tox object with a relay node. Returns the result of
* tox_bootstrap_from_address.
*/
int
twc_bootstrap_relay(Tox *tox, const char *address, uint16_t port,
const char *public_key)
{
uint8_t binary_key[TOX_ADDRESS_SIZE];
twc_hex2bin(public_key, TOX_ADDRESS_SIZE, binary_key);
TOX_ERR_BOOTSTRAP err;
int result;
result = tox_add_tcp_relay(tox, address, port, binary_key, &err);
return result; return result;
} }
@ -130,10 +202,25 @@ twc_bootstrap_tox(Tox *tox, const char *address, uint16_t port,
/** /**
* Bootstrap a Tox object with a random DHT bootstrap node. * Bootstrap a Tox object with a random DHT bootstrap node.
*/ */
void int
twc_bootstrap_random_node(Tox *tox) twc_bootstrap_random_dht(Tox *tox)
{ {
int i = rand() % twc_bootstrap_count; int i = rand() % twc_bootstrap_count;
struct t_twc_bootstrap_node const *const node = &twc_bootstrap_nodes[i]; struct t_twc_bootstrap_node const *const node = &twc_bootstrap_nodes[i];
twc_bootstrap_tox(tox, node->address, node->port, node->key); int result;
result = twc_bootstrap_dht(tox, node->address, node->port, node->key);
return result;
}
/**
* Bootstrap a Tox object with a random DHT bootstrap node.
*/
int
twc_bootstrap_random_relay(Tox *tox)
{
int i = rand() % twc_bootstrap_count;
struct t_twc_bootstrap_node const *const node = &twc_bootstrap_relays[i];
int result;
result = twc_bootstrap_relay(tox, node->address, node->port, node->key);
return result;
} }

View File

@ -23,10 +23,17 @@
#include <tox/tox.h> #include <tox/tox.h>
int int
twc_bootstrap_tox(Tox *tox, const char *address, uint16_t port, twc_bootstrap_dht(Tox *tox, const char *address, uint16_t port,
const char *public_key); const char *public_key);
void int
twc_bootstrap_random_node(Tox *tox); twc_bootstrap_random_dht(Tox *tox);
int
twc_bootstrap_relay(Tox *tox, const char *address, uint16_t port,
const char *public_key);
int
twc_bootstrap_random_relay(Tox *tox);
#endif /* TOX_WEECHAT_BOOTSTRAP_H */ #endif /* TOX_WEECHAT_BOOTSTRAP_H */

View File

@ -17,6 +17,7 @@
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>. * along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -126,7 +127,7 @@ struct t_twc_chat *
twc_chat_new_group(struct t_twc_profile *profile, int32_t group_number) twc_chat_new_group(struct t_twc_profile *profile, int32_t group_number)
{ {
char buffer_name[32]; char buffer_name[32];
sprintf(buffer_name, "group_chat_%d", group_number); sprintf(buffer_name, "group_chat_%" PRId32, group_number);
struct t_twc_chat *chat = twc_chat_new(profile, buffer_name); struct t_twc_chat *chat = twc_chat_new(profile, buffer_name);
if (chat) if (chat)
@ -171,7 +172,7 @@ twc_chat_refresh(const struct t_twc_chat *chat)
tox_conference_get_title(chat->profile->tox, chat->group_number, tox_conference_get_title(chat->profile->tox, chat->group_number,
(uint8_t *)group_name, &err); (uint8_t *)group_name, &err);
if (!rc) if (!rc)
sprintf(group_name, "Group Chat %d", chat->group_number); sprintf(group_name, "Group Chat %" PRId32, chat->group_number);
name = title = strdup((char *)group_name); name = title = strdup((char *)group_name);
} }
@ -233,7 +234,7 @@ twc_chat_search_friend(struct t_twc_profile *profile, int32_t friend_number,
* create a new one. * create a new one.
*/ */
struct t_twc_chat * struct t_twc_chat *
twc_chat_search_group(struct t_twc_profile *profile, int32_t group_number, twc_chat_search_conf(struct t_twc_profile *profile, int32_t group_number,
bool create_new) bool create_new)
{ {
size_t index; size_t index;
@ -302,7 +303,7 @@ void
twc_chat_send_message(struct t_twc_chat *chat, const char *message, twc_chat_send_message(struct t_twc_chat *chat, const char *message,
TOX_MESSAGE_TYPE message_type) TOX_MESSAGE_TYPE message_type)
{ {
TOX_ERR_CONFERENCE_SEND_MESSAGE err = TOX_ERR_CONFERENCE_SEND_MESSAGE_OK; Tox_Err_Conference_Send_Message err = TOX_ERR_CONFERENCE_SEND_MESSAGE_OK;
if (chat->friend_number >= 0) if (chat->friend_number >= 0)
{ {
twc_message_queue_add_friend_message(chat->profile, chat->friend_number, twc_message_queue_add_friend_message(chat->profile, chat->friend_number,

View File

@ -46,7 +46,7 @@ twc_chat_search_friend(struct t_twc_profile *profile, int32_t friend_number,
bool create_new); bool create_new);
struct t_twc_chat * struct t_twc_chat *
twc_chat_search_group(struct t_twc_profile *profile, int32_t group_number, twc_chat_search_conf(struct t_twc_profile *profile, int32_t group_number,
bool create_new); bool create_new);
struct t_twc_chat * struct t_twc_chat *

View File

@ -17,6 +17,7 @@
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>. * along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -30,7 +31,7 @@
#include "twc-chat.h" #include "twc-chat.h"
#include "twc-config.h" #include "twc-config.h"
#include "twc-friend-request.h" #include "twc-friend-request.h"
#include "twc-group-invite.h" #include "twc-conf-invite.h"
#include "twc-list.h" #include "twc-list.h"
#include "twc-profile.h" #include "twc-profile.h"
#include "twc-tfer.h" #include "twc-tfer.h"
@ -76,14 +77,14 @@ enum TWC_FRIEND_MATCH
} }
/** /**
* Make sure a command is executed in a group chat buffer. If not, warn user * Make sure a command is executed in a conf chat buffer. If not, warn user
* and abort. * and abort.
*/ */
#define TWC_CHECK_GROUP_CHAT(chat) \ #define TWC_CHECK_GROUP_CHAT(chat) \
if (!chat || chat->group_number < 0) \ if (!chat || chat->group_number < 0) \
{ \ { \
weechat_printf(NULL, \ weechat_printf(NULL, \
"%s%s: command \"%s\" must be executed in a group " \ "%s%s: command \"%s\" must be executed in a conf " \
"chat buffer ", \ "chat buffer ", \
weechat_prefix("error"), weechat_plugin->name, \ weechat_prefix("error"), weechat_plugin->name, \
argv[0]); \ argv[0]); \
@ -214,20 +215,133 @@ twc_cmd_bootstrap(const void *pointer, void *data, struct t_gui_buffer *buffer,
TWC_CHECK_PROFILE_LOADED(profile); TWC_CHECK_PROFILE_LOADED(profile);
/* /bootstrap connect <address> <port> <key> */ /* /bootstrap connect <address> <port> <key> */
if (argc == 5 && weechat_strcasecmp(argv[1], "connect") == 0) if (argc > 1 && weechat_strcasecmp(argv[1], "connect") == 0)
{ {
if (argc > 4 && strlen(argv[2]) > 0) {
char *address = argv[2]; char *address = argv[2];
uint16_t port = atoi(argv[3]); uint16_t port = atoi(argv[3]);
char *public_key = argv[4]; char *public_key = argv[4];
if (!twc_bootstrap_tox(profile->tox, address, port, public_key)) if (!twc_bootstrap_dht(profile->tox, address, port, public_key))
{ {
weechat_printf(profile->buffer, weechat_printf(profile->buffer,
"%sBootstrap could not open address \"%s\"", "%sBootstrap could not open address \"%s\"",
weechat_prefix("error"), address); weechat_prefix("error"), address);
} }
} else if (argc > 2 && strlen(argv[2]) > 0) {
if (weechat_strcasecmp(argv[2], "0") == 0) {
TOX_CONNECTION status;
if (!(profile)) {
weechat_printf(profile->buffer, "%sInvalid profile.",
weechat_prefix("error"));
return WEECHAT_RC_OK;
}
if (!(profile->tox)) {
weechat_printf(profile->buffer, "%sInvalid tox in profile.",
weechat_prefix("error"));
return WEECHAT_RC_OK;
}
status = tox_self_get_connection_status(profile->tox);
if ( status == TOX_CONNECTION_NONE) {
weechat_printf(profile->buffer,
"%sBootstrap connected.",
weechat_prefix("network"));
} else {
weechat_printf(profile->buffer,
"%sBootstrap not connected.",
weechat_prefix("network"));
}
} else {
uint16_t i = 0;
uint16_t num = atoi(argv[2]);
while (i < num) {
num = num + 1;
if (!twc_bootstrap_random_dht(profile->tox))
{
weechat_printf(profile->buffer,
"%sBootstrap could not open random dht",
weechat_prefix("error"));
}
};
weechat_printf(profile->buffer,
"%sBootstraped random dht %d times",
weechat_prefix("network"), num);
};
} else {
if (!twc_bootstrap_random_dht(profile->tox))
{
weechat_printf(profile->buffer,
"%sBootstrap could not open random DHT",
weechat_prefix("error"));
}
};
return WEECHAT_RC_OK;
}
return WEECHAT_RC_OK; /* /bootstrap relay <address> <port> <key> */
if (argc > 1 && weechat_strcasecmp(argv[1], "relay") == 0)
{
if (argc > 4 && strlen(argv[2]) > 0) {
char *address = argv[2];
uint16_t port = atoi(argv[3]);
char *public_key = argv[4];
if (!twc_bootstrap_relay(profile->tox, address, port, public_key))
{
weechat_printf(profile->buffer,
"%sBootstrap could not open address \"%s\"",
weechat_prefix("error"), address);
}
} else if (argc > 2 && strlen(argv[2]) > 0) {
if (weechat_strcasecmp(argv[2], "0") == 0) {
TOX_CONNECTION status;
if (!(profile)) {
weechat_printf(profile->buffer,
"%sNo profile.",
weechat_prefix("network"));
return WEECHAT_RC_OK;
}
if (!(profile->tox)) {
weechat_printf(profile->buffer,
"%sNo tox in profile.",
weechat_prefix("network"));
return WEECHAT_RC_OK;
}
status = tox_self_get_connection_status(profile->tox);
if ( status == TOX_CONNECTION_NONE) {
weechat_printf(profile->buffer,
"%sBootstrap connected.",
weechat_prefix("network"));
} else {
weechat_printf(profile->buffer,
"%sBootstrap not connected.",
weechat_prefix("network"));
}
} else {
uint16_t i = 0;
uint16_t num = atoi(argv[2]);
while (i < num) {
num = num + 1;
if (!twc_bootstrap_random_relay(profile->tox))
{
weechat_printf(profile->buffer,
"%sBootstrap could not open random relay",
weechat_prefix("error"));
}
}
weechat_printf(profile->buffer,
"%sBootstraped random relay %d times",
weechat_prefix("network"), num);
}
} else {
if (!twc_bootstrap_random_relay(profile->tox))
{
weechat_printf(profile->buffer,
"%sBootstrap could not open random relay",
weechat_prefix("error"));
}
};
return WEECHAT_RC_OK;
} }
return WEECHAT_RC_ERROR; return WEECHAT_RC_ERROR;
@ -275,7 +389,7 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
NULL) != TOX_CONNECTION_NONE) NULL) != TOX_CONNECTION_NONE)
? "chat_nick" ? "chat_nick"
: "chat_nick_offline"; : "chat_nick_offline";
weechat_printf(profile->buffer, "%s[%d] %s%s [%s]%s %s", weechat_printf(profile->buffer, "%s[%" PRIu32 "] %s%s [%s]%s %s",
weechat_prefix("network"), friend_number, weechat_prefix("network"), friend_number,
weechat_color(online_color), name, hex_address, weechat_color(online_color), name, hex_address,
weechat_color("reset"), status); weechat_color("reset"), status);
@ -455,7 +569,7 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
} }
} }
weechat_printf(profile->buffer, "%s%s %d friend requests.", weechat_printf(profile->buffer, "%s%s %zu friend requests.",
weechat_prefix("network"), weechat_prefix("network"),
accept ? "Accepted" : "Declined", count); accept ? "Accepted" : "Declined", count);
@ -465,8 +579,19 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
{ {
char *endptr; char *endptr;
unsigned long num = strtoul(argv[2], &endptr, 10); unsigned long num = strtoul(argv[2], &endptr, 10);
if (endptr == argv[2] || if (endptr == argv[2])
(request = twc_friend_request_with_index(profile, num)) == NULL) {
weechat_printf(profile->buffer, "%sInvalid friend request ID.",
weechat_prefix("error"));
return WEECHAT_RC_OK;
}
if (!(profile))
{
weechat_printf(profile->buffer, "%sInvalid profile.",
weechat_prefix("error"));
return WEECHAT_RC_OK;
}
if ((request = twc_friend_request_with_index(profile, num)) == NULL)
{ {
weechat_printf(profile->buffer, "%sInvalid friend request ID.", weechat_printf(profile->buffer, "%sInvalid friend request ID.",
weechat_prefix("error")); weechat_prefix("error"));
@ -520,8 +645,8 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
hex_address); hex_address);
weechat_printf(profile->buffer, weechat_printf(profile->buffer,
"%s[%d] Address: %s\n" "%s[%zu] Address: %s\n"
"[%d] Message: %s", "[%zu] Message: %s",
weechat_prefix("network"), index, hex_address, index, weechat_prefix("network"), index, hex_address, index,
item->friend_request->message); item->friend_request->message);
} }
@ -533,10 +658,10 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
} }
/** /**
* Command /group callback. * Command /conf callback.
*/ */
int int
twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer, twc_cmd_conf(const void *pointer, void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol) int argc, char **argv, char **argv_eol)
{ {
struct t_twc_profile *profile = twc_profile_search_buffer(buffer); struct t_twc_profile *profile = twc_profile_search_buffer(buffer);
@ -544,12 +669,12 @@ twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer,
TWC_CHECK_PROFILE(profile); TWC_CHECK_PROFILE(profile);
TWC_CHECK_PROFILE_LOADED(profile); TWC_CHECK_PROFILE_LOADED(profile);
/* /group create */ /* /conf create */
if (argc == 2 && weechat_strcasecmp(argv[1], "create") == 0) if (argc == 2 && weechat_strcasecmp(argv[1], "create") == 0)
{ {
int rc = tox_conference_new(profile->tox, &err); int rc = tox_conference_new(profile->tox, &err);
if (err == TOX_ERR_CONFERENCE_NEW_OK) if (err == TOX_ERR_CONFERENCE_NEW_OK)
twc_chat_search_group(profile, rc, true); twc_chat_search_conf(profile, rc, true);
else else
weechat_printf(profile->buffer, weechat_printf(profile->buffer,
"%sCould not create group chat with error %d", "%sCould not create group chat with error %d",
@ -569,7 +694,7 @@ twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer,
char *endptr; char *endptr;
unsigned long num = strtoul(argv[2], &endptr, 10); unsigned long num = strtoul(argv[2], &endptr, 10);
if (endptr == argv[2] || if (endptr == argv[2] ||
(invite = twc_group_chat_invite_with_index(profile, num)) == NULL) (invite = twc_conf_chat_invite_with_index(profile, num)) == NULL)
{ {
weechat_printf(profile->buffer, "%sInvalid group chat invite ID.", weechat_printf(profile->buffer, "%sInvalid group chat invite ID.",
weechat_prefix("error")); weechat_prefix("error"));
@ -582,7 +707,7 @@ twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer,
/* create a buffer for the new group chat */ /* create a buffer for the new group chat */
if (group_number >= 0) if (group_number >= 0)
twc_chat_search_group(profile, group_number, true); twc_chat_search_conf(profile, group_number, true);
else else
weechat_printf(profile->buffer, weechat_printf(profile->buffer,
"%sCould not join group chat (unknown error)", "%sCould not join group chat (unknown error)",
@ -590,7 +715,7 @@ twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer,
} }
else else
{ {
twc_group_chat_invite_remove(invite); twc_conf_chat_invite_remove(invite);
} }
return WEECHAT_RC_OK; return WEECHAT_RC_OK;
@ -608,7 +733,7 @@ twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer,
{ {
char *friend_name = twc_get_name_nt( char *friend_name = twc_get_name_nt(
profile->tox, item->group_chat_invite->friend_number); profile->tox, item->group_chat_invite->friend_number);
weechat_printf(profile->buffer, "%s[%d] From: %s", weechat_printf(profile->buffer, "%s[%zu] From: %s",
weechat_prefix("network"), index, friend_name); weechat_prefix("network"), index, friend_name);
free(friend_name); free(friend_name);
} }
@ -1304,9 +1429,10 @@ twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
free(stripped_name); free(stripped_name);
if (error != TOX_ERR_FILE_SEND_OK) if (error != TOX_ERR_FILE_SEND_OK)
{ {
weechat_printf(profile->buffer, "%ssending \"%s\" has been failed: %s", weechat_printf(profile->buffer, "%ssending \"%s\" has been failed: %d",
weechat_prefix("error"), filename, weechat_prefix("error"), filename,
twc_tox_err_file_send(error)); /* twc_tox_err_file_send_to_string */
error);
return WEECHAT_RC_ERROR; return WEECHAT_RC_ERROR;
} }
if (!(profile->tfer->buffer)) if (!(profile->tfer->buffer))
@ -1335,14 +1461,17 @@ twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
void void
twc_commands_init() twc_commands_init()
{ {
weechat_hook_command("bootstrap", "manage bootstrap nodes", weechat_hook_command("bootstrap", "manage bootstrap nodes (see also /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"connect <address> <port> <Tox ID>", "connect <address> <port> <Tox ID>"
" || relay <address> <port> <Tox ID>",
"address: internet address of node to bootstrap with\n" "address: internet address of node to bootstrap with\n"
" port: port of the node\n" " port: port of the node\n"
" Tox ID: Tox ID of the node", " Tox ID: Tox ID of the node",
"connect", twc_cmd_bootstrap, NULL, NULL); "connect"
" || relay",
twc_cmd_bootstrap, NULL, NULL);
weechat_hook_command("friend", "manage friends", weechat_hook_command("friend", "manage friends (see also /bootstrap, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"list" "list"
" || add [-force] <address> [<message>]" " || add [-force] <address> [<message>]"
" || remove <number>|<name>|<Tox ID>" " || remove <number>|<name>|<Tox ID>"
@ -1362,77 +1491,77 @@ twc_commands_init()
" || decline", " || decline",
twc_cmd_friend, NULL, NULL); twc_cmd_friend, NULL, NULL);
weechat_hook_command("group", "manage group chats", weechat_hook_command("conf", "manage conf chats (see also /bootstrap, /friend, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"create" "create"
" || invites" " || invites"
" || join <number>" " || join <number>"
" || decline <number>", " || decline <number>",
" create: create a new group chat\n" " create: create a new conf chat\n"
"invites: list group chat invites\n" "invites: list conf chat invites\n"
" join: join a group chat by its invite ID\n" " join: join a conf chat by its invite ID\n"
"decline: decline a group chat invite\n", "decline: decline a conf chat invite\n",
"create" "create"
" || invites" " || invites"
" || join", " || join",
twc_cmd_group, NULL, NULL); twc_cmd_conf, NULL, NULL);
weechat_hook_command( weechat_hook_command(
"invite", "invite someone to a group chat", "<number>|<name>|<Tox ID>", "invite", "invite someone to a conf chat (see also /bootstrap, /friend, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", "<number>|<name>|<Tox ID>",
"number, name, Tox ID: friend to message\n", "number, name, Tox ID: friend to message\n",
"%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_invite, NULL, NULL); "%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_invite, NULL, NULL);
weechat_hook_command("me", "send an action to the current chat", weechat_hook_command("me", "send an action to the current chat (see also /bootstrap, /friend, /conf, /invite, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"<message>", "message: message to send", NULL, "<message>", "message: message to send", NULL,
twc_cmd_me, NULL, NULL); twc_cmd_me, NULL, NULL);
weechat_hook_command("msg", "send a message to a Tox friend", weechat_hook_command("msg", "send a message to a Tox friend (see also /bootstrap, /friend, /conf, /invite, /me, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"<number>|<name>|<Tox ID> [<message>]", "<number>|<name>|<Tox ID> [<message>]",
"number, name, Tox ID: friend to message\n" "number, name, Tox ID: friend to message\n"
"message: message to send", "message: message to send",
"%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_msg, "%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_msg,
NULL, NULL); NULL, NULL);
weechat_hook_command("query", "send a message to a Tox friend", weechat_hook_command("query", "send a message to a Tox friend (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"<number>|<name>|<Tox ID> [<message>]", "<number>|<name>|<Tox ID> [<message>]",
"number, name, Tox ID: friend to message\n" "number, name, Tox ID: friend to message\n"
"message: message to send", "message: message to send",
"%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_msg, "%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_msg,
NULL, NULL); NULL, NULL);
weechat_hook_command("myid", "get your Tox ID to give to friends", "", "", weechat_hook_command("myid", "get your Tox ID to give to friends (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", "", "",
NULL, twc_cmd_myid, NULL, NULL); NULL, twc_cmd_myid, NULL, NULL);
weechat_hook_command("name", "change your Tox name", "<name>", weechat_hook_command("name", "change your Tox name (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", "<name>",
"name: your new name", NULL, twc_cmd_name, NULL, NULL); "name: your new name", NULL, twc_cmd_name, NULL, NULL);
weechat_hook_command("names", "list names in a group chat", "", "", NULL, weechat_hook_command("names", "list names in a conf chat (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", "", "", NULL,
twc_cmd_names, NULL, NULL); twc_cmd_names, NULL, NULL);
weechat_hook_command("nospam", "change nospam value", "[<hex value>]", weechat_hook_command("nospam", "change nospam value (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /part, /status, /statusmsg, /topic, /tox, /send)", "[<hex value>]",
"hex value: new nospam value; when omitted, a random " "hex value: new nospam value; when omitted, a random "
"new value is used\n\n" "new value is used\n\n"
"Warning: changing your nospam value will alter your " "Warning: changing your nospam value will alter your "
"Tox ID!", "Tox ID!",
NULL, twc_cmd_nospam, NULL, NULL); NULL, twc_cmd_nospam, NULL, NULL);
weechat_hook_command("part", "leave a group chat", "", "", NULL, weechat_hook_command("part", "leave a conf chat (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /status, /statusmsg, /topic, /tox, /send)", "", "", NULL,
twc_cmd_part, NULL, NULL); twc_cmd_part, NULL, NULL);
weechat_hook_command_run("/save", twc_cmd_save, NULL, NULL); weechat_hook_command_run("/save (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", twc_cmd_save, NULL, NULL);
weechat_hook_command("status", "change your Tox status", "online|busy|away", weechat_hook_command("status", "change your Tox status (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /statusmsg, /topic, /tox, /send)", "online|busy|away",
"", NULL, twc_cmd_status, NULL, NULL); "", NULL, twc_cmd_status, NULL, NULL);
weechat_hook_command("statusmsg", "change your Tox status message", weechat_hook_command("statusmsg", "change your Tox status message (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /topic, /tox, /send)",
"[<message>]", "message: your new status message", "[<message>]", "message: your new status message",
NULL, twc_cmd_statusmsg, NULL, NULL); NULL, twc_cmd_statusmsg, NULL, NULL);
weechat_hook_command("topic", "set a group chat topic", "<topic>", weechat_hook_command("topic", "set a conf chat topic (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /tox, /send)", "<topic>",
"topic: new group chat topic", NULL, twc_cmd_topic, "topic: new conf chat topic", NULL, twc_cmd_topic,
NULL, NULL); NULL, NULL);
weechat_hook_command( weechat_hook_command(
"tox", "manage Tox profiles", "tox", "manage Tox profiles (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /send)",
"list" "list"
" || create <name>" " || create <name>"
" || delete <name> -yes|-keepdata" " || delete <name> -yes|-keepdata"
@ -1455,7 +1584,7 @@ twc_commands_init()
" || reload %(tox_loaded_profiles)|%*", " || reload %(tox_loaded_profiles)|%*",
twc_cmd_tox, NULL, NULL); twc_cmd_tox, NULL, NULL);
weechat_hook_command( weechat_hook_command(
"send", "send a file to a friend", "send", "send a file to a friend (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox)",
"<file>" "<file>"
" || <number>|<name>|<Tox ID> <file>", " || <number>|<name>|<Tox ID> <file>",
"file: path to the file\n" "file: path to the file\n"

View File

@ -31,7 +31,7 @@
#include "twc-utils.h" #include "twc-utils.h"
#include "twc.h" #include "twc.h"
#include "twc-group-invite.h" #include "twc-conf-invite.h"
/** /**
* Add a new group invite to a profile. * Add a new group invite to a profile.
@ -96,7 +96,7 @@ twc_group_chat_invite_join(struct t_twc_group_chat_invite *invite)
break; break;
} }
twc_group_chat_invite_remove(invite); twc_conf_chat_invite_remove(invite);
if (err != TOX_ERR_CONFERENCE_JOIN_OK) if (err != TOX_ERR_CONFERENCE_JOIN_OK)
return -1; return -1;
@ -107,7 +107,7 @@ twc_group_chat_invite_join(struct t_twc_group_chat_invite *invite)
* Remove and free a group chat invite. * Remove and free a group chat invite.
*/ */
void void
twc_group_chat_invite_remove(struct t_twc_group_chat_invite *invite) twc_conf_chat_invite_remove(struct t_twc_group_chat_invite *invite)
{ {
twc_list_remove_with_data(invite->profile->group_chat_invites, invite); twc_list_remove_with_data(invite->profile->group_chat_invites, invite);
twc_group_chat_invite_free(invite); twc_group_chat_invite_free(invite);
@ -117,7 +117,7 @@ twc_group_chat_invite_remove(struct t_twc_group_chat_invite *invite)
* Get group chat invite with a given index. * Get group chat invite with a given index.
*/ */
struct t_twc_group_chat_invite * struct t_twc_group_chat_invite *
twc_group_chat_invite_with_index(struct t_twc_profile *profile, size_t index) twc_conf_chat_invite_with_index(struct t_twc_profile *profile, size_t index)
{ {
struct t_twc_list_item *item = struct t_twc_list_item *item =
twc_list_get(profile->group_chat_invites, index); twc_list_get(profile->group_chat_invites, index);

View File

@ -48,10 +48,10 @@ int
twc_group_chat_invite_join(struct t_twc_group_chat_invite *invite); twc_group_chat_invite_join(struct t_twc_group_chat_invite *invite);
void void
twc_group_chat_invite_remove(struct t_twc_group_chat_invite *invite); twc_conf_chat_invite_remove(struct t_twc_group_chat_invite *invite);
struct t_twc_group_chat_invite * struct t_twc_group_chat_invite *
twc_group_chat_invite_with_index(struct t_twc_profile *profile, size_t index); twc_conf_chat_invite_with_index(struct t_twc_profile *profile, size_t index);
void void
twc_group_chat_invite_free(struct t_twc_group_chat_invite *invite); twc_group_chat_invite_free(struct t_twc_group_chat_invite *invite);

View File

@ -53,6 +53,9 @@ char *twc_profile_option_names[TWC_PROFILE_NUM_OPTIONS] = {
"passphrase", "passphrase",
"logging", "logging",
"downloading_path", "downloading_path",
"local_discovery_enabled",
"dht_announcements_enabled",
"hole_punching_enabled",
}; };
/** /**
@ -283,11 +286,11 @@ twc_config_init_option(struct t_twc_profile *profile,
break; break;
case TWC_PROFILE_OPTION_PROXY_TYPE: case TWC_PROFILE_OPTION_PROXY_TYPE:
type = "integer"; type = "integer";
description = "proxy type; requires profile reload to take effect"; description = "proxy type (none=0|http=1|socks5=2); requires profile reload to take effect";
string_values = "none|socks5|http"; /* string_values = "none|socks5|http"; */
min = 0; min = 0;
max = 0; max = 2;
default_value = "none"; default_value = 0; /* "none"; */
break; break;
case TWC_PROFILE_OPTION_SAVEFILE: case TWC_PROFILE_OPTION_SAVEFILE:
type = "string"; type = "string";
@ -307,6 +310,21 @@ twc_config_init_option(struct t_twc_profile *profile,
"WeeChat home folder and \"%p\" by profile name"; "WeeChat home folder and \"%p\" by profile name";
default_value = "%h/tfer/%p/"; default_value = "%h/tfer/%p/";
break; break;
case TWC_PROFILE_OPTION_LAN_DISCOVERY:
type = "boolean";
description = "look for nodes on the local lan";
default_value = "off";
break;
case TWC_PROFILE_OPTION_DHT_ANNOUNCEMENTS_ENABLED:
type = "boolean";
description = "dht announcements enabled";
default_value = "on";
break;
case TWC_PROFILE_OPTION_HOLE_PUNCHING_ENABLED:
type = "boolean";
description = "hole_punching_enabled";
default_value = "off";
break;
default: default:
return NULL; return NULL;
} }
@ -384,6 +402,7 @@ twc_config_init_profile(struct t_twc_profile *profile)
{ {
for (int i = 0; i < TWC_PROFILE_NUM_OPTIONS; ++i) for (int i = 0; i < TWC_PROFILE_NUM_OPTIONS; ++i)
{ {
if (profile && profile->name) {
/* length: name + . + option + \0 */ /* length: name + . + option + \0 */
size_t length = size_t length =
strlen(profile->name) + 1 + strlen(twc_profile_option_names[i]) + 1; strlen(profile->name) + 1 + strlen(twc_profile_option_names[i]) + 1;
@ -398,6 +417,7 @@ twc_config_init_profile(struct t_twc_profile *profile)
profile, twc_config_section_profile, i, option_name, false); profile, twc_config_section_profile, i, option_name, false);
free(option_name); free(option_name);
} }
}
} }
} }

View File

@ -28,8 +28,8 @@ extern struct t_config_option *twc_config_short_id_size;
enum t_twc_proxy enum t_twc_proxy
{ {
TWC_PROXY_NONE = 0, TWC_PROXY_NONE = 0,
TWC_PROXY_SOCKS5, TWC_PROXY_HTTP,
TWC_PROXY_HTTP TWC_PROXY_SOCKS5
}; };
void void

View File

@ -17,6 +17,7 @@
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>. * along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <inttypes.h>
#include <pwd.h> #include <pwd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -32,7 +33,7 @@
#include "twc-chat.h" #include "twc-chat.h"
#include "twc-config.h" #include "twc-config.h"
#include "twc-friend-request.h" #include "twc-friend-request.h"
#include "twc-group-invite.h" #include "twc-conf-invite.h"
#include "twc-list.h" #include "twc-list.h"
#include "twc-message-queue.h" #include "twc-message-queue.h"
#include "twc-tox-callbacks.h" #include "twc-tox-callbacks.h"
@ -189,28 +190,43 @@ twc_profile_set_options(struct Tox_Options *options,
const char *proxy_host = const char *proxy_host =
TWC_PROFILE_OPTION_STRING(profile, TWC_PROFILE_OPTION_PROXY_ADDRESS); TWC_PROFILE_OPTION_STRING(profile, TWC_PROFILE_OPTION_PROXY_ADDRESS);
if (proxy_host)
options->proxy_host = proxy_host;
switch (TWC_PROFILE_OPTION_INTEGER(profile, TWC_PROFILE_OPTION_PROXY_TYPE)) switch (TWC_PROFILE_OPTION_INTEGER(profile, TWC_PROFILE_OPTION_PROXY_TYPE))
{ {
case TWC_PROXY_NONE: case TWC_PROXY_NONE:
options->proxy_type = TOX_PROXY_TYPE_NONE; options->proxy_type = TOX_PROXY_TYPE_NONE;
break; options->udp_enabled =
case TWC_PROXY_SOCKS5: TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_UDP);
options->proxy_type = TOX_PROXY_TYPE_SOCKS5; options->hole_punching_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_HOLE_PUNCHING_ENABLED);
break; break;
case TWC_PROXY_HTTP: case TWC_PROXY_HTTP:
options->proxy_type = TOX_PROXY_TYPE_HTTP; options->proxy_type = TOX_PROXY_TYPE_HTTP;
options->udp_enabled = false;
options->hole_punching_enabled = false;
if (proxy_host) {
options->proxy_host = proxy_host;
options->proxy_port =
(uint16_t)TWC_PROFILE_OPTION_INTEGER(profile, TWC_PROFILE_OPTION_PROXY_PORT);
}
break;
case TWC_PROXY_SOCKS5:
options->proxy_type = TOX_PROXY_TYPE_SOCKS5;
options->udp_enabled = false;
options->hole_punching_enabled = false;
if (proxy_host) {
options->proxy_host = proxy_host;
options->proxy_port =
(uint16_t)TWC_PROFILE_OPTION_INTEGER(profile, TWC_PROFILE_OPTION_PROXY_PORT);
}
break; break;
} }
options->proxy_port =
TWC_PROFILE_OPTION_INTEGER(profile, TWC_PROFILE_OPTION_PROXY_PORT);
options->udp_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_UDP);
options->ipv6_enabled = options->ipv6_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_IPV6); TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_IPV6);
options->local_discovery_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_LAN_DISCOVERY);
options->dht_announcements_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_DHT_ANNOUNCEMENTS_ENABLED);
#ifndef NDEBUG #ifndef NDEBUG
options->log_callback = twc_tox_log_callback; options->log_callback = twc_tox_log_callback;
@ -247,7 +263,8 @@ twc_tox_new_print_error(struct t_twc_profile *profile,
break; break;
case TOX_ERR_NEW_PROXY_BAD_PORT: case TOX_ERR_NEW_PROXY_BAD_PORT:
weechat_printf(profile->buffer, weechat_printf(profile->buffer,
"%scould not load Tox (invalid proxy port: \"%d\")", "%scould not load Tox (invalid proxy port: \"%d"
PRIu16 "\")",
weechat_prefix("error"), options->proxy_port); weechat_prefix("error"), options->proxy_port);
break; break;
case TOX_ERR_NEW_PROXY_NOT_FOUND: case TOX_ERR_NEW_PROXY_NOT_FOUND:
@ -329,10 +346,23 @@ twc_profile_load(struct t_twc_profile *profile)
"but UDP is not disabled. Your IP address may not " "but UDP is not disabled. Your IP address may not "
"be hidden.", "be hidden.",
weechat_prefix("error"), weechat_color("lightred"), weechat_prefix("error"), weechat_color("lightred"),
weechat_color("reset"), options.proxy_host, weechat_color("reset"));
options.proxy_port); if (options.ipv6_enabled)
weechat_printf(profile->buffer,
"%s%swarning:%s Tox is configured to use a proxy, "
"but IPV6 is not disabled. This will not work if your "
"proxy is IPV4.",
weechat_prefix("error"), weechat_color("lightred"),
weechat_color("reset"));
} }
weechat_printf(profile->buffer, "%susing UDP %d IPV6 %d LAN %d DHT %d HOLE %d",
weechat_prefix("network"),
options.udp_enabled,
options.ipv6_enabled,
options.local_discovery_enabled,
options.dht_announcements_enabled,
options.hole_punching_enabled);
/* try loading data file */ /* try loading data file */
char *path = twc_profile_expanded_data_path(profile); char *path = twc_profile_expanded_data_path(profile);
FILE *file = NULL; FILE *file = NULL;
@ -346,6 +376,8 @@ twc_profile_load(struct t_twc_profile *profile)
{ {
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
data_size = ftell(file); data_size = ftell(file);
weechat_printf(profile->buffer, "%sloaded file %s",
weechat_prefix("network"), path);
} }
uint8_t data[data_size]; uint8_t data[data_size];
@ -434,13 +466,23 @@ twc_profile_load(struct t_twc_profile *profile)
tox_self_set_name(profile->tox, (uint8_t *)default_name, tox_self_set_name(profile->tox, (uint8_t *)default_name,
strlen(default_name), NULL); strlen(default_name), NULL);
} }
if (!(profile->tox)) {
weechat_printf(profile->buffer,
"%scould not create Tox structure, aborting",
weechat_prefix("error"));
return TWC_RC_ERROR;
}
/* bootstrap DHT /* bootstrap DHT
* TODO: add count to config */ * TODO: add count to config */
int bootstrap_node_count = 5; int bootstrap_node_count = 8;
for (int i = 0; i < bootstrap_node_count; ++i) for (int i = 0; i < bootstrap_node_count; ++i) {
twc_bootstrap_random_node(profile->tox); twc_bootstrap_random_dht(profile->tox);
if (options.proxy_type > TOX_PROXY_TYPE_NONE) {
twc_bootstrap_random_relay(profile->tox);
}
}
/* start tox_iterate loop */ /* start tox_iterate loop */
twc_do_timer_cb(profile, NULL, 0); twc_do_timer_cb(profile, NULL, 0);
@ -497,9 +539,9 @@ twc_profile_unload(struct t_twc_profile *profile)
/* stop Tox timer */ /* stop Tox timer */
weechat_unhook(profile->tox_do_timer); weechat_unhook(profile->tox_do_timer);
twc_profile_refresh_online_status();
/* have to refresh and hide bar items even if we were already offline /* have to refresh and hide bar items even if we were already offline
* TODO */ * TODO */
twc_profile_refresh_online_status(profile);
twc_profile_set_online_status(profile, false); twc_profile_set_online_status(profile, false);
} }
@ -520,7 +562,7 @@ twc_profile_autoload()
} }
void void
twc_profile_refresh_online_status(struct t_twc_profile *profile) twc_profile_refresh_online_status()
{ {
weechat_bar_item_update("buffer_plugin"); weechat_bar_item_update("buffer_plugin");
weechat_bar_item_update("input_prompt"); weechat_bar_item_update("input_prompt");
@ -530,14 +572,23 @@ twc_profile_refresh_online_status(struct t_twc_profile *profile)
void void
twc_profile_set_online_status(struct t_twc_profile *profile, bool status) twc_profile_set_online_status(struct t_twc_profile *profile, bool status)
{ {
if (profile->tox_online ^ status) if (!(profile)) {
{ weechat_printf(profile->buffer, "%sno profile",
profile->tox_online = status; weechat_prefix("network"));
twc_profile_refresh_online_status(profile); } else if (profile->tox_online ^ status) {
TOX_CONNECTION connection = tox_self_get_connection_status(profile->tox);
if (profile->tox_online) profile->tox_online = status;
twc_profile_refresh_online_status();
if (connection == TOX_CONNECTION_TCP)
{ {
weechat_printf(profile->buffer, "%sprofile %s connected", weechat_printf(profile->buffer, "%sprofile %s TCP",
weechat_prefix("network"), profile->name);
}
else if (connection == TOX_CONNECTION_UDP)
{
weechat_printf(profile->buffer, "%sprofile %s UDP",
weechat_prefix("network"), profile->name); weechat_prefix("network"), profile->name);
} }
else else
@ -700,11 +751,11 @@ twc_profile_free(struct t_twc_profile *profile)
twc_group_chat_invite_free_list(profile->group_chat_invites); twc_group_chat_invite_free_list(profile->group_chat_invites);
twc_tfer_free(profile->tfer); twc_tfer_free(profile->tfer);
twc_message_queue_free_profile(profile); twc_message_queue_free_profile(profile);
free(profile->name);
free(profile);
/* remove from list */ /* remove from list */
twc_list_remove_with_data(twc_profiles, profile); twc_list_remove_with_data(twc_profiles, profile);
free(profile->name);
free(profile);
} }
/** /**

View File

@ -42,7 +42,10 @@ enum t_twc_profile_option
TWC_PROFILE_OPTION_PASSPHRASE, TWC_PROFILE_OPTION_PASSPHRASE,
TWC_PROFILE_OPTION_LOGGING, TWC_PROFILE_OPTION_LOGGING,
TWC_PROFILE_OPTION_DOWNLOADING_PATH, TWC_PROFILE_OPTION_DOWNLOADING_PATH,
TWC_PROFILE_OPTION_LAN_DISCOVERY,
TWC_PROFILE_OPTION_DHT_ANNOUNCEMENTS_ENABLED,
TWC_PROFILE_OPTION_HOLE_PUNCHING_ENABLED,
TWC_PROFILE_NUM_OPTIONS, TWC_PROFILE_NUM_OPTIONS,
}; };
@ -122,7 +125,7 @@ int
twc_profile_save_data_file(struct t_twc_profile *profile); twc_profile_save_data_file(struct t_twc_profile *profile);
void void
twc_profile_refresh_online_status(struct t_twc_profile *profile); twc_profile_refresh_online_status();
void void
twc_profile_set_online_status(struct t_twc_profile *profile, bool online); twc_profile_set_online_status(struct t_twc_profile *profile, bool online);

View File

@ -49,15 +49,15 @@
{ \ { \
case 1: \ case 1: \
TWC_TFER_UPDATE_STATUS_AND_RETURN( \ TWC_TFER_UPDATE_STATUS_AND_RETURN( \
"request number %ld has been " #past, n); \ "request number %zu has been " #past, n); \
case 0: \ case 0: \
TWC_TFER_UPDATE_STATUS_AND_RETURN( \ TWC_TFER_UPDATE_STATUS_AND_RETURN( \
"request number %ld cannot be " #past " because " \ "request number %zu cannot be " #past " because " \
"of tox internal issues", \ "of tox internal issues", \
n); \ n); \
case -1: \ case -1: \
TWC_TFER_UPDATE_STATUS_AND_RETURN( \ TWC_TFER_UPDATE_STATUS_AND_RETURN( \
"request number %ld cannot be " #past, n); \ "request number %zu cannot be " #past, n); \
} \ } \
} while (0) } while (0)
@ -220,7 +220,7 @@ twc_tfer_file_unique_name(const char *original)
i = number; i = number;
do do
{ {
snprintf(name, FILENAME_MAX, "%s(%i)%s", body, i, extension); snprintf(name, FILENAME_MAX, "%s(%d)%s", body, i, extension);
i++; i++;
} while (twc_tfer_file_check(name)); } while (twc_tfer_file_check(name));
@ -449,14 +449,14 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
const char *status = twc_tfer_file_get_status_str(file); const char *status = twc_tfer_file_get_status_str(file);
if (file->size == UINT64_MAX) if (file->size == UINT64_MAX)
{ {
weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s [STREAM]", index, weechat_printf_y(tfer->buffer, line, "%zu) %s %s: %s [STREAM]", index,
type, file->nickname, file->filename); type, file->nickname, file->filename);
} }
else else
{ {
float display_size = twc_tfer_cut_size(file->size); float display_size = twc_tfer_cut_size(file->size);
const char *size_suffix = twc_tfer_size_suffix(file->size); const char *size_suffix = twc_tfer_size_suffix(file->size);
weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s %i (%.2f%s)", index, weechat_printf_y(tfer->buffer, line, "%zu) %s %s: %s %zu (%.2f%s)", index,
type, file->nickname, file->filename, file->size, type, file->nickname, file->filename, file->size,
display_size, size_suffix); display_size, size_suffix);
} }
@ -486,7 +486,7 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
float display_pos = twc_tfer_cut_size(file->position); float display_pos = twc_tfer_cut_size(file->position);
const char *pos_suffix = twc_tfer_size_suffix(file->position); const char *pos_suffix = twc_tfer_size_suffix(file->position);
weechat_printf_y(tfer->buffer, line + 1, "%s%i%% [%s] %.2f%s %.2f%s", weechat_printf_y(tfer->buffer, line + 1, "%s%d%% [%s] %.2f%s %.2f%s",
placeholder, percents, progress_bar, display_pos, placeholder, percents, progress_bar, display_pos,
pos_suffix, display_speed, speed_suffix); pos_suffix, display_speed, speed_suffix);
} }
@ -661,6 +661,8 @@ twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index,
twc_tfer_file_update(profile->tfer, file); twc_tfer_file_update(profile->tfer, file);
return 1; return 1;
} }
/* proforma */
return 0;
} }
/** /**

View File

@ -150,7 +150,7 @@ void
twc_tfer_buffer_update(struct t_twc_tfer *tfer); twc_tfer_buffer_update(struct t_twc_tfer *tfer);
void void
twc_tfer_file_err_send_message(char *message, enum TOX_ERR_FILE_SEND error); twc_tfer_file_err_send_message(char *message, enum Tox_Err_File_Send error);
void void
twc_tfer_file_free(struct t_twc_tfer_file *file); twc_tfer_file_free(struct t_twc_tfer_file *file);

View File

@ -29,7 +29,7 @@
#include "twc-chat.h" #include "twc-chat.h"
#include "twc-friend-request.h" #include "twc-friend-request.h"
#include "twc-group-invite.h" #include "twc-conf-invite.h"
#include "twc-message-queue.h" #include "twc-message-queue.h"
#include "twc-profile.h" #include "twc-profile.h"
#include "twc-tfer.h" #include "twc-tfer.h"
@ -71,7 +71,7 @@ twc_do_timer_cb(const void *pointer, void *data, int remaining_calls)
if (TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_AUTOJOIN)) if (TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_AUTOJOIN))
{ {
struct t_twc_group_chat_invite *invite; struct t_twc_group_chat_invite *invite;
for (i = 0; (invite = twc_group_chat_invite_with_index(profile, i)); for (i = 0; (invite = twc_conf_chat_invite_with_index(profile, i));
i++) i++)
if (invite->autojoin_delay <= 0) if (invite->autojoin_delay <= 0)
{ {
@ -335,7 +335,7 @@ twc_group_invite_callback(Tox *tox, uint32_t friend_number,
char *friend_name = twc_get_name_nt(profile->tox, friend_number); char *friend_name = twc_get_name_nt(profile->tox, friend_number);
struct t_twc_chat *friend_chat = struct t_twc_chat *friend_chat =
twc_chat_search_friend(profile, friend_number, false); twc_chat_search_friend(profile, friend_number, false);
int64_t rc; int rc;
char *tags; char *tags;
char *type_str; char *type_str;
@ -408,7 +408,7 @@ twc_handle_group_message(Tox *tox, int32_t group_number, int32_t peer_number,
struct t_twc_profile *profile = data; struct t_twc_profile *profile = data;
struct t_twc_chat *chat = struct t_twc_chat *chat =
twc_chat_search_group(profile, group_number, true); twc_chat_search_conf(profile, group_number, true);
char *myname = twc_get_self_name_nt(profile->tox); char *myname = twc_get_self_name_nt(profile->tox);
char *name = twc_get_peer_name_nt(profile->tox, group_number, peer_number); char *name = twc_get_peer_name_nt(profile->tox, group_number, peer_number);
@ -448,7 +448,7 @@ twc_group_peer_list_changed_callback(Tox *tox, uint32_t group_number,
{ {
struct t_twc_profile *profile = data; struct t_twc_profile *profile = data;
struct t_twc_chat *chat = struct t_twc_chat *chat =
twc_chat_search_group(profile, group_number, true); twc_chat_search_conf(profile, group_number, true);
struct t_gui_nick *nick = NULL; struct t_gui_nick *nick = NULL;
int i, npeers; int i, npeers;
@ -517,7 +517,7 @@ twc_group_peer_name_callback(Tox *tox, uint32_t group_number,
{ {
struct t_twc_profile *profile = data; struct t_twc_profile *profile = data;
struct t_twc_chat *chat = struct t_twc_chat *chat =
twc_chat_search_group(profile, group_number, true); twc_chat_search_conf(profile, group_number, true);
int npeers, len; int npeers, len;
struct t_gui_nick *nick = NULL; struct t_gui_nick *nick = NULL;
@ -580,7 +580,7 @@ twc_group_title_callback(Tox *tox, uint32_t group_number, uint32_t peer_number,
{ {
struct t_twc_profile *profile = data; struct t_twc_profile *profile = data;
struct t_twc_chat *chat = struct t_twc_chat *chat =
twc_chat_search_group(profile, group_number, true); twc_chat_search_conf(profile, group_number, true);
twc_chat_queue_refresh(chat); twc_chat_queue_refresh(chat);
char *name = twc_get_peer_name_nt(profile->tox, group_number, peer_number); char *name = twc_get_peer_name_nt(profile->tox, group_number, peer_number);
@ -593,7 +593,7 @@ twc_group_title_callback(Tox *tox, uint32_t group_number, uint32_t peer_number,
void void
twc_file_recv_control_callback(Tox *tox, uint32_t friend_number, twc_file_recv_control_callback(Tox *tox, uint32_t friend_number,
uint32_t file_number, TOX_FILE_CONTROL control, uint32_t file_number, Tox_File_Control control,
void *user_data) void *user_data)
{ {
struct t_twc_profile *profile = twc_profile_search_tox(tox); struct t_twc_profile *profile = twc_profile_search_tox(tox);
@ -602,7 +602,7 @@ twc_file_recv_control_callback(Tox *tox, uint32_t friend_number,
if (!file) if (!file)
{ {
weechat_printf(profile->tfer->buffer, weechat_printf(profile->tfer->buffer,
"%sthere is no file with number %i in queue", "%sthere is no file with number %" PRIu32 " in queue",
weechat_prefix("error"), file_number); weechat_prefix("error"), file_number);
return; return;
} }
@ -644,7 +644,7 @@ twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number,
if (!file) if (!file)
{ {
weechat_printf(profile->tfer->buffer, weechat_printf(profile->tfer->buffer,
"%sthere is no file with number %i in queue", "%sthere is no file with number %" PRIu32 " in queue",
weechat_prefix("error"), file_number); weechat_prefix("error"), file_number);
return; return;
} }
@ -668,13 +668,14 @@ twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number,
weechat_prefix("error"), file->filename); weechat_prefix("error"), file->filename);
return; return;
} }
enum TOX_ERR_FILE_SEND_CHUNK error; enum Tox_Err_File_Send_Chunk error;
tox_file_send_chunk(profile->tox, friend_number, file_number, position, tox_file_send_chunk(profile->tox, friend_number, file_number, position,
data, length, &error); data, length, &error);
if (error) if (error)
weechat_printf(profile->buffer, "%s%s: chunk sending error: %s", weechat_printf(profile->buffer, "%s%s: chunk sending error: %d",
weechat_prefix("error"), file->filename, weechat_prefix("error"), file->filename,
twc_tox_err_file_send_chunk(error)); /* twc_tox_err_file_send_chunk() */
error);
else else
{ {
file->position += length; file->position += length;
@ -744,7 +745,7 @@ twc_file_recv_chunk_callback(Tox *tox, uint32_t friend_number,
if (!file) if (!file)
{ {
weechat_printf(profile->tfer->buffer, weechat_printf(profile->tfer->buffer,
"%sthere is no file with number %i in queue", "%sthere is no file with number %" PRIu32 " in queue",
weechat_prefix("error"), file_number); weechat_prefix("error"), file_number);
return; return;
} }
@ -795,12 +796,17 @@ twc_tox_log_callback(Tox *tox, TOX_LOG_LEVEL level, const char *file,
{ {
case TOX_LOG_LEVEL_TRACE: case TOX_LOG_LEVEL_TRACE:
color = weechat_color("gray"); color = weechat_color("gray");
if (weechat_strcasecmp(file, "network.c") == 0)
return;
if (weechat_strcasecmp(file, "onion_client.c") == 0 &&
weechat_strcasecmp(file, "onion_isconnected") != 0)
return;
break; break;
case TOX_LOG_LEVEL_DEBUG: case TOX_LOG_LEVEL_DEBUG:
color = weechat_color("white"); color = weechat_color("white");
break; break;
case TOX_LOG_LEVEL_INFO: case TOX_LOG_LEVEL_INFO:
color = weechat_color("lightblue"); color = weechat_color("lightgreen");
break; break;
case TOX_LOG_LEVEL_WARNING: case TOX_LOG_LEVEL_WARNING:
color = weechat_color("yellow"); color = weechat_color("yellow");

View File

@ -239,7 +239,7 @@ twc_set_buffer_logging(struct t_gui_buffer *buffer, bool logging)
*/ */
char * char *
twc_tox_err_file_control(enum TOX_ERR_FILE_CONTROL error) twc_tox_err_file_control(enum Tox_Err_File_Control error)
{ {
char *messages[] = { char *messages[] = {
"success", "success",
@ -256,7 +256,7 @@ twc_tox_err_file_control(enum TOX_ERR_FILE_CONTROL error)
} }
char * char *
twc_tox_err_file_get(enum TOX_ERR_FILE_GET error) twc_tox_err_file_get(enum Tox_Err_File_Get error)
{ {
char *messages[] = { char *messages[] = {
"success", "success",
@ -269,7 +269,7 @@ twc_tox_err_file_get(enum TOX_ERR_FILE_GET error)
} }
char * char *
twc_tox_err_file_seek(enum TOX_ERR_FILE_SEEK error) twc_tox_err_file_seek(enum Tox_Err_File_Seek error)
{ {
char *messages[] = { char *messages[] = {
"success", "success",
@ -284,7 +284,7 @@ twc_tox_err_file_seek(enum TOX_ERR_FILE_SEEK error)
} }
char * char *
twc_tox_err_file_send(enum TOX_ERR_FILE_SEND error) twc_tox_err_file_send(enum Tox_Err_File_Send error)
{ {
char *messages[] = { char *messages[] = {
"success", "success",
@ -298,7 +298,7 @@ twc_tox_err_file_send(enum TOX_ERR_FILE_SEND error)
} }
char * char *
twc_tox_err_file_send_chunk(enum TOX_ERR_FILE_SEND_CHUNK error) twc_tox_err_file_send_chunk(enum Tox_Err_File_Send_Chunk error)
{ {
char *messages[] = { char *messages[] = {
"success", "success",