Compare commits

...

63 Commits

Author SHA1 Message Date
886372caac build: add cache to ./configure with -C flag
All checks were successful
CI Code / Check spelling (pull_request) Successful in 23s
CI Code / Check coding style (pull_request) Successful in 38s
CI Code / Linux (arch) (pull_request) Successful in 12m20s
CI Code / Linux (ubuntu) (pull_request) Successful in 14m59s
CI Code / Linux (debian) (pull_request) Successful in 15m18s
Add the -C flag to ./configure to enable caching, reducing redundant
resource fetching during builds when packages and the machine remain
unchanged. Caching may cause issues only if applied across different machines
or if packages are modified, neither of which is the case during the build.
2025-10-14 09:47:14 +00:00
0b0b02d6e0 build: use local libstrophe version and limit depth
`--depth 1` flag ensures that only latest version is loaded (since there is no need to sync full git)
Using local libstrophe version increases speed of fetching
2025-10-14 09:47:14 +00:00
d748ffc527 build: Add multithreading to make
nproc is a standard util that prints amount of available processes.
-j is a flag that specifies how many cores can be utilized by `make` (default is 1)
-j$(nproc) allows to use all the available machine cores, potentially significantly speeding up completion of CI actions
2025-10-14 09:47:14 +00:00
fac1e224bc fix(scroll): handle edge case of extremely long messages
All checks were successful
CI Code / Check coding style (pull_request) Successful in 34s
CI Code / Check spelling (pull_request) Successful in 45s
CI Code / Linux (arch) (pull_request) Successful in 10m43s
CI Code / Linux (ubuntu) (pull_request) Successful in 13m11s
CI Code / Linux (debian) (pull_request) Successful in 16m46s
CI Code / Check spelling (push) Successful in 18s
CI Code / Check coding style (push) Successful in 32s
CI Code / Linux (arch) (push) Successful in 12m56s
CI Code / Linux (debian) (push) Successful in 13m28s
CI Code / Linux (ubuntu) (push) Successful in 16m20s
Prior commit (6ad8a190) did not properly handle overflow by long (9000 lines) message,
to address this issue, multiple changes were made:
- Add lines recalculation on win_redraw
- Move `prof_buff_t` struct to header file so its lines could be externally changed
- Call win_redraw once overflow is detected: it allows to recalculate sizes in lines and apply changes to the buffer
2025-10-08 13:00:32 +02:00
6ad8a19053 fix(buffer): use dynamic buffer size to prevent unnecessary buffer cleanups
All checks were successful
CI Code / Check spelling (pull_request) Successful in 22s
CI Code / Check coding style (pull_request) Successful in 38s
CI Code / Linux (arch) (pull_request) Successful in 13m4s
CI Code / Linux (debian) (pull_request) Successful in 13m32s
CI Code / Linux (ubuntu) (pull_request) Successful in 16m23s
CI Code / Check spelling (push) Successful in 19s
CI Code / Check coding style (push) Successful in 37s
CI Code / Linux (arch) (push) Successful in 13m8s
CI Code / Linux (ubuntu) (push) Successful in 16m2s
CI Code / Linux (debian) (push) Successful in 16m26s
Refactor buffer trimming logic to use dynamic line counts (_lines per entry)
against PAD_SIZE (10k) instead of fixed entry count (MAX_BUFFER_SIZE=200). This
prevents premature cleanups for short messages, reduces scrolling disruptions
during history loads, and scales better with rendered content size.

Delete oldest/newest entry from opposite end only when total lines approach
ncurses pad limit, minimizing unnecessary deletions.
Simplify overflow warning log by removing unused MAX_BUFFER_SIZE reference.

Update buffer.c header for improved DX:
- Add detailed module overview explaining role (in-memory UI buffer vs. DB
persistence), key features (trimming, metadata), and integration (ncurses).
- Shorten copyright/license boilerplate to concise pointer (LICENSE ref).
- Add fork notice; preserve original copyrights per GPLv3.

Partially addresses #36 (stuck scroll mitigation via fewer cleanups)
Related to #36
2025-10-07 15:12:20 +02:00
40dd773c6a docs(apidocs/c): improve profapi.h and profhooks.h comments
All checks were successful
CI API Docs / Test C API Documentation Generation (pull_request) Successful in 23s
CI API Docs / Test Python API Documentation Generation (pull_request) Successful in 26s
CI Code / Check coding style (pull_request) Successful in 33s
CI Code / Check spelling (pull_request) Successful in 20s
CI Code / Linux (debian) (pull_request) Successful in 12m26s
CI Code / Linux (ubuntu) (pull_request) Successful in 12m46s
CI Code / Linux (arch) (pull_request) Successful in 15m17s
CI API Docs / Test C API Documentation Generation (push) Successful in 28s
CI API Docs / Test Python API Documentation Generation (push) Successful in 29s
- Enhanced file-level comments with concise descriptions
- Added usage examples and aligned with Python prof module style
- Updated function comments to remove tables, improve clarity
- Replaced Profanity with CProof, preserved paths and method names
2025-09-23 14:07:32 +02:00
8849d9b79e docs: move callbacks down
All checks were successful
CI API Docs / Test C API Documentation Generation (pull_request) Successful in 26s
CI API Docs / Test Python API Documentation Generation (pull_request) Successful in 28s
CI Code / Check coding style (pull_request) Successful in 36s
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Linux (debian) (pull_request) Successful in 13m40s
CI Code / Linux (ubuntu) (pull_request) Successful in 14m9s
CI Code / Linux (arch) (pull_request) Successful in 21m18s
To improve readability of the docs
2025-09-22 23:05:45 +02:00
92cb930810 docs: Fix indentation
All checks were successful
CI API Docs / Test C API Documentation Generation (pull_request) Successful in 26s
CI API Docs / Test Python API Documentation Generation (pull_request) Successful in 28s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Linux (debian) (pull_request) Successful in 13m38s
CI Code / Linux (ubuntu) (pull_request) Successful in 16m18s
CI Code / Linux (arch) (pull_request) Successful in 16m46s
2025-09-17 01:37:10 +02:00
9fd62e2304 ci: restructure and optimize execution conditions
Some checks failed
CI API Docs / Test C API Documentation Generation (pull_request) Successful in 26s
CI API Docs / Test Python API Documentation Generation (pull_request) Failing after 28s
CI Code / Check coding style (pull_request) Has been cancelled
CI Code / Check spelling (pull_request) Has been cancelled
CI Code / Linux (arch) (pull_request) Has been cancelled
CI Code / Linux (debian) (pull_request) Has been cancelled
CI Code / Linux (ubuntu) (pull_request) Has been cancelled
- The code tests will ignore doc changes and vice versa.
- The CI is split in 2 parts for clarity
2025-09-17 01:00:30 +02:00
c94263486f docs(python): fix formatting to ensure correct parsing
Fixes issues introduced in 052e168, 4cdcf9a, and other commits from PR #31.
2025-09-17 00:34:37 +02:00
353b6bdb11 Merge branch 'build/add-api-docs-gen-tests'
All checks were successful
CI / Check spelling (push) Successful in 20s
CI / Test C API Documentation Generation (push) Successful in 23s
CI / Check coding style (push) Successful in 33s
CI / Test Python API Documentation Generation (push) Successful in 28s
CI / Linux (debian) (push) Successful in 13m38s
CI / Linux (ubuntu) (push) Successful in 14m7s
CI / Linux (arch) (push) Successful in 17m5s
2025-09-15 16:54:33 +02:00
105c496ab1 docs(sphinx): fix conf.py and index.rst to resolve warnings
All checks were successful
CI / Check spelling (pull_request) Successful in 19s
CI / Test C API Documentation Generation (pull_request) Successful in 23s
CI / Check coding style (pull_request) Successful in 31s
CI / Test Python API Documentation Generation (pull_request) Successful in 29s
CI / Linux (debian) (pull_request) Successful in 13m34s
CI / Linux (ubuntu) (pull_request) Successful in 14m4s
CI / Linux (arch) (pull_request) Successful in 17m4s
- Removed unnecessary list item (*) from :ref:`genindex`.
- Added blank line after :ref:`genindex` to terminate markup block.
- Rebranded configs
2025-09-15 16:12:47 +02:00
cb6f302208 docs(prof.py): add CommandCallback, TimedCallback, WindowCallback protocols
Some checks failed
CI / Check spelling (pull_request) Successful in 22s
CI / Test C API Documentation Generation (pull_request) Successful in 26s
CI / Check coding style (pull_request) Successful in 36s
CI / Test Python API Documentation Generation (pull_request) Failing after 28s
CI / Linux (debian) (pull_request) Has been cancelled
CI / Linux (arch) (pull_request) Has been cancelled
CI / Linux (ubuntu) (pull_request) Has been cancelled
- Defined callback protocols for register_command, register_timed, win_create.
- Fixed Sphinx callable warnings with proper type hints.
- Align docs with the code
2025-09-15 15:47:10 +02:00
4cdcf9a8eb docs(plugin): update plugin.py to align with formatting required by Sphinx
- Replace Profanity with CProof in all docstrings and examples.
- Remove Python 2 and unicode references, using Python 3 str types.
- Add type hints for all parameters and return types.
- Use :: for code blocks with blank lines to fix Sphinx errors.
- Improve wording for clarity and integrated examples into docstrings.
- Organize functions into logical sections with RST comments.
- Use double backticks for inline literals to resolve Sphinx warnings.
2025-09-15 11:53:49 +02:00
7e4c60e2c3 ci(Doxygen): Enable warning as error
Some checks failed
CI / Check spelling (pull_request) Successful in 25s
CI / Test C API Documentation Generation (pull_request) Successful in 1m21s
CI / Check coding style (pull_request) Successful in 1m59s
CI / Test Python API Documentation Generation (pull_request) Failing after 1m30s
CI / Linux (debian) (pull_request) Successful in 13m58s
CI / Linux (ubuntu) (pull_request) Successful in 14m18s
CI / Linux (arch) (pull_request) Successful in 19m30s
To ensure that CI builds fails to reflect issues within the documentations
2025-09-10 19:38:24 +02:00
e998d5e7ef docs: fix C API documentation
Some checks failed
CI / Check spelling (pull_request) Successful in 45s
CI / Test C API Documentation Generation (pull_request) Successful in 1m20s
CI / Check coding style (pull_request) Successful in 1m29s
CI / Test Python API Documentation Generation (pull_request) Failing after 1m24s
CI / Linux (ubuntu) (pull_request) Has been cancelled
CI / Linux (debian) (pull_request) Has been cancelled
CI / Linux (arch) (pull_request) Has been cancelled
`barejid` parameter was used instead of the intended `roomjid`, leading to warnings during compilation.
2025-09-10 19:35:21 +02:00
3ffeda1531 ci: Disable Doxygen HTML generation
Some checks failed
CI / Check spelling (pull_request) Successful in 48s
CI / Test C API Documentation Generation (pull_request) Successful in 1m5s
CI / Check coding style (pull_request) Successful in 1m35s
CI / Test Python API Documentation Generation (pull_request) Failing after 1m17s
CI / Linux (debian) (pull_request) Has been cancelled
CI / Linux (ubuntu) (pull_request) Has been cancelled
CI / Linux (arch) (pull_request) Has been cancelled
Since only XML is being used during website build process, generation of HTML involves unnecessary computations.
2025-09-10 19:32:34 +02:00
a4cead7fe8 ci: Update doxygen config file via doxygen -u
Some checks failed
CI / Check spelling (pull_request) Successful in 22s
CI / Test C API Documentation Generation (pull_request) Successful in 28s
CI / Check coding style (pull_request) Successful in 37s
CI / Test Python API Documentation Generation (pull_request) Failing after 28s
CI / Linux (ubuntu) (pull_request) Has been cancelled
CI / Linux (debian) (pull_request) Has been cancelled
CI / Linux (arch) (pull_request) Has been cancelled
2025-09-10 19:30:24 +02:00
052e168e9b docs(prof.py): overhaul documentation to align with Google Python Style Guide
Some checks failed
CI / Check spelling (pull_request) Successful in 39s
CI / Test C API Documentation Generation (pull_request) Successful in 52s
CI / Check coding style (pull_request) Successful in 1m26s
CI / Test Python API Documentation Generation (pull_request) Failing after 1m7s
CI / Linux (ubuntu) (pull_request) Successful in 13m21s
CI / Linux (debian) (pull_request) Successful in 15m48s
CI / Linux (arch) (pull_request) Successful in 20m26s
- Updated project references from Profanity to CProof.
- Removed Python 2 and unicode references.
- Added type hints for all parameters and return types.
- Organized functions into logical sections with RST comments for Sphinx.
- Improved wording for clarity and precision based on source code analysis.
- Ensured compliance with Google Python Style Guide for readable docstrings.

Related to #30
2025-09-10 19:05:33 +02:00
c94cd0b549 ci: add GitHub Actions workflow to test C and Python API doc generation
Introduce separate jobs to test C (Doxygen) and Python (Sphinx) API documentation generation. Ensures build failures are caught early, as API changes often produce warnings that developers miss without automated checks.
2025-09-10 19:05:32 +02:00
4780fdd4a1 tests: update cmocka include in forced encryption tests
All checks were successful
CI / Check spelling (pull_request) Successful in 21s
CI / Check coding style (pull_request) Successful in 36s
CI / Linux (debian) (pull_request) Successful in 15m53s
CI / Linux (ubuntu) (pull_request) Successful in 15m58s
CI / Linux (arch) (pull_request) Successful in 16m35s
CI / Check spelling (push) Successful in 19s
CI / Check coding style (push) Successful in 34s
CI / Linux (ubuntu) (push) Successful in 14m46s
CI / Linux (debian) (push) Successful in 15m26s
CI / Linux (arch) (push) Successful in 17m52s
Includes were updated in 988d366, but the change did not propagate to forced_encryption.c due to the gap between the upstream Profanity and the CProof.
2025-09-10 15:50:26 +02:00
Steffen Jaeckel
9b1cb6ab85 If config keyfile does not exist, create it.
All checks were successful
CI / Check spelling (pull_request) Successful in 22s
CI / Check coding style (pull_request) Successful in 36s
CI / Linux (ubuntu) (pull_request) Successful in 14m11s
CI / Linux (debian) (pull_request) Successful in 16m2s
CI / Linux (arch) (pull_request) Successful in 20m21s
CI / Check spelling (push) Successful in 19s
CI / Check coding style (push) Successful in 34s
CI / Linux (debian) (push) Successful in 13m41s
CI / Linux (ubuntu) (push) Successful in 15m3s
CI / Linux (arch) (push) Successful in 20m23s
Fixes #1911
Alternative to #2056

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>

(cherry picked from commit b12521ca21)
2025-09-10 14:20:08 +02:00
Michael Vetter
f419e65fad Update issue templates
According to the new way: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates

(cherry picked from commit 5dcbd84f75)
2025-09-10 14:18:01 +02:00
Michael Vetter
110b3d27b4 Rename issue template
Seems like GH changed how the templates work.

(cherry picked from commit f1e12a33cf)
2025-09-10 14:17:15 +02:00
Steffen Jaeckel
75b378cf54 Don't use memchr() on strings potentially shorter than 4 bytes.
When running profanity under Valgrind with slashguard enabled, the
following error could occur:

```
[...]
==4021347== Invalid read of size 1
==4021347==    at 0x4851F49: memchr (vg_replace_strmem.c:986)
==4021347==    by 0x45CEAD: _inp_slashguard_check (inputwin.c:183)
==4021347==    by 0x45CEAD: inp_readline (inputwin.c:225)
==4021347==    by 0x431184: prof_run (profanity.c:121)
==4021347==    by 0x42C609: main (main.c:176)
==4021347==  Address 0xe850883 is 0 bytes after a block of size 3 alloc'd
==4021347==    at 0x48477C4: malloc (vg_replace_malloc.c:446)
[...]
```

`memchr()` requires the complete memory that shall be searched to be
accessible. Using `strchr()` could work for shorter strings, but we only
want to search in the first 4 chars.

Instead of somehow working around those limitations, simply search manually
in the first 4 bytes.

Fixes: 3c56b289 ("Add slashguard feature")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>

(cherry picked from commit 7f48452d84)
2025-09-10 14:16:19 +02:00
Steffen Jaeckel
988d3663d1 Introduce tests/prof_cmocka.h
As 9f2abc75 accidentally got the ordering of some of the includes wrong,
I decided to propose my initial solution again.

Additional to that, I've opened a MR against CMocka to solve this on
their side, since I believe that the current way this is done is not
sustainable [0].

[0] https://gitlab.com/cmocka/cmocka/-/merge_requests/91

Fixes: 9f2abc75 ("Fix tests with gcc15 (uintptr_t)")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>

CProof note: our new tests need to also be updated.
2025-09-10 14:11:03 +02:00
Steffen Jaeckel
d3fa1c2f78 Tidy up some code
* less allocations
* less duplicate code

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>

(cherry picked from commit 9d335729a0)
2025-09-10 14:07:41 +02:00
Steffen Jaeckel
1a385b8cd2 Refactor slashguard
Fixes #2054
Fixes: 95c2199c ("Some more memory improvements")

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
(cherry picked from commit 40aafd06e7)
2025-09-10 14:05:30 +02:00
Steffen Jaeckel
39aab45162 Fix memory leak.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>

(cherry picked from commit e0f107f75e)
2025-09-10 14:01:22 +02:00
Steffen Jaeckel
0d5123e69a Trampoline Python unref again.
In the past `Py_XDECREF()` was a macro. Preserve compat to ancient Python
versions by having a trampoline which calls `Py_XDECREF()`.

Fixes: #2043
Fixes: c0da36c4 ("Rage-cleanup.")

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
(cherry picked from commit 3299dd8fc6)
2025-09-10 14:00:51 +02:00
Steffen Jaeckel
36f183d6a4 Separate entries visually in my-prof.supp
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>

(cherry picked from commit 3370f8a7f1)
2025-09-10 14:00:07 +02:00
Martin Dosch
6b6576b31c Fix typo in examples.
(cherry picked from commit 5696bf77c7)

Author:    Martin Dosch <martin@mdosch.de>
2025-09-10 13:58:57 +02:00
Andreas Stieger
1ae78400a4 Fix tests with gcc15 (uintptr_t)
fixes: error: ‘uintptr_t’ undeclared, defined in header ‘<stdint.h>
(cherry picked from commit 9f2abc75ad)

Author:    Andreas Stieger <Andreas.Stieger@gmx.de>
2025-09-10 13:57:36 +02:00
ea8a758ecf Merge branch 'fix/correct-autocompletion'
All checks were successful
CI / Check spelling (push) Successful in 18s
CI / Check coding style (push) Successful in 31s
CI / Linux (debian) (push) Successful in 10m43s
CI / Linux (arch) (push) Successful in 13m6s
CI / Linux (ubuntu) (push) Successful in 13m13s
2025-09-02 14:20:23 +02:00
2808def933 fix(chatwin): Fix LMC autocompletion to suggest corrected message content
All checks were successful
CI / Check spelling (pull_request) Successful in 18s
CI / Check coding style (pull_request) Successful in 33s
CI / Linux (debian) (pull_request) Successful in 9m45s
CI / Linux (ubuntu) (pull_request) Successful in 10m0s
CI / Linux (arch) (pull_request) Successful in 16m48s
- Modified chatwin_outgoing_msg to call _chatwin_set_last_message for corrected messages, using replace_id per XEP-0308.
- Updated _chatwin_set_last_message to skip redundant and invalid free/strdup for same pointers.
- Added null checks in _chatwin_set_last_message for safety.
- Fixes autocompletion suggesting original message content instead of corrected content.

Fixes #24
2025-09-02 00:29:13 +02:00
741dc4c275 fix(ui.h): cons_show_qrcode declaration. Minor change
All checks were successful
CI / Check spelling (pull_request) Successful in 17s
CI / Check coding style (pull_request) Successful in 30s
CI / Linux (debian) (pull_request) Successful in 10m43s
CI / Linux (arch) (pull_request) Successful in 13m6s
CI / Linux (ubuntu) (pull_request) Successful in 13m18s
CI / Check coding style (push) Successful in 36s
CI / Check spelling (push) Successful in 20s
CI / Linux (debian) (push) Successful in 9m44s
CI / Linux (ubuntu) (push) Successful in 10m3s
CI / Linux (arch) (push) Successful in 12m12s
Prior to the change declaration did not include parameters,
leading to errors within static analyzers and potential issues with compilation.
2025-09-01 23:29:26 +02:00
65cf9ddb9c fix(cmd_sub): Prevent crash with malformed JID in /sub command
Added null check for jidp in cmd_sub to handle jid_create returning NULL.

Crash occurred when processing malformed JID inputs like @example.com.

Ensures robust handling of invalid JIDs.

