diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Plugins/Mailx.cpp | 74 | ||||
-rw-r--r-- | lib/Plugins/Mailx.h | 3 |
2 files changed, 68 insertions, 9 deletions
diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 809dbd23..a81ffbe8 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -21,23 +21,27 @@ #include "Mailx.h" #include <stdio.h> +#include <sstream> +#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()) { diff --git a/lib/Plugins/Mailx.h b/lib/Plugins/Mailx.h index 4a1d61b3..789af614 100644 --- a/lib/Plugins/Mailx.h +++ b/lib/Plugins/Mailx.h @@ -33,6 +33,7 @@ class CMailx : public CReporter std::string m_sEmailFrom; std::string m_sEmailTo; std::string m_sParameters; + std::string m_sAttachments; void SendEmail(const std::string& pText); @@ -43,7 +44,7 @@ class CMailx : public CReporter void DeInit() {} void SetSettings(const map_settings_t& pSettings); - void Report(const std::string& pDebugDumpPath); + void Report(const std::string& pDebugDumpDir); }; |