diff options
author | Alexander Orlenko <zxteam@gmail.com> | 2010-08-03 15:51:06 +1100 |
---|---|---|
committer | Alexander Orlenko <zxteam@gmail.com> | 2010-08-03 15:51:06 +1100 |
commit | 51ad38fb7c02dc99627cb5a5422b91ac96f17244 (patch) | |
tree | ef98231add806066a35a5e0f2869deccb28106f1 | |
parent | 381c6bfbb6ef699b99a824b4c7c301dded98ae17 (diff) | |
download | bluez-tools-51ad38fb7c02dc99627cb5a5422b91ac96f17244.tar.gz |
Removed OBEX api (due to migration to obex-data-server)
-rwxr-xr-x | contrib/generate-all.sh | 28 | ||||
-rw-r--r-- | contrib/obexAgent.xml | 35 | ||||
-rw-r--r-- | contrib/obexd-api-0.29-fixed/agent-api.txt | 31 | ||||
-rw-r--r-- | contrib/obexd-api-0.29-fixed/client-api.txt | 328 | ||||
-rw-r--r-- | contrib/obexd-api-0.29-fixed/obexd-api.txt | 90 | ||||
-rw-r--r-- | src/Makefile.am | 10 | ||||
-rw-r--r-- | src/bt-adapter.c | 546 | ||||
-rw-r--r-- | src/bt-agent.c | 190 | ||||
-rw-r--r-- | src/lib/dbus-common.c | 3 | ||||
-rw-r--r-- | src/lib/obexagent.c | 174 | ||||
-rw-r--r-- | src/lib/obexagent.h | 98 | ||||
-rw-r--r-- | src/lib/obexclient.c | 152 | ||||
-rw-r--r-- | src/lib/obexclient.h | 71 | ||||
-rw-r--r-- | src/lib/obexclient_file_transfer.c | 234 | ||||
-rw-r--r-- | src/lib/obexclient_file_transfer.h | 74 | ||||
-rw-r--r-- | src/lib/obexclient_session.c | 282 | ||||
-rw-r--r-- | src/lib/obexclient_session.h | 72 | ||||
-rw-r--r-- | src/lib/obexclient_transfer.c | 274 | ||||
-rw-r--r-- | src/lib/obexclient_transfer.h | 71 | ||||
-rw-r--r-- | src/lib/obexmanager.c | 212 | ||||
-rw-r--r-- | src/lib/obexmanager.h | 67 | ||||
-rw-r--r-- | src/lib/obexsession.c | 217 | ||||
-rw-r--r-- | src/lib/obexsession.h | 68 | ||||
-rw-r--r-- | src/lib/obextransfer.c | 210 | ||||
-rw-r--r-- | src/lib/obextransfer.h | 67 |
25 files changed, 370 insertions, 3234 deletions
diff --git a/contrib/generate-all.sh b/contrib/generate-all.sh index 274a176..42ce4b6 100755 --- a/contrib/generate-all.sh +++ b/contrib/generate-all.sh @@ -39,31 +39,3 @@ ./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/serial-api.txt > ../src/lib/serial.h ./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/serial-api.txt > ../src/lib/serial.c -# service-api.txt -#./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/service-api.txt > ../src/lib/service.h -#./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/service-api.txt > ../src/lib/service.c - -# OBEX API - -# client-api.txt -./gen-dbus-gobject.pl -header obexd-api-0.29-fixed/client-api.txt > ../src/lib/obexclient.h -./gen-dbus-gobject.pl -source obexd-api-0.29-fixed/client-api.txt > ../src/lib/obexclient.c - -./gen-dbus-gobject.pl -header obexd-api-0.29-fixed/client-api.txt 2 > ../src/lib/obexclient_session.h -./gen-dbus-gobject.pl -source obexd-api-0.29-fixed/client-api.txt 2 > ../src/lib/obexclient_session.c - -./gen-dbus-gobject.pl -header obexd-api-0.29-fixed/client-api.txt 3 > ../src/lib/obexclient_file_transfer.h -./gen-dbus-gobject.pl -source obexd-api-0.29-fixed/client-api.txt 3 > ../src/lib/obexclient_file_transfer.c - -./gen-dbus-gobject.pl -header obexd-api-0.29-fixed/client-api.txt 6 > ../src/lib/obexclient_transfer.h -./gen-dbus-gobject.pl -source obexd-api-0.29-fixed/client-api.txt 6 > ../src/lib/obexclient_transfer.c - -# obexd-api.txt -./gen-dbus-gobject.pl -header obexd-api-0.29-fixed/obexd-api.txt > ../src/lib/obexmanager.h -./gen-dbus-gobject.pl -source obexd-api-0.29-fixed/obexd-api.txt > ../src/lib/obexmanager.c - -./gen-dbus-gobject.pl -header obexd-api-0.29-fixed/obexd-api.txt 2 > ../src/lib/obextransfer.h -./gen-dbus-gobject.pl -source obexd-api-0.29-fixed/obexd-api.txt 2 > ../src/lib/obextransfer.c - -./gen-dbus-gobject.pl -header obexd-api-0.29-fixed/obexd-api.txt 3 > ../src/lib/obexsession.h -./gen-dbus-gobject.pl -source obexd-api-0.29-fixed/obexd-api.txt 3 > ../src/lib/obexsession.c diff --git a/contrib/obexAgent.xml b/contrib/obexAgent.xml deleted file mode 100644 index d405c22..0000000 --- a/contrib/obexAgent.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<node name="/ObexAgent"> - <interface name="org.openobex.Agent"> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="obexagent"/> - - <method name="Authorize"> - <arg type="o" name="transfer" direction="in"/> - <arg type="s" name="bt_address" direction="in"/> - <arg type="s" name="name" direction="in"/> - <arg type="s" name="type" direction="in"/> - <arg type="i" name="length" direction="in"/> - <arg type="i" name="time" direction="in"/> - <arg type="s" direction="out"/> - </method> - <method name="Cancel"/> - - <method name="Release"/> - <method name="Request"> - <arg type="o" name="transfer" direction="in"/> - <arg type="s" direction="out"/> - </method> - <method name="Progress"> - <arg type="o" name="transfer" direction="in"/> - <arg type="t" name="transferred" direction="in"/> - </method> - <method name="Complete"> - <arg type="o" name="transfer" direction="in"/> - </method> - <method name="Error"> - <arg type="o" name="transfer" direction="in"/> - <arg type="s" name="message" direction="in"/> - </method> - - </interface> -</node> diff --git a/contrib/obexd-api-0.29-fixed/agent-api.txt b/contrib/obexd-api-0.29-fixed/agent-api.txt deleted file mode 100644 index 74f339c..0000000 --- a/contrib/obexd-api-0.29-fixed/agent-api.txt +++ /dev/null @@ -1,31 +0,0 @@ -obexd Agent API description -********************************** - -Copyright (C) 2007-2010 Nokia Corporation -Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> - - -Agent hierarchy -=============== - -Service unique name -Interface org.openobex.Agent -Object path freely definable - -Methods - string Authorize(object transfer, string bt_address, string name, - string type, int32 length, int32 time) - - This method gets called when the service daemon - needs to accept/reject a Bluetooth object push request. - Returns the full path (including the filename) where - the object shall be stored. - - Possible errors: org.openobex.Error.Rejected - org.openobex.Error.Canceled - - void Cancel() - - This method gets called to indicate that the agent - request failed before a reply was returned. It cancels - the previous request. diff --git a/contrib/obexd-api-0.29-fixed/client-api.txt b/contrib/obexd-api-0.29-fixed/client-api.txt deleted file mode 100644 index 3bfd134..0000000 --- a/contrib/obexd-api-0.29-fixed/client-api.txt +++ /dev/null @@ -1,328 +0,0 @@ -OBEX client API description -*************************** - -Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> - - -Client hierarchy -================ - -Service org.openobex.client -Interface org.openobex.Client -Object path / -Object name OBEXClient - -Methods void SendFiles(dict device, array{string} files, object agent) - - Send one or multiple local files to the specified - device. The device is configured via properties. At - least the Destination property should be specified. - - void PullBusinessCard(dict device, string file) - - Request the business card from a remote device and - store it in the local file. - - void ExchangeBusinessCards(dict device, string clientfile, string file) - - Push the client's business card to the remote device - and then retrieve the remote business card and store - it in a local file. - - object CreateSession(dict device) - - Create a new OBEX session. The device is configured - via properties like in SendFiles. - - void RemoveSession(object session) - - Unregister session and abort pending transfers. - - string GetCapabilities(dict device) - - Get remote device capabilities. - -Properties string Target - - string Source - - string Destination - - byte Channel - - -Session hierarchy -================= - -Service org.openobex.client -Interface org.openobex.Session -Object path [variable prefix]/{session0,session1,...} -Object name OBEXClientSession - -Methods dict GetProperties() - - Returns all properties for the session. - - void AssignAgent(object agent) - - Assign an OBEX agent to this session. This allows - detailed progress reports about the transactions. - - void ReleaseAgent(object agent) - - Release a previously assigned OBEX agent. - -Properties string Source [readonly] - - string Destination [readonly] - - byte Channel [readonly] - - -File Transfer hierarchy -======================= - -Service org.openobex.client -Interface org.openobex.FileTransfer -Object path [variable prefix]/{session0,session1,...} -Object name OBEXClientFileTransfer - -Methods void ChangeFolder(string folder) - - Change the current folder of the remote device. - - void CreateFolder(string folder) - - Create a new folder in the remote device. - - array{dict} ListFolder() - - Returns a dictionary containing information about - the current folder content. - - The following keys are defined: - - string Name : Object name in UTF-8 format - string Type : Either "folder" or "file" - uint64 Size : Object size or number of items in folder - string Permission : Group, owner and other permission - guint64 Modified : Last change - guint64 Accessed : Last access - guint64 Created : Creation date - - void GetFile(string targetfile, string sourcefile) - - Copy the source file (from remote device) to the - target file (on local filesystem). - - A new Transfer object is created to represent this - transaction. - - void PutFile(string sourcefile, string targetfile) - - Copy the source file (from local filesystem) to the - target file (on remote device). - - A new Transfer object is created to represent this - transaction. - - void CopyFile(string sourcefile, string targetfile) - - Copy a file within the remote device from source file - to target file. - - void MoveFile(string sourcefile, string targetfile) - - Movea file within the remote device from source file - to the target file. - - void Delete(string file) - - Deletes the specified file/folder. - - -Phonebook Access hierarchy -======================= - -Service org.openobex.client -Interface org.openobex.PhonebookAccess -Object path [variable prefix]/{session0,session1,...} - -Methods void Select(string location, string phonebook) - - Select the phonebook object for other operations. Should - be call before all the other operations. - - location : Where the phonebook is stored, possible inputs : - "INT" ( "INTERNAL" which is default ) - "SIM" ( "SIM1" ) - "SIM2" - ... - - phonebook : Possible inputs : - "pb" : phonebook for the saved contacts - "ich": incoming call history - "och": outgoing call history - "mch": missing call history - "cch": combination of ich och mch - - string PullAll() - - Return the entire phonebook object from the PSE server - in plain string with vcard format. - - array{string vcard, string name} List() {FIX!} - - Return an array of vcard-listing data which contains the - vcard : name paired string, for example "1.vcf" : "John". - - string Pull(string vcard) - - Retrieve the vcard in the current phonebook object - for example : Pull("0.vcf") - - array{string vcard, string name} Search(string field, string value) {FIX!} - - Return an array of vcard-listing data which contains the - vcard : name paired string match the search condition. - - field : the field in the vcard to search with - { "name" (default) | "number" | "sound" } - value : the string value to search for - - uint16 GetSize() - - Return the number of the non-null entries in the selected - phonebook object. - - void SetFormat(string format) - - Indicate the format of the vcard that should be return by - related methods. - - format : { "vcard21" (default) | "vcard30" } - - void SetOrder(string order) - - Indicate the sorting method of the vcard-listing data returned - by List and Search methods. - - order : { "indexed" (default) | "alphanumeric" | "phonetic" } - - void SetFilter(array{string}) {FIX!??} - - Indicate fields that should be contained in vcards return by - related methods. - - Give an empty array will clear the filter and return all fields - available in vcards. And this is the default behavior. - - Possible filter fields : "VERSION", "FN", ..., "ALL", "bit[0-63]" - - array{string} ListFilterFields() {FIX!??} - - Return All Available fields that can be used in SefFilter method. - - array{string} GetFilter() - - Return the current filter setting - -Synchronization hierarchy -======================= - -Service org.openobex.client -Interface org.openobex.Synchronization -Object path [variable prefix]/{session0,session1,...} - -Methods void SetLocation(string location) - - Set the phonebook object store location for other operations. Should - be called before all the other operations. - - location: Where the phonebook is stored, possible values: - "INT" ( "INTERNAL" which is default ) - "SIM1" - "SIM2" - ...... - - string GetPhonebook() - - retrieve an entire Phonebook Object store from remote device - - void PutPhonebook(string obj) - - send an entire Phonebook Object store to remote device - -Transfer hierarchy -================== - -Service org.openobex.client -Interface org.openobex.Transfer -Object path [variable prefix]/{transfer0,transfer1,...} -Object name OBEXClientTransfer - -Methods dict GetProperties() - - Returns all properties for the transfer. See the - properties section for available properties. - - void Cancel() - - Cancels this transfer. - -Properties string Name [readonly] - - Name of the transferred object. - - uint64 Size [readonly] - - Size of the transferred object. If the size is - unknown, then this property will not be present. - - string Filename [readonly] - - Complete name of the file being received or sent. - - -Agent hierarchy -=============== - -Service unique name -Interface org.openobex.Agent -Object path freely definable - -Methods void Release() - - This method gets called when the service daemon - unregisters the agent. An agent can use it to do - cleanup tasks. There is no need to unregister the - agent, because when this method gets called it has - already been unregistered. - - string Request(object transfer) - - Accept or reject a new transfer (client and server) - and provide the filename for it. - - In case of incoming transfers it is the filename - where to store the file and for outgoing transfers - it is the filename to show the remote device. If left - empty it will be calculated automatically. - - Possible errors: org.openobex.Error.Rejected - org.openobex.Error.Canceled - - void Progress(object transfer, uint64 transferred) - - Progress within the transfer has been made. The - number of transferred bytes is given as second - argument for convenience. - - void Complete(object transfer) - - Informs that the transfer has completed sucessfully. - - void Error(object transfer, string message) - - Informs that the transfer has been terminated because - of some error. diff --git a/contrib/obexd-api-0.29-fixed/obexd-api.txt b/contrib/obexd-api-0.29-fixed/obexd-api.txt deleted file mode 100644 index 6cfaac7..0000000 --- a/contrib/obexd-api-0.29-fixed/obexd-api.txt +++ /dev/null @@ -1,90 +0,0 @@ -obexd API description -********************************** - -Copyright (C) 2007-2010 Nokia Corporation -Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> - - -Manager hierarchy -=============== - -Service org.openobex -Interface org.openobex.Manager -Object path / -Object name OBEXManager - -Methods - void RegisterAgent(object agent) - - Register an agent to request authorization of - the user to accept/reject objects. Object push - service needs to authorize each received object. - - Possible errors: org.openobex.Error.AlreadyExists - - void UnregisterAgent(object agent) - - This unregisters the agent that has been previously - registered. The object path parameter must match the - same value that has been used on registration. - - Possible errors: org.openobex.Error.DoesNotExist - -Signals SessionCreated(object session) - - Signal sent when OBEX connection has been accepted. - (FTP only) - - SessionRemoved(object session) - - Sent when the transport is disconnected - (FTP only) - - TransferStarted(object transfer) - - Signal sent when an object push operation starts. - (OPP only) - - TransferCompleted(object transfer, boolean success) - - Signal sent when the object has been received - or an error happens. - (OPP only) - - -Transfer hierarchy -=============== - -Service org.openobex -Interface org.openobex.Transfer -Object path /transfer{0, 1, 2, ...} -Object name OBEXTransfer - -Methods - void Cancel() - - Stops the current transference. - -Signals - Progress(int32 total, int32 transfered) - - -Session hierarchy -=============== - -Service org.openobex -Interface org.openobex.Session -Object path /session{0, 1, 2, ...} -Object name OBEXSession - -Methods - dict GetProperties() - - -Signals TBD - - -Properties - string Address [readonly] - - Bluetooth device address or USB diff --git a/src/Makefile.am b/src/Makefile.am index 9881950..aab0406 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,15 +26,7 @@ lib_sources = lib/marshallers.c lib/marshallers.h \ lib/network_peer.c lib/network_peer.h \ lib/network_router.c lib/network_router.h \ lib/serial.c lib/serial.h \ - lib/sdp.c lib/sdp.h \ - lib/obexagent.c lib/obexagent.h \ - lib/obexclient.c lib\obexclient.h \ - lib/obexclient_file_transfer.c lib/obexclient_file_transfer.h \ - lib/obexclient_session.c lib/obexclient_session.h \ - lib/obexclient_transfer.c lib/obexclient_transfer.h \ - lib/obexmanager.c lib/obexmanager.h \ - lib/obexsession.c lib/obexsession.h \ - lib/obextransfer.c lib/obextransfer.h + lib/sdp.c lib/sdp.h bin_PROGRAMS = bt-monitor bt-adapter bt-agent bt-device bt-input bt-audio bt-network bt-serial bt_monitor_SOURCES = $(lib_sources) bt-monitor.c diff --git a/src/bt-adapter.c b/src/bt-adapter.c index 99f6c6d..5a9b311 100644 --- a/src/bt-adapter.c +++ b/src/bt-adapter.c @@ -1,273 +1,273 @@ -/*
- *
- * 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 <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include "lib/bluez-dbus.h"
-
-static void adapter_device_found(Adapter *adapter, const gchar *address, GHashTable *values, gpointer data)
-{
- g_assert(data != NULL);
- GHashTable *found_devices = data;
-
- if (g_hash_table_lookup(found_devices, address) != NULL) {
- return;
- }
-
- if (g_hash_table_size(found_devices) == 0) g_print("\n");
-
- g_print("[%s]\n", address);
- g_print(" Name: %s\n", g_value_get_string(g_hash_table_lookup(values, "Name")));
- g_print(" Alias: %s\n", g_value_get_string(g_hash_table_lookup(values, "Alias")));
- g_print(" Address: %s\n", g_value_get_string(g_hash_table_lookup(values, "Address")));
- g_print(" Icon: %s\n", g_value_get_string(g_hash_table_lookup(values, "Icon")));
- g_print(" Class: 0x%x\n", g_value_get_uint(g_hash_table_lookup(values, "Class")));
- g_print(" LegacyPairing: %d\n", g_value_get_boolean(g_hash_table_lookup(values, "LegacyPairing")));
- g_print(" Paired: %d\n", g_value_get_boolean(g_hash_table_lookup(values, "Paired")));
- g_print(" RSSI: %d\n", g_value_get_int(g_hash_table_lookup(values, "RSSI")));
- g_print("\n");
-
- g_hash_table_insert(found_devices, g_strdup(address), g_value_dup_string(g_hash_table_lookup(values, "Alias")));
-}
-
-/*
-static void adapter_device_disappeared(Adapter *adapter, const gchar *address, gpointer data)
-{
- g_assert(data != NULL);
- GHashTable *found_devices = data;
-
- 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)
-{
- g_assert(data != NULL);
- GMainLoop *mainloop = data;
-
- if (g_strcmp0(name, "Discovering") == 0 && g_value_get_boolean(value) == FALSE) {
- g_main_loop_quit(mainloop);
- }
-}
-
-static gboolean list_arg = FALSE;
-static gchar *adapter_arg = NULL;
-static gboolean info_arg = FALSE;
-static gboolean discover_arg = FALSE;
-static gboolean set_arg = FALSE;
-static gchar *set_property_arg = NULL;
-static gchar *set_value_arg = NULL;
-
-static GOptionEntry entries[] = {
- {"list", 'l', 0, G_OPTION_ARG_NONE, &list_arg, "List all available adapters", NULL},
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
- {"info", 'i', 0, G_OPTION_ARG_NONE, &info_arg, "Show adapter info", NULL},
- {"discover", 'd', 0, G_OPTION_ARG_NONE, &discover_arg, "Discover remote devices", NULL},
- {"set", 0, 0, G_OPTION_ARG_NONE, &set_arg, "Set adapter property", NULL},
- {NULL}
-};
-
-int main(int argc, char *argv[])
-{
- GError *error = NULL;
- GOptionContext *context;
-
- g_type_init();
-
- context = g_option_context_new("- a bluetooth adapter 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,
- "Set Options:\n"
- " --set <property> <value>\n"
- " Where `property` is one of:\n"
- " Name\n"
- " Discoverable\n"
- " DiscoverableTimeout\n"
- " Pairable\n"
- " PairableTimeout\n"
- " Powered\n\n"
- //"Report bugs to <"PACKAGE_BUGREPORT">."
- "Project home <"PACKAGE_URL">."
- );
-
- if (!g_option_context_parse(context, &argc, &argv, &error)) {
- 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 (!list_arg && !info_arg && !discover_arg && !set_arg) {
- g_print("%s", g_option_context_get_help(context, FALSE, NULL));
- exit(EXIT_FAILURE);
- } else if (set_arg && (argc != 3 || strlen(argv[1]) == 0 || strlen(argv[2]) == 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);
- }
-
- g_option_context_free(context);
-
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
- exit(EXIT_FAILURE);
- }
-
- Manager *manager = g_object_new(MANAGER_TYPE, NULL);
-
- if (list_arg) {
- const GPtrArray *adapters_list = manager_get_adapters(manager);
- g_assert(adapters_list != NULL);
-
- if (adapters_list->len == 0) {
- g_print("No adapters found\n");
- exit(EXIT_FAILURE);
- }
-
- g_print("Available adapters:\n");
- for (int i = 0; i < adapters_list->len; i++) {
- const gchar *adapter_path = g_ptr_array_index(adapters_list, i);
- Adapter *adapter = g_object_new(ADAPTER_TYPE, "DBusObjectPath", adapter_path, NULL);
- g_print("%s (%s)\n", adapter_get_name(adapter), adapter_get_address(adapter));
- g_object_unref(adapter);
- }
- } else if (info_arg) {
- Adapter *adapter = find_adapter(adapter_arg, &error);
- exit_if_error(error);
-
- gchar *adapter_intf = g_path_get_basename(adapter_get_dbus_object_path(adapter));
- g_print("[%s]\n", adapter_intf);
- g_print(" Name: %s [rw]\n", adapter_get_name(adapter));
- g_print(" Address: %s\n", adapter_get_address(adapter));
- g_print(" Class: 0x%x\n", adapter_get_class(adapter));
- g_print(" Discoverable: %d [rw]\n", adapter_get_discoverable(adapter));
- g_print(" DiscoverableTimeout: %d [rw]\n", adapter_get_discoverable_timeout(adapter));
- g_print(" Discovering: %d\n", adapter_get_discovering(adapter));
- g_print(" Pairable: %d [rw]\n", adapter_get_pairable(adapter));
- g_print(" PairableTimeout: %d [rw]\n", adapter_get_pairable_timeout(adapter));
- g_print(" Powered: %d [rw]\n", adapter_get_powered(adapter));
- g_print(" UUIDs: [");
- const gchar **uuids = adapter_get_uuids(adapter);
- for (int j = 0; uuids[j] != NULL; j++) {
- if (j > 0) g_print(", ");
- g_print("%s", uuid2name(uuids[j]));
- }
- g_print("]\n");
-
- g_free(adapter_intf);
- g_object_unref(adapter);
- } else if (discover_arg) {
- Adapter *adapter = find_adapter(adapter_arg, &error);
- exit_if_error(error);
-
- // To store pairs MAC => Name
- GHashTable *found_devices = g_hash_table_new(g_str_hash, g_str_equal);
-
- // Mainloop
- GMainLoop *mainloop = g_main_loop_new(NULL, FALSE);
-
- g_signal_connect(adapter, "DeviceFound", G_CALLBACK(adapter_device_found), found_devices);
- //g_signal_connect(adapter, "DeviceDisappeared", G_CALLBACK(adapter_device_disappeared), found_devices);
- g_signal_connect(adapter, "PropertyChanged", G_CALLBACK(adapter_property_changed), mainloop);
-
- g_print("Searching...\n");
- adapter_start_discovery(adapter, &error);
- exit_if_error(error);
-
- g_main_loop_run(mainloop);
- /* Discovering process here... */
- g_main_loop_unref(mainloop);
-
- g_print("Done\n");
- g_hash_table_unref(found_devices);
- g_object_unref(adapter);
- } else if (set_arg) {
- set_property_arg = argv[1];
- set_value_arg = argv[2];
-
- Adapter *adapter = find_adapter(adapter_arg, &error);
- exit_if_error(error);
-
- GValue v = {0,};
-
- if (g_strcmp0(set_property_arg, "Name") == 0) {
- g_value_init(&v, G_TYPE_STRING);
- g_value_set_string(&v, set_value_arg);
- } else if (
- g_strcmp0(set_property_arg, "Discoverable") == 0 ||
- g_strcmp0(set_property_arg, "Pairable") == 0 ||
- g_strcmp0(set_property_arg, "Powered") == 0
- ) {
- g_value_init(&v, G_TYPE_BOOLEAN);
-
- if (g_strcmp0(set_value_arg, "0") == 0 || g_ascii_strcasecmp(set_value_arg, "FALSE") == 0 || g_ascii_strcasecmp(set_value_arg, "OFF") == 0) {
- g_value_set_boolean(&v, FALSE);
- } else if (g_strcmp0(set_value_arg, "1") == 0 || g_ascii_strcasecmp(set_value_arg, "TRUE") == 0 || g_ascii_strcasecmp(set_value_arg, "ON") == 0) {
- g_value_set_boolean(&v, TRUE);
- } else {
- g_print("%s: Invalid boolean value: %s\n", g_get_prgname(), set_value_arg);
- g_print("Try `%s --help` for more information.\n", g_get_prgname());
- exit(EXIT_FAILURE);
- }
- } else if (
- g_strcmp0(set_property_arg, "DiscoverableTimeout") == 0 ||
- g_strcmp0(set_property_arg, "PairableTimeout") == 0
- ) {
- g_value_init(&v, G_TYPE_UINT);
- g_value_set_uint(&v, (guint) atoi(set_value_arg));
- } else {
- g_print("%s: Invalid property: %s\n", g_get_prgname(), set_property_arg);
- g_print("Try `%s --help` for more information.\n", g_get_prgname());
- exit(EXIT_FAILURE);
- }
-
- GHashTable *props = adapter_get_properties(adapter, &error);
- exit_if_error(error);
- GValue *old_value = g_hash_table_lookup(props, set_property_arg);
- g_assert(old_value != NULL);
- if (G_VALUE_HOLDS_STRING(old_value)) {
- g_print("%s: %s -> %s\n", set_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", set_property_arg, g_value_get_boolean(old_value), g_value_get_boolean(&v));
- } else if (G_VALUE_HOLDS_UINT(old_value)) {
- g_print("%s: %d -> %d\n", set_property_arg, g_value_get_uint(old_value), g_value_get_uint(&v));
- }
- g_hash_table_unref(props);
-
- adapter_set_property(adapter, set_property_arg, &v, &error);
- exit_if_error(error);
-
- g_value_unset(&v);
- g_object_unref(adapter);
- }
-
- g_object_unref(manager);
- dbus_disconnect();
-
- exit(EXIT_SUCCESS);
-}
-
+/* + * + * 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 <stdlib.h> +#include <string.h> +#include <glib.h> + +#include "lib/bluez-dbus.h" + +static void adapter_device_found(Adapter *adapter, const gchar *address, GHashTable *values, gpointer data) +{ + g_assert(data != NULL); + GHashTable *found_devices = data; + + if (g_hash_table_lookup(found_devices, address) != NULL) { + return; + } + + if (g_hash_table_size(found_devices) == 0) g_print("\n"); + + g_print("[%s]\n", address); + g_print(" Name: %s\n", g_value_get_string(g_hash_table_lookup(values, "Name"))); + g_print(" Alias: %s\n", g_value_get_string(g_hash_table_lookup(values, "Alias"))); + g_print(" Address: %s\n", g_value_get_string(g_hash_table_lookup(values, "Address"))); + g_print(" Icon: %s\n", g_value_get_string(g_hash_table_lookup(values, "Icon"))); + g_print(" Class: 0x%x\n", g_value_get_uint(g_hash_table_lookup(values, "Class"))); + g_print(" LegacyPairing: %d\n", g_value_get_boolean(g_hash_table_lookup(values, "LegacyPairing"))); + g_print(" Paired: %d\n", g_value_get_boolean(g_hash_table_lookup(values, "Paired"))); + g_print(" RSSI: %d\n", g_value_get_int(g_hash_table_lookup(values, "RSSI"))); + g_print("\n"); + + g_hash_table_insert(found_devices, g_strdup(address), g_value_dup_string(g_hash_table_lookup(values, "Alias"))); +} + +/* +static void adapter_device_disappeared(Adapter *adapter, const gchar *address, gpointer data) +{ + g_assert(data != NULL); + GHashTable *found_devices = data; + + 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) +{ + g_assert(data != NULL); + GMainLoop *mainloop = data; + + if (g_strcmp0(name, "Discovering") == 0 && g_value_get_boolean(value) == FALSE) { + g_main_loop_quit(mainloop); + } +} + +static gboolean list_arg = FALSE; +static gchar *adapter_arg = NULL; +static gboolean info_arg = FALSE; +static gboolean discover_arg = FALSE; +static gboolean set_arg = FALSE; +static gchar *set_property_arg = NULL; +static gchar *set_value_arg = NULL; + +static GOptionEntry entries[] = { + {"list", 'l', 0, G_OPTION_ARG_NONE, &list_arg, "List all available adapters", NULL}, + {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"}, + {"info", 'i', 0, G_OPTION_ARG_NONE, &info_arg, "Show adapter info", NULL}, + {"discover", 'd', 0, G_OPTION_ARG_NONE, &discover_arg, "Discover remote devices", NULL}, + {"set", 0, 0, G_OPTION_ARG_NONE, &set_arg, "Set adapter property", NULL}, + {NULL} +}; + +int main(int argc, char *argv[]) +{ + GError *error = NULL; + GOptionContext *context; + + g_type_init(); + + context = g_option_context_new("- a bluetooth adapter 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, + "Set Options:\n" + " --set <property> <value>\n" + " Where `property` is one of:\n" + " Name\n" + " Discoverable\n" + " DiscoverableTimeout\n" + " Pairable\n" + " PairableTimeout\n" + " Powered\n\n" + //"Report bugs to <"PACKAGE_BUGREPORT">." + "Project home <"PACKAGE_URL">." + ); + + if (!g_option_context_parse(context, &argc, &argv, &error)) { + 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 (!list_arg && !info_arg && !discover_arg && !set_arg) { + g_print("%s", g_option_context_get_help(context, FALSE, NULL)); + exit(EXIT_FAILURE); + } else if (set_arg && (argc != 3 || strlen(argv[1]) == 0 || strlen(argv[2]) == 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); + } + + g_option_context_free(context); + + if (!dbus_connect(&error)) { + g_printerr("Couldn't connect to dbus: %s\n", error->message); + exit(EXIT_FAILURE); + } + + Manager *manager = g_object_new(MANAGER_TYPE, NULL); + + if (list_arg) { + const GPtrArray *adapters_list = manager_get_adapters(manager); + g_assert(adapters_list != NULL); + + if (adapters_list->len == 0) { + g_print("No adapters found\n"); + exit(EXIT_FAILURE); + } + + g_print("Available adapters:\n"); + for (int i = 0; i < adapters_list->len; i++) { + const gchar *adapter_path = g_ptr_array_index(adapters_list, i); + Adapter *adapter = g_object_new(ADAPTER_TYPE, "DBusObjectPath", adapter_path, NULL); + g_print("%s (%s)\n", adapter_get_name(adapter), adapter_get_address(adapter)); + g_object_unref(adapter); + } + } else if (info_arg) { + Adapter *adapter = find_adapter(adapter_arg, &error); + exit_if_error(error); + + gchar *adapter_intf = g_path_get_basename(adapter_get_dbus_object_path(adapter)); + g_print("[%s]\n", adapter_intf); + g_print(" Name: %s [rw]\n", adapter_get_name(adapter)); + g_print(" Address: %s\n", adapter_get_address(adapter)); + g_print(" Class: 0x%x\n", adapter_get_class(adapter)); + g_print(" Discoverable: %d [rw]\n", adapter_get_discoverable(adapter)); + g_print(" DiscoverableTimeout: %d [rw]\n", adapter_get_discoverable_timeout(adapter)); + g_print(" Discovering: %d\n", adapter_get_discovering(adapter)); + g_print(" Pairable: %d [rw]\n", adapter_get_pairable(adapter)); + g_print(" PairableTimeout: %d [rw]\n", adapter_get_pairable_timeout(adapter)); + g_print(" Powered: %d [rw]\n", adapter_get_powered(adapter)); + g_print(" UUIDs: ["); + const gchar **uuids = adapter_get_uuids(adapter); + for (int j = 0; uuids[j] != NULL; j++) { + if (j > 0) g_print(", "); + g_print("%s", uuid2name(uuids[j])); + } + g_print("]\n"); + + g_free(adapter_intf); + g_object_unref(adapter); + } else if (discover_arg) { + Adapter *adapter = find_adapter(adapter_arg, &error); + exit_if_error(error); + + // To store pairs MAC => Name + GHashTable *found_devices = g_hash_table_new(g_str_hash, g_str_equal); + + // Mainloop + GMainLoop *mainloop = g_main_loop_new(NULL, FALSE); + + g_signal_connect(adapter, "DeviceFound", G_CALLBACK(adapter_device_found), found_devices); + //g_signal_connect(adapter, "DeviceDisappeared", G_CALLBACK(adapter_device_disappeared), found_devices); + g_signal_connect(adapter, "PropertyChanged", G_CALLBACK(adapter_property_changed), mainloop); + + g_print("Searching...\n"); + adapter_start_discovery(adapter, &error); + exit_if_error(error); + + g_main_loop_run(mainloop); + /* Discovering process here... */ + g_main_loop_unref(mainloop); + + g_print("Done\n"); + g_hash_table_unref(found_devices); + g_object_unref(adapter); + } else if (set_arg) { + set_property_arg = argv[1]; + set_value_arg = argv[2]; + + Adapter *adapter = find_adapter(adapter_arg, &error); + exit_if_error(error); + + GValue v = {0,}; + + if (g_strcmp0(set_property_arg, "Name") == 0) { + g_value_init(&v, G_TYPE_STRING); + g_value_set_string(&v, set_value_arg); + } else if ( + g_strcmp0(set_property_arg, "Discoverable") == 0 || + g_strcmp0(set_property_arg, "Pairable") == 0 || + g_strcmp0(set_property_arg, "Powered") == 0 + ) { + g_value_init(&v, G_TYPE_BOOLEAN); + + if (g_strcmp0(set_value_arg, "0") == 0 || g_ascii_strcasecmp(set_value_arg, "FALSE") == 0 || g_ascii_strcasecmp(set_value_arg, "OFF") == 0) { + g_value_set_boolean(&v, FALSE); + } else if (g_strcmp0(set_value_arg, "1") == 0 || g_ascii_strcasecmp(set_value_arg, "TRUE") == 0 || g_ascii_strcasecmp(set_value_arg, "ON") == 0) { + g_value_set_boolean(&v, TRUE); + } else { + g_print("%s: Invalid boolean value: %s\n", g_get_prgname(), set_value_arg); + g_print("Try `%s --help` for more information.\n", g_get_prgname()); + exit(EXIT_FAILURE); + } + } else if ( + g_strcmp0(set_property_arg, "DiscoverableTimeout") == 0 || + g_strcmp0(set_property_arg, "PairableTimeout") == 0 + ) { + g_value_init(&v, G_TYPE_UINT); + g_value_set_uint(&v, (guint) atoi(set_value_arg)); + } else { + g_print("%s: Invalid property: %s\n", g_get_prgname(), set_property_arg); + g_print("Try `%s --help` for more information.\n", g_get_prgname()); + exit(EXIT_FAILURE); + } + + GHashTable *props = adapter_get_properties(adapter, &error); + exit_if_error(error); + GValue *old_value = g_hash_table_lookup(props, set_property_arg); + g_assert(old_value != NULL); + if (G_VALUE_HOLDS_STRING(old_value)) { + g_print("%s: %s -> %s\n", set_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", set_property_arg, g_value_get_boolean(old_value), g_value_get_boolean(&v)); + } else if (G_VALUE_HOLDS_UINT(old_value)) { + g_print("%s: %d -> %d\n", set_property_arg, g_value_get_uint(old_value), g_value_get_uint(&v)); + } + g_hash_table_unref(props); + + adapter_set_property(adapter, set_property_arg, &v, &error); + exit_if_error(error); + + g_value_unset(&v); + g_object_unref(adapter); + } + + g_object_unref(manager); + dbus_disconnect(); + + exit(EXIT_SUCCESS); +} + diff --git a/src/bt-agent.c b/src/bt-agent.c index 59b5685..9646e1c 100644 --- a/src/bt-agent.c +++ b/src/bt-agent.c @@ -1,95 +1,95 @@ -/*
- *
- * 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 <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include "lib/bluez-dbus.h"
-
-static gchar *adapter_arg = NULL;
-
-static GOptionEntry entries[] = {
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
- {NULL}
-};
-
-int main(int argc, char *argv[])
-{
- GError *error = NULL;
- GOptionContext *context;
-
- g_type_init();
-
- context = g_option_context_new(" - a bluetooth agent");
- g_option_context_add_main_entries(context, entries, NULL);
- g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
- g_option_context_set_description(context,
- //"Report bugs to <"PACKAGE_BUGREPORT">."
- "Project home <"PACKAGE_URL">."
- );
-
- if (!g_option_context_parse(context, &argc, &argv, &error)) {
- 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);
- }
-
- g_option_context_free(context);
-
- if (!dbus_connect(&error)) {
- g_printerr("Couldn't connect to dbus: %s\n", error->message);
- exit(EXIT_FAILURE);
- }
-
- Manager *manager = g_object_new(MANAGER_TYPE, NULL);
-
- Adapter *adapter = find_adapter(adapter_arg, &error);
- exit_if_error(error);
-
- Agent *agent = g_object_new(AGENT_TYPE, NULL);
-
- adapter_register_agent(adapter, DBUS_AGENT_PATH, "DisplayYesNo", &error);
- exit_if_error(error);
-
- GMainLoop *mainloop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(mainloop);
-
- // TODO: Add SIGINT handler (Ctrl+C)
-
- adapter_unregister_agent(adapter, DBUS_AGENT_PATH, &error);
- exit_if_error(error);
-
- g_main_loop_unref(mainloop);
- g_object_unref(agent);
- g_object_unref(adapter);
- g_object_unref(manager);
- dbus_disconnect();
-
- exit(EXIT_SUCCESS);
-}
-
+/* + * + * 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 <stdlib.h> +#include <string.h> +#include <glib.h> + +#include "lib/bluez-dbus.h" + +static gchar *adapter_arg = NULL; + +static GOptionEntry entries[] = { + {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"}, + {NULL} +}; + +int main(int argc, char *argv[]) +{ + GError *error = NULL; + GOptionContext *context; + + g_type_init(); + + context = g_option_context_new(" - a bluetooth agent"); + g_option_context_add_main_entries(context, entries, NULL); + g_option_context_set_summary(context, "Version "PACKAGE_VERSION); + g_option_context_set_description(context, + //"Report bugs to <"PACKAGE_BUGREPORT">." + "Project home <"PACKAGE_URL">." + ); + + if (!g_option_context_parse(context, &argc, &argv, &error)) { + 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); + } + + g_option_context_free(context); + + if (!dbus_connect(&error)) { + g_printerr("Couldn't connect to dbus: %s\n", error->message); + exit(EXIT_FAILURE); + } + + Manager *manager = g_object_new(MANAGER_TYPE, NULL); + + Adapter *adapter = find_adapter(adapter_arg, &error); + exit_if_error(error); + + Agent *agent = g_object_new(AGENT_TYPE, NULL); + + adapter_register_agent(adapter, DBUS_AGENT_PATH, "DisplayYesNo", &error); + exit_if_error(error); + + GMainLoop *mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + // TODO: Add SIGINT handler (Ctrl+C) + + adapter_unregister_agent(adapter, DBUS_AGENT_PATH, &error); + exit_if_error(error); + + g_main_loop_unref(mainloop); + g_object_unref(agent); + g_object_unref(adapter); + g_object_unref(manager); + dbus_disconnect(); + + exit(EXIT_SUCCESS); +} + diff --git a/src/lib/dbus-common.c b/src/lib/dbus-common.c index aaf6bca..d5a40d3 100644 --- a/src/lib/dbus-common.c +++ b/src/lib/dbus-common.c @@ -46,9 +46,8 @@ gboolean dbus_connect(GError **error) dbus_g_object_register_marshaller(g_cclosure_bluez_marshal_VOID__STRING_BOOLEAN, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID); dbus_g_object_register_marshaller(g_cclosure_bluez_marshal_VOID__INT_INT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID); - /* Agents installation */ + /* Agent 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); return TRUE; } diff --git a/src/lib/obexagent.c b/src/lib/obexagent.c deleted file mode 100644 index dd8af91..0000000 --- a/src/lib/obexagent.c +++ /dev/null @@ -1,174 +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 <stdio.h> -#include <string.h> -#include <errno.h> -#include <glib.h> - -#include "dbus-common.h" -#include "obexclient_transfer.h" -#include "obexagent.h" - -#define OBEXAGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXAGENT_TYPE, OBEXAgentPrivate)) - -struct _OBEXAgentPrivate { - DBusGProxy *proxy; -}; - -G_DEFINE_TYPE(OBEXAgent, obexagent, G_TYPE_OBJECT); - -static void obexagent_dispose(GObject *gobject) -{ - OBEXAgent *self = OBEXAGENT(gobject); - - dbus_g_connection_unregister_g_object(conn, gobject); - - /* Chain up to the parent class */ - G_OBJECT_CLASS(obexagent_parent_class)->dispose(gobject); -} - -static void obexagent_class_init(OBEXAgentClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = obexagent_dispose; - - g_type_class_add_private(klass, sizeof(OBEXAgentPrivate)); -} - -static void obexagent_init(OBEXAgent *self) -{ - self->priv = OBEXAGENT_GET_PRIVATE(self); - - g_assert(conn != NULL); - - dbus_g_connection_register_g_object(conn, DBUS_OBEXAGENT_PATH, G_OBJECT(self)); - - g_print("OBEX Agent registered\n"); -} - -/* Methods */ - -/* Agent 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) -{ - *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(" 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); - - 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) { - *ret = g_strdup("/home/zak/obp.ext"); - return TRUE; - } else { - // TODO: Fix error code - if (error) - *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) -{ - g_print("Request cancelled\n"); - return TRUE; -} - -/* Client API */ -gboolean obexagent_release(OBEXAgent *self, GError **error) -{ - g_print("OBEX Agent released\n"); - 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); - - 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) { - return TRUE; - } else { - // TODO: Fix error code - if (error) - *error = g_error_new(g_quark_from_static_string("org.openobex.Error.Rejected"), 0, "File transfer rejected"); - return FALSE; - } - - return TRUE; -} - -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); - - 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); - - 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); - - return TRUE; -} - diff --git a/src/lib/obexagent.h b/src/lib/obexagent.h deleted file mode 100644 index fefbc43..0000000 --- a/src/lib/obexagent.h +++ /dev/null @@ -1,98 +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 __OBEXAGENT_H -#define __OBEXAGENT_H - -#include <glib-object.h> -#include <dbus/dbus-glib.h> - -#include "marshallers.h" - -#define DBUS_OBEXAGENT_PATH "/ObexAgent" - -/* - * Type macros - */ -#define OBEXAGENT_TYPE (obexagent_get_type()) -#define OBEXAGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXAGENT_TYPE, OBEXAgent)) -#define OBEXAGENT_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXAGENT_TYPE)) -#define OBEXAGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXAGENT_TYPE, OBEXAgentClass)) -#define OBEXAGENT_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXAGENT_TYPE)) -#define OBEXAGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXAGENT_TYPE, OBEXAgentClass)) - -typedef struct _OBEXAgent OBEXAgent; -typedef struct _OBEXAgentClass OBEXAgentClass; -typedef struct _OBEXAgentPrivate OBEXAgentPrivate; - -struct _OBEXAgent { - GObject parent_instance; - - /*< private >*/ - OBEXAgentPrivate *priv; -}; - -struct _OBEXAgentClass { - GObjectClass parent_class; -}; - -/* used by OBEXAGENT_TYPE */ -GType obexagent_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ - -/* Agent 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); - -/* Client API */ -gboolean obexagent_release(OBEXAgent *self, GError **error); -gboolean obexagent_request(OBEXAgent *self, const gchar *transfer, gchar **ret, GError **error); -gboolean obexagent_progress(OBEXAgent *self, const gchar *transfer, guint64 transferred, GError **error); -gboolean obexagent_complete(OBEXAgent *self, const gchar *transfer, GError **error); -gboolean obexagent_error(OBEXAgent *self, const gchar *transfer, const gchar *message, GError **error); - -/* Glue code */ -static const DBusGMethodInfo dbus_glib_obexagent_methods[] = { - { (GCallback) obexagent_authorize, g_cclosure_bluez_marshal_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER, 0}, - { (GCallback) obexagent_cancel, g_cclosure_bluez_marshal_BOOLEAN__POINTER, 111}, - { (GCallback) obexagent_release, g_cclosure_bluez_marshal_BOOLEAN__POINTER, 140}, - { (GCallback) obexagent_request, g_cclosure_bluez_marshal_BOOLEAN__BOXED_POINTER_POINTER, 170}, - { (GCallback) obexagent_progress, g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT64_POINTER, 226}, - { (GCallback) obexagent_complete, g_cclosure_bluez_marshal_BOOLEAN__BOXED_POINTER, 286}, - { (GCallback) obexagent_error, g_cclosure_bluez_marshal_BOOLEAN__BOXED_STRING_POINTER, 330}, -}; - -static const DBusGObjectInfo dbus_glib_obexagent_object_info = { - 0, - dbus_glib_obexagent_methods, - 7, - "org.openobex.Agent\0Authorize\0S\0transfer\0I\0o\0bt_address\0I\0s\0name\0I\0s\0type\0I\0s\0length\0I\0i\0time\0I\0i\0arg6\0O\0F\0N\0s\0\0org.openobex.Agent\0Cancel\0S\0\0org.openobex.Agent\0Release\0S\0\0org.openobex.Agent\0Request\0S\0transfer\0I\0o\0arg1\0O\0F\0N\0s\0\0org.openobex.Agent\0Progress\0S\0transfer\0I\0o\0transferred\0I\0t\0\0org.openobex.Agent\0Complete\0S\0transfer\0I\0o\0\0org.openobex.Agent\0Error\0S\0transfer\0I\0o\0message\0I\0s\0\0\0", - "\0", - "\0" -}; - -#endif /* __OBEXAGENT_H */ - diff --git a/src/lib/obexclient.c b/src/lib/obexclient.c deleted file mode 100644 index 45a8e5e..0000000 --- a/src/lib/obexclient.c +++ /dev/null @@ -1,152 +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 "obexclient.h" - -#define OBEXCLIENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXCLIENT_TYPE, OBEXClientPrivate)) - -struct _OBEXClientPrivate { - DBusGProxy *dbus_g_proxy; - - /* Introspection data */ - DBusGProxy *introspection_g_proxy; - gchar *introspection_xml; -}; - -G_DEFINE_TYPE(OBEXClient, obexclient, G_TYPE_OBJECT); - -static void obexclient_dispose(GObject *gobject) -{ - OBEXClient *self = OBEXCLIENT(gobject); - - /* 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(obexclient_parent_class)->dispose(gobject); -} - -static void obexclient_class_init(OBEXClientClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = obexclient_dispose; - - g_type_class_add_private(klass, sizeof(OBEXClientPrivate)); -} - -static void obexclient_init(OBEXClient *self) -{ - self->priv = OBEXCLIENT_GET_PRIVATE(self); - - g_assert(conn != NULL); - - GError *error = NULL; - - /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_OBEXCLIENT_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=\"", BLUEZ_DBUS_OBEXCLIENT_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\"", BLUEZ_DBUS_OBEXCLIENT_INTERFACE, BLUEZ_DBUS_OBEXCLIENT_PATH); - g_assert(FALSE); - } - g_free(check_intf_regex_str); - - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_OBEXCLIENT_PATH, BLUEZ_DBUS_OBEXCLIENT_INTERFACE); -} - -/* Methods */ - -/* object CreateSession(dict device) */ -gchar *obexclient_create_session(OBEXClient *self, const GHashTable *device, GError **error) -{ - g_assert(OBEXCLIENT_IS(self)); - - gchar *ret = NULL; - dbus_g_proxy_call(self->priv->dbus_g_proxy, "CreateSession", error, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE, device, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &ret, G_TYPE_INVALID); - - return ret; -} - -/* void ExchangeBusinessCards(dict device, string clientfile, string file) */ -void obexclient_exchange_business_cards(OBEXClient *self, const GHashTable *device, const gchar *clientfile, const gchar *file, GError **error) -{ - g_assert(OBEXCLIENT_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "ExchangeBusinessCards", error, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE, device, G_TYPE_STRING, clientfile, G_TYPE_STRING, file, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* string GetCapabilities(dict device) */ -gchar *obexclient_get_capabilities(OBEXClient *self, const GHashTable *device, GError **error) -{ - g_assert(OBEXCLIENT_IS(self)); - - gchar *ret = NULL; - dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetCapabilities", error, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE, device, G_TYPE_INVALID, G_TYPE_STRING, &ret, G_TYPE_INVALID); - - return ret; -} - -/* void PullBusinessCard(dict device, string file) */ -void obexclient_pull_business_card(OBEXClient *self, const GHashTable *device, const gchar *file, GError **error) -{ - g_assert(OBEXCLIENT_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "PullBusinessCard", error, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE, device, G_TYPE_STRING, file, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* void RemoveSession(object session) */ -void obexclient_remove_session(OBEXClient *self, const gchar *session, GError **error) -{ - g_assert(OBEXCLIENT_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "RemoveSession", error, DBUS_TYPE_G_OBJECT_PATH, session, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* void SendFiles(dict device, array{string} files, object agent) */ -void obexclient_send_files(OBEXClient *self, const GHashTable *device, const gchar **files, const gchar *agent, GError **error) -{ - g_assert(OBEXCLIENT_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "SendFiles", error, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE, device, G_TYPE_STRV, files, DBUS_TYPE_G_OBJECT_PATH, agent, G_TYPE_INVALID, G_TYPE_INVALID); -} - diff --git a/src/lib/obexclient.h b/src/lib/obexclient.h deleted file mode 100644 index b527dc7..0000000 --- a/src/lib/obexclient.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 __OBEXCLIENT_H -#define __OBEXCLIENT_H - -#include <glib-object.h> - -#define BLUEZ_DBUS_OBEXCLIENT_PATH "/" -#define BLUEZ_DBUS_OBEXCLIENT_INTERFACE "org.openobex.Client" - -/* - * Type macros - */ -#define OBEXCLIENT_TYPE (obexclient_get_type()) -#define OBEXCLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXCLIENT_TYPE, OBEXClient)) -#define OBEXCLIENT_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXCLIENT_TYPE)) -#define OBEXCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXCLIENT_TYPE, OBEXClientClass)) -#define OBEXCLIENT_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXCLIENT_TYPE)) -#define OBEXCLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXCLIENT_TYPE, OBEXClientClass)) - -typedef struct _OBEXClient OBEXClient; -typedef struct _OBEXClientClass OBEXClientClass; -typedef struct _OBEXClientPrivate OBEXClientPrivate; - -struct _OBEXClient { - GObject parent_instance; - - /*< private >*/ - OBEXClientPrivate *priv; -}; - -struct _OBEXClientClass { - GObjectClass parent_class; -}; - -/* used by OBEXCLIENT_TYPE */ -GType obexclient_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ -gchar *obexclient_create_session(OBEXClient *self, const GHashTable *device, GError **error); -void obexclient_exchange_business_cards(OBEXClient *self, const GHashTable *device, const gchar *clientfile, const gchar *file, GError **error); -gchar *obexclient_get_capabilities(OBEXClient *self, const GHashTable *device, GError **error); -void obexclient_pull_business_card(OBEXClient *self, const GHashTable *device, const gchar *file, GError **error); -void obexclient_remove_session(OBEXClient *self, const gchar *session, GError **error); -void obexclient_send_files(OBEXClient *self, const GHashTable *device, const gchar **files, const gchar *agent, GError **error); - -#endif /* __OBEXCLIENT_H */ - diff --git a/src/lib/obexclient_file_transfer.c b/src/lib/obexclient_file_transfer.c deleted file mode 100644 index 883c37c..0000000 --- a/src/lib/obexclient_file_transfer.c +++ /dev/null @@ -1,234 +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 "obexclient_file_transfer.h" - -#define OBEXCLIENT_FILE_TRANSFER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXCLIENT_FILE_TRANSFER_TYPE, OBEXClientFileTransferPrivate)) - -struct _OBEXClientFileTransferPrivate { - DBusGProxy *dbus_g_proxy; - - /* Introspection data */ - DBusGProxy *introspection_g_proxy; - gchar *introspection_xml; -}; - -G_DEFINE_TYPE(OBEXClientFileTransfer, obexclient_file_transfer, G_TYPE_OBJECT); - -enum { - PROP_0, - - PROP_DBUS_OBJECT_PATH /* readwrite, construct only */ -}; - -static void _obexclient_file_transfer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void _obexclient_file_transfer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); - -static void obexclient_file_transfer_dispose(GObject *gobject) -{ - OBEXClientFileTransfer *self = OBEXCLIENT_FILE_TRANSFER(gobject); - - /* 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(obexclient_file_transfer_parent_class)->dispose(gobject); -} - -static void obexclient_file_transfer_class_init(OBEXClientFileTransferClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = obexclient_file_transfer_dispose; - - g_type_class_add_private(klass, sizeof(OBEXClientFileTransferPrivate)); - - /* Properties registration */ - GParamSpec *pspec; - - gobject_class->get_property = _obexclient_file_transfer_get_property; - gobject_class->set_property = _obexclient_file_transfer_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); -} - -static void obexclient_file_transfer_init(OBEXClientFileTransfer *self) -{ - self->priv = OBEXCLIENT_FILE_TRANSFER_GET_PRIVATE(self); - - g_assert(conn != NULL); -} - -static void obexclient_file_transfer_post_init(OBEXClientFileTransfer *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(conn, BLUEZ_DBUS_NAME, 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=\"", BLUEZ_DBUS_OBEXCLIENT_FILE_TRANSFER_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\"", BLUEZ_DBUS_OBEXCLIENT_FILE_TRANSFER_INTERFACE, dbus_object_path); - g_assert(FALSE); - } - g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_OBEXCLIENT_FILE_TRANSFER_INTERFACE); -} - -static void _obexclient_file_transfer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - OBEXClientFileTransfer *self = OBEXCLIENT_FILE_TRANSFER(object); - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - g_value_set_string(value, obexclient_file_transfer_get_dbus_object_path(self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void _obexclient_file_transfer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - OBEXClientFileTransfer *self = OBEXCLIENT_FILE_TRANSFER(object); - GError *error = NULL; - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - obexclient_file_transfer_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 ChangeFolder(string folder) */ -void obexclient_file_transfer_change_folder(OBEXClientFileTransfer *self, const gchar *folder, GError **error) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "ChangeFolder", error, G_TYPE_STRING, folder, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* void CopyFile(string sourcefile, string targetfile) */ -void obexclient_file_transfer_copy_file(OBEXClientFileTransfer *self, const gchar *sourcefile, const gchar *targetfile, GError **error) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "CopyFile", error, G_TYPE_STRING, sourcefile, G_TYPE_STRING, targetfile, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* void CreateFolder(string folder) */ -void obexclient_file_transfer_create_folder(OBEXClientFileTransfer *self, const gchar *folder, GError **error) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "CreateFolder", error, G_TYPE_STRING, folder, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* void Delete(string file) */ -void obexclient_file_transfer_delete(OBEXClientFileTransfer *self, const gchar *file, GError **error) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "Delete", error, G_TYPE_STRING, file, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* void GetFile(string targetfile, string sourcefile) */ -void obexclient_file_transfer_get_file(OBEXClientFileTransfer *self, const gchar *targetfile, const gchar *sourcefile, GError **error) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetFile", error, G_TYPE_STRING, targetfile, G_TYPE_STRING, sourcefile, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* array{dict} ListFolder() */ -GPtrArray *obexclient_file_transfer_list_folder(OBEXClientFileTransfer *self, GError **error) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - GPtrArray *ret = NULL; - dbus_g_proxy_call(self->priv->dbus_g_proxy, "ListFolder", error, G_TYPE_INVALID, DBUS_TYPE_G_HASH_TABLE_ARRAY, &ret, G_TYPE_INVALID); - - return ret; -} - -/* void MoveFile(string sourcefile, string targetfile) */ -void obexclient_file_transfer_move_file(OBEXClientFileTransfer *self, const gchar *sourcefile, const gchar *targetfile, GError **error) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "MoveFile", error, G_TYPE_STRING, sourcefile, G_TYPE_STRING, targetfile, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* void PutFile(string sourcefile, string targetfile) */ -void obexclient_file_transfer_put_file(OBEXClientFileTransfer *self, const gchar *sourcefile, const gchar *targetfile, GError **error) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "PutFile", error, G_TYPE_STRING, sourcefile, G_TYPE_STRING, targetfile, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* Properties access methods */ -const gchar *obexclient_file_transfer_get_dbus_object_path(OBEXClientFileTransfer *self) -{ - g_assert(OBEXCLIENT_FILE_TRANSFER_IS(self)); - - return dbus_g_proxy_get_path(self->priv->dbus_g_proxy); -} - diff --git a/src/lib/obexclient_file_transfer.h b/src/lib/obexclient_file_transfer.h deleted file mode 100644 index 38ac15e..0000000 --- a/src/lib/obexclient_file_transfer.h +++ /dev/null @@ -1,74 +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 __OBEXCLIENT_FILE_TRANSFER_H -#define __OBEXCLIENT_FILE_TRANSFER_H - -#include <glib-object.h> - -#define BLUEZ_DBUS_OBEXCLIENT_FILE_TRANSFER_INTERFACE "org.openobex.FileTransfer" - -/* - * Type macros - */ -#define OBEXCLIENT_FILE_TRANSFER_TYPE (obexclient_file_transfer_get_type()) -#define OBEXCLIENT_FILE_TRANSFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXCLIENT_FILE_TRANSFER_TYPE, OBEXClientFileTransfer)) -#define OBEXCLIENT_FILE_TRANSFER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXCLIENT_FILE_TRANSFER_TYPE)) -#define OBEXCLIENT_FILE_TRANSFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXCLIENT_FILE_TRANSFER_TYPE, OBEXClientFileTransferClass)) -#define OBEXCLIENT_FILE_TRANSFER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXCLIENT_FILE_TRANSFER_TYPE)) -#define OBEXCLIENT_FILE_TRANSFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXCLIENT_FILE_TRANSFER_TYPE, OBEXClientFileTransferClass)) - -typedef struct _OBEXClientFileTransfer OBEXClientFileTransfer; -typedef struct _OBEXClientFileTransferClass OBEXClientFileTransferClass; -typedef struct _OBEXClientFileTransferPrivate OBEXClientFileTransferPrivate; - -struct _OBEXClientFileTransfer { - GObject parent_instance; - - /*< private >*/ - OBEXClientFileTransferPrivate *priv; -}; - -struct _OBEXClientFileTransferClass { - GObjectClass parent_class; -}; - -/* used by OBEXCLIENT_FILE_TRANSFER_TYPE */ -GType obexclient_file_transfer_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ -void obexclient_file_transfer_change_folder(OBEXClientFileTransfer *self, const gchar *folder, GError **error); -void obexclient_file_transfer_copy_file(OBEXClientFileTransfer *self, const gchar *sourcefile, const gchar *targetfile, GError **error); -void obexclient_file_transfer_create_folder(OBEXClientFileTransfer *self, const gchar *folder, GError **error); -void obexclient_file_transfer_delete(OBEXClientFileTransfer *self, const gchar *file, GError **error); -void obexclient_file_transfer_get_file(OBEXClientFileTransfer *self, const gchar *targetfile, const gchar *sourcefile, GError **error); -GPtrArray *obexclient_file_transfer_list_folder(OBEXClientFileTransfer *self, GError **error); -void obexclient_file_transfer_move_file(OBEXClientFileTransfer *self, const gchar *sourcefile, const gchar *targetfile, GError **error); -void obexclient_file_transfer_put_file(OBEXClientFileTransfer *self, const gchar *sourcefile, const gchar *targetfile, GError **error); - -const gchar *obexclient_file_transfer_get_dbus_object_path(OBEXClientFileTransfer *self); - -#endif /* __OBEXCLIENT_FILE_TRANSFER_H */ - diff --git a/src/lib/obexclient_session.c b/src/lib/obexclient_session.c deleted file mode 100644 index 929ad59..0000000 --- a/src/lib/obexclient_session.c +++ /dev/null @@ -1,282 +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 "obexclient_session.h" - -#define OBEXCLIENT_SESSION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXCLIENT_SESSION_TYPE, OBEXClientSessionPrivate)) - -struct _OBEXClientSessionPrivate { - DBusGProxy *dbus_g_proxy; - - /* Introspection data */ - DBusGProxy *introspection_g_proxy; - gchar *introspection_xml; - - /* Properties */ - guchar channel; - gchar *destination; - gchar *source; -}; - -G_DEFINE_TYPE(OBEXClientSession, obexclient_session, G_TYPE_OBJECT); - -enum { - PROP_0, - - PROP_DBUS_OBJECT_PATH, /* readwrite, construct only */ - PROP_CHANNEL, /* readonly */ - PROP_DESTINATION, /* readonly */ - PROP_SOURCE /* readonly */ -}; - -static void _obexclient_session_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void _obexclient_session_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); - -static void obexclient_session_dispose(GObject *gobject) -{ - OBEXClientSession *self = OBEXCLIENT_SESSION(gobject); - - /* Properties free */ - g_free(self->priv->destination); - g_free(self->priv->source); - - /* 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(obexclient_session_parent_class)->dispose(gobject); -} - -static void obexclient_session_class_init(OBEXClientSessionClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = obexclient_session_dispose; - - g_type_class_add_private(klass, sizeof(OBEXClientSessionPrivate)); - - /* Properties registration */ - GParamSpec *pspec; - - gobject_class->get_property = _obexclient_session_get_property; - gobject_class->set_property = _obexclient_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); - - /* byte Channel [readonly] */ - pspec = g_param_spec_uchar("Channel", NULL, NULL, 0, 0xFF, 0, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_CHANNEL, pspec); - - /* string Destination [readonly] */ - pspec = g_param_spec_string("Destination", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_DESTINATION, pspec); - - /* string Source [readonly] */ - pspec = g_param_spec_string("Source", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_SOURCE, pspec); -} - -static void obexclient_session_init(OBEXClientSession *self) -{ - self->priv = OBEXCLIENT_SESSION_GET_PRIVATE(self); - - g_assert(conn != NULL); -} - -static void obexclient_session_post_init(OBEXClientSession *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(conn, BLUEZ_DBUS_NAME, 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=\"", BLUEZ_DBUS_OBEXCLIENT_SESSION_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\"", BLUEZ_DBUS_OBEXCLIENT_SESSION_INTERFACE, dbus_object_path); - g_assert(FALSE); - } - g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_OBEXCLIENT_SESSION_INTERFACE); - - /* Properties init */ - GHashTable *properties = obexclient_session_get_properties(self, &error); - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); - g_assert(properties != NULL); - - /* byte Channel [readonly] */ - if (g_hash_table_lookup(properties, "Channel")) { - self->priv->channel = g_value_get_uchar(g_hash_table_lookup(properties, "Channel")); - } else { - self->priv->channel = 0; - } - - /* string Destination [readonly] */ - if (g_hash_table_lookup(properties, "Destination")) { - self->priv->destination = g_value_dup_string(g_hash_table_lookup(properties, "Destination")); - } else { - self->priv->destination = g_strdup("undefined"); - } - - /* string Source [readonly] */ - if (g_hash_table_lookup(properties, "Source")) { - self->priv->source = g_value_dup_string(g_hash_table_lookup(properties, "Source")); - } else { - self->priv->source = g_strdup("undefined"); - } - - g_hash_table_unref(properties); -} - -static void _obexclient_session_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - OBEXClientSession *self = OBEXCLIENT_SESSION(object); - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - g_value_set_string(value, obexclient_session_get_dbus_object_path(self)); - break; - - case PROP_CHANNEL: - g_value_set_uchar(value, obexclient_session_get_channel(self)); - break; - - case PROP_DESTINATION: - g_value_set_string(value, obexclient_session_get_destination(self)); - break; - - case PROP_SOURCE: - g_value_set_string(value, obexclient_session_get_source(self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void _obexclient_session_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - OBEXClientSession *self = OBEXCLIENT_SESSION(object); - GError *error = NULL; - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - obexclient_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 AssignAgent(object agent) */ -void obexclient_session_assign_agent(OBEXClientSession *self, const gchar *agent, GError **error) -{ - g_assert(OBEXCLIENT_SESSION_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "AssignAgent", error, DBUS_TYPE_G_OBJECT_PATH, agent, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* dict GetProperties() */ -GHashTable *obexclient_session_get_properties(OBEXClientSession *self, GError **error) -{ - g_assert(OBEXCLIENT_SESSION_IS(self)); - - GHashTable *ret = NULL; - dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetProperties", error, G_TYPE_INVALID, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE, &ret, G_TYPE_INVALID); - - return ret; -} - -/* void ReleaseAgent(object agent) */ -void obexclient_session_release_agent(OBEXClientSession *self, const gchar *agent, GError **error) -{ - g_assert(OBEXCLIENT_SESSION_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "ReleaseAgent", error, DBUS_TYPE_G_OBJECT_PATH, agent, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* Properties access methods */ -const gchar *obexclient_session_get_dbus_object_path(OBEXClientSession *self) -{ - g_assert(OBEXCLIENT_SESSION_IS(self)); - - return dbus_g_proxy_get_path(self->priv->dbus_g_proxy); -} - -const guchar obexclient_session_get_channel(OBEXClientSession *self) -{ - g_assert(OBEXCLIENT_SESSION_IS(self)); - - return self->priv->channel; -} - -const gchar *obexclient_session_get_destination(OBEXClientSession *self) -{ - g_assert(OBEXCLIENT_SESSION_IS(self)); - - return self->priv->destination; -} - -const gchar *obexclient_session_get_source(OBEXClientSession *self) -{ - g_assert(OBEXCLIENT_SESSION_IS(self)); - - return self->priv->source; -} - diff --git a/src/lib/obexclient_session.h b/src/lib/obexclient_session.h deleted file mode 100644 index e3715e8..0000000 --- a/src/lib/obexclient_session.h +++ /dev/null @@ -1,72 +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 __OBEXCLIENT_SESSION_H -#define __OBEXCLIENT_SESSION_H - -#include <glib-object.h> - -#define BLUEZ_DBUS_OBEXCLIENT_SESSION_INTERFACE "org.openobex.Session" - -/* - * Type macros - */ -#define OBEXCLIENT_SESSION_TYPE (obexclient_session_get_type()) -#define OBEXCLIENT_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXCLIENT_SESSION_TYPE, OBEXClientSession)) -#define OBEXCLIENT_SESSION_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXCLIENT_SESSION_TYPE)) -#define OBEXCLIENT_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXCLIENT_SESSION_TYPE, OBEXClientSessionClass)) -#define OBEXCLIENT_SESSION_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXCLIENT_SESSION_TYPE)) -#define OBEXCLIENT_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXCLIENT_SESSION_TYPE, OBEXClientSessionClass)) - -typedef struct _OBEXClientSession OBEXClientSession; -typedef struct _OBEXClientSessionClass OBEXClientSessionClass; -typedef struct _OBEXClientSessionPrivate OBEXClientSessionPrivate; - -struct _OBEXClientSession { - GObject parent_instance; - - /*< private >*/ - OBEXClientSessionPrivate *priv; -}; - -struct _OBEXClientSessionClass { - GObjectClass parent_class; -}; - -/* used by OBEXCLIENT_SESSION_TYPE */ -GType obexclient_session_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ -void obexclient_session_assign_agent(OBEXClientSession *self, const gchar *agent, GError **error); -GHashTable *obexclient_session_get_properties(OBEXClientSession *self, GError **error); -void obexclient_session_release_agent(OBEXClientSession *self, const gchar *agent, GError **error); - -const gchar *obexclient_session_get_dbus_object_path(OBEXClientSession *self); -const guchar obexclient_session_get_channel(OBEXClientSession *self); -const gchar *obexclient_session_get_destination(OBEXClientSession *self); -const gchar *obexclient_session_get_source(OBEXClientSession *self); - -#endif /* __OBEXCLIENT_SESSION_H */ - diff --git a/src/lib/obexclient_transfer.c b/src/lib/obexclient_transfer.c deleted file mode 100644 index a3a47e5..0000000 --- a/src/lib/obexclient_transfer.c +++ /dev/null @@ -1,274 +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 "obexclient_transfer.h" - -#define OBEXCLIENT_TRANSFER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXCLIENT_TRANSFER_TYPE, OBEXClientTransferPrivate)) - -struct _OBEXClientTransferPrivate { - DBusGProxy *dbus_g_proxy; - - /* Introspection data */ - DBusGProxy *introspection_g_proxy; - gchar *introspection_xml; - - /* Properties */ - gchar *filename; - gchar *name; - guint64 size; -}; - -G_DEFINE_TYPE(OBEXClientTransfer, obexclient_transfer, G_TYPE_OBJECT); - -enum { - PROP_0, - - PROP_DBUS_OBJECT_PATH, /* readwrite, construct only */ - PROP_FILENAME, /* readonly */ - PROP_NAME, /* readonly */ - PROP_SIZE /* readonly */ -}; - -static void _obexclient_transfer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void _obexclient_transfer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); - -static void obexclient_transfer_dispose(GObject *gobject) -{ - OBEXClientTransfer *self = OBEXCLIENT_TRANSFER(gobject); - - /* Properties free */ - g_free(self->priv->filename); - g_free(self->priv->name); - - /* 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(obexclient_transfer_parent_class)->dispose(gobject); -} - -static void obexclient_transfer_class_init(OBEXClientTransferClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = obexclient_transfer_dispose; - - g_type_class_add_private(klass, sizeof(OBEXClientTransferPrivate)); - - /* Properties registration */ - GParamSpec *pspec; - - gobject_class->get_property = _obexclient_transfer_get_property; - gobject_class->set_property = _obexclient_transfer_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); - - /* string Filename [readonly] */ - pspec = g_param_spec_string("Filename", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_FILENAME, pspec); - - /* string Name [readonly] */ - pspec = g_param_spec_string("Name", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_NAME, pspec); - - /* uint64 Size [readonly] */ - pspec = g_param_spec_uint64("Size", NULL, NULL, 0, 0xFFFFFFFFFFFFFFFF, 0, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_SIZE, pspec); -} - -static void obexclient_transfer_init(OBEXClientTransfer *self) -{ - self->priv = OBEXCLIENT_TRANSFER_GET_PRIVATE(self); - - g_assert(conn != NULL); -} - -static void obexclient_transfer_post_init(OBEXClientTransfer *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(conn, BLUEZ_DBUS_NAME, 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=\"", BLUEZ_DBUS_OBEXCLIENT_TRANSFER_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\"", BLUEZ_DBUS_OBEXCLIENT_TRANSFER_INTERFACE, dbus_object_path); - g_assert(FALSE); - } - g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_OBEXCLIENT_TRANSFER_INTERFACE); - - /* Properties init */ - GHashTable *properties = obexclient_transfer_get_properties(self, &error); - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); - g_assert(properties != NULL); - - /* string Filename [readonly] */ - if (g_hash_table_lookup(properties, "Filename")) { - self->priv->filename = g_value_dup_string(g_hash_table_lookup(properties, "Filename")); - } else { - self->priv->filename = g_strdup("undefined"); - } - - /* string Name [readonly] */ - if (g_hash_table_lookup(properties, "Name")) { - self->priv->name = g_value_dup_string(g_hash_table_lookup(properties, "Name")); - } else { - self->priv->name = g_strdup("undefined"); - } - - /* uint64 Size [readonly] */ - if (g_hash_table_lookup(properties, "Size")) { - self->priv->size = g_value_get_uint64(g_hash_table_lookup(properties, "Size")); - } else { - self->priv->size = 0; - } - - g_hash_table_unref(properties); -} - -static void _obexclient_transfer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - OBEXClientTransfer *self = OBEXCLIENT_TRANSFER(object); - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - g_value_set_string(value, obexclient_transfer_get_dbus_object_path(self)); - break; - - case PROP_FILENAME: - g_value_set_string(value, obexclient_transfer_get_filename(self)); - break; - - case PROP_NAME: - g_value_set_string(value, obexclient_transfer_get_name(self)); - break; - - case PROP_SIZE: - g_value_set_uint64(value, obexclient_transfer_get_size(self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void _obexclient_transfer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - OBEXClientTransfer *self = OBEXCLIENT_TRANSFER(object); - GError *error = NULL; - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - obexclient_transfer_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 obexclient_transfer_cancel(OBEXClientTransfer *self, GError **error) -{ - g_assert(OBEXCLIENT_TRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "Cancel", error, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* dict GetProperties() */ -GHashTable *obexclient_transfer_get_properties(OBEXClientTransfer *self, GError **error) -{ - g_assert(OBEXCLIENT_TRANSFER_IS(self)); - - GHashTable *ret = NULL; - dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetProperties", error, G_TYPE_INVALID, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE, &ret, G_TYPE_INVALID); - - return ret; -} - -/* Properties access methods */ -const gchar *obexclient_transfer_get_dbus_object_path(OBEXClientTransfer *self) -{ - g_assert(OBEXCLIENT_TRANSFER_IS(self)); - - return dbus_g_proxy_get_path(self->priv->dbus_g_proxy); -} - -const gchar *obexclient_transfer_get_filename(OBEXClientTransfer *self) -{ - g_assert(OBEXCLIENT_TRANSFER_IS(self)); - - return self->priv->filename; -} - -const gchar *obexclient_transfer_get_name(OBEXClientTransfer *self) -{ - g_assert(OBEXCLIENT_TRANSFER_IS(self)); - - return self->priv->name; -} - -const guint64 obexclient_transfer_get_size(OBEXClientTransfer *self) -{ - g_assert(OBEXCLIENT_TRANSFER_IS(self)); - - return self->priv->size; -} - diff --git a/src/lib/obexclient_transfer.h b/src/lib/obexclient_transfer.h deleted file mode 100644 index 5bed1b5..0000000 --- a/src/lib/obexclient_transfer.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 __OBEXCLIENT_TRANSFER_H -#define __OBEXCLIENT_TRANSFER_H - -#include <glib-object.h> - -#define BLUEZ_DBUS_OBEXCLIENT_TRANSFER_INTERFACE "org.openobex.Transfer" - -/* - * Type macros - */ -#define OBEXCLIENT_TRANSFER_TYPE (obexclient_transfer_get_type()) -#define OBEXCLIENT_TRANSFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXCLIENT_TRANSFER_TYPE, OBEXClientTransfer)) -#define OBEXCLIENT_TRANSFER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXCLIENT_TRANSFER_TYPE)) -#define OBEXCLIENT_TRANSFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXCLIENT_TRANSFER_TYPE, OBEXClientTransferClass)) -#define OBEXCLIENT_TRANSFER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXCLIENT_TRANSFER_TYPE)) -#define OBEXCLIENT_TRANSFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXCLIENT_TRANSFER_TYPE, OBEXClientTransferClass)) - -typedef struct _OBEXClientTransfer OBEXClientTransfer; -typedef struct _OBEXClientTransferClass OBEXClientTransferClass; -typedef struct _OBEXClientTransferPrivate OBEXClientTransferPrivate; - -struct _OBEXClientTransfer { - GObject parent_instance; - - /*< private >*/ - OBEXClientTransferPrivate *priv; -}; - -struct _OBEXClientTransferClass { - GObjectClass parent_class; -}; - -/* used by OBEXCLIENT_TRANSFER_TYPE */ -GType obexclient_transfer_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ -void obexclient_transfer_cancel(OBEXClientTransfer *self, GError **error); -GHashTable *obexclient_transfer_get_properties(OBEXClientTransfer *self, GError **error); - -const gchar *obexclient_transfer_get_dbus_object_path(OBEXClientTransfer *self); -const gchar *obexclient_transfer_get_filename(OBEXClientTransfer *self); -const gchar *obexclient_transfer_get_name(OBEXClientTransfer *self); -const guint64 obexclient_transfer_get_size(OBEXClientTransfer *self); - -#endif /* __OBEXCLIENT_TRANSFER_H */ - diff --git a/src/lib/obexmanager.c b/src/lib/obexmanager.c deleted file mode 100644 index 8096679..0000000 --- a/src/lib/obexmanager.c +++ /dev/null @@ -1,212 +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_CREATED, - SESSION_REMOVED, - TRANSFER_COMPLETED, - TRANSFER_STARTED, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -static void session_created_handler(DBusGProxy *dbus_g_proxy, const gchar *session, gpointer data); -static void session_removed_handler(DBusGProxy *dbus_g_proxy, const gchar *session, gpointer data); -static void transfer_completed_handler(DBusGProxy *dbus_g_proxy, const gchar *transfer, const gboolean success, gpointer data); -static void transfer_started_handler(DBusGProxy *dbus_g_proxy, const gchar *transfer, 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, "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, "TransferCompleted", G_CALLBACK(transfer_completed_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(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_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[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_bluez_marshal_VOID__STRING_BOOLEAN, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN); - - 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_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); -} - -static void obexmanager_init(OBEXManager *self) -{ - self->priv = OBEXMANAGER_GET_PRIVATE(self); - - g_assert(conn != NULL); - - GError *error = NULL; - - /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_OBEXMANAGER_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=\"", BLUEZ_DBUS_OBEXMANAGER_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\"", BLUEZ_DBUS_OBEXMANAGER_INTERFACE, BLUEZ_DBUS_OBEXMANAGER_PATH); - g_assert(FALSE); - } - g_free(check_intf_regex_str); - - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_OBEXMANAGER_PATH, BLUEZ_DBUS_OBEXMANAGER_INTERFACE); - - /* DBus signals connection */ - - /* SessionCreated(object session) */ - 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) */ - 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); - - /* TransferCompleted(object transfer, boolean success) */ - dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "TransferCompleted", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "TransferCompleted", G_CALLBACK(transfer_completed_handler), self, NULL); - - /* TransferStarted(object transfer) */ - dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "TransferStarted", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "TransferStarted", G_CALLBACK(transfer_started_handler), self, NULL); -} - -/* Methods */ - -/* void RegisterAgent(object agent) */ -void obexmanager_register_agent(OBEXManager *self, const gchar *agent, GError **error) -{ - g_assert(OBEXMANAGER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "RegisterAgent", error, DBUS_TYPE_G_OBJECT_PATH, agent, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* void UnregisterAgent(object agent) */ -void obexmanager_unregister_agent(OBEXManager *self, const gchar *agent, GError **error) -{ - g_assert(OBEXMANAGER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "UnregisterAgent", error, DBUS_TYPE_G_OBJECT_PATH, agent, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* Signals handlers */ -static void session_created_handler(DBusGProxy *dbus_g_proxy, const gchar *session, gpointer data) -{ - OBEXManager *self = OBEXMANAGER(data); - - g_signal_emit(self, signals[SESSION_CREATED], 0, session); -} - -static void session_removed_handler(DBusGProxy *dbus_g_proxy, const gchar *session, gpointer data) -{ - OBEXManager *self = OBEXMANAGER(data); - - g_signal_emit(self, signals[SESSION_REMOVED], 0, session); -} - -static void transfer_completed_handler(DBusGProxy *dbus_g_proxy, const gchar *transfer, const gboolean success, gpointer data) -{ - OBEXManager *self = OBEXMANAGER(data); - - g_signal_emit(self, signals[TRANSFER_COMPLETED], 0, transfer, success); -} - -static void transfer_started_handler(DBusGProxy *dbus_g_proxy, const gchar *transfer, gpointer data) -{ - OBEXManager *self = OBEXMANAGER(data); - - g_signal_emit(self, signals[TRANSFER_STARTED], 0, transfer); -} - diff --git a/src/lib/obexmanager.h b/src/lib/obexmanager.h deleted file mode 100644 index bfdd12c..0000000 --- a/src/lib/obexmanager.h +++ /dev/null @@ -1,67 +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 BLUEZ_DBUS_OBEXMANAGER_PATH "/" -#define BLUEZ_DBUS_OBEXMANAGER_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 - */ -void obexmanager_register_agent(OBEXManager *self, const gchar *agent, GError **error); -void obexmanager_unregister_agent(OBEXManager *self, const gchar *agent, GError **error); - -#endif /* __OBEXMANAGER_H */ - diff --git a/src/lib/obexsession.c b/src/lib/obexsession.c deleted file mode 100644 index ce482ab..0000000 --- a/src/lib/obexsession.c +++ /dev/null @@ -1,217 +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; - - /* Properties */ - gchar *address; -}; - -G_DEFINE_TYPE(OBEXSession, obexsession, G_TYPE_OBJECT); - -enum { - PROP_0, - - PROP_DBUS_OBJECT_PATH, /* readwrite, construct only */ - PROP_ADDRESS /* readonly */ -}; - -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); - -static void obexsession_dispose(GObject *gobject) -{ - OBEXSession *self = OBEXSESSION(gobject); - - /* Properties free */ - g_free(self->priv->address); - - /* 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); - - /* string Address [readonly] */ - pspec = g_param_spec_string("Address", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_ADDRESS, pspec); -} - -static void obexsession_init(OBEXSession *self) -{ - self->priv = OBEXSESSION_GET_PRIVATE(self); - - g_assert(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(conn, BLUEZ_DBUS_NAME, 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=\"", BLUEZ_DBUS_OBEXSESSION_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\"", BLUEZ_DBUS_OBEXSESSION_INTERFACE, dbus_object_path); - g_assert(FALSE); - } - g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_OBEXSESSION_INTERFACE); - - /* Properties init */ - GHashTable *properties = obexsession_get_properties(self, &error); - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); - g_assert(properties != NULL); - - /* string Address [readonly] */ - if (g_hash_table_lookup(properties, "Address")) { - self->priv->address = g_value_dup_string(g_hash_table_lookup(properties, "Address")); - } else { - self->priv->address = g_strdup("undefined"); - } - - g_hash_table_unref(properties); -} - -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; - - case PROP_ADDRESS: - g_value_set_string(value, obexsession_get_address(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 */ - -/* dict GetProperties() */ -GHashTable *obexsession_get_properties(OBEXSession *self, GError **error) -{ - g_assert(OBEXSESSION_IS(self)); - - GHashTable *ret = NULL; - dbus_g_proxy_call(self->priv->dbus_g_proxy, "GetProperties", error, G_TYPE_INVALID, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE, &ret, G_TYPE_INVALID); - - return ret; -} - -/* 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); -} - -const gchar *obexsession_get_address(OBEXSession *self) -{ - g_assert(OBEXSESSION_IS(self)); - - return self->priv->address; -} - diff --git a/src/lib/obexsession.h b/src/lib/obexsession.h deleted file mode 100644 index a6ecec7..0000000 --- a/src/lib/obexsession.h +++ /dev/null @@ -1,68 +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 BLUEZ_DBUS_OBEXSESSION_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 - */ -GHashTable *obexsession_get_properties(OBEXSession *self, GError **error); - -const gchar *obexsession_get_dbus_object_path(OBEXSession *self); -const gchar *obexsession_get_address(OBEXSession *self); - -#endif /* __OBEXSESSION_H */ - diff --git a/src/lib/obextransfer.c b/src/lib/obextransfer.c deleted file mode 100644 index 2b94ee2..0000000 --- a/src/lib/obextransfer.c +++ /dev/null @@ -1,210 +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 "obextransfer.h" - -#define OBEXTRANSFER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXTRANSFER_TYPE, OBEXTransferPrivate)) - -struct _OBEXTransferPrivate { - DBusGProxy *dbus_g_proxy; - - /* Introspection data */ - DBusGProxy *introspection_g_proxy; - gchar *introspection_xml; -}; - -G_DEFINE_TYPE(OBEXTransfer, obextransfer, G_TYPE_OBJECT); - -enum { - PROP_0, - - PROP_DBUS_OBJECT_PATH /* readwrite, construct only */ -}; - -static void _obextransfer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void _obextransfer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); - -enum { - PROGRESS, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -static void progress_handler(DBusGProxy *dbus_g_proxy, const gint32 total, const gint32 transfered, gpointer data); - -static void obextransfer_dispose(GObject *gobject) -{ - OBEXTransfer *self = OBEXTRANSFER(gobject); - - /* DBus signals disconnection */ - dbus_g_proxy_disconnect_signal(self->priv->dbus_g_proxy, "Progress", G_CALLBACK(progress_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(obextransfer_parent_class)->dispose(gobject); -} - -static void obextransfer_class_init(OBEXTransferClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = obextransfer_dispose; - - g_type_class_add_private(klass, sizeof(OBEXTransferPrivate)); - - /* Properties registration */ - GParamSpec *pspec; - - gobject_class->get_property = _obextransfer_get_property; - gobject_class->set_property = _obextransfer_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[PROGRESS] = g_signal_new("Progress", - G_TYPE_FROM_CLASS(gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, - 0, NULL, NULL, - g_cclosure_bluez_marshal_VOID__INT_INT, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); -} - -static void obextransfer_init(OBEXTransfer *self) -{ - self->priv = OBEXTRANSFER_GET_PRIVATE(self); - - g_assert(conn != NULL); -} - -static void obextransfer_post_init(OBEXTransfer *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(conn, BLUEZ_DBUS_NAME, 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=\"", BLUEZ_DBUS_OBEXTRANSFER_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\"", BLUEZ_DBUS_OBEXTRANSFER_INTERFACE, dbus_object_path); - g_assert(FALSE); - } - g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_OBEXTRANSFER_INTERFACE); - - /* DBus signals connection */ - - /* Progress(int32 total, int32 transfered) */ - dbus_g_proxy_add_signal(self->priv->dbus_g_proxy, "Progress", G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "Progress", G_CALLBACK(progress_handler), self, NULL); -} - -static void _obextransfer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - OBEXTransfer *self = OBEXTRANSFER(object); - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - g_value_set_string(value, obextransfer_get_dbus_object_path(self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void _obextransfer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - OBEXTransfer *self = OBEXTRANSFER(object); - GError *error = NULL; - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - obextransfer_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 obextransfer_cancel(OBEXTransfer *self, GError **error) -{ - g_assert(OBEXTRANSFER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "Cancel", error, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* Properties access methods */ -const gchar *obextransfer_get_dbus_object_path(OBEXTransfer *self) -{ - g_assert(OBEXTRANSFER_IS(self)); - - return dbus_g_proxy_get_path(self->priv->dbus_g_proxy); -} - -/* Signals handlers */ -static void progress_handler(DBusGProxy *dbus_g_proxy, const gint32 total, const gint32 transfered, gpointer data) -{ - OBEXTransfer *self = OBEXTRANSFER(data); - - g_signal_emit(self, signals[PROGRESS], 0, total, transfered); -} - diff --git a/src/lib/obextransfer.h b/src/lib/obextransfer.h deleted file mode 100644 index 1484d72..0000000 --- a/src/lib/obextransfer.h +++ /dev/null @@ -1,67 +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 __OBEXTRANSFER_H -#define __OBEXTRANSFER_H - -#include <glib-object.h> - -#define BLUEZ_DBUS_OBEXTRANSFER_INTERFACE "org.openobex.Transfer" - -/* - * Type macros - */ -#define OBEXTRANSFER_TYPE (obextransfer_get_type()) -#define OBEXTRANSFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXTRANSFER_TYPE, OBEXTransfer)) -#define OBEXTRANSFER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXTRANSFER_TYPE)) -#define OBEXTRANSFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXTRANSFER_TYPE, OBEXTransferClass)) -#define OBEXTRANSFER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXTRANSFER_TYPE)) -#define OBEXTRANSFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXTRANSFER_TYPE, OBEXTransferClass)) - -typedef struct _OBEXTransfer OBEXTransfer; -typedef struct _OBEXTransferClass OBEXTransferClass; -typedef struct _OBEXTransferPrivate OBEXTransferPrivate; - -struct _OBEXTransfer { - GObject parent_instance; - - /*< private >*/ - OBEXTransferPrivate *priv; -}; - -struct _OBEXTransferClass { - GObjectClass parent_class; -}; - -/* used by OBEXTRANSFER_TYPE */ -GType obextransfer_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ -void obextransfer_cancel(OBEXTransfer *self, GError **error); - -const gchar *obextransfer_get_dbus_object_path(OBEXTransfer *self); - -#endif /* __OBEXTRANSFER_H */ - |