Compare commits
63 Commits
2020bcaf88
...
build/mult
| Author | SHA1 | Date | |
|---|---|---|---|
| 886372caac | |||
| 0b0b02d6e0 | |||
| d748ffc527 | |||
|
fac1e224bc
|
|||
|
6ad8a19053
|
|||
|
40dd773c6a
|
|||
|
8849d9b79e
|
|||
|
92cb930810
|
|||
|
9fd62e2304
|
|||
|
c94263486f
|
|||
|
353b6bdb11
|
|||
|
105c496ab1
|
|||
|
cb6f302208
|
|||
|
4cdcf9a8eb
|
|||
|
7e4c60e2c3
|
|||
|
e998d5e7ef
|
|||
|
3ffeda1531
|
|||
|
a4cead7fe8
|
|||
|
052e168e9b
|
|||
|
c94cd0b549
|
|||
|
4780fdd4a1
|
|||
|
|
9b1cb6ab85
|
||
|
|
f419e65fad
|
||
|
|
110b3d27b4
|
||
|
|
75b378cf54
|
||
|
|
988d3663d1
|
||
|
|
d3fa1c2f78
|
||
|
|
1a385b8cd2
|
||
|
|
39aab45162
|
||
|
|
0d5123e69a
|
||
|
|
36f183d6a4
|
||
|
|
6b6576b31c
|
||
|
|
1ae78400a4
|
||
|
ea8a758ecf
|
|||
|
2808def933
|
|||
|
741dc4c275
|
|||
|
65cf9ddb9c
|
|||
|
51d2355d97
|
|||
|
e33c7a477d
|
|||
|
f4405d114a
|
|||
|
442bfb6ce1
|
|||
|
a3e23c3514
|
|||
|
ad294cdd6d
|
|||
|
e1ce7ac630
|
|||
|
5ed8ec30f0
|
|||
|
|
091ff41c06
|
||
|
|
b7afea7ec3
|
||
|
7fcc14fdea
|
|||
|
d07ca9953d
|
|||
|
f636090fd9
|
|||
|
a5eab3cad5
|
|||
|
6871a4d46f
|
|||
|
f824cde45f
|
|||
|
40b7a12543
|
|||
|
6a394ae2e5
|
|||
|
43bab6ff8f
|
|||
|
d5d5dc5180
|
|||
|
83c569de37
|
|||
|
7d1e1c726d
|
|||
| b4d3563b96 | |||
| ddc4290c99 | |||
|
0d7a859a20
|
|||
|
0784662d40
|
12
.github/FUNDING.yml
vendored
12
.github/FUNDING.yml
vendored
@@ -1,12 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: jubalh
|
||||
patreon: # Replace with Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with a single custom sponsorship URL
|
||||
44
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
44
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal 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
|
||||
@@ -20,8 +20,6 @@
|
||||
<!--- Give us a screenshot (if it's helpful for this particular bug) -->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
## Context
|
||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||
4
.github/pull_request_template.md
vendored
4
.github/pull_request_template.md
vendored
@@ -5,5 +5,5 @@
|
||||
- [ ] I ran valgrind when using my new feature
|
||||
|
||||
### How to test the functionality
|
||||
* step 1
|
||||
* step 2
|
||||
- step 1
|
||||
- step 2
|
||||
|
||||
44
.github/workflows/ci-api-docs.yml
vendored
Normal file
44
.github/workflows/ci-api-docs.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
name: CI API Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'apidocs/**'
|
||||
pull_request:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'apidocs/**'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test-c-api-docs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Test C API Documentation Generation
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends make doxygen
|
||||
- name: Test C API docs generation
|
||||
run: |
|
||||
cd apidocs/c/
|
||||
doxygen c-prof.conf
|
||||
|
||||
test-python-api-docs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Test Python API Documentation Generation
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends make python3-sphinx
|
||||
- name: Test Python API docs generation
|
||||
run: |
|
||||
cd apidocs/python/
|
||||
sphinx-apidoc -f -o . src && make -j$(nproc) xml SPHINXOPTS="-W --keep-going -n"
|
||||
100
.github/workflows/ci-code.yml
vendored
Normal file
100
.github/workflows/ci-code.yml
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
name: CI Code
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- 'apidocs/**'
|
||||
- 'README.md'
|
||||
pull_request:
|
||||
branches: [master]
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- 'apidocs/**'
|
||||
- 'README.md'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
flavor: [arch, debian, ubuntu]
|
||||
|
||||
name: Linux
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run tests
|
||||
run: |
|
||||
docker build -f Dockerfile.${{ matrix.flavor }} -t profanity .
|
||||
docker run profanity ./ci-build.sh
|
||||
|
||||
code-style:
|
||||
runs-on: ubuntu-latest
|
||||
name: Check coding style
|
||||
continue-on-error: true
|
||||
env:
|
||||
GITHUB_WORKSPACE: ${{ runner.workspace }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# if this check fails, you have to update the number of auto types known and the list of auto types in the check below
|
||||
- name: Check auto types are up-to-date
|
||||
run: |
|
||||
[[ "$(find src -type f -name '*.[ch]' -exec awk '/^#define auto_[\W]*/ {print $2}' '{}' \; | sort -u | wc -l)" == "8" ]] || exit -1
|
||||
- name: Check auto types are initialized
|
||||
run: |
|
||||
grep -P 'auto_(char|gchar|gcharv|guchar|jid|sqlite|gfd|FILE)[\w *]*;$' -r src && exit -1 || true
|
||||
|
||||
- name: Install clang-format
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y clang-format
|
||||
|
||||
- name: Run clang-format check
|
||||
run: |
|
||||
echo $(clang-format --version)
|
||||
# Find all source files you care about
|
||||
INCLUDE_REGEX='^.*\.((((c|C)(c|pp|xx|\+\+)?$)|((h|H)h?(pp|xx|\+\+)?$))|(ino|pde|proto|cu))$'
|
||||
CHECK_PATH='src'
|
||||
files=$(find "$CHECK_PATH" -name .git -prune -o -regextype posix-egrep -regex "$INCLUDE_REGEX" -print)
|
||||
if [ -z "$files" ]; then
|
||||
echo "✅ No source files found to check."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run clang-format in dry-run mode and collect any improperly formatted files
|
||||
failed=0
|
||||
for file in $files; do
|
||||
if ! output=$(clang-format --dry-run --Werror --style=file "$file" 2>&1); then
|
||||
echo "❌ Failed on file: $file"
|
||||
echo "$output"
|
||||
echo "----------------------------------------"
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $failed -ne 0 ]; then
|
||||
echo "🚫 One or more files are not properly formatted."
|
||||
else
|
||||
echo "✅ All files are properly formatted."
|
||||
fi
|
||||
exit $failed
|
||||
|
||||
spell-check:
|
||||
runs-on: ubuntu-latest
|
||||
name: Check spelling
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y --no-install-recommends codespell
|
||||
- name: Check spelling
|
||||
run: |
|
||||
codespell
|
||||
60
.github/workflows/main.yml
vendored
60
.github/workflows/main.yml
vendored
@@ -1,60 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
flavor: [arch, debian, fedora, ubuntu]
|
||||
|
||||
name: Linux
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run tests
|
||||
run: |
|
||||
docker build -f Dockerfile.${{ matrix.flavor }} -t profanity .
|
||||
docker run profanity ./ci-build.sh
|
||||
|
||||
code-style:
|
||||
runs-on: ubuntu-22.04
|
||||
name: Check coding style
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
# if this check fails, you have to update the number of auto types known and the list of auto types in the check below
|
||||
- name: Check auto types are up-to-date
|
||||
run: |
|
||||
[[ "$(find src -type f -name '*.[ch]' -exec awk '/^#define auto_[\W]*/ {print $2}' '{}' \; | sort -u | wc -l)" == "8" ]] || exit -1
|
||||
- name: Check auto types are initialized
|
||||
run: |
|
||||
grep -P 'auto_(char|gchar|gcharv|guchar|jid|sqlite|gfd|FILE)[\w *]*;$' -r src && exit -1 || true
|
||||
- name: Run clang-format
|
||||
uses: jidicula/clang-format-action@v4.11.0
|
||||
with:
|
||||
clang-format-version: '16'
|
||||
check-path: 'src'
|
||||
|
||||
spell-check:
|
||||
runs-on: ubuntu-22.04
|
||||
name: Check spelling
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y --no-install-recommends codespell
|
||||
- name: Check spelling
|
||||
run: |
|
||||
codespell
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -44,6 +44,9 @@ src/gitversion.h.in
|
||||
src/stamp-h1
|
||||
src/plugins/profapi.lo
|
||||
|
||||
# clangd
|
||||
.cache/
|
||||
|
||||
# out-of-tree build folders
|
||||
build*/
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ We recommend for people to always work on a dedicated git branch for each fix or
|
||||
Don't work on master.
|
||||
So that they can easily pull master and rebase their work if needed.
|
||||
|
||||
For fixing (reported) bugs we usually use `git checkout -b fix/issuenumber-somedescription`.
|
||||
When working on a new feature we usually use `git checkout -b feature/optionalissuenumber-somedescription`.
|
||||
For fixing (reported) bugs we usually use `git switch -c fix/issuenumber-somedescription`.
|
||||
When working on a new feature we usually use `git switch -c feature/optionalissuenumber-somedescription`.
|
||||
|
||||
However this is not a rule just a recommendation to keep an overview of things.
|
||||
If your change isn't a bugfix or new feature you can also just use any branch name.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -124,6 +124,7 @@ unittest_sources = \
|
||||
src/event/server_events.c src/event/server_events.h \
|
||||
src/event/client_events.c src/event/client_events.h \
|
||||
src/ui/tray.h src/ui/tray.c \
|
||||
tests/prof_cmocka.h \
|
||||
tests/unittests/xmpp/stub_vcard.c \
|
||||
tests/unittests/xmpp/stub_avatar.c \
|
||||
tests/unittests/xmpp/stub_ox.c \
|
||||
@@ -166,9 +167,11 @@ unittest_sources = \
|
||||
tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \
|
||||
tests/unittests/test_callbacks.c tests/unittests/test_callbacks.h \
|
||||
tests/unittests/test_plugins_disco.c tests/unittests/test_plugins_disco.h \
|
||||
tests/unittests/test_forced_encryption.c tests/unittests/test_forced_encryption.h \
|
||||
tests/unittests/unittests.c
|
||||
|
||||
functionaltest_sources = \
|
||||
tests/prof_cmocka.h \
|
||||
tests/functionaltests/proftest.c tests/functionaltests/proftest.h \
|
||||
tests/functionaltests/test_connect.c tests/functionaltests/test_connect.h \
|
||||
tests/functionaltests/test_ping.c tests/functionaltests/test_ping.h \
|
||||
@@ -283,6 +286,7 @@ endif
|
||||
|
||||
TESTS = tests/unittests/unittests
|
||||
check_PROGRAMS = tests/unittests/unittests
|
||||
tests_unittests_unittests_CPPFLAGS = -Itests/
|
||||
tests_unittests_unittests_SOURCES = $(unittest_sources)
|
||||
tests_unittests_unittests_LDADD = -lcmocka
|
||||
|
||||
@@ -346,9 +350,13 @@ endif
|
||||
.PHONY: my-prof.supp
|
||||
my-prof.supp:
|
||||
@sed '/^# AUTO-GENERATED START/q' prof.supp > $@
|
||||
@printf "\n\n# glib\n" >> $@
|
||||
@cat /usr/share/glib-2.0/valgrind/glib.supp >> $@
|
||||
@printf "\n\n# Python\n" >> $@
|
||||
@wget -O- https://raw.githubusercontent.com/python/cpython/refs/tags/v`python3 --version | cut -d' ' -f2`/Misc/valgrind-python.supp >> $@
|
||||
@printf "\n\n# gtk\n" >> $@
|
||||
@test -z "@GTK_VERSION@" || wget -O- https://raw.githubusercontent.com/GNOME/gtk/refs/tags/@GTK_VERSION@/gtk.supp >> $@
|
||||
@printf "\n\n# more gtk\n" >> $@
|
||||
@test -z "@GTK_VERSION@" || cat /usr/share/gtk-3.0/valgrind/gtk.supp >> $@
|
||||
|
||||
check-unit: tests/unittests/unittests
|
||||
|
||||
65
README.md
65
README.md
@@ -1,65 +1,36 @@
|
||||
# Profanity
|
||||
 [](https://github.com/profanity-im/profanity/graphs/contributors/) [](https://repology.org/project/profanity/versions)
|
||||
# CProof
|
||||

|
||||
|
||||
Profanity is a console based XMPP client inspired by [Irssi](http://www.irssi.org/).
|
||||
CProof is a console based XMPP chat client based on [Profanity](https://profanity-im.github.io/).
|
||||
|
||||
If you like Profanity consider becoming a sponsor or [donate](https://profanity-im.github.io/donate.html) some money.
|
||||

|
||||
|
||||

|
||||
|
||||
See the [User Guide](https://profanity-im.github.io/userguide.html) for information on installing and using Profanity.
|
||||
See the [Quick Start Guide](https://jabber.space/getting-started/quick-start/) for information on installing and using CProof.
|
||||
|
||||
## Project
|
||||
This project is about freedom, privacy and choice. We want to enable people to chat with one another in a safe way. Thus supporting encryption (OTR, PGP, OMEMO, OX) and being decentralized, meaning everyone can run their own server. We believe [XMPP](https://xmpp.org/) is a great proven protocol with an excellent community serving this purpose well.
|
||||
|
||||
Feel free to follow us on [twitter](https://twitter.com/profanityim), join our [mailing list](https://lists.posteo.de/listinfo/profanity) and/or [MUC](xmpp:profanity@rooms.dismail.de?join).
|
||||
CProof enables you to communicate with privacy, freedom and comfort. Our open-source chat application delivers secure, end-to-end encrypted messaging (OTR, PGP, OMEMO, OX) built on the trusted [XMPP](https://xmpp.org/) protocol. With a decentralized design, you can connect directly or even host your own server, keeping your data in your hands. Whether you're chatting with friends or collaborating securely, CProof makes private communication simple, reliable, and truly yours.
|
||||
|
||||
## Installation
|
||||
Our [user guide](https://profanity-im.github.io/userguide.html) contains an [install](https://profanity-im.github.io/guide/latest/install.html) section and a section for [building](https://profanity-im.github.io/guide/latest/build.html) from source yourself.
|
||||
|
||||
## Donations
|
||||
We would highly appreciate it if you support us via [GitHub Sponsors](https://github.com/sponsors/jubalh/). Especially if you make feature requests or need help using Profanity.
|
||||
Sponsoring enables us to spend time on Profanity.
|
||||
|
||||
An alternative way to support us would be to ask for our IBAN or use Bitcoin: `bc1qx265eat7hfasqkqmk9qf38delydnrnuvzhzy0x`.
|
||||
|
||||
Issues backed by a sponsor will be tagged with the [sponsored](https://github.com/profanity-im/profanity/issues?q=label%3Asponsored+) label.
|
||||
Feature requests that we consider out of scope, either because of interest or because of time needed to implement them, will be marked with the [unfunded](https://github.com/profanity-im/profanity/issues?q=label%3Aunfunded) label.
|
||||
|
||||
Another way to sponsor us or get an issue solved is to comment on an issue that you are willing to sponsor it.
|
||||
|
||||
Tasks from our [sponsors](SPONSORS.md) will be tackled first.
|
||||
|
||||
Thank you! <3
|
||||
Check our [installation guide](https://jabber.space/getting-started/installation/) for detailed instructions.
|
||||
|
||||
## How to contribute
|
||||
We tried to sum things up on our [helpout](https://profanity-im.github.io/helpout.html) page.
|
||||
Additionally you can check out our [blog](https://profanity-im.github.io/blog/) where we have articles like:
|
||||
[How to get a backtrace](https://profanity-im.github.io/blog/post/how-to-get-a-backtrace/) and [Contributing a Patch via GitHub](https://profanity-im.github.io/blog/post/contributing-a-patch-via-github/).
|
||||
For more technical details check out our [CONTRIBUTING.md](CONTRIBUTING.md) file.
|
||||
See our [Helping Out](https://jabber.space/contributing/helpout/) page for a concise summary of ways to help us.
|
||||
|
||||
Review the [Contributing Guide](CONTRIBUTING.md) and [Code Overview](https://jabber.space/contributing/code-overview/) pages for advanced technical details.
|
||||
|
||||
## Getting help
|
||||
To get help, first read our [User Guide](https://profanity-im.github.io/userguide.html) then check out the [FAQ](https://profanity-im.github.io/faq.html).
|
||||
If you have are having a problem then first search the [issue tracker](https://github.com/profanity-im/profanity/issues).
|
||||
If you don't find anything there either come to our [MUC](xmpp:profanity@rooms.dismail.de?join) or create a new issue depending on what your problem is.
|
||||
Prior to asking questions, check our [User Guide](https://profanity-im.github.io/userguide.html), then check out the [FAQ](https://jabber.space/about/faq/).
|
||||
|
||||
If you are still having a problem then search the [issue tracker](https://git.jabber.space/devs/cproof/issues).
|
||||
|
||||
As a last resort, feel free to write us on [support@jabber.tech](mailto:support@jabber.tech) or create a new issue depending on what your problem is.
|
||||
|
||||
## Links
|
||||
|
||||
### Website
|
||||
URL: https://profanity-im.github.io
|
||||
Feel free to visit our website: [jabber.space](https://jabber.space/).
|
||||
|
||||
Repo: https://github.com/profanity-im/profanity-im.github.io
|
||||
|
||||
### Blog
|
||||
URL: https://profanity-im.github.io/blog
|
||||
|
||||
Repo: https://github.com/profanity-im/blog
|
||||
|
||||
### Mailinglist
|
||||
Mailing List: https://lists.posteo.de/listinfo/profanity
|
||||
|
||||
### Chatroom
|
||||
MUC: profanity@rooms.dismail.de
|
||||
You may also check the repository if you like, available on [git.jabber.space/devs/profanity](https://git.jabber.space/devs/profanity).
|
||||
|
||||
### Plugins
|
||||
Plugins repository: https://github.com/profanity-im/profanity-plugins
|
||||
Plugins repository: https://git.jabber.space/devs/cproof-plugins
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* Generate HTML docs (the docgen argument only works when package status is development)
|
||||
`./profanity docgen`
|
||||
|
||||
* Determine if libprofanitys version needs to be [increased](https://github.com/profanity-im/profanity/issues/973)
|
||||
* Determine if `libprofanity`'s version needs to be [increased](https://github.com/profanity-im/profanity/issues/973)
|
||||
* Update plugin API docs (./apidocs/c and ./apidocs/python) need to run the `gen.sh` and commit the results to the website git repo
|
||||
* Update CHANGELOG
|
||||
* Update profrc.example
|
||||
|
||||
22
SPONSORS.md
22
SPONSORS.md
@@ -1,22 +0,0 @@
|
||||
# Giving back
|
||||
|
||||
Thank you very much to all of our sponsors and donors (including those that want to stay private)!
|
||||
|
||||
## Sponsors
|
||||
[Martin Dosch](https://github.com/mdosch) since January 2020
|
||||
|
||||
[Alexander Dahl](https://github.com/LeSpocky) since January 2021
|
||||
|
||||
[James Pond](https://github.com/jamesponddotco) since February 2021
|
||||
|
||||
## Donors
|
||||
[Martin Dosch](https://github.com/mdosch)
|
||||
|
||||
[Julian Huhn](https://github.com/huhndev)
|
||||
|
||||
[Matteo Bini](https://github.com/matteobin)
|
||||
|
||||
## Services
|
||||
[Stefan Kropp](https://github.com/StefanKropp) for sponsoring our [mailing list](https://lists.posteo.de/listinfo/profanity)
|
||||
|
||||
[dismail](https://dismail.de/) for hosting our [MUC](xmpp:profanity@rooms.dismail.de?join)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
@@ -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)
|
||||
]
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
sphinx-apidoc -f -o . src && make html
|
||||
sphinx-apidoc -f -o . src && make xml
|
||||
|
||||
@@ -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`
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
53
prof.supp
53
prof.supp
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This file is a combination of our own rules and
|
||||
# * the glib2 suppressions file that usually can be found at /usr/share/glib-2.0/valgrind/glib.supp
|
||||
# * python suppressions file from http://svn.python.org/projects/python/trunk/Misc/valgrind-python.supp
|
||||
# * python suppressions file from https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
|
||||
#
|
||||
|
||||
{
|
||||
@@ -1557,6 +1557,10 @@
|
||||
...
|
||||
fun:xdg_mime_init
|
||||
}
|
||||
|
||||
# Python Valgrind .supp start
|
||||
# taken from https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
|
||||
|
||||
#
|
||||
# This is a valgrind suppression file that should be used when using valgrind.
|
||||
#
|
||||
@@ -1654,6 +1658,49 @@
|
||||
fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
|
||||
}
|
||||
|
||||
#
|
||||
# Leaks: dlopen() called without dlclose()
|
||||
#
|
||||
|
||||
{
|
||||
dlopen() called without dlclose()
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:malloc
|
||||
fun:strdup
|
||||
fun:_dl_load_cache_lookup
|
||||
}
|
||||
{
|
||||
dlopen() called without dlclose()
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:malloc
|
||||
fun:strdup
|
||||
fun:_dl_map_object
|
||||
}
|
||||
{
|
||||
dlopen() called without dlclose()
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:*
|
||||
fun:_dl_new_object
|
||||
}
|
||||
{
|
||||
dlopen() called without dlclose()
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:*
|
||||
fun:_dl_new_object
|
||||
}
|
||||
{
|
||||
dlopen() called without dlclose()
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:*
|
||||
fun:_dl_check_map_versions
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Non-python specific leaks
|
||||
#
|
||||
@@ -2048,6 +2095,10 @@
|
||||
fun:PyUnicode_FSConverter
|
||||
}
|
||||
|
||||
# Python Valgrind .supp end
|
||||
|
||||
|
||||
|
||||
# Actual GTK things
|
||||
{
|
||||
GtkWidgetClass action GPtrArray
|
||||
|
||||
@@ -136,6 +136,7 @@ static char* _mood_autocomplete(ProfWin* window, const char* const input, gboole
|
||||
static char* _strophe_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _adhoc_cmd_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _force_encryption_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
|
||||
static char* _script_autocomplete_func(const char* const prefix, gboolean previous, void* context);
|
||||
|
||||
@@ -296,6 +297,8 @@ static Autocomplete vcard_name_ac;
|
||||
static Autocomplete vcard_set_param_ac;
|
||||
static Autocomplete vcard_togglable_param_ac;
|
||||
static Autocomplete vcard_address_type_ac;
|
||||
static Autocomplete force_encryption_ac;
|
||||
static Autocomplete force_encryption_policy_ac;
|
||||
|
||||
static Autocomplete* all_acs[] = {
|
||||
&commands_ac,
|
||||
@@ -448,6 +451,8 @@ static Autocomplete* all_acs[] = {
|
||||
&vcard_set_param_ac,
|
||||
&vcard_togglable_param_ac,
|
||||
&vcard_address_type_ac,
|
||||
&force_encryption_ac,
|
||||
&force_encryption_policy_ac
|
||||
};
|
||||
|
||||
static GHashTable* ac_funcs = NULL;
|
||||
@@ -1343,6 +1348,13 @@ cmd_ac_init(void)
|
||||
autocomplete_add(vcard_address_type_ac, "domestic");
|
||||
autocomplete_add(vcard_address_type_ac, "international");
|
||||
|
||||
autocomplete_add(force_encryption_ac, "on");
|
||||
autocomplete_add(force_encryption_ac, "off");
|
||||
autocomplete_add(force_encryption_ac, "policy");
|
||||
|
||||
autocomplete_add(force_encryption_policy_ac, "block");
|
||||
autocomplete_add(force_encryption_policy_ac, "resend-to-confirm");
|
||||
|
||||
if (ac_funcs != NULL)
|
||||
g_hash_table_destroy(ac_funcs);
|
||||
ac_funcs = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
@@ -1415,6 +1427,7 @@ cmd_ac_init(void)
|
||||
g_hash_table_insert(ac_funcs, "/win", _win_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/wins", _wins_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/wintitle", _wintitle_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/force-encryption", _force_encryption_autocomplete);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1662,7 +1675,7 @@ char*
|
||||
cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous)
|
||||
{
|
||||
unsigned int output_off = 0;
|
||||
char* tmp;
|
||||
char* tmp = NULL;
|
||||
|
||||
// strip command
|
||||
char* inpcp = (char*)input + strlen(startstr);
|
||||
@@ -1674,38 +1687,36 @@ cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean
|
||||
|
||||
// strip quotes
|
||||
if (*inpcp == '"') {
|
||||
tmp = strchr(inpcp + 1, '"');
|
||||
tmp = strrchr(inpcp + 1, '"');
|
||||
if (tmp) {
|
||||
*tmp = '\0';
|
||||
}
|
||||
tmp = strdup(inpcp + 1);
|
||||
free(inpcp);
|
||||
inpcp = tmp;
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
// expand ~ to $HOME
|
||||
if (inpcp[0] == '~' && inpcp[1] == '/') {
|
||||
tmp = g_strdup_printf("%s/%sfoo", getenv("HOME"), inpcp + 2);
|
||||
if (!tmp) {
|
||||
char* home = getenv("HOME");
|
||||
if (!home) {
|
||||
free(inpcp);
|
||||
return NULL;
|
||||
}
|
||||
output_off = strlen(getenv("HOME")) + 1;
|
||||
tmp = g_strdup_printf("%s/%sfoo", home, inpcp + 2);
|
||||
output_off = strlen(home) + 1;
|
||||
} else {
|
||||
tmp = g_strdup_printf("%sfoo", inpcp);
|
||||
if (!tmp) {
|
||||
free(inpcp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
free(inpcp);
|
||||
inpcp = tmp;
|
||||
if (!tmp) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* inpcp2 = strdup(inpcp);
|
||||
char* foofile = strdup(basename(inpcp2));
|
||||
char* directory = strdup(dirname(inpcp));
|
||||
free(inpcp);
|
||||
free(inpcp2);
|
||||
char* foofile = strdup(basename(tmp));
|
||||
char* directory = strdup(dirname(tmp));
|
||||
g_free(tmp);
|
||||
|
||||
GArray* files = g_array_new(TRUE, FALSE, sizeof(char*));
|
||||
g_array_set_clear_func(files, (GDestroyNotify)_filepath_item_free);
|
||||
@@ -1724,40 +1735,26 @@ cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean
|
||||
continue;
|
||||
}
|
||||
|
||||
char* acstring;
|
||||
char* acstring = NULL;
|
||||
if (output_off) {
|
||||
tmp = g_strdup_printf("%s/%s", directory, dir->d_name);
|
||||
if (!tmp) {
|
||||
free(directory);
|
||||
free(foofile);
|
||||
return NULL;
|
||||
if (tmp) {
|
||||
acstring = g_strdup_printf("~/%s", tmp + output_off);
|
||||
g_free(tmp);
|
||||
}
|
||||
acstring = g_strdup_printf("~/%s", tmp + output_off);
|
||||
if (!acstring) {
|
||||
free(directory);
|
||||
free(foofile);
|
||||
return NULL;
|
||||
}
|
||||
free(tmp);
|
||||
} else if (strcmp(directory, "/") == 0) {
|
||||
acstring = g_strdup_printf("/%s", dir->d_name);
|
||||
if (!acstring) {
|
||||
free(directory);
|
||||
free(foofile);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
acstring = g_strdup_printf("%s/%s", directory, dir->d_name);
|
||||
if (!acstring) {
|
||||
free(directory);
|
||||
free(foofile);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!acstring) {
|
||||
g_array_free(files, TRUE);
|
||||
free(foofile);
|
||||
free(directory);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* acstring_cpy = strdup(acstring);
|
||||
g_array_append_val(files, acstring_cpy);
|
||||
free(acstring);
|
||||
g_array_append_val(files, acstring);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
@@ -4406,3 +4403,17 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static char*
|
||||
_force_encryption_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
{
|
||||
char* result = NULL;
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/force-encryption policy", force_encryption_policy_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/force-encryption", force_encryption_ac, TRUE, previous);
|
||||
return result;
|
||||
}
|
||||
@@ -433,7 +433,7 @@ static const struct cmd_t command_defs[] = {
|
||||
{ "<contact>", "The contact you wish to view information about." },
|
||||
{ "<nick>", "When in a chat room, the occupant you wish to view information about." })
|
||||
CMD_EXAMPLES(
|
||||
"/info thor@aasgard.server.org",
|
||||
"/info thor@asgard.server.org",
|
||||
"/info heimdall")
|
||||
},
|
||||
|
||||
@@ -2729,6 +2729,7 @@ static const struct cmd_t command_defs[] = {
|
||||
{ "os on|off", "Choose whether to include the OS name if a user asks for software information (XEP-0092)." }
|
||||
)
|
||||
CMD_EXAMPLES(
|
||||
"/privacy",
|
||||
"/privacy logging off",
|
||||
"/privacy os off")
|
||||
},
|
||||
@@ -2744,6 +2745,31 @@ static const struct cmd_t command_defs[] = {
|
||||
"Redraw user interface. Can be used when some other program interrupted profanity or wrote to the same terminal and the interface looks \"broken\"." )
|
||||
},
|
||||
|
||||
{ CMD_PREAMBLE("/force-encryption",
|
||||
parse_args, 1, 3, &cons_encryption_setting)
|
||||
CMD_MAINFUNC(cmd_force_encryption)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_CHAT)
|
||||
CMD_SYN(
|
||||
"/force-encryption",
|
||||
"/force-encryption on|off",
|
||||
"/force-encryption policy resend-to-confirm|block")
|
||||
CMD_DESC(
|
||||
"Configure forced encryption for outgoing messages in CProof. "
|
||||
"When enabled, restricts sending unencrypted messages based on the specified policy. "
|
||||
"Run without arguments to display current settings.")
|
||||
CMD_ARGS(
|
||||
{ "on|off", "Enable or disable forced encryption. When enabled, restricts unencrypted messages per the policy. When disabled, allows sending unencrypted messages without restrictions." },
|
||||
{ "policy resend-to-confirm|block", "Set the policy for unencrypted messages when forced encryption is enabled. 'resend-to-confirm' requires pressing Enter again to confirm sending an unencrypted message (default). 'block' prevents sending unencrypted messages entirely." }
|
||||
)
|
||||
CMD_EXAMPLES(
|
||||
"/force-encryption",
|
||||
"/force-encryption on",
|
||||
"/force-encryption off",
|
||||
"/force-encryption policy resend-to-confirm",
|
||||
"/force-encryption policy block")
|
||||
},
|
||||
|
||||
// NEXT-COMMAND (search helper)
|
||||
};
|
||||
|
||||
|
||||
@@ -1263,6 +1263,11 @@ cmd_sub(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
|
||||
if (jidp == NULL) {
|
||||
cons_show("Malformed JID: %s", jid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp(subcmd, "allow") == 0) {
|
||||
presence_subscription(jidp->barejid, PRESENCE_SUBSCRIBED);
|
||||
cons_show("Accepted subscription for %s", jidp->barejid);
|
||||
@@ -1715,8 +1720,15 @@ cmd_help(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_about(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
ProfWin* console = wins_get_console();
|
||||
cons_show("");
|
||||
cons_about();
|
||||
win_println(console, THEME_DEFAULT, "-", "Licensed under GNU GPL v3.");
|
||||
win_println(console, THEME_DEFAULT, "-", "CProof is an independent unaffiliated fork of Profanity.");
|
||||
win_println(console, THEME_DEFAULT, "-", "Profanity: Copyright (C) 2012–2019 James Booth, 2019–2025 Michael Vetter");
|
||||
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2025 CProof Developers");
|
||||
win_println(console, THEME_DEFAULT, "-", "");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -3411,7 +3423,7 @@ cmd_caps(ProfWin* window, const char* const command, gchar** args)
|
||||
if (args[0]) {
|
||||
auto_jid Jid* jid = jid_create(args[0]);
|
||||
|
||||
if (jid->fulljid == NULL) {
|
||||
if (jid == NULL || jid->fulljid == NULL) {
|
||||
cons_show("You must provide a full jid to the /caps command.");
|
||||
} else {
|
||||
PContact pcontact = roster_get_contact(jid->barejid);
|
||||
@@ -5233,54 +5245,43 @@ cmd_console(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_presence(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (strcmp(args[0], "console") != 0 && strcmp(args[0], "chat") != 0 && strcmp(args[0], "room") != 0 && strcmp(args[0], "titlebar") != 0) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "titlebar") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], "Contact presence", PREF_PRESENCE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp(args[1], "all") != 0 && strcmp(args[1], "online") != 0 && strcmp(args[1], "none") != 0) {
|
||||
const struct presence_preferences
|
||||
{
|
||||
preference_t pref;
|
||||
const char *name, *description;
|
||||
} presence_prefs[] = {
|
||||
{ .pref = PREF_STATUSES_CONSOLE, .name = "console", .description = "the console" },
|
||||
{ .pref = PREF_STATUSES_CHAT, .name = "chat", .description = "chat windows" },
|
||||
{ .pref = PREF_STATUSES_MUC, .name = "room", .description = "chat room windows" },
|
||||
};
|
||||
size_t n = 0;
|
||||
for (; n < ARRAY_SIZE(presence_prefs); ++n) {
|
||||
const struct presence_preferences* pp = &presence_prefs[n];
|
||||
if (g_strcmp0(args[0], pp->name) != 0)
|
||||
continue;
|
||||
if (strcmp(args[1], "all") == 0) {
|
||||
cons_show("All presence updates will appear in %s.", pp->description);
|
||||
} else if (strcmp(args[1], "online") == 0) {
|
||||
cons_show("Only %s presence updates will appear in %s.",
|
||||
pp->pref == PREF_STATUSES_MUC ? "join/leave" : "online/offline",
|
||||
pp->description);
|
||||
} else if (strcmp(args[1], "none") == 0) {
|
||||
cons_show("Presence updates will not appear in %s.", pp->description);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
prefs_set_string(pp->pref, args[1]);
|
||||
break;
|
||||
}
|
||||
if (n == ARRAY_SIZE(presence_prefs)) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "console") == 0) {
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, args[1]);
|
||||
if (strcmp(args[1], "all") == 0) {
|
||||
cons_show("All presence updates will appear in the console.");
|
||||
} else if (strcmp(args[1], "online") == 0) {
|
||||
cons_show("Only online/offline presence updates will appear in the console.");
|
||||
} else {
|
||||
cons_show("Presence updates will not appear in the console.");
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "chat") == 0) {
|
||||
prefs_set_string(PREF_STATUSES_CHAT, args[1]);
|
||||
if (strcmp(args[1], "all") == 0) {
|
||||
cons_show("All presence updates will appear in chat windows.");
|
||||
} else if (strcmp(args[1], "online") == 0) {
|
||||
cons_show("Only online/offline presence updates will appear in chat windows.");
|
||||
} else {
|
||||
cons_show("Presence updates will not appear in chat windows.");
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "room") == 0) {
|
||||
prefs_set_string(PREF_STATUSES_MUC, args[1]);
|
||||
if (strcmp(args[1], "all") == 0) {
|
||||
cons_show("All presence updates will appear in chat room windows.");
|
||||
} else if (strcmp(args[1], "online") == 0) {
|
||||
cons_show("Only join/leave presence updates will appear in chat room windows.");
|
||||
} else {
|
||||
cons_show("Presence updates will not appear in chat room windows.");
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -5314,7 +5315,8 @@ cmd_time(ProfWin* window, const char* const command, gchar** args)
|
||||
};
|
||||
gboolean redraw = FALSE;
|
||||
gboolean set_all = g_strcmp0(args[0], "all") == 0;
|
||||
for (size_t n = 0; n < ARRAY_SIZE(time_prefs); ++n) {
|
||||
size_t n = 0;
|
||||
for (; n < ARRAY_SIZE(time_prefs); ++n) {
|
||||
if (!set_all && g_strcmp0(args[0], time_prefs[n].name) != 0)
|
||||
continue;
|
||||
const struct time_preferences* tp = &time_prefs[n];
|
||||
@@ -5355,6 +5357,9 @@ cmd_time(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (!set_all && n == ARRAY_SIZE(time_prefs)) {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
if (redraw)
|
||||
ui_redraw();
|
||||
return TRUE;
|
||||
@@ -8572,19 +8577,20 @@ cmd_omemo_trust_mode(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
#ifdef HAVE_OMEMO
|
||||
|
||||
auto_gchar gchar* trust_mode = prefs_get_string(PREF_OMEMO_TRUST_MODE);
|
||||
if (!args[1]) {
|
||||
cons_show("Current trust mode is %s", prefs_get_string(PREF_OMEMO_TRUST_MODE));
|
||||
cons_show("Current trust mode is %s", trust_mode);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[1], "manual") == 0) {
|
||||
cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]);
|
||||
cons_show("Current trust mode is %s - setting to %s", trust_mode, args[1]);
|
||||
cons_show("You need to trust all OMEMO fingerprints manually");
|
||||
} else if (g_strcmp0(args[1], "firstusage") == 0) {
|
||||
cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]);
|
||||
cons_show("Current trust mode is %s - setting to %s", trust_mode, args[1]);
|
||||
cons_show("The first seen OMEMO fingerprints will be trusted automatically - new keys must be trusted manually");
|
||||
} else if (g_strcmp0(args[1], "blind") == 0) {
|
||||
cons_show("Current trust mode is %s - setting to %s", prefs_get_string(PREF_OMEMO_TRUST_MODE), args[1]);
|
||||
cons_show("Current trust mode is %s - setting to %s", trust_mode, args[1]);
|
||||
cons_show("ALL OMEMO fingerprints will be trusted automatically");
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
@@ -9527,16 +9533,7 @@ cmd_change_password(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_editor(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
auto_gchar gchar* message = NULL;
|
||||
|
||||
if (get_message_from_editor(NULL, &message)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
rl_insert_text(message);
|
||||
ui_resize();
|
||||
rl_point = rl_end;
|
||||
rl_forced_update_display();
|
||||
get_message_from_editor_async(NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -10642,3 +10639,22 @@ cmd_vcard_save(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_show("User vCard uploaded");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_force_encryption(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (g_strv_length(args) == 1 && (g_strcmp0(args[0], "on") == 0 || g_strcmp0(args[0], "off") == 0)) {
|
||||
_cmd_set_boolean_preference(args[0], "Forces encryption", PREF_FORCE_ENCRYPTION);
|
||||
} else if (g_strv_length(args) == 2 && g_strcmp0(args[0], "policy") == 0) {
|
||||
if (g_strcmp0(args[1], "resend-to-confirm") != 0 && g_strcmp0(args[1], "block") != 0) {
|
||||
cons_show_error("Invalid policy: \"%s\". See '/help force-encryption' for details.", args[1]);
|
||||
return TRUE;
|
||||
}
|
||||
prefs_set_string(PREF_FORCE_ENCRYPTION_MODE, args[1]);
|
||||
cons_show("Force encryption policy has been set to \"%s\".", args[1]);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -269,5 +269,6 @@ gboolean cmd_vcard_photo(ProfWin* window, const char* const command, gchar** arg
|
||||
gboolean cmd_vcard_refresh(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_vcard_set(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_vcard_save(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_force_encryption(ProfWin* window, const char* const command, gchar** args);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
@@ -199,6 +200,10 @@ load_custom_keyfile(prof_keyfile_t* keyfile, gchar* filename)
|
||||
|
||||
if (g_file_test(keyfile->filename, G_FILE_TEST_EXISTS)) {
|
||||
g_chmod(keyfile->filename, S_IRUSR | S_IWUSR);
|
||||
} else {
|
||||
int fno = g_creat(keyfile->filename, S_IRUSR | S_IWUSR);
|
||||
if (fno != -1)
|
||||
g_close(fno, NULL);
|
||||
}
|
||||
|
||||
return _load_keyfile(keyfile);
|
||||
@@ -387,7 +392,7 @@ release_get_latest(void)
|
||||
|
||||
curl_easy_setopt(handle, CURLOPT_URL, url);
|
||||
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, _data_callback);
|
||||
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 2);
|
||||
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 2L);
|
||||
curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void*)&output);
|
||||
|
||||
curl_easy_perform(handle);
|
||||
|
||||
@@ -171,6 +171,8 @@ typedef enum {
|
||||
RESOURCE_XA
|
||||
} resource_presence_t;
|
||||
|
||||
extern gboolean background_mode;
|
||||
|
||||
gboolean string_to_verbosity(const char* cmd, int* verbosity, gchar** err_msg);
|
||||
|
||||
gboolean create_dir(const char* name);
|
||||
|
||||
@@ -1792,6 +1792,8 @@ _get_group(preference_t pref)
|
||||
case PREF_OUTGOING_STAMP:
|
||||
case PREF_INCOMING_STAMP:
|
||||
case PREF_MOOD:
|
||||
case PREF_FORCE_ENCRYPTION:
|
||||
case PREF_FORCE_ENCRYPTION_MODE:
|
||||
return PREF_GROUP_UI;
|
||||
case PREF_STATES:
|
||||
case PREF_OUTTYPE:
|
||||
@@ -2150,6 +2152,10 @@ _get_key(preference_t pref)
|
||||
return "strophe.sm.enabled";
|
||||
case PREF_STROPHE_SM_RESEND:
|
||||
return "strophe.sm.resend";
|
||||
case PREF_FORCE_ENCRYPTION:
|
||||
return "force-encryption.enabled";
|
||||
case PREF_FORCE_ENCRYPTION_MODE:
|
||||
return "force-encryption.policy";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -2204,6 +2210,7 @@ _get_default_boolean(preference_t pref)
|
||||
case PREF_STROPHE_SM_RESEND:
|
||||
return TRUE;
|
||||
case PREF_PGP_PUBKEY_AUTOIMPORT:
|
||||
case PREF_FORCE_ENCRYPTION:
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2310,6 +2317,8 @@ _get_default_string(preference_t pref)
|
||||
return "0";
|
||||
case PREF_DBLOG:
|
||||
return "on";
|
||||
case PREF_FORCE_ENCRYPTION_MODE:
|
||||
return "resend-to-confirm";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -187,6 +187,8 @@ typedef enum {
|
||||
PREF_STROPHE_SM_RESEND,
|
||||
PREF_VCARD_PHOTO_CMD,
|
||||
PREF_STATUSBAR_TABMODE,
|
||||
PREF_FORCE_ENCRYPTION,
|
||||
PREF_FORCE_ENCRYPTION_MODE
|
||||
} preference_t;
|
||||
|
||||
typedef struct prof_alias_t
|
||||
|
||||
@@ -56,10 +56,9 @@
|
||||
#include "config/preferences.h"
|
||||
#include "config/color.h"
|
||||
|
||||
static GString* theme_loc;
|
||||
static GKeyFile* theme;
|
||||
static GHashTable* bold_items;
|
||||
static GHashTable* defaults;
|
||||
static GString* theme_loc = NULL;
|
||||
static GKeyFile* theme = NULL;
|
||||
static GHashTable* defaults = NULL;
|
||||
|
||||
static void _load_preferences(void);
|
||||
static void _theme_list_dir(const gchar* const dir, GSList** result);
|
||||
@@ -78,10 +77,6 @@ _theme_close(void)
|
||||
g_string_free(theme_loc, TRUE);
|
||||
theme_loc = NULL;
|
||||
}
|
||||
if (bold_items) {
|
||||
g_hash_table_destroy(bold_items);
|
||||
bold_items = NULL;
|
||||
}
|
||||
if (defaults) {
|
||||
g_hash_table_destroy(defaults);
|
||||
defaults = NULL;
|
||||
@@ -91,6 +86,12 @@ _theme_close(void)
|
||||
void
|
||||
theme_init(const char* const theme_name)
|
||||
{
|
||||
if (defaults || theme_loc || theme) {
|
||||
log_warning("theme_init(): Detected non-NULL state (theme=%p, theme_loc=%p, defaults=%p). Cleaning up previous initialization.",
|
||||
theme, theme_loc, defaults);
|
||||
_theme_close();
|
||||
}
|
||||
|
||||
if (!_theme_load_file(theme_name)) {
|
||||
log_error("Loading theme %s failed.", theme_name);
|
||||
|
||||
|
||||
@@ -222,6 +222,7 @@ out:
|
||||
void
|
||||
log_database_close(void)
|
||||
{
|
||||
log_debug("log_database_close() called");
|
||||
if (g_chatlog_database) {
|
||||
sqlite3_close(g_chatlog_database);
|
||||
sqlite3_shutdown();
|
||||
@@ -318,19 +319,25 @@ log_database_get_limits_info(const gchar* const contact_barejid, gboolean is_las
|
||||
// Query previous chats, constraints start_time and end_time. If end_time is
|
||||
// null the current time is used. from_start gets first few messages if true
|
||||
// otherwise the last ones. Flip flips the order of the results
|
||||
GSList*
|
||||
log_database_get_previous_chat(const gchar* const contact_barejid, const char* start_time, char* end_time, gboolean from_start, gboolean flip)
|
||||
db_history_result_t
|
||||
log_database_get_previous_chat(const gchar* const contact_barejid, const gchar* start_time, const gchar* end_time, gboolean from_start, gboolean flip, GSList** result)
|
||||
{
|
||||
if (!g_chatlog_database) {
|
||||
log_warning("log_database_get_previous_chat() called but db is not initialized");
|
||||
return DB_RESPONSE_ERROR;
|
||||
}
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
const Jid* myjid = connection_get_jid();
|
||||
if (!myjid->str)
|
||||
return NULL;
|
||||
if (!myjid->str) {
|
||||
log_warning("log_database_get_previous_chat() called but no connection detected.");
|
||||
return DB_RESPONSE_ERROR;
|
||||
}
|
||||
|
||||
// Flip order when querying older pages
|
||||
gchar* sort1 = from_start ? "ASC" : "DESC";
|
||||
gchar* sort2 = !flip ? "ASC" : "DESC";
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
auto_gchar gchar* end_date_fmt = end_time ? end_time : g_date_time_format_iso8601(now);
|
||||
auto_gchar gchar* end_date_fmt = end_time ? g_strdup(end_time) : g_date_time_format_iso8601(now);
|
||||
auto_sqlite gchar* query = sqlite3_mprintf("SELECT * FROM ("
|
||||
"SELECT COALESCE(B.`message`, A.`message`) AS message, "
|
||||
"A.`timestamp`, A.`from_jid`, A.`from_resource`, A.`to_jid`, A.`to_resource`, A.`type`, A.`encryption`, A.`stanza_id` FROM `ChatLogs` AS A "
|
||||
@@ -346,18 +353,16 @@ log_database_get_previous_chat(const gchar* const contact_barejid, const char* s
|
||||
g_date_time_unref(now);
|
||||
|
||||
if (!query) {
|
||||
log_error("Could not allocate memory");
|
||||
return NULL;
|
||||
log_error("Could not allocate memory.");
|
||||
return DB_RESPONSE_ERROR;
|
||||
}
|
||||
|
||||
int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL);
|
||||
if (rc != SQLITE_OK) {
|
||||
log_error("SQLite error in log_database_get_previous_chat(): %s", sqlite3_errmsg(g_chatlog_database));
|
||||
return NULL;
|
||||
log_error("SQLite error in log_database_get_previous_chat(): (error code: %d) %s", rc, sqlite3_errmsg(g_chatlog_database));
|
||||
return DB_RESPONSE_ERROR;
|
||||
}
|
||||
|
||||
GSList* history = NULL;
|
||||
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
char* message = (char*)sqlite3_column_text(stmt, 0);
|
||||
char* date = (char*)sqlite3_column_text(stmt, 1);
|
||||
@@ -378,11 +383,11 @@ log_database_get_previous_chat(const gchar* const contact_barejid, const char* s
|
||||
msg->type = _get_message_type_type(type);
|
||||
msg->enc = _get_message_enc_type(encryption);
|
||||
|
||||
history = g_slist_append(history, msg);
|
||||
*result = g_slist_append(*result, msg);
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
return history;
|
||||
return g_slist_length(*result) != 0 ? DB_RESPONSE_SUCCESS : DB_RESPONSE_EMPTY;
|
||||
}
|
||||
|
||||
static const char*
|
||||
|
||||
@@ -40,14 +40,20 @@
|
||||
#include "config/account.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
|
||||
#define MESSAGES_TO_RETRIEVE 10
|
||||
#define MESSAGES_TO_RETRIEVE 100
|
||||
|
||||
typedef enum {
|
||||
DB_RESPONSE_ERROR,
|
||||
DB_RESPONSE_EMPTY,
|
||||
DB_RESPONSE_SUCCESS
|
||||
} db_history_result_t;
|
||||
|
||||
gboolean log_database_init(ProfAccount* account);
|
||||
void log_database_add_incoming(ProfMessage* message);
|
||||
void log_database_add_outgoing_chat(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
|
||||
void log_database_add_outgoing_muc(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
|
||||
void log_database_add_outgoing_muc_pm(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc);
|
||||
GSList* log_database_get_previous_chat(const gchar* const contact_barejid, const char* start_time, char* end_time, gboolean from_start, gboolean flip);
|
||||
db_history_result_t log_database_get_previous_chat(const gchar* const contact_barejid, const gchar* start_time, const gchar* end_time, gboolean from_start, gboolean flip, GSList** result);
|
||||
ProfMessage* log_database_get_limits_info(const gchar* const contact_barejid, gboolean is_last);
|
||||
void log_database_close(void);
|
||||
|
||||
|
||||
@@ -42,9 +42,11 @@
|
||||
#include "log.h"
|
||||
#include "chatlog.h"
|
||||
#include "database.h"
|
||||
#include "client_events.h"
|
||||
#include "config/preferences.h"
|
||||
#include "event/common.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "xmpp/session.h"
|
||||
@@ -177,7 +179,7 @@ cl_ev_send_msg_correct(ProfChatWin* chatwin, const char* const msg, const char*
|
||||
#ifdef HAVE_LIBOTR
|
||||
handled = otr_on_message_send(chatwin, message, request_receipt, replace_id);
|
||||
#endif
|
||||
if (!handled) {
|
||||
if (!handled && allow_unencrypted_message(chatwin, message)) {
|
||||
auto_char char* id = message_send_chat(chatwin->barejid, message, oob_url, request_receipt, replace_id);
|
||||
chat_log_msg_out(chatwin->barejid, message, NULL);
|
||||
log_database_add_outgoing_chat(id, chatwin->barejid, message, replace_id, PROF_MSG_ENC_NONE);
|
||||
@@ -251,3 +253,34 @@ cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char*
|
||||
plugins_post_priv_message_send(privwin->fulljid, message);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
allow_unencrypted_message(ProfChatWin* chatwin, const char* const msg)
|
||||
{
|
||||
if (!prefs_get_boolean(PREF_FORCE_ENCRYPTION)) {
|
||||
return TRUE; // Encryption not enforced
|
||||
}
|
||||
|
||||
auto_gchar gchar* force_enc_mode = prefs_get_string(PREF_FORCE_ENCRYPTION_MODE);
|
||||
|
||||
if (g_strcmp0(force_enc_mode, "block") == 0) {
|
||||
win_println((ProfWin*)chatwin, THEME_ERROR, "-", "Message not sent: encryption required. Enable (omemo/pgp/otr) encryption or /force-encryption off.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(force_enc_mode, "resend-to-confirm") == 0) {
|
||||
// We do not use chatwin->last_message because it should be set only if it's sent.
|
||||
guint msg_hash = g_str_hash(msg);
|
||||
if (msg_hash == chatwin->last_attempted_msg_hash) {
|
||||
chatwin->last_attempted_msg_hash = 0; // reset hash
|
||||
return TRUE;
|
||||
}
|
||||
win_println((ProfWin*)chatwin, THEME_ERROR, "-", "Message not sent: encryption required. Enable (omemo/pgp/otr) encryption or press Enter again to send without encryption. Use /force-encryption off to disable this protection.");
|
||||
chatwin->last_attempted_msg_hash = msg_hash;
|
||||
inp_set_line(msg); // reset message to prevent the need to retype it
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
win_println((ProfWin*)chatwin, THEME_ERROR, "-", "Message not sent: invalid encryption mode (%s). Use '/force-encryption policy resend-to-confirm'.", force_enc_mode);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -52,4 +52,8 @@ void cl_ev_send_muc_msg_corrected(ProfMucWin* mucwin, const char* const msg, con
|
||||
void cl_ev_send_muc_msg(ProfMucWin* mucwin, const char* const msg, const char* const oob_url);
|
||||
void cl_ev_send_priv_msg(ProfPrivateWin* privwin, const char* const msg, const char* const oob_url);
|
||||
|
||||
// Checks if an unencrypted message can be sent based on encryption preferences.
|
||||
// Returns TRUE if allowed, FALSE if blocked.
|
||||
gboolean allow_unencrypted_message(ProfChatWin* chatwin, const char* const msg);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -156,14 +156,7 @@ sv_ev_roster_received(void)
|
||||
if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) {
|
||||
cons_show_error("Invalid PGP key ID specified: %s, %s", account->pgp_keyid, err_str);
|
||||
}
|
||||
|
||||
// Redraw the screen after entry of the PGP secret key, but not init
|
||||
ProfWin* win = wins_get_current();
|
||||
auto_gchar gchar* theme = prefs_get_string(PREF_THEME);
|
||||
win_redraw(win);
|
||||
theme_init(theme);
|
||||
ui_resize();
|
||||
ui_show_roster();
|
||||
}
|
||||
account_free(account);
|
||||
#endif
|
||||
|
||||
@@ -664,7 +664,8 @@ p_gpg_decrypt(const char* const cipher)
|
||||
}
|
||||
gpgme_key_unref(key);
|
||||
} else if (error) {
|
||||
log_warning("GPGME error: %s", gpgme_strerror(error));
|
||||
// Emails are used only to fetch PGP recipients for debug logging. If something went wrong here, it's not worthy of warning.
|
||||
log_debug("GPGME error on gpgme_get_key(): %s", gpgme_strerror(error));
|
||||
}
|
||||
|
||||
if (recipient->next) {
|
||||
|
||||
@@ -86,10 +86,16 @@ python_get_version_number(void)
|
||||
return version_number;
|
||||
}
|
||||
|
||||
static void
|
||||
_unref_module(PyObject* module)
|
||||
{
|
||||
Py_XDECREF(module);
|
||||
}
|
||||
|
||||
void
|
||||
python_env_init(void)
|
||||
{
|
||||
loaded_modules = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)Py_XDECREF);
|
||||
loaded_modules = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_unref_module);
|
||||
|
||||
python_init_prof();
|
||||
|
||||
@@ -900,6 +906,8 @@ _python_type_error(ProfPlugin* plugin, char* hook, char* type)
|
||||
g_string_free(err_msg, TRUE);
|
||||
}
|
||||
|
||||
// Converts a Python string or None result to a C string and decreases the Python object's reference count.
|
||||
// If the result is NULL, or not a string/unicode/bytes/None, logs an error and returns NULL.
|
||||
static char*
|
||||
_handle_string_or_none_result(ProfPlugin* plugin, PyObject* result, char* hook)
|
||||
{
|
||||
@@ -910,18 +918,16 @@ _handle_string_or_none_result(ProfPlugin* plugin, PyObject* result, char* hook)
|
||||
}
|
||||
#ifdef PY_IS_PYTHON3
|
||||
if (result != Py_None && !PyUnicode_Check(result) && !PyBytes_Check(result)) {
|
||||
allow_python_threads();
|
||||
_python_type_error(plugin, hook, "string, unicode or None");
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if (result != Py_None && !PyUnicode_Check(result) && !PyString_Check(result)) {
|
||||
#endif
|
||||
Py_XDECREF(result);
|
||||
allow_python_threads();
|
||||
_python_type_error(plugin, hook, "string, unicode or None");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
char* result_str = python_str_or_unicode_to_string(result);
|
||||
Py_XDECREF(result);
|
||||
allow_python_threads();
|
||||
return result_str;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "config/tlscerts.h"
|
||||
#include "config/scripts.h"
|
||||
#include "command/cmd_defs.h"
|
||||
#include "tools/editor.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "event/client_events.h"
|
||||
#include "ui/ui.h"
|
||||
@@ -93,6 +94,9 @@ static void _connect_default(const char* const account);
|
||||
pthread_mutex_t lock;
|
||||
static gboolean force_quit = FALSE;
|
||||
|
||||
// main.c (prof_run section)
|
||||
gboolean background_mode = FALSE;
|
||||
|
||||
void
|
||||
prof_run(gchar* log_level, gchar* account_name, gchar* config_file, gchar* log_file, gchar* theme_name, gchar** commands)
|
||||
{
|
||||
@@ -118,42 +122,44 @@ prof_run(gchar* log_level, gchar* account_name, gchar* config_file, gchar* log_f
|
||||
log_stderr_handler();
|
||||
session_check_autoaway();
|
||||
|
||||
line = commands ? *commands : inp_readline();
|
||||
if (commands && line && memcmp(line, "/sleep", 6) == 0) {
|
||||
if (!g_timer_is_active(waittimer)) {
|
||||
gchar* err_msg;
|
||||
if (strtoi_range(line + 7, &waittime, 0, 300, &err_msg)) {
|
||||
g_timer_start(waittimer);
|
||||
/* Increase the minimal runtime by the waiting time
|
||||
* so we can be sure there's runtime left after executing
|
||||
* the last command.
|
||||
*/
|
||||
min_runtime += waittime;
|
||||
} else {
|
||||
log_error(err_msg);
|
||||
g_free(err_msg);
|
||||
commands = NULL;
|
||||
if (!background_mode) {
|
||||
line = commands ? *commands : inp_readline();
|
||||
if (commands && line && memcmp(line, "/sleep", 6) == 0) {
|
||||
if (!g_timer_is_active(waittimer)) {
|
||||
gchar* err_msg;
|
||||
if (strtoi_range(line + 7, &waittime, 0, 300, &err_msg)) {
|
||||
g_timer_start(waittimer);
|
||||
/* Increase the minimal runtime by the waiting time
|
||||
* so we can be sure there's runtime left after executing
|
||||
* the last command.
|
||||
*/
|
||||
min_runtime += waittime;
|
||||
} else {
|
||||
log_error(err_msg);
|
||||
g_free(err_msg);
|
||||
commands = NULL;
|
||||
}
|
||||
} else if (g_timer_elapsed(waittimer, NULL) >= waittime) {
|
||||
g_timer_stop(waittimer);
|
||||
commands++;
|
||||
if (!(*commands))
|
||||
commands = NULL;
|
||||
}
|
||||
cont = TRUE;
|
||||
} else if (line) {
|
||||
ProfWin* window = wins_get_current();
|
||||
cont = cmd_process_input(window, line);
|
||||
if (commands) {
|
||||
commands++;
|
||||
if (!(*commands))
|
||||
commands = NULL;
|
||||
} else {
|
||||
free(line);
|
||||
line = NULL;
|
||||
}
|
||||
} else if (g_timer_elapsed(waittimer, NULL) >= waittime) {
|
||||
g_timer_stop(waittimer);
|
||||
commands++;
|
||||
if (!(*commands))
|
||||
commands = NULL;
|
||||
}
|
||||
cont = TRUE;
|
||||
} else if (line) {
|
||||
ProfWin* window = wins_get_current();
|
||||
cont = cmd_process_input(window, line);
|
||||
if (commands) {
|
||||
commands++;
|
||||
if (!(*commands))
|
||||
commands = NULL;
|
||||
} else {
|
||||
free(line);
|
||||
line = NULL;
|
||||
cont = TRUE;
|
||||
}
|
||||
} else {
|
||||
cont = TRUE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
@@ -163,7 +169,12 @@ prof_run(gchar* log_level, gchar* account_name, gchar* config_file, gchar* log_f
|
||||
notify_remind();
|
||||
session_process_events();
|
||||
iq_autoping_check();
|
||||
ui_update();
|
||||
|
||||
editor_process(wins_get_current());
|
||||
|
||||
if (!background_mode) {
|
||||
ui_update();
|
||||
}
|
||||
#ifdef HAVE_GTK
|
||||
tray_update();
|
||||
#endif
|
||||
|
||||
@@ -140,6 +140,9 @@ aesgcm_file_get(void* userdata)
|
||||
"Downloading '%s' failed: Failed to decrypt "
|
||||
"file (%s).",
|
||||
https_url, gcry_strerror(crypt_res));
|
||||
} else {
|
||||
http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->id,
|
||||
"Decrypted file saved to '%s'", aesgcm_dl->filename);
|
||||
}
|
||||
|
||||
if (aesgcm_dl->cmd_template != NULL) {
|
||||
|
||||
@@ -38,15 +38,200 @@
|
||||
#include <fcntl.h>
|
||||
#include <glib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h> // necessary for readline
|
||||
#include <readline/readline.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "config/files.h"
|
||||
#include "config/preferences.h"
|
||||
#include "editor.h"
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
#include "ncurses.h"
|
||||
#include "ui/ui.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
|
||||
EditorTask editor_task = { 0, FALSE, NULL, NULL, PTHREAD_MUTEX_INITIALIZER, 0, NULL, NULL };
|
||||
|
||||
void*
|
||||
editor_thread(void* arg)
|
||||
{
|
||||
EditorTask* task = (EditorTask*)arg;
|
||||
auto_gcharv gchar** argv = g_strsplit(task->editor_cmd, " ", 0);
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
execvp(argv[0], argv);
|
||||
log_error("[Editor] Failed to exec %s", argv[0]);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&task->mutex);
|
||||
if (pid > 0) {
|
||||
task->pid = pid;
|
||||
int status;
|
||||
// Unlock mutex to avoid deadlock on the main loop
|
||||
pthread_mutex_unlock(&task->mutex);
|
||||
waitpid(pid, &status, 0);
|
||||
pthread_mutex_lock(&task->mutex);
|
||||
|
||||
gsize length;
|
||||
if (!g_file_get_contents(task->filename, &task->result, &length, &task->error)) {
|
||||
log_error("[Editor] could not read from %s: %s", task->filename,
|
||||
task->error ? task->error->message : "No GLib error given");
|
||||
task->result = g_strdup(""); // Ensure valid result
|
||||
} else {
|
||||
g_strchomp(task->result);
|
||||
if (remove(task->filename) != 0) {
|
||||
log_error("[Editor] error during file deletion of %s", task->filename);
|
||||
} else {
|
||||
log_debug("[Editor] deleted file: %s", task->filename);
|
||||
}
|
||||
}
|
||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||
task->error = g_error_new(G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
"Editor process failed with status %d", WEXITSTATUS(status));
|
||||
}
|
||||
} else {
|
||||
task->error = g_error_new(G_FILE_ERROR, G_FILE_ERROR_FAILED, "Fork failed: %s", strerror(errno));
|
||||
task->result = g_strdup(""); // Ensure valid result
|
||||
}
|
||||
|
||||
task->active = FALSE;
|
||||
pthread_mutex_unlock(&task->mutex);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Returns true if an error occurred
|
||||
gboolean
|
||||
get_message_from_editor_async(gchar* message)
|
||||
{
|
||||
// Check if editor is already running
|
||||
pthread_mutex_lock(&editor_task.mutex);
|
||||
if (editor_task.active) {
|
||||
pthread_mutex_unlock(&editor_task.mutex);
|
||||
log_error("[Editor] Editor already running");
|
||||
return TRUE;
|
||||
}
|
||||
pthread_mutex_unlock(&editor_task.mutex);
|
||||
|
||||
// Create temporary file
|
||||
auto_gchar gchar* filename = NULL;
|
||||
GError* glib_error = NULL;
|
||||
const char* jid = connection_get_barejid();
|
||||
if (jid) {
|
||||
filename = files_file_in_account_data_path(DIR_EDITOR, jid, "compose.md");
|
||||
} else {
|
||||
log_debug("[Editor] could not get JID");
|
||||
auto_gchar gchar* data_dir = files_get_data_path(DIR_EDITOR);
|
||||
if (!create_dir(data_dir)) {
|
||||
log_error("[Editor] could not create directory %s", data_dir);
|
||||
return TRUE;
|
||||
}
|
||||
filename = g_strdup_printf("%s/compose.md", data_dir);
|
||||
}
|
||||
if (!filename) {
|
||||
log_error("[Editor] something went wrong while creating compose file");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Write message to file
|
||||
gsize messagelen = message ? strlen(message) : 0;
|
||||
if (!g_file_set_contents(filename, message ? message : "", messagelen, &glib_error)) {
|
||||
log_error("[Editor] could not write to %s: %s", filename,
|
||||
glib_error ? glib_error->message : "No GLib error given");
|
||||
if (glib_error) {
|
||||
g_error_free(glib_error);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Prepare editor command
|
||||
auto_gchar gchar* editor = prefs_get_string(PREF_COMPOSE_EDITOR);
|
||||
auto_gchar gchar* editor_with_filename = g_strdup_printf("%s %s", editor, filename);
|
||||
|
||||
// Suspend NCurses
|
||||
def_prog_mode();
|
||||
endwin();
|
||||
|
||||
// Initialize thread task
|
||||
pthread_mutex_lock(&editor_task.mutex);
|
||||
editor_task.active = TRUE;
|
||||
editor_task.result = NULL;
|
||||
editor_task.error = NULL;
|
||||
g_free(editor_task.filename);
|
||||
g_free(editor_task.editor_cmd);
|
||||
editor_task.filename = g_strdup(filename);
|
||||
editor_task.editor_cmd = g_strdup(editor_with_filename);
|
||||
pthread_mutex_unlock(&editor_task.mutex);
|
||||
|
||||
// Set background mode
|
||||
background_mode = TRUE;
|
||||
log_debug("[Editor] Entering background mode");
|
||||
|
||||
// Start editor thread
|
||||
if (pthread_create(&editor_task.thread, NULL, editor_thread, &editor_task) != 0) {
|
||||
pthread_mutex_lock(&editor_task.mutex);
|
||||
editor_task.active = FALSE;
|
||||
editor_task.error = g_error_new(G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
"Failed to create editor thread: %s", strerror(errno));
|
||||
g_free(editor_task.filename);
|
||||
g_free(editor_task.editor_cmd);
|
||||
editor_task.filename = NULL;
|
||||
editor_task.editor_cmd = NULL;
|
||||
pthread_mutex_unlock(&editor_task.mutex);
|
||||
background_mode = FALSE;
|
||||
log_debug("[Editor] Exiting background mode");
|
||||
reset_prog_mode();
|
||||
doupdate();
|
||||
log_error("[Editor] Failed to create editor thread");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
editor_process(ProfWin* window)
|
||||
{
|
||||
pthread_mutex_lock(&editor_task.mutex);
|
||||
if (editor_task.active) {
|
||||
pthread_mutex_unlock(&editor_task.mutex);
|
||||
return;
|
||||
}
|
||||
if (!editor_task.result) {
|
||||
pthread_mutex_unlock(&editor_task.mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
g_strchomp(editor_task.result);
|
||||
rl_replace_line(editor_task.result, 0);
|
||||
rl_point = rl_end;
|
||||
rl_forced_update_display();
|
||||
reset_prog_mode();
|
||||
doupdate();
|
||||
ui_resize();
|
||||
g_free(editor_task.result);
|
||||
g_free(editor_task.filename);
|
||||
g_free(editor_task.editor_cmd);
|
||||
editor_task.result = NULL;
|
||||
editor_task.filename = NULL;
|
||||
editor_task.editor_cmd = NULL;
|
||||
if (editor_task.error) {
|
||||
log_error("[Editor] %s", editor_task.error->message);
|
||||
g_error_free(editor_task.error);
|
||||
editor_task.error = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&editor_task.mutex);
|
||||
background_mode = FALSE;
|
||||
log_debug("[Editor] Exiting background mode");
|
||||
}
|
||||
|
||||
// Deprecated synchronous editor call. Returns a message as returned_message.
|
||||
// Please avoid using it, since it blocks execution of the message handling and other important functionality until the editor is closed.
|
||||
// Returns true if an error occurred
|
||||
gboolean
|
||||
get_message_from_editor(gchar* message, gchar** returned_message)
|
||||
|
||||
@@ -37,8 +37,24 @@
|
||||
#ifndef TOOLS_EDITOR_H
|
||||
#define TOOLS_EDITOR_H
|
||||
|
||||
#include "ui/win_types.h"
|
||||
#include <glib.h>
|
||||
typedef struct
|
||||
{
|
||||
pid_t pid; // Editor process PID
|
||||
gboolean active; // Thread running
|
||||
gchar* result; // Edited message
|
||||
GError* error; // Error if any
|
||||
pthread_mutex_t mutex; // Protect access
|
||||
pthread_t thread; // Editor thread
|
||||
gchar* filename; // Temporary file path
|
||||
gchar* editor_cmd; // Editor command with filename
|
||||
} EditorTask;
|
||||
|
||||
extern EditorTask editor_task;
|
||||
|
||||
gboolean get_message_from_editor(gchar* message, gchar** returned_message);
|
||||
gboolean get_message_from_editor_async(gchar* message);
|
||||
void editor_process(ProfWin* window);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,40 +1,36 @@
|
||||
/*
|
||||
* buffer.c
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*
|
||||
* Message buffer implementation for CProof.
|
||||
*
|
||||
* This module provides an in-memory buffer for managing active chat entries in the
|
||||
* console-based XMPP client. Separate from persistent SQLite storage, it holds
|
||||
* messages and metadata solely for UI rendering, ensuring responsive scrolling and
|
||||
* display without exceeding ncurses pad limits (10k lines). By tracking rendered
|
||||
* line counts per entry, it proactively trims content to prevent overflow, enabling
|
||||
* seamless integration with ncurses for position-aware rendering.
|
||||
*
|
||||
* Key features and operations:
|
||||
* - Append/prepend entries (messages) with automatic line-based cleanup.
|
||||
* - Track cumulative lines for overflow prevention and efficient buffer sizing.
|
||||
* - Remove entries by ID or index; mark delivery receipts as received.
|
||||
* - Retrieve entries by index or ID for rendering and history queries.
|
||||
* - Store metadata including timestamps, senders, themes, and ncurses y-positions.
|
||||
*
|
||||
* CProof. Fork of Profanity (since 2025).
|
||||
*
|
||||
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
||||
* Copyright (C) 2019 - 2025 Michael Vetter <jubalh@iodoru.org>
|
||||
* Copyright (C) 2025 CProof Developers
|
||||
*
|
||||
* This file is part of Profanity.
|
||||
*
|
||||
* Profanity is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Profanity is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link the code of portions of this program with the OpenSSL library under
|
||||
* certain conditions as described in each individual source file, and
|
||||
* distribute linked combinations including the two.
|
||||
*
|
||||
* You must obey the GNU General Public License in all respects for all of the
|
||||
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
||||
* may extend this exception to your version of the file(s), but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version. If you delete this exception statement from all
|
||||
* source files in the program, then also delete it here.
|
||||
* Licensed under the GNU General Public License, version 3,
|
||||
* with the OpenSSL exception. See LICENSE for details.
|
||||
*
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ui/window_list.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -54,15 +50,8 @@
|
||||
#include "ui/window.h"
|
||||
#include "ui/buffer.h"
|
||||
|
||||
#define MAX_BUFFER_SIZE 200
|
||||
#define STRDUP_OR_NULL(str) ((str) ? strdup(str) : NULL)
|
||||
|
||||
struct prof_buff_t
|
||||
{
|
||||
GSList* entries;
|
||||
int lines;
|
||||
};
|
||||
|
||||
static void _free_entry(ProfBuffEntry* entry);
|
||||
static ProfBuffEntry* _create_entry(const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message, DeliveryReceipt* receipt, const char* const id, int y_start_pos, int y_end_pos);
|
||||
static void _buffer_add(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message, DeliveryReceipt* receipt, const char* const id, int y_start_pos, int y_end_pos, gboolean append);
|
||||
@@ -108,16 +97,24 @@ _buffer_add(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* t
|
||||
|
||||
buffer->lines += e->_lines;
|
||||
|
||||
while (g_slist_length(buffer->entries) >= MAX_BUFFER_SIZE) {
|
||||
// With 10% margin to ensure overflow prevention
|
||||
while (buffer->lines >= PAD_SIZE - (PAD_SIZE / 10) && g_slist_length(buffer->entries) > 1) {
|
||||
// Delete message from the opposite size to free buffer
|
||||
GSList* buffer_entry_to_delete = append ? buffer->entries : g_slist_last(buffer->entries);
|
||||
ProfBuffEntry* entry_to_delete = (ProfBuffEntry*)buffer_entry_to_delete->data;
|
||||
// log_debug("(Messages left in buffer: %d) DELETING: %s", g_slist_length(buffer->entries), entry_to_delete->id);
|
||||
buffer->lines -= entry_to_delete->_lines;
|
||||
_free_entry(entry_to_delete);
|
||||
buffer->entries = g_slist_delete_link(buffer->entries, buffer_entry_to_delete);
|
||||
}
|
||||
|
||||
if (from_jid && y_end_pos == y_start_pos) {
|
||||
log_warning("Ncurses Overflow! From: %s, pos: %d, ID: %s, message: %s", from_jid, y_end_pos, id, message);
|
||||
// win_redraw will redraw with entries above removed,
|
||||
// it will also recalculate actual size of the message that caused overflow
|
||||
int old_lines = buffer->lines;
|
||||
win_redraw(wins_get_current());
|
||||
log_debug("Ncurses Overflow! From: %s, position: %d, ID: %s, append: %s, used message buffer size: %d, rendered lines: (old: %d/ actual: %d/ max: %d)",
|
||||
from_jid, y_start_pos, id, append ? "TRUE" : "FALSE", g_slist_length(buffer->entries), old_lines, buffer->lines, PAD_SIZE);
|
||||
}
|
||||
|
||||
buffer->entries = append ? g_slist_append(buffer->entries, e) : g_slist_prepend(buffer->entries, e);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "glib.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "window_list.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
@@ -423,9 +424,11 @@ chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, const char
|
||||
win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, display_message);
|
||||
}
|
||||
|
||||
// save last id and message for LMC in case if it's not LMC message
|
||||
if (id && !replace_id) {
|
||||
_chatwin_set_last_message(chatwin, id, display_message);
|
||||
// Save last id and message for LMC
|
||||
// Note: if the same message is to be corrected several times, the id of the original message is used in each case
|
||||
// https://xmpp.org/extensions/xep-0308.html#rules
|
||||
if (id) {
|
||||
_chatwin_set_last_message(chatwin, replace_id ?: id, display_message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,7 +564,8 @@ static void
|
||||
_chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid)
|
||||
{
|
||||
if (!chatwin->history_shown) {
|
||||
GSList* history = log_database_get_previous_chat(contact_barejid, NULL, NULL, FALSE, FALSE);
|
||||
GSList* history = NULL;
|
||||
log_database_get_previous_chat(contact_barejid, NULL, NULL, FALSE, FALSE, &history);
|
||||
GSList* curr = history;
|
||||
|
||||
while (curr) {
|
||||
@@ -583,15 +587,17 @@ _chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid)
|
||||
// Print history starting from start_time to end_time if end_time is null the
|
||||
// first entry's timestamp in the buffer is used. Flip true to prepend to buffer.
|
||||
// Timestamps should be in iso8601
|
||||
gboolean
|
||||
chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time, gboolean flip)
|
||||
db_history_result_t
|
||||
chatwin_db_history(ProfChatWin* chatwin, const gchar* start_time, const gchar* end_time, gboolean flip)
|
||||
{
|
||||
if (!end_time) {
|
||||
end_time = buffer_size(((ProfWin*)chatwin)->layout->buffer) == 0 ? NULL : g_date_time_format_iso8601(buffer_get_entry(((ProfWin*)chatwin)->layout->buffer, 0)->time);
|
||||
auto_gchar gchar* _end_time = NULL;
|
||||
if (!end_time && buffer_size(((ProfWin*)chatwin)->layout->buffer) > 0) {
|
||||
_end_time = g_date_time_format_iso8601(buffer_get_entry(((ProfWin*)chatwin)->layout->buffer, 0)->time);
|
||||
end_time = _end_time;
|
||||
}
|
||||
|
||||
GSList* history = log_database_get_previous_chat(chatwin->barejid, start_time, end_time, !flip, flip);
|
||||
gboolean has_items = g_slist_length(history) != 0;
|
||||
GSList* history = NULL;
|
||||
db_history_result_t result = log_database_get_previous_chat(chatwin->barejid, start_time, end_time, !flip, flip, &history);
|
||||
GSList* curr = history;
|
||||
|
||||
while (curr) {
|
||||
@@ -610,17 +616,24 @@ chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time,
|
||||
}
|
||||
|
||||
g_slist_free_full(history, (GDestroyNotify)message_free);
|
||||
// TODO: Potential optimization
|
||||
// if (flip)
|
||||
// since adding messages to history without overflowing buffer does not require a win_redraw
|
||||
win_redraw((ProfWin*)chatwin);
|
||||
|
||||
return has_items;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
_chatwin_set_last_message(ProfChatWin* chatwin, const char* const id, const char* const message)
|
||||
{
|
||||
free(chatwin->last_message);
|
||||
chatwin->last_message = strdup(message);
|
||||
if (message && chatwin->last_message != message) {
|
||||
free(chatwin->last_message);
|
||||
chatwin->last_message = strdup(message);
|
||||
}
|
||||
|
||||
free(chatwin->last_msg_id);
|
||||
chatwin->last_msg_id = strdup(id);
|
||||
if (id && chatwin->last_msg_id != id) {
|
||||
free(chatwin->last_msg_id);
|
||||
chatwin->last_msg_id = strdup(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,16 +387,9 @@ cons_about(void)
|
||||
_cons_splash_logo();
|
||||
} else {
|
||||
auto_gchar gchar* prof_version = prof_get_version();
|
||||
win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %s", prof_version);
|
||||
win_println(console, THEME_DEFAULT, "-", "Welcome to CProof, version %s", prof_version);
|
||||
}
|
||||
|
||||
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>.");
|
||||
win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2019 - 2025 Michael Vetter <jubalh@iodoru.org>.");
|
||||
win_println(console, THEME_DEFAULT, "-", "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>");
|
||||
win_println(console, THEME_DEFAULT, "-", "");
|
||||
win_println(console, THEME_DEFAULT, "-", "This is free software; you are free to change and redistribute it.");
|
||||
win_println(console, THEME_DEFAULT, "-", "There is NO WARRANTY, to the extent permitted by law.");
|
||||
win_println(console, THEME_DEFAULT, "-", "");
|
||||
win_println(console, THEME_DEFAULT, "-", "Type '/help' to show complete help.");
|
||||
win_println(console, THEME_DEFAULT, "-", "");
|
||||
|
||||
@@ -484,7 +477,7 @@ cons_show_wins(gboolean unread)
|
||||
}
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
g_slist_free_full(window_strings, free);
|
||||
g_slist_free_full(window_strings, g_free);
|
||||
|
||||
cons_alert(NULL);
|
||||
}
|
||||
@@ -505,7 +498,7 @@ cons_show_wins_attention()
|
||||
}
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
g_slist_free_full(window_strings, free);
|
||||
g_slist_free_full(window_strings, g_free);
|
||||
|
||||
cons_alert(NULL);
|
||||
}
|
||||
@@ -2704,13 +2697,12 @@ _cons_splash_logo(void)
|
||||
ProfWin* console = wins_get_console();
|
||||
win_println(console, THEME_DEFAULT, "-", "Welcome to");
|
||||
|
||||
win_println(console, THEME_SPLASH, "-", " ___ _ ");
|
||||
win_println(console, THEME_SPLASH, "-", " / __) (_)_ ");
|
||||
win_println(console, THEME_SPLASH, "-", " ____ ___ ___ | |__ ____ ____ _| |_ _ _ ");
|
||||
win_println(console, THEME_SPLASH, "-", "| _ \\ / __) _ \\| __) _ | _ \\| | _) | | |");
|
||||
win_println(console, THEME_SPLASH, "-", "| | ) | | | (_) | | | ( | | | | | | |_| |_| |");
|
||||
win_println(console, THEME_SPLASH, "-", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |");
|
||||
win_println(console, THEME_SPLASH, "-", "|_| (____/ ");
|
||||
win_println(console, THEME_SPLASH, "-", " _____ _____ __ ");
|
||||
win_println(console, THEME_SPLASH, "-", " / ____| __ \\ / _|");
|
||||
win_println(console, THEME_SPLASH, "-", " | | | |__) | __ ___ ___ | |_ ");
|
||||
win_println(console, THEME_SPLASH, "-", " | | | ___/ '__/ _ \\ / _ \\| _|");
|
||||
win_println(console, THEME_SPLASH, "-", " | |____| | | | | (_) | (_) | | ");
|
||||
win_println(console, THEME_SPLASH, "-", " \\_____|_| |_| \\___/ \\___/|_| ");
|
||||
win_println(console, THEME_SPLASH, "-", "");
|
||||
|
||||
auto_gchar gchar* prof_version = prof_get_version();
|
||||
@@ -2899,3 +2891,11 @@ cons_privacy_setting(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cons_encryption_setting(void)
|
||||
{
|
||||
cons_show("Force encryption : %sabled", prefs_get_boolean(PREF_FORCE_ENCRYPTION) ? "en" : "dis");
|
||||
|
||||
cons_show("Force encryption mode : %s", prefs_get_string(PREF_FORCE_ENCRYPTION_MODE));
|
||||
}
|
||||
|
||||
@@ -170,6 +170,29 @@ create_input_window(void)
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_inp_slashguard_check(void)
|
||||
{
|
||||
if (get_password)
|
||||
return false;
|
||||
/* ignore empty and quoted messages */
|
||||
if (inp_line == NULL || inp_line[0] == '\0' || inp_line[0] == '>')
|
||||
return false;
|
||||
if (!prefs_get_boolean(PREF_SLASH_GUARD))
|
||||
return false;
|
||||
size_t n = 1;
|
||||
while (inp_line[n] != '\0' && n < 4) {
|
||||
if (inp_line[n] == '/') {
|
||||
cons_show("Your text contains a slash in the first 4 characters");
|
||||
free(inp_line);
|
||||
inp_line = NULL;
|
||||
return true;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
char*
|
||||
inp_readline(void)
|
||||
{
|
||||
@@ -203,17 +226,7 @@ inp_readline(void)
|
||||
chat_state_idle();
|
||||
}
|
||||
|
||||
if (inp_line) {
|
||||
if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) {
|
||||
// ignore quoted messages
|
||||
if (strlen(inp_line) > 1 && inp_line[0] != '>') {
|
||||
char* res = (char*)memchr(inp_line + 1, '/', 3);
|
||||
if (res) {
|
||||
cons_show("Your text contains a slash in the first 4 characters");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inp_line && !_inp_slashguard_check()) {
|
||||
char* ret = inp_line;
|
||||
inp_line = NULL;
|
||||
return ret;
|
||||
@@ -294,6 +307,14 @@ inp_get_line(void)
|
||||
return line;
|
||||
}
|
||||
|
||||
void
|
||||
inp_set_line(const char* const new_line)
|
||||
{
|
||||
rl_replace_line(new_line, 1);
|
||||
rl_point = rl_end;
|
||||
_inp_redisplay();
|
||||
}
|
||||
|
||||
char*
|
||||
inp_get_password(void)
|
||||
{
|
||||
@@ -974,14 +995,7 @@ _inp_rl_send_to_editor(int count, int key)
|
||||
|
||||
auto_gchar gchar* message = NULL;
|
||||
|
||||
if (get_message_from_editor(rl_line_buffer, &message)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rl_replace_line(message, 0);
|
||||
ui_resize();
|
||||
rl_point = rl_end;
|
||||
rl_forced_update_display();
|
||||
get_message_from_editor_async(rl_line_buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -46,5 +46,6 @@ void inp_win_resize(void);
|
||||
void inp_put_back(void);
|
||||
char* inp_get_password(void);
|
||||
char* inp_get_line(void);
|
||||
void inp_set_line(const char* const new_line);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "config/account.h"
|
||||
#include "config/preferences.h"
|
||||
#include "command/cmd_funcs.h"
|
||||
#include "database.h"
|
||||
#include "ui/win_types.h"
|
||||
#include "xmpp/message.h"
|
||||
#include "xmpp/muc.h"
|
||||
@@ -145,7 +146,7 @@ void chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch);
|
||||
void chatwin_unset_incoming_char(ProfChatWin* chatwin);
|
||||
void chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch);
|
||||
void chatwin_unset_outgoing_char(ProfChatWin* chatwin);
|
||||
gboolean chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time, gboolean flip);
|
||||
db_history_result_t chatwin_db_history(ProfChatWin* chatwin, const gchar* start_time, const gchar* end_time, gboolean flip);
|
||||
|
||||
// MUC window
|
||||
ProfMucWin* mucwin_new(const char* const barejid);
|
||||
@@ -288,7 +289,7 @@ void cons_show_disco_info(const char* from, GSList* identities, GSList* features
|
||||
|
||||
void cons_show_disco_contact_information(GHashTable* addresses);
|
||||
|
||||
void cons_show_qrcode();
|
||||
void cons_show_qrcode(const char* const text);
|
||||
|
||||
void cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason);
|
||||
void cons_check_version(gboolean not_available_msg);
|
||||
@@ -350,6 +351,7 @@ void cons_theme_properties(void);
|
||||
void cons_theme_colours(void);
|
||||
void cons_show_tlscert(const TLSCertificate* cert);
|
||||
void cons_show_tlscert_summary(const TLSCertificate* cert);
|
||||
void cons_encryption_setting(void);
|
||||
|
||||
void cons_alert(ProfWin* alert_origin_window);
|
||||
void cons_remove_alert(ProfWin* window);
|
||||
|
||||
@@ -188,6 +188,7 @@ typedef struct prof_chat_win_t
|
||||
char* last_message;
|
||||
char* last_msg_id;
|
||||
gboolean has_attention;
|
||||
guint last_attempted_msg_hash;
|
||||
} ProfChatWin;
|
||||
|
||||
typedef struct prof_muc_win_t
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "database.h"
|
||||
#include "ui/window_list.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -62,9 +63,8 @@
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
|
||||
static const int PAD_SIZE = 100;
|
||||
static const char* LOADING_MESSAGE = "Loading older messages…";
|
||||
static const char* CONS_WIN_TITLE = "Profanity. Type /help for help information.";
|
||||
static const char* CONS_WIN_TITLE = "CProof. Type /help for help information.";
|
||||
static const char* XML_WIN_TITLE = "XML Console";
|
||||
|
||||
#define CEILING(X) (X - (int)(X) > 0 ? (int)(X + 1) : (int)(X))
|
||||
@@ -164,6 +164,7 @@ win_create_chat(const char* const barejid)
|
||||
new_win->last_message = NULL;
|
||||
new_win->last_msg_id = NULL;
|
||||
new_win->has_attention = FALSE;
|
||||
new_win->last_attempted_msg_hash = 0;
|
||||
new_win->memcheck = PROFCHATWIN_MEMCHECK;
|
||||
|
||||
return &new_win->window;
|
||||
@@ -629,54 +630,68 @@ win_free(ProfWin* window)
|
||||
void
|
||||
win_page_up(ProfWin* window, int scroll_size)
|
||||
{
|
||||
// Page offset from the start of the NCurses PAD (invisible window)
|
||||
int* page_start = &(window->layout->y_pos);
|
||||
int page_start_initial = *page_start;
|
||||
int total_rows = getcury(window->layout->win);
|
||||
// Size of the visible chat page
|
||||
int page_space = getmaxy(stdscr) - 4;
|
||||
if (scroll_size == 0)
|
||||
scroll_size = page_space;
|
||||
win_scroll_state_t* scroll_state = &window->scroll_state;
|
||||
*scroll_state = (*scroll_state == WIN_SCROLL_REACHED_BOTTOM) ? WIN_SCROLL_INNER : *scroll_state;
|
||||
*page_start -= scroll_size;
|
||||
gboolean has_scroll_past_buffer = *page_start < 0;
|
||||
|
||||
if (*page_start == -scroll_size && window->type == WIN_CHAT) {
|
||||
if (has_scroll_past_buffer && window->type == WIN_CHAT) {
|
||||
ProfChatWin* chatwin = (ProfChatWin*)window;
|
||||
ProfBuffEntry* first_entry = buffer_size(window->layout->buffer) != 0 ? buffer_get_entry(window->layout->buffer, 0) : NULL;
|
||||
|
||||
// Don't do anything if still fetching mam messages
|
||||
if (first_entry && !(first_entry->theme_item == THEME_ROOMINFO && g_strcmp0(first_entry->message, LOADING_MESSAGE) == 0)) {
|
||||
gboolean is_still_fetching_mam = first_entry && (first_entry->theme_item == THEME_ROOMINFO && g_strcmp0(first_entry->message, LOADING_MESSAGE) == 0);
|
||||
if (!is_still_fetching_mam) {
|
||||
// WIN_SCROLL_REACHED_TOP means that we reached top of DB and there is no need to refetch data from it
|
||||
gboolean is_db_offset_jump_needed = false;
|
||||
if (*scroll_state != WIN_SCROLL_REACHED_TOP) {
|
||||
*scroll_state = !chatwin_db_history(chatwin, NULL, NULL, TRUE) ? WIN_SCROLL_REACHED_TOP : WIN_SCROLL_INNER;
|
||||
db_history_result_t db_response = chatwin_db_history(chatwin, NULL, NULL, TRUE);
|
||||
is_db_offset_jump_needed = db_response == DB_RESPONSE_SUCCESS;
|
||||
*scroll_state = db_response == DB_RESPONSE_EMPTY ? WIN_SCROLL_REACHED_TOP : WIN_SCROLL_INNER;
|
||||
log_debug("Scroll state after DB history fetch: %s", *scroll_state ? "WIN_SCROLL_REACHED_TOP" : "WIN_SCROLL_INNER");
|
||||
}
|
||||
|
||||
if (*scroll_state == WIN_SCROLL_REACHED_TOP && prefs_get_boolean(PREF_MAM)) {
|
||||
win_print_loading_history(window);
|
||||
iq_mam_request_older(chatwin);
|
||||
if (*scroll_state == WIN_SCROLL_REACHED_TOP) {
|
||||
*page_start = 0;
|
||||
if (prefs_get_boolean(PREF_MAM)) {
|
||||
win_print_loading_history(window);
|
||||
iq_mam_request_older(chatwin);
|
||||
}
|
||||
}
|
||||
|
||||
int buff_size = buffer_size(window->layout->buffer);
|
||||
int offset_entry_id = buff_size > 10 ? 10 : buff_size - 1;
|
||||
int offset = buffer_get_entry(window->layout->buffer, offset_entry_id)->y_end_pos;
|
||||
*page_start = offset - page_space;
|
||||
// Recalculate scroll offset after loading older messages from the DB.
|
||||
// *page_start may become negative due to paging up beyond the current buffer.
|
||||
// To maintain smooth scroll positioning, we adjust it relative to the visual offset
|
||||
// (y_start_pos) of the first buffer entry *before* DB fetch.
|
||||
// This ensures a seamless transition as older messages are prepended, regardless
|
||||
// of how many visual lines they occupy (since messages can vary in height).
|
||||
// For example, if *page_start == -5 and first_entry->y_start_pos == 40,
|
||||
// we shift the scroll to 35, preserving the visual context for the user.
|
||||
if (is_db_offset_jump_needed) {
|
||||
*page_start = first_entry ? first_entry->y_start_pos + *page_start : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// went past beginning, show first page
|
||||
if (*page_start < 0) {
|
||||
log_debug("win_page_up(): *page_start adjusted to 0 due to negative value (expected if insufficient history messages). Previous value: %d", *page_start);
|
||||
*page_start = 0;
|
||||
}
|
||||
|
||||
window->layout->paged = 1;
|
||||
|
||||
// update only if position has changed
|
||||
// Update window location only if position has changed
|
||||
if (page_start_initial != *page_start) {
|
||||
win_update_virtual(window);
|
||||
}
|
||||
|
||||
// switch off page if last line and space line visible
|
||||
if ((total_rows) - *page_start == page_space) {
|
||||
window->layout->paged = 0;
|
||||
}
|
||||
// Update scrolling state
|
||||
int total_rows = getcury(window->layout->win);
|
||||
window->layout->paged = (total_rows) - *page_start > page_space;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -696,20 +711,22 @@ win_page_down(ProfWin* window, int scroll_size)
|
||||
// Scrolled down after reaching the bottom of the page
|
||||
if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) {
|
||||
int bf_size = buffer_size(window->layout->buffer);
|
||||
if (bf_size > 0) {
|
||||
if (bf_size > 0 && *scroll_state != WIN_SCROLL_REACHED_BOTTOM) {
|
||||
// How many lines are left until end of the screen
|
||||
int current_offset = total_rows - *page_start;
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
ProfBuffEntry* last_entry = buffer_get_entry(window->layout->buffer, bf_size - 1);
|
||||
auto_gchar gchar* start = g_date_time_format_iso8601(last_entry->time);
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
gchar* end_date = g_date_time_format_iso8601(now);
|
||||
g_date_time_unref(now);
|
||||
if (*scroll_state != WIN_SCROLL_REACHED_BOTTOM && !chatwin_db_history((ProfChatWin*)window, start, end_date, FALSE)) {
|
||||
auto_gchar gchar* end_date = g_date_time_format_iso8601(now);
|
||||
db_history_result_t db_response = chatwin_db_history((ProfChatWin*)window, start, end_date, FALSE);
|
||||
if (db_response == DB_RESPONSE_EMPTY)
|
||||
*scroll_state = WIN_SCROLL_REACHED_BOTTOM;
|
||||
} else if (*scroll_state == WIN_SCROLL_REACHED_BOTTOM) {
|
||||
g_free(end_date);
|
||||
}
|
||||
|
||||
int offset = last_entry->y_end_pos - 1;
|
||||
*page_start = offset - page_space + scroll_size;
|
||||
// similar to page_up (see explanation there)
|
||||
// Get offset of the message that was the latest prior to loading messages from the DB
|
||||
int original_pos = last_entry->y_end_pos;
|
||||
*page_start = original_pos - current_offset;
|
||||
g_date_time_unref(now);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1986,6 +2003,10 @@ win_redraw(ProfWin* window)
|
||||
_win_print_internal(window, e->show_char, e->pad_indent, e->time, e->flags, e->theme_item, e->display_from, e->message, e->receipt);
|
||||
}
|
||||
e->y_end_pos = getcury(window->layout->win);
|
||||
// Recalculate lines (might be incorrect in case of NCurses overflow)
|
||||
window->layout->buffer->lines -= e->_lines;
|
||||
e->_lines = e->y_end_pos - e->y_start_pos;
|
||||
window->layout->buffer->lines += e->_lines;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,9 @@
|
||||
#include "xmpp/contact.h"
|
||||
#include "xmpp/muc.h"
|
||||
|
||||
// Max lines per window rendered by NCurses
|
||||
static const int PAD_SIZE = 10000;
|
||||
|
||||
void win_move_to_end(ProfWin* window);
|
||||
void win_show_status_string(ProfWin* window, const char* const from,
|
||||
const char* const show, const char* const status,
|
||||
|
||||
@@ -258,22 +258,20 @@ GList*
|
||||
wins_get_private_chats(const char* const roomjid)
|
||||
{
|
||||
GList* result = NULL;
|
||||
GString* prefix = g_string_new(roomjid);
|
||||
g_string_append(prefix, "/");
|
||||
auto_gchar gchar* prefix = g_strdup_printf("%s/", roomjid);
|
||||
GList* curr = values;
|
||||
|
||||
while (curr) {
|
||||
ProfWin* window = curr->data;
|
||||
if (window->type == WIN_PRIVATE) {
|
||||
ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
|
||||
if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix->str)) {
|
||||
if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix)) {
|
||||
result = g_list_append(result, privatewin);
|
||||
}
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
g_string_free(prefix, TRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1067,19 +1065,13 @@ wins_create_summary(gboolean unread)
|
||||
while (curr) {
|
||||
ProfWin* window = g_hash_table_lookup(windows, curr->data);
|
||||
if (!unread || (unread && win_unread(window) > 0)) {
|
||||
GString* line = g_string_new("");
|
||||
|
||||
int ui_index = GPOINTER_TO_INT(curr->data);
|
||||
auto_gchar gchar* winstring = win_to_string(window);
|
||||
if (!winstring) {
|
||||
g_string_free(line, TRUE);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_string_append_printf(line, "%d: %s", ui_index, winstring);
|
||||
|
||||
result = g_slist_append(result, strdup(line->str));
|
||||
g_string_free(line, TRUE);
|
||||
gchar* line = g_strdup_printf("%d: %s", ui_index, winstring);
|
||||
result = g_slist_append(result, line);
|
||||
}
|
||||
|
||||
curr = g_list_next(curr);
|
||||
@@ -1108,19 +1100,13 @@ wins_create_summary_attention()
|
||||
has_attention = mucwin->has_attention;
|
||||
}
|
||||
if (has_attention) {
|
||||
GString* line = g_string_new("");
|
||||
|
||||
int ui_index = GPOINTER_TO_INT(curr->data);
|
||||
auto_gchar gchar* winstring = win_to_string(window);
|
||||
if (!winstring) {
|
||||
g_string_free(line, TRUE);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_string_append_printf(line, "%d: %s", ui_index, winstring);
|
||||
|
||||
result = g_slist_append(result, strdup(line->str));
|
||||
g_string_free(line, TRUE);
|
||||
gchar* line = g_strdup_printf("%d: %s", ui_index, winstring);
|
||||
result = g_slist_append(result, line);
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
@@ -119,6 +119,14 @@ caps_init(void)
|
||||
g_hash_table_add(prof_features, strdup(STANZA_NS_LAST_MESSAGE_CORRECTION));
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_MOOD)) {
|
||||
g_hash_table_add(prof_features, strdup(STANZA_NS_MOOD_NOTIFY));
|
||||
}
|
||||
|
||||
#ifdef HAVE_OMEMO
|
||||
g_hash_table_add(prof_features, strdup(XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY));
|
||||
#endif
|
||||
|
||||
my_sha1 = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -2752,6 +2752,22 @@ iq_mam_request(ProfChatWin* win, GDateTime* enddate)
|
||||
return;
|
||||
}
|
||||
|
||||
// Trim the last 3 characters from the datetime string to remove unwanted suffix (timezone offset)
|
||||
static void
|
||||
_truncate_datetime_suffix(gchar* str)
|
||||
{
|
||||
if (!str) {
|
||||
log_warning("_truncate_datetime_suffix(): unexpected null datetime string");
|
||||
return;
|
||||
}
|
||||
size_t len = strlen(str);
|
||||
if (len >= 3) {
|
||||
str[len - 3] = '\0';
|
||||
} else {
|
||||
log_warning("_truncate_datetime_suffix(): unexpected short datetime string: %s", str);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
@@ -2773,17 +2789,17 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
|
||||
buffer_remove_entry(window->layout->buffer, 0);
|
||||
|
||||
auto_char char* start_str = NULL;
|
||||
auto_gchar gchar* start_str = NULL;
|
||||
if (data->start_datestr) {
|
||||
start_str = strdup(data->start_datestr);
|
||||
start_str = g_strdup(data->start_datestr);
|
||||
// Convert to iso8601
|
||||
start_str[strlen(start_str) - 3] = '\0';
|
||||
_truncate_datetime_suffix(start_str);
|
||||
}
|
||||
char* end_str = NULL;
|
||||
auto_gchar gchar* end_str = NULL;
|
||||
if (data->end_datestr) {
|
||||
end_str = strdup(data->end_datestr);
|
||||
end_str = g_strdup(data->end_datestr);
|
||||
// Convert to iso8601
|
||||
end_str[strlen(end_str) - 3] = '\0';
|
||||
_truncate_datetime_suffix(end_str);
|
||||
}
|
||||
|
||||
if (is_complete || !data->fetch_next) {
|
||||
|
||||
@@ -190,7 +190,7 @@ get_nick_from_full_jid(const char* const full_room_jid)
|
||||
/*
|
||||
* get the fulljid, fall back to the barejid
|
||||
*/
|
||||
char*
|
||||
const char*
|
||||
jid_fulljid_or_barejid(Jid* jid)
|
||||
{
|
||||
if (jid->fulljid) {
|
||||
|
||||
@@ -63,7 +63,7 @@ gboolean jid_is_valid_room_form(Jid* jid);
|
||||
char* create_fulljid(const char* const barejid, const char* const resource);
|
||||
char* get_nick_from_full_jid(const char* const full_room_jid);
|
||||
|
||||
char* jid_fulljid_or_barejid(Jid* jid);
|
||||
const char* jid_fulljid_or_barejid(Jid* jid);
|
||||
gchar* jid_random_resource(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -621,7 +621,7 @@ _available_handler(xmpp_stanza_t* const stanza)
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
|
||||
const char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
|
||||
log_debug("Presence available handler fired for: %s", jid);
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ _available_handler(xmpp_stanza_t* const stanza)
|
||||
XMPPCaps* caps = stanza_parse_caps(stanza);
|
||||
if ((g_strcmp0(my_jid->fulljid, xmpp_presence->jid->fulljid) != 0) && caps) {
|
||||
log_debug("Presence contains capabilities.");
|
||||
char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
|
||||
const char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
|
||||
_handle_caps(jid, caps);
|
||||
}
|
||||
stanza_free_caps(caps);
|
||||
@@ -644,7 +644,7 @@ _available_handler(xmpp_stanza_t* const stanza)
|
||||
const char* account_name = session_get_account_name();
|
||||
int max_sessions = accounts_get_max_sessions(account_name);
|
||||
if (max_sessions > 0) {
|
||||
const gchar* cur_resource = accounts_get_resource(account_name);
|
||||
auto_gchar gchar* cur_resource = accounts_get_resource(account_name);
|
||||
int res_count = connection_count_available_resources();
|
||||
if (res_count > max_sessions && g_strcmp0(cur_resource, resource->name)) {
|
||||
ProfWin* console = wins_get_console();
|
||||
|
||||
@@ -275,11 +275,8 @@ roster_remove(const char* const name, const char* const barejid)
|
||||
if (contact) {
|
||||
GList* resources = p_contact_get_available_resources(contact);
|
||||
while (resources) {
|
||||
GString* fulljid = g_string_new(barejid);
|
||||
g_string_append(fulljid, "/");
|
||||
g_string_append(fulljid, resources->data);
|
||||
autocomplete_remove(roster->fulljid_ac, fulljid->str);
|
||||
g_string_free(fulljid, TRUE);
|
||||
auto_gchar gchar* fulljid = g_strdup_printf("%s/%s", barejid, (char*)resources->data);
|
||||
autocomplete_remove(roster->fulljid_ac, fulljid);
|
||||
resources = g_list_next(resources);
|
||||
}
|
||||
g_list_free(resources);
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#include <glib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "prof_cmocka.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -281,7 +278,7 @@ shows_all_messages_in_console_when_window_not_focussed(void **state)
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
prof_input("/win 1");
|
||||
assert_true(prof_output_exact("Profanity. Type /help for help information."));
|
||||
assert_true(prof_output_exact("CProof. Type /help for help information."));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
@@ -322,7 +319,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
prof_input("/win 1");
|
||||
assert_true(prof_output_exact("Profanity. Type /help for help information."));
|
||||
assert_true(prof_output_exact("CProof. Type /help for help information."));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
@@ -368,7 +365,7 @@ shows_no_message_in_console_when_window_not_focussed(void **state)
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
prof_input("/win 1");
|
||||
assert_true(prof_output_exact("Profanity. Type /help for help information."));
|
||||
assert_true(prof_output_exact("CProof. Type /help for help information."));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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
5
tests/prof_cmocka.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
@@ -21,8 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "prof_cmocka.h"
|
||||
|
||||
#include <xmpp/xmpp.h>
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "prof_cmocka.h"
|
||||
|
||||
#include "database.h"
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "prof_cmocka.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res)
|
||||
{
|
||||
return NULL;
|
||||
};
|
||||
void omemo_free(void* a){};
|
||||
void omemo_free(void* a) {};
|
||||
|
||||
uint32_t
|
||||
omemo_device_id()
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "prof_cmocka.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
@@ -40,3 +37,17 @@ cmd_sub_shows_usage_when_no_arg(void** state)
|
||||
gboolean result = cmd_sub(NULL, CMD_SUB, args);
|
||||
assert_true(result);
|
||||
}
|
||||
|
||||
void
|
||||
test_cmd_sub_malformed_jid(void** state)
|
||||
{
|
||||
ProfWin win;
|
||||
win.type = WIN_CONSOLE;
|
||||
gchar* args[] = { "request", "@example.com" };
|
||||
|
||||
will_return(connection_get_status, JABBER_CONNECTED);
|
||||
|
||||
expect_cons_show("Malformed JID: @example.com");
|
||||
gboolean result = cmd_sub((ProfWin*)&win, CMD_SUB, args);
|
||||
assert_true(result);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user