MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / ProcessLine

Method ProcessLine

src/client/Process.cxx:46–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46CommandResult
47Client::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));

Callers

nothing calls this directly

Calls 5

IsAsyncCommmandFunction · 0.85
command_processFunction · 0.85
CommitMethod · 0.45
ResetMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected