Skip to content

EC: expose search result rating to remote clients - #452

Merged
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:ec-search-rating
Apr 22, 2026
Merged

EC: expose search result rating to remote clients#452
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:ec-search-rating

Conversation

@got3nks

@got3nks got3nks commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

CEC_SearchFile_Tag now forwards the aggregated user rating from CSearchFile to EC clients. Previously this field was only available in the native GUI (which reads CSearchFile objects directly from memory); remote GUIs and EC-based tools could not see it.

Search results already carry ratings from ED2K sources and KAD publishers via FT_FILERATING tags, and aMule already aggregates them across sources into m_iUserRating (SearchFile.cpp:76-77, SearchFile.cpp:246-302). The native GUI renders them directly (SearchListCtrl.cpp:873-874). This patch simply bridges the gap in the EC protocol so remote clients can access the same data.

Only rating is exposed — comments are not populated for search results in aMule (m_strComment is never set in SearchFile.cpp; only m_iUserRating is aggregated from FT_FILERATING tags).

Changes

  • Encoder (ECSpecialCoreTags.cpp): add EC_TAG_KNOWNFILE_RATING to CEC_SearchFile_Tag when the search result has a rating (reuses the existing tag ID already used by CEC_SharedFile_Tag)
  • Decoder (amule-remote-gui.cpp): CSearchFile constructor reads the new tag and populates m_iUserRating
  • Header (ECSpecialTags.h): add GetRating() accessor to CEC_SearchFile_Tag (same pattern as CEC_SharedFile_Tag)

Backward compatibility

  • EC clients that don't know about the tag simply ignore it (standard EC behaviour for unknown tags)
  • No wire protocol version bump needed — the tag ID EC_TAG_KNOWNFILE_RATING already exists
  • No changes to search logic or rating aggregation

CEC_SearchFile_Tag now forwards the aggregated user rating from
CSearchFile to EC clients.  Previously this field was only available
in the native GUI (which reads CSearchFile objects directly from
memory); remote GUIs and EC-based tools could not see it.

Only rating is exposed — comments are not populated for search
results in aMule (m_strComment is never set in SearchFile.cpp;
only m_iUserRating is aggregated from FT_FILERATING tags across
sources).

Encoder: add EC_TAG_KNOWNFILE_RATING to CEC_SearchFile_Tag when
the search result has a rating (reuses the existing tag ID already
used by CEC_SharedFile_Tag).

Decoder: CSearchFile constructor in amule-remote-gui.cpp reads the
new tag and populates m_iUserRating.

Header: add GetRating() accessor to CEC_SearchFile_Tag (same
pattern as CEC_SharedFile_Tag).
got3nks added a commit to got3nks/amule-ec-node that referenced this pull request Apr 17, 2026
Requires aMule PR #452 (amule-project/amule#452)
to be applied. Older builds omit the tag and result.rating stays undefined.
@mrjimenez
mrjimenez merged commit d9be7bd into amule-project:master Apr 22, 2026
3 checks passed
@got3nks
got3nks deleted the ec-search-rating branch May 3, 2026 15:19
ngosang pushed a commit to ngosang/amule that referenced this pull request Jul 12, 2026
amule-project#444) (amule-project#452)

When the EC connection to the remote core dropped after startup (e.g. the
machine slept or a VPN/SSH tunnel restarted and the socket died), amulegui
showed "aMule has terminated probably" and exited, forcing a full restart +
resync. It now reconnects in the background instead.

Reconnect mechanics:
- CLibSocket::ResetForReconnect() swaps a fresh asio impl onto the SAME
  CRemoteConnect, so the socket can be re-opened after a loss without
  recreating the object (every remote container pins its CRemoteConnect).
  CECSocket::ResetProtocolState() rewinds the packet-reassembly state
  machine so a mid-packet read left over from the drop can't misparse the
  reconnected session's first bytes.
