1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-09 21:30:42 +00:00
Commit Graph

7410 Commits

Author SHA1 Message Date
Steffen Jaeckel
801c6002af Update Valgrind suppressions
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 18:27:11 +01:00
Steffen Jaeckel
dc0f2acb9a Simplify usage of roster_get_display_name()
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 18:27:11 +01:00
Steffen Jaeckel
3c939264b3 Less GString usage
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 18:27:11 +01:00
Steffen Jaeckel
b4c088232e Improve const correctness
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 18:27:09 +01:00
Steffen Jaeckel
bac24601da Introduce equals_our_barejid()
Instead of always repeating the same pattern, introduce a helper function.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 18:27:02 +01:00
Steffen Jaeckel
fdfe3e2ad9 Rework OMEMO handling on disconnect
* Fix missing destruction of `session_store` and mutex
* Replace `glib_hash_table_free()`
  The glib API `g_hash_table_destroy()` does exactly the same.
* Use the default libsignal `destroy_func` instead of doing that manually
* Set internal state to `0` after everything is cleaned up

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 18:26:21 +01:00
Steffen Jaeckel
835ea397ac Tidy up some code
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 18:26:21 +01:00
Steffen Jaeckel
847a86de50 add connection_get_jid()
Use a singleton `Jid` inside the connection instead of always re-creating
a `Jid` from the same string.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 18:26:21 +01:00
Michael Vetter
b18b6cbd29
Merge pull request #1941 from profanity-im/some-fixes
Some fixes
2023-12-12 16:39:11 +01:00
Steffen Jaeckel
31c6d5f09a Improve shutdown
1. close logfile as last action
2. Fix `plugins_shutdown()` accessing `((ProfPlugin*)curr->data)->lang`
   after `curr->data` had already potentially been free'd.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 16:31:42 +01:00
Steffen Jaeckel
629cd33e2f Reset internal flag
Reset the `received_disco_items` flag when initializing the iq module.

This has caused the console error message "Server doesn't support MAM"
sometimes on reconnect.

Fixes #1940

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 16:31:42 +01:00
Steffen Jaeckel
c3ed0c3262 Only handle MAM response if window still exists
Before this patch the following scenario lead to a segfault:
1. open a window that sends a MAM request
2. fast enough close that window again before the MAM response was
   processed
Once the MAM response is received we'd call `_mam_rsm_id_handler()`
from the `_iq_handler()` and `window` would point to a non-existant window
which leads to a segfault.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 16:31:42 +01:00
Steffen Jaeckel
2b51675e89 Save SM queue on /reconnect now
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 16:31:42 +01:00
Steffen Jaeckel
ff32f51f4f Fix libstrophe verbosity level always being set to 0 on start
Fixup/revert of e55f6d7f4d

This line had been added because an earlier release of libstrophe missed
the initialisation of that variable, which has since been fixed.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-12 16:30:19 +01:00
Steffen Jaeckel
64046bcdf3 Fix some things regarding char* vs. gchar*
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-12-09 15:09:52 +01:00
Michael Vetter
0e66cbe458
Merge pull request #1937 from H3rnand3zzz/fix/db-edge-scrolling
Fix scrolling state at windows edge
2023-12-05 15:14:56 +01:00
John Hernandez
0d29e05d77
Fix scrolling state at windows edge
The problem: if user scrolled to the edge of the window, the state that
edge is reached, transfers to other windows, rendering user unable to
scroll further up/down in other windows as well.

Make unique states for each window that show that edge of the DB is reached.

Later it might be improved with MAM states as well to decrease load on program
in cases when user keeps scrolling despite reaching the edge.

Bug discovered by @atomicwatch, reported through the developers' MUC

`SCROLL_INNER` naming suggestion by @jubalh
2023-12-05 13:28:55 +01:00
Michael Vetter
bd0aa3eb85
Merge pull request #1824 from H3rnand3zzz/feature/mouse-scroll
Smooth scrolling support (+mouse wheel scrolling in some terminals)
2023-12-05 12:25:41 +01:00
Michael Vetter
889593ad6c
Merge pull request #1936 from H3rnand3zzz/fix/underscrolling
Fix underscrolling problem
2023-12-04 16:27:35 +01:00
John Hernandez
d7e46d64fe
Fix underscrolling problem
The problem is caused by ncurses library rendering only 1000 lines, while
it's possible that we have long messages in the buffer.

Current buffer limit is 200 messages, with just average size of message
of 10 lines, ncurses buffer is being overflown and we render only part
of the message. This causing a problem of "underscrolling": user is unable
to scroll to the top or bottom and he is stuck somewhere in the middle
of the history.

It's not a permanent solution, but rather a temporary fix before
introducing line-counting which will align Profanity's message buffer size
in **lines** with ncurses' limits. It might be even adjustable setting
in the future.

