summaryrefslogtreecommitdiff
path: root/src/tpl-headless-logger-init.c
blob: 82705d7a03ab34ffbf3da20b4b0e283f59812c3b (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
#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/channel-dispatch-operation.h>
#include <telepathy-glib/connection-manager.h>
#include <telepathy-glib/debug.h>

#include <tpl-observer.h>
#include <tpl-log-store-empathy.h>

/* 
 * Initialization of TPL (TelePathy Logger), it futurely set all the
 * inernal structs. tpl_headless_logger_deinit will free/unref them
 */
void tpl_headless_logger_init(void)
{
	TplObserver *observer;
	DBusGConnection *bus;
	TpDBusDaemon *tp_bus;
	GError *error = NULL;

	bus = tp_get_bus();
	tp_bus = tp_dbus_daemon_new(bus);
	
	if ( tp_dbus_daemon_request_name (tp_bus, TPL_OBSERVER_WELL_KNOWN_BUS_NAME,
			TRUE, &error) ) {
		g_print("Well Known name requested successfully!\n");
	} else {
		g_print("Well Known name request error: %s\n", error->message);
		g_clear_error(&error);
		g_error_free(error);
	}


	observer = tpl_observer_new ();
	dbus_g_connection_register_g_object (bus,
			TPL_OBSERVER_OBJECT_PATH,
			G_OBJECT(observer));
}