diff options
author | Alexander Orlenko <zxteam@gmail.com> | 2010-08-07 00:45:45 +1100 |
---|---|---|
committer | Alexander Orlenko <zxteam@gmail.com> | 2010-08-07 00:45:45 +1100 |
commit | da8f4e34ae3c1bbff5d46a8a44cf42c6f12c3221 (patch) | |
tree | c6fe1f2cc6f104dfb307b3d7203d43d64a3c800a | |
parent | 75eae0453ceffc4507fc6a5aca7aebebfcd8c521 (diff) | |
download | bluez-tools-da8f4e34ae3c1bbff5d46a8a44cf42c6f12c3221.tar.gz |
A lot of refactoring
Returning to obexd api
ODS (obex-data-server support) freezed
-rw-r--r-- | contrib/bluez-api-4.66-fixed/network-api.txt | 163 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/adapter-api.txt (renamed from contrib/bluez-api-4.66-fixed/adapter-api.txt) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/agent-api.txt (renamed from contrib/bluez-api-4.66-fixed/agent-api.txt) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/agent.xml (renamed from contrib/bluez-api-4.66-fixed/agent.xml) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/attribute-api.txt | 97 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/audio-api.txt (renamed from contrib/bluez-api-4.66-fixed/audio-api.txt) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/control-api.txt (renamed from contrib/bluez-api-4.66-fixed/control-api.txt) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/device-api.txt (renamed from contrib/bluez-api-4.66-fixed/device-api.txt) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/input-api.txt (renamed from contrib/bluez-api-4.66-fixed/input-api.txt) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/manager-api.txt (renamed from contrib/bluez-api-4.66-fixed/manager-api.txt) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/network-api.txt | 88 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/serial-api.txt (renamed from contrib/bluez-api-4.66-fixed/serial-api.txt) | 0 | ||||
-rw-r--r-- | contrib/bluez-api-4.69-fixed/service-api.txt (renamed from contrib/bluez-api-4.66-fixed/service-api.txt) | 0 | ||||
-rwxr-xr-x | contrib/gen-dbus-gobject.pl | 126 | ||||
-rwxr-xr-x | contrib/generate-all.sh | 55 | ||||
-rwxr-xr-x | contrib/generate-bluez-gobjects.sh | 37 | ||||
-rwxr-xr-x | contrib/generate-obexd-gobjects.sh | 29 | ||||
-rwxr-xr-x | contrib/generate-ods-gobjects.sh | 18 | ||||
-rw-r--r-- | contrib/obexd-api-0.30-fixed/agent-api.txt | 30 | ||||
-rw-r--r-- | contrib/obexd-api-0.30-fixed/client-api.txt | 329 | ||||
-rw-r--r-- | contrib/obexd-api-0.30-fixed/obexd-api.txt | 90 | ||||
-rw-r--r-- | contrib/ods-api-0.4.5-fixed/obex-data-server-api-0.4.5-fixed.txt (renamed from contrib/obex-data-server-api-0.4.5-fixed.txt) | 2 | ||||
-rw-r--r-- | src/Makefile.am | 76 | ||||
-rw-r--r-- | src/lib/bluez-api.h (renamed from src/lib/bluez-dbus.h) | 40 | ||||
-rw-r--r-- | src/lib/bluez/adapter.c (renamed from src/lib/adapter.c) | 19 | ||||
-rw-r--r-- | src/lib/bluez/adapter.h (renamed from src/lib/adapter.h) | 2 | ||||
-rw-r--r-- | src/lib/bluez/agent.c (renamed from src/lib/agent.c) | 9 | ||||
-rw-r--r-- | src/lib/bluez/agent.h (renamed from src/lib/agent.h) | 20 | ||||
-rw-r--r-- | src/lib/bluez/audio.c (renamed from src/lib/audio.c) | 17 | ||||
-rw-r--r-- | src/lib/bluez/audio.h (renamed from src/lib/audio.h) | 2 | ||||
-rw-r--r-- | src/lib/bluez/device.c (renamed from src/lib/device.c) | 17 | ||||
-rw-r--r-- | src/lib/bluez/device.h (renamed from src/lib/device.h) | 2 | ||||
-rw-r--r-- | src/lib/bluez/input.c (renamed from src/lib/input.c) | 17 | ||||
-rw-r--r-- | src/lib/bluez/input.h (renamed from src/lib/input.h) | 2 | ||||
-rw-r--r-- | src/lib/bluez/manager.c (renamed from src/lib/manager.c) | 17 | ||||
-rw-r--r-- | src/lib/bluez/manager.h (renamed from src/lib/manager.h) | 4 | ||||
-rw-r--r-- | src/lib/bluez/network.c (renamed from src/lib/network.c) | 17 | ||||
-rw-r--r-- | src/lib/bluez/network.h (renamed from src/lib/network.h) | 2 | ||||
-rw-r--r-- | src/lib/bluez/network_server.c | 184 | ||||
-rw-r--r-- | src/lib/bluez/network_server.h | 68 | ||||
-rw-r--r-- | src/lib/bluez/serial.c (renamed from src/lib/serial.c) | 15 | ||||
-rw-r--r-- | src/lib/bluez/serial.h (renamed from src/lib/serial.h) | 2 | ||||
-rw-r--r-- | src/lib/dbus-common.c | 59 | ||||
-rw-r--r-- | src/lib/dbus-common.h | 13 | ||||
-rw-r--r-- | src/lib/helpers.c | 3 | ||||
-rw-r--r-- | src/lib/helpers.h | 19 | ||||
-rw-r--r-- | src/lib/marshallers.c | 631 | ||||
-rw-r--r-- | src/lib/marshallers.h | 180 | ||||
-rw-r--r-- | src/lib/marshallers.list | 34 | ||||
-rw-r--r-- | src/lib/network_hub.c | 318 | ||||
-rw-r--r-- | src/lib/network_hub.h | 73 | ||||
-rw-r--r-- | src/lib/network_peer.c | 318 | ||||
-rw-r--r-- | src/lib/network_peer.h | 73 | ||||
-rw-r--r-- | src/lib/network_router.c | 318 | ||||
-rw-r--r-- | src/lib/network_router.h | 73 | ||||
-rw-r--r-- | src/lib/obexd-api.h | 44 | ||||
-rw-r--r-- | src/lib/obexd/obexagent.c | 175 | ||||
-rw-r--r-- | src/lib/obexd/obexagent.h | 98 | ||||
-rw-r--r-- | src/lib/obexd/obexclient.c | 153 | ||||
-rw-r--r-- | src/lib/obexd/obexclient.h | 71 | ||||
-rw-r--r-- | src/lib/obexd/obexclient_file_transfer.c | 235 | ||||
-rw-r--r-- | src/lib/obexd/obexclient_file_transfer.h | 74 | ||||
-rw-r--r-- | src/lib/obexd/obexclient_session.c | 283 | ||||
-rw-r--r-- | src/lib/obexd/obexclient_session.h | 72 | ||||
-rw-r--r-- | src/lib/obexd/obexclient_transfer.c | 275 | ||||
-rw-r--r-- | src/lib/obexd/obexclient_transfer.h | 71 | ||||
-rw-r--r-- | src/lib/obexd/obexmanager.c | 213 | ||||
-rw-r--r-- | src/lib/obexd/obexmanager.h | 67 | ||||
-rw-r--r-- | src/lib/obexd/obexsession.c | 218 | ||||
-rw-r--r-- | src/lib/obexd/obexsession.h | 68 | ||||
-rw-r--r-- | src/lib/obexd/obextransfer.c | 211 | ||||
-rw-r--r-- | src/lib/obexd/obextransfer.h | 67 | ||||
-rw-r--r-- | src/lib/ods-api.h | 40 | ||||
-rw-r--r-- | src/lib/ods/obexmanager.c (renamed from src/lib/obexmanager.c) | 17 | ||||
-rw-r--r-- | src/lib/ods/obexmanager.h (renamed from src/lib/obexmanager.h) | 4 | ||||
-rw-r--r-- | src/lib/ods/obexserver.c (renamed from src/lib/obexserver.c) | 17 | ||||
-rw-r--r-- | src/lib/ods/obexserver.h (renamed from src/lib/obexserver.h) | 2 | ||||
-rw-r--r-- | src/lib/ods/obexserver_session.c (renamed from src/lib/obexserver_session.c) | 21 | ||||
-rw-r--r-- | src/lib/ods/obexserver_session.h (renamed from src/lib/obexserver_session.h) | 2 | ||||
-rw-r--r-- | src/lib/ods/obexsession.c (renamed from src/lib/obexsession.c) | 21 | ||||
-rw-r--r-- | src/lib/ods/obexsession.h (renamed from src/lib/obexsession.h) | 2 |
81 files changed, 4274 insertions, 1955 deletions
diff --git a/contrib/bluez-api-4.66-fixed/network-api.txt b/contrib/bluez-api-4.66-fixed/network-api.txt deleted file mode 100644 index e58d001..0000000 --- a/contrib/bluez-api-4.66-fixed/network-api.txt +++ /dev/null @@ -1,163 +0,0 @@ -BlueZ D-Bus Network API description -*********************************** - -Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> - - -Network hierarchy -================= - -Service org.bluez -Interface org.bluez.Network -Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX - -Methods string Connect(string uuid) - - Connect to the network device and return the network - interface name. Examples of the interface name are - bnep0, bnep1 etc. - - uuid can be either one of "gn", "panu" or "nap" (case - insensitive) or a traditional string representation of - UUID or a hexadecimal number. - - The connection will be closed and network device - released either upon calling Disconnect() or when - the client disappears from the message bus. - - Possible errors: org.bluez.Error.AlreadyConnected - org.bluez.Error.ConnectionAttemptFailed - - void Disconnect() - - Disconnect from the network device. - - To abort a connection attempt in case of errors or - timeouts in the client it is fine to call this method. - - Possible errors: org.bluez.Error.Failed - - dict GetProperties() - - Returns all properties for the interface. See the - properties section for available properties. - -Signals PropertyChanged(string name, variant value) - - This signal indicates a changed value of the given - property. - -Properties boolean Connected [readonly] - - Indicates if the device is connected. - - string Interface [readonly] - - Indicates the network interface name when available. - - string UUID [readonly] - - Indicates the connection role when available. - - -Network Hub hierarchy -================= - -Service org.bluez -Interface org.bluez.NetworkHub -Object path /org/bluez/{hci0,hci1,...} - -Methods dict GetProperties() - - Returns all properties for the GN/PANU/NAP server. See the - properties section for available properties. - - void SetProperty(string name, variant value) - - Changes the value of the specified property. Only - properties that are listed a read-write are changeable. - On success this will emit a PropertyChanged signal. - - Possible Errors: org.bluez.Error.DoesNotExist - org.bluez.Error.InvalidArguments - -Properties string Name [readwrite] - - The Bluetooth network server name. - - boolean Enabled [readwrite] - - Indicates if the server is Enabled/Disabled. - - string Uuid [readonly] - - The Bluetooth network server UUID 128 identification. - - -Network Peer hierarchy -================= - -Service org.bluez -Interface org.bluez.NetworkPeer -Object path /org/bluez/{hci0,hci1,...} - -Methods dict GetProperties() - - Returns all properties for the GN/PANU/NAP server. See the - properties section for available properties. - - void SetProperty(string name, variant value) - - Changes the value of the specified property. Only - properties that are listed a read-write are changeable. - On success this will emit a PropertyChanged signal. - - Possible Errors: org.bluez.Error.DoesNotExist - org.bluez.Error.InvalidArguments - -Properties string Name [readwrite] - - The Bluetooth network server name. - - boolean Enabled [readwrite] - - Indicates if the server is Enabled/Disabled. - - string Uuid [readonly] - - The Bluetooth network server UUID 128 identification. - - -Network Router hierarchy -================= - -Service org.bluez -Interface org.bluez.NetworkRouter -Object path /org/bluez/{hci0,hci1,...} - -Methods dict GetProperties() - - Returns all properties for the GN/PANU/NAP server. See the - properties section for available properties. - - void SetProperty(string name, variant value) - - Changes the value of the specified property. Only - properties that are listed a read-write are changeable. - On success this will emit a PropertyChanged signal. - - Possible Errors: org.bluez.Error.DoesNotExist - org.bluez.Error.InvalidArguments - -Properties string Name [readwrite] - - The Bluetooth network server name. - - boolean Enabled [readwrite] - - Indicates if the server is Enabled/Disabled. - - string Uuid [readonly] - - The Bluetooth network server UUID 128 identification. - diff --git a/contrib/bluez-api-4.66-fixed/adapter-api.txt b/contrib/bluez-api-4.69-fixed/adapter-api.txt index 0653ccd..0653ccd 100644 --- a/contrib/bluez-api-4.66-fixed/adapter-api.txt +++ b/contrib/bluez-api-4.69-fixed/adapter-api.txt diff --git a/contrib/bluez-api-4.66-fixed/agent-api.txt b/contrib/bluez-api-4.69-fixed/agent-api.txt index d8d35c0..d8d35c0 100644 --- a/contrib/bluez-api-4.66-fixed/agent-api.txt +++ b/contrib/bluez-api-4.69-fixed/agent-api.txt diff --git a/contrib/bluez-api-4.66-fixed/agent.xml b/contrib/bluez-api-4.69-fixed/agent.xml index 86e442b..86e442b 100644 --- a/contrib/bluez-api-4.66-fixed/agent.xml +++ b/contrib/bluez-api-4.69-fixed/agent.xml diff --git a/contrib/bluez-api-4.69-fixed/attribute-api.txt b/contrib/bluez-api-4.69-fixed/attribute-api.txt new file mode 100644 index 0000000..ee91f93 --- /dev/null +++ b/contrib/bluez-api-4.69-fixed/attribute-api.txt @@ -0,0 +1,97 @@ +BlueZ D-Bus Attribute API description +************************************* + +Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> + + +Attribute hierarchy +=================== + +Service org.bluez +Interface org.bluez.Service + org.bluez.Characteristic +Object path [prefix]/{hci0}/{service0} + [prefix]/{hci0}/{device0}/{service0}/{characteristic0,...} + [prefix]/{hci0}/{device0}/{service1}/{characteristic0,...} + +Service details +--------------- + +One service object path for every remote SDP record or service in the +attribute database. One service object path for every local SDP record +or service from attribute database. + +Local services are children of the adapter object path. Remote services +are children of the remote device object path. This doesn't solve the +problem where local atttributes can have different instances based on +the remote device. + +In general the idea is to also represent SDP records as services so that +new style application can just use the service interfaces to retrieve the +needed information. That way the usage of SDP and GATT would be mostly +fully transparent and a differentiation becomes unimportant in the future. + +A service consists of some generic service information and a set of +characteristics. All characteristic are presented as object path as well. + +Properties +---------- + string Name (mandatory) + + General name of service + + string Description (optional) + + Description of service + + string UUID (mandatory) + + UUID of service. Service class value for SDP and GATT UUID + for attribute based services. + + array{object} Characteristics + + This list contains the characteristics owned by this specific + service and other characteristics from service includes. That + way no complicated service includes array is needed. + + string UUID + string Name + string Description + struct Format (type, name, exponet etc.) + + array{byte} Value + string Representation (of the binary Value) + + object Service (the original service in case of includes) + + At this point only GetProperties() method call should be + supported for simplicity. Changing characteristics is up + to future support. + + The object path of the characteristics might be split + over multiple service objects, because of includes. + + array[(object, dict)] GetCharacteristics() + + Array of tuples with object path as identifier. An alternativ + is doing dict of dict since the object path is unique and the + order of characteristics is irrelevant. However it might be + good to actually present an order here. + + See Characteristics properties for dictionary details. + + RegisterCharacteristicsWatcher(object path) + + Register a watcher for changes in specific characteristics + to monitor changes. + + A watcher will be registered for this service and will + notifier about any changed characteristics in the service. + This also notifies about any included characteristics. + + Method for the watch objects still need to be defined. + + UnregisterCharacteristicsWatcher(object path) + + Unregister a watcher. diff --git a/contrib/bluez-api-4.66-fixed/audio-api.txt b/contrib/bluez-api-4.69-fixed/audio-api.txt index 80c0b5d..80c0b5d 100644 --- a/contrib/bluez-api-4.66-fixed/audio-api.txt +++ b/contrib/bluez-api-4.69-fixed/audio-api.txt diff --git a/contrib/bluez-api-4.66-fixed/control-api.txt b/contrib/bluez-api-4.69-fixed/control-api.txt index ce9d2bd..ce9d2bd 100644 --- a/contrib/bluez-api-4.66-fixed/control-api.txt +++ b/contrib/bluez-api-4.69-fixed/control-api.txt diff --git a/contrib/bluez-api-4.66-fixed/device-api.txt b/contrib/bluez-api-4.69-fixed/device-api.txt index 551d11a..551d11a 100644 --- a/contrib/bluez-api-4.66-fixed/device-api.txt +++ b/contrib/bluez-api-4.69-fixed/device-api.txt diff --git a/contrib/bluez-api-4.66-fixed/input-api.txt b/contrib/bluez-api-4.69-fixed/input-api.txt index 7c3a4b2..7c3a4b2 100644 --- a/contrib/bluez-api-4.66-fixed/input-api.txt +++ b/contrib/bluez-api-4.69-fixed/input-api.txt diff --git a/contrib/bluez-api-4.66-fixed/manager-api.txt b/contrib/bluez-api-4.69-fixed/manager-api.txt index d2c1caf..d2c1caf 100644 --- a/contrib/bluez-api-4.66-fixed/manager-api.txt +++ b/contrib/bluez-api-4.69-fixed/manager-api.txt diff --git a/contrib/bluez-api-4.69-fixed/network-api.txt b/contrib/bluez-api-4.69-fixed/network-api.txt new file mode 100644 index 0000000..4dd3e58 --- /dev/null +++ b/contrib/bluez-api-4.69-fixed/network-api.txt @@ -0,0 +1,88 @@ +BlueZ D-Bus Network API description +*********************************** + +Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> + + +Network hierarchy +================= + +Service org.bluez +Interface org.bluez.Network +Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX + +Methods string Connect(string uuid) + + Connect to the network device and return the network + interface name. Examples of the interface name are + bnep0, bnep1 etc. + + uuid can be either one of "gn", "panu" or "nap" (case + insensitive) or a traditional string representation of + UUID or a hexadecimal number. + + The connection will be closed and network device + released either upon calling Disconnect() or when + the client disappears from the message bus. + + Possible errors: org.bluez.Error.AlreadyConnected + org.bluez.Error.ConnectionAttemptFailed + + void Disconnect() + + Disconnect from the network device. + + To abort a connection attempt in case of errors or + timeouts in the client it is fine to call this method. + + Possible errors: org.bluez.Error.Failed + + dict GetProperties() + + Returns all properties for the interface. See the + properties section for available properties. + +Signals PropertyChanged(string name, variant value) + + This signal indicates a changed value of the given + property. + +Properties boolean Connected [readonly] + + Indicates if the device is connected. + + string Interface [readonly] + + Indicates the network interface name when available. + + string UUID [readonly] + + Indicates the connection role when available. + + +Network server hierarchy +======================== + +Service org.bluez +Interface org.bluez.NetworkServer +Object path /org/bluez/{hci0,hci1,...} + +Methods void Register(string uuid, string bridge) + + Register server for the provided UUID. Every new + connection to this server will be added the bridge + interface. + + Valid UUIDs are "gn", "panu" or "nap". + + Initially no network server SDP is provided. Only + after this method a SDP record will be available + and the BNEP server will be ready for incoming + connections. + + void Unregister(string uuid) + + Unregister the server for provided UUID. + + All servers will be automatically unregistered when + the calling application terminates. diff --git a/contrib/bluez-api-4.66-fixed/serial-api.txt b/contrib/bluez-api-4.69-fixed/serial-api.txt index 5f9bd5f..5f9bd5f 100644 --- a/contrib/bluez-api-4.66-fixed/serial-api.txt +++ b/contrib/bluez-api-4.69-fixed/serial-api.txt diff --git a/contrib/bluez-api-4.66-fixed/service-api.txt b/contrib/bluez-api-4.69-fixed/service-api.txt index 5c8c7f3..5c8c7f3 100644 --- a/contrib/bluez-api-4.66-fixed/service-api.txt +++ b/contrib/bluez-api-4.69-fixed/service-api.txt diff --git a/contrib/gen-dbus-gobject.pl b/contrib/gen-dbus-gobject.pl index c09c03f..ae66cf5 100755 --- a/contrib/gen-dbus-gobject.pl +++ b/contrib/gen-dbus-gobject.pl @@ -40,7 +40,19 @@ sub parse_doc_api { $n++; s/\s+$//; - die "invalid file format (1)\n" if $n == 1 && $_ !~ /^BlueZ D-Bus \S+ API description$/ && $_ !~ /^obex.*?API description$/i; + if ($n == 1) { + if (/^BlueZ D-Bus \S+ API description$/) { + $data{'dbus_conn'} = 'system_conn'; + } elsif (/^obex.*?API description$/i) { + $data{'dbus_conn'} = 'session_conn'; + } elsif (/^ODS API description$/) { + $data{'dbus_conn'} = 'system_conn'; + } else { + die "invalid file format (1)\n"; + } + + next; + } /^\s*$/ && next; @@ -48,9 +60,11 @@ sub parse_doc_api { my $hierarchy = $1; $section = 'hierarchy'; $hierarchy_n++; + my $dbus_conn = $data{'dbus_conn'}; undef %data if $hierarchy_n == $hierarchy_id; last if $hierarchy_n == $hierarchy_id+1; $data{'hierarchy'} = $hierarchy; + $data{'dbus_conn'} = $dbus_conn; } elsif (/^Service\s*(.+)$/) { my $service = $1; die "invalid file format (2)\n" unless $section eq 'hierarchy'; @@ -150,47 +164,47 @@ my $HEADER = <<EOH; EOH sub get_g_type { - my $bluez_type = shift; + my $obj_type = shift; my $g_type; - $g_type = 'void ' if $bluez_type eq 'void'; - $g_type = 'gchar *' if $bluez_type eq 'object' || $bluez_type eq 'string'; - $g_type = 'GHashTable *' if $bluez_type =~ /^dict/; - $g_type = 'GValue *' if $bluez_type eq 'variant'; - $g_type = 'guint8 ' if $bluez_type eq 'uint8'; - $g_type = 'gboolean ' if $bluez_type eq 'boolean'; - $g_type = 'gint32 ' if $bluez_type eq 'int32'; - $g_type = 'guint32 ' if $bluez_type eq 'uint32'; - $g_type = 'guint64 ' if $bluez_type eq 'uint64'; - $g_type = 'GPtrArray *' if $bluez_type eq 'array{object}' || $bluez_type eq 'array{dict}'; - $g_type = 'gchar **' if $bluez_type eq 'array{string}'; - $g_type = 'guchar ' if $bluez_type eq 'byte'; + $g_type = 'void ' if $obj_type eq 'void'; + $g_type = 'gchar *' if $obj_type eq 'object' || $obj_type eq 'string'; + $g_type = 'GHashTable *' if $obj_type =~ /^dict/; + $g_type = 'GValue *' if $obj_type eq 'variant'; + $g_type = 'guint8 ' if $obj_type eq 'uint8'; + $g_type = 'gboolean ' if $obj_type eq 'boolean'; + $g_type = 'gint32 ' if $obj_type eq 'int32'; + $g_type = 'guint32 ' if $obj_type eq 'uint32'; + $g_type = 'guint64 ' if $obj_type eq 'uint64'; + $g_type = 'GPtrArray *' if $obj_type eq 'array{object}' || $obj_type eq 'array{dict}'; + $g_type = 'gchar **' if $obj_type eq 'array{string}'; + $g_type = 'guchar ' if $obj_type eq 'byte'; - die "unknown bluez type (1): $bluez_type\n" unless defined $g_type; + die "unknown object type (1): $obj_type\n" unless defined $g_type; return $g_type; } sub get_g_type_name { - my $bluez_type = shift; + my $obj_type = shift; my $g_type_name; - $g_type_name = 'DBUS_TYPE_G_OBJECT_PATH' if $bluez_type eq 'object'; - $g_type_name = 'G_TYPE_STRING' if $bluez_type eq 'string'; - $g_type_name = 'G_TYPE_VALUE' if $bluez_type eq 'variant'; - $g_type_name = 'G_TYPE_BOOLEAN' if $bluez_type eq 'boolean'; - $g_type_name = 'G_TYPE_INT' if $bluez_type eq 'int32'; - $g_type_name = 'G_TYPE_UINT' if $bluez_type eq 'uint32'; - $g_type_name = 'G_TYPE_UINT64' if $bluez_type eq 'uint64'; - $g_type_name = 'DBUS_TYPE_G_STRING_VARIANT_HASHTABLE' if $bluez_type eq 'dict'; - $g_type_name = 'DBUS_TYPE_G_UINT_STRING_HASHTABLE' if $bluez_type eq 'dict{u,s}'; - $g_type_name = 'DBUS_TYPE_G_STRING_STRING_HASHTABLE' if $bluez_type eq 'dict{s,s}'; - $g_type_name = 'DBUS_TYPE_G_OBJECT_ARRAY' if $bluez_type eq 'array{object}'; - $g_type_name = 'G_TYPE_STRV' if $bluez_type eq 'array{string}'; - $g_type_name = 'G_TYPE_UCHAR' if $bluez_type eq 'byte'; - $g_type_name = 'DBUS_TYPE_G_HASH_TABLE_ARRAY' if $bluez_type eq 'array{dict}'; + $g_type_name = 'DBUS_TYPE_G_OBJECT_PATH' if $obj_type eq 'object'; + $g_type_name = 'G_TYPE_STRING' if $obj_type eq 'string'; + $g_type_name = 'G_TYPE_VALUE' if $obj_type eq 'variant'; + $g_type_name = 'G_TYPE_BOOLEAN' if $obj_type eq 'boolean'; + $g_type_name = 'G_TYPE_INT' if $obj_type eq 'int32'; + $g_type_name = 'G_TYPE_UINT' if $obj_type eq 'uint32'; + $g_type_name = 'G_TYPE_UINT64' if $obj_type eq 'uint64'; + $g_type_name = 'DBUS_TYPE_G_STRING_VARIANT_HASHTABLE' if $obj_type eq 'dict'; + $g_type_name = 'DBUS_TYPE_G_UINT_STRING_HASHTABLE' if $obj_type eq 'dict{u,s}'; + $g_type_name = 'DBUS_TYPE_G_STRING_STRING_HASHTABLE' if $obj_type eq 'dict{s,s}'; + $g_type_name = 'DBUS_TYPE_G_OBJECT_ARRAY' if $obj_type eq 'array{object}'; + $g_type_name = 'G_TYPE_STRV' if $obj_type eq 'array{string}'; + $g_type_name = 'G_TYPE_UCHAR' if $obj_type eq 'byte'; + $g_type_name = 'DBUS_TYPE_G_HASH_TABLE_ARRAY' if $obj_type eq 'array{dict}'; - die "unknown bluez type (2): $bluez_type\n" unless defined $g_type_name; + die "unknown object type (2): $obj_type\n" unless defined $g_type_name; return $g_type_name; } @@ -217,7 +231,7 @@ sub generate_header { #include <glib-object.h> -{BLUEZ_DBUS_OBJECT_DEFS} +{DBUS_OBJECT_DEFS} /* * Type macros @@ -260,9 +274,9 @@ EOT my $obj_lc = lc join('_', $obj =~ /([A-Z]+[a-z]*)/g); my $obj_uc = uc join('_', $obj =~ /([A-Z]+[a-z]*)/g); - my $bluez_dbus_object_defs = ""; - $bluez_dbus_object_defs .= "#define BLUEZ_DBUS_{\$OBJECT}_PATH \"$node->{'objectPath'}\"\n" if defined $node->{'objectPath'}; - $bluez_dbus_object_defs .= "#define BLUEZ_DBUS_{\$OBJECT}_INTERFACE \"$node->{'intf'}\""; + my $dbus_object_defs = ""; + $dbus_object_defs .= "#define {\$OBJECT}_DBUS_PATH \"$node->{'objectPath'}\"\n" if defined $node->{'objectPath'}; + $dbus_object_defs .= "#define {\$OBJECT}_DBUS_INTERFACE \"$node->{'intf'}\""; my $method_defs = ""; @@ -296,7 +310,7 @@ EOT $method_defs =~ s/\s+$//s; my $output = "$HEADER\n$HEADER_TEMPLATE\n"; - $output =~ s/{BLUEZ_DBUS_OBJECT_DEFS}/$bluez_dbus_object_defs/; + $output =~ s/{DBUS_OBJECT_DEFS}/$dbus_object_defs/; $output =~ s/{METHOD_DEFS}/$method_defs/; $output =~ s/{\$OBJECT}/$obj_uc/g; $output =~ s/{\$Object}/$obj/g; @@ -316,8 +330,9 @@ sub generate_source { #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "{\$object}.h" #define {\$OBJECT}_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), {\$OBJECT}_TYPE, {\$Object}Private)) @@ -423,27 +438,27 @@ static void {\$object}_init({\$Object} *self) {PRIV_ASYNC_CALLS_INIT} {FI_ASYNC_CALLS} - g_assert(conn != NULL); + g_assert({\$conn} != NULL); {IF_INIT} GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, {DBUS_SERVICE_NAME}, BLUEZ_DBUS_{\$OBJECT}_PATH, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name({\$conn}, {DBUS_SERVICE_NAME}, {\$OBJECT}_DBUS_PATH, "org.freedesktop.DBus.Introspectable"); self->priv->introspection_xml = NULL; if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { g_critical("%s", error->message); } g_assert(error == NULL); - gchar *check_intf_regex_str = g_strconcat("<interface name=\\"", BLUEZ_DBUS_{\$OBJECT}_INTERFACE, "\\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\\"", {\$OBJECT}_DBUS_INTERFACE, "\\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \\"%s\\" does not exist in \\"%s\\"", BLUEZ_DBUS_{\$OBJECT}_INTERFACE, BLUEZ_DBUS_{\$OBJECT}_PATH); + g_critical("Interface \\"%s\\" does not exist in \\"%s\\"", {\$OBJECT}_DBUS_INTERFACE, {\$OBJECT}_DBUS_PATH); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, {DBUS_SERVICE_NAME}, BLUEZ_DBUS_{\$OBJECT}_PATH, BLUEZ_DBUS_{\$OBJECT}_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name({\$conn}, {DBUS_SERVICE_NAME}, {\$OBJECT}_DBUS_PATH, {\$OBJECT}_DBUS_INTERFACE); {IF_SIGNALS} /* DBus signals connection */ @@ -468,20 +483,20 @@ static void {\$object}_post_init({\$Object} *self, const gchar *dbus_object_path GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, {DBUS_SERVICE_NAME}, dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name({\$conn}, {DBUS_SERVICE_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_{\$OBJECT}_INTERFACE, "\\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\\"", {\$OBJECT}_DBUS_INTERFACE, "\\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \\"%s\\" does not exist in \\"%s\\"", BLUEZ_DBUS_{\$OBJECT}_INTERFACE, dbus_object_path); + g_critical("Interface \\"%s\\" does not exist in \\"%s\\"", {\$OBJECT}_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, {DBUS_SERVICE_NAME}, dbus_object_path, BLUEZ_DBUS_{\$OBJECT}_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name({\$conn}, {DBUS_SERVICE_NAME}, dbus_object_path, {\$OBJECT}_DBUS_INTERFACE); {IF_SIGNALS} /* DBus signals connection */ @@ -657,35 +672,35 @@ EOT "\t\t\tG_TYPE_NONE, 1, G_TYPE_STRING);\n\n"; } elsif ($arg_t eq 'object_string_string') { $signals_registration .= - "\t\t\tg_cclosure_bluez_marshal_VOID__STRING_STRING_STRING,\n". + "\t\t\tg_cclosure_bt_marshal_VOID__STRING_STRING_STRING,\n". "\t\t\tG_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);\n\n"; } elsif ($arg_t eq 'string_variant') { $signals_registration .= - "\t\t\tg_cclosure_bluez_marshal_VOID__STRING_BOXED,\n". + "\t\t\tg_cclosure_bt_marshal_VOID__STRING_BOXED,\n". "\t\t\tG_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE);\n\n"; } elsif ($arg_t eq 'string_dict') { $signals_registration .= - "\t\t\tg_cclosure_bluez_marshal_VOID__STRING_BOXED,\n". + "\t\t\tg_cclosure_bt_marshal_VOID__STRING_BOXED,\n". "\t\t\tG_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_HASH_TABLE);\n\n"; } elsif ($arg_t eq 'object_boolean') { $signals_registration .= - "\t\t\tg_cclosure_bluez_marshal_VOID__STRING_BOOLEAN,\n". + "\t\t\tg_cclosure_bt_marshal_VOID__STRING_BOOLEAN,\n". "\t\t\tG_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);\n\n"; } elsif ($arg_t eq 'uint64') { $signals_registration .= - "\t\t\tg_cclosure_bluez_marshal_VOID__UINT64,\n". + "\t\t\tg_cclosure_bt_marshal_VOID__UINT64,\n". "\t\t\tG_TYPE_NONE, 1, G_TYPE_UINT64);\n\n"; } elsif ($arg_t eq 'int32_int32') { $signals_registration .= - "\t\t\tg_cclosure_bluez_marshal_VOID__INT_INT,\n". + "\t\t\tg_cclosure_bt_marshal_VOID__INT_INT,\n". "\t\t\tG_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);\n\n"; } elsif ($arg_t eq 'string_string') { $signals_registration .= - "\t\t\tg_cclosure_bluez_marshal_VOID__STRING_STRING,\n". + "\t\t\tg_cclosure_bt_marshal_VOID__STRING_STRING,\n". "\t\t\tG_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);\n\n"; } elsif ($arg_t eq 'string_string_uint64') { $signals_registration .= - "\t\t\tg_cclosure_bluez_marshal_VOID__STRING_STRING_UINT64,\n". + "\t\t\tg_cclosure_bt_marshal_VOID__STRING_STRING_UINT64,\n". "\t\t\tG_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64);\n\n"; } else { die "unknown signal arguments: $arg_t\n"; @@ -956,6 +971,7 @@ EOT $output =~ s/\s+\{IF_ASYNC_CALLS\}.+?\{FI_ASYNC_CALLS\}//gs; } $output =~ s/{DBUS_SERVICE_NAME}/"$node->{'serviceName'}"/g; + $output =~ s/{\$conn}/$node->{'dbus_conn'}/g; $output =~ s/{ENUM_SIGNALS}/$enum_signals/; $output =~ s/{SIGNALS_HANDLERS_DEF}/$signals_handlers_def/; $output =~ s/{SIGNALS_REGISTRATION}/$signals_registration/; diff --git a/contrib/generate-all.sh b/contrib/generate-all.sh deleted file mode 100755 index 1f70e2f..0000000 --- a/contrib/generate-all.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -# BlueZ API - -# adapter-api.txt -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/adapter-api.txt > ../src/lib/bluez/adapter.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/adapter-api.txt > ../src/lib/bluez/adapter.c - -# audio-api.txt -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/audio-api.txt > ../src/lib/bluez/audio.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/audio-api.txt > ../src/lib/bluez/audio.c - -# device-api.txt -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/device-api.txt > ../src/lib/bluez/device.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/device-api.txt > ../src/lib/bluez/device.c - -# input-api.txt -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/input-api.txt > ../src/lib/bluez/input.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/input-api.txt > ../src/lib/bluez/input.c - -# manager-api.txt -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/manager-api.txt > ../src/lib/bluez/manager.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/manager-api.txt > ../src/lib/bluez/manager.c - -# network-api.txt -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/network-api.txt > ../src/lib/bluez/network.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/network-api.txt > ../src/lib/bluez/network.c - -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/network-api.txt 2 > ../src/lib/network_hub.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/network-api.txt 2 > ../src/lib/network_hub.c - -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/network-api.txt 3 > ../src/lib/network_peer.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/network-api.txt 3 > ../src/lib/network_peer.c - -./gen-dbus-gobject.pl -header bluez-api-4.66-fixed/network-api.txt 4 > ../src/lib/network_router.h -./gen-dbus-gobject.pl -source bluez-api-4.66-fixed/network-api.txt 4 > ../src/lib/network_router.c - -# serial-api.txt -./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 - -# ODS (obex-data-server) API - -./gen-dbus-gobject.pl -header obex-data-server-api-0.4.5-fixed.txt > ../src/lib/obexmanager.h -./gen-dbus-gobject.pl -source obex-data-server-api-0.4.5-fixed.txt > ../src/lib/obexmanager.c - -./gen-dbus-gobject.pl -header obex-data-server-api-0.4.5-fixed.txt 2 > ../src/lib/obexserver.h -./gen-dbus-gobject.pl -source obex-data-server-api-0.4.5-fixed.txt 2 > ../src/lib/obexserver.c - -./gen-dbus-gobject.pl -header obex-data-server-api-0.4.5-fixed.txt 3 > ../src/lib/obexsession.h -./gen-dbus-gobject.pl -source obex-data-server-api-0.4.5-fixed.txt 3 > ../src/lib/obexsession.c - -./gen-dbus-gobject.pl -header obex-data-server-api-0.4.5-fixed.txt 4 > ../src/lib/obexserver_session.h -./gen-dbus-gobject.pl -source obex-data-server-api-0.4.5-fixed.txt 4 > ../src/lib/obexserver_session.c - diff --git a/contrib/generate-bluez-gobjects.sh b/contrib/generate-bluez-gobjects.sh new file mode 100755 index 0000000..dcd86ad --- /dev/null +++ b/contrib/generate-bluez-gobjects.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# BlueZ API + +API_VERSION=4.69 + +# adapter-api.txt +./gen-dbus-gobject.pl -header bluez-api-${API_VERSION}-fixed/adapter-api.txt > ../src/lib/bluez/adapter.h +./gen-dbus-gobject.pl -source bluez-api-${API_VERSION}-fixed/adapter-api.txt > ../src/lib/bluez/adapter.c + +# audio-api.txt +./gen-dbus-gobject.pl -header bluez-api-${API_VERSION}-fixed/audio-api.txt > ../src/lib/bluez/audio.h +./gen-dbus-gobject.pl -source bluez-api-${API_VERSION}-fixed/audio-api.txt > ../src/lib/bluez/audio.c + +# device-api.txt +./gen-dbus-gobject.pl -header bluez-api-${API_VERSION}-fixed/device-api.txt > ../src/lib/bluez/device.h +./gen-dbus-gobject.pl -source bluez-api-${API_VERSION}-fixed/device-api.txt > ../src/lib/bluez/device.c + +# input-api.txt +./gen-dbus-gobject.pl -header bluez-api-${API_VERSION}-fixed/input-api.txt > ../src/lib/bluez/input.h +./gen-dbus-gobject.pl -source bluez-api-${API_VERSION}-fixed/input-api.txt > ../src/lib/bluez/input.c + +# manager-api.txt +./gen-dbus-gobject.pl -header bluez-api-${API_VERSION}-fixed/manager-api.txt > ../src/lib/bluez/manager.h +./gen-dbus-gobject.pl -source bluez-api-${API_VERSION}-fixed/manager-api.txt > ../src/lib/bluez/manager.c + +# network-api.txt +./gen-dbus-gobject.pl -header bluez-api-${API_VERSION}-fixed/network-api.txt > ../src/lib/bluez/network.h +./gen-dbus-gobject.pl -source bluez-api-${API_VERSION}-fixed/network-api.txt > ../src/lib/bluez/network.c + +./gen-dbus-gobject.pl -header bluez-api-${API_VERSION}-fixed/network-api.txt 2 > ../src/lib/bluez/network_server.h +./gen-dbus-gobject.pl -source bluez-api-${API_VERSION}-fixed/network-api.txt 2 > ../src/lib/bluez/network_server.c + +# serial-api.txt +./gen-dbus-gobject.pl -header bluez-api-${API_VERSION}-fixed/serial-api.txt > ../src/lib/bluez/serial.h +./gen-dbus-gobject.pl -source bluez-api-${API_VERSION}-fixed/serial-api.txt > ../src/lib/bluez/serial.c + diff --git a/contrib/generate-obexd-gobjects.sh b/contrib/generate-obexd-gobjects.sh new file mode 100755 index 0000000..3ef3f50 --- /dev/null +++ b/contrib/generate-obexd-gobjects.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# OBEXD API + +API_VERSION=0.30 + +# client-api.txt +./gen-dbus-gobject.pl -header obexd-api-${API_VERSION}-fixed/client-api.txt > ../src/lib/obexd/obexclient.h +./gen-dbus-gobject.pl -source obexd-api-${API_VERSION}-fixed/client-api.txt > ../src/lib/obexd/obexclient.c + +./gen-dbus-gobject.pl -header obexd-api-${API_VERSION}-fixed/client-api.txt 2 > ../src/lib/obexd/obexclient_session.h +./gen-dbus-gobject.pl -source obexd-api-${API_VERSION}-fixed/client-api.txt 2 > ../src/lib/obexd/obexclient_session.c + +./gen-dbus-gobject.pl -header obexd-api-${API_VERSION}-fixed/client-api.txt 3 > ../src/lib/obexd/obexclient_file_transfer.h +./gen-dbus-gobject.pl -source obexd-api-${API_VERSION}-fixed/client-api.txt 3 > ../src/lib/obexd/obexclient_file_transfer.c + +./gen-dbus-gobject.pl -header obexd-api-${API_VERSION}-fixed/client-api.txt 6 > ../src/lib/obexd/obexclient_transfer.h +./gen-dbus-gobject.pl -source obexd-api-${API_VERSION}-fixed/client-api.txt 6 > ../src/lib/obexd/obexclient_transfer.c + +# obexd-api.txt +./gen-dbus-gobject.pl -header obexd-api-${API_VERSION}-fixed/obexd-api.txt > ../src/lib/obexd/obexmanager.h +./gen-dbus-gobject.pl -source obexd-api-${API_VERSION}-fixed/obexd-api.txt > ../src/lib/obexd/obexmanager.c + +./gen-dbus-gobject.pl -header obexd-api-${API_VERSION}-fixed/obexd-api.txt 2 > ../src/lib/obexd/obextransfer.h +./gen-dbus-gobject.pl -source obexd-api-${API_VERSION}-fixed/obexd-api.txt 2 > ../src/lib/obexd/obextransfer.c + +./gen-dbus-gobject.pl -header obexd-api-${API_VERSION}-fixed/obexd-api.txt 3 > ../src/lib/obexd/obexsession.h +./gen-dbus-gobject.pl -source obexd-api-${API_VERSION}-fixed/obexd-api.txt 3 > ../src/lib/obexd/obexsession.c + diff --git a/contrib/generate-ods-gobjects.sh b/contrib/generate-ods-gobjects.sh new file mode 100755 index 0000000..28c6d3b --- /dev/null +++ b/contrib/generate-ods-gobjects.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# ODS (obex-data-server) API + +API_VERSION=0.4.5 + +./gen-dbus-gobject.pl -header ods-api-${API_VERSION}-fixed/obex-data-server-api-${API_VERSION}-fixed.txt > ../src/lib/ods/obexmanager.h +./gen-dbus-gobject.pl -source ods-api-${API_VERSION}-fixed/obex-data-server-api-${API_VERSION}-fixed.txt > ../src/lib/ods/obexmanager.c + +./gen-dbus-gobject.pl -header ods-api-${API_VERSION}-fixed/obex-data-server-api-${API_VERSION}-fixed.txt 2 > ../src/lib/ods/obexserver.h +./gen-dbus-gobject.pl -source ods-api-${API_VERSION}-fixed/obex-data-server-api-${API_VERSION}-fixed.txt 2 > ../src/lib/ods/obexserver.c + +./gen-dbus-gobject.pl -header ods-api-${API_VERSION}-fixed/obex-data-server-api-${API_VERSION}-fixed.txt 3 > ../src/lib/ods/obexsession.h +./gen-dbus-gobject.pl -source ods-api-${API_VERSION}-fixed/obex-data-server-api-${API_VERSION}-fixed.txt 3 > ../src/lib/ods/obexsession.c + +./gen-dbus-gobject.pl -header ods-api-${API_VERSION}-fixed/obex-data-server-api-${API_VERSION}-fixed.txt 4 > ../src/lib/ods/obexserver_session.h +./gen-dbus-gobject.pl -source ods-api-${API_VERSION}-fixed/obex-data-server-api-${API_VERSION}-fixed.txt 4 > ../src/lib/ods/obexserver_session.c + diff --git a/contrib/obexd-api-0.30-fixed/agent-api.txt b/contrib/obexd-api-0.30-fixed/agent-api.txt new file mode 100644 index 0000000..e3dbc78 --- /dev/null +++ b/contrib/obexd-api-0.30-fixed/agent-api.txt @@ -0,0 +1,30 @@ +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.30-fixed/client-api.txt b/contrib/obexd-api-0.30-fixed/client-api.txt new file mode 100644 index 0000000..fa8a36d --- /dev/null +++ b/contrib/obexd-api-0.30-fixed/client-api.txt @@ -0,0 +1,329 @@ +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() + + 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) + + 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.30-fixed/obexd-api.txt b/contrib/obexd-api-0.30-fixed/obexd-api.txt new file mode 100644 index 0000000..6cfaac7 --- /dev/null +++ b/contrib/obexd-api-0.30-fixed/obexd-api.txt @@ -0,0 +1,90 @@ +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/contrib/obex-data-server-api-0.4.5-fixed.txt b/contrib/ods-api-0.4.5-fixed/obex-data-server-api-0.4.5-fixed.txt index ec2731b..9555770 100644 --- a/contrib/obex-data-server-api-0.4.5-fixed.txt +++ b/contrib/ods-api-0.4.5-fixed/obex-data-server-api-0.4.5-fixed.txt @@ -1,4 +1,4 @@ -OBEX API description +ODS API description ******************** Manager hierarchy diff --git a/src/Makefile.am b/src/Makefile.am index 81878a2..5ba6fed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,9 +1,9 @@ -AM_CPPFLAGS = $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) $(GIO_CFLAGS) $(DBUS_GLIB_CFLAGS) -AM_LDFLAGS = $(DBUS_LIBS) $(GLIB_LIBS) $(GOBJECT_LIBS) $(GIO_LIBS) $(DBUS_GLIB_LIBS) +AM_CPPFLAGS = $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS) +AM_LDFLAGS = $(DBUS_LIBS) $(GLIB_LIBS) $(DBUS_GLIB_LIBS) +# Marshallers generation BUILT_SOURCES = lib/marshallers.c lib/marshallers.h - -GENMARSHAL_FLAGS = --prefix="g_cclosure_bluez_marshal" --g-fatal-warnings +GENMARSHAL_FLAGS = --prefix="g_cclosure_bt_marshal" --g-fatal-warnings lib/marshallers.h: lib/marshallers.list glib-genmarshal $(GENMARSHAL_FLAGS) --header lib/marshallers.list > lib/marshallers.h @@ -11,38 +11,46 @@ lib/marshallers.h: lib/marshallers.list lib/marshallers.c: lib/marshallers.list glib-genmarshal $(GENMARSHAL_FLAGS) --body lib/marshallers.list > lib/marshallers.c +bluez_sources = lib/bluez/adapter.c lib/bluez/adapter.h \ + lib/bluez/agent.c lib/bluez/agent.h \ + lib/bluez/audio.c lib/bluez/audio.h \ + lib/bluez/device.c lib/bluez/device.h \ + lib/bluez/input.c lib/bluez/input.h \ + lib/bluez/manager.c lib/bluez/manager.h \ + lib/bluez/network.c lib/bluez/network.h \ + lib/bluez/network_server.c lib/bluez/network_server.h \ + lib/bluez/serial.c lib/bluez/serial.h + +obexd_sources = lib/obexd/obexagent.c lib/obexd/obexagent.h \ + lib/obexd/obexclient.c lib/obexd/obexclient.h \ + lib/obexd/obexclient_file_transfer.c lib/obexd/obexclient_file_transfer.h \ + lib/obexd/obexclient_session.c lib/obexd/obexclient_session.h \ + lib/obexd/obexclient_transfer.c lib/obexd/obexclient_transfer.h \ + lib/obexd/obexmanager.c lib/obexd/obexmanager.h \ + lib/obexd/obexsession.c lib/obexd/obexsession.h \ + lib/obexd/obextransfer.c lib/obexd/obextransfer.h + +ods_sources = lib/ods/obexmanager.c lib/ods/obexmanager.h \ + lib/ods/obexserver.c lib/ods/obexserver.h \ + lib/ods/obexserver_session.c lib/ods/obexserver_session.h \ + lib/ods/obexsession.c lib/ods/obexsession.h + lib_sources = lib/marshallers.c lib/marshallers.h \ lib/dbus-common.c lib/dbus-common.h \ lib/helpers.c lib/helpers.h \ - lib/bluez-dbus.h \ - lib/adapter.c lib/adapter.h \ - lib/agent.c lib/agent.h \ - lib/audio.c lib/audio.h \ - lib/device.c lib/device.h \ - lib/input.c lib/input.h \ - lib/manager.c lib/manager.h \ - lib/network.c lib/network.h \ - lib/network_hub.c lib/network_hub.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 - -obex_sources = lib/obexmanager.c lib/obexmanager.h \ - lib/obexsession.c lib/obexsession.h \ - lib/obexserver.c lib/obexserver.h \ - lib/obexserver_session.c lib/obexserver_session.h + lib/sdp.c lib/sdp.h \ + lib/bluez-api.h lib/obexd-api.h lib/ods-api.h bin_PROGRAMS = bt-monitor bt-adapter bt-agent bt-device bt-input bt-audio bt-network bt-serial bt-obex -bt_monitor_SOURCES = $(lib_sources) bt-monitor.c -bt_adapter_SOURCES = ${lib_sources} bt-adapter.c -bt_agent_SOURCES = $(lib_sources) bt-agent.c -bt_device_SOURCES = $(lib_sources) bt-device.c -bt_input_SOURCES = $(lib_sources) bt-input.c -bt_audio_SOURCES = $(lib_sources) bt-audio.c -bt_network_SOURCES = $(lib_sources) bt-network.c -bt_serial_SOURCES = $(lib_sources) bt-serial.c -bt_obex_SOURCES = $(lib_sources) $(obex_sources) bt-obex.c - -CLEANFILES = Makefile.in lib/marshallers.c lib/marshallers.h - +bt_monitor_SOURCES = $(lib_sources) $(bluez_sources) bt-monitor.c +bt_adapter_SOURCES = ${lib_sources} $(bluez_sources) bt-adapter.c +bt_agent_SOURCES = $(lib_sources) $(bluez_sources) bt-agent.c +bt_device_SOURCES = $(lib_sources) $(bluez_sources) bt-device.c +bt_input_SOURCES = $(lib_sources) $(bluez_sources) bt-input.c +bt_audio_SOURCES = $(lib_sources) $(bluez_sources) bt-audio.c +bt_network_SOURCES = $(lib_sources) $(bluez_sources) bt-network.c +bt_serial_SOURCES = $(lib_sources) $(bluez_sources) bt-serial.c +bt_obex_SOURCES = $(lib_sources) $(bluez_sources) $(ods_sources) bt-obex.c + +CLEANFILES = Makefile.in \ + lib/marshallers.c lib/marshallers.h diff --git a/src/lib/bluez-dbus.h b/src/lib/bluez-api.h index 47f46e2..56ecae6 100644 --- a/src/lib/bluez-dbus.h +++ b/src/lib/bluez-api.h @@ -21,37 +21,25 @@ * */ -#ifndef __BLUEZ_DBUS_H -#define __BLUEZ_DBUS_H +#ifndef __BLUEZ_API_H +#define __BLUEZ_API_H /* Global includes */ #include <glib.h> #include <dbus/dbus-glib.h> -/* Local includes */ -#include "dbus-common.h" -#include "helpers.h" -#include "marshallers.h" -#include "sdp.h" +#define BLUEZ_DBUS_NAME "org.bluez" -/* Bluez DBus Interfaces */ -#include "adapter.h" -#include "agent.h" -#include "audio.h" -#include "device.h" -#include "input.h" -#include "manager.h" -#include "network.h" -#include "network_hub.h" -#include "network_peer.h" -#include "network_router.h" -#include "serial.h" +/* BlueZ DBus API */ +#include "bluez/adapter.h" +#include "bluez/agent.h" +#include "bluez/audio.h" +#include "bluez/device.h" +#include "bluez/input.h" +#include "bluez/manager.h" +#include "bluez/network.h" +#include "bluez/network_server.h" +#include "bluez/serial.h" -/* OBEX DBus Interfaces */ -#include "obexmanager.h" -#include "obexsession.h" -#include "obexserver.h" -#include "obexserver_session.h" - -#endif /* __BLUEZ_DBUS_H */ +#endif /* __BLUEZ_API_H */ diff --git a/src/lib/adapter.c b/src/lib/bluez/adapter.c index 2f7042f..d0140aa 100644 --- a/src/lib/adapter.c +++ b/src/lib/bluez/adapter.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "adapter.h" #define ADAPTER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), ADAPTER_TYPE, AdapterPrivate)) @@ -207,7 +208,7 @@ static void adapter_class_init(AdapterClass *klass) 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_BOXED, + g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_HASH_TABLE); signals[DEVICE_REMOVED] = g_signal_new("DeviceRemoved", @@ -221,7 +222,7 @@ static void adapter_class_init(AdapterClass *klass) 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_BOXED, + g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); } @@ -232,7 +233,7 @@ static void adapter_init(Adapter *self) /* Async calls init */ self->priv->create_paired_device_call = NULL; - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void adapter_post_init(Adapter *self, const gchar *dbus_object_path) @@ -244,20 +245,20 @@ static void adapter_post_init(Adapter *self, const gchar *dbus_object_path) GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", 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_ADAPTER_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", ADAPTER_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_ADAPTER_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", ADAPTER_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, BLUEZ_DBUS_ADAPTER_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", dbus_object_path, ADAPTER_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/adapter.h b/src/lib/bluez/adapter.h index 2d4a82c..d94675b 100644 --- a/src/lib/adapter.h +++ b/src/lib/bluez/adapter.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_ADAPTER_INTERFACE "org.bluez.Adapter" +#define ADAPTER_DBUS_INTERFACE "org.bluez.Adapter" /* * Type macros diff --git a/src/lib/agent.c b/src/lib/bluez/agent.c index b18f316..e150521 100644 --- a/src/lib/agent.c +++ b/src/lib/bluez/agent.c @@ -30,8 +30,9 @@ #include <string.h> #include <glib.h> -#include "dbus-common.h" -#include "helpers.h" +#include "../dbus-common.h" +#include "../helpers.h" + #include "device.h" #include "agent.h" @@ -56,7 +57,7 @@ static void agent_dispose(GObject *gobject) { Agent *self = AGENT(gobject); - dbus_g_connection_unregister_g_object(conn, gobject); + dbus_g_connection_unregister_g_object(system_conn, gobject); /* Proxy free */ //g_object_unref(self->priv->proxy); @@ -88,7 +89,7 @@ static void agent_init(Agent *self) g_assert(conn != NULL); - dbus_g_connection_register_g_object(conn, DBUS_AGENT_PATH, G_OBJECT(self)); + dbus_g_connection_register_g_object(system_conn, AGENT_DBUS_PATH, G_OBJECT(self)); g_print("Agent registered\n"); } diff --git a/src/lib/agent.h b/src/lib/bluez/agent.h index 7fbad37..10f4944 100644 --- a/src/lib/agent.h +++ b/src/lib/bluez/agent.h @@ -27,9 +27,9 @@ #include <glib-object.h> #include <dbus/dbus-glib.h> -#include "marshallers.h" +#include "../marshallers.h" -#define DBUS_AGENT_PATH "/Agent" +#define AGENT_DBUS_PATH "/Agent" /* * Type macros @@ -73,14 +73,14 @@ gboolean agent_cancel(Agent *self, GError **error); /* Glue code */ static const DBusGMethodInfo dbus_glib_agent_methods[] = { - { (GCallback) agent_release, g_cclosure_bluez_marshal_BOOLEAN__POINTER, 0}, - { (GCallback) agent_request_pin_code, g_cclosure_bluez_marshal_BOOLEAN__BOXED_POINTER_POINTER, 27}, - { (GCallback) agent_request_passkey, g_cclosure_bluez_marshal_BOOLEAN__BOXED_POINTER_POINTER, 85}, - { (GCallback) agent_display_passkey, g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT_UCHAR_POINTER, 143}, - { (GCallback) agent_request_confirmation, g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT_POINTER, 212}, - { (GCallback) agent_authorize, g_cclosure_bluez_marshal_BOOLEAN__BOXED_STRING_POINTER, 274}, - { (GCallback) agent_confirm_mode_change, g_cclosure_bluez_marshal_BOOLEAN__STRING_POINTER, 323}, - { (GCallback) agent_cancel, g_cclosure_bluez_marshal_BOOLEAN__POINTER, 369}, + { (GCallback) agent_release, g_cclosure_bt_marshal_BOOLEAN__POINTER, 0}, + { (GCallback) agent_request_pin_code, g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER_POINTER, 27}, + { (GCallback) agent_request_passkey, g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER_POINTER, 85}, + { (GCallback) agent_display_passkey, g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT_UCHAR_POINTER, 143}, + { (GCallback) agent_request_confirmation, g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT_POINTER, 212}, + { (GCallback) agent_authorize, g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_POINTER, 274}, + { (GCallback) agent_confirm_mode_change, g_cclosure_bt_marshal_BOOLEAN__STRING_POINTER, 323}, + { (GCallback) agent_cancel, g_cclosure_bt_marshal_BOOLEAN__POINTER, 369}, }; static const DBusGObjectInfo dbus_glib_agent_object_info = { diff --git a/src/lib/audio.c b/src/lib/bluez/audio.c index 602904a..d4abcbf 100644 --- a/src/lib/audio.c +++ b/src/lib/bluez/audio.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "audio.h" #define AUDIO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), AUDIO_TYPE, AudioPrivate)) @@ -115,7 +116,7 @@ static void audio_class_init(AudioClass *klass) 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_BOXED, + g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); } @@ -123,7 +124,7 @@ static void audio_init(Audio *self) { self->priv = AUDIO_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void audio_post_init(Audio *self, const gchar *dbus_object_path) @@ -135,20 +136,20 @@ static void audio_post_init(Audio *self, const gchar *dbus_object_path) GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", 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_AUDIO_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", AUDIO_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_AUDIO_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", AUDIO_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, BLUEZ_DBUS_AUDIO_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", dbus_object_path, AUDIO_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/audio.h b/src/lib/bluez/audio.h index f5e4da0..6d801f2 100644 --- a/src/lib/audio.h +++ b/src/lib/bluez/audio.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_AUDIO_INTERFACE "org.bluez.Audio" +#define AUDIO_DBUS_INTERFACE "org.bluez.Audio" /* * Type macros diff --git a/src/lib/device.c b/src/lib/bluez/device.c index fdc9920..12c9017 100644 --- a/src/lib/device.c +++ b/src/lib/bluez/device.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "device.h" #define DEVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), DEVICE_TYPE, DevicePrivate)) @@ -223,7 +224,7 @@ static void device_class_init(DeviceClass *klass) 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_BOXED, + g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); } @@ -231,7 +232,7 @@ static void device_init(Device *self) { self->priv = DEVICE_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void device_post_init(Device *self, const gchar *dbus_object_path) @@ -243,20 +244,20 @@ static void device_post_init(Device *self, const gchar *dbus_object_path) GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", 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_DEVICE_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", DEVICE_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_DEVICE_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", DEVICE_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, BLUEZ_DBUS_DEVICE_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", dbus_object_path, DEVICE_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/device.h b/src/lib/bluez/device.h index f689bdd..b13e750 100644 --- a/src/lib/device.h +++ b/src/lib/bluez/device.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_DEVICE_INTERFACE "org.bluez.Device" +#define DEVICE_DBUS_INTERFACE "org.bluez.Device" /* * Type macros diff --git a/src/lib/input.c b/src/lib/bluez/input.c index 3ec39bf..cff4b71 100644 --- a/src/lib/input.c +++ b/src/lib/bluez/input.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "input.h" #define INPUT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), INPUT_TYPE, InputPrivate)) @@ -115,7 +116,7 @@ static void input_class_init(InputClass *klass) 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_BOXED, + g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); } @@ -123,7 +124,7 @@ static void input_init(Input *self) { self->priv = INPUT_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void input_post_init(Input *self, const gchar *dbus_object_path) @@ -135,20 +136,20 @@ static void input_post_init(Input *self, const gchar *dbus_object_path) GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", 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_INPUT_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", INPUT_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_INPUT_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", INPUT_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, BLUEZ_DBUS_INPUT_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", dbus_object_path, INPUT_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/input.h b/src/lib/bluez/input.h index 0dd7b17..7bf2b86 100644 --- a/src/lib/input.h +++ b/src/lib/bluez/input.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_INPUT_INTERFACE "org.bluez.Input" +#define INPUT_DBUS_INTERFACE "org.bluez.Input" /* * Type macros diff --git a/src/lib/manager.c b/src/lib/bluez/manager.c index 523d133..df50ca3 100644 --- a/src/lib/manager.c +++ b/src/lib/bluez/manager.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "manager.h" #define MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), MANAGER_TYPE, ManagerPrivate)) @@ -140,7 +141,7 @@ static void manager_class_init(ManagerClass *klass) 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_BOXED, + g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); } @@ -148,26 +149,26 @@ static void manager_init(Manager *self) { self->priv = MANAGER_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", BLUEZ_DBUS_MANAGER_PATH, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", MANAGER_DBUS_PATH, "org.freedesktop.DBus.Introspectable"); self->priv->introspection_xml = NULL; if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { g_critical("%s", error->message); } g_assert(error == NULL); - gchar *check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_MANAGER_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", MANAGER_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_MANAGER_INTERFACE, BLUEZ_DBUS_MANAGER_PATH); + g_critical("Interface \"%s\" does not exist in \"%s\"", MANAGER_DBUS_INTERFACE, MANAGER_DBUS_PATH); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", BLUEZ_DBUS_MANAGER_PATH, BLUEZ_DBUS_MANAGER_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", MANAGER_DBUS_PATH, MANAGER_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/manager.h b/src/lib/bluez/manager.h index 770fd5e..66ab2b6 100644 --- a/src/lib/manager.h +++ b/src/lib/bluez/manager.h @@ -26,8 +26,8 @@ #include <glib-object.h> -#define BLUEZ_DBUS_MANAGER_PATH "/" -#define BLUEZ_DBUS_MANAGER_INTERFACE "org.bluez.Manager" +#define MANAGER_DBUS_PATH "/" +#define MANAGER_DBUS_INTERFACE "org.bluez.Manager" /* * Type macros diff --git a/src/lib/network.c b/src/lib/bluez/network.c index ce8dd0e..b6e27e6 100644 --- a/src/lib/network.c +++ b/src/lib/bluez/network.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "network.h" #define NETWORK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), NETWORK_TYPE, NetworkPrivate)) @@ -128,7 +129,7 @@ static void network_class_init(NetworkClass *klass) 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_BOXED, + g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); } @@ -136,7 +137,7 @@ static void network_init(Network *self) { self->priv = NETWORK_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void network_post_init(Network *self, const gchar *dbus_object_path) @@ -148,20 +149,20 @@ static void network_post_init(Network *self, const gchar *dbus_object_path) GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", 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_NETWORK_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", NETWORK_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_NETWORK_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", NETWORK_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, BLUEZ_DBUS_NETWORK_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", dbus_object_path, NETWORK_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/network.h b/src/lib/bluez/network.h index b0af8f2..ddeee5b 100644 --- a/src/lib/network.h +++ b/src/lib/bluez/network.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_NETWORK_INTERFACE "org.bluez.Network" +#define NETWORK_DBUS_INTERFACE "org.bluez.Network" /* * Type macros diff --git a/src/lib/bluez/network_server.c b/src/lib/bluez/network_server.c new file mode 100644 index 0000000..cccecd3 --- /dev/null +++ b/src/lib/bluez/network_server.c @@ -0,0 +1,184 @@ +/* + * + * 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 "network_server.h" + +#define NETWORK_SERVER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), NETWORK_SERVER_TYPE, NetworkServerPrivate)) + +struct _NetworkServerPrivate { + DBusGProxy *dbus_g_proxy; + + /* Introspection data */ + DBusGProxy *introspection_g_proxy; + gchar *introspection_xml; +}; + +G_DEFINE_TYPE(NetworkServer, network_server, G_TYPE_OBJECT); + +enum { + PROP_0, + + PROP_DBUS_OBJECT_PATH /* readwrite, construct only */ +}; + +static void _network_server_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); +static void _network_server_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); + +static void network_server_dispose(GObject *gobject) +{ + NetworkServer *self = NETWORK_SERVER(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(network_server_parent_class)->dispose(gobject); +} + +static void network_server_class_init(NetworkServerClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->dispose = network_server_dispose; + + g_type_class_add_private(klass, sizeof(NetworkServerPrivate)); + + /* Properties registration */ + GParamSpec *pspec; + + gobject_class->get_property = _network_server_get_property; + gobject_class->set_property = _network_server_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 network_server_init(NetworkServer *self) +{ + self->priv = NETWORK_SERVER_GET_PRIVATE(self); + + g_assert(system_conn != NULL); +} + +static void network_server_post_init(NetworkServer *self, const gchar *dbus_object_path) +{ + g_assert(dbus_object_path != NULL); + g_assert(strlen(dbus_object_path) > 0); + g_assert(self->priv->dbus_g_proxy == NULL); + + GError *error = NULL; + + /* Getting introspection XML */ + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", 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=\"", NETWORK_SERVER_DBUS_INTERFACE, "\">", NULL); + if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { + g_critical("Interface \"%s\" does not exist in \"%s\"", NETWORK_SERVER_DBUS_INTERFACE, dbus_object_path); + g_assert(FALSE); + } + g_free(check_intf_regex_str); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", dbus_object_path, NETWORK_SERVER_DBUS_INTERFACE); +} + +static void _network_server_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + NetworkServer *self = NETWORK_SERVER(object); + + switch (property_id) { + case PROP_DBUS_OBJECT_PATH: + g_value_set_string(value, network_server_get_dbus_object_path(self)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + break; + } +} + +static void _network_server_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + NetworkServer *self = NETWORK_SERVER(object); + GError *error = NULL; + + switch (property_id) { + case PROP_DBUS_OBJECT_PATH: + network_server_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 Register(string uuid, string bridge) */ +void network_server_register(NetworkServer *self, const gchar *uuid, const gchar *bridge, GError **error) +{ + g_assert(NETWORK_SERVER_IS(self)); + + dbus_g_proxy_call(self->priv->dbus_g_proxy, "Register", error, G_TYPE_STRING, uuid, G_TYPE_STRING, bridge, G_TYPE_INVALID, G_TYPE_INVALID); +} + +/* void Unregister(string uuid) */ +void network_server_unregister(NetworkServer *self, const gchar *uuid, GError **error) +{ + g_assert(NETWORK_SERVER_IS(self)); + + dbus_g_proxy_call(self->priv->dbus_g_proxy, "Unregister", error, G_TYPE_STRING, uuid, G_TYPE_INVALID, G_TYPE_INVALID); +} + +/* Properties access methods */ +const gchar *network_server_get_dbus_object_path(NetworkServer *self) +{ + g_assert(NETWORK_SERVER_IS(self)); + + return dbus_g_proxy_get_path(self->priv->dbus_g_proxy); +} + diff --git a/src/lib/bluez/network_server.h b/src/lib/bluez/network_server.h new file mode 100644 index 0000000..be2260f --- /dev/null +++ b/src/lib/bluez/network_server.h @@ -0,0 +1,68 @@ +/* + * + * 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 __NETWORK_SERVER_H +#define __NETWORK_SERVER_H + +#include <glib-object.h> + +#define NETWORK_SERVER_DBUS_INTERFACE "org.bluez.NetworkServer" + +/* + * Type macros + */ +#define NETWORK_SERVER_TYPE (network_server_get_type()) +#define NETWORK_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NETWORK_SERVER_TYPE, NetworkServer)) +#define NETWORK_SERVER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NETWORK_SERVER_TYPE)) +#define NETWORK_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NETWORK_SERVER_TYPE, NetworkServerClass)) +#define NETWORK_SERVER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NETWORK_SERVER_TYPE)) +#define NETWORK_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NETWORK_SERVER_TYPE, NetworkServerClass)) + +typedef struct _NetworkServer NetworkServer; +typedef struct _NetworkServerClass NetworkServerClass; +typedef struct _NetworkServerPrivate NetworkServerPrivate; + +struct _NetworkServer { + GObject parent_instance; + + /*< private >*/ + NetworkServerPrivate *priv; +}; + +struct _NetworkServerClass { + GObjectClass parent_class; +}; + +/* used by NETWORK_SERVER_TYPE */ +GType network_server_get_type(void) G_GNUC_CONST; + +/* + * Method definitions + */ +void network_server_register(NetworkServer *self, const gchar *uuid, const gchar *bridge, GError **error); +void network_server_unregister(NetworkServer *self, const gchar *uuid, GError **error); + +const gchar *network_server_get_dbus_object_path(NetworkServer *self); + +#endif /* __NETWORK_SERVER_H */ + diff --git a/src/lib/serial.c b/src/lib/bluez/serial.c index 747a15d..7cab666 100644 --- a/src/lib/serial.c +++ b/src/lib/bluez/serial.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "serial.h" #define SERIAL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), SERIAL_TYPE, SerialPrivate)) @@ -91,7 +92,7 @@ static void serial_init(Serial *self) { self->priv = SERIAL_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void serial_post_init(Serial *self, const gchar *dbus_object_path) @@ -103,20 +104,20 @@ static void serial_post_init(Serial *self, const gchar *dbus_object_path) GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", 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_SERIAL_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", SERIAL_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_SERIAL_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", SERIAL_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dbus_object_path, BLUEZ_DBUS_SERIAL_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.bluez", dbus_object_path, SERIAL_DBUS_INTERFACE); } static void _serial_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) diff --git a/src/lib/serial.h b/src/lib/bluez/serial.h index 97b071b..d9f850b 100644 --- a/src/lib/serial.h +++ b/src/lib/bluez/serial.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_SERIAL_INTERFACE "org.bluez.Serial" +#define SERIAL_DBUS_INTERFACE "org.bluez.Serial" /* * Type macros diff --git a/src/lib/dbus-common.c b/src/lib/dbus-common.c index f80ea11..1951131 100644 --- a/src/lib/dbus-common.c +++ b/src/lib/dbus-common.c @@ -25,35 +25,60 @@ #include <config.h> #endif -#include "marshallers.h" -#include "agent.h" +#include "bluez-api.h" +#include "obexd-api.h" +#include "ods-api.h" + #include "dbus-common.h" -DBusGConnection *conn = NULL; +DBusGConnection *session_conn = NULL; +DBusGConnection *system_conn = NULL; -gboolean dbus_connect(GError **error) +void dbus_init() { - conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, error); - if (!conn) { - return FALSE; - } - /* Marshallers registration * Used for signals */ - dbus_g_object_register_marshaller(g_cclosure_bluez_marshal_VOID__UINT64, G_TYPE_NONE, G_TYPE_UINT64, G_TYPE_INVALID); - dbus_g_object_register_marshaller(g_cclosure_bluez_marshal_VOID__STRING_BOXED, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); - dbus_g_object_register_marshaller(g_cclosure_bluez_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_object_register_marshaller(g_cclosure_bluez_marshal_VOID__STRING_STRING_UINT64, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_INVALID); - dbus_g_object_register_marshaller(g_cclosure_bluez_marshal_VOID__BOXED_STRING_STRING, G_TYPE_NONE, G_TYPE_VALUE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__STRING_BOXED, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__INT_INT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID); + dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__STRING_BOOLEAN, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID); + dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__UINT64, G_TYPE_NONE, G_TYPE_UINT64, G_TYPE_INVALID); + dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_INVALID); + dbus_g_object_register_marshaller(g_cclosure_bt_marshal_VOID__BOXED_STRING_STRING, G_TYPE_NONE, G_TYPE_VALUE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - /* Agent installation */ + /* Agents installation */ dbus_g_object_type_install_info(AGENT_TYPE, &dbus_glib_agent_object_info); + dbus_g_object_type_install_info(OBEXAGENT_TYPE, &dbus_glib_obexagent_object_info); +} + +gboolean dbus_session_connect(GError **error) +{ + session_conn = dbus_g_bus_get(DBUS_BUS_SESSION, error); + if (!session_conn) { + return FALSE; + } + + return TRUE; +} + +void dbus_session_disconnect() +{ + dbus_g_connection_unref(session_conn); +} + +gboolean dbus_system_connect(GError **error) +{ + system_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, error); + if (!system_conn) { + return FALSE; + } return TRUE; } -void dbus_disconnect() +void dbus_system_disconnect() { - dbus_g_connection_unref(conn); + dbus_g_connection_unref(system_conn); } + diff --git a/src/lib/dbus-common.h b/src/lib/dbus-common.h index c6a38be..a6d979f 100644 --- a/src/lib/dbus-common.h +++ b/src/lib/dbus-common.h @@ -27,16 +27,17 @@ #include <glib.h> #include <dbus/dbus-glib.h> -#define BLUEZ_DBUS_NAME "org.bluez" -#define OBEX_DBUS_NAME "org.openobex" - #define DBUS_TYPE_G_STRING_VARIANT_HASHTABLE (dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) #define DBUS_TYPE_G_UINT_STRING_HASHTABLE (dbus_g_type_get_map("GHashTable", G_TYPE_UINT, G_TYPE_STRING)) #define DBUS_TYPE_G_HASH_TABLE_ARRAY (dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_STRING_VARIANT_HASHTABLE)) -extern DBusGConnection *conn; +extern DBusGConnection *session_conn; +extern DBusGConnection *system_conn; -gboolean dbus_connect(GError **error); -void dbus_disconnect(); +void dbus_init(); +gboolean dbus_session_connect(GError **error); +void dbus_session_disconnect(); +gboolean dbus_system_connect(GError **error); +void dbus_system_disconnect(); #endif /* __DBUS_COMMON_H */ diff --git a/src/lib/helpers.c b/src/lib/helpers.c index 8dd2a41..a310a97 100644 --- a/src/lib/helpers.c +++ b/src/lib/helpers.c @@ -30,9 +30,10 @@ #include <string.h> #include "dbus-common.h" -#include "manager.h" #include "helpers.h" +#include "bluez-api.h" + /* UUID Name lookup table */ typedef struct { gchar *uuid; diff --git a/src/lib/helpers.h b/src/lib/helpers.h index c7d7c95..5e1c573 100644 --- a/src/lib/helpers.h +++ b/src/lib/helpers.h @@ -27,22 +27,9 @@ #include <stdio.h> #include <glib.h> -/* Bluez DBus Interfaces */ -#include "adapter.h" -#include "device.h" -#include "audio.h" -#include "input.h" -#include "network.h" -#include "network_hub.h" -#include "network_peer.h" -#include "network_router.h" -#include "serial.h" - -/* OBEX DBus Interfaces */ -#include "obexmanager.h" -#include "obexsession.h" -#include "obexserver.h" -#include "obexserver_session.h" +#include "bluez-api.h" +#include "obexd-api.h" +#include "ods-api.h" enum { DEVICE_INTF, diff --git a/src/lib/marshallers.c b/src/lib/marshallers.c index 559fa61..4fecca4 100644 --- a/src/lib/marshallers.c +++ b/src/lib/marshallers.c @@ -47,49 +47,14 @@ #endif /* !G_ENABLE_DEBUG */ -/* VOID:UINT64 (lib/marshallers.list:1) */ -void -g_cclosure_bluez_marshal_VOID__UINT64 (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) -{ - typedef void (*GMarshalFunc_VOID__UINT64) (gpointer data1, - guint64 arg_1, - gpointer data2); - register GMarshalFunc_VOID__UINT64 callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - - g_return_if_fail (n_param_values == 2); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_VOID__UINT64) (marshal_data ? marshal_data : cc->callback); - - callback (data1, - g_marshal_value_peek_uint64 (param_values + 1), - data2); -} - /* VOID:STRING,BOXED (lib/marshallers.list:2) */ void -g_cclosure_bluez_marshal_VOID__STRING_BOXED (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_VOID__STRING_BOXED (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { typedef void (*GMarshalFunc_VOID__STRING_BOXED) (gpointer data1, gpointer arg_1, @@ -119,24 +84,25 @@ g_cclosure_bluez_marshal_VOID__STRING_BOXED (GClosure *closure, data2); } -/* VOID:STRING,STRING (lib/marshallers.list:3) */ +/* BOOLEAN:POINTER (lib/marshallers.list:5) */ void -g_cclosure_bluez_marshal_VOID__STRING_STRING (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_BOOLEAN__POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer data2); - register GMarshalFunc_VOID__STRING_STRING callback; + typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1, + gpointer arg_1, + gpointer data2); + register GMarshalFunc_BOOLEAN__POINTER callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; + gboolean v_return; - g_return_if_fail (n_param_values == 3); + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 2); if (G_CCLOSURE_SWAP_DATA (closure)) { @@ -148,32 +114,35 @@ g_cclosure_bluez_marshal_VOID__STRING_STRING (GClosure *closure, data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback); - callback (data1, - g_marshal_value_peek_string (param_values + 1), - g_marshal_value_peek_string (param_values + 2), - data2); + v_return = callback (data1, + g_marshal_value_peek_pointer (param_values + 1), + data2); + + g_value_set_boolean (return_value, v_return); } -/* VOID:STRING,STRING,UINT64 (lib/marshallers.list:4) */ +/* BOOLEAN:BOXED,POINTER,POINTER (lib/marshallers.list:6) */ void -g_cclosure_bluez_marshal_VOID__STRING_STRING_UINT64 (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef void (*GMarshalFunc_VOID__STRING_STRING_UINT64) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - guint64 arg_3, - gpointer data2); - register GMarshalFunc_VOID__STRING_STRING_UINT64 callback; + typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; + gboolean v_return; + g_return_if_fail (return_value != NULL); g_return_if_fail (n_param_values == 4); if (G_CCLOSURE_SWAP_DATA (closure)) @@ -186,34 +155,39 @@ g_cclosure_bluez_marshal_VOID__STRING_STRING_UINT64 (GClosure *closure, data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_VOID__STRING_STRING_UINT64) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback); - callback (data1, - g_marshal_value_peek_string (param_values + 1), - g_marshal_value_peek_string (param_values + 2), - g_marshal_value_peek_uint64 (param_values + 3), - data2); + v_return = callback (data1, + g_marshal_value_peek_boxed (param_values + 1), + g_marshal_value_peek_pointer (param_values + 2), + g_marshal_value_peek_pointer (param_values + 3), + data2); + + g_value_set_boolean (return_value, v_return); } -/* VOID:STRING,STRING,STRING (lib/marshallers.list:5) */ +/* BOOLEAN:BOXED,UINT,UCHAR,POINTER (lib/marshallers.list:7) */ void -g_cclosure_bluez_marshal_VOID__STRING_STRING_STRING (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT_UCHAR_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef void (*GMarshalFunc_VOID__STRING_STRING_STRING) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer arg_3, - gpointer data2); - register GMarshalFunc_VOID__STRING_STRING_STRING callback; + typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_UINT_UCHAR_POINTER) (gpointer data1, + gpointer arg_1, + guint arg_2, + guchar arg_3, + gpointer arg_4, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOXED_UINT_UCHAR_POINTER callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; + gboolean v_return; - g_return_if_fail (n_param_values == 4); + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 5); if (G_CCLOSURE_SWAP_DATA (closure)) { @@ -225,33 +199,38 @@ g_cclosure_bluez_marshal_VOID__STRING_STRING_STRING (GClosure *closure, data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_VOID__STRING_STRING_STRING) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_BOOLEAN__BOXED_UINT_UCHAR_POINTER) (marshal_data ? marshal_data : cc->callback); - callback (data1, - g_marshal_value_peek_string (param_values + 1), - g_marshal_value_peek_string (param_values + 2), - g_marshal_value_peek_string (param_values + 3), - data2); + v_return = callback (data1, + g_marshal_value_peek_boxed (param_values + 1), + g_marshal_value_peek_uint (param_values + 2), + g_marshal_value_peek_uchar (param_values + 3), + g_marshal_value_peek_pointer (param_values + 4), + data2); + + g_value_set_boolean (return_value, v_return); } -/* VOID:BOXED,STRING,STRING (lib/marshallers.list:6) */ +/* BOOLEAN:BOXED,UINT,POINTER (lib/marshallers.list:8) */ void -g_cclosure_bluez_marshal_VOID__BOXED_STRING_STRING (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef void (*GMarshalFunc_VOID__BOXED_STRING_STRING) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer arg_3, - gpointer data2); - register GMarshalFunc_VOID__BOXED_STRING_STRING callback; + typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_UINT_POINTER) (gpointer data1, + gpointer arg_1, + guint arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOXED_UINT_POINTER callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; + gboolean v_return; + g_return_if_fail (return_value != NULL); g_return_if_fail (n_param_values == 4); if (G_CCLOSURE_SWAP_DATA (closure)) @@ -264,34 +243,38 @@ g_cclosure_bluez_marshal_VOID__BOXED_STRING_STRING (GClosure *closure, data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_VOID__BOXED_STRING_STRING) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_BOOLEAN__BOXED_UINT_POINTER) (marshal_data ? marshal_data : cc->callback); - callback (data1, - g_marshal_value_peek_boxed (param_values + 1), - g_marshal_value_peek_string (param_values + 2), - g_marshal_value_peek_string (param_values + 3), - data2); + v_return = callback (data1, + g_marshal_value_peek_boxed (param_values + 1), + g_marshal_value_peek_uint (param_values + 2), + g_marshal_value_peek_pointer (param_values + 3), + data2); + + g_value_set_boolean (return_value, v_return); } -/* BOOLEAN:POINTER (lib/marshallers.list:9) */ +/* BOOLEAN:BOXED,STRING,POINTER (lib/marshallers.list:9) */ void -g_cclosure_bluez_marshal_BOOLEAN__POINTER (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1, - gpointer arg_1, - gpointer data2); - register GMarshalFunc_BOOLEAN__POINTER callback; + typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; gboolean v_return; g_return_if_fail (return_value != NULL); - g_return_if_fail (n_param_values == 2); + g_return_if_fail (n_param_values == 4); if (G_CCLOSURE_SWAP_DATA (closure)) { @@ -303,10 +286,12 @@ g_cclosure_bluez_marshal_BOOLEAN__POINTER (GClosure *closure, data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (marshal_data ? marshal_data : cc->callback); v_return = callback (data1, - g_marshal_value_peek_pointer (param_values + 1), + g_marshal_value_peek_boxed (param_values + 1), + g_marshal_value_peek_string (param_values + 2), + g_marshal_value_peek_pointer (param_values + 3), data2); g_value_set_boolean (return_value, v_return); @@ -314,12 +299,12 @@ g_cclosure_bluez_marshal_BOOLEAN__POINTER (GClosure *closure, /* BOOLEAN:STRING,POINTER (lib/marshallers.list:10) */ void -g_cclosure_bluez_marshal_BOOLEAN__STRING_POINTER (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_BOOLEAN__STRING_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_POINTER) (gpointer data1, gpointer arg_1, @@ -353,27 +338,106 @@ g_cclosure_bluez_marshal_BOOLEAN__STRING_POINTER (GClosure *closure, g_value_set_boolean (return_value, v_return); } -/* BOOLEAN:BOXED,STRING,POINTER (lib/marshallers.list:11) */ +/* VOID:INT,INT (lib/marshallers.list:13) */ void -g_cclosure_bluez_marshal_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_VOID__INT_INT (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer arg_3, - gpointer data2); - register GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER callback; + typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1, + gint arg_1, + gint arg_2, + gpointer data2); + register GMarshalFunc_VOID__INT_INT callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_int (param_values + 1), + g_marshal_value_peek_int (param_values + 2), + data2); +} + +/* VOID:STRING,BOOLEAN (lib/marshallers.list:14) */ +void +g_cclosure_bt_marshal_VOID__STRING_BOOLEAN (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__STRING_BOOLEAN) (gpointer data1, + gpointer arg_1, + gboolean arg_2, + gpointer data2); + register GMarshalFunc_VOID__STRING_BOOLEAN callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__STRING_BOOLEAN) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_boolean (param_values + 2), + data2); +} + +/* BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER (lib/marshallers.list:17) */ +void +g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer arg_3, + gpointer arg_4, + gint arg_5, + gint arg_6, + gpointer arg_7, + gpointer arg_8, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; gboolean v_return; g_return_if_fail (return_value != NULL); - g_return_if_fail (n_param_values == 4); + g_return_if_fail (n_param_values == 9); if (G_CCLOSURE_SWAP_DATA (closure)) { @@ -385,32 +449,37 @@ g_cclosure_bluez_marshal_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure, data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback); v_return = callback (data1, g_marshal_value_peek_boxed (param_values + 1), g_marshal_value_peek_string (param_values + 2), - g_marshal_value_peek_pointer (param_values + 3), + g_marshal_value_peek_string (param_values + 3), + g_marshal_value_peek_string (param_values + 4), + g_marshal_value_peek_int (param_values + 5), + g_marshal_value_peek_int (param_values + 6), + g_marshal_value_peek_pointer (param_values + 7), + g_marshal_value_peek_pointer (param_values + 8), data2); g_value_set_boolean (return_value, v_return); } -/* BOOLEAN:BOXED,POINTER,POINTER (lib/marshallers.list:12) */ +/* BOOLEAN:BOXED,UINT64,POINTER (lib/marshallers.list:20) */ void -g_cclosure_bluez_marshal_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT64_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer arg_3, - gpointer data2); - register GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER callback; + typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_UINT64_POINTER) (gpointer data1, + gpointer arg_1, + guint64 arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOXED_UINT64_POINTER callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; gboolean v_return; @@ -428,38 +497,37 @@ g_cclosure_bluez_marshal_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure, data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_BOOLEAN__BOXED_UINT64_POINTER) (marshal_data ? marshal_data : cc->callback); v_return = callback (data1, g_marshal_value_peek_boxed (param_values + 1), - g_marshal_value_peek_pointer (param_values + 2), + g_marshal_value_peek_uint64 (param_values + 2), g_marshal_value_peek_pointer (param_values + 3), data2); g_value_set_boolean (return_value, v_return); } -/* BOOLEAN:BOXED,UINT,POINTER (lib/marshallers.list:13) */ +/* BOOLEAN:BOXED,POINTER (lib/marshallers.list:21) */ void -g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT_POINTER (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_UINT_POINTER) (gpointer data1, - gpointer arg_1, - guint arg_2, - gpointer arg_3, - gpointer data2); - register GMarshalFunc_BOOLEAN__BOXED_UINT_POINTER callback; + typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOXED_POINTER callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; gboolean v_return; g_return_if_fail (return_value != NULL); - g_return_if_fail (n_param_values == 4); + g_return_if_fail (n_param_values == 3); if (G_CCLOSURE_SWAP_DATA (closure)) { @@ -471,39 +539,34 @@ g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT_POINTER (GClosure *closure, data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_BOOLEAN__BOXED_UINT_POINTER) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback); v_return = callback (data1, g_marshal_value_peek_boxed (param_values + 1), - g_marshal_value_peek_uint (param_values + 2), - g_marshal_value_peek_pointer (param_values + 3), + g_marshal_value_peek_pointer (param_values + 2), data2); g_value_set_boolean (return_value, v_return); } -/* BOOLEAN:BOXED,UINT,UCHAR,POINTER (lib/marshallers.list:14) */ +/* VOID:STRING,STRING (lib/marshallers.list:25) */ void -g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT_UCHAR_POINTER (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) +g_cclosure_bt_marshal_VOID__STRING_STRING (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) { - typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_UINT_UCHAR_POINTER) (gpointer data1, - gpointer arg_1, - guint arg_2, - guchar arg_3, - gpointer arg_4, - gpointer data2); - register GMarshalFunc_BOOLEAN__BOXED_UINT_UCHAR_POINTER callback; + typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer data2); + register GMarshalFunc_VOID__STRING_STRING callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; - gboolean v_return; - g_return_if_fail (return_value != NULL); - g_return_if_fail (n_param_values == 5); + g_return_if_fail (n_param_values == 3); if (G_CCLOSURE_SWAP_DATA (closure)) { @@ -515,15 +578,163 @@ g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT_UCHAR_POINTER (GClosure *closur data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } - callback = (GMarshalFunc_BOOLEAN__BOXED_UINT_UCHAR_POINTER) (marshal_data ? marshal_data : cc->callback); + callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback); - v_return = callback (data1, - g_marshal_value_peek_boxed (param_values + 1), - g_marshal_value_peek_uint (param_values + 2), - g_marshal_value_peek_uchar (param_values + 3), - g_marshal_value_peek_pointer (param_values + 4), - data2); + callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_string (param_values + 2), + data2); +} - g_value_set_boolean (return_value, v_return); +/* VOID:UINT64 (lib/marshallers.list:26) */ +void +g_cclosure_bt_marshal_VOID__UINT64 (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__UINT64) (gpointer data1, + guint64 arg_1, + gpointer data2); + register GMarshalFunc_VOID__UINT64 callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 2); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__UINT64) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_uint64 (param_values + 1), + data2); +} + +/* VOID:STRING,STRING,UINT64 (lib/marshallers.list:27) */ +void +g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64 (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__STRING_STRING_UINT64) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + guint64 arg_3, + gpointer data2); + register GMarshalFunc_VOID__STRING_STRING_UINT64 callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 4); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__STRING_STRING_UINT64) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_string (param_values + 2), + g_marshal_value_peek_uint64 (param_values + 3), + data2); +} + +/* VOID:STRING,STRING,STRING (lib/marshallers.list:30) */ +void +g_cclosure_bt_marshal_VOID__STRING_STRING_STRING (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__STRING_STRING_STRING) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_VOID__STRING_STRING_STRING callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 4); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__STRING_STRING_STRING) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_string (param_values + 2), + g_marshal_value_peek_string (param_values + 3), + data2); +} + +/* VOID:BOXED,STRING,STRING (lib/marshallers.list:31) */ +void +g_cclosure_bt_marshal_VOID__BOXED_STRING_STRING (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__BOXED_STRING_STRING) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_VOID__BOXED_STRING_STRING callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 4); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__BOXED_STRING_STRING) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_boxed (param_values + 1), + g_marshal_value_peek_string (param_values + 2), + g_marshal_value_peek_string (param_values + 3), + data2); } diff --git a/src/lib/marshallers.h b/src/lib/marshallers.h index e8d2427..3076e1c 100644 --- a/src/lib/marshallers.h +++ b/src/lib/marshallers.h @@ -1,108 +1,148 @@ -#ifndef __g_cclosure_bluez_marshal_MARSHAL_H__ -#define __g_cclosure_bluez_marshal_MARSHAL_H__ +#ifndef __g_cclosure_bt_marshal_MARSHAL_H__ +#define __g_cclosure_bt_marshal_MARSHAL_H__ #include <glib-object.h> G_BEGIN_DECLS -/* VOID:UINT64 (lib/marshallers.list:1) */ -extern void g_cclosure_bluez_marshal_VOID__UINT64 (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - /* VOID:STRING,BOXED (lib/marshallers.list:2) */ -extern void g_cclosure_bluez_marshal_VOID__STRING_BOXED (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -/* VOID:STRING,STRING (lib/marshallers.list:3) */ -extern void g_cclosure_bluez_marshal_VOID__STRING_STRING (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); +extern void g_cclosure_bt_marshal_VOID__STRING_BOXED (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* BOOLEAN:POINTER (lib/marshallers.list:5) */ +extern void g_cclosure_bt_marshal_BOOLEAN__POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* BOOLEAN:BOXED,POINTER,POINTER (lib/marshallers.list:6) */ +extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); -/* VOID:STRING,STRING,UINT64 (lib/marshallers.list:4) */ -extern void g_cclosure_bluez_marshal_VOID__STRING_STRING_UINT64 (GClosure *closure, +/* BOOLEAN:BOXED,UINT,UCHAR,POINTER (lib/marshallers.list:7) */ +extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT_UCHAR_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* BOOLEAN:BOXED,UINT,POINTER (lib/marshallers.list:8) */ +extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* BOOLEAN:BOXED,STRING,POINTER (lib/marshallers.list:9) */ +extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data); -/* VOID:STRING,STRING,STRING (lib/marshallers.list:5) */ -extern void g_cclosure_bluez_marshal_VOID__STRING_STRING_STRING (GClosure *closure, +/* BOOLEAN:STRING,POINTER (lib/marshallers.list:10) */ +extern void g_cclosure_bt_marshal_BOOLEAN__STRING_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* VOID:INT,INT (lib/marshallers.list:13) */ +extern void g_cclosure_bt_marshal_VOID__INT_INT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* VOID:STRING,BOOLEAN (lib/marshallers.list:14) */ +extern void g_cclosure_bt_marshal_VOID__STRING_BOOLEAN (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER (lib/marshallers.list:17) */ +extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* BOOLEAN:BOXED,UINT64,POINTER (lib/marshallers.list:20) */ +extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT64_POINTER (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data); -/* VOID:BOXED,STRING,STRING (lib/marshallers.list:6) */ -extern void g_cclosure_bluez_marshal_VOID__BOXED_STRING_STRING (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); +/* BOOLEAN:BOXED,POINTER (lib/marshallers.list:21) */ +extern void g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); -/* BOOLEAN:POINTER (lib/marshallers.list:9) */ -extern void g_cclosure_bluez_marshal_BOOLEAN__POINTER (GClosure *closure, +/* VOID:STRING,STRING (lib/marshallers.list:25) */ +extern void g_cclosure_bt_marshal_VOID__STRING_STRING (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data); -/* BOOLEAN:STRING,POINTER (lib/marshallers.list:10) */ -extern void g_cclosure_bluez_marshal_BOOLEAN__STRING_POINTER (GClosure *closure, +/* VOID:UINT64 (lib/marshallers.list:26) */ +extern void g_cclosure_bt_marshal_VOID__UINT64 (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* VOID:STRING,STRING,UINT64 (lib/marshallers.list:27) */ +extern void g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64 (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data); -/* BOOLEAN:BOXED,STRING,POINTER (lib/marshallers.list:11) */ -extern void g_cclosure_bluez_marshal_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -/* BOOLEAN:BOXED,POINTER,POINTER (lib/marshallers.list:12) */ -extern void g_cclosure_bluez_marshal_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -/* BOOLEAN:BOXED,UINT,POINTER (lib/marshallers.list:13) */ -extern void g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT_POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); +/* VOID:STRING,STRING,STRING (lib/marshallers.list:30) */ +extern void g_cclosure_bt_marshal_VOID__STRING_STRING_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); -/* BOOLEAN:BOXED,UINT,UCHAR,POINTER (lib/marshallers.list:14) */ -extern void g_cclosure_bluez_marshal_BOOLEAN__BOXED_UINT_UCHAR_POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); +/* VOID:BOXED,STRING,STRING (lib/marshallers.list:31) */ +extern void g_cclosure_bt_marshal_VOID__BOXED_STRING_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); G_END_DECLS -#endif /* __g_cclosure_bluez_marshal_MARSHAL_H__ */ +#endif /* __g_cclosure_bt_marshal_MARSHAL_H__ */ diff --git a/src/lib/marshallers.list b/src/lib/marshallers.list index 03b73b4..21aed8c 100644 --- a/src/lib/marshallers.list +++ b/src/lib/marshallers.list @@ -1,15 +1,31 @@ -VOID:UINT64 +# [bluez] VOID:STRING,BOXED -VOID:STRING,STRING -VOID:STRING,STRING,UINT64 -VOID:STRING,STRING,STRING -VOID:BOXED,STRING,STRING -# Used by agent +# Used by Agent BOOLEAN:POINTER -BOOLEAN:STRING,POINTER -BOOLEAN:BOXED,STRING,POINTER BOOLEAN:BOXED,POINTER,POINTER -BOOLEAN:BOXED,UINT,POINTER BOOLEAN:BOXED,UINT,UCHAR,POINTER +BOOLEAN:BOXED,UINT,POINTER +BOOLEAN:BOXED,STRING,POINTER +BOOLEAN:STRING,POINTER + +# [obexd] +VOID:INT,INT +VOID:STRING,BOOLEAN + +# Used by OBEXAgent +BOOLEAN:BOXED,STRING,STRING,STRING,INT,INT,POINTER,POINTER +#BOOLEAN:POINTER +#BOOLEAN:BOXED,POINTER,POINTER +BOOLEAN:BOXED,UINT64,POINTER +BOOLEAN:BOXED,POINTER +#BOOLEAN:BOXED,STRING,POINTER +# [ods] +VOID:STRING,STRING +VOID:UINT64 +VOID:STRING,STRING,UINT64 + +# equals +VOID:STRING,STRING,STRING +VOID:BOXED,STRING,STRING diff --git a/src/lib/network_hub.c b/src/lib/network_hub.c deleted file mode 100644 index 16c7044..0000000 --- a/src/lib/network_hub.c +++ /dev/null @@ -1,318 +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 "network_hub.h" - -#define NETWORK_HUB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), NETWORK_HUB_TYPE, NetworkHubPrivate)) - -struct _NetworkHubPrivate { - DBusGProxy *dbus_g_proxy; - - /* Introspection data */ - DBusGProxy *introspection_g_proxy; - gchar *introspection_xml; - - /* Properties */ - gboolean enabled; - gchar *name; - gchar *uuid; -}; - -G_DEFINE_TYPE(NetworkHub, network_hub, G_TYPE_OBJECT); - -enum { - PROP_0, - - PROP_DBUS_OBJECT_PATH, /* readwrite, construct only */ - PROP_ENABLED, /* readwrite */ - PROP_NAME, /* readwrite */ - PROP_UUID /* readonly */ -}; - -static void _network_hub_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void _network_hub_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); - -static void network_hub_dispose(GObject *gobject) -{ - NetworkHub *self = NETWORK_HUB(gobject); - - /* Properties free */ - g_free(self->priv->name); - g_free(self->priv->uuid); - - /* 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(network_hub_parent_class)->dispose(gobject); -} - -static void network_hub_class_init(NetworkHubClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = network_hub_dispose; - - g_type_class_add_private(klass, sizeof(NetworkHubPrivate)); - - /* Properties registration */ - GParamSpec *pspec; - - gobject_class->get_property = _network_hub_get_property; - gobject_class->set_property = _network_hub_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); - - /* boolean Enabled [readwrite] */ - pspec = g_param_spec_boolean("Enabled", NULL, NULL, FALSE, G_PARAM_READWRITE); - g_object_class_install_property(gobject_class, PROP_ENABLED, pspec); - - /* string Name [readwrite] */ - pspec = g_param_spec_string("Name", NULL, NULL, NULL, G_PARAM_READWRITE); - g_object_class_install_property(gobject_class, PROP_NAME, pspec); - - /* string Uuid [readonly] */ - pspec = g_param_spec_string("Uuid", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_UUID, pspec); -} - -static void network_hub_init(NetworkHub *self) -{ - self->priv = NETWORK_HUB_GET_PRIVATE(self); - - g_assert(conn != NULL); -} - -static void network_hub_post_init(NetworkHub *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, "org.bluez", 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_NETWORK_HUB_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_NETWORK_HUB_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, "org.bluez", dbus_object_path, BLUEZ_DBUS_NETWORK_HUB_INTERFACE); - - /* Properties init */ - GHashTable *properties = network_hub_get_properties(self, &error); - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); - g_assert(properties != NULL); - - /* boolean Enabled [readwrite] */ - if (g_hash_table_lookup(properties, "Enabled")) { - self->priv->enabled = g_value_get_boolean(g_hash_table_lookup(properties, "Enabled")); - } else { - self->priv->enabled = FALSE; - } - - /* string Name [readwrite] */ - 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"); - } - - /* string Uuid [readonly] */ - if (g_hash_table_lookup(properties, "Uuid")) { - self->priv->uuid = g_value_dup_string(g_hash_table_lookup(properties, "Uuid")); - } else { - self->priv->uuid = g_strdup("undefined"); - } - - g_hash_table_unref(properties); -} - -static void _network_hub_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - NetworkHub *self = NETWORK_HUB(object); - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - g_value_set_string(value, network_hub_get_dbus_object_path(self)); - break; - - case PROP_ENABLED: - g_value_set_boolean(value, network_hub_get_enabled(self)); - break; - - case PROP_NAME: - g_value_set_string(value, network_hub_get_name(self)); - break; - - case PROP_UUID: - g_value_set_string(value, network_hub_get_uuid(self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void _network_hub_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - NetworkHub *self = NETWORK_HUB(object); - GError *error = NULL; - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - network_hub_post_init(self, g_value_get_string(value)); - break; - - case PROP_ENABLED: - network_hub_set_property(self, "Enabled", value, &error); - break; - - case PROP_NAME: - network_hub_set_property(self, "Name", value, &error); - 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 *network_hub_get_properties(NetworkHub *self, GError **error) -{ - g_assert(NETWORK_HUB_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 SetProperty(string name, variant value) */ -void network_hub_set_property(NetworkHub *self, const gchar *name, const GValue *value, GError **error) -{ - g_assert(NETWORK_HUB_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "SetProperty", error, G_TYPE_STRING, name, G_TYPE_VALUE, value, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* Properties access methods */ -const gchar *network_hub_get_dbus_object_path(NetworkHub *self) -{ - g_assert(NETWORK_HUB_IS(self)); - - return dbus_g_proxy_get_path(self->priv->dbus_g_proxy); -} - -const gboolean network_hub_get_enabled(NetworkHub *self) -{ - g_assert(NETWORK_HUB_IS(self)); - - return self->priv->enabled; -} - -void network_hub_set_enabled(NetworkHub *self, const gboolean value) -{ - g_assert(NETWORK_HUB_IS(self)); - - GError *error = NULL; - - GValue t = {0}; - g_value_init(&t, G_TYPE_BOOLEAN); - g_value_set_boolean(&t, value); - network_hub_set_property(self, "Enabled", &t, &error); - g_value_unset(&t); - - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); -} - -const gchar *network_hub_get_name(NetworkHub *self) -{ - g_assert(NETWORK_HUB_IS(self)); - - return self->priv->name; -} - -void network_hub_set_name(NetworkHub *self, const gchar *value) -{ - g_assert(NETWORK_HUB_IS(self)); - - GError *error = NULL; - - GValue t = {0}; - g_value_init(&t, G_TYPE_STRING); - g_value_set_string(&t, value); - network_hub_set_property(self, "Name", &t, &error); - g_value_unset(&t); - - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); -} - -const gchar *network_hub_get_uuid(NetworkHub *self) -{ - g_assert(NETWORK_HUB_IS(self)); - - return self->priv->uuid; -} - diff --git a/src/lib/network_hub.h b/src/lib/network_hub.h deleted file mode 100644 index f989e5e..0000000 --- a/src/lib/network_hub.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * bluez-tools - a set of tools to manage bluetooth devices for linux - * - * Copyright (C) 2010 Alexander Orlenko <zxteam@gmail.com> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __NETWORK_HUB_H -#define __NETWORK_HUB_H - -#include <glib-object.h> - -#define BLUEZ_DBUS_NETWORK_HUB_INTERFACE "org.bluez.NetworkHub" - -/* - * Type macros - */ -#define NETWORK_HUB_TYPE (network_hub_get_type()) -#define NETWORK_HUB(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NETWORK_HUB_TYPE, NetworkHub)) -#define NETWORK_HUB_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NETWORK_HUB_TYPE)) -#define NETWORK_HUB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NETWORK_HUB_TYPE, NetworkHubClass)) -#define NETWORK_HUB_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NETWORK_HUB_TYPE)) -#define NETWORK_HUB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NETWORK_HUB_TYPE, NetworkHubClass)) - -typedef struct _NetworkHub NetworkHub; -typedef struct _NetworkHubClass NetworkHubClass; -typedef struct _NetworkHubPrivate NetworkHubPrivate; - -struct _NetworkHub { - GObject parent_instance; - - /*< private >*/ - NetworkHubPrivate *priv; -}; - -struct _NetworkHubClass { - GObjectClass parent_class; -}; - -/* used by NETWORK_HUB_TYPE */ -GType network_hub_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ -GHashTable *network_hub_get_properties(NetworkHub *self, GError **error); -void network_hub_set_property(NetworkHub *self, const gchar *name, const GValue *value, GError **error); - -const gchar *network_hub_get_dbus_object_path(NetworkHub *self); -const gboolean network_hub_get_enabled(NetworkHub *self); -void network_hub_set_enabled(NetworkHub *self, const gboolean value); -const gchar *network_hub_get_name(NetworkHub *self); -void network_hub_set_name(NetworkHub *self, const gchar *value); -const gchar *network_hub_get_uuid(NetworkHub *self); - -#endif /* __NETWORK_HUB_H */ - diff --git a/src/lib/network_peer.c b/src/lib/network_peer.c deleted file mode 100644 index 99ad9b3..0000000 --- a/src/lib/network_peer.c +++ /dev/null @@ -1,318 +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 "network_peer.h" - -#define NETWORK_PEER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), NETWORK_PEER_TYPE, NetworkPeerPrivate)) - -struct _NetworkPeerPrivate { - DBusGProxy *dbus_g_proxy; - - /* Introspection data */ - DBusGProxy *introspection_g_proxy; - gchar *introspection_xml; - - /* Properties */ - gboolean enabled; - gchar *name; - gchar *uuid; -}; - -G_DEFINE_TYPE(NetworkPeer, network_peer, G_TYPE_OBJECT); - -enum { - PROP_0, - - PROP_DBUS_OBJECT_PATH, /* readwrite, construct only */ - PROP_ENABLED, /* readwrite */ - PROP_NAME, /* readwrite */ - PROP_UUID /* readonly */ -}; - -static void _network_peer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void _network_peer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); - -static void network_peer_dispose(GObject *gobject) -{ - NetworkPeer *self = NETWORK_PEER(gobject); - - /* Properties free */ - g_free(self->priv->name); - g_free(self->priv->uuid); - - /* 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(network_peer_parent_class)->dispose(gobject); -} - -static void network_peer_class_init(NetworkPeerClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = network_peer_dispose; - - g_type_class_add_private(klass, sizeof(NetworkPeerPrivate)); - - /* Properties registration */ - GParamSpec *pspec; - - gobject_class->get_property = _network_peer_get_property; - gobject_class->set_property = _network_peer_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); - - /* boolean Enabled [readwrite] */ - pspec = g_param_spec_boolean("Enabled", NULL, NULL, FALSE, G_PARAM_READWRITE); - g_object_class_install_property(gobject_class, PROP_ENABLED, pspec); - - /* string Name [readwrite] */ - pspec = g_param_spec_string("Name", NULL, NULL, NULL, G_PARAM_READWRITE); - g_object_class_install_property(gobject_class, PROP_NAME, pspec); - - /* string Uuid [readonly] */ - pspec = g_param_spec_string("Uuid", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_UUID, pspec); -} - -static void network_peer_init(NetworkPeer *self) -{ - self->priv = NETWORK_PEER_GET_PRIVATE(self); - - g_assert(conn != NULL); -} - -static void network_peer_post_init(NetworkPeer *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, "org.bluez", 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_NETWORK_PEER_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_NETWORK_PEER_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, "org.bluez", dbus_object_path, BLUEZ_DBUS_NETWORK_PEER_INTERFACE); - - /* Properties init */ - GHashTable *properties = network_peer_get_properties(self, &error); - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); - g_assert(properties != NULL); - - /* boolean Enabled [readwrite] */ - if (g_hash_table_lookup(properties, "Enabled")) { - self->priv->enabled = g_value_get_boolean(g_hash_table_lookup(properties, "Enabled")); - } else { - self->priv->enabled = FALSE; - } - - /* string Name [readwrite] */ - 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"); - } - - /* string Uuid [readonly] */ - if (g_hash_table_lookup(properties, "Uuid")) { - self->priv->uuid = g_value_dup_string(g_hash_table_lookup(properties, "Uuid")); - } else { - self->priv->uuid = g_strdup("undefined"); - } - - g_hash_table_unref(properties); -} - -static void _network_peer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - NetworkPeer *self = NETWORK_PEER(object); - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - g_value_set_string(value, network_peer_get_dbus_object_path(self)); - break; - - case PROP_ENABLED: - g_value_set_boolean(value, network_peer_get_enabled(self)); - break; - - case PROP_NAME: - g_value_set_string(value, network_peer_get_name(self)); - break; - - case PROP_UUID: - g_value_set_string(value, network_peer_get_uuid(self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void _network_peer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - NetworkPeer *self = NETWORK_PEER(object); - GError *error = NULL; - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - network_peer_post_init(self, g_value_get_string(value)); - break; - - case PROP_ENABLED: - network_peer_set_property(self, "Enabled", value, &error); - break; - - case PROP_NAME: - network_peer_set_property(self, "Name", value, &error); - 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 *network_peer_get_properties(NetworkPeer *self, GError **error) -{ - g_assert(NETWORK_PEER_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 SetProperty(string name, variant value) */ -void network_peer_set_property(NetworkPeer *self, const gchar *name, const GValue *value, GError **error) -{ - g_assert(NETWORK_PEER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "SetProperty", error, G_TYPE_STRING, name, G_TYPE_VALUE, value, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* Properties access methods */ -const gchar *network_peer_get_dbus_object_path(NetworkPeer *self) -{ - g_assert(NETWORK_PEER_IS(self)); - - return dbus_g_proxy_get_path(self->priv->dbus_g_proxy); -} - -const gboolean network_peer_get_enabled(NetworkPeer *self) -{ - g_assert(NETWORK_PEER_IS(self)); - - return self->priv->enabled; -} - -void network_peer_set_enabled(NetworkPeer *self, const gboolean value) -{ - g_assert(NETWORK_PEER_IS(self)); - - GError *error = NULL; - - GValue t = {0}; - g_value_init(&t, G_TYPE_BOOLEAN); - g_value_set_boolean(&t, value); - network_peer_set_property(self, "Enabled", &t, &error); - g_value_unset(&t); - - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); -} - -const gchar *network_peer_get_name(NetworkPeer *self) -{ - g_assert(NETWORK_PEER_IS(self)); - - return self->priv->name; -} - -void network_peer_set_name(NetworkPeer *self, const gchar *value) -{ - g_assert(NETWORK_PEER_IS(self)); - - GError *error = NULL; - - GValue t = {0}; - g_value_init(&t, G_TYPE_STRING); - g_value_set_string(&t, value); - network_peer_set_property(self, "Name", &t, &error); - g_value_unset(&t); - - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); -} - -const gchar *network_peer_get_uuid(NetworkPeer *self) -{ - g_assert(NETWORK_PEER_IS(self)); - - return self->priv->uuid; -} - diff --git a/src/lib/network_peer.h b/src/lib/network_peer.h deleted file mode 100644 index 6ef5746..0000000 --- a/src/lib/network_peer.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * bluez-tools - a set of tools to manage bluetooth devices for linux - * - * Copyright (C) 2010 Alexander Orlenko <zxteam@gmail.com> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __NETWORK_PEER_H -#define __NETWORK_PEER_H - -#include <glib-object.h> - -#define BLUEZ_DBUS_NETWORK_PEER_INTERFACE "org.bluez.NetworkPeer" - -/* - * Type macros - */ -#define NETWORK_PEER_TYPE (network_peer_get_type()) -#define NETWORK_PEER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NETWORK_PEER_TYPE, NetworkPeer)) -#define NETWORK_PEER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NETWORK_PEER_TYPE)) -#define NETWORK_PEER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NETWORK_PEER_TYPE, NetworkPeerClass)) -#define NETWORK_PEER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NETWORK_PEER_TYPE)) -#define NETWORK_PEER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NETWORK_PEER_TYPE, NetworkPeerClass)) - -typedef struct _NetworkPeer NetworkPeer; -typedef struct _NetworkPeerClass NetworkPeerClass; -typedef struct _NetworkPeerPrivate NetworkPeerPrivate; - -struct _NetworkPeer { - GObject parent_instance; - - /*< private >*/ - NetworkPeerPrivate *priv; -}; - -struct _NetworkPeerClass { - GObjectClass parent_class; -}; - -/* used by NETWORK_PEER_TYPE */ -GType network_peer_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ -GHashTable *network_peer_get_properties(NetworkPeer *self, GError **error); -void network_peer_set_property(NetworkPeer *self, const gchar *name, const GValue *value, GError **error); - -const gchar *network_peer_get_dbus_object_path(NetworkPeer *self); -const gboolean network_peer_get_enabled(NetworkPeer *self); -void network_peer_set_enabled(NetworkPeer *self, const gboolean value); -const gchar *network_peer_get_name(NetworkPeer *self); -void network_peer_set_name(NetworkPeer *self, const gchar *value); -const gchar *network_peer_get_uuid(NetworkPeer *self); - -#endif /* __NETWORK_PEER_H */ - diff --git a/src/lib/network_router.c b/src/lib/network_router.c deleted file mode 100644 index c125390..0000000 --- a/src/lib/network_router.c +++ /dev/null @@ -1,318 +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 "network_router.h" - -#define NETWORK_ROUTER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), NETWORK_ROUTER_TYPE, NetworkRouterPrivate)) - -struct _NetworkRouterPrivate { - DBusGProxy *dbus_g_proxy; - - /* Introspection data */ - DBusGProxy *introspection_g_proxy; - gchar *introspection_xml; - - /* Properties */ - gboolean enabled; - gchar *name; - gchar *uuid; -}; - -G_DEFINE_TYPE(NetworkRouter, network_router, G_TYPE_OBJECT); - -enum { - PROP_0, - - PROP_DBUS_OBJECT_PATH, /* readwrite, construct only */ - PROP_ENABLED, /* readwrite */ - PROP_NAME, /* readwrite */ - PROP_UUID /* readonly */ -}; - -static void _network_router_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void _network_router_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); - -static void network_router_dispose(GObject *gobject) -{ - NetworkRouter *self = NETWORK_ROUTER(gobject); - - /* Properties free */ - g_free(self->priv->name); - g_free(self->priv->uuid); - - /* 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(network_router_parent_class)->dispose(gobject); -} - -static void network_router_class_init(NetworkRouterClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = network_router_dispose; - - g_type_class_add_private(klass, sizeof(NetworkRouterPrivate)); - - /* Properties registration */ - GParamSpec *pspec; - - gobject_class->get_property = _network_router_get_property; - gobject_class->set_property = _network_router_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); - - /* boolean Enabled [readwrite] */ - pspec = g_param_spec_boolean("Enabled", NULL, NULL, FALSE, G_PARAM_READWRITE); - g_object_class_install_property(gobject_class, PROP_ENABLED, pspec); - - /* string Name [readwrite] */ - pspec = g_param_spec_string("Name", NULL, NULL, NULL, G_PARAM_READWRITE); - g_object_class_install_property(gobject_class, PROP_NAME, pspec); - - /* string Uuid [readonly] */ - pspec = g_param_spec_string("Uuid", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property(gobject_class, PROP_UUID, pspec); -} - -static void network_router_init(NetworkRouter *self) -{ - self->priv = NETWORK_ROUTER_GET_PRIVATE(self); - - g_assert(conn != NULL); -} - -static void network_router_post_init(NetworkRouter *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, "org.bluez", 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_NETWORK_ROUTER_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_NETWORK_ROUTER_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, "org.bluez", dbus_object_path, BLUEZ_DBUS_NETWORK_ROUTER_INTERFACE); - - /* Properties init */ - GHashTable *properties = network_router_get_properties(self, &error); - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); - g_assert(properties != NULL); - - /* boolean Enabled [readwrite] */ - if (g_hash_table_lookup(properties, "Enabled")) { - self->priv->enabled = g_value_get_boolean(g_hash_table_lookup(properties, "Enabled")); - } else { - self->priv->enabled = FALSE; - } - - /* string Name [readwrite] */ - 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"); - } - - /* string Uuid [readonly] */ - if (g_hash_table_lookup(properties, "Uuid")) { - self->priv->uuid = g_value_dup_string(g_hash_table_lookup(properties, "Uuid")); - } else { - self->priv->uuid = g_strdup("undefined"); - } - - g_hash_table_unref(properties); -} - -static void _network_router_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - NetworkRouter *self = NETWORK_ROUTER(object); - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - g_value_set_string(value, network_router_get_dbus_object_path(self)); - break; - - case PROP_ENABLED: - g_value_set_boolean(value, network_router_get_enabled(self)); - break; - - case PROP_NAME: - g_value_set_string(value, network_router_get_name(self)); - break; - - case PROP_UUID: - g_value_set_string(value, network_router_get_uuid(self)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void _network_router_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - NetworkRouter *self = NETWORK_ROUTER(object); - GError *error = NULL; - - switch (property_id) { - case PROP_DBUS_OBJECT_PATH: - network_router_post_init(self, g_value_get_string(value)); - break; - - case PROP_ENABLED: - network_router_set_property(self, "Enabled", value, &error); - break; - - case PROP_NAME: - network_router_set_property(self, "Name", value, &error); - 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 *network_router_get_properties(NetworkRouter *self, GError **error) -{ - g_assert(NETWORK_ROUTER_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 SetProperty(string name, variant value) */ -void network_router_set_property(NetworkRouter *self, const gchar *name, const GValue *value, GError **error) -{ - g_assert(NETWORK_ROUTER_IS(self)); - - dbus_g_proxy_call(self->priv->dbus_g_proxy, "SetProperty", error, G_TYPE_STRING, name, G_TYPE_VALUE, value, G_TYPE_INVALID, G_TYPE_INVALID); -} - -/* Properties access methods */ -const gchar *network_router_get_dbus_object_path(NetworkRouter *self) -{ - g_assert(NETWORK_ROUTER_IS(self)); - - return dbus_g_proxy_get_path(self->priv->dbus_g_proxy); -} - -const gboolean network_router_get_enabled(NetworkRouter *self) -{ - g_assert(NETWORK_ROUTER_IS(self)); - - return self->priv->enabled; -} - -void network_router_set_enabled(NetworkRouter *self, const gboolean value) -{ - g_assert(NETWORK_ROUTER_IS(self)); - - GError *error = NULL; - - GValue t = {0}; - g_value_init(&t, G_TYPE_BOOLEAN); - g_value_set_boolean(&t, value); - network_router_set_property(self, "Enabled", &t, &error); - g_value_unset(&t); - - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); -} - -const gchar *network_router_get_name(NetworkRouter *self) -{ - g_assert(NETWORK_ROUTER_IS(self)); - - return self->priv->name; -} - -void network_router_set_name(NetworkRouter *self, const gchar *value) -{ - g_assert(NETWORK_ROUTER_IS(self)); - - GError *error = NULL; - - GValue t = {0}; - g_value_init(&t, G_TYPE_STRING); - g_value_set_string(&t, value); - network_router_set_property(self, "Name", &t, &error); - g_value_unset(&t); - - if (error != NULL) { - g_critical("%s", error->message); - } - g_assert(error == NULL); -} - -const gchar *network_router_get_uuid(NetworkRouter *self) -{ - g_assert(NETWORK_ROUTER_IS(self)); - - return self->priv->uuid; -} - diff --git a/src/lib/network_router.h b/src/lib/network_router.h deleted file mode 100644 index a163608..0000000 --- a/src/lib/network_router.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * bluez-tools - a set of tools to manage bluetooth devices for linux - * - * Copyright (C) 2010 Alexander Orlenko <zxteam@gmail.com> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __NETWORK_ROUTER_H -#define __NETWORK_ROUTER_H - -#include <glib-object.h> - -#define BLUEZ_DBUS_NETWORK_ROUTER_INTERFACE "org.bluez.NetworkRouter" - -/* - * Type macros - */ -#define NETWORK_ROUTER_TYPE (network_router_get_type()) -#define NETWORK_ROUTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NETWORK_ROUTER_TYPE, NetworkRouter)) -#define NETWORK_ROUTER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NETWORK_ROUTER_TYPE)) -#define NETWORK_ROUTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NETWORK_ROUTER_TYPE, NetworkRouterClass)) -#define NETWORK_ROUTER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NETWORK_ROUTER_TYPE)) -#define NETWORK_ROUTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NETWORK_ROUTER_TYPE, NetworkRouterClass)) - -typedef struct _NetworkRouter NetworkRouter; -typedef struct _NetworkRouterClass NetworkRouterClass; -typedef struct _NetworkRouterPrivate NetworkRouterPrivate; - -struct _NetworkRouter { - GObject parent_instance; - - /*< private >*/ - NetworkRouterPrivate *priv; -}; - -struct _NetworkRouterClass { - GObjectClass parent_class; -}; - -/* used by NETWORK_ROUTER_TYPE */ -GType network_router_get_type(void) G_GNUC_CONST; - -/* - * Method definitions - */ -GHashTable *network_router_get_properties(NetworkRouter *self, GError **error); -void network_router_set_property(NetworkRouter *self, const gchar *name, const GValue *value, GError **error); - -const gchar *network_router_get_dbus_object_path(NetworkRouter *self); -const gboolean network_router_get_enabled(NetworkRouter *self); -void network_router_set_enabled(NetworkRouter *self, const gboolean value); -const gchar *network_router_get_name(NetworkRouter *self); -void network_router_set_name(NetworkRouter *self, const gchar *value); -const gchar *network_router_get_uuid(NetworkRouter *self); - -#endif /* __NETWORK_ROUTER_H */ - diff --git a/src/lib/obexd-api.h b/src/lib/obexd-api.h new file mode 100644 index 0000000..e299530 --- /dev/null +++ b/src/lib/obexd-api.h @@ -0,0 +1,44 @@ +/* + * + * 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 __OBEXD_API_H +#define __OBEXD_API_H + +/* Global includes */ +#include <glib.h> +#include <dbus/dbus-glib.h> + +#define OBEXD_DBUS_NAME "org.openobex" + +/* OBEXD DBus API */ +#include "obexd/obexagent.h" +#include "obexd/obexclient.h" +#include "obexd/obexclient_file_transfer.h" +#include "obexd/obexclient_session.h" +#include "obexd/obexclient_transfer.h" +#include "obexd/obexmanager.h" +#include "obexd/obexsession.h" +#include "obexd/obextransfer.h" + +#endif /* __OBEXD_API_H */ + diff --git a/src/lib/obexd/obexagent.c b/src/lib/obexd/obexagent.c new file mode 100644 index 0000000..cdf954c --- /dev/null +++ b/src/lib/obexd/obexagent.c @@ -0,0 +1,175 @@ +/* + * + * 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(session_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(session_conn, OBEXAGENT_DBUS_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/obexd/obexagent.h b/src/lib/obexd/obexagent.h new file mode 100644 index 0000000..997ac6d --- /dev/null +++ b/src/lib/obexd/obexagent.h @@ -0,0 +1,98 @@ +/* + * + * 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 OBEXAGENT_DBUS_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_bt_marshal_BOOLEAN__BOXED_STRING_STRING_STRING_INT_INT_POINTER_POINTER, 0}, + { (GCallback) obexagent_cancel, g_cclosure_bt_marshal_BOOLEAN__POINTER, 111}, + { (GCallback) obexagent_release, g_cclosure_bt_marshal_BOOLEAN__POINTER, 140}, + { (GCallback) obexagent_request, g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER_POINTER, 170}, + { (GCallback) obexagent_progress, g_cclosure_bt_marshal_BOOLEAN__BOXED_UINT64_POINTER, 226}, + { (GCallback) obexagent_complete, g_cclosure_bt_marshal_BOOLEAN__BOXED_POINTER, 286}, + { (GCallback) obexagent_error, g_cclosure_bt_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/obexd/obexclient.c b/src/lib/obexd/obexclient.c new file mode 100644 index 0000000..ba78633 --- /dev/null +++ b/src/lib/obexd/obexclient.c @@ -0,0 +1,153 @@ +/* + * + * 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(session_conn != NULL); + + GError *error = NULL; + + /* Getting introspection XML */ + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", OBEXCLIENT_DBUS_PATH, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_xml = NULL; + if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { + g_critical("%s", error->message); + } + g_assert(error == NULL); + + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXCLIENT_DBUS_INTERFACE, "\">", NULL); + if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXCLIENT_DBUS_INTERFACE, OBEXCLIENT_DBUS_PATH); + g_assert(FALSE); + } + g_free(check_intf_regex_str); + + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", OBEXCLIENT_DBUS_PATH, OBEXCLIENT_DBUS_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/obexd/obexclient.h b/src/lib/obexd/obexclient.h new file mode 100644 index 0000000..d999b76 --- /dev/null +++ b/src/lib/obexd/obexclient.h @@ -0,0 +1,71 @@ +/* + * + * 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 OBEXCLIENT_DBUS_PATH "/" +#define OBEXCLIENT_DBUS_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/obexd/obexclient_file_transfer.c b/src/lib/obexd/obexclient_file_transfer.c new file mode 100644 index 0000000..60f44dd --- /dev/null +++ b/src/lib/obexd/obexclient_file_transfer.c @@ -0,0 +1,235 @@ +/* + * + * 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(session_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(session_conn, "org.openobex.client", 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=\"", OBEXCLIENT_FILE_TRANSFER_DBUS_INTERFACE, "\">", NULL); + if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXCLIENT_FILE_TRANSFER_DBUS_INTERFACE, dbus_object_path); + g_assert(FALSE); + } + g_free(check_intf_regex_str); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, OBEXCLIENT_FILE_TRANSFER_DBUS_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/obexd/obexclient_file_transfer.h b/src/lib/obexd/obexclient_file_transfer.h new file mode 100644 index 0000000..5e796b2 --- /dev/null +++ b/src/lib/obexd/obexclient_file_transfer.h @@ -0,0 +1,74 @@ +/* + * + * 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 OBEXCLIENT_FILE_TRANSFER_DBUS_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/obexd/obexclient_session.c b/src/lib/obexd/obexclient_session.c new file mode 100644 index 0000000..810536c --- /dev/null +++ b/src/lib/obexd/obexclient_session.c @@ -0,0 +1,283 @@ +/* + * + * 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(session_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(session_conn, "org.openobex.client", 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=\"", OBEXCLIENT_SESSION_DBUS_INTERFACE, "\">", NULL); + if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXCLIENT_SESSION_DBUS_INTERFACE, dbus_object_path); + g_assert(FALSE); + } + g_free(check_intf_regex_str); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, OBEXCLIENT_SESSION_DBUS_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/obexd/obexclient_session.h b/src/lib/obexd/obexclient_session.h new file mode 100644 index 0000000..87af06d --- /dev/null +++ b/src/lib/obexd/obexclient_session.h @@ -0,0 +1,72 @@ +/* + * + * 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 OBEXCLIENT_SESSION_DBUS_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/obexd/obexclient_transfer.c b/src/lib/obexd/obexclient_transfer.c new file mode 100644 index 0000000..04f7444 --- /dev/null +++ b/src/lib/obexd/obexclient_transfer.c @@ -0,0 +1,275 @@ +/* + * + * 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(session_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(session_conn, "org.openobex.client", 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=\"", OBEXCLIENT_TRANSFER_DBUS_INTERFACE, "\">", NULL); + if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXCLIENT_TRANSFER_DBUS_INTERFACE, dbus_object_path); + g_assert(FALSE); + } + g_free(check_intf_regex_str); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex.client", dbus_object_path, OBEXCLIENT_TRANSFER_DBUS_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/obexd/obexclient_transfer.h b/src/lib/obexd/obexclient_transfer.h new file mode 100644 index 0000000..f84fd69 --- /dev/null +++ b/src/lib/obexd/obexclient_transfer.h @@ -0,0 +1,71 @@ +/* + * + * 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 OBEXCLIENT_TRANSFER_DBUS_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/obexd/obexmanager.c b/src/lib/obexd/obexmanager.c new file mode 100644 index 0000000..f17292d --- /dev/null +++ b/src/lib/obexd/obexmanager.c @@ -0,0 +1,213 @@ +/* + * + * 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_bt_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(session_conn != NULL); + + GError *error = NULL; + + /* Getting introspection XML */ + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", OBEXMANAGER_DBUS_PATH, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_xml = NULL; + if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { + g_critical("%s", error->message); + } + g_assert(error == NULL); + + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXMANAGER_DBUS_INTERFACE, "\">", NULL); + if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXMANAGER_DBUS_INTERFACE, OBEXMANAGER_DBUS_PATH); + g_assert(FALSE); + } + g_free(check_intf_regex_str); + + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", OBEXMANAGER_DBUS_PATH, OBEXMANAGER_DBUS_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/obexd/obexmanager.h b/src/lib/obexd/obexmanager.h new file mode 100644 index 0000000..203fe59 --- /dev/null +++ b/src/lib/obexd/obexmanager.h @@ -0,0 +1,67 @@ +/* + * + * bluez-tools - a set of tools to manage bluetooth devices for linux + * + * Copyright (C) 2010 Alexander Orlenko <zxteam@gmail.com> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __OBEXMANAGER_H +#define __OBEXMANAGER_H + +#include <glib-object.h> + +#define OBEXMANAGER_DBUS_PATH "/" +#define OBEXMANAGER_DBUS_INTERFACE "org.openobex.Manager" + +/* + * Type macros + */ +#define OBEXMANAGER_TYPE (obexmanager_get_type()) +#define OBEXMANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXMANAGER_TYPE, OBEXManager)) +#define OBEXMANAGER_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXMANAGER_TYPE)) +#define OBEXMANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXMANAGER_TYPE, OBEXManagerClass)) +#define OBEXMANAGER_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXMANAGER_TYPE)) +#define OBEXMANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXMANAGER_TYPE, OBEXManagerClass)) + +typedef struct _OBEXManager OBEXManager; +typedef struct _OBEXManagerClass OBEXManagerClass; +typedef struct _OBEXManagerPrivate OBEXManagerPrivate; + +struct _OBEXManager { + GObject parent_instance; + + /*< private >*/ + OBEXManagerPrivate *priv; +}; + +struct _OBEXManagerClass { + GObjectClass parent_class; +}; + +/* used by OBEXMANAGER_TYPE */ +GType obexmanager_get_type(void) G_GNUC_CONST; + +/* + * Method definitions + */ +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/obexd/obexsession.c b/src/lib/obexd/obexsession.c new file mode 100644 index 0000000..8883c1d --- /dev/null +++ b/src/lib/obexd/obexsession.c @@ -0,0 +1,218 @@ +/* + * + * 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(session_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(session_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_xml = NULL; + if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { + g_critical("%s", error->message); + } + g_assert(error == NULL); + + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXSESSION_DBUS_INTERFACE, "\">", NULL); + if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXSESSION_DBUS_INTERFACE, dbus_object_path); + g_assert(FALSE); + } + g_free(check_intf_regex_str); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", dbus_object_path, OBEXSESSION_DBUS_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/obexd/obexsession.h b/src/lib/obexd/obexsession.h new file mode 100644 index 0000000..d39e15f --- /dev/null +++ b/src/lib/obexd/obexsession.h @@ -0,0 +1,68 @@ +/* + * + * bluez-tools - a set of tools to manage bluetooth devices for linux + * + * Copyright (C) 2010 Alexander Orlenko <zxteam@gmail.com> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __OBEXSESSION_H +#define __OBEXSESSION_H + +#include <glib-object.h> + +#define OBEXSESSION_DBUS_INTERFACE "org.openobex.Session" + +/* + * Type macros + */ +#define OBEXSESSION_TYPE (obexsession_get_type()) +#define OBEXSESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OBEXSESSION_TYPE, OBEXSession)) +#define OBEXSESSION_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OBEXSESSION_TYPE)) +#define OBEXSESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OBEXSESSION_TYPE, OBEXSessionClass)) +#define OBEXSESSION_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OBEXSESSION_TYPE)) +#define OBEXSESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OBEXSESSION_TYPE, OBEXSessionClass)) + +typedef struct _OBEXSession OBEXSession; +typedef struct _OBEXSessionClass OBEXSessionClass; +typedef struct _OBEXSessionPrivate OBEXSessionPrivate; + +struct _OBEXSession { + GObject parent_instance; + + /*< private >*/ + OBEXSessionPrivate *priv; +}; + +struct _OBEXSessionClass { + GObjectClass parent_class; +}; + +/* used by OBEXSESSION_TYPE */ +GType obexsession_get_type(void) G_GNUC_CONST; + +/* + * Method definitions + */ +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/obexd/obextransfer.c b/src/lib/obexd/obextransfer.c new file mode 100644 index 0000000..bb08db9 --- /dev/null +++ b/src/lib/obexd/obextransfer.c @@ -0,0 +1,211 @@ +/* + * + * 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_bt_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(session_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(session_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_xml = NULL; + if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { + g_critical("%s", error->message); + } + g_assert(error == NULL); + + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXTRANSFER_DBUS_INTERFACE, "\">", NULL); + if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXTRANSFER_DBUS_INTERFACE, dbus_object_path); + g_assert(FALSE); + } + g_free(check_intf_regex_str); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(session_conn, "org.openobex", dbus_object_path, OBEXTRANSFER_DBUS_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/obexd/obextransfer.h b/src/lib/obexd/obextransfer.h new file mode 100644 index 0000000..99f3084 --- /dev/null +++ b/src/lib/obexd/obextransfer.h @@ -0,0 +1,67 @@ +/* + * + * 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 OBEXTRANSFER_DBUS_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 */ + diff --git a/src/lib/ods-api.h b/src/lib/ods-api.h new file mode 100644 index 0000000..b0644f3 --- /dev/null +++ b/src/lib/ods-api.h @@ -0,0 +1,40 @@ +/* + * + * bluez-tools - a set of tools to manage bluetooth devices for linux + * + * Copyright (C) 2010 Alexander Orlenko <zxteam@gmail.com> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __ODS_API_H +#define __ODS_API_H + +/* Global includes */ +#include <glib.h> +#include <dbus/dbus-glib.h> + +#define ODS_DBUS_NAME "org.openobex" + +/* ODS DBus API */ +#include "ods/obexmanager.h" +#include "ods/obexserver.h" +#include "ods/obexserver_session.h" +#include "ods/obexsession.h" + +#endif /* __ODS_API_H */ + diff --git a/src/lib/obexmanager.c b/src/lib/ods/obexmanager.c index 576e36c..3eb7b10 100644 --- a/src/lib/obexmanager.c +++ b/src/lib/ods/obexmanager.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.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)) @@ -98,7 +99,7 @@ static void obexmanager_class_init(OBEXManagerClass *klass) 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_STRING_STRING, + g_cclosure_bt_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); signals[SESSION_CONNECTED] = g_signal_new("SessionConnected", @@ -113,26 +114,26 @@ static void obexmanager_init(OBEXManager *self) { self->priv = OBEXMANAGER_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.openobex", BLUEZ_DBUS_OBEXMANAGER_PATH, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", OBEXMANAGER_DBUS_PATH, "org.freedesktop.DBus.Introspectable"); self->priv->introspection_xml = NULL; if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { g_critical("%s", error->message); } g_assert(error == NULL); - gchar *check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_OBEXMANAGER_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXMANAGER_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_OBEXMANAGER_INTERFACE, BLUEZ_DBUS_OBEXMANAGER_PATH); + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXMANAGER_DBUS_INTERFACE, OBEXMANAGER_DBUS_PATH); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.openobex", BLUEZ_DBUS_OBEXMANAGER_PATH, BLUEZ_DBUS_OBEXMANAGER_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", OBEXMANAGER_DBUS_PATH, OBEXMANAGER_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/obexmanager.h b/src/lib/ods/obexmanager.h index f5964f2..20e12ea 100644 --- a/src/lib/obexmanager.h +++ b/src/lib/ods/obexmanager.h @@ -26,8 +26,8 @@ #include <glib-object.h> -#define BLUEZ_DBUS_OBEXMANAGER_PATH "/org/openobex" -#define BLUEZ_DBUS_OBEXMANAGER_INTERFACE "org.openobex.Manager" +#define OBEXMANAGER_DBUS_PATH "/org/openobex" +#define OBEXMANAGER_DBUS_INTERFACE "org.openobex.Manager" /* * Type macros diff --git a/src/lib/obexserver.c b/src/lib/ods/obexserver.c index df07a68..ab968b2 100644 --- a/src/lib/obexserver.c +++ b/src/lib/ods/obexserver.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "obexserver.h" #define OBEXSERVER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXSERVER_TYPE, OBEXServerPrivate)) @@ -126,7 +127,7 @@ static void obexserver_class_init(OBEXServerClass *klass) 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_STRING, + g_cclosure_bt_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); signals[SESSION_CREATED] = g_signal_new("SessionCreated", @@ -162,7 +163,7 @@ static void obexserver_init(OBEXServer *self) { self->priv = OBEXSERVER_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void obexserver_post_init(OBEXServer *self, const gchar *dbus_object_path) @@ -174,20 +175,20 @@ static void obexserver_post_init(OBEXServer *self, const gchar *dbus_object_path GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable"); self->priv->introspection_xml = NULL; if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { g_critical("%s", error->message); } g_assert(error == NULL); - gchar *check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_OBEXSERVER_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXSERVER_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_OBEXSERVER_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXSERVER_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.openobex", dbus_object_path, BLUEZ_DBUS_OBEXSERVER_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, OBEXSERVER_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/obexserver.h b/src/lib/ods/obexserver.h index dfea764..f4a3c60 100644 --- a/src/lib/obexserver.h +++ b/src/lib/ods/obexserver.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_OBEXSERVER_INTERFACE "org.openobex.Server" +#define OBEXSERVER_DBUS_INTERFACE "org.openobex.Server" /* * Type macros diff --git a/src/lib/obexserver_session.c b/src/lib/ods/obexserver_session.c index 45f493f..5920517 100644 --- a/src/lib/obexserver_session.c +++ b/src/lib/ods/obexserver_session.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.h" +#include "../dbus-common.h" +#include "../marshallers.h" + #include "obexserver_session.h" #define OBEXSERVER_SESSION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OBEXSERVER_SESSION_TYPE, OBEXServerSessionPrivate)) @@ -133,7 +134,7 @@ static void obexserver_session_class_init(OBEXServerSessionClass *klass) 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_STRING, + g_cclosure_bt_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); signals[TRANSFER_COMPLETED] = g_signal_new("TransferCompleted", @@ -147,14 +148,14 @@ static void obexserver_session_class_init(OBEXServerSessionClass *klass) 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__UINT64, + g_cclosure_bt_marshal_VOID__UINT64, G_TYPE_NONE, 1, G_TYPE_UINT64); signals[TRANSFER_STARTED] = g_signal_new("TransferStarted", G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL, NULL, - g_cclosure_bluez_marshal_VOID__STRING_STRING_UINT64, + g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64); } @@ -162,7 +163,7 @@ static void obexserver_session_init(OBEXServerSession *self) { self->priv = OBEXSERVER_SESSION_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void obexserver_session_post_init(OBEXServerSession *self, const gchar *dbus_object_path) @@ -174,20 +175,20 @@ static void obexserver_session_post_init(OBEXServerSession *self, const gchar *d GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable"); self->priv->introspection_xml = NULL; if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { g_critical("%s", error->message); } g_assert(error == NULL); - gchar *check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_OBEXSERVER_SESSION_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXSERVER_SESSION_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_OBEXSERVER_SESSION_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXSERVER_SESSION_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.openobex", dbus_object_path, BLUEZ_DBUS_OBEXSERVER_SESSION_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, OBEXSERVER_SESSION_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/obexserver_session.h b/src/lib/ods/obexserver_session.h index 53072cd..c1be188 100644 --- a/src/lib/obexserver_session.h +++ b/src/lib/ods/obexserver_session.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_OBEXSERVER_SESSION_INTERFACE "org.openobex.ServerSession" +#define OBEXSERVER_SESSION_DBUS_INTERFACE "org.openobex.ServerSession" /* * Type macros diff --git a/src/lib/obexsession.c b/src/lib/ods/obexsession.c index 368a622..2fde069 100644 --- a/src/lib/obexsession.c +++ b/src/lib/ods/obexsession.c @@ -28,8 +28,9 @@ #include <glib.h> #include <string.h> -#include "dbus-common.h" -#include "marshallers.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)) @@ -143,7 +144,7 @@ static void obexsession_class_init(OBEXSessionClass *klass) 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_STRING, + g_cclosure_bt_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); signals[TRANSFER_COMPLETED] = g_signal_new("TransferCompleted", @@ -157,14 +158,14 @@ static void obexsession_class_init(OBEXSessionClass *klass) 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__UINT64, + g_cclosure_bt_marshal_VOID__UINT64, G_TYPE_NONE, 1, G_TYPE_UINT64); signals[TRANSFER_STARTED] = g_signal_new("TransferStarted", G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL, NULL, - g_cclosure_bluez_marshal_VOID__STRING_STRING_UINT64, + g_cclosure_bt_marshal_VOID__STRING_STRING_UINT64, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64); } @@ -172,7 +173,7 @@ static void obexsession_init(OBEXSession *self) { self->priv = OBEXSESSION_GET_PRIVATE(self); - g_assert(conn != NULL); + g_assert(system_conn != NULL); } static void obexsession_post_init(OBEXSession *self, const gchar *dbus_object_path) @@ -184,20 +185,20 @@ static void obexsession_post_init(OBEXSession *self, const gchar *dbus_object_pa GError *error = NULL; /* Getting introspection XML */ - self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable"); + self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, "org.freedesktop.DBus.Introspectable"); self->priv->introspection_xml = NULL; if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) { g_critical("%s", error->message); } g_assert(error == NULL); - gchar *check_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_OBEXSESSION_INTERFACE, "\">", NULL); + gchar *check_intf_regex_str = g_strconcat("<interface name=\"", OBEXSESSION_DBUS_INTERFACE, "\">", NULL); if (!g_regex_match_simple(check_intf_regex_str, self->priv->introspection_xml, 0, 0)) { - g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_OBEXSESSION_INTERFACE, dbus_object_path); + g_critical("Interface \"%s\" does not exist in \"%s\"", OBEXSESSION_DBUS_INTERFACE, dbus_object_path); g_assert(FALSE); } g_free(check_intf_regex_str); - self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, "org.openobex", dbus_object_path, BLUEZ_DBUS_OBEXSESSION_INTERFACE); + self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(system_conn, "org.openobex", dbus_object_path, OBEXSESSION_DBUS_INTERFACE); /* DBus signals connection */ diff --git a/src/lib/obexsession.h b/src/lib/ods/obexsession.h index a42ff67..93289bf 100644 --- a/src/lib/obexsession.h +++ b/src/lib/ods/obexsession.h @@ -26,7 +26,7 @@ #include <glib-object.h> -#define BLUEZ_DBUS_OBEXSESSION_INTERFACE "org.openobex.Session" +#define OBEXSESSION_DBUS_INTERFACE "org.openobex.Session" /* * Type macros |