The problem was caused by a faulty logic that 1 message = 1 line and
it's a second try to address it, the try earlier was
ea39657b0a.
2023-12-04 15:56:50 +01:00
John Hernandez
23692fedff
Add ALT+UP/DOWN/mouse wheel scroll support
Before the change, the only way to scroll was usage of page up/down,
it allowed to scroll only by skipping pages, which was not smooth.
2023-11-28 15:04:53 +01:00
Michael Vetter
9ef05f4185
Merge pull request #1933 from H3rnand3zzz/fix/wrong-encoding-error-flood-python-plugins
Improve string convertion error handling
2023-11-22 12:42:17 +01:00
John Hernandez
db96d13453
Improve string convertion error handling
Before the change, profanity has shown
`TypeError: prof_pre_chat_message_display() missing 3 required positional arguments: 'barejid',
           'resource', and 'message'`
error for received messages with incorrect encoding
instead of proper error handling for string convertion.

That is a temporary fix, correct fix probably would be
passing potentially problematic char* as `bytes` (using `y` instead of `s` format),
but this would require API changes and hence correction of plugins to
handle new input parameters properly (likely with "decode" function).

A bit hard to reproduce. You need to add a plugin with the following code
(or any other plugin with `prof_pre_chat_message_display` present, such as emoticons.py):
```python
def prof_pre_chat_message_display(barejid, resource, message):
    return message
```

and then receive/send message with incorrectly encoded character, it can be any
invalid UTF8 symbol. You'll see error in console, errors don't represent actual
errors in plugins, but rather Profanity's shortcoming, though it make appear so
that the problem is in plugin.

Actual proper handling would likely be using `y` instead of `s` format
(see [reference](https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue))