Fixes #22
2025-09-01 23:29:26 +02:00
51d2355d97 fix(cmd_caps): Prevent crash in /caps with malformed JID input
All checks were successful
CI / Check spelling (pull_request) Successful in 15s
CI / Check coding style (pull_request) Successful in 29s
CI / Linux (debian) (pull_request) Successful in 9m54s
CI / Linux (ubuntu) (pull_request) Successful in 10m15s
CI / Linux (arch) (pull_request) Successful in 11m51s
CI / Check spelling (push) Successful in 18s
CI / Check coding style (push) Successful in 31s
CI / Linux (debian) (push) Successful in 10m35s
CI / Linux (ubuntu) (push) Successful in 11m0s
CI / Linux (arch) (push) Successful in 13m26s
- Added null check for `jid` in `cmd_caps` to handle `jid_create` returning NULL.
- Crash occurred when processing malformed inputs like `@example.com` in `/caps`.
- Ensures robust handling of invalid JID strings in `WIN_CHAT` and `WIN_CONSOLE` cases.

Fixes #20
2025-09-01 21:28:19 +02:00
e33c7a477d docs(rebranding): update readme
All checks were successful
CI / Check spelling (push) Successful in 16s
CI / Check coding style (push) Successful in 32s
CI / Linux (debian) (push) Successful in 10m39s
CI / Linux (arch) (push) Successful in 13m3s
CI / Linux (ubuntu) (push) Successful in 13m7s
2025-09-01 16:57:10 +02:00
f4405d114a Add unit tests for forced encryption check function
All checks were successful
CI / Check coding style (pull_request) Successful in 35s
CI / Check spelling (pull_request) Successful in 18s
CI / Linux (debian) (pull_request) Successful in 10m28s
CI / Linux (ubuntu) (pull_request) Successful in 10m51s
CI / Linux (arch) (pull_request) Successful in 13m17s
CI / Check spelling (push) Successful in 17s
CI / Check coding style (push) Successful in 33s
CI / Linux (arch) (push) Successful in 12m53s
CI / Linux (ubuntu) (push) Successful in 12m56s
CI / Linux (debian) (push) Successful in 13m4s
2025-08-27 16:48:27 +02:00
442bfb6ce1 feat: Add /force-encryption command and update message handling
All checks were successful
CI / Check spelling (pull_request) Successful in 18s
CI / Check coding style (pull_request) Successful in 34s
CI / Linux (ubuntu) (pull_request) Successful in 14m5s
CI / Linux (debian) (pull_request) Successful in 14m5s
CI / Linux (arch) (pull_request) Successful in 14m53s
Implement /force-encryption command to configure forced encryption
settings with on|off and policy resend-to-confirm|block options.

The changes enhance user experience by clarifying encryption requirements
and providing actionable commands. Users can now press Enter again to
confirm unencrypted messages in resend-to-confirm mode.
2025-08-25 21:11:27 +02:00
a3e23c3514 Temporarily disable Fedora tests
All checks were successful
CI / Check spelling (pull_request) Successful in 15s
CI / Check coding style (pull_request) Successful in 28s
CI / Linux (arch) (pull_request) Successful in 11m52s
CI / Linux (ubuntu) (pull_request) Successful in 11m59s
CI / Linux (debian) (pull_request) Successful in 12m2s
CI / Check spelling (push) Successful in 17s
CI / Check coding style (push) Successful in 30s
CI / Linux (ubuntu) (push) Successful in 10m9s
CI / Linux (arch) (push) Successful in 12m4s
CI / Linux (debian) (push) Successful in 13m0s
They are failing on our runners due to issues with dependency resolution.
2025-08-07 03:27:14 +02:00
ad294cdd6d feat(editor): add asynchronous external editor support
Some checks failed
CI / Check spelling (pull_request) Successful in 18s
CI / Check coding style (pull_request) Successful in 31s
CI / Linux (fedora) (pull_request) Failing after 1m14s
CI / Linux (debian) (pull_request) Successful in 10m19s
CI / Linux (ubuntu) (pull_request) Successful in 10m42s
CI / Linux (arch) (pull_request) Successful in 13m2s
The synchronous `get_message_from_editor` blocked the main loop (`prof_run`) while launching an external editor like `vim`, halting network I/O in `session_process_events` and preventing incoming message reception.

Introduced `get_message_from_editor_async` for `cmd_editor` to run the editor asynchronously. It forks and execs the editor in a thread (`editor_thread`), suspending NCurses to free the terminal. The main loop skips `inp_readline` and `ui_update` via a new `background_mode` flag while the editor runs, allowing `session_process_events` to keep the connection alive.

On editor completion, `editor_process` (called per loop iteration) resumes NCurses with `ui_resize`, inserts the result into the readline buffer and clears `background_mode`.

Retained synchronous `get_message_from_editor` for ~20 existing code paths (e.g., `vcard_nickname`) to avoid breaking them.

Tested with `vim` and `nano`: confirms no rendering conflicts, messages received during editing, and seamless resume. Edge cases like editor crashes handled via error logging and seamless resume.
2025-08-07 03:03:43 +02:00
e1ce7ac630 fix(caps): Add features in caps_init to avoid redundant presence updates
All checks were successful
CI / Check spelling (pull_request) Successful in 1m26s
CI / Check coding style (pull_request) Successful in 1m37s
CI / Linux (debian) (pull_request) Successful in 9m54s
CI / Linux (ubuntu) (pull_request) Successful in 10m11s
CI / Linux (fedora) (pull_request) Successful in 14m56s
CI / Linux (arch) (pull_request) Successful in 16m38s
CI / Check spelling (push) Successful in 15s
CI / Check coding style (push) Successful in 26s
CI / Linux (debian) (push) Successful in 9m49s
CI / Linux (ubuntu) (push) Successful in 10m1s
CI / Linux (fedora) (push) Successful in 12m59s
CI / Linux (arch) (push) Successful in 13m51s
Previously, features like `XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY` were
added in separate init methods (e.g., `omemo_devicelist_subscribe`) via
`caps_add_feature`, triggering `cl_ev_presence_send` and sending multiple
"online" XMPP presence stanzas. This caused other clients to see users
as appearing "online" multiple times.

This change adds `STANZA_NS_MOOD_NOTIFY` and
`XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY` in `caps_init`, ensuring they are
in `prof_features` early. This allows `caps_add_feature` to exit early
when called for these features, avoiding redundant presence updates.
2025-07-19 18:33:03 +02:00
5ed8ec30f0 Update name and license
All checks were successful
CI / Linux (debian) (pull_request) Successful in 11m26s
CI / Linux (arch) (pull_request) Successful in 13m51s
CI / Linux (fedora) (pull_request) Successful in 12m27s
CI / Check coding style (pull_request) Successful in 30s
CI / Check spelling (pull_request) Successful in 14s
CI / Linux (ubuntu) (pull_request) Successful in 11m43s
CI / Linux (debian) (push) Successful in 11m31s
CI / Linux (arch) (push) Successful in 13m51s
CI / Linux (fedora) (push) Successful in 12m16s
CI / Check coding style (push) Successful in 29s
CI / Check spelling (push) Successful in 17s
CI / Linux (ubuntu) (push) Successful in 11m49s
2025-07-19 14:32:26 +02:00
Michael Vetter
091ff41c06 Merge pull request #2041 from profanity-im/some-improvements
All checks were successful
CI / Linux (debian) (pull_request) Successful in 13m45s
CI / Linux (arch) (pull_request) Successful in 16m48s
CI / Linux (fedora) (pull_request) Successful in 15m11s
CI / Check coding style (pull_request) Successful in 29s
CI / Check spelling (pull_request) Successful in 15s
CI / Linux (ubuntu) (pull_request) Successful in 13m50s
CI / Linux (debian) (push) Successful in 11m36s
CI / Linux (arch) (push) Successful in 14m0s
CI / Linux (fedora) (push) Successful in 12m25s
CI / Check coding style (push) Successful in 30s
CI / Check spelling (push) Successful in 16s
CI / Linux (ubuntu) (push) Successful in 11m55s
Summary:
- Print the final storage location when successfully decrypting a file with `aesgcm://` source.
- Less GString
- Re-factor cmd_presence()
- Improve const correctness
- Use correct free function. Fixes: 75d7663 ("Free wins summary list")

Pull Request Source: https://github.com/profanity-im/profanity/pull/2041

Author: Steffen Jaeckel <s@jaeckel.eu>
2025-07-19 00:13:49 +02:00
Steffen Jaeckel
b7afea7ec3 Use correct free function.
Fixes: 75d76638 ("Free wins summary list")

Author: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-07-19 00:13:40 +02:00
7fcc14fdea build: change docs configuration to build XML
All checks were successful
CI / Check spelling (push) Successful in 17s
CI / Check coding style (push) Successful in 33s
CI / Linux (debian) (push) Successful in 9m54s
CI / Linux (ubuntu) (push) Successful in 12m4s
CI / Linux (fedora) (push) Successful in 13m45s
CI / Linux (arch) (push) Successful in 15m20s
So it can be used as a part of CI for the website
2025-07-08 01:52:56 +02:00
d07ca9953d fix: reduce logging
All checks were successful
CI / Check spelling (push) Successful in 16s
CI / Check coding style (push) Successful in 31s
CI / Linux (ubuntu) (push) Successful in 10m12s
CI / Linux (arch) (push) Successful in 12m3s
CI / Linux (debian) (push) Successful in 12m12s
CI / Linux (fedora) (push) Successful in 17m6s
If we can't debug_log because we couldn't obtain some data, but otherwise the app is working, "warning" level is clearly excessive.
2025-07-05 20:54:06 +02:00
f636090fd9 fix(window): preserve scroll offset on page_down and refactor
All checks were successful
CI / Check spelling (pull_request) Successful in 29s
CI / Check coding style (pull_request) Successful in 2m22s
CI / Linux (debian) (pull_request) Successful in 11m28s
CI / Linux (fedora) (pull_request) Successful in 16m46s
CI / Linux (arch) (pull_request) Successful in 20m29s
CI / Linux (ubuntu) (pull_request) Successful in 35m7s
CI / Check spelling (push) Successful in 17s
CI / Check coding style (push) Successful in 31s
CI / Linux (ubuntu) (push) Successful in 11m11s
CI / Linux (debian) (push) Successful in 13m26s
CI / Linux (fedora) (push) Successful in 16m10s
CI / Linux (arch) (push) Successful in 32m49s
When paging down beyond the visible chat buffer, the scroll position could
jump unexpectedly. This occurred because the visual distance from the bottom
(e.g. 6 lines until the last message) wasn’t preserved after loading new
messages from the DB.

This patch fixes that by capturing the visual offset (`current_offset`) before
the DB fetch and reapplying it after, based on the y-position of the final
buffer entry. This ensures consistent and smooth scroll transitions, even
as message heights vary.

In addition to fixing the visual glitch, this commit introduces a targeted
performance optimization: once the bottom of the chat has been reached
(`WIN_SCROLL_REACHED_BOTTOM`), we skip expensive operations entirely —
including datetime lookups and entry formatting — during further page_down
events. This reduces performance stalls
during rapid paging (e.g. holding the Page Down key at the bottom of the scrolling area).

This update also adapts to the recent change in `chatwin_db_history()`,
which now returns a `db_history_result_t` instead of `gboolean`, allowing
correct differentiation between an empty result and an actual DB error.

Together, these changes:
- Fix a scroll-jump bug in `page_down`
- Improve performance and responsiveness during rapid navigation
- Align with improved DB result handling
2025-07-02 19:27:15 +02:00
a5eab3cad5 build: Upgrade valgrind suppression file
Use newer version of Python's .supp file.
2025-07-02 15:21:44 +02:00
6871a4d46f Fix memory leak in _handle_string_or_none_result
All checks were successful
CI / Check spelling (pull_request) Successful in 4m23s
CI / Check coding style (pull_request) Successful in 10m37s
CI / Linux (fedora) (pull_request) Successful in 11m27s
CI / Linux (debian) (pull_request) Successful in 12m48s
CI / Linux (arch) (pull_request) Successful in 16m54s
CI / Linux (ubuntu) (pull_request) Successful in 48m55s
The function did not decref the Python object on type error paths,
resulting in a reference count leak. This caused memory to accumulate
over time. Added Py_XDECREF on all early return paths to properly free
the Python object reference and prevent leaks.
2025-07-02 15:05:44 +02:00
f824cde45f fix(mam, log): improve datetime handling and memory management in MAM and log fetching
- Introduce static helper `_truncate_datetime_suffix()` to safely trim datetime strings, removing unwanted suffixes like timezone offsets
- Replace manual string management with auto_gchar and g_strdup for safer, clearer ownership and to prevent leaks
- Add safety checks and logging warnings for unexpected datetime string lengths or null pointers
- Refactor _mam_rsm_id_handler to use the helper function and updated string handling
- Change log_database_get_previous_chat parameters for consistent ownership semantics, avoiding double frees and mem leaks
- Overall improve stability and prevent memory leaks during log database queries
2025-07-02 14:59:31 +02:00
40b7a12543 Clarify and improve win_page_up() scrolling offset adjustment for smoother paging
All checks were successful
CI / Check spelling (pull_request) Successful in 17s
CI / Check coding style (pull_request) Successful in 29s
CI / Linux (ubuntu) (pull_request) Successful in 11m6s
CI / Linux (debian) (pull_request) Successful in 13m9s
CI / Linux (fedora) (pull_request) Successful in 15m14s
CI / Linux (arch) (pull_request) Successful in 37m59s
CI / Check spelling (push) Successful in 16s
CI / Check coding style (push) Successful in 32s
CI / Linux (debian) (push) Successful in 9m53s
CI / Linux (ubuntu) (push) Successful in 10m9s
CI / Linux (fedora) (push) Successful in 15m8s
CI / Linux (arch) (push) Successful in 15m28s
This commit refines the existing logic in win_page_up() by:
- Improving comments to clearly explain the rationale behind adjusting
  the scroll offset relative to the first buffer entry’s visual position,
  helping future maintainers understand why this is necessary.
- Fixing offset recalculation to better handle cases where older messages
  with variable heights are loaded from the DB, improving scroll smoothness.
- Changing the logging of negative *page_start values from warning to debug,
  recognizing that this can be a normal scenario when insufficient history is loaded.
- Simplifying some conditionals and renaming variables for clearer intent.

No changes yet applied to win_page_down(), but similar improvements could
be considered in the future.

Overall, this enhances the robustness and user experience of scrolling up
in chat windows, while preserving existing functional logic.
2025-07-01 20:53:18 +02:00
6a394ae2e5 fix: Increase scrollback buffer height for chat rendering (PAD_SIZE)
f27fa98 commit introduced issue of scrolling seemingly randomly being stuck and the following message flood in the logs: "WRN: Ncurses Overflow..."

A pad is an off-screen buffer — larger than the visible terminal screen — that you can scroll, render parts of, or update selectively.

Unlike regular windows, a pad is not tied to screen size. You can create a pad that's 1,000 lines tall, even if your terminal is only 40 lines tall.

This commit addresses the issue by increasing PAD_SIZE to a reasonable number,
allowing messages from buffer to be displayed without overflowing NCurses' window size (maxy).

Minor change: add .cache folder to gitignore
2025-07-01 16:42:03 +02:00
43bab6ff8f t push origin master
All checks were successful
CI / Check spelling (push) Successful in 16s
CI / Check coding style (push) Successful in 30s
CI / Linux (ubuntu) (push) Successful in 9m56s
CI / Linux (fedora) (push) Successful in 10m29s
CI / Linux (arch) (push) Successful in 11m56s
CI / Linux (debian) (push) Successful in 12m11s
Merge branch 'fix/theme-mem-leak'
2025-06-24 17:29:55 +02:00
d5d5dc5180 ref(theme): ensure clean reinitialization and explicitly initialize static vars
All checks were successful
CI / Check spelling (pull_request) Successful in 17s
CI / Check coding style (pull_request) Successful in 32s
CI / Linux (debian) (pull_request) Successful in 9m44s
CI / Linux (fedora) (pull_request) Successful in 10m40s
CI / Linux (ubuntu) (pull_request) Successful in 12m19s
CI / Linux (arch) (pull_request) Successful in 15m41s
Improves code robustness by calling _theme_close() in theme_init() when the
theme was already initialized, preventing potential memory leaks or
inconsistent state.

Closes #4
2025-06-24 16:22:48 +02:00
83c569de37 ref: Remove unnecessary variable bold_items
The variable was introduced in 976e5aa. First used to detect bold characters, it was later replaced by another solution in 850ac3c.
2025-06-24 15:24:09 +02:00
7d1e1c726d fix: Remove unnecessary theme_init call (mem leak)
Simple `ui_resize` is sufficient for rerendering all the elements.
Other calls create complexity, slow down the applications and even introduce mem leaks.

`ui_resize` technique is already used widely, including `cmd_editor` case.

