Compare commits

..

37 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
77 changed files with 3102 additions and 2084 deletions

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

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"

View File

@@ -1,10 +1,18 @@
name: CI
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 }}
@@ -83,7 +91,7 @@ jobs:
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: install dependencies
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends codespell

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 \
@@ -170,6 +171,7 @@ unittest_sources = \
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 \
@@ -284,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
@@ -347,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

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,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

@@ -1675,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);
@@ -1687,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);
@@ -1737,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);
}

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")
},

View File

@@ -8577,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);

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);

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();

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,23 +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, position: %d, ID: %s, append: %s, used message buffer size: %d, message buffer size: %d, rendered lines buffer size: %d",
from_jid, y_start_pos, id, append ? "TRUE" : "FALSE", g_slist_length(buffer->entries), MAX_BUFFER_SIZE, PAD_SIZE);
// At this point we have a message that caused overflow of the render buffer.
// Ideally, we want to clean other messages to rerender everything properly. To do so,
// first we need to determine the size of the message that we are trying to display,
// then we need to print the message.
// However, _buffer_add is too late in the code to do this, therefore it has to be done in the win_print_old_history.
// 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

@@ -424,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);
}
}
@@ -625,9 +627,13 @@ chatwin_db_history(ProfChatWin* chatwin, const gchar* start_time, const gchar* e
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

@@ -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;

View File

@@ -2003,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

@@ -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>

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

@@ -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>
@@ -45,6 +42,7 @@ 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);

View File

@@ -1,9 +1,6 @@
#include "xmpp/resource.h"
#include "common.h"
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include <stdlib.h>
void

View File

@@ -1,9 +1,6 @@
#include <glib.h>
#include <stdarg.h>
#include <string.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 <glib.h>
#include "event/client_events.h"
#include "command/cmd_funcs.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/form.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 "xmpp/jid.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 "xmpp/muc.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 "tools/parser.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 "plugins/disco.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,9 +1,6 @@
#include <glib.h>
#include <stdarg.h>
#include <string.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

@@ -3,8 +3,7 @@
#include <glib.h>
#include <wchar.h>
#include <setjmp.h>
#include <cmocka.h>
#include "prof_cmocka.h"
#include "ui/window.h"
#include "ui/ui.h"

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 <stdlib.h>
#include <locale.h>

View File

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