Commit Graph

78 Commits

Author SHA1 Message Date
a96a4ad41e fix(review): address PR #94 reviewer comments
Blockers:
- SPDX/CProof copyright headers (7 files)
- stanza-id non-uniqueness: warn-only, don't skip (matches SQLite)
- fopen → open(O_EXCL|O_NOFOLLOW, 0600) + fdopen in export

Medium:
- log_info → log_warning for SQLite fallback
- remove prefs_save() auto-save from backend switch
- vtable null → log_warning in 4 dispatch functions
- log_debug → log_warning + null error handling in export
- rename failure → cons_show_error to user
- remove unused total_skipped variable
- LMC respects PREF_CORRECTION_ALLOW

Low nits:
- man page .SS fix + jabber.space URL
- profrc.example simplified
- show flatfile path on /logging flatfile
- EXPORT_PROGRESS_INTERVAL constant (magic 500)
- FF_META_PREFIX_ID/AID constants + FF_INDEX_STEP comment
- buffer overflow guard on close[1]/close[2]
- for-loop → memchr for JID resource scan
- BOM check extracted to ff_skip_bom() (DRY)
- index building extracted to _ff_maybe_index_line()
- O_APPEND+O_EXCL comment rewritten
- Makefile.am spaces → tabs
2026-03-28 12:38:39 +03:00
507ef91b5f feat: complete field parity, harden export/import, add tests
Export/Import improvements:
- Replace pagination with direct SQL query (db_sqlite_get_all_chat)
- Wrap import in SQL transaction with rollback on error
- Add fsync before fclose in export for data safety
- Sort merged output by timestamp with secondary key (stanza_id, from_jid)
- Export archive_id and marked_read from SQLite (lossless migration)
- Add progress indication every 500 messages during write/import
- Expand dedup key body prefix from 64 to 256 chars
- Fix g_slist_append O(n²) → g_slist_prepend + g_slist_reverse O(n)

Field parity (to_jid, to_resource, marked_read):
- Add fields to ff_parsed_line_t struct
- Write/parse to:|to_res:|read: metadata tags in flatfile format
- Pass to_resource through _ff_add_message and all callers
- Add marked_read to ProfMessage struct with -1 default (unset)
- Preserve fields across export/import round-trips

Tests (19 new: 11 unit + 8 functional):
- Unit: to_jid_and_marked_read, bracket_in_stanza_id, backslash_in_resource,
  mucpm_type, all_enc_types, crlf_handling, to_jid_special_chars,
  multiple_lines, parsed_line_free_null_safe, no_space_rejected,
  unclosed_bracket
- Functional: export_idempotent_no_duplicates, export_lmc_correction_survives,
  switch_preserves_old_backend_data, export_all_contacts,
  import_double_dedup, verify_after_export,
  switch_backends_independent_messages, export_empty_contact
- Rebalance test groups: move Chat Session from Group 3 to Group 4
  (25/33/30/27 instead of 25/33/36/21)
- Remove hardcoded test counts from group comments

Man page:
- Document /history switch sqlite|flatfile
2026-03-12 18:46:42 +03:00
1f3d3117bf feat(draft): add /history export|import for SQLite<->flatfile migration
DRAFT — not yet tested end-to-end with a live XMPP session.

New commands:
  /history export [<jid>]  — copy messages from SQLite to flat-file
  /history import [<jid>]  — copy messages from flat-file to SQLite
Both merge with existing data; duplicates are skipped using stanza-id
or a SHA-256 fallback key (timestamp + sender + body prefix).

Implementation (src/database_export.c):
- Export: paginate SQLite via get_previous_chat, read existing flatfile
  for dedup, write merged result via ff_write_line + atomic rename
- Import: parse flatfile lines via ff_parse_line, build dedup set from
  SQLite, insert new messages via add_incoming (preserves original
  timestamps for both directions)
- List all contacts: db_sqlite_list_contacts() queries UNION of
  DISTINCT from_jid/to_jid; flatfile enumerates flatlog directories

Wiring:
- database.h: declare export/import functions + db_sqlite_list_contacts
- database_sqlite.c: add db_sqlite_list_contacts()
- cmd_defs.c: add export/import to /history synopsis and args
- cmd_funcs.c: add export/import handlers in cmd_history()
- cmd_ac.c: add 'export' and 'import' to history_ac
- Makefile.am: add database_export.c to core_sources
- stub_database.c: add stubs for test linking
- profanity.1: document export/import in man page

