From b1336faa48bee2cdb7ef0486a5a4faa5c74f4fa7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 6 Nov 2009 17:50:26 +0100 Subject: make exception handling lighter Signed-off-by: Denys Vlasenko --- lib/Plugins/FileTransfer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Plugins/FileTransfer.cpp') diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index 856a326..8a88fef 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -332,7 +332,7 @@ void CFileTransfer::Run(const char *pActionDir, const char *pArgs) } catch (CABRTException& e) { - warn_client(_("CFileTransfer::Run(): Cannot create and send an archive: ") + e.what()); + warn_client(ssprintf(_("Can't create and send an archive: %s"), e.what())); //update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); } unlink(archivename.c_str()); @@ -358,7 +358,7 @@ void CFileTransfer::Run(const char *pActionDir, const char *pArgs) } catch (CABRTException& e) { - warn_client(_("CFileTransfer::Run(): Cannot create and send an archive: ") + e.what()); + warn_client(ssprintf(_("Can't create and send an archive: "), e.what())); // update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); } unlink(archivename.c_str()); -- cgit From 1202706839ec42299e8794750cec66dfa7db0206 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 6 Nov 2009 17:51:17 +0100 Subject: simplify logging a bit. warn_client() is gone, reuse error_msg() for it. Signed-off-by: Denys Vlasenko --- lib/Plugins/FileTransfer.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/Plugins/FileTransfer.cpp') diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index 8a88fef..2220e94 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -60,12 +60,11 @@ void CFileTransfer::SendFile(const char *pURL, const char *pFilename) int len = strlen(pURL); if (len == 0) { - warn_client(_("FileTransfer: URL not specified")); + error_msg(_("FileTransfer: URL not specified")); return; } - string msg = ssprintf(_("Sending archive %s to %s"), pFilename, pURL); - update_client(msg.c_str()); + update_client(_("Sending archive %s to %s"), pFilename, pURL); string wholeURL = concat_path_file(pURL, pFilename); @@ -332,8 +331,7 @@ void CFileTransfer::Run(const char *pActionDir, const char *pArgs) } catch (CABRTException& e) { - warn_client(ssprintf(_("Can't create and send an archive: %s"), e.what())); - //update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); + error_msg(_("Can't create and send an archive: %s"), e.what()); } unlink(archivename.c_str()); } @@ -358,8 +356,7 @@ void CFileTransfer::Run(const char *pActionDir, const char *pArgs) } catch (CABRTException& e) { - warn_client(ssprintf(_("Can't create and send an archive: "), e.what())); -// update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); + error_msg(_("Can't create and send an archive %s"), e.what()); } unlink(archivename.c_str()); } @@ -381,7 +378,7 @@ void CFileTransfer::SetSettings(const map_plugin_settings_t& pSettings) } else { - warn_client(_("FileTransfer: URL not specified")); + error_msg(_("FileTransfer: URL not specified")); } it = pSettings.find("RetryCount"); -- cgit From 57039b590e4411606795893c90f9871e0412ca31 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 6 Nov 2009 18:26:42 +0100 Subject: give Plugin class a map_plugin_settings_t member This simplifies and unifies get/set settings ops Signed-off-by: Denys Vlasenko --- lib/Plugins/FileTransfer.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/Plugins/FileTransfer.cpp') diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index 2220e94..72b3b16 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -405,16 +405,14 @@ void CFileTransfer::SetSettings(const map_plugin_settings_t& pSettings) } } -map_plugin_settings_t CFileTransfer::GetSettings() +const map_plugin_settings_t& CFileTransfer::GetSettings() { - map_plugin_settings_t ret; + m_pSettings["URL"] = m_sURL; + m_pSettings["RetryCount"] = to_string(m_nRetryCount); + m_pSettings["RetryDelay"] = to_string(m_nRetryDelay); + m_pSettings["ArchiveType"] = m_sArchiveType; - ret["URL"] = m_sURL; - ret["RetryCount"] = to_string(m_nRetryCount); - ret["RetryDelay"] = to_string(m_nRetryDelay); - ret["ArchiveType"] = m_sArchiveType; - - return ret; + return m_pSettings; } PLUGIN_INFO(ACTION, -- cgit