Fixes #4
2025-06-24 15:10:26 +02:00
b4d3563b96 Cleanup (#5)
All checks were successful
CI / Check coding style (push) Successful in 29s
CI / Check spelling (push) Successful in 16s
CI / Linux (debian) (push) Successful in 9m35s
CI / Linux (arch) (push) Successful in 11m27s
CI / Linux (fedora) (push) Successful in 13m57s
CI / Linux (ubuntu) (push) Successful in 11m21s
- Update formatting for stub files
- Update docs

While original project, Profanity, provides valuable basis for this
fork, we are not affiliated with the upstream. This commit
is updating documentation to reflect accurate information.

The docs are going to be updated further once the website is created.

Reviewed-on: devs/profanity#5
Co-authored-by: Jabber Developer <jabber.developer@jabber.space>
Co-committed-by: Jabber Developer <jabber.developer@jabber.space>
2025-06-20 18:20:47 +00:00
ddc4290c99 Merge pull request 'Fix arch build; update workflow' (#3) from fix-arch-build into master
All checks were successful
CI / Check spelling (push) Successful in 18s
CI / Check coding style (push) Successful in 29s
CI / Linux (ubuntu) (push) Successful in 11m44s
CI / Linux (debian) (push) Successful in 11m46s
CI / Linux (fedora) (push) Successful in 13m16s
CI / Linux (arch) (push) Successful in 14m47s
Reviewed-on: devs/profanity#3
2025-06-20 13:55:53 +00:00
0d7a859a20 fix: curl parameter type correction
All checks were successful
CI / Check coding style (pull_request) Successful in 34s
CI / Check spelling (pull_request) Successful in 24s
CI / Linux (ubuntu) (pull_request) Successful in 10m8s
CI / Linux (debian) (pull_request) Successful in 12m7s
CI / Linux (fedora) (pull_request) Successful in 13m44s
CI / Linux (arch) (pull_request) Successful in 16m39s
2025-06-20 14:58:30 +02:00
0784662d40 Fix workflow
Current setup of the infratstrcture with DIND
was causing issues with volume binding,
leading to a false-positive error on code formatting check.

This commit addresses the issue by removing dependency on a container,
but at the same time it limits choice of formatting version.

This fix does not address the underlying issue with the architecture.

As an additional change, package versions are updated.
2025-06-20 14:54:12 +02:00
121 changed files with 4086 additions and 2470 deletions

12
.github/FUNDING.yml vendored
View File

@@ -1,12 +0,0 @@
# These are supported funding model platforms
github: jubalh
patreon: # Replace with Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with a single custom sponsorship URL

44
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,44 @@
---
name: Bug report
about: Create a report
title: ''
labels: bug
assignees: ''
---
<!--- Provide a general summary of the issue in the Title above -->
<!--- More than 50 issues open? Please don't file any new feature requests -->
<!--- Help us reduce the work first :-) -->
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->
## Steps to Reproduce (for bugs)
<!--- Describe, in detail, what needs to happen to reproduce this bug -->
<!--- Give us a screenshot (if it's helpful for this particular bug) -->
1.
2.
3.
4.
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
## Environment
* Give us the version and build information output generated by `profanity -v`
* If you could not yet build profanity, mention the revision you try to build from
* Operating System/Distribution
* glib version
* libstrophe version
* Some bugs might be due to specific implementation in the server. `/serversoftware example.domain` can be helpful

View File

@@ -20,8 +20,6 @@
<!--- Give us a screenshot (if it's helpful for this particular bug) -->
1.
2.
3.
4.
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->

View File

@@ -5,5 +5,5 @@
- [ ] I ran valgrind when using my new feature
### How to test the functionality
* step 1
* step 2
- step 1
- step 2

44
.github/workflows/ci-api-docs.yml vendored Normal file
View File

@@ -0,0 +1,44 @@
name: CI API Docs
on:
push:
branches: [master]
paths:
- 'apidocs/**'
pull_request:
branches: [master]
paths:
- 'apidocs/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test-c-api-docs:
runs-on: ubuntu-latest
name: Test C API Documentation Generation
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends make doxygen
- name: Test C API docs generation
run: |
cd apidocs/c/
doxygen c-prof.conf
test-python-api-docs:
runs-on: ubuntu-latest
name: Test Python API Documentation Generation
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends make python3-sphinx
- name: Test Python API docs generation
run: |
cd apidocs/python/
sphinx-apidoc -f -o . src && make -j$(nproc) xml SPHINXOPTS="-W --keep-going -n"

100
.github/workflows/ci-code.yml vendored Normal file
View File

@@ -0,0 +1,100 @@
name: CI Code
on:
push:
branches: [master]
paths-ignore:
- 'docs/**'
- 'apidocs/**'
- 'README.md'
pull_request:
branches: [master]
paths-ignore:
- 'docs/**'
- 'apidocs/**'
- 'README.md'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
flavor: [arch, debian, ubuntu]
name: Linux
steps:
- uses: actions/checkout@v4
- name: Run tests
run: |
docker build -f Dockerfile.${{ matrix.flavor }} -t profanity .
docker run profanity ./ci-build.sh
code-style:
runs-on: ubuntu-latest
name: Check coding style
continue-on-error: true
env:
GITHUB_WORKSPACE: ${{ runner.workspace }}
steps:
- uses: actions/checkout@v4
# if this check fails, you have to update the number of auto types known and the list of auto types in the check below
- name: Check auto types are up-to-date
run: |
[[ "$(find src -type f -name '*.[ch]' -exec awk '/^#define auto_[\W]*/ {print $2}' '{}' \; | sort -u | wc -l)" == "8" ]] || exit -1
- name: Check auto types are initialized
run: |
grep -P 'auto_(char|gchar|gcharv|guchar|jid|sqlite|gfd|FILE)[\w *]*;$' -r src && exit -1 || true
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Run clang-format check
run: |
echo $(clang-format --version)
# Find all source files you care about
INCLUDE_REGEX='^.*\.((((c|C)(c|pp|xx|\+\+)?$)|((h|H)h?(pp|xx|\+\+)?$))|(ino|pde|proto|cu))$'
CHECK_PATH='src'
files=$(find "$CHECK_PATH" -name .git -prune -o -regextype posix-egrep -regex "$INCLUDE_REGEX" -print)
if [ -z "$files" ]; then
echo "✅ No source files found to check."
exit 0
fi
# Run clang-format in dry-run mode and collect any improperly formatted files
failed=0
for file in $files; do
if ! output=$(clang-format --dry-run --Werror --style=file "$file" 2>&1); then
echo "❌ Failed on file: $file"
echo "$output"
echo "----------------------------------------"
failed=1
fi
done
if [ $failed -ne 0 ]; then
echo "🚫 One or more files are not properly formatted."
else
echo "✅ All files are properly formatted."
fi
exit $failed
spell-check:
runs-on: ubuntu-latest
name: Check spelling
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends codespell
- name: Check spelling
run: |
codespell

View File

@@ -1,60 +0,0 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
flavor: [arch, debian, fedora, ubuntu]
name: Linux
steps:
- uses: actions/checkout@v2
- name: Run tests
run: |
docker build -f Dockerfile.${{ matrix.flavor }} -t profanity .
docker run profanity ./ci-build.sh
code-style:
runs-on: ubuntu-22.04
name: Check coding style
continue-on-error: true
steps:
- uses: actions/checkout@v2
# if this check fails, you have to update the number of auto types known and the list of auto types in the check below
- name: Check auto types are up-to-date
run: |
[[ "$(find src -type f -name '*.[ch]' -exec awk '/^#define auto_[\W]*/ {print $2}' '{}' \; | sort -u | wc -l)" == "8" ]] || exit -1
- name: Check auto types are initialized
run: |
grep -P 'auto_(char|gchar|gcharv|guchar|jid|sqlite|gfd|FILE)[\w *]*;$' -r src && exit -1 || true
- name: Run clang-format
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: '16'
check-path: 'src'
spell-check:
runs-on: ubuntu-22.04
name: Check spelling
continue-on-error: true
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends codespell
- name: Check spelling
run: |
codespell

3
.gitignore vendored
View File

@@ -44,6 +44,9 @@ src/gitversion.h.in
src/stamp-h1
src/plugins/profapi.lo
# clangd
.cache/
# out-of-tree build folders
build*/

View File

@@ -10,8 +10,8 @@ We recommend for people to always work on a dedicated git branch for each fix or
Don't work on master.
So that they can easily pull master and rebase their work if needed.
For fixing (reported) bugs we usually use `git checkout -b fix/issuenumber-somedescription`.
When working on a new feature we usually use `git checkout -b feature/optionalissuenumber-somedescription`.
For fixing (reported) bugs we usually use `git switch -c fix/issuenumber-somedescription`.
When working on a new feature we usually use `git switch -c feature/optionalissuenumber-somedescription`.
However this is not a rule just a recommendation to keep an overview of things.
If your change isn't a bugfix or new feature you can also just use any branch name.

View File

@@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
autoconf-archive \
automake \
ca-certificates \
expect \
gcc \
git \
@@ -36,7 +37,7 @@ RUN mkdir -p /usr/src/{stabber,libstrophe,profanity}
WORKDIR /usr/src
#RUN git clone https://github.com/boothj5/stabber
RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
RUN git clone --depth 1 https://git.jabber.space/devs/libstrophe-gh.git libstrophe
#WORKDIR /usr/src/stabber
#RUN ./bootstrap.sh
@@ -47,7 +48,7 @@ RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
WORKDIR /usr/src/libstrophe
RUN ./bootstrap.sh
RUN ./configure --prefix=/usr
RUN make
RUN make -j$(nproc)
RUN make install
WORKDIR /usr/src/profanity

View File

@@ -9,6 +9,7 @@ RUN dnf install -y \
autoconf-archive \
automake \
awk \
ca-certificates \
expect-devel \
gcc \
git \
@@ -56,11 +57,11 @@ WORKDIR /usr/src
WORKDIR /usr/src
RUN mkdir -p /usr/src/libstrophe
RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
RUN git clone --depth 1 https://git.jabber.space/devs/libstrophe-gh.git libstrophe
WORKDIR /usr/src/libstrophe
RUN ./bootstrap.sh
RUN ./configure --prefix=/usr
RUN make
RUN make -j$(nproc)
RUN make install
RUN mkdir -p /usr/src/profanity

View File

@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
autoconf-archive \
automake \
ca-certificates \
expect \
gcc \
git \
@@ -37,7 +38,7 @@ RUN mkdir -p /usr/src/{stabber,libstrophe,profanity}
WORKDIR /usr/src
#RUN git clone https://github.com/boothj5/stabber
RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
RUN git clone --depth 1 https://git.jabber.space/devs/libstrophe-gh.git libstrophe
# TODO: Re-enable once libmicrohttpd-dev has been updated.
#WORKDIR /usr/src/stabber
@@ -49,7 +50,7 @@ RUN git clone -c http.sslverify=false https://github.com/strophe/libstrophe
WORKDIR /usr/src/libstrophe
RUN ./bootstrap.sh
RUN ./configure --prefix=/usr
RUN make
RUN make -j$(nproc)
RUN make install
WORKDIR /usr/src/profanity

View File

@@ -124,6 +124,7 @@ unittest_sources = \
src/event/server_events.c src/event/server_events.h \
src/event/client_events.c src/event/client_events.h \
src/ui/tray.h src/ui/tray.c \
tests/prof_cmocka.h \
tests/unittests/xmpp/stub_vcard.c \
tests/unittests/xmpp/stub_avatar.c \
tests/unittests/xmpp/stub_ox.c \
@@ -166,9 +167,11 @@ unittest_sources = \
tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \
tests/unittests/test_callbacks.c tests/unittests/test_callbacks.h \
tests/unittests/test_plugins_disco.c tests/unittests/test_plugins_disco.h \
tests/unittests/test_forced_encryption.c tests/unittests/test_forced_encryption.h \
tests/unittests/unittests.c
functionaltest_sources = \
tests/prof_cmocka.h \
tests/functionaltests/proftest.c tests/functionaltests/proftest.h \
tests/functionaltests/test_connect.c tests/functionaltests/test_connect.h \
tests/functionaltests/test_ping.c tests/functionaltests/test_ping.h \
@@ -283,6 +286,7 @@ endif
TESTS = tests/unittests/unittests
check_PROGRAMS = tests/unittests/unittests
tests_unittests_unittests_CPPFLAGS = -Itests/
tests_unittests_unittests_SOURCES = $(unittest_sources)
tests_unittests_unittests_LDADD = -lcmocka
@@ -346,9 +350,13 @@ endif
.PHONY: my-prof.supp
my-prof.supp:
@sed '/^# AUTO-GENERATED START/q' prof.supp > $@
@printf "\n\n# glib\n" >> $@
@cat /usr/share/glib-2.0/valgrind/glib.supp >> $@
@printf "\n\n# Python\n" >> $@
@wget -O- https://raw.githubusercontent.com/python/cpython/refs/tags/v`python3 --version | cut -d' ' -f2`/Misc/valgrind-python.supp >> $@
@printf "\n\n# gtk\n" >> $@
@test -z "@GTK_VERSION@" || wget -O- https://raw.githubusercontent.com/GNOME/gtk/refs/tags/@GTK_VERSION@/gtk.supp >> $@
@printf "\n\n# more gtk\n" >> $@
@test -z "@GTK_VERSION@" || cat /usr/share/gtk-3.0/valgrind/gtk.supp >> $@
check-unit: tests/unittests/unittests

View File

@@ -1,65 +1,36 @@
# Profanity
![Build Status](https://github.com/profanity-im/profanity/workflows/CI/badge.svg) [![GitHub contributors](https://img.shields.io/github/contributors/profanity-im/profanity.svg)](https://github.com/profanity-im/profanity/graphs/contributors/) [![Packaging status](https://repology.org/badge/tiny-repos/profanity.svg)](https://repology.org/project/profanity/versions)
# CProof
![Build Status](https://git.jabber.space/devs/cproof/actions/workflows/main.yml/badge.svg)
Profanity is a console based XMPP client inspired by [Irssi](http://www.irssi.org/).
CProof is a console based XMPP chat client based on [Profanity](https://profanity-im.github.io/).
If you like Profanity consider becoming a sponsor or [donate](https://profanity-im.github.io/donate.html) some money.
![alt tag](https://jabber.space/images/CProof-ui.png)
![alt tag](https://profanity-im.github.io/images/prof-2.png)
See the [User Guide](https://profanity-im.github.io/userguide.html) for information on installing and using Profanity.
See the [Quick Start Guide](https://jabber.space/getting-started/quick-start/) for information on installing and using CProof.
## Project
This project is about freedom, privacy and choice. We want to enable people to chat with one another in a safe way. Thus supporting encryption (OTR, PGP, OMEMO, OX) and being decentralized, meaning everyone can run their own server. We believe [XMPP](https://xmpp.org/) is a great proven protocol with an excellent community serving this purpose well.
Feel free to follow us on [twitter](https://twitter.com/profanityim), join our [mailing list](https://lists.posteo.de/listinfo/profanity) and/or [MUC](xmpp:profanity@rooms.dismail.de?join).
CProof enables you to communicate with privacy, freedom and comfort. Our open-source chat application delivers secure, end-to-end encrypted messaging (OTR, PGP, OMEMO, OX) built on the trusted [XMPP](https://xmpp.org/) protocol. With a decentralized design, you can connect directly or even host your own server, keeping your data in your hands. Whether you're chatting with friends or collaborating securely, CProof makes private communication simple, reliable, and truly yours.
## Installation
Our [user guide](https://profanity-im.github.io/userguide.html) contains an [install](https://profanity-im.github.io/guide/latest/install.html) section and a section for [building](https://profanity-im.github.io/guide/latest/build.html) from source yourself.
## Donations
We would highly appreciate it if you support us via [GitHub Sponsors](https://github.com/sponsors/jubalh/). Especially if you make feature requests or need help using Profanity.
Sponsoring enables us to spend time on Profanity.
An alternative way to support us would be to ask for our IBAN or use Bitcoin: `bc1qx265eat7hfasqkqmk9qf38delydnrnuvzhzy0x`.
Issues backed by a sponsor will be tagged with the [sponsored](https://github.com/profanity-im/profanity/issues?q=label%3Asponsored+) label.
Feature requests that we consider out of scope, either because of interest or because of time needed to implement them, will be marked with the [unfunded](https://github.com/profanity-im/profanity/issues?q=label%3Aunfunded) label.
Another way to sponsor us or get an issue solved is to comment on an issue that you are willing to sponsor it.
Tasks from our [sponsors](SPONSORS.md) will be tackled first.
Thank you! <3
Check our [installation guide](https://jabber.space/getting-started/installation/) for detailed instructions.
## How to contribute
We tried to sum things up on our [helpout](https://profanity-im.github.io/helpout.html) page.
Additionally you can check out our [blog](https://profanity-im.github.io/blog/) where we have articles like:
[How to get a backtrace](https://profanity-im.github.io/blog/post/how-to-get-a-backtrace/) and [Contributing a Patch via GitHub](https://profanity-im.github.io/blog/post/contributing-a-patch-via-github/).
For more technical details check out our [CONTRIBUTING.md](CONTRIBUTING.md) file.
See our [Helping Out](https://jabber.space/contributing/helpout/) page for a concise summary of ways to help us.
Review the [Contributing Guide](CONTRIBUTING.md) and [Code Overview](https://jabber.space/contributing/code-overview/) pages for advanced technical details.
## Getting help
To get help, first read our [User Guide](https://profanity-im.github.io/userguide.html) then check out the [FAQ](https://profanity-im.github.io/faq.html).
If you have are having a problem then first search the [issue tracker](https://github.com/profanity-im/profanity/issues).
If you don't find anything there either come to our [MUC](xmpp:profanity@rooms.dismail.de?join) or create a new issue depending on what your problem is.
Prior to asking questions, check our [User Guide](https://profanity-im.github.io/userguide.html), then check out the [FAQ](https://jabber.space/about/faq/).
If you are still having a problem then search the [issue tracker](https://git.jabber.space/devs/cproof/issues).
As a last resort, feel free to write us on [support@jabber.tech](mailto:support@jabber.tech) or create a new issue depending on what your problem is.
## Links
### Website
URL: https://profanity-im.github.io
Feel free to visit our website: [jabber.space](https://jabber.space/).
Repo: https://github.com/profanity-im/profanity-im.github.io
### Blog
URL: https://profanity-im.github.io/blog
Repo: https://github.com/profanity-im/blog
### Mailinglist
Mailing List: https://lists.posteo.de/listinfo/profanity
### Chatroom
MUC: profanity@rooms.dismail.de
You may also check the repository if you like, available on [git.jabber.space/devs/profanity](https://git.jabber.space/devs/profanity).
### Plugins
Plugins repository: https://github.com/profanity-im/profanity-plugins
Plugins repository: https://git.jabber.space/devs/cproof-plugins

View File

@@ -13,7 +13,7 @@
* Generate HTML docs (the docgen argument only works when package status is development)
`./profanity docgen`
* Determine if libprofanitys version needs to be [increased](https://github.com/profanity-im/profanity/issues/973)
* Determine if `libprofanity`'s version needs to be [increased](https://github.com/profanity-im/profanity/issues/973)
* Update plugin API docs (./apidocs/c and ./apidocs/python) need to run the `gen.sh` and commit the results to the website git repo
* Update CHANGELOG
* Update profrc.example

View File

@@ -1,22 +0,0 @@
# Giving back
Thank you very much to all of our sponsors and donors (including those that want to stay private)!
## Sponsors
[Martin Dosch](https://github.com/mdosch) since January 2020
[Alexander Dahl](https://github.com/LeSpocky) since January 2021
[James Pond](https://github.com/jamesponddotco) since February 2021
## Donors
[Martin Dosch](https://github.com/mdosch)
[Julian Huhn](https://github.com/huhndev)
[Matteo Bini](https://github.com/matteobin)
## Services
[Stefan Kropp](https://github.com/StefanKropp) for sponsoring our [mailing list](https://lists.posteo.de/listinfo/profanity)
[dismail](https://dismail.de/) for hosting our [MUC](xmpp:profanity@rooms.dismail.de?join)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,220 +1,247 @@
/** @file
C Hooks.
*/
/** @file profhooks.h
* @brief C Plugin Hooks for CProof.
*
* This header defines optional callback hooks that CProof plugins can implement to
* handle events such as startup, shutdown, message processing, and presence updates in
* CProof, a console-based XMPP client. These hooks are called by CProof when the
* corresponding events occur, allowing plugins to customize behavior. All hooks are
* optional; plugins can define only the hooks they need, and CProof will automatically
* invoke them when appropriate.
*
* To use these hooks, define the functions in your plugin with the signatures provided
* in this header. For example, to handle the startup event:
*
* @code
* #include "profhooks.h"
* void prof_on_start(void) {
* // Handle CProof startup
* }
* @endcode
*
* For additional plugin functionality, such as displaying messages or registering
* commands, see the CProof API functions in profapi.h.
*
* @see profapi.h
*/
/** @mainpage CProof Plugins API and Hooks
* List of all API functions available to plugins: @ref profapi.h
* List of all hooks which plugins may implement: @ref profhooks.h
*/
/**
Called when a plugin is loaded, either when profanity is started, or when the /plugins load or /plugins install commands are called
@param version the version of Profanity
@param status the package status of Profanity, "development" or "release"
@param account_name account name of the currently logged in account, or NULL if not logged in
@param fulljid the users full Jabber ID (barejid and resource) if logged in, NULL otherwise
*/
* Called when a plugin is loaded, either when CProof is started, or when the /plugins load or /plugins install commands are called
* @param version The version of CProof
* @param status The package status of CProof, "development" or "release"
* @param account_name Account name of the currently logged in account, or NULL if not logged in
* @param fulljid The user's full Jabber ID (barejid and resource) if logged in, NULL otherwise
*/
void prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid);
/**
Called when Profanity is started
*/
* Called when CProof is started
*/
void prof_on_start(void);
/**
Called when the user quits Profanity
*/
* Called when the user quits CProof
*/
void prof_on_shutdown(void);
/**
Called when a plugin is unloaded with the /plugins unload command
*/
* Called when a plugin is unloaded with the /plugins unload command
*/
void prof_on_unload(void);
/**
Called when the user connects with an account
@param account_name account name of the account used for logging in
@param fulljid the full Jabber ID (barejid and resource) of the account
*/
* Called when the user connects with an account
* @param account_name Account name of the account used for logging in
* @param fulljid The full Jabber ID (barejid and resource) of the account
*/
void prof_on_connect(const char * const account_name, const char * const fulljid);
/**
Called when the user disconnects an account
@param account_name account name of the account being disconnected
@param fulljid the full Jabber ID (barejid and resource) of the account
*/
* Called when the user disconnects an account
* @param account_name Account name of the account being disconnected
* @param fulljid The full Jabber ID (barejid and resource) of the account
*/
void prof_on_disconnect(const char * const account_name, const char * const fulljid);
/**
Called before a chat message is displayed
@param barejid Jabber ID of the message sender
@param resource resource of the message sender
@param message the received message
@return the new message to display, or NULL to preserve the original message
*/
* Called before a chat message is displayed
* @param barejid Jabber ID of the message sender
* @param resource Resource of the message sender
* @param message The received message
* @return The new message to display, or NULL to preserve the original message
*/
char* prof_pre_chat_message_display(const char * const barejid, const char *const resource, const char *message);
/**
Called after a chat message is displayed
@param barejid Jabber ID of the message sender
@param resource resource of the message sender
@param message the received message
*/
* Called after a chat message is displayed
* @param barejid Jabber ID of the message sender
* @param resource Resource of the message sender
* @param message The received message
*/
void prof_post_chat_message_display(const char * const barejid, const char *const resource, const char *message);
/**
Called before a chat message is sent
@param barejid Jabber ID of the message recipient
@param message the message to be sent
@return the modified or original message to send, or NULL to cancel sending of the message
*/
* Called before a chat message is sent
* @param barejid Jabber ID of the message recipient
* @param message The message to be sent
* @return The modified or original message to send, or NULL to cancel sending of the message
*/
char* prof_pre_chat_message_send(const char * const barejid, const char *message);
/**
Called after a chat message has been sent
@param barejid Jabber ID of the message recipient
@param message the sent message
*/
* Called after a chat message has been sent
* @param barejid Jabber ID of the message recipient
* @param message The sent message
*/
void prof_post_chat_message_send(const char * const barejid, const char *message);
/**
Called before a chat room message is displayed
@param barejid Jabber ID of the room
@param nick nickname of message sender
@param message the received message
@return the new message to display, or NULL to preserve the original message
*/
* Called before a chat room message is displayed
* @param barejid Jabber ID of the room
* @param nick Nickname of message sender
* @param message The received message
* @return The new message to display, or NULL to preserve the original message
*/
char* prof_pre_room_message_display(const char * const barejid, const char * const nick, const char *message);
/**
Called after a chat room message is displayed
@param barejid Jabber ID of the room
@param nick nickname of the message sender
@param message the received message
*/
* Called after a chat room message is displayed
* @param barejid Jabber ID of the room
* @param nick Nickname of the message sender
* @param message The received message
*/
void prof_post_room_message_display(const char * const barejid, const char * const nick, const char *message);
/**
Called before a chat room message is sent
@param barejid Jabber ID of the room
@param message the message to be sent
@return the modified or original message to send, or NULL to cancel sending of the message
*/
* Called before a chat room message is sent
* @param barejid Jabber ID of the room
* @param message The message to be sent
* @return The modified or original message to send, or NULL to cancel sending of the message
*/
char* prof_pre_room_message_send(const char * const barejid, const char *message);
/**
Called after a chat room message has been sent
@param barejid Jabber ID of the room
@param message the sent message
*/
* Called after a chat room message has been sent
* @param barejid Jabber ID of the room
* @param message The sent message
*/
void prof_post_room_message_send(const char * const barejid, const char *message);
/**
Called when the server sends a chat room history message
@param barejid Jabber ID of the room
@param nick nickname of the message sender
@param message the message to be sent
@param timestamp time the message was originally sent to the room, in ISO8601 format
*/
* Called when the server sends a chat room history message
* @param barejid Jabber ID of the room
* @param nick Nickname of the message sender
* @param message The message to be sent
* @param timestamp Time the message was originally sent to the room, in ISO8601 format
*/
void prof_on_room_history_message(const char * const barejid, const char *const nick, const char *const message, const char *const timestamp);
/**
Called before a private chat room message is displayed
@param barejid Jabber ID of the room
@param nick nickname of message sender
@param message the received message
@return the new message to display, or NULL to preserve the original message
*/
* Called before a private chat room message is displayed
* @param barejid Jabber ID of the room
* @param nick Nickname of message sender
* @param message The received message
* @return The new message to display, or NULL to preserve the original message
*/
char* prof_pre_priv_message_display(const char * const barejid, const char * const nick, const char *message);
/**
Called after a private chat room message is displayed
@param barejid Jabber ID of the room
@param nick nickname of the message sender
@param message the received message
*/
* Called after a private chat room message is displayed
* @param barejid Jabber ID of the room
* @param nick Nickname of the message sender
* @param message The received message
*/
void prof_post_priv_message_display(const char * const barejid, const char * const nick, const char *message);
/**
Called before a private chat room message is sent
@param barejid Jabber ID of the room
@param nick nickname of message recipient
@param message the message to be sent
@return the modified or original message to send, or NULL to cancel sending of the message
*/
* Called before a private chat room message is sent
* @param barejid Jabber ID of the room
* @param nick Nickname of message recipient
* @param message The message to be sent
* @return The modified or original message to send, or NULL to cancel sending of the message
*/
char* prof_pre_priv_message_send(const char * const barejid, const char * const nick, const char *message);
/**
Called after a private chat room message has been sent
@param barejid Jabber ID of the room
@param nick nickname of the message recipient
@param message the sent message
*/
* Called after a private chat room message has been sent
* @param barejid Jabber ID of the room
* @param nick Nickname of the message recipient
* @param message The sent message
*/
void prof_post_priv_message_send(const char * const barejid, const char * const nick, const char *message);
/**
Called before an XMPP message stanza is sent
@param stanza The stanza to send
@return The new stanza to send, or NULL to preserve the original stanza
*/
* Called before an XMPP message stanza is sent
* @param stanza The stanza to send
* @return The new stanza to send, or NULL to preserve the original stanza
*/
char* prof_on_message_stanza_send(const char *const stanza);
/**
Called when an XMPP message stanza is received
@param stanza The stanza received
@return 1 if Profanity should continue to process the message stanza, 0 otherwise
*/
* Called when an XMPP message stanza is received
* @param stanza The stanza received
* @return 1 if CProof should continue to process the message stanza, 0 otherwise
*/
int prof_on_message_stanza_receive(const char *const stanza);
/**
Called before an XMPP presence stanza is sent
@param stanza The stanza to send
@return The new stanza to send, or NULL to preserve the original stanza
*/
* Called before an XMPP presence stanza is sent
* @param stanza The stanza to send
* @return The new stanza to send, or NULL to preserve the original stanza
*/
char* prof_on_presence_stanza_send(const char *const stanza);
/**
Called when an XMPP presence stanza is received
@param stanza The stanza received
@return 1 if Profanity should continue to process the presence stanza, 0 otherwise
*/
* Called when an XMPP presence stanza is received
* @param stanza The stanza received
* @return 1 if CProof should continue to process the presence stanza, 0 otherwise
*/
int prof_on_presence_stanza_receive(const char *const stanza);
/**
Called before an XMPP iq stanza is sent
@param stanza The stanza to send
@return The new stanza to send, or NULL to preserve the original stanza
*/
* Called before an XMPP iq stanza is sent
* @param stanza The stanza to send
* @return The new stanza to send, or NULL to preserve the original stanza
*/
char* prof_on_iq_stanza_send(const char *const stanza);
/**
Called when an XMPP iq stanza is received
@param stanza The stanza received
@return 1 if Profanity should continue to process the iq stanza, 0 otherwise
*/
* Called when an XMPP iq stanza is received
* @param stanza The stanza received
* @return 1 if CProof should continue to process the iq stanza, 0 otherwise
*/
int prof_on_iq_stanza_receive(const char *const stanza);
/**
Called when a contact goes offline
@param barejid Jabber ID of the contact
@param resource the resource being disconnected
@param status the status message received with the offline presence, or NULL
*/
* Called when a contact goes offline
* @param barejid Jabber ID of the contact
* @param resource The resource being disconnected
* @param status The status message received with the offline presence, or NULL
*/
void prof_on_contact_offline(const char *const barejid, const char *const resource, const char *const status);
/**
Called when a presence notification is received from a contact
@param barejid Jabber ID of the contact
@param resource the resource being disconnected
@param presence presence of the contact, one of "chat", "online", "away", "xa" or "dnd"
@param status the status message received with the presence, or NULL
@param priority the priority associated with the resource
*/
* Called when a presence notification is received from a contact
* @param barejid Jabber ID of the contact
* @param resource The resource being disconnected
* @param presence Presence of the contact, one of "chat", "online", "away", "xa" or "dnd"
* @param status The status message received with the presence, or NULL
* @param priority The priority associated with the resource
*/
void prof_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence, const char *const status, const int priority);
/**
Called when a chat window is focused
@param barejid Jabber ID of the chat window recipient
*/
* Called when a chat window is focused
* @param barejid Jabber ID of the chat window recipient
*/
void prof_on_chat_win_focus(const char *const barejid);
/**
Called when a chat room window is focused
@param barejid Jabber ID of the room
*/
void prof_on_room_win_focus(const char *const barejid);
* Called when a chat room window is focused
* @param barejid Jabber ID of the room
*/
void prof_on_room_win_focus(const char *const barejid);

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
#
# Profanity Python Plugins API documentation build configuration file, created by
# sphinx-quickstart on Thu Mar 17 23:01:31 2016.
# CProof Python Plugins API documentation build configuration file.
#
# This file is execfile()d with the current directory set to its
# containing dir.
@@ -47,25 +46,25 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'Profanity Python Plugins API'
copyright = u'2016 - 2018, boothj5'
author = u'boothj5'
project = u'CProof Python Plugins API'
copyright = u'2025, CProof, based on Profanity by boothj5 et al.'
author = u'CProof Developers'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0.5.0'
version = u'0.15.0'
# The full version, including alpha/beta/rc tags.
release = u'0.5.0'
release = u'0.15.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
@@ -75,7 +74,7 @@ language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ['_build', 'modules.rst']
# The reST default role (used for this markup: `text`) to use for all
# documents.
@@ -122,7 +121,7 @@ html_theme = 'default'
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = "Profanity Python Plugins"
html_title = "CProof Python Plugins"
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
@@ -139,7 +138,7 @@ html_title = "Profanity Python Plugins"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
@@ -202,7 +201,7 @@ html_show_copyright = False
#html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'ProfanityPythonPluginsAPIdoc'
htmlhelp_basename = 'CProofPythonPluginsAPIdoc'
# -- Options for LaTeX output ---------------------------------------------
@@ -224,8 +223,8 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'ProfanityPythonPluginsAPI.tex', u'Profanity Python Plugins API Documentation',
u'boothj5', 'manual'),
(master_doc, 'CProofPythonPluginsAPI.tex', u'CProof Python Plugins API Documentation',
u'CProof Developers', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -254,7 +253,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'profanitypythonpluginsapi', u'Profanity Python Plugins API Documentation',
(master_doc, 'cproofpythonpluginsapi', u'CProof Python Plugins API Documentation',
[author], 1)
]

View File

@@ -1 +1 @@
sphinx-apidoc -f -o . src && make html
sphinx-apidoc -f -o . src && make xml

View File

@@ -1,8 +1,8 @@
Profanity Python Plugins API
============================
CProof Python Plugins API
===========================
The ``prof`` module describes functions that plugins may call to interact with Profanity.
The ``plugin`` module describes functions that plugins may define to be notified of various events in Profanity.
The ``prof`` module describes functions that plugins may call to interact with CProof.
The ``plugin`` module describes functions that plugins may define to be notified of various events in CProof.
Contents:
@@ -11,4 +11,5 @@ Contents:
prof
plugin
* :ref:`genindex`
:ref:`genindex`

View File

@@ -1,360 +1,495 @@
"""
This page describes functions that plugins may implement to be called from Profanity on certain events. All functions are optional.
The plugin module defines optional callback functions that CProof plugins can
implement to handle events such as startup, shutdown, message processing, and
presence updates.
Examples:
::
def prof_on_start():
prof.cons_show("Profanity has started...")
All functions are optional and are called by CProof when the corresponding event
occurs. You need to define them in your module and they will automatically be used
for callback events.
def prof_pre_room_message_display(room, nick, message):
prof.cons_show("Manipulating chat room message before display...")
new_message = message + " (added by plugin)"
return new_message
To utilize full functionality, such as the ``prof.cons_show`` function, see ``prof``
documentation and use::
def prof_on_contact_presence(barejid, resource, presence, status, priority):
notify_message = barejid + " is " + presence
prof.notify(notify_message, 5, "Presence")
import prof
"""
def prof_init(version, status, account_name, fulljid):
"""Called when a plugin is loaded, either when profanity is started, or when the ``/plugins load`` or ``/plugins install`` commands are called
# Initialization and Lifecycle
# ---------------------------
:param version: the version of Profanity
:param status: the package status of Profanity, ``"development"`` or ``"release"``
:param account_name: account name of the currently logged in account, or ``None`` if not logged in
:param fulljid: the users full Jabber ID (barejid and resource) if logged in, ``None`` otherwise
:type version: str or unicode
:type status: str or unicode
:type account_name: str, unicode or None
:type fulljid: str, unicode or None
def prof_init(version: str, status: str, account_name: str | None, fulljid: str | None) -> None:
"""Initializes the plugin when loaded by CProof.
Called when CProof starts or when the plugin is loaded via the ``/plugins load``
or ``/plugins install`` commands.
:param version: The version of CProof (e.g., ``"1.0.0"``).
:param status: The package status of CProof (``"development"`` or ``"release"``).
:param account_name: The account name of the logged-in user, or None if not logged in.
:param fulljid: The full Jabber ID (barejid/resource) of the logged-in user, or None if not logged in.
:return: None
Example::
def prof_init(version: str, status: str, account_name: str | None, fulljid: str | None) -> None:
prof.cons_show(f"MyPlugin for CProof {version} ({status}) has been loaded, account: {account_name}")
"""
pass
def prof_on_start() -> None:
"""Called when CProof starts.
def prof_on_start():
"""Called when Profanity is started
Use this to perform setup tasks that should occur at application startup.
:return: None
Example::
def prof_on_start() -> None:
prof.cons_show("CProof has started...")
"""
pass
def prof_on_shutdown() -> None:
"""Called when CProof is shutting down.
def prof_on_shutdown():
"""Called when the user quits Profanity
Use this to perform cleanup tasks before the application exits.
:return: None
Example::
def prof_on_shutdown() -> None:
prof.cons_show("CProof is shutting down...")
"""
pass
def prof_on_unload() -> None:
"""Called when the plugin is unloaded via the ``/plugins unload`` command.
def prof_on_unload():
"""Called when a plugin is unloaded with the ``/plugins unload`` command
Use this to clean up plugin-specific resources.
:return: None
Example::
def prof_on_unload() -> None:
prof.cons_show("Plugin unloaded")
"""
pass
def prof_on_connect(account_name: str, fulljid: str) -> None:
"""Called when a user connects to CProof with an account.
def prof_on_connect(account_name, fulljid):
"""Called when the user connects with an account
:param account_name: The account name used for login.
:param fulljid: The full Jabber ID (barejid/resource) of the connected account.
:return: None
:param account_name: account name of the account used for logging in
:param fulljid: the full Jabber ID (barejid and resource) of the account
:type account_name: str or unicode
:type fulljid: str or unicode
Example::
def prof_on_connect(account_name: str, fulljid: str) -> None:
prof.cons_show(f"Connected as {account_name} ({fulljid})")
"""
pass
def prof_on_disconnect(account_name: str, fulljid: str) -> None:
"""Called when a user disconnects an account from CProof.
def prof_on_disconnect(account_name, fulljid):
"""Called when the user disconnects an account
:param account_name: The account name being disconnected.
:param fulljid: The full Jabber ID (barejid/resource) of the disconnected account.
:return: None
:param account_name: account name of the account being disconnected
:param fulljid: the full Jabber ID (barejid and resource) of the account
:type account_name: str or unicode
:type fulljid: str or unicode
Example::
def prof_on_disconnect(account_name: str, fulljid: str) -> None:
prof.cons_show(f"Disconnected {account_name} ({fulljid})")
"""
pass
# Chat Message Handlers
# ---------------------
def prof_pre_chat_message_display(barejid, resource, message):
"""Called before a chat message is displayed
def prof_pre_chat_message_display(barejid: str, resource: str, message: str) -> str | None:
"""Called before a chat message is displayed in a chat window.
:param barejid: Jabber ID of the message sender
:param resource: resource of the message sender
:param message: the received message
:type barejid: str or unicode
:type resource: str or unicode
:type message: str or unicode
:return: the new message to display, or ``None`` to preserve the original message
:rtype: str or unicode
Allows the plugin to modify or cancel the message display.
:param barejid: The Jabber ID of the message sender (e.g., ``bob@example.com``).
:param resource: The sender's resource (e.g., ``laptop``).
:param message: The received message.
:return: The modified message to display, or None to preserve the original.
Example::
def prof_pre_chat_message_display(barejid: str, resource: str, message: str) -> str | None:
new_message = f"{message} (from {barejid})"
return new_message
"""
pass
def prof_post_chat_message_display(barejid: str, resource: str, message: str) -> None:
"""Called after a chat message is displayed in a chat window.
def prof_post_chat_message_display(barejid, resource, message):
"""Called after a chat message is displayed
Use this to perform actions after the message is shown.
:param barejid: Jabber ID of the message sender
:param resource: resource of the message sender
:param message: the received message
:type barejid: str or unicode
:type resource: str or unicode
:type message: str or unicode
:param barejid: The Jabber ID of the message sender (e.g., ``bob@example.com``).
:param resource: The sender's resource (e.g., ``laptop``).
:param message: The displayed message.
:return: None
Example::
def prof_post_chat_message_display(barejid: str, resource: str, message: str) -> None:
prof.cons_show(f"Displayed message from {barejid}/{resource}: {message}")
"""
pass
def prof_pre_chat_message_send(barejid: str, message: str) -> str | None:
"""Called before a chat message is sent from CProof.
def prof_pre_chat_message_send(barejid, message):
"""Called before a chat message is sent
Allows the plugin to modify or cancel the message.
:param barejid: Jabber ID of the message recipient
:param message: the message to be sent
:type barejid: str or unicode
:type message: str or unicode
:return: the modified or original message to send, or ``None`` to cancel sending of the message
:rtype: str or unicode
:param barejid: The Jabber ID of the recipient (e.g., ``bob@example.com``).
:param message: The message to be sent.
:return: The modified message to send, or None to cancel sending.
Example::
def prof_pre_chat_message_send(barejid: str, message: str) -> str | None:
return f"{message} (sent by plugin)"
"""
pass
def prof_post_chat_message_send(barejid: str, message: str) -> None:
"""Called after a chat message is sent from CProof.
def prof_post_chat_message_send(barejid, message):
"""Called after a chat message has been sent
Use this to log or react to sent messages.
:param barejid: Jabber ID of the message recipient
:param message: the sent message
:type barejid: str or unicode
:type message: str or unicode
:param barejid: The Jabber ID of the recipient (e.g., ``bob@example.com``).
:param message: The sent message.
:return: None
Example::
def prof_post_chat_message_send(barejid: str, message: str) -> None:
prof.cons_show(f"Sent to {barejid}: {message}")
"""
pass
# Room Message Handlers
# ---------------------
def prof_pre_room_message_display(barejid, nick, message):
"""Called before a chat room message is displayed
def prof_pre_room_message_display(barejid: str, nick: str, message: str) -> str | None:
"""Called before a chat room message is displayed.
:param barejid: Jabber ID of the room
:param nick: nickname of message sender
:param message: the received message
:type barejid: str or unicode
:type nick: str or unicode
:type message: str or unicode
:return: the new message to display, or ``None`` to preserve the original message
:rtype: str or unicode
Allows the plugin to modify or cancel the message display.
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param nick: The nickname of the message sender.
:param message: The received message.
:return: The modified message to display, or None to preserve the original.
Example::
def prof_pre_room_message_display(barejid: str, nick: str, message: str) -> str | None:
return f"{message} (from {nick})"
"""
pass
def prof_post_room_message_display(barejid: str, nick: str, message: str) -> None:
"""Called after a chat room message is displayed.
def prof_post_room_message_display(barejid, nick, message):
"""Called after a chat room message is displayed
Use this to perform actions after the message is shown.
:param barejid: Jabber ID of the room
:param nick: nickname of the message sender
:param message: the received message
:type barejid: str or unicode
:type nick: str or unicode
:type message: str or unicode
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param nick: The nickname of the message sender.
:param message: The displayed message.
:return: None
Example::
def prof_post_room_message_display(barejid: str, nick: str, message: str) -> None:
prof.cons_show(f"Displayed in {barejid} from {nick}: {message}")
"""
pass
def prof_pre_room_message_send(barejid: str, message: str) -> str | None:
"""Called before a chat room message is sent.
def prof_pre_room_message_send(barejid, message):
"""Called before a chat room message is sent
Allows the plugin to modify or cancel the message.
:param barejid: Jabber ID of the room
:param message: the message to be sent
:type barejid: str or unicode
:type message: str or unicode
:return: the modified or original message to send, or ``None`` to cancel sending of the message
:rtype: str or unicode
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param message: The message to be sent.
:return: The modified message to send, or None to cancel sending.
Example::
def prof_pre_room_message_send(barejid: str, message: str) -> str | None:
return f"{message} (sent by plugin)"
"""
pass
def prof_post_room_message_send(barejid: str, message: str) -> None:
"""Called after a chat room message is sent.
def prof_post_room_message_send(barejid, message):
"""Called after a chat room message has been sent
Use this to log or react to sent messages.
:param barejid: Jabber ID of the room
:param message: the sent message
:type barejid: str or unicode
:type message: str or unicode
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param message: The sent message.
:return: None
Example::
def prof_post_room_message_send(barejid: str, message: str) -> None:
prof.cons_show(f"Sent to {barejid}: {message}")
"""
pass
def prof_on_room_history_message(barejid: str, nick: str, message: str, timestamp: str) -> None:
"""Called when a chat room history message is received from the server.
def prof_on_room_history_message(barejid, nick, message, timestamp):
"""Called when the server sends a chat room history message
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param nick: The nickname of the message sender.
:param message: The received message.
:param timestamp: The message's original send time in ISO 8601 format (e.g., ``2025-09-10T19:45:00Z``).
:return: None
:param barejid: Jabber ID of the room
:param nick: nickname of the message sender
:param message: the message to be sent
:param timestamp: time the message was originally sent to the room, in ISO8601 format
:type barejid: str or unicode
:type nick: str or unicode
:type message: str or unicode
:type timestamp: str or unicode
Example::
def prof_on_room_history_message(barejid: str, nick: str, message: str, timestamp: str) -> None:
prof.cons_show(f"History in {barejid} from {nick} at {timestamp}: {message}")
"""
pass
# Private Message Handlers
# ------------------------
def prof_pre_priv_message_display(barejid, nick, message):
"""Called before a private chat room message is displayed
def prof_pre_priv_message_display(barejid: str, nick: str, message: str) -> str | None:
"""Called before a private chat room message is displayed.
:param barejid: Jabber ID of the room
:param nick: nickname of message sender
:param message: the received message
:type barejid: str or unicode
:type nick: str or unicode
:type message: str or unicode
:return: the new message to display, or ``None`` to preserve the original message
:rtype: str or unicode
Allows the plugin to modify or cancel the message display.
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param nick: The nickname of the message sender.
:param message: The received message.
:return: The modified message to display, or None to preserve the original.
Example::
def prof_pre_priv_message_display(barejid: str, nick: str, message: str) -> str | None:
return f"{message} (private from {nick})"
"""
pass
def prof_post_priv_message_display(barejid: str, nick: str, message: str) -> None:
"""Called after a private chat room message is displayed.
def prof_post_priv_message_display(barejid, nick, message):
"""Called after a private chat room message is displayed
Use this to perform actions after the message is shown.
:param barejid: Jabber ID of the room
:param nick: nickname of the message sender
:param message: the received message
:type barejid: str or unicode
:type nick: str or unicode
:type message: str or unicode
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param nick: The nickname of the message sender.
:param message: The displayed message.
:return: None
Example::
def prof_post_priv_message_display(barejid: str, nick: str, message: str) -> None:
prof.cons_show(f"Displayed private in {barejid} from {nick}: {message}")
"""
pass
def prof_pre_priv_message_send(barejid: str, nick: str, message: str) -> str | None:
"""Called before a private chat room message is sent.
def prof_pre_priv_message_send(barejid, nick, message):
"""Called before a private chat room message is sent
Allows the plugin to modify or cancel the message.
:param barejid: Jabber ID of the room
:param nick: nickname of message recipient
:param message: the message to be sent
:type barejid: str or unicode
:type nick: str or unicode
:type message: str or unicode
:return: the modified or original message to send, or ``None`` to cancel sending of the message
:rtype: str or unicode
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param nick: The nickname of the message recipient.
:param message: The message to be sent.
:return: The modified message to send, or None to cancel sending.
Example::
def prof_pre_priv_message_send(barejid: str, nick: str, message: str) -> str | None:
return f"{message} (private to {nick})"
"""
pass
def prof_post_priv_message_send(barejid: str, nick: str, message: str) -> None:
"""Called after a private chat room message is sent.
def prof_post_priv_message_send(barejid, nick, message):
"""Called after a private chat room message has been sent
Use this to log or react to sent messages.
:param barejid: Jabber ID of the room
:param nick: nickname of the message recipient
:param message: the sent message
:type barejid: str or unicode
:type nick: str or unicode
:type message: str or unicode
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:param nick: The nickname of the message recipient.
:param message: The sent message.
:return: None
Example::
def prof_post_priv_message_send(barejid: str, nick: str, message: str) -> None:
prof.cons_show(f"Sent private to {nick} in {barejid}: {message}")
"""
pass
# Stanza Handlers
# ---------------
def prof_on_message_stanza_send(stanza):
"""Called before an XMPP message stanza is sent
def prof_on_message_stanza_send(stanza: str) -> str | None:
"""Called before an XMPP message stanza is sent.
:param stanza: The stanza to send
:type stanza: str or unicode
:return: The new stanza to send, or ``None`` to preserve the original stanza
:rtype: str or unicode
Allows the plugin to modify or cancel the stanza.
:param stanza: The XMPP message stanza to send.
:return: The modified stanza to send, or None to preserve the original.
Example::
def prof_on_message_stanza_send(stanza: str) -> str | None:
prof.cons_show(f"Sending message stanza: {stanza}")
return stanza
"""
pass
def prof_on_message_stanza_receive(stanza: str) -> bool:
"""Called when an XMPP message stanza is received.
def prof_on_message_stanza_receive(stanza):
"""Called when an XMPP message stanza is received
Allows the plugin to control whether CProof processes the stanza.
:param stanza: The stanza received
:type stanza: str or unicode
:return: ``True`` if Profanity should continue to process the message stanza, ``False`` otherwise
:rtype: boolean
:param stanza: The received XMPP message stanza.
:return: True to allow CProof to process the stanza, False to block processing.
Example::
def prof_on_message_stanza_receive(stanza: str) -> bool:
prof.cons_show(f"Received message stanza: {stanza}")
return True
"""
pass
def prof_on_presence_stanza_send(stanza: str) -> str | None:
"""Called before an XMPP presence stanza is sent.
def prof_on_presence_stanza_send(stanza):
"""Called before an XMPP presence stanza is sent
Allows the plugin to modify or cancel the stanza.
:param stanza: The stanza to send
:type stanza: str or unicode
:return: The new stanza to send, or ``None`` to preserve the original stanza
:rtype: str or unicode
:param stanza: The XMPP presence stanza to send.
:return: The modified stanza to send, or None to preserve the original.
Example::
def prof_on_presence_stanza_send(stanza: str) -> str | None:
prof.cons_show(f"Sending presence stanza: {stanza}")
return stanza
"""
pass
def prof_on_presence_stanza_receive(stanza: str) -> bool:
"""Called when an XMPP presence stanza is received.
def prof_on_presence_stanza_receive(stanza):
"""Called when an XMPP presence stanza is received
Allows the plugin to control whether CProof processes the stanza.
:param stanza: The stanza received
:type stanza: str or unicode
:return: ``True`` if Profanity should continue to process the presence stanza, ``False`` otherwise
:rtype: boolean
:param stanza: The received XMPP presence stanza.
:return: True to allow CProof to process the stanza, False to block processing.
Example::
def prof_on_presence_stanza_receive(stanza: str) -> bool:
prof.cons_show(f"Received presence stanza: {stanza}")
return True
"""
pass
def prof_on_iq_stanza_send(stanza: str) -> str | None:
"""Called before an XMPP IQ stanza is sent.
def prof_on_iq_stanza_send(stanza):
"""Called before an XMPP iq stanza is sent
Allows the plugin to modify or cancel the stanza.
:param stanza: The stanza to send
:type stanza: str or unicode
:return: The new stanza to send, or ``None`` to preserve the original stanza
:rtype: str or unicode
:param stanza: The XMPP IQ stanza to send.
:return: The modified stanza to send, or None to preserve the original.
Example::
def prof_on_iq_stanza_send(stanza: str) -> str | None:
prof.cons_show(f"Sending IQ stanza: {stanza}")
return stanza
"""
pass
def prof_on_iq_stanza_receive(stanza: str) -> bool:
"""Called when an XMPP IQ stanza is received.
def prof_on_iq_stanza_receive(stanza):
"""Called when an XMPP iq stanza is received
Allows the plugin to control whether CProof processes the stanza.
:param stanza: The stanza received
:type stanza: str or unicode
:return: ``True`` if Profanity should continue to process the iq stanza, ``False`` otherwise
:rtype: boolean
:param stanza: The received XMPP IQ stanza.
:return: True to allow CProof to process the stanza, False to block processing.
Example::
def prof_on_iq_stanza_receive(stanza: str) -> bool:
prof.cons_show(f"Received IQ stanza: {stanza}")
return True
"""
pass
# Contact Presence Handlers
# -------------------------
def prof_on_contact_offline(barejid, resource, status):
"""Called when a contact goes offline
def prof_on_contact_offline(barejid: str, resource: str, status: str | None) -> None:
"""Called when a contact goes offline.
:param barejid: Jabber ID of the contact
:param resource: the resource being disconnected
:param status: the status message received with the offline presence, or ``None``
:type barejid: str or unicode
:type resource: str or unicode
:type status: str or unicode
:param barejid: The Jabber ID of the contact (e.g., ``bob@example.com``).
:param resource: The resource being disconnected (e.g., ``laptop``).
:param status: The status message received with the offline presence, or None.
:return: None
Example::
def prof_on_contact_offline(barejid: str, resource: str, status: str | None) -> None:
prof.cons_show(f"{barejid}/{resource} went offline: {status or 'No status'}")
"""
pass
def prof_on_contact_presence(barejid: str, resource: str, presence: str, status: str | None, priority: int) -> None:
"""Called when a presence notification is received from a contact.
def prof_on_contact_presence(barejid, resource, presence, status, priority):
"""Called when a presence notification is received from a contact
:param barejid: The Jabber ID of the contact (e.g., ``bob@example.com``).
:param resource: The resource of the contact (e.g., ``laptop``).
:param presence: The contact's presence (``"chat"``, ``"online"``, ``"away"``, ``"xa"``, or ``"dnd"``).
:param status: The status message received with the presence, or None.
:param priority: The priority associated with the resource.
:return: None
:param barejid: Jabber ID of the contact
:param resource: the resource being disconnected
:param presence: presence of the contact, one of ``"chat"``, ``"online"``, ``"away"``, ``"xa"`` or ``"dnd"``
:param status: the status message received with the presence, or ``None``
:param priority: the priority associated with the resource
:type barejid: str or unicode
:type resource: str or unicode
:type presence: str or unicode
:type status: str or unicode
:type priority: int
Example::
def prof_on_contact_presence(barejid: str, resource: str, presence: str, status: str | None, priority: int) -> None:
prof.notify(f"{barejid} is {presence}", 5000, "Presence")
"""
pass
# Window Focus Handlers
# ---------------------
def prof_on_chat_win_focus(barejid):
"""Called when a chat window is focused
def prof_on_chat_win_focus(barejid: str) -> None:
"""Called when a chat window is focused.
:param barejid: Jabber ID of the chat window recipient
:type barejid: str or unicode
:param barejid: The Jabber ID of the chat window recipient (e.g., ``bob@example.com``).
:return: None
Example::
def prof_on_chat_win_focus(barejid: str) -> None:
prof.cons_show(f"Focused chat window for {barejid}")
"""
pass
def prof_on_room_win_focus(barejid: str) -> None:
"""Called when a chat room window is focused.
def prof_on_room_win_focus(barejid):
"""Called when a chat room window is focused
:param barejid: The Jabber ID of the room (e.g., ``chat@conference.example.com``).
:return: None
:param barejid: Jabber ID of the room
:type barejid: str or unicode
Example::
def prof_on_room_win_focus(barejid: str) -> None:
prof.cons_show(f"Focused room window for {barejid}")
"""
pass
pass

File diff suppressed because it is too large Load Diff

View File

@@ -121,11 +121,11 @@ esac
case "$ARCH" in
linux*)
echo
echo "--> Building with ./configure ${tests[0]} --enable-valgrind $*"
echo "--> Building with ./configure -C ${tests[0]} --enable-valgrind $*"
echo
# shellcheck disable=SC2086
./configure ${tests[0]} --enable-valgrind $*
./configure -C ${tests[0]} --enable-valgrind $*
$MAKE CC="${CC}"
if grep '^ID=' /etc/os-release | grep -q -e debian; then
@@ -140,11 +140,11 @@ esac
for features in "${tests[@]}"
do
echo
echo "--> Building with ./configure ${features} $*"
echo "--> Building with ./configure -C ${features} $*"
echo
# shellcheck disable=SC2086
./configure $features $*
./configure -C $features $*
$MAKE CC="${CC}"
$MAKE check

View File

@@ -5,7 +5,7 @@
#
# This file is a combination of our own rules and
# * the glib2 suppressions file that usually can be found at /usr/share/glib-2.0/valgrind/glib.supp
# * python suppressions file from http://svn.python.org/projects/python/trunk/Misc/valgrind-python.supp
# * python suppressions file from https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
#
{
@@ -1557,6 +1557,10 @@
...
fun:xdg_mime_init
}
# Python Valgrind .supp start
# taken from https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
#
# This is a valgrind suppression file that should be used when using valgrind.
#
@@ -1654,6 +1658,49 @@
fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
}
#
# Leaks: dlopen() called without dlclose()
#
{
dlopen() called without dlclose()
Memcheck:Leak
fun:malloc
fun:malloc
fun:strdup
fun:_dl_load_cache_lookup
}
{
dlopen() called without dlclose()
Memcheck:Leak
fun:malloc
fun:malloc
fun:strdup
fun:_dl_map_object
}
{
dlopen() called without dlclose()
Memcheck:Leak
fun:malloc
fun:*
fun:_dl_new_object
}
{
dlopen() called without dlclose()
Memcheck:Leak
fun:calloc
fun:*
fun:_dl_new_object
}
{
dlopen() called without dlclose()
Memcheck:Leak
fun:calloc
fun:*
fun:_dl_check_map_versions
}
#
# Non-python specific leaks
#
@@ -2048,6 +2095,10 @@
fun:PyUnicode_FSConverter
}
# Python Valgrind .supp end
# Actual GTK things
{
GtkWidgetClass action GPtrArray

View File

@@ -136,6 +136,7 @@ static char* _mood_autocomplete(ProfWin* window, const char* const input, gboole
static char* _strophe_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _adhoc_cmd_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _force_encryption_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _script_autocomplete_func(const char* const prefix, gboolean previous, void* context);
@@ -296,6 +297,8 @@ static Autocomplete vcard_name_ac;
static Autocomplete vcard_set_param_ac;
static Autocomplete vcard_togglable_param_ac;
static Autocomplete vcard_address_type_ac;
static Autocomplete force_encryption_ac;
static Autocomplete force_encryption_policy_ac;
static Autocomplete* all_acs[] = {
&commands_ac,
@@ -448,6 +451,8 @@ static Autocomplete* all_acs[] = {
&vcard_set_param_ac,
&vcard_togglable_param_ac,
&vcard_address_type_ac,
&force_encryption_ac,
&force_encryption_policy_ac
};
static GHashTable* ac_funcs = NULL;
@@ -1343,6 +1348,13 @@ cmd_ac_init(void)
autocomplete_add(vcard_address_type_ac, "domestic");
autocomplete_add(vcard_address_type_ac, "international");
autocomplete_add(force_encryption_ac, "on");
autocomplete_add(force_encryption_ac, "off");
autocomplete_add(force_encryption_ac, "policy");
autocomplete_add(force_encryption_policy_ac, "block");
autocomplete_add(force_encryption_policy_ac, "resend-to-confirm");
if (ac_funcs != NULL)
g_hash_table_destroy(ac_funcs);
ac_funcs = g_hash_table_new(g_str_hash, g_str_equal);
@@ -1415,6 +1427,7 @@ cmd_ac_init(void)
g_hash_table_insert(ac_funcs, "/win", _win_autocomplete);
g_hash_table_insert(ac_funcs, "/wins", _wins_autocomplete);
g_hash_table_insert(ac_funcs, "/wintitle", _wintitle_autocomplete);
g_hash_table_insert(ac_funcs, "/force-encryption", _force_encryption_autocomplete);
}
void
@@ -1662,7 +1675,7 @@ char*
cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous)
{
unsigned int output_off = 0;
char* tmp;
char* tmp = NULL;
// strip command
char* inpcp = (char*)input + strlen(startstr);
@@ -1674,38 +1687,36 @@ cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean
// strip quotes
if (*inpcp == '"') {
tmp = strchr(inpcp + 1, '"');
tmp = strrchr(inpcp + 1, '"');
if (tmp) {
*tmp = '\0';
}
tmp = strdup(inpcp + 1);
free(inpcp);
inpcp = tmp;
tmp = NULL;
}
// expand ~ to $HOME
if (inpcp[0] == '~' && inpcp[1] == '/') {
tmp = g_strdup_printf("%s/%sfoo", getenv("HOME"), inpcp + 2);
if (!tmp) {
char* home = getenv("HOME");
if (!home) {
free(inpcp);
return NULL;
}
output_off = strlen(getenv("HOME")) + 1;
tmp = g_strdup_printf("%s/%sfoo", home, inpcp + 2);
output_off = strlen(home) + 1;
} else {
tmp = g_strdup_printf("%sfoo", inpcp);
if (!tmp) {
free(inpcp);
return NULL;
}
}
free(inpcp);
inpcp = tmp;
if (!tmp) {
return NULL;
}
char* inpcp2 = strdup(inpcp);
char* foofile = strdup(basename(inpcp2));
char* directory = strdup(dirname(inpcp));
free(inpcp);
free(inpcp2);
char* foofile = strdup(basename(tmp));
char* directory = strdup(dirname(tmp));
g_free(tmp);
GArray* files = g_array_new(TRUE, FALSE, sizeof(char*));
g_array_set_clear_func(files, (GDestroyNotify)_filepath_item_free);
@@ -1724,40 +1735,26 @@ cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean
continue;
}
char* acstring;
char* acstring = NULL;
if (output_off) {
tmp = g_strdup_printf("%s/%s", directory, dir->d_name);
if (!tmp) {
free(directory);
free(foofile);
return NULL;
if (tmp) {
acstring = g_strdup_printf("~/%s", tmp + output_off);
g_free(tmp);
}
acstring = g_strdup_printf("~/%s", tmp + output_off);
if (!acstring) {
free(directory);
free(foofile);
return NULL;
}
free(tmp);
} else if (strcmp(directory, "/") == 0) {
acstring = g_strdup_printf("/%s", dir->d_name);
if (!acstring) {
free(directory);
free(foofile);
return NULL;
}
} else {
acstring = g_strdup_printf("%s/%s", directory, dir->d_name);
if (!acstring) {
free(directory);
free(foofile);
return NULL;
}
}
if (!acstring) {
g_array_free(files, TRUE);
free(foofile);
free(directory);
return NULL;
}
char* acstring_cpy = strdup(acstring);
g_array_append_val(files, acstring_cpy);
free(acstring);
g_array_append_val(files, acstring);
}
closedir(d);
}
@@ -4406,3 +4403,17 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
return result;
}
static char*
_force_encryption_autocomplete(ProfWin* window, const char* const input, gboolean previous)
{
char* result = NULL;
result = autocomplete_param_with_ac(input, "/force-encryption policy", force_encryption_policy_ac, TRUE, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/force-encryption", force_encryption_ac, TRUE, previous);
return result;
}

View File

@@ -433,7 +433,7 @@ static const struct cmd_t command_defs[] = {
{ "<contact>", "The contact you wish to view information about." },
{ "<nick>", "When in a chat room, the occupant you wish to view information about." })
CMD_EXAMPLES(
"/info thor@aasgard.server.org",
"/info thor@asgard.server.org",
"/info heimdall")
},
@@ -2729,6 +2729,7 @@ static const struct cmd_t command_defs[] = {
{ "os on|off", "Choose whether to include the OS name if a user asks for software information (XEP-0092)." }
)
CMD_EXAMPLES(
"/privacy",
"/privacy logging off",
"/privacy os off")
},
@@ -2744,6 +2745,31 @@ static const struct cmd_t command_defs[] = {
"Redraw user interface. Can be used when some other program interrupted profanity or wrote to the same terminal and the interface looks \"broken\"." )
},
{ CMD_PREAMBLE("/force-encryption",
parse_args, 1, 3, &cons_encryption_setting)
CMD_MAINFUNC(cmd_force_encryption)
CMD_TAGS(
CMD_TAG_CHAT)
CMD_SYN(
"/force-encryption",
"/force-encryption on|off",
"/force-encryption policy resend-to-confirm|block")
CMD_DESC(
"Configure forced encryption for outgoing messages in CProof. "
"When enabled, restricts sending unencrypted messages based on the specified policy. "
"Run without arguments to display current settings.")
CMD_ARGS(
{ "on|off", "Enable or disable forced encryption. When enabled, restricts unencrypted messages per the policy. When disabled, allows sending unencrypted messages without restrictions." },
{ "policy resend-to-confirm|block", "Set the policy for unencrypted messages when forced encryption is enabled. 'resend-to-confirm' requires pressing Enter again to confirm sending an unencrypted message (default). 'block' prevents sending unencrypted messages entirely." }
)
CMD_EXAMPLES(
"/force-encryption",
"/force-encryption on",
"/force-encryption off",
"/force-encryption policy resend-to-confirm",
"/force-encryption policy block")
},
// NEXT-COMMAND (search helper)
};

View File

@@ -1263,6 +1263,11 @@ cmd_sub(ProfWin* window, const char* const command, gchar** args)
auto_jid Jid* jidp = jid_create(jid);
if (jidp == NULL) {
cons_show("Malformed JID: %s", jid);
return TRUE;
}
if (strcmp(subcmd, "allow") == 0) {
presence_subscription(jidp->barejid, PRESENCE_SUBSCRIBED);
cons_show("Accepted subscription for %s", jidp->barejid);
@@ -1715,8 +1720,15 @@ cmd_help(ProfWin* window, const char* const command, gchar** args)
gboolean
cmd_about(ProfWin* window, const char* const command, gchar** args)
{
ProfWin* console = wins_get_console();
cons_show("");
cons_about();
win_println(console, THEME_DEFAULT, "-", "Licensed under GNU GPL v3.");
win_println(console, THEME_DEFAULT, "-", "CProof is an independent unaffiliated fork of Profanity.");
win_println(console, THEME_DEFAULT, "-", "Profanity: Copyright (C) 20122019 James Booth, 20192025 Michael Vetter");
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2025 CProof Developers");
win_println(console, THEME_DEFAULT, "-", "");
return TRUE;
}
@@ -3411,7 +3423,7 @@ cmd_caps(ProfWin* window, const char* const command, gchar** args)
if (args[0]) {
auto_jid Jid* jid = jid_create(args[0]);
if (jid->fulljid == NULL) {
if (jid == NULL || jid->fulljid == NULL) {
cons_show("You must provide a full jid to the /caps command.");
} else {
PContact pcontact = roster_get_contact(jid->barejid);
@@ -5233,54 +5245,43 @@ cmd_console(ProfWin* window, const char* const command, gchar** args)
gboolean
cmd_presence(ProfWin* window, const char* const command, gchar** args)
{
if (strcmp(args[0], "console") != 0 && strcmp(args[0], "chat") != 0 && strcmp(args[0], "room") != 0 && strcmp(args[0], "titlebar") != 0) {
cons_bad_cmd_usage(command);
return TRUE;
}
if (strcmp(args[0], "titlebar") == 0) {
_cmd_set_boolean_preference(args[1], "Contact presence", PREF_PRESENCE);
return TRUE;
}
if (strcmp(args[1], "all") != 0 && strcmp(args[1], "online") != 0 && strcmp(args[1], "none") != 0) {
const struct presence_preferences
{
preference_t pref;
const char *name, *description;
} presence_prefs[] = {
{ .pref = PREF_STATUSES_CONSOLE, .name = "console", .description = "the console" },
{ .pref = PREF_STATUSES_CHAT, .name = "chat", .description = "chat windows" },
{ .pref = PREF_STATUSES_MUC, .name = "room", .description = "chat room windows" },
};
size_t n = 0;
for (; n < ARRAY_SIZE(presence_prefs); ++n) {
const struct presence_preferences* pp = &presence_prefs[n];
if (g_strcmp0(args[0], pp->name) != 0)
continue;
if (strcmp(args[1], "all") == 0) {
cons_show("All presence updates will appear in %s.", pp->description);
} else if (strcmp(args[1], "online") == 0) {
cons_show("Only %s presence updates will appear in %s.",
pp->pref == PREF_STATUSES_MUC ? "join/leave" : "online/offline",
pp->description);
} else if (strcmp(args[1], "none") == 0) {
cons_show("Presence updates will not appear in %s.", pp->description);
} else {
cons_bad_cmd_usage(command);
return TRUE;
}
prefs_set_string(pp->pref, args[1]);
break;
}
if (n == ARRAY_SIZE(presence_prefs)) {
cons_bad_cmd_usage(command);
return TRUE;
}
if (strcmp(args[0], "console") == 0) {
prefs_set_string(PREF_STATUSES_CONSOLE, args[1]);
if (strcmp(args[1], "all") == 0) {
cons_show("All presence updates will appear in the console.");
} else if (strcmp(args[1], "online") == 0) {
cons_show("Only online/offline presence updates will appear in the console.");
} else {
cons_show("Presence updates will not appear in the console.");
}
}
if (strcmp(args[0], "chat") == 0) {
prefs_set_string(PREF_STATUSES_CHAT, args[1]);
if (strcmp(args[1], "all") == 0) {
cons_show("All presence updates will appear in chat windows.");
} else if (strcmp(args[1], "online") == 0) {
cons_show("Only online/offline presence updates will appear in chat windows.");
} else {
cons_show("Presence updates will not appear in chat windows.");
}
}
if (strcmp(args[0], "room") == 0) {
prefs_set_string(PREF_STATUSES_MUC, args[1]);
if (strcmp(args[1], "all") == 0) {
cons_show("All presence updates will appear in chat room windows.");
} else if (strcmp(args[1], "online") == 0) {
cons_show("Only join/leave presence updates will appear in chat room windows.");
} else {
cons_show("Presence updates will not appear in chat room windows.");
}
}
return TRUE;
}
@@ -5314,7 +5315,8 @@ cmd_time(ProfWin* window, const char* const command, gchar** args)
};
gboolean redraw = FALSE;
gboolean set_all = g_strcmp0(args[0], "all") == 0;
for (size_t n = 0; n < ARRAY_SIZE(time_prefs); ++n) {
size_t n = 0;
for (; n < ARRAY_SIZE(time_prefs); ++n) {
if (!set_all && g_strcmp0(args[0], time_prefs[n].name) != 0)
continue;
const struct time_preferences* tp = &time_prefs[n];
@@ -5355,6 +5357,9 @@ cmd_time(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}
}
if (!set_all && n == ARRAY_SIZE(time_prefs)) {
cons_bad_cmd_usage(command);
}
if (redraw)
ui_redraw();
return TRUE;
@@ -8572,19 +8577,20 @@ cmd_omemo_trust_mode(ProfWin* window, const char* const command, gchar** args)
{
#ifdef HAVE_OMEMO
auto_gchar gchar* trust_mode = prefs_get_string(PREF_OMEMO_TRUST_MODE);
if (!args[1]) {
cons_show("Current trust mode is %s", prefs_get_string(PREF_OMEMO_TRUST_MODE));
cons_show("Current trust mode is %s", trust_mode);
return TRUE;
}
if (g_strcmp0(args[1], "manual") == 0) {
cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]);
cons_show("Current trust mode is %s - setting to %s", trust_mode, args[1]);
cons_show("You need to trust all OMEMO fingerprints manually");
} else if (g_strcmp0(args[1], "firstusage") == 0) {
cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]);
cons_show("Current trust mode is %s - setting to %s", trust_mode, args[1]);
cons_show("The first seen OMEMO fingerprints will be trusted automatically - new keys must be trusted manually");
} else if (g_strcmp0(args[1], "blind") == 0) {
cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]);
cons_show("Current trust mode is %s - setting to %s", trust_mode, args[1]);
cons_show("ALL OMEMO fingerprints will be trusted automatically");
} else {
cons_bad_cmd_usage(command);
@@ -9527,16 +9533,7 @@ cmd_change_password(ProfWin* window, const char* const command, gchar** args)
gboolean
cmd_editor(ProfWin* window, const char* const command, gchar** args)
{
auto_gchar gchar* message = NULL;
if (get_message_from_editor(NULL, &message)) {
return TRUE;
}
rl_insert_text(message);
ui_resize();
rl_point = rl_end;
rl_forced_update_display();
get_message_from_editor_async(NULL);
return TRUE;
}
@@ -10642,3 +10639,22 @@ cmd_vcard_save(ProfWin* window, const char* const command, gchar** args)
cons_show("User vCard uploaded");
return TRUE;
}
gboolean
cmd_force_encryption(ProfWin* window, const char* const command, gchar** args)
{
if (g_strv_length(args) == 1 && (g_strcmp0(args[0], "on") == 0 || g_strcmp0(args[0], "off") == 0)) {
_cmd_set_boolean_preference(args[0], "Forces encryption", PREF_FORCE_ENCRYPTION);
} else if (g_strv_length(args) == 2 && g_strcmp0(args[0], "policy") == 0) {
if (g_strcmp0(args[1], "resend-to-confirm") != 0 && g_strcmp0(args[1], "block") != 0) {
cons_show_error("Invalid policy: \"%s\". See '/help force-encryption' for details.", args[1]);
return TRUE;
}
prefs_set_string(PREF_FORCE_ENCRYPTION_MODE, args[1]);
cons_show("Force encryption policy has been set to \"%s\".", args[1]);
} else {
cons_bad_cmd_usage(command);
}
return TRUE;
}

View File

@@ -269,5 +269,6 @@ gboolean cmd_vcard_photo(ProfWin* window, const char* const command, gchar** arg
gboolean cmd_vcard_refresh(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_vcard_set(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_vcard_save(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_force_encryption(ProfWin* window, const char* const command, gchar** args);
#endif

View File

@@ -45,6 +45,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <curl/curl.h>
#include <curl/easy.h>
@@ -199,6 +200,10 @@ load_custom_keyfile(prof_keyfile_t* keyfile, gchar* filename)
if (g_file_test(keyfile->filename, G_FILE_TEST_EXISTS)) {
g_chmod(keyfile->filename, S_IRUSR | S_IWUSR);
} else {
int fno = g_creat(keyfile->filename, S_IRUSR | S_IWUSR);
if (fno != -1)
g_close(fno, NULL);
}
return _load_keyfile(keyfile);
@@ -387,7 +392,7 @@ release_get_latest(void)
curl_easy_setopt(handle, CURLOPT_URL, url);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, _data_callback);
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 2);
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 2L);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void*)&output);
curl_easy_perform(handle);

View File

@@ -171,6 +171,8 @@ typedef enum {
RESOURCE_XA
} resource_presence_t;
extern gboolean background_mode;
gboolean string_to_verbosity(const char* cmd, int* verbosity, gchar** err_msg);
gboolean create_dir(const char* name);

View File

@@ -1792,6 +1792,8 @@ _get_group(preference_t pref)
case PREF_OUTGOING_STAMP:
case PREF_INCOMING_STAMP:
case PREF_MOOD:
case PREF_FORCE_ENCRYPTION:
case PREF_FORCE_ENCRYPTION_MODE:
return PREF_GROUP_UI;
case PREF_STATES:
case PREF_OUTTYPE:
@@ -2150,6 +2152,10 @@ _get_key(preference_t pref)
return "strophe.sm.enabled";
case PREF_STROPHE_SM_RESEND:
return "strophe.sm.resend";
case PREF_FORCE_ENCRYPTION:
return "force-encryption.enabled";
case PREF_FORCE_ENCRYPTION_MODE:
return "force-encryption.policy";
default:
return NULL;
}
@@ -2204,6 +2210,7 @@ _get_default_boolean(preference_t pref)
case PREF_STROPHE_SM_RESEND:
return TRUE;
case PREF_PGP_PUBKEY_AUTOIMPORT:
case PREF_FORCE_ENCRYPTION:
default:
return FALSE;
}
@@ -2310,6 +2317,8 @@ _get_default_string(preference_t pref)
return "0";
case PREF_DBLOG:
return "on";
case PREF_FORCE_ENCRYPTION_MODE:
return "resend-to-confirm";
default:
return NULL;
}

View File

@@ -187,6 +187,8 @@ typedef enum {
PREF_STROPHE_SM_RESEND,
PREF_VCARD_PHOTO_CMD,
PREF_STATUSBAR_TABMODE,
PREF_FORCE_ENCRYPTION,
PREF_FORCE_ENCRYPTION_MODE
} preference_t;
typedef struct prof_alias_t

View File

@@ -56,10 +56,9 @@
#include "config/preferences.h"
#include "config/color.h"
static GString* theme_loc;
static GKeyFile* theme;
static GHashTable* bold_items;
static GHashTable* defaults;
static GString* theme_loc = NULL;
static GKeyFile* theme = NULL;
static GHashTable* defaults = NULL;
static void _load_preferences(void);
static void _theme_list_dir(const gchar* const dir, GSList** result);
@@ -78,10 +77,6 @@ _theme_close(void)
g_string_free(theme_loc, TRUE);
theme_loc = NULL;
}
if (bold_items) {
g_hash_table_destroy(bold_items);
bold_items = NULL;
}
if (defaults) {
g_hash_table_destroy(defaults);
defaults = NULL;
@@ -91,6 +86,12 @@ _theme_close(void)
void
theme_init(const char* const theme_name)
{
if (defaults || theme_loc || theme) {
log_warning("theme_init(): Detected non-NULL state (theme=%p, theme_loc=%p, defaults=%p). Cleaning up previous initialization.",
theme, theme_loc, defaults);
_theme_close();
}
if (!_theme_load_file(theme_name)) {
log_error("Loading theme %s failed.", theme_name);

View File

@@ -222,6 +222,7 @@ out:
void
log_database_close(void)
{
log_debug("log_database_close() called");
if (g_chatlog_database) {
sqlite3_close(g_chatlog_database);
sqlite3_shutdown();
@@ -318,19 +319,25 @@ log_database_get_limits_info(const gchar* const contact_barejid, gboolean is_las
// Query previous chats, constraints start_time and end_time. If end_time is
// null the current time is used. from_start gets first few messages if true
// otherwise the last ones. Flip flips the order of the results
GSList*
log_database_get_previous_chat(const gchar* const contact_barejid, const char* start_time, char* end_time, gboolean from_start, gboolean flip)
db_history_result_t
log_database_get_previous_chat(const gchar* const contact_barejid, const gchar* start_time, const gchar* end_time, gboolean from_start, gboolean flip, GSList** result)
{
if (!g_chatlog_database) {
log_warning("log_database_get_previous_chat() called but db is not initialized");
return DB_RESPONSE_ERROR;
}
sqlite3_stmt* stmt = NULL;
const Jid* myjid = connection_get_jid();
if (!myjid->str)
return NULL;
if (!myjid->str) {
log_warning("log_database_get_previous_chat() called but no connection detected.");
return DB_RESPONSE_ERROR;
}
// Flip order when querying older pages
gchar* sort1 = from_start ? "ASC" : "DESC";
gchar* sort2 = !flip ? "ASC" : "DESC";
GDateTime* now = g_date_time_new_now_local();
auto_gchar gchar* end_date_fmt = end_time ? end_time : g_date_time_format_iso8601(now);
auto_gchar gchar* end_date_fmt = end_time ? g_strdup(end_time) : g_date_time_format_iso8601(now);
auto_sqlite gchar* query = sqlite3_mprintf("SELECT * FROM ("
"SELECT COALESCE(B.`message`, A.`message`) AS message, "
"A.`timestamp`, A.`from_jid`, A.`from_resource`, A.`to_jid`, A.`to_resource`, A.`type`, A.`encryption`, A.`stanza_id` FROM `ChatLogs` AS A "
@@ -346,18 +353,16 @@ log_database_get_previous_chat(const gchar* const contact_barejid, const char* s
g_date_time_unref(now);
if (!query) {
log_error("Could not allocate memory");
return NULL;
log_error("Could not allocate memory.");
return DB_RESPONSE_ERROR;
}
int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL);
if (rc != SQLITE_OK) {
log_error("SQLite error in log_database_get_previous_chat(): %s", sqlite3_errmsg(g_chatlog_database));
return NULL;
log_error("SQLite error in log_database_get_previous_chat(): (error code: %d) %s", rc, sqlite3_errmsg(g_chatlog_database));
return DB_RESPONSE_ERROR;
}
GSList* history = NULL;
while (sqlite3_step(stmt) == SQLITE_ROW) {
char* message = (char*)sqlite3_column_text(stmt, 0);
char* date = (char*)sqlite3_column_text(stmt, 1);
@@ -378,11 +383,11 @@ log_database_get_previous_chat(const gchar* const contact_barejid, const char* s
msg->type = _get_message_type_type(type);
msg->enc = _get_message_enc_type(encryption);
history = g_slist_append(history, msg);
*result = g_slist_append(*result, msg);
}
sqlite3_finalize(stmt);
return history;
return g_slist_length(*result) != 0 ? DB_RESPONSE_SUCCESS : DB_RESPONSE_EMPTY;
}
static const char*

View File

@@ -40,14 +40,20 @@
#include "config/account.h"
#include "xmpp/xmpp.h"
#define MESSAGES_TO_RETRIEVE 10
#define MESSAGES_TO_RETRIEVE 100
typedef enum {
DB_RESPONSE_ERROR,
DB_RESPONSE_EMPTY,
DB_RESPONSE_SUCCESS
} db_history_result_t;
gboolean log_database_init(ProfAccount* account);
void log_database_add_incoming(ProfMessage* message);
void log_database_add_outgoing_chat(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
void log_database_add_outgoing_muc(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
void log_database_add_outgoing_muc_pm(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
GSList* log_database_get_previous_chat(const gchar* const contact_barejid, const char* start_time, char* end_time, gboolean from_start, gboolean flip);
db_history_result_t log_database_get_previous_chat(const gchar* const contact_barejid, const gchar* start_time, const gchar* end_time, gboolean from_start, gboolean flip, GSList** result);
ProfMessage* log_database_get_limits_info(const gchar* const contact_barejid, gboolean is_last);
void log_database_close(void);

View File

@@ -42,9 +42,11 @@
#include "log.h"
#include "chatlog.h"
#include "database.h"
#include "client_events.h"
#include "config/preferences.h"
#include "event/common.h"
#include "plugins/plugins.h"
#include "ui/inputwin.h"
#include "ui/window_list.h"
#include "xmpp/chat_session.h"
#include "xmpp/session.h"
@@ -177,7 +179,7 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
#ifdef HAVE_LIBOTR
handled = otr_on_message_send(chatwin, message, request_receipt, replace_id);
#endif
if (!handled) {
if (!handled && allow_unencrypted_message(chatwin, message)) {
auto_char char* id = message_send_chat(chatwin->barejid, message, oob_url, request_receipt, replace_id);
chat_log_msg_out(chatwin->barejid, message, NULL);
log_database_add_outgoing_chat(id, chatwin->barejid, message, replace_id, PROF_MSG_ENC_NONE);
@@ -251,3 +253,34 @@ cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char*
plugins_post_priv_message_send(privwin->fulljid, message);
}
}
gboolean
allow_unencrypted_message(ProfChatWin* chatwin, const char* const msg)
{
if (!prefs_get_boolean(PREF_FORCE_ENCRYPTION)) {
return TRUE; // Encryption not enforced
}
auto_gchar gchar* force_enc_mode = prefs_get_string(PREF_FORCE_ENCRYPTION_MODE);
if (g_strcmp0(force_enc_mode, "block") == 0) {
win_println((ProfWin*)chatwin, THEME_ERROR, "-", "Message not sent: encryption required. Enable (omemo/pgp/otr) encryption or /force-encryption off.");
return FALSE;
}
if (g_strcmp0(force_enc_mode, "resend-to-confirm") == 0) {
// We do not use chatwin->last_message because it should be set only if it's sent.
guint msg_hash = g_str_hash(msg);
if (msg_hash == chatwin->last_attempted_msg_hash) {
chatwin->last_attempted_msg_hash = 0; // reset hash
return TRUE;
}
win_println((ProfWin*)chatwin, THEME_ERROR, "-", "Message not sent: encryption required. Enable (omemo/pgp/otr) encryption or press Enter again to send without encryption. Use /force-encryption off to disable this protection.");
chatwin->last_attempted_msg_hash = msg_hash;
inp_set_line(msg); // reset message to prevent the need to retype it
return FALSE;
}
win_println((ProfWin*)chatwin, THEME_ERROR, "-", "Message not sent: invalid encryption mode (%s). Use '/force-encryption policy resend-to-confirm'.", force_enc_mode);
return FALSE;
}

View File

@@ -52,4 +52,8 @@ void cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, con
void cl_ev_send_muc_msg(ProfMucWin* mucwin, const char* const msg, const char* const oob_url);
void cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char* const oob_url);
// Checks if an unencrypted message can be sent based on encryption preferences.
// Returns TRUE if allowed, FALSE if blocked.
gboolean allow_unencrypted_message(ProfChatWin* chatwin, const char* const msg);
#endif

View File

@@ -156,14 +156,7 @@ sv_ev_roster_received(void)
if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) {
cons_show_error("Invalid PGP key ID specified: %s, %s", account->pgp_keyid, err_str);
}
// Redraw the screen after entry of the PGP secret key, but not init
ProfWin* win = wins_get_current();
auto_gchar gchar* theme = prefs_get_string(PREF_THEME);
win_redraw(win);
theme_init(theme);
ui_resize();
ui_show_roster();
}
account_free(account);
#endif

View File

@@ -664,7 +664,8 @@ p_gpg_decrypt(const char* const cipher)
}
gpgme_key_unref(key);
} else if (error) {
log_warning("GPGME error: %s", gpgme_strerror(error));
// Emails are used only to fetch PGP recipients for debug logging. If something went wrong here, it's not worthy of warning.
log_debug("GPGME error on gpgme_get_key(): %s", gpgme_strerror(error));
}
if (recipient->next) {

View File

@@ -86,10 +86,16 @@ python_get_version_number(void)
return version_number;
}
static void
_unref_module(PyObject* module)
{
Py_XDECREF(module);
}
void
python_env_init(void)
{
loaded_modules = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)Py_XDECREF);
loaded_modules = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_unref_module);
python_init_prof();
@@ -900,6 +906,8 @@ _python_type_error(ProfPlugin* plugin, char* hook, char* type)
g_string_free(err_msg, TRUE);
}
// Converts a Python string or None result to a C string and decreases the Python object's reference count.
// If the result is NULL, or not a string/unicode/bytes/None, logs an error and returns NULL.
static char*
_handle_string_or_none_result(ProfPlugin* plugin, PyObject* result, char* hook)
{
@@ -910,18 +918,16 @@ _handle_string_or_none_result(ProfPlugin* plugin, PyObject* result, char* hook)
}
#ifdef PY_IS_PYTHON3
if (result != Py_None && !PyUnicode_Check(result) && !PyBytes_Check(result)) {
allow_python_threads();
_python_type_error(plugin, hook, "string, unicode or None");
return NULL;
}
#else
if (result != Py_None && !PyUnicode_Check(result) && !PyString_Check(result)) {
#endif
Py_XDECREF(result);
allow_python_threads();
_python_type_error(plugin, hook, "string, unicode or None");
return NULL;
}
#endif
char* result_str = python_str_or_unicode_to_string(result);
Py_XDECREF(result);
allow_python_threads();
return result_str;
}

View File

@@ -59,6 +59,7 @@
#include "config/tlscerts.h"
#include "config/scripts.h"
#include "command/cmd_defs.h"
#include "tools/editor.h"
#include "plugins/plugins.h"
#include "event/client_events.h"
#include "ui/ui.h"
@@ -93,6 +94,9 @@ static void _connect_default(const char* const account);
pthread_mutex_t lock;
static gboolean force_quit = FALSE;
// main.c (prof_run section)
gboolean background_mode = FALSE;
void
prof_run(gchar* log_level, gchar* account_name, gchar* config_file, gchar* log_file, gchar* theme_name, gchar** commands)
{
@@ -118,42 +122,44 @@ prof_run(gchar* log_level, gchar* account_name, gchar* config_file, gchar* log_f
log_stderr_handler();
session_check_autoaway();
line = commands ? *commands : inp_readline();
if (commands && line && memcmp(line, "/sleep", 6) == 0) {
if (!g_timer_is_active(waittimer)) {
gchar* err_msg;
if (strtoi_range(line + 7, &waittime, 0, 300, &err_msg)) {
g_timer_start(waittimer);
/* Increase the minimal runtime by the waiting time
* so we can be sure there's runtime left after executing
* the last command.
*/
min_runtime += waittime;
} else {
log_error(err_msg);
g_free(err_msg);
commands = NULL;
if (!background_mode) {
line = commands ? *commands : inp_readline();
if (commands && line && memcmp(line, "/sleep", 6) == 0) {
if (!g_timer_is_active(waittimer)) {
gchar* err_msg;
if (strtoi_range(line + 7, &waittime, 0, 300, &err_msg)) {
g_timer_start(waittimer);
/* Increase the minimal runtime by the waiting time
* so we can be sure there's runtime left after executing
* the last command.
*/
min_runtime += waittime;
} else {
log_error(err_msg);
g_free(err_msg);
commands = NULL;
}
} else if (g_timer_elapsed(waittimer, NULL) >= waittime) {
g_timer_stop(waittimer);
commands++;
if (!(*commands))
commands = NULL;
}
cont = TRUE;
} else if (line) {
ProfWin* window = wins_get_current();
cont = cmd_process_input(window, line);
if (commands) {
commands++;
if (!(*commands))
commands = NULL;
} else {
free(line);
line = NULL;
}
} else if (g_timer_elapsed(waittimer, NULL) >= waittime) {
g_timer_stop(waittimer);
commands++;
if (!(*commands))
commands = NULL;
}
cont = TRUE;
} else if (line) {
ProfWin* window = wins_get_current();
cont = cmd_process_input(window, line);
if (commands) {
commands++;
if (!(*commands))
commands = NULL;
} else {
free(line);
line = NULL;
cont = TRUE;
}
} else {
cont = TRUE;
}
#ifdef HAVE_LIBOTR
@@ -163,7 +169,12 @@ prof_run(gchar* log_level, gchar* account_name, gchar* config_file, gchar* log_f
notify_remind();
session_process_events();
iq_autoping_check();
ui_update();
editor_process(wins_get_current());
if (!background_mode) {
ui_update();
}
#ifdef HAVE_GTK
tray_update();
#endif

View File

@@ -140,6 +140,9 @@ aesgcm_file_get(void* userdata)
"Downloading '%s' failed: Failed to decrypt "
"file (%s).",
https_url, gcry_strerror(crypt_res));
} else {
http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->id,
"Decrypted file saved to '%s'", aesgcm_dl->filename);
}
if (aesgcm_dl->cmd_template != NULL) {

View File

@@ -38,15 +38,200 @@
#include <fcntl.h>
#include <glib.h>
#include <errno.h>
#include <stdio.h> // necessary for readline
#include <readline/readline.h>
#include <sys/wait.h>
#include <unistd.h>
#include <pthread.h>
#include "config/files.h"
#include "config/preferences.h"
#include "editor.h"
#include "log.h"
#include "common.h"
#include "ncurses.h"
#include "ui/ui.h"
#include "xmpp/xmpp.h"
EditorTask editor_task = { 0, FALSE, NULL, NULL, PTHREAD_MUTEX_INITIALIZER, 0, NULL, NULL };
void*
editor_thread(void* arg)
{
EditorTask* task = (EditorTask*)arg;
auto_gcharv gchar** argv = g_strsplit(task->editor_cmd, " ", 0);
pid_t pid = fork();
if (pid == 0) {
execvp(argv[0], argv);
log_error("[Editor] Failed to exec %s", argv[0]);
_exit(EXIT_FAILURE);
}
pthread_mutex_lock(&task->mutex);
if (pid > 0) {
task->pid = pid;
int status;
// Unlock mutex to avoid deadlock on the main loop
pthread_mutex_unlock(&task->mutex);
waitpid(pid, &status, 0);
pthread_mutex_lock(&task->mutex);
gsize length;
if (!g_file_get_contents(task->filename, &task->result, &length, &task->error)) {
log_error("[Editor] could not read from %s: %s", task->filename,
task->error ? task->error->message : "No GLib error given");
task->result = g_strdup(""); // Ensure valid result
} else {
g_strchomp(task->result);
if (remove(task->filename) != 0) {
log_error("[Editor] error during file deletion of %s", task->filename);
} else {
log_debug("[Editor] deleted file: %s", task->filename);
}
}
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
task->error = g_error_new(G_FILE_ERROR, G_FILE_ERROR_FAILED,
"Editor process failed with status %d", WEXITSTATUS(status));
}
} else {
task->error = g_error_new(G_FILE_ERROR, G_FILE_ERROR_FAILED, "Fork failed: %s", strerror(errno));
task->result = g_strdup(""); // Ensure valid result
}
task->active = FALSE;
pthread_mutex_unlock(&task->mutex);
return NULL;
}
// Returns true if an error occurred
gboolean
get_message_from_editor_async(gchar* message)
{
// Check if editor is already running
pthread_mutex_lock(&editor_task.mutex);
if (editor_task.active) {
pthread_mutex_unlock(&editor_task.mutex);
log_error("[Editor] Editor already running");
return TRUE;
}
pthread_mutex_unlock(&editor_task.mutex);
// Create temporary file
auto_gchar gchar* filename = NULL;
GError* glib_error = NULL;
const char* jid = connection_get_barejid();
if (jid) {
filename = files_file_in_account_data_path(DIR_EDITOR, jid, "compose.md");
} else {
log_debug("[Editor] could not get JID");
auto_gchar gchar* data_dir = files_get_data_path(DIR_EDITOR);
if (!create_dir(data_dir)) {
log_error("[Editor] could not create directory %s", data_dir);
return TRUE;
}
filename = g_strdup_printf("%s/compose.md", data_dir);
}
if (!filename) {
log_error("[Editor] something went wrong while creating compose file");
return TRUE;
}
// Write message to file
gsize messagelen = message ? strlen(message) : 0;
if (!g_file_set_contents(filename, message ? message : "", messagelen, &glib_error)) {
log_error("[Editor] could not write to %s: %s", filename,
glib_error ? glib_error->message : "No GLib error given");
if (glib_error) {
g_error_free(glib_error);
}
return TRUE;
}
// Prepare editor command
auto_gchar gchar* editor = prefs_get_string(PREF_COMPOSE_EDITOR);
auto_gchar gchar* editor_with_filename = g_strdup_printf("%s %s", editor, filename);
// Suspend NCurses
def_prog_mode();
endwin();
// Initialize thread task
pthread_mutex_lock(&editor_task.mutex);
editor_task.active = TRUE;
editor_task.result = NULL;
editor_task.error = NULL;
g_free(editor_task.filename);
g_free(editor_task.editor_cmd);
editor_task.filename = g_strdup(filename);
editor_task.editor_cmd = g_strdup(editor_with_filename);
pthread_mutex_unlock(&editor_task.mutex);
// Set background mode
background_mode = TRUE;
log_debug("[Editor] Entering background mode");
// Start editor thread
if (pthread_create(&editor_task.thread, NULL, editor_thread, &editor_task) != 0) {
pthread_mutex_lock(&editor_task.mutex);
editor_task.active = FALSE;
editor_task.error = g_error_new(G_FILE_ERROR, G_FILE_ERROR_FAILED,
"Failed to create editor thread: %s", strerror(errno));
g_free(editor_task.filename);
g_free(editor_task.editor_cmd);
editor_task.filename = NULL;
editor_task.editor_cmd = NULL;
pthread_mutex_unlock(&editor_task.mutex);
background_mode = FALSE;
log_debug("[Editor] Exiting background mode");
reset_prog_mode();
doupdate();
log_error("[Editor] Failed to create editor thread");
return TRUE;
}
return FALSE;
}
void
editor_process(ProfWin* window)
{
pthread_mutex_lock(&editor_task.mutex);
if (editor_task.active) {
pthread_mutex_unlock(&editor_task.mutex);
return;
}
if (!editor_task.result) {
pthread_mutex_unlock(&editor_task.mutex);
return;
}
g_strchomp(editor_task.result);
rl_replace_line(editor_task.result, 0);
rl_point = rl_end;
rl_forced_update_display();
reset_prog_mode();
doupdate();
ui_resize();
g_free(editor_task.result);
g_free(editor_task.filename);
g_free(editor_task.editor_cmd);
editor_task.result = NULL;
editor_task.filename = NULL;
editor_task.editor_cmd = NULL;
if (editor_task.error) {
log_error("[Editor] %s", editor_task.error->message);
g_error_free(editor_task.error);
editor_task.error = NULL;
}
pthread_mutex_unlock(&editor_task.mutex);
background_mode = FALSE;
log_debug("[Editor] Exiting background mode");
}
// Deprecated synchronous editor call. Returns a message as returned_message.
// Please avoid using it, since it blocks execution of the message handling and other important functionality until the editor is closed.
// Returns true if an error occurred
gboolean
get_message_from_editor(gchar* message, gchar** returned_message)

View File

@@ -37,8 +37,24 @@
#ifndef TOOLS_EDITOR_H
#define TOOLS_EDITOR_H
#include "ui/win_types.h"
#include <glib.h>
typedef struct
{
pid_t pid; // Editor process PID
gboolean active; // Thread running
gchar* result; // Edited message
GError* error; // Error if any
pthread_mutex_t mutex; // Protect access
pthread_t thread; // Editor thread
gchar* filename; // Temporary file path
gchar* editor_cmd; // Editor command with filename
} EditorTask;
extern EditorTask editor_task;
gboolean get_message_from_editor(gchar* message, gchar** returned_message);
gboolean get_message_from_editor_async(gchar* message);
void editor_process(ProfWin* window);
#endif

View File

@@ -1,40 +1,36 @@
/*
* buffer.c
* vim: expandtab:ts=4:sts=4:sw=4
*
* Message buffer implementation for CProof.
*
* This module provides an in-memory buffer for managing active chat entries in the
* console-based XMPP client. Separate from persistent SQLite storage, it holds
* messages and metadata solely for UI rendering, ensuring responsive scrolling and
* display without exceeding ncurses pad limits (10k lines). By tracking rendered
* line counts per entry, it proactively trims content to prevent overflow, enabling
* seamless integration with ncurses for position-aware rendering.
*
* Key features and operations:
* - Append/prepend entries (messages) with automatic line-based cleanup.
* - Track cumulative lines for overflow prevention and efficient buffer sizing.
* - Remove entries by ID or index; mark delivery receipts as received.
* - Retrieve entries by index or ID for rendering and history queries.
* - Store metadata including timestamps, senders, themes, and ncurses y-positions.
*
* CProof. Fork of Profanity (since 2025).
*
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
* Copyright (C) 2019 - 2025 Michael Vetter <jubalh@iodoru.org>
* Copyright (C) 2025 CProof Developers
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give permission to
* link the code of portions of this program with the OpenSSL library under
* certain conditions as described in each individual source file, and
* distribute linked combinations including the two.
*
* You must obey the GNU General Public License in all respects for all of the
* code used other than OpenSSL. If you modify file(s) with this exception, you
* may extend this exception to your version of the file(s), but you are not
* obligated to do so. If you do not wish to do so, delete this exception
* statement from your version. If you delete this exception statement from all
* source files in the program, then also delete it here.
* Licensed under the GNU General Public License, version 3,
* with the OpenSSL exception. See LICENSE for details.
*
* vim: expandtab:ts=4:sts=4:sw=4
*/
#include "config.h"
#include "ui/window_list.h"
#include <stdlib.h>
#include <string.h>
@@ -54,15 +50,8 @@
#include "ui/window.h"
#include "ui/buffer.h"
#define MAX_BUFFER_SIZE 200
#define STRDUP_OR_NULL(str) ((str) ? strdup(str) : NULL)
struct prof_buff_t
{
GSList* entries;
int lines;
};
static void _free_entry(ProfBuffEntry* entry);
static ProfBuffEntry* _create_entry(const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message, DeliveryReceipt* receipt, const char* const id, int y_start_pos, int y_end_pos);
static void _buffer_add(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message, DeliveryReceipt* receipt, const char* const id, int y_start_pos, int y_end_pos, gboolean append);
@@ -108,16 +97,24 @@ _buffer_add(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* t
buffer->lines += e->_lines;
while (g_slist_length(buffer->entries) >= MAX_BUFFER_SIZE) {
// With 10% margin to ensure overflow prevention
while (buffer->lines >= PAD_SIZE - (PAD_SIZE / 10) && g_slist_length(buffer->entries) > 1) {
// Delete message from the opposite size to free buffer
GSList* buffer_entry_to_delete = append ? buffer->entries : g_slist_last(buffer->entries);
ProfBuffEntry* entry_to_delete = (ProfBuffEntry*)buffer_entry_to_delete->data;
// log_debug("(Messages left in buffer: %d) DELETING: %s", g_slist_length(buffer->entries), entry_to_delete->id);
buffer->lines -= entry_to_delete->_lines;
_free_entry(entry_to_delete);
buffer->entries = g_slist_delete_link(buffer->entries, buffer_entry_to_delete);
}
if (from_jid && y_end_pos == y_start_pos) {
log_warning("Ncurses Overflow! From: %s, pos: %d, ID: %s, message: %s", from_jid, y_end_pos, id, message);
// win_redraw will redraw with entries above removed,
// it will also recalculate actual size of the message that caused overflow
int old_lines = buffer->lines;
win_redraw(wins_get_current());
log_debug("Ncurses Overflow! From: %s, position: %d, ID: %s, append: %s, used message buffer size: %d, rendered lines: (old: %d/ actual: %d/ max: %d)",
from_jid, y_start_pos, id, append ? "TRUE" : "FALSE", g_slist_length(buffer->entries), old_lines, buffer->lines, PAD_SIZE);
}
buffer->entries = append ? g_slist_append(buffer->entries, e) : g_slist_prepend(buffer->entries, e);

View File

@@ -68,6 +68,12 @@ typedef struct prof_buff_entry_t
char* id;
} ProfBuffEntry;
struct prof_buff_t
{
GSList* entries;
int lines;
};
typedef struct prof_buff_t* ProfBuff;
ProfBuff buffer_create();

View File

@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <assert.h>
#include "glib.h"
#include "xmpp/chat_session.h"
#include "window_list.h"
#include "xmpp/roster_list.h"
@@ -423,9 +424,11 @@ chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, const char
win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, display_message);
}
// save last id and message for LMC in case if it's not LMC message
if (id && !replace_id) {
_chatwin_set_last_message(chatwin, id, display_message);
// Save last id and message for LMC
// Note: if the same message is to be corrected several times, the id of the original message is used in each case
// https://xmpp.org/extensions/xep-0308.html#rules
if (id) {
_chatwin_set_last_message(chatwin, replace_id ?: id, display_message);
}
}
@@ -561,7 +564,8 @@ static void
_chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid)
{
if (!chatwin->history_shown) {
GSList* history = log_database_get_previous_chat(contact_barejid, NULL, NULL, FALSE, FALSE);
GSList* history = NULL;
log_database_get_previous_chat(contact_barejid, NULL, NULL, FALSE, FALSE, &history);
GSList* curr = history;
while (curr) {
@@ -583,15 +587,17 @@ _chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid)
// Print history starting from start_time to end_time if end_time is null the
// first entry's timestamp in the buffer is used. Flip true to prepend to buffer.
// Timestamps should be in iso8601
gboolean
chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time, gboolean flip)
db_history_result_t
chatwin_db_history(ProfChatWin* chatwin, const gchar* start_time, const gchar* end_time, gboolean flip)
{
if (!end_time) {
end_time = buffer_size(((ProfWin*)chatwin)->layout->buffer) == 0 ? NULL : g_date_time_format_iso8601(buffer_get_entry(((ProfWin*)chatwin)->layout->buffer, 0)->time);
auto_gchar gchar* _end_time = NULL;
if (!end_time && buffer_size(((ProfWin*)chatwin)->layout->buffer) > 0) {
_end_time = g_date_time_format_iso8601(buffer_get_entry(((ProfWin*)chatwin)->layout->buffer, 0)->time);
end_time = _end_time;
}
GSList* history = log_database_get_previous_chat(chatwin->barejid, start_time, end_time, !flip, flip);
gboolean has_items = g_slist_length(history) != 0;
GSList* history = NULL;
db_history_result_t result = log_database_get_previous_chat(chatwin->barejid, start_time, end_time, !flip, flip, &history);
GSList* curr = history;
while (curr) {
@@ -610,17 +616,24 @@ chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time,
}
g_slist_free_full(history, (GDestroyNotify)message_free);
// TODO: Potential optimization
// if (flip)
// since adding messages to history without overflowing buffer does not require a win_redraw
win_redraw((ProfWin*)chatwin);
return has_items;
return result;
}
static void
_chatwin_set_last_message(ProfChatWin* chatwin, const char* const id, const char* const message)
{
free(chatwin->last_message);
chatwin->last_message = strdup(message);
if (message && chatwin->last_message != message) {
free(chatwin->last_message);
chatwin->last_message = strdup(message);
}
free(chatwin->last_msg_id);
chatwin->last_msg_id = strdup(id);
if (id && chatwin->last_msg_id != id) {
free(chatwin->last_msg_id);
chatwin->last_msg_id = strdup(id);
}
}

View File

@@ -387,16 +387,9 @@ cons_about(void)
_cons_splash_logo();
} else {
auto_gchar gchar* prof_version = prof_get_version();
win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %s", prof_version);
win_println(console, THEME_DEFAULT, "-", "Welcome to CProof, version %s", prof_version);
}
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.");
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2019 - 2025 Michael Vetter <jubalh@iodoru.org>.");
win_println(console, THEME_DEFAULT, "-", "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>");
win_println(console, THEME_DEFAULT, "-", "");
win_println(console, THEME_DEFAULT, "-", "This is free software; you are free to change and redistribute it.");
win_println(console, THEME_DEFAULT, "-", "There is NO WARRANTY, to the extent permitted by law.");
win_println(console, THEME_DEFAULT, "-", "");
win_println(console, THEME_DEFAULT, "-", "Type '/help' to show complete help.");
win_println(console, THEME_DEFAULT, "-", "");
@@ -484,7 +477,7 @@ cons_show_wins(gboolean unread)
}
curr = g_slist_next(curr);
}
g_slist_free_full(window_strings, free);
g_slist_free_full(window_strings, g_free);
cons_alert(NULL);
}
@@ -505,7 +498,7 @@ cons_show_wins_attention()
}
curr = g_slist_next(curr);
}
g_slist_free_full(window_strings, free);
g_slist_free_full(window_strings, g_free);
cons_alert(NULL);
}
@@ -2704,13 +2697,12 @@ _cons_splash_logo(void)
ProfWin* console = wins_get_console();
win_println(console, THEME_DEFAULT, "-", "Welcome to");
win_println(console, THEME_SPLASH, "-", " ___ _ ");
win_println(console, THEME_SPLASH, "-", " / __) (_)_ ");
win_println(console, THEME_SPLASH, "-", " ____ ___ ___ | |__ ____ ____ _| |_ _ _ ");
win_println(console, THEME_SPLASH, "-", "| _ \\ / __) _ \\| __) _ | _ \\| | _) | | |");
win_println(console, THEME_SPLASH, "-", "| | ) | | | (_) | | | ( | | | | | | |_| |_| |");
win_println(console, THEME_SPLASH, "-", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |");
win_println(console, THEME_SPLASH, "-", "|_| (____/ ");
win_println(console, THEME_SPLASH, "-", " _____ _____ __ ");
win_println(console, THEME_SPLASH, "-", " / ____| __ \\ / _|");
win_println(console, THEME_SPLASH, "-", " | | | |__) | __ ___ ___ | |_ ");
win_println(console, THEME_SPLASH, "-", " | | | ___/ '__/ _ \\ / _ \\| _|");
win_println(console, THEME_SPLASH, "-", " | |____| | | | | (_) | (_) | | ");
win_println(console, THEME_SPLASH, "-", " \\_____|_| |_| \\___/ \\___/|_| ");
win_println(console, THEME_SPLASH, "-", "");
auto_gchar gchar* prof_version = prof_get_version();
@@ -2899,3 +2891,11 @@ cons_privacy_setting(void)
}
}
}
void
cons_encryption_setting(void)
{
cons_show("Force encryption : %sabled", prefs_get_boolean(PREF_FORCE_ENCRYPTION) ? "en" : "dis");
cons_show("Force encryption mode : %s", prefs_get_string(PREF_FORCE_ENCRYPTION_MODE));
}

View File

@@ -170,6 +170,29 @@ create_input_window(void)
_inp_win_update_virtual();
}
static gboolean
_inp_slashguard_check(void)
{
if (get_password)
return false;
/* ignore empty and quoted messages */
if (inp_line == NULL || inp_line[0] == '\0' || inp_line[0] == '>')
return false;
if (!prefs_get_boolean(PREF_SLASH_GUARD))
return false;
size_t n = 1;
while (inp_line[n] != '\0' && n < 4) {
if (inp_line[n] == '/') {
cons_show("Your text contains a slash in the first 4 characters");
free(inp_line);
inp_line = NULL;
return true;
}
n++;
}
return false;
}
char*
inp_readline(void)
{
@@ -203,17 +226,7 @@ inp_readline(void)
chat_state_idle();
}
if (inp_line) {
if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) {
// ignore quoted messages
if (strlen(inp_line) > 1 && inp_line[0] != '>') {
char* res = (char*)memchr(inp_line + 1, '/', 3);
if (res) {
cons_show("Your text contains a slash in the first 4 characters");
return NULL;
}
}
}
if (inp_line && !_inp_slashguard_check()) {
char* ret = inp_line;
inp_line = NULL;
return ret;
@@ -294,6 +307,14 @@ inp_get_line(void)
return line;
}
void
inp_set_line(const char* const new_line)
{
rl_replace_line(new_line, 1);
rl_point = rl_end;
_inp_redisplay();
}
char*
inp_get_password(void)
{
@@ -974,14 +995,7 @@ _inp_rl_send_to_editor(int count, int key)
auto_gchar gchar* message = NULL;
if (get_message_from_editor(rl_line_buffer, &message)) {
return 0;
}
rl_replace_line(message, 0);
ui_resize();
rl_point = rl_end;
rl_forced_update_display();
get_message_from_editor_async(rl_line_buffer);
return 0;
}

View File

@@ -46,5 +46,6 @@ void inp_win_resize(void);
void inp_put_back(void);
char* inp_get_password(void);
char* inp_get_line(void);
void inp_set_line(const char* const new_line);
#endif

View File

@@ -43,6 +43,7 @@
#include "config/account.h"
#include "config/preferences.h"
#include "command/cmd_funcs.h"
#include "database.h"
#include "ui/win_types.h"
#include "xmpp/message.h"
#include "xmpp/muc.h"
@@ -145,7 +146,7 @@ void chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch);
void chatwin_unset_incoming_char(ProfChatWin* chatwin);
void chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch);
void chatwin_unset_outgoing_char(ProfChatWin* chatwin);
gboolean chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time, gboolean flip);
db_history_result_t chatwin_db_history(ProfChatWin* chatwin, const gchar* start_time, const gchar* end_time, gboolean flip);
// MUC window
ProfMucWin* mucwin_new(const char* const barejid);
@@ -288,7 +289,7 @@ void cons_show_disco_info(const char* from, GSList* identities, GSList* features
void cons_show_disco_contact_information(GHashTable* addresses);
void cons_show_qrcode();
void cons_show_qrcode(const char* const text);
void cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason);
void cons_check_version(gboolean not_available_msg);
@@ -350,6 +351,7 @@ void cons_theme_properties(void);
void cons_theme_colours(void);
void cons_show_tlscert(const TLSCertificate* cert);
void cons_show_tlscert_summary(const TLSCertificate* cert);
void cons_encryption_setting(void);
void cons_alert(ProfWin* alert_origin_window);
void cons_remove_alert(ProfWin* window);

View File

@@ -188,6 +188,7 @@ typedef struct prof_chat_win_t
char* last_message;
char* last_msg_id;
gboolean has_attention;
guint last_attempted_msg_hash;
} ProfChatWin;
typedef struct prof_muc_win_t

View File

@@ -35,6 +35,7 @@
*/
#include "config.h"
#include "database.h"
#include "ui/window_list.h"
#include <stdlib.h>
@@ -62,9 +63,8 @@
#include "xmpp/xmpp.h"
#include "xmpp/roster_list.h"
static const int PAD_SIZE = 100;
static const char* LOADING_MESSAGE = "Loading older messages…";
static const char* CONS_WIN_TITLE = "Profanity. Type /help for help information.";
static const char* CONS_WIN_TITLE = "CProof. Type /help for help information.";
static const char* XML_WIN_TITLE = "XML Console";
#define CEILING(X) (X - (int)(X) > 0 ? (int)(X + 1) : (int)(X))
@@ -164,6 +164,7 @@ win_create_chat(const char* const barejid)
new_win->last_message = NULL;
new_win->last_msg_id = NULL;
new_win->has_attention = FALSE;
new_win->last_attempted_msg_hash = 0;
new_win->memcheck = PROFCHATWIN_MEMCHECK;
return &new_win->window;
@@ -629,54 +630,68 @@ win_free(ProfWin* window)
void
win_page_up(ProfWin* window, int scroll_size)
{
// Page offset from the start of the NCurses PAD (invisible window)
int* page_start = &(window->layout->y_pos);
int page_start_initial = *page_start;
int total_rows = getcury(window->layout->win);
// Size of the visible chat page
int page_space = getmaxy(stdscr) - 4;
if (scroll_size == 0)
scroll_size = page_space;
win_scroll_state_t* scroll_state = &window->scroll_state;
*scroll_state = (*scroll_state == WIN_SCROLL_REACHED_BOTTOM) ? WIN_SCROLL_INNER : *scroll_state;
*page_start -= scroll_size;
gboolean has_scroll_past_buffer = *page_start < 0;
if (*page_start == -scroll_size && window->type == WIN_CHAT) {
if (has_scroll_past_buffer && window->type == WIN_CHAT) {
ProfChatWin* chatwin = (ProfChatWin*)window;
ProfBuffEntry* first_entry = buffer_size(window->layout->buffer) != 0 ? buffer_get_entry(window->layout->buffer, 0) : NULL;
// Don't do anything if still fetching mam messages
if (first_entry && !(first_entry->theme_item == THEME_ROOMINFO && g_strcmp0(first_entry->message, LOADING_MESSAGE) == 0)) {
gboolean is_still_fetching_mam = first_entry && (first_entry->theme_item == THEME_ROOMINFO && g_strcmp0(first_entry->message, LOADING_MESSAGE) == 0);
if (!is_still_fetching_mam) {
// WIN_SCROLL_REACHED_TOP means that we reached top of DB and there is no need to refetch data from it
gboolean is_db_offset_jump_needed = false;
if (*scroll_state != WIN_SCROLL_REACHED_TOP) {
*scroll_state = !chatwin_db_history(chatwin, NULL, NULL, TRUE) ? WIN_SCROLL_REACHED_TOP : WIN_SCROLL_INNER;
db_history_result_t db_response = chatwin_db_history(chatwin, NULL, NULL, TRUE);
is_db_offset_jump_needed = db_response == DB_RESPONSE_SUCCESS;
*scroll_state = db_response == DB_RESPONSE_EMPTY ? WIN_SCROLL_REACHED_TOP : WIN_SCROLL_INNER;
log_debug("Scroll state after DB history fetch: %s", *scroll_state ? "WIN_SCROLL_REACHED_TOP" : "WIN_SCROLL_INNER");
}
if (*scroll_state == WIN_SCROLL_REACHED_TOP && prefs_get_boolean(PREF_MAM)) {
win_print_loading_history(window);
iq_mam_request_older(chatwin);
if (*scroll_state == WIN_SCROLL_REACHED_TOP) {
*page_start = 0;
if (prefs_get_boolean(PREF_MAM)) {
win_print_loading_history(window);
iq_mam_request_older(chatwin);
}
}
int buff_size = buffer_size(window->layout->buffer);
int offset_entry_id = buff_size > 10 ? 10 : buff_size - 1;
int offset = buffer_get_entry(window->layout->buffer, offset_entry_id)->y_end_pos;
*page_start = offset - page_space;
// Recalculate scroll offset after loading older messages from the DB.
// *page_start may become negative due to paging up beyond the current buffer.
// To maintain smooth scroll positioning, we adjust it relative to the visual offset
// (y_start_pos) of the first buffer entry *before* DB fetch.
// This ensures a seamless transition as older messages are prepended, regardless
// of how many visual lines they occupy (since messages can vary in height).
// For example, if *page_start == -5 and first_entry->y_start_pos == 40,
// we shift the scroll to 35, preserving the visual context for the user.
if (is_db_offset_jump_needed) {
*page_start = first_entry ? first_entry->y_start_pos + *page_start : 0;
}
}
}
// went past beginning, show first page
if (*page_start < 0) {
log_debug("win_page_up(): *page_start adjusted to 0 due to negative value (expected if insufficient history messages). Previous value: %d", *page_start);
*page_start = 0;
}
window->layout->paged = 1;
// update only if position has changed
// Update window location only if position has changed
if (page_start_initial != *page_start) {
win_update_virtual(window);
}
// switch off page if last line and space line visible
if ((total_rows) - *page_start == page_space) {
window->layout->paged = 0;
}
// Update scrolling state
int total_rows = getcury(window->layout->win);
window->layout->paged = (total_rows) - *page_start > page_space;
}
void
@@ -696,20 +711,22 @@ win_page_down(ProfWin* window, int scroll_size)
// Scrolled down after reaching the bottom of the page
if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
int bf_size = buffer_size(window->layout->buffer);
if (bf_size > 0) {
if (bf_size > 0 && *scroll_state != WIN_SCROLL_REACHED_BOTTOM) {
// How many lines are left until end of the screen
int current_offset = total_rows - *page_start;
GDateTime* now = g_date_time_new_now_local();
ProfBuffEntry* last_entry = buffer_get_entry(window->layout->buffer, bf_size - 1);
auto_gchar gchar* start = g_date_time_format_iso8601(last_entry->time);
GDateTime* now = g_date_time_new_now_local();
gchar* end_date = g_date_time_format_iso8601(now);
g_date_time_unref(now);
if (*scroll_state != WIN_SCROLL_REACHED_BOTTOM && !chatwin_db_history((ProfChatWin*)window, start, end_date, FALSE)) {
auto_gchar gchar* end_date = g_date_time_format_iso8601(now);
db_history_result_t db_response = chatwin_db_history((ProfChatWin*)window, start, end_date, FALSE);
if (db_response == DB_RESPONSE_EMPTY)
*scroll_state = WIN_SCROLL_REACHED_BOTTOM;
} else if (*scroll_state == WIN_SCROLL_REACHED_BOTTOM) {
g_free(end_date);
}
int offset = last_entry->y_end_pos - 1;
*page_start = offset - page_space + scroll_size;
// similar to page_up (see explanation there)
// Get offset of the message that was the latest prior to loading messages from the DB
int original_pos = last_entry->y_end_pos;
*page_start = original_pos - current_offset;
g_date_time_unref(now);
}
}
@@ -1986,6 +2003,10 @@ win_redraw(ProfWin* window)
_win_print_internal(window, e->show_char, e->pad_indent, e->time, e->flags, e->theme_item, e->display_from, e->message, e->receipt);
}
e->y_end_pos = getcury(window->layout->win);
// Recalculate lines (might be incorrect in case of NCurses overflow)
window->layout->buffer->lines -= e->_lines;
e->_lines = e->y_end_pos - e->y_start_pos;
window->layout->buffer->lines += e->_lines;
}
}

View File

@@ -56,6 +56,9 @@
#include "xmpp/contact.h"
#include "xmpp/muc.h"
// Max lines per window rendered by NCurses
static const int PAD_SIZE = 10000;
void win_move_to_end(ProfWin* window);
void win_show_status_string(ProfWin* window, const char* const from,
const char* const show, const char* const status,

View File

@@ -258,22 +258,20 @@ GList*
wins_get_private_chats(const char* const roomjid)
{
GList* result = NULL;
GString* prefix = g_string_new(roomjid);
g_string_append(prefix, "/");
auto_gchar gchar* prefix = g_strdup_printf("%s/", roomjid);
GList* curr = values;
while (curr) {
ProfWin* window = curr->data;
if (window->type == WIN_PRIVATE) {
ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix->str)) {
if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix)) {
result = g_list_append(result, privatewin);
}
}
curr = g_list_next(curr);
}
g_string_free(prefix, TRUE);
return result;
}
@@ -1067,19 +1065,13 @@ wins_create_summary(gboolean unread)
while (curr) {
ProfWin* window = g_hash_table_lookup(windows, curr->data);
if (!unread || (unread && win_unread(window) > 0)) {
GString* line = g_string_new("");
int ui_index = GPOINTER_TO_INT(curr->data);
auto_gchar gchar* winstring = win_to_string(window);
if (!winstring) {
g_string_free(line, TRUE);
continue;
}
g_string_append_printf(line, "%d: %s", ui_index, winstring);
result = g_slist_append(result, strdup(line->str));
g_string_free(line, TRUE);
gchar* line = g_strdup_printf("%d: %s", ui_index, winstring);
result = g_slist_append(result, line);
}
curr = g_list_next(curr);
@@ -1108,19 +1100,13 @@ wins_create_summary_attention()
has_attention = mucwin->has_attention;
}
if (has_attention) {
GString* line = g_string_new("");
int ui_index = GPOINTER_TO_INT(curr->data);
auto_gchar gchar* winstring = win_to_string(window);
if (!winstring) {
g_string_free(line, TRUE);
continue;
}
g_string_append_printf(line, "%d: %s", ui_index, winstring);
result = g_slist_append(result, strdup(line->str));
g_string_free(line, TRUE);
gchar* line = g_strdup_printf("%d: %s", ui_index, winstring);
result = g_slist_append(result, line);
}
curr = g_list_next(curr);
}

View File

@@ -119,6 +119,14 @@ caps_init(void)
g_hash_table_add(prof_features, strdup(STANZA_NS_LAST_MESSAGE_CORRECTION));
}
if (prefs_get_boolean(PREF_MOOD)) {
g_hash_table_add(prof_features, strdup(STANZA_NS_MOOD_NOTIFY));
}
#ifdef HAVE_OMEMO
g_hash_table_add(prof_features, strdup(XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY));
#endif
my_sha1 = NULL;
}

View File

@@ -2752,6 +2752,22 @@ iq_mam_request(ProfChatWin* win, GDateTime* enddate)
return;
}
// Trim the last 3 characters from the datetime string to remove unwanted suffix (timezone offset)
static void
_truncate_datetime_suffix(gchar* str)
{
if (!str) {
log_warning("_truncate_datetime_suffix(): unexpected null datetime string");
return;
}
size_t len = strlen(str);
if (len >= 3) {
str[len - 3] = '\0';
} else {
log_warning("_truncate_datetime_suffix(): unexpected short datetime string: %s", str);
}
}
static int
_mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
{
@@ -2773,17 +2789,17 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
buffer_remove_entry(window->layout->buffer, 0);
auto_char char* start_str = NULL;
auto_gchar gchar* start_str = NULL;
if (data->start_datestr) {
start_str = strdup(data->start_datestr);
start_str = g_strdup(data->start_datestr);
// Convert to iso8601
start_str[strlen(start_str) - 3] = '\0';
_truncate_datetime_suffix(start_str);
}
char* end_str = NULL;
auto_gchar gchar* end_str = NULL;
if (data->end_datestr) {
end_str = strdup(data->end_datestr);
end_str = g_strdup(data->end_datestr);
// Convert to iso8601
end_str[strlen(end_str) - 3] = '\0';
_truncate_datetime_suffix(end_str);
}
if (is_complete || !data->fetch_next) {

View File

@@ -190,7 +190,7 @@ get_nick_from_full_jid(const char* const full_room_jid)
/*
* get the fulljid, fall back to the barejid
*/
char*
const char*
jid_fulljid_or_barejid(Jid* jid)
{
if (jid->fulljid) {

View File

@@ -63,7 +63,7 @@ gboolean jid_is_valid_room_form(Jid* jid);
char* create_fulljid(const char* const barejid, const char* const resource);
char* get_nick_from_full_jid(const char* const full_room_jid);
char* jid_fulljid_or_barejid(Jid* jid);
const char* jid_fulljid_or_barejid(Jid* jid);
gchar* jid_random_resource(void);
#endif

View File

@@ -621,7 +621,7 @@ _available_handler(xmpp_stanza_t* const stanza)
}
return;
} else {
char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
const char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
log_debug("Presence available handler fired for: %s", jid);
}
@@ -632,7 +632,7 @@ _available_handler(xmpp_stanza_t* const stanza)
XMPPCaps* caps = stanza_parse_caps(stanza);
if ((g_strcmp0(my_jid->fulljid, xmpp_presence->jid->fulljid) != 0) && caps) {
log_debug("Presence contains capabilities.");
char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
const char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
_handle_caps(jid, caps);
}
stanza_free_caps(caps);
@@ -644,7 +644,7 @@ _available_handler(xmpp_stanza_t* const stanza)
const char* account_name = session_get_account_name();
int max_sessions = accounts_get_max_sessions(account_name);
if (max_sessions > 0) {
const gchar* cur_resource = accounts_get_resource(account_name);
auto_gchar gchar* cur_resource = accounts_get_resource(account_name);
int res_count = connection_count_available_resources();
if (res_count > max_sessions && g_strcmp0(cur_resource, resource->name)) {
ProfWin* console = wins_get_console();

View File

@@ -275,11 +275,8 @@ roster_remove(const char* const name, const char* const barejid)
if (contact) {
GList* resources = p_contact_get_available_resources(contact);
while (resources) {
GString* fulljid = g_string_new(barejid);
g_string_append(fulljid, "/");
g_string_append(fulljid, resources->data);
autocomplete_remove(roster->fulljid_ac, fulljid->str);
g_string_free(fulljid, TRUE);
auto_gchar gchar* fulljid = g_strdup_printf("%s/%s", barejid, (char*)resources->data);
autocomplete_remove(roster->fulljid_ac, fulljid);
resources = g_list_next(resources);
}
g_list_free(resources);

View File

@@ -1,10 +1,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <sys/stat.h>
#include "config.h"

View File

@@ -2,11 +2,8 @@
#include <sys/wait.h>
#include <glib.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
@@ -27,6 +24,9 @@ message_send(void **state)
assert_true(prof_output_regex("me: .+Hi there"));
}
// TODO: `/message correct` XEP-0308 compliance (whether each correction links to the original message ID)
// https://xmpp.org/extensions/xep-0308.html#rules
void
message_receive_console(void **state)
{

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
@@ -281,7 +278,7 @@ shows_all_messages_in_console_when_window_not_focussed(void **state)
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
prof_input("/win 1");
assert_true(prof_output_exact("Profanity. Type /help for help information."));
assert_true(prof_output_exact("CProof. Type /help for help information."));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
@@ -322,7 +319,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
prof_input("/win 1");
assert_true(prof_output_exact("Profanity. Type /help for help information."));
assert_true(prof_output_exact("CProof. Type /help for help information."));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
@@ -368,7 +365,7 @@ shows_no_message_in_console_when_window_not_focussed(void **state)
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
prof_input("/win 1");
assert_true(prof_output_exact("Profanity. Type /help for help information."));
assert_true(prof_output_exact("CProof. Type /help for help information."));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

5
tests/prof_cmocka.h Normal file
View File

@@ -0,0 +1,5 @@
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>

View File

@@ -21,8 +21,7 @@
*/
#include <glib.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <xmpp/xmpp.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include "common.h"
#include "config/account.h"

View File

@@ -21,8 +21,7 @@
*/
#include <glib.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include "database.h"

View File

@@ -1,8 +1,5 @@
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <glib.h>
#include <stdio.h>
#include <unistd.h>

View File

@@ -21,8 +21,7 @@
*/
#include <glib.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include "log.h"

View File

@@ -109,7 +109,7 @@ omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res)
{
return NULL;
};
void omemo_free(void* a){};
void omemo_free(void* a) {};
uint32_t
omemo_device_id()

View File

@@ -2,10 +2,7 @@
#include <libotr/message.h>
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include "config/account.h"

View File

@@ -1,8 +1,5 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include "xmpp/contact.h"

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,8 +1,5 @@
#include <stdarg.h>
#include <string.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include "xmpp/chat_session.h"

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>

View File

@@ -1,7 +1,4 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
@@ -40,3 +37,17 @@ cmd_sub_shows_usage_when_no_arg(void** state)
gboolean result = cmd_sub(NULL, CMD_SUB, args);
assert_true(result);
}
void
test_cmd_sub_malformed_jid(void** state)
{
ProfWin win;
win.type = WIN_CONSOLE;
gchar* args[] = { "request", "@example.com" };
will_return(connection_get_status, JABBER_CONNECTED);
expect_cons_show("Malformed JID: @example.com");
gboolean result = cmd_sub((ProfWin*)&win, CMD_SUB, args);
assert_true(result);
}

Some files were not shown because too many files have changed in this diff Show More