All code guarded with #ifdef HAVE_SQLITE — builds cleanly without it.
2026-03-12 18:46:42 +03:00
23723376c6 fix: harden flatfile backend, make SQLite optional
Build system:
- Add --without-sqlite configure flag (AM_CONDITIONAL BUILD_SQLITE)
- Guard database_sqlite.c with HAVE_SQLITE in Makefile.am, database.c,
  database.h and stub_database.c
- Fall back to flatfile when SQLite not compiled in

Security (database_flatfile.c):
- MAM dedup: skip incoming messages with duplicate stanza-id (archive_id)
- LMC sender validation: reject corrections from mismatched JIDs
- Add flock() advisory locking to prevent interleaved writes from
  concurrent instances
- Check fprintf return when writing file header

Autocomplete (cmd_ac.c):
- Add 'flatfile' to /privacy logging autocomplete
- Add dedicated /history autocomplete with on/off/verify (was boolean-only)

Code quality:
- Fix fwrite return type: size_t not ssize_t (database_flatfile_parser.c)
- Fix mixed allocators in ff_readline: use malloc() consistently for
  overlength-line fallback instead of g_strdup()
- Fix index alignment in _ff_state_extend: use local counter so index
  step doesn't depend on total_lines from initial build

Documentation:
- Fix page: correct directory structure (history.log not per-day files)
- Fix page: add aid:{archive_id} to line format example
- Fix page: missing newline before .SH BUGS
2026-03-12 18:46:42 +03:00
31e8c30c34 feat: add flat-file database backend for message history
Add pluggable storage backend abstraction (vtable) to the database layer,
allowing selection between SQLite (default) and a new flat-file backend
that stores messages as human-readable plain text files.

New files:
- database_sqlite.c: extracted SQLite backend from database.c
- database_flatfile.c: plain text backend with tolerant parser,
  LMC correction chains, UTF-8/BOM/CRLF handling, integrity checks

Commands:
- /privacy logging flatfile — switch to flat-file backend
- /history verify [<jid>] — check integrity of stored history

Fixes:
- Add missing 'off' guard in flatfile backend
- Enable CHLOG/HISTORY prefs when switching to flatfile mode

Logs stored in ~/.local/share/profanity/flatlog/{account}/{contact}/{date}.log
Format: {ISO8601} [{type}|{enc}|id:{id}|corrects:{id}] {sender}: {message}

Updated: CHANGELOG, CONTRIBUTING.md, profrc.example, man page, cmd_defs,
Makefile.am, test stubs, functional test support (PROF_FLATFILE=1)
2026-03-12 18:46:42 +03:00
Michael Vetter
07dfeec816 Release 0.15.0 2025-03-27 20:06:38 +01:00
Steffen Jaeckel
662a0be633 Add --cmd option
This allows to kind of automate what profanity should do as first jobs,
e.g. `--cmd /foo --cmd /bar --cmd /quit` so one can easily check for memory
leaks.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-07 21:09:16 +01:00
John Hernandez
23692fedff Add ALT+UP/DOWN/mouse wheel scroll support
Before the change, the only way to scroll was usage of page up/down,
it allowed to scroll only by skipping pages, which was not smooth.
2023-11-28 15:04:53 +01:00
John Hernandez
dac6d0c4f8 Handle alt+enter as newline char
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.
2023-11-13 09:40:04 +01:00
Stefan Kropp
2ef528ecd7 Add section Using profanity to profanity.1 2023-10-28 20:38:23 +02:00
Michael Vetter
fd2b977d6a Fix my email 2023-08-04 08:35:27 +02:00
Michael Vetter
6b0fddd925 Release 0.14.0 2023-08-03 08:01:43 +02:00
Michael Vetter
1b679498b6 doscs: Add terminology section to man page
Let's just define some basic terminology.

In many sections of the /help we actually use these terms.
This should help new users understand what they mean.
2023-04-17 11:25:44 +02:00
Michael Vetter
ee6bf23b8d Add encryption section to man page
The goal should be that users can make a more informed decision about
which encryption they actually want to use.

