From 01ff90ad65a58d3f0c0a1a15014f5f4688c07886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Wed, 11 May 2016 08:24:54 +0200 Subject: [PATCH] Remove ToxDNS-related code. ToxDNS is deprecated. --- README.md | 1 - cmake/FindTox.cmake | 14 ++--- src/twc-dns.c | 140 -------------------------------------------- src/twc-dns.h | 39 ------------ 4 files changed, 4 insertions(+), 190 deletions(-) delete mode 100644 src/twc-dns.c delete mode 100644 src/twc-dns.h diff --git a/README.md b/README.md index 3174635..103a670 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ future. - [x] Proxy support - [x] Multiple profiles - [x] Encrypted save files - - [ ] Tox DNS - [ ] File transfer - [ ] WeeChat `/upgrade` - [ ] Audio/video diff --git a/cmake/FindTox.cmake b/cmake/FindTox.cmake index 6fdf739..febf084 100644 --- a/cmake/FindTox.cmake +++ b/cmake/FindTox.cmake @@ -10,9 +10,6 @@ find_library(Tox_AV_LIBRARY toxav) find_path(Tox_ENCRYPTSAVE_INCLUDE_DIR tox/toxencryptsave.h) find_library(Tox_ENCRYPTSAVE_LIBRARY toxencryptsave) -find_path(Tox_DNS_INCLUDE_DIR tox/toxdns.h) -find_library(Tox_DNS_LIBRARY toxdns) - if(Tox_CORE_INCLUDE_DIR AND Tox_CORE_LIBRARY) set(Tox_CORE_FOUND TRUE) list(APPEND Tox_INCLUDE_DIRS ${Tox_CORE_INCLUDE_DIR}) @@ -31,11 +28,8 @@ if(Tox_ENCRYPTSAVE_INCLUDE_DIR AND Tox_ENCRYPTSAVE_LIBRARY) list(APPEND Tox_LIBRARIES ${Tox_ENCRYPTSAVE_LIBRARY}) endif() -if(Tox_DNS_INCLUDE_DIR AND Tox_DNS_LIBRARY) - set(Tox_DNS_FOUND TRUE) - list(APPEND Tox_INCLUDE_DIRS ${Tox_DNS_INCLUDE_DIR}) - list(APPEND Tox_LIBRARIES ${Tox_DNS_LIBRARY}) -endif() - include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Tox FOUND_VAR Tox_FOUND REQUIRED_VARS Tox_INCLUDE_DIRS Tox_LIBRARIES HANDLE_COMPONENTS) +find_package_handle_standard_args(Tox + FOUND_VAR Tox_FOUND + REQUIRED_VARS Tox_INCLUDE_DIRS Tox_LIBRARIES + HANDLE_COMPONENTS) diff --git a/src/twc-dns.c b/src/twc-dns.c deleted file mode 100644 index 954a232..0000000 --- a/src/twc-dns.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2016 Håvard Pettersson - * - * This file is part of Tox-WeeChat. - * - * Tox-WeeChat is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tox-WeeChat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tox-WeeChat. If not, see . - */ - -#include -#include -#include -#include - -#include -#include - -#include "twc.h" -#include "twc-utils.h" - -#include "twc-dns.h" - -/** - * Struct for holding information about a Tox DNS query callback. - */ -struct t_twc_dns_callback_info -{ - void (*callback)(void *data, - enum t_twc_dns_rc rc, - const uint8_t *tox_id); - void *data; - - struct t_hook *hook; -}; - -/** - * Callback when the DNS resolver child process has written to our file - * descriptor. Process the data a bit and pass it on to the original callback. - */ -int -twc_dns_fd_callback(void *data, int fd) -{ - struct t_twc_dns_callback_info *callback_info = data; - - char buffer[TOX_ADDRESS_SIZE * 2 + 1]; - ssize_t size = read(fd, buffer, sizeof(buffer) - 1); - buffer[size] = '\0'; - - if (size > 0) - { - if (size == TOX_ADDRESS_SIZE * 2) - { - uint8_t tox_id[TOX_ADDRESS_SIZE]; - twc_hex2bin(buffer, TOX_ADDRESS_SIZE, tox_id); - - callback_info->callback(callback_info->data, - TWC_DNS_RC_OK, tox_id); - } - else - { - int rc = atoi(buffer); - callback_info->callback(callback_info->data, - rc, NULL); - } - - weechat_unhook(callback_info->hook); - free(callback_info); - } - - return WEECHAT_RC_OK; -} - -/** - * Perform a Tox DNS lookup and write either a Tox ID (as a hexadecimal string) - * or an error code (as a decimal string) to out_fd. - */ -void -twc_perform_dns_lookup(const char *dns_id, int out_fd) -{ - dprintf(out_fd, "%d", TWC_DNS_RC_ERROR); -} - -/** - * Perform a Tox DNS lookup. If return code (rc) parameter in callback is - * TWC_DNS_RC_OK, tox_id contains the resolved Tox ID. For any other value, - * something caused the Tox ID not to be found. - * - * If twc_dns_query returns TWC_DNS_RC_ERROR, the callback will never be - * called. - */ -enum t_twc_dns_rc -twc_dns_query(const char *dns_id, - void (*callback)(void *data, - enum t_twc_dns_rc rc, - const uint8_t *tox_id), - void *callback_data) -{ - if (!callback) return TWC_DNS_RC_OK; - - int fifo[2]; - if (pipe(fifo) < 0) - return TWC_DNS_RC_ERROR; - - pid_t pid; - if ((pid = fork()) == -1) - { - return TWC_DNS_RC_ERROR; - } - else if (pid == 0) - { - twc_perform_dns_lookup(dns_id, fifo[1]); - _exit(0); - } - else - { - struct t_twc_dns_callback_info *callback_info - = malloc(sizeof(struct t_twc_dns_callback_info)); - if (!callback_info) - return TWC_DNS_RC_ERROR; - - callback_info->callback = callback; - callback_info->data = callback_data; - callback_info->hook = weechat_hook_fd(fifo[0], 1, 0, 0, - twc_dns_fd_callback, - callback_info); - } - - return TWC_DNS_RC_OK; -} - diff --git a/src/twc-dns.h b/src/twc-dns.h deleted file mode 100644 index 5ca8db1..0000000 --- a/src/twc-dns.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2016 Håvard Pettersson - * - * This file is part of Tox-WeeChat. - * - * Tox-WeeChat is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tox-WeeChat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tox-WeeChat. If not, see . - */ - -#ifndef TOX_WEECHAT_DNS_H -#define TOX_WEECHAT_DNS_H - -#include - -enum t_twc_dns_rc -{ - TWC_DNS_RC_OK = 0, - TWC_DNS_RC_ERROR = -1, -}; - -enum t_twc_dns_rc -twc_dns_query(const char *dns_id, - void (*callback)(void *data, - enum t_twc_dns_rc rc, - const uint8_t *tox_id), - void *callback_data); - -#endif // TOX_WEECHAT_DNS_H -