Add --no-notify option to utils

This commit is contained in:
Grégory Soutadé 2023-09-06 21:09:42 +02:00
parent e0bb1bd4f8
commit 40dcb7a041
2 changed files with 15 additions and 3 deletions

View File

@ -46,6 +46,7 @@ static bool exportPrivateKey = false;
static const char* outputFile = 0; static const char* outputFile = 0;
static const char* outputDir = 0; static const char* outputDir = 0;
static bool resume = false; static bool resume = false;
static bool notify = true;
class ACSMDownloader class ACSMDownloader
@ -82,7 +83,7 @@ public:
} }
else else
{ {
gourou::FulfillmentItem* item = processor.fulfill(acsmFile); gourou::FulfillmentItem* item = processor.fulfill(acsmFile, notify);
std::string filename; std::string filename;
if (!outputFile) 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 << " " << "-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 << " " << "-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 << " " << "-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|--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 << " " << "-V|--version" << "\t\t" << "Display libgourou version" << std::endl;
std::cout << " " << "-h|--help" << "\t\t" << "This help" << 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' }, {"acsm-file", required_argument, 0, 'f' },
{"export-private-key",no_argument, 0, 'e' }, {"export-private-key",no_argument, 0, 'e' },
{"resume", no_argument, 0, 'r' }, {"resume", no_argument, 0, 'r' },
{"no-notify", no_argument, 0, 'N' },
{"verbose", no_argument, 0, 'v' }, {"verbose", no_argument, 0, 'v' },
{"version", no_argument, 0, 'V' }, {"version", no_argument, 0, 'V' },
{"help", no_argument, 0, 'h' }, {"help", no_argument, 0, 'h' },
{0, 0, 0, 0 } {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); long_options, &option_index);
if (c == -1) if (c == -1)
break; break;
@ -276,6 +279,9 @@ int main(int argc, char** argv)
case 'r': case 'r':
resume = true; resume = true;
break; break;
case 'N':
notify = false;
break;
case 'v': case 'v':
verbose++; verbose++;
break; break;

View File

@ -52,6 +52,7 @@ static const char* devicekeyFile = "devicesalt";
static bool list = false; static bool list = false;
static const char* returnID = 0; static const char* returnID = 0;
static const char* deleteID = 0; static const char* deleteID = 0;
static bool notify = true;
struct Loan struct Loan
{ {
@ -296,7 +297,7 @@ private:
return; return;
} }
processor.returnLoan(loan->id, loan->operatorURL); processor.returnLoan(loan->id, loan->operatorURL, notify);
deleteID = returnID; deleteID = returnID;
if (deleteLoan(false)) 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 << " " << "-l|--list" << "\t\t" << "List all loaned books" << std::endl;
std::cout << " " << "-r|--return" << "\t\t" << "Return a loaned book" << 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 << " " << "-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|--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 << " " << "-V|--version" << "\t\t" << "Display libgourou version" << std::endl;
std::cout << " " << "-h|--help" << "\t\t" << "This help" << 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' }, {"list", no_argument, 0, 'l' },
{"return", no_argument, 0, 'r' }, {"return", no_argument, 0, 'r' },
{"delete", no_argument, 0, 'd' }, {"delete", no_argument, 0, 'd' },
{"no-notify", no_argument, 0, 'N' },
{"verbose", no_argument, 0, 'v' }, {"verbose", no_argument, 0, 'v' },
{"version", no_argument, 0, 'V' }, {"version", no_argument, 0, 'V' },
{"help", no_argument, 0, 'h' }, {"help", no_argument, 0, 'h' },
@ -402,6 +405,9 @@ int main(int argc, char** argv)
deleteID = optarg; deleteID = optarg;
actions++; actions++;
break; break;
case 'N':
notify = false;
break;
case 'v': case 'v':
verbose++; verbose++;
break; break;