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

91 Commits

Author SHA1 Message Date
Michael Vetter
569e37f018 Update copyright to 2024 2024-01-22 16:03:48 +01:00
John Hernandez
4fe2c423b1
Fix overscrolling issue
Before there was a problem of overscrolling:
when messages longer than y axis of the terminal are fetched from the DB,
profanity scroll "jumps" to the top, skipping some messages.

It's resolved by keeping messages' starting and ending line in the
internal profanity buffer, which allows to track proper message positions
and to adjust window position accordingly.

Message size is now tracked as part of the buffer's record in `_line`
variable, which allows calculation of the total buffer size, which
might be a part of the improved solution for the "underscrolling" problem,
if we are going to limit profanity's buffer size by amount of lines as
opposed to the limitation based on the amount of message which is currently
used.

Before adding a limitation by amount of lines, careful consideration is
required, as some users don't use history and their temporary message
history can be cut to minimal limit because of 1 long received/sent message.

Underscrolling problem was fixed in a previous commit
d7e46d64fe
Short recap of the problem:
Despite user scrolling to top/bottom of history,
factual position is offset from the intended location

Another feature of this commit is a minor change which adds fetching
message stanza IDs from the DB. It allows correcting messages
fetched from history.

Fixes https://github.com/profanity-im/profanity/issues/1934
2023-12-21 17:32:30 +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
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
John Hernandez
bc38ddf8fa Improve handling of NULL pointers in DB
Fix crash that occurs when message fetched from the database is NULL.

Introduced in this commit
89dc7a46f1

Previous fix attempt
6d17b4eeb5
2023-11-07 14:09:58 +01:00
Steffen Jaeckel
a99dda9a97 Handle potential NULL pointers in database
Follow-up of 89dc7a46f1 resp. #1902

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-11-07 11:27:17 +01:00
Michael Vetter
45fe1be58f
Merge pull request #1902 from H3rnand3zzz/feature/improved-history
Change DB structure
2023-11-06 22:41:36 +01:00
Steffen Jaeckel
4c26462827 Ensure instances of auto types are initialized
Follow-up of #1913

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-11-06 22:22:35 +01:00
John Hernandez
89dc7a46f1 Improve Database: Replace Empty Strings with NULL Values
Enhance data consistency by updating the database to treat empty
strings as NULL values. This change simplifies queries and improves
overall database integrity.
2023-11-06 18:20:39 +01:00
John Hernandez
d89b5a04fa Change DB stucture, improve LMC behaviour
**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/1893
https://github.com/profanity-im/profanity/issues/1899
https://github.com/profanity-im/profanity/pull/1902
2023-11-03 20:32:01 +01:00
Steffen Jaeckel
1d41a328f1 Fix loading of encryption type
The column of the encryption type in the result is 4, not 3.

Fixup of 6375b2719f

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-10-30 16:06:37 +01:00
Michael Vetter
3bd50fdd6a Unify error logging in database.c
Mentioned in review of:
https://github.com/profanity-im/profanity/pull/1898
2023-10-17 11:28:28 +02:00
John Hernandez
24d0030ecc Check sender for LMC messages
When we received a message correction via `XEP-0308: Last Message Correction`
we accepted the change without checking the sender
making it possible for anybody to replace the message if the ID was known.

This change has been proposed by @jubalh
https://github.com/profanity-im/profanity/pull/1893#issuecomment-1752434740
2023-10-17 11:11:10 +02:00
John Hernandez
403f924462 Add logging to DB message insertion
Add logging for cases when the message is not being inserted in the DB due to its ID.

Make diagnostic of unreliable message history much easier,
lay the groundwork for a fully reliable message history.

Further changes might include insertion of messages with non-unique stanza-id,
but as it's a big change with plentiful issues, decision was made
to further investigate potential causes of history unreliability.

For details see #1893 discussion
2023-10-14 13:29:17 +02:00
Michael Vetter
e853c121d9 Fix my email address
in all files
2023-07-31 16:51:58 +02:00
John Hernandez
029f1caa52 Cleanup jid_destroy to auto_jid
Remove unused variables
Apply minor cleanups
2023-07-13 17:05:07 +02:00
John Hernandez
8304ac86ff g_free() to auto_gfree, introduce auto_guchar
Fix 11 potential mem leaks in theme.c
2023-07-13 17:04:59 +02:00
John Hernandez
e1d137f4e6 Change char->free to auto_char char for autocleanup
Replace `gchar` and `g_free` to `auto_gchar`
Correct certain  `char` functions/variables to `gchar`

Related to #1819.

Edited by @jubalh.
2023-07-11 13:26:37 +02:00
John Hernandez
1c102fec27 Add /privacy logging command
Add ability to completely turn logs off,
Needed since `/logging` and `/history` didn't stop history logging
in the DB, only in files.
Command might break something on usage,
hence it was primarily introduced for privacy geeks.
Privacy command discussion #1836
2023-07-03 16:06:24 +02:00
Steffen Jaeckel
76a8de891e Improve const-correctness of API
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-05-12 08:39:19 +02:00
Steffen Jaeckel
e886ba0c6f fix more memory leaks
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2023-01-18 20:11:13 +01:00
Michael Vetter
3adc399da0 Update copyright year 2023-01-10 10:37:25 +01:00
Michael Vetter
688191f5e1 Fix merge mistake in database
When doing 3bdc14dbcf I forgot an `,`
before encryption
2022-10-21 16:39:44 +02:00
Michael Vetter
3bdc14dbcf Merge MAM improvements from #1724
I think this PR already solves and improves the MAM situation a lot.