> s ([str](https://docs.python.org/3/library/stdtypes.html#str) or None) [const char *]
>    Convert a null-terminated C string to a Python [str](https://docs.python.org/3/library/stdtypes.html#str)
object using 'utf-8' encoding. If the C string pointer is NULL, None is used.

to

> y ([bytes](https://docs.python.org/3/library/stdtypes.html#bytes)) [const char *]
>     This converts a C string to a Python [bytes](https://docs.python.org/3/library/stdtypes.html#bytes)
> object. If the C string pointer is NULL, None is returned.

since there is a [problem](https://docs.python.org/3/c-api/arg.html) with `s`:
> s ([str](https://docs.python.org/3/library/stdtypes.html#str)) [const char *]
>    Convert a Unicode object to a C pointer to a character string.
> A pointer to an existing string is stored in the character pointer variable whose address you pass.
> ... Unicode objects are converted to C strings using 'utf-8' encoding.
> **If this conversion fails**, a [UnicodeError](https://docs.python.org/3/library/exceptions.html#UnicodeError) is raised.

In python such problem can be handled using `errors='ignore'` in [bytes.decode](https://docs.python.org/3/library/stdtypes.html#bytes.decode) or in a more sophisticated manner, depending on needs and realization.
2023-11-22 09:29:31 +01:00
Michael Vetter
dc8776e285
Merge pull request #1912 from H3rnand3zzz/feature/dynamic-statusbar
Add new mode for statusbar tab behaviour
2023-11-20 15:20:21 +01:00
John Hernandez
917558dc87
Separate new tabmode in a setting
Return static tabmode as default,
separate previous change in `dynamic` mode.

Despite usefulness of the solution,
it was not approved to be a new default.

Vote (link below) amongst users to change default
has shown inconclusive result and it was not representative,
as it had low number of participants.
https://github.com/profanity-im/profanity/pull/1912#issuecomment-1816232546
2023-11-20 15:03:59 +01:00
John Hernandez
619309ad9b
Fix pagination in statusbar
This commit changes the current behaviour which displays always the first
tabs until `maxtabs` to display N tabs around the currently selected tab.

So if we are having a maxtab of 1 and the actively selected window is 2,
then 2 is displayed only.

So far we have only displayed `>` to indicate that there are more windows.
Since this PR shifts the range of tabs that are displayed we also add `<`
indicator now to indicate windows to the left of the currently displayed.

Fix https://github.com/profanity-im/profanity/issues/1283
Fix https://github.com/profanity-im/profanity/issues/1764
2023-11-20 15:02:58 +01:00
Michael Vetter
8ba248c87e
Merge pull request #1918 from H3rnand3zzz/fix/plugins-pre-display
Fix `prof_pre_chat_message_display` does not replace sent messages + minor refactoring
2023-11-20 11:27:45 +01:00
Michael Vetter
e143513f20
Merge pull request #1932 from H3rnand3zzz/cleanup/refactor-conf-string-list
Fix mem leak in `conf_string_list_add`
2023-11-20 11:27:20 +01:00
John Hernandez
bd2821fafa
Fix mem leak in conf_string_list_add
Introduced in 1cf7973245
Issue reported and fix proposed by @sjaeckel
2023-11-17 21:13:32 +01:00
Michael Vetter
62e1de0f51
Merge pull request #1931 from H3rnand3zzz/feature/redraw-command
Introduce `/redraw` command
2023-11-14 14:02:47 +01:00
John Hernandez
a1ff88caae Introduce /redraw command
`/redraw` command allows resolve problem for usual users,
as well as developers.

Incredibly useful when debugging with something that
can trash out the output, like GDB.

Not to mention many asynchronous commands that can break the UI
at any point.
2023-11-14 13:32:37 +01:00
Michael Vetter
7718990c08
Merge pull request #1924 from H3rnand3zzz/fix/unintended-exits
Fix unintended exits on some commands
2023-11-14 12:49:42 +01:00
Michael Vetter
9bc68eaab3
Merge pull request #1930 from H3rnand3zzz/cleanup/inputwin
Minor `inputwin.c` refactoring/cleanup
2023-11-14 12:46:03 +01:00
John Hernandez
3dcca35f34 Minor inputwin.c refactoring/cleanup
Function `inp_nonblocking` is changed
to fetch the `inpbloc` pref only once.

`inp_win_resize` cleaned up a bit.
2023-11-13 12:09:38 +01:00
Michael Vetter
08d2a51ae4
Merge pull request #1927 from H3rnand3zzz/feature/print-newline-char
Handle alt+enter as newline char
2023-11-13 09:46:05 +01:00
Michael Vetter
740c209a0d
Merge pull request #1926 from H3rnand3zzz/fix/mam-dupe-stanza-id-flood
Do not check for unique `stanza-id` for MAM messages
2023-11-13 09:41:06 +01:00
John Hernandez
dac6d0c4f8 Handle alt+enter as newline char
Let user print newline character using alt+enter keybind,
it allows great flexibility in communication,
now user will be able to write much better longer messages.
2023-11-13 09:40:04 +01:00
John Hernandez
d3566b1203 Do not check for unique stanza-id for MAM messages
Since we might have MAM messages already received earlier
it doesn't make sense to require unique stanza-ids there.
Fix https://github.com/profanity-im/profanity/issues/1925.
2023-11-13 09:34:53 +01:00
Michael Vetter
e8101aad6b
Merge pull request #1920 from H3rnand3zzz/cleanup/refactor-conf-string-list
Minor `config/conflists.c` refactoring
2023-11-13 09:34:13 +01:00
Michael Vetter
80ab0505e2
Merge pull request #1923 from H3rnand3zzz/cleanup/test-file
Format `test_cmd_otr.c`
2023-11-13 09:33:25 +01:00
John Hernandez
b19f668392 Fix: add plugins_pre_chat_message_display call for outgoing messages
Ensure consistent invocation of `plugins_pre_chat_message_display`
for outgoing messages. Before the change, the function was not
called for sent messages upon sending, but only on fetching
sent messages from DB.

Fix https://github.com/profanity-im/profanity/issues/1917
2023-11-11 22:21:50 +01:00
John Hernandez
16ed7cc187 Refactor plugins_pre_chat_message_display for Memory Management
Refactor function to enhance memory handling, addressing
temporary workaround introduced in 2e0adbd. Adjustments
ensure cleaner code and maintainability.

Part of the improvements suggested by @sjaeckel.
2023-11-11 22:21:04 +01:00
John Hernandez
1c02239ef6 Fix unintended exits on some commands
On some commands execution (like `/privacy logging X`
where X is any symbol/group of symbols)
FALSE is being returned.
Which main cycle understands as a signal to exit profanity.
The mistake is common since returns are often used by
developers to communicate success status.

First reported by @doctor in the Profanity MUC,
as exit on `/logging group color` command.
2023-11-11 13:58:47 +01:00
John Hernandez
53db7562b5 Format test_cmd_otr.c 2023-11-11 10:04:38 +01:00
John Hernandez
1cf7973245 Minor config/conflists.c refactoring
Refactor functions `conf_string_list_add`, `conf_string_list_remove`:
simplify the logic, improve readability and avoid unnecessary allocations.
2023-11-11 08:41:00 +01:00
Michael Vetter
bba8278bb7 Fix passing of wrong parameter to cmd executable template function
`/executable vcard_photo test`

Printed
`Invalid usage, see '/help card_photo' for details.`

So it used the subcommand instead of the command and lost one of the
letters as well.

This mistake got introduced in 60c197487.
Where we added helper functions for the various `/executable` functions.

Discovered by @H3rnand3zzz with correct solution.

Fix https://github.com/profanity-im/profanity/issues/1921
2023-11-10 23:01:27 +01:00
Michael Vetter
74178806a8
Merge pull request #1919 from H3rnand3zzz/patch-1
Fix double free crash
2023-11-10 22:12:31 +01:00
Michael Vetter
1d3378a583
Merge pull request #1922 from H3rnand3zzz/fix/plugins-install-follow-redirect
Allow redirects for  `/plugins install` and add emptiness check for downloaded files
2023-11-10 22:10:31 +01:00
John Hernandez
092b5530b2 Add emptiness check for /url save and /plugins install
Empty file is not a normal condition for file downloading,
thus user has to be notifed.

Related to https://github.com/profanity-im/profanity/issues/1901
2023-11-10 20:05:01 +01:00
John Hernandez
30fe5f0fb9 Allow redirects for '/plugins install <URL>
Fix https://github.com/profanity-im/profanity/issues/1901
Suggested by @jubalh
2023-11-10 20:04:04 +01:00