summaryrefslogtreecommitdiff
path: root/src/lib/helpers.h
blob: c7d7c95cc347e4de48a9292ac2568d178c7a7915 (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
/*
 *
 *  bluez-tools - a set of tools to manage bluetooth devices for linux
 *
 *  Copyright (C) 2010  Alexander Orlenko <zxteam@gmail.com>
 *
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifndef __HELPERS_H
#define __HELPERS_H

#include <stdio.h>
#include <glib.h>

/* Bluez DBus Interfaces */
#include "adapter.h"
#include "device.h"
#include "audio.h"
#include "input.h"
#include "network.h"
#include "network_hub.h"
#include "network_peer.h"
#include "network_router.h"
#include "serial.h"

/* OBEX DBus Interfaces */
#include "obexmanager.h"
#include "obexsession.h"
#include "obexserver.h"
#include "obexserver_session.h"

enum {
	DEVICE_INTF,

	/* BlueZ Interfaces */
	AUDIO_INTF,
	INPUT_INTF,
	NETWORK_INTF,
	NETWORK_HUB_INTF,
	NETWORK_PEER_INTF,
	NETWORK_ROUTER_INTF,
	SERIAL_INTF,

	/* OBEX Interfaces */
	OBEXMANAGER_INTF,
	OBEXSESSION_INRF,
	OBEXSERVER_INTF,
	OBEXSERVER_SESSION_INTF,
};

/* Adapter helpers */
Adapter *find_adapter(const gchar *name, GError **error);

/* Device helpers */
Device *find_device(Adapter *adapter, const gchar *name, GError **error);

/* Others helpers */
#define exit_if_error(error) G_STMT_START{ \
if (error) { \
	g_printerr("%s\n", error->message); \
	exit(EXIT_FAILURE); \
}; }G_STMT_END

inline int xtoi(const gchar *str)
{
	int i = 0;
	sscanf(str, "0x%x", &i);
	return i;
}

const gchar *uuid2name(const gchar *uuid);
const gchar *name2uuid(const gchar *name);

/* Interface helpers */
gboolean intf_is_supported(const gchar *dbus_object_path, int intf_id);

#endif /* __HELPERS_H */