diff --git a/app/Madeira.xcodeproj/project.pbxproj b/app/Madeira.xcodeproj/project.pbxproj index cf86a5a9bb..a85d468ce9 100644 --- a/app/Madeira.xcodeproj/project.pbxproj +++ b/app/Madeira.xcodeproj/project.pbxproj @@ -47,6 +47,7 @@ A1000903 /* LiquidMetalSkin.metal in Sources */ = {isa = PBXBuildFile; fileRef = A2000903 /* LiquidMetalSkin.metal */; }; A1000904 /* AmbientGlow.metal in Sources */ = {isa = PBXBuildFile; fileRef = A2000904 /* AmbientGlow.metal */; }; A1000601 /* SteamOwnedLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2000601 /* SteamOwnedLibrary.swift */; }; + A1F0A002 /* DockFriends.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2F0A002 /* DockFriends.swift */; }; A1000700 /* SteamCloud.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2000700 /* SteamCloud.swift */; }; A1000920 /* ExternalDrives.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2000920 /* ExternalDrives.swift */; }; A1000921 /* ExternalStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2000921 /* ExternalStorage.swift */; }; @@ -326,6 +327,7 @@ A2000903 /* LiquidMetalSkin.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = "LiquidMetalSkin.metal"; sourceTree = ""; }; A2000904 /* AmbientGlow.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = "AmbientGlow.metal"; sourceTree = ""; }; A2000601 /* SteamOwnedLibrary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SteamOwnedLibrary.swift"; sourceTree = ""; }; + A2F0A002 /* DockFriends.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DockFriends.swift"; sourceTree = ""; }; A2000700 /* SteamCloud.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SteamCloud.swift"; sourceTree = ""; }; A2000920 /* ExternalDrives.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ExternalDrives.swift"; sourceTree = ""; }; A2000921 /* ExternalStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ExternalStorage.swift"; sourceTree = ""; }; @@ -652,6 +654,7 @@ A2000903 /* LiquidMetalSkin.metal */, A2000904 /* AmbientGlow.metal */, A2000601 /* SteamOwnedLibrary.swift */, + A2F0A002 /* DockFriends.swift */, A2000700 /* SteamCloud.swift */, A2000920 /* ExternalDrives.swift */, A2000921 /* ExternalStorage.swift */, @@ -1121,6 +1124,7 @@ A1000903 /* LiquidMetalSkin.metal in Sources */, A1000904 /* AmbientGlow.metal in Sources */, A1000601 /* SteamOwnedLibrary.swift in Sources */, + A1F0A002 /* DockFriends.swift in Sources */, A1000700 /* SteamCloud.swift in Sources */, A1000920 /* ExternalDrives.swift in Sources */, A1000921 /* ExternalStorage.swift in Sources */, diff --git a/app/Madeira/DockFriends.swift b/app/Madeira/DockFriends.swift new file mode 100644 index 0000000000..21289744a0 --- /dev/null +++ b/app/Madeira/DockFriends.swift @@ -0,0 +1,306 @@ +import Foundation +import SwiftUI + +/// The friends list and Invite/Join for a running Madeira Dock session (the +/// in-game menu's Friends page). Dock writes the list to C:\madeira-friends.bin +/// and reads one command at a time from C:\madeira-friends-cmd.bin; both +/// formats are in the madeira-dock README, "Friends". SteamIDs and names stay +/// on the device: logs carry counts and result codes only. +@MainActor final class DockFriends: ObservableObject { + static let shared = DockFriends() + + enum Action: UInt8 { case invite = 1, join = 2, setStatus = 3 } + + struct Friend: Equatable { + let steamID: UInt64 + let name: String + /// Feed flags: 1 in game, 2 this game, 4 joinable, 8 invited this player, 16 you have a lobby or connect string (Invite is offered). + let dockFlags: UInt8 + /// Steam persona state (0 offline, 1 online, 2 busy, 3 away, ...). + var state: UInt32 = 0 + var appID: UInt32 = 0 + } + + struct Pending: Equatable { + let action: Action + let steamID: UInt64 + let sequence: UInt32 + } + + /// The feed's limits (madeira-dock src/friends_format.h). + nonisolated static let feedMax = 250 + nonisolated static let nameCap = 64 + nonisolated static let feedCap = 12 + feedMax * (18 + nameCap) + /// Dock rewrites the feed every 3 s while the game runs. An older feed is + /// one a host left behind when it did not end cleanly (a killed Wine + /// process), so it is not shown. + nonisolated static let feedMaxAge: TimeInterval = 15 + /// A command Dock has not answered in this time ends as "No answer from Steam". + nonisolated static let commandTimeout: TimeInterval = 10 + /// The most of the report read for a command's answer: only what Dock wrote + /// after the command was sent. + nonisolated static let resultReadCap = 1 << 16 + + /// C:\madeira-friends.bin: magic MFRND001, count, then per friend + /// SteamID(8) state(4) App ID(4) flags(1) name length(1) name. + nonisolated static func parseFeed(_ data: Data) -> [Friend]? { + let bytes = [UInt8](data) + guard bytes.count >= 12, bytes.count <= feedCap, + Array(bytes[0..<8]) == Array("MFRND001".utf8) else { return nil } + func u32(_ at: Int) -> UInt32 { (0..<4).reduce(0) { $0 | UInt32(bytes[at + $1]) << (8 * $1) } } + func u64(_ at: Int) -> UInt64 { (0..<8).reduce(0) { $0 | UInt64(bytes[at + $1]) << (8 * $1) } } + let count = Int(u32(8)) + guard count <= feedMax else { return nil } + var at = 12, result: [Friend] = [] + for _ in 0.. [Friend]? { + guard let modified = (try? FileManager.default.attributesOfItem(atPath: url.path))?[.modificationDate] as? Date, + now.timeIntervalSince(modified) <= feedMaxAge, + let file = try? FileHandle(forReadingFrom: url) else { return nil } + defer { try? file.close() } + guard let data = try? file.read(upToCount: feedCap + 1), data.count <= feedCap, + let friends = parseFeed(data) else { return nil } + return ordered(friends) + } + + /// Invites first, then joinable friends in this game, this game, other games, online, offline; by name within each. + nonisolated static func ordered(_ friends: [Friend]) -> [Friend] { + func rank(_ f: Friend) -> Int { + if f.dockFlags & 8 != 0 { return 0 } + if f.dockFlags & 4 != 0 { return 1 } + if f.dockFlags & 2 != 0 { return 2 } + if f.dockFlags & 1 != 0 { return 3 } + return f.state > 0 ? 4 : 5 + } + return friends.sorted { rank($0) != rank($1) ? rank($0) < rank($1) + : $0.name.localizedCaseInsensitiveCompare($1.name) == .orderedAscending } + } + + /// C:\madeira-friends-cmd.bin: magic MFCMD001, action(1), SteamID or status(8), sequence(4). + nonisolated static func command(_ action: Action, id: UInt64, sequence: UInt32) -> Data { + var bytes = [UInt8]("MFCMD001".utf8) + bytes.append(action.rawValue) + for i in 0..<8 { bytes.append(UInt8(truncatingIfNeeded: id >> (8 * UInt64(i)))) } + for i in 0..<4 { bytes.append(UInt8(truncatingIfNeeded: sequence >> (8 * UInt32(i)))) } + return Data(bytes) + } + + /// Sequences stay in 1...2^31-1: Dock reports friends-cmd-seq as a signed + /// 32-bit number, so a larger one would never match. + nonisolated static func nextSequence(after sequence: UInt32) -> UInt32 { + let next = (sequence &+ 1) & 0x7fff_ffff + return next == 0 ? 1 : next + } + + /// The friends-cmd-result Dock reported after friends-cmd-seq=`sequence` + /// in `data` (report lines, CRLF), or nil. A partial final line is ignored + /// until Dock finishes it. + nonisolated static func commandResult(in data: Data, sequence: UInt32) -> Int? { + let text = String(decoding: data, as: UTF8.self) + var lines = text.split(whereSeparator: \.isNewline) + if let last = text.last, !last.isNewline, !lines.isEmpty { lines.removeLast() } + func value(_ line: Substring, _ key: String) -> Int? { + guard let range = line.range(of: " " + key + "=") else { return nil } + return Int(line[range.upperBound...].trimmingCharacters(in: .whitespaces)) + } + var seen = false + for line in lines { + if let seq = value(line, "friends-cmd-seq") { seen = seq == Int(sequence) } + else if seen, let result = value(line, "friends-cmd-result") { return result } + } + return nil + } + + @Published private(set) var friends: [DockFriends.Friend] = [] + /// Dock is running with friends available (a current, valid feed). + @Published private(set) var available = false + @Published private(set) var pending: Pending? + /// The last finished command, for the row that sent it. + @Published private(set) var outcome: (steamID: UInt64, action: Action, result: Int)? + + private var sequence = UInt32(truncatingIfNeeded: Int(Date().timeIntervalSince1970)) & 0x7fff_ffff + private var sentAt = Date.distantPast + /// The report's size when the pending command was sent: its answer comes after. + private var reportOffset: UInt64 = 0 + private var lastSequence: UInt32 = 0 + + private var feedURL: URL { MadeiraDock.drive.appendingPathComponent("madeira-friends.bin") } + private var commandURL: URL { MadeiraDock.drive.appendingPathComponent("madeira-friends-cmd.bin") } + private var reportURL: URL { MadeiraDock.drive.appendingPathComponent("madeira-dock.txt") } + + /// Re-reads the feed and the pending command's result. A missing, stale or + /// invalid feed empties the list and makes friends unavailable. + func refresh(now: Date = Date()) { + let feed = DockFriends.readFeed(at: feedURL, now: now) + let list = feed ?? [] + if available != (feed != nil) { available = feed != nil } + if friends != list { friends = list } + if let pending { checkResult(pending, now: now) } + } + + /// Changes the status in a running session. Offline is not offered: it is + /// chosen before launch and turns friends off for the session. + func setStatus(_ status: SteamOnlineStatus, now: Date = Date()) { + guard status != .offline else { return } + if send(.setStatus, id: UInt64(status.rawValue), now: now) { SteamOnlineStatus.current = status } + } + + func send(_ action: Action, to friend: DockFriends.Friend, now: Date = Date()) { send(action, id: friend.steamID, now: now) } + + @discardableResult + private func send(_ action: Action, id: UInt64, now: Date) -> Bool { + guard pending == nil, available else { return false } + sequence = DockFriends.nextSequence(after: sequence) + let offset = (try? FileManager.default.attributesOfItem(atPath: reportURL.path))?[.size] as? UInt64 ?? 0 + do { + try DockFriends.command(action, id: id, sequence: sequence).write(to: commandURL, options: .atomic) + } catch { + SteamLog.event("[dock-friends] command not written") + outcome = (id, action, 6) + return false + } + pending = Pending(action: action, steamID: id, sequence: sequence) + sentAt = now + reportOffset = offset + outcome = nil + SteamLog.event("[dock-friends] \(action) sent") + return true + } + + /// Dock answers with friends-cmd-seq (this command's sequence), then + /// friends-cmd-result; without an answer in commandTimeout the command lapses. + private func checkResult(_ pending: Pending, now: Date) { + if let file = try? FileHandle(forReadingFrom: reportURL) { + defer { try? file.close() } + // A shorter report is a new one (a new session): read it from the start. + if let end = try? file.seekToEnd(), end < reportOffset { reportOffset = 0 } + if (try? file.seek(toOffset: reportOffset)) != nil, + let data = try? file.read(upToCount: DockFriends.resultReadCap), + let result = DockFriends.commandResult(in: data, sequence: pending.sequence) { + finish(pending, result: result) + return + } + } + if now.timeIntervalSince(sentAt) > DockFriends.commandTimeout { finish(pending, result: 0) } + } + + private func finish(_ pending: Pending, result: Int) { + self.pending = nil + outcome = (pending.steamID, pending.action, result) + SteamLog.event("[dock-friends] \(pending.action) result=\(result)") + // The row shows the result for a few seconds, then its status again. + let sequence = pending.sequence + lastSequence = sequence + Task { @MainActor in + try? await Task.sleep(for: .seconds(5)) + if self.pending == nil, self.lastSequence == sequence { self.outcome = nil } + } + } + + /// Clears the state (a new Dock session starts, or one ended). + func reset() { + if !friends.isEmpty { friends = [] } + if available { available = false } + pending = nil + outcome = nil + sentAt = .distantPast + reportOffset = 0 + } + + /// A Dock session ended (or the app starts, or Steam signed out): removes + /// the feed and any unread command, so no later session, Dock or not, + /// shows an old list or answers an old command. + func endSession() { + for name in ["madeira-friends.bin", "madeira-friends.tmp", "madeira-friends-cmd.bin", "madeira-friends-cmd.taken"] { + try? FileManager.default.removeItem(at: MadeiraDock.drive.appendingPathComponent(name)) + } + reset() + } + + nonisolated static func message(action: Action, result: Int) -> String { + switch result { + // Join hands the lobby to the game; whether the game gets in is up to it. + case 1: return action == .invite ? L("Invite sent") : action == .setStatus ? L("Status changed") : L("Sent to the game") + case 2: return action == .invite ? L("Nothing to invite to yet: join or create a lobby") : L("Not in a joinable lobby") + case 3: return L("Not on your friends list") + case 4: return L("Steam refused the request") + case 0: return L("No answer from Steam") + default: return L("Friends are unavailable") + } + } +} + +extension SteamOnlineStatus { + var title: String { + switch self { + case .online: return L("Online") + case .away: return L("Away") + case .invisible: return L("Invisible") + case .offline: return L("Offline") + } + } +} + +struct DockFriendRow: View { + let friend: DockFriends.Friend + @ObservedObject var model: DockFriends + + private var status: String { + if friend.dockFlags & 8 != 0 { return L("Invited you to play") } + if friend.dockFlags & 4 != 0 { return L("In this game · joinable") } + if friend.dockFlags & 2 != 0 { return L("In this game") } + if friend.dockFlags & 1 != 0 { return L("In another game") } + switch friend.state { + case 0: return L("Offline") + case 2: return L("Busy") + case 3, 4: return L("Away") + default: return L("Online") + } + } + + var body: some View { + HStack(spacing: 12) { + Circle().fill(friend.dockFlags & 8 != 0 ? Color.yellow : friend.dockFlags & 3 != 0 ? Color.green : friend.state > 0 ? Color.blue : Color.gray) + .frame(width: 10, height: 10) + VStack(alignment: .leading, spacing: 2) { + Text(friend.name.isEmpty ? L("Unknown") : friend.name).lineLimit(1) + if let outcome = model.outcome, outcome.steamID == friend.steamID { + Text(DockFriends.message(action: outcome.action, result: outcome.result)) + .font(.caption).foregroundStyle(outcome.result == 1 ? .green : .orange) + } else { + Text(status).font(.caption).foregroundStyle(.secondary) + } + } + Spacer() + if model.pending?.steamID == friend.steamID { + ProgressView() + } else { + if friend.dockFlags & 8 != 0 { + Button("Accept") { model.send(.join, to: friend) } + .buttonStyle(.borderedProminent).disabled(model.pending != nil) + } else if friend.dockFlags & 4 != 0 { + Button("Join") { model.send(.join, to: friend) } + .buttonStyle(.borderedProminent).disabled(model.pending != nil) + } + // Like desktop Steam: Invite only while you have a lobby or connect string to invite with (feed flag 16). + if friend.state > 0, friend.dockFlags & 16 != 0 { + Button("Invite") { model.send(.invite, to: friend) }.buttonStyle(.bordered) + .disabled(model.pending != nil) + } + } + } + .frame(minHeight: 44) + } +} diff --git a/app/Madeira/Library.swift b/app/Madeira/Library.swift index 651c0d2515..534a2bf447 100644 --- a/app/Madeira/Library.swift +++ b/app/Madeira/Library.swift @@ -5608,6 +5608,11 @@ struct LibraryHUD: View { /// The Session menu's Controller binds page (keyboard-and-mouse mode). @State private var bindsPage = false @State private var assistPage = false + /// The Session menu's Friends page (Madeira Dock sessions). + @State private var friendsPage = false + /// The status shown on the Friends page; Offline never reaches here (friends are off for that session). + @State private var steamStatus = SteamOnlineStatus.current + @ObservedObject private var dockFriends = DockFriends.shared @Environment(\.accessibilityReduceMotion) private var reduceMotion var body: some View { GeometryReader { geo in @@ -5634,7 +5639,7 @@ struct LibraryHUD: View { if !model.startingScreen { LibraryFloatingItem(isMenu: true, viewport: geo.size, insets: geo.safeAreaInsets) } if model.menu { Color.black.opacity(SessionMenuBackground.blur ? 0.3 : 0.5).ignoresSafeArea().onTapGesture { model.menu = false }.transition(.opacity) - (bindsPage ? AnyView(bindsMenu) : assistPage ? AnyView(assistMenu) : AnyView(menu)) + (bindsPage ? AnyView(bindsMenu) : assistPage ? AnyView(assistMenu) : friendsPage ? AnyView(friendsMenu) : AnyView(menu)) .frame(width: min(460, geo.size.width - 32), height: min(650, geo.size.height - geo.safeAreaInsets.top - geo.safeAreaInsets.bottom - 24)) .modifier(SessionMenuBackground()) .clipShape(RoundedRectangle(cornerRadius: 28)) @@ -5671,7 +5676,8 @@ struct LibraryHUD: View { .onAppear { model.saveCurrentProfile() } .onChange(of: model.menu) { _, open in LibraryController.shared.configure(enabled: model.enabled, ownsInput: open) - if !open { bindsPage = false; assistPage = false } + if !open { bindsPage = false; assistPage = false; friendsPage = false } + if open { dockFriends.refresh() } if !open { model.saveCurrentProfile() } if open { eco = madeira_get_eco() != 0; fenceMode = FPSOverlayFenceMode.current } } @@ -5945,6 +5951,43 @@ struct LibraryHUD: View { } } + /// Friends from the running Madeira Dock session: Join a friend's lobby in + /// this game, or Invite a friend (to this player's lobby when in one). + private var friendsMenu: some View { + VStack(spacing: 0) { + HStack { + Button("Session", systemImage: "chevron.left") { friendsPage = false }.buttonStyle(.borderless) + Spacer() + Text("Friends").font(.headline) + Spacer() + Button("Done") { model.menu = false }.buttonStyle(.bordered) + }.padding(.horizontal, 22).padding(.top, 22).padding(.bottom, 8) + Picker("Status", selection: Binding(get: { steamStatus }, set: { steamStatus = $0; dockFriends.setStatus($0) })) { + ForEach(SteamOnlineStatus.allCases.filter { $0 != .offline }) { Text($0.title).tag($0) } + } + .pickerStyle(.segmented).padding(.horizontal, 22).padding(.bottom, 8) + .disabled(dockFriends.pending != nil || !dockFriends.available) + if dockFriends.friends.isEmpty { + Spacer() + Group { + if dockFriends.available { Text("No friends yet") } else { Text("Friends are available while the game runs") } + } + .foregroundStyle(.secondary) + Spacer() + } else { + List(dockFriends.friends, id: \.steamID) { friend in + DockFriendRow(friend: friend, model: dockFriends) + }.scrollContentBackground(.hidden) + } + } + .task { + while !Task.isCancelled { + dockFriends.refresh() + try? await Task.sleep(for: .seconds(dockFriends.pending == nil ? 3 : 0.5)) + } + } + } + private var menu: some View { ScrollView { VStack(alignment: .leading, spacing: 18) { @@ -5982,6 +6025,9 @@ struct LibraryHUD: View { Button("Gyro aim & turbo", systemImage: "gyroscope") { assistPage = true } } Button("Keyboard", systemImage: "keyboard") { model.menu = false; LibraryKeyboard.show() } + if dockFriends.available { + Button("Friends", systemImage: "person.2") { steamStatus = SteamOnlineStatus.current; friendsPage = true } + } Divider() FPSChoice(mode: Binding(get: { model.fpsMode }, set: { model.setFPS($0) })) // Saved to the game with the rest of the session's profile. diff --git a/app/Madeira/Localizable.xcstrings b/app/Madeira/Localizable.xcstrings index 25536bad4f..98841959e1 100644 --- a/app/Madeira/Localizable.xcstrings +++ b/app/Madeira/Localizable.xcstrings @@ -1001,6 +1001,46 @@ } } }, + "Accept": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Annehmen" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Aceptar" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "수락" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Aceitar" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Принять" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "接受" + } + } + } + }, "Achievements and stats": { "localizations": { "de": { @@ -2441,6 +2481,46 @@ } } }, + "Away": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Abwesend" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Ausente" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "자리 비움" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Ausente" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Нет на месте" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "离开" + } + } + } + }, "Back up saves": { "localizations": { "de": { @@ -2801,6 +2881,46 @@ } } }, + "Busy": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Beschäftigt" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Ocupado" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "다른 용무 중" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Ocupado" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Занят" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "忙碌" + } + } + } + }, "Buy": { "localizations": { "de": { @@ -9081,6 +9201,126 @@ } } }, + "Friends": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Freunde" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Amigos" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "친구" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Amigos" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Друзья" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "好友" + } + } + } + }, + "Friends are available while the game runs": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Freunde sind verfügbar, solange das Spiel läuft" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Los amigos están disponibles mientras el juego está en marcha" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "친구 목록은 게임이 실행 중일 때 사용할 수 있습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Os amigos ficam disponíveis enquanto o jogo está em execução" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Друзья доступны, пока игра запущена" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "游戏运行时可使用好友功能" + } + } + } + }, + "Friends are unavailable": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Freunde sind nicht verfügbar" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Los amigos no están disponibles" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "친구 기능을 사용할 수 없습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Os amigos não estão disponíveis" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Друзья недоступны" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "好友功能不可用" + } + } + } + }, "From Steam's launch settings, with its arguments.": { "localizations": { "de": { @@ -10481,224 +10721,344 @@ } } }, - "In sync": { + "In another game": { "localizations": { "de": { "stringUnit": { "state": "translated", - "value": "Synchron" + "value": "In einem anderen Spiel" } }, "es": { "stringUnit": { "state": "translated", - "value": "Sincronizado" + "value": "En otro juego" } }, "ko": { "stringUnit": { "state": "translated", - "value": "동기화됨" + "value": "다른 게임 중" } }, "pt-BR": { "stringUnit": { "state": "translated", - "value": "Sincronizado" + "value": "Em outro jogo" } }, "ru": { "stringUnit": { "state": "translated", - "value": "Синхронизировано" + "value": "В другой игре" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "已同步" + "value": "在玩其他游戏" } } } }, - "In the Wine desktop": { + "In sync": { "localizations": { "de": { "stringUnit": { "state": "translated", - "value": "Im Wine-Desktop" + "value": "Synchron" } }, "es": { "stringUnit": { "state": "translated", - "value": "En el escritorio de Wine" + "value": "Sincronizado" } }, "ko": { "stringUnit": { "state": "translated", - "value": "Wine 데스크톱에서" + "value": "동기화됨" } }, "pt-BR": { "stringUnit": { "state": "translated", - "value": "Na área de trabalho do Wine" + "value": "Sincronizado" } }, "ru": { "stringUnit": { "state": "translated", - "value": "В рабочем столе Wine" + "value": "Синхронизировано" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "在 Wine 桌面中" + "value": "已同步" } } } }, - "Install %@ to download its Workshop items.": { + "In the Wine desktop": { "localizations": { "de": { "stringUnit": { "state": "translated", - "value": "Installiere %1$@, um seine Workshop-Objekte zu laden." + "value": "Im Wine-Desktop" } }, "es": { "stringUnit": { "state": "translated", - "value": "Instala %1$@ para descargar sus elementos del Workshop." + "value": "En el escritorio de Wine" } }, "ko": { "stringUnit": { "state": "translated", - "value": "창작마당 항목을 다운로드하려면 %1$@을(를) 설치하세요." + "value": "Wine 데스크톱에서" } }, "pt-BR": { "stringUnit": { "state": "translated", - "value": "Instale %1$@ para baixar os itens do Workshop dele." + "value": "Na área de trabalho do Wine" } }, "ru": { "stringUnit": { "state": "translated", - "value": "Установите %1$@, чтобы скачать предметы из Мастерской." + "value": "В рабочем столе Wine" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "安装%1$@才能下载它的创意工坊内容。" + "value": "在 Wine 桌面中" } } } }, - "Install Location": { + "In this game": { "localizations": { "de": { "stringUnit": { "state": "translated", - "value": "Installationsort" + "value": "In diesem Spiel" } }, "es": { "stringUnit": { "state": "translated", - "value": "Ubicación de instalación" + "value": "En este juego" } }, "ko": { "stringUnit": { "state": "translated", - "value": "설치 위치" + "value": "이 게임 중" } }, "pt-BR": { "stringUnit": { "state": "translated", - "value": "Local de instalação" + "value": "Neste jogo" } }, "ru": { "stringUnit": { "state": "translated", - "value": "Место установки" + "value": "В этой игре" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "安装位置" + "value": "在玩此游戏" } } } }, - "Install Steam games on": { + "In this game · joinable": { "localizations": { "de": { "stringUnit": { "state": "translated", - "value": "Steam-Spiele installieren auf" + "value": "In diesem Spiel · beitretbar" } }, "es": { "stringUnit": { "state": "translated", - "value": "Instalar juegos de Steam en" + "value": "En este juego · se puede unir" } }, "ko": { "stringUnit": { "state": "translated", - "value": "Steam 게임 설치 위치" + "value": "이 게임 중 · 참가 가능" } }, "pt-BR": { "stringUnit": { "state": "translated", - "value": "Instalar jogos da Steam em" + "value": "Neste jogo · é possível entrar" } }, "ru": { "stringUnit": { "state": "translated", - "value": "Устанавливать игры Steam на" + "value": "В этой игре · можно присоединиться" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "Steam 游戏安装到" + "value": "在玩此游戏 · 可加入" } } } }, - "Install StikDebug": { + "Install %@ to download its Workshop items.": { "localizations": { "de": { "stringUnit": { "state": "translated", - "value": "StikDebug installieren" + "value": "Installiere %1$@, um seine Workshop-Objekte zu laden." } }, "es": { "stringUnit": { "state": "translated", - "value": "Instalar StikDebug" + "value": "Instala %1$@ para descargar sus elementos del Workshop." } }, "ko": { "stringUnit": { "state": "translated", - "value": "StikDebug 설치" + "value": "창작마당 항목을 다운로드하려면 %1$@을(를) 설치하세요." + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Instale %1$@ para baixar os itens do Workshop dele." + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Установите %1$@, чтобы скачать предметы из Мастерской." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "安装%1$@才能下载它的创意工坊内容。" + } + } + } + }, + "Install Location": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Installationsort" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Ubicación de instalación" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "설치 위치" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Local de instalação" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Место установки" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "安装位置" + } + } + } + }, + "Install Steam games on": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Steam-Spiele installieren auf" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Instalar juegos de Steam en" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "Steam 게임 설치 위치" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Instalar jogos da Steam em" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Устанавливать игры Steam на" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "Steam 游戏安装到" + } + } + } + }, + "Install StikDebug": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "StikDebug installieren" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Instalar StikDebug" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "StikDebug 설치" } }, "pt-BR": { @@ -11281,6 +11641,166 @@ } } }, + "Invisible": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Unsichtbar" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Invisible" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "보이지 않음" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Invisível" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Невидимка" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "隐身" + } + } + } + }, + "Invite": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Einladen" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Invitar" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "초대" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Convidar" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Пригласить" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "邀请" + } + } + } + }, + "Invite sent": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Einladung gesendet" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Invitación enviada" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "초대를 보냈습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Convite enviado" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Приглашение отправлено" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "邀请已发送" + } + } + } + }, + "Invited you to play": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Hat dich zum Spielen eingeladen" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Te ha invitado a jugar" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "함께 플레이하자고 초대했습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Convidou você para jogar" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Приглашает вас в игру" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "邀请你一起玩" + } + } + } + }, "Items download from Steam with your account into Steam's Workshop folder beside the game, so the game finds them when it starts through Madeira Dock. Subscriptions are your Steam account's, the same as on a PC.": { "localizations": { "de": { @@ -11681,6 +12201,46 @@ } } }, + "Join": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Beitreten" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Unirse" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "참가" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Entrar" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Присоединиться" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "加入" + } + } + } + }, "Keep Epic's saves…": { "localizations": { "de": { @@ -14601,6 +15161,86 @@ } } }, + "No answer from Steam": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Keine Antwort von Steam" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Steam no ha respondido" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "Steam에서 응답이 없습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Sem resposta do Steam" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Нет ответа от Steam" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "Steam 没有响应" + } + } + } + }, + "No friends yet": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Noch keine Freunde" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Aún no hay amigos" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "아직 친구가 없습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Ainda não há amigos" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Пока нет друзей" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "还没有好友" + } + } + } + }, "No Steam games are installed yet.": { "localizations": { "de": { @@ -15401,6 +16041,46 @@ } } }, + "Not in a joinable lobby": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Nicht in einer beitretbaren Lobby" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "No está en una sala a la que unirse" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "참가할 수 있는 로비에 없습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Não está em um lobby em que se possa entrar" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Не в лобби, к которому можно присоединиться" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "不在可加入的大厅中" + } + } + } + }, "Not installed": { "localizations": { "de": { @@ -15441,6 +16121,46 @@ } } }, + "Not on your friends list": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Nicht in deiner Freundesliste" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "No está en tu lista de amigos" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "친구 목록에 없습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Não está na sua lista de amigos" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Нет в вашем списке друзей" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "不在你的好友列表中" + } + } + } + }, "Not present": { "localizations": { "de": { @@ -15716,87 +16436,167 @@ "zh-Hans": { "stringUnit": { "state": "translated", - "value": "在你选择保留哪一个之前,不会改动任何内容。" + "value": "在你选择保留哪一个之前,不会改动任何内容。" + } + } + } + }, + "Nothing to invite to yet: join or create a lobby": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Noch nichts, wozu du einladen kannst: Tritt einer Lobby bei oder erstelle eine" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Aún no hay nada a lo que invitar: únete a una sala o crea una" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "아직 초대할 곳이 없습니다: 로비에 참가하거나 로비를 만드세요" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Ainda não há para onde convidar: entre em um lobby ou crie um" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Пока некуда пригласить: присоединитесь к лобби или создайте его" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "暂时没有可邀请加入的内容:请加入或创建一个大厅" + } + } + } + }, + "Numbers": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Zahlen" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Números" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "숫자" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Números" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Цифры" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "数字" } } } }, - "Numbers": { + "Numpad": { "localizations": { "de": { "stringUnit": { "state": "translated", - "value": "Zahlen" + "value": "Ziffernblock" } }, "es": { "stringUnit": { "state": "translated", - "value": "Números" + "value": "Teclado numérico" } }, "ko": { "stringUnit": { "state": "translated", - "value": "숫자" + "value": "숫자 패드" } }, "pt-BR": { "stringUnit": { "state": "translated", - "value": "Números" + "value": "Teclado numérico" } }, "ru": { "stringUnit": { "state": "translated", - "value": "Цифры" + "value": "Цифровой блок" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "数字" + "value": "小键盘" } } } }, - "Numpad": { + "Offline": { "localizations": { "de": { "stringUnit": { "state": "translated", - "value": "Ziffernblock" + "value": "Offline" } }, "es": { "stringUnit": { "state": "translated", - "value": "Teclado numérico" + "value": "Desconectado" } }, "ko": { "stringUnit": { "state": "translated", - "value": "숫자 패드" + "value": "오프라인" } }, "pt-BR": { "stringUnit": { "state": "translated", - "value": "Teclado numérico" + "value": "Offline" } }, "ru": { "stringUnit": { "state": "translated", - "value": "Цифровой блок" + "value": "Не в сети" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "小键盘" + "value": "离线" } } } @@ -16161,6 +16961,46 @@ } } }, + "Online": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Online" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Conectado" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "온라인" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Online" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "В сети" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "在线" + } + } + } + }, "Only x86 and x64 executables are supported.": { "localizations": { "de": { @@ -21081,6 +21921,46 @@ } } }, + "Sent to the game": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "An das Spiel übergeben" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Enviado al juego" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "게임에 전달했습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Enviado ao jogo" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Передано игре" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "已交给游戏" + } + } + } + }, "Session": { "localizations": { "de": { @@ -23441,6 +24321,126 @@ } } }, + "Status": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Status" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Estado" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "상태" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Status" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Статус" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "状态" + } + } + } + }, + "Status changed": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Status geändert" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Estado cambiado" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "상태를 변경했습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Status alterado" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Статус изменён" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "状态已更改" + } + } + } + }, + "Status: what Steam friends see while a game runs through Madeira Dock. Offline, the default, leaves Friends off, as before: no friends list or invites in the game. Online, Away or Invisible signs in to Friends for the game the way desktop Steam's Friends window does, with the same status messages to Steam, and the Madeira menu then has a Friends page where the status can also be changed.": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Status: Was Steam-Freunde sehen, während ein Spiel über Madeira Dock läuft. Offline, die Voreinstellung, lässt Freunde wie bisher aus: keine Freundesliste und keine Einladungen im Spiel. Online, Abwesend oder Unsichtbar meldet dich für das Spiel bei Freunde an, so wie es das Freundesfenster von Steam auf dem Desktop tut, mit denselben Statusnachrichten an Steam, und das Madeira-Menü hat dann eine Seite „Freunde“, auf der sich der Status auch ändern lässt." + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Estado: lo que ven tus amigos de Steam mientras un juego se ejecuta con Madeira Dock. Desconectado, la opción predeterminada, deja Amigos desactivado, como hasta ahora: sin lista de amigos ni invitaciones en el juego. Conectado, Ausente o Invisible inicia sesión en Amigos para el juego como lo hace la ventana de amigos de Steam en el escritorio, con los mismos mensajes de estado a Steam, y el menú de Madeira tiene entonces una página Amigos donde también se puede cambiar el estado." + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "상태: Madeira Dock으로 게임을 실행하는 동안 Steam 친구에게 보이는 상태입니다. 기본값인 오프라인은 지금처럼 친구 기능을 끈 채로 둡니다: 게임 안에서 친구 목록과 초대를 쓸 수 없습니다. 온라인, 자리 비움 또는 보이지 않음은 데스크톱 Steam의 친구 창과 같은 방식으로, 같은 상태 메시지를 Steam에 보내 게임 동안 친구에 로그인합니다. 그러면 Madeira 메뉴에 친구 페이지가 생기고, 거기서도 상태를 바꿀 수 있습니다." + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Status: o que os amigos do Steam veem enquanto um jogo é executado pelo Madeira Dock. Offline, o padrão, deixa os Amigos desligados, como antes: sem lista de amigos nem convites no jogo. Online, Ausente ou Invisível entra nos Amigos durante o jogo do mesmo jeito que a janela de amigos do Steam no computador, com as mesmas mensagens de status para o Steam, e o menu do Madeira passa a ter uma página Amigos onde o status também pode ser alterado." + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Статус: что видят друзья в Steam, пока игра запущена через Madeira Dock. «Не в сети», вариант по умолчанию, оставляет друзей выключенными, как раньше: в игре нет списка друзей и приглашений. «В сети», «Нет на месте» или «Невидимка» входит в друзья на время игры так же, как окно друзей настольного Steam, с теми же сообщениями о статусе для Steam, и тогда в меню Madeira появляется страница «Друзья», где статус тоже можно изменить." + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "状态:通过 Madeira Dock 运行游戏时 Steam 好友看到的状态。默认的“离线”会像以前一样关闭好友功能:游戏中没有好友列表和邀请。“在线”“离开”或“隐身”会像桌面版 Steam 的好友窗口那样,在游戏期间登录好友,并向 Steam 发送相同的状态消息;之后 Madeira 菜单中会出现“好友”页面,也可以在那里更改状态。" + } + } + } + }, "Steam": { "localizations": { "de": { @@ -23561,6 +24561,46 @@ } } }, + "Steam refused the request": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Steam hat die Anfrage abgelehnt" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Steam ha rechazado la solicitud" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "Steam에서 요청을 거부했습니다" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "O Steam recusou a solicitação" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Steam отклонил запрос" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "Steam 拒绝了请求" + } + } + } + }, "Steam Testing": { "localizations": { "de": { @@ -27041,6 +28081,46 @@ } } }, + "Unknown": { + "localizations": { + "de": { + "stringUnit": { + "state": "translated", + "value": "Unbekannt" + } + }, + "es": { + "stringUnit": { + "state": "translated", + "value": "Desconocido" + } + }, + "ko": { + "stringUnit": { + "state": "translated", + "value": "알 수 없음" + } + }, + "pt-BR": { + "stringUnit": { + "state": "translated", + "value": "Desconhecido" + } + }, + "ru": { + "stringUnit": { + "state": "translated", + "value": "Неизвестно" + } + }, + "zh-Hans": { + "stringUnit": { + "state": "translated", + "value": "未知" + } + } + } + }, "Unsubscribe": { "localizations": { "de": { diff --git a/app/Madeira/MadeiraDock.swift b/app/Madeira/MadeiraDock.swift index a07bcb6455..b36ea78362 100644 --- a/app/Madeira/MadeiraDock.swift +++ b/app/Madeira/MadeiraDock.swift @@ -340,6 +340,7 @@ enum MadeiraDock { "session-offline-entitled", "session-offline-listed", "session-offline-timeout-state", "session-offline-fallback", "session-offline-ready", "launch-user-arguments-bytes", "launch-user-arguments-invalid", + "launch-game-running", "friends-available", "friends-own-state", "friends-signin-available", "friends-signin", "friends-requested", "friends-own-game", "friends-total", "friends-valid-ids", "friends-named", "friends-playing", "friends-seconds", "friends-count", "friends-cmd-seq", "friends-cmd-result", "launch-client-error", "launch-option-index", "launch-option-invalid", "launch-option-missing", "launch-update-wait", "launch-update-retry", "launch-update-ready", "launch-config-wait", "launch-config-gave-up", "launch-session-wait", "launch-session-gave-up", @@ -351,8 +352,13 @@ enum MadeiraDock { /// The host's report rounds (madeira-dock src/main.c). static let reportRounds: Set = ["ml1820", "ml1830", "ml1860", "ml1870", "ml1970", "ml1990", "ml2000", "ml2011", "ml2015", "ml2016", "ml2020"] + /// The largest report read. Dock bounds its friends lines, but a long session + /// still writes more than the old 32 KB, and a report past the cap would hide + /// probe-result at game end. + static let reportCap = 1 << 20 + static func parseReport(_ data: Data) -> Report { - guard data.count <= 32768, let text = String(data: data, encoding: .utf8) else { return Report() } + guard data.count <= reportCap, let text = String(data: data, encoding: .utf8) else { return Report() } var report = Report() // Ignore a partial final line until the writer completes and flushes it. for line in text.replacingOccurrences(of: "\r\n", with: "\n") @@ -386,7 +392,7 @@ enum MadeiraDock { let url = drive.appendingPathComponent("madeira-dock.txt") guard let file = try? FileHandle(forReadingFrom: url) else { return lastReport } defer { try? file.close() } - guard let data = try? file.read(upToCount: 32769), data.count <= 32768 else { return lastReport } + guard let data = try? file.read(upToCount: reportCap + 1), data.count <= reportCap else { return lastReport } let report = parseReport(data) for key in report.fields.keys.sorted() where report.fields[key] != lastReport.fields[key] { SteamLog.event("[dock-report] \(key)=\(report.fields[key]!)") @@ -415,6 +421,9 @@ enum MadeiraDock { if let url = transferURL { try? FileManager.default.removeItem(at: url) } unsetenv("MADEIRA_DOCK_AUTH_FILE") unsetenv("MADEIRA_DOCK_OFFLINE") + // The friends feed and command too: a host that did not end cleanly + // leaves them, and a later session must not show its list. + DockFriends.shared.endSession() } /// Writes the one-use transfer to protected Application Support storage @@ -455,6 +464,7 @@ enum MadeiraDock { setenv(key, "1", 1) } setenv("MADEIRA_STEAM_HOST_APPID", String(game.id), 1) + setenv("MADEIRA_DOCK_PERSONA_STATE", String(SteamOnlineStatus.current.rawValue), 1) setenv("MADEIRA_STEAM_HOST_LAUNCH_OPTION", String(launchOption), 1) setenv("MADEIRA_STEAM_HOST_CLIENT_DIR", SteamRuntimeFiles.windowsRoot, 1) setenv("MADEIRA_STEAM_HOST_EXPECTED_INSTALL", game.windowsInstallPath, 1) @@ -627,3 +637,17 @@ enum DockOffline { } static let changed = Notification.Name("MadeiraDockOfflineChanged") } + +/// The Steam status Dock signs in to Friends with (Settings › Steam › Status), +/// passed to Dock as MADEIRA_DOCK_PERSONA_STATE; the raw value is Steam's +/// persona state. Offline, the default, leaves Friends off for the session: +/// Dock then sends Steam nothing of its own (madeira-dock README, "Friends"). +enum SteamOnlineStatus: Int, CaseIterable, Identifiable { + case online = 1, away = 3, invisible = 7, offline = 0 + var id: Int { rawValue } + private static let key = "steamOnlineStatus" + static var current: SteamOnlineStatus { + get { (UserDefaults.standard.object(forKey: key) as? Int).flatMap(SteamOnlineStatus.init(rawValue:)) ?? .offline } + set { UserDefaults.standard.set(newValue.rawValue, forKey: key) } + } +} diff --git a/app/Madeira/Onboarding.swift b/app/Madeira/Onboarding.swift index f773044715..9d4020bdf3 100644 --- a/app/Madeira/Onboarding.swift +++ b/app/Madeira/Onboarding.swift @@ -746,6 +746,8 @@ struct SteamSettingsSection: View { @ObservedObject private var onboarding = OnboardingModel.shared @ObservedObject private var cloud = SteamCloudSetting.shared @State private var confirmSignOut = false + /// Settings › Steam › Status (SteamOnlineStatus), shown while signed in. + @State private var status = SteamOnlineStatus.current /// Settings › Steam › Game language (SteamLanguage); "" follows the device. @State private var language = SteamLanguage.chosen ?? "" /// Settings › Steam › Downloads from PCs on this network (SteamLANSetting). @@ -761,6 +763,10 @@ struct SteamSettingsSection: View { if let name = signIn.accountName { LabeledContent("Signed in as", value: name) Button("Sign out of Steam", role: .destructive) { confirmSignOut = true } + Picker("Status", selection: $status) { + ForEach(SteamOnlineStatus.allCases) { Text($0.title).tag($0) } + } + .onChange(of: status) { _, value in SteamOnlineStatus.current = value } } else { Button { open(.steamSignIn) } label: { Label("Sign in to Steam", systemImage: "person.crop.circle.badge.plus") } } @@ -802,7 +808,10 @@ struct SteamSettingsSection: View { } header: { Text("Steam") } footer: { - Text("Game language: the language Steam downloads install, and the one Steam tells the game to use. A game without it gets English. Installed games keep their language until you choose Download in their page.\n\nDownloads from PCs on this network: a game's download comes first from a PC on the same network whose Steam has it installed and up to date, through Steam's local network game transfers (Steam on the PC: same account, Settings › Downloads › Game file transfer over local network on, no download or game running). Anything the PC does not have comes from Steam's servers. Madeira finds the PC through Steam and shows up in the account's devices as \"Madeira\". PC address: only when the PC is not found; its IP address on this network.\n\nMadeira keeps a Steam sign-in token in this device's Keychain, for this device only. Signing out removes it.") + VStack(alignment: .leading, spacing: 12) { + Text("Status: what Steam friends see while a game runs through Madeira Dock. Offline, the default, leaves Friends off, as before: no friends list or invites in the game. Online, Away or Invisible signs in to Friends for the game the way desktop Steam's Friends window does, with the same status messages to Steam, and the Madeira menu then has a Friends page where the status can also be changed.") + Text("Game language: the language Steam downloads install, and the one Steam tells the game to use. A game without it gets English. Installed games keep their language until you choose Download in their page.\n\nDownloads from PCs on this network: a game's download comes first from a PC on the same network whose Steam has it installed and up to date, through Steam's local network game transfers (Steam on the PC: same account, Settings › Downloads › Game file transfer over local network on, no download or game running). Anything the PC does not have comes from Steam's servers. Madeira finds the PC through Steam and shows up in the account's devices as \"Madeira\". PC address: only when the PC is not found; its IP address on this network.\n\nMadeira keeps a Steam sign-in token in this device's Keychain, for this device only. Signing out removes it.") + } } .confirmationDialog("Sign out of Steam?", isPresented: $confirmSignOut, titleVisibility: .visible) { Button("Sign out", role: .destructive) { signIn.signOut() } diff --git a/docs/MADEIRA_DOCK.md b/docs/MADEIRA_DOCK.md index 3e41d6fc71..20c32eeb28 100644 --- a/docs/MADEIRA_DOCK.md +++ b/docs/MADEIRA_DOCK.md @@ -29,8 +29,9 @@ them. ## Source and licence - Source: the `madeira-dock` submodule - (`https://github.com/125hz/madeira-dock`, pinned at `e1bf62f`), about 1,850 lines of - C. Copyright 2026 125hz, **GPL-3.0-or-later with the Madeira + (`https://github.com/willfaust/madeira-dock`, the URL in `.gitmodules`; this + repository pins the commit), in C. + Copyright 2026 125hz, **GPL-3.0-or-later with the Madeira Converter Exception** (the owner open-sourced it on 2026-09-27; it used to be a closed executable). - Research references: OpenSteamworks (MIT) and Valve's public Steamworks @@ -111,8 +112,36 @@ library session. The sheet has: choice" puts the kept launcher back at the next start. Log lines: `[dock-start-program]`. -Tap a game. Dock is started with Steam's default launch option only; custom -arguments are not supported. +Tap a game. Dock is started with the launch entry Madeira picks from Steam's +launch configuration, or key 0 when none can be picked; extra arguments from the +library profile go to Valve's `LaunchApp` through +`MADEIRA_STEAM_HOST_ARGUMENTS` (bounded; see the Dock README). + +**Friends.** Off unless chosen: Settings › Steam › Status is Offline by default, +and Offline (`MADEIRA_DOCK_PERSONA_STATE=0`, or the variable missing) leaves +Friends off for the whole session, as before Friends existed: Dock sends Steam +nothing of its own and the game's menu has no Friends page. Online, Away or +Invisible makes Dock sign in to Friends while the game runs the way desktop +Steam's Friends window does, with the messages that window sends over the +client's own connection (status, persona data for unnamed friends, the +friends-status subscription and lobby invites; Dock README, "Friends"), so +friends see the chosen status and the session receives theirs. Online, Away +and Invisible can also be changed from the Friends page. Dock writes the +friends list to `C:\madeira-friends.bin` every 3 s (online, invited and +same-game friends first when there are more than 250) and accepts commands in +`C:\madeira-friends-cmd.bin` (formats, limits and the `friends-*` report lines +in the Dock README). In a lobby, Invite sends a real lobby invite. Join goes +through the client's own accepted-invite path to the running game. January +client build only; elsewhere `friends-available=0` and the launch is +unchanged. The in-game Session menu's Friends page (`DockFriends.swift`) reads +the feed and sends the commands; incoming lobby invites show at the top with +Accept. A missing, invalid or stale feed (older than 15 s: a host that did not +end cleanly) shows no list, and `MadeiraDock.cleanup()` (session end, app +start, sign-out) removes the feed and any unread command. Tested: sending an +invite, receiving one and joining with it, joining a friend without an invite, +being joined without sending one, and the Offline status turning friends off +(Dock `docs/HANDOFF.md`). Friends' status comes from Dock, not Steam's Web +API: a trial of Web API presence got a refresh token revoked (2026-10-29). ## How a launch works @@ -557,6 +586,12 @@ credentials: - `check-dock-report.py`: the report parser, its messages (including 34), the ordered callback IDs, rejection of private and malformed fields, and that every report round the pinned host writes is accepted. +- `check-dock-friends.py`: the Friends model (`DockFriends.swift` compiled on + the host against a temporary drive): feed bounds, display order, the command + bytes and 31-bit sequences, matching a command to its own result after it + was sent, the timeout, reset and session end, no list from a missing, + invalid or stale feed, no names or SteamIDs in the log, and Offline (friends + off) as the default status. - `check-dock-path.py`: the transfer path through Wine's own path resolver (`WINE_FILE_C` can point at `dlls/ntdll/unix/file.c` when the wine submodule is not checked out). diff --git a/madeira-dock b/madeira-dock index 67780ba92e..9ce5d634fd 160000 --- a/madeira-dock +++ b/madeira-dock @@ -1 +1 @@ -Subproject commit 67780ba92e60dbfac4fe80eaf2ce34b9ea1a1c60 +Subproject commit 9ce5d634fd7c72ad32292d007d533de84beb6a56 diff --git a/tests/host/check-dock-friends.py b/tests/host/check-dock-friends.py new file mode 100644 index 0000000000..287355e690 --- /dev/null +++ b/tests/host/check-dock-friends.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-or-later +# Copyright 2026 125hz +# Madeira Converter Exception: see LICENSE-EXCEPTION.md +"""Compile the app's production Madeira Dock Friends model; synthetic files only. + +Dock writes the friends feed to C:\\madeira-friends.bin and answers commands from +C:\\madeira-friends-cmd.bin with friends-cmd-seq / friends-cmd-result report lines +(madeira-dock README, "Friends"). Checked here, against a temporary drive_c: +feed bounds, the command bytes, matching a command to its own result, the +timeout, reset and session end, and that a missing, invalid or stale feed +leaves no old list behind. No Steam, Wine or device session is used. +""" +from pathlib import Path +import os, re, shutil, subprocess, sys, tempfile + +root = Path(__file__).resolve().parents[2] +app = root / 'app/Madeira' +SWIFTC = os.environ.get('SWIFTC') or shutil.which('swiftc') or str(Path.home() / '.local/share/swiftly/bin/swiftc') +failures = 0 + + +def require(condition, label): + global failures + print(('PASS: ' if condition else 'FAIL: ') + label) + if not condition: + failures += 1 + + +friends = (app / 'DockFriends.swift').read_text() +dock = (app / 'MadeiraDock.swift').read_text() +library = (app / 'Library.swift').read_text() + +# ------------------------------------------------------------------ static +cleanup = dock[dock.index(' @MainActor static func cleanup() {'):] +cleanup = cleanup[:cleanup.index('\n }\n')] +require('DockFriends.shared.endSession()' in cleanup, 'MadeiraDock.cleanup() (session end, app start, sign-out) removes the friends files') +require('dockFriends.available' in library and 'dockFriends.refresh()' in library, 'the Session menu shows Friends only for a current feed') +for line in friends.splitlines(): + if 'SteamLog.' in line: + require(re.search(r'\\\((?:[^)]*\.)?(name|steamID|id|friend|data|url)\b', line) is None, + f'DockFriends.swift: no SteamID, name or path logged in "{line.strip()[:60]}"') +require('setenv("MADEIRA_DOCK_PERSONA_STATE", String(SteamOnlineStatus.current.rawValue), 1)' in dock, + 'the launch passes the chosen status to Dock') + +# ------------------------------------------------------------------ compiled +model = friends[friends.index('@MainActor final class DockFriends'):friends.index('struct DockFriendRow')] +status = dock[dock.index('/// The Steam status Dock signs in to Friends with'):] +stubs = r''' +import Foundation +import Combine +enum MadeiraDock { static var drive = URL(fileURLWithPath: "/nonexistent") } +enum SteamLog { static var events: [String] = []; static func event(_ m: String) { events.append(m) } } +func L(_ text: String) -> String { text } +''' +checks = r''' +let drive = URL(fileURLWithPath: CommandLine.arguments[1], isDirectory: true) +MadeiraDock.drive = drive +let feed = drive.appendingPathComponent("madeira-friends.bin") +let commandFile = drive.appendingPathComponent("madeira-friends-cmd.bin") +let report = drive.appendingPathComponent("madeira-dock.txt") +let fm = FileManager.default + +func le32(_ v: UInt32) -> [UInt8] { (0..<4).map { UInt8(truncatingIfNeeded: v >> (8 * UInt32($0))) } } +func le64(_ v: UInt64) -> [UInt8] { (0..<8).map { UInt8(truncatingIfNeeded: v >> (8 * UInt64($0))) } } +func entry(_ id: UInt64, _ name: String, state: UInt32 = 1, app: UInt32 = 0, flags: UInt8 = 0) -> [UInt8] { + le64(id) + le32(state) + le32(app) + [flags, UInt8(name.utf8.count)] + Array(name.utf8) +} +func encode(_ entries: [[UInt8]], count: UInt32? = nil) -> Data { + Data(Array("MFRND001".utf8) + le32(count ?? UInt32(entries.count)) + entries.flatMap { $0 }) +} +let alice: UInt64 = 0x0110000100000001, bob: UInt64 = 0x0110000100000002, carol: UInt64 = 0x0110000100000003 + +// Feed bounds (parseFeed). +let one = encode([entry(alice, "Alice")]) +assert(DockFriends.parseFeed(one)?.first?.name == "Alice") +assert(DockFriends.parseFeed(encode([]))?.isEmpty == true) +assert(DockFriends.parseFeed(Data("MFRND002".utf8) + Data(le32(0))) == nil, "magic") +assert(DockFriends.parseFeed(Data(one.prefix(11))) == nil, "short header") +assert(DockFriends.parseFeed(Data(one.dropLast())) == nil, "truncated name") +assert(DockFriends.parseFeed(one + Data([0])) == nil, "trailing byte") +assert(DockFriends.parseFeed(encode([entry(alice, "Alice")], count: 2)) == nil, "count past the data") +assert(DockFriends.parseFeed(encode([], count: 251)) == nil, "count past 250") +assert(DockFriends.parseFeed(encode([entry(alice, String(repeating: "a", count: 63))])) != nil) +assert(DockFriends.parseFeed(encode([entry(alice, String(repeating: "a", count: 64))])) == nil, "64-byte name") +var badName = entry(alice, "ab"); badName[badName.count - 1] = 0xff +assert(DockFriends.parseFeed(encode([badName])) == nil, "invalid UTF-8") +let full = encode((0..<250).map { entry(alice + UInt64($0), String(repeating: "n", count: 63)) }) +assert(full.count <= DockFriends.feedCap && DockFriends.parseFeed(full)?.count == 250, "the largest feed") +let oversized = Data(Array("MFRND001".utf8) + le32(0)) + Data(count: DockFriends.feedCap - 11) +assert(oversized.count == DockFriends.feedCap + 1 && DockFriends.parseFeed(oversized) == nil, "past the cap") + +// Display order: invited, joinable, this game, another game, online, offline; by name. +let order = DockFriends.ordered(DockFriends.parseFeed(encode([ + entry(1, "zed", state: 0), entry(2, "Yan"), entry(3, "xia", flags: 1), entry(4, "Wu", flags: 3), + entry(5, "vic", flags: 7), entry(6, "Uma", state: 0, flags: 8), entry(7, "abe")]))!).map(\.steamID) +assert(order == [6, 5, 4, 3, 7, 2, 1], "\(order)") + +// Command bytes: magic, action, SteamID (LE), sequence (LE); sequences stay below 2^31. +assert([UInt8](DockFriends.command(.invite, id: alice, sequence: 0x01020304)) == + Array("MFCMD001".utf8) + [1] + le64(alice) + [4, 3, 2, 1]) +assert(DockFriends.command(.setStatus, id: 7, sequence: 1).count == 21) +assert(DockFriends.nextSequence(after: 41) == 42) +assert(DockFriends.nextSequence(after: 0x7fff_fffe) == 0x7fff_ffff) +assert(DockFriends.nextSequence(after: 0x7fff_ffff) == 1 && DockFriends.nextSequence(after: 0xffff_ffff) == 1) +assert(DockFriends.nextSequence(after: 0x8000_0005) == 6) + +// A command's own result only: after its friends-cmd-seq, complete lines only. +func lines(_ l: [String], end: String = "\r\n") -> Data { Data((l.joined(separator: "\r\n") + end).utf8) } +let r = { (s: String) in "[steam-host] ml2020 " + s } +assert(DockFriends.commandResult(in: lines([r("friends-cmd-seq=9"), r("friends-cmd-result=1")]), sequence: 9) == 1) +assert(DockFriends.commandResult(in: lines([r("friends-cmd-result=4"), r("friends-cmd-seq=9")]), sequence: 9) == nil, "a result before the sequence") +assert(DockFriends.commandResult(in: lines([r("friends-cmd-seq=19"), r("friends-cmd-result=1")]), sequence: 9) == nil, "another sequence") +assert(DockFriends.commandResult(in: lines([r("friends-cmd-seq=9"), r("friends-cmd-seq=10"), r("friends-cmd-result=1")]), sequence: 9) == nil, "a later command's result") +assert(DockFriends.commandResult(in: lines([r("friends-cmd-seq=9"), r("friends-count=3"), r("friends-cmd-result=2")]), sequence: 9) == 2) +assert(DockFriends.commandResult(in: lines([r("friends-cmd-seq=9"), r("friends-cmd-result=1")], end: ""), sequence: 9) == nil, "a partial final line") +assert(DockFriends.commandResult(in: lines([r("friends-cmd-seq=2147483647"), r("friends-cmd-result=3")]), sequence: 0x7fff_ffff) == 3) + +MainActor.assumeIsolated { + let model = DockFriends() + let now = Date() + func writeFeed(_ data: Data, age: TimeInterval = 0) { + try! data.write(to: feed) + try! fm.setAttributes([.modificationDate: now.addingTimeInterval(-age)], ofItemAtPath: feed.path) + } + + // Valid -> missing, valid -> invalid, valid -> stale: never an old list. + model.refresh(now: now) + assert(!model.available && model.friends.isEmpty, "no feed") + writeFeed(one); model.refresh(now: now) + assert(model.available && model.friends.map(\.name) == ["Alice"]) + try! fm.removeItem(at: feed); model.refresh(now: now) + assert(!model.available && model.friends.isEmpty, "valid to missing") + writeFeed(one); model.refresh(now: now); assert(model.friends.count == 1) + writeFeed(Data([0])); model.refresh(now: now) + assert(!model.available && model.friends.isEmpty, "valid to invalid") + writeFeed(one); model.refresh(now: now); assert(model.friends.count == 1) + writeFeed(one, age: DockFriends.feedMaxAge + 1); model.refresh(now: now) + assert(!model.available && model.friends.isEmpty, "valid to stale (a host that did not end cleanly)") + writeFeed(oversized); model.refresh(now: now) + assert(!model.available, "oversized feed") + + // No command without a current feed. + model.send(.invite, to: DockFriends.Friend(steamID: alice, name: "Alice", dockFlags: 16), now: now) + assert(model.pending == nil && !fm.fileExists(atPath: commandFile.path), "no command while friends are unavailable") + + // A command, its bytes, and its own result in the report written after it. + writeFeed(encode([entry(alice, "Alice", flags: 16), entry(bob, "Bob", state: 3, app: 70, flags: 7)])) + model.refresh(now: now) + try! lines([r("friends-available=1"), r("friends-cmd-seq=1"), r("friends-cmd-result=4")]).write(to: report) + let bobFriend = model.friends.first { $0.steamID == bob }! + model.send(.join, to: bobFriend, now: now) + let sent = model.pending! + assert(sent.action == .join && sent.steamID == bob && sent.sequence <= 0x7fff_ffff) + assert(try! Data(contentsOf: commandFile) == DockFriends.command(.join, id: bob, sequence: sent.sequence)) + model.send(.invite, to: bobFriend, now: now) + assert(model.pending == sent, "one command at a time") + // An earlier session's answer for the same number, before the command was sent, is not this one's. + let before = (try! Data(contentsOf: report)) + model.refresh(now: now) + assert(model.pending == sent) + let handle = try! FileHandle(forWritingTo: report); handle.seekToEndOfFile() + handle.write(lines([r("friends-cmd-seq=\(sent.sequence &+ 1)"), r("friends-cmd-result=4"), + r("friends-cmd-seq=\(sent.sequence)"), r("friends-cmd-result=1")])); handle.closeFile() + model.refresh(now: now) + assert(model.pending == nil && model.outcome?.steamID == bob && model.outcome?.result == 1 && model.outcome?.action == .join) + assert(DockFriends.message(action: .join, result: 1) == "Sent to the game") + + // The earlier lines are ignored by offset: an answer that only exists there does not count. + try! (before + lines([r("friends-cmd-seq=\(DockFriends.nextSequence(after: sent.sequence))"), r("friends-cmd-result=1")])).write(to: report) + let reportSize = (try! fm.attributesOfItem(atPath: report.path))[.size] as! UInt64 + model.send(.invite, to: bobFriend, now: now) + let second = model.pending! + assert(second.sequence == DockFriends.nextSequence(after: sent.sequence)) + model.refresh(now: now) + assert(model.pending == second, "an answer written before the command was sent is not its answer (report \(reportSize) bytes)") + + // No answer in commandTimeout: "No answer from Steam" (result 0). + model.refresh(now: now.addingTimeInterval(DockFriends.commandTimeout - 1)) + assert(model.pending == second) + model.refresh(now: now.addingTimeInterval(DockFriends.commandTimeout + 1)) + assert(model.pending == nil && model.outcome?.result == 0 && DockFriends.message(action: .invite, result: 0) == "No answer from Steam") + + // A new, shorter report (a new session) is read from its start. + model.send(.invite, to: bobFriend, now: now) + let third = model.pending! + try! lines([r("friends-cmd-seq=\(third.sequence)"), r("friends-cmd-result=2")]).write(to: report) + model.refresh(now: now) + assert(model.pending == nil && model.outcome?.result == 2) + + // Status: Offline is never sent; the others are, with the status in the id field. + model.setStatus(.offline, now: now) + assert(model.pending == nil) + model.setStatus(.away, now: now) + assert(model.pending?.action == .setStatus && model.pending?.steamID == 3) + assert(SteamOnlineStatus.current == .away) + + // Reset and session end. + model.reset() + assert(model.friends.isEmpty && !model.available && model.pending == nil && model.outcome == nil) + writeFeed(one); try! Data([1]).write(to: commandFile); model.refresh(now: now) + assert(model.available) + model.endSession() + assert(!fm.fileExists(atPath: feed.path) && !fm.fileExists(atPath: commandFile.path)) + assert(!model.available && model.friends.isEmpty) + model.refresh(now: now) + assert(!model.available, "nothing left for the next session") +} +assert(!SteamLog.events.contains { $0.contains("Alice") || $0.contains("Bob") || $0.contains(String(alice)) || $0.contains(String(bob)) }, + "logs carry no names or SteamIDs") + +// Friends are opt-in: with nothing chosen the status is Offline (friends off). +UserDefaults.standard.removeObject(forKey: "steamOnlineStatus") +assert(SteamOnlineStatus.current == .offline) +SteamOnlineStatus.current = .invisible +assert(SteamOnlineStatus.current == .invisible && UserDefaults.standard.integer(forKey: "steamOnlineStatus") == 7) +UserDefaults.standard.set(5, forKey: "steamOnlineStatus") +assert(SteamOnlineStatus.current == .offline, "an unknown stored value is Offline") +UserDefaults.standard.removeObject(forKey: "steamOnlineStatus") +print("PASS: Friends feed bounds, display order, command bytes, 31-bit sequences, own-result matching, timeout, reset, session end, valid-to-missing/invalid/stale feeds, opt-in status") +''' +with tempfile.TemporaryDirectory(prefix='madeira-dock-friends-') as directory: + work = Path(directory) + source = work / 'main.swift'; binary = work / 'check'; drive = work / 'drive_c' + drive.mkdir() + source.write_text(stubs + model + '\n' + status + '\n' + checks) + built = subprocess.run([SWIFTC, '-Onone', str(source), '-o', str(binary)]) + require(built.returncode == 0, 'production DockFriends model compiles on the host') + if built.returncode == 0: + env = dict(os.environ, CFFIXED_USER_HOME=str(work)) + require(subprocess.run([str(binary), str(drive)], env=env).returncode == 0, 'Friends model checks') + +print('FAIL' if failures else 'PASS') +sys.exit(1 if failures else 0) diff --git a/tests/host/check-dock-report.py b/tests/host/check-dock-report.py index 41d53a62a9..7ee54ee1aa 100644 --- a/tests/host/check-dock-report.py +++ b/tests/host/check-dock-report.py @@ -61,9 +61,14 @@ assert(parse("[steam-host] ml2016 session-offline-ready=1\n").fields["session-offline-ready"] == "1") let rejected = "[steam-host] ml1830 account=synthetic\n[steam-host] ml1830 token=synthetic\n[steam-host] ml1830 probe-result=2147483648\n[steam-host] ml1830 probe-result=secret\n[steam-host] ml1830 client-sha256=invalid\n[steam-host] unknown probe-result=0\n[steam-host] ml1830 probe-result=0 secret\n" assert(parse(rejected).fields.isEmpty) -assert(parse(String(repeating: "x", count: 32769)).fields.isEmpty) +// The cap (1 MiB): a report of exactly reportCap bytes is read, one byte more is not. +let capLine = "[steam-host] ml1830 probe-result=0\n" +let capPad = String(repeating: "x", count: MadeiraDock.reportCap - capLine.utf8.count - 1) + "\n" +assert(MadeiraDock.reportCap == 1 << 20 && (capPad + capLine).utf8.count == MadeiraDock.reportCap) +assert(parse(capPad + capLine).result == 0) +assert(parse("x" + capPad + capLine).fields.isEmpty) assert(MadeiraDock.parseReport(Data([0xff])).fields.isEmpty) -print("PASS: Dock report completion, CRLF, fingerprints, adapter version, callback IDs, failure reasons (including the session wait and the license wait) and private/malformed field rejection") +print("PASS: Dock report completion, the 1 MiB cap, CRLF, fingerprints, adapter version, callback IDs, failure reasons (including the session wait and the license wait) and private/malformed field rejection") ''' with tempfile.TemporaryDirectory(prefix='madeira-dock-report-') as directory: source = Path(directory) / 'main.swift'; binary = Path(directory) / 'check'