summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/Mailx.cpp
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-02-11 15:09:03 +0100
committerZdenek Prikryl <zprikryl@redhat.com>2009-02-11 15:09:03 +0100
commit9bd454b43b01fe3d2f3160b68f0e889a8641e427 (patch)
tree34b5baed186be352de4345a2a6492032e23344e4 /lib/Plugins/Mailx.cpp
parent08ec10a5f6a2d6159e926cb075ad3eb4964ced50 (diff)
downloadabrt-9bd454b43b01fe3d2f3160b68f0e889a8641e427.tar.gz
abrt-9bd454b43b01fe3d2f3160b68f0e889a8641e427.tar.xz
abrt-9bd454b43b01fe3d2f3160b68f0e889a8641e427.zip
mailx sends relevant data
Diffstat (limited to 'lib/Plugins/Mailx.cpp')
-rw-r--r--lib/Plugins/Mailx.cpp74
1 files changed, 66 insertions, 8 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())
{