| 44 | } |
| 45 | |
| 46 | CommandResult |
| 47 | Client::ProcessLine(char *line) noexcept |
| 48 | { |
| 49 | assert(!background_command); |
| 50 | |
| 51 | if (!IsLowerAlphaASCII(*line)) { |
| 52 | /* all valid MPD commands begin with a lower case |
| 53 | letter; this could be a badly routed HTTP |
| 54 | request */ |
| 55 | FmtWarning(client_domain, |
| 56 | "[{}] malformed command {:?}", |
| 57 | name, line); |
| 58 | return CommandResult::CLOSE; |
| 59 | } |
| 60 | |
| 61 | if (cmd_list.IsActive() && IsAsyncCommmand(line)) { |
| 62 | FmtWarning(client_domain, |
| 63 | "[{}] not possible in command list: {:?}", |
| 64 | name, line); |
| 65 | return CommandResult::CLOSE; |
| 66 | } |
| 67 | |
| 68 | if (StringIsEqual(line, "noidle")) { |
| 69 | if (idle_waiting) { |
| 70 | /* send empty idle response and leave idle mode */ |
| 71 | idle_waiting = false; |
| 72 | WriteOK(); |
| 73 | } |
| 74 | |
| 75 | /* do nothing if the client wasn't idling: the client |
| 76 | has already received the full idle response from |
| 77 | IdleNotify(), which he can now evaluate */ |
| 78 | |
| 79 | return CommandResult::OK; |
| 80 | } else if (idle_waiting) { |
| 81 | /* during idle mode, clients must not send anything |
| 82 | except "noidle" */ |
| 83 | FmtWarning(client_domain, |
| 84 | "[{}] command {:?} during idle", |
| 85 | name, line); |
| 86 | return CommandResult::CLOSE; |
| 87 | } |
| 88 | |
| 89 | if (cmd_list.IsActive()) { |
| 90 | if (StringIsEqual(line, CLIENT_LIST_MODE_END)) { |
| 91 | FmtDebug(client_domain, |
| 92 | "[{}] process command list", |
| 93 | name); |
| 94 | |
| 95 | const bool ok_mode = cmd_list.IsOKMode(); |
| 96 | auto list = cmd_list.Commit(); |
| 97 | cmd_list.Reset(); |
| 98 | |
| 99 | auto ret = ProcessCommandList(ok_mode, |
| 100 | std::move(list)); |
| 101 | FmtDebug(client_domain, |
| 102 | "[{}] process command " |
| 103 | "list returned {}", name, unsigned(ret)); |
nothing calls this directly
no test coverage detected