Use string split function in syntool #4933
This commit is contained in:
parent
942dcabdcd
commit
b4563a42c4
|
@ -152,19 +152,19 @@ ToolApp::loginAuth()
|
||||||
String credentials;
|
String credentials;
|
||||||
std::cin >> credentials;
|
std::cin >> credentials;
|
||||||
|
|
||||||
size_t separator1 = credentials.find(':');
|
std::vector<String> parts = synergy::string::splitString(credentials, ':');
|
||||||
size_t separator2 = credentials.find(':', separator1 + 1);
|
int count = parts.size();
|
||||||
size_t separator3 = credentials.find(':', separator2 + 1);
|
|
||||||
String email = credentials.substr(0, separator1);
|
if (count == 3 || count == 4) {
|
||||||
String password = credentials.substr(separator1 + 1, separator2 - separator1 - 1);
|
String email = parts[0];
|
||||||
String macHash;
|
String password = parts[1];
|
||||||
|
String macHash = parts[2];
|
||||||
String os;
|
String os;
|
||||||
if (separator3 != String::npos) {
|
|
||||||
macHash = credentials.substr(separator2 + 1, separator3 - separator2 - 1);
|
if (count == 4) {
|
||||||
os = credentials.substr(separator3 + 1, credentials.length() - separator3 - 1);
|
os = parts[3];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
macHash = credentials.substr(separator2 + 1, credentials.length() - separator2 - 1);
|
|
||||||
os = ARCH->getOSName();
|
os = ARCH->getOSName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +177,10 @@ ToolApp::loginAuth()
|
||||||
ss << "&arch=" << ARCH->internet().urlEncode(ARCH->getPlatformName());
|
ss << "&arch=" << ARCH->internet().urlEncode(ARCH->getPlatformName());
|
||||||
|
|
||||||
std::cout << ARCH->internet().get(ss.str()) << std::endl;
|
std::cout << ARCH->internet().get(ss.str()) << std::endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw XSynergy("Invalid credentials.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -203,9 +207,20 @@ ToolApp::notifyActivation()
|
||||||
String info;
|
String info;
|
||||||
std::cin >> info;
|
std::cin >> info;
|
||||||
|
|
||||||
size_t separator = info.find(':');
|
std::vector<String> parts = synergy::string::splitString(info, ':');
|
||||||
String action = info.substr(0, separator);
|
int count = parts.size();
|
||||||
String macHash = info.substr(separator + 1, info.length());
|
|
||||||
|
if (count == 2 || count == 3) {
|
||||||
|
String action = parts[0];
|
||||||
|
String macHash = parts[1];
|
||||||
|
String os;
|
||||||
|
|
||||||
|
if (count == 3) {
|
||||||
|
os = parts[2];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
os = ARCH->getOSName();
|
||||||
|
}
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << JSON_URL << "notify/";
|
ss << JSON_URL << "notify/";
|
||||||
|
@ -215,4 +230,8 @@ ToolApp::notifyActivation()
|
||||||
ss << "&arch=" << ARCH->internet().urlEncode(ARCH->getPlatformName());
|
ss << "&arch=" << ARCH->internet().urlEncode(ARCH->getPlatformName());
|
||||||
|
|
||||||
std::cout << ARCH->internet().get(ss.str()) << std::endl;
|
std::cout << ARCH->internet().get(ss.str()) << std::endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw XSynergy("Invalid credentials.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue