cpp: Deprecate Error::asString and update users
* lang/cpp/src/error.h (Error::asString): Mark as deprecated. * lang/cpp/src/context.cpp (operator<<), lang/cpp/src/editinteractor.cpp (edit_interactor_callback_impl), lang/cpp/tests/run-getkey.cpp (main), lang/cpp/tests/run-keylist.cpp (main), lang/cpp/tests/run-wkdlookup.cpp (main): Use Error::asStdString instead of Error::asString. -- GnuPG-bug-id: 7188
This commit is contained in:
parent
2656d3ee5b
commit
28542b14c4
1
NEWS
1
NEWS
@ -43,6 +43,7 @@ Noteworthy changes in version 1.24.0 (unrelease)
|
|||||||
cpp: Key::numRevocationKeys NEW.
|
cpp: Key::numRevocationKeys NEW.
|
||||||
cpp: Key::revocationKeys NEW.
|
cpp: Key::revocationKeys NEW.
|
||||||
cpp: Error::asStdString NEW.
|
cpp: Error::asStdString NEW.
|
||||||
|
cpp: Error::asString DEPRECATED.
|
||||||
qt: DecryptVerifyJob::setInputFile NEW.
|
qt: DecryptVerifyJob::setInputFile NEW.
|
||||||
qt: DecryptVerifyJob::inputFile NEW.
|
qt: DecryptVerifyJob::inputFile NEW.
|
||||||
qt: DecryptVerifyJob::setOutputFile NEW.
|
qt: DecryptVerifyJob::setOutputFile NEW.
|
||||||
|
@ -195,7 +195,7 @@ Error Error::fromCode(unsigned int err, unsigned int src)
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const Error &err)
|
std::ostream &operator<<(std::ostream &os, const Error &err)
|
||||||
{
|
{
|
||||||
return os << "GpgME::Error(" << err.encodedError() << " (" << err.asString() << "))";
|
return os << "GpgME::Error(" << err.encodedError() << " (" << err.asStdString() << "))";
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::KeyListModeSaver::KeyListModeSaver(Context *ctx)
|
Context::KeyListModeSaver::KeyListModeSaver(Context *ctx)
|
||||||
|
@ -138,7 +138,7 @@ public:
|
|||||||
if (writeAll(fd, result, len) != len) {
|
if (writeAll(fd, result, len) != len) {
|
||||||
err = Error::fromSystemError();
|
err = Error::fromSystemError();
|
||||||
if (ei->debug) {
|
if (ei->debug) {
|
||||||
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asString());
|
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str());
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public:
|
|||||||
if (writeAll(fd, "\n", 1) != 1) {
|
if (writeAll(fd, "\n", 1) != 1) {
|
||||||
err = Error::fromSystemError();
|
err = Error::fromSystemError();
|
||||||
if (ei->debug) {
|
if (ei->debug) {
|
||||||
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asString());
|
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str());
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,10 @@ public:
|
|||||||
explicit Error(unsigned int e) : mErr(e), mMessage() {}
|
explicit Error(unsigned int e) : mErr(e), mMessage() {}
|
||||||
|
|
||||||
const char *source() const;
|
const char *source() const;
|
||||||
const char *asString() const;
|
/* This function is deprecated. Use asStdString() instead. asString() may
|
||||||
|
* return wrongly encoded (i.e. not UTF-8) results on Windows for the main
|
||||||
|
* thread if the function was first called from a secondary thread. */
|
||||||
|
GPGMEPP_DEPRECATED const char *asString() const;
|
||||||
std::string asStdString() const;
|
std::string asStdString() const;
|
||||||
|
|
||||||
int code() const;
|
int code() const;
|
||||||
|
@ -150,7 +150,7 @@ main (int argc, char **argv)
|
|||||||
const GpgME::Key key = ctx->key (*argv, err, only_secret);
|
const GpgME::Key key = ctx->key (*argv, err, only_secret);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
ss << "Key " << key << " Err: " << err.asString() << "\n";
|
ss << "Key " << key << " Err: " << err.asStdString() << "\n";
|
||||||
|
|
||||||
std::cout << ss.str();
|
std::cout << ss.str();
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
Error err = ctx->startKeyListing (*argv, only_secret);
|
Error err = ctx->startKeyListing (*argv, only_secret);
|
||||||
if (err) {
|
if (err) {
|
||||||
std::cout << "Error: " << err.asString() << "\n";
|
std::cout << "Error: " << err.asStdString() << "\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
GpgME::Key key;
|
GpgME::Key key;
|
||||||
|
@ -75,31 +75,31 @@ main (int argc, char **argv)
|
|||||||
Error err;
|
Error err;
|
||||||
auto ctx = std::unique_ptr<Context>{Context::createForEngine(AssuanEngine, &err)};
|
auto ctx = std::unique_ptr<Context>{Context::createForEngine(AssuanEngine, &err)};
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
std::cerr << "Failed to get context (Error: " << err.asString() << ")\n";
|
std::cerr << "Failed to get context (Error: " << err.asStdString() << ")\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string dirmngrSocket = GpgME::dirInfo("dirmngr-socket");
|
const std::string dirmngrSocket = GpgME::dirInfo("dirmngr-socket");
|
||||||
if ((err = ctx->setEngineFileName(dirmngrSocket.c_str()))) {
|
if ((err = ctx->setEngineFileName(dirmngrSocket.c_str()))) {
|
||||||
std::cerr << "Failed to set engine file name (Error: " << err.asString() << ")\n";
|
std::cerr << "Failed to set engine file name (Error: " << err.asStdString() << ")\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((err = ctx->setEngineHomeDirectory(""))) {
|
if ((err = ctx->setEngineHomeDirectory(""))) {
|
||||||
std::cerr << "Failed to set engine home directory (Error: " << err.asString() << ")\n";
|
std::cerr << "Failed to set engine home directory (Error: " << err.asStdString() << ")\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to connect to dirmngr
|
// try to connect to dirmngr
|
||||||
err = ctx->assuanTransact("GETINFO version");
|
err = ctx->assuanTransact("GETINFO version");
|
||||||
if (err && err.code() != GPG_ERR_ASS_CONNECT_FAILED) {
|
if (err && err.code() != GPG_ERR_ASS_CONNECT_FAILED) {
|
||||||
std::cerr << "Failed to start assuan transaction (Error: " << err.asString() << ")\n";
|
std::cerr << "Failed to start assuan transaction (Error: " << err.asStdString() << ")\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (err.code() == GPG_ERR_ASS_CONNECT_FAILED) {
|
if (err.code() == GPG_ERR_ASS_CONNECT_FAILED) {
|
||||||
std::cerr << "Starting dirmngr ...\n";
|
std::cerr << "Starting dirmngr ...\n";
|
||||||
auto spawnCtx = std::unique_ptr<Context>{Context::createForEngine(SpawnEngine, &err)};
|
auto spawnCtx = std::unique_ptr<Context>{Context::createForEngine(SpawnEngine, &err)};
|
||||||
if (!spawnCtx) {
|
if (!spawnCtx) {
|
||||||
std::cerr << "Failed to get context for spawn engine (Error: " << err.asString() << ")\n";
|
std::cerr << "Failed to get context for spawn engine (Error: " << err.asStdString() << ")\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ main (int argc, char **argv)
|
|||||||
ignoreIO, ignoreIO, ignoreIO,
|
ignoreIO, ignoreIO, ignoreIO,
|
||||||
Context::SpawnDetached);
|
Context::SpawnDetached);
|
||||||
if (err) {
|
if (err) {
|
||||||
std::cerr << "Failed to start dirmngr (Error: " << err.asString() << ")\n";
|
std::cerr << "Failed to start dirmngr (Error: " << err.asStdString() << ")\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ main (int argc, char **argv)
|
|||||||
const auto cmd = std::string{"WKD_GET "} + email;
|
const auto cmd = std::string{"WKD_GET "} + email;
|
||||||
err = ctx->assuanTransact(cmd.c_str());
|
err = ctx->assuanTransact(cmd.c_str());
|
||||||
if (err && err.code() != GPG_ERR_NO_NAME && err.code() != GPG_ERR_NO_DATA) {
|
if (err && err.code() != GPG_ERR_NO_NAME && err.code() != GPG_ERR_NO_DATA) {
|
||||||
std::cerr << "Error: WKD_GET returned " << err.asString() << "\n";
|
std::cerr << "Error: WKD_GET returned " << err.asStdString() << "\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user