98c38dc6d6
sets C99 as standard.
strdup() is not part of C99.
For now set `-D_POSIX_C_SOURCE=200809L` macro to have strdup() in C99.
Using `gnu99` instead would be another option.
We should take more care to use glib functions whenever possible.
Regards https://github.com/profanity-im/profanity/issues/1357
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.
If I'm not mistaken MUC PMs have not been logged at all if there was no
other client sending carbons.
This should add MUC PM logging functionality.
We still need to make sure carbons log to the same file.
Regards https://github.com/profanity-im/profanity/issues/1214
So far if one had enabled `/history` and did `/msg somenick` the history
was loaded from file and displayed like this:
```
04-04-17 15:23 - 3/4/2017:
01-01-00 10:30 - me: ....
01-01-00 10:31 - somebody: ....
01-01-00 10:32 - somebody: ....
```
So the first line contained the actual date. But the date used in each
line was always 01-01-2000. This date was for some reason hardcoded.
This commit now actually uses that date to build the proper GDateTime
instead of just printing it.
Fix https://github.com/profanity-im/profanity/issues/922
If we get a private message from a user in a MUC profanity shows this
like:
`profanity@roomsASDF.dismail.de/Martin: Hi`
This was so far logged at:
`~/.local/share/profanity/chatlogs/my-account-at-server/profanity_at_rooms.dismail.de/2019_09_04.log` as:
```
10:48:13 - profanity@rooms.dismail.de: Hi
```
So the nickname was not saved anywhere. This is due to us not knowing
whether we got a regular message from user@server.org/resource or a MUC
PM from room@server.org/user.
We now check for `<x xmlns='http://jabber.org/protocol/muc#user' />` and
add the resourcepart to the logging if we get it.
The file will be created at
`~/.local/share/profanity/chatlogs/my-account-at-server/profanity_at_rooms.dismail.de_nick` and look like:
```
23:59:43 - nick: Hi
```
Fix https://github.com/profanity-im/profanity/issues/1184
Glib can print error messages to stderr and blocking write freezes
Profanity if the buffer is full. Move stderr to nonblocking mode
in hope that glib will skip printing on EWOULDBLOCK error. In this
case we lose some error messages, but Profanity continues working.
Probably missing copy of body to plain in carbon and privmessage.
Only covers the incoming message path because goal is OMEMO decryption
of untrusted message.
Cover some of the log functions but not all.
With gcc8 we get the following error when stringop-truncation is on:
```
In function ‘_rotate_log_file’,
inlined from ‘log_msg.part.2’ at src/log.c:201:17:
src/log.c:231:5: error: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
strncpy(log_file_new, log_file, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/log.c: In function ‘log_msg.part.2’:
src/log.c:228:18: note: length computed here
size_t len = strlen(log_file);
^~~~~~~~~~~~~~~~
```
Using memcpy instead of strncpy.
This handler redirects stderr output to a pipe and gathers logs from the
read end.
The handler is called from main loop, therefore, if a function prints logs
to stderr they will be put to log file only after function returns.