We can also use this to document usage details of implementation quirks,
if any.
2023-04-17 10:59:41 +02:00
Michael Vetter
e1d45f05d3 Update to new mailing list
Maintained by https://github.com/StefanKropp
2023-03-01 15:25:41 +01:00
Michael Vetter
3adc399da0 Update copyright year 2023-01-10 10:37:25 +01:00
Michael Vetter
0bae298746 Update mailing list link 2023-01-10 10:24:44 +01:00
Michael Vetter
3e7457f42a Release 0.13.1 2022-10-12 16:56:20 +02:00
Michael Vetter
a8e6b26ee1 Release 0.13.0 2022-09-13 11:50:49 +02:00
Michael Vetter
e8ae825709 Add minor hint to manpage 2022-06-28 18:24:42 +02:00
Michael Vetter
1330ad4e1e Update copyright year 2022-05-09 15:43:33 +02:00
Paul Fertser
18242102f8 Mention C-x C-r (reload inputrc) in the man page
Add mentions of less-known but quite useful bindindings to the man
page.
2022-04-09 11:14:12 +03:00
Michael Vetter
e87d09aabf Release 0.12.1 2022-04-04 18:13:32 +02:00
Paul Fertser
8ffa6f7452 Document custom input configuration in man page 2022-03-30 22:41:49 +03:00
Paul Fertser
66bd041617 Improve manpage formatting a bit 2022-03-30 21:01:40 +03:00
Paul Fertser
3478438df5 Add all missing key bindings to man page 2022-03-30 20:59:21 +03:00
Michael Vetter
9214b0a10a Release 0.12.0 2022-03-30 14:08:49 +02:00
Michael Vetter
e6f96cd7d7 Release 0.11.1 2021-09-28 19:48:42 +02:00
Michael Vetter
619204f4f5 man: add more keybindings 2021-09-15 11:24:59 +02:00
Michael Vetter
c89e31269c Mention keybindings in man page 2021-08-31 22:33:00 +02:00
Michael Vetter
d382023961 Release 0.10.0 2021-01-09 08:08:10 +01:00
Michael Vetter
300b60722b Mention new manpages in main manpage 2020-12-04 17:50:30 +01:00
Michael Vetter
3af5f33489 0.9.5 2020-07-01 18:47:07 +02:00
Michael Vetter
1332a4a6c2 Release 0.9.4 2020-06-24 13:56:34 +02:00
Michael Vetter
177c953991 Release 0.9.3 2020-06-19 20:29:31 +02:00
Michael Vetter
c58726d67f Release 0.9.2 2020-06-13 18:37:51 +02:00
Michael Vetter
8551d3dcb1 Release 0.9.1 2020-06-11 10:06:56 +02:00
Michael Vetter
439c6a63b9 Correct and update manpage 2020-06-09 16:34:34 +02:00
Michael Vetter
7d7f0ef5a5 Update copyright in manpage 2020-05-16 10:03:55 +02:00
Michael Vetter
a1ee1ad139 Add description of new flags to manpage 2020-05-16 10:02:19 +02:00
toogley
03b75c833d Update mailing list in manpage 2020-05-16 09:49:13 +02:00
Michael Vetter
10ca3e8c31 Possibility to specify alternative config file
Introduce `profanity -c` to specify an alternative config file.
2019-08-02 15:55:47 +02:00
Michael Vetter
d4892b29c4 Update profanity repo URL
Move from github.com/boothj5/* to github.com/profanity-im/*
2019-05-03 10:51:28 +02:00
Michael Vetter
6f59a57b68 Update profanity URL in manpage
Regards https://github.com/profanity-im/profanity/issues/1085
2019-05-03 10:27:13 +02:00
kaffeekanne
f8640019f3 Update copyright years 2019-04-24 01:08:38 +02:00
Raf Czlonka
89fcaed31d Fix style and warnings - found with mandoc -T lint 2018-10-20 09:50:31 +01:00
James Booth
250e972b7a Update copyright 2018-01-21 15:00:02 +00:00
James Booth
68a3daedb9 Update Copyright 2017-01-28 17:24:22 +00:00
James Booth
a49c63fc75 Updated man page 2016-08-21 23:48:22 +01:00
Pete Maynard
14c8f53f85 Updated GPL URL 2016-07-21 11:49:52 +01:00