What's @MarcoPolo-PasTonMolo still wanted to do in this branch is:
* MAM for mucs
* Check if url and quotes autocompletion works fine
* Check if the api still works fine
* Resolve conflicts

Conflicts are solved with this commit.

MAM for mucs can be another feature PR.

The rest we can check while being on master. And more people can help
testing.
2022-10-21 13:30:43 +02:00
MarcoPolo-PasTonMolo
4b9ff6d4dc Apply corrections when getting messages from db 2022-08-12 12:13:47 +03:00
MarcoPolo-PasTonMolo
a2f79a19b9 Fix duplicate sent messages in db 2022-07-10 11:17:35 +03:00
MarcoPolo-PasTonMolo
85aaf40432 Have ability to scroll through history even without MAM 2022-07-10 11:17:35 +03:00
MarcoPolo-PasTonMolo
47b3e528e2 Handle scrolling down when buffer fills up 2022-07-10 11:17:35 +03:00
MarcoPolo-PasTonMolo
4d6e95d691 Add loading history message on initial MAM request
This prevents scrolling to top and initiating another MAM request while
still fetching the initial one.
Also free timestamp object in database.c
2022-07-05 11:12:29 +03:00
MarcoPolo-PasTonMolo
6429698f18 Fix initial MAM not displaying
Did this by waiting for a batch of MAM messages to arrive before
prepending them to the buffer. Also limited the number of messages
to fetch to 10 so that the user gets more frequent updates.
2022-07-05 00:06:04 +03:00
MarcoPolo-PasTonMolo
ea83165a35 Get messages from history when scrolling up. 2022-07-03 21:29:36 +03:00
MarcoPolo-PasTonMolo
f0202a2fe0 On new chatwin fetch mam according to guidelines.
Taken from here:
cd3e871e55
2022-07-03 21:23:07 +03:00
Michael Vetter
3d17ecc62b database: remove comment 2022-06-29 15:31:37 +02:00
Michael Vetter
6375b2719f database: retrieve encryption type
When we get a message from the database, also retrieve the encryption
type.
2022-06-29 15:30:54 +02:00
Michael Vetter
dfc51f7ba4 database: unref date 2022-06-29 09:42:54 +02:00
Michael Vetter
31e6b7564e Include xmpp and message header to database.c
That was pulled in through log.h.
2022-06-28 20:08:44 +02:00
Michael Vetter
1330ad4e1e Update copyright year 2022-05-09 15:43:33 +02:00
Steffen Jaeckel
b8e46552bf add files_file_in_account_data_path()
As all parts of the code invoking the `files_get_account_data_path()`
function did the same afterwards, a function has been added with the same
behavior.

1. create path
2. `mkdir` of that path
3. return final path

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2022-03-13 14:15:02 +01:00
Steffen Jaeckel
9cf78e59d5 auto-format
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2022-02-01 15:01:28 +01:00
Juraj Mlich
c5b370bffc database.c: fix inserting messages to chat logs if archive_id is empty
The original intention of the code was that in case archive_id is not set, NULL should be inserted. What is
inserted however is an empty string. This causes the condition to not insert messages with non-unique
archive_id insert only one message in total and ignore all further ones (if NULL was there, the condition
would work properly). And this in turn causes chat history not work properly.

This commit makes the SQL condition work properly and therefore fixes chat history.

Fixes #1589.
2021-12-31 17:45:45 +01:00
Michael Vetter
f21595597f Format code correctly 2021-10-05 10:01:27 +02:00
CIacademic
e4d23d9364 Escape all parameters in SQL statements
Some more parameters might contain quotes, so escape all of them
with %q by using sqlite3_mprintf.
2021-06-11 14:16:43 +00:00
Michael Vetter
1ec606540e Get rid of asprintf and _GNU_SOURCE define
_GNU_SOURCE was even in some files where it was not needed at all
(http*).

Let's replace asprintf() with g_strdup_printf().
2021-03-30 17:38:13 +02:00
Michael Vetter
057c9ad776 Add config.h in files were it was missing
Related to https://github.com/profanity-im/profanity/issues/1512
2021-03-26 19:54:22 +01:00
Michael Vetter
901f9d3d8c database: make log_database_get_previous_chat safer 2021-03-25 16:46:18 +01:00
Michael Vetter
e93d4ff331 database: simplify _log_database_add_outgoing 2021-03-25 16:45:30 +01:00
Michael Vetter
c0e339130e database: simplify log_database_add_incoming 2021-03-25 16:44:36 +01:00
kaffeekanne
49dc9c5755 Calm OpenBSD syslog
On every write to `chatlog.db` syslog throws
```
profanity: vfprintf %s NULL in "INSERT INTO `ChatLogs` (`from_jid`,
`from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`,
`stanza_id`, `archive_id`, `replace_id`, `type`, `encryption`) SELECT
'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' WHERE
NOT EXISTS (SELECT 1 FROM `ChatLogs` WHERE `archive_id` = '%s')"
```
in `/var/log/messages`. Checking for `NULL` except in the fields the DB
is expected to throw errors for, satisfies OpenBSDs security measures
2021-02-15 15:58:35 +01:00
Philipp Klaus Krause
6a276e74e3 Since the string from strerror should never be modified, use const. 2020-10-14 09:52:26 +02:00
Michael Vetter
7f5169c2e9 Use g_date_time_format_iso8601()
This partly reverts d3a387a0ec.

For proanity 0.9.x we still wanted to support older glib versions so
that we can be packaged for various linux distros.

Now with 0.10 we want to move on.
2020-09-30 19:43:58 +02:00