Skip to content

feat(amulegui): populate Server Info tab from amuled via EC - #120

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/amulegui-server-info
Jun 12, 2026
Merged

feat(amulegui): populate Server Info tab from amuled via EC#120
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/amulegui-server-info

Conversation

@got3nks

@got3nks got3nks commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Addresses the first item in #54 — the "Server Info" sub-tab on the Network panel was present in amule (monolithic) but missing in amulegui. The tab UI has actually been generated by serverListDlgDown for years, but amuleDlg.cpp:1581-1586 gated its AddPage behind #ifndef CLIENT_GUI, because no one had wired the EC plumbing to populate it. This PR wires the plumbing and drops the gate. The other items in #54 (directory tree behaviour and the broader preferences enable/disable audit) are intentionally left for follow-ups; the issue stays open.

What was already there

  • amuled tracks every ed2k server message in CamuleApp::server_msg (amule.cpp:1841) and exposes it on EC as EC_OP_GET_SERVERINFO / EC_OP_SERVERINFO / EC_OP_CLEAR_SERVERINFO (ExternalConn.cpp:2230-2237). amuleweb has consumed these for years (php_amule_lib.cpp:705-715).
  • CRemoteConnect::GetServerInfo / ClearServerInfo (RemoteConnect.h:293,302) were declared back in 2009 (sturedman's "Implement directory preferences in remote gui" commit) but never implemented, never called, and the declarations have been dead weight ever since.

What this PR adds

  • CServerInfoHandlerRem in amule-remote-gui.h — an EC_OP_GET_SERVERINFO response handler that keeps the last-seen snapshot in m_seenSoFar, computes a delta against the fresh response, and only feeds the new tail to the GUI. Diff-based update preserves scroll position and avoids re-rendering the full log on every poll. On a non-monotonic delta (e.g. amuled restarted, or another client called EC_OP_CLEAR_SERVERINFO), the handler resets ID_SERVERINFO and refills from the current snapshot.
  • Polling hook in CamuleRemoteGuiApp::OnPollTimer step 2 — fires the EC request only while the Network tab is visible. Step 2's natural ~3 s cadence is plenty for the bursty traffic pattern (welcome on connect, ID change, disconnect) and doesn't wake amuled when the user isn't looking.
  • CamuleRemoteGuiApp::AddServerMessageLine — dispatches to CamuleDlg::AddServerMessageLine, the same code path the monolithic build calls, so ID_SERVERINFO (500-char truncation + auto-scroll) behaves identically.
  • CamuleRemoteGuiApp::GetServerLog(true) — was a stub that returned ""; now issues EC_OP_CLEAR_SERVERINFO, resets m_seenSoFar, and clears ID_SERVERINFO so the existing "Reset" button on the Server Info panel (wired via ServerWnd.cpp:171) works the same as in monolithic.
  • Drops the #ifndef CLIENT_GUI gate at amuleDlg.cpp:1582 so the tab is shown unconditionally.

What's deliberately not in this PR (left for the rest of #54)

  • The directory-tree behaviour when amulegui is on remote vs localhost (item 2 in the issue) — separate, larger discussion about how the tree should source data and whether dirpickers should be only-Browse-disabled vs fully disabled (item 3).
  • A broader audit of which preferences panels should be local-only vs amuled-driven vs shared via EC. That deserves its own thread with @ngosang per-tab.

Test plan

  • Local: built clean on macOS Release (cmake --build build-macos --target amulegui).
  • Live: ran the rebuilt aMuleGUI.app against an amuled on a remote ARM64 Ubuntu VM. After amuled connected to an ed2k server, the welcome message appeared in the Server Info sub-tab within ~3 s, and "Reset" both cleared the on-screen log and emptied amuled's server_msg buffer (verified by the next poll arriving empty).
  • CI green on Ubuntu / macOS / mingw-w64.

The Network tab's bottom notebook in the monolithic build has four
sub-panels (aMule Log / Server Info / ED2K Info / Kad Info). In
amulegui only three were ever visible: amuleDlg::DoNetworkRearrange
gated the Server Info AddPage with `#ifndef CLIENT_GUI` because the
remote GUI had no way to populate ID_SERVERINFO from the daemon. EC
has actually shipped `EC_OP_GET_SERVERINFO` / `EC_OP_SERVERINFO` /
`EC_OP_CLEAR_SERVERINFO` opcodes for years (amuleweb uses them), and
the corresponding stubs `CRemoteConnect::GetServerInfo` /
`ClearServerInfo` were declared back in 2009 but never implemented.

This wires the daemon's `server_msg` buffer to amulegui:

- `CServerInfoHandlerRem` (new) issues `EC_OP_GET_SERVERINFO`,
  receives the cumulative log as one `EC_TAG_STRING`, and diffs
  against the last-seen snapshot so the on-screen text control only
  receives new lines (preserves scroll position, no full-redraw on
  every poll). On a non-monotonic delta (amuled restart, or someone
  else called `EC_OP_CLEAR_SERVERINFO`) it resets the ctrl and
  refills from the current snapshot.
- The poll fires from `OnPollTimer` step 2 while the Network tab is
  visible. Step 2 fires roughly every 3 s, which is plenty for the
  bursty ed2k server-message traffic (welcome on connect, ID change,
  disconnect) and avoids waking amuled when the user isn't looking.
- `CamuleRemoteGuiApp::AddServerMessageLine` (new) dispatches to
  `CamuleDlg::AddServerMessageLine`, the same code path the
  monolithic build calls, so the ID_SERVERINFO text control behaves
  identically (500-char truncation + auto-scroll).
- `CamuleRemoteGuiApp::GetServerLog(true)` now actually issues
  `EC_OP_CLEAR_SERVERINFO`, resets the local snapshot, and clears
  ID_SERVERINFO so the existing "Reset" button on the Server Info
  panel works the same as the monolithic one.
- `CamuleDlg::DoNetworkRearrange` drops the `#ifndef CLIENT_GUI` so
  the tab is shown unconditionally.

Refs amule-project#54.
@got3nks
got3nks merged commit 3fc384b into amule-org:master Jun 12, 2026
10 checks passed
@got3nks
got3nks deleted the fix/amulegui-server-info branch June 12, 2026 09:34
got3nks added a commit that referenced this pull request Jun 15, 2026
Reported in #162. The Server Info tab in the Network panel kept
displaying messages from the disconnected server because there was no
clear-on-disconnect path — the cumulative `server_msg` buffer
(monolithic) and the diff-snapshot / on-screen text ctrl
(amulegui post-#120) just kept accumulating.

Adds a small ClearServerInfo() on each app variant:

  - CamuleApp::ClearServerInfo()           — clears server_msg.
  - CamuleRemoteGuiApp::ClearServerInfo()  — sends EC_OP_CLEAR_SERVERINFO
                                             to amuled and clears
                                             m_serverinfo_handler.m_seenSoFar.

CamuleDlg::ShowConnectionState tracks the previous ed2k state via a
static bool and on a connected -> disconnected transition calls both
theApp->ClearServerInfo() (data) and ResetLog(ID_SERVERINFO) (UI).
The dialog does the UI clear so the data-side method stays compilable
in the daemon build (amuledlg lives on CamuleGuiBase which CamuleApp
doesn't inherit).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant