本文整理汇总了C++中Updater::setCredentials方法的典型用法代码示例。如果您正苦于以下问题:C++ Updater::setCredentials方法的具体用法?C++ Updater::setCredentials怎么用?C++ Updater::setCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Updater
的用法示例。
在下文中一共展示了Updater::setCredentials方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::tr("manage a local repository (check for updates, update, check integrity)"));
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption checkonly(QStringList() << "c" << "checkonly"
, QCoreApplication::tr("Only check for updates."));
QCommandLineOption verbose(QStringList() << "verbose"
, QCoreApplication::tr("Run in verbose mode."));
QCommandLineOption force(QStringList() << "f" << "force"
, QCoreApplication::tr("Force integrity checks if the local repository is uptodate."));
QCommandLineOption tmpDirectoryPath(QStringList() << "t" << "tmp"
, QCoreApplication::tr("Path to use for temporary files.")
, "tmp_directory");
parser.addOption(checkonly);
parser.addOption(force);
parser.addOption(tmpDirectoryPath);
parser.addOption(verbose);
parser.addPositionalArgument("local_repository", QCoreApplication::tr("Path to the local repository."), "<local_repository>");
parser.addPositionalArgument("remote_repository", QCoreApplication::tr("Path to the remote repository."), "<remote_repository>");
parser.addPositionalArgument("username", QCoreApplication::tr("Username for the remote repository."), "[<username>");
parser.addPositionalArgument("password", QCoreApplication::tr("Password for the remote repository."), "<password>]");
parser.process(app);
QLoggingCategory::setFilterRules(QStringLiteral("updatesystem.*.debug=%1").arg(parser.isSet(verbose) ? "true" : "false"));
const QStringList args = parser.positionalArguments();
if(args.size() < 1)
qWarning() << "Error : local_repository argument is missing";
else if(args.size() < 2)
qWarning() << "Error : remote_repository argument is missing";
else if(args.size() > 2 && args.size() < 4)
qWarning() << "Error : password argument is missing";
else if(args.size() > 4)
qWarning() << "Error : too much arguments";
else
{
Updater updater;
updater.setLocalRepository(args[0]);
updater.setRemoteRepository(args[1]);
if(parser.isSet(tmpDirectoryPath))
updater.setTmpDirectory(parser.value(tmpDirectoryPath));
if(args.size() == 4)
updater.setCredentials(args[2], args[3]);
if(parser.isSet(checkonly))
{
updater.checkForUpdates();
QEventLoop loop;
QObject::connect(&updater, &Updater::checkForUpdatesFinished, &loop, &QEventLoop::quit);
loop.exec();
if(!updater.errorString().isEmpty())
{
fprintf(stderr, "Failure : %s\n", qPrintable(updater.errorString()));
return 2;
}
if(updater.isUpdateAvailable())
{
printf("An update is available\n");
}
else
{
printf("Already up-to-date\n");
}
}
else
{
updater.checkForUpdates();
QEventLoop loop;
QObject::connect(&updater, &Updater::checkForUpdatesFinished, &loop, &QEventLoop::quit);
loop.exec();
printf("Checking for updates...\n");
if(!updater.errorString().isEmpty())
{
fprintf(stderr, "Failure : %s\n", qPrintable(updater.errorString()));
}
else if(updater.isUpdateAvailable() || parser.isSet(force))
{
printf("Updating...\n");
printf("Download 0%%, Apply 0%%");
fflush(stdout);
updater.update();
QObject::connect(&updater, &Updater::updateFinished, &loop, &QEventLoop::quit);
qint64 downloaded = 0, applied = 0;
QObject::connect(&updater, &Updater::updateDownloadProgress, [&downloaded, &applied](qint64 bytesReceived, qint64 bytesTotal) {
downloaded = (bytesReceived*100)/bytesTotal;
printf("\rDownload %3lld%%, Apply %3lld%%", downloaded, applied);
//.........这里部分代码省略.........