about summary refs log tree commit diff stats
path: root/src/database.c
Commit message (Collapse)AuthorAgeFilesLines
* fix more memory leaksSteffen Jaeckel2023-01-181-3/+11
| | | | Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* Update copyright yearMichael Vetter2023-01-101-1/+1
|
* Fix merge mistake in databaseMichael Vetter2022-10-211-1/+1
| | | | | When doing 3bdc14dbcf1114fa1ea68cd6f455eecf90a9ac5e I forgot an `,` before encryption
* Merge MAM improvements from #1724Michael Vetter2022-10-211-4/+63
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Apply corrections when getting messages from dbMarcoPolo-PasTonMolo2022-08-121-1/+1
| |
| * Fix duplicate sent messages in dbMarcoPolo-PasTonMolo2022-07-101-2/+3
| |
| * Have ability to scroll through history even without MAMMarcoPolo-PasTonMolo2022-07-101-4/+7
| |
| * Handle scrolling down when buffer fills upMarcoPolo-PasTonMolo2022-07-101-5/+5
| |
| * Add loading history message on initial MAM requestMarcoPolo-PasTonMolo2022-07-051-1/+3
| | | | | | | | | | | | This prevents scrolling to top and initiating another MAM request while still fetching the initial one. Also free timestamp object in database.c
| * Fix initial MAM not displayingMarcoPolo-PasTonMolo2022-07-051-5/+8
| | | | | | | | | | | | 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.
| * Get messages from history when scrolling up.MarcoPolo-PasTonMolo2022-07-031-2/+7
| |
| * On new chatwin fetch mam according to guidelines.MarcoPolo-PasTonMolo2022-07-031-0/+45
| | | | | | | | | | Taken from here: https://github.com/modernxmpp/modernxmpp/commit/cd3e871e55c2cff45dffd05d6e50380b99845849
* | database: remove commentMichael Vetter2022-06-291-1/+1
| |
* | database: retrieve encryption typeMichael Vetter2022-06-291-2/+20
| | | | | | | | | | When we get a message from the database, also retrieve the encryption type.
* | database: unref dateMichael Vetter2022-06-291-1/+3
| |
* | Include xmpp and message header to database.cMichael Vetter2022-06-281-0/+2
|/ | | | That was pulled in through log.h.
* Update copyright yearMichael Vetter2022-05-091-1/+1
|
* add `files_file_in_account_data_path()`Steffen Jaeckel2022-03-131-21/+1
| | | | | | | | | | | | 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>
* auto-formatSteffen Jaeckel2022-02-011-1/+1
| | | | Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* database.c: fix inserting messages to chat logs if archive_id is emptyJuraj Mlich2021-12-311-1/+1
| | | | | | | | | | | 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.
* Format code correctlyMichael Vetter2021-10-051-12/+12
|
* Escape all parameters in SQL statementsCIacademic2021-06-111-8/+5
| | | | | Some more parameters might contain quotes, so escape all of them with %q by using sqlite3_mprintf.
* Get rid of asprintf and _GNU_SOURCE defineMichael Vetter2021-03-301-21/+20
| | | | | | | _GNU_SOURCE was even in some files where it was not needed at all (http*). Let's replace asprintf() with g_strdup_printf().
* Add config.h in files were it was missingMichael Vetter2021-03-261-0/+2
| | | | Related to https://github.com/profanity-im/profanity/issues/1512
* database: make log_database_get_previous_chat saferMichael Vetter2021-03-251-0/+2
|
* database: simplify _log_database_add_outgoingMichael Vetter2021-03-251-2/+1
|
* database: simplify log_database_add_incomingMichael Vetter2021-03-251-2/+1
|
* Calm OpenBSD syslogkaffeekanne2021-02-151-5/+5
| | | | | | | | | | | | | 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
* Since the string from strerror should never be modified, use const.Philipp Klaus Krause2020-10-141-1/+1
|
* Use g_date_time_format_iso8601()Michael Vetter2020-09-301-8/+2
| | | | | | | | | This partly reverts d3a387a0ec6e5265f625de87318be2de610efb01. 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.
* database: Only insert if there is no entry with same archive_idMichael Vetter2020-07-231-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | archive_is is <stanza-id> or <result id=""> and should identify one message stable and uniquely. See XEP-0359: Unique and Stable Stanza IDs. We need this for example for this situation: * we go online with Profanity * we fetch all messages since yesterday * we add them to the db * we go offline * we go online with Profanity * we fetch all messages since yesterday * we only want to add the new ones So far we don't ask MAM "give me all since last 'id'" but since a certain date. In case no archive_id will be set, it will be `(null)` and thus should be inserted anyways because it won't find a value with (null) in that row. Because when adding we use `message->stanzaid ? message->stanzaid : "",` so it will be empty in such a case. Regards MAM: https://github.com/profanity-im/profanity/issues/660 Regards Stable IDs: https://github.com/profanity-im/profanity/issues/1207
* Apply coding styleMichael Vetter2020-07-071-65/+72
|
* Revert "Apply coding style"Michael Vetter2020-07-071-76/+69
| | | | | | This reverts commit 9b55f2dec0ea27a9ce4856e303425e12f866cea2. Sorting the includes creates some problems.
* Apply coding styleMichael Vetter2020-07-071-69/+76
| | | | Regards https://github.com/profanity-im/profanity/issues/1396
* Use files_get_account_data_path instead of duplicate codeMichael Vetter2020-07-011-16/+10
| | | | | We often had a use case where we want the account specific data dir. Let's create a function for this instead of doing it by hand each time.
* Feature request - XEP-0373: OpenPGP for XMPP (OX)DebXWoody2020-06-291-1/+3
| | | | | | | | | Basic implementation of XEP-0373: OpenPGP for XMPP. https://xmpp.org/extensions/xep-0373.html Command /ox Issue: #1331
* Fix carbon loggingMichael Vetter2020-05-271-4/+8
| | | | Regards https://github.com/profanity-im/profanity/issues/1342
* Escape message before adding to SQL backendMichael Vetter2020-04-181-1/+5
|
* Add to_jid field to ProfMessage structMichael Vetter2020-04-111-4/+5
| | | | | Is usefult in many cases if we want cleaner code. Hope this edit didn't break anything though ;-)
* Fix error in getting previous chatlogMichael Vetter2020-04-101-1/+5
| | | | | | | | | Our search was too broad, and thus incorrect. One of the various mistakes it can cause was https://github.com/profanity-im/profanity/issues/1308 Fix https://github.com/profanity-im/profanity/issues/1308
* Retrieve message type from databaseMichael Vetter2020-04-081-1/+16
| | | | So we don't have to check for MUC another way.
* Downgrade dependenciesMichael Vetter2020-04-071-2/+8
| | | | | | | | | | | Use g_date_time_format() instead of g_date_time_format_iso8601() to only rely on glib 2.56.0 which is the latest version in Debian Buster (current stable). We also only use basic sqlite functions so 3.27.0 should be fine there (also the one in Debian buster). Thanks to @DebXWoody.
* Add missing includesMichael Vetter2020-04-061-0/+3
|
* db: actually display the last 10 entries in correct orderMichael Vetter2020-04-061-1/+1
|
* db: get last messages sorted by timestampMichael Vetter2020-04-061-1/+1
|
* db: Use type from message struct instead of having individual functionsMichael Vetter2020-04-061-75/+79
|
* db: Fix memleaksMichael Vetter2020-04-061-0/+1
|
* Add sql to error logMichael Vetter2020-04-061-2/+2
| | | | so we can more easily grep for it.
* Remove chat_log_get_previous()Michael Vetter2020-04-061-2/+2
| | | | | | | | | | | | We now dont get the log files from the text files via chat_log_get_previous() anymore. We use the sql backend via log_database_get_previous_chat(). So far it just has the same behaviour like chat_log_get_previous(), except that in _chatwin_history() we don't pass the sender to win_print_history() which should be fixed in a commit soon. And log_database_get_previous_chat() can later easily be expanded to fix https://github.com/profanity-im/profanity/issues/205.
* Get regular chat history out of sql backendMichael Vetter2020-04-061-2/+44
|