summaryrefslogtreecommitdiffstats
path: root/lib/CommLayer/CommLayerServerDBus.cpp
blob: 029cc91c51ae2cc68f519af9b2823488d88b982e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "CommLayerServerDBus.h"
#include <iostream>
#include "ABRTException.h"

DBus::Connection *CCommLayerServerDBus::init_dbus(CCommLayerServerDBus *self)
{
    CCommLayerServerDBus *server = (CCommLayerServerDBus*) self;
    server->m_pDispatcher = new DBus::Glib::BusDispatcher();
    server->m_pDispatcher->attach(NULL);
    DBus::default_dispatcher = self->m_pDispatcher;
	server->m_pConn = new DBus::Connection(DBus::Connection::SystemBus());
    return server->m_pConn;
}

CCommLayerServerDBus::CCommLayerServerDBus()
: CCommLayerServer(),
  DBus::ObjectAdaptor(*init_dbus(this), CC_DBUS_PATH)
{
    try
    {
        m_pConn->request_name(CC_DBUS_NAME);
    }
    catch(DBus::Error err)
    {
        throw CABRTException(EXCEP_FATAL, std::string(__func__) + 
                             "\nPlease check if:\n"
                             + " * abrt is being run with root permissions\n"
                             + " * you have reloaded the dbus\n"+
                             + "Original exception was:\n " + err.what());
    }

}

CCommLayerServerDBus::~CCommLayerServerDBus()
{
    delete m_pDispatcher;
}

vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pSender)
{
    vector_crash_infos_t crashInfos;
    unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str());
    crashInfos = m_pObserver->GetCrashInfos(to_string(unix_uid));
	return crashInfos;
}
//FIXME: fix CLI and remove this
/*
map_crash_report_t CCommLayerServerDBus::CreateReport(const std::string &pUUID,const std::string &pSender)
{
    unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str());
    map_crash_report_t crashReport;
    crashReport = m_pObserver->CreateReport(pUUID, to_string(unix_uid));
    return crashReport;
}
*/
uint64_t CCommLayerServerDBus::CreateReport_t(const std::string &pUUID,const std::string &pSender)
{
    unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str());
    map_crash_report_t crashReport;
    uint64_t job_id = m_pObserver->CreateReport_t(pUUID, to_string(unix_uid), pSender);
    return job_id;
}

bool CCommLayerServerDBus::Report(map_crash_report_t pReport,const std::string &pSender)
{
    unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str());
    m_pObserver->Report(pReport, to_string(unix_uid));
    return true;
}

bool CCommLayerServerDBus::DeleteDebugDump(const std::string& pUUID, const std::string& pSender)
{
    unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str());
    m_pObserver->DeleteDebugDump(pUUID,to_string(unix_uid));
    return true;
}

map_crash_report_t CCommLayerServerDBus::GetJobResult(uint64_t pJobID, const std::string& pSender)
{
    unsigned long unix_uid = m_pConn->sender_unix_uid(pSender.c_str());
    map_crash_report_t crashReport;
    crashReport = m_pObserver->GetJobResult(pJobID,to_string(unix_uid));
    return crashReport;
}

void CCommLayerServerDBus::Crash(const std::string& arg)
{
    CDBusServer_adaptor::Crash(arg);
}

void CCommLayerServerDBus::AnalyzeComplete(map_crash_report_t arg1)
{
    CDBusServer_adaptor::AnalyzeComplete(arg1);
}

void CCommLayerServerDBus::Error(const std::string& arg1)
{
    CDBusServer_adaptor::Error(arg1);
}

void CCommLayerServerDBus::Update(const std::string& pDest, const std::string& pMessage)
{
    CDBusServer_adaptor::Update(pDest, pMessage);
}

void CCommLayerServerDBus::JobDone(const std::string &pDest, uint64_t pJobID)
{
    CDBusServer_adaptor::JobDone(pDest, pJobID);
}

vector_map_string_string_t CCommLayerServerDBus::GetPluginsInfo()
{
    //FIXME: simplify?
    vector_map_string_string_t plugins_info;
    plugins_info = m_pObserver->GetPluginsInfo();
    return plugins_info;
}