From 40dcb7a0416e0a7ef863c98702c2bc82d701632f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 6 Sep 2023 21:09:42 +0200 Subject: [PATCH] Add --no-notify option to utils --- utils/acsmdownloader.cpp | 10 ++++++++-- utils/adept_loan_mgt.cpp | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/utils/acsmdownloader.cpp b/utils/acsmdownloader.cpp index b84efc5..4d23748 100644 --- a/utils/acsmdownloader.cpp +++ b/utils/acsmdownloader.cpp @@ -46,6 +46,7 @@ static bool exportPrivateKey = false; static const char* outputFile = 0; static const char* outputDir = 0; static bool resume = false; +static bool notify = true; class ACSMDownloader @@ -82,7 +83,7 @@ public: } else { - gourou::FulfillmentItem* item = processor.fulfill(acsmFile); + gourou::FulfillmentItem* item = processor.fulfill(acsmFile, notify); std::string filename; if (!outputFile) @@ -190,6 +191,7 @@ static void usage(const char* cmd) std::cout << " " << "-f|--acsm-file" << "\t" << "Backward compatibility: ACSM request file for epub download" << std::endl; std::cout << " " << "-e|--export-private-key"<< "\t" << "Export private key in DER format" << std::endl; std::cout << " " << "-r|--resume" << "\t\t" << "Try to resume download (in case of previous failure)" << std::endl; + std::cout << " " << "-N|--no-notify" << "\t\t" << "Don't notify server, even if requested" << std::endl; std::cout << " " << "-v|--verbose" << "\t\t" << "Increase verbosity, can be set multiple times" << std::endl; std::cout << " " << "-V|--version" << "\t\t" << "Display libgourou version" << std::endl; std::cout << " " << "-h|--help" << "\t\t" << "This help" << std::endl; @@ -232,13 +234,14 @@ int main(int argc, char** argv) {"acsm-file", required_argument, 0, 'f' }, {"export-private-key",no_argument, 0, 'e' }, {"resume", no_argument, 0, 'r' }, + {"no-notify", no_argument, 0, 'N' }, {"verbose", no_argument, 0, 'v' }, {"version", no_argument, 0, 'V' }, {"help", no_argument, 0, 'h' }, {0, 0, 0, 0 } }; - c = getopt_long(argc, argv, "D:d:a:k:O:o:f:ervVh", + c = getopt_long(argc, argv, "D:d:a:k:O:o:f:erNvVh", long_options, &option_index); if (c == -1) break; @@ -276,6 +279,9 @@ int main(int argc, char** argv) case 'r': resume = true; break; + case 'N': + notify = false; + break; case 'v': verbose++; break; diff --git a/utils/adept_loan_mgt.cpp b/utils/adept_loan_mgt.cpp index 34f328f..2bc944e 100644 --- a/utils/adept_loan_mgt.cpp +++ b/utils/adept_loan_mgt.cpp @@ -52,6 +52,7 @@ static const char* devicekeyFile = "devicesalt"; static bool list = false; static const char* returnID = 0; static const char* deleteID = 0; +static bool notify = true; struct Loan { @@ -296,7 +297,7 @@ private: return; } - processor.returnLoan(loan->id, loan->operatorURL); + processor.returnLoan(loan->id, loan->operatorURL, notify); deleteID = returnID; if (deleteLoan(false)) @@ -342,6 +343,7 @@ static void usage(const char* cmd) std::cout << " " << "-l|--list" << "\t\t" << "List all loaned books" << std::endl; std::cout << " " << "-r|--return" << "\t\t" << "Return a loaned book" << std::endl; std::cout << " " << "-d|--delete" << "\t\t" << "Delete a loan entry without returning it" << std::endl; + std::cout << " " << "-N|--no-notify" << "\t\t" << "Don't notify server, even if requested" << std::endl; std::cout << " " << "-v|--verbose" << "\t\t" << "Increase verbosity, can be set multiple times" << std::endl; std::cout << " " << "-V|--version" << "\t\t" << "Display libgourou version" << std::endl; std::cout << " " << "-h|--help" << "\t\t" << "This help" << std::endl; @@ -375,6 +377,7 @@ int main(int argc, char** argv) {"list", no_argument, 0, 'l' }, {"return", no_argument, 0, 'r' }, {"delete", no_argument, 0, 'd' }, + {"no-notify", no_argument, 0, 'N' }, {"verbose", no_argument, 0, 'v' }, {"version", no_argument, 0, 'V' }, {"help", no_argument, 0, 'h' }, @@ -402,6 +405,9 @@ int main(int argc, char** argv) deleteID = optarg; actions++; break; + case 'N': + notify = false; + break; case 'v': verbose++; break;