-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBusSafWorkers.cpp
59 lines (48 loc) · 1.16 KB
/
DBusSafWorkers.cpp
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
/*
* File: DBusSafWorkers.cpp
* Author: Saleem Edah-Tally - nmset@yandex.com
* License : GPL v2
* Copyright Saleem Edah-Tally - © 2017
*
* Created on 7 mai 2017, 15:18
*/
#include "gcc_version.h"
#include "DBusSafWorkers.h"
#include <gloox/message.h>
#include <signal.h>
using namespace std;
extern bool g_verbose;
DBusSafAdaptor::DBusSafAdaptor(DBus::Connection &connection, Connector * connector, SAFConnListener * saf)
: DBus::ObjectAdaptor(connection, "/xmpp/saf")
{
m_connector = connector;
m_saf = saf;
thread t(Entry);
t.detach();
}
DBusSafAdaptor::~DBusSafAdaptor()
{
DBus::default_dispatcher->leave();
}
int DBusSafAdaptor::Entry()
{
DBus::default_dispatcher->enter(); // IS BLOCKING
return 0;
}
void DBusSafAdaptor::Quit()
{
// Handled in main.cpp
raise(SIGTERM);
}
void DBusSafAdaptor::SendMsg(const std::string& recipient, const std::string& msg)
{
const Message m(Message::MessageType::Chat, recipient, msg);
m_saf->GetClient()->send(m);
}
DBusSafProxy::DBusSafProxy(DBus::Connection& connection, const char* service)
: DBus::ObjectProxy(connection, "/xmpp/saf", service)
{
}
DBusSafProxy::~DBusSafProxy()
{
}