mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-28 12:56:21 +00:00
Merge upstream/master into merge/upstream-full
Merge profanity-im/profanity master (373 commits) into cproof fork.
Source changes (manual merge):
- src/command/: cmd_defs, cmd_funcs, cmd_ac — upstream g_new0, auto_gchar,
launch_editor callback; keep our XEP-0308 LMC, force-encryption, CWE-134
- src/config/: preferences, tlscerts, account — upstream UNIQUE dedup,
dynamic pad capacity; keep our db_history_result_t, scroll logic
- src/database.*: upstream g_new0 memory mgmt; keep our return types,
add null-check fix for msg->timestamp
- src/omemo/, src/pgp/: upstream _gpgme_key_get_email, g_new0;
keep our replace_id in omemo_on_message_send
- src/tools/: editor, http_upload, bookmark_ignore — upstream launch_editor
callback API
- src/ui/: console, window, chatwin, mucwin, inputwin, buffer —
upstream win_warn_needed/sent dedup, PAD_MIN_HEIGHT dynamic pads;
keep our y_start_pos scroll, _truncate_datetime_suffix
- src/xmpp/: message, stanza, presence, roster_list, iq, session —
upstream connection_get_available_resources; keep our LMC stanza logic
- src/common.c: fix format-security (cons_show)
Build system:
- Makefile.am: updated test paths to subdirectory structure, added
test_cmd_ac, test_forced_encryption
- Restored autotools files deleted by upstream meson migration:
bootstrap.sh, autogen.sh, m4/ax_valgrind_check.m4, configure-debug
Tests:
- Unit tests: upstream unittests.c base + our forced_encryption tests
(482 passed, 0 failed across all 4 configurations)
- Functional tests: kept our version (93 passed, 0 failed)
upstream version requires stbbr_for_xmlns not yet in our stabber fork
- Updated test stubs: stub_xmpp.c, stub_omemo.c from upstream
Compile fixes:
- src/common.c: cons_show(errmsg) -> cons_show("%s", errmsg)
- src/database.c: null-check before msg->timestamp access
- src/ui/console.c: size_t -> (int) cast for format width
- src/config/tlscerts.c: %d -> %zu for size_t
This commit is contained in:
@@ -3,35 +3,9 @@
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*
|
||||
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
||||
* Copyright (C) 2019 - 2025 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.
|
||||
* Copyright (C) 2019 - 2026 Michael Vetter <jubalh@iodoru.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later WITH OpenSSL-exception
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@@ -73,24 +47,24 @@ typedef struct _status_bar_t
|
||||
char* prompt;
|
||||
char* fulljid;
|
||||
GHashTable* tabs;
|
||||
int current_tab;
|
||||
guint current_tab;
|
||||
} StatusBar;
|
||||
|
||||
static GTimeZone* tz;
|
||||
static StatusBar* statusbar;
|
||||
static WINDOW* statusbar_win;
|
||||
|
||||
void _get_range_bounds(int* start, int* end, gboolean is_static);
|
||||
static int _status_bar_draw_time(int pos);
|
||||
static int _status_bar_draw_maintext(int pos);
|
||||
static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch);
|
||||
static int _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static);
|
||||
static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets);
|
||||
static int _status_bar_draw_tabs(int pos);
|
||||
void _get_range_bounds(guint* start, guint* end, gboolean is_static);
|
||||
static guint _status_bar_draw_time(guint pos);
|
||||
static guint _status_bar_draw_maintext(guint pos);
|
||||
static guint _status_bar_draw_bracket(gboolean current, guint pos, const char* ch);
|
||||
static guint _status_bar_draw_extended_tabs(guint pos, gboolean prefix, guint start, guint end, gboolean is_static);
|
||||
static guint _status_bar_draw_tab(StatusBarTab* tab, guint pos, guint num, gboolean include_brackets);
|
||||
static guint _status_bar_draw_tabs(guint pos);
|
||||
static void _destroy_tab(StatusBarTab* tab);
|
||||
static int _tabs_width(int start, int end);
|
||||
static unsigned int _count_digits(int number);
|
||||
static unsigned int _count_digits_in_range(int start, int end);
|
||||
static guint _tabs_width(guint start, guint end);
|
||||
static guint _count_digits(guint number);
|
||||
static guint _count_digits_in_range(guint start, guint end);
|
||||
static char* _display_name(StatusBarTab* tab);
|
||||
static gboolean _tabmode_is_actlist(void);
|
||||
|
||||
@@ -99,12 +73,12 @@ status_bar_init(void)
|
||||
{
|
||||
tz = g_time_zone_new_local();
|
||||
|
||||
statusbar = malloc(sizeof(StatusBar));
|
||||
statusbar = g_new0(StatusBar, 1);
|
||||
statusbar->time = NULL;
|
||||
statusbar->prompt = NULL;
|
||||
statusbar->fulljid = NULL;
|
||||
statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab);
|
||||
StatusBarTab* console = calloc(1, sizeof(StatusBarTab));
|
||||
StatusBarTab* console = g_new0(StatusBarTab, 1);
|
||||
console->window_type = WIN_CONSOLE;
|
||||
console->identifier = strdup("console");
|
||||
console->display_name = NULL;
|
||||
@@ -178,7 +152,7 @@ status_bar_set_all_inactive(void)
|
||||
}
|
||||
|
||||
void
|
||||
status_bar_current(int i)
|
||||
status_bar_current(guint i)
|
||||
{
|
||||
if (i == 0) {
|
||||
statusbar->current_tab = 10;
|
||||
@@ -207,7 +181,7 @@ _create_tab(const int win, win_type_t wintype, char* identifier, gboolean highli
|
||||
{
|
||||
int true_win = win == 0 ? 10 : win;
|
||||
|
||||
StatusBarTab* tab = malloc(sizeof(StatusBarTab));
|
||||
StatusBarTab* tab = g_new0(StatusBarTab, 1);
|
||||
tab->identifier = strdup(identifier);
|
||||
tab->highlight = highlight;
|
||||
tab->window_type = wintype;
|
||||
@@ -308,7 +282,7 @@ status_bar_draw(void)
|
||||
werase(statusbar_win);
|
||||
wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT));
|
||||
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
int pos = 1;
|
||||
|
||||
pos = _status_bar_draw_time(pos);
|
||||
@@ -320,24 +294,22 @@ status_bar_draw(void)
|
||||
inp_put_back();
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_tabs(int pos)
|
||||
static guint
|
||||
_status_bar_draw_tabs(guint pos)
|
||||
{
|
||||
auto_gchar gchar* tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);
|
||||
|
||||
if (g_strcmp0(tabmode, "actlist") != 0) {
|
||||
int start, end;
|
||||
guint start, end;
|
||||
gboolean is_static = g_strcmp0(tabmode, "dynamic") != 0;
|
||||
_get_range_bounds(&start, &end, is_static);
|
||||
|
||||
pos = getmaxx(stdscr) - _tabs_width(start, end);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
// if the result of the calc is negative we take 0
|
||||
pos = MAX(0, (getmaxx(stdscr) - (int)_tabs_width(start, end)));
|
||||
|
||||
pos = _status_bar_draw_extended_tabs(pos, TRUE, start, end, is_static);
|
||||
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
pos = _status_bar_draw_tab(tab, pos, i, TRUE);
|
||||
@@ -385,9 +357,9 @@ _status_bar_draw_tabs(int pos)
|
||||
static gboolean
|
||||
_has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, int display_tabs_end)
|
||||
{
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
int tabs_count = g_hash_table_size(statusbar->tabs);
|
||||
if (tabs_count <= max_tabs) {
|
||||
if ((guint)tabs_count <= max_tabs) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -404,10 +376,10 @@ _has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, i
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static)
|
||||
static guint
|
||||
_status_bar_draw_extended_tabs(guint pos, gboolean prefix, guint start, guint end, gboolean is_static)
|
||||
{
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
if (max_tabs == 0) {
|
||||
return pos;
|
||||
}
|
||||
@@ -446,8 +418,8 @@ _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gbo
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets)
|
||||
static guint
|
||||
_status_bar_draw_tab(StatusBarTab* tab, guint pos, guint num, gboolean include_brackets)
|
||||
{
|
||||
gboolean is_current = num == statusbar->current_tab;
|
||||
|
||||
@@ -495,8 +467,8 @@ _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brack
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_bracket(gboolean current, int pos, const char* ch)
|
||||
static guint
|
||||
_status_bar_draw_bracket(gboolean current, guint pos, const char* ch)
|
||||
{
|
||||
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
|
||||
wattron(statusbar_win, bracket_attrs);
|
||||
@@ -511,8 +483,8 @@ _status_bar_draw_bracket(gboolean current, int pos, const char* ch)
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_time(int pos)
|
||||
static guint
|
||||
_status_bar_draw_time(guint pos)
|
||||
{
|
||||
auto_gchar gchar* time_pref = prefs_get_string(PREF_TIME_STATUSBAR);
|
||||
if (g_strcmp0(time_pref, "off") == 0) {
|
||||
@@ -556,8 +528,8 @@ _tabmode_is_actlist(void)
|
||||
return g_strcmp0(tabmode, "actlist") == 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_maintext(int pos)
|
||||
static guint
|
||||
_status_bar_draw_maintext(guint pos)
|
||||
{
|
||||
const char* maintext = NULL;
|
||||
auto_jid Jid* jidp = NULL;
|
||||
@@ -617,20 +589,20 @@ _destroy_tab(StatusBarTab* tab)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_tabs_width(int start, int end)
|
||||
static guint
|
||||
_tabs_width(guint start, guint end)
|
||||
{
|
||||
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
|
||||
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
|
||||
gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
guint opened_tabs = g_hash_table_size(statusbar->tabs);
|
||||
|
||||
int width = start < 2 ? 1 : 4;
|
||||
width += end > opened_tabs - 1 ? 0 : 3;
|
||||
|
||||
if (show_name && show_number) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
gboolean is_current = i == statusbar->current_tab;
|
||||
@@ -647,7 +619,7 @@ _tabs_width(int start, int end)
|
||||
}
|
||||
|
||||
if (show_name && !show_number) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
gboolean is_current = i == statusbar->current_tab;
|
||||
@@ -723,7 +695,7 @@ _display_name(StatusBarTab* tab)
|
||||
}
|
||||
|
||||
void
|
||||
_get_range_bounds(int* start, int* end, gboolean is_static)
|
||||
_get_range_bounds(guint* start, guint* end, gboolean is_static)
|
||||
{
|
||||
int current_tab = statusbar->current_tab;
|
||||
gint display_range = prefs_get_statusbartabs();
|
||||
@@ -746,12 +718,10 @@ _get_range_bounds(int* start, int* end, gboolean is_static)
|
||||
}
|
||||
|
||||
// Counts amount of digits in a number
|
||||
static unsigned int
|
||||
_count_digits(int number)
|
||||
static guint
|
||||
_count_digits(guint number)
|
||||
{
|
||||
unsigned int digits_count = 0;
|
||||
if (number < 0)
|
||||
number = -number;
|
||||
guint digits_count = 0;
|
||||
|
||||
do {
|
||||
number /= 10;
|
||||
@@ -763,12 +733,11 @@ _count_digits(int number)
|
||||
|
||||
// Counts the total number of digits in a range of numbers, inclusive.
|
||||
// Example: _count_digits_in_range(2, 3) returns 2, _count_digits_in_range(2, 922) returns 2657
|
||||
static unsigned int
|
||||
_count_digits_in_range(int start, int end)
|
||||
static guint
|
||||
_count_digits_in_range(guint start, guint end)
|
||||
{
|
||||
int total_digits = 0;
|
||||
|
||||
for (int i = start; i <= end; i++) {
|
||||
guint total_digits = 0;
|
||||
for (guint i = start; i <= end; i++) {
|
||||
total_digits += _count_digits(i);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user