1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Add url support (downloading) to /plugins install

Additional changes include code refactoring.
This commit is contained in:
John Hernandez 2023-04-19 14:19:47 +02:00
parent 9a68aab011
commit 95e06ad169
13 changed files with 279 additions and 35 deletions

View File

@ -50,6 +50,8 @@ core_sources = \
src/tools/http_upload.h \ src/tools/http_upload.h \
src/tools/http_download.c \ src/tools/http_download.c \
src/tools/http_download.h \ src/tools/http_download.h \
src/tools/plugin_download.c \
src/tools/plugin_download.h \
src/tools/bookmark_ignore.c \ src/tools/bookmark_ignore.c \
src/tools/bookmark_ignore.h \ src/tools/bookmark_ignore.h \
src/tools/autocomplete.c src/tools/autocomplete.h \ src/tools/autocomplete.c src/tools/autocomplete.h \
@ -137,6 +139,7 @@ unittest_sources = \
tests/unittests/tools/stub_http_upload.c \ tests/unittests/tools/stub_http_upload.c \
tests/unittests/tools/stub_http_download.c \ tests/unittests/tools/stub_http_download.c \
tests/unittests/tools/stub_aesgcm_download.c \ tests/unittests/tools/stub_aesgcm_download.c \
tests/unittests/tools/stub_plugin_download.c \
tests/unittests/helpers.c tests/unittests/helpers.h \ tests/unittests/helpers.c tests/unittests/helpers.h \
tests/unittests/test_form.c tests/unittests/test_form.h \ tests/unittests/test_form.c tests/unittests/test_form.h \
tests/unittests/test_common.c tests/unittests/test_common.h \ tests/unittests/test_common.c tests/unittests/test_common.h \

View File

