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

Method sendCommand

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

Source from the content-addressed store, hash-verified

132}
133
134void BackendCommander::sendCommand(IPC::CliCommands::State *state)
135{
136 LanguageController::instance().setLanguage(state->language_);
137
138 if (cliArgs_.cliCommand() == CLI_COMMAND_CONNECT || cliArgs_.cliCommand() == CLI_COMMAND_CONNECT_BEST
139 || cliArgs_.cliCommand() == CLI_COMMAND_CONNECT_LOCATION || cliArgs_.cliCommand() == CLI_COMMAND_CONNECT_STATIC) {
140#ifdef CLI_ONLY
141 if (!state->connectivity_) {
142 emit(finished(1, QObject::tr("Internet connectivity is not available. Try again later.")));
143 return;
144 }
145#endif
146
147 if (state->loginState_ != LOGIN_STATE_LOGGED_IN) {
148 emit finished(1, QObject::tr("Not logged in"));
149 return;
150 }
151 IPC::CliCommands::Connect cmd;
152 if (cliArgs_.cliCommand() == CLI_COMMAND_CONNECT_STATIC) {
153 cmd.locationType_ = IPC::CliCommands::LocationType::kStaticIp;
154 } else {
155 cmd.locationType_ = IPC::CliCommands::LocationType::kRegular;
156 }
157 cmd.location_ = cliArgs_.location();
158 cmd.protocol_ = cliArgs_.protocol();
159 cmd.port_ = cliArgs_.port();
160 connection_->sendCommand(cmd);
161 }
162 else if (cliArgs_.cliCommand() == CLI_COMMAND_DISCONNECT) {
163 if (state->loginState_ != LOGIN_STATE_LOGGED_IN) {
164 emit finished(1, QObject::tr("Not logged in"));
165 return;
166 }
167 if (state->connectState_.connectState == CONNECT_STATE_DISCONNECTED) {
168 emit finished(0, QObject::tr("Already disconnected"));
169 }
170 IPC::CliCommands::Disconnect cmd;
171 connection_->sendCommand(cmd);
172 }
173 else if (cliArgs_.cliCommand() == CLI_COMMAND_FIREWALL_ON) {
174 if (state->isFirewallOn_) {
175 emit finished(0, QObject::tr("Firewall already on"));
176 return;
177 }
178 IPC::CliCommands::Firewall cmd;
179 cmd.isEnable_ = true;
180 connection_->sendCommand(cmd);
181 }
182 else if (cliArgs_.cliCommand() == CLI_COMMAND_FIREWALL_OFF) {
183 if (!state->isFirewallOn_) {
184 emit finished(0, QObject::tr("Firewall already off"));
185 return;
186 }
187 if (state->isFirewallAlwaysOn_) {
188 emit finished(1, QObject::tr("Firewall set to always on and can't be turned off"));
189 return;
190 }
191

Callers 1

sendStateCommandMethod · 0.45

Calls 14

emitFunction · 0.85
cliCommandMethod · 0.80
keyLimitDeleteMethod · 0.80
keepFirewallOnMethod · 0.80
ignoreSslErrorsMethod · 0.80
ipAddressMethod · 0.80
setLanguageMethod · 0.45
protocolMethod · 0.45
portMethod · 0.45
usernameMethod · 0.45
sizeMethod · 0.45
passwordMethod · 0.45

Tested by

no test coverage detected