blob: b47ad398af6fcbcaf3e03230d86394b767fc6546 (
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
|
#include "propsgs-client.h"
#include <signal.h>
#include <iostream>
using namespace org::freedesktop::DBus;
#define P(x) std::cout << #x << " = " << x << std::endl;
static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties";
static const char *PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties";
PropsClient::PropsClient(DBus::Connection &connection, const char *path, const char *name)
: DBus::ObjectProxy(connection, path, name)
{
}
void PropsClient::MessageChanged(const std::string& message){
std::cout << "message received: " << message << std::endl;
};
DBus::BusDispatcher dispatcher;
PropsClient * client;
void niam(int sig)
{
dispatcher.leave();
pthread_exit(NULL);
delete client;
}
#include <pthread.h>
void * test_property_proxy(void * input){
P("1");
sleep(2);
P(client->Version());
P("2");
sleep(1);
P(client->Message());
P("3");
sleep(1);
client->Message( "message set by property access" );
P("4");
sleep(1);
P(client->Message());
P("5");
sleep(1);
client->Data( 1.1 );
}
int main()
{
signal(SIGTERM, niam);
signal(SIGINT, niam);
DBus::default_dispatcher = &dispatcher;
DBus::Connection conn = DBus::Connection::SessionBus();
client = new PropsClient(conn, PROPS_SERVER_PATH, PROPS_SERVER_NAME );
pthread_t thread;
pthread_create(&thread, NULL, test_property_proxy, 0);
P("dispatcher.enter();");
dispatcher.enter();
return 0;
}
|