- On a post-startup loss the UI is frozen behind a modal reconnect dialog
  (attempt counter + countdown to the next try + "Abort and exit"); attempts
  run every 5 s with a 15 s per-attempt watchdog, until the connection is
  restored or the user aborts.
- amuleweb / amulecmd keep their fail-fast _exit(1) on loss (the new paths
  are all gated on the GUI's m_notifier).

Two fixes the reused socket needs to hand off cleanly:
- Clear m_ErrorCode on a successful connect: the swap can leave a stale
  EBADF from an aborted read on the impl, and SocketRealError() would then
  make CECSocket::WritePacket refuse to send the login.
- Swallow a LibSocketLost that arrives while a dial is still pending
  (EC_CONNECT_SENT): it's a stale event queued for the previous connection
  before the impl was swapped, and would otherwise abort the in-flight
  reconnect. A genuinely failed dial is caught by the connect-timeout
  watchdog instead.

Resync is reconcile-in-place, not wipe+rebuild, so scroll and selection
survive:
- Polling resumes and the fresh full snapshot updates rows in place / adds
  new / prunes gone. A partial-update server won't re-emit FILE_REMOVED for
  files deleted while disconnected, so CKnownFilesRem forces a one-shot
  prune-by-absence on the first post-reconnect update (m_reconnectReconcile).
  The server / client / friend lists already prune every poll, so they
  self-heal with no special case.
- The daemon keeps its RLE gap/part/req-status encoders per connection, so a
  reconnect restarts them from an empty baseline. The reused CKnownFile /
  CPartFile decoders (m_PartFileEncoderData, m_partStatus) are reset to
  match, or the first differential update would XOR against a stale buffer
  and paint garbage (all-red progress bars, wrong availability shading).
- Large libraries stay responsive: the reconnect poll wraps the download +
  shared list ctrls in BeginBatchUpdate()/EndBatchUpdate() (one repaint +
  one sort, per-item sort suppressed) so a 10k+ resync doesn't hitch.

No daemon or EC wire-protocol changes: reconnect works against a stock amuled.
ngosang pushed a commit to ngosang/amule that referenced this pull request Jul 13, 2026
amule-project#444) (amule-project#465)

Follow-up to amule-project#452, from two issues reported after a successful reconnect.

1. Empty download queue + shared file lists (restart required)

   The EC request FIFO (CRemoteConnect::m_req_fifo) assumes the core answers
   every request in FCFS order. A socket dropped mid-poll leaves the requests
   that were on the air unanswered, so their handlers linger in the FIFO. After
   the reconnect each reply pops the wrong (stale) handler: a stats reply routed
   to CKnownFilesRem drives its one-shot post-reconnect reconcile against an
   empty file set, and the absence-prune wipes the whole library. It is
   intermittent (depends how many requests were in flight at the drop) and only
   a full restart clears it, since a fresh process starts with an empty FIFO.

   - CRemoteConnect::DiscardRequestQueue() flushes the FIFO and zeroes the
     in-flight counter on reconnect, rewinding each orphaned handler's request
     state (CECPacketHandlerBase::AbortPendingRequest, overridden by
     CRemoteContainer to reset its request SM to IDLE) so a container whose
     reply died still re-requests instead of wedging.
   - Defensive guard in CKnownFilesRem::ProcessUpdate: if the first
     post-reconnect reply carries no files while the list is still populated,
     skip the absence-prune and keep the one-shot armed for the next poll.

2. Ellipsis mojibake on Windows

   The reconnect status strings embedded a literal U+2026. On the untranslated
   (English) path the narrow msgid is decoded with the C locale (CP1252 on
   Windows), rendering as garbage in both the dialog and the log. Replaced the
   ellipsis with "..." in every source msgid, and -- to keep existing
   translations valid -- in every catalog msgid/msgstr as well (regen leaves no
   new fuzzy entries).

Client-side only: no daemon or EC wire-protocol change, so the updated aMuleGUI
works against a stock amuled.
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.

2 participants