From 1569df114ebfa71ed0d95fa58e60180cc5d4654f Mon Sep 17 00:00:00 2001 From: APTX Date: Mon, 2 Jan 2012 18:10:36 +0100 Subject: [PATCH] Add settings for ENCRYPT support. --- main.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 0dc40a1..ddbe1ed 100644 --- a/main.cpp +++ b/main.cpp @@ -99,11 +99,13 @@ int main(int argc, char *argv[]) opts.addSection("Account settings"); opts.add("user", "AniDB user name", QxtCommandOptions::ValueRequired); opts.add("pass", "AniDB password", QxtCommandOptions::ValueRequired); + opts.add("apikey", "AniDB API key. See encryption", QxtCommandOptions::ValueRequired); opts.addSection("Connecton settings"); opts.add("host", "AniDB UDP API host name", QxtCommandOptions::ValueRequired); opts.add("host-port", "AniDB UDP API host port", QxtCommandOptions::ValueRequired); opts.add("local-port", "Local port. WARNING: DO NOT CHANGE!", QxtCommandOptions::ValueRequired); + opts.add("encryption", "Enable encryption. 1 to enable, 0 to disable. AniDB API key is required for encryption. Check your AniDB profile for details", QxtCommandOptions::ValueRequired); opts.addSection("MyList settings"); opts.add("state", "File state: hdd, cd, deleted or unknown", QxtCommandOptions::ValueRequired); @@ -143,6 +145,7 @@ int main(int argc, char *argv[]) s.beginGroup("account"); c->setUser(s.value("user", "").toString()); c->setPass(s.value("pass", "").toString()); + c->setApiKey(s.value("apikey", "").toString()); s.endGroup(); s.beginGroup("connection"); c->setHost(s.value("host", c->host()).toString()); @@ -152,6 +155,7 @@ int main(int argc, char *argv[]) uint localPort = s.value("localPort", c->localPort()).toUInt(&ok); if (ok) c->setLocalPort(quint16(localPort)); + c->setEncryptionEnabled(s.value("encryption", false).toBool()); s.endGroup(); s.beginGroup("myListState"); state.setState(String2State(s.value("state", State2String(AniDBUdpClient::StateUnknown)).toString())); @@ -188,6 +192,8 @@ int main(int argc, char *argv[]) c->setUser(opts.value("user").toString()); if (opts.count("pass")) c->setPass(opts.value("pass").toString()); + if (opts.count("apikey")) + c->setApiKey(opts.value("apikey").toString()); if (opts.count("host")) c->setHost(opts.value("host").toString()); if (opts.count("host-port")) @@ -202,6 +208,12 @@ int main(int argc, char *argv[]) if (ok) c->setLocalPort(quint16(localPort)); } + if (opts.count("encryption")) + { + bool encryption = bool(opts.value("encryption").toUInt(&ok)); + if (ok) + c->setEncryptionEnabled(encryption); + } if (opts.count("state")) { state.setState(String2State(opts.value("state").toString())); @@ -227,13 +239,15 @@ int main(int argc, char *argv[]) cout << " Print Hash: " << (hash ? "Yes" : "No") << endl << endl; cout << "Account settings:" << endl; - cout << " User: " << c->user().toUtf8().constData() << endl; - cout << " Pass: " << (c->pass().isEmpty() ? "" : "****") << endl << endl; + cout << " User: " << c->user().toUtf8().constData() << endl; + cout << " Pass: " << (c->pass().isEmpty() ? "" : "****") << endl; + cout << " ApiKey: " << (c->apiKey().isEmpty() ? "" : "****") << endl << endl; cout << "Connection settings:" << endl; cout << " Host: " << c->host().toUtf8().constData() << endl; cout << " Host port: " << c->hostPort() << endl; - cout << " Local port: " << c->localPort() << endl << endl; + cout << " Local port: " << c->localPort() << endl; + cout << " Encryption: " << (c->encryptionEnabled() ? "1 (Enabled)" : "0 (Disabled)") << endl << endl; cout << "MyList settings:" << endl; cout << " State: " << State2String(state.state()).toUtf8().constData() << endl; @@ -257,11 +271,13 @@ int main(int argc, char *argv[]) s.beginGroup("account"); s.setValue("user", c->user()); s.setValue("pass", c->pass()); + s.setValue("apikey", c->apiKey()); s.endGroup(); s.beginGroup("connection"); s.setValue("host", c->host()); s.setValue("hostPort", c->hostPort()); s.setValue("localPort", c->localPort()); + s.setValue("encryption", c->encryptionEnabled()); s.endGroup(); s.beginGroup("myListState"); s.setValue("state", State2String(state.state())); -- 2.52.0