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.
**Please, backup your DB before performing any testing.**
Introduce new DB structure and DB migration mechanism.
Index `timestamp`, `to_jid`, `from_jid` columns to improve performance.
Add trigger for `replaced_by_db_id` calculation by DB on message insert.
Now LMC messages are interconnected with original messages,
this way we have fast access to last (hence correct) applicable edits,
as well as reference to the original message from any edit (in case of chained edits).
Change the way LMC messages are being displayed. Now we check if we
can replace a message from current buffer. If we don't have a message in
the buffer, it might've been lost, but we can still display it as a
new message.
Further information available here:
https://github.com/profanity-im/profanity/pull/1893https://github.com/profanity-im/profanity/issues/1899https://github.com/profanity-im/profanity/pull/1902
Refactor getting char, introduce get_show_char() to follow DRY principle.
In theory, performance might be negatively affected after this change.
Ideally get_show_char should be optimized in the future.
Stop fetching message from DB when profanity reached start or end of the history
with the user. This allows to save resources on page up/down
when ceiling or bottom accordingly are reached.
Currently buffer is being redrawn on each DB fetch,
this causes a big waste of resources as on every page_up button click
we redraw 1200 messages (each message can be longer than 1 line),
commit will reduce buffer size to 200,
thus reducing amount of messages redrawn on each page up,
this is a temporary solution for a bigger problem.
Previously we printed a format string into a `GString` to then print that
result again into a `GString` and display that.
This patch removes one level of `GString` printing by forwarding the
`va_arg` to the newly added API `win_println_va()`.
Introducing `static win_println_va_internal()` also allowed refactoring
most of the `win_print*()` and `win_append*()` implementations and removing
all the redundant code.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Thanks to @alarixnia fot the patch and bugreport.
```
Forwarding a bug reported using the NetBSD bug tracker ("Profanity crashes at login"): http://gnats.netbsd.org/57050
The code in question here handles messages by people not in the user's contact list, and what is probably happening is that the XMPP server is sending such a message before profanity has set up its window layout.
Setting roster.unsubscribed=false indeed makes profanity start without crashing, and the attached patch bails out early in the problematic code path if layout->subwin is NULL (Adrian verified for me that either of the two makes profanity work for him again). But I am not familiar enough with the profanity code to say if this has any issues.
Profanity compiled with ncurses doesn't crash because ncurses's wattron() has a guard against the user passing null pointers, but the X/Open curses library standard doesn't have this guarantee and there's no guard in the NetBSD curses implementation.
```
Fix https://github.com/profanity-im/profanity/issues/1769
Refactor `p_gpg_list_keys`
Add `/pgp autoimport` command,
it's not described in XEP-0027, but used in some clients,
such as PSI, Pidgin. It will autoimport keys received with
`/pgp sendpub`, in plain text as a message, or using features,
provided in other clients. It doesn't autoassign them, but shows
command to assign, letting user to decide.
Improve documentation for some preexisting functions
Add contact argument to `/pgp sendpub`
`MB_CUR_MAX` looks like a macro, but it's a function call and therefore
creates a VLA. We don't want that.
Also this array being uninitialized created the following Valgrind error
```
==503529== Conditional jump or move depends on uninitialised value(s)
==503529== at 0x619F15E: waddnstr (lib_addstr.c:67)
==503529== by 0x1929B7: _inp_write (inputwin.c:353)
==503529== by 0x1937D5: _inp_redisplay (inputwin.c:619)
==503529== by 0x61511B1: rl_forced_update_display (display.c:2693)
==503529== by 0x193F9D: _inp_rl_send_to_editor (inputwin.c:957)
==503529== by 0x614642F: _rl_dispatch_subseq (readline.c:916)
==503529== by 0x6146C85: _rl_dispatch_callback (readline.c:823)
==503529== by 0x616739F: rl_callback_read_char (callback.c:241)
==503529== by 0x1923DB: inp_readline (inputwin.c:188)
==503529== by 0x149860: prof_run (profanity.c:117)
==503529== by 0x2283E8: main (main.c:186)
==503529== Uninitialised value was created by a stack allocation
==503529== at 0x1928B1: _inp_write (inputwin.c:334)
```
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Introduce new feature: sessions_alarm.
Added new account setting: max_connections. On exceeding this number,
user will get an alert. If number is less than 1, no alert will happen.
Tests altered to fit new feature.
Expected behaviour
When you type
/command
/command
it should be just 1 entry in the history.
Behaviour
All the entries were saved.
Behaviour is changed by introducing check. Before adding to history,
entry now is compared to the last history entry.
- Fixes statusbar tabs.
Bug: Statusbar used nickname if it was set in roster,
irrelevant to /statusbar chat setting.
Expected behaviour would be using this setting set as "user" to show nickname,
and to show jid with "jid" setting.
Other solution is to give a user control over it with another settings.
- _status_bar_draw_maintext cleaned up, no changes to behaviour
Before this change, only nickname or JID (if no nickname set) is shown in the titlebar.
Change allows to alter nickname/JID preference
using already implemented /titlebar show jid|name setting.
If both are set to "show", then it is displayed in "nickname <JID>" format.
The existing way how active tabs are displayed didn't allow showing more
than 10 tabs. This patch adds a mode where the statusbar shows a
comma-separated list of tabs which were active since the last time viewed.
This view is inspired by how `irssi` shows the active tabs, therefore
it is also called `actlist`.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
It is possible, that a server sends a form with a field as follows, which
has no (default) value assigned.
```
<field label="foo" type="list-single" var="bar">
<option label="a"><value>a</value></option>
<option label="b"><value>b</value></option>
<option label="c"><value>c</value></option>
</field>
```
This patch fixes profanity to show that list. Before this patch
profanity showed nothing.
I stumbled over this while running the `/room config` command inside
a newly created muc on the `sure.im` XMPP server.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>