blob: 5bcecf279392c3e86c01a9214e5c40f5e5b298be (
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#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;
}
vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pDBusSender)
{
vector_crash_infos_t retval;
unsigned long unix_uid = m_pConn->sender_unix_uid(pDBusSender.c_str());
try
{
retval = m_pMW->GetCrashInfos(to_string(unix_uid));
}
catch(std::string err)
{
std::cerr << err << std::endl;
}
Notify("Sent crash info");
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;
}
map_crash_report_t CCommLayerServerDBus::CreateReport(const std::string &pUUID,const std::string &pDBusSender)
{
unsigned long unix_uid = m_pConn->sender_unix_uid(pDBusSender.c_str());
//std::cerr << pUUID << ":" << unix_uid << std::endl;
map_crash_report_t crashReport;
std::cerr << "Creating report" << std::endl;
try
{
m_pMW->CreateCrashReport(pUUID,to_string(unix_uid), crashReport);
//send out the message about completed analyze
CDBusServer_adaptor::AnalyzeComplete(crashReport);
}
catch(std::string err)
{
CDBusServer_adaptor::Error(err);
std::cerr << err << std::endl;
}
return crashReport;
}
bool CCommLayerServerDBus::Report(map_crash_report_t 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(pReport);
}
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;
}
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);
}
|