@ -2158,9 +2158,9 @@ static const struct cmd_t command_defs[] = {
CMD_MAINFUNC(cmd_plugins) CMD_MAINFUNC(cmd_plugins)
CMD_SYN( CMD_SYN(
"/plugins", "/plugins",
"/plugins install [<path>]", "/plugins install [<path or URL>]",
"/plugins update [<path or URL>]",
"/plugins uninstall [<plugin>]", "/plugins uninstall [<plugin>]",
"/plugins update [<path>]",
"/plugins unload [<plugin>]", "/plugins unload [<plugin>]",
"/plugins load [<plugin>]", "/plugins load [<plugin>]",
"/plugins reload [<plugin>]", "/plugins reload [<plugin>]",
@ -2168,17 +2168,18 @@ static const struct cmd_t command_defs[] = {
CMD_DESC( CMD_DESC(
"Manage plugins. Passing no arguments lists installed plugins and global plugins which are available for local installation. Global directory for Python plugins is " GLOBAL_PYTHON_PLUGINS_PATH " and for C Plugins is " GLOBAL_C_PLUGINS_PATH ".") "Manage plugins. Passing no arguments lists installed plugins and global plugins which are available for local installation. Global directory for Python plugins is " GLOBAL_PYTHON_PLUGINS_PATH " and for C Plugins is " GLOBAL_C_PLUGINS_PATH ".")
CMD_ARGS( CMD_ARGS(
{ "install [<path>]", "Install a plugin, or all plugins found in a directory (recursive). And loads it/them." }, { "install [<path or URL>]", "Install a plugin, or all plugins found in a directory (recursive), or download and install plugin (plugin name is based on basename). And loads it/them." },
{ "update [<path or URL>]", "Uninstall and then install the plugin. Plugin name to update is basename." },
{ "uninstall [<plugin>]", "Uninstall a plugin." }, { "uninstall [<plugin>]", "Uninstall a plugin." },
{ "update [<path>]", "Updates an installed plugin" },
{ "load [<plugin>]", "Load a plugin that already exists in the plugin directory, passing no argument loads all found plugins. It will be loaded upon next start too unless unloaded." }, { "load [<plugin>]", "Load a plugin that already exists in the plugin directory, passing no argument loads all found plugins. It will be loaded upon next start too unless unloaded." },
{ "unload [<plugin>]", "Unload a loaded plugin, passing no argument will unload all plugins." }, { "unload [<plugin>]", "Unload a loaded plugin, passing no argument will unload all plugins." },
{ "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins." }, { "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins." },
{ "python_version", "Show the Python interpreter version." }) { "python_version", "Show the Python interpreter version." })
CMD_EXAMPLES( CMD_EXAMPLES(
"/plugins install",
"/plugins install /home/steveharris/Downloads/metal.py", "/plugins install /home/steveharris/Downloads/metal.py",
"/plugins install https://raw.githubusercontent.com/profanity-im/profanity-plugins/master/stable/sounds.py",
"/plugins update /home/steveharris/Downloads/metal.py", "/plugins update /home/steveharris/Downloads/metal.py",
"/plugins update https://raw.githubusercontent.com/profanity-im/profanity-plugins/master/stable/sounds.py",
"/plugins uninstall browser.py", "/plugins uninstall browser.py",
"/plugins load browser.py", "/plugins load browser.py",
"/plugins unload say.py", "/plugins unload say.py",

View File

@ -77,6 +77,7 @@
#include "tools/http_download.h" #include "tools/http_download.h"
#include "tools/autocomplete.h" #include "tools/autocomplete.h"
#include "tools/parser.h" #include "tools/parser.h"
#include "tools/plugin_download.h"
#include "tools/bookmark_ignore.h" #include "tools/bookmark_ignore.h"
#include "tools/editor.h" #include "tools/editor.h"
#include "plugins/plugins.h" #include "plugins/plugins.h"
@ -130,6 +131,8 @@ static gboolean _cmd_execute_default(ProfWin* window, const char* inp);
static gboolean _cmd_execute_alias(ProfWin* window, const char* const inp, gboolean* ran); static gboolean _cmd_execute_alias(ProfWin* window, const char* const inp, gboolean* ran);
static gboolean static gboolean
_string_matches_one_of(const char* what, const char* is, bool is_can_be_null, const char* first, ...) __attribute__((sentinel)); _string_matches_one_of(const char* what, const char* is, bool is_can_be_null, const char* first, ...) __attribute__((sentinel));
static gboolean
_download_install_plugin(ProfWin* window, gchar* url, gchar* path);
static gboolean static gboolean
_string_matches_one_of(const char* what, const char* is, bool is_can_be_null, const char* first, ...) _string_matches_one_of(const char* what, const char* is, bool is_can_be_null, const char* first, ...)
@ -7033,17 +7036,38 @@ cmd_receipts(ProfWin* window, const char* const command, gchar** args)
return TRUE; return TRUE;
} }
static gboolean
_is_correct_plugin_extension(gchar* plugin)
{
return g_str_has_suffix(plugin, ".py") || g_str_has_suffix(plugin, ".so");
}
static gboolean
_http_based_uri_scheme(const char* scheme)
{
return scheme != NULL && (g_strcmp0(scheme, "http") == 0 || g_strcmp0(scheme, "https") == 0);
}
gboolean gboolean
cmd_plugins_install(ProfWin* window, const char* const command, gchar** args) cmd_plugins_install(ProfWin* window, const char* const command, gchar** args)
{ {
char* path = NULL; auto_gchar gchar* path = NULL;
if (args[1] == NULL) { if (args[1] == NULL) {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
return TRUE; return TRUE;
} }
// take whole path or build it in case it's just the plugin name auto_gchar gchar* scheme = g_uri_parse_scheme(args[1]);
if (_http_based_uri_scheme(scheme)) {
if (!_is_correct_plugin_extension(args[1])) {
cons_show("Please, use url ending with correct file name. Plugins must have one of the following extensions: \".py\" or \".so\".");
return TRUE;
}
_download_install_plugin(window, args[1], NULL);
return TRUE;
}
if (strchr(args[1], '/')) { if (strchr(args[1], '/')) {
path = get_expanded_path(args[1]); path = get_expanded_path(args[1]);
} else { } else {
@ -7052,52 +7076,47 @@ cmd_plugins_install(ProfWin* window, const char* const command, gchar** args)
} else if (g_str_has_suffix(args[1], ".so")) { } else if (g_str_has_suffix(args[1], ".so")) {
path = g_strdup_printf("%s/%s", GLOBAL_C_PLUGINS_PATH, args[1]); path = g_strdup_printf("%s/%s", GLOBAL_C_PLUGINS_PATH, args[1]);
} else { } else {
cons_show("Plugins must have one of the following extensions: '.py' '.so'"); cons_show("Plugins must have one of the following extensions: \".py\" or \".so\".");
return TRUE; return TRUE;
} }
} }
if (access(path, R_OK) != 0) { if (access(path, R_OK) != 0) {
cons_show("Cannot access: %s", path); cons_show("Cannot access: %s", path);
free(path);
return TRUE; return TRUE;
} }
if (is_regular_file(path)) { if (is_regular_file(path)) {
if (!g_str_has_suffix(path, ".py") && !g_str_has_suffix(path, ".so")) { if (!_is_correct_plugin_extension(args[1])) {
cons_show("Plugins must have one of the following extensions: '.py' '.so'"); cons_show("Plugins must have one of the following extensions: \".py\" or \".so\".");
free(path);
return TRUE; return TRUE;
} }
GString* error_message = g_string_new(NULL); GString* error_message = g_string_new(NULL);
gchar* plugin_name = g_path_get_basename(path); auto_gchar gchar* plugin_name = g_path_get_basename(path);
gboolean result = plugins_install(plugin_name, path, error_message); gboolean result = plugins_install(plugin_name, path, error_message);
if (result) { if (result) {
cons_show("Plugin installed and loaded: %s", plugin_name); cons_show("Plugin installed and loaded: %s", plugin_name);
} else { } else {
cons_show("Failed to install plugin: %s. %s", plugin_name, error_message->str); cons_show("Failed to install plugin: %s. %s", plugin_name, error_message->str);
} }
g_free(plugin_name);
g_string_free(error_message, TRUE); g_string_free(error_message, TRUE);
free(path);
return TRUE; return TRUE;
} else if (is_dir(path)) { } else if (is_dir(path)) {
PluginsInstallResult* result = plugins_install_all(path); PluginsInstallResult* result = plugins_install_all(path);
if (result->installed || result->failed) { if (result->installed || result->failed) {
if (result->installed) { if (result->installed) {
cons_show("");
cons_show("Installed and loaded plugins:");
GSList* curr = result->installed; GSList* curr = result->installed;
cons_show("");
cons_show("Installed and loaded plugins (%u):", g_slist_length(curr));
while (curr) { while (curr) {
cons_show(" %s", curr->data); cons_show(" %s", curr->data);
curr = g_slist_next(curr); curr = g_slist_next(curr);
} }
} }
if (result->failed) { if (result->failed) {
cons_show("");
cons_show("Failed installs:");
GSList* curr = result->failed; GSList* curr = result->failed;
cons_show("");
cons_show("Failed installs (%u):", g_slist_length(curr));
while (curr) { while (curr) {
cons_show(" %s", curr->data); cons_show(" %s", curr->data);
curr = g_slist_next(curr); curr = g_slist_next(curr);
@ -7106,14 +7125,12 @@ cmd_plugins_install(ProfWin* window, const char* const command, gchar** args)
} else { } else {
cons_show("No plugins found in: %s", path); cons_show("No plugins found in: %s", path);
} }
free(path);
plugins_free_install_result(result); plugins_free_install_result(result);
return TRUE; return TRUE;
} else { } else {
cons_show("Argument must be a file or directory."); cons_show("Argument must be a file or directory.");
} }
free(path);
return TRUE; return TRUE;
} }
@ -7125,6 +7142,23 @@ cmd_plugins_update(ProfWin* window, const char* const command, gchar** args)
return TRUE; return TRUE;
} }
auto_gchar gchar* scheme = g_uri_parse_scheme(args[1]);
if (_http_based_uri_scheme(scheme)) {
auto_char char* plugin_name = basename_from_url(args[1]);
if (!_is_correct_plugin_extension(plugin_name)) {
cons_show("Please, use url ending with correct file name. Plugins must have one of the following extensions: \".py\" or \".so\".");
return TRUE;
}
if (!plugins_uninstall(plugin_name)) {
cons_show("Failed to uninstall plugin: %s.", plugin_name);
return TRUE;
}
_download_install_plugin(window, args[1], NULL);
return TRUE;
}
auto_gchar gchar* path = get_expanded_path(args[1]); auto_gchar gchar* path = get_expanded_path(args[1]);
if (access(path, R_OK) != 0) { if (access(path, R_OK) != 0) {
@ -9472,12 +9506,30 @@ _url_aesgcm_method(ProfWin* window, const char* cmd_template, gchar* url, gchar*
} }
#endif #endif
void static gboolean
_download_install_plugin(ProfWin* window, gchar* url, gchar* path)
{
auto_gchar gchar* filename = _prepare_filename(url, path);
if (!filename)
return FALSE;
HTTPDownload* download = malloc(sizeof(HTTPDownload));
download->window = window;
download->url = strdup(url);
download->filename = strdup(filename);
download->id = get_random_string(4);
download->cmd_template = NULL;
pthread_create(&(download->worker), NULL, &plugin_download_install, download);
plugin_download_add_download(download);
return TRUE;
}
static gchar*
_url_http_method(ProfWin* window, const char* cmd_template, gchar* url, gchar* path) _url_http_method(ProfWin* window, const char* cmd_template, gchar* url, gchar* path)
{ {
auto_gchar gchar* filename = _prepare_filename(url, path); auto_gchar gchar* filename = _prepare_filename(url, path);
if (!filename) if (!filename)
return; return NULL;
auto_char char* id = get_random_string(4); auto_char char* id = get_random_string(4);
HTTPDownload* download = malloc(sizeof(HTTPDownload)); HTTPDownload* download = malloc(sizeof(HTTPDownload));
download->window = window; download->window = window;
@ -9488,6 +9540,7 @@ _url_http_method(ProfWin* window, const char* cmd_template, gchar* url, gchar* p
pthread_create(&(download->worker), NULL, &http_file_get, download); pthread_create(&(download->worker), NULL, &http_file_get, download);
http_download_add_download(download); http_download_add_download(download);
return g_strdup(filename);
} }
void void
@ -9574,7 +9627,7 @@ cmd_url_save(ProfWin* window, const char* const command, gchar** args)
auto_gchar gchar* cmd_template = prefs_get_string(PREF_URL_SAVE_CMD); auto_gchar gchar* cmd_template = prefs_get_string(PREF_URL_SAVE_CMD);
if (cmd_template == NULL && (g_strcmp0(scheme, "http") == 0 || g_strcmp0(scheme, "https") == 0)) { if (cmd_template == NULL && (g_strcmp0(scheme, "http") == 0 || g_strcmp0(scheme, "https") == 0)) {
_url_http_method(window, cmd_template, url, path); g_free(_url_http_method(window, cmd_template, url, path));
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
} else if (g_strcmp0(scheme, "aesgcm") == 0) { } else if (g_strcmp0(scheme, "aesgcm") == 0) {
_url_aesgcm_method(window, cmd_template, url, path); _url_aesgcm_method(window, cmd_template, url, path);

View File

@ -546,7 +546,7 @@ _has_directory_suffix(const char* path)
} }
char* char*
_basename_from_url(const char* url) basename_from_url(const char* url)
{ {
const char* default_name = "index"; const char* default_name = "index";
@ -595,7 +595,7 @@ unique_filename_from_url(const char* url, const char* path)
if (_has_directory_suffix(realpath) || g_file_test(realpath, G_FILE_TEST_IS_DIR)) { if (_has_directory_suffix(realpath) || g_file_test(realpath, G_FILE_TEST_IS_DIR)) {
// The target should be used as a directory. Assume that the basename // The target should be used as a directory. Assume that the basename
// should be derived from the URL. // should be derived from the URL.
char* basename = _basename_from_url(url); char* basename = basename_from_url(url);
filename = g_build_filename(g_file_peek_path(target), basename, NULL); filename = g_build_filename(g_file_peek_path(target), basename, NULL);
g_free(basename); g_free(basename);
} else { } else {

View File

@ -125,5 +125,6 @@ gchar* unique_filename_from_url(const char* url, const char* path);
gchar* get_expanded_path(const char* path); gchar* get_expanded_path(const char* path);
void glib_hash_table_free(GHashTable* hash_table); void glib_hash_table_free(GHashTable* hash_table);
char* basename_from_url(const char* url);
#endif #endif

View File

@ -54,7 +54,11 @@ http_print_transfer_update(ProfWin* window, char* id, const char* fmt, ...)
g_string_vprintf(msg, fmt, args); g_string_vprintf(msg, fmt, args);
va_end(args); va_end(args);
win_update_entry_message(window, id, msg->str); if (window->type != WIN_CONSOLE) {
win_update_entry_message(window, id, msg->str);
} else {
cons_show("%s", msg->str);
}
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
} }

View File

@ -4,6 +4,7 @@
* *
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com> * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
* Copyright (C) 2020 William Wennerström <william@wstrm.dev> * Copyright (C) 2020 William Wennerström <william@wstrm.dev>
* Copyright (C) 2019 - 2023 Michael Vetter <jubalh@iodoru.org>
* *
* This file is part of Profanity. * This file is part of Profanity.
* *
@ -57,6 +58,7 @@
#include "common.h" #include "common.h"
GSList* download_processes = NULL; GSList* download_processes = NULL;
gboolean silent = FALSE;
static int static int
_xferinfo(void* userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) _xferinfo(void* userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
@ -82,8 +84,9 @@ _xferinfo(void* userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultot
dlperc = (100 * dlnow) / dltotal; dlperc = (100 * dlnow) / dltotal;
} }
http_print_transfer_update(download->window, download->url, if (!silent)
"Downloading '%s': %d%%", download->url, dlperc); http_print_transfer_update(download->window, download->url,
"Downloading '%s': %d%%", download->url, dlperc);
pthread_mutex_unlock(&lock); pthread_mutex_unlock(&lock);
@ -107,13 +110,16 @@ http_file_get(void* userdata)
CURL* curl; CURL* curl;
CURLcode res; CURLcode res;
silent = download->silent;
download->cancel = 0; download->cancel = 0;
download->bytes_received = 0; download->bytes_received = 0;
pthread_mutex_lock(&lock); pthread_mutex_lock(&lock);
http_print_transfer(download->window, download->id, if (!silent) {
"Downloading '%s': 0%%", download->url); http_print_transfer(download->window, download->id,
"Downloading '%s': 0%%", download->url);
}
FILE* outfh = fopen(download->filename, "wb"); FILE* outfh = fopen(download->filename, "wb");
if (outfh == NULL) { if (outfh == NULL) {
@ -188,7 +194,7 @@ http_file_get(void* userdata)
} }
free(err); free(err);
} else { } else {
if (!download->cancel) { if (!download->cancel && !silent) {
http_print_transfer_update(download->window, download->id, http_print_transfer_update(download->window, download->id,
"Downloading '%s': done\nSaved to '%s'", "Downloading '%s': done\nSaved to '%s'",
download->url, download->filename); download->url, download->filename);

View File

@ -57,6 +57,7 @@ typedef struct http_download_t
ProfWin* window; ProfWin* window;
pthread_t worker; pthread_t worker;
int cancel; int cancel;
gboolean silent;
} HTTPDownload; } HTTPDownload;
void* http_file_get(void* userdata); void* http_file_get(void* userdata);

View File

@ -0,0 +1,96 @@
/*
* plugin_download.c
* vim: expandtab:ts=4:sts=4:sw=4
*
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
* Copyright (C) 2019 - 2023 Michael Vetter <jubalh@iodoru.org>
*
* This file is part of Profanity.
*
* Profanity 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.
*
* Profanity 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 Profanity. If not, see <https://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give permission to
* link the code of portions of this program with the OpenSSL library under
* certain conditions as described in each individual source file, and
* distribute linked combinations including the two.
*
* You must obey the GNU General Public License in all respects for all of the
* code used other than OpenSSL. If you modify file(s) with this exception, you
* may extend this exception to your version of the file(s), but you are not
* obligated to do so. If you do not wish to do so, delete this exception
* statement from your version. If you delete this exception statement from all
* source files in the program, then also delete it here.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <curl/curl.h>
#include <gio/gio.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include "profanity.h"
#include "event/client_events.h"
#include "tools/http_common.h"
#include "tools/plugin_download.h"
#include "config/preferences.h"
#include "plugins/plugins.h"
#include "ui/ui.h"
#include "ui/window.h"
#include "common.h"
#define FALLBACK_MSG ""
void*
plugin_download_install(void* userdata)
{
HTTPDownload* plugin_dl = (HTTPDownload*)userdata;
auto_char char* path = strdup(plugin_dl->filename);
auto_char char* https_url = strdup(plugin_dl->url);
plugin_dl->silent = TRUE;
http_file_get(plugin_dl);
if (is_regular_file(path)) {
GString* error_message = g_string_new(NULL);
auto_char char* plugin_name = basename_from_url(https_url);
gboolean result = plugins_install(plugin_name, path, error_message);
if (result) {
cons_show("Plugin installed and loaded: %s", plugin_name);
} else {
cons_show("Failed to install plugin: %s. %s", plugin_name, error_message->str);
}
g_string_free(error_message, TRUE);
} else {
cons_show_error("Downloaded file is not a file (?)");
}
remove(path);
return NULL;
}
void
plugin_download_add_download(HTTPDownload* plugin_dl)
{
http_download_add_download(plugin_dl);
}

View File

@ -0,0 +1,55 @@
/*
* plugin_download.h
* vim: expandtab:ts=4:sts=4:sw=4
*
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
* Copyright (C) 2019 - 2023 Michael Vetter <jubalh@iodoru.org>
*
* This file is part of Profanity.
*
* Profanity 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.
*
* Profanity 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 Profanity. If not, see <https://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give permission to
* link the code of portions of this program with the OpenSSL library under
* certain conditions as described in each individual source file, and
* distribute linked combinations including the two.
*
* You must obey the GNU General Public License in all respects for all of the
* code used other than OpenSSL. If you modify file(s) with this exception, you
* may extend this exception to your version of the file(s), but you are not
* obligated to do so. If you do not wish to do so, delete this exception
* statement from your version. If you delete this exception statement from all
* source files in the program, then also delete it here.
*
*/
#ifndef TOOLS_PLUGIN_DOWNLOAD_H
#define TOOLS_PLUGIN_DOWNLOAD_H
#ifdef PLATFORM_CYGWIN
#define SOCKET int
#endif
#include <sys/select.h>
#include <curl/curl.h>
#include "tools/http_common.h"
#include "tools/http_download.h"
#include "ui/win_types.h"
void* plugin_download_install(void* userdata);
void plugin_download_add_download(HTTPDownload* download);
#endif

View File

@ -1727,6 +1727,8 @@ win_print_outgoing_with_receipt(ProfWin* window, const char* show_char, const ch
void void
win_mark_received(ProfWin* window, const char* const id) win_mark_received(ProfWin* window, const char* const id)
{ {
if (window->type == WIN_CONSOLE)
return;
gboolean received = buffer_mark_received(window->layout->buffer, id); gboolean received = buffer_mark_received(window->layout->buffer, id);
if (received) { if (received) {
win_redraw(window); win_redraw(window);
@ -1736,6 +1738,8 @@ win_mark_received(ProfWin* window, const char* const id)
void void
win_update_entry_message(ProfWin* window, const char* const id, const char* const message) win_update_entry_message(ProfWin* window, const char* const id, const char* const message)
{ {
if (window->type == WIN_CONSOLE)
return;
ProfBuffEntry* entry = buffer_get_entry_by_id(window->layout->buffer, id); ProfBuffEntry* entry = buffer_get_entry_by_id(window->layout->buffer, id);
if (entry) { if (entry) {
free(entry->message); free(entry->message);
@ -2289,8 +2293,7 @@ win_handle_command_exec_result_note(ProfWin* window, const char* const type, con
void void
win_insert_last_read_position_marker(ProfWin* window, char* id) win_insert_last_read_position_marker(ProfWin* window, char* id)
{ {
int size; int size = buffer_size(window->layout->buffer);
size = buffer_size(window->layout->buffer);
// TODO: this is somewhat costly. We should improve this later. // TODO: this is somewhat costly. We should improve this later.
// check if we already have a separator present // check if we already have a separator present

View File

@ -3,6 +3,7 @@
#include <curl/curl.h> #include <curl/curl.h>
#include <pthread.h> #include <pthread.h>
#include "common.h"
typedef struct prof_win_t ProfWin; typedef struct prof_win_t ProfWin;
@ -17,6 +18,7 @@ typedef struct http_download_t
ProfWin* window; ProfWin* window;
pthread_t worker; pthread_t worker;
int cancel; int cancel;
gboolean silent;
} HTTPDownload; } HTTPDownload;
void* void*

View File

@ -0,0 +1,19 @@
#ifndef TOOLS_PLUGIN_DOWNLOAD_H
#define TOOLS_PLUGIN_DOWNLOAD_H
#include <stdlib.h>
typedef struct prof_win_t ProfWin;
typedef struct http_download_t HTTPDownload;
void*
plugin_download_install(void* userdata)
{
return NULL;
}
void
plugin_download_add_download(HTTPDownload* download)
{
}
#endif