#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <time.h>
#include "config.h"
#define NAME "bluez-session"
struct impl;
struct object;
struct node {
struct impl *impl;
struct object *object;
uint32_t id;
};
struct object {
struct impl *impl;
uint32_t id;
};
struct impl {
struct timespec now;
};
static struct node *find_node(struct object *obj, uint32_t id)
{
struct node *node;
if (node->id == id)
return node;
}
return NULL;
}
static void update_node(struct object *obj, struct node *node,
{
}
static struct node *create_node(struct object *obj, uint32_t id,
{
struct node *node;
struct impl *impl = obj->impl;
int res;
void *iface;
return NULL;
info->props);
if (handle == NULL) {
goto exit;
}
goto unload_handle;
}
node = calloc(1, sizeof(*node));
if (node == NULL)
goto unload_handle;
node->impl = impl;
node->object = obj;
node->id = id;
node->handle = handle;
node->node = iface;
info->
type, info->props, node->node, 0);
if (node->proxy == NULL)
goto clean_node;
update_node(obj, node, info);
return node;
clean_node:
free(node);
unload_handle:
exit:
return NULL;
}
static void remove_node(struct object *obj, struct node *node)
{
free(node->handle);
free(node);
}
static void device_object_info(void *data, uint32_t id,
{
struct object *obj = data;
struct node *node;
node = find_node(obj, id);
if (info == NULL) {
if (node == NULL) {
return;
}
remove_node(obj, node);
} else if (node == NULL) {
create_node(obj, id, info);
} else {
update_node(obj, node, info);
}
}
.object_info = device_object_info
};
static struct object *find_object(struct impl *impl, uint32_t id)
{
struct object *obj;
if (obj->id == id)
return obj;
}
return NULL;
}
static void update_object(struct impl *impl, struct object *obj,
{
}
static struct object *create_object(struct impl *impl, uint32_t id,
{
struct object *obj;
int res;
void *iface;
return NULL;
info->props);
if (handle == NULL) {
goto exit;
}
goto unload_handle;
}
obj = calloc(1, sizeof(*obj));
if (obj == NULL)
goto unload_handle;
obj->impl = impl;
obj->id = id;
obj->handle = handle;
obj->device = iface;
info->
type, info->props, obj->device, 0);
if (obj->proxy == NULL)
goto clean_object;
&obj->listener, &device_events, obj);
update_object(impl, obj, info);
return obj;
clean_object:
free(obj);
unload_handle:
exit:
return NULL;
}
static void remove_object(struct impl *impl, struct object *obj)
{
free(obj->handle);
free(obj);
}
static void dbus_device_object_info(void *data, uint32_t id,
{
struct impl *impl = data;
struct object *obj;
obj = find_object(impl, id);
if (info == NULL) {
if (obj == NULL)
return;
remove_object(impl, obj);
} else if (obj == NULL) {
if (create_object(impl, id, info) == NULL)
return;
} else {
update_object(impl, obj, info);
}
}
{
.object_info = dbus_device_object_info,
};
static int start_monitor(struct impl *impl)
{
int res;
void *iface;
if (handle == NULL) {
res = -errno;
goto out;
}
goto out_unload;
}
impl->handle = handle;
impl->device = iface;
return 0;
out_unload:
out:
return res;
}
static void on_core_error(void *data, uint32_t id, int seq, int res, const char *message)
{
struct impl *impl = data;
}
.error = on_core_error,
};
int main(int argc, char *argv[])
{
struct impl impl = { 0, };
int res;
clock_gettime(CLOCK_MONOTONIC, &impl.now);
if (impl.core == NULL) {
return -1;
}
&impl.core_listener,
&core_events, &impl);
if ((res = start_monitor(&impl)) < 0) {
return -1;
}
return 0;
}