Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
420adde173 | ||
|
|
2355ffc5d0 |
No files matched your search
@@ -32,7 +32,7 @@ jobs:
|
|||||||
build-essential pkg-config meson ninja-build cmake \
|
build-essential pkg-config meson ninja-build cmake \
|
||||||
gettext \
|
gettext \
|
||||||
libcanberra-dev libglib2.0-dev \
|
libcanberra-dev libglib2.0-dev \
|
||||||
libarchive-dev libsecret-1-dev libxss-dev \
|
libarchive-dev libsecret-1-dev \
|
||||||
libgtk-3-dev libfontconfig1-dev libpango1.0-dev xvfb xauth dbus-daemon at-spi2-core \
|
libgtk-3-dev libfontconfig1-dev libpango1.0-dev xvfb xauth dbus-daemon at-spi2-core \
|
||||||
libwayland-client0 libwayland-cursor0 libwayland-egl1 \
|
libwayland-client0 libwayland-cursor0 libwayland-egl1 \
|
||||||
libxkbcommon0 \
|
libxkbcommon0 \
|
||||||
@@ -75,7 +75,7 @@ jobs:
|
|||||||
ninja -C build
|
ninja -C build
|
||||||
|
|
||||||
- name: Test emoji catalog, font coverage and picker
|
- name: Test emoji catalog, font coverage and picker
|
||||||
run: xvfb-run -a dbus-run-session -- meson test -C build --print-errorlogs "Autoaway Tests" "Idle Backend Tests" "Emoji Data Tests" "Emoji Font Tests" "Emoji UI Tests"
|
run: xvfb-run -a dbus-run-session -- meson test -C build --print-errorlogs "Emoji Data Tests" "Emoji Font Tests" "Emoji UI Tests"
|
||||||
|
|
||||||
- name: Install to AppDir
|
- name: Install to AppDir
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ jobs:
|
|||||||
)
|
)
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
- name: Test autoaway, emoji catalog, font coverage and picker
|
- name: Test emoji catalog, font coverage and picker
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
|
||||||
@@ -213,10 +213,6 @@ jobs:
|
|||||||
..\zoitechat-build\x64\tests\emoji-%%T-tests.exe --tap
|
..\zoitechat-build\x64\tests\emoji-%%T-tests.exe --tap
|
||||||
if errorlevel 1 exit /b 1
|
if errorlevel 1 exit /b 1
|
||||||
)
|
)
|
||||||
msbuild win32\autoaway-tests.vcxproj /m /verbosity:minimal /p:Configuration=Release /p:Platform=x64
|
|
||||||
if errorlevel 1 exit /b 1
|
|
||||||
..\zoitechat-build\x64\tests\autoaway-tests.exe --tap
|
|
||||||
if errorlevel 1 exit /b 1
|
|
||||||
|
|
||||||
- name: Preparing Artifacts
|
- name: Preparing Artifacts
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ jobs:
|
|||||||
|
|
||||||
# Master added native emoji font staging and tests after the release
|
# Master added native emoji font staging and tests after the release
|
||||||
# branch split. Run these before packaging so MSI/MSIX use verified files.
|
# branch split. Run these before packaging so MSI/MSIX use verified files.
|
||||||
- name: Test autoaway, emoji catalog, font coverage and picker
|
- name: Test emoji catalog, font coverage and picker
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
|
||||||
@@ -224,10 +224,6 @@ jobs:
|
|||||||
..\zoitechat-build\x64\tests\emoji-%%T-tests.exe --tap
|
..\zoitechat-build\x64\tests\emoji-%%T-tests.exe --tap
|
||||||
if errorlevel 1 exit /b 1
|
if errorlevel 1 exit /b 1
|
||||||
)
|
)
|
||||||
msbuild win32\autoaway-tests.vcxproj /m /verbosity:minimal /p:Configuration=Release /p:Platform=x64
|
|
||||||
if errorlevel 1 exit /b 1
|
|
||||||
..\zoitechat-build\x64\tests\autoaway-tests.exe --tap
|
|
||||||
if errorlevel 1 exit /b 1
|
|
||||||
|
|
||||||
- name: Install WiX Toolset
|
- name: Install WiX Toolset
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ PROJECT_BRIEF =
|
|||||||
# exceed 55 pixels and the maximum width should not exceed 200 pixels.
|
# exceed 55 pixels and the maximum width should not exceed 200 pixels.
|
||||||
# Doxygen will copy the logo to the output directory.
|
# Doxygen will copy the logo to the output directory.
|
||||||
|
|
||||||
PROJECT_LOGO = "data/icons/zoitechat.png"
|
PROJECT_LOGO = "src/pixmaps/zoitechat.png"
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||||
# base path where the generated documentation will be put.
|
# base path where the generated documentation will be put.
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.8 KiB |
@@ -1,12 +1,46 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg"
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="900px" height="900px" viewBox="0 0 900 900" version="1.1">
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
<defs>
|
||||||
width="128" height="128" viewBox="0 0 128 128">
|
<linearGradient id="linear0" gradientUnits="userSpaceOnUse" x1="14.94" y1="500" x2="893.400024" y2="500" gradientTransform="matrix(0.990818,0,0,0.899663,0,0.168452)">
|
||||||
<title>ZoiteChat</title>
|
<stop offset="0" style="stop-color:rgb(0.392157%,63.137255%,98.431373%);stop-opacity:1;"/>
|
||||||
<g id="upper" inkscape:groupmode="layer" inkscape:label="Upper hex">
|
<stop offset="1" style="stop-color:rgb(0%,27.843137%,73.72549%);stop-opacity:1;"/>
|
||||||
<path fill="#d88b31" d="M36 8H92Q97 8 100 13L123 54Q128 63 123 72L113 89H49L95 48V35H16L28 13Q31 8 36 8Z"/>
|
</linearGradient>
|
||||||
|
<linearGradient id="linear1" gradientUnits="userSpaceOnUse" x1="14.94" y1="533.090027" x2="823" y2="533.090027" gradientTransform="matrix(0.990818,0,0,0.899663,0,0.168452)">
|
||||||
|
<stop offset="0" style="stop-color:rgb(0%,27.843137%,73.72549%);stop-opacity:1;"/>
|
||||||
|
<stop offset="1" style="stop-color:rgb(0.392157%,63.137255%,98.431373%);stop-opacity:1;"/>
|
||||||
|
</linearGradient>
|
||||||
|
<filter id="alpha" filterUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
|
||||||
|
<feColorMatrix type="matrix" in="SourceGraphic" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
|
||||||
|
</filter>
|
||||||
|
<mask id="mask0">
|
||||||
|
<g filter="url(#alpha)">
|
||||||
|
<rect x="0" y="0" width="900" height="900" style="fill:rgb(0%,0%,0%);fill-opacity:0.301961;stroke:none;"/>
|
||||||
</g>
|
</g>
|
||||||
<g id="lower" inkscape:groupmode="layer" inkscape:label="Lower hex">
|
</mask>
|
||||||
<path fill="#a8492b" d="M15 49H77L31 90V103H104L100 111Q97 120 90 120H36Q31 120 28 115L5 74Q0 64 5 54L8 49Z"/>
|
<clipPath id="clip1">
|
||||||
|
<rect x="0" y="0" width="900" height="900"/>
|
||||||
|
</clipPath>
|
||||||
|
<g id="surface6" clip-path="url(#clip1)">
|
||||||
|
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 807.664062 446.90625 C 807.664062 254.1875 635.601562 97.953125 423.355469 97.953125 C 299.296875 97.953125 188.988281 151.347656 118.71875 234.1875 C 185.085938 129.585938 309.460938 59.160156 451.960938 59.160156 C 664.214844 59.160156 836.269531 215.394531 836.269531 408.113281 C 836.269531 488.183594 806.546875 561.945312 756.597656 620.828125 C 789.078125 569.628906 807.664062 510.242188 807.664062 446.90625 Z M 807.664062 446.90625 "/>
|
||||||
|
</g>
|
||||||
|
<mask id="mask1">
|
||||||
|
<g filter="url(#alpha)">
|
||||||
|
<rect x="0" y="0" width="900" height="900" style="fill:rgb(0%,0%,0%);fill-opacity:0.501961;stroke:none;"/>
|
||||||
</g>
|
</g>
|
||||||
|
</mask>
|
||||||
|
<image id="image9" width="314" height="273" xlink:href="data:image/png;base64,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 truncated
|
||||||
|
<clipPath id="clip2">
|
||||||
|
<rect x="0" y="0" width="900" height="900"/>
|
||||||
|
</clipPath>
|
||||||
|
<g id="surface10" clip-path="url(#clip2)">
|
||||||
|
<use xlink:href="#image9" transform="matrix(1.581172,0,0,1.435704,208.067513,213.172682)"/>
|
||||||
|
</g>
|
||||||
|
</defs>
|
||||||
|
<g id="surface2">
|
||||||
|
<path style=" stroke:none;fill-rule:nonzero;fill:url(#linear0);" d="M 207.476562 790.304688 C 214.847656 775.902344 220.566406 761.195312 224.71875 746.339844 C 98.894531 677.074219 14.804688 551.554688 14.804688 408.183594 C 14.804688 189.945312 209.648438 13.023438 450 13.023438 C 690.351562 13.023438 885.195312 189.945312 885.195312 408.183594 C 885.195312 626.425781 690.351562 803.34375 450 803.34375 C 417.175781 803.34375 385.199219 800.023438 354.457031 793.761719 C 297.789062 857.851562 209.816406 892.078125 120.78125 886.34375 C 156.996094 862.296875 187.226562 829.847656 207.476562 790.296875 Z M 207.476562 790.304688 "/>
|
||||||
|
<path style=" stroke:none;fill-rule:nonzero;fill:url(#linear1);" d="M 207.476562 790.304688 C 214.820312 775.984375 220.496094 761.347656 224.648438 746.582031 C 98.875 677.453125 14.804688 552.058594 14.804688 408.824219 C 14.804688 266.605469 97.683594 141.980469 221.972656 72.5625 C 178.703125 133.902344 153.617188 206.828125 153.617188 285.074219 C 153.617188 502.964844 348.144531 679.59375 588.109375 679.59375 C 671.449219 679.59375 749.296875 658.273438 815.433594 621.332031 C 738.210938 730.792969 603.082031 803.34375 449.296875 803.34375 C 416.679688 803.34375 384.914062 800.058594 354.355469 793.871094 C 297.691406 857.898438 209.757812 892.078125 120.769531 886.34375 C 156.984375 862.296875 187.214844 829.847656 207.46875 790.296875 Z M 207.476562 790.304688 "/>
|
||||||
|
<use xlink:href="#surface6" mask="url(#mask0)"/>
|
||||||
|
<use xlink:href="#surface10" mask="url(#mask1)"/>
|
||||||
|
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 677.402344 225.28125 L 259.328125 225.28125 L 220.765625 309.644531 L 467.875 309.644531 L 220.765625 579.972656 L 638.898438 579.972656 L 677.402344 495.550781 L 430.363281 495.550781 L 677.402344 225.273438 Z M 677.402344 225.28125 "/>
|
||||||
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1,12 +1,56 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg"
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 908.34 1000">
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
<defs>
|
||||||
width="128" height="128" viewBox="0 0 128 128">
|
<style>
|
||||||
<title>ZoiteChat</title>
|
.cls-1 {
|
||||||
<g id="upper" inkscape:groupmode="layer" inkscape:label="Upper hex">
|
fill: url(#linear-gradient-2);
|
||||||
<path fill="#d88b31" d="M36 8H92Q97 8 100 13L123 54Q128 63 123 72L113 89H49L95 48V35H16L28 13Q31 8 36 8Z"/>
|
}
|
||||||
|
|
||||||
|
.cls-2 {
|
||||||
|
fill: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cls-3 {
|
||||||
|
isolation: isolate;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cls-4 {
|
||||||
|
opacity: .3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cls-5 {
|
||||||
|
mix-blend-mode: multiply;
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cls-6 {
|
||||||
|
fill: url(#linear-gradient);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<linearGradient id="linear-gradient" x1="14.94" y1="500" x2="893.4" y2="500" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#01a1fb"/>
|
||||||
|
<stop offset="1" stop-color="#0047bc"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="linear-gradient-2" x1="14.94" y1="533.09" x2="823" y2="533.09" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#0047bc"/>
|
||||||
|
<stop offset="1" stop-color="#01a1fb"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<g class="cls-3">
|
||||||
|
<g id="Layer_1" data-name="Layer 1">
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path class="cls-6" d="m209.4,878.26c7.44-16.01,13.21-32.36,17.4-48.87C99.81,752.4,14.94,612.88,14.94,453.52c0-242.58,196.65-439.23,439.23-439.23,242.58,0,439.23,196.65,439.23,439.23,0,242.58-196.65,439.23-439.23,439.23-33.13,0-65.4-3.69-96.43-10.65-57.19,71.24-145.98,109.28-235.84,102.91,36.55-26.73,67.06-62.8,87.5-106.76Z"/>
|
||||||
|
<path class="cls-1" d="m209.4,878.26c7.41-15.92,13.14-32.19,17.33-48.6C99.79,752.82,14.94,613.44,14.94,454.23c0-158.08,83.65-296.6,209.09-373.76-43.67,68.18-68.99,149.24-68.99,236.21,0,242.19,196.33,438.52,438.52,438.52,84.11,0,162.68-23.7,229.43-64.76-77.94,121.67-214.32,202.31-369.53,202.31-32.92,0-64.98-3.65-95.82-10.53-57.19,71.17-145.94,109.16-235.75,102.79,36.55-26.73,67.06-62.8,87.5-106.76Z"/>
|
||||||
|
<g class="cls-4">
|
||||||
|
<path class="cls-2" d="m815.15,496.56c0-214.21-173.66-387.87-387.87-387.87-125.21,0-236.54,59.35-307.46,151.43,66.98-116.27,192.51-194.55,336.33-194.55,214.22,0,387.87,173.66,387.87,387.87,0,89-30,170.99-80.41,236.44,32.78-56.91,51.54-122.92,51.54-193.32Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<image class="cls-5" width="316" height="274" transform="translate(209.32 236.76) scale(1.59)" xlink:href="data:image/png;base64,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 truncated
|
||||||
|
<path class="cls-2" d="m683.68,250.22h-421.95l-38.92,93.77h249.4l-249.4,300.48h422.01l38.86-93.84h-249.33l249.33-300.42Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
</g>
|
</g>
|
||||||
<g id="lower" inkscape:groupmode="layer" inkscape:label="Lower hex">
|
</svg>
|
||||||
<path fill="#a8492b" d="M15 49H77L31 90V103H104L100 111Q97 120 90 120H36Q31 120 28 115L5 74Q0 64 5 54L8 49Z"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,24 @@
|
|||||||
|
# Optional plugin API additions (discussion #144)
|
||||||
|
|
||||||
|
Existing hooks, callbacks, return values, context lookup, strings and menu behaviour
|
||||||
|
remain unchanged. The C plugin function table gains four fixed append-only slots;
|
||||||
|
unused slots are NULL. Older binaries use the unchanged prefix. A plugin must check
|
||||||
|
the documented get_info() feature key before accessing a new slot on an older host.
|
||||||
|
New Python modules are installed by Meson and the existing Windows copy/installer
|
||||||
|
pipeline. Only modules present in the installation are exported; imports of
|
||||||
|
zoitechat, hexchat and xchat retain their compatibility aliases.
|
||||||
|
|
||||||
|
All APIs run on the client main thread unless explicitly documented otherwise.
|
||||||
|
New reserved flags must be zero. These changes do not make old API calls thread-safe.
|
||||||
|
|
||||||
|
Nested hook dispatch defers deleted-hook reclamation until its outermost return,
|
||||||
|
so new observers can safely emit events and unhook themselves or other hooks.
|
||||||
|
|
||||||
|
The optional asyncio module requires Python 3.7 or newer; older supported
|
||||||
|
interpreters skip that module and retain the existing scripting API.
|
||||||
|
|
||||||
|
Python reload drops the script/API modules while retaining the embedding module
|
||||||
|
so callback and lib.ph pointer types keep the same CFFI identity.
|
||||||
|
|
||||||
|
Server-hook insertion matches both raw and attrs hooks so documented priorities
|
||||||
|
are honoured for mixed registrations, including new filtered attrs callbacks.
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Connection and context navigation
|
||||||
|
|
||||||
|
`get_connections()` returns one Connection snapshot per live connection:
|
||||||
|
`id`, `network`, `server`, `context`. Connection IDs distinguish simultaneous
|
||||||
|
connections with identical names. Prefer its server-tab context where present.
|
||||||
|
`get_connection(context=None)` finds the owner of a live context.
|
||||||
|
|
||||||
|
`get_contexts(connection_id=None, types=None)` lists live contexts, optionally
|
||||||
|
filtered by connection ID (or a Connection object) and session types: server=1,
|
||||||
|
channel=2, query=3. `connection.contexts(types=None)` is a convenience method.
|
||||||
|
`find_context_by_id(connection_id, channel=None)` / `connection.find(channel)`
|
||||||
|
resolve using that connection's IRC comparator; no channel selects the server tab.
|
||||||
|
Missing/closed contexts return None. Existing find_context() remains unchanged.
|
||||||
|
|
||||||
|
These helpers use the existing channels list's ID/context fields, so no new C
|
||||||
|
context ABI is needed. Snapshots are not persistent IDs across client restarts;
|
||||||
|
refresh them after closing/recreating connections. Always check Context.set()
|
||||||
|
when explicitly selecting a context that might have closed.
|
||||||
|
|
||||||
|
```python
|
||||||
|
connection = zoitechat.get_connection()
|
||||||
|
for context in connection.contexts(types=(2,)):
|
||||||
|
context.prnt('A channel on this exact connection')
|
||||||
|
```
|
||||||
@@ -628,38 +628,3 @@ List of Settings
|
|||||||
+------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
+------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| **url\_logging** | Toggle logging URLs to *<config>/url.log*. |
|
| **url\_logging** | Toggle logging URLs to *<config>/url.log*. |
|
||||||
+------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
+------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
Autoaway
|
|
||||||
--------
|
|
||||||
|
|
||||||
In **Preferences > Chatting > General > Away**, set **Autoaway after** to a
|
|
||||||
number of minutes. The default is 0 (disabled). The separate **Autoaway
|
|
||||||
message** defaults to "Idle". No plugin or scripting language is required.
|
|
||||||
The same options are available immediately through ``/SET``::
|
|
||||||
|
|
||||||
/SET away_auto_timeout 10
|
|
||||||
/SET away_auto_reason Idle
|
|
||||||
/SET away_auto_system ON
|
|
||||||
|
|
||||||
With desktop activity enabled, Windows uses the current login session's last
|
|
||||||
input time, macOS uses CoreGraphics input time, and native X11 uses the
|
|
||||||
XScreenSaver extension if its development library was available at build time.
|
|
||||||
Debian/Ubuntu builders can install ``libxss-dev``; Fedora builders can install
|
|
||||||
``libXScrnSaver-devel``. Meson detects this optional dependency automatically.
|
|
||||||
|
|
||||||
On native Wayland, XWayland, unsupported desktops, and builds without XScreenSaver,
|
|
||||||
autoaway falls back to keyboard, mouse, scroll and touch activity **inside
|
|
||||||
ZoiteChat**. Activity in other applications does not reset that fallback timer.
|
|
||||||
Set ``away_auto_system OFF`` to always use ZoiteChat activity on every platform.
|
|
||||||
The text frontend uses submitted user input. Network traffic, redraws and window
|
|
||||||
focus changes do not count as user activity.
|
|
||||||
|
|
||||||
Autoaway checks every five seconds, after IRC login finishes, independently on
|
|
||||||
each connected network. Returning clears only away states set by autoaway.
|
|
||||||
Manual ``/AWAY`` (including ``/AWAY`` while already automatically away) takes
|
|
||||||
ownership, so activity does not clear it. ``/BACK`` resets the inactivity timer.
|
|
||||||
The existing **Automatically unmark away** setting keeps its separate behaviour
|
|
||||||
when sending messages. Do not run another autoaway script at the same time.
|
|
||||||
Disabling autoaway clears its own away states. Reconnecting re-evaluates current
|
|
||||||
inactivity instead of restoring an outdated automatic away state; manual away
|
|
||||||
restoration is unchanged.
|
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
"run-tests": true,
|
"run-tests": true,
|
||||||
"test-rule": "",
|
"test-rule": "",
|
||||||
"test-commands": [
|
"test-commands": [
|
||||||
"meson test --print-errorlogs 'Autoaway Tests' 'Idle Backend Tests' 'Emoji Data Tests' 'Emoji Font Tests'"
|
"meson test --print-errorlogs 'Emoji Data Tests' 'Emoji Font Tests'"
|
||||||
],
|
],
|
||||||
"config-opts": [
|
"config-opts": [
|
||||||
"-Ddbus-service-use-appid=true",
|
"-Ddbus-service-use-appid=true",
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ option('with-python', type: 'string', value: 'python3',
|
|||||||
description: 'Python scripting plugin. value is pkg-config name to use or "false"'
|
description: 'Python scripting plugin. value is pkg-config name to use or "false"'
|
||||||
)
|
)
|
||||||
option('with-sysinfo', type: 'boolean',
|
option('with-sysinfo', type: 'boolean',
|
||||||
description: 'System information plugin (optional libpci for PCI names on Unix)'
|
description: 'System information plugin, requires libpci on Unix'
|
||||||
)
|
)
|
||||||
option('with-upd', type: 'boolean',
|
option('with-upd', type: 'boolean',
|
||||||
description: 'Update plugin, Windows only'
|
description: 'Update plugin, Windows only'
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ BuildRequires: pkgconfig(gmodule-2.0)
|
|||||||
BuildRequires: pkgconfig(gtk+-3.0) >= 3.22
|
BuildRequires: pkgconfig(gtk+-3.0) >= 3.22
|
||||||
BuildRequires: pkgconfig(fontconfig) >= 2.13
|
BuildRequires: pkgconfig(fontconfig) >= 2.13
|
||||||
BuildRequires: pkgconfig(pangoft2) >= 1.44
|
BuildRequires: pkgconfig(pangoft2) >= 1.44
|
||||||
BuildRequires: pkgconfig(xscrnsaver)
|
|
||||||
BuildRequires: pkgconfig(iso-codes)
|
BuildRequires: pkgconfig(iso-codes)
|
||||||
BuildRequires: pkgconfig(libarchive)
|
BuildRequires: pkgconfig(libarchive)
|
||||||
BuildRequires: pkgconfig(libcanberra) >= 0.22
|
BuildRequires: pkgconfig(libcanberra) >= 0.22
|
||||||
|
|||||||
@@ -285,15 +285,13 @@ char *decrypt_raw_message(const char *message, const char *key) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean have_echo_message(void) {
|
|
||||||
return g_strcmp0(zoitechat_get_info(ph, "echo-message"), "1") == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a message is to be sent.
|
* Called when a message is to be sent.
|
||||||
*/
|
*/
|
||||||
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
||||||
|
char *prefix;
|
||||||
enum fish_mode mode;
|
enum fish_mode mode;
|
||||||
|
char *message;
|
||||||
GString *command;
|
GString *command;
|
||||||
GSList *encrypted_list, *encrypted_item;
|
GSList *encrypted_list, *encrypted_item;
|
||||||
|
|
||||||
@@ -311,15 +309,15 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
|||||||
return ZOITECHAT_EAT_NONE;
|
return ZOITECHAT_EAT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let the decrypted server echo display the message when available. */
|
/* Get prefix for own nick if any */
|
||||||
if (!have_echo_message()) {
|
prefix = get_my_own_prefix();
|
||||||
char *prefix = get_my_own_prefix();
|
|
||||||
char *message = g_strconcat("[", fish_modes[mode], "] ", word_eol[1], NULL);
|
|
||||||
|
|
||||||
zoitechat_emit_print(ph, "Your Message", zoitechat_get_info(ph, "nick"), message, prefix, NULL);
|
/* Add encrypted flag */
|
||||||
g_free(message);
|
message = g_strconcat("[", fish_modes[mode], "] ", word_eol[1], NULL);
|
||||||
g_free(prefix);
|
|
||||||
}
|
/* Display message */
|
||||||
|
zoitechat_emit_print(ph, "Your Message", zoitechat_get_info(ph, "nick"), message, prefix, NULL);
|
||||||
|
g_free(message);
|
||||||
|
|
||||||
/* Send encrypted messages */
|
/* Send encrypted messages */
|
||||||
encrypted_item = encrypted_list;
|
encrypted_item = encrypted_list;
|
||||||
@@ -330,6 +328,7 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
|||||||
encrypted_item = encrypted_item->next;
|
encrypted_item = encrypted_item->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(prefix);
|
||||||
g_string_free(command, TRUE);
|
g_string_free(command, TRUE);
|
||||||
g_slist_free_full(encrypted_list, g_free);
|
g_slist_free_full(encrypted_list, g_free);
|
||||||
|
|
||||||
@@ -413,14 +412,6 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
|
|||||||
return ZOITECHAT_EAT_NONE;
|
return ZOITECHAT_EAT_NONE;
|
||||||
|
|
||||||
sender = irc_prefix_get_nick(prefix);
|
sender = irc_prefix_get_nick(prefix);
|
||||||
/* A reflected outgoing key exchange is not a request from the peer. */
|
|
||||||
if (irc_nick_cmp(sender, zoitechat_get_info(ph, "nick")) == 0 &&
|
|
||||||
irc_nick_cmp(word[3], sender) != 0 &&
|
|
||||||
(!strcmp(dh_message, ":DH1080_INIT") || !strcmp(dh_message, ":DH1080_FINISH"))) {
|
|
||||||
g_free(sender);
|
|
||||||
return ZOITECHAT_EAT_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
query_ctx = find_context_on_network(sender);
|
query_ctx = find_context_on_network(sender);
|
||||||
if (query_ctx)
|
if (query_ctx)
|
||||||
g_assert(zoitechat_set_context(ph, query_ctx) == 1);
|
g_assert(zoitechat_set_context(ph, query_ctx) == 1);
|
||||||
@@ -959,6 +950,7 @@ static int handle_crypt_topic(char *word[], char *word_eol[], void *userdata) {
|
|||||||
static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
||||||
const char *target = word[2];
|
const char *target = word[2];
|
||||||
const char *notice = word_eol[3];
|
const char *notice = word_eol[3];
|
||||||
|
char *notice_flag;
|
||||||
enum fish_mode mode;
|
enum fish_mode mode;
|
||||||
GString *command;
|
GString *command;
|
||||||
GSList *encrypted_list, *encrypted_item;
|
GSList *encrypted_list, *encrypted_item;
|
||||||
@@ -984,11 +976,8 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
|||||||
return ZOITECHAT_EAT_ALL;
|
return ZOITECHAT_EAT_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!have_echo_message()) {
|
notice_flag = g_strconcat("[", fish_modes[mode], "] ", notice, NULL);
|
||||||
char *notice_flag = g_strconcat("[", fish_modes[mode], "] ", notice, NULL);
|
zoitechat_emit_print(ph, "Notice Send", target, notice_flag);
|
||||||
zoitechat_emit_print(ph, "Notice Send", target, notice_flag);
|
|
||||||
g_free(notice_flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send encrypted messages */
|
/* Send encrypted messages */
|
||||||
encrypted_item = encrypted_list;
|
encrypted_item = encrypted_list;
|
||||||
@@ -998,6 +987,7 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
|||||||
encrypted_item = encrypted_item->next;
|
encrypted_item = encrypted_item->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(notice_flag);
|
||||||
g_string_free(command, TRUE);
|
g_string_free(command, TRUE);
|
||||||
g_slist_free_full(encrypted_list, g_free);
|
g_slist_free_full(encrypted_list, g_free);
|
||||||
|
|
||||||
@@ -1049,9 +1039,6 @@ static int handle_crypt_msg(char *word[], char *word_eol[], void *userdata) {
|
|||||||
g_string_free(command, TRUE);
|
g_string_free(command, TRUE);
|
||||||
g_slist_free_full(encrypted_list, g_free);
|
g_slist_free_full(encrypted_list, g_free);
|
||||||
|
|
||||||
if (have_echo_message())
|
|
||||||
return ZOITECHAT_EAT_ALL;
|
|
||||||
|
|
||||||
query_ctx = find_context_on_network(target);
|
query_ctx = find_context_on_network(target);
|
||||||
if (query_ctx) {
|
if (query_ctx) {
|
||||||
g_assert(zoitechat_set_context(ph, query_ctx) == 1);
|
g_assert(zoitechat_set_context(ph, query_ctx) == 1);
|
||||||
@@ -1092,8 +1079,7 @@ static int handle_crypt_me(char *word[], char *word_eol[], void *userdata) {
|
|||||||
return ZOITECHAT_EAT_ALL;
|
return ZOITECHAT_EAT_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!have_echo_message())
|
zoitechat_emit_print(ph, "Your Action", zoitechat_get_info(ph, "nick"), word_eol[2], NULL);
|
||||||
zoitechat_emit_print(ph, "Your Action", zoitechat_get_info(ph, "nick"), word_eol[2], NULL);
|
|
||||||
|
|
||||||
/* Send encrypted messages */
|
/* Send encrypted messages */
|
||||||
encrypted_item = encrypted_list;
|
encrypted_item = encrypted_list;
|
||||||
|
|||||||
@@ -383,3 +383,24 @@ def find_context(server=None, channel=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
return Context(ctx)
|
return Context(ctx)
|
||||||
|
|
||||||
|
|
||||||
|
# Optional additive APIs live in separate modules so builds can select features.
|
||||||
|
def __load_additive_features():
|
||||||
|
import importlib
|
||||||
|
import os
|
||||||
|
|
||||||
|
for suffix in ('fd', 'events', 'async', 'names', 'contexts',
|
||||||
|
'post', 'filters', 'caps'):
|
||||||
|
if suffix == 'async' and sys.version_info < (3, 7):
|
||||||
|
continue
|
||||||
|
name = '_zoitechat_' + suffix
|
||||||
|
if not os.path.isfile(os.path.join(os.path.dirname(__file__), name + '.py')):
|
||||||
|
continue
|
||||||
|
module = importlib.import_module(name)
|
||||||
|
for symbol in module.__all__:
|
||||||
|
globals()[symbol] = getattr(module, symbol)
|
||||||
|
__all__.append(symbol)
|
||||||
|
|
||||||
|
|
||||||
|
__load_additive_features()
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
"""Navigate live connections by ID instead of ambiguous server/network names."""
|
||||||
|
from collections import namedtuple
|
||||||
|
import operator
|
||||||
|
import _zoitechat as api
|
||||||
|
|
||||||
|
__all__ = ['Connection', 'get_connections', 'get_connection', 'get_contexts',
|
||||||
|
'find_context_by_id']
|
||||||
|
|
||||||
|
|
||||||
|
class Connection(namedtuple('_Connection', 'id network server context')):
|
||||||
|
__slots__ = ()
|
||||||
|
|
||||||
|
def contexts(self, types=None):
|
||||||
|
return get_contexts(self.id, types)
|
||||||
|
|
||||||
|
def find(self, channel=None):
|
||||||
|
return find_context_by_id(self.id, channel)
|
||||||
|
|
||||||
|
|
||||||
|
def _id(connection):
|
||||||
|
return operator.index(connection.id if isinstance(connection, Connection) else connection)
|
||||||
|
|
||||||
|
|
||||||
|
def get_connections():
|
||||||
|
"""Return one snapshot per live connection, including disconnected ones."""
|
||||||
|
entries = api.get_list('channels')
|
||||||
|
by_id = {}
|
||||||
|
order = []
|
||||||
|
for entry in entries:
|
||||||
|
if entry.id not in by_id:
|
||||||
|
order.append(entry.id)
|
||||||
|
if entry.id not in by_id or entry.type == 1:
|
||||||
|
by_id[entry.id] = Connection(entry.id, entry.network, entry.server,
|
||||||
|
entry.context)
|
||||||
|
return [by_id[connection_id] for connection_id in order]
|
||||||
|
|
||||||
|
|
||||||
|
def get_connection(context=None):
|
||||||
|
"""Find the owning connection of a Context; return None when it has closed."""
|
||||||
|
context = context or api.get_context()
|
||||||
|
for entry in api.get_list('channels'):
|
||||||
|
if entry.context == context:
|
||||||
|
for connection in get_connections():
|
||||||
|
if connection.id == entry.id:
|
||||||
|
return connection
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_contexts(connection_id=None, types=None):
|
||||||
|
"""Return contexts, optionally restricted to a connection and session types."""
|
||||||
|
if connection_id is not None:
|
||||||
|
connection_id = _id(connection_id)
|
||||||
|
if types is not None:
|
||||||
|
types = frozenset(types)
|
||||||
|
return [entry.context for entry in api.get_list('channels')
|
||||||
|
if (connection_id is None or entry.id == connection_id)
|
||||||
|
and (types is None or entry.type in types)]
|
||||||
|
|
||||||
|
|
||||||
|
def find_context_by_id(connection_id, channel=None):
|
||||||
|
"""Resolve a live context on exactly one connection; None selects its server tab."""
|
||||||
|
connection_id = _id(connection_id)
|
||||||
|
previous = api.get_context()
|
||||||
|
try:
|
||||||
|
for entry in api.get_list('channels'):
|
||||||
|
if entry.id != connection_id:
|
||||||
|
continue
|
||||||
|
if channel is None:
|
||||||
|
if entry.type == 1:
|
||||||
|
return entry.context
|
||||||
|
elif entry.context.set() and api.nickcmp(entry.channel, channel) == 0:
|
||||||
|
return entry.context
|
||||||
|
finally:
|
||||||
|
previous.set()
|
||||||
|
return None
|
||||||
@@ -27,7 +27,11 @@ python3_source = custom_target('python-bindings',
|
|||||||
command: [find_program('generate_plugin.py'), '@INPUT@', '@OUTPUT@']
|
command: [find_program('generate_plugin.py'), '@INPUT@', '@OUTPUT@']
|
||||||
)
|
)
|
||||||
|
|
||||||
install_data(['_zoitechat.py', 'zoitechat.py', 'xchat.py', 'hexchat.py'],
|
# Include any selected additive API modules alongside the compatibility modules.
|
||||||
|
python_api_files = run_command(python3, '-c',
|
||||||
|
'import glob,sys; print("\\n".join(sorted(glob.glob(sys.argv[1] + "/_zoitechat*.py"))))',
|
||||||
|
meson.current_source_dir(), check: true).stdout().strip().split('\n')
|
||||||
|
install_data(python_api_files + ['zoitechat.py', 'xchat.py', 'hexchat.py'],
|
||||||
install_dir: join_paths(get_option('libdir'), 'zoitechat/python')
|
install_dir: join_paths(get_option('libdir'), 'zoitechat/python')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -376,10 +376,8 @@ def reload_name(name):
|
|||||||
def change_cwd(path):
|
def change_cwd(path):
|
||||||
old_cwd = os.getcwd()
|
old_cwd = os.getcwd()
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
try:
|
yield
|
||||||
yield
|
os.chdir(old_cwd)
|
||||||
finally:
|
|
||||||
os.chdir(old_cwd)
|
|
||||||
|
|
||||||
|
|
||||||
def autoload():
|
def autoload():
|
||||||
@@ -592,7 +590,12 @@ def _on_plugin_deinit():
|
|||||||
sys.stderr = sys.__stderr__
|
sys.stderr = sys.__stderr__
|
||||||
pydoc.help = pydoc.Helper()
|
pydoc.help = pydoc.Helper()
|
||||||
|
|
||||||
for mod in ('_zoitechat', 'zoitechat', 'xchat', '_zoitechat_embedded'):
|
# CFFI callbacks keep the embedding module's ffi/lib identity for the
|
||||||
|
# process lifetime; deleting it creates incompatible types on reload.
|
||||||
|
for mod in ('_zoitechat', 'zoitechat', 'hexchat', 'xchat',
|
||||||
|
'_zoitechat_fd', '_zoitechat_events', '_zoitechat_async',
|
||||||
|
'_zoitechat_names', '_zoitechat_contexts', '_zoitechat_post',
|
||||||
|
'_zoitechat_filters', '_zoitechat_caps'):
|
||||||
try:
|
try:
|
||||||
del sys.modules[mod]
|
del sys.modules[mod]
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
<None Include="xchat.py" />
|
<None Include="xchat.py" />
|
||||||
<None Include="hexchat.py" />
|
<None Include="hexchat.py" />
|
||||||
<None Include="_zoitechat.py" />
|
<None Include="_zoitechat.py" />
|
||||||
|
<None Include="_zoitechat_*.py" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="$(IntDir)python.c" />
|
<ClCompile Include="$(IntDir)python.c" />
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
<None Include="xchat.py" />
|
<None Include="xchat.py" />
|
||||||
<None Include="hexchat.py" />
|
<None Include="hexchat.py" />
|
||||||
<None Include="_zoitechat.py" />
|
<None Include="_zoitechat.py" />
|
||||||
|
<None Include="_zoitechat_*.py" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="$(IntDir)python.c" />
|
<ClCompile Include="$(IntDir)python.c" />
|
||||||
|
|||||||
@@ -88,81 +88,3 @@ sysinfo_format_disk (guint64 total, guint64 free)
|
|||||||
g_free (used_fmt);
|
g_free (used_fmt);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_format_usage (guint64 total, guint64 available)
|
|
||||||
{
|
|
||||||
guint64 used;
|
|
||||||
char *used_fmt;
|
|
||||||
char *total_fmt;
|
|
||||||
char *result;
|
|
||||||
double percent;
|
|
||||||
|
|
||||||
if (total == 0)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (available > total)
|
|
||||||
{
|
|
||||||
available = total;
|
|
||||||
}
|
|
||||||
used = total - available;
|
|
||||||
percent = ((double) used / (double) total) * 100.0;
|
|
||||||
|
|
||||||
used_fmt = g_format_size_full (used, G_FORMAT_SIZE_IEC_UNITS);
|
|
||||||
total_fmt = g_format_size_full (total, G_FORMAT_SIZE_IEC_UNITS);
|
|
||||||
result = g_strdup_printf ("%s / %s used (%.0f%%)", used_fmt, total_fmt, percent);
|
|
||||||
g_free (used_fmt);
|
|
||||||
g_free (total_fmt);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_join_ptr_array (GPtrArray *items, const char *separator)
|
|
||||||
{
|
|
||||||
GString *joined;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!items || items->len == 0)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
joined = g_string_new (NULL);
|
|
||||||
for (i = 0; i < items->len; i++)
|
|
||||||
{
|
|
||||||
const char *item = g_ptr_array_index (items, i);
|
|
||||||
|
|
||||||
if (i != 0)
|
|
||||||
{
|
|
||||||
g_string_append (joined, separator);
|
|
||||||
}
|
|
||||||
g_string_append (joined, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_string_free (joined, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
sysinfo_ptr_array_add_unique (GPtrArray *items, const char *value, gboolean ignore_case)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!value || value[0] == '\0')
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < items->len; i++)
|
|
||||||
{
|
|
||||||
const char *existing = g_ptr_array_index (items, i);
|
|
||||||
if (ignore_case ? g_ascii_strcasecmp (existing, value) == 0 :
|
|
||||||
g_strcmp0 (existing, value) == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_ptr_array_add (items, g_strdup (value));
|
|
||||||
}
|
|
||||||
@@ -24,8 +24,5 @@
|
|||||||
char *sysinfo_format_uptime(gint64 uptime);
|
char *sysinfo_format_uptime(gint64 uptime);
|
||||||
char *sysinfo_format_memory(guint64 totalmem, guint64 freemem);
|
char *sysinfo_format_memory(guint64 totalmem, guint64 freemem);
|
||||||
char *sysinfo_format_disk(guint64 total, guint64 free);
|
char *sysinfo_format_disk(guint64 total, guint64 free);
|
||||||
char *sysinfo_format_usage (guint64 total, guint64 available);
|
|
||||||
char *sysinfo_join_ptr_array (GPtrArray *items, const char *separator);
|
|
||||||
void sysinfo_ptr_array_add_unique (GPtrArray *items, const char *value, gboolean ignore_case);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -6,67 +6,50 @@ sysinfo_sources = [
|
|||||||
sysinfo_deps = [
|
sysinfo_deps = [
|
||||||
libgio_dep,
|
libgio_dep,
|
||||||
zoitechat_plugin_dep,
|
zoitechat_plugin_dep,
|
||||||
|
common_sysinfo_deps,
|
||||||
]
|
]
|
||||||
|
|
||||||
sysinfo_includes = []
|
sysinfo_includes = []
|
||||||
sysinfo_cargs = ['-DHAVE_CONFIG_H']
|
sysinfo_cargs = ['-DHAVE_CONFIG_H']
|
||||||
|
|
||||||
system = host_machine.system()
|
system = host_machine.system()
|
||||||
if system == 'linux'
|
if system == 'linux' or system == 'gnu' or system.startswith('gnu/') or system == 'darwin' or system == 'freebsd'
|
||||||
if get_option('gtk-frontend')
|
sysinfo_includes += 'shared'
|
||||||
sysinfo_deps += dependency('gtk+-3.0', version: '>= 3.22')
|
|
||||||
endif
|
|
||||||
|
|
||||||
libpci = dependency('libpci', required: false, method: 'pkg-config')
|
|
||||||
if libpci.found()
|
|
||||||
sysinfo_deps += libpci
|
|
||||||
sysinfo_cargs += '-DHAVE_LIBPCI'
|
|
||||||
endif
|
|
||||||
|
|
||||||
sysinfo_includes += 'unix'
|
|
||||||
sysinfo_sources += ['unix/modern-backend.c', 'unix/storage.c', 'unix/memory.c']
|
|
||||||
|
|
||||||
elif system == 'freebsd' or system == 'gnu' or system.startswith('gnu/')
|
|
||||||
sysinfo_includes += ['shared', 'unix']
|
|
||||||
sysinfo_sources += [
|
sysinfo_sources += [
|
||||||
'shared/df.c',
|
'shared/df.c'
|
||||||
'unix/backend.c',
|
|
||||||
'unix/match.c',
|
|
||||||
'unix/parse.c',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
libpci = dependency('libpci', required: false, method: 'pkg-config')
|
if system == 'linux' or system == 'gnu' or system.startswith('gnu/') or system == 'freebsd'
|
||||||
if libpci.found()
|
libpci = dependency('libpci', required: false, method: 'pkg-config')
|
||||||
sysinfo_deps += libpci
|
if libpci.found()
|
||||||
sysinfo_cargs += '-DHAVE_LIBPCI'
|
sysinfo_deps += libpci
|
||||||
sysinfo_sources += 'unix/pci.c'
|
sysinfo_cargs += '-DHAVE_LIBPCI'
|
||||||
|
sysinfo_sources += 'unix/pci.c'
|
||||||
|
|
||||||
picidsdir = libpci.get_variable(pkgconfig: 'idsdir')
|
picidsdir = libpci.get_variable(pkgconfig : 'idsdir')
|
||||||
pciids = join_paths(picidsdir, 'pci.ids')
|
pciids = join_paths(picidsdir, 'pci.ids')
|
||||||
sysinfo_cargs += '-DPCIIDS_FILE="@0@"'.format(pciids)
|
sysinfo_cargs += '-DPCIIDS_FILE="@0@"'.format(pciids)
|
||||||
|
endif
|
||||||
|
if get_option('gtk-frontend')
|
||||||
|
sysinfo_deps += dependency('gtk+-3.0', version: '>= 3.22')
|
||||||
|
endif
|
||||||
|
|
||||||
|
sysinfo_includes += 'unix'
|
||||||
|
sysinfo_sources += [
|
||||||
|
'unix/backend.c',
|
||||||
|
'unix/match.c',
|
||||||
|
'unix/parse.c',
|
||||||
|
]
|
||||||
|
elif system == 'darwin'
|
||||||
|
add_languages('objc')
|
||||||
|
sysinfo_sources += 'osx/backend.m'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('gtk-frontend')
|
|
||||||
sysinfo_deps += dependency('gtk+-3.0', version: '>= 3.22')
|
|
||||||
endif
|
|
||||||
|
|
||||||
elif system == 'darwin'
|
|
||||||
sysinfo_includes += 'shared'
|
|
||||||
sysinfo_sources += 'shared/df.c'
|
|
||||||
add_languages('objc')
|
|
||||||
sysinfo_deps += dependency('appleframeworks', modules: ['Cocoa', 'IOKit'])
|
|
||||||
sysinfo_sources += 'osx/backend.m'
|
|
||||||
|
|
||||||
elif system == 'windows'
|
elif system == 'windows'
|
||||||
cc = meson.get_compiler('c')
|
sysinfo_sources += [
|
||||||
sysinfo_deps += [
|
'win32/backend.c',
|
||||||
cc.find_library('advapi32', required: true),
|
'../../src/common/sysinfo/win32/backend.c'
|
||||||
cc.find_library('dxgi', required: true),
|
|
||||||
cc.find_library('dxguid', required: true),
|
|
||||||
cc.find_library('iphlpapi', required: true),
|
|
||||||
cc.find_library('winmm', required: true),
|
|
||||||
]
|
]
|
||||||
sysinfo_sources += 'win32/backend.c'
|
|
||||||
else
|
else
|
||||||
error('sysinfo: Unknown system?')
|
error('sysinfo: Unknown system?')
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#include <IOKit/IOKitLib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
@@ -40,7 +38,6 @@
|
|||||||
|
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "df.h"
|
#include "df.h"
|
||||||
#include "sysinfo-backend.h"
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_os (void)
|
get_os (void)
|
||||||
@@ -51,7 +48,10 @@ get_os (void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
NSString *version = [systemversion objectForKey:@"ProductUserVisibleVersion"];
|
NSString *version = [systemversion objectForKey:@"ProductUserVisibleVersion"];
|
||||||
if (!version)
|
if (!version)
|
||||||
|
{
|
||||||
|
[build release];
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
NSDictionary *profiler = [NSDictionary dictionaryWithContentsOfFile:[@"~/Library/Preferences/com.apple.SystemProfiler.plist" stringByExpandingTildeInPath]];
|
NSDictionary *profiler = [NSDictionary dictionaryWithContentsOfFile:[@"~/Library/Preferences/com.apple.SystemProfiler.plist" stringByExpandingTildeInPath]];
|
||||||
NSDictionary *names = [profiler objectForKey:@"OS Names"];
|
NSDictionary *names = [profiler objectForKey:@"OS Names"];
|
||||||
@@ -65,11 +65,18 @@ get_os (void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Dictionary values are borrowed; releasing them would over-release. */
|
[build release];
|
||||||
if (!os_name)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_strdup_printf ("%s %s", [os_name UTF8String], [version UTF8String]);
|
if (!os_name)
|
||||||
|
{
|
||||||
|
[version release];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *ret = g_strdup_printf ("%s %s", [os_name UTF8String], [version UTF8String]);
|
||||||
|
[version release];
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@@ -92,19 +99,10 @@ get_os_fallback (void)
|
|||||||
return g_strdup_printf ("OS X %ld.%ld.%ld", version.majorVersion, version.minorVersion, version.patchVersion);
|
return g_strdup_printf ("OS X %ld.%ld.%ld", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
static char *os_str;
|
|
||||||
static char *gpu_str;
|
|
||||||
|
|
||||||
void
|
|
||||||
sysinfo_backend_reset_cache (void)
|
|
||||||
{
|
|
||||||
g_clear_pointer (&os_str, g_free);
|
|
||||||
g_clear_pointer (&gpu_str, g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
sysinfo_backend_get_os(void)
|
sysinfo_backend_get_os(void)
|
||||||
{
|
{
|
||||||
|
static char *os_str = NULL;
|
||||||
if (!os_str)
|
if (!os_str)
|
||||||
{
|
{
|
||||||
os_str = get_os();
|
os_str = get_os();
|
||||||
@@ -212,14 +210,9 @@ get_gpu(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const void *class = CFDictionaryGetValue(serviceDictionary, @"class-code");
|
const void *class = CFDictionaryGetValue(serviceDictionary, @"class-code");
|
||||||
guint32 class_code = 0;
|
if (!class || *(guint32*)CFDataGetBytePtr(class) != 0x30000) /* DISPLAY_VGA */
|
||||||
if (class && CFGetTypeID (class) == CFDataGetTypeID () &&
|
|
||||||
CFDataGetLength (class) >= sizeof (class_code))
|
|
||||||
memcpy (&class_code, CFDataGetBytePtr (class), sizeof (class_code));
|
|
||||||
if (GUINT32_FROM_LE (class_code) != 0x30000) /* DISPLAY_VGA */
|
|
||||||
{
|
{
|
||||||
CFRelease(serviceDictionary);
|
CFRelease(serviceDictionary);
|
||||||
IOObjectRelease (serviceObject);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,9 +228,7 @@ get_gpu(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(serviceDictionary);
|
CFRelease(serviceDictionary);
|
||||||
IOObjectRelease (serviceObject);
|
|
||||||
}
|
}
|
||||||
IOObjectRelease (entry_iterator);
|
|
||||||
|
|
||||||
if (gpu_list->len == 0)
|
if (gpu_list->len == 0)
|
||||||
{
|
{
|
||||||
@@ -259,19 +250,13 @@ get_gpu(void)
|
|||||||
char *
|
char *
|
||||||
sysinfo_backend_get_gpu(void)
|
sysinfo_backend_get_gpu(void)
|
||||||
{
|
{
|
||||||
|
static char *gpu_str = NULL;
|
||||||
if (!gpu_str)
|
if (!gpu_str)
|
||||||
gpu_str = get_gpu();
|
gpu_str = get_gpu();
|
||||||
|
|
||||||
return g_strdup (gpu_str);
|
return g_strdup (gpu_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_backend_get_chipset (void)
|
|
||||||
{
|
|
||||||
/* No chipset detector exists in the legacy macOS backend. */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
sysinfo_backend_get_sound(void)
|
sysinfo_backend_get_sound(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 200809L
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -26,7 +25,7 @@ int xs_parse_df(gint64 *out_total, gint64 *out_free)
|
|||||||
{
|
{
|
||||||
FILE *pipe;
|
FILE *pipe;
|
||||||
char buffer[bsize];
|
char buffer[bsize];
|
||||||
|
|
||||||
pipe = popen("df -k -l -P --exclude-type=squashfs --exclude-type=devtmpfs --exclude-type=tmpfs", "r");
|
pipe = popen("df -k -l -P --exclude-type=squashfs --exclude-type=devtmpfs --exclude-type=tmpfs", "r");
|
||||||
if(pipe==NULL)
|
if(pipe==NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
#ifndef SYSINFO_BACKEND_H
|
#ifndef SYSINFO_BACKEND_H
|
||||||
#define SYSINFO_BACKEND_H
|
#define SYSINFO_BACKEND_H
|
||||||
|
|
||||||
/* Called on the same client thread as the getters. Safe to call repeatedly. */
|
|
||||||
void sysinfo_backend_reset_cache (void);
|
|
||||||
char *sysinfo_backend_get_os(void);
|
char *sysinfo_backend_get_os(void);
|
||||||
char *sysinfo_backend_get_disk(void);
|
char *sysinfo_backend_get_disk(void);
|
||||||
char *sysinfo_backend_get_memory(void);
|
char *sysinfo_backend_get_memory(void);
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ static zoitechat_plugin *ph;
|
|||||||
|
|
||||||
static char name[] = "Sysinfo";
|
static char name[] = "Sysinfo";
|
||||||
static char desc[] = "Display info about your hardware and OS";
|
static char desc[] = "Display info about your hardware and OS";
|
||||||
static char version[] = "2.0";
|
static char version[] = "1.0";
|
||||||
static char sysinfo_help[] = "SysInfo Usage:\n /SYSINFO [-e|-o] [CLIENT|UI|OS|CPU|RAM|MEMORY|STORAGE|DISK|GPU|VGA|CHIPSET|SOUND|NETWORK|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n /SYSINFO SET <variable>\n /SYSINFO REFRESH - clear cached hardware information\n";
|
static char sysinfo_help[] = "SysInfo Usage:\n /SYSINFO [-e|-o] [CLIENT|UI|OS|CPU|RAM|STORAGE|GPU|CHIPSET|SOUND|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n /SYSINFO SET <variable>\n";
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -70,9 +70,9 @@ static hwinfo hwinfos[] = {
|
|||||||
{"memory", "Memory", sysinfo_backend_get_memory},
|
{"memory", "Memory", sysinfo_backend_get_memory},
|
||||||
{"storage", "Storage", sysinfo_backend_get_disk, TRUE},
|
{"storage", "Storage", sysinfo_backend_get_disk, TRUE},
|
||||||
{"gpu", "GPU", sysinfo_backend_get_gpu},
|
{"gpu", "GPU", sysinfo_backend_get_gpu},
|
||||||
{"chipset", "Chipset", sysinfo_backend_get_chipset, TRUE},
|
{"chipset", "CHIPSET", sysinfo_backend_get_chipset, TRUE},
|
||||||
{"sound", "Sound", sysinfo_backend_get_sound, TRUE},
|
{"sound", "Sound", sysinfo_backend_get_sound, TRUE},
|
||||||
{"ethernet", "Network", sysinfo_backend_get_network, TRUE},
|
{"ethernet", "Ethernet", sysinfo_backend_get_network, TRUE},
|
||||||
{"uptime", "Uptime", sysinfo_backend_get_uptime},
|
{"uptime", "Uptime", sysinfo_backend_get_uptime},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -115,30 +115,14 @@ print_summary (gboolean announce)
|
|||||||
g_free (output);
|
g_free (output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
|
||||||
normalize_info_name (const char *info)
|
|
||||||
{
|
|
||||||
if (!g_ascii_strcasecmp (info, "ram"))
|
|
||||||
return "memory";
|
|
||||||
if (!g_ascii_strcasecmp (info, "disk"))
|
|
||||||
return "storage";
|
|
||||||
if (!g_ascii_strcasecmp (info, "vga"))
|
|
||||||
return "gpu";
|
|
||||||
if (!g_ascii_strcasecmp (info, "network"))
|
|
||||||
return "ethernet";
|
|
||||||
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_info (char *info, gboolean announce)
|
print_info (char *info, gboolean announce)
|
||||||
{
|
{
|
||||||
const char *normalized = normalize_info_name (info);
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; hwinfos[i].name != NULL; i++)
|
for (i = 0; hwinfos[i].name != NULL; i++)
|
||||||
{
|
{
|
||||||
if (!g_ascii_strcasecmp (normalized, hwinfos[i].name))
|
if (!g_ascii_strcasecmp (info, hwinfos[i].name))
|
||||||
{
|
{
|
||||||
char *str = hwinfos[i].callback();
|
char *str = hwinfos[i].callback();
|
||||||
if (str)
|
if (str)
|
||||||
@@ -192,24 +176,19 @@ sysinfo_set_pref (char *key, char *value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_ascii_strcasecmp (key, "announce"))
|
if (!strcmp (key, "announce"))
|
||||||
{
|
{
|
||||||
sysinfo_set_pref_real ("announce", value, DEFAULT_ANNOUNCE);
|
sysinfo_set_pref_real (key, value, DEFAULT_ANNOUNCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!g_ascii_strncasecmp (key, "hide_", 5))
|
else if (g_str_has_prefix (key, "hide_"))
|
||||||
{
|
{
|
||||||
const char *normalized = normalize_info_name (key + 5);
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; hwinfos[i].name != NULL; i++)
|
for (i = 0; hwinfos[i].name != NULL; i++)
|
||||||
{
|
{
|
||||||
if (!g_ascii_strcasecmp (normalized, hwinfos[i].name))
|
if (!strcmp (key + 5, hwinfos[i].name))
|
||||||
{
|
{
|
||||||
char canonical[32];
|
sysinfo_set_pref_real (key, value, hwinfos[i].def);
|
||||||
|
|
||||||
g_snprintf (canonical, sizeof (canonical), "hide_%s", hwinfos[i].name);
|
|
||||||
sysinfo_set_pref_real (canonical, value, hwinfos[i].def);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,15 +220,10 @@ sysinfo_cb (char *word[], char *word_eol[], void *userdata)
|
|||||||
announce = FALSE;
|
announce = FALSE;
|
||||||
|
|
||||||
cmd = word[2+offset];
|
cmd = word[2+offset];
|
||||||
if (!cmd || !cmd[0])
|
if (!g_ascii_strcasecmp ("SET", cmd))
|
||||||
print_summary (announce);
|
|
||||||
else if (!g_ascii_strcasecmp ("REFRESH", cmd))
|
|
||||||
{
|
|
||||||
sysinfo_backend_reset_cache ();
|
|
||||||
zoitechat_print (ph, _("Sysinfo: Hardware cache cleared."));
|
|
||||||
}
|
|
||||||
else if (!g_ascii_strcasecmp ("SET", cmd))
|
|
||||||
sysinfo_set_pref (word[3+offset], word_eol[4+offset]);
|
sysinfo_set_pref (word[3+offset], word_eol[4+offset]);
|
||||||
|
else if (!cmd || !cmd[0])
|
||||||
|
print_summary (announce);
|
||||||
else
|
else
|
||||||
print_info (cmd, announce);
|
print_info (cmd, announce);
|
||||||
|
|
||||||
@@ -274,7 +248,6 @@ zoitechat_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name, char
|
|||||||
int
|
int
|
||||||
zoitechat_plugin_deinit (void)
|
zoitechat_plugin_deinit (void)
|
||||||
{
|
{
|
||||||
sysinfo_backend_reset_cache ();
|
|
||||||
zoitechat_command (ph, "MENU DEL \"Window/Send System Info\"");
|
zoitechat_command (ph, "MENU DEL \"Window/Send System Info\"");
|
||||||
zoitechat_command (ph, "MENU DEL \"Window/Display System Info\"");
|
zoitechat_command (ph, "MENU DEL \"Window/Display System Info\"");
|
||||||
zoitechat_printf (ph, _("%s plugin unloaded\n"), name);
|
zoitechat_printf (ph, _("%s plugin unloaded\n"), name);
|
||||||
|
|||||||
@@ -175,12 +175,6 @@ char *sysinfo_backend_get_uptime(void)
|
|||||||
return sysinfo_format_uptime (uptime);
|
return sysinfo_format_uptime (uptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The legacy Unix backend does not cache hardware snapshots. */
|
|
||||||
void
|
|
||||||
sysinfo_backend_reset_cache (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
char *sysinfo_backend_get_network(void)
|
char *sysinfo_backend_get_network(void)
|
||||||
{
|
{
|
||||||
char ethernet_card[bsize];
|
char ethernet_card[bsize];
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include "../format.h"
|
|
||||||
#include "memory.h"
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
MEM_TOTAL, MEM_AVAILABLE, MEM_FREE, BUFFERS, CACHED,
|
|
||||||
S_RECLAIMABLE, SHMEM, SWAP_TOTAL, SWAP_FREE, FIELD_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
parse_kib (const char *text, guint64 *value)
|
|
||||||
{
|
|
||||||
char *end;
|
|
||||||
guint64 parsed;
|
|
||||||
while (g_ascii_isspace (*text))
|
|
||||||
text++;
|
|
||||||
if (!g_ascii_isdigit (*text))
|
|
||||||
return FALSE;
|
|
||||||
errno = 0;
|
|
||||||
parsed = g_ascii_strtoull (text, &end, 10);
|
|
||||||
if (errno || parsed > G_MAXUINT64 / 1024)
|
|
||||||
return FALSE;
|
|
||||||
while (g_ascii_isspace (*end))
|
|
||||||
end++;
|
|
||||||
if (strncmp (end, "kB", 2) != 0)
|
|
||||||
return FALSE;
|
|
||||||
end += 2;
|
|
||||||
while (g_ascii_isspace (*end))
|
|
||||||
end++;
|
|
||||||
if (*end)
|
|
||||||
return FALSE;
|
|
||||||
*value = parsed;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_linux_format_meminfo (const char *contents)
|
|
||||||
{
|
|
||||||
static const char *keys[FIELD_COUNT] = {
|
|
||||||
"MemTotal:", "MemAvailable:", "MemFree:", "Buffers:", "Cached:",
|
|
||||||
"SReclaimable:", "Shmem:", "SwapTotal:", "SwapFree:"
|
|
||||||
};
|
|
||||||
guint64 values[FIELD_COUNT] = {0};
|
|
||||||
gboolean present[FIELD_COUNT] = {FALSE};
|
|
||||||
char **lines;
|
|
||||||
guint i, j;
|
|
||||||
guint64 available;
|
|
||||||
char *memory;
|
|
||||||
gboolean estimated = FALSE;
|
|
||||||
|
|
||||||
if (!contents)
|
|
||||||
return NULL;
|
|
||||||
lines = g_strsplit (contents, "\n", -1);
|
|
||||||
for (i = 0; lines[i]; i++)
|
|
||||||
{
|
|
||||||
for (j = 0; j < FIELD_COUNT; j++)
|
|
||||||
{
|
|
||||||
if (g_str_has_prefix (lines[i], keys[j]))
|
|
||||||
{
|
|
||||||
present[j] = parse_kib (lines[i] + strlen (keys[j]), &values[j]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_strfreev (lines);
|
|
||||||
if (!present[MEM_TOTAL] || !values[MEM_TOTAL])
|
|
||||||
return NULL;
|
|
||||||
if (present[MEM_AVAILABLE])
|
|
||||||
available = values[MEM_AVAILABLE];
|
|
||||||
else if (present[MEM_FREE])
|
|
||||||
{
|
|
||||||
/* Older kernels lack MemAvailable. This estimate excludes shared
|
|
||||||
* memory from the reclaimable-cache sum and is labelled as such. */
|
|
||||||
available = values[MEM_FREE] + values[BUFFERS] + values[CACHED] + values[S_RECLAIMABLE];
|
|
||||||
available -= MIN (available, values[SHMEM]);
|
|
||||||
estimated = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
available = MIN (available, values[MEM_TOTAL]);
|
|
||||||
memory = sysinfo_format_usage (values[MEM_TOTAL] * 1024, available * 1024);
|
|
||||||
if (memory && estimated)
|
|
||||||
{
|
|
||||||
char *labelled = g_strdup_printf ("%s (estimated available)", memory);
|
|
||||||
g_free (memory);
|
|
||||||
memory = labelled;
|
|
||||||
}
|
|
||||||
if (memory && present[SWAP_TOTAL] && present[SWAP_FREE] && values[SWAP_TOTAL])
|
|
||||||
{
|
|
||||||
char *swap = sysinfo_format_usage (values[SWAP_TOTAL] * 1024, values[SWAP_FREE] * 1024);
|
|
||||||
if (swap)
|
|
||||||
{
|
|
||||||
char *result = g_strdup_printf ("%s \xC2\xB7 Swap: %s", memory, swap);
|
|
||||||
g_free (memory);
|
|
||||||
g_free (swap);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return memory;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
||||||
#ifndef SYSINFO_LINUX_MEMORY_H
|
|
||||||
#define SYSINFO_LINUX_MEMORY_H
|
|
||||||
|
|
||||||
/* Parse a /proc/meminfo snapshot; the caller owns the returned string. */
|
|
||||||
char *sysinfo_linux_format_meminfo (const char *contents);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -51,18 +51,12 @@ static struct device *scan_device(struct pci_dev *p)
|
|||||||
d = g_new0 (struct device, 1);
|
d = g_new0 (struct device, 1);
|
||||||
d->dev = p;
|
d->dev = p;
|
||||||
if (!pci_read_block(p, 0, d->config, how_much))
|
if (!pci_read_block(p, 0, d->config, how_much))
|
||||||
{
|
exit(1);
|
||||||
g_free (d);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (how_much < 128 && (d->config[PCI_HEADER_TYPE] & 0x7f) == PCI_HEADER_TYPE_CARDBUS)
|
if (how_much < 128 && (d->config[PCI_HEADER_TYPE] & 0x7f) == PCI_HEADER_TYPE_CARDBUS)
|
||||||
{
|
{
|
||||||
/* For cardbus bridges, we need to fetch 64 bytes more to get the full standard header... */
|
/* For cardbus bridges, we need to fetch 64 bytes more to get the full standard header... */
|
||||||
if (!pci_read_block(p, 64, d->config+64, 64))
|
if (!pci_read_block(p, 64, d->config+64, 64))
|
||||||
{
|
exit(1);
|
||||||
g_free (d);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
how_much = 128;
|
how_much = 128;
|
||||||
}
|
}
|
||||||
d->config_cnt = how_much;
|
d->config_cnt = how_much;
|
||||||
@@ -122,14 +116,6 @@ int pci_find_by_class(u16 *class, char *vendor, char *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pci_cleanup(pacc);
|
pci_cleanup(pacc);
|
||||||
pacc = NULL;
|
|
||||||
/* Free the cached configuration buffers after libpci is done with them. */
|
|
||||||
while (first_dev)
|
|
||||||
{
|
|
||||||
d = first_dev;
|
|
||||||
first_dev = d->next;
|
|
||||||
g_free (d);
|
|
||||||
}
|
|
||||||
return nomatch;
|
return nomatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +142,8 @@ void pci_find_fullname(char *fullname, char *vendor, char *device)
|
|||||||
position = strstr(buffer, vendor);
|
position = strstr(buffer, vendor);
|
||||||
position += 6;
|
position += 6;
|
||||||
g_strlcpy(vendorname, position, sizeof (vendorname));
|
g_strlcpy(vendorname, position, sizeof (vendorname));
|
||||||
g_strchomp (vendorname);
|
position = strstr(vendorname, "\n");
|
||||||
|
*(position) = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,9 +155,9 @@ void pci_find_fullname(char *fullname, char *vendor, char *device)
|
|||||||
position += 6;
|
position += 6;
|
||||||
g_strlcpy(devicename, position, sizeof (devicename));
|
g_strlcpy(devicename, position, sizeof (devicename));
|
||||||
position = strstr(devicename, " (");
|
position = strstr(devicename, " (");
|
||||||
if (position)
|
if (position == NULL)
|
||||||
*position = '\0';
|
position = strstr(devicename, "\n");
|
||||||
g_strchomp (devicename);
|
*(position) = '\0';
|
||||||
cardfound = 1;
|
cardfound = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,232 +0,0 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
||||||
/* Whole capacity of the disk backing the boot filesystem. */
|
|
||||||
#define _XOPEN_SOURCE 700
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include "../sysinfo-backend.h"
|
|
||||||
#include "storage.h"
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
read_capacity (const char *entry, guint64 *capacity)
|
|
||||||
{
|
|
||||||
char *path = g_build_filename (entry, "size", NULL);
|
|
||||||
char *contents = NULL;
|
|
||||||
char *end;
|
|
||||||
guint64 sectors;
|
|
||||||
gboolean valid = FALSE;
|
|
||||||
|
|
||||||
if (g_file_get_contents (path, &contents, NULL, NULL))
|
|
||||||
{
|
|
||||||
g_strstrip (contents);
|
|
||||||
if (g_ascii_isdigit (contents[0]))
|
|
||||||
{
|
|
||||||
errno = 0;
|
|
||||||
sectors = g_ascii_strtoull (contents, &end, 10);
|
|
||||||
/* Linux reports size in 512-byte sectors, including 4Kn disks. */
|
|
||||||
if (!errno && *end == '\0' && sectors && sectors <= G_MAXUINT64 / 512)
|
|
||||||
{
|
|
||||||
*capacity = sectors * 512;
|
|
||||||
valid = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_free (contents);
|
|
||||||
g_free (path);
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
has_entry (const char *entry, const char *name)
|
|
||||||
{
|
|
||||||
char *path = g_build_filename (entry, name, NULL);
|
|
||||||
gboolean present = g_file_test (path, G_FILE_TEST_EXISTS);
|
|
||||||
g_free (path);
|
|
||||||
return present;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Resolve the kernel device link before walking from a partition to its
|
|
||||||
* parent. Never infer the parent by stripping digits from a device name. */
|
|
||||||
static gboolean
|
|
||||||
resolve_disk (const char *entry, char **disk, guint depth)
|
|
||||||
{
|
|
||||||
char *resolved = realpath (entry, NULL);
|
|
||||||
char *slaves = NULL;
|
|
||||||
GDir *dir = NULL;
|
|
||||||
const char *name;
|
|
||||||
gboolean valid = FALSE;
|
|
||||||
|
|
||||||
if (!resolved || depth >= 32)
|
|
||||||
goto done;
|
|
||||||
if (has_entry (resolved, "partition"))
|
|
||||||
{
|
|
||||||
char *parent = g_path_get_dirname (resolved);
|
|
||||||
valid = resolve_disk (parent, disk, depth + 1);
|
|
||||||
g_free (parent);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Follow LUKS/LVM/MD layers. Multiple distinct underlying disks are
|
|
||||||
* ambiguous, so don't arbitrarily choose one of them. */
|
|
||||||
slaves = g_build_filename (resolved, "slaves", NULL);
|
|
||||||
dir = g_dir_open (slaves, 0, NULL);
|
|
||||||
if (dir && (name = g_dir_read_name (dir)) != NULL)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
char *child = g_build_filename (slaves, name, NULL);
|
|
||||||
valid = resolve_disk (child, disk, depth + 1);
|
|
||||||
g_free (child);
|
|
||||||
if (!valid)
|
|
||||||
goto done;
|
|
||||||
} while ((name = g_dir_read_name (dir)) != NULL);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
name = strrchr (resolved, '/');
|
|
||||||
name = name ? name + 1 : resolved;
|
|
||||||
if (g_str_has_prefix (name, "loop") || g_str_has_prefix (name, "ram") ||
|
|
||||||
g_str_has_prefix (name, "zram") || g_str_has_prefix (name, "sr") ||
|
|
||||||
g_str_has_prefix (name, "fd") || g_str_has_prefix (name, "dm-") ||
|
|
||||||
g_str_has_prefix (name, "md") || !has_entry (resolved, "device"))
|
|
||||||
goto done;
|
|
||||||
if (!*disk)
|
|
||||||
*disk = g_strdup (resolved);
|
|
||||||
valid = strcmp (*disk, resolved) == 0;
|
|
||||||
|
|
||||||
done:
|
|
||||||
if (dir)
|
|
||||||
g_dir_close (dir);
|
|
||||||
g_free (slaves);
|
|
||||||
free (resolved);
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
static guint
|
|
||||||
boot_mount_priority (const char *mountpoint)
|
|
||||||
{
|
|
||||||
if (strcmp (mountpoint, "/boot") == 0)
|
|
||||||
return 4;
|
|
||||||
if (strcmp (mountpoint, "/boot/efi") == 0)
|
|
||||||
return 3;
|
|
||||||
if (strcmp (mountpoint, "/efi") == 0)
|
|
||||||
return 2;
|
|
||||||
if (strcmp (mountpoint, "/") == 0)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
valid_device_number (const char *id)
|
|
||||||
{
|
|
||||||
const char *p = id;
|
|
||||||
if (!g_ascii_isdigit (*p))
|
|
||||||
return FALSE;
|
|
||||||
while (g_ascii_isdigit (*p))
|
|
||||||
p++;
|
|
||||||
if (*p++ != ':' || !g_ascii_isdigit (*p))
|
|
||||||
return FALSE;
|
|
||||||
while (g_ascii_isdigit (*p))
|
|
||||||
p++;
|
|
||||||
return *p == '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
resolve_mount_device (const char *sysfs, const char *id, const char *source)
|
|
||||||
{
|
|
||||||
char *entry = NULL;
|
|
||||||
struct stat st;
|
|
||||||
|
|
||||||
/* Btrfs and some other filesystems expose a synthetic mount device
|
|
||||||
* number. Prefer a verified source block device in that case. */
|
|
||||||
if (valid_device_number (id))
|
|
||||||
{
|
|
||||||
entry = g_build_filename (sysfs, "dev", "block", id, NULL);
|
|
||||||
if (g_file_test (entry, G_FILE_TEST_EXISTS))
|
|
||||||
return entry;
|
|
||||||
g_free (entry);
|
|
||||||
}
|
|
||||||
if (g_str_has_prefix (source, "/dev/") && stat (source, &st) == 0 && S_ISBLK (st.st_mode))
|
|
||||||
{
|
|
||||||
char *number = g_strdup_printf ("%u:%u", (unsigned int) major (st.st_rdev),
|
|
||||||
(unsigned int) minor (st.st_rdev));
|
|
||||||
entry = g_build_filename (sysfs, "dev", "block", number, NULL);
|
|
||||||
g_free (number);
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
/* A sandbox may hide /dev nodes but still expose kernel block names.
|
|
||||||
* Only accept a direct /dev/<name>, never guess a mapper/UUID alias. */
|
|
||||||
if (g_str_has_prefix (source, "/dev/") && source[5] &&
|
|
||||||
strcmp (source + 5, ".") != 0 && strcmp (source + 5, "..") != 0 &&
|
|
||||||
!strchr (source + 5, '/') && !strchr (source + 5, '\\'))
|
|
||||||
return g_build_filename (sysfs, "class", "block", source + 5, NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_linux_boot_disk (const char *sysfs, const char *mountinfo)
|
|
||||||
{
|
|
||||||
char **lines = g_strsplit (mountinfo, "\n", -1);
|
|
||||||
char *entry = NULL, *disk = NULL, *result = NULL;
|
|
||||||
guint priority = 0, i;
|
|
||||||
guint64 capacity;
|
|
||||||
gboolean ambiguous = FALSE;
|
|
||||||
|
|
||||||
for (i = 0; lines[i]; i++)
|
|
||||||
{
|
|
||||||
char **fields = g_strsplit (lines[i], " ", -1);
|
|
||||||
guint count = g_strv_length (fields), rank, j;
|
|
||||||
|
|
||||||
if (count < 10 || !(rank = boot_mount_priority (fields[4])) || rank < priority)
|
|
||||||
{
|
|
||||||
g_strfreev (fields);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (j = 6; j + 3 < count; j++)
|
|
||||||
if (strcmp (fields[j], "-") == 0)
|
|
||||||
{
|
|
||||||
char *candidate = resolve_mount_device (sysfs, fields[2], fields[j + 2]);
|
|
||||||
if (rank > priority)
|
|
||||||
{
|
|
||||||
g_free (entry);
|
|
||||||
entry = candidate;
|
|
||||||
priority = rank;
|
|
||||||
ambiguous = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (g_strcmp0 (entry, candidate) != 0)
|
|
||||||
ambiguous = TRUE;
|
|
||||||
g_free (candidate);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
g_strfreev (fields);
|
|
||||||
}
|
|
||||||
g_strfreev (lines);
|
|
||||||
|
|
||||||
if (!ambiguous && entry && resolve_disk (entry, &disk, 0) &&
|
|
||||||
read_capacity (disk, &capacity))
|
|
||||||
result = g_format_size (capacity);
|
|
||||||
g_free (disk);
|
|
||||||
g_free (entry);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_backend_get_disk (void)
|
|
||||||
{
|
|
||||||
char *mountinfo = NULL;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
/* The sandbox root is not the host boot filesystem. Without a trusted
|
|
||||||
* host mount table there is no reliable way to identify its boot disk. */
|
|
||||||
if (g_file_test ("/.flatpak-info", G_FILE_TEST_IS_REGULAR) ||
|
|
||||||
!g_file_get_contents ("/proc/self/mountinfo", &mountinfo, NULL, NULL))
|
|
||||||
return NULL;
|
|
||||||
result = sysinfo_linux_boot_disk ("/sys", mountinfo);
|
|
||||||
g_free (mountinfo);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
||||||
#ifndef SYSINFO_LINUX_STORAGE_H
|
|
||||||
#define SYSINFO_LINUX_STORAGE_H
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
/* Returns the whole boot disk size, or NULL if it cannot be identified. */
|
|
||||||
char *sysinfo_linux_boot_disk (const char *sysfs, const char *mountinfo);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,35 +1,28 @@
|
|||||||
/*
|
/* ZoiteChat
|
||||||
* Modern Windows SysInfo backend for ZoiteChat.
|
* Copyright (c) 2011-2012 Berke Viktor.
|
||||||
*
|
*
|
||||||
* Avoids WMI in the plugin hot path and uses native Win32/DXGI APIs.
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _WIN32_WINNT
|
|
||||||
#define _WIN32_WINNT 0x0601
|
|
||||||
#elif _WIN32_WINNT < 0x0601
|
|
||||||
#undef _WIN32_WINNT
|
|
||||||
#define _WIN32_WINNT 0x0601
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <winternl.h>
|
|
||||||
#include <dxgi.h>
|
|
||||||
#include <iphlpapi.h>
|
|
||||||
#include <ipifcons.h>
|
|
||||||
#include <mmsystem.h>
|
|
||||||
#include <winioctl.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma comment(lib, "advapi32.lib")
|
|
||||||
#pragma comment(lib, "dxgi.lib")
|
|
||||||
#pragma comment(lib, "dxguid.lib")
|
|
||||||
#pragma comment(lib, "iphlpapi.lib")
|
|
||||||
#pragma comment(lib, "winmm.lib")
|
|
||||||
#endif
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <windows.h>
|
||||||
|
#include <wbemidl.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@@ -37,502 +30,63 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../../../src/common/sysinfo/sysinfo.h"
|
||||||
|
|
||||||
#include "../format.h"
|
#include "../format.h"
|
||||||
#include "../sysinfo-backend.h"
|
|
||||||
|
|
||||||
#define SYSINFO_SEP " \xC2\xB7 "
|
static char *get_memory_info (void);
|
||||||
|
|
||||||
typedef struct
|
char *
|
||||||
|
sysinfo_backend_get_sound (void)
|
||||||
{
|
{
|
||||||
char *os;
|
return NULL;
|
||||||
char *cpu;
|
|
||||||
char *gpu;
|
|
||||||
char *sound;
|
|
||||||
} WinStaticSnapshot;
|
|
||||||
|
|
||||||
/* Sysinfo callbacks and plugin teardown run on the client thread. */
|
|
||||||
static WinStaticSnapshot snapshot;
|
|
||||||
static gboolean os_initialized;
|
|
||||||
static gboolean cpu_initialized;
|
|
||||||
static gboolean gpu_initialized;
|
|
||||||
static gboolean sound_initialized;
|
|
||||||
|
|
||||||
void
|
|
||||||
sysinfo_backend_reset_cache (void)
|
|
||||||
{
|
|
||||||
g_clear_pointer (&snapshot.os, g_free);
|
|
||||||
g_clear_pointer (&snapshot.cpu, g_free);
|
|
||||||
g_clear_pointer (&snapshot.gpu, g_free);
|
|
||||||
g_clear_pointer (&snapshot.sound, g_free);
|
|
||||||
os_initialized = FALSE;
|
|
||||||
cpu_initialized = FALSE;
|
|
||||||
gpu_initialized = FALSE;
|
|
||||||
sound_initialized = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *wide_to_utf8 (const WCHAR *value);
|
|
||||||
static char *read_registry_string (HKEY root, const WCHAR *subkey, const WCHAR *value_name);
|
|
||||||
static gboolean read_registry_dword (HKEY root, const WCHAR *subkey, const WCHAR *value_name, DWORD *value);
|
|
||||||
static const char *get_native_arch (void);
|
|
||||||
static DWORD get_windows_build_number (void);
|
|
||||||
static char *build_os_string (void);
|
|
||||||
static DWORD count_physical_cores (void);
|
|
||||||
static char *build_cpu_string (void);
|
|
||||||
static char *build_gpu_string (void);
|
|
||||||
static char *build_sound_string (void);
|
|
||||||
static void ensure_os_snapshot (void);
|
|
||||||
static void ensure_cpu_snapshot (void);
|
|
||||||
static void ensure_gpu_snapshot (void);
|
|
||||||
static void ensure_sound_snapshot (void);
|
|
||||||
#define format_usage sysinfo_format_usage
|
|
||||||
#define join_ptr_array sysinfo_join_ptr_array
|
|
||||||
#define ptr_array_add_unique(items, value) sysinfo_ptr_array_add_unique ((items), (value), TRUE)
|
|
||||||
static gboolean adapter_looks_virtual (const char *name);
|
|
||||||
|
|
||||||
static char *
|
|
||||||
wide_to_utf8 (const WCHAR *value)
|
|
||||||
{
|
|
||||||
if (!value || value[0] == L'\0')
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_utf16_to_utf8 ((const gunichar2 *) value, -1, NULL, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
read_registry_string (HKEY root, const WCHAR *subkey, const WCHAR *value_name)
|
|
||||||
{
|
|
||||||
HKEY key;
|
|
||||||
DWORD type = 0;
|
|
||||||
DWORD size = 0;
|
|
||||||
WCHAR *buffer;
|
|
||||||
char *result = NULL;
|
|
||||||
LONG status;
|
|
||||||
|
|
||||||
status = RegOpenKeyExW (root, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &key);
|
|
||||||
if (status != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = RegQueryValueExW (key, value_name, NULL, &type, NULL, &size);
|
|
||||||
if (status != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ) || size < sizeof (WCHAR))
|
|
||||||
{
|
|
||||||
RegCloseKey (key);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = g_malloc0 ((gsize) size + sizeof (WCHAR));
|
|
||||||
status = RegQueryValueExW (key, value_name, NULL, &type, (LPBYTE) buffer, &size);
|
|
||||||
if (status == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
result = wide_to_utf8 (buffer);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
g_strstrip (result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (buffer);
|
|
||||||
RegCloseKey (key);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
read_registry_dword (HKEY root, const WCHAR *subkey, const WCHAR *value_name, DWORD *value)
|
|
||||||
{
|
|
||||||
HKEY key;
|
|
||||||
DWORD type = 0;
|
|
||||||
DWORD size = sizeof (*value);
|
|
||||||
LONG status;
|
|
||||||
|
|
||||||
status = RegOpenKeyExW (root, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &key);
|
|
||||||
if (status != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = RegQueryValueExW (key, value_name, NULL, &type, (LPBYTE) value, &size);
|
|
||||||
RegCloseKey (key);
|
|
||||||
return status == ERROR_SUCCESS && type == REG_DWORD;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
get_native_arch (void)
|
|
||||||
{
|
|
||||||
SYSTEM_INFO info;
|
|
||||||
|
|
||||||
GetNativeSystemInfo (&info);
|
|
||||||
switch (info.wProcessorArchitecture)
|
|
||||||
{
|
|
||||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
|
||||||
return "x64";
|
|
||||||
case PROCESSOR_ARCHITECTURE_ARM64:
|
|
||||||
return "ARM64";
|
|
||||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
|
||||||
return "x86";
|
|
||||||
default:
|
|
||||||
return "unknown-arch";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static DWORD
|
|
||||||
get_windows_build_number (void)
|
|
||||||
{
|
|
||||||
typedef LONG (WINAPI *RtlGetVersionFn) (PRTL_OSVERSIONINFOW);
|
|
||||||
HMODULE ntdll;
|
|
||||||
RtlGetVersionFn rtl_get_version;
|
|
||||||
RTL_OSVERSIONINFOW version;
|
|
||||||
DWORD build = 0;
|
|
||||||
|
|
||||||
ntdll = GetModuleHandleW (L"ntdll.dll");
|
|
||||||
if (ntdll)
|
|
||||||
{
|
|
||||||
rtl_get_version = (RtlGetVersionFn) GetProcAddress (ntdll, "RtlGetVersion");
|
|
||||||
if (rtl_get_version)
|
|
||||||
{
|
|
||||||
ZeroMemory (&version, sizeof (version));
|
|
||||||
version.dwOSVersionInfoSize = sizeof (version);
|
|
||||||
if (rtl_get_version (&version) == 0)
|
|
||||||
{
|
|
||||||
build = version.dwBuildNumber;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return build;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
build_os_string (void)
|
|
||||||
{
|
|
||||||
static const WCHAR current_version_key[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
|
|
||||||
char *product;
|
|
||||||
char *display_version;
|
|
||||||
char *registry_build;
|
|
||||||
char *fixed_product = NULL;
|
|
||||||
char *result;
|
|
||||||
DWORD ubr = 0;
|
|
||||||
DWORD build;
|
|
||||||
guint64 parsed_build = 0;
|
|
||||||
|
|
||||||
product = read_registry_string (HKEY_LOCAL_MACHINE, current_version_key, L"ProductName");
|
|
||||||
display_version = read_registry_string (HKEY_LOCAL_MACHINE, current_version_key, L"DisplayVersion");
|
|
||||||
registry_build = read_registry_string (HKEY_LOCAL_MACHINE, current_version_key, L"CurrentBuildNumber");
|
|
||||||
read_registry_dword (HKEY_LOCAL_MACHINE, current_version_key, L"UBR", &ubr);
|
|
||||||
|
|
||||||
build = get_windows_build_number ();
|
|
||||||
if (registry_build)
|
|
||||||
{
|
|
||||||
parsed_build = g_ascii_strtoull (registry_build, NULL, 10);
|
|
||||||
if (parsed_build != 0)
|
|
||||||
{
|
|
||||||
build = (DWORD) parsed_build;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!product)
|
|
||||||
{
|
|
||||||
product = g_strdup (build >= 22000 ? "Windows 11" : "Windows");
|
|
||||||
}
|
|
||||||
else if (build >= 22000 && g_str_has_prefix (product, "Windows 10"))
|
|
||||||
{
|
|
||||||
fixed_product = g_strdup_printf ("Windows 11%s", product + strlen ("Windows 10"));
|
|
||||||
g_free (product);
|
|
||||||
product = fixed_product;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (display_version && build != 0)
|
|
||||||
{
|
|
||||||
result = g_strdup_printf ("%s %s" SYSINFO_SEP "build %lu.%lu" SYSINFO_SEP "%s",
|
|
||||||
product, display_version, (unsigned long) build, (unsigned long) ubr, get_native_arch ());
|
|
||||||
}
|
|
||||||
else if (build != 0)
|
|
||||||
{
|
|
||||||
result = g_strdup_printf ("%s" SYSINFO_SEP "build %lu.%lu" SYSINFO_SEP "%s",
|
|
||||||
product, (unsigned long) build, (unsigned long) ubr, get_native_arch ());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = g_strdup_printf ("%s" SYSINFO_SEP "%s", product, get_native_arch ());
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (product);
|
|
||||||
g_free (display_version);
|
|
||||||
g_free (registry_build);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DWORD
|
|
||||||
count_physical_cores (void)
|
|
||||||
{
|
|
||||||
DWORD length = 0;
|
|
||||||
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX buffer;
|
|
||||||
BYTE *cursor;
|
|
||||||
BYTE *end;
|
|
||||||
DWORD cores = 0;
|
|
||||||
|
|
||||||
GetLogicalProcessorInformationEx (RelationProcessorCore, NULL, &length);
|
|
||||||
if (GetLastError () != ERROR_INSUFFICIENT_BUFFER || length == 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = g_malloc0 (length);
|
|
||||||
if (!GetLogicalProcessorInformationEx (RelationProcessorCore, buffer, &length))
|
|
||||||
{
|
|
||||||
g_free (buffer);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor = (BYTE *) buffer;
|
|
||||||
end = cursor + length;
|
|
||||||
while (cursor < end)
|
|
||||||
{
|
|
||||||
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX info = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) cursor;
|
|
||||||
|
|
||||||
if (info->Size == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (info->Relationship == RelationProcessorCore)
|
|
||||||
{
|
|
||||||
cores++;
|
|
||||||
}
|
|
||||||
cursor += info->Size;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (buffer);
|
|
||||||
return cores;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
build_cpu_string (void)
|
|
||||||
{
|
|
||||||
static const WCHAR cpu_key[] = L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
|
|
||||||
char *name;
|
|
||||||
DWORD cores;
|
|
||||||
DWORD threads;
|
|
||||||
SYSTEM_INFO info;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
name = read_registry_string (HKEY_LOCAL_MACHINE, cpu_key, L"ProcessorNameString");
|
|
||||||
if (!name)
|
|
||||||
{
|
|
||||||
name = g_strdup ("Unknown CPU");
|
|
||||||
}
|
|
||||||
|
|
||||||
cores = count_physical_cores ();
|
|
||||||
threads = GetActiveProcessorCount (ALL_PROCESSOR_GROUPS);
|
|
||||||
if (threads == 0)
|
|
||||||
{
|
|
||||||
GetNativeSystemInfo (&info);
|
|
||||||
threads = info.dwNumberOfProcessors;
|
|
||||||
}
|
|
||||||
if (cores != 0)
|
|
||||||
{
|
|
||||||
result = g_strdup_printf ("%s" SYSINFO_SEP "%luC/%luT",
|
|
||||||
name, (unsigned long) cores, (unsigned long) threads);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Logical processor count cannot establish the physical core count. */
|
|
||||||
result = g_strdup_printf ("%s" SYSINFO_SEP "%luT", name, (unsigned long) threads);
|
|
||||||
}
|
|
||||||
g_free (name);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
build_gpu_string (void)
|
|
||||||
{
|
|
||||||
IDXGIFactory1 *factory = NULL;
|
|
||||||
GPtrArray *adapters;
|
|
||||||
UINT index;
|
|
||||||
HRESULT hr;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
hr = CreateDXGIFactory1 (&IID_IDXGIFactory1, (void **) &factory);
|
|
||||||
if (FAILED (hr) || !factory)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
adapters = g_ptr_array_new_with_free_func (g_free);
|
|
||||||
for (index = 0; ; index++)
|
|
||||||
{
|
|
||||||
IDXGIAdapter1 *adapter = NULL;
|
|
||||||
DXGI_ADAPTER_DESC1 desc;
|
|
||||||
char *name;
|
|
||||||
char *label;
|
|
||||||
|
|
||||||
hr = factory->lpVtbl->EnumAdapters1 (factory, index, &adapter);
|
|
||||||
if (hr == DXGI_ERROR_NOT_FOUND)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (FAILED (hr) || !adapter)
|
|
||||||
{
|
|
||||||
/* A failed enumeration is not another adapter. Retrying every
|
|
||||||
* index can freeze the client indefinitely after a device error. */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZeroMemory (&desc, sizeof (desc));
|
|
||||||
hr = adapter->lpVtbl->GetDesc1 (adapter, &desc);
|
|
||||||
adapter->lpVtbl->Release (adapter);
|
|
||||||
if (FAILED (hr) || (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = wide_to_utf8 (desc.Description);
|
|
||||||
if (!name)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
g_strstrip (name);
|
|
||||||
|
|
||||||
if ((guint64) desc.DedicatedVideoMemory >= (512ULL * 1024ULL * 1024ULL))
|
|
||||||
{
|
|
||||||
char *vram = g_format_size_full ((guint64) desc.DedicatedVideoMemory, G_FORMAT_SIZE_IEC_UNITS);
|
|
||||||
label = g_strdup_printf ("%s (%s VRAM)", name, vram);
|
|
||||||
g_free (vram);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
label = g_strdup (name);
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr_array_add_unique (adapters, label);
|
|
||||||
g_free (label);
|
|
||||||
g_free (name);
|
|
||||||
}
|
|
||||||
|
|
||||||
factory->lpVtbl->Release (factory);
|
|
||||||
result = join_ptr_array (adapters, ", ");
|
|
||||||
g_ptr_array_free (adapters, TRUE);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
build_sound_string (void)
|
|
||||||
{
|
|
||||||
UINT count;
|
|
||||||
UINT i;
|
|
||||||
GPtrArray *devices;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
count = waveOutGetNumDevs ();
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
devices = g_ptr_array_new_with_free_func (g_free);
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
WAVEOUTCAPSW caps;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
ZeroMemory (&caps, sizeof (caps));
|
|
||||||
if (waveOutGetDevCapsW ((UINT_PTR) i, &caps, sizeof (caps)) != MMSYSERR_NOERROR)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = wide_to_utf8 (caps.szPname);
|
|
||||||
if (name)
|
|
||||||
{
|
|
||||||
g_strstrip (name);
|
|
||||||
ptr_array_add_unique (devices, name);
|
|
||||||
g_free (name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = join_ptr_array (devices, ", ");
|
|
||||||
g_ptr_array_free (devices, TRUE);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ensure_os_snapshot (void)
|
|
||||||
{
|
|
||||||
if (!os_initialized)
|
|
||||||
{
|
|
||||||
snapshot.os = build_os_string ();
|
|
||||||
os_initialized = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ensure_cpu_snapshot (void)
|
|
||||||
{
|
|
||||||
if (!cpu_initialized)
|
|
||||||
{
|
|
||||||
snapshot.cpu = build_cpu_string ();
|
|
||||||
cpu_initialized = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ensure_gpu_snapshot (void)
|
|
||||||
{
|
|
||||||
if (!gpu_initialized)
|
|
||||||
{
|
|
||||||
snapshot.gpu = build_gpu_string ();
|
|
||||||
gpu_initialized = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
ensure_sound_snapshot (void)
|
|
||||||
{
|
|
||||||
if (!sound_initialized)
|
|
||||||
{
|
|
||||||
snapshot.sound = build_sound_string ();
|
|
||||||
sound_initialized = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
sysinfo_backend_get_os (void)
|
sysinfo_backend_get_network (void)
|
||||||
{
|
{
|
||||||
ensure_os_snapshot ();
|
return NULL;
|
||||||
return g_strdup (snapshot.os);
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_uptime (void)
|
||||||
|
{
|
||||||
|
return sysinfo_format_uptime (GetTickCount64 () / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysinfo_backend_get_disk (void)
|
||||||
|
{
|
||||||
|
guint64 hdd_capacity;
|
||||||
|
guint64 hdd_free_space;
|
||||||
|
|
||||||
|
sysinfo_get_hdd_info (&hdd_capacity, &hdd_free_space);
|
||||||
|
|
||||||
|
if (hdd_capacity != 0)
|
||||||
|
{
|
||||||
|
return sysinfo_format_disk(hdd_capacity, hdd_free_space);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
sysinfo_backend_get_cpu (void)
|
sysinfo_backend_get_cpu (void)
|
||||||
{
|
{
|
||||||
static const WCHAR cpu_key[] = L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
|
return sysinfo_get_cpu ();
|
||||||
DWORD mhz = 0;
|
}
|
||||||
ensure_cpu_snapshot ();
|
|
||||||
if (!snapshot.cpu)
|
char *
|
||||||
return NULL;
|
sysinfo_backend_get_memory (void)
|
||||||
/* The registry's reported MHz is not a guaranteed live or turbo clock. */
|
{
|
||||||
if (read_registry_dword (HKEY_LOCAL_MACHINE, cpu_key, L"~MHz", &mhz) && mhz && mhz <= 100000)
|
/* Memory information is always loaded dynamically since it includes the current amount of free memory */
|
||||||
{
|
return get_memory_info ();
|
||||||
if (mhz >= 1000)
|
|
||||||
return g_strdup_printf ("%s" SYSINFO_SEP "reported %.2f GHz", snapshot.cpu, (double) mhz / 1000.0);
|
|
||||||
return g_strdup_printf ("%s" SYSINFO_SEP "reported %lu MHz", snapshot.cpu, (unsigned long) mhz);
|
|
||||||
}
|
|
||||||
return g_strdup (snapshot.cpu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
sysinfo_backend_get_gpu (void)
|
sysinfo_backend_get_gpu (void)
|
||||||
{
|
{
|
||||||
ensure_gpu_snapshot ();
|
return sysinfo_get_gpu ();
|
||||||
return g_strdup (snapshot.gpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_backend_get_sound (void)
|
|
||||||
{
|
|
||||||
ensure_sound_snapshot ();
|
|
||||||
return g_strdup (snapshot.sound);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@@ -542,207 +96,43 @@ sysinfo_backend_get_chipset (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
sysinfo_backend_get_memory (void)
|
sysinfo_backend_get_os (void)
|
||||||
{
|
{
|
||||||
MEMORYSTATUSEX memory;
|
return sysinfo_get_os ();
|
||||||
|
}
|
||||||
|
|
||||||
ZeroMemory (&memory, sizeof (memory));
|
static char *get_memory_info (void)
|
||||||
memory.dwLength = sizeof (memory);
|
{
|
||||||
if (!GlobalMemoryStatusEx (&memory))
|
MEMORYSTATUSEX meminfo = { 0 };
|
||||||
|
meminfo.dwLength = sizeof (meminfo);
|
||||||
|
|
||||||
|
if (!GlobalMemoryStatusEx (&meminfo))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return format_usage ((guint64) memory.ullTotalPhys, (guint64) memory.ullAvailPhys);
|
return sysinfo_format_memory (meminfo.ullTotalPhys, meminfo.ullAvailPhys);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static const char *sysinfo_detect_toolkit(void)
|
||||||
get_boot_disk_number (DWORD *number)
|
|
||||||
{
|
{
|
||||||
WCHAR windows_dir[MAX_PATH];
|
#if defined(USE_GTK_FRONTEND)
|
||||||
WCHAR volume_path[MAX_PATH];
|
return "GTK3";
|
||||||
WCHAR volume_name[MAX_PATH];
|
#else
|
||||||
UINT length;
|
return NULL;
|
||||||
HANDLE volume;
|
#endif
|
||||||
VOLUME_DISK_EXTENTS extents;
|
|
||||||
DWORD returned;
|
|
||||||
gboolean valid = FALSE;
|
|
||||||
|
|
||||||
/* Windows calls the volume containing Windows the boot volume. Resolve
|
|
||||||
* it to a volume GUID instead of assuming Windows is installed on C:. */
|
|
||||||
length = GetWindowsDirectoryW (windows_dir, G_N_ELEMENTS (windows_dir));
|
|
||||||
if (!length || length >= G_N_ELEMENTS (windows_dir) ||
|
|
||||||
!GetVolumePathNameW (windows_dir, volume_path, G_N_ELEMENTS (volume_path)) ||
|
|
||||||
GetDriveTypeW (volume_path) != DRIVE_FIXED ||
|
|
||||||
!GetVolumeNameForVolumeMountPointW (volume_path, volume_name, G_N_ELEMENTS (volume_name)))
|
|
||||||
return FALSE;
|
|
||||||
length = lstrlenW (volume_name);
|
|
||||||
if (!length || volume_name[length - 1] != L'\\')
|
|
||||||
return FALSE;
|
|
||||||
volume_name[length - 1] = L'\0';
|
|
||||||
volume = CreateFileW (volume_name, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
||||||
NULL, OPEN_EXISTING, 0, NULL);
|
|
||||||
if (volume == INVALID_HANDLE_VALUE)
|
|
||||||
return FALSE;
|
|
||||||
/* Refuse spanned volumes rather than choosing an arbitrary disk. */
|
|
||||||
if (DeviceIoControl (volume, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0,
|
|
||||||
&extents, sizeof (extents), &returned, NULL) && returned >= sizeof (extents) &&
|
|
||||||
extents.NumberOfDiskExtents == 1)
|
|
||||||
{
|
|
||||||
*number = extents.Extents[0].DiskNumber;
|
|
||||||
valid = TRUE;
|
|
||||||
}
|
|
||||||
CloseHandle (volume);
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_backend_get_disk (void)
|
|
||||||
{
|
|
||||||
DWORD number, returned, previous_mode = 0;
|
|
||||||
BOOL error_mode_changed;
|
|
||||||
DISK_GEOMETRY_EX geometry;
|
|
||||||
HANDLE disk;
|
|
||||||
char *path, *result = NULL;
|
|
||||||
|
|
||||||
error_mode_changed = SetThreadErrorMode (GetThreadErrorMode () | SEM_FAILCRITICALERRORS, &previous_mode);
|
|
||||||
if (get_boot_disk_number (&number))
|
|
||||||
{
|
|
||||||
/* The PhysicalDrive handle describes the complete disk, not a
|
|
||||||
* partition or filesystem. Request metadata access only. */
|
|
||||||
path = g_strdup_printf ("\\\\.\\PhysicalDrive%lu", (unsigned long) number);
|
|
||||||
disk = CreateFileA (path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
||||||
NULL, OPEN_EXISTING, 0, NULL);
|
|
||||||
g_free (path);
|
|
||||||
if (disk != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
if (DeviceIoControl (disk, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0,
|
|
||||||
&geometry, sizeof (geometry), &returned, NULL) &&
|
|
||||||
returned >= FIELD_OFFSET (DISK_GEOMETRY_EX, Data) && geometry.DiskSize.QuadPart > 0)
|
|
||||||
result = g_format_size ((guint64) geometry.DiskSize.QuadPart);
|
|
||||||
CloseHandle (disk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (error_mode_changed)
|
|
||||||
SetThreadErrorMode (previous_mode, NULL);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_backend_get_uptime (void)
|
|
||||||
{
|
|
||||||
return sysinfo_format_uptime ((gint64) (GetTickCount64 () / 1000ULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
adapter_looks_virtual (const char *name)
|
|
||||||
{
|
|
||||||
char *lower;
|
|
||||||
gboolean result;
|
|
||||||
|
|
||||||
if (!name)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
lower = g_ascii_strdown (name, -1);
|
|
||||||
result = strstr (lower, "virtual") != NULL ||
|
|
||||||
strstr (lower, "hyper-v") != NULL ||
|
|
||||||
strstr (lower, "vmware") != NULL ||
|
|
||||||
strstr (lower, "virtualbox") != NULL ||
|
|
||||||
strstr (lower, "tap-windows") != NULL ||
|
|
||||||
strstr (lower, "wireguard") != NULL ||
|
|
||||||
strstr (lower, "vpn") != NULL;
|
|
||||||
g_free (lower);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
sysinfo_backend_get_network (void)
|
|
||||||
{
|
|
||||||
ULONG size = 16 * 1024;
|
|
||||||
ULONG status;
|
|
||||||
IP_ADAPTER_ADDRESSES *addresses;
|
|
||||||
IP_ADAPTER_ADDRESSES *adapter;
|
|
||||||
GPtrArray *physical;
|
|
||||||
GPtrArray *fallback;
|
|
||||||
GPtrArray *selected;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
addresses = g_malloc0 (size);
|
|
||||||
status = GetAdaptersAddresses (AF_UNSPEC,
|
|
||||||
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
|
|
||||||
NULL, addresses, &size);
|
|
||||||
if (status == ERROR_BUFFER_OVERFLOW)
|
|
||||||
{
|
|
||||||
g_free (addresses);
|
|
||||||
addresses = g_malloc0 (size);
|
|
||||||
status = GetAdaptersAddresses (AF_UNSPEC,
|
|
||||||
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
|
|
||||||
NULL, addresses, &size);
|
|
||||||
}
|
|
||||||
if (status != NO_ERROR)
|
|
||||||
{
|
|
||||||
g_free (addresses);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
physical = g_ptr_array_new_with_free_func (g_free);
|
|
||||||
fallback = g_ptr_array_new_with_free_func (g_free);
|
|
||||||
for (adapter = addresses; adapter != NULL; adapter = adapter->Next)
|
|
||||||
{
|
|
||||||
char *description;
|
|
||||||
char *friendly;
|
|
||||||
const char *name;
|
|
||||||
const char *type;
|
|
||||||
char *label;
|
|
||||||
|
|
||||||
if (adapter->OperStatus != IfOperStatusUp || adapter->PhysicalAddressLength == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (adapter->IfType != IF_TYPE_ETHERNET_CSMACD && adapter->IfType != IF_TYPE_IEEE80211)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
description = wide_to_utf8 (adapter->Description);
|
|
||||||
friendly = wide_to_utf8 (adapter->FriendlyName);
|
|
||||||
name = description && description[0] ? description : friendly;
|
|
||||||
if (!name)
|
|
||||||
{
|
|
||||||
g_free (description);
|
|
||||||
g_free (friendly);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = adapter->IfType == IF_TYPE_IEEE80211 ? "Wi-Fi" : "Ethernet";
|
|
||||||
label = g_strdup_printf ("%s: %s", type, name);
|
|
||||||
ptr_array_add_unique (fallback, label);
|
|
||||||
if (!adapter_looks_virtual (name))
|
|
||||||
{
|
|
||||||
ptr_array_add_unique (physical, label);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (label);
|
|
||||||
g_free (description);
|
|
||||||
g_free (friendly);
|
|
||||||
}
|
|
||||||
g_free (addresses);
|
|
||||||
|
|
||||||
selected = physical->len != 0 ? physical : fallback;
|
|
||||||
result = join_ptr_array (selected, ", ");
|
|
||||||
g_ptr_array_free (physical, TRUE);
|
|
||||||
g_ptr_array_free (fallback, TRUE);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
sysinfo_backend_get_ui (void)
|
sysinfo_backend_get_ui (void)
|
||||||
{
|
{
|
||||||
#if defined(USE_GTK_FRONTEND)
|
const char *toolkit = sysinfo_detect_toolkit();
|
||||||
return g_strdup ("Windows / GTK3");
|
|
||||||
#else
|
/* On Windows we don't have X11/Wayland. Keep it simple. */
|
||||||
|
if (toolkit)
|
||||||
|
{
|
||||||
|
return g_strdup_printf ("Windows / %s", toolkit);
|
||||||
|
}
|
||||||
|
|
||||||
return g_strdup ("Windows");
|
return g_strdup ("Windows");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
/* ZoiteChat
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "zoitechat.h"
|
|
||||||
#include "zoitechatc.h"
|
|
||||||
#include "server.h"
|
|
||||||
#include "fe.h"
|
|
||||||
#include "autoaway.h"
|
|
||||||
|
|
||||||
static gint64 last_activity;
|
|
||||||
static int timer_tag;
|
|
||||||
static int previous_timeout;
|
|
||||||
static unsigned int previous_system;
|
|
||||||
|
|
||||||
void
|
|
||||||
autoaway_activity (void)
|
|
||||||
{
|
|
||||||
last_activity = g_get_monotonic_time ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A manual /AWAY takes ownership even if the server already says away. */
|
|
||||||
void
|
|
||||||
autoaway_manual (server *serv)
|
|
||||||
{
|
|
||||||
serv->autoaway_owned = FALSE;
|
|
||||||
serv->autoaway_back_pending = FALSE;
|
|
||||||
autoaway_activity ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
autoaway_reset (server *serv)
|
|
||||||
{
|
|
||||||
if (!serv->autoaway_owned)
|
|
||||||
return;
|
|
||||||
|
|
||||||
serv->autoaway_owned = FALSE;
|
|
||||||
serv->autoaway_back_pending = FALSE;
|
|
||||||
serv->reconnect_away = FALSE;
|
|
||||||
g_clear_pointer (&serv->last_away_reason, g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
autoaway_ack_back (server *serv)
|
|
||||||
{
|
|
||||||
if (serv->autoaway_back_pending)
|
|
||||||
autoaway_reset (serv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
autoaway_release (server *serv, gint64 now)
|
|
||||||
{
|
|
||||||
if (!serv->autoaway_owned)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Retain ownership until RPL_UNAWAY, including across a late 306. */
|
|
||||||
if (serv->autoaway_back_pending &&
|
|
||||||
now - serv->autoaway_sent_at < 30 * G_USEC_PER_SEC)
|
|
||||||
return;
|
|
||||||
|
|
||||||
serv->autoaway_back_pending = TRUE;
|
|
||||||
serv->autoaway_sent_at = now;
|
|
||||||
serv->p_set_back (serv);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
autoaway_request_back (server *serv)
|
|
||||||
{
|
|
||||||
if (!serv->autoaway_owned)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (serv->connected && serv->end_of_motd)
|
|
||||||
autoaway_release (serv, g_get_monotonic_time ());
|
|
||||||
else
|
|
||||||
autoaway_reset (serv);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
autoaway_has_owned_servers (void)
|
|
||||||
{
|
|
||||||
GSList *list;
|
|
||||||
|
|
||||||
for (list = serv_list; list; list = list->next)
|
|
||||||
if (((server *)list->data)->autoaway_owned)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
autoaway_check (gint64 now, gint64 desktop_idle)
|
|
||||||
{
|
|
||||||
GSList *list;
|
|
||||||
gint64 idle = MAX ((gint64)0, now - last_activity);
|
|
||||||
gint64 limit = (gint64)prefs.hex_away_auto_timeout * 60 * G_USEC_PER_SEC;
|
|
||||||
|
|
||||||
if (prefs.hex_away_auto_system && desktop_idle >= 0)
|
|
||||||
idle = MIN (idle, desktop_idle);
|
|
||||||
|
|
||||||
for (list = serv_list; list; list = list->next)
|
|
||||||
{
|
|
||||||
server *serv = list->data;
|
|
||||||
|
|
||||||
if (!serv->connected)
|
|
||||||
{
|
|
||||||
/* Re-evaluate idle after login instead of restoring stale autoaway. */
|
|
||||||
autoaway_reset (serv);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!serv->end_of_motd)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (serv->autoaway_back_pending || limit <= 0 || idle < limit)
|
|
||||||
{
|
|
||||||
autoaway_release (serv, now);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (serv->is_away || serv->reconnect_away)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Retry a rejected/lost request slowly, never once per poll. */
|
|
||||||
if (serv->autoaway_owned &&
|
|
||||||
now - serv->autoaway_sent_at < 30 * G_USEC_PER_SEC)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
g_free (serv->last_away_reason);
|
|
||||||
serv->last_away_reason = g_strdup (prefs.hex_away_auto_reason[0] ?
|
|
||||||
prefs.hex_away_auto_reason : _("Idle"));
|
|
||||||
serv->autoaway_owned = TRUE;
|
|
||||||
serv->autoaway_sent_at = now;
|
|
||||||
serv->p_set_away (serv, serv->last_away_reason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
autoaway_timer (gpointer data)
|
|
||||||
{
|
|
||||||
(void)data;
|
|
||||||
autoaway_check (g_get_monotonic_time (),
|
|
||||||
prefs.hex_away_auto_system ? fe_get_idle_time () : -1);
|
|
||||||
if (prefs.hex_away_auto_timeout <= 0 && !autoaway_has_owned_servers ())
|
|
||||||
{
|
|
||||||
timer_tag = 0;
|
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
|
||||||
return G_SOURCE_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
autoaway_reinit (void)
|
|
||||||
{
|
|
||||||
if (previous_timeout != prefs.hex_away_auto_timeout ||
|
|
||||||
previous_system != prefs.hex_away_auto_system)
|
|
||||||
{
|
|
||||||
autoaway_activity ();
|
|
||||||
previous_timeout = prefs.hex_away_auto_timeout;
|
|
||||||
previous_system = prefs.hex_away_auto_system;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Disabling autoaway sends BACK immediately, but retries until ACK. */
|
|
||||||
if (prefs.hex_away_auto_timeout <= 0)
|
|
||||||
autoaway_check (g_get_monotonic_time (), -1);
|
|
||||||
|
|
||||||
if (prefs.hex_away_auto_timeout > 0 || autoaway_has_owned_servers ())
|
|
||||||
{
|
|
||||||
if (!timer_tag)
|
|
||||||
timer_tag = fe_timeout_add_seconds (5, autoaway_timer, NULL);
|
|
||||||
}
|
|
||||||
else if (timer_tag)
|
|
||||||
{
|
|
||||||
fe_timeout_remove (timer_tag);
|
|
||||||
timer_tag = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
/* ZoiteChat
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ZOITECHAT_AUTOAWAY_H
|
|
||||||
#define ZOITECHAT_AUTOAWAY_H
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
struct server;
|
|
||||||
|
|
||||||
void autoaway_activity (void);
|
|
||||||
void autoaway_manual (struct server *serv);
|
|
||||||
void autoaway_reset (struct server *serv);
|
|
||||||
void autoaway_ack_back (struct server *serv);
|
|
||||||
gboolean autoaway_request_back (struct server *serv);
|
|
||||||
void autoaway_reinit (void);
|
|
||||||
/* Both samples are in microseconds; -1 means desktop idle is unavailable. */
|
|
||||||
void autoaway_check (gint64 now, gint64 desktop_idle);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -29,7 +29,6 @@
|
|||||||
#include "fe.h"
|
#include "fe.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "zoitechatc.h"
|
#include "zoitechatc.h"
|
||||||
#include "autoaway.h"
|
|
||||||
#include "typedef.h"
|
#include "typedef.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@@ -301,37 +300,6 @@ char *xdir = NULL; /* utf-8 encoding */
|
|||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Resolve relative config paths before plugins can change the working directory. */
|
|
||||||
void
|
|
||||||
set_xdir (const char *path)
|
|
||||||
{
|
|
||||||
char *dir;
|
|
||||||
const char *root;
|
|
||||||
gsize len;
|
|
||||||
|
|
||||||
if (!*path || g_path_is_absolute (path)
|
|
||||||
#ifdef WIN32
|
|
||||||
|| (g_ascii_isalpha (path[0]) && path[1] == ':')
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
dir = g_strdup (path);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *cwd = g_get_current_dir ();
|
|
||||||
dir = g_build_filename (cwd, path, NULL);
|
|
||||||
g_free (cwd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Keep the existing trailing separator convention, but preserve roots. */
|
|
||||||
len = strlen (dir);
|
|
||||||
root = g_path_skip_root (dir);
|
|
||||||
if (len && G_IS_DIR_SEPARATOR (dir[len - 1]) && (!root || dir + len > root))
|
|
||||||
dir[len - 1] = '\0';
|
|
||||||
|
|
||||||
g_free (xdir);
|
|
||||||
xdir = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
get_xdir (void)
|
get_xdir (void)
|
||||||
{
|
{
|
||||||
@@ -391,9 +359,6 @@ default_file (void)
|
|||||||
|
|
||||||
const struct prefs vars[] =
|
const struct prefs vars[] =
|
||||||
{
|
{
|
||||||
{"away_auto_reason", P_OFFSET (hex_away_auto_reason), TYPE_STR},
|
|
||||||
{"away_auto_system", P_OFFINT (hex_away_auto_system), TYPE_BOOL, autoaway_reinit},
|
|
||||||
{"away_auto_timeout", P_OFFINT (hex_away_auto_timeout), TYPE_INT, autoaway_reinit},
|
|
||||||
{"away_auto_unmark", P_OFFINT (hex_away_auto_unmark), TYPE_BOOL},
|
{"away_auto_unmark", P_OFFINT (hex_away_auto_unmark), TYPE_BOOL},
|
||||||
{"away_omit_alerts", P_OFFINT (hex_away_omit_alerts), TYPE_BOOL},
|
{"away_omit_alerts", P_OFFINT (hex_away_omit_alerts), TYPE_BOOL},
|
||||||
{"away_reason", P_OFFSET (hex_away_reason), TYPE_STR},
|
{"away_reason", P_OFFSET (hex_away_reason), TYPE_STR},
|
||||||
@@ -802,7 +767,6 @@ load_default_config(void)
|
|||||||
/* put in default values, anything left out is automatically zero */
|
/* put in default values, anything left out is automatically zero */
|
||||||
|
|
||||||
/* BOOLEANS */
|
/* BOOLEANS */
|
||||||
prefs.hex_away_auto_system = 1;
|
|
||||||
prefs.hex_away_show_once = 1;
|
prefs.hex_away_show_once = 1;
|
||||||
prefs.hex_away_track = 1;
|
prefs.hex_away_track = 1;
|
||||||
prefs.hex_dcc_auto_resume = 1;
|
prefs.hex_dcc_auto_resume = 1;
|
||||||
@@ -923,7 +887,6 @@ load_default_config(void)
|
|||||||
prefs.hex_url_grabber_limit = 100; /* 0 means unlimited */
|
prefs.hex_url_grabber_limit = 100; /* 0 means unlimited */
|
||||||
|
|
||||||
/* STRINGS */
|
/* STRINGS */
|
||||||
strcpy (prefs.hex_away_auto_reason, _("Idle"));
|
|
||||||
strcpy (prefs.hex_away_reason, _("I'm busy"));
|
strcpy (prefs.hex_away_reason, _("I'm busy"));
|
||||||
strcpy (prefs.hex_completion_suffix, ",");
|
strcpy (prefs.hex_completion_suffix, ",");
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ int cfg_get_int (char *cfg, char *var);
|
|||||||
int cfg_put_int (int fh, int value, char *var);
|
int cfg_put_int (int fh, int value, char *var);
|
||||||
int cfg_get_color (char *cfg, char *var, guint16 *r, guint16 *g, guint16 *b);
|
int cfg_get_color (char *cfg, char *var, guint16 *r, guint16 *g, guint16 *b);
|
||||||
int cfg_put_color (int fh, guint16 r, guint16 g, guint16 b, char *var);
|
int cfg_put_color (int fh, guint16 r, guint16 g, guint16 b, char *var);
|
||||||
void set_xdir (const char *path);
|
|
||||||
char *get_xdir (void);
|
char *get_xdir (void);
|
||||||
int check_config_dir (void);
|
int check_config_dir (void);
|
||||||
void load_default_config (void);
|
void load_default_config (void);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="autoaway.h" />
|
|
||||||
<ClInclude Include="cfgfiles.h" />
|
<ClInclude Include="cfgfiles.h" />
|
||||||
<ClInclude Include="chanopt.h" />
|
<ClInclude Include="chanopt.h" />
|
||||||
<ClInclude Include="ctcp.h" />
|
<ClInclude Include="ctcp.h" />
|
||||||
@@ -53,7 +52,6 @@
|
|||||||
<ClInclude Include="gtk3-theme-service.h" />
|
<ClInclude Include="gtk3-theme-service.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="autoaway.c" />
|
|
||||||
<ClCompile Include="cfgfiles.c" />
|
<ClCompile Include="cfgfiles.c" />
|
||||||
<ClCompile Include="chanopt.c" />
|
<ClCompile Include="chanopt.c" />
|
||||||
<ClCompile Include="ctcp.c" />
|
<ClCompile Include="ctcp.c" />
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="autoaway.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="cfgfiles.h">
|
<ClInclude Include="cfgfiles.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -139,9 +136,6 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="autoaway.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="cfgfiles.c">
|
<ClCompile Include="cfgfiles.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ void fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gtk_xtext_sea
|
|||||||
void fe_set_lag (server *serv, long lag);
|
void fe_set_lag (server *serv, long lag);
|
||||||
void fe_set_throttle (server *serv);
|
void fe_set_throttle (server *serv);
|
||||||
void fe_set_away (server *serv);
|
void fe_set_away (server *serv);
|
||||||
gint64 fe_get_idle_time (void);
|
|
||||||
void fe_serverlist_open (session *sess);
|
void fe_serverlist_open (session *sess);
|
||||||
void fe_get_bool (char *title, char *prompt, void *callback, void *userdata);
|
void fe_get_bool (char *title, char *prompt, void *callback, void *userdata);
|
||||||
void fe_get_str (char *prompt, char *def, void *callback, void *ud);
|
void fe_get_str (char *prompt, char *def, void *callback, void *ud);
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "outbound.h"
|
#include "outbound.h"
|
||||||
#include "inbound.h"
|
#include "inbound.h"
|
||||||
#include "autoaway.h"
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "servlist.h"
|
#include "servlist.h"
|
||||||
#include "sts.h"
|
#include "sts.h"
|
||||||
@@ -687,10 +686,7 @@ inbound_chanmsg (server *serv, session *sess, char *chan, char *from,
|
|||||||
{
|
{
|
||||||
if (prefs.hex_away_auto_unmark && serv->is_away &&
|
if (prefs.hex_away_auto_unmark && serv->is_away &&
|
||||||
(!tags_data->timestamp || serv->have_echo_message))
|
(!tags_data->timestamp || serv->have_echo_message))
|
||||||
{
|
sess->server->p_set_back (sess->server);
|
||||||
if (!autoaway_request_back (serv))
|
|
||||||
sess->server->p_set_back (sess->server);
|
|
||||||
}
|
|
||||||
reply_context_print (sess, tags_data);
|
reply_context_print (sess, tags_data);
|
||||||
inbound_emit_message (XP_TE_UCHANMSG, sess, from, text, nickchar, NULL, tags_data);
|
inbound_emit_message (XP_TE_UCHANMSG, sess, from, text, nickchar, NULL, tags_data);
|
||||||
reply_cache_add (sess, tags_data->msgid, from, text, tags_data->timestamp);
|
reply_cache_add (sess, tags_data->msgid, from, text, tags_data->timestamp);
|
||||||
@@ -1640,7 +1636,6 @@ inbound_uback (server *serv, const message_tags_data *tags_data)
|
|||||||
{
|
{
|
||||||
serv->is_away = FALSE;
|
serv->is_away = FALSE;
|
||||||
serv->reconnect_away = FALSE;
|
serv->reconnect_away = FALSE;
|
||||||
autoaway_ack_back (serv);
|
|
||||||
fe_set_away (serv);
|
fe_set_away (serv);
|
||||||
|
|
||||||
inbound_set_all_away_status (serv, serv->nick, 0);
|
inbound_set_all_away_status (serv, serv->nick, 0);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
common_sources = [
|
common_sources = [
|
||||||
'autoaway.c',
|
|
||||||
'cfgfiles.c',
|
'cfgfiles.c',
|
||||||
'chanopt.c',
|
'chanopt.c',
|
||||||
'ctcp.c',
|
'ctcp.c',
|
||||||
@@ -231,10 +230,3 @@ test('Hex Color Tests', hexcolor_tests,
|
|||||||
protocol: 'tap',
|
protocol: 'tap',
|
||||||
timeout: 120,
|
timeout: 120,
|
||||||
)
|
)
|
||||||
|
|
||||||
autoaway_tests = executable('autoaway_tests',
|
|
||||||
['tests/test-autoaway.c', 'autoaway.c'],
|
|
||||||
include_directories: [config_h_include, include_directories('.')],
|
|
||||||
dependencies: zoitechat_common_header_deps,
|
|
||||||
)
|
|
||||||
test('Autoaway Tests', autoaway_tests, protocol: 'tap', timeout: 30)
|
|
||||||
@@ -54,7 +54,6 @@
|
|||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "outbound.h"
|
#include "outbound.h"
|
||||||
#include "autoaway.h"
|
|
||||||
#include "chanopt.h"
|
#include "chanopt.h"
|
||||||
|
|
||||||
#define TBUFSIZE 4096
|
#define TBUFSIZE 4096
|
||||||
@@ -360,23 +359,17 @@ static int
|
|||||||
cmd_away (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
cmd_away (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
{
|
{
|
||||||
char *reason = word_eol[2];
|
char *reason = word_eol[2];
|
||||||
gboolean was_returning = sess->server->autoaway_back_pending;
|
|
||||||
|
|
||||||
/* Restoring a manual away after reconnect is not new user input. */
|
|
||||||
if (!sess->server->reconnect_away)
|
|
||||||
autoaway_manual (sess->server);
|
|
||||||
|
|
||||||
if (!(*reason))
|
if (!(*reason))
|
||||||
{
|
{
|
||||||
if (sess->server->is_away && !was_returning)
|
if (sess->server->is_away)
|
||||||
{
|
{
|
||||||
if (sess->server->last_away_reason)
|
if (sess->server->last_away_reason)
|
||||||
PrintTextf (sess, _("Already marked away: %s\n"), sess->server->last_away_reason);
|
PrintTextf (sess, _("Already marked away: %s\n"), sess->server->last_away_reason);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sess->server->reconnect_away ||
|
if (sess->server->reconnect_away)
|
||||||
(was_returning && sess->server->last_away_reason))
|
|
||||||
reason = sess->server->last_away_reason;
|
reason = sess->server->last_away_reason;
|
||||||
else
|
else
|
||||||
/* must manage memory pointed to by random_line() */
|
/* must manage memory pointed to by random_line() */
|
||||||
@@ -403,10 +396,6 @@ cmd_away (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
static int
|
static int
|
||||||
cmd_back (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
cmd_back (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
{
|
{
|
||||||
autoaway_activity ();
|
|
||||||
if (autoaway_request_back (sess->server))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (sess->server->is_away)
|
if (sess->server->is_away)
|
||||||
{
|
{
|
||||||
sess->server->p_set_back (sess->server);
|
sess->server->p_set_back (sess->server);
|
||||||
@@ -3126,8 +3115,7 @@ cmd_notice (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
while ((split_text = split_up_text (sess, text + offset, cmd_length, split_text)))
|
while ((split_text = split_up_text (sess, text + offset, cmd_length, split_text)))
|
||||||
{
|
{
|
||||||
sess->server->p_notice (sess->server, word[2], split_text);
|
sess->server->p_notice (sess->server, word[2], split_text);
|
||||||
if (!sess->server->have_echo_message || split_text[0] == '\001')
|
EMIT_SIGNAL (XP_TE_NOTICESEND, sess, word[2], split_text, NULL, NULL, 0);
|
||||||
EMIT_SIGNAL (XP_TE_NOTICESEND, sess, word[2], split_text, NULL, NULL, 0);
|
|
||||||
|
|
||||||
if (*split_text)
|
if (*split_text)
|
||||||
offset += strlen(split_text);
|
offset += strlen(split_text);
|
||||||
@@ -3136,8 +3124,7 @@ cmd_notice (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
sess->server->p_notice (sess->server, word[2], text + offset);
|
sess->server->p_notice (sess->server, word[2], text + offset);
|
||||||
if (!sess->server->have_echo_message || text[offset] == '\001')
|
EMIT_SIGNAL (XP_TE_NOTICESEND, sess, word[2], text + offset, NULL, NULL, 0);
|
||||||
EMIT_SIGNAL (XP_TE_NOTICESEND, sess, word[2], text + offset, NULL, NULL, 0);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -5064,9 +5051,6 @@ handle_user_input (session *sess, char *text, int history, int nocommand)
|
|||||||
if (*text == '\0')
|
if (*text == '\0')
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (history)
|
|
||||||
autoaway_activity ();
|
|
||||||
|
|
||||||
if (history)
|
if (history)
|
||||||
history_add (&sess->history, text);
|
history_add (&sess->history, text);
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ enum
|
|||||||
|
|
||||||
GSList *plugin_list = NULL; /* export for plugingui.c */
|
GSList *plugin_list = NULL; /* export for plugingui.c */
|
||||||
static GSList *hook_list = NULL;
|
static GSList *hook_list = NULL;
|
||||||
|
static unsigned int plugin_dispatch_depth;
|
||||||
|
|
||||||
extern const struct prefs vars[]; /* cfgfiles.c */
|
extern const struct prefs vars[]; /* cfgfiles.c */
|
||||||
|
|
||||||
@@ -243,7 +244,7 @@ plugin_list_add (zoitechat_context *ctx, char *filename, const char *name,
|
|||||||
{
|
{
|
||||||
zoitechat_plugin *pl;
|
zoitechat_plugin *pl;
|
||||||
|
|
||||||
pl = g_new (zoitechat_plugin, 1);
|
pl = g_new0 (zoitechat_plugin, 1);
|
||||||
pl->handle = handle;
|
pl->handle = handle;
|
||||||
pl->filename = filename;
|
pl->filename = filename;
|
||||||
pl->context = ctx;
|
pl->context = ctx;
|
||||||
@@ -610,6 +611,7 @@ plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[],
|
|||||||
zoitechat_hook *hook;
|
zoitechat_hook *hook;
|
||||||
int ret, eat = 0;
|
int ret, eat = 0;
|
||||||
|
|
||||||
|
plugin_dispatch_depth++;
|
||||||
list = hook_list;
|
list = hook_list;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -655,6 +657,10 @@ plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
xit:
|
xit:
|
||||||
|
/* Nested callbacks can unhook entries still used by an outer dispatch.
|
||||||
|
* Keep both hook objects and list links alive until the outermost return. */
|
||||||
|
if (--plugin_dispatch_depth != 0)
|
||||||
|
return eat;
|
||||||
/* really remove deleted hooks now */
|
/* really remove deleted hooks now */
|
||||||
list = hook_list;
|
list = hook_list;
|
||||||
while (list)
|
while (list)
|
||||||
@@ -806,7 +812,7 @@ plugin_insert_hook (zoitechat_hook *new_hook)
|
|||||||
break;
|
break;
|
||||||
case HOOK_SERVER:
|
case HOOK_SERVER:
|
||||||
case HOOK_SERVER_ATTRS:
|
case HOOK_SERVER_ATTRS:
|
||||||
new_hook_type = HOOK_SERVER | HOOK_PRINT_ATTRS;
|
new_hook_type = HOOK_SERVER | HOOK_SERVER_ATTRS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
new_hook_type = new_hook->type;
|
new_hook_type = new_hook->type;
|
||||||
@@ -1242,9 +1248,6 @@ zoitechat_get_info (zoitechat_plugin *ph, const char *id)
|
|||||||
case 0x6de15a2e: /* network */
|
case 0x6de15a2e: /* network */
|
||||||
return server_get_network (sess->server, FALSE);
|
return server_get_network (sess->server, FALSE);
|
||||||
|
|
||||||
case 0xa089585f: /* echo-message */
|
|
||||||
return sess->server->have_echo_message ? "1" : "0";
|
|
||||||
|
|
||||||
case 0x339763: /* nick */
|
case 0x339763: /* nick */
|
||||||
return sess->server->nick;
|
return sess->server->nick;
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,15 @@ struct _zoitechat_plugin
|
|||||||
void (*zoitechat_event_attrs_free) (zoitechat_plugin *ph,
|
void (*zoitechat_event_attrs_free) (zoitechat_plugin *ph,
|
||||||
zoitechat_event_attrs *attrs);
|
zoitechat_event_attrs *attrs);
|
||||||
|
|
||||||
|
/* Additive API slots: append only; old binary offsets are unchanged. */
|
||||||
|
zoitechat_hook *(*zoitechat_hook_print_after) (zoitechat_plugin *, const char *, int,
|
||||||
|
int, int (*)(char *[], zoitechat_event_attrs *, void *), void *);
|
||||||
|
zoitechat_hook *(*zoitechat_hook_server_filtered) (zoitechat_plugin *, const char *, int,
|
||||||
|
int, int, const char *, int (*)(char *[], char *[], zoitechat_event_attrs *, void *), void *);
|
||||||
|
zoitechat_hook *(*zoitechat_hook_print_filtered) (zoitechat_plugin *, const char *, int,
|
||||||
|
int, int, const char *, int (*)(char *[], zoitechat_event_attrs *, void *), void *);
|
||||||
|
zoitechat_hook *(*zoitechat_register_capability) (zoitechat_plugin *, const char *, int, int, void *);
|
||||||
|
|
||||||
/* PRIVATE FIELDS! */
|
/* PRIVATE FIELDS! */
|
||||||
void *handle; /* from dlopen */
|
void *handle; /* from dlopen */
|
||||||
char *filename; /* loaded from */
|
char *filename; /* loaded from */
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
/* IRC RFC1459(+commonly used extensions) protocol implementation */
|
/* IRC RFC1459(+commonly used extensions) protocol implementation */
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 200809L
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -31,7 +30,6 @@
|
|||||||
|
|
||||||
#include "zoitechat.h"
|
#include "zoitechat.h"
|
||||||
#include "proto-irc.h"
|
#include "proto-irc.h"
|
||||||
#include "autoaway.h"
|
|
||||||
#include "ctcp.h"
|
#include "ctcp.h"
|
||||||
#include "fe.h"
|
#include "fe.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
@@ -440,23 +438,6 @@ irc_raw (server *serv, char *raw)
|
|||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char tbuf[8704];
|
char tbuf[8704];
|
||||||
|
|
||||||
/* Raw AWAY takes manual ownership unless it clears an automatic AWAY. */
|
|
||||||
if (!g_ascii_strncasecmp (raw, "AWAY", 4) &&
|
|
||||||
(raw[4] == 0 || raw[4] == ' '))
|
|
||||||
{
|
|
||||||
const char *reason = raw + 4;
|
|
||||||
while (*reason == ' ')
|
|
||||||
reason++;
|
|
||||||
if (!*reason || !strcmp (reason, ":"))
|
|
||||||
{
|
|
||||||
autoaway_activity ();
|
|
||||||
if (autoaway_request_back (serv))
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
autoaway_manual (serv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*raw)
|
if (*raw)
|
||||||
{
|
{
|
||||||
len = strlen (raw);
|
len = strlen (raw);
|
||||||
@@ -511,7 +492,7 @@ process_numeric (session * sess, int n,
|
|||||||
server *serv = sess->server;
|
server *serv = sess->server;
|
||||||
/* show whois is the server tab */
|
/* show whois is the server tab */
|
||||||
session *whois_sess = serv->server_session;
|
session *whois_sess = serv->server_session;
|
||||||
|
|
||||||
/* unless this setting is on */
|
/* unless this setting is on */
|
||||||
if (prefs.hex_irc_whois_front)
|
if (prefs.hex_irc_whois_front)
|
||||||
whois_sess = serv->front_session;
|
whois_sess = serv->front_session;
|
||||||
@@ -682,7 +663,7 @@ process_numeric (session * sess, int n,
|
|||||||
|
|
||||||
case 323:
|
case 323:
|
||||||
if (!fe_is_chanwindow (sess->server))
|
if (!fe_is_chanwindow (sess->server))
|
||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text,
|
EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text,
|
||||||
word[1], word[2], NULL, 0, tags_data->timestamp);
|
word[1], word[2], NULL, 0, tags_data->timestamp);
|
||||||
else
|
else
|
||||||
fe_chan_list_end (sess->server);
|
fe_chan_list_end (sess->server);
|
||||||
@@ -712,7 +693,7 @@ process_numeric (session * sess, int n,
|
|||||||
if (sess)
|
if (sess)
|
||||||
{
|
{
|
||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANURL, sess, word[4], (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5],
|
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANURL, sess, word[4], (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5],
|
||||||
NULL, NULL, 0, tags_data->timestamp);
|
NULL, NULL, 0, tags_data->timestamp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -748,7 +729,7 @@ process_numeric (session * sess, int n,
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
case 338: /* Undernet Real user@host, Real IP */
|
case 338: /* Undernet Real user@host, Real IP */
|
||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_REALHOST, sess, word[4], word[5], word[6],
|
EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_REALHOST, sess, word[4], word[5], word[6],
|
||||||
(word_eol[7][0]==':') ? word_eol[7]+1 : word_eol[7],
|
(word_eol[7][0]==':') ? word_eol[7]+1 : word_eol[7],
|
||||||
0, tags_data->timestamp);
|
0, tags_data->timestamp);
|
||||||
break;
|
break;
|
||||||
@@ -981,7 +962,7 @@ process_numeric (session * sess, int n,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 900: /* successful SASL 'logged in as ' */
|
case 900: /* successful SASL 'logged in as ' */
|
||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session,
|
EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session,
|
||||||
word_eol[6]+1, word[1], word[2], NULL, 0,
|
word_eol[6]+1, word[1], word[2], NULL, 0,
|
||||||
tags_data->timestamp);
|
tags_data->timestamp);
|
||||||
break;
|
break;
|
||||||
@@ -1020,7 +1001,7 @@ process_numeric (session * sess, int n,
|
|||||||
def:
|
def:
|
||||||
{
|
{
|
||||||
session *sess;
|
session *sess;
|
||||||
|
|
||||||
if (is_channel (serv, word[4]))
|
if (is_channel (serv, word[4]))
|
||||||
{
|
{
|
||||||
sess = find_channel (serv, word[4]);
|
sess = find_channel (serv, word[4]);
|
||||||
@@ -1031,7 +1012,7 @@ process_numeric (session * sess, int n,
|
|||||||
;
|
;
|
||||||
else
|
else
|
||||||
sess=serv->server_session;
|
sess=serv->server_session;
|
||||||
|
|
||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, sess, text, word[1], word[2],
|
EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, sess, text, word[1], word[2],
|
||||||
NULL, 0, tags_data->timestamp);
|
NULL, 0, tags_data->timestamp);
|
||||||
}
|
}
|
||||||
@@ -1110,7 +1091,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
{
|
{
|
||||||
guint32 t;
|
guint32 t;
|
||||||
|
|
||||||
t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]);
|
t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]);
|
||||||
/* this should compile to a bunch of: CMP.L, JE ... nice & fast */
|
/* this should compile to a bunch of: CMP.L, JE ... nice & fast */
|
||||||
switch (t)
|
switch (t)
|
||||||
{
|
{
|
||||||
@@ -1166,7 +1147,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case WORDL('N','I','C','K'):
|
case WORDL('N','I','C','K'):
|
||||||
inbound_newnick (serv, nick,
|
inbound_newnick (serv, nick,
|
||||||
(word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3],
|
(word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3],
|
||||||
FALSE, tags_data);
|
FALSE, tags_data);
|
||||||
return;
|
return;
|
||||||
@@ -1250,7 +1231,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
{
|
{
|
||||||
guint32 t;
|
guint32 t;
|
||||||
|
|
||||||
t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]);
|
t = WORDL((guint8)type[0], (guint8)type[1], (guint8)type[2], (guint8)type[3]);
|
||||||
/* this should compile to a bunch of: CMP.L, JE ... nice & fast */
|
/* this should compile to a bunch of: CMP.L, JE ... nice & fast */
|
||||||
switch (t)
|
switch (t)
|
||||||
{
|
{
|
||||||
@@ -1286,7 +1267,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_INVITED, sess, text, nick,
|
EMIT_SIGNAL_TIMESTAMP (XP_TE_INVITED, sess, text, nick,
|
||||||
serv->servername, NULL, 0,
|
serv->servername, NULL, 0,
|
||||||
tags_data->timestamp);
|
tags_data->timestamp);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case WORDL('N','O','T','I'):
|
case WORDL('N','O','T','I'):
|
||||||
@@ -1324,19 +1305,6 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Echoed notices are outgoing, not incoming notifications or CTCP replies. */
|
|
||||||
if (serv->have_echo_message && !serv->p_cmp (nick, serv->nick))
|
|
||||||
{
|
|
||||||
if (text[0] != '\001')
|
|
||||||
{
|
|
||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_NOTICESEND, sess, word[3], text, NULL, NULL, 0,
|
|
||||||
tags_data->timestamp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (serv->p_cmp (word[3], serv->nick))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ignore_check (word[1], IG_NOTI))
|
if (!ignore_check (word[1], IG_NOTI))
|
||||||
inbound_notice (serv, word[3], nick, text, ip, tags_data->identified, tags_data);
|
inbound_notice (serv, word[3], nick, text, ip, tags_data->identified, tags_data);
|
||||||
}
|
}
|
||||||
@@ -1352,7 +1320,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
if (strchr (serv->chantypes, to[0]) == NULL
|
if (strchr (serv->chantypes, to[0]) == NULL
|
||||||
&& strchr (serv->nick_prefixes, to[0]) != NULL)
|
&& strchr (serv->nick_prefixes, to[0]) != NULL)
|
||||||
to++;
|
to++;
|
||||||
|
|
||||||
text = word_eol[4];
|
text = word_eol[4];
|
||||||
if (*text == ':')
|
if (*text == ':')
|
||||||
text++;
|
text++;
|
||||||
@@ -1366,10 +1334,6 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
text[len - 1] = 0;
|
text[len - 1] = 0;
|
||||||
}
|
}
|
||||||
text++;
|
text++;
|
||||||
/* Do not answer our own outgoing CTCP or DCC requests. */
|
|
||||||
if (serv->have_echo_message && !serv->p_cmp (nick, serv->nick) &&
|
|
||||||
serv->p_cmp (to, serv->nick) && g_ascii_strncasecmp (text, "ACTION ", 7))
|
|
||||||
return;
|
|
||||||
if (g_ascii_strncasecmp (text, "ACTION", 6) != 0)
|
if (g_ascii_strncasecmp (text, "ACTION", 6) != 0)
|
||||||
flood_check (nick, ip, serv, sess, 0);
|
flood_check (nick, ip, serv, sess, 0);
|
||||||
if (g_ascii_strncasecmp (text, "DCC ", 4) == 0)
|
if (g_ascii_strncasecmp (text, "DCC ", 4) == 0)
|
||||||
@@ -1478,13 +1442,13 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
case WORDL('C','A','P','\0'):
|
case WORDL('C','A','P','\0'):
|
||||||
if (g_ascii_strncasecmp(word[4], "ACK", 3) == 0)
|
if (g_ascii_strncasecmp(word[4], "ACK", 3) == 0)
|
||||||
{
|
{
|
||||||
inbound_cap_ack (serv, word[1],
|
inbound_cap_ack (serv, word[1],
|
||||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||||
tags_data);
|
tags_data);
|
||||||
}
|
}
|
||||||
else if (g_ascii_strncasecmp(word[4], "LS", 2) == 0)
|
else if (g_ascii_strncasecmp(word[4], "LS", 2) == 0)
|
||||||
{
|
{
|
||||||
inbound_cap_ls (serv, word[1],
|
inbound_cap_ls (serv, word[1],
|
||||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||||
tags_data);
|
tags_data);
|
||||||
}
|
}
|
||||||
@@ -1498,9 +1462,9 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
|||||||
{
|
{
|
||||||
inbound_cap_nak (serv, word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data);
|
inbound_cap_nak (serv, word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data);
|
||||||
}
|
}
|
||||||
else if (g_ascii_strncasecmp(word[4], "LIST", 4) == 0)
|
else if (g_ascii_strncasecmp(word[4], "LIST", 4) == 0)
|
||||||
{
|
{
|
||||||
inbound_cap_list (serv, word[1],
|
inbound_cap_list (serv, word[1],
|
||||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||||
tags_data);
|
tags_data);
|
||||||
}
|
}
|
||||||
@@ -1544,7 +1508,7 @@ process_named_servermsg (session *sess, char *buf, char *rawname, char *word_eol
|
|||||||
buf = word_eol[3];
|
buf = word_eol[3];
|
||||||
if (*buf == ':')
|
if (*buf == ':')
|
||||||
buf++;
|
buf++;
|
||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVNOTICE, sess, buf,
|
EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVNOTICE, sess, buf,
|
||||||
sess->server->servername, NULL, NULL, 0,
|
sess->server->servername, NULL, NULL, 0,
|
||||||
tags_data->timestamp);
|
tags_data->timestamp);
|
||||||
return;
|
return;
|
||||||
@@ -1593,8 +1557,8 @@ get_timezone (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Handle time-server tags.
|
/* Handle time-server tags.
|
||||||
*
|
*
|
||||||
* Sets tags_data->timestamp to the correct time (in unix time).
|
* Sets tags_data->timestamp to the correct time (in unix time).
|
||||||
* This received time is always in UTC.
|
* This received time is always in UTC.
|
||||||
*
|
*
|
||||||
* See http://ircv3.atheme.org/extensions/server-time-3.2
|
* See http://ircv3.atheme.org/extensions/server-time-3.2
|
||||||
@@ -1609,7 +1573,7 @@ handle_message_tag_time (const char *time, message_tags_data *tags_data)
|
|||||||
*/
|
*/
|
||||||
if (!*time)
|
if (!*time)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (time[strlen (time) - 1] == 'Z')
|
if (time[strlen (time) - 1] == 'Z')
|
||||||
{
|
{
|
||||||
/* as defined in the specification */
|
/* as defined in the specification */
|
||||||
@@ -1659,7 +1623,7 @@ handle_message_tag_time (const char *time, message_tags_data *tags_data)
|
|||||||
|
|
||||||
/* Handle message tags.
|
/* Handle message tags.
|
||||||
*
|
*
|
||||||
* See http://ircv3.atheme.org/specification/message-tags-3.2
|
* See http://ircv3.atheme.org/specification/message-tags-3.2
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
message_tag_unescape (const char *value)
|
message_tag_unescape (const char *value)
|
||||||
@@ -1814,7 +1778,7 @@ irc_inline (server *serv, char *buf, int len)
|
|||||||
|
|
||||||
if (!sep)
|
if (!sep)
|
||||||
goto xit;
|
goto xit;
|
||||||
|
|
||||||
*sep = '\0';
|
*sep = '\0';
|
||||||
buf = sep + 1;
|
buf = sep + 1;
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,6 @@
|
|||||||
* Inferno Nettverk A/S, Norway. All rights reserved.
|
* Inferno Nettverk A/S, Norway. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#define _POSIX_C_SOURCE 200809L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -58,7 +54,6 @@
|
|||||||
#include "proto-irc.h"
|
#include "proto-irc.h"
|
||||||
#include "servlist.h"
|
#include "servlist.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "autoaway.h"
|
|
||||||
#include "sts.h"
|
#include "sts.h"
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
@@ -835,7 +830,7 @@ auto_reconnect (server *serv, int send_quit, int err)
|
|||||||
#else
|
#else
|
||||||
if (err == -1 || err == 0 || err == WSAECONNRESET || err == WSAETIMEDOUT)
|
if (err == -1 || err == 0 || err == WSAECONNRESET || err == WSAETIMEDOUT)
|
||||||
#endif
|
#endif
|
||||||
serv->reconnect_away = serv->is_away && !serv->autoaway_owned;
|
serv->reconnect_away = serv->is_away;
|
||||||
|
|
||||||
/* is this server in a reconnect delay? remove it! */
|
/* is this server in a reconnect delay? remove it! */
|
||||||
if (serv->recondelay_tag)
|
if (serv->recondelay_tag)
|
||||||
@@ -1809,7 +1804,7 @@ server_set_encoding (server *serv, char *new_encoding)
|
|||||||
if (new_encoding)
|
if (new_encoding)
|
||||||
{
|
{
|
||||||
serv->encoding = g_strdup (new_encoding);
|
serv->encoding = g_strdup (new_encoding);
|
||||||
/* the serverlist GUI might have added a space
|
/* the serverlist GUI might have added a space
|
||||||
and short description - remove it. */
|
and short description - remove it. */
|
||||||
space = strchr (serv->encoding, ' ');
|
space = strchr (serv->encoding, ' ');
|
||||||
if (space)
|
if (space)
|
||||||
@@ -1878,7 +1873,6 @@ is_server (server *serv)
|
|||||||
void
|
void
|
||||||
server_set_defaults (server *serv)
|
server_set_defaults (server *serv)
|
||||||
{
|
{
|
||||||
autoaway_reset (serv);
|
|
||||||
g_free (serv->chantypes);
|
g_free (serv->chantypes);
|
||||||
g_clear_pointer (&serv->clienttagdeny, g_free);
|
g_clear_pointer (&serv->clienttagdeny, g_free);
|
||||||
g_free (serv->chanmodes);
|
g_free (serv->chanmodes);
|
||||||
|
|||||||
@@ -1,316 +0,0 @@
|
|||||||
/* ZoiteChat
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include "../zoitechat.h"
|
|
||||||
#include "../autoaway.h"
|
|
||||||
|
|
||||||
struct zoitechatprefs prefs;
|
|
||||||
GSList *serv_list;
|
|
||||||
static server servers[3];
|
|
||||||
static int away_count, back_count, timer_adds, timer_removes;
|
|
||||||
static gint64 base;
|
|
||||||
static char *sent_reason;
|
|
||||||
|
|
||||||
/* Protocol stubs deliberately do not acknowledge requests. */
|
|
||||||
static void
|
|
||||||
send_away (server *serv, char *reason)
|
|
||||||
{
|
|
||||||
away_count++;
|
|
||||||
g_free (sent_reason);
|
|
||||||
sent_reason = g_strdup (reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
send_back (server *serv)
|
|
||||||
{
|
|
||||||
back_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
fe_timeout_add_seconds (int interval, void *callback, void *data)
|
|
||||||
{
|
|
||||||
g_assert_cmpint (interval, ==, 5);
|
|
||||||
timer_adds++;
|
|
||||||
return 42;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
fe_timeout_remove (int tag)
|
|
||||||
{
|
|
||||||
g_assert_cmpint (tag, ==, 42);
|
|
||||||
timer_removes++;
|
|
||||||
}
|
|
||||||
|
|
||||||
gint64
|
|
||||||
fe_get_idle_time (void)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
setup (void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
autoaway_reset (&servers[i]);
|
|
||||||
prefs.hex_away_auto_timeout = 0;
|
|
||||||
autoaway_reinit ();
|
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
g_free (servers[i].last_away_reason);
|
|
||||||
g_slist_free (serv_list);
|
|
||||||
serv_list = NULL;
|
|
||||||
memset (servers, 0, sizeof servers);
|
|
||||||
memset (&prefs, 0, sizeof prefs);
|
|
||||||
away_count = back_count = timer_adds = timer_removes = 0;
|
|
||||||
g_clear_pointer (&sent_reason, g_free);
|
|
||||||
prefs.hex_away_auto_timeout = 10;
|
|
||||||
prefs.hex_away_auto_system = TRUE;
|
|
||||||
g_strlcpy (prefs.hex_away_auto_reason, "Auto idle", sizeof prefs.hex_away_auto_reason);
|
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
servers[i].connected = TRUE;
|
|
||||||
servers[i].end_of_motd = TRUE;
|
|
||||||
servers[i].p_set_away = send_away;
|
|
||||||
servers[i].p_set_back = send_back;
|
|
||||||
}
|
|
||||||
serv_list = g_slist_append (NULL, &servers[0]);
|
|
||||||
autoaway_activity ();
|
|
||||||
base = g_get_monotonic_time ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_fallback_boundary (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
autoaway_check (base + 599 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 0);
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
g_assert_true (servers[0].autoaway_owned);
|
|
||||||
g_assert_cmpstr (sent_reason, ==, "Auto idle");
|
|
||||||
/* An ACK is not required to avoid flooding the connection. */
|
|
||||||
autoaway_check (base + 605 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
servers[0].is_away = TRUE;
|
|
||||||
autoaway_check (base + 640 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
autoaway_activity ();
|
|
||||||
autoaway_check (g_get_monotonic_time (), -1);
|
|
||||||
g_assert_cmpint (back_count, ==, 1);
|
|
||||||
g_assert_true (servers[0].autoaway_owned);
|
|
||||||
g_assert_true (servers[0].autoaway_back_pending);
|
|
||||||
autoaway_ack_back (&servers[0]);
|
|
||||||
g_assert_false (servers[0].autoaway_owned);
|
|
||||||
g_assert_false (servers[0].autoaway_back_pending);
|
|
||||||
g_assert_null (servers[0].last_away_reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_desktop_activity (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
autoaway_check (base + 900 * G_USEC_PER_SEC, 5 * G_USEC_PER_SEC);
|
|
||||||
g_assert_cmpint (away_count, ==, 0);
|
|
||||||
autoaway_check (base + 900 * G_USEC_PER_SEC, 700 * G_USEC_PER_SEC);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
servers[0].is_away = TRUE;
|
|
||||||
autoaway_check (base + 905 * G_USEC_PER_SEC, 0);
|
|
||||||
g_assert_cmpint (back_count, ==, 1);
|
|
||||||
/* App input wins even if the native backend still has an old sample. */
|
|
||||||
autoaway_activity ();
|
|
||||||
autoaway_check (g_get_monotonic_time (), 900 * G_USEC_PER_SEC);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_app_mode (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
prefs.hex_away_auto_system = FALSE;
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, 0);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_manual_away (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
servers[0].is_away = TRUE;
|
|
||||||
servers[0].last_away_reason = g_strdup ("Lunch");
|
|
||||||
autoaway_check (base + 900 * G_USEC_PER_SEC, -1);
|
|
||||||
autoaway_check (base + 905 * G_USEC_PER_SEC, 0);
|
|
||||||
prefs.hex_away_auto_timeout = 0;
|
|
||||||
autoaway_reinit ();
|
|
||||||
g_assert_cmpint (away_count, ==, 0);
|
|
||||||
g_assert_cmpint (back_count, ==, 0);
|
|
||||||
g_assert_cmpstr (servers[0].last_away_reason, ==, "Lunch");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_manual_takeover (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, -1);
|
|
||||||
servers[0].is_away = TRUE;
|
|
||||||
/* This is also called for /AWAY with no reason, even if already away. */
|
|
||||||
autoaway_manual (&servers[0]);
|
|
||||||
autoaway_check (g_get_monotonic_time (), 0);
|
|
||||||
prefs.hex_away_auto_timeout = 0;
|
|
||||||
autoaway_reinit ();
|
|
||||||
g_assert_cmpint (back_count, ==, 0);
|
|
||||||
g_assert_true (servers[0].is_away);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_pending_away_cancel (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_false (servers[0].is_away);
|
|
||||||
autoaway_activity ();
|
|
||||||
autoaway_check (g_get_monotonic_time (), -1);
|
|
||||||
g_assert_cmpint (back_count, ==, 1);
|
|
||||||
/* A late 306 must not discard ownership or cause a duplicate BACK. */
|
|
||||||
servers[0].is_away = TRUE;
|
|
||||||
autoaway_check (servers[0].autoaway_sent_at + 29 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (back_count, ==, 1);
|
|
||||||
autoaway_check (servers[0].autoaway_sent_at + 30 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (back_count, ==, 2);
|
|
||||||
servers[0].is_away = FALSE;
|
|
||||||
autoaway_ack_back (&servers[0]);
|
|
||||||
g_assert_false (servers[0].autoaway_owned);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_login_and_multiple_servers (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
serv_list = g_slist_append (serv_list, &servers[1]);
|
|
||||||
serv_list = g_slist_append (serv_list, &servers[2]);
|
|
||||||
servers[1].is_away = TRUE;
|
|
||||||
servers[1].last_away_reason = g_strdup ("Manual");
|
|
||||||
servers[2].end_of_motd = FALSE;
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
servers[2].end_of_motd = TRUE;
|
|
||||||
autoaway_check (base + 605 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 2);
|
|
||||||
autoaway_check (base + 610 * G_USEC_PER_SEC, 0);
|
|
||||||
g_assert_cmpint (back_count, ==, 2);
|
|
||||||
g_assert_cmpstr (servers[1].last_away_reason, ==, "Manual");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_disconnect_and_reconnect (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, -1);
|
|
||||||
autoaway_check (base + 601 * G_USEC_PER_SEC, 0);
|
|
||||||
g_assert_true (servers[0].autoaway_back_pending);
|
|
||||||
servers[0].connected = FALSE;
|
|
||||||
servers[0].is_away = TRUE;
|
|
||||||
servers[0].reconnect_away = TRUE;
|
|
||||||
autoaway_check (base + 605 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_false (servers[0].autoaway_owned);
|
|
||||||
g_assert_false (servers[0].reconnect_away);
|
|
||||||
g_assert_null (servers[0].last_away_reason);
|
|
||||||
g_assert_false (servers[0].autoaway_back_pending);
|
|
||||||
g_assert_cmpint (back_count, ==, 1);
|
|
||||||
servers[0].is_away = FALSE;
|
|
||||||
servers[0].connected = TRUE;
|
|
||||||
servers[0].end_of_motd = FALSE;
|
|
||||||
autoaway_check (base + 610 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
servers[0].end_of_motd = TRUE;
|
|
||||||
autoaway_check (base + 615 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 2);
|
|
||||||
/* server_set_defaults resets ownership even before the next timer tick. */
|
|
||||||
servers[0].reconnect_away = TRUE;
|
|
||||||
autoaway_reset (&servers[0]);
|
|
||||||
g_assert_false (servers[0].reconnect_away);
|
|
||||||
/* Existing manual reconnect-away must be left alone. */
|
|
||||||
servers[0].reconnect_away = TRUE;
|
|
||||||
servers[0].last_away_reason = g_strdup ("Manual");
|
|
||||||
autoaway_reset (&servers[0]);
|
|
||||||
g_assert_true (servers[0].reconnect_away);
|
|
||||||
g_assert_cmpstr (servers[0].last_away_reason, ==, "Manual");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_retry (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, -1);
|
|
||||||
autoaway_check (base + 629 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
autoaway_check (base + 630 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_disable_and_timers (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
autoaway_reinit ();
|
|
||||||
autoaway_reinit ();
|
|
||||||
g_assert_cmpint (timer_adds, ==, 1);
|
|
||||||
base = g_get_monotonic_time ();
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, -1);
|
|
||||||
prefs.hex_away_auto_timeout = 0;
|
|
||||||
autoaway_reinit ();
|
|
||||||
g_assert_cmpint (back_count, ==, 1);
|
|
||||||
g_assert_cmpint (timer_removes, ==, 0);
|
|
||||||
g_assert_true (servers[0].autoaway_back_pending);
|
|
||||||
autoaway_reinit ();
|
|
||||||
g_assert_cmpint (back_count, ==, 1);
|
|
||||||
autoaway_check (servers[0].autoaway_sent_at + 30 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (back_count, ==, 2);
|
|
||||||
autoaway_ack_back (&servers[0]);
|
|
||||||
autoaway_reinit ();
|
|
||||||
g_assert_cmpint (timer_removes, ==, 1);
|
|
||||||
g_assert_false (servers[0].autoaway_owned);
|
|
||||||
prefs.hex_away_auto_timeout = -1;
|
|
||||||
autoaway_reinit ();
|
|
||||||
g_assert_cmpint (away_count, ==, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_empty_reason_and_large_timeout (void)
|
|
||||||
{
|
|
||||||
setup ();
|
|
||||||
prefs.hex_away_auto_reason[0] = 0;
|
|
||||||
autoaway_check (base + 600 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_nonnull (sent_reason);
|
|
||||||
g_assert_cmpstr (sent_reason, !=, "");
|
|
||||||
setup ();
|
|
||||||
prefs.hex_away_auto_timeout = G_MAXINT;
|
|
||||||
autoaway_check (base + 900 * G_USEC_PER_SEC, -1);
|
|
||||||
g_assert_cmpint (away_count, ==, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
int result, i;
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
|
||||||
g_test_add_func ("/autoaway/fallback-boundary", test_fallback_boundary);
|
|
||||||
g_test_add_func ("/autoaway/desktop-activity", test_desktop_activity);
|
|
||||||
g_test_add_func ("/autoaway/app-mode", test_app_mode);
|
|
||||||
g_test_add_func ("/autoaway/manual-away", test_manual_away);
|
|
||||||
g_test_add_func ("/autoaway/manual-takeover", test_manual_takeover);
|
|
||||||
g_test_add_func ("/autoaway/pending-cancel", test_pending_away_cancel);
|
|
||||||
g_test_add_func ("/autoaway/login-multiple-servers", test_login_and_multiple_servers);
|
|
||||||
g_test_add_func ("/autoaway/reconnect", test_disconnect_and_reconnect);
|
|
||||||
g_test_add_func ("/autoaway/retry", test_retry);
|
|
||||||
g_test_add_func ("/autoaway/disable-timers", test_disable_and_timers);
|
|
||||||
g_test_add_func ("/autoaway/empty-reason-large-timeout", test_empty_reason_and_large_timeout);
|
|
||||||
result = g_test_run ();
|
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
g_free (servers[i].last_away_reason);
|
|
||||||
g_free (sent_reason);
|
|
||||||
g_slist_free (serv_list);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
@@ -545,12 +545,11 @@ make_re (const char *grist)
|
|||||||
#define LPAR "\\("
|
#define LPAR "\\("
|
||||||
#define RPAR "\\)"
|
#define RPAR "\\)"
|
||||||
#define NOPARENS "[^() \t]*"
|
#define NOPARENS "[^() \t]*"
|
||||||
/* Match non-parenthesized characters individually to avoid nested repetition. */
|
|
||||||
#define PATH \
|
#define PATH \
|
||||||
"(" \
|
"(" \
|
||||||
"(" LPAR NOPARENS RPAR ")" \
|
"(" LPAR NOPARENS RPAR ")" \
|
||||||
"|" \
|
"|" \
|
||||||
"[^() \t]" \
|
"(" NOPARENS ")" \
|
||||||
")*" /* Zero or more occurrences of either of these */ \
|
")*" /* Zero or more occurrences of either of these */ \
|
||||||
"(?<![.,?!\\]])" /* Not allowed to end with these */
|
"(?<![.,?!\\]])" /* Not allowed to end with these */
|
||||||
struct
|
struct
|
||||||
|
|||||||
@@ -193,6 +193,15 @@ struct _zoitechat_plugin
|
|||||||
zoitechat_event_attrs *(*zoitechat_event_attrs_create) (zoitechat_plugin *ph);
|
zoitechat_event_attrs *(*zoitechat_event_attrs_create) (zoitechat_plugin *ph);
|
||||||
void (*zoitechat_event_attrs_free) (zoitechat_plugin *ph,
|
void (*zoitechat_event_attrs_free) (zoitechat_plugin *ph,
|
||||||
zoitechat_event_attrs *attrs);
|
zoitechat_event_attrs *attrs);
|
||||||
|
/* Additive API slots: append only; old binary offsets are unchanged. */
|
||||||
|
zoitechat_hook *(*zoitechat_hook_print_after) (zoitechat_plugin *, const char *, int,
|
||||||
|
int, int (*)(char *[], zoitechat_event_attrs *, void *), void *);
|
||||||
|
zoitechat_hook *(*zoitechat_hook_server_filtered) (zoitechat_plugin *, const char *, int,
|
||||||
|
int, int, const char *, int (*)(char *[], char *[], zoitechat_event_attrs *, void *), void *);
|
||||||
|
zoitechat_hook *(*zoitechat_hook_print_filtered) (zoitechat_plugin *, const char *, int,
|
||||||
|
int, int, const char *, int (*)(char *[], zoitechat_event_attrs *, void *), void *);
|
||||||
|
zoitechat_hook *(*zoitechat_register_capability) (zoitechat_plugin *, const char *, int, int, void *);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,6 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#define _POSIX_C_SOURCE 200809L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -50,7 +46,6 @@
|
|||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "plugin-identd.h"
|
#include "plugin-identd.h"
|
||||||
#include "plugin-timer.h"
|
#include "plugin-timer.h"
|
||||||
#include "autoaway.h"
|
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "servlist.h"
|
#include "servlist.h"
|
||||||
@@ -313,7 +308,7 @@ lastact_getfirst(int (*filter) (session *sess))
|
|||||||
sess->lastact_idx = LACT_NONE;
|
sess->lastact_idx = LACT_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sess;
|
return sess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +360,7 @@ lagcheck_update (void)
|
|||||||
{
|
{
|
||||||
server *serv;
|
server *serv;
|
||||||
GSList *list = serv_list;
|
GSList *list = serv_list;
|
||||||
|
|
||||||
if (!prefs.hex_gui_lagometer)
|
if (!prefs.hex_gui_lagometer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -504,8 +499,6 @@ zoitechat_reinit_timers (void)
|
|||||||
static int lag_check_tag = 0;
|
static int lag_check_tag = 0;
|
||||||
static int away_tag = 0;
|
static int away_tag = 0;
|
||||||
|
|
||||||
autoaway_reinit ();
|
|
||||||
|
|
||||||
if (prefs.hex_notify_timeout && notify_tag == 0)
|
if (prefs.hex_notify_timeout && notify_tag == 0)
|
||||||
{
|
{
|
||||||
notify_tag = fe_timeout_add_seconds (prefs.hex_notify_timeout,
|
notify_tag = fe_timeout_add_seconds (prefs.hex_notify_timeout,
|
||||||
@@ -582,7 +575,7 @@ irc_init (session *sess)
|
|||||||
g_free (buf);
|
g_free (buf);
|
||||||
g_free (arg_url);
|
g_free (arg_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_urls != NULL)
|
if (arg_urls != NULL)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
@@ -903,7 +896,7 @@ static char defaultconf_urlhandlers[] =
|
|||||||
#ifdef USE_SIGACTION
|
#ifdef USE_SIGACTION
|
||||||
/* Close and open log files on SIGUSR1. Usefull for log rotating */
|
/* Close and open log files on SIGUSR1. Usefull for log rotating */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sigusr1_handler (int signal, siginfo_t *si, void *un)
|
sigusr1_handler (int signal, siginfo_t *si, void *un)
|
||||||
{
|
{
|
||||||
GSList *list = sess_list;
|
GSList *list = sess_list;
|
||||||
@@ -1222,15 +1215,21 @@ main (int argc, char *argv[])
|
|||||||
if ((strcmp (argv[i], "-d") == 0 || strcmp (argv[i], "--cfgdir") == 0)
|
if ((strcmp (argv[i], "-d") == 0 || strcmp (argv[i], "--cfgdir") == 0)
|
||||||
&& i + 1 < argc)
|
&& i + 1 < argc)
|
||||||
{
|
{
|
||||||
set_xdir (argv[i + 1]);
|
xdir = g_strdup (argv[i + 1]);
|
||||||
}
|
}
|
||||||
else if (strncmp (argv[i], "--cfgdir=", 9) == 0)
|
else if (strncmp (argv[i], "--cfgdir=", 9) == 0)
|
||||||
{
|
{
|
||||||
set_xdir (argv[i] + 9);
|
xdir = g_strdup (argv[i] + 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xdir != NULL)
|
if (xdir != NULL)
|
||||||
|
{
|
||||||
|
if (xdir[strlen (xdir) - 1] == G_DIR_SEPARATOR)
|
||||||
|
{
|
||||||
|
xdir[strlen (xdir) - 1] = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ struct zoitechatprefs
|
|||||||
/* these are the rebranded, consistent, sorted zoitechat variables */
|
/* these are the rebranded, consistent, sorted zoitechat variables */
|
||||||
|
|
||||||
/* BOOLEANS */
|
/* BOOLEANS */
|
||||||
unsigned int hex_away_auto_system;
|
|
||||||
unsigned int hex_away_auto_unmark;
|
unsigned int hex_away_auto_unmark;
|
||||||
unsigned int hex_away_omit_alerts;
|
unsigned int hex_away_omit_alerts;
|
||||||
unsigned int hex_away_show_once;
|
unsigned int hex_away_show_once;
|
||||||
@@ -234,7 +233,6 @@ struct zoitechatprefs
|
|||||||
unsigned int hex_url_logging;
|
unsigned int hex_url_logging;
|
||||||
|
|
||||||
/* NUMBERS */
|
/* NUMBERS */
|
||||||
int hex_away_auto_timeout;
|
|
||||||
int hex_away_size_max;
|
int hex_away_size_max;
|
||||||
int hex_away_timeout;
|
int hex_away_timeout;
|
||||||
int hex_completion_amount;
|
int hex_completion_amount;
|
||||||
@@ -313,7 +311,6 @@ struct zoitechatprefs
|
|||||||
int hex_url_grabber_limit;
|
int hex_url_grabber_limit;
|
||||||
|
|
||||||
/* STRINGS */
|
/* STRINGS */
|
||||||
char hex_away_auto_reason[256];
|
|
||||||
char hex_away_reason[256];
|
char hex_away_reason[256];
|
||||||
char hex_completion_suffix[4]; /* Only ever holds a one-character string. */
|
char hex_completion_suffix[4]; /* Only ever holds a one-character string. */
|
||||||
char hex_dcc_completed_dir[PATHLEN + 1];
|
char hex_dcc_completed_dir[PATHLEN + 1];
|
||||||
@@ -600,7 +597,6 @@ typedef struct server
|
|||||||
/*time_t connect_time;*/ /* when did it connect? */
|
/*time_t connect_time;*/ /* when did it connect? */
|
||||||
unsigned long lag_sent; /* we are still waiting for this ping response*/
|
unsigned long lag_sent; /* we are still waiting for this ping response*/
|
||||||
time_t ping_recv; /* when we last got a ping reply */
|
time_t ping_recv; /* when we last got a ping reply */
|
||||||
gint64 autoaway_sent_at;
|
|
||||||
time_t away_time; /* when we were marked away */
|
time_t away_time; /* when we were marked away */
|
||||||
|
|
||||||
char *encoding;
|
char *encoding;
|
||||||
@@ -620,8 +616,6 @@ typedef struct server
|
|||||||
unsigned int end_of_motd:1; /* end of motd reached (logged in) */
|
unsigned int end_of_motd:1; /* end of motd reached (logged in) */
|
||||||
unsigned int sent_quit:1; /* sent a QUIT already? */
|
unsigned int sent_quit:1; /* sent a QUIT already? */
|
||||||
unsigned int use_listargs:1; /* undernet and dalnet need /list >0,<10000 */
|
unsigned int use_listargs:1; /* undernet and dalnet need /list >0,<10000 */
|
||||||
unsigned int autoaway_owned:1;
|
|
||||||
unsigned int autoaway_back_pending:1;
|
|
||||||
unsigned int is_away:1;
|
unsigned int is_away:1;
|
||||||
unsigned int reconnect_away:1; /* whether to reconnect in is_away state */
|
unsigned int reconnect_away:1; /* whether to reconnect in is_away state */
|
||||||
unsigned int dont_use_proxy:1; /* to proxy or not to proxy */
|
unsigned int dont_use_proxy:1; /* to proxy or not to proxy */
|
||||||
|
|||||||
@@ -59,7 +59,6 @@
|
|||||||
#include "notifygui.h"
|
#include "notifygui.h"
|
||||||
#include "textgui.h"
|
#include "textgui.h"
|
||||||
#include "fkeys.h"
|
#include "fkeys.h"
|
||||||
#include "idle.h"
|
|
||||||
#include "plugin-tray.h"
|
#include "plugin-tray.h"
|
||||||
#include "urlgrab.h"
|
#include "urlgrab.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
@@ -639,7 +638,6 @@ fe_init (void)
|
|||||||
{
|
{
|
||||||
theme_manager_init ();
|
theme_manager_init ();
|
||||||
key_init ();
|
key_init ();
|
||||||
idle_init ();
|
|
||||||
pixmaps_init ();
|
pixmaps_init ();
|
||||||
|
|
||||||
#ifdef HAVE_GTK_MAC
|
#ifdef HAVE_GTK_MAC
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalLibraryDirectories>$(ArchiveLibDir);$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(ArchiveLibDir);$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>$(DepLibs);$(ZoiteChatLib)common.lib;wbemuuid.lib;dwmapi.lib;user32.lib;pangoft2-1.0.lib;fontconfig.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>$(DepLibs);$(ZoiteChatLib)common.lib;wbemuuid.lib;dwmapi.lib;pangoft2-1.0.lib;fontconfig.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
@@ -49,7 +49,6 @@ powershell "Get-Content -Encoding UTF8 '$(ZoiteChatLib)zoitechat.rc.utf8' | Out-
|
|||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="idle.h" />
|
|
||||||
<ClInclude Include="ascii.h" />
|
<ClInclude Include="ascii.h" />
|
||||||
<ClInclude Include="banlist.h" />
|
<ClInclude Include="banlist.h" />
|
||||||
<ClInclude Include="chanlist.h" />
|
<ClInclude Include="chanlist.h" />
|
||||||
@@ -92,7 +91,6 @@ powershell "Get-Content -Encoding UTF8 '$(ZoiteChatLib)zoitechat.rc.utf8' | Out-
|
|||||||
<ClInclude Include="theme\theme-preferences.h" />
|
<ClInclude Include="theme\theme-preferences.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="idle.c" />
|
|
||||||
<ClCompile Include="ascii.c" />
|
<ClCompile Include="ascii.c" />
|
||||||
<ClCompile Include="banlist.c" />
|
<ClCompile Include="banlist.c" />
|
||||||
<ClCompile Include="chanlist.c" />
|
<ClCompile Include="chanlist.c" />
|
||||||
|
|||||||
@@ -15,9 +15,6 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="idle.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ascii.h">
|
<ClInclude Include="ascii.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -140,9 +137,6 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="idle.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ascii.c">
|
<ClCompile Include="ascii.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
/* ZoiteChat
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include "../common/autoaway.h"
|
|
||||||
#include "idle.h"
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include <CoreGraphics/CoreGraphics.h>
|
|
||||||
#include <math.h>
|
|
||||||
#elif defined(HAVE_XSS) && defined(GDK_WINDOWING_X11)
|
|
||||||
#include <gdk/gdkx.h>
|
|
||||||
#include <X11/extensions/scrnsaver.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Do not count focus changes, redraws, timers or incoming IRC traffic. */
|
|
||||||
static void
|
|
||||||
idle_event (GdkEvent *event, gpointer data)
|
|
||||||
{
|
|
||||||
switch (event->type)
|
|
||||||
{
|
|
||||||
case GDK_KEY_PRESS:
|
|
||||||
case GDK_BUTTON_PRESS:
|
|
||||||
case GDK_SCROLL:
|
|
||||||
case GDK_MOTION_NOTIFY:
|
|
||||||
case GDK_TOUCH_BEGIN:
|
|
||||||
case GDK_TOUCH_UPDATE:
|
|
||||||
autoaway_activity ();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_main_do_event (event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
idle_init (void)
|
|
||||||
{
|
|
||||||
autoaway_activity ();
|
|
||||||
/* Keep GTK's normal dispatch, including detached windows and dialogs. */
|
|
||||||
gdk_event_handler_set (idle_event, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Microseconds since desktop input, or -1 for the portable app fallback. */
|
|
||||||
gint64
|
|
||||||
fe_get_idle_time (void)
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
LASTINPUTINFO input = {0};
|
|
||||||
DWORD elapsed;
|
|
||||||
|
|
||||||
input.cbSize = sizeof input;
|
|
||||||
if (!GetLastInputInfo (&input))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* DWORD subtraction handles the 49-day GetTickCount wrap. Some injected
|
|
||||||
* input has a slightly newer timestamp; do not treat it as weeks idle. */
|
|
||||||
elapsed = GetTickCount () - input.dwTime;
|
|
||||||
if ((gint32)elapsed < 0)
|
|
||||||
elapsed = 0;
|
|
||||||
return (gint64)elapsed * 1000;
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
CFTimeInterval seconds = CGEventSourceSecondsSinceLastEventType (
|
|
||||||
kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType);
|
|
||||||
if (!isfinite (seconds) || seconds < 0 ||
|
|
||||||
seconds >= (double)G_MAXINT64 / G_USEC_PER_SEC)
|
|
||||||
return -1;
|
|
||||||
return (gint64)(seconds * G_USEC_PER_SEC);
|
|
||||||
#elif defined(HAVE_XSS) && defined(GDK_WINDOWING_X11)
|
|
||||||
GdkDisplay *display = gdk_display_get_default ();
|
|
||||||
XScreenSaverInfo info = {0};
|
|
||||||
Display *xdisplay;
|
|
||||||
int event_base, error_base, error;
|
|
||||||
Status ok;
|
|
||||||
const char *wayland = g_getenv ("WAYLAND_DISPLAY");
|
|
||||||
const char *session_type = g_getenv ("XDG_SESSION_TYPE");
|
|
||||||
|
|
||||||
/* XWayland idle is not desktop-wide. Never pass a Wayland display to Xlib. */
|
|
||||||
if (!display || !GDK_IS_X11_DISPLAY (display) || (wayland && *wayland) ||
|
|
||||||
(session_type && !g_ascii_strcasecmp (session_type, "wayland")))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
xdisplay = gdk_x11_display_get_xdisplay (display);
|
|
||||||
gdk_x11_display_error_trap_push (display);
|
|
||||||
ok = XScreenSaverQueryExtension (xdisplay, &event_base, &error_base);
|
|
||||||
if (ok)
|
|
||||||
ok = XScreenSaverQueryInfo (xdisplay, DefaultRootWindow (xdisplay), &info);
|
|
||||||
error = gdk_x11_display_error_trap_pop (display);
|
|
||||||
if (!ok || error)
|
|
||||||
return -1;
|
|
||||||
return (gint64)info.idle * 1000;
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* ZoiteChat
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ZOITECHAT_IDLE_H
|
|
||||||
#define ZOITECHAT_IDLE_H
|
|
||||||
|
|
||||||
void idle_init (void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1923,6 +1923,7 @@ inline_image_show_viewer (GtkXText *xtext, textentry *ent)
|
|||||||
{
|
{
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
|
||||||
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ON_PARENT);
|
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ON_PARENT);
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
|
||||||
gtk_window_set_destroy_with_parent (GTK_WINDOW (window), TRUE);
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (window), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3600,9 +3600,9 @@ mg_topicbar_update_height (GtkWidget *topic)
|
|||||||
if (width <= 1 && parent)
|
if (width <= 1 && parent)
|
||||||
width = gtk_widget_get_allocated_width (parent);
|
width = gtk_widget_get_allocated_width (parent);
|
||||||
width -= margin_left + margin_right;
|
width -= margin_left + margin_right;
|
||||||
/* Until we have a usable allocation, keep a single-line height.
|
if (width < 1)
|
||||||
* The size-allocate callback will measure the wrapped topic again. */
|
width = 1;
|
||||||
if (width > 0 && prefs.hex_gui_topicbar_multiline && !prefs.hex_gui_mode_buttons_inline)
|
if (prefs.hex_gui_topicbar_multiline && !prefs.hex_gui_mode_buttons_inline)
|
||||||
{
|
{
|
||||||
pango_layout_set_width (layout, width * PANGO_SCALE);
|
pango_layout_set_width (layout, width * PANGO_SCALE);
|
||||||
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
|
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
|
||||||
@@ -3618,7 +3618,7 @@ mg_topicbar_update_height (GtkWidget *topic)
|
|||||||
if (line_height <= 0)
|
if (line_height <= 0)
|
||||||
line_height = 16;
|
line_height = 16;
|
||||||
|
|
||||||
line_count = width > 0 && prefs.hex_gui_topicbar_multiline && !prefs.hex_gui_mode_buttons_inline ?
|
line_count = prefs.hex_gui_topicbar_multiline && !prefs.hex_gui_mode_buttons_inline ?
|
||||||
pango_layout_get_line_count (layout) : 1;
|
pango_layout_get_line_count (layout) : 1;
|
||||||
if (line_count <= 0)
|
if (line_count <= 0)
|
||||||
line_count = 1;
|
line_count = 1;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ zoitechat_gtk_sources = [
|
|||||||
'gtkutil.c',
|
'gtkutil.c',
|
||||||
'icon-resolver.c',
|
'icon-resolver.c',
|
||||||
'ignoregui.c',
|
'ignoregui.c',
|
||||||
'idle.c',
|
|
||||||
'inline-image.c',
|
'inline-image.c',
|
||||||
'joind.c',
|
'joind.c',
|
||||||
'menu.c',
|
'menu.c',
|
||||||
@@ -46,7 +45,6 @@ zoitechat_gtk_sources = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
zoitechat_gtk_cflags = []
|
zoitechat_gtk_cflags = []
|
||||||
idle_deps = []
|
|
||||||
|
|
||||||
zoitechat_gtk_deps = [
|
zoitechat_gtk_deps = [
|
||||||
zoitechat_common_dep,
|
zoitechat_common_dep,
|
||||||
@@ -95,17 +93,9 @@ if host_machine.system() != 'windows'
|
|||||||
zoitechat_gtk_deps += gdk_x11_dep
|
zoitechat_gtk_deps += gdk_x11_dep
|
||||||
endif
|
endif
|
||||||
|
|
||||||
xss_dep = dependency('xscrnsaver', required: false)
|
|
||||||
if gdk_x11_dep.found() and xss_dep.found()
|
|
||||||
zoitechat_gtk_deps += xss_dep
|
|
||||||
idle_deps += [gdk_x11_dep, xss_dep]
|
|
||||||
zoitechat_gtk_cflags += '-DHAVE_XSS'
|
|
||||||
endif
|
|
||||||
|
|
||||||
x11_dep = dependency('x11', required: false)
|
x11_dep = dependency('x11', required: false)
|
||||||
if x11_dep.found()
|
if x11_dep.found()
|
||||||
zoitechat_gtk_deps += x11_dep
|
zoitechat_gtk_deps += x11_dep
|
||||||
idle_deps += x11_dep
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -115,16 +105,13 @@ zoitechat_gtk_objcflags = []
|
|||||||
if host_machine.system() == 'windows'
|
if host_machine.system() == 'windows'
|
||||||
zoitechat_gtk_sources += 'notifications/notification-windows.c'
|
zoitechat_gtk_sources += 'notifications/notification-windows.c'
|
||||||
zoitechat_gtk_deps += cc.find_library('dwmapi', required: true)
|
zoitechat_gtk_deps += cc.find_library('dwmapi', required: true)
|
||||||
idle_deps += cc.find_library('user32', required: true)
|
|
||||||
zoitechat_gtk_deps += idle_deps
|
|
||||||
zoitechat_theme_deps += cc.find_library('dwmapi', required: true)
|
zoitechat_theme_deps += cc.find_library('dwmapi', required: true)
|
||||||
|
|
||||||
elif host_machine.system() == 'darwin'
|
elif host_machine.system() == 'darwin'
|
||||||
add_languages('objc', required: true)
|
add_languages('objc', required: true)
|
||||||
zoitechat_gtk_sources += 'macos-shortcuts.c'
|
zoitechat_gtk_sources += 'macos-shortcuts.c'
|
||||||
zoitechat_gtk_sources += 'notifications/notification-osx.m'
|
zoitechat_gtk_sources += 'notifications/notification-osx.m'
|
||||||
zoitechat_gtk_deps += dependency('appleframeworks', modules: ['Cocoa', 'UserNotifications', 'CoreGraphics'])
|
zoitechat_gtk_deps += dependency('appleframeworks', modules: ['Cocoa', 'UserNotifications'])
|
||||||
idle_deps += dependency('appleframeworks', modules: ['CoreGraphics'])
|
|
||||||
zoitechat_gtk_objcflags += '-fobjc-arc'
|
zoitechat_gtk_objcflags += '-fobjc-arc'
|
||||||
else
|
else
|
||||||
zoitechat_gtk_sources += 'notifications/notification-freedesktop.c'
|
zoitechat_gtk_sources += 'notifications/notification-freedesktop.c'
|
||||||
@@ -315,11 +302,3 @@ xtext_tests = executable('xtext_tests',
|
|||||||
dependencies: [gtk_dep],
|
dependencies: [gtk_dep],
|
||||||
)
|
)
|
||||||
test('XText Tests', xtext_tests, protocol: 'tap', timeout: 120)
|
test('XText Tests', xtext_tests, protocol: 'tap', timeout: 120)
|
||||||
|
|
||||||
idle_tests = executable('idle_tests',
|
|
||||||
'tests/test-idle.c',
|
|
||||||
include_directories: [config_h_include],
|
|
||||||
dependencies: [gtk_dep] + idle_deps,
|
|
||||||
c_args: zoitechat_gtk_cflags,
|
|
||||||
)
|
|
||||||
test('Idle Backend Tests', idle_tests, protocol: 'tap', timeout: 30)
|
|
||||||
@@ -92,13 +92,8 @@ notification_backend_init (const char **error)
|
|||||||
char **capabilities;
|
char **capabilities;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
/* We never read properties or listen for signals. Loading properties makes
|
|
||||||
* proxy creation block on Properties.GetAll, which some notification
|
|
||||||
* daemons (e.g. awesome's naughty) never answer, freezing startup until
|
|
||||||
* the 25 second D-Bus timeout expires. */
|
|
||||||
fdo_notifications = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
fdo_notifications = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
||||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
|
|
||||||
NULL,
|
NULL,
|
||||||
"org.freedesktop.Notifications",
|
"org.freedesktop.Notifications",
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
|
|||||||
@@ -197,9 +197,6 @@ tray_gtk3_cache_pixbuf_icon (const char *basename, GdkPixbuf *pixbuf)
|
|||||||
char *cache_dir;
|
char *cache_dir;
|
||||||
char *filename;
|
char *filename;
|
||||||
char *path;
|
char *path;
|
||||||
char *contents;
|
|
||||||
char *checksum;
|
|
||||||
gsize length;
|
|
||||||
|
|
||||||
if (!pixbuf || !basename)
|
if (!pixbuf || !basename)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -211,25 +208,13 @@ tray_gtk3_cache_pixbuf_icon (const char *basename, GdkPixbuf *pixbuf)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Include the artwork in the cache key so upgrades and theme changes
|
filename = g_strdup_printf ("%s.png", basename);
|
||||||
* cannot reuse an icon cached by an older version. */
|
|
||||||
if (!gdk_pixbuf_save_to_buffer (pixbuf, &contents, &length, "png", NULL, NULL))
|
|
||||||
{
|
|
||||||
g_free (cache_dir);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
checksum = g_compute_checksum_for_data (G_CHECKSUM_SHA256,
|
|
||||||
(const guchar *)contents, length);
|
|
||||||
filename = g_strdup_printf ("%s-%s.png", basename, checksum);
|
|
||||||
g_free (checksum);
|
|
||||||
path = g_build_filename (cache_dir, filename, NULL);
|
path = g_build_filename (cache_dir, filename, NULL);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
g_free (cache_dir);
|
g_free (cache_dir);
|
||||||
|
|
||||||
if (!g_file_test (path, G_FILE_TEST_EXISTS) &&
|
if (!g_file_test (path, G_FILE_TEST_EXISTS))
|
||||||
!g_file_set_contents (path, contents, length, NULL))
|
gdk_pixbuf_save (pixbuf, path, "png", NULL, NULL);
|
||||||
g_clear_pointer (&path, g_free);
|
|
||||||
g_free (contents);
|
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@@ -433,17 +418,6 @@ tray_app_indicator_cleanup (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
tray_app_indicator_activate_cb (AppIndicator *indicator, gint x, gint y, gpointer userdata)
|
|
||||||
{
|
|
||||||
(void)indicator;
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
(void)userdata;
|
|
||||||
|
|
||||||
tray_menu_restore_cb (NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
tray_app_indicator_init (void)
|
tray_app_indicator_init (void)
|
||||||
{
|
{
|
||||||
@@ -456,11 +430,6 @@ tray_app_indicator_init (void)
|
|||||||
if (!tray_indicator)
|
if (!tray_indicator)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Primary activation was added in Ayatana AppIndicator 0.6.0. */
|
|
||||||
if (g_signal_lookup ("activate", G_OBJECT_TYPE (tray_indicator)))
|
|
||||||
g_signal_connect (G_OBJECT (tray_indicator), "activate",
|
|
||||||
G_CALLBACK (tray_app_indicator_activate_cb), NULL);
|
|
||||||
|
|
||||||
tray_menu = gtk_menu_new ();
|
tray_menu = gtk_menu_new ();
|
||||||
g_signal_connect (G_OBJECT (tray_menu), "show",
|
g_signal_connect (G_OBJECT (tray_menu), "show",
|
||||||
G_CALLBACK (tray_menu_show_cb), NULL);
|
G_CALLBACK (tray_menu_show_cb), NULL);
|
||||||
|
|||||||
@@ -558,10 +558,6 @@ static const setting general_settings[] =
|
|||||||
{ST_ENTRY, N_("Away:"), P_OFFSETNL(hex_away_reason), 0, 0, sizeof prefs.hex_away_reason},
|
{ST_ENTRY, N_("Away:"), P_OFFSETNL(hex_away_reason), 0, 0, sizeof prefs.hex_away_reason},
|
||||||
|
|
||||||
{ST_HEADER, N_("Away"),0,0,0},
|
{ST_HEADER, N_("Away"),0,0,0},
|
||||||
{ST_NUMBER, N_("Autoaway after:"), P_OFFINTNL(hex_away_auto_timeout), N_("Set to 0 to disable automatic away."), (const char **)N_("minutes (0 = off)."), 1440},
|
|
||||||
{ST_ENTRY, N_("Autoaway message:"), P_OFFSETNL(hex_away_auto_reason), 0, 0, sizeof prefs.hex_away_auto_reason},
|
|
||||||
{ST_TOGGLE, N_("Use desktop activity when available"), P_OFFINTNL(hex_away_auto_system), N_("Use desktop input on Windows, macOS and X11. Otherwise, use keyboard and mouse activity in ZoiteChat."), 0, 0},
|
|
||||||
{ST_LABEL, N_("On Wayland, autoaway uses activity in ZoiteChat.\nOnly automatically set away states are cleared when activity resumes.")},
|
|
||||||
{ST_TOGGLE, N_("Show away once"), P_OFFINTNL(hex_away_show_once), N_("Show identical away messages only once."), 0, 0},
|
{ST_TOGGLE, N_("Show away once"), P_OFFINTNL(hex_away_show_once), N_("Show identical away messages only once."), 0, 0},
|
||||||
{ST_TOGGLE, N_("Automatically unmark away"), P_OFFINTNL(hex_away_auto_unmark), N_("Unmark yourself as away before sending messages."), 0, 0},
|
{ST_TOGGLE, N_("Automatically unmark away"), P_OFFINTNL(hex_away_auto_unmark), N_("Unmark yourself as away before sending messages."), 0, 0},
|
||||||
|
|
||||||
@@ -2349,10 +2345,9 @@ static void
|
|||||||
setup_apply (struct zoitechatprefs *pr)
|
setup_apply (struct zoitechatprefs *pr)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
PangoFontDescription *font_desc;
|
PangoFontDescription *old_desc;
|
||||||
const char *family;
|
PangoFontDescription *new_desc;
|
||||||
char *families;
|
char buffer[4 * FONTNAMELEN + 1];
|
||||||
char *font_name;
|
|
||||||
#endif
|
#endif
|
||||||
int noapply = FALSE;
|
int noapply = FALSE;
|
||||||
ThemeChangedEvent event;
|
ThemeChangedEvent event;
|
||||||
@@ -2431,26 +2426,24 @@ setup_apply (struct zoitechatprefs *pr)
|
|||||||
|
|
||||||
memcpy (&prefs, pr, sizeof (prefs));
|
memcpy (&prefs, pr, sizeof (prefs));
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
/* Append fallback families without losing the selected face attributes. */
|
|
||||||
font_desc = pango_font_description_from_string (prefs.hex_text_font_main);
|
|
||||||
family = pango_font_description_get_family (font_desc);
|
|
||||||
if (prefs.hex_text_font_alternative[0])
|
|
||||||
{
|
|
||||||
families = family && *family
|
|
||||||
? g_strconcat (family, ",", prefs.hex_text_font_alternative, NULL)
|
|
||||||
: g_strdup (prefs.hex_text_font_alternative);
|
|
||||||
pango_font_description_set_family (font_desc, families);
|
|
||||||
g_free (families);
|
|
||||||
}
|
|
||||||
font_name = pango_font_description_to_string (font_desc);
|
|
||||||
g_strlcpy (prefs.hex_text_font, font_name, sizeof prefs.hex_text_font);
|
|
||||||
g_free (font_name);
|
|
||||||
pango_font_description_free (font_desc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
event = theme_manager_on_preferences_changed (&old_prefs, &prefs, old_dark_mode, &color_change);
|
event = theme_manager_on_preferences_changed (&old_prefs, &prefs, old_dark_mode, &color_change);
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
/* merge hex_font_main and hex_font_alternative into hex_font_normal */
|
||||||
|
old_desc = pango_font_description_from_string (prefs.hex_text_font_main);
|
||||||
|
sprintf (buffer, "%s,%s", pango_font_description_get_family (old_desc), prefs.hex_text_font_alternative);
|
||||||
|
new_desc = pango_font_description_from_string (buffer);
|
||||||
|
pango_font_description_set_weight (new_desc, pango_font_description_get_weight (old_desc));
|
||||||
|
pango_font_description_set_style (new_desc, pango_font_description_get_style (old_desc));
|
||||||
|
pango_font_description_set_size (new_desc, pango_font_description_get_size (old_desc));
|
||||||
|
sprintf (prefs.hex_text_font, "%s", pango_font_description_to_string (new_desc));
|
||||||
|
|
||||||
|
/* FIXME this is not required after pango_font_description_from_string()
|
||||||
|
g_free (old_desc);
|
||||||
|
g_free (new_desc);
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
if (prefs.hex_irc_real_name[0] == 0)
|
if (prefs.hex_irc_real_name[0] == 0)
|
||||||
{
|
{
|
||||||
fe_message (_("The Real name option cannot be left blank. Falling back to \"realname\"."), FE_MSG_WARN);
|
fe_message (_("The Real name option cannot be left blank. Falling back to \"realname\"."), FE_MSG_WARN);
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
/* ZoiteChat
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include "../idle.h"
|
|
||||||
|
|
||||||
static int activity_count, dispatch_count;
|
|
||||||
static void test_gtk_dispatch (GdkEvent *event);
|
|
||||||
|
|
||||||
void
|
|
||||||
autoaway_activity (void)
|
|
||||||
{
|
|
||||||
activity_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Exercise the real handler without delivering synthetic input to a widget. */
|
|
||||||
#define gtk_main_do_event test_gtk_dispatch
|
|
||||||
#include "../idle.c"
|
|
||||||
#undef gtk_main_do_event
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_gtk_dispatch (GdkEvent *event)
|
|
||||||
{
|
|
||||||
dispatch_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_user_input_and_dispatch (void)
|
|
||||||
{
|
|
||||||
GdkEvent event = {0};
|
|
||||||
GdkEventType input[] = {GDK_KEY_PRESS, GDK_BUTTON_PRESS, GDK_SCROLL,
|
|
||||||
GDK_MOTION_NOTIFY, GDK_TOUCH_BEGIN, GDK_TOUCH_UPDATE};
|
|
||||||
GdkEventType other[] = {GDK_FOCUS_CHANGE, GDK_CONFIGURE, GDK_WINDOW_STATE,
|
|
||||||
GDK_PROPERTY_NOTIFY, GDK_VISIBILITY_NOTIFY};
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
activity_count = dispatch_count = 0;
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (input); i++)
|
|
||||||
{
|
|
||||||
event.type = input[i];
|
|
||||||
idle_event (&event, NULL);
|
|
||||||
}
|
|
||||||
g_assert_cmpint (activity_count, ==, G_N_ELEMENTS (input));
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (other); i++)
|
|
||||||
{
|
|
||||||
event.type = other[i];
|
|
||||||
idle_event (&event, NULL);
|
|
||||||
}
|
|
||||||
g_assert_cmpint (activity_count, ==, G_N_ELEMENTS (input));
|
|
||||||
g_assert_cmpint (dispatch_count, ==, G_N_ELEMENTS (input) + G_N_ELEMENTS (other));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_native_idle (void)
|
|
||||||
{
|
|
||||||
gint64 idle = fe_get_idle_time ();
|
|
||||||
g_assert_cmpint (idle, >=, -1);
|
|
||||||
#if defined(HAVE_XSS) && defined(GDK_WINDOWING_X11)
|
|
||||||
if (gdk_display_get_default () && GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
|
|
||||||
{
|
|
||||||
/* XWayland must use the app fallback, even if XSS is compiled in. */
|
|
||||||
char *saved = g_strdup (g_getenv ("WAYLAND_DISPLAY"));
|
|
||||||
char *saved_type = g_strdup (g_getenv ("XDG_SESSION_TYPE"));
|
|
||||||
g_unsetenv ("WAYLAND_DISPLAY");
|
|
||||||
g_unsetenv ("XDG_SESSION_TYPE");
|
|
||||||
g_assert_cmpint (fe_get_idle_time (), >=, 0);
|
|
||||||
g_setenv ("WAYLAND_DISPLAY", "wayland-test", TRUE);
|
|
||||||
g_assert_cmpint (fe_get_idle_time (), ==, -1);
|
|
||||||
g_unsetenv ("WAYLAND_DISPLAY");
|
|
||||||
g_setenv ("XDG_SESSION_TYPE", "wayland", TRUE);
|
|
||||||
g_assert_cmpint (fe_get_idle_time (), ==, -1);
|
|
||||||
if (saved_type)
|
|
||||||
g_setenv ("XDG_SESSION_TYPE", saved_type, TRUE);
|
|
||||||
else
|
|
||||||
g_unsetenv ("XDG_SESSION_TYPE");
|
|
||||||
g_free (saved_type);
|
|
||||||
if (saved)
|
|
||||||
g_setenv ("WAYLAND_DISPLAY", saved, TRUE);
|
|
||||||
else
|
|
||||||
g_unsetenv ("WAYLAND_DISPLAY");
|
|
||||||
g_free (saved);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
|
||||||
gtk_init_check (&argc, &argv);
|
|
||||||
g_test_add_func ("/idle/user-input-and-dispatch", test_user_input_and_dispatch);
|
|
||||||
g_test_add_func ("/idle/native-backend", test_native_idle);
|
|
||||||
return g_test_run ();
|
|
||||||
}
|
|
||||||
@@ -2003,34 +2003,12 @@ gtk_xtext_word_select_char (const unsigned char *ch)
|
|||||||
return g_unichar_isalnum (uc) || uc == '_' || uc == '-';
|
return g_unichar_isalnum (uc) || uc == '_' || uc == '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
gtk_xtext_color_code_len (const unsigned char *p, const unsigned char *lim)
|
|
||||||
{
|
|
||||||
const unsigned char *q = p + 1;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
if (*p == ATTR_HEXCOLOR)
|
|
||||||
return 1 + hexcolor_parse ((const char *)q, (int)(lim - q), NULL, NULL, NULL);
|
|
||||||
if (*p != ATTR_COLOR)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (n = 0; n < 2 && q < lim && g_ascii_isdigit (*q); n++)
|
|
||||||
q++;
|
|
||||||
if (n && q + 1 < lim && *q == ',' && g_ascii_isdigit (q[1]))
|
|
||||||
{
|
|
||||||
q += 2;
|
|
||||||
if (q < lim && g_ascii_isdigit (*q))
|
|
||||||
q++;
|
|
||||||
}
|
|
||||||
return (int)(q - p);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_xtext_get_word_select_range (GtkXText *xtext, int x, int y, textentry **ret_ent, int *ret_off, int *ret_len)
|
gtk_xtext_get_word_select_range (GtkXText *xtext, int x, int y, textentry **ret_ent, int *ret_off, int *ret_len)
|
||||||
{
|
{
|
||||||
textentry *ent;
|
textentry *ent;
|
||||||
int offset;
|
int offset;
|
||||||
unsigned char *start, *end, *p, *lim;
|
unsigned char *start, *end;
|
||||||
|
|
||||||
ent = gtk_xtext_find_char (xtext, x, y, &offset, NULL);
|
ent = gtk_xtext_find_char (xtext, x, y, &offset, NULL);
|
||||||
if (!ent || offset < 0 || offset >= ent->str_len)
|
if (!ent || offset < 0 || offset >= ent->str_len)
|
||||||
@@ -2049,29 +2027,8 @@ gtk_xtext_get_word_select_range (GtkXText *xtext, int x, int y, textentry **ret_
|
|||||||
start = prev;
|
start = prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The digits after a color code look like word characters, but they
|
|
||||||
are part of the code. Move the start past any code they belong to. */
|
|
||||||
lim = ent->str + ent->str_len;
|
|
||||||
for (p = ent->str; p < start; )
|
|
||||||
{
|
|
||||||
int n = gtk_xtext_color_code_len (p, lim);
|
|
||||||
|
|
||||||
if (!n)
|
|
||||||
{
|
|
||||||
p++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (p + n > start)
|
|
||||||
start = p + n;
|
|
||||||
p += n;
|
|
||||||
}
|
|
||||||
if (start > ent->str + offset)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
while (end && end < ent->str + ent->str_len && gtk_xtext_word_select_char (end))
|
while (end && end < ent->str + ent->str_len && gtk_xtext_word_select_char (end))
|
||||||
end = g_utf8_find_next_char (end, ent->str + ent->str_len);
|
end = g_utf8_find_next_char (end, ent->str + ent->str_len);
|
||||||
if (!end)
|
|
||||||
end = ent->str + ent->str_len;
|
|
||||||
|
|
||||||
if (ret_ent)
|
if (ret_ent)
|
||||||
*ret_ent = ent;
|
*ret_ent = ent;
|
||||||
|
|||||||
@@ -48,12 +48,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
gint64
|
|
||||||
fe_get_idle_time (void)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int done = FALSE;
|
static int done = FALSE;
|
||||||
|
|
||||||
|
|
||||||
@@ -591,7 +585,10 @@ fe_args (int argc, char *argv[])
|
|||||||
|
|
||||||
if (arg_cfgdir)
|
if (arg_cfgdir)
|
||||||
{
|
{
|
||||||
set_xdir (arg_cfgdir);
|
g_free (xdir);
|
||||||
|
xdir = g_strdup(arg_cfgdir);
|
||||||
|
if (xdir[strlen (xdir) - 1] == '/')
|
||||||
|
xdir[strlen (xdir) - 1] = 0;
|
||||||
g_free (arg_cfgdir);
|
g_free (arg_cfgdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{EE388A27-6992-43C0-BA9B-61D8968D42E3}</ProjectGuid>
|
|
||||||
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Label="Configuration">
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<Import Project="zoitechat.props" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetName>autoaway-tests</TargetName>
|
|
||||||
<OutDir>$(ZoiteChatBuild)\$(ZoiteChatPlatform)\tests\</OutDir>
|
|
||||||
<IntDir>$(ZoiteChatObj)autoaway-tests\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup>
|
|
||||||
<ClCompile>
|
|
||||||
<PreprocessorDefinitions>WIN32;_WIN64;_CONSOLE;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>$(ZoiteChatLib);$(DepsRoot)\include;$(OpenSslInclude);$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
||||||
<AdditionalDependencies>gio-2.0.lib;gobject-2.0.lib;glib-2.0.lib;$(IntlLib);%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="..\src\common\autoaway.c" />
|
|
||||||
<ClCompile Include="..\src\common\tests\test-autoaway.c" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
</Project>
|
|
||||||
@@ -90,6 +90,7 @@
|
|||||||
<MSWindowsTheme Include="$(DepsRoot)\share\themes\MS-Windows\**\*" />
|
<MSWindowsTheme Include="$(DepsRoot)\share\themes\MS-Windows\**\*" />
|
||||||
<HicolorIcons Include="$(DepsRoot)\share\icons\hicolor\index.theme" />
|
<HicolorIcons Include="$(DepsRoot)\share\icons\hicolor\index.theme" />
|
||||||
<HicolorIcons Include="$(DepsRoot)\share\icons\hicolor\**\*.*" />
|
<HicolorIcons Include="$(DepsRoot)\share\icons\hicolor\**\*.*" />
|
||||||
|
<PythonAdditiveApis Include="..\..\plugins\python\_zoitechat_*.py" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Copy SourceFiles="@(None)" DestinationFolder="$(ZoiteChatRel)" />
|
<Copy SourceFiles="@(None)" DestinationFolder="$(ZoiteChatRel)" />
|
||||||
@@ -115,6 +116,7 @@
|
|||||||
<Copy SourceFiles="..\..\plugins\python\hexchat.py" DestinationFolder="$(ZoiteChatRel)\python" Condition="'$(Python3Enabled)'=='true' or '$(Python38Enabled)'=='true'" />
|
<Copy SourceFiles="..\..\plugins\python\hexchat.py" DestinationFolder="$(ZoiteChatRel)\python" Condition="'$(Python3Enabled)'=='true' or '$(Python38Enabled)'=='true'" />
|
||||||
<Copy SourceFiles="..\..\plugins\python\zoitechat.py" DestinationFolder="$(ZoiteChatRel)\python" Condition="'$(Python3Enabled)'=='true' or '$(Python38Enabled)'=='true'" />
|
<Copy SourceFiles="..\..\plugins\python\zoitechat.py" DestinationFolder="$(ZoiteChatRel)\python" Condition="'$(Python3Enabled)'=='true' or '$(Python38Enabled)'=='true'" />
|
||||||
<Copy SourceFiles="..\..\plugins\python\_zoitechat.py" DestinationFolder="$(ZoiteChatRel)\python" Condition="'$(Python3Enabled)'=='true' or '$(Python38Enabled)'=='true'" />
|
<Copy SourceFiles="..\..\plugins\python\_zoitechat.py" DestinationFolder="$(ZoiteChatRel)\python" Condition="'$(Python3Enabled)'=='true' or '$(Python38Enabled)'=='true'" />
|
||||||
|
<Copy SourceFiles="@(PythonAdditiveApis)" DestinationFolder="$(ZoiteChatRel)\python" Condition="('$(Python3Enabled)'=='true' or '$(Python38Enabled)'=='true') and '@(PythonAdditiveApis)' != ''" />
|
||||||
|
|
||||||
<WriteLinesToFile File="$(ZoiteChatRel)portable-mode" Lines="2" Overwrite="true" />
|
<WriteLinesToFile File="$(ZoiteChatRel)portable-mode" Lines="2" Overwrite="true" />
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 201 KiB After Width: | Height: | Size: 201 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -122,7 +122,7 @@ if (-not (Test-Path (Join-Path $source 'zoitechat.exe'))) {
|
|||||||
|
|
||||||
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
||||||
$templatePath = Join-Path $PSScriptRoot 'AppxManifest.xml.in'
|
$templatePath = Join-Path $PSScriptRoot 'AppxManifest.xml.in'
|
||||||
$iconPath = Join-Path $repoRoot 'data\icons\zoitechat-256.png'
|
$iconPath = Join-Path $repoRoot 'data\icons\zoitechat.png'
|
||||||
|
|
||||||
if (-not (Test-Path $templatePath)) {
|
if (-not (Test-Path $templatePath)) {
|
||||||
throw "MSIX manifest template is missing: $templatePath"
|
throw "MSIX manifest template is missing: $templatePath"
|
||||||
|
|||||||