From 9bd454b43b01fe3d2f3160b68f0e889a8641e427 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Wed, 11 Feb 2009 15:09:03 +0100 Subject: mailx sends relevant data --- lib/Plugins/Mailx.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 8 deletions(-) (limited to 'lib/Plugins/Mailx.cpp') diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 809dbd2..a81ffbe 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -21,23 +21,27 @@ #include "Mailx.h" #include +#include +#include "DebugDump.h" -#define MAILX_COMMAND "mailx" -#define MAILX_SUBJECT "CrashCatcher automated bug report" +#define MAILX_COMMAND "/bin/mailx" +#define MAILX_SUBJECT "\"CrashCatcher automated bug report\"" CMailx::CMailx() : m_sEmailFrom(""), m_sEmailTo(""), - m_sParameters() + m_sParameters(""), + m_sAttachments("") {} void CMailx::SendEmail(const std::string& pText) { FILE* command; - std::string mailx_command = MAILX_COMMAND + m_sParameters + + std::string mailx_command = MAILX_COMMAND + m_sAttachments + + " " + m_sParameters + " -s " + MAILX_SUBJECT + - " -r " + m_sEmailTo + " " + m_sEmailFrom; + " -r " + m_sEmailFrom + " " + m_sEmailTo; command = popen(mailx_command.c_str(), "w"); if (!command) @@ -52,9 +56,63 @@ void CMailx::SendEmail(const std::string& pText) } -void CMailx::Report(const std::string& pDebugDumpPath) +void CMailx::Report(const std::string& pDebugDumpDir) { - SendEmail("Nejakej zbesilej report."); + std::stringstream ss; + std::string data; + CDebugDump dd; + dd.Open(pDebugDumpDir); + + ss << "Common information" << std::endl; + ss << "==================" << std::endl << std::endl; + dd.LoadText(FILENAME_ARCHITECTURE, data); + ss << "Architecture" << std::endl; + ss << "------------" << std::endl; + ss << data << std::endl << std::endl; + dd.LoadText(FILENAME_KERNEL, data); + ss << "Kernel version" << std::endl; + ss << "--------------" << std::endl; + ss << data << std::endl << std::endl; + dd.LoadText(FILENAME_PACKAGE, data); + ss << "Package" << std::endl; + ss << "-------" << std::endl; + ss << data << std::endl << std::endl; + dd.LoadText(FILENAME_EXECUTABLE, data); + ss << "Executable" << std::endl; + ss << "----------" << std::endl; + ss << data << std::endl << std::endl; + ss << "Created report" << std::endl; + ss << "==============" << std::endl; + ss << "Text reports" << std::endl; + ss << "==============" << std::endl; + if (dd.Exist(FILENAME_TEXTDATA1)) + { + dd.LoadText(FILENAME_TEXTDATA1, data); + ss << "Text Data 1" << std::endl; + ss << "-----------" << std::endl; + ss << data << std::endl << std::endl; + } + if (dd.Exist(FILENAME_TEXTDATA2)) + { + dd.LoadText(FILENAME_TEXTDATA2, data); + ss << "Text Data 2" << std::endl; + ss << "-----------" << std::endl; + ss << data << std::endl << std::endl; + } + ss << "Binary reports" << std::endl; + ss << "==============" << std::endl; + ss << "See the attachment[s]" << std::endl; + + if (dd.Exist(FILENAME_BINARYDATA1)) + { + m_sAttachments = " -a " + pDebugDumpDir + "/" + FILENAME_BINARYDATA1; + } + if (dd.Exist(FILENAME_BINARYDATA2)) + { + m_sAttachments = " -a " + pDebugDumpDir + "/" + FILENAME_BINARYDATA2; + } + + SendEmail(ss.str()); } void CMailx::SetSettings(const map_settings_t& pSettings) @@ -65,7 +123,7 @@ void CMailx::SetSettings(const map_settings_t& pSettings) } if (pSettings.find("Email_To")!= pSettings.end()) { - m_sEmailFrom = pSettings.find("Email_To")->second; + m_sEmailTo = pSettings.find("Email_To")->second; } if (pSettings.find("Parameters")!= pSettings.end()) { -- cgit From 8b9c51fff870ef59066878ae818bb3aaf4c04682 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Thu, 12 Feb 2009 09:59:31 +0100 Subject: changed interface of reporter plugins, so user have posibility ti change reported data --- lib/Plugins/Mailx.cpp | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'lib/Plugins/Mailx.cpp') diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index a81ffbe..eb73184 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -56,60 +56,51 @@ void CMailx::SendEmail(const std::string& pText) } -void CMailx::Report(const std::string& pDebugDumpDir) +void CMailx::Report(const report_t& pReport) { std::stringstream ss; - std::string data; - CDebugDump dd; - dd.Open(pDebugDumpDir); ss << "Common information" << std::endl; ss << "==================" << std::endl << std::endl; - dd.LoadText(FILENAME_ARCHITECTURE, data); ss << "Architecture" << std::endl; ss << "------------" << std::endl; - ss << data << std::endl << std::endl; - dd.LoadText(FILENAME_KERNEL, data); + ss << pReport.m_sArchitecture << std::endl << std::endl; ss << "Kernel version" << std::endl; ss << "--------------" << std::endl; - ss << data << std::endl << std::endl; - dd.LoadText(FILENAME_PACKAGE, data); + ss << pReport.m_sKernel << std::endl << std::endl; ss << "Package" << std::endl; ss << "-------" << std::endl; - ss << data << std::endl << std::endl; - dd.LoadText(FILENAME_EXECUTABLE, data); + ss << pReport.m_sPackage << std::endl << std::endl; ss << "Executable" << std::endl; ss << "----------" << std::endl; - ss << data << std::endl << std::endl; + ss << pReport.m_sExecutable << std::endl << std::endl; ss << "Created report" << std::endl; ss << "==============" << std::endl; ss << "Text reports" << std::endl; ss << "==============" << std::endl; - if (dd.Exist(FILENAME_TEXTDATA1)) + if (pReport.m_sTextData1 != "") { - dd.LoadText(FILENAME_TEXTDATA1, data); ss << "Text Data 1" << std::endl; ss << "-----------" << std::endl; - ss << data << std::endl << std::endl; + ss << pReport.m_sTextData1 << std::endl << std::endl; } - if (dd.Exist(FILENAME_TEXTDATA2)) + if (pReport.m_sTextData2 != "") { - dd.LoadText(FILENAME_TEXTDATA2, data); ss << "Text Data 2" << std::endl; ss << "-----------" << std::endl; - ss << data << std::endl << std::endl; + ss << pReport.m_sTextData2 << std::endl << std::endl; } ss << "Binary reports" << std::endl; ss << "==============" << std::endl; ss << "See the attachment[s]" << std::endl; - if (dd.Exist(FILENAME_BINARYDATA1)) + if (pReport.m_bBinaryData1 != "") { - m_sAttachments = " -a " + pDebugDumpDir + "/" + FILENAME_BINARYDATA1; + m_sAttachments = " -a " + pReport.m_bBinaryData1; } - if (dd.Exist(FILENAME_BINARYDATA2)) + if (pReport.m_bBinaryData2 != "") { - m_sAttachments = " -a " + pDebugDumpDir + "/" + FILENAME_BINARYDATA2; + m_sAttachments = " -a " + pReport.m_bBinaryData2; } SendEmail(ss.str()); -- cgit From c93222d1407ede085833d3a91bfeda5f0f910eb4 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Thu, 12 Feb 2009 11:56:02 +0100 Subject: added new crash information, "cmdline" --- lib/Plugins/Mailx.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/Plugins/Mailx.cpp') diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index eb73184..cb26e39 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -74,6 +74,9 @@ void CMailx::Report(const report_t& pReport) ss << "Executable" << std::endl; ss << "----------" << std::endl; ss << pReport.m_sExecutable << std::endl << std::endl; + ss << "CmdLine" << std::endl; + ss << "----------" << std::endl; + ss << pReport.m_sCmdLine << std::endl << std::endl; ss << "Created report" << std::endl; ss << "==============" << std::endl; ss << "Text reports" << std::endl; -- cgit