MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / onConnectionNewCommand

Method onConnectionNewCommand

src/windscribe-cli/backendcommander.cpp:48–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void BackendCommander::onConnectionNewCommand(IPC::Command *command, IPC::Connection * /*connection*/)
49{
50 std::unique_ptr<IPC::Command> owner(command);
51
52 if (command->getStringId() == IPC::CliCommands::Acknowledge::getCommandStringId()) {
53 IPC::CliCommands::Acknowledge *ackCmd = static_cast<IPC::CliCommands::Acknowledge *>(command);
54 onAcknowledge(ackCmd);
55 } else if (command->getStringId() == IPC::CliCommands::State::getCommandStringId()) {
56 if (cliArgs_.cliCommand() == CLI_COMMAND_STATUS) {
57 // If we explicitly requested status, print it.
58 onStateResponse(command);
59 } else if (!bCommandSent_){
60 // If it's a response for the initial state request, send the command now.
61 IPC::CliCommands::State *state = static_cast<IPC::CliCommands::State *>(command);
62 sendCommand(state);
63 } else {
64 // Otherwise, this is an ongoing command in blocking mode.
65 onStateUpdated(command);
66 }
67 } else if (command->getStringId() == IPC::CliCommands::LocationsList::getCommandStringId()) {
68 IPC::CliCommands::LocationsList *cmd = static_cast<IPC::CliCommands::LocationsList *>(command);
69
70 if (cliArgs_.cliCommand() == CLI_COMMAND_LOCATIONS_STATIC) {
71 std::cout << deviceNameString(cmd->deviceName_).toStdString() << std::endl << std::endl;
72 }
73
74 if (cmd->locations_.isEmpty()) {
75 emit finished(1, tr("No locations."));
76 } else {
77 emit finished(0, locationsString(cmd->locations_));
78 }
79 } else if (command->getStringId() == IPC::CliCommands::PortsList::getCommandStringId()) {
80 IPC::CliCommands::PortsList *cmd = static_cast<IPC::CliCommands::PortsList *>(command);
81 if (cmd->ports_.isEmpty()) {
82 emit finished(1, tr("No ports available for the specified protocol."));
83 } else {
84 QStringList portStrings;
85 for (uint port : std::as_const(cmd->ports_)) {
86 portStrings << QString::number(port);
87 }
88 emit finished(0, portStrings.join(", "));
89 }
90 } else if (command->getStringId() == IPC::CliCommands::AmneziawgPresetsList::getCommandStringId()) {
91 IPC::CliCommands::AmneziawgPresetsList *cmd = static_cast<IPC::CliCommands::AmneziawgPresetsList *>(command);
92 if (cmd->presets_.isEmpty()) {
93 emit finished(1, tr("No AmneziaWG configurations available."));
94 } else {
95 QString msg;
96 for (const QString &preset : std::as_const(cmd->presets_)) {
97 msg += preset + "\n";
98 }
99 emit finished(0, msg.trimmed());
100 }
101 }
102}
103
104void BackendCommander::onConnectionStateChanged(int state, IPC::Connection * /*connection*/)
105{

Callers

nothing calls this directly

Calls 5

deviceNameStringFunction · 0.85
locationsStringFunction · 0.85
cliCommandMethod · 0.80
getStringIdMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected