[gnome-bluetooth] Add test-class test binary



commit f550ced056e1a199f620f72dc5de5295b9073905
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jul 23 09:49:37 2009 +0100

    Add test-class test binary

 lib/Makefile.am                |    4 ++-
 lib/bluetooth-client-private.h |    2 +
 lib/bluetooth-client.c         |    5 ++-
 lib/test-class.c               |   49 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 3 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5a8d6c4..9966b08 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -97,7 +97,7 @@ nodist_libcommon_la_SOURCES = $(BUILT_SOURCES)
 
 CLEANFILES = $(BUILT_SOURCES)
 
-noinst_PROGRAMS = test-client test-agent test-deviceselection test-plugins
+noinst_PROGRAMS = test-client test-agent test-deviceselection test-plugins test-class
 
 test_client_LDADD = libcommon.la $(GTK_LIBS) $(DBUS_LIBS)
 
@@ -107,6 +107,8 @@ test_deviceselection_LDADD = libgnome-bluetooth.la
 
 test_plugins_LDADD = libcommon.la
 
+test_class_LDADD = libcommon.la
+
 EXTRA_DIST += marshal.list \
 		bluetooth-client.xml \
 		bluetooth-agent.xml \
diff --git a/lib/bluetooth-client-private.h b/lib/bluetooth-client-private.h
index 63f292e..b773820 100644
--- a/lib/bluetooth-client-private.h
+++ b/lib/bluetooth-client-private.h
@@ -31,6 +31,8 @@
 
 G_BEGIN_DECLS
 
+guint bluetooth_class_to_type (guint32 class);
+
 DBusGProxy *bluetooth_client_get_default_adapter(BluetoothClient *client);
 
 gboolean bluetooth_client_start_discovery(BluetoothClient *client);
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index b087861..29b8c27 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -169,7 +169,8 @@ bluetooth_verify_address (const char *bdaddr)
 	return retval;
 }
 
-static guint class_to_type(guint32 class)
+guint
+bluetooth_class_to_type (guint32 class)
 {
 	switch ((class & 0x1f00) >> 8) {
 	case 0x01:
@@ -638,7 +639,7 @@ static void add_device(DBusGProxy *adapter, GtkTreeIter *parent,
 		name = value ? g_value_get_string(value) : NULL;
 
 		value = g_hash_table_lookup(hash, "Class");
-		type = class_to_type(g_value_get_uint(value));
+		type = bluetooth_class_to_type(g_value_get_uint(value));
 
 		value = g_hash_table_lookup(hash, "Icon");
 		icon = value ? g_value_get_string(value) : "bluetooth";
diff --git a/lib/test-class.c b/lib/test-class.c
new file mode 100644
index 0000000..b62307e
--- /dev/null
+++ b/lib/test-class.c
@@ -0,0 +1,49 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2009  Bastien Nocera <hadess hadess net>
+ *
+ *
+ *  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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+#include "bluetooth-client.h"
+#include "bluetooth-client-private.h"
+
+int main(int argc, char *argv[])
+{
+	GLogLevelFlags fatal_mask;
+	guint class;
+
+	gtk_init(&argc, &argv);
+
+	fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+	fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
+	g_log_set_always_fatal (fatal_mask);
+
+	class = g_ascii_strtoull (argv[1], NULL, 0);
+
+	g_message ("%d %s", bluetooth_class_to_type (class), bluetooth_type_to_string (bluetooth_class_to_type (class)));
+
+	return 0;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]