diff --git a/src/auth.cpp b/src/auth.cpp index b860876..febabfd 100644 --- a/src/auth.cpp +++ b/src/auth.cpp @@ -309,37 +309,47 @@ int Auth::PerformAction(const AuthAction p_AuthAction) scriptPath + " " + ((p_AuthAction == Generate) ? "-g" : "-r") + " > " + outPath + " 2>&1"; int status = system(command.c_str()); + const std::string output = Util::ReadFile(outPath); if (WIFEXITED(status) && (WEXITSTATUS(status) == 0)) { LOG_DEBUG((p_AuthAction == Generate) ? "oauth2 generate ok" : "oauth2 refresh ok"); UpdateExpiryTime(); + if (!output.empty()) + { + LOG_DEBUG("%s", output.c_str()); + } } else if (WIFEXITED(status)) { LOG_WARNING((p_AuthAction == Generate) ? "oauth2 generate failed (%d): %s" : "oauth2 refresh failed (%d): %s", WEXITSTATUS(status), command.c_str()); - std::string output = Util::ReadFile(outPath); - - // stderr is logged to terminal before ui started, otherwise to log file - std::cerr << output << "\n"; + std::cerr << output; + if (WEXITSTATUS(status) == 7) + { + std::string msg = "try setup: nmail -d " + Util::GetApplicationDir() + " -s " + m_Auth; + LOG_WARNING("%s", msg.c_str()); + } } else if (WIFSIGNALED(status)) { LOG_WARNING((p_AuthAction == Generate) ? "oauth2 generate killed %d" : "oauth2 refresh killed %d", WTERMSIG(status)); + std::cerr << output; } else if (WIFSTOPPED(status)) { LOG_WARNING((p_AuthAction == Generate) ? "oauth2 generate stopped %d" : "oauth2 refresh stopped %d", WSTOPSIG(status)); + std::cerr << output; } else if (WIFCONTINUED(status)) { LOG_WARNING((p_AuthAction == Generate) ? "oauth2 generate continued" : "oauth2 refresh continued"); + std::cerr << output; } Util::DeleteFile(outPath); diff --git a/src/nmail.1 b/src/nmail.1 index 4ff798f..d2e37f3 100644 --- a/src/nmail.1 +++ b/src/nmail.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NMAIL "1" "August 2024" "nmail 5.1.6" "User Commands" +.TH NMAIL "1" "August 2024" "nmail 5.1.7" "User Commands" .SH NAME nmail \- ncurses mail .SH SYNOPSIS diff --git a/src/oauth2nmail b/src/oauth2nmail index c43c06b..09ee38f 100755 --- a/src/oauth2nmail +++ b/src/oauth2nmail @@ -67,6 +67,7 @@ def show_help(): print(" 4 http request network error") print(" 5 http request returned non-200") print(" 6 access token not available") + print(" 7 refresh token not available") print(" 130 keyboard interrupt (ctrl-c)") print("") print("Examples:") @@ -340,7 +341,7 @@ def refresh(provider, client_id, client_secret, token_store): refresh_token = tokens["refresh_token"] else: sys.stderr.write("refresh_token not set in " + token_store + "\n") - return 1 + return 7 # use refresh code to request new access token refrParams = {} diff --git a/src/version.cpp b/src/version.cpp index d0f9996..950788b 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -7,7 +7,7 @@ #include "version.h" -#define NMAIL_VERSION "5.1.6" +#define NMAIL_VERSION "5.1.7" std::string Version::GetBuildOs() {