Transmission RPC integration
The Transmission RPC integration connects the desktop client to a remote Transmission daemon. It turns daemon replies into the torrent, session, peer, file, tracker, and statistics state shown by the application. It also sends user actions back to the daemon and reports connection or request errors to the main window.
Client boundary
The RPC client is the boundary between the application and the daemon. The main window asks it to connect, refresh state, or send an action; the client owns the HTTP request and response exchange, while the daemon remains the source of truth for remote torrent state.
RPC client role
/home/user/repo/rpc.pas defines the shared RPC client and its worker that perform this boundary work. The client exposes connection state, the negotiated RPC version, refresh requests, and JSON request methods. The main window uses these services instead of managing the daemon session as part of each screen action.
The client supports the Transmission RPC message model. A request names a method and can carry arguments. A successful response can return an arguments object; an unsuccessful response becomes client status that the main window can display.
References: rpc.pas• L108-183 rpc-spec.txt• L22-54
Application state mapping
The client maps broad groups of daemon data to the views that use them. Torrent summaries drive the main list. Selected-torrent data drives the detail views. Session data drives global status and limits. Peer, file, tracker, and statistics data are loaded only when their view needs them.
The main window receives these groups through focused update operations such as FillTorrentsList, FillGeneralInfo, and FillSessionInfo. This keeps remote data in daemon terms at the RPC boundary while the UI presents it in user-facing lists and panels.
References: rpc.pas• L372-425 main.pas• L5973-6089 main.pas• L7217-7255
Connection lifecycle
The connection lifecycle prepares one configured daemon endpoint, starts a background exchange, and exposes a connected or failed state to the rest of the application. A disconnect clears remote state before the next connection can begin.
Connection setup
The active connection profile supplies the host, port, RPC path, authentication, transport security, and optional proxy settings. The main window applies these values to the RPC client, then starts the client worker. The default RPC path is /transmission/rpc, but the profile can override it.
The first session request checks that the daemon answers and reads its RPC version and version string. The client uses that version to decide which data and actions the daemon can support. A successful session check updates the connection and status information used by the UI.
For details about the profile fields and how they reach the client, see Daemon connection configuration.
References: main.pas• L5310-5397 rpc.pas• L452-504 rpc.pas• L818-840 connoptions.pas• L535-592
Connection teardown
Disconnect stops outstanding work and clears the connection session before the main window removes its remote data. The UI then disables actions that require a daemon and shows the disconnected state.
When a request fails in the worker, the client records the error and marks the connection as unavailable. The main window can show a reconnect panel when auto-reconnect is enabled. This makes a transport failure affect both the connection indicator and the availability of remote actions.
References: rpc.pas• L1464-1500 main.pas• L5426-5477 main.pas• L7399-7447
Refresh coordination
Refresh coordination turns periodic and user-driven requests into an ordered stream of daemon reads. It avoids overlapping updates and prevents an older response from replacing newer user selections.
Refresh groups
The client tracks three refresh groups:
- Torrents provide the main list and its summary values.
- Details provide data for the selected torrent and the active detail view.
- Session provides daemon-wide settings, status, and free-space information.
The worker checks these groups in a defined order. Torrent and detail data refresh at the normal interval. Session data refreshes less often. User actions can mark one or more groups for immediate refresh after a remote change.
The client also requests peer, file, tracker, or statistics data according to the active detail view. It sends the smallest useful detail request rather than treating all detail data as one permanent payload.
References: rpc.pas• L47-50 rpc.pas• L266-345 rpc.pas• L506-664 main.pas• L3375-3381
Selection consistency
Each detail request carries the selected torrent and the selected detail type that were current when the request began. If the user changes either value before the response arrives, the client keeps the new request pending and does not apply stale detail data.
File details use the same rule after a file selection or priority change. A changed file view invalidates the earlier payload so that a late response cannot restore old file choices.
This is the main protection against races between a slow daemon response and fast UI navigation. The related RPC protocol and session flow page describes the request exchange in more detail.
References: rpc.pas• L119-127 rpc.pas• L1345-1383 rpc.pas• L1398-1457 main.pas• L7533-7547
Data freshness
The client keeps selected-torrent data fresh without fetching every large field on every cycle. Stable metadata is reused after it is known. The piece bitfield is refreshed less often because it can be large. Incomplete magnet metadata remains eligible for later refresh until it becomes complete.
This balance keeps the detail view responsive while allowing the daemon to remain the authority for values that can change. A torrent that disappears clears the related cached detail data instead of leaving an empty view that looks valid.
References: rpc.pas• L666-799
Remote operations
Remote operations translate UI actions into Transmission methods and then request fresh state. The operation result is not treated as the final UI state; a later refresh confirms what the daemon accepted.
Torrent actions
The application uses a common action path for operations on one or more torrent IDs. It sends start, stop, force-start, verify, reannounce, remove, queue movement, and related actions. Successful actions trigger a list and detail refresh. Removal also invalidates selected file details.
Torrent settings use the same RPC boundary for download and upload limits, file selection, file priority, tracker changes, labels, location changes, and path renames. These changes can alter the shape or meaning of detail data, so the client marks the affected detail group as stale.
References: main.pas• L7450-7490 main.pas• L7492-7531 main.pas• L2882-2967 main.pas• L6800-6834
Torrent intake
Adding a torrent sends either a remote filename or torrent content to the daemon. The reply identifies the new torrent or reports that the torrent already exists. The application uses that result to continue with tracker updates, file choices, naming, and optional start behavior.
The add flow can also query free space on the daemon before or during destination selection. The path belongs to the daemon host, not the local desktop, so the check supports remote download locations.
References: main.pas• L2628-2662 main.pas• L2882-2975 addtorrent.pas• L1117-1147 rpc-spec.txt• L356-390
Session operations
Session operations cover daemon-wide settings and checks. The UI reads and writes session limits and related options, tests the peer port, and updates the blocklist. These requests affect the daemon as a whole rather than one torrent.
The session read also combines the daemon's download directory with a free-space request when the RPC version supports that method. The resulting value feeds the status and add-torrent views.
References: daemonoptions.pas• L147-168 main.pas• L3508-3710 main.pas• L4380-4394 rpc.pas• L452-504
RPC compatibility
Transmission daemons can expose different RPC versions. The integration reads the version during connection and uses it to adapt both the fields it requests and the actions it exposes.
Version-aware behavior
The UI enables features only when the connected daemon supports their RPC method or field. Examples include force start, queue movement, torrent location changes, labels, tracker editing, path renaming, and free-space checks. The client also omits fields that are not valid for an older version.
Some daemon versions return torrent rows in a compact table form. The client expands those rows into named torrent objects before the main window consumes them. This gives the UI one stable shape across supported server versions.
References: rpc.pas• L506-563 rpc.pas• L1161-1203 main.pas• L5640-5687 main.pas• L7217-7243 rpc-spec.txt• L624-767
Protocol session
The RPC protocol uses HTTP POST with UTF-8 JSON. Most daemons protect the endpoint with an X-Transmission-Session-Id value. When the daemon returns HTTP 409, the client takes the new session ID from the response and retries the request.
The client accepts compressed JSON responses and checks both the HTTP result and the RPC result value. It reports transport errors, invalid JSON, missing result data, and RPC method errors through the same status path used by the connection UI.
References: rpc.pas• L859-900 rpc.pas• L902-1150 rpc-spec.txt• L47-67
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to RPC fields or method names must be checked against the daemon RPC version gates and the UI actions that depend on them.
- Changes to the selected-torrent or file payload must preserve generation checks so late responses cannot overwrite a newer selection.
- Changes to the session response must keep free-space and RPC-version state consistent with the status bar, add-torrent flow, and feature enablement.
- Changes to request failure handling must preserve the distinction between a recoverable action error and a connection failure that can start auto-reconnect.
- Changes to connection profile names or keys must remain aligned between
connoptions.pasand the endpoint setup inmain.pas.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The daemon returns HTTP 409 with a new session ID. | The request fails unless the request is retried with the new ID. | The RPC client replaces the stored session header and retries. |
| A request returns a non-success RPC result or invalid JSON. | The requested state or action is not applied and the status can show an error. | SendRequest validates the response shape and reports the error through Status. |
| The transport or TLS connection fails during a worker request. | The client becomes disconnected and the UI clears or disables remote state. | The worker stops the connection; the main window offers auto-reconnect when configured. |
| A detail response arrives after the user selects another torrent or detail view. | Old peers, files, or general data could appear for the new selection. | Detail generations and selected IDs must match before the data is applied. |
| A feature is sent to a daemon below its required RPC version. | The daemon rejects the method or field. | Connection-time RPC version checks gate UI actions and remove unsupported fields. |
| A file or torrent mutation succeeds but no refresh is requested. | The UI continues to show values that no longer match the daemon. | Successful mutations invalidate affected detail data and request a refresh. |
Key files
| File | Why to read it |
|---|---|
rpc.pas | Defines the RPC client boundary, session exchange, refresh worker, response checks, and version-aware data reads. |
main.pas | Shows how connection state reaches the UI, how RPC data fills application views, and how user actions become remote operations. |
connoptions.pas | Shows the connection profile values that shape the daemon endpoint and transport. |
| rpc-spec.txt | Defines the Transmission request, response, session, torrent, and version contracts used by the client. |
addtorrent.pas | Shows how the add-torrent flow uses the daemon for destination checks and remote torrent creation. |
daemonoptions.pas | Shows how daemon-wide checks and settings use session-level RPC operations. |