This makes logging and error reporting in the plugin more consistent with other plugins and Geany. Also set the G_LOG_DOMAIN for the plugin in order to have proper log messages. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/370
-- Commit Summary --
* Use GLib error reporting/logging instead of fprintf()
-- File Changes --
M geanypg/src/Makefile.am (2) M geanypg/src/decrypt_cb.c (2) M geanypg/src/encrypt_cb.c (2) M geanypg/src/geanypg.c (5) M geanypg/src/pinentry.c (12) M geanypg/src/sign_cb.c (2) M geanypg/src/verify_aux.c (2)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/370.patch https://github.com/geany/geany-plugins/pull/370.diff
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370
@@ -58,7 +57,7 @@ gpgme_error_t geanypg_show_err_msg(gpgme_error_t err) gchar const * msg = (gchar const *)gpgme_strerror(err); gchar const * src = (gchar const *)gpgme_strsource(err); dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s %s: %s\n", _("Error from"), src, msg);
- fprintf(stderr, "GeanyPG: %s %s: %s\n", _("Error from"), msg, src);
- g_error("%s %s: %s", _("Error from"), msg, src);
don't use [`g_error()`](https://developer.gnome.org/glib/unstable/glib-Message-Logging.html#g-error) as it `abort()`s.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370/files#r54021345
@@ -83,12 +83,12 @@ gpgme_error_t geanypg_passphrase_cb(void * hook,
if (pipe(outpipe)) {
fprintf(stderr, "GeanyPG: %s\n", strerror(errno));
g_error("%s", strerror(errno));
ditto
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370/files#r54021365
return gpgme_error_from_errno(errno); } if (pipe(inpipe)) {
fprintf(stderr, "GeanyPG: %s\n", strerror(errno));
g_error("%s", strerror(errno));
ditto
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370/files#r54021378
@@ -108,7 +108,7 @@ gpgme_error_t geanypg_passphrase_cb(void * hook,
execvp(*argv, argv); /* shouldn't get here */
fprintf(stderr, "GeanyPG: %s\n%s\n", _("Could not use pinentry."), strerror(errno));
g_error("%s: %s", _("Could not use pinentry."), strerror(errno));
ditto
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370/files#r54021388
@@ -108,7 +108,7 @@ gpgme_error_t geanypg_passphrase_cb(void * hook,
execvp(*argv, argv); /* shouldn't get here */
fprintf(stderr, "GeanyPG: %s\n%s\n", _("Could not use pinentry."), strerror(errno));
g_error("%s: %s", _("Could not use pinentry."), strerror(errno)); exit(1); /* kill the child */
well, here it `exit()`s so it's probably okay-ish, although it's still less nice `exit()` is nicer (less "OMG something funky happened lemme outta here plzz")
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370/files#r54021618
@@ -168,10 +168,10 @@ gpgme_error_t geanypg_passphrase_cb(void * hook, geanypg_read(outpipe[READ], ' ', 2049, readbuffer); sscanf(readbuffer, "%lu", &errval); geanypg_read(outpipe[READ], '\n', 2049, readbuffer);
fprintf(stderr, "GeanyPG: %s %lu %s\n", _("pinentry gave error"), errval, readbuffer);
g_error("%s %lu %s", _("pinentry gave error"), errval, readbuffer);
ditto
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370/files#r54021634
} else
fprintf(stderr, "GeanyPG: %s\n", _("Unexpected error from pinentry."));
g_error(_("Unexpected error from pinentry."));
ditto
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370/files#r54021647
@@ -58,7 +57,7 @@ gpgme_error_t geanypg_show_err_msg(gpgme_error_t err) gchar const * msg = (gchar const *)gpgme_strerror(err); gchar const * src = (gchar const *)gpgme_strsource(err); dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s %s: %s\n", _("Error from"), src, msg);
- fprintf(stderr, "GeanyPG: %s %s: %s\n", _("Error from"), msg, src);
- g_error("%s %s: %s", _("Error from"), msg, src);
Oops, sorry for that. Especially because I knew this once and then forgot about it. I replaced all occurrences of g_error with g_warning.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370/files#r54170895
LGTM
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370#issuecomment-189008653
Merged #370.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/370#event-569015929
github-comments@lists.geany.org