summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Orlenko <zxteam@gmail.com>2010-08-09 16:01:57 +1100
committerAlexander Orlenko <zxteam@gmail.com>2010-08-09 16:01:57 +1100
commit2ebd9e865dcb3fd0e5c0007c25636ee754d4813a (patch)
tree513aeb9cf933fb89bef286929c16d328dcaadb70 /src
parentda8f4e34ae3c1bbff5d46a8a44cf42c6f12c3221 (diff)
downloadbluez-tools-2ebd9e865dcb3fd0e5c0007c25636ee754d4813a.tar.gz
Refactoring of code
Removed ODS API Some impl of bt-obex
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am25
-rw-r--r--src/bt-adapter.c18
-rw-r--r--src/bt-agent.c20
-rw-r--r--src/bt-audio.c18
-rw-r--r--src/bt-device.c36
-rw-r--r--src/bt-input.c18
-rw-r--r--src/bt-monitor.c24
-rw-r--r--src/bt-network.c219
-rw-r--r--src/bt-obex.c541
-rw-r--r--src/bt-serial.c33
-rw-r--r--src/lib/bluez/adapter.c5
-rw-r--r--src/lib/bluez/agent.c3
-rw-r--r--src/lib/bluez/audio.c5
-rw-r--r--src/lib/bluez/device.c5
-rw-r--r--src/lib/bluez/input.c5
-rw-r--r--src/lib/bluez/manager.c5
-rw-r--r--src/lib/bluez/network.c5
-rw-r--r--src/lib/bluez/network_server.c5
-rw-r--r--src/lib/bluez/serial.c5
-rw-r--r--src/lib/dbus-common.c23
-rw-r--r--src/lib/dbus-common.h1
-rw-r--r--src/lib/helpers.c92
-rw-r--r--src/lib/helpers.h28
-rw-r--r--src/lib/marshallers.c234
-rw-r--r--src/lib/marshallers.h56
-rw-r--r--src/lib/marshallers.list12
-rw-r--r--src/lib/obexd/obexagent.c162
-rw-r--r--src/lib/obexd/obexagent.h2
-rw-r--r--src/lib/obexd/obexclient.c5
-rw-r--r--src/lib/obexd/obexclient_file_transfer.c5
-rw-r--r--src/lib/obexd/obexclient_session.c5
-rw-r--r--src/lib/obexd/obexclient_transfer.c5
-rw-r--r--src/lib/obexd/obexmanager.c5
-rw-r--r--src/lib/obexd/obexsession.c5
-rw-r--r--src/lib/obexd/obextransfer.c5
-rw-r--r--src/lib/ods-api.h40
-rw-r--r--src/lib/ods/obexmanager.c264
-rw-r--r--src/lib/ods/obexmanager.h73
-rw-r--r--src/lib/ods/obexserver.c373
-rw-r--r--src/lib/ods/obexserver.h73
-rw-r--r--src/lib/ods/obexserver_session.c351
-rw-r--r--src/lib/ods/obexserver_session.h71
-rw-r--r--src/lib/ods/obexsession.c496
-rw-r--r--src/lib/ods/obexsession.h85
44 files changed, 727 insertions, 2739 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5ba6fed..b0442f3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,27 +30,22 @@ obexd_sources = lib/obexd/obexagent.c lib/obexd/obexagent.h \
lib/obexd/obexsession.c lib/obexd/obexsession.h \
lib/obexd/obextransfer.c lib/obexd/obextransfer.h
-ods_sources = lib/ods/obexmanager.c lib/ods/obexmanager.h \
- lib/ods/obexserver.c lib/ods/obexserver.h \
- lib/ods/obexserver_session.c lib/ods/obexserver_session.h \
- lib/ods/obexsession.c lib/ods/obexsession.h
-
lib_sources = lib/marshallers.c lib/marshallers.h \
lib/dbus-common.c lib/dbus-common.h \
lib/helpers.c lib/helpers.h \
lib/sdp.c lib/sdp.h \
- lib/bluez-api.h lib/obexd-api.h lib/ods-api.h
+ lib/bluez-api.h lib/obexd-api.h
bin_PROGRAMS = bt-monitor bt-adapter bt-agent bt-device bt-input bt-audio bt-network bt-serial bt-obex
-bt_monitor_SOURCES = $(lib_sources) $(bluez_sources) bt-monitor.c
-bt_adapter_SOURCES = ${lib_sources} $(bluez_sources) bt-adapter.c
-bt_agent_SOURCES = $(lib_sources) $(bluez_sources) bt-agent.c
-bt_device_SOURCES = $(lib_sources) $(bluez_sources) bt-device.c
-bt_input_SOURCES = $(lib_sources) $(bluez_sources) bt-input.c
-bt_audio_SOURCES = $(lib_sources) $(bluez_sources) bt-audio.c
-bt_network_SOURCES = $(lib_sources) $(bluez_sources) bt-network.c
-bt_serial_SOURCES = $(lib_sources) $(bluez_sources) bt-serial.c
-bt_obex_SOURCES = $(lib_sources) $(bluez_sources) $(ods_sources) bt-obex.c
+bt_monitor_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-monitor.c
+bt_adapter_SOURCES = ${lib_sources} $(bluez_sources) $(obexd_sources) bt-adapter.c
+bt_agent_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-agent.c
+bt_device_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-device.c
+bt_input_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-input.c
+bt_audio_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-audio.c
+bt_network_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-network.c
+bt_serial_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-serial.c
+bt_obex_SOURCES = $(lib_sources) $(bluez_sources) $(obexd_sources) bt-obex.c
CLEANFILES = Makefile.in \
lib/marshallers.c lib/marshallers.h
diff --git a/src/bt-adapter.c b/src/bt-adapter.c
index e34cb3d..f6404ea 100644
--- a/src/bt-adapter.c
+++ b/src/bt-adapter.c
@@ -29,7 +29,9 @@
#include <string.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/bluez-api.h"
static void adapter_device_found(Adapter *adapter, const gchar *address, GHashTable *values, gpointer data)
{
@@ -64,7 +66,7 @@ static void adapter_device_disappeared(Adapter *adapter, const gchar *address, g
g_print("Device disappeared: %s (%s)\n", g_value_get_string(g_hash_table_lookup(found_devices, address)), address);
}
-*/
+ */
static void adapter_property_changed(Adapter *adapter, const gchar *name, const GValue *value, gpointer data)
{
@@ -99,6 +101,7 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new("- a bluetooth adapter manager");
g_option_context_add_main_entries(context, entries, NULL);
@@ -132,8 +135,15 @@ int main(int argc, char *argv[])
g_option_context_free(context);
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
exit(EXIT_FAILURE);
}
diff --git a/src/bt-agent.c b/src/bt-agent.c
index 3af0f5b..0f655d9 100644
--- a/src/bt-agent.c
+++ b/src/bt-agent.c
@@ -30,7 +30,9 @@
#include <signal.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/bluez-api.h"
static gboolean need_unregister = TRUE;
static GMainLoop *mainloop = NULL;
@@ -65,6 +67,7 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new(" - a bluetooth agent");
g_option_context_add_main_entries(context, entries, NULL);
@@ -82,8 +85,15 @@ int main(int argc, char *argv[])
g_option_context_free(context);
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
exit(EXIT_FAILURE);
}
@@ -96,7 +106,7 @@ int main(int argc, char *argv[])
Agent *agent = g_object_new(AGENT_TYPE, NULL);
- adapter_register_agent(adapter, DBUS_AGENT_PATH, "DisplayYesNo", &error);
+ adapter_register_agent(adapter, AGENT_DBUS_PATH, "DisplayYesNo", &error);
exit_if_error(error);
g_signal_connect(agent, "AgentReleased", G_CALLBACK(agent_released), mainloop);
@@ -111,7 +121,7 @@ int main(int argc, char *argv[])
g_main_loop_run(mainloop);
if (need_unregister) {
- adapter_unregister_agent(adapter, DBUS_AGENT_PATH, &error);
+ adapter_unregister_agent(adapter, AGENT_DBUS_PATH, &error);
exit_if_error(error);
/* Waiting for AgentReleased signal */
diff --git a/src/bt-audio.c b/src/bt-audio.c
index 2bc555e..067135d 100644
--- a/src/bt-audio.c
+++ b/src/bt-audio.c
@@ -29,7 +29,9 @@
#include <string.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/bluez-api.h"
static void audio_property_changed(Audio *audio, const gchar *name, const GValue *value, gpointer data)
{
@@ -66,6 +68,7 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new("- a bluetooth generic audio manager");
g_option_context_add_main_entries(context, entries, NULL);
@@ -86,8 +89,15 @@ int main(int argc, char *argv[])
g_option_context_free(context);
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
exit(EXIT_FAILURE);
}
@@ -97,7 +107,7 @@ int main(int argc, char *argv[])
Device *device = find_device(adapter, connect_arg != NULL ? connect_arg : disconnect_arg, &error);
exit_if_error(error);
- if (!intf_is_supported(device_get_dbus_object_path(device), AUDIO_INTF)) {
+ if (!intf_supported(BLUEZ_DBUS_NAME, device_get_dbus_object_path(device), AUDIO_DBUS_INTERFACE)) {
g_printerr("Audio service is not supported by this device\n");
exit(EXIT_FAILURE);
}
diff --git a/src/bt-device.c b/src/bt-device.c
index abc2dd6..b15aa5b 100644
--- a/src/bt-device.c
+++ b/src/bt-device.c
@@ -29,7 +29,10 @@
#include <string.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/sdp.h"
+#include "lib/bluez-api.h"
enum {
REC,
@@ -45,6 +48,7 @@ enum {
static int xml_t[LAST_E] = {0, 0, 0, 0, -1, -1};
+/* Main arguments */
static gchar *adapter_arg = NULL;
static gboolean list_arg = FALSE;
static gchar *connect_arg = NULL;
@@ -248,6 +252,7 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new("- a bluetooth device manager");
g_option_context_add_main_entries(context, entries, NULL);
@@ -255,13 +260,15 @@ int main(int argc, char *argv[])
g_option_context_set_description(context,
"Services Options:\n"
" -s, --services <name|mac> [<pattern>]\n"
- " Where `pattern` is an optional specific UUID\n\n"
+ " Where `pattern` is an optional specific UUID to search\n\n"
"Set Options:\n"
" --set <name|mac> <property> <value>\n"
- " Where `property` is one of:\n"
- " Alias\n"
- " Trusted\n"
- " Blocked\n\n"
+ " Where\n"
+ " `name|mac` is a device name or MAC\n"
+ " `property` is one of:\n"
+ " Alias\n"
+ " Trusted\n"
+ " Blocked\n\n"
//"Report bugs to <"PACKAGE_BUGREPORT">."
"Project home page <"PACKAGE_URL">."
);
@@ -277,7 +284,7 @@ int main(int argc, char *argv[])
g_print("%s: Invalid arguments for --services\n", g_get_prgname());
g_print("Try `%s --help` for more information.\n", g_get_prgname());
exit(EXIT_FAILURE);
- } else if (set_arg && (argc != 4 || strlen(argv[1]) == 0 || strlen(argv[2]) ==0 || strlen(argv[3]) == 0)) {
+ } else if (set_arg && (argc != 4 || strlen(argv[1]) == 0 || strlen(argv[2]) == 0 || strlen(argv[3]) == 0)) {
g_print("%s: Invalid arguments for --set\n", g_get_prgname());
g_print("Try `%s --help` for more information.\n", g_get_prgname());
exit(EXIT_FAILURE);
@@ -285,8 +292,15 @@ int main(int argc, char *argv[])
g_option_context_free(context);
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
exit(EXIT_FAILURE);
}
@@ -314,7 +328,7 @@ int main(int argc, char *argv[])
Agent *agent = g_object_new(AGENT_TYPE, NULL);
GMainLoop *mainloop = g_main_loop_new(NULL, FALSE);
- adapter_create_paired_device_begin(adapter, create_paired_device_done, mainloop, connect_arg, DBUS_AGENT_PATH, "DisplayYesNo");
+ adapter_create_paired_device_begin(adapter, create_paired_device_done, mainloop, connect_arg, AGENT_DBUS_PATH, "DisplayYesNo");
g_main_loop_run(mainloop);
gchar *created_device = adapter_create_paired_device_end(adapter, &error);
exit_if_error(error);
@@ -376,7 +390,7 @@ int main(int argc, char *argv[])
while (g_hash_table_iter_next(&iter, &key, &value)) {
n++;
if (n == 1) g_print("\n");
- g_print("[RECORD:%d]\n", (int)key);
+ g_print("[RECORD:%d]\n", (gint) key);
GMarkupParser xml_parser = {xml_start_element, xml_end_element, NULL, NULL, NULL};
GMarkupParseContext *xml_parse_context = g_markup_parse_context_new(&xml_parser, 0, NULL, NULL);
g_markup_parse_context_parse(xml_parse_context, value, strlen(value), &error);
diff --git a/src/bt-input.c b/src/bt-input.c
index 57bb471..1248791 100644
--- a/src/bt-input.c
+++ b/src/bt-input.c
@@ -29,7 +29,9 @@
#include <string.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/bluez-api.h"
static void input_property_changed(Input *input, const gchar *name, const GValue *value, gpointer data)
{
@@ -63,6 +65,7 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new("- a bluetooth input manager");
g_option_context_add_main_entries(context, entries, NULL);
@@ -83,8 +86,15 @@ int main(int argc, char *argv[])
g_option_context_free(context);
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
exit(EXIT_FAILURE);
}
@@ -94,7 +104,7 @@ int main(int argc, char *argv[])
Device *device = find_device(adapter, connect_arg != NULL ? connect_arg : disconnect_arg, &error);
exit_if_error(error);
- if (!intf_is_supported(device_get_dbus_object_path(device), INPUT_INTF)) {
+ if (!intf_supported(BLUEZ_DBUS_NAME, device_get_dbus_object_path(device), INPUT_DBUS_INTERFACE)) {
g_printerr("Input service is not supported by this device\n");
exit(EXIT_FAILURE);
}
diff --git a/src/bt-monitor.c b/src/bt-monitor.c
index 8522a3e..2078e04 100644
--- a/src/bt-monitor.c
+++ b/src/bt-monitor.c
@@ -29,7 +29,9 @@
#include <string.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/bluez-api.h"
static gchar *adapter_arg = NULL;
@@ -103,7 +105,7 @@ static void adapter_device_created(Adapter *adapter, const gchar *device_path, g
{
//g_print("adapter_device_created()\n");
- if (intf_is_supported(device_path, DEVICE_INTF)) {
+ if (intf_supported(BLUEZ_DBUS_NAME, device_path, DEVICE_DBUS_INTERFACE)) {
Device *device = g_object_new(DEVICE_TYPE, "DBusObjectPath", device_path, NULL);
g_print("[Adapter: %s (%s)] Device created: %s (%s)\n", adapter_get_name(adapter), adapter_get_address(adapter), device_get_alias(device), device_get_address(device));
capture_device(device);
@@ -393,17 +395,17 @@ static void reload_device_services(Device *device)
}
// Capturing signals from available services
- if (intf_is_supported(device_get_dbus_object_path(device), AUDIO_INTF)) {
+ if (intf_supported(BLUEZ_DBUS_NAME, device_get_dbus_object_path(device), AUDIO_DBUS_INTERFACE)) {
Audio *audio = g_object_new(AUDIO_TYPE, "DBusObjectPath", device_get_dbus_object_path(device), NULL);
g_signal_connect(audio, "PropertyChanged", G_CALLBACK(audio_property_changed), device);
t2 = g_slist_append(t2, audio);
}
- if (intf_is_supported(device_get_dbus_object_path(device), INPUT_INTF)) {
+ if (intf_supported(BLUEZ_DBUS_NAME, device_get_dbus_object_path(device), INPUT_DBUS_INTERFACE)) {
Input *input = g_object_new(INPUT_TYPE, "DBusObjectPath", device_get_dbus_object_path(device), NULL);
g_signal_connect(input, "PropertyChanged", G_CALLBACK(input_property_changed), device);
t2 = g_slist_append(t2, input);
}
- if (intf_is_supported(device_get_dbus_object_path(device), NETWORK_INTF)) {
+ if (intf_supported(BLUEZ_DBUS_NAME, device_get_dbus_object_path(device), NETWORK_DBUS_INTERFACE)) {
Network *network = g_object_new(NETWORK_TYPE, "DBusObjectPath", device_get_dbus_object_path(device), NULL);
g_signal_connect(network, "PropertyChanged", G_CALLBACK(network_property_changed), device);
t2 = g_slist_append(t2, network);
@@ -423,6 +425,7 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new("- a bluetooth monitor");
g_option_context_add_main_entries(context, entries, NULL);
@@ -440,8 +443,15 @@ int main(int argc, char *argv[])
g_option_context_free(context);
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
exit(EXIT_FAILURE);
}
diff --git a/src/bt-network.c b/src/bt-network.c
index 21a9fb1..4128da6 100644
--- a/src/bt-network.c
+++ b/src/bt-network.c
@@ -27,15 +27,26 @@
#include <stdlib.h>
#include <string.h>
+#include <signal.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/bluez-api.h"
+
+static GMainLoop *mainloop = NULL;
+
+static void sigterm_handler(int sig)
+{
+ g_message("%s received", sig == SIGTERM ? "SIGTERM" : "SIGINT");
+ g_main_loop_quit(mainloop);
+}
static void network_property_changed(Network *network, const gchar *name, const GValue *value, gpointer data)
{
g_assert(data != NULL);
GMainLoop *mainloop = data;
-
+
if (g_strcmp0(name, "Connected") == 0) {
if (g_value_get_boolean(value) == TRUE) {
g_print("Network service is connected\n");
@@ -49,18 +60,17 @@ static void network_property_changed(Network *network, const gchar *name, const
static gchar *adapter_arg = NULL;
static gboolean connect_arg = FALSE;
static gchar *connect_device_arg = NULL;
-static gchar *connect_service_arg = NULL;
+static gchar *connect_uuid_arg = NULL;
static gchar *disconnect_arg = NULL;
-static gboolean service_arg = FALSE;
-static gchar *service_name_arg = NULL;
-static gchar *service_property_arg = NULL;
-static gchar *service_value_arg = NULL;
+static gboolean server_arg = FALSE;
+static gchar *server_uuid_arg = NULL;
+static gchar *server_brige_arg = NULL;
static GOptionEntry entries[] = {
{"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
{"connect", 'c', 0, G_OPTION_ARG_NONE, &connect_arg, "Connect to a network device", NULL},
{"disconnect", 'd', 0, G_OPTION_ARG_STRING, &disconnect_arg, "Disconnect from a network device", "<name|mac>"},
- {"service", 's', 0, G_OPTION_ARG_NONE, &service_arg, "Manage GN/PANU/NAP services", NULL},
+ {"server", 's', 0, G_OPTION_ARG_NONE, &server_arg, "Start GN/PANU/NAP server", NULL},
{NULL}
};
@@ -70,23 +80,21 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new("- a bluetooth network manager");
g_option_context_add_main_entries(context, entries, NULL);
g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
g_option_context_set_description(context,
"Connect Options:\n"
- " -c, --connect <name|mac> <pattern>\n"
- " Where `pattern` is:\n"
- " UUID 128 bit string\n"
- " Profile short name: gn, panu or nap\n"
- " UUID hexadecimal number\n\n"
- "Service Options:\n"
- " -s, --service <gn|panu|nap> [<property> <value>]\n"
- " Where `property` is one of:\n"
- " Name\n"
- " Enabled\n"
- " By default - show status\n\n"
+ " -c, --connect <name|mac> <uuid>\n"
+ " Where\n"
+ " `name|mac` is a device name or MAC\n"
+ " `uuid` is:\n"
+ " Profile short name: gn, panu or nap\n\n"
+ "Server Options:\n"
+ " -s, --server <gn|panu|nap> <brige>\n"
+ " Every new connection to this server will be added the `bridge` interface\n\n"
//"Report bugs to <"PACKAGE_BUGREPORT">."
"Project home page <"PACKAGE_URL">."
);
@@ -95,23 +103,30 @@ int main(int argc, char *argv[])
g_print("%s: %s\n", g_get_prgname(), error->message);
g_print("Try `%s --help` for more information.\n", g_get_prgname());
exit(EXIT_FAILURE);
- } else if (!connect_arg && (!disconnect_arg || strlen(disconnect_arg) == 0) && !service_arg) {
+ } else if (!connect_arg && (!disconnect_arg || strlen(disconnect_arg) == 0) && !server_arg) {
g_print("%s", g_option_context_get_help(context, FALSE, NULL));
exit(EXIT_FAILURE);
} else if (connect_arg && (argc != 3 || strlen(argv[1]) == 0 || strlen(argv[2]) == 0)) {
g_print("%s: Invalid arguments for --connect\n", g_get_prgname());
g_print("Try `%s --help` for more information.\n", g_get_prgname());
exit(EXIT_FAILURE);
- } else if (service_arg && (argc != 2 || strlen(argv[1]) == 0) && (argc != 4 || strlen(argv[1]) == 0 || strlen(argv[2]) == 0 || strlen(argv[3]) == 0)) {
- g_print("%s: Invalid arguments for --service\n", g_get_prgname());
+ } else if (server_arg && (argc != 3 || strlen(argv[1]) == 0 || strlen(argv[2]) == 0)) {
+ g_print("%s: Invalid arguments for --server\n", g_get_prgname());
g_print("Try `%s --help` for more information.\n", g_get_prgname());
exit(EXIT_FAILURE);
}
g_option_context_free(context);
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
exit(EXIT_FAILURE);
}
@@ -121,13 +136,13 @@ int main(int argc, char *argv[])
if (connect_arg || disconnect_arg) {
if (connect_arg) {
connect_device_arg = argv[1];
- connect_service_arg = argv[2];
+ connect_uuid_arg = argv[2];
}
Device *device = find_device(adapter, connect_device_arg != NULL ? connect_device_arg : disconnect_arg, &error);
exit_if_error(error);
- if (!intf_is_supported(device_get_dbus_object_path(device), NETWORK_INTF)) {
+ if (!intf_supported(BLUEZ_DBUS_NAME, device_get_dbus_object_path(device), NETWORK_DBUS_INTERFACE)) {
g_printerr("Network service is not supported by this device\n");
exit(EXIT_FAILURE);
}
@@ -141,7 +156,7 @@ int main(int argc, char *argv[])
if (network_get_connected(network) == TRUE) {
g_print("Network service is already connected\n");
} else {
- gchar *intf = network_connect(network, connect_service_arg, &error);
+ gchar *intf = network_connect(network, connect_uuid_arg, &error);
exit_if_error(error);
g_main_loop_run(mainloop);
g_free(intf);
@@ -161,135 +176,47 @@ int main(int argc, char *argv[])
g_object_unref(network);
g_object_unref(device);
g_main_loop_unref(mainloop);
- } else if (service_arg) {
- GValue v = {0,};
-
- service_name_arg = argv[1];
- if (argc == 4) {
- service_property_arg = argv[2];
- service_value_arg = argv[3];
-
- if (g_strcmp0(service_property_arg, "Name") == 0) {
- g_value_init(&v, G_TYPE_STRING);
- g_value_set_string(&v, service_value_arg);
- } else if (g_strcmp0(service_property_arg, "Enabled") == 0) {
- g_value_init(&v, G_TYPE_BOOLEAN);
-
- if (g_strcmp0(service_value_arg, "0") == 0 || g_ascii_strcasecmp(service_value_arg, "FALSE") == 0 || g_ascii_strcasecmp(service_value_arg, "OFF") == 0) {
- g_value_set_boolean(&v, FALSE);
- } else if (g_strcmp0(service_value_arg, "1") == 0 || g_ascii_strcasecmp(service_value_arg, "TRUE") == 0 || g_ascii_strcasecmp(service_value_arg, "ON") == 0) {
- g_value_set_boolean(&v, TRUE);
- } else {
- g_print("%s: Invalid boolean value: %s\n", g_get_prgname(), service_value_arg);
- g_print("Try `%s --help` for more information.\n", g_get_prgname());
- exit(EXIT_FAILURE);
- }
- } else {
- g_print("%s: Invalid property: %s\n", g_get_prgname(), service_property_arg);
- g_print("Try `%s --help` for more information.\n", g_get_prgname());
- exit(EXIT_FAILURE);
- }
- }
-
- if (g_ascii_strcasecmp(service_name_arg, "GN") == 0) {
- if (!intf_is_supported(adapter_get_dbus_object_path(adapter), NETWORK_HUB_INTF)) {
- g_printerr("GN service is not supported by this adapter\n");
- exit(EXIT_FAILURE);
- }
+ } else if (server_arg) {
+ server_uuid_arg = argv[1];
+ server_brige_arg = argv[2];
- NetworkHub *hub = g_object_new(NETWORK_HUB_TYPE, "DBusObjectPath", adapter_get_dbus_object_path(adapter), NULL);
+ if (g_ascii_strcasecmp(server_uuid_arg, "gn") != 0 && g_ascii_strcasecmp(server_uuid_arg, "panu") != 0 && g_ascii_strcasecmp(server_uuid_arg, "nap") != 0) {
+ g_print("%s: Invalid server UUID: %s\n", g_get_prgname(), server_uuid_arg);
+ g_print("Try `%s --help` for more information.\n", g_get_prgname());
+ exit(EXIT_FAILURE);
+ }
- if (service_property_arg == NULL) {
- g_print("[Service: GN]\n");
- g_print(" Name: %s\n", network_hub_get_name(hub));
- g_print(" Enabled: %d\n", network_hub_get_enabled(hub));
- g_print(" UUID: %s (%s)\n", uuid2name(network_hub_get_uuid(hub)), network_hub_get_uuid(hub));
- } else {
- GHashTable *props = network_hub_get_properties(hub, &error);
- exit_if_error(error);
- GValue *old_value = g_hash_table_lookup(props, service_property_arg);
- g_assert(old_value != NULL);
- if (G_VALUE_HOLDS_STRING(old_value)) {
- g_print("%s: %s -> %s\n", service_property_arg, g_value_get_string(old_value), g_value_get_string(&v));
- } else if (G_VALUE_HOLDS_BOOLEAN(old_value)) {
- g_print("%s: %d -> %d\n", service_property_arg, g_value_get_boolean(old_value), g_value_get_boolean(&v));
- }
- g_hash_table_unref(props);
-
- network_hub_set_property(hub, service_property_arg, &v, &error);
- exit_if_error(error);
- }
+ if (!intf_supported(BLUEZ_DBUS_NAME, adapter_get_dbus_object_path(adapter), NETWORK_SERVER_DBUS_INTERFACE)) {
+ g_printerr("Network server is not supported by this adapter\n");
+ exit(EXIT_FAILURE);
+ }
- g_object_unref(hub);
- } else if (g_ascii_strcasecmp(service_name_arg, "PANU") == 0) {
- if (!intf_is_supported(adapter_get_dbus_object_path(adapter), NETWORK_PEER_INTF)) {
- g_printerr("PANU service is not supported by this adapter\n");
- exit(EXIT_FAILURE);
- }
+ gchar *server_uuid_upper = g_ascii_strup(server_uuid_arg, -1);
- NetworkPeer *peer = g_object_new(NETWORK_PEER_TYPE, "DBusObjectPath", adapter_get_dbus_object_path(adapter), NULL);
+ NetworkServer *network_server = g_object_new(NETWORK_SERVER_TYPE, "DBusObjectPath", adapter_get_dbus_object_path(adapter), NULL);
- if (service_property_arg == NULL) {
- g_print("[Service: PANU]\n");
- g_print(" Name: %s\n", network_peer_get_name(peer));
- g_print(" Enabled: %d\n", network_peer_get_enabled(peer));
- g_print(" UUID: %s (%s)\n", uuid2name(network_peer_get_uuid(peer)), network_peer_get_uuid(peer));
- } else {
- GHashTable *props = network_peer_get_properties(peer, &error);
- exit_if_error(error);
- GValue *old_value = g_hash_table_lookup(props, service_property_arg);
- g_assert(old_value != NULL);
- if (G_VALUE_HOLDS_STRING(old_value)) {
- g_print("%s: %s -> %s\n", service_property_arg, g_value_get_string(old_value), g_value_get_string(&v));
- } else if (G_VALUE_HOLDS_BOOLEAN(old_value)) {
- g_print("%s: %d -> %d\n", service_property_arg, g_value_get_boolean(old_value), g_value_get_boolean(&v));
- }
- g_hash_table_unref(props);
-
- network_peer_set_property(peer, service_property_arg, &v, &error);
- exit_if_error(error);
- }
+ network_server_register(network_server, server_uuid_arg, server_brige_arg, &error);
+ exit_if_error(error);
+ g_print("%s server registered\n", server_uuid_upper);
- g_object_unref(peer);
- } else if (g_ascii_strcasecmp(service_name_arg, "NAP") == 0) {
- if (!intf_is_supported(adapter_get_dbus_object_path(adapter), NETWORK_ROUTER_INTF)) {
- g_printerr("NAP service is not supported by this adapter\n");
- exit(EXIT_FAILURE);
- }
+ mainloop = g_main_loop_new(NULL, FALSE);
- NetworkRouter *router = g_object_new(NETWORK_ROUTER_TYPE, "DBusObjectPath", adapter_get_dbus_object_path(adapter), NULL);
+ /* Add SIGTERM && SIGINT handlers */
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = sigterm_handler;
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
- if (service_property_arg == NULL) {
- g_print("[Service: NAP]\n");
- g_print(" Name: %s\n", network_router_get_name(router));
- g_print(" Enabled: %d\n", network_router_get_enabled(router));
- g_print(" UUID: %s (%s)\n", uuid2name(network_router_get_uuid(router)), network_router_get_uuid(router));
- } else {
- GHashTable *props = network_router_get_properties(router, &error);
- exit_if_error(error);
- GValue *old_value = g_hash_table_lookup(props, service_property_arg);
- g_assert(old_value != NULL);
- if (G_VALUE_HOLDS_STRING(old_value)) {
- g_print("%s: %s -> %s\n", service_property_arg, g_value_get_string(old_value), g_value_get_string(&v));
- } else if (G_VALUE_HOLDS_BOOLEAN(old_value)) {
- g_print("%s: %d -> %d\n", service_property_arg, g_value_get_boolean(old_value), g_value_get_boolean(&v));
- }
- g_hash_table_unref(props);
-
- network_router_set_property(router, service_property_arg, &v, &error);
- exit_if_error(error);
- }
+ g_main_loop_run(mainloop);
- g_object_unref(router);
- } else {
- g_print("%s: Invalid service name: %s\n", g_get_prgname(), service_name_arg);
- g_print("Try `%s --help` for more information.\n", g_get_prgname());
- exit(EXIT_FAILURE);
- }
+ network_server_unregister(network_server, server_uuid_arg, &error);
+ exit_if_error(error);
+ g_print("%s server unregistered\n", server_uuid_upper);
- if (argc == 4) {
- g_value_unset(&v);
- }
+ g_free(server_uuid_upper);
+ g_main_loop_unref(mainloop);
+ g_object_unref(network_server);
}
g_object_unref(adapter);
diff --git a/src/bt-obex.c b/src/bt-obex.c
index bed079f..c4d9787 100644
--- a/src/bt-obex.c
+++ b/src/bt-obex.c
@@ -33,295 +33,85 @@
#include <errno.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/bluez-api.h"
+#include "lib/obexd-api.h"
-typedef struct {
- OBEXServer *serv;
- OBEXServerSession *sess;
- gchar *sess_id;
+GHashTable *server_transfers = NULL;
+GMainLoop *mainloop = NULL;
- /* Client address */
- gchar *client_name;
- gchar *client_addr;
-
- /* Transfer info */
- gchar *filename;
- gchar *local_path;
- guint64 size;
- guint pp; // per sent
-} sess_transf_s;
-
-static gchar *server_type = NULL;
-static GHashTable *server_sessions = NULL;
-
-/* Main arguments */
-static gchar *adapter_arg = NULL;
-static gboolean server_arg = FALSE;
-static gchar *server_type_arg = NULL;
-static gchar *server_path_arg = NULL;
-static gboolean opp_arg = FALSE;
-static gchar *opp_device_arg = NULL;
-static gchar *opp_file_arg = NULL;
-static gchar *ftp_arg = NULL;
-
-/* Sessions signals defs */
-static void obexserver_session_cancelled(OBEXServerSession *session, gpointer data);
-static void obexserver_session_disconnected(OBEXServerSession *session, gpointer data);
-static void obexserver_session_transfer_started(OBEXServerSession *session, const gchar *filename, const gchar *local_path, guint64 total_bytes, gpointer data);
-static void obexserver_session_transfer_progress(OBEXServerSession *session, guint64 bytes_transferred, gpointer data);
-static void obexserver_session_transfer_completed(OBEXServerSession *session, gpointer data);
-static void obexserver_session_error_occurred(OBEXServerSession *session, const gchar *error_name, const gchar *error_message, gpointer data);
-
-static void obexsession_cancelled(OBEXSession *session, gpointer data);
-static void obexsession_disconnected(OBEXSession *session, gpointer data);
-static void obexsession_closed(OBEXSession *session, gpointer data);
-static void obexsession_transfer_started(OBEXSession *session, const gchar *filename, const gchar *local_path, guint64 total_bytes, gpointer data);
-static void obexsession_transfer_progress(OBEXSession *session, guint64 bytes_transferred, gpointer data);
-static void obexsession_transfer_completed(OBEXSession *session, gpointer data);
-static void obexsession_error_occurred(OBEXSession *session, const gchar *error_name, const gchar *error_message, gpointer data);
-
-/*
- * OBEXManager signals
- */
-static void obexmanager_session_connected(OBEXManager *manager, const gchar *path, gpointer data)
-{
- g_print("[OBEXManager] Session connected: %s\n", path);
-}
-
-static void obexmanager_session_connect_error(OBEXManager *manager, const gchar *path, const gchar *error_name, const gchar *error_message, gpointer data)
+/* OBEXTransfer signals */
+static void obextransfer_progress(OBEXTransfer *transfer, gint total, gint transfered, gpointer data)
{
- g_print("[OBEXManager] Session connect error: %s:%s\n", path, error_name, error_message);
-}
-
-static void obexmanager_session_closed(OBEXManager *manager, const gchar *path, gpointer data)
-{
- g_print("[OBEXManager] Session closed: %s\n", path);
-}
-
-/*
- * OBEXServer signals
- */
-static void obexserver_started(OBEXServer *server, gpointer data)
-{
- g_print("[%sServer] Started\n", server_type);
-}
-
-static void obexserver_stopped(OBEXServer *server, gpointer data)
-{
- g_print("[%sServer] Stopped\n", server_type);
-}
-
-static void obexserver_closed(OBEXServer *server, gpointer data)
-{
- g_print("[%sServer] Closed\n", server_type);
-}
-
-static void obexserver_error_occurred(OBEXServer *server, const gchar *error_name, const gchar *error_message, gpointer data)
-{
- g_print("[%sServer] %s:%s\n", server_type, error_name, error_message);
-}
-
-static void obexserver_session_created(OBEXServer *server, const gchar *path, gpointer data)
-{
- OBEXServerSession *session = g_object_new(OBEXSERVER_SESSION_TYPE, "DBusObjectPath", path, NULL);
- g_signal_connect(session, "Cancelled", G_CALLBACK(obexserver_session_cancelled), NULL);
- g_signal_connect(session, "Disconnected", G_CALLBACK(obexserver_session_disconnected), NULL);
- g_signal_connect(session, "TransferStarted", G_CALLBACK(obexserver_session_transfer_started), NULL);
- g_signal_connect(session, "TransferProgress", G_CALLBACK(obexserver_session_transfer_progress), NULL);
- g_signal_connect(session, "TransferCompleted", G_CALLBACK(obexserver_session_transfer_completed), NULL);
- g_signal_connect(session, "ErrorOccurred", G_CALLBACK(obexserver_session_error_occurred), NULL);
-
- sess_transf_s *t = g_new0(sess_transf_s, 1);
- t->serv = server;
- t->sess = session;
- t->sess_id = g_path_get_basename(path);
-
- g_print("[%sServer] Session created: %s\n", server_type, t->sess_id);
-
- /* Get remote address & name (if possible) */
- GError *error = NULL;
- GHashTable *sess_info = obexserver_get_server_session_info(server, path, &error);
- exit_if_error(error);
- t->client_addr = g_strdup(g_hash_table_lookup(sess_info, "BluetoothAddress"));
- g_hash_table_unref(sess_info);
-
- Adapter *adapter_t = find_adapter(adapter_arg, &error);
- exit_if_error(error);
- Device *device_t = find_device(adapter_t, t->client_addr, &error);
- exit_if_error(error);
- if (device_t)
- t->client_name = g_strdup(device_get_name(device_t));
- g_object_unref(device_t);
- g_object_unref(adapter_t);
-
- g_hash_table_insert(server_sessions, g_strdup(path), t);
-
- if (t->client_name)
- g_print("[%sServer] Client: %s (%s)\n", server_type, t->client_name, t->client_addr);
- else
- g_print("[%sServer] Client: %s\n", server_type, t->client_addr);
-}
-
-static void obexserver_session_removed(OBEXServer *server, const gchar *path, gpointer data)
-{
- sess_transf_s *t = g_hash_table_lookup(server_sessions, path);
- g_assert(t != NULL);
-
- g_print("[%sServer] Session removed: %s\n", server_type, t->sess_id);
-
- /* Transfer free (if exists) */
- g_free(t->filename);
- g_free(t->local_path);
- t->size = 0;
- t->pp = 0;
-
- /* Session data free */
- g_free(t->sess_id);
- g_free(t->client_addr);
- g_free(t->client_name);
- g_object_unref(t->sess);
- g_free(t);
-
- g_hash_table_remove(server_sessions, path);
-}
-
-/*
- * OBEXServerSession signals
- */
-static void obexserver_session_cancelled(OBEXServerSession *session, gpointer data)
-{
- sess_transf_s *t = g_hash_table_lookup(server_sessions, obexserver_session_get_dbus_object_path(session));
- g_assert(t != NULL);
-
- g_print("[%s] Cancelled\n", t->sess_id);
-}
-
-static void obexserver_session_disconnected(OBEXServerSession *session, gpointer data)
-{
- sess_transf_s *t = g_hash_table_lookup(server_sessions, obexserver_session_get_dbus_object_path(session));
- g_assert(t != NULL);
-
- g_print("[%s] Disconnected\n", t->sess_id);
-}
-
-static void obexserver_session_transfer_started(OBEXServerSession *session, const gchar *filename, const gchar *local_path, guint64 total_bytes, gpointer data)
-{
- sess_transf_s *t = g_hash_table_lookup(server_sessions, obexserver_session_get_dbus_object_path(session));
- g_assert(t != NULL);
-
- GError *error = NULL;
-
- g_print("[%s] Transfer started:\n", t->sess_id);
- g_print(" Filename: %s\n", filename);
- g_print(" Save path: %s\n", local_path);
- g_print(" Size: %llu bytes\n", total_bytes);
-
- gchar yn[4] = {0,};
- g_print("Accept (yes/no)? ");
- errno = 0;
- if (scanf("%3s", yn) == EOF && errno) {
- g_warning("%s\n", strerror(errno));
- }
- if (g_strcmp0(yn, "y") == 0 || g_strcmp0(yn, "yes") == 0) {
- obexserver_session_accept(session, &error);
- exit_if_error(error);
- } else {
- obexserver_session_reject(session, &error);
- exit_if_error(error);
- return;
- }
-
- t->filename = g_strdup(filename);
- t->local_path = g_strdup(local_path);
- t->size = total_bytes;
- t->pp = 0;
-}
-
-static void obexserver_session_transfer_progress(OBEXServerSession *session, guint64 bytes_transferred, gpointer data)
-{
- sess_transf_s *t = g_hash_table_lookup(server_sessions, obexserver_session_get_dbus_object_path(session));
- g_assert(t != NULL);
-
- t->pp = (bytes_transferred / (gfloat) t->size)*100;
+ guint pp = (transfered / (gfloat) total)*100;
static gboolean update_progress = FALSE;
if (!update_progress) {
- g_print("[%s] Transfer progress: %3u%%", t->sess_id, t->pp);
+ g_print("[OBEXTransfer] Progress: %3u%%", pp);
update_progress = TRUE;
} else {
- g_print("\b\b\b\b%3u%%", t->pp);
+ g_print("\b\b\b\b%3u%%", pp);
}
- if (t->pp == 100) g_print("\n");
-}
-
-static void obexserver_session_transfer_completed(OBEXServerSession *session, gpointer data)
-{
- sess_transf_s *t = g_hash_table_lookup(server_sessions, obexserver_session_get_dbus_object_path(session));
- g_assert(t != NULL);
-
- g_print("[%s] Transfer completed\n", t->sess_id);
-
- g_free(t->filename);
- t->filename = NULL;
- g_free(t->local_path);
- t->local_path = NULL;
- t->size = 0;
- t->pp = 0;
-}
-
-static void obexserver_session_error_occurred(OBEXServerSession *session, const gchar *error_name, const gchar *error_message, gpointer data)
-{
- sess_transf_s *t = g_hash_table_lookup(server_sessions, obexserver_session_get_dbus_object_path(session));
- g_assert(t != NULL);
-
- /* If an error occurred during transfer */
- if (t->pp > 0 && t->pp < 100) g_print("\n");
-
- g_print("[%s] %s:%s\n", t->sess_id, error_name, error_message);
-}
-
-/*
- * OBEXSession signals
- */
-static void obexsession_cancelled(OBEXSession *session, gpointer data)
-{
-
-}
-
-static void obexsession_disconnected(OBEXSession *session, gpointer data)
-{
-
+ if (pp == 100) {
+ g_print("\n");
+ update_progress = FALSE;
+ }
}
-static void obexsession_closed(OBEXSession *session, gpointer data)
+/* OBEXManager signals */
+static void obexmanager_session_created(OBEXManager *manager, const gchar *session_path, gpointer data)
{
-
+ g_print("[OBEXManager] FTP session opened\n");
}
-static void obexsession_transfer_started(OBEXSession *session, const gchar *filename, const gchar *local_path, guint64 total_bytes, gpointer data)
+static void obexmanager_session_removed(OBEXManager *manager, const gchar *session_path, gpointer data)
{
-
+ g_print("[OBEXManager] FTP session closed\n", session_path);
}
-static void obexsession_transfer_progress(OBEXSession *session, guint64 bytes_transferred, gpointer data)
+static void obexmanager_transfer_started(OBEXManager *manager, const gchar *transfer_path, gpointer data)
{
+ g_print("[OBEXManager] Transfer started\n", transfer_path);
+ OBEXTransfer *t = g_object_new(OBEXTRANSFER_TYPE, "DBusObjectPath", transfer_path, NULL);
+ g_signal_connect(t, "Progress", G_CALLBACK(obextransfer_progress), NULL);
+ g_hash_table_insert(server_transfers, transfer_path, t);
}
-static void obexsession_transfer_completed(OBEXSession *session, gpointer data)
+static void obexmanager_transfer_completed(OBEXManager *manager, const gchar *transfer_path, gboolean success, gpointer data)
{
-
+ OBEXTransfer *t = g_hash_table_lookup(server_transfers, transfer_path);
+ if (t) {
+ g_print("[OBEXManager] Transfer %s\n", success == TRUE ? "succeeded" : "failed");
+ g_object_unref(t);
+ g_hash_table_remove(server_transfers, transfer_path);
+ } else {
+ // Bug ?
+ }
}
-static void obexsession_error_occurred(OBEXSession *session, const gchar *error_name, const gchar *error_message, gpointer data)
+/* Async callback for SendFiles() */
+/*static void send_files_done(gpointer data)
{
+ g_assert(data != NULL);
+ GMainLoop *mainloop = data;
+ g_main_loop_quit(mainloop);
+}*/
-}
+/* Main arguments */
+static gchar *adapter_arg = NULL;
+static gboolean server_arg = FALSE;
+static gchar *server_path_arg = NULL;
+static gboolean opp_arg = FALSE;
+static gchar *opp_device_arg = NULL;
+static gchar *opp_file_arg = NULL;
+static gchar *ftp_arg = NULL;
static GOptionEntry entries[] = {
{"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
- {"server", 's', 0, G_OPTION_ARG_NONE, &server_arg, "Start OPP/FTP server", NULL},
+ {"server", 's', 0, G_OPTION_ARG_NONE, &server_arg, "Register self at OBEX server", NULL},
{"opp", 'p', 0, G_OPTION_ARG_NONE, &opp_arg, "Send file to remote device", NULL},
{"ftp", 'f', 0, G_OPTION_ARG_STRING, &ftp_arg, "Start FTP session with remote device", "<name|mac>"},
{NULL}
@@ -333,14 +123,15 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new(" - a bluetooth OBEX client/server");
g_option_context_add_main_entries(context, entries, NULL);
g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
g_option_context_set_description(context,
"Server Options:\n"
- " -s, --server <opp|ftp> [<path>]\n"
- " Start OPP/FTP server and use given `path` as root directory\n"
+ " -s, --server [<path>]\n"
+ " Register self at OBEX server and use given `path` as OPP save directory\n"
" If `path` does not specified - use current directory\n\n"
"OPP Options:\n"
" -p, --opp <name|mac> <file>\n"
@@ -356,7 +147,7 @@ int main(int argc, char *argv[])
} else if (!server_arg && !opp_arg && (!ftp_arg || strlen(ftp_arg) == 0)) {
g_print("%s", g_option_context_get_help(context, FALSE, NULL));
exit(EXIT_FAILURE);
- } else if (server_arg && (argc != 2 || strlen(argv[1]) == 0) && (argc != 3 || strlen(argv[1]) == 0 || strlen(argv[2]) == 0)) {
+ } else if (server_arg && argc != 1 && (argc != 2 || strlen(argv[1]) == 0)) {
g_print("%s: Invalid arguments for --server\n", g_get_prgname());
g_print("Try `%s --help` for more information.\n", g_get_prgname());
exit(EXIT_FAILURE);
@@ -368,30 +159,33 @@ int main(int argc, char *argv[])
g_option_context_free(context);
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
exit(EXIT_FAILURE);
}
- if (!intf_is_supported(BLUEZ_DBUS_OBEXMANAGER_PATH, OBEXMANAGER_INTF)) {
- g_printerr("%s: OBEX service does not found\n", g_get_prgname());
- g_printerr("Did you forget to run obex-data-server?\n");
+ if (!dbus_session_connect(&error)) {
+ g_printerr("Couldn't connect to dbus session bus: %s\n", error->message);
exit(EXIT_FAILURE);
}
- Adapter *adapter = find_adapter(adapter_arg, &error);
- exit_if_error(error);
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
+ exit(EXIT_FAILURE);
+ }
- OBEXManager *manager = g_object_new(OBEXMANAGER_TYPE, NULL);
- g_signal_connect(manager, "SessionConnected", G_CALLBACK(obexmanager_session_connected), NULL);
- g_signal_connect(manager, "SessionConnectError", G_CALLBACK(obexmanager_session_connect_error), NULL);
- g_signal_connect(manager, "SessionClosed", G_CALLBACK(obexmanager_session_closed), NULL);
+ /* Check, that obexd daemon is running */
+ if (!intf_supported(OBEXD_DBUS_NAME, OBEXMANAGER_DBUS_PATH, OBEXMANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: OBEXD service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run obexd?\n");
+ exit(EXIT_FAILURE);
+ }
if (server_arg) {
- server_sessions = g_hash_table_new(g_str_hash, g_str_equal);
- server_type_arg = argv[1];
- if (argc == 3) {
- server_path_arg = argv[2];
+ if (argc == 2) {
+ server_path_arg = argv[1];
}
/* Check that `path` is valid */
@@ -411,60 +205,175 @@ int main(int argc, char *argv[])
root_dir = g_strdup(server_path_arg);
}
- gboolean require_pairing = TRUE;
- gboolean auto_accept = FALSE;
-
- if (g_strcmp0(server_type_arg, "opp") == 0) {
- require_pairing = FALSE;
- auto_accept = FALSE;
- server_type = "OPP";
- } else if (g_strcmp0(server_type_arg, "ftp") == 0) {
- require_pairing = TRUE;
- auto_accept = TRUE;
- server_type = "FTP";
- } else {
- g_print("%s: Invalid server type: %s\n", g_get_prgname(), server_type_arg);
- g_print("Try `%s --help` for more information.\n", g_get_prgname());
- exit(EXIT_FAILURE);
- }
+ server_transfers = g_hash_table_new(g_str_hash, g_str_equal);
- gchar *serv_path = obexmanager_create_bluetooth_server(manager, adapter_get_address(adapter), server_type_arg, require_pairing, &error);
- exit_if_error(error);
+ OBEXManager *manager = g_object_new(OBEXMANAGER_TYPE, NULL);
+ g_signal_connect(manager, "SessionCreated", G_CALLBACK(obexmanager_session_created), NULL);
+ g_signal_connect(manager, "SessionRemoved", G_CALLBACK(obexmanager_session_removed), NULL);
+ g_signal_connect(manager, "TransferStarted", G_CALLBACK(obexmanager_transfer_started), NULL);
+ g_signal_connect(manager, "TransferCompleted", G_CALLBACK(obexmanager_transfer_completed), NULL);
- OBEXServer *serv = g_object_new(OBEXSERVER_TYPE, "DBusObjectPath", serv_path, NULL);
- g_signal_connect(serv, "Started", G_CALLBACK(obexserver_started), NULL);
- g_signal_connect(serv, "Stopped", G_CALLBACK(obexserver_stopped), NULL);
- g_signal_connect(serv, "Closed", G_CALLBACK(obexserver_closed), NULL);
- g_signal_connect(serv, "ErrorOccurred", G_CALLBACK(obexserver_error_occurred), NULL);
- g_signal_connect(serv, "SessionCreated", G_CALLBACK(obexserver_session_created), NULL);
- g_signal_connect(serv, "SessionRemoved", G_CALLBACK(obexserver_session_removed), NULL);
+ OBEXAgent *agent = g_object_new(OBEXAGENT_TYPE, "RootFolder", root_dir, NULL);
- gboolean is_started = obexserver_is_started(serv, &error);
- exit_if_error(error);
- if (is_started) {
- g_printerr("%s: Server is already started\n", g_get_prgname());
- exit(EXIT_FAILURE);
- }
+ g_free(root_dir);
- obexserver_start(serv, root_dir, TRUE, auto_accept, &error);
+ obexmanager_register_agent(manager, OBEXAGENT_DBUS_PATH, &error);
exit_if_error(error);
- GMainLoop *mainloop = g_main_loop_new(NULL, FALSE);
+ mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);
/* Waiting for connections... */
+ // TODO: Add SIGINT handler
+
g_main_loop_unref(mainloop);
- g_object_unref(serv);
- g_free(serv_path);
- g_free(root_dir);
- g_hash_table_unref(server_sessions);
+
+ /* Stop active transfers */
+ GHashTableIter iter;
+ gpointer key, value;
+ g_hash_table_iter_init(&iter, server_transfers);
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ OBEXTransfer *t = OBEXTRANSFER(value);
+ obextransfer_cancel(t, NULL);
+ g_object_unref(t);
+ g_hash_table_iter_remove(&iter);
+ }
+ g_hash_table_unref(server_transfers);
+
+ obexmanager_unregister_agent(manager, OBEXAGENT_DBUS_PATH, &error);
+ g_object_unref(agent);
+ g_object_unref(manager);
} else if (opp_arg) {
+ opp_device_arg = argv[1];
+ opp_file_arg = argv[2];
+
+ /* Check that `file` is valid and readable */
+ {
+ struct stat buf;
+ if (stat(opp_file_arg, &buf) != 0) {
+ g_printerr("%s: %s\n", g_get_prgname(), strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ if (!S_ISREG(buf.st_mode)) {
+ g_printerr("%s: Invalid file: %s\n", g_get_prgname(), opp_file_arg);
+ exit(EXIT_FAILURE);
+ }
+ }
+ gchar * files_to_send[] = {NULL, NULL};
+ if (!g_path_is_absolute(opp_file_arg)) {
+ gchar *current_dir = g_get_current_dir();
+ files_to_send[0] = g_build_filename(current_dir, opp_file_arg, NULL);
+ g_free(current_dir);
+ } else {
+ files_to_send[0] = g_strdup(opp_file_arg);
+ }
+
+ /* Get source address (address of adapter) */
+ Adapter *adapter = find_adapter(adapter_arg, &error);
+ exit_if_error(error);
+ gchar *src_address = g_strdup(adapter_get_address(adapter));
+
+ /* Get destination address (address of remote device) */
+ Device *device = find_device(adapter, opp_device_arg, &error);
+ exit_if_error(error);
+ gchar *dst_address = g_strdup(device == NULL ? opp_device_arg : device_get_address(device));
+
+ g_object_unref(device);
+ g_object_unref(adapter);
+
+ /* Build arguments */
+ GHashTable *device_dict = g_hash_table_new(g_str_hash, g_str_equal);
+ GValue source = {0};
+ GValue destination = {0};
+ g_value_init(&source, G_TYPE_STRING);
+ g_value_init(&destination, G_TYPE_STRING);
+ g_value_set_string(&source, src_address);
+ g_value_set_string(&destination, dst_address);
+ g_hash_table_insert(device_dict, "Source", &source);
+ g_hash_table_insert(device_dict, "Destination", &destination);
+
+ OBEXClient *client = g_object_new(OBEXCLIENT_TYPE, NULL);
+ OBEXAgent *agent = g_object_new(OBEXAGENT_TYPE, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ /* Sending file(s) */
+ obexclient_send_files_begin(client, send_files_done, mainloop, device_dict, files_to_send, OBEXAGENT_DBUS_PATH);
+ g_main_loop_run(mainloop);
+
+ /* Sending files process here ?? */
+
+ // TODO: Add SIGINT handler ??
+
+ g_main_loop_unref(mainloop);
+
+ obexclient_send_files_end(client, &error);
+ exit_if_error(error);
+
+ g_object_unref(agent);
+ g_object_unref(client);
+
+ g_value_unset(&source);
+ g_value_unset(&destination);
+ g_hash_table_unref(device_dict);
+
+ g_free(src_address);
+ g_free(dst_address);
+ g_strfreev(files_to_send);
+ } else if (ftp_arg) {
+ /* Get source address (address of adapter) */
+ Adapter *adapter = find_adapter(adapter_arg, &error);
+ exit_if_error(error);
+ gchar *src_address = g_strdup(adapter_get_address(adapter));
+
+ /* Get destination address (address of remote device) */
+ Device *device = find_device(adapter, ftp_arg, &error);
+ exit_if_error(error);
+ gchar *dst_address = g_strdup(device == NULL ? ftp_arg : device_get_address(device));
+
+ g_object_unref(device);
+ g_object_unref(adapter);
+
+ /* Build arguments */
+ GHashTable *device_dict = g_hash_table_new(g_str_hash, g_str_equal);
+ GValue source = {0};
+ GValue destination = {0};
+ GValue target = {0};
+ g_value_init(&source, G_TYPE_STRING);
+ g_value_init(&destination, G_TYPE_STRING);
+ g_value_init(&target, G_TYPE_STRING);
+ g_value_set_string(&source, src_address);
+ g_value_set_string(&destination, dst_address);
+ g_value_set_string(&target, "FTP");
+ g_hash_table_insert(device_dict, "Source", &source);
+ g_hash_table_insert(device_dict, "Destination", &destination);
+ g_hash_table_insert(device_dict, "Target", &target);
+
+ OBEXClient *client = g_object_new(OBEXCLIENT_TYPE, NULL);
+ OBEXAgent *agent = g_object_new(OBEXAGENT_TYPE, NULL);
+
+ /* Create FTP session */
+ gchar *session_path = obexclient_create_session(client, device_dict, &error);
+ exit_if_error(error);
+
+ OBEXClientFileTransfer *ftp_session = g_object_new(OBEXCLIENT_FILE_TRANSFER_TYPE, "DBusObjectPath", session_path, NULL);
+
+ g_print("FTP session opened\n");
+
+ while (TRUE) {
+ g_print("> ");
+ gchar cmd[128] = {0,};
+ errno = 0;
+ if (scanf("%128s", cmd) == EOF && errno) {
+ g_warning("%s\n", strerror(errno));
+ }
+
+ g_print("cmd: %s\n", cmd);
+ }
}
- g_object_unref(manager);
- g_object_unref(adapter);
dbus_disconnect();
exit(EXIT_SUCCESS);
diff --git a/src/bt-serial.c b/src/bt-serial.c
index 2d2ed11..49a0f81 100644
--- a/src/bt-serial.c
+++ b/src/bt-serial.c
@@ -29,7 +29,9 @@
#include <string.h>
#include <glib.h>
-#include "lib/bluez-dbus.h"
+#include "lib/dbus-common.h"
+#include "lib/helpers.h"
+#include "lib/bluez-api.h"
static gchar *adapter_arg = NULL;
static gboolean connect_arg = FALSE;
@@ -52,6 +54,7 @@ int main(int argc, char *argv[])
GOptionContext *context;
g_type_init();
+ dbus_init();
context = g_option_context_new(" - a bluetooth serial manager");
g_option_context_add_main_entries(context, entries, NULL);
@@ -59,14 +62,17 @@ int main(int argc, char *argv[])
g_option_context_set_description(context,
"Connect Options:\n"
" -c, --connect <name|mac> <pattern>\n"
- " Where `pattern` is:\n"
- " UUID 128 bit string\n"
- " Profile short name, e.g: spp, dun\n"
- " RFCOMM channel, 1-30\n\n"
+ " Where\n"
+ " `name|mac` is a device name or MAC\n"
+ " `pattern` is:\n"
+ " UUID 128 bit string\n"
+ " Profile short name, e.g: spp, dun\n"
+ " RFCOMM channel, 1-30\n\n"
"Disconnect Options:\n"
" -d, --disconnect <name|mac> <tty_device>\n"
- " Where `tty_device` is:\n"
- " RFCOMM TTY device that has been connected\n\n"
+ " Where\n"
+ " `name|mac` is a device name or MAC\n"
+ " `tty_device` is a RFCOMM TTY device that has been connected\n\n"
//"Report bugs to <"PACKAGE_BUGREPORT">."
"Project home page <"PACKAGE_URL">."
);
@@ -98,8 +104,15 @@ int main(int argc, char *argv[])
disconnect_tty_device_arg = argv[2];
}
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
+ if (!dbus_system_connect(&error)) {
+ g_printerr("Couldn't connect to dbus system bus: %s\n", error->message);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check, that bluetooth daemon is running */
+ if (!intf_supported(BLUEZ_DBUS_NAME, MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE)) {
+ g_printerr("%s: BLUEZ service does not found\n", g_get_prgname());
+ g_printerr("Did you forget to run bluetoothd?\n");
exit(EXIT_FAILURE);
}
@@ -109,7 +122,7 @@ int main(int argc, char *argv[])
Device *device = find_device(adapter, connect_device_arg != NULL ? connect_device_arg : disconnect_device_arg, &error);
exit_if_error(error);
- if (!intf_is_supported(device_get_dbus_object_path(device), SERIAL_INTF)) {
+ if (!intf_supported(BLUEZ_DBUS_NAME, device_get_dbus_object_path(device), SERIAL_DBUS_INTERFACE)) {
g_printerr("Serial service is not supported by this device\n");
exit(EXIT_FAILURE);
}
diff --git a/src/lib/bluez/adapter.c b/src/lib/bluez/adapter.c
index d0140aa..b6cfd0e 100644
--- a/src/lib/bluez/adapter.c
+++ b/src/lib/bluez/adapter.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -230,6 +230,9 @@ static void adapter_init(Adapter *self)
{
self->priv = ADAPTER_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
/* Async calls init */
self->priv->create_paired_device_call = NULL;
diff --git a/src/lib/bluez/agent.c b/src/lib/bluez/agent.c
index e150521..04dbd03 100644
--- a/src/lib/bluez/agent.c
+++ b/src/lib/bluez/agent.c
@@ -87,10 +87,9 @@ static void agent_init(Agent *self)
{
self->priv = AGENT_GET_PRIVATE(self);
- g_assert(conn != NULL);
+ g_assert(system_conn != NULL);
dbus_g_connection_register_g_object(system_conn, AGENT_DBUS_PATH, G_OBJECT(self));
-
g_print("Agent registered\n");
}
diff --git a/src/lib/bluez/audio.c b/src/lib/bluez/audio.c
index d4abcbf..6c6c0d5 100644
--- a/src/lib/bluez/audio.c
+++ b/src/lib/bluez/audio.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -124,6 +124,9 @@ static void audio_init(Audio *self)
{
self->priv = AUDIO_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(system_conn != NULL);
}
diff --git a/src/lib/bluez/device.c b/src/lib/bluez/device.c
index 12c9017..587b804 100644
--- a/src/lib/bluez/device.c
+++ b/src/lib/bluez/device.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -232,6 +232,9 @@ static void device_init(Device *self)
{
self->priv = DEVICE_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(system_conn != NULL);
}
diff --git a/src/lib/bluez/input.c b/src/lib/bluez/input.c
index cff4b71..09dbdfe 100644
--- a/src/lib/bluez/input.c
+++ b/src/lib/bluez/input.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -124,6 +124,9 @@ static void input_init(Input *self)
{
self->priv = INPUT_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(system_conn != NULL);
}
diff --git a/src/lib/bluez/manager.c b/src/lib/bluez/manager.c
index df50ca3..7eea246 100644
--- a/src/lib/bluez/manager.c
+++ b/src/lib/bluez/manager.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -149,6 +149,9 @@ static void manager_init(Manager *self)
{
self->priv = MANAGER_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(system_conn != NULL);
GError *error = NULL;
diff --git a/src/lib/bluez/network.c b/src/lib/bluez/network.c
index b6e27e6..d6967f0 100644
--- a/src/lib/bluez/network.c
+++ b/src/lib/bluez/network.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -137,6 +137,9 @@ static void network_init(Network *self)
{
self->priv = NETWORK_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(system_conn != NULL);
}
diff --git a/src/lib/bluez/network_server.c b/src/lib/bluez/network_server.c
index cccecd3..78ab124 100644
--- a/src/lib/bluez/network_server.c
+++ b/src/lib/bluez/network_server.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -92,6 +92,9 @@ static void network_server_init(NetworkServer *self)
{
self->priv = NETWORK_SERVER_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(system_conn != NULL);
}
diff --git a/src/lib/bluez/serial.c b/src/lib/bluez/serial.c
index 7cab666..8cd230a 100644
--- a/src/lib/bluez/serial.c
+++ b/src/lib/bluez/serial.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -92,6 +92,9 @@ static void serial_init(Serial *self)
{
self->priv = SERIAL_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(system_conn != NULL);
}
diff --git a/src/lib/dbus-common.c b/src/lib/dbus-common.c
index 1951131..91ee2c9 100644
--- a/src/lib/dbus-common.c
+++ b/src/lib/dbus-common.c
@@ -27,13 +27,14 @@
#include "bluez-api.h"
#include "obexd-api.h"
-#include "ods-api.h"
#include "dbus-common.h"
DBusGConnection *session_conn = NULL;
DBusGConnection *system_conn = NULL;
+static gboolean dbus_initialized = FALSE;
+
void dbus_init()
{
/* Marshallers registration
@@ -41,19 +42,19 @@ void dbus_init()
*/
dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__INT_INT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID);
- dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__STRING_BOOLEAN, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
- dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__UINT64, G_TYPE_NONE, G_TYPE_UINT64, G_TYPE_INVALID);
- dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_INVALID);
- dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__BOXED_STRING_STRING, G_TYPE_NONE, G_TYPE_VALUE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__BOXED_BOOLEAN, G_TYPE_NONE, G_TYPE_VALUE, G_TYPE_BOOLEAN, G_TYPE_INVALID);
/* Agents installation */
dbus_g_object_type_install_info(AGENT_TYPE, &dbus_glib_agent_object_info);
dbus_g_object_type_install_info(OBEXAGENT_TYPE, &dbus_glib_obexagent_object_info);
+
+ dbus_initialized = TRUE;
}
gboolean dbus_session_connect(GError **error)
{
+ g_assert(dbus_initialized == TRUE);
+
session_conn = dbus_g_bus_get(DBUS_BUS_SESSION, error);
if (!session_conn) {
return FALSE;
@@ -69,6 +70,8 @@ void dbus_session_disconnect()
gboolean dbus_system_connect(GError **error)
{
+ g_assert(dbus_initialized == TRUE);
+
system_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, error);
if (!system_conn) {
return FALSE;
@@ -82,3 +85,11 @@ void dbus_system_disconnect()
dbus_g_connection_unref(system_conn);
}
+void dbus_disconnect()
+{
+ if (system_conn)
+ dbus_g_connection_unref(system_conn);
+ if (session_conn)
+ dbus_g_connection_unref(session_conn);
+}
+
diff --git a/src/lib/dbus-common.h b/src/lib/dbus-common.h
index a6d979f..e0fcb9c 100644
--- a/src/lib/dbus-common.h
+++ b/src/lib/dbus-common.h
@@ -39,5 +39,6 @@ gboolean dbus_session_connect(GError **error);
void dbus_session_disconnect();
gboolean dbus_system_connect(GError **error);
void dbus_system_disconnect();
+void dbus_disconnect();
#endif /* __DBUS_COMMON_H */
diff --git a/src/lib/helpers.c b/src/lib/helpers.c
index a310a97..7dc1b03 100644
--- a/src/lib/helpers.c
+++ b/src/lib/helpers.c
@@ -25,15 +25,13 @@
#include <config.h>
#endif
+#include <string.h>
#include <glib.h>
#include <dbus/dbus-glib.h>
-#include <string.h>
#include "dbus-common.h"
#include "helpers.h"
-#include "bluez-api.h"
-
/* UUID Name lookup table */
typedef struct {
gchar *uuid;
@@ -188,11 +186,8 @@ Adapter *find_adapter(const gchar *name, GError **error)
Device *find_device(Adapter *adapter, const gchar *name, GError **error)
{
- g_assert(adapter != NULL);
- g_assert(ADAPTER_IS(adapter));
-
- g_assert(name);
- g_assert(strlen(name) > 0);
+ g_assert(adapter != NULL && ADAPTER_IS(adapter));
+ g_assert(name != NULL && strlen(name) > 0);
gchar *device_path = NULL;
Device *device = NULL;
@@ -230,68 +225,25 @@ Device *find_device(Adapter *adapter, const gchar *name, GError **error)
return device;
}
-gboolean intf_is_supported(const gchar *dbus_object_path, int intf_id)
+gboolean intf_supported(const gchar *dbus_service_name, const gchar *dbus_object_path, const gchar *intf_name)
{
- g_assert(conn != NULL);
- g_assert(dbus_object_path != NULL);
- g_assert(strlen(dbus_object_path) > 0);
- gboolean intf_supported = FALSE;
-
- gchar *check_intf_regex_str = NULL;
- const gchar *dbus_service_name = NULL;
- switch (intf_id) {
- case DEVICE_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_DEVICE_INTERFACE, "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
- break;
- case AUDIO_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_AUDIO_INTERFACE, "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
- break;
- case INPUT_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_INPUT_INTERFACE, "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
- break;
- case NETWORK_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_NETWORK_INTERFACE, "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
- break;
- case NETWORK_HUB_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_NETWORK_HUB_INTERFACE, "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
- break;
- case NETWORK_PEER_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_NETWORK_PEER_INTERFACE, "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
- break;
- case NETWORK_ROUTER_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_NETWORK_ROUTER_INTERFACE, "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
- break;
- case SERIAL_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_SERIAL_INTERFACE, "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
- break;
- case OBEXMANAGER_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_OBEXMANAGER_INTERFACE, "\">", NULL);
- dbus_service_name = OBEX_DBUS_NAME;
- break;
- case OBEXSESSION_INRF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_OBEXSESSION_INTERFACE, "\">", NULL);
- dbus_service_name = OBEX_DBUS_NAME;
- break;
- case OBEXSERVER_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_OBEXSERVER_INTERFACE, "\">", NULL);
- dbus_service_name = OBEX_DBUS_NAME;
- break;
- case OBEXSERVER_SESSION_INTF:
- check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_OBEXSERVER_SESSION_INTERFACE, "\">", NULL);
- dbus_service_name = OBEX_DBUS_NAME;
- break;
- default:
- check_intf_regex_str = g_strconcat("<interface name=\"", "undefined", "\">", NULL);
- dbus_service_name = BLUEZ_DBUS_NAME;
+ g_assert(dbus_service_name != NULL && strlen(dbus_service_name) > 0);
+ g_assert(dbus_object_path != NULL && strlen(dbus_object_path) > 0);
+ g_assert(intf_name != NULL && strlen(intf_name) > 0);
+
+ gboolean supported = FALSE;
+ DBusGConnection *conn = NULL;
+
+ if (g_strcmp0(dbus_service_name, BLUEZ_DBUS_NAME) == 0) {
+ conn = system_conn;
+ } else if (g_strcmp0(dbus_service_name, OBEXD_DBUS_NAME) == 0) {
+ conn = session_conn;
+ } else {
+ return FALSE;
}
+ g_assert(conn != NULL);
+
+ gchar *check_intf_regex_str = g_strconcat("<interface name=\"", intf_name, "\">", NULL);
/* Getting introspection XML */
DBusGProxy *introspection_g_proxy = dbus_g_proxy_new_for_name(conn, dbus_service_name, dbus_object_path, "org.freedesktop.DBus.Introspectable");
@@ -309,13 +261,13 @@ gboolean intf_is_supported(const gchar *dbus_object_path, int intf_id)
g_assert(error == NULL);
if (g_regex_match_simple(check_intf_regex_str, introspection_xml, 0, 0)) {
- intf_supported = TRUE;
+ supported = TRUE;
}
g_free(check_intf_regex_str);
g_free(introspection_xml);
g_object_unref(introspection_g_proxy);
- return intf_supported;
+ return supported;
}
diff --git a/src/lib/helpers.h b/src/lib/helpers.h
index 5e1c573..c0b90f8 100644
--- a/src/lib/helpers.h
+++ b/src/lib/helpers.h
@@ -29,31 +29,12 @@
#include "bluez-api.h"
#include "obexd-api.h"
-#include "ods-api.h"
-enum {
- DEVICE_INTF,
+/* DBus helpers */
+gboolean intf_supported(const gchar *dbus_service_name, const gchar *dbus_object_path, const gchar *intf_name);
- /* 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 */
+/* BlueZ helpers */
Adapter *find_adapter(const gchar *name, GError **error);
-
-/* Device helpers */
Device *find_device(Adapter *adapter, const gchar *name, GError **error);
/* Others helpers */
@@ -73,8 +54,5 @@ inline int xtoi(const gchar *str)
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 */
diff --git a/src/lib/marshallers.c b/src/lib/marshallers.c
index 4fecca4..c88186e 100644
--- a/src/lib/marshallers.c
+++ b/src/lib/marshallers.c
@@ -375,7 +375,7 @@ g_cclosure_bt_marshal_VOID__INT_INT (GClosure *closure,
data2);
}
-/* VOID:STRING,BOOLEAN (lib/marshallers.list:14) */
+/* VOID:STRING,BOOLEAN (lib/marshallers.list:16) */
void
g_cclosure_bt_marshal_VOID__STRING_BOOLEAN (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
@@ -412,7 +412,44 @@ g_cclosure_bt_marshal_VOID__STRING_BOOLEAN (GClosure *closure,
data2);
}
-/* BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER (lib/marshallers.list:17) */
+/* VOID:BOXED,BOOLEAN (lib/marshallers.list:17) */
+void
+g_cclosure_bt_marshal_VOID__BOXED_BOOLEAN (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__BOXED_BOOLEAN) (gpointer data1,
+ gpointer arg_1,
+ gboolean arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__BOXED_BOOLEAN callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__BOXED_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_boolean (param_values + 2),
+ data2);
+}
+
+/* BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER (lib/marshallers.list:20) */
void
g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
@@ -465,7 +502,7 @@ g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTE
g_value_set_boolean (return_value, v_return);
}
-/* BOOLEAN:BOXED,UINT64,POINTER (lib/marshallers.list:20) */
+/* BOOLEAN:BOXED,UINT64,POINTER (lib/marshallers.list:23) */
void
g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT64_POINTER (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
@@ -508,7 +545,7 @@ g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT64_POINTER (GClosure *closure,
g_value_set_boolean (return_value, v_return);
}
-/* BOOLEAN:BOXED,POINTER (lib/marshallers.list:21) */
+/* BOOLEAN:BOXED,POINTER (lib/marshallers.list:24) */
void
g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
@@ -549,192 +586,3 @@ g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER (GClosure *closure,
g_value_set_boolean (return_value, v_return);
}
-/* VOID:STRING,STRING (lib/marshallers.list:25) */
-void
-g_cclosure_bt_marshal_VOID__STRING_STRING (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__STRING_STRING callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_string (param_values + 1),
- g_marshal_value_peek_string (param_values + 2),
- data2);
-}
-
-/* VOID:UINT64 (lib/marshallers.list:26) */
-void
-g_cclosure_bt_marshal_VOID__UINT64 (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__UINT64) (gpointer data1,
- guint64 arg_1,
- gpointer data2);
- register GMarshalFunc_VOID__UINT64 callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 2);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__UINT64) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_uint64 (param_values + 1),
- data2);
-}
-
-/* VOID:STRING,STRING,UINT64 (lib/marshallers.list:27) */
-void
-g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64 (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__STRING_STRING_UINT64) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- guint64 arg_3,
- gpointer data2);
- register GMarshalFunc_VOID__STRING_STRING_UINT64 callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 4);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__STRING_STRING_UINT64) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_string (param_values + 1),
- g_marshal_value_peek_string (param_values + 2),
- g_marshal_value_peek_uint64 (param_values + 3),
- data2);
-}
-
-/* VOID:STRING,STRING,STRING (lib/marshallers.list:30) */
-void
-g_cclosure_bt_marshal_VOID__STRING_STRING_STRING (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__STRING_STRING_STRING) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer arg_3,
- gpointer data2);
- register GMarshalFunc_VOID__STRING_STRING_STRING callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 4);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__STRING_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_string (param_values + 1),
- g_marshal_value_peek_string (param_values + 2),
- g_marshal_value_peek_string (param_values + 3),
- data2);
-}
-
-/* VOID:BOXED,STRING,STRING (lib/marshallers.list:31) */
-void
-g_cclosure_bt_marshal_VOID__BOXED_STRING_STRING (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__BOXED_STRING_STRING) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer arg_3,
- gpointer data2);
- register GMarshalFunc_VOID__BOXED_STRING_STRING callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 4);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__BOXED_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_boxed (param_values + 1),
- g_marshal_value_peek_string (param_values + 2),
- g_marshal_value_peek_string (param_values + 3),
- data2);
-}
-
diff --git a/src/lib/marshallers.h b/src/lib/marshallers.h
index 3076e1c..510e605 100644
--- a/src/lib/marshallers.h
+++ b/src/lib/marshallers.h
@@ -70,7 +70,7 @@ extern void g_cclosure_bt_marshal_VOID__INT_INT (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
-/* VOID:STRING,BOOLEAN (lib/marshallers.list:14) */
+/* VOID:STRING,BOOLEAN (lib/marshallers.list:16) */
extern void g_cclosure_bt_marshal_VOID__STRING_BOOLEAN (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -78,7 +78,15 @@ extern void g_cclosure_bt_marshal_VOID__STRING_BOOLEAN (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
-/* BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER (lib/marshallers.list:17) */
+/* VOID:BOXED,BOOLEAN (lib/marshallers.list:17) */
+extern void g_cclosure_bt_marshal_VOID__BOXED_BOOLEAN (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER (lib/marshallers.list:20) */
extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -86,7 +94,7 @@ extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_PO
gpointer invocation_hint,
gpointer marshal_data);
-/* BOOLEAN:BOXED,UINT64,POINTER (lib/marshallers.list:20) */
+/* BOOLEAN:BOXED,UINT64,POINTER (lib/marshallers.list:23) */
extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT64_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -94,7 +102,7 @@ extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT64_POINTER (GClosure *c
gpointer invocation_hint,
gpointer marshal_data);
-/* BOOLEAN:BOXED,POINTER (lib/marshallers.list:21) */
+/* BOOLEAN:BOXED,POINTER (lib/marshallers.list:24) */
extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -102,46 +110,6 @@ extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
-/* VOID:STRING,STRING (lib/marshallers.list:25) */
-extern void g_cclosure_bt_marshal_VOID__STRING_STRING (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:UINT64 (lib/marshallers.list:26) */
-extern void g_cclosure_bt_marshal_VOID__UINT64 (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:STRING,STRING,UINT64 (lib/marshallers.list:27) */
-extern void g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64 (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:STRING,STRING,STRING (lib/marshallers.list:30) */
-extern void g_cclosure_bt_marshal_VOID__STRING_STRING_STRING (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:BOXED,STRING,STRING (lib/marshallers.list:31) */
-extern void g_cclosure_bt_marshal_VOID__BOXED_STRING_STRING (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
G_END_DECLS
#endif /* __g_cclosure_bt_marshal_MARSHAL_H__ */
diff --git a/src/lib/marshallers.list b/src/lib/marshallers.list
index 21aed8c..87edb09 100644
--- a/src/lib/marshallers.list
+++ b/src/lib/marshallers.list
@@ -11,7 +11,10 @@ BOOLEAN:STRING,POINTER
# [obexd]
VOID:INT,INT
+
+# equals
VOID:STRING,BOOLEAN
+VOID:BOXED,BOOLEAN
# Used by OBEXAgent
BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER
@@ -20,12 +23,3 @@ BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER
BOOLEAN:BOXED,UINT64,POINTER
BOOLEAN:BOXED,POINTER
#BOOLEAN:BOXED,STRING,POINTER
-
-# [ods]
-VOID:STRING,STRING
-VOID:UINT64
-VOID:STRING,STRING,UINT64
-
-# equals
-VOID:STRING,STRING,STRING
-VOID:BOXED,STRING,STRING
diff --git a/src/lib/obexd/obexagent.c b/src/lib/obexd/obexagent.c
index cdf954c..dc98fba 100644
--- a/src/lib/obexd/obexagent.c
+++ b/src/lib/obexd/obexagent.c
@@ -31,6 +31,7 @@
#include <glib.h>
#include "../dbus-common.h"
+#include "../helpers.h"
#include "obexclient_transfer.h"
#include "obexagent.h"
@@ -38,17 +39,44 @@
#define OBEXAGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXAGENT_TYPE, OBEXAgentPrivate))
struct _OBEXAgentPrivate {
+ /* Unused */
DBusGProxy *proxy;
+
+ /* Properties */
+ gchar *root_folder;
};
G_DEFINE_TYPE(OBEXAgent, obexagent, G_TYPE_OBJECT);
+enum {
+ PROP_0,
+
+ PROP_ROOT_FOLDER, /* readwrite, construct only */
+};
+
+static void _obexagent_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static void _obexagent_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
+
+enum {
+ OBEXAGENT_RELEASED,
+
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
static void obexagent_dispose(GObject *gobject)
{
OBEXAgent *self = OBEXAGENT(gobject);
dbus_g_connection_unregister_g_object(session_conn, gobject);
+ /* Proxy free */
+ //g_object_unref(self->priv->proxy);
+
+ /* Properties free */
+ g_free(self->priv->root_folder);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(obexagent_parent_class)->dispose(gobject);
}
@@ -60,34 +88,87 @@ static void obexagent_class_init(OBEXAgentClass *klass)
gobject_class->dispose = obexagent_dispose;
g_type_class_add_private(klass, sizeof(OBEXAgentPrivate));
+
+ /* Signals registation */
+ signals[OBEXAGENT_RELEASED] = g_signal_new("AgentReleased",
+ G_TYPE_FROM_CLASS(gobject_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /* Properties registration */
+ GParamSpec *pspec;
+
+ gobject_class->get_property = _obexagent_get_property;
+ gobject_class->set_property = _obexagent_set_property;
+
+ /* string RootFolder [readwrite, construct only] */
+ pspec = g_param_spec_string("RootFolder", "root_folder", "Root folder location", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property(gobject_class, PROP_ROOT_FOLDER, pspec);
}
static void obexagent_init(OBEXAgent *self)
{
self->priv = OBEXAGENT_GET_PRIVATE(self);
- g_assert(conn != NULL);
+ g_assert(session_conn != NULL);
+
+ /* Properties init */
+ self->priv->root_folder = NULL;
dbus_g_connection_register_g_object(session_conn, OBEXAGENT_DBUS_PATH, G_OBJECT(self));
+ g_print("OBEXAgent registered\n");
+}
+
+static void _obexagent_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+ OBEXAgent *self = OBEXAGENT(object);
- g_print("OBEX Agent registered\n");
+ switch (property_id) {
+ case PROP_ROOT_FOLDER:
+ g_value_set_string(value, self->priv->root_folder);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
+ }
+}
+
+static void _obexagent_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+ OBEXAgent *self = OBEXAGENT(object);
+
+ switch (property_id) {
+ case PROP_ROOT_FOLDER:
+ self->priv->root_folder = g_value_dup_string(value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
+ }
}
/* Methods */
-/* Agent API */
+/* Server API */
gboolean obexagent_authorize(OBEXAgent *self, const gchar *transfer, const gchar *bt_address, const gchar *name, const gchar *type, gint length, gint time, gchar **ret, GError **error)
{
+ g_assert(self->priv->root_folder != NULL && strlen(self->priv->root_folder));
+
*ret = NULL;
- g_print("[Bluetooth ObjectPush request]\n");
- OBEXClientTransfer *transfer_obj = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
- g_print(" Transfer: %s (%llu bytes), %s\n", obexclient_transfer_get_name(transfer_obj), obexclient_transfer_get_size(transfer_obj), obexclient_transfer_get_filename(transfer_obj));
- g_object_unref(transfer_obj);
+ g_print("[ObjectPush Request]\n");
g_print(" Address: %s\n", bt_address);
g_print(" Name: %s\n", name);
- g_print(" Type: %s\n", type);
- g_print(" Length: %d\n", length);
- g_print(" Time: %d\n", time);
+ if (type && strlen(type)) {
+ g_print(" Type: %s\n", type);
+ }
+ g_print(" Length: %d bytes\n", length);
+ /*if (time) {
+ g_print(" Time: %d\n", time);
+ }*/
gchar yn[4] = {0,};
g_print("Accept (yes/no)? ");
@@ -96,7 +177,16 @@ gboolean obexagent_authorize(OBEXAgent *self, const gchar *transfer, const gchar
g_warning("%s\n", strerror(errno));
}
if (g_strcmp0(yn, "y") == 0 || g_strcmp0(yn, "yes") == 0) {
- *ret = g_strdup("/home/zak/obp.ext");
+ if (!g_path_is_absolute(self->priv->root_folder)) {
+ gchar *current_dir = g_get_current_dir();
+ gchar *end_path = g_build_filename(self->priv->root_folder, name, NULL);
+ *ret = g_build_filename(current_dir, end_path, NULL);
+ g_free(current_dir);
+ g_free(end_path);
+ } else {
+ *ret = g_build_filename(self->priv->root_folder, name, NULL);
+ }
+
return TRUE;
} else {
// TODO: Fix error code
@@ -104,8 +194,6 @@ gboolean obexagent_authorize(OBEXAgent *self, const gchar *transfer, const gchar
*error = g_error_new(g_quark_from_static_string("org.openobex.Error.Rejected"), 0, "File transfer rejected");
return FALSE;
}
-
- return TRUE;
}
gboolean obexagent_cancel(OBEXAgent *self, GError **error)
@@ -117,16 +205,22 @@ gboolean obexagent_cancel(OBEXAgent *self, GError **error)
/* Client API */
gboolean obexagent_release(OBEXAgent *self, GError **error)
{
- g_print("OBEX Agent released\n");
+ g_print("OBEXAgent released\n");
+
+ g_signal_emit(self, signals[OBEXAGENT_RELEASED], 0);
+
return TRUE;
}
gboolean obexagent_request(OBEXAgent *self, const gchar *transfer, gchar **ret, GError **error)
{
*ret = NULL;
- OBEXClientTransfer *transfer_obj = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
- g_print("Transfer: %s (%llu bytes), %s\n", obexclient_transfer_get_name(transfer_obj), obexclient_transfer_get_size(transfer_obj), obexclient_transfer_get_filename(transfer_obj));
- g_object_unref(transfer_obj);
+ OBEXClientTransfer *transfer_t = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
+ g_print("[Transfer Request]\n");
+ g_print(" Name: %s\n", obexclient_transfer_get_name(transfer_t));
+ g_print(" Size: %llu bytes\n", obexclient_transfer_get_size(transfer_t));
+ g_print(" Filename: %s\n", obexclient_transfer_get_filename(transfer_t));
+ g_object_unref(transfer_t);
gchar yn[4] = {0,};
g_print("Accept (yes/no)? ");
@@ -148,27 +242,43 @@ gboolean obexagent_request(OBEXAgent *self, const gchar *transfer, gchar **ret,
gboolean obexagent_progress(OBEXAgent *self, const gchar *transfer, guint64 transferred, GError **error)
{
- OBEXClientTransfer *transfer_obj = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
- g_print("Transfer progress: %s (%llu/%llu bytes), %s\n", obexclient_transfer_get_name(transfer_obj), transferred, obexclient_transfer_get_size(transfer_obj), obexclient_transfer_get_filename(transfer_obj));
- g_object_unref(transfer_obj);
+ OBEXClientTransfer *transfer_t = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
+ guint64 total = obexclient_transfer_get_size(transfer_t);
+
+ guint pp = (transferred / (gfloat) total)*100;
+
+ static gboolean update_progress = FALSE;
+ if (!update_progress) {
+ g_print("[Transfer#%s] Progress: %3u%%", obexclient_transfer_get_filename(transfer_t), pp);
+ update_progress = TRUE;
+ } else {
+ g_print("\b\b\b\b%3u%%", pp);
+ }
+
+ if (pp == 100) {
+ g_print("\n");
+ update_progress = FALSE;
+ }
+
+ g_object_unref(transfer_t);
return TRUE;
}
gboolean obexagent_complete(OBEXAgent *self, const gchar *transfer, GError **error)
{
- OBEXClientTransfer *transfer_obj = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
- g_print("Transfer complete: %s (%llu bytes), %s\n", obexclient_transfer_get_name(transfer_obj), obexclient_transfer_get_size(transfer_obj), obexclient_transfer_get_filename(transfer_obj));
- g_object_unref(transfer_obj);
+ OBEXClientTransfer *transfer_t = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
+ g_print("[Transfer#%s] Completed\n", obexclient_transfer_get_filename(transfer_t));
+ g_object_unref(transfer_t);
return TRUE;
}
gboolean obexagent_error(OBEXAgent *self, const gchar *transfer, const gchar *message, GError **error)
{
- OBEXClientTransfer *transfer_obj = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
- g_print("Transfer error: %s (%llu bytes), %s: %s\n", obexclient_transfer_get_name(transfer_obj), obexclient_transfer_get_size(transfer_obj), obexclient_transfer_get_filename(transfer_obj), message);
- g_object_unref(transfer_obj);
+ OBEXClientTransfer *transfer_t = g_object_new(OBEXCLIENT_TRANSFER_TYPE, "DBusObjectPath", transfer, NULL);
+ g_print("[Transfer#%s] Error: %s\n", obexclient_transfer_get_filename(transfer_t), message);
+ g_object_unref(transfer_t);
return TRUE;
}
diff --git a/src/lib/obexd/obexagent.h b/src/lib/obexd/obexagent.h
index 997ac6d..b94fb2c 100644
--- a/src/lib/obexd/obexagent.h
+++ b/src/lib/obexd/obexagent.h
@@ -63,7 +63,7 @@ GType obexagent_get_type(void) G_GNUC_CONST;
* Method definitions
*/
-/* Agent API */
+/* Server API */
gboolean obexagent_authorize(OBEXAgent *self, const gchar *transfer, const gchar *bt_address, const gchar *name, const gchar *type, gint length, gint time, gchar **ret, GError **error);
gboolean obexagent_cancel(OBEXAgent *self, GError **error);
diff --git a/src/lib/obexd/obexclient.c b/src/lib/obexd/obexclient.c
index ba78633..1a15c93 100644
--- a/src/lib/obexd/obexclient.c
+++ b/src/lib/obexd/obexclient.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -73,6 +73,9 @@ static void obexclient_init(OBEXClient *self)
{
self->priv = OBEXCLIENT_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(session_conn != NULL);
GError *error = NULL;
diff --git a/src/lib/obexd/obexclient_file_transfer.c b/src/lib/obexd/obexclient_file_transfer.c
index 60f44dd..e15de6c 100644
--- a/src/lib/obexd/obexclient_file_transfer.c
+++ b/src/lib/obexd/obexclient_file_transfer.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -92,6 +92,9 @@ static void obexclient_file_transfer_init(OBEXClientFileTransfer *self)
{
self->priv = OBEXCLIENT_FILE_TRANSFER_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(session_conn != NULL);
}
diff --git a/src/lib/obexd/obexclient_session.c b/src/lib/obexd/obexclient_session.c
index 810536c..8702d39 100644
--- a/src/lib/obexd/obexclient_session.c
+++ b/src/lib/obexd/obexclient_session.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -116,6 +116,9 @@ static void obexclient_session_init(OBEXClientSession *self)
{
self->priv = OBEXCLIENT_SESSION_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(session_conn != NULL);
}
diff --git a/src/lib/obexd/obexclient_transfer.c b/src/lib/obexd/obexclient_transfer.c
index 04f7444..b3e7560 100644
--- a/src/lib/obexd/obexclient_transfer.c
+++ b/src/lib/obexd/obexclient_transfer.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -116,6 +116,9 @@ static void obexclient_transfer_init(OBEXClientTransfer *self)
{
self->priv = OBEXCLIENT_TRANSFER_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(session_conn != NULL);
}
diff --git a/src/lib/obexd/obexmanager.c b/src/lib/obexd/obexmanager.c
index f17292d..3a6d368 100644
--- a/src/lib/obexd/obexmanager.c
+++ b/src/lib/obexd/obexmanager.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -124,6 +124,9 @@ static void obexmanager_init(OBEXManager *self)
{
self->priv = OBEXMANAGER_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(session_conn != NULL);
GError *error = NULL;
diff --git a/src/lib/obexd/obexsession.c b/src/lib/obexd/obexsession.c
index 8883c1d..fa80e02 100644
--- a/src/lib/obexd/obexsession.c
+++ b/src/lib/obexd/obexsession.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -103,6 +103,9 @@ static void obexsession_init(OBEXSession *self)
{
self->priv = OBEXSESSION_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(session_conn != NULL);
}
diff --git a/src/lib/obexd/obextransfer.c b/src/lib/obexd/obextransfer.c
index bb08db9..59556e4 100644
--- a/src/lib/obexd/obextransfer.c
+++ b/src/lib/obexd/obextransfer.c
@@ -25,8 +25,8 @@
#include <config.h>
#endif
-#include <glib.h>
#include <string.h>
+#include <glib.h>
#include "../dbus-common.h"
#include "../marshallers.h"
@@ -113,6 +113,9 @@ static void obextransfer_init(OBEXTransfer *self)
{
self->priv = OBEXTRANSFER_GET_PRIVATE(self);
+ /* DBusGProxy init */
+ self->priv->dbus_g_proxy = NULL;
+
g_assert(session_conn != NULL);
}
diff --git a/src/lib/ods-api.h b/src/lib/ods-api.h
deleted file mode 100644
index b0644f3..0000000
--- a/src/lib/ods-api.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * 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 __ODS_API_H
-#define __ODS_API_H
-
-/* Global includes */
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-#define ODS_DBUS_NAME "org.openobex"
-
-/* ODS DBus API */
-#include "ods/obexmanager.h"
-#include "ods/obexserver.h"
-#include "ods/obexserver_session.h"
-#include "ods/obexsession.h"
-
-#endif /* __ODS_API_H */
-
diff --git a/src/lib/ods/obexmanager.c b/src/lib/ods/obexmanager.c
deleted file mode 100644
index 3eb7b10..0000000
--- a/src/lib/ods/obexmanager.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- *
- * 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
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-
-#include "../dbus-common.h"
-#include "../marshallers.h"
-
-#include "obexmanager.h"
-
-#define OBEXMANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXMANAGER_TYPE, OBEXManagerPrivate))
-
-struct _OBEXManagerPrivate {
- DBusGProxy *dbus_g_proxy;
-
- /* Introspection data */
- DBusGProxy *introspection_g_proxy;
- gchar *introspection_xml;
-};
-
-G_DEFINE_TYPE(OBEXManager, obexmanager, G_TYPE_OBJECT);
-
-enum {
- SESSION_CLOSED,
- SESSION_CONNECT_ERROR,
- SESSION_CONNECTED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-static void session_closed_handler(DBusGProxy *dbus_g_proxy, const gchar *path, gpointer data);
-static void session_connect_error_handler(DBusGProxy *dbus_g_proxy, const gchar *path, const gchar *error_name, const gchar *error_message, gpointer data);
-static void session_connected_handler(DBusGProxy *dbus_g_proxy, const gchar *path, gpointer data);
-
-static void obexmanager_dispose(GObject *gobject)
-{
- OBEXManager *self = OBEXMANAGER(gobject);
-
- /* DBus signals disconnection */
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "SessionClosed", G_CALLBACK(session_closed_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "SessionConnectError", G_CALLBACK(session_connect_error_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "SessionConnected", G_CALLBACK(session_connected_handler), self);
-
- /* Proxy free */
- g_object_unref(self->priv->dbus_g_proxy);
-
- /* Introspection data free */
- g_free(self->priv->introspection_xml);
- g_object_unref(self->priv->introspection_g_proxy);
-
- /* Chain up to the parent class */
- G_OBJECT_CLASS(obexmanager_parent_class)->dispose(gobject);
-}
-
-static void obexmanager_class_init(OBEXManagerClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->dispose = obexmanager_dispose;
-
- g_type_class_add_private(klass, sizeof(OBEXManagerPrivate));
-
- /* Signals registation */
- signals[SESSION_CLOSED] = g_signal_new("SessionClosed",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- signals[SESSION_CONNECT_ERROR] = g_signal_new("SessionConnectError",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_bt_marshal_VOID__STRING_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-
- signals[SESSION_CONNECTED] = g_signal_new("SessionConnected",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-}
-
-static void obexmanager_init(OBEXManager *self)
-{
- self->priv = OBEXMANAGER_GET_PRIVATE(self);
-
- g_assert(system_conn != NULL);
-
- GError *error = NULL;
-
- /* Getting introspection XML */
- self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", OBEXMANAGER_DBUS_PATH, "org.freedesktop.DBus.Introspectable");
- self->priv->introspection_xml = NULL;
- if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
- g_critical("%s", error->message);
- }
- g_assert(error == NULL);
-
- gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXMANAGER_DBUS_INTERFACE, "\">", NULL);
- if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
- g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXMANAGER_DBUS_INTERFACE, OBEXMANAGER_DBUS_PATH);
- g_assert(FALSE);
- }
- g_free(check_intf_regex_str);
-
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", OBEXMANAGER_DBUS_PATH, OBEXMANAGER_DBUS_INTERFACE);
-
- /* DBus signals connection */
-
- /* SessionClosed(object path) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "SessionClosed", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "SessionClosed", G_CALLBACK(session_closed_handler), self, NULL);
-
- /* SessionConnectError(object path, string error_name, string error_message) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "SessionConnectError", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "SessionConnectError", G_CALLBACK(session_connect_error_handler), self, NULL);
-
- /* SessionConnected(object path) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "SessionConnected", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "SessionConnected", G_CALLBACK(session_connected_handler), self, NULL);
-}
-
-/* Methods */
-
-/* boolean CancelSessionConnect(object session_object) */
-gboolean obexmanager_cancel_session_connect(OBEXManager *self, const gchar *session_object, GError **error)
-{
- g_assert(OBEXMANAGER_IS(self));
-
- gboolean ret = FALSE;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "CancelSessionConnect", error, DBUS_TYPE_G_OBJECT_PATH, session_object, G_TYPE_INVALID, G_TYPE_BOOLEAN, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* object CreateBluetoothServer(string source_address, string pattern, boolean require_pairing) */
-gchar *obexmanager_create_bluetooth_server(OBEXManager *self, const gchar *source_address, const gchar *pattern, const gboolean require_pairing, GError **error)
-{
- g_assert(OBEXMANAGER_IS(self));
-
- gchar *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "CreateBluetoothServer", error, G_TYPE_STRING, source_address, G_TYPE_STRING, pattern, G_TYPE_BOOLEAN, require_pairing, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* object CreateBluetoothSession(string target_address, string source_address, string pattern) */
-gchar *obexmanager_create_bluetooth_session(OBEXManager *self, const gchar *target_address, const gchar *source_address, const gchar *pattern, GError **error)
-{
- g_assert(OBEXMANAGER_IS(self));
-
- gchar *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "CreateBluetoothSession", error, G_TYPE_STRING, target_address, G_TYPE_STRING, source_address, G_TYPE_STRING, pattern, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* dict{s,s} GetServerInfo(object server_object) */
-GHashTable *obexmanager_get_server_info(OBEXManager *self, const gchar *server_object, GError **error)
-{
- g_assert(OBEXMANAGER_IS(self));
-
- GHashTable *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetServerInfo", error, DBUS_TYPE_G_OBJECT_PATH, server_object, G_TYPE_INVALID, DBUS_TYPE_G_STRING_STRING_HASHTABLE, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* array{string} GetServerList() */
-gchar **obexmanager_get_server_list(OBEXManager *self, GError **error)
-{
- g_assert(OBEXMANAGER_IS(self));
-
- gchar **ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetServerList", error, G_TYPE_INVALID, G_TYPE_STRV, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* dict{s,s} GetSessionInfo(object session_object) */
-GHashTable *obexmanager_get_session_info(OBEXManager *self, const gchar *session_object, GError **error)
-{
- g_assert(OBEXMANAGER_IS(self));
-
- GHashTable *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetSessionInfo", error, DBUS_TYPE_G_OBJECT_PATH, session_object, G_TYPE_INVALID, DBUS_TYPE_G_STRING_STRING_HASHTABLE, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* array{string} GetSessionList() */
-gchar **obexmanager_get_session_list(OBEXManager *self, GError **error)
-{
- g_assert(OBEXMANAGER_IS(self));
-
- gchar **ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetSessionList", error, G_TYPE_INVALID, G_TYPE_STRV, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* string GetVersion() */
-gchar *obexmanager_get_version(OBEXManager *self, GError **error)
-{
- g_assert(OBEXMANAGER_IS(self));
-
- gchar *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetVersion", error, G_TYPE_INVALID, G_TYPE_STRING, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* Signals handlers */
-static void session_closed_handler(DBusGProxy *dbus_g_proxy, const gchar *path, gpointer data)
-{
- OBEXManager *self = OBEXMANAGER(data);
-
- g_signal_emit(self, signals[SESSION_CLOSED], 0, path);
-}
-
-static void session_connect_error_handler(DBusGProxy *dbus_g_proxy, const gchar *path, const gchar *error_name, const gchar *error_message, gpointer data)
-{
- OBEXManager *self = OBEXMANAGER(data);
-
- g_signal_emit(self, signals[SESSION_CONNECT_ERROR], 0, path, error_name, error_message);
-}
-
-static void session_connected_handler(DBusGProxy *dbus_g_proxy, const gchar *path, gpointer data)
-{
- OBEXManager *self = OBEXMANAGER(data);
-
- g_signal_emit(self, signals[SESSION_CONNECTED], 0, path);
-}
-
diff --git a/src/lib/ods/obexmanager.h b/src/lib/ods/obexmanager.h
deleted file mode 100644
index 20e12ea..0000000
--- a/src/lib/ods/obexmanager.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * 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 __OBEXMANAGER_H
-#define __OBEXMANAGER_H
-
-#include <glib-object.h>
-
-#define OBEXMANAGER_DBUS_PATH "/org/openobex"
-#define OBEXMANAGER_DBUS_INTERFACE "org.openobex.Manager"
-
-/*
- * Type macros
- */
-#define OBEXMANAGER_TYPE (obexmanager_get_type())
-#define OBEXMANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXMANAGER_TYPE, OBEXManager))
-#define OBEXMANAGER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXMANAGER_TYPE))
-#define OBEXMANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXMANAGER_TYPE, OBEXManagerClass))
-#define OBEXMANAGER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXMANAGER_TYPE))
-#define OBEXMANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXMANAGER_TYPE, OBEXManagerClass))
-
-typedef struct _OBEXManager OBEXManager;
-typedef struct _OBEXManagerClass OBEXManagerClass;
-typedef struct _OBEXManagerPrivate OBEXManagerPrivate;
-
-struct _OBEXManager {
- GObject parent_instance;
-
- /*< private >*/
- OBEXManagerPrivate *priv;
-};
-
-struct _OBEXManagerClass {
- GObjectClass parent_class;
-};
-
-/* used by OBEXMANAGER_TYPE */
-GType obexmanager_get_type(void) G_GNUC_CONST;
-
-/*
- * Method definitions
- */
-gboolean obexmanager_cancel_session_connect(OBEXManager *self, const gchar *session_object, GError **error);
-gchar *obexmanager_create_bluetooth_server(OBEXManager *self, const gchar *source_address, const gchar *pattern, const gboolean require_pairing, GError **error);
-gchar *obexmanager_create_bluetooth_session(OBEXManager *self, const gchar *target_address, const gchar *source_address, const gchar *pattern, GError **error);
-GHashTable *obexmanager_get_server_info(OBEXManager *self, const gchar *server_object, GError **error);
-gchar **obexmanager_get_server_list(OBEXManager *self, GError **error);
-GHashTable *obexmanager_get_session_info(OBEXManager *self, const gchar *session_object, GError **error);
-gchar **obexmanager_get_session_list(OBEXManager *self, GError **error);
-gchar *obexmanager_get_version(OBEXManager *self, GError **error);
-
-#endif /* __OBEXMANAGER_H */
-
diff --git a/src/lib/ods/obexserver.c b/src/lib/ods/obexserver.c
deleted file mode 100644
index ab968b2..0000000
--- a/src/lib/ods/obexserver.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- *
- * 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
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-
-#include "../dbus-common.h"
-#include "../marshallers.h"
-
-#include "obexserver.h"
-
-#define OBEXSERVER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXSERVER_TYPE, OBEXServerPrivate))
-
-struct _OBEXServerPrivate {
- DBusGProxy *dbus_g_proxy;
-
- /* Introspection data */
- DBusGProxy *introspection_g_proxy;
- gchar *introspection_xml;
-};
-
-G_DEFINE_TYPE(OBEXServer, obexserver, G_TYPE_OBJECT);
-
-enum {
- PROP_0,
-
- PROP_DBUS_OBJECT_PATH /* readwrite, construct only */
-};
-
-static void _obexserver_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static void _obexserver_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-
-enum {
- CLOSED,
- ERROR_OCCURRED,
- SESSION_CREATED,
- SESSION_REMOVED,
- STARTED,
- STOPPED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-static void closed_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void error_occurred_handler(DBusGProxy *dbus_g_proxy, const gchar *error_name, const gchar *error_message, gpointer data);
-static void session_created_handler(DBusGProxy *dbus_g_proxy, const gchar *session_object, gpointer data);
-static void session_removed_handler(DBusGProxy *dbus_g_proxy, const gchar *session_object, gpointer data);
-static void started_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void stopped_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-
-static void obexserver_dispose(GObject *gobject)
-{
- OBEXServer *self = OBEXSERVER(gobject);
-
- /* DBus signals disconnection */
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Closed", G_CALLBACK(closed_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_CALLBACK(error_occurred_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "SessionCreated", G_CALLBACK(session_created_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "SessionRemoved", G_CALLBACK(session_removed_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Started", G_CALLBACK(started_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Stopped", G_CALLBACK(stopped_handler), self);
-
- /* Proxy free */
- g_object_unref(self->priv->dbus_g_proxy);
-
- /* Introspection data free */
- g_free(self->priv->introspection_xml);
- g_object_unref(self->priv->introspection_g_proxy);
-
- /* Chain up to the parent class */
- G_OBJECT_CLASS(obexserver_parent_class)->dispose(gobject);
-}
-
-static void obexserver_class_init(OBEXServerClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->dispose = obexserver_dispose;
-
- g_type_class_add_private(klass, sizeof(OBEXServerPrivate));
-
- /* Properties registration */
- GParamSpec *pspec;
-
- gobject_class->get_property = _obexserver_get_property;
- gobject_class->set_property = _obexserver_set_property;
-
- /* object DBusObjectPath [readwrite, construct only] */
- pspec = g_param_spec_string("DBusObjectPath", "dbus_object_path", "Adapter D-Bus object path", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property(gobject_class, PROP_DBUS_OBJECT_PATH, pspec);
-
- /* Signals registation */
- signals[CLOSED] = g_signal_new("Closed",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[ERROR_OCCURRED] = g_signal_new("ErrorOccurred",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_bt_marshal_VOID__STRING_STRING,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
-
- signals[SESSION_CREATED] = g_signal_new("SessionCreated",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- signals[SESSION_REMOVED] = g_signal_new("SessionRemoved",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- signals[STARTED] = g_signal_new("Started",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[STOPPED] = g_signal_new("Stopped",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void obexserver_init(OBEXServer *self)
-{
- self->priv = OBEXSERVER_GET_PRIVATE(self);
-
- g_assert(system_conn != NULL);
-}
-
-static void obexserver_post_init(OBEXServer *self, const gchar *dbus_object_path)
-{
- g_assert(dbus_object_path != NULL);
- g_assert(strlen(dbus_object_path) > 0);
- g_assert(self->priv->dbus_g_proxy == NULL);
-
- GError *error = NULL;
-
- /* Getting introspection XML */
- self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable");
- self->priv->introspection_xml = NULL;
- if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
- g_critical("%s", error->message);
- }
- g_assert(error == NULL);
-
- gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXSERVER_DBUS_INTERFACE, "\">", NULL);
- if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
- g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXSERVER_DBUS_INTERFACE, dbus_object_path);
- g_assert(FALSE);
- }
- g_free(check_intf_regex_str);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, OBEXSERVER_DBUS_INTERFACE);
-
- /* DBus signals connection */
-
- /* Closed() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Closed", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Closed", G_CALLBACK(closed_handler), self, NULL);
-
- /* ErrorOccurred(string error_name, string error_message) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_CALLBACK(error_occurred_handler), self, NULL);
-
- /* SessionCreated(object session_object) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "SessionCreated", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "SessionCreated", G_CALLBACK(session_created_handler), self, NULL);
-
- /* SessionRemoved(object session_object) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "SessionRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "SessionRemoved", G_CALLBACK(session_removed_handler), self, NULL);
-
- /* Started() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Started", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Started", G_CALLBACK(started_handler), self, NULL);
-
- /* Stopped() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Stopped", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Stopped", G_CALLBACK(stopped_handler), self, NULL);
-}
-
-static void _obexserver_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- OBEXServer *self = OBEXSERVER(object);
-
- switch (property_id) {
- case PROP_DBUS_OBJECT_PATH:
- g_value_set_string(value, obexserver_get_dbus_object_path(self));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
- }
-}
-
-static void _obexserver_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- OBEXServer *self = OBEXSERVER(object);
- GError *error = NULL;
-
- switch (property_id) {
- case PROP_DBUS_OBJECT_PATH:
- obexserver_post_init(self, g_value_get_string(value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
- }
-
- if (error != NULL) {
- g_critical("%s", error->message);
- }
- g_assert(error == NULL);
-}
-
-/* Methods */
-
-/* void Close() */
-void obexserver_close(OBEXServer *self, GError **error)
-{
- g_assert(OBEXSERVER_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Close", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* dict{s,s} GetServerSessionInfo(object session_object) */
-GHashTable *obexserver_get_server_session_info(OBEXServer *self, const gchar *session_object, GError **error)
-{
- g_assert(OBEXSERVER_IS(self));
-
- GHashTable *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetServerSessionInfo", error, DBUS_TYPE_G_OBJECT_PATH, session_object, G_TYPE_INVALID, DBUS_TYPE_G_STRING_STRING_HASHTABLE, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* array{string} GetServerSessionList() */
-gchar **obexserver_get_server_session_list(OBEXServer *self, GError **error)
-{
- g_assert(OBEXSERVER_IS(self));
-
- gchar **ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetServerSessionList", error, G_TYPE_INVALID, G_TYPE_STRV, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* boolean IsStarted() */
-gboolean obexserver_is_started(OBEXServer *self, GError **error)
-{
- g_assert(OBEXSERVER_IS(self));
-
- gboolean ret = FALSE;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "IsStarted", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* void SetOption(string name, variant value) */
-void obexserver_set_option(OBEXServer *self, const gchar *name, const GValue *value, GError **error)
-{
- g_assert(OBEXSERVER_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "SetOption", error, G_TYPE_STRING, name, G_TYPE_VALUE, value, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void Start(string path, boolean allow_write, boolean auto_accept) */
-void obexserver_start(OBEXServer *self, const gchar *path, const gboolean allow_write, const gboolean auto_accept, GError **error)
-{
- g_assert(OBEXSERVER_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Start", error, G_TYPE_STRING, path, G_TYPE_BOOLEAN, allow_write, G_TYPE_BOOLEAN, auto_accept, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void Stop() */
-void obexserver_stop(OBEXServer *self, GError **error)
-{
- g_assert(OBEXSERVER_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Stop", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* Properties access methods */
-const gchar *obexserver_get_dbus_object_path(OBEXServer *self)
-{
- g_assert(OBEXSERVER_IS(self));
-
- return dbus_g_proxy_get_path(self->priv->dbus_g_proxy);
-}
-
-/* Signals handlers */
-static void closed_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXServer *self = OBEXSERVER(data);
-
- g_signal_emit(self, signals[CLOSED], 0);
-}
-
-static void error_occurred_handler(DBusGProxy *dbus_g_proxy, const gchar *error_name, const gchar *error_message, gpointer data)
-{
- OBEXServer *self = OBEXSERVER(data);
-
- g_signal_emit(self, signals[ERROR_OCCURRED], 0, error_name, error_message);
-}
-
-static void session_created_handler(DBusGProxy *dbus_g_proxy, const gchar *session_object, gpointer data)
-{
- OBEXServer *self = OBEXSERVER(data);
-
- g_signal_emit(self, signals[SESSION_CREATED], 0, session_object);
-}
-
-static void session_removed_handler(DBusGProxy *dbus_g_proxy, const gchar *session_object, gpointer data)
-{
- OBEXServer *self = OBEXSERVER(data);
-
- g_signal_emit(self, signals[SESSION_REMOVED], 0, session_object);
-}
-
-static void started_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXServer *self = OBEXSERVER(data);
-
- g_signal_emit(self, signals[STARTED], 0);
-}
-
-static void stopped_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXServer *self = OBEXSERVER(data);
-
- g_signal_emit(self, signals[STOPPED], 0);
-}
-
diff --git a/src/lib/ods/obexserver.h b/src/lib/ods/obexserver.h
deleted file mode 100644
index f4a3c60..0000000
--- a/src/lib/ods/obexserver.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * 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 __OBEXSERVER_H
-#define __OBEXSERVER_H
-
-#include <glib-object.h>
-
-#define OBEXSERVER_DBUS_INTERFACE "org.openobex.Server"
-
-/*
- * Type macros
- */
-#define OBEXSERVER_TYPE (obexserver_get_type())
-#define OBEXSERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXSERVER_TYPE, OBEXServer))
-#define OBEXSERVER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXSERVER_TYPE))
-#define OBEXSERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXSERVER_TYPE, OBEXServerClass))
-#define OBEXSERVER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXSERVER_TYPE))
-#define OBEXSERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXSERVER_TYPE, OBEXServerClass))
-
-typedef struct _OBEXServer OBEXServer;
-typedef struct _OBEXServerClass OBEXServerClass;
-typedef struct _OBEXServerPrivate OBEXServerPrivate;
-
-struct _OBEXServer {
- GObject parent_instance;
-
- /*< private >*/
- OBEXServerPrivate *priv;
-};
-
-struct _OBEXServerClass {
- GObjectClass parent_class;
-};
-
-/* used by OBEXSERVER_TYPE */
-GType obexserver_get_type(void) G_GNUC_CONST;
-
-/*
- * Method definitions
- */
-void obexserver_close(OBEXServer *self, GError **error);
-GHashTable *obexserver_get_server_session_info(OBEXServer *self, const gchar *session_object, GError **error);
-gchar **obexserver_get_server_session_list(OBEXServer *self, GError **error);
-gboolean obexserver_is_started(OBEXServer *self, GError **error);
-void obexserver_set_option(OBEXServer *self, const gchar *name, const GValue *value, GError **error);
-void obexserver_start(OBEXServer *self, const gchar *path, const gboolean allow_write, const gboolean auto_accept, GError **error);
-void obexserver_stop(OBEXServer *self, GError **error);
-
-const gchar *obexserver_get_dbus_object_path(OBEXServer *self);
-
-#endif /* __OBEXSERVER_H */
-
diff --git a/src/lib/ods/obexserver_session.c b/src/lib/ods/obexserver_session.c
deleted file mode 100644
index 5920517..0000000
--- a/src/lib/ods/obexserver_session.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- *
- * 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
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-
-#include "../dbus-common.h"
-#include "../marshallers.h"
-
-#include "obexserver_session.h"
-
-#define OBEXSERVER_SESSION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXSERVER_SESSION_TYPE, OBEXServerSessionPrivate))
-
-struct _OBEXServerSessionPrivate {
- DBusGProxy *dbus_g_proxy;
-
- /* Introspection data */
- DBusGProxy *introspection_g_proxy;
- gchar *introspection_xml;
-};
-
-G_DEFINE_TYPE(OBEXServerSession, obexserver_session, G_TYPE_OBJECT);
-
-enum {
- PROP_0,
-
- PROP_DBUS_OBJECT_PATH /* readwrite, construct only */
-};
-
-static void _obexserver_session_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static void _obexserver_session_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-
-enum {
- CANCELLED,
- DISCONNECTED,
- ERROR_OCCURRED,
- TRANSFER_COMPLETED,
- TRANSFER_PROGRESS,
- TRANSFER_STARTED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-static void cancelled_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void disconnected_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void error_occurred_handler(DBusGProxy *dbus_g_proxy, const gchar *error_name, const gchar *error_message, gpointer data);
-static void transfer_completed_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void transfer_progress_handler(DBusGProxy *dbus_g_proxy, const guint64 bytes_transferred, gpointer data);
-static void transfer_started_handler(DBusGProxy *dbus_g_proxy, const gchar *filename, const gchar *local_path, const guint64 total_bytes, gpointer data);
-
-static void obexserver_session_dispose(GObject *gobject)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(gobject);
-
- /* DBus signals disconnection */
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Cancelled", G_CALLBACK(cancelled_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Disconnected", G_CALLBACK(disconnected_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_CALLBACK(error_occurred_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "TransferCompleted", G_CALLBACK(transfer_completed_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "TransferProgress", G_CALLBACK(transfer_progress_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "TransferStarted", G_CALLBACK(transfer_started_handler), self);
-
- /* Proxy free */
- g_object_unref(self->priv->dbus_g_proxy);
-
- /* Introspection data free */
- g_free(self->priv->introspection_xml);
- g_object_unref(self->priv->introspection_g_proxy);
-
- /* Chain up to the parent class */
- G_OBJECT_CLASS(obexserver_session_parent_class)->dispose(gobject);
-}
-
-static void obexserver_session_class_init(OBEXServerSessionClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->dispose = obexserver_session_dispose;
-
- g_type_class_add_private(klass, sizeof(OBEXServerSessionPrivate));
-
- /* Properties registration */
- GParamSpec *pspec;
-
- gobject_class->get_property = _obexserver_session_get_property;
- gobject_class->set_property = _obexserver_session_set_property;
-
- /* object DBusObjectPath [readwrite, construct only] */
- pspec = g_param_spec_string("DBusObjectPath", "dbus_object_path", "Adapter D-Bus object path", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property(gobject_class, PROP_DBUS_OBJECT_PATH, pspec);
-
- /* Signals registation */
- signals[CANCELLED] = g_signal_new("Cancelled",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[DISCONNECTED] = g_signal_new("Disconnected",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[ERROR_OCCURRED] = g_signal_new("ErrorOccurred",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_bt_marshal_VOID__STRING_STRING,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
-
- signals[TRANSFER_COMPLETED] = g_signal_new("TransferCompleted",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[TRANSFER_PROGRESS] = g_signal_new("TransferProgress",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_bt_marshal_VOID__UINT64,
- G_TYPE_NONE, 1, G_TYPE_UINT64);
-
- signals[TRANSFER_STARTED] = g_signal_new("TransferStarted",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64,
- G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64);
-}
-
-static void obexserver_session_init(OBEXServerSession *self)
-{
- self->priv = OBEXSERVER_SESSION_GET_PRIVATE(self);
-
- g_assert(system_conn != NULL);
-}
-
-static void obexserver_session_post_init(OBEXServerSession *self, const gchar *dbus_object_path)
-{
- g_assert(dbus_object_path != NULL);
- g_assert(strlen(dbus_object_path) > 0);
- g_assert(self->priv->dbus_g_proxy == NULL);
-
- GError *error = NULL;
-
- /* Getting introspection XML */
- self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable");
- self->priv->introspection_xml = NULL;
- if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
- g_critical("%s", error->message);
- }
- g_assert(error == NULL);
-
- gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXSERVER_SESSION_DBUS_INTERFACE, "\">", NULL);
- if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
- g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXSERVER_SESSION_DBUS_INTERFACE, dbus_object_path);
- g_assert(FALSE);
- }
- g_free(check_intf_regex_str);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, OBEXSERVER_SESSION_DBUS_INTERFACE);
-
- /* DBus signals connection */
-
- /* Cancelled() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Cancelled", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Cancelled", G_CALLBACK(cancelled_handler), self, NULL);
-
- /* Disconnected() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Disconnected", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Disconnected", G_CALLBACK(disconnected_handler), self, NULL);
-
- /* ErrorOccurred(string error_name, string error_message) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_CALLBACK(error_occurred_handler), self, NULL);
-
- /* TransferCompleted() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "TransferCompleted", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "TransferCompleted", G_CALLBACK(transfer_completed_handler), self, NULL);
-
- /* TransferProgress(uint64 bytes_transferred) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "TransferProgress", G_TYPE_UINT64, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "TransferProgress", G_CALLBACK(transfer_progress_handler), self, NULL);
-
- /* TransferStarted(string filename, string local_path, uint64 total_bytes) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "TransferStarted", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "TransferStarted", G_CALLBACK(transfer_started_handler), self, NULL);
-}
-
-static void _obexserver_session_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(object);
-
- switch (property_id) {
- case PROP_DBUS_OBJECT_PATH:
- g_value_set_string(value, obexserver_session_get_dbus_object_path(self));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
- }
-}
-
-static void _obexserver_session_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(object);
- GError *error = NULL;
-
- switch (property_id) {
- case PROP_DBUS_OBJECT_PATH:
- obexserver_session_post_init(self, g_value_get_string(value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
- }
-
- if (error != NULL) {
- g_critical("%s", error->message);
- }
- g_assert(error == NULL);
-}
-
-/* Methods */
-
-/* void Accept() */
-void obexserver_session_accept(OBEXServerSession *self, GError **error)
-{
- g_assert(OBEXSERVER_SESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Accept", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void Cancel() */
-void obexserver_session_cancel(OBEXServerSession *self, GError **error)
-{
- g_assert(OBEXSERVER_SESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Cancel", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void Disconnect() */
-void obexserver_session_disconnect(OBEXServerSession *self, GError **error)
-{
- g_assert(OBEXSERVER_SESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Disconnect", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* dict{s,s} GetTransferInfo() */
-GHashTable *obexserver_session_get_transfer_info(OBEXServerSession *self, GError **error)
-{
- g_assert(OBEXSERVER_SESSION_IS(self));
-
- GHashTable *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetTransferInfo", error, G_TYPE_INVALID, DBUS_TYPE_G_STRING_STRING_HASHTABLE, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* void Reject() */
-void obexserver_session_reject(OBEXServerSession *self, GError **error)
-{
- g_assert(OBEXSERVER_SESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Reject", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* Properties access methods */
-const gchar *obexserver_session_get_dbus_object_path(OBEXServerSession *self)
-{
- g_assert(OBEXSERVER_SESSION_IS(self));
-
- return dbus_g_proxy_get_path(self->priv->dbus_g_proxy);
-}
-
-/* Signals handlers */
-static void cancelled_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(data);
-
- g_signal_emit(self, signals[CANCELLED], 0);
-}
-
-static void disconnected_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(data);
-
- g_signal_emit(self, signals[DISCONNECTED], 0);
-}
-
-static void error_occurred_handler(DBusGProxy *dbus_g_proxy, const gchar *error_name, const gchar *error_message, gpointer data)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(data);
-
- g_signal_emit(self, signals[ERROR_OCCURRED], 0, error_name, error_message);
-}
-
-static void transfer_completed_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(data);
-
- g_signal_emit(self, signals[TRANSFER_COMPLETED], 0);
-}
-
-static void transfer_progress_handler(DBusGProxy *dbus_g_proxy, const guint64 bytes_transferred, gpointer data)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(data);
-
- g_signal_emit(self, signals[TRANSFER_PROGRESS], 0, bytes_transferred);
-}
-
-static void transfer_started_handler(DBusGProxy *dbus_g_proxy, const gchar *filename, const gchar *local_path, const guint64 total_bytes, gpointer data)
-{
- OBEXServerSession *self = OBEXSERVER_SESSION(data);
-
- g_signal_emit(self, signals[TRANSFER_STARTED], 0, filename, local_path, total_bytes);
-}
-
diff --git a/src/lib/ods/obexserver_session.h b/src/lib/ods/obexserver_session.h
deleted file mode 100644
index c1be188..0000000
--- a/src/lib/ods/obexserver_session.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *
- * 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 __OBEXSERVER_SESSION_H
-#define __OBEXSERVER_SESSION_H
-
-#include <glib-object.h>
-
-#define OBEXSERVER_SESSION_DBUS_INTERFACE "org.openobex.ServerSession"
-
-/*
- * Type macros
- */
-#define OBEXSERVER_SESSION_TYPE (obexserver_session_get_type())
-#define OBEXSERVER_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXSERVER_SESSION_TYPE, OBEXServerSession))
-#define OBEXSERVER_SESSION_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXSERVER_SESSION_TYPE))
-#define OBEXSERVER_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXSERVER_SESSION_TYPE, OBEXServerSessionClass))
-#define OBEXSERVER_SESSION_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXSERVER_SESSION_TYPE))
-#define OBEXSERVER_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXSERVER_SESSION_TYPE, OBEXServerSessionClass))
-
-typedef struct _OBEXServerSession OBEXServerSession;
-typedef struct _OBEXServerSessionClass OBEXServerSessionClass;
-typedef struct _OBEXServerSessionPrivate OBEXServerSessionPrivate;
-
-struct _OBEXServerSession {
- GObject parent_instance;
-
- /*< private >*/
- OBEXServerSessionPrivate *priv;
-};
-
-struct _OBEXServerSessionClass {
- GObjectClass parent_class;
-};
-
-/* used by OBEXSERVER_SESSION_TYPE */
-GType obexserver_session_get_type(void) G_GNUC_CONST;
-
-/*
- * Method definitions
- */
-void obexserver_session_accept(OBEXServerSession *self, GError **error);
-void obexserver_session_cancel(OBEXServerSession *self, GError **error);
-void obexserver_session_disconnect(OBEXServerSession *self, GError **error);
-GHashTable *obexserver_session_get_transfer_info(OBEXServerSession *self, GError **error);
-void obexserver_session_reject(OBEXServerSession *self, GError **error);
-
-const gchar *obexserver_session_get_dbus_object_path(OBEXServerSession *self);
-
-#endif /* __OBEXSERVER_SESSION_H */
-
diff --git a/src/lib/ods/obexsession.c b/src/lib/ods/obexsession.c
deleted file mode 100644
index 2fde069..0000000
--- a/src/lib/ods/obexsession.c
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- *
- * 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
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-
-#include "../dbus-common.h"
-#include "../marshallers.h"
-
-#include "obexsession.h"
-
-#define OBEXSESSION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXSESSION_TYPE, OBEXSessionPrivate))
-
-struct _OBEXSessionPrivate {
- DBusGProxy *dbus_g_proxy;
-
- /* Introspection data */
- DBusGProxy *introspection_g_proxy;
- gchar *introspection_xml;
-};
-
-G_DEFINE_TYPE(OBEXSession, obexsession, G_TYPE_OBJECT);
-
-enum {
- PROP_0,
-
- PROP_DBUS_OBJECT_PATH /* readwrite, construct only */
-};
-
-static void _obexsession_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static void _obexsession_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-
-enum {
- CANCELLED,
- CLOSED,
- DISCONNECTED,
- ERROR_OCCURRED,
- TRANSFER_COMPLETED,
- TRANSFER_PROGRESS,
- TRANSFER_STARTED,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = {0};
-
-static void cancelled_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void closed_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void disconnected_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void error_occurred_handler(DBusGProxy *dbus_g_proxy, const gchar *error_name, const gchar *error_message, gpointer data);
-static void transfer_completed_handler(DBusGProxy *dbus_g_proxy, gpointer data);
-static void transfer_progress_handler(DBusGProxy *dbus_g_proxy, const guint64 bytes_transferred, gpointer data);
-static void transfer_started_handler(DBusGProxy *dbus_g_proxy, const gchar *filename, const gchar *local_path, const guint64 total_bytes, gpointer data);
-
-static void obexsession_dispose(GObject *gobject)
-{
- OBEXSession *self = OBEXSESSION(gobject);
-
- /* DBus signals disconnection */
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Cancelled", G_CALLBACK(cancelled_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Closed", G_CALLBACK(closed_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Disconnected", G_CALLBACK(disconnected_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_CALLBACK(error_occurred_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "TransferCompleted", G_CALLBACK(transfer_completed_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "TransferProgress", G_CALLBACK(transfer_progress_handler), self);
- dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "TransferStarted", G_CALLBACK(transfer_started_handler), self);
-
- /* Proxy free */
- g_object_unref(self->priv->dbus_g_proxy);
-
- /* Introspection data free */
- g_free(self->priv->introspection_xml);
- g_object_unref(self->priv->introspection_g_proxy);
-
- /* Chain up to the parent class */
- G_OBJECT_CLASS(obexsession_parent_class)->dispose(gobject);
-}
-
-static void obexsession_class_init(OBEXSessionClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->dispose = obexsession_dispose;
-
- g_type_class_add_private(klass, sizeof(OBEXSessionPrivate));
-
- /* Properties registration */
- GParamSpec *pspec;
-
- gobject_class->get_property = _obexsession_get_property;
- gobject_class->set_property = _obexsession_set_property;
-
- /* object DBusObjectPath [readwrite, construct only] */
- pspec = g_param_spec_string("DBusObjectPath", "dbus_object_path", "Adapter D-Bus object path", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property(gobject_class, PROP_DBUS_OBJECT_PATH, pspec);
-
- /* Signals registation */
- signals[CANCELLED] = g_signal_new("Cancelled",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[CLOSED] = g_signal_new("Closed",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[DISCONNECTED] = g_signal_new("Disconnected",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[ERROR_OCCURRED] = g_signal_new("ErrorOccurred",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_bt_marshal_VOID__STRING_STRING,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
-
- signals[TRANSFER_COMPLETED] = g_signal_new("TransferCompleted",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[TRANSFER_PROGRESS] = g_signal_new("TransferProgress",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_bt_marshal_VOID__UINT64,
- G_TYPE_NONE, 1, G_TYPE_UINT64);
-
- signals[TRANSFER_STARTED] = g_signal_new("TransferStarted",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL,
- g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64,
- G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64);
-}
-
-static void obexsession_init(OBEXSession *self)
-{
- self->priv = OBEXSESSION_GET_PRIVATE(self);
-
- g_assert(system_conn != NULL);
-}
-
-static void obexsession_post_init(OBEXSession *self, const gchar *dbus_object_path)
-{
- g_assert(dbus_object_path != NULL);
- g_assert(strlen(dbus_object_path) > 0);
- g_assert(self->priv->dbus_g_proxy == NULL);
-
- GError *error = NULL;
-
- /* Getting introspection XML */
- self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable");
- self->priv->introspection_xml = NULL;
- if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
- g_critical("%s", error->message);
- }
- g_assert(error == NULL);
-
- gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXSESSION_DBUS_INTERFACE, "\">", NULL);
- if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
- g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXSESSION_DBUS_INTERFACE, dbus_object_path);
- g_assert(FALSE);
- }
- g_free(check_intf_regex_str);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, OBEXSESSION_DBUS_INTERFACE);
-
- /* DBus signals connection */
-
- /* Cancelled() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Cancelled", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Cancelled", G_CALLBACK(cancelled_handler), self, NULL);
-
- /* Closed() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Closed", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Closed", G_CALLBACK(closed_handler), self, NULL);
-
- /* Disconnected() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Disconnected", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Disconnected", G_CALLBACK(disconnected_handler), self, NULL);
-
- /* ErrorOccurred(string error_name, string error_message) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "ErrorOccurred", G_CALLBACK(error_occurred_handler), self, NULL);
-
- /* TransferCompleted() */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "TransferCompleted", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "TransferCompleted", G_CALLBACK(transfer_completed_handler), self, NULL);
-
- /* TransferProgress(uint64 bytes_transferred) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "TransferProgress", G_TYPE_UINT64, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "TransferProgress", G_CALLBACK(transfer_progress_handler), self, NULL);
-
- /* TransferStarted(string filename, string local_path, uint64 total_bytes) */
- dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "TransferStarted", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "TransferStarted", G_CALLBACK(transfer_started_handler), self, NULL);
-}
-
-static void _obexsession_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- OBEXSession *self = OBEXSESSION(object);
-
- switch (property_id) {
- case PROP_DBUS_OBJECT_PATH:
- g_value_set_string(value, obexsession_get_dbus_object_path(self));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
- }
-}
-
-static void _obexsession_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- OBEXSession *self = OBEXSESSION(object);
- GError *error = NULL;
-
- switch (property_id) {
- case PROP_DBUS_OBJECT_PATH:
- obexsession_post_init(self, g_value_get_string(value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
- }
-
- if (error != NULL) {
- g_critical("%s", error->message);
- }
- g_assert(error == NULL);
-}
-
-/* Methods */
-
-/* void Cancel() */
-void obexsession_cancel(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Cancel", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void ChangeCurrentFolder(string path) */
-void obexsession_change_current_folder(OBEXSession *self, const gchar *path, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "ChangeCurrentFolder", error, G_TYPE_STRING, path, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void ChangeCurrentFolderBackward() */
-void obexsession_change_current_folder_backward(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "ChangeCurrentFolderBackward", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void ChangeCurrentFolderToRoot() */
-void obexsession_change_current_folder_to_root(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "ChangeCurrentFolderToRoot", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void Close() */
-void obexsession_close(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Close", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void CopyRemoteFile(string remote_filename, string local_path) */
-void obexsession_copy_remote_file(OBEXSession *self, const gchar *remote_filename, const gchar *local_path, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "CopyRemoteFile", error, G_TYPE_STRING, remote_filename, G_TYPE_STRING, local_path, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void CopyRemoteFileByType(string type, string local_path) */
-void obexsession_copy_remote_file_by_type(OBEXSession *self, const gchar *type, const gchar *local_path, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "CopyRemoteFileByType", error, G_TYPE_STRING, type, G_TYPE_STRING, local_path, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void CreateFolder(string folder_name) */
-void obexsession_create_folder(OBEXSession *self, const gchar *folder_name, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "CreateFolder", error, G_TYPE_STRING, folder_name, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void DeleteRemoteFile(string remote_filename) */
-void obexsession_delete_remote_file(OBEXSession *self, const gchar *remote_filename, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "DeleteRemoteFile", error, G_TYPE_STRING, remote_filename, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void Disconnect() */
-void obexsession_disconnect(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "Disconnect", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* string GetCapability() */
-gchar *obexsession_get_capability(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- gchar *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetCapability", error, G_TYPE_INVALID, G_TYPE_STRING, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* string GetCurrentPath() */
-gchar *obexsession_get_current_path(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- gchar *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetCurrentPath", error, G_TYPE_INVALID, G_TYPE_STRING, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* dict{s,s} GetTransferInfo() */
-GHashTable *obexsession_get_transfer_info(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- GHashTable *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetTransferInfo", error, G_TYPE_INVALID, DBUS_TYPE_G_STRING_STRING_HASHTABLE, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* boolean IsBusy() */
-gboolean obexsession_is_busy(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- gboolean ret = FALSE;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "IsBusy", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* void RemoteCopy(string remote_source, string remote_destination) */
-void obexsession_remote_copy(OBEXSession *self, const gchar *remote_source, const gchar *remote_destination, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "RemoteCopy", error, G_TYPE_STRING, remote_source, G_TYPE_STRING, remote_destination, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void RemoteMove(string remote_source, string remote_destination) */
-void obexsession_remote_move(OBEXSession *self, const gchar *remote_source, const gchar *remote_destination, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "RemoteMove", error, G_TYPE_STRING, remote_source, G_TYPE_STRING, remote_destination, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* string RetrieveFolderListing() */
-gchar *obexsession_retrieve_folder_listing(OBEXSession *self, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- gchar *ret = NULL;
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "RetrieveFolderListing", error, G_TYPE_INVALID, G_TYPE_STRING, &ret, G_TYPE_INVALID);
-
- return ret;
-}
-
-/* void SendFile(string local_path) */
-void obexsession_send_file(OBEXSession *self, const gchar *local_path, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "SendFile", error, G_TYPE_STRING, local_path, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* void SendFileExt(string local_path, string remote_filename, string type) */
-void obexsession_send_file_ext(OBEXSession *self, const gchar *local_path, const gchar *remote_filename, const gchar *type, GError **error)
-{
- g_assert(OBEXSESSION_IS(self));
-
- dbus_g_proxy_call(self->priv->dbus_g_proxy, "SendFileExt", error, G_TYPE_STRING, local_path, G_TYPE_STRING, remote_filename, G_TYPE_STRING, type, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-/* Properties access methods */
-const gchar *obexsession_get_dbus_object_path(OBEXSession *self)
-{
- g_assert(OBEXSESSION_IS(self));
-
- return dbus_g_proxy_get_path(self->priv->dbus_g_proxy);
-}
-
-/* Signals handlers */
-static void cancelled_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXSession *self = OBEXSESSION(data);
-
- g_signal_emit(self, signals[CANCELLED], 0);
-}
-
-static void closed_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXSession *self = OBEXSESSION(data);
-
- g_signal_emit(self, signals[CLOSED], 0);
-}
-
-static void disconnected_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXSession *self = OBEXSESSION(data);
-
- g_signal_emit(self, signals[DISCONNECTED], 0);
-}
-
-static void error_occurred_handler(DBusGProxy *dbus_g_proxy, const gchar *error_name, const gchar *error_message, gpointer data)
-{
- OBEXSession *self = OBEXSESSION(data);
-
- g_signal_emit(self, signals[ERROR_OCCURRED], 0, error_name, error_message);
-}
-
-static void transfer_completed_handler(DBusGProxy *dbus_g_proxy, gpointer data)
-{
- OBEXSession *self = OBEXSESSION(data);
-
- g_signal_emit(self, signals[TRANSFER_COMPLETED], 0);
-}
-
-static void transfer_progress_handler(DBusGProxy *dbus_g_proxy, const guint64 bytes_transferred, gpointer data)
-{
- OBEXSession *self = OBEXSESSION(data);
-
- g_signal_emit(self, signals[TRANSFER_PROGRESS], 0, bytes_transferred);
-}
-
-static void transfer_started_handler(DBusGProxy *dbus_g_proxy, const gchar *filename, const gchar *local_path, const guint64 total_bytes, gpointer data)
-{
- OBEXSession *self = OBEXSESSION(data);
-
- g_signal_emit(self, signals[TRANSFER_STARTED], 0, filename, local_path, total_bytes);
-}
-
diff --git a/src/lib/ods/obexsession.h b/src/lib/ods/obexsession.h
deleted file mode 100644
index 93289bf..0000000
--- a/src/lib/ods/obexsession.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * 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 __OBEXSESSION_H
-#define __OBEXSESSION_H
-
-#include <glib-object.h>
-
-#define OBEXSESSION_DBUS_INTERFACE "org.openobex.Session"
-
-/*
- * Type macros
- */
-#define OBEXSESSION_TYPE (obexsession_get_type())
-#define OBEXSESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXSESSION_TYPE, OBEXSession))
-#define OBEXSESSION_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXSESSION_TYPE))
-#define OBEXSESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXSESSION_TYPE, OBEXSessionClass))
-#define OBEXSESSION_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXSESSION_TYPE))
-#define OBEXSESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXSESSION_TYPE, OBEXSessionClass))
-
-typedef struct _OBEXSession OBEXSession;
-typedef struct _OBEXSessionClass OBEXSessionClass;
-typedef struct _OBEXSessionPrivate OBEXSessionPrivate;
-
-struct _OBEXSession {
- GObject parent_instance;
-
- /*< private >*/
- OBEXSessionPrivate *priv;
-};
-
-struct _OBEXSessionClass {
- GObjectClass parent_class;
-};
-
-/* used by OBEXSESSION_TYPE */
-GType obexsession_get_type(void) G_GNUC_CONST;
-
-/*
- * Method definitions
- */
-void obexsession_cancel(OBEXSession *self, GError **error);
-void obexsession_change_current_folder(OBEXSession *self, const gchar *path, GError **error);
-void obexsession_change_current_folder_backward(OBEXSession *self, GError **error);
-void obexsession_change_current_folder_to_root(OBEXSession *self, GError **error);
-void obexsession_close(OBEXSession *self, GError **error);
-void obexsession_copy_remote_file(OBEXSession *self, const gchar *remote_filename, const gchar *local_path, GError **error);
-void obexsession_copy_remote_file_by_type(OBEXSession *self, const gchar *type, const gchar *local_path, GError **error);
-void obexsession_create_folder(OBEXSession *self, const gchar *folder_name, GError **error);
-void obexsession_delete_remote_file(OBEXSession *self, const gchar *remote_filename, GError **error);
-void obexsession_disconnect(OBEXSession *self, GError **error);
-gchar *obexsession_get_capability(OBEXSession *self, GError **error);
-gchar *obexsession_get_current_path(OBEXSession *self, GError **error);
-GHashTable *obexsession_get_transfer_info(OBEXSession *self, GError **error);
-gboolean obexsession_is_busy(OBEXSession *self, GError **error);
-void obexsession_remote_copy(OBEXSession *self, const gchar *remote_source, const gchar *remote_destination, GError **error);
-void obexsession_remote_move(OBEXSession *self, const gchar *remote_source, const gchar *remote_destination, GError **error);
-gchar *obexsession_retrieve_folder_listing(OBEXSession *self, GError **error);
-void obexsession_send_file(OBEXSession *self, const gchar *local_path, GError **error);
-void obexsession_send_file_ext(OBEXSession *self, const gchar *local_path, const gchar *remote_filename, const gchar *type, GError **error);
-
-const gchar *obexsession_get_dbus_object_path(OBEXSession *self);
-
-#endif /* __OBEXSESSION_H */
-