blob: 33bb2f9b40fd51a7b5539b60045b6545c1796a3f (
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
118
119
|
#include "CommLayerServerDBus.h"
#include <iostream>
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(CMiddleWare *pMW)
: CCommLayerServer(pMW),
DBus::ObjectAdaptor(*init_dbus(this), CC_DBUS_PATH)
{
std::cerr << "CCommLayerDBus init.." << std::endl;
m_pConn->request_name(CC_DBUS_NAME);
}
CCommLayerServerDBus::~CCommLayerServerDBus()
{
std::cout << "Cleaning up dbus" << std::endl;
delete m_pDispatcher;
}
dbus_vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pUID)
{
dbus_vector_crash_infos_t retval;
vector_crash_infos_t crash_info;
m_pMW->GetCrashInfos("501");
for (vector_crash_infos_t::iterator it = crash_info.begin(); it!=crash_info.end(); ++it) {
std::cerr << it->m_sExecutable << std::endl;
}
return retval;
}
dbus_vector_map_crash_infos_t CCommLayerServerDBus::GetCrashInfosMap(const std::string &pDBusSender)
{
dbus_vector_map_crash_infos_t retval;
vector_crash_infos_t crash_info;
unsigned long unix_uid = m_pConn->sender_unix_uid(pDBusSender.c_str());
try
{
crash_info = m_pMW->GetCrashInfos(to_string(unix_uid));
}
catch(std::string err)
{
std::cerr << err << std::endl;
}
for (vector_crash_infos_t::iterator it = crash_info.begin(); it!=crash_info.end(); ++it) {
std::cerr << it->m_sExecutable << std::endl;
retval.push_back(it->GetMap());
}
Notify("Sent crash info");
return retval;
}
dbus_vector_crash_report_info_t CCommLayerServerDBus::CreateReport(const std::string &pUUID,const std::string &pDBusSender)
{
dbus_vector_crash_report_info_t retval;
unsigned long unix_uid = m_pConn->sender_unix_uid(pDBusSender.c_str());
//std::cerr << pUUID << ":" << unix_uid << std::endl;
crash_report_t crashReport;
std::cerr << "Creating report" << std::endl;
try
{
m_pMW->CreateCrashReport(pUUID,to_string(unix_uid), crashReport);
retval = crash_report_to_vector_strings(crashReport);
//send out the message about completed analyze
CDBusServer_adaptor::AnalyzeComplete(retval);
}
catch(std::string err)
{
CDBusServer_adaptor::Error(err);
std::cerr << err << std::endl;
}
return retval;
}
bool CCommLayerServerDBus::Report(dbus_vector_crash_report_info_t pReport)
{
crash_report_t crashReport = vector_strings_to_crash_report(pReport);
//#define FIELD(X) crashReport.m_s##X = pReport[#X];
//crashReport.m_sUUID = pReport["UUID"];
//ALL_CRASH_REPORT_FIELDS;
//#undef FIELD
//for (dbus_map_report_info_t::iterator it = pReport.begin(); it!=pReport.end(); ++it) {
// std::cerr << it->second << std::endl;
//}
try
{
m_pMW->Report(crashReport);
}
catch(std::string err)
{
std::cerr << err << std::endl;
return false;
}
return true;
}
bool CCommLayerServerDBus::DeleteDebugDump(const std::string& pUUID, const std::string& pDBusSender)
{
unsigned long unix_uid = m_pConn->sender_unix_uid(pDBusSender.c_str());
try
{
//std::cerr << "DeleteDebugDump(" << pUUID << "," << unix_uid << ")" << std::endl;
m_pMW->DeleteCrashInfo(pUUID,to_string(unix_uid), true);
}
catch(std::string err)
{
std::cerr << err << std::endl;
return false;
}
return true;
}
|