summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-03-04 11:37:30 +0100
committerZdenek Prikryl <zprikryl@redhat.com>2009-03-04 11:37:30 +0100
commit4eaf8b24b495aa654def79d1d4a5d6b3d1ade39b (patch)
tree8e87bc637db01b70e041a81b24b1bb4629f97e92
parent02f9b4ad59a0bc4a0b7969d05816e78ec8c9c8f0 (diff)
downloadabrt-4eaf8b24b495aa654def79d1d4a5d6b3d1ade39b.tar.gz
abrt-4eaf8b24b495aa654def79d1d4a5d6b3d1ade39b.tar.xz
abrt-4eaf8b24b495aa654def79d1d4a5d6b3d1ade39b.zip
changed class name
-rw-r--r--lib/MiddleWare/Makefile.am2
-rw-r--r--lib/MiddleWare/MiddleWare.cpp26
-rw-r--r--lib/MiddleWare/MiddleWare.h4
-rw-r--r--lib/MiddleWare/RPM.cpp45
-rw-r--r--lib/MiddleWare/RPM.h9
5 files changed, 49 insertions, 37 deletions
diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am
index d1eb98b6..27eda453 100644
--- a/lib/MiddleWare/Makefile.am
+++ b/lib/MiddleWare/Makefile.am
@@ -3,7 +3,7 @@ libMiddleWare_la_SOURCES = MiddleWare.cpp MiddleWare.h PluginManager.cpp \
PluginManager.h ABRTPlugin.cpp \
ABRTPlugin.h DynamicLibrary.cpp \
DynamicLibrary.h Settings.h Settings.cpp \
- RPMInfo.cpp RPMInfo.h Plugin.h CrashTypes.h \
+ RPM.cpp RPM.h Plugin.h CrashTypes.h \
MiddleWareTypes.h Application.h Database.h \
Reporter.h Language.h
libMiddleWare_la_LIBADD = $(DL_LIBS) ../Utils/libUtils.la $(RPM_LIBS)
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp
index 20ee48a9..0d7fdf6b 100644
--- a/lib/MiddleWare/MiddleWare.cpp
+++ b/lib/MiddleWare/MiddleWare.cpp
@@ -68,7 +68,7 @@ void CMiddleWare::LoadSettings(const std::string& pPath)
set_opengpg_keys_t::iterator it_k;
for (it_k = m_setOpenGPGKeys.begin(); it_k != m_setOpenGPGKeys.end(); it_k++)
{
- m_RPMInfo.LoadOpenGPGPublicKey(*it_k);
+ m_RPM.LoadOpenGPGPublicKey(*it_k);
}
}
if (settings.find("EnableOpenGPG") != settings.end())
@@ -281,10 +281,16 @@ int CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir, crash_info_t& p
dd.Open(pDebugDumpDir);
dd.LoadText(FILENAME_EXECUTABLE, executable);
- package = m_RPMInfo.GetPackage(executable, description);
- if (executable != "kernel")
+ if (executable == "kernel")
{
+ package = "kernel";
+ description = m_RPM.GetDescription(executable);
+ }
+ else
+ {
+ package = m_RPM.GetPackage(executable);
std::string packageName = package.substr(0, package.rfind("-", package.rfind("-") - 1));
+ description = m_RPM.GetDescription(executable);
if (packageName == "" ||
(m_setBlackList.find(packageName) != m_setBlackList.end()))
{
@@ -294,8 +300,8 @@ int CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir, crash_info_t& p
}
if (m_bOpenGPGCheck)
{
- if (!m_RPMInfo.CheckFingerprint(packageName) ||
- !m_RPMInfo.CheckHash(packageName, executable))
+ if (!m_RPM.CheckFingerprint(packageName) ||
+ !m_RPM.CheckHash(packageName, executable))
{
dd.Delete();
dd.Close();
@@ -303,16 +309,6 @@ int CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir, crash_info_t& p
}
}
}
- else
- {
- package = "kernel";
- description = "The Linux kernel";
- description += "\n\n";
- description += "The kernel contains the Linux kernel (vmlinuz), the core of any"
- "Linux operating system. The kernel handles the basic functions"
- "of the operating system: memory allocation, process allocation, device"
- "input and output, etc.";
- }
dd.SaveText(FILENAME_PACKAGE, package);
dd.SaveText(FILENAME_DESCRIPTION, description);
diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h
index a492257b..9de12d0f 100644
--- a/lib/MiddleWare/MiddleWare.h
+++ b/lib/MiddleWare/MiddleWare.h
@@ -27,7 +27,7 @@
#include "PluginManager.h"
#include "CrashTypes.h"
#include "MiddleWareTypes.h"
-#include "RPMInfo.h"
+#include "RPM.h"
class CMiddleWare
{
@@ -39,7 +39,7 @@ class CMiddleWare
typedef std::map<std::string, set_reporters_t> map_plugin2reporters_t;
CPluginManager* m_pPluginManager;
- CRPMInfo m_RPMInfo;
+ CRPM m_RPM;
set_blacklist_t m_setBlackList;
set_enabled_plugins_t m_setEnabledPlugins;
set_opengpg_keys_t m_setOpenGPGKeys;
diff --git a/lib/MiddleWare/RPM.cpp b/lib/MiddleWare/RPM.cpp
index 971148b4..409959e4 100644
--- a/lib/MiddleWare/RPM.cpp
+++ b/lib/MiddleWare/RPM.cpp
@@ -1,18 +1,18 @@
-#include "RPMInfo.h"
+#include "RPM.h"
#include <iostream>
-CRPMInfo::CRPMInfo()
+CRPM::CRPM()
{
char *argv[] = {(char*)""};
m_poptContext = rpmcliInit(0, argv, NULL);
}
-CRPMInfo::~CRPMInfo()
+CRPM::~CRPM()
{
rpmcliFini(m_poptContext);
}
-void CRPMInfo::LoadOpenGPGPublicKey(const std::string& pFileName)
+void CRPM::LoadOpenGPGPublicKey(const std::string& pFileName)
{
uint8_t* pkt = NULL;
size_t pklen;
@@ -20,7 +20,7 @@ void CRPMInfo::LoadOpenGPGPublicKey(const std::string& pFileName)
if (pgpReadPkts(pFileName.c_str(), &pkt, &pklen) != PGPARMOR_PUBKEY)
{
free(pkt);
- std::cerr << "CRPMInfo::LoadOpenGPGPublicKey(): Can not load public key " + pFileName << std::endl;
+ std::cerr << "CRPM::LoadOpenGPGPublicKey(): Can not load public key " + pFileName << std::endl;
return;
}
if (pgpPubkeyFingerprint(pkt, pklen, keyID) == 0)
@@ -34,7 +34,7 @@ void CRPMInfo::LoadOpenGPGPublicKey(const std::string& pFileName)
free(pkt);
}
-bool CRPMInfo::CheckFingerprint(const std::string& pPackage)
+bool CRPM::CheckFingerprint(const std::string& pPackage)
{
bool ret = false;
rpmts ts = rpmtsCreate();
@@ -64,7 +64,7 @@ bool CRPMInfo::CheckFingerprint(const std::string& pPackage)
return ret;
}
-bool CRPMInfo::CheckHash(const std::string& pPackage, const std::string& pPath)
+bool CRPM::CheckHash(const std::string& pPackage, const std::string& pPath)
{
bool ret = false;
rpmts ts = rpmtsCreate();
@@ -98,7 +98,29 @@ bool CRPMInfo::CheckHash(const std::string& pPackage, const std::string& pPath)
return ret;
}
-std::string CRPMInfo::GetPackage(const std::string& pFileName, std::string& pDescription)
+std::string CRPM::GetDescription(const std::string& pPackage)
+{
+ std::string pDescription = "";
+ rpmts ts = rpmtsCreate();
+ rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage.c_str(), 0);
+ Header header;
+ if ((header = rpmdbNextIterator(iter)) != NULL)
+ {
+ rpmtd td = rpmtdNew();
+ headerGet(header, RPMTAG_SUMMARY, td, HEADERGET_DEFAULT);
+ const char* summary = rpmtdGetString(td);
+ headerGet(header, RPMTAG_DESCRIPTION, td, HEADERGET_DEFAULT);
+ const char* description = rpmtdGetString(td);
+ pDescription = summary + std::string("\n\n") + description;
+ rpmtdFree(td);
+
+ }
+ rpmdbFreeIterator(iter);
+ rpmtsFree(ts);
+ return pDescription;
+}
+
+std::string CRPM::GetPackage(const std::string& pFileName)
{
std::string ret = "";
rpmts ts = rpmtsCreate();
@@ -112,13 +134,6 @@ std::string CRPMInfo::GetPackage(const std::string& pFileName, std::string& pDes
ret = nerv;
free(nerv);
}
- rpmtd td = rpmtdNew();
- headerGet(header, RPMTAG_SUMMARY, td, HEADERGET_DEFAULT);
- const char* summary = rpmtdGetString(td);
- headerGet(header, RPMTAG_DESCRIPTION, td, HEADERGET_DEFAULT);
- const char* description = rpmtdGetString(td);
- pDescription = summary + std::string("\n\n") + description;
- rpmtdFree(td);
}
rpmdbFreeIterator(iter);
diff --git a/lib/MiddleWare/RPM.h b/lib/MiddleWare/RPM.h
index f2d00aac..00196f7e 100644
--- a/lib/MiddleWare/RPM.h
+++ b/lib/MiddleWare/RPM.h
@@ -29,7 +29,7 @@
#include <rpm/rpmts.h>
#include <rpm/rpmdb.h>
-class CRPMInfo
+class CRPM
{
private:
@@ -39,14 +39,15 @@ class CRPMInfo
set_fingerprints_t m_setFingerprints;
public:
- CRPMInfo();
- ~CRPMInfo();
+ CRPM();
+ ~CRPM();
void LoadOpenGPGPublicKey(const std::string& pFileName);
bool CheckFingerprint(const std::string& pPackage);
bool CheckHash(const std::string& pPackage, const std::string&pPath);
- std::string GetPackage(const std::string& pFileName, std::string& pDescription);
+ std::string GetDescription(const std::string& pPackage);
+ std::string GetPackage(const std::string& pFileName);
};
#endif /* RPMINFO_H_ */