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>
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>
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>
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>
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
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.
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.
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
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
`/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.
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.
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
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.
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.
`/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